@libxai/board 0.17.253 → 0.17.254

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -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,useCallback,useMemo,useImperativeHandle,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 fc 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,Moon,Sun,Palette,ZoomOut,ZoomIn,Keyboard,ChevronRight,Image,FileText,File,Sparkles,Maximize2,MoreHorizontal,X,User,ChevronDown,Check,CalendarDays,Flag,Clock,Tag,Diamond,ListChecks,Upload,MessageSquare,Send,Rows3,FileImage,FileSpreadsheet,FileJson,FolderKanban,Download,Calendar,ChevronLeft,GripVertical,AlertCircle,CircleDot,Users,Milestone,List,Search}from'lucide-react';import {Command}from'cmdk';import Bu from'react-markdown';import Ru from'remark-gfm';import Ou from'rehype-sanitize';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Line,AreaChart,Area,PieChart,Pie,Cell,BarChart,Bar}from'recharts';var Yo=(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 qo=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 [qo.Translate.toString(e),qo.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function b(...e){return twMerge(clsx(e))}function Xo(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 Yp(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function Qn(e,t){return e.length===0?1e3:t===0?Xo(null,e[0].position):t>=e.length?Xo(e[e.length-1].position,null):Xo(e[t-1].position,e[t].position)}function hl(e,t=100){return e>t}var qp=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 Xp(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 Jo(e,t={}){let{maxAttempts:a=3,initialDelay:r=1e3,backoffMultiplier:o=2,maxDelay:s=1e4,shouldRetry:n=qp,onRetry:c}=t,m,l=0;for(let u=1;u<=a;u++){l=u;try{return {data:await e(),attempts:l,success:!0}}catch(d){if(m=d,u===a||!n(m,u))return {error:m,attempts:l,success:false};let h=Xp(u,r,o,s);if(c)try{c(m,u,h);}catch(C){console.error("Error in retry callback:",C);}await new Promise(C=>setTimeout(C,h));}}return {error:m||new Error("Unknown error"),attempts:l,success:false}}function Jp(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 Zp(e,t={}){return async(...a)=>Jo(()=>e(...a),t)}var es=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 bl=(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))(bl||{}),Ar=class Ar{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...n}=t,c=`[${a}] [${r}] [${s}]`,m=Object.keys(n).length>0;switch(r){case "DEBUG":console.debug(c,o,m?n:"");break;case "INFO":console.info(c,o,m?n:"");break;case "WARN":console.warn(c,o,m?n:"");break;case "ERROR":console.error(c,o,m?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",...Ar.globalOptions};}static configure(t){Ar.globalOptions={...Ar.globalOptions,...t};}child(t){return new Ar({...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 Zo((a,r)=>{this.log(0,`${t} completed`,{...r,action:t,duration:a});},true):new Zo(()=>{},false)}log(t,a,r){if(!this.options.enabled||t<this.options.minLevel)return;let o={timestamp:new Date().toISOString(),level:bl[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};Ar.globalOptions={};var ts=Ar,Zo=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}},yl=new ts;function em(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 tm(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,as(s.title),as(s.description||""),as(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 am(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 fc(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),c=n.toDataURL("image/png"),m=297,l=210,u=n.width/n.height,d=m-20,i=d/u;i>l-20&&(i=l-20,d=i*u);let h=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});h.setFontSize(16),h.setTextColor(255,255,255),h.setFillColor(10,10,10),h.rect(0,0,m,15,"F"),h.text(e.title||"Kanban Board",10,10);let C=(m-d)/2;return h.addImage(c,"PNG",C,20,d,i),h}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(m=>m.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(m=>{if(s>260&&(o.addPage(),s=20),o.setFontSize(12),o.setFont("helvetica","bold"),o.text(m.title,25,s),s+=6,m.description){o.setFontSize(9),o.setFont("helvetica","normal");let u=o.splitTextToSize(m.description,160);o.text(u,25,s),s+=u.length*5;}let l=[];if(m.priority&&l.push(`Priority: ${m.priority}`),m.labels&&m.labels.length>0&&l.push(`Labels: ${m.labels.join(", ")}`),m.assignedUserIds&&m.assignedUserIds.length>0&&l.push(`Assigned: ${m.assignedUserIds.length} user(s)`),m.startDate||m.endDate){let u=[];m.startDate&&u.push(`Start: ${m.startDate}`),m.endDate&&u.push(`End: ${m.endDate}`),l.push(u.join(" \u2192 "));}l.length>0&&(o.setFontSize(8),o.setTextColor(100,100,100),o.text(l.join(" \u2022 "),25,s),o.setTextColor(0,0,0),s+=5),s+=5;}),s+=5;}),o}function as(e){return e.includes(",")||e.includes('"')||e.includes(`
3
- `)?`"${e.replace(/"/g,'""')}"`:e}async function xl(e,t,a,r){switch(t){case "json":return em(e,r);case "csv":return tm(e);case "pdf":return await am(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function kl(e,t,a){let r=`board-export-${new Date().getTime()}`;if(t==="pdf"&&typeof e=="object"&&e!==null&&"save"in e){let u=`${r}.pdf`;e.save(u);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]}),m=URL.createObjectURL(c),l=document.createElement("a");l.href=m,l.download=s,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(m);}function rm(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 om(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=wl(t[0]),r=[],o=new Map,s=[];for(let n=1;n<t.length;n++)try{let c=wl(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 l={};a.forEach((h,C)=>{l[h]=c[C]||"";});let u=l.Column||"Unnamed";o.has(u)||o.set(u,{id:`col-${o.size+1}`,title:u,position:o.size+1,cardIds:[]});let d=o.get(u),i={id:l["Card ID"]||`card-${n}`,title:l.Title||"Untitled",description:l.Description?l.Description:void 0,columnId:d.id,position:d.cardIds.length+1,priority:l.Priority||void 0,labels:l.Labels?l.Labels.split(";").filter(Boolean):void 0,assignedUserIds:l["Assigned Users"]?l["Assigned Users"].split(";").filter(Boolean):void 0,startDate:l["Start Date"]?l["Start Date"]:void 0,endDate:l["End Date"]?l["End Date"]:void 0,createdAt:l["Created At"]?l["Created At"]:void 0,updatedAt:l["Updated At"]?l["Updated At"]:void 0};r.push(i),d.cardIds.push(i.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 wl(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 Cl(e,t){switch(t){case "json":return rm(e);case "csv":return om(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Tl(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 rs=createContext(null);function Nl(){return useContext(rs)}var Dl=createContext(null);function Sl({children:e,themeName:t}){return jsx(Dl.Provider,{value:{themeName:t},children:e})}function Zr(){return useContext(Dl)}function mt({children:e,container:t}){let[a,r]=useState(false),o=Nl(),s=Zr();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:m}=o,l={"--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":m,"data-gantt-portal":"true",style:l,children:e}),n)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),n):createPortal(e,n)}var Fl={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},mm="#BDC3C7",um=({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 Fr({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,n]=useState({top:0,left:0}),c=useRef(null),m=useRef(null),l=()=>{if(!m.current)return;let h=m.current.getBoundingClientRect(),C=window.innerHeight,p=window.innerWidth,y=160,f=220,v=4,g=h.right-y;g<10&&(g=h.left),g+y>p-10&&(g=p-y-10);let k=C-h.bottom,x=h.top,D;k>=f+v?D=h.bottom+v:x>=f+v?D=h.top-f-v:D=k>=x?h.bottom+v:Math.max(10,h.top-f-v),n({top:D,left:g}),o(true);};useEffect(()=>{let h=C=>{c.current&&!c.current.contains(C.target)&&!m.current?.contains(C.target)&&o(false);};if(r)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[r]),useEffect(()=>{let h=C=>{C.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r]);let u=h=>{t(h),o(false);},d=e?Fl[e]:null,i=d?.color||mm;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:m,onClick:()=>r?o(false):l(),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?`${i}10`:"transparent",boxShadow:e?`0 0 0 2px ${i}30 inset`:"none"},title:d?.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:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:i,fillOpacity:e?"0.6":"0.4"})})}),r&&jsx(mt,{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(Fl).map(([h,C])=>jsxs("button",{onClick:()=>u(h),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:C.color,background:"transparent"},onMouseEnter:p=>{p.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:p=>{p.currentTarget.style.background="transparent";},children:[jsx(um,{color:C.color}),jsx("span",{className:"font-semibold text-sm",children:C.label}),e===h&&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)),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:()=>u(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:h=>{h.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:h=>{h.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 gm=[{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 vo({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),m=useRef(null),l=useRef(null),i=(Zr()?.themeName||"dark")==="dark",h=()=>{if(!l.current)return;let g=l.current.getBoundingClientRect(),k=window.innerHeight,x=window.innerWidth,D=320,B=380,w=4,z=g.left;z+D>x-10&&(z=x-D-10),z<10&&(z=10);let P=k-g.bottom,T=g.top,G;P>=B+w?G=g.bottom+w:T>=B+w?G=g.top-B-w:G=P>=T?g.bottom+w:Math.max(10,g.top-B-w),c({top:G,left:z}),s(true);};useEffect(()=>{let g=k=>{m.current&&!m.current.contains(k.target)&&!l.current?.contains(k.target)&&s(false);};if(o)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[o]),useEffect(()=>{let g=k=>{k.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[o]);let C=g=>{let k=new Date,x=z=>{let P=z.getFullYear(),T=String(z.getMonth()+1).padStart(2,"0"),G=String(z.getDate()).padStart(2,"0");return `${P}-${T}-${G}`},D=x(k),B=new Date(k);B.setDate(B.getDate()+g);let w=x(B);a(D,w),s(false);},p=()=>{if(!e||!t)return "Set date";let g=B=>{if(B instanceof Date)return B;if(typeof B!="string"||!B.match(/^\d{4}-\d{2}-\d{2}$/))return null;let w=B.split("-").map(Number);if(w.length!==3||w.some(G=>isNaN(G)))return null;let z=w[0],P=w[1],T=w[2];return z===void 0||P===void 0||T===void 0?null:new Date(z,P-1,T)},k=g(e),x=g(t);if(!k||!x||isNaN(k.getTime())||isNaN(x.getTime()))return "Set date";let D=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${D[k.getMonth()]} ${k.getDate()} \u2013 ${D[x.getMonth()]} ${x.getDate()}`},y=e&&t,v=(()=>{if(!t)return false;let g=typeof t=="string"?new Date(t):t,k=new Date;return k.setHours(0,0,0,0),g<k})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:l,onClick:()=>o?s(false):h(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${v?"asakaa-date-overdue":"asakaa-date"}`,title:y?`${p()}`:"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:p()})]}),o&&jsx(mt,{children:jsxs("div",{ref:m,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,background:i?"#1A1D25":"#FFFFFF",border:`1px solid ${i?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.12)"}`,boxShadow:i?"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:i?"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:i?"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:gm.map(g=>jsx("button",{onClick:()=>C(g.days),className:"px-3 py-2.5 rounded-lg text-xs font-semibold transition-all active:scale-95",style:{color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",border:`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`,backgroundColor:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)"},onMouseEnter:k=>{k.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",k.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:k=>{k.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",k.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:g.label},g.label))})]}),jsxs("div",{className:"p-4",children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:i?"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:g=>a(g.target.value,t),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:i?"dark":"light"}}),jsx("input",{type:"date",value:t||"",onChange:g=>a(e,g.target.value),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:i?"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:g=>{g.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:g=>{g.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function Lr({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,n]=useState(false),[c,m]=useState(""),[l,u]=useState({top:0,left:0}),d=useRef(null),i=useRef(null),h=()=>{if(!i.current)return;let v=i.current.getBoundingClientRect(),g=window.innerHeight,k=window.innerWidth,x=300,D=380,B=4,w=v.right-x;w<10&&(w=v.left),w+x>k-10&&(w=k-x-10);let z=g-v.bottom,P=v.top,T;z>=D+B?T=v.bottom+B:P>=D+B?T=v.top-D-B:T=z>=P?v.bottom+B:Math.max(10,v.top-D-B),u({top:T,left:w}),n(true);};useEffect(()=>{let v=g=>{d.current&&!d.current.contains(g.target)&&!i.current?.contains(g.target)&&(n(false),m(""));};if(s)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s]),useEffect(()=>{let v=g=>{g.key==="Escape"&&(n(false),m(""));};if(s)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[s]);let C=v=>{let g=e.some(k=>k.id===v.id);a(g?e.filter(k=>k.id!==v.id):[...e,v]);},p=t.filter(v=>v.name.toLowerCase().includes(c.toLowerCase())),y=e.slice(0,o),f=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:i,onClick:()=>s?n(false):h(),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:[y.map(v=>jsx("div",{className:"asakaa-avatar",title:v.name,children:v.avatar?jsx("img",{src:v.avatar,alt:v.name,className:"asakaa-avatar-img"}):v.initials},v.id)),f>0&&jsxs("div",{className:"asakaa-avatar",children:["+",f]})]}):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(mt,{children:jsxs("div",{ref:d,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${l.top}px`,left:`${l.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:v=>m(v.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:p.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"}):p.map(v=>{let g=e.some(k=>k.id===v.id);return jsxs("button",{onClick:()=>C(v),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:k=>{k.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:k=>{k.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:v.color,color:"#fff"},children:v.avatar?jsx("img",{src:v.avatar,alt:v.name,className:"w-full h-full rounded-full object-cover"}):v.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:v.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:g?"#3b82f6":"transparent"},children:g?"\u2713":""})]},v.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 Qo(e,t,a){let r=new Map;e.forEach(m=>{if(m.dependencies&&Array.isArray(m.dependencies)){let l=m.dependencies.map(u=>{if(typeof u=="string")return u;let d=u;return d.taskId||d.targetId||""}).filter(Boolean);r.set(m.id,l);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,n=new Set,c=m=>{if(!s.has(m)){s.add(m),n.add(m);let l=r.get(m)||[];for(let u of l){if(!s.has(u)&&c(u))return true;if(n.has(u))return true}}return n.delete(m),false};return c(a)}function ko({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:n}){let[c,m]=useState(false),[l,u]=useState(""),[d,i]=useState(t.length>0),[h,C]=useState({top:0,left:0}),[p,y]=useState(null),f=useRef(null),v=useRef(null),g=()=>{if(!v.current)return;let w=v.current.getBoundingClientRect(),z=window.innerHeight,P=window.innerWidth,T=300,G=d?380:120,R=4,q=w.right-T;q<10&&(q=w.left),q+T>P-10&&(q=P-T-10);let te=z-w.bottom,xe=w.top,Ae;te>=G+R?Ae=w.bottom+R:xe>=G+R?Ae=w.top-G-R:Ae=te>=xe?w.bottom+R:Math.max(10,w.top-G-R),C({top:Ae,left:q}),m(true);};useEffect(()=>{if(!c||!v.current)return;let w=v.current.getBoundingClientRect(),z=window.innerHeight,P=window.innerWidth,T=300,G=d?380:120,R=4,q=w.right-T;q<10&&(q=w.left),q+T>P-10&&(q=P-T-10);let te=z-w.bottom,xe=w.top,Ae;te>=G+R?Ae=w.bottom+R:xe>=G+R?Ae=w.top-G-R:Ae=te>=xe?w.bottom+R:Math.max(10,w.top-G-R),C({top:Ae,left:q});},[d,c]),useEffect(()=>{let w=z=>{f.current&&!f.current.contains(z.target)&&!v.current?.contains(z.target)&&(m(false),u(""));};if(c)return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]),useEffect(()=>{let w=z=>{z.key==="Escape"&&(m(false),u(""));};if(c)return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[c]);let k=w=>{let z=t.includes(w),P=a.find(T=>T.id===w);if(y(null),z){let T=t.filter(G=>G!==w);r(T),T.length===0&&i(false);}else {if(s&&Qo(a,w,e)){let G=`Cannot add "${P?.title||w}" as dependency - would create circular reference`;y(G),n?.(w,P?.title||w),setTimeout(()=>y(null),3e3);return}r([...t,w]),i(true);}},x=()=>{let w=!d;i(w),w||r([]);},D=a.filter(w=>w.id!==e).filter(w=>w.title.toLowerCase().includes(l.toLowerCase())||w.id.toLowerCase().includes(l.toLowerCase())),B=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:v,onClick:()=>c?m(false):g(),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(mt,{children:jsxs("div",{ref:f,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${h.top}px`,left:`${h.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:[p&&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:p})]}),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:x,children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center transition-all",style:{background:d?"#3b82f6":"transparent",borderColor:d?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:d&&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"})]})}),d&&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:l,onChange:w=>u(w.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:D.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"}):D.map(w=>{let z=t.includes(w.id);return jsxs("button",{onClick:()=>k(w.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:P=>{P.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:P=>{P.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:z?"#3b82f6":"transparent",borderColor:z?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:z&&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:w.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:w.id})]})]},w.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),i(false),m(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:m=[]})=>{let{attributes:l,listeners:u,setNodeRef:d,transform:i,transition:h,isDragging:C}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),p={transform:qo.Transform.toString(i),transition:h};if(t)return jsx("div",{ref:d,style:p,...l,...u,onClick:()=>a?.(e),children:t(e)});let y=c.filter(k=>e.assignedUserIds?.includes(k.id)),f=e.progress===100,v=(e.attachments||[]).filter(k=>k.type.startsWith("image/")),g={...p,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:d,style:g,className:b("asakaa-card",C&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...l,...u,onClick:k=>{k.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:k=>{k.currentTarget.style.display="none";}})}),v.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:v.length===1&&v[0]?jsx("img",{src:v[0].url,alt:v[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:k=>{k.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:v.slice(0,4).map((k,x)=>jsxs("div",{className:"relative",children:[jsx("img",{src:k.url,alt:k.name,className:"w-full h-16 object-cover rounded",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:D=>{D.currentTarget.style.display="none";}}),x===3&&v.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:["+",v.length-4]})})]},k.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:f?"line-through":"none",opacity:f?.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:k=>k.stopPropagation(),className:"priority-selector",children:jsx(Fr,{priority:e.priority,onChange:k=>n?.(e.id,{priority:k})})}),jsx("div",{onClick:k=>k.stopPropagation(),className:"date-picker",children:jsx(vo,{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:(k,x)=>n?.(e.id,{startDate:k,endDate:x})})}),c.length>0&&jsx("div",{onClick:k=>k.stopPropagation(),className:"user-selector",children:jsx(Lr,{assignedUsers:y,availableUsers:c,onChange:k=>n?.(e.id,{assignedUserIds:k.map(x=>x.id)})})}),jsx("div",{onClick:k=>k.stopPropagation(),className:"dependencies-selector",children:jsx(ko,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(k=>typeof k=="string"?k:k.taskId):[],availableTasks:m,onChange:k=>n?.(e.id,{dependencies:k})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(k=>jsx("span",{className:"asakaa-label",children:k},k))}),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 en={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"}},Wl=({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 Gl({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),m=useRef(null),l=useRef(null),u=[...Object.entries(en).map(([y,f])=>({id:y,label:f.label,color:f.color,icon:f.icon})),...r.filter(y=>!Object.keys(en).includes(y.id)).map(y=>({id:y.id,label:y.title,color:y.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let y=en[e];if(y)return {...y,id:e};let f=r.find(v=>v.id===e);return f?{id:f.id,label:f.title,color:f.color||"#8B5CF6",icon:"circle-dot"}:{...en.todo,id:"todo"}},i=()=>{if(!l.current)return;let y=l.current.getBoundingClientRect(),f=window.innerHeight,v=window.innerWidth,g=180,k=280,x=4,D=y.right-g;D<10&&(D=y.left),D+g>v-10&&(D=v-g-10);let B=f-y.bottom,w=y.top,z;B>=k+x?z=y.bottom+x:w>=k+x?z=y.top-k-x:z=B>=w?y.bottom+x:Math.max(10,y.top-k-x),c({top:z,left:D}),s(true);};useEffect(()=>{let y=f=>{m.current&&!m.current.contains(f.target)&&!l.current?.contains(f.target)&&s(false);};if(o)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[o]),useEffect(()=>{let y=f=>{f.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[o]);let h=y=>{t(y),s(false);},C=d(),p=C.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:l,onClick:()=>o?s(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:`${p}10`,boxShadow:`0 0 0 2px ${p}30 inset`},title:C.label,children:jsx(Wl,{icon:C.icon,color:p})}),o&&jsx(mt,{children:jsxs("div",{ref:m,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:u.map(y=>jsxs("button",{onClick:()=>h(y.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:y.color,background:"transparent"},onMouseEnter:f=>{f.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:f=>{f.currentTarget.style.background="transparent";},children:[jsx(Wl,{icon:y.icon,color:y.color}),jsx("span",{className:"font-semibold",children:y.label}),e===y.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"})})]},y.id))})]})})]})}function _l({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,n]=useState(false),[c,m]=useState(false),[l,u]=useState(e),[d,i]=useState({top:0,left:0}),h=useRef(null),C=useRef(null),p=useRef(null);useEffect(()=>{if(s&&C.current){let g=C.current.getBoundingClientRect();i({top:g.bottom+window.scrollY+8,left:g.left+window.scrollX});}},[s]),useEffect(()=>{let g=k=>{h.current&&!h.current.contains(k.target)&&!C.current?.contains(k.target)&&(n(false),m(false));};if(s)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[s]),useEffect(()=>{let g=k=>{k.key==="Escape"&&(n(false),m(false),u(e));};if(s)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s,e]),useEffect(()=>{c&&p.current&&(p.current.focus(),p.current.select());},[c]);let y=()=>{m(true),u(e);},f=()=>{let g=l.trim();g&&g!==e&&t(g),m(false),n(false),u(e);},v=g=>{g.key==="Enter"?f():g.key==="Escape"&&(m(false),u(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:C,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(mt,{children:jsx("div",{ref:h,className:"fixed rounded-xl shadow-2xl border min-w-[200px]",style:{top:`${d.top}px`,left:`${d.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:p,type:"text",value:l,onChange:g=>u(g.target.value),onKeyDown:v,onBlur:f,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:y,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 to=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:n,onCardUpdate:c,availableUsers:m,allCards:l,enableVirtualization:u,cardHeight:d=120,isCollapsed:i,onToggleCollapse:h,onColumnRename:C,onColumnDelete:p,isDeletable:y=false,className:f})=>{let{setNodeRef:v,isOver:g}=useDroppable({id:e.id,data:{type:"column",column:e}}),k=useRef(null),x=u??hl(t.length),D=useVirtualizer({count:t.length,getScrollElement:()=>k.current,estimateSize:()=>d,enabled:x});if(a)return jsx("div",{ref:v,className:f,children:a(e,t)});let w=(()=>{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}})(),z=w.state==="exceeded",P=()=>"asakaa-column-count";return jsxs("div",{ref:v,className:b("asakaa-column",g&&"ring-2 ring-asakaa-accent-blue",z&&"ring-2 ring-asakaa-accent-red",f),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:b(P()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&w.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${w.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[w.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"})]}),w.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"})]}),w.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"})}),w.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"})]})]}),(C||p)&&jsx(_l,{columnTitle:e.title,onRename:T=>C?.(e.id,T),onDelete:p?()=>p(e.id):void 0,isDeletable:y}),h&&jsx("button",{onClick:h,className:"text-asakaa-text-tertiary hover:text-asakaa-text-primary","aria-label":i?"Expand column":"Collapse column",children:i?"\u25B6":"\u25BC"})]})]}),!i&&jsx("div",{ref:k,className:"asakaa-column-cards",style:{maxHeight:x?"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"})}):x?jsx("div",{style:{height:`${D.getTotalSize()}px`,position:"relative"},children:D.getVirtualItems().map(T=>{let G=t[T.index];return G?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${T.start}px)`},children:jsx(sr,{card:G,render:r,onClick:n,onUpdate:c,availableUsers:m,allCards:l})},G.id):null})}):t.map(T=>jsx(sr,{card:T,render:r,onClick:n,onUpdate:c,availableUsers:m,allCards:l},T.id))})})]})});to.displayName="Column";function ls({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 m=()=>{let u=s.trim();u&&u!==e?t(u):n(e),o(false);},l=u=>{u.key==="Enter"?m():u.key==="Escape"&&(n(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:u=>n(u.target.value),onBlur:m,onKeyDown:l,className:b("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:b("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}var on=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function Qa({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:n=true}){let[c,m]=useState(false),[l,u]=useState(""),[d,i]=useState(false),[h,C]=useState(on[10]||"#3B82F6"),[p,y]=useState({top:0,left:0}),f=useRef(null),v=useRef(null),g=useRef(null),k=useRef(null),x=t.filter(T=>T.name.toLowerCase().includes(l.toLowerCase())),D=t.some(T=>T.name.toLowerCase()===l.toLowerCase());useEffect(()=>{if(c&&v.current){let T=v.current.getBoundingClientRect();y({top:T.bottom+6,left:T.left});}},[c]),useEffect(()=>{let T=G=>{let R=G.target,q=f.current?.contains(R),te=g.current?.contains(R);!q&&!te&&(m(false),u(""),i(false));};if(c)return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[c]),useEffect(()=>{c&&k.current&&k.current.focus();},[c]);let B=T=>{let G=e.some(R=>R.id===T.id);a(G?e.filter(R=>R.id!==T.id):[...e,T]);},w=async()=>{if(!(!r||!l.trim())){i(true);try{let T=await r(l.trim(),h);T&&(a([...e,T]),u(""),C(on[Math.floor(Math.random()*on.length)]||"#3B82F6"));}finally{i(false);}}},z=(T,G)=>{G.stopPropagation(),a(e.filter(R=>R.id!==T));},P={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:f,className:"relative",children:[jsxs("button",{ref:v,type:"button",onClick:()=>!s&&m(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:P,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:g,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:p.top,left:p.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:k,type:"text",value:l,onChange:T=>u(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"&&l.trim()&&!D&&r&&w();}})}),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:G=>z(T.id,G),children:[T.name,jsx(X,{className:"w-3 h-3"})]},T.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:x.length>0?x.map(T=>{let G=e.some(R=>R.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:G?`${T.color}15`:"transparent",color:o.textPrimary},onMouseEnter:R=>{G||(R.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:R=>{G||(R.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}),G&&jsx(Check,{className:"w-4 h-4",style:{color:T.color}})]},T.id)}):l.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"})}),l.trim()&&!D&&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:on.map(T=>jsx("button",{type:"button",onClick:()=>C(T),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:T,outline:h===T?`2px solid ${T}`:"none",outlineOffset:"2px"}},T))}),jsxs("button",{type:"button",onClick:w,disabled:d,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{backgroundColor:h,color:"#FFFFFF",opacity:d?.7:1},children:[d?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 "',l.trim(),'"']})]})]})}),document.body)]})}function cs({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 Yl({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(cs,{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 er=[{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 Ql(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 eu(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 Or({task:e,isOpen:t,onClose:a,onTaskUpdate:r,onCardUpdate:o,theme:s="dark",locale:n="es",availableUsers:c=[],availableTags:m=[],onCreateTag:l,attachments:u=[],onUploadAttachments:d,onDeleteAttachment:i,availableTasks:h=[],comments:C=[],onAddComment:p,currentUser:y}){let f=s==="dark",v={textTertiary:f?"#6B7280":"#9CA3AF",textSecondary:f?"#9CA3AF":"#6B7280",textPrimary:f?"#FFFFFF":"#111827",borderLight:f?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:f?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:f?"#1A1D25":"#FFFFFF",bgSecondary:f?"#0F1117":"#F9FAFB",hoverBg:f?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},g=e&&"title"in e&&!("name"in e),k=e,[x,D]=useState(e?Ql(e,c):null),[B,w]=useState(false),[z,P]=useState(false),[T,G]=useState(false),[R,q]=useState(null),[te,xe]=useState(new Date),[Ae,ze]=useState(false),[le,O]=useState(false),[L,H]=useState(""),[F,X$1]=useState(false),[Q,U]=useState(false),[ke,Te]=useState(false),[Fe,ve]=useState(""),et=useRef(null),[Ie,pt]=useState(""),it=useRef(null),[lt,tt]=useState(""),[$,ne]=useState(false);useEffect(()=>{if(e){let S=Ql(e,c);D(S),ve(S.description||""),pt(S.name||"");}},[e?.id,c]),useEffect(()=>()=>{et.current&&clearTimeout(et.current),it.current&&clearTimeout(it.current);},[]);let re=useCallback(S=>{D(S),g&&o&&k?o(eu(S,k)):r&&r(S);},[g,k,o,r]),we=useCallback(()=>{w(false),P(false),G(false),q(null),O(false),H(""),X$1(false);},[]),Ne=useCallback((S,J)=>{if(!x)return;let ce={...x,[S]:J};re(ce);},[x,re]),at=useCallback(S=>{ve(S),et.current&&clearTimeout(et.current),et.current=setTimeout(()=>{if(x){let J={...x,description:S};re(J);}},800);},[x,re]),wt=useCallback(S=>{pt(S),it.current&&clearTimeout(it.current),it.current=setTimeout(()=>{if(x&&S.trim()){let J={...x,name:S.trim()};re(J);}},800);},[x,re]),Le=useCallback(async()=>{if(!(!x||!lt.trim()||!p)){ne(true);try{await p(x.id,lt.trim()),tt("");}finally{ne(false);}}},[x,lt,p]),he=useCallback(S=>{let J=typeof S=="string"?new Date(S):S,De=new Date().getTime()-J.getTime(),Ue=Math.floor(De/6e4),Re=Math.floor(De/36e5),Be=Math.floor(De/864e5);return Ue<1?n==="es"?"Ahora":"Just now":Ue<60?n==="es"?`Hace ${Ue} min`:`${Ue}m ago`:Re<24?n==="es"?`Hace ${Re}h`:`${Re}h ago`:Be<7?n==="es"?`Hace ${Be}d`:`${Be}d ago`:J.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})},[n]),Ee=useCallback(S=>{if(!x)return;let J=x.progress||0;S==="completed"?J=100:S==="in-progress"&&J===0?J=10:S==="todo"&&(J=0);let ce={...x,status:S,progress:J};re(ce),w(false);},[x,re]),St=useCallback((S,J)=>{if(!x)return;let ce={...x,startDate:S,endDate:J};re(ce);},[x,re]),gt=useCallback(()=>{let S=te.getFullYear(),J=te.getMonth(),ce=new Date(S,J,1),Ue=new Date(S,J+1,0).getDate(),Re=ce.getDay(),Be=[],Je=new Date(S,J,0).getDate();for(let K=Re-1;K>=0;K--)Be.push({date:new Date(S,J-1,Je-K),isCurrentMonth:false});for(let K=1;K<=Ue;K++)Be.push({date:new Date(S,J,K),isCurrentMonth:true});let dt=42-Be.length;for(let K=1;K<=dt;K++)Be.push({date:new Date(S,J+1,K),isCurrentMonth:false});return Be},[te]),ta=useCallback(async S=>{if(S.preventDefault(),S.stopPropagation(),U(false),!x||!d)return;let J=Array.from(S.dataTransfer.files);if(J.length!==0){Te(true);try{await d(x.id,J);}finally{Te(false);}}},[x,d]),sa=useCallback(async S=>{if(!x||!d||!S.target.files)return;let J=Array.from(S.target.files);if(J.length!==0){Te(true);try{await d(x.id,J);}finally{Te(false);}S.target.value="";}},[x,d]),_e=useCallback(S=>{S.preventDefault(),S.stopPropagation(),U(true);},[]),He=useCallback(S=>{S.preventDefault(),S.stopPropagation(),U(false);},[]),ia=useCallback(S=>S<1024?`${S} B`:S<1024*1024?`${(S/1024).toFixed(1)} KB`:`${(S/(1024*1024)).toFixed(1)} MB`,[]),fe=useCallback(S=>S.startsWith("image/")?Image:S.includes("pdf")||S.includes("document")?FileText:File,[]);return !t||!x?null:jsx(AnimatePresence,{children:t&&x&&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:b("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",f?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:b("px-6 py-3 border-b flex items-center gap-3",f?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:b("w-4 h-4",f?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:b("text-xs px-2 py-0.5 rounded",f?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:b("text-xs font-mono",f?"text-[#6B7280]":"text-gray-400"),children:x.id.slice(0,8)}),jsxs("button",{className:b("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",f?"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:b("p-1.5 rounded transition-colors",f?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:b("p-1.5 rounded transition-colors",f?"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:b("p-1.5 rounded transition-colors",f?"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=x.progress===100?0:100,ce={...x,progress:S,status:S===100?"completed":"todo"};re(ce);},className:b("mt-2 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors flex-shrink-0",x.progress===100?"bg-green-500 border-green-500":f?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:x.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("input",{type:"text",value:Ie,onChange:S=>wt(S.target.value),placeholder:n==="es"?"Nombre de la tarea...":"Task name...",className:b("text-xl font-semibold flex-1 bg-transparent outline-none border-none px-0 py-0","focus:ring-0 focus:outline-none",x.progress===100?"line-through text-[#6B7280]":f?"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:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{we(),w(!B);},className:b("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",x.progress===100||x.status==="completed"?"bg-green-500/20 text-green-400":x.progress&&x.progress>0||x.status==="in-progress"?"bg-blue-500/20 text-blue-400":f?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:x.progress===100||x.status==="completed"?n==="es"?"COMPLETADO":"DONE":x.progress&&x.progress>0||x.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:B&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>w(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",f?"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:()=>Ee(S.id),className:b("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",f?"hover:bg-white/5":"hover:bg-gray-50",x.status===S.id&&(f?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",S.color)}),jsx("span",{className:f?"text-white":"text-gray-900",children:S.label})]},S.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{we(),G(!T);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",f?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[x.assignees&&x.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[x.assignees.slice(0,3).map((S,J)=>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()},J)),x.assignees.length>3&&jsxs("span",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:["+",x.assignees.length-3]})]}):jsx("span",{className:b("text-sm",f?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:b("w-3 h-3",f?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:T&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>G(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",f?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:c.length>0?c.map(S=>{let J=x.assignees?.some(ce=>ce.name===S.name);return jsxs("button",{onClick:()=>{let ce=x.assignees||[],De;J?De=ce.filter(Ue=>Ue.name!==S.name):De=[...ce,S],Ne("assignees",De);},className:b("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",f?"hover:bg-white/5":"hover:bg-gray-50",J&&(f?"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:b("flex-1",f?"text-white":"text-gray-900"),children:S.name}),J&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},S.name)}):jsx("div",{className:b("px-3 py-4 text-sm text-center",f?"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:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{q(R?null:"start"),xe(x.startDate||new Date);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",f?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[x.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:b("mx-1",f?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),x.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End")]}),jsx(AnimatePresence,{children:R&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>q(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:b("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",f?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:S=>S.stopPropagation(),children:[jsxs("div",{className:b("w-44 py-2 border-r",f?"border-white/10":"border-gray-200"),children:[(()=>{let S=new Date,J=new Date(S);J.setDate(S.getDate()+1);let ce=new Date(S);ce.setDate(S.getDate()+((6-S.getDay()+7)%7||7));let De=new Date(S);De.setDate(S.getDate()+((1-S.getDay()+7)%7||7));let Ue=new Date(S);Ue.setDate(S.getDate()+(6-S.getDay()+7)%7+7);let Re=new Date(S);Re.setDate(S.getDate()+14);let Be=new Date(S);return Be.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:J,display:J.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:ce,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:De,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:Ue,display:Ue.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:Re,display:Re.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Be,display:Be.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((dt,K)=>jsxs("button",{className:b("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",f?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(R==="start"){let ae=x.endDate&&dt.date>x.endDate?dt.date:x.endDate;St(dt.date,ae),q("end");}else {let ae=x.startDate&&dt.date<x.startDate?dt.date:x.startDate;St(ae,dt.date),q(null);}},children:[jsx("span",{children:dt.label}),jsx("span",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:dt.display})]},K))})(),jsx("div",{className:b("border-t mt-2 pt-2",f?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{St(void 0,void 0),q(null);},className:b("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",f?"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:b("text-xs mb-3 px-2 py-1 rounded",f?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:R==="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:b("font-medium",f?"text-white":"text-gray-900"),children:te.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>xe(new Date),className:b("p-1 rounded text-sm transition-colors",f?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>xe(new Date(te.getFullYear(),te.getMonth()-1)),className:b("p-1 rounded",f?"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:()=>xe(new Date(te.getFullYear(),te.getMonth()+1)),className:b("p-1 rounded",f?"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:b("w-8 h-8 flex items-center justify-center text-xs",f?"text-[#6B7280]":"text-gray-400"),children:S},S))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:gt().map((S,J)=>{let ce=S.date.toDateString()===new Date().toDateString(),De=x.startDate?.toDateString()===S.date.toDateString(),Ue=x.endDate?.toDateString()===S.date.toDateString(),Re=De||Ue,Be=x.startDate&&x.endDate&&S.date>=x.startDate&&S.date<=x.endDate;return jsx("button",{onClick:()=>{let Je=new Date(S.date);if(R==="start"){let dt=x.endDate&&Je>x.endDate?Je:x.endDate;St(Je,dt),q("end");}else {let dt=x.startDate&&Je<x.startDate?Je:x.startDate;St(dt,Je),q(null);}},className:b("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!S.isCurrentMonth&&(f?"text-[#4B5563]":"text-gray-300"),S.isCurrentMonth&&(f?"text-white":"text-gray-900"),ce&&"ring-2 ring-[#3B82F6]",De&&"bg-[#3B82F6] text-white",Ue&&!De&&"bg-[#7C3AED] text-white",Be&&!Re&&(f?"bg-[#7C3AED]/20":"bg-purple-100"),!Re&&(f?"hover:bg-white/10":"hover:bg-gray-100")),children:S.date.getDate()},J)})})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{we(),P(!z);},className:b("text-xs px-2 py-1 rounded font-medium transition-all hover:ring-2 hover:ring-white/20",x.priority==="high"||x.priority==="urgent"?"bg-red-500/20 text-red-400":x.priority==="medium"?"bg-yellow-500/20 text-yellow-400":x.priority==="low"?"bg-green-500/20 text-green-400":f?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:x.priority?x.priority==="high"||x.priority==="urgent"?n==="es"?"Alta":"High":x.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:z&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>P(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",f?"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:()=>{Ne("priority",S.id),P(false);},className:b("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",f?"hover:bg-white/5":"hover:bg-gray-50",x.priority===S.id&&(f?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",S.color)}),jsx("span",{className:f?"text-white":"text-gray-900",children:S.label})]},S.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:b("text-sm",f?"text-white":"text-gray-900"),children:x.startDate&&x.endDate?`${Math.ceil((x.endDate.getTime()-x.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:b("w-4 h-4 rounded-full border-2",f?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Ae?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:x.progress||0,onChange:S=>{let J=parseInt(S.target.value),ce=x.status;J===100?ce="completed":J>0?ce="in-progress":ce="todo";let De={...x,progress:J,status:ce};re(De);},onBlur:()=>ze(false),className:b("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",f?"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:()=>ze(true),className:b("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",f?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:b("h-full rounded-full transition-all",x.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${x.progress||0}%`}})}),jsxs("span",{className:b("text-sm font-medium min-w-[40px]",f?"text-white":"text-gray-900"),children:[x.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx(Qa,{selectedTags:x.tags||[],availableTags:m,onChange:S=>{Ne("tags",S);},onCreateTag:l,theme:v})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:b("w-4 h-4 mt-1.5",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24 mt-1",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[x.dependencies&&x.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:x.dependencies.map(S=>{let J=h.find(ce=>ce.id===S);return jsxs("span",{className:b("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",f?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[J?.name||S.slice(0,8),jsx("button",{onClick:()=>{let ce=(x.dependencies||[]).filter(De=>De!==S);Ne("dependencies",ce);},className:b("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:()=>{we(),O(!le);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",f?"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:b("text-sm",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:le&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{O(false),H("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",f?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:b("p-2 border-b",f?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:L,onChange:S=>H(S.target.value),placeholder:n==="es"?"Buscar tarea...":"Search task...",className:b("w-full px-3 py-2 rounded-md text-sm outline-none",f?"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:h.length>0?h.filter(S=>S.id!==x.id).filter(S=>L===""||S.name.toLowerCase().includes(L.toLowerCase())).map(S=>{let J=x.dependencies?.includes(S.id);return jsxs("button",{onClick:()=>{let ce=x.dependencies||[],De;J?De=ce.filter(Ue=>Ue!==S.id):De=[...ce,S.id],Ne("dependencies",De);},className:b("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",f?"hover:bg-white/5":"hover:bg-gray-50",J&&(f?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:b("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",J?"bg-blue-500 border-blue-500":f?"border-white/30":"border-gray-300"),children:J&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:b("block truncate",f?"text-white":"text-gray-900"),children:S.name}),jsx("span",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:S.id.slice(0,8)})]})]},S.id)}):jsx("div",{className:b("px-3 py-4 text-sm text-center",f?"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:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{we(),X$1(!F);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",f?"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:x.color||"#6366F1"}}),jsx("span",{className:b("text-sm",f?"text-white":"text-gray-900"),children:er.find(S=>S.value===x.color)?.name||(n==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:b("w-3 h-3",f?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:F&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>X$1(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",f?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:er.map(S=>{let J=x.color===S.value;return jsx("button",{onClick:()=>{Ne("color",S.value),X$1(false);},className:b("w-7 h-7 rounded-full flex items-center justify-center transition-all",J&&"ring-2 ring-offset-2",f?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:S.value,outlineColor:J?S.value:void 0},title:S.name,children:J&&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:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"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:x.isMilestone||false,onChange:S=>Ne("isMilestone",S.target.checked),className:b("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",x.isMilestone?"bg-purple-500 border-purple-500":f?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:b("text-sm",f?"text-white":"text-gray-900"),children:n==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:b("text-sm font-semibold",f?"text-white":"text-gray-900"),children:n==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:Fe,onChange:S=>at(S.target.value),placeholder:n==="es"?"Agregar descripci\xF3n...":"Add description...",className:b("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",f?"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:b("flex items-center gap-2 text-sm mt-2 transition-colors",f?"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:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:b("text-sm font-semibold mb-3",f?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",f?"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:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:b("text-sm font-semibold mb-3",f?"text-white":"text-gray-900"),children:n==="es"?"Subtareas":"Subtasks"}),x.subtasks&&x.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:x.subtasks.map(S=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:b("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",S.progress===100?"bg-green-500 border-green-500":f?"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:b("text-sm",S.progress===100?"line-through text-[#6B7280]":f?"text-white":"text-gray-900"),children:S.name})]},S.id))}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",f?"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:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:b("text-sm font-semibold",f?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:b("p-1 rounded transition-colors",f?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",f?"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:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:b("text-sm font-semibold mb-3",f?"text-white":"text-gray-900"),children:[n==="es"?"Adjuntos":"Attachments",u.length>0&&jsxs("span",{className:b("ml-2 text-xs font-normal",f?"text-[#6B7280]":"text-gray-400"),children:["(",u.length,")"]})]}),u.length>0&&jsx("div",{className:"space-y-2 mb-4",children:u.map(S=>{let J=fe(S.type),ce=S.type.startsWith("image/");return jsxs("div",{className:b("flex items-center gap-3 p-2 rounded-lg group transition-colors",f?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[ce&&S.thumbnailUrl?jsx("img",{src:S.thumbnailUrl,alt:S.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:b("w-10 h-10 rounded flex items-center justify-center",f?"bg-white/10":"bg-gray-200"),children:jsx(J,{className:b("w-5 h-5",f?"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:b("text-sm font-medium truncate block hover:underline",f?"text-white":"text-gray-900"),children:S.name}),jsx("p",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:ia(S.size)})]}),i&&jsx("button",{onClick:()=>i(S.id),className:b("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",f?"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:_e,onDragLeave:He,onDrop:ta,className:b("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",Q?f?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":f?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",ke&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:sa,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!d||ke}),ke?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:b("text-sm",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:b("w-6 h-6 mx-auto mb-2",Q?"text-blue-500":f?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:b("text-sm",f?"text-[#9CA3AF]":"text-gray-500"),children:Q?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"})]})}),!d&&jsx("p",{className:b("text-xs mt-1",f?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:b("w-80 border-l flex flex-col",f?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:b("px-4 py-3 border-b",f?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:b("text-sm font-semibold",f?"text-white":"text-gray-900"),children:[n==="es"?"Actividad":"Activity",C.length>0&&jsxs("span",{className:b("ml-2 text-xs font-normal",f?"text-[#6B7280]":"text-gray-400"),children:["(",C.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:C.length>0?jsx("div",{className:"space-y-4",children:C.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:b("text-sm font-medium",f?"text-white":"text-gray-900"),children:S.user?.name||(n==="es"?"Usuario":"User")}),jsx("span",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:he(S.createdAt)})]}),jsx("p",{className:b("text-sm break-words",f?"text-[#9CA3AF]":"text-gray-600"),children:S.content})]})]},S.id))}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:b("w-10 h-10 mb-3",f?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:b("text-sm",f?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:b("p-4 border-t",f?"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:b("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",f?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:lt,onChange:S=>tt(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&(S.preventDefault(),Le());},placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",disabled:$||!p,className:b("flex-1 bg-transparent text-sm outline-none",f?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",($||!p)&&"opacity-50")}),jsx("button",{onClick:Le,disabled:$||!lt.trim()||!p,className:b("p-1.5 rounded transition-colors",lt.trim()&&p?"bg-blue-500 text-white hover:bg-blue-600":f?"text-[#6B7280]":"text-gray-400",$&&"opacity-50 cursor-not-allowed"),children:$?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"})})]})]})})]})]})]})})}function fs(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function vr({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:n,style:c,isLoading:m,error:l,children:u,availableTags:d=[],onCreateTag:i,attachmentsByCard:h,onUploadAttachments:C,onDeleteAttachment:p}){let[y,f]=fs(),[v,g]=useState(null),k=o?.theme||"dark",x=k==="dark"||k==="neutral",D=x?"dark":"",B=useCallback((le,O)=>{t.onCardUpdate?.(le,O);},[t]),w=useCallback((le,O)=>{t.onColumnUpdate?.(le,{title:O});},[t]),z=useCallback(le=>{t.onColumnDelete?.(le);},[t]),P=["todo","in-progress","completed"],T=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),G=useMemo(()=>{let le=new Map;return e.columns.forEach(O=>{let L=O.cardIds.map(H=>e.cards.find(F=>F.id===H)).filter(H=>H!==void 0).sort((H,F)=>H.position-F.position);le.set(O.id,L);}),le},[e.cards,e.columns]),R=useMemo(()=>e.cards.map(le=>({id:le.id,name:le.title,startDate:le.startDate?new Date(le.startDate):void 0,endDate:le.endDate?new Date(le.endDate):void 0,progress:le.progress||0,status:le.columnId,priority:le.priority?.toLowerCase(),dependencies:Array.isArray(le.dependencies)?le.dependencies.map(O=>typeof O=="string"?O:O.taskId):[]})),[e.cards]),q=useCallback(le=>{let{active:O}=le,L=e.cards.find(H=>H.id===O.id);L&&f({isDragging:true,draggedCardId:L.id,sourceColumnId:L.columnId,targetColumnId:L.columnId});},[e.cards,f]),te=useCallback(le=>{let{active:O,over:L}=le;if(!L||!e.cards.find(X=>X.id===O.id))return;let F=null;L.data.current?.type==="column"?F=L.id:L.data.current?.type==="card"&&(F=e.cards.find(Q=>Q.id===L.id)?.columnId||null),F&&F!==y.targetColumnId&&f({...y,targetColumnId:F});},[e.cards,y,f]),xe=useCallback(async le=>{let{active:O,over:L}=le;if(f({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!L)return;let H=e.cards.find(U=>U.id===O.id);if(!H)return;let F,X;if(L.data.current?.type==="column"){F=L.id;let U=G.get(F)||[];X=Qn(U,0);}else {let U=e.cards.find(Fe=>Fe.id===L.id);if(!U)return;F=U.columnId;let ke=G.get(F)||[],Te=ke.findIndex(Fe=>Fe.id===L.id);X=Qn(ke,Te);}let Q=e.columns.find(U=>U.id===F);if(Q&&Q.wipLimit&&Q.wipLimitType==="hard"){let U=G.get(F)||[];if(H.columnId!==F&&U.length>=Q.wipLimit){t.onWipLimitExceeded?.(Q,H);return}}(H.columnId!==F||H.position!==X)&&await t.onCardMove?.(H.id,F,X);},[e.cards,e.columns,G,t,f]),Ae=useCallback(le=>{g(le),a?.(le);},[a]),ze=useCallback(le=>{t.onCardUpdate?.(le.id,le),g(le);},[t]);return m?jsx("div",{className:b("asakaa-board",D,n),style:c,children:jsx(mu,{columnCount:3})}):l?jsx("div",{className:b("asakaa-board",D,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 l=="string"?l:l.message})]})})}):jsxs(Sl,{themeName:k,children:[jsxs(DndContext,{sensors:T,collisionDetection:closestCorners,onDragStart:q,onDragOver:te,onDragEnd:xe,children:[jsxs("div",{className:b("asakaa-board",D,n),style:c,"data-theme":k,children:[e.columns.sort((le,O)=>le.position-O.position).map(le=>{let O=G.get(le.id)||[],L=!P.includes(le.id);return jsx(to,{column:le,cards:O,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:Ae,onCardUpdate:B,onColumnRename:w,onColumnDelete:z,isDeletable:L,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},le.id)}),u]}),jsx(DragOverlay,{children:y.draggedCardId?jsx(sr,{card:e.cards.find(le=>le.id===y.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]}),jsx(Or,{task:v,isOpen:!!v,onClose:()=>g(null),onCardUpdate:ze,theme:x?"dark":"light",locale:o?.locale==="es"?"es":"en",availableUsers:s,availableTags:d,onCreateTag:i,attachments:v?h?.get(v.id)||[]:[],onUploadAttachments:C,onDeleteAttachment:p,availableTasks:R})]})}function mu({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 bu={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)"},yu={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)"},vu={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},xu={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function ku({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let l=u=>{c.current&&!c.current.contains(u.target)&&n(false);};return s&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[s]);let m=l=>{t(l),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((l,u)=>l.position-u.position).map((l,u)=>jsxs(motion.button,{onClick:()=>m(l.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:u<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:l.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:l.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[l.cardIds.length," ",l.cardIds.length===1?"tarea":"tareas"]})]})]},l.id))]})})})]})}function wu({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,n]=useState(false),[c,m]=useState(null),l=useRef(null);if(useEffect(()=>{let h=C=>{l.current&&!l.current.contains(C.target)&&n(false);};return s&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]),!(a||r||o))return null;let d=[{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(h=>h.handler),i=async(h,C)=>{if(C){m(h);try{await C();}catch(p){console.error(`Export ${h} failed:`,p);}finally{m(null),n(false);}}};return jsxs("div",{ref:l,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:d.map((h,C)=>jsxs(motion.button,{onClick:()=>i(h.id,h.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:C<d.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:C*.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===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 Cu({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 bs({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:n,onExportJSON:c,onExportExcel:m,translations:l}){let u=r==="dark"?bu:yu,d={...o==="es"?vu:xu,...l},i=n||c||m;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:u.bgGrid,borderColor:u.border},children:jsxs("div",{className:"flex items-center gap-3",children:[i&&jsxs(Fragment,{children:[jsx(wu,{theme:u,t:d,onExportCSV:n,onExportJSON:c,onExportExcel:m}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:u.borderLight}})]}),t&&(s?jsx(ku,{columns:e,onSelect:t,theme:u,t:d,createTaskLabel:a}):jsx(Cu,{onClick:()=>t(),label:a||d.newTask}))]})})}function vs({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,n]=useState(false),[c,m]=useState(""),l=useCallback(()=>{let i=c.trim();i&&(e(i),m(""),n(false));},[c,e]),u=useCallback(i=>{i.key==="Enter"?(i.preventDefault(),l()):i.key==="Escape"&&(m(""),n(false));},[l]),d=useCallback(()=>{setTimeout(()=>{c.trim()||n(false);},150);},[c]);return s?jsx("div",{className:b("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:i=>m(i.target.value),onKeyDown:u,onBlur:d,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:l,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:()=>{m(""),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:b("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 xs({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:n=false,theme:c="dark",locale:m="es"}){let[l,u]=useState(false),[d,i]=useState(false),[h,C]=useState(""),[p,y]=useState([]),[f,v]=useState(""),[g,k]=useState(""),[x,D]=useState(""),[B,w]=useState(false),[z,P]=useState(false),[T,G]=useState(false),R=useRef(null),q=useRef(null),te={placeholder:o||(m==="es"?"Nombre de la tarea...":"Task Name..."),buttonLabel:s||(m==="es"?"Agregar Tarea":"Add Task"),save:m==="es"?"Guardar":"Save",addAssignee:m==="es"?"Agregar asignado":"Add assignee",addDates:m==="es"?"Agregar fechas":"Add dates",addPriority:m==="es"?"Agregar prioridad":"Add priority",startDate:m==="es"?"Inicio":"Start",endDate:m==="es"?"Fin":"End",low:m==="es"?"Baja":"Low",medium:m==="es"?"Media":"Medium",high:m==="es"?"Alta":"High",urgent:m==="es"?"Urgente":"Urgent"},xe=useCallback(()=>{C(""),y([]),v(""),k(""),D(""),w(false),P(false),G(false),u(false);},[]);useEffect(()=>{l&&R.current&&R.current.focus();},[l]),useEffect(()=>{if(!l)return;let L=H=>{q.current&&!q.current.contains(H.target)&&(h.trim()||xe());};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[l,h,xe]);let Ae=useCallback(async()=>{let L=h.trim();if(!(!L||d)){i(true);try{await t({name:L,columnId:e,assigneeIds:p.length>0?p:void 0,startDate:f?new Date(f):void 0,endDate:g?new Date(g):void 0,priority:x||void 0}),C(""),y([]),v(""),k(""),D(""),w(!1),P(!1),G(!1),R.current?.focus();}catch(H){console.error("Error creating card:",H);}finally{i(false);}}},[h,e,p,f,g,x,t,d]),ze=useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),Ae()):L.key==="Escape"&&xe();},[Ae,xe]),le=useCallback(L=>{y(H=>H.includes(L)?H.filter(F=>F!==L):[...H,L]);},[]),O=c==="dark";return l?jsxs("div",{ref:q,className:b("rounded-lg overflow-hidden shadow-lg",O?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:R,type:"text",value:h,onChange:L=>C(L.target.value),onKeyDown:ze,placeholder:te.placeholder,disabled:d,className:b("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",O?"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:()=>w(!B),className:b("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",B||p.length>0?"bg-emerald-500/20 text-emerald-400":O?"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"})]}),p.length>0&&jsx("span",{className:"ml-0.5",children:p.length})]}),jsx("button",{onClick:()=>P(!z),className:b("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",z||f||g?"bg-blue-500/20 text-blue-400":O?"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:()=>G(!T),className:b("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",T||x?x==="urgent"?"bg-red-500/20 text-red-400":x==="high"?"bg-orange-500/20 text-orange-400":x==="medium"?"bg-yellow-500/20 text-yellow-400":x==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":O?"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:Ae,disabled:!h.trim()||d,className:b("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:d?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:b("px-3 pb-3 pt-0","border-t",O?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(L=>jsxs("button",{onClick:()=>le(L.id),className:b("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",p.includes(L.id)?"bg-emerald-500 text-white":O?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[L.avatar?jsx("img",{src:L.avatar,alt:L.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:b("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",p.includes(L.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:L.name.charAt(0).toUpperCase()}),jsx("span",{children:L.name.split(" ")[0]})]},L.id))})}),z&&jsx("div",{className:b("px-3 pb-3 pt-0","border-t",O?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:b("block text-[10px] uppercase tracking-wide mb-1",O?"text-gray-500":"text-gray-400"),children:te.startDate}),jsx("input",{type:"date",value:f,onChange:L=>v(L.target.value),className:b("w-full px-2 py-1.5 rounded text-xs border",O?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:b("block text-[10px] uppercase tracking-wide mb-1",O?"text-gray-500":"text-gray-400"),children:te.endDate}),jsx("input",{type:"date",value:g,onChange:L=>k(L.target.value),className:b("w-full px-2 py-1.5 rounded text-xs border",O?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),T&&jsx("div",{className:b("px-3 pb-3 pt-0","border-t",O?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(L=>jsx("button",{onClick:()=>D(x===L?"":L),className:b("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",x===L?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[L]} text-white`:O?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:te[L]},L))})})]}):jsxs("button",{onClick:()=>u(true),disabled:n,className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",O?"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 No=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(vr,{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 pd(e={}){return new No(e)}var ro=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 ks(e,t){let a=r=>jsx(ro,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Cs({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:n,onPredictRisks:c,onOpenAIUsage:m,shortcut:l="k",className:u=""}){let[d,i]=useState(false),[h,C]=useState(""),[p,y]=useState("home"),[f,v]=useState(""),[g,k]=useState("");useEffect(()=>{let w=z=>{(z.metaKey||z.ctrlKey)&&z.key===l&&(z.preventDefault(),i(P=>!P)),z.key==="Escape"&&(i(false),y("home"),C(""));};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[l]),useEffect(()=>{d||(y("home"),C(""),v(""),k(""));},[d]);let x=useCallback(()=>{i(false);},[]),D=useCallback(w=>{let[z,P]=w.split(":");switch(z){case "create-card":y("create-card");break;case "create-card-in":v(P||"");break;case "navigate":P?(a?.(P),x()):y("navigate");break;case "search":r?.(h),x();break;case "priority":y("priority");break;case "set-priority":g&&P&&(o?.(g,P),x());break;case "assign":y("assign");break;case "assign-user":g&&P&&(s?.(g,P),x());break;case "ai":y("ai");break;case "ai-generate-plan":n?.(),x();break;case "ai-predict-risks":c?.(),x();break;case "ai-usage":m?.(),x();break;case "back":y("home");break;}},[h,g,t,a,r,o,s,n,c,m,x]),B=useCallback(()=>{f&&h.trim()&&(t?.(f,h.trim()),x());},[f,h,t,x]);return d?jsx(mt,{children:jsx("div",{className:"command-palette-overlay",onClick:x,children:jsx("div",{className:`command-palette ${u}`,onClick:w=>w.stopPropagation(),children:jsxs(Command,{value:h,onValueChange:C,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:p==="create-card"&&f?"Type card title and press Enter...":p==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:w=>{w.key==="Enter"&&p==="create-card"&&f&&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."}),p==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:D,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:D,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:D,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:D,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(w=>jsxs(Command.Item,{value:`navigate:${w.id}`,onSelect:D,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:w.priority==="URGENT"?"#EF4444":w.priority==="HIGH"?"#F59E0B":w.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:w.title}),w.labels&&w.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:w.labels.slice(0,2).map(z=>jsx("span",{className:"command-palette-item-label",children:z},z))})]},w.id))})]}),p==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:D,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(w=>jsxs(Command.Item,{value:`create-card-in:${w.id}`,onSelect:D,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:w.title}),jsxs("div",{className:"command-palette-item-count",children:[w.cardIds.length," cards"]})]},w.id))})]}),p==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:D,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(w=>{let z=e.columns.find(P=>P.id===w.columnId);return jsxs(Command.Item,{value:`navigate:${w.id}`,onSelect:D,className:"command-palette-item",keywords:[w.title,w.description||"",...w.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:w.priority==="URGENT"?"#EF4444":w.priority==="HIGH"?"#F59E0B":w.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:w.title}),jsx("div",{className:"command-palette-item-meta",children:z?.title})]}),w.labels&&w.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:w.labels.slice(0,2).map(P=>jsx("span",{className:"command-palette-item-label",children:P},P))})]},w.id)})})]}),p==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:D,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:D,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:D,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:D,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 gd(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,useEffect,useCallback,useMemo,useImperativeHandle,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 fc 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,Moon,Sun,Palette,ZoomOut,ZoomIn,Keyboard,ChevronRight,Image,FileText,File,Sparkles,Maximize2,MoreHorizontal,X,User,ChevronDown,Check,CalendarDays,Flag,Clock,Tag,Diamond,ListChecks,Upload,MessageSquare,Send,Rows3,FileImage,FileSpreadsheet,FileJson,FolderKanban,Download,Calendar,ChevronLeft,GripVertical,AlertCircle,CircleDot,Users,Milestone,List,Search}from'lucide-react';import {Command}from'cmdk';import Bu from'react-markdown';import Ru from'remark-gfm';import Ou from'rehype-sanitize';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Line,AreaChart,Area,PieChart,Pie,Cell,BarChart,Bar}from'recharts';var Yo=(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 qo=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 [qo.Translate.toString(e),qo.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function b(...e){return twMerge(clsx(e))}function Xo(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 Ym(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function Qn(e,t){return e.length===0?1e3:t===0?Xo(null,e[0].position):t>=e.length?Xo(e[e.length-1].position,null):Xo(e[t-1].position,e[t].position)}function hl(e,t=100){return e>t}var qm=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 Xm(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 Jo(e,t={}){let{maxAttempts:a=3,initialDelay:r=1e3,backoffMultiplier:o=2,maxDelay:s=1e4,shouldRetry:n=qm,onRetry:c}=t,p,l=0;for(let u=1;u<=a;u++){l=u;try{return {data:await e(),attempts:l,success:!0}}catch(d){if(p=d,u===a||!n(p,u))return {error:p,attempts:l,success:false};let h=Xm(u,r,o,s);if(c)try{c(p,u,h);}catch(C){console.error("Error in retry callback:",C);}await new Promise(C=>setTimeout(C,h));}}return {error:p||new Error("Unknown error"),attempts:l,success:false}}function Jm(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 Zm(e,t={}){return async(...a)=>Jo(()=>e(...a),t)}var es=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 bl=(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))(bl||{}),Ar=class Ar{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...n}=t,c=`[${a}] [${r}] [${s}]`,p=Object.keys(n).length>0;switch(r){case "DEBUG":console.debug(c,o,p?n:"");break;case "INFO":console.info(c,o,p?n:"");break;case "WARN":console.warn(c,o,p?n:"");break;case "ERROR":console.error(c,o,p?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",...Ar.globalOptions};}static configure(t){Ar.globalOptions={...Ar.globalOptions,...t};}child(t){return new Ar({...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 Zo((a,r)=>{this.log(0,`${t} completed`,{...r,action:t,duration:a});},true):new Zo(()=>{},false)}log(t,a,r){if(!this.options.enabled||t<this.options.minLevel)return;let o={timestamp:new Date().toISOString(),level:bl[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};Ar.globalOptions={};var ts=Ar,Zo=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}},yl=new ts;function ep(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 tp(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,as(s.title),as(s.description||""),as(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 ap(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 fc(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),c=n.toDataURL("image/png"),p=297,l=210,u=n.width/n.height,d=p-20,i=d/u;i>l-20&&(i=l-20,d=i*u);let h=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});h.setFontSize(16),h.setTextColor(255,255,255),h.setFillColor(10,10,10),h.rect(0,0,p,15,"F"),h.text(e.title||"Kanban Board",10,10);let C=(p-d)/2;return h.addImage(c,"PNG",C,20,d,i),h}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(p=>p.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(p=>{if(s>260&&(o.addPage(),s=20),o.setFontSize(12),o.setFont("helvetica","bold"),o.text(p.title,25,s),s+=6,p.description){o.setFontSize(9),o.setFont("helvetica","normal");let u=o.splitTextToSize(p.description,160);o.text(u,25,s),s+=u.length*5;}let l=[];if(p.priority&&l.push(`Priority: ${p.priority}`),p.labels&&p.labels.length>0&&l.push(`Labels: ${p.labels.join(", ")}`),p.assignedUserIds&&p.assignedUserIds.length>0&&l.push(`Assigned: ${p.assignedUserIds.length} user(s)`),p.startDate||p.endDate){let u=[];p.startDate&&u.push(`Start: ${p.startDate}`),p.endDate&&u.push(`End: ${p.endDate}`),l.push(u.join(" \u2192 "));}l.length>0&&(o.setFontSize(8),o.setTextColor(100,100,100),o.text(l.join(" \u2022 "),25,s),o.setTextColor(0,0,0),s+=5),s+=5;}),s+=5;}),o}function as(e){return e.includes(",")||e.includes('"')||e.includes(`
3
+ `)?`"${e.replace(/"/g,'""')}"`:e}async function xl(e,t,a,r){switch(t){case "json":return ep(e,r);case "csv":return tp(e);case "pdf":return await ap(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function kl(e,t,a){let r=`board-export-${new Date().getTime()}`;if(t==="pdf"&&typeof e=="object"&&e!==null&&"save"in e){let u=`${r}.pdf`;e.save(u);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]}),p=URL.createObjectURL(c),l=document.createElement("a");l.href=p,l.download=s,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(p);}function rp(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 op(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=wl(t[0]),r=[],o=new Map,s=[];for(let n=1;n<t.length;n++)try{let c=wl(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 l={};a.forEach((h,C)=>{l[h]=c[C]||"";});let u=l.Column||"Unnamed";o.has(u)||o.set(u,{id:`col-${o.size+1}`,title:u,position:o.size+1,cardIds:[]});let d=o.get(u),i={id:l["Card ID"]||`card-${n}`,title:l.Title||"Untitled",description:l.Description?l.Description:void 0,columnId:d.id,position:d.cardIds.length+1,priority:l.Priority||void 0,labels:l.Labels?l.Labels.split(";").filter(Boolean):void 0,assignedUserIds:l["Assigned Users"]?l["Assigned Users"].split(";").filter(Boolean):void 0,startDate:l["Start Date"]?l["Start Date"]:void 0,endDate:l["End Date"]?l["End Date"]:void 0,createdAt:l["Created At"]?l["Created At"]:void 0,updatedAt:l["Updated At"]?l["Updated At"]:void 0};r.push(i),d.cardIds.push(i.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 wl(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 Cl(e,t){switch(t){case "json":return rp(e);case "csv":return op(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Tl(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 rs=createContext(null);function Nl(){return useContext(rs)}var Dl=createContext(null);function Sl({children:e,themeName:t}){return jsx(Dl.Provider,{value:{themeName:t},children:e})}function Zr(){return useContext(Dl)}function pt({children:e,container:t}){let[a,r]=useState(false),o=Nl(),s=Zr();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:p}=o,l={"--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":p,"data-gantt-portal":"true",style:l,children:e}),n)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),n):createPortal(e,n)}var Fl={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},pp="#BDC3C7",up=({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 Fr({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,n]=useState({top:0,left:0}),c=useRef(null),p=useRef(null),l=()=>{if(!p.current)return;let h=p.current.getBoundingClientRect(),C=window.innerHeight,m=window.innerWidth,y=160,f=220,v=4,g=h.right-y;g<10&&(g=h.left),g+y>m-10&&(g=m-y-10);let k=C-h.bottom,x=h.top,S;k>=f+v?S=h.bottom+v:x>=f+v?S=h.top-f-v:S=k>=x?h.bottom+v:Math.max(10,h.top-f-v),n({top:S,left:g}),o(true);};useEffect(()=>{let h=C=>{c.current&&!c.current.contains(C.target)&&!p.current?.contains(C.target)&&o(false);};if(r)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[r]),useEffect(()=>{let h=C=>{C.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r]);let u=h=>{t(h),o(false);},d=e?Fl[e]:null,i=d?.color||pp;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:p,onClick:()=>r?o(false):l(),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?`${i}10`:"transparent",boxShadow:e?`0 0 0 2px ${i}30 inset`:"none"},title:d?.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:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:i,fillOpacity:e?"0.6":"0.4"})})}),r&&jsx(pt,{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(Fl).map(([h,C])=>jsxs("button",{onClick:()=>u(h),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:C.color,background:"transparent"},onMouseEnter:m=>{m.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:m=>{m.currentTarget.style.background="transparent";},children:[jsx(up,{color:C.color}),jsx("span",{className:"font-semibold text-sm",children:C.label}),e===h&&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)),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:()=>u(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:h=>{h.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:h=>{h.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 gp=[{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 vo({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),p=useRef(null),l=useRef(null),i=(Zr()?.themeName||"dark")==="dark",h=()=>{if(!l.current)return;let g=l.current.getBoundingClientRect(),k=window.innerHeight,x=window.innerWidth,S=320,L=380,w=4,O=g.left;O+S>x-10&&(O=x-S-10),O<10&&(O=10);let M=k-g.bottom,T=g.top,_;M>=L+w?_=g.bottom+w:T>=L+w?_=g.top-L-w:_=M>=T?g.bottom+w:Math.max(10,g.top-L-w),c({top:_,left:O}),s(true);};useEffect(()=>{let g=k=>{p.current&&!p.current.contains(k.target)&&!l.current?.contains(k.target)&&s(false);};if(o)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[o]),useEffect(()=>{let g=k=>{k.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[o]);let C=g=>{let k=new Date,x=O=>{let M=O.getFullYear(),T=String(O.getMonth()+1).padStart(2,"0"),_=String(O.getDate()).padStart(2,"0");return `${M}-${T}-${_}`},S=x(k),L=new Date(k);L.setDate(L.getDate()+g);let w=x(L);a(S,w),s(false);},m=()=>{if(!e||!t)return "Set date";let g=L=>{if(L instanceof Date)return L;if(typeof L!="string"||!L.match(/^\d{4}-\d{2}-\d{2}$/))return null;let w=L.split("-").map(Number);if(w.length!==3||w.some(_=>isNaN(_)))return null;let O=w[0],M=w[1],T=w[2];return O===void 0||M===void 0||T===void 0?null:new Date(O,M-1,T)},k=g(e),x=g(t);if(!k||!x||isNaN(k.getTime())||isNaN(x.getTime()))return "Set date";let S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${S[k.getMonth()]} ${k.getDate()} \u2013 ${S[x.getMonth()]} ${x.getDate()}`},y=e&&t,v=(()=>{if(!t)return false;let g=typeof t=="string"?new Date(t):t,k=new Date;return k.setHours(0,0,0,0),g<k})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:l,onClick:()=>o?s(false):h(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${v?"asakaa-date-overdue":"asakaa-date"}`,title:y?`${m()}`:"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:m()})]}),o&&jsx(pt,{children:jsxs("div",{ref:p,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.left}px`,background:i?"#1A1D25":"#FFFFFF",border:`1px solid ${i?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.12)"}`,boxShadow:i?"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:i?"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:i?"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:gp.map(g=>jsx("button",{onClick:()=>C(g.days),className:"px-3 py-2.5 rounded-lg text-xs font-semibold transition-all active:scale-95",style:{color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",border:`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`,backgroundColor:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)"},onMouseEnter:k=>{k.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",k.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:k=>{k.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",k.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:g.label},g.label))})]}),jsxs("div",{className:"p-4",children:[jsx("span",{className:"text-xs font-bold uppercase tracking-wider block mb-3",style:{color:i?"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:g=>a(g.target.value,t),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:i?"dark":"light"}}),jsx("input",{type:"date",value:t||"",onChange:g=>a(e,g.target.value),className:"w-full px-3 py-2.5 rounded-lg text-sm border focus:outline-none transition-all",style:{background:i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",borderColor:i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)",color:i?"rgba(255, 255, 255, 0.95)":"rgba(0, 0, 0, 0.85)",colorScheme:i?"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:g=>{g.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:g=>{g.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function Lr({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,n]=useState(false),[c,p]=useState(""),[l,u]=useState({top:0,left:0}),d=useRef(null),i=useRef(null),h=()=>{if(!i.current)return;let v=i.current.getBoundingClientRect(),g=window.innerHeight,k=window.innerWidth,x=300,S=380,L=4,w=v.right-x;w<10&&(w=v.left),w+x>k-10&&(w=k-x-10);let O=g-v.bottom,M=v.top,T;O>=S+L?T=v.bottom+L:M>=S+L?T=v.top-S-L:T=O>=M?v.bottom+L:Math.max(10,v.top-S-L),u({top:T,left:w}),n(true);};useEffect(()=>{let v=g=>{d.current&&!d.current.contains(g.target)&&!i.current?.contains(g.target)&&(n(false),p(""));};if(s)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s]),useEffect(()=>{let v=g=>{g.key==="Escape"&&(n(false),p(""));};if(s)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[s]);let C=v=>{let g=e.some(k=>k.id===v.id);a(g?e.filter(k=>k.id!==v.id):[...e,v]);},m=t.filter(v=>v.name.toLowerCase().includes(c.toLowerCase())),y=e.slice(0,o),f=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:i,onClick:()=>s?n(false):h(),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:[y.map(v=>jsx("div",{className:"asakaa-avatar",title:v.name,children:v.avatar?jsx("img",{src:v.avatar,alt:v.name,className:"asakaa-avatar-img"}):v.initials},v.id)),f>0&&jsxs("div",{className:"asakaa-avatar",children:["+",f]})]}):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(pt,{children:jsxs("div",{ref:d,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${l.top}px`,left:`${l.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:v=>p(v.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:m.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"}):m.map(v=>{let g=e.some(k=>k.id===v.id);return jsxs("button",{onClick:()=>C(v),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:k=>{k.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:k=>{k.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:v.color,color:"#fff"},children:v.avatar?jsx("img",{src:v.avatar,alt:v.name,className:"w-full h-full rounded-full object-cover"}):v.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:v.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:g?"#3b82f6":"transparent"},children:g?"\u2713":""})]},v.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 Qo(e,t,a){let r=new Map;e.forEach(p=>{if(p.dependencies&&Array.isArray(p.dependencies)){let l=p.dependencies.map(u=>{if(typeof u=="string")return u;let d=u;return d.taskId||d.targetId||""}).filter(Boolean);r.set(p.id,l);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,n=new Set,c=p=>{if(!s.has(p)){s.add(p),n.add(p);let l=r.get(p)||[];for(let u of l){if(!s.has(u)&&c(u))return true;if(n.has(u))return true}}return n.delete(p),false};return c(a)}function ko({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:n}){let[c,p]=useState(false),[l,u]=useState(""),[d,i]=useState(t.length>0),[h,C]=useState({top:0,left:0}),[m,y]=useState(null),f=useRef(null),v=useRef(null),g=()=>{if(!v.current)return;let w=v.current.getBoundingClientRect(),O=window.innerHeight,M=window.innerWidth,T=300,_=d?380:120,B=4,J=w.right-T;J<10&&(J=w.left),J+T>M-10&&(J=M-T-10);let te=O-w.bottom,be=w.top,Fe;te>=_+B?Fe=w.bottom+B:be>=_+B?Fe=w.top-_-B:Fe=te>=be?w.bottom+B:Math.max(10,w.top-_-B),C({top:Fe,left:J}),p(true);};useEffect(()=>{if(!c||!v.current)return;let w=v.current.getBoundingClientRect(),O=window.innerHeight,M=window.innerWidth,T=300,_=d?380:120,B=4,J=w.right-T;J<10&&(J=w.left),J+T>M-10&&(J=M-T-10);let te=O-w.bottom,be=w.top,Fe;te>=_+B?Fe=w.bottom+B:be>=_+B?Fe=w.top-_-B:Fe=te>=be?w.bottom+B:Math.max(10,w.top-_-B),C({top:Fe,left:J});},[d,c]),useEffect(()=>{let w=O=>{f.current&&!f.current.contains(O.target)&&!v.current?.contains(O.target)&&(p(false),u(""));};if(c)return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]),useEffect(()=>{let w=O=>{O.key==="Escape"&&(p(false),u(""));};if(c)return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[c]);let k=w=>{let O=t.includes(w),M=a.find(T=>T.id===w);if(y(null),O){let T=t.filter(_=>_!==w);r(T),T.length===0&&i(false);}else {if(s&&Qo(a,w,e)){let _=`Cannot add "${M?.title||w}" as dependency - would create circular reference`;y(_),n?.(w,M?.title||w),setTimeout(()=>y(null),3e3);return}r([...t,w]),i(true);}},x=()=>{let w=!d;i(w),w||r([]);},S=a.filter(w=>w.id!==e).filter(w=>w.title.toLowerCase().includes(l.toLowerCase())||w.id.toLowerCase().includes(l.toLowerCase())),L=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:v,onClick:()=>c?p(false):g(),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:L,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:L},children:t.length})]}),c&&jsx(pt,{children:jsxs("div",{ref:f,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${h.top}px`,left:`${h.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:[m&&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:m})]}),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:x,children:[jsx("div",{className:"w-4 h-4 rounded border-2 flex items-center justify-center transition-all",style:{background:d?"#3b82f6":"transparent",borderColor:d?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:d&&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"})]})}),d&&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:l,onChange:w=>u(w.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:S.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"}):S.map(w=>{let O=t.includes(w.id);return jsxs("button",{onClick:()=>k(w.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:M=>{M.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:M=>{M.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:O?"#3b82f6":"transparent",borderColor:O?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:O&&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:w.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:w.id})]})]},w.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),i(false),p(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:p=[]})=>{let{attributes:l,listeners:u,setNodeRef:d,transform:i,transition:h,isDragging:C}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),m={transform:qo.Transform.toString(i),transition:h};if(t)return jsx("div",{ref:d,style:m,...l,...u,onClick:()=>a?.(e),children:t(e)});let y=c.filter(k=>e.assignedUserIds?.includes(k.id)),f=e.progress===100,v=(e.attachments||[]).filter(k=>k.type.startsWith("image/")),g={...m,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:d,style:g,className:b("asakaa-card",C&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...l,...u,onClick:k=>{k.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:k=>{k.currentTarget.style.display="none";}})}),v.length>0&&!e.coverImage&&jsx("div",{className:"asakaa-card-attachments mb-3",children:v.length===1&&v[0]?jsx("img",{src:v[0].url,alt:v[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:k=>{k.currentTarget.style.display="none";}}):jsx("div",{className:"grid grid-cols-2 gap-1",children:v.slice(0,4).map((k,x)=>jsxs("div",{className:"relative",children:[jsx("img",{src:k.url,alt:k.name,className:"w-full h-16 object-cover rounded",loading:"lazy",decoding:"async",style:{imageRendering:"auto",WebkitBackfaceVisibility:"hidden",backfaceVisibility:"hidden",transform:"translateZ(0)"},onError:S=>{S.currentTarget.style.display="none";}}),x===3&&v.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:["+",v.length-4]})})]},k.id))})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:f?"line-through":"none",opacity:f?.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:k=>k.stopPropagation(),className:"priority-selector",children:jsx(Fr,{priority:e.priority,onChange:k=>n?.(e.id,{priority:k})})}),jsx("div",{onClick:k=>k.stopPropagation(),className:"date-picker",children:jsx(vo,{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:(k,x)=>n?.(e.id,{startDate:k,endDate:x})})}),c.length>0&&jsx("div",{onClick:k=>k.stopPropagation(),className:"user-selector",children:jsx(Lr,{assignedUsers:y,availableUsers:c,onChange:k=>n?.(e.id,{assignedUserIds:k.map(x=>x.id)})})}),jsx("div",{onClick:k=>k.stopPropagation(),className:"dependencies-selector",children:jsx(ko,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(k=>typeof k=="string"?k:k.taskId):[],availableTasks:p,onChange:k=>n?.(e.id,{dependencies:k})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(k=>jsx("span",{className:"asakaa-label",children:k},k))}),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 en={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"}},Wl=({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 Gl({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[n,c]=useState({top:0,left:0}),p=useRef(null),l=useRef(null),u=[...Object.entries(en).map(([y,f])=>({id:y,label:f.label,color:f.color,icon:f.icon})),...r.filter(y=>!Object.keys(en).includes(y.id)).map(y=>({id:y.id,label:y.title,color:y.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let y=en[e];if(y)return {...y,id:e};let f=r.find(v=>v.id===e);return f?{id:f.id,label:f.title,color:f.color||"#8B5CF6",icon:"circle-dot"}:{...en.todo,id:"todo"}},i=()=>{if(!l.current)return;let y=l.current.getBoundingClientRect(),f=window.innerHeight,v=window.innerWidth,g=180,k=280,x=4,S=y.right-g;S<10&&(S=y.left),S+g>v-10&&(S=v-g-10);let L=f-y.bottom,w=y.top,O;L>=k+x?O=y.bottom+x:w>=k+x?O=y.top-k-x:O=L>=w?y.bottom+x:Math.max(10,y.top-k-x),c({top:O,left:S}),s(true);};useEffect(()=>{let y=f=>{p.current&&!p.current.contains(f.target)&&!l.current?.contains(f.target)&&s(false);};if(o)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[o]),useEffect(()=>{let y=f=>{f.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[o]);let h=y=>{t(y),s(false);},C=d(),m=C.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:l,onClick:()=>o?s(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:`${m}10`,boxShadow:`0 0 0 2px ${m}30 inset`},title:C.label,children:jsx(Wl,{icon:C.icon,color:m})}),o&&jsx(pt,{children:jsxs("div",{ref:p,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:u.map(y=>jsxs("button",{onClick:()=>h(y.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:y.color,background:"transparent"},onMouseEnter:f=>{f.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:f=>{f.currentTarget.style.background="transparent";},children:[jsx(Wl,{icon:y.icon,color:y.color}),jsx("span",{className:"font-semibold",children:y.label}),e===y.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"})})]},y.id))})]})})]})}function _l({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,n]=useState(false),[c,p]=useState(false),[l,u]=useState(e),[d,i]=useState({top:0,left:0}),h=useRef(null),C=useRef(null),m=useRef(null);useEffect(()=>{if(s&&C.current){let g=C.current.getBoundingClientRect();i({top:g.bottom+window.scrollY+8,left:g.left+window.scrollX});}},[s]),useEffect(()=>{let g=k=>{h.current&&!h.current.contains(k.target)&&!C.current?.contains(k.target)&&(n(false),p(false));};if(s)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[s]),useEffect(()=>{let g=k=>{k.key==="Escape"&&(n(false),p(false),u(e));};if(s)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s,e]),useEffect(()=>{c&&m.current&&(m.current.focus(),m.current.select());},[c]);let y=()=>{p(true),u(e);},f=()=>{let g=l.trim();g&&g!==e&&t(g),p(false),n(false),u(e);},v=g=>{g.key==="Enter"?f():g.key==="Escape"&&(p(false),u(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:C,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(pt,{children:jsx("div",{ref:h,className:"fixed rounded-xl shadow-2xl border min-w-[200px]",style:{top:`${d.top}px`,left:`${d.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:m,type:"text",value:l,onChange:g=>u(g.target.value),onKeyDown:v,onBlur:f,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:y,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 to=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:n,onCardUpdate:c,availableUsers:p,allCards:l,enableVirtualization:u,cardHeight:d=120,isCollapsed:i,onToggleCollapse:h,onColumnRename:C,onColumnDelete:m,isDeletable:y=false,className:f})=>{let{setNodeRef:v,isOver:g}=useDroppable({id:e.id,data:{type:"column",column:e}}),k=useRef(null),x=u??hl(t.length),S=useVirtualizer({count:t.length,getScrollElement:()=>k.current,estimateSize:()=>d,enabled:x});if(a)return jsx("div",{ref:v,className:f,children:a(e,t)});let w=(()=>{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}})(),O=w.state==="exceeded",M=()=>"asakaa-column-count";return jsxs("div",{ref:v,className:b("asakaa-column",g&&"ring-2 ring-asakaa-accent-blue",O&&"ring-2 ring-asakaa-accent-red",f),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:b(M()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&w.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${w.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[w.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"})]}),w.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"})]}),w.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"})}),w.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"})]})]}),(C||m)&&jsx(_l,{columnTitle:e.title,onRename:T=>C?.(e.id,T),onDelete:m?()=>m(e.id):void 0,isDeletable:y}),h&&jsx("button",{onClick:h,className:"text-asakaa-text-tertiary hover:text-asakaa-text-primary","aria-label":i?"Expand column":"Collapse column",children:i?"\u25B6":"\u25BC"})]})]}),!i&&jsx("div",{ref:k,className:"asakaa-column-cards",style:{maxHeight:x?"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"})}):x?jsx("div",{style:{height:`${S.getTotalSize()}px`,position:"relative"},children:S.getVirtualItems().map(T=>{let _=t[T.index];return _?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${T.start}px)`},children:jsx(sr,{card:_,render:r,onClick:n,onUpdate:c,availableUsers:p,allCards:l})},_.id):null})}):t.map(T=>jsx(sr,{card:T,render:r,onClick:n,onUpdate:c,availableUsers:p,allCards:l},T.id))})})]})});to.displayName="Column";function ls({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 p=()=>{let u=s.trim();u&&u!==e?t(u):n(e),o(false);},l=u=>{u.key==="Enter"?p():u.key==="Escape"&&(n(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:u=>n(u.target.value),onBlur:p,onKeyDown:l,className:b("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:b("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}var on=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function Qa({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:n=true}){let[c,p]=useState(false),[l,u]=useState(""),[d,i]=useState(false),[h,C]=useState(on[10]||"#3B82F6"),[m,y]=useState({top:0,left:0}),f=useRef(null),v=useRef(null),g=useRef(null),k=useRef(null),x=t.filter(T=>T.name.toLowerCase().includes(l.toLowerCase())),S=t.some(T=>T.name.toLowerCase()===l.toLowerCase());useEffect(()=>{if(c&&v.current){let T=v.current.getBoundingClientRect();y({top:T.bottom+6,left:T.left});}},[c]),useEffect(()=>{let T=_=>{let B=_.target,J=f.current?.contains(B),te=g.current?.contains(B);!J&&!te&&(p(false),u(""),i(false));};if(c)return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[c]),useEffect(()=>{c&&k.current&&k.current.focus();},[c]);let L=T=>{let _=e.some(B=>B.id===T.id);a(_?e.filter(B=>B.id!==T.id):[...e,T]);},w=async()=>{if(!(!r||!l.trim())){i(true);try{let T=await r(l.trim(),h);T&&(a([...e,T]),u(""),C(on[Math.floor(Math.random()*on.length)]||"#3B82F6"));}finally{i(false);}}},O=(T,_)=>{_.stopPropagation(),a(e.filter(B=>B.id!==T));},M={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:f,className:"relative",children:[jsxs("button",{ref:v,type:"button",onClick:()=>!s&&p(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:M,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:g,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:m.top,left:m.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:k,type:"text",value:l,onChange:T=>u(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"&&l.trim()&&!S&&r&&w();}})}),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:_=>O(T.id,_),children:[T.name,jsx(X,{className:"w-3 h-3"})]},T.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:x.length>0?x.map(T=>{let _=e.some(B=>B.id===T.id);return jsxs("button",{type:"button",onClick:()=>L(T),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:_?`${T.color}15`:"transparent",color:o.textPrimary},onMouseEnter:B=>{_||(B.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:B=>{_||(B.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}),_&&jsx(Check,{className:"w-4 h-4",style:{color:T.color}})]},T.id)}):l.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"})}),l.trim()&&!S&&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:on.map(T=>jsx("button",{type:"button",onClick:()=>C(T),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:T,outline:h===T?`2px solid ${T}`:"none",outlineOffset:"2px"}},T))}),jsxs("button",{type:"button",onClick:w,disabled:d,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{backgroundColor:h,color:"#FFFFFF",opacity:d?.7:1},children:[d?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 "',l.trim(),'"']})]})]})}),document.body)]})}function cs({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 Yl({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(cs,{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 er=[{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 Ql(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 eu(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 Or({task:e,isOpen:t,onClose:a,onTaskUpdate:r,onCardUpdate:o,theme:s="dark",locale:n="es",availableUsers:c=[],availableTags:p=[],onCreateTag:l,attachments:u=[],onUploadAttachments:d,onDeleteAttachment:i,availableTasks:h=[],comments:C=[],onAddComment:m,currentUser:y}){let f=s==="dark",v={textTertiary:f?"#6B7280":"#9CA3AF",textSecondary:f?"#9CA3AF":"#6B7280",textPrimary:f?"#FFFFFF":"#111827",borderLight:f?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:f?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:f?"#1A1D25":"#FFFFFF",bgSecondary:f?"#0F1117":"#F9FAFB",hoverBg:f?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},g=e&&"title"in e&&!("name"in e),k=e,[x,S]=useState(e?Ql(e,c):null),[L,w]=useState(false),[O,M]=useState(false),[T,_]=useState(false),[B,J]=useState(null),[te,be]=useState(new Date),[Fe,Oe]=useState(false),[je,H]=useState(false),[z,W]=useState(""),[N,j]=useState(false),[q,R]=useState(false),[ie,ke]=useState(false),[Ee,ce]=useState(""),Ke=useRef(null),[Me,at]=useState(""),lt=useRef(null),[dt,tt]=useState(""),[U,ne]=useState(false);useEffect(()=>{if(e){let E=Ql(e,c);S(E),ce(E.description||""),at(E.name||"");}},[e?.id,c]),useEffect(()=>()=>{Ke.current&&clearTimeout(Ke.current),lt.current&&clearTimeout(lt.current);},[]);let re=useCallback(E=>{S(E),g&&o&&k?o(eu(E,k)):r&&r(E);},[g,k,o,r]),we=useCallback(()=>{w(false),M(false),_(false),J(null),H(false),W(""),j(false);},[]),Te=useCallback((E,Z)=>{if(!x)return;let me={...x,[E]:Z};re(me);},[x,re]),rt=useCallback(E=>{ce(E),Ke.current&&clearTimeout(Ke.current),Ke.current=setTimeout(()=>{if(x){let Z={...x,description:E};re(Z);}},800);},[x,re]),wt=useCallback(E=>{at(E),lt.current&&clearTimeout(lt.current),lt.current=setTimeout(()=>{if(x&&E.trim()){let Z={...x,name:E.trim()};re(Z);}},800);},[x,re]),Ie=useCallback(async()=>{if(!(!x||!dt.trim()||!m)){ne(true);try{await m(x.id,dt.trim()),tt("");}finally{ne(false);}}},[x,dt,m]),ye=useCallback(E=>{let Z=typeof E=="string"?new Date(E):E,Ne=new Date().getTime()-Z.getTime(),ze=Math.floor(Ne/6e4),Be=Math.floor(Ne/36e5),Le=Math.floor(Ne/864e5);return ze<1?n==="es"?"Ahora":"Just now":ze<60?n==="es"?`Hace ${ze} min`:`${ze}m ago`:Be<24?n==="es"?`Hace ${Be}h`:`${Be}h ago`:Le<7?n==="es"?`Hace ${Le}d`:`${Le}d ago`:Z.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})},[n]),Se=useCallback(E=>{if(!x)return;let Z=x.progress||0;E==="completed"?Z=100:E==="in-progress"&&Z===0?Z=10:E==="todo"&&(Z=0);let me={...x,status:E,progress:Z};re(me),w(false);},[x,re]),St=useCallback((E,Z)=>{if(!x)return;let me={...x,startDate:E,endDate:Z};re(me);},[x,re]),gt=useCallback(()=>{let E=te.getFullYear(),Z=te.getMonth(),me=new Date(E,Z,1),ze=new Date(E,Z+1,0).getDate(),Be=me.getDay(),Le=[],Ze=new Date(E,Z,0).getDate();for(let Y=Be-1;Y>=0;Y--)Le.push({date:new Date(E,Z-1,Ze-Y),isCurrentMonth:false});for(let Y=1;Y<=ze;Y++)Le.push({date:new Date(E,Z,Y),isCurrentMonth:true});let ct=42-Le.length;for(let Y=1;Y<=ct;Y++)Le.push({date:new Date(E,Z+1,Y),isCurrentMonth:false});return Le},[te]),ta=useCallback(async E=>{if(E.preventDefault(),E.stopPropagation(),R(false),!x||!d)return;let Z=Array.from(E.dataTransfer.files);if(Z.length!==0){ke(true);try{await d(x.id,Z);}finally{ke(false);}}},[x,d]),sa=useCallback(async E=>{if(!x||!d||!E.target.files)return;let Z=Array.from(E.target.files);if(Z.length!==0){ke(true);try{await d(x.id,Z);}finally{ke(false);}E.target.value="";}},[x,d]),Ge=useCallback(E=>{E.preventDefault(),E.stopPropagation(),R(true);},[]),$e=useCallback(E=>{E.preventDefault(),E.stopPropagation(),R(false);},[]),ia=useCallback(E=>E<1024?`${E} B`:E<1024*1024?`${(E/1024).toFixed(1)} KB`:`${(E/(1024*1024)).toFixed(1)} MB`,[]),he=useCallback(E=>E.startsWith("image/")?Image:E.includes("pdf")||E.includes("document")?FileText:File,[]);return !t||!x?null:jsx(AnimatePresence,{children:t&&x&&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:b("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",f?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:b("px-6 py-3 border-b flex items-center gap-3",f?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:b("w-4 h-4",f?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:b("text-xs px-2 py-0.5 rounded",f?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:b("text-xs font-mono",f?"text-[#6B7280]":"text-gray-400"),children:x.id.slice(0,8)}),jsxs("button",{className:b("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",f?"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:b("p-1.5 rounded transition-colors",f?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:b("p-1.5 rounded transition-colors",f?"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:b("p-1.5 rounded transition-colors",f?"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 E=x.progress===100?0:100,me={...x,progress:E,status:E===100?"completed":"todo"};re(me);},className:b("mt-2 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors flex-shrink-0",x.progress===100?"bg-green-500 border-green-500":f?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:x.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("input",{type:"text",value:Me,onChange:E=>wt(E.target.value),placeholder:n==="es"?"Nombre de la tarea...":"Task name...",className:b("text-xl font-semibold flex-1 bg-transparent outline-none border-none px-0 py-0","focus:ring-0 focus:outline-none",x.progress===100?"line-through text-[#6B7280]":f?"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:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{we(),w(!L);},className:b("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",x.progress===100||x.status==="completed"?"bg-green-500/20 text-green-400":x.progress&&x.progress>0||x.status==="in-progress"?"bg-blue-500/20 text-blue-400":f?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:x.progress===100||x.status==="completed"?n==="es"?"COMPLETADO":"DONE":x.progress&&x.progress>0||x.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:L&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>w(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",f?"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(E=>jsxs("button",{onClick:()=>Se(E.id),className:b("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",f?"hover:bg-white/5":"hover:bg-gray-50",x.status===E.id&&(f?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",E.color)}),jsx("span",{className:f?"text-white":"text-gray-900",children:E.label})]},E.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{we(),_(!T);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",f?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[x.assignees&&x.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[x.assignees.slice(0,3).map((E,Z)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:E.color||"#8B5CF6"},title:E.name,children:E.initials||E.name.slice(0,2).toUpperCase()},Z)),x.assignees.length>3&&jsxs("span",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:["+",x.assignees.length-3]})]}):jsx("span",{className:b("text-sm",f?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:b("w-3 h-3",f?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:T&&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:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",f?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:c.length>0?c.map(E=>{let Z=x.assignees?.some(me=>me.name===E.name);return jsxs("button",{onClick:()=>{let me=x.assignees||[],Ne;Z?Ne=me.filter(ze=>ze.name!==E.name):Ne=[...me,E],Te("assignees",Ne);},className:b("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",f?"hover:bg-white/5":"hover:bg-gray-50",Z&&(f?"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:E.color||"#8B5CF6"},children:E.initials||E.name.slice(0,2).toUpperCase()}),jsx("span",{className:b("flex-1",f?"text-white":"text-gray-900"),children:E.name}),Z&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},E.name)}):jsx("div",{className:b("px-3 py-4 text-sm text-center",f?"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:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{J(B?null:"start"),be(x.startDate||new Date);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",f?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[x.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:b("mx-1",f?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),x.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End")]}),jsx(AnimatePresence,{children:B&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>J(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:b("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",f?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:E=>E.stopPropagation(),children:[jsxs("div",{className:b("w-44 py-2 border-r",f?"border-white/10":"border-gray-200"),children:[(()=>{let E=new Date,Z=new Date(E);Z.setDate(E.getDate()+1);let me=new Date(E);me.setDate(E.getDate()+((6-E.getDay()+7)%7||7));let Ne=new Date(E);Ne.setDate(E.getDate()+((1-E.getDay()+7)%7||7));let ze=new Date(E);ze.setDate(E.getDate()+(6-E.getDay()+7)%7+7);let Be=new Date(E);Be.setDate(E.getDate()+14);let Le=new Date(E);return Le.setDate(E.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:E,display:E.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:Z,display:Z.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:me,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Ne,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:ze,display:ze.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:Be,display:Be.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Le,display:Le.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((ct,Y)=>jsxs("button",{className:b("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",f?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(B==="start"){let ae=x.endDate&&ct.date>x.endDate?ct.date:x.endDate;St(ct.date,ae),J("end");}else {let ae=x.startDate&&ct.date<x.startDate?ct.date:x.startDate;St(ae,ct.date),J(null);}},children:[jsx("span",{children:ct.label}),jsx("span",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:ct.display})]},Y))})(),jsx("div",{className:b("border-t mt-2 pt-2",f?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{St(void 0,void 0),J(null);},className:b("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",f?"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:b("text-xs mb-3 px-2 py-1 rounded",f?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:B==="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:b("font-medium",f?"text-white":"text-gray-900"),children:te.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>be(new Date),className:b("p-1 rounded text-sm transition-colors",f?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>be(new Date(te.getFullYear(),te.getMonth()-1)),className:b("p-1 rounded",f?"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:()=>be(new Date(te.getFullYear(),te.getMonth()+1)),className:b("p-1 rounded",f?"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(E=>jsx("div",{className:b("w-8 h-8 flex items-center justify-center text-xs",f?"text-[#6B7280]":"text-gray-400"),children:E},E))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:gt().map((E,Z)=>{let me=E.date.toDateString()===new Date().toDateString(),Ne=x.startDate?.toDateString()===E.date.toDateString(),ze=x.endDate?.toDateString()===E.date.toDateString(),Be=Ne||ze,Le=x.startDate&&x.endDate&&E.date>=x.startDate&&E.date<=x.endDate;return jsx("button",{onClick:()=>{let Ze=new Date(E.date);if(B==="start"){let ct=x.endDate&&Ze>x.endDate?Ze:x.endDate;St(Ze,ct),J("end");}else {let ct=x.startDate&&Ze<x.startDate?Ze:x.startDate;St(ct,Ze),J(null);}},className:b("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!E.isCurrentMonth&&(f?"text-[#4B5563]":"text-gray-300"),E.isCurrentMonth&&(f?"text-white":"text-gray-900"),me&&"ring-2 ring-[#3B82F6]",Ne&&"bg-[#3B82F6] text-white",ze&&!Ne&&"bg-[#7C3AED] text-white",Le&&!Be&&(f?"bg-[#7C3AED]/20":"bg-purple-100"),!Be&&(f?"hover:bg-white/10":"hover:bg-gray-100")),children:E.date.getDate()},Z)})})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{we(),M(!O);},className:b("text-xs px-2 py-1 rounded font-medium transition-all hover:ring-2 hover:ring-white/20",x.priority==="high"||x.priority==="urgent"?"bg-red-500/20 text-red-400":x.priority==="medium"?"bg-yellow-500/20 text-yellow-400":x.priority==="low"?"bg-green-500/20 text-green-400":f?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:x.priority?x.priority==="high"||x.priority==="urgent"?n==="es"?"Alta":"High":x.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:O&&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:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",f?"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(E=>jsxs("button",{onClick:()=>{Te("priority",E.id),M(false);},className:b("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",f?"hover:bg-white/5":"hover:bg-gray-50",x.priority===E.id&&(f?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",E.color)}),jsx("span",{className:f?"text-white":"text-gray-900",children:E.label})]},E.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:b("text-sm",f?"text-white":"text-gray-900"),children:x.startDate&&x.endDate?`${Math.ceil((x.endDate.getTime()-x.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:b("w-4 h-4 rounded-full border-2",f?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Fe?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:x.progress||0,onChange:E=>{let Z=parseInt(E.target.value),me=x.status;Z===100?me="completed":Z>0?me="in-progress":me="todo";let Ne={...x,progress:Z,status:me};re(Ne);},onBlur:()=>Oe(false),className:b("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",f?"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:()=>Oe(true),className:b("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",f?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:b("h-full rounded-full transition-all",x.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${x.progress||0}%`}})}),jsxs("span",{className:b("text-sm font-medium min-w-[40px]",f?"text-white":"text-gray-900"),children:[x.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx(Qa,{selectedTags:x.tags||[],availableTags:p,onChange:E=>{Te("tags",E);},onCreateTag:l,theme:v})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:b("w-4 h-4 mt-1.5",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24 mt-1",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[x.dependencies&&x.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:x.dependencies.map(E=>{let Z=h.find(me=>me.id===E);return jsxs("span",{className:b("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",f?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[Z?.name||E.slice(0,8),jsx("button",{onClick:()=>{let me=(x.dependencies||[]).filter(Ne=>Ne!==E);Te("dependencies",me);},className:b("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},E)})}),jsxs("button",{onClick:()=>{we(),H(!je);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",f?"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:b("text-sm",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:je&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{H(false),W("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",f?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:b("p-2 border-b",f?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:z,onChange:E=>W(E.target.value),placeholder:n==="es"?"Buscar tarea...":"Search task...",className:b("w-full px-3 py-2 rounded-md text-sm outline-none",f?"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:h.length>0?h.filter(E=>E.id!==x.id).filter(E=>z===""||E.name.toLowerCase().includes(z.toLowerCase())).map(E=>{let Z=x.dependencies?.includes(E.id);return jsxs("button",{onClick:()=>{let me=x.dependencies||[],Ne;Z?Ne=me.filter(ze=>ze!==E.id):Ne=[...me,E.id],Te("dependencies",Ne);},className:b("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",f?"hover:bg-white/5":"hover:bg-gray-50",Z&&(f?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:b("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",Z?"bg-blue-500 border-blue-500":f?"border-white/30":"border-gray-300"),children:Z&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:b("block truncate",f?"text-white":"text-gray-900"),children:E.name}),jsx("span",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:E.id.slice(0,8)})]})]},E.id)}):jsx("div",{className:b("px-3 py-4 text-sm text-center",f?"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:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{we(),j(!N);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",f?"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:x.color||"#6366F1"}}),jsx("span",{className:b("text-sm",f?"text-white":"text-gray-900"),children:er.find(E=>E.value===x.color)?.name||(n==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:b("w-3 h-3",f?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:N&&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:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",f?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:er.map(E=>{let Z=x.color===E.value;return jsx("button",{onClick:()=>{Te("color",E.value),j(false);},className:b("w-7 h-7 rounded-full flex items-center justify-center transition-all",Z&&"ring-2 ring-offset-2",f?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:E.value,outlineColor:Z?E.value:void 0},title:E.name,children:Z&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},E.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",f?"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:x.isMilestone||false,onChange:E=>Te("isMilestone",E.target.checked),className:b("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",x.isMilestone?"bg-purple-500 border-purple-500":f?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:b("text-sm",f?"text-white":"text-gray-900"),children:n==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:b("w-4 h-4",f?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:b("text-sm font-semibold",f?"text-white":"text-gray-900"),children:n==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:Ee,onChange:E=>rt(E.target.value),placeholder:n==="es"?"Agregar descripci\xF3n...":"Add description...",className:b("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",f?"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:b("flex items-center gap-2 text-sm mt-2 transition-colors",f?"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:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:b("text-sm font-semibold mb-3",f?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",f?"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:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:b("text-sm font-semibold mb-3",f?"text-white":"text-gray-900"),children:n==="es"?"Subtareas":"Subtasks"}),x.subtasks&&x.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:x.subtasks.map(E=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:b("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",E.progress===100?"bg-green-500 border-green-500":f?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:E.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:b("text-sm",E.progress===100?"line-through text-[#6B7280]":f?"text-white":"text-gray-900"),children:E.name})]},E.id))}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",f?"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:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:b("text-sm font-semibold",f?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:b("p-1 rounded transition-colors",f?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",f?"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:b("mt-6 pt-4 border-t",f?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:b("text-sm font-semibold mb-3",f?"text-white":"text-gray-900"),children:[n==="es"?"Adjuntos":"Attachments",u.length>0&&jsxs("span",{className:b("ml-2 text-xs font-normal",f?"text-[#6B7280]":"text-gray-400"),children:["(",u.length,")"]})]}),u.length>0&&jsx("div",{className:"space-y-2 mb-4",children:u.map(E=>{let Z=he(E.type),me=E.type.startsWith("image/");return jsxs("div",{className:b("flex items-center gap-3 p-2 rounded-lg group transition-colors",f?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[me&&E.thumbnailUrl?jsx("img",{src:E.thumbnailUrl,alt:E.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:b("w-10 h-10 rounded flex items-center justify-center",f?"bg-white/10":"bg-gray-200"),children:jsx(Z,{className:b("w-5 h-5",f?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:E.url,target:"_blank",rel:"noopener noreferrer",className:b("text-sm font-medium truncate block hover:underline",f?"text-white":"text-gray-900"),children:E.name}),jsx("p",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:ia(E.size)})]}),i&&jsx("button",{onClick:()=>i(E.id),className:b("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",f?"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"})})]},E.id)})}),jsxs("div",{onDragOver:Ge,onDragLeave:$e,onDrop:ta,className:b("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",q?f?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":f?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",ie&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:sa,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!d||ie}),ie?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:b("text-sm",f?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:b("w-6 h-6 mx-auto mb-2",q?"text-blue-500":f?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:b("text-sm",f?"text-[#9CA3AF]":"text-gray-500"),children:q?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"})]})}),!d&&jsx("p",{className:b("text-xs mt-1",f?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:b("w-80 border-l flex flex-col",f?"border-white/10 bg-[#0F1117]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:b("px-4 py-3 border-b",f?"border-white/10":"border-gray-200"),children:jsxs("h3",{className:b("text-sm font-semibold",f?"text-white":"text-gray-900"),children:[n==="es"?"Actividad":"Activity",C.length>0&&jsxs("span",{className:b("ml-2 text-xs font-normal",f?"text-[#6B7280]":"text-gray-400"),children:["(",C.length,")"]})]})}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:C.length>0?jsx("div",{className:"space-y-4",children:C.map(E=>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:E.user?.color||"#8B5CF6"},children:E.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:b("text-sm font-medium",f?"text-white":"text-gray-900"),children:E.user?.name||(n==="es"?"Usuario":"User")}),jsx("span",{className:b("text-xs",f?"text-[#6B7280]":"text-gray-400"),children:ye(E.createdAt)})]}),jsx("p",{className:b("text-sm break-words",f?"text-[#9CA3AF]":"text-gray-600"),children:E.content})]})]},E.id))}):jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[jsx(MessageSquare,{className:b("w-10 h-10 mb-3",f?"text-[#3B4252]":"text-gray-300")}),jsx("p",{className:b("text-sm",f?"text-[#6B7280]":"text-gray-500"),children:n==="es"?"Sin actividad reciente":"No recent activity"})]})}),jsx("div",{className:b("p-4 border-t",f?"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:b("flex-1 flex items-center gap-2 px-3 py-2 rounded-lg",f?"bg-white/5":"bg-white border border-gray-200"),children:[jsx("input",{type:"text",value:dt,onChange:E=>tt(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),Ie());},placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",disabled:U||!m,className:b("flex-1 bg-transparent text-sm outline-none",f?"text-white placeholder:text-[#6B7280]":"text-gray-900 placeholder:text-gray-400",(U||!m)&&"opacity-50")}),jsx("button",{onClick:Ie,disabled:U||!dt.trim()||!m,className:b("p-1.5 rounded transition-colors",dt.trim()&&m?"bg-blue-500 text-white hover:bg-blue-600":f?"text-[#6B7280]":"text-gray-400",U&&"opacity-50 cursor-not-allowed"),children:U?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"})})]})]})})]})]})]})})}function fs(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function vr({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:n,style:c,isLoading:p,error:l,children:u,availableTags:d=[],onCreateTag:i,attachmentsByCard:h,onUploadAttachments:C,onDeleteAttachment:m,comments:y,onAddComment:f,currentUser:v,onTaskOpen:g}){let[k,x]=fs(),[S,L]=useState(null),w=o?.theme||"dark",O=w==="dark"||w==="neutral",M=O?"dark":"",T=useCallback((N,j)=>{t.onCardUpdate?.(N,j);},[t]),_=useCallback((N,j)=>{t.onColumnUpdate?.(N,{title:j});},[t]),B=useCallback(N=>{t.onColumnDelete?.(N);},[t]),J=["todo","in-progress","completed"],te=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),be=useMemo(()=>{let N=new Map;return e.columns.forEach(j=>{let q=j.cardIds.map(R=>e.cards.find(ie=>ie.id===R)).filter(R=>R!==void 0).sort((R,ie)=>R.position-ie.position);N.set(j.id,q);}),N},[e.cards,e.columns]),Fe=useMemo(()=>e.cards.map(N=>({id:N.id,name:N.title,startDate:N.startDate?new Date(N.startDate):void 0,endDate:N.endDate?new Date(N.endDate):void 0,progress:N.progress||0,status:N.columnId,priority:N.priority?.toLowerCase(),dependencies:Array.isArray(N.dependencies)?N.dependencies.map(j=>typeof j=="string"?j:j.taskId):[]})),[e.cards]),Oe=useCallback(N=>{let{active:j}=N,q=e.cards.find(R=>R.id===j.id);q&&x({isDragging:true,draggedCardId:q.id,sourceColumnId:q.columnId,targetColumnId:q.columnId});},[e.cards,x]),je=useCallback(N=>{let{active:j,over:q}=N;if(!q||!e.cards.find(ke=>ke.id===j.id))return;let ie=null;q.data.current?.type==="column"?ie=q.id:q.data.current?.type==="card"&&(ie=e.cards.find(Ee=>Ee.id===q.id)?.columnId||null),ie&&ie!==k.targetColumnId&&x({...k,targetColumnId:ie});},[e.cards,k,x]),H=useCallback(async N=>{let{active:j,over:q}=N;if(x({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!q)return;let R=e.cards.find(ce=>ce.id===j.id);if(!R)return;let ie,ke;if(q.data.current?.type==="column"){ie=q.id;let ce=be.get(ie)||[];ke=Qn(ce,0);}else {let ce=e.cards.find(at=>at.id===q.id);if(!ce)return;ie=ce.columnId;let Ke=be.get(ie)||[],Me=Ke.findIndex(at=>at.id===q.id);ke=Qn(Ke,Me);}let Ee=e.columns.find(ce=>ce.id===ie);if(Ee&&Ee.wipLimit&&Ee.wipLimitType==="hard"){let ce=be.get(ie)||[];if(R.columnId!==ie&&ce.length>=Ee.wipLimit){t.onWipLimitExceeded?.(Ee,R);return}}(R.columnId!==ie||R.position!==ke)&&await t.onCardMove?.(R.id,ie,ke);},[e.cards,e.columns,be,t,x]),z=useCallback(N=>{L(N),a?.(N),g?.(N.id);},[a,g]),W=useCallback(N=>{t.onCardUpdate?.(N.id,N),L(N);},[t]);return p?jsx("div",{className:b("asakaa-board",M,n),style:c,children:jsx(pu,{columnCount:3})}):l?jsx("div",{className:b("asakaa-board",M,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 l=="string"?l:l.message})]})})}):jsxs(Sl,{themeName:w,children:[jsxs(DndContext,{sensors:te,collisionDetection:closestCorners,onDragStart:Oe,onDragOver:je,onDragEnd:H,children:[jsxs("div",{className:b("asakaa-board",M,n),style:c,"data-theme":w,children:[e.columns.sort((N,j)=>N.position-j.position).map(N=>{let j=be.get(N.id)||[],q=!J.includes(N.id);return jsx(to,{column:N,cards:j,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:z,onCardUpdate:T,onColumnRename:_,onColumnDelete:B,isDeletable:q,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},N.id)}),u]}),jsx(DragOverlay,{children:k.draggedCardId?jsx(sr,{card:e.cards.find(N=>N.id===k.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]}),jsx(Or,{task:S,isOpen:!!S,onClose:()=>L(null),onCardUpdate:W,theme:O?"dark":"light",locale:o?.locale==="es"?"es":"en",availableUsers:s,availableTags:d,onCreateTag:i,attachments:S?h?.get(S.id)||[]:[],onUploadAttachments:C,onDeleteAttachment:m,availableTasks:Fe,comments:y,onAddComment:f,currentUser:v})]})}function pu({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 bu={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)"},yu={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)"},vu={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},xu={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function ku({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,n]=useState(false),c=useRef(null);useEffect(()=>{let l=u=>{c.current&&!c.current.contains(u.target)&&n(false);};return s&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[s]);let p=l=>{t(l),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((l,u)=>l.position-u.position).map((l,u)=>jsxs(motion.button,{onClick:()=>p(l.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:u<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:l.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:l.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[l.cardIds.length," ",l.cardIds.length===1?"tarea":"tareas"]})]})]},l.id))]})})})]})}function wu({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,n]=useState(false),[c,p]=useState(null),l=useRef(null);if(useEffect(()=>{let h=C=>{l.current&&!l.current.contains(C.target)&&n(false);};return s&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]),!(a||r||o))return null;let d=[{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(h=>h.handler),i=async(h,C)=>{if(C){p(h);try{await C();}catch(m){console.error(`Export ${h} failed:`,m);}finally{p(null),n(false);}}};return jsxs("div",{ref:l,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:d.map((h,C)=>jsxs(motion.button,{onClick:()=>i(h.id,h.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:C<d.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:C*.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===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 Cu({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 bs({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:n,onExportJSON:c,onExportExcel:p,translations:l}){let u=r==="dark"?bu:yu,d={...o==="es"?vu:xu,...l},i=n||c||p;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:u.bgGrid,borderColor:u.border},children:jsxs("div",{className:"flex items-center gap-3",children:[i&&jsxs(Fragment,{children:[jsx(wu,{theme:u,t:d,onExportCSV:n,onExportJSON:c,onExportExcel:p}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:u.borderLight}})]}),t&&(s?jsx(ku,{columns:e,onSelect:t,theme:u,t:d,createTaskLabel:a}):jsx(Cu,{onClick:()=>t(),label:a||d.newTask}))]})})}function vs({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,n]=useState(false),[c,p]=useState(""),l=useCallback(()=>{let i=c.trim();i&&(e(i),p(""),n(false));},[c,e]),u=useCallback(i=>{i.key==="Enter"?(i.preventDefault(),l()):i.key==="Escape"&&(p(""),n(false));},[l]),d=useCallback(()=>{setTimeout(()=>{c.trim()||n(false);},150);},[c]);return s?jsx("div",{className:b("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:i=>p(i.target.value),onKeyDown:u,onBlur:d,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:l,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:()=>{p(""),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:b("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 xs({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:n=false,theme:c="dark",locale:p="es"}){let[l,u]=useState(false),[d,i]=useState(false),[h,C]=useState(""),[m,y]=useState([]),[f,v]=useState(""),[g,k]=useState(""),[x,S]=useState(""),[L,w]=useState(false),[O,M]=useState(false),[T,_]=useState(false),B=useRef(null),J=useRef(null),te={placeholder:o||(p==="es"?"Nombre de la tarea...":"Task Name..."),buttonLabel:s||(p==="es"?"Agregar Tarea":"Add Task"),save:p==="es"?"Guardar":"Save",addAssignee:p==="es"?"Agregar asignado":"Add assignee",addDates:p==="es"?"Agregar fechas":"Add dates",addPriority:p==="es"?"Agregar prioridad":"Add priority",startDate:p==="es"?"Inicio":"Start",endDate:p==="es"?"Fin":"End",low:p==="es"?"Baja":"Low",medium:p==="es"?"Media":"Medium",high:p==="es"?"Alta":"High",urgent:p==="es"?"Urgente":"Urgent"},be=useCallback(()=>{C(""),y([]),v(""),k(""),S(""),w(false),M(false),_(false),u(false);},[]);useEffect(()=>{l&&B.current&&B.current.focus();},[l]),useEffect(()=>{if(!l)return;let z=W=>{J.current&&!J.current.contains(W.target)&&(h.trim()||be());};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[l,h,be]);let Fe=useCallback(async()=>{let z=h.trim();if(!(!z||d)){i(true);try{await t({name:z,columnId:e,assigneeIds:m.length>0?m:void 0,startDate:f?new Date(f):void 0,endDate:g?new Date(g):void 0,priority:x||void 0}),C(""),y([]),v(""),k(""),S(""),w(!1),M(!1),_(!1),B.current?.focus();}catch(W){console.error("Error creating card:",W);}finally{i(false);}}},[h,e,m,f,g,x,t,d]),Oe=useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),Fe()):z.key==="Escape"&&be();},[Fe,be]),je=useCallback(z=>{y(W=>W.includes(z)?W.filter(N=>N!==z):[...W,z]);},[]),H=c==="dark";return l?jsxs("div",{ref:J,className:b("rounded-lg overflow-hidden shadow-lg",H?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:B,type:"text",value:h,onChange:z=>C(z.target.value),onKeyDown:Oe,placeholder:te.placeholder,disabled:d,className:b("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",H?"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:()=>w(!L),className:b("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",L||m.length>0?"bg-emerald-500/20 text-emerald-400":H?"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"})]}),m.length>0&&jsx("span",{className:"ml-0.5",children:m.length})]}),jsx("button",{onClick:()=>M(!O),className:b("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",O||f||g?"bg-blue-500/20 text-blue-400":H?"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:()=>_(!T),className:b("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",T||x?x==="urgent"?"bg-red-500/20 text-red-400":x==="high"?"bg-orange-500/20 text-orange-400":x==="medium"?"bg-yellow-500/20 text-yellow-400":x==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":H?"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:Fe,disabled:!h.trim()||d,className:b("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:d?jsx("div",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"}):te.save})]})]}),L&&a.length>0&&jsx("div",{className:b("px-3 pb-3 pt-0","border-t",H?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(z=>jsxs("button",{onClick:()=>je(z.id),className:b("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",m.includes(z.id)?"bg-emerald-500 text-white":H?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[z.avatar?jsx("img",{src:z.avatar,alt:z.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:b("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",m.includes(z.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:z.name.charAt(0).toUpperCase()}),jsx("span",{children:z.name.split(" ")[0]})]},z.id))})}),O&&jsx("div",{className:b("px-3 pb-3 pt-0","border-t",H?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:b("block text-[10px] uppercase tracking-wide mb-1",H?"text-gray-500":"text-gray-400"),children:te.startDate}),jsx("input",{type:"date",value:f,onChange:z=>v(z.target.value),className:b("w-full px-2 py-1.5 rounded text-xs border",H?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:b("block text-[10px] uppercase tracking-wide mb-1",H?"text-gray-500":"text-gray-400"),children:te.endDate}),jsx("input",{type:"date",value:g,onChange:z=>k(z.target.value),className:b("w-full px-2 py-1.5 rounded text-xs border",H?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),T&&jsx("div",{className:b("px-3 pb-3 pt-0","border-t",H?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(z=>jsx("button",{onClick:()=>S(x===z?"":z),className:b("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",x===z?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[z]} text-white`:H?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:te[z]},z))})})]}):jsxs("button",{onClick:()=>u(true),disabled:n,className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",H?"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 No=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(vr,{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 md(e={}){return new No(e)}var ro=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 ks(e,t){let a=r=>jsx(ro,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Cs({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:n,onPredictRisks:c,onOpenAIUsage:p,shortcut:l="k",className:u=""}){let[d,i]=useState(false),[h,C]=useState(""),[m,y]=useState("home"),[f,v]=useState(""),[g,k]=useState("");useEffect(()=>{let w=O=>{(O.metaKey||O.ctrlKey)&&O.key===l&&(O.preventDefault(),i(M=>!M)),O.key==="Escape"&&(i(false),y("home"),C(""));};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[l]),useEffect(()=>{d||(y("home"),C(""),v(""),k(""));},[d]);let x=useCallback(()=>{i(false);},[]),S=useCallback(w=>{let[O,M]=w.split(":");switch(O){case "create-card":y("create-card");break;case "create-card-in":v(M||"");break;case "navigate":M?(a?.(M),x()):y("navigate");break;case "search":r?.(h),x();break;case "priority":y("priority");break;case "set-priority":g&&M&&(o?.(g,M),x());break;case "assign":y("assign");break;case "assign-user":g&&M&&(s?.(g,M),x());break;case "ai":y("ai");break;case "ai-generate-plan":n?.(),x();break;case "ai-predict-risks":c?.(),x();break;case "ai-usage":p?.(),x();break;case "back":y("home");break;}},[h,g,t,a,r,o,s,n,c,p,x]),L=useCallback(()=>{f&&h.trim()&&(t?.(f,h.trim()),x());},[f,h,t,x]);return d?jsx(pt,{children:jsx("div",{className:"command-palette-overlay",onClick:x,children:jsx("div",{className:`command-palette ${u}`,onClick:w=>w.stopPropagation(),children:jsxs(Command,{value:h,onValueChange:C,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:m==="create-card"&&f?"Type card title and press Enter...":m==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:w=>{w.key==="Enter"&&m==="create-card"&&f&&L();}}),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."}),m==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:S,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:S,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:S,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:S,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(w=>jsxs(Command.Item,{value:`navigate:${w.id}`,onSelect:S,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:w.priority==="URGENT"?"#EF4444":w.priority==="HIGH"?"#F59E0B":w.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:w.title}),w.labels&&w.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:w.labels.slice(0,2).map(O=>jsx("span",{className:"command-palette-item-label",children:O},O))})]},w.id))})]}),m==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:S,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(w=>jsxs(Command.Item,{value:`create-card-in:${w.id}`,onSelect:S,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:w.title}),jsxs("div",{className:"command-palette-item-count",children:[w.cardIds.length," cards"]})]},w.id))})]}),m==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:S,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(w=>{let O=e.columns.find(M=>M.id===w.columnId);return jsxs(Command.Item,{value:`navigate:${w.id}`,onSelect:S,className:"command-palette-item",keywords:[w.title,w.description||"",...w.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:w.priority==="URGENT"?"#EF4444":w.priority==="HIGH"?"#F59E0B":w.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:w.title}),jsx("div",{className:"command-palette-item-meta",children:O?.title})]}),w.labels&&w.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:w.labels.slice(0,2).map(M=>jsx("span",{className:"command-palette-item-label",children:M},M))})]},w.id)})})]}),m==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:S,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:S,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:S,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:S,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 gd(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;
@@ -16,7 +16,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
16
16
  max-height: 92vh !important;
17
17
  object-fit: contain !important;
18
18
  cursor: default !important;
19
- `,c.onclick=d=>d.stopPropagation();let m=document.createElement("div");m.className="attachment-lightbox-hint",m.textContent="Click anywhere or press ESC to close",m.style.cssText=`
19
+ `,c.onclick=d=>d.stopPropagation();let p=document.createElement("div");p.className="attachment-lightbox-hint",p.textContent="Click anywhere or press ESC to close",p.style.cssText=`
20
20
  position: absolute !important;
21
21
  bottom: 24px !important;
22
22
  left: 50% !important;
@@ -34,15 +34,15 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
34
34
  padding: 8px 12px !important;
35
35
  background: rgba(0, 0, 0, 0.4) !important;
36
36
  border-radius: 20px !important;
37
- `,d.onclick=C=>C.stopPropagation(),a.forEach((C,p)=>{let y=document.createElement("button");y.className=`attachment-lightbox-dot ${p===r?"active":""}`,y.style.cssText=`
37
+ `,d.onclick=C=>C.stopPropagation(),a.forEach((C,m)=>{let y=document.createElement("button");y.className=`attachment-lightbox-dot ${m===r?"active":""}`,y.style.cssText=`
38
38
  width: 8px !important;
39
39
  height: 8px !important;
40
40
  border-radius: 50% !important;
41
- background: ${p===r?"white":"rgba(255, 255, 255, 0.3)"} !important;
41
+ background: ${m===r?"white":"rgba(255, 255, 255, 0.3)"} !important;
42
42
  border: none !important;
43
43
  padding: 0 !important;
44
44
  cursor: pointer !important;
45
- `,y.onclick=f=>{f.stopPropagation(),l(),o(p);},d.appendChild(y);});let i=document.createElement("button");i.className="attachment-lightbox-nav-area attachment-lightbox-nav-prev",i.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M15 18L9 12L15 6" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',i.style.cssText=`
45
+ `,y.onclick=f=>{f.stopPropagation(),l(),o(m);},d.appendChild(y);});let i=document.createElement("button");i.className="attachment-lightbox-nav-area attachment-lightbox-nav-prev",i.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M15 18L9 12L15 6" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',i.style.cssText=`
46
46
  position: absolute !important;
47
47
  left: 0 !important;
48
48
  top: 0 !important;
@@ -55,7 +55,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
55
55
  border: none !important;
56
56
  cursor: pointer !important;
57
57
  opacity: 0.5 !important;
58
- `,i.onmouseenter=()=>{i.style.opacity="1";},i.onmouseleave=()=>{i.style.opacity="0.5";},i.onclick=C=>{C.stopPropagation();let p=r>0?r-1:a.length-1;l(),o(p);};let h=document.createElement("button");h.className="attachment-lightbox-nav-area attachment-lightbox-nav-next",h.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M9 18L15 12L9 6" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',h.style.cssText=`
58
+ `,i.onmouseenter=()=>{i.style.opacity="1";},i.onmouseleave=()=>{i.style.opacity="0.5";},i.onclick=C=>{C.stopPropagation();let m=r>0?r-1:a.length-1;l(),o(m);};let h=document.createElement("button");h.className="attachment-lightbox-nav-area attachment-lightbox-nav-next",h.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M9 18L15 12L9 6" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',h.style.cssText=`
59
59
  position: absolute !important;
60
60
  right: 0 !important;
61
61
  top: 0 !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
- `,h.onmouseenter=()=>{h.style.opacity="1";},h.onmouseleave=()=>{h.style.opacity="0.5";},h.onclick=C=>{C.stopPropagation();let p=r<a.length-1?r+1:0;l(),o(p);},n.appendChild(d),n.appendChild(i),n.appendChild(h);}n.appendChild(c),n.appendChild(m),document.body.appendChild(n),setTimeout(()=>{m.style.transition="opacity 0.5s ease",m.style.opacity="0";},2e3);}function Pu(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 Mu(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 Ns(e){return e.startsWith("image/")}function rr({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[n,c]=useState(false),[m,l]=useState(false),[u,d]=useState(null),i=useRef(null),h=useRef(e);h.current=e;let C=useCallback((w,z)=>{z.preventDefault(),z.stopPropagation();let P=h.current.filter(R=>Ns(R.type)),T=P.findIndex(R=>R.id===w.id),G=R=>{let q=h.current.filter(xe=>Ns(xe.type)),te=q[R];te&&gd(te.url,te.name,q,R,G);};gd(w.url,w.name,P,T,G);},[]),p=useCallback(w=>{let z=[],P=[];return e.length+w.length>s?(P.push(`Maximum ${s} files allowed`),{valid:z,errors:P}):(w.forEach(T=>{if(T.size/1048576>r){P.push(`${T.name} is too large (max ${r}MB)`);return}if(o&&!o.some(R=>T.type.match(R))){P.push(`${T.name} has invalid file type`);return}z.push(T);}),{valid:z,errors:P})},[e.length,s,r,o]),y=useCallback(async w=>{let{valid:z,errors:P}=p(w);if(P.length>0){d(P.join(", ")),setTimeout(()=>d(null),5e3);return}if(z.length!==0){l(true),d(null);try{await t?.(z);}catch(T){d(T instanceof Error?T.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{l(false);}}},[p,t]),f=useCallback(w=>{w.preventDefault(),w.stopPropagation(),c(true);},[]),v=useCallback(w=>{w.preventDefault(),w.stopPropagation(),c(false);},[]),g=useCallback(w=>{w.preventDefault(),w.stopPropagation();},[]),k=useCallback(w=>{w.preventDefault(),w.stopPropagation(),c(false);let z=Array.from(w.dataTransfer.files);y(z);},[y]),x=useCallback(w=>{let z=w.target.files?Array.from(w.target.files):[];y(z),i.current&&(i.current.value="");},[y]),D=useCallback(()=>{i.current?.click();},[]),B=useCallback(w=>{confirm("Are you sure you want to delete this attachment?")&&a?.(w);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${n?"dragging":""} ${m?"uploading":""}`,onDragEnter:f,onDragLeave:v,onDragOver:g,onDrop:k,onClick:D,children:[jsx("input",{ref:i,type:"file",multiple:true,onChange:x,style:{display:"none"},accept:o?.join(",")}),jsx("div",{className:"attachment-dropzone-content",children:m?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"]})]})})]}),u&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:u})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(w=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Ns(w.type)&&w.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:z=>C(w,z),title:"Click to view full size",children:[jsx("img",{src:w.thumbnailUrl||w.url,alt:w.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:Mu(w.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:w.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:w.name,children:w.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:Pu(w.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(w.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>B(w.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"})})})]},w.id))})]})}function Ds({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],aiInsights:m=[],attachments:l=[],onAddComment:u,onDeleteComment:d,onUploadAttachments:i,onDeleteAttachment:h,onSuggestAssignee:C,onGenerateSubtasks:p,onEstimateEffort:y,currentUserId:f="user-1"}){let[v,g]=useState("details"),[k,x]=useState(false),[D,B]=useState({}),[w,z]=useState(""),[P,T]=useState(false),[G,R]=useState({});if(!t||!e)return null;let q=useCallback(()=>{x(false),B({}),g("details"),z(""),R({}),a();},[a]),te=useCallback(()=>{r&&Object.keys(D).length>0&&(r(e.id,D),B({}),x(false));},[e.id,D,r]),xe=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),q());},[e.id,o,q]),Ae=useCallback(()=>{u&&w.trim()&&(u(e.id,w.trim()),z(""));},[e.id,w,u]),ze=useCallback(async()=>{if(C){T(true);try{let F=await C(e);R(X=>({...X,assignees:F}));}catch(F){console.error("Failed to suggest assignee:",F);}finally{T(false);}}},[e,C]),le=useCallback(async()=>{if(p){T(true);try{let F=await p(e);R(X=>({...X,subtasks:F}));}catch(F){console.error("Failed to generate subtasks:",F);}finally{T(false);}}},[e,p]),O=useCallback(async()=>{if(y){T(true);try{let F=await y(e);R(X=>({...X,effort:F}));}catch(F){console.error("Failed to estimate effort:",F);}finally{T(false);}}},[e,y]),L={...e,...D},H=s.filter(F=>L.assignedUserIds?.includes(F.id));return jsx(mt,{children:jsx("div",{className:"card-detail-overlay",onClick:q,children:jsxs("div",{className:"card-detail-modal",onClick:F=>F.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:L.priority==="URGENT"?"#EF4444":L.priority==="HIGH"?"#F59E0B":L.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),k?jsx("input",{type:"text",value:D.title??L.title,onChange:F=>B({...D,title:F.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:L.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[k?jsxs(Fragment,{children:[jsx("button",{onClick:te,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{x(false),B({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>x(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:xe,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:q,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:()=>g("details"),className:`card-detail-tab ${v==="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:()=>g("comments"),className:`card-detail-tab ${v==="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:()=>g("activity"),className:`card-detail-tab ${v==="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:()=>g("attachments"),className:`card-detail-tab ${v==="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",l.length>0&&jsx("span",{className:"card-detail-tab-badge",children:l.length})]}),jsxs("button",{onClick:()=>g("ai"),className:`card-detail-tab ${v==="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:[v==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),k?jsx("textarea",{value:D.description??L.description??"",onChange:F=>B({...D,description:F.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:L.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),k?jsx("select",{multiple:true,value:D.assignedUserIds??L.assignedUserIds??[],onChange:F=>{let X=Array.from(F.target.selectedOptions,Q=>Q.value);B({...D,assignedUserIds:X});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(F=>jsx("option",{value:F.id,children:F.name},F.id))}):jsx("div",{className:"card-detail-users",children:H.length>0?H.map(F=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:F.color},children:F.initials}),jsx("span",{children:F.name})]},F.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),k?jsxs("select",{value:D.priority??L.priority??"",onChange:F=>B({...D,priority:F.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:L.priority==="URGENT"?"#EF4444":L.priority==="HIGH"?"#F59E0B":L.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:L.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:L.labels&&L.labels.length>0?L.labels.map(F=>jsx("span",{className:"card-detail-label-tag",children:F},F)):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"}),k?jsx("input",{type:"date",value:D.startDate?new Date(D.startDate).toISOString().split("T")[0]:L.startDate?new Date(L.startDate).toISOString().split("T")[0]:"",onChange:F=>B({...D,startDate:F.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:L.startDate?new Date(L.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),k?jsx("input",{type:"date",value:D.endDate?new Date(D.endDate).toISOString().split("T")[0]:L.endDate?new Date(L.endDate).toISOString().split("T")[0]:"",onChange:F=>B({...D,endDate:F.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:L.endDate?new Date(L.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),k?jsx("input",{type:"number",min:"0",step:"0.5",value:D.estimatedTime??L.estimatedTime??"",onChange:F=>B({...D,estimatedTime:F.target.value?parseFloat(F.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:L.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:L.dependencies&&L.dependencies.length>0?L.dependencies.map(F=>{let X=typeof F=="string"?F:F.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",X.slice(-4)]},X)}):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:L.createdAt?new Date(L.createdAt).toLocaleString():"Unknown"})]})]}),v==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:w,onChange:F=>z(F.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:Ae,disabled:!w.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(F=>{let X=s.find(Q=>Q.id===F.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:[X&&jsx("div",{className:"card-detail-user-avatar",style:{background:X.color},children:X.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:X?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(F.createdAt).toLocaleString()})]})]}),d&&jsx("button",{onClick:()=>d(F.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:F.content})]},F.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"})]})})]}),v==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(F=>{let X=s.find(Q=>Q.id===F.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[F.type.includes("CREATED")&&"\u2795",F.type.includes("UPDATED")&&"\u270F\uFE0F",F.type.includes("MOVED")&&"\u27A1\uFE0F",F.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",F.type.includes("COMMENT")&&"\u{1F4AC}",F.type.includes("ASSIGNED")&&"\u{1F464}",F.type.includes("PRIORITY")&&"\u{1F3AF}",F.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",F.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:X?.name||"Unknown"})," ",F.type.replace(/_/g," ").toLowerCase(),F.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:F.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(F.timestamp).toLocaleString()})]})]},F.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"})]})}),v==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx(rr,{cardId:e.id,attachments:l,onUpload:i?F=>i(e.id,F):void 0,onDelete:h,currentUserId:f,maxSizeMB:10,maxFiles:20})}),v==="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:ze,disabled:P||!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("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:le,disabled:P||!p,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:O,disabled:P||!y,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"]})]}),G.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),G.assignees.map((F,X)=>{let Q=s.find(U=>U.id===F.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:F.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(F.confidence*100).toFixed(0),"%"]})]})]},X)})]}),G.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),G.subtasks.map((F,X)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:F.title}),F.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:F.description}),F.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",F.estimatedTime,"h"]})]},X))]}),G.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:[G.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(G.effort.confidence*100).toFixed(0),"%"]})]})]}),m.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),m.map(F=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${F.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:F.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:F.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:F.description}),F.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",F.suggestedAction]})]},F.id))]}),!G.assignees&&!G.subtasks&&!G.effort&&m.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 So({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:n=""}){let[c,m]=useState({top:0,left:0}),l=useRef(null),u=useCallback(()=>{if(!e.current)return {top:0,left:0};let d=e.current.getBoundingClientRect(),i=window.innerHeight,h=window.innerWidth,C=4,p=d.left;p+o>h-10&&(p=h-o-10),p<10&&(p=10);let y=i-d.bottom,f=d.top,v;return y>=s+C?v=d.bottom+C:f>=s+C?v=d.top-s-C:y>=f?v=d.bottom+C:v=Math.max(10,d.top-s-C),{top:v,left:p}},[e,o,s]);return useEffect(()=>{t&&m(u());},[t,u]),useEffect(()=>{if(!t)return;let d=h=>{let C=h.target;l.current&&!l.current.contains(C)&&e.current&&!e.current.contains(C)&&a();},i=setTimeout(()=>{document.addEventListener("mousedown",d);},0);return ()=>{clearTimeout(i),document.removeEventListener("mousedown",d);}},[t,a,e]),useEffect(()=>{if(!t)return;let d=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),a());};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,a]),t?jsx(mt,{children:jsx("div",{ref:l,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 Ye={dark:{bgPrimary:"#1A1D21",bgSecondary:"#22262D",bgGrid:"#1E2126",bgWeekend:"rgba(59, 130, 246, 0.03)",border:"#334155",borderLight:"#2D3139",textPrimary:"#FFFFFF",textSecondary:"#CBD5E1",textTertiary:"#64748B",accent:"#3B82F6",accentHover:"#60A5FA",accentLight:"rgba(59, 130, 246, 0.12)",taskBarPrimary:"#3B82F6",taskBarProgress:"#2563EB",taskBarHandle:"#FFFFFF",dependency:"rgba(180, 185, 197, 0.25)",dependencyHover:"rgba(180, 185, 197, 0.45)",criticalPath:"#EF4444",criticalPathLight:"rgba(239, 68, 68, 0.12)",today:"#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:"rgba(75, 85, 99, 0.25)",dependencyHover:"rgba(75, 85, 99, 0.45)",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:"rgba(87, 83, 78, 0.25)",dependencyHover:"rgba(87, 83, 78, 0.4)",criticalPath:"#44403C",criticalPathLight:"rgba(68, 64, 60, 0.08)",today:"#1C1917",todayLight:"rgba(28, 25, 23, 0.06)",milestone:"#57534E",milestoneLight:"rgba(87, 83, 78, 0.08)",statusTodo:"#78716C",statusInProgress:"#292524",statusCompleted:"#15803D",hoverBg:"rgba(0, 0, 0, 0.035)",focusRing:"#292524"}};var zu=["LOW","MEDIUM","HIGH","URGENT"],Uu=["todo","in-progress","review","done"];function Ps({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],onAddComment:m,onDeleteComment:l,currentUser:u,onAIGenerateDescription:d,onAICreateSubtasks:i,onAIFindSimilar:h,availableColumns:C=[],availableLabels:p=[],availableTags:y=[],onCreateTag:f,onUploadCoverImage:v,unsplashAccessKey:g,theme:k,onSubtasksChange:x,attachments:D=[],onUploadAttachments:B,onDeleteAttachment:w}){let z=Zr(),P=k||z?.themeName||"dark",[T,G]=useState(e),[R,q]=useState(false),[te,xe]=useState(e?.subtasks||[]),[Ae,ze]=useState(false),[le,O]=useState(""),[L,H]=useState(""),[F,X]=useState("all"),[Q,U]=useState(false),[ke,Te]=useState(false),[Fe,ve]=useState(false),[et,Ie]=useState(false),[pt,it]=useState(false),[lt,tt]=useState(false),$=useRef(null),ne=useRef(null),re=useRef(null),we=useRef(null),Ne=useRef(null),at=useRef(null),wt=useRef(null),Le=useRef(null),he=useRef(null),Ee=useRef(null),St=useRef(null),gt=useRef(null);useEffect(()=>{e&&!T?(G({...e}),xe(e.subtasks||[])):e&&T&&e.id!==T.id&&(G({...e}),xe(e.subtasks||[]));},[e,T]),useEffect(()=>{let M=_=>{let pe=_.target;we.current&&!we.current.contains(pe)&&U(false),Ne.current&&!Ne.current.contains(pe)&&Te(false),at.current&&!at.current.contains(pe)&&ve(false),wt.current&&!wt.current.contains(pe)&&Ie(false);};if(Q||ke||Fe||et)return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[Q,ke,Fe,et]),useEffect(()=>{if(!t)return;let M=_=>{let pe=_.target,Ke=pe.tagName==="INPUT"||pe.tagName==="TEXTAREA"||pe.isContentEditable;if(_.key==="Escape"){_.preventDefault(),Q||ke||Fe||et||pt||lt?(U(false),Te(false),ve(false),Ie(false),it(false),tt(false)):Ke||a();return}if(Ke&&_.key!=="Escape")return;let Z=_.metaKey||_.ctrlKey;switch(_.key.toLowerCase()){case "s":_.preventDefault(),U(true);break;case "a":_.preventDefault(),ve(true);break;case "p":_.preventDefault(),Te(true);break;case "l":_.preventDefault(),Ie(true);break;case "d":Z||(_.preventDefault(),it(true),setTimeout(()=>Le.current?.focus(),0));break;case "e":Z||(_.preventDefault(),tt(true));break;case "i":_.preventDefault(),q(true),setTimeout(()=>ne.current?.focus(),0);break;case "t":_.preventDefault(),ze(true);break;case "c":_.preventDefault(),re.current?.focus();break}};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t,a,Q,ke,Fe,et,pt,lt]);let ta=useCallback(M=>{let _=M.currentTarget.textContent?.trim()||"";if(T&&_!==T.title){let pe={...T,title:_};G(pe),r?.(T.id,{title:_});}},[T,r]),sa=useCallback(M=>{M.key==="Enter"&&(M.preventDefault(),M.currentTarget.blur()),M.key==="Escape"&&(M.preventDefault(),M.currentTarget.textContent=T?.title||"",M.currentTarget.blur());},[T]),_e=useCallback(()=>{T&&e&&T.description!==e.description&&r?.(T.id,{description:T.description}),q(false);},[T,e,r]),He=useCallback(M=>{if(T){let _={...T,columnId:M};G(_),r?.(T.id,{columnId:M}),U(false);}},[T,r]),ia=useCallback(M=>{if(T){let _={...T,priority:M};G(_),r?.(T.id,{priority:M}),Te(false);}},[T,r]),fe=useCallback(M=>{if(T){let _=T.assignedUserIds||[],pe=_.includes(M)?_.filter(Z=>Z!==M):[..._,M],Ke={...T,assignedUserIds:pe};G(Ke),r?.(T.id,{assignedUserIds:pe});}},[T,r]),S=useCallback(M=>{if(T){let _=T.labels||[],pe=_.includes(M)?_.filter(Z=>Z!==M):[..._,M],Ke={...T,labels:pe};G(Ke),r?.(T.id,{labels:pe});}},[T,r]),J=useCallback(M=>{if(T){let _={...T,tags:M};G(_),r?.(T.id,{tags:M});}},[T,r]),ce=useCallback(M=>{if(T){let _=M.target.value,pe={...T,endDate:_};G(pe),r?.(T.id,{endDate:_}),it(false);}},[T,r]),De=useCallback(M=>{if(T){let _={...T,estimatedTime:parseFloat(M)||0};G(_),r?.(T.id,{estimatedTime:parseFloat(M)||0});}},[T,r]),Ue=useCallback(()=>{if(le.trim()&&T){let M={id:`subtask-${Date.now()}`,title:le.trim(),completed:false,createdAt:new Date},_=[...te,M];xe(_),O(""),ze(false),x?.(T.id,_);}},[le,te,T,x]),Re=useCallback(M=>{let _=te.map(pe=>pe.id===M?{...pe,completed:!pe.completed,updatedAt:new Date}:pe);xe(_),T&&x?.(T.id,_);},[te,T,x]),Be=useCallback(M=>{let _=te.filter(pe=>pe.id!==M);xe(_),T&&x?.(T.id,_);},[te,T,x]),Je=useCallback(()=>{L.trim()&&T&&m&&(m(T.id,L.trim()),H(""));},[L,T,m]),dt=useCallback(M=>{(M.metaKey||M.ctrlKey)&&M.key==="Enter"&&(M.preventDefault(),Je());},[Je]),K=M=>jsx(Bu,{remarkPlugins:[Ru],rehypePlugins:[Ou],components:{a:({node:_,...pe})=>jsx("a",{...pe,target:"_blank",rel:"noopener noreferrer"})},children:M}),ae=c.filter(M=>F==="comments"?M.type.includes("COMMENT"):F==="history"?!M.type.includes("COMMENT"):true);if(!t||!e)return null;let Pe=T||e,We=s.filter(M=>Pe.assignedUserIds?.includes(M.id)),N=te.filter(M=>M.completed).length;return jsx(mt,{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:M=>M.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":P,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:$,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:ta,onKeyDown:sa,children:Pe.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:we,children:[jsxs("button",{ref:he,className:"modal-v2-field",onClick:()=>U(!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:Pe.columnId||"No status"})]}),jsx(So,{triggerRef:he,isOpen:Q,onClose:()=>U(false),width:250,estimatedHeight:200,children:(C.length>0?C:Uu.map(M=>({id:M,title:M}))).map(M=>jsx("button",{className:`modal-v2-popover-item ${Pe.columnId===M.id?"active":""}`,onClick:()=>He(M.id),children:M.title},M.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:at,children:[jsxs("button",{ref:Ee,className:"modal-v2-field",onClick:()=>ve(!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:We.length>0?jsx("div",{className:"modal-v2-avatars",children:We.map(M=>jsx("div",{className:"modal-v2-avatar",style:{background:M.color},title:M.name,children:M.initials},M.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(So,{triggerRef:Ee,isOpen:Fe,onClose:()=>ve(false),width:280,estimatedHeight:300,children:s.map(M=>jsxs("button",{className:`modal-v2-popover-item ${Pe.assignedUserIds?.includes(M.id)?"active":""}`,onClick:()=>fe(M.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:M.color},children:M.initials}),M.name,Pe.assignedUserIds?.includes(M.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"})})]},M.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ne,children:[jsxs("button",{ref:St,className:"modal-v2-field",onClick:()=>Te(!ke),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:Pe.priority||"None"})]}),jsxs(So,{triggerRef:St,isOpen:ke,onClose:()=>Te(false),width:180,estimatedHeight:220,children:[zu.map(M=>jsx("button",{className:`modal-v2-popover-item priority-${M.toLowerCase()} ${Pe.priority===M?"active":""}`,onClick:()=>ia(M),children:M},M)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>ia(""),children:"None"})]})]}),y.length>0||f?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(Qa,{selectedTags:Pe.tags||[],availableTags:y,onChange:J,onCreateTag:f,theme:Ye[P]||Ye.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:wt,children:[jsxs("button",{ref:gt,className:"modal-v2-field",onClick:()=>Ie(!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:Pe.labels&&Pe.labels.length>0?jsx("span",{children:Pe.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(So,{triggerRef:gt,isOpen:et,onClose:()=>Ie(false),width:220,estimatedHeight:200,children:(p.length>0?p:["Bug","Feature","Enhancement","Documentation"]).map(M=>jsxs("button",{className:`modal-v2-popover-item ${Pe.labels?.includes(M)?"active":""}`,onClick:()=>S(M),children:[M,Pe.labels?.includes(M)&&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"})})]},M))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{it(!pt),setTimeout(()=>Le.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:Pe.endDate?new Date(Pe.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Le,type:"date",value:typeof Pe.endDate=="string"?Pe.endDate.split("T")[0]:Pe.endDate?(()=>{let M=new Date(Pe.endDate),_=M.getUTCFullYear(),pe=String(M.getUTCMonth()+1).padStart(2,"0"),Ke=String(M.getUTCDate()).padStart(2,"0");return `${_}-${pe}-${Ke}`})():"",onChange:ce,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>tt(!lt),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:Pe.estimatedTime?`${Pe.estimatedTime}h`:"Not set"})]}),lt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:Pe.estimatedTime||"",onChange:M=>De(M.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>tt(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"})]}),R?jsx("textarea",{className:"modal-v2-textarea",value:Pe.description||"",onChange:M=>{if(T){let _={...T,description:M.target.value};G(_);}},onBlur:_e,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>q(true),children:Pe.description?jsx("div",{className:"modal-v2-markdown",children:K(Pe.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:[N,"/",te.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>ze(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(M=>jsxs("div",{className:`modal-v2-subtask ${M.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>Re(M.id),children:M.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:M.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>Be(M.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"})]})})]},M.id)),Ae&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:le,onChange:M=>O(M.target.value),onKeyDown:M=>{M.key==="Enter"&&Ue(),M.key==="Escape"&&(ze(false),O(""));},onBlur:Ue,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(B||D.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"}),D.length>0&&jsx("span",{className:"modal-v2-count",children:D.length})]}),jsx(rr,{cardId:Pe.id,attachments:D,onUpload:B?M=>B(Pe.id,M):void 0,onDelete:w,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 ${F==="all"?"active":""}`,onClick:()=>X("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${F==="comments"?"active":""}`,onClick:()=>X("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${F==="history"?"active":""}`,onClick:()=>X("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[u&&jsx("div",{className:"modal-v2-avatar",style:{background:u.color},children:u.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:re,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:L,onChange:M=>H(M.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:Je,disabled:!L.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[ae.map(M=>{let _=s.find(Ke=>Ke.id===M.userId);if(M.type.includes("COMMENT")){let Ke=n.find(Z=>Z.id===M.metadata?.commentId);return Ke?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[_&&jsx("div",{className:"modal-v2-avatar",style:{background:_.color},children:_.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:_?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(M.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:Ke.content})]})]},M.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[M.type.includes("CREATED")&&"\u2795",M.type.includes("UPDATED")&&"\u270F\uFE0F",M.type.includes("MOVED")&&"\u27A1\uFE0F",M.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",M.type.includes("ASSIGNED")&&"\u{1F464}",M.type.includes("PRIORITY")&&"\u{1F3AF}",M.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:_?.name||"Unknown"})," ",M.type.replace(/_/g," ").toLowerCase(),M.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:M.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(M.timestamp).toLocaleString()})]})]},M.id)}),ae.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function Yu({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 As({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,m)=>c+m.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(Yu,{})}),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 rg({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 Fs({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,m=s>0?(s-n)/s*100:0,l=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(rg,{})}),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:l?"#10B981":"#EF4444",fill:l?"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:l?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:l?"#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:m>=50?"#10B981":"#F59E0B"},children:[m.toFixed(0),"%"]})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Remaining"}),jsx("span",{className:"chart-stat-value",style:{color:l?"#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:l?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:l?"#10B981":"#EF4444"},children:l?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var mg={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Cd=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function ug({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)),m=t+n*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:c,y:m,fill:"white",textAnchor:c>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Td({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 Is({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((m,l)=>m+l.value,0),n=e.map(m=>({...m,totalValue:s,color:m.color||mg[m.name]||Cd[e.indexOf(m)%Cd.length]})),c=n.map(m=>m.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?ug:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:n.map((m,l)=>jsx(Cell,{fill:c[l]},`cell-${l}`))}),jsx(Tooltip,{content:jsx(Td,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(m,l)=>{let u=l.payload,d=s>0?(u.value/s*100).toFixed(0):"0";return `${m} (${u.value} - ${d}%)`}})]}):jsxs(BarChart,{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(Td,{})}),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((m,l)=>jsx(Cell,{fill:c[l]},`cell-${l}`))})]})}),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((m,l)=>l.value>m.value?l:m).name})]})]})]})}var pn=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[n,c]=useState(false),[m,l]=useState(false),[u,d]=useState(false),[i,h]=useState(false);if(e.length===0)return null;let C=e.map(k=>k.id),p=k=>{r.onBulkUpdate?.(C,{priority:k}),c(false);},y=k=>{r.onBulkMove?.(C,k),l(false),a();},f=k=>{r.onBulkUpdate?.(C,{assignedUserIds:k}),d(false);},v=k=>{let x=new Set;e.forEach(B=>{B.labels?.forEach(w=>x.add(w));});let D=Array.from(new Set([...x,...k]));r.onBulkUpdate?.(C,{labels:D}),h(false);},g=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(C),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(k=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>p(k),children:[jsx("span",{className:b("asakaa-priority-dot",k==="LOW"&&"bg-asakaa-priority-low",k==="MEDIUM"&&"bg-asakaa-priority-medium",k==="HIGH"&&"bg-asakaa-priority-high",k==="URGENT"&&"bg-asakaa-priority-urgent")}),k]},k))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>l(!m),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),m&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(k=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>y(k.id),children:k.title},k.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>d(!u),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),u&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(k=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>f([k.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:k.color},children:k.initials}),k.name]},k.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>h(!i),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),i&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(k=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>v([k]),children:k},k))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:g,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"})})]})]})})});pn.displayName="BulkOperationsToolbar";function yg(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,n,c,m,l;switch(t){case "assignee":let u=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);u.length>0?u.forEach(h=>{let C=a?.find(p=>p.id===h);n=`assignee-${h}`,c=C?.name||`User ${h}`,m=C?.color,l=C?.avatar,r.has(n)||r.set(n,{id:n,title:c,groupValue:h,cardIds:[],color:m,icon:l}),r.get(n).cardIds.push(o.id);}):(n="assignee-unassigned",c="Unassigned",m="#6b7280",l="\u{1F464}",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:m,icon:l}),r.get(n).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",n=`priority-${s}`;let i={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=i.title,m=i.color,r.has(n)||r.set(n,{id:n,title:c,groupValue:s,cardIds:[],color:m}),r.get(n).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(h=>{n=`label-${h}`,c=h,m="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:h,cardIds:[],color:m}),r.get(n).cardIds.push(o.id);}):(n="label-none",c="No Labels",m="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:m}),r.get(n).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function Ls({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,n]=useState(new Set),c=useMemo(()=>yg(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),m=useCallback(l=>{n(u=>{let d=new Set(u);return d.has(l)?d.delete(l):d.add(l),d});},[]);return t.groupBy==="none"||c.length===0?jsx(vr,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:b("asakaa-swimlane-view",o),children:[c.map(l=>{let u=s.has(l.id),d=e.cards.filter(h=>l.cardIds.includes(h.id)),i={...e,cards:d};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&&m(l.id),style:{borderLeft:l.color?`4px solid ${l.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[l.icon&&jsx("span",{className:"text-2xl leading-none",children:l.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:l.color},children:l.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",l.cardIds.length," ",l.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":u?"Expand lane":"Collapse lane",children:u?"\u25B6":"\u25BC"})]}),!u&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(vr,{board:i,callbacks:r,availableUsers:a})})]},l.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 Bs=[{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 Rs({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null),c=Bs.find(l=>l.value===e)||Bs[0];useEffect(()=>{function l(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]);let m=l=>{t(l),o(false);};return jsxs("div",{className:b("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:b("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:Bs.map(l=>jsxs("button",{onClick:()=>m(l.value),className:b("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===l.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:l.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:l.label}),e===l.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:l.description})]})]},l.value))})]})]})}var Eo=[{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 kg(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(l=>e.key===l||e.code===l))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,m=o.meta?e.metaKey:true;return s&&n&&c&&m}function Pd(e={}){let{shortcuts:t=Eo,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(m=>{o.current=[...o.current,m];},[]),c=useCallback(m=>{o.current=o.current.filter(l=>l.action!==m);},[]);return useEffect(()=>{function m(l){if(!s.current)return;let u=l.target;if(!((u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable)&&l.key!=="Escape"&&!l.ctrlKey&&!l.metaKey)){for(let d of o.current)if(kg(l,d)){r&&l.preventDefault();let i=new CustomEvent("keyboard-action",{detail:d.action,bubbles:true,cancelable:true});window.dispatchEvent(i);break}}}return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r]),{registerShortcut:n,unregisterShortcut:c,isEnabled:a}}function Cg(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function Tg(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 Ng(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=Tg(e),r=t?Cg(t):"";return a?`${a} + ${r}`:r}function Dg(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 Os({shortcuts:e=Eo,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function c(m){m.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,a]),!o||!t)return null;let n=Dg(e);return jsxs("div",{className:b("fixed inset-0 z-[9999] flex items-center justify-center",r),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-3xl w-full mx-4 max-h-[80vh] overflow-hidden",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:"\u2328\uFE0F"}),"Keyboard Shortcuts"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Speed up your workflow with these shortcuts"})]}),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"})]}),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,m])=>m.length===0?null:jsxs("div",{children:[jsxs("h3",{className:"text-lg font-semibold text-white/90 mb-4 flex items-center gap-2",children:[jsx("span",{className:"w-1 h-5 bg-blue-500 rounded-full"}),c]}),jsx("div",{className:"space-y-3",children:m.map(l=>jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-lg bg-white/5 hover:bg-white/10 transition-colors",children:[jsx("span",{className:"text-sm text-white/80",children:l.description}),jsx("kbd",{className:"px-3 py-1.5 bg-gradient-to-br from-gray-700 to-gray-800 border border-white/20 rounded-md text-xs font-mono text-white/90 shadow-lg whitespace-nowrap",children:Ng(l)})]},l.action))})]},c))})}),jsx("div",{className:"px-6 py-4 border-t border-white/10 bg-white/5",children:jsxs("p",{className:"text-xs text-white/50 text-center",children:["Press ",jsx("kbd",{className:"px-2 py-0.5 bg-white/10 rounded text-white/70",children:"?"})," to toggle this help panel"]})})]})]})}var zs=[{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
+ `,h.onmouseenter=()=>{h.style.opacity="1";},h.onmouseleave=()=>{h.style.opacity="0.5";},h.onclick=C=>{C.stopPropagation();let m=r<a.length-1?r+1:0;l(),o(m);},n.appendChild(d),n.appendChild(i),n.appendChild(h);}n.appendChild(c),n.appendChild(p),document.body.appendChild(n),setTimeout(()=>{p.style.transition="opacity 0.5s ease",p.style.opacity="0";},2e3);}function Pu(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 Mu(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 Ns(e){return e.startsWith("image/")}function rr({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[n,c]=useState(false),[p,l]=useState(false),[u,d]=useState(null),i=useRef(null),h=useRef(e);h.current=e;let C=useCallback((w,O)=>{O.preventDefault(),O.stopPropagation();let M=h.current.filter(B=>Ns(B.type)),T=M.findIndex(B=>B.id===w.id),_=B=>{let J=h.current.filter(be=>Ns(be.type)),te=J[B];te&&gd(te.url,te.name,J,B,_);};gd(w.url,w.name,M,T,_);},[]),m=useCallback(w=>{let O=[],M=[];return e.length+w.length>s?(M.push(`Maximum ${s} files allowed`),{valid:O,errors:M}):(w.forEach(T=>{if(T.size/1048576>r){M.push(`${T.name} is too large (max ${r}MB)`);return}if(o&&!o.some(B=>T.type.match(B))){M.push(`${T.name} has invalid file type`);return}O.push(T);}),{valid:O,errors:M})},[e.length,s,r,o]),y=useCallback(async w=>{let{valid:O,errors:M}=m(w);if(M.length>0){d(M.join(", ")),setTimeout(()=>d(null),5e3);return}if(O.length!==0){l(true),d(null);try{await t?.(O);}catch(T){d(T instanceof Error?T.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{l(false);}}},[m,t]),f=useCallback(w=>{w.preventDefault(),w.stopPropagation(),c(true);},[]),v=useCallback(w=>{w.preventDefault(),w.stopPropagation(),c(false);},[]),g=useCallback(w=>{w.preventDefault(),w.stopPropagation();},[]),k=useCallback(w=>{w.preventDefault(),w.stopPropagation(),c(false);let O=Array.from(w.dataTransfer.files);y(O);},[y]),x=useCallback(w=>{let O=w.target.files?Array.from(w.target.files):[];y(O),i.current&&(i.current.value="");},[y]),S=useCallback(()=>{i.current?.click();},[]),L=useCallback(w=>{confirm("Are you sure you want to delete this attachment?")&&a?.(w);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${n?"dragging":""} ${p?"uploading":""}`,onDragEnter:f,onDragLeave:v,onDragOver:g,onDrop:k,onClick:S,children:[jsx("input",{ref:i,type:"file",multiple:true,onChange:x,style:{display:"none"},accept:o?.join(",")}),jsx("div",{className:"attachment-dropzone-content",children:p?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"]})]})})]}),u&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:u})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(w=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Ns(w.type)&&w.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:O=>C(w,O),title:"Click to view full size",children:[jsx("img",{src:w.thumbnailUrl||w.url,alt:w.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:Mu(w.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:w.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:w.name,children:w.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:Pu(w.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(w.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>L(w.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"})})})]},w.id))})]})}function Ds({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],aiInsights:p=[],attachments:l=[],onAddComment:u,onDeleteComment:d,onUploadAttachments:i,onDeleteAttachment:h,onSuggestAssignee:C,onGenerateSubtasks:m,onEstimateEffort:y,currentUserId:f="user-1"}){let[v,g]=useState("details"),[k,x]=useState(false),[S,L]=useState({}),[w,O]=useState(""),[M,T]=useState(false),[_,B]=useState({});if(!t||!e)return null;let J=useCallback(()=>{x(false),L({}),g("details"),O(""),B({}),a();},[a]),te=useCallback(()=>{r&&Object.keys(S).length>0&&(r(e.id,S),L({}),x(false));},[e.id,S,r]),be=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),J());},[e.id,o,J]),Fe=useCallback(()=>{u&&w.trim()&&(u(e.id,w.trim()),O(""));},[e.id,w,u]),Oe=useCallback(async()=>{if(C){T(true);try{let N=await C(e);B(j=>({...j,assignees:N}));}catch(N){console.error("Failed to suggest assignee:",N);}finally{T(false);}}},[e,C]),je=useCallback(async()=>{if(m){T(true);try{let N=await m(e);B(j=>({...j,subtasks:N}));}catch(N){console.error("Failed to generate subtasks:",N);}finally{T(false);}}},[e,m]),H=useCallback(async()=>{if(y){T(true);try{let N=await y(e);B(j=>({...j,effort:N}));}catch(N){console.error("Failed to estimate effort:",N);}finally{T(false);}}},[e,y]),z={...e,...S},W=s.filter(N=>z.assignedUserIds?.includes(N.id));return jsx(pt,{children:jsx("div",{className:"card-detail-overlay",onClick:J,children:jsxs("div",{className:"card-detail-modal",onClick:N=>N.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:z.priority==="URGENT"?"#EF4444":z.priority==="HIGH"?"#F59E0B":z.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),k?jsx("input",{type:"text",value:S.title??z.title,onChange:N=>L({...S,title:N.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:z.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[k?jsxs(Fragment,{children:[jsx("button",{onClick:te,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{x(false),L({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>x(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:be,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:()=>g("details"),className:`card-detail-tab ${v==="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:()=>g("comments"),className:`card-detail-tab ${v==="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:()=>g("activity"),className:`card-detail-tab ${v==="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:()=>g("attachments"),className:`card-detail-tab ${v==="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",l.length>0&&jsx("span",{className:"card-detail-tab-badge",children:l.length})]}),jsxs("button",{onClick:()=>g("ai"),className:`card-detail-tab ${v==="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:[v==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),k?jsx("textarea",{value:S.description??z.description??"",onChange:N=>L({...S,description:N.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:z.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),k?jsx("select",{multiple:true,value:S.assignedUserIds??z.assignedUserIds??[],onChange:N=>{let j=Array.from(N.target.selectedOptions,q=>q.value);L({...S,assignedUserIds:j});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(N=>jsx("option",{value:N.id,children:N.name},N.id))}):jsx("div",{className:"card-detail-users",children:W.length>0?W.map(N=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:N.color},children:N.initials}),jsx("span",{children:N.name})]},N.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),k?jsxs("select",{value:S.priority??z.priority??"",onChange:N=>L({...S,priority:N.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:z.priority==="URGENT"?"#EF4444":z.priority==="HIGH"?"#F59E0B":z.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:z.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:z.labels&&z.labels.length>0?z.labels.map(N=>jsx("span",{className:"card-detail-label-tag",children:N},N)):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"}),k?jsx("input",{type:"date",value:S.startDate?new Date(S.startDate).toISOString().split("T")[0]:z.startDate?new Date(z.startDate).toISOString().split("T")[0]:"",onChange:N=>L({...S,startDate:N.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:z.startDate?new Date(z.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),k?jsx("input",{type:"date",value:S.endDate?new Date(S.endDate).toISOString().split("T")[0]:z.endDate?new Date(z.endDate).toISOString().split("T")[0]:"",onChange:N=>L({...S,endDate:N.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:z.endDate?new Date(z.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),k?jsx("input",{type:"number",min:"0",step:"0.5",value:S.estimatedTime??z.estimatedTime??"",onChange:N=>L({...S,estimatedTime:N.target.value?parseFloat(N.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:z.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:z.dependencies&&z.dependencies.length>0?z.dependencies.map(N=>{let j=typeof N=="string"?N:N.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:z.createdAt?new Date(z.createdAt).toLocaleString():"Unknown"})]})]}),v==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:w,onChange:N=>O(N.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:Fe,disabled:!w.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(N=>{let j=s.find(q=>q.id===N.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(N.createdAt).toLocaleString()})]})]}),d&&jsx("button",{onClick:()=>d(N.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:N.content})]},N.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"})]})})]}),v==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(N=>{let j=s.find(q=>q.id===N.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[N.type.includes("CREATED")&&"\u2795",N.type.includes("UPDATED")&&"\u270F\uFE0F",N.type.includes("MOVED")&&"\u27A1\uFE0F",N.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",N.type.includes("COMMENT")&&"\u{1F4AC}",N.type.includes("ASSIGNED")&&"\u{1F464}",N.type.includes("PRIORITY")&&"\u{1F3AF}",N.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",N.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"})," ",N.type.replace(/_/g," ").toLowerCase(),N.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:N.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(N.timestamp).toLocaleString()})]})]},N.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"})]})}),v==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx(rr,{cardId:e.id,attachments:l,onUpload:i?N=>i(e.id,N):void 0,onDelete:h,currentUserId:f,maxSizeMB:10,maxFiles:20})}),v==="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:Oe,disabled:M||!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("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:je,disabled:M||!m,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:H,disabled:M||!y,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"]})]}),_.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),_.assignees.map((N,j)=>{let q=s.find(R=>R.id===N.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:N.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(N.confidence*100).toFixed(0),"%"]})]})]},j)})]}),_.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),_.subtasks.map((N,j)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:N.title}),N.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:N.description}),N.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",N.estimatedTime,"h"]})]},j))]}),_.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:[_.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(_.effort.confidence*100).toFixed(0),"%"]})]})]}),p.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),p.map(N=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${N.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:N.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:N.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:N.description}),N.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",N.suggestedAction]})]},N.id))]}),!_.assignees&&!_.subtasks&&!_.effort&&p.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 So({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:n=""}){let[c,p]=useState({top:0,left:0}),l=useRef(null),u=useCallback(()=>{if(!e.current)return {top:0,left:0};let d=e.current.getBoundingClientRect(),i=window.innerHeight,h=window.innerWidth,C=4,m=d.left;m+o>h-10&&(m=h-o-10),m<10&&(m=10);let y=i-d.bottom,f=d.top,v;return y>=s+C?v=d.bottom+C:f>=s+C?v=d.top-s-C:y>=f?v=d.bottom+C:v=Math.max(10,d.top-s-C),{top:v,left:m}},[e,o,s]);return useEffect(()=>{t&&p(u());},[t,u]),useEffect(()=>{if(!t)return;let d=h=>{let C=h.target;l.current&&!l.current.contains(C)&&e.current&&!e.current.contains(C)&&a();},i=setTimeout(()=>{document.addEventListener("mousedown",d);},0);return ()=>{clearTimeout(i),document.removeEventListener("mousedown",d);}},[t,a,e]),useEffect(()=>{if(!t)return;let d=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),a());};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,a]),t?jsx(pt,{children:jsx("div",{ref:l,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 qe={dark:{bgPrimary:"#1A1D21",bgSecondary:"#22262D",bgGrid:"#1E2126",bgWeekend:"rgba(59, 130, 246, 0.03)",border:"#334155",borderLight:"#2D3139",textPrimary:"#FFFFFF",textSecondary:"#CBD5E1",textTertiary:"#64748B",accent:"#3B82F6",accentHover:"#60A5FA",accentLight:"rgba(59, 130, 246, 0.12)",taskBarPrimary:"#3B82F6",taskBarProgress:"#2563EB",taskBarHandle:"#FFFFFF",dependency:"rgba(180, 185, 197, 0.25)",dependencyHover:"rgba(180, 185, 197, 0.45)",criticalPath:"#EF4444",criticalPathLight:"rgba(239, 68, 68, 0.12)",today:"#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:"rgba(75, 85, 99, 0.25)",dependencyHover:"rgba(75, 85, 99, 0.45)",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:"rgba(87, 83, 78, 0.25)",dependencyHover:"rgba(87, 83, 78, 0.4)",criticalPath:"#44403C",criticalPathLight:"rgba(68, 64, 60, 0.08)",today:"#1C1917",todayLight:"rgba(28, 25, 23, 0.06)",milestone:"#57534E",milestoneLight:"rgba(87, 83, 78, 0.08)",statusTodo:"#78716C",statusInProgress:"#292524",statusCompleted:"#15803D",hoverBg:"rgba(0, 0, 0, 0.035)",focusRing:"#292524"}};var zu=["LOW","MEDIUM","HIGH","URGENT"],Uu=["todo","in-progress","review","done"];function Ps({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:n=[],activities:c=[],onAddComment:p,onDeleteComment:l,currentUser:u,onAIGenerateDescription:d,onAICreateSubtasks:i,onAIFindSimilar:h,availableColumns:C=[],availableLabels:m=[],availableTags:y=[],onCreateTag:f,onUploadCoverImage:v,unsplashAccessKey:g,theme:k,onSubtasksChange:x,attachments:S=[],onUploadAttachments:L,onDeleteAttachment:w}){let O=Zr(),M=k||O?.themeName||"dark",[T,_]=useState(e),[B,J]=useState(false),[te,be]=useState(e?.subtasks||[]),[Fe,Oe]=useState(false),[je,H]=useState(""),[z,W]=useState(""),[N,j]=useState("all"),[q,R]=useState(false),[ie,ke]=useState(false),[Ee,ce]=useState(false),[Ke,Me]=useState(false),[at,lt]=useState(false),[dt,tt]=useState(false),U=useRef(null),ne=useRef(null),re=useRef(null),we=useRef(null),Te=useRef(null),rt=useRef(null),wt=useRef(null),Ie=useRef(null),ye=useRef(null),Se=useRef(null),St=useRef(null),gt=useRef(null);useEffect(()=>{e&&!T?(_({...e}),be(e.subtasks||[])):e&&T&&e.id!==T.id&&(_({...e}),be(e.subtasks||[]));},[e,T]),useEffect(()=>{let A=G=>{let pe=G.target;we.current&&!we.current.contains(pe)&&R(false),Te.current&&!Te.current.contains(pe)&&ke(false),rt.current&&!rt.current.contains(pe)&&ce(false),wt.current&&!wt.current.contains(pe)&&Me(false);};if(q||ie||Ee||Ke)return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[q,ie,Ee,Ke]),useEffect(()=>{if(!t)return;let A=G=>{let pe=G.target,Ye=pe.tagName==="INPUT"||pe.tagName==="TEXTAREA"||pe.isContentEditable;if(G.key==="Escape"){G.preventDefault(),q||ie||Ee||Ke||at||dt?(R(false),ke(false),ce(false),Me(false),lt(false),tt(false)):Ye||a();return}if(Ye&&G.key!=="Escape")return;let Q=G.metaKey||G.ctrlKey;switch(G.key.toLowerCase()){case "s":G.preventDefault(),R(true);break;case "a":G.preventDefault(),ce(true);break;case "p":G.preventDefault(),ke(true);break;case "l":G.preventDefault(),Me(true);break;case "d":Q||(G.preventDefault(),lt(true),setTimeout(()=>Ie.current?.focus(),0));break;case "e":Q||(G.preventDefault(),tt(true));break;case "i":G.preventDefault(),J(true),setTimeout(()=>ne.current?.focus(),0);break;case "t":G.preventDefault(),Oe(true);break;case "c":G.preventDefault(),re.current?.focus();break}};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,a,q,ie,Ee,Ke,at,dt]);let ta=useCallback(A=>{let G=A.currentTarget.textContent?.trim()||"";if(T&&G!==T.title){let pe={...T,title:G};_(pe),r?.(T.id,{title:G});}},[T,r]),sa=useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),A.currentTarget.blur()),A.key==="Escape"&&(A.preventDefault(),A.currentTarget.textContent=T?.title||"",A.currentTarget.blur());},[T]),Ge=useCallback(()=>{T&&e&&T.description!==e.description&&r?.(T.id,{description:T.description}),J(false);},[T,e,r]),$e=useCallback(A=>{if(T){let G={...T,columnId:A};_(G),r?.(T.id,{columnId:A}),R(false);}},[T,r]),ia=useCallback(A=>{if(T){let G={...T,priority:A};_(G),r?.(T.id,{priority:A}),ke(false);}},[T,r]),he=useCallback(A=>{if(T){let G=T.assignedUserIds||[],pe=G.includes(A)?G.filter(Q=>Q!==A):[...G,A],Ye={...T,assignedUserIds:pe};_(Ye),r?.(T.id,{assignedUserIds:pe});}},[T,r]),E=useCallback(A=>{if(T){let G=T.labels||[],pe=G.includes(A)?G.filter(Q=>Q!==A):[...G,A],Ye={...T,labels:pe};_(Ye),r?.(T.id,{labels:pe});}},[T,r]),Z=useCallback(A=>{if(T){let G={...T,tags:A};_(G),r?.(T.id,{tags:A});}},[T,r]),me=useCallback(A=>{if(T){let G=A.target.value,pe={...T,endDate:G};_(pe),r?.(T.id,{endDate:G}),lt(false);}},[T,r]),Ne=useCallback(A=>{if(T){let G={...T,estimatedTime:parseFloat(A)||0};_(G),r?.(T.id,{estimatedTime:parseFloat(A)||0});}},[T,r]),ze=useCallback(()=>{if(je.trim()&&T){let A={id:`subtask-${Date.now()}`,title:je.trim(),completed:false,createdAt:new Date},G=[...te,A];be(G),H(""),Oe(false),x?.(T.id,G);}},[je,te,T,x]),Be=useCallback(A=>{let G=te.map(pe=>pe.id===A?{...pe,completed:!pe.completed,updatedAt:new Date}:pe);be(G),T&&x?.(T.id,G);},[te,T,x]),Le=useCallback(A=>{let G=te.filter(pe=>pe.id!==A);be(G),T&&x?.(T.id,G);},[te,T,x]),Ze=useCallback(()=>{z.trim()&&T&&p&&(p(T.id,z.trim()),W(""));},[z,T,p]),ct=useCallback(A=>{(A.metaKey||A.ctrlKey)&&A.key==="Enter"&&(A.preventDefault(),Ze());},[Ze]),Y=A=>jsx(Bu,{remarkPlugins:[Ru],rehypePlugins:[Ou],components:{a:({node:G,...pe})=>jsx("a",{...pe,target:"_blank",rel:"noopener noreferrer"})},children:A}),ae=c.filter(A=>N==="comments"?A.type.includes("COMMENT"):N==="history"?!A.type.includes("COMMENT"):true);if(!t||!e)return null;let Pe=T||e,He=s.filter(A=>Pe.assignedUserIds?.includes(A.id)),D=te.filter(A=>A.completed).length;return jsx(pt,{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:A=>A.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":M,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:U,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:ta,onKeyDown:sa,children:Pe.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:we,children:[jsxs("button",{ref:ye,className:"modal-v2-field",onClick:()=>R(!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:Pe.columnId||"No status"})]}),jsx(So,{triggerRef:ye,isOpen:q,onClose:()=>R(false),width:250,estimatedHeight:200,children:(C.length>0?C:Uu.map(A=>({id:A,title:A}))).map(A=>jsx("button",{className:`modal-v2-popover-item ${Pe.columnId===A.id?"active":""}`,onClick:()=>$e(A.id),children:A.title},A.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:rt,children:[jsxs("button",{ref:Se,className:"modal-v2-field",onClick:()=>ce(!Ee),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:He.length>0?jsx("div",{className:"modal-v2-avatars",children:He.map(A=>jsx("div",{className:"modal-v2-avatar",style:{background:A.color},title:A.name,children:A.initials},A.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(So,{triggerRef:Se,isOpen:Ee,onClose:()=>ce(false),width:280,estimatedHeight:300,children:s.map(A=>jsxs("button",{className:`modal-v2-popover-item ${Pe.assignedUserIds?.includes(A.id)?"active":""}`,onClick:()=>he(A.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:A.color},children:A.initials}),A.name,Pe.assignedUserIds?.includes(A.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"})})]},A.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Te,children:[jsxs("button",{ref:St,className:"modal-v2-field",onClick:()=>ke(!ie),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:Pe.priority||"None"})]}),jsxs(So,{triggerRef:St,isOpen:ie,onClose:()=>ke(false),width:180,estimatedHeight:220,children:[zu.map(A=>jsx("button",{className:`modal-v2-popover-item priority-${A.toLowerCase()} ${Pe.priority===A?"active":""}`,onClick:()=>ia(A),children:A},A)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>ia(""),children:"None"})]})]}),y.length>0||f?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(Qa,{selectedTags:Pe.tags||[],availableTags:y,onChange:Z,onCreateTag:f,theme:qe[M]||qe.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:wt,children:[jsxs("button",{ref:gt,className:"modal-v2-field",onClick:()=>Me(!Ke),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:Pe.labels&&Pe.labels.length>0?jsx("span",{children:Pe.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(So,{triggerRef:gt,isOpen:Ke,onClose:()=>Me(false),width:220,estimatedHeight:200,children:(m.length>0?m:["Bug","Feature","Enhancement","Documentation"]).map(A=>jsxs("button",{className:`modal-v2-popover-item ${Pe.labels?.includes(A)?"active":""}`,onClick:()=>E(A),children:[A,Pe.labels?.includes(A)&&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"})})]},A))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{lt(!at),setTimeout(()=>Ie.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:Pe.endDate?new Date(Pe.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Ie,type:"date",value:typeof Pe.endDate=="string"?Pe.endDate.split("T")[0]:Pe.endDate?(()=>{let A=new Date(Pe.endDate),G=A.getUTCFullYear(),pe=String(A.getUTCMonth()+1).padStart(2,"0"),Ye=String(A.getUTCDate()).padStart(2,"0");return `${G}-${pe}-${Ye}`})():"",onChange:me,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>tt(!dt),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:Pe.estimatedTime?`${Pe.estimatedTime}h`:"Not set"})]}),dt&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:Pe.estimatedTime||"",onChange:A=>Ne(A.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>tt(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"})]}),B?jsx("textarea",{className:"modal-v2-textarea",value:Pe.description||"",onChange:A=>{if(T){let G={...T,description:A.target.value};_(G);}},onBlur:Ge,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>J(true),children:Pe.description?jsx("div",{className:"modal-v2-markdown",children:Y(Pe.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:[D,"/",te.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Oe(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(A=>jsxs("div",{className:`modal-v2-subtask ${A.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>Be(A.id),children:A.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:A.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>Le(A.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"})]})})]},A.id)),Fe&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:je,onChange:A=>H(A.target.value),onKeyDown:A=>{A.key==="Enter"&&ze(),A.key==="Escape"&&(Oe(false),H(""));},onBlur:ze,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(L||S.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"}),S.length>0&&jsx("span",{className:"modal-v2-count",children:S.length})]}),jsx(rr,{cardId:Pe.id,attachments:S,onUpload:L?A=>L(Pe.id,A):void 0,onDelete:w,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 ${N==="all"?"active":""}`,onClick:()=>j("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${N==="comments"?"active":""}`,onClick:()=>j("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${N==="history"?"active":""}`,onClick:()=>j("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[u&&jsx("div",{className:"modal-v2-avatar",style:{background:u.color},children:u.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:re,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:z,onChange:A=>W(A.target.value),onKeyDown:ct,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:Ze,disabled:!z.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[ae.map(A=>{let G=s.find(Ye=>Ye.id===A.userId);if(A.type.includes("COMMENT")){let Ye=n.find(Q=>Q.id===A.metadata?.commentId);return Ye?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[G&&jsx("div",{className:"modal-v2-avatar",style:{background:G.color},children:G.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:G?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(A.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:Ye.content})]})]},A.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[A.type.includes("CREATED")&&"\u2795",A.type.includes("UPDATED")&&"\u270F\uFE0F",A.type.includes("MOVED")&&"\u27A1\uFE0F",A.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",A.type.includes("ASSIGNED")&&"\u{1F464}",A.type.includes("PRIORITY")&&"\u{1F3AF}",A.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:G?.name||"Unknown"})," ",A.type.replace(/_/g," ").toLowerCase(),A.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:A.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(A.timestamp).toLocaleString()})]})]},A.id)}),ae.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function Yu({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 As({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,p)=>c+p.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(Yu,{})}),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 rg({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 Fs({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,p=s>0?(s-n)/s*100:0,l=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(rg,{})}),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:l?"#10B981":"#EF4444",fill:l?"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:l?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:l?"#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:p>=50?"#10B981":"#F59E0B"},children:[p.toFixed(0),"%"]})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Remaining"}),jsx("span",{className:"chart-stat-value",style:{color:l?"#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:l?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:l?"#10B981":"#EF4444"},children:l?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var pg={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Cd=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function ug({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)),p=t+n*Math.sin(-a*(Math.PI/180));return s<.05?null:jsx("text",{x:c,y:p,fill:"white",textAnchor:c>e?"start":"end",dominantBaseline:"central",style:{fontSize:"12px",fontWeight:600},children:`${(s*100).toFixed(0)}%`})}function Td({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 Is({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((p,l)=>p+l.value,0),n=e.map(p=>({...p,totalValue:s,color:p.color||pg[p.name]||Cd[e.indexOf(p)%Cd.length]})),c=n.map(p=>p.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?ug:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:n.map((p,l)=>jsx(Cell,{fill:c[l]},`cell-${l}`))}),jsx(Tooltip,{content:jsx(Td,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(p,l)=>{let u=l.payload,d=s>0?(u.value/s*100).toFixed(0):"0";return `${p} (${u.value} - ${d}%)`}})]}):jsxs(BarChart,{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(Td,{})}),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((p,l)=>jsx(Cell,{fill:c[l]},`cell-${l}`))})]})}),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((p,l)=>l.value>p.value?l:p).name})]})]})]})}var mn=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[n,c]=useState(false),[p,l]=useState(false),[u,d]=useState(false),[i,h]=useState(false);if(e.length===0)return null;let C=e.map(k=>k.id),m=k=>{r.onBulkUpdate?.(C,{priority:k}),c(false);},y=k=>{r.onBulkMove?.(C,k),l(false),a();},f=k=>{r.onBulkUpdate?.(C,{assignedUserIds:k}),d(false);},v=k=>{let x=new Set;e.forEach(L=>{L.labels?.forEach(w=>x.add(w));});let S=Array.from(new Set([...x,...k]));r.onBulkUpdate?.(C,{labels:S}),h(false);},g=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(C),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(k=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>m(k),children:[jsx("span",{className:b("asakaa-priority-dot",k==="LOW"&&"bg-asakaa-priority-low",k==="MEDIUM"&&"bg-asakaa-priority-medium",k==="HIGH"&&"bg-asakaa-priority-high",k==="URGENT"&&"bg-asakaa-priority-urgent")}),k]},k))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>l(!p),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(k=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>y(k.id),children:k.title},k.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>d(!u),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),u&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(k=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>f([k.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:k.color},children:k.initials}),k.name]},k.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>h(!i),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),i&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(k=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>v([k]),children:k},k))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:g,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"})})]})]})})});mn.displayName="BulkOperationsToolbar";function yg(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,n,c,p,l;switch(t){case "assignee":let u=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);u.length>0?u.forEach(h=>{let C=a?.find(m=>m.id===h);n=`assignee-${h}`,c=C?.name||`User ${h}`,p=C?.color,l=C?.avatar,r.has(n)||r.set(n,{id:n,title:c,groupValue:h,cardIds:[],color:p,icon:l}),r.get(n).cardIds.push(o.id);}):(n="assignee-unassigned",c="Unassigned",p="#6b7280",l="\u{1F464}",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:p,icon:l}),r.get(n).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",n=`priority-${s}`;let i={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=i.title,p=i.color,r.has(n)||r.set(n,{id:n,title:c,groupValue:s,cardIds:[],color:p}),r.get(n).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(h=>{n=`label-${h}`,c=h,p="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:h,cardIds:[],color:p}),r.get(n).cardIds.push(o.id);}):(n="label-none",c="No Labels",p="#6b7280",r.has(n)||r.set(n,{id:n,title:c,groupValue:null,cardIds:[],color:p}),r.get(n).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function Ls({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,n]=useState(new Set),c=useMemo(()=>yg(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),p=useCallback(l=>{n(u=>{let d=new Set(u);return d.has(l)?d.delete(l):d.add(l),d});},[]);return t.groupBy==="none"||c.length===0?jsx(vr,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:b("asakaa-swimlane-view",o),children:[c.map(l=>{let u=s.has(l.id),d=e.cards.filter(h=>l.cardIds.includes(h.id)),i={...e,cards:d};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&&p(l.id),style:{borderLeft:l.color?`4px solid ${l.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[l.icon&&jsx("span",{className:"text-2xl leading-none",children:l.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:l.color},children:l.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",l.cardIds.length," ",l.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":u?"Expand lane":"Collapse lane",children:u?"\u25B6":"\u25BC"})]}),!u&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(vr,{board:i,callbacks:r,availableUsers:a})})]},l.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 Bs=[{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 Rs({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null),c=Bs.find(l=>l.value===e)||Bs[0];useEffect(()=>{function l(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]);let p=l=>{t(l),o(false);};return jsxs("div",{className:b("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:b("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:Bs.map(l=>jsxs("button",{onClick:()=>p(l.value),className:b("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===l.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:l.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:l.label}),e===l.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:l.description})]})]},l.value))})]})]})}var Eo=[{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 kg(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(l=>e.key===l||e.code===l))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,p=o.meta?e.metaKey:true;return s&&n&&c&&p}function Pd(e={}){let{shortcuts:t=Eo,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(p=>{o.current=[...o.current,p];},[]),c=useCallback(p=>{o.current=o.current.filter(l=>l.action!==p);},[]);return useEffect(()=>{function p(l){if(!s.current)return;let u=l.target;if(!((u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable)&&l.key!=="Escape"&&!l.ctrlKey&&!l.metaKey)){for(let d of o.current)if(kg(l,d)){r&&l.preventDefault();let i=new CustomEvent("keyboard-action",{detail:d.action,bubbles:true,cancelable:true});window.dispatchEvent(i);break}}}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),{registerShortcut:n,unregisterShortcut:c,isEnabled:a}}function Cg(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function Tg(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 Ng(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=Tg(e),r=t?Cg(t):"";return a?`${a} + ${r}`:r}function Dg(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 Os({shortcuts:e=Eo,isOpen:t,onClose:a,className:r}){let[o,s]=useState(false);if(useEffect(()=>{s(true);},[]),useEffect(()=>{function c(p){p.key==="Escape"&&t&&a();}if(t)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,a]),!o||!t)return null;let n=Dg(e);return jsxs("div",{className:b("fixed inset-0 z-[9999] flex items-center justify-center",r),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-3xl w-full mx-4 max-h-[80vh] overflow-hidden",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:"\u2328\uFE0F"}),"Keyboard Shortcuts"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Speed up your workflow with these shortcuts"})]}),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"})]}),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,p])=>p.length===0?null:jsxs("div",{children:[jsxs("h3",{className:"text-lg font-semibold text-white/90 mb-4 flex items-center gap-2",children:[jsx("span",{className:"w-1 h-5 bg-blue-500 rounded-full"}),c]}),jsx("div",{className:"space-y-3",children:p.map(l=>jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-lg bg-white/5 hover:bg-white/10 transition-colors",children:[jsx("span",{className:"text-sm text-white/80",children:l.description}),jsx("kbd",{className:"px-3 py-1.5 bg-gradient-to-br from-gray-700 to-gray-800 border border-white/20 rounded-md text-xs font-mono text-white/90 shadow-lg whitespace-nowrap",children:Ng(l)})]},l.action))})]},c))})}),jsx("div",{className:"px-6 py-4 border-t border-white/10 bg-white/5",children:jsxs("p",{className:"text-xs text-white/50 text-center",children:["Press ",jsx("kbd",{className:"px-2 py-0.5 bg-white/10 rounded text-white/70",children:"?"})," to toggle this help panel"]})})]})]})}var zs=[{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,8 +108,8 @@ 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 Us({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null);useEffect(()=>{function l(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]);let c=l=>{t(l),o(false);},m=e.reduce((l,u)=>{let d=u.category||"Other";return l[d]||(l[d]=[]),l[d].push(u),l},{});return jsxs("div",{className:b("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:l=>{l.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",l.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",l.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:b("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[320px] max-w-[400px] rounded-xl backdrop-blur-xl border shadow-2xl z-50 overflow-hidden max-h-[500px] overflow-y-auto",style:{backgroundColor:"var(--theme-bg-primary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-4 py-3 border-b sticky top-0 backdrop-blur-sm",style:{borderColor:"var(--theme-border-primary)",backgroundColor:"var(--theme-bg-secondary)"},children:[jsx("span",{className:"text-sm font-bold uppercase tracking-wider",style:{color:"var(--theme-text-primary)"},children:"Card Templates"}),jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:"Quick start with pre-configured cards"})]}),Object.entries(m).map(([l,u])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:l})}),jsx("div",{children:u.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},l)),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 Hs({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,c]=useState("export"),[m,l]=useState("json"),[u,d]=useState(null),i=useRef(null);if(!t)return null;let h=async()=>{let p=o?.current||void 0,y=await xl(e,m,p);kl(y,m);},C=async p=>{let y=p.target.files?.[0];if(y){try{let f=await Tl(y),v=y.name.endsWith(".json")?"json":"csv",g=Cl(f,v);d(g),g.success&&r&&r(g,f);}catch(f){d({success:false,errors:[`Failed to read file: ${f instanceof Error?f.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:b("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:b("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:b("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(p=>jsxs("button",{onClick:()=>l(p),className:b("p-4 rounded-lg border-2 transition-all text-center",m===p?"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:[p==="json"&&"\u{1F4C4}",p==="csv"&&"\u{1F4CA}",p==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:p})]},p))})]}),jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:"Preview"}),jsxs("div",{className:"text-xs text-white/60",children:[jsxs("div",{children:["Board: ",jsx("span",{className:"text-white/90",children:e.title||"Untitled"})]}),jsxs("div",{children:["Columns: ",jsx("span",{className:"text-white/90",children:e.columns.length})]}),jsxs("div",{children:["Cards: ",jsx("span",{className:"text-white/90",children:e.cards.length})]})]})]}),jsx("button",{onClick:h,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),n==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:i,type:"file",accept:".json,.csv",onChange:C,className:"hidden"}),jsxs("button",{onClick:()=>i.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),u&&jsxs("div",{className:b("p-4 rounded-lg",u.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:b("font-semibold mb-2",u.success?"text-green-400":"text-red-400"),children:u.success?"\u2713 Import Successful":"\u2717 Import Failed"}),u.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",u.cardsImported]}),jsxs("div",{children:["Columns imported: ",u.columnsImported]})]}),u.errors&&u.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:u.errors.map((p,y)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",p]},y))})]})]})]})]})]})}var Ag=["URGENT","HIGH","MEDIUM","LOW"],Fg=[{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"}],Ig=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ws({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:c,availableUsers:m=[],availableLabels:l=[],availableColumns:u=[],showQuickFilters:d=true,compact:i=false,groupBy:h="none",onGroupByChange:C}){let[p,y]=useState(true),f=useCallback(D=>{a({search:D.target.value});},[a]),v=useCallback(D=>{a({dateFilter:D.target.value});},[a]),g=useCallback(D=>{r({by:D.target.value});},[r]),k=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),x=e.search||e.dateFilter!=="all"||e.priorities.length>0||e.assignees.length>0||e.labels.length>0||t.by!=="none";return jsxs("div",{className:`filter-bar ${i?"filter-bar--compact":""} ${p?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>y(!p),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:p?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:D=>{D.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:p?"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"}),x&&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)"]})]}),!p&&jsxs("div",{className:"filter-bar__content",children:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),n&&jsx("button",{onClick:n,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),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:f,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:v,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:D=>{let B=D.target.value;a({priorities:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Ag.map(D=>jsx("option",{value:D,children:D},D))]})}),m.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:D=>{let B=D.target.value;a({assignees:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),m.map(D=>jsx("option",{value:D.id,children:D.name},D.id))]})}),l.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:D=>{let B=D.target.value;a({labels:B==="all"?[]:[B]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),l.map(D=>jsx("option",{value:D,children:D},D))]})}),jsxs("div",{className:"filter-bar__field filter-bar__sort",children:[jsx("span",{className:"filter-bar__label",style:{color:"var(--theme-text-secondary)"},children:"Sort:"}),jsx("select",{value:t.by,onChange:g,className:"filter-bar__select filter-bar__select--sm",children:Fg.map(D=>jsx("option",{value:D.value,children:D.label},D.value))}),t.by!=="none"&&jsx("button",{onClick:k,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),C&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:h,onChange:D=>C(D.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Ig.map(D=>jsx("option",{value:D.value,children:D.label},D.value))})}),x&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Gs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:c,onExportGanttCSV:m}){let[l,u]=useState(false),d=useRef(null);useEffect(()=>{let h=C=>{d.current&&!d.current.contains(C.target)&&u(false);};return l&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[l]);let i=h=>{h(),u(false);};return jsxs("div",{className:b("relative",r),ref:d,children:[jsxs("button",{onClick:()=>u(!l),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",h.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",h.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":l,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"})]}),l&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>i(e),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Export"]}):jsxs(Fragment,{children:[jsxs("button",{onClick:()=>i(async()=>await s?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Export PDF"]}),jsxs("button",{onClick:()=>i(async()=>await n?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),"Export Excel"]}),jsxs("button",{onClick:()=>i(async()=>await c?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Export PNG"]}),jsxs("button",{onClick:()=>i(()=>m?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]}),"Export CSV"]})]}),jsxs("button",{onClick:()=>i(t),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v6m0 6v6m8.5-8.5L17 15M7 9L3.5 5.5M7 15l-3.5 3.5M20.5 5.5L17 9m3.5 11.5L17 17"})]}),"Themes"]}),jsxs("button",{onClick:()=>i(a),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),"Shortcuts"]})]})]})}var _s={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"}},Vs={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"}},js={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"}},$r={dark:_s,light:Vs,neutral:js},un="dark";var gn=createContext(void 0),Gg="asakaa-theme";function Fd({children:e,defaultTheme:t=un,storageKey:a=Gg}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,m=$r[r];Object.entries(m.colors).forEach(([u,d])=>{d&&c.style.setProperty(`--theme-${_g(u)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([u,d])=>{let i=m.colors[u];i&&c.style.setProperty(d,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let n={theme:r,setTheme:s,themes:$r};return jsx(gn.Provider,{value:n,children:e})}function io(){let e=useContext(gn);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function _g(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Ks({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=io();return e?jsxs("div",{className:b("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($r).map(([s,n])=>jsxs("button",{onClick:()=>{o(s),t();},className:b("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 Id(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Ye[e]||Ye.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",Ye[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Ye[e].bgSecondary),bgGrid:r("--theme-bg-card",Ye[e].bgGrid),bgWeekend:r("--theme-bg-hover",Ye[e].bgWeekend),border:r("--theme-border-primary",Ye[e].border),borderLight:r("--theme-border-subtle",Ye[e].borderLight),textPrimary:r("--theme-text-primary",Ye[e].textPrimary),textSecondary:r("--theme-text-secondary",Ye[e].textSecondary),textTertiary:r("--theme-text-tertiary",Ye[e].textTertiary),accent:r("--theme-accent-primary",Ye[e].accent),accentHover:r("--theme-accent-hover",Ye[e].accentHover),accentLight:r("--theme-accent-primary",Ye[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Ye[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Ye[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Ye[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Ye[e].dependency),dependencyHover:r("--theme-border-secondary",Ye[e].dependencyHover),criticalPath:r("--theme-error",Ye[e].criticalPath),criticalPathLight:r("--theme-error",Ye[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Ye[e].today):e==="neutral"?r("--theme-text-primary",Ye[e].today):r("--theme-error",Ye[e].today),todayLight:e==="light"?r("--theme-accent-primary",Ye[e].todayLight):e==="neutral"?r("--theme-text-primary",Ye[e].todayLight):r("--theme-error",Ye[e].todayLight),milestone:r("--theme-warning",Ye[e].milestone),milestoneLight:r("--theme-warning",Ye[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Ye[e].statusTodo),statusInProgress:r("--theme-accent-primary",Ye[e].statusInProgress),statusCompleted:r("--theme-success",Ye[e].statusCompleted),hoverBg:r("--theme-bg-hover",Ye[e].hoverBg),focusRing:r("--theme-accent-primary",Ye[e].focusRing)}}var fn={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},Ld={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},Ys={en:fn,es:Ld};function Bd(e){return Ys[e]||Ys.en}function qs(e,t){let a=Bd(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 co=createContext(fn);function Po(){return useContext(co)}function lf({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[c,m]=useState(false),[l,u]=useState(null),d=useRef(null),i=Po();if(useEffect(()=>{let y=f=>{d.current&&!d.current.contains(f.target)&&m(false);};return c&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[c]),!(t||a||r||o||s||n))return null;let C=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:n}].filter(y=>y.handler),p=async(y,f)=>{if(f){u(y);try{await f();}catch(v){console.error(`Export ${y} failed:`,v);}finally{u(null),m(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>m(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:i.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:C.map((y,f)=>jsxs(motion.button,{onClick:()=>p(y.id,y.handler),disabled:l!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:f<C.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:f*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:l===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 df({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 cf({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 pf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=Po();useEffect(()=>{let l=u=>{s.current&&!s.current.contains(u.target)&&o(false);};return r&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]);let c=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],m=c.find(l=>l.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${n.toolbar.density||"Density"}: ${m}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:c.map((l,u)=>{let d=t===l.value;return jsxs(motion.button,{onClick:()=>{a(l.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent",borderBottom:u<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:l.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},l.value)})})})})]})}function hn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:c,onRowDensityChange:m,showThemeSelector:l=false,showCreateTaskButton:u=false,createTaskLabel:d,onCreateTask:i,onExportPNG:h,onExportPDF:C,onExportExcel:p,onExportCSV:y,onExportJSON:f,onExportMSProject:v}){let g=Po(),k=h||C||p||y||f||v,x=[{value:"day",label:g.toolbar.day},{value:"week",label:g.toolbar.week},{value:"month",label:g.toolbar.month}],D=[{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(cf,{options:x,value:t,onChange:B=>a(B),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(pf,{theme:e,value:c,onChange:m})]}),jsxs("div",{className:"flex items-center gap-3",children:[u&&i&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:i,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:d||g.toolbar.createTask})]}),(k||l)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),k&&jsxs(Fragment,{children:[jsx(lf,{theme:e,onExportPNG:h,onExportPDF:C,onExportExcel:p,onExportCSV:y,onExportJSON:f,onExportMSProject:v}),l&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),l&&jsx(df,{options:D,value:s,onChange:B=>n(B),theme:e})]})]})}function bn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),c=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;let u=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]);let l=e.filter(u=>u.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:m,onClick:()=>{if(!r&&m.current){let u=m.current.getBoundingClientRect();n({x:u.left,y:u.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(mt,{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"}),l.map(u=>jsxs("button",{onClick:()=>{t(u.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:u.label}),u.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},u.id))]})})})})]})}function po({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[c,m]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let u=200,d=r.length*36+8,i=8,h=window.innerWidth,C=window.innerHeight,p=t,y=a;t+u+i>h&&(p=t-u,p<i&&(p=i)),a+d+i>C&&(y=C-d-i,y<i&&(y=i)),m({x:p,y});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let u=i=>{n.current&&!n.current.contains(i.target)&&o();},d=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let l=u=>u.startsWith("#")&&(u.length===7||u.length===4)?u:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:n,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:l(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(u=>jsxs("div",{children:[u.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{u.disabled||(u.onClick(),o());},disabled:u.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:u.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:u.disabled?"not-allowed":"pointer",opacity:u.disabled?.5:1},onMouseEnter:d=>{u.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[u.icon&&jsx("span",{style:{color:s.textSecondary},children:u.icon}),jsx("span",{className:"flex-1",children:u.label}),u.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},u.id))})})})}var Lt={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 Yd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:c,onTaskOutdent:m,onTaskRename:l,onTaskToggleExpand:u,onOpenTaskModal:d,enableKeyboard:i=true}){let h=useRef(false),C=useCallback(g=>{h.current=g;},[]),p=useCallback(g=>{let k=[],x=D=>{for(let B of D)k.push(B),B.subtasks&&B.subtasks.length>0&&B.isExpanded&&x(B.subtasks);};return x(g),k},[]),y=useCallback(()=>{let g=p(e);for(let k of g)if(t.has(k.id))return k;return null},[e,t,p]),f=useCallback((g,k)=>{let x=p(e);if(x.length===0)return;let D=y();if(!D){a(x[0].id,false);return}let B=x.findIndex(P=>P.id===D.id);if(B===-1)return;let w=g==="up"?B-1:B+1;if(w<0||w>=x.length)return;let z=x[w];a(z.id,k);},[e,y,p,a]),v=useCallback(g=>{if(!i)return;let k=g.target;if(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable||h.current){g.key==="Escape"&&(k.blur(),h.current=false);return}let B=navigator.platform.toUpperCase().indexOf("MAC")>=0?g.metaKey:g.ctrlKey,w=Array.from(t),z=y();if(g.key==="ArrowUp"){g.preventDefault(),f("up",g.shiftKey);return}if(g.key==="ArrowDown"){g.preventDefault(),f("down",g.shiftKey);return}if(z&&(g.key==="ArrowRight"||g.key==="ArrowLeft")){z.subtasks&&z.subtasks.length>0&&(g.preventDefault(),(g.key==="ArrowRight"&&!z.isExpanded||g.key==="ArrowLeft"&&z.isExpanded)&&u(z.id));return}if(g.altKey&&(g.key==="ArrowUp"||g.key==="ArrowDown")){w.length>0&&(g.preventDefault(),n(w,g.key==="ArrowUp"?"up":"down"));return}if(g.key==="Tab"&&!g.shiftKey){w.length>0&&(g.preventDefault(),c(w));return}if(g.key==="Tab"&&g.shiftKey){w.length>0&&(g.preventDefault(),m(w));return}if(g.key==="Enter"&&!g.shiftKey&&!B){z&&(g.preventDefault(),r(z.id,"below"));return}if(g.key==="Enter"&&g.shiftKey&&!B){z&&(g.preventDefault(),r(z.id,"above"));return}if(g.key==="Enter"&&B){z&&(g.preventDefault(),d(z.id));return}if(g.key==="F2"){z&&(g.preventDefault(),l(z.id));return}if(g.key==="Delete"||g.key==="Backspace"&&B){w.length>0&&(g.preventDefault(),o(w));return}if(g.key==="d"&&B&&!g.shiftKey){w.length>0&&(g.preventDefault(),s(w));return}},[i,t,y,f,r,o,s,n,c,m,l,u,d]);return useEffect(()=>{if(i)return window.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",v);}},[i,v]),{setIsEditing:C}}function Xd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(i=>{let h=new Set(i);return h.has(d)?h.delete(d):h.add(d),h}),r(d);},[]),n=useCallback((d,i)=>{if(!a){o(d);return}let h=i.indexOf(a),C=i.indexOf(d);if(h===-1||C===-1){o(d);return}let p=Math.min(h,C),y=Math.max(h,C),f=i.slice(p,y+1);t(new Set(f)),r(d);},[a,o]),c=useCallback((d,i,h,C)=>{C?n(d,i):h?s(d):o(d);},[o,s,n]),m=useCallback((d,i)=>{i?t(h=>{let C=new Set(h);return C.add(d),C}):o(d);},[o]),l=useCallback(()=>{t(new Set),r(null);},[]),u=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:n,handleTaskClick:c,handleKeyboardSelection:m,clearSelection:l,isTaskSelected:u}}function mo(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 Jd(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=Jd(a.subtasks,t);if(r)return r}}return null}function Zs(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Zs(a.subtasks,t);if(r)return r}return null}function Qs(e,t){if(t.length===0)return e;let a=mo(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],n=(d,i)=>{let h=[];return {tasks:d.filter(p=>{if(i.has(p.id))return h.push(p),false;if(p.subtasks){let y=n(p.subtasks,i);p.subtasks=y.tasks,h.push(...y.removed);}return true}),removed:h}},c=(d,i,h)=>d.map(C=>C.id===i?{...C,subtasks:[...C.subtasks||[],...h],isExpanded:true}:C.subtasks?{...C,subtasks:c(C.subtasks,i,h)}:C),m=new Set(t),{tasks:l,removed:u}=n(e,m);return c(l,s.id,u)}function ei(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Zs(a,r);if(!o)continue;let s=Zs(a,o.id),n=(l,u,d)=>{for(let i=0;i<l.length;i++){let h=l[i];if(h.id===u&&h.subtasks){let C=h.subtasks.findIndex(p=>p.id===d);if(C!==-1){let[p]=h.subtasks.splice(C,1);return p}}if(h.subtasks){let C=n(h.subtasks,u,d);if(C)return C}}return null},c=(l,u,d)=>{let i=l.findIndex(h=>h.id===u);if(i!==-1)return l.splice(i+1,0,d),l;for(let h of l)h.subtasks&&c(h.subtasks,u,d);return l},m=n(a,o.id,r);m&&(s&&s.subtasks?c(s.subtasks,o.id,m):c(a,o.id,m));}return a}function ti(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,c,m)=>{let l=n.findIndex(d=>d.id===c);if(l===-1){for(let d of n)if(d.subtasks&&s(d.subtasks,c,m))return true;return false}let u=m==="up"?l-1:l+1;return u<0||u>=n.length?false:([n[l],n[u]]=[n[u],n[l]],true)};return s(r,o,a),r}function ai(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 ri(e,t){let a=[...e];for(let r of t){let o=n=>{let c=n.findIndex(u=>u.id===r);if(c===-1){for(let u of n)if(u.subtasks&&o(u.subtasks))return true;return false}let m=n[c],l={...m,id:`${m.id}-copy-${Date.now()}`,name:`${m.name} (Copy)`,subtasks:m.subtasks?s(m.subtasks):void 0};return n.splice(c+1,0,l),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 Zd(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=m=>{let l=m.findIndex(d=>d.id===t);if(l===-1){for(let d of m)if(d.subtasks&&c(d.subtasks))return true;return false}let u=a==="above"?l:l+1;return m.splice(u,0,n),true};return c(r),{tasks:r,newTask:n}}function oi(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:oi(r.subtasks,t,a)}:r)}function ni(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:ni(a.subtasks,t)}:a)}function si(e,t){let a=u=>{for(let d of u){if(d.id===t)return d;if(d.subtasks){let i=a(d.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n=r?.startDate||o,c=r?.endDate||s,m={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(c),color:r?.color||"#3B82F6"},l=u=>u.map(d=>{if(d.id===t){let i=d.subtasks||[];return {...d,subtasks:[...i,m],isExpanded:true}}return d.subtasks?{...d,subtasks:l(d.subtasks)}:d});return {tasks:l(e),newTask:m}}function Qd(e,t,a,r){if(t===a)return e;let o=Jd(e,t);if(!o)return e;if(a){let c=(m,l)=>{if(!m.subtasks)return false;for(let u of m.subtasks)if(u.id===l||c(u,l))return true;return false};if(c(o,a))return e}let s=c=>c.filter(m=>m.id!==t).map(m=>m.subtasks&&m.subtasks.length>0?{...m,subtasks:s(m.subtasks)}:m),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=m=>m.map(l=>{if(l.id===a){let u=l.subtasks||[],d=r!==void 0?r:u.length,i=[...u];return i.splice(d,0,{...o,parentId:a}),{...l,subtasks:i,isExpanded:true}}return l.subtasks&&l.subtasks.length>0?{...l,subtasks:c(l.subtasks)}:l});n=c(n);}return n}function xn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:c,onTaskToggle:m,scrollTop:l,columns:u,onToggleColumn:d,onColumnResize:i,onTaskUpdate:h,onTaskIndent:C,onTaskOutdent:p,onTaskMove:y,onMultiTaskDelete:f,onTaskDuplicate:v,onTaskCreate:g,onTaskRename:k,onCreateSubtask:x,onOpenTaskModal:D,onDeleteRequest:B,onTaskReparent:w}){let z=useContext(co),[P,T]=useState(null),[G,R]=useState(null),[q,te]=useState(""),xe=useRef(null),[Ae,ze]=useState(null),[le,O]=useState(0),[L,H]=useState(0),[F,X]=useState({isOpen:false,x:0,y:0,type:"header"}),[Q,U]=useState(null),[ke,Te]=useState(null),[Fe,ve]=useState(null),et=useRef(0),Ie=5,pt=useRef(false),[it,lt]=useState(null),[tt,$]=useState(false),[ne,re]=useState(null),[we,Ne]=useState(false),at=useRef(null);useEffect(()=>{function K(ae){at.current&&!at.current.contains(ae.target)&&Ne(false);}if(we)return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[we]),useEffect(()=>{G&&xe.current&&(xe.current.focus(),xe.current.select());},[G]),useEffect(()=>{if(!Ae)return;let K=Pe=>{let We=Pe.clientX-le,N=L+We;i?.(Ae,N);},ae=()=>{ze(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",K),document.addEventListener("mouseup",ae),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",ae),document.body.style.cursor="",document.body.style.userSelect="";}},[Ae,le,L,i]);let{selectedTaskIds:wt,handleTaskClick:Le,isTaskSelected:he}=Xd(),{setIsEditing:Ee}=Yd({tasks:e,selectedTaskIds:wt,onTaskSelect:(K,ae)=>{let We=mo(e).map(N=>N.id);Le(K,We,ae||false,false);},onTaskCreate:g||(()=>{}),onTaskDelete:f||(()=>{}),onTaskDuplicate:v||(()=>{}),onTaskMove:y||(()=>{}),onTaskIndent:C||(()=>{}),onTaskOutdent:p||(()=>{}),onTaskRename:K=>{let ae=mo(e).find(Pe=>Pe.id===K);ae&&He(ae);},onTaskToggleExpand:m||(()=>{}),onOpenTaskModal:K=>{let ae=mo(e).find(Pe=>Pe.id===K);ae&&D&&D(ae);},enableKeyboard:true}),St=(K,ae=0)=>{let Pe=[];for(let We of K)Pe.push({task:We,level:ae}),We.subtasks&&We.subtasks.length>0&&We.isExpanded&&Pe.push(...St(We.subtasks,ae+1));return Pe},gt=St(e),ta=48,sa=Math.max(gt.length*a,600-ta),_e=K=>!K.startDate||!K.endDate?"-":`${Math.ceil((K.endDate.getTime()-K.startDate.getTime())/(1e3*60*60*24))}d`,He=K=>{R(K.id),te(K.name),Ee(true);},ia=K=>{q.trim()&&q!==e.find(ae=>ae.id===K)?.name&&k?.(K,q.trim()),R(null),te(""),Ee(false);},fe=()=>{R(null),te(""),Ee(false);},S=(K,ae)=>{ae.stopPropagation(),x?.(K.id);},J=(K,ae)=>{ae.preventDefault(),et.current=ae.clientY,U(K),pt.current=false,$(false),lt({x:ae.clientX,y:ae.clientY});},ce=K=>{if(!Q||(Math.abs(K.clientY-et.current)>Ie&&!pt.current&&(pt.current=true,$(true)),lt({x:K.clientX,y:K.clientY}),!pt.current))return;let Pe=document.querySelectorAll("[data-task-row]"),We=null,N=null;Pe.forEach(M=>{let _=M.getBoundingClientRect(),pe=M.getAttribute("data-task-row");if(pe&&pe!==Q&&K.clientY>=_.top&&K.clientY<=_.bottom){We=pe;let Ke=K.clientY-_.top,Z=_.height;Ke<Z*.25?N="above":Ke>Z*.75?N="below":N="child";}}),Te(We),ve(N);},De=()=>{if(pt.current&&Q&&ke&&Fe){if(Fe==="child")w?.(Q,ke);else if(Fe==="above"||Fe==="below"){let K=(We,N,M=null)=>{for(let _ of We){if(_.id===N)return M;if(_.subtasks){let pe=K(_.subtasks,N,_.id);if(pe!==void 0)return pe}}},ae=K(e,ke,null),Pe=(We,N)=>{let M=We.findIndex(_=>_.id===N);return Fe==="below"?M+1:M};if(ae===null){let We=Pe(e,ke);w?.(Q,null,We);}else {let We=gt.find(N=>N.task.id===ae)?.task;if(We?.subtasks){let N=Pe(We.subtasks,ke);w?.(Q,ae,N);}}}}U(null),Te(null),ve(null),lt(null),pt.current=false,$(false);};useEffect(()=>{if(Q)return document.addEventListener("mousemove",ce),document.addEventListener("mouseup",De),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",De),document.body.style.cursor="",document.body.style.userSelect="";}},[Q,ke,Fe]);let Ue=(K,ae,Pe)=>{switch(K.id){case "name":let We=G===ae.id,N=P===ae.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${Pe*20}px`},children:[w&&jsx("div",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-white/10 transition-all flex-shrink-0",style:{color:t.textTertiary,opacity:N?1:.3},onMouseDown:oe=>J(ae.id,oe),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),ae.subtasks&&ae.subtasks.length>0?jsx("button",{onClick:oe=>{oe.stopPropagation(),m?.(ae.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:ae.isExpanded?jsx(ChevronDown,{className:"w-4 h-4"}):jsx(ChevronRight,{className:"w-4 h-4"})}):jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:ae.color||"#3B82F6",opacity:ae.parentId?.6:1,borderColor:ae.isMilestone?t.accent:"transparent",borderWidth:ae.isMilestone?"2px":"0px"},title:ae.isMilestone?"Milestone":ae.parentId?"Subtask":"Task"})}),We?jsx("input",{ref:xe,type:"text",value:q,onChange:oe=>te(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"?ia(ae.id):oe.key==="Escape"&&fe();},onBlur:()=>ia(ae.id),className:"flex-1 px-2 py-1 rounded border outline-none",style:{backgroundColor:t.bgPrimary,borderColor:t.accent,color:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:"13px",fontWeight:500},onClick:oe=>oe.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:ae.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:ae.parentId?"13px":"14px",fontWeight:ae.isMilestone?600:ae.parentId?400:600,letterSpacing:ae.parentId?"0":"-0.01em"},title:ae.name,children:ae.name}),N&&!We&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:oe=>oe.stopPropagation(),children:[jsx("button",{onClick:oe=>S(ae,oe),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:oe=>{oe.stopPropagation(),He(ae);},className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Rename (F2)",children:jsx(Edit3,{className:"w-3.5 h-3.5"})})]})]})]});case "startDate":case "endDate":let _=K.id==="startDate"?"startDate":"endDate",pe=ae[_],Ke=ne?.taskId===ae.id&&ne?.field===_,Z=oe=>oe?(typeof oe=="string"?new Date(oe):oe).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:oe=>oe.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:oe=>{if(Ke)re(null);else {let nt=oe.currentTarget.getBoundingClientRect();re({taskId:ae.id,field:_,month:pe?typeof pe=="string"?new Date(pe):pe:new Date,position:{top:nt.bottom+4,left:nt.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Z(pe)})]}),Ke&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>re(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:ne?.position.top,left:ne?.position.left},onClick:oe=>oe.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let oe=new Date,nt=new Date(oe);nt.setDate(oe.getDate()+1);let rt=new Date(oe);rt.setDate(oe.getDate()+7);let $e=new Date(oe);return $e.setDate(oe.getDate()+14),[{label:"Hoy",date:oe},{label:"Ma\xF1ana",date:nt},{label:"Pr\xF3xima semana",date:rt},{label:"2 semanas",date:$e}].map((Pt,da)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:Er=>Er.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:Er=>Er.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(ae.id,{[_]:Pt.date}),re(null);},children:Pt.label},da))})(),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:oe=>oe.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(ae.id,{[_]:void 0}),re(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:()=>re(oe=>oe?{...oe,month:new Date(oe.month.getFullYear(),oe.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:ne?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>re(oe=>oe?{...oe,month:new Date(oe.month.getFullYear(),oe.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((oe,nt)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:oe},nt))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let oe=ne?.month||new Date,nt=oe.getFullYear(),rt=oe.getMonth(),$e=new Date(nt,rt,1).getDay(),Et=new Date(nt,rt+1,0).getDate(),Pt=new Date,da=[];for(let Vt=$e-1;Vt>=0;Vt--)da.push({day:new Date(nt,rt,-Vt).getDate(),date:new Date(nt,rt-1,new Date(nt,rt,-Vt).getDate()),isCurrentMonth:false});for(let Vt=1;Vt<=Et;Vt++)da.push({day:Vt,date:new Date(nt,rt,Vt),isCurrentMonth:true});let Er=42-da.length;for(let Vt=1;Vt<=Er;Vt++)da.push({day:Vt,date:new Date(nt,rt+1,Vt),isCurrentMonth:false});return da.map((Vt,bo)=>{let Kn=Vt.date.toDateString()===Pt.toDateString(),yo=(pe?typeof pe=="string"?new Date(pe):pe:null)?.toDateString()===Vt.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:Vt.isCurrentMonth?yo?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:yo?"#3B82F6":"transparent",boxShadow:Kn&&!yo?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{h?.(ae.id,{[_]:Vt.date}),re(null);},children:Vt.day},bo)})})()})]})]})]}),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(ae)})});case "assignees":let Oe=r.filter(oe=>ae.assignees?.some(nt=>nt.name===oe.name||nt.initials===oe.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:oe=>oe.stopPropagation(),children:jsx(Lr,{assignedUsers:Oe,availableUsers:r,onChange:oe=>{let nt=oe.map(rt=>({id:rt.id,name:rt.name,initials:rt.initials,color:rt.color}));h?.(ae.id,{assignees:nt.length>0?nt:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:oe=>oe.stopPropagation(),children:jsx(Gl,{status:ae.status||"todo",onChange:oe=>{h?.(ae.id,{status:oe,progress:oe==="completed"?100:ae.progress});}})});case "progress":return jsxs("div",{className:"flex items-center justify-center gap-2 w-full",children:[jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden max-w-[60px]",style:{backgroundColor:t.bgSecondary},children:jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ae.progress}%`,backgroundColor:ae.progress===100?t.statusCompleted:t.accent}})}),jsxs("span",{className:"text-xs tabular-nums min-w-[35px] text-right",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:[ae.progress,"%"]})]});case "priority":let Nt={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},Me={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},aa=Nt[ae.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:oe=>oe.stopPropagation(),children:jsx(Fr,{priority:aa,onChange:oe=>{oe&&h?.(ae.id,{priority:Me[oe]||"medium"});}})});default:return null}},Re=K=>[{id:"hide",label:"Hide Column",icon:Lt.Hide,onClick:()=>d(K),disabled:K==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Lt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Lt.SortDesc,onClick:()=>{}}],Be=K=>K.subtasks&&K.subtasks.length>0?[{id:"addSubtask",label:z?.contextMenu?.addSubtask||"Add Subtask",icon:Lt.Add,onClick:()=>{x?.(K.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:z?.contextMenu?.deleteTask||"Delete Task",icon:Lt.Delete,onClick:()=>{B?B(K.id,K.name):f?.([K.id]);}}]:[{id:"edit",label:z?.contextMenu?.editTask||"Edit Task",icon:Lt.Pencil,onClick:()=>{n?.(K);}},{id:"addSubtask",label:z?.contextMenu?.addSubtask||"Add Subtask",icon:Lt.Add,onClick:()=>{x?.(K.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:z?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Lt.MarkIncomplete,onClick:()=>{h?.(K.id,{status:"todo",progress:0});},disabled:K.status==="todo"},{id:"setInProgress",label:z?.contextMenu?.setInProgress||"Set In Progress",icon:Lt.SetInProgress,onClick:()=>{h?.(K.id,{status:"in-progress"});},disabled:K.status==="in-progress"},{id:"markComplete",label:z?.contextMenu?.markComplete||"Mark Complete",icon:Lt.MarkComplete,onClick:()=>{h?.(K.id,{status:"completed",progress:100});},disabled:K.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:z?.contextMenu?.splitTask||"Split Task",icon:Lt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:z?.contextMenu?.deleteTask||"Delete Task",icon:Lt.Delete,onClick:()=>{B?B(K.id,K.name):f?.([K.id]);}}],Je=u.filter(K=>K.visible),dt=Je.reduce((K,ae)=>K+ae.width,0);return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:dt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${ta}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:Je.map((K,ae)=>{let Pe=ae===Je.length-1,We=K.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${We?"":"justify-center"}`,style:{width:`${K.width}px`,minWidth:`${K.minWidth??(We?200:60)}px`,maxWidth:`${K.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Pe?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:N=>{N.preventDefault(),X({isOpen:true,x:N.clientX,y:N.clientY,type:"header",columnId:K.id});},onMouseEnter:N=>{N.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:N=>{N.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:K.label,children:K.label}),K.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:Ae===K.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:N=>{N.preventDefault(),N.stopPropagation(),ze(K.id),O(N.clientX),H(K.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"}})})]},K.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(bn,{columns:u,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>Ne(!we),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"})}),we&&jsxs("div",{ref:at,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:K=>K.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:()=>Ne(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:sa},children:gt.map(({task:K,level:ae},Pe)=>{let We=he(K.id),N=ke===K.id,M=N&&Fe==="above",_=N&&Fe==="below",pe=N&&Fe==="child",Ke={};return pe&&(Ke.backgroundColor=`${t.accent}15`,Ke.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":K.id,className:`flex items-center cursor-pointer group ${Q===K.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:We?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:We?t.accentLight:pe?`${t.accent}15`:Pe%2===0?t.bgPrimary:t.bgGrid,...Ke},onMouseEnter:()=>T(K.id),onMouseLeave:()=>T(null),onClick:Z=>{let Nt=mo(e).map(oe=>oe.id),aa=navigator.platform.toUpperCase().indexOf("MAC")>=0?Z.metaKey:Z.ctrlKey;Le(K.id,Nt,aa,Z.shiftKey),s?.(K);},onDoubleClick:Z=>{Z.stopPropagation(),n?.(K);},onContextMenu:Z=>{Z.preventDefault(),X({isOpen:true,x:Z.clientX,y:Z.clientY,type:"task",task:K}),c?.(K,Z);},whileHover:{backgroundColor:We?t.accentLight:t.hoverBg},children:[M&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),_&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Je.map((Z,Oe)=>{let Nt=Oe===Je.length-1,Me=Z.id==="name";return jsx("div",{className:`px-4 flex items-center ${Me?"justify-start":"justify-center"}`,style:{width:`${Z.width}px`,minWidth:`${Z.minWidth??(Me?200:60)}px`,maxWidth:`${Z.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Nt?"none":`1px solid ${P===K.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:Ue(Z,K,Me?ae:0)},`${K.id}-${Z.id}`)})]},K.id)})}),jsx(po,{isOpen:F.isOpen,x:F.x,y:F.y,items:F.type==="header"&&F.columnId?Re(F.columnId):F.type==="task"&&F.task?Be(F.task):[],onClose:()=>X({...F,isOpen:false}),theme:t}),tt&&it&&Q&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:it.x+12,top:it.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let K=gt.find(ae=>ae.task.id===Q)?.task;return K?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:K.name})}):null})()}),document.body)]})}function oc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,c]=useState(e),[m,l]=useState(t),[u,d]=useState(null),[i,h]=useState(null),[C,p]=useState(null),[y,f]=useState(null),[v,g]=useState(0),[k,x]=useState(0),[D,B]=useState(null),[w,z]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:c,ghostWidth:m,setGhostWidth:l,connectionLine:u,setConnectionLine:d,hoveredTaskId:i,setHoveredTaskId:h,activeZone:C,setActiveZone:p,draggedSegmentIndex:y,setDraggedSegmentIndex:f,draggedSegmentStartX:v,setDraggedSegmentStartX:g,segmentDragOffsetX:k,setSegmentDragOffsetX:x,hoveredSegmentIndex:D,setHoveredSegmentIndex:B,isHovered:w,setIsHovered:z,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(q,te)=>{r("none"),d(null),h(null),c(q),l(te),x(0),f(null),g(0);}}}function kn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:c,onClick:m,onDoubleClick:l,onContextMenu:u,onDateChange:d,onDependencyCreate:i,allTaskPositions:h=[],onDragMove:C,onHoverChange:p}){let y=oc(t,r),f=useRef(null),{dragMode:v,setDragMode:g,dragOffset:k,setDragOffset:x,ghostX:D,setGhostX:B,ghostWidth:w,setGhostWidth:z,connectionLine:P,setConnectionLine:T,hoveredTaskId:G,setHoveredTaskId:R,activeZone:q,setActiveZone:te,draggedSegmentIndex:xe,setDraggedSegmentIndex:Ae,draggedSegmentStartX:ze,setDraggedSegmentStartX:le,segmentDragOffsetX:O,setSegmentDragOffsetX:L,hoveredSegmentIndex:H,setHoveredSegmentIndex:F,isHovered:X,setIsHovered:Q,isDragging:U,isResizing:ke,isConnecting:Te,resetDragState:Fe}=y,ve=32,et=8,Ie=e.endDate&&e.endDate<new Date&&e.progress<100,pt=e.isCriticalPath,it=o.name==="neutral"||o.today==="#1C1917",lt=e.status==="completed"||e.progress===100,tt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},ne=e.isCriticalPath||Ie?"#DC2626":e.color?e.color:e.priority&&tt[e.priority]?tt[e.priority]:o.taskBarPrimary,we=(fe=>fe>=80?20:fe>=60?15:fe>=50?12:10)(r),Ne=r<50,at=r<40;useEffect(()=>{if(p)if(X&&!U&&!e.segments){let fe=a<100;p({task:e,x:t,y:a,width:r,height:ve,showBelow:fe});}else p(null);},[X,U,e,t,a,r,ve,p]);let wt=fe=>fe.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Le=()=>{let fe=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${fe} day${fe!==1?"s":""}`},he=fe=>Math.round(fe/s)*s,Ee=fe=>{let S=Math.round(fe/s),J=new Date(n);return J.setDate(J.getDate()+S),J},St=(fe,S)=>{for(let J of h){if(J.id===e.id)continue;let ce=5;if(fe>=J.x-ce&&fe<=J.x+J.width+ce&&S>=J.y-ce&&S<=J.y+J.height+ce)return J.id}return null},gt=useCallback((fe,S,J)=>{fe.preventDefault(),fe.stopPropagation();let ce=f.current?.ownerSVGElement;if(!ce)return;let De=ce.createSVGPoint();De.x=fe.clientX,De.y=fe.clientY;let Ue=De.matrixTransform(ce.getScreenCTM()?.inverse()),Re=J!==void 0?J:t,Be=S;if(!Be){let Je=Ue.x-Re;fe.shiftKey?(Be="connect",T({x:t+r,y:a+ve/2})):fe.ctrlKey||fe.metaKey?Be="move":fe.altKey?Be=Je<r/2?"resize-start":"resize-end":at?Je<r/2?Be="move":Be="resize-end":Ne?Je<=we/2?Be="resize-start":Je>=r-we/2?Be="resize-end":Be="move":Je<=we?Be="resize-start":Je>=r-we?Be="resize-end":Be="move";}g(Be),Q(false),te(null),Be==="move"?x(Ue.x-Re):Be==="connect"?T({x:t+r,y:a+ve/2}):x(0),B(Re),z(r);},[t,r,a,ve]),ta=useCallback(fe=>{if(v==="none")return;let S=f.current?.ownerSVGElement;if(!S)return;let J=S.createSVGPoint();J.x=fe.clientX,J.y=fe.clientY;let ce=J.matrixTransform(S.getScreenCTM()?.inverse());if(v==="connect"){T({x:ce.x,y:ce.y});let De=St(ce.x,ce.y);R(De);}else if(v==="move"){let De=ce.x-k,Ue=he(De);B(Ue),z(r);let Re=Math.round((Ue-t)/s);if(C?.(e.id,Re,true),e.segments&&e.segments.length>0&&xe!==null){let Be=Ue-ze;L(Be);}}else if(v==="resize-start"){let De=ce.x,Ue=he(De),Re=t+r-Ue;Re>=s&&(B(Ue),z(Re));}else if(v==="resize-end"){let De=ce.x,Re=he(De)-t;Re>=s&&z(Re);}},[v,t,r,s,k,e,he,xe,ze,St,R,T,B,z,L,C]),sa=useCallback(()=>{if(v!=="none"){if(v==="connect")G&&i&&i(e,G),T(null),R(null);else {let fe=e.endDate.getTime()-e.startDate.getTime(),S,J,ce=true;if(v==="move"){if(S=Ee(D),J=new Date(S.getTime()+fe),e.segments&&e.segments.length>0&&xe!==null){let De=Math.round(O/s),Ue=e.segments.map((dt,K)=>{if(K===xe){let ae=new Date(dt.startDate),Pe=new Date(dt.endDate);return ae.setDate(ae.getDate()+De),Pe.setDate(Pe.getDate()+De),{startDate:ae,endDate:Pe}}return dt}),Re=Ue.flatMap(dt=>[dt.startDate,dt.endDate]),Be=new Date(Math.min(...Re.map(dt=>dt.getTime()))),Je=new Date(Math.max(...Re.map(dt=>dt.getTime())));d?.({...e,segments:Ue},Be,Je),Fe(t,r);return}}else v==="resize-start"?(S=Ee(D),J=e.endDate,S>J&&(console.warn("Invalid date range: start date must be before or equal to end date"),ce=false)):v==="resize-end"?(S=e.startDate,J=Ee(D+w),J<S&&(console.warn("Invalid date range: end date must be after or equal to start date"),ce=false)):ce=false;ce&&S&&J&&(J.getTime()<S.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,S,J));}C?.(e.id,0,false),Fe(t,r);}},[v,D,w,e,d,G,i,t,r,s,Ee,O,xe,Fe,C]);useEffect(()=>{if(v==="none")return;let fe=J=>{ta(J);},S=()=>{sa();};return window.addEventListener("mousemove",fe),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",fe),window.removeEventListener("mouseup",S);}},[v,ta,sa]);let _e=U&&!Te?D:t,He=U&&!Te?w:r,ia=c.taskClass(e);return jsxs("g",{ref:f,onMouseEnter:()=>!U&&Q(true),onMouseLeave:()=>{U||(Q(false),te(null));},onClick:()=>!U&&m?.(e),onDoubleClick:fe=>{U||(fe.stopPropagation(),l?.(e));},onContextMenu:fe=>{fe.preventDefault(),u?.(e,fe);},children:[X&&!U&&!Ne&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:we,height:ve,fill:q==="resize-start"?o.accent:"transparent",opacity:q==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-start"),onMouseDown:fe=>gt(fe,"resize-start")}),jsx("rect",{x:t+we,y:a,width:r-we*2,height:ve,fill:q==="move"?o.accent:"transparent",opacity:q==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>te("move"),onMouseDown:fe=>gt(fe,"move")}),jsx("rect",{x:t+r-we,y:a,width:we,height:ve,fill:q==="resize-end"?o.accent:"transparent",opacity:q==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-end"),onMouseDown:fe=>gt(fe,"resize-end")})]}),X&&!U&&at&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:ve,fill:q==="move"?o.accent:"transparent",opacity:q==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>te("move"),onMouseDown:fe=>gt(fe,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:ve,fill:q==="resize-end"?o.accent:"transparent",opacity:q==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-end"),onMouseDown:fe=>gt(fe,"resize-end")}),X&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+ve-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),U&&!Te&&!e.segments&&jsx(motion.rect,{x:D,y:a,width:w,height:ve,rx:et,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:_e,y:a,width:He,height:ve,rx:et,fill:ne,"data-task-class":ia,initial:{opacity:0,scale:.95},animate:{opacity:U&&!Te?.15:e.parentId?.6:X?.9:.8,scale:X&&!U?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:fe=>gt(fe),style:{cursor:U?Te?"crosshair":ke?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:_e,y:a,width:He*(e.progress/100),height:ve,rx:et,fill:ne,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((fe,S)=>{let J=(fe.startDate.getTime()-n.getTime())/864e5*s,De=(fe.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-J+s,Ue=U&&v==="move"&&xe===S,Re=H===S,Be=Ue?J+O:J;return jsxs("g",{onMouseEnter:()=>!U&&F(S),onMouseLeave:()=>!U&&F(null),children:[jsx(motion.rect,{x:Be,y:a,width:De,height:ve,rx:et,fill:ne,initial:{opacity:0,scale:.95},animate:{opacity:Ue||e.parentId?.6:Re?.9:.8,scale:Re&&!U?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:Je=>{Je.stopPropagation(),Ae(S),le(J),gt(Je,void 0,J);},style:{cursor:U?Te?"crosshair":ke?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Be,y:a,width:De*(e.progress/100),height:ve,rx:et,fill:ne,opacity:1,style:{pointerEvents:"none"}})]},`segment-${S}`)}),it&&(Ie||pt)&&!e.segments&&jsxs(Fragment,{children:[pt&&!Ie&&jsx("rect",{x:_e,y:a,width:He,height:ve,rx:et,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Ie&&jsx("rect",{x:_e,y:a,width:He,height:ve,rx:et,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),He>60&&!e.segments&&(()=>{let fe=c.taskLabel(e),S=typeof fe=="string"?fe:e.name,J=S.length>Math.floor(He/8)?`${S.substring(0,Math.floor(He/8))}...`:S;return jsx("text",{x:_e+12,y:a+ve/2,dominantBaseline:"middle",fill:lt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:lt?"line-through":"none"},children:J})})(),He>100&&e.progress>0&&e.progress<100&&!U&&!e.segments&&jsxs("text",{x:_e+He-12,y:a+ve/2,dominantBaseline:"middle",textAnchor:"end",fill:"rgba(255, 255, 255, 0.9)",fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:[e.progress,"%"]}),e.status&&He>80&&!U&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:_e+He-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:_e+He-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(X||ke)&&!Te&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ne?_e-15:_e-10,y:a-5,width:Ne?25:20,height:ve+10,fill:"transparent",onMouseDown:fe=>gt(fe,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ne?_e-8:_e-3,y:a+6,width:Ne?8:6,height:Ne?ve-12:ve-16,rx:3,fill:v==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:v==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:_e+He-10,y:a-5,width:Ne?25:20,height:ve+10,fill:"transparent",onMouseDown:fe=>gt(fe,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ne?_e+He:_e+He-3,y:a+6,width:Ne?8:6,height:Ne?ve-12:ve-16,rx:3,fill:v==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:v==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:X&&!U&&!e.segments&&jsxs(motion.g,{style:{pointerEvents:"all"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx(motion.circle,{cx:t+r+8,cy:a+ve/2,r:6,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.2,type:"spring",stiffness:400,damping:25},onMouseDown:fe=>{fe.stopPropagation(),gt(fe,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+ve/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),Te&&P&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+ve/2,x2:P.x,y2:P.y,stroke:G?o.statusCompleted:o.accent,strokeWidth:G?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:G?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:P.x,cy:P.y,r:G?8:6,fill:G?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),G&&jsx(motion.text,{x:P.x+15,y:P.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:P.x+10},animate:{opacity:1,x:P.x+15},transition:{duration:.2},children:"Connect"})]}),(X||U)&&!Te&&!e.segments&&jsx(motion.rect,{x:_e-2,y:a-2,width:He+4,height:ve+4,rx:et+2,fill:"none",stroke:U?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:U?.6:.4,initial:{opacity:0},animate:{opacity:U?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),ke&&jsxs(Fragment,{children:[jsx("line",{x1:D,y1:0,x2:D,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:D+w,y1:0,x2:D+w,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:X&&!U&&!e.segments&&!p&&(()=>{let J=a<100,ce=J?a+ve+13:a-82-13,De=J?`M ${_e+He/2-6} ${a+ve+3} L ${_e+He/2} ${a+ve+13} L ${_e+He/2+6} ${a+ve+3}`:`M ${_e+He/2-6} ${a-13} L ${_e+He/2} ${a-3} L ${_e+He/2+6} ${a-13}`,Ue=ce+22,Re=ce+40,Be=ce+55,Je=ce+70,dt=J?ce+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:J?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:J?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:De,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:_e+He/2-120,y:ce,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:_e+He/2,y:Ue,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:_e+He/2-110,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:_e+He/2-70,y:Re,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:wt(e.startDate)}),jsx("text",{x:_e+He/2-110,y:Be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:_e+He/2-70,y:Be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:wt(e.endDate)}),jsx("text",{x:_e+He/2+10,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:_e+He/2+65,y:Re,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Le()}),jsx("text",{x:_e+He/2+10,y:Be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:_e+He/2+65,y:Be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.progress,"%"]}),e.assignees&&e.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:_e+He/2-110,y:Je,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:_e+He/2-50,y:Je,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(K=>K.name).join(", ").substring(0,30),e.assignees.map(K=>K.name).join(", ").length>30?"...":""]})]}),!J&&jsx("text",{x:_e+He/2,y:dt,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:at?"Left: move \u2022 Right: resize":Ne?"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 ic({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:c}=e,m=82,l=13,u=c?o+n+l:o-m-l,d=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}`,i=u+22,h=u+40,C=u+55,p=u+70,y=k=>k.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),f=()=>{if(!a.startDate||!a.endDate)return "N/A";let k=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${k} day${k!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:u,width:240,height:m,rx:8,fill:t.bgSecondary,stroke:t.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:r+s/2,y:i,textAnchor:"middle",fill:t.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:a.name.length>28?`${a.name.substring(0,28)}...`:a.name}),jsx("text",{x:r+s/2-110,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?y(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?y(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:f()}),jsx("text",{x:r+s/2+10,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.progress,"%"]}),a.assignees&&a.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:r+s/2-110,y:p,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:p,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(k=>k.name).join(", ").substring(0,30),a.assignees.map(k=>k.name).join(", ").length>30?"...":""]})]})]})})}function Tn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:n}){let[c,m]=useState(false),l=a-e,u=r-t,d=e+l/2,i=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,h=6,C=Math.atan2(u,l),p=a-h*Math.cos(C-Math.PI/6),y=r-h*Math.sin(C-Math.PI/6),f=a-h*Math.cos(C+Math.PI/6),v=r-h*Math.sin(C+Math.PI/6),g=o.dependency;useEffect(()=>{n&&s&&n(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,n]);let k=!s&&!n;return jsxs("g",{onMouseEnter:()=>!k&&m(true),onMouseLeave:()=>!k&&m(false),style:{pointerEvents:k?"none":"auto"},children:[!k&&jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&n?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${p} ${y} M ${a} ${r} L ${f} ${v}`,fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&n?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:g,initial:{scale:0},animate:{scale:c&&n?0:c?1.3:1,opacity:c&&n?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!n&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:x=>{x.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function Dn({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),c=16,m=l=>l.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>n(true),onMouseLeave:()=>n(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:m(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var me={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=l=>{l.forEach(u=>{u.dependencies&&r.set(u.id,u.dependencies),u.subtasks&&o(u.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let n=new Set,c=new Set,m=l=>{if(!n.has(l)){n.add(l),c.add(l);let u=r.get(l)||[];for(let d of u){if(!n.has(d)&&m(d))return true;if(c.has(d))return true}}return c.delete(l),false};return m(a)},flattenTasks:e=>{let t=[],a=r=>{r.forEach(o=>{t.push(o),o.subtasks&&o.subtasks.length>0&&a(o.subtasks);});};return a(e),t},findTaskById:(e,t)=>{for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=me.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=me.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=me.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=me.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
- `)},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=me.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=me.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)=>me.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=me.findTaskById(e,t);return !a||!a.dependencies?[]:me.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>me.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>me.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=me.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=>me.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=me.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(m=>{let l=m.startDate&&m.endDate?me.calculateDuration(m.startDate,m.endDate):0;return [m.name,m.startDate?me.formatDate(m.startDate):"N/A",m.endDate?me.formatDate(m.endDate):"N/A",l>0?`${l} days`:"N/A",`${m.progress}%`,m.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=me.flattenTasks(e).map(m=>{let l=m.startDate&&m.endDate?me.calculateDuration(m.startDate,m.endDate):0;return {"Task ID":m.id,"Task Name":m.name,"Start Date":m.startDate?me.formatDate(m.startDate):"","End Date":m.endDate?me.formatDate(m.endDate):"","Duration (days)":l>0?l:"","Progress (%)":m.progress,Status:m.status||"",Assignees:m.assignees?.map(u=>u.name).join(", ")||"",Dependencies:m.dependencies?.join(", ")||"","Is Milestone":m.isMilestone?"Yes":"No","Parent ID":m.parentId||"",Level:m.level||0}}),s=a.utils.json_to_sheet(o),n=[{wch:15},{wch:40},{wch:12},{wch:12},{wch:15},{wch:12},{wch:15},{wch:30},{wch:20},{wch:12},{wch:15},{wch:8}];s["!cols"]=n;let 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=me.flattenTasks(e),o=new Map;r.forEach((i,h)=>{o.set(i.id,h+1);});let s=i=>i.toISOString().replace("Z",""),n=me.getEarliestStartDate(e)||new Date,c=me.getLatestEndDate(e)||new Date,m=r.map((i,h)=>{let C=o.get(i.id),p=i.startDate&&i.endDate?me.calculateDuration(i.startDate,i.endDate):0,y=(i.dependencies||[]).filter(f=>o.has(f)).map(f=>`
111
+ - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function Us({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null);useEffect(()=>{function l(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]);let c=l=>{t(l),o(false);},p=e.reduce((l,u)=>{let d=u.category||"Other";return l[d]||(l[d]=[]),l[d].push(u),l},{});return jsxs("div",{className:b("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:l=>{l.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",l.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",l.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:b("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[320px] max-w-[400px] rounded-xl backdrop-blur-xl border shadow-2xl z-50 overflow-hidden max-h-[500px] overflow-y-auto",style:{backgroundColor:"var(--theme-bg-primary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-4 py-3 border-b sticky top-0 backdrop-blur-sm",style:{borderColor:"var(--theme-border-primary)",backgroundColor:"var(--theme-bg-secondary)"},children:[jsx("span",{className:"text-sm font-bold uppercase tracking-wider",style:{color:"var(--theme-text-primary)"},children:"Card Templates"}),jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:"Quick start with pre-configured cards"})]}),Object.entries(p).map(([l,u])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:l})}),jsx("div",{children:u.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},l)),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 Hs({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,c]=useState("export"),[p,l]=useState("json"),[u,d]=useState(null),i=useRef(null);if(!t)return null;let h=async()=>{let m=o?.current||void 0,y=await xl(e,p,m);kl(y,p);},C=async m=>{let y=m.target.files?.[0];if(y){try{let f=await Tl(y),v=y.name.endsWith(".json")?"json":"csv",g=Cl(f,v);d(g),g.success&&r&&r(g,f);}catch(f){d({success:false,errors:[`Failed to read file: ${f instanceof Error?f.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:b("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:b("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:b("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(m=>jsxs("button",{onClick:()=>l(m),className:b("p-4 rounded-lg border-2 transition-all text-center",p===m?"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:[m==="json"&&"\u{1F4C4}",m==="csv"&&"\u{1F4CA}",m==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:m})]},m))})]}),jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:"Preview"}),jsxs("div",{className:"text-xs text-white/60",children:[jsxs("div",{children:["Board: ",jsx("span",{className:"text-white/90",children:e.title||"Untitled"})]}),jsxs("div",{children:["Columns: ",jsx("span",{className:"text-white/90",children:e.columns.length})]}),jsxs("div",{children:["Cards: ",jsx("span",{className:"text-white/90",children:e.cards.length})]})]})]}),jsx("button",{onClick:h,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),n==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:i,type:"file",accept:".json,.csv",onChange:C,className:"hidden"}),jsxs("button",{onClick:()=>i.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),u&&jsxs("div",{className:b("p-4 rounded-lg",u.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:b("font-semibold mb-2",u.success?"text-green-400":"text-red-400"),children:u.success?"\u2713 Import Successful":"\u2717 Import Failed"}),u.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",u.cardsImported]}),jsxs("div",{children:["Columns imported: ",u.columnsImported]})]}),u.errors&&u.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:u.errors.map((m,y)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",m]},y))})]})]})]})]})]})}var Ag=["URGENT","HIGH","MEDIUM","LOW"],Fg=[{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"}],Ig=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ws({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:c,availableUsers:p=[],availableLabels:l=[],availableColumns:u=[],showQuickFilters:d=true,compact:i=false,groupBy:h="none",onGroupByChange:C}){let[m,y]=useState(true),f=useCallback(S=>{a({search:S.target.value});},[a]),v=useCallback(S=>{a({dateFilter:S.target.value});},[a]),g=useCallback(S=>{r({by:S.target.value});},[r]),k=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),x=e.search||e.dateFilter!=="all"||e.priorities.length>0||e.assignees.length>0||e.labels.length>0||t.by!=="none";return jsxs("div",{className:`filter-bar ${i?"filter-bar--compact":""} ${m?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>y(!m),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:m?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:m?"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"}),x&&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)"]})]}),!m&&jsxs("div",{className:"filter-bar__content",children:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),n&&jsx("button",{onClick:n,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),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:f,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:v,className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Dates"}),jsx("option",{value:"overdue",children:"Overdue"}),jsx("option",{value:"today",children:"Today"}),jsx("option",{value:"this-week",children:"This Week"})]})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.priorities[0]||"all",onChange:S=>{let L=S.target.value;a({priorities:L==="all"?[]:[L]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Ag.map(S=>jsx("option",{value:S,children:S},S))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:S=>{let L=S.target.value;a({assignees:L==="all"?[]:[L]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(S=>jsx("option",{value:S.id,children:S.name},S.id))]})}),l.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:S=>{let L=S.target.value;a({labels:L==="all"?[]:[L]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),l.map(S=>jsx("option",{value:S,children:S},S))]})}),jsxs("div",{className:"filter-bar__field filter-bar__sort",children:[jsx("span",{className:"filter-bar__label",style:{color:"var(--theme-text-secondary)"},children:"Sort:"}),jsx("select",{value:t.by,onChange:g,className:"filter-bar__select filter-bar__select--sm",children:Fg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))}),t.by!=="none"&&jsx("button",{onClick:k,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),C&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:h,onChange:S=>C(S.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Ig.map(S=>jsx("option",{value:S.value,children:S.label},S.value))})}),x&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Gs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:c,onExportGanttCSV:p}){let[l,u]=useState(false),d=useRef(null);useEffect(()=>{let h=C=>{d.current&&!d.current.contains(C.target)&&u(false);};return l&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[l]);let i=h=>{h(),u(false);};return jsxs("div",{className:b("relative",r),ref:d,children:[jsxs("button",{onClick:()=>u(!l),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",h.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",h.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":l,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"})]}),l&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>i(e),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Export"]}):jsxs(Fragment,{children:[jsxs("button",{onClick:()=>i(async()=>await s?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Export PDF"]}),jsxs("button",{onClick:()=>i(async()=>await n?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),"Export Excel"]}),jsxs("button",{onClick:()=>i(async()=>await c?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Export PNG"]}),jsxs("button",{onClick:()=>i(()=>p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]}),"Export CSV"]})]}),jsxs("button",{onClick:()=>i(t),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v6m0 6v6m8.5-8.5L17 15M7 9L3.5 5.5M7 15l-3.5 3.5M20.5 5.5L17 9m3.5 11.5L17 17"})]}),"Themes"]}),jsxs("button",{onClick:()=>i(a),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),"Shortcuts"]})]})]})}var _s={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"}},Vs={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"}},js={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"}},$r={dark:_s,light:Vs,neutral:js},un="dark";var gn=createContext(void 0),Gg="asakaa-theme";function Fd({children:e,defaultTheme:t=un,storageKey:a=Gg}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,p=$r[r];Object.entries(p.colors).forEach(([u,d])=>{d&&c.style.setProperty(`--theme-${_g(u)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([u,d])=>{let i=p.colors[u];i&&c.style.setProperty(d,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let n={theme:r,setTheme:s,themes:$r};return jsx(gn.Provider,{value:n,children:e})}function io(){let e=useContext(gn);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function _g(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Ks({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=io();return e?jsxs("div",{className:b("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($r).map(([s,n])=>jsxs("button",{onClick:()=>{o(s),t();},className:b("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 Id(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return qe[e]||qe.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",qe[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",qe[e].bgSecondary),bgGrid:r("--theme-bg-card",qe[e].bgGrid),bgWeekend:r("--theme-bg-hover",qe[e].bgWeekend),border:r("--theme-border-primary",qe[e].border),borderLight:r("--theme-border-subtle",qe[e].borderLight),textPrimary:r("--theme-text-primary",qe[e].textPrimary),textSecondary:r("--theme-text-secondary",qe[e].textSecondary),textTertiary:r("--theme-text-tertiary",qe[e].textTertiary),accent:r("--theme-accent-primary",qe[e].accent),accentHover:r("--theme-accent-hover",qe[e].accentHover),accentLight:r("--theme-accent-primary",qe[e].accentLight),taskBarPrimary:r("--theme-accent-primary",qe[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",qe[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",qe[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",qe[e].dependency),dependencyHover:r("--theme-border-secondary",qe[e].dependencyHover),criticalPath:r("--theme-error",qe[e].criticalPath),criticalPathLight:r("--theme-error",qe[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",qe[e].today):e==="neutral"?r("--theme-text-primary",qe[e].today):r("--theme-error",qe[e].today),todayLight:e==="light"?r("--theme-accent-primary",qe[e].todayLight):e==="neutral"?r("--theme-text-primary",qe[e].todayLight):r("--theme-error",qe[e].todayLight),milestone:r("--theme-warning",qe[e].milestone),milestoneLight:r("--theme-warning",qe[e].milestoneLight),statusTodo:r("--theme-text-tertiary",qe[e].statusTodo),statusInProgress:r("--theme-accent-primary",qe[e].statusInProgress),statusCompleted:r("--theme-success",qe[e].statusCompleted),hoverBg:r("--theme-bg-hover",qe[e].hoverBg),focusRing:r("--theme-accent-primary",qe[e].focusRing)}}var fn={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},Ld={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},Ys={en:fn,es:Ld};function Bd(e){return Ys[e]||Ys.en}function qs(e,t){let a=Bd(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 co=createContext(fn);function Po(){return useContext(co)}function lf({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[c,p]=useState(false),[l,u]=useState(null),d=useRef(null),i=Po();if(useEffect(()=>{let y=f=>{d.current&&!d.current.contains(f.target)&&p(false);};return c&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[c]),!(t||a||r||o||s||n))return null;let C=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:n}].filter(y=>y.handler),m=async(y,f)=>{if(f){u(y);try{await f();}catch(v){console.error(`Export ${y} failed:`,v);}finally{u(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:i.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:C.map((y,f)=>jsxs(motion.button,{onClick:()=>m(y.id,y.handler),disabled:l!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:f<C.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:f*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:l===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 df({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 cf({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 mf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=Po();useEffect(()=>{let l=u=>{s.current&&!s.current.contains(u.target)&&o(false);};return r&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]);let c=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],p=c.find(l=>l.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"}: ${p}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:c.map((l,u)=>{let d=t===l.value;return jsxs(motion.button,{onClick:()=>{a(l.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent",borderBottom:u<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:l.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},l.value)})})})})]})}function hn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:c,onRowDensityChange:p,showThemeSelector:l=false,showCreateTaskButton:u=false,createTaskLabel:d,onCreateTask:i,onExportPNG:h,onExportPDF:C,onExportExcel:m,onExportCSV:y,onExportJSON:f,onExportMSProject:v}){let g=Po(),k=h||C||m||y||f||v,x=[{value:"day",label:g.toolbar.day},{value:"week",label:g.toolbar.week},{value:"month",label:g.toolbar.month}],S=[{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(cf,{options:x,value:t,onChange:L=>a(L),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(mf,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[u&&i&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:i,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:d||g.toolbar.createTask})]}),(k||l)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),k&&jsxs(Fragment,{children:[jsx(lf,{theme:e,onExportPNG:h,onExportPDF:C,onExportExcel:m,onExportCSV:y,onExportJSON:f,onExportMSProject:v}),l&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),l&&jsx(df,{options:S,value:s,onChange:L=>n(L),theme:e})]})]})}function bn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let u=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]);let l=e.filter(u=>u.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let u=p.current.getBoundingClientRect();n({x:u.left,y:u.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(pt,{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"}),l.map(u=>jsxs("button",{onClick:()=>{t(u.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:u.label}),u.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},u.id))]})})})})]})}function mo({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let u=200,d=r.length*36+8,i=8,h=window.innerWidth,C=window.innerHeight,m=t,y=a;t+u+i>h&&(m=t-u,m<i&&(m=i)),a+d+i>C&&(y=C-d-i,y<i&&(y=i)),p({x:m,y});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let u=i=>{n.current&&!n.current.contains(i.target)&&o();},d=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let l=u=>u.startsWith("#")&&(u.length===7||u.length===4)?u:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:n,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:l(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(u=>jsxs("div",{children:[u.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{u.disabled||(u.onClick(),o());},disabled:u.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:u.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:u.disabled?"not-allowed":"pointer",opacity:u.disabled?.5:1},onMouseEnter:d=>{u.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[u.icon&&jsx("span",{style:{color:s.textSecondary},children:u.icon}),jsx("span",{className:"flex-1",children:u.label}),u.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},u.id))})})})}var Lt={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 Yd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:c,onTaskOutdent:p,onTaskRename:l,onTaskToggleExpand:u,onOpenTaskModal:d,enableKeyboard:i=true}){let h=useRef(false),C=useCallback(g=>{h.current=g;},[]),m=useCallback(g=>{let k=[],x=S=>{for(let L of S)k.push(L),L.subtasks&&L.subtasks.length>0&&L.isExpanded&&x(L.subtasks);};return x(g),k},[]),y=useCallback(()=>{let g=m(e);for(let k of g)if(t.has(k.id))return k;return null},[e,t,m]),f=useCallback((g,k)=>{let x=m(e);if(x.length===0)return;let S=y();if(!S){a(x[0].id,false);return}let L=x.findIndex(M=>M.id===S.id);if(L===-1)return;let w=g==="up"?L-1:L+1;if(w<0||w>=x.length)return;let O=x[w];a(O.id,k);},[e,y,m,a]),v=useCallback(g=>{if(!i)return;let k=g.target;if(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable||h.current){g.key==="Escape"&&(k.blur(),h.current=false);return}let L=navigator.platform.toUpperCase().indexOf("MAC")>=0?g.metaKey:g.ctrlKey,w=Array.from(t),O=y();if(g.key==="ArrowUp"){g.preventDefault(),f("up",g.shiftKey);return}if(g.key==="ArrowDown"){g.preventDefault(),f("down",g.shiftKey);return}if(O&&(g.key==="ArrowRight"||g.key==="ArrowLeft")){O.subtasks&&O.subtasks.length>0&&(g.preventDefault(),(g.key==="ArrowRight"&&!O.isExpanded||g.key==="ArrowLeft"&&O.isExpanded)&&u(O.id));return}if(g.altKey&&(g.key==="ArrowUp"||g.key==="ArrowDown")){w.length>0&&(g.preventDefault(),n(w,g.key==="ArrowUp"?"up":"down"));return}if(g.key==="Tab"&&!g.shiftKey){w.length>0&&(g.preventDefault(),c(w));return}if(g.key==="Tab"&&g.shiftKey){w.length>0&&(g.preventDefault(),p(w));return}if(g.key==="Enter"&&!g.shiftKey&&!L){O&&(g.preventDefault(),r(O.id,"below"));return}if(g.key==="Enter"&&g.shiftKey&&!L){O&&(g.preventDefault(),r(O.id,"above"));return}if(g.key==="Enter"&&L){O&&(g.preventDefault(),d(O.id));return}if(g.key==="F2"){O&&(g.preventDefault(),l(O.id));return}if(g.key==="Delete"||g.key==="Backspace"&&L){w.length>0&&(g.preventDefault(),o(w));return}if(g.key==="d"&&L&&!g.shiftKey){w.length>0&&(g.preventDefault(),s(w));return}},[i,t,y,f,r,o,s,n,c,p,l,u,d]);return useEffect(()=>{if(i)return window.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",v);}},[i,v]),{setIsEditing:C}}function Xd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(i=>{let h=new Set(i);return h.has(d)?h.delete(d):h.add(d),h}),r(d);},[]),n=useCallback((d,i)=>{if(!a){o(d);return}let h=i.indexOf(a),C=i.indexOf(d);if(h===-1||C===-1){o(d);return}let m=Math.min(h,C),y=Math.max(h,C),f=i.slice(m,y+1);t(new Set(f)),r(d);},[a,o]),c=useCallback((d,i,h,C)=>{C?n(d,i):h?s(d):o(d);},[o,s,n]),p=useCallback((d,i)=>{i?t(h=>{let C=new Set(h);return C.add(d),C}):o(d);},[o]),l=useCallback(()=>{t(new Set),r(null);},[]),u=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:n,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:l,isTaskSelected:u}}function po(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 Jd(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=Jd(a.subtasks,t);if(r)return r}}return null}function Zs(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Zs(a.subtasks,t);if(r)return r}return null}function Qs(e,t){if(t.length===0)return e;let a=po(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],n=(d,i)=>{let h=[];return {tasks:d.filter(m=>{if(i.has(m.id))return h.push(m),false;if(m.subtasks){let y=n(m.subtasks,i);m.subtasks=y.tasks,h.push(...y.removed);}return true}),removed:h}},c=(d,i,h)=>d.map(C=>C.id===i?{...C,subtasks:[...C.subtasks||[],...h],isExpanded:true}:C.subtasks?{...C,subtasks:c(C.subtasks,i,h)}:C),p=new Set(t),{tasks:l,removed:u}=n(e,p);return c(l,s.id,u)}function ei(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Zs(a,r);if(!o)continue;let s=Zs(a,o.id),n=(l,u,d)=>{for(let i=0;i<l.length;i++){let h=l[i];if(h.id===u&&h.subtasks){let C=h.subtasks.findIndex(m=>m.id===d);if(C!==-1){let[m]=h.subtasks.splice(C,1);return m}}if(h.subtasks){let C=n(h.subtasks,u,d);if(C)return C}}return null},c=(l,u,d)=>{let i=l.findIndex(h=>h.id===u);if(i!==-1)return l.splice(i+1,0,d),l;for(let h of l)h.subtasks&&c(h.subtasks,u,d);return l},p=n(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function ti(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,c,p)=>{let l=n.findIndex(d=>d.id===c);if(l===-1){for(let d of n)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let u=p==="up"?l-1:l+1;return u<0||u>=n.length?false:([n[l],n[u]]=[n[u],n[l]],true)};return s(r,o,a),r}function ai(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 ri(e,t){let a=[...e];for(let r of t){let o=n=>{let c=n.findIndex(u=>u.id===r);if(c===-1){for(let u of n)if(u.subtasks&&o(u.subtasks))return true;return false}let p=n[c],l={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return n.splice(c+1,0,l),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 Zd(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=p=>{let l=p.findIndex(d=>d.id===t);if(l===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let u=a==="above"?l:l+1;return p.splice(u,0,n),true};return c(r),{tasks:r,newTask:n}}function oi(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:oi(r.subtasks,t,a)}:r)}function ni(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:ni(a.subtasks,t)}:a)}function si(e,t){let a=u=>{for(let d of u){if(d.id===t)return d;if(d.subtasks){let i=a(d.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(c),color:r?.color||"#3B82F6"},l=u=>u.map(d=>{if(d.id===t){let i=d.subtasks||[];return {...d,subtasks:[...i,p],isExpanded:true}}return d.subtasks?{...d,subtasks:l(d.subtasks)}:d});return {tasks:l(e),newTask:p}}function Qd(e,t,a,r){if(t===a)return e;let o=Jd(e,t);if(!o)return e;if(a){let c=(p,l)=>{if(!p.subtasks)return false;for(let u of p.subtasks)if(u.id===l||c(u,l))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),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=p=>p.map(l=>{if(l.id===a){let u=l.subtasks||[],d=r!==void 0?r:u.length,i=[...u];return i.splice(d,0,{...o,parentId:a}),{...l,subtasks:i,isExpanded:true}}return l.subtasks&&l.subtasks.length>0?{...l,subtasks:c(l.subtasks)}:l});n=c(n);}return n}function xn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:c,onTaskToggle:p,scrollTop:l,columns:u,onToggleColumn:d,onColumnResize:i,onTaskUpdate:h,onTaskIndent:C,onTaskOutdent:m,onTaskMove:y,onMultiTaskDelete:f,onTaskDuplicate:v,onTaskCreate:g,onTaskRename:k,onCreateSubtask:x,onOpenTaskModal:S,onDeleteRequest:L,onTaskReparent:w}){let O=useContext(co),[M,T]=useState(null),[_,B]=useState(null),[J,te]=useState(""),be=useRef(null),[Fe,Oe]=useState(null),[je,H]=useState(0),[z,W]=useState(0),[N,j]=useState({isOpen:false,x:0,y:0,type:"header"}),[q,R]=useState(null),[ie,ke]=useState(null),[Ee,ce]=useState(null),Ke=useRef(0),Me=5,at=useRef(false),[lt,dt]=useState(null),[tt,U]=useState(false),[ne,re]=useState(null),[we,Te]=useState(false),rt=useRef(null);useEffect(()=>{function Y(ae){rt.current&&!rt.current.contains(ae.target)&&Te(false);}if(we)return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[we]),useEffect(()=>{_&&be.current&&(be.current.focus(),be.current.select());},[_]),useEffect(()=>{if(!Fe)return;let Y=Pe=>{let He=Pe.clientX-je,D=z+He;i?.(Fe,D);},ae=()=>{Oe(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",ae),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",ae),document.body.style.cursor="",document.body.style.userSelect="";}},[Fe,je,z,i]);let{selectedTaskIds:wt,handleTaskClick:Ie,isTaskSelected:ye}=Xd(),{setIsEditing:Se}=Yd({tasks:e,selectedTaskIds:wt,onTaskSelect:(Y,ae)=>{let He=po(e).map(D=>D.id);Ie(Y,He,ae||false,false);},onTaskCreate:g||(()=>{}),onTaskDelete:f||(()=>{}),onTaskDuplicate:v||(()=>{}),onTaskMove:y||(()=>{}),onTaskIndent:C||(()=>{}),onTaskOutdent:m||(()=>{}),onTaskRename:Y=>{let ae=po(e).find(Pe=>Pe.id===Y);ae&&$e(ae);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:Y=>{let ae=po(e).find(Pe=>Pe.id===Y);ae&&S&&S(ae);},enableKeyboard:true}),St=(Y,ae=0)=>{let Pe=[];for(let He of Y)Pe.push({task:He,level:ae}),He.subtasks&&He.subtasks.length>0&&He.isExpanded&&Pe.push(...St(He.subtasks,ae+1));return Pe},gt=St(e),ta=48,sa=Math.max(gt.length*a,600-ta),Ge=Y=>!Y.startDate||!Y.endDate?"-":`${Math.ceil((Y.endDate.getTime()-Y.startDate.getTime())/(1e3*60*60*24))}d`,$e=Y=>{B(Y.id),te(Y.name),Se(true);},ia=Y=>{J.trim()&&J!==e.find(ae=>ae.id===Y)?.name&&k?.(Y,J.trim()),B(null),te(""),Se(false);},he=()=>{B(null),te(""),Se(false);},E=(Y,ae)=>{ae.stopPropagation(),x?.(Y.id);},Z=(Y,ae)=>{ae.preventDefault(),Ke.current=ae.clientY,R(Y),at.current=false,U(false),dt({x:ae.clientX,y:ae.clientY});},me=Y=>{if(!q||(Math.abs(Y.clientY-Ke.current)>Me&&!at.current&&(at.current=true,U(true)),dt({x:Y.clientX,y:Y.clientY}),!at.current))return;let Pe=document.querySelectorAll("[data-task-row]"),He=null,D=null;Pe.forEach(A=>{let G=A.getBoundingClientRect(),pe=A.getAttribute("data-task-row");if(pe&&pe!==q&&Y.clientY>=G.top&&Y.clientY<=G.bottom){He=pe;let Ye=Y.clientY-G.top,Q=G.height;Ye<Q*.25?D="above":Ye>Q*.75?D="below":D="child";}}),ke(He),ce(D);},Ne=()=>{if(at.current&&q&&ie&&Ee){if(Ee==="child")w?.(q,ie);else if(Ee==="above"||Ee==="below"){let Y=(He,D,A=null)=>{for(let G of He){if(G.id===D)return A;if(G.subtasks){let pe=Y(G.subtasks,D,G.id);if(pe!==void 0)return pe}}},ae=Y(e,ie,null),Pe=(He,D)=>{let A=He.findIndex(G=>G.id===D);return Ee==="below"?A+1:A};if(ae===null){let He=Pe(e,ie);w?.(q,null,He);}else {let He=gt.find(D=>D.task.id===ae)?.task;if(He?.subtasks){let D=Pe(He.subtasks,ie);w?.(q,ae,D);}}}}R(null),ke(null),ce(null),dt(null),at.current=false,U(false);};useEffect(()=>{if(q)return document.addEventListener("mousemove",me),document.addEventListener("mouseup",Ne),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",me),document.removeEventListener("mouseup",Ne),document.body.style.cursor="",document.body.style.userSelect="";}},[q,ie,Ee]);let ze=(Y,ae,Pe)=>{switch(Y.id){case "name":let He=_===ae.id,D=M===ae.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${Pe*20}px`},children:[w&&jsx("div",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-white/10 transition-all flex-shrink-0",style:{color:t.textTertiary,opacity:D?1:.3},onMouseDown:oe=>Z(ae.id,oe),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),ae.subtasks&&ae.subtasks.length>0?jsx("button",{onClick:oe=>{oe.stopPropagation(),p?.(ae.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:ae.isExpanded?jsx(ChevronDown,{className:"w-4 h-4"}):jsx(ChevronRight,{className:"w-4 h-4"})}):jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:ae.color||"#3B82F6",opacity:ae.parentId?.6:1,borderColor:ae.isMilestone?t.accent:"transparent",borderWidth:ae.isMilestone?"2px":"0px"},title:ae.isMilestone?"Milestone":ae.parentId?"Subtask":"Task"})}),He?jsx("input",{ref:be,type:"text",value:J,onChange:oe=>te(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"?ia(ae.id):oe.key==="Escape"&&he();},onBlur:()=>ia(ae.id),className:"flex-1 px-2 py-1 rounded border outline-none",style:{backgroundColor:t.bgPrimary,borderColor:t.accent,color:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:"13px",fontWeight:500},onClick:oe=>oe.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:ae.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:ae.parentId?"13px":"14px",fontWeight:ae.isMilestone?600:ae.parentId?400:600,letterSpacing:ae.parentId?"0":"-0.01em"},title:ae.name,children:ae.name}),D&&!He&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:oe=>oe.stopPropagation(),children:[jsx("button",{onClick:oe=>E(ae,oe),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:oe=>{oe.stopPropagation(),$e(ae);},className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Rename (F2)",children:jsx(Edit3,{className:"w-3.5 h-3.5"})})]})]})]});case "startDate":case "endDate":let G=Y.id==="startDate"?"startDate":"endDate",pe=ae[G],Ye=ne?.taskId===ae.id&&ne?.field===G,Q=oe=>oe?(typeof oe=="string"?new Date(oe):oe).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:oe=>oe.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:oe=>{if(Ye)re(null);else {let st=oe.currentTarget.getBoundingClientRect();re({taskId:ae.id,field:G,month:pe?typeof pe=="string"?new Date(pe):pe:new Date,position:{top:st.bottom+4,left:st.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Q(pe)})]}),Ye&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>re(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:ne?.position.top,left:ne?.position.left},onClick:oe=>oe.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let oe=new Date,st=new Date(oe);st.setDate(oe.getDate()+1);let ot=new Date(oe);ot.setDate(oe.getDate()+7);let Ue=new Date(oe);return Ue.setDate(oe.getDate()+14),[{label:"Hoy",date:oe},{label:"Ma\xF1ana",date:st},{label:"Pr\xF3xima semana",date:ot},{label:"2 semanas",date:Ue}].map((Pt,da)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:Er=>Er.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:Er=>Er.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(ae.id,{[G]:Pt.date}),re(null);},children:Pt.label},da))})(),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:oe=>oe.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:oe=>oe.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(ae.id,{[G]:void 0}),re(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:()=>re(oe=>oe?{...oe,month:new Date(oe.month.getFullYear(),oe.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:ne?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>re(oe=>oe?{...oe,month:new Date(oe.month.getFullYear(),oe.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((oe,st)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:oe},st))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let oe=ne?.month||new Date,st=oe.getFullYear(),ot=oe.getMonth(),Ue=new Date(st,ot,1).getDay(),Et=new Date(st,ot+1,0).getDate(),Pt=new Date,da=[];for(let Vt=Ue-1;Vt>=0;Vt--)da.push({day:new Date(st,ot,-Vt).getDate(),date:new Date(st,ot-1,new Date(st,ot,-Vt).getDate()),isCurrentMonth:false});for(let Vt=1;Vt<=Et;Vt++)da.push({day:Vt,date:new Date(st,ot,Vt),isCurrentMonth:true});let Er=42-da.length;for(let Vt=1;Vt<=Er;Vt++)da.push({day:Vt,date:new Date(st,ot+1,Vt),isCurrentMonth:false});return da.map((Vt,bo)=>{let Kn=Vt.date.toDateString()===Pt.toDateString(),yo=(pe?typeof pe=="string"?new Date(pe):pe:null)?.toDateString()===Vt.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:Vt.isCurrentMonth?yo?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:yo?"#3B82F6":"transparent",boxShadow:Kn&&!yo?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{h?.(ae.id,{[G]:Vt.date}),re(null);},children:Vt.day},bo)})})()})]})]})]}),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:Ge(ae)})});case "assignees":let Re=r.filter(oe=>ae.assignees?.some(st=>st.name===oe.name||st.initials===oe.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:oe=>oe.stopPropagation(),children:jsx(Lr,{assignedUsers:Re,availableUsers:r,onChange:oe=>{let st=oe.map(ot=>({id:ot.id,name:ot.name,initials:ot.initials,color:ot.color}));h?.(ae.id,{assignees:st.length>0?st:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:oe=>oe.stopPropagation(),children:jsx(Gl,{status:ae.status||"todo",onChange:oe=>{h?.(ae.id,{status:oe,progress:oe==="completed"?100:ae.progress});}})});case "progress":return jsxs("div",{className:"flex items-center justify-center gap-2 w-full",children:[jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden max-w-[60px]",style:{backgroundColor:t.bgSecondary},children:jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ae.progress}%`,backgroundColor:ae.progress===100?t.statusCompleted:t.accent}})}),jsxs("span",{className:"text-xs tabular-nums min-w-[35px] text-right",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:[ae.progress,"%"]})]});case "priority":let Nt={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},Ae={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},aa=Nt[ae.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:oe=>oe.stopPropagation(),children:jsx(Fr,{priority:aa,onChange:oe=>{oe&&h?.(ae.id,{priority:Ae[oe]||"medium"});}})});default:return null}},Be=Y=>[{id:"hide",label:"Hide Column",icon:Lt.Hide,onClick:()=>d(Y),disabled:Y==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Lt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Lt.SortDesc,onClick:()=>{}}],Le=Y=>Y.subtasks&&Y.subtasks.length>0?[{id:"addSubtask",label:O?.contextMenu?.addSubtask||"Add Subtask",icon:Lt.Add,onClick:()=>{x?.(Y.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:O?.contextMenu?.deleteTask||"Delete Task",icon:Lt.Delete,onClick:()=>{L?L(Y.id,Y.name):f?.([Y.id]);}}]:[{id:"edit",label:O?.contextMenu?.editTask||"Edit Task",icon:Lt.Pencil,onClick:()=>{n?.(Y);}},{id:"addSubtask",label:O?.contextMenu?.addSubtask||"Add Subtask",icon:Lt.Add,onClick:()=>{x?.(Y.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:O?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Lt.MarkIncomplete,onClick:()=>{h?.(Y.id,{status:"todo",progress:0});},disabled:Y.status==="todo"},{id:"setInProgress",label:O?.contextMenu?.setInProgress||"Set In Progress",icon:Lt.SetInProgress,onClick:()=>{h?.(Y.id,{status:"in-progress"});},disabled:Y.status==="in-progress"},{id:"markComplete",label:O?.contextMenu?.markComplete||"Mark Complete",icon:Lt.MarkComplete,onClick:()=>{h?.(Y.id,{status:"completed",progress:100});},disabled:Y.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:O?.contextMenu?.splitTask||"Split Task",icon:Lt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:O?.contextMenu?.deleteTask||"Delete Task",icon:Lt.Delete,onClick:()=>{L?L(Y.id,Y.name):f?.([Y.id]);}}],Ze=u.filter(Y=>Y.visible),ct=Ze.reduce((Y,ae)=>Y+ae.width,0);return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:ct},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${ta}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:Ze.map((Y,ae)=>{let Pe=ae===Ze.length-1,He=Y.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${He?"":"justify-center"}`,style:{width:`${Y.width}px`,minWidth:`${Y.minWidth??(He?200:60)}px`,maxWidth:`${Y.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Pe?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:D=>{D.preventDefault(),j({isOpen:true,x:D.clientX,y:D.clientY,type:"header",columnId:Y.id});},onMouseEnter:D=>{D.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:D=>{D.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:Y.label,children:Y.label}),Y.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:Fe===Y.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:D=>{D.preventDefault(),D.stopPropagation(),Oe(Y.id),H(D.clientX),W(Y.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"}})})]},Y.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(bn,{columns:u,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>Te(!we),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"})}),we&&jsxs("div",{ref:rt,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:Y=>Y.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:()=>Te(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:sa},children:gt.map(({task:Y,level:ae},Pe)=>{let He=ye(Y.id),D=ie===Y.id,A=D&&Ee==="above",G=D&&Ee==="below",pe=D&&Ee==="child",Ye={};return pe&&(Ye.backgroundColor=`${t.accent}15`,Ye.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":Y.id,className:`flex items-center cursor-pointer group ${q===Y.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:He?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:He?t.accentLight:pe?`${t.accent}15`:Pe%2===0?t.bgPrimary:t.bgGrid,...Ye},onMouseEnter:()=>T(Y.id),onMouseLeave:()=>T(null),onClick:Q=>{let Nt=po(e).map(oe=>oe.id),aa=navigator.platform.toUpperCase().indexOf("MAC")>=0?Q.metaKey:Q.ctrlKey;Ie(Y.id,Nt,aa,Q.shiftKey),s?.(Y);},onDoubleClick:Q=>{Q.stopPropagation(),n?.(Y);},onContextMenu:Q=>{Q.preventDefault(),j({isOpen:true,x:Q.clientX,y:Q.clientY,type:"task",task:Y}),c?.(Y,Q);},whileHover:{backgroundColor:He?t.accentLight:t.hoverBg},children:[A&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),G&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Ze.map((Q,Re)=>{let Nt=Re===Ze.length-1,Ae=Q.id==="name";return jsx("div",{className:`px-4 flex items-center ${Ae?"justify-start":"justify-center"}`,style:{width:`${Q.width}px`,minWidth:`${Q.minWidth??(Ae?200:60)}px`,maxWidth:`${Q.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Nt?"none":`1px solid ${M===Y.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:ze(Q,Y,Ae?ae:0)},`${Y.id}-${Q.id}`)})]},Y.id)})}),jsx(mo,{isOpen:N.isOpen,x:N.x,y:N.y,items:N.type==="header"&&N.columnId?Be(N.columnId):N.type==="task"&&N.task?Le(N.task):[],onClose:()=>j({...N,isOpen:false}),theme:t}),tt&&lt&&q&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:lt.x+12,top:lt.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let Y=gt.find(ae=>ae.task.id===q)?.task;return Y?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:Y.name})}):null})()}),document.body)]})}function oc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,c]=useState(e),[p,l]=useState(t),[u,d]=useState(null),[i,h]=useState(null),[C,m]=useState(null),[y,f]=useState(null),[v,g]=useState(0),[k,x]=useState(0),[S,L]=useState(null),[w,O]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:c,ghostWidth:p,setGhostWidth:l,connectionLine:u,setConnectionLine:d,hoveredTaskId:i,setHoveredTaskId:h,activeZone:C,setActiveZone:m,draggedSegmentIndex:y,setDraggedSegmentIndex:f,draggedSegmentStartX:v,setDraggedSegmentStartX:g,segmentDragOffsetX:k,setSegmentDragOffsetX:x,hoveredSegmentIndex:S,setHoveredSegmentIndex:L,isHovered:w,setIsHovered:O,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(J,te)=>{r("none"),d(null),h(null),c(J),l(te),x(0),f(null),g(0);}}}function kn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:c,onClick:p,onDoubleClick:l,onContextMenu:u,onDateChange:d,onDependencyCreate:i,allTaskPositions:h=[],onDragMove:C,onHoverChange:m}){let y=oc(t,r),f=useRef(null),{dragMode:v,setDragMode:g,dragOffset:k,setDragOffset:x,ghostX:S,setGhostX:L,ghostWidth:w,setGhostWidth:O,connectionLine:M,setConnectionLine:T,hoveredTaskId:_,setHoveredTaskId:B,activeZone:J,setActiveZone:te,draggedSegmentIndex:be,setDraggedSegmentIndex:Fe,draggedSegmentStartX:Oe,setDraggedSegmentStartX:je,segmentDragOffsetX:H,setSegmentDragOffsetX:z,hoveredSegmentIndex:W,setHoveredSegmentIndex:N,isHovered:j,setIsHovered:q,isDragging:R,isResizing:ie,isConnecting:ke,resetDragState:Ee}=y,ce=32,Ke=8,Me=e.endDate&&e.endDate<new Date&&e.progress<100,at=e.isCriticalPath,lt=o.name==="neutral"||o.today==="#1C1917",dt=e.status==="completed"||e.progress===100,tt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},ne=e.isCriticalPath||Me?"#DC2626":e.color?e.color:e.priority&&tt[e.priority]?tt[e.priority]:o.taskBarPrimary,we=(he=>he>=80?20:he>=60?15:he>=50?12:10)(r),Te=r<50,rt=r<40;useEffect(()=>{if(m)if(j&&!R&&!e.segments){let he=a<100;m({task:e,x:t,y:a,width:r,height:ce,showBelow:he});}else m(null);},[j,R,e,t,a,r,ce,m]);let wt=he=>he.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Ie=()=>{let he=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${he} day${he!==1?"s":""}`},ye=he=>Math.round(he/s)*s,Se=he=>{let E=Math.round(he/s),Z=new Date(n);return Z.setDate(Z.getDate()+E),Z},St=(he,E)=>{for(let Z of h){if(Z.id===e.id)continue;let me=5;if(he>=Z.x-me&&he<=Z.x+Z.width+me&&E>=Z.y-me&&E<=Z.y+Z.height+me)return Z.id}return null},gt=useCallback((he,E,Z)=>{he.preventDefault(),he.stopPropagation();let me=f.current?.ownerSVGElement;if(!me)return;let Ne=me.createSVGPoint();Ne.x=he.clientX,Ne.y=he.clientY;let ze=Ne.matrixTransform(me.getScreenCTM()?.inverse()),Be=Z!==void 0?Z:t,Le=E;if(!Le){let Ze=ze.x-Be;he.shiftKey?(Le="connect",T({x:t+r,y:a+ce/2})):he.ctrlKey||he.metaKey?Le="move":he.altKey?Le=Ze<r/2?"resize-start":"resize-end":rt?Ze<r/2?Le="move":Le="resize-end":Te?Ze<=we/2?Le="resize-start":Ze>=r-we/2?Le="resize-end":Le="move":Ze<=we?Le="resize-start":Ze>=r-we?Le="resize-end":Le="move";}g(Le),q(false),te(null),Le==="move"?x(ze.x-Be):Le==="connect"?T({x:t+r,y:a+ce/2}):x(0),L(Be),O(r);},[t,r,a,ce]),ta=useCallback(he=>{if(v==="none")return;let E=f.current?.ownerSVGElement;if(!E)return;let Z=E.createSVGPoint();Z.x=he.clientX,Z.y=he.clientY;let me=Z.matrixTransform(E.getScreenCTM()?.inverse());if(v==="connect"){T({x:me.x,y:me.y});let Ne=St(me.x,me.y);B(Ne);}else if(v==="move"){let Ne=me.x-k,ze=ye(Ne);L(ze),O(r);let Be=Math.round((ze-t)/s);if(C?.(e.id,Be,true),e.segments&&e.segments.length>0&&be!==null){let Le=ze-Oe;z(Le);}}else if(v==="resize-start"){let Ne=me.x,ze=ye(Ne),Be=t+r-ze;Be>=s&&(L(ze),O(Be));}else if(v==="resize-end"){let Ne=me.x,Be=ye(Ne)-t;Be>=s&&O(Be);}},[v,t,r,s,k,e,ye,be,Oe,St,B,T,L,O,z,C]),sa=useCallback(()=>{if(v!=="none"){if(v==="connect")_&&i&&i(e,_),T(null),B(null);else {let he=e.endDate.getTime()-e.startDate.getTime(),E,Z,me=true;if(v==="move"){if(E=Se(S),Z=new Date(E.getTime()+he),e.segments&&e.segments.length>0&&be!==null){let Ne=Math.round(H/s),ze=e.segments.map((ct,Y)=>{if(Y===be){let ae=new Date(ct.startDate),Pe=new Date(ct.endDate);return ae.setDate(ae.getDate()+Ne),Pe.setDate(Pe.getDate()+Ne),{startDate:ae,endDate:Pe}}return ct}),Be=ze.flatMap(ct=>[ct.startDate,ct.endDate]),Le=new Date(Math.min(...Be.map(ct=>ct.getTime()))),Ze=new Date(Math.max(...Be.map(ct=>ct.getTime())));d?.({...e,segments:ze},Le,Ze),Ee(t,r);return}}else v==="resize-start"?(E=Se(S),Z=e.endDate,E>Z&&(console.warn("Invalid date range: start date must be before or equal to end date"),me=false)):v==="resize-end"?(E=e.startDate,Z=Se(S+w),Z<E&&(console.warn("Invalid date range: end date must be after or equal to start date"),me=false)):me=false;me&&E&&Z&&(Z.getTime()<E.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,E,Z));}C?.(e.id,0,false),Ee(t,r);}},[v,S,w,e,d,_,i,t,r,s,Se,H,be,Ee,C]);useEffect(()=>{if(v==="none")return;let he=Z=>{ta(Z);},E=()=>{sa();};return window.addEventListener("mousemove",he),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",he),window.removeEventListener("mouseup",E);}},[v,ta,sa]);let Ge=R&&!ke?S:t,$e=R&&!ke?w:r,ia=c.taskClass(e);return jsxs("g",{ref:f,onMouseEnter:()=>!R&&q(true),onMouseLeave:()=>{R||(q(false),te(null));},onClick:()=>!R&&p?.(e),onDoubleClick:he=>{R||(he.stopPropagation(),l?.(e));},onContextMenu:he=>{he.preventDefault(),u?.(e,he);},children:[j&&!R&&!Te&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:we,height:ce,fill:J==="resize-start"?o.accent:"transparent",opacity:J==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-start"),onMouseDown:he=>gt(he,"resize-start")}),jsx("rect",{x:t+we,y:a,width:r-we*2,height:ce,fill:J==="move"?o.accent:"transparent",opacity:J==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>te("move"),onMouseDown:he=>gt(he,"move")}),jsx("rect",{x:t+r-we,y:a,width:we,height:ce,fill:J==="resize-end"?o.accent:"transparent",opacity:J==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-end"),onMouseDown:he=>gt(he,"resize-end")})]}),j&&!R&&rt&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:ce,fill:J==="move"?o.accent:"transparent",opacity:J==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>te("move"),onMouseDown:he=>gt(he,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:ce,fill:J==="resize-end"?o.accent:"transparent",opacity:J==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-end"),onMouseDown:he=>gt(he,"resize-end")}),j&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+ce-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),R&&!ke&&!e.segments&&jsx(motion.rect,{x:S,y:a,width:w,height:ce,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:Ge,y:a,width:$e,height:ce,rx:Ke,fill:ne,"data-task-class":ia,initial:{opacity:0,scale:.95},animate:{opacity:R&&!ke?.15:e.parentId?.6:j?.9:.8,scale:j&&!R?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:he=>gt(he),style:{cursor:R?ke?"crosshair":ie?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:Ge,y:a,width:$e*(e.progress/100),height:ce,rx:Ke,fill:ne,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((he,E)=>{let Z=(he.startDate.getTime()-n.getTime())/864e5*s,Ne=(he.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-Z+s,ze=R&&v==="move"&&be===E,Be=W===E,Le=ze?Z+H:Z;return jsxs("g",{onMouseEnter:()=>!R&&N(E),onMouseLeave:()=>!R&&N(null),children:[jsx(motion.rect,{x:Le,y:a,width:Ne,height:ce,rx:Ke,fill:ne,initial:{opacity:0,scale:.95},animate:{opacity:ze||e.parentId?.6:Be?.9:.8,scale:Be&&!R?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:Ze=>{Ze.stopPropagation(),Fe(E),je(Z),gt(Ze,void 0,Z);},style:{cursor:R?ke?"crosshair":ie?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Le,y:a,width:Ne*(e.progress/100),height:ce,rx:Ke,fill:ne,opacity:1,style:{pointerEvents:"none"}})]},`segment-${E}`)}),lt&&(Me||at)&&!e.segments&&jsxs(Fragment,{children:[at&&!Me&&jsx("rect",{x:Ge,y:a,width:$e,height:ce,rx:Ke,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Me&&jsx("rect",{x:Ge,y:a,width:$e,height:ce,rx:Ke,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),$e>60&&!e.segments&&(()=>{let he=c.taskLabel(e),E=typeof he=="string"?he:e.name,Z=E.length>Math.floor($e/8)?`${E.substring(0,Math.floor($e/8))}...`:E;return jsx("text",{x:Ge+12,y:a+ce/2,dominantBaseline:"middle",fill:dt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:dt?"line-through":"none"},children:Z})})(),$e>100&&e.progress>0&&e.progress<100&&!R&&!e.segments&&jsxs("text",{x:Ge+$e-12,y:a+ce/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&&$e>80&&!R&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:Ge+$e-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:Ge+$e-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(j||ie)&&!ke&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Te?Ge-15:Ge-10,y:a-5,width:Te?25:20,height:ce+10,fill:"transparent",onMouseDown:he=>gt(he,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Te?Ge-8:Ge-3,y:a+6,width:Te?8:6,height:Te?ce-12:ce-16,rx:3,fill:v==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:v==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ge+$e-10,y:a-5,width:Te?25:20,height:ce+10,fill:"transparent",onMouseDown:he=>gt(he,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Te?Ge+$e:Ge+$e-3,y:a+6,width:Te?8:6,height:Te?ce-12:ce-16,rx:3,fill:v==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:v==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:j&&!R&&!e.segments&&jsxs(motion.g,{style:{pointerEvents:"all"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx(motion.circle,{cx:t+r+8,cy:a+ce/2,r:6,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.2,type:"spring",stiffness:400,damping:25},onMouseDown:he=>{he.stopPropagation(),gt(he,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+ce/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),ke&&M&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+ce/2,x2:M.x,y2:M.y,stroke:_?o.statusCompleted:o.accent,strokeWidth:_?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:_?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:M.x,cy:M.y,r:_?8:6,fill:_?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),_&&jsx(motion.text,{x:M.x+15,y:M.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:M.x+10},animate:{opacity:1,x:M.x+15},transition:{duration:.2},children:"Connect"})]}),(j||R)&&!ke&&!e.segments&&jsx(motion.rect,{x:Ge-2,y:a-2,width:$e+4,height:ce+4,rx:Ke+2,fill:"none",stroke:R?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:R?.6:.4,initial:{opacity:0},animate:{opacity:R?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),ie&&jsxs(Fragment,{children:[jsx("line",{x1:S,y1:0,x2:S,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:S+w,y1:0,x2:S+w,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:j&&!R&&!e.segments&&!m&&(()=>{let Z=a<100,me=Z?a+ce+13:a-82-13,Ne=Z?`M ${Ge+$e/2-6} ${a+ce+3} L ${Ge+$e/2} ${a+ce+13} L ${Ge+$e/2+6} ${a+ce+3}`:`M ${Ge+$e/2-6} ${a-13} L ${Ge+$e/2} ${a-3} L ${Ge+$e/2+6} ${a-13}`,ze=me+22,Be=me+40,Le=me+55,Ze=me+70,ct=Z?me+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:Z?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:Z?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:Ne,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:Ge+$e/2-120,y:me,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:Ge+$e/2,y:ze,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:Ge+$e/2-110,y:Be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:Ge+$e/2-70,y:Be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:wt(e.startDate)}),jsx("text",{x:Ge+$e/2-110,y:Le,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:Ge+$e/2-70,y:Le,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:wt(e.endDate)}),jsx("text",{x:Ge+$e/2+10,y:Be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:Ge+$e/2+65,y:Be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ie()}),jsx("text",{x:Ge+$e/2+10,y:Le,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:Ge+$e/2+65,y:Le,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:Ge+$e/2-110,y:Ze,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:Ge+$e/2-50,y:Ze,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(Y=>Y.name).join(", ").substring(0,30),e.assignees.map(Y=>Y.name).join(", ").length>30?"...":""]})]}),!Z&&jsx("text",{x:Ge+$e/2,y:ct,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:rt?"Left: move \u2022 Right: resize":Te?"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 ic({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:c}=e,p=82,l=13,u=c?o+n+l:o-p-l,d=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}`,i=u+22,h=u+40,C=u+55,m=u+70,y=k=>k.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),f=()=>{if(!a.startDate||!a.endDate)return "N/A";let k=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${k} day${k!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:u,width:240,height:p,rx:8,fill:t.bgSecondary,stroke:t.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:r+s/2,y:i,textAnchor:"middle",fill:t.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:a.name.length>28?`${a.name.substring(0,28)}...`:a.name}),jsx("text",{x:r+s/2-110,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?y(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?y(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:f()}),jsx("text",{x:r+s/2+10,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.progress,"%"]}),a.assignees&&a.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:r+s/2-110,y:m,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:m,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(k=>k.name).join(", ").substring(0,30),a.assignees.map(k=>k.name).join(", ").length>30?"...":""]})]})]})})}function Tn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:n}){let[c,p]=useState(false),l=a-e,u=r-t,d=e+l/2,i=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,h=6,C=Math.atan2(u,l),m=a-h*Math.cos(C-Math.PI/6),y=r-h*Math.sin(C-Math.PI/6),f=a-h*Math.cos(C+Math.PI/6),v=r-h*Math.sin(C+Math.PI/6),g=o.dependency;useEffect(()=>{n&&s&&n(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,n]);let k=!s&&!n;return jsxs("g",{onMouseEnter:()=>!k&&p(true),onMouseLeave:()=>!k&&p(false),style:{pointerEvents:k?"none":"auto"},children:[!k&&jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&n?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${m} ${y} M ${a} ${r} L ${f} ${v}`,fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&n?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:g,initial:{scale:0},animate:{scale:c&&n?0:c?1.3:1,opacity:c&&n?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!n&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:x=>{x.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function Dn({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),c=16,p=l=>l.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>n(true),onMouseLeave:()=>n(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:p(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var ue={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=l=>{l.forEach(u=>{u.dependencies&&r.set(u.id,u.dependencies),u.subtasks&&o(u.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let n=new Set,c=new Set,p=l=>{if(!n.has(l)){n.add(l),c.add(l);let u=r.get(l)||[];for(let d of u){if(!n.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(l),false};return p(a)},flattenTasks:e=>{let t=[],a=r=>{r.forEach(o=>{t.push(o),o.subtasks&&o.subtasks.length>0&&a(o.subtasks);});};return a(e),t},findTaskById:(e,t)=>{for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=ue.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=ue.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=ue.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=ue.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
+ `)},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=ue.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=ue.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)=>ue.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=ue.findTaskById(e,t);return !a||!a.dependencies?[]:ue.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>ue.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>ue.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=ue.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=>ue.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=ue.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(p=>{let l=p.startDate&&p.endDate?ue.calculateDuration(p.startDate,p.endDate):0;return [p.name,p.startDate?ue.formatDate(p.startDate):"N/A",p.endDate?ue.formatDate(p.endDate):"N/A",l>0?`${l} days`:"N/A",`${p.progress}%`,p.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=ue.flattenTasks(e).map(p=>{let l=p.startDate&&p.endDate?ue.calculateDuration(p.startDate,p.endDate):0;return {"Task ID":p.id,"Task Name":p.name,"Start Date":p.startDate?ue.formatDate(p.startDate):"","End Date":p.endDate?ue.formatDate(p.endDate):"","Duration (days)":l>0?l:"","Progress (%)":p.progress,Status:p.status||"",Assignees:p.assignees?.map(u=>u.name).join(", ")||"",Dependencies:p.dependencies?.join(", ")||"","Is Milestone":p.isMilestone?"Yes":"No","Parent ID":p.parentId||"",Level:p.level||0}}),s=a.utils.json_to_sheet(o),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=ue.flattenTasks(e),o=new Map;r.forEach((i,h)=>{o.set(i.id,h+1);});let s=i=>i.toISOString().replace("Z",""),n=ue.getEarliestStartDate(e)||new Date,c=ue.getLatestEndDate(e)||new Date,p=r.map((i,h)=>{let C=o.get(i.id),m=i.startDate&&i.endDate?ue.calculateDuration(i.startDate,i.endDate):0,y=(i.dependencies||[]).filter(f=>o.has(f)).map(f=>`
113
113
  <PredecessorLink>
114
114
  <PredecessorUID>${o.get(f)}</PredecessorUID>
115
115
  <Type>1</Type>
@@ -130,9 +130,9 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
130
130
  <Priority>500</Priority>
131
131
  <Start>${i.startDate?s(i.startDate):""}</Start>
132
132
  <Finish>${i.endDate?s(i.endDate):""}</Finish>
133
- <Duration>PT${p*8}H0M0S</Duration>
133
+ <Duration>PT${m*8}H0M0S</Duration>
134
134
  <DurationFormat>7</DurationFormat>
135
- <Work>PT${p*8}H0M0S</Work>
135
+ <Work>PT${m*8}H0M0S</Work>
136
136
  <Stop>${i.endDate?s(i.endDate):""}</Stop>
137
137
  <Resume>${i.startDate?s(i.startDate):""}</Resume>
138
138
  <ResumeValid>0</ResumeValid>
@@ -164,15 +164,15 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
164
164
  <OvertimeWork>PT0H0M0S</OvertimeWork>
165
165
  <ActualStart>${i.progress>0&&i.startDate?s(i.startDate):""}</ActualStart>
166
166
  <ActualFinish>${i.progress===100&&i.endDate?s(i.endDate):""}</ActualFinish>
167
- <ActualDuration>PT${Math.round(p*i.progress/100)*8}H0M0S</ActualDuration>
167
+ <ActualDuration>PT${Math.round(m*i.progress/100)*8}H0M0S</ActualDuration>
168
168
  <ActualCost>0</ActualCost>
169
169
  <ActualOvertimeCost>0</ActualOvertimeCost>
170
- <ActualWork>PT${Math.round(p*i.progress/100)*8}H0M0S</ActualWork>
170
+ <ActualWork>PT${Math.round(m*i.progress/100)*8}H0M0S</ActualWork>
171
171
  <ActualOvertimeWork>PT0H0M0S</ActualOvertimeWork>
172
- <RegularWork>PT${p*8}H0M0S</RegularWork>
173
- <RemainingDuration>PT${Math.round(p*(100-i.progress)/100)*8}H0M0S</RemainingDuration>
172
+ <RegularWork>PT${m*8}H0M0S</RegularWork>
173
+ <RemainingDuration>PT${Math.round(m*(100-i.progress)/100)*8}H0M0S</RemainingDuration>
174
174
  <RemainingCost>0</RemainingCost>
175
- <RemainingWork>PT${Math.round(p*(100-i.progress)/100)*8}H0M0S</RemainingWork>
175
+ <RemainingWork>PT${Math.round(m*(100-i.progress)/100)*8}H0M0S</RemainingWork>
176
176
  <RemainingOvertimeCost>0</RemainingOvertimeCost>
177
177
  <RemainingOvertimeWork>PT0H0M0S</RemainingOvertimeWork>
178
178
  <ACWP>0</ACWP>
@@ -337,11 +337,11 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
337
337
  </WeekDays>
338
338
  </Calendar>
339
339
  </Calendars>
340
- <Tasks>${m}
340
+ <Tasks>${p}
341
341
  </Tasks>
342
- </Project>`,u=new Blob([l],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=me.flattenTasks(e),a=t.filter(l=>l.startDate&&l.endDate);if(a.length===0)return [];let r=new Map,o=l=>{if(r.has(l.id))return;let u=l.startDate&&l.endDate?me.calculateDuration(l.startDate,l.endDate):0,d=0;if(l.dependencies&&l.dependencies.length>0)for(let h of l.dependencies){let C=t.find(p=>p.id===h);if(C){o(C);let p=r.get(h)?.ef||0;d=Math.max(d,p);}}let i=d+u;r.set(l.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(l=>l.ef)),n=new Map,c=l=>{if(n.has(l.id))return;let u=l.startDate&&l.endDate?me.calculateDuration(l.startDate,l.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(l.id)),i=s;if(d.length>0)for(let C of d){c(C);let p=n.get(C.id)?.ls||0;i=Math.min(i,p);}let h=i-u;n.set(l.id,{ls:h,lf:i});};a.forEach(c);let m=[];for(let l of a){let u=r.get(l.id),d=n.get(l.id);if(u&&d){let i=d.ls-u.es;Math.abs(i)<.01&&m.push(l.id);}}return m},calculateSlack:(e,t)=>{let a=me.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(me.calculateCriticalPath(e).includes(t))return 0;let o=me.getDependentTasks(e,t);if(o.length===0){let c=me.getLatestEndDate(e);if(!c)return null;let m=me.calculateDuration(a.endDate,c);return Math.max(0,m)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,m)=>c-m)[0];if(!s)return null;let n=me.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>me.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=me.findTaskById(e,t);if(!r||!r.endDate)return e;let o=me.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=me.calculateDuration(n.startDate,n.endDate),m;a!==void 0?(m=new Date(n.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let l=me.calculateEndDate(m,c),u=d=>d.map(i=>i.id===n.id?{...i,startDate:m,endDate:l}:i.subtasks?{...i,subtasks:u(i.subtasks)}:i);s=u(s),s=me.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,c)=>{if(a===0)return [];let m=[],l=o.getTime(),u=1e3*60*60*24,d=me.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(h,C,p=new Set)=>{if(p.has(h))return;p.add(h);let y=me.getDependentTasks(e,h);for(let f of y){if(!f.startDate||!f.endDate)continue;let v=r.findIndex(T=>T.id===f.id);if(v===-1)continue;let g=f.startDate.getTime(),x=(f.endDate.getTime()-g)/u,B=(g-l)/u*s,w=B+C*s,z=Math.max(x*s,s),P=c+v*n+12;m.push({taskId:f.id,taskName:f.name,originalX:B,previewX:w,width:z,y:P,rowIndex:v,daysDelta:C,color:f.color}),i(f.id,C,p);}};return i(t,a),m},splitTask:(e,t,a,r=3)=>{let o=me.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 m=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:c}],l=u=>u.map(d=>d.id===o.id?{...d,endDate:c,segments:m}:d.subtasks?{...d,subtasks:l(d.subtasks)}:d);return l(e)}};function En({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:c,onTaskClick:m,onTaskDblClick:l,onTaskContextMenu:u,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:h}){let[p,y]=useState([]),[f,v]=useState(null),[g,k]=useState(null),x=useCallback(O=>{v(O);},[]),D=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),B=r==="day"?60:r==="week"?20:8,w=D*B*n,z=O=>{let L=new Date(Date.UTC(O.getFullYear(),O.getMonth(),O.getDate())),H=L.getUTCDay()||7;L.setUTCDate(L.getUTCDate()+4-H);let F=new Date(Date.UTC(L.getUTCFullYear(),0,1));return Math.ceil(((L.getTime()-F.getTime())/864e5+1)/7)},P=O=>{let L=O.getDay();return L===0||L===6},T=useCallback(O=>{let L=Math.round(O/(B*n)),H=new Date(o);return H.setDate(H.getDate()+L),H},[o,B,n]),G=useCallback((O,L)=>{if(L.startDate&&L.endDate)return;let H=O.currentTarget.ownerSVGElement;if(!H)return;let F=H.createSVGPoint();F.x=O.clientX,F.y=O.clientY;let X=F.matrixTransform(H.getScreenCTM()?.inverse()),Q=T(X.x),U=new Date(Q);U.setDate(U.getDate()+1),d?.(L,Q,U);},[T,d]),R=useMemo(()=>{let O=X=>X.map(Q=>{if(Q.subtasks&&Q.subtasks.length>0){let U=O(Q.subtasks),ke=U.filter(Te=>Te.startDate&&Te.endDate);if(ke.length>0){let Te=ke.map(Ie=>Ie.startDate.getTime()),Fe=ke.map(Ie=>Ie.endDate.getTime()),ve=new Date(Math.min(...Te)),et=new Date(Math.max(...Fe));return {...Q,subtasks:U,startDate:ve,endDate:et}}return {...Q,subtasks:U}}return Q}),L=(X,Q=[])=>{for(let U of X)Q.push(U),U.subtasks&&U.subtasks.length>0&&(U.isExpanded===void 0||U.isExpanded)&&L(U.subtasks,Q);return Q},H=O(e);return L(H)},[e]),q=useCallback(O=>{if(!O.startDate||!O.endDate)return {x:0,width:0};let L=O.startDate.getTime(),H=O.endDate.getTime(),F=o.getTime(),X=(L-F)/(1e3*60*60*24),Q=(H-L)/(1e3*60*60*24),U=X*B*n,ke=Math.max(B*n,40),Te=Math.max(Q*B*n,ke);return {x:U,width:Te}},[o,B,n]),te=useMemo(()=>R.filter(O=>O.startDate&&O.endDate).map(O=>{let{x:L,width:H}=q(O),X=R.findIndex(Q=>Q.id===O.id)*a+12;return {id:O.id,x:L,y:X,width:H,height:32}}),[R,q]),xe=useCallback((O,L,H)=>{if(!H||L===0){y([]);return}let F=me.calculateCascadePreview(e,O,L,R,o,B*n,a,48);y(F);},[e,R,o,B,n,a,48]),Ae=useMemo(()=>{let O=[],L=new Date(o);for(;L<=s;){let X=(L.getTime()-o.getTime())/864e5*B*n;if(r==="day")O.push({date:new Date(L),label:L.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:X}),L.setDate(L.getDate()+1);else if(r==="week"){let Q=z(L);O.push({date:new Date(L),label:`Week ${Q}`,x:X}),L.setDate(L.getDate()+7);}else O.push({date:new Date(L),label:L.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:X}),L.setMonth(L.getMonth()+1);}return O},[o,s,r,B,n]),ze=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*B*n,[o,B,n]),le=Math.max(R.length*a,552);return jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},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(w,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(w,1e3),height:48,fill:t.bgGrid}),Ae.map((O,L)=>jsxs("g",{children:[L>0&&jsx("line",{x1:O.x,y1:0,x2:O.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:O.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:O.label})]},`header-${L}`)),ze>=0&&ze<=w&&jsx("circle",{cx:ze,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(w,1e3),height:le,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(w,1e3),height:le,fill:t.bgPrimary}),Ae.map((O,L)=>{let H=Ae[L+1]?.x||w,F=P(O.date);return jsxs("g",{children:[F&&jsx("rect",{x:O.x,y:0,width:H-O.x,height:R.length*a,fill:t.bgWeekend,opacity:1}),L>0&&jsx("line",{x1:O.x,y1:0,x2:O.x,y2:R.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},L)}),R.map((O,L)=>{let H=O.startDate&&O.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:L*a,width:w,height:a,fill:L%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${O.id}`),!H&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:L*a,width:w,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:F=>G(F,O),onMouseEnter:F=>{F.currentTarget.setAttribute("fill",t.accentLight),F.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:F=>{F.currentTarget.setAttribute("fill","transparent"),F.currentTarget.setAttribute("opacity","1");}},`clickable-${O.id}`),jsx("text",{x:ze>0?ze:100,y:L*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${O.id}`)]})]},`row-group-${O.id}`)}),R.map((O,L)=>!O.dependencies||O.dependencies.length===0||!O.startDate||!O.endDate?null:O.dependencies.map(H=>{let F=R.find(ke=>ke.id===H);if(!F||!F.startDate||!F.endDate)return null;let X=R.findIndex(ke=>ke.id===H),Q=q(F),U=q(O);return jsx(Tn,{x1:Q.x+Q.width,y1:X*a+a/2,x2:U.x,y2:L*a+a/2,theme:t},`dep-${H}-${O.id}`)})),R.map((O,L)=>{if(!O.startDate||!O.endDate)return null;let{x:H,width:F}=q(O),X=L*a+12,Q=O.subtasks&&O.subtasks.length>0&&!O.isMilestone;return O.isMilestone?jsx(Dn,{task:O,x:H+F/2,y:X+16,theme:t,onClick:m},O.id):Q?jsxs("g",{onClick:()=>m?.(O),onContextMenu:U=>{U.preventDefault(),U.stopPropagation(),u?.(O,U);},style:{cursor:"default"},children:[jsx("rect",{x:H,y:X,width:F,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:H,y1:X,x2:H+F,y2:X,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:H,y1:X,x2:H,y2:X+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:H+F,y1:X,x2:H+F,y2:X+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:H,y1:X+32,x2:H+F,y2:X+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),F>60&&jsx("text",{x:H+12,y:X+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:O.name})]},O.id):jsx(kn,{task:O,x:H,y:X,width:F,theme:t,dayWidth:B*n,startDate:o,templates:c,onClick:m,onDoubleClick:l,onContextMenu:u,onDateChange:d,onDependencyCreate:i,allTaskPositions:te,onDragMove:xe,onHoverChange:x},O.id)}),R.map((O,L)=>!O.dependencies||O.dependencies.length===0||!O.startDate||!O.endDate?null:O.dependencies.map(H=>{let F=R.find(re=>re.id===H);if(!F||!F.startDate||!F.endDate)return null;let X=R.findIndex(re=>re.id===H),Q=q(F),U=q(O),ke=Q.x+Q.width,Te=X*a+a/2,Fe=U.x,ve=L*a+a/2,et=Fe-ke,Ie=ke+et/2,pt=re=>{let we=1-re,Ne=we*we,at=Ne*we,wt=re*re,Le=wt*re,he=at*ke+3*Ne*re*Ie+3*we*wt*Ie+Le*Fe,Ee=at*Te+3*Ne*re*Te+3*we*wt*ve+Le*ve;return {x:he,y:Ee}},it=20,lt=[];for(let re=0;re<=it;re++){let we=.1+re/it*.8;lt.push(pt(we));}let tt=lt[0],$=`M ${tt.x} ${tt.y} `+lt.slice(1).map(re=>`L ${re.x} ${re.y}`).join(" ");return g&&g.x1===ke&&g.y1===Te&&g.x2===Fe&&g.y2===ve?null:jsx("path",{d:$,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{k({x1:ke,y1:Te,x2:Fe,y2:ve,onDelete:()=>h?.(O.id,H)});}},`dep-hover-${H}-${O.id}`)})),p.map(O=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:O.previewX,y:O.y-48,width:O.width,height:32,rx:8,fill:O.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(O.daysDelta)>0&&jsx("text",{x:O.previewX+O.width/2,y:O.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:O.daysDelta>0?`+${O.daysDelta}d`:`${O.daysDelta}d`})]},`cascade-preview-${O.taskId}`)),g&&(()=>{let{x1:O,y1:L,x2:H,y2:F,onDelete:X}=g,Q=H-O,U=F-L,ke=O+Q/2,Te=(L+F)/2,Fe=`M ${O} ${L} C ${ke} ${L}, ${ke} ${F}, ${H} ${F}`,ve=6,et=Math.atan2(U,Q),Ie=H-ve*Math.cos(et-Math.PI/6),pt=F-ve*Math.sin(et-Math.PI/6),it=H-ve*Math.cos(et+Math.PI/6),lt=F-ve*Math.sin(et+Math.PI/6),tt=t.dependency,$="#f87171";return jsxs("g",{onMouseLeave:()=>k(null),children:[jsx("path",{d:Fe,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:ke,cy:Te,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:Fe,fill:"none",stroke:tt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:Fe,fill:"none",stroke:tt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${H} ${F} L ${Ie} ${pt} M ${H} ${F} L ${it} ${lt}`,fill:"none",stroke:tt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:H,cy:F,r:4,fill:tt,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:re=>{re.stopPropagation(),k(null),X();},style:{cursor:"pointer"},children:[jsx("circle",{cx:ke,cy:Te,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:$,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:ke-3,y1:Te-3,x2:ke+3,y2:Te+3,stroke:$,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:ke+3,y1:Te-3,x2:ke-3,y2:Te+3,stroke:$,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),ze>=0&&ze<=w&&jsx("line",{x1:ze,y1:0,x2:ze,y2:le,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),f&&jsx(ic,{tooltipData:f,theme:t})]})]})}var o0=['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"'],cc=()=>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"})]}),n0=()=>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"})}),s0=()=>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"})}),i0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),l0=()=>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 Pn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:c,onDependencyDelete:m}){let[l,u]=useState(false),[d,i]=useState(false),[h,C]=useState([]),[p,y]=useState(""),[f,v]=useState(false),[g,k]=useState(true),x=useRef(null),D=useRef(null),B=useRef(null),{enabled:w=true,placeholder:z='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:P="bottom-right",onCommand:T,suggestions:G=o0,maxHistory:R=50,persistHistory:q}=a,te=q?.storageKey||"gantt-ai-history",xe=q?.maxMessages??5;useEffect(()=>{if(q?.enabled)try{let H=localStorage.getItem(te);if(H){let X=JSON.parse(H).map(Q=>({...Q,timestamp:new Date(Q.timestamp)}));C(X.slice(-xe));}}catch(H){console.warn("[GanttAIAssistant] Failed to load persisted history:",H);}},[q?.enabled,te,xe]),useEffect(()=>{if(q?.enabled&&h.length>0)try{let H=h.filter(F=>!F.isLoading).slice(-xe);localStorage.setItem(te,JSON.stringify(H));}catch(H){console.warn("[GanttAIAssistant] Failed to persist history:",H);}},[h,q?.enabled,te,xe]),useEffect(()=>{D.current&&D.current.scrollIntoView({behavior:"smooth"});},[h]),useEffect(()=>{l&&!d&&x.current&&setTimeout(()=>x.current?.focus(),100);},[l,d]);let Ae=useCallback(H=>{if(H.success)switch(H.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":H.taskId&&H.updates&&o?.(H.taskId,H.updates);break;case "create_task":H.newTask&&s?.(H.newTask);break;case "delete_task":H.taskId&&n?.(H.taskId);break;case "link_tasks":H.dependencyFrom&&H.dependencyTo&&c?.(H.dependencyFrom,H.dependencyTo);break;case "unlink_tasks":H.taskId&&H.dependencyFrom&&m?.(H.taskId,H.dependencyFrom);break}},[o,s,n,c,m]),ze=useCallback(async H=>{if(!H.trim()||f)return;let F={id:`user-${Date.now()}`,role:"user",content:H,timestamp:new Date};C(Q=>[...Q.slice(-(R-1)),F]),y(""),k(false),v(true);let X={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(Q=>[...Q,X]);try{if(T){let Q=await T(H,e);C(U=>{let ke=U.filter(Fe=>!Fe.isLoading),Te={id:`assistant-${Date.now()}`,role:"assistant",content:Q.message,timestamp:new Date,command:Q};return [...ke,Te]}),Ae(Q);}else C(Q=>[...Q.filter(ke=>!ke.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){C(U=>[...U.filter(Te=>!Te.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${Q instanceof Error?Q.message:"Unknown error"}`,timestamp:new Date}]);}finally{v(false);}},[f,R,T,e,Ae]),le=H=>{H.preventDefault(),ze(p);},O=H=>{y(H),x.current?.focus();};if(useEffect(()=>{let H=F=>{(F.metaKey||F.ctrlKey)&&F.key==="k"&&(F.preventDefault(),u(X=>!X),l||i(false)),F.key==="Escape"&&l&&u(false);};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[l]),useEffect(()=>{if(!l)return;let H=X=>{let Q=X.target;B.current&&!B.current.contains(Q)&&u(false);},F=setTimeout(()=>{document.addEventListener("mousedown",H);},100);return ()=>{clearTimeout(F),document.removeEventListener("mousedown",H);}},[l]),!w)return null;let L={"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(mt,{children:[jsx(AnimatePresence,{children:!l&&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 ${L[P]} 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:()=>u(true),children:[jsx(cc,{}),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:l&&jsxs(motion.div,{ref:B,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${L[P]} 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(cc,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>i(H=>!H),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(i0,{})}),jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(s0,{})})]})]}),jsx(AnimatePresence,{children:!d&&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:[h.length===0&&g&&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:G.slice(0,4).map((H,F)=>jsx("button",{onClick:()=>O(H),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:H.length>30?H.slice(0,30)+"...":H},F))})]}),h.map(H=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${H.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${H.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:H.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:H.role==="user"?"white":t.textPrimary},children:[H.isLoading?jsx(l0,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:H.content}),H.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:H.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:H.command.success?"#10B981":"#EF4444"},children:[H.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:H.command.type.replace(/_/g," ")})]})]})},H.id)),jsx("div",{ref:D})]}),jsxs("form",{onSubmit:le,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:x,type:"text",value:p,onChange:H=>y(H.target.value),placeholder:z,disabled:f,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!p.trim()||f,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:p.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:p.trim()?"white":t.textSecondary},children:jsx(n0,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function pc(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((l,u=true)=>{r(d=>{let i=typeof l=="function"?l(d.present):l;if(o.current)return {...d,present:i};if(!u)return {...d,present:i};let h=[...d.past,d.present];return h.length>t&&h.shift(),{past:h,present:i,future:[]}});},[t]),n=useCallback(()=>{r(l=>{if(l.past.length===0)return l;let u=l.past[l.past.length-1],d=l.past.slice(0,l.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:u,future:[l.present,...l.future]}});},[]),c=useCallback(()=>{r(l=>{if(l.future.length===0)return l;let u=l.future[0],d=l.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...l.past,l.present],present:u,future:d}});},[]),m=useCallback(()=>{r(l=>({past:[],present:l.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:m}}function mc({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,m=c?n.metaKey:n.ctrlKey;if(m&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!c&&m&&n.key==="y"){n.preventDefault(),t();return}if(c&&m&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var m0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${me.formatDate(e.startDate)} - ${me.formatDate(e.endDate)}`);let a=me.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=>me.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function uc(e){return {...m0,...e}}var v0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},hc=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:c="comfortable",showThemeSelector:m=true,showExportButton:l=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:i=true,persistExpandedState:h,aiAssistant:C,locale:p="en",customTranslations:y,showCreateTaskButton:f=false,createTaskLabel:v,onCreateTask:g,onThemeChange:k,onTaskClick:x,onTaskDblClick:D,onTaskContextMenu:B,onTaskUpdate:w,onProgressChange:z,onTaskEdit:P,onTaskAddSubtask:T,onTaskMarkIncomplete:G,onTaskSetInProgress:R,onDependencyCreate:q,onDependencyDelete:te,onBeforeTaskAdd:xe,onAfterTaskAdd:Ae,onBeforeTaskUpdate:ze,onAfterTaskUpdate:le,onBeforeTaskDelete:O,onAfterTaskDelete:L}=a,F=useContext(gn)?.theme,[X,Q]=useState(F||s||"dark"),[U,ke]=useState(n),[Te,Fe]=useState(c),[ve,et]=useState(1),[Ie,pt]=useState(0),[it,lt]=useState(false),[tt,$]=useState(null),[ne,re]=useState({isOpen:false,x:0,y:0,task:null}),[we,Ne]=useState(null),[at,wt]=useState(null);useEffect(()=>{F&&F!==X&&Q(F);},[F]),useEffect(()=>{s&&s!==X&&Q(s);},[s]);let Le=useCallback(A=>{Q(A),k?.(A);},[k]),{state:he,setState:Ee,undo:St,redo:gt,canUndo:ta,canRedo:sa,clearHistory:_e}=pc(t,50),He=useCallback(()=>h?typeof h=="string"?h:"gantt-expanded-tasks":null,[h]),ia=useRef(new Map),fe=useRef(false);if(!fe.current&&h){fe.current=true;let A=typeof h=="string"?h:"gantt-expanded-tasks";try{let I=localStorage.getItem(A);if(I){let V=JSON.parse(I);Array.isArray(V)&&(ia.current=new Map(V));}}catch(I){console.warn("[GanttBoard] Error loading expanded state from localStorage:",I);}}let S=useCallback(()=>{let A=He();if(A)try{let I=Array.from(ia.current.entries());localStorage.setItem(A,JSON.stringify(I));}catch(I){console.warn("[GanttBoard] Error saving expanded state to localStorage:",I);}},[He]);useEffect(()=>{let A=I=>I.map(V=>{let se=ia.current.get(V.id),ge=se!==void 0?{...V,isExpanded:se}:V;return ge.subtasks?.length?{...ge,subtasks:A(ge.subtasks)}:ge});ia.current.size>0?Ee(A(t)):Ee(t);},[t,Ee]);let J=useRef(t),ce=useRef(true);useEffect(()=>{if(ce.current){ce.current=false,J.current=he;return}if(!r)return;let A=JSON.stringify(J.current),I=JSON.stringify(he);A!==I&&(J.current=he,r(he));},[he,r]);let De=useMemo(()=>qs(p,y),[p,y]),Ue=useCallback(A=>[{id:"name",label:A.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:A.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:A.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:A.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:A.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:A.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:A.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:A.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Re,Be]=useState(()=>Ue(De));useEffect(()=>{Be(A=>A.map(I=>({...I,label:De.columns[I.id==="name"?"taskName":I.id]||I.label})));},[De]);let Je=useMemo(()=>Re.filter(I=>I.visible).reduce((I,V)=>I+V.width,0),[Re]),dt=useRef(Re.filter(A=>A.visible).map(A=>A.id).join(","));useEffect(()=>{let A=Re.filter(se=>se.visible),I=A.map(se=>se.id).join(","),V=dt.current;if(I!==V){let se=A.some(Se=>Se.id!=="name"),ge=V.includes(",");se?!ge&&se&&$(null):$(null),dt.current=I;}},[Re]);let K=60,ae=.6,Pe=useMemo(()=>{let I=Je+K,V=typeof window<"u"?window.innerWidth*ae:800,se=Math.max(I,V);return tt!==null?Math.max(200,Math.min(tt,se)):Math.max(200,I)},[tt,Je]),We=useRef(null),N=useRef(null),M=useRef(null),_=useMemo(()=>Id(X),[X]),pe=useMemo(()=>({theme:_,themeName:X}),[_,X]),Ke=useMemo(()=>uc(d),[d]),Z=useMemo(()=>{if(!i)return he;let A=me.calculateCriticalPath(he),I=V=>V.map(se=>({...se,isCriticalPath:A.includes(se.id),subtasks:se.subtasks?I(se.subtasks):void 0}));return I(he)},[he,i]),Oe=v0(Te);mc({undo:St,redo:gt,canUndo:ta,canRedo:sa,enabled:true}),useImperativeHandle(o,()=>({getTask:A=>me.findTaskById(he,A),addTask:(A,I)=>{Ee(V=>{if(!I)return [...V,{...A,level:0}];let se=ge=>ge.map(Se=>Se.id===I?{...Se,subtasks:[...Se.subtasks||[],{...A,parentId:I,level:(Se.level||0)+1}],isExpanded:true}:Se.subtasks?{...Se,subtasks:se(Se.subtasks)}:Se);return se(V)});},updateTask:(A,I)=>{Ee(V=>{let se=ge=>ge.map(Se=>Se.id===A?{...Se,...I}:Se.subtasks?{...Se,subtasks:se(Se.subtasks)}:Se);return se(V)});},deleteTask:A=>{Ee(I=>{let V=se=>se.filter(ge=>ge.id===A?false:(ge.subtasks&&(ge.subtasks=V(ge.subtasks)),true));return V(I)});},deleteTasks:A=>{Ee(I=>ai(I,A));},duplicateTask:A=>{Ee(I=>ri(I,[A]));},splitTask:(A,I,V=3)=>{Ee(se=>me.splitTask(se,A,I,V));},calculateEndDate:me.calculateEndDate,calculateDuration:me.calculateDuration,validateDependency:(A,I)=>!me.validateDependencies(he,A,I),getAllTasks:()=>me.flattenTasks(he),getTasksByStatus:A=>me.flattenTasks(he).filter(I=>I.status===A),getTasksByParent:A=>A?me.findTaskById(he,A)?.subtasks||[]:he.filter(V=>!V.parentId),getCriticalPath:()=>me.flattenTasks(he).filter(A=>A.isCriticalPath),indentTask:A=>{Ee(I=>Qs(I,[A]));},outdentTask:A=>{Ee(I=>ei(I,[A]));},moveTask:(A,I)=>{Ee(V=>ti(V,[A],I));},createSubtask:async A=>{let{tasks:I,newTask:V}=si(he,A);if(xe){let se=xe({...V,parentId:A});if((se instanceof Promise?await se:se)===false)return}Ee(I),Ae&&Ae({...V,parentId:A});},scrollToTask:A=>{let V=me.flattenTasks(he).findIndex(se=>se.id===A);if(V!==-1&&We.current){let se=V*Oe;We.current.scrollTo({top:se,behavior:"smooth"}),N.current&&N.current.scrollTo({top:se,behavior:"smooth"});}},highlightTask:(A,I=2e3)=>{},expandTask:A=>{Ee(I=>{let V=se=>se.map(ge=>ge.id===A?{...ge,isExpanded:true}:ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge);return V(I)});},collapseTask:A=>{Ee(I=>{let V=se=>se.map(ge=>ge.id===A?{...ge,isExpanded:false}:ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge);return V(I)});},expandAll:()=>{Ee(A=>{let I=V=>V.map(se=>({...se,isExpanded:true,subtasks:se.subtasks?I(se.subtasks):void 0}));return I(A)});},collapseAll:()=>{Ee(A=>{let I=V=>V.map(se=>({...se,isExpanded:false,subtasks:se.subtasks?I(se.subtasks):void 0}));return I(A)});},undo:St,redo:gt,canUndo:()=>ta,canRedo:()=>sa,clearHistory:_e,exportToPNG:async()=>{if(!M.current||!We.current||!N.current)throw new Error("Gantt container not found");let A=M.current,I=We.current.querySelector(".gantt-grid-scroll"),V=N.current,se=I?.scrollTop||0,ge=V.scrollTop,Se=A.style.overflow,yt=A.style.height;try{let Kt=I?.querySelector(".gantt-taskgrid-content"),ga=V.querySelector("svg"),fa=Kt?.scrollHeight||I?.scrollHeight||600,Na=ga?.getBoundingClientRect().height||V.scrollHeight,Pr=(A.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(fa,Na)+20;I&&(I.scrollTop=0),V.scrollTop=0,A.style.overflow="visible",A.style.height=`${Pr}px`,await new Promise(ur=>setTimeout(ur,100));let mr=await fc(A,{backgroundColor:_.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:ur=>{let Jr=window.getComputedStyle(ur),Mr=parseInt(Jr.zIndex,10);return !isNaN(Mr)&&Mr>=50||Jr.position==="fixed"}});return new Promise((ur,Jr)=>{mr.toBlob(Mr=>{Mr?ur(Mr):Jr(new Error("Failed to create blob from canvas"));},"image/png");})}finally{A.style.overflow=Se,A.style.height=yt,I&&(I.scrollTop=se),V.scrollTop=ge;}},exportToPDF:async A=>{await me.exportToPDF(he,A);},exportToExcel:async A=>{await me.exportToExcel(he,A);},exportToJSON:()=>me.exportToJSON(he),exportToCSV:()=>me.exportToCSV(he),importFromJSON:A=>{let I=me.importFromJSON(A);Ee(I);},getTasks:()=>he,refresh:()=>{Ee(A=>[...A]);},clearAll:()=>{Ee([]);}}),[he,St,gt,ta,sa,_e,_,Oe]);let Nt=useCallback(A=>{Be(I=>I.map(V=>V.id===A?{...V,visible:!V.visible}:V));},[]),Me=useCallback((A,I)=>{Be(V=>V.map(se=>{if(se.id!==A)return se;let ge=se.minWidth??100,Se=se.maxWidth??800,yt=Math.max(ge,Math.min(Se,I));return {...se,width:yt}}));},[]),aa=useCallback(A=>{Ee(I=>{let V=ni(I,A),se=ge=>{for(let Se of ge){if(Se.id===A){ia.current.set(A,Se.isExpanded??true);return}Se.subtasks?.length&&se(Se.subtasks);}};return se(V),S(),V}),a.onTaskToggleExpand?.(A);},[a,S]),oe=useCallback((A,I)=>{if(ze&&ze(A,I)===false)return;let se=me.findTaskById(he,A)?.progress,ge=yt=>yt.map(Kt=>Kt.id===A?{...Kt,...I}:Kt.subtasks?{...Kt,subtasks:ge(Kt.subtasks)}:Kt);Ee(ge(he));let Se=me.findTaskById(ge(he),A);Se&&(w?.(Se),le?.(Se),I.progress!==void 0&&se!==void 0&&I.progress!==se&&z?.(A,se,I.progress));},[he,w,ze,le,z]),nt=useCallback(A=>{A.length!==0&&(Ee(I=>Qs(I,A)),a.onTaskIndent?.(A[0]));},[a]),rt=useCallback(A=>{A.length!==0&&(Ee(I=>ei(I,A)),a.onTaskOutdent?.(A[0]));},[a]),$e=useCallback((A,I,V)=>{Ee(se=>Qd(se,A,I,V)),a.onTaskReparent?.(A,I,V);},[a]),Et=useCallback((A,I)=>{A.length!==0&&(Ee(V=>ti(V,A,I)),a.onTaskMove?.(A[0],I));},[a]),Pt=useCallback(async A=>{let I=[];for(let V of A)O&&await Promise.resolve(O(V))===false||I.push(V);I.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(I):(Ee(V=>ai(V,I)),I.forEach(V=>a.onTaskDelete?.(V))),L&&I.forEach(V=>L(V)));},[a,O,L]),da=useCallback(A=>{Ee(I=>ri(I,A)),A.forEach(I=>a.onTaskDuplicate?.(I));},[a]),Er=useCallback((A,I)=>{Ee(V=>{let{tasks:se,newTask:ge}=Zd(V,A,I);return xe&&xe(ge)===false?V:(a.onTaskCreate?.(ge.parentId,ge.position||0),Ae?.(ge),se)});},[a,xe,Ae]),Vt=useCallback((A,I)=>{Ee(V=>oi(V,A,I)),a.onTaskRename?.(A,I);},[a]),bo=useCallback(A=>{Ee(I=>{let{tasks:V}=si(I,A);return a.onTaskCreate?.(A,0),V});},[a]),Kn=useCallback((A,I,V)=>{let se=A.startDate?Math.round((I.getTime()-A.startDate.getTime())/864e5):0,ge=Kt=>Kt.map(ga=>ga.id===A.id?{...ga,startDate:I,endDate:V,...A.segments&&{segments:A.segments}}:ga.subtasks?{...ga,subtasks:ge(ga.subtasks)}:ga),Se=ge(he);Se=me.autoScheduleDependents(Se,A.id,se),Ee(Se);let yt={...A,startDate:I,endDate:V};w?.(yt);},[he,w]),ll=useCallback((A,I)=>{B?.(A,I),re({isOpen:true,x:I.clientX,y:I.clientY,task:A});},[B]),yo=useCallback((A,I)=>{let V=me.splitTask(he,A.id,I);Ee(V),re({isOpen:false,x:0,y:0,task:null});},[he]),dl=useCallback(A=>{let I=me.findTaskById(he,A.id)||A;D?.(I),P||Ne(I);},[he,D,P]),cl=useCallback((A,I,V)=>{let se=new Map,ge=fa=>{fa.forEach(Na=>{Na.dependencies&&se.set(Na.id,Na.dependencies),Na.subtasks&&ge(Na.subtasks);});};ge(V);let Se=se.get(I)||[];se.set(I,[...Se,A]);let yt=new Set,Kt=new Set,ga=fa=>{if(!yt.has(fa)){yt.add(fa),Kt.add(fa);let Na=se.get(fa)||[];for(let pr of Na){if(!yt.has(pr)&&ga(pr))return true;if(Kt.has(pr))return true}}return Kt.delete(fa),false};return ga(I)},[]),pl=useCallback((A,I)=>{if(cl(A.id,I,he)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
342
+ </Project>`,u=new Blob([l],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=ue.flattenTasks(e),a=t.filter(l=>l.startDate&&l.endDate);if(a.length===0)return [];let r=new Map,o=l=>{if(r.has(l.id))return;let u=l.startDate&&l.endDate?ue.calculateDuration(l.startDate,l.endDate):0,d=0;if(l.dependencies&&l.dependencies.length>0)for(let h of l.dependencies){let C=t.find(m=>m.id===h);if(C){o(C);let m=r.get(h)?.ef||0;d=Math.max(d,m);}}let i=d+u;r.set(l.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(l=>l.ef)),n=new Map,c=l=>{if(n.has(l.id))return;let u=l.startDate&&l.endDate?ue.calculateDuration(l.startDate,l.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(l.id)),i=s;if(d.length>0)for(let C of d){c(C);let m=n.get(C.id)?.ls||0;i=Math.min(i,m);}let h=i-u;n.set(l.id,{ls:h,lf:i});};a.forEach(c);let p=[];for(let l of a){let u=r.get(l.id),d=n.get(l.id);if(u&&d){let i=d.ls-u.es;Math.abs(i)<.01&&p.push(l.id);}}return p},calculateSlack:(e,t)=>{let a=ue.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(ue.calculateCriticalPath(e).includes(t))return 0;let o=ue.getDependentTasks(e,t);if(o.length===0){let c=ue.getLatestEndDate(e);if(!c)return null;let p=ue.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let n=ue.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>ue.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=ue.findTaskById(e,t);if(!r||!r.endDate)return e;let o=ue.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=ue.calculateDuration(n.startDate,n.endDate),p;a!==void 0?(p=new Date(n.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let l=ue.calculateEndDate(p,c),u=d=>d.map(i=>i.id===n.id?{...i,startDate:p,endDate:l}:i.subtasks?{...i,subtasks:u(i.subtasks)}:i);s=u(s),s=ue.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,c)=>{if(a===0)return [];let p=[],l=o.getTime(),u=1e3*60*60*24,d=ue.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(h,C,m=new Set)=>{if(m.has(h))return;m.add(h);let y=ue.getDependentTasks(e,h);for(let f of y){if(!f.startDate||!f.endDate)continue;let v=r.findIndex(T=>T.id===f.id);if(v===-1)continue;let g=f.startDate.getTime(),x=(f.endDate.getTime()-g)/u,L=(g-l)/u*s,w=L+C*s,O=Math.max(x*s,s),M=c+v*n+12;p.push({taskId:f.id,taskName:f.name,originalX:L,previewX:w,width:O,y:M,rowIndex:v,daysDelta:C,color:f.color}),i(f.id,C,m);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=ue.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 p=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:c}],l=u=>u.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:l(d.subtasks)}:d);return l(e)}};function En({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:c,onTaskClick:p,onTaskDblClick:l,onTaskContextMenu:u,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:h}){let[m,y]=useState([]),[f,v]=useState(null),[g,k]=useState(null),x=useCallback(H=>{v(H);},[]),S=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),L=r==="day"?60:r==="week"?20:8,w=S*L*n,O=H=>{let z=new Date(Date.UTC(H.getFullYear(),H.getMonth(),H.getDate())),W=z.getUTCDay()||7;z.setUTCDate(z.getUTCDate()+4-W);let N=new Date(Date.UTC(z.getUTCFullYear(),0,1));return Math.ceil(((z.getTime()-N.getTime())/864e5+1)/7)},M=H=>{let z=H.getDay();return z===0||z===6},T=useCallback(H=>{let z=Math.round(H/(L*n)),W=new Date(o);return W.setDate(W.getDate()+z),W},[o,L,n]),_=useCallback((H,z)=>{if(z.startDate&&z.endDate)return;let W=H.currentTarget.ownerSVGElement;if(!W)return;let N=W.createSVGPoint();N.x=H.clientX,N.y=H.clientY;let j=N.matrixTransform(W.getScreenCTM()?.inverse()),q=T(j.x),R=new Date(q);R.setDate(R.getDate()+1),d?.(z,q,R);},[T,d]),B=useMemo(()=>{let H=j=>j.map(q=>{if(q.subtasks&&q.subtasks.length>0){let R=H(q.subtasks),ie=R.filter(ke=>ke.startDate&&ke.endDate);if(ie.length>0){let ke=ie.map(Me=>Me.startDate.getTime()),Ee=ie.map(Me=>Me.endDate.getTime()),ce=new Date(Math.min(...ke)),Ke=new Date(Math.max(...Ee));return {...q,subtasks:R,startDate:ce,endDate:Ke}}return {...q,subtasks:R}}return q}),z=(j,q=[])=>{for(let R of j)q.push(R),R.subtasks&&R.subtasks.length>0&&(R.isExpanded===void 0||R.isExpanded)&&z(R.subtasks,q);return q},W=H(e);return z(W)},[e]),J=useCallback(H=>{if(!H.startDate||!H.endDate)return {x:0,width:0};let z=H.startDate.getTime(),W=H.endDate.getTime(),N=o.getTime(),j=(z-N)/(1e3*60*60*24),q=(W-z)/(1e3*60*60*24),R=j*L*n,ie=Math.max(L*n,40),ke=Math.max(q*L*n,ie);return {x:R,width:ke}},[o,L,n]),te=useMemo(()=>B.filter(H=>H.startDate&&H.endDate).map(H=>{let{x:z,width:W}=J(H),j=B.findIndex(q=>q.id===H.id)*a+12;return {id:H.id,x:z,y:j,width:W,height:32}}),[B,J]),be=useCallback((H,z,W)=>{if(!W||z===0){y([]);return}let N=ue.calculateCascadePreview(e,H,z,B,o,L*n,a,48);y(N);},[e,B,o,L,n,a,48]),Fe=useMemo(()=>{let H=[],z=new Date(o);for(;z<=s;){let j=(z.getTime()-o.getTime())/864e5*L*n;if(r==="day")H.push({date:new Date(z),label:z.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:j}),z.setDate(z.getDate()+1);else if(r==="week"){let q=O(z);H.push({date:new Date(z),label:`Week ${q}`,x:j}),z.setDate(z.getDate()+7);}else H.push({date:new Date(z),label:z.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:j}),z.setMonth(z.getMonth()+1);}return H},[o,s,r,L,n]),Oe=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*L*n,[o,L,n]),je=Math.max(B.length*a,552);return jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},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(w,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(w,1e3),height:48,fill:t.bgGrid}),Fe.map((H,z)=>jsxs("g",{children:[z>0&&jsx("line",{x1:H.x,y1:0,x2:H.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:H.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:H.label})]},`header-${z}`)),Oe>=0&&Oe<=w&&jsx("circle",{cx:Oe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(w,1e3),height:je,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(w,1e3),height:je,fill:t.bgPrimary}),Fe.map((H,z)=>{let W=Fe[z+1]?.x||w,N=M(H.date);return jsxs("g",{children:[N&&jsx("rect",{x:H.x,y:0,width:W-H.x,height:B.length*a,fill:t.bgWeekend,opacity:1}),z>0&&jsx("line",{x1:H.x,y1:0,x2:H.x,y2:B.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},z)}),B.map((H,z)=>{let W=H.startDate&&H.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:z*a,width:w,height:a,fill:z%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${H.id}`),!W&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:z*a,width:w,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:N=>_(N,H),onMouseEnter:N=>{N.currentTarget.setAttribute("fill",t.accentLight),N.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:N=>{N.currentTarget.setAttribute("fill","transparent"),N.currentTarget.setAttribute("opacity","1");}},`clickable-${H.id}`),jsx("text",{x:Oe>0?Oe:100,y:z*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${H.id}`)]})]},`row-group-${H.id}`)}),B.map((H,z)=>!H.dependencies||H.dependencies.length===0||!H.startDate||!H.endDate?null:H.dependencies.map(W=>{let N=B.find(ie=>ie.id===W);if(!N||!N.startDate||!N.endDate)return null;let j=B.findIndex(ie=>ie.id===W),q=J(N),R=J(H);return jsx(Tn,{x1:q.x+q.width,y1:j*a+a/2,x2:R.x,y2:z*a+a/2,theme:t},`dep-${W}-${H.id}`)})),B.map((H,z)=>{if(!H.startDate||!H.endDate)return null;let{x:W,width:N}=J(H),j=z*a+12,q=H.subtasks&&H.subtasks.length>0&&!H.isMilestone;return H.isMilestone?jsx(Dn,{task:H,x:W+N/2,y:j+16,theme:t,onClick:p},H.id):q?jsxs("g",{onClick:()=>p?.(H),onContextMenu:R=>{R.preventDefault(),R.stopPropagation(),u?.(H,R);},style:{cursor:"default"},children:[jsx("rect",{x:W,y:j,width:N,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:W,y1:j,x2:W+N,y2:j,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:j,x2:W,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W+N,y1:j,x2:W+N,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:j+32,x2:W+N,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),N>60&&jsx("text",{x:W+12,y:j+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:H.name})]},H.id):jsx(kn,{task:H,x:W,y:j,width:N,theme:t,dayWidth:L*n,startDate:o,templates:c,onClick:p,onDoubleClick:l,onContextMenu:u,onDateChange:d,onDependencyCreate:i,allTaskPositions:te,onDragMove:be,onHoverChange:x},H.id)}),B.map((H,z)=>!H.dependencies||H.dependencies.length===0||!H.startDate||!H.endDate?null:H.dependencies.map(W=>{let N=B.find(re=>re.id===W);if(!N||!N.startDate||!N.endDate)return null;let j=B.findIndex(re=>re.id===W),q=J(N),R=J(H),ie=q.x+q.width,ke=j*a+a/2,Ee=R.x,ce=z*a+a/2,Ke=Ee-ie,Me=ie+Ke/2,at=re=>{let we=1-re,Te=we*we,rt=Te*we,wt=re*re,Ie=wt*re,ye=rt*ie+3*Te*re*Me+3*we*wt*Me+Ie*Ee,Se=rt*ke+3*Te*re*ke+3*we*wt*ce+Ie*ce;return {x:ye,y:Se}},lt=20,dt=[];for(let re=0;re<=lt;re++){let we=.1+re/lt*.8;dt.push(at(we));}let tt=dt[0],U=`M ${tt.x} ${tt.y} `+dt.slice(1).map(re=>`L ${re.x} ${re.y}`).join(" ");return g&&g.x1===ie&&g.y1===ke&&g.x2===Ee&&g.y2===ce?null:jsx("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{k({x1:ie,y1:ke,x2:Ee,y2:ce,onDelete:()=>h?.(H.id,W)});}},`dep-hover-${W}-${H.id}`)})),m.map(H=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:H.previewX,y:H.y-48,width:H.width,height:32,rx:8,fill:H.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(H.daysDelta)>0&&jsx("text",{x:H.previewX+H.width/2,y:H.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:H.daysDelta>0?`+${H.daysDelta}d`:`${H.daysDelta}d`})]},`cascade-preview-${H.taskId}`)),g&&(()=>{let{x1:H,y1:z,x2:W,y2:N,onDelete:j}=g,q=W-H,R=N-z,ie=H+q/2,ke=(z+N)/2,Ee=`M ${H} ${z} C ${ie} ${z}, ${ie} ${N}, ${W} ${N}`,ce=6,Ke=Math.atan2(R,q),Me=W-ce*Math.cos(Ke-Math.PI/6),at=N-ce*Math.sin(Ke-Math.PI/6),lt=W-ce*Math.cos(Ke+Math.PI/6),dt=N-ce*Math.sin(Ke+Math.PI/6),tt=t.dependency,U="#f87171";return jsxs("g",{onMouseLeave:()=>k(null),children:[jsx("path",{d:Ee,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:ie,cy:ke,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:Ee,fill:"none",stroke:tt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:Ee,fill:"none",stroke:tt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${W} ${N} L ${Me} ${at} M ${W} ${N} L ${lt} ${dt}`,fill:"none",stroke:tt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:W,cy:N,r:4,fill:tt,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:re=>{re.stopPropagation(),k(null),j();},style:{cursor:"pointer"},children:[jsx("circle",{cx:ie,cy:ke,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:U,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:ie-3,y1:ke-3,x2:ie+3,y2:ke+3,stroke:U,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:ie+3,y1:ke-3,x2:ie-3,y2:ke+3,stroke:U,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Oe>=0&&Oe<=w&&jsx("line",{x1:Oe,y1:0,x2:Oe,y2:je,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),f&&jsx(ic,{tooltipData:f,theme:t})]})]})}var o0=['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"'],cc=()=>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"})]}),n0=()=>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"})}),s0=()=>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"})}),i0=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),l0=()=>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 Pn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:c,onDependencyDelete:p}){let[l,u]=useState(false),[d,i]=useState(false),[h,C]=useState([]),[m,y]=useState(""),[f,v]=useState(false),[g,k]=useState(true),x=useRef(null),S=useRef(null),L=useRef(null),{enabled:w=true,placeholder:O='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:M="bottom-right",onCommand:T,suggestions:_=o0,maxHistory:B=50,persistHistory:J}=a,te=J?.storageKey||"gantt-ai-history",be=J?.maxMessages??5;useEffect(()=>{if(J?.enabled)try{let W=localStorage.getItem(te);if(W){let j=JSON.parse(W).map(q=>({...q,timestamp:new Date(q.timestamp)}));C(j.slice(-be));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[J?.enabled,te,be]),useEffect(()=>{if(J?.enabled&&h.length>0)try{let W=h.filter(N=>!N.isLoading).slice(-be);localStorage.setItem(te,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[h,J?.enabled,te,be]),useEffect(()=>{S.current&&S.current.scrollIntoView({behavior:"smooth"});},[h]),useEffect(()=>{l&&!d&&x.current&&setTimeout(()=>x.current?.focus(),100);},[l,d]);let Fe=useCallback(W=>{if(W.success)switch(W.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":W.taskId&&W.updates&&o?.(W.taskId,W.updates);break;case "create_task":W.newTask&&s?.(W.newTask);break;case "delete_task":W.taskId&&n?.(W.taskId);break;case "link_tasks":W.dependencyFrom&&W.dependencyTo&&c?.(W.dependencyFrom,W.dependencyTo);break;case "unlink_tasks":W.taskId&&W.dependencyFrom&&p?.(W.taskId,W.dependencyFrom);break}},[o,s,n,c,p]),Oe=useCallback(async W=>{if(!W.trim()||f)return;let N={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};C(q=>[...q.slice(-(B-1)),N]),y(""),k(false),v(true);let j={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(q=>[...q,j]);try{if(T){let q=await T(W,e);C(R=>{let ie=R.filter(Ee=>!Ee.isLoading),ke={id:`assistant-${Date.now()}`,role:"assistant",content:q.message,timestamp:new Date,command:q};return [...ie,ke]}),Fe(q);}else C(q=>[...q.filter(ie=>!ie.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){C(R=>[...R.filter(ke=>!ke.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${q instanceof Error?q.message:"Unknown error"}`,timestamp:new Date}]);}finally{v(false);}},[f,B,T,e,Fe]),je=W=>{W.preventDefault(),Oe(m);},H=W=>{y(W),x.current?.focus();};if(useEffect(()=>{let W=N=>{(N.metaKey||N.ctrlKey)&&N.key==="k"&&(N.preventDefault(),u(j=>!j),l||i(false)),N.key==="Escape"&&l&&u(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[l]),useEffect(()=>{if(!l)return;let W=j=>{let q=j.target;L.current&&!L.current.contains(q)&&u(false);},N=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(N),document.removeEventListener("mousedown",W);}},[l]),!w)return null;let z={"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(pt,{children:[jsx(AnimatePresence,{children:!l&&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 ${z[M]} 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:()=>u(true),children:[jsx(cc,{}),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:l&&jsxs(motion.div,{ref:L,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${z[M]} 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(cc,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>i(W=>!W),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(i0,{})}),jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(s0,{})})]})]}),jsx(AnimatePresence,{children:!d&&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:[h.length===0&&g&&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:_.slice(0,4).map((W,N)=>jsx("button",{onClick:()=>H(W),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:W.length>30?W.slice(0,30)+"...":W},N))})]}),h.map(W=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${W.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${W.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:W.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:W.role==="user"?"white":t.textPrimary},children:[W.isLoading?jsx(l0,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:W.content}),W.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:W.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:W.command.success?"#10B981":"#EF4444"},children:[W.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:W.command.type.replace(/_/g," ")})]})]})},W.id)),jsx("div",{ref:S})]}),jsxs("form",{onSubmit:je,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:x,type:"text",value:m,onChange:W=>y(W.target.value),placeholder:O,disabled:f,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!m.trim()||f,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:m.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:m.trim()?"white":t.textSecondary},children:jsx(n0,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function mc(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((l,u=true)=>{r(d=>{let i=typeof l=="function"?l(d.present):l;if(o.current)return {...d,present:i};if(!u)return {...d,present:i};let h=[...d.past,d.present];return h.length>t&&h.shift(),{past:h,present:i,future:[]}});},[t]),n=useCallback(()=>{r(l=>{if(l.past.length===0)return l;let u=l.past[l.past.length-1],d=l.past.slice(0,l.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:u,future:[l.present,...l.future]}});},[]),c=useCallback(()=>{r(l=>{if(l.future.length===0)return l;let u=l.future[0],d=l.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...l.past,l.present],present:u,future:d}});},[]),p=useCallback(()=>{r(l=>({past:[],present:l.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function pc({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,p=c?n.metaKey:n.ctrlKey;if(p&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!c&&p&&n.key==="y"){n.preventDefault(),t();return}if(c&&p&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var p0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${ue.formatDate(e.startDate)} - ${ue.formatDate(e.endDate)}`);let a=ue.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=>ue.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function uc(e){return {...p0,...e}}var v0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},hc=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:l=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:i=true,persistExpandedState:h,aiAssistant:C,locale:m="en",customTranslations:y,showCreateTaskButton:f=false,createTaskLabel:v,onCreateTask:g,onThemeChange:k,onTaskClick:x,onTaskDblClick:S,onTaskContextMenu:L,onTaskUpdate:w,onProgressChange:O,onTaskEdit:M,onTaskAddSubtask:T,onTaskMarkIncomplete:_,onTaskSetInProgress:B,onDependencyCreate:J,onDependencyDelete:te,onBeforeTaskAdd:be,onAfterTaskAdd:Fe,onBeforeTaskUpdate:Oe,onAfterTaskUpdate:je,onBeforeTaskDelete:H,onAfterTaskDelete:z}=a,N=useContext(gn)?.theme,[j,q]=useState(N||s||"dark"),[R,ie]=useState(n),[ke,Ee]=useState(c),[ce,Ke]=useState(1),[Me,at]=useState(0),[lt,dt]=useState(false),[tt,U]=useState(null),[ne,re]=useState({isOpen:false,x:0,y:0,task:null}),[we,Te]=useState(null),[rt,wt]=useState(null);useEffect(()=>{N&&N!==j&&q(N);},[N]),useEffect(()=>{s&&s!==j&&q(s);},[s]);let Ie=useCallback(F=>{q(F),k?.(F);},[k]),{state:ye,setState:Se,undo:St,redo:gt,canUndo:ta,canRedo:sa,clearHistory:Ge}=mc(t,50),$e=useCallback(()=>h?typeof h=="string"?h:"gantt-expanded-tasks":null,[h]),ia=useRef(new Map),he=useRef(false);if(!he.current&&h){he.current=true;let F=typeof h=="string"?h:"gantt-expanded-tasks";try{let I=localStorage.getItem(F);if(I){let V=JSON.parse(I);Array.isArray(V)&&(ia.current=new Map(V));}}catch(I){console.warn("[GanttBoard] Error loading expanded state from localStorage:",I);}}let E=useCallback(()=>{let F=$e();if(F)try{let I=Array.from(ia.current.entries());localStorage.setItem(F,JSON.stringify(I));}catch(I){console.warn("[GanttBoard] Error saving expanded state to localStorage:",I);}},[$e]);useEffect(()=>{let F=I=>I.map(V=>{let se=ia.current.get(V.id),fe=se!==void 0?{...V,isExpanded:se}:V;return fe.subtasks?.length?{...fe,subtasks:F(fe.subtasks)}:fe});ia.current.size>0?Se(F(t)):Se(t);},[t,Se]);let Z=useRef(t),me=useRef(true);useEffect(()=>{if(me.current){me.current=false,Z.current=ye;return}if(!r)return;let F=JSON.stringify(Z.current),I=JSON.stringify(ye);F!==I&&(Z.current=ye,r(ye));},[ye,r]);let Ne=useMemo(()=>qs(m,y),[m,y]),ze=useCallback(F=>[{id:"name",label:F.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:F.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:F.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:F.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:F.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:F.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:F.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:F.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Be,Le]=useState(()=>ze(Ne));useEffect(()=>{Le(F=>F.map(I=>({...I,label:Ne.columns[I.id==="name"?"taskName":I.id]||I.label})));},[Ne]);let Ze=useMemo(()=>Be.filter(I=>I.visible).reduce((I,V)=>I+V.width,0),[Be]),ct=useRef(Be.filter(F=>F.visible).map(F=>F.id).join(","));useEffect(()=>{let F=Be.filter(se=>se.visible),I=F.map(se=>se.id).join(","),V=ct.current;if(I!==V){let se=F.some(De=>De.id!=="name"),fe=V.includes(",");se?!fe&&se&&U(null):U(null),ct.current=I;}},[Be]);let Y=60,ae=.6,Pe=useMemo(()=>{let I=Ze+Y,V=typeof window<"u"?window.innerWidth*ae:800,se=Math.max(I,V);return tt!==null?Math.max(200,Math.min(tt,se)):Math.max(200,I)},[tt,Ze]),He=useRef(null),D=useRef(null),A=useRef(null),G=useMemo(()=>Id(j),[j]),pe=useMemo(()=>({theme:G,themeName:j}),[G,j]),Ye=useMemo(()=>uc(d),[d]),Q=useMemo(()=>{if(!i)return ye;let F=ue.calculateCriticalPath(ye),I=V=>V.map(se=>({...se,isCriticalPath:F.includes(se.id),subtasks:se.subtasks?I(se.subtasks):void 0}));return I(ye)},[ye,i]),Re=v0(ke);pc({undo:St,redo:gt,canUndo:ta,canRedo:sa,enabled:true}),useImperativeHandle(o,()=>({getTask:F=>ue.findTaskById(ye,F),addTask:(F,I)=>{Se(V=>{if(!I)return [...V,{...F,level:0}];let se=fe=>fe.map(De=>De.id===I?{...De,subtasks:[...De.subtasks||[],{...F,parentId:I,level:(De.level||0)+1}],isExpanded:true}:De.subtasks?{...De,subtasks:se(De.subtasks)}:De);return se(V)});},updateTask:(F,I)=>{Se(V=>{let se=fe=>fe.map(De=>De.id===F?{...De,...I}:De.subtasks?{...De,subtasks:se(De.subtasks)}:De);return se(V)});},deleteTask:F=>{Se(I=>{let V=se=>se.filter(fe=>fe.id===F?false:(fe.subtasks&&(fe.subtasks=V(fe.subtasks)),true));return V(I)});},deleteTasks:F=>{Se(I=>ai(I,F));},duplicateTask:F=>{Se(I=>ri(I,[F]));},splitTask:(F,I,V=3)=>{Se(se=>ue.splitTask(se,F,I,V));},calculateEndDate:ue.calculateEndDate,calculateDuration:ue.calculateDuration,validateDependency:(F,I)=>!ue.validateDependencies(ye,F,I),getAllTasks:()=>ue.flattenTasks(ye),getTasksByStatus:F=>ue.flattenTasks(ye).filter(I=>I.status===F),getTasksByParent:F=>F?ue.findTaskById(ye,F)?.subtasks||[]:ye.filter(V=>!V.parentId),getCriticalPath:()=>ue.flattenTasks(ye).filter(F=>F.isCriticalPath),indentTask:F=>{Se(I=>Qs(I,[F]));},outdentTask:F=>{Se(I=>ei(I,[F]));},moveTask:(F,I)=>{Se(V=>ti(V,[F],I));},createSubtask:async F=>{let{tasks:I,newTask:V}=si(ye,F);if(be){let se=be({...V,parentId:F});if((se instanceof Promise?await se:se)===false)return}Se(I),Fe&&Fe({...V,parentId:F});},scrollToTask:F=>{let V=ue.flattenTasks(ye).findIndex(se=>se.id===F);if(V!==-1&&He.current){let se=V*Re;He.current.scrollTo({top:se,behavior:"smooth"}),D.current&&D.current.scrollTo({top:se,behavior:"smooth"});}},highlightTask:(F,I=2e3)=>{},expandTask:F=>{Se(I=>{let V=se=>se.map(fe=>fe.id===F?{...fe,isExpanded:true}:fe.subtasks?{...fe,subtasks:V(fe.subtasks)}:fe);return V(I)});},collapseTask:F=>{Se(I=>{let V=se=>se.map(fe=>fe.id===F?{...fe,isExpanded:false}:fe.subtasks?{...fe,subtasks:V(fe.subtasks)}:fe);return V(I)});},expandAll:()=>{Se(F=>{let I=V=>V.map(se=>({...se,isExpanded:true,subtasks:se.subtasks?I(se.subtasks):void 0}));return I(F)});},collapseAll:()=>{Se(F=>{let I=V=>V.map(se=>({...se,isExpanded:false,subtasks:se.subtasks?I(se.subtasks):void 0}));return I(F)});},undo:St,redo:gt,canUndo:()=>ta,canRedo:()=>sa,clearHistory:Ge,exportToPNG:async()=>{if(!A.current||!He.current||!D.current)throw new Error("Gantt container not found");let F=A.current,I=He.current.querySelector(".gantt-grid-scroll"),V=D.current,se=I?.scrollTop||0,fe=V.scrollTop,De=F.style.overflow,yt=F.style.height;try{let Kt=I?.querySelector(".gantt-taskgrid-content"),ga=V.querySelector("svg"),fa=Kt?.scrollHeight||I?.scrollHeight||600,Na=ga?.getBoundingClientRect().height||V.scrollHeight,Pr=(F.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(fa,Na)+20;I&&(I.scrollTop=0),V.scrollTop=0,F.style.overflow="visible",F.style.height=`${Pr}px`,await new Promise(ur=>setTimeout(ur,100));let pr=await fc(F,{backgroundColor:G.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:ur=>{let Jr=window.getComputedStyle(ur),Mr=parseInt(Jr.zIndex,10);return !isNaN(Mr)&&Mr>=50||Jr.position==="fixed"}});return new Promise((ur,Jr)=>{pr.toBlob(Mr=>{Mr?ur(Mr):Jr(new Error("Failed to create blob from canvas"));},"image/png");})}finally{F.style.overflow=De,F.style.height=yt,I&&(I.scrollTop=se),V.scrollTop=fe;}},exportToPDF:async F=>{await ue.exportToPDF(ye,F);},exportToExcel:async F=>{await ue.exportToExcel(ye,F);},exportToJSON:()=>ue.exportToJSON(ye),exportToCSV:()=>ue.exportToCSV(ye),importFromJSON:F=>{let I=ue.importFromJSON(F);Se(I);},getTasks:()=>ye,refresh:()=>{Se(F=>[...F]);},clearAll:()=>{Se([]);}}),[ye,St,gt,ta,sa,Ge,G,Re]);let Nt=useCallback(F=>{Le(I=>I.map(V=>V.id===F?{...V,visible:!V.visible}:V));},[]),Ae=useCallback((F,I)=>{Le(V=>V.map(se=>{if(se.id!==F)return se;let fe=se.minWidth??100,De=se.maxWidth??800,yt=Math.max(fe,Math.min(De,I));return {...se,width:yt}}));},[]),aa=useCallback(F=>{Se(I=>{let V=ni(I,F),se=fe=>{for(let De of fe){if(De.id===F){ia.current.set(F,De.isExpanded??true);return}De.subtasks?.length&&se(De.subtasks);}};return se(V),E(),V}),a.onTaskToggleExpand?.(F);},[a,E]),oe=useCallback((F,I)=>{if(Oe&&Oe(F,I)===false)return;let se=ue.findTaskById(ye,F)?.progress,fe=yt=>yt.map(Kt=>Kt.id===F?{...Kt,...I}:Kt.subtasks?{...Kt,subtasks:fe(Kt.subtasks)}:Kt);Se(fe(ye));let De=ue.findTaskById(fe(ye),F);De&&(w?.(De),je?.(De),I.progress!==void 0&&se!==void 0&&I.progress!==se&&O?.(F,se,I.progress));},[ye,w,Oe,je,O]),st=useCallback(F=>{F.length!==0&&(Se(I=>Qs(I,F)),a.onTaskIndent?.(F[0]));},[a]),ot=useCallback(F=>{F.length!==0&&(Se(I=>ei(I,F)),a.onTaskOutdent?.(F[0]));},[a]),Ue=useCallback((F,I,V)=>{Se(se=>Qd(se,F,I,V)),a.onTaskReparent?.(F,I,V);},[a]),Et=useCallback((F,I)=>{F.length!==0&&(Se(V=>ti(V,F,I)),a.onTaskMove?.(F[0],I));},[a]),Pt=useCallback(async F=>{let I=[];for(let V of F)H&&await Promise.resolve(H(V))===false||I.push(V);I.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(I):(Se(V=>ai(V,I)),I.forEach(V=>a.onTaskDelete?.(V))),z&&I.forEach(V=>z(V)));},[a,H,z]),da=useCallback(F=>{Se(I=>ri(I,F)),F.forEach(I=>a.onTaskDuplicate?.(I));},[a]),Er=useCallback((F,I)=>{Se(V=>{let{tasks:se,newTask:fe}=Zd(V,F,I);return be&&be(fe)===false?V:(a.onTaskCreate?.(fe.parentId,fe.position||0),Fe?.(fe),se)});},[a,be,Fe]),Vt=useCallback((F,I)=>{Se(V=>oi(V,F,I)),a.onTaskRename?.(F,I);},[a]),bo=useCallback(F=>{Se(I=>{let{tasks:V}=si(I,F);return a.onTaskCreate?.(F,0),V});},[a]),Kn=useCallback((F,I,V)=>{let se=F.startDate?Math.round((I.getTime()-F.startDate.getTime())/864e5):0,fe=Kt=>Kt.map(ga=>ga.id===F.id?{...ga,startDate:I,endDate:V,...F.segments&&{segments:F.segments}}:ga.subtasks?{...ga,subtasks:fe(ga.subtasks)}:ga),De=fe(ye);De=ue.autoScheduleDependents(De,F.id,se),Se(De);let yt={...F,startDate:I,endDate:V};w?.(yt);},[ye,w]),ll=useCallback((F,I)=>{L?.(F,I),re({isOpen:true,x:I.clientX,y:I.clientY,task:F});},[L]),yo=useCallback((F,I)=>{let V=ue.splitTask(ye,F.id,I);Se(V),re({isOpen:false,x:0,y:0,task:null});},[ye]),dl=useCallback(F=>{let I=ue.findTaskById(ye,F.id)||F;S?.(I),M||Te(I);},[ye,S,M]),cl=useCallback((F,I,V)=>{let se=new Map,fe=fa=>{fa.forEach(Na=>{Na.dependencies&&se.set(Na.id,Na.dependencies),Na.subtasks&&fe(Na.subtasks);});};fe(V);let De=se.get(I)||[];se.set(I,[...De,F]);let yt=new Set,Kt=new Set,ga=fa=>{if(!yt.has(fa)){yt.add(fa),Kt.add(fa);let Na=se.get(fa)||[];for(let mr of Na){if(!yt.has(mr)&&ga(mr))return true;if(Kt.has(mr))return true}}return Kt.delete(fa),false};return ga(I)},[]),ml=useCallback((F,I)=>{if(cl(F.id,I,ye)){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 V=se=>se.map(ge=>{if(ge.id===I){let Se=ge.dependencies||[];if(!Se.includes(A.id))return {...ge,dependencies:[...Se,A.id]}}return ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge});Ee(V(he)),q?.(A.id,I);},[he,q,cl]),ml=useCallback((A,I)=>{let V=se=>se.map(ge=>{if(ge.id===A&&ge.dependencies){let Se=ge.dependencies.filter(yt=>yt!==I);return {...ge,dependencies:Se}}return ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge});Ee(V(he)),te?.(A,I);},[he,te]),{startDate:Bp,endDate:Rp}=useMemo(()=>{let A=he.filter(Se=>Se.startDate&&Se.endDate);if(A.length===0){let Se=new Date,yt=new Date(Se);yt.setDate(yt.getDate()-30);let Kt=new Date(Se);return Kt.setDate(Kt.getDate()+60),{startDate:yt,endDate:Kt}}let I=A.flatMap(Se=>[Se.startDate,Se.endDate]).filter(Se=>Se!==void 0),V=new Date(Math.min(...I.map(Se=>Se.getTime()))),se=new Date(Math.max(...I.map(Se=>Se.getTime()))),ge=U==="day"?7:U==="week"?14:30;return V.setDate(V.getDate()-ge),se.setDate(se.getDate()+ge),{startDate:V,endDate:se}},[he,U]),Op=useCallback(async()=>{if(!M.current||!We.current||!N.current)return;await new Promise(Pr=>setTimeout(Pr,200));let A=M.current,I=We.current.querySelector(".gantt-grid-scroll"),V=N.current,se=I?.scrollTop||0,ge=I?.scrollLeft||0,Se=V.scrollTop,yt=V.scrollLeft,Kt=A.style.overflow,ga=A.style.height,fa=I?.style.overflow||"",Na=V.style.overflow,pr=A.style.width,Ko=V.style.width;try{let Pr=I?.querySelector(".gantt-taskgrid-content"),mr=V.querySelector("svg"),ur=mr?.getAttribute("height")?parseInt(mr.getAttribute("height"),10):mr?.getBoundingClientRect().height||0,Jr=Pr?.scrollHeight||I?.scrollHeight||600,Mr=Math.max(ur,V.scrollHeight),ul=mr?.getAttribute("width")?parseInt(mr.getAttribute("width"),10):mr?.getBoundingClientRect().width||V.scrollWidth,_p=A.querySelector('[class*="h-12"]')?.offsetHeight||48,Yn=Math.max(Jr,Mr,ur),qn=_p+Yn+50,Xn=(I?.offsetWidth||300)+ul+10;I&&(I.scrollTop=0,I.scrollLeft=0),V.scrollTop=0,V.scrollLeft=0,A.style.overflow="visible",A.style.height=`${qn}px`,A.style.width=`${Xn}px`,I&&(I.style.overflow="visible",I.style.height=`${Yn+50}px`),V.style.overflow="visible",V.style.height=`${Yn+50}px`,V.style.width=`${ul+10}px`,await new Promise(Zn=>setTimeout(Zn,150));let Vp=await fc(A,{backgroundColor:_.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:Xn,height:qn,windowWidth:Xn+100,windowHeight:qn+100,scrollX:0,scrollY:0,ignoreElements:Zn=>{let gl=window.getComputedStyle(Zn),fl=parseInt(gl.zIndex,10);return !isNaN(fl)&&fl>=50||gl.position==="fixed"}}),Jn=document.createElement("a");Jn.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,Jn.href=Vp.toDataURL("image/png"),Jn.click();}finally{A.style.overflow=Kt,A.style.height=ga,A.style.width=pr,I&&(I.style.overflow=fa,I.style.height="",I.scrollTop=se,I.scrollLeft=ge),V.style.overflow=Na,V.style.height="",V.style.width=Ko,V.scrollTop=Se,V.scrollLeft=yt;}},[_]),zp=useCallback(async()=>{await me.exportToPDF(he);},[he]),Up=useCallback(async()=>{await me.exportToExcel(he);},[he]),$p=useCallback(()=>{let A=me.exportToCSV(he),I=new Blob([A],{type:"text/csv;charset=utf-8;"}),V=document.createElement("a");V.href=URL.createObjectURL(I),V.download="gantt-chart.csv",V.click(),URL.revokeObjectURL(V.href);},[he]),Hp=useCallback(()=>{let A=me.exportToJSON(he),I=new Blob([A],{type:"application/json;charset=utf-8;"}),V=document.createElement("a");V.href=URL.createObjectURL(I),V.download="gantt-chart.json",V.click(),URL.revokeObjectURL(V.href);},[he]),Wp=useCallback(()=>{me.exportToMSProject(he,"Gantt Project","project.xml");},[he]),Gp=A=>{A.preventDefault(),lt(true);},Xr=useRef(false);return useEffect(()=>{let A=N.current,I=We.current?.querySelector(".gantt-grid-scroll");if(!A||!I)return;let V=()=>{if(Xr.current)return;Xr.current=true;let yt=A.scrollTop;pt(yt),I.scrollTop=yt,requestAnimationFrame(()=>{Xr.current=false;});},se=()=>{if(Xr.current)return;Xr.current=true;let yt=I.scrollTop;pt(yt),A.scrollTop=yt,requestAnimationFrame(()=>{Xr.current=false;});},ge=yt=>{if(it&&I){let ga=I.parentElement?.getBoundingClientRect()?.left||0,fa=yt.clientX-ga,Na=200,pr=Je+K,Ko=window.innerWidth*ae,Pr=Math.max(pr,Ko);fa>=Na&&fa<=Pr&&$(fa);}},Se=()=>{lt(false);};return A.addEventListener("scroll",V),I.addEventListener("scroll",se),document.addEventListener("mousemove",ge),document.addEventListener("mouseup",Se),()=>{A.removeEventListener("scroll",V),I.removeEventListener("scroll",se),document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",Se);}},[it,Je]),jsx(co.Provider,{value:De,children:jsx(rs.Provider,{value:pe,children:jsxs("div",{ref:M,className:"flex flex-col h-full w-full",style:{backgroundColor:_.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(hn,{theme:_,timeScale:U,onTimeScaleChange:ke,zoom:ve,onZoomChange:et,currentTheme:X,onThemeChange:Le,rowDensity:Te,onRowDensityChange:Fe,showThemeSelector:m,showCreateTaskButton:f,createTaskLabel:v,onCreateTask:g,onExportPNG:l?Op:void 0,onExportPDF:l?zp:void 0,onExportExcel:l?Up:void 0,onExportCSV:l?$p:void 0,onExportJSON:l?Hp:void 0,onExportMSProject:l?Wp:void 0}),jsxs("div",{ref:We,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Pe,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsx(xn,{tasks:Z,theme:_,rowHeight:Oe,availableUsers:u,templates:Ke,onTaskClick:x,onTaskDblClick:dl,onTaskContextMenu:B,onTaskToggle:aa,scrollTop:Ie,columns:Re,onToggleColumn:Nt,onColumnResize:Me,onTaskUpdate:oe,onTaskIndent:nt,onTaskOutdent:rt,onTaskMove:Et,onMultiTaskDelete:Pt,onTaskDuplicate:da,onTaskCreate:Er,onTaskRename:Vt,onCreateSubtask:bo,onOpenTaskModal:x?A=>x(A):void 0,onDeleteRequest:(A,I)=>wt({taskId:A,taskName:I}),onTaskReparent:$e})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:_.border,zIndex:15},onMouseDown:Gp}),jsx("div",{ref:N,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(En,{tasks:Z,theme:_,rowHeight:Oe,timeScale:U,startDate:Bp,endDate:Rp,zoom:ve,templates:Ke,onTaskClick:x,onTaskDblClick:dl,onTaskContextMenu:ll,onTaskDateChange:Kn,onDependencyCreate:pl,onDependencyDelete:ml})})]}),ne.task&&jsx(po,{isOpen:ne.isOpen,x:ne.x,y:ne.y,theme:_,onClose:()=>re({isOpen:false,x:0,y:0,task:null}),items:(()=>{let A=ne.task;if(!A)return [];let I=me.findTaskById(he,A.id)||A;return I.subtasks&&I.subtasks.length>0?[{id:"addSubtask",label:De.contextMenu?.addSubtask||"Add Subtask",icon:Lt.Add,onClick:()=>{T?T(I):bo(I.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:De.contextMenu?.deleteTask||"Delete Task",icon:Lt.Delete,onClick:()=>{wt({taskId:I.id,taskName:I.name});}}]:[{id:"edit",label:De.contextMenu?.editTask||"Edit Task",icon:Lt.Pencil,onClick:()=>{P?P(I):Ne(I);}},{id:"addSubtask",label:De.contextMenu?.addSubtask||"Add Subtask",icon:Lt.Add,onClick:()=>{T?T(I):bo(I.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:De.contextMenu?.markIncomplete||"Mark Incomplete",icon:Lt.MarkIncomplete,onClick:()=>{G?G(I):oe(I.id,{status:"todo",progress:0});},disabled:I.status==="todo"},{id:"setInProgress",label:De.contextMenu?.setInProgress||"Set In Progress",icon:Lt.SetInProgress,onClick:()=>{R?R(I):oe(I.id,{status:"in-progress"});},disabled:I.status==="in-progress"},{id:"markComplete",label:De.contextMenu?.markComplete||"Mark Complete",icon:Lt.MarkComplete,onClick:()=>{oe(I.id,{status:"completed",progress:100});},disabled:I.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:De.contextMenu?.splitTask||"Split Task",icon:Lt.Split,onClick:()=>{if(!I.startDate||!I.endDate){console.warn("Cannot split task without dates");return}let se=I.startDate.getTime(),ge=I.endDate.getTime(),Se=se+(ge-se)/2,yt=new Date(Se);yo(I,yt);},disabled:!I.startDate||!I.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:De.contextMenu?.deleteTask||"Delete Task",icon:Lt.Delete,onClick:()=>{wt({taskId:I.id,taskName:I.name});}}]})()}),jsx(Or,{task:we,isOpen:!!we,onClose:()=>Ne(null),onTaskUpdate:A=>{we&&(oe(we.id,A),Ne(null));},theme:X==="light"?"light":"dark",locale:p==="es"?"es":"en",availableUsers:u,availableTasks:t}),jsx(AnimatePresence,{children:at&&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:()=>wt(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:A=>A.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:_.bgSecondary,border:`1px solid ${_.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${_.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:_.textPrimary,fontFamily:"Inter, sans-serif"},children:[De.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:_.textSecondary,fontFamily:"Inter, sans-serif"},children:p==="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:_.textSecondary,fontFamily:"Inter, sans-serif"},children:[p==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:_.textPrimary},children:['"',at.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:_.bgPrimary,borderTop:`1px solid ${_.border}`},children:[jsx("button",{onClick:()=>wt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:_.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:A=>{A.currentTarget.style.backgroundColor=_.hoverBg;},onMouseLeave:A=>{A.currentTarget.style.backgroundColor="transparent";},children:p==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{Pt([at.taskId]),wt(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:A=>{A.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:A=>{A.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),p==="es"?"Eliminar":"Delete"]})]})]})})}),C?.enabled&&jsx(Pn,{tasks:he,theme:_,config:C,onTasksUpdate:Ee,onTaskUpdate:oe,onTaskCreate:A=>{Ee(I=>[...I,A]);},onTaskDelete:A=>{Pt([A]);},onDependencyCreate:(A,I)=>{let V=me.findTaskById(he,A);V&&pl(V,I);},onDependencyDelete:ml})]})})})});var ui=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],gi=[{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 vc({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:c=a?"edit":"create",theme:m="dark",customStatuses:l=[],availableTags:u=[],onCreateTag:d,attachments:i=[],onUploadAttachments:h,onDeleteAttachment:C}){let p=[...ui,...l.filter($=>!ui.some(ne=>ne.id===$.id))],y=Ye[m]||Ye.dark,[f,v]=useState(false),[g,k]=useState(false),[x,D]=useState(false),[B,w]=useState(false),[z,P]=useState({top:0,left:0}),[T,G]=useState(null),[R,q]=useState(new Date),[te,xe]=useState({top:0,left:0}),[Ae,ze]=useState(false),[le,O]=useState([]),L=useRef(null),H=useRef(null),F=useRef(null),X$1=useRef(null),Q=useRef(null),[U,ke]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[Te,Fe]=useState({});useEffect(()=>{a?(ke({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)&&ze(true)):(ke({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),ze(false),O([]));},[a,e]),useEffect(()=>{let $=ne=>{L.current&&!L.current.contains(ne.target)&&v(false),H.current&&!H.current.contains(ne.target)&&k(false),F.current&&!F.current.contains(ne.target)&&D(false),X$1.current&&!X$1.current.contains(ne.target)&&w(false);};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);let ve=()=>{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(),!!ve())try{let ne=c==="create"&&le.length>0?{...U,pendingFiles:le}:U;await s(ne),O([]),t();}catch(ne){console.error("Error submitting task:",ne);}},Ie=($,ne)=>{ke(re=>{let we={...re,[$]:ne};if($==="status"){let Ne=ne;Ne==="todo"?we.progress=0:Ne==="in-progress"?(re.progress===0||re.progress===100)&&(we.progress=50):Ne==="completed"||Ne==="closed"?we.progress=100:(Ne==="in-review"||Ne==="review")&&(we.progress=75);}if($==="progress"){let Ne=typeof ne=="number"?ne:parseInt(ne,10);Ne===100&&re.status!=="completed"?we.status="completed":Ne>0&&Ne<100&&re.status==="todo"?we.status="in-progress":Ne===0&&re.status!=="todo"&&(we.status="todo");}return we}),Te[$]&&Fe(re=>{let we={...re};return delete we[$],we});},pt=p.find($=>$.id===U.status)??ui[0],it=gi.find($=>$.id===U.priority)??gi[1],lt=er.find($=>$.value===U.color)??er[0],tt={backgroundColor:y.bgSecondary,border:`1px solid ${y.borderLight}`,color:y.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":m,style:{backgroundColor:y.bgPrimary,border:`1px solid ${y.border}`},onClick:$=>$.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${y.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:pt.color||y.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:y.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:y.textTertiary},onMouseEnter:$=>{$.currentTarget.style.backgroundColor=y.hoverBg,$.currentTarget.style.color=y.textPrimary;},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent",$.currentTarget.style.color=y.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:$=>Ie("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:y.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),Te.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),Te.name]})]}),jsx("div",{children:jsx("textarea",{value:U.description||"",onChange:$=>Ie("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:y.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsx("div",{style:{borderTop:`1px solid ${y.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:L,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&v(!f),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...tt,borderColor:pt.color,backgroundColor:`${pt.color}15`},disabled:n,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:pt.color}}),jsx("span",{style:{color:pt.color},children:pt.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:pt.color}})]}),jsx(AnimatePresence,{children:f&&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:y.bgPrimary,border:`1px solid ${y.border}`},children:p.map($=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:y.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=y.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Ie("status",$.id),v(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:y.accent}})]},$.id))})})]}),jsxs("div",{ref:H,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&k(!g),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:tt,disabled:n,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:it.color}}),jsx("span",{children:it.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:y.textTertiary}})]}),jsx(AnimatePresence,{children:g&&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:y.bgPrimary,border:`1px solid ${y.border}`},children:gi.map($=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:y.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=y.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Ie("priority",$.id),k(false);},children:[jsx("span",{children:$.icon}),$.label,U.priority===$.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:y.accent}})]},$.id))})})]}),o.length>0&&jsxs("div",{ref:F,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&D(!x),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:tt,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(($,ne)=>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||y.accent,borderColor:y.bgSecondary},children:$.initials},ne))}),U.assignees.length>3&&jsxs("span",{style:{color:y.textTertiary},children:["+",U.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:y.textTertiary}}),jsx("span",{style:{color:y.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:y.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-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:y.bgPrimary,border:`1px solid ${y.border}`},children:o.map($=>{let ne=U.assignees?.some(re=>re.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:y.textPrimary},onMouseEnter:re=>re.currentTarget.style.backgroundColor=y.hoverBg,onMouseLeave:re=>re.currentTarget.style.backgroundColor="transparent",onClick:()=>{let re=ne?(U.assignees||[]).filter(we=>we.name!==$.name):[...U.assignees||[],{name:$.name,avatar:$.avatar,initials:$.name.split(" ").map(we=>we[0]).join("").toUpperCase().slice(0,2),color:y.accent}];Ie("assignees",re);},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:y.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:ne&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:y.accent}})})]},$.id)})})})]}),jsxs("div",{ref:X$1,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!n)if(B)w(false);else {if(X$1.current){let $=X$1.current.getBoundingClientRect(),ne=window.innerHeight,re=120,Ne=ne-$.bottom<re?$.top-re-8:$.bottom+8;P({top:Ne,left:$.left});}w(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:tt,disabled:n,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:U.color}}),jsx("span",{children:lt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:y.textTertiary}})]}),jsx(AnimatePresence,{children:B&&jsxs(mt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>w(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:`${z.top}px`,left:`${z.left}px`,zIndex:99999,backgroundColor:y.bgPrimary,border:`1px solid ${y.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:er.slice(0,18).map($=>{let ne=U.color===$.value;return jsx("button",{type:"button",onClick:re=>{re.preventDefault(),re.stopPropagation(),Ie("color",$.value),w(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:ne?`2px solid ${$.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},$.value)})})})})]})})]}),u.length>0||d?jsx(Qa,{selectedTags:U.tags||[],availableTags:u,onChange:$=>Ie("tags",$),onCreateTag:d,theme:y,disabled:n}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:y.textTertiary}}),jsxs("div",{ref:Q,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!n&&!U.isMilestone)if(T==="start")G(null);else {if(Q.current){let $=Q.current.getBoundingClientRect(),ne=window.innerHeight,re=320,Ne=ne-$.bottom<re?$.top-re-8:$.bottom+8;xe({top:Ne,left:$.left});}G("start"),q(U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...tt,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:y.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!n&&!U.isMilestone)if(T==="end")G(null);else {if(Q.current){let $=Q.current.getBoundingClientRect(),ne=window.innerHeight,re=320,Ne=ne-$.bottom<re?$.top-re-8:$.bottom+8;xe({top:Ne,left:$.left});}G("end"),q(U.endDate||U.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...tt,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(mt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>G(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:y.bgPrimary,border:`1px solid ${y.border}`},onClick:$=>$.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${y.border}`},children:[(()=>{let $=new Date,ne=new Date($);ne.setDate($.getDate()+1);let re=new Date($);re.setDate($.getDate()+7);let we=new Date($);return we.setDate($.getDate()+14),[{label:"Hoy",date:$},{label:"Ma\xF1ana",date:ne},{label:"Pr\xF3xima semana",date:re},{label:"2 semanas",date:we}].map((at,wt)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:y.textPrimary},onMouseEnter:Le=>Le.currentTarget.style.backgroundColor=y.hoverBg,onMouseLeave:Le=>Le.currentTarget.style.backgroundColor="transparent",onClick:()=>{T==="start"?(Ie("startDate",at.date),(!U.endDate||at.date>U.endDate)&&Ie("endDate",at.date),G("end")):(Ie("endDate",at.date),(!U.startDate||at.date<U.startDate)&&Ie("startDate",at.date),G(null));},children:at.label},wt))})(),jsx("div",{style:{borderTop:`1px solid ${y.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=y.hoverBg,onMouseLeave:$=>$.currentTarget.style.backgroundColor="transparent",onClick:()=>{Ie("startDate",void 0),Ie("endDate",void 0),G(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:()=>q(new Date(R.getFullYear(),R.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:y.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:y.textPrimary},children:R.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>q(new Date(R.getFullYear(),R.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:y.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map(($,ne)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:y.textTertiary},children:$},ne))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let $=R.getFullYear(),ne=R.getMonth(),re=new Date($,ne,1).getDay(),we=new Date($,ne+1,0).getDate(),Ne=new Date,at=[];for(let Le=re-1;Le>=0;Le--)at.push({day:new Date($,ne,-Le).getDate(),date:new Date($,ne-1,new Date($,ne,-Le).getDate()),isCurrentMonth:false});for(let Le=1;Le<=we;Le++)at.push({day:Le,date:new Date($,ne,Le),isCurrentMonth:true});let wt=42-at.length;for(let Le=1;Le<=wt;Le++)at.push({day:Le,date:new Date($,ne+1,Le),isCurrentMonth:false});return at.map((Le,he)=>{let Ee=Le.date.toDateString()===Ne.toDateString(),St=U.startDate?.toDateString()===Le.date.toDateString(),gt=U.endDate?.toDateString()===Le.date.toDateString(),ta=U.startDate&&U.endDate&&Le.date>=U.startDate&&Le.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:Le.isCurrentMonth?St||gt?"#FFF":y.textPrimary:y.textTertiary,backgroundColor:St?"#3B82F6":gt?"#7C3AED":ta?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Ee&&!St&&!gt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{T==="start"?(Ie("startDate",Le.date),U.endDate&&Le.date>U.endDate&&Ie("endDate",Le.date),G("end")):(Ie("endDate",Le.date),U.startDate&&Le.date<U.startDate&&Ie("startDate",Le.date),G(null));},children:Le.day},he)})})()})]})]})]})})]}),Te.endDate&&jsx("span",{className:"text-xs text-red-400",children:Te.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:y.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:$=>Ie("progress",parseInt($.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:y.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:()=>ze(!Ae),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:y.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${Ae?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:Ae&&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:[(h||i.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:y.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:y.textTertiary},children:["Adjuntos ",c==="create"?le.length>0&&`(${le.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsx(rr,{cardId:"pending",attachments:le.map(($,ne)=>({id:`pending-${ne}`,cardId:"pending",name:$.name,size:$.size,type:$.type,url:URL.createObjectURL($),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:$=>O(ne=>[...ne,...$]),onDelete:$=>{let ne=parseInt($.replace("pending-",""),10);O(re=>re.filter((we,Ne)=>Ne!==ne));},maxSizeMB:10,maxFiles:20}):jsx(rr,{cardId:a?.id||"new",attachments:i,onUpload:h&&a?.id?$=>h(a.id,$):void 0,onDelete:C,maxSizeMB:10,maxFiles:20}),c==="create"&&le.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:y.textTertiary},children:[le.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:$=>Ie("isMilestone",$.target.checked),className:"w-4 h-4 rounded",style:{accentColor:y.accent},disabled:n}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:y.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:y.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:y.bgSecondary},children:r.filter($=>$.id!==a?.id).map($=>{let ne=U.dependencies?.includes($.id);return jsx("button",{type:"button",onClick:()=>{let re=ne?(U.dependencies||[]).filter(we=>we!==$.id):[...U.dependencies||[],$.id];Ie("dependencies",re);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:ne?`${y.accent}30`:y.bgPrimary,color:ne?y.accent:y.textSecondary,border:`1px solid ${ne?y.accent:y.borderLight}`},disabled:n,children:$.name},$.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${y.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:y.textSecondary},onMouseEnter:$=>$.currentTarget.style.backgroundColor=y.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:y.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 xc=`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=se=>se.map(fe=>{if(fe.id===I){let De=fe.dependencies||[];if(!De.includes(F.id))return {...fe,dependencies:[...De,F.id]}}return fe.subtasks?{...fe,subtasks:V(fe.subtasks)}:fe});Se(V(ye)),J?.(F.id,I);},[ye,J,cl]),pl=useCallback((F,I)=>{let V=se=>se.map(fe=>{if(fe.id===F&&fe.dependencies){let De=fe.dependencies.filter(yt=>yt!==I);return {...fe,dependencies:De}}return fe.subtasks?{...fe,subtasks:V(fe.subtasks)}:fe});Se(V(ye)),te?.(F,I);},[ye,te]),{startDate:Bm,endDate:Rm}=useMemo(()=>{let F=ye.filter(De=>De.startDate&&De.endDate);if(F.length===0){let De=new Date,yt=new Date(De);yt.setDate(yt.getDate()-30);let Kt=new Date(De);return Kt.setDate(Kt.getDate()+60),{startDate:yt,endDate:Kt}}let I=F.flatMap(De=>[De.startDate,De.endDate]).filter(De=>De!==void 0),V=new Date(Math.min(...I.map(De=>De.getTime()))),se=new Date(Math.max(...I.map(De=>De.getTime()))),fe=R==="day"?7:R==="week"?14:30;return V.setDate(V.getDate()-fe),se.setDate(se.getDate()+fe),{startDate:V,endDate:se}},[ye,R]),Om=useCallback(async()=>{if(!A.current||!He.current||!D.current)return;await new Promise(Pr=>setTimeout(Pr,200));let F=A.current,I=He.current.querySelector(".gantt-grid-scroll"),V=D.current,se=I?.scrollTop||0,fe=I?.scrollLeft||0,De=V.scrollTop,yt=V.scrollLeft,Kt=F.style.overflow,ga=F.style.height,fa=I?.style.overflow||"",Na=V.style.overflow,mr=F.style.width,Ko=V.style.width;try{let Pr=I?.querySelector(".gantt-taskgrid-content"),pr=V.querySelector("svg"),ur=pr?.getAttribute("height")?parseInt(pr.getAttribute("height"),10):pr?.getBoundingClientRect().height||0,Jr=Pr?.scrollHeight||I?.scrollHeight||600,Mr=Math.max(ur,V.scrollHeight),ul=pr?.getAttribute("width")?parseInt(pr.getAttribute("width"),10):pr?.getBoundingClientRect().width||V.scrollWidth,_m=F.querySelector('[class*="h-12"]')?.offsetHeight||48,Yn=Math.max(Jr,Mr,ur),qn=_m+Yn+50,Xn=(I?.offsetWidth||300)+ul+10;I&&(I.scrollTop=0,I.scrollLeft=0),V.scrollTop=0,V.scrollLeft=0,F.style.overflow="visible",F.style.height=`${qn}px`,F.style.width=`${Xn}px`,I&&(I.style.overflow="visible",I.style.height=`${Yn+50}px`),V.style.overflow="visible",V.style.height=`${Yn+50}px`,V.style.width=`${ul+10}px`,await new Promise(Zn=>setTimeout(Zn,150));let Vm=await fc(F,{backgroundColor:G.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:Xn,height:qn,windowWidth:Xn+100,windowHeight:qn+100,scrollX:0,scrollY:0,ignoreElements:Zn=>{let gl=window.getComputedStyle(Zn),fl=parseInt(gl.zIndex,10);return !isNaN(fl)&&fl>=50||gl.position==="fixed"}}),Jn=document.createElement("a");Jn.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,Jn.href=Vm.toDataURL("image/png"),Jn.click();}finally{F.style.overflow=Kt,F.style.height=ga,F.style.width=mr,I&&(I.style.overflow=fa,I.style.height="",I.scrollTop=se,I.scrollLeft=fe),V.style.overflow=Na,V.style.height="",V.style.width=Ko,V.scrollTop=De,V.scrollLeft=yt;}},[G]),zm=useCallback(async()=>{await ue.exportToPDF(ye);},[ye]),Um=useCallback(async()=>{await ue.exportToExcel(ye);},[ye]),$m=useCallback(()=>{let F=ue.exportToCSV(ye),I=new Blob([F],{type:"text/csv;charset=utf-8;"}),V=document.createElement("a");V.href=URL.createObjectURL(I),V.download="gantt-chart.csv",V.click(),URL.revokeObjectURL(V.href);},[ye]),Hm=useCallback(()=>{let F=ue.exportToJSON(ye),I=new Blob([F],{type:"application/json;charset=utf-8;"}),V=document.createElement("a");V.href=URL.createObjectURL(I),V.download="gantt-chart.json",V.click(),URL.revokeObjectURL(V.href);},[ye]),Wm=useCallback(()=>{ue.exportToMSProject(ye,"Gantt Project","project.xml");},[ye]),Gm=F=>{F.preventDefault(),dt(true);},Xr=useRef(false);return useEffect(()=>{let F=D.current,I=He.current?.querySelector(".gantt-grid-scroll");if(!F||!I)return;let V=()=>{if(Xr.current)return;Xr.current=true;let yt=F.scrollTop;at(yt),I.scrollTop=yt,requestAnimationFrame(()=>{Xr.current=false;});},se=()=>{if(Xr.current)return;Xr.current=true;let yt=I.scrollTop;at(yt),F.scrollTop=yt,requestAnimationFrame(()=>{Xr.current=false;});},fe=yt=>{if(lt&&I){let ga=I.parentElement?.getBoundingClientRect()?.left||0,fa=yt.clientX-ga,Na=200,mr=Ze+Y,Ko=window.innerWidth*ae,Pr=Math.max(mr,Ko);fa>=Na&&fa<=Pr&&U(fa);}},De=()=>{dt(false);};return F.addEventListener("scroll",V),I.addEventListener("scroll",se),document.addEventListener("mousemove",fe),document.addEventListener("mouseup",De),()=>{F.removeEventListener("scroll",V),I.removeEventListener("scroll",se),document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",De);}},[lt,Ze]),jsx(co.Provider,{value:Ne,children:jsx(rs.Provider,{value:pe,children:jsxs("div",{ref:A,className:"flex flex-col h-full w-full",style:{backgroundColor:G.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(hn,{theme:G,timeScale:R,onTimeScaleChange:ie,zoom:ce,onZoomChange:Ke,currentTheme:j,onThemeChange:Ie,rowDensity:ke,onRowDensityChange:Ee,showThemeSelector:p,showCreateTaskButton:f,createTaskLabel:v,onCreateTask:g,onExportPNG:l?Om:void 0,onExportPDF:l?zm:void 0,onExportExcel:l?Um:void 0,onExportCSV:l?$m:void 0,onExportJSON:l?Hm:void 0,onExportMSProject:l?Wm:void 0}),jsxs("div",{ref:He,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Pe,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsx(xn,{tasks:Q,theme:G,rowHeight:Re,availableUsers:u,templates:Ye,onTaskClick:x,onTaskDblClick:dl,onTaskContextMenu:L,onTaskToggle:aa,scrollTop:Me,columns:Be,onToggleColumn:Nt,onColumnResize:Ae,onTaskUpdate:oe,onTaskIndent:st,onTaskOutdent:ot,onTaskMove:Et,onMultiTaskDelete:Pt,onTaskDuplicate:da,onTaskCreate:Er,onTaskRename:Vt,onCreateSubtask:bo,onOpenTaskModal:x?F=>x(F):void 0,onDeleteRequest:(F,I)=>wt({taskId:F,taskName:I}),onTaskReparent:Ue})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:G.border,zIndex:15},onMouseDown:Gm}),jsx("div",{ref:D,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(En,{tasks:Q,theme:G,rowHeight:Re,timeScale:R,startDate:Bm,endDate:Rm,zoom:ce,templates:Ye,onTaskClick:x,onTaskDblClick:dl,onTaskContextMenu:ll,onTaskDateChange:Kn,onDependencyCreate:ml,onDependencyDelete:pl})})]}),ne.task&&jsx(mo,{isOpen:ne.isOpen,x:ne.x,y:ne.y,theme:G,onClose:()=>re({isOpen:false,x:0,y:0,task:null}),items:(()=>{let F=ne.task;if(!F)return [];let I=ue.findTaskById(ye,F.id)||F;return I.subtasks&&I.subtasks.length>0?[{id:"addSubtask",label:Ne.contextMenu?.addSubtask||"Add Subtask",icon:Lt.Add,onClick:()=>{T?T(I):bo(I.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Ne.contextMenu?.deleteTask||"Delete Task",icon:Lt.Delete,onClick:()=>{wt({taskId:I.id,taskName:I.name});}}]:[{id:"edit",label:Ne.contextMenu?.editTask||"Edit Task",icon:Lt.Pencil,onClick:()=>{M?M(I):Te(I);}},{id:"addSubtask",label:Ne.contextMenu?.addSubtask||"Add Subtask",icon:Lt.Add,onClick:()=>{T?T(I):bo(I.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:Ne.contextMenu?.markIncomplete||"Mark Incomplete",icon:Lt.MarkIncomplete,onClick:()=>{_?_(I):oe(I.id,{status:"todo",progress:0});},disabled:I.status==="todo"},{id:"setInProgress",label:Ne.contextMenu?.setInProgress||"Set In Progress",icon:Lt.SetInProgress,onClick:()=>{B?B(I):oe(I.id,{status:"in-progress"});},disabled:I.status==="in-progress"},{id:"markComplete",label:Ne.contextMenu?.markComplete||"Mark Complete",icon:Lt.MarkComplete,onClick:()=>{oe(I.id,{status:"completed",progress:100});},disabled:I.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:Ne.contextMenu?.splitTask||"Split Task",icon:Lt.Split,onClick:()=>{if(!I.startDate||!I.endDate){console.warn("Cannot split task without dates");return}let se=I.startDate.getTime(),fe=I.endDate.getTime(),De=se+(fe-se)/2,yt=new Date(De);yo(I,yt);},disabled:!I.startDate||!I.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:Ne.contextMenu?.deleteTask||"Delete Task",icon:Lt.Delete,onClick:()=>{wt({taskId:I.id,taskName:I.name});}}]})()}),jsx(Or,{task:we,isOpen:!!we,onClose:()=>Te(null),onTaskUpdate:F=>{we&&(oe(we.id,F),Te(null));},theme:j==="light"?"light":"dark",locale:m==="es"?"es":"en",availableUsers:u,availableTasks:t}),jsx(AnimatePresence,{children:rt&&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:()=>wt(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:F=>F.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:G.bgSecondary,border:`1px solid ${G.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${G.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:G.textPrimary,fontFamily:"Inter, sans-serif"},children:[Ne.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:G.textSecondary,fontFamily:"Inter, sans-serif"},children:m==="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:G.textSecondary,fontFamily:"Inter, sans-serif"},children:[m==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:G.textPrimary},children:['"',rt.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:G.bgPrimary,borderTop:`1px solid ${G.border}`},children:[jsx("button",{onClick:()=>wt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:G.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor=G.hoverBg;},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent";},children:m==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{Pt([rt.taskId]),wt(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:F=>{F.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),m==="es"?"Eliminar":"Delete"]})]})]})})}),C?.enabled&&jsx(Pn,{tasks:ye,theme:G,config:C,onTasksUpdate:Se,onTaskUpdate:oe,onTaskCreate:F=>{Se(I=>[...I,F]);},onTaskDelete:F=>{Pt([F]);},onDependencyCreate:(F,I)=>{let V=ue.findTaskById(ye,F);V&&ml(V,I);},onDependencyDelete:pl})]})})})});var ui=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],gi=[{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 vc({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:l=[],availableTags:u=[],onCreateTag:d,attachments:i=[],onUploadAttachments:h,onDeleteAttachment:C}){let m=[...ui,...l.filter(U=>!ui.some(ne=>ne.id===U.id))],y=qe[p]||qe.dark,[f,v]=useState(false),[g,k]=useState(false),[x,S]=useState(false),[L,w]=useState(false),[O,M]=useState({top:0,left:0}),[T,_]=useState(null),[B,J]=useState(new Date),[te,be]=useState({top:0,left:0}),[Fe,Oe]=useState(false),[je,H]=useState([]),z=useRef(null),W=useRef(null),N=useRef(null),j=useRef(null),q=useRef(null),[R,ie]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ke,Ee]=useState({});useEffect(()=>{a?(ie({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)&&Oe(true)):(ie({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Oe(false),H([]));},[a,e]),useEffect(()=>{let U=ne=>{z.current&&!z.current.contains(ne.target)&&v(false),W.current&&!W.current.contains(ne.target)&&k(false),N.current&&!N.current.contains(ne.target)&&S(false),j.current&&!j.current.contains(ne.target)&&w(false);};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]);let ce=()=>{let U={};return R.name.trim()||(U.name="El nombre es requerido"),R.startDate&&R.endDate&&R.startDate>R.endDate&&(U.endDate="La fecha de fin debe ser posterior a la de inicio"),Ee(U),Object.keys(U).length===0},Ke=async U=>{if(U.preventDefault(),!!ce())try{let ne=c==="create"&&je.length>0?{...R,pendingFiles:je}:R;await s(ne),H([]),t();}catch(ne){console.error("Error submitting task:",ne);}},Me=(U,ne)=>{ie(re=>{let we={...re,[U]:ne};if(U==="status"){let Te=ne;Te==="todo"?we.progress=0:Te==="in-progress"?(re.progress===0||re.progress===100)&&(we.progress=50):Te==="completed"||Te==="closed"?we.progress=100:(Te==="in-review"||Te==="review")&&(we.progress=75);}if(U==="progress"){let Te=typeof ne=="number"?ne:parseInt(ne,10);Te===100&&re.status!=="completed"?we.status="completed":Te>0&&Te<100&&re.status==="todo"?we.status="in-progress":Te===0&&re.status!=="todo"&&(we.status="todo");}return we}),ke[U]&&Ee(re=>{let we={...re};return delete we[U],we});},at=m.find(U=>U.id===R.status)??ui[0],lt=gi.find(U=>U.id===R.priority)??gi[1],dt=er.find(U=>U.value===R.color)??er[0],tt={backgroundColor:y.bgSecondary,border:`1px solid ${y.borderLight}`,color:y.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":p,style:{backgroundColor:y.bgPrimary,border:`1px solid ${y.border}`},onClick:U=>U.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${y.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:at.color||y.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:y.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:y.textTertiary},onMouseEnter:U=>{U.currentTarget.style.backgroundColor=y.hoverBg,U.currentTarget.style.color=y.textPrimary;},onMouseLeave:U=>{U.currentTarget.style.backgroundColor="transparent",U.currentTarget.style.color=y.textTertiary;},disabled:n,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:Ke,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:R.name,onChange:U=>Me("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:y.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),ke.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),ke.name]})]}),jsx("div",{children:jsx("textarea",{value:R.description||"",onChange:U=>Me("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:y.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsx("div",{style:{borderTop:`1px solid ${y.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:z,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&v(!f),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...tt,borderColor:at.color,backgroundColor:`${at.color}15`},disabled:n,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:at.color}}),jsx("span",{style:{color:at.color},children:at.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:at.color}})]}),jsx(AnimatePresence,{children:f&&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:y.bgPrimary,border:`1px solid ${y.border}`},children:m.map(U=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:y.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=y.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Me("status",U.id),v(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:U.color}}),U.title,R.status===U.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:y.accent}})]},U.id))})})]}),jsxs("div",{ref:W,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&k(!g),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:tt,disabled:n,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:lt.color}}),jsx("span",{children:lt.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:y.textTertiary}})]}),jsx(AnimatePresence,{children:g&&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:y.bgPrimary,border:`1px solid ${y.border}`},children:gi.map(U=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:y.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=y.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Me("priority",U.id),k(false);},children:[jsx("span",{children:U.icon}),U.label,R.priority===U.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:y.accent}})]},U.id))})})]}),o.length>0&&jsxs("div",{ref:N,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!n&&S(!x),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:tt,disabled:n,children:[R.assignees&&R.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:R.assignees.slice(0,3).map((U,ne)=>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||y.accent,borderColor:y.bgSecondary},children:U.initials},ne))}),R.assignees.length>3&&jsxs("span",{style:{color:y.textTertiary},children:["+",R.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:y.textTertiary}}),jsx("span",{style:{color:y.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:y.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-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:y.bgPrimary,border:`1px solid ${y.border}`},children:o.map(U=>{let ne=R.assignees?.some(re=>re.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:y.textPrimary},onMouseEnter:re=>re.currentTarget.style.backgroundColor=y.hoverBg,onMouseLeave:re=>re.currentTarget.style.backgroundColor="transparent",onClick:()=>{let re=ne?(R.assignees||[]).filter(we=>we.name!==U.name):[...R.assignees||[],{name:U.name,avatar:U.avatar,initials:U.name.split(" ").map(we=>we[0]).join("").toUpperCase().slice(0,2),color:y.accent}];Me("assignees",re);},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:y.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:ne&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:y.accent}})})]},U.id)})})})]}),jsxs("div",{ref:j,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!n)if(L)w(false);else {if(j.current){let U=j.current.getBoundingClientRect(),ne=window.innerHeight,re=120,Te=ne-U.bottom<re?U.top-re-8:U.bottom+8;M({top:Te,left:U.left});}w(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:tt,disabled:n,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:R.color}}),jsx("span",{children:dt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:y.textTertiary}})]}),jsx(AnimatePresence,{children:L&&jsxs(pt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>w(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:`${O.top}px`,left:`${O.left}px`,zIndex:99999,backgroundColor:y.bgPrimary,border:`1px solid ${y.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:er.slice(0,18).map(U=>{let ne=R.color===U.value;return jsx("button",{type:"button",onClick:re=>{re.preventDefault(),re.stopPropagation(),Me("color",U.value),w(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:ne?`2px solid ${U.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},U.value)})})})})]})})]}),u.length>0||d?jsx(Qa,{selectedTags:R.tags||[],availableTags:u,onChange:U=>Me("tags",U),onCreateTag:d,theme:y,disabled:n}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:y.textTertiary}}),jsxs("div",{ref:q,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!n&&!R.isMilestone)if(T==="start")_(null);else {if(q.current){let U=q.current.getBoundingClientRect(),ne=window.innerHeight,re=320,Te=ne-U.bottom<re?U.top-re-8:U.bottom+8;be({top:Te,left:U.left});}_("start"),J(R.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...tt,opacity:R.isMilestone?.5:1,cursor:R.isMilestone?"not-allowed":"pointer"},disabled:n||R.isMilestone,children:R.startDate?R.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:y.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!n&&!R.isMilestone)if(T==="end")_(null);else {if(q.current){let U=q.current.getBoundingClientRect(),ne=window.innerHeight,re=320,Te=ne-U.bottom<re?U.top-re-8:U.bottom+8;be({top:Te,left:U.left});}_("end"),J(R.endDate||R.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...tt,opacity:R.isMilestone?.5:1,cursor:R.isMilestone?"not-allowed":"pointer"},disabled:n||R.isMilestone,children:R.endDate?R.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:T&&jsxs(pt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>_(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:y.bgPrimary,border:`1px solid ${y.border}`},onClick:U=>U.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${y.border}`},children:[(()=>{let U=new Date,ne=new Date(U);ne.setDate(U.getDate()+1);let re=new Date(U);re.setDate(U.getDate()+7);let we=new Date(U);return we.setDate(U.getDate()+14),[{label:"Hoy",date:U},{label:"Ma\xF1ana",date:ne},{label:"Pr\xF3xima semana",date:re},{label:"2 semanas",date:we}].map((rt,wt)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:y.textPrimary},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor=y.hoverBg,onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{T==="start"?(Me("startDate",rt.date),(!R.endDate||rt.date>R.endDate)&&Me("endDate",rt.date),_("end")):(Me("endDate",rt.date),(!R.startDate||rt.date<R.startDate)&&Me("startDate",rt.date),_(null));},children:rt.label},wt))})(),jsx("div",{style:{borderTop:`1px solid ${y.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=y.hoverBg,onMouseLeave:U=>U.currentTarget.style.backgroundColor="transparent",onClick:()=>{Me("startDate",void 0),Me("endDate",void 0),_(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(B.getFullYear(),B.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:y.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:y.textPrimary},children:B.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>J(new Date(B.getFullYear(),B.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:y.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((U,ne)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:y.textTertiary},children:U},ne))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let U=B.getFullYear(),ne=B.getMonth(),re=new Date(U,ne,1).getDay(),we=new Date(U,ne+1,0).getDate(),Te=new Date,rt=[];for(let Ie=re-1;Ie>=0;Ie--)rt.push({day:new Date(U,ne,-Ie).getDate(),date:new Date(U,ne-1,new Date(U,ne,-Ie).getDate()),isCurrentMonth:false});for(let Ie=1;Ie<=we;Ie++)rt.push({day:Ie,date:new Date(U,ne,Ie),isCurrentMonth:true});let wt=42-rt.length;for(let Ie=1;Ie<=wt;Ie++)rt.push({day:Ie,date:new Date(U,ne+1,Ie),isCurrentMonth:false});return rt.map((Ie,ye)=>{let Se=Ie.date.toDateString()===Te.toDateString(),St=R.startDate?.toDateString()===Ie.date.toDateString(),gt=R.endDate?.toDateString()===Ie.date.toDateString(),ta=R.startDate&&R.endDate&&Ie.date>=R.startDate&&Ie.date<=R.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Ie.isCurrentMonth?St||gt?"#FFF":y.textPrimary:y.textTertiary,backgroundColor:St?"#3B82F6":gt?"#7C3AED":ta?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Se&&!St&&!gt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{T==="start"?(Me("startDate",Ie.date),R.endDate&&Ie.date>R.endDate&&Me("endDate",Ie.date),_("end")):(Me("endDate",Ie.date),R.startDate&&Ie.date<R.startDate&&Me("startDate",Ie.date),_(null));},children:Ie.day},ye)})})()})]})]})]})})]}),ke.endDate&&jsx("span",{className:"text-xs text-red-400",children:ke.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:y.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:R.progress,onChange:U=>Me("progress",parseInt(U.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:y.bgSecondary,accentColor:R.progress<30?"#EF4444":R.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:`${R.progress<30?"#EF4444":R.progress<70?"#F59E0B":"#10B981"}20`,color:R.progress<30?"#EF4444":R.progress<70?"#F59E0B":"#10B981"},children:[R.progress,"%"]})]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Oe(!Fe),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:y.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${Fe?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:Fe&&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:[(h||i.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:y.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:y.textTertiary},children:["Adjuntos ",c==="create"?je.length>0&&`(${je.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsx(rr,{cardId:"pending",attachments:je.map((U,ne)=>({id:`pending-${ne}`,cardId:"pending",name:U.name,size:U.size,type:U.type,url:URL.createObjectURL(U),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:U=>H(ne=>[...ne,...U]),onDelete:U=>{let ne=parseInt(U.replace("pending-",""),10);H(re=>re.filter((we,Te)=>Te!==ne));},maxSizeMB:10,maxFiles:20}):jsx(rr,{cardId:a?.id||"new",attachments:i,onUpload:h&&a?.id?U=>h(a.id,U):void 0,onDelete:C,maxSizeMB:10,maxFiles:20}),c==="create"&&je.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:y.textTertiary},children:[je.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:R.isMilestone,onChange:U=>Me("isMilestone",U.target.checked),className:"w-4 h-4 rounded",style:{accentColor:y.accent},disabled:n}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:y.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:y.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:y.bgSecondary},children:r.filter(U=>U.id!==a?.id).map(U=>{let ne=R.dependencies?.includes(U.id);return jsx("button",{type:"button",onClick:()=>{let re=ne?(R.dependencies||[]).filter(we=>we!==U.id):[...R.dependencies||[],U.id];Me("dependencies",re);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:ne?`${y.accent}30`:y.bgPrimary,color:ne?y.accent:y.textSecondary,border:`1px solid ${ne?y.accent:y.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 ${y.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:y.textSecondary},onMouseEnter:U=>U.currentTarget.style.backgroundColor=y.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:y.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 xc=`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
@@ -386,7 +386,7 @@ If ambiguous, ask for clarification in the message field.`;function kc(e){return
386
386
  ${wc(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 wc(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function cr(e,t){let a=wc(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 m=c.name.toLowerCase();return n.every(l=>m.includes(l))})}function fi(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 i=new Date(r);return i.setDate(i.getDate()+1),i}if(a==="yesterday"||a==="ayer"){let i=new Date(r);return i.setDate(i.getDate()-1),i}if(a==="next week"||a==="la pr\xF3xima semana"){let i=new Date(r);return i.setDate(i.getDate()+7),i}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 h={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(h!==void 0){let C=new Date(r),p=C.getDay(),y=h-p;return y<=0&&(y+=7),C.setDate(C.getDate()+y),C}}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 i=parseInt(s[1],10),h=s[2].toLowerCase(),C=new Date(r);return h==="day"||h==="d\xEDa"||h==="dias"?C.setDate(C.getDate()+i):h==="week"||h==="semana"||h==="semanas"?C.setDate(C.getDate()+i*7):(h==="month"||h==="mes"||h==="meses")&&C.setMonth(C.getMonth()+i),C}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 i=parseInt(c[1],10),h=parseInt(c[2],10)-1,C=parseInt(c[3],10);return new Date(C,h,i)}let m={enero:0,febrero:1,marzo:2,abril:3,mayo:4,junio:5,julio:6,agosto:7,septiembre:8,octubre:9,noviembre:10,diciembre:11},l=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(l&&l[1]&&l[2]){let i=parseInt(l[1],10),h=m[l[2].toLowerCase()],C=l[3]?parseInt(l[3],10):r.getFullYear();if(h!==void 0)return new Date(C,h,i)}let u={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11},d=a.match(/(january|february|march|april|may|june|july|august|september|october|november|december)\s+(\d{1,2})(?:,?\s+(\d{4}))?/i);if(d&&d[1]&&d[2]){let i=u[d[1].toLowerCase()],h=parseInt(d[2],10),C=d[3]?parseInt(d[3],10):r.getFullYear();if(i!==void 0)return new Date(C,i,h)}return null}function hi(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 bi(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 Cc(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 Tc(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 l=r[1].trim(),u=r[2].trim(),d=cr(t,l),i=fi(u);if(!d)return {type:"move_task",taskName:l,message:`Could not find a task named "${l}". Please check the task name and try again.`,success:false,error:"Task not found"};if(!i)return {type:"move_task",taskId:d.id,taskName:d.name,message:`Could not parse the date "${u}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let h=d.startDate&&d.endDate?Math.round((d.endDate.getTime()-d.startDate.getTime())/(1e3*60*60*24)):1,C=new Date(i);return C.setDate(C.getDate()+h),{type:"move_task",taskId:d.id,taskName:d.name,updates:{startDate:i,endDate:C},message:`Moved "${d.name}" to ${i.toLocaleDateString()}.`,success:true}}let o=a.match(/(?:extend|extender|extiende|alargar)\s+["""]?(.+?)["""]?\s+(?:by|por)\s+(.+)/i);if(o&&o[1]&&o[2]){let l=o[1].trim(),u=o[2].trim(),d=cr(t,l),i=hi(u);if(!d)return {type:"resize_task",taskName:l,message:`Could not find a task named "${l}".`,success:false,error:"Task not found"};if(!i||!d.endDate)return {type:"resize_task",taskId:d.id,taskName:d.name,message:`Could not parse the duration "${u}".`,success:false,error:"Invalid duration"};let h=new Date(d.endDate);return h.setDate(h.getDate()+i),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:h},message:`Extended "${d.name}" by ${i} days. New end date: ${h.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 l=s[1].trim(),u=s[2].trim(),d=cr(t,l),i=bi(u);return d?i===null?{type:"set_progress",taskId:d.id,taskName:d.name,message:`Could not parse the progress value "${u}".`,success:false,error:"Invalid progress"}:{type:"set_progress",taskId:d.id,taskName:d.name,updates:{progress:i},message:`Set "${d.name}" progress to ${i}%.`,success:true}:{type:"set_progress",taskName:l,message:`Could not find a task named "${l}".`,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 l=n[1].trim(),u=n[2].trim(),d=cr(t,l);return d?{type:"rename_task",taskId:d.id,taskName:d.name,updates:{name:u},message:`Renamed "${d.name}" to "${u}".`,success:true}:{type:"rename_task",taskName:l,message:`Could not find a task named "${l}".`,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 l=c[1].trim(),u=c[2].trim(),d=cr(t,l),i=cr(t,u);return d?i?{type:"link_tasks",taskId:i.id,taskName:i.name,dependencyFrom:d.id,dependencyTo:i.id,message:`Linked "${d.name}" \u2192 "${i.name}".`,success:true}:{type:"link_tasks",taskName:u,message:`Could not find a task named "${u}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:l,message:`Could not find a task named "${l}".`,success:false,error:"Source task not found"}}let m=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(m&&m[1]){let l=m[1].trim(),u=cr(t,l);return u?{type:"delete_task",taskId:u.id,taskName:u.name,message:`Deleted "${u.name}".`,success:true}:{type:"delete_task",taskName:l,message:`Could not find a task named "${l}".`,success:false,error:"Task not found"}}return null}function Nc(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 M0(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 A0(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function An(e,t=[],a=[]){let r=e.assignedUserIds?.map(u=>{let d=a.find(i=>i.id===u);return d?{name:d.name,initials:d.initials,color:d.color}:null}).filter(u=>u!==null),o=t.filter(u=>u.metadata?.parentCardId===e.id).map(u=>An(u,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(u=>u.type==="finish-to-start").map(u=>u.taskId));let n=u=>{if(u)return typeof u=="string"?new Date(u):u},c=n(e.startDate),m=n(e.endDate),l=e.metadata?.isMilestone===true||c&&m&&Math.abs(m.getTime()-c.getTime())<=864e5;return {id:e.id,name:e.title,startDate:c,endDate:m,progress:e.progress||0,status:M0(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:l,isCriticalPath:e.metadata?.isCriticalPath===true}}function Dc(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:A0(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Sc(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>An(r,e,t))}var yi={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"}},vi={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"}},Fn={en:yi,es:vi};function xi(e){return Fn[e]||Fn.en}function In(e,t){let a=xi(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}function Ac(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(...Ac(r.subtasks,t+1));return a}function W0({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 Fc({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:n}){let{theme:c="dark",locale:m="en",customTranslations:l,showSearch:u=true,showHierarchy:d=true}=t,i=In(m,l),h=c==="dark",[C,p]=useState(new Set),[y,f]=useState("startDate"),[v,g]=useState("asc"),[k,x]=useState("");useMemo(()=>{let P=new Set;function T(G){for(let R of G)R.subtasks?.length&&(P.add(R.id),T(R.subtasks));}T(e),p(P);},[e]);let D=useCallback(P=>{p(T=>{let G=new Set(T);return G.has(P)?G.delete(P):G.add(P),G}),a.onTaskToggleExpand?.(P);},[a]),B=useCallback(P=>{y===P?g(T=>T==="asc"?"desc":"asc"):(f(P),g("asc")),a.onSortChange?.({column:P,direction:v==="asc"?"desc":"asc"});},[y,v,a]),w=useMemo(()=>{let P=Ac(e);if(k.trim()){let G=k.toLowerCase();P=P.filter(R=>R.name.toLowerCase().includes(G));}let T=[];for(let G of P){let R=G.level===0;G.level>0&&(R=true),(R||k.trim())&&T.push(G);}return k.trim()&&T.sort((G,R)=>{let q,te;switch(y){case "name":q=G.name.toLowerCase(),te=R.name.toLowerCase();break;case "startDate":q=G.startDate?.getTime()||0,te=R.startDate?.getTime()||0;break;case "endDate":q=G.endDate?.getTime()||0,te=R.endDate?.getTime()||0;break;case "progress":q=G.progress||0,te=R.progress||0;break;case "status":q=G.status||"todo",te=R.status||"todo";break;default:return 0}return q<te?v==="asc"?-1:1:q>te?v==="asc"?1:-1:0}),T},[e,k,y,v]),z=P=>P?(P instanceof Date?P:new Date(P)).toLocaleDateString(m==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:b("flex-1 flex items-center justify-center",h?"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:b("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[i.empty.noTasks,"..."]})]})}):o?jsx("div",{className:b("flex-1 flex items-center justify-center",h?"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:b("text-lg font-semibold mb-2",h?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:b("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:b("flex-1 flex items-center justify-center",h?"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:b("text-lg font-semibold mb-2",h?"text-white":"text-gray-900"),children:i.empty.noTasks}),jsx("p",{className:b("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.addFirstTask})]})}):jsxs("div",{className:b("flex-1 flex flex-col w-full h-full overflow-hidden",h?"bg-[#0F1117]":"bg-white",s),style:n,children:[jsx("div",{className:b("flex-shrink-0 px-6 py-4 border-b",h?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[u&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:b("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:k,onChange:P=>x(P.target.value),placeholder:i.toolbar.searchPlaceholder,className:b("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",h?"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:b("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[w.length," ",i.pagination.tasks]})]})}),jsxs("div",{className:b("flex-shrink-0 grid grid-cols-12 gap-4 px-6 py-3 border-b text-xs font-medium uppercase tracking-wider",h?"border-white/10 bg-white/5 text-[#9CA3AF]":"border-gray-200 bg-gray-50 text-gray-500"),children:[jsx("div",{className:"col-span-5 flex items-center gap-2",children:jsxs("button",{onClick:()=>B("name"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.name,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>B("status"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.status,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>B("startDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.startDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>B("endDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.endDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-1 flex items-center gap-1",children:jsxs("button",{onClick:()=>B("progress"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:["%",jsx(ArrowUpDown,{className:"w-3 h-3"})]})})]}),jsxs("div",{className:"flex-1 overflow-auto",children:[jsx(AnimatePresence,{children:w.map((P,T)=>{let G=C.has(P.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:T*.02},className:b("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",h?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),style:{paddingLeft:d?`${24+P.level*24}px`:void 0},onClick:()=>a.onTaskClick?.(P),onDoubleClick:()=>a.onTaskDoubleClick?.(P),children:[jsxs("div",{className:"col-span-5 flex items-center gap-2 min-w-0",children:[d&&P.hasChildren&&jsx("button",{onClick:R=>{R.stopPropagation(),D(P.id);},className:b("p-0.5 rounded",h?"hover:bg-white/10":"hover:bg-gray-200"),children:G?jsx(ChevronDown,{className:b("w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:b("w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")})}),d&&!P.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:R=>{R.stopPropagation(),a.onTaskUpdate?.({...P,progress:P.progress===100?0:100,status:P.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(W0,{status:P.status,progress:P.progress})}),jsx("span",{className:b("truncate",h?"text-white":"text-gray-900",P.progress===100&&(h?"line-through text-[#6B7280]":"line-through text-gray-400")),children:P.name})]}),jsx("div",{className:"col-span-2 flex items-center",children:jsx("span",{className:b("px-2 py-1 rounded-full text-xs font-medium",P.progress===100||P.status==="completed"?"bg-green-500/10 text-green-500":P.progress&&P.progress>0||P.status==="in-progress"?"bg-blue-500/10 text-blue-500":h?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:P.progress===100||P.status==="completed"?i.status.completed:P.progress&&P.progress>0||P.status==="in-progress"?i.status.inProgress:i.status.todo})}),jsxs("div",{className:b("col-span-2 flex items-center gap-1 text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),z(P.startDate)]}),jsxs("div",{className:b("col-span-2 flex items-center gap-1 text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),z(P.endDate)]}),jsx("div",{className:"col-span-1 flex items-center",children:jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{className:b("flex-1 h-1.5 rounded-full overflow-hidden",h?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:b("h-full rounded-full transition-all",P.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${P.progress||0}%`}})}),jsxs("span",{className:b("text-xs w-8",h?"text-[#9CA3AF]":"text-gray-500"),children:[P.progress||0,"%"]})]})})]},P.id)})}),w.length===0&&k&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:b("w-12 h-12 mx-auto mb-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:b(h?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.noResults})]})})]})]})}var ki={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"},wi={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"},Ci={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"},Bn={dark:ki,light:wi,neutral:Ci};function Ic(e){return Bn[e]||Bn.dark}var Ti={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"}},Ni={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"}},Rn={en:Ti,es:Ni};function Oo(e){return Rn[e]||Rn.en}function On(e,t){let a=Oo(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 Lc(e){let t=Oo(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 Bc(e,t=0,a=true){let r=Oo(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 sh(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 Ai(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 $c({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 Wc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:n,style:c,availableTags:m=[],onCreateTag:l,attachmentsByTask:u}){let{theme:d="dark",locale:i="en",customTranslations:h}=t,C=On(i,h),p=d==="dark",y={textTertiary:p?"#6B7280":"#9CA3AF",textSecondary:p?"#9CA3AF":"#6B7280",textPrimary:p?"#FFFFFF":"#111827",borderLight:p?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",border:p?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",bgPrimary:p?"#1A1D25":"#FFFFFF",bgSecondary:p?"#0F1117":"#F9FAFB",hoverBg:p?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},[f,v]=useState(r||new Date),[g,k]=useState(null),[x,D]=useState(null),[B,w]=useState(null),[z,P]=useState(new Date),[T,G]=useState({}),R=4,q=3,[te,xe]=useState(false),[Ae,ze]=useState(false),[le,O]=useState(false),[L,H]=useState(false),[F,X$1]=useState(null),[Q,U]=useState(""),[ke,Te]=useState(void 0),[Fe,ve]=useState(null),[et,Ie]=useState(false),[pt,it]=useState(false),[lt,tt]=useState(null),[$,ne]=useState(false),[re,we]=useState(new Date),[Ne,at]=useState(false),[wt,Le]=useState(false),[he,Ee]=useState(false),[St,gt]=useState(""),[ta,sa]=useState(false),_e=useCallback(()=>{v(new Date(f.getFullYear(),f.getMonth()-1,1));},[f]),He=useCallback(()=>{v(new Date(f.getFullYear(),f.getMonth()+1,1));},[f]),ia=useCallback(()=>{v(new Date);},[]),fe=useMemo(()=>{let N=f.getFullYear(),M=f.getMonth(),_=new Date(N,M,1),pe=new Date(N,M+1,0),Ke=_.getDay(),Z=pe.getDate(),Oe=sh(e),Nt=new Date;Nt.setHours(0,0,0,0);let Me=[],aa=Ke,oe=new Date(N,M,0).getDate();for(let rt=aa-1;rt>=0;rt--){let $e=new Date(N,M-1,oe-rt);Me.push({date:$e,isCurrentMonth:false,isToday:false,isWeekend:$e.getDay()===0||$e.getDay()===6,events:Oe.filter(Et=>Ai($e,Et)).map(Et=>({id:Et.id,title:Et.name,start:Et.startDate,end:Et.endDate,task:Et}))});}for(let rt=1;rt<=Z;rt++){let $e=new Date(N,M,rt),Et=$e.getTime()===Nt.getTime();Me.push({date:$e,isCurrentMonth:true,isToday:Et,isWeekend:$e.getDay()===0||$e.getDay()===6,events:Oe.filter(Pt=>Ai($e,Pt)).map(Pt=>({id:Pt.id,title:Pt.name,start:Pt.startDate,end:Pt.endDate,task:Pt}))});}let nt=42-Me.length;for(let rt=1;rt<=nt;rt++){let $e=new Date(N,M+1,rt);Me.push({date:$e,isCurrentMonth:false,isToday:false,isWeekend:$e.getDay()===0||$e.getDay()===6,events:Oe.filter(Et=>Ai($e,Et)).map(Et=>({id:Et.id,title:Et.name,start:Et.startDate,end:Et.endDate,task:Et}))});}return Me},[f,e]),S=i==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],J=f.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),ce=useCallback((N,M)=>{if(!g)return;let _={...g,[N]:M};k(_),a.onTaskUpdate?.(_);},[g,a]),De=useCallback(N=>{if(!g)return;let M=g.progress||0;N==="completed"?M=100:N==="todo"&&(M=0);let _={...g,status:N,progress:M};k(_),a.onTaskUpdate?.(_),xe(false);},[g,a]),Ue=useCallback((N,M)=>{if(!g)return;let _={...g,startDate:N,endDate:M};k(_),a.onTaskUpdate?.(_);},[g,a]),Re=useCallback(()=>{xe(false),ze(false),O(false),w(null),Ee(false),gt(""),sa(false);},[]),Be=useCallback(async N=>{if(N.preventDefault(),N.stopPropagation(),at(false),!g||!a.onUploadAttachments)return;let M=Array.from(N.dataTransfer.files);if(M.length!==0){Le(true);try{await a.onUploadAttachments(g.id,M);}finally{Le(false);}}},[g,a]),Je=useCallback(async N=>{if(!g||!a.onUploadAttachments||!N.target.files)return;let M=Array.from(N.target.files);if(M.length!==0){Le(true);try{await a.onUploadAttachments(g.id,M);}finally{Le(false);}N.target.value="";}},[g,a]),dt=useCallback(N=>{N.preventDefault(),N.stopPropagation(),at(true);},[]),K=useCallback(N=>{N.preventDefault(),N.stopPropagation(),at(false);},[]),ae=useCallback(N=>N<1024?`${N} B`:N<1024*1024?`${(N/1024).toFixed(1)} KB`:`${(N/(1024*1024)).toFixed(1)} MB`,[]),Pe=useCallback(N=>N.startsWith("image/")?Image:N.includes("pdf")||N.includes("document")?FileText:File,[]),We=useMemo(()=>!g||!u?[]:u.get(g.id)||[],[g,u]);return o?jsx("div",{className:b("flex-1 flex items-center justify-center",p?"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:b("text-sm",p?"text-[#9CA3AF]":"text-gray-600"),children:[C.labels.noEvents,"..."]})]})}):s?jsx("div",{className:b("flex-1 flex items-center justify-center",p?"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:b("text-lg font-semibold mb-2",p?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:b("text-sm",p?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:b("flex-1 flex items-center justify-center",p?"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:b("text-lg font-semibold mb-2",p?"text-white":"text-gray-900"),children:C.labels.noEvents}),jsx("p",{className:b("text-sm",p?"text-[#9CA3AF]":"text-gray-600"),children:C.labels.newTask})]})}):jsxs("div",{className:b("flex-1 flex flex-col w-full h-full overflow-auto",p?"bg-[#0F1117]":"bg-white",n),style:c,children:[jsx("div",{className:b("flex-shrink-0 px-6 py-4 border-b",p?"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:b("text-xl font-semibold capitalize",p?"text-white":"text-gray-900"),children:J}),jsx("button",{onClick:ia,className:b("px-3 py-1.5 text-sm rounded-lg transition-colors",p?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:C.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:_e,className:b("p-2 rounded-lg transition-colors",p?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:b("w-5 h-5",p?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:He,className:b("p-2 rounded-lg transition-colors",p?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:b("w-5 h-5",p?"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:S.map(N=>jsx("div",{className:b("py-2 text-center text-xs font-medium uppercase",p?"text-[#9CA3AF]":"text-gray-500"),children:N},N))}),jsx("div",{className:b("grid grid-cols-7 auto-rows-min gap-px rounded-lg",p?"bg-[#2D2D2D]":"bg-gray-300"),children:fe.map((N,M)=>{let _=N.date.getDay()===0||N.date.getDay()===6;return jsxs("div",{className:b("min-h-[120px] p-2 transition-colors flex flex-col relative group",p?_?"bg-[#1C1F26]":N.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":_?"bg-gray-100":N.isCurrentMonth?"bg-white":"bg-gray-50",N.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let pe=T[M]||R,Ke=N.events.slice(0,pe),Z=N.events.length-pe;return jsxs("div",{className:"space-y-1 flex-1",children:[Ke.map(Oe=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{k(Oe.task),a.onEventClick?.(Oe);},whileHover:{scale:1.02},className:b("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",Oe.task.progress===100?p?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":p?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx($c,{task:Oe.task}),jsx("span",{className:"truncate",children:Oe.title})]})},Oe.id)),Z>0&&jsxs("button",{onClick:Oe=>{Oe.stopPropagation(),G(Nt=>({...Nt,[M]:pe+q}));},className:b("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",p?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",Z," ",i==="es"?"M\xC1S":"MORE"]}),pe>R&&N.events.length>R&&jsx("button",{onClick:Oe=>{Oe.stopPropagation(),G(Nt=>({...Nt,[M]:R}));},className:b("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",p?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:i==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let pe=M>=28,Ke=M%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:Z=>{Z.stopPropagation(),F===M?X$1(null):(X$1(M),U(""),Te(void 0),ve(null),tt(null),Ie(false),it(false),ne(false),we(N.date));},className:b("w-5 h-5 rounded flex items-center justify-center transition-all",F===M?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",p?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:b("w-3.5 h-3.5 transition-transform",F===M&&"rotate-45")})}),jsx(AnimatePresence,{children:F===M&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{X$1(null),U(""),Te(void 0),ve(null),tt(null),Ie(false),it(false),ne(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:b("absolute w-[320px] rounded-lg shadow-2xl z-50",pe?"bottom-full mb-1":"top-full mt-1",Ke?"right-0":"left-0",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Z=>{Z.stopPropagation(),Ie(false),it(false),ne(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Q,onChange:Z=>U(Z.target.value),placeholder:i==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:b("w-full bg-transparent text-sm outline-none placeholder:opacity-40",p?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:Z=>{if(Z.key==="Enter"&&Q.trim()){let Oe=t.availableUsers?.find(Me=>Me.id===Fe),Nt=lt||N.date;a.onTaskCreate?.({name:Q.trim(),startDate:Nt,endDate:Nt,priority:ke,assignees:Oe?[Oe]:void 0}),U(""),Te(void 0),ve(null),tt(null),X$1(null);}Z.key==="Escape"&&(X$1(null),U(""),Te(void 0),ve(null),tt(null));}})}),jsxs("div",{className:b("px-2.5 py-2 flex items-center justify-between border-t",p?"border-white/10":"border-gray-100"),children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs("div",{className:"relative",children:[jsx("button",{onClick:Z=>{Z.stopPropagation(),Ie(!et),it(false);},className:b("p-1 rounded transition-colors",ke?ke==="urgent"||ke==="high"?"text-red-400 bg-red-500/20":ke==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":p?"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:et&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Z=>Z.stopPropagation(),children:[{id:"urgent",label:i==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:i==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:i==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:i==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:i==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(Z=>jsxs("button",{onClick:()=>{Te(Z.id),Ie(false);},className:b("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",p?"hover:bg-white/5":"hover:bg-gray-50",ke===Z.id&&(p?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",Z.color)}),jsx("span",{className:p?"text-white":"text-gray-900",children:Z.label})]},Z.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:Z=>{Z.stopPropagation(),ne(!$),Ie(false),it(false),we(lt||N.date);},className:b("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",lt?"bg-[#7C3AED]/20 text-[#7C3AED]":p?"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"}),(lt||N.date).toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:$&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Z=>Z.stopPropagation(),children:[jsx("div",{className:b("w-40 py-2 border-r",p?"border-white/10":"border-gray-200"),children:(()=>{let Z=new Date,Oe=new Date(Z);Oe.setDate(Z.getDate()+1);let Nt=new Date(Z);Nt.setDate(Z.getDate()+((6-Z.getDay()+7)%7||7));let Me=new Date(Z);Me.setDate(Z.getDate()+((1-Z.getDay()+7)%7||7));let aa=new Date(Z);aa.setDate(Z.getDate()+14);let oe=new Date(Z);return oe.setDate(Z.getDate()+28),[{label:i==="es"?"Hoy":"Today",date:Z,display:Z.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:i==="es"?"Ma\xF1ana":"Tomorrow",date:Oe,display:Oe.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:i==="es"?"Este fin de semana":"This weekend",date:Nt,display:i==="es"?"s\xE1b.":"sat."},{label:i==="es"?"Pr\xF3xima semana":"Next week",date:Me,display:i==="es"?"lun.":"mon."},{label:i==="es"?"2 semanas":"2 weeks",date:aa,display:aa.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:i==="es"?"4 semanas":"4 weeks",date:oe,display:oe.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((rt,$e)=>jsxs("button",{className:b("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",p?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{tt(rt.date),ne(false);},children:[jsx("span",{children:rt.label}),jsx("span",{className:b("text-[10px]",p?"text-[#6B7280]":"text-gray-400"),children:rt.display})]},$e))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:b("text-xs font-medium",p?"text-white":"text-gray-900"),children:re.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>we(new Date),className:b("px-1.5 py-0.5 rounded text-[10px] transition-colors",p?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:i==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>we(new Date(re.getFullYear(),re.getMonth()-1)),className:b("p-0.5 rounded",p?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>we(new Date(re.getFullYear(),re.getMonth()+1)),className:b("p-0.5 rounded",p?"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:(i==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(Z=>jsx("div",{className:b("w-6 h-6 flex items-center justify-center text-[10px]",p?"text-[#6B7280]":"text-gray-400"),children:Z},Z))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let Z=re.getFullYear(),Oe=re.getMonth(),Nt=new Date(Z,Oe,1).getDay(),Me=new Date(Z,Oe+1,0).getDate(),aa=new Date(Z,Oe,0).getDate(),oe=new Date,nt=[];for(let $e=Nt-1;$e>=0;$e--)nt.push({dayNum:aa-$e,isCurrentMonth:false,date:new Date(Z,Oe-1,aa-$e)});for(let $e=1;$e<=Me;$e++)nt.push({dayNum:$e,isCurrentMonth:true,date:new Date(Z,Oe,$e)});let rt=42-nt.length;for(let $e=1;$e<=rt;$e++)nt.push({dayNum:$e,isCurrentMonth:false,date:new Date(Z,Oe+1,$e)});return nt.map(($e,Et)=>{let Pt=$e.date.toDateString()===oe.toDateString(),da=(lt||N.date).toDateString()===$e.date.toDateString();return jsx("button",{className:b("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!$e.isCurrentMonth&&(p?"text-[#4B5563]":"text-gray-300"),$e.isCurrentMonth&&(p?"text-white":"text-gray-900"),Pt&&"ring-1 ring-[#3B82F6]",da&&"bg-[#7C3AED] text-white",!da&&(p?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{tt($e.date),ne(false);},children:$e.dayNum},Et)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:Z=>{Z.stopPropagation(),it(!pt),Ie(false);},className:b("p-1 rounded transition-colors",Fe?"text-[#7C3AED] bg-[#7C3AED]/20":p?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:Fe?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(Z=>Z.id===Fe)?.color||"#7C3AED"},children:t.availableUsers?.find(Z=>Z.id===Fe)?.initials||t.availableUsers?.find(Z=>Z.id===Fe)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:pt&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Z=>Z.stopPropagation(),children:[jsxs("button",{onClick:()=>{ve(null),it(false);},className:b("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",p?"hover:bg-white/5":"hover:bg-gray-50",!Fe&&(p?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:b("w-5 h-5 rounded-full flex items-center justify-center",p?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:p?"text-[#9CA3AF]":"text-gray-500",children:i==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(Z=>jsxs("button",{onClick:()=>{ve(Z.id),it(false);},className:b("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",p?"hover:bg-white/5":"hover:bg-gray-50",Fe===Z.id&&(p?"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:Z.color||"#7C3AED"},children:Z.initials||Z.name?.slice(0,2).toUpperCase()}),jsx("span",{className:p?"text-white":"text-gray-900",children:Z.name})]},Z.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:b("px-3 py-2 text-xs",p?"text-[#6B7280]":"text-gray-400"),children:i==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Q.trim()){let Z=t.availableUsers?.find(Nt=>Nt.id===Fe),Oe=lt||N.date;a.onTaskCreate?.({name:Q.trim(),startDate:Oe,endDate:Oe,priority:ke,assignees:Z?[Z]:void 0}),U(""),Te(void 0),ve(null),tt(null),X$1(null);}},disabled:!Q.trim(),className:b("px-2.5 py-1 rounded text-xs font-medium transition-colors",Q.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":p?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:i==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:b("text-sm font-medium",N.isToday?"text-[#3B82F6]":N.isCurrentMonth?p?"text-white":"text-gray-900":p?"text-[#6B7280]":"text-gray-400"),children:N.date.getDate()})]})]},M)})})]})}),jsx(AnimatePresence,{children:g&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>k(null),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:b("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",p?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:b("px-6 py-3 border-b flex items-center gap-3",p?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:b("w-4 h-4",p?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:b("text-xs px-2 py-0.5 rounded",p?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[i==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:b("text-xs font-mono",p?"text-[#6B7280]":"text-gray-400"),children:g.id.slice(0,8)}),jsxs("button",{className:b("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",p?"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:b("p-1.5 rounded transition-colors",p?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:b("p-1.5 rounded transition-colors",p?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>k(null),className:b("p-1.5 rounded transition-colors",p?"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 N=g.progress===100?0:100,_={...g,progress:N,status:N===100?"completed":"todo"};k(_),a.onTaskUpdate?.(_);},className:b("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",g.progress===100?"bg-green-500 border-green-500":p?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:g.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:b("text-xl font-semibold flex-1",g.progress===100?"line-through text-[#6B7280]":p?"text-white":"text-gray-900"),children:g.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:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{Re(),xe(!te);},className:b("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",g.progress===100||g.status==="completed"?"bg-green-500/20 text-green-400":g.progress&&g.progress>0||g.status==="in-progress"?"bg-blue-500/20 text-blue-400":p?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:g.progress===100||g.status==="completed"?i==="es"?"COMPLETADO":"DONE":g.progress&&g.progress>0||g.status==="in-progress"?i==="es"?"EN PROGRESO":"IN PROGRESS":i==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:te&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>xe(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:i==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:i==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:i==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(N=>jsxs("button",{onClick:()=>De(N.id),className:b("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",p?"hover:bg-white/5":"hover:bg-gray-50",(g.status===N.id||N.id==="completed"&&g.progress===100||N.id==="in-progress"&&g.progress&&g.progress>0&&g.progress<100||N.id==="todo"&&(!g.progress||g.progress===0)&&g.status!=="in-progress"&&g.status!=="completed")&&(p?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",N.id==="completed"?"bg-green-500":N.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:p?"text-white":"text-gray-900",children:N.label})]},N.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{xe(false),ze(false),w(null),O(!le);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",p?"bg-white/5 hover:bg-white/10":"bg-gray-100 hover:bg-gray-200"),children:[g.assignees&&g.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[g.assignees.slice(0,3).map((N,M)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:N.color||"#8B5CF6"},title:N.name,children:N.initials||N.name.slice(0,2).toUpperCase()},M)),g.assignees.length>3&&jsxs("span",{className:b("text-xs",p?"text-[#6B7280]":"text-gray-400"),children:["+",g.assignees.length-3]})]}):jsx("span",{className:b("text-sm",p?"text-[#6B7280]":"text-gray-400"),children:i==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:b("w-3 h-3",p?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:le&&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:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[200px] max-h-[280px] overflow-y-auto",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:t.availableUsers&&t.availableUsers.length>0?t.availableUsers.map(N=>{let M=g.assignees?.some(_=>_.name===N.name);return jsxs("button",{onClick:()=>{let _=g.assignees||[],pe;M?pe=_.filter(Ke=>Ke.name!==N.name):pe=[..._,{name:N.name,avatar:N.avatar,initials:N.initials||N.name.slice(0,2).toUpperCase(),color:N.color||"#8B5CF6"}],ce("assignees",pe);},className:b("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",p?"hover:bg-white/5":"hover:bg-gray-50",M&&(p?"bg-white/5":"bg-gray-50")),children:[N.avatar?jsx("img",{src:N.avatar,alt:N.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:N.color||"#8B5CF6"},children:N.initials||N.name.slice(0,2).toUpperCase()}),jsx("span",{className:b("flex-1 text-left",p?"text-white":"text-gray-900"),children:N.name}),M&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},N.id||N.name)}):jsx("div",{className:b("px-3 py-4 text-sm text-center",p?"text-[#6B7280]":"text-gray-400"),children:i==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{w(B?null:"start"),P(g.startDate||new Date);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",p?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[g.startDate?.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(i==="es"?"Inicio":"Start"),jsx("span",{className:b("mx-1",p?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),g.endDate?.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(i==="es"?"Fin":"End"),(g.startDate||g.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:N=>{N.stopPropagation();}})]}),jsx(AnimatePresence,{children:B&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>w(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:b("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:N=>N.stopPropagation(),children:[jsxs("div",{className:b("w-44 py-2 border-r",p?"border-white/10":"border-gray-200"),children:[(()=>{let N=new Date,M=new Date(N);M.setDate(N.getDate()+1);let _=new Date(N);_.setDate(N.getDate()+((6-N.getDay()+7)%7||7));let pe=new Date(N);pe.setDate(N.getDate()+((1-N.getDay()+7)%7||7));let Ke=new Date(N);Ke.setDate(N.getDate()+(6-N.getDay()+7)%7+7);let Z=new Date(N);Z.setDate(N.getDate()+14);let Oe=new Date(N);return Oe.setDate(N.getDate()+28),[{label:i==="es"?"Hoy":"Today",date:N,display:N.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:i==="es"?"Ma\xF1ana":"Tomorrow",date:M,display:M.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:i==="es"?"Este fin de semana":"This weekend",date:_,display:i==="es"?"s\xE1b.":"sat."},{label:i==="es"?"Pr\xF3xima semana":"Next week",date:pe,display:i==="es"?"lun.":"mon."},{label:i==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:Ke,display:Ke.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:i==="es"?"2 semanas":"2 weeks",date:Z,display:Z.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:i==="es"?"4 semanas":"4 weeks",date:Oe,display:Oe.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Me,aa)=>jsxs("button",{className:b("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",p?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(B==="start"){let oe=g.endDate&&Me.date>g.endDate?Me.date:g.endDate;Ue(Me.date,oe),w("end");}else {let oe=g.startDate&&Me.date<g.startDate?Me.date:g.startDate;Ue(oe,Me.date),w(null);}},children:[jsx("span",{children:Me.label}),jsx("span",{className:b("text-xs",p?"text-[#6B7280]":"text-gray-400"),children:Me.display})]},aa))})(),jsx("div",{className:b("border-t mt-2 pt-2",p?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Ue(void 0,void 0),w(null);},className:b("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",p?"hover:bg-white/5 text-red-400":"hover:bg-gray-50 text-red-500"),children:[jsx("span",{children:i==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:b("text-xs mb-3 px-2 py-1 rounded",p?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:B==="start"?i==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":i==="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:b("font-medium",p?"text-white":"text-gray-900"),children:z.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>P(new Date),className:b("p-1 rounded text-sm transition-colors",p?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:i==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>P(new Date(z.getFullYear(),z.getMonth()-1)),className:b("p-1 rounded",p?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>P(new Date(z.getFullYear(),z.getMonth()+1)),className:b("p-1 rounded",p?"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:(i==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(N=>jsx("div",{className:b("w-8 h-8 flex items-center justify-center text-xs",p?"text-[#6B7280]":"text-gray-400"),children:N},N))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let N=z.getFullYear(),M=z.getMonth(),_=new Date(N,M,1).getDay(),pe=new Date(N,M+1,0).getDate(),Ke=new Date(N,M,0).getDate(),Z=new Date,Oe=[];for(let Me=_-1;Me>=0;Me--)Oe.push({day:Ke-Me,isCurrentMonth:false,date:new Date(N,M-1,Ke-Me)});for(let Me=1;Me<=pe;Me++)Oe.push({day:Me,isCurrentMonth:true,date:new Date(N,M,Me)});let Nt=42-Oe.length;for(let Me=1;Me<=Nt;Me++)Oe.push({day:Me,isCurrentMonth:false,date:new Date(N,M+1,Me)});return Oe.map((Me,aa)=>{let oe=Me.date.toDateString()===Z.toDateString(),nt=g.startDate?.toDateString()===Me.date.toDateString(),rt=g.endDate?.toDateString()===Me.date.toDateString(),$e=nt||rt,Et=g.startDate&&g.endDate&&Me.date>=g.startDate&&Me.date<=g.endDate;return jsx("button",{className:b("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Me.isCurrentMonth&&(p?"text-[#4B5563]":"text-gray-300"),Me.isCurrentMonth&&(p?"text-white":"text-gray-900"),oe&&"ring-2 ring-[#3B82F6]",nt&&"bg-[#3B82F6] text-white",rt&&!nt&&"bg-[#7C3AED] text-white",Et&&!$e&&(p?"bg-[#7C3AED]/20":"bg-purple-100"),!$e&&(p?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let Pt=new Date(Me.date);if(B==="start"){let da=g.endDate&&Pt>g.endDate?Pt:g.endDate;Ue(Pt,da),w("end");}else {let da=g.startDate&&Pt<g.startDate?Pt:g.startDate;Ue(da,Pt),w(null);}},children:Me.day},aa)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{Re(),ze(!Ae);},className:b("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",g.priority==="high"||g.priority==="urgent"?"bg-red-500/20 text-red-400":g.priority==="medium"?"bg-yellow-500/20 text-yellow-400":g.priority==="low"?"bg-green-500/20 text-green-400":p?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:g.priority?g.priority==="high"||g.priority==="urgent"?i==="es"?"Urgente":"Urgent":g.priority==="medium"?i==="es"?"Media":"Medium":i==="es"?"Baja":"Low":i==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:Ae&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ze(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"urgent",label:i==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:i==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:i==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:i==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:i==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(N=>jsxs("button",{onClick:()=>{ce("priority",N.id),ze(false);},className:b("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",p?"hover:bg-white/5":"hover:bg-gray-50",g.priority===N.id&&(p?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",N.color)}),jsx("span",{className:p?"text-white":"text-gray-900",children:N.label})]},N.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:b("text-sm",p?"text-white":"text-gray-900"),children:g.startDate&&g.endDate?`${Math.ceil((g.endDate.getTime()-g.startDate.getTime())/(1e3*60*60*24))} ${i==="es"?"d\xEDas":"days"}`:i==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:b("w-4 h-4 rounded-full border-2",p?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[L?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:g.progress||0,onChange:N=>{let M=parseInt(N.target.value),_=g.status;M===100?_="completed":M>0?_="in-progress":_="todo";let pe={...g,progress:M,status:_};k(pe),a.onTaskUpdate?.(pe);},onBlur:()=>H(false),className:b("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",p?"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:()=>H(true),className:b("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",p?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:b("h-full rounded-full transition-all",g.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${g.progress||0}%`}})}),jsxs("span",{className:b("text-sm font-medium min-w-[40px]",p?"text-white":"text-gray-900"),children:[g.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Etiquetas":"Tags"}),jsx(Qa,{selectedTags:g.tags||[],availableTags:m,onChange:N=>{ce("tags",N);},onCreateTag:l,theme:y})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:b("w-4 h-4 mt-1.5",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24 mt-1",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[g.dependencies&&g.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:g.dependencies.map(N=>{let M=e.find(_=>_.id===N);return jsxs("span",{className:b("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",p?"bg-blue-500/20 text-blue-400":"bg-blue-100 text-blue-700"),children:[M?.name||N.slice(0,8),jsx("button",{onClick:()=>{let _=(g.dependencies||[]).filter(pe=>pe!==N);ce("dependencies",_);},className:b("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},N)})}),jsxs("button",{onClick:()=>{Re(),Ee(!he);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",p?"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:b("text-sm",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:he&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Ee(false),gt("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[280px] max-h-[320px]",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[jsx("div",{className:b("p-2 border-b",p?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:St,onChange:N=>gt(N.target.value),placeholder:i==="es"?"Buscar tarea...":"Search task...",className:b("w-full px-3 py-2 rounded-md text-sm outline-none",p?"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(N=>N.id!==g.id).filter(N=>St===""||N.name.toLowerCase().includes(St.toLowerCase())).map(N=>{let M=g.dependencies?.includes(N.id);return jsxs("button",{onClick:()=>{let _=g.dependencies||[],pe;M?pe=_.filter(Ke=>Ke!==N.id):pe=[..._,N.id],ce("dependencies",pe);},className:b("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors text-left",p?"hover:bg-white/5":"hover:bg-gray-50",M&&(p?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:b("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",M?"bg-blue-500 border-blue-500":p?"border-white/30":"border-gray-300"),children:M&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:b("block truncate",p?"text-white":"text-gray-900"),children:N.name}),jsx("span",{className:b("text-xs",p?"text-[#6B7280]":"text-gray-400"),children:N.id.slice(0,8)})]})]},N.id)}):jsx("div",{className:b("px-3 py-4 text-sm text-center",p?"text-[#6B7280]":"text-gray-500"),children:i==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{Re(),sa(!ta);},className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",p?"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:g.color||"#6366F1"}}),jsx("span",{className:b("text-sm",p?"text-white":"text-gray-900"),children:er.find(N=>N.value===g.color)?.name||(i==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:b("w-3 h-3",p?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:ta&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>sa(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden p-3",p?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:jsx("div",{className:"grid grid-cols-6 gap-1.5",children:er.map(N=>{let M=g.color===N.value;return jsx("button",{onClick:()=>{ce("color",N.value),sa(false);},className:b("w-7 h-7 rounded-full flex items-center justify-center transition-all",M&&"ring-2 ring-offset-2",p?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:N.value,outlineColor:M?N.value:void 0},title:N.name,children:M&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},N.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:g.isMilestone||false,onChange:N=>ce("isMilestone",N.target.checked),className:b("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",g.isMilestone?"bg-purple-500 border-purple-500":p?"border-white/30 bg-transparent":"border-gray-300 bg-transparent","checked:bg-purple-500 checked:border-purple-500")}),jsx("span",{className:b("text-sm",p?"text-white":"text-gray-900"),children:i==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",p?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsx(FileText,{className:b("w-4 h-4",p?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:b("text-sm font-semibold",p?"text-white":"text-gray-900"),children:i==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:g.description||"",onChange:N=>ce("description",N.target.value),placeholder:i==="es"?"Agregar descripci\xF3n...":"Add description...",className:b("w-full min-h-[100px] px-3 py-2 rounded-lg text-sm resize-none outline-none transition-colors",p?"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:b("flex items-center gap-2 text-sm mt-2 transition-colors",p?"text-purple-400 hover:text-purple-300":"text-purple-600 hover:text-purple-700"),children:[jsx(Sparkles,{className:"w-4 h-4"}),i==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",p?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:b("text-sm font-semibold mb-3",p?"text-white":"text-gray-900"),children:i==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",p?"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"}),i==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",p?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:b("text-sm font-semibold mb-3",p?"text-white":"text-gray-900"),children:i==="es"?"Agregar subtarea":"Add subtask"}),g.subtasks&&g.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:g.subtasks.map(N=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:b("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",N.progress===100?"bg-green-500 border-green-500":p?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:N.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:b("text-sm",N.progress===100?"line-through text-[#6B7280]":p?"text-white":"text-gray-900"),children:N.name})]},N.id))}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",p?"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"}),i==="es"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",p?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:b("text-sm font-semibold",p?"text-white":"text-gray-900"),children:i==="es"?"Listas de control":"Checklists"}),jsx("button",{className:b("p-1 rounded transition-colors",p?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",p?"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"}),i==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",p?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:b("text-sm font-semibold mb-3",p?"text-white":"text-gray-900"),children:[i==="es"?"Adjuntos":"Attachments",We.length>0&&jsxs("span",{className:b("ml-2 text-xs font-normal",p?"text-[#6B7280]":"text-gray-400"),children:["(",We.length,")"]})]}),We.length>0&&jsx("div",{className:"space-y-2 mb-4",children:We.map(N=>{let M=Pe(N.type),_=N.type.startsWith("image/");return jsxs("div",{className:b("flex items-center gap-3 p-2 rounded-lg group transition-colors",p?"bg-white/5 hover:bg-white/10":"bg-gray-50 hover:bg-gray-100"),children:[_&&N.thumbnailUrl?jsx("img",{src:N.thumbnailUrl,alt:N.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:b("w-10 h-10 rounded flex items-center justify-center",p?"bg-white/10":"bg-gray-200"),children:jsx(M,{className:b("w-5 h-5",p?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:N.url,target:"_blank",rel:"noopener noreferrer",className:b("text-sm font-medium truncate block hover:underline",p?"text-white":"text-gray-900"),children:N.name}),jsx("p",{className:b("text-xs",p?"text-[#6B7280]":"text-gray-400"),children:ae(N.size)})]}),a.onDeleteAttachment&&jsx("button",{onClick:()=>a.onDeleteAttachment?.(N.id),className:b("p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",p?"hover:bg-red-500/20 text-red-400":"hover:bg-red-100 text-red-500"),title:i==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},N.id)})}),jsxs("div",{onDragOver:dt,onDragLeave:K,onDrop:Be,className:b("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",Ne?p?"border-blue-500 bg-blue-500/10":"border-blue-400 bg-blue-50":p?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300",wt&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:Je,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!a.onUploadAttachments||wt}),wt?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:b("text-sm",p?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:b("w-6 h-6 mx-auto mb-2",Ne?"text-blue-500":p?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:b("text-sm",p?"text-[#9CA3AF]":"text-gray-500"),children:Ne?i==="es"?"Suelta los archivos aqu\xED":"Drop files here":i==="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:b("text-xs mt-1",p?"text-[#6B7280]":"text-gray-400"),children:i==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:b("w-[280px] border-l flex flex-col",p?"border-white/10 bg-[#141619]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:b("px-4 py-3 border-b flex items-center justify-between",p?"border-white/10":"border-gray-200"),children:jsx("span",{className:b("font-medium",p?"text-white":"text-gray-900"),children:i==="es"?"Actividad":"Activity"})}),jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:jsxs("div",{className:b("text-sm text-center py-8",p?"text-[#6B7280]":"text-gray-400"),children:[jsx(MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),i==="es"?"Sin actividad reciente":"No recent activity"]})}),jsx("div",{className:b("p-3 border-t",p?"border-white/10":"border-gray-200"),children:jsx("div",{className:b("flex items-center gap-2 px-3 py-2 rounded-lg",p?"bg-white/5":"bg-white border border-gray-200"),children:jsx("input",{type:"text",placeholder:i==="es"?"Escribe un comentario...":"Write a comment...",className:b("flex-1 bg-transparent text-sm outline-none",p?"text-white placeholder-[#6B7280]":"text-gray-900 placeholder-gray-400")})})})]})]})]})}),jsx(AnimatePresence,{children:x&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>D(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:b("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",p?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:b("px-4 py-3 border-b flex items-center justify-between",p?"border-white/10":"border-gray-200"),children:[jsx("span",{className:b("font-medium",p?"text-white":"text-gray-900"),children:x.date.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>D(null),className:b("p-1 rounded",p?"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:x.events.map(N=>jsxs("button",{onClick:()=>{D(null),k(N.task);},className:b("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",p?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx($c,{task:N.task}),jsx("span",{className:b("text-sm truncate flex-1",p?"text-white":"text-gray-900"),children:N.title}),N.task.priority==="high"||N.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},N.id))})]})]})})]})}var Fi={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"},Ii={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"},Li={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"},Un={dark:Fi,light:Ii,neutral:Li};function Gc(e){return Un[e]||Un.dark}function lh({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:n,className:c}){let[m,l]=useState(false),u=useMemo(()=>t.filter(h=>e.cardIds.includes(h.id)),[t,e.cardIds]),d=useMemo(()=>{let h=u.length,C=new Set(u.flatMap(f=>f.assignedUserIds||[])).size,p=u.map(f=>f.priority).filter(Boolean),y=new Set(u.flatMap(f=>f.labels||[])).size;return {totalCards:h,uniqueAssignees:C,priorities:p,labels:y}},[u]),i=()=>{o?.(e.id);};return jsxs("div",{className:b("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),style:{"--stack-color":e.color||"var(--color-accent-primary)"},children:[jsxs("div",{className:"card-stack-header",onClick:i,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:b("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:d.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"]})]}),m&&jsx("div",{className:"card-stack-actions",children:jsx("button",{className:"card-stack-action",onClick:h=>{h.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:[d.uniqueAssignees," assignees"]})]}),d.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:[d.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:u.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:u.map(h=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(h),children:a(h)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(h),children:[jsx("h4",{children:h.title}),h.description&&jsxs("p",{children:[h.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:C=>{C.stopPropagation(),s?.(e.id,h.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"})]})})]},h.id))})})]})}var Vc={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function $o(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 Ho(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 jc(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 Kc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:n,className:c}){let m=useMemo(()=>({...Vc,...n}),[n]),[l,u]=useState(new Set),d=useRef(null),i=useMemo(()=>{if(!m.groupByDay)return [{date:null,events:e}];let v=new Map;return e.forEach(g=>{let k=g.timestamp.toISOString().split("T")[0],x=v.get(k);x?x.push(g):v.set(k,[g]);}),Array.from(v.entries()).sort((g,k)=>k[0].localeCompare(g[0])).map(([g,k])=>({date:new Date(g),events:k.sort((x,D)=>D.timestamp.getTime()-x.timestamp.getTime())}))},[e,m.groupByDay]),{uniqueUsers:h,uniqueTypes:C}=useMemo(()=>{let v=new Set,g=new Set;return e.forEach(k=>{v.add(k.userId),g.add(k.type);}),{uniqueUsers:Array.from(v),uniqueTypes:Array.from(g)}},[e]),p=v=>{u(g=>{let k=new Set(g);return k.has(v)?k.delete(v):k.add(v),k});},y=v=>{let k=new Date().getTime()-v.getTime(),x=Math.floor(k/6e4),D=Math.floor(k/36e5),B=Math.floor(k/864e5);return x<1?"just now":x<60?`${x}m ago`:D<24?`${D}h ago`:B<7?`${B}d ago`:v.toLocaleDateString()},f=useMemo(()=>{let v=0;return t.types&&t.types.length>0&&v++,t.users&&t.users.length>0&&v++,t.dateRange&&v++,t.searchTerm&&v++,v},[t]);return useEffect(()=>{if(s&&d.current){let v=d.current.querySelector(`[data-event-id="${s}"]`);v&&v.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:b("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:b("history-timeline",m.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:v=>{let g=v.target.value;a({...t,types:g?[g]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),C.map(v=>jsxs("option",{value:v,children:[Ho(v)," ",v.replace("_"," ")]},v))]}),h.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:v=>{let g=v.target.value;a({...t,users:g?[g]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),h.map(v=>jsx("option",{value:v,children:v},v))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:v=>a({...t,searchTerm:v.target.value})})]}),f>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",f,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:i.map(v=>jsxs("div",{className:"history-timeline-group",children:[m.groupByDay&&v.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:v.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[v.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:v.events.map((g,k)=>{let x=l.has(g.id),D=s===g.id,B=jc(g.type);return jsxs("div",{"data-event-id":g.id,className:b("history-timeline-event",x&&"expanded",D&&"selected"),onClick:()=>o?.(g),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:B},children:m.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:Ho(g.type)})}),k<v.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:[m.showAvatars&&g.userAvatar&&jsx("img",{src:g.userAvatar,alt:g.userName||g.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:g.userName||g.userId}),jsx("span",{className:"history-timeline-event-action",children:$o(g)})]})]}),jsx("div",{className:"history-timeline-event-time",children:m.useRelativeTime?y(g.timestamp):g.timestamp.toLocaleString()})]}),Object.keys(g.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:w=>{w.stopPropagation(),p(g.id);},children:[x?"\u25BC":"\u25B6"," Show changes"]}),x&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(g.changes).map(([w,z])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[w,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(z.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(z.to)})]})]},w)),g.metadata&&Object.keys(g.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(g.metadata).map(([w,z])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[w,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(z)})]},w))]})]})]})]},g.id)})})]},v.date?.toISOString()||"all"))})]})}function qc({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:n,onGoToEvent:c,onSpeedChange:m,className:l}){let u=[.5,1,1.5,2,3],d=useMemo(()=>!e||t.length===0?null:t[e.currentIndex],[e,t]),i=useMemo(()=>!e||e.totalEvents===0?0:e.currentIndex/(e.totalEvents-1)*100,[e]);return t.length===0?jsxs("div",{className:b("history-replay-empty",l),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:b("history-replay",l),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:d&&Ho(d.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:d&&$o(d)}),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:d&&d.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:h=>c(parseInt(h.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${i}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((h,C)=>jsx("div",{className:b("history-replay-progress-marker",C===e.currentIndex&&"active"),style:{left:`${C/(e.totalEvents-1)*100}%`},onClick:()=>c(C),title:$o(h)},h.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:u.map(h=>jsxs("button",{className:b("history-replay-speed-btn",e.speed===h&&"active"),onClick:()=>m(h),children:[h,"x"]},h))})]}),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:d&&d.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(h=>jsx("span",{className:"history-replay-card-preview-label-tag",children:h},h))})]})]})]})]}):jsxs("div",{className:b("history-replay-start",l),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 Bi(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 Ri(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 Xc(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 Jc(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function gh(e,t,a,r,o,s=100){let n=e.map(m=>({...m,x:m.x??a/2+Math.random()*100-50,y:m.y??r/2+Math.random()*100-50,vx:0,vy:0})),c=new Map(n.map(m=>[m.id,m]));for(let m=0;m<s;m++){let l=1-m/s;n.forEach(u=>{let d=a/2,i=r/2;u.vx+=(d-u.x)*o.centerForce*l,u.vy+=(i-u.y)*o.centerForce*l,n.forEach(h=>{if(u.id===h.id)return;let C=u.x-h.x,p=u.y-h.y,y=Math.sqrt(C*C+p*p)||1,f=o.chargeStrength*l/(y*y);u.vx+=C/y*f,u.vy+=p/y*f;});}),t.forEach(u=>{let d=c.get(typeof u.source=="string"?u.source:u.source.id),i=c.get(typeof u.target=="string"?u.target:u.target.id);if(!d||!i)return;let h=i.x-d.x,C=i.y-d.y,p=Math.sqrt(h*h+C*C)||1,y=(p-o.linkDistance)/p*o.forceStrength*l;d.vx+=h*y,d.vy+=C*y,i.vx-=h*y,i.vy-=C*y;}),n.forEach(u=>{u.fx!==null&&u.fx!==void 0?(u.x=u.fx,u.vx=0):u.x+=u.vx,u.fy!==null&&u.fy!==void 0?(u.y=u.fy,u.vy=0):u.y+=u.vy,u.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,u.x)),u.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,u.y)),u.vx*=.9,u.vy*=.9;});}return n}function Zc({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:n,onInteraction:c,className:m}){let l=useRef(null),[u,d]=useState([]),[i,h]=useState(null),[C,p]=useState(null),[y,f]=useState(null),[v,g]=useState(1),[k,x]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let R=gh(e,t,a.width,a.height,a,150);d(R);},[e,t,a]);let D=useCallback((R,q)=>{a.enableDragging&&(q.stopPropagation(),h(R));},[a.enableDragging]),B=useCallback(R=>{if(!i||!l.current)return;let te=l.current.getBoundingClientRect(),xe=(R.clientX-te.left-k.x)/v,Ae=(R.clientY-te.top-k.y)/v;d(ze=>ze.map(le=>le.id===i?{...le,x:xe,y:Ae,fx:xe,fy:Ae}:le));},[i,v,k]),w=useCallback(()=>{h(null);},[]),z=useCallback((R,q)=>{q.stopPropagation(),c?.({type:"node-click",node:R,position:{x:q.clientX,y:q.clientY}});},[c]),P=useCallback((R,q)=>{q.stopPropagation(),c?.({type:"edge-click",edge:R,position:{x:q.clientX,y:q.clientY}});},[c]),T=useCallback(R=>{let q=u.find(te=>te.id===R);return q?{x:q.x,y:q.y}:{x:0,y:0}},[u]),G=useCallback(R=>{if(R.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return R.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let q=R.card.priority;return q==="URGENT"?"#ef4444":q==="HIGH"?"#f59e0b":q==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return R.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:b("relationships-graph-empty",m),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:b("relationships-graph",m),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:()=>g(R=>Math.min(R+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(v*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>g(R=>Math.max(R-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{g(1),x({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(R=>R.type))).map(R=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:Bi(R)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[Xc(R)," ",Ri(R)]})]},R))}),jsxs("svg",{ref:l,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:B,onMouseUp:w,onMouseLeave:w,children:[jsxs("g",{transform:`translate(${k.x}, ${k.y}) scale(${v})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(R=>{let q=T(typeof R.source=="string"?R.source:R.source.id),te=T(typeof R.target=="string"?R.target:R.target.id),xe=Jc(R.type),Ae=y===R.id,ze=R.onCriticalPath;return jsxs("g",{className:b("relationships-graph-edge",Ae&&"hovered",ze&&"critical"),onMouseEnter:()=>f(R.id),onMouseLeave:()=>f(null),onClick:le=>P(R,le),children:[jsx("line",{x1:q.x,y1:q.y,x2:te.x,y2:te.y,stroke:Bi(R.type),strokeWidth:ze?a.edgeWidth*2:a.edgeWidth,strokeOpacity:Ae?1:.6,markerEnd:xe?"url(#arrowhead)":void 0}),a.showEdgeLabels&&Ae&&jsx("text",{x:(q.x+te.x)/2,y:(q.y+te.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:Ri(R.type)})]},R.id)})}),jsx("g",{className:"relationships-graph-nodes",children:u.map(R=>{let q=C===R.id,te=R.onCriticalPath;return jsxs("g",{className:b("relationships-graph-node",q&&"hovered",te&&"critical"),transform:`translate(${R.x}, ${R.y})`,onMouseDown:xe=>D(R.id,xe),onMouseEnter:()=>p(R.id),onMouseLeave:()=>p(null),onClick:xe=>z(R,xe),children:[jsx("circle",{r:te?a.nodeSize*1.2:a.nodeSize,fill:G(R),stroke:te?"#fbbf24":"#ffffff",strokeWidth:te?3:2,opacity:q?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:R.card.title.length>20?R.card.title.substring(0,20)+"...":R.card.title})]},R.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 tp({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,n]=useState(""),[c,m]=useState(false),[l,u]=useState(null),[d,i]=useState(null),h=useRef(null),C=c||o;useEffect(()=>{e&&h.current&&h.current.focus();},[e]),useEffect(()=>{let v=g=>{g.key==="Escape"&&!C&&p();};if(e)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[e,C]);let p=()=>{C||(n(""),u(null),i(null),t());},y=async()=>{if(!(!s.trim()||C)){m(true),u(null),i(null);try{let v=await r(s.trim());i(v);}catch(v){u(v instanceof Error?v.message:"Failed to generate plan");}finally{m(false);}}},f=()=>{d&&(a(d),p());};return e?jsxs(mt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:p}),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:v=>v.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:p,disabled:C,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:d?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!"})]}),d.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:d.explanation})}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Columns (",d.columns.length,")"]}),jsx("div",{className:"flex gap-2 flex-wrap",children:d.columns.map((v,g)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:v.title},g))})]}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Tasks (",d.cards.length,")"]}),jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[d.cards.slice(0,10).map((v,g)=>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:v.title}),v.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:v.description})]}),v.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${v.priority==="URGENT"?"bg-red-500/20 text-red-400":v.priority==="HIGH"?"bg-orange-500/20 text-orange-400":v.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:v.priority})]})},g)),d.cards.length>10&&jsxs("p",{className:"text-xs text-white/50 text-center py-2",children:["+",d.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:h,value:s,onChange:v=>n(v.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:C}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),l&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:l}),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((v,g)=>jsx("button",{onClick:()=>n(v),disabled:C,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:v},g))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:C&&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:p,disabled:C,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"}),d?jsx("button",{onClick:f,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:y,disabled:!s.trim()||C,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:C?"Generating...":"Generate Plan"})]})]})]})})]}):null}var Oi={"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 hh={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},bh={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 yh(e,t,a){let r=Oi[e];if(!r)throw new Error(`Unknown model: ${e}`);let o=t/1e3*r.costPer1kInput,s=a/1e3*r.costPer1kOutput;return o+s}function Wo(e){return `$${e.toFixed(4)}`}var zi=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=yh(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(d=>d.timestamp>=t.start&&d.timestamp<=t.end));let r=a.length,o=a.reduce((d,i)=>d+i.cost,0),s=a.reduce((d,i)=>d+i.inputTokens,0),n=a.reduce((d,i)=>d+i.outputTokens,0),c=a.filter(d=>d.success),m=a.reduce((d,i)=>d+i.duration,0),l={},u={};return a.forEach(d=>{l[d.feature]=(l[d.feature]||0)+1,u[d.feature]=(u[d.feature]||0)+d.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:n,operationsByFeature:l,costsByFeature:u,averageDuration:r>0?m/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(u=>u.timestamp>=n).length,m=Math.max(0,o-c),l=c/o*100;return {used:c,limit:o,remaining:m,percentUsed:l,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)}},jr=new zi;function op({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(jr.getStats()),[s,n]=useState(jr.checkLimit(a));if(useEffect(()=>{if(!e)return;let m=setInterval(()=>{o(jr.getStats()),n(jr.checkLimit(a));},1e3);return ()=>clearInterval(m)},[e,a]),useEffect(()=>{let m=l=>{l.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,t]),!e)return null;let c=jr.getRecentOperations(5);return jsxs(mt,{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:m=>m.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:Wo(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(([m,l])=>{let u=r.costsByFeature[m]||0,d=r.totalOperations>0?l/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:m.replace(/([A-Z])/g," $1").trim()}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[l," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:Wo(u)})]})]}),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:`${d}%`}})})]},m)})})]}),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(m=>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:m.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(m.timestamp).toLocaleTimeString()," \u2022"," ",m.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[m.inputTokens+m.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:Wo(m.cost)}),jsx("div",{className:`w-2 h-2 rounded-full ${m.success?"bg-green-400":"bg-red-400"}`})]})]},m.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 ip({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[n,c]=useState(""),[m,l]=useState(""),[u,d]=useState(""),[i,h]=useState(false),[C,p]=useState(null),[y,f]=useState(null),[v,g]=useState(null),k=useRef(null),x=i||o;useEffect(()=>{e&&k.current&&k.current.focus();},[e]),useEffect(()=>{let P=T=>{T.key==="Escape"&&!x&&D();};if(e)return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[e,x]);let D=()=>{x||(c(""),l(""),d(""),p(null),f(null),g(null),t());},B=async()=>{if(!(!n.trim()||x)){h(true),p(null),f(null),g(null);try{let P=await r({prompt:n.trim(),projectName:s||"Mi Proyecto",startDate:m||void 0,endDate:u||void 0});f(P.tasks.tasks),g({from_cache:P.from_cache,tokens_used:P.tokens_used,mock_mode:P.mock_mode,similarity:P.similarity,tokens_saved:P.tokens_saved});}catch(P){p(P instanceof Error?P.message:"Failed to generate tasks");}finally{h(false);}}},w=()=>{y&&(a(y),D());};if(!e)return null;let z=v?.similarity?((v.similarity||0)*100).toFixed(0):"0";return jsxs(mt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:D}),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:P=>P.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:D,disabled:x,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:y?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:[v?.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"}),v?.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 (",z,"% 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:[v?.tokens_used||0," tokens"]}),v?.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:[v.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:[y.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:y.map((P,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:P.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"})]}),P.start," \u2192 ",P.end]}),jsxs("span",{children:[P.duration," days"]}),P.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",P.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${P.priority==="high"?"bg-red-500/20 text-red-400":P.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:P.priority})]})},P.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:k,value:n,onChange:P=>c(P.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:x}),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:m,onChange:P=>l(P.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:x})]}),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:u,onChange:P=>d(P.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:x})]})]}),C&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:C}),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((P,T)=>jsx("button",{onClick:()=>c(P),disabled:x,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:P},T))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:x&&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:D,disabled:x,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"}),y?jsx("button",{onClick:w,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()||x,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:x?"Generating...":"Generate Tasks"})]})]})]})})]})}function Wn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(y=>{t&&Jo(()=>Promise.resolve(t(y)),{maxAttempts:3,initialDelay:1e3,onRetry:(f,v,g)=>{console.warn(`Retry attempt ${v} after ${g}ms: ${f.message}`);}}).then(f=>{f.success||console.error(`Failed to persist board after ${f.attempts} attempts:`,f.error);});},[t]),s=useCallback(async(y,f,v)=>{r(g=>{let k=g.cards.find(P=>P.id===y);if(!k)return g;let x=k.columnId,D={...k,columnId:f,position:v},B=g.cards.map(P=>P.id===y?D:P),w=g.columns.map(P=>{if(P.id===x)return {...P,cardIds:P.cardIds.filter(T=>T!==y)};if(P.id===f){let T=B.filter(G=>G.columnId===f).sort((G,R)=>G.position-R.position);return {...P,cardIds:T.map(G=>G.id)}}return P}),z={...g,cards:B,columns:w};return o(z),z});},[o]),n=useCallback(async(y,f)=>{r(v=>{let g=v.cards.map(x=>x.id===y?{...x,...f}:x),k={...v,cards:g};return o(k),k});},[o]),c=useCallback(async y=>{let f=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(v=>{let g={...y,id:f},k=v.columns.map(D=>D.id===y.columnId?{...D,cardIds:[...D.cardIds,f]}:D),x={...v,cards:[...v.cards,g],columns:k};return o(x),x});},[o]),m=useCallback(async y=>{r(f=>{let v=f.cards.find(D=>D.id===y);if(!v)return f;let g=f.cards.filter(D=>D.id!==y),k=f.columns.map(D=>D.id===v.columnId?{...D,cardIds:D.cardIds.filter(B=>B!==y)}:D),x={...f,cards:g,columns:k};return o(x),x});},[o]),l=useCallback(async y=>{let f=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(v=>{let g={...y,id:f,cardIds:[]},k={...v,columns:[...v.columns,g]};return o(k),k});},[o]),u=useCallback(async(y,f)=>{r(v=>{let g=v.columns.map(x=>x.id===y?{...x,...f}:x),k={...v,columns:g};return o(k),k});},[o]),d=useCallback(async y=>{r(f=>{let v=f.cards.filter(x=>x.columnId!==y),g=f.columns.filter(x=>x.id!==y),k={...f,cards:v,columns:g};return o(k),k});},[o]),i=useCallback(y=>{let f=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(y),f},[c]),h=useCallback(y=>{let f=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return l(y),f},[l]),C=useCallback(()=>{r(y=>{let f={...y,cards:[],columns:[]};return o(f),f});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:n,onCardCreate:c,onCardDelete:m,onColumnCreate:l,onColumnUpdate:u,onColumnDelete:d},setBoard:r,helpers:{addCard:i,addColumn:h,deleteCard:m,deleteColumn:d,clearBoard:C}}}function dp({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=Wn({initialBoard:e,onPersist:a}),n=useMemo(()=>({addCard:(m,l,u={})=>{s.addCard({title:l,columnId:m,position:r.cards.filter(d=>d.columnId===m).length,...u});},addColumn:(m,l)=>{let u=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:m,position:l??u+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 Go={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},pp={by:"none",order:"asc"};function mp({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...Go,...e}),[s,n]=useState({...pp,...t}),c=useCallback(p=>{o(y=>({...y,...p}));},[]),m=useCallback(p=>{n(y=>({...y,...p}));},[]),l=useCallback(()=>{o(Go),n(pp);},[]),u=useCallback(()=>{a&&o({...Go,assignees:[a]});},[a]),d=useCallback(()=>{o({...Go,dateFilter:"overdue"});},[]),i=useCallback(()=>{o({...Go,priorities:["HIGH","URGENT"]});},[]),h=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]),C=useCallback(p=>{let y=[...p];if(r.search){let f=r.search.toLowerCase();y=y.filter(v=>v.title.toLowerCase().includes(f)||v.description?.toLowerCase().includes(f));}if(r.dateFilter!=="all"){let f=new Date,v=f.getFullYear(),g=String(f.getMonth()+1).padStart(2,"0"),k=String(f.getDate()).padStart(2,"0"),x=`${v}-${g}-${k}`;y=y.filter(D=>{if(!D.endDate&&!D.dueDate)return false;let B=D.endDate||D.dueDate;if(!B)return false;let w;if(typeof B=="string")w=B.split("T")[0]||B;else {let z=B.getUTCFullYear(),P=String(B.getUTCMonth()+1).padStart(2,"0"),T=String(B.getUTCDate()).padStart(2,"0");w=`${z}-${P}-${T}`;}switch(r.dateFilter){case "overdue":return w<x;case "today":return w===x;case "this-week":let z=new Date(x+"T00:00:00"),P=new Date(w+"T00:00:00"),T=new Date(z);return T.setDate(T.getDate()+7),P>=z&&P<=T;case "custom":if(r.dateRange){let G=typeof B=="string"?new Date(B):B;return G>=r.dateRange.start&&G<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(y=y.filter(f=>f.priority&&r.priorities.includes(f.priority))),r.assignees.length>0&&(y=y.filter(f=>(f.assignedUserIds||(f.assigneeId?[f.assigneeId]:[])).some(g=>r.assignees.includes(g)))),r.labels.length>0&&(y=y.filter(f=>f.labels&&f.labels.some(v=>r.labels.includes(v)))),r.columns.length>0&&(y=y.filter(f=>r.columns.includes(f.columnId))),s.by!=="none"&&y.sort((f,v)=>{let g=0;switch(s.by){case "created":let k=f.createdAt?new Date(f.createdAt).getTime():0,x=v.createdAt?new Date(v.createdAt).getTime():0;g=k-x;break;case "priority":let D={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},B=D[f.priority||"LOW"],w=D[v.priority||"LOW"];g=B-w;break;case "dueDate":let z=f.endDate||f.dueDate,P=v.endDate||v.dueDate;if(!z)return 1;if(!P)return -1;let T=typeof z=="string"?new Date(z).getTime():z.getTime(),G=typeof P=="string"?new Date(P).getTime():P.getTime();g=T-G;break;case "title":g=f.title.localeCompare(v.title);break;case "estimate":let R=f.estimatedTime||0,q=v.estimatedTime||0;g=R-q;break;default:g=0;}return s.order==="asc"?g:-g}),y},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:m,resetFilters:l,filterMyTasks:u,filterOverdue:d,filterHighPriority:i,applyFilters:C,hasActiveFilters:h}}var gp,fp;if(typeof window<"u")try{let e=Yo("ai");gp=e.generateObject,fp=e.generateText;}catch{}function hp(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(gp&&fp&&e.apiKey),n=useCallback(async d=>{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:",d),{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: ${d}`,position:1e3,columnId:"temp-col-1"}],explanation:"This is a sample plan. Real implementation would use AI SDK."}}catch(i){let h=i instanceof Error?i:new Error("Failed to generate plan");throw o(h),h}finally{a(false);}},[s]),c=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Suggesting assignee for:",d.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(i){let h=i instanceof Error?i:new Error("Failed to suggest assignee");throw o(h),h}finally{a(false);}},[s]),m=useCallback(async d=>{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(i){let h=i instanceof Error?i:new Error("Failed to predict risks");throw o(h),h}finally{a(false);}},[s]),l=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Generating subtasks for:",d.title),[{title:`Subtask 1 for: ${d.title}`,position:d.position+.1,columnId:d.columnId},{title:`Subtask 2 for: ${d.title}`,position:d.position+.2,columnId:d.columnId}]}catch(i){let h=i instanceof Error?i:new Error("Failed to generate subtasks");throw o(h),h}finally{a(false);}},[s]),u=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Estimating effort for:",d.title),{hours:8,confidence:.75}}catch(i){let h=i instanceof Error?i:new Error("Failed to estimate effort");throw o(h),h}finally{a(false);}},[s]);return {onGeneratePlan:n,onSuggestAssignee:c,onPredictRisks:m,onGenerateSubtasks:l,onEstimateEffort:u,isAvailable:s,isLoading:t,error:r}}function $i(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function bp(e){let{cards:t}=e,[a,r]=$i(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,i)=>{if(!i){r({selectedCardIds:[d],lastSelectedCardId:d});return}let h=i.ctrlKey||i.metaKey,C=i.shiftKey;if(h)a.selectedCardIds.includes(d)?r({selectedCardIds:a.selectedCardIds.filter(p=>p!==d),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});else if(C&&a.lastSelectedCardId){let p=t.find(f=>f.id===d),y=t.find(f=>f.id===a.lastSelectedCardId);if(p&&y&&p.columnId===y.columnId){let f=t.filter(w=>w.columnId===p.columnId).sort((w,z)=>w.position-z.position),v=f.findIndex(w=>w.id===a.lastSelectedCardId),g=f.findIndex(w=>w.id===d),[k,x]=v<g?[v,g]:[g,v],D=f.slice(k,x+1).map(w=>w.id),B=Array.from(new Set([...a.selectedCardIds,...D]));r({selectedCardIds:B,lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});},[t,a,r]),n=useCallback(d=>{r({selectedCardIds:a.selectedCardIds.filter(i=>i!==d),lastSelectedCardId:a.lastSelectedCardId});},[a,r]),c=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),m=useCallback(()=>{r({selectedCardIds:t.map(d=>d.id),lastSelectedCardId:t[t.length-1]?.id||null});},[t,r]),l=useCallback(d=>{a.selectedCardIds.includes(d)?n(d):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});},[a,n,r]),u=useCallback(()=>t.filter(d=>a.selectedCardIds.includes(d.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:n,clearSelection:c,selectAll:m,toggleCard:l,getSelectedCards:u}}var yp={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function vp(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...yp,...a}),[a]),[s,n]=useState([]),c=useCallback((p,y,f,v,g)=>{if(y.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let k={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:p,cardIds:y,columnId:f,strategy:v,color:g,isExpanded:true,position:s.filter(x=>x.columnId===f).length,createdAt:new Date};n(x=>[...x,k]);},[o.minCardsPerStack,s]),m=useCallback(p=>{n(y=>y.filter(f=>f.id!==p));},[]),l=useCallback(p=>{n(y=>y.map(f=>f.id===p?{...f,isExpanded:!f.isExpanded}:f));},[]),u=useCallback((p,y)=>{n(f=>f.map(v=>v.id===p&&!v.cardIds.includes(y)?{...v,cardIds:[...v.cardIds,y]}:v));},[]),d=useCallback((p,y)=>{n(f=>f.map(v=>{if(v.id===p){let g=v.cardIds.filter(k=>k!==y);return g.length<o.minCardsPerStack?null:{...v,cardIds:g}}return v}).filter(v=>v!==null));},[o.minCardsPerStack]),i=useCallback(p=>s.filter(y=>y.columnId===p).sort((y,f)=>y.position-f.position),[s]),h=useCallback(async p=>{let y=t.filter(x=>x.columnId===p);if(y.length<o.minCardsPerStack*2)return [];let f=[],v=new Map;y.forEach(x=>{x.labels&&x.labels.length>0&&x.labels.forEach(D=>{v.has(D)||v.set(D,[]),v.get(D).push(x);});}),v.forEach((x,D)=>{x.length>=o.minCardsPerStack&&f.push({stack:{title:`\u{1F4CC} ${D}`,cardIds:x.map(B=>B.id),columnId:p,strategy:"labels",color:"#3b82f6"},reason:`${x.length} cards with label "${D}"`,confidence:.85});});let g=new Map;y.forEach(x=>{x.assignedUserIds&&x.assignedUserIds.length>0&&x.assignedUserIds.forEach(D=>{g.has(D)||g.set(D,[]),g.get(D).push(x);});}),g.forEach((x,D)=>{x.length>=o.minCardsPerStack&&f.push({stack:{title:`\u{1F464} Assigned to user-${D.slice(-4)}`,cardIds:x.map(B=>B.id),columnId:p,strategy:"assignee",color:"#8b5cf6"},reason:`${x.length} cards assigned to the same user`,confidence:.8});});let k=new Map;if(y.forEach(x=>{x.priority&&(k.has(x.priority)||k.set(x.priority,[]),k.get(x.priority).push(x));}),k.forEach((x,D)=>{if(x.length>=o.minCardsPerStack){let B={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[D.toLowerCase()]||"\u26AA";f.push({stack:{title:`${B} ${D} Priority`,cardIds:x.map(w=>w.id),columnId:p,strategy:"priority",color:D==="high"||D==="urgent"?"#ef4444":"#10b981"},reason:`${x.length} cards with ${D} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let x of y){let B=(await r.findSimilar(x,y)).filter(w=>w.similarity>=o.autoStackConfidenceThreshold);if(B.length>=o.minCardsPerStack-1){let w=[x.id,...B.map(P=>P.card.id)],z=B.reduce((P,T)=>P+T.similarity,0)/B.length;f.push({stack:{title:`\u2728 Similar to "${x.title.substring(0,30)}${x.title.length>30?"...":""}"`,cardIds:w,columnId:p,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${B.length+1} similar tasks`,confidence:z});}}return f.filter(x=>x.confidence>=o.autoStackConfidenceThreshold).sort((x,D)=>D.confidence-x.confidence).slice(0,5)},[t,o,r]),C=useCallback(p=>{c(p.stack.title,p.stack.cardIds,p.stack.columnId,p.stack.strategy,p.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(y=>y.columnId)).forEach(async y=>{let f=await h(y),v=f[0];f.length>0&&v&&v.confidence>=.9&&C(v);});},[]),{stacks:s,createStack:c,deleteStack:m,toggleStack:l,addToStack:u,removeFromStack:d,getStacksForColumn:i,getSuggestions:h,applySuggestion:C,config:o}}var xp=createContext(null);function kp({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,n=new Map;t?.columns?.forEach(m=>{let{Column:l}=Yo("@libxai/core");s.set(m.id,new l(m));}),t?.cards?.forEach(m=>{let{Card:l}=Yo("@libxai/core");n.set(m.id,new l(m));});let c=null;if(t?.board){let{Board:m}=Yo("@libxai/core");c=new m(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(xp.Provider,{value:{store:o},children:e})}function Gn(){let e=useContext(xp);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function Vo(){let e=Gn(),[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(v=>{e.updateBoard(v);},[e]),m=useCallback(v=>{e.addColumn(v);},[e]),l=useCallback((v,g)=>{e.updateColumn(v,g);},[e]),u=useCallback(v=>{e.deleteColumn(v);},[e]),d=useCallback(v=>e.getColumn(v),[e]),i=useCallback(v=>{e.addCard(v);},[e]),h=useCallback((v,g)=>{e.updateCard(v,g);},[e]),C=useCallback(v=>{e.deleteCard(v);},[e]),p=useCallback((v,g,k)=>{e.moveCard(v,g,k);},[e]),y=useCallback(v=>e.getCard(v),[e]),f=useCallback(v=>e.getCardsByColumn(v),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:m,updateColumn:l,deleteColumn:u,getColumn:d,addCard:i,updateCard:h,deleteCard:C,moveCard:p,getCard:y,getCardsByColumn:f}}function Cp(e){let{cards:t}=Vo();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 Tp(e="position",t="asc"){let{cards:a}=Vo();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},m=o.priority?c[o.priority]:0,l=s.priority?c[s.priority]:0;n=m-l;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 _n=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=yl.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);}},Bh=new _n;function Dp({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:n=false,gap:c=0,getItemKey:m}){let l=useRef(null),u=useVirtualizer({count:e.length,getScrollElement:()=>l.current,estimateSize:()=>a,overscan:s,horizontal:n,gap:c}),d=u.getVirtualItems(),i={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},h=n?{width:`${u.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${u.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:l,style:i,className:o,children:jsx("div",{style:h,children:d.map(C=>{let p=e[C.index];if(!p)return null;let y=m?m(p,C.index):C.index,f={position:"absolute",top:n?0:C.start,left:n?C.start:0,width:n?C.size:"100%",height:n?"100%":C.size};return jsx("div",{style:f,"data-index":C.index,children:r(p,C.index)},y)})})})}function Sp(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 Pp({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:n=3,gap:c=16,getItemKey:m,horizontal:l=true}){let u=useRef(null),d=useVirtualizer({horizontal:l,count:e.length,getScrollElement:()=>u.current,estimateSize:()=>r,overscan:n,gap:c}),i=d.getVirtualItems(),h={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},C={width:`${d.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:u,style:h,className:s,children:jsx("div",{style:C,children:i.map(p=>{let y=e[p.index];if(!y)return null;let f=m?m(y,p.index):p.index,v={position:"absolute",top:0,left:p.start,width:p.size,height:"100%"};return jsx("div",{style:v,"data-index":p.index,children:o(y,p.index)},f)})})})}function Mp(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 Ap(e,t=10){return e>t}var _i={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},Vi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},ji={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},Ki={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},Yi={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},qi={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Xi={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Ji={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)"},Zi={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)"},Qi={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},el={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}},tl={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}},Vn={spacing:_i,borderRadius:Vi,fontSize:ji,fontWeight:Ki,lineHeight:Yi,zIndex:qi,duration:Xi,easing:Ji,shadows:Zi,opacity:Qi,kanban:el,gantt:tl};function Fp(e,t,a){return e[t]??a}function al(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)?al(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function zh(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function rl(e="asakaa"){let t=al(Vn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,n=zh(o);a.push(` ${s}: ${n};`);}return `:root {
389
+ Today's date: ${new Date().toISOString().split("T")[0]}`}function wc(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function cr(e,t){let a=wc(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 p=c.name.toLowerCase();return n.every(l=>p.includes(l))})}function fi(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 i=new Date(r);return i.setDate(i.getDate()+1),i}if(a==="yesterday"||a==="ayer"){let i=new Date(r);return i.setDate(i.getDate()-1),i}if(a==="next week"||a==="la pr\xF3xima semana"){let i=new Date(r);return i.setDate(i.getDate()+7),i}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 h={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(h!==void 0){let C=new Date(r),m=C.getDay(),y=h-m;return y<=0&&(y+=7),C.setDate(C.getDate()+y),C}}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 i=parseInt(s[1],10),h=s[2].toLowerCase(),C=new Date(r);return h==="day"||h==="d\xEDa"||h==="dias"?C.setDate(C.getDate()+i):h==="week"||h==="semana"||h==="semanas"?C.setDate(C.getDate()+i*7):(h==="month"||h==="mes"||h==="meses")&&C.setMonth(C.getMonth()+i),C}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 i=parseInt(c[1],10),h=parseInt(c[2],10)-1,C=parseInt(c[3],10);return new Date(C,h,i)}let p={enero:0,febrero:1,marzo:2,abril:3,mayo:4,junio:5,julio:6,agosto:7,septiembre:8,octubre:9,noviembre:10,diciembre:11},l=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(l&&l[1]&&l[2]){let i=parseInt(l[1],10),h=p[l[2].toLowerCase()],C=l[3]?parseInt(l[3],10):r.getFullYear();if(h!==void 0)return new Date(C,h,i)}let u={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11},d=a.match(/(january|february|march|april|may|june|july|august|september|october|november|december)\s+(\d{1,2})(?:,?\s+(\d{4}))?/i);if(d&&d[1]&&d[2]){let i=u[d[1].toLowerCase()],h=parseInt(d[2],10),C=d[3]?parseInt(d[3],10):r.getFullYear();if(i!==void 0)return new Date(C,i,h)}return null}function hi(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 bi(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 Cc(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 Tc(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 l=r[1].trim(),u=r[2].trim(),d=cr(t,l),i=fi(u);if(!d)return {type:"move_task",taskName:l,message:`Could not find a task named "${l}". Please check the task name and try again.`,success:false,error:"Task not found"};if(!i)return {type:"move_task",taskId:d.id,taskName:d.name,message:`Could not parse the date "${u}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let h=d.startDate&&d.endDate?Math.round((d.endDate.getTime()-d.startDate.getTime())/(1e3*60*60*24)):1,C=new Date(i);return C.setDate(C.getDate()+h),{type:"move_task",taskId:d.id,taskName:d.name,updates:{startDate:i,endDate:C},message:`Moved "${d.name}" to ${i.toLocaleDateString()}.`,success:true}}let o=a.match(/(?:extend|extender|extiende|alargar)\s+["""]?(.+?)["""]?\s+(?:by|por)\s+(.+)/i);if(o&&o[1]&&o[2]){let l=o[1].trim(),u=o[2].trim(),d=cr(t,l),i=hi(u);if(!d)return {type:"resize_task",taskName:l,message:`Could not find a task named "${l}".`,success:false,error:"Task not found"};if(!i||!d.endDate)return {type:"resize_task",taskId:d.id,taskName:d.name,message:`Could not parse the duration "${u}".`,success:false,error:"Invalid duration"};let h=new Date(d.endDate);return h.setDate(h.getDate()+i),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:h},message:`Extended "${d.name}" by ${i} days. New end date: ${h.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 l=s[1].trim(),u=s[2].trim(),d=cr(t,l),i=bi(u);return d?i===null?{type:"set_progress",taskId:d.id,taskName:d.name,message:`Could not parse the progress value "${u}".`,success:false,error:"Invalid progress"}:{type:"set_progress",taskId:d.id,taskName:d.name,updates:{progress:i},message:`Set "${d.name}" progress to ${i}%.`,success:true}:{type:"set_progress",taskName:l,message:`Could not find a task named "${l}".`,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 l=n[1].trim(),u=n[2].trim(),d=cr(t,l);return d?{type:"rename_task",taskId:d.id,taskName:d.name,updates:{name:u},message:`Renamed "${d.name}" to "${u}".`,success:true}:{type:"rename_task",taskName:l,message:`Could not find a task named "${l}".`,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 l=c[1].trim(),u=c[2].trim(),d=cr(t,l),i=cr(t,u);return d?i?{type:"link_tasks",taskId:i.id,taskName:i.name,dependencyFrom:d.id,dependencyTo:i.id,message:`Linked "${d.name}" \u2192 "${i.name}".`,success:true}:{type:"link_tasks",taskName:u,message:`Could not find a task named "${u}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:l,message:`Could not find a task named "${l}".`,success:false,error:"Source task not found"}}let p=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(p&&p[1]){let l=p[1].trim(),u=cr(t,l);return u?{type:"delete_task",taskId:u.id,taskName:u.name,message:`Deleted "${u.name}".`,success:true}:{type:"delete_task",taskName:l,message:`Could not find a task named "${l}".`,success:false,error:"Task not found"}}return null}function Nc(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 M0(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 A0(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function An(e,t=[],a=[]){let r=e.assignedUserIds?.map(u=>{let d=a.find(i=>i.id===u);return d?{name:d.name,initials:d.initials,color:d.color}:null}).filter(u=>u!==null),o=t.filter(u=>u.metadata?.parentCardId===e.id).map(u=>An(u,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(u=>u.type==="finish-to-start").map(u=>u.taskId));let n=u=>{if(u)return typeof u=="string"?new Date(u):u},c=n(e.startDate),p=n(e.endDate),l=e.metadata?.isMilestone===true||c&&p&&Math.abs(p.getTime()-c.getTime())<=864e5;return {id:e.id,name:e.title,startDate:c,endDate:p,progress:e.progress||0,status:M0(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:l,isCriticalPath:e.metadata?.isCriticalPath===true}}function Dc(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:A0(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Sc(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>An(r,e,t))}var yi={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"}},vi={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"}},Fn={en:yi,es:vi};function xi(e){return Fn[e]||Fn.en}function In(e,t){let a=xi(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}function Ac(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(...Ac(r.subtasks,t+1));return a}function W0({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 Fc({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:n}){let{theme:c="dark",locale:p="en",customTranslations:l,showSearch:u=true,showHierarchy:d=true}=t,i=In(p,l),h=c==="dark",[C,m]=useState(new Set),[y,f]=useState("startDate"),[v,g]=useState("asc"),[k,x]=useState("");useMemo(()=>{let M=new Set;function T(_){for(let B of _)B.subtasks?.length&&(M.add(B.id),T(B.subtasks));}T(e),m(M);},[e]);let S=useCallback(M=>{m(T=>{let _=new Set(T);return _.has(M)?_.delete(M):_.add(M),_}),a.onTaskToggleExpand?.(M);},[a]),L=useCallback(M=>{y===M?g(T=>T==="asc"?"desc":"asc"):(f(M),g("asc")),a.onSortChange?.({column:M,direction:v==="asc"?"desc":"asc"});},[y,v,a]),w=useMemo(()=>{let M=Ac(e);if(k.trim()){let _=k.toLowerCase();M=M.filter(B=>B.name.toLowerCase().includes(_));}let T=[];for(let _ of M){let B=_.level===0;_.level>0&&(B=true),(B||k.trim())&&T.push(_);}return k.trim()&&T.sort((_,B)=>{let J,te;switch(y){case "name":J=_.name.toLowerCase(),te=B.name.toLowerCase();break;case "startDate":J=_.startDate?.getTime()||0,te=B.startDate?.getTime()||0;break;case "endDate":J=_.endDate?.getTime()||0,te=B.endDate?.getTime()||0;break;case "progress":J=_.progress||0,te=B.progress||0;break;case "status":J=_.status||"todo",te=B.status||"todo";break;default:return 0}return J<te?v==="asc"?-1:1:J>te?v==="asc"?1:-1:0}),T},[e,k,y,v]),O=M=>M?(M instanceof Date?M:new Date(M)).toLocaleDateString(p==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:b("flex-1 flex items-center justify-center",h?"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:b("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[i.empty.noTasks,"..."]})]})}):o?jsx("div",{className:b("flex-1 flex items-center justify-center",h?"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:b("text-lg font-semibold mb-2",h?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:b("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:b("flex-1 flex items-center justify-center",h?"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:b("text-lg font-semibold mb-2",h?"text-white":"text-gray-900"),children:i.empty.noTasks}),jsx("p",{className:b("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.addFirstTask})]})}):jsxs("div",{className:b("flex-1 flex flex-col w-full h-full overflow-hidden",h?"bg-[#0F1117]":"bg-white",s),style:n,children:[jsx("div",{className:b("flex-shrink-0 px-6 py-4 border-b",h?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[u&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:b("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:k,onChange:M=>x(M.target.value),placeholder:i.toolbar.searchPlaceholder,className:b("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",h?"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:b("text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[w.length," ",i.pagination.tasks]})]})}),jsxs("div",{className:b("flex-shrink-0 grid grid-cols-12 gap-4 px-6 py-3 border-b text-xs font-medium uppercase tracking-wider",h?"border-white/10 bg-white/5 text-[#9CA3AF]":"border-gray-200 bg-gray-50 text-gray-500"),children:[jsx("div",{className:"col-span-5 flex items-center gap-2",children:jsxs("button",{onClick:()=>L("name"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.name,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>L("status"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.status,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>L("startDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.startDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-2 flex items-center gap-1",children:jsxs("button",{onClick:()=>L("endDate"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:[i.columns.endDate,jsx(ArrowUpDown,{className:"w-3 h-3"})]})}),jsx("div",{className:"col-span-1 flex items-center gap-1",children:jsxs("button",{onClick:()=>L("progress"),className:"flex items-center gap-1 hover:text-[#3B82F6]",children:["%",jsx(ArrowUpDown,{className:"w-3 h-3"})]})})]}),jsxs("div",{className:"flex-1 overflow-auto",children:[jsx(AnimatePresence,{children:w.map((M,T)=>{let _=C.has(M.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:T*.02},className:b("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",h?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),style:{paddingLeft:d?`${24+M.level*24}px`:void 0},onClick:()=>a.onTaskClick?.(M),onDoubleClick:()=>a.onTaskDoubleClick?.(M),children:[jsxs("div",{className:"col-span-5 flex items-center gap-2 min-w-0",children:[d&&M.hasChildren&&jsx("button",{onClick:B=>{B.stopPropagation(),S(M.id);},className:b("p-0.5 rounded",h?"hover:bg-white/10":"hover:bg-gray-200"),children:_?jsx(ChevronDown,{className:b("w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:b("w-4 h-4",h?"text-[#9CA3AF]":"text-gray-400")})}),d&&!M.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:B=>{B.stopPropagation(),a.onTaskUpdate?.({...M,progress:M.progress===100?0:100,status:M.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(W0,{status:M.status,progress:M.progress})}),jsx("span",{className:b("truncate",h?"text-white":"text-gray-900",M.progress===100&&(h?"line-through text-[#6B7280]":"line-through text-gray-400")),children:M.name})]}),jsx("div",{className:"col-span-2 flex items-center",children:jsx("span",{className:b("px-2 py-1 rounded-full text-xs font-medium",M.progress===100||M.status==="completed"?"bg-green-500/10 text-green-500":M.progress&&M.progress>0||M.status==="in-progress"?"bg-blue-500/10 text-blue-500":h?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:M.progress===100||M.status==="completed"?i.status.completed:M.progress&&M.progress>0||M.status==="in-progress"?i.status.inProgress:i.status.todo})}),jsxs("div",{className:b("col-span-2 flex items-center gap-1 text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),O(M.startDate)]}),jsxs("div",{className:b("col-span-2 flex items-center gap-1 text-sm",h?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),O(M.endDate)]}),jsx("div",{className:"col-span-1 flex items-center",children:jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{className:b("flex-1 h-1.5 rounded-full overflow-hidden",h?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:b("h-full rounded-full transition-all",M.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${M.progress||0}%`}})}),jsxs("span",{className:b("text-xs w-8",h?"text-[#9CA3AF]":"text-gray-500"),children:[M.progress||0,"%"]})]})})]},M.id)})}),w.length===0&&k&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:b("w-12 h-12 mx-auto mb-4",h?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:b(h?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.noResults})]})})]})]})}var ki={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"},wi={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"},Ci={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"},Bn={dark:ki,light:wi,neutral:Ci};function Ic(e){return Bn[e]||Bn.dark}var Ti={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"}},Ni={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"}},Rn={en:Ti,es:Ni};function Oo(e){return Rn[e]||Rn.en}function On(e,t){let a=Oo(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 Lc(e){let t=Oo(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 Bc(e,t=0,a=true){let r=Oo(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 sh(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 Ai(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 $c({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 Wc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:n,style:c,availableTags:p=[],onCreateTag:l,attachmentsByTask:u}){let{theme:d="dark",locale:i="en",customTranslations:h}=t,C=On(i,h),m=d==="dark",y={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)"},[f,v]=useState(r||new Date),[g,k]=useState(null),[x,S]=useState(null),[L,w]=useState(null),[O,M]=useState(new Date),[T,_]=useState({}),B=4,J=3,[te,be]=useState(false),[Fe,Oe]=useState(false),[je,H]=useState(false),[z,W]=useState(false),[N,j]=useState(null),[q,R]=useState(""),[ie,ke]=useState(void 0),[Ee,ce]=useState(null),[Ke,Me]=useState(false),[at,lt]=useState(false),[dt,tt]=useState(null),[U,ne]=useState(false),[re,we]=useState(new Date),[Te,rt]=useState(false),[wt,Ie]=useState(false),[ye,Se]=useState(false),[St,gt]=useState(""),[ta,sa]=useState(false),Ge=useCallback(()=>{v(new Date(f.getFullYear(),f.getMonth()-1,1));},[f]),$e=useCallback(()=>{v(new Date(f.getFullYear(),f.getMonth()+1,1));},[f]),ia=useCallback(()=>{v(new Date);},[]),he=useMemo(()=>{let D=f.getFullYear(),A=f.getMonth(),G=new Date(D,A,1),pe=new Date(D,A+1,0),Ye=G.getDay(),Q=pe.getDate(),Re=sh(e),Nt=new Date;Nt.setHours(0,0,0,0);let Ae=[],aa=Ye,oe=new Date(D,A,0).getDate();for(let ot=aa-1;ot>=0;ot--){let Ue=new Date(D,A-1,oe-ot);Ae.push({date:Ue,isCurrentMonth:false,isToday:false,isWeekend:Ue.getDay()===0||Ue.getDay()===6,events:Re.filter(Et=>Ai(Ue,Et)).map(Et=>({id:Et.id,title:Et.name,start:Et.startDate,end:Et.endDate,task:Et}))});}for(let ot=1;ot<=Q;ot++){let Ue=new Date(D,A,ot),Et=Ue.getTime()===Nt.getTime();Ae.push({date:Ue,isCurrentMonth:true,isToday:Et,isWeekend:Ue.getDay()===0||Ue.getDay()===6,events:Re.filter(Pt=>Ai(Ue,Pt)).map(Pt=>({id:Pt.id,title:Pt.name,start:Pt.startDate,end:Pt.endDate,task:Pt}))});}let st=42-Ae.length;for(let ot=1;ot<=st;ot++){let Ue=new Date(D,A+1,ot);Ae.push({date:Ue,isCurrentMonth:false,isToday:false,isWeekend:Ue.getDay()===0||Ue.getDay()===6,events:Re.filter(Et=>Ai(Ue,Et)).map(Et=>({id:Et.id,title:Et.name,start:Et.startDate,end:Et.endDate,task:Et}))});}return Ae},[f,e]),E=i==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Z=f.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),me=useCallback((D,A)=>{if(!g)return;let G={...g,[D]:A};k(G),a.onTaskUpdate?.(G);},[g,a]),Ne=useCallback(D=>{if(!g)return;let A=g.progress||0;D==="completed"?A=100:D==="todo"&&(A=0);let G={...g,status:D,progress:A};k(G),a.onTaskUpdate?.(G),be(false);},[g,a]),ze=useCallback((D,A)=>{if(!g)return;let G={...g,startDate:D,endDate:A};k(G),a.onTaskUpdate?.(G);},[g,a]),Be=useCallback(()=>{be(false),Oe(false),H(false),w(null),Se(false),gt(""),sa(false);},[]),Le=useCallback(async D=>{if(D.preventDefault(),D.stopPropagation(),rt(false),!g||!a.onUploadAttachments)return;let A=Array.from(D.dataTransfer.files);if(A.length!==0){Ie(true);try{await a.onUploadAttachments(g.id,A);}finally{Ie(false);}}},[g,a]),Ze=useCallback(async D=>{if(!g||!a.onUploadAttachments||!D.target.files)return;let A=Array.from(D.target.files);if(A.length!==0){Ie(true);try{await a.onUploadAttachments(g.id,A);}finally{Ie(false);}D.target.value="";}},[g,a]),ct=useCallback(D=>{D.preventDefault(),D.stopPropagation(),rt(true);},[]),Y=useCallback(D=>{D.preventDefault(),D.stopPropagation(),rt(false);},[]),ae=useCallback(D=>D<1024?`${D} B`:D<1024*1024?`${(D/1024).toFixed(1)} KB`:`${(D/(1024*1024)).toFixed(1)} MB`,[]),Pe=useCallback(D=>D.startsWith("image/")?Image:D.includes("pdf")||D.includes("document")?FileText:File,[]),He=useMemo(()=>!g||!u?[]:u.get(g.id)||[],[g,u]);return o?jsx("div",{className:b("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:b("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:[C.labels.noEvents,"..."]})]})}):s?jsx("div",{className:b("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:b("text-lg font-semibold mb-2",m?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:b("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:b("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:b("text-lg font-semibold mb-2",m?"text-white":"text-gray-900"),children:C.labels.noEvents}),jsx("p",{className:b("text-sm",m?"text-[#9CA3AF]":"text-gray-600"),children:C.labels.newTask})]})}):jsxs("div",{className:b("flex-1 flex flex-col w-full h-full overflow-auto",m?"bg-[#0F1117]":"bg-white",n),style:c,children:[jsx("div",{className:b("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:b("text-xl font-semibold capitalize",m?"text-white":"text-gray-900"),children:Z}),jsx("button",{onClick:ia,className:b("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:C.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:Ge,className:b("p-2 rounded-lg transition-colors",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:b("w-5 h-5",m?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:$e,className:b("p-2 rounded-lg transition-colors",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:b("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:E.map(D=>jsx("div",{className:b("py-2 text-center text-xs font-medium uppercase",m?"text-[#9CA3AF]":"text-gray-500"),children:D},D))}),jsx("div",{className:b("grid grid-cols-7 auto-rows-min gap-px rounded-lg",m?"bg-[#2D2D2D]":"bg-gray-300"),children:he.map((D,A)=>{let G=D.date.getDay()===0||D.date.getDay()===6;return jsxs("div",{className:b("min-h-[120px] p-2 transition-colors flex flex-col relative group",m?G?"bg-[#1C1F26]":D.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":G?"bg-gray-100":D.isCurrentMonth?"bg-white":"bg-gray-50",D.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let pe=T[A]||B,Ye=D.events.slice(0,pe),Q=D.events.length-pe;return jsxs("div",{className:"space-y-1 flex-1",children:[Ye.map(Re=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{k(Re.task),a.onEventClick?.(Re);},whileHover:{scale:1.02},className:b("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",Re.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($c,{task:Re.task}),jsx("span",{className:"truncate",children:Re.title})]})},Re.id)),Q>0&&jsxs("button",{onClick:Re=>{Re.stopPropagation(),_(Nt=>({...Nt,[A]:pe+J}));},className:b("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:["+",Q," ",i==="es"?"M\xC1S":"MORE"]}),pe>B&&D.events.length>B&&jsx("button",{onClick:Re=>{Re.stopPropagation(),_(Nt=>({...Nt,[A]:B}));},className:b("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:i==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let pe=A>=28,Ye=A%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:Q=>{Q.stopPropagation(),N===A?j(null):(j(A),R(""),ke(void 0),ce(null),tt(null),Me(false),lt(false),ne(false),we(D.date));},className:b("w-5 h-5 rounded flex items-center justify-center transition-all",N===A?"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:b("w-3.5 h-3.5 transition-transform",N===A&&"rotate-45")})}),jsx(AnimatePresence,{children:N===A&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{j(null),R(""),ke(void 0),ce(null),tt(null),Me(false),lt(false),ne(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:b("absolute w-[320px] rounded-lg shadow-2xl z-50",pe?"bottom-full mb-1":"top-full mt-1",Ye?"right-0":"left-0",m?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Q=>{Q.stopPropagation(),Me(false),lt(false),ne(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:q,onChange:Q=>R(Q.target.value),placeholder:i==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:b("w-full bg-transparent text-sm outline-none placeholder:opacity-40",m?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:Q=>{if(Q.key==="Enter"&&q.trim()){let Re=t.availableUsers?.find(Ae=>Ae.id===Ee),Nt=dt||D.date;a.onTaskCreate?.({name:q.trim(),startDate:Nt,endDate:Nt,priority:ie,assignees:Re?[Re]:void 0}),R(""),ke(void 0),ce(null),tt(null),j(null);}Q.key==="Escape"&&(j(null),R(""),ke(void 0),ce(null),tt(null));}})}),jsxs("div",{className:b("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:Q=>{Q.stopPropagation(),Me(!Ke),lt(false);},className:b("p-1 rounded transition-colors",ie?ie==="urgent"||ie==="high"?"text-red-400 bg-red-500/20":ie==="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:Ke&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("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:Q=>Q.stopPropagation(),children:[{id:"urgent",label:i==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:i==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:i==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:i==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:i==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(Q=>jsxs("button",{onClick:()=>{ke(Q.id),Me(false);},className:b("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",ie===Q.id&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",Q.color)}),jsx("span",{className:m?"text-white":"text-gray-900",children:Q.label})]},Q.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:Q=>{Q.stopPropagation(),ne(!U),Me(false),lt(false),we(dt||D.date);},className:b("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",dt?"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"}),(dt||D.date).toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:U&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("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:Q=>Q.stopPropagation(),children:[jsx("div",{className:b("w-40 py-2 border-r",m?"border-white/10":"border-gray-200"),children:(()=>{let Q=new Date,Re=new Date(Q);Re.setDate(Q.getDate()+1);let Nt=new Date(Q);Nt.setDate(Q.getDate()+((6-Q.getDay()+7)%7||7));let Ae=new Date(Q);Ae.setDate(Q.getDate()+((1-Q.getDay()+7)%7||7));let aa=new Date(Q);aa.setDate(Q.getDate()+14);let oe=new Date(Q);return oe.setDate(Q.getDate()+28),[{label:i==="es"?"Hoy":"Today",date:Q,display:Q.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:i==="es"?"Ma\xF1ana":"Tomorrow",date:Re,display:Re.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:i==="es"?"Este fin de semana":"This weekend",date:Nt,display:i==="es"?"s\xE1b.":"sat."},{label:i==="es"?"Pr\xF3xima semana":"Next week",date:Ae,display:i==="es"?"lun.":"mon."},{label:i==="es"?"2 semanas":"2 weeks",date:aa,display:aa.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:i==="es"?"4 semanas":"4 weeks",date:oe,display:oe.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((ot,Ue)=>jsxs("button",{className:b("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:()=>{tt(ot.date),ne(false);},children:[jsx("span",{children:ot.label}),jsx("span",{className:b("text-[10px]",m?"text-[#6B7280]":"text-gray-400"),children:ot.display})]},Ue))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:b("text-xs font-medium",m?"text-white":"text-gray-900"),children:re.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>we(new Date),className:b("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:i==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>we(new Date(re.getFullYear(),re.getMonth()-1)),className:b("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:()=>we(new Date(re.getFullYear(),re.getMonth()+1)),className:b("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:(i==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(Q=>jsx("div",{className:b("w-6 h-6 flex items-center justify-center text-[10px]",m?"text-[#6B7280]":"text-gray-400"),children:Q},Q))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let Q=re.getFullYear(),Re=re.getMonth(),Nt=new Date(Q,Re,1).getDay(),Ae=new Date(Q,Re+1,0).getDate(),aa=new Date(Q,Re,0).getDate(),oe=new Date,st=[];for(let Ue=Nt-1;Ue>=0;Ue--)st.push({dayNum:aa-Ue,isCurrentMonth:false,date:new Date(Q,Re-1,aa-Ue)});for(let Ue=1;Ue<=Ae;Ue++)st.push({dayNum:Ue,isCurrentMonth:true,date:new Date(Q,Re,Ue)});let ot=42-st.length;for(let Ue=1;Ue<=ot;Ue++)st.push({dayNum:Ue,isCurrentMonth:false,date:new Date(Q,Re+1,Ue)});return st.map((Ue,Et)=>{let Pt=Ue.date.toDateString()===oe.toDateString(),da=(dt||D.date).toDateString()===Ue.date.toDateString();return jsx("button",{className:b("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!Ue.isCurrentMonth&&(m?"text-[#4B5563]":"text-gray-300"),Ue.isCurrentMonth&&(m?"text-white":"text-gray-900"),Pt&&"ring-1 ring-[#3B82F6]",da&&"bg-[#7C3AED] text-white",!da&&(m?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{tt(Ue.date),ne(false);},children:Ue.dayNum},Et)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:Q=>{Q.stopPropagation(),lt(!at),Me(false);},className:b("p-1 rounded transition-colors",Ee?"text-[#7C3AED] bg-[#7C3AED]/20":m?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:Ee?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(Q=>Q.id===Ee)?.color||"#7C3AED"},children:t.availableUsers?.find(Q=>Q.id===Ee)?.initials||t.availableUsers?.find(Q=>Q.id===Ee)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:at&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("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:Q=>Q.stopPropagation(),children:[jsxs("button",{onClick:()=>{ce(null),lt(false);},className:b("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",!Ee&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:b("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:i==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(Q=>jsxs("button",{onClick:()=>{ce(Q.id),lt(false);},className:b("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",Ee===Q.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:Q.color||"#7C3AED"},children:Q.initials||Q.name?.slice(0,2).toUpperCase()}),jsx("span",{className:m?"text-white":"text-gray-900",children:Q.name})]},Q.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:b("px-3 py-2 text-xs",m?"text-[#6B7280]":"text-gray-400"),children:i==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(q.trim()){let Q=t.availableUsers?.find(Nt=>Nt.id===Ee),Re=dt||D.date;a.onTaskCreate?.({name:q.trim(),startDate:Re,endDate:Re,priority:ie,assignees:Q?[Q]:void 0}),R(""),ke(void 0),ce(null),tt(null),j(null);}},disabled:!q.trim(),className:b("px-2.5 py-1 rounded text-xs font-medium transition-colors",q.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":m?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:i==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:b("text-sm font-medium",D.isToday?"text-[#3B82F6]":D.isCurrentMonth?m?"text-white":"text-gray-900":m?"text-[#6B7280]":"text-gray-400"),children:D.date.getDate()})]})]},A)})})]})}),jsx(AnimatePresence,{children:g&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>k(null),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:b("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:b("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:b("w-4 h-4",m?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:b("text-xs px-2 py-0.5 rounded",m?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[i==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:b("text-xs font-mono",m?"text-[#6B7280]":"text-gray-400"),children:g.id.slice(0,8)}),jsxs("button",{className:b("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:b("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:b("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:()=>k(null),className:b("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 D=g.progress===100?0:100,G={...g,progress:D,status:D===100?"completed":"todo"};k(G),a.onTaskUpdate?.(G);},className:b("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",g.progress===100?"bg-green-500 border-green-500":m?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:g.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:b("text-xl font-semibold flex-1",g.progress===100?"line-through text-[#6B7280]":m?"text-white":"text-gray-900"),children:g.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:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{Be(),be(!te);},className:b("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",g.progress===100||g.status==="completed"?"bg-green-500/20 text-green-400":g.progress&&g.progress>0||g.status==="in-progress"?"bg-blue-500/20 text-blue-400":m?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:g.progress===100||g.status==="completed"?i==="es"?"COMPLETADO":"DONE":g.progress&&g.progress>0||g.status==="in-progress"?i==="es"?"EN PROGRESO":"IN PROGRESS":i==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:te&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>be(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("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:i==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:i==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:i==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(D=>jsxs("button",{onClick:()=>Ne(D.id),className:b("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",(g.status===D.id||D.id==="completed"&&g.progress===100||D.id==="in-progress"&&g.progress&&g.progress>0&&g.progress<100||D.id==="todo"&&(!g.progress||g.progress===0)&&g.status!=="in-progress"&&g.status!=="completed")&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",D.id==="completed"?"bg-green-500":D.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:m?"text-white":"text-gray-900",children:D.label})]},D.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(User,{className:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Asignados":"Assignees"}),jsxs("button",{onClick:()=>{be(false),Oe(false),w(null),H(!je);},className:b("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:[g.assignees&&g.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[g.assignees.slice(0,3).map((D,A)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:D.color||"#8B5CF6"},title:D.name,children:D.initials||D.name.slice(0,2).toUpperCase()},A)),g.assignees.length>3&&jsxs("span",{className:b("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:["+",g.assignees.length-3]})]}):jsx("span",{className:b("text-sm",m?"text-[#6B7280]":"text-gray-400"),children:i==="es"?"Agregar":"Add"}),jsx(ChevronDown,{className:b("w-3 h-3",m?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:je&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>H(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("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(D=>{let A=g.assignees?.some(G=>G.name===D.name);return jsxs("button",{onClick:()=>{let G=g.assignees||[],pe;A?pe=G.filter(Ye=>Ye.name!==D.name):pe=[...G,{name:D.name,avatar:D.avatar,initials:D.initials||D.name.slice(0,2).toUpperCase(),color:D.color||"#8B5CF6"}],me("assignees",pe);},className:b("w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors",m?"hover:bg-white/5":"hover:bg-gray-50",A&&(m?"bg-white/5":"bg-gray-50")),children:[D.avatar?jsx("img",{src:D.avatar,alt:D.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:D.color||"#8B5CF6"},children:D.initials||D.name.slice(0,2).toUpperCase()}),jsx("span",{className:b("flex-1 text-left",m?"text-white":"text-gray-900"),children:D.name}),A&&jsx(Check,{className:"w-4 h-4 text-green-500"})]},D.id||D.name)}):jsx("div",{className:b("px-3 py-4 text-sm text-center",m?"text-[#6B7280]":"text-gray-400"),children:i==="es"?"No hay usuarios disponibles":"No users available"})})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{w(L?null:"start"),M(g.startDate||new Date);},className:b("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:[g.startDate?.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(i==="es"?"Inicio":"Start"),jsx("span",{className:b("mx-1",m?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),g.endDate?.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(i==="es"?"Fin":"End"),(g.startDate||g.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:D=>{D.stopPropagation();}})]}),jsx(AnimatePresence,{children:L&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>w(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:b("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:D=>D.stopPropagation(),children:[jsxs("div",{className:b("w-44 py-2 border-r",m?"border-white/10":"border-gray-200"),children:[(()=>{let D=new Date,A=new Date(D);A.setDate(D.getDate()+1);let G=new Date(D);G.setDate(D.getDate()+((6-D.getDay()+7)%7||7));let pe=new Date(D);pe.setDate(D.getDate()+((1-D.getDay()+7)%7||7));let Ye=new Date(D);Ye.setDate(D.getDate()+(6-D.getDay()+7)%7+7);let Q=new Date(D);Q.setDate(D.getDate()+14);let Re=new Date(D);return Re.setDate(D.getDate()+28),[{label:i==="es"?"Hoy":"Today",date:D,display:D.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:i==="es"?"Ma\xF1ana":"Tomorrow",date:A,display:A.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:i==="es"?"Este fin de semana":"This weekend",date:G,display:i==="es"?"s\xE1b.":"sat."},{label:i==="es"?"Pr\xF3xima semana":"Next week",date:pe,display:i==="es"?"lun.":"mon."},{label:i==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:Ye,display:Ye.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:i==="es"?"2 semanas":"2 weeks",date:Q,display:Q.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:i==="es"?"4 semanas":"4 weeks",date:Re,display:Re.toLocaleDateString(i==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ae,aa)=>jsxs("button",{className:b("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(L==="start"){let oe=g.endDate&&Ae.date>g.endDate?Ae.date:g.endDate;ze(Ae.date,oe),w("end");}else {let oe=g.startDate&&Ae.date<g.startDate?Ae.date:g.startDate;ze(oe,Ae.date),w(null);}},children:[jsx("span",{children:Ae.label}),jsx("span",{className:b("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:Ae.display})]},aa))})(),jsx("div",{className:b("border-t mt-2 pt-2",m?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{ze(void 0,void 0),w(null);},className:b("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:i==="es"?"Quitar fechas":"Clear dates"}),jsx(X,{className:"w-4 h-4 opacity-50"})]})})]}),jsxs("div",{className:"p-4",children:[jsx("div",{className:b("text-xs mb-3 px-2 py-1 rounded",m?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:L==="start"?i==="es"?"\u{1F4C5} Selecciona fecha de inicio":"\u{1F4C5} Select start date":i==="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:b("font-medium",m?"text-white":"text-gray-900"),children:O.toLocaleDateString(i==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>M(new Date),className:b("p-1 rounded text-sm transition-colors",m?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:i==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>M(new Date(O.getFullYear(),O.getMonth()-1)),className:b("p-1 rounded",m?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>M(new Date(O.getFullYear(),O.getMonth()+1)),className:b("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:(i==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(D=>jsx("div",{className:b("w-8 h-8 flex items-center justify-center text-xs",m?"text-[#6B7280]":"text-gray-400"),children:D},D))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let D=O.getFullYear(),A=O.getMonth(),G=new Date(D,A,1).getDay(),pe=new Date(D,A+1,0).getDate(),Ye=new Date(D,A,0).getDate(),Q=new Date,Re=[];for(let Ae=G-1;Ae>=0;Ae--)Re.push({day:Ye-Ae,isCurrentMonth:false,date:new Date(D,A-1,Ye-Ae)});for(let Ae=1;Ae<=pe;Ae++)Re.push({day:Ae,isCurrentMonth:true,date:new Date(D,A,Ae)});let Nt=42-Re.length;for(let Ae=1;Ae<=Nt;Ae++)Re.push({day:Ae,isCurrentMonth:false,date:new Date(D,A+1,Ae)});return Re.map((Ae,aa)=>{let oe=Ae.date.toDateString()===Q.toDateString(),st=g.startDate?.toDateString()===Ae.date.toDateString(),ot=g.endDate?.toDateString()===Ae.date.toDateString(),Ue=st||ot,Et=g.startDate&&g.endDate&&Ae.date>=g.startDate&&Ae.date<=g.endDate;return jsx("button",{className:b("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Ae.isCurrentMonth&&(m?"text-[#4B5563]":"text-gray-300"),Ae.isCurrentMonth&&(m?"text-white":"text-gray-900"),oe&&"ring-2 ring-[#3B82F6]",st&&"bg-[#3B82F6] text-white",ot&&!st&&"bg-[#7C3AED] text-white",Et&&!Ue&&(m?"bg-[#7C3AED]/20":"bg-purple-100"),!Ue&&(m?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let Pt=new Date(Ae.date);if(L==="start"){let da=g.endDate&&Pt>g.endDate?Pt:g.endDate;ze(Pt,da),w("end");}else {let da=g.startDate&&Pt<g.startDate?Pt:g.startDate;ze(da,Pt),w(null);}},children:Ae.day},aa)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{Be(),Oe(!Fe);},className:b("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",g.priority==="high"||g.priority==="urgent"?"bg-red-500/20 text-red-400":g.priority==="medium"?"bg-yellow-500/20 text-yellow-400":g.priority==="low"?"bg-green-500/20 text-green-400":m?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:g.priority?g.priority==="high"||g.priority==="urgent"?i==="es"?"Urgente":"Urgent":g.priority==="medium"?i==="es"?"Media":"Medium":i==="es"?"Baja":"Low":i==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:Fe&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Oe(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("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:i==="es"?"Urgente":"Urgent",color:"bg-red-500"},{id:"high",label:i==="es"?"Alta":"High",color:"bg-orange-500"},{id:"medium",label:i==="es"?"Media":"Medium",color:"bg-yellow-500"},{id:"low",label:i==="es"?"Baja":"Low",color:"bg-green-500"},{id:void 0,label:i==="es"?"Sin prioridad":"No priority",color:"bg-gray-400"}].map(D=>jsxs("button",{onClick:()=>{me("priority",D.id),Oe(false);},className:b("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",g.priority===D.id&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:b("w-2 h-2 rounded-full",D.color)}),jsx("span",{className:m?"text-white":"text-gray-900",children:D.label})]},D.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:b("text-sm",m?"text-white":"text-gray-900"),children:g.startDate&&g.endDate?`${Math.ceil((g.endDate.getTime()-g.startDate.getTime())/(1e3*60*60*24))} ${i==="es"?"d\xEDas":"days"}`:i==="es"?"Sin definir":"Not set"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:b("w-4 h-4 rounded-full border-2",m?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="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:g.progress||0,onChange:D=>{let A=parseInt(D.target.value),G=g.status;A===100?G="completed":A>0?G="in-progress":G="todo";let pe={...g,progress:A,status:G};k(pe),a.onTaskUpdate?.(pe);},onBlur:()=>W(false),className:b("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:()=>W(true),className:b("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:b("h-full rounded-full transition-all",g.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${g.progress||0}%`}})}),jsxs("span",{className:b("text-sm font-medium min-w-[40px]",m?"text-white":"text-gray-900"),children:[g.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Etiquetas":"Tags"}),jsx(Qa,{selectedTags:g.tags||[],availableTags:p,onChange:D=>{me("tags",D);},onCreateTag:l,theme:y})]}),jsxs("div",{className:"flex items-start gap-3 relative",children:[jsx(Link2,{className:b("w-4 h-4 mt-1.5",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24 mt-1",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Relaciones":"Relations"}),jsxs("div",{className:"flex-1",children:[g.dependencies&&g.dependencies.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:g.dependencies.map(D=>{let A=e.find(G=>G.id===D);return jsxs("span",{className:b("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:[A?.name||D.slice(0,8),jsx("button",{onClick:()=>{let G=(g.dependencies||[]).filter(pe=>pe!==D);me("dependencies",G);},className:b("ml-0.5 hover:bg-white/20 rounded-full p-0.5 transition-colors"),children:jsx(X,{className:"w-3 h-3"})})]},D)})}),jsxs("button",{onClick:()=>{Be(),Se(!ye);},className:b("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:b("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Agregar dependencia":"Add dependency"})]}),jsx(AnimatePresence,{children:ye&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Se(false),gt("");}}),jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("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:b("p-2 border-b",m?"border-white/10":"border-gray-200"),children:jsx("input",{type:"text",value:St,onChange:D=>gt(D.target.value),placeholder:i==="es"?"Buscar tarea...":"Search task...",className:b("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(D=>D.id!==g.id).filter(D=>St===""||D.name.toLowerCase().includes(St.toLowerCase())).map(D=>{let A=g.dependencies?.includes(D.id);return jsxs("button",{onClick:()=>{let G=g.dependencies||[],pe;A?pe=G.filter(Ye=>Ye!==D.id):pe=[...G,D.id],me("dependencies",pe);},className:b("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",A&&(m?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:b("w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0",A?"bg-blue-500 border-blue-500":m?"border-white/30":"border-gray-300"),children:A&&jsx(Check,{className:"w-3 h-3 text-white"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("span",{className:b("block truncate",m?"text-white":"text-gray-900"),children:D.name}),jsx("span",{className:b("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:D.id.slice(0,8)})]})]},D.id)}):jsx("div",{className:b("px-3 py-4 text-sm text-center",m?"text-[#6B7280]":"text-gray-500"),children:i==="es"?"No hay tareas disponibles":"No tasks available"})})]})]})})]})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Palette,{className:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:"Color"}),jsxs("button",{onClick:()=>{Be(),sa(!ta);},className:b("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:g.color||"#6366F1"}}),jsx("span",{className:b("text-sm",m?"text-white":"text-gray-900"),children:er.find(D=>D.value===g.color)?.name||(i==="es"?"Azul":"Blue")}),jsx(ChevronDown,{className:b("w-3 h-3",m?"text-[#6B7280]":"text-gray-400")})]}),jsx(AnimatePresence,{children:ta&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>sa(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:b("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:er.map(D=>{let A=g.color===D.value;return jsx("button",{onClick:()=>{me("color",D.value),sa(false);},className:b("w-7 h-7 rounded-full flex items-center justify-center transition-all",A&&"ring-2 ring-offset-2",m?"ring-offset-[#1A1D25]":"ring-offset-white"),style:{backgroundColor:D.value,outlineColor:A?D.value:void 0},title:D.name,children:A&&jsx(Check,{className:"w-3.5 h-3.5 text-white"})},D.value)})})})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Diamond,{className:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:b("text-sm w-24",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Hito":"Milestone"}),jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:g.isMilestone||false,onChange:D=>me("isMilestone",D.target.checked),className:b("w-4 h-4 rounded border-2 cursor-pointer appearance-none transition-colors",g.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:b("text-sm",m?"text-white":"text-gray-900"),children:i==="es"?"Marcar como hito":"Mark as milestone"})]})]})]}),jsxs("div",{className:b("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:b("w-4 h-4",m?"text-[#6B7280]":"text-gray-400")}),jsx("h3",{className:b("text-sm font-semibold",m?"text-white":"text-gray-900"),children:i==="es"?"Descripci\xF3n":"Description"})]}),jsx("textarea",{value:g.description||"",onChange:D=>me("description",D.target.value),placeholder:i==="es"?"Agregar descripci\xF3n...":"Add description...",className:b("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:b("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"}),i==="es"?"Escribe con IA":"Write with AI"]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:b("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:i==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:b("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"}),i==="es"?"Crea un campo en esta lista":"Create a field in this list"]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:b("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:i==="es"?"Agregar subtarea":"Add subtask"}),g.subtasks&&g.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:g.subtasks.map(D=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:b("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",D.progress===100?"bg-green-500 border-green-500":m?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:D.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:b("text-sm",D.progress===100?"line-through text-[#6B7280]":m?"text-white":"text-gray-900"),children:D.name})]},D.id))}),jsxs("button",{className:b("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"}),i==="es"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:b("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:b("text-sm font-semibold",m?"text-white":"text-gray-900"),children:i==="es"?"Listas de control":"Checklists"}),jsx("button",{className:b("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:b("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"}),i==="es"?"Crear lista de control":"Create checklist"]})]}),jsxs("div",{className:b("mt-6 pt-4 border-t",m?"border-white/10":"border-gray-200"),children:[jsxs("h3",{className:b("text-sm font-semibold mb-3",m?"text-white":"text-gray-900"),children:[i==="es"?"Adjuntos":"Attachments",He.length>0&&jsxs("span",{className:b("ml-2 text-xs font-normal",m?"text-[#6B7280]":"text-gray-400"),children:["(",He.length,")"]})]}),He.length>0&&jsx("div",{className:"space-y-2 mb-4",children:He.map(D=>{let A=Pe(D.type),G=D.type.startsWith("image/");return jsxs("div",{className:b("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:[G&&D.thumbnailUrl?jsx("img",{src:D.thumbnailUrl,alt:D.name,className:"w-10 h-10 rounded object-cover"}):jsx("div",{className:b("w-10 h-10 rounded flex items-center justify-center",m?"bg-white/10":"bg-gray-200"),children:jsx(A,{className:b("w-5 h-5",m?"text-[#9CA3AF]":"text-gray-500")})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("a",{href:D.url,target:"_blank",rel:"noopener noreferrer",className:b("text-sm font-medium truncate block hover:underline",m?"text-white":"text-gray-900"),children:D.name}),jsx("p",{className:b("text-xs",m?"text-[#6B7280]":"text-gray-400"),children:ae(D.size)})]}),a.onDeleteAttachment&&jsx("button",{onClick:()=>a.onDeleteAttachment?.(D.id),className:b("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:i==="es"?"Eliminar":"Delete",children:jsx(Trash2,{className:"w-4 h-4"})})]},D.id)})}),jsxs("div",{onDragOver:ct,onDragLeave:Y,onDrop:Le,className:b("border-2 border-dashed rounded-lg p-6 text-center transition-all cursor-pointer relative",Te?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",wt&&"pointer-events-none opacity-50"),children:[jsx("input",{type:"file",multiple:true,onChange:Ze,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:!a.onUploadAttachments||wt}),wt?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:b("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:i==="es"?"Subiendo...":"Uploading..."})]}):jsxs(Fragment,{children:[jsx(Upload,{className:b("w-6 h-6 mx-auto mb-2",Te?"text-blue-500":m?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:b("text-sm",m?"text-[#9CA3AF]":"text-gray-500"),children:Te?i==="es"?"Suelta los archivos aqu\xED":"Drop files here":i==="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:b("text-xs mt-1",m?"text-[#6B7280]":"text-gray-400"),children:i==="es"?"Upload no disponible":"Upload not available"})]})]})]})]})]}),jsxs("div",{className:b("w-[280px] border-l flex flex-col",m?"border-white/10 bg-[#141619]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:b("px-4 py-3 border-b flex items-center justify-between",m?"border-white/10":"border-gray-200"),children:jsx("span",{className:b("font-medium",m?"text-white":"text-gray-900"),children:i==="es"?"Actividad":"Activity"})}),jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:jsxs("div",{className:b("text-sm text-center py-8",m?"text-[#6B7280]":"text-gray-400"),children:[jsx(MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),i==="es"?"Sin actividad reciente":"No recent activity"]})}),jsx("div",{className:b("p-3 border-t",m?"border-white/10":"border-gray-200"),children:jsx("div",{className:b("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",placeholder:i==="es"?"Escribe un comentario...":"Write a comment...",className:b("flex-1 bg-transparent text-sm outline-none",m?"text-white placeholder-[#6B7280]":"text-gray-900 placeholder-gray-400")})})})]})]})]})}),jsx(AnimatePresence,{children:x&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>S(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:b("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:b("px-4 py-3 border-b flex items-center justify-between",m?"border-white/10":"border-gray-200"),children:[jsx("span",{className:b("font-medium",m?"text-white":"text-gray-900"),children:x.date.toLocaleDateString(i==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>S(null),className:b("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:x.events.map(D=>jsxs("button",{onClick:()=>{S(null),k(D.task);},className:b("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($c,{task:D.task}),jsx("span",{className:b("text-sm truncate flex-1",m?"text-white":"text-gray-900"),children:D.title}),D.task.priority==="high"||D.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},D.id))})]})]})})]})}var Fi={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"},Ii={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"},Li={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"},Un={dark:Fi,light:Ii,neutral:Li};function Gc(e){return Un[e]||Un.dark}function lh({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:n,className:c}){let[p,l]=useState(false),u=useMemo(()=>t.filter(h=>e.cardIds.includes(h.id)),[t,e.cardIds]),d=useMemo(()=>{let h=u.length,C=new Set(u.flatMap(f=>f.assignedUserIds||[])).size,m=u.map(f=>f.priority).filter(Boolean),y=new Set(u.flatMap(f=>f.labels||[])).size;return {totalCards:h,uniqueAssignees:C,priorities:m,labels:y}},[u]),i=()=>{o?.(e.id);};return jsxs("div",{className:b("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),style:{"--stack-color":e.color||"var(--color-accent-primary)"},children:[jsxs("div",{className:"card-stack-header",onClick:i,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:b("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:d.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"]})]}),p&&jsx("div",{className:"card-stack-actions",children:jsx("button",{className:"card-stack-action",onClick:h=>{h.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:[d.uniqueAssignees," assignees"]})]}),d.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:[d.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:u.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:u.map(h=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(h),children:a(h)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(h),children:[jsx("h4",{children:h.title}),h.description&&jsxs("p",{children:[h.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:C=>{C.stopPropagation(),s?.(e.id,h.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"})]})})]},h.id))})})]})}var Vc={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function $o(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 Ho(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 jc(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 Kc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:n,className:c}){let p=useMemo(()=>({...Vc,...n}),[n]),[l,u]=useState(new Set),d=useRef(null),i=useMemo(()=>{if(!p.groupByDay)return [{date:null,events:e}];let v=new Map;return e.forEach(g=>{let k=g.timestamp.toISOString().split("T")[0],x=v.get(k);x?x.push(g):v.set(k,[g]);}),Array.from(v.entries()).sort((g,k)=>k[0].localeCompare(g[0])).map(([g,k])=>({date:new Date(g),events:k.sort((x,S)=>S.timestamp.getTime()-x.timestamp.getTime())}))},[e,p.groupByDay]),{uniqueUsers:h,uniqueTypes:C}=useMemo(()=>{let v=new Set,g=new Set;return e.forEach(k=>{v.add(k.userId),g.add(k.type);}),{uniqueUsers:Array.from(v),uniqueTypes:Array.from(g)}},[e]),m=v=>{u(g=>{let k=new Set(g);return k.has(v)?k.delete(v):k.add(v),k});},y=v=>{let k=new Date().getTime()-v.getTime(),x=Math.floor(k/6e4),S=Math.floor(k/36e5),L=Math.floor(k/864e5);return x<1?"just now":x<60?`${x}m ago`:S<24?`${S}h ago`:L<7?`${L}d ago`:v.toLocaleDateString()},f=useMemo(()=>{let v=0;return t.types&&t.types.length>0&&v++,t.users&&t.users.length>0&&v++,t.dateRange&&v++,t.searchTerm&&v++,v},[t]);return useEffect(()=>{if(s&&d.current){let v=d.current.querySelector(`[data-event-id="${s}"]`);v&&v.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:b("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:b("history-timeline",p.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:v=>{let g=v.target.value;a({...t,types:g?[g]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),C.map(v=>jsxs("option",{value:v,children:[Ho(v)," ",v.replace("_"," ")]},v))]}),h.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:v=>{let g=v.target.value;a({...t,users:g?[g]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),h.map(v=>jsx("option",{value:v,children:v},v))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:v=>a({...t,searchTerm:v.target.value})})]}),f>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",f,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:i.map(v=>jsxs("div",{className:"history-timeline-group",children:[p.groupByDay&&v.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:v.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[v.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:v.events.map((g,k)=>{let x=l.has(g.id),S=s===g.id,L=jc(g.type);return jsxs("div",{"data-event-id":g.id,className:b("history-timeline-event",x&&"expanded",S&&"selected"),onClick:()=>o?.(g),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:L},children:p.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:Ho(g.type)})}),k<v.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:L}})]}),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:[p.showAvatars&&g.userAvatar&&jsx("img",{src:g.userAvatar,alt:g.userName||g.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:g.userName||g.userId}),jsx("span",{className:"history-timeline-event-action",children:$o(g)})]})]}),jsx("div",{className:"history-timeline-event-time",children:p.useRelativeTime?y(g.timestamp):g.timestamp.toLocaleString()})]}),Object.keys(g.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:w=>{w.stopPropagation(),m(g.id);},children:[x?"\u25BC":"\u25B6"," Show changes"]}),x&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(g.changes).map(([w,O])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[w,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(O.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(O.to)})]})]},w)),g.metadata&&Object.keys(g.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(g.metadata).map(([w,O])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[w,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(O)})]},w))]})]})]})]},g.id)})})]},v.date?.toISOString()||"all"))})]})}function qc({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:n,onGoToEvent:c,onSpeedChange:p,className:l}){let u=[.5,1,1.5,2,3],d=useMemo(()=>!e||t.length===0?null:t[e.currentIndex],[e,t]),i=useMemo(()=>!e||e.totalEvents===0?0:e.currentIndex/(e.totalEvents-1)*100,[e]);return t.length===0?jsxs("div",{className:b("history-replay-empty",l),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:b("history-replay",l),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:d&&Ho(d.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:d&&$o(d)}),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:d&&d.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:h=>c(parseInt(h.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${i}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((h,C)=>jsx("div",{className:b("history-replay-progress-marker",C===e.currentIndex&&"active"),style:{left:`${C/(e.totalEvents-1)*100}%`},onClick:()=>c(C),title:$o(h)},h.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:u.map(h=>jsxs("button",{className:b("history-replay-speed-btn",e.speed===h&&"active"),onClick:()=>p(h),children:[h,"x"]},h))})]}),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:d&&d.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(h=>jsx("span",{className:"history-replay-card-preview-label-tag",children:h},h))})]})]})]})]}):jsxs("div",{className:b("history-replay-start",l),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 Bi(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 Ri(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 Xc(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 Jc(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function gh(e,t,a,r,o,s=100){let n=e.map(p=>({...p,x:p.x??a/2+Math.random()*100-50,y:p.y??r/2+Math.random()*100-50,vx:0,vy:0})),c=new Map(n.map(p=>[p.id,p]));for(let p=0;p<s;p++){let l=1-p/s;n.forEach(u=>{let d=a/2,i=r/2;u.vx+=(d-u.x)*o.centerForce*l,u.vy+=(i-u.y)*o.centerForce*l,n.forEach(h=>{if(u.id===h.id)return;let C=u.x-h.x,m=u.y-h.y,y=Math.sqrt(C*C+m*m)||1,f=o.chargeStrength*l/(y*y);u.vx+=C/y*f,u.vy+=m/y*f;});}),t.forEach(u=>{let d=c.get(typeof u.source=="string"?u.source:u.source.id),i=c.get(typeof u.target=="string"?u.target:u.target.id);if(!d||!i)return;let h=i.x-d.x,C=i.y-d.y,m=Math.sqrt(h*h+C*C)||1,y=(m-o.linkDistance)/m*o.forceStrength*l;d.vx+=h*y,d.vy+=C*y,i.vx-=h*y,i.vy-=C*y;}),n.forEach(u=>{u.fx!==null&&u.fx!==void 0?(u.x=u.fx,u.vx=0):u.x+=u.vx,u.fy!==null&&u.fy!==void 0?(u.y=u.fy,u.vy=0):u.y+=u.vy,u.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,u.x)),u.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,u.y)),u.vx*=.9,u.vy*=.9;});}return n}function Zc({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:n,onInteraction:c,className:p}){let l=useRef(null),[u,d]=useState([]),[i,h]=useState(null),[C,m]=useState(null),[y,f]=useState(null),[v,g]=useState(1),[k,x]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let B=gh(e,t,a.width,a.height,a,150);d(B);},[e,t,a]);let S=useCallback((B,J)=>{a.enableDragging&&(J.stopPropagation(),h(B));},[a.enableDragging]),L=useCallback(B=>{if(!i||!l.current)return;let te=l.current.getBoundingClientRect(),be=(B.clientX-te.left-k.x)/v,Fe=(B.clientY-te.top-k.y)/v;d(Oe=>Oe.map(je=>je.id===i?{...je,x:be,y:Fe,fx:be,fy:Fe}:je));},[i,v,k]),w=useCallback(()=>{h(null);},[]),O=useCallback((B,J)=>{J.stopPropagation(),c?.({type:"node-click",node:B,position:{x:J.clientX,y:J.clientY}});},[c]),M=useCallback((B,J)=>{J.stopPropagation(),c?.({type:"edge-click",edge:B,position:{x:J.clientX,y:J.clientY}});},[c]),T=useCallback(B=>{let J=u.find(te=>te.id===B);return J?{x:J.x,y:J.y}:{x:0,y:0}},[u]),_=useCallback(B=>{if(B.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return B.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let J=B.card.priority;return J==="URGENT"?"#ef4444":J==="HIGH"?"#f59e0b":J==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return B.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:b("relationships-graph-empty",p),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:b("relationships-graph",p),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:()=>g(B=>Math.min(B+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(v*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>g(B=>Math.max(B-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{g(1),x({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(B=>B.type))).map(B=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:Bi(B)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[Xc(B)," ",Ri(B)]})]},B))}),jsxs("svg",{ref:l,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:L,onMouseUp:w,onMouseLeave:w,children:[jsxs("g",{transform:`translate(${k.x}, ${k.y}) scale(${v})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(B=>{let J=T(typeof B.source=="string"?B.source:B.source.id),te=T(typeof B.target=="string"?B.target:B.target.id),be=Jc(B.type),Fe=y===B.id,Oe=B.onCriticalPath;return jsxs("g",{className:b("relationships-graph-edge",Fe&&"hovered",Oe&&"critical"),onMouseEnter:()=>f(B.id),onMouseLeave:()=>f(null),onClick:je=>M(B,je),children:[jsx("line",{x1:J.x,y1:J.y,x2:te.x,y2:te.y,stroke:Bi(B.type),strokeWidth:Oe?a.edgeWidth*2:a.edgeWidth,strokeOpacity:Fe?1:.6,markerEnd:be?"url(#arrowhead)":void 0}),a.showEdgeLabels&&Fe&&jsx("text",{x:(J.x+te.x)/2,y:(J.y+te.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:Ri(B.type)})]},B.id)})}),jsx("g",{className:"relationships-graph-nodes",children:u.map(B=>{let J=C===B.id,te=B.onCriticalPath;return jsxs("g",{className:b("relationships-graph-node",J&&"hovered",te&&"critical"),transform:`translate(${B.x}, ${B.y})`,onMouseDown:be=>S(B.id,be),onMouseEnter:()=>m(B.id),onMouseLeave:()=>m(null),onClick:be=>O(B,be),children:[jsx("circle",{r:te?a.nodeSize*1.2:a.nodeSize,fill:_(B),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:B.card.title.length>20?B.card.title.substring(0,20)+"...":B.card.title})]},B.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 tm({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,n]=useState(""),[c,p]=useState(false),[l,u]=useState(null),[d,i]=useState(null),h=useRef(null),C=c||o;useEffect(()=>{e&&h.current&&h.current.focus();},[e]),useEffect(()=>{let v=g=>{g.key==="Escape"&&!C&&m();};if(e)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[e,C]);let m=()=>{C||(n(""),u(null),i(null),t());},y=async()=>{if(!(!s.trim()||C)){p(true),u(null),i(null);try{let v=await r(s.trim());i(v);}catch(v){u(v instanceof Error?v.message:"Failed to generate plan");}finally{p(false);}}},f=()=>{d&&(a(d),m());};return e?jsxs(pt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:m}),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:v=>v.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:m,disabled:C,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:d?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!"})]}),d.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:d.explanation})}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Columns (",d.columns.length,")"]}),jsx("div",{className:"flex gap-2 flex-wrap",children:d.columns.map((v,g)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:v.title},g))})]}),jsxs("div",{children:[jsxs("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:["Tasks (",d.cards.length,")"]}),jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[d.cards.slice(0,10).map((v,g)=>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:v.title}),v.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:v.description})]}),v.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${v.priority==="URGENT"?"bg-red-500/20 text-red-400":v.priority==="HIGH"?"bg-orange-500/20 text-orange-400":v.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:v.priority})]})},g)),d.cards.length>10&&jsxs("p",{className:"text-xs text-white/50 text-center py-2",children:["+",d.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:h,value:s,onChange:v=>n(v.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:C}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),l&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:l}),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((v,g)=>jsx("button",{onClick:()=>n(v),disabled:C,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:v},g))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:C&&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:m,disabled:C,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"}),d?jsx("button",{onClick:f,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:y,disabled:!s.trim()||C,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:C?"Generating...":"Generate Plan"})]})]})]})})]}):null}var Oi={"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 hh={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},bh={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 yh(e,t,a){let r=Oi[e];if(!r)throw new Error(`Unknown model: ${e}`);let o=t/1e3*r.costPer1kInput,s=a/1e3*r.costPer1kOutput;return o+s}function Wo(e){return `$${e.toFixed(4)}`}var zi=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=yh(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(d=>d.timestamp>=t.start&&d.timestamp<=t.end));let r=a.length,o=a.reduce((d,i)=>d+i.cost,0),s=a.reduce((d,i)=>d+i.inputTokens,0),n=a.reduce((d,i)=>d+i.outputTokens,0),c=a.filter(d=>d.success),p=a.reduce((d,i)=>d+i.duration,0),l={},u={};return a.forEach(d=>{l[d.feature]=(l[d.feature]||0)+1,u[d.feature]=(u[d.feature]||0)+d.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:n,operationsByFeature:l,costsByFeature:u,averageDuration:r>0?p/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(u=>u.timestamp>=n).length,p=Math.max(0,o-c),l=c/o*100;return {used:c,limit:o,remaining:p,percentUsed:l,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)}},jr=new zi;function om({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(jr.getStats()),[s,n]=useState(jr.checkLimit(a));if(useEffect(()=>{if(!e)return;let p=setInterval(()=>{o(jr.getStats()),n(jr.checkLimit(a));},1e3);return ()=>clearInterval(p)},[e,a]),useEffect(()=>{let p=l=>{l.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,t]),!e)return null;let c=jr.getRecentOperations(5);return jsxs(pt,{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:p=>p.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:Wo(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(([p,l])=>{let u=r.costsByFeature[p]||0,d=r.totalOperations>0?l/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:p.replace(/([A-Z])/g," $1").trim()}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[l," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:Wo(u)})]})]}),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:`${d}%`}})})]},p)})})]}),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(p=>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:p.feature.replace(/([A-Z])/g," $1").trim()}),jsxs("p",{className:"text-xs text-white/50 mt-0.5",children:[new Date(p.timestamp).toLocaleTimeString()," \u2022"," ",p.duration,"ms"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-white/60",children:[p.inputTokens+p.outputTokens," tokens"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:Wo(p.cost)}),jsx("div",{className:`w-2 h-2 rounded-full ${p.success?"bg-green-400":"bg-red-400"}`})]})]},p.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 im({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[n,c]=useState(""),[p,l]=useState(""),[u,d]=useState(""),[i,h]=useState(false),[C,m]=useState(null),[y,f]=useState(null),[v,g]=useState(null),k=useRef(null),x=i||o;useEffect(()=>{e&&k.current&&k.current.focus();},[e]),useEffect(()=>{let M=T=>{T.key==="Escape"&&!x&&S();};if(e)return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[e,x]);let S=()=>{x||(c(""),l(""),d(""),m(null),f(null),g(null),t());},L=async()=>{if(!(!n.trim()||x)){h(true),m(null),f(null),g(null);try{let M=await r({prompt:n.trim(),projectName:s||"Mi Proyecto",startDate:p||void 0,endDate:u||void 0});f(M.tasks.tasks),g({from_cache:M.from_cache,tokens_used:M.tokens_used,mock_mode:M.mock_mode,similarity:M.similarity,tokens_saved:M.tokens_saved});}catch(M){m(M instanceof Error?M.message:"Failed to generate tasks");}finally{h(false);}}},w=()=>{y&&(a(y),S());};if(!e)return null;let O=v?.similarity?((v.similarity||0)*100).toFixed(0):"0";return jsxs(pt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:S}),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:M=>M.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:S,disabled:x,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:y?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:[v?.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"}),v?.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 (",O,"% 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:[v?.tokens_used||0," tokens"]}),v?.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:[v.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:[y.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:y.map((M,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:M.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"})]}),M.start," \u2192 ",M.end]}),jsxs("span",{children:[M.duration," days"]}),M.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",M.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${M.priority==="high"?"bg-red-500/20 text-red-400":M.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:M.priority})]})},M.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:k,value:n,onChange:M=>c(M.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:x}),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:p,onChange:M=>l(M.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:x})]}),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:u,onChange:M=>d(M.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:x})]})]}),C&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:C}),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((M,T)=>jsx("button",{onClick:()=>c(M),disabled:x,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:M},T))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:x&&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:S,disabled:x,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"}),y?jsx("button",{onClick:w,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:L,disabled:!n.trim()||x,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:x?"Generating...":"Generate Tasks"})]})]})]})})]})}function Wn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(y=>{t&&Jo(()=>Promise.resolve(t(y)),{maxAttempts:3,initialDelay:1e3,onRetry:(f,v,g)=>{console.warn(`Retry attempt ${v} after ${g}ms: ${f.message}`);}}).then(f=>{f.success||console.error(`Failed to persist board after ${f.attempts} attempts:`,f.error);});},[t]),s=useCallback(async(y,f,v)=>{r(g=>{let k=g.cards.find(M=>M.id===y);if(!k)return g;let x=k.columnId,S={...k,columnId:f,position:v},L=g.cards.map(M=>M.id===y?S:M),w=g.columns.map(M=>{if(M.id===x)return {...M,cardIds:M.cardIds.filter(T=>T!==y)};if(M.id===f){let T=L.filter(_=>_.columnId===f).sort((_,B)=>_.position-B.position);return {...M,cardIds:T.map(_=>_.id)}}return M}),O={...g,cards:L,columns:w};return o(O),O});},[o]),n=useCallback(async(y,f)=>{r(v=>{let g=v.cards.map(x=>x.id===y?{...x,...f}:x),k={...v,cards:g};return o(k),k});},[o]),c=useCallback(async y=>{let f=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(v=>{let g={...y,id:f},k=v.columns.map(S=>S.id===y.columnId?{...S,cardIds:[...S.cardIds,f]}:S),x={...v,cards:[...v.cards,g],columns:k};return o(x),x});},[o]),p=useCallback(async y=>{r(f=>{let v=f.cards.find(S=>S.id===y);if(!v)return f;let g=f.cards.filter(S=>S.id!==y),k=f.columns.map(S=>S.id===v.columnId?{...S,cardIds:S.cardIds.filter(L=>L!==y)}:S),x={...f,cards:g,columns:k};return o(x),x});},[o]),l=useCallback(async y=>{let f=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(v=>{let g={...y,id:f,cardIds:[]},k={...v,columns:[...v.columns,g]};return o(k),k});},[o]),u=useCallback(async(y,f)=>{r(v=>{let g=v.columns.map(x=>x.id===y?{...x,...f}:x),k={...v,columns:g};return o(k),k});},[o]),d=useCallback(async y=>{r(f=>{let v=f.cards.filter(x=>x.columnId!==y),g=f.columns.filter(x=>x.id!==y),k={...f,cards:v,columns:g};return o(k),k});},[o]),i=useCallback(y=>{let f=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(y),f},[c]),h=useCallback(y=>{let f=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return l(y),f},[l]),C=useCallback(()=>{r(y=>{let f={...y,cards:[],columns:[]};return o(f),f});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:n,onCardCreate:c,onCardDelete:p,onColumnCreate:l,onColumnUpdate:u,onColumnDelete:d},setBoard:r,helpers:{addCard:i,addColumn:h,deleteCard:p,deleteColumn:d,clearBoard:C}}}function dm({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=Wn({initialBoard:e,onPersist:a}),n=useMemo(()=>({addCard:(p,l,u={})=>{s.addCard({title:l,columnId:p,position:r.cards.filter(d=>d.columnId===p).length,...u});},addColumn:(p,l)=>{let u=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:p,position:l??u+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 Go={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},mm={by:"none",order:"asc"};function pm({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...Go,...e}),[s,n]=useState({...mm,...t}),c=useCallback(m=>{o(y=>({...y,...m}));},[]),p=useCallback(m=>{n(y=>({...y,...m}));},[]),l=useCallback(()=>{o(Go),n(mm);},[]),u=useCallback(()=>{a&&o({...Go,assignees:[a]});},[a]),d=useCallback(()=>{o({...Go,dateFilter:"overdue"});},[]),i=useCallback(()=>{o({...Go,priorities:["HIGH","URGENT"]});},[]),h=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]),C=useCallback(m=>{let y=[...m];if(r.search){let f=r.search.toLowerCase();y=y.filter(v=>v.title.toLowerCase().includes(f)||v.description?.toLowerCase().includes(f));}if(r.dateFilter!=="all"){let f=new Date,v=f.getFullYear(),g=String(f.getMonth()+1).padStart(2,"0"),k=String(f.getDate()).padStart(2,"0"),x=`${v}-${g}-${k}`;y=y.filter(S=>{if(!S.endDate&&!S.dueDate)return false;let L=S.endDate||S.dueDate;if(!L)return false;let w;if(typeof L=="string")w=L.split("T")[0]||L;else {let O=L.getUTCFullYear(),M=String(L.getUTCMonth()+1).padStart(2,"0"),T=String(L.getUTCDate()).padStart(2,"0");w=`${O}-${M}-${T}`;}switch(r.dateFilter){case "overdue":return w<x;case "today":return w===x;case "this-week":let O=new Date(x+"T00:00:00"),M=new Date(w+"T00:00:00"),T=new Date(O);return T.setDate(T.getDate()+7),M>=O&&M<=T;case "custom":if(r.dateRange){let _=typeof L=="string"?new Date(L):L;return _>=r.dateRange.start&&_<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(y=y.filter(f=>f.priority&&r.priorities.includes(f.priority))),r.assignees.length>0&&(y=y.filter(f=>(f.assignedUserIds||(f.assigneeId?[f.assigneeId]:[])).some(g=>r.assignees.includes(g)))),r.labels.length>0&&(y=y.filter(f=>f.labels&&f.labels.some(v=>r.labels.includes(v)))),r.columns.length>0&&(y=y.filter(f=>r.columns.includes(f.columnId))),s.by!=="none"&&y.sort((f,v)=>{let g=0;switch(s.by){case "created":let k=f.createdAt?new Date(f.createdAt).getTime():0,x=v.createdAt?new Date(v.createdAt).getTime():0;g=k-x;break;case "priority":let S={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},L=S[f.priority||"LOW"],w=S[v.priority||"LOW"];g=L-w;break;case "dueDate":let O=f.endDate||f.dueDate,M=v.endDate||v.dueDate;if(!O)return 1;if(!M)return -1;let T=typeof O=="string"?new Date(O).getTime():O.getTime(),_=typeof M=="string"?new Date(M).getTime():M.getTime();g=T-_;break;case "title":g=f.title.localeCompare(v.title);break;case "estimate":let B=f.estimatedTime||0,J=v.estimatedTime||0;g=B-J;break;default:g=0;}return s.order==="asc"?g:-g}),y},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:p,resetFilters:l,filterMyTasks:u,filterOverdue:d,filterHighPriority:i,applyFilters:C,hasActiveFilters:h}}var gm,fm;if(typeof window<"u")try{let e=Yo("ai");gm=e.generateObject,fm=e.generateText;}catch{}function hm(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(gm&&fm&&e.apiKey),n=useCallback(async d=>{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:",d),{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: ${d}`,position:1e3,columnId:"temp-col-1"}],explanation:"This is a sample plan. Real implementation would use AI SDK."}}catch(i){let h=i instanceof Error?i:new Error("Failed to generate plan");throw o(h),h}finally{a(false);}},[s]),c=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Suggesting assignee for:",d.title),{userId:"user-123",confidence:.85,reasoning:"Based on past performance and expertise"}}catch(i){let h=i instanceof Error?i:new Error("Failed to suggest assignee");throw o(h),h}finally{a(false);}},[s]),p=useCallback(async d=>{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(i){let h=i instanceof Error?i:new Error("Failed to predict risks");throw o(h),h}finally{a(false);}},[s]),l=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Generating subtasks for:",d.title),[{title:`Subtask 1 for: ${d.title}`,position:d.position+.1,columnId:d.columnId},{title:`Subtask 2 for: ${d.title}`,position:d.position+.2,columnId:d.columnId}]}catch(i){let h=i instanceof Error?i:new Error("Failed to generate subtasks");throw o(h),h}finally{a(false);}},[s]),u=useCallback(async d=>{if(!s)throw new Error("AI features not available");a(true),o(null);try{return console.log("Estimating effort for:",d.title),{hours:8,confidence:.75}}catch(i){let h=i instanceof Error?i:new Error("Failed to estimate effort");throw o(h),h}finally{a(false);}},[s]);return {onGeneratePlan:n,onSuggestAssignee:c,onPredictRisks:p,onGenerateSubtasks:l,onEstimateEffort:u,isAvailable:s,isLoading:t,error:r}}function $i(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function bm(e){let{cards:t}=e,[a,r]=$i(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,i)=>{if(!i){r({selectedCardIds:[d],lastSelectedCardId:d});return}let h=i.ctrlKey||i.metaKey,C=i.shiftKey;if(h)a.selectedCardIds.includes(d)?r({selectedCardIds:a.selectedCardIds.filter(m=>m!==d),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});else if(C&&a.lastSelectedCardId){let m=t.find(f=>f.id===d),y=t.find(f=>f.id===a.lastSelectedCardId);if(m&&y&&m.columnId===y.columnId){let f=t.filter(w=>w.columnId===m.columnId).sort((w,O)=>w.position-O.position),v=f.findIndex(w=>w.id===a.lastSelectedCardId),g=f.findIndex(w=>w.id===d),[k,x]=v<g?[v,g]:[g,v],S=f.slice(k,x+1).map(w=>w.id),L=Array.from(new Set([...a.selectedCardIds,...S]));r({selectedCardIds:L,lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});},[t,a,r]),n=useCallback(d=>{r({selectedCardIds:a.selectedCardIds.filter(i=>i!==d),lastSelectedCardId:a.lastSelectedCardId});},[a,r]),c=useCallback(()=>{r({selectedCardIds:[],lastSelectedCardId:null});},[r]),p=useCallback(()=>{r({selectedCardIds:t.map(d=>d.id),lastSelectedCardId:t[t.length-1]?.id||null});},[t,r]),l=useCallback(d=>{a.selectedCardIds.includes(d)?n(d):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});},[a,n,r]),u=useCallback(()=>t.filter(d=>a.selectedCardIds.includes(d.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:n,clearSelection:c,selectAll:p,toggleCard:l,getSelectedCards:u}}var ym={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function vm(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...ym,...a}),[a]),[s,n]=useState([]),c=useCallback((m,y,f,v,g)=>{if(y.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let k={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:m,cardIds:y,columnId:f,strategy:v,color:g,isExpanded:true,position:s.filter(x=>x.columnId===f).length,createdAt:new Date};n(x=>[...x,k]);},[o.minCardsPerStack,s]),p=useCallback(m=>{n(y=>y.filter(f=>f.id!==m));},[]),l=useCallback(m=>{n(y=>y.map(f=>f.id===m?{...f,isExpanded:!f.isExpanded}:f));},[]),u=useCallback((m,y)=>{n(f=>f.map(v=>v.id===m&&!v.cardIds.includes(y)?{...v,cardIds:[...v.cardIds,y]}:v));},[]),d=useCallback((m,y)=>{n(f=>f.map(v=>{if(v.id===m){let g=v.cardIds.filter(k=>k!==y);return g.length<o.minCardsPerStack?null:{...v,cardIds:g}}return v}).filter(v=>v!==null));},[o.minCardsPerStack]),i=useCallback(m=>s.filter(y=>y.columnId===m).sort((y,f)=>y.position-f.position),[s]),h=useCallback(async m=>{let y=t.filter(x=>x.columnId===m);if(y.length<o.minCardsPerStack*2)return [];let f=[],v=new Map;y.forEach(x=>{x.labels&&x.labels.length>0&&x.labels.forEach(S=>{v.has(S)||v.set(S,[]),v.get(S).push(x);});}),v.forEach((x,S)=>{x.length>=o.minCardsPerStack&&f.push({stack:{title:`\u{1F4CC} ${S}`,cardIds:x.map(L=>L.id),columnId:m,strategy:"labels",color:"#3b82f6"},reason:`${x.length} cards with label "${S}"`,confidence:.85});});let g=new Map;y.forEach(x=>{x.assignedUserIds&&x.assignedUserIds.length>0&&x.assignedUserIds.forEach(S=>{g.has(S)||g.set(S,[]),g.get(S).push(x);});}),g.forEach((x,S)=>{x.length>=o.minCardsPerStack&&f.push({stack:{title:`\u{1F464} Assigned to user-${S.slice(-4)}`,cardIds:x.map(L=>L.id),columnId:m,strategy:"assignee",color:"#8b5cf6"},reason:`${x.length} cards assigned to the same user`,confidence:.8});});let k=new Map;if(y.forEach(x=>{x.priority&&(k.has(x.priority)||k.set(x.priority,[]),k.get(x.priority).push(x));}),k.forEach((x,S)=>{if(x.length>=o.minCardsPerStack){let L={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[S.toLowerCase()]||"\u26AA";f.push({stack:{title:`${L} ${S} Priority`,cardIds:x.map(w=>w.id),columnId:m,strategy:"priority",color:S==="high"||S==="urgent"?"#ef4444":"#10b981"},reason:`${x.length} cards with ${S} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let x of y){let L=(await r.findSimilar(x,y)).filter(w=>w.similarity>=o.autoStackConfidenceThreshold);if(L.length>=o.minCardsPerStack-1){let w=[x.id,...L.map(M=>M.card.id)],O=L.reduce((M,T)=>M+T.similarity,0)/L.length;f.push({stack:{title:`\u2728 Similar to "${x.title.substring(0,30)}${x.title.length>30?"...":""}"`,cardIds:w,columnId:m,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${L.length+1} similar tasks`,confidence:O});}}return f.filter(x=>x.confidence>=o.autoStackConfidenceThreshold).sort((x,S)=>S.confidence-x.confidence).slice(0,5)},[t,o,r]),C=useCallback(m=>{c(m.stack.title,m.stack.cardIds,m.stack.columnId,m.stack.strategy,m.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(y=>y.columnId)).forEach(async y=>{let f=await h(y),v=f[0];f.length>0&&v&&v.confidence>=.9&&C(v);});},[]),{stacks:s,createStack:c,deleteStack:p,toggleStack:l,addToStack:u,removeFromStack:d,getStacksForColumn:i,getSuggestions:h,applySuggestion:C,config:o}}var xm=createContext(null);function km({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,n=new Map;t?.columns?.forEach(p=>{let{Column:l}=Yo("@libxai/core");s.set(p.id,new l(p));}),t?.cards?.forEach(p=>{let{Card:l}=Yo("@libxai/core");n.set(p.id,new l(p));});let c=null;if(t?.board){let{Board:p}=Yo("@libxai/core");c=new p(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(xm.Provider,{value:{store:o},children:e})}function Gn(){let e=useContext(xm);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function Vo(){let e=Gn(),[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(v=>{e.updateBoard(v);},[e]),p=useCallback(v=>{e.addColumn(v);},[e]),l=useCallback((v,g)=>{e.updateColumn(v,g);},[e]),u=useCallback(v=>{e.deleteColumn(v);},[e]),d=useCallback(v=>e.getColumn(v),[e]),i=useCallback(v=>{e.addCard(v);},[e]),h=useCallback((v,g)=>{e.updateCard(v,g);},[e]),C=useCallback(v=>{e.deleteCard(v);},[e]),m=useCallback((v,g,k)=>{e.moveCard(v,g,k);},[e]),y=useCallback(v=>e.getCard(v),[e]),f=useCallback(v=>e.getCardsByColumn(v),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:p,updateColumn:l,deleteColumn:u,getColumn:d,addCard:i,updateCard:h,deleteCard:C,moveCard:m,getCard:y,getCardsByColumn:f}}function Cm(e){let{cards:t}=Vo();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 Tm(e="position",t="asc"){let{cards:a}=Vo();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},p=o.priority?c[o.priority]:0,l=s.priority?c[s.priority]:0;n=p-l;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 _n=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=yl.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);}},Bh=new _n;function Dm({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:n=false,gap:c=0,getItemKey:p}){let l=useRef(null),u=useVirtualizer({count:e.length,getScrollElement:()=>l.current,estimateSize:()=>a,overscan:s,horizontal:n,gap:c}),d=u.getVirtualItems(),i={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},h=n?{width:`${u.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${u.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:l,style:i,className:o,children:jsx("div",{style:h,children:d.map(C=>{let m=e[C.index];if(!m)return null;let y=p?p(m,C.index):C.index,f={position:"absolute",top:n?0:C.start,left:n?C.start:0,width:n?C.size:"100%",height:n?"100%":C.size};return jsx("div",{style:f,"data-index":C.index,children:r(m,C.index)},y)})})})}function Sm(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 Pm({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:n=3,gap:c=16,getItemKey:p,horizontal:l=true}){let u=useRef(null),d=useVirtualizer({horizontal:l,count:e.length,getScrollElement:()=>u.current,estimateSize:()=>r,overscan:n,gap:c}),i=d.getVirtualItems(),h={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},C={width:`${d.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:u,style:h,className:s,children:jsx("div",{style:C,children:i.map(m=>{let y=e[m.index];if(!y)return null;let f=p?p(y,m.index):m.index,v={position:"absolute",top:0,left:m.start,width:m.size,height:"100%"};return jsx("div",{style:v,"data-index":m.index,children:o(y,m.index)},f)})})})}function Mm(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 Am(e,t=10){return e>t}var _i={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},Vi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},ji={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},Ki={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},Yi={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},qi={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Xi={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Ji={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)"},Zi={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)"},Qi={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},el={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}},tl={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}},Vn={spacing:_i,borderRadius:Vi,fontSize:ji,fontWeight:Ki,lineHeight:Yi,zIndex:qi,duration:Xi,easing:Ji,shadows:Zi,opacity:Qi,kanban:el,gantt:tl};function Fm(e,t,a){return e[t]??a}function al(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)?al(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function zh(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function rl(e="asakaa"){let t=al(Vn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,n=zh(o);a.push(` ${s}: ${n};`);}return `:root {
390
390
  ${a.join(`
391
391
  `)}
392
392
  }`}function jo(e,t="asakaa"){let a=[],r=al(e);for(let[o,s]of Object.entries(r)){let n=`--${t}-color-${o}`;a.push(` ${n}: ${s};`);}return `:root {
@@ -394,7 +394,7 @@ ${a.join(`
394
394
  `)}
395
395
  }`}var jn={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"}},ol={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"}},nl={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 sl(e=jn,t="asakaa"){let a=rl(t),r=jo(e,t);return `${a}
396
396
 
397
- ${r}`}function Ip(){return `/**
397
+ ${r}`}function Im(){return `/**
398
398
  * ASAKAA Design Tokens
399
399
  * Auto-generated from design-tokens.ts
400
400
  * Do not edit this file directly
@@ -415,6 +415,6 @@ ${jo(nl,"asakaa").split(`
415
415
  `).slice(1,-1).join(`
416
416
  `)}
417
417
  }
418
- `}var Uh=({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 Lp({showLabels:e=true,compact:t=false,className:a=""}){let{theme:r,setTheme:o,themes:s}=io();return jsx("div",{className:`theme-switcher ${t?"theme-switcher--compact":""} ${a}`,children:Object.entries(s).map(([n,c])=>{let m=n,l=m===r;return jsxs("button",{onClick:()=>o(m),className:`theme-switcher__button ${l?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${c.displayName} theme`,"aria-pressed":l,title:c.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(Uh,{theme:m})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:c.displayName})]},m)})})}
419
- export{op as AIUsageDashboard,bh as AI_FEATURES,Oi as AI_MODELS,xs as AddCardButton,vs as AddColumnButton,rr as AttachmentUploader,kp as BoardProvider,pn as BulkOperationsToolbar,Fs as BurnDownChart,Wc as CalendarBoard,sr as Card,Ds as CardDetailModal,Ps as CardDetailModalV2,qc as CardHistoryReplay,Kc as CardHistoryTimeline,Zc as CardRelationshipsGraph,lh as CardStack,Us as CardTemplateSelector,es as CircuitBreaker,to as Column,bn as ColumnManager,Cs as CommandPalette,Gs as ConfigMenu,po as ContextMenu,Eo as DEFAULT_SHORTCUTS,zs as DEFAULT_TEMPLATES,vo as DateRangePicker,ko as DependenciesSelector,Tn as DependencyLine,Is as DistributionCharts,ls as EditableColumnTitle,ro as ErrorBoundary,Hs as ExportImportModal,Ws as FilterBar,xc as GANTT_AI_SYSTEM_PROMPT,Pn as GanttAIAssistant,hc as GanttBoard,co as GanttI18nContext,Dn as GanttMilestone,hn as GanttToolbar,ip as GenerateGanttTasksDialog,tp as GeneratePlanModal,Rs as GroupBySelector,vr as KanbanBoard,bs as KanbanToolbar,No as KanbanViewAdapter,Os as KeyboardShortcutsHelp,Fc as ListView,Lt as MenuIcons,_n as PluginManager,Fr as PrioritySelector,hh as RATE_LIMITS,Ls as SwimlaneBoardView,cs as TagBadge,Yl as TagList,Qa as TagPicker,kn as TaskBar,Or as TaskDetailModal,vc as TaskFormModal,xn as TaskGrid,Ks as ThemeModal,Fd as ThemeProvider,Lp as ThemeSwitcher,En as Timeline,Lr as UserAssignmentSelector,As as VelocityChart,Pp as VirtualGrid,Dp as VirtualList,jr as aiUsageTracker,Vi as borderRadius,Xo as calculatePosition,Fi as calendarDarkTheme,Ti as calendarEnTranslations,Ni as calendarEsTranslations,Ii as calendarLightTheme,Li as calendarNeutralTheme,Un as calendarThemes,Rn as calendarTranslations,An as cardToGanttTask,Sc as cardsToGanttTasks,b as cn,pd as createKanbanView,Zp as createRetryWrapper,_s as darkTheme,jn as darkTokenTheme,un as defaultTheme,Vn as designTokens,Xi as duration,Ji as easing,Ip as exportTokensToCSS,cr as findTaskByName,ji as fontSize,Ki as fontWeight,Wo as formatCost,fn as ganttEnTranslations,Ld as ganttEsTranslations,Dc as ganttTaskToCardUpdate,Ye as ganttThemes,tl as ganttTokens,Ys as ganttTranslations,me as ganttUtils,rl as generateCSSVariables,sl as generateCompleteCSS,Yp as generateInitialPositions,kc as generateTasksContext,jo as generateThemeVariables,Gc as getCalendarTheme,Oo as getCalendarTranslations,Ic as getListViewTheme,xi as getListViewTranslations,Lc as getMonthNames,Fp as getToken,Bd as getTranslations,Bc as getWeekdayNames,el as kanbanTokens,Vs as lightTheme,ol as lightTokenTheme,Yi as lineHeight,ki as listViewDarkTheme,yi as listViewEnTranslations,vi as listViewEsTranslations,wi as listViewLightTheme,Ci as listViewNeutralTheme,Bn as listViewThemes,Fn as listViewTranslations,On as mergeCalendarTranslations,In as mergeListViewTranslations,qs as mergeTranslations,js as neutralTheme,nl as neutralTokenTheme,Qi as opacity,Tc as parseLocalCommand,fi as parseNaturalDate,hi as parseNaturalDuration,bi as parseProgress,Cc as parseStatus,Bh as pluginManager,Jp as retrySyncOperation,Jo as retryWithBackoff,Zi as shadows,Ap as shouldVirtualizeGrid,_i as spacing,$r as themes,hp as useAI,dp as useBoard,Vo as useBoardCore,Gn as useBoardStore,vp as useCardStacking,fs as useDragState,Cp as useFilteredCards,mp as useFilters,Po as useGanttI18n,Wn as useKanbanState,Pd as useKeyboardShortcuts,bp as useMultiSelect,$i as useSelectionState,Tp as useSortedCards,io as useTheme,Mp as useVirtualGrid,Sp as useVirtualList,Nc as validateAIResponse,ks as withErrorBoundary,Qo as wouldCreateCircularDependency,qi as zIndex};//# sourceMappingURL=index.js.map
418
+ `}var Uh=({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 Lm({showLabels:e=true,compact:t=false,className:a=""}){let{theme:r,setTheme:o,themes:s}=io();return jsx("div",{className:`theme-switcher ${t?"theme-switcher--compact":""} ${a}`,children:Object.entries(s).map(([n,c])=>{let p=n,l=p===r;return jsxs("button",{onClick:()=>o(p),className:`theme-switcher__button ${l?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${c.displayName} theme`,"aria-pressed":l,title:c.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(Uh,{theme:p})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:c.displayName})]},p)})})}
419
+ export{om as AIUsageDashboard,bh as AI_FEATURES,Oi as AI_MODELS,xs as AddCardButton,vs as AddColumnButton,rr as AttachmentUploader,km as BoardProvider,mn as BulkOperationsToolbar,Fs as BurnDownChart,Wc as CalendarBoard,sr as Card,Ds as CardDetailModal,Ps as CardDetailModalV2,qc as CardHistoryReplay,Kc as CardHistoryTimeline,Zc as CardRelationshipsGraph,lh as CardStack,Us as CardTemplateSelector,es as CircuitBreaker,to as Column,bn as ColumnManager,Cs as CommandPalette,Gs as ConfigMenu,mo as ContextMenu,Eo as DEFAULT_SHORTCUTS,zs as DEFAULT_TEMPLATES,vo as DateRangePicker,ko as DependenciesSelector,Tn as DependencyLine,Is as DistributionCharts,ls as EditableColumnTitle,ro as ErrorBoundary,Hs as ExportImportModal,Ws as FilterBar,xc as GANTT_AI_SYSTEM_PROMPT,Pn as GanttAIAssistant,hc as GanttBoard,co as GanttI18nContext,Dn as GanttMilestone,hn as GanttToolbar,im as GenerateGanttTasksDialog,tm as GeneratePlanModal,Rs as GroupBySelector,vr as KanbanBoard,bs as KanbanToolbar,No as KanbanViewAdapter,Os as KeyboardShortcutsHelp,Fc as ListView,Lt as MenuIcons,_n as PluginManager,Fr as PrioritySelector,hh as RATE_LIMITS,Ls as SwimlaneBoardView,cs as TagBadge,Yl as TagList,Qa as TagPicker,kn as TaskBar,Or as TaskDetailModal,vc as TaskFormModal,xn as TaskGrid,Ks as ThemeModal,Fd as ThemeProvider,Lm as ThemeSwitcher,En as Timeline,Lr as UserAssignmentSelector,As as VelocityChart,Pm as VirtualGrid,Dm as VirtualList,jr as aiUsageTracker,Vi as borderRadius,Xo as calculatePosition,Fi as calendarDarkTheme,Ti as calendarEnTranslations,Ni as calendarEsTranslations,Ii as calendarLightTheme,Li as calendarNeutralTheme,Un as calendarThemes,Rn as calendarTranslations,An as cardToGanttTask,Sc as cardsToGanttTasks,b as cn,md as createKanbanView,Zm as createRetryWrapper,_s as darkTheme,jn as darkTokenTheme,un as defaultTheme,Vn as designTokens,Xi as duration,Ji as easing,Im as exportTokensToCSS,cr as findTaskByName,ji as fontSize,Ki as fontWeight,Wo as formatCost,fn as ganttEnTranslations,Ld as ganttEsTranslations,Dc as ganttTaskToCardUpdate,qe as ganttThemes,tl as ganttTokens,Ys as ganttTranslations,ue as ganttUtils,rl as generateCSSVariables,sl as generateCompleteCSS,Ym as generateInitialPositions,kc as generateTasksContext,jo as generateThemeVariables,Gc as getCalendarTheme,Oo as getCalendarTranslations,Ic as getListViewTheme,xi as getListViewTranslations,Lc as getMonthNames,Fm as getToken,Bd as getTranslations,Bc as getWeekdayNames,el as kanbanTokens,Vs as lightTheme,ol as lightTokenTheme,Yi as lineHeight,ki as listViewDarkTheme,yi as listViewEnTranslations,vi as listViewEsTranslations,wi as listViewLightTheme,Ci as listViewNeutralTheme,Bn as listViewThemes,Fn as listViewTranslations,On as mergeCalendarTranslations,In as mergeListViewTranslations,qs as mergeTranslations,js as neutralTheme,nl as neutralTokenTheme,Qi as opacity,Tc as parseLocalCommand,fi as parseNaturalDate,hi as parseNaturalDuration,bi as parseProgress,Cc as parseStatus,Bh as pluginManager,Jm as retrySyncOperation,Jo as retryWithBackoff,Zi as shadows,Am as shouldVirtualizeGrid,_i as spacing,$r as themes,hm as useAI,dm as useBoard,Vo as useBoardCore,Gn as useBoardStore,vm as useCardStacking,fs as useDragState,Cm as useFilteredCards,pm as useFilters,Po as useGanttI18n,Wn as useKanbanState,Pd as useKeyboardShortcuts,bm as useMultiSelect,$i as useSelectionState,Tm as useSortedCards,io as useTheme,Mm as useVirtualGrid,Sm as useVirtualList,Nc as validateAIResponse,ks as withErrorBoundary,Qo as wouldCreateCircularDependency,qi as zIndex};//# sourceMappingURL=index.js.map
420
420
  //# sourceMappingURL=index.js.map