@libxai/board 0.17.416 → 0.17.417
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +20 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +20 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,selectionStore,BoardStore}from'@libxai/core';export{Board as BoardModel,BoardStore,Card as CardModel,Column as ColumnModel,DependencyEngine,Store}from'@libxai/core';import {createContext,memo,useRef,useState,forwardRef,useContext,useEffect,
|
|
2
|
-
`)}async function
|
|
3
|
-
`)?`"${e.replace(/"/g,'""')}"`:e}async function
|
|
4
|
-
`);if(t.length<1||!t[0])return {success:!1,errors:["CSV file is empty or invalid"]};let a=gd(t[0]),r=[],o=new Map,s=[];for(let n=1;n<t.length;n++)try{let c=gd(t[n]||"");if(c.length>a.length){s.push(`Line ${n+1}: Too many columns`);continue}if(a.length-c.length>3){s.push(`Line ${n+1}: Column count mismatch (expected ${a.length}, got ${c.length})`);continue}for(;c.length<a.length;)c.push("");let i={};a.forEach((y,k)=>{i[y]=c[k]||"";});let p=i.Column||"Unnamed";o.has(p)||o.set(p,{id:`col-${o.size+1}`,title:p,position:o.size+1,cardIds:[]});let l=o.get(p),f={id:i["Card ID"]||`card-${n}`,title:i.Title||"Untitled",description:i.Description?i.Description:void 0,columnId:l.id,position:l.cardIds.length+1,priority:i.Priority||void 0,labels:i.Labels?i.Labels.split(";").filter(Boolean):void 0,assignedUserIds:i["Assigned Users"]?i["Assigned Users"].split(";").filter(Boolean):void 0,startDate:i["Start Date"]?i["Start Date"]:void 0,endDate:i["End Date"]?i["End Date"]:void 0,createdAt:i["Created At"]?i["Created At"]:void 0,updatedAt:i["Updated At"]?i["Updated At"]:void 0};r.push(f),l.cardIds.push(f.id);}catch(c){s.push(`Line ${n+1}: ${c instanceof Error?c.message:"Unknown error"}`);}return r.length===0?{success:!1,errors:["No valid cards found in CSV",...s]}:{success:!0,cardsImported:r.length,columnsImported:o.size,errors:s.length>0?s:void 0}}catch(t){return {success:false,errors:[`Failed to parse CSV: ${t instanceof Error?t.message:"Unknown error"}`]}}}function gd(e){let t=[],a="",r=false;for(let o=0;o<e.length;o++){let s=e[o],n=e[o+1];s==='"'&&r&&n==='"'?(a+='"',o++):s==='"'?r=!r:s===","&&!r?(t.push(a),a=""):a+=s;}return t.push(a),t}function fd(e,t){switch(t){case "json":return Hu(e);case "csv":return Wu(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function bd(e){return new Promise((t,a)=>{let r=new FileReader;r.onload=o=>{o.target?.result?t(o.target.result):a(new Error("Failed to read file"));},r.onerror=()=>a(new Error("Failed to read file")),r.readAsText(e);})}var $s=createContext(null);function hd(){return useContext($s)}var yd=createContext(null);function vd({children:e,themeName:t}){return jsx(yd.Provider,{value:{themeName:t},children:e})}function wo(){return useContext(yd)}function bt({children:e,container:t}){let[a,r]=useState(false),o=hd(),s=wo();if(useEffect(()=>(r(true),()=>r(false)),[]),!a)return null;let n=t||(typeof document<"u"?document.body:null);if(!n)return null;if(o){let{theme:c,themeName:g}=o,i={"--asakaa-color-background-primary":c.bgPrimary,"--asakaa-color-background-secondary":c.bgSecondary,"--asakaa-color-background-card":c.bgGrid,"--asakaa-color-background-hover":c.hoverBg,"--asakaa-color-text-primary":c.textPrimary,"--asakaa-color-text-secondary":c.textSecondary,"--asakaa-color-text-tertiary":c.textTertiary,"--asakaa-color-text-inverse":c.taskBarHandle||"#FFFFFF","--asakaa-color-border-default":c.border,"--asakaa-color-border-hover":c.borderLight,"--asakaa-color-border-subtle":c.borderLight,"--asakaa-color-interactive-primary":c.accent,"--asakaa-color-interactive-primaryHover":c.accentHover,"--asakaa-color-interactive-primaryBorder":`${c.accent}4D`,"--asakaa-color-interactive-primaryBackground":`${c.accent}1A`,"--asakaa-color-interactive-primaryBackgroundHover":`${c.accent}33`,"--asakaa-color-status-success":c.statusCompleted,"--asakaa-color-status-warning":c.milestone,"--asakaa-color-status-error":c.criticalPath,"--asakaa-color-danger":c.criticalPath,"--asakaa-color-danger-border":`${c.criticalPath}4D`,"--asakaa-color-danger-background":`${c.criticalPath}14`,"--asakaa-color-danger-backgroundHover":`${c.criticalPath}26`};return createPortal(jsx("div",{"data-theme":g,"data-gantt-portal":"true",style:i,children:e}),n)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),n):createPortal(e,n)}var Td={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},Xu="#BDC3C7",Ju=({color:e})=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",fill:e,opacity:"0.9"}),jsx("circle",{cx:"8",cy:"8",r:"6",stroke:e,strokeWidth:"1.5",opacity:"0.3"})]});function to({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,n]=useState({top:0,left:0}),c=useRef(null),g=useRef(null),i=()=>{if(!g.current)return;let y=g.current.getBoundingClientRect(),k=window.innerHeight,C=window.innerWidth,h=160,b=220,u=4,x=y.right-h;x<10&&(x=y.left),x+h>C-10&&(x=C-h-10);let m=k-y.bottom,N=y.top,w;m>=b+u?w=y.bottom+u:N>=b+u?w=y.top-b-u:w=m>=N?y.bottom+u:Math.max(10,y.top-b-u),n({top:w,left:x}),o(true);};useEffect(()=>{let y=k=>{c.current&&!c.current.contains(k.target)&&!g.current?.contains(k.target)&&o(false);};if(r)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[r]),useEffect(()=>{let y=k=>{k.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]);let p=y=>{t(y),o(false);},l=e?Td[e]:null,f=l?.color||Xu;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:g,onClick:()=>r?o(false):i(),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all hover:bg-white/15 hover:scale-110 active:scale-95",style:{background:e?`${f}10`:"transparent",boxShadow:e?`0 0 0 2px ${f}30 inset`:"none"},title:l?.label||"Set priority",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 2L3 14M3 2L13 6L3 8V2Z",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:f,fillOpacity:e?"0.6":"0.4"})})}),r&&jsx(bt,{children:jsxs("div",{ref:c,className:"priority-selector-menu",style:{position:"fixed",top:`${s.top}px`,left:`${s.left}px`,zIndex:99999,minWidth:"160px",maxHeight:"calc(100vh - 40px)",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Priority"})}),jsxs("div",{className:"py-1",children:[Object.entries(Td).map(([y,k])=>jsxs("button",{onClick:()=>p(y),className:"w-full px-3 py-1.5 flex items-center gap-2 text-xs font-medium transition-all active:scale-[0.98] priority-option",style:{color:k.color,background:"transparent"},onMouseEnter:C=>{C.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:C=>{C.currentTarget.style.background="transparent";},children:[jsx(Ju,{color:k.color}),jsx("span",{className:"font-semibold text-sm",children:k.label}),e===y&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},y)),jsx("div",{className:"mt-0.5 pt-0.5 border-t",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsxs("button",{onClick:()=>p(void 0),className:"w-full px-3 py-1.5 flex items-center gap-2 text-xs font-medium transition-all active:scale-[0.98]",style:{color:"var(--modal-v2-text-primary, #e5e5e5)",background:"transparent"},onMouseEnter:y=>{y.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:y=>{y.currentTarget.style.background="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"#9CA3AF",strokeWidth:"1.5",strokeDasharray:"2 2",opacity:"0.6"})}),jsx("span",{className:"font-semibold text-sm",children:"Clear"}),!e&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]})]})})]})}var Zu=[{label:"Today",days:0},{label:"Tomorrow",days:1},{label:"Next Week",days:7},{label:"2 Weeks",days:14},{label:"4 Weeks",days:28},{label:"8 Weeks",days:56}];function Wo({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),g=useRef(null),i=useRef(null),f=(wo()?.themeName||"dark")==="dark",y=()=>{if(!i.current)return;let x=i.current.getBoundingClientRect(),m=window.innerHeight,N=window.innerWidth,w=320,B=380,v=4,I=x.left;I+w>N-10&&(I=N-w-10),I<10&&(I=10);let A=m-x.bottom,T=x.top,W;A>=B+v?W=x.bottom+v:T>=B+v?W=x.top-B-v:W=A>=T?x.bottom+v:Math.max(10,x.top-B-v),c({top:W,left:I}),s(true);};useEffect(()=>{let x=m=>{g.current&&!g.current.contains(m.target)&&!i.current?.contains(m.target)&&s(false);};if(o)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[o]),useEffect(()=>{let x=m=>{m.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o]);let k=x=>{let m=new Date,N=I=>{let A=I.getFullYear(),T=String(I.getMonth()+1).padStart(2,"0"),W=String(I.getDate()).padStart(2,"0");return `${A}-${T}-${W}`},w=N(m),B=new Date(m);B.setDate(B.getDate()+x);let v=N(B);a(w,v),s(false);},C=()=>{if(!e||!t)return "Set date";let x=B=>{if(B instanceof Date)return B;if(typeof B!="string"||!B.match(/^\d{4}-\d{2}-\d{2}$/))return null;let v=B.split("-").map(Number);if(v.length!==3||v.some(W=>isNaN(W)))return null;let I=v[0],A=v[1],T=v[2];return I===void 0||A===void 0||T===void 0?null:new Date(I,A-1,T)},m=x(e),N=x(t);if(!m||!N||isNaN(m.getTime())||isNaN(N.getTime()))return "Set date";let w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${w[m.getMonth()]} ${m.getDate()} \u2013 ${w[N.getMonth()]} ${N.getDate()}`},h=e&&t,u=(()=>{if(!t)return false;let x=typeof t=="string"?new Date(t):t,m=new Date;return m.setHours(0,0,0,0),x<m})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:i,onClick:()=>o?s(false):y(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${u?"asakaa-date-overdue":"asakaa-date"}`,title:h?`${C()}`:"Set date range",children:[jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"2",y:"3",width:"12",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M2 6H14",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M5 2V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("path",{d:"M11 2V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),e&&t&&jsx("span",{className:"whitespace-nowrap",children:C()})]}),o&&jsx(bt,{children:jsxs("div",{ref:g,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,background:f?"#1A1D25":"#FFFFFF",border:`1px solid ${f?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.12)"}`,boxShadow:f?"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)":"0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.08)",zIndex:99999},children:[jsxs("div",{className:"p-4 border-b",style:{borderColor:f?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.08)"},children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:f?"rgba(255, 255, 255, 0.85)":"rgba(0, 0, 0, 0.7)"},children:"Quick Select"}),jsx("div",{className:"grid grid-cols-2 gap-2",children:Zu.map(x=>jsx("button",{onClick:()=>k(x.days),className:"px-3 py-2.5 rounded-lg text-xs font-semibold transition-all active:scale-95",style:{color:f?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",border:`1px solid ${f?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`,backgroundColor:f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)"},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=f?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",m.currentTarget.style.border=`1px solid ${f?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",m.currentTarget.style.border=`1px solid ${f?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:x.label},x.label))})]}),jsxs("div",{className:"p-4",children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:f?"rgba(255, 255, 255, 0.85)":"rgba(0, 0, 0, 0.7)"},children:"Custom Range"}),jsxs("div",{className:"space-y-3",children:[jsx("input",{type:"date",value:e||"",onChange:x=>a(x.target.value,t),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:f?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:f?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:f?"dark":"light"}}),jsx("input",{type:"date",value:t||"",onChange:x=>a(e,x.target.value),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:f?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:f?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:f?"dark":"light"}})]}),(e||t)&&jsx("button",{onClick:()=>{a(void 0,void 0),s(false);},className:"mt-4 w-full px-3 py-2.5 rounded-lg text-sm font-semibold transition-all active:scale-95 border",style:{color:"#ef4444",borderColor:"rgba(239, 68, 68, 0.3)",background:"rgba(239, 68, 68, 0.1)"},onMouseEnter:x=>{x.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function ro({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,n]=useState(false),[c,g]=useState(""),[i,p]=useState({top:0,left:0}),l=useRef(null),f=useRef(null),y=()=>{if(!f.current)return;let u=f.current.getBoundingClientRect(),x=window.innerHeight,m=window.innerWidth,N=300,w=380,B=4,v=u.right-N;v<10&&(v=u.left),v+N>m-10&&(v=m-N-10);let I=x-u.bottom,A=u.top,T;I>=w+B?T=u.bottom+B:A>=w+B?T=u.top-w-B:T=I>=A?u.bottom+B:Math.max(10,u.top-w-B),p({top:T,left:v}),n(true);};useEffect(()=>{let u=x=>{l.current&&!l.current.contains(x.target)&&!f.current?.contains(x.target)&&(n(false),g(""));};if(s)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[s]),useEffect(()=>{let u=x=>{x.key==="Escape"&&(n(false),g(""));};if(s)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]);let k=u=>{let x=e.some(m=>m.id===u.id);a(x?e.filter(m=>m.id!==u.id):[...e,u]);},C=t.filter(u=>u.name.toLowerCase().includes(c.toLowerCase())),h=e.slice(0,o),b=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:f,onClick:()=>s?n(false):y(),className:"flex items-center gap-1 p-0.5 rounded transition-all hover:bg-white/10 hover:scale-105 active:scale-95",title:e.length>0?`${e.length} assigned`:"Assign users",children:e.length>0?jsxs("div",{className:"asakaa-avatar-group",children:[h.map(u=>jsx("div",{className:"asakaa-avatar",title:u.name,children:u.avatar?jsx("img",{src:u.avatar,alt:u.name,className:"asakaa-avatar-img"}):u.initials},u.id)),b>0&&jsxs("div",{className:"asakaa-avatar",children:["+",b]})]}):jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center transition-all",style:{background:"rgba(96, 165, 250, 0.15)",border:"1.5px solid rgba(96, 165, 250, 0.4)",color:"#60a5fa"},children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M8 8a3 3 0 100-6 3 3 0 000 6zM4 14c0-2.21 1.79-4 4-4s4 1.79 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("line",{x1:"13",y1:"5",x2:"13",y2:"9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("line",{x1:"11",y1:"7",x2:"15",y2:"7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})}),s&&jsx(bt,{children:jsxs("div",{ref:l,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${i.top}px`,left:`${i.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.8))"},children:"Assign Users"})}),jsx("div",{className:"px-3 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("input",{type:"text",value:c,onChange:u=>g(u.target.value),placeholder:"Search users...",className:"w-full px-3 py-2.5 rounded-lg text-sm border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.2))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[300px] overflow-y-auto",children:C.length===0?jsx("div",{className:"px-4 py-3 text-sm text-center",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.6))"},children:"No users found"}):C.map(u=>{let x=e.some(m=>m.id===u.id);return jsxs("button",{onClick:()=>k(u),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:m=>{m.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:m=>{m.currentTarget.style.background="transparent";},children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[11px] font-bold flex-shrink-0 shadow-sm",style:{backgroundColor:u.color,color:"#fff"},children:u.avatar?jsx("img",{src:u.avatar,alt:u.name,className:"w-full h-full rounded-full object-cover"}):u.initials}),jsx("span",{className:"font-semibold flex-1 text-left truncate",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.95))"},children:u.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:x?"#3b82f6":"transparent"},children:x?"\u2713":""})]},u.id)})}),e.length>0&&jsx("div",{className:"px-3 py-3 border-t border-white/10",children:jsx("button",{onClick:()=>{a([]),n(false);},className:"w-full px-3 py-2.5 rounded-lg text-sm font-semibold transition-all hover:bg-red-600/30 active:scale-95 border",style:{color:"#f87171",borderColor:"rgba(248, 113, 113, 0.3)",background:"rgba(248, 113, 113, 0.08)"},children:"Clear All"})})]})})]})}function Nn(e,t,a){let r=new Map;e.forEach(g=>{if(g.dependencies&&Array.isArray(g.dependencies)){let i=g.dependencies.map(p=>{if(typeof p=="string")return p;let l=p;return l.taskId||l.targetId||""}).filter(Boolean);r.set(g.id,i);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,n=new Set,c=g=>{if(!s.has(g)){s.add(g),n.add(g);let i=r.get(g)||[];for(let p of i){if(!s.has(p)&&c(p))return true;if(n.has(p))return true}}return n.delete(g),false};return c(a)}function _o({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:n}){let[c,g]=useState(false),[i,p]=useState(""),[l,f]=useState(t.length>0),[y,k]=useState({top:0,left:0}),[C,h]=useState(null),b=useRef(null),u=useRef(null),x=()=>{if(!u.current)return;let v=u.current.getBoundingClientRect(),I=window.innerHeight,A=window.innerWidth,T=300,W=l?380:120,$=4,j=v.right-T;j<10&&(j=v.left),j+T>A-10&&(j=A-T-10);let te=I-v.bottom,oe=v.top,re;te>=W+$?re=v.bottom+$:oe>=W+$?re=v.top-W-$:re=te>=oe?v.bottom+$:Math.max(10,v.top-W-$),k({top:re,left:j}),g(true);};useEffect(()=>{if(!c||!u.current)return;let v=u.current.getBoundingClientRect(),I=window.innerHeight,A=window.innerWidth,T=300,W=l?380:120,$=4,j=v.right-T;j<10&&(j=v.left),j+T>A-10&&(j=A-T-10);let te=I-v.bottom,oe=v.top,re;te>=W+$?re=v.bottom+$:oe>=W+$?re=v.top-W-$:re=te>=oe?v.bottom+$:Math.max(10,v.top-W-$),k({top:re,left:j});},[l,c]),useEffect(()=>{let v=I=>{b.current&&!b.current.contains(I.target)&&!u.current?.contains(I.target)&&(g(false),p(""));};if(c)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]),useEffect(()=>{let v=I=>{I.key==="Escape"&&(g(false),p(""));};if(c)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[c]);let m=v=>{let I=t.includes(v),A=a.find(T=>T.id===v);if(h(null),I){let T=t.filter(W=>W!==v);r(T),T.length===0&&f(false);}else {if(s&&Nn(a,v,e)){let W=`Cannot add "${A?.title||v}" as dependency - would create circular reference`;h(W),n?.(v,A?.title||v),setTimeout(()=>h(null),3e3);return}r([...t,v]),f(true);}},N=()=>{let v=!l;f(v),v||r([]);},w=a.filter(v=>v.id!==e).filter(v=>v.title.toLowerCase().includes(i.toLowerCase())||v.id.toLowerCase().includes(i.toLowerCase())),B=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:u,onClick:()=>c?g(false):x(),className:"flex items-center gap-1 px-2 py-1 rounded transition-all hover:bg-white/5",title:t.length>0?`${t.length} dependencies`:"Add dependencies",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M7 9L9 7M11.5 3.5L10 2C8.89543 0.89543 7.10457 0.89543 6 2C4.89543 3.10457 4.89543 4.89543 6 6L7.5 7.5M4.5 12.5L6 14C7.10457 15.1046 8.89543 15.1046 10 14C11.1046 12.8954 11.1046 11.1046 10 10L8.5 8.5",stroke:B,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:B},children:t.length})]}),c&&jsx(bt,{children:jsxs("div",{ref:b,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${y.top}px`,left:`${y.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[C&&jsxs("div",{className:"px-4 py-3 flex items-center gap-2",style:{background:"rgba(239, 68, 68, 0.15)",borderBottom:"1px solid rgba(239, 68, 68, 0.3)"},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M8 5V8M8 11H8.01M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z",stroke:"#ef4444",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"text-xs font-medium",style:{color:"#ef4444"},children:C})]}),jsx("div",{className:"px-4 py-2 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Task Dependencies"})}),jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsxs("label",{className:"flex items-center gap-2 cursor-pointer group",onClick:N,children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center transition-all",style:{background:l?"#3b82f6":"transparent",borderColor:l?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:l&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{className:"text-sm font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.8))"},children:"Has dependencies"})]})}),l&&jsxs(Fragment,{children:[jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsx("input",{type:"text",value:i,onChange:v=>p(v.target.value),placeholder:"Search by name or ID...",className:"w-full px-3 py-2 rounded-md text-xs border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[280px] overflow-y-auto",children:w.length===0?jsx("div",{className:"px-4 py-3 text-xs text-center",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:"No tasks found"}):w.map(v=>{let I=t.includes(v.id);return jsxs("button",{onClick:()=>m(v.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:A=>{A.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:A=>{A.currentTarget.style.background="transparent";},children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0 mt-0.5 transition-all",style:{background:I?"#3b82f6":"transparent",borderColor:I?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:I&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxs("div",{className:"flex-1 text-left",children:[jsx("div",{className:"font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.9))"},children:v.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:v.id})]})]},v.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),f(false),g(false);},className:"w-full px-3 py-2 rounded-md text-xs font-medium transition-all hover:bg-red-600/20 border border-red-500/30",style:{color:"#E74C3C"},children:"Clear All Dependencies"})})]})})]})}var Dr=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:n,availableUsers:c=[],allCards:g=[]})=>{let{attributes:i,listeners:p,setNodeRef:l,transform:f,transition:y,isDragging:k}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),C={transform:kn.Transform.toString(f),transition:y};if(t)return jsx("div",{ref:l,style:C,...i,...p,onClick:()=>a?.(e),children:t(e)});let h=c.filter(m=>e.assignedUserIds?.includes(m.id)),b=e.progress===100,u=(e.attachments||[]).filter(m=>m.type.startsWith("image/")),x={...C,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:l,style:x,className:d("asakaa-card",k&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...i,...p,onClick:m=>{m.target.closest(".priority-selector, .date-picker, .user-selector, .dependencies-selector")||a?.(e);},children:[e.coverImage&&jsx("div",{className:"asakaa-card-cover mb-3",children:jsx("img",{src:e.coverImage,alt:`Cover for ${e.title}`,className:"w-full h-32 object-cover rounded-md",loading:"lazy",onError:m=>{m.currentTarget.style.display="none";}})}),u.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:u.length===1&&u[0]?jsx("img",{src:u[0].url,alt:u[0].name,className:"w-full h-32 object-cover rounded-md",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:m=>{m.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:u.slice(0,4).map((m,N)=>jsxs("div",{className:"relative",children:[jsx("img",{src:m.url,alt:m.name,className:"w-full h-16 object-cover rounded",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:w=>{w.currentTarget.style.display="none";}}),N===3&&u.length>4&&jsx("div",{className:"absolute inset-0 bg-black/60 rounded flex items-center justify-center",children:jsxs("span",{className:"text-white text-sm font-medium",children:["+",u.length-4]})})]},m.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:b?"line-through":"none",opacity:b?.6:1},children:e.title}),e.description&&jsx("p",{className:"asakaa-card-description mb-3",children:e.description}),jsxs("div",{className:"flex items-center gap-3 mb-3 pt-1",children:[jsx("div",{onClick:m=>m.stopPropagation(),className:"priority-selector",children:jsx(to,{priority:e.priority,onChange:m=>n?.(e.id,{priority:m})})}),jsx("div",{onClick:m=>m.stopPropagation(),className:"date-picker",children:jsx(Wo,{startDate:e.startDate?typeof e.startDate=="string"?e.startDate:e.startDate.toISOString().split("T")[0]:void 0,endDate:e.endDate?typeof e.endDate=="string"?e.endDate:e.endDate.toISOString().split("T")[0]:void 0,onChange:(m,N)=>n?.(e.id,{startDate:m,endDate:N})})}),c.length>0&&jsx("div",{onClick:m=>m.stopPropagation(),className:"user-selector",children:jsx(ro,{assignedUsers:h,availableUsers:c,onChange:m=>n?.(e.id,{assignedUserIds:m.map(N=>N.id)})})}),jsx("div",{onClick:m=>m.stopPropagation(),className:"dependencies-selector",children:jsx(_o,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(m=>typeof m=="string"?m:m.taskId):[],availableTasks:g,onChange:m=>n?.(e.id,{dependencies:m})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(m=>jsx("span",{className:"asakaa-label",children:m},m))}),typeof e.progress=="number"&&jsxs("div",{className:"mt-3 pt-2 border-t border-white/5",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-[10px] text-[#6B7280]",children:"Progreso"}),jsxs("span",{className:"text-[10px] font-medium",style:{color:"#3B82F6"},children:[Math.round(e.progress),"%"]})]}),jsx("div",{className:"h-1.5 rounded-full bg-white/5 overflow-hidden",children:jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progress))}%`,backgroundColor:"#3B82F6"}})})]})]})},(e,t)=>e.card.id===t.card.id&&e.card.title===t.card.title&&e.card.description===t.card.description&&e.card.position===t.card.position&&e.card.columnId===t.card.columnId&&e.card.priority===t.card.priority&&e.card.color===t.card.color&&e.card.progress===t.card.progress&&e.card.startDate===t.card.startDate&&e.card.endDate===t.card.endDate&&e.isSelected===t.isSelected&&JSON.stringify(e.card.labels)===JSON.stringify(t.card.labels)&&JSON.stringify(e.card.assignedUserIds)===JSON.stringify(t.card.assignedUserIds)&&JSON.stringify(e.card.dependencies)===JSON.stringify(t.card.dependencies)&&JSON.stringify(e.card.attachments?.map(a=>a.id))===JSON.stringify(t.card.attachments?.map(a=>a.id)));Dr.displayName="Card";var Dn={todo:{label:"To Do",color:"#94a3b8",icon:"circle"},"in-progress":{label:"In Progress",color:"#60a5fa",icon:"circle-dot"},completed:{label:"Completed",color:"#34d399",icon:"check-circle"}},Id=({icon:e,color:t})=>e==="circle"?jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"})}):e==="circle-dot"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"}),jsx("circle",{cx:"8",cy:"8",r:"3",fill:t})]}):jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:t,fillOpacity:"0.2"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:t,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});function Bd({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),g=useRef(null),i=useRef(null),p=[...Object.entries(Dn).map(([h,b])=>({id:h,label:b.label,color:b.color,icon:b.icon})),...r.filter(h=>!Object.keys(Dn).includes(h.id)).map(h=>({id:h.id,label:h.title,color:h.color||"#8B5CF6",icon:"circle-dot"}))],l=()=>{let h=Dn[e];if(h)return {...h,id:e};let b=r.find(u=>u.id===e);return b?{id:b.id,label:b.title,color:b.color||"#8B5CF6",icon:"circle-dot"}:{...Dn.todo,id:"todo"}},f=()=>{if(!i.current)return;let h=i.current.getBoundingClientRect(),b=window.innerHeight,u=window.innerWidth,x=180,m=280,N=4,w=h.right-x;w<10&&(w=h.left),w+x>u-10&&(w=u-x-10);let B=b-h.bottom,v=h.top,I;B>=m+N?I=h.bottom+N:v>=m+N?I=h.top-m-N:I=B>=v?h.bottom+N:Math.max(10,h.top-m-N),c({top:I,left:w}),s(true);};useEffect(()=>{let h=b=>{g.current&&!g.current.contains(b.target)&&!i.current?.contains(b.target)&&s(false);};if(o)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o]),useEffect(()=>{let h=b=>{b.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[o]);let y=h=>{t(h),s(false);},k=l(),C=k.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:i,onClick:()=>o?s(false):f(),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all hover:bg-white/15 hover:scale-110 active:scale-95",style:{background:`${C}10`,boxShadow:`0 0 0 2px ${C}30 inset`},title:k.label,children:jsx(Id,{icon:k.icon,color:C})}),o&&jsx(bt,{children:jsxs("div",{ref:g,className:"status-selector-menu",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,zIndex:99999,minWidth:"180px",maxHeight:"calc(100vh - 40px)",overflowY:"auto",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Status"})}),jsx("div",{className:"py-1",children:p.map(h=>jsxs("button",{onClick:()=>y(h.id),className:"w-full px-3 py-2 flex items-center gap-2.5 text-sm font-medium transition-all active:scale-[0.98] status-option",style:{color:h.color,background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:b=>{b.currentTarget.style.background="transparent";},children:[jsx(Id,{icon:h.icon,color:h.color}),jsx("span",{className:"font-semibold",children:h.label}),e===h.id&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},h.id))})]})})]})}function Rd({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,n]=useState(false),[c,g]=useState(false),[i,p]=useState(e),[l,f]=useState({top:0,left:0}),y=useRef(null),k=useRef(null),C=useRef(null);useEffect(()=>{if(s&&k.current){let x=k.current.getBoundingClientRect();f({top:x.bottom+window.scrollY+8,left:x.left+window.scrollX});}},[s]),useEffect(()=>{let x=m=>{y.current&&!y.current.contains(m.target)&&!k.current?.contains(m.target)&&(n(false),g(false));};if(s)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[s]),useEffect(()=>{let x=m=>{m.key==="Escape"&&(n(false),g(false),p(e));};if(s)return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[s,e]),useEffect(()=>{c&&C.current&&(C.current.focus(),C.current.select());},[c]);let h=()=>{g(true),p(e);},b=()=>{let x=i.trim();x&&x!==e&&t(x),g(false),n(false),p(e);},u=x=>{x.key==="Enter"?b():x.key==="Escape"&&(g(false),p(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:k,onClick:()=>n(!s),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-white/10",title:"Column options","aria-label":"Column menu",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"3",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"8",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"13",r:"1.5",fill:"currentColor"})]})}),s&&jsx(bt,{children:jsx("div",{ref:y,className:"fixed rounded-xl shadow-2xl border min-w-[200px]",style:{top:`${l.top}px`,left:`${l.left}px`,background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:c?jsxs("div",{className:"p-3",children:[jsx("label",{className:"text-xs font-bold text-white/80 uppercase tracking-wider block mb-2",children:"Rename Column"}),jsx("input",{ref:C,type:"text",value:i,onChange:x=>p(x.target.value),onKeyDown:u,onBlur:b,className:"w-full px-3 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/50 outline-none focus:border-blue-500/50 transition-all",placeholder:"Column name",maxLength:50})]}):jsxs("div",{className:"py-1",children:[jsxs("button",{onClick:h,className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm text-white/90 hover:bg-white/10 transition-all",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M11.5 1.5L14.5 4.5L5 14H2V11L11.5 1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-medium",children:"Rename"})]}),r&&a&&jsxs(Fragment,{children:[jsx("div",{className:"h-px bg-white/10 mx-2 my-1"}),jsxs("button",{onClick:()=>{a(),n(false);},className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm text-red-400 hover:bg-red-500/10 transition-all",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 4H14M5 4V2.5C5 2.22386 5.22386 2 5.5 2H10.5C10.7761 2 11 2.22386 11 2.5V4M12.5 4V13.5C12.5 13.7761 12.2761 14 12 14H4C3.72386 14 3.5 13.7761 3.5 13.5V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M6.5 7V11M9.5 7V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsx("span",{className:"font-medium",children:"Delete"})]})]})]})})})]})}var No=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:n,onCardUpdate:c,availableUsers:g,allCards:i,enableVirtualization:p,cardHeight:l=120,isCollapsed:f,onToggleCollapse:y,onColumnRename:k,onColumnDelete:C,isDeletable:h=false,className:b})=>{let{setNodeRef:u,isOver:x}=useDroppable({id:e.id,data:{type:"column",column:e}}),m=useRef(null),N=p??ld(t.length),w=useVirtualizer({count:t.length,getScrollElement:()=>m.current,estimateSize:()=>l,enabled:N});if(a)return jsx("div",{ref:u,className:b,children:a(e,t)});let v=(()=>{if(!e.wipLimit)return {state:"none",percentage:0};let T=t.length/e.wipLimit*100;return t.length>e.wipLimit?{state:"exceeded",percentage:T}:T>=80?{state:"warning",percentage:T}:T>=60?{state:"approaching",percentage:T}:{state:"ok",percentage:T}})(),I=v.state==="exceeded",A=()=>"asakaa-column-count";return jsxs("div",{ref:u,className:d("asakaa-column",x&&"ring-2 ring-asakaa-accent-blue",I&&"ring-2 ring-asakaa-accent-red",b),children:[o?o(e,t.length):jsxs("div",{className:"asakaa-column-header group",children:[jsx("h2",{className:"asakaa-column-title",children:e.title}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:d(A()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&v.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${v.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[v.state==="exceeded"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#EF4444",opacity:"0.9"}),jsx("path",{d:"M5 5L11 11M11 5L5 11",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}),v.state==="warning"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("path",{d:"M8 1L15 14H1L8 1Z",fill:"#F59E0B",opacity:"0.9"}),jsx("path",{d:"M8 6V9M8 11V11.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"})]}),v.state==="approaching"&&jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M8 1L10 7H14L10 10L12 16L8 12L4 16L6 10L2 7H6L8 1Z",fill:"#FB923C",opacity:"0.9"})}),v.state==="ok"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#10B981",opacity:"0.9"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]}),(k||C)&&jsx(Rd,{columnTitle:e.title,onRename:T=>k?.(e.id,T),onDelete:C?()=>C(e.id):void 0,isDeletable:h}),y&&jsx("button",{onClick:y,className:"text-asakaa-text-tertiary hover:text-asakaa-text-primary","aria-label":f?"Expand column":"Collapse column",children:f?"\u25B6":"\u25BC"})]})]}),!f&&jsx("div",{ref:m,className:"asakaa-column-cards",style:{maxHeight:N?"600px":void 0},children:jsx(SortableContext,{items:t.map(T=>T.id),strategy:verticalListSortingStrategy,children:t.length===0?s?s(e):jsx("div",{className:"asakaa-drop-zone asakaa-empty",children:jsx("p",{children:"Drop cards here"})}):N?jsx("div",{style:{height:`${w.getTotalSize()}px`,position:"relative"},children:w.getVirtualItems().map(T=>{let W=t[T.index];return W?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${T.start}px)`},children:jsx(Dr,{card:W,render:r,onClick:n,onUpdate:c,availableUsers:g,allCards:i})},W.id):null})}):t.map(T=>jsx(Dr,{card:T,render:r,onClick:n,onUpdate:c,availableUsers:g,allCards:i},T.id))})})]})});No.displayName="Column";function Gs({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,n]=useState(e),c=useRef(null);useEffect(()=>{r&&c.current&&(c.current.focus(),c.current.select());},[r]);let g=()=>{let p=s.trim();p&&p!==e?t(p):n(e),o(false);},i=p=>{p.key==="Enter"?g():p.key==="Escape"&&(n(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:p=>n(p.target.value),onBlur:g,onKeyDown:i,className:d("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:d("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}function gg(e,t){let a=e.slice(0,t),r=a.lastIndexOf("@");if(r===-1)return null;let o=a[r-1];if(r>0&&o&&!/\s/.test(o))return null;let s=a.slice(r+1);return /\s/.test(s)?null:{start:r,end:t,query:s.toLowerCase()}}function Wd(e,t){let a=[],r=/@(\S+)/g,o;for(;(o=r.exec(e))!==null;){let s=o[1]?.toLowerCase()??"";if(!s)continue;let n=t.find(c=>c.name.toLowerCase().replace(/\s+/g,"")===s||c.name.toLowerCase()===s);n&&!a.includes(n.id)&&a.push(n.id);}return a}function fg(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function Gd({value:e,onChange:t,onSubmit:a,users:r,placeholder:o,disabled:s=false,isSubmitting:n=false,theme:c="dark",locale:g="es",currentUser:i}){let p=c==="dark",[l,f]=useState(false),[y,k]=useState([]),[C,h]=useState(0),[b,u]=useState(null),x=useRef(null),m=useRef(null),N=useCallback((A,T)=>{let W=gg(A,T);if(u(W),W){let $=r.filter(j=>j.name.toLowerCase().includes(W.query)||j.email&&j.email.toLowerCase().includes(W.query)).slice(0,5);k($),f($.length>0),h(0);}else f(false),k([]);},[r]),w=A=>{let T=A.target.value;t(T),N(T,A.target.selectionStart||0);},B=()=>{x.current&&N(e,x.current.selectionStart||0);},v=useCallback(A=>{if(!b||!x.current)return;let T=e.slice(0,b.start),W=e.slice(b.end),$=`@${A.name.replace(/\s+/g,"")} `,j=T+$+W;t(j),f(false),u(null),setTimeout(()=>{if(x.current){let te=b.start+$.length;x.current.selectionStart=te,x.current.selectionEnd=te,x.current.focus();}},0);},[b,e,t]),I=A=>{if(l&&y.length>0)switch(A.key){case "ArrowDown":A.preventDefault(),h(T=>T<y.length-1?T+1:0);break;case "ArrowUp":A.preventDefault(),h(T=>T>0?T-1:y.length-1);break;case "Enter":{A.preventDefault();let T=y[C];T&&v(T);break}case "Tab":{A.preventDefault();let T=y[C];T&&v(T);break}case "Escape":A.preventDefault(),f(false);break}else A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),a());};return useEffect(()=>{let A=T=>{m.current&&!m.current.contains(T.target)&&x.current&&!x.current.contains(T.target)&&f(false);};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[]),useEffect(()=>{if(l&&m.current){let A=m.current.children[C];A&&A.scrollIntoView({block:"nearest"});}},[C,l]),jsxs("div",{className:"flex items-start gap-2",children:[i&&jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:i.color||"#8B5CF6"},children:i.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:d("flex-1 relative"),children:[jsxs("div",{className:d("flex items-center gap-2 px-3 py-2 rounded-lg",p?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{ref:x,type:"text",value:e,onChange:w,onSelect:B,onKeyDown:I,placeholder:o||(g==="es"?"Escribe un comentario...":"Write a comment..."),disabled:s||n,className:d("flex-1 bg-transparent text-sm outline-none",p?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(s||n)&&"opacity-50")}),jsx("button",{onClick:a,disabled:n||!e.trim()||s,className:d("p-1.5 rounded transition-colors",e.trim()&&!s?"bg-blue-500 text-white hover:bg-blue-600":p?"text-[#6B7280]":"text-gray-400",n&&"opacity-50 cursor-not-allowed"),children:n?jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):jsx(Send,{className:"w-4 h-4"})})]}),jsx(AnimatePresence,{children:l&&y.length>0&&jsx(motion.div,{ref:m,initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},className:d("absolute bottom-full left-0 right-0 mb-1 py-1 rounded-lg shadow-xl z-50","max-h-[200px] overflow-y-auto",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:y.map((A,T)=>jsxs("button",{type:"button",onClick:()=>v(A),className:d("w-full flex items-center gap-3 px-3 py-2 text-left transition-colors",T===C?p?"bg-white/10":"bg-gray-100":p?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:A.color||"#8B5CF6"},children:fg(A.name)}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("p",{className:d("text-sm font-medium truncate",p?"text-white":"text-gray-900"),children:A.name}),A.email&&jsx("p",{className:d("text-xs truncate",p?"text-[#6B7280]":"text-gray-500"),children:A.email})]})]},A.id))})})]})]})}function _d({content:e,theme:t="dark"}){let a=t==="dark",r=[],o=/@(\S+)/g,s=0,n;for(;(n=o.exec(e))!==null;)n.index>s&&r.push({type:"text",value:e.slice(s,n.index)}),r.push({type:"mention",value:n[0]}),s=n.index+n[0].length;return s<e.length&&r.push({type:"text",value:e.slice(s)}),jsx("span",{className:"whitespace-pre-wrap break-words",children:r.map((c,g)=>c.type==="mention"?jsx("span",{className:d("inline-flex items-center px-1 py-0.5 rounded","font-medium text-sm",a?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:c.value},g):jsx("span",{children:c.value},g))})}var An=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function hr({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:n=true}){let[c,g]=useState(false),[i,p]=useState(""),[l,f]=useState(false),[y,k]=useState(An[10]||"#3B82F6"),[C,h]=useState({top:0,left:0}),b=useRef(null),u=useRef(null),x=useRef(null),m=useRef(null),N=t.filter(T=>T.name.toLowerCase().includes(i.toLowerCase())),w=t.some(T=>T.name.toLowerCase()===i.toLowerCase());useEffect(()=>{if(c&&u.current){let T=u.current.getBoundingClientRect();h({top:T.bottom+6,left:T.left});}},[c]),useEffect(()=>{let T=W=>{let $=W.target,j=b.current?.contains($),te=x.current?.contains($);!j&&!te&&(g(false),p(""),f(false));};if(c)return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[c]),useEffect(()=>{c&&m.current&&m.current.focus();},[c]);let B=T=>{let W=e.some($=>$.id===T.id);a(W?e.filter($=>$.id!==T.id):[...e,T]);},v=async()=>{if(!(!r||!i.trim())){f(true);try{let T=await r(i.trim(),y);T&&(a([...e,T]),p(""),k(An[Math.floor(Math.random()*An.length)]||"#3B82F6"));}finally{f(false);}}},I=(T,W)=>{W.stopPropagation(),a(e.filter($=>$.id!==T));},A={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:b,className:"relative",children:[jsxs("button",{ref:u,type:"button",onClick:()=>!s&&g(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:A,disabled:s,children:[jsx(Tag,{className:"w-3.5 h-3.5"}),e.length>0?jsxs("div",{className:"flex items-center gap-1",children:[e.slice(0,2).map(T=>jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",style:{backgroundColor:`${T.color}20`,color:T.color},children:T.name},T.id)),e.length>2&&jsxs("span",{className:"text-xs",style:{color:o.textTertiary},children:["+",e.length-2]})]}):jsx("span",{children:"Agregar"}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:o.textTertiary}})]}),typeof document<"u"&&createPortal(jsx(AnimatePresence,{children:c&&jsxs(motion.div,{ref:x,initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg min-w-[240px]",style:{position:"fixed",top:C.top,left:C.left,zIndex:99999,backgroundColor:o.bgPrimary,border:`1px solid ${o.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:[jsx("div",{className:"p-2 border-b",style:{borderColor:o.border},children:jsx("input",{ref:m,type:"text",value:i,onChange:T=>p(T.target.value),placeholder:"Buscar o crear etiqueta...",className:"w-full px-3 py-1.5 text-sm rounded-md outline-none",style:{backgroundColor:o.bgSecondary,color:o.textPrimary,border:`1px solid ${o.borderLight}`},onKeyDown:T=>{T.key==="Enter"&&i.trim()&&!w&&r&&v();}})}),e.length>0&&jsxs("div",{className:"p-2 border-b",style:{borderColor:o.border},children:[jsx("p",{className:"text-xs mb-1.5",style:{color:o.textTertiary},children:"Seleccionadas"}),jsx("div",{className:"flex flex-wrap gap-1",children:e.map(T=>jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium cursor-pointer hover:opacity-80",style:{backgroundColor:`${T.color}20`,color:T.color},onClick:W=>I(T.id,W),children:[T.name,jsx(X,{className:"w-3 h-3"})]},T.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:N.length>0?N.map(T=>{let W=e.some($=>$.id===T.id);return jsxs("button",{type:"button",onClick:()=>B(T),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:W?`${T.color}15`:"transparent",color:o.textPrimary},onMouseEnter:$=>{W||($.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:$=>{W||($.currentTarget.style.backgroundColor="transparent");},children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:T.color}}),jsx("span",{className:"flex-1 text-left",children:T.name}),W&&jsx(Check,{className:"w-4 h-4",style:{color:T.color}})]},T.id)}):i.trim()?jsx("div",{className:"p-2 text-center text-sm",style:{color:o.textTertiary},children:"No se encontraron etiquetas"}):jsx("div",{className:"p-2 text-center text-sm",style:{color:o.textTertiary},children:"No hay etiquetas disponibles"})}),i.trim()&&!w&&r&&jsxs("div",{className:"p-2 border-t",style:{borderColor:o.border},children:[jsx("div",{className:"flex items-center gap-2 mb-2",children:jsx("p",{className:"text-xs",style:{color:o.textTertiary},children:"Crear nueva etiqueta"})}),jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:An.map(T=>jsx("button",{type:"button",onClick:()=>k(T),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:T,outline:y===T?`2px solid ${T}`:"none",outlineOffset:"2px"}},T))}),jsxs("button",{type:"button",onClick:v,disabled:l,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{backgroundColor:y,color:"#FFFFFF",opacity:l?.7:1},children:[l?jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):jsx(Plus,{className:"w-4 h-4"}),'Crear "',i.trim(),'"']})]})]})}),document.body)]})}function Vs({tag:e,onRemove:t,size:a="sm"}){return jsxs("span",{className:`inline-flex items-center gap-1 rounded-full font-medium ${a==="xs"?"px-1.5 py-0.5 text-[10px]":"px-2 py-0.5 text-xs"}`,style:{backgroundColor:`${e.color}20`,color:e.color},children:[e.name,t&&jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t();},className:"hover:opacity-70",children:jsx(X,{className:"w-3 h-3"})})]})}function jd({tags:e,maxVisible:t=3,size:a="sm"}){if(!e||e.length===0)return null;let r=e.slice(0,t),o=e.length-t;return jsxs("div",{className:"flex flex-wrap gap-1",children:[r.map(s=>jsx(Vs,{tag:s,size:a},s.id)),o>0&&jsxs("span",{className:`inline-flex items-center rounded-full font-medium ${a==="xs"?"px-1.5 py-0.5 text-[10px]":"px-2 py-0.5 text-xs"}`,style:{backgroundColor:"rgba(100,100,100,0.2)",color:"#9CA3AF"},children:["+",o]})]})}var yr=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];function Jd(e,t=[]){if("title"in e&&!("name"in e)){let a=e,r=(a.assignedUserIds||[]).map(o=>{let s=t.find(n=>n.id===o);return s||null}).filter(o=>o!==null);return {id:a.id,name:a.title,startDate:a.startDate?new Date(a.startDate):void 0,endDate:a.endDate?new Date(a.endDate):void 0,progress:a.progress||0,status:a.columnId,priority:a.priority?.toLowerCase(),assignees:r,dependencies:Array.isArray(a.dependencies)?a.dependencies.map(o=>typeof o=="string"?o:o.taskId):[],tags:a.tags,subtasks:a.subtasks?.map(o=>({id:o.id,name:o.title,progress:o.completed?100:0,startDate:new Date,endDate:new Date})),color:a.color,description:a.description}}return e}function Wg(e,t){return {...t,title:e.name,startDate:e.startDate,endDate:e.endDate,progress:e.progress,priority:e.priority?.toUpperCase(),tags:e.tags,description:e.description,color:e.color,columnId:e.status,assignedUserIds:t.assignedUserIds}}function so({task:e,isOpen:t,onClose:a,onTaskUpdate:r,onCardUpdate:o,theme:s="dark",locale:n="es",availableUsers:c=[],availableTags:g=[],onCreateTag:i,attachments:p=[],onUploadAttachments:l,onDeleteAttachment:f,availableTasks:y=[],comments:k=[],onAddComment:C,currentUser:h,mentionableUsers:b=[]}){let u=s==="dark",x={textTertiary:u?"#6B7280":"#9CA3AF",textSecondary:u?"#9CA3AF":"#6B7280",textPrimary:u?"#FFFFFF":"#111827",borderLight:u?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:u?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:u?"#1A1D25":"#FFFFFF",bgSecondary:u?"#0F1117":"#F9FAFB",hoverBg:u?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},m=e&&"title"in e&&!("name"in e),N=e,[w,B]=useState(e?Jd(e,c):null),[v,I]=useState(false),[A,T]=useState(false),[W,$]=useState(false),[j,te]=useState(null),[oe,re]=useState(new Date),[ge,fe]=useState(false),[Ie,M]=useState(false),[R,L]=useState(""),[V,q]=useState(false),[z,ye]=useState(false),[ne,Be]=useState(false),[qe,tt]=useState(""),le=useRef(null),[Je,ct]=useState(""),wt=useRef(null),[vt,U]=useState(""),[me,Ae]=useState(false);useEffect(()=>{if(e){let F=Jd(e,c);B(F),tt(F.description||""),ct(F.name||"");}},[e?.id,c]),useEffect(()=>()=>{le.current&&clearTimeout(le.current),wt.current&&clearTimeout(wt.current);},[]);let Fe=useCallback(F=>{B(F),m&&o&&N?o(Wg(F,N)):r&&r(F);},[m,N,o,r]),je=useCallback(()=>{I(false),T(false),$(false),te(null),M(false),L(""),q(false);},[]),Qe=useCallback((F,Ce)=>{if(!w)return;let Z={...w,[F]:Ce};Fe(Z);},[w,Fe]),Pt=useCallback(F=>{tt(F),le.current&&clearTimeout(le.current),le.current=setTimeout(()=>{if(w){let Ce={...w,description:F};Fe(Ce);}},800);},[w,Fe]),Re=useCallback(F=>{ct(F),wt.current&&clearTimeout(wt.current),wt.current=setTimeout(()=>{if(w&&F.trim()){let Ce={...w,name:F.trim()};Fe(Ce);}},800);},[w,Fe]),J=useCallback(async()=>{if(!(!w||!vt.trim()||!C)){Ae(true);try{let F=Wd(vt,b);await C(w.id,vt.trim(),F.length>0?F:void 0),U("");}finally{Ae(false);}}},[w,vt,C,b]),ve=useCallback(F=>{let Ce=typeof F=="string"?new Date(F):F,Te=new Date().getTime()-Ce.getTime(),we=Math.floor(Te/6e4),Oe=Math.floor(Te/36e5),$e=Math.floor(Te/864e5);return we<1?n==="es"?"Ahora":"Just now":we<60?n==="es"?`Hace ${we} min`:`${we}m ago`:Oe<24?n==="es"?`Hace ${Oe}h`:`${Oe}h ago`:$e<7?n==="es"?`Hace ${$e}d`:`${$e}d ago`:Ce.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})},[n]),He=useCallback(F=>{if(!w)return;let Ce=w.progress||0;F==="completed"?Ce=100:F==="in-progress"&&Ce===0?Ce=10:F==="todo"&&(Ce=0);let Z={...w,status:F,progress:Ce};Fe(Z),I(false);},[w,Fe]),Le=useCallback((F,Ce)=>{if(!w)return;let Z={...w,startDate:F,endDate:Ce};Fe(Z);},[w,Fe]),nt=useCallback(()=>{let F=oe.getFullYear(),Ce=oe.getMonth(),Z=new Date(F,Ce,1),we=new Date(F,Ce+1,0).getDate(),Oe=Z.getDay(),$e=[],dt=new Date(F,Ce,0).getDate();for(let Y=Oe-1;Y>=0;Y--)$e.push({date:new Date(F,Ce-1,dt-Y),isCurrentMonth:false});for(let Y=1;Y<=we;Y++)$e.push({date:new Date(F,Ce,Y),isCurrentMonth:true});let _=42-$e.length;for(let Y=1;Y<=_;Y++)$e.push({date:new Date(F,Ce+1,Y),isCurrentMonth:false});return $e},[oe]),st=useCallback(async F=>{if(F.preventDefault(),F.stopPropagation(),ye(false),!w||!l)return;let Ce=Array.from(F.dataTransfer.files);if(Ce.length!==0){Be(true);try{await l(w.id,Ce);}finally{Be(false);}}},[w,l]),_e=useCallback(async F=>{if(!w||!l||!F.target.files)return;let Ce=Array.from(F.target.files);if(Ce.length!==0){Be(true);try{await l(w.id,Ce);}finally{Be(false);}F.target.value="";}},[w,l]),ea=useCallback(F=>{F.preventDefault(),F.stopPropagation(),ye(true);},[]),ke=useCallback(F=>{F.preventDefault(),F.stopPropagation(),ye(false);},[]),be=useCallback(F=>F<1024?`${F} B`:F<1024*1024?`${(F/1024).toFixed(1)} KB`:`${(F/(1024*1024)).toFixed(1)} MB`,[]),Ke=useCallback(F=>F.startsWith("image/")?Image:F.includes("pdf")||F.includes("document")?FileText:File,[]);return !t||!w?null:jsx(AnimatePresence,{children:t&&w&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:a,className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:d("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",u?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:d("px-6 py-3 border-b flex items-center gap-3",u?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:d("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:d("text-xs px-2 py-0.5 rounded",u?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:d("text-xs font-mono",u?"text-[#6B7280]":"text-gray-400"),children:w.id.slice(0,8)}),jsxs("button",{className:d("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",u?"bg-purple-500/20 text-purple-400 hover:bg-purple-500/30":"bg-purple-100 text-purple-700 hover:bg-purple-200"),children:[jsx(Sparkles,{className:"w-3 h-3"}),"Ask AI"]})]}),jsx("div",{className:"flex-1"}),jsx("button",{className:d("p-1.5 rounded transition-colors",u?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:d("p-1.5 rounded transition-colors",u?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:a,className:d("p-1.5 rounded transition-colors",u?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-5 h-5"})})]}),jsx("div",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("button",{onClick:()=>{let F=w.progress===100?0:100,Z={...w,progress:F,status:F===100?"completed":"todo"};Fe(Z);},className:d("mt-2 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors flex-shrink-0",w.progress===100?"bg-green-500 border-green-500":u?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:w.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("input",{type:"text",value:Je,onChange:F=>Re(F.target.value),placeholder:n==="es"?"Nombre de la tarea...":"Task name...",className:d("text-xl font-semibold flex-1 bg-transparent outline-none border-none px-0 py-0","focus:ring-0 focus:outline-none",w.progress===100?"line-through text-[#6B7280]":u?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400")})]})}),jsxs("div",{className:"px-6 pb-6 flex-1 overflow-y-auto overflow-x-visible",children:[jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-5",children:[jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CheckCircle2,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{je(),I(!v);},className:d("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",w.progress===100||w.status==="completed"?"bg-green-500/20 text-green-400":w.progress&&w.progress>0||w.status==="in-progress"?"bg-blue-500/20 text-blue-400":u?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:w.progress===100||w.status==="completed"?n==="es"?"COMPLETADO":"DONE":w.progress&&w.progress>0||w.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:v&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>I(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:n==="es"?"Por hacer":"To Do",color:"bg-gray-400"},{id:"in-progress",label:n==="es"?"En progreso":"In Progress",color:"bg-blue-500"},{id:"completed",label:n==="es"?"Completado":"Done",color:"bg-green-500"}].map(F=>jsxs("button",{onClick:()=>He(F.id),className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",u?"hover:bg-white/5":"hover:bg-gray-50",w.status===F.id&&(u?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",F.color)}),jsx("span",{className:u?"text-white":"text-gray-900",children:F.label})]},F.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{je(),$(!W);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[w.assignees&&w.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[w.assignees.slice(0,3).map((F,Ce)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:F.color||"#8B5CF6"},title:F.name,children:F.initials||F.name.slice(0,2).toUpperCase()},Ce)),w.assignees.length>3&&jsxs("span",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:["+",w.assignees.length-3]})]}):jsx("span",{className:d("text-sm",u?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:d("w-3 h-3",u?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:W&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>$(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:c.length>0?c.map(F=>{let Ce=w.assignees?.some(Z=>Z.name===F.name);return jsxs("button",{onClick:()=>{let Z=w.assignees||[],Te;Ce?Te=Z.filter(we=>we.name!==F.name):Te=[...Z,F],Qe("assignees",Te);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",u?"hover:bg-white/5":"hover:bg-gray-50",Ce&&(u?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:F.color||"#8B5CF6"},children:F.initials||F.name.slice(0,2).toUpperCase()}),jsx("span",{className:d("flex-1",u?"text-white":"text-gray-900"),children:F.name}),Ce&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},F.name)}):jsx("div",{className:d("px-3 py-4 text-sm text-center",u?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{te(j?null:"start"),re(w.startDate||new Date);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[w.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:d("mx-1",u?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),w.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End")]}),jsx(AnimatePresence,{children:j&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>te(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:d("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:F=>F.stopPropagation(),children:[jsxs("div",{className:d("w-44 py-2 border-r",u?"border-white/10":"border-gray-200"),children:[(()=>{let F=new Date,Ce=new Date(F);Ce.setDate(F.getDate()+1);let Z=new Date(F);Z.setDate(F.getDate()+((6-F.getDay()+7)%7||7));let Te=new Date(F);Te.setDate(F.getDate()+((1-F.getDay()+7)%7||7));let we=new Date(F);we.setDate(F.getDate()+(6-F.getDay()+7)%7+7);let Oe=new Date(F);Oe.setDate(F.getDate()+14);let $e=new Date(F);return $e.setDate(F.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:F,display:F.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:Ce,display:Ce.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:Z,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Te,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:we,display:we.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:Oe,display:Oe.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:$e,display:$e.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((_,Y)=>jsxs("button",{className:d("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",u?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(j==="start"){let se=w.endDate&&_.date>w.endDate?_.date:w.endDate;Le(_.date,se),te("end");}else {let se=w.startDate&&_.date<w.startDate?_.date:w.startDate;Le(se,_.date),te(null);}},children:[jsx("span",{children:_.label}),jsx("span",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:_.display})]},Y))})(),jsx("div",{className:d("border-t mt-2 pt-2",u?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Le(void 0,void 0),te(null);},className:d("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",u?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:n==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:d("text-xs mb-3 px-2 py-1 rounded",u?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:j==="start"?n==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":n==="es"?"\u{1F4C5} Selecciona fecha de fin":"\u{1F4C5} Select end date"}),jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:d("font-medium",u?"text-white":"text-gray-900"),children:oe.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>re(new Date),className:d("p-1 rounded text-sm transition-colors",u?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>re(new Date(oe.getFullYear(),oe.getMonth()-1)),className:d("p-1 rounded",u?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),jsx("button",{onClick:()=>re(new Date(oe.getFullYear(),oe.getMonth()+1)),className:d("p-1 rounded",u?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(F=>jsx("div",{className:d("w-8 h-8 flex items-center justify-center text-xs",u?"text-[#6B7280]":"text-gray-400"),children:F},F))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:nt().map((F,Ce)=>{let Z=F.date.toDateString()===new Date().toDateString(),Te=w.startDate?.toDateString()===F.date.toDateString(),we=w.endDate?.toDateString()===F.date.toDateString(),Oe=Te||we,$e=w.startDate&&w.endDate&&F.date>=w.startDate&&F.date<=w.endDate;return jsx("button",{onClick:()=>{let dt=new Date(F.date);if(j==="start"){let _=w.endDate&&dt>w.endDate?dt:w.endDate;Le(dt,_),te("end");}else {let _=w.startDate&&dt<w.startDate?dt:w.startDate;Le(_,dt),te(null);}},className:d("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!F.isCurrentMonth&&(u?"text-[#4B5563]":"text-gray-300"),F.isCurrentMonth&&(u?"text-white":"text-gray-900"),Z&&"ring-2 ring-[#3B82F6]",Te&&"bg-[#3B82F6] text-white",we&&!Te&&"bg-[#7C3AED] text-white",$e&&!Oe&&(u?"bg-[#7C3AED]/20":"bg-purple-100"),!Oe&&(u?"hover:bg-white/10":"hover:bg-gray-100")),children:F.date.getDate()},Ce)})})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{je(),T(!A);},className:d("text-xs px-2 py-1 rounded font-medium transition-all hover:ring-2 hover:ring-white/20",w.priority==="high"||w.priority==="urgent"?"bg-red-500/20 text-red-400":w.priority==="medium"?"bg-yellow-500/20 text-yellow-400":w.priority==="low"?"bg-green-500/20 text-green-400":u?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:w.priority?w.priority==="high"||w.priority==="urgent"?n==="es"?"Alta":"High":w.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:A&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>T(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:n==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:n==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:n==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:n==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:n==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(F=>jsxs("button",{onClick:()=>{Qe("priority",F.id),T(false);},className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",u?"hover:bg-white/5":"hover:bg-gray-50",w.priority===F.id&&(u?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",F.color)}),jsx("span",{className:u?"text-white":"text-gray-900",children:F.label})]},F.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:d("text-sm",u?"text-white":"text-gray-900"),children:w.startDate&&w.endDate?`${Math.ceil((w.endDate.getTime()-w.startDate.getTime())/(1e3*60*60*24))} ${n==="es"?"d\xEDas":"days"}`:n==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:d("w-4 h-4 rounded-full border-2",u?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[ge?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:w.progress||0,onChange:F=>{let Ce=parseInt(F.target.value),Z=w.status;Ce===100?Z="completed":Ce>0?Z="in-progress":Z="todo";let Te={...w,progress:Ce,status:Z};Fe(Te);},onBlur:()=>fe(false),className:d("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",u?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>fe(true),className:d("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",u?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:d("h-full rounded-full transition-all",w.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${w.progress||0}%`}})}),jsxs("span",{className:d("text-sm font-medium min-w-[40px]",u?"text-white":"text-gray-900"),children:[w.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx(hr,{selectedTags:w.tags||[],availableTags:g,onChange:F=>{Qe("tags",F);},onCreateTag:i,theme:x})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:d("w-4 h-4 mt-1.5",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24 mt-1",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[w.dependencies&&w.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:w.dependencies.map(F=>{let Ce=y.find(Z=>Z.id===F);return jsxs("span",{className:d("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",u?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[Ce?.name||F.slice(0,8),jsx("button",{onClick:()=>{let Z=(w.dependencies||[]).filter(Te=>Te!==F);Qe("dependencies",Z);},className:d("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},F)})}),jsxs("button",{onClick:()=>{je(),M(!Ie);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{className:d("text-sm",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:Ie&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{M(false),L("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:d("p-2 border-b",u?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:R,onChange:F=>L(F.target.value),placeholder:n==="es"?"Buscar tarea...":"Search task...",className:d("w-full px-3 py-2 rounded-md text-sm outline-none",u?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400"),autoFocus:true})}),jsx("div",{className:"max-h-[240px] overflow-y-auto",children:y.length>0?y.filter(F=>F.id!==w.id).filter(F=>R===""||F.name.toLowerCase().includes(R.toLowerCase())).map(F=>{let Ce=w.dependencies?.includes(F.id);return jsxs("button",{onClick:()=>{let Z=w.dependencies||[],Te;Ce?Te=Z.filter(we=>we!==F.id):Te=[...Z,F.id],Qe("dependencies",Te);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",u?"hover:bg-white/5":"hover:bg-gray-50",Ce&&(u?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:d("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",Ce?"bg-blue-500 border-blue-500":u?"border-white/30":"border-gray-300"),children:Ce&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:d("block truncate",u?"text-white":"text-gray-900"),children:F.name}),jsx("span",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:F.id.slice(0,8)})]})]},F.id)}):jsx("div",{className:d("px-3 py-4 text-sm text-center",u?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{je(),q(!V);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:w.color||"#6366F1"}}),jsx("span",{className:d("text-sm",u?"text-white":"text-gray-900"),children:yr.find(F=>F.value===w.color)?.name||(n==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:d("w-3 h-3",u?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:V&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>q(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:yr.map(F=>{let Ce=w.color===F.value;return jsx("button",{onClick:()=>{Qe("color",F.value),q(false);},className:d("w-7 h-7 rounded-full flex items-center justify-center transition-all",Ce&&"ring-2 ring-offset-2",u?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:F.value,outlineColor:Ce?F.value:void 0},title:F.name,children:Ce&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},F.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:w.isMilestone||false,onChange:F=>Qe("isMilestone",F.target.checked),className:d("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",w.isMilestone?"bg-purple-500 border-purple-500":u?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:d("text-sm",u?"text-white":"text-gray-900"),children:n==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:d("text-sm font-semibold",u?"text-white":"text-gray-900"),children:n==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:qe,onChange:F=>Pt(F.target.value),placeholder:n==="es"?"Agregar descripci\xF3n...":"Add description...",className:d("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",u?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400 focus:bg-gray-200")}),jsxs("button",{className:d("flex items-center gap-2 text-sm mt-2 transition-colors",u?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),n==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("text-sm font-semibold mb-3",u?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),n==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("text-sm font-semibold mb-3",u?"text-white":"text-gray-900"),children:n==="es"?"Subtareas":"Subtasks"}),w.subtasks&&w.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:w.subtasks.map(F=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:d("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",F.progress===100?"bg-green-500 border-green-500":u?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:F.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:d("text-sm",F.progress===100?"line-through text-[#6B7280]":u?"text-white":"text-gray-900"),children:F.name})]},F.id))}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),n==="es"?"Agregar subtarea":"Add subtask"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:d("text-sm font-semibold",u?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:d("p-1 rounded transition-colors",u?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(ListChecks,{className:"w-4 h-4"}),n==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:d("text-sm font-semibold mb-3",u?"text-white":"text-gray-900"),children:[n==="es"?"Adjuntos":"Attachments",p.length>0&&jsxs("span",{className:d("ml-2 text-xs font-normal",u?"text-[#6B7280]":"text-gray-400"),children:["(",p.length,")"]})]}),p.length>0&&jsx("div",{className:"space-y-2 mb-4",children:p.map(F=>{let Ce=Ke(F.type),Z=F.type.startsWith("image/");return jsxs("div",{className:d("flex items-center gap-3 p-2 rounded-lg group transition-colors",u?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[Z&&F.thumbnailUrl?jsx("img",{src:F.thumbnailUrl,alt:F.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:d("w-10 h-10 rounded flex items-center justify-center",u?"bg-white/10":"bg-gray-200"),children:jsx(Ce,{className:d("w-5 h-5",u?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:F.url,target:"_blank",rel:"noopener noreferrer",className:d("text-sm font-medium truncate block hover:underline",u?"text-white":"text-gray-900"),children:F.name}),jsx("p",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:be(F.size)})]}),f&&jsx("button",{onClick:()=>f(F.id),className:d("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",u?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:n==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},F.id)})}),jsxs("div",{onDragOver:ea,onDragLeave:ke,onDrop:st,className:d("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",z?u?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":u?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",ne&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:_e,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!l||ne}),ne?jsxs(Fragment,{children:[jsx("div",{className:"w-6 h-6 mx-auto mb-2 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),jsx("p",{className:d("text-sm",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:d("w-6 h-6 mx-auto mb-2",z?"text-blue-500":u?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:d("text-sm",u?"text-[#9CA3AF]":"text-gray-500"),children:z?n==="es"?"Suelta los archivos aqu\xED":"Drop files here":n==="es"?jsxs(Fragment,{children:["Suelta tus archivos aqu\xED o ",jsx("span",{className:"underline",children:"haz clic para subir"})]}):jsxs(Fragment,{children:["Drop your files here or ",jsx("span",{className:"underline",children:"click to upload"})]})}),!l&&jsx("p",{className:d("text-xs mt-1",u?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:d("w-80 border-l flex flex-col",u?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:d("px-4 py-3 border-b",u?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:d("text-sm font-semibold",u?"text-white":"text-gray-900"),children:[n==="es"?"Actividad":"Activity",k.length>0&&jsxs("span",{className:d("ml-2 text-xs font-normal",u?"text-[#6B7280]":"text-gray-400"),children:["(",k.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:k.length>0?jsx("div",{className:"space-y-4",children:k.map(F=>jsxs("div",{className:"flex gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:F.user?.color||"#8B5CF6"},children:F.user?.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:d("text-sm font-medium",u?"text-white":"text-gray-900"),children:F.user?.name||(n==="es"?"Usuario":"User")}),jsx("span",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:ve(F.createdAt)})]}),jsx("div",{className:d("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:jsx(_d,{content:F.content,theme:s})})]})]},F.id))}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:d("w-10 h-10 mb-3",u?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:d("text-sm",u?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:d("p-4 border-t",u?"border-white/10":"border-gray-200"),children:jsx(Gd,{value:vt,onChange:U,onSubmit:J,users:b,placeholder:n==="es"?"Escribe un comentario... (usa @ para mencionar)":"Write a comment... (use @ to mention)",disabled:!C,isSubmitting:me,theme:s,locale:n,currentUser:h})})]})]})]})})}function Xs(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function zr({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:n,style:c,isLoading:g,error:i,children:p,availableTags:l=[],onCreateTag:f,attachmentsByCard:y,onUploadAttachments:k,onDeleteAttachment:C,comments:h,onAddComment:b,currentUser:u,mentionableUsers:x,onTaskOpen:m}){let[N,w]=Xs(),[B,v]=useState(null),I=o?.theme||"dark",A=I==="dark"||I==="neutral",T=A?"dark":"",W=useCallback((V,q)=>{t.onCardUpdate?.(V,q);},[t]),$=useCallback((V,q)=>{t.onColumnUpdate?.(V,{title:q});},[t]),j=useCallback(V=>{t.onColumnDelete?.(V);},[t]),te=["todo","in-progress","completed"],oe=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),re=useMemo(()=>{let V=new Map;return e.columns.forEach(q=>{let z=q.cardIds.map(ye=>e.cards.find(ne=>ne.id===ye)).filter(ye=>ye!==void 0).sort((ye,ne)=>ye.position-ne.position);V.set(q.id,z);}),V},[e.cards,e.columns]),ge=useMemo(()=>e.cards.map(V=>({id:V.id,name:V.title,startDate:V.startDate?new Date(V.startDate):void 0,endDate:V.endDate?new Date(V.endDate):void 0,progress:V.progress||0,status:V.columnId,priority:V.priority?.toLowerCase(),dependencies:Array.isArray(V.dependencies)?V.dependencies.map(q=>typeof q=="string"?q:q.taskId):[]})),[e.cards]),fe=useCallback(V=>{let{active:q}=V,z=e.cards.find(ye=>ye.id===q.id);z&&w({isDragging:true,draggedCardId:z.id,sourceColumnId:z.columnId,targetColumnId:z.columnId});},[e.cards,w]),Ie=useCallback(V=>{let{active:q,over:z}=V;if(!z||!e.cards.find(Be=>Be.id===q.id))return;let ne=null;z.data.current?.type==="column"?ne=z.id:z.data.current?.type==="card"&&(ne=e.cards.find(qe=>qe.id===z.id)?.columnId||null),ne&&ne!==N.targetColumnId&&w({...N,targetColumnId:ne});},[e.cards,N,w]),M=useCallback(async V=>{let{active:q,over:z}=V;if(w({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!z)return;let ye=e.cards.find(tt=>tt.id===q.id);if(!ye)return;let ne,Be;if(z.data.current?.type==="column"){ne=z.id;let tt=re.get(ne)||[];Be=Is(tt,0);}else {let tt=e.cards.find(ct=>ct.id===z.id);if(!tt)return;ne=tt.columnId;let le=re.get(ne)||[],Je=le.findIndex(ct=>ct.id===z.id);Be=Is(le,Je);}let qe=e.columns.find(tt=>tt.id===ne);if(qe&&qe.wipLimit&&qe.wipLimitType==="hard"){let tt=re.get(ne)||[];if(ye.columnId!==ne&&tt.length>=qe.wipLimit){t.onWipLimitExceeded?.(qe,ye);return}}(ye.columnId!==ne||ye.position!==Be)&&await t.onCardMove?.(ye.id,ne,Be);},[e.cards,e.columns,re,t,w]),R=useCallback(V=>{v(V),a?.(V),m?.(V.id);},[a,m]),L=useCallback(V=>{t.onCardUpdate?.(V.id,V),v(V);},[t]);return g?jsx("div",{className:d("asakaa-board",T,n),style:c,children:jsx(ef,{columnCount:3})}):i?jsx("div",{className:d("asakaa-board",T,n),style:c,children:jsx("div",{className:"flex items-center justify-center w-full h-64",children:jsxs("div",{className:"text-center",children:[jsx("p",{className:"text-asakaa-accent-red text-lg font-semibold mb-2",children:"Error loading board"}),jsx("p",{className:"text-asakaa-text-secondary text-sm",children:typeof i=="string"?i:i.message})]})})}):jsxs(vd,{themeName:I,children:[jsxs(DndContext,{sensors:oe,collisionDetection:closestCorners,onDragStart:fe,onDragOver:Ie,onDragEnd:M,children:[jsxs("div",{className:d("asakaa-board",T,n),style:c,"data-theme":I,children:[e.columns.sort((V,q)=>V.position-q.position).map(V=>{let q=re.get(V.id)||[],z=!te.includes(V.id);return jsx(No,{column:V,cards:q,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:R,onCardUpdate:W,onColumnRename:$,onColumnDelete:j,isDeletable:z,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},V.id)}),p]}),jsx(DragOverlay,{children:N.draggedCardId?jsx(Dr,{card:e.cards.find(V=>V.id===N.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]}),jsx(so,{task:B,isOpen:!!B,onClose:()=>v(null),onCardUpdate:L,theme:A?"dark":"light",locale:o?.locale==="es"?"es":"en",availableUsers:s,availableTags:l,onCreateTag:f,attachments:B?y?.get(B.id)||[]:[],onUploadAttachments:k,onDeleteAttachment:C,availableTasks:ge,comments:h,onAddComment:b,currentUser:u,mentionableUsers:x})]})}function ef({columnCount:e}){return jsx(Fragment,{children:Array.from({length:e}).map((t,a)=>jsxs("div",{className:"asakaa-column",children:[jsx("div",{className:"asakaa-skeleton h-8 mb-3"}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx("div",{className:"asakaa-skeleton h-24"}),jsx("div",{className:"asakaa-skeleton h-32"}),jsx("div",{className:"asakaa-skeleton h-28"})]})]},a))})}var nf={bgGrid:"#0F1117",bgSecondary:"#1A1D25",border:"rgba(255, 255, 255, 0.1)",borderLight:"rgba(255, 255, 255, 0.05)",textPrimary:"#E5E7EB",textSecondary:"#9CA3AF",textTertiary:"#6B7280",accent:"#3B82F6",accentLight:"rgba(59, 130, 246, 0.15)",hoverBg:"rgba(255, 255, 255, 0.05)"},sf={bgGrid:"#FFFFFF",bgSecondary:"#F9FAFB",border:"rgba(0, 0, 0, 0.1)",borderLight:"rgba(0, 0, 0, 0.05)",textPrimary:"#111827",textSecondary:"#6B7280",textTertiary:"#9CA3AF",accent:"#3B82F6",accentLight:"rgba(59, 130, 246, 0.1)",hoverBg:"rgba(0, 0, 0, 0.05)"},lf={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},df={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function cf({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let i=p=>{c.current&&!c.current.contains(p.target)&&n(false);};return s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[s]);let g=i=>{t(i),n(false);};return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:()=>n(!s),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:o||r.newTask}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:s?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:s&&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:a.bgSecondary,border:`1px solid ${a.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wider",style:{color:a.textTertiary},children:r.selectColumn}),e.sort((i,p)=>i.position-p.position).map((i,p)=>jsxs(motion.button,{onClick:()=>g(i.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:p<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:p*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:i.color||a.accent}}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:a.textPrimary},children:i.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[i.cardIds.length," ",i.cardIds.length===1?"tarea":"tareas"]})]})]},i.id))]})})})]})}function mf({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,n]=useState(false),[c,g]=useState(null),i=useRef(null);if(useEffect(()=>{let y=k=>{i.current&&!i.current.contains(k.target)&&n(false);};return s&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[s]),!(a||r||o))return null;let l=[{id:"csv",label:t.exportCSV,description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"json",label:t.exportJSON,description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:r},{id:"excel",label:t.exportExcel,description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:o}].filter(y=>y.handler),f=async(y,k)=>{if(k){g(y);try{await k();}catch(C){console.error(`Export ${y} failed:`,C);}finally{g(null),n(false);}}};return jsxs("div",{ref:i,className:"relative",children:[jsxs(motion.button,{onClick:()=>n(!s),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:s?e.accent:e.bgSecondary,border:`1px solid ${s?e.accent:e.borderLight}`,color:s?"#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:t.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:s?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:s&&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-44 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:l.map((y,k)=>jsxs(motion.button,{onClick:()=>f(y.id,y.handler),disabled:c!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:k<l.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:c===y.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):y.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:y.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:y.description})]})]},y.id))})})})]})}function pf({onClick:e,label:t}){return jsxs(motion.button,{onClick:e,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:t})]})}function Zs({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:n,onExportJSON:c,onExportExcel:g,translations:i}){let p=r==="dark"?nf:sf,l={...o==="es"?lf:df,...i},f=n||c||g;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:p.bgGrid,borderColor:p.border},children:jsxs("div",{className:"flex items-center gap-3",children:[f&&jsxs(Fragment,{children:[jsx(mf,{theme:p,t:l,onExportCSV:n,onExportJSON:c,onExportExcel:g}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:p.borderLight}})]}),t&&(s?jsx(cf,{columns:e,onSelect:t,theme:p,t:l,createTaskLabel:a}):jsx(pf,{onClick:()=>t(),label:a||l.newTask}))]})})}function ei({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,n]=useState(false),[c,g]=useState(""),i=useCallback(()=>{let f=c.trim();f&&(e(f),g(""),n(false));},[c,e]),p=useCallback(f=>{f.key==="Enter"?(f.preventDefault(),i()):f.key==="Escape"&&(g(""),n(false));},[i]),l=useCallback(()=>{setTimeout(()=>{c.trim()||n(false);},150);},[c]);return s?jsx("div",{className:d("asakaa-add-column asakaa-add-column--editing",t),children:jsxs("div",{className:"asakaa-add-column__input-wrapper",children:[jsx("input",{type:"text",value:c,onChange:f=>g(f.target.value),onKeyDown:p,onBlur:l,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:i,disabled:!c.trim(),className:"asakaa-add-column__submit",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}),jsx("button",{onClick:()=>{g(""),n(false);},className:"asakaa-add-column__cancel",type:"button",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})}):jsx("div",{className:d("asakaa-add-column",t),children:jsxs("button",{onClick:()=>n(true),disabled:o,className:"asakaa-add-column__button",type:"button",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r]})})}function ti({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:n=false,theme:c="dark",locale:g="es"}){let[i,p]=useState(false),[l,f]=useState(false),[y,k]=useState(""),[C,h]=useState([]),[b,u]=useState(""),[x,m]=useState(""),[N,w]=useState(""),[B,v]=useState(false),[I,A]=useState(false),[T,W]=useState(false),$=useRef(null),j=useRef(null),te={placeholder:o||(g==="es"?"Nombre de la tarea...":"Task Name..."),buttonLabel:s||(g==="es"?"Agregar Tarea":"Add Task"),save:g==="es"?"Guardar":"Save",addAssignee:g==="es"?"Agregar asignado":"Add assignee",addDates:g==="es"?"Agregar fechas":"Add dates",addPriority:g==="es"?"Agregar prioridad":"Add priority",startDate:g==="es"?"Inicio":"Start",endDate:g==="es"?"Fin":"End",low:g==="es"?"Baja":"Low",medium:g==="es"?"Media":"Medium",high:g==="es"?"Alta":"High",urgent:g==="es"?"Urgente":"Urgent"},oe=useCallback(()=>{k(""),h([]),u(""),m(""),w(""),v(false),A(false),W(false),p(false);},[]);useEffect(()=>{i&&$.current&&$.current.focus();},[i]),useEffect(()=>{if(!i)return;let M=R=>{j.current&&!j.current.contains(R.target)&&(y.trim()||oe());};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[i,y,oe]);let re=useCallback(async()=>{let M=y.trim();if(!(!M||l)){f(true);try{await t({name:M,columnId:e,assigneeIds:C.length>0?C:void 0,startDate:b?new Date(b):void 0,endDate:x?new Date(x):void 0,priority:N||void 0}),k(""),h([]),u(""),m(""),w(""),v(!1),A(!1),W(!1),$.current?.focus();}catch(R){console.error("Error creating card:",R);}finally{f(false);}}},[y,e,C,b,x,N,t,l]),ge=useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),re()):M.key==="Escape"&&oe();},[re,oe]),fe=useCallback(M=>{h(R=>R.includes(M)?R.filter(L=>L!==M):[...R,M]);},[]),Ie=c==="dark";return i?jsxs("div",{ref:j,className:d("rounded-lg overflow-hidden shadow-lg",Ie?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:$,type:"text",value:y,onChange:M=>k(M.target.value),onKeyDown:ge,placeholder:te.placeholder,disabled:l,className:d("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",Ie?"text-gray-100 placeholder-gray-500":"text-gray-800 placeholder-gray-400")}),jsxs("div",{className:"flex items-center gap-1 mt-3",children:[a.length>0&&jsxs("button",{onClick:()=>v(!B),className:d("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",B||C.length>0?"bg-emerald-500/20 text-emerald-400":Ie?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:te.addAssignee,children:[jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),C.length>0&&jsx("span",{className:"ml-0.5",children:C.length})]}),jsx("button",{onClick:()=>A(!I),className:d("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",I||b||x?"bg-blue-500/20 text-blue-400":Ie?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:te.addDates,children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),jsx("button",{onClick:()=>W(!T),className:d("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",T||N?N==="urgent"?"bg-red-500/20 text-red-400":N==="high"?"bg-orange-500/20 text-orange-400":N==="medium"?"bg-yellow-500/20 text-yellow-400":N==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":Ie?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:te.addPriority,children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"}),jsx("line",{x1:"4",y1:"22",x2:"4",y2:"15"})]})}),jsx("div",{className:"flex-1"}),jsx("button",{onClick:re,disabled:!y.trim()||l,className:d("px-3 py-1.5 rounded-md text-xs font-medium text-white transition-all","bg-emerald-500 hover:bg-emerald-600","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-emerald-500"),type:"button",children:l?jsx("div",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"}):te.save})]})]}),B&&a.length>0&&jsx("div",{className:d("px-3 pb-3 pt-0","border-t",Ie?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(M=>jsxs("button",{onClick:()=>fe(M.id),className:d("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",C.includes(M.id)?"bg-emerald-500 text-white":Ie?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[M.avatar?jsx("img",{src:M.avatar,alt:M.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:d("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",C.includes(M.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:M.name.charAt(0).toUpperCase()}),jsx("span",{children:M.name.split(" ")[0]})]},M.id))})}),I&&jsx("div",{className:d("px-3 pb-3 pt-0","border-t",Ie?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:d("block text-[10px] uppercase tracking-wide mb-1",Ie?"text-gray-500":"text-gray-400"),children:te.startDate}),jsx("input",{type:"date",value:b,onChange:M=>u(M.target.value),className:d("w-full px-2 py-1.5 rounded text-xs border",Ie?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:d("block text-[10px] uppercase tracking-wide mb-1",Ie?"text-gray-500":"text-gray-400"),children:te.endDate}),jsx("input",{type:"date",value:x,onChange:M=>m(M.target.value),className:d("w-full px-2 py-1.5 rounded text-xs border",Ie?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),T&&jsx("div",{className:d("px-3 pb-3 pt-0","border-t",Ie?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(M=>jsx("button",{onClick:()=>w(N===M?"":M),className:d("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",N===M?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[M]} text-white`:Ie?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:te[M]},M))})})]}):jsxs("button",{onClick:()=>p(true),disabled:n,className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",Ie?"hover:bg-[#2a2a3e]":"hover:bg-gray-100",n&&"opacity-50 cursor-not-allowed",r),type:"button",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),jsx("span",{className:"text-sm font-medium",children:te.buttonLabel})]})}var qo=class extends BaseViewAdapter{constructor(a={}){super();this.id="kanban";this.name="Kanban Board";this.version="1.0.0";this.description="";this.icon="";this.supportedExports=["json","csv","pdf","png"];this.root=null;this.description="Interactive Kanban board with drag & drop, filters, and real-time updates",this.icon="\u{1F4CB}",this.kanbanConfig=a,this.options={animations:a.viewOptions?.animations??true,virtualScrolling:a.viewOptions?.virtualScrolling??false,theme:a.viewOptions?.theme??"dark",readonly:a.viewOptions?.readonly??false};}mount(a,r){this.isMounted()&&(console.warn("[KanbanViewAdapter] Already mounted, unmounting first"),this.unmount()),this.container=a,this.data=r,this.root=createRoot(a),this.render(),this.emit("view:mounted",{viewId:this.id,timestamp:Date.now()});}unmount(){this.isMounted()&&(this.emit("view:unmounted",{viewId:this.id,timestamp:Date.now()}),this.root&&(this.root.unmount(),this.root=null),this.container&&(this.container.innerHTML="",this.container=null),this.data=null);}update(a){if(!this.isMounted()){console.warn("[KanbanViewAdapter] Not mounted, cannot update");return}this.data=a,this.render(),this.emit("view:updated",{viewId:this.id,data:a});}configure(a){this.options={...this.options,...a},this.isMounted()&&this.render();}async export(a){if(!this.data)throw new Error("No data to export");switch(a){case "json":return JSON.stringify(this.data,null,2);case "csv":return this.exportToCSV();case "pdf":return this.exportToPDF();case "png":return this.exportToPNG();default:throw new Error(`Unsupported export format: ${a}`)}}render(){if(!this.root||!this.data)return;let a={id:this.data.board?.id||"board-1",title:this.data.board?.title||"Untitled Board",columns:this.data.columns,cards:this.data.cards};this.root.render(jsx(zr,{board:a,callbacks:this.kanbanConfig.callbacks||{},onCardClick:this.kanbanConfig.onCardClick,renderProps:this.kanbanConfig.renderProps,config:this.kanbanConfig.config,availableUsers:this.kanbanConfig.availableUsers,className:this.kanbanConfig.className,style:this.kanbanConfig.style}));}exportToCSV(){if(!this.data)return "";let a=[["Card ID","Title","Column","Description","Labels","Assignees","Due Date","Position"]];return this.data.cards.forEach(r=>{let o=this.data.columns.find(s=>s.id===r.columnId);a.push([r.id,r.title,o?.title||"",r.description||"",r.labels?.join(", ")||"",r.assignedUserIds?.join(", ")||r.assigneeId||"",r.dueDate?.toString()||"",r.position.toString()]);}),a.map(r=>r.map(o=>`"${o}"`).join(",")).join(`
|
|
5
|
-
`)}async exportToPDF(){throw new Error("PDF export not yet implemented in ViewAdapter")}async exportToPNG(){if(!this.container)throw new Error("View not mounted");let r=await(await import('html2canvas')).default(this.container,{backgroundColor:this.options.theme==="dark"?"#1a1a1a":"#ffffff",scale:2});return new Promise((o,s)=>{r.toBlob(n=>{n?o(n):s(new Error("Failed to create PNG blob"));},"image/png");})}};function dc(e={}){return new qo(e)}var So=class extends Component{constructor(a){super(a);this.resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(a){return {hasError:true,error:a}}componentDidCatch(a,r){let{onError:o,componentName:s}=this.props;if(process.env.NODE_ENV==="development"&&(console.error(`Error in ${s||"Component"}:`,a),console.error("Error Info:",r)),this.setState({errorInfo:r}),o)try{o(a,r);}catch(n){console.error("Error in error handler:",n);}}render(){let{hasError:a,error:r}=this.state,{children:o,fallback:s,componentName:n}=this.props;return a&&r?s?s(r,this.resetError):jsx("div",{className:"p-6 rounded-lg border",style:{background:"linear-gradient(135deg, #2d1b1b 0%, #1a1a1a 100%)",borderColor:"rgba(239, 68, 68, 0.3)"},children:jsxs("div",{className:"flex items-start gap-3",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"#EF4444",strokeWidth:"2"}),jsx("path",{d:"M12 8V12",stroke:"#EF4444",strokeWidth:"2",strokeLinecap:"round"}),jsx("circle",{cx:"12",cy:"16",r:"1",fill:"#EF4444"})]}),jsxs("div",{className:"flex-1",children:[jsx("h3",{className:"text-lg font-semibold text-red-400 mb-1",children:n?`Error in ${n}`:"Something went wrong"}),jsx("p",{className:"text-sm text-white/70 mb-3",children:r.message||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&jsxs("details",{className:"mb-3",children:[jsx("summary",{className:"text-xs text-white/50 cursor-pointer hover:text-white/70 mb-2",children:"Error Details (Development Only)"}),jsx("pre",{className:"text-xs text-white/60 bg-black/30 p-3 rounded overflow-auto max-h-48",children:r.stack})]}),jsx("button",{onClick:this.resetError,className:"px-4 py-2 rounded-lg text-sm font-medium transition-all hover:bg-red-600/20 border border-red-500/30",style:{color:"#EF4444"},children:"Try Again"})]})]})}):o}};function ai(e,t){let a=r=>jsx(So,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function oi({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:n,onPredictRisks:c,onOpenAIUsage:g,shortcut:i="k",className:p=""}){let[l,f]=useState(false),[y,k]=useState(""),[C,h]=useState("home"),[b,u]=useState(""),[x,m]=useState("");useEffect(()=>{let v=I=>{(I.metaKey||I.ctrlKey)&&I.key===i&&(I.preventDefault(),f(A=>!A)),I.key==="Escape"&&(f(false),h("home"),k(""));};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[i]),useEffect(()=>{l||(h("home"),k(""),u(""),m(""));},[l]);let N=useCallback(()=>{f(false);},[]),w=useCallback(v=>{let[I,A]=v.split(":");switch(I){case "create-card":h("create-card");break;case "create-card-in":u(A||"");break;case "navigate":A?(a?.(A),N()):h("navigate");break;case "search":r?.(y),N();break;case "priority":h("priority");break;case "set-priority":x&&A&&(o?.(x,A),N());break;case "assign":h("assign");break;case "assign-user":x&&A&&(s?.(x,A),N());break;case "ai":h("ai");break;case "ai-generate-plan":n?.(),N();break;case "ai-predict-risks":c?.(),N();break;case "ai-usage":g?.(),N();break;case "back":h("home");break;}},[y,x,t,a,r,o,s,n,c,g,N]),B=useCallback(()=>{b&&y.trim()&&(t?.(b,y.trim()),N());},[b,y,t,N]);return l?jsx(bt,{children:jsx("div",{className:"command-palette-overlay",onClick:N,children:jsx("div",{className:`command-palette ${p}`,onClick:v=>v.stopPropagation(),children:jsxs(Command,{value:y,onValueChange:k,label:"Command Menu",children:[jsxs("div",{className:"command-palette-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"11",cy:"11",r:"8"}),jsx("path",{d:"m21 21-4.35-4.35"})]}),jsx(Command.Input,{placeholder:C==="create-card"&&b?"Type card title and press Enter...":C==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:v=>{v.key==="Enter"&&C==="create-card"&&b&&B();}}),jsxs("div",{className:"command-palette-shortcut",children:[jsx("kbd",{children:navigator.platform.includes("Mac")?"\u2318":"Ctrl"}),jsx("kbd",{children:"K"})]})]}),jsxs(Command.List,{className:"command-palette-list",children:[jsx(Command.Empty,{className:"command-palette-empty",children:"No results found."}),C==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:w,className:"command-palette-item",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"}),jsx("path",{d:"M12 8v8m-4-4h8"})]}),jsx("span",{children:"Create Card"}),jsx("div",{className:"command-palette-item-shortcut",children:"C"})]}),jsxs(Command.Item,{value:"navigate",onSelect:w,className:"command-palette-item",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:"10"}),jsx("polyline",{points:"12 16 16 12 12 8"}),jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),jsx("span",{children:"Navigate to Card"}),jsx("div",{className:"command-palette-item-shortcut",children:"G"})]}),jsxs(Command.Item,{value:"search",onSelect:w,className:"command-palette-item",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"11",cy:"11",r:"8"}),jsx("path",{d:"m21 21-4.35-4.35"})]}),jsx("span",{children:"Search Cards"}),jsx("div",{className:"command-palette-item-shortcut",children:"/"})]})]}),jsx(Command.Group,{heading:"AI Features",className:"command-palette-group",children:jsxs(Command.Item,{value:"ai",onSelect:w,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"AI Commands"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})}),jsx(Command.Group,{heading:"Cards",className:"command-palette-group",children:e.cards.slice(0,5).map(v=>jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:w,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:v.title}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(I=>jsx("span",{className:"command-palette-item-label",children:I},I))})]},v.id))})]}),C==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:w,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"Select Column",className:"command-palette-group",children:e.columns.map(v=>jsxs(Command.Item,{value:`create-card-in:${v.id}`,onSelect:w,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("rect",{x:"3",y:"3",width:"7",height:"18",rx:"1"})}),jsx("span",{children:v.title}),jsxs("div",{className:"command-palette-item-count",children:[v.cardIds.length," cards"]})]},v.id))})]}),C==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:w,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"All Cards",className:"command-palette-group",children:e.cards.map(v=>{let I=e.columns.find(A=>A.id===v.columnId);return jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:w,className:"command-palette-item",keywords:[v.title,v.description||"",...v.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:v.title}),jsx("div",{className:"command-palette-item-meta",children:I?.title})]}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(A=>jsx("span",{className:"command-palette-item-label",children:A},A))})]},v.id)})})]}),C==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:w,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsxs(Command.Group,{heading:"AI Features",className:"command-palette-group",children:[jsxs(Command.Item,{value:"ai-generate-plan",onSelect:w,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"Generate Project Plan"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]}),jsxs(Command.Item,{value:"ai-predict-risks",onSelect:w,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Predict Risks"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]}),jsxs(Command.Item,{value:"ai-usage",onSelect:w,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"1",x2:"12",y2:"23"}),jsx("path",{d:"M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6"})]}),jsx("span",{children:"AI Usage & Costs"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})]})]})]}),jsxs("div",{className:"command-palette-footer",children:[jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"\u2191"}),jsx("kbd",{children:"\u2193"}),jsx("span",{children:"Navigate"})]}),jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"Enter"}),jsx("span",{children:"Select"})]}),jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"Esc"}),jsx("span",{children:"Close"})]})]})]})})})}):null}function pc(e,t,a,r,o){let s=document.getElementById("attachment-lightbox-native");s&&s.remove();let n=document.createElement("div");n.id="attachment-lightbox-native",n.className="attachment-lightbox",n.style.cssText=`
|
|
1
|
+
import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,selectionStore,BoardStore}from'@libxai/core';export{Board as BoardModel,BoardStore,Card as CardModel,Column as ColumnModel,DependencyEngine,Store}from'@libxai/core';import {createContext,memo,useRef,useState,forwardRef,useContext,useCallback,useEffect,useMemo,useImperativeHandle,useLayoutEffect,Component}from'react';import {useDroppable,useSensors,useSensor,PointerSensor,KeyboardSensor,DndContext,closestCorners,DragOverlay}from'@dnd-kit/core';import {useSortable,SortableContext,verticalListSortingStrategy,sortableKeyboardCoordinates}from'@dnd-kit/sortable';import {useVirtualizer}from'@tanstack/react-virtual';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsPDF}from'jspdf';import mm from'html2canvas';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {AnimatePresence,motion}from'framer-motion';import {CheckCircle2,PlayCircle,Circle,Scissors,Settings,Eye,EyeOff,ArrowDown,ArrowUp,ArrowUpDown,BarChart3,Link2,Minus,Plus,Trash2,Pencil,Edit3,AlertTriangle,CheckSquare,ChevronDown,Calendar,Hash,Type,Tag,BarChart,CalendarCheck,Users,Flag,CircleDot,Moon,Sun,Palette,ZoomOut,ZoomIn,Keyboard,ChevronRight,Image,FileText,File,Sparkles,Maximize2,MoreHorizontal,X,User,Check,CalendarDays,Clock,Diamond,ListChecks,Upload,MessageSquare,Rows3,Filter,FileImage,FileSpreadsheet,FileJson,FolderKanban,Download,ChevronLeft,GripVertical,Send,AlertCircle,Milestone,List,Search,Copy}from'lucide-react';import {Command}from'cmdk';import Df from'react-markdown';import Sf from'remark-gfm';import Ef from'rehype-sanitize';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Line,AreaChart,Area,PieChart,Pie,Cell,BarChart as BarChart$1,Bar}from'recharts';var xn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,a)=>(typeof require<"u"?require:t)[a]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var kn=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:a}=e;return "translate3d("+(t?Math.round(t):0)+"px, "+(a?Math.round(a):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:a}=e;return "scaleX("+t+") scaleY("+a+")"}},Transform:{toString(e){if(e)return [kn.Translate.toString(e),kn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function d(...e){return twMerge(clsx(e))}function wn(e,t){return e===null&&t===null?1e3:e===null&&t!==null?t/2:e!==null&&t===null?e+1e3:e!==null&&t!==null?(e+t)/2:1e3}function Iu(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function Bs(e,t){return e.length===0?1e3:t===0?wn(null,e[0].position):t>=e.length?wn(e[e.length-1].position,null):wn(e[t-1].position,e[t].position)}function dd(e,t=100){return e>t}var Bu=e=>{if(e.message.includes("network")||e.message.includes("fetch"))return true;if("status"in e){let t=e.status;return t>=500||t===429}return false};function Ru(e,t,a,r){let o=t*Math.pow(a,e-1),s=o*.2*Math.random();return Math.min(o+s,r)}async function Cn(e,t={}){let{maxAttempts:a=3,initialDelay:r=1e3,backoffMultiplier:o=2,maxDelay:s=1e4,shouldRetry:n=Bu,onRetry:c}=t,g,i=0;for(let p=1;p<=a;p++){i=p;try{return {data:await e(),attempts:i,success:!0}}catch(l){if(g=l,p===a||!n(g,p))return {error:g,attempts:i,success:false};let y=Ru(p,r,o,s);if(c)try{c(g,p,y);}catch(k){console.error("Error in retry callback:",k);}await new Promise(k=>setTimeout(k,y));}}return {error:g||new Error("Unknown error"),attempts:i,success:false}}function Ou(e,t=3){let a;for(let r=1;r<=t;r++)try{return {data:e(),success:!0}}catch(o){if(a=o,r===t)return {error:a,success:false}}return {error:a||new Error("Unknown error"),success:false}}function $u(e,t={}){return async(...a)=>Cn(()=>e(...a),t)}var Rs=class{constructor(t=5,a=6e4){this.threshold=t;this.resetTimeout=a;this.failures=0;this.lastFailureTime=0;this.isOpen=false;}async execute(t){if(this.isOpen)if(Date.now()-this.lastFailureTime>=this.resetTimeout)this.reset();else throw new Error("Circuit breaker is open - too many failures");try{let a=await t();return this.onSuccess(),a}catch(a){throw this.onFailure(),a}}onSuccess(){this.failures=0,this.isOpen=false;}onFailure(){this.failures++,this.lastFailureTime=Date.now(),this.failures>=this.threshold&&(this.isOpen=true);}reset(){this.failures=0,this.isOpen=false;}getStatus(){return {failures:this.failures,isOpen:this.isOpen}}};var cd=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.NONE=4]="NONE",s))(cd||{}),to=class to{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...n}=t,c=`[${a}] [${r}] [${s}]`,g=Object.keys(n).length>0;switch(r){case "DEBUG":console.debug(c,o,g?n:"");break;case "INFO":console.info(c,o,g?n:"");break;case "WARN":console.warn(c,o,g?n:"");break;case "ERROR":console.error(c,o,g?n:""),t.error?.stack&&console.error(t.error.stack);break}};let a=process.env.NODE_ENV==="development";this.options={minLevel:t.minLevel??(a?0:1),enabled:t.enabled??true,onLog:t.onLog??this.defaultLogHandler,enableTiming:t.enableTiming??true,componentName:t.componentName??"ASAKAA",...to.globalOptions};}static configure(t){to.globalOptions={...to.globalOptions,...t};}child(t){return new to({...this.options,componentName:`${this.options.componentName}:${t}`})}debug(t,a){this.log(0,t,a);}info(t,a){this.log(1,t,a);}warn(t,a){this.log(2,t,a);}error(t,a,r){this.log(3,t,{...r,error:a?{message:a.message,stack:a.stack,name:a.name}:void 0});}startTimer(t){return this.options.enableTiming?new Tn((a,r)=>{this.log(0,`${t} completed`,{...r,action:t,duration:a});},true):new Tn(()=>{},false)}log(t,a,r){if(!this.options.enabled||t<this.options.minLevel)return;let o={timestamp:new Date().toISOString(),level:cd[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};to.globalOptions={};var Os=to,Tn=class{constructor(t,a){this.onEnd=t;this.enabled=a;this.startTime=a?performance.now():0;}end(t){if(!this.enabled)return 0;let a=Math.round(performance.now()-this.startTime);return this.onEnd(a,t),a}elapsed(){return this.enabled?Math.round(performance.now()-this.startTime):0}},md=new Os;function zu(e,t){let a={board:{id:e.id,title:e.title,metadata:e.metadata,exportedAt:new Date().toISOString()},columns:e.columns,cards:e.cards,options:t};return JSON.stringify(a,null,2)}function Hu(e,t){let a=["Card ID","Title","Description","Column","Priority","Labels","Assigned Users","Start Date","End Date","Created At","Updated At"],r=e.cards.map(s=>{let n=e.columns.find(c=>c.id===s.columnId);return [s.id,$s(s.title),$s(s.description||""),$s(n?.title||""),s.priority||"",(s.labels||[]).join(";"),(s.assignedUserIds||[]).join(";"),s.startDate||"",s.endDate||"",s.createdAt||"",s.updatedAt||""]});return [a.join(","),...r.map(s=>s.join(","))].join(`
|
|
2
|
+
`)}async function Wu(e,t,a){let r=t;if(!r){let n=document.querySelector(".asakaa-board");n&&(r=n.parentElement||n);}if(r)try{let n=await mm(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),c=n.toDataURL("image/png"),g=297,i=210,p=n.width/n.height,l=g-20,f=l/p;f>i-20&&(f=i-20,l=f*p);let y=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});y.setFontSize(16),y.setTextColor(255,255,255),y.setFillColor(10,10,10),y.rect(0,0,g,15,"F"),y.text(e.title||"Kanban Board",10,10);let k=(g-l)/2;return y.addImage(c,"PNG",k,20,l,f),y}catch(n){console.error("Error capturing board:",n);}let o=new jsPDF,s=20;return o.setFontSize(20),o.text(e.title||"Kanban Board",20,s),s+=10,o.setFontSize(10),o.setTextColor(128,128,128),o.text(`Exported on ${new Date().toLocaleString()}`,20,s),s+=15,o.setTextColor(0,0,0),e.columns.forEach(n=>{let c=e.cards.filter(g=>g.columnId===n.id);s>250&&(o.addPage(),s=20),o.setFontSize(16),o.setFont("helvetica","bold"),o.text(n.title,20,s),s+=8,c.length===0?(o.setFontSize(10),o.setFont("helvetica","italic"),o.setTextColor(128,128,128),o.text("No cards in this column",20,s),o.setTextColor(0,0,0),s+=10):c.forEach(g=>{if(s>260&&(o.addPage(),s=20),o.setFontSize(12),o.setFont("helvetica","bold"),o.text(g.title,25,s),s+=6,g.description){o.setFontSize(9),o.setFont("helvetica","normal");let p=o.splitTextToSize(g.description,160);o.text(p,25,s),s+=p.length*5;}let i=[];if(g.priority&&i.push(`Priority: ${g.priority}`),g.labels&&g.labels.length>0&&i.push(`Labels: ${g.labels.join(", ")}`),g.assignedUserIds&&g.assignedUserIds.length>0&&i.push(`Assigned: ${g.assignedUserIds.length} user(s)`),g.startDate||g.endDate){let p=[];g.startDate&&p.push(`Start: ${g.startDate}`),g.endDate&&p.push(`End: ${g.endDate}`),i.push(p.join(" \u2192 "));}i.length>0&&(o.setFontSize(8),o.setTextColor(100,100,100),o.text(i.join(" \u2022 "),25,s),o.setTextColor(0,0,0),s+=5),s+=5;}),s+=5;}),o}function $s(e){return e.includes(",")||e.includes('"')||e.includes(`
|
|
3
|
+
`)?`"${e.replace(/"/g,'""')}"`:e}async function ud(e,t,a,r){switch(t){case "json":return zu(e,r);case "csv":return Hu(e);case "pdf":return await Wu(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function gd(e,t,a){let r=`board-export-${new Date().getTime()}`;if(t==="pdf"&&typeof e=="object"&&e!==null&&"save"in e){let p=`${r}.pdf`;e.save(p);return}if(typeof e!="string")throw new Error("Invalid content type for non-PDF export");let s=`${r}.${{json:"json",csv:"csv",pdf:"pdf"}[t]}`,n={json:"application/json",csv:"text/csv",pdf:"application/pdf"},c=new Blob([e],{type:n[t]}),g=URL.createObjectURL(c),i=document.createElement("a");i.href=g,i.download=s,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(g);}function Gu(e){try{let t=JSON.parse(e);if(!t.board||!t.columns||!t.cards)return {success:!1,errors:["Invalid JSON format: missing required fields (board, columns, cards)"]};let a={id:t.board.id,title:t.board.title,columns:t.columns,cards:t.cards,metadata:t.board.metadata};return {success:!0,cardsImported:a.cards.length,columnsImported:a.columns.length}}catch(t){return {success:false,errors:[`Failed to parse JSON: ${t instanceof Error?t.message:"Unknown error"}`]}}}function _u(e){try{let t=e.trim().split(`
|
|
4
|
+
`);if(t.length<1||!t[0])return {success:!1,errors:["CSV file is empty or invalid"]};let a=fd(t[0]),r=[],o=new Map,s=[];for(let n=1;n<t.length;n++)try{let c=fd(t[n]||"");if(c.length>a.length){s.push(`Line ${n+1}: Too many columns`);continue}if(a.length-c.length>3){s.push(`Line ${n+1}: Column count mismatch (expected ${a.length}, got ${c.length})`);continue}for(;c.length<a.length;)c.push("");let i={};a.forEach((y,k)=>{i[y]=c[k]||"";});let p=i.Column||"Unnamed";o.has(p)||o.set(p,{id:`col-${o.size+1}`,title:p,position:o.size+1,cardIds:[]});let l=o.get(p),f={id:i["Card ID"]||`card-${n}`,title:i.Title||"Untitled",description:i.Description?i.Description:void 0,columnId:l.id,position:l.cardIds.length+1,priority:i.Priority||void 0,labels:i.Labels?i.Labels.split(";").filter(Boolean):void 0,assignedUserIds:i["Assigned Users"]?i["Assigned Users"].split(";").filter(Boolean):void 0,startDate:i["Start Date"]?i["Start Date"]:void 0,endDate:i["End Date"]?i["End Date"]:void 0,createdAt:i["Created At"]?i["Created At"]:void 0,updatedAt:i["Updated At"]?i["Updated At"]:void 0};r.push(f),l.cardIds.push(f.id);}catch(c){s.push(`Line ${n+1}: ${c instanceof Error?c.message:"Unknown error"}`);}return r.length===0?{success:!1,errors:["No valid cards found in CSV",...s]}:{success:!0,cardsImported:r.length,columnsImported:o.size,errors:s.length>0?s:void 0}}catch(t){return {success:false,errors:[`Failed to parse CSV: ${t instanceof Error?t.message:"Unknown error"}`]}}}function fd(e){let t=[],a="",r=false;for(let o=0;o<e.length;o++){let s=e[o],n=e[o+1];s==='"'&&r&&n==='"'?(a+='"',o++):s==='"'?r=!r:s===","&&!r?(t.push(a),a=""):a+=s;}return t.push(a),t}function bd(e,t){switch(t){case "json":return Gu(e);case "csv":return _u(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function hd(e){return new Promise((t,a)=>{let r=new FileReader;r.onload=o=>{o.target?.result?t(o.target.result):a(new Error("Failed to read file"));},r.onerror=()=>a(new Error("Failed to read file")),r.readAsText(e);})}var Us=createContext(null);function yd(){return useContext(Us)}var vd=createContext(null);function xd({children:e,themeName:t}){return jsx(vd.Provider,{value:{themeName:t},children:e})}function wo(){return useContext(vd)}function ft({children:e,container:t}){let[a,r]=useState(false),o=yd(),s=wo();if(useEffect(()=>(r(true),()=>r(false)),[]),!a)return null;let n=t||(typeof document<"u"?document.body:null);if(!n)return null;if(o){let{theme:c,themeName:g}=o,i={"--asakaa-color-background-primary":c.bgPrimary,"--asakaa-color-background-secondary":c.bgSecondary,"--asakaa-color-background-card":c.bgGrid,"--asakaa-color-background-hover":c.hoverBg,"--asakaa-color-text-primary":c.textPrimary,"--asakaa-color-text-secondary":c.textSecondary,"--asakaa-color-text-tertiary":c.textTertiary,"--asakaa-color-text-inverse":c.taskBarHandle||"#FFFFFF","--asakaa-color-border-default":c.border,"--asakaa-color-border-hover":c.borderLight,"--asakaa-color-border-subtle":c.borderLight,"--asakaa-color-interactive-primary":c.accent,"--asakaa-color-interactive-primaryHover":c.accentHover,"--asakaa-color-interactive-primaryBorder":`${c.accent}4D`,"--asakaa-color-interactive-primaryBackground":`${c.accent}1A`,"--asakaa-color-interactive-primaryBackgroundHover":`${c.accent}33`,"--asakaa-color-status-success":c.statusCompleted,"--asakaa-color-status-warning":c.milestone,"--asakaa-color-status-error":c.criticalPath,"--asakaa-color-danger":c.criticalPath,"--asakaa-color-danger-border":`${c.criticalPath}4D`,"--asakaa-color-danger-background":`${c.criticalPath}14`,"--asakaa-color-danger-backgroundHover":`${c.criticalPath}26`};return createPortal(jsx("div",{"data-theme":g,"data-gantt-portal":"true",style:i,children:e}),n)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),n):createPortal(e,n)}var Nd={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},Zu="#BDC3C7",Qu=({color:e})=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",fill:e,opacity:"0.9"}),jsx("circle",{cx:"8",cy:"8",r:"6",stroke:e,strokeWidth:"1.5",opacity:"0.3"})]});function ao({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,n]=useState({top:0,left:0}),c=useRef(null),g=useRef(null),i=()=>{if(!g.current)return;let y=g.current.getBoundingClientRect(),k=window.innerHeight,C=window.innerWidth,h=160,b=220,u=4,x=y.right-h;x<10&&(x=y.left),x+h>C-10&&(x=C-h-10);let m=k-y.bottom,N=y.top,w;m>=b+u?w=y.bottom+u:N>=b+u?w=y.top-b-u:w=m>=N?y.bottom+u:Math.max(10,y.top-b-u),n({top:w,left:x}),o(true);};useEffect(()=>{let y=k=>{c.current&&!c.current.contains(k.target)&&!g.current?.contains(k.target)&&o(false);};if(r)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[r]),useEffect(()=>{let y=k=>{k.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]);let p=y=>{t(y),o(false);},l=e?Nd[e]:null,f=l?.color||Zu;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:g,onClick:()=>r?o(false):i(),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all hover:bg-white/15 hover:scale-110 active:scale-95",style:{background:e?`${f}10`:"transparent",boxShadow:e?`0 0 0 2px ${f}30 inset`:"none"},title:l?.label||"Set priority",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 2L3 14M3 2L13 6L3 8V2Z",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:f,fillOpacity:e?"0.6":"0.4"})})}),r&&jsx(ft,{children:jsxs("div",{ref:c,className:"priority-selector-menu",style:{position:"fixed",top:`${s.top}px`,left:`${s.left}px`,zIndex:99999,minWidth:"160px",maxHeight:"calc(100vh - 40px)",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Priority"})}),jsxs("div",{className:"py-1",children:[Object.entries(Nd).map(([y,k])=>jsxs("button",{onClick:()=>p(y),className:"w-full px-3 py-1.5 flex items-center gap-2 text-xs font-medium transition-all active:scale-[0.98] priority-option",style:{color:k.color,background:"transparent"},onMouseEnter:C=>{C.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:C=>{C.currentTarget.style.background="transparent";},children:[jsx(Qu,{color:k.color}),jsx("span",{className:"font-semibold text-sm",children:k.label}),e===y&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},y)),jsx("div",{className:"mt-0.5 pt-0.5 border-t",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsxs("button",{onClick:()=>p(void 0),className:"w-full px-3 py-1.5 flex items-center gap-2 text-xs font-medium transition-all active:scale-[0.98]",style:{color:"var(--modal-v2-text-primary, #e5e5e5)",background:"transparent"},onMouseEnter:y=>{y.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:y=>{y.currentTarget.style.background="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"#9CA3AF",strokeWidth:"1.5",strokeDasharray:"2 2",opacity:"0.6"})}),jsx("span",{className:"font-semibold text-sm",children:"Clear"}),!e&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]})]})})]})}var eg=[{label:"Today",days:0},{label:"Tomorrow",days:1},{label:"Next Week",days:7},{label:"2 Weeks",days:14},{label:"4 Weeks",days:28},{label:"8 Weeks",days:56}];function Wo({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),g=useRef(null),i=useRef(null),f=(wo()?.themeName||"dark")==="dark",y=()=>{if(!i.current)return;let x=i.current.getBoundingClientRect(),m=window.innerHeight,N=window.innerWidth,w=320,B=380,v=4,I=x.left;I+w>N-10&&(I=N-w-10),I<10&&(I=10);let F=m-x.bottom,T=x.top,H;F>=B+v?H=x.bottom+v:T>=B+v?H=x.top-B-v:H=F>=T?x.bottom+v:Math.max(10,x.top-B-v),c({top:H,left:I}),s(true);};useEffect(()=>{let x=m=>{g.current&&!g.current.contains(m.target)&&!i.current?.contains(m.target)&&s(false);};if(o)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[o]),useEffect(()=>{let x=m=>{m.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o]);let k=x=>{let m=new Date,N=I=>{let F=I.getFullYear(),T=String(I.getMonth()+1).padStart(2,"0"),H=String(I.getDate()).padStart(2,"0");return `${F}-${T}-${H}`},w=N(m),B=new Date(m);B.setDate(B.getDate()+x);let v=N(B);a(w,v),s(false);},C=()=>{if(!e||!t)return "Set date";let x=B=>{if(B instanceof Date)return B;if(typeof B!="string"||!B.match(/^\d{4}-\d{2}-\d{2}$/))return null;let v=B.split("-").map(Number);if(v.length!==3||v.some(H=>isNaN(H)))return null;let I=v[0],F=v[1],T=v[2];return I===void 0||F===void 0||T===void 0?null:new Date(I,F-1,T)},m=x(e),N=x(t);if(!m||!N||isNaN(m.getTime())||isNaN(N.getTime()))return "Set date";let w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${w[m.getMonth()]} ${m.getDate()} \u2013 ${w[N.getMonth()]} ${N.getDate()}`},h=e&&t,u=(()=>{if(!t)return false;let x=typeof t=="string"?new Date(t):t,m=new Date;return m.setHours(0,0,0,0),x<m})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:i,onClick:()=>o?s(false):y(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${u?"asakaa-date-overdue":"asakaa-date"}`,title:h?`${C()}`:"Set date range",children:[jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"2",y:"3",width:"12",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M2 6H14",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M5 2V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("path",{d:"M11 2V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),e&&t&&jsx("span",{className:"whitespace-nowrap",children:C()})]}),o&&jsx(ft,{children:jsxs("div",{ref:g,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,background:f?"#1A1D25":"#FFFFFF",border:`1px solid ${f?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.12)"}`,boxShadow:f?"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)":"0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.08)",zIndex:99999},children:[jsxs("div",{className:"p-4 border-b",style:{borderColor:f?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.08)"},children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:f?"rgba(255, 255, 255, 0.85)":"rgba(0, 0, 0, 0.7)"},children:"Quick Select"}),jsx("div",{className:"grid grid-cols-2 gap-2",children:eg.map(x=>jsx("button",{onClick:()=>k(x.days),className:"px-3 py-2.5 rounded-lg text-xs font-semibold transition-all active:scale-95",style:{color:f?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",border:`1px solid ${f?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`,backgroundColor:f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)"},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=f?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",m.currentTarget.style.border=`1px solid ${f?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",m.currentTarget.style.border=`1px solid ${f?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:x.label},x.label))})]}),jsxs("div",{className:"p-4",children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:f?"rgba(255, 255, 255, 0.85)":"rgba(0, 0, 0, 0.7)"},children:"Custom Range"}),jsxs("div",{className:"space-y-3",children:[jsx("input",{type:"date",value:e||"",onChange:x=>a(x.target.value,t),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:f?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:f?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:f?"dark":"light"}}),jsx("input",{type:"date",value:t||"",onChange:x=>a(e,x.target.value),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:f?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:f?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:f?"dark":"light"}})]}),(e||t)&&jsx("button",{onClick:()=>{a(void 0,void 0),s(false);},className:"mt-4 w-full px-3 py-2.5 rounded-lg text-sm font-semibold transition-all active:scale-95 border",style:{color:"#ef4444",borderColor:"rgba(239, 68, 68, 0.3)",background:"rgba(239, 68, 68, 0.1)"},onMouseEnter:x=>{x.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function oo({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,n]=useState(false),[c,g]=useState(""),[i,p]=useState({top:0,left:0}),l=useRef(null),f=useRef(null),y=()=>{if(!f.current)return;let u=f.current.getBoundingClientRect(),x=window.innerHeight,m=window.innerWidth,N=300,w=380,B=4,v=u.right-N;v<10&&(v=u.left),v+N>m-10&&(v=m-N-10);let I=x-u.bottom,F=u.top,T;I>=w+B?T=u.bottom+B:F>=w+B?T=u.top-w-B:T=I>=F?u.bottom+B:Math.max(10,u.top-w-B),p({top:T,left:v}),n(true);};useEffect(()=>{let u=x=>{l.current&&!l.current.contains(x.target)&&!f.current?.contains(x.target)&&(n(false),g(""));};if(s)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[s]),useEffect(()=>{let u=x=>{x.key==="Escape"&&(n(false),g(""));};if(s)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]);let k=u=>{let x=e.some(m=>m.id===u.id);a(x?e.filter(m=>m.id!==u.id):[...e,u]);},C=t.filter(u=>u.name.toLowerCase().includes(c.toLowerCase())),h=e.slice(0,o),b=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:f,onClick:()=>s?n(false):y(),className:"flex items-center gap-1 p-0.5 rounded transition-all hover:bg-white/10 hover:scale-105 active:scale-95",title:e.length>0?`${e.length} assigned`:"Assign users",children:e.length>0?jsxs("div",{className:"asakaa-avatar-group",children:[h.map(u=>jsx("div",{className:"asakaa-avatar",title:u.name,children:u.avatar?jsx("img",{src:u.avatar,alt:u.name,className:"asakaa-avatar-img"}):u.initials},u.id)),b>0&&jsxs("div",{className:"asakaa-avatar",children:["+",b]})]}):jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center transition-all",style:{background:"rgba(96, 165, 250, 0.15)",border:"1.5px solid rgba(96, 165, 250, 0.4)",color:"#60a5fa"},children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M8 8a3 3 0 100-6 3 3 0 000 6zM4 14c0-2.21 1.79-4 4-4s4 1.79 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("line",{x1:"13",y1:"5",x2:"13",y2:"9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("line",{x1:"11",y1:"7",x2:"15",y2:"7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})})}),s&&jsx(ft,{children:jsxs("div",{ref:l,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${i.top}px`,left:`${i.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.8))"},children:"Assign Users"})}),jsx("div",{className:"px-3 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("input",{type:"text",value:c,onChange:u=>g(u.target.value),placeholder:"Search users...",className:"w-full px-3 py-2.5 rounded-lg text-sm border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.2))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[300px] overflow-y-auto",children:C.length===0?jsx("div",{className:"px-4 py-3 text-sm text-center",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.6))"},children:"No users found"}):C.map(u=>{let x=e.some(m=>m.id===u.id);return jsxs("button",{onClick:()=>k(u),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:m=>{m.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:m=>{m.currentTarget.style.background="transparent";},children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[11px] font-bold flex-shrink-0 shadow-sm",style:{backgroundColor:u.color,color:"#fff"},children:u.avatar?jsx("img",{src:u.avatar,alt:u.name,className:"w-full h-full rounded-full object-cover"}):u.initials}),jsx("span",{className:"font-semibold flex-1 text-left truncate",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.95))"},children:u.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:x?"#3b82f6":"transparent"},children:x?"\u2713":""})]},u.id)})}),e.length>0&&jsx("div",{className:"px-3 py-3 border-t border-white/10",children:jsx("button",{onClick:()=>{a([]),n(false);},className:"w-full px-3 py-2.5 rounded-lg text-sm font-semibold transition-all hover:bg-red-600/30 active:scale-95 border",style:{color:"#f87171",borderColor:"rgba(248, 113, 113, 0.3)",background:"rgba(248, 113, 113, 0.08)"},children:"Clear All"})})]})})]})}function Nn(e,t,a){let r=new Map;e.forEach(g=>{if(g.dependencies&&Array.isArray(g.dependencies)){let i=g.dependencies.map(p=>{if(typeof p=="string")return p;let l=p;return l.taskId||l.targetId||""}).filter(Boolean);r.set(g.id,i);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,n=new Set,c=g=>{if(!s.has(g)){s.add(g),n.add(g);let i=r.get(g)||[];for(let p of i){if(!s.has(p)&&c(p))return true;if(n.has(p))return true}}return n.delete(g),false};return c(a)}function _o({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:n}){let[c,g]=useState(false),[i,p]=useState(""),[l,f]=useState(t.length>0),[y,k]=useState({top:0,left:0}),[C,h]=useState(null),b=useRef(null),u=useRef(null),x=()=>{if(!u.current)return;let v=u.current.getBoundingClientRect(),I=window.innerHeight,F=window.innerWidth,T=300,H=l?380:120,O=4,K=v.right-T;K<10&&(K=v.left),K+T>F-10&&(K=F-T-10);let ae=I-v.bottom,ne=v.top,oe;ae>=H+O?oe=v.bottom+O:ne>=H+O?oe=v.top-H-O:oe=ae>=ne?v.bottom+O:Math.max(10,v.top-H-O),k({top:oe,left:K}),g(true);};useEffect(()=>{if(!c||!u.current)return;let v=u.current.getBoundingClientRect(),I=window.innerHeight,F=window.innerWidth,T=300,H=l?380:120,O=4,K=v.right-T;K<10&&(K=v.left),K+T>F-10&&(K=F-T-10);let ae=I-v.bottom,ne=v.top,oe;ae>=H+O?oe=v.bottom+O:ne>=H+O?oe=v.top-H-O:oe=ae>=ne?v.bottom+O:Math.max(10,v.top-H-O),k({top:oe,left:K});},[l,c]),useEffect(()=>{let v=I=>{b.current&&!b.current.contains(I.target)&&!u.current?.contains(I.target)&&(g(false),p(""));};if(c)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]),useEffect(()=>{let v=I=>{I.key==="Escape"&&(g(false),p(""));};if(c)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[c]);let m=v=>{let I=t.includes(v),F=a.find(T=>T.id===v);if(h(null),I){let T=t.filter(H=>H!==v);r(T),T.length===0&&f(false);}else {if(s&&Nn(a,v,e)){let H=`Cannot add "${F?.title||v}" as dependency - would create circular reference`;h(H),n?.(v,F?.title||v),setTimeout(()=>h(null),3e3);return}r([...t,v]),f(true);}},N=()=>{let v=!l;f(v),v||r([]);},w=a.filter(v=>v.id!==e).filter(v=>v.title.toLowerCase().includes(i.toLowerCase())||v.id.toLowerCase().includes(i.toLowerCase())),B=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:u,onClick:()=>c?g(false):x(),className:"flex items-center gap-1 px-2 py-1 rounded transition-all hover:bg-white/5",title:t.length>0?`${t.length} dependencies`:"Add dependencies",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M7 9L9 7M11.5 3.5L10 2C8.89543 0.89543 7.10457 0.89543 6 2C4.89543 3.10457 4.89543 4.89543 6 6L7.5 7.5M4.5 12.5L6 14C7.10457 15.1046 8.89543 15.1046 10 14C11.1046 12.8954 11.1046 11.1046 10 10L8.5 8.5",stroke:B,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:B},children:t.length})]}),c&&jsx(ft,{children:jsxs("div",{ref:b,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${y.top}px`,left:`${y.left}px`,maxHeight:"calc(100vh - 40px)",overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:[C&&jsxs("div",{className:"px-4 py-3 flex items-center gap-2",style:{background:"rgba(239, 68, 68, 0.15)",borderBottom:"1px solid rgba(239, 68, 68, 0.3)"},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M8 5V8M8 11H8.01M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z",stroke:"#ef4444",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"text-xs font-medium",style:{color:"#ef4444"},children:C})]}),jsx("div",{className:"px-4 py-2 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Task Dependencies"})}),jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsxs("label",{className:"flex items-center gap-2 cursor-pointer group",onClick:N,children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center transition-all",style:{background:l?"#3b82f6":"transparent",borderColor:l?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:l&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{className:"text-sm font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.8))"},children:"Has dependencies"})]})}),l&&jsxs(Fragment,{children:[jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.05))"},children:jsx("input",{type:"text",value:i,onChange:v=>p(v.target.value),placeholder:"Search by name or ID...",className:"w-full px-3 py-2 rounded-md text-xs border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[280px] overflow-y-auto",children:w.length===0?jsx("div",{className:"px-4 py-3 text-xs text-center",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:"No tasks found"}):w.map(v=>{let I=t.includes(v.id);return jsxs("button",{onClick:()=>m(v.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:F=>{F.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:F=>{F.currentTarget.style.background="transparent";},children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0 mt-0.5 transition-all",style:{background:I?"#3b82f6":"transparent",borderColor:I?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:I&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxs("div",{className:"flex-1 text-left",children:[jsx("div",{className:"font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.9))"},children:v.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:v.id})]})]},v.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),f(false),g(false);},className:"w-full px-3 py-2 rounded-md text-xs font-medium transition-all hover:bg-red-600/20 border border-red-500/30",style:{color:"#E74C3C"},children:"Clear All Dependencies"})})]})})]})}var Sr=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:n,availableUsers:c=[],allCards:g=[]})=>{let{attributes:i,listeners:p,setNodeRef:l,transform:f,transition:y,isDragging:k}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),C={transform:kn.Transform.toString(f),transition:y};if(t)return jsx("div",{ref:l,style:C,...i,...p,onClick:()=>a?.(e),children:t(e)});let h=c.filter(m=>e.assignedUserIds?.includes(m.id)),b=e.progress===100,u=(e.attachments||[]).filter(m=>m.type.startsWith("image/")),x={...C,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:l,style:x,className:d("asakaa-card",k&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...i,...p,onClick:m=>{m.target.closest(".priority-selector, .date-picker, .user-selector, .dependencies-selector")||a?.(e);},children:[e.coverImage&&jsx("div",{className:"asakaa-card-cover mb-3",children:jsx("img",{src:e.coverImage,alt:`Cover for ${e.title}`,className:"w-full h-32 object-cover rounded-md",loading:"lazy",onError:m=>{m.currentTarget.style.display="none";}})}),u.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:u.length===1&&u[0]?jsx("img",{src:u[0].url,alt:u[0].name,className:"w-full h-32 object-cover rounded-md",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:m=>{m.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:u.slice(0,4).map((m,N)=>jsxs("div",{className:"relative",children:[jsx("img",{src:m.url,alt:m.name,className:"w-full h-16 object-cover rounded",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:w=>{w.currentTarget.style.display="none";}}),N===3&&u.length>4&&jsx("div",{className:"absolute inset-0 bg-black/60 rounded flex items-center justify-center",children:jsxs("span",{className:"text-white text-sm font-medium",children:["+",u.length-4]})})]},m.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:b?"line-through":"none",opacity:b?.6:1},children:e.title}),e.description&&jsx("p",{className:"asakaa-card-description mb-3",children:e.description}),jsxs("div",{className:"flex items-center gap-3 mb-3 pt-1",children:[jsx("div",{onClick:m=>m.stopPropagation(),className:"priority-selector",children:jsx(ao,{priority:e.priority,onChange:m=>n?.(e.id,{priority:m})})}),jsx("div",{onClick:m=>m.stopPropagation(),className:"date-picker",children:jsx(Wo,{startDate:e.startDate?typeof e.startDate=="string"?e.startDate:e.startDate.toISOString().split("T")[0]:void 0,endDate:e.endDate?typeof e.endDate=="string"?e.endDate:e.endDate.toISOString().split("T")[0]:void 0,onChange:(m,N)=>n?.(e.id,{startDate:m,endDate:N})})}),c.length>0&&jsx("div",{onClick:m=>m.stopPropagation(),className:"user-selector",children:jsx(oo,{assignedUsers:h,availableUsers:c,onChange:m=>n?.(e.id,{assignedUserIds:m.map(N=>N.id)})})}),jsx("div",{onClick:m=>m.stopPropagation(),className:"dependencies-selector",children:jsx(_o,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(m=>typeof m=="string"?m:m.taskId):[],availableTasks:g,onChange:m=>n?.(e.id,{dependencies:m})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(m=>jsx("span",{className:"asakaa-label",children:m},m))}),typeof e.progress=="number"&&jsxs("div",{className:"mt-3 pt-2 border-t border-white/5",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-[10px] text-[#6B7280]",children:"Progreso"}),jsxs("span",{className:"text-[10px] font-medium",style:{color:"#3B82F6"},children:[Math.round(e.progress),"%"]})]}),jsx("div",{className:"h-1.5 rounded-full bg-white/5 overflow-hidden",children:jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progress))}%`,backgroundColor:"#3B82F6"}})})]})]})},(e,t)=>e.card.id===t.card.id&&e.card.title===t.card.title&&e.card.description===t.card.description&&e.card.position===t.card.position&&e.card.columnId===t.card.columnId&&e.card.priority===t.card.priority&&e.card.color===t.card.color&&e.card.progress===t.card.progress&&e.card.startDate===t.card.startDate&&e.card.endDate===t.card.endDate&&e.isSelected===t.isSelected&&JSON.stringify(e.card.labels)===JSON.stringify(t.card.labels)&&JSON.stringify(e.card.assignedUserIds)===JSON.stringify(t.card.assignedUserIds)&&JSON.stringify(e.card.dependencies)===JSON.stringify(t.card.dependencies)&&JSON.stringify(e.card.attachments?.map(a=>a.id))===JSON.stringify(t.card.attachments?.map(a=>a.id)));Sr.displayName="Card";var Dn={todo:{label:"To Do",color:"#94a3b8",icon:"circle"},"in-progress":{label:"In Progress",color:"#60a5fa",icon:"circle-dot"},completed:{label:"Completed",color:"#34d399",icon:"check-circle"}},Bd=({icon:e,color:t})=>e==="circle"?jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"})}):e==="circle-dot"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:"none"}),jsx("circle",{cx:"8",cy:"8",r:"3",fill:t})]}):jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:t,strokeWidth:"1.5",fill:t,fillOpacity:"0.2"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:t,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});function Rd({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),g=useRef(null),i=useRef(null),p=[...Object.entries(Dn).map(([h,b])=>({id:h,label:b.label,color:b.color,icon:b.icon})),...r.filter(h=>!Object.keys(Dn).includes(h.id)).map(h=>({id:h.id,label:h.title,color:h.color||"#8B5CF6",icon:"circle-dot"}))],l=()=>{let h=Dn[e];if(h)return {...h,id:e};let b=r.find(u=>u.id===e);return b?{id:b.id,label:b.title,color:b.color||"#8B5CF6",icon:"circle-dot"}:{...Dn.todo,id:"todo"}},f=()=>{if(!i.current)return;let h=i.current.getBoundingClientRect(),b=window.innerHeight,u=window.innerWidth,x=180,m=280,N=4,w=h.right-x;w<10&&(w=h.left),w+x>u-10&&(w=u-x-10);let B=b-h.bottom,v=h.top,I;B>=m+N?I=h.bottom+N:v>=m+N?I=h.top-m-N:I=B>=v?h.bottom+N:Math.max(10,h.top-m-N),c({top:I,left:w}),s(true);};useEffect(()=>{let h=b=>{g.current&&!g.current.contains(b.target)&&!i.current?.contains(b.target)&&s(false);};if(o)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o]),useEffect(()=>{let h=b=>{b.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[o]);let y=h=>{t(h),s(false);},k=l(),C=k.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:i,onClick:()=>o?s(false):f(),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-all hover:bg-white/15 hover:scale-110 active:scale-95",style:{background:`${C}10`,boxShadow:`0 0 0 2px ${C}30 inset`},title:k.label,children:jsx(Bd,{icon:k.icon,color:C})}),o&&jsx(ft,{children:jsxs("div",{ref:g,className:"status-selector-menu",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,zIndex:99999,minWidth:"180px",maxHeight:"calc(100vh - 40px)",overflowY:"auto",borderRadius:"8px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},children:[jsx("div",{className:"px-3 py-1.5 border-b",style:{borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))"},children:jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--modal-v2-text-secondary, rgba(255, 255, 255, 0.7))"},children:"Status"})}),jsx("div",{className:"py-1",children:p.map(h=>jsxs("button",{onClick:()=>y(h.id),className:"w-full px-3 py-2 flex items-center gap-2.5 text-sm font-medium transition-all active:scale-[0.98] status-option",style:{color:h.color,background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:b=>{b.currentTarget.style.background="transparent";},children:[jsx(Bd,{icon:h.icon,color:h.color}),jsx("span",{className:"font-semibold",children:h.label}),e===h.id&&jsx("svg",{className:"ml-auto",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"#3B82F6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},h.id))})]})})]})}function Od({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,n]=useState(false),[c,g]=useState(false),[i,p]=useState(e),[l,f]=useState({top:0,left:0}),y=useRef(null),k=useRef(null),C=useRef(null);useEffect(()=>{if(s&&k.current){let x=k.current.getBoundingClientRect();f({top:x.bottom+window.scrollY+8,left:x.left+window.scrollX});}},[s]),useEffect(()=>{let x=m=>{y.current&&!y.current.contains(m.target)&&!k.current?.contains(m.target)&&(n(false),g(false));};if(s)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[s]),useEffect(()=>{let x=m=>{m.key==="Escape"&&(n(false),g(false),p(e));};if(s)return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[s,e]),useEffect(()=>{c&&C.current&&(C.current.focus(),C.current.select());},[c]);let h=()=>{g(true),p(e);},b=()=>{let x=i.trim();x&&x!==e&&t(x),g(false),n(false),p(e);},u=x=>{x.key==="Enter"?b():x.key==="Escape"&&(g(false),p(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:k,onClick:()=>n(!s),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-white/10",title:"Column options","aria-label":"Column menu",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"3",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"8",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"13",r:"1.5",fill:"currentColor"})]})}),s&&jsx(ft,{children:jsx("div",{ref:y,className:"fixed rounded-xl shadow-2xl border min-w-[200px]",style:{top:`${l.top}px`,left:`${l.left}px`,background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)",zIndex:99999},children:c?jsxs("div",{className:"p-3",children:[jsx("label",{className:"text-xs font-bold text-white/80 uppercase tracking-wider block mb-2",children:"Rename Column"}),jsx("input",{ref:C,type:"text",value:i,onChange:x=>p(x.target.value),onKeyDown:u,onBlur:b,className:"w-full px-3 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/50 outline-none focus:border-blue-500/50 transition-all",placeholder:"Column name",maxLength:50})]}):jsxs("div",{className:"py-1",children:[jsxs("button",{onClick:h,className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm text-white/90 hover:bg-white/10 transition-all",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M11.5 1.5L14.5 4.5L5 14H2V11L11.5 1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-medium",children:"Rename"})]}),r&&a&&jsxs(Fragment,{children:[jsx("div",{className:"h-px bg-white/10 mx-2 my-1"}),jsxs("button",{onClick:()=>{a(),n(false);},className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm text-red-400 hover:bg-red-500/10 transition-all",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 4H14M5 4V2.5C5 2.22386 5.22386 2 5.5 2H10.5C10.7761 2 11 2.22386 11 2.5V4M12.5 4V13.5C12.5 13.7761 12.2761 14 12 14H4C3.72386 14 3.5 13.7761 3.5 13.5V4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M6.5 7V11M9.5 7V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsx("span",{className:"font-medium",children:"Delete"})]})]})]})})})]})}var No=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:n,onCardUpdate:c,availableUsers:g,allCards:i,enableVirtualization:p,cardHeight:l=120,isCollapsed:f,onToggleCollapse:y,onColumnRename:k,onColumnDelete:C,isDeletable:h=false,className:b})=>{let{setNodeRef:u,isOver:x}=useDroppable({id:e.id,data:{type:"column",column:e}}),m=useRef(null),N=p??dd(t.length),w=useVirtualizer({count:t.length,getScrollElement:()=>m.current,estimateSize:()=>l,enabled:N});if(a)return jsx("div",{ref:u,className:b,children:a(e,t)});let v=(()=>{if(!e.wipLimit)return {state:"none",percentage:0};let T=t.length/e.wipLimit*100;return t.length>e.wipLimit?{state:"exceeded",percentage:T}:T>=80?{state:"warning",percentage:T}:T>=60?{state:"approaching",percentage:T}:{state:"ok",percentage:T}})(),I=v.state==="exceeded",F=()=>"asakaa-column-count";return jsxs("div",{ref:u,className:d("asakaa-column",x&&"ring-2 ring-asakaa-accent-blue",I&&"ring-2 ring-asakaa-accent-red",b),children:[o?o(e,t.length):jsxs("div",{className:"asakaa-column-header group",children:[jsx("h2",{className:"asakaa-column-title",children:e.title}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:d(F()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&v.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${v.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[v.state==="exceeded"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#EF4444",opacity:"0.9"}),jsx("path",{d:"M5 5L11 11M11 5L5 11",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}),v.state==="warning"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("path",{d:"M8 1L15 14H1L8 1Z",fill:"#F59E0B",opacity:"0.9"}),jsx("path",{d:"M8 6V9M8 11V11.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"})]}),v.state==="approaching"&&jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M8 1L10 7H14L10 10L12 16L8 12L4 16L6 10L2 7H6L8 1Z",fill:"#FB923C",opacity:"0.9"})}),v.state==="ok"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#10B981",opacity:"0.9"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]}),(k||C)&&jsx(Od,{columnTitle:e.title,onRename:T=>k?.(e.id,T),onDelete:C?()=>C(e.id):void 0,isDeletable:h}),y&&jsx("button",{onClick:y,className:"text-asakaa-text-tertiary hover:text-asakaa-text-primary","aria-label":f?"Expand column":"Collapse column",children:f?"\u25B6":"\u25BC"})]})]}),!f&&jsx("div",{ref:m,className:"asakaa-column-cards",style:{maxHeight:N?"600px":void 0},children:jsx(SortableContext,{items:t.map(T=>T.id),strategy:verticalListSortingStrategy,children:t.length===0?s?s(e):jsx("div",{className:"asakaa-drop-zone asakaa-empty",children:jsx("p",{children:"Drop cards here"})}):N?jsx("div",{style:{height:`${w.getTotalSize()}px`,position:"relative"},children:w.getVirtualItems().map(T=>{let H=t[T.index];return H?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${T.start}px)`},children:jsx(Sr,{card:H,render:r,onClick:n,onUpdate:c,availableUsers:g,allCards:i})},H.id):null})}):t.map(T=>jsx(Sr,{card:T,render:r,onClick:n,onUpdate:c,availableUsers:g,allCards:i},T.id))})})]})});No.displayName="Column";function _s({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,n]=useState(e),c=useRef(null);useEffect(()=>{r&&c.current&&(c.current.focus(),c.current.select());},[r]);let g=()=>{let p=s.trim();p&&p!==e?t(p):n(e),o(false);},i=p=>{p.key==="Enter"?g():p.key==="Escape"&&(n(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:p=>n(p.target.value),onBlur:g,onKeyDown:i,className:d("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:d("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}function bg(e,t){let a=e.slice(0,t),r=a.lastIndexOf("@");if(r===-1)return null;let o=a[r-1];if(r>0&&o&&!/\s/.test(o))return null;let s=a.slice(r+1);return /\s/.test(s)?null:{start:r,end:t,query:s.toLowerCase()}}function Gd(e,t){let a=[],r=/@(\S+)/g,o;for(;(o=r.exec(e))!==null;){let s=o[1]?.toLowerCase()??"";if(!s)continue;let n=t.find(c=>c.name.toLowerCase().replace(/\s+/g,"")===s||c.name.toLowerCase()===s);n&&!a.includes(n.id)&&a.push(n.id);}return a}function hg(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function _d({value:e,onChange:t,onSubmit:a,users:r,placeholder:o,disabled:s=false,isSubmitting:n=false,theme:c="dark",locale:g="es",currentUser:i}){let p=c==="dark",[l,f]=useState(false),[y,k]=useState([]),[C,h]=useState(0),[b,u]=useState(null),x=useRef(null),m=useRef(null),N=useCallback((F,T)=>{let H=bg(F,T);if(u(H),H){let O=r.filter(K=>K.name.toLowerCase().includes(H.query)||K.email&&K.email.toLowerCase().includes(H.query)).slice(0,5);k(O),f(O.length>0),h(0);}else f(false),k([]);},[r]),w=F=>{let T=F.target.value;t(T),N(T,F.target.selectionStart||0);},B=()=>{x.current&&N(e,x.current.selectionStart||0);},v=useCallback(F=>{if(!b||!x.current)return;let T=e.slice(0,b.start),H=e.slice(b.end),O=`@${F.name.replace(/\s+/g,"")} `,K=T+O+H;t(K),f(false),u(null),setTimeout(()=>{if(x.current){let ae=b.start+O.length;x.current.selectionStart=ae,x.current.selectionEnd=ae,x.current.focus();}},0);},[b,e,t]),I=F=>{if(l&&y.length>0)switch(F.key){case "ArrowDown":F.preventDefault(),h(T=>T<y.length-1?T+1:0);break;case "ArrowUp":F.preventDefault(),h(T=>T>0?T-1:y.length-1);break;case "Enter":{F.preventDefault();let T=y[C];T&&v(T);break}case "Tab":{F.preventDefault();let T=y[C];T&&v(T);break}case "Escape":F.preventDefault(),f(false);break}else F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),a());};return useEffect(()=>{let F=T=>{m.current&&!m.current.contains(T.target)&&x.current&&!x.current.contains(T.target)&&f(false);};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[]),useEffect(()=>{if(l&&m.current){let F=m.current.children[C];F&&F.scrollIntoView({block:"nearest"});}},[C,l]),jsxs("div",{className:"flex items-start gap-2",children:[i&&jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:i.color||"#8B5CF6"},children:i.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:d("flex-1 relative"),children:[jsxs("div",{className:d("flex items-center gap-2 px-3 py-2 rounded-lg",p?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{ref:x,type:"text",value:e,onChange:w,onSelect:B,onKeyDown:I,placeholder:o||(g==="es"?"Escribe un comentario...":"Write a comment..."),disabled:s||n,className:d("flex-1 bg-transparent text-sm outline-none",p?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(s||n)&&"opacity-50")}),jsx("button",{onClick:a,disabled:n||!e.trim()||s,className:d("p-1.5 rounded transition-colors",e.trim()&&!s?"bg-blue-500 text-white hover:bg-blue-600":p?"text-[#6B7280]":"text-gray-400",n&&"opacity-50 cursor-not-allowed"),children:n?jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):jsx(Send,{className:"w-4 h-4"})})]}),jsx(AnimatePresence,{children:l&&y.length>0&&jsx(motion.div,{ref:m,initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},className:d("absolute bottom-full left-0 right-0 mb-1 py-1 rounded-lg shadow-xl z-50","max-h-[200px] overflow-y-auto",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:y.map((F,T)=>jsxs("button",{type:"button",onClick:()=>v(F),className:d("w-full flex items-center gap-3 px-3 py-2 text-left transition-colors",T===C?p?"bg-white/10":"bg-gray-100":p?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:F.color||"#8B5CF6"},children:hg(F.name)}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("p",{className:d("text-sm font-medium truncate",p?"text-white":"text-gray-900"),children:F.name}),F.email&&jsx("p",{className:d("text-xs truncate",p?"text-[#6B7280]":"text-gray-500"),children:F.email})]})]},F.id))})})]})]})}function Vd({content:e,theme:t="dark"}){let a=t==="dark",r=[],o=/@(\S+)/g,s=0,n;for(;(n=o.exec(e))!==null;)n.index>s&&r.push({type:"text",value:e.slice(s,n.index)}),r.push({type:"mention",value:n[0]}),s=n.index+n[0].length;return s<e.length&&r.push({type:"text",value:e.slice(s)}),jsx("span",{className:"whitespace-pre-wrap break-words",children:r.map((c,g)=>c.type==="mention"?jsx("span",{className:d("inline-flex items-center px-1 py-0.5 rounded","font-medium text-sm",a?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:c.value},g):jsx("span",{children:c.value},g))})}var An=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function hr({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:n=true}){let[c,g]=useState(false),[i,p]=useState(""),[l,f]=useState(false),[y,k]=useState(An[10]||"#3B82F6"),[C,h]=useState({top:0,left:0}),b=useRef(null),u=useRef(null),x=useRef(null),m=useRef(null),N=t.filter(T=>T.name.toLowerCase().includes(i.toLowerCase())),w=t.some(T=>T.name.toLowerCase()===i.toLowerCase());useEffect(()=>{if(c&&u.current){let T=u.current.getBoundingClientRect();h({top:T.bottom+6,left:T.left});}},[c]),useEffect(()=>{let T=H=>{let O=H.target,K=b.current?.contains(O),ae=x.current?.contains(O);!K&&!ae&&(g(false),p(""),f(false));};if(c)return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[c]),useEffect(()=>{c&&m.current&&m.current.focus();},[c]);let B=T=>{let H=e.some(O=>O.id===T.id);a(H?e.filter(O=>O.id!==T.id):[...e,T]);},v=async()=>{if(!(!r||!i.trim())){f(true);try{let T=await r(i.trim(),y);T&&(a([...e,T]),p(""),k(An[Math.floor(Math.random()*An.length)]||"#3B82F6"));}finally{f(false);}}},I=(T,H)=>{H.stopPropagation(),a(e.filter(O=>O.id!==T));},F={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:b,className:"relative",children:[jsxs("button",{ref:u,type:"button",onClick:()=>!s&&g(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:F,disabled:s,children:[jsx(Tag,{className:"w-3.5 h-3.5"}),e.length>0?jsxs("div",{className:"flex items-center gap-1",children:[e.slice(0,2).map(T=>jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",style:{backgroundColor:`${T.color}20`,color:T.color},children:T.name},T.id)),e.length>2&&jsxs("span",{className:"text-xs",style:{color:o.textTertiary},children:["+",e.length-2]})]}):jsx("span",{children:"Agregar"}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:o.textTertiary}})]}),typeof document<"u"&&createPortal(jsx(AnimatePresence,{children:c&&jsxs(motion.div,{ref:x,initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg min-w-[240px]",style:{position:"fixed",top:C.top,left:C.left,zIndex:99999,backgroundColor:o.bgPrimary,border:`1px solid ${o.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:[jsx("div",{className:"p-2 border-b",style:{borderColor:o.border},children:jsx("input",{ref:m,type:"text",value:i,onChange:T=>p(T.target.value),placeholder:"Buscar o crear etiqueta...",className:"w-full px-3 py-1.5 text-sm rounded-md outline-none",style:{backgroundColor:o.bgSecondary,color:o.textPrimary,border:`1px solid ${o.borderLight}`},onKeyDown:T=>{T.key==="Enter"&&i.trim()&&!w&&r&&v();}})}),e.length>0&&jsxs("div",{className:"p-2 border-b",style:{borderColor:o.border},children:[jsx("p",{className:"text-xs mb-1.5",style:{color:o.textTertiary},children:"Seleccionadas"}),jsx("div",{className:"flex flex-wrap gap-1",children:e.map(T=>jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium cursor-pointer hover:opacity-80",style:{backgroundColor:`${T.color}20`,color:T.color},onClick:H=>I(T.id,H),children:[T.name,jsx(X,{className:"w-3 h-3"})]},T.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:N.length>0?N.map(T=>{let H=e.some(O=>O.id===T.id);return jsxs("button",{type:"button",onClick:()=>B(T),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:H?`${T.color}15`:"transparent",color:o.textPrimary},onMouseEnter:O=>{H||(O.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:O=>{H||(O.currentTarget.style.backgroundColor="transparent");},children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:T.color}}),jsx("span",{className:"flex-1 text-left",children:T.name}),H&&jsx(Check,{className:"w-4 h-4",style:{color:T.color}})]},T.id)}):i.trim()?jsx("div",{className:"p-2 text-center text-sm",style:{color:o.textTertiary},children:"No se encontraron etiquetas"}):jsx("div",{className:"p-2 text-center text-sm",style:{color:o.textTertiary},children:"No hay etiquetas disponibles"})}),i.trim()&&!w&&r&&jsxs("div",{className:"p-2 border-t",style:{borderColor:o.border},children:[jsx("div",{className:"flex items-center gap-2 mb-2",children:jsx("p",{className:"text-xs",style:{color:o.textTertiary},children:"Crear nueva etiqueta"})}),jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:An.map(T=>jsx("button",{type:"button",onClick:()=>k(T),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:T,outline:y===T?`2px solid ${T}`:"none",outlineOffset:"2px"}},T))}),jsxs("button",{type:"button",onClick:v,disabled:l,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{backgroundColor:y,color:"#FFFFFF",opacity:l?.7:1},children:[l?jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):jsx(Plus,{className:"w-4 h-4"}),'Crear "',i.trim(),'"']})]})]})}),document.body)]})}function js({tag:e,onRemove:t,size:a="sm"}){return jsxs("span",{className:`inline-flex items-center gap-1 rounded-full font-medium ${a==="xs"?"px-1.5 py-0.5 text-[10px]":"px-2 py-0.5 text-xs"}`,style:{backgroundColor:`${e.color}20`,color:e.color},children:[e.name,t&&jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t();},className:"hover:opacity-70",children:jsx(X,{className:"w-3 h-3"})})]})}function Kd({tags:e,maxVisible:t=3,size:a="sm"}){if(!e||e.length===0)return null;let r=e.slice(0,t),o=e.length-t;return jsxs("div",{className:"flex flex-wrap gap-1",children:[r.map(s=>jsx(js,{tag:s,size:a},s.id)),o>0&&jsxs("span",{className:`inline-flex items-center rounded-full font-medium ${a==="xs"?"px-1.5 py-0.5 text-[10px]":"px-2 py-0.5 text-xs"}`,style:{backgroundColor:"rgba(100,100,100,0.2)",color:"#9CA3AF"},children:["+",o]})]})}var yr=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];function Zd(e,t=[]){if("title"in e&&!("name"in e)){let a=e,r=(a.assignedUserIds||[]).map(o=>{let s=t.find(n=>n.id===o);return s||null}).filter(o=>o!==null);return {id:a.id,name:a.title,startDate:a.startDate?new Date(a.startDate):void 0,endDate:a.endDate?new Date(a.endDate):void 0,progress:a.progress||0,status:a.columnId,priority:a.priority?.toLowerCase(),assignees:r,dependencies:Array.isArray(a.dependencies)?a.dependencies.map(o=>typeof o=="string"?o:o.taskId):[],tags:a.tags,subtasks:a.subtasks?.map(o=>({id:o.id,name:o.title,progress:o.completed?100:0,startDate:new Date,endDate:new Date})),color:a.color,description:a.description}}return e}function _g(e,t){return {...t,title:e.name,startDate:e.startDate,endDate:e.endDate,progress:e.progress,priority:e.priority?.toUpperCase(),tags:e.tags,description:e.description,color:e.color,columnId:e.status,assignedUserIds:t.assignedUserIds}}function io({task:e,isOpen:t,onClose:a,onTaskUpdate:r,onCardUpdate:o,theme:s="dark",locale:n="es",availableUsers:c=[],availableTags:g=[],onCreateTag:i,attachments:p=[],onUploadAttachments:l,onDeleteAttachment:f,availableTasks:y=[],comments:k=[],onAddComment:C,currentUser:h,mentionableUsers:b=[]}){let u=s==="dark",x={textTertiary:u?"#6B7280":"#9CA3AF",textSecondary:u?"#9CA3AF":"#6B7280",textPrimary:u?"#FFFFFF":"#111827",borderLight:u?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:u?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:u?"#1A1D25":"#FFFFFF",bgSecondary:u?"#0F1117":"#F9FAFB",hoverBg:u?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},m=e&&"title"in e&&!("name"in e),N=e,[w,B]=useState(e?Zd(e,c):null),[v,I]=useState(false),[F,T]=useState(false),[H,O]=useState(false),[K,ae]=useState(null),[ne,oe]=useState(new Date),[ye,fe]=useState(false),[Re,A]=useState(false),[R,L]=useState(""),[j,J]=useState(false),[U,ge]=useState(false),[le,Fe]=useState(false),[qe,et]=useState(""),de=useRef(null),[Ke,dt]=useState(""),vt=useRef(null),[kt,$]=useState(""),[me,Le]=useState(false);useEffect(()=>{if(e){let S=Zd(e,c);B(S),et(S.description||""),dt(S.name||"");}},[e?.id,c]),useEffect(()=>()=>{de.current&&clearTimeout(de.current),vt.current&&clearTimeout(vt.current);},[]);let Se=useCallback(S=>{B(S),m&&o&&N?o(_g(S,N)):r&&r(S);},[m,N,o,r]),Ye=useCallback(()=>{I(false),T(false),O(false),ae(null),A(false),L(""),J(false);},[]),Je=useCallback((S,Ce)=>{if(!w)return;let X={...w,[S]:Ce};Se(X);},[w,Se]),Pt=useCallback(S=>{et(S),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{if(w){let Ce={...w,description:S};Se(Ce);}},800);},[w,Se]),Oe=useCallback(S=>{dt(S),vt.current&&clearTimeout(vt.current),vt.current=setTimeout(()=>{if(w&&S.trim()){let Ce={...w,name:S.trim()};Se(Ce);}},800);},[w,Se]),Z=useCallback(async()=>{if(!(!w||!kt.trim()||!C)){Le(true);try{let S=Gd(kt,b);await C(w.id,kt.trim(),S.length>0?S:void 0),$("");}finally{Le(false);}}},[w,kt,C,b]),xe=useCallback(S=>{let Ce=typeof S=="string"?new Date(S):S,we=new Date().getTime()-Ce.getTime(),ke=Math.floor(we/6e4),He=Math.floor(we/36e5),$e=Math.floor(we/864e5);return ke<1?n==="es"?"Ahora":"Just now":ke<60?n==="es"?`Hace ${ke} min`:`${ke}m ago`:He<24?n==="es"?`Hace ${He}h`:`${He}h ago`:$e<7?n==="es"?`Hace ${$e}d`:`${$e}d ago`:Ce.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})},[n]),ze=useCallback(S=>{if(!w)return;let Ce=w.progress||0;S==="completed"?Ce=100:S==="in-progress"&&Ce===0?Ce=10:S==="todo"&&(Ce=0);let X={...w,status:S,progress:Ce};Se(X),I(false);},[w,Se]),Be=useCallback((S,Ce)=>{if(!w)return;let X={...w,startDate:S,endDate:Ce};Se(X);},[w,Se]),st=useCallback(()=>{let S=ne.getFullYear(),Ce=ne.getMonth(),X=new Date(S,Ce,1),ke=new Date(S,Ce+1,0).getDate(),He=X.getDay(),$e=[],tt=new Date(S,Ce,0).getDate();for(let Y=He-1;Y>=0;Y--)$e.push({date:new Date(S,Ce-1,tt-Y),isCurrentMonth:false});for(let Y=1;Y<=ke;Y++)$e.push({date:new Date(S,Ce,Y),isCurrentMonth:true});let _=42-$e.length;for(let Y=1;Y<=_;Y++)$e.push({date:new Date(S,Ce+1,Y),isCurrentMonth:false});return $e},[ne]),nt=useCallback(async S=>{if(S.preventDefault(),S.stopPropagation(),ge(false),!w||!l)return;let Ce=Array.from(S.dataTransfer.files);if(Ce.length!==0){Fe(true);try{await l(w.id,Ce);}finally{Fe(false);}}},[w,l]),Ve=useCallback(async S=>{if(!w||!l||!S.target.files)return;let Ce=Array.from(S.target.files);if(Ce.length!==0){Fe(true);try{await l(w.id,Ce);}finally{Fe(false);}S.target.value="";}},[w,l]),Vt=useCallback(S=>{S.preventDefault(),S.stopPropagation(),ge(true);},[]),Bt=useCallback(S=>{S.preventDefault(),S.stopPropagation(),ge(false);},[]),Ze=useCallback(S=>S<1024?`${S} B`:S<1024*1024?`${(S/1024).toFixed(1)} KB`:`${(S/(1024*1024)).toFixed(1)} MB`,[]),te=useCallback(S=>S.startsWith("image/")?Image:S.includes("pdf")||S.includes("document")?FileText:File,[]);return !t||!w?null:jsx(AnimatePresence,{children:t&&w&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:a,className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:d("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",u?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:d("px-6 py-3 border-b flex items-center gap-3",u?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:d("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:d("text-xs px-2 py-0.5 rounded",u?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:d("text-xs font-mono",u?"text-[#6B7280]":"text-gray-400"),children:w.id.slice(0,8)}),jsxs("button",{className:d("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",u?"bg-purple-500/20 text-purple-400 hover:bg-purple-500/30":"bg-purple-100 text-purple-700 hover:bg-purple-200"),children:[jsx(Sparkles,{className:"w-3 h-3"}),"Ask AI"]})]}),jsx("div",{className:"flex-1"}),jsx("button",{className:d("p-1.5 rounded transition-colors",u?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:d("p-1.5 rounded transition-colors",u?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:a,className:d("p-1.5 rounded transition-colors",u?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-5 h-5"})})]}),jsx("div",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("button",{onClick:()=>{let S=w.progress===100?0:100,X={...w,progress:S,status:S===100?"completed":"todo"};Se(X);},className:d("mt-2 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors flex-shrink-0",w.progress===100?"bg-green-500 border-green-500":u?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:w.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("input",{type:"text",value:Ke,onChange:S=>Oe(S.target.value),placeholder:n==="es"?"Nombre de la tarea...":"Task name...",className:d("text-xl font-semibold flex-1 bg-transparent outline-none border-none px-0 py-0","focus:ring-0 focus:outline-none",w.progress===100?"line-through text-[#6B7280]":u?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400")})]})}),jsxs("div",{className:"px-6 pb-6 flex-1 overflow-y-auto overflow-x-visible",children:[jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-5",children:[jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CheckCircle2,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{Ye(),I(!v);},className:d("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",w.progress===100||w.status==="completed"?"bg-green-500/20 text-green-400":w.progress&&w.progress>0||w.status==="in-progress"?"bg-blue-500/20 text-blue-400":u?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:w.progress===100||w.status==="completed"?n==="es"?"COMPLETADO":"DONE":w.progress&&w.progress>0||w.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:v&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>I(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:n==="es"?"Por hacer":"To Do",color:"bg-gray-400"},{id:"in-progress",label:n==="es"?"En progreso":"In Progress",color:"bg-blue-500"},{id:"completed",label:n==="es"?"Completado":"Done",color:"bg-green-500"}].map(S=>jsxs("button",{onClick:()=>ze(S.id),className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",u?"hover:bg-white/5":"hover:bg-gray-50",w.status===S.id&&(u?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",S.color)}),jsx("span",{className:u?"text-white":"text-gray-900",children:S.label})]},S.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{Ye(),O(!H);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[w.assignees&&w.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[w.assignees.slice(0,3).map((S,Ce)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:S.color||"#8B5CF6"},title:S.name,children:S.initials||S.name.slice(0,2).toUpperCase()},Ce)),w.assignees.length>3&&jsxs("span",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:["+",w.assignees.length-3]})]}):jsx("span",{className:d("text-sm",u?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:d("w-3 h-3",u?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:H&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>O(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:c.length>0?c.map(S=>{let Ce=w.assignees?.some(X=>X.name===S.name);return jsxs("button",{onClick:()=>{let X=w.assignees||[],we;Ce?we=X.filter(ke=>ke.name!==S.name):we=[...X,S],Je("assignees",we);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",u?"hover:bg-white/5":"hover:bg-gray-50",Ce&&(u?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:S.color||"#8B5CF6"},children:S.initials||S.name.slice(0,2).toUpperCase()}),jsx("span",{className:d("flex-1",u?"text-white":"text-gray-900"),children:S.name}),Ce&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},S.name)}):jsx("div",{className:d("px-3 py-4 text-sm text-center",u?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{ae(K?null:"start"),oe(w.startDate||new Date);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[w.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:d("mx-1",u?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),w.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End")]}),jsx(AnimatePresence,{children:K&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ae(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:d("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:S=>S.stopPropagation(),children:[jsxs("div",{className:d("w-44 py-2 border-r",u?"border-white/10":"border-gray-200"),children:[(()=>{let S=new Date,Ce=new Date(S);Ce.setDate(S.getDate()+1);let X=new Date(S);X.setDate(S.getDate()+((6-S.getDay()+7)%7||7));let we=new Date(S);we.setDate(S.getDate()+((1-S.getDay()+7)%7||7));let ke=new Date(S);ke.setDate(S.getDate()+(6-S.getDay()+7)%7+7);let He=new Date(S);He.setDate(S.getDate()+14);let $e=new Date(S);return $e.setDate(S.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:S,display:S.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:Ce,display:Ce.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:X,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:we,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:ke,display:ke.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:He,display:He.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:$e,display:$e.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((_,Y)=>jsxs("button",{className:d("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",u?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(K==="start"){let be=w.endDate&&_.date>w.endDate?_.date:w.endDate;Be(_.date,be),ae("end");}else {let be=w.startDate&&_.date<w.startDate?_.date:w.startDate;Be(be,_.date),ae(null);}},children:[jsx("span",{children:_.label}),jsx("span",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:_.display})]},Y))})(),jsx("div",{className:d("border-t mt-2 pt-2",u?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Be(void 0,void 0),ae(null);},className:d("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",u?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:n==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:d("text-xs mb-3 px-2 py-1 rounded",u?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:K==="start"?n==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":n==="es"?"\u{1F4C5} Selecciona fecha de fin":"\u{1F4C5} Select end date"}),jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:d("font-medium",u?"text-white":"text-gray-900"),children:ne.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>oe(new Date),className:d("p-1 rounded text-sm transition-colors",u?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>oe(new Date(ne.getFullYear(),ne.getMonth()-1)),className:d("p-1 rounded",u?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),jsx("button",{onClick:()=>oe(new Date(ne.getFullYear(),ne.getMonth()+1)),className:d("p-1 rounded",u?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(S=>jsx("div",{className:d("w-8 h-8 flex items-center justify-center text-xs",u?"text-[#6B7280]":"text-gray-400"),children:S},S))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:st().map((S,Ce)=>{let X=S.date.toDateString()===new Date().toDateString(),we=w.startDate?.toDateString()===S.date.toDateString(),ke=w.endDate?.toDateString()===S.date.toDateString(),He=we||ke,$e=w.startDate&&w.endDate&&S.date>=w.startDate&&S.date<=w.endDate;return jsx("button",{onClick:()=>{let tt=new Date(S.date);if(K==="start"){let _=w.endDate&&tt>w.endDate?tt:w.endDate;Be(tt,_),ae("end");}else {let _=w.startDate&&tt<w.startDate?tt:w.startDate;Be(_,tt),ae(null);}},className:d("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!S.isCurrentMonth&&(u?"text-[#4B5563]":"text-gray-300"),S.isCurrentMonth&&(u?"text-white":"text-gray-900"),X&&"ring-2 ring-[#3B82F6]",we&&"bg-[#3B82F6] text-white",ke&&!we&&"bg-[#7C3AED] text-white",$e&&!He&&(u?"bg-[#7C3AED]/20":"bg-purple-100"),!He&&(u?"hover:bg-white/10":"hover:bg-gray-100")),children:S.date.getDate()},Ce)})})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{Ye(),T(!F);},className:d("text-xs px-2 py-1 rounded font-medium transition-all hover:ring-2 hover:ring-white/20",w.priority==="high"||w.priority==="urgent"?"bg-red-500/20 text-red-400":w.priority==="medium"?"bg-yellow-500/20 text-yellow-400":w.priority==="low"?"bg-green-500/20 text-green-400":u?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:w.priority?w.priority==="high"||w.priority==="urgent"?n==="es"?"Alta":"High":w.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:F&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>T(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:n==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:n==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:n==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:n==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:n==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(S=>jsxs("button",{onClick:()=>{Je("priority",S.id),T(false);},className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",u?"hover:bg-white/5":"hover:bg-gray-50",w.priority===S.id&&(u?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",S.color)}),jsx("span",{className:u?"text-white":"text-gray-900",children:S.label})]},S.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:d("text-sm",u?"text-white":"text-gray-900"),children:w.startDate&&w.endDate?`${Math.ceil((w.endDate.getTime()-w.startDate.getTime())/(1e3*60*60*24))} ${n==="es"?"d\xEDas":"days"}`:n==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:d("w-4 h-4 rounded-full border-2",u?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[ye?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:w.progress||0,onChange:S=>{let Ce=parseInt(S.target.value),X=w.status;Ce===100?X="completed":Ce>0?X="in-progress":X="todo";let we={...w,progress:Ce,status:X};Se(we);},onBlur:()=>fe(false),className:d("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",u?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>fe(true),className:d("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",u?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:d("h-full rounded-full transition-all",w.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${w.progress||0}%`}})}),jsxs("span",{className:d("text-sm font-medium min-w-[40px]",u?"text-white":"text-gray-900"),children:[w.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx(hr,{selectedTags:w.tags||[],availableTags:g,onChange:S=>{Je("tags",S);},onCreateTag:i,theme:x})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:d("w-4 h-4 mt-1.5",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24 mt-1",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[w.dependencies&&w.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:w.dependencies.map(S=>{let Ce=y.find(X=>X.id===S);return jsxs("span",{className:d("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",u?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[Ce?.name||S.slice(0,8),jsx("button",{onClick:()=>{let X=(w.dependencies||[]).filter(we=>we!==S);Je("dependencies",X);},className:d("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},S)})}),jsxs("button",{onClick:()=>{Ye(),A(!Re);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{className:d("text-sm",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:Re&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{A(false),L("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:d("p-2 border-b",u?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:R,onChange:S=>L(S.target.value),placeholder:n==="es"?"Buscar tarea...":"Search task...",className:d("w-full px-3 py-2 rounded-md text-sm outline-none",u?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400"),autoFocus:true})}),jsx("div",{className:"max-h-[240px] overflow-y-auto",children:y.length>0?y.filter(S=>S.id!==w.id).filter(S=>R===""||S.name.toLowerCase().includes(R.toLowerCase())).map(S=>{let Ce=w.dependencies?.includes(S.id);return jsxs("button",{onClick:()=>{let X=w.dependencies||[],we;Ce?we=X.filter(ke=>ke!==S.id):we=[...X,S.id],Je("dependencies",we);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",u?"hover:bg-white/5":"hover:bg-gray-50",Ce&&(u?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:d("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",Ce?"bg-blue-500 border-blue-500":u?"border-white/30":"border-gray-300"),children:Ce&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:d("block truncate",u?"text-white":"text-gray-900"),children:S.name}),jsx("span",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:S.id.slice(0,8)})]})]},S.id)}):jsx("div",{className:d("px-3 py-4 text-sm text-center",u?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{Ye(),J(!j);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:w.color||"#6366F1"}}),jsx("span",{className:d("text-sm",u?"text-white":"text-gray-900"),children:yr.find(S=>S.value===w.color)?.name||(n==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:d("w-3 h-3",u?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:j&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>J(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",u?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:yr.map(S=>{let Ce=w.color===S.value;return jsx("button",{onClick:()=>{Je("color",S.value),J(false);},className:d("w-7 h-7 rounded-full flex items-center justify-center transition-all",Ce&&"ring-2 ring-offset-2",u?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:S.value,outlineColor:Ce?S.value:void 0},title:S.name,children:Ce&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},S.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:w.isMilestone||false,onChange:S=>Je("isMilestone",S.target.checked),className:d("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",w.isMilestone?"bg-purple-500 border-purple-500":u?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:d("text-sm",u?"text-white":"text-gray-900"),children:n==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:d("w-4 h-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:d("text-sm font-semibold",u?"text-white":"text-gray-900"),children:n==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:qe,onChange:S=>Pt(S.target.value),placeholder:n==="es"?"Agregar descripci\xF3n...":"Add description...",className:d("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",u?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400 focus:bg-gray-200")}),jsxs("button",{className:d("flex items-center gap-2 text-sm mt-2 transition-colors",u?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),n==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("text-sm font-semibold mb-3",u?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),n==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("text-sm font-semibold mb-3",u?"text-white":"text-gray-900"),children:n==="es"?"Subtareas":"Subtasks"}),w.subtasks&&w.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:w.subtasks.map(S=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:d("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",S.progress===100?"bg-green-500 border-green-500":u?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:S.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:d("text-sm",S.progress===100?"line-through text-[#6B7280]":u?"text-white":"text-gray-900"),children:S.name})]},S.id))}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),n==="es"?"Agregar subtarea":"Add subtask"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:d("text-sm font-semibold",u?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:d("p-1 rounded transition-colors",u?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",u?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(ListChecks,{className:"w-4 h-4"}),n==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",u?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:d("text-sm font-semibold mb-3",u?"text-white":"text-gray-900"),children:[n==="es"?"Adjuntos":"Attachments",p.length>0&&jsxs("span",{className:d("ml-2 text-xs font-normal",u?"text-[#6B7280]":"text-gray-400"),children:["(",p.length,")"]})]}),p.length>0&&jsx("div",{className:"space-y-2 mb-4",children:p.map(S=>{let Ce=te(S.type),X=S.type.startsWith("image/");return jsxs("div",{className:d("flex items-center gap-3 p-2 rounded-lg group transition-colors",u?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[X&&S.thumbnailUrl?jsx("img",{src:S.thumbnailUrl,alt:S.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:d("w-10 h-10 rounded flex items-center justify-center",u?"bg-white/10":"bg-gray-200"),children:jsx(Ce,{className:d("w-5 h-5",u?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",className:d("text-sm font-medium truncate block hover:underline",u?"text-white":"text-gray-900"),children:S.name}),jsx("p",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:Ze(S.size)})]}),f&&jsx("button",{onClick:()=>f(S.id),className:d("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",u?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:n==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},S.id)})}),jsxs("div",{onDragOver:Vt,onDragLeave:Bt,onDrop:nt,className:d("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",U?u?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":u?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",le&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:Ve,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!l||le}),le?jsxs(Fragment,{children:[jsx("div",{className:"w-6 h-6 mx-auto mb-2 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),jsx("p",{className:d("text-sm",u?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:d("w-6 h-6 mx-auto mb-2",U?"text-blue-500":u?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:d("text-sm",u?"text-[#9CA3AF]":"text-gray-500"),children:U?n==="es"?"Suelta los archivos aqu\xED":"Drop files here":n==="es"?jsxs(Fragment,{children:["Suelta tus archivos aqu\xED o ",jsx("span",{className:"underline",children:"haz clic para subir"})]}):jsxs(Fragment,{children:["Drop your files here or ",jsx("span",{className:"underline",children:"click to upload"})]})}),!l&&jsx("p",{className:d("text-xs mt-1",u?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:d("w-80 border-l flex flex-col",u?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:d("px-4 py-3 border-b",u?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:d("text-sm font-semibold",u?"text-white":"text-gray-900"),children:[n==="es"?"Actividad":"Activity",k.length>0&&jsxs("span",{className:d("ml-2 text-xs font-normal",u?"text-[#6B7280]":"text-gray-400"),children:["(",k.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:k.length>0?jsx("div",{className:"space-y-4",children:k.map(S=>jsxs("div",{className:"flex gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:S.user?.color||"#8B5CF6"},children:S.user?.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:d("text-sm font-medium",u?"text-white":"text-gray-900"),children:S.user?.name||(n==="es"?"Usuario":"User")}),jsx("span",{className:d("text-xs",u?"text-[#6B7280]":"text-gray-400"),children:xe(S.createdAt)})]}),jsx("div",{className:d("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:jsx(Vd,{content:S.content,theme:s})})]})]},S.id))}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:d("w-10 h-10 mb-3",u?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:d("text-sm",u?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:d("p-4 border-t",u?"border-white/10":"border-gray-200"),children:jsx(_d,{value:kt,onChange:$,onSubmit:Z,users:b,placeholder:n==="es"?"Escribe un comentario... (usa @ para mencionar)":"Write a comment... (use @ to mention)",disabled:!C,isSubmitting:me,theme:s,locale:n,currentUser:h})})]})]})]})})}function Js(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function zr({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:n,style:c,isLoading:g,error:i,children:p,availableTags:l=[],onCreateTag:f,attachmentsByCard:y,onUploadAttachments:k,onDeleteAttachment:C,comments:h,onAddComment:b,currentUser:u,mentionableUsers:x,onTaskOpen:m}){let[N,w]=Js(),[B,v]=useState(null),I=o?.theme||"dark",F=I==="dark"||I==="neutral",T=F?"dark":"",H=useCallback((j,J)=>{t.onCardUpdate?.(j,J);},[t]),O=useCallback((j,J)=>{t.onColumnUpdate?.(j,{title:J});},[t]),K=useCallback(j=>{t.onColumnDelete?.(j);},[t]),ae=["todo","in-progress","completed"],ne=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),oe=useMemo(()=>{let j=new Map;return e.columns.forEach(J=>{let U=J.cardIds.map(ge=>e.cards.find(le=>le.id===ge)).filter(ge=>ge!==void 0).sort((ge,le)=>ge.position-le.position);j.set(J.id,U);}),j},[e.cards,e.columns]),ye=useMemo(()=>e.cards.map(j=>({id:j.id,name:j.title,startDate:j.startDate?new Date(j.startDate):void 0,endDate:j.endDate?new Date(j.endDate):void 0,progress:j.progress||0,status:j.columnId,priority:j.priority?.toLowerCase(),dependencies:Array.isArray(j.dependencies)?j.dependencies.map(J=>typeof J=="string"?J:J.taskId):[]})),[e.cards]),fe=useCallback(j=>{let{active:J}=j,U=e.cards.find(ge=>ge.id===J.id);U&&w({isDragging:true,draggedCardId:U.id,sourceColumnId:U.columnId,targetColumnId:U.columnId});},[e.cards,w]),Re=useCallback(j=>{let{active:J,over:U}=j;if(!U||!e.cards.find(Fe=>Fe.id===J.id))return;let le=null;U.data.current?.type==="column"?le=U.id:U.data.current?.type==="card"&&(le=e.cards.find(qe=>qe.id===U.id)?.columnId||null),le&&le!==N.targetColumnId&&w({...N,targetColumnId:le});},[e.cards,N,w]),A=useCallback(async j=>{let{active:J,over:U}=j;if(w({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!U)return;let ge=e.cards.find(et=>et.id===J.id);if(!ge)return;let le,Fe;if(U.data.current?.type==="column"){le=U.id;let et=oe.get(le)||[];Fe=Bs(et,0);}else {let et=e.cards.find(dt=>dt.id===U.id);if(!et)return;le=et.columnId;let de=oe.get(le)||[],Ke=de.findIndex(dt=>dt.id===U.id);Fe=Bs(de,Ke);}let qe=e.columns.find(et=>et.id===le);if(qe&&qe.wipLimit&&qe.wipLimitType==="hard"){let et=oe.get(le)||[];if(ge.columnId!==le&&et.length>=qe.wipLimit){t.onWipLimitExceeded?.(qe,ge);return}}(ge.columnId!==le||ge.position!==Fe)&&await t.onCardMove?.(ge.id,le,Fe);},[e.cards,e.columns,oe,t,w]),R=useCallback(j=>{v(j),a?.(j),m?.(j.id);},[a,m]),L=useCallback(j=>{t.onCardUpdate?.(j.id,j),v(j);},[t]);return g?jsx("div",{className:d("asakaa-board",T,n),style:c,children:jsx(af,{columnCount:3})}):i?jsx("div",{className:d("asakaa-board",T,n),style:c,children:jsx("div",{className:"flex items-center justify-center w-full h-64",children:jsxs("div",{className:"text-center",children:[jsx("p",{className:"text-asakaa-accent-red text-lg font-semibold mb-2",children:"Error loading board"}),jsx("p",{className:"text-asakaa-text-secondary text-sm",children:typeof i=="string"?i:i.message})]})})}):jsxs(xd,{themeName:I,children:[jsxs(DndContext,{sensors:ne,collisionDetection:closestCorners,onDragStart:fe,onDragOver:Re,onDragEnd:A,children:[jsxs("div",{className:d("asakaa-board",T,n),style:c,"data-theme":I,children:[e.columns.sort((j,J)=>j.position-J.position).map(j=>{let J=oe.get(j.id)||[],U=!ae.includes(j.id);return jsx(No,{column:j,cards:J,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:R,onCardUpdate:H,onColumnRename:O,onColumnDelete:K,isDeletable:U,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},j.id)}),p]}),jsx(DragOverlay,{children:N.draggedCardId?jsx(Sr,{card:e.cards.find(j=>j.id===N.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]}),jsx(io,{task:B,isOpen:!!B,onClose:()=>v(null),onCardUpdate:L,theme:F?"dark":"light",locale:o?.locale==="es"?"es":"en",availableUsers:s,availableTags:l,onCreateTag:f,attachments:B?y?.get(B.id)||[]:[],onUploadAttachments:k,onDeleteAttachment:C,availableTasks:ye,comments:h,onAddComment:b,currentUser:u,mentionableUsers:x})]})}function af({columnCount:e}){return jsx(Fragment,{children:Array.from({length:e}).map((t,a)=>jsxs("div",{className:"asakaa-column",children:[jsx("div",{className:"asakaa-skeleton h-8 mb-3"}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx("div",{className:"asakaa-skeleton h-24"}),jsx("div",{className:"asakaa-skeleton h-32"}),jsx("div",{className:"asakaa-skeleton h-28"})]})]},a))})}var lf={bgGrid:"#0F1117",bgSecondary:"#1A1D25",border:"rgba(255, 255, 255, 0.1)",borderLight:"rgba(255, 255, 255, 0.05)",textPrimary:"#E5E7EB",textSecondary:"#9CA3AF",textTertiary:"#6B7280",accent:"#3B82F6",accentLight:"rgba(59, 130, 246, 0.15)",hoverBg:"rgba(255, 255, 255, 0.05)"},df={bgGrid:"#FFFFFF",bgSecondary:"#F9FAFB",border:"rgba(0, 0, 0, 0.1)",borderLight:"rgba(0, 0, 0, 0.05)",textPrimary:"#111827",textSecondary:"#6B7280",textTertiary:"#9CA3AF",accent:"#3B82F6",accentLight:"rgba(59, 130, 246, 0.1)",hoverBg:"rgba(0, 0, 0, 0.05)"},cf={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},mf={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function pf({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let i=p=>{c.current&&!c.current.contains(p.target)&&n(false);};return s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[s]);let g=i=>{t(i),n(false);};return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:()=>n(!s),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:o||r.newTask}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:s?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:s&&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:a.bgSecondary,border:`1px solid ${a.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wider",style:{color:a.textTertiary},children:r.selectColumn}),e.sort((i,p)=>i.position-p.position).map((i,p)=>jsxs(motion.button,{onClick:()=>g(i.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:p<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:p*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:i.color||a.accent}}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:a.textPrimary},children:i.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[i.cardIds.length," ",i.cardIds.length===1?"tarea":"tareas"]})]})]},i.id))]})})})]})}function uf({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,n]=useState(false),[c,g]=useState(null),i=useRef(null);if(useEffect(()=>{let y=k=>{i.current&&!i.current.contains(k.target)&&n(false);};return s&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[s]),!(a||r||o))return null;let l=[{id:"csv",label:t.exportCSV,description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"json",label:t.exportJSON,description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:r},{id:"excel",label:t.exportExcel,description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:o}].filter(y=>y.handler),f=async(y,k)=>{if(k){g(y);try{await k();}catch(C){console.error(`Export ${y} failed:`,C);}finally{g(null),n(false);}}};return jsxs("div",{ref:i,className:"relative",children:[jsxs(motion.button,{onClick:()=>n(!s),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:s?e.accent:e.bgSecondary,border:`1px solid ${s?e.accent:e.borderLight}`,color:s?"#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:t.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:s?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:s&&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-44 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:l.map((y,k)=>jsxs(motion.button,{onClick:()=>f(y.id,y.handler),disabled:c!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:k<l.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:c===y.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):y.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:y.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:y.description})]})]},y.id))})})})]})}function gf({onClick:e,label:t}){return jsxs(motion.button,{onClick:e,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:t})]})}function Qs({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:n,onExportJSON:c,onExportExcel:g,translations:i}){let p=r==="dark"?lf:df,l={...o==="es"?cf:mf,...i},f=n||c||g;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:p.bgGrid,borderColor:p.border},children:jsxs("div",{className:"flex items-center gap-3",children:[f&&jsxs(Fragment,{children:[jsx(uf,{theme:p,t:l,onExportCSV:n,onExportJSON:c,onExportExcel:g}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:p.borderLight}})]}),t&&(s?jsx(pf,{columns:e,onSelect:t,theme:p,t:l,createTaskLabel:a}):jsx(gf,{onClick:()=>t(),label:a||l.newTask}))]})})}function ti({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,n]=useState(false),[c,g]=useState(""),i=useCallback(()=>{let f=c.trim();f&&(e(f),g(""),n(false));},[c,e]),p=useCallback(f=>{f.key==="Enter"?(f.preventDefault(),i()):f.key==="Escape"&&(g(""),n(false));},[i]),l=useCallback(()=>{setTimeout(()=>{c.trim()||n(false);},150);},[c]);return s?jsx("div",{className:d("asakaa-add-column asakaa-add-column--editing",t),children:jsxs("div",{className:"asakaa-add-column__input-wrapper",children:[jsx("input",{type:"text",value:c,onChange:f=>g(f.target.value),onKeyDown:p,onBlur:l,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:i,disabled:!c.trim(),className:"asakaa-add-column__submit",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}),jsx("button",{onClick:()=>{g(""),n(false);},className:"asakaa-add-column__cancel",type:"button",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})}):jsx("div",{className:d("asakaa-add-column",t),children:jsxs("button",{onClick:()=>n(true),disabled:o,className:"asakaa-add-column__button",type:"button",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r]})})}function ai({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:n=false,theme:c="dark",locale:g="es"}){let[i,p]=useState(false),[l,f]=useState(false),[y,k]=useState(""),[C,h]=useState([]),[b,u]=useState(""),[x,m]=useState(""),[N,w]=useState(""),[B,v]=useState(false),[I,F]=useState(false),[T,H]=useState(false),O=useRef(null),K=useRef(null),ae={placeholder:o||(g==="es"?"Nombre de la tarea...":"Task Name..."),buttonLabel:s||(g==="es"?"Agregar Tarea":"Add Task"),save:g==="es"?"Guardar":"Save",addAssignee:g==="es"?"Agregar asignado":"Add assignee",addDates:g==="es"?"Agregar fechas":"Add dates",addPriority:g==="es"?"Agregar prioridad":"Add priority",startDate:g==="es"?"Inicio":"Start",endDate:g==="es"?"Fin":"End",low:g==="es"?"Baja":"Low",medium:g==="es"?"Media":"Medium",high:g==="es"?"Alta":"High",urgent:g==="es"?"Urgente":"Urgent"},ne=useCallback(()=>{k(""),h([]),u(""),m(""),w(""),v(false),F(false),H(false),p(false);},[]);useEffect(()=>{i&&O.current&&O.current.focus();},[i]),useEffect(()=>{if(!i)return;let A=R=>{K.current&&!K.current.contains(R.target)&&(y.trim()||ne());};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[i,y,ne]);let oe=useCallback(async()=>{let A=y.trim();if(!(!A||l)){f(true);try{await t({name:A,columnId:e,assigneeIds:C.length>0?C:void 0,startDate:b?new Date(b):void 0,endDate:x?new Date(x):void 0,priority:N||void 0}),k(""),h([]),u(""),m(""),w(""),v(!1),F(!1),H(!1),O.current?.focus();}catch(R){console.error("Error creating card:",R);}finally{f(false);}}},[y,e,C,b,x,N,t,l]),ye=useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),oe()):A.key==="Escape"&&ne();},[oe,ne]),fe=useCallback(A=>{h(R=>R.includes(A)?R.filter(L=>L!==A):[...R,A]);},[]),Re=c==="dark";return i?jsxs("div",{ref:K,className:d("rounded-lg overflow-hidden shadow-lg",Re?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:O,type:"text",value:y,onChange:A=>k(A.target.value),onKeyDown:ye,placeholder:ae.placeholder,disabled:l,className:d("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",Re?"text-gray-100 placeholder-gray-500":"text-gray-800 placeholder-gray-400")}),jsxs("div",{className:"flex items-center gap-1 mt-3",children:[a.length>0&&jsxs("button",{onClick:()=>v(!B),className:d("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",B||C.length>0?"bg-emerald-500/20 text-emerald-400":Re?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addAssignee,children:[jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),C.length>0&&jsx("span",{className:"ml-0.5",children:C.length})]}),jsx("button",{onClick:()=>F(!I),className:d("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",I||b||x?"bg-blue-500/20 text-blue-400":Re?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addDates,children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),jsx("button",{onClick:()=>H(!T),className:d("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",T||N?N==="urgent"?"bg-red-500/20 text-red-400":N==="high"?"bg-orange-500/20 text-orange-400":N==="medium"?"bg-yellow-500/20 text-yellow-400":N==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":Re?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:ae.addPriority,children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"}),jsx("line",{x1:"4",y1:"22",x2:"4",y2:"15"})]})}),jsx("div",{className:"flex-1"}),jsx("button",{onClick:oe,disabled:!y.trim()||l,className:d("px-3 py-1.5 rounded-md text-xs font-medium text-white transition-all","bg-emerald-500 hover:bg-emerald-600","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-emerald-500"),type:"button",children:l?jsx("div",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"}):ae.save})]})]}),B&&a.length>0&&jsx("div",{className:d("px-3 pb-3 pt-0","border-t",Re?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(A=>jsxs("button",{onClick:()=>fe(A.id),className:d("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",C.includes(A.id)?"bg-emerald-500 text-white":Re?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[A.avatar?jsx("img",{src:A.avatar,alt:A.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:d("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",C.includes(A.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:A.name.charAt(0).toUpperCase()}),jsx("span",{children:A.name.split(" ")[0]})]},A.id))})}),I&&jsx("div",{className:d("px-3 pb-3 pt-0","border-t",Re?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:d("block text-[10px] uppercase tracking-wide mb-1",Re?"text-gray-500":"text-gray-400"),children:ae.startDate}),jsx("input",{type:"date",value:b,onChange:A=>u(A.target.value),className:d("w-full px-2 py-1.5 rounded text-xs border",Re?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:d("block text-[10px] uppercase tracking-wide mb-1",Re?"text-gray-500":"text-gray-400"),children:ae.endDate}),jsx("input",{type:"date",value:x,onChange:A=>m(A.target.value),className:d("w-full px-2 py-1.5 rounded text-xs border",Re?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),T&&jsx("div",{className:d("px-3 pb-3 pt-0","border-t",Re?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(A=>jsx("button",{onClick:()=>w(N===A?"":A),className:d("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",N===A?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[A]} text-white`:Re?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:ae[A]},A))})})]}):jsxs("button",{onClick:()=>p(true),disabled:n,className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",Re?"hover:bg-[#2a2a3e]":"hover:bg-gray-100",n&&"opacity-50 cursor-not-allowed",r),type:"button",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),jsx("span",{className:"text-sm font-medium",children:ae.buttonLabel})]})}var qo=class extends BaseViewAdapter{constructor(a={}){super();this.id="kanban";this.name="Kanban Board";this.version="1.0.0";this.description="";this.icon="";this.supportedExports=["json","csv","pdf","png"];this.root=null;this.description="Interactive Kanban board with drag & drop, filters, and real-time updates",this.icon="\u{1F4CB}",this.kanbanConfig=a,this.options={animations:a.viewOptions?.animations??true,virtualScrolling:a.viewOptions?.virtualScrolling??false,theme:a.viewOptions?.theme??"dark",readonly:a.viewOptions?.readonly??false};}mount(a,r){this.isMounted()&&(console.warn("[KanbanViewAdapter] Already mounted, unmounting first"),this.unmount()),this.container=a,this.data=r,this.root=createRoot(a),this.render(),this.emit("view:mounted",{viewId:this.id,timestamp:Date.now()});}unmount(){this.isMounted()&&(this.emit("view:unmounted",{viewId:this.id,timestamp:Date.now()}),this.root&&(this.root.unmount(),this.root=null),this.container&&(this.container.innerHTML="",this.container=null),this.data=null);}update(a){if(!this.isMounted()){console.warn("[KanbanViewAdapter] Not mounted, cannot update");return}this.data=a,this.render(),this.emit("view:updated",{viewId:this.id,data:a});}configure(a){this.options={...this.options,...a},this.isMounted()&&this.render();}async export(a){if(!this.data)throw new Error("No data to export");switch(a){case "json":return JSON.stringify(this.data,null,2);case "csv":return this.exportToCSV();case "pdf":return this.exportToPDF();case "png":return this.exportToPNG();default:throw new Error(`Unsupported export format: ${a}`)}}render(){if(!this.root||!this.data)return;let a={id:this.data.board?.id||"board-1",title:this.data.board?.title||"Untitled Board",columns:this.data.columns,cards:this.data.cards};this.root.render(jsx(zr,{board:a,callbacks:this.kanbanConfig.callbacks||{},onCardClick:this.kanbanConfig.onCardClick,renderProps:this.kanbanConfig.renderProps,config:this.kanbanConfig.config,availableUsers:this.kanbanConfig.availableUsers,className:this.kanbanConfig.className,style:this.kanbanConfig.style}));}exportToCSV(){if(!this.data)return "";let a=[["Card ID","Title","Column","Description","Labels","Assignees","Due Date","Position"]];return this.data.cards.forEach(r=>{let o=this.data.columns.find(s=>s.id===r.columnId);a.push([r.id,r.title,o?.title||"",r.description||"",r.labels?.join(", ")||"",r.assignedUserIds?.join(", ")||r.assigneeId||"",r.dueDate?.toString()||"",r.position.toString()]);}),a.map(r=>r.map(o=>`"${o}"`).join(",")).join(`
|
|
5
|
+
`)}async exportToPDF(){throw new Error("PDF export not yet implemented in ViewAdapter")}async exportToPNG(){if(!this.container)throw new Error("View not mounted");let r=await(await import('html2canvas')).default(this.container,{backgroundColor:this.options.theme==="dark"?"#1a1a1a":"#ffffff",scale:2});return new Promise((o,s)=>{r.toBlob(n=>{n?o(n):s(new Error("Failed to create PNG blob"));},"image/png");})}};function cc(e={}){return new qo(e)}var So=class extends Component{constructor(a){super(a);this.resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(a){return {hasError:true,error:a}}componentDidCatch(a,r){let{onError:o,componentName:s}=this.props;if(process.env.NODE_ENV==="development"&&(console.error(`Error in ${s||"Component"}:`,a),console.error("Error Info:",r)),this.setState({errorInfo:r}),o)try{o(a,r);}catch(n){console.error("Error in error handler:",n);}}render(){let{hasError:a,error:r}=this.state,{children:o,fallback:s,componentName:n}=this.props;return a&&r?s?s(r,this.resetError):jsx("div",{className:"p-6 rounded-lg border",style:{background:"linear-gradient(135deg, #2d1b1b 0%, #1a1a1a 100%)",borderColor:"rgba(239, 68, 68, 0.3)"},children:jsxs("div",{className:"flex items-start gap-3",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"#EF4444",strokeWidth:"2"}),jsx("path",{d:"M12 8V12",stroke:"#EF4444",strokeWidth:"2",strokeLinecap:"round"}),jsx("circle",{cx:"12",cy:"16",r:"1",fill:"#EF4444"})]}),jsxs("div",{className:"flex-1",children:[jsx("h3",{className:"text-lg font-semibold text-red-400 mb-1",children:n?`Error in ${n}`:"Something went wrong"}),jsx("p",{className:"text-sm text-white/70 mb-3",children:r.message||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&jsxs("details",{className:"mb-3",children:[jsx("summary",{className:"text-xs text-white/50 cursor-pointer hover:text-white/70 mb-2",children:"Error Details (Development Only)"}),jsx("pre",{className:"text-xs text-white/60 bg-black/30 p-3 rounded overflow-auto max-h-48",children:r.stack})]}),jsx("button",{onClick:this.resetError,className:"px-4 py-2 rounded-lg text-sm font-medium transition-all hover:bg-red-600/20 border border-red-500/30",style:{color:"#EF4444"},children:"Try Again"})]})]})}):o}};function ri(e,t){let a=r=>jsx(So,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function ni({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:n,onPredictRisks:c,onOpenAIUsage:g,shortcut:i="k",className:p=""}){let[l,f]=useState(false),[y,k]=useState(""),[C,h]=useState("home"),[b,u]=useState(""),[x,m]=useState("");useEffect(()=>{let v=I=>{(I.metaKey||I.ctrlKey)&&I.key===i&&(I.preventDefault(),f(F=>!F)),I.key==="Escape"&&(f(false),h("home"),k(""));};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[i]),useEffect(()=>{l||(h("home"),k(""),u(""),m(""));},[l]);let N=useCallback(()=>{f(false);},[]),w=useCallback(v=>{let[I,F]=v.split(":");switch(I){case "create-card":h("create-card");break;case "create-card-in":u(F||"");break;case "navigate":F?(a?.(F),N()):h("navigate");break;case "search":r?.(y),N();break;case "priority":h("priority");break;case "set-priority":x&&F&&(o?.(x,F),N());break;case "assign":h("assign");break;case "assign-user":x&&F&&(s?.(x,F),N());break;case "ai":h("ai");break;case "ai-generate-plan":n?.(),N();break;case "ai-predict-risks":c?.(),N();break;case "ai-usage":g?.(),N();break;case "back":h("home");break;}},[y,x,t,a,r,o,s,n,c,g,N]),B=useCallback(()=>{b&&y.trim()&&(t?.(b,y.trim()),N());},[b,y,t,N]);return l?jsx(ft,{children:jsx("div",{className:"command-palette-overlay",onClick:N,children:jsx("div",{className:`command-palette ${p}`,onClick:v=>v.stopPropagation(),children:jsxs(Command,{value:y,onValueChange:k,label:"Command Menu",children:[jsxs("div",{className:"command-palette-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"11",cy:"11",r:"8"}),jsx("path",{d:"m21 21-4.35-4.35"})]}),jsx(Command.Input,{placeholder:C==="create-card"&&b?"Type card title and press Enter...":C==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:v=>{v.key==="Enter"&&C==="create-card"&&b&&B();}}),jsxs("div",{className:"command-palette-shortcut",children:[jsx("kbd",{children:navigator.platform.includes("Mac")?"\u2318":"Ctrl"}),jsx("kbd",{children:"K"})]})]}),jsxs(Command.List,{className:"command-palette-list",children:[jsx(Command.Empty,{className:"command-palette-empty",children:"No results found."}),C==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:w,className:"command-palette-item",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"}),jsx("path",{d:"M12 8v8m-4-4h8"})]}),jsx("span",{children:"Create Card"}),jsx("div",{className:"command-palette-item-shortcut",children:"C"})]}),jsxs(Command.Item,{value:"navigate",onSelect:w,className:"command-palette-item",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:"10"}),jsx("polyline",{points:"12 16 16 12 12 8"}),jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),jsx("span",{children:"Navigate to Card"}),jsx("div",{className:"command-palette-item-shortcut",children:"G"})]}),jsxs(Command.Item,{value:"search",onSelect:w,className:"command-palette-item",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"11",cy:"11",r:"8"}),jsx("path",{d:"m21 21-4.35-4.35"})]}),jsx("span",{children:"Search Cards"}),jsx("div",{className:"command-palette-item-shortcut",children:"/"})]})]}),jsx(Command.Group,{heading:"AI Features",className:"command-palette-group",children:jsxs(Command.Item,{value:"ai",onSelect:w,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"AI Commands"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})}),jsx(Command.Group,{heading:"Cards",className:"command-palette-group",children:e.cards.slice(0,5).map(v=>jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:w,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:v.title}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(I=>jsx("span",{className:"command-palette-item-label",children:I},I))})]},v.id))})]}),C==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:w,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"Select Column",className:"command-palette-group",children:e.columns.map(v=>jsxs(Command.Item,{value:`create-card-in:${v.id}`,onSelect:w,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("rect",{x:"3",y:"3",width:"7",height:"18",rx:"1"})}),jsx("span",{children:v.title}),jsxs("div",{className:"command-palette-item-count",children:[v.cardIds.length," cards"]})]},v.id))})]}),C==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:w,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"All Cards",className:"command-palette-group",children:e.cards.map(v=>{let I=e.columns.find(F=>F.id===v.columnId);return jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:w,className:"command-palette-item",keywords:[v.title,v.description||"",...v.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:v.title}),jsx("div",{className:"command-palette-item-meta",children:I?.title})]}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(F=>jsx("span",{className:"command-palette-item-label",children:F},F))})]},v.id)})})]}),C==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:w,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsxs(Command.Group,{heading:"AI Features",className:"command-palette-group",children:[jsxs(Command.Item,{value:"ai-generate-plan",onSelect:w,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"Generate Project Plan"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]}),jsxs(Command.Item,{value:"ai-predict-risks",onSelect:w,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Predict Risks"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]}),jsxs(Command.Item,{value:"ai-usage",onSelect:w,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"1",x2:"12",y2:"23"}),jsx("path",{d:"M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6"})]}),jsx("span",{children:"AI Usage & Costs"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})]})]})]}),jsxs("div",{className:"command-palette-footer",children:[jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"\u2191"}),jsx("kbd",{children:"\u2193"}),jsx("span",{children:"Navigate"})]}),jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"Enter"}),jsx("span",{children:"Select"})]}),jsxs("div",{className:"command-palette-footer-hint",children:[jsx("kbd",{children:"Esc"}),jsx("span",{children:"Close"})]})]})]})})})}):null}function uc(e,t,a,r,o){let s=document.getElementById("attachment-lightbox-native");s&&s.remove();let n=document.createElement("div");n.id="attachment-lightbox-native",n.className="attachment-lightbox",n.style.cssText=`
|
|
6
6
|
position: fixed !important;
|
|
7
7
|
inset: 0 !important;
|
|
8
8
|
z-index: 2147483647 !important;
|
|
@@ -68,7 +68,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
|
|
|
68
68
|
border: none !important;
|
|
69
69
|
cursor: pointer !important;
|
|
70
70
|
opacity: 0.5 !important;
|
|
71
|
-
`,y.onmouseenter=()=>{y.style.opacity="1";},y.onmouseleave=()=>{y.style.opacity="0.5";},y.onclick=k=>{k.stopPropagation();let C=r<a.length-1?r+1:0;i(),o(C);},n.appendChild(l),n.appendChild(f),n.appendChild(y);}n.appendChild(c),n.appendChild(g),document.body.appendChild(n),setTimeout(()=>{g.style.transition="opacity 0.5s ease",g.style.opacity="0";},2e3);}function yf(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+a[r]}function vf(e){return e.startsWith("image/")?"\u{1F5BC}\uFE0F":e.startsWith("video/")?"\u{1F3A5}":e.startsWith("audio/")?"\u{1F3B5}":e.includes("pdf")?"\u{1F4C4}":e.includes("word")||e.includes("document")?"\u{1F4DD}":e.includes("sheet")||e.includes("excel")?"\u{1F4CA}":e.includes("presentation")||e.includes("powerpoint")?"\u{1F4FD}\uFE0F":e.includes("zip")||e.includes("rar")||e.includes("compressed")?"\u{1F5DC}\uFE0F":e.includes("text")?"\u{1F4C3}":"\u{1F4CE}"}function si(e){return e.startsWith("image/")}function kr({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[n,c]=useState(false),[g,i]=useState(false),[p,l]=useState(null),f=useRef(null),y=useRef(e);y.current=e;let k=useCallback((v,I)=>{I.preventDefault(),I.stopPropagation();let A=y.current.filter($=>si($.type)),T=A.findIndex($=>$.id===v.id),W=$=>{let j=y.current.filter(oe=>si(oe.type)),te=j[$];te&&pc(te.url,te.name,j,$,W);};pc(v.url,v.name,A,T,W);},[]),C=useCallback(v=>{let I=[],A=[];return e.length+v.length>s?(A.push(`Maximum ${s} files allowed`),{valid:I,errors:A}):(v.forEach(T=>{if(T.size/1048576>r){A.push(`${T.name} is too large (max ${r}MB)`);return}if(o&&!o.some($=>T.type.match($))){A.push(`${T.name} has invalid file type`);return}I.push(T);}),{valid:I,errors:A})},[e.length,s,r,o]),h=useCallback(async v=>{let{valid:I,errors:A}=C(v);if(A.length>0){l(A.join(", ")),setTimeout(()=>l(null),5e3);return}if(I.length!==0){i(true),l(null);try{await t?.(I);}catch(T){l(T instanceof Error?T.message:"Upload failed"),setTimeout(()=>l(null),5e3);}finally{i(false);}}},[C,t]),b=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(true);},[]),u=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);},[]),x=useCallback(v=>{v.preventDefault(),v.stopPropagation();},[]),m=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);let I=Array.from(v.dataTransfer.files);h(I);},[h]),N=useCallback(v=>{let I=v.target.files?Array.from(v.target.files):[];h(I),f.current&&(f.current.value="");},[h]),w=useCallback(()=>{f.current?.click();},[]),B=useCallback(v=>{confirm("Are you sure you want to delete this attachment?")&&a?.(v);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${n?"dragging":""} ${g?"uploading":""}`,onDragEnter:b,onDragLeave:u,onDragOver:x,onDrop:m,onClick:w,children:[jsx("input",{ref:f,type:"file",multiple:true,onChange:N,style:{display:"none"},accept:o?.join(",")}),jsx("div",{className:"attachment-dropzone-content",children:g?jsxs(Fragment,{children:[jsx("div",{className:"attachment-spinner"}),jsx("p",{className:"attachment-dropzone-text",children:"Uploading..."})]}):jsxs(Fragment,{children:[jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"attachment-dropzone-icon",children:[jsx("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M17 8L12 3L7 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M12 3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),jsx("p",{className:"attachment-dropzone-text",children:n?"Drop files here":"Drag & drop files here"}),jsx("p",{className:"attachment-dropzone-subtext",children:"or click to browse"}),jsxs("p",{className:"attachment-dropzone-info",children:["Max ",r,"MB \u2022 ",e.length,"/",s," files"]})]})})]}),p&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:p})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(v=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:si(v.type)&&v.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:I=>k(v,I),title:"Click to view full size",children:[jsx("img",{src:v.thumbnailUrl||v.url,alt:v.name,className:"attachment-thumbnail"}),jsx("div",{className:"attachment-thumbnail-overlay",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M9 21H3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M21 3L14 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M3 21L10 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}):jsx("div",{className:"attachment-icon",children:vf(v.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:v.name,children:v.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:yf(v.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(v.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>B(v.id),className:"attachment-delete",title:"Delete attachment",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},v.id))})]})}function ii({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],aiInsights:g=[],attachments:i=[],onAddComment:p,onDeleteComment:l,onUploadAttachments:f,onDeleteAttachment:y,onSuggestAssignee:k,onGenerateSubtasks:C,onEstimateEffort:h,currentUserId:b="user-1"}){let[u,x]=useState("details"),[m,N]=useState(false),[w,B]=useState({}),[v,I]=useState(""),[A,T]=useState(false),[W,$]=useState({});if(!t||!e)return null;let j=useCallback(()=>{N(false),B({}),x("details"),I(""),$({}),a();},[a]),te=useCallback(()=>{r&&Object.keys(w).length>0&&(r(e.id,w),B({}),N(false));},[e.id,w,r]),oe=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),j());},[e.id,o,j]),re=useCallback(()=>{p&&v.trim()&&(p(e.id,v.trim()),I(""));},[e.id,v,p]),ge=useCallback(async()=>{if(k){T(true);try{let L=await k(e);$(V=>({...V,assignees:L}));}catch(L){console.error("Failed to suggest assignee:",L);}finally{T(false);}}},[e,k]),fe=useCallback(async()=>{if(C){T(true);try{let L=await C(e);$(V=>({...V,subtasks:L}));}catch(L){console.error("Failed to generate subtasks:",L);}finally{T(false);}}},[e,C]),Ie=useCallback(async()=>{if(h){T(true);try{let L=await h(e);$(V=>({...V,effort:L}));}catch(L){console.error("Failed to estimate effort:",L);}finally{T(false);}}},[e,h]),M={...e,...w},R=s.filter(L=>M.assignedUserIds?.includes(L.id));return jsx(bt,{children:jsx("div",{className:"card-detail-overlay",onClick:j,children:jsxs("div",{className:"card-detail-modal",onClick:L=>L.stopPropagation(),children:[jsxs("div",{className:"card-detail-header",children:[jsxs("div",{className:"card-detail-header-left",children:[jsx("div",{className:"card-detail-priority-dot",style:{background:M.priority==="URGENT"?"#EF4444":M.priority==="HIGH"?"#F59E0B":M.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),m?jsx("input",{type:"text",value:w.title??M.title,onChange:L=>B({...w,title:L.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:M.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[m?jsxs(Fragment,{children:[jsx("button",{onClick:te,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{N(false),B({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>N(true),className:"card-detail-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Edit"]}),jsxs("button",{onClick:oe,className:"card-detail-btn card-detail-btn-danger",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]}),"Delete"]}),jsx("button",{onClick:j,className:"card-detail-btn-close",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),jsxs("div",{className:"card-detail-tabs",children:[jsxs("button",{onClick:()=>x("details"),className:`card-detail-tab ${u==="details"?"active":""}`,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 00-2 2v16a2 2 0 002 2h12a2 2 0 002-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"})]}),"Details"]}),jsxs("button",{onClick:()=>x("comments"),className:`card-detail-tab ${u==="comments"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),"Comments",n.length>0&&jsx("span",{className:"card-detail-tab-badge",children:n.length})]}),jsxs("button",{onClick:()=>x("activity"),className:`card-detail-tab ${u==="activity"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),"Activity",c.length>0&&jsx("span",{className:"card-detail-tab-badge",children:c.length})]}),jsxs("button",{onClick:()=>x("attachments"),className:`card-detail-tab ${u==="attachments"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),"Attachments",i.length>0&&jsx("span",{className:"card-detail-tab-badge",children:i.length})]}),jsxs("button",{onClick:()=>x("ai"),className:`card-detail-tab ${u==="ai"?"active":""}`,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),"AI Insights",jsx("span",{className:"card-detail-tab-badge card-detail-tab-badge-ai",children:"AI"})]})]}),jsxs("div",{className:"card-detail-content",children:[u==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),m?jsx("textarea",{value:w.description??M.description??"",onChange:L=>B({...w,description:L.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:M.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),m?jsx("select",{multiple:true,value:w.assignedUserIds??M.assignedUserIds??[],onChange:L=>{let V=Array.from(L.target.selectedOptions,q=>q.value);B({...w,assignedUserIds:V});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(L=>jsx("option",{value:L.id,children:L.name},L.id))}):jsx("div",{className:"card-detail-users",children:R.length>0?R.map(L=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:L.color},children:L.initials}),jsx("span",{children:L.name})]},L.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),m?jsxs("select",{value:w.priority??M.priority??"",onChange:L=>B({...w,priority:L.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},children:[jsx("option",{value:"",children:"None"}),jsx("option",{value:"LOW",children:"LOW"}),jsx("option",{value:"MEDIUM",children:"MEDIUM"}),jsx("option",{value:"HIGH",children:"HIGH"}),jsx("option",{value:"URGENT",children:"URGENT"})]}):jsxs("div",{className:"card-detail-priority",children:[jsx("div",{className:"card-detail-priority-dot",style:{background:M.priority==="URGENT"?"#EF4444":M.priority==="HIGH"?"#F59E0B":M.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:M.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:M.labels&&M.labels.length>0?M.labels.map(L=>jsx("span",{className:"card-detail-label-tag",children:L},L)):jsx("span",{className:"card-detail-empty",children:"No labels"})})]}),jsxs("div",{className:"card-detail-section-row",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Start Date"}),m?jsx("input",{type:"date",value:w.startDate?new Date(w.startDate).toISOString().split("T")[0]:M.startDate?new Date(M.startDate).toISOString().split("T")[0]:"",onChange:L=>B({...w,startDate:L.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:M.startDate?new Date(M.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),m?jsx("input",{type:"date",value:w.endDate?new Date(w.endDate).toISOString().split("T")[0]:M.endDate?new Date(M.endDate).toISOString().split("T")[0]:"",onChange:L=>B({...w,endDate:L.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:M.endDate?new Date(M.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),m?jsx("input",{type:"number",min:"0",step:"0.5",value:w.estimatedTime??M.estimatedTime??"",onChange:L=>B({...w,estimatedTime:L.target.value?parseFloat(L.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:M.estimatedTime||"Not estimated"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Dependencies"}),jsx("div",{className:"card-detail-dependencies",children:M.dependencies&&M.dependencies.length>0?M.dependencies.map(L=>{let V=typeof L=="string"?L:L.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",V.slice(-4)]},V)}):jsx("span",{className:"card-detail-empty",children:"No dependencies"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Created"}),jsx("span",{className:"card-detail-text",children:M.createdAt?new Date(M.createdAt).toLocaleString():"Unknown"})]})]}),u==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:v,onChange:L=>I(L.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:re,disabled:!v.trim(),className:"card-detail-btn card-detail-btn-primary",children:"Add Comment"})]}),jsx("div",{className:"card-detail-comments-list",children:n.length>0?n.map(L=>{let V=s.find(q=>q.id===L.authorId);return jsxs("div",{className:"card-detail-comment",children:[jsxs("div",{className:"card-detail-comment-header",children:[jsxs("div",{className:"card-detail-comment-author",children:[V&&jsx("div",{className:"card-detail-user-avatar",style:{background:V.color},children:V.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:V?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(L.createdAt).toLocaleString()})]})]}),l&&jsx("button",{onClick:()=>l(L.id),className:"card-detail-comment-delete",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]})})]}),jsx("p",{className:"card-detail-comment-content",children:L.content})]},L.id)}):jsxs("div",{className:"card-detail-empty-state",children:[jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("p",{children:"No comments yet"}),jsx("span",{children:"Be the first to comment"})]})})]}),u==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(L=>{let V=s.find(q=>q.id===L.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[L.type.includes("CREATED")&&"\u2795",L.type.includes("UPDATED")&&"\u270F\uFE0F",L.type.includes("MOVED")&&"\u27A1\uFE0F",L.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",L.type.includes("COMMENT")&&"\u{1F4AC}",L.type.includes("ASSIGNED")&&"\u{1F464}",L.type.includes("PRIORITY")&&"\u{1F3AF}",L.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",L.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:V?.name||"Unknown"})," ",L.type.replace(/_/g," ").toLowerCase(),L.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:L.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(L.timestamp).toLocaleString()})]})]},L.id)})}):jsxs("div",{className:"card-detail-empty-state",children:[jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})}),u==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx(kr,{cardId:e.id,attachments:i,onUpload:f?L=>f(e.id,L):void 0,onDelete:y,currentUserId:b,maxSizeMB:10,maxFiles:20})}),u==="ai"&&jsxs("div",{className:"card-detail-ai",children:[jsxs("div",{className:"card-detail-ai-actions",children:[jsx("h3",{className:"card-detail-ai-heading",children:"AI-Powered Suggestions"}),jsxs("button",{onClick:ge,disabled:A||!k,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Suggest Best Assignee"]}),jsxs("button",{onClick:fe,disabled:A||!C,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),jsx("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),jsx("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),jsx("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),jsx("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]}),"Generate Subtasks"]}),jsxs("button",{onClick:Ie,disabled:A||!h,className:"card-detail-ai-btn",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:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Estimate Effort"]})]}),W.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),W.assignees.map((L,V)=>{let q=s.find(z=>z.id===L.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[q&&jsx("div",{className:"card-detail-user-avatar",style:{background:q.color},children:q.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:q?.name}),jsx("div",{className:"card-detail-ai-suggestion-reason",children:L.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(L.confidence*100).toFixed(0),"%"]})]})]},V)})]}),W.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),W.subtasks.map((L,V)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:L.title}),L.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:L.description}),L.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",L.estimatedTime,"h"]})]},V))]}),W.effort&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Effort Estimate"}),jsxs("div",{className:"card-detail-ai-effort",children:[jsxs("div",{className:"card-detail-ai-effort-hours",children:[W.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(W.effort.confidence*100).toFixed(0),"%"]})]})]}),g.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),g.map(L=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${L.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:L.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:L.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:L.description}),L.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",L.suggestedAction]})]},L.id))]}),!W.assignees&&!W.subtasks&&!W.effort&&g.length===0&&jsxs("div",{className:"card-detail-empty-state",children:[jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("p",{children:"AI Suggestions"}),jsx("span",{children:"Click a button above to get AI-powered insights"})]})]})]})]})})})}function Jo({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:n=""}){let[c,g]=useState({top:0,left:0}),i=useRef(null),p=useCallback(()=>{if(!e.current)return {top:0,left:0};let l=e.current.getBoundingClientRect(),f=window.innerHeight,y=window.innerWidth,k=4,C=l.left;C+o>y-10&&(C=y-o-10),C<10&&(C=10);let h=f-l.bottom,b=l.top,u;return h>=s+k?u=l.bottom+k:b>=s+k?u=l.top-s-k:h>=b?u=l.bottom+k:u=Math.max(10,l.top-s-k),{top:u,left:C}},[e,o,s]);return useEffect(()=>{t&&g(p());},[t,p]),useEffect(()=>{if(!t)return;let l=y=>{let k=y.target;i.current&&!i.current.contains(k)&&e.current&&!e.current.contains(k)&&a();},f=setTimeout(()=>{document.addEventListener("mousedown",l);},0);return ()=>{clearTimeout(f),document.removeEventListener("mousedown",l);}},[t,a,e]),useEffect(()=>{if(!t)return;let l=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),a());};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t,a]),t?jsx(bt,{children:jsx("div",{ref:i,className:`smart-popover ${n}`,style:{position:"fixed",top:`${c.top}px`,left:`${c.left}px`,width:`${o}px`,maxHeight:"calc(100vh - 40px)",overflowY:"auto",zIndex:99999,padding:"6px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",animation:"popoverSlideIn 100ms ease-out"},children:r})}):null}var at={dark:{bgPrimary:"#1A1D21",bgSecondary:"#22262D",bgGrid:"#1E2126",bgWeekend:"rgba(59, 130, 246, 0.03)",border:"#334155",borderLight:"#2D3139",textPrimary:"#FFFFFF",textSecondary:"#CBD5E1",textTertiary:"#64748B",accent:"#3B82F6",accentHover:"#60A5FA",accentLight:"rgba(59, 130, 246, 0.12)",taskBarPrimary:"#3B82F6",taskBarProgress:"#2563EB",taskBarHandle:"#FFFFFF",dependency:"#9CA3AF",dependencyHover:"#6B7280",criticalPath:"#EF4444",criticalPathLight:"rgba(239, 68, 68, 0.12)",today:"#D21E24",todayLight:"rgba(210, 30, 36, 0.12)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.1)",statusTodo:"#64748B",statusInProgress:"#3B82F6",statusCompleted:"#10B981",hoverBg:"rgba(255, 255, 255, 0.06)",focusRing:"#3B82F6"},light:{bgPrimary:"#FFFFFF",bgSecondary:"#F8FAFC",bgGrid:"#F1F5F9",bgWeekend:"rgba(37, 99, 235, 0.03)",border:"#CBD5E1",borderLight:"#E2E8F0",textPrimary:"#0F172A",textSecondary:"#334155",textTertiary:"#64748B",accent:"#2563EB",accentHover:"#1D4ED8",accentLight:"rgba(37, 99, 235, 0.08)",taskBarPrimary:"#2563EB",taskBarProgress:"#1E40AF",taskBarHandle:"#FFFFFF",dependency:"#6B7280",dependencyHover:"#4B5563",criticalPath:"#DC2626",criticalPathLight:"rgba(220, 38, 38, 0.1)",today:"#D21E24",todayLight:"rgba(210, 30, 36, 0.1)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.08)",statusTodo:"#64748B",statusInProgress:"#2563EB",statusCompleted:"#059669",hoverBg:"rgba(0, 0, 0, 0.04)",focusRing:"#2563EB"},neutral:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgGrid:"#EFEDEC",bgWeekend:"rgba(41, 37, 36, 0.02)",border:"#D6D3D1",borderLight:"#E7E5E4",textPrimary:"#0C0A09",textSecondary:"#44403C",textTertiary:"#78716C",accent:"#292524",accentHover:"#44403C",accentLight:"rgba(41, 37, 36, 0.08)",taskBarPrimary:"#292524",taskBarProgress:"#1C1917",taskBarHandle:"#FFFFFF",dependency:"#78716C",dependencyHover:"#57534E",criticalPath:"#44403C",criticalPathLight:"rgba(68, 64, 60, 0.08)",today:"#1C1917",todayLight:"rgba(28, 25, 23, 0.06)",milestone:"#57534E",milestoneLight:"rgba(87, 83, 78, 0.08)",statusTodo:"#78716C",statusInProgress:"#292524",statusCompleted:"#15803D",hoverBg:"rgba(0, 0, 0, 0.035)",focusRing:"#292524"}};var Sf=["LOW","MEDIUM","HIGH","URGENT"],Ef=["todo","in-progress","review","done"];function ci({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],onAddComment:g,onDeleteComment:i,currentUser:p,onAIGenerateDescription:l,onAICreateSubtasks:f,onAIFindSimilar:y,availableColumns:k=[],availableLabels:C=[],availableTags:h=[],onCreateTag:b,onUploadCoverImage:u,unsplashAccessKey:x,theme:m,onSubtasksChange:N,attachments:w=[],onUploadAttachments:B,onDeleteAttachment:v}){let I=wo(),A=m||I?.themeName||"dark",[T,W]=useState(e),[$,j]=useState(false),[te,oe]=useState(e?.subtasks||[]),[re,ge]=useState(false),[fe,Ie]=useState(""),[M,R]=useState(""),[L,V]=useState("all"),[q,z]=useState(false),[ye,ne]=useState(false),[Be,qe]=useState(false),[tt,le]=useState(false),[Je,ct]=useState(false),[wt,vt]=useState(false),U=useRef(null),me=useRef(null),Ae=useRef(null),Fe=useRef(null),je=useRef(null),Qe=useRef(null),Pt=useRef(null),Re=useRef(null),J=useRef(null),ve=useRef(null),He=useRef(null),Le=useRef(null);useEffect(()=>{e&&!T?(W({...e}),oe(e.subtasks||[])):e&&T&&e.id!==T.id&&(W({...e}),oe(e.subtasks||[]));},[e,T]),useEffect(()=>{let H=ie=>{let We=ie.target;Fe.current&&!Fe.current.contains(We)&&z(false),je.current&&!je.current.contains(We)&&ne(false),Qe.current&&!Qe.current.contains(We)&&qe(false),Pt.current&&!Pt.current.contains(We)&&le(false);};if(q||ye||Be||tt)return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[q,ye,Be,tt]),useEffect(()=>{if(!t)return;let H=ie=>{let We=ie.target,Mt=We.tagName==="INPUT"||We.tagName==="TEXTAREA"||We.isContentEditable;if(ie.key==="Escape"){ie.preventDefault(),q||ye||Be||tt||Je||wt?(z(false),ne(false),qe(false),le(false),ct(false),vt(false)):Mt||a();return}if(Mt&&ie.key!=="Escape")return;let pt=ie.metaKey||ie.ctrlKey;switch(ie.key.toLowerCase()){case "s":ie.preventDefault(),z(true);break;case "a":ie.preventDefault(),qe(true);break;case "p":ie.preventDefault(),ne(true);break;case "l":ie.preventDefault(),le(true);break;case "d":pt||(ie.preventDefault(),ct(true),setTimeout(()=>Re.current?.focus(),0));break;case "e":pt||(ie.preventDefault(),vt(true));break;case "i":ie.preventDefault(),j(true),setTimeout(()=>me.current?.focus(),0);break;case "t":ie.preventDefault(),ge(true);break;case "c":ie.preventDefault(),Ae.current?.focus();break}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[t,a,q,ye,Be,tt,Je,wt]);let nt=useCallback(H=>{let ie=H.currentTarget.textContent?.trim()||"";if(T&&ie!==T.title){let We={...T,title:ie};W(We),r?.(T.id,{title:ie});}},[T,r]),st=useCallback(H=>{H.key==="Enter"&&(H.preventDefault(),H.currentTarget.blur()),H.key==="Escape"&&(H.preventDefault(),H.currentTarget.textContent=T?.title||"",H.currentTarget.blur());},[T]),_e=useCallback(()=>{T&&e&&T.description!==e.description&&r?.(T.id,{description:T.description}),j(false);},[T,e,r]),ea=useCallback(H=>{if(T){let ie={...T,columnId:H};W(ie),r?.(T.id,{columnId:H}),z(false);}},[T,r]),ke=useCallback(H=>{if(T){let ie={...T,priority:H};W(ie),r?.(T.id,{priority:H}),ne(false);}},[T,r]),be=useCallback(H=>{if(T){let ie=T.assignedUserIds||[],We=ie.includes(H)?ie.filter(pt=>pt!==H):[...ie,H],Mt={...T,assignedUserIds:We};W(Mt),r?.(T.id,{assignedUserIds:We});}},[T,r]),Ke=useCallback(H=>{if(T){let ie=T.labels||[],We=ie.includes(H)?ie.filter(pt=>pt!==H):[...ie,H],Mt={...T,labels:We};W(Mt),r?.(T.id,{labels:We});}},[T,r]),F=useCallback(H=>{if(T){let ie={...T,tags:H};W(ie),r?.(T.id,{tags:H});}},[T,r]),Ce=useCallback(H=>{if(T){let ie=H.target.value,We={...T,endDate:ie};W(We),r?.(T.id,{endDate:ie}),ct(false);}},[T,r]),Z=useCallback(H=>{if(T){let ie={...T,estimatedTime:parseFloat(H)||0};W(ie),r?.(T.id,{estimatedTime:parseFloat(H)||0});}},[T,r]),Te=useCallback(()=>{if(fe.trim()&&T){let H={id:`subtask-${Date.now()}`,title:fe.trim(),completed:false,createdAt:new Date},ie=[...te,H];oe(ie),Ie(""),ge(false),N?.(T.id,ie);}},[fe,te,T,N]),we=useCallback(H=>{let ie=te.map(We=>We.id===H?{...We,completed:!We.completed,updatedAt:new Date}:We);oe(ie),T&&N?.(T.id,ie);},[te,T,N]),Oe=useCallback(H=>{let ie=te.filter(We=>We.id!==H);oe(ie),T&&N?.(T.id,ie);},[te,T,N]),$e=useCallback(()=>{M.trim()&&T&&g&&(g(T.id,M.trim()),R(""));},[M,T,g]),dt=useCallback(H=>{(H.metaKey||H.ctrlKey)&&H.key==="Enter"&&(H.preventDefault(),$e());},[$e]),_=H=>jsx(Tf,{remarkPlugins:[Nf],rehypePlugins:[Df],components:{a:({node:ie,...We})=>jsx("a",{...We,target:"_blank",rel:"noopener noreferrer"})},children:H}),Y=c.filter(H=>L==="comments"?H.type.includes("COMMENT"):L==="history"?!H.type.includes("COMMENT"):true);if(!t||!e)return null;let se=T||e,Ye=s.filter(H=>se.assignedUserIds?.includes(H.id)),Ue=te.filter(H=>H.completed).length;return jsx(bt,{children:jsx("div",{className:"modal-v2-backdrop",onClick:a,style:{position:"fixed",inset:"0",zIndex:9999,background:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxs("div",{className:"modal-v2-container",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":A,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:U,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:nt,onKeyDown:st,children:se.title}),jsxs("p",{className:"modal-v2-ai-prompt",children:[jsx("span",{className:"modal-v2-ai-icon",children:"\u2728"}),"Ask AI to write a description, create subtasks, or find similar tasks"]}),jsx("button",{className:"modal-v2-close",onClick:a,"aria-label":"Close",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("section",{className:"modal-v2-metadata",children:[jsxs("div",{className:"modal-v2-field-wrapper",ref:Fe,children:[jsxs("button",{ref:J,className:"modal-v2-field",onClick:()=>z(!q),children:[jsxs("div",{className:"modal-v2-field-label",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:"10"}),jsx("path",{d:"M12 6v6l4 2"})]}),jsx("span",{children:"Status"}),jsx("kbd",{className:"modal-v2-shortcut",children:"S"})]}),jsx("div",{className:"modal-v2-field-value",children:se.columnId||"No status"})]}),jsx(Jo,{triggerRef:J,isOpen:q,onClose:()=>z(false),width:250,estimatedHeight:200,children:(k.length>0?k:Ef.map(H=>({id:H,title:H}))).map(H=>jsx("button",{className:`modal-v2-popover-item ${se.columnId===H.id?"active":""}`,onClick:()=>ea(H.id),children:H.title},H.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Qe,children:[jsxs("button",{ref:ve,className:"modal-v2-field",onClick:()=>qe(!Be),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),jsx("span",{children:"Assignees"}),jsx("kbd",{className:"modal-v2-shortcut",children:"A"})]}),jsx("div",{className:"modal-v2-field-value",children:Ye.length>0?jsx("div",{className:"modal-v2-avatars",children:Ye.map(H=>jsx("div",{className:"modal-v2-avatar",style:{background:H.color},title:H.name,children:H.initials},H.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Jo,{triggerRef:ve,isOpen:Be,onClose:()=>qe(false),width:280,estimatedHeight:300,children:s.map(H=>jsxs("button",{className:`modal-v2-popover-item ${se.assignedUserIds?.includes(H.id)?"active":""}`,onClick:()=>be(H.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:H.color},children:H.initials}),H.name,se.assignedUserIds?.includes(H.id)&&jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{marginLeft:"auto"},children:jsx("polyline",{points:"20 6 9 17 4 12"})})]},H.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:je,children:[jsxs("button",{ref:He,className:"modal-v2-field",onClick:()=>ne(!ye),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Priority"}),jsx("kbd",{className:"modal-v2-shortcut",children:"P"})]}),jsx("div",{className:"modal-v2-field-value",children:se.priority||"None"})]}),jsxs(Jo,{triggerRef:He,isOpen:ye,onClose:()=>ne(false),width:180,estimatedHeight:220,children:[Sf.map(H=>jsx("button",{className:`modal-v2-popover-item priority-${H.toLowerCase()} ${se.priority===H?"active":""}`,onClick:()=>ke(H),children:H},H)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>ke(""),children:"None"})]})]}),h.length>0||b?jsx("div",{className:"modal-v2-field-wrapper",children:jsxs("div",{className:"modal-v2-field",style:{cursor:"default"},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Etiquetas"})]}),jsx("div",{className:"modal-v2-field-value",children:jsx(hr,{selectedTags:se.tags||[],availableTags:h,onChange:F,onCreateTag:b,theme:at[A]||at.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:Pt,children:[jsxs("button",{ref:Le,className:"modal-v2-field",onClick:()=>le(!tt),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Labels"}),jsx("kbd",{className:"modal-v2-shortcut",children:"L"})]}),jsx("div",{className:"modal-v2-field-value",children:se.labels&&se.labels.length>0?jsx("span",{children:se.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Jo,{triggerRef:Le,isOpen:tt,onClose:()=>le(false),width:220,estimatedHeight:200,children:(C.length>0?C:["Bug","Feature","Enhancement","Documentation"]).map(H=>jsxs("button",{className:`modal-v2-popover-item ${se.labels?.includes(H)?"active":""}`,onClick:()=>Ke(H),children:[H,se.labels?.includes(H)&&jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{marginLeft:"auto"},children:jsx("polyline",{points:"20 6 9 17 4 12"})})]},H))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{ct(!Je),setTimeout(()=>Re.current?.showPicker?.(),0);},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),jsx("span",{children:"Due Date"}),jsx("kbd",{className:"modal-v2-shortcut",children:"D"})]}),jsx("div",{className:"modal-v2-field-value",children:se.endDate?new Date(se.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Re,type:"date",value:typeof se.endDate=="string"?se.endDate.split("T")[0]:se.endDate?(()=>{let H=new Date(se.endDate),ie=H.getUTCFullYear(),We=String(H.getUTCMonth()+1).padStart(2,"0"),Mt=String(H.getUTCDate()).padStart(2,"0");return `${ie}-${We}-${Mt}`})():"",onChange:Ce,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>vt(!wt),children:[jsxs("div",{className:"modal-v2-field-label",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:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx("span",{children:"Estimated Time"}),jsx("kbd",{className:"modal-v2-shortcut",children:"E"})]}),jsx("div",{className:"modal-v2-field-value",children:se.estimatedTime?`${se.estimatedTime}h`:"Not set"})]}),wt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:se.estimatedTime||"",onChange:H=>Z(H.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>vt(false)})})]})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-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"})]}),jsx("h2",{children:"Description"})]}),$?jsx("textarea",{className:"modal-v2-textarea",value:se.description||"",onChange:H=>{if(T){let ie={...T,description:H.target.value};W(ie);}},onBlur:_e,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>j(true),children:se.description?jsx("div",{className:"modal-v2-markdown",children:_(se.description)}):jsxs("p",{className:"modal-v2-placeholder",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Add description..."]})})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M9 11l3 3L22 4"}),jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]}),jsx("h2",{children:"Subtasks"}),te.length>0&&jsxs("span",{className:"modal-v2-count",children:[Ue,"/",te.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>ge(true),children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add"]})]}),jsxs("div",{className:"modal-v2-subtasks",children:[te.map(H=>jsxs("div",{className:`modal-v2-subtask ${H.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>we(H.id),children:H.completed?jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9 12l2 2 4-4",stroke:"white",strokeWidth:"2",fill:"none"})]}):jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("circle",{cx:"12",cy:"12",r:"10"})})}),jsx("span",{className:"modal-v2-subtask-title",children:H.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>Oe(H.id),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]})})]},H.id)),re&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:fe,onChange:H=>Ie(H.target.value),onKeyDown:H=>{H.key==="Enter"&&Te(),H.key==="Escape"&&(ge(false),Ie(""));},onBlur:Te,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(B||w.length>0)&&jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),jsx("h2",{children:"Attachments"}),w.length>0&&jsx("span",{className:"modal-v2-count",children:w.length})]}),jsx(kr,{cardId:se.id,attachments:w,onUpload:B?H=>B(se.id,H):void 0,onDelete:v,maxSizeMB:10,maxFiles:20})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("h2",{children:"Activity"}),jsxs("div",{className:"modal-v2-filters",children:[jsx("button",{className:`modal-v2-filter ${L==="all"?"active":""}`,onClick:()=>V("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${L==="comments"?"active":""}`,onClick:()=>V("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${L==="history"?"active":""}`,onClick:()=>V("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[p&&jsx("div",{className:"modal-v2-avatar",style:{background:p.color},children:p.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:Ae,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:M,onChange:H=>R(H.target.value),onKeyDown:dt,rows:1}),jsxs("div",{className:"modal-v2-comment-toolbar",children:[jsxs("div",{className:"modal-v2-toolbar-left",children:[jsx("button",{className:"modal-v2-toolbar-button",title:"Attach file",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})})}),jsx("button",{className:"modal-v2-toolbar-button",title:"Mention user",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:"4"}),jsx("path",{d:"M16 8v5a3 3 0 006 0v-1a10 10 0 10-3.92 7.94"})]})}),jsx("button",{className:"modal-v2-toolbar-button",title:"Add emoji",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:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",y1:"9",x2:"9.01",y2:"9"}),jsx("line",{x1:"15",y1:"9",x2:"15.01",y2:"9"})]})})]}),jsx("button",{className:"modal-v2-send-button",onClick:$e,disabled:!M.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[Y.map(H=>{let ie=s.find(Mt=>Mt.id===H.userId);if(H.type.includes("COMMENT")){let Mt=n.find(pt=>pt.id===H.metadata?.commentId);return Mt?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[ie&&jsx("div",{className:"modal-v2-avatar",style:{background:ie.color},children:ie.initials}),jsxs("div",{className:"modal-v2-activity-content",children:[jsxs("div",{className:"modal-v2-activity-header",children:[jsx("span",{className:"modal-v2-activity-user",children:ie?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(H.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:Mt.content})]})]},H.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[H.type.includes("CREATED")&&"\u2795",H.type.includes("UPDATED")&&"\u270F\uFE0F",H.type.includes("MOVED")&&"\u27A1\uFE0F",H.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",H.type.includes("ASSIGNED")&&"\u{1F464}",H.type.includes("PRIORITY")&&"\u{1F3AF}",H.type.includes("LABEL")&&"\u{1F3F7}\uFE0F"]}),jsxs("div",{className:"modal-v2-activity-content",children:[jsxs("div",{className:"modal-v2-history-text",children:[jsx("span",{className:"modal-v2-activity-user",children:ie?.name||"Unknown"})," ",H.type.replace(/_/g," ").toLowerCase(),H.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:H.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(H.timestamp).toLocaleString()})]})]},H.id)}),Y.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function Of({active:e,payload:t}){return !e||!t||!t.length?null:jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:t[0].payload.period}),t.map((a,r)=>jsxs("p",{className:"chart-tooltip-value",style:{color:a.color},children:[a.name,": ",jsx("strong",{children:a.value})," cards"]},r))]})}function pi({data:e,title:t="Team Velocity",height:a=300,showAverage:r=true,showPlanned:o=true}){let s=e.map(n=>({...n,average:n.average??e.reduce((c,g)=>c+g.completed,0)/e.length}));return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(LineChart,{data:s,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"period",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Of,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Line,{type:"monotone",dataKey:"completed",stroke:"#10B981",strokeWidth:3,name:"Completed",dot:{fill:"#10B981",r:5},activeDot:{r:7}}),o&&jsx(Line,{type:"monotone",dataKey:"planned",stroke:"#3B82F6",strokeWidth:2,strokeDasharray:"5 5",name:"Planned",dot:{fill:"#3B82F6",r:4}}),r&&jsx(Line,{type:"monotone",dataKey:"average",stroke:"#F59E0B",strokeWidth:2,strokeDasharray:"3 3",name:"Average",dot:false})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Completed"}),jsx("span",{className:"chart-stat-value",style:{color:"#10B981"},children:e.reduce((n,c)=>n+c.completed,0)})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Average Velocity"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:(e.reduce((n,c)=>n+c.completed,0)/e.length).toFixed(1)})]}),o&&e.some(n=>n.planned)&&jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Planned"}),jsx("span",{className:"chart-stat-value",style:{color:"#3B82F6"},children:e.reduce((n,c)=>n+(c.planned||0),0)})]})]})]})}function jf({active:e,payload:t}){return !e||!t||!t.length?null:jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:t[0].payload.day}),t.map((a,r)=>jsxs("p",{className:"chart-tooltip-value",style:{color:a.color},children:[a.name,": ",jsx("strong",{children:a.value})," tasks"]},r))]})}function ui({data:e,title:t="Sprint Burndown",height:a=300,totalTasks:r,useArea:o=false}){let s=r??(e[0]?.ideal||e[0]?.remaining||0),n=e[e.length-1]?.remaining||0,c=e[e.length-1]?.ideal||0,g=s>0?(s-n)/s*100:0,i=n<=c;return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(o?AreaChart:LineChart,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"day",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(jf,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),o?jsxs(Fragment,{children:[jsx(Area,{type:"monotone",dataKey:"ideal",stroke:"#F59E0B",fill:"rgba(245, 158, 11, 0.2)",strokeWidth:2,strokeDasharray:"5 5",name:"Ideal"}),jsx(Area,{type:"monotone",dataKey:"remaining",stroke:i?"#10B981":"#EF4444",fill:i?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",strokeWidth:3,name:"Remaining"})]}):jsxs(Fragment,{children:[jsx(Line,{type:"linear",dataKey:"ideal",stroke:"#F59E0B",strokeWidth:2,strokeDasharray:"5 5",name:"Ideal",dot:{fill:"#F59E0B",r:4}}),jsx(Line,{type:"monotone",dataKey:"remaining",stroke:i?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:i?"#10B981":"#EF4444",r:5},activeDot:{r:7}})]})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Progress"}),jsxs("span",{className:"chart-stat-value",style:{color:g>=50?"#10B981":"#F59E0B"},children:[g.toFixed(0),"%"]})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Remaining"}),jsx("span",{className:"chart-stat-value",style:{color:i?"#10B981":"#EF4444"},children:n})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Status"}),jsx("span",{className:"chart-stat-badge",style:{background:i?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:i?"#10B981":"#EF4444"},children:i?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var t0={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},kc=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function a0({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let n=r+(o-r)*.5,c=e+n*Math.cos(-a*(Math.PI/180)),g=t+n*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:c,y:g,fill:"white",textAnchor:c>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function wc({active:e,payload:t}){if(!e||!t||!t.length)return null;let a=t[0].payload,r=t[0].payload.totalValue||0,o=r>0?(a.value/r*100).toFixed(1):"0";return jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:a.name}),jsxs("p",{className:"chart-tooltip-value",style:{color:a.color||t[0].color},children:["Count: ",jsx("strong",{children:a.value})]}),jsxs("p",{className:"chart-tooltip-value",style:{color:"rgba(255, 255, 255, 0.7)"},children:["Percentage: ",jsxs("strong",{children:[o,"%"]})]})]})}function gi({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((g,i)=>g+i.value,0),n=e.map(g=>({...g,totalValue:s,color:g.color||t0[g.name]||kc[e.indexOf(g)%kc.length]})),c=n.map(g=>g.color);return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:r,children:a==="pie"?jsxs(PieChart,{children:[jsx(Pie,{data:n,cx:"50%",cy:"50%",labelLine:false,label:o?a0:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:n.map((g,i)=>jsx(Cell,{fill:c[i]},`cell-${i}`))}),jsx(Tooltip,{content:jsx(wc,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(g,i)=>{let p=i.payload,l=s>0?(p.value/s*100).toFixed(0):"0";return `${g} (${p.value} - ${l}%)`}})]}):jsxs(BarChart$1,{data:n,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"name",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(wc,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Bar,{dataKey:"value",name:"Count",radius:[8,8,0,0],children:n.map((g,i)=>jsx(Cell,{fill:c[i]},`cell-${i}`))})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Cards"}),jsx("span",{className:"chart-stat-value",style:{color:"#3B82F6"},children:s})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Categories"}),jsx("span",{className:"chart-stat-value",style:{color:"#10B981"},children:e.length})]}),e.length>0&&jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Largest Category"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:e.reduce((g,i)=>i.value>g.value?i:g).name})]})]})]})}var On=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[n,c]=useState(false),[g,i]=useState(false),[p,l]=useState(false),[f,y]=useState(false);if(e.length===0)return null;let k=e.map(m=>m.id),C=m=>{r.onBulkUpdate?.(k,{priority:m}),c(false);},h=m=>{r.onBulkMove?.(k,m),i(false),a();},b=m=>{r.onBulkUpdate?.(k,{assignedUserIds:m}),l(false);},u=m=>{let N=new Set;e.forEach(B=>{B.labels?.forEach(v=>N.add(v));});let w=Array.from(new Set([...N,...m]));r.onBulkUpdate?.(k,{labels:w}),y(false);},x=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(k),a());};return jsx("div",{className:"asakaa-bulk-toolbar",children:jsxs("div",{className:"asakaa-bulk-toolbar-content",children:[jsxs("div",{className:"asakaa-bulk-toolbar-count",children:[e.length," card",e.length!==1?"s":""," selected"]}),jsxs("div",{className:"asakaa-bulk-toolbar-actions",children:[jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>c(!n),title:"Update priority",children:jsx("span",{className:"text-sm",children:"Priority"})}),n&&jsx("div",{className:"asakaa-bulk-menu",children:["LOW","MEDIUM","HIGH","URGENT"].map(m=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>C(m),children:[jsx("span",{className:d("asakaa-priority-dot",m==="LOW"&&"bg-asakaa-priority-low",m==="MEDIUM"&&"bg-asakaa-priority-medium",m==="HIGH"&&"bg-asakaa-priority-high",m==="URGENT"&&"bg-asakaa-priority-urgent")}),m]},m))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>i(!g),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),g&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(m=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>h(m.id),children:m.title},m.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>l(!p),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(m=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>b([m.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:m.color},children:m.initials}),m.name]},m.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>y(!f),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),f&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(m=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>u([m]),children:m},m))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:x,title:"Delete selected cards",children:jsx("span",{className:"text-sm",children:"Delete"})}),jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:a,title:"Clear selection",children:jsx("span",{className:"text-sm",children:"\u2715"})})]})]})})});On.displayName="BulkOperationsToolbar";function i0(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,n,c,g,i;switch(t){case "assignee":let p=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);p.length>0?p.forEach(y=>{let k=a?.find(C=>C.id===y);n=`assignee-${y}`,c=k?.name||`User ${y}`,g=k?.color,i=k?.avatar,r.has(n)||r.set(n,{id:n,title:c,groupValue:y,cardIds:[],color:g,icon:i}),r.get(n).cardIds.push(o.id);}):(n="assignee-unassigned",c="Unassigned",g="#6b7280",i="\u{1F464}",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:g,icon:i}),r.get(n).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",n=`priority-${s}`;let f={URGENT:{title:"\u{1F534} Urgent",color:"#ef4444"},HIGH:{title:"\u{1F7E0} High",color:"#f97316"},MEDIUM:{title:"\u{1F7E1} Medium",color:"#eab308"},LOW:{title:"\u{1F7E2} Low",color:"#22c55e"},NONE:{title:"\u26AA No Priority",color:"#6b7280"}}[s];c=f.title,g=f.color,r.has(n)||r.set(n,{id:n,title:c,groupValue:s,cardIds:[],color:g}),r.get(n).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(y=>{n=`label-${y}`,c=y,g="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:y,cardIds:[],color:g}),r.get(n).cardIds.push(o.id);}):(n="label-none",c="No Labels",g="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:g}),r.get(n).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function fi({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,n]=useState(new Set),c=useMemo(()=>i0(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),g=useCallback(i=>{n(p=>{let l=new Set(p);return l.has(i)?l.delete(i):l.add(i),l});},[]);return t.groupBy==="none"||c.length===0?jsx(zr,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:d("asakaa-swimlane-view",o),children:[c.map(i=>{let p=s.has(i.id),l=e.cards.filter(y=>i.cardIds.includes(y.id)),f={...e,cards:l};return jsxs("div",{className:"asakaa-swimlane mb-6 rounded-lg border border-white/10 overflow-hidden",children:[jsxs("div",{className:"asakaa-swimlane-header px-4 py-3 bg-white/5 backdrop-blur-sm flex items-center justify-between cursor-pointer hover:bg-white/10 transition-colors",onClick:()=>t.collapsible&&g(i.id),style:{borderLeft:i.color?`4px solid ${i.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[i.icon&&jsx("span",{className:"text-2xl leading-none",children:i.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:i.color},children:i.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",i.cardIds.length," ",i.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":p?"Expand lane":"Collapse lane",children:p?"\u25B6":"\u25BC"})]}),!p&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(zr,{board:f,callbacks:r,availableUsers:a})})]},i.id)}),c.length===0&&jsxs("div",{className:"text-center py-12 text-white/50",children:[jsx("p",{className:"text-lg",children:"No cards to display"}),jsx("p",{className:"text-sm mt-2",children:"Cards will appear here when they match the grouping criteria"})]})]})}var bi=[{value:"none",label:"No Grouping",icon:"\u{1F4CB}",description:"Standard Kanban board view"},{value:"assignee",label:"By Assignee",icon:"\u{1F465}",description:"Group cards by assigned user"},{value:"priority",label:"By Priority",icon:"\u{1F3AF}",description:"Group cards by priority level"},{value:"label",label:"By Label",icon:"\u{1F3F7}\uFE0F",description:"Group cards by label/tag"}];function hi({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null),c=bi.find(i=>i.value===e)||bi[0];useEffect(()=>{function i(p){s.current&&!s.current.contains(p.target)&&n.current&&!n.current.contains(p.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let g=i=>{t(i),o(false);};return jsxs("div",{className:d("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/10 hover:bg-white/15 border border-white/20 transition-all text-sm font-medium text-white/90",children:[jsx("span",{className:"text-base leading-none",children:c.icon}),jsx("span",{children:c.label}),jsx("svg",{className:d("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-[280px] rounded-lg bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl border border-white/20 shadow-2xl z-50 overflow-hidden",children:[jsx("div",{className:"px-3 py-2 border-b border-white/10",children:jsx("span",{className:"text-[10px] font-bold text-white/70 uppercase tracking-wider",children:"Group By"})}),jsx("div",{className:"py-1",children:bi.map(i=>jsxs("button",{onClick:()=>g(i.value),className:d("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===i.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:i.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"font-semibold text-sm text-white",children:i.label}),e===i.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:i.description})]})]},i.value))})]})]})}var Zo=[{keys:"ArrowUp",action:"navigate_up",description:"Navigate to card above"},{keys:"ArrowDown",action:"navigate_down",description:"Navigate to card below"},{keys:"ArrowLeft",action:"navigate_left",description:"Navigate to previous column"},{keys:"ArrowRight",action:"navigate_right",description:"Navigate to next column"},{keys:"Enter",action:"open_card",description:"Open selected card"},{keys:"Escape",action:"close_modal",description:"Close modal or dialog"},{keys:"Delete",action:"delete_card",description:"Delete selected card",modifiers:{shift:true}},{keys:"n",action:"new_card",description:"Create new card",modifiers:{ctrl:true}},{keys:"k",action:"search",description:"Open search/command palette",modifiers:{ctrl:true}},{keys:"s",action:"save",description:"Save changes",modifiers:{ctrl:true}},{keys:"z",action:"undo",description:"Undo last action",modifiers:{ctrl:true}},{keys:"y",action:"redo",description:"Redo last undone action",modifiers:{ctrl:true}},{keys:"a",action:"select_all",description:"Select all cards",modifiers:{ctrl:true}},{keys:"Escape",action:"deselect_all",description:"Deselect all cards"},{keys:"?",action:"show_shortcuts",description:"Show keyboard shortcuts help",modifiers:{shift:true}}];function c0(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(i=>e.key===i||e.code===i))return false;let o=t.modifiers||{},s=o.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,n=o.shift?e.shiftKey:!e.shiftKey,c=o.alt?e.altKey:!e.altKey,g=o.meta?e.metaKey:true;return s&&n&&c&&g}function Sc(e={}){let{shortcuts:t=Zo,enabled:a=true,preventDefault:r=true}=e,o=useRef(t),s=useRef(a);useEffect(()=>{o.current=t,s.current=a;},[t,a]);let n=useCallback(g=>{o.current=[...o.current,g];},[]),c=useCallback(g=>{o.current=o.current.filter(i=>i.action!==g);},[]);return useEffect(()=>{function g(i){if(!s.current)return;let p=i.target;if(!((p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.isContentEditable)&&i.key!=="Escape"&&!i.ctrlKey&&!i.metaKey)){for(let l of o.current)if(c0(i,l)){r&&i.preventDefault();let f=new CustomEvent("keyboard-action",{detail:l.action,bubbles:true,cancelable:true});window.dispatchEvent(f);break}}}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[r]),{registerShortcut:n,unregisterShortcut:c,isEnabled:a}}function p0(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function u0(e){let t=[],a=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.modifiers?.ctrl&&t.push(a?"\u2318":"Ctrl"),e.modifiers?.shift&&t.push("Shift"),e.modifiers?.alt&&t.push(a?"\u2325":"Alt"),e.modifiers?.meta&&t.push("\u2318"),t.join(" + ")}function g0(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=u0(e),r=t?p0(t):"";return a?`${a} + ${r}`:r}function f0(e){let t={Navigation:[],Actions:[],Editing:[],Selection:[]};return e.forEach(a=>{a.action.includes("navigate")?t.Navigation?.push(a):a.action.includes("select")?t.Selection?.push(a):["undo","redo","save"].includes(a.action)?t.Editing?.push(a):t.Actions?.push(a);}),t}function yi({shortcuts:e=Zo,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function c(g){g.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,a]),!o||!t)return null;let n=f0(e);return jsxs("div",{className:d("fixed inset-0 z-[9999] flex items-center justify-center",r),children:[jsx("div",{className:"absolute inset-0 backdrop-blur-sm bg-black/40 dark:bg-black/60",onClick:a}),jsxs("div",{className:"relative backdrop-blur-xl rounded-2xl border shadow-2xl max-w-3xl w-full mx-4 max-h-[80vh] overflow-hidden bg-white dark:bg-gradient-to-br dark:from-gray-900/95 dark:to-gray-800/95 border-gray-200 dark:border-white/20",children:[jsxs("div",{className:"px-6 py-5 border-b flex items-center justify-between border-gray-200 dark:border-white/10",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold flex items-center gap-3 text-gray-900 dark:text-white",children:[jsx("span",{className:"text-3xl",children:"\u2328\uFE0F"}),"Keyboard Shortcuts"]}),jsx("p",{className:"text-sm mt-1 text-gray-500 dark:text-white/60",children:"Speed up your workflow with these shortcuts"})]}),jsx("button",{onClick:a,className:"transition-colors text-2xl leading-none p-2 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 dark:text-white/50 dark:hover:text-white dark:hover:bg-white/10","aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"px-6 py-6 overflow-y-auto max-h-[calc(80vh-120px)]",children:jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:Object.entries(n).map(([c,g])=>g.length===0?null:jsxs("div",{children:[jsxs("h3",{className:"text-lg font-semibold mb-4 flex items-center gap-2 text-gray-800 dark:text-white/90",children:[jsx("span",{className:"w-1 h-5 bg-blue-500 rounded-full"}),c]}),jsx("div",{className:"space-y-3",children:g.map(i=>jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-lg transition-colors bg-gray-50 hover:bg-gray-100 dark:bg-white/5 dark:hover:bg-white/10",children:[jsx("span",{className:"text-sm text-gray-700 dark:text-white/80",children:i.description}),jsx("kbd",{className:"px-3 py-1.5 border rounded-md text-xs font-mono shadow-sm whitespace-nowrap bg-white border-gray-300 text-gray-800 dark:bg-gradient-to-br dark:from-gray-700 dark:to-gray-800 dark:border-white/20 dark:text-white/90",children:g0(i)})]},i.action))})]},c))})}),jsx("div",{className:"px-6 py-4 border-t border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/5",children:jsxs("p",{className:"text-xs text-center text-gray-500 dark:text-white/50",children:["Press ",jsx("kbd",{className:"px-2 py-0.5 rounded bg-gray-200 text-gray-600 dark:bg-white/10 dark:text-white/70",children:"?"})," to toggle this help panel"]})})]})]})}var vi=[{id:"bug-report",name:"Bug Report",description:"Report a bug or issue",icon:"\u{1F41B}",category:"Development",template:{title:"[BUG] ",description:`**Steps to reproduce:**
|
|
71
|
+
`,y.onmouseenter=()=>{y.style.opacity="1";},y.onmouseleave=()=>{y.style.opacity="0.5";},y.onclick=k=>{k.stopPropagation();let C=r<a.length-1?r+1:0;i(),o(C);},n.appendChild(l),n.appendChild(f),n.appendChild(y);}n.appendChild(c),n.appendChild(g),document.body.appendChild(n),setTimeout(()=>{g.style.transition="opacity 0.5s ease",g.style.opacity="0";},2e3);}function xf(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+a[r]}function kf(e){return e.startsWith("image/")?"\u{1F5BC}\uFE0F":e.startsWith("video/")?"\u{1F3A5}":e.startsWith("audio/")?"\u{1F3B5}":e.includes("pdf")?"\u{1F4C4}":e.includes("word")||e.includes("document")?"\u{1F4DD}":e.includes("sheet")||e.includes("excel")?"\u{1F4CA}":e.includes("presentation")||e.includes("powerpoint")?"\u{1F4FD}\uFE0F":e.includes("zip")||e.includes("rar")||e.includes("compressed")?"\u{1F5DC}\uFE0F":e.includes("text")?"\u{1F4C3}":"\u{1F4CE}"}function ii(e){return e.startsWith("image/")}function kr({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[n,c]=useState(false),[g,i]=useState(false),[p,l]=useState(null),f=useRef(null),y=useRef(e);y.current=e;let k=useCallback((v,I)=>{I.preventDefault(),I.stopPropagation();let F=y.current.filter(O=>ii(O.type)),T=F.findIndex(O=>O.id===v.id),H=O=>{let K=y.current.filter(ne=>ii(ne.type)),ae=K[O];ae&&uc(ae.url,ae.name,K,O,H);};uc(v.url,v.name,F,T,H);},[]),C=useCallback(v=>{let I=[],F=[];return e.length+v.length>s?(F.push(`Maximum ${s} files allowed`),{valid:I,errors:F}):(v.forEach(T=>{if(T.size/1048576>r){F.push(`${T.name} is too large (max ${r}MB)`);return}if(o&&!o.some(O=>T.type.match(O))){F.push(`${T.name} has invalid file type`);return}I.push(T);}),{valid:I,errors:F})},[e.length,s,r,o]),h=useCallback(async v=>{let{valid:I,errors:F}=C(v);if(F.length>0){l(F.join(", ")),setTimeout(()=>l(null),5e3);return}if(I.length!==0){i(true),l(null);try{await t?.(I);}catch(T){l(T instanceof Error?T.message:"Upload failed"),setTimeout(()=>l(null),5e3);}finally{i(false);}}},[C,t]),b=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(true);},[]),u=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);},[]),x=useCallback(v=>{v.preventDefault(),v.stopPropagation();},[]),m=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);let I=Array.from(v.dataTransfer.files);h(I);},[h]),N=useCallback(v=>{let I=v.target.files?Array.from(v.target.files):[];h(I),f.current&&(f.current.value="");},[h]),w=useCallback(()=>{f.current?.click();},[]),B=useCallback(v=>{confirm("Are you sure you want to delete this attachment?")&&a?.(v);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${n?"dragging":""} ${g?"uploading":""}`,onDragEnter:b,onDragLeave:u,onDragOver:x,onDrop:m,onClick:w,children:[jsx("input",{ref:f,type:"file",multiple:true,onChange:N,style:{display:"none"},accept:o?.join(",")}),jsx("div",{className:"attachment-dropzone-content",children:g?jsxs(Fragment,{children:[jsx("div",{className:"attachment-spinner"}),jsx("p",{className:"attachment-dropzone-text",children:"Uploading..."})]}):jsxs(Fragment,{children:[jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"attachment-dropzone-icon",children:[jsx("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M17 8L12 3L7 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M12 3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),jsx("p",{className:"attachment-dropzone-text",children:n?"Drop files here":"Drag & drop files here"}),jsx("p",{className:"attachment-dropzone-subtext",children:"or click to browse"}),jsxs("p",{className:"attachment-dropzone-info",children:["Max ",r,"MB \u2022 ",e.length,"/",s," files"]})]})})]}),p&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:p})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(v=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:ii(v.type)&&v.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:I=>k(v,I),title:"Click to view full size",children:[jsx("img",{src:v.thumbnailUrl||v.url,alt:v.name,className:"attachment-thumbnail"}),jsx("div",{className:"attachment-thumbnail-overlay",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M9 21H3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M21 3L14 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M3 21L10 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}):jsx("div",{className:"attachment-icon",children:kf(v.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:v.name,children:v.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:xf(v.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(v.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>B(v.id),className:"attachment-delete",title:"Delete attachment",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},v.id))})]})}function li({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],aiInsights:g=[],attachments:i=[],onAddComment:p,onDeleteComment:l,onUploadAttachments:f,onDeleteAttachment:y,onSuggestAssignee:k,onGenerateSubtasks:C,onEstimateEffort:h,currentUserId:b="user-1"}){let[u,x]=useState("details"),[m,N]=useState(false),[w,B]=useState({}),[v,I]=useState(""),[F,T]=useState(false),[H,O]=useState({});if(!t||!e)return null;let K=useCallback(()=>{N(false),B({}),x("details"),I(""),O({}),a();},[a]),ae=useCallback(()=>{r&&Object.keys(w).length>0&&(r(e.id,w),B({}),N(false));},[e.id,w,r]),ne=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),K());},[e.id,o,K]),oe=useCallback(()=>{p&&v.trim()&&(p(e.id,v.trim()),I(""));},[e.id,v,p]),ye=useCallback(async()=>{if(k){T(true);try{let L=await k(e);O(j=>({...j,assignees:L}));}catch(L){console.error("Failed to suggest assignee:",L);}finally{T(false);}}},[e,k]),fe=useCallback(async()=>{if(C){T(true);try{let L=await C(e);O(j=>({...j,subtasks:L}));}catch(L){console.error("Failed to generate subtasks:",L);}finally{T(false);}}},[e,C]),Re=useCallback(async()=>{if(h){T(true);try{let L=await h(e);O(j=>({...j,effort:L}));}catch(L){console.error("Failed to estimate effort:",L);}finally{T(false);}}},[e,h]),A={...e,...w},R=s.filter(L=>A.assignedUserIds?.includes(L.id));return jsx(ft,{children:jsx("div",{className:"card-detail-overlay",onClick:K,children:jsxs("div",{className:"card-detail-modal",onClick:L=>L.stopPropagation(),children:[jsxs("div",{className:"card-detail-header",children:[jsxs("div",{className:"card-detail-header-left",children:[jsx("div",{className:"card-detail-priority-dot",style:{background:A.priority==="URGENT"?"#EF4444":A.priority==="HIGH"?"#F59E0B":A.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),m?jsx("input",{type:"text",value:w.title??A.title,onChange:L=>B({...w,title:L.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:A.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[m?jsxs(Fragment,{children:[jsx("button",{onClick:ae,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{N(false),B({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>N(true),className:"card-detail-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Edit"]}),jsxs("button",{onClick:ne,className:"card-detail-btn card-detail-btn-danger",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]}),"Delete"]}),jsx("button",{onClick:K,className:"card-detail-btn-close",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),jsxs("div",{className:"card-detail-tabs",children:[jsxs("button",{onClick:()=>x("details"),className:`card-detail-tab ${u==="details"?"active":""}`,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 00-2 2v16a2 2 0 002 2h12a2 2 0 002-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"})]}),"Details"]}),jsxs("button",{onClick:()=>x("comments"),className:`card-detail-tab ${u==="comments"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),"Comments",n.length>0&&jsx("span",{className:"card-detail-tab-badge",children:n.length})]}),jsxs("button",{onClick:()=>x("activity"),className:`card-detail-tab ${u==="activity"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),"Activity",c.length>0&&jsx("span",{className:"card-detail-tab-badge",children:c.length})]}),jsxs("button",{onClick:()=>x("attachments"),className:`card-detail-tab ${u==="attachments"?"active":""}`,children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),"Attachments",i.length>0&&jsx("span",{className:"card-detail-tab-badge",children:i.length})]}),jsxs("button",{onClick:()=>x("ai"),className:`card-detail-tab ${u==="ai"?"active":""}`,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),"AI Insights",jsx("span",{className:"card-detail-tab-badge card-detail-tab-badge-ai",children:"AI"})]})]}),jsxs("div",{className:"card-detail-content",children:[u==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),m?jsx("textarea",{value:w.description??A.description??"",onChange:L=>B({...w,description:L.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:A.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),m?jsx("select",{multiple:true,value:w.assignedUserIds??A.assignedUserIds??[],onChange:L=>{let j=Array.from(L.target.selectedOptions,J=>J.value);B({...w,assignedUserIds:j});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(L=>jsx("option",{value:L.id,children:L.name},L.id))}):jsx("div",{className:"card-detail-users",children:R.length>0?R.map(L=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:L.color},children:L.initials}),jsx("span",{children:L.name})]},L.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),m?jsxs("select",{value:w.priority??A.priority??"",onChange:L=>B({...w,priority:L.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},children:[jsx("option",{value:"",children:"None"}),jsx("option",{value:"LOW",children:"LOW"}),jsx("option",{value:"MEDIUM",children:"MEDIUM"}),jsx("option",{value:"HIGH",children:"HIGH"}),jsx("option",{value:"URGENT",children:"URGENT"})]}):jsxs("div",{className:"card-detail-priority",children:[jsx("div",{className:"card-detail-priority-dot",style:{background:A.priority==="URGENT"?"#EF4444":A.priority==="HIGH"?"#F59E0B":A.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:A.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:A.labels&&A.labels.length>0?A.labels.map(L=>jsx("span",{className:"card-detail-label-tag",children:L},L)):jsx("span",{className:"card-detail-empty",children:"No labels"})})]}),jsxs("div",{className:"card-detail-section-row",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Start Date"}),m?jsx("input",{type:"date",value:w.startDate?new Date(w.startDate).toISOString().split("T")[0]:A.startDate?new Date(A.startDate).toISOString().split("T")[0]:"",onChange:L=>B({...w,startDate:L.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:A.startDate?new Date(A.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),m?jsx("input",{type:"date",value:w.endDate?new Date(w.endDate).toISOString().split("T")[0]:A.endDate?new Date(A.endDate).toISOString().split("T")[0]:"",onChange:L=>B({...w,endDate:L.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:A.endDate?new Date(A.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),m?jsx("input",{type:"number",min:"0",step:"0.5",value:w.estimatedTime??A.estimatedTime??"",onChange:L=>B({...w,estimatedTime:L.target.value?parseFloat(L.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:A.estimatedTime||"Not estimated"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Dependencies"}),jsx("div",{className:"card-detail-dependencies",children:A.dependencies&&A.dependencies.length>0?A.dependencies.map(L=>{let j=typeof L=="string"?L:L.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",j.slice(-4)]},j)}):jsx("span",{className:"card-detail-empty",children:"No dependencies"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Created"}),jsx("span",{className:"card-detail-text",children:A.createdAt?new Date(A.createdAt).toLocaleString():"Unknown"})]})]}),u==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:v,onChange:L=>I(L.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:oe,disabled:!v.trim(),className:"card-detail-btn card-detail-btn-primary",children:"Add Comment"})]}),jsx("div",{className:"card-detail-comments-list",children:n.length>0?n.map(L=>{let j=s.find(J=>J.id===L.authorId);return jsxs("div",{className:"card-detail-comment",children:[jsxs("div",{className:"card-detail-comment-header",children:[jsxs("div",{className:"card-detail-comment-author",children:[j&&jsx("div",{className:"card-detail-user-avatar",style:{background:j.color},children:j.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:j?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(L.createdAt).toLocaleString()})]})]}),l&&jsx("button",{onClick:()=>l(L.id),className:"card-detail-comment-delete",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]})})]}),jsx("p",{className:"card-detail-comment-content",children:L.content})]},L.id)}):jsxs("div",{className:"card-detail-empty-state",children:[jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("p",{children:"No comments yet"}),jsx("span",{children:"Be the first to comment"})]})})]}),u==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(L=>{let j=s.find(J=>J.id===L.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[L.type.includes("CREATED")&&"\u2795",L.type.includes("UPDATED")&&"\u270F\uFE0F",L.type.includes("MOVED")&&"\u27A1\uFE0F",L.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",L.type.includes("COMMENT")&&"\u{1F4AC}",L.type.includes("ASSIGNED")&&"\u{1F464}",L.type.includes("PRIORITY")&&"\u{1F3AF}",L.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",L.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:j?.name||"Unknown"})," ",L.type.replace(/_/g," ").toLowerCase(),L.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:L.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(L.timestamp).toLocaleString()})]})]},L.id)})}):jsxs("div",{className:"card-detail-empty-state",children:[jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})}),jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})}),u==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx(kr,{cardId:e.id,attachments:i,onUpload:f?L=>f(e.id,L):void 0,onDelete:y,currentUserId:b,maxSizeMB:10,maxFiles:20})}),u==="ai"&&jsxs("div",{className:"card-detail-ai",children:[jsxs("div",{className:"card-detail-ai-actions",children:[jsx("h3",{className:"card-detail-ai-heading",children:"AI-Powered Suggestions"}),jsxs("button",{onClick:ye,disabled:F||!k,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Suggest Best Assignee"]}),jsxs("button",{onClick:fe,disabled:F||!C,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),jsx("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),jsx("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),jsx("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),jsx("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]}),"Generate Subtasks"]}),jsxs("button",{onClick:Re,disabled:F||!h,className:"card-detail-ai-btn",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:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Estimate Effort"]})]}),H.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),H.assignees.map((L,j)=>{let J=s.find(U=>U.id===L.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[J&&jsx("div",{className:"card-detail-user-avatar",style:{background:J.color},children:J.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:J?.name}),jsx("div",{className:"card-detail-ai-suggestion-reason",children:L.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(L.confidence*100).toFixed(0),"%"]})]})]},j)})]}),H.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),H.subtasks.map((L,j)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:L.title}),L.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:L.description}),L.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",L.estimatedTime,"h"]})]},j))]}),H.effort&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Effort Estimate"}),jsxs("div",{className:"card-detail-ai-effort",children:[jsxs("div",{className:"card-detail-ai-effort-hours",children:[H.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(H.effort.confidence*100).toFixed(0),"%"]})]})]}),g.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),g.map(L=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${L.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:L.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:L.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:L.description}),L.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",L.suggestedAction]})]},L.id))]}),!H.assignees&&!H.subtasks&&!H.effort&&g.length===0&&jsxs("div",{className:"card-detail-empty-state",children:[jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("p",{children:"AI Suggestions"}),jsx("span",{children:"Click a button above to get AI-powered insights"})]})]})]})]})})})}function Jo({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:n=""}){let[c,g]=useState({top:0,left:0}),i=useRef(null),p=useCallback(()=>{if(!e.current)return {top:0,left:0};let l=e.current.getBoundingClientRect(),f=window.innerHeight,y=window.innerWidth,k=4,C=l.left;C+o>y-10&&(C=y-o-10),C<10&&(C=10);let h=f-l.bottom,b=l.top,u;return h>=s+k?u=l.bottom+k:b>=s+k?u=l.top-s-k:h>=b?u=l.bottom+k:u=Math.max(10,l.top-s-k),{top:u,left:C}},[e,o,s]);return useEffect(()=>{t&&g(p());},[t,p]),useEffect(()=>{if(!t)return;let l=y=>{let k=y.target;i.current&&!i.current.contains(k)&&e.current&&!e.current.contains(k)&&a();},f=setTimeout(()=>{document.addEventListener("mousedown",l);},0);return ()=>{clearTimeout(f),document.removeEventListener("mousedown",l);}},[t,a,e]),useEffect(()=>{if(!t)return;let l=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),a());};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t,a]),t?jsx(ft,{children:jsx("div",{ref:i,className:`smart-popover ${n}`,style:{position:"fixed",top:`${c.top}px`,left:`${c.left}px`,width:`${o}px`,maxHeight:"calc(100vh - 40px)",overflowY:"auto",zIndex:99999,padding:"6px",background:"var(--modal-v2-bg, #1f1f1f)",border:"1px solid var(--modal-v2-border, rgba(255, 255, 255, 0.15))",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",animation:"popoverSlideIn 100ms ease-out"},children:r})}):null}var at={dark:{bgPrimary:"#1A1D21",bgSecondary:"#22262D",bgGrid:"#1E2126",bgWeekend:"rgba(59, 130, 246, 0.03)",border:"#334155",borderLight:"#2D3139",textPrimary:"#FFFFFF",textSecondary:"#CBD5E1",textTertiary:"#64748B",accent:"#3B82F6",accentHover:"#60A5FA",accentLight:"rgba(59, 130, 246, 0.12)",taskBarPrimary:"#3B82F6",taskBarProgress:"#2563EB",taskBarHandle:"#FFFFFF",dependency:"#9CA3AF",dependencyHover:"#6B7280",criticalPath:"#EF4444",criticalPathLight:"rgba(239, 68, 68, 0.12)",today:"#D21E24",todayLight:"rgba(210, 30, 36, 0.12)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.1)",statusTodo:"#64748B",statusInProgress:"#3B82F6",statusCompleted:"#10B981",hoverBg:"rgba(255, 255, 255, 0.06)",focusRing:"#3B82F6"},light:{bgPrimary:"#FFFFFF",bgSecondary:"#F8FAFC",bgGrid:"#F1F5F9",bgWeekend:"rgba(37, 99, 235, 0.03)",border:"#CBD5E1",borderLight:"#E2E8F0",textPrimary:"#0F172A",textSecondary:"#334155",textTertiary:"#64748B",accent:"#2563EB",accentHover:"#1D4ED8",accentLight:"rgba(37, 99, 235, 0.08)",taskBarPrimary:"#2563EB",taskBarProgress:"#1E40AF",taskBarHandle:"#FFFFFF",dependency:"#6B7280",dependencyHover:"#4B5563",criticalPath:"#DC2626",criticalPathLight:"rgba(220, 38, 38, 0.1)",today:"#D21E24",todayLight:"rgba(210, 30, 36, 0.1)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.08)",statusTodo:"#64748B",statusInProgress:"#2563EB",statusCompleted:"#059669",hoverBg:"rgba(0, 0, 0, 0.04)",focusRing:"#2563EB"},neutral:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgGrid:"#EFEDEC",bgWeekend:"rgba(41, 37, 36, 0.02)",border:"#D6D3D1",borderLight:"#E7E5E4",textPrimary:"#0C0A09",textSecondary:"#44403C",textTertiary:"#78716C",accent:"#292524",accentHover:"#44403C",accentLight:"rgba(41, 37, 36, 0.08)",taskBarPrimary:"#292524",taskBarProgress:"#1C1917",taskBarHandle:"#FFFFFF",dependency:"#78716C",dependencyHover:"#57534E",criticalPath:"#44403C",criticalPathLight:"rgba(68, 64, 60, 0.08)",today:"#1C1917",todayLight:"rgba(28, 25, 23, 0.06)",milestone:"#57534E",milestoneLight:"rgba(87, 83, 78, 0.08)",statusTodo:"#78716C",statusInProgress:"#292524",statusCompleted:"#15803D",hoverBg:"rgba(0, 0, 0, 0.035)",focusRing:"#292524"}};var Pf=["LOW","MEDIUM","HIGH","URGENT"],Mf=["todo","in-progress","review","done"];function mi({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],onAddComment:g,onDeleteComment:i,currentUser:p,onAIGenerateDescription:l,onAICreateSubtasks:f,onAIFindSimilar:y,availableColumns:k=[],availableLabels:C=[],availableTags:h=[],onCreateTag:b,onUploadCoverImage:u,unsplashAccessKey:x,theme:m,onSubtasksChange:N,attachments:w=[],onUploadAttachments:B,onDeleteAttachment:v}){let I=wo(),F=m||I?.themeName||"dark",[T,H]=useState(e),[O,K]=useState(false),[ae,ne]=useState(e?.subtasks||[]),[oe,ye]=useState(false),[fe,Re]=useState(""),[A,R]=useState(""),[L,j]=useState("all"),[J,U]=useState(false),[ge,le]=useState(false),[Fe,qe]=useState(false),[et,de]=useState(false),[Ke,dt]=useState(false),[vt,kt]=useState(false),$=useRef(null),me=useRef(null),Le=useRef(null),Se=useRef(null),Ye=useRef(null),Je=useRef(null),Pt=useRef(null),Oe=useRef(null),Z=useRef(null),xe=useRef(null),ze=useRef(null),Be=useRef(null);useEffect(()=>{e&&!T?(H({...e}),ne(e.subtasks||[])):e&&T&&e.id!==T.id&&(H({...e}),ne(e.subtasks||[]));},[e,T]),useEffect(()=>{let z=se=>{let We=se.target;Se.current&&!Se.current.contains(We)&&U(false),Ye.current&&!Ye.current.contains(We)&&le(false),Je.current&&!Je.current.contains(We)&&qe(false),Pt.current&&!Pt.current.contains(We)&&de(false);};if(J||ge||Fe||et)return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[J,ge,Fe,et]),useEffect(()=>{if(!t)return;let z=se=>{let We=se.target,Nt=We.tagName==="INPUT"||We.tagName==="TEXTAREA"||We.isContentEditable;if(se.key==="Escape"){se.preventDefault(),J||ge||Fe||et||Ke||vt?(U(false),le(false),qe(false),de(false),dt(false),kt(false)):Nt||a();return}if(Nt&&se.key!=="Escape")return;let mt=se.metaKey||se.ctrlKey;switch(se.key.toLowerCase()){case "s":se.preventDefault(),U(true);break;case "a":se.preventDefault(),qe(true);break;case "p":se.preventDefault(),le(true);break;case "l":se.preventDefault(),de(true);break;case "d":mt||(se.preventDefault(),dt(true),setTimeout(()=>Oe.current?.focus(),0));break;case "e":mt||(se.preventDefault(),kt(true));break;case "i":se.preventDefault(),K(true),setTimeout(()=>me.current?.focus(),0);break;case "t":se.preventDefault(),ye(true);break;case "c":se.preventDefault(),Le.current?.focus();break}};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[t,a,J,ge,Fe,et,Ke,vt]);let st=useCallback(z=>{let se=z.currentTarget.textContent?.trim()||"";if(T&&se!==T.title){let We={...T,title:se};H(We),r?.(T.id,{title:se});}},[T,r]),nt=useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),z.currentTarget.blur()),z.key==="Escape"&&(z.preventDefault(),z.currentTarget.textContent=T?.title||"",z.currentTarget.blur());},[T]),Ve=useCallback(()=>{T&&e&&T.description!==e.description&&r?.(T.id,{description:T.description}),K(false);},[T,e,r]),Vt=useCallback(z=>{if(T){let se={...T,columnId:z};H(se),r?.(T.id,{columnId:z}),U(false);}},[T,r]),Bt=useCallback(z=>{if(T){let se={...T,priority:z};H(se),r?.(T.id,{priority:z}),le(false);}},[T,r]),Ze=useCallback(z=>{if(T){let se=T.assignedUserIds||[],We=se.includes(z)?se.filter(mt=>mt!==z):[...se,z],Nt={...T,assignedUserIds:We};H(Nt),r?.(T.id,{assignedUserIds:We});}},[T,r]),te=useCallback(z=>{if(T){let se=T.labels||[],We=se.includes(z)?se.filter(mt=>mt!==z):[...se,z],Nt={...T,labels:We};H(Nt),r?.(T.id,{labels:We});}},[T,r]),S=useCallback(z=>{if(T){let se={...T,tags:z};H(se),r?.(T.id,{tags:z});}},[T,r]),Ce=useCallback(z=>{if(T){let se=z.target.value,We={...T,endDate:se};H(We),r?.(T.id,{endDate:se}),dt(false);}},[T,r]),X=useCallback(z=>{if(T){let se={...T,estimatedTime:parseFloat(z)||0};H(se),r?.(T.id,{estimatedTime:parseFloat(z)||0});}},[T,r]),we=useCallback(()=>{if(fe.trim()&&T){let z={id:`subtask-${Date.now()}`,title:fe.trim(),completed:false,createdAt:new Date},se=[...ae,z];ne(se),Re(""),ye(false),N?.(T.id,se);}},[fe,ae,T,N]),ke=useCallback(z=>{let se=ae.map(We=>We.id===z?{...We,completed:!We.completed,updatedAt:new Date}:We);ne(se),T&&N?.(T.id,se);},[ae,T,N]),He=useCallback(z=>{let se=ae.filter(We=>We.id!==z);ne(se),T&&N?.(T.id,se);},[ae,T,N]),$e=useCallback(()=>{A.trim()&&T&&g&&(g(T.id,A.trim()),R(""));},[A,T,g]),tt=useCallback(z=>{(z.metaKey||z.ctrlKey)&&z.key==="Enter"&&(z.preventDefault(),$e());},[$e]),_=z=>jsx(Df,{remarkPlugins:[Sf],rehypePlugins:[Ef],components:{a:({node:se,...We})=>jsx("a",{...We,target:"_blank",rel:"noopener noreferrer"})},children:z}),Y=c.filter(z=>L==="comments"?z.type.includes("COMMENT"):L==="history"?!z.type.includes("COMMENT"):true);if(!t||!e)return null;let be=T||e,je=s.filter(z=>be.assignedUserIds?.includes(z.id)),Ie=ae.filter(z=>z.completed).length;return jsx(ft,{children:jsx("div",{className:"modal-v2-backdrop",onClick:a,style:{position:"fixed",inset:"0",zIndex:9999,background:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxs("div",{className:"modal-v2-container",onClick:z=>z.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":F,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:$,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:st,onKeyDown:nt,children:be.title}),jsxs("p",{className:"modal-v2-ai-prompt",children:[jsx("span",{className:"modal-v2-ai-icon",children:"\u2728"}),"Ask AI to write a description, create subtasks, or find similar tasks"]}),jsx("button",{className:"modal-v2-close",onClick:a,"aria-label":"Close",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("section",{className:"modal-v2-metadata",children:[jsxs("div",{className:"modal-v2-field-wrapper",ref:Se,children:[jsxs("button",{ref:Z,className:"modal-v2-field",onClick:()=>U(!J),children:[jsxs("div",{className:"modal-v2-field-label",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:"10"}),jsx("path",{d:"M12 6v6l4 2"})]}),jsx("span",{children:"Status"}),jsx("kbd",{className:"modal-v2-shortcut",children:"S"})]}),jsx("div",{className:"modal-v2-field-value",children:be.columnId||"No status"})]}),jsx(Jo,{triggerRef:Z,isOpen:J,onClose:()=>U(false),width:250,estimatedHeight:200,children:(k.length>0?k:Mf.map(z=>({id:z,title:z}))).map(z=>jsx("button",{className:`modal-v2-popover-item ${be.columnId===z.id?"active":""}`,onClick:()=>Vt(z.id),children:z.title},z.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Je,children:[jsxs("button",{ref:xe,className:"modal-v2-field",onClick:()=>qe(!Fe),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),jsx("span",{children:"Assignees"}),jsx("kbd",{className:"modal-v2-shortcut",children:"A"})]}),jsx("div",{className:"modal-v2-field-value",children:je.length>0?jsx("div",{className:"modal-v2-avatars",children:je.map(z=>jsx("div",{className:"modal-v2-avatar",style:{background:z.color},title:z.name,children:z.initials},z.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Jo,{triggerRef:xe,isOpen:Fe,onClose:()=>qe(false),width:280,estimatedHeight:300,children:s.map(z=>jsxs("button",{className:`modal-v2-popover-item ${be.assignedUserIds?.includes(z.id)?"active":""}`,onClick:()=>Ze(z.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:z.color},children:z.initials}),z.name,be.assignedUserIds?.includes(z.id)&&jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{marginLeft:"auto"},children:jsx("polyline",{points:"20 6 9 17 4 12"})})]},z.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ye,children:[jsxs("button",{ref:ze,className:"modal-v2-field",onClick:()=>le(!ge),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{children:"Priority"}),jsx("kbd",{className:"modal-v2-shortcut",children:"P"})]}),jsx("div",{className:"modal-v2-field-value",children:be.priority||"None"})]}),jsxs(Jo,{triggerRef:ze,isOpen:ge,onClose:()=>le(false),width:180,estimatedHeight:220,children:[Pf.map(z=>jsx("button",{className:`modal-v2-popover-item priority-${z.toLowerCase()} ${be.priority===z?"active":""}`,onClick:()=>Bt(z),children:z},z)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>Bt(""),children:"None"})]})]}),h.length>0||b?jsx("div",{className:"modal-v2-field-wrapper",children:jsxs("div",{className:"modal-v2-field",style:{cursor:"default"},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Etiquetas"})]}),jsx("div",{className:"modal-v2-field-value",children:jsx(hr,{selectedTags:be.tags||[],availableTags:h,onChange:S,onCreateTag:b,theme:at[F]||at.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:Pt,children:[jsxs("button",{ref:Be,className:"modal-v2-field",onClick:()=>de(!et),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Labels"}),jsx("kbd",{className:"modal-v2-shortcut",children:"L"})]}),jsx("div",{className:"modal-v2-field-value",children:be.labels&&be.labels.length>0?jsx("span",{children:be.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(Jo,{triggerRef:Be,isOpen:et,onClose:()=>de(false),width:220,estimatedHeight:200,children:(C.length>0?C:["Bug","Feature","Enhancement","Documentation"]).map(z=>jsxs("button",{className:`modal-v2-popover-item ${be.labels?.includes(z)?"active":""}`,onClick:()=>te(z),children:[z,be.labels?.includes(z)&&jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{marginLeft:"auto"},children:jsx("polyline",{points:"20 6 9 17 4 12"})})]},z))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{dt(!Ke),setTimeout(()=>Oe.current?.showPicker?.(),0);},children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),jsx("span",{children:"Due Date"}),jsx("kbd",{className:"modal-v2-shortcut",children:"D"})]}),jsx("div",{className:"modal-v2-field-value",children:be.endDate?new Date(be.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Oe,type:"date",value:typeof be.endDate=="string"?be.endDate.split("T")[0]:be.endDate?(()=>{let z=new Date(be.endDate),se=z.getUTCFullYear(),We=String(z.getUTCMonth()+1).padStart(2,"0"),Nt=String(z.getUTCDate()).padStart(2,"0");return `${se}-${We}-${Nt}`})():"",onChange:Ce,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>kt(!vt),children:[jsxs("div",{className:"modal-v2-field-label",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:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx("span",{children:"Estimated Time"}),jsx("kbd",{className:"modal-v2-shortcut",children:"E"})]}),jsx("div",{className:"modal-v2-field-value",children:be.estimatedTime?`${be.estimatedTime}h`:"Not set"})]}),vt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:be.estimatedTime||"",onChange:z=>X(z.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>kt(false)})})]})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-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"})]}),jsx("h2",{children:"Description"})]}),O?jsx("textarea",{className:"modal-v2-textarea",value:be.description||"",onChange:z=>{if(T){let se={...T,description:z.target.value};H(se);}},onBlur:Ve,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>K(true),children:be.description?jsx("div",{className:"modal-v2-markdown",children:_(be.description)}):jsxs("p",{className:"modal-v2-placeholder",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Add description..."]})})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M9 11l3 3L22 4"}),jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"})]}),jsx("h2",{children:"Subtasks"}),ae.length>0&&jsxs("span",{className:"modal-v2-count",children:[Ie,"/",ae.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>ye(true),children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add"]})]}),jsxs("div",{className:"modal-v2-subtasks",children:[ae.map(z=>jsxs("div",{className:`modal-v2-subtask ${z.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>ke(z.id),children:z.completed?jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9 12l2 2 4-4",stroke:"white",strokeWidth:"2",fill:"none"})]}):jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("circle",{cx:"12",cy:"12",r:"10"})})}),jsx("span",{className:"modal-v2-subtask-title",children:z.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>He(z.id),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})]})})]},z.id)),oe&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:fe,onChange:z=>Re(z.target.value),onKeyDown:z=>{z.key==="Enter"&&we(),z.key==="Escape"&&(ye(false),Re(""));},onBlur:we,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(B||w.length>0)&&jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),jsx("h2",{children:"Attachments"}),w.length>0&&jsx("span",{className:"modal-v2-count",children:w.length})]}),jsx(kr,{cardId:be.id,attachments:w,onUpload:B?z=>B(be.id,z):void 0,onDelete:v,maxSizeMB:10,maxFiles:20})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("h2",{children:"Activity"}),jsxs("div",{className:"modal-v2-filters",children:[jsx("button",{className:`modal-v2-filter ${L==="all"?"active":""}`,onClick:()=>j("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${L==="comments"?"active":""}`,onClick:()=>j("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${L==="history"?"active":""}`,onClick:()=>j("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[p&&jsx("div",{className:"modal-v2-avatar",style:{background:p.color},children:p.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:Le,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:A,onChange:z=>R(z.target.value),onKeyDown:tt,rows:1}),jsxs("div",{className:"modal-v2-comment-toolbar",children:[jsxs("div",{className:"modal-v2-toolbar-left",children:[jsx("button",{className:"modal-v2-toolbar-button",title:"Attach file",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})})}),jsx("button",{className:"modal-v2-toolbar-button",title:"Mention user",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:"4"}),jsx("path",{d:"M16 8v5a3 3 0 006 0v-1a10 10 0 10-3.92 7.94"})]})}),jsx("button",{className:"modal-v2-toolbar-button",title:"Add emoji",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:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",y1:"9",x2:"9.01",y2:"9"}),jsx("line",{x1:"15",y1:"9",x2:"15.01",y2:"9"})]})})]}),jsx("button",{className:"modal-v2-send-button",onClick:$e,disabled:!A.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[Y.map(z=>{let se=s.find(Nt=>Nt.id===z.userId);if(z.type.includes("COMMENT")){let Nt=n.find(mt=>mt.id===z.metadata?.commentId);return Nt?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[se&&jsx("div",{className:"modal-v2-avatar",style:{background:se.color},children:se.initials}),jsxs("div",{className:"modal-v2-activity-content",children:[jsxs("div",{className:"modal-v2-activity-header",children:[jsx("span",{className:"modal-v2-activity-user",children:se?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(z.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:Nt.content})]})]},z.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[z.type.includes("CREATED")&&"\u2795",z.type.includes("UPDATED")&&"\u270F\uFE0F",z.type.includes("MOVED")&&"\u27A1\uFE0F",z.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",z.type.includes("ASSIGNED")&&"\u{1F464}",z.type.includes("PRIORITY")&&"\u{1F3AF}",z.type.includes("LABEL")&&"\u{1F3F7}\uFE0F"]}),jsxs("div",{className:"modal-v2-activity-content",children:[jsxs("div",{className:"modal-v2-history-text",children:[jsx("span",{className:"modal-v2-activity-user",children:se?.name||"Unknown"})," ",z.type.replace(/_/g," ").toLowerCase(),z.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:z.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(z.timestamp).toLocaleString()})]})]},z.id)}),Y.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function Uf({active:e,payload:t}){return !e||!t||!t.length?null:jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:t[0].payload.period}),t.map((a,r)=>jsxs("p",{className:"chart-tooltip-value",style:{color:a.color},children:[a.name,": ",jsx("strong",{children:a.value})," cards"]},r))]})}function ui({data:e,title:t="Team Velocity",height:a=300,showAverage:r=true,showPlanned:o=true}){let s=e.map(n=>({...n,average:n.average??e.reduce((c,g)=>c+g.completed,0)/e.length}));return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(LineChart,{data:s,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"period",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Uf,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Line,{type:"monotone",dataKey:"completed",stroke:"#10B981",strokeWidth:3,name:"Completed",dot:{fill:"#10B981",r:5},activeDot:{r:7}}),o&&jsx(Line,{type:"monotone",dataKey:"planned",stroke:"#3B82F6",strokeWidth:2,strokeDasharray:"5 5",name:"Planned",dot:{fill:"#3B82F6",r:4}}),r&&jsx(Line,{type:"monotone",dataKey:"average",stroke:"#F59E0B",strokeWidth:2,strokeDasharray:"3 3",name:"Average",dot:false})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Completed"}),jsx("span",{className:"chart-stat-value",style:{color:"#10B981"},children:e.reduce((n,c)=>n+c.completed,0)})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Average Velocity"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:(e.reduce((n,c)=>n+c.completed,0)/e.length).toFixed(1)})]}),o&&e.some(n=>n.planned)&&jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Planned"}),jsx("span",{className:"chart-stat-value",style:{color:"#3B82F6"},children:e.reduce((n,c)=>n+(c.planned||0),0)})]})]})]})}function Yf({active:e,payload:t}){return !e||!t||!t.length?null:jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:t[0].payload.day}),t.map((a,r)=>jsxs("p",{className:"chart-tooltip-value",style:{color:a.color},children:[a.name,": ",jsx("strong",{children:a.value})," tasks"]},r))]})}function gi({data:e,title:t="Sprint Burndown",height:a=300,totalTasks:r,useArea:o=false}){let s=r??(e[0]?.ideal||e[0]?.remaining||0),n=e[e.length-1]?.remaining||0,c=e[e.length-1]?.ideal||0,g=s>0?(s-n)/s*100:0,i=n<=c;return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:a,children:jsxs(o?AreaChart:LineChart,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"day",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Yf,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),o?jsxs(Fragment,{children:[jsx(Area,{type:"monotone",dataKey:"ideal",stroke:"#F59E0B",fill:"rgba(245, 158, 11, 0.2)",strokeWidth:2,strokeDasharray:"5 5",name:"Ideal"}),jsx(Area,{type:"monotone",dataKey:"remaining",stroke:i?"#10B981":"#EF4444",fill:i?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",strokeWidth:3,name:"Remaining"})]}):jsxs(Fragment,{children:[jsx(Line,{type:"linear",dataKey:"ideal",stroke:"#F59E0B",strokeWidth:2,strokeDasharray:"5 5",name:"Ideal",dot:{fill:"#F59E0B",r:4}}),jsx(Line,{type:"monotone",dataKey:"remaining",stroke:i?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:i?"#10B981":"#EF4444",r:5},activeDot:{r:7}})]})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Progress"}),jsxs("span",{className:"chart-stat-value",style:{color:g>=50?"#10B981":"#F59E0B"},children:[g.toFixed(0),"%"]})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Remaining"}),jsx("span",{className:"chart-stat-value",style:{color:i?"#10B981":"#EF4444"},children:n})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Status"}),jsx("span",{className:"chart-stat-badge",style:{background:i?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:i?"#10B981":"#EF4444"},children:i?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var r0={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},wc=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function o0({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let n=r+(o-r)*.5,c=e+n*Math.cos(-a*(Math.PI/180)),g=t+n*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:c,y:g,fill:"white",textAnchor:c>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Cc({active:e,payload:t}){if(!e||!t||!t.length)return null;let a=t[0].payload,r=t[0].payload.totalValue||0,o=r>0?(a.value/r*100).toFixed(1):"0";return jsxs("div",{className:"chart-tooltip",children:[jsx("p",{className:"chart-tooltip-label",children:a.name}),jsxs("p",{className:"chart-tooltip-value",style:{color:a.color||t[0].color},children:["Count: ",jsx("strong",{children:a.value})]}),jsxs("p",{className:"chart-tooltip-value",style:{color:"rgba(255, 255, 255, 0.7)"},children:["Percentage: ",jsxs("strong",{children:[o,"%"]})]})]})}function fi({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((g,i)=>g+i.value,0),n=e.map(g=>({...g,totalValue:s,color:g.color||r0[g.name]||wc[e.indexOf(g)%wc.length]})),c=n.map(g=>g.color);return jsxs("div",{className:"chart-container",children:[t&&jsx("h3",{className:"chart-title",children:t}),jsx(ResponsiveContainer,{width:"100%",height:r,children:a==="pie"?jsxs(PieChart,{children:[jsx(Pie,{data:n,cx:"50%",cy:"50%",labelLine:false,label:o?o0:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:n.map((g,i)=>jsx(Cell,{fill:c[i]},`cell-${i}`))}),jsx(Tooltip,{content:jsx(Cc,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(g,i)=>{let p=i.payload,l=s>0?(p.value/s*100).toFixed(0):"0";return `${g} (${p.value} - ${l}%)`}})]}):jsxs(BarChart$1,{data:n,margin:{top:5,right:30,left:20,bottom:5},children:[jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.1)"}),jsx(XAxis,{dataKey:"name",stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(YAxis,{stroke:"rgba(255, 255, 255, 0.5)",style:{fontSize:"12px"}}),jsx(Tooltip,{content:jsx(Cc,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Bar,{dataKey:"value",name:"Count",radius:[8,8,0,0],children:n.map((g,i)=>jsx(Cell,{fill:c[i]},`cell-${i}`))})]})}),jsxs("div",{className:"chart-stats",children:[jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Total Cards"}),jsx("span",{className:"chart-stat-value",style:{color:"#3B82F6"},children:s})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Categories"}),jsx("span",{className:"chart-stat-value",style:{color:"#10B981"},children:e.length})]}),e.length>0&&jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Largest Category"}),jsx("span",{className:"chart-stat-value",style:{color:"#F59E0B"},children:e.reduce((g,i)=>i.value>g.value?i:g).name})]})]})]})}var On=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[n,c]=useState(false),[g,i]=useState(false),[p,l]=useState(false),[f,y]=useState(false);if(e.length===0)return null;let k=e.map(m=>m.id),C=m=>{r.onBulkUpdate?.(k,{priority:m}),c(false);},h=m=>{r.onBulkMove?.(k,m),i(false),a();},b=m=>{r.onBulkUpdate?.(k,{assignedUserIds:m}),l(false);},u=m=>{let N=new Set;e.forEach(B=>{B.labels?.forEach(v=>N.add(v));});let w=Array.from(new Set([...N,...m]));r.onBulkUpdate?.(k,{labels:w}),y(false);},x=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(k),a());};return jsx("div",{className:"asakaa-bulk-toolbar",children:jsxs("div",{className:"asakaa-bulk-toolbar-content",children:[jsxs("div",{className:"asakaa-bulk-toolbar-count",children:[e.length," card",e.length!==1?"s":""," selected"]}),jsxs("div",{className:"asakaa-bulk-toolbar-actions",children:[jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>c(!n),title:"Update priority",children:jsx("span",{className:"text-sm",children:"Priority"})}),n&&jsx("div",{className:"asakaa-bulk-menu",children:["LOW","MEDIUM","HIGH","URGENT"].map(m=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>C(m),children:[jsx("span",{className:d("asakaa-priority-dot",m==="LOW"&&"bg-asakaa-priority-low",m==="MEDIUM"&&"bg-asakaa-priority-medium",m==="HIGH"&&"bg-asakaa-priority-high",m==="URGENT"&&"bg-asakaa-priority-urgent")}),m]},m))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>i(!g),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),g&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(m=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>h(m.id),children:m.title},m.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>l(!p),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(m=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>b([m.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:m.color},children:m.initials}),m.name]},m.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>y(!f),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),f&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(m=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>u([m]),children:m},m))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:x,title:"Delete selected cards",children:jsx("span",{className:"text-sm",children:"Delete"})}),jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:a,title:"Clear selection",children:jsx("span",{className:"text-sm",children:"\u2715"})})]})]})})});On.displayName="BulkOperationsToolbar";function d0(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,n,c,g,i;switch(t){case "assignee":let p=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);p.length>0?p.forEach(y=>{let k=a?.find(C=>C.id===y);n=`assignee-${y}`,c=k?.name||`User ${y}`,g=k?.color,i=k?.avatar,r.has(n)||r.set(n,{id:n,title:c,groupValue:y,cardIds:[],color:g,icon:i}),r.get(n).cardIds.push(o.id);}):(n="assignee-unassigned",c="Unassigned",g="#6b7280",i="\u{1F464}",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:g,icon:i}),r.get(n).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",n=`priority-${s}`;let f={URGENT:{title:"\u{1F534} Urgent",color:"#ef4444"},HIGH:{title:"\u{1F7E0} High",color:"#f97316"},MEDIUM:{title:"\u{1F7E1} Medium",color:"#eab308"},LOW:{title:"\u{1F7E2} Low",color:"#22c55e"},NONE:{title:"\u26AA No Priority",color:"#6b7280"}}[s];c=f.title,g=f.color,r.has(n)||r.set(n,{id:n,title:c,groupValue:s,cardIds:[],color:g}),r.get(n).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(y=>{n=`label-${y}`,c=y,g="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:y,cardIds:[],color:g}),r.get(n).cardIds.push(o.id);}):(n="label-none",c="No Labels",g="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:g}),r.get(n).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function bi({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,n]=useState(new Set),c=useMemo(()=>d0(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),g=useCallback(i=>{n(p=>{let l=new Set(p);return l.has(i)?l.delete(i):l.add(i),l});},[]);return t.groupBy==="none"||c.length===0?jsx(zr,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:d("asakaa-swimlane-view",o),children:[c.map(i=>{let p=s.has(i.id),l=e.cards.filter(y=>i.cardIds.includes(y.id)),f={...e,cards:l};return jsxs("div",{className:"asakaa-swimlane mb-6 rounded-lg border border-white/10 overflow-hidden",children:[jsxs("div",{className:"asakaa-swimlane-header px-4 py-3 bg-white/5 backdrop-blur-sm flex items-center justify-between cursor-pointer hover:bg-white/10 transition-colors",onClick:()=>t.collapsible&&g(i.id),style:{borderLeft:i.color?`4px solid ${i.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[i.icon&&jsx("span",{className:"text-2xl leading-none",children:i.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:i.color},children:i.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",i.cardIds.length," ",i.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":p?"Expand lane":"Collapse lane",children:p?"\u25B6":"\u25BC"})]}),!p&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(zr,{board:f,callbacks:r,availableUsers:a})})]},i.id)}),c.length===0&&jsxs("div",{className:"text-center py-12 text-white/50",children:[jsx("p",{className:"text-lg",children:"No cards to display"}),jsx("p",{className:"text-sm mt-2",children:"Cards will appear here when they match the grouping criteria"})]})]})}var hi=[{value:"none",label:"No Grouping",icon:"\u{1F4CB}",description:"Standard Kanban board view"},{value:"assignee",label:"By Assignee",icon:"\u{1F465}",description:"Group cards by assigned user"},{value:"priority",label:"By Priority",icon:"\u{1F3AF}",description:"Group cards by priority level"},{value:"label",label:"By Label",icon:"\u{1F3F7}\uFE0F",description:"Group cards by label/tag"}];function yi({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null),c=hi.find(i=>i.value===e)||hi[0];useEffect(()=>{function i(p){s.current&&!s.current.contains(p.target)&&n.current&&!n.current.contains(p.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let g=i=>{t(i),o(false);};return jsxs("div",{className:d("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/10 hover:bg-white/15 border border-white/20 transition-all text-sm font-medium text-white/90",children:[jsx("span",{className:"text-base leading-none",children:c.icon}),jsx("span",{children:c.label}),jsx("svg",{className:d("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-[280px] rounded-lg bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl border border-white/20 shadow-2xl z-50 overflow-hidden",children:[jsx("div",{className:"px-3 py-2 border-b border-white/10",children:jsx("span",{className:"text-[10px] font-bold text-white/70 uppercase tracking-wider",children:"Group By"})}),jsx("div",{className:"py-1",children:hi.map(i=>jsxs("button",{onClick:()=>g(i.value),className:d("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===i.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:i.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"font-semibold text-sm text-white",children:i.label}),e===i.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:i.description})]})]},i.value))})]})]})}var Zo=[{keys:"ArrowUp",action:"navigate_up",description:"Navigate to card above"},{keys:"ArrowDown",action:"navigate_down",description:"Navigate to card below"},{keys:"ArrowLeft",action:"navigate_left",description:"Navigate to previous column"},{keys:"ArrowRight",action:"navigate_right",description:"Navigate to next column"},{keys:"Enter",action:"open_card",description:"Open selected card"},{keys:"Escape",action:"close_modal",description:"Close modal or dialog"},{keys:"Delete",action:"delete_card",description:"Delete selected card",modifiers:{shift:true}},{keys:"n",action:"new_card",description:"Create new card",modifiers:{ctrl:true}},{keys:"k",action:"search",description:"Open search/command palette",modifiers:{ctrl:true}},{keys:"s",action:"save",description:"Save changes",modifiers:{ctrl:true}},{keys:"z",action:"undo",description:"Undo last action",modifiers:{ctrl:true}},{keys:"y",action:"redo",description:"Redo last undone action",modifiers:{ctrl:true}},{keys:"a",action:"select_all",description:"Select all cards",modifiers:{ctrl:true}},{keys:"Escape",action:"deselect_all",description:"Deselect all cards"},{keys:"?",action:"show_shortcuts",description:"Show keyboard shortcuts help",modifiers:{shift:true}}];function p0(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(i=>e.key===i||e.code===i))return false;let o=t.modifiers||{},s=o.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,n=o.shift?e.shiftKey:!e.shiftKey,c=o.alt?e.altKey:!e.altKey,g=o.meta?e.metaKey:true;return s&&n&&c&&g}function Ec(e={}){let{shortcuts:t=Zo,enabled:a=true,preventDefault:r=true}=e,o=useRef(t),s=useRef(a);useEffect(()=>{o.current=t,s.current=a;},[t,a]);let n=useCallback(g=>{o.current=[...o.current,g];},[]),c=useCallback(g=>{o.current=o.current.filter(i=>i.action!==g);},[]);return useEffect(()=>{function g(i){if(!s.current)return;let p=i.target;if(!((p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.isContentEditable)&&i.key!=="Escape"&&!i.ctrlKey&&!i.metaKey)){for(let l of o.current)if(p0(i,l)){r&&i.preventDefault();let f=new CustomEvent("keyboard-action",{detail:l.action,bubbles:true,cancelable:true});window.dispatchEvent(f);break}}}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[r]),{registerShortcut:n,unregisterShortcut:c,isEnabled:a}}function g0(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function f0(e){let t=[],a=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.modifiers?.ctrl&&t.push(a?"\u2318":"Ctrl"),e.modifiers?.shift&&t.push("Shift"),e.modifiers?.alt&&t.push(a?"\u2325":"Alt"),e.modifiers?.meta&&t.push("\u2318"),t.join(" + ")}function b0(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=f0(e),r=t?g0(t):"";return a?`${a} + ${r}`:r}function h0(e){let t={Navigation:[],Actions:[],Editing:[],Selection:[]};return e.forEach(a=>{a.action.includes("navigate")?t.Navigation?.push(a):a.action.includes("select")?t.Selection?.push(a):["undo","redo","save"].includes(a.action)?t.Editing?.push(a):t.Actions?.push(a);}),t}function vi({shortcuts:e=Zo,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function c(g){g.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,a]),!o||!t)return null;let n=h0(e);return jsxs("div",{className:d("fixed inset-0 z-[9999] flex items-center justify-center",r),children:[jsx("div",{className:"absolute inset-0 backdrop-blur-sm bg-black/40 dark:bg-black/60",onClick:a}),jsxs("div",{className:"relative backdrop-blur-xl rounded-2xl border shadow-2xl max-w-3xl w-full mx-4 max-h-[80vh] overflow-hidden bg-white dark:bg-gradient-to-br dark:from-gray-900/95 dark:to-gray-800/95 border-gray-200 dark:border-white/20",children:[jsxs("div",{className:"px-6 py-5 border-b flex items-center justify-between border-gray-200 dark:border-white/10",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold flex items-center gap-3 text-gray-900 dark:text-white",children:[jsx("span",{className:"text-3xl",children:"\u2328\uFE0F"}),"Keyboard Shortcuts"]}),jsx("p",{className:"text-sm mt-1 text-gray-500 dark:text-white/60",children:"Speed up your workflow with these shortcuts"})]}),jsx("button",{onClick:a,className:"transition-colors text-2xl leading-none p-2 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 dark:text-white/50 dark:hover:text-white dark:hover:bg-white/10","aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"px-6 py-6 overflow-y-auto max-h-[calc(80vh-120px)]",children:jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:Object.entries(n).map(([c,g])=>g.length===0?null:jsxs("div",{children:[jsxs("h3",{className:"text-lg font-semibold mb-4 flex items-center gap-2 text-gray-800 dark:text-white/90",children:[jsx("span",{className:"w-1 h-5 bg-blue-500 rounded-full"}),c]}),jsx("div",{className:"space-y-3",children:g.map(i=>jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-lg transition-colors bg-gray-50 hover:bg-gray-100 dark:bg-white/5 dark:hover:bg-white/10",children:[jsx("span",{className:"text-sm text-gray-700 dark:text-white/80",children:i.description}),jsx("kbd",{className:"px-3 py-1.5 border rounded-md text-xs font-mono shadow-sm whitespace-nowrap bg-white border-gray-300 text-gray-800 dark:bg-gradient-to-br dark:from-gray-700 dark:to-gray-800 dark:border-white/20 dark:text-white/90",children:b0(i)})]},i.action))})]},c))})}),jsx("div",{className:"px-6 py-4 border-t border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/5",children:jsxs("p",{className:"text-xs text-center text-gray-500 dark:text-white/50",children:["Press ",jsx("kbd",{className:"px-2 py-0.5 rounded bg-gray-200 text-gray-600 dark:bg-white/10 dark:text-white/70",children:"?"})," to toggle this help panel"]})})]})]})}var xi=[{id:"bug-report",name:"Bug Report",description:"Report a bug or issue",icon:"\u{1F41B}",category:"Development",template:{title:"[BUG] ",description:`**Steps to reproduce:**
|
|
72
72
|
1.
|
|
73
73
|
|
|
74
74
|
**Expected behavior:**
|
|
@@ -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 xi({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null);useEffect(()=>{function i(p){s.current&&!s.current.contains(p.target)&&n.current&&!n.current.contains(p.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let c=i=>{t(i),o(false);},g=e.reduce((i,p)=>{let l=p.category||"Other";return i[l]||(i[l]=[]),i[l].push(p),i},{});return jsxs("div",{className:d("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg border transition-all text-sm font-medium shadow-lg",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",i.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",i.currentTarget.style.borderColor="var(--theme-border-primary)";},title:"Create from template",children:[jsx("span",{className:"text-base leading-none",children:"\u{1F4CB}"}),jsx("span",{children:"Templates"}),jsx("svg",{className:d("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(g).map(([i,p])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:i})}),jsx("div",{children:p.map(l=>jsxs("button",{onClick:()=>c(l),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:l.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:l.name}),l.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:l.description})]})]},l.id))})]},i)),e.length===0&&jsx("div",{className:"px-4 py-8 text-center",style:{color:"var(--theme-text-tertiary)"},children:jsx("p",{className:"text-sm",children:"No templates available"})})]})]})}function wi({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,c]=useState("export"),[g,i]=useState("json"),[p,l]=useState(null),f=useRef(null);if(!t)return null;let y=async()=>{let C=o?.current||void 0,h=await pd(e,g,C);ud(h,g);},k=async C=>{let h=C.target.files?.[0];if(h){try{let b=await bd(h),u=h.name.endsWith(".json")?"json":"csv",x=fd(b,u);l(x),x.success&&r&&r(x,b);}catch(b){l({success:false,errors:[`Failed to read file: ${b instanceof Error?b.message:"Unknown error"}`]});}f.current&&(f.current.value="");}};return jsxs("div",{className:d("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:d("flex-1 px-6 py-4 font-semibold transition-colors",n==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:d("flex-1 px-6 py-4 font-semibold transition-colors",n==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[n==="export"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Select format"}),jsx("div",{className:"grid grid-cols-3 gap-3",children:["json","csv","pdf"].map(C=>jsxs("button",{onClick:()=>i(C),className:d("p-4 rounded-lg border-2 transition-all text-center",g===C?"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:[C==="json"&&"\u{1F4C4}",C==="csv"&&"\u{1F4CA}",C==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:C})]},C))})]}),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:y,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),n==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:f,type:"file",accept:".json,.csv",onChange:k,className:"hidden"}),jsxs("button",{onClick:()=>f.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),p&&jsxs("div",{className:d("p-4 rounded-lg",p.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:d("font-semibold mb-2",p.success?"text-green-400":"text-red-400"),children:p.success?"\u2713 Import Successful":"\u2717 Import Failed"}),p.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",p.cardsImported]}),jsxs("div",{children:["Columns imported: ",p.columnsImported]})]}),p.errors&&p.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:p.errors.map((C,h)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",C]},h))})]})]})]})]})]})}var x0=["URGENT","HIGH","MEDIUM","LOW"],k0=[{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"}],w0=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ci({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:c,availableUsers:g=[],availableLabels:i=[],availableColumns:p=[],showQuickFilters:l=true,compact:f=false,groupBy:y="none",onGroupByChange:k}){let[C,h]=useState(true),b=useCallback(w=>{a({search:w.target.value});},[a]),u=useCallback(w=>{a({dateFilter:w.target.value});},[a]),x=useCallback(w=>{r({by:w.target.value});},[r]),m=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),N=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 ${f?"filter-bar--compact":""} ${C?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>h(!C),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:C?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:w=>{w.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:w=>{w.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:C?"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"}),N&&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)"]})]}),!C&&jsxs("div",{className:"filter-bar__content",children:[l&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),n&&jsx("button",{onClick:n,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:b,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:u,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:w=>{let B=w.target.value;a({priorities:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),x0.map(w=>jsx("option",{value:w,children:w},w))]})}),g.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:w=>{let B=w.target.value;a({assignees:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),g.map(w=>jsx("option",{value:w.id,children:w.name},w.id))]})}),i.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:w=>{let B=w.target.value;a({labels:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),i.map(w=>jsx("option",{value:w,children:w},w))]})}),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:x,className:"filter-bar__select filter-bar__select--sm",children:k0.map(w=>jsx("option",{value:w.value,children:w.label},w.value))}),t.by!=="none"&&jsx("button",{onClick:m,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),k&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:y,onChange:w=>k(w.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:w0.map(w=>jsx("option",{value:w.value,children:w.label},w.value))})}),N&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Ti({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:c,onExportGanttCSV:g}){let[i,p]=useState(false),l=useRef(null);useEffect(()=>{let y=k=>{l.current&&!l.current.contains(k.target)&&p(false);};return i&&document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y);}},[i]);let f=y=>{y(),p(false);};return jsxs("div",{className:d("relative",r),ref:l,children:[jsxs("button",{onClick:()=>p(!i),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",y.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",y.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":i,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"3"}),jsx("path",{d:"M12 1v6m0 6v6M5.6 5.6l4.2 4.2m4.2 4.2l4.2 4.2M1 12h6m6 0h6M5.6 18.4l4.2-4.2m4.2-4.2l4.2-4.2"})]}),jsx("span",{children:"Config"})]}),i&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(async()=>await n?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(()=>g?.()),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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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 Ni={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"}},Di={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"}},Si={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"}},co={dark:Ni,light:Di,neutral:Si},Un="dark";var zn=createContext(void 0),F0="asakaa-theme";function Mc({children:e,defaultTheme:t=Un,storageKey:a=F0}){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,g=co[r];Object.entries(g.colors).forEach(([p,l])=>{l&&c.style.setProperty(`--theme-${L0(p)}`,l);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([p,l])=>{let f=g.colors[p];f&&c.style.setProperty(l,f);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let n={theme:r,setTheme:s,themes:co};return jsx(zn.Provider,{value:n,children:e})}function Ao(){let e=useContext(zn);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function L0(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Ei({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=Ao();return e?jsxs("div",{className:d("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(co).map(([s,n])=>jsxs("button",{onClick:()=>{o(s),t();},className:d("w-full p-4 rounded-lg border-2 transition-all flex items-center gap-4",r===s?"border-blue-500 bg-blue-500/20":"border-white/20 hover:border-white/40"),style:{backgroundColor:r===s?"var(--theme-accent-primary)20":"transparent"},children:[jsx("div",{className:"text-3xl",children:n.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:n.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Ac(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return at[e]||at.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",at[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",at[e].bgSecondary),bgGrid:r("--theme-bg-card",at[e].bgGrid),bgWeekend:r("--theme-bg-hover",at[e].bgWeekend),border:r("--theme-border-primary",at[e].border),borderLight:r("--theme-border-subtle",at[e].borderLight),textPrimary:r("--theme-text-primary",at[e].textPrimary),textSecondary:r("--theme-text-secondary",at[e].textSecondary),textTertiary:r("--theme-text-tertiary",at[e].textTertiary),accent:r("--theme-accent-primary",at[e].accent),accentHover:r("--theme-accent-hover",at[e].accentHover),accentLight:r("--theme-accent-primary",at[e].accentLight),taskBarPrimary:r("--theme-accent-primary",at[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",at[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",at[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",at[e].dependency),dependencyHover:r("--theme-border-secondary",at[e].dependencyHover),criticalPath:r("--theme-error",at[e].criticalPath),criticalPathLight:r("--theme-error",at[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",at[e].today):e==="neutral"?r("--theme-text-primary",at[e].today):r("--theme-error",at[e].today),todayLight:e==="light"?r("--theme-accent-primary",at[e].todayLight):e==="neutral"?r("--theme-text-primary",at[e].todayLight):r("--theme-error",at[e].todayLight),milestone:r("--theme-warning",at[e].milestone),milestoneLight:r("--theme-warning",at[e].milestoneLight),statusTodo:r("--theme-text-tertiary",at[e].statusTodo),statusInProgress:r("--theme-accent-primary",at[e].statusInProgress),statusCompleted:r("--theme-success",at[e].statusCompleted),hoverBg:r("--theme-bg-hover",at[e].hoverBg),focusRing:r("--theme-accent-primary",at[e].focusRing)}}var Hn={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious",filterAll:"All",filterIncomplete:"Incomplete",filterInProgress:"In Progress",filterCompleted:"Completed",filter:"Filters",filterBy:"FILTER BY STATUS",filterAllDesc:"Show all tasks",filterIncompleteDesc:"Hide completed tasks",filterInProgressDesc:"Tasks currently being worked on",filterCompletedDesc:"Only show finished tasks",clearFilter:"Clear filter",hideCompleted:"Hide Completed Tasks",toDo:"To Do / Pending"},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",week:"Week",clickToSetDates:"Click to set dates..."},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"}},Fc={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso",filterAll:"Todas",filterIncomplete:"Sin completar",filterInProgress:"En progreso",filterCompleted:"Completadas",filter:"Filtros",filterBy:"FILTRAR POR ESTADO",filterAllDesc:"Mostrar todas las tareas",filterIncompleteDesc:"Ocultar tareas completadas",filterInProgressDesc:"Tareas en las que se est\xE1 trabajando",filterCompletedDesc:"Solo mostrar tareas terminadas",clearFilter:"Limpiar filtro",hideCompleted:"Ocultar Tareas Completadas",toDo:"Por Hacer / Pendiente"},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",week:"Semana",clickToSetDates:"Clic para establecer fechas..."},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"}},Pi={en:Hn,es:Fc};function Lc(e){return Pi[e]||Pi.en}function Mi(e,t){let a=Lc(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 Lo=createContext(Hn);function Vr(){return useContext(Lo)}function eb({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[c,g]=useState(false),[i,p]=useState(null),l=useRef(null),f=Vr();if(useEffect(()=>{let h=b=>{l.current&&!l.current.contains(b.target)&&g(false);};return c&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[c]),!(t||a||r||o||s||n))return null;let k=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:n}].filter(h=>h.handler),C=async(h,b)=>{if(b){p(h);try{await b();}catch(u){console.error(`Export ${h} failed:`,u);}finally{p(null),g(false);}}};return jsxs("div",{ref:l,className:"relative",children:[jsxs(motion.button,{onClick:()=>g(!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:f.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:k.map((h,b)=>jsxs(motion.button,{onClick:()=>C(h.id,h.handler),disabled:i!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:b<k.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:b*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:i===h.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):h.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:h.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:h.description})]})]},h.id))})})})]})}function tb({options:e,value:t,onChange:a,theme:r,layoutId:o="activeSegment"}){return jsx("div",{className:"inline-flex p-1 rounded-lg relative",style:{backgroundColor:r.bgSecondary,border:`1px solid ${r.borderLight}`},children:e.map(s=>{let n=t===s.value;return jsxs(motion.button,{onClick:()=>a(s.value),className:"relative px-3 py-1.5 rounded-md text-xs transition-all flex items-center gap-1.5 min-w-[70px] justify-center",style:{color:n?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:n?600:500,zIndex:n?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[n&&jsx(motion.div,{layoutId:o,className:"absolute inset-0 rounded-md",style:{backgroundColor:r.accent,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},transition:{type:"spring",stiffness:400,damping:30}}),s.icon&&jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function ab({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 rb({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=Vr();useEffect(()=>{let i=p=>{s.current&&!s.current.contains(p.target)&&o(false);};return r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let c=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],g=c.find(i=>i.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${n.toolbar.density||"Density"}: ${g}`,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((i,p)=>{let l=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:l?e.accentLight:"transparent",borderBottom:p<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:l?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:p*.03},children:[jsx("span",{className:"text-xs",style:{color:l?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500},children:i.label}),l&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},i.value)})})})})]})}function ob({theme:e,value:t,onChange:a,hideCompleted:r=false,onHideCompletedChange:o}){let[s,n]=useState(false),c=useRef(null),g=Vr();useEffect(()=>{if(!s)return;let f=setTimeout(()=>{let y=C=>{c.current&&!c.current.contains(C.target)&&n(false);},k=C=>{C.key==="Escape"&&n(false);};document.addEventListener("mousedown",y),document.addEventListener("keydown",k),c._cleanup=()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",k);};},100);return ()=>{clearTimeout(f),c._cleanup&&c._cleanup();}},[s]);let i=[{value:"all",label:g.toolbar.filterAll||"Show All",icon:jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#3B82F6] bg-[#3B82F6]"}),color:"text-[#3B82F6]"},{value:"completed",label:g.toolbar.filterCompleted||"Completed",icon:jsx(CheckCircle2,{className:"w-4 h-4"}),color:"text-green-500"},{value:"in_progress",label:g.toolbar.filterInProgress||"In Progress",icon:jsx(PlayCircle,{className:"w-4 h-4"}),color:"text-blue-500"},{value:"incomplete",label:g.toolbar.toDo||"To Do / Pending",icon:jsx(Circle,{className:"w-4 h-4"}),color:"text-gray-400"}],p=t!=="all"||r,l=e.bgPrimary==="#0F1117"||e.bgPrimary==="#0a0a0a"||e.textPrimary==="#FFFFFF";return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:f=>{f.stopPropagation(),n(y=>!y);},className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:p?l?"rgba(59, 130, 246, 0.2)":"rgb(239 246 255)":s?e.hoverBg:e.bgSecondary,border:`1px solid ${p?l?"rgba(59, 130, 246, 0.5)":"rgb(191 219 254)":e.borderLight}`,color:p?"#3B82F6":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},children:[jsx(Filter,{className:"w-4 h-4"}),jsx("span",{children:g.toolbar.filter||"Filters"}),p&&jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:"#3B82F6"}})]}),jsx(AnimatePresence,{children:s&&jsxs(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-72 rounded-lg overflow-hidden z-50",style:{backgroundColor:l?"#0F1117":"#FFFFFF",border:`1px solid ${l?"rgba(255,255,255,0.1)":"rgb(229 231 235)"}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:[jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:l?"rgba(255,255,255,0.1)":"rgb(229 231 235)"},children:jsx("span",{className:"text-xs font-medium uppercase tracking-wider",style:{color:l?"#6B7280":"#9CA3AF"},children:g.toolbar.filterBy||"FILTER BY STATUS"})}),jsx("div",{className:"py-2",children:i.map(f=>{let y=t===f.value&&!r,k=()=>f.value==="all"?y?jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#3B82F6] bg-[#3B82F6]"}):jsx("div",{className:"w-4 h-4 rounded-full border-2 border-gray-400"}):f.icon;return jsxs(motion.button,{onClick:()=>{a(f.value),o&&o(false);},className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors",style:{backgroundColor:y?l?"rgba(255,255,255,0.05)":"rgb(249 250 251)":"transparent"},whileHover:{backgroundColor:l?"rgba(255,255,255,0.1)":"rgb(243 244 246)"},children:[jsx("span",{className:`${y?f.color:"text-gray-400"} flex-shrink-0`,children:k()}),jsx("span",{className:"flex-1 text-left whitespace-nowrap",style:{color:l?"#FFFFFF":"#111827"},children:f.label}),y&&jsx(Check,{className:"w-4 h-4 flex-shrink-0",style:{color:l?"#3B82F6":"#2563EB"}})]},f.value)})}),jsx("div",{className:"my-2 mx-4 h-px",style:{backgroundColor:l?"rgba(255,255,255,0.1)":"rgb(229 231 235)"}}),o&&jsx("div",{className:"py-1",children:jsxs(motion.button,{onClick:()=>{o(!r),r||a("all");},className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors",style:{backgroundColor:r?l?"rgba(255,255,255,0.05)":"rgb(249 250 251)":"transparent"},whileHover:{backgroundColor:l?"rgba(255,255,255,0.1)":"rgb(243 244 246)"},children:[jsx(EyeOff,{className:"w-4 h-4 flex-shrink-0",style:{color:r?l?"#3B82F6":"#2563EB":l?"#6B7280":"#9CA3AF"}}),jsx("span",{className:"flex-1 text-left whitespace-nowrap",style:{color:l?"#FFFFFF":"#111827"},children:g.toolbar.hideCompleted||"Hide Completed Tasks"}),r&&jsx(Check,{className:"w-4 h-4 flex-shrink-0",style:{color:l?"#3B82F6":"#2563EB"}})]})})]})})]})}function Gn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:c,onRowDensityChange:g,showThemeSelector:i=false,showCreateTaskButton:p=false,createTaskLabel:l,onCreateTask:f,taskFilter:y="all",onTaskFilterChange:k,hideCompleted:C=false,onHideCompletedChange:h,onExportPNG:b,onExportPDF:u,onExportExcel:x,onExportCSV:m,onExportJSON:N,onExportMSProject:w}){let B=Vr(),v=b||u||x||m||N||w,I=[{value:"day",label:B.toolbar.day},{value:"week",label:B.toolbar.week},{value:"month",label:B.toolbar.month}],A=[{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(ab,{options:I,value:t,onChange:T=>a(T),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(rb,{theme:e,value:c,onChange:g}),k&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(ob,{theme:e,value:y,onChange:k,hideCompleted:C,onHideCompletedChange:h})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[p&&f&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:f,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:l||B.toolbar.createTask})]}),(v||i)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),v&&jsxs(Fragment,{children:[jsx(eb,{theme:e,onExportPNG:b,onExportPDF:u,onExportExcel:x,onExportCSV:m,onExportJSON:N,onExportMSProject:w}),i&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),i&&jsx(tb,{options:A,value:s,onChange:T=>n(T),theme:e})]})]})}function _n({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),c=useRef(null),g=useRef(null);useEffect(()=>{if(!r)return;let p=l=>{c.current&&!c.current.contains(l.target)&&o(false);};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r]);let i=e.filter(p=>p.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:g,onClick:()=>{if(!r&&g.current){let p=g.current.getBoundingClientRect();n({x:p.left,y:p.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(bt,{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"}),i.map(p=>jsxs("button",{onClick:()=>{t(p.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:l=>{l.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:p.label}),p.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},p.id))]})})})})]})}function Io({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[c,g]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let p=200,l=r.length*36+8,f=8,y=window.innerWidth,k=window.innerHeight,C=t,h=a;t+p+f>y&&(C=t-p,C<f&&(C=f)),a+l+f>k&&(h=k-l-f,h<f&&(h=f)),g({x:C,y:h});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let p=f=>{n.current&&!n.current.contains(f.target)&&o();},l=f=>{f.key==="Escape"&&o();};return document.addEventListener("mousedown",p),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",l);}},[e,o]),!e)return null;let i=p=>p.startsWith("#")&&(p.length===7||p.length===4)?p:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:n,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:i(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(p=>jsxs("div",{children:[p.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{p.disabled||(p.onClick(),o());},disabled:p.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:p.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:p.disabled?"not-allowed":"pointer",opacity:p.disabled?.5:1},onMouseEnter:l=>{p.disabled||(l.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent";},children:[p.icon&&jsx("span",{style:{color:s.textSecondary},children:p.icon}),jsx("span",{className:"flex-1",children:p.label}),p.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},p.id))})})})}var Wt={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 Wc({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:c,onTaskOutdent:g,onTaskRename:i,onTaskToggleExpand:p,onOpenTaskModal:l,enableKeyboard:f=true}){let y=useRef(false),k=useCallback(x=>{y.current=x;},[]),C=useCallback(x=>{let m=[],N=w=>{for(let B of w)m.push(B),B.subtasks&&B.subtasks.length>0&&B.isExpanded&&N(B.subtasks);};return N(x),m},[]),h=useCallback(()=>{let x=C(e);for(let m of x)if(t.has(m.id))return m;return null},[e,t,C]),b=useCallback((x,m)=>{let N=C(e);if(N.length===0)return;let w=h();if(!w){a(N[0].id,false);return}let B=N.findIndex(A=>A.id===w.id);if(B===-1)return;let v=x==="up"?B-1:B+1;if(v<0||v>=N.length)return;let I=N[v];a(I.id,m);},[e,h,C,a]),u=useCallback(x=>{if(!f)return;let m=x.target;if(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.isContentEditable||y.current){x.key==="Escape"&&(m.blur(),y.current=false);return}let B=navigator.platform.toUpperCase().indexOf("MAC")>=0?x.metaKey:x.ctrlKey,v=Array.from(t),I=h();if(x.key==="ArrowUp"){x.preventDefault(),b("up",x.shiftKey);return}if(x.key==="ArrowDown"){x.preventDefault(),b("down",x.shiftKey);return}if(I&&(x.key==="ArrowRight"||x.key==="ArrowLeft")){I.subtasks&&I.subtasks.length>0&&(x.preventDefault(),(x.key==="ArrowRight"&&!I.isExpanded||x.key==="ArrowLeft"&&I.isExpanded)&&p(I.id));return}if(x.altKey&&(x.key==="ArrowUp"||x.key==="ArrowDown")){v.length>0&&(x.preventDefault(),n(v,x.key==="ArrowUp"?"up":"down"));return}if(x.key==="Tab"&&!x.shiftKey){v.length>0&&(x.preventDefault(),c(v));return}if(x.key==="Tab"&&x.shiftKey){v.length>0&&(x.preventDefault(),g(v));return}if(x.key==="Enter"&&!x.shiftKey&&!B){I&&(x.preventDefault(),r(I.id,"below"));return}if(x.key==="Enter"&&x.shiftKey&&!B){I&&(x.preventDefault(),r(I.id,"above"));return}if(x.key==="Enter"&&B){I&&(x.preventDefault(),l(I.id));return}if(x.key==="F2"){I&&(x.preventDefault(),i(I.id));return}if(x.key==="Delete"||x.key==="Backspace"&&B){v.length>0&&(x.preventDefault(),o(v));return}if(x.key==="d"&&B&&!x.shiftKey){v.length>0&&(x.preventDefault(),s(v));return}},[f,t,h,b,r,o,s,n,c,g,i,p,l]);return useEffect(()=>{if(f)return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[f,u]),{setIsEditing:k}}function _c(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(l=>{t(new Set([l])),r(l);},[]),s=useCallback(l=>{t(f=>{let y=new Set(f);return y.has(l)?y.delete(l):y.add(l),y}),r(l);},[]),n=useCallback((l,f)=>{if(!a){o(l);return}let y=f.indexOf(a),k=f.indexOf(l);if(y===-1||k===-1){o(l);return}let C=Math.min(y,k),h=Math.max(y,k),b=f.slice(C,h+1);t(new Set(b)),r(l);},[a,o]),c=useCallback((l,f,y,k)=>{k?n(l,f):y?s(l):o(l);},[o,s,n]),g=useCallback((l,f)=>{f?t(y=>{let k=new Set(y);return k.add(l),k}):o(l);},[o]),i=useCallback(()=>{t(new Set),r(null);},[]),p=useCallback(l=>e.has(l),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:n,handleTaskClick:c,handleKeyboardSelection:g,clearSelection:i,isTaskSelected:p}}function Bo(e){let t=[],a=(r,o,s=0)=>{for(let n=0;n<r.length;n++){let c={...r[n],parentId:o,level:s,position:n};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function Vc(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=Vc(a.subtasks,t);if(r)return r}}return null}function Oi(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Oi(a.subtasks,t);if(r)return r}return null}function $i(e,t){if(t.length===0)return e;let a=Bo(e),r=t[0],o=a.findIndex(l=>l.id===r);if(o<=0)return e;let s=a[o-1],n=(l,f)=>{let y=[];return {tasks:l.filter(C=>{if(f.has(C.id))return y.push(C),false;if(C.subtasks){let h=n(C.subtasks,f);C.subtasks=h.tasks,y.push(...h.removed);}return true}),removed:y}},c=(l,f,y)=>l.map(k=>k.id===f?{...k,subtasks:[...k.subtasks||[],...y],isExpanded:true}:k.subtasks?{...k,subtasks:c(k.subtasks,f,y)}:k),g=new Set(t),{tasks:i,removed:p}=n(e,g);return c(i,s.id,p)}function Ui(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Oi(a,r);if(!o)continue;let s=Oi(a,o.id),n=(i,p,l)=>{for(let f=0;f<i.length;f++){let y=i[f];if(y.id===p&&y.subtasks){let k=y.subtasks.findIndex(C=>C.id===l);if(k!==-1){let[C]=y.subtasks.splice(k,1);return C}}if(y.subtasks){let k=n(y.subtasks,p,l);if(k)return k}}return null},c=(i,p,l)=>{let f=i.findIndex(y=>y.id===p);if(f!==-1)return i.splice(f+1,0,l),i;for(let y of i)y.subtasks&&c(y.subtasks,p,l);return i},g=n(a,o.id,r);g&&(s&&s.subtasks?c(s.subtasks,o.id,g):c(a,o.id,g));}return a}function zi(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,c,g)=>{let i=n.findIndex(l=>l.id===c);if(i===-1){for(let l of n)if(l.subtasks&&s(l.subtasks,c,g))return true;return false}let p=g==="up"?i-1:i+1;return p<0||p>=n.length?false:([n[i],n[p]]=[n[p],n[i]],true)};return s(r,o,a),r}function Hi(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 Wi(e,t){let a=[...e];for(let r of t){let o=n=>{let c=n.findIndex(p=>p.id===r);if(c===-1){for(let p of n)if(p.subtasks&&o(p.subtasks))return true;return false}let g=n[c],i={...g,id:`${g.id}-copy-${Date.now()}`,name:`${g.name} (Copy)`,subtasks:g.subtasks?s(g.subtasks):void 0};return n.splice(c+1,0,i),true},s=n=>n.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function jc(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=g=>{let i=g.findIndex(l=>l.id===t);if(i===-1){for(let l of g)if(l.subtasks&&c(l.subtasks))return true;return false}let p=a==="above"?i:i+1;return g.splice(p,0,n),true};return c(r),{tasks:r,newTask:n}}function Gi(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:Gi(r.subtasks,t,a)}:r)}function _i(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:_i(a.subtasks,t)}:a)}function Vi(e,t){let a=p=>{for(let l of p){if(l.id===t)return l;if(l.subtasks){let f=a(l.subtasks);if(f)return f}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n=r?.startDate||o,c=r?.endDate||s,g={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(c),color:r?.color||"#3B82F6"},i=p=>p.map(l=>{if(l.id===t){let f=l.subtasks||[];return {...l,subtasks:[...f,g],isExpanded:true}}return l.subtasks?{...l,subtasks:i(l.subtasks)}:l});return {tasks:i(e),newTask:g}}function Kc(e,t,a,r){if(t===a)return e;let o=Vc(e,t);if(!o)return e;if(a){let c=(g,i)=>{if(!g.subtasks)return false;for(let p of g.subtasks)if(p.id===i||c(p,i))return true;return false};if(c(o,a))return e}let s=c=>c.filter(g=>g.id!==t).map(g=>g.subtasks&&g.subtasks.length>0?{...g,subtasks:s(g.subtasks)}:g),n=s(e);if(a===null){let c=r!==void 0?r:n.length;n.splice(c,0,{...o,parentId:void 0});}else {let c=g=>g.map(i=>{if(i.id===a){let p=i.subtasks||[],l=r!==void 0?r:p.length,f=[...p];return f.splice(l,0,{...o,parentId:a}),{...i,subtasks:f,isExpanded:true}}return i.subtasks&&i.subtasks.length>0?{...i,subtasks:c(i.subtasks)}:i});n=c(n);}return n}function Kn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:c,onTaskToggle:g,scrollTop:i,columns:p,onToggleColumn:l,onColumnResize:f,onTaskUpdate:y,onTaskIndent:k,onTaskOutdent:C,onTaskMove:h,onMultiTaskDelete:b,onTaskDuplicate:u,onTaskCreate:x,onTaskRename:m,onCreateSubtask:N,onOpenTaskModal:w,onDeleteRequest:B,onTaskReparent:v}){let I=useContext(Lo),[A,T]=useState(null),[W,$]=useState(null),[j,te]=useState(""),oe=useRef(null),[re,ge]=useState(null),[fe,Ie]=useState(0),[M,R]=useState(0),[L,V]=useState({isOpen:false,x:0,y:0,type:"header"}),[q,z]=useState(null),[ye,ne]=useState(null),[Be,qe]=useState(null),tt=useRef(0),le=5,Je=useRef(false),[ct,wt]=useState(null),[vt,U]=useState(false),[me,Ae]=useState(null),[Fe,je]=useState(false),Qe=useRef(null);useEffect(()=>{function _(Y){Qe.current&&!Qe.current.contains(Y.target)&&je(false);}if(Fe)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[Fe]),useEffect(()=>{W&&oe.current&&(oe.current.focus(),oe.current.select());},[W]),useEffect(()=>{if(!re)return;let _=se=>{let Ye=se.clientX-fe,Ue=M+Ye;f?.(re,Ue);},Y=()=>{ge(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",Y),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",Y),document.body.style.cursor="",document.body.style.userSelect="";}},[re,fe,M,f]);let{selectedTaskIds:Pt,handleTaskClick:Re,isTaskSelected:J}=_c(),{setIsEditing:ve}=Wc({tasks:e,selectedTaskIds:Pt,onTaskSelect:(_,Y)=>{let Ye=Bo(e).map(Ue=>Ue.id);Re(_,Ye,Y||false,false);},onTaskCreate:x||(()=>{}),onTaskDelete:b||(()=>{}),onTaskDuplicate:u||(()=>{}),onTaskMove:h||(()=>{}),onTaskIndent:k||(()=>{}),onTaskOutdent:C||(()=>{}),onTaskRename:_=>{let Y=Bo(e).find(se=>se.id===_);Y&&ea(Y);},onTaskToggleExpand:g||(()=>{}),onOpenTaskModal:_=>{let Y=Bo(e).find(se=>se.id===_);Y&&w&&w(Y);},enableKeyboard:true}),He=(_,Y=0)=>{let se=[];for(let Ye of _)se.push({task:Ye,level:Y}),Ye.subtasks&&Ye.subtasks.length>0&&Ye.isExpanded&&se.push(...He(Ye.subtasks,Y+1));return se},Le=He(e),nt=48,st=Math.max(Le.length*a,600-nt),_e=_=>!_.startDate||!_.endDate?"-":`${Math.ceil((_.endDate.getTime()-_.startDate.getTime())/(1e3*60*60*24))}d`,ea=_=>{$(_.id),te(_.name),ve(true);},ke=_=>{j.trim()&&j!==e.find(Y=>Y.id===_)?.name&&m?.(_,j.trim()),$(null),te(""),ve(false);},be=()=>{$(null),te(""),ve(false);},Ke=(_,Y)=>{Y.stopPropagation(),N?.(_.id);},F=(_,Y)=>{Y.preventDefault(),tt.current=Y.clientY,z(_),Je.current=false,U(false),wt({x:Y.clientX,y:Y.clientY});},Ce=_=>{if(!q||(Math.abs(_.clientY-tt.current)>le&&!Je.current&&(Je.current=true,U(true)),wt({x:_.clientX,y:_.clientY}),!Je.current))return;let se=document.querySelectorAll("[data-task-row]"),Ye=null,Ue=null;se.forEach(H=>{let ie=H.getBoundingClientRect(),We=H.getAttribute("data-task-row");if(We&&We!==q&&_.clientY>=ie.top&&_.clientY<=ie.bottom){Ye=We;let Mt=_.clientY-ie.top,pt=ie.height;Mt<pt*.25?Ue="above":Mt>pt*.75?Ue="below":Ue="child";}}),ne(Ye),qe(Ue);},Z=()=>{if(Je.current&&q&&ye&&Be){if(Be==="child")v?.(q,ye);else if(Be==="above"||Be==="below"){let _=(Ye,Ue,H=null)=>{for(let ie of Ye){if(ie.id===Ue)return H;if(ie.subtasks){let We=_(ie.subtasks,Ue,ie.id);if(We!==void 0)return We}}},Y=_(e,ye,null),se=(Ye,Ue)=>{let H=Ye.findIndex(ie=>ie.id===Ue);return Be==="below"?H+1:H};if(Y===null){let Ye=se(e,ye);v?.(q,null,Ye);}else {let Ye=Le.find(Ue=>Ue.task.id===Y)?.task;if(Ye?.subtasks){let Ue=se(Ye.subtasks,ye);v?.(q,Y,Ue);}}}}z(null),ne(null),qe(null),wt(null),Je.current=false,U(false);};useEffect(()=>{if(q)return document.addEventListener("mousemove",Ce),document.addEventListener("mouseup",Z),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Ce),document.removeEventListener("mouseup",Z),document.body.style.cursor="",document.body.style.userSelect="";}},[q,ye,Be]);let Te=(_,Y,se)=>{switch(_.id){case "name":let Ye=W===Y.id,Ue=A===Y.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${se*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:O=>F(Y.id,O),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),Y.subtasks&&Y.subtasks.length>0?jsx("button",{onClick:O=>{O.stopPropagation(),g?.(Y.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:Y.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:Y.color||"#3B82F6",opacity:Y.parentId?.6:1,borderColor:Y.isMilestone?t.accent:"transparent",borderWidth:Y.isMilestone?"2px":"0px"},title:Y.isMilestone?"Milestone":Y.parentId?"Subtask":"Task"})}),Ye?jsx("input",{ref:oe,type:"text",value:j,onChange:O=>te(O.target.value),onKeyDown:O=>{O.key==="Enter"?ke(Y.id):O.key==="Escape"&&be();},onBlur:()=>ke(Y.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:O=>O.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:Y.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:Y.parentId?"13px":"14px",fontWeight:Y.isMilestone?600:Y.parentId?400:600,letterSpacing:Y.parentId?"0":"-0.01em"},title:Y.name,children:Y.name}),Ue&&!Ye&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:O=>O.stopPropagation(),children:[jsx("button",{onClick:O=>Ke(Y,O),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:O=>{O.stopPropagation(),ea(Y);},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 ie=_.id==="startDate"?"startDate":"endDate",We=Y[ie],Mt=me?.taskId===Y.id&&me?.field===ie,pt=O=>O?(typeof O=="string"?new Date(O):O).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:O=>O.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:O=>{if(Mt)Ae(null);else {let Me=O.currentTarget.getBoundingClientRect();Ae({taskId:Y.id,field:ie,month:We?typeof We=="string"?new Date(We):We:new Date,position:{top:Me.bottom+4,left:Me.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:pt(We)})]}),Mt&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>Ae(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:me?.position.top,left:me?.position.left},onClick:O=>O.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let O=new Date,Me=new Date(O);Me.setDate(O.getDate()+1);let Xe=new Date(O);Xe.setDate(O.getDate()+7);let Lt=new Date(O);return Lt.setDate(O.getDate()+14),[{label:"Hoy",date:O},{label:"Ma\xF1ana",date:Me},{label:"Pr\xF3xima semana",date:Xe},{label:"2 semanas",date:Lt}].map((ze,xt)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:Ve=>Ve.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:Ve=>Ve.currentTarget.style.backgroundColor="transparent",onClick:()=>{y?.(Y.id,{[ie]:ze.date}),Ae(null);},children:ze.label},xt))})(),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:O=>O.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",onClick:()=>{y?.(Y.id,{[ie]:void 0}),Ae(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:()=>Ae(O=>O?{...O,month:new Date(O.month.getFullYear(),O.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:me?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>Ae(O=>O?{...O,month:new Date(O.month.getFullYear(),O.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((O,Me)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:O},Me))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let O=me?.month||new Date,Me=O.getFullYear(),Xe=O.getMonth(),Lt=new Date(Me,Xe,1).getDay(),de=new Date(Me,Xe+1,0).getDate(),ze=new Date,xt=[];for(let ft=Lt-1;ft>=0;ft--)xt.push({day:new Date(Me,Xe,-ft).getDate(),date:new Date(Me,Xe-1,new Date(Me,Xe,-ft).getDate()),isCurrentMonth:false});for(let ft=1;ft<=de;ft++)xt.push({day:ft,date:new Date(Me,Xe,ft),isCurrentMonth:true});let Ve=42-xt.length;for(let ft=1;ft<=Ve;ft++)xt.push({day:ft,date:new Date(Me,Xe+1,ft),isCurrentMonth:false});return xt.map((ft,aa)=>{let Ca=ft.date.toDateString()===ze.toDateString(),Ze=(We?typeof We=="string"?new Date(We):We:null)?.toDateString()===ft.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:ft.isCurrentMonth?Ze?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Ze?"#3B82F6":"transparent",boxShadow:Ca&&!Ze?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{y?.(Y.id,{[ie]:ft.date}),Ae(null);},children:ft.day},aa)})})()})]})]})]}),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:_e(Y)})});case "assignees":let Ar=r.filter(O=>Y.assignees?.some(Me=>Me.name===O.name||Me.initials===O.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:O=>O.stopPropagation(),children:jsx(ro,{assignedUsers:Ar,availableUsers:r,onChange:O=>{let Me=O.map(Xe=>({id:Xe.id,name:Xe.name,initials:Xe.initials,color:Xe.color}));y?.(Y.id,{assignees:Me.length>0?Me:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:O=>O.stopPropagation(),children:jsx(Bd,{status:Y.status||"todo",onChange:O=>{y?.(Y.id,{status:O,progress:O==="completed"?100:Y.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:`${Y.progress}%`,backgroundColor:Y.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:[Y.progress,"%"]})]});case "priority":let wa={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},ta={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},P=wa[Y.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:O=>O.stopPropagation(),children:jsx(to,{priority:P,onChange:O=>{O&&y?.(Y.id,{priority:ta[O]||"medium"});}})});default:return null}},we=_=>[{id:"hide",label:"Hide Column",icon:Wt.Hide,onClick:()=>l(_),disabled:_==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Wt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Wt.SortDesc,onClick:()=>{}}],Oe=_=>_.subtasks&&_.subtasks.length>0?[{id:"addSubtask",label:I?.contextMenu?.addSubtask||"Add Subtask",icon:Wt.Add,onClick:()=>{N?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:I?.contextMenu?.deleteTask||"Delete Task",icon:Wt.Delete,onClick:()=>{B?B(_.id,_.name):b?.([_.id]);}}]:[{id:"edit",label:I?.contextMenu?.editTask||"Edit Task",icon:Wt.Pencil,onClick:()=>{n?.(_);}},{id:"addSubtask",label:I?.contextMenu?.addSubtask||"Add Subtask",icon:Wt.Add,onClick:()=>{N?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:I?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Wt.MarkIncomplete,onClick:()=>{y?.(_.id,{status:"todo",progress:0});},disabled:_.status==="todo"},{id:"setInProgress",label:I?.contextMenu?.setInProgress||"Set In Progress",icon:Wt.SetInProgress,onClick:()=>{y?.(_.id,{status:"in-progress"});},disabled:_.status==="in-progress"},{id:"markComplete",label:I?.contextMenu?.markComplete||"Mark Complete",icon:Wt.MarkComplete,onClick:()=>{y?.(_.id,{status:"completed",progress:100});},disabled:_.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:I?.contextMenu?.splitTask||"Split Task",icon:Wt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:I?.contextMenu?.deleteTask||"Delete Task",icon:Wt.Delete,onClick:()=>{B?B(_.id,_.name):b?.([_.id]);}}],$e=p.filter(_=>_.visible),dt=$e.reduce((_,Y)=>_+Y.width,0);return jsxs("div",{className:"gantt-taskgrid-content",style:{backgroundColor:t.bgPrimary,minWidth:dt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${nt}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:$e.map((_,Y)=>{let se=Y===$e.length-1,Ye=_.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${Ye?"":"justify-center"}`,style:{width:`${_.width}px`,minWidth:`${_.minWidth??(Ye?200:60)}px`,maxWidth:`${_.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:se?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:Ue=>{Ue.preventDefault(),V({isOpen:true,x:Ue.clientX,y:Ue.clientY,type:"header",columnId:_.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:_.label,children:_.label}),_.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:re===_.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:Ue=>{Ue.preventDefault(),Ue.stopPropagation(),ge(_.id),Ie(Ue.clientX),R(_.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},_.id)})}),jsxs("div",{className:"flex items-center gap-1 px-2",style:{position:"sticky",right:0,height:"100%",backgroundColor:t.bgGrid,zIndex:5},children:[jsx(_n,{columns:p,onToggleColumn:l,theme:t}),jsx("button",{onClick:()=>je(!Fe),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"})}),Fe&&jsxs("div",{ref:Qe,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:_=>_.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>je(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:t.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]})]}),jsx("div",{className:"gantt-taskgrid-content",style:{minHeight:st},children:Le.map(({task:_,level:Y},se)=>{let Ye=J(_.id),Ue=ye===_.id,H=Ue&&Be==="above",ie=Ue&&Be==="below",We=Ue&&Be==="child",Mt={};return We&&(Mt.backgroundColor=`${t.accent}15`,Mt.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":_.id,className:`flex items-center cursor-pointer group ${q===_.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:Ye?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:Ye?t.accentLight:We?`${t.accent}15`:se%2===0?t.bgPrimary:t.bgGrid,...Mt},onMouseEnter:()=>T(_.id),onMouseLeave:()=>T(null),onClick:pt=>{let wa=Bo(e).map(O=>O.id),P=navigator.platform.toUpperCase().indexOf("MAC")>=0?pt.metaKey:pt.ctrlKey;Re(_.id,wa,P,pt.shiftKey),s?.(_);},onDoubleClick:pt=>{pt.stopPropagation(),n?.(_);},onContextMenu:pt=>{pt.preventDefault(),V({isOpen:true,x:pt.clientX,y:pt.clientY,type:"task",task:_}),c?.(_,pt);},whileHover:{backgroundColor:Ye?t.accentLight:t.hoverBg},children:[H&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),ie&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),$e.map((pt,Ar)=>{let wa=Ar===$e.length-1,ta=pt.id==="name";return jsx("div",{className:`px-4 flex items-center ${ta?"justify-start":"justify-center"}`,style:{width:`${pt.width}px`,minWidth:`${pt.minWidth??(ta?200:60)}px`,maxWidth:`${pt.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:wa?"none":`1px solid ${A===_.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:Te(pt,_,ta?Y:0)},`${_.id}-${pt.id}`)})]},_.id)})}),jsx(Io,{isOpen:L.isOpen,x:L.x,y:L.y,items:L.type==="header"&&L.columnId?we(L.columnId):L.type==="task"&&L.task?Oe(L.task):[],onClose:()=>V({...L,isOpen:false}),theme:t}),vt&&ct&&q&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:ct.x+12,top:ct.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let _=Le.find(Y=>Y.task.id===q)?.task;return _?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:_.name})}):null})()}),document.body)]})}function Zc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,c]=useState(e),[g,i]=useState(t),[p,l]=useState(null),[f,y]=useState(null),[k,C]=useState(null),[h,b]=useState(null),[u,x]=useState(0),[m,N]=useState(0),[w,B]=useState(null),[v,I]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:c,ghostWidth:g,setGhostWidth:i,connectionLine:p,setConnectionLine:l,hoveredTaskId:f,setHoveredTaskId:y,activeZone:k,setActiveZone:C,draggedSegmentIndex:h,setDraggedSegmentIndex:b,draggedSegmentStartX:u,setDraggedSegmentStartX:x,segmentDragOffsetX:m,setSegmentDragOffsetX:N,hoveredSegmentIndex:w,setHoveredSegmentIndex:B,isHovered:v,setIsHovered:I,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(j,te)=>{r("none"),l(null),y(null),c(j),i(te),N(0),b(null),x(0);}}}function qn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:c,onClick:g,onDoubleClick:i,onContextMenu:p,onDateChange:l,onDependencyCreate:f,allTaskPositions:y=[],onDragMove:k,onHoverChange:C}){let h=Zc(t,r),b=useRef(null),u=useRef(null),x=useRef(null),{dragMode:m,setDragMode:N,dragOffset:w,setDragOffset:B,ghostX:v,setGhostX:I,ghostWidth:A,setGhostWidth:T,connectionLine:W,setConnectionLine:$,hoveredTaskId:j,setHoveredTaskId:te,activeZone:oe,setActiveZone:re,draggedSegmentIndex:ge,setDraggedSegmentIndex:fe,draggedSegmentStartX:Ie,setDraggedSegmentStartX:M,segmentDragOffsetX:R,setSegmentDragOffsetX:L,hoveredSegmentIndex:V,setHoveredSegmentIndex:q,isHovered:z,setIsHovered:ye,isDragging:ne,isResizing:Be,isConnecting:qe,resetDragState:tt}=h,le=32,Je=8,ct=e.endDate&&e.endDate<new Date&&e.progress<100,wt=e.isCriticalPath,vt=o.name==="neutral"||o.today==="#1C1917",U=e.status==="completed"||e.progress===100,me={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},Fe=e.isCriticalPath||ct?"#DC2626":e.color?e.color:e.priority&&me[e.priority]?me[e.priority]:o.taskBarPrimary,Qe=(Z=>Z>=80?20:Z>=60?15:Z>=50?12:10)(r),Pt=r<50,Re=r<40;useEffect(()=>{if(C)if(z&&!ne&&!e.segments){let Z=a<100;C({task:e,x:t,y:a,width:r,height:le,showBelow:Z});}else C(null);},[z,ne,e,t,a,r,le,C]);let J=Z=>Z.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),ve=()=>{let Z=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${Z} day${Z!==1?"s":""}`},He=Z=>Math.round(Z/s)*s,Le=Z=>{let Te=Math.round(Z/s),we=new Date(n);return we.setDate(we.getDate()+Te),we},nt=(Z,Te)=>{for(let we of y){if(we.id===e.id)continue;let Oe=5;if(Z>=we.x-Oe&&Z<=we.x+we.width+Oe&&Te>=we.y-Oe&&Te<=we.y+we.height+Oe)return we.id}return null},st=useCallback((Z,Te,we)=>{Z.preventDefault(),Z.stopPropagation();let Oe=b.current?.ownerSVGElement;if(!Oe)return;let $e=Oe.createSVGPoint();$e.x=Z.clientX,$e.y=Z.clientY;let dt=$e.matrixTransform(Oe.getScreenCTM()?.inverse()),_=we!==void 0?we:t,Y=Te;if(!Y){let se=dt.x-_;Z.shiftKey?(Y="connect",$({x:t+r,y:a+le/2})):Z.ctrlKey||Z.metaKey?Y="move":Z.altKey?Y=se<r/2?"resize-start":"resize-end":Re?se<r/2?Y="move":Y="resize-end":Pt?se<=Qe/2?Y="resize-start":se>=r-Qe/2?Y="resize-end":Y="move":se<=Qe?Y="resize-start":se>=r-Qe?Y="resize-end":Y="move";}N(Y),ye(false),re(null),Y==="move"?B(dt.x-_):Y==="connect"?$({x:t+r,y:a+le/2}):B(0),I(_),T(r);},[t,r,a,le]),_e=useCallback(Z=>{let Te=b.current?.ownerSVGElement;if(!Te)return;let we=Te.closest(".gantt-timeline-scroll");if(!we)return;let Oe=we.getBoundingClientRect(),$e=60,dt=15,_=0;if(Z.clientX<Oe.left+$e){let Y=Oe.left+$e-Z.clientX;_=-Math.min(dt,Y/2);}else if(Z.clientX>Oe.right-$e){let Y=Z.clientX-(Oe.right-$e);_=Math.min(dt,Y/2);}return _!==0&&(we.scrollLeft+=_),_!==0},[]),ea=useCallback(Z=>{if(m==="none")return;x.current=Z;let Te=b.current?.ownerSVGElement;if(!Te)return;if(m==="move"||m==="resize-start"||m==="resize-end"){let $e=_e(Z);$e&&!u.current?u.current=window.setInterval(()=>{x.current&&(_e(x.current),ea(x.current));},16):!$e&&u.current&&(window.clearInterval(u.current),u.current=null);}let we=Te.createSVGPoint();we.x=Z.clientX,we.y=Z.clientY;let Oe=we.matrixTransform(Te.getScreenCTM()?.inverse());if(m==="connect"){$({x:Oe.x,y:Oe.y});let $e=nt(Oe.x,Oe.y);te($e);}else if(m==="move"){let $e=Oe.x-w,dt=He($e);I(dt),T(r);let _=Math.round((dt-t)/s);if(k?.(e.id,_,true),e.segments&&e.segments.length>0&&ge!==null){let Y=dt-Ie;L(Y);}}else if(m==="resize-start"){let $e=Oe.x,dt=He($e),_=t+r-dt;_>=s&&(I(dt),T(_));}else if(m==="resize-end"){let $e=Oe.x,_=He($e)-t;_>=s&&T(_);}},[m,t,r,s,w,e,He,ge,Ie,nt,te,$,I,T,L,k,_e]),ke=useCallback(()=>{if(u.current&&(window.clearInterval(u.current),u.current=null),x.current=null,m!=="none"){if(m==="connect")j&&f&&f(e,j),$(null),te(null);else {let Z=e.endDate.getTime()-e.startDate.getTime(),Te,we,Oe=true;if(m==="move"){if(Te=Le(v),we=new Date(Te.getTime()+Z),e.segments&&e.segments.length>0&&ge!==null){let $e=Math.round(R/s),dt=e.segments.map((Ye,Ue)=>{if(Ue===ge){let H=new Date(Ye.startDate),ie=new Date(Ye.endDate);return H.setDate(H.getDate()+$e),ie.setDate(ie.getDate()+$e),{startDate:H,endDate:ie}}return Ye}),_=dt.flatMap(Ye=>[Ye.startDate,Ye.endDate]),Y=new Date(Math.min(..._.map(Ye=>Ye.getTime()))),se=new Date(Math.max(..._.map(Ye=>Ye.getTime())));l?.({...e,segments:dt},Y,se),tt(t,r);return}}else m==="resize-start"?(Te=Le(v),we=e.endDate,Te>we&&(console.warn("Invalid date range: start date must be before or equal to end date"),Oe=false)):m==="resize-end"?(Te=e.startDate,we=Le(v+A),we<Te&&(console.warn("Invalid date range: end date must be after or equal to start date"),Oe=false)):Oe=false;Oe&&Te&&we&&(we.getTime()<Te.getTime()?console.warn("Invalid date range: end date cannot be before start date"):l?.(e,Te,we));}k?.(e.id,0,false),tt(t,r);}},[m,v,A,e,l,j,f,t,r,s,Le,R,ge,tt,k]);useEffect(()=>{if(m==="none")return;let Z=we=>{ea(we);},Te=()=>{ke();};return window.addEventListener("mousemove",Z),window.addEventListener("mouseup",Te),()=>{window.removeEventListener("mousemove",Z),window.removeEventListener("mouseup",Te),u.current&&(window.clearInterval(u.current),u.current=null);}},[m,ea,ke]);let be=ne&&!qe?v:t,Ke=ne&&!qe?A:r,F=c.taskClass(e);return jsxs("g",{ref:b,"data-task-bar":"true",onClick:()=>!ne&&g?.(e),onDoubleClick:Z=>{ne||(Z.stopPropagation(),i?.(e));},onContextMenu:Z=>{Z.preventDefault(),p?.(e,Z);},onMouseEnter:()=>!ne&&ye(true),onMouseLeave:()=>{ne||(ye(false),re(null));},children:[jsx("rect",{x:t,y:a,width:r+24,height:le,fill:"transparent",style:{pointerEvents:"all"}}),z&&!ne&&!Pt&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Qe,height:le,fill:oe==="resize-start"?o.accent:"transparent",opacity:oe==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>re("resize-start"),onMouseDown:Z=>st(Z,"resize-start")}),jsx("rect",{x:t+Qe,y:a,width:r-Qe*2,height:le,fill:oe==="move"?o.accent:"transparent",opacity:oe==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>re("move"),onMouseDown:Z=>st(Z,"move")}),jsx("rect",{x:t+r-Qe,y:a,width:Qe,height:le,fill:oe==="resize-end"?o.accent:"transparent",opacity:oe==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>re("resize-end"),onMouseDown:Z=>st(Z,"resize-end")})]}),z&&!ne&&Re&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:le,fill:oe==="move"?o.accent:"transparent",opacity:oe==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>re("move"),onMouseDown:Z=>st(Z,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:le,fill:oe==="resize-end"?o.accent:"transparent",opacity:oe==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>re("resize-end"),onMouseDown:Z=>st(Z,"resize-end")}),z&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+le-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),ne&&!qe&&!e.segments&&jsx(motion.rect,{x:v,y:a,width:A,height:le,rx:Je,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:be,y:a,width:Ke,height:le,rx:Je,fill:Fe,"data-task-class":F,initial:{opacity:0,scale:.95},animate:{opacity:ne&&!qe?.15:e.parentId?.6:z?.9:.8,scale:z&&!ne?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:Z=>st(Z),style:{cursor:ne?qe?"crosshair":Be?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:be,y:a,width:Ke*(e.progress/100),height:le,rx:Je,fill:Fe,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((Z,Te)=>{let we=(Z.startDate.getTime()-n.getTime())/864e5*s,$e=(Z.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-we+s,dt=ne&&m==="move"&&ge===Te,_=V===Te,Y=dt?we+R:we;return jsxs("g",{onMouseEnter:()=>!ne&&q(Te),onMouseLeave:()=>!ne&&q(null),children:[jsx(motion.rect,{x:Y,y:a,width:$e,height:le,rx:Je,fill:Fe,initial:{opacity:0,scale:.95},animate:{opacity:dt||e.parentId?.6:_?.9:.8,scale:_&&!ne?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:se=>{se.stopPropagation(),fe(Te),M(we),st(se,void 0,we);},style:{cursor:ne?qe?"crosshair":Be?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Y,y:a,width:$e*(e.progress/100),height:le,rx:Je,fill:Fe,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Te}`)}),vt&&(ct||wt)&&!e.segments&&jsxs(Fragment,{children:[wt&&!ct&&jsx("rect",{x:be,y:a,width:Ke,height:le,rx:Je,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),ct&&jsx("rect",{x:be,y:a,width:Ke,height:le,rx:Je,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),Ke>60&&!e.segments&&(()=>{let Z=c.taskLabel(e),Te=typeof Z=="string"?Z:e.name,we=Te.length>Math.floor(Ke/8)?`${Te.substring(0,Math.floor(Ke/8))}...`:Te;return jsx("text",{x:be+12,y:a+le/2,dominantBaseline:"middle",fill:U?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:U?"line-through":"none"},children:we})})(),Ke>100&&e.progress>0&&e.progress<100&&!ne&&!e.segments&&jsxs("text",{x:be+Ke-12,y:a+le/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&&Ke>80&&!ne&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:be+Ke-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:be+Ke-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(z||Be)&&!qe&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{children:[jsx("rect",{x:be-2,y:a,width:16,height:le,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>re("resize-start"),onMouseLeave:()=>re(null),onMouseDown:Z=>{Z.stopPropagation(),st(Z,"resize-start");}}),jsx(motion.rect,{x:be+4,y:a+8,width:3,height:le-16,rx:1.5,fill:oe==="resize-start"||m==="resize-start"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]}),jsxs("g",{children:[jsx("rect",{x:be+Ke-14,y:a,width:16,height:le,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>re("resize-end"),onMouseLeave:()=>re(null),onMouseDown:Z=>{Z.stopPropagation(),st(Z,"resize-end");}}),jsx(motion.rect,{x:be+Ke-7,y:a+8,width:3,height:le-16,rx:1.5,fill:oe==="resize-end"||m==="resize-end"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]})]}),jsx(AnimatePresence,{children:z&&!ne&&!e.segments&&jsxs(motion.g,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx("circle",{cx:t+r+10,cy:a+le/2,r:10,fill:"transparent",style:{cursor:"crosshair"},onMouseEnter:()=>re("connect"),onMouseLeave:()=>re(null),onMouseDown:Z=>{Z.stopPropagation(),st(Z,"connect");}}),jsx(motion.circle,{cx:t+r+10,cy:a+le/2,r:4,fill:o.accent,stroke:"#FFFFFF",strokeWidth:1.5,style:{pointerEvents:"none"},initial:{scale:0},animate:{scale:oe==="connect"?1.4:1},exit:{scale:0},transition:{duration:.15,type:"spring",stiffness:500,damping:30}})]})}),qe&&W&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+le/2,x2:W.x,y2:W.y,stroke:j?o.statusCompleted:o.accent,strokeWidth:j?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:j?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:W.x,cy:W.y,r:j?8:6,fill:j?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),j&&jsx(motion.text,{x:W.x+15,y:W.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:W.x+10},animate:{opacity:1,x:W.x+15},transition:{duration:.2},children:"Connect"})]}),(z||ne)&&!qe&&!e.segments&&jsx(motion.rect,{x:be-2,y:a-2,width:Ke+4,height:le+4,rx:Je+2,fill:"none",stroke:ne?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:ne?.6:.4,initial:{opacity:0},animate:{opacity:ne?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),Be&&jsxs(Fragment,{children:[jsx("line",{x1:v,y1:0,x2:v,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:v+A,y1:0,x2:v+A,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:z&&!ne&&!e.segments&&!C&&(()=>{let we=a<100,Oe=we?a+le+13:a-82-13,$e=we?`M ${be+Ke/2-6} ${a+le+3} L ${be+Ke/2} ${a+le+13} L ${be+Ke/2+6} ${a+le+3}`:`M ${be+Ke/2-6} ${a-13} L ${be+Ke/2} ${a-3} L ${be+Ke/2+6} ${a-13}`,dt=Oe+22,_=Oe+40,Y=Oe+55,se=Oe+70,Ye=we?Oe+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:we?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:we?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:$e,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:be+Ke/2-120,y:Oe,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:be+Ke/2,y:dt,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:be+Ke/2-110,y:_,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:be+Ke/2-70,y:_,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:J(e.startDate)}),jsx("text",{x:be+Ke/2-110,y:Y,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:be+Ke/2-70,y:Y,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:J(e.endDate)}),jsx("text",{x:be+Ke/2+10,y:_,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:be+Ke/2+65,y:_,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ve()}),jsx("text",{x:be+Ke/2+10,y:Y,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:be+Ke/2+65,y:Y,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:be+Ke/2-110,y:se,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:be+Ke/2-50,y:se,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(Ue=>Ue.name).join(", ").substring(0,30),e.assignees.map(Ue=>Ue.name).join(", ").length>30?"...":""]})]}),!we&&jsx("text",{x:be+Ke/2,y:Ye,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:Re?"Left: move \u2022 Right: resize":Pt?"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 tm({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:c}=e,g=82,i=13,p=c?o+n+i:o-g-i,l=c?`M ${r+s/2-6} ${o+n+3} L ${r+s/2} ${o+n+13} L ${r+s/2+6} ${o+n+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,f=p+22,y=p+40,k=p+55,C=p+70,h=m=>m.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),b=()=>{if(!a.startDate||!a.endDate)return "N/A";let m=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${m} day${m!==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:l,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:p,width:240,height:g,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:f,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,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?h(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:k,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:k,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?h(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:b()}),jsx("text",{x:r+s/2+10,y:k,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:k,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:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(m=>m.name).join(", ").substring(0,30),a.assignees.map(m=>m.name).join(", ").length>30?"...":""]})]})]})})}function Zn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,lineStyle:n="curved",isHoverLayer:c=false}){let[g,i]=useState(false),[p,l]=useState(null),f=r-t,y=f>0,k=Math.abs(f)<5,h=5,b=20,u=!k&&a<=e,x,m;if(k)if(m=(e+a)/2,n==="squared")x=`M ${e} ${t} L ${a} ${r}`;else {let oe=Math.min(Math.abs(a-e)/3,30);x=`M ${e} ${t} C ${e+oe} ${t}, ${a-oe} ${r}, ${a} ${r}`;}else if(m=a-b,u){let re=e+15,ge=a-b,fe=y?t+20:t-20;m=ge,n==="squared"?x=`M ${e} ${t} L ${re} ${t} L ${re} ${fe} L ${ge} ${fe} L ${ge} ${r} L ${a} ${r}`:y?x=`M ${e} ${t} L ${re-h} ${t} Q ${re} ${t} ${re} ${t+h} L ${re} ${fe-h} Q ${re} ${fe} ${re-h} ${fe} L ${ge+h} ${fe} Q ${ge} ${fe} ${ge} ${fe+h} L ${ge} ${r-h} Q ${ge} ${r} ${ge+h} ${r} L ${a} ${r}`:x=`M ${e} ${t} L ${re-h} ${t} Q ${re} ${t} ${re} ${t-h} L ${re} ${fe+h} Q ${re} ${fe} ${re-h} ${fe} L ${ge+h} ${fe} Q ${ge} ${fe} ${ge} ${fe-h} L ${ge} ${r+h} Q ${ge} ${r} ${ge+h} ${r} L ${a} ${r}`;}else n==="squared"?x=`M ${e} ${t} L ${m} ${t} L ${m} ${r} L ${a} ${r}`:y?x=`M ${e} ${t} L ${m-h} ${t} Q ${m} ${t} ${m} ${t+h} L ${m} ${r-h} Q ${m} ${r} ${m+h} ${r} L ${a} ${r}`:x=`M ${e} ${t} L ${m-h} ${t} Q ${m} ${t} ${m} ${t-h} L ${m} ${r+h} Q ${m} ${r} ${m+h} ${r} L ${a} ${r}`;let N=5,w=`M ${a} ${r} L ${a-N} ${r-N*.5} M ${a} ${r} L ${a-N} ${r+N*.5}`,B=o.dependency,v=o.dependencyHover||B,I="#f87171",A="rgba(248, 113, 113, 0.15)",T=m,W=(t+r)/2;if(p)if(k)T=Math.max(e+10,Math.min(a-10,p.x)),W=t;else if(u){let oe=e+15,re=a-b,ge=y?t+20:t-20,fe=[[e,t,oe,t],[oe,t,oe,ge],[oe,ge,re,ge],[re,ge,re,r],[re,r,a,r]],Ie=1/0,M={x:T,y:W};for(let R of fe){let L=$(p.x,p.y,R[0],R[1],R[2],R[3]),V=Math.hypot(p.x-L.x,p.y-L.y);V<Ie&&(Ie=V,M=L);}T=M.x,W=M.y;}else {let oe=[[e,t,m,t],[m,t,m,r],[m,r,a,r]],re=1/0,ge={x:T,y:W};for(let fe of oe){let Ie=$(p.x,p.y,fe[0],fe[1],fe[2],fe[3]),M=Math.hypot(p.x-Ie.x,p.y-Ie.y);M<re&&(re=M,ge=Ie);}T=ge.x,W=ge.y;}function $(oe,re,ge,fe,Ie,M){let R=Ie-ge,L=M-fe,V=R*R+L*L;if(V===0)return {x:ge,y:fe};let q=((oe-ge)*R+(re-fe)*L)/V;return q=Math.max(0,Math.min(1,q)),{x:ge+q*R,y:fe+q*L}}let j=oe=>{let re=oe.currentTarget.ownerSVGElement;if(!re)return;let ge=re.getBoundingClientRect();l({x:oe.clientX-ge.left,y:oe.clientY-ge.top});},te=()=>{i(false),l(null);};return c?jsxs("g",{"data-dependency-line":"true",onMouseLeave:te,onMouseMove:j,children:[jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("path",{d:x,fill:"none",stroke:v,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:x,fill:"none",stroke:v,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:w,fill:"none",stroke:v,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:a,cy:r,r:4,fill:v,opacity:.9,style:{pointerEvents:"none"}}),s&&jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:oe=>{oe.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:T,cy:W,r:9,fill:A,stroke:I,strokeWidth:1.5}),jsx("line",{x1:T-3,y1:W-3,x2:T+3,y2:W+3,stroke:I,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:T+3,y1:W-3,x2:T-3,y2:W+3,stroke:I,strokeWidth:1.5,strokeLinecap:"round"})]})]}):jsxs("g",{"data-dependency-line":"true",onMouseEnter:()=>i(true),onMouseLeave:te,onMouseMove:j,style:{cursor:s?"pointer":"default"},children:[jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:16,strokeLinecap:"round",style:{cursor:s?"pointer":"default"}}),jsx(motion.path,{d:x,fill:"none",stroke:g?v:B,strokeWidth:g?2.5:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:1},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2}}}),jsx(motion.path,{d:w,fill:"none",stroke:g?v:B,strokeWidth:g?2.5:2,strokeLinecap:"round",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.3}}),jsx(motion.circle,{cx:a,cy:r,r:g?4:3,fill:g?v:B,initial:{scale:0},animate:{scale:1},transition:{delay:.3,duration:.15}}),g&&s&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.15},onClick:oe=>{oe.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:T,cy:W,r:9,fill:A,stroke:I,strokeWidth:1.5}),jsx("line",{x1:T-3,y1:W-3,x2:T+3,y2:W+3,stroke:I,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:T+3,y1:W-3,x2:T-3,y2:W+3,stroke:I,strokeWidth:1.5,strokeLinecap:"round"})]})]})}function es({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),c=16,g=i=>i.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{"data-task-bar":"true",onMouseEnter:()=>n(true),onMouseLeave:()=>n(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:g(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 he={calculateEndDate:(e,t)=>{let a=new Date(e);return a.setDate(a.getDate()+t),a},calculateDuration:(e,t)=>{let a=t.getTime()-e.getTime();return Math.ceil(a/(1e3*60*60*24))},calculateWorkingDays:(e,t)=>{let a=0,r=new Date(e);for(;r<=t;){let o=r.getDay();o!==0&&o!==6&&a++,r.setDate(r.getDate()+1);}return a},addWorkingDays:(e,t)=>{let a=new Date(e),r=0;for(;r<t;){a.setDate(a.getDate()+1);let o=a.getDay();o!==0&&o!==6&&r++;}return a},isWeekend:e=>{let t=e.getDay();return t===0||t===6},validateDependencies:(e,t,a)=>{let r=new Map,o=i=>{i.forEach(p=>{p.dependencies&&r.set(p.id,p.dependencies),p.subtasks&&o(p.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let n=new Set,c=new Set,g=i=>{if(!n.has(i)){n.add(i),c.add(i);let p=r.get(i)||[];for(let l of p){if(!n.has(l)&&g(l))return true;if(c.has(l))return true}}return c.delete(i),false};return g(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=he.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=he.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=he.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=he.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 ki({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null);useEffect(()=>{function i(p){s.current&&!s.current.contains(p.target)&&n.current&&!n.current.contains(p.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let c=i=>{t(i),o(false);},g=e.reduce((i,p)=>{let l=p.category||"Other";return i[l]||(i[l]=[]),i[l].push(p),i},{});return jsxs("div",{className:d("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg border transition-all text-sm font-medium shadow-lg",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",i.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",i.currentTarget.style.borderColor="var(--theme-border-primary)";},title:"Create from template",children:[jsx("span",{className:"text-base leading-none",children:"\u{1F4CB}"}),jsx("span",{children:"Templates"}),jsx("svg",{className:d("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(g).map(([i,p])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:i})}),jsx("div",{children:p.map(l=>jsxs("button",{onClick:()=>c(l),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:l.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:l.name}),l.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:l.description})]})]},l.id))})]},i)),e.length===0&&jsx("div",{className:"px-4 py-8 text-center",style:{color:"var(--theme-text-tertiary)"},children:jsx("p",{className:"text-sm",children:"No templates available"})})]})]})}function Ci({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,c]=useState("export"),[g,i]=useState("json"),[p,l]=useState(null),f=useRef(null);if(!t)return null;let y=async()=>{let C=o?.current||void 0,h=await ud(e,g,C);gd(h,g);},k=async C=>{let h=C.target.files?.[0];if(h){try{let b=await hd(h),u=h.name.endsWith(".json")?"json":"csv",x=bd(b,u);l(x),x.success&&r&&r(x,b);}catch(b){l({success:false,errors:[`Failed to read file: ${b instanceof Error?b.message:"Unknown error"}`]});}f.current&&(f.current.value="");}};return jsxs("div",{className:d("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:d("flex-1 px-6 py-4 font-semibold transition-colors",n==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:d("flex-1 px-6 py-4 font-semibold transition-colors",n==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[n==="export"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Select format"}),jsx("div",{className:"grid grid-cols-3 gap-3",children:["json","csv","pdf"].map(C=>jsxs("button",{onClick:()=>i(C),className:d("p-4 rounded-lg border-2 transition-all text-center",g===C?"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:[C==="json"&&"\u{1F4C4}",C==="csv"&&"\u{1F4CA}",C==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:C})]},C))})]}),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:y,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),n==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:f,type:"file",accept:".json,.csv",onChange:k,className:"hidden"}),jsxs("button",{onClick:()=>f.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),p&&jsxs("div",{className:d("p-4 rounded-lg",p.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:d("font-semibold mb-2",p.success?"text-green-400":"text-red-400"),children:p.success?"\u2713 Import Successful":"\u2717 Import Failed"}),p.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",p.cardsImported]}),jsxs("div",{children:["Columns imported: ",p.columnsImported]})]}),p.errors&&p.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:p.errors.map((C,h)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",C]},h))})]})]})]})]})]})}var w0=["URGENT","HIGH","MEDIUM","LOW"],C0=[{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"}],T0=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ti({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:c,availableUsers:g=[],availableLabels:i=[],availableColumns:p=[],showQuickFilters:l=true,compact:f=false,groupBy:y="none",onGroupByChange:k}){let[C,h]=useState(true),b=useCallback(w=>{a({search:w.target.value});},[a]),u=useCallback(w=>{a({dateFilter:w.target.value});},[a]),x=useCallback(w=>{r({by:w.target.value});},[r]),m=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),N=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 ${f?"filter-bar--compact":""} ${C?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>h(!C),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:C?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:w=>{w.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:w=>{w.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:C?"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"}),N&&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)"]})]}),!C&&jsxs("div",{className:"filter-bar__content",children:[l&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),n&&jsx("button",{onClick:n,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:b,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:u,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:w=>{let B=w.target.value;a({priorities:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),w0.map(w=>jsx("option",{value:w,children:w},w))]})}),g.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:w=>{let B=w.target.value;a({assignees:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),g.map(w=>jsx("option",{value:w.id,children:w.name},w.id))]})}),i.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:w=>{let B=w.target.value;a({labels:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),i.map(w=>jsx("option",{value:w,children:w},w))]})}),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:x,className:"filter-bar__select filter-bar__select--sm",children:C0.map(w=>jsx("option",{value:w.value,children:w.label},w.value))}),t.by!=="none"&&jsx("button",{onClick:m,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),k&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:y,onChange:w=>k(w.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:T0.map(w=>jsx("option",{value:w.value,children:w.label},w.value))})}),N&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Ni({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:c,onExportGanttCSV:g}){let[i,p]=useState(false),l=useRef(null);useEffect(()=>{let y=k=>{l.current&&!l.current.contains(k.target)&&p(false);};return i&&document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y);}},[i]);let f=y=>{y(),p(false);};return jsxs("div",{className:d("relative",r),ref:l,children:[jsxs("button",{onClick:()=>p(!i),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",y.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",y.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":i,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"3"}),jsx("path",{d:"M12 1v6m0 6v6M5.6 5.6l4.2 4.2m4.2 4.2l4.2 4.2M1 12h6m6 0h6M5.6 18.4l4.2-4.2m4.2-4.2l4.2-4.2"})]}),jsx("span",{children:"Config"})]}),i&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(async()=>await n?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(()=>g?.()),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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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:()=>f(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:y=>{y.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:y=>{y.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 Di={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"}},Si={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"}},Ei={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"}},mo={dark:Di,light:Si,neutral:Ei},Un="dark";var zn=createContext(void 0),I0="asakaa-theme";function Ac({children:e,defaultTheme:t=Un,storageKey:a=I0}){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,g=mo[r];Object.entries(g.colors).forEach(([p,l])=>{l&&c.style.setProperty(`--theme-${B0(p)}`,l);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([p,l])=>{let f=g.colors[p];f&&c.style.setProperty(l,f);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let n={theme:r,setTheme:s,themes:mo};return jsx(zn.Provider,{value:n,children:e})}function Ao(){let e=useContext(zn);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function B0(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Pi({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=Ao();return e?jsxs("div",{className:d("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(mo).map(([s,n])=>jsxs("button",{onClick:()=>{o(s),t();},className:d("w-full p-4 rounded-lg border-2 transition-all flex items-center gap-4",r===s?"border-blue-500 bg-blue-500/20":"border-white/20 hover:border-white/40"),style:{backgroundColor:r===s?"var(--theme-accent-primary)20":"transparent"},children:[jsx("div",{className:"text-3xl",children:n.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:n.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Fc(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return at[e]||at.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",at[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",at[e].bgSecondary),bgGrid:r("--theme-bg-card",at[e].bgGrid),bgWeekend:r("--theme-bg-hover",at[e].bgWeekend),border:r("--theme-border-primary",at[e].border),borderLight:r("--theme-border-subtle",at[e].borderLight),textPrimary:r("--theme-text-primary",at[e].textPrimary),textSecondary:r("--theme-text-secondary",at[e].textSecondary),textTertiary:r("--theme-text-tertiary",at[e].textTertiary),accent:r("--theme-accent-primary",at[e].accent),accentHover:r("--theme-accent-hover",at[e].accentHover),accentLight:r("--theme-accent-primary",at[e].accentLight),taskBarPrimary:r("--theme-accent-primary",at[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",at[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",at[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",at[e].dependency),dependencyHover:r("--theme-border-secondary",at[e].dependencyHover),criticalPath:r("--theme-error",at[e].criticalPath),criticalPathLight:r("--theme-error",at[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",at[e].today):e==="neutral"?r("--theme-text-primary",at[e].today):r("--theme-error",at[e].today),todayLight:e==="light"?r("--theme-accent-primary",at[e].todayLight):e==="neutral"?r("--theme-text-primary",at[e].todayLight):r("--theme-error",at[e].todayLight),milestone:r("--theme-warning",at[e].milestone),milestoneLight:r("--theme-warning",at[e].milestoneLight),statusTodo:r("--theme-text-tertiary",at[e].statusTodo),statusInProgress:r("--theme-accent-primary",at[e].statusInProgress),statusCompleted:r("--theme-success",at[e].statusCompleted),hoverBg:r("--theme-bg-hover",at[e].hoverBg),focusRing:r("--theme-accent-primary",at[e].focusRing)}}var Hn={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious",filterAll:"All",filterIncomplete:"Incomplete",filterInProgress:"In Progress",filterCompleted:"Completed",filter:"Filters",filterBy:"FILTER BY STATUS",filterAllDesc:"Show all tasks",filterIncompleteDesc:"Hide completed tasks",filterInProgressDesc:"Tasks currently being worked on",filterCompletedDesc:"Only show finished tasks",clearFilter:"Clear filter",hideCompleted:"Hide Completed Tasks",toDo:"To Do / Pending"},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",week:"Week",clickToSetDates:"Click to set dates..."},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"}},Lc={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso",filterAll:"Todas",filterIncomplete:"Sin completar",filterInProgress:"En progreso",filterCompleted:"Completadas",filter:"Filtros",filterBy:"FILTRAR POR ESTADO",filterAllDesc:"Mostrar todas las tareas",filterIncompleteDesc:"Ocultar tareas completadas",filterInProgressDesc:"Tareas en las que se est\xE1 trabajando",filterCompletedDesc:"Solo mostrar tareas terminadas",clearFilter:"Limpiar filtro",hideCompleted:"Ocultar Tareas Completadas",toDo:"Por Hacer / Pendiente"},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",week:"Semana",clickToSetDates:"Clic para establecer fechas..."},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"}},Mi={en:Hn,es:Lc};function Ic(e){return Mi[e]||Mi.en}function Ai(e,t){let a=Ic(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 Lo=createContext(Hn);function Vr(){return useContext(Lo)}function ab({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[c,g]=useState(false),[i,p]=useState(null),l=useRef(null),f=Vr();if(useEffect(()=>{let h=b=>{l.current&&!l.current.contains(b.target)&&g(false);};return c&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[c]),!(t||a||r||o||s||n))return null;let k=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:n}].filter(h=>h.handler),C=async(h,b)=>{if(b){p(h);try{await b();}catch(u){console.error(`Export ${h} failed:`,u);}finally{p(null),g(false);}}};return jsxs("div",{ref:l,className:"relative",children:[jsxs(motion.button,{onClick:()=>g(!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:f.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:k.map((h,b)=>jsxs(motion.button,{onClick:()=>C(h.id,h.handler),disabled:i!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:b<k.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:b*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:i===h.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):h.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:h.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:h.description})]})]},h.id))})})})]})}function rb({options:e,value:t,onChange:a,theme:r,layoutId:o="activeSegment"}){return jsx("div",{className:"inline-flex p-1 rounded-lg relative",style:{backgroundColor:r.bgSecondary,border:`1px solid ${r.borderLight}`},children:e.map(s=>{let n=t===s.value;return jsxs(motion.button,{onClick:()=>a(s.value),className:"relative px-3 py-1.5 rounded-md text-xs transition-all flex items-center gap-1.5 min-w-[70px] justify-center",style:{color:n?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:n?600:500,zIndex:n?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[n&&jsx(motion.div,{layoutId:o,className:"absolute inset-0 rounded-md",style:{backgroundColor:r.accent,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},transition:{type:"spring",stiffness:400,damping:30}}),s.icon&&jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function ob({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 nb({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=Vr();useEffect(()=>{let i=p=>{s.current&&!s.current.contains(p.target)&&o(false);};return r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let c=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],g=c.find(i=>i.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${n.toolbar.density||"Density"}: ${g}`,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((i,p)=>{let l=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:l?e.accentLight:"transparent",borderBottom:p<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:l?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:p*.03},children:[jsx("span",{className:"text-xs",style:{color:l?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500},children:i.label}),l&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},i.value)})})})})]})}function sb({theme:e,value:t,onChange:a,hideCompleted:r=false,onHideCompletedChange:o}){let[s,n]=useState(false),c=useRef(null),g=Vr();useEffect(()=>{if(!s)return;let f=setTimeout(()=>{let y=C=>{c.current&&!c.current.contains(C.target)&&n(false);},k=C=>{C.key==="Escape"&&n(false);};document.addEventListener("mousedown",y),document.addEventListener("keydown",k),c._cleanup=()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",k);};},100);return ()=>{clearTimeout(f),c._cleanup&&c._cleanup();}},[s]);let i=[{value:"all",label:g.toolbar.filterAll||"Show All",icon:jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#3B82F6] bg-[#3B82F6]"}),color:"text-[#3B82F6]"},{value:"completed",label:g.toolbar.filterCompleted||"Completed",icon:jsx(CheckCircle2,{className:"w-4 h-4"}),color:"text-green-500"},{value:"in_progress",label:g.toolbar.filterInProgress||"In Progress",icon:jsx(PlayCircle,{className:"w-4 h-4"}),color:"text-blue-500"},{value:"incomplete",label:g.toolbar.toDo||"To Do / Pending",icon:jsx(Circle,{className:"w-4 h-4"}),color:"text-gray-400"}],p=t!=="all"||r,l=e.bgPrimary==="#0F1117"||e.bgPrimary==="#0a0a0a"||e.textPrimary==="#FFFFFF";return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:f=>{f.stopPropagation(),n(y=>!y);},className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:p?l?"rgba(59, 130, 246, 0.2)":"rgb(239 246 255)":s?e.hoverBg:e.bgSecondary,border:`1px solid ${p?l?"rgba(59, 130, 246, 0.5)":"rgb(191 219 254)":e.borderLight}`,color:p?"#3B82F6":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},children:[jsx(Filter,{className:"w-4 h-4"}),jsx("span",{children:g.toolbar.filter||"Filters"}),p&&jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:"#3B82F6"}})]}),jsx(AnimatePresence,{children:s&&jsxs(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-72 rounded-lg overflow-hidden z-50",style:{backgroundColor:l?"#0F1117":"#FFFFFF",border:`1px solid ${l?"rgba(255,255,255,0.1)":"rgb(229 231 235)"}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:[jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:l?"rgba(255,255,255,0.1)":"rgb(229 231 235)"},children:jsx("span",{className:"text-xs font-medium uppercase tracking-wider",style:{color:l?"#6B7280":"#9CA3AF"},children:g.toolbar.filterBy||"FILTER BY STATUS"})}),jsx("div",{className:"py-2",children:i.map(f=>{let y=t===f.value&&!r,k=()=>f.value==="all"?y?jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#3B82F6] bg-[#3B82F6]"}):jsx("div",{className:"w-4 h-4 rounded-full border-2 border-gray-400"}):f.icon;return jsxs(motion.button,{onClick:()=>{a(f.value),o&&o(false);},className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors",style:{backgroundColor:y?l?"rgba(255,255,255,0.05)":"rgb(249 250 251)":"transparent"},whileHover:{backgroundColor:l?"rgba(255,255,255,0.1)":"rgb(243 244 246)"},children:[jsx("span",{className:`${y?f.color:"text-gray-400"} flex-shrink-0`,children:k()}),jsx("span",{className:"flex-1 text-left whitespace-nowrap",style:{color:l?"#FFFFFF":"#111827"},children:f.label}),y&&jsx(Check,{className:"w-4 h-4 flex-shrink-0",style:{color:l?"#3B82F6":"#2563EB"}})]},f.value)})}),jsx("div",{className:"my-2 mx-4 h-px",style:{backgroundColor:l?"rgba(255,255,255,0.1)":"rgb(229 231 235)"}}),o&&jsx("div",{className:"py-1",children:jsxs(motion.button,{onClick:()=>{o(!r),r||a("all");},className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors",style:{backgroundColor:r?l?"rgba(255,255,255,0.05)":"rgb(249 250 251)":"transparent"},whileHover:{backgroundColor:l?"rgba(255,255,255,0.1)":"rgb(243 244 246)"},children:[jsx(EyeOff,{className:"w-4 h-4 flex-shrink-0",style:{color:r?l?"#3B82F6":"#2563EB":l?"#6B7280":"#9CA3AF"}}),jsx("span",{className:"flex-1 text-left whitespace-nowrap",style:{color:l?"#FFFFFF":"#111827"},children:g.toolbar.hideCompleted||"Hide Completed Tasks"}),r&&jsx(Check,{className:"w-4 h-4 flex-shrink-0",style:{color:l?"#3B82F6":"#2563EB"}})]})})]})})]})}function Gn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:c,onRowDensityChange:g,showThemeSelector:i=false,showCreateTaskButton:p=false,createTaskLabel:l,onCreateTask:f,taskFilter:y="all",onTaskFilterChange:k,hideCompleted:C=false,onHideCompletedChange:h,onExportPNG:b,onExportPDF:u,onExportExcel:x,onExportCSV:m,onExportJSON:N,onExportMSProject:w}){let B=Vr(),v=b||u||x||m||N||w,I=[{value:"day",label:B.toolbar.day},{value:"week",label:B.toolbar.week},{value:"month",label:B.toolbar.month}],F=[{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(ob,{options:I,value:t,onChange:T=>a(T),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(nb,{theme:e,value:c,onChange:g}),k&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(sb,{theme:e,value:y,onChange:k,hideCompleted:C,onHideCompletedChange:h})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[p&&f&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:f,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:l||B.toolbar.createTask})]}),(v||i)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),v&&jsxs(Fragment,{children:[jsx(ab,{theme:e,onExportPNG:b,onExportPDF:u,onExportExcel:x,onExportCSV:m,onExportJSON:N,onExportMSProject:w}),i&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),i&&jsx(rb,{options:F,value:s,onChange:T=>n(T),theme:e})]})]})}function _n({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),c=useRef(null),g=useRef(null);useEffect(()=>{if(!r)return;let p=l=>{c.current&&!c.current.contains(l.target)&&o(false);};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r]);let i=e.filter(p=>p.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:g,onClick:()=>{if(!r&&g.current){let p=g.current.getBoundingClientRect();n({x:p.left,y:p.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(ft,{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"}),i.map(p=>jsxs("button",{onClick:()=>{t(p.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:l=>{l.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:p.label}),p.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},p.id))]})})})})]})}function Io({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[c,g]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let p=200,l=r.length*36+8,f=8,y=window.innerWidth,k=window.innerHeight,C=t,h=a;t+p+f>y&&(C=t-p,C<f&&(C=f)),a+l+f>k&&(h=k-l-f,h<f&&(h=f)),g({x:C,y:h});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let p=f=>{n.current&&!n.current.contains(f.target)&&o();},l=f=>{f.key==="Escape"&&o();};return document.addEventListener("mousedown",p),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",l);}},[e,o]),!e)return null;let i=p=>p.startsWith("#")&&(p.length===7||p.length===4)?p:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:n,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:i(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(p=>jsxs("div",{children:[p.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{p.disabled||(p.onClick(),o());},disabled:p.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:p.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:p.disabled?"not-allowed":"pointer",opacity:p.disabled?.5:1},onMouseEnter:l=>{p.disabled||(l.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent";},children:[p.icon&&jsx("span",{style:{color:s.textSecondary},children:p.icon}),jsx("span",{className:"flex-1",children:p.label}),p.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},p.id))})})})}var Gt={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 Gc({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:c,onTaskOutdent:g,onTaskRename:i,onTaskToggleExpand:p,onOpenTaskModal:l,enableKeyboard:f=true}){let y=useRef(false),k=useCallback(x=>{y.current=x;},[]),C=useCallback(x=>{let m=[],N=w=>{for(let B of w)m.push(B),B.subtasks&&B.subtasks.length>0&&B.isExpanded&&N(B.subtasks);};return N(x),m},[]),h=useCallback(()=>{let x=C(e);for(let m of x)if(t.has(m.id))return m;return null},[e,t,C]),b=useCallback((x,m)=>{let N=C(e);if(N.length===0)return;let w=h();if(!w){a(N[0].id,false);return}let B=N.findIndex(F=>F.id===w.id);if(B===-1)return;let v=x==="up"?B-1:B+1;if(v<0||v>=N.length)return;let I=N[v];a(I.id,m);},[e,h,C,a]),u=useCallback(x=>{if(!f)return;let m=x.target;if(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.isContentEditable||y.current){x.key==="Escape"&&(m.blur(),y.current=false);return}let B=navigator.platform.toUpperCase().indexOf("MAC")>=0?x.metaKey:x.ctrlKey,v=Array.from(t),I=h();if(x.key==="ArrowUp"){x.preventDefault(),b("up",x.shiftKey);return}if(x.key==="ArrowDown"){x.preventDefault(),b("down",x.shiftKey);return}if(I&&(x.key==="ArrowRight"||x.key==="ArrowLeft")){I.subtasks&&I.subtasks.length>0&&(x.preventDefault(),(x.key==="ArrowRight"&&!I.isExpanded||x.key==="ArrowLeft"&&I.isExpanded)&&p(I.id));return}if(x.altKey&&(x.key==="ArrowUp"||x.key==="ArrowDown")){v.length>0&&(x.preventDefault(),n(v,x.key==="ArrowUp"?"up":"down"));return}if(x.key==="Tab"&&!x.shiftKey){v.length>0&&(x.preventDefault(),c(v));return}if(x.key==="Tab"&&x.shiftKey){v.length>0&&(x.preventDefault(),g(v));return}if(x.key==="Enter"&&!x.shiftKey&&!B){I&&(x.preventDefault(),r(I.id,"below"));return}if(x.key==="Enter"&&x.shiftKey&&!B){I&&(x.preventDefault(),r(I.id,"above"));return}if(x.key==="Enter"&&B){I&&(x.preventDefault(),l(I.id));return}if(x.key==="F2"){I&&(x.preventDefault(),i(I.id));return}if(x.key==="Delete"||x.key==="Backspace"&&B){v.length>0&&(x.preventDefault(),o(v));return}if(x.key==="d"&&B&&!x.shiftKey){v.length>0&&(x.preventDefault(),s(v));return}},[f,t,h,b,r,o,s,n,c,g,i,p,l]);return useEffect(()=>{if(f)return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[f,u]),{setIsEditing:k}}function Vc(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(l=>{t(new Set([l])),r(l);},[]),s=useCallback(l=>{t(f=>{let y=new Set(f);return y.has(l)?y.delete(l):y.add(l),y}),r(l);},[]),n=useCallback((l,f)=>{if(!a){o(l);return}let y=f.indexOf(a),k=f.indexOf(l);if(y===-1||k===-1){o(l);return}let C=Math.min(y,k),h=Math.max(y,k),b=f.slice(C,h+1);t(new Set(b)),r(l);},[a,o]),c=useCallback((l,f,y,k)=>{k?n(l,f):y?s(l):o(l);},[o,s,n]),g=useCallback((l,f)=>{f?t(y=>{let k=new Set(y);return k.add(l),k}):o(l);},[o]),i=useCallback(()=>{t(new Set),r(null);},[]),p=useCallback(l=>e.has(l),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:n,handleTaskClick:c,handleKeyboardSelection:g,clearSelection:i,isTaskSelected:p}}function Bo(e){let t=[],a=(r,o,s=0)=>{for(let n=0;n<r.length;n++){let c={...r[n],parentId:o,level:s,position:n};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function jc(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=jc(a.subtasks,t);if(r)return r}}return null}function $i(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=$i(a.subtasks,t);if(r)return r}return null}function Ui(e,t){if(t.length===0)return e;let a=Bo(e),r=t[0],o=a.findIndex(l=>l.id===r);if(o<=0)return e;let s=a[o-1],n=(l,f)=>{let y=[];return {tasks:l.filter(C=>{if(f.has(C.id))return y.push(C),false;if(C.subtasks){let h=n(C.subtasks,f);C.subtasks=h.tasks,y.push(...h.removed);}return true}),removed:y}},c=(l,f,y)=>l.map(k=>k.id===f?{...k,subtasks:[...k.subtasks||[],...y],isExpanded:true}:k.subtasks?{...k,subtasks:c(k.subtasks,f,y)}:k),g=new Set(t),{tasks:i,removed:p}=n(e,g);return c(i,s.id,p)}function zi(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=$i(a,r);if(!o)continue;let s=$i(a,o.id),n=(i,p,l)=>{for(let f=0;f<i.length;f++){let y=i[f];if(y.id===p&&y.subtasks){let k=y.subtasks.findIndex(C=>C.id===l);if(k!==-1){let[C]=y.subtasks.splice(k,1);return C}}if(y.subtasks){let k=n(y.subtasks,p,l);if(k)return k}}return null},c=(i,p,l)=>{let f=i.findIndex(y=>y.id===p);if(f!==-1)return i.splice(f+1,0,l),i;for(let y of i)y.subtasks&&c(y.subtasks,p,l);return i},g=n(a,o.id,r);g&&(s&&s.subtasks?c(s.subtasks,o.id,g):c(a,o.id,g));}return a}function Hi(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,c,g)=>{let i=n.findIndex(l=>l.id===c);if(i===-1){for(let l of n)if(l.subtasks&&s(l.subtasks,c,g))return true;return false}let p=g==="up"?i-1:i+1;return p<0||p>=n.length?false:([n[i],n[p]]=[n[p],n[i]],true)};return s(r,o,a),r}function Wi(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 Gi(e,t){let a=[...e];for(let r of t){let o=n=>{let c=n.findIndex(p=>p.id===r);if(c===-1){for(let p of n)if(p.subtasks&&o(p.subtasks))return true;return false}let g=n[c],i={...g,id:`${g.id}-copy-${Date.now()}`,name:`${g.name} (Copy)`,subtasks:g.subtasks?s(g.subtasks):void 0};return n.splice(c+1,0,i),true},s=n=>n.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function Kc(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=g=>{let i=g.findIndex(l=>l.id===t);if(i===-1){for(let l of g)if(l.subtasks&&c(l.subtasks))return true;return false}let p=a==="above"?i:i+1;return g.splice(p,0,n),true};return c(r),{tasks:r,newTask:n}}function _i(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:_i(r.subtasks,t,a)}:r)}function Vi(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:Vi(a.subtasks,t)}:a)}function ji(e,t){let a=p=>{for(let l of p){if(l.id===t)return l;if(l.subtasks){let f=a(l.subtasks);if(f)return f}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n=r?.startDate||o,c=r?.endDate||s,g={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(c),color:r?.color||"#3B82F6"},i=p=>p.map(l=>{if(l.id===t){let f=l.subtasks||[];return {...l,subtasks:[...f,g],isExpanded:true}}return l.subtasks?{...l,subtasks:i(l.subtasks)}:l});return {tasks:i(e),newTask:g}}function Yc(e,t,a,r){if(t===a)return e;let o=jc(e,t);if(!o)return e;if(a){let c=(g,i)=>{if(!g.subtasks)return false;for(let p of g.subtasks)if(p.id===i||c(p,i))return true;return false};if(c(o,a))return e}let s=c=>c.filter(g=>g.id!==t).map(g=>g.subtasks&&g.subtasks.length>0?{...g,subtasks:s(g.subtasks)}:g),n=s(e);if(a===null){let c=r!==void 0?r:n.length;n.splice(c,0,{...o,parentId:void 0});}else {let c=g=>g.map(i=>{if(i.id===a){let p=i.subtasks||[],l=r!==void 0?r:p.length,f=[...p];return f.splice(l,0,{...o,parentId:a}),{...i,subtasks:f,isExpanded:true}}return i.subtasks&&i.subtasks.length>0?{...i,subtasks:c(i.subtasks)}:i});n=c(n);}return n}function Kn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:c,onTaskToggle:g,scrollTop:i,columns:p,onToggleColumn:l,onColumnResize:f,onTaskUpdate:y,onTaskIndent:k,onTaskOutdent:C,onTaskMove:h,onMultiTaskDelete:b,onTaskDuplicate:u,onTaskCreate:x,onTaskRename:m,onCreateSubtask:N,onOpenTaskModal:w,onDeleteRequest:B,onTaskReparent:v}){let I=useContext(Lo),[F,T]=useState(null),[H,O]=useState(null),[K,ae]=useState(""),ne=useRef(null),[oe,ye]=useState(null),[fe,Re]=useState(0),[A,R]=useState(0),[L,j]=useState({isOpen:false,x:0,y:0,type:"header"}),[J,U]=useState(null),[ge,le]=useState(null),[Fe,qe]=useState(null),et=useRef(0),de=5,Ke=useRef(false),[dt,vt]=useState(null),[kt,$]=useState(false),[me,Le]=useState(null),[Se,Ye]=useState(false),Je=useRef(null);useEffect(()=>{function _(Y){Je.current&&!Je.current.contains(Y.target)&&Ye(false);}if(Se)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[Se]),useEffect(()=>{H&&ne.current&&(ne.current.focus(),ne.current.select());},[H]),useEffect(()=>{if(!oe)return;let _=be=>{let je=be.clientX-fe,Ie=A+je;f?.(oe,Ie);},Y=()=>{ye(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",Y),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",Y),document.body.style.cursor="",document.body.style.userSelect="";}},[oe,fe,A,f]);let{selectedTaskIds:Pt,handleTaskClick:Oe,isTaskSelected:Z}=Vc(),{setIsEditing:xe}=Gc({tasks:e,selectedTaskIds:Pt,onTaskSelect:(_,Y)=>{let je=Bo(e).map(Ie=>Ie.id);Oe(_,je,Y||false,false);},onTaskCreate:x||(()=>{}),onTaskDelete:b||(()=>{}),onTaskDuplicate:u||(()=>{}),onTaskMove:h||(()=>{}),onTaskIndent:k||(()=>{}),onTaskOutdent:C||(()=>{}),onTaskRename:_=>{let Y=Bo(e).find(be=>be.id===_);Y&&Vt(Y);},onTaskToggleExpand:g||(()=>{}),onOpenTaskModal:_=>{let Y=Bo(e).find(be=>be.id===_);Y&&w&&w(Y);},enableKeyboard:true}),ze=(_,Y=0)=>{let be=[];for(let je of _)be.push({task:je,level:Y}),je.subtasks&&je.subtasks.length>0&&je.isExpanded&&be.push(...ze(je.subtasks,Y+1));return be},Be=ze(e),st=48,nt=Math.max(Be.length*a,600-st),Ve=_=>!_.startDate||!_.endDate?"-":`${Math.ceil((_.endDate.getTime()-_.startDate.getTime())/(1e3*60*60*24))}d`,Vt=_=>{O(_.id),ae(_.name),xe(true);},Bt=_=>{K.trim()&&K!==e.find(Y=>Y.id===_)?.name&&m?.(_,K.trim()),O(null),ae(""),xe(false);},Ze=()=>{O(null),ae(""),xe(false);},te=(_,Y)=>{Y.stopPropagation(),N?.(_.id);},S=(_,Y)=>{Y.preventDefault(),et.current=Y.clientY,U(_),Ke.current=false,$(false),vt({x:Y.clientX,y:Y.clientY});},Ce=_=>{if(!J||(Math.abs(_.clientY-et.current)>de&&!Ke.current&&(Ke.current=true,$(true)),vt({x:_.clientX,y:_.clientY}),!Ke.current))return;let be=document.querySelectorAll("[data-task-row]"),je=null,Ie=null;be.forEach(z=>{let se=z.getBoundingClientRect(),We=z.getAttribute("data-task-row");if(We&&We!==J&&_.clientY>=se.top&&_.clientY<=se.bottom){je=We;let Nt=_.clientY-se.top,mt=se.height;Nt<mt*.25?Ie="above":Nt>mt*.75?Ie="below":Ie="child";}}),le(je),qe(Ie);},X=()=>{if(Ke.current&&J&&ge&&Fe){if(Fe==="child")v?.(J,ge);else if(Fe==="above"||Fe==="below"){let _=(je,Ie,z=null)=>{for(let se of je){if(se.id===Ie)return z;if(se.subtasks){let We=_(se.subtasks,Ie,se.id);if(We!==void 0)return We}}},Y=_(e,ge,null),be=(je,Ie)=>{let z=je.findIndex(se=>se.id===Ie);return Fe==="below"?z+1:z};if(Y===null){let je=be(e,ge);v?.(J,null,je);}else {let je=Be.find(Ie=>Ie.task.id===Y)?.task;if(je?.subtasks){let Ie=be(je.subtasks,ge);v?.(J,Y,Ie);}}}}U(null),le(null),qe(null),vt(null),Ke.current=false,$(false);};useEffect(()=>{if(J)return document.addEventListener("mousemove",Ce),document.addEventListener("mouseup",X),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Ce),document.removeEventListener("mouseup",X),document.body.style.cursor="",document.body.style.userSelect="";}},[J,ge,Fe]);let we=(_,Y,be)=>{switch(_.id){case "name":let je=H===Y.id,Ie=F===Y.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${be*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:Ie?1:.3},onMouseDown:W=>S(Y.id,W),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),Y.subtasks&&Y.subtasks.length>0?jsx("button",{onClick:W=>{W.stopPropagation(),g?.(Y.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:Y.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:Y.color||"#3B82F6",opacity:Y.parentId?.6:1,borderColor:Y.isMilestone?t.accent:"transparent",borderWidth:Y.isMilestone?"2px":"0px"},title:Y.isMilestone?"Milestone":Y.parentId?"Subtask":"Task"})}),je?jsx("input",{ref:ne,type:"text",value:K,onChange:W=>ae(W.target.value),onKeyDown:W=>{W.key==="Enter"?Bt(Y.id):W.key==="Escape"&&Ze();},onBlur:()=>Bt(Y.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:W=>W.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:Y.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:Y.parentId?"13px":"14px",fontWeight:Y.isMilestone?600:Y.parentId?400:600,letterSpacing:Y.parentId?"0":"-0.01em"},title:Y.name,children:Y.name}),Ie&&!je&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:W=>W.stopPropagation(),children:[jsx("button",{onClick:W=>te(Y,W),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:W=>{W.stopPropagation(),Vt(Y);},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 se=_.id==="startDate"?"startDate":"endDate",We=Y[se],Nt=me?.taskId===Y.id&&me?.field===se,mt=W=>W?(typeof W=="string"?new Date(W):W).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:W=>W.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:W=>{if(Nt)Le(null);else {let Ee=W.currentTarget.getBoundingClientRect();Le({taskId:Y.id,field:se,month:We?typeof We=="string"?new Date(We):We:new Date,position:{top:Ee.bottom+4,left:Ee.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:mt(We)})]}),Nt&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>Le(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:me?.position.top,left:me?.position.left},onClick:W=>W.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let W=new Date,Ee=new Date(W);Ee.setDate(W.getDate()+1);let Pe=new Date(W);Pe.setDate(W.getDate()+7);let $t=new Date(W);return $t.setDate(W.getDate()+14),[{label:"Hoy",date:W},{label:"Ma\xF1ana",date:Ee},{label:"Pr\xF3xima semana",date:Pe},{label:"2 semanas",date:$t}].map((Ge,yt)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:Ue=>Ue.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:Ue=>Ue.currentTarget.style.backgroundColor="transparent",onClick:()=>{y?.(Y.id,{[se]:Ge.date}),Le(null);},children:Ge.label},yt))})(),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:W=>W.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{y?.(Y.id,{[se]:void 0}),Le(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:()=>Le(W=>W?{...W,month:new Date(W.month.getFullYear(),W.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:me?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>Le(W=>W?{...W,month:new Date(W.month.getFullYear(),W.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((W,Ee)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:W},Ee))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let W=me?.month||new Date,Ee=W.getFullYear(),Pe=W.getMonth(),$t=new Date(Ee,Pe,1).getDay(),ie=new Date(Ee,Pe+1,0).getDate(),Ge=new Date,yt=[];for(let gt=$t-1;gt>=0;gt--)yt.push({day:new Date(Ee,Pe,-gt).getDate(),date:new Date(Ee,Pe-1,new Date(Ee,Pe,-gt).getDate()),isCurrentMonth:false});for(let gt=1;gt<=ie;gt++)yt.push({day:gt,date:new Date(Ee,Pe,gt),isCurrentMonth:true});let Ue=42-yt.length;for(let gt=1;gt<=Ue;gt++)yt.push({day:gt,date:new Date(Ee,Pe+1,gt),isCurrentMonth:false});return yt.map((gt,ya)=>{let ka=gt.date.toDateString()===Ge.toDateString(),Xe=(We?typeof We=="string"?new Date(We):We:null)?.toDateString()===gt.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:gt.isCurrentMonth?Xe?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Xe?"#3B82F6":"transparent",boxShadow:ka&&!Xe?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{y?.(Y.id,{[se]:gt.date}),Le(null);},children:gt.day},ya)})})()})]})]})]}),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:Ve(Y)})});case "assignees":let Dr=r.filter(W=>Y.assignees?.some(Ee=>Ee.name===W.name||Ee.initials===W.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:W=>W.stopPropagation(),children:jsx(oo,{assignedUsers:Dr,availableUsers:r,onChange:W=>{let Ee=W.map(Pe=>({id:Pe.id,name:Pe.name,initials:Pe.initials,color:Pe.color}));y?.(Y.id,{assignees:Ee.length>0?Ee:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:W=>W.stopPropagation(),children:jsx(Rd,{status:Y.status||"todo",onChange:W=>{y?.(Y.id,{status:W,progress:W==="completed"?100:Y.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:`${Y.progress}%`,backgroundColor:Y.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:[Y.progress,"%"]})]});case "priority":let fr={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},$a={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},M=fr[Y.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:W=>W.stopPropagation(),children:jsx(ao,{priority:M,onChange:W=>{W&&y?.(Y.id,{priority:$a[W]||"medium"});}})});default:return null}},ke=_=>[{id:"hide",label:"Hide Column",icon:Gt.Hide,onClick:()=>l(_),disabled:_==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Gt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Gt.SortDesc,onClick:()=>{}}],He=_=>_.subtasks&&_.subtasks.length>0?[{id:"addSubtask",label:I?.contextMenu?.addSubtask||"Add Subtask",icon:Gt.Add,onClick:()=>{N?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:I?.contextMenu?.deleteTask||"Delete Task",icon:Gt.Delete,onClick:()=>{B?B(_.id,_.name):b?.([_.id]);}}]:[{id:"edit",label:I?.contextMenu?.editTask||"Edit Task",icon:Gt.Pencil,onClick:()=>{n?.(_);}},{id:"addSubtask",label:I?.contextMenu?.addSubtask||"Add Subtask",icon:Gt.Add,onClick:()=>{N?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:I?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Gt.MarkIncomplete,onClick:()=>{y?.(_.id,{status:"todo",progress:0});},disabled:_.status==="todo"},{id:"setInProgress",label:I?.contextMenu?.setInProgress||"Set In Progress",icon:Gt.SetInProgress,onClick:()=>{y?.(_.id,{status:"in-progress"});},disabled:_.status==="in-progress"},{id:"markComplete",label:I?.contextMenu?.markComplete||"Mark Complete",icon:Gt.MarkComplete,onClick:()=>{y?.(_.id,{status:"completed",progress:100});},disabled:_.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:I?.contextMenu?.splitTask||"Split Task",icon:Gt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:I?.contextMenu?.deleteTask||"Delete Task",icon:Gt.Delete,onClick:()=>{B?B(_.id,_.name):b?.([_.id]);}}],$e=p.filter(_=>_.visible),tt=$e.reduce((_,Y)=>_+Y.width,0);return jsxs("div",{className:"gantt-taskgrid-content",style:{backgroundColor:t.bgPrimary,minWidth:tt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${st}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:$e.map((_,Y)=>{let be=Y===$e.length-1,je=_.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${je?"":"justify-center"}`,style:{width:`${_.width}px`,minWidth:`${_.minWidth??(je?200:60)}px`,maxWidth:`${_.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:be?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:Ie=>{Ie.preventDefault(),j({isOpen:true,x:Ie.clientX,y:Ie.clientY,type:"header",columnId:_.id});},onMouseEnter:Ie=>{Ie.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:Ie=>{Ie.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,paddingRight:"0"},title:_.label,children:_.label}),_.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:oe===_.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),ye(_.id),Re(Ie.clientX),R(_.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},_.id)})}),jsxs("div",{className:"flex items-center gap-1 px-2",style:{position:"sticky",right:0,height:"100%",backgroundColor:t.bgGrid,zIndex:5},children:[jsx(_n,{columns:p,onToggleColumn:l,theme:t}),jsx("button",{onClick:()=>Ye(!Se),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"})}),Se&&jsxs("div",{ref:Je,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:_=>_.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>Ye(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:t.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]})]}),jsx("div",{className:"gantt-taskgrid-content",style:{minHeight:nt},children:Be.map(({task:_,level:Y},be)=>{let je=Z(_.id),Ie=ge===_.id,z=Ie&&Fe==="above",se=Ie&&Fe==="below",We=Ie&&Fe==="child",Nt={};return We&&(Nt.backgroundColor=`${t.accent}15`,Nt.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":_.id,className:`flex items-center cursor-pointer group ${J===_.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:je?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:je?t.accentLight:We?`${t.accent}15`:be%2===0?t.bgPrimary:t.bgGrid,...Nt},onMouseEnter:()=>T(_.id),onMouseLeave:()=>T(null),onClick:mt=>{let fr=Bo(e).map(W=>W.id),M=navigator.platform.toUpperCase().indexOf("MAC")>=0?mt.metaKey:mt.ctrlKey;Oe(_.id,fr,M,mt.shiftKey),s?.(_);},onDoubleClick:mt=>{mt.stopPropagation(),n?.(_);},onContextMenu:mt=>{mt.preventDefault(),j({isOpen:true,x:mt.clientX,y:mt.clientY,type:"task",task:_}),c?.(_,mt);},whileHover:{backgroundColor:je?t.accentLight:t.hoverBg},children:[z&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),se&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),$e.map((mt,Dr)=>{let fr=Dr===$e.length-1,$a=mt.id==="name";return jsx("div",{className:`px-4 flex items-center ${$a?"justify-start":"justify-center"}`,style:{width:`${mt.width}px`,minWidth:`${mt.minWidth??($a?200:60)}px`,maxWidth:`${mt.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:fr?"none":`1px solid ${F===_.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:we(mt,_,$a?Y:0)},`${_.id}-${mt.id}`)})]},_.id)})}),jsx(Io,{isOpen:L.isOpen,x:L.x,y:L.y,items:L.type==="header"&&L.columnId?ke(L.columnId):L.type==="task"&&L.task?He(L.task):[],onClose:()=>j({...L,isOpen:false}),theme:t}),kt&&dt&&J&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:dt.x+12,top:dt.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let _=Be.find(Y=>Y.task.id===J)?.task;return _?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:_.name})}):null})()}),document.body)]})}function Qc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,c]=useState(e),[g,i]=useState(t),[p,l]=useState(null),[f,y]=useState(null),[k,C]=useState(null),[h,b]=useState(null),[u,x]=useState(0),[m,N]=useState(0),[w,B]=useState(null),[v,I]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:c,ghostWidth:g,setGhostWidth:i,connectionLine:p,setConnectionLine:l,hoveredTaskId:f,setHoveredTaskId:y,activeZone:k,setActiveZone:C,draggedSegmentIndex:h,setDraggedSegmentIndex:b,draggedSegmentStartX:u,setDraggedSegmentStartX:x,segmentDragOffsetX:m,setSegmentDragOffsetX:N,hoveredSegmentIndex:w,setHoveredSegmentIndex:B,isHovered:v,setIsHovered:I,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(K,ae)=>{r("none"),l(null),y(null),c(K),i(ae),N(0),b(null),x(0);}}}function qn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:c,onClick:g,onDoubleClick:i,onContextMenu:p,onDateChange:l,onDependencyCreate:f,allTaskPositions:y=[],onDragMove:k,onHoverChange:C}){let h=Qc(t,r),b=useRef(null),u=useRef(null),x=useRef(null),{dragMode:m,setDragMode:N,dragOffset:w,setDragOffset:B,ghostX:v,setGhostX:I,ghostWidth:F,setGhostWidth:T,connectionLine:H,setConnectionLine:O,hoveredTaskId:K,setHoveredTaskId:ae,activeZone:ne,setActiveZone:oe,draggedSegmentIndex:ye,setDraggedSegmentIndex:fe,draggedSegmentStartX:Re,setDraggedSegmentStartX:A,segmentDragOffsetX:R,setSegmentDragOffsetX:L,hoveredSegmentIndex:j,setHoveredSegmentIndex:J,isHovered:U,setIsHovered:ge,isDragging:le,isResizing:Fe,isConnecting:qe,resetDragState:et}=h,de=32,Ke=8,dt=e.endDate&&e.endDate<new Date&&e.progress<100,vt=e.isCriticalPath,kt=o.name==="neutral"||o.today==="#1C1917",$=e.status==="completed"||e.progress===100,me={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},Se=e.isCriticalPath||dt?"#DC2626":e.color?e.color:e.priority&&me[e.priority]?me[e.priority]:o.taskBarPrimary,Je=(X=>X>=80?20:X>=60?15:X>=50?12:10)(r),Pt=r<50,Oe=r<40;useEffect(()=>{if(C)if(U&&!le&&!e.segments){let X=a<100;C({task:e,x:t,y:a,width:r,height:de,showBelow:X});}else C(null);},[U,le,e,t,a,r,de,C]);let Z=X=>X.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),xe=()=>{let X=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${X} day${X!==1?"s":""}`},ze=X=>Math.round(X/s)*s,Be=X=>{let we=Math.round(X/s),ke=new Date(n);return ke.setDate(ke.getDate()+we),ke},st=(X,we)=>{for(let ke of y){if(ke.id===e.id)continue;let He=5;if(X>=ke.x-He&&X<=ke.x+ke.width+He&&we>=ke.y-He&&we<=ke.y+ke.height+He)return ke.id}return null},nt=useCallback((X,we,ke)=>{X.preventDefault(),X.stopPropagation();let He=b.current?.ownerSVGElement;if(!He)return;let $e=He.createSVGPoint();$e.x=X.clientX,$e.y=X.clientY;let tt=$e.matrixTransform(He.getScreenCTM()?.inverse()),_=ke!==void 0?ke:t,Y=we;if(!Y){let be=tt.x-_;X.shiftKey?(Y="connect",O({x:t+r,y:a+de/2})):X.ctrlKey||X.metaKey?Y="move":X.altKey?Y=be<r/2?"resize-start":"resize-end":Oe?be<r/2?Y="move":Y="resize-end":Pt?be<=Je/2?Y="resize-start":be>=r-Je/2?Y="resize-end":Y="move":be<=Je?Y="resize-start":be>=r-Je?Y="resize-end":Y="move";}N(Y),ge(false),oe(null),Y==="move"?B(tt.x-_):Y==="connect"?O({x:t+r,y:a+de/2}):B(0),I(_),T(r);},[t,r,a,de]),Ve=useCallback(X=>{let we=b.current?.ownerSVGElement;if(!we)return;let ke=we.closest(".gantt-timeline-scroll");if(!ke)return;let He=ke.getBoundingClientRect(),$e=60,tt=15,_=0;if(X.clientX<He.left+$e){let Y=He.left+$e-X.clientX;_=-Math.min(tt,Y/2);}else if(X.clientX>He.right-$e){let Y=X.clientX-(He.right-$e);_=Math.min(tt,Y/2);}return _!==0&&(ke.scrollLeft+=_),_!==0},[]),Vt=useCallback(X=>{if(m==="none")return;x.current=X;let we=b.current?.ownerSVGElement;if(!we)return;if(m==="move"||m==="resize-start"||m==="resize-end"){let $e=Ve(X);$e&&!u.current?u.current=window.setInterval(()=>{x.current&&(Ve(x.current),Vt(x.current));},16):!$e&&u.current&&(window.clearInterval(u.current),u.current=null);}let ke=we.createSVGPoint();ke.x=X.clientX,ke.y=X.clientY;let He=ke.matrixTransform(we.getScreenCTM()?.inverse());if(m==="connect"){O({x:He.x,y:He.y});let $e=st(He.x,He.y);ae($e);}else if(m==="move"){let $e=He.x-w,tt=ze($e);I(tt),T(r);let _=Math.round((tt-t)/s);if(k?.(e.id,_,true),e.segments&&e.segments.length>0&&ye!==null){let Y=tt-Re;L(Y);}}else if(m==="resize-start"){let $e=He.x,tt=ze($e),_=t+r-tt;_>=s&&(I(tt),T(_));}else if(m==="resize-end"){let $e=He.x,_=ze($e)-t;_>=s&&T(_);}},[m,t,r,s,w,e,ze,ye,Re,st,ae,O,I,T,L,k,Ve]),Bt=useCallback(()=>{if(u.current&&(window.clearInterval(u.current),u.current=null),x.current=null,m!=="none"){if(m==="connect")K&&f&&f(e,K),O(null),ae(null);else {let X=e.endDate.getTime()-e.startDate.getTime(),we,ke,He=true;if(m==="move"){if(we=Be(v),ke=new Date(we.getTime()+X),e.segments&&e.segments.length>0&&ye!==null){let $e=Math.round(R/s),tt=e.segments.map((je,Ie)=>{if(Ie===ye){let z=new Date(je.startDate),se=new Date(je.endDate);return z.setDate(z.getDate()+$e),se.setDate(se.getDate()+$e),{startDate:z,endDate:se}}return je}),_=tt.flatMap(je=>[je.startDate,je.endDate]),Y=new Date(Math.min(..._.map(je=>je.getTime()))),be=new Date(Math.max(..._.map(je=>je.getTime())));l?.({...e,segments:tt},Y,be),et(t,r);return}}else m==="resize-start"?(we=Be(v),ke=e.endDate,we>ke&&(console.warn("Invalid date range: start date must be before or equal to end date"),He=false)):m==="resize-end"?(we=e.startDate,ke=Be(v+F),ke<we&&(console.warn("Invalid date range: end date must be after or equal to start date"),He=false)):He=false;He&&we&&ke&&(ke.getTime()<we.getTime()?console.warn("Invalid date range: end date cannot be before start date"):l?.(e,we,ke));}k?.(e.id,0,false),et(t,r);}},[m,v,F,e,l,K,f,t,r,s,Be,R,ye,et,k]);useEffect(()=>{if(m==="none")return;let X=ke=>{Vt(ke);},we=()=>{Bt();};return window.addEventListener("mousemove",X),window.addEventListener("mouseup",we),()=>{window.removeEventListener("mousemove",X),window.removeEventListener("mouseup",we),u.current&&(window.clearInterval(u.current),u.current=null);}},[m,Vt,Bt]);let Ze=le&&!qe?v:t,te=le&&!qe?F:r,S=c.taskClass(e);return jsxs("g",{ref:b,"data-task-bar":"true",onClick:()=>!le&&g?.(e),onDoubleClick:X=>{le||(X.stopPropagation(),i?.(e));},onContextMenu:X=>{X.preventDefault(),p?.(e,X);},onMouseEnter:()=>!le&&ge(true),onMouseLeave:()=>{le||(ge(false),oe(null));},children:[jsx("rect",{x:t,y:a,width:r+24,height:de,fill:"transparent",style:{pointerEvents:"all"}}),U&&!le&&!Pt&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Je,height:de,fill:ne==="resize-start"?o.accent:"transparent",opacity:ne==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>oe("resize-start"),onMouseDown:X=>nt(X,"resize-start")}),jsx("rect",{x:t+Je,y:a,width:r-Je*2,height:de,fill:ne==="move"?o.accent:"transparent",opacity:ne==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>oe("move"),onMouseDown:X=>nt(X,"move")}),jsx("rect",{x:t+r-Je,y:a,width:Je,height:de,fill:ne==="resize-end"?o.accent:"transparent",opacity:ne==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>oe("resize-end"),onMouseDown:X=>nt(X,"resize-end")})]}),U&&!le&&Oe&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:de,fill:ne==="move"?o.accent:"transparent",opacity:ne==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>oe("move"),onMouseDown:X=>nt(X,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:de,fill:ne==="resize-end"?o.accent:"transparent",opacity:ne==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>oe("resize-end"),onMouseDown:X=>nt(X,"resize-end")}),U&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+de-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),le&&!qe&&!e.segments&&jsx(motion.rect,{x:v,y:a,width:F,height:de,rx:Ke,fill:o.accent,opacity:.5,stroke:o.accent,strokeWidth:2,strokeDasharray:"4 4",initial:{opacity:0},animate:{opacity:.6},transition:{duration:.15},style:{pointerEvents:"none"}}),!e.segments&&jsx(motion.rect,{x:Ze,y:a,width:te,height:de,rx:Ke,fill:Se,"data-task-class":S,initial:{opacity:0,scale:.95},animate:{opacity:le&&!qe?.15:e.parentId?.6:U?.9:.8,scale:U&&!le?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:X=>nt(X),style:{cursor:le?qe?"crosshair":Fe?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:Ze,y:a,width:te*(e.progress/100),height:de,rx:Ke,fill:Se,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((X,we)=>{let ke=(X.startDate.getTime()-n.getTime())/864e5*s,$e=(X.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-ke+s,tt=le&&m==="move"&&ye===we,_=j===we,Y=tt?ke+R:ke;return jsxs("g",{onMouseEnter:()=>!le&&J(we),onMouseLeave:()=>!le&&J(null),children:[jsx(motion.rect,{x:Y,y:a,width:$e,height:de,rx:Ke,fill:Se,initial:{opacity:0,scale:.95},animate:{opacity:tt||e.parentId?.6:_?.9:.8,scale:_&&!le?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:be=>{be.stopPropagation(),fe(we),A(ke),nt(be,void 0,ke);},style:{cursor:le?qe?"crosshair":Fe?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Y,y:a,width:$e*(e.progress/100),height:de,rx:Ke,fill:Se,opacity:1,style:{pointerEvents:"none"}})]},`segment-${we}`)}),kt&&(dt||vt)&&!e.segments&&jsxs(Fragment,{children:[vt&&!dt&&jsx("rect",{x:Ze,y:a,width:te,height:de,rx:Ke,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),dt&&jsx("rect",{x:Ze,y:a,width:te,height:de,rx:Ke,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),te>60&&!e.segments&&(()=>{let X=c.taskLabel(e),we=typeof X=="string"?X:e.name,ke=we.length>Math.floor(te/8)?`${we.substring(0,Math.floor(te/8))}...`:we;return jsx("text",{x:Ze+12,y:a+de/2,dominantBaseline:"middle",fill:$?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:$?"line-through":"none"},children:ke})})(),te>100&&e.progress>0&&e.progress<100&&!le&&!e.segments&&jsxs("text",{x:Ze+te-12,y:a+de/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&&te>80&&!le&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:Ze+te-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:Ze+te-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(U||Fe)&&!qe&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{children:[jsx("rect",{x:Ze-2,y:a,width:16,height:de,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>oe("resize-start"),onMouseLeave:()=>oe(null),onMouseDown:X=>{X.stopPropagation(),nt(X,"resize-start");}}),jsx(motion.rect,{x:Ze+4,y:a+8,width:3,height:de-16,rx:1.5,fill:ne==="resize-start"||m==="resize-start"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]}),jsxs("g",{children:[jsx("rect",{x:Ze+te-14,y:a,width:16,height:de,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>oe("resize-end"),onMouseLeave:()=>oe(null),onMouseDown:X=>{X.stopPropagation(),nt(X,"resize-end");}}),jsx(motion.rect,{x:Ze+te-7,y:a+8,width:3,height:de-16,rx:1.5,fill:ne==="resize-end"||m==="resize-end"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]})]}),jsx(AnimatePresence,{children:U&&!le&&!e.segments&&jsxs(motion.g,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx("circle",{cx:t+r+10,cy:a+de/2,r:10,fill:"transparent",style:{cursor:"crosshair"},onMouseEnter:()=>oe("connect"),onMouseLeave:()=>oe(null),onMouseDown:X=>{X.stopPropagation(),nt(X,"connect");}}),jsx(motion.circle,{cx:t+r+10,cy:a+de/2,r:4,fill:o.accent,stroke:"#FFFFFF",strokeWidth:1.5,style:{pointerEvents:"none"},initial:{scale:0},animate:{scale:ne==="connect"?1.4:1},exit:{scale:0},transition:{duration:.15,type:"spring",stiffness:500,damping:30}})]})}),qe&&H&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+de/2,x2:H.x,y2:H.y,stroke:K?o.statusCompleted:o.accent,strokeWidth:K?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:K?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:H.x,cy:H.y,r:K?8:6,fill:K?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),K&&jsx(motion.text,{x:H.x+15,y:H.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:H.x+10},animate:{opacity:1,x:H.x+15},transition:{duration:.2},children:"Connect"})]}),(U||le)&&!qe&&!e.segments&&jsx(motion.rect,{x:Ze-2,y:a-2,width:te+4,height:de+4,rx:Ke+2,fill:"none",stroke:le?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:le?.6:.4,initial:{opacity:0},animate:{opacity:le?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),Fe&&jsxs(Fragment,{children:[jsx("line",{x1:v,y1:0,x2:v,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:v+F,y1:0,x2:v+F,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:U&&!le&&!e.segments&&!C&&(()=>{let ke=a<100,He=ke?a+de+13:a-82-13,$e=ke?`M ${Ze+te/2-6} ${a+de+3} L ${Ze+te/2} ${a+de+13} L ${Ze+te/2+6} ${a+de+3}`:`M ${Ze+te/2-6} ${a-13} L ${Ze+te/2} ${a-3} L ${Ze+te/2+6} ${a-13}`,tt=He+22,_=He+40,Y=He+55,be=He+70,je=ke?He+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:ke?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:ke?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:$e,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:Ze+te/2-120,y:He,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:Ze+te/2,y:tt,textAnchor:"middle",fill:o.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>28?`${e.name.substring(0,28)}...`:e.name}),jsx("text",{x:Ze+te/2-110,y:_,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:Ze+te/2-70,y:_,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Z(e.startDate)}),jsx("text",{x:Ze+te/2-110,y:Y,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:Ze+te/2-70,y:Y,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Z(e.endDate)}),jsx("text",{x:Ze+te/2+10,y:_,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:Ze+te/2+65,y:_,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:xe()}),jsx("text",{x:Ze+te/2+10,y:Y,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:Ze+te/2+65,y:Y,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:Ze+te/2-110,y:be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:Ze+te/2-50,y:be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(Ie=>Ie.name).join(", ").substring(0,30),e.assignees.map(Ie=>Ie.name).join(", ").length>30?"...":""]})]}),!ke&&jsx("text",{x:Ze+te/2,y:je,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:Oe?"Left: move \u2022 Right: resize":Pt?"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 am({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:c}=e,g=82,i=13,p=c?o+n+i:o-g-i,l=c?`M ${r+s/2-6} ${o+n+3} L ${r+s/2} ${o+n+13} L ${r+s/2+6} ${o+n+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,f=p+22,y=p+40,k=p+55,C=p+70,h=m=>m.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),b=()=>{if(!a.startDate||!a.endDate)return "N/A";let m=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${m} day${m!==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:l,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:p,width:240,height:g,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:f,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,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?h(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:k,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:k,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?h(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:b()}),jsx("text",{x:r+s/2+10,y:k,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:k,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:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(m=>m.name).join(", ").substring(0,30),a.assignees.map(m=>m.name).join(", ").length>30?"...":""]})]})]})})}function Zn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,lineStyle:n="curved",isHoverLayer:c=false}){let[g,i]=useState(false),[p,l]=useState(null),f=r-t,y=f>0,k=Math.abs(f)<5,h=5,b=20,u=!k&&a<=e,x,m;if(k)if(m=(e+a)/2,n==="squared")x=`M ${e} ${t} L ${a} ${r}`;else {let ne=Math.min(Math.abs(a-e)/3,30);x=`M ${e} ${t} C ${e+ne} ${t}, ${a-ne} ${r}, ${a} ${r}`;}else if(m=a-b,u){let oe=e+15,ye=a-b,fe=y?t+20:t-20;m=ye,n==="squared"?x=`M ${e} ${t} L ${oe} ${t} L ${oe} ${fe} L ${ye} ${fe} L ${ye} ${r} L ${a} ${r}`:y?x=`M ${e} ${t} L ${oe-h} ${t} Q ${oe} ${t} ${oe} ${t+h} L ${oe} ${fe-h} Q ${oe} ${fe} ${oe-h} ${fe} L ${ye+h} ${fe} Q ${ye} ${fe} ${ye} ${fe+h} L ${ye} ${r-h} Q ${ye} ${r} ${ye+h} ${r} L ${a} ${r}`:x=`M ${e} ${t} L ${oe-h} ${t} Q ${oe} ${t} ${oe} ${t-h} L ${oe} ${fe+h} Q ${oe} ${fe} ${oe-h} ${fe} L ${ye+h} ${fe} Q ${ye} ${fe} ${ye} ${fe-h} L ${ye} ${r+h} Q ${ye} ${r} ${ye+h} ${r} L ${a} ${r}`;}else n==="squared"?x=`M ${e} ${t} L ${m} ${t} L ${m} ${r} L ${a} ${r}`:y?x=`M ${e} ${t} L ${m-h} ${t} Q ${m} ${t} ${m} ${t+h} L ${m} ${r-h} Q ${m} ${r} ${m+h} ${r} L ${a} ${r}`:x=`M ${e} ${t} L ${m-h} ${t} Q ${m} ${t} ${m} ${t-h} L ${m} ${r+h} Q ${m} ${r} ${m+h} ${r} L ${a} ${r}`;let N=5,w=`M ${a} ${r} L ${a-N} ${r-N*.5} M ${a} ${r} L ${a-N} ${r+N*.5}`,B=o.dependency,v=o.dependencyHover||B,I="#f87171",F="rgba(248, 113, 113, 0.15)",T=m,H=(t+r)/2;if(p)if(k)T=Math.max(e+10,Math.min(a-10,p.x)),H=t;else if(u){let ne=e+15,oe=a-b,ye=y?t+20:t-20,fe=[[e,t,ne,t],[ne,t,ne,ye],[ne,ye,oe,ye],[oe,ye,oe,r],[oe,r,a,r]],Re=1/0,A={x:T,y:H};for(let R of fe){let L=O(p.x,p.y,R[0],R[1],R[2],R[3]),j=Math.hypot(p.x-L.x,p.y-L.y);j<Re&&(Re=j,A=L);}T=A.x,H=A.y;}else {let ne=[[e,t,m,t],[m,t,m,r],[m,r,a,r]],oe=1/0,ye={x:T,y:H};for(let fe of ne){let Re=O(p.x,p.y,fe[0],fe[1],fe[2],fe[3]),A=Math.hypot(p.x-Re.x,p.y-Re.y);A<oe&&(oe=A,ye=Re);}T=ye.x,H=ye.y;}function O(ne,oe,ye,fe,Re,A){let R=Re-ye,L=A-fe,j=R*R+L*L;if(j===0)return {x:ye,y:fe};let J=((ne-ye)*R+(oe-fe)*L)/j;return J=Math.max(0,Math.min(1,J)),{x:ye+J*R,y:fe+J*L}}let K=ne=>{let oe=ne.currentTarget.ownerSVGElement;if(!oe)return;let ye=oe.getBoundingClientRect();l({x:ne.clientX-ye.left,y:ne.clientY-ye.top});},ae=()=>{i(false),l(null);};return c?jsxs("g",{"data-dependency-line":"true",onMouseLeave:ae,onMouseMove:K,children:[jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("path",{d:x,fill:"none",stroke:v,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:x,fill:"none",stroke:v,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:w,fill:"none",stroke:v,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:a,cy:r,r:4,fill:v,opacity:.9,style:{pointerEvents:"none"}}),s&&jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:ne=>{ne.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:T,cy:H,r:9,fill:F,stroke:I,strokeWidth:1.5}),jsx("line",{x1:T-3,y1:H-3,x2:T+3,y2:H+3,stroke:I,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:T+3,y1:H-3,x2:T-3,y2:H+3,stroke:I,strokeWidth:1.5,strokeLinecap:"round"})]})]}):jsxs("g",{"data-dependency-line":"true",onMouseEnter:()=>i(true),onMouseLeave:ae,onMouseMove:K,style:{cursor:s?"pointer":"default"},children:[jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:16,strokeLinecap:"round",style:{cursor:s?"pointer":"default"}}),jsx(motion.path,{d:x,fill:"none",stroke:g?v:B,strokeWidth:g?2.5:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:1},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2}}}),jsx(motion.path,{d:w,fill:"none",stroke:g?v:B,strokeWidth:g?2.5:2,strokeLinecap:"round",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.3}}),jsx(motion.circle,{cx:a,cy:r,r:g?4:3,fill:g?v:B,initial:{scale:0},animate:{scale:1},transition:{delay:.3,duration:.15}}),g&&s&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.15},onClick:ne=>{ne.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:T,cy:H,r:9,fill:F,stroke:I,strokeWidth:1.5}),jsx("line",{x1:T-3,y1:H-3,x2:T+3,y2:H+3,stroke:I,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:T+3,y1:H-3,x2:T-3,y2:H+3,stroke:I,strokeWidth:1.5,strokeLinecap:"round"})]})]})}function es({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),c=16,g=i=>i.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{"data-task-bar":"true",onMouseEnter:()=>n(true),onMouseLeave:()=>n(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:g(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 he={calculateEndDate:(e,t)=>{let a=new Date(e);return a.setDate(a.getDate()+t),a},calculateDuration:(e,t)=>{let a=t.getTime()-e.getTime();return Math.ceil(a/(1e3*60*60*24))},calculateWorkingDays:(e,t)=>{let a=0,r=new Date(e);for(;r<=t;){let o=r.getDay();o!==0&&o!==6&&a++,r.setDate(r.getDate()+1);}return a},addWorkingDays:(e,t)=>{let a=new Date(e),r=0;for(;r<t;){a.setDate(a.getDate()+1);let o=a.getDay();o!==0&&o!==6&&r++;}return a},isWeekend:e=>{let t=e.getDay();return t===0||t===6},validateDependencies:(e,t,a)=>{let r=new Map,o=i=>{i.forEach(p=>{p.dependencies&&r.set(p.id,p.dependencies),p.subtasks&&o(p.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let n=new Set,c=new Set,g=i=>{if(!n.has(i)){n.add(i),c.add(i);let p=r.get(i)||[];for(let l of p){if(!n.has(l)&&g(l))return true;if(c.has(l))return true}}return c.delete(i),false};return g(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=he.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=he.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=he.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=he.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=he.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=he.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)=>he.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=he.findTaskById(e,t);return !a||!a.dependencies?[]:he.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>he.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>he.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=he.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=>he.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=he.flattenTasks(e);if(s.length===0){alert("No tasks found to export");return}o.setFontSize(16),o.text("Gantt Chart - Task List",14,20);let n=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],c=s.map(g=>{let i=g.startDate&&g.endDate?he.calculateDuration(g.startDate,g.endDate):0;return [g.name,g.startDate?he.formatDate(g.startDate):"N/A",g.endDate?he.formatDate(g.endDate):"N/A",i>0?`${i} days`:"N/A",`${g.progress}%`,g.status||"N/A"]});r(o,{head:n,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=he.flattenTasks(e).map(g=>{let i=g.startDate&&g.endDate?he.calculateDuration(g.startDate,g.endDate):0;return {"Task ID":g.id,"Task Name":g.name,"Start Date":g.startDate?he.formatDate(g.startDate):"","End Date":g.endDate?he.formatDate(g.endDate):"","Duration (days)":i>0?i:"","Progress (%)":g.progress,Status:g.status||"",Assignees:g.assignees?.map(p=>p.name).join(", ")||"",Dependencies:g.dependencies?.join(", ")||"","Is Milestone":g.isMilestone?"Yes":"No","Parent ID":g.parentId||"",Level:g.level||0}}),s=a.utils.json_to_sheet(o),n=[{wch:15},{wch:40},{wch:12},{wch:12},{wch:15},{wch:12},{wch:15},{wch:30},{wch:20},{wch:12},{wch:15},{wch:8}];s["!cols"]=n;let 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=he.flattenTasks(e),o=new Map;r.forEach((f,y)=>{o.set(f.id,y+1);});let s=f=>f.toISOString().replace("Z",""),n=he.getEarliestStartDate(e)||new Date,c=he.getLatestEndDate(e)||new Date,g=r.map((f,y)=>{let k=o.get(f.id),C=f.startDate&&f.endDate?he.calculateDuration(f.startDate,f.endDate):0,h=(f.dependencies||[]).filter(b=>o.has(b)).map(b=>`
|
|
113
113
|
<PredecessorLink>
|
|
114
114
|
<PredecessorUID>${o.get(b)}</PredecessorUID>
|
|
@@ -339,9 +339,9 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
|
|
|
339
339
|
</Calendars>
|
|
340
340
|
<Tasks>${g}
|
|
341
341
|
</Tasks>
|
|
342
|
-
</Project>`,p=new Blob([i],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(p),l.download=a,l.click(),URL.revokeObjectURL(l.href);},calculateCriticalPath:e=>{let t=he.flattenTasks(e),a=t.filter(i=>i.startDate&&i.endDate);if(a.length===0)return [];let r=new Map,o=i=>{if(r.has(i.id))return;let p=i.startDate&&i.endDate?he.calculateDuration(i.startDate,i.endDate):0,l=0;if(i.dependencies&&i.dependencies.length>0)for(let y of i.dependencies){let k=t.find(C=>C.id===y);if(k){o(k);let C=r.get(y)?.ef||0;l=Math.max(l,C);}}let f=l+p;r.set(i.id,{es:l,ef:f});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,c=i=>{if(n.has(i.id))return;let p=i.startDate&&i.endDate?he.calculateDuration(i.startDate,i.endDate):0,l=t.filter(k=>k.dependencies&&k.dependencies.includes(i.id)),f=s;if(l.length>0)for(let k of l){c(k);let C=n.get(k.id)?.ls||0;f=Math.min(f,C);}let y=f-p;n.set(i.id,{ls:y,lf:f});};a.forEach(c);let g=[];for(let i of a){let p=r.get(i.id),l=n.get(i.id);if(p&&l){let f=l.ls-p.es;Math.abs(f)<.01&&g.push(i.id);}}return g},calculateSlack:(e,t)=>{let a=he.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(he.calculateCriticalPath(e).includes(t))return 0;let o=he.getDependentTasks(e,t);if(o.length===0){let c=he.getLatestEndDate(e);if(!c)return null;let g=he.calculateDuration(a.endDate,c);return Math.max(0,g)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,g)=>c-g)[0];if(!s)return null;let n=he.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>he.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=he.findTaskById(e,t);if(!r||!r.endDate)return e;let o=he.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let c=he.calculateDuration(n.startDate,n.endDate),g;a!==void 0?(g=new Date(n.startDate),g.setDate(g.getDate()+a)):(g=new Date(r.endDate),g.setDate(g.getDate()+1));let i=he.calculateEndDate(g,c),p=l=>l.map(f=>f.id===n.id?{...f,startDate:g,endDate:i}:f.subtasks?{...f,subtasks:p(f.subtasks)}:f);s=p(s),s=he.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,c)=>{if(a===0)return [];let g=[],i=o.getTime(),p=1e3*60*60*24,l=he.findTaskById(e,t);if(!l||!l.endDate)return [];let f=(y,k,C=new Set)=>{if(C.has(y))return;C.add(y);let h=he.getDependentTasks(e,y);for(let b of h){if(!b.startDate||!b.endDate)continue;let u=r.findIndex(T=>T.id===b.id);if(u===-1)continue;let x=b.startDate.getTime(),N=(b.endDate.getTime()-x)/p,B=(x-i)/p*s,v=B+k*s,I=Math.max(N*s,s),A=c+u*n+12;g.push({taskId:b.id,taskName:b.name,originalX:B,previewX:v,width:I,y:A,rowIndex:u,daysDelta:k,color:b.color}),f(b.id,k,C);}};return f(t,a),g},splitTask:(e,t,a,r=3)=>{let o=he.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let n=new Date(a);n.setDate(n.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let g=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:c}],i=p=>p.map(l=>l.id===o.id?{...l,endDate:c,segments:g}:l.subtasks?{...l,subtasks:i(l.subtasks)}:l);return i(e)}};function as({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,locale:c="en",templates:g,dependencyLineStyle:i="curved",onTaskClick:p,onTaskDblClick:l,onTaskContextMenu:f,onTaskDateChange:y,onDependencyCreate:k,onDependencyDelete:C}){let b=Vr(),[u,x]=useState([]),[m,N]=useState(null),w=useCallback(M=>{N(M);},[]),B=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),v=r==="day"?60:r==="week"?20:8,I=B*v*n,A=M=>{let R=new Date(Date.UTC(M.getFullYear(),M.getMonth(),M.getDate())),L=R.getUTCDay()||7;R.setUTCDate(R.getUTCDate()+4-L);let V=new Date(Date.UTC(R.getUTCFullYear(),0,1));return Math.ceil(((R.getTime()-V.getTime())/864e5+1)/7)},T=M=>{let R=M.getDay();return R===0||R===6},W=useCallback(M=>{let R=Math.round(M/(v*n)),L=new Date(o);return L.setDate(L.getDate()+R),L},[o,v,n]),$=useCallback((M,R)=>{if(R.startDate&&R.endDate)return;let L=M.currentTarget.ownerSVGElement;if(!L)return;let V=L.createSVGPoint();V.x=M.clientX,V.y=M.clientY;let q=V.matrixTransform(L.getScreenCTM()?.inverse()),z=W(q.x),ye=new Date(z);ye.setDate(ye.getDate()+1),y?.(R,z,ye);},[W,y]),j=useMemo(()=>{let M=q=>q.map(z=>{if(z.subtasks&&z.subtasks.length>0){let ye=M(z.subtasks),ne=ye.filter(Be=>Be.startDate&&Be.endDate);if(ne.length>0){let Be=ne.map(Je=>Je.startDate.getTime()),qe=ne.map(Je=>Je.endDate.getTime()),tt=new Date(Math.min(...Be)),le=new Date(Math.max(...qe));return {...z,subtasks:ye,startDate:tt,endDate:le}}return {...z,subtasks:ye}}return z}),R=(q,z=[])=>{for(let ye of q)z.push(ye),ye.subtasks&&ye.subtasks.length>0&&(ye.isExpanded===void 0||ye.isExpanded)&&R(ye.subtasks,z);return z},L=M(e);return R(L)},[e]),te=useCallback(M=>{if(!M.startDate||!M.endDate)return {x:0,width:0};let R=M.startDate.getTime(),L=M.endDate.getTime(),V=o.getTime(),q=(R-V)/(1e3*60*60*24),z=(L-R)/(1e3*60*60*24),ye=q*v*n,ne=Math.max(v*n,40),Be=Math.max(z*v*n,ne);return {x:ye,width:Be}},[o,v,n]),oe=useMemo(()=>j.filter(M=>M.startDate&&M.endDate).map(M=>{let{x:R,width:L}=te(M),q=j.findIndex(z=>z.id===M.id)*a+12;return {id:M.id,x:R,y:q,width:L,height:32}}),[j,te]),re=useCallback((M,R,L)=>{if(!L||R===0){x([]);return}let V=he.calculateCascadePreview(e,M,R,j,o,v*n,a,48);x(V);},[e,j,o,v,n,a,48]),ge=useMemo(()=>{let M=[],R=new Date(o);for(;R<=s;){let q=(R.getTime()-o.getTime())/864e5*v*n;if(r==="day")M.push({date:new Date(R),label:R.toLocaleDateString(c,{day:"numeric",month:"short"}),x:q}),R.setDate(R.getDate()+1);else if(r==="week"){let z=A(R);M.push({date:new Date(R),label:`${b.labels.week} ${z}`,x:q}),R.setDate(R.getDate()+7);}else M.push({date:new Date(R),label:R.toLocaleDateString(c,{month:"short",year:"numeric"}),x:q}),R.setMonth(R.getMonth()+1);}return M},[o,s,r,v,n,c,b.labels.week]),fe=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*v*n,[o,v,n]),Ie=Math.max(j.length*a,552);return jsxs("div",{className:"w-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxs("svg",{width:Math.max(I,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(I,1e3),height:48,fill:t.bgGrid}),ge.map((M,R)=>jsxs("g",{children:[R>0&&jsx("line",{x1:M.x,y1:0,x2:M.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:M.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:M.label})]},`header-${R}`)),fe>=0&&fe<=I&&jsx("circle",{cx:fe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(I,1e3),height:Ie,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxs("defs",{children:[jsx("filter",{id:"shadow",children:jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsx("rect",{x:0,y:0,width:Math.max(I,1e3),height:Ie,fill:t.bgPrimary}),ge.map((M,R)=>{let L=ge[R+1]?.x||I,V=T(M.date);return jsxs("g",{children:[V&&jsx("rect",{x:M.x,y:0,width:L-M.x,height:j.length*a,fill:t.bgWeekend,opacity:1}),R>0&&jsx("line",{x1:M.x,y1:0,x2:M.x,y2:j.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},R)}),j.map((M,R)=>{let L=M.startDate&&M.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:R*a,width:I,height:a,fill:R%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${M.id}`),!L&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:R*a,width:I,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:V=>$(V,M),onMouseEnter:V=>{V.currentTarget.setAttribute("fill",t.accentLight),V.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:V=>{V.currentTarget.setAttribute("fill","transparent"),V.currentTarget.setAttribute("opacity","1");}},`clickable-${M.id}`),jsx("text",{x:fe>0?fe:100,y:R*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:b.labels.clickToSetDates},`placeholder-${M.id}`)]})]},`row-group-${M.id}`)}),j.map((M,R)=>{if(!M.startDate||!M.endDate)return null;let{x:L,width:V}=te(M),q=R*a+12,z=M.subtasks&&M.subtasks.length>0&&!M.isMilestone;return M.isMilestone?jsx(es,{task:M,x:L+V/2,y:q+16,theme:t,onClick:p},M.id):z?jsxs("g",{onClick:()=>p?.(M),onContextMenu:ye=>{ye.preventDefault(),ye.stopPropagation(),f?.(M,ye);},style:{cursor:"default"},children:[jsx("rect",{x:L,y:q,width:V,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:L,y1:q,x2:L+V,y2:q,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:L,y1:q,x2:L,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:L+V,y1:q,x2:L+V,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:L,y1:q+32,x2:L+V,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),V>60&&jsx("text",{x:L+12,y:q+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:M.name})]},M.id):jsx(qn,{task:M,x:L,y:q,width:V,theme:t,dayWidth:v*n,startDate:o,templates:g,onClick:p,onDoubleClick:l,onContextMenu:f,onDateChange:y,onDependencyCreate:k,allTaskPositions:oe,onDragMove:re,onHoverChange:w},M.id)}),j.map((M,R)=>!M.dependencies||M.dependencies.length===0||!M.startDate||!M.endDate?null:M.dependencies.map(L=>{let V=j.find(le=>le.id===L);if(!V||!V.startDate||!V.endDate)return null;let q=j.findIndex(le=>le.id===L),z=te(V),ye=te(M),ne=z.x+z.width,Be=q*a+28,qe=ye.x,tt=R*a+28;return jsx(Zn,{x1:ne,y1:Be,x2:qe,y2:tt,theme:t,lineStyle:i,onDelete:()=>C?.(M.id,L)},`dep-${L}-${M.id}`)})),u.map(M=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:M.previewX,y:M.y-48,width:M.width,height:32,rx:8,fill:M.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(M.daysDelta)>0&&jsx("text",{x:M.previewX+M.width/2,y:M.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:M.daysDelta>0?`+${M.daysDelta}d`:`${M.daysDelta}d`})]},`cascade-preview-${M.taskId}`)),fe>=0&&fe<=I&&jsx("line",{x1:fe,y1:0,x2:fe,y2:Ie,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),m&&jsx(tm,{tooltipData:m,theme:t})]})]})}var Kb=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],nm=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsx("circle",{cx:"12",cy:"12",r:"4"})]}),Yb=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),qb=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),Xb=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),Jb=()=>jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsx(motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function rs({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:c,onDependencyDelete:g}){let[i,p]=useState(false),[l,f]=useState(false),[y,k]=useState([]),[C,h]=useState(""),[b,u]=useState(false),[x,m]=useState(true),N=useRef(null),w=useRef(null),B=useRef(null),{enabled:v=true,placeholder:I='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:A="bottom-right",onCommand:T,suggestions:W=Kb,maxHistory:$=50,persistHistory:j}=a,te=j?.storageKey||"gantt-ai-history",oe=j?.maxMessages??5;useEffect(()=>{if(j?.enabled)try{let R=localStorage.getItem(te);if(R){let V=JSON.parse(R).map(q=>({...q,timestamp:new Date(q.timestamp)}));k(V.slice(-oe));}}catch(R){console.warn("[GanttAIAssistant] Failed to load persisted history:",R);}},[j?.enabled,te,oe]),useEffect(()=>{if(j?.enabled&&y.length>0)try{let R=y.filter(L=>!L.isLoading).slice(-oe);localStorage.setItem(te,JSON.stringify(R));}catch(R){console.warn("[GanttAIAssistant] Failed to persist history:",R);}},[y,j?.enabled,te,oe]),useEffect(()=>{w.current&&w.current.scrollIntoView({behavior:"smooth"});},[y]),useEffect(()=>{i&&!l&&N.current&&setTimeout(()=>N.current?.focus(),100);},[i,l]);let re=useCallback(R=>{if(R.success)switch(R.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":R.taskId&&R.updates&&o?.(R.taskId,R.updates);break;case "create_task":R.newTask&&s?.(R.newTask);break;case "delete_task":R.taskId&&n?.(R.taskId);break;case "link_tasks":R.dependencyFrom&&R.dependencyTo&&c?.(R.dependencyFrom,R.dependencyTo);break;case "unlink_tasks":R.taskId&&R.dependencyFrom&&g?.(R.taskId,R.dependencyFrom);break}},[o,s,n,c,g]),ge=useCallback(async R=>{if(!R.trim()||b)return;let L={id:`user-${Date.now()}`,role:"user",content:R,timestamp:new Date};k(q=>[...q.slice(-($-1)),L]),h(""),m(false),u(true);let V={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};k(q=>[...q,V]);try{if(T){let q=await T(R,e);k(z=>{let ye=z.filter(Be=>!Be.isLoading),ne={id:`assistant-${Date.now()}`,role:"assistant",content:q.message,timestamp:new Date,command:q};return [...ye,ne]}),re(q);}else k(q=>[...q.filter(ye=>!ye.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(q){k(z=>[...z.filter(ne=>!ne.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${q instanceof Error?q.message:"Unknown error"}`,timestamp:new Date}]);}finally{u(false);}},[b,$,T,e,re]),fe=R=>{R.preventDefault(),ge(C);},Ie=R=>{h(R),N.current?.focus();};if(useEffect(()=>{let R=L=>{(L.metaKey||L.ctrlKey)&&L.key==="k"&&(L.preventDefault(),p(V=>!V),i||f(false)),L.key==="Escape"&&i&&p(false);};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[i]),useEffect(()=>{if(!i)return;let R=V=>{let q=V.target;B.current&&!B.current.contains(q)&&p(false);},L=setTimeout(()=>{document.addEventListener("mousedown",R);},100);return ()=>{clearTimeout(L),document.removeEventListener("mousedown",R);}},[i]),!v)return null;let M={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxs(bt,{children:[jsx(AnimatePresence,{children:!i&&jsxs(motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${M[A]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>p(true),children:[jsx(nm,{}),jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsx(AnimatePresence,{children:i&&jsxs(motion.div,{ref:B,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:l?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${M[A]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsx(nm,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>f(R=>!R),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(Xb,{})}),jsx("button",{onClick:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(qb,{})})]})]}),jsx(AnimatePresence,{children:!l&&jsxs(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[y.length===0&&x&&jsxs("div",{className:"space-y-3",children:[jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsx("div",{className:"flex flex-wrap gap-2",children:W.slice(0,4).map((R,L)=>jsx("button",{onClick:()=>Ie(R),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:R.length>30?R.slice(0,30)+"...":R},L))})]}),y.map(R=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${R.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${R.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:R.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:R.role==="user"?"white":t.textPrimary},children:[R.isLoading?jsx(Jb,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:R.content}),R.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:R.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:R.command.success?"#10B981":"#EF4444"},children:[R.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:R.command.type.replace(/_/g," ")})]})]})},R.id)),jsx("div",{ref:w})]}),jsxs("form",{onSubmit:fe,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsx("input",{ref:N,type:"text",value:C,onChange:R=>h(R.target.value),placeholder:I,disabled:b,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!C.trim()||b,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:C.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:C.trim()?"white":t.textSecondary},children:jsx(Yb,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function sm(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((i,p=true)=>{r(l=>{let f=typeof i=="function"?i(l.present):i;if(o.current)return {...l,present:f};if(!p)return {...l,present:f};let y=[...l.past,l.present];return y.length>t&&y.shift(),{past:y,present:f,future:[]}});},[t]),n=useCallback(()=>{r(i=>{if(i.past.length===0)return i;let p=i.past[i.past.length-1],l=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:l,present:p,future:[i.present,...i.future]}});},[]),c=useCallback(()=>{r(i=>{if(i.future.length===0)return i;let p=i.future[0],l=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:p,future:l}});},[]),g=useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:g}}function im({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=n=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,g=c?n.metaKey:n.ctrlKey;if(g&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!c&&g&&n.key==="y"){n.preventDefault(),t();return}if(c&&g&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var th={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${he.formatDate(e.startDate)} - ${he.formatDate(e.endDate)}`);let a=he.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${a} days`);}if(e.progress!==void 0&&t.push(`Progress: ${e.progress}%`),e.status&&t.push(`Status: ${e.status}`),e.assignees&&e.assignees.length>0){let a=e.assignees.map(r=>r.name).join(", ");t.push(`Assigned: ${a}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,a)=>a,taskClass:e=>{let t=[];return e.isCriticalPath&&t.push("critical-path"),e.status==="completed"?t.push("completed"):e.status==="in-progress"?t.push("in-progress"):e.status==="todo"&&t.push("todo"),e.isMilestone&&t.push("milestone"),t.join(" ")},milestoneContent:e=>`\u25C6 ${e.name}`,dateFormat:e=>he.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function lm(e){return {...th,...e}}var dh=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},mm=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:c="comfortable",showThemeSelector:g=true,showExportButton:i=true,availableUsers:p=[],templates:l,enableAutoCriticalPath:f=true,persistExpandedState:y,aiAssistant:k,locale:C="en",customTranslations:h,showCreateTaskButton:b=false,createTaskLabel:u,onCreateTask:x,taskFilter:m,onTaskFilterChange:N,onThemeChange:w,onTaskClick:B,onTaskDblClick:v,onTaskContextMenu:I,onTaskUpdate:A,onProgressChange:T,onTaskEdit:W,onTaskAddSubtask:$,onTaskMarkIncomplete:j,onTaskSetInProgress:te,onDependencyCreate:oe,onDependencyDelete:re,onBeforeTaskAdd:ge,onAfterTaskAdd:fe,onBeforeTaskUpdate:Ie,onAfterTaskUpdate:M,onBeforeTaskDelete:R,onAfterTaskDelete:L}=a,q=useContext(zn)?.theme,[z,ye]=useState(q||s||"dark"),[ne,Be]=useState(n),[qe,tt]=useState(c),[le,Je]=useState(1),[ct,wt]=useState("all"),vt=m??ct,U=N??wt,[me,Ae]=useState(false),[Fe,je]=useState(0),[Qe,Pt]=useState(false),[Re,J]=useState(null),[ve,He]=useState({isOpen:false,x:0,y:0,task:null}),[Le,nt]=useState(null),[st,_e]=useState(null);useEffect(()=>{q&&q!==z&&ye(q);},[q]),useEffect(()=>{s&&s!==z&&ye(s);},[s]);let ea=useCallback(S=>{ye(S),w?.(S);},[w]),{state:ke,setState:be,undo:Ke,redo:F,canUndo:Ce,canRedo:Z,clearHistory:Te}=sm(t,50),we=useCallback(()=>y?typeof y=="string"?y:"gantt-expanded-tasks":null,[y]),Oe=useRef(new Map),$e=useRef(false);if(!$e.current&&y){$e.current=true;let S=typeof y=="string"?y:"gantt-expanded-tasks";try{let E=localStorage.getItem(S);if(E){let K=JSON.parse(E);Array.isArray(K)&&(Oe.current=new Map(K));}}catch(E){console.warn("[GanttBoard] Error loading expanded state from localStorage:",E);}}let dt=useCallback(()=>{let S=we();if(S)try{let E=Array.from(Oe.current.entries());localStorage.setItem(S,JSON.stringify(E));}catch(E){console.warn("[GanttBoard] Error saving expanded state to localStorage:",E);}},[we]);useEffect(()=>{let S=E=>E.map(K=>{let ae=Oe.current.get(K.id),pe=ae!==void 0?{...K,isExpanded:ae}:K;return pe.subtasks?.length?{...pe,subtasks:S(pe.subtasks)}:pe});Oe.current.size>0?be(S(t)):be(t);},[t,be]);let _=useRef(t),Y=useRef(true);useEffect(()=>{if(Y.current){Y.current=false,_.current=ke;return}if(!r)return;let S=JSON.stringify(_.current),E=JSON.stringify(ke);S!==E&&(_.current=ke,r(ke));},[ke,r]);let se=useMemo(()=>Mi(C,h),[C,h]),Ye=useCallback(S=>[{id:"name",label:S.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:S.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:S.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:S.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:S.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:S.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:S.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:S.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ue,H]=useState(()=>Ye(se));useEffect(()=>{H(S=>S.map(E=>({...E,label:se.columns[E.id==="name"?"taskName":E.id]||E.label})));},[se]);let ie=useMemo(()=>Ue.filter(E=>E.visible).reduce((E,K)=>E+K.width,0),[Ue]),We=useRef(Ue.filter(S=>S.visible).map(S=>S.id).join(","));useEffect(()=>{let S=Ue.filter(ae=>ae.visible),E=S.map(ae=>ae.id).join(","),K=We.current;if(E!==K){let ae=S.some(Se=>Se.id!=="name"),pe=K.includes(",");ae?!pe&&ae&&J(null):J(null),We.current=E;}},[Ue]);let Mt=60,pt=.6,Ar=useMemo(()=>{let E=ie+Mt,K=typeof window<"u"?window.innerWidth*pt:800,ae=Math.max(E,K);return Re!==null?Math.max(200,Math.min(Re,ae)):Math.max(200,E)},[Re,ie]),wa=useRef(null),ta=useRef(null),P=useRef(null),O=useMemo(()=>Ac(z),[z]),Me=useMemo(()=>({theme:O,themeName:z}),[O,z]),Xe=useMemo(()=>lm(l),[l]),Lt=useMemo(()=>{if(!f)return ke;let S=he.calculateCriticalPath(ke),E=K=>K.map(ae=>({...ae,isCriticalPath:S.includes(ae.id),subtasks:ae.subtasks?E(ae.subtasks):void 0}));return E(ke)},[ke,f]),de=useMemo(()=>{if(vt==="all"&&!me)return Lt;let S=E=>{let K=[];for(let ae of E){let pe=ae.subtasks?.length?S(ae.subtasks):void 0,Se=false;if(me)Se=ae.progress<100;else switch(vt){case "all":Se=true;break;case "incomplete":Se=ae.progress<100;break;case "in_progress":Se=ae.progress>0&&ae.progress<100;break;case "completed":Se=ae.progress===100;break}(Se||pe&&pe.length>0)&&K.push({...ae,subtasks:pe});}return K};return S(Lt)},[Lt,vt,me]),ze=dh(qe);im({undo:Ke,redo:F,canUndo:Ce,canRedo:Z,enabled:true}),useImperativeHandle(o,()=>({getTask:S=>he.findTaskById(ke,S),addTask:(S,E)=>{be(K=>{if(!E)return [...K,{...S,level:0}];let ae=pe=>pe.map(Se=>Se.id===E?{...Se,subtasks:[...Se.subtasks||[],{...S,parentId:E,level:(Se.level||0)+1}],isExpanded:true}:Se.subtasks?{...Se,subtasks:ae(Se.subtasks)}:Se);return ae(K)});},updateTask:(S,E)=>{be(K=>{let ae=pe=>pe.map(Se=>Se.id===S?{...Se,...E}:Se.subtasks?{...Se,subtasks:ae(Se.subtasks)}:Se);return ae(K)});},deleteTask:S=>{be(E=>{let K=ae=>ae.filter(pe=>pe.id===S?false:(pe.subtasks&&(pe.subtasks=K(pe.subtasks)),true));return K(E)});},deleteTasks:S=>{be(E=>Hi(E,S));},duplicateTask:S=>{be(E=>Wi(E,[S]));},splitTask:(S,E,K=3)=>{be(ae=>he.splitTask(ae,S,E,K));},calculateEndDate:he.calculateEndDate,calculateDuration:he.calculateDuration,validateDependency:(S,E)=>!he.validateDependencies(ke,S,E),getAllTasks:()=>he.flattenTasks(ke),getTasksByStatus:S=>he.flattenTasks(ke).filter(E=>E.status===S),getTasksByParent:S=>S?he.findTaskById(ke,S)?.subtasks||[]:ke.filter(K=>!K.parentId),getCriticalPath:()=>he.flattenTasks(ke).filter(S=>S.isCriticalPath),indentTask:S=>{be(E=>$i(E,[S]));},outdentTask:S=>{be(E=>Ui(E,[S]));},moveTask:(S,E)=>{be(K=>zi(K,[S],E));},createSubtask:async S=>{let{tasks:E,newTask:K}=Vi(ke,S);if(ge){let ae=ge({...K,parentId:S});if((ae instanceof Promise?await ae:ae)===false)return}be(E),fe&&fe({...K,parentId:S});},scrollToTask:S=>{let K=he.flattenTasks(ke).findIndex(ae=>ae.id===S);if(K!==-1&&wa.current){let ae=K*ze;wa.current.scrollTo({top:ae,behavior:"smooth"}),ta.current&&ta.current.scrollTo({top:ae,behavior:"smooth"});}},highlightTask:(S,E=2e3)=>{},expandTask:S=>{be(E=>{let K=ae=>ae.map(pe=>pe.id===S?{...pe,isExpanded:true}:pe.subtasks?{...pe,subtasks:K(pe.subtasks)}:pe);return K(E)});},collapseTask:S=>{be(E=>{let K=ae=>ae.map(pe=>pe.id===S?{...pe,isExpanded:false}:pe.subtasks?{...pe,subtasks:K(pe.subtasks)}:pe);return K(E)});},expandAll:()=>{be(S=>{let E=K=>K.map(ae=>({...ae,isExpanded:true,subtasks:ae.subtasks?E(ae.subtasks):void 0}));return E(S)});},collapseAll:()=>{be(S=>{let E=K=>K.map(ae=>({...ae,isExpanded:false,subtasks:ae.subtasks?E(ae.subtasks):void 0}));return E(S)});},undo:Ke,redo:F,canUndo:()=>Ce,canRedo:()=>Z,clearHistory:Te,exportToPNG:async()=>{if(!P.current||!wa.current||!ta.current)throw new Error("Gantt container not found");let S=P.current,E=wa.current.querySelector(".gantt-grid-scroll"),K=ta.current,ae=E?.scrollTop||0,pe=K.scrollTop,Se=S.style.overflow,It=S.style.height;try{let ut=E?.querySelector(".gantt-taskgrid-content"),Yt=K.querySelector("svg"),Ta=ut?.scrollHeight||E?.scrollHeight||600,Ea=Yt?.getBoundingClientRect().height||K.scrollHeight,Zr=(S.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(Ta,Ea)+20;E&&(E.scrollTop=0),K.scrollTop=0,S.style.overflow="visible",S.style.height=`${Zr}px`,await new Promise(Ir=>setTimeout(Ir,100));let br=await cm(S,{backgroundColor:O.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:Ir=>{let ko=window.getComputedStyle(Ir),Qr=parseInt(ko.zIndex,10);return !isNaN(Qr)&&Qr>=50||ko.position==="fixed"}});return new Promise((Ir,ko)=>{br.toBlob(Qr=>{Qr?Ir(Qr):ko(new Error("Failed to create blob from canvas"));},"image/png");})}finally{S.style.overflow=Se,S.style.height=It,E&&(E.scrollTop=ae),K.scrollTop=pe;}},exportToPDF:async S=>{await he.exportToPDF(ke,S);},exportToExcel:async S=>{await he.exportToExcel(ke,S);},exportToJSON:()=>he.exportToJSON(ke),exportToCSV:()=>he.exportToCSV(ke),importFromJSON:S=>{let E=he.importFromJSON(S);be(E);},getTasks:()=>ke,refresh:()=>{be(S=>[...S]);},clearAll:()=>{be([]);}}),[ke,Ke,F,Ce,Z,Te,O,ze]);let xt=useCallback(S=>{H(E=>E.map(K=>K.id===S?{...K,visible:!K.visible}:K));},[]),Ve=useCallback((S,E)=>{H(K=>K.map(ae=>{if(ae.id!==S)return ae;let pe=ae.minWidth??100,Se=ae.maxWidth??800,It=Math.max(pe,Math.min(Se,E));return {...ae,width:It}}));},[]),ft=useCallback(S=>{be(E=>{let K=_i(E,S),ae=pe=>{for(let Se of pe){if(Se.id===S){Oe.current.set(S,Se.isExpanded??true);return}Se.subtasks?.length&&ae(Se.subtasks);}};return ae(K),dt(),K}),a.onTaskToggleExpand?.(S);},[a,dt]),aa=useCallback((S,E)=>{if(Ie&&Ie(S,E)===false)return;let ae=he.findTaskById(ke,S)?.progress,pe=It=>It.map(ut=>ut.id===S?{...ut,...E}:ut.subtasks?{...ut,subtasks:pe(ut.subtasks)}:ut);be(pe(ke));let Se=he.findTaskById(pe(ke),S);Se&&(A?.(Se),M?.(Se),E.progress!==void 0&&ae!==void 0&&E.progress!==ae&&T?.(S,ae,E.progress));},[ke,A,Ie,M,T]),Ca=useCallback(S=>{S.length!==0&&(be(E=>$i(E,S)),a.onTaskIndent?.(S[0]));},[a]),jt=useCallback(S=>{S.length!==0&&(be(E=>Ui(E,S)),a.onTaskOutdent?.(S[0]));},[a]),Ze=useCallback((S,E,K)=>{be(ae=>Kc(ae,S,E,K)),a.onTaskReparent?.(S,E,K);},[a]),Kt=useCallback((S,E)=>{S.length!==0&&(be(K=>zi(K,S,E)),a.onTaskMove?.(S[0],E));},[a]),la=useCallback(async S=>{let E=[];for(let K of S)R&&await Promise.resolve(R(K))===false||E.push(K);E.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(E):(be(K=>Hi(K,E)),E.forEach(K=>a.onTaskDelete?.(K))),L&&E.forEach(K=>L(K)));},[a,R,L]),Fr=useCallback(S=>{be(E=>Wi(E,S)),S.forEach(E=>a.onTaskDuplicate?.(E));},[a]),gu=useCallback((S,E)=>{be(K=>{let{tasks:ae,newTask:pe}=jc(K,S,E);return ge&&ge(pe)===false?K:(a.onTaskCreate?.(pe.parentId,pe.position||0),fe?.(pe),ae)});},[a,ge,fe]),fu=useCallback((S,E)=>{be(K=>Gi(K,S,E)),a.onTaskRename?.(S,E);},[a]),Ss=useCallback(S=>{be(E=>{let{tasks:K}=Vi(E,S);return a.onTaskCreate?.(S,0),K});},[a]),bu=useCallback((S,E,K)=>{let ae=S.startDate?Math.round((E.getTime()-S.startDate.getTime())/864e5):0,pe=ut=>ut.map(Yt=>Yt.id===S.id?{...Yt,startDate:E,endDate:K,...S.segments&&{segments:S.segments}}:Yt.subtasks?{...Yt,subtasks:pe(Yt.subtasks)}:Yt),Se=pe(ke);Se=he.autoScheduleDependents(Se,S.id,ae),be(Se);let It={...S,startDate:E,endDate:K};A?.(It);},[ke,A]),hu=useCallback((S,E)=>{I?.(S,E),He({isOpen:true,x:E.clientX,y:E.clientY,task:S});},[I]),yu=useCallback((S,E)=>{let K=he.splitTask(ke,S.id,E);be(K),He({isOpen:false,x:0,y:0,task:null});},[ke]),Ql=useCallback(S=>{let E=he.findTaskById(ke,S.id)||S;v?.(E),W||nt(E);},[ke,v,W]),ed=useCallback((S,E,K)=>{let ae=new Map,pe=Ta=>{Ta.forEach(Ea=>{Ea.dependencies&&ae.set(Ea.id,Ea.dependencies),Ea.subtasks&&pe(Ea.subtasks);});};pe(K);let Se=ae.get(E)||[];ae.set(E,[...Se,S]);let It=new Set,ut=new Set,Yt=Ta=>{if(!It.has(Ta)){It.add(Ta),ut.add(Ta);let Ea=ae.get(Ta)||[];for(let Lr of Ea){if(!It.has(Lr)&&Yt(Lr))return true;if(ut.has(Lr))return true}}return ut.delete(Ta),false};return Yt(E)},[]),td=useCallback((S,E)=>{if(ed(S.id,E,ke)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
342
|
+
</Project>`,p=new Blob([i],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(p),l.download=a,l.click(),URL.revokeObjectURL(l.href);},calculateCriticalPath:e=>{let t=he.flattenTasks(e),a=t.filter(i=>i.startDate&&i.endDate);if(a.length===0)return [];let r=new Map,o=i=>{if(r.has(i.id))return;let p=i.startDate&&i.endDate?he.calculateDuration(i.startDate,i.endDate):0,l=0;if(i.dependencies&&i.dependencies.length>0)for(let y of i.dependencies){let k=t.find(C=>C.id===y);if(k){o(k);let C=r.get(y)?.ef||0;l=Math.max(l,C);}}let f=l+p;r.set(i.id,{es:l,ef:f});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,c=i=>{if(n.has(i.id))return;let p=i.startDate&&i.endDate?he.calculateDuration(i.startDate,i.endDate):0,l=t.filter(k=>k.dependencies&&k.dependencies.includes(i.id)),f=s;if(l.length>0)for(let k of l){c(k);let C=n.get(k.id)?.ls||0;f=Math.min(f,C);}let y=f-p;n.set(i.id,{ls:y,lf:f});};a.forEach(c);let g=[];for(let i of a){let p=r.get(i.id),l=n.get(i.id);if(p&&l){let f=l.ls-p.es;Math.abs(f)<.01&&g.push(i.id);}}return g},calculateSlack:(e,t)=>{let a=he.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(he.calculateCriticalPath(e).includes(t))return 0;let o=he.getDependentTasks(e,t);if(o.length===0){let c=he.getLatestEndDate(e);if(!c)return null;let g=he.calculateDuration(a.endDate,c);return Math.max(0,g)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,g)=>c-g)[0];if(!s)return null;let n=he.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>he.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=he.findTaskById(e,t);if(!r||!r.endDate)return e;let o=he.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let c=he.calculateDuration(n.startDate,n.endDate),g;a!==void 0?(g=new Date(n.startDate),g.setDate(g.getDate()+a)):(g=new Date(r.endDate),g.setDate(g.getDate()+1));let i=he.calculateEndDate(g,c),p=l=>l.map(f=>f.id===n.id?{...f,startDate:g,endDate:i}:f.subtasks?{...f,subtasks:p(f.subtasks)}:f);s=p(s),s=he.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,c)=>{if(a===0)return [];let g=[],i=o.getTime(),p=1e3*60*60*24,l=he.findTaskById(e,t);if(!l||!l.endDate)return [];let f=(y,k,C=new Set)=>{if(C.has(y))return;C.add(y);let h=he.getDependentTasks(e,y);for(let b of h){if(!b.startDate||!b.endDate)continue;let u=r.findIndex(T=>T.id===b.id);if(u===-1)continue;let x=b.startDate.getTime(),N=(b.endDate.getTime()-x)/p,B=(x-i)/p*s,v=B+k*s,I=Math.max(N*s,s),F=c+u*n+12;g.push({taskId:b.id,taskName:b.name,originalX:B,previewX:v,width:I,y:F,rowIndex:u,daysDelta:k,color:b.color}),f(b.id,k,C);}};return f(t,a),g},splitTask:(e,t,a,r=3)=>{let o=he.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let n=new Date(a);n.setDate(n.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let g=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:c}],i=p=>p.map(l=>l.id===o.id?{...l,endDate:c,segments:g}:l.subtasks?{...l,subtasks:i(l.subtasks)}:l);return i(e)}};function as({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,locale:c="en",templates:g,dependencyLineStyle:i="curved",onTaskClick:p,onTaskDblClick:l,onTaskContextMenu:f,onTaskDateChange:y,onDependencyCreate:k,onDependencyDelete:C}){let b=Vr(),[u,x]=useState([]),[m,N]=useState(null),w=useCallback(A=>{N(A);},[]),B=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),v=r==="day"?60:r==="week"?20:8,I=B*v*n,F=A=>{let R=new Date(Date.UTC(A.getFullYear(),A.getMonth(),A.getDate())),L=R.getUTCDay()||7;R.setUTCDate(R.getUTCDate()+4-L);let j=new Date(Date.UTC(R.getUTCFullYear(),0,1));return Math.ceil(((R.getTime()-j.getTime())/864e5+1)/7)},T=A=>{let R=A.getDay();return R===0||R===6},H=useCallback(A=>{let R=Math.round(A/(v*n)),L=new Date(o);return L.setDate(L.getDate()+R),L},[o,v,n]),O=useCallback((A,R)=>{if(R.startDate&&R.endDate)return;let L=A.currentTarget.ownerSVGElement;if(!L)return;let j=L.createSVGPoint();j.x=A.clientX,j.y=A.clientY;let J=j.matrixTransform(L.getScreenCTM()?.inverse()),U=H(J.x),ge=new Date(U);ge.setDate(ge.getDate()+1),y?.(R,U,ge);},[H,y]),K=useMemo(()=>{let A=J=>J.map(U=>{if(U.subtasks&&U.subtasks.length>0){let ge=A(U.subtasks),le=ge.filter(Fe=>Fe.startDate&&Fe.endDate);if(le.length>0){let Fe=le.map(Ke=>Ke.startDate.getTime()),qe=le.map(Ke=>Ke.endDate.getTime()),et=new Date(Math.min(...Fe)),de=new Date(Math.max(...qe));return {...U,subtasks:ge,startDate:et,endDate:de}}return {...U,subtasks:ge}}return U}),R=(J,U=[])=>{for(let ge of J)U.push(ge),ge.subtasks&&ge.subtasks.length>0&&(ge.isExpanded===void 0||ge.isExpanded)&&R(ge.subtasks,U);return U},L=A(e);return R(L)},[e]),ae=useCallback(A=>{if(!A.startDate||!A.endDate)return {x:0,width:0};let R=A.startDate.getTime(),L=A.endDate.getTime(),j=o.getTime(),J=(R-j)/(1e3*60*60*24),U=(L-R)/(1e3*60*60*24),ge=J*v*n,le=Math.max(v*n,40),Fe=Math.max(U*v*n,le);return {x:ge,width:Fe}},[o,v,n]),ne=useMemo(()=>K.filter(A=>A.startDate&&A.endDate).map(A=>{let{x:R,width:L}=ae(A),J=K.findIndex(U=>U.id===A.id)*a+12;return {id:A.id,x:R,y:J,width:L,height:32}}),[K,ae]),oe=useCallback((A,R,L)=>{if(!L||R===0){x([]);return}let j=he.calculateCascadePreview(e,A,R,K,o,v*n,a,48);x(j);},[e,K,o,v,n,a,48]),ye=useMemo(()=>{let A=[],R=new Date(o);for(;R<=s;){let J=(R.getTime()-o.getTime())/864e5*v*n;if(r==="day")A.push({date:new Date(R),label:R.toLocaleDateString(c,{day:"numeric",month:"short"}),x:J}),R.setDate(R.getDate()+1);else if(r==="week"){let U=F(R);A.push({date:new Date(R),label:`${b.labels.week} ${U}`,x:J}),R.setDate(R.getDate()+7);}else A.push({date:new Date(R),label:R.toLocaleDateString(c,{month:"short",year:"numeric"}),x:J}),R.setMonth(R.getMonth()+1);}return A},[o,s,r,v,n,c,b.labels.week]),fe=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*v*n,[o,v,n]),Re=Math.max(K.length*a,552);return jsxs("div",{className:"w-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxs("svg",{width:Math.max(I,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(I,1e3),height:48,fill:t.bgGrid}),ye.map((A,R)=>jsxs("g",{children:[R>0&&jsx("line",{x1:A.x,y1:0,x2:A.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:A.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:A.label})]},`header-${R}`)),fe>=0&&fe<=I&&jsx("circle",{cx:fe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(I,1e3),height:Re,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxs("defs",{children:[jsx("filter",{id:"shadow",children:jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsx("rect",{x:0,y:0,width:Math.max(I,1e3),height:Re,fill:t.bgPrimary}),ye.map((A,R)=>{let L=ye[R+1]?.x||I,j=T(A.date);return jsxs("g",{children:[j&&jsx("rect",{x:A.x,y:0,width:L-A.x,height:K.length*a,fill:t.bgWeekend,opacity:1}),R>0&&jsx("line",{x1:A.x,y1:0,x2:A.x,y2:K.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},R)}),K.map((A,R)=>{let L=A.startDate&&A.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:R*a,width:I,height:a,fill:R%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${A.id}`),!L&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:R*a,width:I,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:j=>O(j,A),onMouseEnter:j=>{j.currentTarget.setAttribute("fill",t.accentLight),j.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:j=>{j.currentTarget.setAttribute("fill","transparent"),j.currentTarget.setAttribute("opacity","1");}},`clickable-${A.id}`),jsx("text",{x:fe>0?fe:100,y:R*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:b.labels.clickToSetDates},`placeholder-${A.id}`)]})]},`row-group-${A.id}`)}),K.map((A,R)=>{if(!A.startDate||!A.endDate)return null;let{x:L,width:j}=ae(A),J=R*a+12,U=A.subtasks&&A.subtasks.length>0&&!A.isMilestone;return A.isMilestone?jsx(es,{task:A,x:L+j/2,y:J+16,theme:t,onClick:p},A.id):U?jsxs("g",{onClick:()=>p?.(A),onContextMenu:ge=>{ge.preventDefault(),ge.stopPropagation(),f?.(A,ge);},style:{cursor:"default"},children:[jsx("rect",{x:L,y:J,width:j,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:L,y1:J,x2:L+j,y2:J,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:L,y1:J,x2:L,y2:J+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:L+j,y1:J,x2:L+j,y2:J+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:L,y1:J+32,x2:L+j,y2:J+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),j>60&&jsx("text",{x:L+12,y:J+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:A.name})]},A.id):jsx(qn,{task:A,x:L,y:J,width:j,theme:t,dayWidth:v*n,startDate:o,templates:g,onClick:p,onDoubleClick:l,onContextMenu:f,onDateChange:y,onDependencyCreate:k,allTaskPositions:ne,onDragMove:oe,onHoverChange:w},A.id)}),K.map((A,R)=>!A.dependencies||A.dependencies.length===0||!A.startDate||!A.endDate?null:A.dependencies.map(L=>{let j=K.find(de=>de.id===L);if(!j||!j.startDate||!j.endDate)return null;let J=K.findIndex(de=>de.id===L),U=ae(j),ge=ae(A),le=U.x+U.width,Fe=J*a+28,qe=ge.x,et=R*a+28;return jsx(Zn,{x1:le,y1:Fe,x2:qe,y2:et,theme:t,lineStyle:i,onDelete:()=>C?.(A.id,L)},`dep-${L}-${A.id}`)})),u.map(A=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:A.previewX,y:A.y-48,width:A.width,height:32,rx:8,fill:A.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(A.daysDelta)>0&&jsx("text",{x:A.previewX+A.width/2,y:A.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:A.daysDelta>0?`+${A.daysDelta}d`:`${A.daysDelta}d`})]},`cascade-preview-${A.taskId}`)),fe>=0&&fe<=I&&jsx("line",{x1:fe,y1:0,x2:fe,y2:Re,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),m&&jsx(am,{tooltipData:m,theme:t})]})]})}var qb=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],sm=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsx("circle",{cx:"12",cy:"12",r:"4"})]}),Xb=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),Jb=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),Zb=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),Qb=()=>jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsx(motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function rs({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:c,onDependencyDelete:g}){let[i,p]=useState(false),[l,f]=useState(false),[y,k]=useState([]),[C,h]=useState(""),[b,u]=useState(false),[x,m]=useState(true),N=useRef(null),w=useRef(null),B=useRef(null),{enabled:v=true,placeholder:I='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:F="bottom-right",onCommand:T,suggestions:H=qb,maxHistory:O=50,persistHistory:K}=a,ae=K?.storageKey||"gantt-ai-history",ne=K?.maxMessages??5;useEffect(()=>{if(K?.enabled)try{let R=localStorage.getItem(ae);if(R){let j=JSON.parse(R).map(J=>({...J,timestamp:new Date(J.timestamp)}));k(j.slice(-ne));}}catch(R){console.warn("[GanttAIAssistant] Failed to load persisted history:",R);}},[K?.enabled,ae,ne]),useEffect(()=>{if(K?.enabled&&y.length>0)try{let R=y.filter(L=>!L.isLoading).slice(-ne);localStorage.setItem(ae,JSON.stringify(R));}catch(R){console.warn("[GanttAIAssistant] Failed to persist history:",R);}},[y,K?.enabled,ae,ne]),useEffect(()=>{w.current&&w.current.scrollIntoView({behavior:"smooth"});},[y]),useEffect(()=>{i&&!l&&N.current&&setTimeout(()=>N.current?.focus(),100);},[i,l]);let oe=useCallback(R=>{if(R.success)switch(R.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":R.taskId&&R.updates&&o?.(R.taskId,R.updates);break;case "create_task":R.newTask&&s?.(R.newTask);break;case "delete_task":R.taskId&&n?.(R.taskId);break;case "link_tasks":R.dependencyFrom&&R.dependencyTo&&c?.(R.dependencyFrom,R.dependencyTo);break;case "unlink_tasks":R.taskId&&R.dependencyFrom&&g?.(R.taskId,R.dependencyFrom);break}},[o,s,n,c,g]),ye=useCallback(async R=>{if(!R.trim()||b)return;let L={id:`user-${Date.now()}`,role:"user",content:R,timestamp:new Date};k(J=>[...J.slice(-(O-1)),L]),h(""),m(false),u(true);let j={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};k(J=>[...J,j]);try{if(T){let J=await T(R,e);k(U=>{let ge=U.filter(Fe=>!Fe.isLoading),le={id:`assistant-${Date.now()}`,role:"assistant",content:J.message,timestamp:new Date,command:J};return [...ge,le]}),oe(J);}else k(J=>[...J.filter(ge=>!ge.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(J){k(U=>[...U.filter(le=>!le.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${J instanceof Error?J.message:"Unknown error"}`,timestamp:new Date}]);}finally{u(false);}},[b,O,T,e,oe]),fe=R=>{R.preventDefault(),ye(C);},Re=R=>{h(R),N.current?.focus();};if(useEffect(()=>{let R=L=>{(L.metaKey||L.ctrlKey)&&L.key==="k"&&(L.preventDefault(),p(j=>!j),i||f(false)),L.key==="Escape"&&i&&p(false);};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[i]),useEffect(()=>{if(!i)return;let R=j=>{let J=j.target;B.current&&!B.current.contains(J)&&p(false);},L=setTimeout(()=>{document.addEventListener("mousedown",R);},100);return ()=>{clearTimeout(L),document.removeEventListener("mousedown",R);}},[i]),!v)return null;let A={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxs(ft,{children:[jsx(AnimatePresence,{children:!i&&jsxs(motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${A[F]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>p(true),children:[jsx(sm,{}),jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsx(AnimatePresence,{children:i&&jsxs(motion.div,{ref:B,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:l?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${A[F]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsx(sm,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>f(R=>!R),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(Zb,{})}),jsx("button",{onClick:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(Jb,{})})]})]}),jsx(AnimatePresence,{children:!l&&jsxs(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[y.length===0&&x&&jsxs("div",{className:"space-y-3",children:[jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsx("div",{className:"flex flex-wrap gap-2",children:H.slice(0,4).map((R,L)=>jsx("button",{onClick:()=>Re(R),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:R.length>30?R.slice(0,30)+"...":R},L))})]}),y.map(R=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${R.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${R.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:R.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:R.role==="user"?"white":t.textPrimary},children:[R.isLoading?jsx(Qb,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:R.content}),R.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:R.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:R.command.success?"#10B981":"#EF4444"},children:[R.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:R.command.type.replace(/_/g," ")})]})]})},R.id)),jsx("div",{ref:w})]}),jsxs("form",{onSubmit:fe,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsx("input",{ref:N,type:"text",value:C,onChange:R=>h(R.target.value),placeholder:I,disabled:b,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!C.trim()||b,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:C.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:C.trim()?"white":t.textSecondary},children:jsx(Xb,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function im(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((i,p=true)=>{r(l=>{let f=typeof i=="function"?i(l.present):i;if(o.current)return {...l,present:f};if(!p)return {...l,present:f};let y=[...l.past,l.present];return y.length>t&&y.shift(),{past:y,present:f,future:[]}});},[t]),n=useCallback(()=>{r(i=>{if(i.past.length===0)return i;let p=i.past[i.past.length-1],l=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:l,present:p,future:[i.present,...i.future]}});},[]),c=useCallback(()=>{r(i=>{if(i.future.length===0)return i;let p=i.future[0],l=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:p,future:l}});},[]),g=useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:g}}function lm({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=n=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,g=c?n.metaKey:n.ctrlKey;if(g&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!c&&g&&n.key==="y"){n.preventDefault(),t();return}if(c&&g&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var rh={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${he.formatDate(e.startDate)} - ${he.formatDate(e.endDate)}`);let a=he.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${a} days`);}if(e.progress!==void 0&&t.push(`Progress: ${e.progress}%`),e.status&&t.push(`Status: ${e.status}`),e.assignees&&e.assignees.length>0){let a=e.assignees.map(r=>r.name).join(", ");t.push(`Assigned: ${a}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,a)=>a,taskClass:e=>{let t=[];return e.isCriticalPath&&t.push("critical-path"),e.status==="completed"?t.push("completed"):e.status==="in-progress"?t.push("in-progress"):e.status==="todo"&&t.push("todo"),e.isMilestone&&t.push("milestone"),t.join(" ")},milestoneContent:e=>`\u25C6 ${e.name}`,dateFormat:e=>he.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function dm(e){return {...rh,...e}}var mh=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},pm=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:c="comfortable",showThemeSelector:g=true,showExportButton:i=true,availableUsers:p=[],templates:l,enableAutoCriticalPath:f=true,persistExpandedState:y,persistFilter:k,aiAssistant:C,locale:h="en",customTranslations:b,showCreateTaskButton:u=false,createTaskLabel:x,onCreateTask:m,taskFilter:N,onTaskFilterChange:w,onThemeChange:B,onTaskClick:v,onTaskDblClick:I,onTaskContextMenu:F,onTaskUpdate:T,onProgressChange:H,onTaskEdit:O,onTaskAddSubtask:K,onTaskMarkIncomplete:ae,onTaskSetInProgress:ne,onDependencyCreate:oe,onDependencyDelete:ye,onBeforeTaskAdd:fe,onAfterTaskAdd:Re,onBeforeTaskUpdate:A,onAfterTaskUpdate:R,onBeforeTaskDelete:L,onAfterTaskDelete:j}=a,U=useContext(zn)?.theme,[ge,le]=useState(U||s||"dark"),[Fe,qe]=useState(n),[et,de]=useState(c),[Ke,dt]=useState(1),vt=useCallback(()=>k?typeof k=="string"?k:"gantt-filter-state":null,[k]),[kt,$]=useState(()=>{if(!k)return "all";try{let D=typeof k=="string"?k:"gantt-filter-state",P=localStorage.getItem(D);if(P){let V=JSON.parse(P);if(V.taskFilter)return V.taskFilter}}catch(D){console.warn("[GanttBoard] Error loading filter state from localStorage:",D);}return "all"}),me=N??kt,Le=w??$,[Se,Ye]=useState(()=>{if(!k)return false;try{let D=typeof k=="string"?k:"gantt-filter-state",P=localStorage.getItem(D);if(P){let V=JSON.parse(P);if(typeof V.hideCompleted=="boolean")return V.hideCompleted}}catch(D){console.warn("[GanttBoard] Error loading hideCompleted state from localStorage:",D);}return false});useEffect(()=>{let D=vt();if(D)try{let P={taskFilter:kt,hideCompleted:Se};localStorage.setItem(D,JSON.stringify(P));}catch(P){console.warn("[GanttBoard] Error saving filter state to localStorage:",P);}},[kt,Se,vt]);let[Je,Pt]=useState(0),[Oe,Z]=useState(false),[xe,ze]=useState(null),[Be,st]=useState({isOpen:false,x:0,y:0,task:null}),[nt,Ve]=useState(null),[Vt,Bt]=useState(null);useEffect(()=>{U&&U!==ge&&le(U);},[U]),useEffect(()=>{s&&s!==ge&&le(s);},[s]);let Ze=useCallback(D=>{le(D),B?.(D);},[B]),{state:te,setState:S,undo:Ce,redo:X,canUndo:we,canRedo:ke,clearHistory:He}=im(t,50),$e=useCallback(()=>y?typeof y=="string"?y:"gantt-expanded-tasks":null,[y]),tt=useRef(new Map),_=useRef(false);if(!_.current&&y){_.current=true;let D=typeof y=="string"?y:"gantt-expanded-tasks";try{let P=localStorage.getItem(D);if(P){let V=JSON.parse(P);Array.isArray(V)&&(tt.current=new Map(V));}}catch(P){console.warn("[GanttBoard] Error loading expanded state from localStorage:",P);}}let Y=useCallback(()=>{let D=$e();if(D)try{let P=Array.from(tt.current.entries());localStorage.setItem(D,JSON.stringify(P));}catch(P){console.warn("[GanttBoard] Error saving expanded state to localStorage:",P);}},[$e]);useEffect(()=>{let D=P=>P.map(V=>{let re=tt.current.get(V.id),pe=re!==void 0?{...V,isExpanded:re}:V;return pe.subtasks?.length?{...pe,subtasks:D(pe.subtasks)}:pe});tt.current.size>0?S(D(t)):S(t);},[t,S]);let be=useRef(t),je=useRef(true);useEffect(()=>{if(je.current){je.current=false,be.current=te;return}if(!r)return;let D=JSON.stringify(be.current),P=JSON.stringify(te);D!==P&&(be.current=te,r(te));},[te,r]);let Ie=useMemo(()=>Ai(h,b),[h,b]),z=useCallback(D=>[{id:"name",label:D.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:D.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:D.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:D.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:D.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:D.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:D.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:D.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[se,We]=useState(()=>z(Ie));useEffect(()=>{We(D=>D.map(P=>({...P,label:Ie.columns[P.id==="name"?"taskName":P.id]||P.label})));},[Ie]);let Nt=useMemo(()=>se.filter(P=>P.visible).reduce((P,V)=>P+V.width,0),[se]),mt=useRef(se.filter(D=>D.visible).map(D=>D.id).join(","));useEffect(()=>{let D=se.filter(re=>re.visible),P=D.map(re=>re.id).join(","),V=mt.current;if(P!==V){let re=D.some(De=>De.id!=="name"),pe=V.includes(",");re?!pe&&re&&ze(null):ze(null),mt.current=P;}},[se]);let Dr=60,fr=.6,$a=useMemo(()=>{let P=Nt+Dr,V=typeof window<"u"?window.innerWidth*fr:800,re=Math.max(P,V);return xe!==null?Math.max(200,Math.min(xe,re)):Math.max(200,P)},[xe,Nt]),M=useRef(null),W=useRef(null),Ee=useRef(null),Pe=useMemo(()=>Fc(ge),[ge]),$t=useMemo(()=>({theme:Pe,themeName:ge}),[Pe,ge]),ie=useMemo(()=>dm(l),[l]),Ge=useMemo(()=>{if(!f)return te;let D=he.calculateCriticalPath(te),P=V=>V.map(re=>({...re,isCriticalPath:D.includes(re.id),subtasks:re.subtasks?P(re.subtasks):void 0}));return P(te)},[te,f]),yt=useMemo(()=>{if(me==="all"&&!Se)return Ge;let D=P=>{let V=[];for(let re of P){let pe=re.subtasks?.length?D(re.subtasks):void 0,De=false;if(Se)De=re.progress<100;else switch(me){case "all":De=true;break;case "incomplete":De=re.progress<100;break;case "in_progress":De=re.progress>0&&re.progress<100;break;case "completed":De=re.progress===100;break}(De||pe&&pe.length>0)&&V.push({...re,subtasks:pe});}return V};return D(Ge)},[Ge,me,Se]),Ue=mh(et);lm({undo:Ce,redo:X,canUndo:we,canRedo:ke,enabled:true}),useImperativeHandle(o,()=>({getTask:D=>he.findTaskById(te,D),addTask:(D,P)=>{S(V=>{if(!P)return [...V,{...D,level:0}];let re=pe=>pe.map(De=>De.id===P?{...De,subtasks:[...De.subtasks||[],{...D,parentId:P,level:(De.level||0)+1}],isExpanded:true}:De.subtasks?{...De,subtasks:re(De.subtasks)}:De);return re(V)});},updateTask:(D,P)=>{S(V=>{let re=pe=>pe.map(De=>De.id===D?{...De,...P}:De.subtasks?{...De,subtasks:re(De.subtasks)}:De);return re(V)});},deleteTask:D=>{S(P=>{let V=re=>re.filter(pe=>pe.id===D?false:(pe.subtasks&&(pe.subtasks=V(pe.subtasks)),true));return V(P)});},deleteTasks:D=>{S(P=>Wi(P,D));},duplicateTask:D=>{S(P=>Gi(P,[D]));},splitTask:(D,P,V=3)=>{S(re=>he.splitTask(re,D,P,V));},calculateEndDate:he.calculateEndDate,calculateDuration:he.calculateDuration,validateDependency:(D,P)=>!he.validateDependencies(te,D,P),getAllTasks:()=>he.flattenTasks(te),getTasksByStatus:D=>he.flattenTasks(te).filter(P=>P.status===D),getTasksByParent:D=>D?he.findTaskById(te,D)?.subtasks||[]:te.filter(V=>!V.parentId),getCriticalPath:()=>he.flattenTasks(te).filter(D=>D.isCriticalPath),indentTask:D=>{S(P=>Ui(P,[D]));},outdentTask:D=>{S(P=>zi(P,[D]));},moveTask:(D,P)=>{S(V=>Hi(V,[D],P));},createSubtask:async D=>{let{tasks:P,newTask:V}=ji(te,D);if(fe){let re=fe({...V,parentId:D});if((re instanceof Promise?await re:re)===false)return}S(P),Re&&Re({...V,parentId:D});},scrollToTask:D=>{let V=he.flattenTasks(te).findIndex(re=>re.id===D);if(V!==-1&&M.current){let re=V*Ue;M.current.scrollTo({top:re,behavior:"smooth"}),W.current&&W.current.scrollTo({top:re,behavior:"smooth"});}},highlightTask:(D,P=2e3)=>{},expandTask:D=>{S(P=>{let V=re=>re.map(pe=>pe.id===D?{...pe,isExpanded:true}:pe.subtasks?{...pe,subtasks:V(pe.subtasks)}:pe);return V(P)});},collapseTask:D=>{S(P=>{let V=re=>re.map(pe=>pe.id===D?{...pe,isExpanded:false}:pe.subtasks?{...pe,subtasks:V(pe.subtasks)}:pe);return V(P)});},expandAll:()=>{S(D=>{let P=V=>V.map(re=>({...re,isExpanded:true,subtasks:re.subtasks?P(re.subtasks):void 0}));return P(D)});},collapseAll:()=>{S(D=>{let P=V=>V.map(re=>({...re,isExpanded:false,subtasks:re.subtasks?P(re.subtasks):void 0}));return P(D)});},undo:Ce,redo:X,canUndo:()=>we,canRedo:()=>ke,clearHistory:He,exportToPNG:async()=>{if(!Ee.current||!M.current||!W.current)throw new Error("Gantt container not found");let D=Ee.current,P=M.current.querySelector(".gantt-grid-scroll"),V=W.current,re=P?.scrollTop||0,pe=V.scrollTop,De=D.style.overflow,Lt=D.style.height;try{let pt=P?.querySelector(".gantt-taskgrid-content"),qt=V.querySelector("svg"),wa=pt?.scrollHeight||P?.scrollHeight||600,Da=qt?.getBoundingClientRect().height||V.scrollHeight,Qr=(D.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(wa,Da)+20;P&&(P.scrollTop=0),V.scrollTop=0,D.style.overflow="visible",D.style.height=`${Qr}px`,await new Promise(Ir=>setTimeout(Ir,100));let br=await mm(D,{backgroundColor:Pe.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:Ir=>{let ko=window.getComputedStyle(Ir),eo=parseInt(ko.zIndex,10);return !isNaN(eo)&&eo>=50||ko.position==="fixed"}});return new Promise((Ir,ko)=>{br.toBlob(eo=>{eo?Ir(eo):ko(new Error("Failed to create blob from canvas"));},"image/png");})}finally{D.style.overflow=De,D.style.height=Lt,P&&(P.scrollTop=re),V.scrollTop=pe;}},exportToPDF:async D=>{await he.exportToPDF(te,D);},exportToExcel:async D=>{await he.exportToExcel(te,D);},exportToJSON:()=>he.exportToJSON(te),exportToCSV:()=>he.exportToCSV(te),importFromJSON:D=>{let P=he.importFromJSON(D);S(P);},getTasks:()=>te,refresh:()=>{S(D=>[...D]);},clearAll:()=>{S([]);}}),[te,Ce,X,we,ke,He,Pe,Ue]);let gt=useCallback(D=>{We(P=>P.map(V=>V.id===D?{...V,visible:!V.visible}:V));},[]),ya=useCallback((D,P)=>{We(V=>V.map(re=>{if(re.id!==D)return re;let pe=re.minWidth??100,De=re.maxWidth??800,Lt=Math.max(pe,Math.min(De,P));return {...re,width:Lt}}));},[]),ka=useCallback(D=>{S(P=>{let V=Vi(P,D),re=pe=>{for(let De of pe){if(De.id===D){tt.current.set(D,De.isExpanded??true);return}De.subtasks?.length&&re(De.subtasks);}};return re(V),Y(),V}),a.onTaskToggleExpand?.(D);},[a,Y]),Mt=useCallback((D,P)=>{if(A&&A(D,P)===false)return;let re=he.findTaskById(te,D)?.progress,pe=Lt=>Lt.map(pt=>pt.id===D?{...pt,...P}:pt.subtasks?{...pt,subtasks:pe(pt.subtasks)}:pt);S(pe(te));let De=he.findTaskById(pe(te),D);De&&(T?.(De),R?.(De),P.progress!==void 0&&re!==void 0&&P.progress!==re&&H?.(D,re,P.progress));},[te,T,A,R,H]),Xe=useCallback(D=>{D.length!==0&&(S(P=>Ui(P,D)),a.onTaskIndent?.(D[0]));},[a]),Yt=useCallback(D=>{D.length!==0&&(S(P=>zi(P,D)),a.onTaskOutdent?.(D[0]));},[a]),ua=useCallback((D,P,V)=>{S(re=>Yc(re,D,P,V)),a.onTaskReparent?.(D,P,V);},[a]),Fr=useCallback((D,P)=>{D.length!==0&&(S(V=>Hi(V,D,P)),a.onTaskMove?.(D[0],P));},[a]),Ss=useCallback(async D=>{let P=[];for(let V of D)L&&await Promise.resolve(L(V))===false||P.push(V);P.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(P):(S(V=>Wi(V,P)),P.forEach(V=>a.onTaskDelete?.(V))),j&&P.forEach(V=>j(V)));},[a,L,j]),fu=useCallback(D=>{S(P=>Gi(P,D)),D.forEach(P=>a.onTaskDuplicate?.(P));},[a]),bu=useCallback((D,P)=>{S(V=>{let{tasks:re,newTask:pe}=Kc(V,D,P);return fe&&fe(pe)===false?V:(a.onTaskCreate?.(pe.parentId,pe.position||0),Re?.(pe),re)});},[a,fe,Re]),hu=useCallback((D,P)=>{S(V=>_i(V,D,P)),a.onTaskRename?.(D,P);},[a]),Es=useCallback(D=>{S(P=>{let{tasks:V}=ji(P,D);return a.onTaskCreate?.(D,0),V});},[a]),yu=useCallback((D,P,V)=>{let re=D.startDate?Math.round((P.getTime()-D.startDate.getTime())/864e5):0,pe=pt=>pt.map(qt=>qt.id===D.id?{...qt,startDate:P,endDate:V,...D.segments&&{segments:D.segments}}:qt.subtasks?{...qt,subtasks:pe(qt.subtasks)}:qt),De=pe(te);De=he.autoScheduleDependents(De,D.id,re),S(De);let Lt={...D,startDate:P,endDate:V};T?.(Lt);},[te,T]),vu=useCallback((D,P)=>{F?.(D,P),st({isOpen:true,x:P.clientX,y:P.clientY,task:D});},[F]),xu=useCallback((D,P)=>{let V=he.splitTask(te,D.id,P);S(V),st({isOpen:false,x:0,y:0,task:null});},[te]),ed=useCallback(D=>{let P=he.findTaskById(te,D.id)||D;I?.(P),O||Ve(P);},[te,I,O]),td=useCallback((D,P,V)=>{let re=new Map,pe=wa=>{wa.forEach(Da=>{Da.dependencies&&re.set(Da.id,Da.dependencies),Da.subtasks&&pe(Da.subtasks);});};pe(V);let De=re.get(P)||[];re.set(P,[...De,D]);let Lt=new Set,pt=new Set,qt=wa=>{if(!Lt.has(wa)){Lt.add(wa),pt.add(wa);let Da=re.get(wa)||[];for(let Lr of Da){if(!Lt.has(Lr)&&qt(Lr))return true;if(pt.has(Lr))return true}}return pt.delete(wa),false};return qt(P)},[]),ad=useCallback((D,P)=>{if(td(D.id,P,te)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
343
343
|
|
|
344
|
-
Task dependencies must flow in one direction only.`);return}let K=ae=>ae.map(pe=>{if(pe.id===E){let Se=pe.dependencies||[];if(!Se.includes(S.id))return {...pe,dependencies:[...Se,S.id]}}return pe.subtasks?{...pe,subtasks:K(pe.subtasks)}:pe});be(K(ke)),oe?.(S.id,E);},[ke,oe,ed]),ad=useCallback((S,E)=>{let K=ae=>ae.map(pe=>{if(pe.id===S&&pe.dependencies){let Se=pe.dependencies.filter(It=>It!==E);return {...pe,dependencies:Se}}return pe.subtasks?{...pe,subtasks:K(pe.subtasks)}:pe});be(K(ke)),re?.(S,E);},[ke,re]),{startDate:yn,endDate:vu}=useMemo(()=>{let S=ke.filter(Se=>Se.startDate&&Se.endDate);if(S.length===0){let Se=new Date,It=new Date(Se);It.setDate(It.getDate()-30);let ut=new Date(Se);return ut.setDate(ut.getDate()+60),{startDate:It,endDate:ut}}let E=S.flatMap(Se=>[Se.startDate,Se.endDate]).filter(Se=>Se!==void 0),K=new Date(Math.min(...E.map(Se=>Se.getTime()))),ae=new Date(Math.max(...E.map(Se=>Se.getTime()))),pe=ne==="day"?7:ne==="week"?14:30;return K.setDate(K.getDate()-pe),ae.setDate(ae.getDate()+pe),{startDate:K,endDate:ae}},[ke,ne]),xu=useCallback(async()=>{if(!P.current||!wa.current||!ta.current)return;await new Promise(Zr=>setTimeout(Zr,200));let S=P.current,E=wa.current.querySelector(".gantt-grid-scroll"),K=ta.current,ae=E?.scrollTop||0,pe=E?.scrollLeft||0,Se=K.scrollTop,It=K.scrollLeft,ut=S.style.overflow,Yt=S.style.height,Ta=E?.style.overflow||"",Ea=K.style.overflow,Lr=S.style.width,vn=K.style.width;try{let Zr=E?.querySelector(".gantt-taskgrid-content"),br=K.querySelector("svg"),Ir=br?.getAttribute("height")?parseInt(br.getAttribute("height"),10):br?.getBoundingClientRect().height||0,ko=Zr?.scrollHeight||E?.scrollHeight||600,Qr=Math.max(Ir,K.scrollHeight),nd=br?.getAttribute("width")?parseInt(br.getAttribute("width"),10):br?.getBoundingClientRect().width||K.scrollWidth,Eu=S.querySelector('[class*="h-12"]')?.offsetHeight||48,Ps=Math.max(ko,Qr,Ir),Ms=Eu+Ps+50,As=(E?.offsetWidth||300)+nd+10;E&&(E.scrollTop=0,E.scrollLeft=0),K.scrollTop=0,K.scrollLeft=0,S.style.overflow="visible",S.style.height=`${Ms}px`,S.style.width=`${As}px`,E&&(E.style.overflow="visible",E.style.height=`${Ps+50}px`),K.style.overflow="visible",K.style.height=`${Ps+50}px`,K.style.width=`${nd+10}px`,await new Promise(Ls=>setTimeout(Ls,150));let Pu=await cm(S,{backgroundColor:O.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:As,height:Ms,windowWidth:As+100,windowHeight:Ms+100,scrollX:0,scrollY:0,ignoreElements:Ls=>{let sd=window.getComputedStyle(Ls),id=parseInt(sd.zIndex,10);return !isNaN(id)&&id>=50||sd.position==="fixed"}}),Fs=document.createElement("a");Fs.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,Fs.href=Pu.toDataURL("image/png"),Fs.click();}finally{S.style.overflow=ut,S.style.height=Yt,S.style.width=Lr,E&&(E.style.overflow=Ta,E.style.height="",E.scrollTop=ae,E.scrollLeft=pe),K.style.overflow=Ea,K.style.height="",K.style.width=vn,K.scrollTop=Se,K.scrollLeft=It;}},[O]),ku=useCallback(async()=>{await he.exportToPDF(ke);},[ke]),wu=useCallback(async()=>{await he.exportToExcel(ke);},[ke]),Cu=useCallback(()=>{let S=he.exportToCSV(ke),E=new Blob([S],{type:"text/csv;charset=utf-8;"}),K=document.createElement("a");K.href=URL.createObjectURL(E),K.download="gantt-chart.csv",K.click(),URL.revokeObjectURL(K.href);},[ke]),Tu=useCallback(()=>{let S=he.exportToJSON(ke),E=new Blob([S],{type:"application/json;charset=utf-8;"}),K=document.createElement("a");K.href=URL.createObjectURL(E),K.download="gantt-chart.json",K.click(),URL.revokeObjectURL(K.href);},[ke]),Nu=useCallback(()=>{he.exportToMSProject(ke,"Gantt Project","project.xml");},[ke]),Du=S=>{S.preventDefault(),Pt(true);},xo=useRef(false),[Es,rd]=useState(false),Ho=useRef({x:0,y:0,scrollLeft:0,scrollTop:0});useEffect(()=>{let S=ta.current,E=wa.current?.querySelector(".gantt-grid-scroll");if(!S||!E)return;let K=()=>{if(xo.current)return;xo.current=true;let ut=S.scrollTop;je(ut),E.scrollTop=ut,requestAnimationFrame(()=>{xo.current=false;});},ae=()=>{if(xo.current)return;xo.current=true;let ut=E.scrollTop;je(ut),S.scrollTop=ut,requestAnimationFrame(()=>{xo.current=false;});},pe=ut=>{if(Qe&&E){let Ta=E.parentElement?.getBoundingClientRect()?.left||0,Ea=ut.clientX-Ta,Lr=200,vn=ie+Mt,Zr=window.innerWidth*pt,br=Math.max(vn,Zr);Ea>=Lr&&Ea<=br&&J(Ea);}if(Es&&S){let Yt=ut.clientX-Ho.current.x,Ta=ut.clientY-Ho.current.y;S.scrollLeft=Ho.current.scrollLeft-Yt,S.scrollTop=Ho.current.scrollTop-Ta;}},Se=()=>{Pt(false),rd(false);},It=ut=>{if(ut.button!==0)return;let Yt=ut.target;Yt.closest("[data-task-bar]")||Yt.closest("[data-dependency-line]")||Yt.closest("button")||Yt.closest('[role="button"]')||Yt.tagName==="rect"&&Yt.getAttribute("data-clickable")==="true"||(rd(true),Ho.current={x:ut.clientX,y:ut.clientY,scrollLeft:S.scrollLeft,scrollTop:S.scrollTop},ut.preventDefault());};return S.addEventListener("scroll",K),E.addEventListener("scroll",ae),S.addEventListener("mousedown",It),document.addEventListener("mousemove",pe),document.addEventListener("mouseup",Se),()=>{S.removeEventListener("scroll",K),E.removeEventListener("scroll",ae),S.removeEventListener("mousedown",It),document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",Se);}},[Qe,Es,ie]);let od=useRef(false),Su=useRef(null);return useLayoutEffect(()=>{if(od.current||ke.length===0||!ta.current)return;od.current=true,Su.current=yn;let S=ta.current,E=new Date,K=ne==="day"?60:ne==="week"?20:8,ae=(E.getTime()-yn.getTime())/(1e3*60*60*24),pe=S.clientWidth,It=ae*K*le-pe/2;ae>=0&&pe>0&&(S.scrollLeft=Math.max(0,It));},[ke.length,yn,ne,le]),jsx(Lo.Provider,{value:se,children:jsx($s.Provider,{value:Me,children:jsxs("div",{ref:P,className:"flex flex-col h-full w-full",style:{backgroundColor:O.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(Gn,{theme:O,timeScale:ne,onTimeScaleChange:Be,zoom:le,onZoomChange:Je,currentTheme:z,onThemeChange:ea,rowDensity:qe,onRowDensityChange:tt,showThemeSelector:g,showCreateTaskButton:b,createTaskLabel:u,onCreateTask:x,taskFilter:vt,onTaskFilterChange:U,hideCompleted:me,onHideCompletedChange:Ae,onExportPNG:i?xu:void 0,onExportPDF:i?ku:void 0,onExportExcel:i?wu:void 0,onExportCSV:i?Cu:void 0,onExportJSON:i?Tu:void 0,onExportMSProject:i?Nu:void 0}),jsxs("div",{ref:wa,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Ar,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsx(Kn,{tasks:de,theme:O,rowHeight:ze,availableUsers:p,templates:Xe,onTaskClick:B,onTaskDblClick:Ql,onTaskContextMenu:I,onTaskToggle:ft,scrollTop:Fe,columns:Ue,onToggleColumn:xt,onColumnResize:Ve,onTaskUpdate:aa,onTaskIndent:Ca,onTaskOutdent:jt,onTaskMove:Kt,onMultiTaskDelete:la,onTaskDuplicate:Fr,onTaskCreate:gu,onTaskRename:fu,onCreateSubtask:Ss,onOpenTaskModal:B?S=>B(S):void 0,onDeleteRequest:(S,E)=>_e({taskId:S,taskName:E}),onTaskReparent:Ze})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:O.border,zIndex:15},onMouseDown:Du}),jsx("div",{ref:ta,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",cursor:Es?"grabbing":"grab",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(as,{tasks:de,theme:O,rowHeight:ze,timeScale:ne,startDate:yn,endDate:vu,zoom:le,locale:C,templates:Xe,dependencyLineStyle:a?.dependencyLineStyle,onTaskClick:B,onTaskDblClick:Ql,onTaskContextMenu:hu,onTaskDateChange:bu,onDependencyCreate:td,onDependencyDelete:ad})})]}),ve.task&&jsx(Io,{isOpen:ve.isOpen,x:ve.x,y:ve.y,theme:O,onClose:()=>He({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=ve.task;if(!S)return [];let E=he.findTaskById(ke,S.id)||S;return E.subtasks&&E.subtasks.length>0?[{id:"addSubtask",label:se.contextMenu?.addSubtask||"Add Subtask",icon:Wt.Add,onClick:()=>{$?$(E):Ss(E.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:se.contextMenu?.deleteTask||"Delete Task",icon:Wt.Delete,onClick:()=>{_e({taskId:E.id,taskName:E.name});}}]:[{id:"edit",label:se.contextMenu?.editTask||"Edit Task",icon:Wt.Pencil,onClick:()=>{W?W(E):nt(E);}},{id:"addSubtask",label:se.contextMenu?.addSubtask||"Add Subtask",icon:Wt.Add,onClick:()=>{$?$(E):Ss(E.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:se.contextMenu?.markIncomplete||"Mark Incomplete",icon:Wt.MarkIncomplete,onClick:()=>{j?j(E):aa(E.id,{status:"todo",progress:0});},disabled:E.status==="todo"},{id:"setInProgress",label:se.contextMenu?.setInProgress||"Set In Progress",icon:Wt.SetInProgress,onClick:()=>{te?te(E):aa(E.id,{status:"in-progress"});},disabled:E.status==="in-progress"},{id:"markComplete",label:se.contextMenu?.markComplete||"Mark Complete",icon:Wt.MarkComplete,onClick:()=>{aa(E.id,{status:"completed",progress:100});},disabled:E.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:se.contextMenu?.splitTask||"Split Task",icon:Wt.Split,onClick:()=>{if(!E.startDate||!E.endDate){console.warn("Cannot split task without dates");return}let ae=E.startDate.getTime(),pe=E.endDate.getTime(),Se=ae+(pe-ae)/2,It=new Date(Se);yu(E,It);},disabled:!E.startDate||!E.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:se.contextMenu?.deleteTask||"Delete Task",icon:Wt.Delete,onClick:()=>{_e({taskId:E.id,taskName:E.name});}}]})()}),jsx(so,{task:Le,isOpen:!!Le,onClose:()=>nt(null),onTaskUpdate:S=>{Le&&(aa(Le.id,S),nt(null));},theme:z==="light"?"light":"dark",locale:C==="es"?"es":"en",availableUsers:p,availableTasks:t}),jsx(AnimatePresence,{children:st&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>_e(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:S=>S.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:O.bgSecondary,border:`1px solid ${O.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${O.border}`},children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"rgba(239, 68, 68, 0.2)"},children:jsx(AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxs("div",{className:"flex-1",children:[jsxs("h3",{className:"text-lg font-semibold",style:{color:O.textPrimary,fontFamily:"Inter, sans-serif"},children:[se.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:O.textSecondary,fontFamily:"Inter, sans-serif"},children:C==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:O.textSecondary,fontFamily:"Inter, sans-serif"},children:[C==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:O.textPrimary},children:['"',st.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:O.bgPrimary,borderTop:`1px solid ${O.border}`},children:[jsx("button",{onClick:()=>_e(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:O.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=O.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:C==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{la([st.taskId]),_e(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),C==="es"?"Eliminar":"Delete"]})]})]})})}),k?.enabled&&jsx(rs,{tasks:ke,theme:O,config:k,onTasksUpdate:be,onTaskUpdate:aa,onTaskCreate:S=>{be(E=>[...E,S]);},onTaskDelete:S=>{la([S]);},onDependencyCreate:(S,E)=>{let K=he.findTaskById(ke,S);K&&td(K,E);},onDependencyDelete:ad})]})})})});var Ji=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Zi=[{id:"low",label:"Baja",color:"#10B981",icon:"\u{1F7E2}"},{id:"medium",label:"Media",color:"#F59E0B",icon:"\u{1F7E1}"},{id:"high",label:"Alta",color:"#F97316",icon:"\u{1F7E0}"},{id:"urgent",label:"Urgente",color:"#EF4444",icon:"\u{1F534}"}];function gm({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:c=a?"edit":"create",theme:g="dark",customStatuses:i=[],availableTags:p=[],onCreateTag:l,attachments:f=[],onUploadAttachments:y,onDeleteAttachment:k}){let C=[...Ji,...i.filter(U=>!Ji.some(me=>me.id===U.id))],h=at[g]||at.dark,[b,u]=useState(false),[x,m]=useState(false),[N,w]=useState(false),[B,v]=useState(false),[I,A]=useState({top:0,left:0}),[T,W]=useState(null),[$,j]=useState(new Date),[te,oe]=useState({top:0,left:0}),[re,ge]=useState(false),[fe,Ie]=useState([]),M=useRef(null),R=useRef(null),L=useRef(null),V=useRef(null),q=useRef(null),[z,ye]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ne,Be]=useState({});useEffect(()=>{a?(ye({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&ge(true)):(ye({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),ge(false),Ie([]));},[a,e]),useEffect(()=>{let U=me=>{M.current&&!M.current.contains(me.target)&&u(false),R.current&&!R.current.contains(me.target)&&m(false),L.current&&!L.current.contains(me.target)&&w(false),V.current&&!V.current.contains(me.target)&&v(false);};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]);let qe=()=>{let U={};return z.name.trim()||(U.name="El nombre es requerido"),z.startDate&&z.endDate&&z.startDate>z.endDate&&(U.endDate="La fecha de fin debe ser posterior a la de inicio"),Be(U),Object.keys(U).length===0},tt=async U=>{if(U.preventDefault(),!!qe())try{let me=c==="create"&&fe.length>0?{...z,pendingFiles:fe}:z;await s(me),Ie([]),t();}catch(me){console.error("Error submitting task:",me);}},le=(U,me)=>{ye(Ae=>{let Fe={...Ae,[U]:me};if(U==="status"){let je=me;je==="todo"?Fe.progress=0:je==="in-progress"?(Ae.progress===0||Ae.progress===100)&&(Fe.progress=50):je==="completed"||je==="closed"?Fe.progress=100:(je==="in-review"||je==="review")&&(Fe.progress=75);}if(U==="progress"){let je=typeof me=="number"?me:parseInt(me,10);je===100&&Ae.status!=="completed"?Fe.status="completed":je>0&&je<100&&Ae.status==="todo"?Fe.status="in-progress":je===0&&Ae.status!=="todo"&&(Fe.status="todo");}return Fe}),ne[U]&&Be(Ae=>{let Fe={...Ae};return delete Fe[U],Fe});},Je=C.find(U=>U.id===z.status)??Ji[0],ct=Zi.find(U=>U.id===z.priority)??Zi[1],wt=yr.find(U=>U.value===z.color)??yr[0],vt={backgroundColor:h.bgSecondary,border:`1px solid ${h.borderLight}`,color:h.textPrimary};return jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsx(motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden","data-theme":g,style:{backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},onClick:U=>U.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${h.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Je.color||h.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:h.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:h.textTertiary},onMouseEnter:U=>{U.currentTarget.style.backgroundColor=h.hoverBg,U.currentTarget.style.color=h.textPrimary;},onMouseLeave:U=>{U.currentTarget.style.backgroundColor="transparent",U.currentTarget.style.color=h.textTertiary;},disabled:n,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:tt,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxs("div",{className:"p-5 space-y-4",children:[jsxs("div",{children:[jsx("input",{type:"text",value:z.name,onChange:U=>le("name",U.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:h.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),ne.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),ne.name]})]}),jsx("div",{children:jsx("textarea",{value:z.description||"",onChange:U=>le("description",U.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:h.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsx("div",{style:{borderTop:`1px solid ${h.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:M,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&u(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...vt,borderColor:Je.color,backgroundColor:`${Je.color}15`},disabled:n,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:Je.color}}),jsx("span",{style:{color:Je.color},children:Je.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:Je.color}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},children:C.map(U=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:h.textPrimary},onMouseEnter:me=>me.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:me=>me.currentTarget.style.backgroundColor="transparent",onClick:()=>{le("status",U.id),u(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:U.color}}),U.title,z.status===U.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:h.accent}})]},U.id))})})]}),jsxs("div",{ref:R,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&m(!x),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:vt,disabled:n,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:ct.color}}),jsx("span",{children:ct.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:h.textTertiary}})]}),jsx(AnimatePresence,{children:x&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},children:Zi.map(U=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:h.textPrimary},onMouseEnter:me=>me.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:me=>me.currentTarget.style.backgroundColor="transparent",onClick:()=>{le("priority",U.id),m(false);},children:[jsx("span",{children:U.icon}),U.label,z.priority===U.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:h.accent}})]},U.id))})})]}),o.length>0&&jsxs("div",{ref:L,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&w(!N),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:vt,disabled:n,children:[z.assignees&&z.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:z.assignees.slice(0,3).map((U,me)=>jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:U.color||h.accent,borderColor:h.bgSecondary},children:U.initials},me))}),z.assignees.length>3&&jsxs("span",{style:{color:h.textTertiary},children:["+",z.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:h.textTertiary}}),jsx("span",{style:{color:h.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:h.textTertiary}})]}),jsx(AnimatePresence,{children:N&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},children:o.map(U=>{let me=z.assignees?.some(Ae=>Ae.name===U.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:h.textPrimary},onMouseEnter:Ae=>Ae.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:Ae=>Ae.currentTarget.style.backgroundColor="transparent",onClick:()=>{let Ae=me?(z.assignees||[]).filter(Fe=>Fe.name!==U.name):[...z.assignees||[],{name:U.name,avatar:U.avatar,initials:U.name.split(" ").map(Fe=>Fe[0]).join("").toUpperCase().slice(0,2),color:h.accent}];le("assignees",Ae);},children:[jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium flex-shrink-0",style:{backgroundColor:h.accent},children:U.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:U.name}),jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:me&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:h.accent}})})]},U.id)})})})]}),jsxs("div",{ref:V,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!n)if(B)v(false);else {if(V.current){let U=V.current.getBoundingClientRect(),me=window.innerHeight,Ae=120,je=me-U.bottom<Ae?U.top-Ae-8:U.bottom+8;A({top:je,left:U.left});}v(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:vt,disabled:n,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:z.color}}),jsx("span",{children:wt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:h.textTertiary}})]}),jsx(AnimatePresence,{children:B&&jsxs(bt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>v(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg",style:{position:"fixed",top:`${I.top}px`,left:`${I.left}px`,zIndex:99999,backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:U=>U.stopPropagation(),children:jsx("div",{style:{padding:"6px 8px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:yr.slice(0,18).map(U=>{let me=z.color===U.value;return jsx("button",{type:"button",onClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),le("color",U.value),v(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:U.name,children:jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:U.value,outline:me?`2px solid ${U.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},U.value)})})})})]})})]}),p.length>0||l?jsx(hr,{selectedTags:z.tags||[],availableTags:p,onChange:U=>le("tags",U),onCreateTag:l,theme:h,disabled:n}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:h.textTertiary}}),jsxs("div",{ref:q,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!n&&!z.isMilestone)if(T==="start")W(null);else {if(q.current){let U=q.current.getBoundingClientRect(),me=window.innerHeight,Ae=320,je=me-U.bottom<Ae?U.top-Ae-8:U.bottom+8;oe({top:je,left:U.left});}W("start"),j(z.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...vt,opacity:z.isMilestone?.5:1,cursor:z.isMilestone?"not-allowed":"pointer"},disabled:n||z.isMilestone,children:z.startDate?z.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:h.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!n&&!z.isMilestone)if(T==="end")W(null);else {if(q.current){let U=q.current.getBoundingClientRect(),me=window.innerHeight,Ae=320,je=me-U.bottom<Ae?U.top-Ae-8:U.bottom+8;oe({top:je,left:U.left});}W("end"),j(z.endDate||z.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...vt,opacity:z.isMilestone?.5:1,cursor:z.isMilestone?"not-allowed":"pointer"},disabled:n||z.isMilestone,children:z.endDate?z.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:T&&jsxs(bt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>W(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"rounded-xl shadow-2xl overflow-hidden flex",style:{position:"fixed",top:`${te.top}px`,left:`${te.left}px`,zIndex:99999,backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},onClick:U=>U.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${h.border}`},children:[(()=>{let U=new Date,me=new Date(U);me.setDate(U.getDate()+1);let Ae=new Date(U);Ae.setDate(U.getDate()+7);let Fe=new Date(U);return Fe.setDate(U.getDate()+14),[{label:"Hoy",date:U},{label:"Ma\xF1ana",date:me},{label:"Pr\xF3xima semana",date:Ae},{label:"2 semanas",date:Fe}].map((Qe,Pt)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:h.textPrimary},onMouseEnter:Re=>Re.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:Re=>Re.currentTarget.style.backgroundColor="transparent",onClick:()=>{T==="start"?(le("startDate",Qe.date),(!z.endDate||Qe.date>z.endDate)&&le("endDate",Qe.date),W("end")):(le("endDate",Qe.date),(!z.startDate||Qe.date<z.startDate)&&le("startDate",Qe.date),W(null));},children:Qe.label},Pt))})(),jsx("div",{style:{borderTop:`1px solid ${h.border}`,margin:"0.5rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:U=>U.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:U=>U.currentTarget.style.backgroundColor="transparent",onClick:()=>{le("startDate",void 0),le("endDate",void 0),W(null);},children:"Borrar fechas"})]}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{type:"button",onClick:()=>j(new Date($.getFullYear(),$.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:h.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:h.textPrimary},children:$.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>j(new Date($.getFullYear(),$.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:h.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((U,me)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:h.textTertiary},children:U},me))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let U=$.getFullYear(),me=$.getMonth(),Ae=new Date(U,me,1).getDay(),Fe=new Date(U,me+1,0).getDate(),je=new Date,Qe=[];for(let Re=Ae-1;Re>=0;Re--)Qe.push({day:new Date(U,me,-Re).getDate(),date:new Date(U,me-1,new Date(U,me,-Re).getDate()),isCurrentMonth:false});for(let Re=1;Re<=Fe;Re++)Qe.push({day:Re,date:new Date(U,me,Re),isCurrentMonth:true});let Pt=42-Qe.length;for(let Re=1;Re<=Pt;Re++)Qe.push({day:Re,date:new Date(U,me+1,Re),isCurrentMonth:false});return Qe.map((Re,J)=>{let ve=Re.date.toDateString()===je.toDateString(),He=z.startDate?.toDateString()===Re.date.toDateString(),Le=z.endDate?.toDateString()===Re.date.toDateString(),nt=z.startDate&&z.endDate&&Re.date>=z.startDate&&Re.date<=z.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Re.isCurrentMonth?He||Le?"#FFF":h.textPrimary:h.textTertiary,backgroundColor:He?"#3B82F6":Le?"#7C3AED":nt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:ve&&!He&&!Le?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{T==="start"?(le("startDate",Re.date),z.endDate&&Re.date>z.endDate&&le("endDate",Re.date),W("end")):(le("endDate",Re.date),z.startDate&&Re.date<z.startDate&&le("startDate",Re.date),W(null));},children:Re.day},J)})})()})]})]})]})})]}),ne.endDate&&jsx("span",{className:"text-xs text-red-400",children:ne.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:h.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:z.progress,onChange:U=>le("progress",parseInt(U.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:h.bgSecondary,accentColor:z.progress<30?"#EF4444":z.progress<70?"#F59E0B":"#10B981"},disabled:n}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${z.progress<30?"#EF4444":z.progress<70?"#F59E0B":"#10B981"}20`,color:z.progress<30?"#EF4444":z.progress<70?"#F59E0B":"#10B981"},children:[z.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>ge(!re),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:h.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${re?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:re&&jsx(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxs("div",{className:"pt-3 space-y-3",children:[(y||f.length>0||c==="create")&&jsxs("div",{children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:h.textTertiary},children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),jsxs("span",{className:"text-xs",style:{color:h.textTertiary},children:["Adjuntos ",c==="create"?fe.length>0&&`(${fe.length})`:f.length>0&&`(${f.length})`]})]}),c==="create"?jsx(kr,{cardId:"pending",attachments:fe.map((U,me)=>({id:`pending-${me}`,cardId:"pending",name:U.name,size:U.size,type:U.type,url:URL.createObjectURL(U),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:U=>Ie(me=>[...me,...U]),onDelete:U=>{let me=parseInt(U.replace("pending-",""),10);Ie(Ae=>Ae.filter((Fe,je)=>je!==me));},maxSizeMB:10,maxFiles:20}):jsx(kr,{cardId:a?.id||"new",attachments:f,onUpload:y&&a?.id?U=>y(a.id,U):void 0,onDelete:k,maxSizeMB:10,maxFiles:20}),c==="create"&&fe.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:h.textTertiary},children:[fe.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsx("input",{type:"checkbox",checked:z.isMilestone,onChange:U=>le("isMilestone",U.target.checked),className:"w-4 h-4 rounded",style:{accentColor:h.accent},disabled:n}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:h.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxs("div",{children:[jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:h.textTertiary},children:[jsx(Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:h.bgSecondary},children:r.filter(U=>U.id!==a?.id).map(U=>{let me=z.dependencies?.includes(U.id);return jsx("button",{type:"button",onClick:()=>{let Ae=me?(z.dependencies||[]).filter(Fe=>Fe!==U.id):[...z.dependencies||[],U.id];le("dependencies",Ae);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:me?`${h.accent}30`:h.bgPrimary,color:me?h.accent:h.textSecondary,border:`1px solid ${me?h.accent:h.borderLight}`},disabled:n,children:U.name},U.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${h.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:h.textSecondary},onMouseEnter:U=>U.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:U=>U.currentTarget.style.backgroundColor="transparent",disabled:n,children:"Cancelar"}),jsx("button",{type:"submit",disabled:n,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:h.accent,color:"#FFF"},onMouseEnter:U=>!n&&(U.currentTarget.style.opacity="0.9"),onMouseLeave:U=>!n&&(U.currentTarget.style.opacity="1"),children:n?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var fm=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
344
|
+
Task dependencies must flow in one direction only.`);return}let V=re=>re.map(pe=>{if(pe.id===P){let De=pe.dependencies||[];if(!De.includes(D.id))return {...pe,dependencies:[...De,D.id]}}return pe.subtasks?{...pe,subtasks:V(pe.subtasks)}:pe});S(V(te)),oe?.(D.id,P);},[te,oe,td]),rd=useCallback((D,P)=>{let V=re=>re.map(pe=>{if(pe.id===D&&pe.dependencies){let De=pe.dependencies.filter(Lt=>Lt!==P);return {...pe,dependencies:De}}return pe.subtasks?{...pe,subtasks:V(pe.subtasks)}:pe});S(V(te)),ye?.(D,P);},[te,ye]),{startDate:yn,endDate:ku}=useMemo(()=>{let D=te.filter(De=>De.startDate&&De.endDate);if(D.length===0){let De=new Date,Lt=new Date(De);Lt.setDate(Lt.getDate()-30);let pt=new Date(De);return pt.setDate(pt.getDate()+60),{startDate:Lt,endDate:pt}}let P=D.flatMap(De=>[De.startDate,De.endDate]).filter(De=>De!==void 0),V=new Date(Math.min(...P.map(De=>De.getTime()))),re=new Date(Math.max(...P.map(De=>De.getTime()))),pe=Fe==="day"?7:Fe==="week"?14:30;return V.setDate(V.getDate()-pe),re.setDate(re.getDate()+pe),{startDate:V,endDate:re}},[te,Fe]),wu=useCallback(async()=>{if(!Ee.current||!M.current||!W.current)return;await new Promise(Qr=>setTimeout(Qr,200));let D=Ee.current,P=M.current.querySelector(".gantt-grid-scroll"),V=W.current,re=P?.scrollTop||0,pe=P?.scrollLeft||0,De=V.scrollTop,Lt=V.scrollLeft,pt=D.style.overflow,qt=D.style.height,wa=P?.style.overflow||"",Da=V.style.overflow,Lr=D.style.width,vn=V.style.width;try{let Qr=P?.querySelector(".gantt-taskgrid-content"),br=V.querySelector("svg"),Ir=br?.getAttribute("height")?parseInt(br.getAttribute("height"),10):br?.getBoundingClientRect().height||0,ko=Qr?.scrollHeight||P?.scrollHeight||600,eo=Math.max(Ir,V.scrollHeight),sd=br?.getAttribute("width")?parseInt(br.getAttribute("width"),10):br?.getBoundingClientRect().width||V.scrollWidth,Mu=D.querySelector('[class*="h-12"]')?.offsetHeight||48,Ms=Math.max(ko,eo,Ir),As=Mu+Ms+50,Fs=(P?.offsetWidth||300)+sd+10;P&&(P.scrollTop=0,P.scrollLeft=0),V.scrollTop=0,V.scrollLeft=0,D.style.overflow="visible",D.style.height=`${As}px`,D.style.width=`${Fs}px`,P&&(P.style.overflow="visible",P.style.height=`${Ms+50}px`),V.style.overflow="visible",V.style.height=`${Ms+50}px`,V.style.width=`${sd+10}px`,await new Promise(Is=>setTimeout(Is,150));let Au=await mm(D,{backgroundColor:Pe.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:Fs,height:As,windowWidth:Fs+100,windowHeight:As+100,scrollX:0,scrollY:0,ignoreElements:Is=>{let id=window.getComputedStyle(Is),ld=parseInt(id.zIndex,10);return !isNaN(ld)&&ld>=50||id.position==="fixed"}}),Ls=document.createElement("a");Ls.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,Ls.href=Au.toDataURL("image/png"),Ls.click();}finally{D.style.overflow=pt,D.style.height=qt,D.style.width=Lr,P&&(P.style.overflow=wa,P.style.height="",P.scrollTop=re,P.scrollLeft=pe),V.style.overflow=Da,V.style.height="",V.style.width=vn,V.scrollTop=De,V.scrollLeft=Lt;}},[Pe]),Cu=useCallback(async()=>{await he.exportToPDF(te);},[te]),Tu=useCallback(async()=>{await he.exportToExcel(te);},[te]),Nu=useCallback(()=>{let D=he.exportToCSV(te),P=new Blob([D],{type:"text/csv;charset=utf-8;"}),V=document.createElement("a");V.href=URL.createObjectURL(P),V.download="gantt-chart.csv",V.click(),URL.revokeObjectURL(V.href);},[te]),Du=useCallback(()=>{let D=he.exportToJSON(te),P=new Blob([D],{type:"application/json;charset=utf-8;"}),V=document.createElement("a");V.href=URL.createObjectURL(P),V.download="gantt-chart.json",V.click(),URL.revokeObjectURL(V.href);},[te]),Su=useCallback(()=>{he.exportToMSProject(te,"Gantt Project","project.xml");},[te]),Eu=D=>{D.preventDefault(),Z(true);},xo=useRef(false),[Ps,od]=useState(false),Ho=useRef({x:0,y:0,scrollLeft:0,scrollTop:0});useEffect(()=>{let D=W.current,P=M.current?.querySelector(".gantt-grid-scroll");if(!D||!P)return;let V=()=>{if(xo.current)return;xo.current=true;let pt=D.scrollTop;Pt(pt),P.scrollTop=pt,requestAnimationFrame(()=>{xo.current=false;});},re=()=>{if(xo.current)return;xo.current=true;let pt=P.scrollTop;Pt(pt),D.scrollTop=pt,requestAnimationFrame(()=>{xo.current=false;});},pe=pt=>{if(Oe&&P){let wa=P.parentElement?.getBoundingClientRect()?.left||0,Da=pt.clientX-wa,Lr=200,vn=Nt+Dr,Qr=window.innerWidth*fr,br=Math.max(vn,Qr);Da>=Lr&&Da<=br&&ze(Da);}if(Ps&&D){let qt=pt.clientX-Ho.current.x,wa=pt.clientY-Ho.current.y;D.scrollLeft=Ho.current.scrollLeft-qt,D.scrollTop=Ho.current.scrollTop-wa;}},De=()=>{Z(false),od(false);},Lt=pt=>{if(pt.button!==0)return;let qt=pt.target;qt.closest("[data-task-bar]")||qt.closest("[data-dependency-line]")||qt.closest("button")||qt.closest('[role="button"]')||qt.tagName==="rect"&&qt.getAttribute("data-clickable")==="true"||(od(true),Ho.current={x:pt.clientX,y:pt.clientY,scrollLeft:D.scrollLeft,scrollTop:D.scrollTop},pt.preventDefault());};return D.addEventListener("scroll",V),P.addEventListener("scroll",re),D.addEventListener("mousedown",Lt),document.addEventListener("mousemove",pe),document.addEventListener("mouseup",De),()=>{D.removeEventListener("scroll",V),P.removeEventListener("scroll",re),D.removeEventListener("mousedown",Lt),document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",De);}},[Oe,Ps,Nt]);let nd=useRef(false),Pu=useRef(null);return useLayoutEffect(()=>{if(nd.current||te.length===0||!W.current)return;nd.current=true,Pu.current=yn;let D=W.current,P=new Date,V=Fe==="day"?60:Fe==="week"?20:8,re=(P.getTime()-yn.getTime())/(1e3*60*60*24),pe=D.clientWidth,Lt=re*V*Ke-pe/2;re>=0&&pe>0&&(D.scrollLeft=Math.max(0,Lt));},[te.length,yn,Fe,Ke]),jsx(Lo.Provider,{value:Ie,children:jsx(Us.Provider,{value:$t,children:jsxs("div",{ref:Ee,className:"flex flex-col h-full w-full",style:{backgroundColor:Pe.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(Gn,{theme:Pe,timeScale:Fe,onTimeScaleChange:qe,zoom:Ke,onZoomChange:dt,currentTheme:ge,onThemeChange:Ze,rowDensity:et,onRowDensityChange:de,showThemeSelector:g,showCreateTaskButton:u,createTaskLabel:x,onCreateTask:m,taskFilter:me,onTaskFilterChange:Le,hideCompleted:Se,onHideCompletedChange:Ye,onExportPNG:i?wu:void 0,onExportPDF:i?Cu:void 0,onExportExcel:i?Tu:void 0,onExportCSV:i?Nu:void 0,onExportJSON:i?Du:void 0,onExportMSProject:i?Su:void 0}),jsxs("div",{ref:M,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:$a,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsx(Kn,{tasks:yt,theme:Pe,rowHeight:Ue,availableUsers:p,templates:ie,onTaskClick:v,onTaskDblClick:ed,onTaskContextMenu:F,onTaskToggle:ka,scrollTop:Je,columns:se,onToggleColumn:gt,onColumnResize:ya,onTaskUpdate:Mt,onTaskIndent:Xe,onTaskOutdent:Yt,onTaskMove:Fr,onMultiTaskDelete:Ss,onTaskDuplicate:fu,onTaskCreate:bu,onTaskRename:hu,onCreateSubtask:Es,onOpenTaskModal:v?D=>v(D):void 0,onDeleteRequest:(D,P)=>Bt({taskId:D,taskName:P}),onTaskReparent:ua})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:Pe.border,zIndex:15},onMouseDown:Eu}),jsx("div",{ref:W,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",cursor:Ps?"grabbing":"grab",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(as,{tasks:yt,theme:Pe,rowHeight:Ue,timeScale:Fe,startDate:yn,endDate:ku,zoom:Ke,locale:h,templates:ie,dependencyLineStyle:a?.dependencyLineStyle,onTaskClick:v,onTaskDblClick:ed,onTaskContextMenu:vu,onTaskDateChange:yu,onDependencyCreate:ad,onDependencyDelete:rd})})]}),Be.task&&jsx(Io,{isOpen:Be.isOpen,x:Be.x,y:Be.y,theme:Pe,onClose:()=>st({isOpen:false,x:0,y:0,task:null}),items:(()=>{let D=Be.task;if(!D)return [];let P=he.findTaskById(te,D.id)||D;return P.subtasks&&P.subtasks.length>0?[{id:"addSubtask",label:Ie.contextMenu?.addSubtask||"Add Subtask",icon:Gt.Add,onClick:()=>{K?K(P):Es(P.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Ie.contextMenu?.deleteTask||"Delete Task",icon:Gt.Delete,onClick:()=>{Bt({taskId:P.id,taskName:P.name});}}]:[{id:"edit",label:Ie.contextMenu?.editTask||"Edit Task",icon:Gt.Pencil,onClick:()=>{O?O(P):Ve(P);}},{id:"addSubtask",label:Ie.contextMenu?.addSubtask||"Add Subtask",icon:Gt.Add,onClick:()=>{K?K(P):Es(P.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:Ie.contextMenu?.markIncomplete||"Mark Incomplete",icon:Gt.MarkIncomplete,onClick:()=>{ae?ae(P):Mt(P.id,{status:"todo",progress:0});},disabled:P.status==="todo"},{id:"setInProgress",label:Ie.contextMenu?.setInProgress||"Set In Progress",icon:Gt.SetInProgress,onClick:()=>{ne?ne(P):Mt(P.id,{status:"in-progress"});},disabled:P.status==="in-progress"},{id:"markComplete",label:Ie.contextMenu?.markComplete||"Mark Complete",icon:Gt.MarkComplete,onClick:()=>{Mt(P.id,{status:"completed",progress:100});},disabled:P.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:Ie.contextMenu?.splitTask||"Split Task",icon:Gt.Split,onClick:()=>{if(!P.startDate||!P.endDate){console.warn("Cannot split task without dates");return}let re=P.startDate.getTime(),pe=P.endDate.getTime(),De=re+(pe-re)/2,Lt=new Date(De);xu(P,Lt);},disabled:!P.startDate||!P.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Ie.contextMenu?.deleteTask||"Delete Task",icon:Gt.Delete,onClick:()=>{Bt({taskId:P.id,taskName:P.name});}}]})()}),jsx(io,{task:nt,isOpen:!!nt,onClose:()=>Ve(null),onTaskUpdate:D=>{nt&&(Mt(nt.id,D),Ve(null));},theme:ge==="light"?"light":"dark",locale:h==="es"?"es":"en",availableUsers:p,availableTasks:t}),jsx(AnimatePresence,{children:Vt&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>Bt(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:D=>D.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:Pe.bgSecondary,border:`1px solid ${Pe.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${Pe.border}`},children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"rgba(239, 68, 68, 0.2)"},children:jsx(AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxs("div",{className:"flex-1",children:[jsxs("h3",{className:"text-lg font-semibold",style:{color:Pe.textPrimary,fontFamily:"Inter, sans-serif"},children:[Ie.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:Pe.textSecondary,fontFamily:"Inter, sans-serif"},children:h==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:Pe.textSecondary,fontFamily:"Inter, sans-serif"},children:[h==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:Pe.textPrimary},children:['"',Vt.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:Pe.bgPrimary,borderTop:`1px solid ${Pe.border}`},children:[jsx("button",{onClick:()=>Bt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:Pe.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:D=>{D.currentTarget.style.backgroundColor=Pe.hoverBg;},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="transparent";},children:h==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{Ss([Vt.taskId]),Bt(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:D=>{D.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),h==="es"?"Eliminar":"Delete"]})]})]})})}),C?.enabled&&jsx(rs,{tasks:te,theme:Pe,config:C,onTasksUpdate:S,onTaskUpdate:Mt,onTaskCreate:D=>{S(P=>[...P,D]);},onTaskDelete:D=>{Ss([D]);},onDependencyCreate:(D,P)=>{let V=he.findTaskById(te,D);V&&ad(V,P);},onDependencyDelete:rd})]})})})});var Zi=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Qi=[{id:"low",label:"Baja",color:"#10B981",icon:"\u{1F7E2}"},{id:"medium",label:"Media",color:"#F59E0B",icon:"\u{1F7E1}"},{id:"high",label:"Alta",color:"#F97316",icon:"\u{1F7E0}"},{id:"urgent",label:"Urgente",color:"#EF4444",icon:"\u{1F534}"}];function fm({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:c=a?"edit":"create",theme:g="dark",customStatuses:i=[],availableTags:p=[],onCreateTag:l,attachments:f=[],onUploadAttachments:y,onDeleteAttachment:k}){let C=[...Zi,...i.filter($=>!Zi.some(me=>me.id===$.id))],h=at[g]||at.dark,[b,u]=useState(false),[x,m]=useState(false),[N,w]=useState(false),[B,v]=useState(false),[I,F]=useState({top:0,left:0}),[T,H]=useState(null),[O,K]=useState(new Date),[ae,ne]=useState({top:0,left:0}),[oe,ye]=useState(false),[fe,Re]=useState([]),A=useRef(null),R=useRef(null),L=useRef(null),j=useRef(null),J=useRef(null),[U,ge]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[le,Fe]=useState({});useEffect(()=>{a?(ge({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&ye(true)):(ge({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),ye(false),Re([]));},[a,e]),useEffect(()=>{let $=me=>{A.current&&!A.current.contains(me.target)&&u(false),R.current&&!R.current.contains(me.target)&&m(false),L.current&&!L.current.contains(me.target)&&w(false),j.current&&!j.current.contains(me.target)&&v(false);};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);let qe=()=>{let $={};return U.name.trim()||($.name="El nombre es requerido"),U.startDate&&U.endDate&&U.startDate>U.endDate&&($.endDate="La fecha de fin debe ser posterior a la de inicio"),Fe($),Object.keys($).length===0},et=async $=>{if($.preventDefault(),!!qe())try{let me=c==="create"&&fe.length>0?{...U,pendingFiles:fe}:U;await s(me),Re([]),t();}catch(me){console.error("Error submitting task:",me);}},de=($,me)=>{ge(Le=>{let Se={...Le,[$]:me};if($==="status"){let Ye=me;Ye==="todo"?Se.progress=0:Ye==="in-progress"?(Le.progress===0||Le.progress===100)&&(Se.progress=50):Ye==="completed"||Ye==="closed"?Se.progress=100:(Ye==="in-review"||Ye==="review")&&(Se.progress=75);}if($==="progress"){let Ye=typeof me=="number"?me:parseInt(me,10);Ye===100&&Le.status!=="completed"?Se.status="completed":Ye>0&&Ye<100&&Le.status==="todo"?Se.status="in-progress":Ye===0&&Le.status!=="todo"&&(Se.status="todo");}return Se}),le[$]&&Fe(Le=>{let Se={...Le};return delete Se[$],Se});},Ke=C.find($=>$.id===U.status)??Zi[0],dt=Qi.find($=>$.id===U.priority)??Qi[1],vt=yr.find($=>$.value===U.color)??yr[0],kt={backgroundColor:h.bgSecondary,border:`1px solid ${h.borderLight}`,color:h.textPrimary};return jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsx(motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden","data-theme":g,style:{backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},onClick:$=>$.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${h.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ke.color||h.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:h.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:h.textTertiary},onMouseEnter:$=>{$.currentTarget.style.backgroundColor=h.hoverBg,$.currentTarget.style.color=h.textPrimary;},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent",$.currentTarget.style.color=h.textTertiary;},disabled:n,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:et,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxs("div",{className:"p-5 space-y-4",children:[jsxs("div",{children:[jsx("input",{type:"text",value:U.name,onChange:$=>de("name",$.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:h.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),le.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),le.name]})]}),jsx("div",{children:jsx("textarea",{value:U.description||"",onChange:$=>de("description",$.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:h.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsx("div",{style:{borderTop:`1px solid ${h.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:A,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&u(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...kt,borderColor:Ke.color,backgroundColor:`${Ke.color}15`},disabled:n,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:Ke.color}}),jsx("span",{style:{color:Ke.color},children:Ke.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:Ke.color}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},children:C.map($=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:h.textPrimary},onMouseEnter:me=>me.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:me=>me.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("status",$.id),u(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:$.color}}),$.title,U.status===$.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:h.accent}})]},$.id))})})]}),jsxs("div",{ref:R,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&m(!x),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:kt,disabled:n,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:dt.color}}),jsx("span",{children:dt.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:h.textTertiary}})]}),jsx(AnimatePresence,{children:x&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},children:Qi.map($=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:h.textPrimary},onMouseEnter:me=>me.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:me=>me.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("priority",$.id),m(false);},children:[jsx("span",{children:$.icon}),$.label,U.priority===$.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:h.accent}})]},$.id))})})]}),o.length>0&&jsxs("div",{ref:L,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&w(!N),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:kt,disabled:n,children:[U.assignees&&U.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:U.assignees.slice(0,3).map(($,me)=>jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:$.color||h.accent,borderColor:h.bgSecondary},children:$.initials},me))}),U.assignees.length>3&&jsxs("span",{style:{color:h.textTertiary},children:["+",U.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:h.textTertiary}}),jsx("span",{style:{color:h.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:h.textTertiary}})]}),jsx(AnimatePresence,{children:N&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},children:o.map($=>{let me=U.assignees?.some(Le=>Le.name===$.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:h.textPrimary},onMouseEnter:Le=>Le.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:Le=>Le.currentTarget.style.backgroundColor="transparent",onClick:()=>{let Le=me?(U.assignees||[]).filter(Se=>Se.name!==$.name):[...U.assignees||[],{name:$.name,avatar:$.avatar,initials:$.name.split(" ").map(Se=>Se[0]).join("").toUpperCase().slice(0,2),color:h.accent}];de("assignees",Le);},children:[jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium flex-shrink-0",style:{backgroundColor:h.accent},children:$.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:$.name}),jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:me&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:h.accent}})})]},$.id)})})})]}),jsxs("div",{ref:j,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!n)if(B)v(false);else {if(j.current){let $=j.current.getBoundingClientRect(),me=window.innerHeight,Le=120,Ye=me-$.bottom<Le?$.top-Le-8:$.bottom+8;F({top:Ye,left:$.left});}v(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:kt,disabled:n,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:U.color}}),jsx("span",{children:vt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:h.textTertiary}})]}),jsx(AnimatePresence,{children:B&&jsxs(ft,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>v(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg",style:{position:"fixed",top:`${I.top}px`,left:`${I.left}px`,zIndex:99999,backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:$=>$.stopPropagation(),children:jsx("div",{style:{padding:"6px 8px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:yr.slice(0,18).map($=>{let me=U.color===$.value;return jsx("button",{type:"button",onClick:Le=>{Le.preventDefault(),Le.stopPropagation(),de("color",$.value),v(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:$.name,children:jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:$.value,outline:me?`2px solid ${$.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},$.value)})})})})]})})]}),p.length>0||l?jsx(hr,{selectedTags:U.tags||[],availableTags:p,onChange:$=>de("tags",$),onCreateTag:l,theme:h,disabled:n}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:h.textTertiary}}),jsxs("div",{ref:J,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!n&&!U.isMilestone)if(T==="start")H(null);else {if(J.current){let $=J.current.getBoundingClientRect(),me=window.innerHeight,Le=320,Ye=me-$.bottom<Le?$.top-Le-8:$.bottom+8;ne({top:Ye,left:$.left});}H("start"),K(U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...kt,opacity:U.isMilestone?.5:1,cursor:U.isMilestone?"not-allowed":"pointer"},disabled:n||U.isMilestone,children:U.startDate?U.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:h.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!n&&!U.isMilestone)if(T==="end")H(null);else {if(J.current){let $=J.current.getBoundingClientRect(),me=window.innerHeight,Le=320,Ye=me-$.bottom<Le?$.top-Le-8:$.bottom+8;ne({top:Ye,left:$.left});}H("end"),K(U.endDate||U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...kt,opacity:U.isMilestone?.5:1,cursor:U.isMilestone?"not-allowed":"pointer"},disabled:n||U.isMilestone,children:U.endDate?U.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:T&&jsxs(ft,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>H(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"rounded-xl shadow-2xl overflow-hidden flex",style:{position:"fixed",top:`${ae.top}px`,left:`${ae.left}px`,zIndex:99999,backgroundColor:h.bgPrimary,border:`1px solid ${h.border}`},onClick:$=>$.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${h.border}`},children:[(()=>{let $=new Date,me=new Date($);me.setDate($.getDate()+1);let Le=new Date($);Le.setDate($.getDate()+7);let Se=new Date($);return Se.setDate($.getDate()+14),[{label:"Hoy",date:$},{label:"Ma\xF1ana",date:me},{label:"Pr\xF3xima semana",date:Le},{label:"2 semanas",date:Se}].map((Je,Pt)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:h.textPrimary},onMouseEnter:Oe=>Oe.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:Oe=>Oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{T==="start"?(de("startDate",Je.date),(!U.endDate||Je.date>U.endDate)&&de("endDate",Je.date),H("end")):(de("endDate",Je.date),(!U.startDate||Je.date<U.startDate)&&de("startDate",Je.date),H(null));},children:Je.label},Pt))})(),jsx("div",{style:{borderTop:`1px solid ${h.border}`,margin:"0.5rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:$=>$.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:$=>$.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("startDate",void 0),de("endDate",void 0),H(null);},children:"Borrar fechas"})]}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{type:"button",onClick:()=>K(new Date(O.getFullYear(),O.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:h.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:h.textPrimary},children:O.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>K(new Date(O.getFullYear(),O.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:h.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map(($,me)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:h.textTertiary},children:$},me))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let $=O.getFullYear(),me=O.getMonth(),Le=new Date($,me,1).getDay(),Se=new Date($,me+1,0).getDate(),Ye=new Date,Je=[];for(let Oe=Le-1;Oe>=0;Oe--)Je.push({day:new Date($,me,-Oe).getDate(),date:new Date($,me-1,new Date($,me,-Oe).getDate()),isCurrentMonth:false});for(let Oe=1;Oe<=Se;Oe++)Je.push({day:Oe,date:new Date($,me,Oe),isCurrentMonth:true});let Pt=42-Je.length;for(let Oe=1;Oe<=Pt;Oe++)Je.push({day:Oe,date:new Date($,me+1,Oe),isCurrentMonth:false});return Je.map((Oe,Z)=>{let xe=Oe.date.toDateString()===Ye.toDateString(),ze=U.startDate?.toDateString()===Oe.date.toDateString(),Be=U.endDate?.toDateString()===Oe.date.toDateString(),st=U.startDate&&U.endDate&&Oe.date>=U.startDate&&Oe.date<=U.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Oe.isCurrentMonth?ze||Be?"#FFF":h.textPrimary:h.textTertiary,backgroundColor:ze?"#3B82F6":Be?"#7C3AED":st?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:xe&&!ze&&!Be?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{T==="start"?(de("startDate",Oe.date),U.endDate&&Oe.date>U.endDate&&de("endDate",Oe.date),H("end")):(de("endDate",Oe.date),U.startDate&&Oe.date<U.startDate&&de("startDate",Oe.date),H(null));},children:Oe.day},Z)})})()})]})]})]})})]}),le.endDate&&jsx("span",{className:"text-xs text-red-400",children:le.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:h.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:U.progress,onChange:$=>de("progress",parseInt($.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:h.bgSecondary,accentColor:U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"},disabled:n}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"}20`,color:U.progress<30?"#EF4444":U.progress<70?"#F59E0B":"#10B981"},children:[U.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>ye(!oe),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:h.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${oe?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:oe&&jsx(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxs("div",{className:"pt-3 space-y-3",children:[(y||f.length>0||c==="create")&&jsxs("div",{children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:h.textTertiary},children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),jsxs("span",{className:"text-xs",style:{color:h.textTertiary},children:["Adjuntos ",c==="create"?fe.length>0&&`(${fe.length})`:f.length>0&&`(${f.length})`]})]}),c==="create"?jsx(kr,{cardId:"pending",attachments:fe.map(($,me)=>({id:`pending-${me}`,cardId:"pending",name:$.name,size:$.size,type:$.type,url:URL.createObjectURL($),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:$=>Re(me=>[...me,...$]),onDelete:$=>{let me=parseInt($.replace("pending-",""),10);Re(Le=>Le.filter((Se,Ye)=>Ye!==me));},maxSizeMB:10,maxFiles:20}):jsx(kr,{cardId:a?.id||"new",attachments:f,onUpload:y&&a?.id?$=>y(a.id,$):void 0,onDelete:k,maxSizeMB:10,maxFiles:20}),c==="create"&&fe.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:h.textTertiary},children:[fe.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsx("input",{type:"checkbox",checked:U.isMilestone,onChange:$=>de("isMilestone",$.target.checked),className:"w-4 h-4 rounded",style:{accentColor:h.accent},disabled:n}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:h.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxs("div",{children:[jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:h.textTertiary},children:[jsx(Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:h.bgSecondary},children:r.filter($=>$.id!==a?.id).map($=>{let me=U.dependencies?.includes($.id);return jsx("button",{type:"button",onClick:()=>{let Le=me?(U.dependencies||[]).filter(Se=>Se!==$.id):[...U.dependencies||[],$.id];de("dependencies",Le);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:me?`${h.accent}30`:h.bgPrimary,color:me?h.accent:h.textSecondary,border:`1px solid ${me?h.accent:h.borderLight}`},disabled:n,children:$.name},$.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${h.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:h.textSecondary},onMouseEnter:$=>$.currentTarget.style.backgroundColor=h.hoverBg,onMouseLeave:$=>$.currentTarget.style.backgroundColor="transparent",disabled:n,children:"Cancelar"}),jsx("button",{type:"submit",disabled:n,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:h.accent,color:"#FFF"},onMouseEnter:$=>!n&&($.currentTarget.style.opacity="0.9"),onMouseLeave:$=>!n&&($.currentTarget.style.opacity="1"),children:n?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var bm=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
345
345
|
|
|
346
346
|
AVAILABLE COMMANDS:
|
|
347
347
|
1. move_task - Move a task to a different date
|
|
@@ -382,39 +382,39 @@ Tasks have: id, name, startDate, endDate, progress, status, dependencies[], assi
|
|
|
382
382
|
|
|
383
383
|
Always try to match task names case-insensitively and handle partial matches.
|
|
384
384
|
If you can't find a task by name, search through the provided task list.
|
|
385
|
-
If ambiguous, ask for clarification in the message field.`;function
|
|
386
|
-
${
|
|
385
|
+
If ambiguous, ask for clarification in the message field.`;function hm(e){return `CURRENT TASKS:
|
|
386
|
+
${ym(e).map(r=>{let o=r.startDate?r.startDate.toISOString().split("T")[0]:"no date",s=r.endDate?r.endDate.toISOString().split("T")[0]:"no date",n=r.dependencies?.length?`deps: [${r.dependencies.join(", ")}]`:"";return `- ${r.id}: "${r.name}" (${o} to ${s}, ${r.progress}%, ${r.status||"todo"}) ${n}`}).join(`
|
|
387
387
|
`)}
|
|
388
388
|
|
|
389
|
-
Today's date: ${new Date().toISOString().split("T")[0]}`}function hm(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function Mr(e,t){let a=hm(e),r=t.toLowerCase().trim(),o=a.find(c=>c.name.toLowerCase()===r);if(o)return o;let s=a.find(c=>c.name.toLowerCase().includes(r));if(s)return s;let n=r.split(/\s+/);return a.find(c=>{let g=c.name.toLowerCase();return n.every(i=>g.includes(i))})}function Qi(e,t=new Date){let a=e.toLowerCase().trim(),r=new Date(t);if(r.setHours(0,0,0,0),a==="today"||a==="hoy")return r;if(a==="tomorrow"||a==="ma\xF1ana"){let f=new Date(r);return f.setDate(f.getDate()+1),f}if(a==="yesterday"||a==="ayer"){let f=new Date(r);return f.setDate(f.getDate()-1),f}if(a==="next week"||a==="la pr\xF3xima semana"){let f=new Date(r);return f.setDate(f.getDate()+7),f}let o=a.match(/(?:next\s+)?(monday|tuesday|wednesday|thursday|friday|saturday|sunday|lunes|martes|miércoles|miercoles|jueves|viernes|sábado|sabado|domingo)/i);if(o){let y={sunday:0,domingo:0,monday:1,lunes:1,tuesday:2,martes:2,wednesday:3,mi\u00E9rcoles:3,miercoles:3,thursday:4,jueves:4,friday:5,viernes:5,saturday:6,s\u00E1bado:6,sabado:6}[o[1].toLowerCase()];if(y!==void 0){let k=new Date(r),C=k.getDay(),h=y-C;return h<=0&&(h+=7),k.setDate(k.getDate()+h),k}}let s=a.match(/in\s+(\d+)\s+(day|week|month|día|dias|semana|semanas|mes|meses)s?/i);if(s&&s[1]&&s[2]){let f=parseInt(s[1],10),y=s[2].toLowerCase(),k=new Date(r);return y==="day"||y==="d\xEDa"||y==="dias"?k.setDate(k.getDate()+f):y==="week"||y==="semana"||y==="semanas"?k.setDate(k.getDate()+f*7):(y==="month"||y==="mes"||y==="meses")&&k.setMonth(k.getMonth()+f),k}if(a.match(/(\d{4})-(\d{2})-(\d{2})/))return new Date(a);let c=a.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);if(c&&c[1]&&c[2]&&c[3]){let f=parseInt(c[1],10),y=parseInt(c[2],10)-1,k=parseInt(c[3],10);return new Date(k,y,f)}let g={enero:0,febrero:1,marzo:2,abril:3,mayo:4,junio:5,julio:6,agosto:7,septiembre:8,octubre:9,noviembre:10,diciembre:11},i=a.match(/(\d{1,2})\s+de\s+(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)(?:\s+de\s+(\d{4}))?/i);if(i&&i[1]&&i[2]){let f=parseInt(i[1],10),y=g[i[2].toLowerCase()],k=i[3]?parseInt(i[3],10):r.getFullYear();if(y!==void 0)return new Date(k,y,f)}let p={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11},l=a.match(/(january|february|march|april|may|june|july|august|september|october|november|december)\s+(\d{1,2})(?:,?\s+(\d{4}))?/i);if(l&&l[1]&&l[2]){let f=p[l[1].toLowerCase()],y=parseInt(l[2],10),k=l[3]?parseInt(l[3],10):r.getFullYear();if(f!==void 0)return new Date(k,f,y)}return null}function el(e){let a=e.toLowerCase().trim().match(/(\d+)\s*(day|week|month|día|dias|semana|semanas|mes|meses)s?/i);if(a&&a[1]&&a[2]){let r=parseInt(a[1],10),o=a[2].toLowerCase();if(o==="day"||o==="d\xEDa"||o==="dias")return r;if(o==="week"||o==="semana"||o==="semanas")return r*7;if(o==="month"||o==="mes"||o==="meses")return r*30}return null}function tl(e){let t=e.match(/(\d+)(?:\s*%)?/);if(t&&t[1]){let a=parseInt(t[1],10);return Math.max(0,Math.min(100,a))}return null}function ym(e){let t=e.toLowerCase().trim();return t.includes("todo")||t.includes("pendiente")||t.includes("por hacer")?"todo":t.includes("in progress")||t.includes("in-progress")||t.includes("en progreso")||t.includes("working")||t.includes("trabajando")?"in-progress":t.includes("done")||t.includes("complete")||t.includes("finished")||t.includes("completado")||t.includes("terminado")||t.includes("hecho")?"completed":null}function vm(e,t){let a=e.toLowerCase().trim(),r=a.match(/(?:move|mover|mueve)\s+(?:la\s+tarea\s+)?["""]?(.+?)["""]?\s+(?:to|a|para)\s+(?:la\s+fecha\s+)?(.+)/i);if(r&&r[1]&&r[2]){let i=r[1].trim(),p=r[2].trim(),l=Mr(t,i),f=Qi(p);if(!l)return {type:"move_task",taskName:i,message:`Could not find a task named "${i}". Please check the task name and try again.`,success:false,error:"Task not found"};if(!f)return {type:"move_task",taskId:l.id,taskName:l.name,message:`Could not parse the date "${p}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let y=l.startDate&&l.endDate?Math.round((l.endDate.getTime()-l.startDate.getTime())/(1e3*60*60*24)):1,k=new Date(f);return k.setDate(k.getDate()+y),{type:"move_task",taskId:l.id,taskName:l.name,updates:{startDate:f,endDate:k},message:`Moved "${l.name}" to ${f.toLocaleDateString()}.`,success:true}}let o=a.match(/(?:extend|extender|extiende|alargar)\s+["""]?(.+?)["""]?\s+(?:by|por)\s+(.+)/i);if(o&&o[1]&&o[2]){let i=o[1].trim(),p=o[2].trim(),l=Mr(t,i),f=el(p);if(!l)return {type:"resize_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"};if(!f||!l.endDate)return {type:"resize_task",taskId:l.id,taskName:l.name,message:`Could not parse the duration "${p}".`,success:false,error:"Invalid duration"};let y=new Date(l.endDate);return y.setDate(y.getDate()+f),{type:"resize_task",taskId:l.id,taskName:l.name,updates:{endDate:y},message:`Extended "${l.name}" by ${f} days. New end date: ${y.toLocaleDateString()}.`,success:true}}let s=a.match(/(?:set|establecer|poner)\s+["""]?(.+?)["""]?\s+(?:progress|progreso)\s+(?:to|a|en)\s+(.+)/i);if(s&&s[1]&&s[2]){let i=s[1].trim(),p=s[2].trim(),l=Mr(t,i),f=tl(p);return l?f===null?{type:"set_progress",taskId:l.id,taskName:l.name,message:`Could not parse the progress value "${p}".`,success:false,error:"Invalid progress"}:{type:"set_progress",taskId:l.id,taskName:l.name,updates:{progress:f},message:`Set "${l.name}" progress to ${f}%.`,success:true}:{type:"set_progress",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}let n=a.match(/(?:rename|renombrar|cambiar nombre de)\s+["""]?(.+?)["""]?\s+(?:to|a|por)\s+["""]?(.+?)["""]?$/i);if(n&&n[1]&&n[2]){let i=n[1].trim(),p=n[2].trim(),l=Mr(t,i);return l?{type:"rename_task",taskId:l.id,taskName:l.name,updates:{name:p},message:`Renamed "${l.name}" to "${p}".`,success:true}:{type:"rename_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}let c=a.match(/(?:link|vincular|conectar)\s+["""]?(.+?)["""]?\s+(?:to|a|con)\s+["""]?(.+?)["""]?$/i);if(c&&c[1]&&c[2]){let i=c[1].trim(),p=c[2].trim(),l=Mr(t,i),f=Mr(t,p);return l?f?{type:"link_tasks",taskId:f.id,taskName:f.name,dependencyFrom:l.id,dependencyTo:f.id,message:`Linked "${l.name}" \u2192 "${f.name}".`,success:true}:{type:"link_tasks",taskName:p,message:`Could not find a task named "${p}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Source task not found"}}let g=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(g&&g[1]){let i=g[1].trim(),p=Mr(t,i);return p?{type:"delete_task",taskId:p.id,taskName:p.name,message:`Deleted "${p.name}".`,success:true}:{type:"delete_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}return null}function xm(e){if(!e||typeof e!="object")return {type:"unknown",message:"Invalid response from AI",success:false,error:"Invalid response format"};let t=e;return {type:t.type||"unknown",taskId:typeof t.taskId=="string"?t.taskId:void 0,taskName:typeof t.taskName=="string"?t.taskName:void 0,updates:t.updates,newTask:t.newTask,dependencyFrom:typeof t.dependencyFrom=="string"?t.dependencyFrom:void 0,dependencyTo:typeof t.dependencyTo=="string"?t.dependencyTo:void 0,message:typeof t.message=="string"?t.message:"Command processed",success:typeof t.success=="boolean"?t.success:false,error:typeof t.error=="string"?t.error:void 0}}function xh(e){if(e)switch(e.toUpperCase()){case "TODO":case "BLOCKED":return "todo";case "IN_PROGRESS":case "REVIEW":return "in-progress";case "DONE":return "completed";default:return "todo"}}function kh(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function ns(e,t=[],a=[]){let r=e.assignedUserIds?.map(p=>{let l=a.find(f=>f.id===p);return l?{name:l.name,initials:l.initials,color:l.color}:null}).filter(p=>p!==null),o=t.filter(p=>p.metadata?.parentCardId===e.id).map(p=>ns(p,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(p=>p.type==="finish-to-start").map(p=>p.taskId));let n=p=>{if(p)return typeof p=="string"?new Date(p):p},c=n(e.startDate),g=n(e.endDate),i=e.metadata?.isMilestone===true||c&&g&&Math.abs(g.getTime()-c.getTime())<=864e5;return {id:e.id,name:e.title,startDate:c,endDate:g,progress:e.progress||0,status:xh(e.metadata?.status),assignees:r?.length?r:void 0,dependencies:s?.length?s:void 0,subtasks:o?.length?o:void 0,isExpanded:e.metadata?.isExpanded===true,isMilestone:i,isCriticalPath:e.metadata?.isCriticalPath===true}}function km(e,t=[]){let a;return e.assignees&&e.assignees.length>0&&(a=e.assignees.map(r=>t.find(s=>s.name===r.name||s.initials===r.initials)?.id).filter(r=>r!==void 0)),{id:e.id,title:e.name,startDate:e.startDate,endDate:e.endDate,progress:e.progress,assignedUserIds:a?.length?a:void 0,metadata:{status:kh(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function wm(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>ns(r,e,t))}var al={columns:{name:"Task Name",startDate:"Start Date",endDate:"End Date",progress:"Progress",status:"Status",assignees:"Assignees",priority:"Priority",actions:"Actions"},toolbar:{search:"Search",searchPlaceholder:"Search tasks...",filter:"Filter",clearFilters:"Clear Filters",export:"Export",columns:"Columns",newTask:"New Task"},filters:{status:"Status",assignees:"Assignees",dateRange:"Date Range",showCompleted:"Show Completed",all:"All",none:"None"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",viewDetails:"View Details"},empty:{noTasks:"No tasks yet",noResults:"No tasks match your filters",addFirstTask:"Add your first task"},pagination:{showing:"Showing",of:"of",tasks:"tasks",previous:"Previous",next:"Next"},bulk:{selected:"selected",delete:"Delete",move:"Move to",assignTo:"Assign to"}},rl={columns:{name:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",progress:"Progreso",status:"Estado",assignees:"Asignados",priority:"Prioridad",actions:"Acciones"},toolbar:{search:"Buscar",searchPlaceholder:"Buscar tareas...",filter:"Filtrar",clearFilters:"Limpiar Filtros",export:"Exportar",columns:"Columnas",newTask:"Nueva Tarea"},filters:{status:"Estado",assignees:"Asignados",dateRange:"Rango de Fechas",showCompleted:"Mostrar Completadas",all:"Todos",none:"Ninguno"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",viewDetails:"Ver Detalles"},empty:{noTasks:"Sin tareas a\xFAn",noResults:"Ninguna tarea coincide con los filtros",addFirstTask:"Agrega tu primera tarea"},pagination:{showing:"Mostrando",of:"de",tasks:"tareas",previous:"Anterior",next:"Siguiente"},bulk:{selected:"seleccionadas",delete:"Eliminar",move:"Mover a",assignTo:"Asignar a"}},ss={en:al,es:rl};function ol(e){return ss[e]||ss.en}function is(e,t){let a=ol(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},filters:{...a.filters,...t.filters},status:{...a.status,...t.status},actions:{...a.actions,...t.actions},empty:{...a.empty,...t.empty},pagination:{...a.pagination,...t.pagination},bulk:{...a.bulk,...t.bulk}}:a}var nl=[{value:"todo",icon:Circle,color:"text-gray-400"},{value:"in-progress",icon:PlayCircle,color:"text-blue-500"},{value:"completed",icon:CheckCircle2,color:"text-green-500"}];function Cm({value:e,onChange:t,isDark:a,translations:r,disabled:o=false}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let f=y=>{c.current&&!c.current.contains(y.target)&&n(false);};return s&&document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[s]);let g=nl[0],i=nl.find(f=>f.value===e)??g,p=i.icon,l=f=>{switch(f){case "completed":return r.completed;case "in-progress":return r.inProgress;default:return r.todo}};return o||!t?jsxs("div",{className:"flex items-center gap-2",children:[jsx(p,{className:d("w-4 h-4",i.color)}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:l(e)})]}):jsxs("div",{ref:c,className:"relative",children:[jsxs("button",{onClick:f=>{f.stopPropagation(),n(!s);},className:d("flex items-center gap-2 px-2 py-1 rounded transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx(p,{className:d("w-4 h-4",i.color)}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:l(e)}),jsx(ChevronDown,{className:d("w-3 h-3",a?"text-[#6B7280]":"text-gray-400")})]}),s&&jsx("div",{className:d("absolute z-50 top-full left-0 mt-1 py-1 rounded-lg shadow-lg border min-w-[140px]",a?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:nl.map(f=>{let y=f.icon;return jsxs("button",{onClick:k=>{k.stopPropagation(),t(f.value),n(false);},className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100",e===f.value&&(a?"bg-white/5":"bg-gray-50")),children:[jsx(y,{className:d("w-4 h-4",f.color)}),jsx("span",{className:a?"text-white":"text-gray-900",children:l(f.value)})]},f.value)})})]})}var sl=[{value:"urgent",label:{en:"Urgent",es:"Urgente"},color:"text-red-500",bg:"bg-red-500"},{value:"high",label:{en:"High",es:"Alta"},color:"text-orange-500",bg:"bg-orange-500"},{value:"medium",label:{en:"Medium",es:"Media"},color:"text-yellow-500",bg:"bg-yellow-500"},{value:"low",label:{en:"Low",es:"Baja"},color:"text-blue-500",bg:"bg-blue-500"},{value:"none",label:{en:"None",es:"Ninguna"},color:"text-gray-400",bg:"bg-gray-400"}];function Nm({value:e="none",onChange:t,isDark:a,locale:r,disabled:o=false}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let p=l=>{c.current&&!c.current.contains(l.target)&&n(false);};return s&&document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);let g=sl.find(p=>p.value===e)??sl[4],i=r==="es"?"es":"en";return o||!t?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Flag,{className:d("w-4 h-4",g.color)}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:g.label[i]})]}):jsxs("div",{ref:c,className:"relative",children:[jsxs("button",{onClick:p=>{p.stopPropagation(),n(!s);},className:d("flex items-center gap-2 px-2 py-1 rounded transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx(Flag,{className:d("w-4 h-4",g.color)}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:g.label[i]}),jsx(ChevronDown,{className:d("w-3 h-3",a?"text-[#6B7280]":"text-gray-400")})]}),s&&jsx("div",{className:d("absolute z-50 top-full left-0 mt-1 py-1 rounded-lg shadow-lg border min-w-[120px]",a?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:sl.map(p=>jsxs("button",{onClick:l=>{l.stopPropagation(),t(p.value),n(false);},className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100",e===p.value&&(a?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:d("w-2 h-2 rounded-full",p.bg)}),jsx("span",{className:a?"text-white":"text-gray-900",children:p.label[i]})]},p.value))})]})}function cs(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function ms(e){let t=["bg-blue-500","bg-green-500","bg-purple-500","bg-pink-500","bg-yellow-500","bg-red-500","bg-indigo-500","bg-teal-500"],a=0;for(let r=0;r<e.length;r++)a=e.charCodeAt(r)+((a<<5)-a);return t[Math.abs(a)%t.length]??"bg-blue-500"}function Sm({value:e=[],availableUsers:t=[],onChange:a,isDark:r,locale:o,disabled:s=false}){let[n,c]=useState(false),[g,i]=useState(""),p=useRef(null);useEffect(()=>{let k=C=>{p.current&&!p.current.contains(C.target)&&(c(false),i(""));};return n&&document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[n]);let l=t.filter(k=>k.name.toLowerCase().includes(g.toLowerCase())||k.email?.toLowerCase().includes(g.toLowerCase())),f=k=>e.some(C=>C.name===k),y=k=>{if(a)if(f(k.name))a(e.filter(C=>C.name!==k.name));else {let C={name:k.name,initials:cs(k.name),color:k.color||ms(k.name).replace("bg-","").replace("-500",""),avatar:k.avatarUrl};a([...e,C]);}};return s||!a?e.length===0?jsx("span",{className:d("text-sm",r?"text-[#6B7280]":"text-gray-400"),children:"-"}):jsxs("div",{className:"flex items-center -space-x-2",children:[e.slice(0,3).map((k,C)=>jsx("div",{className:d("w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium text-white border-2",r?"border-[#0F1117]":"border-white",!k.avatar&&ms(k.name)),style:k.color&&!k.avatar?{backgroundColor:k.color}:void 0,title:k.name,children:k.avatar?jsx("img",{src:k.avatar,alt:k.name,className:"w-full h-full rounded-full object-cover"}):k.initials||cs(k.name)},`${k.name}-${C}`)),e.length>3&&jsxs("div",{className:d("w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium border-2",r?"bg-[#374151] border-[#0F1117] text-white":"bg-gray-200 border-white text-gray-600"),children:["+",e.length-3]})]}):jsxs("div",{ref:p,className:"relative",children:[jsx("button",{onClick:k=>{k.stopPropagation(),c(!n);},className:d("flex items-center gap-1 px-2 py-1 rounded transition-colors",r?"hover:bg-white/10":"hover:bg-gray-100"),children:e.length===0?jsxs(Fragment,{children:[jsx(User,{className:d("w-4 h-4",r?"text-[#6B7280]":"text-gray-400")}),jsx(Plus,{className:d("w-3 h-3",r?"text-[#6B7280]":"text-gray-400")})]}):jsxs("div",{className:"flex items-center -space-x-1",children:[e.slice(0,2).map((k,C)=>jsx("div",{className:d("w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-medium text-white border",r?"border-[#0F1117]":"border-white",!k.avatar&&ms(k.name)),style:k.color&&!k.avatar?{backgroundColor:k.color}:void 0,children:k.avatar?jsx("img",{src:k.avatar,alt:k.name,className:"w-full h-full rounded-full object-cover"}):k.initials||cs(k.name)},`${k.name}-${C}`)),e.length>2&&jsxs("span",{className:d("text-xs ml-1",r?"text-[#9CA3AF]":"text-gray-500"),children:["+",e.length-2]})]})}),n&&jsxs("div",{className:d("absolute z-50 top-full left-0 mt-1 rounded-lg shadow-lg border w-64",r?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:[jsx("div",{className:"p-2 border-b",style:{borderColor:r?"rgba(255,255,255,0.1)":"#E5E7EB"},children:jsx("input",{type:"text",value:g,onChange:k=>i(k.target.value),placeholder:o==="es"?"Buscar usuario...":"Search user...",className:d("w-full px-3 py-1.5 text-sm rounded border outline-none",r?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400"),onClick:k=>k.stopPropagation()})}),jsx("div",{className:"max-h-48 overflow-y-auto py-1",children:l.length===0?jsx("p",{className:d("px-3 py-2 text-sm",r?"text-[#6B7280]":"text-gray-400"),children:o==="es"?"No se encontraron usuarios":"No users found"}):l.map(k=>jsxs("button",{onClick:C=>{C.stopPropagation(),y(k);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",r?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx("div",{className:d("w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium text-white",!k.avatarUrl&&ms(k.name)),children:k.avatarUrl?jsx("img",{src:k.avatarUrl,alt:k.name,className:"w-full h-full rounded-full object-cover"}):cs(k.name)}),jsxs("div",{className:"flex-1 text-left",children:[jsx("div",{className:r?"text-white":"text-gray-900",children:k.name}),k.email&&jsx("div",{className:d("text-xs",r?"text-[#6B7280]":"text-gray-400"),children:k.email})]}),f(k.name)&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},k.id))}),e.length>0&&jsx("div",{className:"p-2 border-t flex flex-wrap gap-1",style:{borderColor:r?"rgba(255,255,255,0.1)":"#E5E7EB"},children:e.map((k,C)=>jsxs("span",{className:d("inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full",r?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:[k.name,jsx("button",{onClick:h=>{h.stopPropagation(),a(e.filter(b=>b.name!==k.name));},className:"hover:text-red-500",children:jsx(X,{className:"w-3 h-3"})})]},`${k.name}-${C}`))})]})]})}var Vh={en:["January","February","March","April","May","June","July","August","September","October","November","December"],es:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]},jh={en:["Su","Mo","Tu","We","Th","Fr","Sa"],es:["Do","Lu","Ma","Mi","Ju","Vi","S\xE1"]};function ps({value:e,onChange:t,isDark:a,locale:r,disabled:o=false}){let[s,n]=useState(false),[c,g]=useState(()=>{if(e){let h=e instanceof Date?e:new Date(e);return new Date(h.getFullYear(),h.getMonth(),1)}return new Date(new Date().getFullYear(),new Date().getMonth(),1)}),i=useRef(null),p=e?e instanceof Date?e:new Date(e):null,l=r==="es"?"es":"en";useEffect(()=>{let h=b=>{i.current&&!i.current.contains(b.target)&&n(false);};return s&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]);let f=h=>h?h.toLocaleDateString(r==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-",y=(h,b)=>new Date(h,b+1,0).getDate(),k=(h,b)=>new Date(h,b,1).getDay(),C=()=>{let h=c.getFullYear(),b=c.getMonth(),u=y(h,b),x=k(h,b),m=new Date,N=[];for(let w=0;w<x;w++)N.push(jsx("div",{className:"w-8 h-8"},`empty-${w}`));for(let w=1;w<=u;w++){let B=new Date(h,b,w),v=p&&p.getDate()===w&&p.getMonth()===b&&p.getFullYear()===h,I=m.getDate()===w&&m.getMonth()===b&&m.getFullYear()===h;N.push(jsx("button",{onClick:A=>{A.stopPropagation(),t?.(B),n(false);},className:d("w-8 h-8 rounded-full text-sm transition-colors",v?"bg-[#3B82F6] text-white":I?a?"bg-white/10 text-white":"bg-gray-100 text-gray-900":a?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-900"),children:w},w));}return N};return o||!t?jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:f(p)}):jsxs("div",{ref:i,className:"relative",children:[jsxs("button",{onClick:h=>{h.stopPropagation(),n(!s);},className:d("flex items-center gap-2 px-2 py-1 rounded transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx(Calendar,{className:d("w-4 h-4",a?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:f(p)})]}),s&&jsxs("div",{className:d("absolute z-50 top-full left-0 mt-1 p-3 rounded-lg shadow-lg border",a?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{onClick:h=>{h.stopPropagation(),g(new Date(c.getFullYear(),c.getMonth()-1,1));},className:d("p-1 rounded",a?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:d("w-4 h-4",a?"text-white":"text-gray-600")})}),jsxs("span",{className:d("text-sm font-medium",a?"text-white":"text-gray-900"),children:[Vh[l][c.getMonth()]," ",c.getFullYear()]}),jsx("button",{onClick:h=>{h.stopPropagation(),g(new Date(c.getFullYear(),c.getMonth()+1,1));},className:d("p-1 rounded",a?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:d("w-4 h-4",a?"text-white":"text-gray-600")})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:jh[l].map(h=>jsx("div",{className:d("w-8 h-6 text-xs flex items-center justify-center",a?"text-[#6B7280]":"text-gray-400"),children:h},h))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:C()}),jsxs("div",{className:"mt-3 pt-3 border-t flex gap-2",style:{borderColor:a?"rgba(255,255,255,0.1)":"#E5E7EB"},children:[jsx("button",{onClick:h=>{h.stopPropagation(),t?.(new Date),n(false);},className:d("flex-1 py-1.5 text-xs rounded",a?"bg-white/10 text-white hover:bg-white/20":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:r==="es"?"Hoy":"Today"}),jsx("button",{onClick:h=>{h.stopPropagation();let b=new Date;b.setDate(b.getDate()+1),t?.(b),n(false);},className:d("flex-1 py-1.5 text-xs rounded",a?"bg-white/10 text-white hover:bg-white/20":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:r==="es"?"Ma\xF1ana":"Tomorrow"})]})]})]})}function Am({value:e=0,onChange:t,isDark:a,disabled:r=false}){return jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{onClick:s=>{if(r||!t)return;s.stopPropagation();let n=s.currentTarget.getBoundingClientRect(),c=s.clientX-n.left,g=Math.round(c/n.width*100),i=Math.max(0,Math.min(100,g));t(i);},className:d("flex-1 h-2 rounded-full overflow-hidden",a?"bg-white/10":"bg-gray-200",!r&&t&&"cursor-pointer"),children:jsx("div",{className:d("h-full rounded-full transition-all",e===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${e}%`}})}),jsxs("span",{className:d("text-xs w-8 text-right",a?"text-[#9CA3AF]":"text-gray-500"),children:[e,"%"]})]})}function Im({value:e="",onChange:t,isDark:a,placeholder:r="-",disabled:o=false}){let[s,n]=useState(false),[c,g]=useState(e),i=useRef(null);useEffect(()=>{s&&i.current&&(i.current.focus(),i.current.select());},[s]),useEffect(()=>{g(e);},[e]);let p=()=>{c!==e&&t?.(c),n(false);},l=f=>{f.key==="Enter"?p():f.key==="Escape"&&(g(e),n(false));};return o||!t?jsx("span",{className:d("text-sm truncate",a?"text-[#94A3B8]":"text-gray-500"),children:e||r}):s?jsx("input",{ref:i,type:"text",value:c,onChange:f=>g(f.target.value),onBlur:p,onKeyDown:l,onClick:f=>f.stopPropagation(),className:d("w-full px-2 py-1 text-sm rounded border outline-none",a?"bg-white/5 border-[#3B82F6] text-white":"bg-white border-[#3B82F6] text-gray-900")}):jsx("button",{onClick:f=>{f.stopPropagation(),n(true);},className:d("text-sm truncate text-left w-full px-2 py-1 rounded transition-colors",a?"text-[#94A3B8] hover:bg-white/10":"text-gray-500 hover:bg-gray-100",!e&&(a?"text-[#6B7280]":"text-gray-400")),children:e||r})}function Om({value:e,onChange:t,isDark:a,placeholder:r="-",min:o,max:s,disabled:n=false}){let[c,g]=useState(false),[i,p]=useState(e?.toString()||""),l=useRef(null);useEffect(()=>{c&&l.current&&(l.current.focus(),l.current.select());},[c]),useEffect(()=>{p(e?.toString()||"");},[e]);let f=()=>{let k=parseFloat(i);if(!isNaN(k)){let C=k;o!==void 0&&(C=Math.max(o,C)),s!==void 0&&(C=Math.min(s,C)),C!==e&&t?.(C);}g(false);},y=k=>{k.key==="Enter"?f():k.key==="Escape"&&(p(e?.toString()||""),g(false));};return n||!t?jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:e!==void 0?e:r}):c?jsx("input",{ref:l,type:"number",value:i,onChange:k=>p(k.target.value),onBlur:f,onKeyDown:y,onClick:k=>k.stopPropagation(),min:o,max:s,className:d("w-full px-2 py-1 text-sm rounded border outline-none",a?"bg-white/5 border-[#3B82F6] text-white":"bg-white border-[#3B82F6] text-gray-900")}):jsx("button",{onClick:k=>{k.stopPropagation(),g(true);},className:d("text-sm text-left w-full px-2 py-1 rounded transition-colors",a?"text-[#94A3B8] hover:bg-white/10":"text-gray-500 hover:bg-gray-100",e===void 0&&(a?"text-[#6B7280]":"text-gray-400")),children:e!==void 0?e:r})}function $m({value:e,options:t=[],onChange:a,isDark:r,placeholder:o="-",disabled:s=false}){let[n,c]=useState(false),g=useRef(null);return useEffect(()=>{let i=p=>{g.current&&!g.current.contains(p.target)&&c(false);};return n&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[n]),s||!a?jsx("span",{className:d("text-sm",r?"text-[#94A3B8]":"text-gray-500"),children:e||o}):jsxs("div",{ref:g,className:"relative",children:[jsxs("button",{onClick:i=>{i.stopPropagation(),c(!n);},className:d("flex items-center gap-2 px-2 py-1 rounded transition-colors min-w-[80px]",r?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx("span",{className:d("text-sm flex-1 text-left truncate",r?"text-[#94A3B8]":"text-gray-500",!e&&(r?"text-[#6B7280]":"text-gray-400")),children:e||o}),jsx(ChevronDown,{className:d("w-3 h-3 flex-shrink-0",r?"text-[#6B7280]":"text-gray-400")})]}),n&&jsx("div",{className:d("absolute z-50 top-full left-0 mt-1 py-1 rounded-lg shadow-lg border min-w-[120px] max-h-48 overflow-y-auto",r?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:t.length===0?jsx("p",{className:d("px-3 py-2 text-sm",r?"text-[#6B7280]":"text-gray-400"),children:"No options"}):t.map(i=>jsxs("button",{onClick:p=>{p.stopPropagation(),a(i),c(false);},className:d("w-full flex items-center justify-between gap-2 px-3 py-2 text-sm transition-colors",r?"hover:bg-white/10":"hover:bg-gray-100",e===i&&(r?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:r?"text-white":"text-gray-900",children:i}),e===i&&jsx(Check,{className:"w-4 h-4 text-[#3B82F6]"})]},i))})]})}function zm({value:e=false,onChange:t,isDark:a,disabled:r=false}){return jsx("button",{onClick:s=>{s.stopPropagation(),!r&&t&&t(!e);},disabled:r||!t,className:d("w-5 h-5 rounded border-2 flex items-center justify-center transition-colors",e?"bg-[#3B82F6] border-[#3B82F6]":a?"border-[#4B5563] hover:border-[#6B7280]":"border-gray-300 hover:border-gray-400",(r||!t)&&"opacity-50 cursor-not-allowed"),children:e&&jsx(Check,{className:"w-3 h-3 text-white"})})}function Gm({value:e=[],isDark:t,maxVisible:a=2}){if(e.length===0)return jsx("span",{className:d("text-sm",t?"text-[#6B7280]":"text-gray-400"),children:"-"});let r=e.slice(0,a),o=e.length-a;return jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[r.map(s=>jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-xs rounded-full",style:{backgroundColor:s.color?`${s.color}20`:t?"rgba(255,255,255,0.1)":"#F3F4F6",color:s.color||(t?"#9CA3AF":"#6B7280")},children:s.name},s.id)),o>0&&jsxs("span",{className:d("inline-flex items-center px-2 py-0.5 text-xs rounded-full",t?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-500"),children:["+",o]})]})}function gy(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function fy(e){let t=["blue","green","purple","pink","yellow","red","indigo","teal"],a=0;for(let r=0;r<e.length;r++)a=e.charCodeAt(r)+((a<<5)-a);return t[Math.abs(a)%t.length]??"blue"}function Km({state:e,onClose:t,isDark:a,locale:r,onTaskEdit:o,onTaskDuplicate:s,onTaskDelete:n,onTaskUpdate:c,onColumnHide:g,onColumnSort:i,availableUsers:p=[]}){let l=useRef(null),f=r==="es"?Vm.es:Vm.en;if(useEffect(()=>{let b=x=>{l.current&&!l.current.contains(x.target)&&t();},u=x=>{x.key==="Escape"&&t();};return document.addEventListener("mousedown",b),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",u);}},[t]),!e.isOpen)return null;let y=()=>{if(!e.task)return [];let b=[];return o&&b.push({id:"edit",label:f.edit,icon:jsx(Edit3,{className:"w-4 h-4"}),onClick:()=>{o(e.task),t();}}),b.push({id:"sep1",label:"",icon:null,separator:true}),c&&(b.push({id:"status",label:f.changeStatus,icon:jsx(CheckCircle2,{className:"w-4 h-4"}),submenu:[{id:"status-todo",label:f.todo,icon:jsx(Circle,{className:"w-4 h-4 text-gray-400"}),onClick:()=>{c({...e.task,status:"todo",progress:0}),t();}},{id:"status-in-progress",label:f.inProgress,icon:jsx(PlayCircle,{className:"w-4 h-4 text-blue-500"}),onClick:()=>{c({...e.task,status:"in-progress",progress:e.task.progress||50}),t();}},{id:"status-completed",label:f.completed,icon:jsx(CheckCircle2,{className:"w-4 h-4 text-green-500"}),onClick:()=>{c({...e.task,status:"completed",progress:100}),t();}}]}),b.push({id:"priority",label:f.changePriority,icon:jsx(Flag,{className:"w-4 h-4"}),submenu:[{id:"priority-urgent",label:f.urgent,icon:jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),onClick:()=>{c({...e.task,priority:"urgent"}),t();}},{id:"priority-high",label:f.high,icon:jsx("div",{className:"w-3 h-3 rounded-full bg-orange-500"}),onClick:()=>{c({...e.task,priority:"high"}),t();}},{id:"priority-medium",label:f.medium,icon:jsx("div",{className:"w-3 h-3 rounded-full bg-yellow-500"}),onClick:()=>{c({...e.task,priority:"medium"}),t();}},{id:"priority-low",label:f.low,icon:jsx("div",{className:"w-3 h-3 rounded-full bg-blue-500"}),onClick:()=>{c({...e.task,priority:"low"}),t();}}]}),p.length>0&&b.push({id:"assign",label:f.assignUser,icon:jsx(Users,{className:"w-4 h-4"}),submenu:p.slice(0,5).map(u=>({id:`assign-${u.id}`,label:u.name,icon:jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white bg-blue-500",children:u.name.charAt(0).toUpperCase()}),onClick:()=>{let x=e.task.assignees||[],N=x.some(w=>w.name===u.name)?x.filter(w=>w.name!==u.name):[...x,{name:u.name,initials:gy(u.name),color:u.color||fy(u.name),avatar:u.avatarUrl}];c({...e.task,assignees:N}),t();}}))})),b.push({id:"sep2",label:"",icon:null,separator:true}),s&&b.push({id:"duplicate",label:f.duplicate,icon:jsx(Copy,{className:"w-4 h-4"}),onClick:()=>{s(e.task),t();}}),n&&b.push({id:"delete",label:f.delete,icon:jsx(Trash2,{className:"w-4 h-4"}),danger:true,onClick:()=>{n(e.task.id),t();}}),b},k=()=>{if(!e.columnId)return [];let b=[];return i&&(b.push({id:"sort-asc",label:f.sortAsc,icon:jsx(ArrowUp,{className:"w-4 h-4"}),onClick:()=>{i(e.columnId,"asc"),t();}}),b.push({id:"sort-desc",label:f.sortDesc,icon:jsx(ArrowDown,{className:"w-4 h-4"}),onClick:()=>{i(e.columnId,"desc"),t();}})),g&&e.columnId!=="name"&&(b.push({id:"sep-hide",label:"",icon:null,separator:true}),b.push({id:"hide",label:f.hideColumn,icon:jsx(EyeOff,{className:"w-4 h-4"}),onClick:()=>{g(e.columnId),t();}})),b},C=e.type==="task"?y():k(),h={position:"fixed",left:e.x,top:e.y,zIndex:9999};return jsx("div",{ref:l,style:h,className:d("py-1 rounded-lg shadow-xl border min-w-[180px]",a?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:C.map(b=>b.separator?jsx("div",{className:d("my-1 h-px",a?"bg-white/10":"bg-gray-200")},b.id):b.submenu?jsx(by,{item:b,isDark:a},b.id):jsxs("button",{onClick:b.onClick,className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100",b.danger?"text-red-500 hover:text-red-600":a?"text-white":"text-gray-700"),children:[jsx("span",{className:d(b.danger?"text-red-500":a?"text-[#9CA3AF]":"text-gray-400"),children:b.icon}),b.label]},b.id))})}function by({item:e,isDark:t}){let[a,r]=useState(false),o=useRef();return jsxs("div",{className:"relative",onMouseEnter:()=>{o.current&&clearTimeout(o.current),r(true);},onMouseLeave:()=>{o.current=setTimeout(()=>r(false),150);},children:[jsxs("button",{className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",t?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:[jsx("span",{className:t?"text-[#9CA3AF]":"text-gray-400",children:e.icon}),jsx("span",{className:"flex-1",children:e.label}),jsx(ChevronRight,{className:d("w-4 h-4",t?"text-[#6B7280]":"text-gray-400")})]}),a&&e.submenu&&jsx("div",{className:d("absolute left-full top-0 ml-1 py-1 rounded-lg shadow-xl border min-w-[160px]",t?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:e.submenu.map(c=>jsxs("button",{onClick:c.onClick,className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",t?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:[jsx("span",{className:t?"text-[#9CA3AF]":"text-gray-400",children:c.icon}),c.label]},c.id))})]})}var Vm={en:{edit:"Edit",changeStatus:"Change status",changePriority:"Change priority",assignUser:"Assign user",duplicate:"Duplicate",delete:"Delete",todo:"To Do",inProgress:"In Progress",completed:"Completed",urgent:"Urgent",high:"High",medium:"Medium",low:"Low",sortAsc:"Sort A \u2192 Z",sortDesc:"Sort Z \u2192 A",hideColumn:"Hide column"},es:{edit:"Editar",changeStatus:"Cambiar estado",changePriority:"Cambiar prioridad",assignUser:"Asignar usuario",duplicate:"Duplicar",delete:"Eliminar",todo:"Pendiente",inProgress:"En Progreso",completed:"Completado",urgent:"Urgente",high:"Alta",medium:"Media",low:"Baja",sortAsc:"Ordenar A \u2192 Z",sortDesc:"Ordenar Z \u2192 A",hideColumn:"Ocultar columna"}};var Xm={name:jsx(Type,{className:"w-4 h-4"}),status:jsx(CircleDot,{className:"w-4 h-4"}),priority:jsx(Flag,{className:"w-4 h-4"}),assignees:jsx(Users,{className:"w-4 h-4"}),startDate:jsx(Calendar,{className:"w-4 h-4"}),endDate:jsx(CalendarCheck,{className:"w-4 h-4"}),progress:jsx(BarChart,{className:"w-4 h-4"}),tags:jsx(Tag,{className:"w-4 h-4"}),text:jsx(Type,{className:"w-4 h-4"}),number:jsx(Hash,{className:"w-4 h-4"}),date:jsx(Calendar,{className:"w-4 h-4"}),dropdown:jsx(ChevronDown,{className:"w-4 h-4"}),checkbox:jsx(CheckSquare,{className:"w-4 h-4"})},Fy=["name","status","priority","assignees","startDate","endDate","progress","tags"];function Zm({isOpen:e,onClose:t,columns:a,customFields:r=[],onColumnsChange:o,onCreateCustomField:s,isDark:n,locale:c}){let[g,i]=useState(""),p=useRef(null),l=c==="es"?Jm.es:Jm.en;if(useEffect(()=>{if(!e)return;let b=setTimeout(()=>{let u=m=>{p.current&&!p.current.contains(m.target)&&t();},x=m=>{m.key==="Escape"&&t();};document.addEventListener("mousedown",u),document.addEventListener("keydown",x),p._cleanup=()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",x);};},100);return ()=>{clearTimeout(b),p._cleanup&&p._cleanup();}},[e,t]),!e)return null;let f=b=>l.columns[b]||b,y=b=>{if(b==="name")return;let u=a.map(x=>x.id===b?{...x,visible:!x.visible}:x);o(u);},k=(b,u)=>{let x=a.find(N=>N.type===b&&(!u||N.customFieldId===u));if(x){y(x.id);return}let m={id:u||b,type:b,label:u?r.find(N=>N.id===u)?.name||b:f(b),width:120,visible:true,sortable:true,resizable:true,customFieldId:u};o([...a,m]);},C=Fy.filter(b=>f(b).toLowerCase().includes(g.toLowerCase())),h=r.filter(b=>b.name.toLowerCase().includes(g.toLowerCase()));return jsxs("div",{ref:p,className:d("absolute right-0 top-full mt-1 w-72 rounded-lg shadow-xl border z-50",n?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:[jsxs("div",{className:d("flex items-center justify-between px-4 py-3 border-b",n?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("font-medium",n?"text-white":"text-gray-900"),children:l.title}),jsx("button",{onClick:t,className:d("p-1 rounded",n?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(X,{className:d("w-4 h-4",n?"text-[#9CA3AF]":"text-gray-400")})})]}),jsx("div",{className:"p-3",children:jsxs("div",{className:"relative",children:[jsx(Search,{className:d("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",n?"text-[#6B7280]":"text-gray-400")}),jsx("input",{type:"text",value:g,onChange:b=>i(b.target.value),placeholder:l.searchPlaceholder,className:d("w-full pl-9 pr-3 py-2 text-sm rounded-lg border outline-none",n?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400")})]})}),jsxs("div",{className:"px-3 pb-2",children:[jsx("h4",{className:d("text-xs font-medium uppercase tracking-wider mb-2",n?"text-[#6B7280]":"text-gray-400"),children:l.standardFields}),jsx("div",{className:"space-y-1",children:C.map(b=>{let u=a.find(N=>N.type===b&&!N.customFieldId),x=u?.visible??false,m=b==="name";return jsxs("button",{onClick:()=>{m||(u?y(u.id):k(b));},disabled:m,className:d("w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors",n?"hover:bg-white/10":"hover:bg-gray-100",m&&"opacity-50 cursor-not-allowed"),children:[jsx("div",{className:d("w-5 h-5 rounded border flex items-center justify-center",x?"bg-[#3B82F6] border-[#3B82F6]":n?"border-[#4B5563]":"border-gray-300"),children:x&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsx("span",{className:n?"text-[#9CA3AF]":"text-gray-400",children:Xm[b]}),jsx("span",{className:n?"text-white":"text-gray-900",children:f(b)})]},b)})})]}),h.length>0&&jsxs("div",{className:"px-3 pb-2",children:[jsx("h4",{className:d("text-xs font-medium uppercase tracking-wider mb-2",n?"text-[#6B7280]":"text-gray-400"),children:l.customFields}),jsx("div",{className:"space-y-1",children:h.map(b=>{let x=a.find(m=>m.customFieldId===b.id)?.visible??false;return jsxs("button",{onClick:()=>k(b.type,b.id),className:d("w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors",n?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx("div",{className:d("w-5 h-5 rounded border flex items-center justify-center",x?"bg-[#3B82F6] border-[#3B82F6]":n?"border-[#4B5563]":"border-gray-300"),children:x&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsx("span",{className:n?"text-[#9CA3AF]":"text-gray-400",children:Xm[b.type]||jsx(Type,{className:"w-4 h-4"})}),jsx("span",{className:n?"text-white":"text-gray-900",children:b.name})]},b.id)})})]}),s&&jsx("div",{className:d("p-3 border-t",n?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:s,className:d("w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-colors",n?"bg-[#3B82F6]/20 text-[#3B82F6] hover:bg-[#3B82F6]/30":"bg-blue-50 text-blue-600 hover:bg-blue-100"),children:[jsx(Plus,{className:"w-4 h-4"}),l.createField]})})]})}var Jm={en:{title:"Columns",searchPlaceholder:"Search fields...",standardFields:"Standard Fields",customFields:"Custom Fields",createField:"Create custom field",columns:{name:"Name",status:"Status",priority:"Priority",assignees:"Assignees",startDate:"Start Date",endDate:"End Date",progress:"Progress",tags:"Tags",text:"Text",number:"Number",date:"Date",dropdown:"Dropdown",checkbox:"Checkbox"}},es:{title:"Columnas",searchPlaceholder:"Buscar campos...",standardFields:"Campos Est\xE1ndar",customFields:"Campos Personalizados",createField:"Crear campo personalizado",columns:{name:"Nombre",status:"Estado",priority:"Prioridad",assignees:"Asignados",startDate:"Fecha Inicio",endDate:"Fecha Fin",progress:"Progreso",tags:"Etiquetas",text:"Texto",number:"N\xFAmero",date:"Fecha",dropdown:"Lista",checkbox:"Casilla"}}};var Hy=[{type:"text",icon:jsx(Type,{className:"w-5 h-5"})},{type:"number",icon:jsx(Hash,{className:"w-5 h-5"})},{type:"date",icon:jsx(Calendar,{className:"w-5 h-5"})},{type:"dropdown",icon:jsx(ChevronDown,{className:"w-5 h-5"})},{type:"checkbox",icon:jsx(CheckSquare,{className:"w-5 h-5"})}];function tp({isOpen:e,onClose:t,onSave:a,isDark:r,locale:o}){let[s,n]=useState(""),[c,g]=useState("text"),[i,p]=useState([""]),l=o==="es"?ep.es:ep.en;useEffect(()=>{e&&(n(""),g("text"),p([""]));},[e]),useEffect(()=>{let h=b=>{b.key==="Escape"&&t();};return e&&document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,t]);let f=()=>{if(!s.trim())return;let h={name:s.trim(),type:c};c==="dropdown"&&(h.options=i.filter(b=>b.trim())),a(h),t();},y=()=>{p([...i,""]);},k=(h,b)=>{let u=[...i];u[h]=b,p(u);},C=h=>{i.length>1&&p(i.filter((b,u)=>u!==h));};return e?jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),jsxs("div",{className:d("relative w-full max-w-md rounded-xl shadow-2xl border",r?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:[jsxs("div",{className:d("flex items-center justify-between px-6 py-4 border-b",r?"border-white/10":"border-gray-200"),children:[jsx("h2",{className:d("text-lg font-semibold",r?"text-white":"text-gray-900"),children:l.title}),jsx("button",{onClick:t,className:d("p-1 rounded",r?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(X,{className:d("w-5 h-5",r?"text-[#9CA3AF]":"text-gray-400")})})]}),jsxs("div",{className:"p-6 space-y-6",children:[jsxs("div",{children:[jsx("label",{className:d("block text-sm font-medium mb-2",r?"text-white":"text-gray-900"),children:l.fieldName}),jsx("input",{type:"text",value:s,onChange:h=>n(h.target.value),placeholder:l.fieldNamePlaceholder,className:d("w-full px-4 py-2.5 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",r?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400"),autoFocus:true})]}),jsxs("div",{children:[jsx("label",{className:d("block text-sm font-medium mb-2",r?"text-white":"text-gray-900"),children:l.fieldType}),jsx("div",{className:"grid grid-cols-5 gap-2",children:Hy.map(h=>jsxs("button",{onClick:()=>g(h.type),className:d("flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors",c===h.type?"border-[#3B82F6] bg-[#3B82F6]/10":r?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300"),children:[jsx("span",{className:c===h.type?"text-[#3B82F6]":r?"text-[#9CA3AF]":"text-gray-400",children:h.icon}),jsx("span",{className:d("text-xs",c===h.type?"text-[#3B82F6]":r?"text-[#9CA3AF]":"text-gray-500"),children:l.types[h.type]})]},h.type))})]}),c==="dropdown"&&jsxs("div",{children:[jsx("label",{className:d("block text-sm font-medium mb-2",r?"text-white":"text-gray-900"),children:l.options}),jsxs("div",{className:"space-y-2",children:[i.map((h,b)=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"text",value:h,onChange:u=>k(b,u.target.value),placeholder:`${l.option} ${b+1}`,className:d("flex-1 px-3 py-2 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",r?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400")}),i.length>1&&jsx("button",{onClick:()=>C(b),className:d("p-2 rounded-lg transition-colors",r?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-400"),children:jsx(Trash2,{className:"w-4 h-4"})})]},b)),jsxs("button",{onClick:y,className:d("flex items-center gap-2 px-3 py-2 text-sm rounded-lg transition-colors",r?"text-[#3B82F6] hover:bg-white/10":"text-blue-600 hover:bg-gray-100"),children:[jsx(Plus,{className:"w-4 h-4"}),l.addOption]})]})]})]}),jsxs("div",{className:d("flex items-center justify-end gap-3 px-6 py-4 border-t",r?"border-white/10":"border-gray-200"),children:[jsx("button",{onClick:t,className:d("px-4 py-2 text-sm font-medium rounded-lg transition-colors",r?"text-[#9CA3AF] hover:bg-white/10":"text-gray-600 hover:bg-gray-100"),children:l.cancel}),jsx("button",{onClick:f,disabled:!s.trim(),className:d("px-4 py-2 text-sm font-medium rounded-lg transition-colors","bg-[#3B82F6] text-white hover:bg-[#2563EB]",!s.trim()&&"opacity-50 cursor-not-allowed"),children:l.create})]})]})]}):null}var ep={en:{title:"Create Custom Field",fieldName:"Field Name",fieldNamePlaceholder:"Enter field name...",fieldType:"Field Type",options:"Options",option:"Option",addOption:"Add option",cancel:"Cancel",create:"Create Field",types:{text:"Text",number:"Number",date:"Date",dropdown:"Dropdown",checkbox:"Checkbox"}},es:{title:"Crear Campo Personalizado",fieldName:"Nombre del Campo",fieldNamePlaceholder:"Ingresa el nombre...",fieldType:"Tipo de Campo",options:"Opciones",option:"Opci\xF3n",addOption:"Agregar opci\xF3n",cancel:"Cancelar",create:"Crear Campo",types:{text:"Texto",number:"N\xFAmero",date:"Fecha",dropdown:"Lista",checkbox:"Casilla"}}};var rp={en:{filters:"Filters",filterByStatus:"FILTER BY STATUS",showAll:"Show All",completed:"Completed",inProgress:"In Progress",toDo:"To Do / Pending",hideCompleted:"Hide Completed Tasks"},es:{filters:"Filtros",filterByStatus:"FILTRAR POR ESTADO",showAll:"Mostrar Todo",completed:"Completadas",inProgress:"En Progreso",toDo:"Por Hacer / Pendiente",hideCompleted:"Ocultar Tareas Completadas"}};function op({value:e,hideCompleted:t,onChange:a,onHideCompletedChange:r,isDark:o,locale:s}){let[n,c]=useState(false),g=useRef(null),i=s==="es"?rp.es:rp.en;useEffect(()=>{if(!n)return;let f=setTimeout(()=>{let y=C=>{g.current&&!g.current.contains(C.target)&&c(false);},k=C=>{C.key==="Escape"&&c(false);};document.addEventListener("mousedown",y),document.addEventListener("keydown",k),g._cleanup=()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",k);};},100);return ()=>{clearTimeout(f),g._cleanup&&g._cleanup();}},[n]);let p=[{value:"all",label:i.showAll,icon:jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#3B82F6] bg-[#3B82F6]"}),color:"text-[#3B82F6]"},{value:"completed",label:i.completed,icon:jsx(CheckCircle2,{className:"w-4 h-4"}),color:"text-green-500"},{value:"in-progress",label:i.inProgress,icon:jsx(PlayCircle,{className:"w-4 h-4"}),color:"text-blue-500"},{value:"todo",label:i.toDo,icon:jsx(Circle,{className:"w-4 h-4"}),color:"text-gray-400"}],l=e!=="all"||t;return jsxs("div",{ref:g,className:"relative",children:[jsxs("button",{onClick:f=>{f.stopPropagation(),c(y=>!y);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors border",o?"border-white/10 hover:bg-white/10 text-white":"border-gray-200 hover:bg-gray-100 text-gray-700",l&&(o?"bg-[#3B82F6]/20 border-[#3B82F6]/50 text-[#3B82F6]":"bg-blue-50 border-blue-200 text-blue-600"),n&&(o?"bg-white/10":"bg-gray-100")),children:[jsx(Filter,{className:"w-4 h-4"}),i.filters,l&&jsx("span",{className:d("w-2 h-2 rounded-full",o?"bg-[#3B82F6]":"bg-blue-500")})]}),n&&jsxs("div",{className:d("absolute left-0 top-full mt-2 w-72 rounded-lg shadow-xl border z-50",o?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:[jsx("div",{className:d("px-4 py-3 border-b",o?"border-white/10":"border-gray-200"),children:jsx("span",{className:d("text-xs font-medium uppercase tracking-wider",o?"text-[#6B7280]":"text-gray-400"),children:i.filterByStatus})}),jsx("div",{className:"py-2",children:p.map(f=>{let y=e===f.value&&!t,k=()=>f.value==="all"?y?jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#3B82F6] bg-[#3B82F6]"}):jsx("div",{className:"w-4 h-4 rounded-full border-2 border-gray-400"}):f.icon;return jsxs("button",{onClick:()=>{a(f.value),r(false);},className:d("w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors",o?"hover:bg-white/10":"hover:bg-gray-100",y&&(o?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d(y?f.color:"text-gray-400","flex-shrink-0"),children:k()}),jsx("span",{className:d("flex-1 text-left whitespace-nowrap",o?"text-white":"text-gray-900"),children:f.label}),y&&jsx(Check,{className:d("w-4 h-4 flex-shrink-0",o?"text-[#3B82F6]":"text-blue-500")})]},f.value)})}),jsx("div",{className:d("my-2 mx-4 h-px",o?"bg-white/10":"bg-gray-200")}),jsx("div",{className:"py-1",children:jsxs("button",{onClick:()=>{r(!t),t||a("all");},className:d("w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors",o?"hover:bg-white/10":"hover:bg-gray-100",t&&(o?"bg-white/5":"bg-gray-50")),children:[jsx(EyeOff,{className:d("w-4 h-4 flex-shrink-0",t?o?"text-[#3B82F6]":"text-blue-500":o?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("flex-1 text-left whitespace-nowrap",o?"text-white":"text-gray-900"),children:i.hideCompleted}),t&&jsx(Check,{className:d("w-4 h-4 flex-shrink-0",o?"text-[#3B82F6]":"text-blue-500")})]})})]})]})}var iv=[{id:"name",type:"name",label:"Name",width:300,visible:true,sortable:true,resizable:true},{id:"status",type:"status",label:"Status",width:120,visible:true,sortable:true,resizable:true},{id:"startDate",type:"startDate",label:"Start Date",width:120,visible:true,sortable:true,resizable:true},{id:"endDate",type:"endDate",label:"End Date",width:120,visible:true,sortable:true,resizable:true},{id:"progress",type:"progress",label:"Progress",width:100,visible:true,sortable:true,resizable:true}];function ip(e,t=0){let a=[];for(let r of e)a.push({...r,level:t,hasChildren:(r.subtasks?.length||0)>0,parentPath:[r.id]}),r.subtasks?.length&&r.isExpanded!==false&&a.push(...ip(r.subtasks,t+1));return a}function lv({status:e,progress:t}){return t===100||e==="completed"?jsx(CheckCircle2,{className:"w-5 h-5 text-green-500"}):t&&t>0||e==="in-progress"?jsx(PlayCircle,{className:"w-5 h-5 text-blue-500"}):jsx(Circle,{className:"w-5 h-5 text-gray-400"})}function lp({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:n,availableUsers:c=[],customFields:g=[]}){let{theme:i="dark",locale:p="en",customTranslations:l,showSearch:f=true,showHierarchy:y=true,tableColumns:k,allowColumnCustomization:C=true,allowColumnResize:h=true,enableContextMenu:b=true}=t,u=is(p,l),x=i==="dark",[m,N]=useState("startDate"),[w,B]=useState("asc"),[v,I]=useState(""),[A,T]=useState("all"),[W,$]=useState(false),[j,te]=useState(k||iv),[oe,re]=useState(false),[ge,fe]=useState(false),[Ie,M]=useState({isOpen:false,x:0,y:0,type:"task"}),[R,L]=useState(null),[V,q]=useState(0),[z,ye]=useState(0),ne=useRef(null);useEffect(()=>{k&&te(k);},[k]);let Be=useMemo(()=>{let J=new Set;function ve(He){for(let Le of He)Le.subtasks?.length&&(Le.isExpanded!==false&&J.add(Le.id),ve(Le.subtasks));}return ve(e),J},[e]),qe=useMemo(()=>j.filter(J=>J.visible),[j]),tt=useCallback(J=>{a.onTaskToggleExpand?.(J);},[a]),le=useCallback(J=>{m===J?B(ve=>ve==="asc"?"desc":"asc"):(N(J),B("asc")),a.onSortChange?.({column:J,direction:w==="asc"?"desc":"asc"});},[m,w,a]),Je=useCallback(J=>{te(J),a.onColumnsChange?.(J);},[a]),ct=useCallback(J=>{let ve=j.map(He=>He.id===J?{...He,visible:false}:He);Je(ve);},[j,Je]),wt=useCallback((J,ve)=>{N(J),B(ve);},[]),vt=useCallback((J,ve,He)=>{b&&(J.preventDefault(),M({isOpen:true,x:J.clientX,y:J.clientY,type:ve?"task":"header",task:ve,columnId:He}));},[b]),U=useCallback(()=>{M(J=>({...J,isOpen:false}));},[]),me=useCallback((J,ve)=>{if(!h)return;J.preventDefault(),J.stopPropagation();let He=j.find(Le=>Le.id===ve);He&&(L(ve),q(J.clientX),ye(He.width));},[j,h]);useEffect(()=>{if(!R)return;let J=He=>{let Le=He.clientX-V,nt=Math.max(50,z+Le),st=j.map(_e=>_e.id===R?{..._e,width:nt}:_e);te(st);},ve=()=>{R&&a.onColumnsChange?.(j),L(null);};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",ve),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",ve);}},[R,V,z,j,a]);let Ae=useCallback(async J=>{if(a.onCreateCustomField){let ve={...J,id:`cf_${Date.now()}`,projectId:""};await a.onCreateCustomField(ve);}fe(false);},[a]),Fe=useCallback(J=>J.progress===100||J.status==="completed"?"completed":J.progress&&J.progress>0||J.status==="in-progress"?"in-progress":"todo",[]),je=useMemo(()=>{let J=ip(e);if(v.trim()){let ve=v.toLowerCase();J=J.filter(He=>He.name.toLowerCase().includes(ve));}return A!=="all"&&(J=J.filter(ve=>Fe(ve)===A)),W&&(J=J.filter(ve=>Fe(ve)!=="completed")),J.sort((ve,He)=>{let Le,nt;switch(m){case "name":Le=ve.name.toLowerCase(),nt=He.name.toLowerCase();break;case "startDate":Le=ve.startDate?.getTime()||0,nt=He.startDate?.getTime()||0;break;case "endDate":Le=ve.endDate?.getTime()||0,nt=He.endDate?.getTime()||0;break;case "progress":Le=ve.progress||0,nt=He.progress||0;break;case "status":Le=ve.status||"todo",nt=He.status||"todo";break;case "priority":let st={urgent:0,high:1,medium:2,low:3,none:4};Le=st[ve.priority]??4,nt=st[He.priority]??4;break;default:return 0}return Le<nt?w==="asc"?-1:1:Le>nt?w==="asc"?1:-1:0}),J},[e,v,A,W,m,w,Fe]),Qe=useCallback((J,ve)=>{let He=st=>{a.onTaskUpdate?.({...J,...st});},Le=st=>st?J.customFields?.find(ea=>ea.fieldId===st)?.value:void 0,nt=(st,_e)=>{if(!st)return;let ke=[...J.customFields||[]],be=ke.findIndex(Ke=>Ke.fieldId===st);be>=0?ke[be]={fieldId:st,value:_e}:ke.push({fieldId:st,value:_e}),He({customFields:ke});};switch(ve.type){case "name":return null;case "status":return jsx(Cm,{value:J.status||(J.progress===100?"completed":J.progress&&J.progress>0?"in-progress":"todo"),onChange:_e=>{He({status:_e,progress:_e==="completed"?100:_e==="in-progress"?50:0});},isDark:x,locale:p,translations:u.status});case "priority":return jsx(Nm,{value:J.priority,onChange:_e=>He({priority:_e}),isDark:x,locale:p});case "assignees":return jsx(Sm,{value:J.assignees||[],availableUsers:c,onChange:_e=>He({assignees:_e}),isDark:x,locale:p});case "startDate":return jsx(ps,{value:J.startDate,onChange:_e=>He({startDate:_e}),isDark:x,locale:p});case "endDate":return jsx(ps,{value:J.endDate,onChange:_e=>He({endDate:_e}),isDark:x,locale:p});case "progress":return jsx(Am,{value:J.progress||0,onChange:_e=>{let ea=_e===100?"completed":_e>0?"in-progress":"todo";He({progress:_e,status:ea});},isDark:x});case "tags":return jsx(Gm,{value:J.tags||[],isDark:x});case "text":return jsx(Im,{value:Le(ve.customFieldId)||"",onChange:_e=>nt(ve.customFieldId,_e),isDark:x});case "number":return jsx(Om,{value:Le(ve.customFieldId)||0,onChange:_e=>nt(ve.customFieldId,_e),isDark:x});case "date":let st=Le(ve.customFieldId);return jsx(ps,{value:st?new Date(st):void 0,onChange:_e=>nt(ve.customFieldId,_e),isDark:x,locale:p});case "dropdown":return jsx($m,{value:Le(ve.customFieldId)||"",options:ve.options||[],onChange:_e=>nt(ve.customFieldId,_e),isDark:x});case "checkbox":return jsx(zm,{value:Le(ve.customFieldId)||false,onChange:_e=>nt(ve.customFieldId,_e),isDark:x});default:return jsx("span",{className:d("text-sm",x?"text-[#94A3B8]":"text-gray-500"),children:"-"})}},[a,x,p,c,u]),Pt=useCallback(J=>({name:u.columns.name,status:u.columns.status,priority:u.columns.priority,assignees:u.columns.assignees,startDate:u.columns.startDate,endDate:u.columns.endDate,progress:u.columns.progress})[J.type]||J.label,[u]),Re=useMemo(()=>qe.reduce((J,ve)=>J+ve.width,0)+(C?48:0),[qe,C]);return r?jsx("div",{className:d("flex-1 flex items-center justify-center",x?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:d("text-sm",x?"text-[#9CA3AF]":"text-gray-600"),children:[u.empty.noTasks,"..."]})]})}):o?jsx("div",{className:d("flex-1 flex items-center justify-center",x?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:d("text-lg font-semibold mb-2",x?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:d("text-sm",x?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:d("flex-1 flex items-center justify-center",x?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(List,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:d("text-lg font-semibold mb-2",x?"text-white":"text-gray-900"),children:u.empty.noTasks}),jsx("p",{className:d("text-sm",x?"text-[#9CA3AF]":"text-gray-600"),children:u.empty.addFirstTask})]})}):jsxs("div",{ref:ne,className:d("flex-1 flex flex-col w-full h-full overflow-hidden",x?"bg-[#0F1117]":"bg-white",R&&"select-none",s),style:n,children:[jsx("div",{className:d("flex-shrink-0 px-6 py-4 border-b",x?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[jsx(op,{value:A,hideCompleted:W,onChange:T,onHideCompletedChange:$,isDark:x,locale:p}),f&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:d("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",x?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:v,onChange:J=>I(J.target.value),placeholder:u.toolbar.searchPlaceholder,className:d("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",x?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-100 border-gray-200 text-gray-900 placeholder:text-gray-400")})]}),jsxs("div",{className:d("text-sm",x?"text-[#9CA3AF]":"text-gray-600"),children:[je.length," ",u.pagination.tasks]})]})}),jsx("div",{className:"flex-1 overflow-auto",children:jsxs("div",{style:{minWidth:Re},children:[jsxs("div",{className:d("flex-shrink-0 flex items-center border-b text-xs font-medium uppercase tracking-wider sticky top-0 z-10",x?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[qe.map(J=>jsxs("div",{className:d("relative flex items-center gap-2 px-4 py-3",x?"text-[#9CA3AF]":"text-gray-500"),style:{width:J.width,minWidth:J.minWidth},onContextMenu:ve=>vt(ve,void 0,J.id),children:[J.sortable?jsxs("button",{onClick:()=>le(J.id),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[Pt(J),jsx(ArrowUpDown,{className:d("w-3 h-3",m===J.id&&"text-[#3B82F6]")})]}):jsx("span",{children:Pt(J)}),h&&J.resizable&&jsx("div",{className:d("absolute right-0 top-0 bottom-0 w-1 cursor-col-resize group","hover:bg-[#3B82F6]",R===J.id&&"bg-[#3B82F6]"),onMouseDown:ve=>me(ve,J.id)})]},J.id)),C&&jsxs("div",{className:"relative flex items-center justify-center px-3 py-3",children:[jsx("button",{onClick:J=>{J.stopPropagation(),re(ve=>!ve);},className:d("p-1.5 rounded-lg transition-colors",x?"hover:bg-white/10 text-[#9CA3AF] hover:text-white":"hover:bg-gray-200 text-gray-400 hover:text-gray-600",oe&&(x?"bg-white/10":"bg-gray-200")),title:p==="es"?"Agregar columna":"Add column",children:jsx(Plus,{className:"w-4 h-4"})}),jsx(Zm,{isOpen:oe,onClose:()=>re(false),columns:j,customFields:g,onColumnsChange:Je,onCreateCustomField:()=>{re(false),fe(true);},isDark:x,locale:p})]})]}),jsx(AnimatePresence,{children:je.map((J,ve)=>{let He=Be.has(J.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:ve*.02},className:d("flex items-center border-b transition-colors",x?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),onClick:()=>a.onTaskClick?.(J),onDoubleClick:()=>a.onTaskDoubleClick?.(J),onContextMenu:Le=>vt(Le,J),children:[qe.map(Le=>jsx("div",{className:"flex items-center px-4 py-3 min-h-[52px]",style:{width:Le.width,minWidth:Le.minWidth},children:Le.type==="name"?jsxs("div",{className:"flex items-center gap-2 min-w-0 w-full",children:[y&&J.level>0&&jsx("div",{style:{width:`${J.level*24}px`},className:"flex-shrink-0"}),y&&J.hasChildren&&jsx("button",{onClick:nt=>{nt.stopPropagation(),tt(J.id);},className:d("p-0.5 rounded flex-shrink-0",x?"hover:bg-white/10":"hover:bg-gray-200"),children:He?jsx(ChevronDown,{className:d("w-4 h-4",x?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:d("w-4 h-4",x?"text-[#9CA3AF]":"text-gray-400")})}),y&&!J.hasChildren&&jsx("div",{className:"w-5 flex-shrink-0"}),jsx("button",{onClick:nt=>{nt.stopPropagation(),a.onTaskUpdate?.({...J,progress:J.progress===100?0:100,status:J.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(lv,{status:J.status,progress:J.progress})}),jsx("span",{className:d("truncate font-medium",x?"text-white":"text-gray-900",J.progress===100&&(x?"line-through text-[#6B7280]":"line-through text-gray-400")),children:J.name})]}):Qe(J,Le)},Le.id)),C&&jsx("div",{className:"w-12 flex-shrink-0"})]},J.id)})}),je.length===0&&v&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:d("w-12 h-12 mx-auto mb-4",x?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:d(x?"text-[#9CA3AF]":"text-gray-600"),children:u.empty.noResults})]})})]})}),jsx(Km,{state:Ie,onClose:U,isDark:x,locale:p,onTaskEdit:a.onTaskEdit,onTaskDuplicate:a.onTaskDuplicate,onTaskDelete:a.onTaskDelete,onTaskUpdate:a.onTaskUpdate,onColumnHide:ct,onColumnSort:wt,availableUsers:c}),jsx(tp,{isOpen:ge,onClose:()=>fe(false),onSave:Ae,isDark:x,locale:p})]})}var dp=[{id:"name",type:"name",label:"Name",width:300,visible:true,sortable:true,resizable:true},{id:"status",type:"status",label:"Status",width:120,visible:true,sortable:true,resizable:true},{id:"priority",type:"priority",label:"Priority",width:100,visible:false,sortable:true,resizable:true},{id:"assignees",type:"assignees",label:"Assignees",width:150,visible:false,sortable:false,resizable:true},{id:"startDate",type:"startDate",label:"Start Date",width:120,visible:true,sortable:true,resizable:true},{id:"endDate",type:"endDate",label:"End Date",width:120,visible:true,sortable:true,resizable:true},{id:"progress",type:"progress",label:"Progress",width:100,visible:true,sortable:true,resizable:true},{id:"tags",type:"tags",label:"Tags",width:150,visible:false,sortable:false,resizable:true}],cp=[{type:"name",labelKey:"columns.name",icon:"Type"},{type:"status",labelKey:"columns.status",icon:"CircleDot"},{type:"priority",labelKey:"columns.priority",icon:"Flag"},{type:"assignees",labelKey:"columns.assignees",icon:"Users"},{type:"startDate",labelKey:"columns.startDate",icon:"Calendar"},{type:"endDate",labelKey:"columns.endDate",icon:"CalendarCheck"},{type:"progress",labelKey:"columns.progress",icon:"BarChart"},{type:"tags",labelKey:"columns.tags",icon:"Tag"}],mp=[{type:"text",labelKey:"customFields.text",icon:"Type"},{type:"number",labelKey:"customFields.number",icon:"Hash"},{type:"date",labelKey:"customFields.date",icon:"Calendar"},{type:"dropdown",labelKey:"customFields.dropdown",icon:"ChevronDown"},{type:"checkbox",labelKey:"customFields.checkbox",icon:"CheckSquare"}];var pl={bgPrimary:"#0d1117",bgSecondary:"#161b22",bgHover:"#21262d",bgSelected:"#1f6feb20",bgAlternate:"#0d111780",border:"#30363d",borderLight:"#21262d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#6e7681",accent:"#58a6ff",accentHover:"#79b8ff",accentLight:"#58a6ff20",statusTodo:"#8b949e",statusInProgress:"#f0883e",statusCompleted:"#3fb950",focusRing:"#58a6ff",checkboxBg:"#21262d",checkboxChecked:"#58a6ff"},ul={bgPrimary:"#ffffff",bgSecondary:"#f6f8fa",bgHover:"#f3f4f6",bgSelected:"#dbeafe",bgAlternate:"#f9fafb",border:"#d0d7de",borderLight:"#e5e7eb",textPrimary:"#24292f",textSecondary:"#57606a",textMuted:"#8b949e",accent:"#0969da",accentHover:"#0550ae",accentLight:"#dbeafe",statusTodo:"#8b949e",statusInProgress:"#bf8700",statusCompleted:"#1a7f37",focusRing:"#0969da",checkboxBg:"#ffffff",checkboxChecked:"#0969da"},gl={bgPrimary:"#1a1a2e",bgSecondary:"#16213e",bgHover:"#1f3460",bgSelected:"#0f4c7520",bgAlternate:"#1a1a2e80",border:"#2a3f5f",borderLight:"#1f3460",textPrimary:"#e4e6eb",textSecondary:"#a8b2c1",textMuted:"#6b7280",accent:"#6366f1",accentHover:"#818cf8",accentLight:"#6366f120",statusTodo:"#9ca3af",statusInProgress:"#fbbf24",statusCompleted:"#34d399",focusRing:"#6366f1",checkboxBg:"#1f3460",checkboxChecked:"#6366f1"},fs={dark:pl,light:ul,neutral:gl};function pp(e){return fs[e]||fs.dark}var fl={navigation:{today:"Today",previous:"Previous",next:"Next",month:"Month",week:"Week",day:"Day"},weekdays:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},weekdaysFull:{sunday:"Sunday",monday:"Monday",tuesday:"Tuesday",wednesday:"Wednesday",thursday:"Thursday",friday:"Friday",saturday:"Saturday"},months:{january:"January",february:"February",march:"March",april:"April",may:"May",june:"June",july:"July",august:"August",september:"September",october:"October",november:"November",december:"December"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{allDay:"All day",moreEvents:"+{count} more",noEvents:"No tasks",newTask:"New Task",viewAll:"View all",week:"Week"},tooltips:{progress:"Progress",status:"Status",assignees:"Assignees",duration:"Duration",days:"days"}},bl={navigation:{today:"Hoy",previous:"Anterior",next:"Siguiente",month:"Mes",week:"Semana",day:"D\xEDa"},weekdays:{sun:"Dom",mon:"Lun",tue:"Mar",wed:"Mi\xE9",thu:"Jue",fri:"Vie",sat:"S\xE1b"},weekdaysFull:{sunday:"Domingo",monday:"Lunes",tuesday:"Martes",wednesday:"Mi\xE9rcoles",thursday:"Jueves",friday:"Viernes",saturday:"S\xE1bado"},months:{january:"Enero",february:"Febrero",march:"Marzo",april:"Abril",may:"Mayo",june:"Junio",july:"Julio",august:"Agosto",september:"Septiembre",october:"Octubre",november:"Noviembre",december:"Diciembre"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{allDay:"Todo el d\xEDa",moreEvents:"+{count} m\xE1s",noEvents:"Sin tareas",newTask:"Nueva Tarea",viewAll:"Ver todo",week:"Semana"},tooltips:{progress:"Progreso",status:"Estado",assignees:"Asignados",duration:"Duraci\xF3n",days:"d\xEDas"}},bs={en:fl,es:bl};function ln(e){return bs[e]||bs.en}function hs(e,t){let a=ln(e);return t?{navigation:{...a.navigation,...t.navigation},weekdays:{...a.weekdays,...t.weekdays},weekdaysFull:{...a.weekdaysFull,...t.weekdaysFull},months:{...a.months,...t.months},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},tooltips:{...a.tooltips,...t.tooltips}}:a}function up(e){let t=ln(e);return [t.months.january,t.months.february,t.months.march,t.months.april,t.months.may,t.months.june,t.months.july,t.months.august,t.months.september,t.months.october,t.months.november,t.months.december]}function gp(e,t=0,a=true){let r=ln(e),o=a?[r.weekdays.sun,r.weekdays.mon,r.weekdays.tue,r.weekdays.wed,r.weekdays.thu,r.weekdays.fri,r.weekdays.sat]:[r.weekdaysFull.sunday,r.weekdaysFull.monday,r.weekdaysFull.tuesday,r.weekdaysFull.wednesday,r.weekdaysFull.thursday,r.weekdaysFull.friday,r.weekdaysFull.saturday];return [...o.slice(t),...o.slice(0,t)]}function Sv(e){let t=[];function a(r){for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);}return a(e),t}function wl(e,t){if(!t.startDate||!t.endDate)return false;let a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.startDate.getFullYear(),t.startDate.getMonth(),t.startDate.getDate()),o=new Date(t.endDate.getFullYear(),t.endDate.getMonth(),t.endDate.getDate());return a>=r&&a<=o}function vp({task:e}){return e.progress===100||e.status==="completed"?jsx(CheckCircle2,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):e.progress&&e.progress>0||e.status==="in-progress"?jsx(PlayCircle,{className:"w-3 h-3 text-blue-500 flex-shrink-0"}):jsx(Circle,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})}function kp({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:n,style:c,availableTags:g=[],onCreateTag:i,attachmentsByTask:p,comments:l,onAddComment:f,currentUser:y,mentionableUsers:k,onTaskOpen:C}){let{theme:h="dark",locale:b="en",customTranslations:u}=t,x=hs(b,u),m=h==="dark",N={textTertiary:m?"#6B7280":"#9CA3AF",textSecondary:m?"#9CA3AF":"#6B7280",textPrimary:m?"#FFFFFF":"#111827",borderLight:m?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:m?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:m?"#1A1D25":"#FFFFFF",bgSecondary:m?"#0F1117":"#F9FAFB",hoverBg:m?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},[w,B]=useState(r||new Date),[v,I]=useState(null),[A,T]=useState(null),[W,$]=useState(null),[j,te]=useState(new Date),[oe,re]=useState({}),ge=4,fe=3,[Ie,M]=useState(false),[R,L]=useState(false),[V,q]=useState(false),[z,ye]=useState(false),[ne,Be]=useState(null),[qe,tt]=useState(""),[le,Je]=useState(void 0),[ct,wt]=useState(null),[vt,U]=useState(false),[me,Ae]=useState(false),[Fe,je]=useState(null),[Qe,Pt]=useState(false),[Re,J]=useState(new Date),[ve,He]=useState(false),[Le,nt]=useState(false),[st,_e]=useState(false),[ea,ke]=useState(""),[be,Ke]=useState(false),[F,Ce]=useState(""),[Z,Te]=useState(false),we=useCallback(()=>{B(new Date(w.getFullYear(),w.getMonth()-1,1));},[w]),Oe=useCallback(()=>{B(new Date(w.getFullYear(),w.getMonth()+1,1));},[w]),$e=useCallback(()=>{B(new Date);},[]),dt=useMemo(()=>{let P=w.getFullYear(),O=w.getMonth(),Me=new Date(P,O,1),Xe=new Date(P,O+1,0),Lt=Me.getDay(),de=Xe.getDate(),ze=Sv(e),xt=new Date;xt.setHours(0,0,0,0);let Ve=[],ft=Lt,aa=new Date(P,O,0).getDate();for(let jt=ft-1;jt>=0;jt--){let Ze=new Date(P,O-1,aa-jt);Ve.push({date:Ze,isCurrentMonth:false,isToday:false,isWeekend:Ze.getDay()===0||Ze.getDay()===6,events:ze.filter(Kt=>wl(Ze,Kt)).map(Kt=>({id:Kt.id,title:Kt.name,start:Kt.startDate,end:Kt.endDate,task:Kt}))});}for(let jt=1;jt<=de;jt++){let Ze=new Date(P,O,jt),Kt=Ze.getTime()===xt.getTime();Ve.push({date:Ze,isCurrentMonth:true,isToday:Kt,isWeekend:Ze.getDay()===0||Ze.getDay()===6,events:ze.filter(la=>wl(Ze,la)).map(la=>({id:la.id,title:la.name,start:la.startDate,end:la.endDate,task:la}))});}let Ca=42-Ve.length;for(let jt=1;jt<=Ca;jt++){let Ze=new Date(P,O+1,jt);Ve.push({date:Ze,isCurrentMonth:false,isToday:false,isWeekend:Ze.getDay()===0||Ze.getDay()===6,events:ze.filter(Kt=>wl(Ze,Kt)).map(Kt=>({id:Kt.id,title:Kt.name,start:Kt.startDate,end:Kt.endDate,task:Kt}))});}return Ve},[w,e]),_=b==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Y=w.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),se=useCallback((P,O)=>{if(!v)return;let Me={...v,[P]:O};I(Me),a.onTaskUpdate?.(Me);},[v,a]),Ye=useCallback(P=>{if(!v)return;let O=v.progress||0;P==="completed"?O=100:P==="todo"&&(O=0);let Me={...v,status:P,progress:O};I(Me),a.onTaskUpdate?.(Me),M(false);},[v,a]),Ue=useCallback((P,O)=>{if(!v)return;let Me={...v,startDate:P,endDate:O};I(Me),a.onTaskUpdate?.(Me);},[v,a]),H=useCallback(()=>{M(false),L(false),q(false),$(null),_e(false),ke(""),Ke(false);},[]),ie=useCallback(async P=>{if(P.preventDefault(),P.stopPropagation(),He(false),!v||!a.onUploadAttachments)return;let O=Array.from(P.dataTransfer.files);if(O.length!==0){nt(true);try{await a.onUploadAttachments(v.id,O);}finally{nt(false);}}},[v,a]),We=useCallback(async P=>{if(!v||!a.onUploadAttachments||!P.target.files)return;let O=Array.from(P.target.files);if(O.length!==0){nt(true);try{await a.onUploadAttachments(v.id,O);}finally{nt(false);}P.target.value="";}},[v,a]),Mt=useCallback(P=>{P.preventDefault(),P.stopPropagation(),He(true);},[]),pt=useCallback(P=>{P.preventDefault(),P.stopPropagation(),He(false);},[]),Ar=useCallback(P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(1024*1024)).toFixed(1)} MB`,[]),wa=useCallback(P=>P.startsWith("image/")?Image:P.includes("pdf")||P.includes("document")?FileText:File,[]),ta=useMemo(()=>!v||!p?[]:p.get(v.id)||[],[v,p]);return o?jsx("div",{className:d("flex-1 flex items-center justify-center",m?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:[x.labels.noEvents,"..."]})]})}):s?jsx("div",{className:d("flex-1 flex items-center justify-center",m?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:d("text-lg font-semibold mb-2",m?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:d("flex-1 flex items-center justify-center",m?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(Calendar,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:d("text-lg font-semibold mb-2",m?"text-white":"text-gray-900"),children:x.labels.noEvents}),jsx("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:x.labels.newTask})]})}):jsxs("div",{className:d("flex-1 flex flex-col w-full h-full overflow-auto",m?"bg-[#0F1117]":"bg-white",n),style:c,children:[jsx("div",{className:d("flex-shrink-0 px-6 py-4 border-b",m?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx("h2",{className:d("text-xl font-semibold capitalize",m?"text-white":"text-gray-900"),children:Y}),jsx("button",{onClick:$e,className:d("px-3 py-1.5 text-sm rounded-lg transition-colors",m?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:x.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:we,className:d("p-2 rounded-lg transition-colors",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:d("w-5 h-5",m?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:Oe,className:d("p-2 rounded-lg transition-colors",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:d("w-5 h-5",m?"text-[#9CA3AF]":"text-gray-600")})})]})]})}),jsx("div",{className:"flex-1 p-6 min-h-0",children:jsxs("div",{className:"flex flex-col",children:[jsx("div",{className:"grid grid-cols-7 gap-px mb-2",children:_.map(P=>jsx("div",{className:d("py-2 text-center text-xs font-medium uppercase",m?"text-[#9CA3AF]":"text-gray-500"),children:P},P))}),jsx("div",{className:d("grid grid-cols-7 auto-rows-min gap-px rounded-lg",m?"bg-[#2D2D2D]":"bg-gray-300"),children:dt.map((P,O)=>{let Me=P.date.getDay()===0||P.date.getDay()===6;return jsxs("div",{className:d("min-h-[120px] p-2 transition-colors flex flex-col relative group",m?Me?"bg-[#1C1F26]":P.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":Me?"bg-gray-100":P.isCurrentMonth?"bg-white":"bg-gray-50",P.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let Xe=oe[O]||ge,Lt=P.events.slice(0,Xe),de=P.events.length-Xe;return jsxs("div",{className:"space-y-1 flex-1",children:[Lt.map(ze=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{I(ze.task),a.onEventClick?.(ze),C?.(ze.task.id);},whileHover:{scale:1.02},className:d("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",ze.task.progress===100?m?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":m?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx(vp,{task:ze.task}),jsx("span",{className:"truncate",children:ze.title})]})},ze.id)),de>0&&jsxs("button",{onClick:ze=>{ze.stopPropagation(),re(xt=>({...xt,[O]:Xe+fe}));},className:d("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",m?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",de," ",b==="es"?"M\xC1S":"MORE"]}),Xe>ge&&P.events.length>ge&&jsx("button",{onClick:ze=>{ze.stopPropagation(),re(xt=>({...xt,[O]:ge}));},className:d("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",m?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:b==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let Xe=O>=28,Lt=O%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:de=>{de.stopPropagation(),ne===O?Be(null):(Be(O),tt(""),Je(void 0),wt(null),je(null),U(false),Ae(false),Pt(false),J(P.date));},className:d("w-5 h-5 rounded flex items-center justify-center transition-all",ne===O?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",m?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:d("w-3.5 h-3.5 transition-transform",ne===O&&"rotate-45")})}),jsx(AnimatePresence,{children:ne===O&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Be(null),tt(""),Je(void 0),wt(null),je(null),U(false),Ae(false),Pt(false);}}),jsxs(motion.div,{initial:{opacity:0,y:Xe?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:Xe?-5:5,scale:.95},transition:{duration:.12},className:d("absolute w-[320px] rounded-lg shadow-2xl z-50",Xe?"bottom-full mb-1":"top-full mt-1",Lt?"right-0":"left-0",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:de=>{de.stopPropagation(),U(false),Ae(false),Pt(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:qe,onChange:de=>tt(de.target.value),placeholder:b==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:d("w-full bg-transparent text-sm outline-none placeholder:opacity-40",m?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:de=>{if(de.key==="Enter"&&qe.trim()){let ze=t.availableUsers?.find(Ve=>Ve.id===ct),xt=Fe||P.date;a.onTaskCreate?.({name:qe.trim(),startDate:xt,endDate:xt,priority:le,assignees:ze?[ze]:void 0}),tt(""),Je(void 0),wt(null),je(null),Be(null);}de.key==="Escape"&&(Be(null),tt(""),Je(void 0),wt(null),je(null));}})}),jsxs("div",{className:d("px-2.5 py-2 flex items-center justify-between border-t",m?"border-white/10":"border-gray-100"),children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs("div",{className:"relative",children:[jsx("button",{onClick:de=>{de.stopPropagation(),U(!vt),Ae(false);},className:d("p-1 rounded transition-colors",le?le==="urgent"||le==="high"?"text-red-400 bg-red-500/20":le==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":m?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Flag,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:vt&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:de=>de.stopPropagation(),children:[{id:"urgent",label:b==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:b==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:b==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:b==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:b==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(de=>jsxs("button",{onClick:()=>{Je(de.id),U(false);},className:d("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",le===de.id&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",de.color)}),jsx("span",{className:m?"text-white":"text-gray-900",children:de.label})]},de.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:de=>{de.stopPropagation(),Pt(!Qe),U(false),Ae(false),J(Fe||P.date);},className:d("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",Fe?"bg-[#7C3AED]/20 text-[#7C3AED]":m?"bg-white/5 text-[#9CA3AF] hover:bg-white/10":"bg-gray-100 text-gray-500 hover:bg-gray-200"),children:[jsx(CalendarDays,{className:"w-3 h-3"}),(Fe||P.date).toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:Qe&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:de=>de.stopPropagation(),children:[jsx("div",{className:d("w-40 py-2 border-r",m?"border-white/10":"border-gray-200"),children:(()=>{let de=new Date,ze=new Date(de);ze.setDate(de.getDate()+1);let xt=new Date(de);xt.setDate(de.getDate()+((6-de.getDay()+7)%7||7));let Ve=new Date(de);Ve.setDate(de.getDate()+((1-de.getDay()+7)%7||7));let ft=new Date(de);ft.setDate(de.getDate()+14);let aa=new Date(de);return aa.setDate(de.getDate()+28),[{label:b==="es"?"Hoy":"Today",date:de,display:de.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:b==="es"?"Ma\xF1ana":"Tomorrow",date:ze,display:ze.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:b==="es"?"Este fin de semana":"This weekend",date:xt,display:b==="es"?"s\xE1b.":"sat."},{label:b==="es"?"Pr\xF3xima semana":"Next week",date:Ve,display:b==="es"?"lun.":"mon."},{label:b==="es"?"2 semanas":"2 weeks",date:ft,display:ft.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:b==="es"?"4 semanas":"4 weeks",date:aa,display:aa.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((jt,Ze)=>jsxs("button",{className:d("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",m?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{je(jt.date),Pt(false);},children:[jsx("span",{children:jt.label}),jsx("span",{className:d("text-[10px]",m?"text-[#6B7280]":"text-gray-400"),children:jt.display})]},Ze))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:d("text-xs font-medium",m?"text-white":"text-gray-900"),children:Re.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>J(new Date),className:d("px-1.5 py-0.5 rounded text-[10px] transition-colors",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:b==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>J(new Date(Re.getFullYear(),Re.getMonth()-1)),className:d("p-0.5 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>J(new Date(Re.getFullYear(),Re.getMonth()+1)),className:d("p-0.5 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:"w-3.5 h-3.5"})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:(b==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(de=>jsx("div",{className:d("w-6 h-6 flex items-center justify-center text-[10px]",m?"text-[#6B7280]":"text-gray-400"),children:de},de))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let de=Re.getFullYear(),ze=Re.getMonth(),xt=new Date(de,ze,1).getDay(),Ve=new Date(de,ze+1,0).getDate(),ft=new Date(de,ze,0).getDate(),aa=new Date,Ca=[];for(let Ze=xt-1;Ze>=0;Ze--)Ca.push({dayNum:ft-Ze,isCurrentMonth:false,date:new Date(de,ze-1,ft-Ze)});for(let Ze=1;Ze<=Ve;Ze++)Ca.push({dayNum:Ze,isCurrentMonth:true,date:new Date(de,ze,Ze)});let jt=42-Ca.length;for(let Ze=1;Ze<=jt;Ze++)Ca.push({dayNum:Ze,isCurrentMonth:false,date:new Date(de,ze+1,Ze)});return Ca.map((Ze,Kt)=>{let la=Ze.date.toDateString()===aa.toDateString(),Fr=(Fe||P.date).toDateString()===Ze.date.toDateString();return jsx("button",{className:d("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!Ze.isCurrentMonth&&(m?"text-[#4B5563]":"text-gray-300"),Ze.isCurrentMonth&&(m?"text-white":"text-gray-900"),la&&"ring-1 ring-[#3B82F6]",Fr&&"bg-[#7C3AED] text-white",!Fr&&(m?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{je(Ze.date),Pt(false);},children:Ze.dayNum},Kt)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:de=>{de.stopPropagation(),Ae(!me),U(false);},className:d("p-1 rounded transition-colors",ct?"text-[#7C3AED] bg-[#7C3AED]/20":m?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:ct?jsx("div",{className:"w-4 h-4 rounded-full flex items-center justify-center text-white text-[8px] font-medium",style:{backgroundColor:t.availableUsers?.find(de=>de.id===ct)?.color||"#7C3AED"},children:t.availableUsers?.find(de=>de.id===ct)?.initials||t.availableUsers?.find(de=>de.id===ct)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:me&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:de=>de.stopPropagation(),children:[jsxs("button",{onClick:()=>{wt(null),Ae(false);},className:d("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",!ct&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:d("w-5 h-5 rounded-full flex items-center justify-center",m?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:m?"text-[#9CA3AF]":"text-gray-500",children:b==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(de=>jsxs("button",{onClick:()=>{wt(de.id),Ae(false);},className:d("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",ct===de.id&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-white text-[9px] font-medium",style:{backgroundColor:de.color||"#7C3AED"},children:de.initials||de.name?.slice(0,2).toUpperCase()}),jsx("span",{className:m?"text-white":"text-gray-900",children:de.name})]},de.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:d("px-3 py-2 text-xs",m?"text-[#6B7280]":"text-gray-400"),children:b==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(qe.trim()){let de=t.availableUsers?.find(xt=>xt.id===ct),ze=Fe||P.date;a.onTaskCreate?.({name:qe.trim(),startDate:ze,endDate:ze,priority:le,assignees:de?[de]:void 0}),tt(""),Je(void 0),wt(null),je(null),Be(null);}},disabled:!qe.trim(),className:d("px-2.5 py-1 rounded text-xs font-medium transition-colors",qe.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":m?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:b==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:d("text-sm font-medium",P.isToday?"text-[#3B82F6]":P.isCurrentMonth?m?"text-white":"text-gray-900":m?"text-[#6B7280]":"text-gray-400"),children:P.date.getDate()})]})]},O)})})]})}),jsx(AnimatePresence,{children:v&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>{I(null),Ce("");},className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:d("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",m?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:d("px-6 py-3 border-b flex items-center gap-3",m?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:d("w-4 h-4",m?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:d("text-xs px-2 py-0.5 rounded",m?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[b==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:d("text-xs font-mono",m?"text-[#6B7280]":"text-gray-400"),children:v.id.slice(0,8)}),jsxs("button",{className:d("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",m?"bg-purple-500/20 text-purple-400 hover:bg-purple-500/30":"bg-purple-100 text-purple-700 hover:bg-purple-200"),children:[jsx(Sparkles,{className:"w-3 h-3"}),"Ask AI"]})]}),jsx("div",{className:"flex-1"}),jsx("button",{className:d("p-1.5 rounded transition-colors",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:d("p-1.5 rounded transition-colors",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>{I(null),Ce("");},className:d("p-1.5 rounded transition-colors",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-5 h-5"})})]}),jsx("div",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("button",{onClick:()=>{let P=v.progress===100?0:100,Me={...v,progress:P,status:P===100?"completed":"todo"};I(Me),a.onTaskUpdate?.(Me);},className:d("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",v.progress===100?"bg-green-500 border-green-500":m?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:v.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:d("text-xl font-semibold flex-1",v.progress===100?"line-through text-[#6B7280]":m?"text-white":"text-gray-900"),children:v.name})]})}),jsxs("div",{className:"px-6 pb-6 flex-1 overflow-y-auto overflow-x-visible",children:[jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-5",children:[jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CheckCircle2,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{H(),M(!Ie);},className:d("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",v.progress===100||v.status==="completed"?"bg-green-500/20 text-green-400":v.progress&&v.progress>0||v.status==="in-progress"?"bg-blue-500/20 text-blue-400":m?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:v.progress===100||v.status==="completed"?b==="es"?"COMPLETADO":"DONE":v.progress&&v.progress>0||v.status==="in-progress"?b==="es"?"EN PROGRESO":"IN PROGRESS":b==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:Ie&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>M(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:b==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:b==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:b==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(P=>jsxs("button",{onClick:()=>Ye(P.id),className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",(v.status===P.id||P.id==="completed"&&v.progress===100||P.id==="in-progress"&&v.progress&&v.progress>0&&v.progress<100||P.id==="todo"&&(!v.progress||v.progress===0)&&v.status!=="in-progress"&&v.status!=="completed")&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",P.id==="completed"?"bg-green-500":P.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:m?"text-white":"text-gray-900",children:P.label})]},P.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{M(false),L(false),$(null),q(!V);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[v.assignees&&v.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[v.assignees.slice(0,3).map((P,O)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:P.color||"#8B5CF6"},title:P.name,children:P.initials||P.name.slice(0,2).toUpperCase()},O)),v.assignees.length>3&&jsxs("span",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:["+",v.assignees.length-3]})]}):jsx("span",{className:d("text-sm",m?"text-[#6B7280]":"text-gray-400"),children:b==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:d("w-3 h-3",m?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:V&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>q(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:t.availableUsers&&t.availableUsers.length>0?t.availableUsers.map(P=>{let O=v.assignees?.some(Me=>Me.name===P.name);return jsxs("button",{onClick:()=>{let Me=v.assignees||[],Xe;O?Xe=Me.filter(Lt=>Lt.name!==P.name):Xe=[...Me,{name:P.name,avatar:P.avatar,initials:P.initials||P.name.slice(0,2).toUpperCase(),color:P.color||"#8B5CF6"}],se("assignees",Xe);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",m?"hover:bg-white/5":"hover:bg-gray-50",O&&(m?"bg-white/5":"bg-gray-50")),children:[P.avatar?jsx("img",{src:P.avatar,alt:P.name,className:"w-6 h-6 rounded-full object-cover"}):jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:P.color||"#8B5CF6"},children:P.initials||P.name.slice(0,2).toUpperCase()}),jsx("span",{className:d("flex-1 text-left",m?"text-white":"text-gray-900"),children:P.name}),O&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},P.id||P.name)}):jsx("div",{className:d("px-3 py-4 text-sm text-center",m?"text-[#6B7280]":"text-gray-400"),children:b==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{$(W?null:"start"),te(v.startDate||new Date);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[v.startDate?.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(b==="es"?"Inicio":"Start"),jsx("span",{className:d("mx-1",m?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),v.endDate?.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(b==="es"?"Fin":"End"),(v.startDate||v.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:P=>{P.stopPropagation();}})]}),jsx(AnimatePresence,{children:W&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>$(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:d("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:P=>P.stopPropagation(),children:[jsxs("div",{className:d("w-44 py-2 border-r",m?"border-white/10":"border-gray-200"),children:[(()=>{let P=new Date,O=new Date(P);O.setDate(P.getDate()+1);let Me=new Date(P);Me.setDate(P.getDate()+((6-P.getDay()+7)%7||7));let Xe=new Date(P);Xe.setDate(P.getDate()+((1-P.getDay()+7)%7||7));let Lt=new Date(P);Lt.setDate(P.getDate()+(6-P.getDay()+7)%7+7);let de=new Date(P);de.setDate(P.getDate()+14);let ze=new Date(P);return ze.setDate(P.getDate()+28),[{label:b==="es"?"Hoy":"Today",date:P,display:P.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:b==="es"?"Ma\xF1ana":"Tomorrow",date:O,display:O.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:b==="es"?"Este fin de semana":"This weekend",date:Me,display:b==="es"?"s\xE1b.":"sat."},{label:b==="es"?"Pr\xF3xima semana":"Next week",date:Xe,display:b==="es"?"lun.":"mon."},{label:b==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:Lt,display:Lt.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:b==="es"?"2 semanas":"2 weeks",date:de,display:de.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:b==="es"?"4 semanas":"4 weeks",date:ze,display:ze.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ve,ft)=>jsxs("button",{className:d("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",m?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(W==="start"){let aa=v.endDate&&Ve.date>v.endDate?Ve.date:v.endDate;Ue(Ve.date,aa),$("end");}else {let aa=v.startDate&&Ve.date<v.startDate?Ve.date:v.startDate;Ue(aa,Ve.date),$(null);}},children:[jsx("span",{children:Ve.label}),jsx("span",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:Ve.display})]},ft))})(),jsx("div",{className:d("border-t mt-2 pt-2",m?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Ue(void 0,void 0),$(null);},className:d("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",m?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:b==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:d("text-xs mb-3 px-2 py-1 rounded",m?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:W==="start"?b==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":b==="es"?"\u{1F4C5} Selecciona fecha de fin":"\u{1F4C5} Select end date"}),jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:d("font-medium",m?"text-white":"text-gray-900"),children:j.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>te(new Date),className:d("p-1 rounded text-sm transition-colors",m?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:b==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>te(new Date(j.getFullYear(),j.getMonth()-1)),className:d("p-1 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>te(new Date(j.getFullYear(),j.getMonth()+1)),className:d("p-1 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:"w-4 h-4"})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:(b==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(P=>jsx("div",{className:d("w-8 h-8 flex items-center justify-center text-xs",m?"text-[#6B7280]":"text-gray-400"),children:P},P))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=j.getFullYear(),O=j.getMonth(),Me=new Date(P,O,1).getDay(),Xe=new Date(P,O+1,0).getDate(),Lt=new Date(P,O,0).getDate(),de=new Date,ze=[];for(let Ve=Me-1;Ve>=0;Ve--)ze.push({day:Lt-Ve,isCurrentMonth:false,date:new Date(P,O-1,Lt-Ve)});for(let Ve=1;Ve<=Xe;Ve++)ze.push({day:Ve,isCurrentMonth:true,date:new Date(P,O,Ve)});let xt=42-ze.length;for(let Ve=1;Ve<=xt;Ve++)ze.push({day:Ve,isCurrentMonth:false,date:new Date(P,O+1,Ve)});return ze.map((Ve,ft)=>{let aa=Ve.date.toDateString()===de.toDateString(),Ca=v.startDate?.toDateString()===Ve.date.toDateString(),jt=v.endDate?.toDateString()===Ve.date.toDateString(),Ze=Ca||jt,Kt=v.startDate&&v.endDate&&Ve.date>=v.startDate&&Ve.date<=v.endDate;return jsx("button",{className:d("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Ve.isCurrentMonth&&(m?"text-[#4B5563]":"text-gray-300"),Ve.isCurrentMonth&&(m?"text-white":"text-gray-900"),aa&&"ring-2 ring-[#3B82F6]",Ca&&"bg-[#3B82F6] text-white",jt&&!Ca&&"bg-[#7C3AED] text-white",Kt&&!Ze&&(m?"bg-[#7C3AED]/20":"bg-purple-100"),!Ze&&(m?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let la=new Date(Ve.date);if(W==="start"){let Fr=v.endDate&&la>v.endDate?la:v.endDate;Ue(la,Fr),$("end");}else {let Fr=v.startDate&&la<v.startDate?la:v.startDate;Ue(Fr,la),$(null);}},children:Ve.day},ft)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{H(),L(!R);},className:d("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",v.priority==="high"||v.priority==="urgent"?"bg-red-500/20 text-red-400":v.priority==="medium"?"bg-yellow-500/20 text-yellow-400":v.priority==="low"?"bg-green-500/20 text-green-400":m?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:v.priority?v.priority==="high"||v.priority==="urgent"?b==="es"?"Urgente":"Urgent":v.priority==="medium"?b==="es"?"Media":"Medium":b==="es"?"Baja":"Low":b==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:R&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>L(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:b==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:b==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:b==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:b==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:b==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(P=>jsxs("button",{onClick:()=>{se("priority",P.id),L(false);},className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",v.priority===P.id&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",P.color)}),jsx("span",{className:m?"text-white":"text-gray-900",children:P.label})]},P.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:d("text-sm",m?"text-white":"text-gray-900"),children:v.startDate&&v.endDate?`${Math.ceil((v.endDate.getTime()-v.startDate.getTime())/(1e3*60*60*24))} ${b==="es"?"d\xEDas":"days"}`:b==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:d("w-4 h-4 rounded-full border-2",m?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[z?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:v.progress||0,onChange:P=>{let O=parseInt(P.target.value),Me=v.status;O===100?Me="completed":O>0?Me="in-progress":Me="todo";let Xe={...v,progress:O,status:Me};I(Xe),a.onTaskUpdate?.(Xe);},onBlur:()=>ye(false),className:d("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",m?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>ye(true),className:d("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",m?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:d("h-full rounded-full transition-all",v.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${v.progress||0}%`}})}),jsxs("span",{className:d("text-sm font-medium min-w-[40px]",m?"text-white":"text-gray-900"),children:[v.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Etiquetas":"Tags"}),jsx(hr,{selectedTags:v.tags||[],availableTags:g,onChange:P=>{se("tags",P);},onCreateTag:i,theme:N})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:d("w-4 h-4 mt-1.5",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24 mt-1",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[v.dependencies&&v.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:v.dependencies.map(P=>{let O=e.find(Me=>Me.id===P);return jsxs("span",{className:d("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",m?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[O?.name||P.slice(0,8),jsx("button",{onClick:()=>{let Me=(v.dependencies||[]).filter(Xe=>Xe!==P);se("dependencies",Me);},className:d("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},P)})}),jsxs("button",{onClick:()=>{H(),_e(!st);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:st&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{_e(false),ke("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:d("p-2 border-b",m?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:ea,onChange:P=>ke(P.target.value),placeholder:b==="es"?"Buscar tarea...":"Search task...",className:d("w-full px-3 py-2 rounded-md text-sm outline-none",m?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400"),autoFocus:true})}),jsx("div",{className:"max-h-[240px] overflow-y-auto",children:e.length>0?e.filter(P=>P.id!==v.id).filter(P=>ea===""||P.name.toLowerCase().includes(ea.toLowerCase())).map(P=>{let O=v.dependencies?.includes(P.id);return jsxs("button",{onClick:()=>{let Me=v.dependencies||[],Xe;O?Xe=Me.filter(Lt=>Lt!==P.id):Xe=[...Me,P.id],se("dependencies",Xe);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",O&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:d("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",O?"bg-blue-500 border-blue-500":m?"border-white/30":"border-gray-300"),children:O&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:d("block truncate",m?"text-white":"text-gray-900"),children:P.name}),jsx("span",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:P.id.slice(0,8)})]})]},P.id)}):jsx("div",{className:d("px-3 py-4 text-sm text-center",m?"text-[#6B7280]":"text-gray-500"),children:b==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{H(),Ke(!be);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:v.color||"#6366F1"}}),jsx("span",{className:d("text-sm",m?"text-white":"text-gray-900"),children:yr.find(P=>P.value===v.color)?.name||(b==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:d("w-3 h-3",m?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:be&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Ke(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:yr.map(P=>{let O=v.color===P.value;return jsx("button",{onClick:()=>{se("color",P.value),Ke(false);},className:d("w-7 h-7 rounded-full flex items-center justify-center transition-all",O&&"ring-2 ring-offset-2",m?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:P.value,outlineColor:O?P.value:void 0},title:P.name,children:O&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},P.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:v.isMilestone||false,onChange:P=>se("isMilestone",P.target.checked),className:d("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",v.isMilestone?"bg-purple-500 border-purple-500":m?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:d("text-sm",m?"text-white":"text-gray-900"),children:b==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:d("text-sm font-semibold",m?"text-white":"text-gray-900"),children:b==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:v.description||"",onChange:P=>se("description",P.target.value),placeholder:b==="es"?"Agregar descripci\xF3n...":"Add description...",className:d("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",m?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400 focus:bg-gray-200")}),jsxs("button",{className:d("flex items-center gap-2 text-sm mt-2 transition-colors",m?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),b==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:b==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),b==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:b==="es"?"Agregar subtarea":"Add subtask"}),v.subtasks&&v.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:v.subtasks.map(P=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:d("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",P.progress===100?"bg-green-500 border-green-500":m?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:P.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:d("text-sm",P.progress===100?"line-through text-[#6B7280]":m?"text-white":"text-gray-900"),children:P.name})]},P.id))}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),b==="es"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:d("text-sm font-semibold",m?"text-white":"text-gray-900"),children:b==="es"?"Listas de control":"Checklists"}),jsx("button",{className:d("p-1 rounded transition-colors",m?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(ListChecks,{className:"w-4 h-4"}),b==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:d("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:[b==="es"?"Adjuntos":"Attachments",ta.length>0&&jsxs("span",{className:d("ml-2 text-xs font-normal",m?"text-[#6B7280]":"text-gray-400"),children:["(",ta.length,")"]})]}),ta.length>0&&jsx("div",{className:"space-y-2 mb-4",children:ta.map(P=>{let O=wa(P.type),Me=P.type.startsWith("image/");return jsxs("div",{className:d("flex items-center gap-3 p-2 rounded-lg group transition-colors",m?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[Me&&P.thumbnailUrl?jsx("img",{src:P.thumbnailUrl,alt:P.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:d("w-10 h-10 rounded flex items-center justify-center",m?"bg-white/10":"bg-gray-200"),children:jsx(O,{className:d("w-5 h-5",m?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:P.url,target:"_blank",rel:"noopener noreferrer",className:d("text-sm font-medium truncate block hover:underline",m?"text-white":"text-gray-900"),children:P.name}),jsx("p",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:Ar(P.size)})]}),a.onDeleteAttachment&&jsx("button",{onClick:()=>a.onDeleteAttachment?.(P.id),className:d("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",m?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:b==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},P.id)})}),jsxs("div",{onDragOver:Mt,onDragLeave:pt,onDrop:ie,className:d("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",ve?m?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":m?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",Le&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:We,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!a.onUploadAttachments||Le}),Le?jsxs(Fragment,{children:[jsx("div",{className:"w-6 h-6 mx-auto mb-2 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),jsx("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:d("w-6 h-6 mx-auto mb-2",ve?"text-blue-500":m?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:ve?b==="es"?"Suelta los archivos aqu\xED":"Drop files here":b==="es"?jsxs(Fragment,{children:["Suelta tus archivos aqu\xED o ",jsx("span",{className:"underline",children:"haz clic para subir"})]}):jsxs(Fragment,{children:["Drop your files here or ",jsx("span",{className:"underline",children:"click to upload"})]})}),!a.onUploadAttachments&&jsx("p",{className:d("text-xs mt-1",m?"text-[#6B7280]":"text-gray-400"),children:b==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:d("w-80 border-l flex flex-col",m?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:d("px-4 py-3 border-b",m?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:d("text-sm font-semibold",m?"text-white":"text-gray-900"),children:[b==="es"?"Actividad":"Activity",l&&l.length>0&&jsxs("span",{className:d("ml-2 text-xs font-normal",m?"text-[#6B7280]":"text-gray-400"),children:["(",l.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:l&&l.length>0?jsx("div",{className:"space-y-4",children:l.map(P=>{let O=(()=>{let Me=new Date,Xe=new Date(P.createdAt),Lt=Me.getTime()-Xe.getTime(),de=Math.floor(Lt/6e4),ze=Math.floor(de/60),xt=Math.floor(ze/24);return de<1?b==="es"?"ahora":"now":de<60?b==="es"?`hace ${de}m`:`${de}m ago`:ze<24?b==="es"?`hace ${ze}h`:`${ze}h ago`:b==="es"?`hace ${xt}d`:`${xt}d ago`})();return jsxs("div",{className:"flex gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:"#8B5CF6"},children:P.user?.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:d("text-sm font-medium",m?"text-white":"text-gray-900"),children:P.user?.name||(b==="es"?"Usuario":"User")}),jsx("span",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:O})]}),jsx("p",{className:d("text-sm break-words",m?"text-[#9CA3AF]":"text-gray-600"),children:P.content})]})]},P.id)})}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:d("w-10 h-10 mb-3",m?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:d("text-sm",m?"text-[#6B7280]":"text-gray-500"),children:b==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:d("p-4 border-t",m?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-start gap-2",children:[y&&jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:y.color||"#8B5CF6"},children:y.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:d("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",m?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:F,onChange:P=>Ce(P.target.value),onKeyDown:async P=>{if(P.key==="Enter"&&!P.shiftKey&&v&&F.trim()&&f){P.preventDefault(),Te(true);try{await f(v.id,F.trim()),Ce("");}finally{Te(false);}}},placeholder:b==="es"?"Escribe un comentario...":"Write a comment...",disabled:Z||!f,className:d("flex-1 bg-transparent text-sm outline-none",m?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(Z||!f)&&"opacity-50")}),jsx("button",{onClick:async()=>{if(v&&F.trim()&&f){Te(true);try{await f(v.id,F.trim()),Ce("");}finally{Te(false);}}},disabled:Z||!F.trim()||!f,className:d("p-1.5 rounded transition-colors",F.trim()&&f?"bg-blue-500 text-white hover:bg-blue-600":m?"text-[#6B7280]":"text-gray-400",Z&&"opacity-50 cursor-not-allowed"),children:Z?jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):jsx(Send,{className:"w-4 h-4"})})]})]})})]})]})]})}),jsx(AnimatePresence,{children:A&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>T(null),className:"fixed inset-0 bg-black/30 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:d("fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[320px] max-h-[400px] rounded-xl shadow-2xl z-50 overflow-hidden",m?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:d("px-4 py-3 border-b flex items-center justify-between",m?"border-white/10":"border-gray-200"),children:[jsx("span",{className:d("font-medium",m?"text-white":"text-gray-900"),children:A.date.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>T(null),className:d("p-1 rounded",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:"p-3 max-h-[320px] overflow-y-auto space-y-2",children:A.events.map(P=>jsxs("button",{onClick:()=>{T(null),I(P.task),C?.(P.task.id);},className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",m?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx(vp,{task:P.task}),jsx("span",{className:d("text-sm truncate flex-1",m?"text-white":"text-gray-900"),children:P.title}),P.task.priority==="high"||P.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},P.id))})]})]})})]})}var Cl={bgPrimary:"#0d1117",bgSecondary:"#161b22",bgHover:"#21262d",bgToday:"#1f6feb20",bgWeekend:"#161b2280",bgOtherMonth:"#0d111750",border:"#30363d",borderLight:"#21262d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#6e7681",textToday:"#58a6ff",accent:"#58a6ff",accentHover:"#79b8ff",accentLight:"#58a6ff20",statusTodo:"#8b949e",statusInProgress:"#f0883e",statusCompleted:"#3fb950",focusRing:"#58a6ff"},Tl={bgPrimary:"#ffffff",bgSecondary:"#f6f8fa",bgHover:"#f3f4f6",bgToday:"#dbeafe",bgWeekend:"#f9fafb",bgOtherMonth:"#f3f4f680",border:"#d0d7de",borderLight:"#e5e7eb",textPrimary:"#24292f",textSecondary:"#57606a",textMuted:"#8b949e",textToday:"#0969da",accent:"#0969da",accentHover:"#0550ae",accentLight:"#dbeafe",statusTodo:"#8b949e",statusInProgress:"#bf8700",statusCompleted:"#1a7f37",focusRing:"#0969da"},Nl={bgPrimary:"#1a1a2e",bgSecondary:"#16213e",bgHover:"#1f3460",bgToday:"#6366f120",bgWeekend:"#16213e80",bgOtherMonth:"#1a1a2e50",border:"#2a3f5f",borderLight:"#1f3460",textPrimary:"#e4e6eb",textSecondary:"#a8b2c1",textMuted:"#6b7280",textToday:"#818cf8",accent:"#6366f1",accentHover:"#818cf8",accentLight:"#6366f120",statusTodo:"#9ca3af",statusInProgress:"#fbbf24",statusCompleted:"#34d399",focusRing:"#6366f1"},vs={dark:Cl,light:Tl,neutral:Nl};function wp(e){return vs[e]||vs.dark}function Pv({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:n,className:c}){let[g,i]=useState(false),p=useMemo(()=>t.filter(y=>e.cardIds.includes(y.id)),[t,e.cardIds]),l=useMemo(()=>{let y=p.length,k=new Set(p.flatMap(b=>b.assignedUserIds||[])).size,C=p.map(b=>b.priority).filter(Boolean),h=new Set(p.flatMap(b=>b.labels||[])).size;return {totalCards:y,uniqueAssignees:k,priorities:C,labels:h}},[p]),f=()=>{o?.(e.id);};return jsxs("div",{className:d("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>i(true),onMouseLeave:()=>i(false),style:{"--stack-color":e.color||"var(--color-accent-primary)"},children:[jsxs("div",{className:"card-stack-header",onClick:f,children:[jsxs("div",{className:"card-stack-header-left",children:[jsx("button",{className:"card-stack-toggle","aria-label":e.isExpanded?"Collapse":"Expand",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:d("card-stack-chevron",e.isExpanded&&"expanded"),children:jsx("polyline",{points:"6 9 12 15 18 9"})})}),jsx("h3",{className:"card-stack-title",children:e.title}),jsx("div",{className:"card-stack-badge",children:l.totalCards}),jsxs("div",{className:"card-stack-strategy",children:[e.strategy==="ai-similarity"&&"\u2728 AI",e.strategy==="manual"&&"\u{1F464} Manual",e.strategy==="labels"&&"\u{1F3F7}\uFE0F Labels",e.strategy==="assignee"&&"\u{1F465} Assignee",e.strategy==="priority"&&"\u{1F3AF} Priority",e.strategy==="epic"&&"\u{1F4DA} Epic"]})]}),g&&jsx("div",{className:"card-stack-actions",children:jsx("button",{className:"card-stack-action",onClick:y=>{y.stopPropagation(),n?.(e.id);},"aria-label":"Delete stack",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})})]}),!e.isExpanded&&jsxs("div",{className:"card-stack-summary",children:[jsxs("div",{className:"card-stack-summary-item",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),jsxs("span",{children:[l.uniqueAssignees," assignees"]})]}),l.labels>0&&jsxs("div",{className:"card-stack-summary-item",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsxs("span",{children:[l.labels," labels"]})]}),e.confidence&&jsx("div",{className:"card-stack-summary-item",children:jsxs("span",{className:"card-stack-confidence",children:[Math.round(e.confidence*100),"% match"]})})]}),e.isExpanded&&jsx("div",{className:"card-stack-content",children:p.length===0?jsxs("div",{className:"card-stack-empty",children:[jsx("p",{children:"No cards in this stack"}),jsx("span",{children:"Drag cards here or delete this stack"})]}):jsx("div",{className:"card-stack-cards",children:p.map(y=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(y),children:a(y)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(y),children:[jsx("h4",{children:y.title}),y.description&&jsxs("p",{children:[y.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:k=>{k.stopPropagation(),s?.(e.id,y.id);},"aria-label":"Remove from stack",children:jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},y.id))})})]})}var Tp={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function mn(e){switch(e.type){case "created":return "Created card";case "status_changed":return `Changed status from "${e.changes.status?.from}" to "${e.changes.status?.to}"`;case "assignee_changed":return "Changed assignee";case "priority_changed":return `Changed priority from ${e.changes.priority?.from} to ${e.changes.priority?.to}`;case "moved":return `Moved from ${e.metadata?.fromColumn||"unknown"} to ${e.metadata?.toColumn||"unknown"}`;case "title_updated":return "Updated title";case "description_updated":return "Updated description";case "dates_changed":return "Changed dates";case "labels_changed":return "Updated labels";case "dependency_added":return "Added dependency";case "dependency_removed":return "Removed dependency";case "comment_added":return "Added comment";case "archived":return "Archived card";case "restored":return "Restored card";default:return "Updated card"}}function pn(e){return {created:"\u2728",status_changed:"\u{1F504}",assignee_changed:"\u{1F464}",priority_changed:"\u{1F3AF}",moved:"\u27A1\uFE0F",title_updated:"\u270F\uFE0F",description_updated:"\u{1F4DD}",dates_changed:"\u{1F4C5}",labels_changed:"\u{1F3F7}\uFE0F",dependency_added:"\u{1F517}",dependency_removed:"\u26D3\uFE0F\u200D\u{1F4A5}",comment_added:"\u{1F4AC}",archived:"\u{1F4E6}",restored:"\u267B\uFE0F"}[e]||"\u{1F4CC}"}function Np(e){return {created:"#10b981",status_changed:"#3b82f6",assignee_changed:"#8b5cf6",priority_changed:"#f59e0b",moved:"#06b6d4",title_updated:"#6366f1",description_updated:"#6366f1",dates_changed:"#ec4899",labels_changed:"#14b8a6",dependency_added:"#a855f7",dependency_removed:"#ef4444",comment_added:"#84cc16",archived:"#6b7280",restored:"#10b981"}[e]||"#6b7280"}function Dp({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:n,className:c}){let g=useMemo(()=>({...Tp,...n}),[n]),[i,p]=useState(new Set),l=useRef(null),f=useMemo(()=>{if(!g.groupByDay)return [{date:null,events:e}];let u=new Map;return e.forEach(x=>{let m=x.timestamp.toISOString().split("T")[0],N=u.get(m);N?N.push(x):u.set(m,[x]);}),Array.from(u.entries()).sort((x,m)=>m[0].localeCompare(x[0])).map(([x,m])=>({date:new Date(x),events:m.sort((N,w)=>w.timestamp.getTime()-N.timestamp.getTime())}))},[e,g.groupByDay]),{uniqueUsers:y,uniqueTypes:k}=useMemo(()=>{let u=new Set,x=new Set;return e.forEach(m=>{u.add(m.userId),x.add(m.type);}),{uniqueUsers:Array.from(u),uniqueTypes:Array.from(x)}},[e]),C=u=>{p(x=>{let m=new Set(x);return m.has(u)?m.delete(u):m.add(u),m});},h=u=>{let m=new Date().getTime()-u.getTime(),N=Math.floor(m/6e4),w=Math.floor(m/36e5),B=Math.floor(m/864e5);return N<1?"just now":N<60?`${N}m ago`:w<24?`${w}h ago`:B<7?`${B}d ago`:u.toLocaleDateString()},b=useMemo(()=>{let u=0;return t.types&&t.types.length>0&&u++,t.users&&t.users.length>0&&u++,t.dateRange&&u++,t.searchTerm&&u++,u},[t]);return useEffect(()=>{if(s&&l.current){let u=l.current.querySelector(`[data-event-id="${s}"]`);u&&u.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:d("history-timeline-empty",c),children:[jsx("div",{className:"history-timeline-empty-icon",children:"\u{1F4DC}"}),jsx("p",{className:"history-timeline-empty-text",children:"No history events yet"}),jsx("p",{className:"history-timeline-empty-subtext",children:"Changes to this card will appear here"})]}):jsxs("div",{className:d("history-timeline",g.compact&&"compact",c),children:[jsxs("div",{className:"history-timeline-filters",children:[jsxs("div",{className:"history-timeline-filter-group",children:[jsxs("select",{className:"history-timeline-filter-select",value:t.types?.[0]||"",onChange:u=>{let x=u.target.value;a({...t,types:x?[x]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),k.map(u=>jsxs("option",{value:u,children:[pn(u)," ",u.replace("_"," ")]},u))]}),y.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:u=>{let x=u.target.value;a({...t,users:x?[x]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),y.map(u=>jsx("option",{value:u,children:u},u))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:u=>a({...t,searchTerm:u.target.value})})]}),b>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",b,")"]})]}),jsx("div",{className:"history-timeline-container",ref:l,children:f.map(u=>jsxs("div",{className:"history-timeline-group",children:[g.groupByDay&&u.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:u.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[u.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:u.events.map((x,m)=>{let N=i.has(x.id),w=s===x.id,B=Np(x.type);return jsxs("div",{"data-event-id":x.id,className:d("history-timeline-event",N&&"expanded",w&&"selected"),onClick:()=>o?.(x),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:B},children:g.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:pn(x.type)})}),m<u.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:B}})]}),jsxs("div",{className:"history-timeline-event-content",children:[jsxs("div",{className:"history-timeline-event-header",children:[jsxs("div",{className:"history-timeline-event-header-left",children:[g.showAvatars&&x.userAvatar&&jsx("img",{src:x.userAvatar,alt:x.userName||x.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:x.userName||x.userId}),jsx("span",{className:"history-timeline-event-action",children:mn(x)})]})]}),jsx("div",{className:"history-timeline-event-time",children:g.useRelativeTime?h(x.timestamp):x.timestamp.toLocaleString()})]}),Object.keys(x.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:v=>{v.stopPropagation(),C(x.id);},children:[N?"\u25BC":"\u25B6"," Show changes"]}),N&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(x.changes).map(([v,I])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[v,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(I.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(I.to)})]})]},v)),x.metadata&&Object.keys(x.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(x.metadata).map(([v,I])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[v,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(I)})]},v))]})]})]})]},x.id)})})]},u.date?.toISOString()||"all"))})]})}function Ep({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:n,onGoToEvent:c,onSpeedChange:g,className:i}){let p=[.5,1,1.5,2,3],l=useMemo(()=>!e||t.length===0?null:t[e.currentIndex],[e,t]),f=useMemo(()=>!e||e.totalEvents===0?0:e.currentIndex/(e.totalEvents-1)*100,[e]);return t.length===0?jsxs("div",{className:d("history-replay-empty",i),children:[jsx("div",{className:"history-replay-empty-icon",children:"\u23F3"}),jsx("p",{className:"history-replay-empty-text",children:"No history to replay"})]}):e?jsxs("div",{className:d("history-replay",i),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:l&&pn(l.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:l&&mn(l)}),jsxs("div",{className:"history-replay-event-meta",children:[jsxs("span",{className:"history-replay-event-index",children:["Event ",e.currentIndex+1," of ",e.totalEvents]}),jsx("span",{className:"history-replay-event-time",children:l&&l.timestamp.toLocaleString()})]})]})]}),jsxs("div",{className:"history-replay-progress-container",children:[jsx("input",{type:"range",className:"history-replay-progress-slider",min:"0",max:e.totalEvents-1,value:e.currentIndex,onChange:y=>c(parseInt(y.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${f}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((y,k)=>jsx("div",{className:d("history-replay-progress-marker",k===e.currentIndex&&"active"),style:{left:`${k/(e.totalEvents-1)*100}%`},onClick:()=>c(k),title:mn(y)},y.id))})]}),jsxs("div",{className:"history-replay-controls",children:[jsx("button",{className:"history-replay-control-btn",onClick:s,disabled:!e.canGoBack,title:"Previous event (\u2190)",children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polygon",{points:"19 20 9 12 19 4 19 20"}),jsx("line",{x1:"5",y1:"19",x2:"5",y2:"5"})]})}),jsx("button",{className:"history-replay-control-btn history-replay-control-play",onClick:o,title:e.isPlaying?"Pause (Space)":"Play (Space)",children:e.isPlaying?jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]}):jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})}),jsx("button",{className:"history-replay-control-btn",onClick:n,disabled:!e.canGoForward,title:"Next event (\u2192)",children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polygon",{points:"5 4 15 12 5 20 5 4"}),jsx("line",{x1:"19",y1:"5",x2:"19",y2:"19"})]})}),jsxs("div",{className:"history-replay-speed",children:[jsx("label",{className:"history-replay-speed-label",children:"Speed:"}),jsx("div",{className:"history-replay-speed-buttons",children:p.map(y=>jsxs("button",{className:d("history-replay-speed-btn",e.speed===y&&"active"),onClick:()=>g(y),children:[y,"x"]},y))})]}),jsx("button",{className:"history-replay-control-btn history-replay-stop",onClick:r,title:"Stop replay (Esc)",children:jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:jsx("rect",{x:"6",y:"6",width:"12",height:"12"})})})]}),jsxs("div",{className:"history-replay-shortcuts",children:[jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"Space"})," Play/Pause"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"\u2190"})," Previous"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"\u2192"})," Next"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"Esc"})," Stop"]})]}),jsxs("div",{className:"history-replay-card-preview",children:[jsxs("div",{className:"history-replay-card-preview-header",children:[jsx("span",{className:"history-replay-card-preview-title",children:"Card State at This Point"}),jsx("span",{className:"history-replay-card-preview-time",children:l&&l.timestamp.toLocaleDateString()})]}),jsxs("div",{className:"history-replay-card-preview-content",children:[jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Title:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.title})]}),e.cardState.description&&jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Description:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.description})]}),jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Priority:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.priority||"None"})]}),e.cardState.labels&&e.cardState.labels.length>0&&jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Labels:"}),jsx("div",{className:"history-replay-card-preview-labels",children:e.cardState.labels.map(y=>jsx("span",{className:"history-replay-card-preview-label-tag",children:y},y))})]})]})]})]}):jsxs("div",{className:d("history-replay-start",i),children:[jsxs("button",{className:"history-replay-start-button",onClick:a,children:[jsx("svg",{className:"history-replay-start-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),jsx("span",{children:"Start Time Travel"})]}),jsxs("p",{className:"history-replay-start-hint",children:["Replay ",t.length," events from this card's history"]})]})}function Dl(e){return {blocks:"#ef4444",blocked_by:"#dc2626",depends_on:"#f59e0b",required_by:"#d97706",relates_to:"#6b7280",duplicates:"#8b5cf6",parent_of:"#3b82f6",child_of:"#2563eb",similar_to:"#10b981"}[e]||"#6b7280"}function Sl(e){return {blocks:"Blocks",blocked_by:"Blocked by",depends_on:"Depends on",required_by:"Required by",relates_to:"Relates to",duplicates:"Duplicates",parent_of:"Parent of",child_of:"Child of",similar_to:"Similar to"}[e]||e}function Pp(e){return {blocks:"\u{1F6AB}",blocked_by:"\u26D4",depends_on:"\u{1F517}",required_by:"\u{1F4CC}",relates_to:"\u{1F504}",duplicates:"\u{1F4CB}",parent_of:"\u{1F4C2}",child_of:"\u{1F4C4}",similar_to:"\u{1F50D}"}[e]||"\u{1F517}"}function Mp(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function Bv(e,t,a,r,o,s=100){let n=e.map(g=>({...g,x:g.x??a/2+Math.random()*100-50,y:g.y??r/2+Math.random()*100-50,vx:0,vy:0})),c=new Map(n.map(g=>[g.id,g]));for(let g=0;g<s;g++){let i=1-g/s;n.forEach(p=>{let l=a/2,f=r/2;p.vx+=(l-p.x)*o.centerForce*i,p.vy+=(f-p.y)*o.centerForce*i,n.forEach(y=>{if(p.id===y.id)return;let k=p.x-y.x,C=p.y-y.y,h=Math.sqrt(k*k+C*C)||1,b=o.chargeStrength*i/(h*h);p.vx+=k/h*b,p.vy+=C/h*b;});}),t.forEach(p=>{let l=c.get(typeof p.source=="string"?p.source:p.source.id),f=c.get(typeof p.target=="string"?p.target:p.target.id);if(!l||!f)return;let y=f.x-l.x,k=f.y-l.y,C=Math.sqrt(y*y+k*k)||1,h=(C-o.linkDistance)/C*o.forceStrength*i;l.vx+=y*h,l.vy+=k*h,f.vx-=y*h,f.vy-=k*h;}),n.forEach(p=>{p.fx!==null&&p.fx!==void 0?(p.x=p.fx,p.vx=0):p.x+=p.vx,p.fy!==null&&p.fy!==void 0?(p.y=p.fy,p.vy=0):p.y+=p.vy,p.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,p.x)),p.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,p.y)),p.vx*=.9,p.vy*=.9;});}return n}function Ap({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:n,onInteraction:c,className:g}){let i=useRef(null),[p,l]=useState([]),[f,y]=useState(null),[k,C]=useState(null),[h,b]=useState(null),[u,x]=useState(1),[m,N]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let $=Bv(e,t,a.width,a.height,a,150);l($);},[e,t,a]);let w=useCallback(($,j)=>{a.enableDragging&&(j.stopPropagation(),y($));},[a.enableDragging]),B=useCallback($=>{if(!f||!i.current)return;let te=i.current.getBoundingClientRect(),oe=($.clientX-te.left-m.x)/u,re=($.clientY-te.top-m.y)/u;l(ge=>ge.map(fe=>fe.id===f?{...fe,x:oe,y:re,fx:oe,fy:re}:fe));},[f,u,m]),v=useCallback(()=>{y(null);},[]),I=useCallback(($,j)=>{j.stopPropagation(),c?.({type:"node-click",node:$,position:{x:j.clientX,y:j.clientY}});},[c]),A=useCallback(($,j)=>{j.stopPropagation(),c?.({type:"edge-click",edge:$,position:{x:j.clientX,y:j.clientY}});},[c]),T=useCallback($=>{let j=p.find(te=>te.id===$);return j?{x:j.x,y:j.y}:{x:0,y:0}},[p]),W=useCallback($=>{if($.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return $.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let j=$.card.priority;return j==="URGENT"?"#ef4444":j==="HIGH"?"#f59e0b":j==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return $.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:d("relationships-graph-empty",g),children:[jsx("div",{className:"relationships-graph-empty-icon",children:"\u{1F517}"}),jsx("p",{className:"relationships-graph-empty-text",children:"No relationships to display"}),jsx("p",{className:"relationships-graph-empty-subtext",children:"Add relationships between cards to see the graph"})]}):jsxs("div",{className:d("relationships-graph",g),children:[jsxs("div",{className:"relationships-graph-controls",children:[jsxs("div",{className:"relationships-graph-stats",children:[jsxs("span",{className:"relationships-graph-stat",children:[jsx("span",{className:"relationships-graph-stat-value",children:n.totalNodes}),jsx("span",{className:"relationships-graph-stat-label",children:"Cards"})]}),jsxs("span",{className:"relationships-graph-stat",children:[jsx("span",{className:"relationships-graph-stat-value",children:n.totalEdges}),jsx("span",{className:"relationships-graph-stat-label",children:"Relations"})]}),s&&jsxs("span",{className:"relationships-graph-stat relationships-graph-stat-critical",children:[jsx("span",{className:"relationships-graph-stat-value",children:s.cardIds.length}),jsx("span",{className:"relationships-graph-stat-label",children:"Critical Path"})]})]}),a.enableZoom&&jsxs("div",{className:"relationships-graph-zoom-controls",children:[jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>x($=>Math.min($+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(u*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>x($=>Math.max($-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{x(1),N({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map($=>$.type))).map($=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:Dl($)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[Pp($)," ",Sl($)]})]},$))}),jsxs("svg",{ref:i,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:B,onMouseUp:v,onMouseLeave:v,children:[jsxs("g",{transform:`translate(${m.x}, ${m.y}) scale(${u})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map($=>{let j=T(typeof $.source=="string"?$.source:$.source.id),te=T(typeof $.target=="string"?$.target:$.target.id),oe=Mp($.type),re=h===$.id,ge=$.onCriticalPath;return jsxs("g",{className:d("relationships-graph-edge",re&&"hovered",ge&&"critical"),onMouseEnter:()=>b($.id),onMouseLeave:()=>b(null),onClick:fe=>A($,fe),children:[jsx("line",{x1:j.x,y1:j.y,x2:te.x,y2:te.y,stroke:Dl($.type),strokeWidth:ge?a.edgeWidth*2:a.edgeWidth,strokeOpacity:re?1:.6,markerEnd:oe?"url(#arrowhead)":void 0}),a.showEdgeLabels&&re&&jsx("text",{x:(j.x+te.x)/2,y:(j.y+te.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:Sl($.type)})]},$.id)})}),jsx("g",{className:"relationships-graph-nodes",children:p.map($=>{let j=k===$.id,te=$.onCriticalPath;return jsxs("g",{className:d("relationships-graph-node",j&&"hovered",te&&"critical"),transform:`translate(${$.x}, ${$.y})`,onMouseDown:oe=>w($.id,oe),onMouseEnter:()=>C($.id),onMouseLeave:()=>C(null),onClick:oe=>I($,oe),children:[jsx("circle",{r:te?a.nodeSize*1.2:a.nodeSize,fill:W($),stroke:te?"#fbbf24":"#ffffff",strokeWidth:te?3:2,opacity:j?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:$.card.title.length>20?$.card.title.substring(0,20)+"...":$.card.title})]},$.id)})})]}),jsx("defs",{children:jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"10",refX:"9",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#6b7280"})})})]})]})}function Ip({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,n]=useState(""),[c,g]=useState(false),[i,p]=useState(null),[l,f]=useState(null),y=useRef(null),k=c||o;useEffect(()=>{e&&y.current&&y.current.focus();},[e]),useEffect(()=>{let u=x=>{x.key==="Escape"&&!k&&C();};if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,k]);let C=()=>{k||(n(""),p(null),f(null),t());},h=async()=>{if(!(!s.trim()||k)){g(true),p(null),f(null);try{let u=await r(s.trim());f(u);}catch(u){p(u instanceof Error?u.message:"Failed to generate plan");}finally{g(false);}}},b=()=>{l&&(a(l),C());};return e?jsxs(bt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:C}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-2xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:u=>u.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-blue-400",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Generate Project Plan with AI"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Describe your project and let AI create a complete Kanban board"})]}),jsx("button",{onClick:C,disabled:k,className:"text-white/60 hover:text-white transition-colors disabled:opacity-50",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:l?jsx(Fragment,{children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M4 10L8 14L16 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-semibold",children:"Plan Generated Successfully!"})]}),l.explanation&&jsx("div",{className:"p-4 rounded-lg bg-blue-500/10 border border-blue-500/30",children:jsx("p",{className:"text-sm text-white/90",children:l.explanation})}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Columns (",l.columns.length,")"]}),jsx("div",{className:"flex gap-2 flex-wrap",children:l.columns.map((u,x)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:u.title},x))})]}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Tasks (",l.cards.length,")"]}),jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[l.cards.slice(0,10).map((u,x)=>jsx("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10",children:jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex-1",children:[jsx("p",{className:"text-sm font-medium text-white/90",children:u.title}),u.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:u.description})]}),u.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${u.priority==="URGENT"?"bg-red-500/20 text-red-400":u.priority==="HIGH"?"bg-orange-500/20 text-orange-400":u.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:u.priority})]})},x)),l.cards.length>10&&jsxs("p",{className:"text-xs text-white/50 text-center py-2",children:["+",l.cards.length-10," more tasks..."]})]})]})]})}):jsxs(Fragment,{children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Project Description"}),jsx("textarea",{ref:y,value:s,onChange:u=>n(u.target.value),placeholder:"Example: Build a mobile app for tracking fitness goals with user authentication, workout logging, progress charts, and social features...",className:"w-full h-32 px-4 py-3 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/40 outline-none focus:border-blue-500/50 transition-all resize-none",disabled:k}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),i&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:i}),jsxs("div",{className:"border-t border-white/10 pt-4",children:[jsx("p",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider mb-3",children:"Example Prompts"}),jsx("div",{className:"space-y-2",children:["Build an e-commerce platform with product catalog, shopping cart, payment integration, and order tracking","Create a task management app with team collaboration, real-time updates, file attachments, and notifications","Develop a blog platform with markdown editor, SEO optimization, comments system, and analytics dashboard"].map((u,x)=>jsx("button",{onClick:()=>n(u),disabled:k,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-all border border-white/10 hover:border-white/20 disabled:opacity-50",children:u},x))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:k&&jsxs("div",{className:"flex items-center gap-2 text-blue-400 text-sm",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),jsx("span",{children:"Generating with AI..."})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:C,disabled:k,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80 disabled:opacity-50",children:"Cancel"}),l?jsx("button",{onClick:b,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Plan to Board"}):jsx("button",{onClick:h,disabled:!s.trim()||k,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#ffffff"},children:k?"Generating...":"Generate Plan"})]})]})]})})]}):null}var El={"gpt-4-turbo":{provider:"openai",name:"GPT-4 Turbo",contextWindow:128e3,costPer1kInput:.01,costPer1kOutput:.03,supportsVision:true,supportsJSON:true},"gpt-4":{provider:"openai",name:"GPT-4",contextWindow:8192,costPer1kInput:.03,costPer1kOutput:.06,supportsVision:false,supportsJSON:true},"gpt-3.5-turbo":{provider:"openai",name:"GPT-3.5 Turbo",contextWindow:16385,costPer1kInput:5e-4,costPer1kOutput:.0015,supportsVision:false,supportsJSON:true},"claude-3-5-sonnet-20241022":{provider:"anthropic",name:"Claude 3.5 Sonnet",contextWindow:2e5,costPer1kInput:.003,costPer1kOutput:.015,supportsVision:true,supportsJSON:true},"claude-3-opus-20240229":{provider:"anthropic",name:"Claude 3 Opus",contextWindow:2e5,costPer1kInput:.015,costPer1kOutput:.075,supportsVision:true,supportsJSON:true},"claude-3-haiku-20240307":{provider:"anthropic",name:"Claude 3 Haiku",contextWindow:2e5,costPer1kInput:25e-5,costPer1kOutput:.00125,supportsVision:true,supportsJSON:true}};var Ov={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},$v={generatePlan:{enabled:true,minPlanTier:"hobby",estimatedTokens:2e3},predictRisks:{enabled:true,minPlanTier:"pro",estimatedTokens:1500},suggestAssignee:{enabled:true,minPlanTier:"hobby",estimatedTokens:800},generateReport:{enabled:true,minPlanTier:"enterprise",estimatedTokens:3e3},generateSubtasks:{enabled:true,minPlanTier:"hobby",estimatedTokens:1e3}};function Uv(e,t,a){let r=El[e];if(!r)throw new Error(`Unknown model: ${e}`);let o=t/1e3*r.costPer1kInput,s=a/1e3*r.costPer1kOutput;return o+s}function un(e){return `$${e.toFixed(4)}`}var Pl=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=Uv(t.model,t.inputTokens,t.outputTokens),r={...t,id:`op_${Date.now()}_${Math.random().toString(36).substring(7)}`,timestamp:new Date,cost:a};return this.operations.push(r),this.listeners.forEach(o=>o(r)),this.operations.length>1e3&&(this.operations=this.operations.slice(-1e3)),r}getStats(t){let a=this.operations;t&&(a=a.filter(l=>l.timestamp>=t.start&&l.timestamp<=t.end));let r=a.length,o=a.reduce((l,f)=>l+f.cost,0),s=a.reduce((l,f)=>l+f.inputTokens,0),n=a.reduce((l,f)=>l+f.outputTokens,0),c=a.filter(l=>l.success),g=a.reduce((l,f)=>l+f.duration,0),i={},p={};return a.forEach(l=>{i[l.feature]=(i[l.feature]||0)+1,p[l.feature]=(p[l.feature]||0)+l.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:n,operationsByFeature:i,costsByFeature:p,averageDuration:r>0?g/r:0,successRate:r>0?c.length/r:0}}getRecentOperations(t=10){return this.operations.slice(-t).reverse()}checkLimit(t,a="month"){let o={hobby:{month:50,day:5},pro:{month:500,day:50},enterprise:{month:2e3,day:200}}[t][a],s=new Date,n=new Date;a==="month"?n.setMonth(s.getMonth()-1):n.setDate(s.getDate()-1);let c=this.operations.filter(p=>p.timestamp>=n).length,g=Math.max(0,o-c),i=c/o*100;return {used:c,limit:o,remaining:g,percentUsed:i,isExceeded:c>=o}}subscribe(t){return this.listeners.push(t),()=>{let a=this.listeners.indexOf(t);a>-1&&this.listeners.splice(a,1);}}clear(){this.operations=[];}export(){return JSON.stringify(this.operations,null,2)}},bo=new Pl;function Op({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(bo.getStats()),[s,n]=useState(bo.checkLimit(a));if(useEffect(()=>{if(!e)return;let g=setInterval(()=>{o(bo.getStats()),n(bo.checkLimit(a));},1e3);return ()=>clearInterval(g)},[e,a]),useEffect(()=>{let g=i=>{i.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,t]),!e)return null;let c=bo.getRecentOperations(5);return jsxs(bt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:t}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-3xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:g=>g.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("h2",{className:"text-xl font-bold text-white",children:"AI Usage Dashboard"}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Monitor your AI consumption and costs"})]}),jsx("button",{onClick:t,className:"text-white/60 hover:text-white transition-colors",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-blue-500/10 to-purple-500/10 border border-blue-500/30",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("span",{className:"text-sm font-semibold text-white/90",children:["Monthly Usage (",a.toUpperCase(),")"]}),jsxs("span",{className:"text-sm font-bold text-white",children:[s.used," / ",s.limit]})]}),jsx("div",{className:"w-full h-2 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full transition-all",style:{width:`${Math.min(100,s.percentUsed)}%`,background:s.percentUsed>90?"#EF4444":s.percentUsed>70?"#F59E0B":"#10B981"}})}),jsxs("p",{className:"text-xs text-white/60 mt-2",children:[s.remaining," operations remaining this month"]})]}),jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Total Cost"}),jsx("p",{className:"text-2xl font-bold text-green-400 mt-1",children:un(r.totalCost)})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Operations"}),jsx("p",{className:"text-2xl font-bold text-blue-400 mt-1",children:r.totalOperations})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Tokens Used"}),jsx("p",{className:"text-2xl font-bold text-purple-400 mt-1",children:(r.totalInputTokens+r.totalOutputTokens).toLocaleString()}),jsxs("p",{className:"text-xs text-white/50 mt-1",children:[r.totalInputTokens.toLocaleString()," in /"," ",r.totalOutputTokens.toLocaleString()," out"]})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Success Rate"}),jsxs("p",{className:"text-2xl font-bold text-green-400 mt-1",children:[(r.successRate*100).toFixed(1),"%"]}),jsxs("p",{className:"text-xs text-white/50 mt-1",children:["Avg: ",r.averageDuration.toFixed(0),"ms"]})]})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Usage by Feature"}),jsx("div",{className:"space-y-2",children:Object.entries(r.operationsByFeature).map(([g,i])=>{let p=r.costsByFeature[g]||0,l=r.totalOperations>0?i/r.totalOperations*100:0;return jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("span",{className:"text-sm font-medium text-white/90 capitalize",children:g.replace(/([A-Z])/g," $1").trim()}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[i," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:un(p)})]})]}),jsx("div",{className:"w-full h-1.5 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500",style:{width:`${l}%`}})})]},g)})})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Recent Operations"}),c.length===0?jsx("p",{className:"text-sm text-white/50 text-center py-8",children:"No operations yet. Start using AI features!"}):jsx("div",{className:"space-y-2",children:c.map(g=>jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("p",{className:"text-sm font-medium text-white/90 capitalize",children:g.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(g.timestamp).toLocaleTimeString()," \u2022"," ",g.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[g.inputTokens+g.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:un(g.cost)}),jsx("div",{className:`w-2 h-2 rounded-full ${g.success?"bg-green-400":"bg-red-400"}`})]})]},g.id))})]})]}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("p",{className:"text-xs text-white/50",children:"Costs are estimates. Actual API charges may vary."}),jsx("button",{onClick:t,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80",children:"Close"})]})]})})]})}function zp({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[n,c]=useState(""),[g,i]=useState(""),[p,l]=useState(""),[f,y]=useState(false),[k,C]=useState(null),[h,b]=useState(null),[u,x]=useState(null),m=useRef(null),N=f||o;useEffect(()=>{e&&m.current&&m.current.focus();},[e]),useEffect(()=>{let A=T=>{T.key==="Escape"&&!N&&w();};if(e)return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[e,N]);let w=()=>{N||(c(""),i(""),l(""),C(null),b(null),x(null),t());},B=async()=>{if(!(!n.trim()||N)){y(true),C(null),b(null),x(null);try{let A=await r({prompt:n.trim(),projectName:s||"Mi Proyecto",startDate:g||void 0,endDate:p||void 0});b(A.tasks.tasks),x({from_cache:A.from_cache,tokens_used:A.tokens_used,mock_mode:A.mock_mode,similarity:A.similarity,tokens_saved:A.tokens_saved});}catch(A){C(A instanceof Error?A.message:"Failed to generate tasks");}finally{y(false);}}},v=()=>{h&&(a(h),w());};if(!e)return null;let I=u?.similarity?((u.similarity||0)*100).toFixed(0):"0";return jsxs(bt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:w}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-3xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:A=>A.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-blue-400",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"9",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"14",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"19",width:"18",height:"2",rx:"1",fill:"currentColor"})]}),"Generate Gantt Tasks with AI"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Describe your project and let AI create a complete task timeline"})]}),jsx("button",{onClick:w,disabled:N,className:"text-white/60 hover:text-white transition-colors disabled:opacity-50",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:h?jsx(Fragment,{children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M4 10L8 14L16 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-semibold",children:"Tasks Generated Successfully!"})]}),jsxs("div",{className:"flex flex-wrap gap-2",children:[u?.mock_mode&&jsx("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-yellow-500/20 text-yellow-400 border border-yellow-500/30",children:"Mock Mode"}),u?.from_cache?jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-blue-500/20 text-blue-400 border border-blue-500/30",children:["From Cache (",I,"% similar)"]}):jsx("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-green-500/20 text-green-400 border border-green-500/30",children:"AI Generated"}),jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-purple-500/20 text-purple-400 border border-purple-500/30",children:[u?.tokens_used||0," tokens"]}),u?.tokens_saved&&jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-indigo-500/20 text-indigo-400 border border-indigo-500/30",children:[u.tokens_saved," tokens saved"]}),jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-pink-500/20 text-pink-400 border border-pink-500/30",children:[h.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:h.map((A,T)=>jsx("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 hover:bg-white/10 transition-colors",children:jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex-1",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsxs("span",{className:"text-xs text-white/50",children:["#",T+1]}),jsx("p",{className:"text-sm font-medium text-white/90",children:A.name})]}),jsxs("div",{className:"flex items-center gap-3 text-xs text-white/60",children:[jsxs("span",{className:"flex items-center gap-1",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-white/40",children:[jsx("rect",{x:"1",y:"2",width:"10",height:"8",rx:"1",stroke:"currentColor"}),jsx("path",{d:"M1 4h10",stroke:"currentColor"})]}),A.start," \u2192 ",A.end]}),jsxs("span",{children:[A.duration," days"]}),A.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",A.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${A.priority==="high"?"bg-red-500/20 text-red-400":A.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:A.priority})]})},A.id))})]})}):jsxs(Fragment,{children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Project Description *"}),jsx("textarea",{ref:m,value:n,onChange:A=>c(A.target.value),placeholder:"Example: Build a mobile app for tracking fitness goals with user authentication, workout logging, progress charts, and social features...",className:"w-full h-32 px-4 py-3 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/40 outline-none focus:border-blue-500/50 transition-all resize-none",disabled:N}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Start Date (Optional)"}),jsx("input",{type:"date",value:g,onChange:A=>i(A.target.value),className:"w-full px-4 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white outline-none focus:border-blue-500/50 transition-all",disabled:N})]}),jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"End Date (Optional)"}),jsx("input",{type:"date",value:p,onChange:A=>l(A.target.value),className:"w-full px-4 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white outline-none focus:border-blue-500/50 transition-all",disabled:N})]})]}),k&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:k}),jsxs("div",{className:"border-t border-white/10 pt-4",children:[jsx("p",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider mb-3",children:"Example Prompts"}),jsx("div",{className:"space-y-2",children:["Build an e-commerce platform with product catalog, shopping cart, payment integration, and order tracking","Create a task management app with team collaboration, real-time updates, file attachments, and notifications","Develop a blog platform with markdown editor, SEO optimization, comments system, and analytics dashboard"].map((A,T)=>jsx("button",{onClick:()=>c(A),disabled:N,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-all border border-white/10 hover:border-white/20 disabled:opacity-50",children:A},T))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:N&&jsxs("div",{className:"flex items-center gap-2 text-blue-400 text-sm",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),jsx("span",{children:"Generating with AI..."})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:w,disabled:N,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80 disabled:opacity-50",children:"Cancel"}),h?jsx("button",{onClick:v,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Tasks to Gantt"}):jsx("button",{onClick:B,disabled:!n.trim()||N,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#ffffff"},children:N?"Generating...":"Generate Tasks"})]})]})]})})]})}function ws({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(h=>{t&&Cn(()=>Promise.resolve(t(h)),{maxAttempts:3,initialDelay:1e3,onRetry:(b,u,x)=>{console.warn(`Retry attempt ${u} after ${x}ms: ${b.message}`);}}).then(b=>{b.success||console.error(`Failed to persist board after ${b.attempts} attempts:`,b.error);});},[t]),s=useCallback(async(h,b,u)=>{r(x=>{let m=x.cards.find(A=>A.id===h);if(!m)return x;let N=m.columnId,w={...m,columnId:b,position:u},B=x.cards.map(A=>A.id===h?w:A),v=x.columns.map(A=>{if(A.id===N)return {...A,cardIds:A.cardIds.filter(T=>T!==h)};if(A.id===b){let T=B.filter(W=>W.columnId===b).sort((W,$)=>W.position-$.position);return {...A,cardIds:T.map(W=>W.id)}}return A}),I={...x,cards:B,columns:v};return o(I),I});},[o]),n=useCallback(async(h,b)=>{r(u=>{let x=u.cards.map(N=>N.id===h?{...N,...b}:N),m={...u,cards:x};return o(m),m});},[o]),c=useCallback(async h=>{let b=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(u=>{let x={...h,id:b},m=u.columns.map(w=>w.id===h.columnId?{...w,cardIds:[...w.cardIds,b]}:w),N={...u,cards:[...u.cards,x],columns:m};return o(N),N});},[o]),g=useCallback(async h=>{r(b=>{let u=b.cards.find(w=>w.id===h);if(!u)return b;let x=b.cards.filter(w=>w.id!==h),m=b.columns.map(w=>w.id===u.columnId?{...w,cardIds:w.cardIds.filter(B=>B!==h)}:w),N={...b,cards:x,columns:m};return o(N),N});},[o]),i=useCallback(async h=>{let b=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(u=>{let x={...h,id:b,cardIds:[]},m={...u,columns:[...u.columns,x]};return o(m),m});},[o]),p=useCallback(async(h,b)=>{r(u=>{let x=u.columns.map(N=>N.id===h?{...N,...b}:N),m={...u,columns:x};return o(m),m});},[o]),l=useCallback(async h=>{r(b=>{let u=b.cards.filter(N=>N.columnId!==h),x=b.columns.filter(N=>N.id!==h),m={...b,cards:u,columns:x};return o(m),m});},[o]),f=useCallback(h=>{let b=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(h),b},[c]),y=useCallback(h=>{let b=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return i(h),b},[i]),k=useCallback(()=>{r(h=>{let b={...h,cards:[],columns:[]};return o(b),b});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:n,onCardCreate:c,onCardDelete:g,onColumnCreate:i,onColumnUpdate:p,onColumnDelete:l},setBoard:r,helpers:{addCard:f,addColumn:y,deleteCard:g,deleteColumn:l,clearBoard:k}}}function Wp({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=ws({initialBoard:e,onPersist:a}),n=useMemo(()=>({addCard:(g,i,p={})=>{s.addCard({title:i,columnId:g,position:r.cards.filter(l=>l.columnId===g).length,...p});},addColumn:(g,i)=>{let p=r.columns.length>0?Math.max(...r.columns.map(l=>l.position)):0;s.addColumn({title:g,position:i??p+1e3});},reset:s.clearBoard}),[r.cards,r.columns,s]);return {props:useMemo(()=>({board:r,callbacks:o,availableUsers:t}),[r,o,t]),board:r,callbacks:o,utils:n}}var gn={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},_p={by:"none",order:"asc"};function Vp({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...gn,...e}),[s,n]=useState({..._p,...t}),c=useCallback(C=>{o(h=>({...h,...C}));},[]),g=useCallback(C=>{n(h=>({...h,...C}));},[]),i=useCallback(()=>{o(gn),n(_p);},[]),p=useCallback(()=>{a&&o({...gn,assignees:[a]});},[a]),l=useCallback(()=>{o({...gn,dateFilter:"overdue"});},[]),f=useCallback(()=>{o({...gn,priorities:["HIGH","URGENT"]});},[]),y=useMemo(()=>r.dateFilter!=="all"||r.priorities.length>0||r.assignees.length>0||r.labels.length>0||r.columns.length>0||r.search!==""||s.by!=="none",[r,s]),k=useCallback(C=>{let h=[...C];if(r.search){let b=r.search.toLowerCase();h=h.filter(u=>u.title.toLowerCase().includes(b)||u.description?.toLowerCase().includes(b));}if(r.dateFilter!=="all"){let b=new Date,u=b.getFullYear(),x=String(b.getMonth()+1).padStart(2,"0"),m=String(b.getDate()).padStart(2,"0"),N=`${u}-${x}-${m}`;h=h.filter(w=>{if(!w.endDate&&!w.dueDate)return false;let B=w.endDate||w.dueDate;if(!B)return false;let v;if(typeof B=="string")v=B.split("T")[0]||B;else {let I=B.getUTCFullYear(),A=String(B.getUTCMonth()+1).padStart(2,"0"),T=String(B.getUTCDate()).padStart(2,"0");v=`${I}-${A}-${T}`;}switch(r.dateFilter){case "overdue":return v<N;case "today":return v===N;case "this-week":let I=new Date(N+"T00:00:00"),A=new Date(v+"T00:00:00"),T=new Date(I);return T.setDate(T.getDate()+7),A>=I&&A<=T;case "custom":if(r.dateRange){let W=typeof B=="string"?new Date(B):B;return W>=r.dateRange.start&&W<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(h=h.filter(b=>b.priority&&r.priorities.includes(b.priority))),r.assignees.length>0&&(h=h.filter(b=>(b.assignedUserIds||(b.assigneeId?[b.assigneeId]:[])).some(x=>r.assignees.includes(x)))),r.labels.length>0&&(h=h.filter(b=>b.labels&&b.labels.some(u=>r.labels.includes(u)))),r.columns.length>0&&(h=h.filter(b=>r.columns.includes(b.columnId))),s.by!=="none"&&h.sort((b,u)=>{let x=0;switch(s.by){case "created":let m=b.createdAt?new Date(b.createdAt).getTime():0,N=u.createdAt?new Date(u.createdAt).getTime():0;x=m-N;break;case "priority":let w={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},B=w[b.priority||"LOW"],v=w[u.priority||"LOW"];x=B-v;break;case "dueDate":let I=b.endDate||b.dueDate,A=u.endDate||u.dueDate;if(!I)return 1;if(!A)return -1;let T=typeof I=="string"?new Date(I).getTime():I.getTime(),W=typeof A=="string"?new Date(A).getTime():A.getTime();x=T-W;break;case "title":x=b.title.localeCompare(u.title);break;case "estimate":let $=b.estimatedTime||0,j=u.estimatedTime||0;x=$-j;break;default:x=0;}return s.order==="asc"?x:-x}),h},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:g,resetFilters:i,filterMyTasks:p,filterOverdue:l,filterHighPriority:f,applyFilters:k,hasActiveFilters:y}}var Kp,Yp;if(typeof window<"u")try{let e=xn("ai");Kp=e.generateObject,Yp=e.generateText;}catch{}function qp(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(Kp&&Yp&&e.apiKey),n=useCallback(async l=>{if(!s)throw new Error('AI features require the "ai" package and an API key. Install with: npm install ai');a(true),o(null);try{return console.log("Generating plan for:",l),{columns:[{title:"To Do",position:1e3,cardIds:[]},{title:"In Progress",position:2e3,cardIds:[]},{title:"Done",position:3e3,cardIds:[]}],cards:[{title:"Generated task from AI",description:`Based on: ${l}`,position:1e3,columnId:"temp-col-1"}],explanation:"This is a sample plan. Real implementation would use AI SDK."}}catch(f){let y=f instanceof Error?f:new Error("Failed to generate plan");throw o(y),y}finally{a(false);}},[s]),c=useCallback(async l=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Suggesting assignee for:",l.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(f){let y=f instanceof Error?f:new Error("Failed to suggest assignee");throw o(y),y}finally{a(false);}},[s]),g=useCallback(async l=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Analyzing board for risks..."),[{type:"RISK_OVERLOAD",severity:"HIGH",title:"Column overload detected",description:'Too many cards in "In Progress"',confidence:.9,suggestedAction:'Consider moving some cards back to "To Do"'}]}catch(f){let y=f instanceof Error?f:new Error("Failed to predict risks");throw o(y),y}finally{a(false);}},[s]),i=useCallback(async l=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Generating subtasks for:",l.title),[{title:`Subtask 1 for: ${l.title}`,position:l.position+.1,columnId:l.columnId},{title:`Subtask 2 for: ${l.title}`,position:l.position+.2,columnId:l.columnId}]}catch(f){let y=f instanceof Error?f:new Error("Failed to generate subtasks");throw o(y),y}finally{a(false);}},[s]),p=useCallback(async l=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Estimating effort for:",l.title),{hours:8,confidence:.75}}catch(f){let y=f instanceof Error?f:new Error("Failed to estimate effort");throw o(y),y}finally{a(false);}},[s]);return {onGeneratePlan:n,onSuggestAssignee:c,onPredictRisks:g,onGenerateSubtasks:i,onEstimateEffort:p,isAvailable:s,isLoading:t,error:r}}function Al(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function Xp(e){let{cards:t}=e,[a,r]=Al(),o=useCallback(l=>a.selectedCardIds.includes(l),[a.selectedCardIds]),s=useCallback((l,f)=>{if(!f){r({selectedCardIds:[l],lastSelectedCardId:l});return}let y=f.ctrlKey||f.metaKey,k=f.shiftKey;if(y)a.selectedCardIds.includes(l)?r({selectedCardIds:a.selectedCardIds.filter(C=>C!==l),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,l],lastSelectedCardId:l});else if(k&&a.lastSelectedCardId){let C=t.find(b=>b.id===l),h=t.find(b=>b.id===a.lastSelectedCardId);if(C&&h&&C.columnId===h.columnId){let b=t.filter(v=>v.columnId===C.columnId).sort((v,I)=>v.position-I.position),u=b.findIndex(v=>v.id===a.lastSelectedCardId),x=b.findIndex(v=>v.id===l),[m,N]=u<x?[u,x]:[x,u],w=b.slice(m,N+1).map(v=>v.id),B=Array.from(new Set([...a.selectedCardIds,...w]));r({selectedCardIds:B,lastSelectedCardId:l});}else r({selectedCardIds:[l],lastSelectedCardId:l});}else r({selectedCardIds:[l],lastSelectedCardId:l});},[t,a,r]),n=useCallback(l=>{r({selectedCardIds:a.selectedCardIds.filter(f=>f!==l),lastSelectedCardId:a.lastSelectedCardId});},[a,r]),c=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),g=useCallback(()=>{r({selectedCardIds:t.map(l=>l.id),lastSelectedCardId:t[t.length-1]?.id||null});},[t,r]),i=useCallback(l=>{a.selectedCardIds.includes(l)?n(l):r({selectedCardIds:[...a.selectedCardIds,l],lastSelectedCardId:l});},[a,n,r]),p=useCallback(()=>t.filter(l=>a.selectedCardIds.includes(l.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:n,clearSelection:c,selectAll:g,toggleCard:i,getSelectedCards:p}}var Jp={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function Zp(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...Jp,...a}),[a]),[s,n]=useState([]),c=useCallback((C,h,b,u,x)=>{if(h.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let m={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:C,cardIds:h,columnId:b,strategy:u,color:x,isExpanded:true,position:s.filter(N=>N.columnId===b).length,createdAt:new Date};n(N=>[...N,m]);},[o.minCardsPerStack,s]),g=useCallback(C=>{n(h=>h.filter(b=>b.id!==C));},[]),i=useCallback(C=>{n(h=>h.map(b=>b.id===C?{...b,isExpanded:!b.isExpanded}:b));},[]),p=useCallback((C,h)=>{n(b=>b.map(u=>u.id===C&&!u.cardIds.includes(h)?{...u,cardIds:[...u.cardIds,h]}:u));},[]),l=useCallback((C,h)=>{n(b=>b.map(u=>{if(u.id===C){let x=u.cardIds.filter(m=>m!==h);return x.length<o.minCardsPerStack?null:{...u,cardIds:x}}return u}).filter(u=>u!==null));},[o.minCardsPerStack]),f=useCallback(C=>s.filter(h=>h.columnId===C).sort((h,b)=>h.position-b.position),[s]),y=useCallback(async C=>{let h=t.filter(N=>N.columnId===C);if(h.length<o.minCardsPerStack*2)return [];let b=[],u=new Map;h.forEach(N=>{N.labels&&N.labels.length>0&&N.labels.forEach(w=>{u.has(w)||u.set(w,[]),u.get(w).push(N);});}),u.forEach((N,w)=>{N.length>=o.minCardsPerStack&&b.push({stack:{title:`\u{1F4CC} ${w}`,cardIds:N.map(B=>B.id),columnId:C,strategy:"labels",color:"#3b82f6"},reason:`${N.length} cards with label "${w}"`,confidence:.85});});let x=new Map;h.forEach(N=>{N.assignedUserIds&&N.assignedUserIds.length>0&&N.assignedUserIds.forEach(w=>{x.has(w)||x.set(w,[]),x.get(w).push(N);});}),x.forEach((N,w)=>{N.length>=o.minCardsPerStack&&b.push({stack:{title:`\u{1F464} Assigned to user-${w.slice(-4)}`,cardIds:N.map(B=>B.id),columnId:C,strategy:"assignee",color:"#8b5cf6"},reason:`${N.length} cards assigned to the same user`,confidence:.8});});let m=new Map;if(h.forEach(N=>{N.priority&&(m.has(N.priority)||m.set(N.priority,[]),m.get(N.priority).push(N));}),m.forEach((N,w)=>{if(N.length>=o.minCardsPerStack){let B={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[w.toLowerCase()]||"\u26AA";b.push({stack:{title:`${B} ${w} Priority`,cardIds:N.map(v=>v.id),columnId:C,strategy:"priority",color:w==="high"||w==="urgent"?"#ef4444":"#10b981"},reason:`${N.length} cards with ${w} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let N of h){let B=(await r.findSimilar(N,h)).filter(v=>v.similarity>=o.autoStackConfidenceThreshold);if(B.length>=o.minCardsPerStack-1){let v=[N.id,...B.map(A=>A.card.id)],I=B.reduce((A,T)=>A+T.similarity,0)/B.length;b.push({stack:{title:`\u2728 Similar to "${N.title.substring(0,30)}${N.title.length>30?"...":""}"`,cardIds:v,columnId:C,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${B.length+1} similar tasks`,confidence:I});}}return b.filter(N=>N.confidence>=o.autoStackConfidenceThreshold).sort((N,w)=>w.confidence-N.confidence).slice(0,5)},[t,o,r]),k=useCallback(C=>{c(C.stack.title,C.stack.cardIds,C.stack.columnId,C.stack.strategy,C.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(h=>h.columnId)).forEach(async h=>{let b=await y(h),u=b[0];b.length>0&&u&&u.confidence>=.9&&k(u);});},[]),{stacks:s,createStack:c,deleteStack:g,toggleStack:i,addToStack:p,removeFromStack:l,getStacksForColumn:f,getSuggestions:y,applySuggestion:k,config:o}}var Qp=createContext(null);function eu({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,n=new Map;t?.columns?.forEach(g=>{let{Column:i}=xn("@libxai/core");s.set(g.id,new i(g));}),t?.cards?.forEach(g=>{let{Card:i}=xn("@libxai/core");n.set(g.id,new i(g));});let c=null;if(t?.board){let{Board:g}=xn("@libxai/core");c=new g(t.board);}r.current=new BoardStore({board:c,columns:s,cards:n});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(Qp.Provider,{value:{store:o},children:e})}function Cs(){let e=useContext(Qp);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function bn(){let e=Cs(),[t,a]=useState(e.getBoard()),[r,o]=useState(e.getAllColumns()),[s,n]=useState(e.getAllCards());useEffect(()=>e.subscribeAll(()=>{a(e.getBoard()),o(e.getAllColumns()),n(e.getAllCards());}),[e]);let c=useCallback(u=>{e.updateBoard(u);},[e]),g=useCallback(u=>{e.addColumn(u);},[e]),i=useCallback((u,x)=>{e.updateColumn(u,x);},[e]),p=useCallback(u=>{e.deleteColumn(u);},[e]),l=useCallback(u=>e.getColumn(u),[e]),f=useCallback(u=>{e.addCard(u);},[e]),y=useCallback((u,x)=>{e.updateCard(u,x);},[e]),k=useCallback(u=>{e.deleteCard(u);},[e]),C=useCallback((u,x,m)=>{e.moveCard(u,x,m);},[e]),h=useCallback(u=>e.getCard(u),[e]),b=useCallback(u=>e.getCardsByColumn(u),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:g,updateColumn:i,deleteColumn:p,getColumn:l,addCard:f,updateCard:y,deleteCard:k,moveCard:C,getCard:h,getCardsByColumn:b}}function au(e){let{cards:t}=bn();return useMemo(()=>e?t.filter(a=>{if(e.searchQuery){let r=e.searchQuery.toLowerCase(),o=a.title.toLowerCase().includes(r),s=a.description?.toLowerCase().includes(r);if(!o&&!s)return false}return !(e.priorities&&e.priorities.length>0&&(!a.priority||!e.priorities.includes(a.priority))||e.statuses&&e.statuses.length>0&&(!a.status||!e.statuses.includes(a.status))||e.assignedUserIds&&e.assignedUserIds.length>0&&!e.assignedUserIds.some(o=>a.isAssignedTo(o))||e.labels&&e.labels.length>0&&!e.labels.some(o=>a.hasLabel(o))||e.columnIds&&e.columnIds.length>0&&!e.columnIds.includes(a.columnId)||e.isOverdue!==void 0&&e.isOverdue!==a.isOverdue())}):t,[t,e])}function ru(e="position",t="asc"){let{cards:a}=bn();return useMemo(()=>[...a].sort((o,s)=>{let n=0;switch(e){case "title":n=o.title.localeCompare(s.title);break;case "priority":{let c={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},g=o.priority?c[o.priority]:0,i=s.priority?c[s.priority]:0;n=g-i;break}case "createdAt":n=o.createdAt.getTime()-s.createdAt.getTime();break;case "updatedAt":n=o.updatedAt.getTime()-s.updatedAt.getTime();break;case "position":n=o.position-s.position;break}return t==="asc"?n:-n}),[a,e,t])}var Ts=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=cd.child("PluginManager");}setContext(t){this.context=t;}register(t){if(!t.id||!t.name||!t.version)throw new Error("Plugin must have id, name, and version");if(this.plugins.has(t.id)&&this.pluginLogger.warn(`Plugin ${t.id} is already registered, overwriting...`),t.dependencies){for(let a of t.dependencies)if(!this.plugins.has(a))throw new Error(`Plugin ${t.id} depends on ${a} which is not registered`)}this.plugins.set(t.id,t),t.defaultConfig&&this.config.set(t.id,{...t.defaultConfig}),this.enabled.add(t.id),this.pluginLogger.info(`Plugin registered: ${t.name} v${t.version}`),t.onInit&&this.context&&Promise.resolve(t.onInit(this.context)).catch(a=>{this.pluginLogger.error(`Failed to initialize plugin ${t.id}`,a,{plugin:t.id});});}unregister(t){let a=this.plugins.get(t);if(!a){this.pluginLogger.warn(`Plugin ${t} is not registered`);return}a.onDestroy&&Promise.resolve(a.onDestroy()).catch(r=>{this.pluginLogger.error(`Failed to destroy plugin ${t}`,r);}),this.plugins.delete(t),this.enabled.delete(t),this.config.delete(t),this.pluginLogger.info(`Plugin unregistered: ${a.name}`);}getPlugin(t){return this.plugins.get(t)}getPlugins(){return Array.from(this.plugins.values())}hasPlugin(t){return this.plugins.has(t)}setEnabled(t,a){if(!this.plugins.has(t))throw new Error(`Plugin ${t} is not registered`);a?(this.enabled.add(t),this.pluginLogger.info(`Plugin enabled: ${t}`)):(this.enabled.delete(t),this.pluginLogger.info(`Plugin disabled: ${t}`));}isEnabled(t){return this.enabled.has(t)}getConfig(t,a){return this.config.get(t)?.[a]}setConfig(t,a,r){this.config.has(t)||this.config.set(t,{});let o=this.config.get(t);o[a]=r,this.pluginLogger.debug(`Plugin config set: ${t}.${a}`,{value:r});}async executeHook(t,a,r){let o=r;for(let s of this.plugins.values()){if(!this.enabled.has(s.id))continue;let n=s[t];if(typeof n=="function")try{let c=await Promise.resolve(n.apply(s,a));c!==void 0&&(o=c,a[0]=c);}catch(c){this.pluginLogger.error(`Plugin hook failed: ${s.id}.${t}`,c,{plugin:s.id,hook:t});}}return o}async executeHookParallel(t,a){let r=[];for(let o of this.plugins.values()){if(!this.enabled.has(o.id))continue;let s=o[t];typeof s=="function"&&r.push(Promise.resolve(s.apply(o,a)).catch(n=>{this.pluginLogger.error(`Plugin hook failed: ${o.id}.${t}`,n,{plugin:o.id,hook:t});}));}await Promise.all(r);}},ax=new Ts;function nu({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:n=false,gap:c=0,getItemKey:g}){let i=useRef(null),p=useVirtualizer({count:e.length,getScrollElement:()=>i.current,estimateSize:()=>a,overscan:s,horizontal:n,gap:c}),l=p.getVirtualItems(),f={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},y=n?{width:`${p.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${p.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:i,style:f,className:o,children:jsx("div",{style:y,children:l.map(k=>{let C=e[k.index];if(!C)return null;let h=g?g(C,k.index):k.index,b={position:"absolute",top:n?0:k.start,left:n?k.start:0,width:n?k.size:"100%",height:n?"100%":k.size};return jsx("div",{style:b,"data-index":k.index,children:r(C,k.index)},h)})})})}function su(e){return useVirtualizer({count:e.items.length,getScrollElement:()=>e.scrollElement,estimateSize:()=>e.estimateSize,overscan:e.overscan??5,horizontal:e.horizontal??false,gap:e.gap??0})}function lu({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:n=3,gap:c=16,getItemKey:g,horizontal:i=true}){let p=useRef(null),l=useVirtualizer({horizontal:i,count:e.length,getScrollElement:()=>p.current,estimateSize:()=>r,overscan:n,gap:c}),f=l.getVirtualItems(),y={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},k={width:`${l.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:p,style:y,className:s,children:jsx("div",{style:k,children:f.map(C=>{let h=e[C.index];if(!h)return null;let b=g?g(h,C.index):C.index,u={position:"absolute",top:0,left:C.start,width:C.size,height:"100%"};return jsx("div",{style:u,"data-index":C.index,children:o(h,C.index)},b)})})})}function du(e){let t=useVirtualizer({horizontal:true,count:e.items.length,getScrollElement:()=>e.scrollElement,estimateSize:()=>e.estimateColumnWidth,overscan:e.overscan??3,gap:e.gap??0});return {columnVirtualizer:t,virtualColumns:t.getVirtualItems(),totalWidth:t.getTotalSize()}}function cu(e,t=10){return e>t}var Bl={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},Rl={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},Ol={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},$l={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},Ul={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},zl={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Hl={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Wl={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",smooth:"cubic-bezier(0.4, 0.0, 0.2, 1)",sharp:"cubic-bezier(0.4, 0.0, 0.6, 1)",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},Gl={none:"none",sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",base:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)","2xl":"0 25px 50px -12px rgba(0, 0, 0, 0.25)",inner:"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},_l={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},Vl={column:{width:320,minWidth:280,maxWidth:400,gap:16,padding:12,headerHeight:48},card:{minHeight:80,maxHeight:400,padding:12,gap:8},board:{padding:16,gap:16}},jl={timeline:{headerHeight:60,rowHeight:44,minRowHeight:32,maxRowHeight:80,taskPadding:4,gridLineWidth:1},task:{height:28,minHeight:20,maxHeight:40,borderRadius:4,padding:6},dependency:{lineWidth:2,arrowSize:8},scale:{day:{columnWidth:40,minColumnWidth:30,maxColumnWidth:60},week:{columnWidth:80,minColumnWidth:60,maxColumnWidth:120},month:{columnWidth:120,minColumnWidth:80,maxColumnWidth:200},quarter:{columnWidth:200,minColumnWidth:150,maxColumnWidth:300}},milestone:{size:16,rotation:45}},Ns={spacing:Bl,borderRadius:Rl,fontSize:Ol,fontWeight:$l,lineHeight:Ul,zIndex:zl,duration:Hl,easing:Wl,shadows:Gl,opacity:_l,kanban:Vl,gantt:jl};function mu(e,t,a){return e[t]??a}function Kl(e,t="",a={}){for(let[r,o]of Object.entries(e)){let s=t?`${t}-${r}`:r;typeof o=="object"&&o!==null&&!Array.isArray(o)?Kl(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function nx(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function Yl(e="asakaa"){let t=Kl(Ns),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,n=nx(o);a.push(` ${s}: ${n};`);}return `:root {
|
|
389
|
+
Today's date: ${new Date().toISOString().split("T")[0]}`}function ym(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function Ar(e,t){let a=ym(e),r=t.toLowerCase().trim(),o=a.find(c=>c.name.toLowerCase()===r);if(o)return o;let s=a.find(c=>c.name.toLowerCase().includes(r));if(s)return s;let n=r.split(/\s+/);return a.find(c=>{let g=c.name.toLowerCase();return n.every(i=>g.includes(i))})}function el(e,t=new Date){let a=e.toLowerCase().trim(),r=new Date(t);if(r.setHours(0,0,0,0),a==="today"||a==="hoy")return r;if(a==="tomorrow"||a==="ma\xF1ana"){let f=new Date(r);return f.setDate(f.getDate()+1),f}if(a==="yesterday"||a==="ayer"){let f=new Date(r);return f.setDate(f.getDate()-1),f}if(a==="next week"||a==="la pr\xF3xima semana"){let f=new Date(r);return f.setDate(f.getDate()+7),f}let o=a.match(/(?:next\s+)?(monday|tuesday|wednesday|thursday|friday|saturday|sunday|lunes|martes|miércoles|miercoles|jueves|viernes|sábado|sabado|domingo)/i);if(o){let y={sunday:0,domingo:0,monday:1,lunes:1,tuesday:2,martes:2,wednesday:3,mi\u00E9rcoles:3,miercoles:3,thursday:4,jueves:4,friday:5,viernes:5,saturday:6,s\u00E1bado:6,sabado:6}[o[1].toLowerCase()];if(y!==void 0){let k=new Date(r),C=k.getDay(),h=y-C;return h<=0&&(h+=7),k.setDate(k.getDate()+h),k}}let s=a.match(/in\s+(\d+)\s+(day|week|month|día|dias|semana|semanas|mes|meses)s?/i);if(s&&s[1]&&s[2]){let f=parseInt(s[1],10),y=s[2].toLowerCase(),k=new Date(r);return y==="day"||y==="d\xEDa"||y==="dias"?k.setDate(k.getDate()+f):y==="week"||y==="semana"||y==="semanas"?k.setDate(k.getDate()+f*7):(y==="month"||y==="mes"||y==="meses")&&k.setMonth(k.getMonth()+f),k}if(a.match(/(\d{4})-(\d{2})-(\d{2})/))return new Date(a);let c=a.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/);if(c&&c[1]&&c[2]&&c[3]){let f=parseInt(c[1],10),y=parseInt(c[2],10)-1,k=parseInt(c[3],10);return new Date(k,y,f)}let g={enero:0,febrero:1,marzo:2,abril:3,mayo:4,junio:5,julio:6,agosto:7,septiembre:8,octubre:9,noviembre:10,diciembre:11},i=a.match(/(\d{1,2})\s+de\s+(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)(?:\s+de\s+(\d{4}))?/i);if(i&&i[1]&&i[2]){let f=parseInt(i[1],10),y=g[i[2].toLowerCase()],k=i[3]?parseInt(i[3],10):r.getFullYear();if(y!==void 0)return new Date(k,y,f)}let p={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11},l=a.match(/(january|february|march|april|may|june|july|august|september|october|november|december)\s+(\d{1,2})(?:,?\s+(\d{4}))?/i);if(l&&l[1]&&l[2]){let f=p[l[1].toLowerCase()],y=parseInt(l[2],10),k=l[3]?parseInt(l[3],10):r.getFullYear();if(f!==void 0)return new Date(k,f,y)}return null}function tl(e){let a=e.toLowerCase().trim().match(/(\d+)\s*(day|week|month|día|dias|semana|semanas|mes|meses)s?/i);if(a&&a[1]&&a[2]){let r=parseInt(a[1],10),o=a[2].toLowerCase();if(o==="day"||o==="d\xEDa"||o==="dias")return r;if(o==="week"||o==="semana"||o==="semanas")return r*7;if(o==="month"||o==="mes"||o==="meses")return r*30}return null}function al(e){let t=e.match(/(\d+)(?:\s*%)?/);if(t&&t[1]){let a=parseInt(t[1],10);return Math.max(0,Math.min(100,a))}return null}function vm(e){let t=e.toLowerCase().trim();return t.includes("todo")||t.includes("pendiente")||t.includes("por hacer")?"todo":t.includes("in progress")||t.includes("in-progress")||t.includes("en progreso")||t.includes("working")||t.includes("trabajando")?"in-progress":t.includes("done")||t.includes("complete")||t.includes("finished")||t.includes("completado")||t.includes("terminado")||t.includes("hecho")?"completed":null}function xm(e,t){let a=e.toLowerCase().trim(),r=a.match(/(?:move|mover|mueve)\s+(?:la\s+tarea\s+)?["""]?(.+?)["""]?\s+(?:to|a|para)\s+(?:la\s+fecha\s+)?(.+)/i);if(r&&r[1]&&r[2]){let i=r[1].trim(),p=r[2].trim(),l=Ar(t,i),f=el(p);if(!l)return {type:"move_task",taskName:i,message:`Could not find a task named "${i}". Please check the task name and try again.`,success:false,error:"Task not found"};if(!f)return {type:"move_task",taskId:l.id,taskName:l.name,message:`Could not parse the date "${p}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let y=l.startDate&&l.endDate?Math.round((l.endDate.getTime()-l.startDate.getTime())/(1e3*60*60*24)):1,k=new Date(f);return k.setDate(k.getDate()+y),{type:"move_task",taskId:l.id,taskName:l.name,updates:{startDate:f,endDate:k},message:`Moved "${l.name}" to ${f.toLocaleDateString()}.`,success:true}}let o=a.match(/(?:extend|extender|extiende|alargar)\s+["""]?(.+?)["""]?\s+(?:by|por)\s+(.+)/i);if(o&&o[1]&&o[2]){let i=o[1].trim(),p=o[2].trim(),l=Ar(t,i),f=tl(p);if(!l)return {type:"resize_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"};if(!f||!l.endDate)return {type:"resize_task",taskId:l.id,taskName:l.name,message:`Could not parse the duration "${p}".`,success:false,error:"Invalid duration"};let y=new Date(l.endDate);return y.setDate(y.getDate()+f),{type:"resize_task",taskId:l.id,taskName:l.name,updates:{endDate:y},message:`Extended "${l.name}" by ${f} days. New end date: ${y.toLocaleDateString()}.`,success:true}}let s=a.match(/(?:set|establecer|poner)\s+["""]?(.+?)["""]?\s+(?:progress|progreso)\s+(?:to|a|en)\s+(.+)/i);if(s&&s[1]&&s[2]){let i=s[1].trim(),p=s[2].trim(),l=Ar(t,i),f=al(p);return l?f===null?{type:"set_progress",taskId:l.id,taskName:l.name,message:`Could not parse the progress value "${p}".`,success:false,error:"Invalid progress"}:{type:"set_progress",taskId:l.id,taskName:l.name,updates:{progress:f},message:`Set "${l.name}" progress to ${f}%.`,success:true}:{type:"set_progress",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}let n=a.match(/(?:rename|renombrar|cambiar nombre de)\s+["""]?(.+?)["""]?\s+(?:to|a|por)\s+["""]?(.+?)["""]?$/i);if(n&&n[1]&&n[2]){let i=n[1].trim(),p=n[2].trim(),l=Ar(t,i);return l?{type:"rename_task",taskId:l.id,taskName:l.name,updates:{name:p},message:`Renamed "${l.name}" to "${p}".`,success:true}:{type:"rename_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}let c=a.match(/(?:link|vincular|conectar)\s+["""]?(.+?)["""]?\s+(?:to|a|con)\s+["""]?(.+?)["""]?$/i);if(c&&c[1]&&c[2]){let i=c[1].trim(),p=c[2].trim(),l=Ar(t,i),f=Ar(t,p);return l?f?{type:"link_tasks",taskId:f.id,taskName:f.name,dependencyFrom:l.id,dependencyTo:f.id,message:`Linked "${l.name}" \u2192 "${f.name}".`,success:true}:{type:"link_tasks",taskName:p,message:`Could not find a task named "${p}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Source task not found"}}let g=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(g&&g[1]){let i=g[1].trim(),p=Ar(t,i);return p?{type:"delete_task",taskId:p.id,taskName:p.name,message:`Deleted "${p.name}".`,success:true}:{type:"delete_task",taskName:i,message:`Could not find a task named "${i}".`,success:false,error:"Task not found"}}return null}function km(e){if(!e||typeof e!="object")return {type:"unknown",message:"Invalid response from AI",success:false,error:"Invalid response format"};let t=e;return {type:t.type||"unknown",taskId:typeof t.taskId=="string"?t.taskId:void 0,taskName:typeof t.taskName=="string"?t.taskName:void 0,updates:t.updates,newTask:t.newTask,dependencyFrom:typeof t.dependencyFrom=="string"?t.dependencyFrom:void 0,dependencyTo:typeof t.dependencyTo=="string"?t.dependencyTo:void 0,message:typeof t.message=="string"?t.message:"Command processed",success:typeof t.success=="boolean"?t.success:false,error:typeof t.error=="string"?t.error:void 0}}function wh(e){if(e)switch(e.toUpperCase()){case "TODO":case "BLOCKED":return "todo";case "IN_PROGRESS":case "REVIEW":return "in-progress";case "DONE":return "completed";default:return "todo"}}function Ch(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function ns(e,t=[],a=[]){let r=e.assignedUserIds?.map(p=>{let l=a.find(f=>f.id===p);return l?{name:l.name,initials:l.initials,color:l.color}:null}).filter(p=>p!==null),o=t.filter(p=>p.metadata?.parentCardId===e.id).map(p=>ns(p,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(p=>p.type==="finish-to-start").map(p=>p.taskId));let n=p=>{if(p)return typeof p=="string"?new Date(p):p},c=n(e.startDate),g=n(e.endDate),i=e.metadata?.isMilestone===true||c&&g&&Math.abs(g.getTime()-c.getTime())<=864e5;return {id:e.id,name:e.title,startDate:c,endDate:g,progress:e.progress||0,status:wh(e.metadata?.status),assignees:r?.length?r:void 0,dependencies:s?.length?s:void 0,subtasks:o?.length?o:void 0,isExpanded:e.metadata?.isExpanded===true,isMilestone:i,isCriticalPath:e.metadata?.isCriticalPath===true}}function wm(e,t=[]){let a;return e.assignees&&e.assignees.length>0&&(a=e.assignees.map(r=>t.find(s=>s.name===r.name||s.initials===r.initials)?.id).filter(r=>r!==void 0)),{id:e.id,title:e.name,startDate:e.startDate,endDate:e.endDate,progress:e.progress,assignedUserIds:a?.length?a:void 0,metadata:{status:Ch(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Cm(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>ns(r,e,t))}var rl={columns:{name:"Task Name",startDate:"Start Date",endDate:"End Date",progress:"Progress",status:"Status",assignees:"Assignees",priority:"Priority",actions:"Actions"},toolbar:{search:"Search",searchPlaceholder:"Search tasks...",filter:"Filter",clearFilters:"Clear Filters",export:"Export",columns:"Columns",newTask:"New Task"},filters:{status:"Status",assignees:"Assignees",dateRange:"Date Range",showCompleted:"Show Completed",all:"All",none:"None"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",viewDetails:"View Details"},empty:{noTasks:"No tasks yet",noResults:"No tasks match your filters",addFirstTask:"Add your first task"},pagination:{showing:"Showing",of:"of",tasks:"tasks",previous:"Previous",next:"Next"},bulk:{selected:"selected",delete:"Delete",move:"Move to",assignTo:"Assign to"}},ol={columns:{name:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",progress:"Progreso",status:"Estado",assignees:"Asignados",priority:"Prioridad",actions:"Acciones"},toolbar:{search:"Buscar",searchPlaceholder:"Buscar tareas...",filter:"Filtrar",clearFilters:"Limpiar Filtros",export:"Exportar",columns:"Columnas",newTask:"Nueva Tarea"},filters:{status:"Estado",assignees:"Asignados",dateRange:"Rango de Fechas",showCompleted:"Mostrar Completadas",all:"Todos",none:"Ninguno"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",viewDetails:"Ver Detalles"},empty:{noTasks:"Sin tareas a\xFAn",noResults:"Ninguna tarea coincide con los filtros",addFirstTask:"Agrega tu primera tarea"},pagination:{showing:"Mostrando",of:"de",tasks:"tareas",previous:"Anterior",next:"Siguiente"},bulk:{selected:"seleccionadas",delete:"Eliminar",move:"Mover a",assignTo:"Asignar a"}},ss={en:rl,es:ol};function nl(e){return ss[e]||ss.en}function is(e,t){let a=nl(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},filters:{...a.filters,...t.filters},status:{...a.status,...t.status},actions:{...a.actions,...t.actions},empty:{...a.empty,...t.empty},pagination:{...a.pagination,...t.pagination},bulk:{...a.bulk,...t.bulk}}:a}var sl=[{value:"todo",icon:Circle,color:"text-gray-400"},{value:"in-progress",icon:PlayCircle,color:"text-blue-500"},{value:"completed",icon:CheckCircle2,color:"text-green-500"}];function Tm({value:e,onChange:t,isDark:a,translations:r,disabled:o=false}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let f=y=>{c.current&&!c.current.contains(y.target)&&n(false);};return s&&document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[s]);let g=sl[0],i=sl.find(f=>f.value===e)??g,p=i.icon,l=f=>{switch(f){case "completed":return r.completed;case "in-progress":return r.inProgress;default:return r.todo}};return o||!t?jsxs("div",{className:"flex items-center gap-2",children:[jsx(p,{className:d("w-4 h-4",i.color)}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:l(e)})]}):jsxs("div",{ref:c,className:"relative",children:[jsxs("button",{onClick:f=>{f.stopPropagation(),n(!s);},className:d("flex items-center gap-2 px-2 py-1 rounded transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx(p,{className:d("w-4 h-4",i.color)}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:l(e)}),jsx(ChevronDown,{className:d("w-3 h-3",a?"text-[#6B7280]":"text-gray-400")})]}),s&&jsx("div",{className:d("absolute z-50 top-full left-0 mt-1 py-1 rounded-lg shadow-lg border min-w-[140px]",a?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:sl.map(f=>{let y=f.icon;return jsxs("button",{onClick:k=>{k.stopPropagation(),t(f.value),n(false);},className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100",e===f.value&&(a?"bg-white/5":"bg-gray-50")),children:[jsx(y,{className:d("w-4 h-4",f.color)}),jsx("span",{className:a?"text-white":"text-gray-900",children:l(f.value)})]},f.value)})})]})}var il=[{value:"urgent",label:{en:"Urgent",es:"Urgente"},color:"text-red-500",bg:"bg-red-500"},{value:"high",label:{en:"High",es:"Alta"},color:"text-orange-500",bg:"bg-orange-500"},{value:"medium",label:{en:"Medium",es:"Media"},color:"text-yellow-500",bg:"bg-yellow-500"},{value:"low",label:{en:"Low",es:"Baja"},color:"text-blue-500",bg:"bg-blue-500"},{value:"none",label:{en:"None",es:"Ninguna"},color:"text-gray-400",bg:"bg-gray-400"}];function Dm({value:e="none",onChange:t,isDark:a,locale:r,disabled:o=false}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let p=l=>{c.current&&!c.current.contains(l.target)&&n(false);};return s&&document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);let g=il.find(p=>p.value===e)??il[4],i=r==="es"?"es":"en";return o||!t?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Flag,{className:d("w-4 h-4",g.color)}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:g.label[i]})]}):jsxs("div",{ref:c,className:"relative",children:[jsxs("button",{onClick:p=>{p.stopPropagation(),n(!s);},className:d("flex items-center gap-2 px-2 py-1 rounded transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx(Flag,{className:d("w-4 h-4",g.color)}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:g.label[i]}),jsx(ChevronDown,{className:d("w-3 h-3",a?"text-[#6B7280]":"text-gray-400")})]}),s&&jsx("div",{className:d("absolute z-50 top-full left-0 mt-1 py-1 rounded-lg shadow-lg border min-w-[120px]",a?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:il.map(p=>jsxs("button",{onClick:l=>{l.stopPropagation(),t(p.value),n(false);},className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100",e===p.value&&(a?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:d("w-2 h-2 rounded-full",p.bg)}),jsx("span",{className:a?"text-white":"text-gray-900",children:p.label[i]})]},p.value))})]})}function cs(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function ms(e){let t=["bg-blue-500","bg-green-500","bg-purple-500","bg-pink-500","bg-yellow-500","bg-red-500","bg-indigo-500","bg-teal-500"],a=0;for(let r=0;r<e.length;r++)a=e.charCodeAt(r)+((a<<5)-a);return t[Math.abs(a)%t.length]??"bg-blue-500"}function Em({value:e=[],availableUsers:t=[],onChange:a,isDark:r,locale:o,disabled:s=false}){let[n,c]=useState(false),[g,i]=useState(""),p=useRef(null);useEffect(()=>{let k=C=>{p.current&&!p.current.contains(C.target)&&(c(false),i(""));};return n&&document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[n]);let l=t.filter(k=>k.name.toLowerCase().includes(g.toLowerCase())||k.email?.toLowerCase().includes(g.toLowerCase())),f=k=>e.some(C=>C.name===k),y=k=>{if(a)if(f(k.name))a(e.filter(C=>C.name!==k.name));else {let C={name:k.name,initials:cs(k.name),color:k.color||ms(k.name).replace("bg-","").replace("-500",""),avatar:k.avatarUrl};a([...e,C]);}};return s||!a?e.length===0?jsx("span",{className:d("text-sm",r?"text-[#6B7280]":"text-gray-400"),children:"-"}):jsxs("div",{className:"flex items-center -space-x-2",children:[e.slice(0,3).map((k,C)=>jsx("div",{className:d("w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium text-white border-2",r?"border-[#0F1117]":"border-white",!k.avatar&&ms(k.name)),style:k.color&&!k.avatar?{backgroundColor:k.color}:void 0,title:k.name,children:k.avatar?jsx("img",{src:k.avatar,alt:k.name,className:"w-full h-full rounded-full object-cover"}):k.initials||cs(k.name)},`${k.name}-${C}`)),e.length>3&&jsxs("div",{className:d("w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium border-2",r?"bg-[#374151] border-[#0F1117] text-white":"bg-gray-200 border-white text-gray-600"),children:["+",e.length-3]})]}):jsxs("div",{ref:p,className:"relative",children:[jsx("button",{onClick:k=>{k.stopPropagation(),c(!n);},className:d("flex items-center gap-1 px-2 py-1 rounded transition-colors",r?"hover:bg-white/10":"hover:bg-gray-100"),children:e.length===0?jsxs(Fragment,{children:[jsx(User,{className:d("w-4 h-4",r?"text-[#6B7280]":"text-gray-400")}),jsx(Plus,{className:d("w-3 h-3",r?"text-[#6B7280]":"text-gray-400")})]}):jsxs("div",{className:"flex items-center -space-x-1",children:[e.slice(0,2).map((k,C)=>jsx("div",{className:d("w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-medium text-white border",r?"border-[#0F1117]":"border-white",!k.avatar&&ms(k.name)),style:k.color&&!k.avatar?{backgroundColor:k.color}:void 0,children:k.avatar?jsx("img",{src:k.avatar,alt:k.name,className:"w-full h-full rounded-full object-cover"}):k.initials||cs(k.name)},`${k.name}-${C}`)),e.length>2&&jsxs("span",{className:d("text-xs ml-1",r?"text-[#9CA3AF]":"text-gray-500"),children:["+",e.length-2]})]})}),n&&jsxs("div",{className:d("absolute z-50 top-full left-0 mt-1 rounded-lg shadow-lg border w-64",r?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:[jsx("div",{className:"p-2 border-b",style:{borderColor:r?"rgba(255,255,255,0.1)":"#E5E7EB"},children:jsx("input",{type:"text",value:g,onChange:k=>i(k.target.value),placeholder:o==="es"?"Buscar usuario...":"Search user...",className:d("w-full px-3 py-1.5 text-sm rounded border outline-none",r?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400"),onClick:k=>k.stopPropagation()})}),jsx("div",{className:"max-h-48 overflow-y-auto py-1",children:l.length===0?jsx("p",{className:d("px-3 py-2 text-sm",r?"text-[#6B7280]":"text-gray-400"),children:o==="es"?"No se encontraron usuarios":"No users found"}):l.map(k=>jsxs("button",{onClick:C=>{C.stopPropagation(),y(k);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",r?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx("div",{className:d("w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium text-white",!k.avatarUrl&&ms(k.name)),children:k.avatarUrl?jsx("img",{src:k.avatarUrl,alt:k.name,className:"w-full h-full rounded-full object-cover"}):cs(k.name)}),jsxs("div",{className:"flex-1 text-left",children:[jsx("div",{className:r?"text-white":"text-gray-900",children:k.name}),k.email&&jsx("div",{className:d("text-xs",r?"text-[#6B7280]":"text-gray-400"),children:k.email})]}),f(k.name)&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},k.id))}),e.length>0&&jsx("div",{className:"p-2 border-t flex flex-wrap gap-1",style:{borderColor:r?"rgba(255,255,255,0.1)":"#E5E7EB"},children:e.map((k,C)=>jsxs("span",{className:d("inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full",r?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:[k.name,jsx("button",{onClick:h=>{h.stopPropagation(),a(e.filter(b=>b.name!==k.name));},className:"hover:text-red-500",children:jsx(X,{className:"w-3 h-3"})})]},`${k.name}-${C}`))})]})]})}var Kh={en:["January","February","March","April","May","June","July","August","September","October","November","December"],es:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]},Yh={en:["Su","Mo","Tu","We","Th","Fr","Sa"],es:["Do","Lu","Ma","Mi","Ju","Vi","S\xE1"]};function ps({value:e,onChange:t,isDark:a,locale:r,disabled:o=false}){let[s,n]=useState(false),[c,g]=useState(()=>{if(e){let h=e instanceof Date?e:new Date(e);return new Date(h.getFullYear(),h.getMonth(),1)}return new Date(new Date().getFullYear(),new Date().getMonth(),1)}),i=useRef(null),p=e?e instanceof Date?e:new Date(e):null,l=r==="es"?"es":"en";useEffect(()=>{let h=b=>{i.current&&!i.current.contains(b.target)&&n(false);};return s&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]);let f=h=>h?h.toLocaleDateString(r==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-",y=(h,b)=>new Date(h,b+1,0).getDate(),k=(h,b)=>new Date(h,b,1).getDay(),C=()=>{let h=c.getFullYear(),b=c.getMonth(),u=y(h,b),x=k(h,b),m=new Date,N=[];for(let w=0;w<x;w++)N.push(jsx("div",{className:"w-8 h-8"},`empty-${w}`));for(let w=1;w<=u;w++){let B=new Date(h,b,w),v=p&&p.getDate()===w&&p.getMonth()===b&&p.getFullYear()===h,I=m.getDate()===w&&m.getMonth()===b&&m.getFullYear()===h;N.push(jsx("button",{onClick:F=>{F.stopPropagation(),t?.(B),n(false);},className:d("w-8 h-8 rounded-full text-sm transition-colors",v?"bg-[#3B82F6] text-white":I?a?"bg-white/10 text-white":"bg-gray-100 text-gray-900":a?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-900"),children:w},w));}return N};return o||!t?jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:f(p)}):jsxs("div",{ref:i,className:"relative",children:[jsxs("button",{onClick:h=>{h.stopPropagation(),n(!s);},className:d("flex items-center gap-2 px-2 py-1 rounded transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx(Calendar,{className:d("w-4 h-4",a?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:f(p)})]}),s&&jsxs("div",{className:d("absolute z-50 top-full left-0 mt-1 p-3 rounded-lg shadow-lg border",a?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{onClick:h=>{h.stopPropagation(),g(new Date(c.getFullYear(),c.getMonth()-1,1));},className:d("p-1 rounded",a?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:d("w-4 h-4",a?"text-white":"text-gray-600")})}),jsxs("span",{className:d("text-sm font-medium",a?"text-white":"text-gray-900"),children:[Kh[l][c.getMonth()]," ",c.getFullYear()]}),jsx("button",{onClick:h=>{h.stopPropagation(),g(new Date(c.getFullYear(),c.getMonth()+1,1));},className:d("p-1 rounded",a?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:d("w-4 h-4",a?"text-white":"text-gray-600")})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:Yh[l].map(h=>jsx("div",{className:d("w-8 h-6 text-xs flex items-center justify-center",a?"text-[#6B7280]":"text-gray-400"),children:h},h))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:C()}),jsxs("div",{className:"mt-3 pt-3 border-t flex gap-2",style:{borderColor:a?"rgba(255,255,255,0.1)":"#E5E7EB"},children:[jsx("button",{onClick:h=>{h.stopPropagation(),t?.(new Date),n(false);},className:d("flex-1 py-1.5 text-xs rounded",a?"bg-white/10 text-white hover:bg-white/20":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:r==="es"?"Hoy":"Today"}),jsx("button",{onClick:h=>{h.stopPropagation();let b=new Date;b.setDate(b.getDate()+1),t?.(b),n(false);},className:d("flex-1 py-1.5 text-xs rounded",a?"bg-white/10 text-white hover:bg-white/20":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:r==="es"?"Ma\xF1ana":"Tomorrow"})]})]})]})}function Fm({value:e=0,onChange:t,isDark:a,disabled:r=false}){return jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{onClick:s=>{if(r||!t)return;s.stopPropagation();let n=s.currentTarget.getBoundingClientRect(),c=s.clientX-n.left,g=Math.round(c/n.width*100),i=Math.max(0,Math.min(100,g));t(i);},className:d("flex-1 h-2 rounded-full overflow-hidden",a?"bg-white/10":"bg-gray-200",!r&&t&&"cursor-pointer"),children:jsx("div",{className:d("h-full rounded-full transition-all",e===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${e}%`}})}),jsxs("span",{className:d("text-xs w-8 text-right",a?"text-[#9CA3AF]":"text-gray-500"),children:[e,"%"]})]})}function Bm({value:e="",onChange:t,isDark:a,placeholder:r="-",disabled:o=false}){let[s,n]=useState(false),[c,g]=useState(e),i=useRef(null);useEffect(()=>{s&&i.current&&(i.current.focus(),i.current.select());},[s]),useEffect(()=>{g(e);},[e]);let p=()=>{c!==e&&t?.(c),n(false);},l=f=>{f.key==="Enter"?p():f.key==="Escape"&&(g(e),n(false));};return o||!t?jsx("span",{className:d("text-sm truncate",a?"text-[#94A3B8]":"text-gray-500"),children:e||r}):s?jsx("input",{ref:i,type:"text",value:c,onChange:f=>g(f.target.value),onBlur:p,onKeyDown:l,onClick:f=>f.stopPropagation(),className:d("w-full px-2 py-1 text-sm rounded border outline-none",a?"bg-white/5 border-[#3B82F6] text-white":"bg-white border-[#3B82F6] text-gray-900")}):jsx("button",{onClick:f=>{f.stopPropagation(),n(true);},className:d("text-sm truncate text-left w-full px-2 py-1 rounded transition-colors",a?"text-[#94A3B8] hover:bg-white/10":"text-gray-500 hover:bg-gray-100",!e&&(a?"text-[#6B7280]":"text-gray-400")),children:e||r})}function $m({value:e,onChange:t,isDark:a,placeholder:r="-",min:o,max:s,disabled:n=false}){let[c,g]=useState(false),[i,p]=useState(e?.toString()||""),l=useRef(null);useEffect(()=>{c&&l.current&&(l.current.focus(),l.current.select());},[c]),useEffect(()=>{p(e?.toString()||"");},[e]);let f=()=>{let k=parseFloat(i);if(!isNaN(k)){let C=k;o!==void 0&&(C=Math.max(o,C)),s!==void 0&&(C=Math.min(s,C)),C!==e&&t?.(C);}g(false);},y=k=>{k.key==="Enter"?f():k.key==="Escape"&&(p(e?.toString()||""),g(false));};return n||!t?jsx("span",{className:d("text-sm",a?"text-[#94A3B8]":"text-gray-500"),children:e!==void 0?e:r}):c?jsx("input",{ref:l,type:"number",value:i,onChange:k=>p(k.target.value),onBlur:f,onKeyDown:y,onClick:k=>k.stopPropagation(),min:o,max:s,className:d("w-full px-2 py-1 text-sm rounded border outline-none",a?"bg-white/5 border-[#3B82F6] text-white":"bg-white border-[#3B82F6] text-gray-900")}):jsx("button",{onClick:k=>{k.stopPropagation(),g(true);},className:d("text-sm text-left w-full px-2 py-1 rounded transition-colors",a?"text-[#94A3B8] hover:bg-white/10":"text-gray-500 hover:bg-gray-100",e===void 0&&(a?"text-[#6B7280]":"text-gray-400")),children:e!==void 0?e:r})}function Um({value:e,options:t=[],onChange:a,isDark:r,placeholder:o="-",disabled:s=false}){let[n,c]=useState(false),g=useRef(null);return useEffect(()=>{let i=p=>{g.current&&!g.current.contains(p.target)&&c(false);};return n&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[n]),s||!a?jsx("span",{className:d("text-sm",r?"text-[#94A3B8]":"text-gray-500"),children:e||o}):jsxs("div",{ref:g,className:"relative",children:[jsxs("button",{onClick:i=>{i.stopPropagation(),c(!n);},className:d("flex items-center gap-2 px-2 py-1 rounded transition-colors min-w-[80px]",r?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx("span",{className:d("text-sm flex-1 text-left truncate",r?"text-[#94A3B8]":"text-gray-500",!e&&(r?"text-[#6B7280]":"text-gray-400")),children:e||o}),jsx(ChevronDown,{className:d("w-3 h-3 flex-shrink-0",r?"text-[#6B7280]":"text-gray-400")})]}),n&&jsx("div",{className:d("absolute z-50 top-full left-0 mt-1 py-1 rounded-lg shadow-lg border min-w-[120px] max-h-48 overflow-y-auto",r?"bg-[#1F2937] border-white/10":"bg-white border-gray-200"),children:t.length===0?jsx("p",{className:d("px-3 py-2 text-sm",r?"text-[#6B7280]":"text-gray-400"),children:"No options"}):t.map(i=>jsxs("button",{onClick:p=>{p.stopPropagation(),a(i),c(false);},className:d("w-full flex items-center justify-between gap-2 px-3 py-2 text-sm transition-colors",r?"hover:bg-white/10":"hover:bg-gray-100",e===i&&(r?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:r?"text-white":"text-gray-900",children:i}),e===i&&jsx(Check,{className:"w-4 h-4 text-[#3B82F6]"})]},i))})]})}function Hm({value:e=false,onChange:t,isDark:a,disabled:r=false}){return jsx("button",{onClick:s=>{s.stopPropagation(),!r&&t&&t(!e);},disabled:r||!t,className:d("w-5 h-5 rounded border-2 flex items-center justify-center transition-colors",e?"bg-[#3B82F6] border-[#3B82F6]":a?"border-[#4B5563] hover:border-[#6B7280]":"border-gray-300 hover:border-gray-400",(r||!t)&&"opacity-50 cursor-not-allowed"),children:e&&jsx(Check,{className:"w-3 h-3 text-white"})})}function _m({value:e=[],isDark:t,maxVisible:a=2}){if(e.length===0)return jsx("span",{className:d("text-sm",t?"text-[#6B7280]":"text-gray-400"),children:"-"});let r=e.slice(0,a),o=e.length-a;return jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[r.map(s=>jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-xs rounded-full",style:{backgroundColor:s.color?`${s.color}20`:t?"rgba(255,255,255,0.1)":"#F3F4F6",color:s.color||(t?"#9CA3AF":"#6B7280")},children:s.name},s.id)),o>0&&jsxs("span",{className:d("inline-flex items-center px-2 py-0.5 text-xs rounded-full",t?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-500"),children:["+",o]})]})}function by(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function hy(e){let t=["blue","green","purple","pink","yellow","red","indigo","teal"],a=0;for(let r=0;r<e.length;r++)a=e.charCodeAt(r)+((a<<5)-a);return t[Math.abs(a)%t.length]??"blue"}function Ym({state:e,onClose:t,isDark:a,locale:r,onTaskEdit:o,onTaskDuplicate:s,onTaskDelete:n,onTaskUpdate:c,onColumnHide:g,onColumnSort:i,availableUsers:p=[]}){let l=useRef(null),f=r==="es"?jm.es:jm.en;if(useEffect(()=>{let b=x=>{l.current&&!l.current.contains(x.target)&&t();},u=x=>{x.key==="Escape"&&t();};return document.addEventListener("mousedown",b),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",u);}},[t]),!e.isOpen)return null;let y=()=>{if(!e.task)return [];let b=[];return o&&b.push({id:"edit",label:f.edit,icon:jsx(Edit3,{className:"w-4 h-4"}),onClick:()=>{o(e.task),t();}}),b.push({id:"sep1",label:"",icon:null,separator:true}),c&&(b.push({id:"status",label:f.changeStatus,icon:jsx(CheckCircle2,{className:"w-4 h-4"}),submenu:[{id:"status-todo",label:f.todo,icon:jsx(Circle,{className:"w-4 h-4 text-gray-400"}),onClick:()=>{c({...e.task,status:"todo",progress:0}),t();}},{id:"status-in-progress",label:f.inProgress,icon:jsx(PlayCircle,{className:"w-4 h-4 text-blue-500"}),onClick:()=>{c({...e.task,status:"in-progress",progress:e.task.progress||50}),t();}},{id:"status-completed",label:f.completed,icon:jsx(CheckCircle2,{className:"w-4 h-4 text-green-500"}),onClick:()=>{c({...e.task,status:"completed",progress:100}),t();}}]}),b.push({id:"priority",label:f.changePriority,icon:jsx(Flag,{className:"w-4 h-4"}),submenu:[{id:"priority-urgent",label:f.urgent,icon:jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),onClick:()=>{c({...e.task,priority:"urgent"}),t();}},{id:"priority-high",label:f.high,icon:jsx("div",{className:"w-3 h-3 rounded-full bg-orange-500"}),onClick:()=>{c({...e.task,priority:"high"}),t();}},{id:"priority-medium",label:f.medium,icon:jsx("div",{className:"w-3 h-3 rounded-full bg-yellow-500"}),onClick:()=>{c({...e.task,priority:"medium"}),t();}},{id:"priority-low",label:f.low,icon:jsx("div",{className:"w-3 h-3 rounded-full bg-blue-500"}),onClick:()=>{c({...e.task,priority:"low"}),t();}}]}),p.length>0&&b.push({id:"assign",label:f.assignUser,icon:jsx(Users,{className:"w-4 h-4"}),submenu:p.slice(0,5).map(u=>({id:`assign-${u.id}`,label:u.name,icon:jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white bg-blue-500",children:u.name.charAt(0).toUpperCase()}),onClick:()=>{let x=e.task.assignees||[],N=x.some(w=>w.name===u.name)?x.filter(w=>w.name!==u.name):[...x,{name:u.name,initials:by(u.name),color:u.color||hy(u.name),avatar:u.avatarUrl}];c({...e.task,assignees:N}),t();}}))})),b.push({id:"sep2",label:"",icon:null,separator:true}),s&&b.push({id:"duplicate",label:f.duplicate,icon:jsx(Copy,{className:"w-4 h-4"}),onClick:()=>{s(e.task),t();}}),n&&b.push({id:"delete",label:f.delete,icon:jsx(Trash2,{className:"w-4 h-4"}),danger:true,onClick:()=>{n(e.task.id),t();}}),b},k=()=>{if(!e.columnId)return [];let b=[];return i&&(b.push({id:"sort-asc",label:f.sortAsc,icon:jsx(ArrowUp,{className:"w-4 h-4"}),onClick:()=>{i(e.columnId,"asc"),t();}}),b.push({id:"sort-desc",label:f.sortDesc,icon:jsx(ArrowDown,{className:"w-4 h-4"}),onClick:()=>{i(e.columnId,"desc"),t();}})),g&&e.columnId!=="name"&&(b.push({id:"sep-hide",label:"",icon:null,separator:true}),b.push({id:"hide",label:f.hideColumn,icon:jsx(EyeOff,{className:"w-4 h-4"}),onClick:()=>{g(e.columnId),t();}})),b},C=e.type==="task"?y():k(),h={position:"fixed",left:e.x,top:e.y,zIndex:9999};return jsx("div",{ref:l,style:h,className:d("py-1 rounded-lg shadow-xl border min-w-[180px]",a?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:C.map(b=>b.separator?jsx("div",{className:d("my-1 h-px",a?"bg-white/10":"bg-gray-200")},b.id):b.submenu?jsx(yy,{item:b,isDark:a},b.id):jsxs("button",{onClick:b.onClick,className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",a?"hover:bg-white/10":"hover:bg-gray-100",b.danger?"text-red-500 hover:text-red-600":a?"text-white":"text-gray-700"),children:[jsx("span",{className:d(b.danger?"text-red-500":a?"text-[#9CA3AF]":"text-gray-400"),children:b.icon}),b.label]},b.id))})}function yy({item:e,isDark:t}){let[a,r]=useState(false),o=useRef();return jsxs("div",{className:"relative",onMouseEnter:()=>{o.current&&clearTimeout(o.current),r(true);},onMouseLeave:()=>{o.current=setTimeout(()=>r(false),150);},children:[jsxs("button",{className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",t?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:[jsx("span",{className:t?"text-[#9CA3AF]":"text-gray-400",children:e.icon}),jsx("span",{className:"flex-1",children:e.label}),jsx(ChevronRight,{className:d("w-4 h-4",t?"text-[#6B7280]":"text-gray-400")})]}),a&&e.submenu&&jsx("div",{className:d("absolute left-full top-0 ml-1 py-1 rounded-lg shadow-xl border min-w-[160px]",t?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:e.submenu.map(c=>jsxs("button",{onClick:c.onClick,className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",t?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:[jsx("span",{className:t?"text-[#9CA3AF]":"text-gray-400",children:c.icon}),c.label]},c.id))})]})}var jm={en:{edit:"Edit",changeStatus:"Change status",changePriority:"Change priority",assignUser:"Assign user",duplicate:"Duplicate",delete:"Delete",todo:"To Do",inProgress:"In Progress",completed:"Completed",urgent:"Urgent",high:"High",medium:"Medium",low:"Low",sortAsc:"Sort A \u2192 Z",sortDesc:"Sort Z \u2192 A",hideColumn:"Hide column"},es:{edit:"Editar",changeStatus:"Cambiar estado",changePriority:"Cambiar prioridad",assignUser:"Asignar usuario",duplicate:"Duplicar",delete:"Eliminar",todo:"Pendiente",inProgress:"En Progreso",completed:"Completado",urgent:"Urgente",high:"Alta",medium:"Media",low:"Baja",sortAsc:"Ordenar A \u2192 Z",sortDesc:"Ordenar Z \u2192 A",hideColumn:"Ocultar columna"}};var Jm={name:jsx(Type,{className:"w-4 h-4"}),status:jsx(CircleDot,{className:"w-4 h-4"}),priority:jsx(Flag,{className:"w-4 h-4"}),assignees:jsx(Users,{className:"w-4 h-4"}),startDate:jsx(Calendar,{className:"w-4 h-4"}),endDate:jsx(CalendarCheck,{className:"w-4 h-4"}),progress:jsx(BarChart,{className:"w-4 h-4"}),tags:jsx(Tag,{className:"w-4 h-4"}),text:jsx(Type,{className:"w-4 h-4"}),number:jsx(Hash,{className:"w-4 h-4"}),date:jsx(Calendar,{className:"w-4 h-4"}),dropdown:jsx(ChevronDown,{className:"w-4 h-4"}),checkbox:jsx(CheckSquare,{className:"w-4 h-4"})},Iy=["name","status","priority","assignees","startDate","endDate","progress","tags"];function Qm({isOpen:e,onClose:t,columns:a,customFields:r=[],onColumnsChange:o,onCreateCustomField:s,isDark:n,locale:c}){let[g,i]=useState(""),p=useRef(null),l=c==="es"?Zm.es:Zm.en;if(useEffect(()=>{if(!e)return;let b=setTimeout(()=>{let u=m=>{p.current&&!p.current.contains(m.target)&&t();},x=m=>{m.key==="Escape"&&t();};document.addEventListener("mousedown",u),document.addEventListener("keydown",x),p._cleanup=()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",x);};},100);return ()=>{clearTimeout(b),p._cleanup&&p._cleanup();}},[e,t]),!e)return null;let f=b=>l.columns[b]||b,y=b=>{if(b==="name")return;let u=a.map(x=>x.id===b?{...x,visible:!x.visible}:x);o(u);},k=(b,u)=>{let x=a.find(N=>N.type===b&&(!u||N.customFieldId===u));if(x){y(x.id);return}let m={id:u||b,type:b,label:u?r.find(N=>N.id===u)?.name||b:f(b),width:120,visible:true,sortable:true,resizable:true,customFieldId:u};o([...a,m]);},C=Iy.filter(b=>f(b).toLowerCase().includes(g.toLowerCase())),h=r.filter(b=>b.name.toLowerCase().includes(g.toLowerCase()));return jsxs("div",{ref:p,className:d("absolute right-0 top-full mt-1 w-72 rounded-lg shadow-xl border z-50",n?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:[jsxs("div",{className:d("flex items-center justify-between px-4 py-3 border-b",n?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("font-medium",n?"text-white":"text-gray-900"),children:l.title}),jsx("button",{onClick:t,className:d("p-1 rounded",n?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(X,{className:d("w-4 h-4",n?"text-[#9CA3AF]":"text-gray-400")})})]}),jsx("div",{className:"p-3",children:jsxs("div",{className:"relative",children:[jsx(Search,{className:d("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",n?"text-[#6B7280]":"text-gray-400")}),jsx("input",{type:"text",value:g,onChange:b=>i(b.target.value),placeholder:l.searchPlaceholder,className:d("w-full pl-9 pr-3 py-2 text-sm rounded-lg border outline-none",n?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400")})]})}),jsxs("div",{className:"px-3 pb-2",children:[jsx("h4",{className:d("text-xs font-medium uppercase tracking-wider mb-2",n?"text-[#6B7280]":"text-gray-400"),children:l.standardFields}),jsx("div",{className:"space-y-1",children:C.map(b=>{let u=a.find(N=>N.type===b&&!N.customFieldId),x=u?.visible??false,m=b==="name";return jsxs("button",{onClick:()=>{m||(u?y(u.id):k(b));},disabled:m,className:d("w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors",n?"hover:bg-white/10":"hover:bg-gray-100",m&&"opacity-50 cursor-not-allowed"),children:[jsx("div",{className:d("w-5 h-5 rounded border flex items-center justify-center",x?"bg-[#3B82F6] border-[#3B82F6]":n?"border-[#4B5563]":"border-gray-300"),children:x&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsx("span",{className:n?"text-[#9CA3AF]":"text-gray-400",children:Jm[b]}),jsx("span",{className:n?"text-white":"text-gray-900",children:f(b)})]},b)})})]}),h.length>0&&jsxs("div",{className:"px-3 pb-2",children:[jsx("h4",{className:d("text-xs font-medium uppercase tracking-wider mb-2",n?"text-[#6B7280]":"text-gray-400"),children:l.customFields}),jsx("div",{className:"space-y-1",children:h.map(b=>{let x=a.find(m=>m.customFieldId===b.id)?.visible??false;return jsxs("button",{onClick:()=>k(b.type,b.id),className:d("w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors",n?"hover:bg-white/10":"hover:bg-gray-100"),children:[jsx("div",{className:d("w-5 h-5 rounded border flex items-center justify-center",x?"bg-[#3B82F6] border-[#3B82F6]":n?"border-[#4B5563]":"border-gray-300"),children:x&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsx("span",{className:n?"text-[#9CA3AF]":"text-gray-400",children:Jm[b.type]||jsx(Type,{className:"w-4 h-4"})}),jsx("span",{className:n?"text-white":"text-gray-900",children:b.name})]},b.id)})})]}),s&&jsx("div",{className:d("p-3 border-t",n?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:s,className:d("w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-colors",n?"bg-[#3B82F6]/20 text-[#3B82F6] hover:bg-[#3B82F6]/30":"bg-blue-50 text-blue-600 hover:bg-blue-100"),children:[jsx(Plus,{className:"w-4 h-4"}),l.createField]})})]})}var Zm={en:{title:"Columns",searchPlaceholder:"Search fields...",standardFields:"Standard Fields",customFields:"Custom Fields",createField:"Create custom field",columns:{name:"Name",status:"Status",priority:"Priority",assignees:"Assignees",startDate:"Start Date",endDate:"End Date",progress:"Progress",tags:"Tags",text:"Text",number:"Number",date:"Date",dropdown:"Dropdown",checkbox:"Checkbox"}},es:{title:"Columnas",searchPlaceholder:"Buscar campos...",standardFields:"Campos Est\xE1ndar",customFields:"Campos Personalizados",createField:"Crear campo personalizado",columns:{name:"Nombre",status:"Estado",priority:"Prioridad",assignees:"Asignados",startDate:"Fecha Inicio",endDate:"Fecha Fin",progress:"Progreso",tags:"Etiquetas",text:"Texto",number:"N\xFAmero",date:"Fecha",dropdown:"Lista",checkbox:"Casilla"}}};var Gy=[{type:"text",icon:jsx(Type,{className:"w-5 h-5"})},{type:"number",icon:jsx(Hash,{className:"w-5 h-5"})},{type:"date",icon:jsx(Calendar,{className:"w-5 h-5"})},{type:"dropdown",icon:jsx(ChevronDown,{className:"w-5 h-5"})},{type:"checkbox",icon:jsx(CheckSquare,{className:"w-5 h-5"})}];function ap({isOpen:e,onClose:t,onSave:a,isDark:r,locale:o}){let[s,n]=useState(""),[c,g]=useState("text"),[i,p]=useState([""]),l=o==="es"?tp.es:tp.en;useEffect(()=>{e&&(n(""),g("text"),p([""]));},[e]),useEffect(()=>{let h=b=>{b.key==="Escape"&&t();};return e&&document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,t]);let f=()=>{if(!s.trim())return;let h={name:s.trim(),type:c};c==="dropdown"&&(h.options=i.filter(b=>b.trim())),a(h),t();},y=()=>{p([...i,""]);},k=(h,b)=>{let u=[...i];u[h]=b,p(u);},C=h=>{i.length>1&&p(i.filter((b,u)=>u!==h));};return e?jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),jsxs("div",{className:d("relative w-full max-w-md rounded-xl shadow-2xl border",r?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:[jsxs("div",{className:d("flex items-center justify-between px-6 py-4 border-b",r?"border-white/10":"border-gray-200"),children:[jsx("h2",{className:d("text-lg font-semibold",r?"text-white":"text-gray-900"),children:l.title}),jsx("button",{onClick:t,className:d("p-1 rounded",r?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(X,{className:d("w-5 h-5",r?"text-[#9CA3AF]":"text-gray-400")})})]}),jsxs("div",{className:"p-6 space-y-6",children:[jsxs("div",{children:[jsx("label",{className:d("block text-sm font-medium mb-2",r?"text-white":"text-gray-900"),children:l.fieldName}),jsx("input",{type:"text",value:s,onChange:h=>n(h.target.value),placeholder:l.fieldNamePlaceholder,className:d("w-full px-4 py-2.5 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",r?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400"),autoFocus:true})]}),jsxs("div",{children:[jsx("label",{className:d("block text-sm font-medium mb-2",r?"text-white":"text-gray-900"),children:l.fieldType}),jsx("div",{className:"grid grid-cols-5 gap-2",children:Gy.map(h=>jsxs("button",{onClick:()=>g(h.type),className:d("flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors",c===h.type?"border-[#3B82F6] bg-[#3B82F6]/10":r?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300"),children:[jsx("span",{className:c===h.type?"text-[#3B82F6]":r?"text-[#9CA3AF]":"text-gray-400",children:h.icon}),jsx("span",{className:d("text-xs",c===h.type?"text-[#3B82F6]":r?"text-[#9CA3AF]":"text-gray-500"),children:l.types[h.type]})]},h.type))})]}),c==="dropdown"&&jsxs("div",{children:[jsx("label",{className:d("block text-sm font-medium mb-2",r?"text-white":"text-gray-900"),children:l.options}),jsxs("div",{className:"space-y-2",children:[i.map((h,b)=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"text",value:h,onChange:u=>k(b,u.target.value),placeholder:`${l.option} ${b+1}`,className:d("flex-1 px-3 py-2 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",r?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-50 border-gray-200 text-gray-900 placeholder:text-gray-400")}),i.length>1&&jsx("button",{onClick:()=>C(b),className:d("p-2 rounded-lg transition-colors",r?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-400"),children:jsx(Trash2,{className:"w-4 h-4"})})]},b)),jsxs("button",{onClick:y,className:d("flex items-center gap-2 px-3 py-2 text-sm rounded-lg transition-colors",r?"text-[#3B82F6] hover:bg-white/10":"text-blue-600 hover:bg-gray-100"),children:[jsx(Plus,{className:"w-4 h-4"}),l.addOption]})]})]})]}),jsxs("div",{className:d("flex items-center justify-end gap-3 px-6 py-4 border-t",r?"border-white/10":"border-gray-200"),children:[jsx("button",{onClick:t,className:d("px-4 py-2 text-sm font-medium rounded-lg transition-colors",r?"text-[#9CA3AF] hover:bg-white/10":"text-gray-600 hover:bg-gray-100"),children:l.cancel}),jsx("button",{onClick:f,disabled:!s.trim(),className:d("px-4 py-2 text-sm font-medium rounded-lg transition-colors","bg-[#3B82F6] text-white hover:bg-[#2563EB]",!s.trim()&&"opacity-50 cursor-not-allowed"),children:l.create})]})]})]}):null}var tp={en:{title:"Create Custom Field",fieldName:"Field Name",fieldNamePlaceholder:"Enter field name...",fieldType:"Field Type",options:"Options",option:"Option",addOption:"Add option",cancel:"Cancel",create:"Create Field",types:{text:"Text",number:"Number",date:"Date",dropdown:"Dropdown",checkbox:"Checkbox"}},es:{title:"Crear Campo Personalizado",fieldName:"Nombre del Campo",fieldNamePlaceholder:"Ingresa el nombre...",fieldType:"Tipo de Campo",options:"Opciones",option:"Opci\xF3n",addOption:"Agregar opci\xF3n",cancel:"Cancelar",create:"Crear Campo",types:{text:"Texto",number:"N\xFAmero",date:"Fecha",dropdown:"Lista",checkbox:"Casilla"}}};var op={en:{filters:"Filters",filterByStatus:"FILTER BY STATUS",showAll:"Show All",completed:"Completed",inProgress:"In Progress",toDo:"To Do / Pending",hideCompleted:"Hide Completed Tasks"},es:{filters:"Filtros",filterByStatus:"FILTRAR POR ESTADO",showAll:"Mostrar Todo",completed:"Completadas",inProgress:"En Progreso",toDo:"Por Hacer / Pendiente",hideCompleted:"Ocultar Tareas Completadas"}};function np({value:e,hideCompleted:t,onChange:a,onHideCompletedChange:r,isDark:o,locale:s}){let[n,c]=useState(false),g=useRef(null),i=s==="es"?op.es:op.en;useEffect(()=>{if(!n)return;let f=setTimeout(()=>{let y=C=>{g.current&&!g.current.contains(C.target)&&c(false);},k=C=>{C.key==="Escape"&&c(false);};document.addEventListener("mousedown",y),document.addEventListener("keydown",k),g._cleanup=()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",k);};},100);return ()=>{clearTimeout(f),g._cleanup&&g._cleanup();}},[n]);let p=[{value:"all",label:i.showAll,icon:jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#3B82F6] bg-[#3B82F6]"}),color:"text-[#3B82F6]"},{value:"completed",label:i.completed,icon:jsx(CheckCircle2,{className:"w-4 h-4"}),color:"text-green-500"},{value:"in-progress",label:i.inProgress,icon:jsx(PlayCircle,{className:"w-4 h-4"}),color:"text-blue-500"},{value:"todo",label:i.toDo,icon:jsx(Circle,{className:"w-4 h-4"}),color:"text-gray-400"}],l=e!=="all"||t;return jsxs("div",{ref:g,className:"relative",children:[jsxs("button",{onClick:f=>{f.stopPropagation(),c(y=>!y);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors border",o?"border-white/10 hover:bg-white/10 text-white":"border-gray-200 hover:bg-gray-100 text-gray-700",l&&(o?"bg-[#3B82F6]/20 border-[#3B82F6]/50 text-[#3B82F6]":"bg-blue-50 border-blue-200 text-blue-600"),n&&(o?"bg-white/10":"bg-gray-100")),children:[jsx(Filter,{className:"w-4 h-4"}),i.filters,l&&jsx("span",{className:d("w-2 h-2 rounded-full",o?"bg-[#3B82F6]":"bg-blue-500")})]}),n&&jsxs("div",{className:d("absolute left-0 top-full mt-2 w-72 rounded-lg shadow-xl border z-50",o?"bg-[#0F1117] border-white/10":"bg-white border-gray-200"),children:[jsx("div",{className:d("px-4 py-3 border-b",o?"border-white/10":"border-gray-200"),children:jsx("span",{className:d("text-xs font-medium uppercase tracking-wider",o?"text-[#6B7280]":"text-gray-400"),children:i.filterByStatus})}),jsx("div",{className:"py-2",children:p.map(f=>{let y=e===f.value&&!t,k=()=>f.value==="all"?y?jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#3B82F6] bg-[#3B82F6]"}):jsx("div",{className:"w-4 h-4 rounded-full border-2 border-gray-400"}):f.icon;return jsxs("button",{onClick:()=>{a(f.value),r(false);},className:d("w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors",o?"hover:bg-white/10":"hover:bg-gray-100",y&&(o?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d(y?f.color:"text-gray-400","flex-shrink-0"),children:k()}),jsx("span",{className:d("flex-1 text-left whitespace-nowrap",o?"text-white":"text-gray-900"),children:f.label}),y&&jsx(Check,{className:d("w-4 h-4 flex-shrink-0",o?"text-[#3B82F6]":"text-blue-500")})]},f.value)})}),jsx("div",{className:d("my-2 mx-4 h-px",o?"bg-white/10":"bg-gray-200")}),jsx("div",{className:"py-1",children:jsxs("button",{onClick:()=>{r(!t),t||a("all");},className:d("w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors",o?"hover:bg-white/10":"hover:bg-gray-100",t&&(o?"bg-white/5":"bg-gray-50")),children:[jsx(EyeOff,{className:d("w-4 h-4 flex-shrink-0",t?o?"text-[#3B82F6]":"text-blue-500":o?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("flex-1 text-left whitespace-nowrap",o?"text-white":"text-gray-900"),children:i.hideCompleted}),t&&jsx(Check,{className:d("w-4 h-4 flex-shrink-0",o?"text-[#3B82F6]":"text-blue-500")})]})})]})]})}var dv=[{id:"name",type:"name",label:"Name",width:300,visible:true,sortable:true,resizable:true},{id:"status",type:"status",label:"Status",width:120,visible:true,sortable:true,resizable:true},{id:"startDate",type:"startDate",label:"Start Date",width:120,visible:true,sortable:true,resizable:true},{id:"endDate",type:"endDate",label:"End Date",width:120,visible:true,sortable:true,resizable:true},{id:"progress",type:"progress",label:"Progress",width:100,visible:true,sortable:true,resizable:true}];function lp(e,t=0){let a=[];for(let r of e)a.push({...r,level:t,hasChildren:(r.subtasks?.length||0)>0,parentPath:[r.id]}),r.subtasks?.length&&r.isExpanded!==false&&a.push(...lp(r.subtasks,t+1));return a}function cv({status:e,progress:t}){return t===100||e==="completed"?jsx(CheckCircle2,{className:"w-5 h-5 text-green-500"}):t&&t>0||e==="in-progress"?jsx(PlayCircle,{className:"w-5 h-5 text-blue-500"}):jsx(Circle,{className:"w-5 h-5 text-gray-400"})}function dp({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:n,availableUsers:c=[],customFields:g=[]}){let{theme:i="dark",locale:p="en",customTranslations:l,showSearch:f=true,showHierarchy:y=true,tableColumns:k,allowColumnCustomization:C=true,allowColumnResize:h=true,enableContextMenu:b=true}=t,u=is(p,l),x=i==="dark",[m,N]=useState("startDate"),[w,B]=useState("asc"),[v,I]=useState(""),[F,T]=useState("all"),[H,O]=useState(false),[K,ae]=useState(k||dv),[ne,oe]=useState(false),[ye,fe]=useState(false),[Re,A]=useState({isOpen:false,x:0,y:0,type:"task"}),[R,L]=useState(null),[j,J]=useState(0),[U,ge]=useState(0),le=useRef(null);useEffect(()=>{k&&ae(k);},[k]);let Fe=useMemo(()=>{let Z=new Set;function xe(ze){for(let Be of ze)Be.subtasks?.length&&(Be.isExpanded!==false&&Z.add(Be.id),xe(Be.subtasks));}return xe(e),Z},[e]),qe=useMemo(()=>K.filter(Z=>Z.visible),[K]),et=useCallback(Z=>{a.onTaskToggleExpand?.(Z);},[a]),de=useCallback(Z=>{m===Z?B(xe=>xe==="asc"?"desc":"asc"):(N(Z),B("asc")),a.onSortChange?.({column:Z,direction:w==="asc"?"desc":"asc"});},[m,w,a]),Ke=useCallback(Z=>{ae(Z),a.onColumnsChange?.(Z);},[a]),dt=useCallback(Z=>{let xe=K.map(ze=>ze.id===Z?{...ze,visible:false}:ze);Ke(xe);},[K,Ke]),vt=useCallback((Z,xe)=>{N(Z),B(xe);},[]),kt=useCallback((Z,xe,ze)=>{b&&(Z.preventDefault(),A({isOpen:true,x:Z.clientX,y:Z.clientY,type:xe?"task":"header",task:xe,columnId:ze}));},[b]),$=useCallback(()=>{A(Z=>({...Z,isOpen:false}));},[]),me=useCallback((Z,xe)=>{if(!h)return;Z.preventDefault(),Z.stopPropagation();let ze=K.find(Be=>Be.id===xe);ze&&(L(xe),J(Z.clientX),ge(ze.width));},[K,h]);useEffect(()=>{if(!R)return;let Z=ze=>{let Be=ze.clientX-j,st=Math.max(50,U+Be),nt=K.map(Ve=>Ve.id===R?{...Ve,width:st}:Ve);ae(nt);},xe=()=>{R&&a.onColumnsChange?.(K),L(null);};return document.addEventListener("mousemove",Z),document.addEventListener("mouseup",xe),()=>{document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",xe);}},[R,j,U,K,a]);let Le=useCallback(async Z=>{if(a.onCreateCustomField){let xe={...Z,id:`cf_${Date.now()}`,projectId:""};await a.onCreateCustomField(xe);}fe(false);},[a]),Se=useCallback(Z=>Z.progress===100||Z.status==="completed"?"completed":Z.progress&&Z.progress>0||Z.status==="in-progress"?"in-progress":"todo",[]),Ye=useMemo(()=>{let Z=lp(e);if(v.trim()){let xe=v.toLowerCase();Z=Z.filter(ze=>ze.name.toLowerCase().includes(xe));}return F!=="all"&&(Z=Z.filter(xe=>Se(xe)===F)),H&&(Z=Z.filter(xe=>Se(xe)!=="completed")),Z.sort((xe,ze)=>{let Be,st;switch(m){case "name":Be=xe.name.toLowerCase(),st=ze.name.toLowerCase();break;case "startDate":Be=xe.startDate?.getTime()||0,st=ze.startDate?.getTime()||0;break;case "endDate":Be=xe.endDate?.getTime()||0,st=ze.endDate?.getTime()||0;break;case "progress":Be=xe.progress||0,st=ze.progress||0;break;case "status":Be=xe.status||"todo",st=ze.status||"todo";break;case "priority":let nt={urgent:0,high:1,medium:2,low:3,none:4};Be=nt[xe.priority]??4,st=nt[ze.priority]??4;break;default:return 0}return Be<st?w==="asc"?-1:1:Be>st?w==="asc"?1:-1:0}),Z},[e,v,F,H,m,w,Se]),Je=useCallback((Z,xe)=>{let ze=nt=>{a.onTaskUpdate?.({...Z,...nt});},Be=nt=>nt?Z.customFields?.find(Vt=>Vt.fieldId===nt)?.value:void 0,st=(nt,Ve)=>{if(!nt)return;let Bt=[...Z.customFields||[]],Ze=Bt.findIndex(te=>te.fieldId===nt);Ze>=0?Bt[Ze]={fieldId:nt,value:Ve}:Bt.push({fieldId:nt,value:Ve}),ze({customFields:Bt});};switch(xe.type){case "name":return null;case "status":return jsx(Tm,{value:Z.status||(Z.progress===100?"completed":Z.progress&&Z.progress>0?"in-progress":"todo"),onChange:Ve=>{ze({status:Ve,progress:Ve==="completed"?100:Ve==="in-progress"?50:0});},isDark:x,locale:p,translations:u.status});case "priority":return jsx(Dm,{value:Z.priority,onChange:Ve=>ze({priority:Ve}),isDark:x,locale:p});case "assignees":return jsx(Em,{value:Z.assignees||[],availableUsers:c,onChange:Ve=>ze({assignees:Ve}),isDark:x,locale:p});case "startDate":return jsx(ps,{value:Z.startDate,onChange:Ve=>ze({startDate:Ve}),isDark:x,locale:p});case "endDate":return jsx(ps,{value:Z.endDate,onChange:Ve=>ze({endDate:Ve}),isDark:x,locale:p});case "progress":return jsx(Fm,{value:Z.progress||0,onChange:Ve=>{let Vt=Ve===100?"completed":Ve>0?"in-progress":"todo";ze({progress:Ve,status:Vt});},isDark:x});case "tags":return jsx(_m,{value:Z.tags||[],isDark:x});case "text":return jsx(Bm,{value:Be(xe.customFieldId)||"",onChange:Ve=>st(xe.customFieldId,Ve),isDark:x});case "number":return jsx($m,{value:Be(xe.customFieldId)||0,onChange:Ve=>st(xe.customFieldId,Ve),isDark:x});case "date":let nt=Be(xe.customFieldId);return jsx(ps,{value:nt?new Date(nt):void 0,onChange:Ve=>st(xe.customFieldId,Ve),isDark:x,locale:p});case "dropdown":return jsx(Um,{value:Be(xe.customFieldId)||"",options:xe.options||[],onChange:Ve=>st(xe.customFieldId,Ve),isDark:x});case "checkbox":return jsx(Hm,{value:Be(xe.customFieldId)||false,onChange:Ve=>st(xe.customFieldId,Ve),isDark:x});default:return jsx("span",{className:d("text-sm",x?"text-[#94A3B8]":"text-gray-500"),children:"-"})}},[a,x,p,c,u]),Pt=useCallback(Z=>({name:u.columns.name,status:u.columns.status,priority:u.columns.priority,assignees:u.columns.assignees,startDate:u.columns.startDate,endDate:u.columns.endDate,progress:u.columns.progress})[Z.type]||Z.label,[u]),Oe=useMemo(()=>qe.reduce((Z,xe)=>Z+xe.width,0)+(C?48:0),[qe,C]);return r?jsx("div",{className:d("flex-1 flex items-center justify-center",x?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:d("text-sm",x?"text-[#9CA3AF]":"text-gray-600"),children:[u.empty.noTasks,"..."]})]})}):o?jsx("div",{className:d("flex-1 flex items-center justify-center",x?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:d("text-lg font-semibold mb-2",x?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:d("text-sm",x?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:d("flex-1 flex items-center justify-center",x?"bg-[#0F1117]":"bg-white",s),style:n,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(List,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:d("text-lg font-semibold mb-2",x?"text-white":"text-gray-900"),children:u.empty.noTasks}),jsx("p",{className:d("text-sm",x?"text-[#9CA3AF]":"text-gray-600"),children:u.empty.addFirstTask})]})}):jsxs("div",{ref:le,className:d("flex-1 flex flex-col w-full h-full overflow-hidden",x?"bg-[#0F1117]":"bg-white",R&&"select-none",s),style:n,children:[jsx("div",{className:d("flex-shrink-0 px-6 py-4 border-b",x?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[jsx(np,{value:F,hideCompleted:H,onChange:T,onHideCompletedChange:O,isDark:x,locale:p}),f&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:d("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",x?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:v,onChange:Z=>I(Z.target.value),placeholder:u.toolbar.searchPlaceholder,className:d("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",x?"bg-white/5 border-white/10 text-white placeholder:text-[#6B7280]":"bg-gray-100 border-gray-200 text-gray-900 placeholder:text-gray-400")})]}),jsxs("div",{className:d("text-sm",x?"text-[#9CA3AF]":"text-gray-600"),children:[Ye.length," ",u.pagination.tasks]})]})}),jsx("div",{className:"flex-1 overflow-auto",children:jsxs("div",{style:{minWidth:Oe},children:[jsxs("div",{className:d("flex-shrink-0 flex items-center border-b text-xs font-medium uppercase tracking-wider sticky top-0 z-10",x?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[qe.map(Z=>jsxs("div",{className:d("relative flex items-center gap-2 px-4 py-3",x?"text-[#9CA3AF]":"text-gray-500"),style:{width:Z.width,minWidth:Z.minWidth},onContextMenu:xe=>kt(xe,void 0,Z.id),children:[Z.sortable?jsxs("button",{onClick:()=>de(Z.id),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[Pt(Z),jsx(ArrowUpDown,{className:d("w-3 h-3",m===Z.id&&"text-[#3B82F6]")})]}):jsx("span",{children:Pt(Z)}),h&&Z.resizable&&jsx("div",{className:d("absolute right-0 top-0 bottom-0 w-1 cursor-col-resize group","hover:bg-[#3B82F6]",R===Z.id&&"bg-[#3B82F6]"),onMouseDown:xe=>me(xe,Z.id)})]},Z.id)),C&&jsxs("div",{className:"relative flex items-center justify-center px-3 py-3",children:[jsx("button",{onClick:Z=>{Z.stopPropagation(),oe(xe=>!xe);},className:d("p-1.5 rounded-lg transition-colors",x?"hover:bg-white/10 text-[#9CA3AF] hover:text-white":"hover:bg-gray-200 text-gray-400 hover:text-gray-600",ne&&(x?"bg-white/10":"bg-gray-200")),title:p==="es"?"Agregar columna":"Add column",children:jsx(Plus,{className:"w-4 h-4"})}),jsx(Qm,{isOpen:ne,onClose:()=>oe(false),columns:K,customFields:g,onColumnsChange:Ke,onCreateCustomField:()=>{oe(false),fe(true);},isDark:x,locale:p})]})]}),jsx(AnimatePresence,{children:Ye.map((Z,xe)=>{let ze=Fe.has(Z.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:xe*.02},className:d("flex items-center border-b transition-colors",x?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),onClick:()=>a.onTaskClick?.(Z),onDoubleClick:()=>a.onTaskDoubleClick?.(Z),onContextMenu:Be=>kt(Be,Z),children:[qe.map(Be=>jsx("div",{className:"flex items-center px-4 py-3 min-h-[52px]",style:{width:Be.width,minWidth:Be.minWidth},children:Be.type==="name"?jsxs("div",{className:"flex items-center gap-2 min-w-0 w-full",children:[y&&Z.level>0&&jsx("div",{style:{width:`${Z.level*24}px`},className:"flex-shrink-0"}),y&&Z.hasChildren&&jsx("button",{onClick:st=>{st.stopPropagation(),et(Z.id);},className:d("p-0.5 rounded flex-shrink-0",x?"hover:bg-white/10":"hover:bg-gray-200"),children:ze?jsx(ChevronDown,{className:d("w-4 h-4",x?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:d("w-4 h-4",x?"text-[#9CA3AF]":"text-gray-400")})}),y&&!Z.hasChildren&&jsx("div",{className:"w-5 flex-shrink-0"}),jsx("button",{onClick:st=>{st.stopPropagation(),a.onTaskUpdate?.({...Z,progress:Z.progress===100?0:100,status:Z.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(cv,{status:Z.status,progress:Z.progress})}),jsx("span",{className:d("truncate font-medium",x?"text-white":"text-gray-900",Z.progress===100&&(x?"line-through text-[#6B7280]":"line-through text-gray-400")),children:Z.name})]}):Je(Z,Be)},Be.id)),C&&jsx("div",{className:"w-12 flex-shrink-0"})]},Z.id)})}),Ye.length===0&&v&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:d("w-12 h-12 mx-auto mb-4",x?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:d(x?"text-[#9CA3AF]":"text-gray-600"),children:u.empty.noResults})]})})]})}),jsx(Ym,{state:Re,onClose:$,isDark:x,locale:p,onTaskEdit:a.onTaskEdit,onTaskDuplicate:a.onTaskDuplicate,onTaskDelete:a.onTaskDelete,onTaskUpdate:a.onTaskUpdate,onColumnHide:dt,onColumnSort:vt,availableUsers:c}),jsx(ap,{isOpen:ye,onClose:()=>fe(false),onSave:Le,isDark:x,locale:p})]})}var cp=[{id:"name",type:"name",label:"Name",width:300,visible:true,sortable:true,resizable:true},{id:"status",type:"status",label:"Status",width:120,visible:true,sortable:true,resizable:true},{id:"priority",type:"priority",label:"Priority",width:100,visible:false,sortable:true,resizable:true},{id:"assignees",type:"assignees",label:"Assignees",width:150,visible:false,sortable:false,resizable:true},{id:"startDate",type:"startDate",label:"Start Date",width:120,visible:true,sortable:true,resizable:true},{id:"endDate",type:"endDate",label:"End Date",width:120,visible:true,sortable:true,resizable:true},{id:"progress",type:"progress",label:"Progress",width:100,visible:true,sortable:true,resizable:true},{id:"tags",type:"tags",label:"Tags",width:150,visible:false,sortable:false,resizable:true}],mp=[{type:"name",labelKey:"columns.name",icon:"Type"},{type:"status",labelKey:"columns.status",icon:"CircleDot"},{type:"priority",labelKey:"columns.priority",icon:"Flag"},{type:"assignees",labelKey:"columns.assignees",icon:"Users"},{type:"startDate",labelKey:"columns.startDate",icon:"Calendar"},{type:"endDate",labelKey:"columns.endDate",icon:"CalendarCheck"},{type:"progress",labelKey:"columns.progress",icon:"BarChart"},{type:"tags",labelKey:"columns.tags",icon:"Tag"}],pp=[{type:"text",labelKey:"customFields.text",icon:"Type"},{type:"number",labelKey:"customFields.number",icon:"Hash"},{type:"date",labelKey:"customFields.date",icon:"Calendar"},{type:"dropdown",labelKey:"customFields.dropdown",icon:"ChevronDown"},{type:"checkbox",labelKey:"customFields.checkbox",icon:"CheckSquare"}];var ul={bgPrimary:"#0d1117",bgSecondary:"#161b22",bgHover:"#21262d",bgSelected:"#1f6feb20",bgAlternate:"#0d111780",border:"#30363d",borderLight:"#21262d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#6e7681",accent:"#58a6ff",accentHover:"#79b8ff",accentLight:"#58a6ff20",statusTodo:"#8b949e",statusInProgress:"#f0883e",statusCompleted:"#3fb950",focusRing:"#58a6ff",checkboxBg:"#21262d",checkboxChecked:"#58a6ff"},gl={bgPrimary:"#ffffff",bgSecondary:"#f6f8fa",bgHover:"#f3f4f6",bgSelected:"#dbeafe",bgAlternate:"#f9fafb",border:"#d0d7de",borderLight:"#e5e7eb",textPrimary:"#24292f",textSecondary:"#57606a",textMuted:"#8b949e",accent:"#0969da",accentHover:"#0550ae",accentLight:"#dbeafe",statusTodo:"#8b949e",statusInProgress:"#bf8700",statusCompleted:"#1a7f37",focusRing:"#0969da",checkboxBg:"#ffffff",checkboxChecked:"#0969da"},fl={bgPrimary:"#1a1a2e",bgSecondary:"#16213e",bgHover:"#1f3460",bgSelected:"#0f4c7520",bgAlternate:"#1a1a2e80",border:"#2a3f5f",borderLight:"#1f3460",textPrimary:"#e4e6eb",textSecondary:"#a8b2c1",textMuted:"#6b7280",accent:"#6366f1",accentHover:"#818cf8",accentLight:"#6366f120",statusTodo:"#9ca3af",statusInProgress:"#fbbf24",statusCompleted:"#34d399",focusRing:"#6366f1",checkboxBg:"#1f3460",checkboxChecked:"#6366f1"},fs={dark:ul,light:gl,neutral:fl};function up(e){return fs[e]||fs.dark}var bl={navigation:{today:"Today",previous:"Previous",next:"Next",month:"Month",week:"Week",day:"Day"},weekdays:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},weekdaysFull:{sunday:"Sunday",monday:"Monday",tuesday:"Tuesday",wednesday:"Wednesday",thursday:"Thursday",friday:"Friday",saturday:"Saturday"},months:{january:"January",february:"February",march:"March",april:"April",may:"May",june:"June",july:"July",august:"August",september:"September",october:"October",november:"November",december:"December"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{allDay:"All day",moreEvents:"+{count} more",noEvents:"No tasks",newTask:"New Task",viewAll:"View all",week:"Week"},tooltips:{progress:"Progress",status:"Status",assignees:"Assignees",duration:"Duration",days:"days"}},hl={navigation:{today:"Hoy",previous:"Anterior",next:"Siguiente",month:"Mes",week:"Semana",day:"D\xEDa"},weekdays:{sun:"Dom",mon:"Lun",tue:"Mar",wed:"Mi\xE9",thu:"Jue",fri:"Vie",sat:"S\xE1b"},weekdaysFull:{sunday:"Domingo",monday:"Lunes",tuesday:"Martes",wednesday:"Mi\xE9rcoles",thursday:"Jueves",friday:"Viernes",saturday:"S\xE1bado"},months:{january:"Enero",february:"Febrero",march:"Marzo",april:"Abril",may:"Mayo",june:"Junio",july:"Julio",august:"Agosto",september:"Septiembre",october:"Octubre",november:"Noviembre",december:"Diciembre"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{allDay:"Todo el d\xEDa",moreEvents:"+{count} m\xE1s",noEvents:"Sin tareas",newTask:"Nueva Tarea",viewAll:"Ver todo",week:"Semana"},tooltips:{progress:"Progreso",status:"Estado",assignees:"Asignados",duration:"Duraci\xF3n",days:"d\xEDas"}},bs={en:bl,es:hl};function ln(e){return bs[e]||bs.en}function hs(e,t){let a=ln(e);return t?{navigation:{...a.navigation,...t.navigation},weekdays:{...a.weekdays,...t.weekdays},weekdaysFull:{...a.weekdaysFull,...t.weekdaysFull},months:{...a.months,...t.months},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},tooltips:{...a.tooltips,...t.tooltips}}:a}function gp(e){let t=ln(e);return [t.months.january,t.months.february,t.months.march,t.months.april,t.months.may,t.months.june,t.months.july,t.months.august,t.months.september,t.months.october,t.months.november,t.months.december]}function fp(e,t=0,a=true){let r=ln(e),o=a?[r.weekdays.sun,r.weekdays.mon,r.weekdays.tue,r.weekdays.wed,r.weekdays.thu,r.weekdays.fri,r.weekdays.sat]:[r.weekdaysFull.sunday,r.weekdaysFull.monday,r.weekdaysFull.tuesday,r.weekdaysFull.wednesday,r.weekdaysFull.thursday,r.weekdaysFull.friday,r.weekdaysFull.saturday];return [...o.slice(t),...o.slice(0,t)]}function Pv(e){let t=[];function a(r){for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);}return a(e),t}function Cl(e,t){if(!t.startDate||!t.endDate)return false;let a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.startDate.getFullYear(),t.startDate.getMonth(),t.startDate.getDate()),o=new Date(t.endDate.getFullYear(),t.endDate.getMonth(),t.endDate.getDate());return a>=r&&a<=o}function xp({task:e}){return e.progress===100||e.status==="completed"?jsx(CheckCircle2,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):e.progress&&e.progress>0||e.status==="in-progress"?jsx(PlayCircle,{className:"w-3 h-3 text-blue-500 flex-shrink-0"}):jsx(Circle,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})}function wp({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:n,style:c,availableTags:g=[],onCreateTag:i,attachmentsByTask:p,comments:l,onAddComment:f,currentUser:y,mentionableUsers:k,onTaskOpen:C}){let{theme:h="dark",locale:b="en",customTranslations:u}=t,x=hs(b,u),m=h==="dark",N={textTertiary:m?"#6B7280":"#9CA3AF",textSecondary:m?"#9CA3AF":"#6B7280",textPrimary:m?"#FFFFFF":"#111827",borderLight:m?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:m?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:m?"#1A1D25":"#FFFFFF",bgSecondary:m?"#0F1117":"#F9FAFB",hoverBg:m?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},[w,B]=useState(r||new Date),[v,I]=useState(null),[F,T]=useState(null),[H,O]=useState(null),[K,ae]=useState(new Date),[ne,oe]=useState({}),ye=4,fe=3,[Re,A]=useState(false),[R,L]=useState(false),[j,J]=useState(false),[U,ge]=useState(false),[le,Fe]=useState(null),[qe,et]=useState(""),[de,Ke]=useState(void 0),[dt,vt]=useState(null),[kt,$]=useState(false),[me,Le]=useState(false),[Se,Ye]=useState(null),[Je,Pt]=useState(false),[Oe,Z]=useState(new Date),[xe,ze]=useState(false),[Be,st]=useState(false),[nt,Ve]=useState(false),[Vt,Bt]=useState(""),[Ze,te]=useState(false),[S,Ce]=useState(""),[X$1,we]=useState(false),ke=useCallback(()=>{B(new Date(w.getFullYear(),w.getMonth()-1,1));},[w]),He=useCallback(()=>{B(new Date(w.getFullYear(),w.getMonth()+1,1));},[w]),$e=useCallback(()=>{B(new Date);},[]),tt=useMemo(()=>{let M=w.getFullYear(),W=w.getMonth(),Ee=new Date(M,W,1),Pe=new Date(M,W+1,0),$t=Ee.getDay(),ie=Pe.getDate(),Ge=Pv(e),yt=new Date;yt.setHours(0,0,0,0);let Ue=[],gt=$t,ya=new Date(M,W,0).getDate();for(let Mt=gt-1;Mt>=0;Mt--){let Xe=new Date(M,W-1,ya-Mt);Ue.push({date:Xe,isCurrentMonth:false,isToday:false,isWeekend:Xe.getDay()===0||Xe.getDay()===6,events:Ge.filter(Yt=>Cl(Xe,Yt)).map(Yt=>({id:Yt.id,title:Yt.name,start:Yt.startDate,end:Yt.endDate,task:Yt}))});}for(let Mt=1;Mt<=ie;Mt++){let Xe=new Date(M,W,Mt),Yt=Xe.getTime()===yt.getTime();Ue.push({date:Xe,isCurrentMonth:true,isToday:Yt,isWeekend:Xe.getDay()===0||Xe.getDay()===6,events:Ge.filter(ua=>Cl(Xe,ua)).map(ua=>({id:ua.id,title:ua.name,start:ua.startDate,end:ua.endDate,task:ua}))});}let ka=42-Ue.length;for(let Mt=1;Mt<=ka;Mt++){let Xe=new Date(M,W+1,Mt);Ue.push({date:Xe,isCurrentMonth:false,isToday:false,isWeekend:Xe.getDay()===0||Xe.getDay()===6,events:Ge.filter(Yt=>Cl(Xe,Yt)).map(Yt=>({id:Yt.id,title:Yt.name,start:Yt.startDate,end:Yt.endDate,task:Yt}))});}return Ue},[w,e]),_=b==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Y=w.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),be=useCallback((M,W)=>{if(!v)return;let Ee={...v,[M]:W};I(Ee),a.onTaskUpdate?.(Ee);},[v,a]),je=useCallback(M=>{if(!v)return;let W=v.progress||0;M==="completed"?W=100:M==="todo"&&(W=0);let Ee={...v,status:M,progress:W};I(Ee),a.onTaskUpdate?.(Ee),A(false);},[v,a]),Ie=useCallback((M,W)=>{if(!v)return;let Ee={...v,startDate:M,endDate:W};I(Ee),a.onTaskUpdate?.(Ee);},[v,a]),z=useCallback(()=>{A(false),L(false),J(false),O(null),Ve(false),Bt(""),te(false);},[]),se=useCallback(async M=>{if(M.preventDefault(),M.stopPropagation(),ze(false),!v||!a.onUploadAttachments)return;let W=Array.from(M.dataTransfer.files);if(W.length!==0){st(true);try{await a.onUploadAttachments(v.id,W);}finally{st(false);}}},[v,a]),We=useCallback(async M=>{if(!v||!a.onUploadAttachments||!M.target.files)return;let W=Array.from(M.target.files);if(W.length!==0){st(true);try{await a.onUploadAttachments(v.id,W);}finally{st(false);}M.target.value="";}},[v,a]),Nt=useCallback(M=>{M.preventDefault(),M.stopPropagation(),ze(true);},[]),mt=useCallback(M=>{M.preventDefault(),M.stopPropagation(),ze(false);},[]),Dr=useCallback(M=>M<1024?`${M} B`:M<1024*1024?`${(M/1024).toFixed(1)} KB`:`${(M/(1024*1024)).toFixed(1)} MB`,[]),fr=useCallback(M=>M.startsWith("image/")?Image:M.includes("pdf")||M.includes("document")?FileText:File,[]),$a=useMemo(()=>!v||!p?[]:p.get(v.id)||[],[v,p]);return o?jsx("div",{className:d("flex-1 flex items-center justify-center",m?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4",children:[jsx("div",{className:"w-8 h-8 animate-spin rounded-full border-b-2 border-[#3B82F6]"}),jsxs("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:[x.labels.noEvents,"..."]})]})}):s?jsx("div",{className:d("flex-1 flex items-center justify-center",m?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md text-center",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:jsx("span",{className:"text-red-500 text-2xl",children:"\u26A0"})}),jsxs("div",{children:[jsx("h3",{className:d("text-lg font-semibold mb-2",m?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:d("flex-1 flex items-center justify-center",m?"bg-[#0F1117]":"bg-white",n),style:c,children:jsxs("div",{className:"text-center max-w-md",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-[#3B82F6]/10 flex items-center justify-center",children:jsx(Calendar,{className:"w-8 h-8 text-[#3B82F6]"})}),jsx("h3",{className:d("text-lg font-semibold mb-2",m?"text-white":"text-gray-900"),children:x.labels.noEvents}),jsx("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:x.labels.newTask})]})}):jsxs("div",{className:d("flex-1 flex flex-col w-full h-full overflow-auto",m?"bg-[#0F1117]":"bg-white",n),style:c,children:[jsx("div",{className:d("flex-shrink-0 px-6 py-4 border-b",m?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx("h2",{className:d("text-xl font-semibold capitalize",m?"text-white":"text-gray-900"),children:Y}),jsx("button",{onClick:$e,className:d("px-3 py-1.5 text-sm rounded-lg transition-colors",m?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:x.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:ke,className:d("p-2 rounded-lg transition-colors",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:d("w-5 h-5",m?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:He,className:d("p-2 rounded-lg transition-colors",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:d("w-5 h-5",m?"text-[#9CA3AF]":"text-gray-600")})})]})]})}),jsx("div",{className:"flex-1 p-6 min-h-0",children:jsxs("div",{className:"flex flex-col",children:[jsx("div",{className:"grid grid-cols-7 gap-px mb-2",children:_.map(M=>jsx("div",{className:d("py-2 text-center text-xs font-medium uppercase",m?"text-[#9CA3AF]":"text-gray-500"),children:M},M))}),jsx("div",{className:d("grid grid-cols-7 auto-rows-min gap-px rounded-lg",m?"bg-[#2D2D2D]":"bg-gray-300"),children:tt.map((M,W)=>{let Ee=M.date.getDay()===0||M.date.getDay()===6;return jsxs("div",{className:d("min-h-[120px] p-2 transition-colors flex flex-col relative group",m?Ee?"bg-[#1C1F26]":M.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":Ee?"bg-gray-100":M.isCurrentMonth?"bg-white":"bg-gray-50",M.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let Pe=ne[W]||ye,$t=M.events.slice(0,Pe),ie=M.events.length-Pe;return jsxs("div",{className:"space-y-1 flex-1",children:[$t.map(Ge=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{I(Ge.task),a.onEventClick?.(Ge),C?.(Ge.task.id);},whileHover:{scale:1.02},className:d("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",Ge.task.progress===100?m?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":m?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx(xp,{task:Ge.task}),jsx("span",{className:"truncate",children:Ge.title})]})},Ge.id)),ie>0&&jsxs("button",{onClick:Ge=>{Ge.stopPropagation(),oe(yt=>({...yt,[W]:Pe+fe}));},className:d("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",m?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",ie," ",b==="es"?"M\xC1S":"MORE"]}),Pe>ye&&M.events.length>ye&&jsx("button",{onClick:Ge=>{Ge.stopPropagation(),oe(yt=>({...yt,[W]:ye}));},className:d("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",m?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:b==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let Pe=W>=28,$t=W%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:ie=>{ie.stopPropagation(),le===W?Fe(null):(Fe(W),et(""),Ke(void 0),vt(null),Ye(null),$(false),Le(false),Pt(false),Z(M.date));},className:d("w-5 h-5 rounded flex items-center justify-center transition-all",le===W?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",m?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:d("w-3.5 h-3.5 transition-transform",le===W&&"rotate-45")})}),jsx(AnimatePresence,{children:le===W&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Fe(null),et(""),Ke(void 0),vt(null),Ye(null),$(false),Le(false),Pt(false);}}),jsxs(motion.div,{initial:{opacity:0,y:Pe?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:Pe?-5:5,scale:.95},transition:{duration:.12},className:d("absolute w-[320px] rounded-lg shadow-2xl z-50",Pe?"bottom-full mb-1":"top-full mt-1",$t?"right-0":"left-0",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ie=>{ie.stopPropagation(),$(false),Le(false),Pt(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:qe,onChange:ie=>et(ie.target.value),placeholder:b==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:d("w-full bg-transparent text-sm outline-none placeholder:opacity-40",m?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:ie=>{if(ie.key==="Enter"&&qe.trim()){let Ge=t.availableUsers?.find(Ue=>Ue.id===dt),yt=Se||M.date;a.onTaskCreate?.({name:qe.trim(),startDate:yt,endDate:yt,priority:de,assignees:Ge?[Ge]:void 0}),et(""),Ke(void 0),vt(null),Ye(null),Fe(null);}ie.key==="Escape"&&(Fe(null),et(""),Ke(void 0),vt(null),Ye(null));}})}),jsxs("div",{className:d("px-2.5 py-2 flex items-center justify-between border-t",m?"border-white/10":"border-gray-100"),children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs("div",{className:"relative",children:[jsx("button",{onClick:ie=>{ie.stopPropagation(),$(!kt),Le(false);},className:d("p-1 rounded transition-colors",de?de==="urgent"||de==="high"?"text-red-400 bg-red-500/20":de==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":m?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Flag,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:kt&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ie=>ie.stopPropagation(),children:[{id:"urgent",label:b==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:b==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:b==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:b==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:b==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(ie=>jsxs("button",{onClick:()=>{Ke(ie.id),$(false);},className:d("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",de===ie.id&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",ie.color)}),jsx("span",{className:m?"text-white":"text-gray-900",children:ie.label})]},ie.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:ie=>{ie.stopPropagation(),Pt(!Je),$(false),Le(false),Z(Se||M.date);},className:d("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",Se?"bg-[#7C3AED]/20 text-[#7C3AED]":m?"bg-white/5 text-[#9CA3AF] hover:bg-white/10":"bg-gray-100 text-gray-500 hover:bg-gray-200"),children:[jsx(CalendarDays,{className:"w-3 h-3"}),(Se||M.date).toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:Je&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ie=>ie.stopPropagation(),children:[jsx("div",{className:d("w-40 py-2 border-r",m?"border-white/10":"border-gray-200"),children:(()=>{let ie=new Date,Ge=new Date(ie);Ge.setDate(ie.getDate()+1);let yt=new Date(ie);yt.setDate(ie.getDate()+((6-ie.getDay()+7)%7||7));let Ue=new Date(ie);Ue.setDate(ie.getDate()+((1-ie.getDay()+7)%7||7));let gt=new Date(ie);gt.setDate(ie.getDate()+14);let ya=new Date(ie);return ya.setDate(ie.getDate()+28),[{label:b==="es"?"Hoy":"Today",date:ie,display:ie.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:b==="es"?"Ma\xF1ana":"Tomorrow",date:Ge,display:Ge.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:b==="es"?"Este fin de semana":"This weekend",date:yt,display:b==="es"?"s\xE1b.":"sat."},{label:b==="es"?"Pr\xF3xima semana":"Next week",date:Ue,display:b==="es"?"lun.":"mon."},{label:b==="es"?"2 semanas":"2 weeks",date:gt,display:gt.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:b==="es"?"4 semanas":"4 weeks",date:ya,display:ya.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Mt,Xe)=>jsxs("button",{className:d("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",m?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{Ye(Mt.date),Pt(false);},children:[jsx("span",{children:Mt.label}),jsx("span",{className:d("text-[10px]",m?"text-[#6B7280]":"text-gray-400"),children:Mt.display})]},Xe))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:d("text-xs font-medium",m?"text-white":"text-gray-900"),children:Oe.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>Z(new Date),className:d("px-1.5 py-0.5 rounded text-[10px] transition-colors",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:b==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>Z(new Date(Oe.getFullYear(),Oe.getMonth()-1)),className:d("p-0.5 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>Z(new Date(Oe.getFullYear(),Oe.getMonth()+1)),className:d("p-0.5 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:"w-3.5 h-3.5"})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:(b==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(ie=>jsx("div",{className:d("w-6 h-6 flex items-center justify-center text-[10px]",m?"text-[#6B7280]":"text-gray-400"),children:ie},ie))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let ie=Oe.getFullYear(),Ge=Oe.getMonth(),yt=new Date(ie,Ge,1).getDay(),Ue=new Date(ie,Ge+1,0).getDate(),gt=new Date(ie,Ge,0).getDate(),ya=new Date,ka=[];for(let Xe=yt-1;Xe>=0;Xe--)ka.push({dayNum:gt-Xe,isCurrentMonth:false,date:new Date(ie,Ge-1,gt-Xe)});for(let Xe=1;Xe<=Ue;Xe++)ka.push({dayNum:Xe,isCurrentMonth:true,date:new Date(ie,Ge,Xe)});let Mt=42-ka.length;for(let Xe=1;Xe<=Mt;Xe++)ka.push({dayNum:Xe,isCurrentMonth:false,date:new Date(ie,Ge+1,Xe)});return ka.map((Xe,Yt)=>{let ua=Xe.date.toDateString()===ya.toDateString(),Fr=(Se||M.date).toDateString()===Xe.date.toDateString();return jsx("button",{className:d("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!Xe.isCurrentMonth&&(m?"text-[#4B5563]":"text-gray-300"),Xe.isCurrentMonth&&(m?"text-white":"text-gray-900"),ua&&"ring-1 ring-[#3B82F6]",Fr&&"bg-[#7C3AED] text-white",!Fr&&(m?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{Ye(Xe.date),Pt(false);},children:Xe.dayNum},Yt)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:ie=>{ie.stopPropagation(),Le(!me),$(false);},className:d("p-1 rounded transition-colors",dt?"text-[#7C3AED] bg-[#7C3AED]/20":m?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:dt?jsx("div",{className:"w-4 h-4 rounded-full flex items-center justify-center text-white text-[8px] font-medium",style:{backgroundColor:t.availableUsers?.find(ie=>ie.id===dt)?.color||"#7C3AED"},children:t.availableUsers?.find(ie=>ie.id===dt)?.initials||t.availableUsers?.find(ie=>ie.id===dt)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:me&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:ie=>ie.stopPropagation(),children:[jsxs("button",{onClick:()=>{vt(null),Le(false);},className:d("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",!dt&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:d("w-5 h-5 rounded-full flex items-center justify-center",m?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:m?"text-[#9CA3AF]":"text-gray-500",children:b==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(ie=>jsxs("button",{onClick:()=>{vt(ie.id),Le(false);},className:d("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",dt===ie.id&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-white text-[9px] font-medium",style:{backgroundColor:ie.color||"#7C3AED"},children:ie.initials||ie.name?.slice(0,2).toUpperCase()}),jsx("span",{className:m?"text-white":"text-gray-900",children:ie.name})]},ie.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:d("px-3 py-2 text-xs",m?"text-[#6B7280]":"text-gray-400"),children:b==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(qe.trim()){let ie=t.availableUsers?.find(yt=>yt.id===dt),Ge=Se||M.date;a.onTaskCreate?.({name:qe.trim(),startDate:Ge,endDate:Ge,priority:de,assignees:ie?[ie]:void 0}),et(""),Ke(void 0),vt(null),Ye(null),Fe(null);}},disabled:!qe.trim(),className:d("px-2.5 py-1 rounded text-xs font-medium transition-colors",qe.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":m?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:b==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:d("text-sm font-medium",M.isToday?"text-[#3B82F6]":M.isCurrentMonth?m?"text-white":"text-gray-900":m?"text-[#6B7280]":"text-gray-400"),children:M.date.getDate()})]})]},W)})})]})}),jsx(AnimatePresence,{children:v&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>{I(null),Ce("");},className:"fixed inset-0 bg-black/50 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},className:d("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",m?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:d("px-6 py-3 border-b flex items-center gap-3",m?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:d("w-4 h-4",m?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:d("text-xs px-2 py-0.5 rounded",m?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[b==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:d("text-xs font-mono",m?"text-[#6B7280]":"text-gray-400"),children:v.id.slice(0,8)}),jsxs("button",{className:d("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",m?"bg-purple-500/20 text-purple-400 hover:bg-purple-500/30":"bg-purple-100 text-purple-700 hover:bg-purple-200"),children:[jsx(Sparkles,{className:"w-3 h-3"}),"Ask AI"]})]}),jsx("div",{className:"flex-1"}),jsx("button",{className:d("p-1.5 rounded transition-colors",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:d("p-1.5 rounded transition-colors",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>{I(null),Ce("");},className:d("p-1.5 rounded transition-colors",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-5 h-5"})})]}),jsx("div",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("button",{onClick:()=>{let M=v.progress===100?0:100,Ee={...v,progress:M,status:M===100?"completed":"todo"};I(Ee),a.onTaskUpdate?.(Ee);},className:d("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",v.progress===100?"bg-green-500 border-green-500":m?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:v.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:d("text-xl font-semibold flex-1",v.progress===100?"line-through text-[#6B7280]":m?"text-white":"text-gray-900"),children:v.name})]})}),jsxs("div",{className:"px-6 pb-6 flex-1 overflow-y-auto overflow-x-visible",children:[jsxs("div",{className:"grid grid-cols-2 gap-x-12 gap-y-5",children:[jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CheckCircle2,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{z(),A(!Re);},className:d("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",v.progress===100||v.status==="completed"?"bg-green-500/20 text-green-400":v.progress&&v.progress>0||v.status==="in-progress"?"bg-blue-500/20 text-blue-400":m?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:v.progress===100||v.status==="completed"?b==="es"?"COMPLETADO":"DONE":v.progress&&v.progress>0||v.status==="in-progress"?b==="es"?"EN PROGRESO":"IN PROGRESS":b==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:Re&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>A(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:b==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:b==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:b==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(M=>jsxs("button",{onClick:()=>je(M.id),className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",(v.status===M.id||M.id==="completed"&&v.progress===100||M.id==="in-progress"&&v.progress&&v.progress>0&&v.progress<100||M.id==="todo"&&(!v.progress||v.progress===0)&&v.status!=="in-progress"&&v.status!=="completed")&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",M.id==="completed"?"bg-green-500":M.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:m?"text-white":"text-gray-900",children:M.label})]},M.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{A(false),L(false),O(null),J(!j);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[v.assignees&&v.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[v.assignees.slice(0,3).map((M,W)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:M.color||"#8B5CF6"},title:M.name,children:M.initials||M.name.slice(0,2).toUpperCase()},W)),v.assignees.length>3&&jsxs("span",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:["+",v.assignees.length-3]})]}):jsx("span",{className:d("text-sm",m?"text-[#6B7280]":"text-gray-400"),children:b==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:d("w-3 h-3",m?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:j&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>J(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:t.availableUsers&&t.availableUsers.length>0?t.availableUsers.map(M=>{let W=v.assignees?.some(Ee=>Ee.name===M.name);return jsxs("button",{onClick:()=>{let Ee=v.assignees||[],Pe;W?Pe=Ee.filter($t=>$t.name!==M.name):Pe=[...Ee,{name:M.name,avatar:M.avatar,initials:M.initials||M.name.slice(0,2).toUpperCase(),color:M.color||"#8B5CF6"}],be("assignees",Pe);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",m?"hover:bg-white/5":"hover:bg-gray-50",W&&(m?"bg-white/5":"bg-gray-50")),children:[M.avatar?jsx("img",{src:M.avatar,alt:M.name,className:"w-6 h-6 rounded-full object-cover"}):jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:M.color||"#8B5CF6"},children:M.initials||M.name.slice(0,2).toUpperCase()}),jsx("span",{className:d("flex-1 text-left",m?"text-white":"text-gray-900"),children:M.name}),W&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},M.id||M.name)}):jsx("div",{className:d("px-3 py-4 text-sm text-center",m?"text-[#6B7280]":"text-gray-400"),children:b==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{O(H?null:"start"),ae(v.startDate||new Date);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[v.startDate?.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(b==="es"?"Inicio":"Start"),jsx("span",{className:d("mx-1",m?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),v.endDate?.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(b==="es"?"Fin":"End"),(v.startDate||v.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:M=>{M.stopPropagation();}})]}),jsx(AnimatePresence,{children:H&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>O(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:d("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:M=>M.stopPropagation(),children:[jsxs("div",{className:d("w-44 py-2 border-r",m?"border-white/10":"border-gray-200"),children:[(()=>{let M=new Date,W=new Date(M);W.setDate(M.getDate()+1);let Ee=new Date(M);Ee.setDate(M.getDate()+((6-M.getDay()+7)%7||7));let Pe=new Date(M);Pe.setDate(M.getDate()+((1-M.getDay()+7)%7||7));let $t=new Date(M);$t.setDate(M.getDate()+(6-M.getDay()+7)%7+7);let ie=new Date(M);ie.setDate(M.getDate()+14);let Ge=new Date(M);return Ge.setDate(M.getDate()+28),[{label:b==="es"?"Hoy":"Today",date:M,display:M.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:b==="es"?"Ma\xF1ana":"Tomorrow",date:W,display:W.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:b==="es"?"Este fin de semana":"This weekend",date:Ee,display:b==="es"?"s\xE1b.":"sat."},{label:b==="es"?"Pr\xF3xima semana":"Next week",date:Pe,display:b==="es"?"lun.":"mon."},{label:b==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:$t,display:$t.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:b==="es"?"2 semanas":"2 weeks",date:ie,display:ie.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:b==="es"?"4 semanas":"4 weeks",date:Ge,display:Ge.toLocaleDateString(b==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ue,gt)=>jsxs("button",{className:d("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",m?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(H==="start"){let ya=v.endDate&&Ue.date>v.endDate?Ue.date:v.endDate;Ie(Ue.date,ya),O("end");}else {let ya=v.startDate&&Ue.date<v.startDate?Ue.date:v.startDate;Ie(ya,Ue.date),O(null);}},children:[jsx("span",{children:Ue.label}),jsx("span",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:Ue.display})]},gt))})(),jsx("div",{className:d("border-t mt-2 pt-2",m?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Ie(void 0,void 0),O(null);},className:d("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",m?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:b==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:d("text-xs mb-3 px-2 py-1 rounded",m?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:H==="start"?b==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":b==="es"?"\u{1F4C5} Selecciona fecha de fin":"\u{1F4C5} Select end date"}),jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:d("font-medium",m?"text-white":"text-gray-900"),children:K.toLocaleDateString(b==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>ae(new Date),className:d("p-1 rounded text-sm transition-colors",m?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:b==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>ae(new Date(K.getFullYear(),K.getMonth()-1)),className:d("p-1 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>ae(new Date(K.getFullYear(),K.getMonth()+1)),className:d("p-1 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:"w-4 h-4"})})]})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:(b==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(M=>jsx("div",{className:d("w-8 h-8 flex items-center justify-center text-xs",m?"text-[#6B7280]":"text-gray-400"),children:M},M))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let M=K.getFullYear(),W=K.getMonth(),Ee=new Date(M,W,1).getDay(),Pe=new Date(M,W+1,0).getDate(),$t=new Date(M,W,0).getDate(),ie=new Date,Ge=[];for(let Ue=Ee-1;Ue>=0;Ue--)Ge.push({day:$t-Ue,isCurrentMonth:false,date:new Date(M,W-1,$t-Ue)});for(let Ue=1;Ue<=Pe;Ue++)Ge.push({day:Ue,isCurrentMonth:true,date:new Date(M,W,Ue)});let yt=42-Ge.length;for(let Ue=1;Ue<=yt;Ue++)Ge.push({day:Ue,isCurrentMonth:false,date:new Date(M,W+1,Ue)});return Ge.map((Ue,gt)=>{let ya=Ue.date.toDateString()===ie.toDateString(),ka=v.startDate?.toDateString()===Ue.date.toDateString(),Mt=v.endDate?.toDateString()===Ue.date.toDateString(),Xe=ka||Mt,Yt=v.startDate&&v.endDate&&Ue.date>=v.startDate&&Ue.date<=v.endDate;return jsx("button",{className:d("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Ue.isCurrentMonth&&(m?"text-[#4B5563]":"text-gray-300"),Ue.isCurrentMonth&&(m?"text-white":"text-gray-900"),ya&&"ring-2 ring-[#3B82F6]",ka&&"bg-[#3B82F6] text-white",Mt&&!ka&&"bg-[#7C3AED] text-white",Yt&&!Xe&&(m?"bg-[#7C3AED]/20":"bg-purple-100"),!Xe&&(m?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let ua=new Date(Ue.date);if(H==="start"){let Fr=v.endDate&&ua>v.endDate?ua:v.endDate;Ie(ua,Fr),O("end");}else {let Fr=v.startDate&&ua<v.startDate?ua:v.startDate;Ie(Fr,ua),O(null);}},children:Ue.day},gt)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{z(),L(!R);},className:d("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",v.priority==="high"||v.priority==="urgent"?"bg-red-500/20 text-red-400":v.priority==="medium"?"bg-yellow-500/20 text-yellow-400":v.priority==="low"?"bg-green-500/20 text-green-400":m?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:v.priority?v.priority==="high"||v.priority==="urgent"?b==="es"?"Urgente":"Urgent":v.priority==="medium"?b==="es"?"Media":"Medium":b==="es"?"Baja":"Low":b==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:R&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>L(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:b==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:b==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:b==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:b==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:b==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(M=>jsxs("button",{onClick:()=>{be("priority",M.id),L(false);},className:d("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",v.priority===M.id&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:d("w-2 h-2 rounded-full",M.color)}),jsx("span",{className:m?"text-white":"text-gray-900",children:M.label})]},M.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:d("text-sm",m?"text-white":"text-gray-900"),children:v.startDate&&v.endDate?`${Math.ceil((v.endDate.getTime()-v.startDate.getTime())/(1e3*60*60*24))} ${b==="es"?"d\xEDas":"days"}`:b==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:d("w-4 h-4 rounded-full border-2",m?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[U?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:v.progress||0,onChange:M=>{let W=parseInt(M.target.value),Ee=v.status;W===100?Ee="completed":W>0?Ee="in-progress":Ee="todo";let Pe={...v,progress:W,status:Ee};I(Pe),a.onTaskUpdate?.(Pe);},onBlur:()=>ge(false),className:d("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",m?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>ge(true),className:d("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",m?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:d("h-full rounded-full transition-all",v.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${v.progress||0}%`}})}),jsxs("span",{className:d("text-sm font-medium min-w-[40px]",m?"text-white":"text-gray-900"),children:[v.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Etiquetas":"Tags"}),jsx(hr,{selectedTags:v.tags||[],availableTags:g,onChange:M=>{be("tags",M);},onCreateTag:i,theme:N})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:d("w-4 h-4 mt-1.5",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24 mt-1",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[v.dependencies&&v.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:v.dependencies.map(M=>{let W=e.find(Ee=>Ee.id===M);return jsxs("span",{className:d("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",m?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[W?.name||M.slice(0,8),jsx("button",{onClick:()=>{let Ee=(v.dependencies||[]).filter(Pe=>Pe!==M);be("dependencies",Ee);},className:d("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},M)})}),jsxs("button",{onClick:()=>{z(),Ve(!nt);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:nt&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Ve(false),Bt("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:d("p-2 border-b",m?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:Vt,onChange:M=>Bt(M.target.value),placeholder:b==="es"?"Buscar tarea...":"Search task...",className:d("w-full px-3 py-2 rounded-md text-sm outline-none",m?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400"),autoFocus:true})}),jsx("div",{className:"max-h-[240px] overflow-y-auto",children:e.length>0?e.filter(M=>M.id!==v.id).filter(M=>Vt===""||M.name.toLowerCase().includes(Vt.toLowerCase())).map(M=>{let W=v.dependencies?.includes(M.id);return jsxs("button",{onClick:()=>{let Ee=v.dependencies||[],Pe;W?Pe=Ee.filter($t=>$t!==M.id):Pe=[...Ee,M.id],be("dependencies",Pe);},className:d("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",m?"hover:bg-white/5":"hover:bg-gray-50",W&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:d("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",W?"bg-blue-500 border-blue-500":m?"border-white/30":"border-gray-300"),children:W&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:d("block truncate",m?"text-white":"text-gray-900"),children:M.name}),jsx("span",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:M.id.slice(0,8)})]})]},M.id)}):jsx("div",{className:d("px-3 py-4 text-sm text-center",m?"text-[#6B7280]":"text-gray-500"),children:b==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{z(),te(!Ze);},className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:v.color||"#6366F1"}}),jsx("span",{className:d("text-sm",m?"text-white":"text-gray-900"),children:yr.find(M=>M.value===v.color)?.name||(b==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:d("w-3 h-3",m?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:Ze&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>te(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:d("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:yr.map(M=>{let W=v.color===M.value;return jsx("button",{onClick:()=>{be("color",M.value),te(false);},className:d("w-7 h-7 rounded-full flex items-center justify-center transition-all",W&&"ring-2 ring-offset-2",m?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:M.value,outlineColor:W?M.value:void 0},title:M.name,children:W&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},M.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:d("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:v.isMilestone||false,onChange:M=>be("isMilestone",M.target.checked),className:d("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",v.isMilestone?"bg-purple-500 border-purple-500":m?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:d("text-sm",m?"text-white":"text-gray-900"),children:b==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:d("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:d("text-sm font-semibold",m?"text-white":"text-gray-900"),children:b==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:v.description||"",onChange:M=>be("description",M.target.value),placeholder:b==="es"?"Agregar descripci\xF3n...":"Add description...",className:d("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",m?"bg-white/5 text-white placeholder:text-[#6B7280] focus:bg-white/10":"bg-gray-100 text-gray-900 placeholder:text-gray-400 focus:bg-gray-200")}),jsxs("button",{className:d("flex items-center gap-2 text-sm mt-2 transition-colors",m?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),b==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:b==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),b==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:d("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:b==="es"?"Agregar subtarea":"Add subtask"}),v.subtasks&&v.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:v.subtasks.map(M=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:d("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",M.progress===100?"bg-green-500 border-green-500":m?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:M.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:d("text-sm",M.progress===100?"line-through text-[#6B7280]":m?"text-white":"text-gray-900"),children:M.name})]},M.id))}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(Plus,{className:"w-4 h-4"}),b==="es"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:d("text-sm font-semibold",m?"text-white":"text-gray-900"),children:b==="es"?"Listas de control":"Checklists"}),jsx("button",{className:d("p-1 rounded transition-colors",m?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",m?"bg-white/5 hover:bg-white/10 text-[#9CA3AF]":"bg-gray-100 hover:bg-gray-200 text-gray-600"),children:[jsx(ListChecks,{className:"w-4 h-4"}),b==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:d("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:d("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:[b==="es"?"Adjuntos":"Attachments",$a.length>0&&jsxs("span",{className:d("ml-2 text-xs font-normal",m?"text-[#6B7280]":"text-gray-400"),children:["(",$a.length,")"]})]}),$a.length>0&&jsx("div",{className:"space-y-2 mb-4",children:$a.map(M=>{let W=fr(M.type),Ee=M.type.startsWith("image/");return jsxs("div",{className:d("flex items-center gap-3 p-2 rounded-lg group transition-colors",m?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[Ee&&M.thumbnailUrl?jsx("img",{src:M.thumbnailUrl,alt:M.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:d("w-10 h-10 rounded flex items-center justify-center",m?"bg-white/10":"bg-gray-200"),children:jsx(W,{className:d("w-5 h-5",m?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:M.url,target:"_blank",rel:"noopener noreferrer",className:d("text-sm font-medium truncate block hover:underline",m?"text-white":"text-gray-900"),children:M.name}),jsx("p",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:Dr(M.size)})]}),a.onDeleteAttachment&&jsx("button",{onClick:()=>a.onDeleteAttachment?.(M.id),className:d("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",m?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:b==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},M.id)})}),jsxs("div",{onDragOver:Nt,onDragLeave:mt,onDrop:se,className:d("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",xe?m?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":m?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",Be&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:We,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!a.onUploadAttachments||Be}),Be?jsxs(Fragment,{children:[jsx("div",{className:"w-6 h-6 mx-auto mb-2 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),jsx("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:b==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:d("w-6 h-6 mx-auto mb-2",xe?"text-blue-500":m?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:d("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:xe?b==="es"?"Suelta los archivos aqu\xED":"Drop files here":b==="es"?jsxs(Fragment,{children:["Suelta tus archivos aqu\xED o ",jsx("span",{className:"underline",children:"haz clic para subir"})]}):jsxs(Fragment,{children:["Drop your files here or ",jsx("span",{className:"underline",children:"click to upload"})]})}),!a.onUploadAttachments&&jsx("p",{className:d("text-xs mt-1",m?"text-[#6B7280]":"text-gray-400"),children:b==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:d("w-80 border-l flex flex-col",m?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:d("px-4 py-3 border-b",m?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:d("text-sm font-semibold",m?"text-white":"text-gray-900"),children:[b==="es"?"Actividad":"Activity",l&&l.length>0&&jsxs("span",{className:d("ml-2 text-xs font-normal",m?"text-[#6B7280]":"text-gray-400"),children:["(",l.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:l&&l.length>0?jsx("div",{className:"space-y-4",children:l.map(M=>{let W=(()=>{let Ee=new Date,Pe=new Date(M.createdAt),$t=Ee.getTime()-Pe.getTime(),ie=Math.floor($t/6e4),Ge=Math.floor(ie/60),yt=Math.floor(Ge/24);return ie<1?b==="es"?"ahora":"now":ie<60?b==="es"?`hace ${ie}m`:`${ie}m ago`:Ge<24?b==="es"?`hace ${Ge}h`:`${Ge}h ago`:b==="es"?`hace ${yt}d`:`${yt}d ago`})();return jsxs("div",{className:"flex gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:"#8B5CF6"},children:M.user?.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:d("text-sm font-medium",m?"text-white":"text-gray-900"),children:M.user?.name||(b==="es"?"Usuario":"User")}),jsx("span",{className:d("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:W})]}),jsx("p",{className:d("text-sm break-words",m?"text-[#9CA3AF]":"text-gray-600"),children:M.content})]})]},M.id)})}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:d("w-10 h-10 mb-3",m?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:d("text-sm",m?"text-[#6B7280]":"text-gray-500"),children:b==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:d("p-4 border-t",m?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-start gap-2",children:[y&&jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",style:{backgroundColor:y.color||"#8B5CF6"},children:y.name?.slice(0,2).toUpperCase()||"U"}),jsxs("div",{className:d("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",m?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:S,onChange:M=>Ce(M.target.value),onKeyDown:async M=>{if(M.key==="Enter"&&!M.shiftKey&&v&&S.trim()&&f){M.preventDefault(),we(true);try{await f(v.id,S.trim()),Ce("");}finally{we(false);}}},placeholder:b==="es"?"Escribe un comentario...":"Write a comment...",disabled:X$1||!f,className:d("flex-1 bg-transparent text-sm outline-none",m?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(X$1||!f)&&"opacity-50")}),jsx("button",{onClick:async()=>{if(v&&S.trim()&&f){we(true);try{await f(v.id,S.trim()),Ce("");}finally{we(false);}}},disabled:X$1||!S.trim()||!f,className:d("p-1.5 rounded transition-colors",S.trim()&&f?"bg-blue-500 text-white hover:bg-blue-600":m?"text-[#6B7280]":"text-gray-400",X$1&&"opacity-50 cursor-not-allowed"),children:X$1?jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):jsx(Send,{className:"w-4 h-4"})})]})]})})]})]})]})}),jsx(AnimatePresence,{children:F&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>T(null),className:"fixed inset-0 bg-black/30 z-40"}),jsxs(motion.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:d("fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[320px] max-h-[400px] rounded-xl shadow-2xl z-50 overflow-hidden",m?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:d("px-4 py-3 border-b flex items-center justify-between",m?"border-white/10":"border-gray-200"),children:[jsx("span",{className:d("font-medium",m?"text-white":"text-gray-900"),children:F.date.toLocaleDateString(b==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>T(null),className:d("p-1 rounded",m?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:"p-3 max-h-[320px] overflow-y-auto space-y-2",children:F.events.map(M=>jsxs("button",{onClick:()=>{T(null),I(M.task),C?.(M.task.id);},className:d("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",m?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx(xp,{task:M.task}),jsx("span",{className:d("text-sm truncate flex-1",m?"text-white":"text-gray-900"),children:M.title}),M.task.priority==="high"||M.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},M.id))})]})]})})]})}var Tl={bgPrimary:"#0d1117",bgSecondary:"#161b22",bgHover:"#21262d",bgToday:"#1f6feb20",bgWeekend:"#161b2280",bgOtherMonth:"#0d111750",border:"#30363d",borderLight:"#21262d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#6e7681",textToday:"#58a6ff",accent:"#58a6ff",accentHover:"#79b8ff",accentLight:"#58a6ff20",statusTodo:"#8b949e",statusInProgress:"#f0883e",statusCompleted:"#3fb950",focusRing:"#58a6ff"},Nl={bgPrimary:"#ffffff",bgSecondary:"#f6f8fa",bgHover:"#f3f4f6",bgToday:"#dbeafe",bgWeekend:"#f9fafb",bgOtherMonth:"#f3f4f680",border:"#d0d7de",borderLight:"#e5e7eb",textPrimary:"#24292f",textSecondary:"#57606a",textMuted:"#8b949e",textToday:"#0969da",accent:"#0969da",accentHover:"#0550ae",accentLight:"#dbeafe",statusTodo:"#8b949e",statusInProgress:"#bf8700",statusCompleted:"#1a7f37",focusRing:"#0969da"},Dl={bgPrimary:"#1a1a2e",bgSecondary:"#16213e",bgHover:"#1f3460",bgToday:"#6366f120",bgWeekend:"#16213e80",bgOtherMonth:"#1a1a2e50",border:"#2a3f5f",borderLight:"#1f3460",textPrimary:"#e4e6eb",textSecondary:"#a8b2c1",textMuted:"#6b7280",textToday:"#818cf8",accent:"#6366f1",accentHover:"#818cf8",accentLight:"#6366f120",statusTodo:"#9ca3af",statusInProgress:"#fbbf24",statusCompleted:"#34d399",focusRing:"#6366f1"},vs={dark:Tl,light:Nl,neutral:Dl};function Cp(e){return vs[e]||vs.dark}function Av({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:n,className:c}){let[g,i]=useState(false),p=useMemo(()=>t.filter(y=>e.cardIds.includes(y.id)),[t,e.cardIds]),l=useMemo(()=>{let y=p.length,k=new Set(p.flatMap(b=>b.assignedUserIds||[])).size,C=p.map(b=>b.priority).filter(Boolean),h=new Set(p.flatMap(b=>b.labels||[])).size;return {totalCards:y,uniqueAssignees:k,priorities:C,labels:h}},[p]),f=()=>{o?.(e.id);};return jsxs("div",{className:d("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>i(true),onMouseLeave:()=>i(false),style:{"--stack-color":e.color||"var(--color-accent-primary)"},children:[jsxs("div",{className:"card-stack-header",onClick:f,children:[jsxs("div",{className:"card-stack-header-left",children:[jsx("button",{className:"card-stack-toggle","aria-label":e.isExpanded?"Collapse":"Expand",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:d("card-stack-chevron",e.isExpanded&&"expanded"),children:jsx("polyline",{points:"6 9 12 15 18 9"})})}),jsx("h3",{className:"card-stack-title",children:e.title}),jsx("div",{className:"card-stack-badge",children:l.totalCards}),jsxs("div",{className:"card-stack-strategy",children:[e.strategy==="ai-similarity"&&"\u2728 AI",e.strategy==="manual"&&"\u{1F464} Manual",e.strategy==="labels"&&"\u{1F3F7}\uFE0F Labels",e.strategy==="assignee"&&"\u{1F465} Assignee",e.strategy==="priority"&&"\u{1F3AF} Priority",e.strategy==="epic"&&"\u{1F4DA} Epic"]})]}),g&&jsx("div",{className:"card-stack-actions",children:jsx("button",{className:"card-stack-action",onClick:y=>{y.stopPropagation(),n?.(e.id);},"aria-label":"Delete stack",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})})]}),!e.isExpanded&&jsxs("div",{className:"card-stack-summary",children:[jsxs("div",{className:"card-stack-summary-item",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),jsxs("span",{children:[l.uniqueAssignees," assignees"]})]}),l.labels>0&&jsxs("div",{className:"card-stack-summary-item",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsxs("span",{children:[l.labels," labels"]})]}),e.confidence&&jsx("div",{className:"card-stack-summary-item",children:jsxs("span",{className:"card-stack-confidence",children:[Math.round(e.confidence*100),"% match"]})})]}),e.isExpanded&&jsx("div",{className:"card-stack-content",children:p.length===0?jsxs("div",{className:"card-stack-empty",children:[jsx("p",{children:"No cards in this stack"}),jsx("span",{children:"Drag cards here or delete this stack"})]}):jsx("div",{className:"card-stack-cards",children:p.map(y=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(y),children:a(y)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(y),children:[jsx("h4",{children:y.title}),y.description&&jsxs("p",{children:[y.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:k=>{k.stopPropagation(),s?.(e.id,y.id);},"aria-label":"Remove from stack",children:jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},y.id))})})]})}var Np={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function mn(e){switch(e.type){case "created":return "Created card";case "status_changed":return `Changed status from "${e.changes.status?.from}" to "${e.changes.status?.to}"`;case "assignee_changed":return "Changed assignee";case "priority_changed":return `Changed priority from ${e.changes.priority?.from} to ${e.changes.priority?.to}`;case "moved":return `Moved from ${e.metadata?.fromColumn||"unknown"} to ${e.metadata?.toColumn||"unknown"}`;case "title_updated":return "Updated title";case "description_updated":return "Updated description";case "dates_changed":return "Changed dates";case "labels_changed":return "Updated labels";case "dependency_added":return "Added dependency";case "dependency_removed":return "Removed dependency";case "comment_added":return "Added comment";case "archived":return "Archived card";case "restored":return "Restored card";default:return "Updated card"}}function pn(e){return {created:"\u2728",status_changed:"\u{1F504}",assignee_changed:"\u{1F464}",priority_changed:"\u{1F3AF}",moved:"\u27A1\uFE0F",title_updated:"\u270F\uFE0F",description_updated:"\u{1F4DD}",dates_changed:"\u{1F4C5}",labels_changed:"\u{1F3F7}\uFE0F",dependency_added:"\u{1F517}",dependency_removed:"\u26D3\uFE0F\u200D\u{1F4A5}",comment_added:"\u{1F4AC}",archived:"\u{1F4E6}",restored:"\u267B\uFE0F"}[e]||"\u{1F4CC}"}function Dp(e){return {created:"#10b981",status_changed:"#3b82f6",assignee_changed:"#8b5cf6",priority_changed:"#f59e0b",moved:"#06b6d4",title_updated:"#6366f1",description_updated:"#6366f1",dates_changed:"#ec4899",labels_changed:"#14b8a6",dependency_added:"#a855f7",dependency_removed:"#ef4444",comment_added:"#84cc16",archived:"#6b7280",restored:"#10b981"}[e]||"#6b7280"}function Sp({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:n,className:c}){let g=useMemo(()=>({...Np,...n}),[n]),[i,p]=useState(new Set),l=useRef(null),f=useMemo(()=>{if(!g.groupByDay)return [{date:null,events:e}];let u=new Map;return e.forEach(x=>{let m=x.timestamp.toISOString().split("T")[0],N=u.get(m);N?N.push(x):u.set(m,[x]);}),Array.from(u.entries()).sort((x,m)=>m[0].localeCompare(x[0])).map(([x,m])=>({date:new Date(x),events:m.sort((N,w)=>w.timestamp.getTime()-N.timestamp.getTime())}))},[e,g.groupByDay]),{uniqueUsers:y,uniqueTypes:k}=useMemo(()=>{let u=new Set,x=new Set;return e.forEach(m=>{u.add(m.userId),x.add(m.type);}),{uniqueUsers:Array.from(u),uniqueTypes:Array.from(x)}},[e]),C=u=>{p(x=>{let m=new Set(x);return m.has(u)?m.delete(u):m.add(u),m});},h=u=>{let m=new Date().getTime()-u.getTime(),N=Math.floor(m/6e4),w=Math.floor(m/36e5),B=Math.floor(m/864e5);return N<1?"just now":N<60?`${N}m ago`:w<24?`${w}h ago`:B<7?`${B}d ago`:u.toLocaleDateString()},b=useMemo(()=>{let u=0;return t.types&&t.types.length>0&&u++,t.users&&t.users.length>0&&u++,t.dateRange&&u++,t.searchTerm&&u++,u},[t]);return useEffect(()=>{if(s&&l.current){let u=l.current.querySelector(`[data-event-id="${s}"]`);u&&u.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:d("history-timeline-empty",c),children:[jsx("div",{className:"history-timeline-empty-icon",children:"\u{1F4DC}"}),jsx("p",{className:"history-timeline-empty-text",children:"No history events yet"}),jsx("p",{className:"history-timeline-empty-subtext",children:"Changes to this card will appear here"})]}):jsxs("div",{className:d("history-timeline",g.compact&&"compact",c),children:[jsxs("div",{className:"history-timeline-filters",children:[jsxs("div",{className:"history-timeline-filter-group",children:[jsxs("select",{className:"history-timeline-filter-select",value:t.types?.[0]||"",onChange:u=>{let x=u.target.value;a({...t,types:x?[x]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),k.map(u=>jsxs("option",{value:u,children:[pn(u)," ",u.replace("_"," ")]},u))]}),y.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:u=>{let x=u.target.value;a({...t,users:x?[x]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),y.map(u=>jsx("option",{value:u,children:u},u))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:u=>a({...t,searchTerm:u.target.value})})]}),b>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",b,")"]})]}),jsx("div",{className:"history-timeline-container",ref:l,children:f.map(u=>jsxs("div",{className:"history-timeline-group",children:[g.groupByDay&&u.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:u.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[u.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:u.events.map((x,m)=>{let N=i.has(x.id),w=s===x.id,B=Dp(x.type);return jsxs("div",{"data-event-id":x.id,className:d("history-timeline-event",N&&"expanded",w&&"selected"),onClick:()=>o?.(x),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:B},children:g.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:pn(x.type)})}),m<u.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:B}})]}),jsxs("div",{className:"history-timeline-event-content",children:[jsxs("div",{className:"history-timeline-event-header",children:[jsxs("div",{className:"history-timeline-event-header-left",children:[g.showAvatars&&x.userAvatar&&jsx("img",{src:x.userAvatar,alt:x.userName||x.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:x.userName||x.userId}),jsx("span",{className:"history-timeline-event-action",children:mn(x)})]})]}),jsx("div",{className:"history-timeline-event-time",children:g.useRelativeTime?h(x.timestamp):x.timestamp.toLocaleString()})]}),Object.keys(x.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:v=>{v.stopPropagation(),C(x.id);},children:[N?"\u25BC":"\u25B6"," Show changes"]}),N&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(x.changes).map(([v,I])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[v,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(I.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(I.to)})]})]},v)),x.metadata&&Object.keys(x.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(x.metadata).map(([v,I])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[v,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(I)})]},v))]})]})]})]},x.id)})})]},u.date?.toISOString()||"all"))})]})}function Pp({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:n,onGoToEvent:c,onSpeedChange:g,className:i}){let p=[.5,1,1.5,2,3],l=useMemo(()=>!e||t.length===0?null:t[e.currentIndex],[e,t]),f=useMemo(()=>!e||e.totalEvents===0?0:e.currentIndex/(e.totalEvents-1)*100,[e]);return t.length===0?jsxs("div",{className:d("history-replay-empty",i),children:[jsx("div",{className:"history-replay-empty-icon",children:"\u23F3"}),jsx("p",{className:"history-replay-empty-text",children:"No history to replay"})]}):e?jsxs("div",{className:d("history-replay",i),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:l&&pn(l.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:l&&mn(l)}),jsxs("div",{className:"history-replay-event-meta",children:[jsxs("span",{className:"history-replay-event-index",children:["Event ",e.currentIndex+1," of ",e.totalEvents]}),jsx("span",{className:"history-replay-event-time",children:l&&l.timestamp.toLocaleString()})]})]})]}),jsxs("div",{className:"history-replay-progress-container",children:[jsx("input",{type:"range",className:"history-replay-progress-slider",min:"0",max:e.totalEvents-1,value:e.currentIndex,onChange:y=>c(parseInt(y.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${f}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((y,k)=>jsx("div",{className:d("history-replay-progress-marker",k===e.currentIndex&&"active"),style:{left:`${k/(e.totalEvents-1)*100}%`},onClick:()=>c(k),title:mn(y)},y.id))})]}),jsxs("div",{className:"history-replay-controls",children:[jsx("button",{className:"history-replay-control-btn",onClick:s,disabled:!e.canGoBack,title:"Previous event (\u2190)",children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polygon",{points:"19 20 9 12 19 4 19 20"}),jsx("line",{x1:"5",y1:"19",x2:"5",y2:"5"})]})}),jsx("button",{className:"history-replay-control-btn history-replay-control-play",onClick:o,title:e.isPlaying?"Pause (Space)":"Play (Space)",children:e.isPlaying?jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]}):jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})}),jsx("button",{className:"history-replay-control-btn",onClick:n,disabled:!e.canGoForward,title:"Next event (\u2192)",children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polygon",{points:"5 4 15 12 5 20 5 4"}),jsx("line",{x1:"19",y1:"5",x2:"19",y2:"19"})]})}),jsxs("div",{className:"history-replay-speed",children:[jsx("label",{className:"history-replay-speed-label",children:"Speed:"}),jsx("div",{className:"history-replay-speed-buttons",children:p.map(y=>jsxs("button",{className:d("history-replay-speed-btn",e.speed===y&&"active"),onClick:()=>g(y),children:[y,"x"]},y))})]}),jsx("button",{className:"history-replay-control-btn history-replay-stop",onClick:r,title:"Stop replay (Esc)",children:jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:jsx("rect",{x:"6",y:"6",width:"12",height:"12"})})})]}),jsxs("div",{className:"history-replay-shortcuts",children:[jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"Space"})," Play/Pause"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"\u2190"})," Previous"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"\u2192"})," Next"]}),jsxs("span",{className:"history-replay-shortcut",children:[jsx("kbd",{children:"Esc"})," Stop"]})]}),jsxs("div",{className:"history-replay-card-preview",children:[jsxs("div",{className:"history-replay-card-preview-header",children:[jsx("span",{className:"history-replay-card-preview-title",children:"Card State at This Point"}),jsx("span",{className:"history-replay-card-preview-time",children:l&&l.timestamp.toLocaleDateString()})]}),jsxs("div",{className:"history-replay-card-preview-content",children:[jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Title:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.title})]}),e.cardState.description&&jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Description:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.description})]}),jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Priority:"}),jsx("span",{className:"history-replay-card-preview-value",children:e.cardState.priority||"None"})]}),e.cardState.labels&&e.cardState.labels.length>0&&jsxs("div",{className:"history-replay-card-preview-field",children:[jsx("span",{className:"history-replay-card-preview-label",children:"Labels:"}),jsx("div",{className:"history-replay-card-preview-labels",children:e.cardState.labels.map(y=>jsx("span",{className:"history-replay-card-preview-label-tag",children:y},y))})]})]})]})]}):jsxs("div",{className:d("history-replay-start",i),children:[jsxs("button",{className:"history-replay-start-button",onClick:a,children:[jsx("svg",{className:"history-replay-start-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),jsx("span",{children:"Start Time Travel"})]}),jsxs("p",{className:"history-replay-start-hint",children:["Replay ",t.length," events from this card's history"]})]})}function Sl(e){return {blocks:"#ef4444",blocked_by:"#dc2626",depends_on:"#f59e0b",required_by:"#d97706",relates_to:"#6b7280",duplicates:"#8b5cf6",parent_of:"#3b82f6",child_of:"#2563eb",similar_to:"#10b981"}[e]||"#6b7280"}function El(e){return {blocks:"Blocks",blocked_by:"Blocked by",depends_on:"Depends on",required_by:"Required by",relates_to:"Relates to",duplicates:"Duplicates",parent_of:"Parent of",child_of:"Child of",similar_to:"Similar to"}[e]||e}function Mp(e){return {blocks:"\u{1F6AB}",blocked_by:"\u26D4",depends_on:"\u{1F517}",required_by:"\u{1F4CC}",relates_to:"\u{1F504}",duplicates:"\u{1F4CB}",parent_of:"\u{1F4C2}",child_of:"\u{1F4C4}",similar_to:"\u{1F50D}"}[e]||"\u{1F517}"}function Ap(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function Ov(e,t,a,r,o,s=100){let n=e.map(g=>({...g,x:g.x??a/2+Math.random()*100-50,y:g.y??r/2+Math.random()*100-50,vx:0,vy:0})),c=new Map(n.map(g=>[g.id,g]));for(let g=0;g<s;g++){let i=1-g/s;n.forEach(p=>{let l=a/2,f=r/2;p.vx+=(l-p.x)*o.centerForce*i,p.vy+=(f-p.y)*o.centerForce*i,n.forEach(y=>{if(p.id===y.id)return;let k=p.x-y.x,C=p.y-y.y,h=Math.sqrt(k*k+C*C)||1,b=o.chargeStrength*i/(h*h);p.vx+=k/h*b,p.vy+=C/h*b;});}),t.forEach(p=>{let l=c.get(typeof p.source=="string"?p.source:p.source.id),f=c.get(typeof p.target=="string"?p.target:p.target.id);if(!l||!f)return;let y=f.x-l.x,k=f.y-l.y,C=Math.sqrt(y*y+k*k)||1,h=(C-o.linkDistance)/C*o.forceStrength*i;l.vx+=y*h,l.vy+=k*h,f.vx-=y*h,f.vy-=k*h;}),n.forEach(p=>{p.fx!==null&&p.fx!==void 0?(p.x=p.fx,p.vx=0):p.x+=p.vx,p.fy!==null&&p.fy!==void 0?(p.y=p.fy,p.vy=0):p.y+=p.vy,p.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,p.x)),p.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,p.y)),p.vx*=.9,p.vy*=.9;});}return n}function Fp({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:n,onInteraction:c,className:g}){let i=useRef(null),[p,l]=useState([]),[f,y]=useState(null),[k,C]=useState(null),[h,b]=useState(null),[u,x]=useState(1),[m,N]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let O=Ov(e,t,a.width,a.height,a,150);l(O);},[e,t,a]);let w=useCallback((O,K)=>{a.enableDragging&&(K.stopPropagation(),y(O));},[a.enableDragging]),B=useCallback(O=>{if(!f||!i.current)return;let ae=i.current.getBoundingClientRect(),ne=(O.clientX-ae.left-m.x)/u,oe=(O.clientY-ae.top-m.y)/u;l(ye=>ye.map(fe=>fe.id===f?{...fe,x:ne,y:oe,fx:ne,fy:oe}:fe));},[f,u,m]),v=useCallback(()=>{y(null);},[]),I=useCallback((O,K)=>{K.stopPropagation(),c?.({type:"node-click",node:O,position:{x:K.clientX,y:K.clientY}});},[c]),F=useCallback((O,K)=>{K.stopPropagation(),c?.({type:"edge-click",edge:O,position:{x:K.clientX,y:K.clientY}});},[c]),T=useCallback(O=>{let K=p.find(ae=>ae.id===O);return K?{x:K.x,y:K.y}:{x:0,y:0}},[p]),H=useCallback(O=>{if(O.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return O.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let K=O.card.priority;return K==="URGENT"?"#ef4444":K==="HIGH"?"#f59e0b":K==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return O.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:d("relationships-graph-empty",g),children:[jsx("div",{className:"relationships-graph-empty-icon",children:"\u{1F517}"}),jsx("p",{className:"relationships-graph-empty-text",children:"No relationships to display"}),jsx("p",{className:"relationships-graph-empty-subtext",children:"Add relationships between cards to see the graph"})]}):jsxs("div",{className:d("relationships-graph",g),children:[jsxs("div",{className:"relationships-graph-controls",children:[jsxs("div",{className:"relationships-graph-stats",children:[jsxs("span",{className:"relationships-graph-stat",children:[jsx("span",{className:"relationships-graph-stat-value",children:n.totalNodes}),jsx("span",{className:"relationships-graph-stat-label",children:"Cards"})]}),jsxs("span",{className:"relationships-graph-stat",children:[jsx("span",{className:"relationships-graph-stat-value",children:n.totalEdges}),jsx("span",{className:"relationships-graph-stat-label",children:"Relations"})]}),s&&jsxs("span",{className:"relationships-graph-stat relationships-graph-stat-critical",children:[jsx("span",{className:"relationships-graph-stat-value",children:s.cardIds.length}),jsx("span",{className:"relationships-graph-stat-label",children:"Critical Path"})]})]}),a.enableZoom&&jsxs("div",{className:"relationships-graph-zoom-controls",children:[jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>x(O=>Math.min(O+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(u*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>x(O=>Math.max(O-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{x(1),N({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(O=>O.type))).map(O=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:Sl(O)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[Mp(O)," ",El(O)]})]},O))}),jsxs("svg",{ref:i,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:B,onMouseUp:v,onMouseLeave:v,children:[jsxs("g",{transform:`translate(${m.x}, ${m.y}) scale(${u})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(O=>{let K=T(typeof O.source=="string"?O.source:O.source.id),ae=T(typeof O.target=="string"?O.target:O.target.id),ne=Ap(O.type),oe=h===O.id,ye=O.onCriticalPath;return jsxs("g",{className:d("relationships-graph-edge",oe&&"hovered",ye&&"critical"),onMouseEnter:()=>b(O.id),onMouseLeave:()=>b(null),onClick:fe=>F(O,fe),children:[jsx("line",{x1:K.x,y1:K.y,x2:ae.x,y2:ae.y,stroke:Sl(O.type),strokeWidth:ye?a.edgeWidth*2:a.edgeWidth,strokeOpacity:oe?1:.6,markerEnd:ne?"url(#arrowhead)":void 0}),a.showEdgeLabels&&oe&&jsx("text",{x:(K.x+ae.x)/2,y:(K.y+ae.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:El(O.type)})]},O.id)})}),jsx("g",{className:"relationships-graph-nodes",children:p.map(O=>{let K=k===O.id,ae=O.onCriticalPath;return jsxs("g",{className:d("relationships-graph-node",K&&"hovered",ae&&"critical"),transform:`translate(${O.x}, ${O.y})`,onMouseDown:ne=>w(O.id,ne),onMouseEnter:()=>C(O.id),onMouseLeave:()=>C(null),onClick:ne=>I(O,ne),children:[jsx("circle",{r:ae?a.nodeSize*1.2:a.nodeSize,fill:H(O),stroke:ae?"#fbbf24":"#ffffff",strokeWidth:ae?3:2,opacity:K?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:O.card.title.length>20?O.card.title.substring(0,20)+"...":O.card.title})]},O.id)})})]}),jsx("defs",{children:jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"10",refX:"9",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#6b7280"})})})]})]})}function Bp({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,n]=useState(""),[c,g]=useState(false),[i,p]=useState(null),[l,f]=useState(null),y=useRef(null),k=c||o;useEffect(()=>{e&&y.current&&y.current.focus();},[e]),useEffect(()=>{let u=x=>{x.key==="Escape"&&!k&&C();};if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,k]);let C=()=>{k||(n(""),p(null),f(null),t());},h=async()=>{if(!(!s.trim()||k)){g(true),p(null),f(null);try{let u=await r(s.trim());f(u);}catch(u){p(u instanceof Error?u.message:"Failed to generate plan");}finally{g(false);}}},b=()=>{l&&(a(l),C());};return e?jsxs(ft,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:C}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-2xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:u=>u.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-blue-400",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Generate Project Plan with AI"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Describe your project and let AI create a complete Kanban board"})]}),jsx("button",{onClick:C,disabled:k,className:"text-white/60 hover:text-white transition-colors disabled:opacity-50",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:l?jsx(Fragment,{children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M4 10L8 14L16 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-semibold",children:"Plan Generated Successfully!"})]}),l.explanation&&jsx("div",{className:"p-4 rounded-lg bg-blue-500/10 border border-blue-500/30",children:jsx("p",{className:"text-sm text-white/90",children:l.explanation})}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Columns (",l.columns.length,")"]}),jsx("div",{className:"flex gap-2 flex-wrap",children:l.columns.map((u,x)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:u.title},x))})]}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Tasks (",l.cards.length,")"]}),jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[l.cards.slice(0,10).map((u,x)=>jsx("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10",children:jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex-1",children:[jsx("p",{className:"text-sm font-medium text-white/90",children:u.title}),u.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:u.description})]}),u.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${u.priority==="URGENT"?"bg-red-500/20 text-red-400":u.priority==="HIGH"?"bg-orange-500/20 text-orange-400":u.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:u.priority})]})},x)),l.cards.length>10&&jsxs("p",{className:"text-xs text-white/50 text-center py-2",children:["+",l.cards.length-10," more tasks..."]})]})]})]})}):jsxs(Fragment,{children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Project Description"}),jsx("textarea",{ref:y,value:s,onChange:u=>n(u.target.value),placeholder:"Example: Build a mobile app for tracking fitness goals with user authentication, workout logging, progress charts, and social features...",className:"w-full h-32 px-4 py-3 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/40 outline-none focus:border-blue-500/50 transition-all resize-none",disabled:k}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),i&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:i}),jsxs("div",{className:"border-t border-white/10 pt-4",children:[jsx("p",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider mb-3",children:"Example Prompts"}),jsx("div",{className:"space-y-2",children:["Build an e-commerce platform with product catalog, shopping cart, payment integration, and order tracking","Create a task management app with team collaboration, real-time updates, file attachments, and notifications","Develop a blog platform with markdown editor, SEO optimization, comments system, and analytics dashboard"].map((u,x)=>jsx("button",{onClick:()=>n(u),disabled:k,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-all border border-white/10 hover:border-white/20 disabled:opacity-50",children:u},x))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:k&&jsxs("div",{className:"flex items-center gap-2 text-blue-400 text-sm",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),jsx("span",{children:"Generating with AI..."})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:C,disabled:k,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80 disabled:opacity-50",children:"Cancel"}),l?jsx("button",{onClick:b,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Plan to Board"}):jsx("button",{onClick:h,disabled:!s.trim()||k,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#ffffff"},children:k?"Generating...":"Generate Plan"})]})]})]})})]}):null}var Pl={"gpt-4-turbo":{provider:"openai",name:"GPT-4 Turbo",contextWindow:128e3,costPer1kInput:.01,costPer1kOutput:.03,supportsVision:true,supportsJSON:true},"gpt-4":{provider:"openai",name:"GPT-4",contextWindow:8192,costPer1kInput:.03,costPer1kOutput:.06,supportsVision:false,supportsJSON:true},"gpt-3.5-turbo":{provider:"openai",name:"GPT-3.5 Turbo",contextWindow:16385,costPer1kInput:5e-4,costPer1kOutput:.0015,supportsVision:false,supportsJSON:true},"claude-3-5-sonnet-20241022":{provider:"anthropic",name:"Claude 3.5 Sonnet",contextWindow:2e5,costPer1kInput:.003,costPer1kOutput:.015,supportsVision:true,supportsJSON:true},"claude-3-opus-20240229":{provider:"anthropic",name:"Claude 3 Opus",contextWindow:2e5,costPer1kInput:.015,costPer1kOutput:.075,supportsVision:true,supportsJSON:true},"claude-3-haiku-20240307":{provider:"anthropic",name:"Claude 3 Haiku",contextWindow:2e5,costPer1kInput:25e-5,costPer1kOutput:.00125,supportsVision:true,supportsJSON:true}};var Uv={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},zv={generatePlan:{enabled:true,minPlanTier:"hobby",estimatedTokens:2e3},predictRisks:{enabled:true,minPlanTier:"pro",estimatedTokens:1500},suggestAssignee:{enabled:true,minPlanTier:"hobby",estimatedTokens:800},generateReport:{enabled:true,minPlanTier:"enterprise",estimatedTokens:3e3},generateSubtasks:{enabled:true,minPlanTier:"hobby",estimatedTokens:1e3}};function Hv(e,t,a){let r=Pl[e];if(!r)throw new Error(`Unknown model: ${e}`);let o=t/1e3*r.costPer1kInput,s=a/1e3*r.costPer1kOutput;return o+s}function un(e){return `$${e.toFixed(4)}`}var Ml=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=Hv(t.model,t.inputTokens,t.outputTokens),r={...t,id:`op_${Date.now()}_${Math.random().toString(36).substring(7)}`,timestamp:new Date,cost:a};return this.operations.push(r),this.listeners.forEach(o=>o(r)),this.operations.length>1e3&&(this.operations=this.operations.slice(-1e3)),r}getStats(t){let a=this.operations;t&&(a=a.filter(l=>l.timestamp>=t.start&&l.timestamp<=t.end));let r=a.length,o=a.reduce((l,f)=>l+f.cost,0),s=a.reduce((l,f)=>l+f.inputTokens,0),n=a.reduce((l,f)=>l+f.outputTokens,0),c=a.filter(l=>l.success),g=a.reduce((l,f)=>l+f.duration,0),i={},p={};return a.forEach(l=>{i[l.feature]=(i[l.feature]||0)+1,p[l.feature]=(p[l.feature]||0)+l.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:n,operationsByFeature:i,costsByFeature:p,averageDuration:r>0?g/r:0,successRate:r>0?c.length/r:0}}getRecentOperations(t=10){return this.operations.slice(-t).reverse()}checkLimit(t,a="month"){let o={hobby:{month:50,day:5},pro:{month:500,day:50},enterprise:{month:2e3,day:200}}[t][a],s=new Date,n=new Date;a==="month"?n.setMonth(s.getMonth()-1):n.setDate(s.getDate()-1);let c=this.operations.filter(p=>p.timestamp>=n).length,g=Math.max(0,o-c),i=c/o*100;return {used:c,limit:o,remaining:g,percentUsed:i,isExceeded:c>=o}}subscribe(t){return this.listeners.push(t),()=>{let a=this.listeners.indexOf(t);a>-1&&this.listeners.splice(a,1);}}clear(){this.operations=[];}export(){return JSON.stringify(this.operations,null,2)}},bo=new Ml;function $p({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(bo.getStats()),[s,n]=useState(bo.checkLimit(a));if(useEffect(()=>{if(!e)return;let g=setInterval(()=>{o(bo.getStats()),n(bo.checkLimit(a));},1e3);return ()=>clearInterval(g)},[e,a]),useEffect(()=>{let g=i=>{i.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,t]),!e)return null;let c=bo.getRecentOperations(5);return jsxs(ft,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:t}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-3xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:g=>g.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("h2",{className:"text-xl font-bold text-white",children:"AI Usage Dashboard"}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Monitor your AI consumption and costs"})]}),jsx("button",{onClick:t,className:"text-white/60 hover:text-white transition-colors",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-blue-500/10 to-purple-500/10 border border-blue-500/30",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("span",{className:"text-sm font-semibold text-white/90",children:["Monthly Usage (",a.toUpperCase(),")"]}),jsxs("span",{className:"text-sm font-bold text-white",children:[s.used," / ",s.limit]})]}),jsx("div",{className:"w-full h-2 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full transition-all",style:{width:`${Math.min(100,s.percentUsed)}%`,background:s.percentUsed>90?"#EF4444":s.percentUsed>70?"#F59E0B":"#10B981"}})}),jsxs("p",{className:"text-xs text-white/60 mt-2",children:[s.remaining," operations remaining this month"]})]}),jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Total Cost"}),jsx("p",{className:"text-2xl font-bold text-green-400 mt-1",children:un(r.totalCost)})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Operations"}),jsx("p",{className:"text-2xl font-bold text-blue-400 mt-1",children:r.totalOperations})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Tokens Used"}),jsx("p",{className:"text-2xl font-bold text-purple-400 mt-1",children:(r.totalInputTokens+r.totalOutputTokens).toLocaleString()}),jsxs("p",{className:"text-xs text-white/50 mt-1",children:[r.totalInputTokens.toLocaleString()," in /"," ",r.totalOutputTokens.toLocaleString()," out"]})]}),jsxs("div",{className:"p-4 rounded-lg bg-white/5 border border-white/10",children:[jsx("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Success Rate"}),jsxs("p",{className:"text-2xl font-bold text-green-400 mt-1",children:[(r.successRate*100).toFixed(1),"%"]}),jsxs("p",{className:"text-xs text-white/50 mt-1",children:["Avg: ",r.averageDuration.toFixed(0),"ms"]})]})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Usage by Feature"}),jsx("div",{className:"space-y-2",children:Object.entries(r.operationsByFeature).map(([g,i])=>{let p=r.costsByFeature[g]||0,l=r.totalOperations>0?i/r.totalOperations*100:0;return jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("span",{className:"text-sm font-medium text-white/90 capitalize",children:g.replace(/([A-Z])/g," $1").trim()}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[i," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:un(p)})]})]}),jsx("div",{className:"w-full h-1.5 bg-white/10 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500",style:{width:`${l}%`}})})]},g)})})]}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-3",children:"Recent Operations"}),c.length===0?jsx("p",{className:"text-sm text-white/50 text-center py-8",children:"No operations yet. Start using AI features!"}):jsx("div",{className:"space-y-2",children:c.map(g=>jsxs("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsx("p",{className:"text-sm font-medium text-white/90 capitalize",children:g.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(g.timestamp).toLocaleTimeString()," \u2022"," ",g.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[g.inputTokens+g.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:un(g.cost)}),jsx("div",{className:`w-2 h-2 rounded-full ${g.success?"bg-green-400":"bg-red-400"}`})]})]},g.id))})]})]}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("p",{className:"text-xs text-white/50",children:"Costs are estimates. Actual API charges may vary."}),jsx("button",{onClick:t,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80",children:"Close"})]})]})})]})}function Hp({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[n,c]=useState(""),[g,i]=useState(""),[p,l]=useState(""),[f,y]=useState(false),[k,C]=useState(null),[h,b]=useState(null),[u,x]=useState(null),m=useRef(null),N=f||o;useEffect(()=>{e&&m.current&&m.current.focus();},[e]),useEffect(()=>{let F=T=>{T.key==="Escape"&&!N&&w();};if(e)return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[e,N]);let w=()=>{N||(c(""),i(""),l(""),C(null),b(null),x(null),t());},B=async()=>{if(!(!n.trim()||N)){y(true),C(null),b(null),x(null);try{let F=await r({prompt:n.trim(),projectName:s||"Mi Proyecto",startDate:g||void 0,endDate:p||void 0});b(F.tasks.tasks),x({from_cache:F.from_cache,tokens_used:F.tokens_used,mock_mode:F.mock_mode,similarity:F.similarity,tokens_saved:F.tokens_saved});}catch(F){C(F instanceof Error?F.message:"Failed to generate tasks");}finally{y(false);}}},v=()=>{h&&(a(h),w());};if(!e)return null;let I=u?.similarity?((u.similarity||0)*100).toFixed(0):"0";return jsxs(ft,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:w}),jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100001] p-4",children:jsxs("div",{className:"w-full max-w-3xl rounded-2xl shadow-2xl border max-h-[90vh] overflow-hidden flex flex-col",style:{background:"linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%)",borderColor:"rgba(255, 255, 255, 0.15)",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1)"},onClick:F=>F.stopPropagation(),children:[jsxs("div",{className:"px-6 py-4 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-blue-400",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"9",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"14",width:"18",height:"2",rx:"1",fill:"currentColor"}),jsx("rect",{x:"3",y:"19",width:"18",height:"2",rx:"1",fill:"currentColor"})]}),"Generate Gantt Tasks with AI"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Describe your project and let AI create a complete task timeline"})]}),jsx("button",{onClick:w,disabled:N,className:"text-white/60 hover:text-white transition-colors disabled:opacity-50",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:h?jsx(Fragment,{children:jsxs("div",{className:"space-y-4",children:[jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M4 10L8 14L16 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jsx("span",{className:"font-semibold",children:"Tasks Generated Successfully!"})]}),jsxs("div",{className:"flex flex-wrap gap-2",children:[u?.mock_mode&&jsx("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-yellow-500/20 text-yellow-400 border border-yellow-500/30",children:"Mock Mode"}),u?.from_cache?jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-blue-500/20 text-blue-400 border border-blue-500/30",children:["From Cache (",I,"% similar)"]}):jsx("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-green-500/20 text-green-400 border border-green-500/30",children:"AI Generated"}),jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-purple-500/20 text-purple-400 border border-purple-500/30",children:[u?.tokens_used||0," tokens"]}),u?.tokens_saved&&jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-indigo-500/20 text-indigo-400 border border-indigo-500/30",children:[u.tokens_saved," tokens saved"]}),jsxs("span",{className:"px-2 py-1 rounded-lg text-xs font-semibold bg-pink-500/20 text-pink-400 border border-pink-500/30",children:[h.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:h.map((F,T)=>jsx("div",{className:"p-3 rounded-lg bg-white/5 border border-white/10 hover:bg-white/10 transition-colors",children:jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex-1",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsxs("span",{className:"text-xs text-white/50",children:["#",T+1]}),jsx("p",{className:"text-sm font-medium text-white/90",children:F.name})]}),jsxs("div",{className:"flex items-center gap-3 text-xs text-white/60",children:[jsxs("span",{className:"flex items-center gap-1",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-white/40",children:[jsx("rect",{x:"1",y:"2",width:"10",height:"8",rx:"1",stroke:"currentColor"}),jsx("path",{d:"M1 4h10",stroke:"currentColor"})]}),F.start," \u2192 ",F.end]}),jsxs("span",{children:[F.duration," days"]}),F.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",F.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${F.priority==="high"?"bg-red-500/20 text-red-400":F.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:F.priority})]})},F.id))})]})}):jsxs(Fragment,{children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Project Description *"}),jsx("textarea",{ref:m,value:n,onChange:F=>c(F.target.value),placeholder:"Example: Build a mobile app for tracking fitness goals with user authentication, workout logging, progress charts, and social features...",className:"w-full h-32 px-4 py-3 rounded-lg text-sm bg-white/5 border border-white/20 text-white placeholder-white/40 outline-none focus:border-blue-500/50 transition-all resize-none",disabled:N}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"Start Date (Optional)"}),jsx("input",{type:"date",value:g,onChange:F=>i(F.target.value),className:"w-full px-4 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white outline-none focus:border-blue-500/50 transition-all",disabled:N})]}),jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-2",children:"End Date (Optional)"}),jsx("input",{type:"date",value:p,onChange:F=>l(F.target.value),className:"w-full px-4 py-2 rounded-lg text-sm bg-white/5 border border-white/20 text-white outline-none focus:border-blue-500/50 transition-all",disabled:N})]})]}),k&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:k}),jsxs("div",{className:"border-t border-white/10 pt-4",children:[jsx("p",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider mb-3",children:"Example Prompts"}),jsx("div",{className:"space-y-2",children:["Build an e-commerce platform with product catalog, shopping cart, payment integration, and order tracking","Create a task management app with team collaboration, real-time updates, file attachments, and notifications","Develop a blog platform with markdown editor, SEO optimization, comments system, and analytics dashboard"].map((F,T)=>jsx("button",{onClick:()=>c(F),disabled:N,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-white/70 hover:text-white hover:bg-white/5 transition-all border border-white/10 hover:border-white/20 disabled:opacity-50",children:F},T))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:N&&jsxs("div",{className:"flex items-center gap-2 text-blue-400 text-sm",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),jsx("span",{children:"Generating with AI..."})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:w,disabled:N,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-all hover:bg-white/10 text-white/80 disabled:opacity-50",children:"Cancel"}),h?jsx("button",{onClick:v,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Tasks to Gantt"}):jsx("button",{onClick:B,disabled:!n.trim()||N,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#ffffff"},children:N?"Generating...":"Generate Tasks"})]})]})]})})]})}function ws({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(h=>{t&&Cn(()=>Promise.resolve(t(h)),{maxAttempts:3,initialDelay:1e3,onRetry:(b,u,x)=>{console.warn(`Retry attempt ${u} after ${x}ms: ${b.message}`);}}).then(b=>{b.success||console.error(`Failed to persist board after ${b.attempts} attempts:`,b.error);});},[t]),s=useCallback(async(h,b,u)=>{r(x=>{let m=x.cards.find(F=>F.id===h);if(!m)return x;let N=m.columnId,w={...m,columnId:b,position:u},B=x.cards.map(F=>F.id===h?w:F),v=x.columns.map(F=>{if(F.id===N)return {...F,cardIds:F.cardIds.filter(T=>T!==h)};if(F.id===b){let T=B.filter(H=>H.columnId===b).sort((H,O)=>H.position-O.position);return {...F,cardIds:T.map(H=>H.id)}}return F}),I={...x,cards:B,columns:v};return o(I),I});},[o]),n=useCallback(async(h,b)=>{r(u=>{let x=u.cards.map(N=>N.id===h?{...N,...b}:N),m={...u,cards:x};return o(m),m});},[o]),c=useCallback(async h=>{let b=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(u=>{let x={...h,id:b},m=u.columns.map(w=>w.id===h.columnId?{...w,cardIds:[...w.cardIds,b]}:w),N={...u,cards:[...u.cards,x],columns:m};return o(N),N});},[o]),g=useCallback(async h=>{r(b=>{let u=b.cards.find(w=>w.id===h);if(!u)return b;let x=b.cards.filter(w=>w.id!==h),m=b.columns.map(w=>w.id===u.columnId?{...w,cardIds:w.cardIds.filter(B=>B!==h)}:w),N={...b,cards:x,columns:m};return o(N),N});},[o]),i=useCallback(async h=>{let b=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(u=>{let x={...h,id:b,cardIds:[]},m={...u,columns:[...u.columns,x]};return o(m),m});},[o]),p=useCallback(async(h,b)=>{r(u=>{let x=u.columns.map(N=>N.id===h?{...N,...b}:N),m={...u,columns:x};return o(m),m});},[o]),l=useCallback(async h=>{r(b=>{let u=b.cards.filter(N=>N.columnId!==h),x=b.columns.filter(N=>N.id!==h),m={...b,cards:u,columns:x};return o(m),m});},[o]),f=useCallback(h=>{let b=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(h),b},[c]),y=useCallback(h=>{let b=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return i(h),b},[i]),k=useCallback(()=>{r(h=>{let b={...h,cards:[],columns:[]};return o(b),b});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:n,onCardCreate:c,onCardDelete:g,onColumnCreate:i,onColumnUpdate:p,onColumnDelete:l},setBoard:r,helpers:{addCard:f,addColumn:y,deleteCard:g,deleteColumn:l,clearBoard:k}}}function Gp({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=ws({initialBoard:e,onPersist:a}),n=useMemo(()=>({addCard:(g,i,p={})=>{s.addCard({title:i,columnId:g,position:r.cards.filter(l=>l.columnId===g).length,...p});},addColumn:(g,i)=>{let p=r.columns.length>0?Math.max(...r.columns.map(l=>l.position)):0;s.addColumn({title:g,position:i??p+1e3});},reset:s.clearBoard}),[r.cards,r.columns,s]);return {props:useMemo(()=>({board:r,callbacks:o,availableUsers:t}),[r,o,t]),board:r,callbacks:o,utils:n}}var gn={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},Vp={by:"none",order:"asc"};function jp({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...gn,...e}),[s,n]=useState({...Vp,...t}),c=useCallback(C=>{o(h=>({...h,...C}));},[]),g=useCallback(C=>{n(h=>({...h,...C}));},[]),i=useCallback(()=>{o(gn),n(Vp);},[]),p=useCallback(()=>{a&&o({...gn,assignees:[a]});},[a]),l=useCallback(()=>{o({...gn,dateFilter:"overdue"});},[]),f=useCallback(()=>{o({...gn,priorities:["HIGH","URGENT"]});},[]),y=useMemo(()=>r.dateFilter!=="all"||r.priorities.length>0||r.assignees.length>0||r.labels.length>0||r.columns.length>0||r.search!==""||s.by!=="none",[r,s]),k=useCallback(C=>{let h=[...C];if(r.search){let b=r.search.toLowerCase();h=h.filter(u=>u.title.toLowerCase().includes(b)||u.description?.toLowerCase().includes(b));}if(r.dateFilter!=="all"){let b=new Date,u=b.getFullYear(),x=String(b.getMonth()+1).padStart(2,"0"),m=String(b.getDate()).padStart(2,"0"),N=`${u}-${x}-${m}`;h=h.filter(w=>{if(!w.endDate&&!w.dueDate)return false;let B=w.endDate||w.dueDate;if(!B)return false;let v;if(typeof B=="string")v=B.split("T")[0]||B;else {let I=B.getUTCFullYear(),F=String(B.getUTCMonth()+1).padStart(2,"0"),T=String(B.getUTCDate()).padStart(2,"0");v=`${I}-${F}-${T}`;}switch(r.dateFilter){case "overdue":return v<N;case "today":return v===N;case "this-week":let I=new Date(N+"T00:00:00"),F=new Date(v+"T00:00:00"),T=new Date(I);return T.setDate(T.getDate()+7),F>=I&&F<=T;case "custom":if(r.dateRange){let H=typeof B=="string"?new Date(B):B;return H>=r.dateRange.start&&H<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(h=h.filter(b=>b.priority&&r.priorities.includes(b.priority))),r.assignees.length>0&&(h=h.filter(b=>(b.assignedUserIds||(b.assigneeId?[b.assigneeId]:[])).some(x=>r.assignees.includes(x)))),r.labels.length>0&&(h=h.filter(b=>b.labels&&b.labels.some(u=>r.labels.includes(u)))),r.columns.length>0&&(h=h.filter(b=>r.columns.includes(b.columnId))),s.by!=="none"&&h.sort((b,u)=>{let x=0;switch(s.by){case "created":let m=b.createdAt?new Date(b.createdAt).getTime():0,N=u.createdAt?new Date(u.createdAt).getTime():0;x=m-N;break;case "priority":let w={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},B=w[b.priority||"LOW"],v=w[u.priority||"LOW"];x=B-v;break;case "dueDate":let I=b.endDate||b.dueDate,F=u.endDate||u.dueDate;if(!I)return 1;if(!F)return -1;let T=typeof I=="string"?new Date(I).getTime():I.getTime(),H=typeof F=="string"?new Date(F).getTime():F.getTime();x=T-H;break;case "title":x=b.title.localeCompare(u.title);break;case "estimate":let O=b.estimatedTime||0,K=u.estimatedTime||0;x=O-K;break;default:x=0;}return s.order==="asc"?x:-x}),h},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:g,resetFilters:i,filterMyTasks:p,filterOverdue:l,filterHighPriority:f,applyFilters:k,hasActiveFilters:y}}var Yp,qp;if(typeof window<"u")try{let e=xn("ai");Yp=e.generateObject,qp=e.generateText;}catch{}function Xp(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(Yp&&qp&&e.apiKey),n=useCallback(async l=>{if(!s)throw new Error('AI features require the "ai" package and an API key. Install with: npm install ai');a(true),o(null);try{return console.log("Generating plan for:",l),{columns:[{title:"To Do",position:1e3,cardIds:[]},{title:"In Progress",position:2e3,cardIds:[]},{title:"Done",position:3e3,cardIds:[]}],cards:[{title:"Generated task from AI",description:`Based on: ${l}`,position:1e3,columnId:"temp-col-1"}],explanation:"This is a sample plan. Real implementation would use AI SDK."}}catch(f){let y=f instanceof Error?f:new Error("Failed to generate plan");throw o(y),y}finally{a(false);}},[s]),c=useCallback(async l=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Suggesting assignee for:",l.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(f){let y=f instanceof Error?f:new Error("Failed to suggest assignee");throw o(y),y}finally{a(false);}},[s]),g=useCallback(async l=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Analyzing board for risks..."),[{type:"RISK_OVERLOAD",severity:"HIGH",title:"Column overload detected",description:'Too many cards in "In Progress"',confidence:.9,suggestedAction:'Consider moving some cards back to "To Do"'}]}catch(f){let y=f instanceof Error?f:new Error("Failed to predict risks");throw o(y),y}finally{a(false);}},[s]),i=useCallback(async l=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Generating subtasks for:",l.title),[{title:`Subtask 1 for: ${l.title}`,position:l.position+.1,columnId:l.columnId},{title:`Subtask 2 for: ${l.title}`,position:l.position+.2,columnId:l.columnId}]}catch(f){let y=f instanceof Error?f:new Error("Failed to generate subtasks");throw o(y),y}finally{a(false);}},[s]),p=useCallback(async l=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Estimating effort for:",l.title),{hours:8,confidence:.75}}catch(f){let y=f instanceof Error?f:new Error("Failed to estimate effort");throw o(y),y}finally{a(false);}},[s]);return {onGeneratePlan:n,onSuggestAssignee:c,onPredictRisks:g,onGenerateSubtasks:i,onEstimateEffort:p,isAvailable:s,isLoading:t,error:r}}function Fl(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function Jp(e){let{cards:t}=e,[a,r]=Fl(),o=useCallback(l=>a.selectedCardIds.includes(l),[a.selectedCardIds]),s=useCallback((l,f)=>{if(!f){r({selectedCardIds:[l],lastSelectedCardId:l});return}let y=f.ctrlKey||f.metaKey,k=f.shiftKey;if(y)a.selectedCardIds.includes(l)?r({selectedCardIds:a.selectedCardIds.filter(C=>C!==l),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,l],lastSelectedCardId:l});else if(k&&a.lastSelectedCardId){let C=t.find(b=>b.id===l),h=t.find(b=>b.id===a.lastSelectedCardId);if(C&&h&&C.columnId===h.columnId){let b=t.filter(v=>v.columnId===C.columnId).sort((v,I)=>v.position-I.position),u=b.findIndex(v=>v.id===a.lastSelectedCardId),x=b.findIndex(v=>v.id===l),[m,N]=u<x?[u,x]:[x,u],w=b.slice(m,N+1).map(v=>v.id),B=Array.from(new Set([...a.selectedCardIds,...w]));r({selectedCardIds:B,lastSelectedCardId:l});}else r({selectedCardIds:[l],lastSelectedCardId:l});}else r({selectedCardIds:[l],lastSelectedCardId:l});},[t,a,r]),n=useCallback(l=>{r({selectedCardIds:a.selectedCardIds.filter(f=>f!==l),lastSelectedCardId:a.lastSelectedCardId});},[a,r]),c=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),g=useCallback(()=>{r({selectedCardIds:t.map(l=>l.id),lastSelectedCardId:t[t.length-1]?.id||null});},[t,r]),i=useCallback(l=>{a.selectedCardIds.includes(l)?n(l):r({selectedCardIds:[...a.selectedCardIds,l],lastSelectedCardId:l});},[a,n,r]),p=useCallback(()=>t.filter(l=>a.selectedCardIds.includes(l.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:n,clearSelection:c,selectAll:g,toggleCard:i,getSelectedCards:p}}var Zp={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function Qp(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...Zp,...a}),[a]),[s,n]=useState([]),c=useCallback((C,h,b,u,x)=>{if(h.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let m={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:C,cardIds:h,columnId:b,strategy:u,color:x,isExpanded:true,position:s.filter(N=>N.columnId===b).length,createdAt:new Date};n(N=>[...N,m]);},[o.minCardsPerStack,s]),g=useCallback(C=>{n(h=>h.filter(b=>b.id!==C));},[]),i=useCallback(C=>{n(h=>h.map(b=>b.id===C?{...b,isExpanded:!b.isExpanded}:b));},[]),p=useCallback((C,h)=>{n(b=>b.map(u=>u.id===C&&!u.cardIds.includes(h)?{...u,cardIds:[...u.cardIds,h]}:u));},[]),l=useCallback((C,h)=>{n(b=>b.map(u=>{if(u.id===C){let x=u.cardIds.filter(m=>m!==h);return x.length<o.minCardsPerStack?null:{...u,cardIds:x}}return u}).filter(u=>u!==null));},[o.minCardsPerStack]),f=useCallback(C=>s.filter(h=>h.columnId===C).sort((h,b)=>h.position-b.position),[s]),y=useCallback(async C=>{let h=t.filter(N=>N.columnId===C);if(h.length<o.minCardsPerStack*2)return [];let b=[],u=new Map;h.forEach(N=>{N.labels&&N.labels.length>0&&N.labels.forEach(w=>{u.has(w)||u.set(w,[]),u.get(w).push(N);});}),u.forEach((N,w)=>{N.length>=o.minCardsPerStack&&b.push({stack:{title:`\u{1F4CC} ${w}`,cardIds:N.map(B=>B.id),columnId:C,strategy:"labels",color:"#3b82f6"},reason:`${N.length} cards with label "${w}"`,confidence:.85});});let x=new Map;h.forEach(N=>{N.assignedUserIds&&N.assignedUserIds.length>0&&N.assignedUserIds.forEach(w=>{x.has(w)||x.set(w,[]),x.get(w).push(N);});}),x.forEach((N,w)=>{N.length>=o.minCardsPerStack&&b.push({stack:{title:`\u{1F464} Assigned to user-${w.slice(-4)}`,cardIds:N.map(B=>B.id),columnId:C,strategy:"assignee",color:"#8b5cf6"},reason:`${N.length} cards assigned to the same user`,confidence:.8});});let m=new Map;if(h.forEach(N=>{N.priority&&(m.has(N.priority)||m.set(N.priority,[]),m.get(N.priority).push(N));}),m.forEach((N,w)=>{if(N.length>=o.minCardsPerStack){let B={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[w.toLowerCase()]||"\u26AA";b.push({stack:{title:`${B} ${w} Priority`,cardIds:N.map(v=>v.id),columnId:C,strategy:"priority",color:w==="high"||w==="urgent"?"#ef4444":"#10b981"},reason:`${N.length} cards with ${w} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let N of h){let B=(await r.findSimilar(N,h)).filter(v=>v.similarity>=o.autoStackConfidenceThreshold);if(B.length>=o.minCardsPerStack-1){let v=[N.id,...B.map(F=>F.card.id)],I=B.reduce((F,T)=>F+T.similarity,0)/B.length;b.push({stack:{title:`\u2728 Similar to "${N.title.substring(0,30)}${N.title.length>30?"...":""}"`,cardIds:v,columnId:C,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${B.length+1} similar tasks`,confidence:I});}}return b.filter(N=>N.confidence>=o.autoStackConfidenceThreshold).sort((N,w)=>w.confidence-N.confidence).slice(0,5)},[t,o,r]),k=useCallback(C=>{c(C.stack.title,C.stack.cardIds,C.stack.columnId,C.stack.strategy,C.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(h=>h.columnId)).forEach(async h=>{let b=await y(h),u=b[0];b.length>0&&u&&u.confidence>=.9&&k(u);});},[]),{stacks:s,createStack:c,deleteStack:g,toggleStack:i,addToStack:p,removeFromStack:l,getStacksForColumn:f,getSuggestions:y,applySuggestion:k,config:o}}var eu=createContext(null);function tu({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,n=new Map;t?.columns?.forEach(g=>{let{Column:i}=xn("@libxai/core");s.set(g.id,new i(g));}),t?.cards?.forEach(g=>{let{Card:i}=xn("@libxai/core");n.set(g.id,new i(g));});let c=null;if(t?.board){let{Board:g}=xn("@libxai/core");c=new g(t.board);}r.current=new BoardStore({board:c,columns:s,cards:n});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(eu.Provider,{value:{store:o},children:e})}function Cs(){let e=useContext(eu);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function bn(){let e=Cs(),[t,a]=useState(e.getBoard()),[r,o]=useState(e.getAllColumns()),[s,n]=useState(e.getAllCards());useEffect(()=>e.subscribeAll(()=>{a(e.getBoard()),o(e.getAllColumns()),n(e.getAllCards());}),[e]);let c=useCallback(u=>{e.updateBoard(u);},[e]),g=useCallback(u=>{e.addColumn(u);},[e]),i=useCallback((u,x)=>{e.updateColumn(u,x);},[e]),p=useCallback(u=>{e.deleteColumn(u);},[e]),l=useCallback(u=>e.getColumn(u),[e]),f=useCallback(u=>{e.addCard(u);},[e]),y=useCallback((u,x)=>{e.updateCard(u,x);},[e]),k=useCallback(u=>{e.deleteCard(u);},[e]),C=useCallback((u,x,m)=>{e.moveCard(u,x,m);},[e]),h=useCallback(u=>e.getCard(u),[e]),b=useCallback(u=>e.getCardsByColumn(u),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:g,updateColumn:i,deleteColumn:p,getColumn:l,addCard:f,updateCard:y,deleteCard:k,moveCard:C,getCard:h,getCardsByColumn:b}}function ru(e){let{cards:t}=bn();return useMemo(()=>e?t.filter(a=>{if(e.searchQuery){let r=e.searchQuery.toLowerCase(),o=a.title.toLowerCase().includes(r),s=a.description?.toLowerCase().includes(r);if(!o&&!s)return false}return !(e.priorities&&e.priorities.length>0&&(!a.priority||!e.priorities.includes(a.priority))||e.statuses&&e.statuses.length>0&&(!a.status||!e.statuses.includes(a.status))||e.assignedUserIds&&e.assignedUserIds.length>0&&!e.assignedUserIds.some(o=>a.isAssignedTo(o))||e.labels&&e.labels.length>0&&!e.labels.some(o=>a.hasLabel(o))||e.columnIds&&e.columnIds.length>0&&!e.columnIds.includes(a.columnId)||e.isOverdue!==void 0&&e.isOverdue!==a.isOverdue())}):t,[t,e])}function ou(e="position",t="asc"){let{cards:a}=bn();return useMemo(()=>[...a].sort((o,s)=>{let n=0;switch(e){case "title":n=o.title.localeCompare(s.title);break;case "priority":{let c={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},g=o.priority?c[o.priority]:0,i=s.priority?c[s.priority]:0;n=g-i;break}case "createdAt":n=o.createdAt.getTime()-s.createdAt.getTime();break;case "updatedAt":n=o.updatedAt.getTime()-s.updatedAt.getTime();break;case "position":n=o.position-s.position;break}return t==="asc"?n:-n}),[a,e,t])}var Ts=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=md.child("PluginManager");}setContext(t){this.context=t;}register(t){if(!t.id||!t.name||!t.version)throw new Error("Plugin must have id, name, and version");if(this.plugins.has(t.id)&&this.pluginLogger.warn(`Plugin ${t.id} is already registered, overwriting...`),t.dependencies){for(let a of t.dependencies)if(!this.plugins.has(a))throw new Error(`Plugin ${t.id} depends on ${a} which is not registered`)}this.plugins.set(t.id,t),t.defaultConfig&&this.config.set(t.id,{...t.defaultConfig}),this.enabled.add(t.id),this.pluginLogger.info(`Plugin registered: ${t.name} v${t.version}`),t.onInit&&this.context&&Promise.resolve(t.onInit(this.context)).catch(a=>{this.pluginLogger.error(`Failed to initialize plugin ${t.id}`,a,{plugin:t.id});});}unregister(t){let a=this.plugins.get(t);if(!a){this.pluginLogger.warn(`Plugin ${t} is not registered`);return}a.onDestroy&&Promise.resolve(a.onDestroy()).catch(r=>{this.pluginLogger.error(`Failed to destroy plugin ${t}`,r);}),this.plugins.delete(t),this.enabled.delete(t),this.config.delete(t),this.pluginLogger.info(`Plugin unregistered: ${a.name}`);}getPlugin(t){return this.plugins.get(t)}getPlugins(){return Array.from(this.plugins.values())}hasPlugin(t){return this.plugins.has(t)}setEnabled(t,a){if(!this.plugins.has(t))throw new Error(`Plugin ${t} is not registered`);a?(this.enabled.add(t),this.pluginLogger.info(`Plugin enabled: ${t}`)):(this.enabled.delete(t),this.pluginLogger.info(`Plugin disabled: ${t}`));}isEnabled(t){return this.enabled.has(t)}getConfig(t,a){return this.config.get(t)?.[a]}setConfig(t,a,r){this.config.has(t)||this.config.set(t,{});let o=this.config.get(t);o[a]=r,this.pluginLogger.debug(`Plugin config set: ${t}.${a}`,{value:r});}async executeHook(t,a,r){let o=r;for(let s of this.plugins.values()){if(!this.enabled.has(s.id))continue;let n=s[t];if(typeof n=="function")try{let c=await Promise.resolve(n.apply(s,a));c!==void 0&&(o=c,a[0]=c);}catch(c){this.pluginLogger.error(`Plugin hook failed: ${s.id}.${t}`,c,{plugin:s.id,hook:t});}}return o}async executeHookParallel(t,a){let r=[];for(let o of this.plugins.values()){if(!this.enabled.has(o.id))continue;let s=o[t];typeof s=="function"&&r.push(Promise.resolve(s.apply(o,a)).catch(n=>{this.pluginLogger.error(`Plugin hook failed: ${o.id}.${t}`,n,{plugin:o.id,hook:t});}));}await Promise.all(r);}},ox=new Ts;function su({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:n=false,gap:c=0,getItemKey:g}){let i=useRef(null),p=useVirtualizer({count:e.length,getScrollElement:()=>i.current,estimateSize:()=>a,overscan:s,horizontal:n,gap:c}),l=p.getVirtualItems(),f={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},y=n?{width:`${p.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${p.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:i,style:f,className:o,children:jsx("div",{style:y,children:l.map(k=>{let C=e[k.index];if(!C)return null;let h=g?g(C,k.index):k.index,b={position:"absolute",top:n?0:k.start,left:n?k.start:0,width:n?k.size:"100%",height:n?"100%":k.size};return jsx("div",{style:b,"data-index":k.index,children:r(C,k.index)},h)})})})}function iu(e){return useVirtualizer({count:e.items.length,getScrollElement:()=>e.scrollElement,estimateSize:()=>e.estimateSize,overscan:e.overscan??5,horizontal:e.horizontal??false,gap:e.gap??0})}function du({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:n=3,gap:c=16,getItemKey:g,horizontal:i=true}){let p=useRef(null),l=useVirtualizer({horizontal:i,count:e.length,getScrollElement:()=>p.current,estimateSize:()=>r,overscan:n,gap:c}),f=l.getVirtualItems(),y={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},k={width:`${l.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:p,style:y,className:s,children:jsx("div",{style:k,children:f.map(C=>{let h=e[C.index];if(!h)return null;let b=g?g(h,C.index):C.index,u={position:"absolute",top:0,left:C.start,width:C.size,height:"100%"};return jsx("div",{style:u,"data-index":C.index,children:o(h,C.index)},b)})})})}function cu(e){let t=useVirtualizer({horizontal:true,count:e.items.length,getScrollElement:()=>e.scrollElement,estimateSize:()=>e.estimateColumnWidth,overscan:e.overscan??3,gap:e.gap??0});return {columnVirtualizer:t,virtualColumns:t.getVirtualItems(),totalWidth:t.getTotalSize()}}function mu(e,t=10){return e>t}var Rl={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},Ol={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},$l={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},Ul={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},zl={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},Hl={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Wl={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Gl={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",smooth:"cubic-bezier(0.4, 0.0, 0.2, 1)",sharp:"cubic-bezier(0.4, 0.0, 0.6, 1)",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},_l={none:"none",sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",base:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)","2xl":"0 25px 50px -12px rgba(0, 0, 0, 0.25)",inner:"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},Vl={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},jl={column:{width:320,minWidth:280,maxWidth:400,gap:16,padding:12,headerHeight:48},card:{minHeight:80,maxHeight:400,padding:12,gap:8},board:{padding:16,gap:16}},Kl={timeline:{headerHeight:60,rowHeight:44,minRowHeight:32,maxRowHeight:80,taskPadding:4,gridLineWidth:1},task:{height:28,minHeight:20,maxHeight:40,borderRadius:4,padding:6},dependency:{lineWidth:2,arrowSize:8},scale:{day:{columnWidth:40,minColumnWidth:30,maxColumnWidth:60},week:{columnWidth:80,minColumnWidth:60,maxColumnWidth:120},month:{columnWidth:120,minColumnWidth:80,maxColumnWidth:200},quarter:{columnWidth:200,minColumnWidth:150,maxColumnWidth:300}},milestone:{size:16,rotation:45}},Ns={spacing:Rl,borderRadius:Ol,fontSize:$l,fontWeight:Ul,lineHeight:zl,zIndex:Hl,duration:Wl,easing:Gl,shadows:_l,opacity:Vl,kanban:jl,gantt:Kl};function pu(e,t,a){return e[t]??a}function Yl(e,t="",a={}){for(let[r,o]of Object.entries(e)){let s=t?`${t}-${r}`:r;typeof o=="object"&&o!==null&&!Array.isArray(o)?Yl(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function ix(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function ql(e="asakaa"){let t=Yl(Ns),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,n=ix(o);a.push(` ${s}: ${n};`);}return `:root {
|
|
390
390
|
${a.join(`
|
|
391
391
|
`)}
|
|
392
|
-
}`}function hn(e,t="asakaa"){let a=[],r=
|
|
392
|
+
}`}function hn(e,t="asakaa"){let a=[],r=Yl(e);for(let[o,s]of Object.entries(r)){let n=`--${t}-color-${o}`;a.push(` ${n}: ${s};`);}return `:root {
|
|
393
393
|
${a.join(`
|
|
394
394
|
`)}
|
|
395
|
-
}`}var Ds={background:{primary:"#1a1a1a",secondary:"#2a2a2a",tertiary:"#3a3a3a",card:"#2d2d2d",hover:"#353535",active:"#404040"},text:{primary:"#ffffff",secondary:"#b0b0b0",tertiary:"#808080",disabled:"#606060",inverse:"#1a1a1a"},border:{default:"#404040",hover:"#505050",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#22c55e",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},priority:{low:"#6b7280",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#6b7280",secondaryHover:"#4b5563",secondaryActive:"#374151"},gantt:{gridLine:"#404040",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#6b7280",weekend:"#2a2a2a"}},
|
|
395
|
+
}`}var Ds={background:{primary:"#1a1a1a",secondary:"#2a2a2a",tertiary:"#3a3a3a",card:"#2d2d2d",hover:"#353535",active:"#404040"},text:{primary:"#ffffff",secondary:"#b0b0b0",tertiary:"#808080",disabled:"#606060",inverse:"#1a1a1a"},border:{default:"#404040",hover:"#505050",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#22c55e",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},priority:{low:"#6b7280",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#6b7280",secondaryHover:"#4b5563",secondaryActive:"#374151"},gantt:{gridLine:"#404040",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#6b7280",weekend:"#2a2a2a"}},Xl={background:{primary:"#ffffff",secondary:"#f9fafb",tertiary:"#f3f4f6",card:"#ffffff",hover:"#f3f4f6",active:"#e5e7eb"},text:{primary:"#111827",secondary:"#6b7280",tertiary:"#9ca3af",disabled:"#d1d5db",inverse:"#ffffff"},border:{default:"#e5e7eb",hover:"#d1d5db",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#2563eb"},priority:{low:"#9ca3af",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#6b7280",secondaryHover:"#4b5563",secondaryActive:"#374151"},gantt:{gridLine:"#e5e7eb",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#6b7280",weekend:"#f9fafb"}},Jl={background:{primary:"#18181b",secondary:"#27272a",tertiary:"#3f3f46",card:"#27272a",hover:"#3f3f46",active:"#52525b"},text:{primary:"#fafafa",secondary:"#a1a1aa",tertiary:"#71717a",disabled:"#52525b",inverse:"#18181b"},border:{default:"#3f3f46",hover:"#52525b",focus:"#0ea5e9",active:"#0284c7"},status:{success:"#22c55e",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},priority:{low:"#71717a",medium:"#3b82f6",high:"#f59e0b",urgent:"#ef4444"},interactive:{primary:"#0ea5e9",primaryHover:"#0284c7",primaryActive:"#0369a1",secondary:"#71717a",secondaryHover:"#52525b",secondaryActive:"#3f3f46"},gantt:{gridLine:"#3f3f46",todayLine:"#0ea5e9",taskBackground:"#3b82f6",taskBorder:"#2563eb",criticalPath:"#ef4444",milestone:"#3b82f6",dependency:"#71717a",weekend:"#27272a"}};function Zl(e=Ds,t="asakaa"){let a=ql(t),r=hn(e,t);return `${a}
|
|
396
396
|
|
|
397
|
-
${r}`}function
|
|
397
|
+
${r}`}function uu(){return `/**
|
|
398
398
|
* ASAKAA Design Tokens
|
|
399
399
|
* Auto-generated from design-tokens.ts
|
|
400
400
|
* Do not edit this file directly
|
|
401
401
|
*/
|
|
402
402
|
|
|
403
|
-
${
|
|
403
|
+
${Zl(Ds)}
|
|
404
404
|
|
|
405
405
|
/* Light theme */
|
|
406
406
|
[data-theme="light"] {
|
|
407
|
-
${hn(
|
|
407
|
+
${hn(Xl,"asakaa").split(`
|
|
408
408
|
`).slice(1,-1).join(`
|
|
409
409
|
`)}
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
/* Neutral theme */
|
|
413
413
|
[data-theme="neutral"] {
|
|
414
|
-
${hn(
|
|
414
|
+
${hn(Jl,"asakaa").split(`
|
|
415
415
|
`).slice(1,-1).join(`
|
|
416
416
|
`)}
|
|
417
417
|
}
|
|
418
|
-
`}var
|
|
419
|
-
export{
|
|
418
|
+
`}var lx=({theme:e})=>{switch(e){case "dark":return jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M13.5 8.5C13.5 11.2614 11.2614 13.5 8.5 13.5C5.73858 13.5 3.5 11.2614 3.5 8.5C3.5 5.73858 5.73858 3.5 8.5 3.5C8.66667 3.5 8.83074 3.50926 8.99199 3.52734C8.10635 4.35233 7.5 5.53318 7.5 6.85C7.5 9.33579 9.49421 11.33 11.98 11.33C12.5933 11.33 13.1751 11.2075 13.7069 10.9844C13.5698 11.8951 13.2042 12.7349 12.6674 13.4367",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});case "light":return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 1V2M8 14V15M15 8H14M2 8H1M12.5 12.5L11.8 11.8M4.2 4.2L3.5 3.5M12.5 3.5L11.8 4.2M4.2 11.8L3.5 12.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "neutral":return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M5 8L8 8L8 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}};function gu({showLabels:e=true,compact:t=false,className:a=""}){let{theme:r,setTheme:o,themes:s}=Ao();return jsx("div",{className:`theme-switcher ${t?"theme-switcher--compact":""} ${a}`,children:Object.entries(s).map(([n,c])=>{let g=n,i=g===r;return jsxs("button",{onClick:()=>o(g),className:`theme-switcher__button ${i?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${c.displayName} theme`,"aria-pressed":i,title:c.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(lx,{theme:g})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:c.displayName})]},g)})})}
|
|
419
|
+
export{$p as AIUsageDashboard,zv as AI_FEATURES,Pl as AI_MODELS,ai as AddCardButton,ti as AddColumnButton,kr as AttachmentUploader,tu as BoardProvider,On as BulkOperationsToolbar,gi as BurnDownChart,pp as CUSTOM_FIELD_TYPES,wp as CalendarBoard,Sr as Card,li as CardDetailModal,mi as CardDetailModalV2,Pp as CardHistoryReplay,Sp as CardHistoryTimeline,Fp as CardRelationshipsGraph,Av as CardStack,ki as CardTemplateSelector,Rs as CircuitBreaker,No as Column,_n as ColumnManager,ni as CommandPalette,Ni as ConfigMenu,Io as ContextMenu,Zo as DEFAULT_SHORTCUTS,cp as DEFAULT_TABLE_COLUMNS,xi as DEFAULT_TEMPLATES,Wo as DateRangePicker,_o as DependenciesSelector,Zn as DependencyLine,fi as DistributionCharts,_s as EditableColumnTitle,So as ErrorBoundary,Ci as ExportImportModal,Ti as FilterBar,bm as GANTT_AI_SYSTEM_PROMPT,rs as GanttAIAssistant,pm as GanttBoard,Lo as GanttI18nContext,es as GanttMilestone,Gn as GanttToolbar,Hp as GenerateGanttTasksDialog,Bp as GeneratePlanModal,yi as GroupBySelector,zr as KanbanBoard,Qs as KanbanToolbar,qo as KanbanViewAdapter,vi as KeyboardShortcutsHelp,dp as ListView,Gt as MenuIcons,Ts as PluginManager,ao as PrioritySelector,Uv as RATE_LIMITS,mp as STANDARD_FIELDS,bi as SwimlaneBoardView,js as TagBadge,Kd as TagList,hr as TagPicker,qn as TaskBar,io as TaskDetailModal,fm as TaskFormModal,Kn as TaskGrid,Pi as ThemeModal,Ac as ThemeProvider,gu as ThemeSwitcher,as as Timeline,oo as UserAssignmentSelector,ui as VelocityChart,du as VirtualGrid,su as VirtualList,bo as aiUsageTracker,Ol as borderRadius,wn as calculatePosition,Tl as calendarDarkTheme,bl as calendarEnTranslations,hl as calendarEsTranslations,Nl as calendarLightTheme,Dl as calendarNeutralTheme,vs as calendarThemes,bs as calendarTranslations,ns as cardToGanttTask,Cm as cardsToGanttTasks,d as cn,cc as createKanbanView,$u as createRetryWrapper,Di as darkTheme,Ds as darkTokenTheme,Un as defaultTheme,Ns as designTokens,Wl as duration,Gl as easing,uu as exportTokensToCSS,Ar as findTaskByName,$l as fontSize,Ul as fontWeight,un as formatCost,Hn as ganttEnTranslations,Lc as ganttEsTranslations,wm as ganttTaskToCardUpdate,at as ganttThemes,Kl as ganttTokens,Mi as ganttTranslations,he as ganttUtils,ql as generateCSSVariables,Zl as generateCompleteCSS,Iu as generateInitialPositions,hm as generateTasksContext,hn as generateThemeVariables,Cp as getCalendarTheme,ln as getCalendarTranslations,up as getListViewTheme,nl as getListViewTranslations,gp as getMonthNames,pu as getToken,Ic as getTranslations,fp as getWeekdayNames,jl as kanbanTokens,Si as lightTheme,Xl as lightTokenTheme,zl as lineHeight,ul as listViewDarkTheme,rl as listViewEnTranslations,ol as listViewEsTranslations,gl as listViewLightTheme,fl as listViewNeutralTheme,fs as listViewThemes,ss as listViewTranslations,hs as mergeCalendarTranslations,is as mergeListViewTranslations,Ai as mergeTranslations,Ei as neutralTheme,Jl as neutralTokenTheme,Vl as opacity,xm as parseLocalCommand,el as parseNaturalDate,tl as parseNaturalDuration,al as parseProgress,vm as parseStatus,ox as pluginManager,Ou as retrySyncOperation,Cn as retryWithBackoff,_l as shadows,mu as shouldVirtualizeGrid,Rl as spacing,mo as themes,Xp as useAI,Gp as useBoard,bn as useBoardCore,Cs as useBoardStore,Qp as useCardStacking,Js as useDragState,ru as useFilteredCards,jp as useFilters,Vr as useGanttI18n,ws as useKanbanState,Ec as useKeyboardShortcuts,Jp as useMultiSelect,Fl as useSelectionState,ou as useSortedCards,Ao as useTheme,cu as useVirtualGrid,iu as useVirtualList,km as validateAIResponse,ri as withErrorBoundary,Nn as wouldCreateCircularDependency,Hl as zIndex};//# sourceMappingURL=index.js.map
|
|
420
420
|
//# sourceMappingURL=index.js.map
|