@libxai/board 0.17.180 → 0.17.181

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 Id from'html2canvas';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';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,X,AlertCircle,CircleDot,ChevronDown,Check,Flag,Users,Calendar,ChevronLeft,Clock,Milestone,Rows3,FileImage,FileText,FileSpreadsheet,FileJson,FolderKanban,Download,GripVertical,Tag,List,Search,CalendarDays,User,Sparkles,Maximize2,MoreHorizontal,ListChecks,Upload,MessageSquare}from'lucide-react';import {AnimatePresence,motion}from'framer-motion';import {Command}from'cmdk';import Dm from'react-markdown';import Nm from'remark-gfm';import Sm from'rehype-sanitize';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Line,AreaChart,Area,PieChart,Pie,Cell,BarChart,Bar}from'recharts';var Po=(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 Mo=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 [Mo.Translate.toString(e),Mo.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function C(...e){return twMerge(clsx(e))}function Ao(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 np(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function In(e,t){return e.length===0?1e3:t===0?Ao(null,e[0].position):t>=e.length?Ao(e[e.length-1].position,null):Ao(e[t-1].position,e[t].position)}function Oi(e,t=100){return e>t}var sp=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 ip(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 Io(e,t={}){let{maxAttempts:a=3,initialDelay:r=1e3,backoffMultiplier:o=2,maxDelay:s=1e4,shouldRetry:l=sp,onRetry:c}=t,p,n=0;for(let m=1;m<=a;m++){n=m;try{return {data:await e(),attempts:n,success:!0}}catch(d){if(p=d,m===a||!l(p,m))return {error:p,attempts:n,success:false};let u=ip(m,r,o,s);if(c)try{c(p,m,u);}catch(y){console.error("Error in retry callback:",y);}await new Promise(y=>setTimeout(y,u));}}return {error:p||new Error("Unknown error"),attempts:n,success:false}}function lp(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 dp(e,t={}){return async(...a)=>Io(()=>e(...a),t)}var Ln=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 zi=(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))(zi||{}),dr=class dr{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...l}=t,c=`[${a}] [${r}] [${s}]`,p=Object.keys(l).length>0;switch(r){case "DEBUG":console.debug(c,o,p?l:"");break;case "INFO":console.info(c,o,p?l:"");break;case "WARN":console.warn(c,o,p?l:"");break;case "ERROR":console.error(c,o,p?l:""),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",...dr.globalOptions};}static configure(t){dr.globalOptions={...dr.globalOptions,...t};}child(t){return new dr({...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 Lo((a,r)=>{this.log(0,`${t} completed`,{...r,action:t,duration:a});},true):new Lo(()=>{},false)}log(t,a,r){if(!this.options.enabled||t<this.options.minLevel)return;let o={timestamp:new Date().toISOString(),level:zi[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};dr.globalOptions={};var Fn=dr,Lo=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}},$i=new Fn;function pp(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 mp(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 l=e.columns.find(c=>c.id===s.columnId);return [s.id,Bn(s.title),Bn(s.description||""),Bn(l?.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 up(e,t,a){let r=t;if(!r){let l=document.querySelector(".asakaa-board");l&&(r=l.parentElement||l);}if(r)try{let l=await Id(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),c=l.toDataURL("image/png"),p=297,n=210,m=l.width/l.height,d=p-20,i=d/m;i>n-20&&(i=n-20,d=i*m);let u=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});u.setFontSize(16),u.setTextColor(255,255,255),u.setFillColor(10,10,10),u.rect(0,0,p,15,"F"),u.text(e.title||"Kanban Board",10,10);let y=(p-d)/2;return u.addImage(c,"PNG",y,20,d,i),u}catch(l){console.error("Error capturing board:",l);}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(l=>{let c=e.cards.filter(p=>p.columnId===l.id);s>250&&(o.addPage(),s=20),o.setFontSize(16),o.setFont("helvetica","bold"),o.text(l.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 m=o.splitTextToSize(p.description,160);o.text(m,25,s),s+=m.length*5;}let n=[];if(p.priority&&n.push(`Priority: ${p.priority}`),p.labels&&p.labels.length>0&&n.push(`Labels: ${p.labels.join(", ")}`),p.assignedUserIds&&p.assignedUserIds.length>0&&n.push(`Assigned: ${p.assignedUserIds.length} user(s)`),p.startDate||p.endDate){let m=[];p.startDate&&m.push(`Start: ${p.startDate}`),p.endDate&&m.push(`End: ${p.endDate}`),n.push(m.join(" \u2192 "));}n.length>0&&(o.setFontSize(8),o.setTextColor(100,100,100),o.text(n.join(" \u2022 "),25,s),o.setTextColor(0,0,0),s+=5),s+=5;}),s+=5;}),o}function Bn(e){return e.includes(",")||e.includes('"')||e.includes(`
3
- `)?`"${e.replace(/"/g,'""')}"`:e}async function Wi(e,t,a,r){switch(t){case "json":return pp(e,r);case "csv":return mp(e);case "pdf":return await up(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function Hi(e,t,a){let r=`board-export-${new Date().getTime()}`;if(t==="pdf"&&typeof e=="object"&&e!==null&&"save"in e){let m=`${r}.pdf`;e.save(m);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]}`,l={json:"application/json",csv:"text/csv",pdf:"application/pdf"},c=new Blob([e],{type:l[t]}),p=URL.createObjectURL(c),n=document.createElement("a");n.href=p,n.download=s,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(p);}function gp(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 fp(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=Gi(t[0]),r=[],o=new Map,s=[];for(let l=1;l<t.length;l++)try{let c=Gi(t[l]||"");if(c.length>a.length){s.push(`Line ${l+1}: Too many columns`);continue}if(a.length-c.length>3){s.push(`Line ${l+1}: Column count mismatch (expected ${a.length}, got ${c.length})`);continue}for(;c.length<a.length;)c.push("");let n={};a.forEach((u,y)=>{n[u]=c[y]||"";});let m=n.Column||"Unnamed";o.has(m)||o.set(m,{id:`col-${o.size+1}`,title:m,position:o.size+1,cardIds:[]});let d=o.get(m),i={id:n["Card ID"]||`card-${l}`,title:n.Title||"Untitled",description:n.Description?n.Description:void 0,columnId:d.id,position:d.cardIds.length+1,priority:n.Priority||void 0,labels:n.Labels?n.Labels.split(";").filter(Boolean):void 0,assignedUserIds:n["Assigned Users"]?n["Assigned Users"].split(";").filter(Boolean):void 0,startDate:n["Start Date"]?n["Start Date"]:void 0,endDate:n["End Date"]?n["End Date"]:void 0,createdAt:n["Created At"]?n["Created At"]:void 0,updatedAt:n["Updated At"]?n["Updated At"]:void 0};r.push(i),d.cardIds.push(i.id);}catch(c){s.push(`Line ${l+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 Gi(e){let t=[],a="",r=false;for(let o=0;o<e.length;o++){let s=e[o],l=e[o+1];s==='"'&&r&&l==='"'?(a+='"',o++):s==='"'?r=!r:s===","&&!r?(t.push(a),a=""):a+=s;}return t.push(a),t}function _i(e,t){switch(t){case "json":return gp(e);case "csv":return fp(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Vi(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 Rn=createContext(null);function ji(){return useContext(Rn)}var Ki=createContext(null);function Yi({children:e,themeName:t}){return jsx(Ki.Provider,{value:{themeName:t},children:e})}function Mr(){return useContext(Ki)}function tt({children:e,container:t}){let[a,r]=useState(false),o=ji(),s=Mr();if(useEffect(()=>(r(true),()=>r(false)),[]),!a)return null;let l=t||(typeof document<"u"?document.body:null);if(!l)return null;if(o){let{theme:c,themeName:p}=o,n={"--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:n,children:e}),l)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),l):createPortal(e,l)}var Qi={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},Cp="#BDC3C7",Tp=({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 cr({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,l]=useState({top:0,left:0}),c=useRef(null),p=useRef(null),n=()=>{if(!p.current)return;let u=p.current.getBoundingClientRect(),y=window.innerHeight,f=window.innerWidth,g=160,x=220,b=4,h=u.right-g;h<10&&(h=u.left),h+g>f-10&&(h=f-g-10);let w=y-u.bottom,D=u.top,N;w>=x+b?N=u.bottom+b:D>=x+b?N=u.top-x-b:N=w>=D?u.bottom+b:Math.max(10,u.top-x-b),l({top:N,left:h}),o(true);};useEffect(()=>{let u=y=>{c.current&&!c.current.contains(y.target)&&!p.current?.contains(y.target)&&o(false);};if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),useEffect(()=>{let u=y=>{y.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);let m=u=>{t(u),o(false);},d=e?Qi[e]:null,i=d?.color||Cp;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:p,onClick:()=>r?o(false):n(),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(tt,{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(Qi).map(([u,y])=>jsxs("button",{onClick:()=>m(u),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: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(Tp,{color:y.color}),jsx("span",{className:"font-semibold text-sm",children:y.label}),e===u&&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"})})]},u)),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:()=>m(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:u=>{u.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:u=>{u.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 Dp=[{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 Zr({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[l,c]=useState({top:0,left:0}),p=useRef(null),n=useRef(null),i=(Mr()?.themeName||"dark")==="dark",u=()=>{if(!n.current)return;let h=n.current.getBoundingClientRect(),w=window.innerHeight,D=window.innerWidth,N=320,M=380,v=4,L=h.left;L+N>D-10&&(L=D-N-10),L<10&&(L=10);let T=w-h.bottom,k=h.top,F;T>=M+v?F=h.bottom+v:k>=M+v?F=h.top-M-v:F=T>=k?h.bottom+v:Math.max(10,h.top-M-v),c({top:F,left:L}),s(true);};useEffect(()=>{let h=w=>{p.current&&!p.current.contains(w.target)&&!n.current?.contains(w.target)&&s(false);};if(o)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o]),useEffect(()=>{let h=w=>{w.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[o]);let y=h=>{let w=new Date,D=L=>{let T=L.getFullYear(),k=String(L.getMonth()+1).padStart(2,"0"),F=String(L.getDate()).padStart(2,"0");return `${T}-${k}-${F}`},N=D(w),M=new Date(w);M.setDate(M.getDate()+h);let v=D(M);a(N,v),s(false);},f=()=>{if(!e||!t)return "Set date";let h=M=>{if(M instanceof Date)return M;if(typeof M!="string"||!M.match(/^\d{4}-\d{2}-\d{2}$/))return null;let v=M.split("-").map(Number);if(v.length!==3||v.some(F=>isNaN(F)))return null;let L=v[0],T=v[1],k=v[2];return L===void 0||T===void 0||k===void 0?null:new Date(L,T-1,k)},w=h(e),D=h(t);if(!w||!D||isNaN(w.getTime())||isNaN(D.getTime()))return "Set date";let N=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${N[w.getMonth()]} ${w.getDate()} \u2013 ${N[D.getMonth()]} ${D.getDate()}`},g=e&&t,b=(()=>{if(!t)return false;let h=typeof t=="string"?new Date(t):t,w=new Date;return w.setHours(0,0,0,0),h<w})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:n,onClick:()=>o?s(false):u(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${b?"asakaa-date-overdue":"asakaa-date"}`,title:g?`${f()}`:"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:f()})]}),o&&jsx(tt,{children:jsxs("div",{ref:p,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${l.top}px`,left:`${l.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:Dp.map(h=>jsx("button",{onClick:()=>y(h.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:w=>{w.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",w.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:w=>{w.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",w.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:h.label},h.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:h=>a(h.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:h=>a(e,h.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:h=>{h.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function mr({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,l]=useState(false),[c,p]=useState(""),[n,m]=useState({top:0,left:0}),d=useRef(null),i=useRef(null),u=()=>{if(!i.current)return;let b=i.current.getBoundingClientRect(),h=window.innerHeight,w=window.innerWidth,D=300,N=380,M=4,v=b.right-D;v<10&&(v=b.left),v+D>w-10&&(v=w-D-10);let L=h-b.bottom,T=b.top,k;L>=N+M?k=b.bottom+M:T>=N+M?k=b.top-N-M:k=L>=T?b.bottom+M:Math.max(10,b.top-N-M),m({top:k,left:v}),l(true);};useEffect(()=>{let b=h=>{d.current&&!d.current.contains(h.target)&&!i.current?.contains(h.target)&&(l(false),p(""));};if(s)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),useEffect(()=>{let b=h=>{h.key==="Escape"&&(l(false),p(""));};if(s)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s]);let y=b=>{let h=e.some(w=>w.id===b.id);a(h?e.filter(w=>w.id!==b.id):[...e,b]);},f=t.filter(b=>b.name.toLowerCase().includes(c.toLowerCase())),g=e.slice(0,o),x=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:i,onClick:()=>s?l(false):u(),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:[g.map(b=>jsx("div",{className:"asakaa-avatar",title:b.name,children:b.avatar?jsx("img",{src:b.avatar,alt:b.name,className:"asakaa-avatar-img"}):b.initials},b.id)),x>0&&jsxs("div",{className:"asakaa-avatar",children:["+",x]})]}):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(tt,{children:jsxs("div",{ref:d,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.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:b=>p(b.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:f.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"}):f.map(b=>{let h=e.some(w=>w.id===b.id);return jsxs("button",{onClick:()=>y(b),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:w=>{w.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:w=>{w.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:b.color,color:"#fff"},children:b.avatar?jsx("img",{src:b.avatar,alt:b.name,className:"w-full h-full rounded-full object-cover"}):b.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:b.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:h?"#3b82f6":"transparent"},children:h?"\u2713":""})]},b.id)})}),e.length>0&&jsx("div",{className:"px-3 py-3 border-t border-white/10",children:jsx("button",{onClick:()=>{a([]),l(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 Fo(e,t,a){let r=new Map;e.forEach(p=>{if(p.dependencies&&Array.isArray(p.dependencies)){let n=p.dependencies.map(m=>{if(typeof m=="string")return m;let d=m;return d.taskId||d.targetId||""}).filter(Boolean);r.set(p.id,n);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,l=new Set,c=p=>{if(!s.has(p)){s.add(p),l.add(p);let n=r.get(p)||[];for(let m of n){if(!s.has(m)&&c(m))return true;if(l.has(m))return true}}return l.delete(p),false};return c(a)}function eo({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:l}){let[c,p]=useState(false),[n,m]=useState(""),[d,i]=useState(t.length>0),[u,y]=useState({top:0,left:0}),[f,g]=useState(null),x=useRef(null),b=useRef(null),h=()=>{if(!b.current)return;let v=b.current.getBoundingClientRect(),L=window.innerHeight,T=window.innerWidth,k=300,F=d?380:120,P=4,H=v.right-k;H<10&&(H=v.left),H+k>T-10&&(H=T-k-10);let X=L-v.bottom,ye=v.top,we;X>=F+P?we=v.bottom+P:ye>=F+P?we=v.top-F-P:we=X>=ye?v.bottom+P:Math.max(10,v.top-F-P),y({top:we,left:H}),p(true);};useEffect(()=>{if(!c||!b.current)return;let v=b.current.getBoundingClientRect(),L=window.innerHeight,T=window.innerWidth,k=300,F=d?380:120,P=4,H=v.right-k;H<10&&(H=v.left),H+k>T-10&&(H=T-k-10);let X=L-v.bottom,ye=v.top,we;X>=F+P?we=v.bottom+P:ye>=F+P?we=v.top-F-P:we=X>=ye?v.bottom+P:Math.max(10,v.top-F-P),y({top:we,left:H});},[d,c]),useEffect(()=>{let v=L=>{x.current&&!x.current.contains(L.target)&&!b.current?.contains(L.target)&&(p(false),m(""));};if(c)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]),useEffect(()=>{let v=L=>{L.key==="Escape"&&(p(false),m(""));};if(c)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[c]);let w=v=>{let L=t.includes(v),T=a.find(k=>k.id===v);if(g(null),L){let k=t.filter(F=>F!==v);r(k),k.length===0&&i(false);}else {if(s&&Fo(a,v,e)){let F=`Cannot add "${T?.title||v}" as dependency - would create circular reference`;g(F),l?.(v,T?.title||v),setTimeout(()=>g(null),3e3);return}r([...t,v]),i(true);}},D=()=>{let v=!d;i(v),v||r([]);},N=a.filter(v=>v.id!==e).filter(v=>v.title.toLowerCase().includes(n.toLowerCase())||v.id.toLowerCase().includes(n.toLowerCase())),M=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:b,onClick:()=>c?p(false):h(),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:M,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:M},children:t.length})]}),c&&jsx(tt,{children:jsxs("div",{ref:x,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${u.top}px`,left:`${u.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:[f&&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:f})]}),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:D,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:n,onChange:v=>m(v.target.value),placeholder:"Search by name or ID...",className:"w-full px-3 py-2 rounded-md text-xs border outline-none transition-all",style:{background:"var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))",borderColor:"var(--modal-v2-border, rgba(255, 255, 255, 0.1))",color:"var(--modal-v2-text-primary, #ffffff)"},autoFocus:true})}),jsx("div",{className:"py-2 max-h-[280px] overflow-y-auto",children:N.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"}):N.map(v=>{let L=t.includes(v.id);return jsxs("button",{onClick:()=>w(v.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:T=>{T.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:T=>{T.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:L?"#3b82f6":"transparent",borderColor:L?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:L&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxs("div",{className:"flex-1 text-left",children:[jsx("div",{className:"font-medium",style:{color:"var(--modal-v2-text-primary, rgba(255, 255, 255, 0.9))"},children:v.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:v.id})]})]},v.id)})})]}),t.length>0&&jsx("div",{className:"px-3 py-2 border-t border-white/5",children:jsx("button",{onClick:()=>{r([]),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 Ga=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:l,availableUsers:c=[],allCards:p=[]})=>{let{attributes:n,listeners:m,setNodeRef:d,transform:i,transition:u,isDragging:y}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),f={transform:Mo.Transform.toString(i),transition:u};if(t)return jsx("div",{ref:d,style:f,...n,...m,onClick:()=>a?.(e),children:t(e)});let g=c.filter(h=>e.assignedUserIds?.includes(h.id)),x=e.progress===100,b={...f,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:d,style:b,className:C("asakaa-card",y&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...n,...m,onClick:h=>{h.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:h=>{h.currentTarget.style.display="none";}})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:x?"line-through":"none",opacity:x?.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:h=>h.stopPropagation(),className:"priority-selector",children:jsx(cr,{priority:e.priority,onChange:h=>l?.(e.id,{priority:h})})}),jsx("div",{onClick:h=>h.stopPropagation(),className:"date-picker",children:jsx(Zr,{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:(h,w)=>l?.(e.id,{startDate:h,endDate:w})})}),c.length>0&&jsx("div",{onClick:h=>h.stopPropagation(),className:"user-selector",children:jsx(mr,{assignedUsers:g,availableUsers:c,onChange:h=>l?.(e.id,{assignedUserIds:h.map(w=>w.id)})})}),jsx("div",{onClick:h=>h.stopPropagation(),className:"dependencies-selector",children:jsx(eo,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(h=>typeof h=="string"?h:h.taskId):[],availableTasks:p,onChange:h=>l?.(e.id,{dependencies:h})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(h=>jsx("span",{className:"asakaa-label",children:h},h))}),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));Ga.displayName="Card";var Bo={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"}},dl=({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 cl({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[l,c]=useState({top:0,left:0}),p=useRef(null),n=useRef(null),m=[...Object.entries(Bo).map(([g,x])=>({id:g,label:x.label,color:x.color,icon:x.icon})),...r.filter(g=>!Object.keys(Bo).includes(g.id)).map(g=>({id:g.id,label:g.title,color:g.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let g=Bo[e];if(g)return {...g,id:e};let x=r.find(b=>b.id===e);return x?{id:x.id,label:x.title,color:x.color||"#8B5CF6",icon:"circle-dot"}:{...Bo.todo,id:"todo"}},i=()=>{if(!n.current)return;let g=n.current.getBoundingClientRect(),x=window.innerHeight,b=window.innerWidth,h=180,w=280,D=4,N=g.right-h;N<10&&(N=g.left),N+h>b-10&&(N=b-h-10);let M=x-g.bottom,v=g.top,L;M>=w+D?L=g.bottom+D:v>=w+D?L=g.top-w-D:L=M>=v?g.bottom+D:Math.max(10,g.top-w-D),c({top:L,left:N}),s(true);};useEffect(()=>{let g=x=>{p.current&&!p.current.contains(x.target)&&!n.current?.contains(x.target)&&s(false);};if(o)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[o]),useEffect(()=>{let g=x=>{x.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[o]);let u=g=>{t(g),s(false);},y=d(),f=y.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:n,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:`${f}10`,boxShadow:`0 0 0 2px ${f}30 inset`},title:y.label,children:jsx(dl,{icon:y.icon,color:f})}),o&&jsx(tt,{children:jsxs("div",{ref:p,className:"status-selector-menu",style:{position:"fixed",top:`${l.top}px`,left:`${l.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:m.map(g=>jsxs("button",{onClick:()=>u(g.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:g.color,background:"transparent"},onMouseEnter:x=>{x.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:x=>{x.currentTarget.style.background="transparent";},children:[jsx(dl,{icon:g.icon,color:g.color}),jsx("span",{className:"font-semibold",children:g.label}),e===g.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"})})]},g.id))})]})})]})}function pl({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,l]=useState(false),[c,p]=useState(false),[n,m]=useState(e),[d,i]=useState({top:0,left:0}),u=useRef(null),y=useRef(null),f=useRef(null);useEffect(()=>{if(s&&y.current){let h=y.current.getBoundingClientRect();i({top:h.bottom+window.scrollY+8,left:h.left+window.scrollX});}},[s]),useEffect(()=>{let h=w=>{u.current&&!u.current.contains(w.target)&&!y.current?.contains(w.target)&&(l(false),p(false));};if(s)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]),useEffect(()=>{let h=w=>{w.key==="Escape"&&(l(false),p(false),m(e));};if(s)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[s,e]),useEffect(()=>{c&&f.current&&(f.current.focus(),f.current.select());},[c]);let g=()=>{p(true),m(e);},x=()=>{let h=n.trim();h&&h!==e&&t(h),p(false),l(false),m(e);},b=h=>{h.key==="Enter"?x():h.key==="Escape"&&(p(false),m(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:y,onClick:()=>l(!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(tt,{children:jsx("div",{ref:u,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:f,type:"text",value:n,onChange:h=>m(h.target.value),onKeyDown:b,onBlur:x,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:g,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(),l(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 Lr=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:l,onCardUpdate:c,availableUsers:p,allCards:n,enableVirtualization:m,cardHeight:d=120,isCollapsed:i,onToggleCollapse:u,onColumnRename:y,onColumnDelete:f,isDeletable:g=false,className:x})=>{let{setNodeRef:b,isOver:h}=useDroppable({id:e.id,data:{type:"column",column:e}}),w=useRef(null),D=m??Oi(t.length),N=useVirtualizer({count:t.length,getScrollElement:()=>w.current,estimateSize:()=>d,enabled:D});if(a)return jsx("div",{ref:b,className:x,children:a(e,t)});let v=(()=>{if(!e.wipLimit)return {state:"none",percentage:0};let k=t.length/e.wipLimit*100;return t.length>e.wipLimit?{state:"exceeded",percentage:k}:k>=80?{state:"warning",percentage:k}:k>=60?{state:"approaching",percentage:k}:{state:"ok",percentage:k}})(),L=v.state==="exceeded",T=()=>"asakaa-column-count";return jsxs("div",{ref:b,className:C("asakaa-column",h&&"ring-2 ring-asakaa-accent-blue",L&&"ring-2 ring-asakaa-accent-red",x),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:C(T()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&v.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${v.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[v.state==="exceeded"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#EF4444",opacity:"0.9"}),jsx("path",{d:"M5 5L11 11M11 5L5 11",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}),v.state==="warning"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("path",{d:"M8 1L15 14H1L8 1Z",fill:"#F59E0B",opacity:"0.9"}),jsx("path",{d:"M8 6V9M8 11V11.5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"})]}),v.state==="approaching"&&jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M8 1L10 7H14L10 10L12 16L8 12L4 16L6 10L2 7H6L8 1Z",fill:"#FB923C",opacity:"0.9"})}),v.state==="ok"&&jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"7",fill:"#10B981",opacity:"0.9"}),jsx("path",{d:"M5 8L7 10L11 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]}),(y||f)&&jsx(pl,{columnTitle:e.title,onRename:k=>y?.(e.id,k),onDelete:f?()=>f(e.id):void 0,isDeletable:g}),u&&jsx("button",{onClick:u,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:w,className:"asakaa-column-cards",style:{maxHeight:D?"600px":void 0},children:jsx(SortableContext,{items:t.map(k=>k.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"})}):D?jsx("div",{style:{height:`${N.getTotalSize()}px`,position:"relative"},children:N.getVirtualItems().map(k=>{let F=t[k.index];return F?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${k.start}px)`},children:jsx(Ga,{card:F,render:r,onClick:l,onUpdate:c,availableUsers:p,allCards:n})},F.id):null})}):t.map(k=>jsx(Ga,{card:k,render:r,onClick:l,onUpdate:c,availableUsers:p,allCards:n},k.id))})})]})});Lr.displayName="Column";function Wn({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,l]=useState(e),c=useRef(null);useEffect(()=>{r&&c.current&&(c.current.focus(),c.current.select());},[r]);let p=()=>{let m=s.trim();m&&m!==e?t(m):l(e),o(false);},n=m=>{m.key==="Enter"?p():m.key==="Escape"&&(l(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:m=>l(m.target.value),onBlur:p,onKeyDown:n,className:C("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:C("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}function Gn(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function Qa({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:l,style:c,isLoading:p,error:n,children:m}){let[d,i]=Gn(),u=o?.theme||"dark",f=u==="dark"||u==="neutral"?"dark":"",g=useCallback((T,k)=>{t.onCardUpdate?.(T,k);},[t]),x=useCallback((T,k)=>{t.onColumnUpdate?.(T,{title:k});},[t]),b=useCallback(T=>{t.onColumnDelete?.(T);},[t]),h=["todo","in-progress","completed"],w=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),D=useMemo(()=>{let T=new Map;return e.columns.forEach(k=>{let F=k.cardIds.map(P=>e.cards.find(H=>H.id===P)).filter(P=>P!==void 0).sort((P,H)=>P.position-H.position);T.set(k.id,F);}),T},[e.cards,e.columns]),N=useCallback(T=>{let{active:k}=T,F=e.cards.find(P=>P.id===k.id);F&&i({isDragging:true,draggedCardId:F.id,sourceColumnId:F.columnId,targetColumnId:F.columnId});},[e.cards,i]),M=useCallback(T=>{let{active:k,over:F}=T;if(!F||!e.cards.find(X=>X.id===k.id))return;let H=null;F.data.current?.type==="column"?H=F.id:F.data.current?.type==="card"&&(H=e.cards.find(ye=>ye.id===F.id)?.columnId||null),H&&H!==d.targetColumnId&&i({...d,targetColumnId:H});},[e.cards,d,i]),v=useCallback(async T=>{let{active:k,over:F}=T;if(i({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!F)return;let P=e.cards.find(we=>we.id===k.id);if(!P)return;let H,X;if(F.data.current?.type==="column"){H=F.id;let we=D.get(H)||[];X=In(we,0);}else {let we=e.cards.find(O=>O.id===F.id);if(!we)return;H=we.columnId;let Ie=D.get(H)||[],Le=Ie.findIndex(O=>O.id===F.id);X=In(Ie,Le);}let ye=e.columns.find(we=>we.id===H);if(ye&&ye.wipLimit&&ye.wipLimitType==="hard"){let we=D.get(H)||[];if(P.columnId!==H&&we.length>=ye.wipLimit){t.onWipLimitExceeded?.(ye,P);return}}(P.columnId!==H||P.position!==X)&&await t.onCardMove?.(P.id,H,X);},[e.cards,e.columns,D,t,i]),L=useCallback(T=>{a?.(T);},[a]);return p?jsx("div",{className:C("asakaa-board",f,l),style:c,children:jsx(qp,{columnCount:3})}):n?jsx("div",{className:C("asakaa-board",f,l),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 n=="string"?n:n.message})]})})}):jsx(Yi,{themeName:u,children:jsxs(DndContext,{sensors:w,collisionDetection:closestCorners,onDragStart:N,onDragOver:M,onDragEnd:v,children:[jsxs("div",{className:C("asakaa-board",f,l),style:c,"data-theme":u,children:[e.columns.sort((T,k)=>T.position-k.position).map(T=>{let k=D.get(T.id)||[],F=!h.includes(T.id);return jsx(Lr,{column:T,cards:k,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:L,onCardUpdate:g,onColumnRename:x,onColumnDelete:b,isDeletable:F,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},T.id)}),m]}),jsx(DragOverlay,{children:d.draggedCardId?jsx(Ga,{card:e.cards.find(T=>T.id===d.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]})})}function qp({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 em={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)"},tm={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)"},am={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},rm={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function om({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,l]=useState(false),c=useRef(null);useEffect(()=>{let n=m=>{c.current&&!c.current.contains(m.target)&&l(false);};return s&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[s]);let p=n=>{t(n),l(false);};return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:()=>l(!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((n,m)=>n.position-m.position).map((n,m)=>jsxs(motion.button,{onClick:()=>p(n.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:m<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n.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:n.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[n.cardIds.length," ",n.cardIds.length===1?"tarea":"tareas"]})]})]},n.id))]})})})]})}function nm({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,l]=useState(false),[c,p]=useState(null),n=useRef(null);if(useEffect(()=>{let u=y=>{n.current&&!n.current.contains(y.target)&&l(false);};return s&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[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(u=>u.handler),i=async(u,y)=>{if(y){p(u);try{await y();}catch(f){console.error(`Export ${u} failed:`,f);}finally{p(null),l(false);}}};return jsxs("div",{ref:n,className:"relative",children:[jsxs(motion.button,{onClick:()=>l(!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((u,y)=>jsxs(motion.button,{onClick:()=>i(u.id,u.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:y<d.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:y*.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===u.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):u.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:u.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:u.description})]})]},u.id))})})})]})}function sm({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 Vn({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:l,onExportJSON:c,onExportExcel:p,translations:n}){let m=r==="dark"?em:tm,d={...o==="es"?am:rm,...n},i=l||c||p;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:m.bgGrid,borderColor:m.border},children:jsxs("div",{className:"flex items-center gap-3",children:[i&&jsxs(Fragment,{children:[jsx(nm,{theme:m,t:d,onExportCSV:l,onExportJSON:c,onExportExcel:p}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:m.borderLight}})]}),t&&(s?jsx(om,{columns:e,onSelect:t,theme:m,t:d,createTaskLabel:a}):jsx(sm,{onClick:()=>t(),label:a||d.newTask}))]})})}function Kn({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,l]=useState(false),[c,p]=useState(""),n=useCallback(()=>{let i=c.trim();i&&(e(i),p(""),l(false));},[c,e]),m=useCallback(i=>{i.key==="Enter"?(i.preventDefault(),n()):i.key==="Escape"&&(p(""),l(false));},[n]),d=useCallback(()=>{setTimeout(()=>{c.trim()||l(false);},150);},[c]);return s?jsx("div",{className:C("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:m,onBlur:d,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:n,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(""),l(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:C("asakaa-add-column",t),children:jsxs("button",{onClick:()=>l(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 Yn({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:l=false,theme:c="dark",locale:p="es"}){let[n,m]=useState(false),[d,i]=useState(false),[u,y]=useState(""),[f,g]=useState([]),[x,b]=useState(""),[h,w]=useState(""),[D,N]=useState(""),[M,v]=useState(false),[L,T]=useState(false),[k,F]=useState(false),P=useRef(null),H=useRef(null),X={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"},ye=useCallback(()=>{y(""),g([]),b(""),w(""),N(""),v(false),T(false),F(false),m(false);},[]);useEffect(()=>{n&&P.current&&P.current.focus();},[n]),useEffect(()=>{if(!n)return;let B=W=>{H.current&&!H.current.contains(W.target)&&(u.trim()||ye());};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[n,u,ye]);let we=useCallback(async()=>{let B=u.trim();if(!(!B||d)){i(true);try{await t({name:B,columnId:e,assigneeIds:f.length>0?f:void 0,startDate:x?new Date(x):void 0,endDate:h?new Date(h):void 0,priority:D||void 0}),y(""),g([]),b(""),w(""),N(""),v(!1),T(!1),F(!1),P.current?.focus();}catch(W){console.error("Error creating card:",W);}finally{i(false);}}},[u,e,f,x,h,D,t,d]),Ie=useCallback(B=>{B.key==="Enter"&&!B.shiftKey?(B.preventDefault(),we()):B.key==="Escape"&&ye();},[we,ye]),Le=useCallback(B=>{g(W=>W.includes(B)?W.filter(S=>S!==B):[...W,B]);},[]),O=c==="dark";return n?jsxs("div",{ref:H,className:C("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:P,type:"text",value:u,onChange:B=>y(B.target.value),onKeyDown:Ie,placeholder:X.placeholder,disabled:d,className:C("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:()=>v(!M),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",M||f.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:X.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"})]}),f.length>0&&jsx("span",{className:"ml-0.5",children:f.length})]}),jsx("button",{onClick:()=>T(!L),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",L||x||h?"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:X.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:()=>F(!k),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",k||D?D==="urgent"?"bg-red-500/20 text-red-400":D==="high"?"bg-orange-500/20 text-orange-400":D==="medium"?"bg-yellow-500/20 text-yellow-400":D==="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:X.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:we,disabled:!u.trim()||d,className:C("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"}):X.save})]})]}),M&&a.length>0&&jsx("div",{className:C("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(B=>jsxs("button",{onClick:()=>Le(B.id),className:C("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",f.includes(B.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:[B.avatar?jsx("img",{src:B.avatar,alt:B.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:C("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",f.includes(B.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:B.name.charAt(0).toUpperCase()}),jsx("span",{children:B.name.split(" ")[0]})]},B.id))})}),L&&jsx("div",{className:C("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:C("block text-[10px] uppercase tracking-wide mb-1",O?"text-gray-500":"text-gray-400"),children:X.startDate}),jsx("input",{type:"date",value:x,onChange:B=>b(B.target.value),className:C("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:C("block text-[10px] uppercase tracking-wide mb-1",O?"text-gray-500":"text-gray-400"),children:X.endDate}),jsx("input",{type:"date",value:h,onChange:B=>w(B.target.value),className:C("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")})]})]})}),k&&jsx("div",{className:C("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(B=>jsx("button",{onClick:()=>N(D===B?"":B),className:C("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",D===B?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[B]} text-white`:O?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:X[B]},B))})})]}):jsxs("button",{onClick:()=>m(true),disabled:l,className:C("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",l&&"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:X.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(Qa,{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(l=>{l?o(l):s(new Error("Failed to create PNG blob"));},"image/png");})}};function Tl(e={}){return new no(e)}var Fr=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(l){console.error("Error in error handler:",l);}}render(){let{hasError:a,error:r}=this.state,{children:o,fallback:s,componentName:l}=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:l?`Error in ${l}`:"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 qn(e,t){let a=r=>jsx(Fr,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Jn({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:l,onPredictRisks:c,onOpenAIUsage:p,shortcut:n="k",className:m=""}){let[d,i]=useState(false),[u,y]=useState(""),[f,g]=useState("home"),[x,b]=useState(""),[h,w]=useState("");useEffect(()=>{let v=L=>{(L.metaKey||L.ctrlKey)&&L.key===n&&(L.preventDefault(),i(T=>!T)),L.key==="Escape"&&(i(false),g("home"),y(""));};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n]),useEffect(()=>{d||(g("home"),y(""),b(""),w(""));},[d]);let D=useCallback(()=>{i(false);},[]),N=useCallback(v=>{let[L,T]=v.split(":");switch(L){case "create-card":g("create-card");break;case "create-card-in":b(T||"");break;case "navigate":T?(a?.(T),D()):g("navigate");break;case "search":r?.(u),D();break;case "priority":g("priority");break;case "set-priority":h&&T&&(o?.(h,T),D());break;case "assign":g("assign");break;case "assign-user":h&&T&&(s?.(h,T),D());break;case "ai":g("ai");break;case "ai-generate-plan":l?.(),D();break;case "ai-predict-risks":c?.(),D();break;case "ai-usage":p?.(),D();break;case "back":g("home");break;}},[u,h,t,a,r,o,s,l,c,p,D]),M=useCallback(()=>{x&&u.trim()&&(t?.(x,u.trim()),D());},[x,u,t,D]);return d?jsx(tt,{children:jsx("div",{className:"command-palette-overlay",onClick:D,children:jsx("div",{className:`command-palette ${m}`,onClick:v=>v.stopPropagation(),children:jsxs(Command,{value:u,onValueChange:y,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:f==="create-card"&&x?"Type card title and press Enter...":f==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:v=>{v.key==="Enter"&&f==="create-card"&&x&&M();}}),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."}),f==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:N,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:N,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:N,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:N,className:"command-palette-item command-palette-item-ai",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z"}),jsx("path",{d:"M2 17L12 22L22 17"}),jsx("path",{d:"M2 12L12 17L22 12"})]}),jsx("span",{children:"AI Commands"}),jsx("div",{className:"command-palette-item-badge",children:"AI"})]})}),jsx(Command.Group,{heading:"Cards",className:"command-palette-group",children:e.cards.slice(0,5).map(v=>jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:N,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:v.title}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(L=>jsx("span",{className:"command-palette-item-label",children:L},L))})]},v.id))})]}),f==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"Select Column",className:"command-palette-group",children:e.columns.map(v=>jsxs(Command.Item,{value:`create-card-in:${v.id}`,onSelect:N,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("rect",{x:"3",y:"3",width:"7",height:"18",rx:"1"})}),jsx("span",{children:v.title}),jsxs("div",{className:"command-palette-item-count",children:[v.cardIds.length," cards"]})]},v.id))})]}),f==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,className:"command-palette-item",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),jsx("span",{children:"Back"})]}),jsx(Command.Group,{heading:"All Cards",className:"command-palette-group",children:e.cards.map(v=>{let L=e.columns.find(T=>T.id===v.columnId);return jsxs(Command.Item,{value:`navigate:${v.id}`,onSelect:N,className:"command-palette-item",keywords:[v.title,v.description||"",...v.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:v.priority==="URGENT"?"#EF4444":v.priority==="HIGH"?"#F59E0B":v.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:v.title}),jsx("div",{className:"command-palette-item-meta",children:L?.title})]}),v.labels&&v.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:v.labels.slice(0,2).map(T=>jsx("span",{className:"command-palette-item-label",children:T},T))})]},v.id)})})]}),f==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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:N,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:N,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:N,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 Sl(e,t,a,r,o){let s=document.getElementById("attachment-lightbox-native");s&&s.remove();let l=document.createElement("div");l.id="attachment-lightbox-native",l.className="attachment-lightbox",l.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 Bd from'html2canvas';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';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,X,AlertCircle,CircleDot,ChevronDown,Check,Flag,Users,Calendar,ChevronLeft,Clock,Milestone,Rows3,FileImage,FileText,FileSpreadsheet,FileJson,FolderKanban,Download,GripVertical,Tag,List,Search,CalendarDays,User,Sparkles,Maximize2,MoreHorizontal,ListChecks,Upload,MessageSquare}from'lucide-react';import {AnimatePresence,motion}from'framer-motion';import {Command}from'cmdk';import Pm from'react-markdown';import Mm from'remark-gfm';import Am from'rehype-sanitize';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Line,AreaChart,Area,PieChart,Pie,Cell,BarChart,Bar}from'recharts';var So=(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 Eo=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 [Eo.Translate.toString(e),Eo.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:a,easing:r}=e;return t+" "+a+"ms "+r}}});function C(...e){return twMerge(clsx(e))}function Po(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 dp(e){return Array.from({length:e},(t,a)=>(a+1)*1e3)}function An(e,t){return e.length===0?1e3:t===0?Po(null,e[0].position):t>=e.length?Po(e[e.length-1].position,null):Po(e[t-1].position,e[t].position)}function Ui(e,t=100){return e>t}var cp=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 pp(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 Mo(e,t={}){let{maxAttempts:a=3,initialDelay:r=1e3,backoffMultiplier:o=2,maxDelay:s=1e4,shouldRetry:l=cp,onRetry:c}=t,p,n=0;for(let m=1;m<=a;m++){n=m;try{return {data:await e(),attempts:n,success:!0}}catch(d){if(p=d,m===a||!l(p,m))return {error:p,attempts:n,success:false};let u=pp(m,r,o,s);if(c)try{c(p,m,u);}catch(v){console.error("Error in retry callback:",v);}await new Promise(v=>setTimeout(v,u));}}return {error:p||new Error("Unknown error"),attempts:n,success:false}}function mp(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 up(e,t={}){return async(...a)=>Mo(()=>e(...a),t)}var In=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 Wi=(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))(Wi||{}),cr=class cr{constructor(t={}){this.defaultLogHandler=t=>{let{timestamp:a,level:r,message:o,component:s,...l}=t,c=`[${a}] [${r}] [${s}]`,p=Object.keys(l).length>0;switch(r){case "DEBUG":console.debug(c,o,p?l:"");break;case "INFO":console.info(c,o,p?l:"");break;case "WARN":console.warn(c,o,p?l:"");break;case "ERROR":console.error(c,o,p?l:""),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",...cr.globalOptions};}static configure(t){cr.globalOptions={...cr.globalOptions,...t};}child(t){return new cr({...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 Ao((a,r)=>{this.log(0,`${t} completed`,{...r,action:t,duration:a});},true):new Ao(()=>{},false)}log(t,a,r){if(!this.options.enabled||t<this.options.minLevel)return;let o={timestamp:new Date().toISOString(),level:Wi[t],message:a,component:this.options.componentName,...r};this.options.onLog(o);}};cr.globalOptions={};var Ln=cr,Ao=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}},Hi=new Ln;function fp(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 hp(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 l=e.columns.find(c=>c.id===s.columnId);return [s.id,Fn(s.title),Fn(s.description||""),Fn(l?.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 bp(e,t,a){let r=t;if(!r){let l=document.querySelector(".asakaa-board");l&&(r=l.parentElement||l);}if(r)try{let l=await Bd(r,{backgroundColor:"#0a0a0a",scale:1.5,logging:!1,useCORS:!0,allowTaint:!0,windowWidth:r.scrollWidth,windowHeight:r.scrollHeight}),c=l.toDataURL("image/png"),p=297,n=210,m=l.width/l.height,d=p-20,i=d/m;i>n-20&&(i=n-20,d=i*m);let u=new jsPDF({orientation:"landscape",unit:"mm",format:"a4"});u.setFontSize(16),u.setTextColor(255,255,255),u.setFillColor(10,10,10),u.rect(0,0,p,15,"F"),u.text(e.title||"Kanban Board",10,10);let v=(p-d)/2;return u.addImage(c,"PNG",v,20,d,i),u}catch(l){console.error("Error capturing board:",l);}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(l=>{let c=e.cards.filter(p=>p.columnId===l.id);s>250&&(o.addPage(),s=20),o.setFontSize(16),o.setFont("helvetica","bold"),o.text(l.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 m=o.splitTextToSize(p.description,160);o.text(m,25,s),s+=m.length*5;}let n=[];if(p.priority&&n.push(`Priority: ${p.priority}`),p.labels&&p.labels.length>0&&n.push(`Labels: ${p.labels.join(", ")}`),p.assignedUserIds&&p.assignedUserIds.length>0&&n.push(`Assigned: ${p.assignedUserIds.length} user(s)`),p.startDate||p.endDate){let m=[];p.startDate&&m.push(`Start: ${p.startDate}`),p.endDate&&m.push(`End: ${p.endDate}`),n.push(m.join(" \u2192 "));}n.length>0&&(o.setFontSize(8),o.setTextColor(100,100,100),o.text(n.join(" \u2022 "),25,s),o.setTextColor(0,0,0),s+=5),s+=5;}),s+=5;}),o}function Fn(e){return e.includes(",")||e.includes('"')||e.includes(`
3
+ `)?`"${e.replace(/"/g,'""')}"`:e}async function _i(e,t,a,r){switch(t){case "json":return fp(e,r);case "csv":return hp(e);case "pdf":return await bp(e,a);default:throw new Error(`Unsupported export format: ${t}`)}}function Vi(e,t,a){let r=`board-export-${new Date().getTime()}`;if(t==="pdf"&&typeof e=="object"&&e!==null&&"save"in e){let m=`${r}.pdf`;e.save(m);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]}`,l={json:"application/json",csv:"text/csv",pdf:"application/pdf"},c=new Blob([e],{type:l[t]}),p=URL.createObjectURL(c),n=document.createElement("a");n.href=p,n.download=s,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(p);}function yp(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 vp(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=ji(t[0]),r=[],o=new Map,s=[];for(let l=1;l<t.length;l++)try{let c=ji(t[l]||"");if(c.length>a.length){s.push(`Line ${l+1}: Too many columns`);continue}if(a.length-c.length>3){s.push(`Line ${l+1}: Column count mismatch (expected ${a.length}, got ${c.length})`);continue}for(;c.length<a.length;)c.push("");let n={};a.forEach((u,v)=>{n[u]=c[v]||"";});let m=n.Column||"Unnamed";o.has(m)||o.set(m,{id:`col-${o.size+1}`,title:m,position:o.size+1,cardIds:[]});let d=o.get(m),i={id:n["Card ID"]||`card-${l}`,title:n.Title||"Untitled",description:n.Description?n.Description:void 0,columnId:d.id,position:d.cardIds.length+1,priority:n.Priority||void 0,labels:n.Labels?n.Labels.split(";").filter(Boolean):void 0,assignedUserIds:n["Assigned Users"]?n["Assigned Users"].split(";").filter(Boolean):void 0,startDate:n["Start Date"]?n["Start Date"]:void 0,endDate:n["End Date"]?n["End Date"]:void 0,createdAt:n["Created At"]?n["Created At"]:void 0,updatedAt:n["Updated At"]?n["Updated At"]:void 0};r.push(i),d.cardIds.push(i.id);}catch(c){s.push(`Line ${l+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 ji(e){let t=[],a="",r=false;for(let o=0;o<e.length;o++){let s=e[o],l=e[o+1];s==='"'&&r&&l==='"'?(a+='"',o++):s==='"'?r=!r:s===","&&!r?(t.push(a),a=""):a+=s;}return t.push(a),t}function Ki(e,t){switch(t){case "json":return yp(e);case "csv":return vp(e);default:return {success:false,errors:[`Unsupported import format: ${t}`]}}}function Yi(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 Bn=createContext(null);function qi(){return useContext(Bn)}var Xi=createContext(null);function Ji({children:e,themeName:t}){return jsx(Xi.Provider,{value:{themeName:t},children:e})}function Lr(){return useContext(Xi)}function rt({children:e,container:t}){let[a,r]=useState(false),o=qi(),s=Lr();if(useEffect(()=>(r(true),()=>r(false)),[]),!a)return null;let l=t||(typeof document<"u"?document.body:null);if(!l)return null;if(o){let{theme:c,themeName:p}=o,n={"--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:n,children:e}),l)}return s?createPortal(jsx("div",{"data-theme":s.themeName,"data-kanban-portal":"true",children:e}),l):createPortal(e,l)}var al={URGENT:{label:"Urgent",color:"#E74C3C"},HIGH:{label:"High",color:"#E67E22"},MEDIUM:{label:"Normal",color:"#F1C40F"},LOW:{label:"Low",color:"#2ECC71"}},Sp="#BDC3C7",Ep=({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 pr({priority:e,onChange:t,className:a}){let[r,o]=useState(false),[s,l]=useState({top:0,left:0}),c=useRef(null),p=useRef(null),n=()=>{if(!p.current)return;let u=p.current.getBoundingClientRect(),v=window.innerHeight,f=window.innerWidth,g=160,x=220,b=4,h=u.right-g;h<10&&(h=u.left),h+g>f-10&&(h=f-g-10);let w=v-u.bottom,D=u.top,N;w>=x+b?N=u.bottom+b:D>=x+b?N=u.top-x-b:N=w>=D?u.bottom+b:Math.max(10,u.top-x-b),l({top:N,left:h}),o(true);};useEffect(()=>{let u=v=>{c.current&&!c.current.contains(v.target)&&!p.current?.contains(v.target)&&o(false);};if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),useEffect(()=>{let u=v=>{v.key==="Escape"&&o(false);};if(r)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);let m=u=>{t(u),o(false);},d=e?al[e]:null,i=d?.color||Sp;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:p,onClick:()=>r?o(false):n(),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(rt,{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(al).map(([u,v])=>jsxs("button",{onClick:()=>m(u),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:v.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(Ep,{color:v.color}),jsx("span",{className:"font-semibold text-sm",children:v.label}),e===u&&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"})})]},u)),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:()=>m(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:u=>{u.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:u=>{u.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 Pp=[{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 Zr({startDate:e,endDate:t,onChange:a,className:r}){let[o,s]=useState(false),[l,c]=useState({top:0,left:0}),p=useRef(null),n=useRef(null),i=(Lr()?.themeName||"dark")==="dark",u=()=>{if(!n.current)return;let h=n.current.getBoundingClientRect(),w=window.innerHeight,D=window.innerWidth,N=320,A=380,y=4,R=h.left;R+N>D-10&&(R=D-N-10),R<10&&(R=10);let T=w-h.bottom,k=h.top,B;T>=A+y?B=h.bottom+y:k>=A+y?B=h.top-A-y:B=T>=k?h.bottom+y:Math.max(10,h.top-A-y),c({top:B,left:R}),s(true);};useEffect(()=>{let h=w=>{p.current&&!p.current.contains(w.target)&&!n.current?.contains(w.target)&&s(false);};if(o)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o]),useEffect(()=>{let h=w=>{w.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[o]);let v=h=>{let w=new Date,D=R=>{let T=R.getFullYear(),k=String(R.getMonth()+1).padStart(2,"0"),B=String(R.getDate()).padStart(2,"0");return `${T}-${k}-${B}`},N=D(w),A=new Date(w);A.setDate(A.getDate()+h);let y=D(A);a(N,y),s(false);},f=()=>{if(!e||!t)return "Set date";let h=A=>{if(A instanceof Date)return A;if(typeof A!="string"||!A.match(/^\d{4}-\d{2}-\d{2}$/))return null;let y=A.split("-").map(Number);if(y.length!==3||y.some(B=>isNaN(B)))return null;let R=y[0],T=y[1],k=y[2];return R===void 0||T===void 0||k===void 0?null:new Date(R,T-1,k)},w=h(e),D=h(t);if(!w||!D||isNaN(w.getTime())||isNaN(D.getTime()))return "Set date";let N=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return `${N[w.getMonth()]} ${w.getDate()} \u2013 ${N[D.getMonth()]} ${D.getDate()}`},g=e&&t,b=(()=>{if(!t)return false;let h=typeof t=="string"?new Date(t):t,w=new Date;return w.setHours(0,0,0,0),h<w})();return jsxs("div",{className:`relative ${r||""}`,children:[jsxs("button",{ref:n,onClick:()=>o?s(false):u(),className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all hover:bg-white/5 ${b?"asakaa-date-overdue":"asakaa-date"}`,title:g?`${f()}`:"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:f()})]}),o&&jsx(rt,{children:jsxs("div",{ref:p,className:"date-picker-menu rounded-xl shadow-2xl border min-w-[320px]",style:{position:"fixed",top:`${l.top}px`,left:`${l.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:Pp.map(h=>jsx("button",{onClick:()=>v(h.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:w=>{w.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.1)",w.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.25)"}`;},onMouseLeave:w=>{w.currentTarget.style.backgroundColor=i?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.05)",w.currentTarget.style.border=`1px solid ${i?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.15)"}`;},children:h.label},h.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:h=>a(h.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:h=>a(e,h.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:h=>{h.currentTarget.style.background="rgba(239, 68, 68, 0.2)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(239, 68, 68, 0.1)";},children:"Clear Dates"})]})]})})]})}function ur({assignedUsers:e=[],availableUsers:t,onChange:a,className:r,maxVisibleAvatars:o=3}){let[s,l]=useState(false),[c,p]=useState(""),[n,m]=useState({top:0,left:0}),d=useRef(null),i=useRef(null),u=()=>{if(!i.current)return;let b=i.current.getBoundingClientRect(),h=window.innerHeight,w=window.innerWidth,D=300,N=380,A=4,y=b.right-D;y<10&&(y=b.left),y+D>w-10&&(y=w-D-10);let R=h-b.bottom,T=b.top,k;R>=N+A?k=b.bottom+A:T>=N+A?k=b.top-N-A:k=R>=T?b.bottom+A:Math.max(10,b.top-N-A),m({top:k,left:y}),l(true);};useEffect(()=>{let b=h=>{d.current&&!d.current.contains(h.target)&&!i.current?.contains(h.target)&&(l(false),p(""));};if(s)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),useEffect(()=>{let b=h=>{h.key==="Escape"&&(l(false),p(""));};if(s)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s]);let v=b=>{let h=e.some(w=>w.id===b.id);a(h?e.filter(w=>w.id!==b.id):[...e,b]);},f=t.filter(b=>b.name.toLowerCase().includes(c.toLowerCase())),g=e.slice(0,o),x=e.length-o;return jsxs("div",{className:`relative ${r||""}`,children:[jsx("button",{ref:i,onClick:()=>s?l(false):u(),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:[g.map(b=>jsx("div",{className:"asakaa-avatar",title:b.name,children:b.avatar?jsx("img",{src:b.avatar,alt:b.name,className:"asakaa-avatar-img"}):b.initials},b.id)),x>0&&jsxs("div",{className:"asakaa-avatar",children:["+",x]})]}):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(rt,{children:jsxs("div",{ref:d,className:"user-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${n.top}px`,left:`${n.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:b=>p(b.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:f.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"}):f.map(b=>{let h=e.some(w=>w.id===b.id);return jsxs("button",{onClick:()=>v(b),className:"w-full px-4 py-2.5 flex items-center gap-3 text-sm transition-all active:scale-98",style:{background:"transparent"},onMouseEnter:w=>{w.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.1))";},onMouseLeave:w=>{w.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:b.color,color:"#fff"},children:b.avatar?jsx("img",{src:b.avatar,alt:b.name,className:"w-full h-full rounded-full object-cover"}):b.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:b.name}),jsx("span",{className:"w-5 text-lg flex-shrink-0 text-right",style:{color:h?"#3b82f6":"transparent"},children:h?"\u2713":""})]},b.id)})}),e.length>0&&jsx("div",{className:"px-3 py-3 border-t border-white/10",children:jsx("button",{onClick:()=>{a([]),l(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 Io(e,t,a){let r=new Map;e.forEach(p=>{if(p.dependencies&&Array.isArray(p.dependencies)){let n=p.dependencies.map(m=>{if(typeof m=="string")return m;let d=m;return d.taskId||d.targetId||""}).filter(Boolean);r.set(p.id,n);}});let o=r.get(a)||[];r.set(a,[...o,t]);let s=new Set,l=new Set,c=p=>{if(!s.has(p)){s.add(p),l.add(p);let n=r.get(p)||[];for(let m of n){if(!s.has(m)&&c(m))return true;if(l.has(m))return true}}return l.delete(p),false};return c(a)}function eo({currentCardId:e,dependencies:t=[],availableTasks:a,onChange:r,className:o,validateCircular:s=true,onCircularDependencyError:l}){let[c,p]=useState(false),[n,m]=useState(""),[d,i]=useState(t.length>0),[u,v]=useState({top:0,left:0}),[f,g]=useState(null),x=useRef(null),b=useRef(null),h=()=>{if(!b.current)return;let y=b.current.getBoundingClientRect(),R=window.innerHeight,T=window.innerWidth,k=300,B=d?380:120,P=4,H=y.right-k;H<10&&(H=y.left),H+k>T-10&&(H=T-k-10);let X=R-y.bottom,be=y.top,ke;X>=B+P?ke=y.bottom+P:be>=B+P?ke=y.top-B-P:ke=X>=be?y.bottom+P:Math.max(10,y.top-B-P),v({top:ke,left:H}),p(true);};useEffect(()=>{if(!c||!b.current)return;let y=b.current.getBoundingClientRect(),R=window.innerHeight,T=window.innerWidth,k=300,B=d?380:120,P=4,H=y.right-k;H<10&&(H=y.left),H+k>T-10&&(H=T-k-10);let X=R-y.bottom,be=y.top,ke;X>=B+P?ke=y.bottom+P:be>=B+P?ke=y.top-B-P:ke=X>=be?y.bottom+P:Math.max(10,y.top-B-P),v({top:ke,left:H});},[d,c]),useEffect(()=>{let y=R=>{x.current&&!x.current.contains(R.target)&&!b.current?.contains(R.target)&&(p(false),m(""));};if(c)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[c]),useEffect(()=>{let y=R=>{R.key==="Escape"&&(p(false),m(""));};if(c)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[c]);let w=y=>{let R=t.includes(y),T=a.find(k=>k.id===y);if(g(null),R){let k=t.filter(B=>B!==y);r(k),k.length===0&&i(false);}else {if(s&&Io(a,y,e)){let B=`Cannot add "${T?.title||y}" as dependency - would create circular reference`;g(B),l?.(y,T?.title||y),setTimeout(()=>g(null),3e3);return}r([...t,y]),i(true);}},D=()=>{let y=!d;i(y),y||r([]);},N=a.filter(y=>y.id!==e).filter(y=>y.title.toLowerCase().includes(n.toLowerCase())||y.id.toLowerCase().includes(n.toLowerCase())),A=t.length>0?"#3B82F6":"#BDC3C7";return jsxs("div",{className:`relative ${o||""}`,children:[jsxs("button",{ref:b,onClick:()=>c?p(false):h(),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:A,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),t.length>0&&jsx("span",{className:"text-xs font-medium",style:{color:A},children:t.length})]}),c&&jsx(rt,{children:jsxs("div",{ref:x,className:"dependencies-selector-menu rounded-xl shadow-2xl border min-w-[300px]",style:{position:"fixed",top:`${u.top}px`,left:`${u.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:[f&&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:f})]}),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:D,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:n,onChange:y=>m(y.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:N.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"}):N.map(y=>{let R=t.includes(y.id);return jsxs("button",{onClick:()=>w(y.id),className:"w-full px-4 py-2 flex items-start gap-3 text-sm transition-colors",style:{background:"transparent"},onMouseEnter:T=>{T.currentTarget.style.background="var(--modal-v2-bg-secondary, rgba(255, 255, 255, 0.05))";},onMouseLeave:T=>{T.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:R?"#3b82f6":"transparent",borderColor:R?"#3b82f6":"var(--modal-v2-border, rgba(255, 255, 255, 0.3))"},children:R&&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:y.title}),jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--modal-v2-text-tertiary, rgba(255, 255, 255, 0.5))"},children:y.id})]})]},y.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 _a=memo(({card:e,render:t,onClick:a,isSelected:r,disableDrag:o,className:s,onUpdate:l,availableUsers:c=[],allCards:p=[]})=>{let{attributes:n,listeners:m,setNodeRef:d,transform:i,transition:u,isDragging:v}=useSortable({id:e.id,disabled:o,data:{type:"card",card:e}}),f={transform:Eo.Transform.toString(i),transition:u};if(t)return jsx("div",{ref:d,style:f,...n,...m,onClick:()=>a?.(e),children:t(e)});let g=c.filter(h=>e.assignedUserIds?.includes(h.id)),x=e.progress===100,b={...f,...e.color&&{borderTopWidth:"3px",borderTopStyle:"solid",borderTopColor:e.color}};return jsxs("div",{ref:d,style:b,className:C("asakaa-card",v&&"asakaa-card-dragging",r&&"ring-2 ring-asakaa-accent-blue",s),...n,...m,onClick:h=>{h.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:h=>{h.currentTarget.style.display="none";}})}),jsx("h3",{className:"asakaa-card-title mb-2",style:{textDecoration:x?"line-through":"none",opacity:x?.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:h=>h.stopPropagation(),className:"priority-selector",children:jsx(pr,{priority:e.priority,onChange:h=>l?.(e.id,{priority:h})})}),jsx("div",{onClick:h=>h.stopPropagation(),className:"date-picker",children:jsx(Zr,{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:(h,w)=>l?.(e.id,{startDate:h,endDate:w})})}),c.length>0&&jsx("div",{onClick:h=>h.stopPropagation(),className:"user-selector",children:jsx(ur,{assignedUsers:g,availableUsers:c,onChange:h=>l?.(e.id,{assignedUserIds:h.map(w=>w.id)})})}),jsx("div",{onClick:h=>h.stopPropagation(),className:"dependencies-selector",children:jsx(eo,{currentCardId:e.id,dependencies:Array.isArray(e.dependencies)?e.dependencies.map(h=>typeof h=="string"?h:h.taskId):[],availableTasks:p,onChange:h=>l?.(e.id,{dependencies:h})})})]}),e.labels&&e.labels.length>0&&jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.slice(0,3).map(h=>jsx("span",{className:"asakaa-label",children:h},h))}),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));_a.displayName="Card";var Lo={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"}},ml=({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 ul({status:e="todo",onChange:t,className:a,customStatuses:r=[]}){let[o,s]=useState(false),[l,c]=useState({top:0,left:0}),p=useRef(null),n=useRef(null),m=[...Object.entries(Lo).map(([g,x])=>({id:g,label:x.label,color:x.color,icon:x.icon})),...r.filter(g=>!Object.keys(Lo).includes(g.id)).map(g=>({id:g.id,label:g.title,color:g.color||"#8B5CF6",icon:"circle-dot"}))],d=()=>{let g=Lo[e];if(g)return {...g,id:e};let x=r.find(b=>b.id===e);return x?{id:x.id,label:x.title,color:x.color||"#8B5CF6",icon:"circle-dot"}:{...Lo.todo,id:"todo"}},i=()=>{if(!n.current)return;let g=n.current.getBoundingClientRect(),x=window.innerHeight,b=window.innerWidth,h=180,w=280,D=4,N=g.right-h;N<10&&(N=g.left),N+h>b-10&&(N=b-h-10);let A=x-g.bottom,y=g.top,R;A>=w+D?R=g.bottom+D:y>=w+D?R=g.top-w-D:R=A>=y?g.bottom+D:Math.max(10,g.top-w-D),c({top:R,left:N}),s(true);};useEffect(()=>{let g=x=>{p.current&&!p.current.contains(x.target)&&!n.current?.contains(x.target)&&s(false);};if(o)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[o]),useEffect(()=>{let g=x=>{x.key==="Escape"&&s(false);};if(o)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[o]);let u=g=>{t(g),s(false);},v=d(),f=v.color;return jsxs("div",{className:`relative ${a||""}`,children:[jsx("button",{ref:n,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:`${f}10`,boxShadow:`0 0 0 2px ${f}30 inset`},title:v.label,children:jsx(ml,{icon:v.icon,color:f})}),o&&jsx(rt,{children:jsxs("div",{ref:p,className:"status-selector-menu",style:{position:"fixed",top:`${l.top}px`,left:`${l.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:m.map(g=>jsxs("button",{onClick:()=>u(g.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:g.color,background:"transparent"},onMouseEnter:x=>{x.currentTarget.style.background="var(--modal-v2-bg-tertiary, rgba(255, 255, 255, 0.15))";},onMouseLeave:x=>{x.currentTarget.style.background="transparent";},children:[jsx(ml,{icon:g.icon,color:g.color}),jsx("span",{className:"font-semibold",children:g.label}),e===g.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"})})]},g.id))})]})})]})}function gl({columnTitle:e,onRename:t,onDelete:a,isDeletable:r=false,className:o}){let[s,l]=useState(false),[c,p]=useState(false),[n,m]=useState(e),[d,i]=useState({top:0,left:0}),u=useRef(null),v=useRef(null),f=useRef(null);useEffect(()=>{if(s&&v.current){let h=v.current.getBoundingClientRect();i({top:h.bottom+window.scrollY+8,left:h.left+window.scrollX});}},[s]),useEffect(()=>{let h=w=>{u.current&&!u.current.contains(w.target)&&!v.current?.contains(w.target)&&(l(false),p(false));};if(s)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]),useEffect(()=>{let h=w=>{w.key==="Escape"&&(l(false),p(false),m(e));};if(s)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[s,e]),useEffect(()=>{c&&f.current&&(f.current.focus(),f.current.select());},[c]);let g=()=>{p(true),m(e);},x=()=>{let h=n.trim();h&&h!==e&&t(h),p(false),l(false),m(e);},b=h=>{h.key==="Enter"?x():h.key==="Escape"&&(p(false),m(e));};return jsxs("div",{className:`relative ${o||""}`,children:[jsx("button",{ref:v,onClick:()=>l(!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(rt,{children:jsx("div",{ref:u,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:f,type:"text",value:n,onChange:h=>m(h.target.value),onKeyDown:b,onBlur:x,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:g,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(),l(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 Rr=memo(({column:e,cards:t,renderColumn:a,renderCard:r,renderHeader:o,renderEmptyState:s,onCardClick:l,onCardUpdate:c,availableUsers:p,allCards:n,enableVirtualization:m,cardHeight:d=120,isCollapsed:i,onToggleCollapse:u,onColumnRename:v,onColumnDelete:f,isDeletable:g=false,className:x})=>{let{setNodeRef:b,isOver:h}=useDroppable({id:e.id,data:{type:"column",column:e}}),w=useRef(null),D=m??Ui(t.length),N=useVirtualizer({count:t.length,getScrollElement:()=>w.current,estimateSize:()=>d,enabled:D});if(a)return jsx("div",{ref:b,className:x,children:a(e,t)});let y=(()=>{if(!e.wipLimit)return {state:"none",percentage:0};let k=t.length/e.wipLimit*100;return t.length>e.wipLimit?{state:"exceeded",percentage:k}:k>=80?{state:"warning",percentage:k}:k>=60?{state:"approaching",percentage:k}:{state:"ok",percentage:k}})(),R=y.state==="exceeded",T=()=>"asakaa-column-count";return jsxs("div",{ref:b,className:C("asakaa-column",h&&"ring-2 ring-asakaa-accent-blue",R&&"ring-2 ring-asakaa-accent-red",x),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:C(T()),children:[t.length,e.wipLimit&&` / ${e.wipLimit}`]}),e.wipLimit&&y.state!=="none"&&jsxs("span",{className:"text-xs font-medium flex items-center",title:`${y.percentage.toFixed(0)}% capacity${e.wipLimitType==="hard"?" (Hard limit - blocks new cards)":" (Soft limit - shows warning)"}`,children:[y.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"})]}),y.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"})]}),y.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"})}),y.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"})]})]}),(v||f)&&jsx(gl,{columnTitle:e.title,onRename:k=>v?.(e.id,k),onDelete:f?()=>f(e.id):void 0,isDeletable:g}),u&&jsx("button",{onClick:u,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:w,className:"asakaa-column-cards",style:{maxHeight:D?"600px":void 0},children:jsx(SortableContext,{items:t.map(k=>k.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"})}):D?jsx("div",{style:{height:`${N.getTotalSize()}px`,position:"relative"},children:N.getVirtualItems().map(k=>{let B=t[k.index];return B?jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${k.start}px)`},children:jsx(_a,{card:B,render:r,onClick:l,onUpdate:c,availableUsers:p,allCards:n})},B.id):null})}):t.map(k=>jsx(_a,{card:k,render:r,onClick:l,onUpdate:c,availableUsers:p,allCards:n},k.id))})})]})});Rr.displayName="Column";function Un({title:e,onSave:t,className:a}){let[r,o]=useState(false),[s,l]=useState(e),c=useRef(null);useEffect(()=>{r&&c.current&&(c.current.focus(),c.current.select());},[r]);let p=()=>{let m=s.trim();m&&m!==e?t(m):l(e),o(false);},n=m=>{m.key==="Enter"?p():m.key==="Escape"&&(l(e),o(false));};return r?jsx("input",{ref:c,type:"text",value:s,onChange:m=>l(m.target.value),onBlur:p,onKeyDown:n,className:C("asakaa-column-title bg-transparent border-b-2 border-blue-500","outline-none px-1 -ml-1",a),maxLength:50}):jsx("h2",{className:C("asakaa-column-title cursor-pointer",a),onClick:()=>o(true),title:"Click to edit",children:e})}function Hn(){let[e,t]=useState(()=>dragStore.getState());useEffect(()=>dragStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{dragStore.setState(r);},[]);return [e,a]}function er({board:e,callbacks:t,onCardClick:a,renderProps:r,config:o,availableUsers:s=[],className:l,style:c,isLoading:p,error:n,children:m}){let[d,i]=Hn(),u=o?.theme||"dark",f=u==="dark"||u==="neutral"?"dark":"",g=useCallback((T,k)=>{t.onCardUpdate?.(T,k);},[t]),x=useCallback((T,k)=>{t.onColumnUpdate?.(T,{title:k});},[t]),b=useCallback(T=>{t.onColumnDelete?.(T);},[t]),h=["todo","in-progress","completed"],w=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:8}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),D=useMemo(()=>{let T=new Map;return e.columns.forEach(k=>{let B=k.cardIds.map(P=>e.cards.find(H=>H.id===P)).filter(P=>P!==void 0).sort((P,H)=>P.position-H.position);T.set(k.id,B);}),T},[e.cards,e.columns]),N=useCallback(T=>{let{active:k}=T,B=e.cards.find(P=>P.id===k.id);B&&i({isDragging:true,draggedCardId:B.id,sourceColumnId:B.columnId,targetColumnId:B.columnId});},[e.cards,i]),A=useCallback(T=>{let{active:k,over:B}=T;if(!B||!e.cards.find(X=>X.id===k.id))return;let H=null;B.data.current?.type==="column"?H=B.id:B.data.current?.type==="card"&&(H=e.cards.find(be=>be.id===B.id)?.columnId||null),H&&H!==d.targetColumnId&&i({...d,targetColumnId:H});},[e.cards,d,i]),y=useCallback(async T=>{let{active:k,over:B}=T;if(i({isDragging:false,draggedCardId:null,sourceColumnId:null,targetColumnId:null}),!B)return;let P=e.cards.find(ke=>ke.id===k.id);if(!P)return;let H,X;if(B.data.current?.type==="column"){H=B.id;let ke=D.get(H)||[];X=An(ke,0);}else {let ke=e.cards.find(z=>z.id===B.id);if(!ke)return;H=ke.columnId;let Ae=D.get(H)||[],Fe=Ae.findIndex(z=>z.id===B.id);X=An(Ae,Fe);}let be=e.columns.find(ke=>ke.id===H);if(be&&be.wipLimit&&be.wipLimitType==="hard"){let ke=D.get(H)||[];if(P.columnId!==H&&ke.length>=be.wipLimit){t.onWipLimitExceeded?.(be,P);return}}(P.columnId!==H||P.position!==X)&&await t.onCardMove?.(P.id,H,X);},[e.cards,e.columns,D,t,i]),R=useCallback(T=>{a?.(T);},[a]);return p?jsx("div",{className:C("asakaa-board",f,l),style:c,children:jsx(Qp,{columnCount:3})}):n?jsx("div",{className:C("asakaa-board",f,l),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 n=="string"?n:n.message})]})})}):jsx(Ji,{themeName:u,children:jsxs(DndContext,{sensors:w,collisionDetection:closestCorners,onDragStart:N,onDragOver:A,onDragEnd:y,children:[jsxs("div",{className:C("asakaa-board",f,l),style:c,"data-theme":u,children:[e.columns.sort((T,k)=>T.position-k.position).map(T=>{let k=D.get(T.id)||[],B=!h.includes(T.id);return jsx(Rr,{column:T,cards:k,renderCard:r?.renderCard,renderColumn:r?.renderColumn,renderHeader:r?.renderColumnHeader,renderEmptyState:r?.renderEmptyState,onCardClick:R,onCardUpdate:g,onColumnRename:x,onColumnDelete:b,isDeletable:B,availableUsers:s,allCards:e.cards,enableVirtualization:o?.enableVirtualization,cardHeight:o?.cardHeight},T.id)}),m]}),jsx(DragOverlay,{children:d.draggedCardId?jsx(_a,{card:e.cards.find(T=>T.id===d.draggedCardId),render:r?.renderCardOverlay||r?.renderCard,disableDrag:true,className:"opacity-90 rotate-3 shadow-2xl"}):null})]})})}function Qp({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 om={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)"},nm={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)"},sm={newTask:"Nueva Tarea",selectColumn:"Seleccionar columna",export:"Exportar",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"},im={newTask:"New Task",selectColumn:"Select column",export:"Export",exportCSV:"CSV",exportJSON:"JSON",exportExcel:"Excel"};function lm({columns:e,onSelect:t,theme:a,t:r,createTaskLabel:o}){let[s,l]=useState(false),c=useRef(null);useEffect(()=>{let n=m=>{c.current&&!c.current.contains(m.target)&&l(false);};return s&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[s]);let p=n=>{t(n),l(false);};return jsxs("div",{ref:c,className:"relative",children:[jsxs(motion.button,{onClick:()=>l(!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((n,m)=>n.position-m.position).map((n,m)=>jsxs(motion.button,{onClick:()=>p(n.id),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:m<e.length-1?`1px solid ${a.borderLight}`:"none"},whileHover:{backgroundColor:a.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n.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:n.title}),jsxs("div",{className:"text-[10px] truncate",style:{color:a.textTertiary},children:[n.cardIds.length," ",n.cardIds.length===1?"tarea":"tareas"]})]})]},n.id))]})})})]})}function dm({theme:e,t,onExportCSV:a,onExportJSON:r,onExportExcel:o}){let[s,l]=useState(false),[c,p]=useState(null),n=useRef(null);if(useEffect(()=>{let u=v=>{n.current&&!n.current.contains(v.target)&&l(false);};return s&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[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(u=>u.handler),i=async(u,v)=>{if(v){p(u);try{await v();}catch(f){console.error(`Export ${u} failed:`,f);}finally{p(null),l(false);}}};return jsxs("div",{ref:n,className:"relative",children:[jsxs(motion.button,{onClick:()=>l(!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((u,v)=>jsxs(motion.button,{onClick:()=>i(u.id,u.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:v<d.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:v*.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===u.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):u.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:u.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:u.description})]})]},u.id))})})})]})}function cm({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 _n({columns:e,onCreateTask:t,createTaskLabel:a,theme:r="dark",locale:o="es",useColumnSelector:s=false,onExportCSV:l,onExportJSON:c,onExportExcel:p,translations:n}){let m=r==="dark"?om:nm,d={...o==="es"?sm:im,...n},i=l||c||p;return jsx("div",{className:"h-12 px-4 flex items-center justify-end border-b sticky top-0 z-10",style:{backgroundColor:m.bgGrid,borderColor:m.border},children:jsxs("div",{className:"flex items-center gap-3",children:[i&&jsxs(Fragment,{children:[jsx(dm,{theme:m,t:d,onExportCSV:l,onExportJSON:c,onExportExcel:p}),t&&jsx("div",{className:"w-px h-6",style:{backgroundColor:m.borderLight}})]}),t&&(s?jsx(lm,{columns:e,onSelect:t,theme:m,t:d,createTaskLabel:a}):jsx(cm,{onClick:()=>t(),label:a||d.newTask}))]})})}function jn({onAddColumn:e,className:t,placeholder:a="Nombre de la columna...",buttonLabel:r="Agregar Columna",disabled:o=false}){let[s,l]=useState(false),[c,p]=useState(""),n=useCallback(()=>{let i=c.trim();i&&(e(i),p(""),l(false));},[c,e]),m=useCallback(i=>{i.key==="Enter"?(i.preventDefault(),n()):i.key==="Escape"&&(p(""),l(false));},[n]),d=useCallback(()=>{setTimeout(()=>{c.trim()||l(false);},150);},[c]);return s?jsx("div",{className:C("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:m,onBlur:d,placeholder:a,autoFocus:true,className:"asakaa-add-column__input"}),jsxs("div",{className:"asakaa-add-column__actions",children:[jsx("button",{onClick:n,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(""),l(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:C("asakaa-add-column",t),children:jsxs("button",{onClick:()=>l(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 Kn({columnId:e,onAddCard:t,availableUsers:a=[],className:r,placeholder:o,buttonLabel:s,disabled:l=false,theme:c="dark",locale:p="es"}){let[n,m]=useState(false),[d,i]=useState(false),[u,v]=useState(""),[f,g]=useState([]),[x,b]=useState(""),[h,w]=useState(""),[D,N]=useState(""),[A,y]=useState(false),[R,T]=useState(false),[k,B]=useState(false),P=useRef(null),H=useRef(null),X={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(()=>{v(""),g([]),b(""),w(""),N(""),y(false),T(false),B(false),m(false);},[]);useEffect(()=>{n&&P.current&&P.current.focus();},[n]),useEffect(()=>{if(!n)return;let F=W=>{H.current&&!H.current.contains(W.target)&&(u.trim()||be());};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[n,u,be]);let ke=useCallback(async()=>{let F=u.trim();if(!(!F||d)){i(true);try{await t({name:F,columnId:e,assigneeIds:f.length>0?f:void 0,startDate:x?new Date(x):void 0,endDate:h?new Date(h):void 0,priority:D||void 0}),v(""),g([]),b(""),w(""),N(""),y(!1),T(!1),B(!1),P.current?.focus();}catch(W){console.error("Error creating card:",W);}finally{i(false);}}},[u,e,f,x,h,D,t,d]),Ae=useCallback(F=>{F.key==="Enter"&&!F.shiftKey?(F.preventDefault(),ke()):F.key==="Escape"&&be();},[ke,be]),Fe=useCallback(F=>{g(W=>W.includes(F)?W.filter(E=>E!==F):[...W,F]);},[]),z=c==="dark";return n?jsxs("div",{ref:H,className:C("rounded-lg overflow-hidden shadow-lg",z?"bg-[#1e1e2e]":"bg-white",r),style:{border:"2px solid #10b981"},children:[jsxs("div",{className:"p-3",children:[jsx("input",{ref:P,type:"text",value:u,onChange:F=>v(F.target.value),onKeyDown:Ae,placeholder:X.placeholder,disabled:d,className:C("w-full px-0 py-1 text-sm font-medium border-0 bg-transparent focus:outline-none focus:ring-0",z?"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:()=>y(!A),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",A||f.length>0?"bg-emerald-500/20 text-emerald-400":z?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:X.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"})]}),f.length>0&&jsx("span",{className:"ml-0.5",children:f.length})]}),jsx("button",{onClick:()=>T(!R),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",R||x||h?"bg-blue-500/20 text-blue-400":z?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:X.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:()=>B(!k),className:C("flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors",k||D?D==="urgent"?"bg-red-500/20 text-red-400":D==="high"?"bg-orange-500/20 text-orange-400":D==="medium"?"bg-yellow-500/20 text-yellow-400":D==="low"?"bg-green-500/20 text-green-400":"bg-orange-500/20 text-orange-400":z?"text-gray-400 hover:bg-[#2a2a3e] hover:text-gray-300":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),type:"button",title:X.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:ke,disabled:!u.trim()||d,className:C("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"}):X.save})]})]}),A&&a.length>0&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",z?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex flex-wrap gap-1.5 pt-3",children:a.map(F=>jsxs("button",{onClick:()=>Fe(F.id),className:C("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs transition-all",f.includes(F.id)?"bg-emerald-500 text-white":z?"bg-[#2a2a3e] text-gray-300 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-700 hover:bg-gray-200"),type:"button",children:[F.avatar?jsx("img",{src:F.avatar,alt:F.name,className:"w-4 h-4 rounded-full"}):jsx("div",{className:C("w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-medium",f.includes(F.id)?"bg-emerald-600 text-white":"bg-emerald-500 text-white"),children:F.name.charAt(0).toUpperCase()}),jsx("span",{children:F.name.split(" ")[0]})]},F.id))})}),R&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",z?"border-[#3a3a4e]":"border-gray-200"),children:jsxs("div",{className:"grid grid-cols-2 gap-2 pt-3",children:[jsxs("div",{children:[jsx("label",{className:C("block text-[10px] uppercase tracking-wide mb-1",z?"text-gray-500":"text-gray-400"),children:X.startDate}),jsx("input",{type:"date",value:x,onChange:F=>b(F.target.value),className:C("w-full px-2 py-1.5 rounded text-xs border",z?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]}),jsxs("div",{children:[jsx("label",{className:C("block text-[10px] uppercase tracking-wide mb-1",z?"text-gray-500":"text-gray-400"),children:X.endDate}),jsx("input",{type:"date",value:h,onChange:F=>w(F.target.value),className:C("w-full px-2 py-1.5 rounded text-xs border",z?"bg-[#2a2a3e] border-[#3a3a4e] text-gray-200":"bg-gray-50 border-gray-200 text-gray-800")})]})]})}),k&&jsx("div",{className:C("px-3 pb-3 pt-0","border-t",z?"border-[#3a3a4e]":"border-gray-200"),children:jsx("div",{className:"flex gap-1.5 pt-3",children:["low","medium","high","urgent"].map(F=>jsx("button",{onClick:()=>N(D===F?"":F),className:C("flex-1 px-2 py-1.5 rounded text-xs font-medium transition-all",D===F?`${{low:"bg-green-500",medium:"bg-yellow-500",high:"bg-orange-500",urgent:"bg-red-500"}[F]} text-white`:z?"bg-[#2a2a3e] text-gray-400 hover:bg-[#3a3a4e]":"bg-gray-100 text-gray-600 hover:bg-gray-200"),type:"button",children:X[F]},F))})})]}):jsxs("button",{onClick:()=>m(true),disabled:l,className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-all duration-200","text-emerald-500 hover:text-emerald-400",z?"hover:bg-[#2a2a3e]":"hover:bg-gray-100",l&&"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:X.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(er,{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(l=>{l?o(l):s(new Error("Failed to create PNG blob"));},"image/png");})}};function Sl(e={}){return new no(e)}var Or=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(l){console.error("Error in error handler:",l);}}render(){let{hasError:a,error:r}=this.state,{children:o,fallback:s,componentName:l}=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:l?`Error in ${l}`:"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 Yn(e,t){let a=r=>jsx(Or,{...t,children:jsx(e,{...r})});return a.displayName=`withErrorBoundary(${e.displayName||e.name||"Component"})`,a}function Xn({board:e,onCreateCard:t,onNavigateToCard:a,onSearch:r,onChangePriority:o,onAssignUser:s,onGeneratePlan:l,onPredictRisks:c,onOpenAIUsage:p,shortcut:n="k",className:m=""}){let[d,i]=useState(false),[u,v]=useState(""),[f,g]=useState("home"),[x,b]=useState(""),[h,w]=useState("");useEffect(()=>{let y=R=>{(R.metaKey||R.ctrlKey)&&R.key===n&&(R.preventDefault(),i(T=>!T)),R.key==="Escape"&&(i(false),g("home"),v(""));};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[n]),useEffect(()=>{d||(g("home"),v(""),b(""),w(""));},[d]);let D=useCallback(()=>{i(false);},[]),N=useCallback(y=>{let[R,T]=y.split(":");switch(R){case "create-card":g("create-card");break;case "create-card-in":b(T||"");break;case "navigate":T?(a?.(T),D()):g("navigate");break;case "search":r?.(u),D();break;case "priority":g("priority");break;case "set-priority":h&&T&&(o?.(h,T),D());break;case "assign":g("assign");break;case "assign-user":h&&T&&(s?.(h,T),D());break;case "ai":g("ai");break;case "ai-generate-plan":l?.(),D();break;case "ai-predict-risks":c?.(),D();break;case "ai-usage":p?.(),D();break;case "back":g("home");break;}},[u,h,t,a,r,o,s,l,c,p,D]),A=useCallback(()=>{x&&u.trim()&&(t?.(x,u.trim()),D());},[x,u,t,D]);return d?jsx(rt,{children:jsx("div",{className:"command-palette-overlay",onClick:D,children:jsx("div",{className:`command-palette ${m}`,onClick:y=>y.stopPropagation(),children:jsxs(Command,{value:u,onValueChange:v,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:f==="create-card"&&x?"Type card title and press Enter...":f==="create-card"?"Select a column first...":"Type a command or search...",className:"command-palette-input",onKeyDown:y=>{y.key==="Enter"&&f==="create-card"&&x&&A();}}),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."}),f==="home"&&jsxs(Fragment,{children:[jsxs(Command.Group,{heading:"Actions",className:"command-palette-group",children:[jsxs(Command.Item,{value:"create-card",onSelect:N,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:N,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:N,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:N,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(y=>jsxs(Command.Item,{value:`navigate:${y.id}`,onSelect:N,className:"command-palette-item",children:[jsx("div",{className:"command-palette-item-dot",style:{background:y.priority==="URGENT"?"#EF4444":y.priority==="HIGH"?"#F59E0B":y.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:y.title}),y.labels&&y.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:y.labels.slice(0,2).map(R=>jsx("span",{className:"command-palette-item-label",children:R},R))})]},y.id))})]}),f==="create-card"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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(y=>jsxs(Command.Item,{value:`create-card-in:${y.id}`,onSelect:N,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:y.title}),jsxs("div",{className:"command-palette-item-count",children:[y.cardIds.length," cards"]})]},y.id))})]}),f==="navigate"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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(y=>{let R=e.columns.find(T=>T.id===y.columnId);return jsxs(Command.Item,{value:`navigate:${y.id}`,onSelect:N,className:"command-palette-item",keywords:[y.title,y.description||"",...y.labels||[]],children:[jsx("div",{className:"command-palette-item-dot",style:{background:y.priority==="URGENT"?"#EF4444":y.priority==="HIGH"?"#F59E0B":y.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsxs("div",{className:"command-palette-item-content",children:[jsx("div",{children:y.title}),jsx("div",{className:"command-palette-item-meta",children:R?.title})]}),y.labels&&y.labels.length>0&&jsx("div",{className:"command-palette-item-labels",children:y.labels.slice(0,2).map(T=>jsx("span",{className:"command-palette-item-label",children:T},T))})]},y.id)})})]}),f==="ai"&&jsxs(Fragment,{children:[jsxs(Command.Item,{value:"back",onSelect:N,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:N,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:N,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:N,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 Ml(e,t,a,r,o){let s=document.getElementById("attachment-lightbox-native");s&&s.remove();let l=document.createElement("div");l.id="attachment-lightbox-native",l.className="attachment-lightbox",l.style.cssText=`
6
6
  position: fixed !important;
7
7
  inset: 0 !important;
8
8
  z-index: 2147483647 !important;
@@ -34,7 +34,7 @@ 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=y=>y.stopPropagation(),a.forEach((y,f)=>{let g=document.createElement("button");g.className=`attachment-lightbox-dot ${f===r?"active":""}`,g.style.cssText=`
37
+ `,d.onclick=v=>v.stopPropagation(),a.forEach((v,f)=>{let g=document.createElement("button");g.className=`attachment-lightbox-dot ${f===r?"active":""}`,g.style.cssText=`
38
38
  width: 8px !important;
39
39
  height: 8px !important;
40
40
  border-radius: 50% !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=y=>{y.stopPropagation();let f=r>0?r-1:a.length-1;n(),o(f);};let u=document.createElement("button");u.className="attachment-lightbox-nav-area attachment-lightbox-nav-next",u.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>',u.style.cssText=`
58
+ `,i.onmouseenter=()=>{i.style.opacity="1";},i.onmouseleave=()=>{i.style.opacity="0.5";},i.onclick=v=>{v.stopPropagation();let f=r>0?r-1:a.length-1;n(),o(f);};let u=document.createElement("button");u.className="attachment-lightbox-nav-area attachment-lightbox-nav-next",u.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>',u.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
- `,u.onmouseenter=()=>{u.style.opacity="1";},u.onmouseleave=()=>{u.style.opacity="0.5";},u.onclick=y=>{y.stopPropagation();let f=r<a.length-1?r+1:0;n(),o(f);},l.appendChild(d),l.appendChild(i),l.appendChild(u);}l.appendChild(c),l.appendChild(p),document.body.appendChild(l),setTimeout(()=>{p.style.transition="opacity 0.5s ease",p.style.opacity="0";},2e3);}function mm(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 um(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 Qn(e){return e.startsWith("image/")}function za({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[l,c]=useState(false),[p,n]=useState(false),[m,d]=useState(null),i=useRef(null),u=useRef(e);u.current=e;let y=useCallback((v,L)=>{L.preventDefault(),L.stopPropagation();let T=u.current.filter(P=>Qn(P.type)),k=T.findIndex(P=>P.id===v.id),F=P=>{let H=u.current.filter(ye=>Qn(ye.type)),X=H[P];X&&Sl(X.url,X.name,H,P,F);};Sl(v.url,v.name,T,k,F);},[]),f=useCallback(v=>{let L=[],T=[];return e.length+v.length>s?(T.push(`Maximum ${s} files allowed`),{valid:L,errors:T}):(v.forEach(k=>{if(k.size/1048576>r){T.push(`${k.name} is too large (max ${r}MB)`);return}if(o&&!o.some(P=>k.type.match(P))){T.push(`${k.name} has invalid file type`);return}L.push(k);}),{valid:L,errors:T})},[e.length,s,r,o]),g=useCallback(async v=>{let{valid:L,errors:T}=f(v);if(T.length>0){d(T.join(", ")),setTimeout(()=>d(null),5e3);return}if(L.length!==0){n(true),d(null);try{await t?.(L);}catch(k){d(k instanceof Error?k.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{n(false);}}},[f,t]),x=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(true);},[]),b=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);},[]),h=useCallback(v=>{v.preventDefault(),v.stopPropagation();},[]),w=useCallback(v=>{v.preventDefault(),v.stopPropagation(),c(false);let L=Array.from(v.dataTransfer.files);g(L);},[g]),D=useCallback(v=>{let L=v.target.files?Array.from(v.target.files):[];g(L),i.current&&(i.current.value="");},[g]),N=useCallback(()=>{i.current?.click();},[]),M=useCallback(v=>{confirm("Are you sure you want to delete this attachment?")&&a?.(v);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${l?"dragging":""} ${p?"uploading":""}`,onDragEnter:x,onDragLeave:b,onDragOver:h,onDrop:w,onClick:N,children:[jsx("input",{ref:i,type:"file",multiple:true,onChange:D,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:l?"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"]})]})})]}),m&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:m})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(v=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Qn(v.type)&&v.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:L=>y(v,L),title:"Click to view full size",children:[jsx("img",{src:v.thumbnailUrl||v.url,alt:v.name,className:"attachment-thumbnail"}),jsx("div",{className:"attachment-thumbnail-overlay",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M9 21H3V15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M21 3L14 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M3 21L10 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}):jsx("div",{className:"attachment-icon",children:um(v.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:v.name,children:v.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:mm(v.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(v.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>M(v.id),className:"attachment-delete",title:"Delete attachment",type:"button",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},v.id))})]})}function es({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:l=[],activities:c=[],aiInsights:p=[],attachments:n=[],onAddComment:m,onDeleteComment:d,onUploadAttachments:i,onDeleteAttachment:u,onSuggestAssignee:y,onGenerateSubtasks:f,onEstimateEffort:g,currentUserId:x="user-1"}){let[b,h]=useState("details"),[w,D]=useState(false),[N,M]=useState({}),[v,L]=useState(""),[T,k]=useState(false),[F,P]=useState({});if(!t||!e)return null;let H=useCallback(()=>{D(false),M({}),h("details"),L(""),P({}),a();},[a]),X=useCallback(()=>{r&&Object.keys(N).length>0&&(r(e.id,N),M({}),D(false));},[e.id,N,r]),ye=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),H());},[e.id,o,H]),we=useCallback(()=>{m&&v.trim()&&(m(e.id,v.trim()),L(""));},[e.id,v,m]),Ie=useCallback(async()=>{if(y){k(true);try{let S=await y(e);P(q=>({...q,assignees:S}));}catch(S){console.error("Failed to suggest assignee:",S);}finally{k(false);}}},[e,y]),Le=useCallback(async()=>{if(f){k(true);try{let S=await f(e);P(q=>({...q,subtasks:S}));}catch(S){console.error("Failed to generate subtasks:",S);}finally{k(false);}}},[e,f]),O=useCallback(async()=>{if(g){k(true);try{let S=await g(e);P(q=>({...q,effort:S}));}catch(S){console.error("Failed to estimate effort:",S);}finally{k(false);}}},[e,g]),B={...e,...N},W=s.filter(S=>B.assignedUserIds?.includes(S.id));return jsx(tt,{children:jsx("div",{className:"card-detail-overlay",onClick:H,children:jsxs("div",{className:"card-detail-modal",onClick:S=>S.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:B.priority==="URGENT"?"#EF4444":B.priority==="HIGH"?"#F59E0B":B.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),w?jsx("input",{type:"text",value:N.title??B.title,onChange:S=>M({...N,title:S.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:B.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[w?jsxs(Fragment,{children:[jsx("button",{onClick:X,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{D(false),M({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>D(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:ye,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:H,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:()=>h("details"),className:`card-detail-tab ${b==="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:()=>h("comments"),className:`card-detail-tab ${b==="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",l.length>0&&jsx("span",{className:"card-detail-tab-badge",children:l.length})]}),jsxs("button",{onClick:()=>h("activity"),className:`card-detail-tab ${b==="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:()=>h("attachments"),className:`card-detail-tab ${b==="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",n.length>0&&jsx("span",{className:"card-detail-tab-badge",children:n.length})]}),jsxs("button",{onClick:()=>h("ai"),className:`card-detail-tab ${b==="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:[b==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),w?jsx("textarea",{value:N.description??B.description??"",onChange:S=>M({...N,description:S.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:B.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),w?jsx("select",{multiple:true,value:N.assignedUserIds??B.assignedUserIds??[],onChange:S=>{let q=Array.from(S.target.selectedOptions,ee=>ee.value);M({...N,assignedUserIds:q});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(S=>jsx("option",{value:S.id,children:S.name},S.id))}):jsx("div",{className:"card-detail-users",children:W.length>0?W.map(S=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:S.color},children:S.initials}),jsx("span",{children:S.name})]},S.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),w?jsxs("select",{value:N.priority??B.priority??"",onChange:S=>M({...N,priority:S.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:B.priority==="URGENT"?"#EF4444":B.priority==="HIGH"?"#F59E0B":B.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:B.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:B.labels&&B.labels.length>0?B.labels.map(S=>jsx("span",{className:"card-detail-label-tag",children:S},S)):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"}),w?jsx("input",{type:"date",value:N.startDate?new Date(N.startDate).toISOString().split("T")[0]:B.startDate?new Date(B.startDate).toISOString().split("T")[0]:"",onChange:S=>M({...N,startDate:S.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:B.startDate?new Date(B.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),w?jsx("input",{type:"date",value:N.endDate?new Date(N.endDate).toISOString().split("T")[0]:B.endDate?new Date(B.endDate).toISOString().split("T")[0]:"",onChange:S=>M({...N,endDate:S.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:B.endDate?new Date(B.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),w?jsx("input",{type:"number",min:"0",step:"0.5",value:N.estimatedTime??B.estimatedTime??"",onChange:S=>M({...N,estimatedTime:S.target.value?parseFloat(S.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:B.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:B.dependencies&&B.dependencies.length>0?B.dependencies.map(S=>{let q=typeof S=="string"?S:S.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",q.slice(-4)]},q)}):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:B.createdAt?new Date(B.createdAt).toLocaleString():"Unknown"})]})]}),b==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:v,onChange:S=>L(S.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:we,disabled:!v.trim(),className:"card-detail-btn card-detail-btn-primary",children:"Add Comment"})]}),jsx("div",{className:"card-detail-comments-list",children:l.length>0?l.map(S=>{let q=s.find(ee=>ee.id===S.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:[q&&jsx("div",{className:"card-detail-user-avatar",style:{background:q.color},children:q.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:q?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(S.createdAt).toLocaleString()})]})]}),d&&jsx("button",{onClick:()=>d(S.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:S.content})]},S.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"})]})})]}),b==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(S=>{let q=s.find(ee=>ee.id===S.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[S.type.includes("CREATED")&&"\u2795",S.type.includes("UPDATED")&&"\u270F\uFE0F",S.type.includes("MOVED")&&"\u27A1\uFE0F",S.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",S.type.includes("COMMENT")&&"\u{1F4AC}",S.type.includes("ASSIGNED")&&"\u{1F464}",S.type.includes("PRIORITY")&&"\u{1F3AF}",S.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",S.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:q?.name||"Unknown"})," ",S.type.replace(/_/g," ").toLowerCase(),S.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:S.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(S.timestamp).toLocaleString()})]})]},S.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"})]})}),b==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx(za,{cardId:e.id,attachments:n,onUpload:i?S=>i(e.id,S):void 0,onDelete:u,currentUserId:x,maxSizeMB:10,maxFiles:20})}),b==="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:Ie,disabled:T||!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("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:T||!f,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:T||!g,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"]})]}),F.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),F.assignees.map((S,q)=>{let ee=s.find($=>$.id===S.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[ee&&jsx("div",{className:"card-detail-user-avatar",style:{background:ee.color},children:ee.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:ee?.name}),jsx("div",{className:"card-detail-ai-suggestion-reason",children:S.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(S.confidence*100).toFixed(0),"%"]})]})]},q)})]}),F.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),F.subtasks.map((S,q)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:S.title}),S.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:S.description}),S.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",S.estimatedTime,"h"]})]},q))]}),F.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:[F.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(F.effort.confidence*100).toFixed(0),"%"]})]})]}),p.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),p.map(S=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${S.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:S.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:S.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:S.description}),S.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",S.suggestedAction]})]},S.id))]}),!F.assignees&&!F.subtasks&&!F.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 io({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:l=""}){let[c,p]=useState({top:0,left:0}),n=useRef(null),m=useCallback(()=>{if(!e.current)return {top:0,left:0};let d=e.current.getBoundingClientRect(),i=window.innerHeight,u=window.innerWidth,y=4,f=d.left;f+o>u-10&&(f=u-o-10),f<10&&(f=10);let g=i-d.bottom,x=d.top,b;return g>=s+y?b=d.bottom+y:x>=s+y?b=d.top-s-y:g>=x?b=d.bottom+y:b=Math.max(10,d.top-s-y),{top:b,left:f}},[e,o,s]);return useEffect(()=>{t&&p(m());},[t,m]),useEffect(()=>{if(!t)return;let d=u=>{let y=u.target;n.current&&!n.current.contains(y)&&e.current&&!e.current.contains(y)&&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(tt,{children:jsx("div",{ref:n,className:`smart-popover ${l}`,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 Ho=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function Rr({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:l=true}){let[c,p]=useState(false),[n,m]=useState(""),[d,i]=useState(false),[u,y]=useState(Ho[10]||"#3B82F6"),[f,g]=useState({top:0,left:0}),x=useRef(null),b=useRef(null),h=useRef(null),w=useRef(null),D=t.filter(k=>k.name.toLowerCase().includes(n.toLowerCase())),N=t.some(k=>k.name.toLowerCase()===n.toLowerCase());useEffect(()=>{if(c&&b.current){let k=b.current.getBoundingClientRect();g({top:k.bottom+6,left:k.left});}},[c]),useEffect(()=>{let k=F=>{let P=F.target,H=x.current?.contains(P),X=h.current?.contains(P);!H&&!X&&(p(false),m(""),i(false));};if(c)return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[c]),useEffect(()=>{c&&w.current&&w.current.focus();},[c]);let M=k=>{let F=e.some(P=>P.id===k.id);a(F?e.filter(P=>P.id!==k.id):[...e,k]);},v=async()=>{if(!(!r||!n.trim())){i(true);try{let k=await r(n.trim(),u);k&&(a([...e,k]),m(""),y(Ho[Math.floor(Math.random()*Ho.length)]||"#3B82F6"));}finally{i(false);}}},L=(k,F)=>{F.stopPropagation(),a(e.filter(P=>P.id!==k));},T={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:x,className:"relative",children:[jsxs("button",{ref:b,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:T,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(k=>jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",style:{backgroundColor:`${k.color}20`,color:k.color},children:k.name},k.id)),e.length>2&&jsxs("span",{className:"text-xs",style:{color:o.textTertiary},children:["+",e.length-2]})]}):jsx("span",{children:"Etiquetas"}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:o.textTertiary}})]}),typeof document<"u"&&createPortal(jsx(AnimatePresence,{children:c&&jsxs(motion.div,{ref:h,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:f.top,left:f.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:w,type:"text",value:n,onChange:k=>m(k.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:k=>{k.key==="Enter"&&n.trim()&&!N&&r&&v();}})}),e.length>0&&jsxs("div",{className:"p-2 border-b",style:{borderColor:o.border},children:[jsx("p",{className:"text-xs mb-1.5",style:{color:o.textTertiary},children:"Seleccionadas"}),jsx("div",{className:"flex flex-wrap gap-1",children:e.map(k=>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:`${k.color}20`,color:k.color},onClick:F=>L(k.id,F),children:[k.name,jsx(X,{className:"w-3 h-3"})]},k.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:D.length>0?D.map(k=>{let F=e.some(P=>P.id===k.id);return jsxs("button",{type:"button",onClick:()=>M(k),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:F?`${k.color}15`:"transparent",color:o.textPrimary},onMouseEnter:P=>{F||(P.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:P=>{F||(P.currentTarget.style.backgroundColor="transparent");},children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:k.color}}),jsx("span",{className:"flex-1 text-left",children:k.name}),F&&jsx(Check,{className:"w-4 h-4",style:{color:k.color}})]},k.id)}):n.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"})}),n.trim()&&!N&&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:Ho.map(k=>jsx("button",{type:"button",onClick:()=>y(k),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:k,outline:u===k?`2px solid ${k}`:"none",outlineOffset:"2px"}},k))}),jsxs("button",{type:"button",onClick:v,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:u,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 "',n.trim(),'"']})]})]})}),document.body)]})}function rs({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 Al({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(rs,{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 Ge={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 Em=["LOW","MEDIUM","HIGH","URGENT"],Pm=["todo","in-progress","review","done"];function ns({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:l=[],activities:c=[],onAddComment:p,onDeleteComment:n,currentUser:m,onAIGenerateDescription:d,onAICreateSubtasks:i,onAIFindSimilar:u,availableColumns:y=[],availableLabels:f=[],availableTags:g=[],onCreateTag:x,onUploadCoverImage:b,unsplashAccessKey:h,theme:w,onSubtasksChange:D,attachments:N=[],onUploadAttachments:M,onDeleteAttachment:v}){let L=Mr(),T=w||L?.themeName||"dark",[k,F]=useState(e),[P,H]=useState(false),[X,ye]=useState(e?.subtasks||[]),[we,Ie]=useState(false),[Le,O]=useState(""),[B,W]=useState(""),[S,q]=useState("all"),[ee,$]=useState(false),[Me,be]=useState(false),[qe,ue]=useState(false),[Qe,Te]=useState(false),[rt,gt]=useState(false),[ft,et]=useState(false),R=useRef(null),se=useRef(null),ve=useRef(null),De=useRef(null),Ee=useRef(null),Ve=useRef(null),Ct=useRef(null),Y=useRef(null),z=useRef(null),ke=useRef(null),We=useRef(null),Ue=useRef(null);useEffect(()=>{e&&!k?(F({...e}),ye(e.subtasks||[])):e&&k&&e.id!==k.id&&(F({...e}),ye(e.subtasks||[]));},[e,k]),useEffect(()=>{let U=ce=>{let Ce=ce.target;De.current&&!De.current.contains(Ce)&&$(false),Ee.current&&!Ee.current.contains(Ce)&&be(false),Ve.current&&!Ve.current.contains(Ce)&&ue(false),Ct.current&&!Ct.current.contains(Ce)&&Te(false);};if(ee||Me||qe||Qe)return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[ee,Me,qe,Qe]),useEffect(()=>{if(!t)return;let U=ce=>{let Ce=ce.target,zt=Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable;if(ce.key==="Escape"){ce.preventDefault(),ee||Me||qe||Qe||rt||ft?($(false),be(false),ue(false),Te(false),gt(false),et(false)):zt||a();return}if(zt&&ce.key!=="Escape")return;let ea=ce.metaKey||ce.ctrlKey;switch(ce.key.toLowerCase()){case "s":ce.preventDefault(),$(true);break;case "a":ce.preventDefault(),ue(true);break;case "p":ce.preventDefault(),be(true);break;case "l":ce.preventDefault(),Te(true);break;case "d":ea||(ce.preventDefault(),gt(true),setTimeout(()=>Y.current?.focus(),0));break;case "e":ea||(ce.preventDefault(),et(true));break;case "i":ce.preventDefault(),H(true),setTimeout(()=>se.current?.focus(),0);break;case "t":ce.preventDefault(),Ie(true);break;case "c":ce.preventDefault(),ve.current?.focus();break}};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[t,a,ee,Me,qe,Qe,rt,ft]);let ht=useCallback(U=>{let ce=U.currentTarget.textContent?.trim()||"";if(k&&ce!==k.title){let Ce={...k,title:ce};F(Ce),r?.(k.id,{title:ce});}},[k,r]),Z=useCallback(U=>{U.key==="Enter"&&(U.preventDefault(),U.currentTarget.blur()),U.key==="Escape"&&(U.preventDefault(),U.currentTarget.textContent=k?.title||"",U.currentTarget.blur());},[k]),te=useCallback(()=>{k&&e&&k.description!==e.description&&r?.(k.id,{description:k.description}),H(false);},[k,e,r]),xe=useCallback(U=>{if(k){let ce={...k,columnId:U};F(ce),r?.(k.id,{columnId:U}),$(false);}},[k,r]),Pe=useCallback(U=>{if(k){let ce={...k,priority:U};F(ce),r?.(k.id,{priority:U}),be(false);}},[k,r]),J=useCallback(U=>{if(k){let ce=k.assignedUserIds||[],Ce=ce.includes(U)?ce.filter(ea=>ea!==U):[...ce,U],zt={...k,assignedUserIds:Ce};F(zt),r?.(k.id,{assignedUserIds:Ce});}},[k,r]),Ae=useCallback(U=>{if(k){let ce=k.labels||[],Ce=ce.includes(U)?ce.filter(ea=>ea!==U):[...ce,U],zt={...k,labels:Ce};F(zt),r?.(k.id,{labels:Ce});}},[k,r]),he=useCallback(U=>{if(k){let ce={...k,tags:U};F(ce),r?.(k.id,{tags:U});}},[k,r]),Ne=useCallback(U=>{if(k){let ce=U.target.value,Ce={...k,endDate:ce};F(Ce),r?.(k.id,{endDate:ce}),gt(false);}},[k,r]),de=useCallback(U=>{if(k){let ce={...k,estimatedTime:parseFloat(U)||0};F(ce),r?.(k.id,{estimatedTime:parseFloat(U)||0});}},[k,r]),Re=useCallback(()=>{if(Le.trim()&&k){let U={id:`subtask-${Date.now()}`,title:Le.trim(),completed:false,createdAt:new Date},ce=[...X,U];ye(ce),O(""),Ie(false),D?.(k.id,ce);}},[Le,X,k,D]),Fe=useCallback(U=>{let ce=X.map(Ce=>Ce.id===U?{...Ce,completed:!Ce.completed,updatedAt:new Date}:Ce);ye(ce),k&&D?.(k.id,ce);},[X,k,D]),Oe=useCallback(U=>{let ce=X.filter(Ce=>Ce.id!==U);ye(ce),k&&D?.(k.id,ce);},[X,k,D]),_=useCallback(()=>{B.trim()&&k&&p&&(p(k.id,B.trim()),W(""));},[B,k,p]),j=useCallback(U=>{(U.metaKey||U.ctrlKey)&&U.key==="Enter"&&(U.preventDefault(),_());},[_]),nt=U=>jsx(Dm,{remarkPlugins:[Nm],rehypePlugins:[Sm],components:{a:({node:ce,...Ce})=>jsx("a",{...Ce,target:"_blank",rel:"noopener noreferrer"})},children:U}),He=c.filter(U=>S==="comments"?U.type.includes("COMMENT"):S==="history"?!U.type.includes("COMMENT"):true);if(!t||!e)return null;let ge=k||e,Vt=s.filter(U=>ge.assignedUserIds?.includes(U.id)),Tt=X.filter(U=>U.completed).length;return jsx(tt,{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:U=>U.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":T,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:R,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:ht,onKeyDown:Z,children:ge.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:De,children:[jsxs("button",{ref:z,className:"modal-v2-field",onClick:()=>$(!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("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:ge.columnId||"No status"})]}),jsx(io,{triggerRef:z,isOpen:ee,onClose:()=>$(false),width:250,estimatedHeight:200,children:(y.length>0?y:Pm.map(U=>({id:U,title:U}))).map(U=>jsx("button",{className:`modal-v2-popover-item ${ge.columnId===U.id?"active":""}`,onClick:()=>xe(U.id),children:U.title},U.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ve,children:[jsxs("button",{ref:ke,className:"modal-v2-field",onClick:()=>ue(!qe),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:Vt.length>0?jsx("div",{className:"modal-v2-avatars",children:Vt.map(U=>jsx("div",{className:"modal-v2-avatar",style:{background:U.color},title:U.name,children:U.initials},U.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(io,{triggerRef:ke,isOpen:qe,onClose:()=>ue(false),width:280,estimatedHeight:300,children:s.map(U=>jsxs("button",{className:`modal-v2-popover-item ${ge.assignedUserIds?.includes(U.id)?"active":""}`,onClick:()=>J(U.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:U.color},children:U.initials}),U.name,ge.assignedUserIds?.includes(U.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"})})]},U.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ee,children:[jsxs("button",{ref:We,className:"modal-v2-field",onClick:()=>be(!Me),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:ge.priority||"None"})]}),jsxs(io,{triggerRef:We,isOpen:Me,onClose:()=>be(false),width:180,estimatedHeight:220,children:[Em.map(U=>jsx("button",{className:`modal-v2-popover-item priority-${U.toLowerCase()} ${ge.priority===U?"active":""}`,onClick:()=>Pe(U),children:U},U)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>Pe(""),children:"None"})]})]}),g.length>0||x?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(Rr,{selectedTags:ge.tags||[],availableTags:g,onChange:he,onCreateTag:x,theme:Ge[T]||Ge.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:Ct,children:[jsxs("button",{ref:Ue,className:"modal-v2-field",onClick:()=>Te(!Qe),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:ge.labels&&ge.labels.length>0?jsx("span",{children:ge.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(io,{triggerRef:Ue,isOpen:Qe,onClose:()=>Te(false),width:220,estimatedHeight:200,children:(f.length>0?f:["Bug","Feature","Enhancement","Documentation"]).map(U=>jsxs("button",{className:`modal-v2-popover-item ${ge.labels?.includes(U)?"active":""}`,onClick:()=>Ae(U),children:[U,ge.labels?.includes(U)&&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"})})]},U))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{gt(!rt),setTimeout(()=>Y.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:ge.endDate?new Date(ge.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Y,type:"date",value:typeof ge.endDate=="string"?ge.endDate.split("T")[0]:ge.endDate?(()=>{let U=new Date(ge.endDate),ce=U.getUTCFullYear(),Ce=String(U.getUTCMonth()+1).padStart(2,"0"),zt=String(U.getUTCDate()).padStart(2,"0");return `${ce}-${Ce}-${zt}`})():"",onChange:Ne,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>et(!ft),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:ge.estimatedTime?`${ge.estimatedTime}h`:"Not set"})]}),ft&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:ge.estimatedTime||"",onChange:U=>de(U.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>et(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"})]}),P?jsx("textarea",{className:"modal-v2-textarea",value:ge.description||"",onChange:U=>{if(k){let ce={...k,description:U.target.value};F(ce);}},onBlur:te,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>H(true),children:ge.description?jsx("div",{className:"modal-v2-markdown",children:nt(ge.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"}),X.length>0&&jsxs("span",{className:"modal-v2-count",children:[Tt,"/",X.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Ie(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:[X.map(U=>jsxs("div",{className:`modal-v2-subtask ${U.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>Fe(U.id),children:U.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:U.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>Oe(U.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"})]})})]},U.id)),we&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:Le,onChange:U=>O(U.target.value),onKeyDown:U=>{U.key==="Enter"&&Re(),U.key==="Escape"&&(Ie(false),O(""));},onBlur:Re,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(M||N.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"}),N.length>0&&jsx("span",{className:"modal-v2-count",children:N.length})]}),jsx(za,{cardId:ge.id,attachments:N,onUpload:M?U=>M(ge.id,U):void 0,onDelete:v,maxSizeMB:10,maxFiles:20})]}),jsxs("section",{className:"modal-v2-section",children:[jsxs("div",{className:"modal-v2-section-header",children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),jsx("h2",{children:"Activity"}),jsxs("div",{className:"modal-v2-filters",children:[jsx("button",{className:`modal-v2-filter ${S==="all"?"active":""}`,onClick:()=>q("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${S==="comments"?"active":""}`,onClick:()=>q("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${S==="history"?"active":""}`,onClick:()=>q("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[m&&jsx("div",{className:"modal-v2-avatar",style:{background:m.color},children:m.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:ve,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:B,onChange:U=>W(U.target.value),onKeyDown:j,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:_,disabled:!B.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[He.map(U=>{let ce=s.find(zt=>zt.id===U.userId);if(U.type.includes("COMMENT")){let zt=l.find(ea=>ea.id===U.metadata?.commentId);return zt?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[ce&&jsx("div",{className:"modal-v2-avatar",style:{background:ce.color},children:ce.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:ce?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(U.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:zt.content})]})]},U.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[U.type.includes("CREATED")&&"\u2795",U.type.includes("UPDATED")&&"\u270F\uFE0F",U.type.includes("MOVED")&&"\u27A1\uFE0F",U.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",U.type.includes("ASSIGNED")&&"\u{1F464}",U.type.includes("PRIORITY")&&"\u{1F3AF}",U.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:ce?.name||"Unknown"})," ",U.type.replace(/_/g," ").toLowerCase(),U.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:U.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(U.timestamp).toLocaleString()})]})]},U.id)}),He.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function zm({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 is({data:e,title:t="Team Velocity",height:a=300,showAverage:r=true,showPlanned:o=true}){let s=e.map(l=>({...l,average:l.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(zm,{})}),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((l,c)=>l+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((l,c)=>l+c.completed,0)/e.length).toFixed(1)})]}),o&&e.some(l=>l.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((l,c)=>l+(c.planned||0),0)})]})]})]})}function Km({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 ls({data:e,title:t="Sprint Burndown",height:a=300,totalTasks:r,useArea:o=false}){let s=r??(e[0]?.ideal||e[0]?.remaining||0),l=e[e.length-1]?.remaining||0,c=e[e.length-1]?.ideal||0,p=s>0?(s-l)/s*100:0,n=l<=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(Km,{})}),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:n?"#10B981":"#EF4444",fill:n?"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:n?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:n?"#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:n?"#10B981":"#EF4444"},children:l})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Status"}),jsx("span",{className:"chart-stat-badge",style:{background:n?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:n?"#10B981":"#EF4444"},children:n?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var au={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},zl=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function ru({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let l=r+(o-r)*.5,c=e+l*Math.cos(-a*(Math.PI/180)),p=t+l*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 $l({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 ds({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((p,n)=>p+n.value,0),l=e.map(p=>({...p,totalValue:s,color:p.color||au[p.name]||zl[e.indexOf(p)%zl.length]})),c=l.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:l,cx:"50%",cy:"50%",labelLine:false,label:o?ru:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:l.map((p,n)=>jsx(Cell,{fill:c[n]},`cell-${n}`))}),jsx(Tooltip,{content:jsx($l,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(p,n)=>{let m=n.payload,d=s>0?(m.value/s*100).toFixed(0):"0";return `${p} (${m.value} - ${d}%)`}})]}):jsxs(BarChart,{data:l,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($l,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Bar,{dataKey:"value",name:"Count",radius:[8,8,0,0],children:l.map((p,n)=>jsx(Cell,{fill:c[n]},`cell-${n}`))})]})}),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,n)=>n.value>p.value?n:p).name})]})]})]})}var _o=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[l,c]=useState(false),[p,n]=useState(false),[m,d]=useState(false),[i,u]=useState(false);if(e.length===0)return null;let y=e.map(w=>w.id),f=w=>{r.onBulkUpdate?.(y,{priority:w}),c(false);},g=w=>{r.onBulkMove?.(y,w),n(false),a();},x=w=>{r.onBulkUpdate?.(y,{assignedUserIds:w}),d(false);},b=w=>{let D=new Set;e.forEach(M=>{M.labels?.forEach(v=>D.add(v));});let N=Array.from(new Set([...D,...w]));r.onBulkUpdate?.(y,{labels:N}),u(false);},h=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(y),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(!l),title:"Update priority",children:jsx("span",{className:"text-sm",children:"Priority"})}),l&&jsx("div",{className:"asakaa-bulk-menu",children:["LOW","MEDIUM","HIGH","URGENT"].map(w=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>f(w),children:[jsx("span",{className:C("asakaa-priority-dot",w==="LOW"&&"bg-asakaa-priority-low",w==="MEDIUM"&&"bg-asakaa-priority-medium",w==="HIGH"&&"bg-asakaa-priority-high",w==="URGENT"&&"bg-asakaa-priority-urgent")}),w]},w))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>n(!p),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(w=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>g(w.id),children:w.title},w.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>d(!m),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),m&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(w=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>x([w.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:w.color},children:w.initials}),w.name]},w.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>u(!i),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),i&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(w=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>b([w]),children:w},w))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:h,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"})})]})]})})});_o.displayName="BulkOperationsToolbar";function lu(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,l,c,p,n;switch(t){case "assignee":let m=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);m.length>0?m.forEach(u=>{let y=a?.find(f=>f.id===u);l=`assignee-${u}`,c=y?.name||`User ${u}`,p=y?.color,n=y?.avatar,r.has(l)||r.set(l,{id:l,title:c,groupValue:u,cardIds:[],color:p,icon:n}),r.get(l).cardIds.push(o.id);}):(l="assignee-unassigned",c="Unassigned",p="#6b7280",n="\u{1F464}",r.has(l)||r.set(l,{id:l,title:c,groupValue:null,cardIds:[],color:p,icon:n}),r.get(l).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",l=`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(l)||r.set(l,{id:l,title:c,groupValue:s,cardIds:[],color:p}),r.get(l).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(u=>{l=`label-${u}`,c=u,p="#6b7280",r.has(l)||r.set(l,{id:l,title:c,groupValue:u,cardIds:[],color:p}),r.get(l).cardIds.push(o.id);}):(l="label-none",c="No Labels",p="#6b7280",r.has(l)||r.set(l,{id:l,title:c,groupValue:null,cardIds:[],color:p}),r.get(l).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function cs({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,l]=useState(new Set),c=useMemo(()=>lu(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),p=useCallback(n=>{l(m=>{let d=new Set(m);return d.has(n)?d.delete(n):d.add(n),d});},[]);return t.groupBy==="none"||c.length===0?jsx(Qa,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:C("asakaa-swimlane-view",o),children:[c.map(n=>{let m=s.has(n.id),d=e.cards.filter(u=>n.cardIds.includes(u.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(n.id),style:{borderLeft:n.color?`4px solid ${n.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[n.icon&&jsx("span",{className:"text-2xl leading-none",children:n.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:n.color},children:n.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",n.cardIds.length," ",n.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":m?"Expand lane":"Collapse lane",children:m?"\u25B6":"\u25BC"})]}),!m&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(Qa,{board:i,callbacks:r,availableUsers:a})})]},n.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 ps=[{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 ms({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null),c=ps.find(n=>n.value===e)||ps[0];useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let p=n=>{t(n),o(false);};return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg 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:C("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[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:ps.map(n=>jsxs("button",{onClick:()=>p(n.value),className:C("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===n.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:n.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:n.label}),e===n.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:n.description})]})]},n.value))})]})]})}var co=[{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 pu(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(n=>e.key===n||e.code===n))return false;let o=t.modifiers||{},s=o.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,l=o.shift?e.shiftKey:!e.shiftKey,c=o.alt?e.altKey:!e.altKey,p=o.meta?e.metaKey:true;return s&&l&&c&&p}function _l(e={}){let{shortcuts:t=co,enabled:a=true,preventDefault:r=true}=e,o=useRef(t),s=useRef(a);useEffect(()=>{o.current=t,s.current=a;},[t,a]);let l=useCallback(p=>{o.current=[...o.current,p];},[]),c=useCallback(p=>{o.current=o.current.filter(n=>n.action!==p);},[]);return useEffect(()=>{function p(n){if(!s.current)return;let m=n.target;if(!((m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.isContentEditable)&&n.key!=="Escape"&&!n.ctrlKey&&!n.metaKey)){for(let d of o.current)if(pu(n,d)){r&&n.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:l,unregisterShortcut:c,isEnabled:a}}function uu(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function gu(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 fu(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=gu(e),r=t?uu(t):"";return a?`${a} + ${r}`:r}function hu(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 us({shortcuts:e=co,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 l=hu(e);return jsxs("div",{className:C("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(l).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(n=>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:n.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:fu(n)})]},n.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 gs=[{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
+ `,u.onmouseenter=()=>{u.style.opacity="1";},u.onmouseleave=()=>{u.style.opacity="0.5";},u.onclick=v=>{v.stopPropagation();let f=r<a.length-1?r+1:0;n(),o(f);},l.appendChild(d),l.appendChild(i),l.appendChild(u);}l.appendChild(c),l.appendChild(p),document.body.appendChild(l),setTimeout(()=>{p.style.transition="opacity 0.5s ease",p.style.opacity="0";},2e3);}function hm(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 bm(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 Zn(e){return e.startsWith("image/")}function $a({attachments:e=[],onUpload:t,onDelete:a,maxSizeMB:r=10,allowedTypes:o,maxFiles:s=10}){let[l,c]=useState(false),[p,n]=useState(false),[m,d]=useState(null),i=useRef(null),u=useRef(e);u.current=e;let v=useCallback((y,R)=>{R.preventDefault(),R.stopPropagation();let T=u.current.filter(P=>Zn(P.type)),k=T.findIndex(P=>P.id===y.id),B=P=>{let H=u.current.filter(be=>Zn(be.type)),X=H[P];X&&Ml(X.url,X.name,H,P,B);};Ml(y.url,y.name,T,k,B);},[]),f=useCallback(y=>{let R=[],T=[];return e.length+y.length>s?(T.push(`Maximum ${s} files allowed`),{valid:R,errors:T}):(y.forEach(k=>{if(k.size/1048576>r){T.push(`${k.name} is too large (max ${r}MB)`);return}if(o&&!o.some(P=>k.type.match(P))){T.push(`${k.name} has invalid file type`);return}R.push(k);}),{valid:R,errors:T})},[e.length,s,r,o]),g=useCallback(async y=>{let{valid:R,errors:T}=f(y);if(T.length>0){d(T.join(", ")),setTimeout(()=>d(null),5e3);return}if(R.length!==0){n(true),d(null);try{await t?.(R);}catch(k){d(k instanceof Error?k.message:"Upload failed"),setTimeout(()=>d(null),5e3);}finally{n(false);}}},[f,t]),x=useCallback(y=>{y.preventDefault(),y.stopPropagation(),c(true);},[]),b=useCallback(y=>{y.preventDefault(),y.stopPropagation(),c(false);},[]),h=useCallback(y=>{y.preventDefault(),y.stopPropagation();},[]),w=useCallback(y=>{y.preventDefault(),y.stopPropagation(),c(false);let R=Array.from(y.dataTransfer.files);g(R);},[g]),D=useCallback(y=>{let R=y.target.files?Array.from(y.target.files):[];g(R),i.current&&(i.current.value="");},[g]),N=useCallback(()=>{i.current?.click();},[]),A=useCallback(y=>{confirm("Are you sure you want to delete this attachment?")&&a?.(y);},[a]);return jsxs("div",{className:"attachment-uploader",children:[jsxs("div",{className:`attachment-dropzone ${l?"dragging":""} ${p?"uploading":""}`,onDragEnter:x,onDragLeave:b,onDragOver:h,onDrop:w,onClick:N,children:[jsx("input",{ref:i,type:"file",multiple:true,onChange:D,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:l?"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"]})]})})]}),m&&jsxs("div",{className:"attachment-error",children:[jsx("span",{className:"attachment-error-icon",children:"\u26A0\uFE0F"}),jsx("span",{className:"attachment-error-text",children:m})]}),e.length>0&&jsx("div",{className:"attachment-list",children:e.map(y=>jsxs("div",{className:"attachment-item",children:[jsx("div",{className:"attachment-preview",children:Zn(y.type)&&y.url?jsxs("button",{type:"button",className:"attachment-thumbnail-btn",onClick:R=>v(y,R),title:"Click to view full size",children:[jsx("img",{src:y.thumbnailUrl||y.url,alt:y.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:bm(y.type)})}),jsxs("div",{className:"attachment-info",children:[jsx("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",className:"attachment-name",title:y.name,children:y.name}),jsxs("div",{className:"attachment-meta",children:[jsx("span",{className:"attachment-size",children:hm(y.size)}),jsx("span",{className:"attachment-separator",children:"\u2022"}),jsx("span",{className:"attachment-date",children:new Date(y.uploadedAt).toLocaleDateString()})]})]}),jsx("button",{onClick:()=>A(y.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"})})})]},y.id))})]})}function Qn({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:l=[],activities:c=[],aiInsights:p=[],attachments:n=[],onAddComment:m,onDeleteComment:d,onUploadAttachments:i,onDeleteAttachment:u,onSuggestAssignee:v,onGenerateSubtasks:f,onEstimateEffort:g,currentUserId:x="user-1"}){let[b,h]=useState("details"),[w,D]=useState(false),[N,A]=useState({}),[y,R]=useState(""),[T,k]=useState(false),[B,P]=useState({});if(!t||!e)return null;let H=useCallback(()=>{D(false),A({}),h("details"),R(""),P({}),a();},[a]),X=useCallback(()=>{r&&Object.keys(N).length>0&&(r(e.id,N),A({}),D(false));},[e.id,N,r]),be=useCallback(()=>{o&&window.confirm("Are you sure you want to delete this card?")&&(o(e.id),H());},[e.id,o,H]),ke=useCallback(()=>{m&&y.trim()&&(m(e.id,y.trim()),R(""));},[e.id,y,m]),Ae=useCallback(async()=>{if(v){k(true);try{let E=await v(e);P(K=>({...K,assignees:E}));}catch(E){console.error("Failed to suggest assignee:",E);}finally{k(false);}}},[e,v]),Fe=useCallback(async()=>{if(f){k(true);try{let E=await f(e);P(K=>({...K,subtasks:E}));}catch(E){console.error("Failed to generate subtasks:",E);}finally{k(false);}}},[e,f]),z=useCallback(async()=>{if(g){k(true);try{let E=await g(e);P(K=>({...K,effort:E}));}catch(E){console.error("Failed to estimate effort:",E);}finally{k(false);}}},[e,g]),F={...e,...N},W=s.filter(E=>F.assignedUserIds?.includes(E.id));return jsx(rt,{children:jsx("div",{className:"card-detail-overlay",onClick:H,children:jsxs("div",{className:"card-detail-modal",onClick:E=>E.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:F.priority==="URGENT"?"#EF4444":F.priority==="HIGH"?"#F59E0B":F.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),w?jsx("input",{type:"text",value:N.title??F.title,onChange:E=>A({...N,title:E.target.value}),className:"card-detail-title-input",placeholder:"Card title"}):jsx("h2",{className:"card-detail-title",children:F.title})]}),jsxs("div",{className:"card-detail-header-actions",children:[w?jsxs(Fragment,{children:[jsx("button",{onClick:X,className:"card-detail-btn card-detail-btn-primary",children:"Save"}),jsx("button",{onClick:()=>{D(false),A({});},className:"card-detail-btn",children:"Cancel"})]}):jsxs("button",{onClick:()=>D(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:H,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:()=>h("details"),className:`card-detail-tab ${b==="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:()=>h("comments"),className:`card-detail-tab ${b==="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",l.length>0&&jsx("span",{className:"card-detail-tab-badge",children:l.length})]}),jsxs("button",{onClick:()=>h("activity"),className:`card-detail-tab ${b==="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:()=>h("attachments"),className:`card-detail-tab ${b==="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",n.length>0&&jsx("span",{className:"card-detail-tab-badge",children:n.length})]}),jsxs("button",{onClick:()=>h("ai"),className:`card-detail-tab ${b==="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:[b==="details"&&jsxs("div",{className:"card-detail-details",children:[jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Description"}),w?jsx("textarea",{value:N.description??F.description??"",onChange:E=>A({...N,description:E.target.value}),className:"card-detail-textarea",placeholder:"Add a description...",rows:4}):jsx("p",{className:"card-detail-text",children:F.description||"No description"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Assigned To"}),w?jsx("select",{multiple:true,value:N.assignedUserIds??F.assignedUserIds??[],onChange:E=>{let K=Array.from(E.target.selectedOptions,te=>te.value);A({...N,assignedUserIds:K});},className:"card-detail-textarea",style:{height:"120px",padding:"8px 12px"},children:s.map(E=>jsx("option",{value:E.id,children:E.name},E.id))}):jsx("div",{className:"card-detail-users",children:W.length>0?W.map(E=>jsxs("div",{className:"card-detail-user",children:[jsx("div",{className:"card-detail-user-avatar",style:{background:E.color},children:E.initials}),jsx("span",{children:E.name})]},E.id)):jsx("span",{className:"card-detail-empty",children:"Unassigned"})})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Priority"}),w?jsxs("select",{value:N.priority??F.priority??"",onChange:E=>A({...N,priority:E.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:F.priority==="URGENT"?"#EF4444":F.priority==="HIGH"?"#F59E0B":F.priority==="MEDIUM"?"#3B82F6":"#6B7280"}}),jsx("span",{children:F.priority||"None"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Labels"}),jsx("div",{className:"card-detail-labels",children:F.labels&&F.labels.length>0?F.labels.map(E=>jsx("span",{className:"card-detail-label-tag",children:E},E)):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"}),w?jsx("input",{type:"date",value:N.startDate?new Date(N.startDate).toISOString().split("T")[0]:F.startDate?new Date(F.startDate).toISOString().split("T")[0]:"",onChange:E=>A({...N,startDate:E.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:F.startDate?new Date(F.startDate).toLocaleDateString():"Not set"})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"End Date"}),w?jsx("input",{type:"date",value:N.endDate?new Date(N.endDate).toISOString().split("T")[0]:F.endDate?new Date(F.endDate).toISOString().split("T")[0]:"",onChange:E=>A({...N,endDate:E.target.value||void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"}}):jsx("span",{className:"card-detail-text",children:F.endDate?new Date(F.endDate).toLocaleDateString():"Not set"})]})]}),jsxs("div",{className:"card-detail-section",children:[jsx("label",{className:"card-detail-label",children:"Estimated Hours"}),w?jsx("input",{type:"number",min:"0",step:"0.5",value:N.estimatedTime??F.estimatedTime??"",onChange:E=>A({...N,estimatedTime:E.target.value?parseFloat(E.target.value):void 0}),className:"card-detail-textarea",style:{height:"auto",padding:"8px 12px"},placeholder:"Enter hours"}):jsx("span",{className:"card-detail-text",children:F.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:F.dependencies&&F.dependencies.length>0?F.dependencies.map(E=>{let K=typeof E=="string"?E:E.taskId;return jsxs("span",{className:"card-detail-dependency",children:["Card #",K.slice(-4)]},K)}):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:F.createdAt?new Date(F.createdAt).toLocaleString():"Unknown"})]})]}),b==="comments"&&jsxs("div",{className:"card-detail-comments",children:[jsxs("div",{className:"card-detail-comment-form",children:[jsx("textarea",{value:y,onChange:E=>R(E.target.value),className:"card-detail-comment-textarea",placeholder:"Write a comment...",rows:3}),jsx("button",{onClick:ke,disabled:!y.trim(),className:"card-detail-btn card-detail-btn-primary",children:"Add Comment"})]}),jsx("div",{className:"card-detail-comments-list",children:l.length>0?l.map(E=>{let K=s.find(te=>te.id===E.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:[K&&jsx("div",{className:"card-detail-user-avatar",style:{background:K.color},children:K.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-comment-author-name",children:K?.name||"Unknown"}),jsx("div",{className:"card-detail-comment-time",children:new Date(E.createdAt).toLocaleString()})]})]}),d&&jsx("button",{onClick:()=>d(E.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:E.content})]},E.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"})]})})]}),b==="activity"&&jsx("div",{className:"card-detail-activity",children:c.length>0?jsx("div",{className:"card-detail-activity-list",children:c.map(E=>{let K=s.find(te=>te.id===E.userId);return jsxs("div",{className:"card-detail-activity-item",children:[jsxs("div",{className:"card-detail-activity-icon",children:[E.type.includes("CREATED")&&"\u2795",E.type.includes("UPDATED")&&"\u270F\uFE0F",E.type.includes("MOVED")&&"\u27A1\uFE0F",E.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",E.type.includes("COMMENT")&&"\u{1F4AC}",E.type.includes("ASSIGNED")&&"\u{1F464}",E.type.includes("PRIORITY")&&"\u{1F3AF}",E.type.includes("LABEL")&&"\u{1F3F7}\uFE0F",E.type.includes("ATTACHMENT")&&"\u{1F4CE}"]}),jsxs("div",{className:"card-detail-activity-content",children:[jsxs("div",{className:"card-detail-activity-text",children:[jsx("strong",{children:K?.name||"Unknown"})," ",E.type.replace(/_/g," ").toLowerCase(),E.newValue&&jsxs("span",{className:"card-detail-activity-value",children:[" ","to ",jsx("strong",{children:E.newValue})]})]}),jsx("div",{className:"card-detail-activity-time",children:new Date(E.timestamp).toLocaleString()})]})]},E.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"})]})}),b==="attachments"&&jsx("div",{className:"card-detail-attachments",children:jsx($a,{cardId:e.id,attachments:n,onUpload:i?E=>i(e.id,E):void 0,onDelete:u,currentUserId:x,maxSizeMB:10,maxFiles:20})}),b==="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:Ae,disabled:T||!v,className:"card-detail-ai-btn",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"}),jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Suggest Best Assignee"]}),jsxs("button",{onClick:Fe,disabled:T||!f,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:z,disabled:T||!g,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"]})]}),B.assignees&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Assignee Suggestions"}),B.assignees.map((E,K)=>{let te=s.find(O=>O.id===E.userId);return jsxs("div",{className:"card-detail-ai-suggestion",children:[te&&jsx("div",{className:"card-detail-user-avatar",style:{background:te.color},children:te.initials}),jsxs("div",{children:[jsx("div",{className:"card-detail-ai-suggestion-name",children:te?.name}),jsx("div",{className:"card-detail-ai-suggestion-reason",children:E.reasoning}),jsxs("div",{className:"card-detail-ai-suggestion-confidence",children:["Confidence: ",(E.confidence*100).toFixed(0),"%"]})]})]},K)})]}),B.subtasks&&jsxs("div",{className:"card-detail-ai-results",children:[jsx("h4",{children:"Suggested Subtasks"}),B.subtasks.map((E,K)=>jsxs("div",{className:"card-detail-ai-subtask",children:[jsx("div",{className:"card-detail-ai-subtask-title",children:E.title}),E.description&&jsx("div",{className:"card-detail-ai-subtask-desc",children:E.description}),E.estimatedTime&&jsxs("div",{className:"card-detail-ai-subtask-time",children:["Est: ",E.estimatedTime,"h"]})]},K))]}),B.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:[B.effort.hours," hours"]}),jsxs("div",{className:"card-detail-ai-effort-confidence",children:["Confidence: ",(B.effort.confidence*100).toFixed(0),"%"]})]})]}),p.length>0&&jsxs("div",{className:"card-detail-ai-insights",children:[jsx("h4",{children:"AI Insights"}),p.map(E=>jsxs("div",{className:`card-detail-ai-insight card-detail-ai-insight-${E.severity.toLowerCase()}`,children:[jsxs("div",{className:"card-detail-ai-insight-header",children:[jsx("span",{className:"card-detail-ai-insight-title",children:E.title}),jsx("span",{className:"card-detail-ai-insight-severity",children:E.severity})]}),jsx("p",{className:"card-detail-ai-insight-desc",children:E.description}),E.suggestedAction&&jsxs("div",{className:"card-detail-ai-insight-action",children:["\u{1F4A1} ",E.suggestedAction]})]},E.id))]}),!B.assignees&&!B.subtasks&&!B.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 io({triggerRef:e,isOpen:t,onClose:a,children:r,width:o=200,estimatedHeight:s=300,className:l=""}){let[c,p]=useState({top:0,left:0}),n=useRef(null),m=useCallback(()=>{if(!e.current)return {top:0,left:0};let d=e.current.getBoundingClientRect(),i=window.innerHeight,u=window.innerWidth,v=4,f=d.left;f+o>u-10&&(f=u-o-10),f<10&&(f=10);let g=i-d.bottom,x=d.top,b;return g>=s+v?b=d.bottom+v:x>=s+v?b=d.top-s-v:g>=x?b=d.bottom+v:b=Math.max(10,d.top-s-v),{top:b,left:f}},[e,o,s]);return useEffect(()=>{t&&p(m());},[t,m]),useEffect(()=>{if(!t)return;let d=u=>{let v=u.target;n.current&&!n.current.contains(v)&&e.current&&!e.current.contains(v)&&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(rt,{children:jsx("div",{ref:n,className:`smart-popover ${l}`,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 Uo=["#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#22C55E","#10B981","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899"];function $r({selectedTags:e,availableTags:t,onChange:a,onCreateTag:r,theme:o,disabled:s=false,compact:l=true}){let[c,p]=useState(false),[n,m]=useState(""),[d,i]=useState(false),[u,v]=useState(Uo[10]||"#3B82F6"),[f,g]=useState({top:0,left:0}),x=useRef(null),b=useRef(null),h=useRef(null),w=useRef(null),D=t.filter(k=>k.name.toLowerCase().includes(n.toLowerCase())),N=t.some(k=>k.name.toLowerCase()===n.toLowerCase());useEffect(()=>{if(c&&b.current){let k=b.current.getBoundingClientRect();g({top:k.bottom+6,left:k.left});}},[c]),useEffect(()=>{let k=B=>{let P=B.target,H=x.current?.contains(P),X=h.current?.contains(P);!H&&!X&&(p(false),m(""),i(false));};if(c)return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[c]),useEffect(()=>{c&&w.current&&w.current.focus();},[c]);let A=k=>{let B=e.some(P=>P.id===k.id);a(B?e.filter(P=>P.id!==k.id):[...e,k]);},y=async()=>{if(!(!r||!n.trim())){i(true);try{let k=await r(n.trim(),u);k&&(a([...e,k]),m(""),v(Uo[Math.floor(Math.random()*Uo.length)]||"#3B82F6"));}finally{i(false);}}},R=(k,B)=>{B.stopPropagation(),a(e.filter(P=>P.id!==k));},T={backgroundColor:`${o.textTertiary}15`,border:`1px solid ${o.borderLight}`,color:o.textSecondary};return jsxs("div",{ref:x,className:"relative",children:[jsxs("button",{ref:b,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:T,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(k=>jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",style:{backgroundColor:`${k.color}20`,color:k.color},children:k.name},k.id)),e.length>2&&jsxs("span",{className:"text-xs",style:{color:o.textTertiary},children:["+",e.length-2]})]}):jsx("span",{children:"Etiquetas"}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:o.textTertiary}})]}),typeof document<"u"&&createPortal(jsx(AnimatePresence,{children:c&&jsxs(motion.div,{ref:h,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:f.top,left:f.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:w,type:"text",value:n,onChange:k=>m(k.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:k=>{k.key==="Enter"&&n.trim()&&!N&&r&&y();}})}),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(k=>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:`${k.color}20`,color:k.color},onClick:B=>R(k.id,B),children:[k.name,jsx(X,{className:"w-3 h-3"})]},k.id))})]}),jsx("div",{className:"max-h-[200px] overflow-y-auto p-1",children:D.length>0?D.map(k=>{let B=e.some(P=>P.id===k.id);return jsxs("button",{type:"button",onClick:()=>A(k),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",style:{backgroundColor:B?`${k.color}15`:"transparent",color:o.textPrimary},onMouseEnter:P=>{B||(P.currentTarget.style.backgroundColor=o.hoverBg);},onMouseLeave:P=>{B||(P.currentTarget.style.backgroundColor="transparent");},children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:k.color}}),jsx("span",{className:"flex-1 text-left",children:k.name}),B&&jsx(Check,{className:"w-4 h-4",style:{color:k.color}})]},k.id)}):n.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"})}),n.trim()&&!N&&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:Uo.map(k=>jsx("button",{type:"button",onClick:()=>v(k),className:"w-5 h-5 rounded-full transition-transform hover:scale-110",style:{backgroundColor:k,outline:u===k?`2px solid ${k}`:"none",outlineOffset:"2px"}},k))}),jsxs("button",{type:"button",onClick:y,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:u,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 "',n.trim(),'"']})]})]})}),document.body)]})}function as({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 Fl({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(as,{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 Ge={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 Im=["LOW","MEDIUM","HIGH","URGENT"],Lm=["todo","in-progress","review","done"];function os({card:e,isOpen:t,onClose:a,onUpdate:r,onDelete:o,availableUsers:s=[],comments:l=[],activities:c=[],onAddComment:p,onDeleteComment:n,currentUser:m,onAIGenerateDescription:d,onAICreateSubtasks:i,onAIFindSimilar:u,availableColumns:v=[],availableLabels:f=[],availableTags:g=[],onCreateTag:x,onUploadCoverImage:b,unsplashAccessKey:h,theme:w,onSubtasksChange:D,attachments:N=[],onUploadAttachments:A,onDeleteAttachment:y}){let R=Lr(),T=w||R?.themeName||"dark",[k,B]=useState(e),[P,H]=useState(false),[X,be]=useState(e?.subtasks||[]),[ke,Ae]=useState(false),[Fe,z]=useState(""),[F,W]=useState(""),[E,K]=useState("all"),[te,O]=useState(false),[Me,he]=useState(false),[qe,me]=useState(false),[tt,we]=useState(false),[st,ht]=useState(false),[Ft,Xe]=useState(false),$=useRef(null),ne=useRef(null),ve=useRef(null),Te=useRef(null),De=useRef(null),Ye=useRef(null),mt=useRef(null),Ie=useRef(null),I=useRef(null),Y=useRef(null),He=useRef(null),We=useRef(null);useEffect(()=>{e&&!k?(B({...e}),be(e.subtasks||[])):e&&k&&e.id!==k.id&&(B({...e}),be(e.subtasks||[]));},[e,k]),useEffect(()=>{let U=ce=>{let Se=ce.target;Te.current&&!Te.current.contains(Se)&&O(false),De.current&&!De.current.contains(Se)&&he(false),Ye.current&&!Ye.current.contains(Se)&&me(false),mt.current&&!mt.current.contains(Se)&&we(false);};if(te||Me||qe||tt)return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[te,Me,qe,tt]),useEffect(()=>{if(!t)return;let U=ce=>{let Se=ce.target,$t=Se.tagName==="INPUT"||Se.tagName==="TEXTAREA"||Se.isContentEditable;if(ce.key==="Escape"){ce.preventDefault(),te||Me||qe||tt||st||Ft?(O(false),he(false),me(false),we(false),ht(false),Xe(false)):$t||a();return}if($t&&ce.key!=="Escape")return;let ea=ce.metaKey||ce.ctrlKey;switch(ce.key.toLowerCase()){case "s":ce.preventDefault(),O(true);break;case "a":ce.preventDefault(),me(true);break;case "p":ce.preventDefault(),he(true);break;case "l":ce.preventDefault(),we(true);break;case "d":ea||(ce.preventDefault(),ht(true),setTimeout(()=>Ie.current?.focus(),0));break;case "e":ea||(ce.preventDefault(),Xe(true));break;case "i":ce.preventDefault(),H(true),setTimeout(()=>ne.current?.focus(),0);break;case "t":ce.preventDefault(),Ae(true);break;case "c":ce.preventDefault(),ve.current?.focus();break}};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[t,a,te,Me,qe,tt,st,Ft]);let bt=useCallback(U=>{let ce=U.currentTarget.textContent?.trim()||"";if(k&&ce!==k.title){let Se={...k,title:ce};B(Se),r?.(k.id,{title:ce});}},[k,r]),J=useCallback(U=>{U.key==="Enter"&&(U.preventDefault(),U.currentTarget.blur()),U.key==="Escape"&&(U.preventDefault(),U.currentTarget.textContent=k?.title||"",U.currentTarget.blur());},[k]),Q=useCallback(()=>{k&&e&&k.description!==e.description&&r?.(k.id,{description:k.description}),H(false);},[k,e,r]),xe=useCallback(U=>{if(k){let ce={...k,columnId:U};B(ce),r?.(k.id,{columnId:U}),O(false);}},[k,r]),Ce=useCallback(U=>{if(k){let ce={...k,priority:U};B(ce),r?.(k.id,{priority:U}),he(false);}},[k,r]),ae=useCallback(U=>{if(k){let ce=k.assignedUserIds||[],Se=ce.includes(U)?ce.filter(ea=>ea!==U):[...ce,U],$t={...k,assignedUserIds:Se};B($t),r?.(k.id,{assignedUserIds:Se});}},[k,r]),Pe=useCallback(U=>{if(k){let ce=k.labels||[],Se=ce.includes(U)?ce.filter(ea=>ea!==U):[...ce,U],$t={...k,labels:Se};B($t),r?.(k.id,{labels:Se});}},[k,r]),ye=useCallback(U=>{if(k){let ce={...k,tags:U};B(ce),r?.(k.id,{tags:U});}},[k,r]),Ne=useCallback(U=>{if(k){let ce=U.target.value,Se={...k,endDate:ce};B(Se),r?.(k.id,{endDate:ce}),ht(false);}},[k,r]),se=useCallback(U=>{if(k){let ce={...k,estimatedTime:parseFloat(U)||0};B(ce),r?.(k.id,{estimatedTime:parseFloat(U)||0});}},[k,r]),Re=useCallback(()=>{if(Fe.trim()&&k){let U={id:`subtask-${Date.now()}`,title:Fe.trim(),completed:false,createdAt:new Date},ce=[...X,U];be(ce),z(""),Ae(false),D?.(k.id,ce);}},[Fe,X,k,D]),Le=useCallback(U=>{let ce=X.map(Se=>Se.id===U?{...Se,completed:!Se.completed,updatedAt:new Date}:Se);be(ce),k&&D?.(k.id,ce);},[X,k,D]),$e=useCallback(U=>{let ce=X.filter(Se=>Se.id!==U);be(ce),k&&D?.(k.id,ce);},[X,k,D]),_=useCallback(()=>{F.trim()&&k&&p&&(p(k.id,F.trim()),W(""));},[F,k,p]),q=useCallback(U=>{(U.metaKey||U.ctrlKey)&&U.key==="Enter"&&(U.preventDefault(),_());},[_]),at=U=>jsx(Pm,{remarkPlugins:[Mm],rehypePlugins:[Am],components:{a:({node:ce,...Se})=>jsx("a",{...Se,target:"_blank",rel:"noopener noreferrer"})},children:U}),Ue=c.filter(U=>E==="comments"?U.type.includes("COMMENT"):E==="history"?!U.type.includes("COMMENT"):true);if(!t||!e)return null;let le=k||e,Ze=s.filter(U=>le.assignedUserIds?.includes(U.id)),Tt=X.filter(U=>U.completed).length;return jsx(rt,{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:U=>U.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"modal-title","data-theme":T,children:[jsxs("header",{className:"modal-v2-header",children:[jsx("h1",{id:"modal-title",ref:$,className:"modal-v2-title",contentEditable:true,suppressContentEditableWarning:true,onBlur:bt,onKeyDown:J,children:le.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:Te,children:[jsxs("button",{ref:I,className:"modal-v2-field",onClick:()=>O(!te),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:le.columnId||"No status"})]}),jsx(io,{triggerRef:I,isOpen:te,onClose:()=>O(false),width:250,estimatedHeight:200,children:(v.length>0?v:Lm.map(U=>({id:U,title:U}))).map(U=>jsx("button",{className:`modal-v2-popover-item ${le.columnId===U.id?"active":""}`,onClick:()=>xe(U.id),children:U.title},U.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:Ye,children:[jsxs("button",{ref:Y,className:"modal-v2-field",onClick:()=>me(!qe),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:Ze.length>0?jsx("div",{className:"modal-v2-avatars",children:Ze.map(U=>jsx("div",{className:"modal-v2-avatar",style:{background:U.color},title:U.name,children:U.initials},U.id))}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(io,{triggerRef:Y,isOpen:qe,onClose:()=>me(false),width:280,estimatedHeight:300,children:s.map(U=>jsxs("button",{className:`modal-v2-popover-item ${le.assignedUserIds?.includes(U.id)?"active":""}`,onClick:()=>ae(U.id),children:[jsx("div",{className:"modal-v2-avatar-small",style:{background:U.color},children:U.initials}),U.name,le.assignedUserIds?.includes(U.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"})})]},U.id))})]}),jsxs("div",{className:"modal-v2-field-wrapper",ref:De,children:[jsxs("button",{ref:He,className:"modal-v2-field",onClick:()=>he(!Me),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:le.priority||"None"})]}),jsxs(io,{triggerRef:He,isOpen:Me,onClose:()=>he(false),width:180,estimatedHeight:220,children:[Im.map(U=>jsx("button",{className:`modal-v2-popover-item priority-${U.toLowerCase()} ${le.priority===U?"active":""}`,onClick:()=>Ce(U),children:U},U)),jsx("button",{className:"modal-v2-popover-item",onClick:()=>Ce(""),children:"None"})]})]}),g.length>0||x?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($r,{selectedTags:le.tags||[],availableTags:g,onChange:ye,onCreateTag:x,theme:Ge[T]||Ge.dark})})]})}):jsxs("div",{className:"modal-v2-field-wrapper",ref:mt,children:[jsxs("button",{ref:We,className:"modal-v2-field",onClick:()=>we(!tt),children:[jsxs("div",{className:"modal-v2-field-label",children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z"}),jsx("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]}),jsx("span",{children:"Labels"}),jsx("kbd",{className:"modal-v2-shortcut",children:"L"})]}),jsx("div",{className:"modal-v2-field-value",children:le.labels&&le.labels.length>0?jsx("span",{children:le.labels.join(", ")}):jsx("span",{className:"modal-v2-empty",children:"Empty"})})]}),jsx(io,{triggerRef:We,isOpen:tt,onClose:()=>we(false),width:220,estimatedHeight:200,children:(f.length>0?f:["Bug","Feature","Enhancement","Documentation"]).map(U=>jsxs("button",{className:`modal-v2-popover-item ${le.labels?.includes(U)?"active":""}`,onClick:()=>Pe(U),children:[U,le.labels?.includes(U)&&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"})})]},U))})]}),jsxs("button",{className:"modal-v2-field",onClick:()=>{ht(!st),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:le.endDate?new Date(le.endDate).toLocaleDateString():"Not set"}),jsx("input",{ref:Ie,type:"date",value:typeof le.endDate=="string"?le.endDate.split("T")[0]:le.endDate?(()=>{let U=new Date(le.endDate),ce=U.getUTCFullYear(),Se=String(U.getUTCMonth()+1).padStart(2,"0"),$t=String(U.getUTCDate()).padStart(2,"0");return `${ce}-${Se}-${$t}`})():"",onChange:Ne,style:{position:"absolute",opacity:0,pointerEvents:"none"}})]}),jsxs("div",{className:"modal-v2-field-wrapper",children:[jsxs("button",{className:"modal-v2-field",onClick:()=>Xe(!Ft),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:le.estimatedTime?`${le.estimatedTime}h`:"Not set"})]}),Ft&&jsx("div",{className:"modal-v2-popover",children:jsx("input",{type:"number",min:"0",step:"0.5",placeholder:"Hours",value:le.estimatedTime||"",onChange:U=>se(U.target.value),className:"modal-v2-time-input",autoFocus:true,onBlur:()=>Xe(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"})]}),P?jsx("textarea",{className:"modal-v2-textarea",value:le.description||"",onChange:U=>{if(k){let ce={...k,description:U.target.value};B(ce);}},onBlur:Q,placeholder:"Add a detailed description...",autoFocus:true}):jsx("div",{className:"modal-v2-content",onClick:()=>H(true),children:le.description?jsx("div",{className:"modal-v2-markdown",children:at(le.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"}),X.length>0&&jsxs("span",{className:"modal-v2-count",children:[Tt,"/",X.length]}),jsxs("button",{className:"modal-v2-add-button",onClick:()=>Ae(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:[X.map(U=>jsxs("div",{className:`modal-v2-subtask ${U.completed?"completed":""}`,children:[jsx("button",{className:"modal-v2-subtask-checkbox",onClick:()=>Le(U.id),children:U.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:U.title}),jsx("button",{className:"modal-v2-subtask-delete",onClick:()=>$e(U.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"})]})})]},U.id)),ke&&jsx("div",{className:"modal-v2-subtask-input-row",children:jsx("input",{type:"text",placeholder:"Subtask title...",value:Fe,onChange:U=>z(U.target.value),onKeyDown:U=>{U.key==="Enter"&&Re(),U.key==="Escape"&&(Ae(false),z(""));},onBlur:Re,autoFocus:true,className:"modal-v2-subtask-input"})})]})]}),(A||N.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"}),N.length>0&&jsx("span",{className:"modal-v2-count",children:N.length})]}),jsx($a,{cardId:le.id,attachments:N,onUpload:A?U=>A(le.id,U):void 0,onDelete:y,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 ${E==="all"?"active":""}`,onClick:()=>K("all"),children:"All"}),jsx("button",{className:`modal-v2-filter ${E==="comments"?"active":""}`,onClick:()=>K("comments"),children:"Comments"}),jsx("button",{className:`modal-v2-filter ${E==="history"?"active":""}`,onClick:()=>K("history"),children:"History"})]})]}),jsxs("div",{className:"modal-v2-comment-input",children:[m&&jsx("div",{className:"modal-v2-avatar",style:{background:m.color},children:m.initials}),jsxs("div",{className:"modal-v2-comment-wrapper",children:[jsx("textarea",{ref:ve,className:"modal-v2-comment-textarea",placeholder:"Write a comment...",value:F,onChange:U=>W(U.target.value),onKeyDown:q,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:_,disabled:!F.trim(),children:"Send"})]})]})]}),jsxs("div",{className:"modal-v2-timeline",children:[Ue.map(U=>{let ce=s.find($t=>$t.id===U.userId);if(U.type.includes("COMMENT")){let $t=l.find(ea=>ea.id===U.metadata?.commentId);return $t?jsxs("div",{className:"modal-v2-activity-item comment-item",children:[ce&&jsx("div",{className:"modal-v2-avatar",style:{background:ce.color},children:ce.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:ce?.name||"Unknown"}),jsx("span",{className:"modal-v2-activity-time",children:new Date(U.timestamp).toLocaleString()})]}),jsx("div",{className:"modal-v2-comment-body",children:$t.content})]})]},U.id):null}return jsxs("div",{className:"modal-v2-activity-item history-item",children:[jsxs("div",{className:"modal-v2-history-icon",children:[U.type.includes("CREATED")&&"\u2795",U.type.includes("UPDATED")&&"\u270F\uFE0F",U.type.includes("MOVED")&&"\u27A1\uFE0F",U.type.includes("DELETED")&&"\u{1F5D1}\uFE0F",U.type.includes("ASSIGNED")&&"\u{1F464}",U.type.includes("PRIORITY")&&"\u{1F3AF}",U.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:ce?.name||"Unknown"})," ",U.type.replace(/_/g," ").toLowerCase(),U.newValue&&jsxs(Fragment,{children:[" to ",jsx("strong",{children:U.newValue})]})]}),jsx("span",{className:"modal-v2-activity-time",children:new Date(U.timestamp).toLocaleString()})]})]},U.id)}),Ue.length===0&&jsxs("div",{className:"modal-v2-empty",children:[jsx("p",{children:"No activity yet"}),jsx("span",{children:"Activity will appear here"})]})]})]})]})})})}function Hm({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 ss({data:e,title:t="Team Velocity",height:a=300,showAverage:r=true,showPlanned:o=true}){let s=e.map(l=>({...l,average:l.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(Hm,{})}),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((l,c)=>l+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((l,c)=>l+c.completed,0)/e.length).toFixed(1)})]}),o&&e.some(l=>l.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((l,c)=>l+(c.planned||0),0)})]})]})]})}function Jm({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 is({data:e,title:t="Sprint Burndown",height:a=300,totalTasks:r,useArea:o=false}){let s=r??(e[0]?.ideal||e[0]?.remaining||0),l=e[e.length-1]?.remaining||0,c=e[e.length-1]?.ideal||0,p=s>0?(s-l)/s*100:0,n=l<=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(Jm,{})}),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:n?"#10B981":"#EF4444",fill:n?"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:n?"#10B981":"#EF4444",strokeWidth:3,name:"Remaining",dot:{fill:n?"#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:n?"#10B981":"#EF4444"},children:l})]}),jsxs("div",{className:"chart-stat",children:[jsx("span",{className:"chart-stat-label",children:"Status"}),jsx("span",{className:"chart-stat-badge",style:{background:n?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:n?"#10B981":"#EF4444"},children:n?"\u2713 On Track":"\u26A0 Behind"})]})]})]})}var su={URGENT:"#EF4444",HIGH:"#F59E0B",MEDIUM:"#3B82F6",LOW:"#10B981"},Wl=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899"];function iu({cx:e,cy:t,midAngle:a,innerRadius:r,outerRadius:o,percent:s}){let l=r+(o-r)*.5,c=e+l*Math.cos(-a*(Math.PI/180)),p=t+l*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 Hl({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 ls({data:e,title:t="Distribution",type:a="pie",height:r=300,showPercentages:o=true}){let s=e.reduce((p,n)=>p+n.value,0),l=e.map(p=>({...p,totalValue:s,color:p.color||su[p.name]||Wl[e.indexOf(p)%Wl.length]})),c=l.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:l,cx:"50%",cy:"50%",labelLine:false,label:o?iu:false,outerRadius:r*.35,fill:"#8884d8",dataKey:"value",children:l.map((p,n)=>jsx(Cell,{fill:c[n]},`cell-${n}`))}),jsx(Tooltip,{content:jsx(Hl,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"},formatter:(p,n)=>{let m=n.payload,d=s>0?(m.value/s*100).toFixed(0):"0";return `${p} (${m.value} - ${d}%)`}})]}):jsxs(BarChart,{data:l,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(Hl,{})}),jsx(Legend,{wrapperStyle:{fontSize:"12px",color:"rgba(255, 255, 255, 0.7)"}}),jsx(Bar,{dataKey:"value",name:"Count",radius:[8,8,0,0],children:l.map((p,n)=>jsx(Cell,{fill:c[n]},`cell-${n}`))})]})}),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,n)=>n.value>p.value?n:p).name})]})]})]})}var Ho=memo(({selectedCards:e,availableUsers:t=[],onClearSelection:a,callbacks:r,columns:o=[],availableLabels:s=[]})=>{let[l,c]=useState(false),[p,n]=useState(false),[m,d]=useState(false),[i,u]=useState(false);if(e.length===0)return null;let v=e.map(w=>w.id),f=w=>{r.onBulkUpdate?.(v,{priority:w}),c(false);},g=w=>{r.onBulkMove?.(v,w),n(false),a();},x=w=>{r.onBulkUpdate?.(v,{assignedUserIds:w}),d(false);},b=w=>{let D=new Set;e.forEach(A=>{A.labels?.forEach(y=>D.add(y));});let N=Array.from(new Set([...D,...w]));r.onBulkUpdate?.(v,{labels:N}),u(false);},h=()=>{confirm(`Delete ${e.length} card(s)? This cannot be undone.`)&&(r.onBulkDelete?.(v),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(!l),title:"Update priority",children:jsx("span",{className:"text-sm",children:"Priority"})}),l&&jsx("div",{className:"asakaa-bulk-menu",children:["LOW","MEDIUM","HIGH","URGENT"].map(w=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>f(w),children:[jsx("span",{className:C("asakaa-priority-dot",w==="LOW"&&"bg-asakaa-priority-low",w==="MEDIUM"&&"bg-asakaa-priority-medium",w==="HIGH"&&"bg-asakaa-priority-high",w==="URGENT"&&"bg-asakaa-priority-urgent")}),w]},w))})]}),o.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>n(!p),title:"Move to column",children:jsx("span",{className:"text-sm",children:"Move"})}),p&&jsx("div",{className:"asakaa-bulk-menu",children:o.map(w=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>g(w.id),children:w.title},w.id))})]}),t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>d(!m),title:"Assign users",children:jsx("span",{className:"text-sm",children:"Assign"})}),m&&jsx("div",{className:"asakaa-bulk-menu",children:t.map(w=>jsxs("button",{className:"asakaa-bulk-menu-item",onClick:()=>x([w.id]),children:[jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs font-medium",style:{backgroundColor:w.color},children:w.initials}),w.name]},w.id))})]}),s.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{className:"asakaa-bulk-toolbar-button",onClick:()=>u(!i),title:"Add labels",children:jsx("span",{className:"text-sm",children:"Labels"})}),i&&jsx("div",{className:"asakaa-bulk-menu",children:s.map(w=>jsx("button",{className:"asakaa-bulk-menu-item",onClick:()=>b([w]),children:w},w))})]}),jsx("button",{className:"asakaa-bulk-toolbar-button asakaa-bulk-toolbar-button-danger",onClick:h,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"})})]})]})})});Ho.displayName="BulkOperationsToolbar";function mu(e,t,a){if(t==="none")return [];let r=new Map;return e.forEach(o=>{let s,l,c,p,n;switch(t){case "assignee":let m=o.assignedUserIds||(o.assigneeId?[o.assigneeId]:[]);m.length>0?m.forEach(u=>{let v=a?.find(f=>f.id===u);l=`assignee-${u}`,c=v?.name||`User ${u}`,p=v?.color,n=v?.avatar,r.has(l)||r.set(l,{id:l,title:c,groupValue:u,cardIds:[],color:p,icon:n}),r.get(l).cardIds.push(o.id);}):(l="assignee-unassigned",c="Unassigned",p="#6b7280",n="\u{1F464}",r.has(l)||r.set(l,{id:l,title:c,groupValue:null,cardIds:[],color:p,icon:n}),r.get(l).cardIds.push(o.id));break;case "priority":s=o.priority||"NONE",l=`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(l)||r.set(l,{id:l,title:c,groupValue:s,cardIds:[],color:p}),r.get(l).cardIds.push(o.id);break;case "label":o.labels&&o.labels.length>0?o.labels.forEach(u=>{l=`label-${u}`,c=u,p="#6b7280",r.has(l)||r.set(l,{id:l,title:c,groupValue:u,cardIds:[],color:p}),r.get(l).cardIds.push(o.id);}):(l="label-none",c="No Labels",p="#6b7280",r.has(l)||r.set(l,{id:l,title:c,groupValue:null,cardIds:[],color:p}),r.get(l).cardIds.push(o.id));break}}),Array.from(r.values()).sort((o,s)=>o.title.localeCompare(s.title))}function ds({board:e,swimlaneConfig:t,availableUsers:a,callbacks:r,className:o}){let[s,l]=useState(new Set),c=useMemo(()=>mu(e.cards,t.groupBy,a),[e.cards,t.groupBy,a]),p=useCallback(n=>{l(m=>{let d=new Set(m);return d.has(n)?d.delete(n):d.add(n),d});},[]);return t.groupBy==="none"||c.length===0?jsx(er,{board:e,callbacks:r,availableUsers:a,className:o}):jsxs("div",{className:C("asakaa-swimlane-view",o),children:[c.map(n=>{let m=s.has(n.id),d=e.cards.filter(u=>n.cardIds.includes(u.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(n.id),style:{borderLeft:n.color?`4px solid ${n.color}`:void 0},children:[jsxs("div",{className:"flex items-center gap-3",children:[n.icon&&jsx("span",{className:"text-2xl leading-none",children:n.icon}),jsx("h3",{className:"text-lg font-semibold",style:{color:n.color},children:n.title}),jsxs("span",{className:"text-sm text-white/50 font-medium",children:["(",n.cardIds.length," ",n.cardIds.length===1?"card":"cards",")"]})]}),t.collapsible&&jsx("button",{className:"text-white/50 hover:text-white transition-colors","aria-label":m?"Expand lane":"Collapse lane",children:m?"\u25B6":"\u25BC"})]}),!m&&jsx("div",{className:"asakaa-swimlane-content p-4",children:jsx(er,{board:i,callbacks:r,availableUsers:a})})]},n.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 cs=[{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 ps({value:e,onChange:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null),c=cs.find(n=>n.value===e)||cs[0];useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let p=n=>{t(n),o(false);};return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg 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:C("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[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:cs.map(n=>jsxs("button",{onClick:()=>p(n.value),className:C("w-full px-3 py-2 flex items-start gap-3 text-left transition-all hover:bg-white/10",e===n.value&&"bg-white/5"),children:[jsx("span",{className:"text-xl leading-none mt-0.5",children:n.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:n.label}),e===n.value&&jsx("span",{className:"text-blue-400 text-xs",children:"\u2713"})]}),jsx("p",{className:"text-xs text-white/60 mt-0.5",children:n.description})]})]},n.value))})]})]})}var co=[{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 fu(e,t){if(!(Array.isArray(t.keys)?t.keys:[t.keys]).some(n=>e.key===n||e.code===n))return false;let o=t.modifiers||{},s=o.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,l=o.shift?e.shiftKey:!e.shiftKey,c=o.alt?e.altKey:!e.altKey,p=o.meta?e.metaKey:true;return s&&l&&c&&p}function Kl(e={}){let{shortcuts:t=co,enabled:a=true,preventDefault:r=true}=e,o=useRef(t),s=useRef(a);useEffect(()=>{o.current=t,s.current=a;},[t,a]);let l=useCallback(p=>{o.current=[...o.current,p];},[]),c=useCallback(p=>{o.current=o.current.filter(n=>n.action!==p);},[]);return useEffect(()=>{function p(n){if(!s.current)return;let m=n.target;if(!((m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.isContentEditable)&&n.key!=="Escape"&&!n.ctrlKey&&!n.metaKey)){for(let d of o.current)if(fu(n,d)){r&&n.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:l,unregisterShortcut:c,isEnabled:a}}function bu(e){return {ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192",Enter:"\u21B5",Escape:"Esc",Delete:"Del"," ":"Space"}[e]||e.toUpperCase()}function yu(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 vu(e){let t=Array.isArray(e.keys)?e.keys[0]:e.keys,a=yu(e),r=t?bu(t):"";return a?`${a} + ${r}`:r}function xu(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 ms({shortcuts:e=co,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 l=xu(e);return jsxs("div",{className:C("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(l).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(n=>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:n.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:vu(n)})]},n.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 us=[{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 fs({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null);useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=n=>{t(n),o(false);},p=e.reduce((n,m)=>{let d=m.category||"Other";return n[d]||(n[d]=[]),n[d].push(m),n},{});return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg border transition-all text-sm font-medium shadow-lg",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-primary)"},onMouseEnter:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",n.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",n.currentTarget.style.borderColor="var(--theme-border-primary)";},title:"Create from template",children:[jsx("span",{className:"text-base leading-none",children:"\u{1F4CB}"}),jsx("span",{children:"Templates"}),jsx("svg",{className:C("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[320px] max-w-[400px] rounded-xl backdrop-blur-xl border shadow-2xl z-50 overflow-hidden max-h-[500px] overflow-y-auto",style:{backgroundColor:"var(--theme-bg-primary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-4 py-3 border-b sticky top-0 backdrop-blur-sm",style:{borderColor:"var(--theme-border-primary)",backgroundColor:"var(--theme-bg-secondary)"},children:[jsx("span",{className:"text-sm font-bold uppercase tracking-wider",style:{color:"var(--theme-text-primary)"},children:"Card Templates"}),jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:"Quick start with pre-configured cards"})]}),Object.entries(p).map(([n,m])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:n})}),jsx("div",{children:m.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},n)),e.length===0&&jsx("div",{className:"px-4 py-8 text-center",style:{color:"var(--theme-text-tertiary)"},children:jsx("p",{className:"text-sm",children:"No templates available"})})]})]})}function bs({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[l,c]=useState("export"),[p,n]=useState("json"),[m,d]=useState(null),i=useRef(null);if(!t)return null;let u=async()=>{let f=o?.current||void 0,g=await Wi(e,p,f);Hi(g,p);},y=async f=>{let g=f.target.files?.[0];if(g){try{let x=await Vi(g),b=g.name.endsWith(".json")?"json":"csv",h=_i(x,b);d(h),h.success&&r&&r(h,x);}catch(x){d({success:false,errors:[`Failed to read file: ${x instanceof Error?x.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:C("fixed inset-0 z-[9999] flex items-center justify-center",s),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-2xl w-full mx-4",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u{1F4E6}"}),"Export / Import"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Transfer your board data"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsxs("div",{className:"flex border-b border-white/10",children:[jsx("button",{onClick:()=>c("export"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[l==="export"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Select format"}),jsx("div",{className:"grid grid-cols-3 gap-3",children:["json","csv","pdf"].map(f=>jsxs("button",{onClick:()=>n(f),className:C("p-4 rounded-lg border-2 transition-all text-center",p===f?"border-blue-500 bg-blue-500/20 text-white":"border-white/20 hover:border-white/40 text-white/70 hover:text-white"),children:[jsxs("div",{className:"text-2xl mb-2",children:[f==="json"&&"\u{1F4C4}",f==="csv"&&"\u{1F4CA}",f==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:f})]},f))})]}),jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:"Preview"}),jsxs("div",{className:"text-xs text-white/60",children:[jsxs("div",{children:["Board: ",jsx("span",{className:"text-white/90",children:e.title||"Untitled"})]}),jsxs("div",{children:["Columns: ",jsx("span",{className:"text-white/90",children:e.columns.length})]}),jsxs("div",{children:["Cards: ",jsx("span",{className:"text-white/90",children:e.cards.length})]})]})]}),jsx("button",{onClick:u,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),l==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:i,type:"file",accept:".json,.csv",onChange:y,className:"hidden"}),jsxs("button",{onClick:()=>i.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),m&&jsxs("div",{className:C("p-4 rounded-lg",m.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:C("font-semibold mb-2",m.success?"text-green-400":"text-red-400"),children:m.success?"\u2713 Import Successful":"\u2717 Import Failed"}),m.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",m.cardsImported]}),jsxs("div",{children:["Columns imported: ",m.columnsImported]})]}),m.errors&&m.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:m.errors.map((f,g)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",f]},g))})]})]})]})]})]})}var ku=["URGENT","HIGH","MEDIUM","LOW"],wu=[{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"}],Cu=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function ys({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:l,onFilterHighPriority:c,availableUsers:p=[],availableLabels:n=[],availableColumns:m=[],showQuickFilters:d=true,compact:i=false,groupBy:u="none",onGroupByChange:y}){let[f,g]=useState(true),x=useCallback(N=>{a({search:N.target.value});},[a]),b=useCallback(N=>{a({dateFilter:N.target.value});},[a]),h=useCallback(N=>{r({by:N.target.value});},[r]),w=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),D=e.search||e.dateFilter!=="all"||e.priorities.length>0||e.assignees.length>0||e.labels.length>0||t.by!=="none";return jsxs("div",{className:`filter-bar ${i?"filter-bar--compact":""} ${f?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>g(!f),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:f?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:N=>{N.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:f?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.2s",color:"var(--theme-text-secondary)"},children:jsx("polyline",{points:"6 9 12 15 18 9"})}),jsx("span",{className:"filter-bar__label",style:{fontWeight:500,fontSize:"0.875rem",color:"var(--theme-text-primary)"},children:"Filters & Grouping"}),D&&jsxs("span",{style:{color:"var(--theme-accent-primary)",fontSize:"0.75rem",fontWeight:600},children:["(",[e.search&&"search",e.dateFilter!=="all"&&"date",e.priorities.length>0&&"priority",e.assignees.length>0&&"assignee",e.labels.length>0&&"label",t.by!=="none"&&"sort"].filter(Boolean).length," active)"]})]}),!f&&jsxs("div",{className:"filter-bar__content",children:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),l&&jsx("button",{onClick:l,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),c&&jsx("button",{onClick:c,className:"filter-bar__quick-btn",title:"Show high priority tasks",children:"High Priority"})]}),jsxs("div",{className:"filter-bar__main",children:[jsx("div",{className:"filter-bar__field",children:jsx("input",{type:"text",placeholder:"Search tasks...",value:e.search,onChange:x,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:b,className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Dates"}),jsx("option",{value:"overdue",children:"Overdue"}),jsx("option",{value:"today",children:"Today"}),jsx("option",{value:"this-week",children:"This Week"})]})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.priorities[0]||"all",onChange:N=>{let M=N.target.value;a({priorities:M==="all"?[]:[M]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),ku.map(N=>jsx("option",{value:N,children:N},N))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:N=>{let M=N.target.value;a({assignees:M==="all"?[]:[M]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(N=>jsx("option",{value:N.id,children:N.name},N.id))]})}),n.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:N=>{let M=N.target.value;a({labels:M==="all"?[]:[M]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),n.map(N=>jsx("option",{value:N,children:N},N))]})}),jsxs("div",{className:"filter-bar__field filter-bar__sort",children:[jsx("span",{className:"filter-bar__label",style:{color:"var(--theme-text-secondary)"},children:"Sort:"}),jsx("select",{value:t.by,onChange:h,className:"filter-bar__select filter-bar__select--sm",children:wu.map(N=>jsx("option",{value:N.value,children:N.label},N.value))}),t.by!=="none"&&jsx("button",{onClick:w,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),y&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:u,onChange:N=>y(N.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Cu.map(N=>jsx("option",{value:N.value,children:N.label},N.value))})}),D&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function vs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:l,onExportGanttPNG:c,onExportGanttCSV:p}){let[n,m]=useState(false),d=useRef(null);useEffect(()=>{let u=y=>{d.current&&!d.current.contains(y.target)&&m(false);};return n&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[n]);let i=u=>{u(),m(false);};return jsxs("div",{className:C("relative",r),ref:d,children:[jsxs("button",{onClick:()=>m(!n),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",u.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",u.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":n,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"3"}),jsx("path",{d:"M12 1v6m0 6v6M5.6 5.6l4.2 4.2m4.2 4.2l4.2 4.2M1 12h6m6 0h6M5.6 18.4l4.2-4.2m4.2-4.2l4.2-4.2"})]}),jsx("span",{children:"Config"})]}),n&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>i(e),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Export"]}):jsxs(Fragment,{children:[jsxs("button",{onClick:()=>i(async()=>await s?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Export PDF"]}),jsxs("button",{onClick:()=>i(async()=>await l?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),"Export Excel"]}),jsxs("button",{onClick:()=>i(async()=>await c?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Export PNG"]}),jsxs("button",{onClick:()=>i(()=>p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]}),"Export CSV"]})]}),jsxs("button",{onClick:()=>i(t),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v6m0 6v6m8.5-8.5L17 15M7 9L3.5 5.5M7 15l-3.5 3.5M20.5 5.5L17 9m3.5 11.5L17 17"})]}),"Themes"]}),jsxs("button",{onClick:()=>i(a),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),"Shortcuts"]})]})]})}var xs={name:"dark",displayName:"Dark (Enhanced)",emoji:"\u{1F319}",colors:{bgPrimary:"#222326",bgSecondary:"#2A2B2F",bgTertiary:"#33343A",bgCard:"#2d2d2d",bgHover:"#353535",bgActive:"#404040",bgInput:"#2a2a2a",textPrimary:"#F4F5F8",textSecondary:"#AEB6C0",textTertiary:"#7A7F8A",textDisabled:"#606060",textInverse:"#1a1a1a",borderPrimary:"rgba(255, 255, 255, 0.1)",borderSecondary:"rgba(255, 255, 255, 0.05)",borderDefault:"#404040",borderHover:"#505050",borderSubtle:"#2a2a2a",accentPrimary:"#5E6AD2",accentHover:"#7780DD",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.1)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.2)",success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6",danger:"#ef4444",dangerBorder:"rgba(239, 68, 68, 0.3)",dangerBackground:"rgba(239, 68, 68, 0.1)",dangerBackgroundHover:"rgba(239, 68, 68, 0.2)"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.3)",md:"0 4px 12px rgba(0, 0, 0, 0.4)",lg:"0 12px 32px rgba(0, 0, 0, 0.5)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},ks={name:"light",displayName:"Light (Standard)",emoji:"\u2600\uFE0F",colors:{bgPrimary:"#FFFFFF",bgSecondary:"#F7F7F8",bgTertiary:"#EEEFF1",bgCard:"#ffffff",bgHover:"#f3f4f6",bgActive:"#e5e7eb",bgInput:"#f9fafb",textPrimary:"#1A1A1A",textSecondary:"#5A5A5A",textTertiary:"#8A8A8A",textDisabled:"#d1d5db",textInverse:"#ffffff",borderPrimary:"rgba(0, 0, 0, 0.1)",borderSecondary:"rgba(0, 0, 0, 0.05)",borderDefault:"#e5e7eb",borderHover:"#d1d5db",borderSubtle:"#f3f4f6",accentPrimary:"#5E6AD2",accentHover:"#4A56B8",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.08)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.15)",success:"#059669",warning:"#D97706",error:"#DC2626",info:"#2563EB",danger:"#dc2626",dangerBorder:"rgba(220, 38, 38, 0.3)",dangerBackground:"rgba(220, 38, 38, 0.08)",dangerBackgroundHover:"rgba(220, 38, 38, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.12)",md:"0 4px 12px rgba(0, 0, 0, 0.15)",lg:"0 12px 32px rgba(0, 0, 0, 0.2)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},ws={name:"neutral",emoji:"\u26AA",displayName:"Neutral (Zen)",colors:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgTertiary:"#E7E5E4",bgCard:"#FEFEFE",bgHover:"#F0EFEE",bgActive:"#E7E5E4",bgInput:"#FAFAF9",textPrimary:"#1C1917",textSecondary:"#57534E",textTertiary:"#A8A29E",textDisabled:"#D6D3D1",textInverse:"#FAFAF9",borderPrimary:"#E7E5E4",borderSecondary:"#F0EFEE",borderDefault:"#E7E5E4",borderHover:"#D6D3D1",borderSubtle:"#F5F5F4",accentPrimary:"#292524",accentHover:"#44403C",interactivePrimary:"#292524",interactivePrimaryHover:"#44403C",interactivePrimaryBorder:"rgba(41, 37, 36, 0.3)",interactivePrimaryBackground:"rgba(41, 37, 36, 0.06)",interactivePrimaryBackgroundHover:"rgba(41, 37, 36, 0.12)",success:"#15803D",warning:"#CA8A04",error:"#B91C1C",info:"#1D4ED8",danger:"#B91C1C",dangerBorder:"rgba(185, 28, 28, 0.3)",dangerBackground:"rgba(185, 28, 28, 0.08)",dangerBackgroundHover:"rgba(185, 28, 28, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.1)",md:"0 4px 12px rgba(0, 0, 0, 0.12)",lg:"0 12px 32px rgba(0, 0, 0, 0.15)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},hr={dark:xs,light:ks,neutral:ws},jo="dark";var Ko=createContext(void 0),Lu="asakaa-theme";function Kl({children:e,defaultTheme:t=jo,storageKey:a=Lu}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,p=hr[r];Object.entries(p.colors).forEach(([m,d])=>{d&&c.style.setProperty(`--theme-${Fu(m)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([m,d])=>{let i=p.colors[m];i&&c.style.setProperty(d,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let l={theme:r,setTheme:s,themes:hr};return jsx(Ko.Provider,{value:l,children:e})}function $r(){let e=useContext(Ko);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function Fu(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Cs({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=$r();return e?jsxs("div",{className:C("fixed inset-0 z-[9999] flex items-center justify-center",a),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),jsxs("div",{className:"relative rounded-2xl border shadow-2xl max-w-md w-full mx-4",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-6 py-5 border-b flex items-center justify-between",style:{borderColor:"var(--theme-border-primary)"},children:[jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--theme-text-primary)"},children:"Select Theme"}),jsx("button",{onClick:t,className:"text-2xl leading-none p-2 hover:bg-white/10 rounded-lg transition-colors",style:{color:"var(--theme-text-secondary)"},"aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"p-6 space-y-3",children:Object.entries(hr).map(([s,l])=>jsxs("button",{onClick:()=>{o(s),t();},className:C("w-full p-4 rounded-lg border-2 transition-all flex items-center gap-4",r===s?"border-blue-500 bg-blue-500/20":"border-white/20 hover:border-white/40"),style:{backgroundColor:r===s?"var(--theme-accent-primary)20":"transparent"},children:[jsx("div",{className:"text-3xl",children:l.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:l.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Yl(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Ge[e]||Ge.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,l)=>a.getPropertyValue(s).trim()||l;return {bgPrimary:r("--theme-bg-primary",Ge[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Ge[e].bgSecondary),bgGrid:r("--theme-bg-card",Ge[e].bgGrid),bgWeekend:r("--theme-bg-hover",Ge[e].bgWeekend),border:r("--theme-border-primary",Ge[e].border),borderLight:r("--theme-border-subtle",Ge[e].borderLight),textPrimary:r("--theme-text-primary",Ge[e].textPrimary),textSecondary:r("--theme-text-secondary",Ge[e].textSecondary),textTertiary:r("--theme-text-tertiary",Ge[e].textTertiary),accent:r("--theme-accent-primary",Ge[e].accent),accentHover:r("--theme-accent-hover",Ge[e].accentHover),accentLight:r("--theme-accent-primary",Ge[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Ge[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Ge[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Ge[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Ge[e].dependency),dependencyHover:r("--theme-border-secondary",Ge[e].dependencyHover),criticalPath:r("--theme-error",Ge[e].criticalPath),criticalPathLight:r("--theme-error",Ge[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Ge[e].today):e==="neutral"?r("--theme-text-primary",Ge[e].today):r("--theme-error",Ge[e].today),todayLight:e==="light"?r("--theme-accent-primary",Ge[e].todayLight):e==="neutral"?r("--theme-text-primary",Ge[e].todayLight):r("--theme-error",Ge[e].todayLight),milestone:r("--theme-warning",Ge[e].milestone),milestoneLight:r("--theme-warning",Ge[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Ge[e].statusTodo),statusInProgress:r("--theme-accent-primary",Ge[e].statusInProgress),statusCompleted:r("--theme-success",Ge[e].statusCompleted),hoverBg:r("--theme-bg-hover",Ge[e].hoverBg),focusRing:r("--theme-accent-primary",Ge[e].focusRing)}}var Yo={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},ql={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},Ts={en:Yo,es:ql};function Xl(e){return Ts[e]||Ts.en}function Ds(e,t){let a=Xl(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},contextMenu:{...a.contextMenu,...t.contextMenu},actions:{...a.actions,...t.actions},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},ai:{...a.ai,...t.ai,suggestions:{...a.ai.suggestions,...t.ai?.suggestions},errors:{...a.ai.errors,...t.ai?.errors}},export:{...a.export,...t.export},dateFormat:{...a.dateFormat,...t.dateFormat}}:a}var Wr=createContext(Yo);function po(){return useContext(Wr)}function Ju({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:l}){let[c,p]=useState(false),[n,m]=useState(null),d=useRef(null),i=po();if(useEffect(()=>{let g=x=>{d.current&&!d.current.contains(x.target)&&p(false);};return c&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[c]),!(t||a||r||o||s||l))return null;let y=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:l}].filter(g=>g.handler),f=async(g,x)=>{if(x){m(g);try{await x();}catch(b){console.error(`Export ${g} failed:`,b);}finally{m(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:i.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:y.map((g,x)=>jsxs(motion.button,{onClick:()=>f(g.id,g.handler),disabled:n!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:x<y.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:x*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:n===g.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):g.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:g.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:g.description})]})]},g.id))})})})]})}function Zu({options:e,value:t,onChange:a,theme:r,layoutId:o="activeSegment"}){return jsx("div",{className:"inline-flex p-1 rounded-lg relative",style:{backgroundColor:r.bgSecondary,border:`1px solid ${r.borderLight}`},children:e.map(s=>{let l=t===s.value;return jsxs(motion.button,{onClick:()=>a(s.value),className:"relative px-3 py-1.5 rounded-md text-xs transition-all flex items-center gap-1.5 min-w-[70px] justify-center",style:{color:l?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500,zIndex:l?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[l&&jsx(motion.div,{layoutId:o,className:"absolute inset-0 rounded-md",style:{backgroundColor:r.accent,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},transition:{type:"spring",stiffness:400,damping:30}}),s.icon&&jsx("span",{className:"relative z-10",style:{color:l?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:l?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function Qu({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 eg({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),l=po();useEffect(()=>{let n=m=>{s.current&&!s.current.contains(m.target)&&o(false);};return r&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=[{value:"compact",label:l.toolbar.compact||"Compact"},{value:"comfortable",label:l.toolbar.normal||"Normal"},{value:"spacious",label:l.toolbar.spacious||"Spacious"}],p=c.find(n=>n.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${l.toolbar.density||"Density"}: ${p}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:c.map((n,m)=>{let d=t===n.value;return jsxs(motion.button,{onClick:()=>{a(n.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent",borderBottom:m<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:n.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},n.value)})})})})]})}function qo({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:l,rowDensity:c,onRowDensityChange:p,showThemeSelector:n=false,showCreateTaskButton:m=false,createTaskLabel:d,onCreateTask:i,onExportPNG:u,onExportPDF:y,onExportExcel:f,onExportCSV:g,onExportJSON:x,onExportMSProject:b}){let h=po(),w=u||y||f||g||x||b,D=[{value:"day",label:h.toolbar.day},{value:"week",label:h.toolbar.week},{value:"month",label:h.toolbar.month}],N=[{value:"dark",label:"Dark",icon:jsx(Moon,{className:"w-3.5 h-3.5"})},{value:"light",label:"Light",icon:jsx(Sun,{className:"w-3.5 h-3.5"})},{value:"neutral",label:"Zen",icon:jsx(Palette,{className:"w-3.5 h-3.5"})}];return jsxs("div",{className:"h-12 px-4 flex items-center justify-between border-b",style:{backgroundColor:e.bgGrid,borderColor:e.border},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(Qu,{options:D,value:t,onChange:M=>a(M),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(eg,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[m&&i&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:i,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:d||h.toolbar.createTask})]}),(w||n)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),w&&jsxs(Fragment,{children:[jsx(Ju,{theme:e,onExportPNG:u,onExportPDF:y,onExportExcel:f,onExportCSV:g,onExportJSON:x,onExportMSProject:b}),n&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),n&&jsx(Zu,{options:N,value:s,onChange:M=>l(M),theme:e})]})]})}function Xo({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,l]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let m=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[r]);let n=e.filter(m=>m.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let m=p.current.getBoundingClientRect();l({x:m.left,y:m.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(tt,{children:jsx(motion.div,{ref:c,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),n.map(m=>jsxs("button",{onClick:()=>{t(m.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:m.label}),m.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},m.id))]})})})})]})}function Hr({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let l=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let m=200,d=r.length*36+8,i=8,u=window.innerWidth,y=window.innerHeight,f=t,g=a;t+m+i>u&&(f=t-m,f<i&&(f=i)),a+d+i>y&&(g=y-d-i,g<i&&(g=i)),p({x:f,y:g});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let m=i=>{l.current&&!l.current.contains(i.target)&&o();},d=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",m),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let n=m=>m.startsWith("#")&&(m.length===7||m.length===4)?m:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:l,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:n(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(m=>jsxs("div",{children:[m.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{m.disabled||(m.onClick(),o());},disabled:m.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:m.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:m.disabled?"not-allowed":"pointer",opacity:m.disabled?.5:1},onMouseEnter:d=>{m.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[m.icon&&jsx("span",{style:{color:s.textSecondary},children:m.icon}),jsx("span",{className:"flex-1",children:m.label}),m.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},m.id))})})})}var kt={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 dd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:l,onTaskIndent:c,onTaskOutdent:p,onTaskRename:n,onTaskToggleExpand:m,onOpenTaskModal:d,enableKeyboard:i=true}){let u=useRef(false),y=useCallback(h=>{u.current=h;},[]),f=useCallback(h=>{let w=[],D=N=>{for(let M of N)w.push(M),M.subtasks&&M.subtasks.length>0&&M.isExpanded&&D(M.subtasks);};return D(h),w},[]),g=useCallback(()=>{let h=f(e);for(let w of h)if(t.has(w.id))return w;return null},[e,t,f]),x=useCallback((h,w)=>{let D=f(e);if(D.length===0)return;let N=g();if(!N){a(D[0].id,false);return}let M=D.findIndex(T=>T.id===N.id);if(M===-1)return;let v=h==="up"?M-1:M+1;if(v<0||v>=D.length)return;let L=D[v];a(L.id,w);},[e,g,f,a]),b=useCallback(h=>{if(!i)return;let w=h.target;if(w.tagName==="INPUT"||w.tagName==="TEXTAREA"||w.isContentEditable||u.current){h.key==="Escape"&&(w.blur(),u.current=false);return}let M=navigator.platform.toUpperCase().indexOf("MAC")>=0?h.metaKey:h.ctrlKey,v=Array.from(t),L=g();if(h.key==="ArrowUp"){h.preventDefault(),x("up",h.shiftKey);return}if(h.key==="ArrowDown"){h.preventDefault(),x("down",h.shiftKey);return}if(L&&(h.key==="ArrowRight"||h.key==="ArrowLeft")){L.subtasks&&L.subtasks.length>0&&(h.preventDefault(),(h.key==="ArrowRight"&&!L.isExpanded||h.key==="ArrowLeft"&&L.isExpanded)&&m(L.id));return}if(h.altKey&&(h.key==="ArrowUp"||h.key==="ArrowDown")){v.length>0&&(h.preventDefault(),l(v,h.key==="ArrowUp"?"up":"down"));return}if(h.key==="Tab"&&!h.shiftKey){v.length>0&&(h.preventDefault(),c(v));return}if(h.key==="Tab"&&h.shiftKey){v.length>0&&(h.preventDefault(),p(v));return}if(h.key==="Enter"&&!h.shiftKey&&!M){L&&(h.preventDefault(),r(L.id,"below"));return}if(h.key==="Enter"&&h.shiftKey&&!M){L&&(h.preventDefault(),r(L.id,"above"));return}if(h.key==="Enter"&&M){L&&(h.preventDefault(),d(L.id));return}if(h.key==="F2"){L&&(h.preventDefault(),n(L.id));return}if(h.key==="Delete"||h.key==="Backspace"&&M){v.length>0&&(h.preventDefault(),o(v));return}if(h.key==="d"&&M&&!h.shiftKey){v.length>0&&(h.preventDefault(),s(v));return}},[i,t,g,x,r,o,s,l,c,p,n,m,d]);return useEffect(()=>{if(i)return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b);}},[i,b]),{setIsEditing:y}}function pd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(i=>{let u=new Set(i);return u.has(d)?u.delete(d):u.add(d),u}),r(d);},[]),l=useCallback((d,i)=>{if(!a){o(d);return}let u=i.indexOf(a),y=i.indexOf(d);if(u===-1||y===-1){o(d);return}let f=Math.min(u,y),g=Math.max(u,y),x=i.slice(f,g+1);t(new Set(x)),r(d);},[a,o]),c=useCallback((d,i,u,y)=>{y?l(d,i):u?s(d):o(d);},[o,s,l]),p=useCallback((d,i)=>{i?t(u=>{let y=new Set(u);return y.add(d),y}):o(d);},[o]),n=useCallback(()=>{t(new Set),r(null);},[]),m=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:l,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:n,isTaskSelected:m}}function Gr(e){let t=[],a=(r,o,s=0)=>{for(let l=0;l<r.length;l++){let c={...r[l],parentId:o,level:s,position:l};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function md(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=md(a.subtasks,t);if(r)return r}}return null}function Es(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Es(a.subtasks,t);if(r)return r}return null}function Ps(e,t){if(t.length===0)return e;let a=Gr(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],l=(d,i)=>{let u=[];return {tasks:d.filter(f=>{if(i.has(f.id))return u.push(f),false;if(f.subtasks){let g=l(f.subtasks,i);f.subtasks=g.tasks,u.push(...g.removed);}return true}),removed:u}},c=(d,i,u)=>d.map(y=>y.id===i?{...y,subtasks:[...y.subtasks||[],...u],isExpanded:true}:y.subtasks?{...y,subtasks:c(y.subtasks,i,u)}:y),p=new Set(t),{tasks:n,removed:m}=l(e,p);return c(n,s.id,m)}function Ms(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Es(a,r);if(!o)continue;let s=Es(a,o.id),l=(n,m,d)=>{for(let i=0;i<n.length;i++){let u=n[i];if(u.id===m&&u.subtasks){let y=u.subtasks.findIndex(f=>f.id===d);if(y!==-1){let[f]=u.subtasks.splice(y,1);return f}}if(u.subtasks){let y=l(u.subtasks,m,d);if(y)return y}}return null},c=(n,m,d)=>{let i=n.findIndex(u=>u.id===m);if(i!==-1)return n.splice(i+1,0,d),n;for(let u of n)u.subtasks&&c(u.subtasks,m,d);return n},p=l(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function As(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(l,c,p)=>{let n=l.findIndex(d=>d.id===c);if(n===-1){for(let d of l)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let m=p==="up"?n-1:n+1;return m<0||m>=l.length?false:([l[n],l[m]]=[l[m],l[n]],true)};return s(r,o,a),r}function Is(e,t){let a=new Set(t),r=o=>o.filter(s=>!a.has(s.id)).map(s=>s.subtasks?{...s,subtasks:r(s.subtasks)}:s);return r(e)}function Ls(e,t){let a=[...e];for(let r of t){let o=l=>{let c=l.findIndex(m=>m.id===r);if(c===-1){for(let m of l)if(m.subtasks&&o(m.subtasks))return true;return false}let p=l[c],n={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return l.splice(c+1,0,n),true},s=l=>l.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function ud(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=p=>{let n=p.findIndex(d=>d.id===t);if(n===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let m=a==="above"?n:n+1;return p.splice(m,0,l),true};return c(r),{tasks:r,newTask:l}}function Fs(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:Fs(r.subtasks,t,a)}:r)}function Bs(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:Bs(a.subtasks,t)}:a)}function Rs(e,t){let a=m=>{for(let d of m){if(d.id===t)return d;if(d.subtasks){let i=a(d.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(l),endDate:new Date(c),color:r?.color||"#3B82F6"},n=m=>m.map(d=>{if(d.id===t){let i=d.subtasks||[];return {...d,subtasks:[...i,p],isExpanded:true}}return d.subtasks?{...d,subtasks:n(d.subtasks)}:d});return {tasks:n(e),newTask:p}}function gd(e,t,a,r){if(t===a)return e;let o=md(e,t);if(!o)return e;if(a){let c=(p,n)=>{if(!p.subtasks)return false;for(let m of p.subtasks)if(m.id===n||c(m,n))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),l=s(e);if(a===null){let c=r!==void 0?r:l.length;l.splice(c,0,{...o,parentId:void 0});}else {let c=p=>p.map(n=>{if(n.id===a){let m=n.subtasks||[],d=r!==void 0?r:m.length,i=[...m];return i.splice(d,0,{...o,parentId:a}),{...n,subtasks:i,isExpanded:true}}return n.subtasks&&n.subtasks.length>0?{...n,subtasks:c(n.subtasks)}:n});l=c(l);}return l}function Qo({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:l,onTaskContextMenu:c,onTaskToggle:p,scrollTop:n,columns:m,onToggleColumn:d,onColumnResize:i,onTaskUpdate:u,onTaskIndent:y,onTaskOutdent:f,onTaskMove:g,onMultiTaskDelete:x,onTaskDuplicate:b,onTaskCreate:h,onTaskRename:w,onCreateSubtask:D,onOpenTaskModal:N,onDeleteRequest:M,onTaskReparent:v}){let L=useContext(Wr),[T,k]=useState(null),[F,P]=useState(false),[H,X]=useState(null),[ye,we]=useState(""),Ie=useRef(null),Le=useRef(null),[O,B]=useState(null),[W,S]=useState(0),[q,ee]=useState(0),[$,Me]=useState({isOpen:false,x:0,y:0,type:"header"}),[be,qe]=useState(null),[ue,Qe]=useState(null),[Te,rt]=useState(null),gt=useRef(0),ft=5,et=useRef(false),[R,se]=useState(null),[ve,De]=useState(false),[Ee,Ve]=useState(null);useEffect(()=>{function _(j){Ie.current&&!Ie.current.contains(j.target)&&P(false);}if(F)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[F]),useEffect(()=>{H&&Le.current&&(Le.current.focus(),Le.current.select());},[H]),useEffect(()=>{if(!O)return;let _=nt=>{let He=nt.clientX-W,ge=q+He;i?.(O,ge);},j=()=>{B(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect="";}},[O,W,q,i]);let{selectedTaskIds:Ct,handleTaskClick:Y,isTaskSelected:z}=pd(),{setIsEditing:ke}=dd({tasks:e,selectedTaskIds:Ct,onTaskSelect:(_,j)=>{let He=Gr(e).map(ge=>ge.id);Y(_,He,j||false,false);},onTaskCreate:h||(()=>{}),onTaskDelete:x||(()=>{}),onTaskDuplicate:b||(()=>{}),onTaskMove:g||(()=>{}),onTaskIndent:y||(()=>{}),onTaskOutdent:f||(()=>{}),onTaskRename:_=>{let j=Gr(e).find(nt=>nt.id===_);j&&te(j);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:_=>{let j=Gr(e).find(nt=>nt.id===_);j&&N&&N(j);},enableKeyboard:true}),We=(_,j=0)=>{let nt=[];for(let He of _)nt.push({task:He,level:j}),He.subtasks&&He.subtasks.length>0&&He.isExpanded&&nt.push(...We(He.subtasks,j+1));return nt},Ue=We(e),ht=48,Z=_=>!_.startDate||!_.endDate?"-":`${Math.ceil((_.endDate.getTime()-_.startDate.getTime())/(1e3*60*60*24))}d`,te=_=>{X(_.id),we(_.name),ke(true);},xe=_=>{ye.trim()&&ye!==e.find(j=>j.id===_)?.name&&w?.(_,ye.trim()),X(null),we(""),ke(false);},Pe=()=>{X(null),we(""),ke(false);},J=(_,j)=>{j.stopPropagation(),D?.(_.id);},Ae=(_,j)=>{j.preventDefault(),gt.current=j.clientY,qe(_),et.current=false,De(false),se({x:j.clientX,y:j.clientY});},he=_=>{if(!be||(Math.abs(_.clientY-gt.current)>ft&&!et.current&&(et.current=true,De(true)),se({x:_.clientX,y:_.clientY}),!et.current))return;let nt=document.querySelectorAll("[data-task-row]"),He=null,ge=null;nt.forEach(Vt=>{let Tt=Vt.getBoundingClientRect(),U=Vt.getAttribute("data-task-row");if(U&&U!==be&&_.clientY>=Tt.top&&_.clientY<=Tt.bottom){He=U;let ce=_.clientY-Tt.top,Ce=Tt.height;ce<Ce*.25?ge="above":ce>Ce*.75?ge="below":ge="child";}}),Qe(He),rt(ge);},Ne=()=>{if(et.current&&be&&ue&&Te){if(Te==="child")v?.(be,ue);else if(Te==="above"||Te==="below"){let _=(He,ge,Vt=null)=>{for(let Tt of He){if(Tt.id===ge)return Vt;if(Tt.subtasks){let U=_(Tt.subtasks,ge,Tt.id);if(U!==void 0)return U}}},j=_(e,ue,null),nt=(He,ge)=>{let Vt=He.findIndex(Tt=>Tt.id===ge);return Te==="below"?Vt+1:Vt};if(j===null){let He=nt(e,ue);v?.(be,null,He);}else {let He=Ue.find(ge=>ge.task.id===j)?.task;if(He?.subtasks){let ge=nt(He.subtasks,ue);v?.(be,j,ge);}}}}qe(null),Qe(null),rt(null),se(null),et.current=false,De(false);};useEffect(()=>{if(be)return document.addEventListener("mousemove",he),document.addEventListener("mouseup",Ne),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Ne),document.body.style.cursor="",document.body.style.userSelect="";}},[be,ue,Te]);let de=(_,j,nt)=>{switch(_.id){case "name":let He=H===j.id,ge=T===j.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${nt*20}px`},children:[v&&jsx("div",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-white/10 transition-all flex-shrink-0",style:{color:t.textTertiary,opacity:ge?1:.3},onMouseDown:ie=>Ae(j.id,ie),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),j.subtasks&&j.subtasks.length>0?jsx("button",{onClick:ie=>{ie.stopPropagation(),p?.(j.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:j.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"}),!(j.subtasks&&j.subtasks.length>0)&&jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0 border",style:{backgroundColor:j.color||"#3B82F6",opacity:j.parentId?.6:1,borderColor:j.isMilestone?t.accent:"transparent",borderWidth:j.isMilestone?"2px":"0px"},title:j.isMilestone?"Milestone":j.parentId?"Subtask":"Task"}),He?jsx("input",{ref:Le,type:"text",value:ye,onChange:ie=>we(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"?xe(j.id):ie.key==="Escape"&&Pe();},onBlur:()=>xe(j.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:ie=>ie.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:j.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:j.parentId?"13px":"14px",fontWeight:j.isMilestone?600:j.parentId?400:600,letterSpacing:j.parentId?"0":"-0.01em"},title:j.name,children:j.name}),ge&&!He&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:ie=>ie.stopPropagation(),children:[jsx("button",{onClick:ie=>J(j,ie),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:ie=>{ie.stopPropagation(),te(j);},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 Tt=_.id==="startDate"?"startDate":"endDate",U=j[Tt],ce=Ee?.taskId===j.id&&Ee?.field===Tt,Ce=ie=>ie?(typeof ie=="string"?new Date(ie):ie).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:ie=>ie.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:ie=>{if(ce)Ve(null);else {let Dt=ie.currentTarget.getBoundingClientRect();Ve({taskId:j.id,field:Tt,month:U?typeof U=="string"?new Date(U):U:new Date,position:{top:Dt.bottom+4,left:Dt.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Ce(U)})]}),ce&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>Ve(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:Ee?.position.top,left:Ee?.position.left},onClick:ie=>ie.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let ie=new Date,Dt=new Date(ie);Dt.setDate(ie.getDate()+1);let Jt=new Date(ie);Jt.setDate(ie.getDate()+7);let Sr=new Date(ie);return Sr.setDate(ie.getDate()+14),[{label:"Hoy",date:ie},{label:"Ma\xF1ana",date:Dt},{label:"Pr\xF3xima semana",date:Jt},{label:"2 semanas",date:Sr}].map((Pr,Wa)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:ir=>ir.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:ir=>ir.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(j.id,{[Tt]:Pr.date}),Ve(null);},children:Pr.label},Wa))})(),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:ie=>ie.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:ie=>ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(j.id,{[Tt]:void 0}),Ve(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:()=>Ve(ie=>ie?{...ie,month:new Date(ie.month.getFullYear(),ie.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:Ee?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>Ve(ie=>ie?{...ie,month:new Date(ie.month.getFullYear(),ie.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((ie,Dt)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:ie},Dt))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let ie=Ee?.month||new Date,Dt=ie.getFullYear(),Jt=ie.getMonth(),Sr=new Date(Dt,Jt,1).getDay(),Er=new Date(Dt,Jt+1,0).getDate(),Pr=new Date,Wa=[];for(let Et=Sr-1;Et>=0;Et--)Wa.push({day:new Date(Dt,Jt,-Et).getDate(),date:new Date(Dt,Jt-1,new Date(Dt,Jt,-Et).getDate()),isCurrentMonth:false});for(let Et=1;Et<=Er;Et++)Wa.push({day:Et,date:new Date(Dt,Jt,Et),isCurrentMonth:true});let ir=42-Wa.length;for(let Et=1;Et<=ir;Et++)Wa.push({day:Et,date:new Date(Dt,Jt+1,Et),isCurrentMonth:false});return Wa.map((Et,So)=>{let Eo=Et.date.toDateString()===Pr.toDateString(),Jr=(U?typeof U=="string"?new Date(U):U:null)?.toDateString()===Et.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:Et.isCurrentMonth?Jr?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Jr?"#3B82F6":"transparent",boxShadow:Eo&&!Jr?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{u?.(j.id,{[Tt]:Et.date}),Ve(null);},children:Et.day},So)})})()})]})]})]}),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:Z(j)})});case "assignees":let zt=r.filter(ie=>j.assignees?.some(Dt=>Dt.name===ie.name||Dt.initials===ie.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:ie=>ie.stopPropagation(),children:jsx(mr,{assignedUsers:zt,availableUsers:r,onChange:ie=>{let Dt=ie.map(Jt=>({id:Jt.id,name:Jt.name,initials:Jt.initials,color:Jt.color}));u?.(j.id,{assignees:Dt.length>0?Dt:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:ie=>ie.stopPropagation(),children:jsx(cl,{status:j.status||"todo",onChange:ie=>{u?.(j.id,{status:ie,progress:ie==="completed"?100:j.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:`${j.progress}%`,backgroundColor:j.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:[j.progress,"%"]})]});case "priority":let ea={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},qa={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},Xr=ea[j.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:ie=>ie.stopPropagation(),children:jsx(cr,{priority:Xr,onChange:ie=>{ie&&u?.(j.id,{priority:qa[ie]||"medium"});}})});default:return null}},Re=_=>[{id:"hide",label:"Hide Column",icon:kt.Hide,onClick:()=>d(_),disabled:_==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:kt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:kt.SortDesc,onClick:()=>{}}],Fe=_=>_.subtasks&&_.subtasks.length>0?[{id:"addSubtask",label:L?.contextMenu?.addSubtask||"Add Subtask",icon:kt.Add,onClick:()=>{D?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:L?.contextMenu?.deleteTask||"Delete Task",icon:kt.Delete,onClick:()=>{M?M(_.id,_.name):x?.([_.id]);}}]:[{id:"edit",label:L?.contextMenu?.editTask||"Edit Task",icon:kt.Pencil,onClick:()=>{l?.(_);}},{id:"addSubtask",label:L?.contextMenu?.addSubtask||"Add Subtask",icon:kt.Add,onClick:()=>{D?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:L?.contextMenu?.markIncomplete||"Mark Incomplete",icon:kt.MarkIncomplete,onClick:()=>{u?.(_.id,{status:"todo",progress:0});},disabled:_.status==="todo"},{id:"setInProgress",label:L?.contextMenu?.setInProgress||"Set In Progress",icon:kt.SetInProgress,onClick:()=>{u?.(_.id,{status:"in-progress"});},disabled:_.status==="in-progress"},{id:"markComplete",label:L?.contextMenu?.markComplete||"Mark Complete",icon:kt.MarkComplete,onClick:()=>{u?.(_.id,{status:"completed",progress:100});},disabled:_.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:L?.contextMenu?.splitTask||"Split Task",icon:kt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:L?.contextMenu?.deleteTask||"Delete Task",icon:kt.Delete,onClick:()=>{M?M(_.id,_.name):x?.([_.id]);}}],Oe=m.filter(_=>_.visible);return jsxs("div",{className:"h-full overflow-hidden",style:{backgroundColor:t.bgPrimary},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${ht}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[Oe.map((_,j)=>{let nt=j===Oe.length-1,He=_.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:`${_.width}px`,minWidth:`${_.minWidth??(He?200:60)}px`,maxWidth:`${_.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:nt?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:ge=>{ge.preventDefault(),Me({isOpen:true,x:ge.clientX,y:ge.clientY,type:"header",columnId:_.id});},onMouseEnter:ge=>{ge.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:ge=>{ge.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:He?"70px":"0"},title:_.label,children:_.label}),He&&jsxs("div",{className:"absolute flex items-center gap-1",style:{right:"4px",top:"50%",transform:"translateY(-50%)",zIndex:4},children:[jsx(Xo,{columns:m,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>P(!F),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors relative group",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})})]}),_.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:O===_.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:ge=>{ge.preventDefault(),ge.stopPropagation(),B(_.id),S(ge.clientX),ee(_.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},_.id)}),F&&jsxs("div",{ref:Ie,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:_=>_.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>P(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:t.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]}),jsx("div",{className:"gantt-taskgrid-content",children:Ue.map(({task:_,level:j},nt)=>{let He=z(_.id),ge=ue===_.id,Vt=ge&&Te==="above",Tt=ge&&Te==="below",U=ge&&Te==="child",ce={};return U&&(ce.backgroundColor=`${t.accent}15`,ce.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":_.id,className:`flex items-center cursor-pointer group ${be===_.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:He?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:He?t.accentLight:U?`${t.accent}15`:nt%2===0?t.bgPrimary:t.bgGrid,...ce},onMouseEnter:()=>k(_.id),onMouseLeave:()=>k(null),onClick:Ce=>{let ea=Gr(e).map(ie=>ie.id),Xr=navigator.platform.toUpperCase().indexOf("MAC")>=0?Ce.metaKey:Ce.ctrlKey;Y(_.id,ea,Xr,Ce.shiftKey),s?.(_);},onDoubleClick:Ce=>{Ce.stopPropagation(),l?.(_);},onContextMenu:Ce=>{Ce.preventDefault(),Me({isOpen:true,x:Ce.clientX,y:Ce.clientY,type:"task",task:_}),c?.(_,Ce);},whileHover:{backgroundColor:He?t.accentLight:t.hoverBg},children:[Vt&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Tt&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Oe.map((Ce,zt)=>{let ea=zt===Oe.length-1,qa=Ce.id==="name";return jsx("div",{className:`px-4 flex items-center ${qa?"justify-start":"justify-center"}`,style:{width:`${Ce.width}px`,minWidth:`${Ce.minWidth??(qa?200:60)}px`,maxWidth:`${Ce.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:ea?"none":`1px solid ${T===_.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:de(Ce,_,qa?j:0)},`${_.id}-${Ce.id}`)})]},_.id)})}),jsx(Hr,{isOpen:$.isOpen,x:$.x,y:$.y,items:$.type==="header"&&$.columnId?Re($.columnId):$.type==="task"&&$.task?Fe($.task):[],onClose:()=>Me({...$,isOpen:false}),theme:t}),ve&&R&&be&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:R.x+12,top:R.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let _=Ue.find(j=>j.task.id===be)?.task;return _?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:_.name})}):null})()}),document.body)]})}function vd(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[l,c]=useState(e),[p,n]=useState(t),[m,d]=useState(null),[i,u]=useState(null),[y,f]=useState(null),[g,x]=useState(null),[b,h]=useState(0),[w,D]=useState(0),[N,M]=useState(null),[v,L]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:l,setGhostX:c,ghostWidth:p,setGhostWidth:n,connectionLine:m,setConnectionLine:d,hoveredTaskId:i,setHoveredTaskId:u,activeZone:y,setActiveZone:f,draggedSegmentIndex:g,setDraggedSegmentIndex:x,draggedSegmentStartX:b,setDraggedSegmentStartX:h,segmentDragOffsetX:w,setSegmentDragOffsetX:D,hoveredSegmentIndex:N,setHoveredSegmentIndex:M,isHovered:v,setIsHovered:L,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(H,X)=>{r("none"),d(null),u(null),c(H),n(X),D(0),x(null),h(0);}}}function en({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:l,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:u=[],onDragMove:y,onHoverChange:f}){let g=vd(t,r),x=useRef(null),{dragMode:b,setDragMode:h,dragOffset:w,setDragOffset:D,ghostX:N,setGhostX:M,ghostWidth:v,setGhostWidth:L,connectionLine:T,setConnectionLine:k,hoveredTaskId:F,setHoveredTaskId:P,activeZone:H,setActiveZone:X,draggedSegmentIndex:ye,setDraggedSegmentIndex:we,draggedSegmentStartX:Ie,setDraggedSegmentStartX:Le,segmentDragOffsetX:O,setSegmentDragOffsetX:B,hoveredSegmentIndex:W,setHoveredSegmentIndex:S,isHovered:q,setIsHovered:ee,isDragging:$,isResizing:Me,isConnecting:be,resetDragState:qe}=g,ue=32,Qe=8,Te=e.endDate&&e.endDate<new Date&&e.progress<100,rt=e.isCriticalPath,gt=o.name==="neutral"||o.today==="#1C1917",ft=e.status==="completed"||e.progress===100,et={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},se=e.isCriticalPath||Te?"#DC2626":e.color?e.color:e.priority&&et[e.priority]?et[e.priority]:o.taskBarPrimary,De=(J=>J>=80?20:J>=60?15:J>=50?12:10)(r),Ee=r<50,Ve=r<40;useEffect(()=>{if(f)if(q&&!$&&!e.segments){let J=a<100;f({task:e,x:t,y:a,width:r,height:ue,showBelow:J});}else f(null);},[q,$,e,t,a,r,ue,f]);let Ct=J=>J.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Y=()=>{let J=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${J} day${J!==1?"s":""}`},z=J=>Math.round(J/s)*s,ke=J=>{let Ae=Math.round(J/s),he=new Date(l);return he.setDate(he.getDate()+Ae),he},We=(J,Ae)=>{for(let he of u){if(he.id===e.id)continue;let Ne=5;if(J>=he.x-Ne&&J<=he.x+he.width+Ne&&Ae>=he.y-Ne&&Ae<=he.y+he.height+Ne)return he.id}return null},Ue=useCallback((J,Ae,he)=>{J.preventDefault(),J.stopPropagation();let Ne=x.current?.ownerSVGElement;if(!Ne)return;let de=Ne.createSVGPoint();de.x=J.clientX,de.y=J.clientY;let Re=de.matrixTransform(Ne.getScreenCTM()?.inverse()),Fe=he!==void 0?he:t,Oe=Ae;if(!Oe){let _=Re.x-Fe;J.shiftKey?(Oe="connect",k({x:t+r,y:a+ue/2})):J.ctrlKey||J.metaKey?Oe="move":J.altKey?Oe=_<r/2?"resize-start":"resize-end":Ve?_<r/2?Oe="move":Oe="resize-end":Ee?_<=De/2?Oe="resize-start":_>=r-De/2?Oe="resize-end":Oe="move":_<=De?Oe="resize-start":_>=r-De?Oe="resize-end":Oe="move";}h(Oe),ee(false),X(null),Oe==="move"?D(Re.x-Fe):Oe==="connect"?k({x:t+r,y:a+ue/2}):D(0),M(Fe),L(r);},[t,r,a,ue]),ht=useCallback(J=>{if(b==="none")return;let Ae=x.current?.ownerSVGElement;if(!Ae)return;let he=Ae.createSVGPoint();he.x=J.clientX,he.y=J.clientY;let Ne=he.matrixTransform(Ae.getScreenCTM()?.inverse());if(b==="connect"){k({x:Ne.x,y:Ne.y});let de=We(Ne.x,Ne.y);P(de);}else if(b==="move"){let de=Ne.x-w,Re=z(de);M(Re),L(r);let Fe=Math.round((Re-t)/s);if(y?.(e.id,Fe,true),e.segments&&e.segments.length>0&&ye!==null){let Oe=Re-Ie;B(Oe);}}else if(b==="resize-start"){let de=Ne.x,Re=z(de),Fe=t+r-Re;Fe>=s&&(M(Re),L(Fe));}else if(b==="resize-end"){let de=Ne.x,Fe=z(de)-t;Fe>=s&&L(Fe);}},[b,t,r,s,w,e,z,ye,Ie,We,P,k,M,L,B,y]),Z=useCallback(()=>{if(b!=="none"){if(b==="connect")F&&i&&i(e,F),k(null),P(null);else {let J=e.endDate.getTime()-e.startDate.getTime(),Ae,he,Ne=true;if(b==="move"){if(Ae=ke(N),he=new Date(Ae.getTime()+J),e.segments&&e.segments.length>0&&ye!==null){let de=Math.round(O/s),Re=e.segments.map((j,nt)=>{if(nt===ye){let He=new Date(j.startDate),ge=new Date(j.endDate);return He.setDate(He.getDate()+de),ge.setDate(ge.getDate()+de),{startDate:He,endDate:ge}}return j}),Fe=Re.flatMap(j=>[j.startDate,j.endDate]),Oe=new Date(Math.min(...Fe.map(j=>j.getTime()))),_=new Date(Math.max(...Fe.map(j=>j.getTime())));d?.({...e,segments:Re},Oe,_),qe(t,r);return}}else b==="resize-start"?(Ae=ke(N),he=e.endDate,Ae>=he&&(console.warn("Invalid date range: start date must be before end date"),Ne=false)):b==="resize-end"?(Ae=e.startDate,he=ke(N+v),he<=Ae&&(console.warn("Invalid date range: end date must be after start date"),Ne=false)):Ne=false;Ne&&Ae&&he&&(he.getTime()-Ae.getTime()<864e5?console.warn("Invalid date range: task must be at least 1 day long"):d?.(e,Ae,he));}y?.(e.id,0,false),qe(t,r);}},[b,N,v,e,d,F,i,t,r,s,ke,O,ye,qe,y]);useEffect(()=>{if(b==="none")return;let J=he=>{ht(he);},Ae=()=>{Z();};return window.addEventListener("mousemove",J),window.addEventListener("mouseup",Ae),()=>{window.removeEventListener("mousemove",J),window.removeEventListener("mouseup",Ae);}},[b,ht,Z]);let te=$&&!be?N:t,xe=$&&!be?v:r,Pe=c.taskClass(e);return jsxs("g",{ref:x,onMouseEnter:()=>!$&&ee(true),onMouseLeave:()=>{$||(ee(false),X(null));},onClick:()=>!$&&p?.(e),onDoubleClick:J=>{$||(J.stopPropagation(),n?.(e));},onContextMenu:J=>{J.preventDefault(),m?.(e,J);},children:[q&&!$&&!Ee&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:De,height:ue,fill:H==="resize-start"?o.accent:"transparent",opacity:H==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-start"),onMouseDown:J=>Ue(J,"resize-start")}),jsx("rect",{x:t+De,y:a,width:r-De*2,height:ue,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>X("move"),onMouseDown:J=>Ue(J,"move")}),jsx("rect",{x:t+r-De,y:a,width:De,height:ue,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-end"),onMouseDown:J=>Ue(J,"resize-end")})]}),q&&!$&&Ve&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:ue,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>X("move"),onMouseDown:J=>Ue(J,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:ue,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-end"),onMouseDown:J=>Ue(J,"resize-end")}),q&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+ue-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),$&&!be&&!e.segments&&jsx(motion.rect,{x:N,y:a,width:v,height:ue,rx:Qe,fill:o.accent,opacity:.5,stroke:o.accent,strokeWidth:2,strokeDasharray:"4 4",initial:{opacity:0},animate:{opacity:.6},transition:{duration:.15},style:{pointerEvents:"none"}}),!e.segments&&jsx(motion.rect,{x:te,y:a,width:xe,height:ue,rx:Qe,fill:se,"data-task-class":Pe,initial:{opacity:0,scale:.95},animate:{opacity:$&&!be?.15:e.parentId?.6:q?.9:.8,scale:q&&!$?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:J=>Ue(J),style:{cursor:$?be?"crosshair":Me?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:te,y:a,width:xe*(e.progress/100),height:ue,rx:Qe,fill:se,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((J,Ae)=>{let he=(J.startDate.getTime()-l.getTime())/864e5*s,de=(J.endDate.getTime()-l.getTime())/(1e3*60*60*24)*s-he+s,Re=$&&b==="move"&&ye===Ae,Fe=W===Ae,Oe=Re?he+O:he;return jsxs("g",{onMouseEnter:()=>!$&&S(Ae),onMouseLeave:()=>!$&&S(null),children:[jsx(motion.rect,{x:Oe,y:a,width:de,height:ue,rx:Qe,fill:se,initial:{opacity:0,scale:.95},animate:{opacity:Re||e.parentId?.6:Fe?.9:.8,scale:Fe&&!$?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:_=>{_.stopPropagation(),we(Ae),Le(he),Ue(_,void 0,he);},style:{cursor:$?be?"crosshair":Me?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Oe,y:a,width:de*(e.progress/100),height:ue,rx:Qe,fill:se,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Ae}`)}),gt&&(Te||rt)&&!e.segments&&jsxs(Fragment,{children:[rt&&!Te&&jsx("rect",{x:te,y:a,width:xe,height:ue,rx:Qe,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Te&&jsx("rect",{x:te,y:a,width:xe,height:ue,rx:Qe,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),xe>60&&!e.segments&&(()=>{let J=c.taskLabel(e),Ae=typeof J=="string"?J:e.name,he=Ae.length>Math.floor(xe/8)?`${Ae.substring(0,Math.floor(xe/8))}...`:Ae;return jsx("text",{x:te+12,y:a+ue/2,dominantBaseline:"middle",fill:ft?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:ft?"line-through":"none"},children:he})})(),xe>100&&e.progress>0&&e.progress<100&&!$&&!e.segments&&jsxs("text",{x:te+xe-12,y:a+ue/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&&xe>80&&!$&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:te+xe-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:te+xe-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(q||Me)&&!be&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ee?te-15:te-10,y:a-5,width:Ee?25:20,height:ue+10,fill:"transparent",onMouseDown:J=>Ue(J,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ee?te-8:te-3,y:a+6,width:Ee?8:6,height:Ee?ue-12:ue-16,rx:3,fill:b==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:b==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:te+xe-10,y:a-5,width:Ee?25:20,height:ue+10,fill:"transparent",onMouseDown:J=>Ue(J,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ee?te+xe:te+xe-3,y:a+6,width:Ee?8:6,height:Ee?ue-12:ue-16,rx:3,fill:b==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:b==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:q&&!$&&!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+ue/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:J=>{J.stopPropagation(),Ue(J,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+ue/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),be&&T&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+ue/2,x2:T.x,y2:T.y,stroke:F?o.statusCompleted:o.accent,strokeWidth:F?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:F?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:T.x,cy:T.y,r:F?8:6,fill:F?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),F&&jsx(motion.text,{x:T.x+15,y:T.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:T.x+10},animate:{opacity:1,x:T.x+15},transition:{duration:.2},children:"Connect"})]}),(q||$)&&!be&&!e.segments&&jsx(motion.rect,{x:te-2,y:a-2,width:xe+4,height:ue+4,rx:Qe+2,fill:"none",stroke:$?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:$?.6:.4,initial:{opacity:0},animate:{opacity:$?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),Me&&jsxs(Fragment,{children:[jsx("line",{x1:N,y1:0,x2:N,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:N+v,y1:0,x2:N+v,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:q&&!$&&!e.segments&&!f&&(()=>{let he=a<100,Ne=he?a+ue+13:a-82-13,de=he?`M ${te+xe/2-6} ${a+ue+3} L ${te+xe/2} ${a+ue+13} L ${te+xe/2+6} ${a+ue+3}`:`M ${te+xe/2-6} ${a-13} L ${te+xe/2} ${a-3} L ${te+xe/2+6} ${a-13}`,Re=Ne+22,Fe=Ne+40,Oe=Ne+55,_=Ne+70,j=he?Ne+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:he?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:he?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:de,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:te+xe/2-120,y:Ne,width:240,height:82,rx:8,fill:o.bgSecondary,stroke:o.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:te+xe/2,y:Re,textAnchor:"middle",fill:o.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>28?`${e.name.substring(0,28)}...`:e.name}),jsx("text",{x:te+xe/2-110,y:Fe,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:te+xe/2-70,y:Fe,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ct(e.startDate)}),jsx("text",{x:te+xe/2-110,y:Oe,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:te+xe/2-70,y:Oe,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ct(e.endDate)}),jsx("text",{x:te+xe/2+10,y:Fe,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:te+xe/2+65,y:Fe,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Y()}),jsx("text",{x:te+xe/2+10,y:Oe,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:te+xe/2+65,y:Oe,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.progress,"%"]}),e.assignees&&e.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:te+xe/2-110,y:_,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:te+xe/2-50,y:_,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(nt=>nt.name).join(", ").substring(0,30),e.assignees.map(nt=>nt.name).join(", ").length>30?"...":""]})]}),!he&&jsx("text",{x:te+xe/2,y:j,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:Ve?"Left: move \u2022 Right: resize":Ee?"Drag to move \u2022 Hold ALT + drag edge to resize":"Drag edges to resize \u2022 Drag center to move \u2022 Click \u26AB to link"})]})})()})]})}function wd({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:l,showBelow:c}=e,p=82,n=13,m=c?o+l+n:o-p-n,d=c?`M ${r+s/2-6} ${o+l+3} L ${r+s/2} ${o+l+13} L ${r+s/2+6} ${o+l+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,i=m+22,u=m+40,y=m+55,f=m+70,g=w=>w.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),x=()=>{if(!a.startDate||!a.endDate)return "N/A";let w=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${w} day${w!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:m,width:240,height:p,rx:8,fill:t.bgSecondary,stroke:t.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:r+s/2,y:i,textAnchor:"middle",fill:t.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:a.name.length>28?`${a.name.substring(0,28)}...`:a.name}),jsx("text",{x:r+s/2-110,y:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?g(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?g(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:x()}),jsx("text",{x:r+s/2+10,y,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.progress,"%"]}),a.assignees&&a.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:r+s/2-110,y:f,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:f,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(w=>w.name).join(", ").substring(0,30),a.assignees.map(w=>w.name).join(", ").length>30?"...":""]})]})]})})}function rn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:l}){let[c,p]=useState(false),n=a-e,m=r-t,d=e+n/2,i=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,u=6,y=Math.atan2(m,n),f=a-u*Math.cos(y-Math.PI/6),g=r-u*Math.sin(y-Math.PI/6),x=a-u*Math.cos(y+Math.PI/6),b=r-u*Math.sin(y+Math.PI/6),h=o.dependency;useEffect(()=>{l&&s&&l(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,l]);let w=!s&&!l;return jsxs("g",{onMouseEnter:()=>!w&&p(true),onMouseLeave:()=>!w&&p(false),style:{pointerEvents:w?"none":"auto"},children:[!w&&jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:h,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&l?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${f} ${g} M ${a} ${r} L ${x} ${b}`,fill:"none",stroke:h,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&l?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:h,initial:{scale:0},animate:{scale:c&&l?0:c?1.3:1,opacity:c&&l?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!l&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:D=>{D.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function nn({task:e,x:t,y:a,theme:r,onClick:o}){let[s,l]=useState(false),c=16,p=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:p(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var ne={calculateEndDate:(e,t)=>{let a=new Date(e);return a.setDate(a.getDate()+t),a},calculateDuration:(e,t)=>{let a=t.getTime()-e.getTime();return Math.ceil(a/(1e3*60*60*24))},calculateWorkingDays:(e,t)=>{let a=0,r=new Date(e);for(;r<=t;){let o=r.getDay();o!==0&&o!==6&&a++,r.setDate(r.getDate()+1);}return a},addWorkingDays:(e,t)=>{let a=new Date(e),r=0;for(;r<t;){a.setDate(a.getDate()+1);let o=a.getDay();o!==0&&o!==6&&r++;}return a},isWeekend:e=>{let t=e.getDay();return t===0||t===6},validateDependencies:(e,t,a)=>{let r=new Map,o=n=>{n.forEach(m=>{m.dependencies&&r.set(m.id,m.dependencies),m.subtasks&&o(m.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let l=new Set,c=new Set,p=n=>{if(!l.has(n)){l.add(n),c.add(n);let m=r.get(n)||[];for(let d of m){if(!l.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(n),false};return p(a)},flattenTasks:e=>{let t=[],a=r=>{r.forEach(o=>{t.push(o),o.subtasks&&o.subtasks.length>0&&a(o.subtasks);});};return a(e),t},findTaskById:(e,t)=>{for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=ne.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=ne.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=ne.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=ne.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=ne.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=ne.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)=>ne.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=ne.findTaskById(e,t);return !a||!a.dependencies?[]:ne.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>ne.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>ne.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=ne.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=>ne.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=ne.flattenTasks(e);if(s.length===0){alert("No tasks found to export");return}o.setFontSize(16),o.text("Gantt Chart - Task List",14,20);let l=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],c=s.map(p=>{let n=p.startDate&&p.endDate?ne.calculateDuration(p.startDate,p.endDate):0;return [p.name,p.startDate?ne.formatDate(p.startDate):"N/A",p.endDate?ne.formatDate(p.endDate):"N/A",n>0?`${n} days`:"N/A",`${p.progress}%`,p.status||"N/A"]});r(o,{head:l,body:c,startY:30,styles:{fontSize:9,cellPadding:3},headStyles:{fillColor:[66,139,202],textColor:255,fontStyle:"bold"},alternateRowStyles:{fillColor:[245,245,245]},columnStyles:{0:{cellWidth:60},1:{cellWidth:30},2:{cellWidth:30},3:{cellWidth:25},4:{cellWidth:20},5:{cellWidth:25}}}),o.save(t);}catch(a){throw a}},exportToExcel:async(e,t="gantt-chart.xlsx")=>{let a=await import('xlsx'),o=ne.flattenTasks(e).map(p=>{let n=p.startDate&&p.endDate?ne.calculateDuration(p.startDate,p.endDate):0;return {"Task ID":p.id,"Task Name":p.name,"Start Date":p.startDate?ne.formatDate(p.startDate):"","End Date":p.endDate?ne.formatDate(p.endDate):"","Duration (days)":n>0?n:"","Progress (%)":p.progress,Status:p.status||"",Assignees:p.assignees?.map(m=>m.name).join(", ")||"",Dependencies:p.dependencies?.join(", ")||"","Is Milestone":p.isMilestone?"Yes":"No","Parent ID":p.parentId||"",Level:p.level||0}}),s=a.utils.json_to_sheet(o),l=[{wch:15},{wch:40},{wch:12},{wch:12},{wch:15},{wch:12},{wch:15},{wch:30},{wch:20},{wch:12},{wch:15},{wch:8}];s["!cols"]=l;let c=a.utils.book_new();a.utils.book_append_sheet(c,s,"Gantt Tasks"),a.writeFile(c,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=ne.flattenTasks(e),o=new Map;r.forEach((i,u)=>{o.set(i.id,u+1);});let s=i=>i.toISOString().replace("Z",""),l=ne.getEarliestStartDate(e)||new Date,c=ne.getLatestEndDate(e)||new Date,p=r.map((i,u)=>{let y=o.get(i.id),f=i.startDate&&i.endDate?ne.calculateDuration(i.startDate,i.endDate):0,g=(i.dependencies||[]).filter(x=>o.has(x)).map(x=>`
111
+ - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function gs({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null);useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=n=>{t(n),o(false);},p=e.reduce((n,m)=>{let d=m.category||"Other";return n[d]||(n[d]=[]),n[d].push(m),n},{});return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg border transition-all text-sm font-medium shadow-lg",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-primary)"},onMouseEnter:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",n.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",n.currentTarget.style.borderColor="var(--theme-border-primary)";},title:"Create from template",children:[jsx("span",{className:"text-base leading-none",children:"\u{1F4CB}"}),jsx("span",{children:"Templates"}),jsx("svg",{className:C("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[320px] max-w-[400px] rounded-xl backdrop-blur-xl border shadow-2xl z-50 overflow-hidden max-h-[500px] overflow-y-auto",style:{backgroundColor:"var(--theme-bg-primary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-4 py-3 border-b sticky top-0 backdrop-blur-sm",style:{borderColor:"var(--theme-border-primary)",backgroundColor:"var(--theme-bg-secondary)"},children:[jsx("span",{className:"text-sm font-bold uppercase tracking-wider",style:{color:"var(--theme-text-primary)"},children:"Card Templates"}),jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:"Quick start with pre-configured cards"})]}),Object.entries(p).map(([n,m])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:n})}),jsx("div",{children:m.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},n)),e.length===0&&jsx("div",{className:"px-4 py-8 text-center",style:{color:"var(--theme-text-tertiary)"},children:jsx("p",{className:"text-sm",children:"No templates available"})})]})]})}function hs({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[l,c]=useState("export"),[p,n]=useState("json"),[m,d]=useState(null),i=useRef(null);if(!t)return null;let u=async()=>{let f=o?.current||void 0,g=await _i(e,p,f);Vi(g,p);},v=async f=>{let g=f.target.files?.[0];if(g){try{let x=await Yi(g),b=g.name.endsWith(".json")?"json":"csv",h=Ki(x,b);d(h),h.success&&r&&r(h,x);}catch(x){d({success:false,errors:[`Failed to read file: ${x instanceof Error?x.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:C("fixed inset-0 z-[9999] flex items-center justify-center",s),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-2xl w-full mx-4",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u{1F4E6}"}),"Export / Import"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Transfer your board data"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsxs("div",{className:"flex border-b border-white/10",children:[jsx("button",{onClick:()=>c("export"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[l==="export"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Select format"}),jsx("div",{className:"grid grid-cols-3 gap-3",children:["json","csv","pdf"].map(f=>jsxs("button",{onClick:()=>n(f),className:C("p-4 rounded-lg border-2 transition-all text-center",p===f?"border-blue-500 bg-blue-500/20 text-white":"border-white/20 hover:border-white/40 text-white/70 hover:text-white"),children:[jsxs("div",{className:"text-2xl mb-2",children:[f==="json"&&"\u{1F4C4}",f==="csv"&&"\u{1F4CA}",f==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:f})]},f))})]}),jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:"Preview"}),jsxs("div",{className:"text-xs text-white/60",children:[jsxs("div",{children:["Board: ",jsx("span",{className:"text-white/90",children:e.title||"Untitled"})]}),jsxs("div",{children:["Columns: ",jsx("span",{className:"text-white/90",children:e.columns.length})]}),jsxs("div",{children:["Cards: ",jsx("span",{className:"text-white/90",children:e.cards.length})]})]})]}),jsx("button",{onClick:u,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),l==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:i,type:"file",accept:".json,.csv",onChange:v,className:"hidden"}),jsxs("button",{onClick:()=>i.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),m&&jsxs("div",{className:C("p-4 rounded-lg",m.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:C("font-semibold mb-2",m.success?"text-green-400":"text-red-400"),children:m.success?"\u2713 Import Successful":"\u2717 Import Failed"}),m.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",m.cardsImported]}),jsxs("div",{children:["Columns imported: ",m.columnsImported]})]}),m.errors&&m.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:m.errors.map((f,g)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",f]},g))})]})]})]})]})]})}var Du=["URGENT","HIGH","MEDIUM","LOW"],Nu=[{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"}],Su=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function bs({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:l,onFilterHighPriority:c,availableUsers:p=[],availableLabels:n=[],availableColumns:m=[],showQuickFilters:d=true,compact:i=false,groupBy:u="none",onGroupByChange:v}){let[f,g]=useState(true),x=useCallback(N=>{a({search:N.target.value});},[a]),b=useCallback(N=>{a({dateFilter:N.target.value});},[a]),h=useCallback(N=>{r({by:N.target.value});},[r]),w=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),D=e.search||e.dateFilter!=="all"||e.priorities.length>0||e.assignees.length>0||e.labels.length>0||t.by!=="none";return jsxs("div",{className:`filter-bar ${i?"filter-bar--compact":""} ${f?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>g(!f),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:f?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:N=>{N.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:f?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.2s",color:"var(--theme-text-secondary)"},children:jsx("polyline",{points:"6 9 12 15 18 9"})}),jsx("span",{className:"filter-bar__label",style:{fontWeight:500,fontSize:"0.875rem",color:"var(--theme-text-primary)"},children:"Filters & Grouping"}),D&&jsxs("span",{style:{color:"var(--theme-accent-primary)",fontSize:"0.75rem",fontWeight:600},children:["(",[e.search&&"search",e.dateFilter!=="all"&&"date",e.priorities.length>0&&"priority",e.assignees.length>0&&"assignee",e.labels.length>0&&"label",t.by!=="none"&&"sort"].filter(Boolean).length," active)"]})]}),!f&&jsxs("div",{className:"filter-bar__content",children:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),l&&jsx("button",{onClick:l,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),c&&jsx("button",{onClick:c,className:"filter-bar__quick-btn",title:"Show high priority tasks",children:"High Priority"})]}),jsxs("div",{className:"filter-bar__main",children:[jsx("div",{className:"filter-bar__field",children:jsx("input",{type:"text",placeholder:"Search tasks...",value:e.search,onChange:x,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:b,className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Dates"}),jsx("option",{value:"overdue",children:"Overdue"}),jsx("option",{value:"today",children:"Today"}),jsx("option",{value:"this-week",children:"This Week"})]})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.priorities[0]||"all",onChange:N=>{let A=N.target.value;a({priorities:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Du.map(N=>jsx("option",{value:N,children:N},N))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:N=>{let A=N.target.value;a({assignees:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(N=>jsx("option",{value:N.id,children:N.name},N.id))]})}),n.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:N=>{let A=N.target.value;a({labels:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),n.map(N=>jsx("option",{value:N,children:N},N))]})}),jsxs("div",{className:"filter-bar__field filter-bar__sort",children:[jsx("span",{className:"filter-bar__label",style:{color:"var(--theme-text-secondary)"},children:"Sort:"}),jsx("select",{value:t.by,onChange:h,className:"filter-bar__select filter-bar__select--sm",children:Nu.map(N=>jsx("option",{value:N.value,children:N.label},N.value))}),t.by!=="none"&&jsx("button",{onClick:w,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),v&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:u,onChange:N=>v(N.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Su.map(N=>jsx("option",{value:N.value,children:N.label},N.value))})}),D&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function ys({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:l,onExportGanttPNG:c,onExportGanttCSV:p}){let[n,m]=useState(false),d=useRef(null);useEffect(()=>{let u=v=>{d.current&&!d.current.contains(v.target)&&m(false);};return n&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[n]);let i=u=>{u(),m(false);};return jsxs("div",{className:C("relative",r),ref:d,children:[jsxs("button",{onClick:()=>m(!n),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",u.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",u.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":n,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"3"}),jsx("path",{d:"M12 1v6m0 6v6M5.6 5.6l4.2 4.2m4.2 4.2l4.2 4.2M1 12h6m6 0h6M5.6 18.4l4.2-4.2m4.2-4.2l4.2-4.2"})]}),jsx("span",{children:"Config"})]}),n&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>i(e),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Export"]}):jsxs(Fragment,{children:[jsxs("button",{onClick:()=>i(async()=>await s?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Export PDF"]}),jsxs("button",{onClick:()=>i(async()=>await l?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),"Export Excel"]}),jsxs("button",{onClick:()=>i(async()=>await c?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Export PNG"]}),jsxs("button",{onClick:()=>i(()=>p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]}),"Export CSV"]})]}),jsxs("button",{onClick:()=>i(t),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v6m0 6v6m8.5-8.5L17 15M7 9L3.5 5.5M7 15l-3.5 3.5M20.5 5.5L17 9m3.5 11.5L17 17"})]}),"Themes"]}),jsxs("button",{onClick:()=>i(a),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),"Shortcuts"]})]})]})}var vs={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"}},xs={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"}},ks={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"}},br={dark:vs,light:xs,neutral:ks},_o="dark";var Vo=createContext(void 0),Ou="asakaa-theme";function Xl({children:e,defaultTheme:t=_o,storageKey:a=Ou}){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=br[r];Object.entries(p.colors).forEach(([m,d])=>{d&&c.style.setProperty(`--theme-${zu(m)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([m,d])=>{let i=p.colors[m];i&&c.style.setProperty(d,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let l={theme:r,setTheme:s,themes:br};return jsx(Vo.Provider,{value:l,children:e})}function Hr(){let e=useContext(Vo);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function zu(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function ws({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=Hr();return e?jsxs("div",{className:C("fixed inset-0 z-[9999] flex items-center justify-center",a),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),jsxs("div",{className:"relative rounded-2xl border shadow-2xl max-w-md w-full mx-4",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-6 py-5 border-b flex items-center justify-between",style:{borderColor:"var(--theme-border-primary)"},children:[jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--theme-text-primary)"},children:"Select Theme"}),jsx("button",{onClick:t,className:"text-2xl leading-none p-2 hover:bg-white/10 rounded-lg transition-colors",style:{color:"var(--theme-text-secondary)"},"aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"p-6 space-y-3",children:Object.entries(br).map(([s,l])=>jsxs("button",{onClick:()=>{o(s),t();},className:C("w-full p-4 rounded-lg border-2 transition-all flex items-center gap-4",r===s?"border-blue-500 bg-blue-500/20":"border-white/20 hover:border-white/40"),style:{backgroundColor:r===s?"var(--theme-accent-primary)20":"transparent"},children:[jsx("div",{className:"text-3xl",children:l.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:l.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Jl(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Ge[e]||Ge.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,l)=>a.getPropertyValue(s).trim()||l;return {bgPrimary:r("--theme-bg-primary",Ge[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Ge[e].bgSecondary),bgGrid:r("--theme-bg-card",Ge[e].bgGrid),bgWeekend:r("--theme-bg-hover",Ge[e].bgWeekend),border:r("--theme-border-primary",Ge[e].border),borderLight:r("--theme-border-subtle",Ge[e].borderLight),textPrimary:r("--theme-text-primary",Ge[e].textPrimary),textSecondary:r("--theme-text-secondary",Ge[e].textSecondary),textTertiary:r("--theme-text-tertiary",Ge[e].textTertiary),accent:r("--theme-accent-primary",Ge[e].accent),accentHover:r("--theme-accent-hover",Ge[e].accentHover),accentLight:r("--theme-accent-primary",Ge[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Ge[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Ge[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Ge[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Ge[e].dependency),dependencyHover:r("--theme-border-secondary",Ge[e].dependencyHover),criticalPath:r("--theme-error",Ge[e].criticalPath),criticalPathLight:r("--theme-error",Ge[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Ge[e].today):e==="neutral"?r("--theme-text-primary",Ge[e].today):r("--theme-error",Ge[e].today),todayLight:e==="light"?r("--theme-accent-primary",Ge[e].todayLight):e==="neutral"?r("--theme-text-primary",Ge[e].todayLight):r("--theme-error",Ge[e].todayLight),milestone:r("--theme-warning",Ge[e].milestone),milestoneLight:r("--theme-warning",Ge[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Ge[e].statusTodo),statusInProgress:r("--theme-accent-primary",Ge[e].statusInProgress),statusCompleted:r("--theme-success",Ge[e].statusCompleted),hoverBg:r("--theme-bg-hover",Ge[e].hoverBg),focusRing:r("--theme-accent-primary",Ge[e].focusRing)}}var jo={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"}},Zl={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"}},Cs={en:jo,es:Zl};function Ql(e){return Cs[e]||Cs.en}function Ts(e,t){let a=Ql(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 _r=createContext(jo);function po(){return useContext(_r)}function tg({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:l}){let[c,p]=useState(false),[n,m]=useState(null),d=useRef(null),i=po();if(useEffect(()=>{let g=x=>{d.current&&!d.current.contains(x.target)&&p(false);};return c&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[c]),!(t||a||r||o||s||l))return null;let v=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:l}].filter(g=>g.handler),f=async(g,x)=>{if(x){m(g);try{await x();}catch(b){console.error(`Export ${g} failed:`,b);}finally{m(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:i.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:v.map((g,x)=>jsxs(motion.button,{onClick:()=>f(g.id,g.handler),disabled:n!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:x<v.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:x*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:n===g.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):g.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:g.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:g.description})]})]},g.id))})})})]})}function ag({options:e,value:t,onChange:a,theme:r,layoutId:o="activeSegment"}){return jsx("div",{className:"inline-flex p-1 rounded-lg relative",style:{backgroundColor:r.bgSecondary,border:`1px solid ${r.borderLight}`},children:e.map(s=>{let l=t===s.value;return jsxs(motion.button,{onClick:()=>a(s.value),className:"relative px-3 py-1.5 rounded-md text-xs transition-all flex items-center gap-1.5 min-w-[70px] justify-center",style:{color:l?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500,zIndex:l?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[l&&jsx(motion.div,{layoutId:o,className:"absolute inset-0 rounded-md",style:{backgroundColor:r.accent,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},transition:{type:"spring",stiffness:400,damping:30}}),s.icon&&jsx("span",{className:"relative z-10",style:{color:l?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:l?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function rg({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 og({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),l=po();useEffect(()=>{let n=m=>{s.current&&!s.current.contains(m.target)&&o(false);};return r&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=[{value:"compact",label:l.toolbar.compact||"Compact"},{value:"comfortable",label:l.toolbar.normal||"Normal"},{value:"spacious",label:l.toolbar.spacious||"Spacious"}],p=c.find(n=>n.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${l.toolbar.density||"Density"}: ${p}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:c.map((n,m)=>{let d=t===n.value;return jsxs(motion.button,{onClick:()=>{a(n.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent",borderBottom:m<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:n.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},n.value)})})})})]})}function Ko({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:l,rowDensity:c,onRowDensityChange:p,showThemeSelector:n=false,showCreateTaskButton:m=false,createTaskLabel:d,onCreateTask:i,onExportPNG:u,onExportPDF:v,onExportExcel:f,onExportCSV:g,onExportJSON:x,onExportMSProject:b}){let h=po(),w=u||v||f||g||x||b,D=[{value:"day",label:h.toolbar.day},{value:"week",label:h.toolbar.week},{value:"month",label:h.toolbar.month}],N=[{value:"dark",label:"Dark",icon:jsx(Moon,{className:"w-3.5 h-3.5"})},{value:"light",label:"Light",icon:jsx(Sun,{className:"w-3.5 h-3.5"})},{value:"neutral",label:"Zen",icon:jsx(Palette,{className:"w-3.5 h-3.5"})}];return jsxs("div",{className:"h-12 px-4 flex items-center justify-between border-b",style:{backgroundColor:e.bgGrid,borderColor:e.border},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(rg,{options:D,value:t,onChange:A=>a(A),theme:e}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(motion.button,{onClick:()=>o(Math.max(.5,r-.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomOut,{className:"w-3.5 h-3.5"})}),jsxs("div",{className:"px-2 py-0.5 rounded text-xs tabular-nums min-w-[42px] text-center",style:{color:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},children:[Math.round(r*100),"%"]}),jsx(motion.button,{onClick:()=>o(Math.min(2,r+.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomIn,{className:"w-3.5 h-3.5"})})]}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(og,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[m&&i&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:i,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:d||h.toolbar.createTask})]}),(w||n)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),w&&jsxs(Fragment,{children:[jsx(tg,{theme:e,onExportPNG:u,onExportPDF:v,onExportExcel:f,onExportCSV:g,onExportJSON:x,onExportMSProject:b}),n&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),n&&jsx(ag,{options:N,value:s,onChange:A=>l(A),theme:e})]})]})}function Yo({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,l]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let m=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[r]);let n=e.filter(m=>m.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let m=p.current.getBoundingClientRect();l({x:m.left,y:m.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(rt,{children:jsx(motion.div,{ref:c,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),n.map(m=>jsxs("button",{onClick:()=>{t(m.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:m.label}),m.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},m.id))]})})})})]})}function Vr({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let l=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let m=200,d=r.length*36+8,i=8,u=window.innerWidth,v=window.innerHeight,f=t,g=a;t+m+i>u&&(f=t-m,f<i&&(f=i)),a+d+i>v&&(g=v-d-i,g<i&&(g=i)),p({x:f,y:g});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let m=i=>{l.current&&!l.current.contains(i.target)&&o();},d=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",m),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let n=m=>m.startsWith("#")&&(m.length===7||m.length===4)?m:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:l,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${c.x}px`,top:`${c.y}px`,backgroundColor:n(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(m=>jsxs("div",{children:[m.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{m.disabled||(m.onClick(),o());},disabled:m.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:m.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:m.disabled?"not-allowed":"pointer",opacity:m.disabled?.5:1},onMouseEnter:d=>{m.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[m.icon&&jsx("span",{style:{color:s.textSecondary},children:m.icon}),jsx("span",{className:"flex-1",children:m.label}),m.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},m.id))})})})}var wt={Edit:jsx(Edit3,{className:"w-4 h-4"}),Pencil:jsx(Pencil,{className:"w-4 h-4"}),Delete:jsx(Trash2,{className:"w-4 h-4"}),Add:jsx(Plus,{className:"w-4 h-4"}),AddSubtask:jsx(Plus,{className:"w-4 h-4"}),Remove:jsx(Minus,{className:"w-4 h-4"}),Link:jsx(Link2,{className:"w-4 h-4"}),Progress:jsx(BarChart3,{className:"w-4 h-4"}),Sort:jsx(ArrowUpDown,{className:"w-4 h-4"}),SortAsc:jsx(ArrowUp,{className:"w-4 h-4"}),SortDesc:jsx(ArrowDown,{className:"w-4 h-4"}),Hide:jsx(EyeOff,{className:"w-4 h-4"}),Show:jsx(Eye,{className:"w-4 h-4"}),Settings:jsx(Settings,{className:"w-4 h-4"}),Split:jsx(Scissors,{className:"w-4 h-4"}),MarkIncomplete:jsx(Circle,{className:"w-4 h-4"}),SetInProgress:jsx(PlayCircle,{className:"w-4 h-4"}),MarkComplete:jsx(CheckCircle2,{className:"w-4 h-4"})};function md({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:l,onTaskIndent:c,onTaskOutdent:p,onTaskRename:n,onTaskToggleExpand:m,onOpenTaskModal:d,enableKeyboard:i=true}){let u=useRef(false),v=useCallback(h=>{u.current=h;},[]),f=useCallback(h=>{let w=[],D=N=>{for(let A of N)w.push(A),A.subtasks&&A.subtasks.length>0&&A.isExpanded&&D(A.subtasks);};return D(h),w},[]),g=useCallback(()=>{let h=f(e);for(let w of h)if(t.has(w.id))return w;return null},[e,t,f]),x=useCallback((h,w)=>{let D=f(e);if(D.length===0)return;let N=g();if(!N){a(D[0].id,false);return}let A=D.findIndex(T=>T.id===N.id);if(A===-1)return;let y=h==="up"?A-1:A+1;if(y<0||y>=D.length)return;let R=D[y];a(R.id,w);},[e,g,f,a]),b=useCallback(h=>{if(!i)return;let w=h.target;if(w.tagName==="INPUT"||w.tagName==="TEXTAREA"||w.isContentEditable||u.current){h.key==="Escape"&&(w.blur(),u.current=false);return}let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?h.metaKey:h.ctrlKey,y=Array.from(t),R=g();if(h.key==="ArrowUp"){h.preventDefault(),x("up",h.shiftKey);return}if(h.key==="ArrowDown"){h.preventDefault(),x("down",h.shiftKey);return}if(R&&(h.key==="ArrowRight"||h.key==="ArrowLeft")){R.subtasks&&R.subtasks.length>0&&(h.preventDefault(),(h.key==="ArrowRight"&&!R.isExpanded||h.key==="ArrowLeft"&&R.isExpanded)&&m(R.id));return}if(h.altKey&&(h.key==="ArrowUp"||h.key==="ArrowDown")){y.length>0&&(h.preventDefault(),l(y,h.key==="ArrowUp"?"up":"down"));return}if(h.key==="Tab"&&!h.shiftKey){y.length>0&&(h.preventDefault(),c(y));return}if(h.key==="Tab"&&h.shiftKey){y.length>0&&(h.preventDefault(),p(y));return}if(h.key==="Enter"&&!h.shiftKey&&!A){R&&(h.preventDefault(),r(R.id,"below"));return}if(h.key==="Enter"&&h.shiftKey&&!A){R&&(h.preventDefault(),r(R.id,"above"));return}if(h.key==="Enter"&&A){R&&(h.preventDefault(),d(R.id));return}if(h.key==="F2"){R&&(h.preventDefault(),n(R.id));return}if(h.key==="Delete"||h.key==="Backspace"&&A){y.length>0&&(h.preventDefault(),o(y));return}if(h.key==="d"&&A&&!h.shiftKey){y.length>0&&(h.preventDefault(),s(y));return}},[i,t,g,x,r,o,s,l,c,p,n,m,d]);return useEffect(()=>{if(i)return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b);}},[i,b]),{setIsEditing:v}}function gd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(i=>{let u=new Set(i);return u.has(d)?u.delete(d):u.add(d),u}),r(d);},[]),l=useCallback((d,i)=>{if(!a){o(d);return}let u=i.indexOf(a),v=i.indexOf(d);if(u===-1||v===-1){o(d);return}let f=Math.min(u,v),g=Math.max(u,v),x=i.slice(f,g+1);t(new Set(x)),r(d);},[a,o]),c=useCallback((d,i,u,v)=>{v?l(d,i):u?s(d):o(d);},[o,s,l]),p=useCallback((d,i)=>{i?t(u=>{let v=new Set(u);return v.add(d),v}):o(d);},[o]),n=useCallback(()=>{t(new Set),r(null);},[]),m=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:l,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:n,isTaskSelected:m}}function jr(e){let t=[],a=(r,o,s=0)=>{for(let l=0;l<r.length;l++){let c={...r[l],parentId:o,level:s,position:l};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function fd(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=fd(a.subtasks,t);if(r)return r}}return null}function Ss(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Ss(a.subtasks,t);if(r)return r}return null}function Es(e,t){if(t.length===0)return e;let a=jr(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],l=(d,i)=>{let u=[];return {tasks:d.filter(f=>{if(i.has(f.id))return u.push(f),false;if(f.subtasks){let g=l(f.subtasks,i);f.subtasks=g.tasks,u.push(...g.removed);}return true}),removed:u}},c=(d,i,u)=>d.map(v=>v.id===i?{...v,subtasks:[...v.subtasks||[],...u],isExpanded:true}:v.subtasks?{...v,subtasks:c(v.subtasks,i,u)}:v),p=new Set(t),{tasks:n,removed:m}=l(e,p);return c(n,s.id,m)}function Ps(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Ss(a,r);if(!o)continue;let s=Ss(a,o.id),l=(n,m,d)=>{for(let i=0;i<n.length;i++){let u=n[i];if(u.id===m&&u.subtasks){let v=u.subtasks.findIndex(f=>f.id===d);if(v!==-1){let[f]=u.subtasks.splice(v,1);return f}}if(u.subtasks){let v=l(u.subtasks,m,d);if(v)return v}}return null},c=(n,m,d)=>{let i=n.findIndex(u=>u.id===m);if(i!==-1)return n.splice(i+1,0,d),n;for(let u of n)u.subtasks&&c(u.subtasks,m,d);return n},p=l(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function Ms(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(l,c,p)=>{let n=l.findIndex(d=>d.id===c);if(n===-1){for(let d of l)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let m=p==="up"?n-1:n+1;return m<0||m>=l.length?false:([l[n],l[m]]=[l[m],l[n]],true)};return s(r,o,a),r}function As(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 Is(e,t){let a=[...e];for(let r of t){let o=l=>{let c=l.findIndex(m=>m.id===r);if(c===-1){for(let m of l)if(m.subtasks&&o(m.subtasks))return true;return false}let p=l[c],n={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return l.splice(c+1,0,n),true},s=l=>l.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function hd(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=p=>{let n=p.findIndex(d=>d.id===t);if(n===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let m=a==="above"?n:n+1;return p.splice(m,0,l),true};return c(r),{tasks:r,newTask:l}}function Ls(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:Ls(r.subtasks,t,a)}:r)}function Fs(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:Fs(a.subtasks,t)}:a)}function Bs(e,t){let a=m=>{for(let d of m){if(d.id===t)return d;if(d.subtasks){let i=a(d.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(l),endDate:new Date(c),color:r?.color||"#3B82F6"},n=m=>m.map(d=>{if(d.id===t){let i=d.subtasks||[];return {...d,subtasks:[...i,p],isExpanded:true}}return d.subtasks?{...d,subtasks:n(d.subtasks)}:d});return {tasks:n(e),newTask:p}}function bd(e,t,a,r){if(t===a)return e;let o=fd(e,t);if(!o)return e;if(a){let c=(p,n)=>{if(!p.subtasks)return false;for(let m of p.subtasks)if(m.id===n||c(m,n))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),l=s(e);if(a===null){let c=r!==void 0?r:l.length;l.splice(c,0,{...o,parentId:void 0});}else {let c=p=>p.map(n=>{if(n.id===a){let m=n.subtasks||[],d=r!==void 0?r:m.length,i=[...m];return i.splice(d,0,{...o,parentId:a}),{...n,subtasks:i,isExpanded:true}}return n.subtasks&&n.subtasks.length>0?{...n,subtasks:c(n.subtasks)}:n});l=c(l);}return l}function Jo({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:l,onTaskContextMenu:c,onTaskToggle:p,scrollTop:n,columns:m,onToggleColumn:d,onColumnResize:i,onTaskUpdate:u,onTaskIndent:v,onTaskOutdent:f,onTaskMove:g,onMultiTaskDelete:x,onTaskDuplicate:b,onTaskCreate:h,onTaskRename:w,onCreateSubtask:D,onOpenTaskModal:N,onDeleteRequest:A,onTaskReparent:y}){let R=useContext(_r),[T,k]=useState(null),[B,P]=useState(false),[H,X]=useState(null),[be,ke]=useState(""),Ae=useRef(null),Fe=useRef(null),[z,F]=useState(null),[W,E]=useState(0),[K,te]=useState(0),[O,Me]=useState({isOpen:false,x:0,y:0,type:"header"}),[he,qe]=useState(null),[me,tt]=useState(null),[we,st]=useState(null),ht=useRef(0),Ft=5,Xe=useRef(false),[$,ne]=useState(null),[ve,Te]=useState(false),[De,Ye]=useState(null);useEffect(()=>{function _(q){Ae.current&&!Ae.current.contains(q.target)&&P(false);}if(B)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[B]),useEffect(()=>{H&&Fe.current&&(Fe.current.focus(),Fe.current.select());},[H]),useEffect(()=>{if(!z)return;let _=at=>{let Ue=at.clientX-W,le=K+Ue;i?.(z,le);},q=()=>{F(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",q),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",q),document.body.style.cursor="",document.body.style.userSelect="";}},[z,W,K,i]);let{selectedTaskIds:mt,handleTaskClick:Ie,isTaskSelected:I}=gd(),{setIsEditing:Y}=md({tasks:e,selectedTaskIds:mt,onTaskSelect:(_,q)=>{let Ue=jr(e).map(le=>le.id);Ie(_,Ue,q||false,false);},onTaskCreate:h||(()=>{}),onTaskDelete:x||(()=>{}),onTaskDuplicate:b||(()=>{}),onTaskMove:g||(()=>{}),onTaskIndent:v||(()=>{}),onTaskOutdent:f||(()=>{}),onTaskRename:_=>{let q=jr(e).find(at=>at.id===_);q&&Q(q);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:_=>{let q=jr(e).find(at=>at.id===_);q&&N&&N(q);},enableKeyboard:true}),He=(_,q=0)=>{let at=[];for(let Ue of _)at.push({task:Ue,level:q}),Ue.subtasks&&Ue.subtasks.length>0&&Ue.isExpanded&&at.push(...He(Ue.subtasks,q+1));return at},We=He(e),bt=48,J=_=>!_.startDate||!_.endDate?"-":`${Math.ceil((_.endDate.getTime()-_.startDate.getTime())/(1e3*60*60*24))}d`,Q=_=>{X(_.id),ke(_.name),Y(true);},xe=_=>{be.trim()&&be!==e.find(q=>q.id===_)?.name&&w?.(_,be.trim()),X(null),ke(""),Y(false);},Ce=()=>{X(null),ke(""),Y(false);},ae=(_,q)=>{q.stopPropagation(),D?.(_.id);},Pe=(_,q)=>{q.preventDefault(),ht.current=q.clientY,qe(_),Xe.current=false,Te(false),ne({x:q.clientX,y:q.clientY});},ye=_=>{if(!he||(Math.abs(_.clientY-ht.current)>Ft&&!Xe.current&&(Xe.current=true,Te(true)),ne({x:_.clientX,y:_.clientY}),!Xe.current))return;let at=document.querySelectorAll("[data-task-row]"),Ue=null,le=null;at.forEach(Ze=>{let Tt=Ze.getBoundingClientRect(),U=Ze.getAttribute("data-task-row");if(U&&U!==he&&_.clientY>=Tt.top&&_.clientY<=Tt.bottom){Ue=U;let ce=_.clientY-Tt.top,Se=Tt.height;ce<Se*.25?le="above":ce>Se*.75?le="below":le="child";}}),tt(Ue),st(le);},Ne=()=>{if(Xe.current&&he&&me&&we){if(we==="child")y?.(he,me);else if(we==="above"||we==="below"){let _=(Ue,le,Ze=null)=>{for(let Tt of Ue){if(Tt.id===le)return Ze;if(Tt.subtasks){let U=_(Tt.subtasks,le,Tt.id);if(U!==void 0)return U}}},q=_(e,me,null),at=(Ue,le)=>{let Ze=Ue.findIndex(Tt=>Tt.id===le);return we==="below"?Ze+1:Ze};if(q===null){let Ue=at(e,me);y?.(he,null,Ue);}else {let Ue=We.find(le=>le.task.id===q)?.task;if(Ue?.subtasks){let le=at(Ue.subtasks,me);y?.(he,q,le);}}}}qe(null),tt(null),st(null),ne(null),Xe.current=false,Te(false);};useEffect(()=>{if(he)return document.addEventListener("mousemove",ye),document.addEventListener("mouseup",Ne),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",Ne),document.body.style.cursor="",document.body.style.userSelect="";}},[he,me,we]);let se=(_,q,at)=>{switch(_.id){case "name":let Ue=H===q.id,le=T===q.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${at*20}px`},children:[y&&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:le?1:.3},onMouseDown:de=>Pe(q.id,de),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),q.subtasks&&q.subtasks.length>0?jsx("button",{onClick:de=>{de.stopPropagation(),p?.(q.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:q.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"}),!(q.subtasks&&q.subtasks.length>0)&&jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0 border",style:{backgroundColor:q.color||"#3B82F6",opacity:q.parentId?.6:1,borderColor:q.isMilestone?t.accent:"transparent",borderWidth:q.isMilestone?"2px":"0px"},title:q.isMilestone?"Milestone":q.parentId?"Subtask":"Task"}),Ue?jsx("input",{ref:Fe,type:"text",value:be,onChange:de=>ke(de.target.value),onKeyDown:de=>{de.key==="Enter"?xe(q.id):de.key==="Escape"&&Ce();},onBlur:()=>xe(q.id),className:"flex-1 px-2 py-1 rounded border outline-none",style:{backgroundColor:t.bgPrimary,borderColor:t.accent,color:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:"13px",fontWeight:500},onClick:de=>de.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:q.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:q.parentId?"13px":"14px",fontWeight:q.isMilestone?600:q.parentId?400:600,letterSpacing:q.parentId?"0":"-0.01em"},title:q.name,children:q.name}),le&&!Ue&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:de=>de.stopPropagation(),children:[jsx("button",{onClick:de=>ae(q,de),className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Create subtask",children:jsx(Plus,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:de=>{de.stopPropagation(),Q(q);},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 Tt=_.id==="startDate"?"startDate":"endDate",U=q[Tt],ce=De?.taskId===q.id&&De?.field===Tt,Se=de=>de?(typeof de=="string"?new Date(de):de).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:de=>de.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:de=>{if(ce)Ye(null);else {let Dt=de.currentTarget.getBoundingClientRect();Ye({taskId:q.id,field:Tt,month:U?typeof U=="string"?new Date(U):U:new Date,position:{top:Dt.bottom+4,left:Dt.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Se(U)})]}),ce&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>Ye(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:De?.position.top,left:De?.position.left},onClick:de=>de.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let de=new Date,Dt=new Date(de);Dt.setDate(de.getDate()+1);let Jt=new Date(de);Jt.setDate(de.getDate()+7);let Pr=new Date(de);return Pr.setDate(de.getDate()+14),[{label:"Hoy",date:de},{label:"Ma\xF1ana",date:Dt},{label:"Pr\xF3xima semana",date:Jt},{label:"2 semanas",date:Pr}].map((Ar,Ha)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:lr=>lr.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:lr=>lr.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(q.id,{[Tt]:Ar.date}),Ye(null);},children:Ar.label},Ha))})(),jsx("div",{style:{borderTop:`1px solid ${t.border}`,margin:"0.25rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:de=>de.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:de=>de.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(q.id,{[Tt]:void 0}),Ye(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:()=>Ye(de=>de?{...de,month:new Date(de.month.getFullYear(),de.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:De?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>Ye(de=>de?{...de,month:new Date(de.month.getFullYear(),de.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((de,Dt)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:de},Dt))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let de=De?.month||new Date,Dt=de.getFullYear(),Jt=de.getMonth(),Pr=new Date(Dt,Jt,1).getDay(),Mr=new Date(Dt,Jt+1,0).getDate(),Ar=new Date,Ha=[];for(let Nt=Pr-1;Nt>=0;Nt--)Ha.push({day:new Date(Dt,Jt,-Nt).getDate(),date:new Date(Dt,Jt-1,new Date(Dt,Jt,-Nt).getDate()),isCurrentMonth:false});for(let Nt=1;Nt<=Mr;Nt++)Ha.push({day:Nt,date:new Date(Dt,Jt,Nt),isCurrentMonth:true});let lr=42-Ha.length;for(let Nt=1;Nt<=lr;Nt++)Ha.push({day:Nt,date:new Date(Dt,Jt+1,Nt),isCurrentMonth:false});return Ha.map((Nt,Pn)=>{let Mn=Nt.date.toDateString()===Ar.toDateString(),Ir=(U?typeof U=="string"?new Date(U):U:null)?.toDateString()===Nt.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:Nt.isCurrentMonth?Ir?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Ir?"#3B82F6":"transparent",boxShadow:Mn&&!Ir?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{u?.(q.id,{[Tt]:Nt.date}),Ye(null);},children:Nt.day},Pn)})})()})]})]})]}),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:J(q)})});case "assignees":let $t=r.filter(de=>q.assignees?.some(Dt=>Dt.name===de.name||Dt.initials===de.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:de=>de.stopPropagation(),children:jsx(ur,{assignedUsers:$t,availableUsers:r,onChange:de=>{let Dt=de.map(Jt=>({id:Jt.id,name:Jt.name,initials:Jt.initials,color:Jt.color}));u?.(q.id,{assignees:Dt.length>0?Dt:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:de=>de.stopPropagation(),children:jsx(ul,{status:q.status||"todo",onChange:de=>{u?.(q.id,{status:de,progress:de==="completed"?100:q.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:`${q.progress}%`,backgroundColor:q.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:[q.progress,"%"]})]});case "priority":let ea={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},Xa={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},Ra=ea[q.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:de=>de.stopPropagation(),children:jsx(pr,{priority:Ra,onChange:de=>{de&&u?.(q.id,{priority:Xa[de]||"medium"});}})});default:return null}},Re=_=>[{id:"hide",label:"Hide Column",icon:wt.Hide,onClick:()=>d(_),disabled:_==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:wt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:wt.SortDesc,onClick:()=>{}}],Le=_=>_.subtasks&&_.subtasks.length>0?[{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:wt.Add,onClick:()=>{D?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:wt.Delete,onClick:()=>{A?A(_.id,_.name):x?.([_.id]);}}]:[{id:"edit",label:R?.contextMenu?.editTask||"Edit Task",icon:wt.Pencil,onClick:()=>{l?.(_);}},{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:wt.Add,onClick:()=>{D?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:R?.contextMenu?.markIncomplete||"Mark Incomplete",icon:wt.MarkIncomplete,onClick:()=>{u?.(_.id,{status:"todo",progress:0});},disabled:_.status==="todo"},{id:"setInProgress",label:R?.contextMenu?.setInProgress||"Set In Progress",icon:wt.SetInProgress,onClick:()=>{u?.(_.id,{status:"in-progress"});},disabled:_.status==="in-progress"},{id:"markComplete",label:R?.contextMenu?.markComplete||"Mark Complete",icon:wt.MarkComplete,onClick:()=>{u?.(_.id,{status:"completed",progress:100});},disabled:_.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:R?.contextMenu?.splitTask||"Split Task",icon:wt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:wt.Delete,onClick:()=>{A?A(_.id,_.name):x?.([_.id]);}}],$e=m.filter(_=>_.visible);return jsxs("div",{className:"h-full overflow-hidden",style:{backgroundColor:t.bgPrimary},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${bt}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[$e.map((_,q)=>{let at=q===$e.length-1,Ue=_.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${Ue?"":"justify-center"}`,style:{width:`${_.width}px`,minWidth:`${_.minWidth??(Ue?200:60)}px`,maxWidth:`${_.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:at?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:le=>{le.preventDefault(),Me({isOpen:true,x:le.clientX,y:le.clientY,type:"header",columnId:_.id});},onMouseEnter:le=>{le.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:le=>{le.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:Ue?"70px":"0"},title:_.label,children:_.label}),Ue&&jsxs("div",{className:"absolute flex items-center gap-1",style:{right:"4px",top:"50%",transform:"translateY(-50%)",zIndex:4},children:[jsx(Yo,{columns:m,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>P(!B),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors relative group",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})})]}),_.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:z===_.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:le=>{le.preventDefault(),le.stopPropagation(),F(_.id),E(le.clientX),te(_.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},_.id)}),B&&jsxs("div",{ref:Ae,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:_=>_.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>P(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:t.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]}),jsx("div",{className:"gantt-taskgrid-content",children:We.map(({task:_,level:q},at)=>{let Ue=I(_.id),le=me===_.id,Ze=le&&we==="above",Tt=le&&we==="below",U=le&&we==="child",ce={};return U&&(ce.backgroundColor=`${t.accent}15`,ce.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":_.id,className:`flex items-center cursor-pointer group ${he===_.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:Ue?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:Ue?t.accentLight:U?`${t.accent}15`:at%2===0?t.bgPrimary:t.bgGrid,...ce},onMouseEnter:()=>k(_.id),onMouseLeave:()=>k(null),onClick:Se=>{let ea=jr(e).map(de=>de.id),Ra=navigator.platform.toUpperCase().indexOf("MAC")>=0?Se.metaKey:Se.ctrlKey;Ie(_.id,ea,Ra,Se.shiftKey),s?.(_);},onDoubleClick:Se=>{Se.stopPropagation(),l?.(_);},onContextMenu:Se=>{Se.preventDefault(),Me({isOpen:true,x:Se.clientX,y:Se.clientY,type:"task",task:_}),c?.(_,Se);},whileHover:{backgroundColor:Ue?t.accentLight:t.hoverBg},children:[Ze&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Tt&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),$e.map((Se,$t)=>{let ea=$t===$e.length-1,Xa=Se.id==="name";return jsx("div",{className:`px-4 flex items-center ${Xa?"justify-start":"justify-center"}`,style:{width:`${Se.width}px`,minWidth:`${Se.minWidth??(Xa?200:60)}px`,maxWidth:`${Se.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:ea?"none":`1px solid ${T===_.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:se(Se,_,Xa?q:0)},`${_.id}-${Se.id}`)})]},_.id)})}),jsx(Vr,{isOpen:O.isOpen,x:O.x,y:O.y,items:O.type==="header"&&O.columnId?Re(O.columnId):O.type==="task"&&O.task?Le(O.task):[],onClose:()=>Me({...O,isOpen:false}),theme:t}),ve&&$&&he&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:$.x+12,top:$.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let _=We.find(q=>q.task.id===he)?.task;return _?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:_.name})}):null})()}),document.body)]})}function wd(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[l,c]=useState(e),[p,n]=useState(t),[m,d]=useState(null),[i,u]=useState(null),[v,f]=useState(null),[g,x]=useState(null),[b,h]=useState(0),[w,D]=useState(0),[N,A]=useState(null),[y,R]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:l,setGhostX:c,ghostWidth:p,setGhostWidth:n,connectionLine:m,setConnectionLine:d,hoveredTaskId:i,setHoveredTaskId:u,activeZone:v,setActiveZone:f,draggedSegmentIndex:g,setDraggedSegmentIndex:x,draggedSegmentStartX:b,setDraggedSegmentStartX:h,segmentDragOffsetX:w,setSegmentDragOffsetX:D,hoveredSegmentIndex:N,setHoveredSegmentIndex:A,isHovered:y,setIsHovered:R,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(H,X)=>{r("none"),d(null),u(null),c(H),n(X),D(0),x(null),h(0);}}}function Zo({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:l,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:u=[],onDragMove:v,onHoverChange:f}){let g=wd(t,r),x=useRef(null),{dragMode:b,setDragMode:h,dragOffset:w,setDragOffset:D,ghostX:N,setGhostX:A,ghostWidth:y,setGhostWidth:R,connectionLine:T,setConnectionLine:k,hoveredTaskId:B,setHoveredTaskId:P,activeZone:H,setActiveZone:X,draggedSegmentIndex:be,setDraggedSegmentIndex:ke,draggedSegmentStartX:Ae,setDraggedSegmentStartX:Fe,segmentDragOffsetX:z,setSegmentDragOffsetX:F,hoveredSegmentIndex:W,setHoveredSegmentIndex:E,isHovered:K,setIsHovered:te,isDragging:O,isResizing:Me,isConnecting:he,resetDragState:qe}=g,me=32,tt=8,we=e.endDate&&e.endDate<new Date&&e.progress<100,st=e.isCriticalPath,ht=o.name==="neutral"||o.today==="#1C1917",Ft=e.status==="completed"||e.progress===100,Xe={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},ne=e.isCriticalPath||we?"#DC2626":e.color?e.color:e.priority&&Xe[e.priority]?Xe[e.priority]:o.taskBarPrimary,Te=(ae=>ae>=80?20:ae>=60?15:ae>=50?12:10)(r),De=r<50,Ye=r<40;useEffect(()=>{if(f)if(K&&!O&&!e.segments){let ae=a<100;f({task:e,x:t,y:a,width:r,height:me,showBelow:ae});}else f(null);},[K,O,e,t,a,r,me,f]);let mt=ae=>ae.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Ie=()=>{let ae=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${ae} day${ae!==1?"s":""}`},I=ae=>Math.round(ae/s)*s,Y=ae=>{let Pe=Math.round(ae/s),ye=new Date(l);return ye.setDate(ye.getDate()+Pe),ye},He=(ae,Pe)=>{for(let ye of u){if(ye.id===e.id)continue;let Ne=5;if(ae>=ye.x-Ne&&ae<=ye.x+ye.width+Ne&&Pe>=ye.y-Ne&&Pe<=ye.y+ye.height+Ne)return ye.id}return null},We=useCallback((ae,Pe,ye)=>{ae.preventDefault(),ae.stopPropagation();let Ne=x.current?.ownerSVGElement;if(!Ne)return;let se=Ne.createSVGPoint();se.x=ae.clientX,se.y=ae.clientY;let Re=se.matrixTransform(Ne.getScreenCTM()?.inverse()),Le=ye!==void 0?ye:t,$e=Pe;if(!$e){let _=Re.x-Le;ae.shiftKey?($e="connect",k({x:t+r,y:a+me/2})):ae.ctrlKey||ae.metaKey?$e="move":ae.altKey?$e=_<r/2?"resize-start":"resize-end":Ye?_<r/2?$e="move":$e="resize-end":De?_<=Te/2?$e="resize-start":_>=r-Te/2?$e="resize-end":$e="move":_<=Te?$e="resize-start":_>=r-Te?$e="resize-end":$e="move";}h($e),te(false),X(null),$e==="move"?D(Re.x-Le):$e==="connect"?k({x:t+r,y:a+me/2}):D(0),A(Le),R(r);},[t,r,a,me]),bt=useCallback(ae=>{if(b==="none")return;let Pe=x.current?.ownerSVGElement;if(!Pe)return;let ye=Pe.createSVGPoint();ye.x=ae.clientX,ye.y=ae.clientY;let Ne=ye.matrixTransform(Pe.getScreenCTM()?.inverse());if(b==="connect"){k({x:Ne.x,y:Ne.y});let se=He(Ne.x,Ne.y);P(se);}else if(b==="move"){let se=Ne.x-w,Re=I(se);A(Re),R(r);let Le=Math.round((Re-t)/s);if(v?.(e.id,Le,true),e.segments&&e.segments.length>0&&be!==null){let $e=Re-Ae;F($e);}}else if(b==="resize-start"){let se=Ne.x,Re=I(se),Le=t+r-Re;Le>=s&&(A(Re),R(Le));}else if(b==="resize-end"){let se=Ne.x,Le=I(se)-t;Le>=s&&R(Le);}},[b,t,r,s,w,e,I,be,Ae,He,P,k,A,R,F,v]),J=useCallback(()=>{if(b!=="none"){if(b==="connect")B&&i&&i(e,B),k(null),P(null);else {let ae=e.endDate.getTime()-e.startDate.getTime(),Pe,ye,Ne=true;if(b==="move"){if(Pe=Y(N),ye=new Date(Pe.getTime()+ae),e.segments&&e.segments.length>0&&be!==null){let se=Math.round(z/s),Re=e.segments.map((q,at)=>{if(at===be){let Ue=new Date(q.startDate),le=new Date(q.endDate);return Ue.setDate(Ue.getDate()+se),le.setDate(le.getDate()+se),{startDate:Ue,endDate:le}}return q}),Le=Re.flatMap(q=>[q.startDate,q.endDate]),$e=new Date(Math.min(...Le.map(q=>q.getTime()))),_=new Date(Math.max(...Le.map(q=>q.getTime())));d?.({...e,segments:Re},$e,_),qe(t,r);return}}else b==="resize-start"?(Pe=Y(N),ye=e.endDate,Pe>=ye&&(console.warn("Invalid date range: start date must be before end date"),Ne=false)):b==="resize-end"?(Pe=e.startDate,ye=Y(N+y),ye<=Pe&&(console.warn("Invalid date range: end date must be after start date"),Ne=false)):Ne=false;Ne&&Pe&&ye&&(ye.getTime()-Pe.getTime()<864e5?console.warn("Invalid date range: task must be at least 1 day long"):d?.(e,Pe,ye));}v?.(e.id,0,false),qe(t,r);}},[b,N,y,e,d,B,i,t,r,s,Y,z,be,qe,v]);useEffect(()=>{if(b==="none")return;let ae=ye=>{bt(ye);},Pe=()=>{J();};return window.addEventListener("mousemove",ae),window.addEventListener("mouseup",Pe),()=>{window.removeEventListener("mousemove",ae),window.removeEventListener("mouseup",Pe);}},[b,bt,J]);let Q=O&&!he?N:t,xe=O&&!he?y:r,Ce=c.taskClass(e);return jsxs("g",{ref:x,onMouseEnter:()=>!O&&te(true),onMouseLeave:()=>{O||(te(false),X(null));},onClick:()=>!O&&p?.(e),onDoubleClick:ae=>{O||(ae.stopPropagation(),n?.(e));},onContextMenu:ae=>{ae.preventDefault(),m?.(e,ae);},children:[K&&!O&&!De&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Te,height:me,fill:H==="resize-start"?o.accent:"transparent",opacity:H==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-start"),onMouseDown:ae=>We(ae,"resize-start")}),jsx("rect",{x:t+Te,y:a,width:r-Te*2,height:me,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>X("move"),onMouseDown:ae=>We(ae,"move")}),jsx("rect",{x:t+r-Te,y:a,width:Te,height:me,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-end"),onMouseDown:ae=>We(ae,"resize-end")})]}),K&&!O&&Ye&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:me,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>X("move"),onMouseDown:ae=>We(ae,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:me,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>X("resize-end"),onMouseDown:ae=>We(ae,"resize-end")}),K&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+me-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),O&&!he&&!e.segments&&jsx(motion.rect,{x:N,y:a,width:y,height:me,rx:tt,fill:o.accent,opacity:.5,stroke:o.accent,strokeWidth:2,strokeDasharray:"4 4",initial:{opacity:0},animate:{opacity:.6},transition:{duration:.15},style:{pointerEvents:"none"}}),!e.segments&&jsx(motion.rect,{x:Q,y:a,width:xe,height:me,rx:tt,fill:ne,"data-task-class":Ce,initial:{opacity:0,scale:.95},animate:{opacity:O&&!he?.15:e.parentId?.6:K?.9:.8,scale:K&&!O?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:ae=>We(ae),style:{cursor:O?he?"crosshair":Me?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:Q,y:a,width:xe*(e.progress/100),height:me,rx:tt,fill:ne,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((ae,Pe)=>{let ye=(ae.startDate.getTime()-l.getTime())/864e5*s,se=(ae.endDate.getTime()-l.getTime())/(1e3*60*60*24)*s-ye+s,Re=O&&b==="move"&&be===Pe,Le=W===Pe,$e=Re?ye+z:ye;return jsxs("g",{onMouseEnter:()=>!O&&E(Pe),onMouseLeave:()=>!O&&E(null),children:[jsx(motion.rect,{x:$e,y:a,width:se,height:me,rx:tt,fill:ne,initial:{opacity:0,scale:.95},animate:{opacity:Re||e.parentId?.6:Le?.9:.8,scale:Le&&!O?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:_=>{_.stopPropagation(),ke(Pe),Fe(ye),We(_,void 0,ye);},style:{cursor:O?he?"crosshair":Me?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:$e,y:a,width:se*(e.progress/100),height:me,rx:tt,fill:ne,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Pe}`)}),ht&&(we||st)&&!e.segments&&jsxs(Fragment,{children:[st&&!we&&jsx("rect",{x:Q,y:a,width:xe,height:me,rx:tt,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),we&&jsx("rect",{x:Q,y:a,width:xe,height:me,rx:tt,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),xe>60&&!e.segments&&(()=>{let ae=c.taskLabel(e),Pe=typeof ae=="string"?ae:e.name,ye=Pe.length>Math.floor(xe/8)?`${Pe.substring(0,Math.floor(xe/8))}...`:Pe;return jsx("text",{x:Q+12,y:a+me/2,dominantBaseline:"middle",fill:Ft?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:Ft?"line-through":"none"},children:ye})})(),xe>100&&e.progress>0&&e.progress<100&&!O&&!e.segments&&jsxs("text",{x:Q+xe-12,y:a+me/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&&xe>80&&!O&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:Q+xe-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:Q+xe-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(K||Me)&&!he&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:De?Q-15:Q-10,y:a-5,width:De?25:20,height:me+10,fill:"transparent",onMouseDown:ae=>We(ae,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:De?Q-8:Q-3,y:a+6,width:De?8:6,height:De?me-12:me-16,rx:3,fill:b==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:b==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Q+xe-10,y:a-5,width:De?25:20,height:me+10,fill:"transparent",onMouseDown:ae=>We(ae,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:De?Q+xe:Q+xe-3,y:a+6,width:De?8:6,height:De?me-12:me-16,rx:3,fill:b==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:b==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:K&&!O&&!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+me/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:ae=>{ae.stopPropagation(),We(ae,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+me/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),he&&T&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+me/2,x2:T.x,y2:T.y,stroke:B?o.statusCompleted:o.accent,strokeWidth:B?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:B?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:T.x,cy:T.y,r:B?8:6,fill:B?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),B&&jsx(motion.text,{x:T.x+15,y:T.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:T.x+10},animate:{opacity:1,x:T.x+15},transition:{duration:.2},children:"Connect"})]}),(K||O)&&!he&&!e.segments&&jsx(motion.rect,{x:Q-2,y:a-2,width:xe+4,height:me+4,rx:tt+2,fill:"none",stroke:O?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:O?.6:.4,initial:{opacity:0},animate:{opacity:O?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),Me&&jsxs(Fragment,{children:[jsx("line",{x1:N,y1:0,x2:N,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:N+y,y1:0,x2:N+y,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:K&&!O&&!e.segments&&!f&&(()=>{let ye=a<100,Ne=ye?a+me+13:a-82-13,se=ye?`M ${Q+xe/2-6} ${a+me+3} L ${Q+xe/2} ${a+me+13} L ${Q+xe/2+6} ${a+me+3}`:`M ${Q+xe/2-6} ${a-13} L ${Q+xe/2} ${a-3} L ${Q+xe/2+6} ${a-13}`,Re=Ne+22,Le=Ne+40,$e=Ne+55,_=Ne+70,q=ye?Ne+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:ye?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:ye?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:se,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:Q+xe/2-120,y:Ne,width:240,height:82,rx:8,fill:o.bgSecondary,stroke:o.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:Q+xe/2,y:Re,textAnchor:"middle",fill:o.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>28?`${e.name.substring(0,28)}...`:e.name}),jsx("text",{x:Q+xe/2-110,y:Le,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:Q+xe/2-70,y:Le,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:mt(e.startDate)}),jsx("text",{x:Q+xe/2-110,y:$e,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:Q+xe/2-70,y:$e,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:mt(e.endDate)}),jsx("text",{x:Q+xe/2+10,y:Le,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:Q+xe/2+65,y:Le,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ie()}),jsx("text",{x:Q+xe/2+10,y:$e,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:Q+xe/2+65,y:$e,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.progress,"%"]}),e.assignees&&e.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:Q+xe/2-110,y:_,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:Q+xe/2-50,y:_,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(at=>at.name).join(", ").substring(0,30),e.assignees.map(at=>at.name).join(", ").length>30?"...":""]})]}),!ye&&jsx("text",{x:Q+xe/2,y:q,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:Ye?"Left: move \u2022 Right: resize":De?"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 Dd({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:l,showBelow:c}=e,p=82,n=13,m=c?o+l+n:o-p-n,d=c?`M ${r+s/2-6} ${o+l+3} L ${r+s/2} ${o+l+13} L ${r+s/2+6} ${o+l+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,i=m+22,u=m+40,v=m+55,f=m+70,g=w=>w.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),x=()=>{if(!a.startDate||!a.endDate)return "N/A";let w=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${w} day${w!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:m,width:240,height:p,rx:8,fill:t.bgSecondary,stroke:t.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:r+s/2,y:i,textAnchor:"middle",fill:t.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:a.name.length>28?`${a.name.substring(0,28)}...`:a.name}),jsx("text",{x:r+s/2-110,y:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?g(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:v,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:v,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?g(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:x()}),jsx("text",{x:r+s/2+10,y:v,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:v,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.progress,"%"]}),a.assignees&&a.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:r+s/2-110,y:f,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:f,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(w=>w.name).join(", ").substring(0,30),a.assignees.map(w=>w.name).join(", ").length>30?"...":""]})]})]})})}function tn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:l}){let[c,p]=useState(false),n=a-e,m=r-t,d=e+n/2,i=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,u=6,v=Math.atan2(m,n),f=a-u*Math.cos(v-Math.PI/6),g=r-u*Math.sin(v-Math.PI/6),x=a-u*Math.cos(v+Math.PI/6),b=r-u*Math.sin(v+Math.PI/6),h=o.dependency;useEffect(()=>{l&&s&&l(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,l]);let w=!s&&!l;return jsxs("g",{onMouseEnter:()=>!w&&p(true),onMouseLeave:()=>!w&&p(false),style:{pointerEvents:w?"none":"auto"},children:[!w&&jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:h,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&l?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${f} ${g} M ${a} ${r} L ${x} ${b}`,fill:"none",stroke:h,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&l?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:h,initial:{scale:0},animate:{scale:c&&l?0:c?1.3:1,opacity:c&&l?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!l&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:D=>{D.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function rn({task:e,x:t,y:a,theme:r,onClick:o}){let[s,l]=useState(false),c=16,p=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:p(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var ie={calculateEndDate:(e,t)=>{let a=new Date(e);return a.setDate(a.getDate()+t),a},calculateDuration:(e,t)=>{let a=t.getTime()-e.getTime();return Math.ceil(a/(1e3*60*60*24))},calculateWorkingDays:(e,t)=>{let a=0,r=new Date(e);for(;r<=t;){let o=r.getDay();o!==0&&o!==6&&a++,r.setDate(r.getDate()+1);}return a},addWorkingDays:(e,t)=>{let a=new Date(e),r=0;for(;r<t;){a.setDate(a.getDate()+1);let o=a.getDay();o!==0&&o!==6&&r++;}return a},isWeekend:e=>{let t=e.getDay();return t===0||t===6},validateDependencies:(e,t,a)=>{let r=new Map,o=n=>{n.forEach(m=>{m.dependencies&&r.set(m.id,m.dependencies),m.subtasks&&o(m.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let l=new Set,c=new Set,p=n=>{if(!l.has(n)){l.add(n),c.add(n);let m=r.get(n)||[];for(let d of m){if(!l.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(n),false};return p(a)},flattenTasks:e=>{let t=[],a=r=>{r.forEach(o=>{t.push(o),o.subtasks&&o.subtasks.length>0&&a(o.subtasks);});};return a(e),t},findTaskById:(e,t)=>{for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=ie.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=ie.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=ie.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=ie.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=ie.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=ie.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)=>ie.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=ie.findTaskById(e,t);return !a||!a.dependencies?[]:ie.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>ie.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>ie.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=ie.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=>ie.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=ie.flattenTasks(e);if(s.length===0){alert("No tasks found to export");return}o.setFontSize(16),o.text("Gantt Chart - Task List",14,20);let l=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],c=s.map(p=>{let n=p.startDate&&p.endDate?ie.calculateDuration(p.startDate,p.endDate):0;return [p.name,p.startDate?ie.formatDate(p.startDate):"N/A",p.endDate?ie.formatDate(p.endDate):"N/A",n>0?`${n} days`:"N/A",`${p.progress}%`,p.status||"N/A"]});r(o,{head:l,body:c,startY:30,styles:{fontSize:9,cellPadding:3},headStyles:{fillColor:[66,139,202],textColor:255,fontStyle:"bold"},alternateRowStyles:{fillColor:[245,245,245]},columnStyles:{0:{cellWidth:60},1:{cellWidth:30},2:{cellWidth:30},3:{cellWidth:25},4:{cellWidth:20},5:{cellWidth:25}}}),o.save(t);}catch(a){throw a}},exportToExcel:async(e,t="gantt-chart.xlsx")=>{let a=await import('xlsx'),o=ie.flattenTasks(e).map(p=>{let n=p.startDate&&p.endDate?ie.calculateDuration(p.startDate,p.endDate):0;return {"Task ID":p.id,"Task Name":p.name,"Start Date":p.startDate?ie.formatDate(p.startDate):"","End Date":p.endDate?ie.formatDate(p.endDate):"","Duration (days)":n>0?n:"","Progress (%)":p.progress,Status:p.status||"",Assignees:p.assignees?.map(m=>m.name).join(", ")||"",Dependencies:p.dependencies?.join(", ")||"","Is Milestone":p.isMilestone?"Yes":"No","Parent ID":p.parentId||"",Level:p.level||0}}),s=a.utils.json_to_sheet(o),l=[{wch:15},{wch:40},{wch:12},{wch:12},{wch:15},{wch:12},{wch:15},{wch:30},{wch:20},{wch:12},{wch:15},{wch:8}];s["!cols"]=l;let c=a.utils.book_new();a.utils.book_append_sheet(c,s,"Gantt Tasks"),a.writeFile(c,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=ie.flattenTasks(e),o=new Map;r.forEach((i,u)=>{o.set(i.id,u+1);});let s=i=>i.toISOString().replace("Z",""),l=ie.getEarliestStartDate(e)||new Date,c=ie.getLatestEndDate(e)||new Date,p=r.map((i,u)=>{let v=o.get(i.id),f=i.startDate&&i.endDate?ie.calculateDuration(i.startDate,i.endDate):0,g=(i.dependencies||[]).filter(x=>o.has(x)).map(x=>`
113
113
  <PredecessorLink>
114
114
  <PredecessorUID>${o.get(x)}</PredecessorUID>
115
115
  <Type>1</Type>
@@ -118,7 +118,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
118
118
  <LagFormat>7</LagFormat>
119
119
  </PredecessorLink>`).join("");return `
120
120
  <Task>
121
- <UID>${y}</UID>
121
+ <UID>${v}</UID>
122
122
  <ID>${u+1}</ID>
123
123
  <Name>${i.name.replace(/[<>&'"]/g,x=>({"<":"&lt;",">":"&gt;","&":"&amp;","'":"&apos;",'"':"&quot;"})[x]||x)}</Name>
124
124
  <Type>0</Type>
@@ -339,9 +339,9 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
339
339
  </Calendars>
340
340
  <Tasks>${p}
341
341
  </Tasks>
342
- </Project>`,m=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(m),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=ne.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let m=n.startDate&&n.endDate?ne.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let y=t.find(f=>f.id===u);if(y){o(y);let f=r.get(u)?.ef||0;d=Math.max(d,f);}}let i=d+m;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,c=n=>{if(l.has(n.id))return;let m=n.startDate&&n.endDate?ne.calculateDuration(n.startDate,n.endDate):0,d=t.filter(y=>y.dependencies&&y.dependencies.includes(n.id)),i=s;if(d.length>0)for(let y of d){c(y);let f=l.get(y.id)?.ls||0;i=Math.min(i,f);}let u=i-m;l.set(n.id,{ls:u,lf:i});};a.forEach(c);let p=[];for(let n of a){let m=r.get(n.id),d=l.get(n.id);if(m&&d){let i=d.ls-m.es;Math.abs(i)<.01&&p.push(n.id);}}return p},calculateSlack:(e,t)=>{let a=ne.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(ne.calculateCriticalPath(e).includes(t))return 0;let o=ne.getDependentTasks(e,t);if(o.length===0){let c=ne.getLatestEndDate(e);if(!c)return null;let p=ne.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 l=ne.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>ne.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=ne.findTaskById(e,t);if(!r||!r.endDate)return e;let o=ne.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let c=ne.calculateDuration(l.startDate,l.endDate),p;a!==void 0?(p=new Date(l.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=ne.calculateEndDate(p,c),m=d=>d.map(i=>i.id===l.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:m(i.subtasks)}:i);s=m(s),s=ne.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,c)=>{if(a===0)return [];let p=[],n=o.getTime(),m=1e3*60*60*24,d=ne.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,y,f=new Set)=>{if(f.has(u))return;f.add(u);let g=ne.getDependentTasks(e,u);for(let x of g){if(!x.startDate||!x.endDate)continue;let b=r.findIndex(k=>k.id===x.id);if(b===-1)continue;let h=x.startDate.getTime(),D=(x.endDate.getTime()-h)/m,M=(h-n)/m*s,v=M+y*s,L=Math.max(D*s,s),T=c+b*l+12;p.push({taskId:x.id,taskName:x.name,originalX:M,previewX:v,width:L,y:T,rowIndex:b,daysDelta:y,color:x.color}),i(x.id,y,f);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=ne.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 l=new Date(a);l.setDate(l.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:c}],n=m=>m.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function ln({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:c,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:m,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[f,g]=useState([]),[x,b]=useState(null),[h,w]=useState(null),D=useCallback(O=>{b(O);},[]),N=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),M=r==="day"?60:r==="week"?20:8,v=N*M*l,L=O=>{let B=new Date(Date.UTC(O.getFullYear(),O.getMonth(),O.getDate())),W=B.getUTCDay()||7;B.setUTCDate(B.getUTCDate()+4-W);let S=new Date(Date.UTC(B.getUTCFullYear(),0,1));return Math.ceil(((B.getTime()-S.getTime())/864e5+1)/7)},T=O=>{let B=O.getDay();return B===0||B===6},k=useCallback(O=>{let B=Math.round(O/(M*l)),W=new Date(o);return W.setDate(W.getDate()+B),W},[o,M,l]),F=useCallback((O,B)=>{if(B.startDate&&B.endDate)return;let W=O.currentTarget.ownerSVGElement;if(!W)return;let S=W.createSVGPoint();S.x=O.clientX,S.y=O.clientY;let q=S.matrixTransform(W.getScreenCTM()?.inverse()),ee=k(q.x),$=new Date(ee);$.setDate($.getDate()+1),d?.(B,ee,$);},[k,d]),P=useMemo(()=>{let O=q=>q.map(ee=>{if(ee.subtasks&&ee.subtasks.length>0){let $=O(ee.subtasks),Me=$.filter(be=>be.startDate&&be.endDate);if(Me.length>0){let be=Me.map(Te=>Te.startDate.getTime()),qe=Me.map(Te=>Te.endDate.getTime()),ue=new Date(Math.min(...be)),Qe=new Date(Math.max(...qe));return {...ee,subtasks:$,startDate:ue,endDate:Qe}}return {...ee,subtasks:$}}return ee}),B=(q,ee=[])=>{for(let $ of q)ee.push($),$.subtasks&&$.subtasks.length>0&&($.isExpanded===void 0||$.isExpanded)&&B($.subtasks,ee);return ee},W=O(e);return B(W)},[e]),H=useCallback(O=>{if(!O.startDate||!O.endDate)return {x:0,width:0};let B=O.startDate.getTime(),W=O.endDate.getTime(),S=o.getTime(),q=(B-S)/(1e3*60*60*24),ee=(W-B)/(1e3*60*60*24),$=q*M*l,Me=Math.max(M*l,40),be=Math.max(ee*M*l,Me);return {x:$,width:be}},[o,M,l]),X=useMemo(()=>P.filter(O=>O.startDate&&O.endDate).map(O=>{let{x:B,width:W}=H(O),q=P.findIndex(ee=>ee.id===O.id)*a+12;return {id:O.id,x:B,y:q,width:W,height:32}}),[P,H]),ye=useCallback((O,B,W)=>{if(!W||B===0){g([]);return}let S=ne.calculateCascadePreview(e,O,B,P,o,M*l,a,48);g(S);},[e,P,o,M,l,a,48]),we=useMemo(()=>{let O=[],B=new Date(o);for(;B<=s;){let q=(B.getTime()-o.getTime())/864e5*M*l;if(r==="day")O.push({date:new Date(B),label:B.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:q}),B.setDate(B.getDate()+1);else if(r==="week"){let ee=L(B);O.push({date:new Date(B),label:`Week ${ee}`,x:q}),B.setDate(B.getDate()+7);}else O.push({date:new Date(B),label:B.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:q}),B.setMonth(B.getMonth()+1);}return O},[o,s,r,M,l]),Ie=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*M*l,[o,M,l]),Le=Math.max(P.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(v,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(v,1e3),height:48,fill:t.bgGrid}),we.map((O,B)=>jsxs("g",{children:[B>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-${B}`)),Ie>=0&&Ie<=v&&jsx("circle",{cx:Ie,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(v,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(v,1e3),height:Le,fill:t.bgPrimary}),we.map((O,B)=>{let W=we[B+1]?.x||v,S=T(O.date);return jsxs("g",{children:[S&&jsx("rect",{x:O.x,y:0,width:W-O.x,height:P.length*a,fill:t.bgWeekend,opacity:1}),B>0&&jsx("line",{x1:O.x,y1:0,x2:O.x,y2:P.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},B)}),P.map((O,B)=>{let W=O.startDate&&O.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:B*a,width:v,height:a,fill:B%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${O.id}`),!W&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:B*a,width:v,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:S=>F(S,O),onMouseEnter:S=>{S.currentTarget.setAttribute("fill",t.accentLight),S.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:S=>{S.currentTarget.setAttribute("fill","transparent"),S.currentTarget.setAttribute("opacity","1");}},`clickable-${O.id}`),jsx("text",{x:Ie>0?Ie:100,y:B*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}`)}),P.map((O,B)=>!O.dependencies||O.dependencies.length===0||!O.startDate||!O.endDate?null:O.dependencies.map(W=>{let S=P.find(Me=>Me.id===W);if(!S||!S.startDate||!S.endDate)return null;let q=P.findIndex(Me=>Me.id===W),ee=H(S),$=H(O);return jsx(rn,{x1:ee.x+ee.width,y1:q*a+a/2,x2:$.x,y2:B*a+a/2,theme:t},`dep-${W}-${O.id}`)})),P.map((O,B)=>{if(!O.startDate||!O.endDate)return null;let{x:W,width:S}=H(O),q=B*a+12,ee=O.subtasks&&O.subtasks.length>0&&!O.isMilestone;return O.isMilestone?jsx(nn,{task:O,x:W+S/2,y:q+16,theme:t,onClick:p},O.id):ee?jsxs("g",{onClick:()=>p?.(O),onContextMenu:$=>{$.preventDefault(),$.stopPropagation(),m?.(O,$);},style:{cursor:"default"},children:[jsx("rect",{x:W,y:q,width:S,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:W,y1:q,x2:W+S,y2:q,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:q,x2:W,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W+S,y1:q,x2:W+S,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:q+32,x2:W+S,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),S>60&&jsx("text",{x:W+12,y:q+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:O.name})]},O.id):jsx(en,{task:O,x:W,y:q,width:S,theme:t,dayWidth:M*l,startDate:o,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:X,onDragMove:ye,onHoverChange:D},O.id)}),P.map((O,B)=>!O.dependencies||O.dependencies.length===0||!O.startDate||!O.endDate?null:O.dependencies.map(W=>{let S=P.find(ve=>ve.id===W);if(!S||!S.startDate||!S.endDate)return null;let q=P.findIndex(ve=>ve.id===W),ee=H(S),$=H(O),Me=ee.x+ee.width,be=q*a+a/2,qe=$.x,ue=B*a+a/2,Qe=qe-Me,Te=Me+Qe/2,rt=ve=>{let De=1-ve,Ee=De*De,Ve=Ee*De,Ct=ve*ve,Y=Ct*ve,z=Ve*Me+3*Ee*ve*Te+3*De*Ct*Te+Y*qe,ke=Ve*be+3*Ee*ve*be+3*De*Ct*ue+Y*ue;return {x:z,y:ke}},gt=20,ft=[];for(let ve=0;ve<=gt;ve++){let De=.1+ve/gt*.8;ft.push(rt(De));}let et=ft[0],R=`M ${et.x} ${et.y} `+ft.slice(1).map(ve=>`L ${ve.x} ${ve.y}`).join(" ");return h&&h.x1===Me&&h.y1===be&&h.x2===qe&&h.y2===ue?null:jsx("path",{d:R,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{w({x1:Me,y1:be,x2:qe,y2:ue,onDelete:()=>u?.(O.id,W)});}},`dep-hover-${W}-${O.id}`)})),f.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}`)),h&&(()=>{let{x1:O,y1:B,x2:W,y2:S,onDelete:q}=h,ee=W-O,$=S-B,Me=O+ee/2,be=(B+S)/2,qe=`M ${O} ${B} C ${Me} ${B}, ${Me} ${S}, ${W} ${S}`,ue=6,Qe=Math.atan2($,ee),Te=W-ue*Math.cos(Qe-Math.PI/6),rt=S-ue*Math.sin(Qe-Math.PI/6),gt=W-ue*Math.cos(Qe+Math.PI/6),ft=S-ue*Math.sin(Qe+Math.PI/6),et=t.dependency,R="#f87171";return jsxs("g",{onMouseLeave:()=>w(null),children:[jsx("path",{d:qe,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:Me,cy:be,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:qe,fill:"none",stroke:et,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:qe,fill:"none",stroke:et,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${W} ${S} L ${Te} ${rt} M ${W} ${S} L ${gt} ${ft}`,fill:"none",stroke:et,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:W,cy:S,r:4,fill:et,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:ve=>{ve.stopPropagation(),w(null),q();},style:{cursor:"pointer"},children:[jsx("circle",{cx:Me,cy:be,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:R,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:Me-3,y1:be-3,x2:Me+3,y2:be+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:Me+3,y1:be-3,x2:Me-3,y2:be+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Ie>=0&&Ie<=v&&jsx("line",{x1:Ie,y1:0,x2:Ie,y2:Le,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),x&&jsx(wd,{tooltipData:x,theme:t})]})]})}var dn=[{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"}];var Ws=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Hs=[{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 cn({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:n=[],availableTags:m=[],onCreateTag:d,attachments:i=[],onUploadAttachments:u,onDeleteAttachment:y}){let f=[...Ws,...n.filter(R=>!Ws.some(se=>se.id===R.id))],g=Ge[p]||Ge.dark,[x,b]=useState(false),[h,w]=useState(false),[D,N]=useState(false),[M,v]=useState(false),[L,T]=useState({top:0,left:0}),[k,F]=useState(null),[P,H]=useState(new Date),[X$1,ye]=useState({top:0,left:0}),[we,Ie]=useState(false),[Le,O]=useState([]),B=useRef(null),W=useRef(null),S=useRef(null),q=useRef(null),ee=useRef(null),[$,Me]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[be,qe]=useState({});useEffect(()=>{a?(Me({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)&&Ie(true)):(Me({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Ie(false),O([]));},[a,e]),useEffect(()=>{let R=se=>{B.current&&!B.current.contains(se.target)&&b(false),W.current&&!W.current.contains(se.target)&&w(false),S.current&&!S.current.contains(se.target)&&N(false),q.current&&!q.current.contains(se.target)&&v(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]);let ue=()=>{let R={};return $.name.trim()||(R.name="El nombre es requerido"),$.startDate&&$.endDate&&$.startDate>$.endDate&&(R.endDate="La fecha de fin debe ser posterior a la de inicio"),qe(R),Object.keys(R).length===0},Qe=async R=>{if(R.preventDefault(),!!ue())try{let se=c==="create"&&Le.length>0?{...$,pendingFiles:Le}:$;await s(se),O([]),t();}catch(se){console.error("Error submitting task:",se);}},Te=(R,se)=>{Me(ve=>{let De={...ve,[R]:se};if(R==="status"){let Ee=se;Ee==="todo"?De.progress=0:Ee==="in-progress"?(ve.progress===0||ve.progress===100)&&(De.progress=50):Ee==="completed"||Ee==="closed"?De.progress=100:(Ee==="in-review"||Ee==="review")&&(De.progress=75);}if(R==="progress"){let Ee=typeof se=="number"?se:parseInt(se,10);Ee===100&&ve.status!=="completed"?De.status="completed":Ee>0&&Ee<100&&ve.status==="todo"?De.status="in-progress":Ee===0&&ve.status!=="todo"&&(De.status="todo");}return De}),be[R]&&qe(ve=>{let De={...ve};return delete De[R],De});},rt=f.find(R=>R.id===$.status)??Ws[0],gt=Hs.find(R=>R.id===$.priority)??Hs[1],ft=dn.find(R=>R.value===$.color)??dn[0],et={backgroundColor:g.bgSecondary,border:`1px solid ${g.borderLight}`,color:g.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:g.bgPrimary,border:`1px solid ${g.border}`},onClick:R=>R.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${g.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:rt.color||g.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:g.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:g.textTertiary},onMouseEnter:R=>{R.currentTarget.style.backgroundColor=g.hoverBg,R.currentTarget.style.color=g.textPrimary;},onMouseLeave:R=>{R.currentTarget.style.backgroundColor="transparent",R.currentTarget.style.color=g.textTertiary;},disabled:l,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:Qe,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:$.name,onChange:R=>Te("name",R.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:g.textPrimary},placeholder:"Nombre de la tarea",disabled:l,autoFocus:true}),be.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),be.name]})]}),jsx("div",{children:jsx("textarea",{value:$.description||"",onChange:R=>Te("description",R.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:g.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:l})}),jsx("div",{style:{borderTop:`1px solid ${g.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:B,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&b(!x),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...et,borderColor:rt.color,backgroundColor:`${rt.color}15`},disabled:l,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:rt.color}}),jsx("span",{style:{color:rt.color},children:rt.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:rt.color}})]}),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-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:f.map(R=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:se=>se.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:se=>se.currentTarget.style.backgroundColor="transparent",onClick:()=>{Te("status",R.id),b(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:R.color}}),R.title,$.status===R.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},R.id))})})]}),jsxs("div",{ref:W,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&w(!h),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:et,disabled:l,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:gt.color}}),jsx("span",{children:gt.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:h&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:Hs.map(R=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:se=>se.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:se=>se.currentTarget.style.backgroundColor="transparent",onClick:()=>{Te("priority",R.id),w(false);},children:[jsx("span",{children:R.icon}),R.label,$.priority===R.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},R.id))})})]}),o.length>0&&jsxs("div",{ref:S,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&N(!D),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:et,disabled:l,children:[$.assignees&&$.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:$.assignees.slice(0,3).map((R,se)=>jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:R.color||g.accent,borderColor:g.bgSecondary},children:R.initials},se))}),$.assignees.length>3&&jsxs("span",{style:{color:g.textTertiary},children:["+",$.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:g.textTertiary}}),jsx("span",{style:{color:g.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:D&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:o.map(R=>{let se=$.assignees?.some(ve=>ve.name===R.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:ve=>ve.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ve=>ve.currentTarget.style.backgroundColor="transparent",onClick:()=>{let ve=se?($.assignees||[]).filter(De=>De.name!==R.name):[...$.assignees||[],{name:R.name,avatar:R.avatar,initials:R.name.split(" ").map(De=>De[0]).join("").toUpperCase().slice(0,2),color:g.accent}];Te("assignees",ve);},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:g.accent},children:R.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:R.name}),jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:se&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:g.accent}})})]},R.id)})})})]}),jsxs("div",{ref:q,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!l)if(M)v(false);else {if(q.current){let R=q.current.getBoundingClientRect(),se=window.innerHeight,ve=120,Ee=se-R.bottom<ve?R.top-ve-8:R.bottom+8;T({top:Ee,left:R.left});}v(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:et,disabled:l,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:$.color}}),jsx("span",{children:ft.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:M&&jsxs(tt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>v(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg",style:{position:"fixed",top:`${L.top}px`,left:`${L.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:R=>R.stopPropagation(),children:jsx("div",{style:{padding:"14px 18px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 16px)",gap:"14px"},children:dn.slice(0,18).map(R=>{let se=$.color===R.value;return jsx(motion.button,{type:"button",onClick:()=>{Te("color",R.value),v(false);},style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:R.value,outline:se?`2px solid ${R.value}`:"none",outlineOffset:"3px",cursor:"pointer",border:"none"},whileHover:{scale:1.2},whileTap:{scale:.95},title:R.name},R.value)})})})})]})})]}),m.length>0||d?jsx(Rr,{selectedTags:$.tags||[],availableTags:m,onChange:R=>Te("tags",R),onCreateTag:d,theme:g,disabled:l}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{ref:ee,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!l&&!$.isMilestone)if(k==="start")F(null);else {if(ee.current){let R=ee.current.getBoundingClientRect(),se=window.innerHeight,ve=320,Ee=se-R.bottom<ve?R.top-ve-8:R.bottom+8;ye({top:Ee,left:R.left});}F("start"),H($.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...et,opacity:$.isMilestone?.5:1,cursor:$.isMilestone?"not-allowed":"pointer"},disabled:l||$.isMilestone,children:$.startDate?$.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:g.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!l&&!$.isMilestone)if(k==="end")F(null);else {if(ee.current){let R=ee.current.getBoundingClientRect(),se=window.innerHeight,ve=320,Ee=se-R.bottom<ve?R.top-ve-8:R.bottom+8;ye({top:Ee,left:R.left});}F("end"),H($.endDate||$.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...et,opacity:$.isMilestone?.5:1,cursor:$.isMilestone?"not-allowed":"pointer"},disabled:l||$.isMilestone,children:$.endDate?$.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:k&&jsxs(tt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>F(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:`${X$1.top}px`,left:`${X$1.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},onClick:R=>R.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${g.border}`},children:[(()=>{let R=new Date,se=new Date(R);se.setDate(R.getDate()+1);let ve=new Date(R);ve.setDate(R.getDate()+7);let De=new Date(R);return De.setDate(R.getDate()+14),[{label:"Hoy",date:R},{label:"Ma\xF1ana",date:se},{label:"Pr\xF3xima semana",date:ve},{label:"2 semanas",date:De}].map((Ve,Ct)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:g.textPrimary},onMouseEnter:Y=>Y.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:Y=>Y.currentTarget.style.backgroundColor="transparent",onClick:()=>{k==="start"?(Te("startDate",Ve.date),(!$.endDate||Ve.date>$.endDate)&&Te("endDate",Ve.date),F("end")):(Te("endDate",Ve.date),(!$.startDate||Ve.date<$.startDate)&&Te("startDate",Ve.date),F(null));},children:Ve.label},Ct))})(),jsx("div",{style:{borderTop:`1px solid ${g.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:R=>R.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:R=>R.currentTarget.style.backgroundColor="transparent",onClick:()=>{Te("startDate",void 0),Te("endDate",void 0),F(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:()=>H(new Date(P.getFullYear(),P.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:g.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:g.textPrimary},children:P.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>H(new Date(P.getFullYear(),P.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:g.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((R,se)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:g.textTertiary},children:R},se))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let R=P.getFullYear(),se=P.getMonth(),ve=new Date(R,se,1).getDay(),De=new Date(R,se+1,0).getDate(),Ee=new Date,Ve=[];for(let Y=ve-1;Y>=0;Y--)Ve.push({day:new Date(R,se,-Y).getDate(),date:new Date(R,se-1,new Date(R,se,-Y).getDate()),isCurrentMonth:false});for(let Y=1;Y<=De;Y++)Ve.push({day:Y,date:new Date(R,se,Y),isCurrentMonth:true});let Ct=42-Ve.length;for(let Y=1;Y<=Ct;Y++)Ve.push({day:Y,date:new Date(R,se+1,Y),isCurrentMonth:false});return Ve.map((Y,z)=>{let ke=Y.date.toDateString()===Ee.toDateString(),We=$.startDate?.toDateString()===Y.date.toDateString(),Ue=$.endDate?.toDateString()===Y.date.toDateString(),ht=$.startDate&&$.endDate&&Y.date>=$.startDate&&Y.date<=$.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Y.isCurrentMonth?We||Ue?"#FFF":g.textPrimary:g.textTertiary,backgroundColor:We?"#3B82F6":Ue?"#7C3AED":ht?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:ke&&!We&&!Ue?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{k==="start"?(Te("startDate",Y.date),$.endDate&&Y.date>$.endDate&&Te("endDate",Y.date),F("end")):(Te("endDate",Y.date),$.startDate&&Y.date<$.startDate&&Te("startDate",Y.date),F(null));},children:Y.day},z)})})()})]})]})]})})]}),be.endDate&&jsx("span",{className:"text-xs text-red-400",children:be.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:$.progress,onChange:R=>Te("progress",parseInt(R.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:g.bgSecondary,accentColor:$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"}20`,color:$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"},children:[$.progress,"%"]})]})]}),(u||i.length>0||c==="create")&&jsxs("div",{className:"pt-2",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:g.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:g.textTertiary},children:["Adjuntos ",c==="create"?Le.length>0&&`(${Le.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsx(za,{cardId:"pending",attachments:Le.map((R,se)=>({id:`pending-${se}`,cardId:"pending",name:R.name,size:R.size,type:R.type,url:URL.createObjectURL(R),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:R=>O(se=>[...se,...R]),onDelete:R=>{let se=parseInt(R.replace("pending-",""),10);O(ve=>ve.filter((De,Ee)=>Ee!==se));},maxSizeMB:10,maxFiles:20}):jsx(za,{cardId:a?.id||"new",attachments:i,onUpload:u&&a?.id?R=>u(a.id,R):void 0,onDelete:y,maxSizeMB:10,maxFiles:20}),c==="create"&&Le.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:g.textTertiary},children:[Le.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Ie(!we),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:g.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${we?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:we&&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:[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:$.isMilestone,onChange:R=>Te("isMilestone",R.target.checked),className:"w-4 h-4 rounded",style:{accentColor:g.accent},disabled:l}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:g.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:g.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:g.bgSecondary},children:r.filter(R=>R.id!==a?.id).map(R=>{let se=$.dependencies?.includes(R.id);return jsx("button",{type:"button",onClick:()=>{let ve=se?($.dependencies||[]).filter(De=>De!==R.id):[...$.dependencies||[],R.id];Te("dependencies",ve);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:se?`${g.accent}30`:g.bgPrimary,color:se?g.accent:g.textSecondary,border:`1px solid ${se?g.accent:g.borderLight}`},disabled:l,children:R.name},R.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${g.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:g.textSecondary},onMouseEnter:R=>R.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:R=>R.currentTarget.style.backgroundColor="transparent",disabled:l,children:"Cancelar"}),jsx("button",{type:"submit",disabled:l,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:g.accent,color:"#FFF"},onMouseEnter:R=>!l&&(R.currentTarget.style.opacity="0.9"),onMouseLeave:R=>!l&&(R.currentTarget.style.opacity="1"),children:l?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 rf=['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"'],Sd=()=>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"})]}),of=()=>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"})}),nf=()=>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"})}),sf=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),lf=()=>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:l,onDependencyCreate:c,onDependencyDelete:p}){let[n,m]=useState(false),[d,i]=useState(false),[u,y]=useState([]),[f,g]=useState(""),[x,b]=useState(false),[h,w]=useState(true),D=useRef(null),N=useRef(null),M=useRef(null),{enabled:v=true,placeholder:L='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:k,suggestions:F=rf,maxHistory:P=50,persistHistory:H}=a,X=H?.storageKey||"gantt-ai-history",ye=H?.maxMessages??5;useEffect(()=>{if(H?.enabled)try{let W=localStorage.getItem(X);if(W){let q=JSON.parse(W).map(ee=>({...ee,timestamp:new Date(ee.timestamp)}));y(q.slice(-ye));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[H?.enabled,X,ye]),useEffect(()=>{if(H?.enabled&&u.length>0)try{let W=u.filter(S=>!S.isLoading).slice(-ye);localStorage.setItem(X,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[u,H?.enabled,X,ye]),useEffect(()=>{N.current&&N.current.scrollIntoView({behavior:"smooth"});},[u]),useEffect(()=>{n&&!d&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,d]);let we=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&&l?.(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,l,c,p]),Ie=useCallback(async W=>{if(!W.trim()||x)return;let S={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};y(ee=>[...ee.slice(-(P-1)),S]),g(""),w(false),b(true);let q={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};y(ee=>[...ee,q]);try{if(k){let ee=await k(W,e);y($=>{let Me=$.filter(qe=>!qe.isLoading),be={id:`assistant-${Date.now()}`,role:"assistant",content:ee.message,timestamp:new Date,command:ee};return [...Me,be]}),we(ee);}else y(ee=>[...ee.filter(Me=>!Me.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(ee){y($=>[...$.filter(be=>!be.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${ee instanceof Error?ee.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,P,k,e,we]),Le=W=>{W.preventDefault(),Ie(f);},O=W=>{g(W),D.current?.focus();};if(useEffect(()=>{let W=S=>{(S.metaKey||S.ctrlKey)&&S.key==="k"&&(S.preventDefault(),m(q=>!q),n||i(false)),S.key==="Escape"&&n&&m(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[n]),useEffect(()=>{if(!n)return;let W=q=>{let ee=q.target;M.current&&!M.current.contains(ee)&&m(false);},S=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(S),document.removeEventListener("mousedown",W);}},[n]),!v)return null;let B={"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(tt,{children:[jsx(AnimatePresence,{children:!n&&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 ${B[T]} 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:()=>m(true),children:[jsx(Sd,{}),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:n&&jsxs(motion.div,{ref:M,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 ${B[T]} 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(Sd,{}),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(sf,{})}),jsx("button",{onClick:()=>m(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(nf,{})})]})]}),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:[u.length===0&&h&&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:F.slice(0,4).map((W,S)=>jsx("button",{onClick:()=>O(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},S))})]}),u.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(lf,{}):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:N})]}),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:D,type:"text",value:f,onChange:W=>g(W.target.value),placeholder:L,disabled:x,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!f.trim()||x,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsx(of,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function Ed(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((n,m=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!m)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=useCallback(()=>{r(n=>{if(n.past.length===0)return n;let m=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:m,future:[n.present,...n.future]}});},[]),c=useCallback(()=>{r(n=>{if(n.future.length===0)return n;let m=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:m,future:d}});},[]),p=useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function Pd({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=l=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?l.metaKey:l.ctrlKey;if(p&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!c&&p&&l.key==="y"){l.preventDefault(),t();return}if(c&&p&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var mf={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${ne.formatDate(e.startDate)} - ${ne.formatDate(e.endDate)}`);let a=ne.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=>ne.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function Md(e){return {...mf,...e}}var vf=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},Ld=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:m=[],templates:d,enableAutoCriticalPath:i=true,aiAssistant:u,locale:y="en",customTranslations:f,showCreateTaskButton:g=false,createTaskLabel:x,onCreateTask:b,onThemeChange:h,onTaskClick:w,onTaskDblClick:D,onTaskContextMenu:N,onTaskUpdate:M,onProgressChange:v,onTaskEdit:L,onTaskAddSubtask:T,onTaskMarkIncomplete:k,onTaskSetInProgress:F,onDependencyCreate:P,onDependencyDelete:H,onBeforeTaskAdd:X,onAfterTaskAdd:ye,onBeforeTaskUpdate:we,onAfterTaskUpdate:Ie,onBeforeTaskDelete:Le,onAfterTaskDelete:O}=a,W=useContext(Ko)?.theme,[S,q]=useState(W||s||"dark"),[ee,$]=useState(l),[Me,be]=useState(c),[qe,ue]=useState(1),[Qe,Te]=useState(0),[rt,gt]=useState(false),[ft,et]=useState(null),[R,se]=useState({isOpen:false,x:0,y:0,task:null}),[ve,De]=useState(null),[Ee,Ve]=useState(null);useEffect(()=>{W&&W!==S&&q(W);},[W]),useEffect(()=>{s&&s!==S&&q(s);},[s]);let Ct=useCallback(E=>{q(E),h?.(E);},[h]),{state:Y,setState:z,undo:ke,redo:We,canUndo:Ue,canRedo:ht,clearHistory:Z}=Ed(t,50),te=useRef(new Map);useEffect(()=>{let E=A=>A.map(K=>{let ae=te.current.get(K.id),le=ae!==void 0?{...K,isExpanded:ae}:K;return le.subtasks?.length?{...le,subtasks:E(le.subtasks)}:le});te.current.size>0?z(E(t)):z(t);},[t,z]);let xe=useRef(t),Pe=useRef(true);useEffect(()=>{if(Pe.current){Pe.current=false,xe.current=Y;return}if(!r)return;let E=JSON.stringify(xe.current),A=JSON.stringify(Y);E!==A&&(xe.current=Y,r(Y));},[Y,r]);let J=useMemo(()=>Ds(y,f),[y,f]),Ae=useCallback(E=>[{id:"name",label:E.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:E.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:E.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:E.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:E.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:E.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:E.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:E.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[he,Ne]=useState(()=>Ae(J));useEffect(()=>{Ne(E=>E.map(A=>({...A,label:J.columns[A.id==="name"?"taskName":A.id]||A.label})));},[J]);let de=useMemo(()=>{let E=he.filter(ae=>ae.visible),A=E.some(ae=>ae.id!=="name");return E.reduce((ae,le)=>ae+le.width,0)+(A?20:0)},[he]);useEffect(()=>{ft!==null&&ft>de&&(he.filter(K=>K.visible).some(K=>K.id!=="name")||et(null));},[he,de,ft]);let Re=useMemo(()=>ft!==null?Math.max(280,ft,de):Math.max(280,de),[ft,de]),Fe=useRef(null),Oe=useRef(null),_=useRef(null),j=useMemo(()=>Yl(S),[S]),nt=useMemo(()=>({theme:j,themeName:S}),[j,S]),He=useMemo(()=>Md(d),[d]),ge=useMemo(()=>{if(!i)return Y;let E=ne.calculateCriticalPath(Y),A=K=>K.map(ae=>({...ae,isCriticalPath:E.includes(ae.id),subtasks:ae.subtasks?A(ae.subtasks):void 0}));return A(Y)},[Y,i]),Vt=vf(Me);Pd({undo:ke,redo:We,canUndo:Ue,canRedo:ht,enabled:true}),useImperativeHandle(o,()=>({getTask:E=>ne.findTaskById(Y,E),addTask:(E,A)=>{z(K=>{if(!A)return [...K,{...E,level:0}];let ae=le=>le.map(Se=>Se.id===A?{...Se,subtasks:[...Se.subtasks||[],{...E,parentId:A,level:(Se.level||0)+1}],isExpanded:true}:Se.subtasks?{...Se,subtasks:ae(Se.subtasks)}:Se);return ae(K)});},updateTask:(E,A)=>{z(K=>{let ae=le=>le.map(Se=>Se.id===E?{...Se,...A}:Se.subtasks?{...Se,subtasks:ae(Se.subtasks)}:Se);return ae(K)});},deleteTask:E=>{z(A=>{let K=ae=>ae.filter(le=>le.id===E?false:(le.subtasks&&(le.subtasks=K(le.subtasks)),true));return K(A)});},deleteTasks:E=>{z(A=>Is(A,E));},duplicateTask:E=>{z(A=>Ls(A,[E]));},splitTask:(E,A,K=3)=>{z(ae=>ne.splitTask(ae,E,A,K));},calculateEndDate:ne.calculateEndDate,calculateDuration:ne.calculateDuration,validateDependency:(E,A)=>!ne.validateDependencies(Y,E,A),getAllTasks:()=>ne.flattenTasks(Y),getTasksByStatus:E=>ne.flattenTasks(Y).filter(A=>A.status===E),getTasksByParent:E=>E?ne.findTaskById(Y,E)?.subtasks||[]:Y.filter(K=>!K.parentId),getCriticalPath:()=>ne.flattenTasks(Y).filter(E=>E.isCriticalPath),indentTask:E=>{z(A=>Ps(A,[E]));},outdentTask:E=>{z(A=>Ms(A,[E]));},moveTask:(E,A)=>{z(K=>As(K,[E],A));},createSubtask:async E=>{let{tasks:A,newTask:K}=Rs(Y,E);if(X){let ae=X({...K,parentId:E});if((ae instanceof Promise?await ae:ae)===false)return}z(A),ye&&ye({...K,parentId:E});},scrollToTask:E=>{let K=ne.flattenTasks(Y).findIndex(ae=>ae.id===E);if(K!==-1&&Fe.current){let ae=K*Vt;Fe.current.scrollTo({top:ae,behavior:"smooth"}),Oe.current&&Oe.current.scrollTo({top:ae,behavior:"smooth"});}},highlightTask:(E,A=2e3)=>{},expandTask:E=>{z(A=>{let K=ae=>ae.map(le=>le.id===E?{...le,isExpanded:true}:le.subtasks?{...le,subtasks:K(le.subtasks)}:le);return K(A)});},collapseTask:E=>{z(A=>{let K=ae=>ae.map(le=>le.id===E?{...le,isExpanded:false}:le.subtasks?{...le,subtasks:K(le.subtasks)}:le);return K(A)});},expandAll:()=>{z(E=>{let A=K=>K.map(ae=>({...ae,isExpanded:true,subtasks:ae.subtasks?A(ae.subtasks):void 0}));return A(E)});},collapseAll:()=>{z(E=>{let A=K=>K.map(ae=>({...ae,isExpanded:false,subtasks:ae.subtasks?A(ae.subtasks):void 0}));return A(E)});},undo:ke,redo:We,canUndo:()=>Ue,canRedo:()=>ht,clearHistory:Z,exportToPNG:async()=>{if(!_.current)throw new Error("Gantt container not found");let E=await Id(_.current,{backgroundColor:j.bgPrimary,scale:2});return new Promise((A,K)=>{E.toBlob(ae=>{ae?A(ae):K(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async E=>{await ne.exportToPDF(Y,E);},exportToExcel:async E=>{await ne.exportToExcel(Y,E);},exportToJSON:()=>ne.exportToJSON(Y),exportToCSV:()=>ne.exportToCSV(Y),importFromJSON:E=>{let A=ne.importFromJSON(E);z(A);},getTasks:()=>Y,refresh:()=>{z(E=>[...E]);},clearAll:()=>{z([]);}}),[Y,ke,We,Ue,ht,Z,j,Vt]);let Tt=useCallback(E=>{Ne(A=>A.map(K=>K.id===E?{...K,visible:!K.visible}:K));},[]),U=useCallback((E,A)=>{Ne(K=>K.map(ae=>{if(ae.id!==E)return ae;let le=ae.minWidth??100,Se=ae.maxWidth??800,Bt=Math.max(le,Math.min(Se,A));return {...ae,width:Bt}}));},[]),ce=useCallback(E=>{z(A=>{let K=Bs(A,E),ae=le=>{for(let Se of le){if(Se.id===E){te.current.set(E,Se.isExpanded??true);return}Se.subtasks?.length&&ae(Se.subtasks);}};return ae(K),K}),a.onTaskToggleExpand?.(E);},[a]),Ce=useCallback((E,A)=>{if(we&&we(E,A)===false)return;let ae=ne.findTaskById(Y,E)?.progress,le=Bt=>Bt.map(Ht=>Ht.id===E?{...Ht,...A}:Ht.subtasks?{...Ht,subtasks:le(Ht.subtasks)}:Ht);z(le(Y));let Se=ne.findTaskById(le(Y),E);Se&&(M?.(Se),Ie?.(Se),A.progress!==void 0&&ae!==void 0&&A.progress!==ae&&v?.(E,ae,A.progress));},[Y,M,we,Ie,v]),zt=useCallback(E=>{E.length!==0&&(z(A=>Ps(A,E)),a.onTaskIndent?.(E[0]));},[a]),ea=useCallback(E=>{E.length!==0&&(z(A=>Ms(A,E)),a.onTaskOutdent?.(E[0]));},[a]),qa=useCallback((E,A,K)=>{z(ae=>gd(ae,E,A,K)),a.onTaskReparent?.(E,A,K);},[a]),Xr=useCallback((E,A)=>{E.length!==0&&(z(K=>As(K,E,A)),a.onTaskMove?.(E[0],A));},[a]),ie=useCallback(async E=>{let A=[];for(let K of E)Le&&await Promise.resolve(Le(K))===false||A.push(K);A.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(A):(z(K=>Is(K,A)),A.forEach(K=>a.onTaskDelete?.(K))),O&&A.forEach(K=>O(K)));},[a,Le,O]),Dt=useCallback(E=>{z(A=>Ls(A,E)),E.forEach(A=>a.onTaskDuplicate?.(A));},[a]),Jt=useCallback((E,A)=>{z(K=>{let{tasks:ae,newTask:le}=ud(K,E,A);return X&&X(le)===false?K:(a.onTaskCreate?.(le.parentId,le.position||0),ye?.(le),ae)});},[a,X,ye]),Sr=useCallback((E,A)=>{z(K=>Fs(K,E,A)),a.onTaskRename?.(E,A);},[a]),Er=useCallback(E=>{z(A=>{let{tasks:K}=Rs(A,E);return a.onTaskCreate?.(E,0),K});},[a]),Pr=useCallback((E,A,K)=>{let ae=E.startDate?Math.round((A.getTime()-E.startDate.getTime())/864e5):0,le=Ht=>Ht.map(Zt=>Zt.id===E.id?{...Zt,startDate:A,endDate:K,...E.segments&&{segments:E.segments}}:Zt.subtasks?{...Zt,subtasks:le(Zt.subtasks)}:Zt),Se=le(Y);Se=ne.autoScheduleDependents(Se,E.id,ae),z(Se);let Bt={...E,startDate:A,endDate:K};M?.(Bt);},[Y,M]),Wa=useCallback((E,A)=>{N?.(E,A),se({isOpen:true,x:A.clientX,y:A.clientY,task:E});},[N]),ir=useCallback((E,A)=>{let K=ne.splitTask(Y,E.id,A);z(K),se({isOpen:false,x:0,y:0,task:null});},[Y]),Et=useCallback(E=>{let A=ne.findTaskById(Y,E.id)||E;D?.(A),L||De(A);},[Y,D,L]),So=useCallback((E,A,K)=>{let ae=new Map,le=Da=>{Da.forEach(Ha=>{Ha.dependencies&&ae.set(Ha.id,Ha.dependencies),Ha.subtasks&&le(Ha.subtasks);});};le(K);let Se=ae.get(A)||[];ae.set(A,[...Se,E]);let Bt=new Set,Ht=new Set,Zt=Da=>{if(!Bt.has(Da)){Bt.add(Da),Ht.add(Da);let Ha=ae.get(Da)||[];for(let lr of Ha){if(!Bt.has(lr)&&Zt(lr))return true;if(Ht.has(lr))return true}}return Ht.delete(Da),false};return Zt(A)},[]),Eo=useCallback((E,A)=>{if(So(E.id,A,Y)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
342
+ </Project>`,m=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(m),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=ie.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let m=n.startDate&&n.endDate?ie.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(f=>f.id===u);if(v){o(v);let f=r.get(u)?.ef||0;d=Math.max(d,f);}}let i=d+m;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,c=n=>{if(l.has(n.id))return;let m=n.startDate&&n.endDate?ie.calculateDuration(n.startDate,n.endDate):0,d=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(d.length>0)for(let v of d){c(v);let f=l.get(v.id)?.ls||0;i=Math.min(i,f);}let u=i-m;l.set(n.id,{ls:u,lf:i});};a.forEach(c);let p=[];for(let n of a){let m=r.get(n.id),d=l.get(n.id);if(m&&d){let i=d.ls-m.es;Math.abs(i)<.01&&p.push(n.id);}}return p},calculateSlack:(e,t)=>{let a=ie.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(ie.calculateCriticalPath(e).includes(t))return 0;let o=ie.getDependentTasks(e,t);if(o.length===0){let c=ie.getLatestEndDate(e);if(!c)return null;let p=ie.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 l=ie.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>ie.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=ie.findTaskById(e,t);if(!r||!r.endDate)return e;let o=ie.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let c=ie.calculateDuration(l.startDate,l.endDate),p;a!==void 0?(p=new Date(l.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=ie.calculateEndDate(p,c),m=d=>d.map(i=>i.id===l.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:m(i.subtasks)}:i);s=m(s),s=ie.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,c)=>{if(a===0)return [];let p=[],n=o.getTime(),m=1e3*60*60*24,d=ie.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,v,f=new Set)=>{if(f.has(u))return;f.add(u);let g=ie.getDependentTasks(e,u);for(let x of g){if(!x.startDate||!x.endDate)continue;let b=r.findIndex(k=>k.id===x.id);if(b===-1)continue;let h=x.startDate.getTime(),D=(x.endDate.getTime()-h)/m,A=(h-n)/m*s,y=A+v*s,R=Math.max(D*s,s),T=c+b*l+12;p.push({taskId:x.id,taskName:x.name,originalX:A,previewX:y,width:R,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),p},splitTask:(e,t,a,r=3)=>{let o=ie.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 l=new Date(a);l.setDate(l.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:c}],n=m=>m.map(d=>d.id===o.id?{...d,endDate:c,segments:p}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function nn({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:c,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:m,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[f,g]=useState([]),[x,b]=useState(null),[h,w]=useState(null),D=useCallback(z=>{b(z);},[]),N=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),A=r==="day"?60:r==="week"?20:8,y=N*A*l,R=z=>{let F=new Date(Date.UTC(z.getFullYear(),z.getMonth(),z.getDate())),W=F.getUTCDay()||7;F.setUTCDate(F.getUTCDate()+4-W);let E=new Date(Date.UTC(F.getUTCFullYear(),0,1));return Math.ceil(((F.getTime()-E.getTime())/864e5+1)/7)},T=z=>{let F=z.getDay();return F===0||F===6},k=useCallback(z=>{let F=Math.round(z/(A*l)),W=new Date(o);return W.setDate(W.getDate()+F),W},[o,A,l]),B=useCallback((z,F)=>{if(F.startDate&&F.endDate)return;let W=z.currentTarget.ownerSVGElement;if(!W)return;let E=W.createSVGPoint();E.x=z.clientX,E.y=z.clientY;let K=E.matrixTransform(W.getScreenCTM()?.inverse()),te=k(K.x),O=new Date(te);O.setDate(O.getDate()+1),d?.(F,te,O);},[k,d]),P=useMemo(()=>{let z=K=>K.map(te=>{if(te.subtasks&&te.subtasks.length>0){let O=z(te.subtasks),Me=O.filter(he=>he.startDate&&he.endDate);if(Me.length>0){let he=Me.map(we=>we.startDate.getTime()),qe=Me.map(we=>we.endDate.getTime()),me=new Date(Math.min(...he)),tt=new Date(Math.max(...qe));return {...te,subtasks:O,startDate:me,endDate:tt}}return {...te,subtasks:O}}return te}),F=(K,te=[])=>{for(let O of K)te.push(O),O.subtasks&&O.subtasks.length>0&&(O.isExpanded===void 0||O.isExpanded)&&F(O.subtasks,te);return te},W=z(e);return F(W)},[e]),H=useCallback(z=>{if(!z.startDate||!z.endDate)return {x:0,width:0};let F=z.startDate.getTime(),W=z.endDate.getTime(),E=o.getTime(),K=(F-E)/(1e3*60*60*24),te=(W-F)/(1e3*60*60*24),O=K*A*l,Me=Math.max(A*l,40),he=Math.max(te*A*l,Me);return {x:O,width:he}},[o,A,l]),X=useMemo(()=>P.filter(z=>z.startDate&&z.endDate).map(z=>{let{x:F,width:W}=H(z),K=P.findIndex(te=>te.id===z.id)*a+12;return {id:z.id,x:F,y:K,width:W,height:32}}),[P,H]),be=useCallback((z,F,W)=>{if(!W||F===0){g([]);return}let E=ie.calculateCascadePreview(e,z,F,P,o,A*l,a,48);g(E);},[e,P,o,A,l,a,48]),ke=useMemo(()=>{let z=[],F=new Date(o);for(;F<=s;){let K=(F.getTime()-o.getTime())/864e5*A*l;if(r==="day")z.push({date:new Date(F),label:F.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:K}),F.setDate(F.getDate()+1);else if(r==="week"){let te=R(F);z.push({date:new Date(F),label:`Week ${te}`,x:K}),F.setDate(F.getDate()+7);}else z.push({date:new Date(F),label:F.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:K}),F.setMonth(F.getMonth()+1);}return z},[o,s,r,A,l]),Ae=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*A*l,[o,A,l]),Fe=Math.max(P.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(y,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(y,1e3),height:48,fill:t.bgGrid}),ke.map((z,F)=>jsxs("g",{children:[F>0&&jsx("line",{x1:z.x,y1:0,x2:z.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:z.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:z.label})]},`header-${F}`)),Ae>=0&&Ae<=y&&jsx("circle",{cx:Ae,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(y,1e3),height:Fe,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(y,1e3),height:Fe,fill:t.bgPrimary}),ke.map((z,F)=>{let W=ke[F+1]?.x||y,E=T(z.date);return jsxs("g",{children:[E&&jsx("rect",{x:z.x,y:0,width:W-z.x,height:P.length*a,fill:t.bgWeekend,opacity:1}),F>0&&jsx("line",{x1:z.x,y1:0,x2:z.x,y2:P.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},F)}),P.map((z,F)=>{let W=z.startDate&&z.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:F*a,width:y,height:a,fill:F%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${z.id}`),!W&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:F*a,width:y,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:E=>B(E,z),onMouseEnter:E=>{E.currentTarget.setAttribute("fill",t.accentLight),E.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:E=>{E.currentTarget.setAttribute("fill","transparent"),E.currentTarget.setAttribute("opacity","1");}},`clickable-${z.id}`),jsx("text",{x:Ae>0?Ae:100,y:F*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-${z.id}`)]})]},`row-group-${z.id}`)}),P.map((z,F)=>!z.dependencies||z.dependencies.length===0||!z.startDate||!z.endDate?null:z.dependencies.map(W=>{let E=P.find(Me=>Me.id===W);if(!E||!E.startDate||!E.endDate)return null;let K=P.findIndex(Me=>Me.id===W),te=H(E),O=H(z);return jsx(tn,{x1:te.x+te.width,y1:K*a+a/2,x2:O.x,y2:F*a+a/2,theme:t},`dep-${W}-${z.id}`)})),P.map((z,F)=>{if(!z.startDate||!z.endDate)return null;let{x:W,width:E}=H(z),K=F*a+12,te=z.subtasks&&z.subtasks.length>0&&!z.isMilestone;return z.isMilestone?jsx(rn,{task:z,x:W+E/2,y:K+16,theme:t,onClick:p},z.id):te?jsxs("g",{onClick:()=>p?.(z),onContextMenu:O=>{O.preventDefault(),O.stopPropagation(),m?.(z,O);},style:{cursor:"default"},children:[jsx("rect",{x:W,y:K,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:W,y1:K,x2:W+E,y2:K,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:K,x2:W,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W+E,y1:K,x2:W+E,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:K+32,x2:W+E,y2:K+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsx("text",{x:W+12,y:K+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:z.name})]},z.id):jsx(Zo,{task:z,x:W,y:K,width:E,theme:t,dayWidth:A*l,startDate:o,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:X,onDragMove:be,onHoverChange:D},z.id)}),P.map((z,F)=>!z.dependencies||z.dependencies.length===0||!z.startDate||!z.endDate?null:z.dependencies.map(W=>{let E=P.find(ve=>ve.id===W);if(!E||!E.startDate||!E.endDate)return null;let K=P.findIndex(ve=>ve.id===W),te=H(E),O=H(z),Me=te.x+te.width,he=K*a+a/2,qe=O.x,me=F*a+a/2,tt=qe-Me,we=Me+tt/2,st=ve=>{let Te=1-ve,De=Te*Te,Ye=De*Te,mt=ve*ve,Ie=mt*ve,I=Ye*Me+3*De*ve*we+3*Te*mt*we+Ie*qe,Y=Ye*he+3*De*ve*he+3*Te*mt*me+Ie*me;return {x:I,y:Y}},ht=20,Ft=[];for(let ve=0;ve<=ht;ve++){let Te=.1+ve/ht*.8;Ft.push(st(Te));}let Xe=Ft[0],$=`M ${Xe.x} ${Xe.y} `+Ft.slice(1).map(ve=>`L ${ve.x} ${ve.y}`).join(" ");return h&&h.x1===Me&&h.y1===he&&h.x2===qe&&h.y2===me?null:jsx("path",{d:$,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{w({x1:Me,y1:he,x2:qe,y2:me,onDelete:()=>u?.(z.id,W)});}},`dep-hover-${W}-${z.id}`)})),f.map(z=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:z.previewX,y:z.y-48,width:z.width,height:32,rx:8,fill:z.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(z.daysDelta)>0&&jsx("text",{x:z.previewX+z.width/2,y:z.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:z.daysDelta>0?`+${z.daysDelta}d`:`${z.daysDelta}d`})]},`cascade-preview-${z.taskId}`)),h&&(()=>{let{x1:z,y1:F,x2:W,y2:E,onDelete:K}=h,te=W-z,O=E-F,Me=z+te/2,he=(F+E)/2,qe=`M ${z} ${F} C ${Me} ${F}, ${Me} ${E}, ${W} ${E}`,me=6,tt=Math.atan2(O,te),we=W-me*Math.cos(tt-Math.PI/6),st=E-me*Math.sin(tt-Math.PI/6),ht=W-me*Math.cos(tt+Math.PI/6),Ft=E-me*Math.sin(tt+Math.PI/6),Xe=t.dependency,$="#f87171";return jsxs("g",{onMouseLeave:()=>w(null),children:[jsx("path",{d:qe,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:Me,cy:he,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:qe,fill:"none",stroke:Xe,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:qe,fill:"none",stroke:Xe,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${W} ${E} L ${we} ${st} M ${W} ${E} L ${ht} ${Ft}`,fill:"none",stroke:Xe,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:W,cy:E,r:4,fill:Xe,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:ve=>{ve.stopPropagation(),w(null),K();},style:{cursor:"pointer"},children:[jsx("circle",{cx:Me,cy:he,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:$,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:Me-3,y1:he-3,x2:Me+3,y2:he+3,stroke:$,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:Me+3,y1:he-3,x2:Me-3,y2:he+3,stroke:$,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Ae>=0&&Ae<=y&&jsx("line",{x1:Ae,y1:0,x2:Ae,y2:Fe,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),x&&jsx(Dd,{tooltipData:x,theme:t})]})]})}var sn=[{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"}];var Us=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Ws=[{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 ln({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:n=[],availableTags:m=[],onCreateTag:d,attachments:i=[],onUploadAttachments:u,onDeleteAttachment:v}){let f=[...Us,...n.filter($=>!Us.some(ne=>ne.id===$.id))],g=Ge[p]||Ge.dark,[x,b]=useState(false),[h,w]=useState(false),[D,N]=useState(false),[A,y]=useState(false),[R,T]=useState({top:0,left:0}),[k,B]=useState(null),[P,H]=useState(new Date),[X$1,be]=useState({top:0,left:0}),[ke,Ae]=useState(false),[Fe,z]=useState([]),F=useRef(null),W=useRef(null),E=useRef(null),K=useRef(null),te=useRef(null),[O,Me]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[he,qe]=useState({});useEffect(()=>{a?(Me({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)&&Ae(true)):(Me({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Ae(false),z([]));},[a,e]),useEffect(()=>{let $=ne=>{F.current&&!F.current.contains(ne.target)&&b(false),W.current&&!W.current.contains(ne.target)&&w(false),E.current&&!E.current.contains(ne.target)&&N(false),K.current&&!K.current.contains(ne.target)&&y(false);};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);let me=()=>{let $={};return O.name.trim()||($.name="El nombre es requerido"),O.startDate&&O.endDate&&O.startDate>O.endDate&&($.endDate="La fecha de fin debe ser posterior a la de inicio"),qe($),Object.keys($).length===0},tt=async $=>{if($.preventDefault(),!!me())try{let ne=c==="create"&&Fe.length>0?{...O,pendingFiles:Fe}:O;await s(ne),z([]),t();}catch(ne){console.error("Error submitting task:",ne);}},we=($,ne)=>{Me(ve=>{let Te={...ve,[$]:ne};if($==="status"){let De=ne;De==="todo"?Te.progress=0:De==="in-progress"?(ve.progress===0||ve.progress===100)&&(Te.progress=50):De==="completed"||De==="closed"?Te.progress=100:(De==="in-review"||De==="review")&&(Te.progress=75);}if($==="progress"){let De=typeof ne=="number"?ne:parseInt(ne,10);De===100&&ve.status!=="completed"?Te.status="completed":De>0&&De<100&&ve.status==="todo"?Te.status="in-progress":De===0&&ve.status!=="todo"&&(Te.status="todo");}return Te}),he[$]&&qe(ve=>{let Te={...ve};return delete Te[$],Te});},st=f.find($=>$.id===O.status)??Us[0],ht=Ws.find($=>$.id===O.priority)??Ws[1],Ft=sn.find($=>$.value===O.color)??sn[0],Xe={backgroundColor:g.bgSecondary,border:`1px solid ${g.borderLight}`,color:g.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:g.bgPrimary,border:`1px solid ${g.border}`},onClick:$=>$.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${g.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:st.color||g.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:g.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:g.textTertiary},onMouseEnter:$=>{$.currentTarget.style.backgroundColor=g.hoverBg,$.currentTarget.style.color=g.textPrimary;},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent",$.currentTarget.style.color=g.textTertiary;},disabled:l,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:tt,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxs("div",{className:"p-5 space-y-4",children:[jsxs("div",{children:[jsx("input",{type:"text",value:O.name,onChange:$=>we("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:g.textPrimary},placeholder:"Nombre de la tarea",disabled:l,autoFocus:true}),he.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),he.name]})]}),jsx("div",{children:jsx("textarea",{value:O.description||"",onChange:$=>we("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:g.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:l})}),jsx("div",{style:{borderTop:`1px solid ${g.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:F,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&b(!x),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...Xe,borderColor:st.color,backgroundColor:`${st.color}15`},disabled:l,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:st.color}}),jsx("span",{style:{color:st.color},children:st.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:st.color}})]}),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-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:f.map($=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{we("status",$.id),b(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:$.color}}),$.title,O.status===$.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},$.id))})})]}),jsxs("div",{ref:W,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&w(!h),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:Xe,disabled:l,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:ht.color}}),jsx("span",{children:ht.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:h&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:Ws.map($=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{we("priority",$.id),w(false);},children:[jsx("span",{children:$.icon}),$.label,O.priority===$.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},$.id))})})]}),o.length>0&&jsxs("div",{ref:E,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&N(!D),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:Xe,disabled:l,children:[O.assignees&&O.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:O.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||g.accent,borderColor:g.bgSecondary},children:$.initials},ne))}),O.assignees.length>3&&jsxs("span",{style:{color:g.textTertiary},children:["+",O.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:g.textTertiary}}),jsx("span",{style:{color:g.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:D&&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:g.bgPrimary,border:`1px solid ${g.border}`},children:o.map($=>{let ne=O.assignees?.some(ve=>ve.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:g.textPrimary},onMouseEnter:ve=>ve.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ve=>ve.currentTarget.style.backgroundColor="transparent",onClick:()=>{let ve=ne?(O.assignees||[]).filter(Te=>Te.name!==$.name):[...O.assignees||[],{name:$.name,avatar:$.avatar,initials:$.name.split(" ").map(Te=>Te[0]).join("").toUpperCase().slice(0,2),color:g.accent}];we("assignees",ve);},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:g.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:g.accent}})})]},$.id)})})})]}),jsxs("div",{ref:K,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!l)if(A)y(false);else {if(K.current){let $=K.current.getBoundingClientRect(),ne=window.innerHeight,ve=120,De=ne-$.bottom<ve?$.top-ve-8:$.bottom+8;T({top:De,left:$.left});}y(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:Xe,disabled:l,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:O.color}}),jsx("span",{children:Ft.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:A&&jsxs(rt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>y(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:`${R.top}px`,left:`${R.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:$=>$.stopPropagation(),children:jsx("div",{style:{padding:"14px 18px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 16px)",gap:"14px"},children:sn.slice(0,18).map($=>{let ne=O.color===$.value;return jsx(motion.button,{type:"button",onClick:()=>{we("color",$.value),y(false);},style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:$.value,outline:ne?`2px solid ${$.value}`:"none",outlineOffset:"3px",cursor:"pointer",border:"none"},whileHover:{scale:1.2},whileTap:{scale:.95},title:$.name},$.value)})})})})]})})]}),m.length>0||d?jsx($r,{selectedTags:O.tags||[],availableTags:m,onChange:$=>we("tags",$),onCreateTag:d,theme:g,disabled:l}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{ref:te,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!l&&!O.isMilestone)if(k==="start")B(null);else {if(te.current){let $=te.current.getBoundingClientRect(),ne=window.innerHeight,ve=320,De=ne-$.bottom<ve?$.top-ve-8:$.bottom+8;be({top:De,left:$.left});}B("start"),H(O.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...Xe,opacity:O.isMilestone?.5:1,cursor:O.isMilestone?"not-allowed":"pointer"},disabled:l||O.isMilestone,children:O.startDate?O.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:g.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!l&&!O.isMilestone)if(k==="end")B(null);else {if(te.current){let $=te.current.getBoundingClientRect(),ne=window.innerHeight,ve=320,De=ne-$.bottom<ve?$.top-ve-8:$.bottom+8;be({top:De,left:$.left});}B("end"),H(O.endDate||O.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...Xe,opacity:O.isMilestone?.5:1,cursor:O.isMilestone?"not-allowed":"pointer"},disabled:l||O.isMilestone,children:O.endDate?O.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:k&&jsxs(rt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>B(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:`${X$1.top}px`,left:`${X$1.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},onClick:$=>$.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${g.border}`},children:[(()=>{let $=new Date,ne=new Date($);ne.setDate($.getDate()+1);let ve=new Date($);ve.setDate($.getDate()+7);let Te=new Date($);return Te.setDate($.getDate()+14),[{label:"Hoy",date:$},{label:"Ma\xF1ana",date:ne},{label:"Pr\xF3xima semana",date:ve},{label:"2 semanas",date:Te}].map((Ye,mt)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:g.textPrimary},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{k==="start"?(we("startDate",Ye.date),(!O.endDate||Ye.date>O.endDate)&&we("endDate",Ye.date),B("end")):(we("endDate",Ye.date),(!O.startDate||Ye.date<O.startDate)&&we("startDate",Ye.date),B(null));},children:Ye.label},mt))})(),jsx("div",{style:{borderTop:`1px solid ${g.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=g.hoverBg,onMouseLeave:$=>$.currentTarget.style.backgroundColor="transparent",onClick:()=>{we("startDate",void 0),we("endDate",void 0),B(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:()=>H(new Date(P.getFullYear(),P.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:g.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:g.textPrimary},children:P.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>H(new Date(P.getFullYear(),P.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:g.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:g.textTertiary},children:$},ne))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let $=P.getFullYear(),ne=P.getMonth(),ve=new Date($,ne,1).getDay(),Te=new Date($,ne+1,0).getDate(),De=new Date,Ye=[];for(let Ie=ve-1;Ie>=0;Ie--)Ye.push({day:new Date($,ne,-Ie).getDate(),date:new Date($,ne-1,new Date($,ne,-Ie).getDate()),isCurrentMonth:false});for(let Ie=1;Ie<=Te;Ie++)Ye.push({day:Ie,date:new Date($,ne,Ie),isCurrentMonth:true});let mt=42-Ye.length;for(let Ie=1;Ie<=mt;Ie++)Ye.push({day:Ie,date:new Date($,ne+1,Ie),isCurrentMonth:false});return Ye.map((Ie,I)=>{let Y=Ie.date.toDateString()===De.toDateString(),He=O.startDate?.toDateString()===Ie.date.toDateString(),We=O.endDate?.toDateString()===Ie.date.toDateString(),bt=O.startDate&&O.endDate&&Ie.date>=O.startDate&&Ie.date<=O.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?He||We?"#FFF":g.textPrimary:g.textTertiary,backgroundColor:He?"#3B82F6":We?"#7C3AED":bt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Y&&!He&&!We?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{k==="start"?(we("startDate",Ie.date),O.endDate&&Ie.date>O.endDate&&we("endDate",Ie.date),B("end")):(we("endDate",Ie.date),O.startDate&&Ie.date<O.startDate&&we("startDate",Ie.date),B(null));},children:Ie.day},I)})})()})]})]})]})})]}),he.endDate&&jsx("span",{className:"text-xs text-red-400",children:he.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:O.progress,onChange:$=>we("progress",parseInt($.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:g.bgSecondary,accentColor:O.progress<30?"#EF4444":O.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${O.progress<30?"#EF4444":O.progress<70?"#F59E0B":"#10B981"}20`,color:O.progress<30?"#EF4444":O.progress<70?"#F59E0B":"#10B981"},children:[O.progress,"%"]})]})]}),(u||i.length>0||c==="create")&&jsxs("div",{className:"pt-2",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:g.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:g.textTertiary},children:["Adjuntos ",c==="create"?Fe.length>0&&`(${Fe.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsx($a,{cardId:"pending",attachments:Fe.map(($,ne)=>({id:`pending-${ne}`,cardId:"pending",name:$.name,size:$.size,type:$.type,url:URL.createObjectURL($),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:$=>z(ne=>[...ne,...$]),onDelete:$=>{let ne=parseInt($.replace("pending-",""),10);z(ve=>ve.filter((Te,De)=>De!==ne));},maxSizeMB:10,maxFiles:20}):jsx($a,{cardId:a?.id||"new",attachments:i,onUpload:u&&a?.id?$=>u(a.id,$):void 0,onDelete:v,maxSizeMB:10,maxFiles:20}),c==="create"&&Fe.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:g.textTertiary},children:[Fe.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Ae(!ke),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:g.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${ke?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:ke&&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:[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:O.isMilestone,onChange:$=>we("isMilestone",$.target.checked),className:"w-4 h-4 rounded",style:{accentColor:g.accent},disabled:l}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:g.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:g.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:g.bgSecondary},children:r.filter($=>$.id!==a?.id).map($=>{let ne=O.dependencies?.includes($.id);return jsx("button",{type:"button",onClick:()=>{let ve=ne?(O.dependencies||[]).filter(Te=>Te!==$.id):[...O.dependencies||[],$.id];we("dependencies",ve);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:ne?`${g.accent}30`:g.bgPrimary,color:ne?g.accent:g.textSecondary,border:`1px solid ${ne?g.accent:g.borderLight}`},disabled:l,children:$.name},$.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${g.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:g.textSecondary},onMouseEnter:$=>$.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:$=>$.currentTarget.style.backgroundColor="transparent",disabled:l,children:"Cancelar"}),jsx("button",{type:"submit",disabled:l,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:g.accent,color:"#FFF"},onMouseEnter:$=>!l&&($.currentTarget.style.opacity="0.9"),onMouseLeave:$=>!l&&($.currentTarget.style.opacity="1"),children:l?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 lf=['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"'],Md=()=>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"})]}),df=()=>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"})}),cf=()=>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"})}),pf=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),mf=()=>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 dn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:l,onDependencyCreate:c,onDependencyDelete:p}){let[n,m]=useState(false),[d,i]=useState(false),[u,v]=useState([]),[f,g]=useState(""),[x,b]=useState(false),[h,w]=useState(true),D=useRef(null),N=useRef(null),A=useRef(null),{enabled:y=true,placeholder:R='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:k,suggestions:B=lf,maxHistory:P=50,persistHistory:H}=a,X=H?.storageKey||"gantt-ai-history",be=H?.maxMessages??5;useEffect(()=>{if(H?.enabled)try{let W=localStorage.getItem(X);if(W){let K=JSON.parse(W).map(te=>({...te,timestamp:new Date(te.timestamp)}));v(K.slice(-be));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[H?.enabled,X,be]),useEffect(()=>{if(H?.enabled&&u.length>0)try{let W=u.filter(E=>!E.isLoading).slice(-be);localStorage.setItem(X,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[u,H?.enabled,X,be]),useEffect(()=>{N.current&&N.current.scrollIntoView({behavior:"smooth"});},[u]),useEffect(()=>{n&&!d&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,d]);let ke=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&&l?.(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,l,c,p]),Ae=useCallback(async W=>{if(!W.trim()||x)return;let E={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};v(te=>[...te.slice(-(P-1)),E]),g(""),w(false),b(true);let K={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(te=>[...te,K]);try{if(k){let te=await k(W,e);v(O=>{let Me=O.filter(qe=>!qe.isLoading),he={id:`assistant-${Date.now()}`,role:"assistant",content:te.message,timestamp:new Date,command:te};return [...Me,he]}),ke(te);}else v(te=>[...te.filter(Me=>!Me.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(te){v(O=>[...O.filter(he=>!he.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${te instanceof Error?te.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,P,k,e,ke]),Fe=W=>{W.preventDefault(),Ae(f);},z=W=>{g(W),D.current?.focus();};if(useEffect(()=>{let W=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),m(K=>!K),n||i(false)),E.key==="Escape"&&n&&m(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[n]),useEffect(()=>{if(!n)return;let W=K=>{let te=K.target;A.current&&!A.current.contains(te)&&m(false);},E=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",W);}},[n]),!y)return null;let F={"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(rt,{children:[jsx(AnimatePresence,{children:!n&&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 ${F[T]} 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:()=>m(true),children:[jsx(Md,{}),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:n&&jsxs(motion.div,{ref:A,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 ${F[T]} 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(Md,{}),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(pf,{})}),jsx("button",{onClick:()=>m(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(cf,{})})]})]}),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:[u.length===0&&h&&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:B.slice(0,4).map((W,E)=>jsx("button",{onClick:()=>z(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},E))})]}),u.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(mf,{}):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:N})]}),jsxs("form",{onSubmit:Fe,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsx("input",{ref:D,type:"text",value:f,onChange:W=>g(W.target.value),placeholder:R,disabled:x,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!f.trim()||x,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsx(df,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function Ad(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((n,m=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!m)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=useCallback(()=>{r(n=>{if(n.past.length===0)return n;let m=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:m,future:[n.present,...n.future]}});},[]),c=useCallback(()=>{r(n=>{if(n.future.length===0)return n;let m=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:m,future:d}});},[]),p=useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function Id({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=l=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?l.metaKey:l.ctrlKey;if(p&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!c&&p&&l.key==="y"){l.preventDefault(),t();return}if(c&&p&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var hf={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${ie.formatDate(e.startDate)} - ${ie.formatDate(e.endDate)}`);let a=ie.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=>ie.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function Ld(e){return {...hf,...e}}var Cf=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},Rd=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:m=[],templates:d,enableAutoCriticalPath:i=true,persistExpandedState:u,aiAssistant:v,locale:f="en",customTranslations:g,showCreateTaskButton:x=false,createTaskLabel:b,onCreateTask:h,onThemeChange:w,onTaskClick:D,onTaskDblClick:N,onTaskContextMenu:A,onTaskUpdate:y,onProgressChange:R,onTaskEdit:T,onTaskAddSubtask:k,onTaskMarkIncomplete:B,onTaskSetInProgress:P,onDependencyCreate:H,onDependencyDelete:X,onBeforeTaskAdd:be,onAfterTaskAdd:ke,onBeforeTaskUpdate:Ae,onAfterTaskUpdate:Fe,onBeforeTaskDelete:z,onAfterTaskDelete:F}=a,E=useContext(Vo)?.theme,[K,te]=useState(E||s||"dark"),[O,Me]=useState(l),[he,qe]=useState(c),[me,tt]=useState(1),[we,st]=useState(0),[ht,Ft]=useState(false),[Xe,$]=useState(null),[ne,ve]=useState({isOpen:false,x:0,y:0,task:null}),[Te,De]=useState(null),[Ye,mt]=useState(null);useEffect(()=>{E&&E!==K&&te(E);},[E]),useEffect(()=>{s&&s!==K&&te(s);},[s]);let Ie=useCallback(S=>{te(S),w?.(S);},[w]),{state:I,setState:Y,undo:He,redo:We,canUndo:bt,canRedo:J,clearHistory:Q}=Ad(t,50),xe=useCallback(()=>u?typeof u=="string"?u:"gantt-expanded-tasks":null,[u]),Ce=useRef(new Map),ae=useRef(false);if(!ae.current&&u){ae.current=true;let S=typeof u=="string"?u:"gantt-expanded-tasks";try{let M=localStorage.getItem(S);if(M){let j=JSON.parse(M);Array.isArray(j)&&(Ce.current=new Map(j));}}catch(M){console.warn("[GanttBoard] Error loading expanded state from localStorage:",M);}}let Pe=useCallback(()=>{let S=xe();if(S)try{let M=Array.from(Ce.current.entries());localStorage.setItem(S,JSON.stringify(M));}catch(M){console.warn("[GanttBoard] Error saving expanded state to localStorage:",M);}},[xe]);useEffect(()=>{let S=M=>M.map(j=>{let ee=Ce.current.get(j.id),pe=ee!==void 0?{...j,isExpanded:ee}:j;return pe.subtasks?.length?{...pe,subtasks:S(pe.subtasks)}:pe});Ce.current.size>0?Y(S(t)):Y(t);},[t,Y]);let ye=useRef(t),Ne=useRef(true);useEffect(()=>{if(Ne.current){Ne.current=false,ye.current=I;return}if(!r)return;let S=JSON.stringify(ye.current),M=JSON.stringify(I);S!==M&&(ye.current=I,r(I));},[I,r]);let se=useMemo(()=>Ts(f,g),[f,g]),Re=useCallback(S=>[{id:"name",label:S.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:S.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:S.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:S.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:S.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:S.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:S.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:S.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Le,$e]=useState(()=>Re(se));useEffect(()=>{$e(S=>S.map(M=>({...M,label:se.columns[M.id==="name"?"taskName":M.id]||M.label})));},[se]);let _=useMemo(()=>{let S=Le.filter(ee=>ee.visible),M=S.some(ee=>ee.id!=="name");return S.reduce((ee,pe)=>ee+pe.width,0)+(M?20:0)},[Le]);useEffect(()=>{Xe!==null&&Xe>_&&(Le.filter(j=>j.visible).some(j=>j.id!=="name")||$(null));},[Le,_,Xe]);let q=useMemo(()=>Xe!==null?Math.max(280,Xe,_):Math.max(280,_),[Xe,_]),at=useRef(null),Ue=useRef(null),le=useRef(null),Ze=useMemo(()=>Jl(K),[K]),Tt=useMemo(()=>({theme:Ze,themeName:K}),[Ze,K]),U=useMemo(()=>Ld(d),[d]),ce=useMemo(()=>{if(!i)return I;let S=ie.calculateCriticalPath(I),M=j=>j.map(ee=>({...ee,isCriticalPath:S.includes(ee.id),subtasks:ee.subtasks?M(ee.subtasks):void 0}));return M(I)},[I,i]),Se=Cf(he);Id({undo:He,redo:We,canUndo:bt,canRedo:J,enabled:true}),useImperativeHandle(o,()=>({getTask:S=>ie.findTaskById(I,S),addTask:(S,M)=>{Y(j=>{if(!M)return [...j,{...S,level:0}];let ee=pe=>pe.map(Ee=>Ee.id===M?{...Ee,subtasks:[...Ee.subtasks||[],{...S,parentId:M,level:(Ee.level||0)+1}],isExpanded:true}:Ee.subtasks?{...Ee,subtasks:ee(Ee.subtasks)}:Ee);return ee(j)});},updateTask:(S,M)=>{Y(j=>{let ee=pe=>pe.map(Ee=>Ee.id===S?{...Ee,...M}:Ee.subtasks?{...Ee,subtasks:ee(Ee.subtasks)}:Ee);return ee(j)});},deleteTask:S=>{Y(M=>{let j=ee=>ee.filter(pe=>pe.id===S?false:(pe.subtasks&&(pe.subtasks=j(pe.subtasks)),true));return j(M)});},deleteTasks:S=>{Y(M=>As(M,S));},duplicateTask:S=>{Y(M=>Is(M,[S]));},splitTask:(S,M,j=3)=>{Y(ee=>ie.splitTask(ee,S,M,j));},calculateEndDate:ie.calculateEndDate,calculateDuration:ie.calculateDuration,validateDependency:(S,M)=>!ie.validateDependencies(I,S,M),getAllTasks:()=>ie.flattenTasks(I),getTasksByStatus:S=>ie.flattenTasks(I).filter(M=>M.status===S),getTasksByParent:S=>S?ie.findTaskById(I,S)?.subtasks||[]:I.filter(j=>!j.parentId),getCriticalPath:()=>ie.flattenTasks(I).filter(S=>S.isCriticalPath),indentTask:S=>{Y(M=>Es(M,[S]));},outdentTask:S=>{Y(M=>Ps(M,[S]));},moveTask:(S,M)=>{Y(j=>Ms(j,[S],M));},createSubtask:async S=>{let{tasks:M,newTask:j}=Bs(I,S);if(be){let ee=be({...j,parentId:S});if((ee instanceof Promise?await ee:ee)===false)return}Y(M),ke&&ke({...j,parentId:S});},scrollToTask:S=>{let j=ie.flattenTasks(I).findIndex(ee=>ee.id===S);if(j!==-1&&at.current){let ee=j*Se;at.current.scrollTo({top:ee,behavior:"smooth"}),Ue.current&&Ue.current.scrollTo({top:ee,behavior:"smooth"});}},highlightTask:(S,M=2e3)=>{},expandTask:S=>{Y(M=>{let j=ee=>ee.map(pe=>pe.id===S?{...pe,isExpanded:true}:pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe);return j(M)});},collapseTask:S=>{Y(M=>{let j=ee=>ee.map(pe=>pe.id===S?{...pe,isExpanded:false}:pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe);return j(M)});},expandAll:()=>{Y(S=>{let M=j=>j.map(ee=>({...ee,isExpanded:true,subtasks:ee.subtasks?M(ee.subtasks):void 0}));return M(S)});},collapseAll:()=>{Y(S=>{let M=j=>j.map(ee=>({...ee,isExpanded:false,subtasks:ee.subtasks?M(ee.subtasks):void 0}));return M(S)});},undo:He,redo:We,canUndo:()=>bt,canRedo:()=>J,clearHistory:Q,exportToPNG:async()=>{if(!le.current)throw new Error("Gantt container not found");let S=await Bd(le.current,{backgroundColor:Ze.bgPrimary,scale:2});return new Promise((M,j)=>{S.toBlob(ee=>{ee?M(ee):j(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async S=>{await ie.exportToPDF(I,S);},exportToExcel:async S=>{await ie.exportToExcel(I,S);},exportToJSON:()=>ie.exportToJSON(I),exportToCSV:()=>ie.exportToCSV(I),importFromJSON:S=>{let M=ie.importFromJSON(S);Y(M);},getTasks:()=>I,refresh:()=>{Y(S=>[...S]);},clearAll:()=>{Y([]);}}),[I,He,We,bt,J,Q,Ze,Se]);let $t=useCallback(S=>{$e(M=>M.map(j=>j.id===S?{...j,visible:!j.visible}:j));},[]),ea=useCallback((S,M)=>{$e(j=>j.map(ee=>{if(ee.id!==S)return ee;let pe=ee.minWidth??100,Ee=ee.maxWidth??800,Rt=Math.max(pe,Math.min(Ee,M));return {...ee,width:Rt}}));},[]),Xa=useCallback(S=>{Y(M=>{let j=Fs(M,S),ee=pe=>{for(let Ee of pe){if(Ee.id===S){Ce.current.set(S,Ee.isExpanded??true);return}Ee.subtasks?.length&&ee(Ee.subtasks);}};return ee(j),Pe(),j}),a.onTaskToggleExpand?.(S);},[a,Pe]),Ra=useCallback((S,M)=>{if(Ae&&Ae(S,M)===false)return;let ee=ie.findTaskById(I,S)?.progress,pe=Rt=>Rt.map(Gt=>Gt.id===S?{...Gt,...M}:Gt.subtasks?{...Gt,subtasks:pe(Gt.subtasks)}:Gt);Y(pe(I));let Ee=ie.findTaskById(pe(I),S);Ee&&(y?.(Ee),Fe?.(Ee),M.progress!==void 0&&ee!==void 0&&M.progress!==ee&&R?.(S,ee,M.progress));},[I,y,Ae,Fe,R]),de=useCallback(S=>{S.length!==0&&(Y(M=>Es(M,S)),a.onTaskIndent?.(S[0]));},[a]),Dt=useCallback(S=>{S.length!==0&&(Y(M=>Ps(M,S)),a.onTaskOutdent?.(S[0]));},[a]),Jt=useCallback((S,M,j)=>{Y(ee=>bd(ee,S,M,j)),a.onTaskReparent?.(S,M,j);},[a]),Pr=useCallback((S,M)=>{S.length!==0&&(Y(j=>Ms(j,S,M)),a.onTaskMove?.(S[0],M));},[a]),Mr=useCallback(async S=>{let M=[];for(let j of S)z&&await Promise.resolve(z(j))===false||M.push(j);M.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(M):(Y(j=>As(j,M)),M.forEach(j=>a.onTaskDelete?.(j))),F&&M.forEach(j=>F(j)));},[a,z,F]),Ar=useCallback(S=>{Y(M=>Is(M,S)),S.forEach(M=>a.onTaskDuplicate?.(M));},[a]),Ha=useCallback((S,M)=>{Y(j=>{let{tasks:ee,newTask:pe}=hd(j,S,M);return be&&be(pe)===false?j:(a.onTaskCreate?.(pe.parentId,pe.position||0),ke?.(pe),ee)});},[a,be,ke]),lr=useCallback((S,M)=>{Y(j=>Ls(j,S,M)),a.onTaskRename?.(S,M);},[a]),Nt=useCallback(S=>{Y(M=>{let{tasks:j}=Bs(M,S);return a.onTaskCreate?.(S,0),j});},[a]),Pn=useCallback((S,M,j)=>{let ee=S.startDate?Math.round((M.getTime()-S.startDate.getTime())/864e5):0,pe=Gt=>Gt.map(Zt=>Zt.id===S.id?{...Zt,startDate:M,endDate:j,...S.segments&&{segments:S.segments}}:Zt.subtasks?{...Zt,subtasks:pe(Zt.subtasks)}:Zt),Ee=pe(I);Ee=ie.autoScheduleDependents(Ee,S.id,ee),Y(Ee);let Rt={...S,startDate:M,endDate:j};y?.(Rt);},[I,y]),Mn=useCallback((S,M)=>{A?.(S,M),ve({isOpen:true,x:M.clientX,y:M.clientY,task:S});},[A]),Ri=useCallback((S,M)=>{let j=ie.splitTask(I,S.id,M);Y(j),ve({isOpen:false,x:0,y:0,task:null});},[I]),Ir=useCallback(S=>{let M=ie.findTaskById(I,S.id)||S;N?.(M),T||De(M);},[I,N,T]),Oi=useCallback((S,M,j)=>{let ee=new Map,pe=Da=>{Da.forEach(Ga=>{Ga.dependencies&&ee.set(Ga.id,Ga.dependencies),Ga.subtasks&&pe(Ga.subtasks);});};pe(j);let Ee=ee.get(M)||[];ee.set(M,[...Ee,S]);let Rt=new Set,Gt=new Set,Zt=Da=>{if(!Rt.has(Da)){Rt.add(Da),Gt.add(Da);let Ga=ee.get(Da)||[];for(let dr of Ga){if(!Rt.has(dr)&&Zt(dr))return true;if(Gt.has(dr))return true}}return Gt.delete(Da),false};return Zt(M)},[]),zi=useCallback((S,M)=>{if(Oi(S.id,M,I)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
343
343
 
344
- Task dependencies must flow in one direction only.`);return}let K=ae=>ae.map(le=>{if(le.id===A){let Se=le.dependencies||[];if(!Se.includes(E.id))return {...le,dependencies:[...Se,E.id]}}return le.subtasks?{...le,subtasks:K(le.subtasks)}:le});z(K(Y)),P?.(E.id,A);},[Y,P,So]),An=useCallback((E,A)=>{let K=ae=>ae.map(le=>{if(le.id===E&&le.dependencies){let Se=le.dependencies.filter(Bt=>Bt!==A);return {...le,dependencies:Se}}return le.subtasks?{...le,subtasks:K(le.subtasks)}:le});z(K(Y)),H?.(E,A);},[Y,H]),{startDate:Jr,endDate:Kc}=useMemo(()=>{let E=Y.filter(Se=>Se.startDate&&Se.endDate);if(E.length===0){let Se=new Date,Bt=new Date(Se);Bt.setDate(Bt.getDate()-30);let Ht=new Date(Se);return Ht.setDate(Ht.getDate()+60),{startDate:Bt,endDate:Ht}}let A=E.flatMap(Se=>[Se.startDate,Se.endDate]).filter(Se=>Se!==void 0),K=new Date(Math.min(...A.map(Se=>Se.getTime()))),ae=new Date(Math.max(...A.map(Se=>Se.getTime()))),le=ee==="day"?7:ee==="week"?14:30;return K.setDate(K.getDate()-le),ae.setDate(ae.getDate()+le),{startDate:K,endDate:ae}},[Y,ee]),Yc=useCallback(async()=>{if(!_.current)return;let E=await Id(_.current,{backgroundColor:j.bgPrimary,scale:2}),A=document.createElement("a");A.download="gantt-chart.png",A.href=E.toDataURL("image/png"),A.click();},[j]),qc=useCallback(async()=>{await ne.exportToPDF(Y);},[Y]),Xc=useCallback(async()=>{await ne.exportToExcel(Y);},[Y]),Jc=useCallback(()=>{let E=ne.exportToCSV(Y),A=new Blob([E],{type:"text/csv;charset=utf-8;"}),K=document.createElement("a");K.href=URL.createObjectURL(A),K.download="gantt-chart.csv",K.click(),URL.revokeObjectURL(K.href);},[Y]),Zc=useCallback(()=>{let E=ne.exportToJSON(Y),A=new Blob([E],{type:"application/json;charset=utf-8;"}),K=document.createElement("a");K.href=URL.createObjectURL(A),K.download="gantt-chart.json",K.click(),URL.revokeObjectURL(K.href);},[Y]),Qc=useCallback(()=>{ne.exportToMSProject(Y,"Gantt Project","project.xml");},[Y]),ep=E=>{E.preventDefault(),gt(true);};return useEffect(()=>{let E=Oe.current,A=Fe.current;if(!E||!A)return;let K=A.querySelector(".gantt-taskgrid-content"),ae=()=>{let Zt=E.scrollTop;Te(Zt),K&&(K.style.transform=`translateY(-${Zt}px)`);},le=Zt=>{if(rt&&A){let Ha=A.parentElement?.getBoundingClientRect()?.left||0,lr=Zt.clientX-Ha,tp=280,ap=Math.min(window.innerWidth-300,800);lr>=tp&&lr<=ap&&et(lr);}},Se=()=>{gt(false);},Bt=A.querySelector(".gantt-grid-scroll")||A,Ht=Zt=>{let Da=Zt;Da.deltaY!==0&&(E.scrollTop+=Da.deltaY,Zt.preventDefault());};return E.addEventListener("scroll",ae),Bt.addEventListener("wheel",Ht,{passive:false}),document.addEventListener("mousemove",le),document.addEventListener("mouseup",Se),()=>{E.removeEventListener("scroll",ae),Bt.removeEventListener("wheel",Ht),document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",Se);}},[rt]),jsx(Wr.Provider,{value:J,children:jsx(Rn.Provider,{value:nt,children:jsxs("div",{ref:_,className:"flex flex-col h-full w-full",style:{backgroundColor:j.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(qo,{theme:j,timeScale:ee,onTimeScaleChange:$,zoom:qe,onZoomChange:ue,currentTheme:S,onThemeChange:Ct,rowDensity:Me,onRowDensityChange:be,showThemeSelector:p,showCreateTaskButton:g,createTaskLabel:x,onCreateTask:b,onExportPNG:n?Yc:void 0,onExportPDF:n?qc:void 0,onExportExcel:n?Xc:void 0,onExportCSV:n?Jc:void 0,onExportJSON:n?Zc:void 0,onExportMSProject:n?Qc:void 0}),jsxs("div",{ref:Fe,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Re,overflow:"hidden"},children:jsx(Qo,{tasks:ge,theme:j,rowHeight:Vt,availableUsers:m,templates:He,onTaskClick:w,onTaskDblClick:Et,onTaskContextMenu:N,onTaskToggle:ce,scrollTop:Qe,columns:he,onToggleColumn:Tt,onColumnResize:U,onTaskUpdate:Ce,onTaskIndent:zt,onTaskOutdent:ea,onTaskMove:Xr,onMultiTaskDelete:ie,onTaskDuplicate:Dt,onTaskCreate:Jt,onTaskRename:Sr,onCreateSubtask:Er,onOpenTaskModal:w?E=>w(E):void 0,onDeleteRequest:(E,A)=>Ve({taskId:E,taskName:A}),onTaskReparent:qa})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize",style:{width:6,marginLeft:-3,zIndex:10},onMouseDown:ep}),jsx("div",{ref:Oe,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(ln,{tasks:ge,theme:j,rowHeight:Vt,timeScale:ee,startDate:Jr,endDate:Kc,zoom:qe,templates:He,onTaskClick:w,onTaskDblClick:Et,onTaskContextMenu:Wa,onTaskDateChange:Pr,onDependencyCreate:Eo,onDependencyDelete:An})})]}),R.task&&jsx(Hr,{isOpen:R.isOpen,x:R.x,y:R.y,theme:j,onClose:()=>se({isOpen:false,x:0,y:0,task:null}),items:(()=>{let E=R.task;if(!E)return [];let A=ne.findTaskById(Y,E.id)||E;return A.subtasks&&A.subtasks.length>0?[{id:"addSubtask",label:J.contextMenu?.addSubtask||"Add Subtask",icon:kt.Add,onClick:()=>{T?T(A):Er(A.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:J.contextMenu?.deleteTask||"Delete Task",icon:kt.Delete,onClick:()=>{Ve({taskId:A.id,taskName:A.name});}}]:[{id:"edit",label:J.contextMenu?.editTask||"Edit Task",icon:kt.Pencil,onClick:()=>{L?L(A):De(A);}},{id:"addSubtask",label:J.contextMenu?.addSubtask||"Add Subtask",icon:kt.Add,onClick:()=>{T?T(A):Er(A.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:J.contextMenu?.markIncomplete||"Mark Incomplete",icon:kt.MarkIncomplete,onClick:()=>{k?k(A):Ce(A.id,{status:"todo",progress:0});},disabled:A.status==="todo"},{id:"setInProgress",label:J.contextMenu?.setInProgress||"Set In Progress",icon:kt.SetInProgress,onClick:()=>{F?F(A):Ce(A.id,{status:"in-progress"});},disabled:A.status==="in-progress"},{id:"markComplete",label:J.contextMenu?.markComplete||"Mark Complete",icon:kt.MarkComplete,onClick:()=>{Ce(A.id,{status:"completed",progress:100});},disabled:A.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:J.contextMenu?.splitTask||"Split Task",icon:kt.Split,onClick:()=>{if(!A.startDate||!A.endDate){console.warn("Cannot split task without dates");return}let ae=A.startDate.getTime(),le=A.endDate.getTime(),Se=ae+(le-ae)/2,Bt=new Date(Se);ir(A,Bt);},disabled:!A.startDate||!A.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:J.contextMenu?.deleteTask||"Delete Task",icon:kt.Delete,onClick:()=>{Ve({taskId:A.id,taskName:A.name});}}]})()}),ve&&jsx(cn,{isOpen:true,onClose:()=>De(null),task:ve,onSubmit:E=>{Ce(ve.id,E),De(null);},mode:"edit",theme:S}),jsx(AnimatePresence,{children:Ee&&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:()=>Ve(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:E=>E.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:j.bgSecondary,border:`1px solid ${j.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${j.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:j.textPrimary,fontFamily:"Inter, sans-serif"},children:[J.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:j.textSecondary,fontFamily:"Inter, sans-serif"},children:y==="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:j.textSecondary,fontFamily:"Inter, sans-serif"},children:[y==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:j.textPrimary},children:['"',Ee.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:j.bgPrimary,borderTop:`1px solid ${j.border}`},children:[jsx("button",{onClick:()=>Ve(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:j.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:E=>{E.currentTarget.style.backgroundColor=j.hoverBg;},onMouseLeave:E=>{E.currentTarget.style.backgroundColor="transparent";},children:y==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{ie([Ee.taskId]),Ve(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:E=>{E.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:E=>{E.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),y==="es"?"Eliminar":"Delete"]})]})]})})}),u?.enabled&&jsx(pn,{tasks:Y,theme:j,config:u,onTasksUpdate:z,onTaskUpdate:Ce,onTaskCreate:E=>{z(A=>[...A,E]);},onTaskDelete:E=>{ie([E]);},onDependencyCreate:(E,A)=>{let K=ne.findTaskById(Y,E);K&&Eo(K,A);},onDependencyDelete:An})]})})})});var Fd=`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 j=ee=>ee.map(pe=>{if(pe.id===M){let Ee=pe.dependencies||[];if(!Ee.includes(S.id))return {...pe,dependencies:[...Ee,S.id]}}return pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe});Y(j(I)),H?.(S.id,M);},[I,H,Oi]),$i=useCallback((S,M)=>{let j=ee=>ee.map(pe=>{if(pe.id===S&&pe.dependencies){let Ee=pe.dependencies.filter(Rt=>Rt!==M);return {...pe,dependencies:Ee}}return pe.subtasks?{...pe,subtasks:j(pe.subtasks)}:pe});Y(j(I)),X?.(S,M);},[I,X]),{startDate:Xc,endDate:Jc}=useMemo(()=>{let S=I.filter(Ee=>Ee.startDate&&Ee.endDate);if(S.length===0){let Ee=new Date,Rt=new Date(Ee);Rt.setDate(Rt.getDate()-30);let Gt=new Date(Ee);return Gt.setDate(Gt.getDate()+60),{startDate:Rt,endDate:Gt}}let M=S.flatMap(Ee=>[Ee.startDate,Ee.endDate]).filter(Ee=>Ee!==void 0),j=new Date(Math.min(...M.map(Ee=>Ee.getTime()))),ee=new Date(Math.max(...M.map(Ee=>Ee.getTime()))),pe=O==="day"?7:O==="week"?14:30;return j.setDate(j.getDate()-pe),ee.setDate(ee.getDate()+pe),{startDate:j,endDate:ee}},[I,O]),Zc=useCallback(async()=>{if(!le.current)return;let S=await Bd(le.current,{backgroundColor:Ze.bgPrimary,scale:2}),M=document.createElement("a");M.download="gantt-chart.png",M.href=S.toDataURL("image/png"),M.click();},[Ze]),Qc=useCallback(async()=>{await ie.exportToPDF(I);},[I]),ep=useCallback(async()=>{await ie.exportToExcel(I);},[I]),tp=useCallback(()=>{let S=ie.exportToCSV(I),M=new Blob([S],{type:"text/csv;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(M),j.download="gantt-chart.csv",j.click(),URL.revokeObjectURL(j.href);},[I]),ap=useCallback(()=>{let S=ie.exportToJSON(I),M=new Blob([S],{type:"application/json;charset=utf-8;"}),j=document.createElement("a");j.href=URL.createObjectURL(M),j.download="gantt-chart.json",j.click(),URL.revokeObjectURL(j.href);},[I]),rp=useCallback(()=>{ie.exportToMSProject(I,"Gantt Project","project.xml");},[I]),op=S=>{S.preventDefault(),Ft(true);};return useEffect(()=>{let S=Ue.current,M=at.current;if(!S||!M)return;let j=M.querySelector(".gantt-taskgrid-content"),ee=()=>{let Zt=S.scrollTop;st(Zt),j&&(j.style.transform=`translateY(-${Zt}px)`);},pe=Zt=>{if(ht&&M){let Ga=M.parentElement?.getBoundingClientRect()?.left||0,dr=Zt.clientX-Ga,np=280,sp=Math.min(window.innerWidth-300,800);dr>=np&&dr<=sp&&$(dr);}},Ee=()=>{Ft(false);},Rt=M.querySelector(".gantt-grid-scroll")||M,Gt=Zt=>{let Da=Zt;Da.deltaY!==0&&(S.scrollTop+=Da.deltaY,Zt.preventDefault());};return S.addEventListener("scroll",ee),Rt.addEventListener("wheel",Gt,{passive:false}),document.addEventListener("mousemove",pe),document.addEventListener("mouseup",Ee),()=>{S.removeEventListener("scroll",ee),Rt.removeEventListener("wheel",Gt),document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",Ee);}},[ht]),jsx(_r.Provider,{value:se,children:jsx(Bn.Provider,{value:Tt,children:jsxs("div",{ref:le,className:"flex flex-col h-full w-full",style:{backgroundColor:Ze.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(Ko,{theme:Ze,timeScale:O,onTimeScaleChange:Me,zoom:me,onZoomChange:tt,currentTheme:K,onThemeChange:Ie,rowDensity:he,onRowDensityChange:qe,showThemeSelector:p,showCreateTaskButton:x,createTaskLabel:b,onCreateTask:h,onExportPNG:n?Zc:void 0,onExportPDF:n?Qc:void 0,onExportExcel:n?ep:void 0,onExportCSV:n?tp:void 0,onExportJSON:n?ap:void 0,onExportMSProject:n?rp:void 0}),jsxs("div",{ref:at,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:q,overflow:"hidden"},children:jsx(Jo,{tasks:ce,theme:Ze,rowHeight:Se,availableUsers:m,templates:U,onTaskClick:D,onTaskDblClick:Ir,onTaskContextMenu:A,onTaskToggle:Xa,scrollTop:we,columns:Le,onToggleColumn:$t,onColumnResize:ea,onTaskUpdate:Ra,onTaskIndent:de,onTaskOutdent:Dt,onTaskMove:Pr,onMultiTaskDelete:Mr,onTaskDuplicate:Ar,onTaskCreate:Ha,onTaskRename:lr,onCreateSubtask:Nt,onOpenTaskModal:D?S=>D(S):void 0,onDeleteRequest:(S,M)=>mt({taskId:S,taskName:M}),onTaskReparent:Jt})}),jsx("div",{className:"flex-shrink-0 cursor-col-resize",style:{width:6,marginLeft:-3,zIndex:10},onMouseDown:op}),jsx("div",{ref:Ue,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(nn,{tasks:ce,theme:Ze,rowHeight:Se,timeScale:O,startDate:Xc,endDate:Jc,zoom:me,templates:U,onTaskClick:D,onTaskDblClick:Ir,onTaskContextMenu:Mn,onTaskDateChange:Pn,onDependencyCreate:zi,onDependencyDelete:$i})})]}),ne.task&&jsx(Vr,{isOpen:ne.isOpen,x:ne.x,y:ne.y,theme:Ze,onClose:()=>ve({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=ne.task;if(!S)return [];let M=ie.findTaskById(I,S.id)||S;return M.subtasks&&M.subtasks.length>0?[{id:"addSubtask",label:se.contextMenu?.addSubtask||"Add Subtask",icon:wt.Add,onClick:()=>{k?k(M):Nt(M.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:se.contextMenu?.deleteTask||"Delete Task",icon:wt.Delete,onClick:()=>{mt({taskId:M.id,taskName:M.name});}}]:[{id:"edit",label:se.contextMenu?.editTask||"Edit Task",icon:wt.Pencil,onClick:()=>{T?T(M):De(M);}},{id:"addSubtask",label:se.contextMenu?.addSubtask||"Add Subtask",icon:wt.Add,onClick:()=>{k?k(M):Nt(M.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:se.contextMenu?.markIncomplete||"Mark Incomplete",icon:wt.MarkIncomplete,onClick:()=>{B?B(M):Ra(M.id,{status:"todo",progress:0});},disabled:M.status==="todo"},{id:"setInProgress",label:se.contextMenu?.setInProgress||"Set In Progress",icon:wt.SetInProgress,onClick:()=>{P?P(M):Ra(M.id,{status:"in-progress"});},disabled:M.status==="in-progress"},{id:"markComplete",label:se.contextMenu?.markComplete||"Mark Complete",icon:wt.MarkComplete,onClick:()=>{Ra(M.id,{status:"completed",progress:100});},disabled:M.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:se.contextMenu?.splitTask||"Split Task",icon:wt.Split,onClick:()=>{if(!M.startDate||!M.endDate){console.warn("Cannot split task without dates");return}let ee=M.startDate.getTime(),pe=M.endDate.getTime(),Ee=ee+(pe-ee)/2,Rt=new Date(Ee);Ri(M,Rt);},disabled:!M.startDate||!M.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:se.contextMenu?.deleteTask||"Delete Task",icon:wt.Delete,onClick:()=>{mt({taskId:M.id,taskName:M.name});}}]})()}),Te&&jsx(ln,{isOpen:true,onClose:()=>De(null),task:Te,onSubmit:S=>{Ra(Te.id,S),De(null);},mode:"edit",theme:K}),jsx(AnimatePresence,{children:Ye&&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:()=>mt(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:S=>S.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:Ze.bgSecondary,border:`1px solid ${Ze.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${Ze.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:Ze.textPrimary,fontFamily:"Inter, sans-serif"},children:[se.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:Ze.textSecondary,fontFamily:"Inter, sans-serif"},children:f==="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:Ze.textSecondary,fontFamily:"Inter, sans-serif"},children:[f==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:Ze.textPrimary},children:['"',Ye.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:Ze.bgPrimary,borderTop:`1px solid ${Ze.border}`},children:[jsx("button",{onClick:()=>mt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:Ze.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=Ze.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:f==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{Mr([Ye.taskId]),mt(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),f==="es"?"Eliminar":"Delete"]})]})]})})}),v?.enabled&&jsx(dn,{tasks:I,theme:Ze,config:v,onTasksUpdate:Y,onTaskUpdate:Ra,onTaskCreate:S=>{Y(M=>[...M,S]);},onTaskDelete:S=>{Mr([S]);},onDependencyCreate:(S,M)=>{let j=ie.findTaskById(I,S);j&&zi(j,M);},onDependencyDelete:$i})]})})})});var Od=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
345
345
 
346
346
  AVAILABLE COMMANDS:
347
347
  1. move_task - Move a task to a different date
@@ -382,39 +382,39 @@ Tasks have: id, name, startDate, endDate, progress, status, dependencies[], assi
382
382
 
383
383
  Always try to match task names case-insensitively and handle partial matches.
384
384
  If you can't find a task by name, search through the provided task list.
385
- If ambiguous, ask for clarification in the message field.`;function Bd(e){return `CURRENT TASKS:
386
- ${Rd(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",l=r.dependencies?.length?`deps: [${r.dependencies.join(", ")}]`:"";return `- ${r.id}: "${r.name}" (${o} to ${s}, ${r.progress}%, ${r.status||"todo"}) ${l}`}).join(`
385
+ If ambiguous, ask for clarification in the message field.`;function zd(e){return `CURRENT TASKS:
386
+ ${$d(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",l=r.dependencies?.length?`deps: [${r.dependencies.join(", ")}]`:"";return `- ${r.id}: "${r.name}" (${o} to ${s}, ${r.progress}%, ${r.status||"todo"}) ${l}`}).join(`
387
387
  `)}
388
388
 
389
- Today's date: ${new Date().toISOString().split("T")[0]}`}function Rd(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function Ka(e,t){let a=Rd(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 l=r.split(/\s+/);return a.find(c=>{let p=c.name.toLowerCase();return l.every(n=>p.includes(n))})}function Vs(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 u={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(u!==void 0){let y=new Date(r),f=y.getDay(),g=u-f;return g<=0&&(g+=7),y.setDate(y.getDate()+g),y}}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),u=s[2].toLowerCase(),y=new Date(r);return u==="day"||u==="d\xEDa"||u==="dias"?y.setDate(y.getDate()+i):u==="week"||u==="semana"||u==="semanas"?y.setDate(y.getDate()+i*7):(u==="month"||u==="mes"||u==="meses")&&y.setMonth(y.getMonth()+i),y}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),u=parseInt(c[2],10)-1,y=parseInt(c[3],10);return new Date(y,u,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},n=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(n&&n[1]&&n[2]){let i=parseInt(n[1],10),u=p[n[2].toLowerCase()],y=n[3]?parseInt(n[3],10):r.getFullYear();if(u!==void 0)return new Date(y,u,i)}let m={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=m[d[1].toLowerCase()],u=parseInt(d[2],10),y=d[3]?parseInt(d[3],10):r.getFullYear();if(i!==void 0)return new Date(y,i,u)}return null}function js(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 Ks(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 Od(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 zd(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 n=r[1].trim(),m=r[2].trim(),d=Ka(t,n),i=Vs(m);if(!d)return {type:"move_task",taskName:n,message:`Could not find a task named "${n}". 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 "${m}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let u=d.startDate&&d.endDate?Math.round((d.endDate.getTime()-d.startDate.getTime())/(1e3*60*60*24)):1,y=new Date(i);return y.setDate(y.getDate()+u),{type:"move_task",taskId:d.id,taskName:d.name,updates:{startDate:i,endDate:y},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 n=o[1].trim(),m=o[2].trim(),d=Ka(t,n),i=js(m);if(!d)return {type:"resize_task",taskName:n,message:`Could not find a task named "${n}".`,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 "${m}".`,success:false,error:"Invalid duration"};let u=new Date(d.endDate);return u.setDate(u.getDate()+i),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:u},message:`Extended "${d.name}" by ${i} days. New end date: ${u.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 n=s[1].trim(),m=s[2].trim(),d=Ka(t,n),i=Ks(m);return d?i===null?{type:"set_progress",taskId:d.id,taskName:d.name,message:`Could not parse the progress value "${m}".`,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:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}let l=a.match(/(?:rename|renombrar|cambiar nombre de)\s+["""]?(.+?)["""]?\s+(?:to|a|por)\s+["""]?(.+?)["""]?$/i);if(l&&l[1]&&l[2]){let n=l[1].trim(),m=l[2].trim(),d=Ka(t,n);return d?{type:"rename_task",taskId:d.id,taskName:d.name,updates:{name:m},message:`Renamed "${d.name}" to "${m}".`,success:true}:{type:"rename_task",taskName:n,message:`Could not find a task named "${n}".`,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 n=c[1].trim(),m=c[2].trim(),d=Ka(t,n),i=Ka(t,m);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:m,message:`Could not find a task named "${m}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Source task not found"}}let p=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(p&&p[1]){let n=p[1].trim(),m=Ka(t,n);return m?{type:"delete_task",taskId:m.id,taskName:m.name,message:`Deleted "${m.name}".`,success:true}:{type:"delete_task",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}return null}function $d(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 xf(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 kf(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function un(e,t=[],a=[]){let r=e.assignedUserIds?.map(m=>{let d=a.find(i=>i.id===m);return d?{name:d.name,initials:d.initials,color:d.color}:null}).filter(m=>m!==null),o=t.filter(m=>m.metadata?.parentCardId===e.id).map(m=>un(m,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(m=>m.type==="finish-to-start").map(m=>m.taskId));let l=m=>{if(m)return typeof m=="string"?new Date(m):m},c=l(e.startDate),p=l(e.endDate),n=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:xf(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:n,isCriticalPath:e.metadata?.isCriticalPath===true}}function Ud(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:kf(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function Wd(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>un(r,e,t))}var Ys={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"}},qs={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"}},gn={en:Ys,es:qs};function Xs(e){return gn[e]||gn.en}function fn(e,t){let a=Xs(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 Vd(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(...Vd(r.subtasks,t+1));return a}function If({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 jd({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:l}){let{theme:c="dark",locale:p="en",customTranslations:n,showSearch:m=true,showHierarchy:d=true}=t,i=fn(p,n),u=c==="dark",[y,f]=useState(new Set),[g,x]=useState("startDate"),[b,h]=useState("asc"),[w,D]=useState("");useMemo(()=>{let T=new Set;function k(F){for(let P of F)P.subtasks?.length&&(T.add(P.id),k(P.subtasks));}k(e),f(T);},[e]);let N=useCallback(T=>{f(k=>{let F=new Set(k);return F.has(T)?F.delete(T):F.add(T),F}),a.onTaskToggleExpand?.(T);},[a]),M=useCallback(T=>{g===T?h(k=>k==="asc"?"desc":"asc"):(x(T),h("asc")),a.onSortChange?.({column:T,direction:b==="asc"?"desc":"asc"});},[g,b,a]),v=useMemo(()=>{let T=Vd(e);if(w.trim()){let F=w.toLowerCase();T=T.filter(P=>P.name.toLowerCase().includes(F));}let k=[];for(let F of T){let P=F.level===0;F.level>0&&(P=true),(P||w.trim())&&k.push(F);}return w.trim()&&k.sort((F,P)=>{let H,X;switch(g){case "name":H=F.name.toLowerCase(),X=P.name.toLowerCase();break;case "startDate":H=F.startDate?.getTime()||0,X=P.startDate?.getTime()||0;break;case "endDate":H=F.endDate?.getTime()||0,X=P.endDate?.getTime()||0;break;case "progress":H=F.progress||0,X=P.progress||0;break;case "status":H=F.status||"todo",X=P.status||"todo";break;default:return 0}return H<X?b==="asc"?-1:1:H>X?b==="asc"?1:-1:0}),k},[e,w,g,b]),L=T=>T?(T instanceof Date?T:new Date(T)).toLocaleDateString(p==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[i.empty.noTasks,"..."]})]})}):o?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-lg font-semibold mb-2",u?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-lg font-semibold mb-2",u?"text-white":"text-gray-900"),children:i.empty.noTasks}),jsx("p",{className:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.addFirstTask})]})}):jsxs("div",{className:C("flex-1 flex flex-col w-full h-full overflow-hidden",u?"bg-[#0F1117]":"bg-white",s),style:l,children:[jsx("div",{className:C("flex-shrink-0 px-6 py-4 border-b",u?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[m&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:C("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:w,onChange:T=>D(T.target.value),placeholder:i.toolbar.searchPlaceholder,className:C("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",u?"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:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[v.length," ",i.pagination.tasks]})]})}),jsxs("div",{className:C("flex-shrink-0 grid grid-cols-12 gap-4 px-6 py-3 border-b text-xs font-medium uppercase tracking-wider",u?"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:()=>M("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:()=>M("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:()=>M("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:()=>M("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:()=>M("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:v.map((T,k)=>{let F=y.has(T.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:k*.02},className:C("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",u?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),style:{paddingLeft:d?`${24+T.level*24}px`:void 0},onClick:()=>a.onTaskClick?.(T),onDoubleClick:()=>a.onTaskDoubleClick?.(T),children:[jsxs("div",{className:"col-span-5 flex items-center gap-2 min-w-0",children:[d&&T.hasChildren&&jsx("button",{onClick:P=>{P.stopPropagation(),N(T.id);},className:C("p-0.5 rounded",u?"hover:bg-white/10":"hover:bg-gray-200"),children:F?jsx(ChevronDown,{className:C("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:C("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")})}),d&&!T.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:P=>{P.stopPropagation(),a.onTaskUpdate?.({...T,progress:T.progress===100?0:100,status:T.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(If,{status:T.status,progress:T.progress})}),jsx("span",{className:C("truncate",u?"text-white":"text-gray-900",T.progress===100&&(u?"line-through text-[#6B7280]":"line-through text-gray-400")),children:T.name})]}),jsx("div",{className:"col-span-2 flex items-center",children:jsx("span",{className:C("px-2 py-1 rounded-full text-xs font-medium",T.progress===100||T.status==="completed"?"bg-green-500/10 text-green-500":T.progress&&T.progress>0||T.status==="in-progress"?"bg-blue-500/10 text-blue-500":u?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:T.progress===100||T.status==="completed"?i.status.completed:T.progress&&T.progress>0||T.status==="in-progress"?i.status.inProgress:i.status.todo})}),jsxs("div",{className:C("col-span-2 flex items-center gap-1 text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),L(T.startDate)]}),jsxs("div",{className:C("col-span-2 flex items-center gap-1 text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),L(T.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:C("flex-1 h-1.5 rounded-full overflow-hidden",u?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:C("h-full rounded-full transition-all",T.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${T.progress||0}%`}})}),jsxs("span",{className:C("text-xs w-8",u?"text-[#9CA3AF]":"text-gray-500"),children:[T.progress||0,"%"]})]})})]},T.id)})}),v.length===0&&w&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:C("w-12 h-12 mx-auto mb-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:C(u?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.noResults})]})})]})]})}var Js={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"},Zs={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"},Qs={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:Js,light:Zs,neutral:Qs};function Kd(e){return bn[e]||bn.dark}var ei={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"}},ti={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"}},yn={en:ei,es:ti};function vo(e){return yn[e]||yn.en}function vn(e,t){let a=vo(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 Yd(e){let t=vo(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 qd(e,t=0,a=true){let r=vo(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 Vf(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 si(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 Zd({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 ec({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:l,style:c}){let{theme:p="dark",locale:n="en",customTranslations:m}=t,d=vn(n,m),i=p==="dark",[u,y]=useState(r||new Date),[f,g]=useState(null),[x,b]=useState(null),[h,w]=useState(null),[D,N]=useState(new Date),[M,v]=useState({}),L=4,T=3,[k,F]=useState(false),[P,H]=useState(false),[X$1,ye]=useState(false),[we,Ie]=useState(null),[Le,O]=useState(""),[B,W]=useState(void 0),[S,q]=useState(null),[ee,$]=useState(false),[Me,be]=useState(false),[qe,ue]=useState(null),[Qe,Te]=useState(false),[rt,gt]=useState(new Date),ft=useCallback(()=>{y(new Date(u.getFullYear(),u.getMonth()-1,1));},[u]),et=useCallback(()=>{y(new Date(u.getFullYear(),u.getMonth()+1,1));},[u]),R=useCallback(()=>{y(new Date);},[]),se=useMemo(()=>{let z=u.getFullYear(),ke=u.getMonth(),We=new Date(z,ke,1),Ue=new Date(z,ke+1,0),ht=We.getDay(),Z=Ue.getDate(),te=Vf(e),xe=new Date;xe.setHours(0,0,0,0);let Pe=[],J=ht,Ae=new Date(z,ke,0).getDate();for(let Ne=J-1;Ne>=0;Ne--){let de=new Date(z,ke-1,Ae-Ne);Pe.push({date:de,isCurrentMonth:false,isToday:false,isWeekend:de.getDay()===0||de.getDay()===6,events:te.filter(Re=>si(de,Re)).map(Re=>({id:Re.id,title:Re.name,start:Re.startDate,end:Re.endDate,task:Re}))});}for(let Ne=1;Ne<=Z;Ne++){let de=new Date(z,ke,Ne),Re=de.getTime()===xe.getTime();Pe.push({date:de,isCurrentMonth:true,isToday:Re,isWeekend:de.getDay()===0||de.getDay()===6,events:te.filter(Fe=>si(de,Fe)).map(Fe=>({id:Fe.id,title:Fe.name,start:Fe.startDate,end:Fe.endDate,task:Fe}))});}let he=42-Pe.length;for(let Ne=1;Ne<=he;Ne++){let de=new Date(z,ke+1,Ne);Pe.push({date:de,isCurrentMonth:false,isToday:false,isWeekend:de.getDay()===0||de.getDay()===6,events:te.filter(Re=>si(de,Re)).map(Re=>({id:Re.id,title:Re.name,start:Re.startDate,end:Re.endDate,task:Re}))});}return Pe},[u,e]),ve=n==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],De=u.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),Ee=useCallback((z,ke)=>{if(!f)return;let We={...f,[z]:ke};g(We),a.onTaskUpdate?.(We);},[f,a]),Ve=useCallback(z=>{if(!f)return;let ke=f.progress||0;z==="completed"?ke=100:z==="todo"&&(ke=0);let We={...f,status:z,progress:ke};g(We),a.onTaskUpdate?.(We),F(false);},[f,a]),Ct=useCallback((z,ke)=>{if(!f)return;let We={...f,startDate:z,endDate:ke};g(We),a.onTaskUpdate?.(We);},[f,a]),Y=useCallback(()=>{F(false),H(false),w(null);},[]);return o?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),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:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:[d.labels.noEvents,"..."]})]})}):s?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),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:C("text-lg font-semibold mb-2",i?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),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:C("text-lg font-semibold mb-2",i?"text-white":"text-gray-900"),children:d.labels.noEvents}),jsx("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:d.labels.newTask})]})}):jsxs("div",{className:C("flex-1 flex flex-col w-full h-full overflow-auto",i?"bg-[#0F1117]":"bg-white",l),style:c,children:[jsx("div",{className:C("flex-shrink-0 px-6 py-4 border-b",i?"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:C("text-xl font-semibold capitalize",i?"text-white":"text-gray-900"),children:De}),jsx("button",{onClick:R,className:C("px-3 py-1.5 text-sm rounded-lg transition-colors",i?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:d.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:ft,className:C("p-2 rounded-lg transition-colors",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:C("w-5 h-5",i?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:et,className:C("p-2 rounded-lg transition-colors",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:C("w-5 h-5",i?"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:ve.map(z=>jsx("div",{className:C("py-2 text-center text-xs font-medium uppercase",i?"text-[#9CA3AF]":"text-gray-500"),children:z},z))}),jsx("div",{className:C("grid grid-cols-7 auto-rows-min gap-px rounded-lg",i?"bg-[#2D2D2D]":"bg-gray-300"),children:se.map((z,ke)=>{let We=z.date.getDay()===0||z.date.getDay()===6;return jsxs("div",{className:C("min-h-[120px] p-2 transition-colors flex flex-col relative group",i?We?"bg-[#1C1F26]":z.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":We?"bg-gray-100":z.isCurrentMonth?"bg-white":"bg-gray-50",z.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let Ue=M[ke]||L,ht=z.events.slice(0,Ue),Z=z.events.length-Ue;return jsxs("div",{className:"space-y-1 flex-1",children:[ht.map(te=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{g(te.task),a.onEventClick?.(te);},whileHover:{scale:1.02},className:C("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",te.task.progress===100?i?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":i?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx(Zd,{task:te.task}),jsx("span",{className:"truncate",children:te.title})]})},te.id)),Z>0&&jsxs("button",{onClick:te=>{te.stopPropagation(),v(xe=>({...xe,[ke]:Ue+T}));},className:C("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",i?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",Z," ",n==="es"?"M\xC1S":"MORE"]}),Ue>L&&z.events.length>L&&jsx("button",{onClick:te=>{te.stopPropagation(),v(xe=>({...xe,[ke]:L}));},className:C("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",i?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:n==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let Ue=ke>=28,ht=ke%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:Z=>{Z.stopPropagation(),we===ke?Ie(null):(Ie(ke),O(""),W(void 0),q(null),ue(null),$(false),be(false),Te(false),gt(z.date));},className:C("w-5 h-5 rounded flex items-center justify-center transition-all",we===ke?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",i?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:C("w-3.5 h-3.5 transition-transform",we===ke&&"rotate-45")})}),jsx(AnimatePresence,{children:we===ke&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Ie(null),O(""),W(void 0),q(null),ue(null),$(false),be(false),Te(false);}}),jsxs(motion.div,{initial:{opacity:0,y:Ue?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:Ue?-5:5,scale:.95},transition:{duration:.12},className:C("absolute w-[320px] rounded-lg shadow-2xl z-50",Ue?"bottom-full mb-1":"top-full mt-1",ht?"right-0":"left-0",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Z=>{Z.stopPropagation(),$(false),be(false),Te(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Le,onChange:Z=>O(Z.target.value),placeholder:n==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:C("w-full bg-transparent text-sm outline-none placeholder:opacity-40",i?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:Z=>{if(Z.key==="Enter"&&Le.trim()){let te=t.availableUsers?.find(Pe=>Pe.id===S),xe=qe||z.date;a.onTaskCreate?.({name:Le.trim(),startDate:xe,endDate:xe,priority:B,assignees:te?[te]:void 0}),O(""),W(void 0),q(null),ue(null),Ie(null);}Z.key==="Escape"&&(Ie(null),O(""),W(void 0),q(null),ue(null));}})}),jsxs("div",{className:C("px-2.5 py-2 flex items-center justify-between border-t",i?"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(),$(!ee),be(false);},className:C("p-1 rounded transition-colors",B?B==="urgent"||B==="high"?"text-red-400 bg-red-500/20":B==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":i?"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:ee&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Z=>Z.stopPropagation(),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(Z=>jsxs("button",{onClick:()=>{W(Z.id),$(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",B===Z.id&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",Z.color)}),jsx("span",{className:i?"text-white":"text-gray-900",children:Z.label})]},Z.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:Z=>{Z.stopPropagation(),Te(!Qe),$(false),be(false),gt(qe||z.date);},className:C("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",qe?"bg-[#7C3AED]/20 text-[#7C3AED]":i?"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"}),(qe||z.date).toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:Qe&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Z=>Z.stopPropagation(),children:[jsx("div",{className:C("w-40 py-2 border-r",i?"border-white/10":"border-gray-200"),children:(()=>{let Z=new Date,te=new Date(Z);te.setDate(Z.getDate()+1);let xe=new Date(Z);xe.setDate(Z.getDate()+((6-Z.getDay()+7)%7||7));let Pe=new Date(Z);Pe.setDate(Z.getDate()+((1-Z.getDay()+7)%7||7));let J=new Date(Z);J.setDate(Z.getDate()+14);let Ae=new Date(Z);return Ae.setDate(Z.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:Z,display:Z.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:te,display:te.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:xe,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Pe,display:n==="es"?"lun.":"mon."},{label:n==="es"?"2 semanas":"2 weeks",date:J,display:J.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Ae,display:Ae.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ne,de)=>jsxs("button",{className:C("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",i?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{ue(Ne.date),Te(false);},children:[jsx("span",{children:Ne.label}),jsx("span",{className:C("text-[10px]",i?"text-[#6B7280]":"text-gray-400"),children:Ne.display})]},de))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:C("text-xs font-medium",i?"text-white":"text-gray-900"),children:rt.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>gt(new Date),className:C("px-1.5 py-0.5 rounded text-[10px] transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>gt(new Date(rt.getFullYear(),rt.getMonth()-1)),className:C("p-0.5 rounded",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>gt(new Date(rt.getFullYear(),rt.getMonth()+1)),className:C("p-0.5 rounded",i?"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:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(Z=>jsx("div",{className:C("w-6 h-6 flex items-center justify-center text-[10px]",i?"text-[#6B7280]":"text-gray-400"),children:Z},Z))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let Z=rt.getFullYear(),te=rt.getMonth(),xe=new Date(Z,te,1).getDay(),Pe=new Date(Z,te+1,0).getDate(),J=new Date(Z,te,0).getDate(),Ae=new Date,he=[];for(let de=xe-1;de>=0;de--)he.push({dayNum:J-de,isCurrentMonth:false,date:new Date(Z,te-1,J-de)});for(let de=1;de<=Pe;de++)he.push({dayNum:de,isCurrentMonth:true,date:new Date(Z,te,de)});let Ne=42-he.length;for(let de=1;de<=Ne;de++)he.push({dayNum:de,isCurrentMonth:false,date:new Date(Z,te+1,de)});return he.map((de,Re)=>{let Fe=de.date.toDateString()===Ae.toDateString(),Oe=(qe||z.date).toDateString()===de.date.toDateString();return jsx("button",{className:C("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!de.isCurrentMonth&&(i?"text-[#4B5563]":"text-gray-300"),de.isCurrentMonth&&(i?"text-white":"text-gray-900"),Fe&&"ring-1 ring-[#3B82F6]",Oe&&"bg-[#7C3AED] text-white",!Oe&&(i?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{ue(de.date),Te(false);},children:de.dayNum},Re)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:Z=>{Z.stopPropagation(),be(!Me),$(false);},className:C("p-1 rounded transition-colors",S?"text-[#7C3AED] bg-[#7C3AED]/20":i?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:S?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===S)?.color||"#7C3AED"},children:t.availableUsers?.find(Z=>Z.id===S)?.initials||t.availableUsers?.find(Z=>Z.id===S)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:Me&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:Z=>Z.stopPropagation(),children:[jsxs("button",{onClick:()=>{q(null),be(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",!S&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:C("w-5 h-5 rounded-full flex items-center justify-center",i?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:i?"text-[#9CA3AF]":"text-gray-500",children:n==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(Z=>jsxs("button",{onClick:()=>{q(Z.id),be(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",S===Z.id&&(i?"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:i?"text-white":"text-gray-900",children:Z.name})]},Z.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:C("px-3 py-2 text-xs",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Le.trim()){let Z=t.availableUsers?.find(xe=>xe.id===S),te=qe||z.date;a.onTaskCreate?.({name:Le.trim(),startDate:te,endDate:te,priority:B,assignees:Z?[Z]:void 0}),O(""),W(void 0),q(null),ue(null),Ie(null);}},disabled:!Le.trim(),className:C("px-2.5 py-1 rounded text-xs font-medium transition-colors",Le.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":i?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:n==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:C("text-sm font-medium",z.isToday?"text-[#3B82F6]":z.isCurrentMonth?i?"text-white":"text-gray-900":i?"text-[#6B7280]":"text-gray-400"),children:z.date.getDate()})]})]},ke)})})]})}),jsx(AnimatePresence,{children:f&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>g(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:C("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",i?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:C("px-6 py-3 border-b flex items-center gap-3",i?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:C("w-4 h-4",i?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:C("text-xs px-2 py-0.5 rounded",i?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:C("text-xs font-mono",i?"text-[#6B7280]":"text-gray-400"),children:f.id.slice(0,8)}),jsxs("button",{className:C("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",i?"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:C("p-1.5 rounded transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:C("p-1.5 rounded transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>g(null),className:C("p-1.5 rounded transition-colors",i?"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 z=f.progress===100?0:100,We={...f,progress:z,status:z===100?"completed":"todo"};g(We),a.onTaskUpdate?.(We);},className:C("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",f.progress===100?"bg-green-500 border-green-500":i?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:f.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:C("text-xl font-semibold flex-1",f.progress===100?"line-through text-[#6B7280]":i?"text-white":"text-gray-900"),children:f.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:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{Y(),F(!k);},className:C("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",f.progress===100||f.status==="completed"?"bg-green-500/20 text-green-400":f.progress&&f.progress>0||f.status==="in-progress"?"bg-blue-500/20 text-blue-400":i?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:f.progress===100||f.status==="completed"?n==="es"?"COMPLETADO":"DONE":f.progress&&f.progress>0||f.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:k&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>F(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:n==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:n==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:n==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(z=>jsxs("button",{onClick:()=>Ve(z.id),className:C("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",(f.status===z.id||z.id==="completed"&&f.progress===100||z.id==="in-progress"&&f.progress&&f.progress>0&&f.progress<100||z.id==="todo"&&(!f.progress||f.progress===0)&&f.status!=="in-progress"&&f.status!=="completed")&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",z.id==="completed"?"bg-green-500":z.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:i?"text-white":"text-gray-900",children:z.label})]},z.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(User,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),f.assignees&&f.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[f.assignees.slice(0,3).map((z,ke)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:z.color||"#8B5CF6"},title:z.name,children:z.initials||z.name.slice(0,2).toUpperCase()},ke)),f.assignees.length>3&&jsxs("span",{className:C("text-xs",i?"text-[#6B7280]":"text-gray-400"),children:["+",f.assignees.length-3]})]}):jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Sin asignar":"Unassigned"})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{w(h?null:"start"),N(f.startDate||new Date);},className:C("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",i?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[f.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:C("mx-1",i?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),f.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End"),(f.startDate||f.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:z=>{z.stopPropagation();}})]}),jsx(AnimatePresence,{children:h&&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:C("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:z=>z.stopPropagation(),children:[jsxs("div",{className:C("w-44 py-2 border-r",i?"border-white/10":"border-gray-200"),children:[(()=>{let z=new Date,ke=new Date(z);ke.setDate(z.getDate()+1);let We=new Date(z);We.setDate(z.getDate()+((6-z.getDay()+7)%7||7));let Ue=new Date(z);Ue.setDate(z.getDate()+((1-z.getDay()+7)%7||7));let ht=new Date(z);ht.setDate(z.getDate()+(6-z.getDay()+7)%7+7);let Z=new Date(z);Z.setDate(z.getDate()+14);let te=new Date(z);return te.setDate(z.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:z,display:z.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:ke,display:ke.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:We,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Ue,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:ht,display:ht.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:Z,display:Z.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:te,display:te.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Pe,J)=>jsxs("button",{className:C("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",i?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(h==="start"){let Ae=f.endDate&&Pe.date>f.endDate?Pe.date:f.endDate;Ct(Pe.date,Ae),w("end");}else {let Ae=f.startDate&&Pe.date<f.startDate?Pe.date:f.startDate;Ct(Ae,Pe.date),w(null);}},children:[jsx("span",{children:Pe.label}),jsx("span",{className:C("text-xs",i?"text-[#6B7280]":"text-gray-400"),children:Pe.display})]},J))})(),jsx("div",{className:C("border-t mt-2 pt-2",i?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{Ct(void 0,void 0),w(null);},className:C("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",i?"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:C("text-xs mb-3 px-2 py-1 rounded",i?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:h==="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:C("font-medium",i?"text-white":"text-gray-900"),children:D.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>N(new Date),className:C("p-1 rounded text-sm transition-colors",i?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>N(new Date(D.getFullYear(),D.getMonth()-1)),className:C("p-1 rounded",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>N(new Date(D.getFullYear(),D.getMonth()+1)),className:C("p-1 rounded",i?"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:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(z=>jsx("div",{className:C("w-8 h-8 flex items-center justify-center text-xs",i?"text-[#6B7280]":"text-gray-400"),children:z},z))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let z=D.getFullYear(),ke=D.getMonth(),We=new Date(z,ke,1).getDay(),Ue=new Date(z,ke+1,0).getDate(),ht=new Date(z,ke,0).getDate(),Z=new Date,te=[];for(let Pe=We-1;Pe>=0;Pe--)te.push({day:ht-Pe,isCurrentMonth:false,date:new Date(z,ke-1,ht-Pe)});for(let Pe=1;Pe<=Ue;Pe++)te.push({day:Pe,isCurrentMonth:true,date:new Date(z,ke,Pe)});let xe=42-te.length;for(let Pe=1;Pe<=xe;Pe++)te.push({day:Pe,isCurrentMonth:false,date:new Date(z,ke+1,Pe)});return te.map((Pe,J)=>{let Ae=Pe.date.toDateString()===Z.toDateString(),he=f.startDate?.toDateString()===Pe.date.toDateString(),Ne=f.endDate?.toDateString()===Pe.date.toDateString(),de=he||Ne,Re=f.startDate&&f.endDate&&Pe.date>=f.startDate&&Pe.date<=f.endDate;return jsx("button",{className:C("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Pe.isCurrentMonth&&(i?"text-[#4B5563]":"text-gray-300"),Pe.isCurrentMonth&&(i?"text-white":"text-gray-900"),Ae&&"ring-2 ring-[#3B82F6]",he&&"bg-[#3B82F6] text-white",Ne&&!he&&"bg-[#7C3AED] text-white",Re&&!de&&(i?"bg-[#7C3AED]/20":"bg-purple-100"),!de&&(i?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let Fe=new Date(Pe.date);if(h==="start"){let Oe=f.endDate&&Fe>f.endDate?Fe:f.endDate;Ct(Fe,Oe),w("end");}else {let Oe=f.startDate&&Fe<f.startDate?Fe:f.startDate;Ct(Oe,Fe),w(null);}},children:Pe.day},J)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{Y(),H(!P);},className:C("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",f.priority==="high"||f.priority==="urgent"?"bg-red-500/20 text-red-400":f.priority==="medium"?"bg-yellow-500/20 text-yellow-400":f.priority==="low"?"bg-green-500/20 text-green-400":i?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:f.priority?f.priority==="high"||f.priority==="urgent"?n==="es"?"Urgente":"Urgent":f.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:P&&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:C("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",i?"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(z=>jsxs("button",{onClick:()=>{Ee("priority",z.id),H(false);},className:C("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",f.priority===z.id&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",z.color)}),jsx("span",{className:i?"text-white":"text-gray-900",children:z.label})]},z.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:C("text-sm",i?"text-white":"text-gray-900"),children:f.startDate&&f.endDate?`${Math.ceil((f.endDate.getTime()-f.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:C("w-4 h-4 rounded-full border-2",i?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[X$1?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:f.progress||0,onChange:z=>{let ke=parseInt(z.target.value),We=f.status;ke===100?We="completed":ke>0?We="in-progress":We="todo";let Ue={...f,progress:ke,status:We};g(Ue),a.onTaskUpdate?.(Ue);},onBlur:()=>ye(false),className:C("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",i?"bg-white/10":"bg-gray-200","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#3B82F6] [&::-webkit-slider-thumb]:cursor-pointer"),autoFocus:true}):jsx("button",{onClick:()=>ye(true),className:C("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",i?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:C("h-full rounded-full transition-all",f.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${f.progress||0}%`}})}),jsxs("span",{className:C("text-sm font-medium min-w-[40px]",i?"text-white":"text-gray-900"),children:[f.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Vac\xEDo":"Empty"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Link2,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:f.dependencies&&f.dependencies.length>0?`${f.dependencies.length} ${n==="es"?"dependencias":"dependencies"}`:n==="es"?"Vac\xEDo":"Empty"})]})]}),jsxs("div",{className:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsxs("button",{className:C("flex items-center gap-2 text-sm transition-colors",i?"text-[#9CA3AF] hover:text-white":"text-gray-500 hover:text-gray-900"),children:[jsx(FileText,{className:"w-4 h-4"}),n==="es"?"Agregar descripci\xF3n":"Add description"]}),jsxs("button",{className:C("flex items-center gap-2 text-sm mt-2 transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Agregar subtarea":"Add subtask"}),f.subtasks&&f.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:f.subtasks.map(z=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:C("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",z.progress===100?"bg-green-500 border-green-500":i?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:z.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:C("text-sm",z.progress===100?"line-through text-[#6B7280]":i?"text-white":"text-gray-900"),children:z.name})]},z.id))}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:C("text-sm font-semibold",i?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:C("p-1 rounded transition-colors",i?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Adjuntos":"Attachments"}),jsxs("div",{className:C("border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer",i?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300"),children:[jsx(Upload,{className:C("w-6 h-6 mx-auto mb-2",i?"text-[#6B7280]":"text-gray-400")}),jsxs("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-500"),children:[n==="es"?"Suelta tus archivos aqu\xED para ":"Drop your files here to ",jsx("span",{className:C("underline",i?"text-white":"text-gray-700"),children:n==="es"?"subir":"upload"})]})]})]})]})]}),jsxs("div",{className:C("w-[280px] border-l flex flex-col",i?"border-white/10 bg-[#141619]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:C("px-4 py-3 border-b flex items-center justify-between",i?"border-white/10":"border-gray-200"),children:jsx("span",{className:C("font-medium",i?"text-white":"text-gray-900"),children:n==="es"?"Actividad":"Activity"})}),jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:jsxs("div",{className:C("text-sm text-center py-8",i?"text-[#6B7280]":"text-gray-400"),children:[jsx(MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),n==="es"?"Sin actividad reciente":"No recent activity"]})}),jsx("div",{className:C("p-3 border-t",i?"border-white/10":"border-gray-200"),children:jsx("div",{className:C("flex items-center gap-2 px-3 py-2 rounded-lg",i?"bg-white/5":"bg-white border border-gray-200"),children:jsx("input",{type:"text",placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",className:C("flex-1 bg-transparent text-sm outline-none",i?"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:()=>b(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:C("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",i?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:C("px-4 py-3 border-b flex items-center justify-between",i?"border-white/10":"border-gray-200"),children:[jsx("span",{className:C("font-medium",i?"text-white":"text-gray-900"),children:x.date.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>b(null),className:C("p-1 rounded",i?"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(z=>jsxs("button",{onClick:()=>{b(null),g(z.task);},className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",i?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx(Zd,{task:z.task}),jsx("span",{className:C("text-sm truncate flex-1",i?"text-white":"text-gray-900"),children:z.title}),z.task.priority==="high"||z.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},z.id))})]})]})})]})}var ii={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"},li={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"},di={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"},Cn={dark:ii,light:li,neutral:di};function tc(e){return Cn[e]||Cn.dark}function Kf({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:l,className:c}){let[p,n]=useState(false),m=useMemo(()=>t.filter(u=>e.cardIds.includes(u.id)),[t,e.cardIds]),d=useMemo(()=>{let u=m.length,y=new Set(m.flatMap(x=>x.assignedUserIds||[])).size,f=m.map(x=>x.priority).filter(Boolean),g=new Set(m.flatMap(x=>x.labels||[])).size;return {totalCards:u,uniqueAssignees:y,priorities:f,labels:g}},[m]),i=()=>{o?.(e.id);};return jsxs("div",{className:C("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>n(true),onMouseLeave:()=>n(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:C("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:u=>{u.stopPropagation(),l?.(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:m.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:m.map(u=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(u),children:a(u)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(u),children:[jsx("h4",{children:u.title}),u.description&&jsxs("p",{children:[u.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:y=>{y.stopPropagation(),s?.(e.id,u.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"})]})})]},u.id))})})]})}var rc={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function xo(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 ko(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 oc(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 nc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:l,className:c}){let p=useMemo(()=>({...rc,...l}),[l]),[n,m]=useState(new Set),d=useRef(null),i=useMemo(()=>{if(!p.groupByDay)return [{date:null,events:e}];let b=new Map;return e.forEach(h=>{let w=h.timestamp.toISOString().split("T")[0],D=b.get(w);D?D.push(h):b.set(w,[h]);}),Array.from(b.entries()).sort((h,w)=>w[0].localeCompare(h[0])).map(([h,w])=>({date:new Date(h),events:w.sort((D,N)=>N.timestamp.getTime()-D.timestamp.getTime())}))},[e,p.groupByDay]),{uniqueUsers:u,uniqueTypes:y}=useMemo(()=>{let b=new Set,h=new Set;return e.forEach(w=>{b.add(w.userId),h.add(w.type);}),{uniqueUsers:Array.from(b),uniqueTypes:Array.from(h)}},[e]),f=b=>{m(h=>{let w=new Set(h);return w.has(b)?w.delete(b):w.add(b),w});},g=b=>{let w=new Date().getTime()-b.getTime(),D=Math.floor(w/6e4),N=Math.floor(w/36e5),M=Math.floor(w/864e5);return D<1?"just now":D<60?`${D}m ago`:N<24?`${N}h ago`:M<7?`${M}d ago`:b.toLocaleDateString()},x=useMemo(()=>{let b=0;return t.types&&t.types.length>0&&b++,t.users&&t.users.length>0&&b++,t.dateRange&&b++,t.searchTerm&&b++,b},[t]);return useEffect(()=>{if(s&&d.current){let b=d.current.querySelector(`[data-event-id="${s}"]`);b&&b.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:C("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:C("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:b=>{let h=b.target.value;a({...t,types:h?[h]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),y.map(b=>jsxs("option",{value:b,children:[ko(b)," ",b.replace("_"," ")]},b))]}),u.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:b=>{let h=b.target.value;a({...t,users:h?[h]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),u.map(b=>jsx("option",{value:b,children:b},b))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:b=>a({...t,searchTerm:b.target.value})})]}),x>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",x,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:i.map(b=>jsxs("div",{className:"history-timeline-group",children:[p.groupByDay&&b.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:b.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[b.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:b.events.map((h,w)=>{let D=n.has(h.id),N=s===h.id,M=oc(h.type);return jsxs("div",{"data-event-id":h.id,className:C("history-timeline-event",D&&"expanded",N&&"selected"),onClick:()=>o?.(h),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:M},children:p.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:ko(h.type)})}),w<b.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:M}})]}),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&&h.userAvatar&&jsx("img",{src:h.userAvatar,alt:h.userName||h.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:h.userName||h.userId}),jsx("span",{className:"history-timeline-event-action",children:xo(h)})]})]}),jsx("div",{className:"history-timeline-event-time",children:p.useRelativeTime?g(h.timestamp):h.timestamp.toLocaleString()})]}),Object.keys(h.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:v=>{v.stopPropagation(),f(h.id);},children:[D?"\u25BC":"\u25B6"," Show changes"]}),D&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(h.changes).map(([v,L])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[v,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(L.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(L.to)})]})]},v)),h.metadata&&Object.keys(h.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(h.metadata).map(([v,L])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[v,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(L)})]},v))]})]})]})]},h.id)})})]},b.date?.toISOString()||"all"))})]})}function ic({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:l,onGoToEvent:c,onSpeedChange:p,className:n}){let m=[.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:C("history-replay-empty",n),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:C("history-replay",n),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:d&&ko(d.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:d&&xo(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:u=>c(parseInt(u.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${i}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((u,y)=>jsx("div",{className:C("history-replay-progress-marker",y===e.currentIndex&&"active"),style:{left:`${y/(e.totalEvents-1)*100}%`},onClick:()=>c(y),title:xo(u)},u.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:l,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:m.map(u=>jsxs("button",{className:C("history-replay-speed-btn",e.speed===u&&"active"),onClick:()=>p(u),children:[u,"x"]},u))})]}),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(u=>jsx("span",{className:"history-replay-card-preview-label-tag",children:u},u))})]})]})]})]}):jsxs("div",{className:C("history-replay-start",n),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 ci(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 pi(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 lc(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 dc(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function Qf(e,t,a,r,o,s=100){let l=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(l.map(p=>[p.id,p]));for(let p=0;p<s;p++){let n=1-p/s;l.forEach(m=>{let d=a/2,i=r/2;m.vx+=(d-m.x)*o.centerForce*n,m.vy+=(i-m.y)*o.centerForce*n,l.forEach(u=>{if(m.id===u.id)return;let y=m.x-u.x,f=m.y-u.y,g=Math.sqrt(y*y+f*f)||1,x=o.chargeStrength*n/(g*g);m.vx+=y/g*x,m.vy+=f/g*x;});}),t.forEach(m=>{let d=c.get(typeof m.source=="string"?m.source:m.source.id),i=c.get(typeof m.target=="string"?m.target:m.target.id);if(!d||!i)return;let u=i.x-d.x,y=i.y-d.y,f=Math.sqrt(u*u+y*y)||1,g=(f-o.linkDistance)/f*o.forceStrength*n;d.vx+=u*g,d.vy+=y*g,i.vx-=u*g,i.vy-=y*g;}),l.forEach(m=>{m.fx!==null&&m.fx!==void 0?(m.x=m.fx,m.vx=0):m.x+=m.vx,m.fy!==null&&m.fy!==void 0?(m.y=m.fy,m.vy=0):m.y+=m.vy,m.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,m.x)),m.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,m.y)),m.vx*=.9,m.vy*=.9;});}return l}function cc({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:l,onInteraction:c,className:p}){let n=useRef(null),[m,d]=useState([]),[i,u]=useState(null),[y,f]=useState(null),[g,x]=useState(null),[b,h]=useState(1),[w,D]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let P=Qf(e,t,a.width,a.height,a,150);d(P);},[e,t,a]);let N=useCallback((P,H)=>{a.enableDragging&&(H.stopPropagation(),u(P));},[a.enableDragging]),M=useCallback(P=>{if(!i||!n.current)return;let X=n.current.getBoundingClientRect(),ye=(P.clientX-X.left-w.x)/b,we=(P.clientY-X.top-w.y)/b;d(Ie=>Ie.map(Le=>Le.id===i?{...Le,x:ye,y:we,fx:ye,fy:we}:Le));},[i,b,w]),v=useCallback(()=>{u(null);},[]),L=useCallback((P,H)=>{H.stopPropagation(),c?.({type:"node-click",node:P,position:{x:H.clientX,y:H.clientY}});},[c]),T=useCallback((P,H)=>{H.stopPropagation(),c?.({type:"edge-click",edge:P,position:{x:H.clientX,y:H.clientY}});},[c]),k=useCallback(P=>{let H=m.find(X=>X.id===P);return H?{x:H.x,y:H.y}:{x:0,y:0}},[m]),F=useCallback(P=>{if(P.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return P.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let H=P.card.priority;return H==="URGENT"?"#ef4444":H==="HIGH"?"#f59e0b":H==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return P.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:C("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:C("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:l.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:l.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:()=>h(P=>Math.min(P+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(b*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>h(P=>Math.max(P-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{h(1),D({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(P=>P.type))).map(P=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:ci(P)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[lc(P)," ",pi(P)]})]},P))}),jsxs("svg",{ref:n,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:M,onMouseUp:v,onMouseLeave:v,children:[jsxs("g",{transform:`translate(${w.x}, ${w.y}) scale(${b})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(P=>{let H=k(typeof P.source=="string"?P.source:P.source.id),X=k(typeof P.target=="string"?P.target:P.target.id),ye=dc(P.type),we=g===P.id,Ie=P.onCriticalPath;return jsxs("g",{className:C("relationships-graph-edge",we&&"hovered",Ie&&"critical"),onMouseEnter:()=>x(P.id),onMouseLeave:()=>x(null),onClick:Le=>T(P,Le),children:[jsx("line",{x1:H.x,y1:H.y,x2:X.x,y2:X.y,stroke:ci(P.type),strokeWidth:Ie?a.edgeWidth*2:a.edgeWidth,strokeOpacity:we?1:.6,markerEnd:ye?"url(#arrowhead)":void 0}),a.showEdgeLabels&&we&&jsx("text",{x:(H.x+X.x)/2,y:(H.y+X.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:pi(P.type)})]},P.id)})}),jsx("g",{className:"relationships-graph-nodes",children:m.map(P=>{let H=y===P.id,X=P.onCriticalPath;return jsxs("g",{className:C("relationships-graph-node",H&&"hovered",X&&"critical"),transform:`translate(${P.x}, ${P.y})`,onMouseDown:ye=>N(P.id,ye),onMouseEnter:()=>f(P.id),onMouseLeave:()=>f(null),onClick:ye=>L(P,ye),children:[jsx("circle",{r:X?a.nodeSize*1.2:a.nodeSize,fill:F(P),stroke:X?"#fbbf24":"#ffffff",strokeWidth:X?3:2,opacity:H?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:P.card.title.length>20?P.card.title.substring(0,20)+"...":P.card.title})]},P.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 uc({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,l]=useState(""),[c,p]=useState(false),[n,m]=useState(null),[d,i]=useState(null),u=useRef(null),y=c||o;useEffect(()=>{e&&u.current&&u.current.focus();},[e]),useEffect(()=>{let b=h=>{h.key==="Escape"&&!y&&f();};if(e)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,y]);let f=()=>{y||(l(""),m(null),i(null),t());},g=async()=>{if(!(!s.trim()||y)){p(true),m(null),i(null);try{let b=await r(s.trim());i(b);}catch(b){m(b instanceof Error?b.message:"Failed to generate plan");}finally{p(false);}}},x=()=>{d&&(a(d),f());};return e?jsxs(tt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:f}),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:b=>b.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:f,disabled:y,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((b,h)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:b.title},h))})]}),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((b,h)=>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:b.title}),b.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:b.description})]}),b.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${b.priority==="URGENT"?"bg-red-500/20 text-red-400":b.priority==="HIGH"?"bg-orange-500/20 text-orange-400":b.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:b.priority})]})},h)),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:u,value:s,onChange:b=>l(b.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:y}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),n&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:n}),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((b,h)=>jsx("button",{onClick:()=>l(b),disabled:y,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:b},h))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:y&&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:f,disabled:y,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:x,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:g,disabled:!s.trim()||y,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:y?"Generating...":"Generate Plan"})]})]})]})})]}):null}var mi={"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 th={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},ah={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 rh(e,t,a){let r=mi[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 ui=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=rh(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),l=a.reduce((d,i)=>d+i.outputTokens,0),c=a.filter(d=>d.success),p=a.reduce((d,i)=>d+i.duration,0),n={},m={};return a.forEach(d=>{n[d.feature]=(n[d.feature]||0)+1,m[d.feature]=(m[d.feature]||0)+d.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:l,operationsByFeature:n,costsByFeature:m,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,l=new Date;a==="month"?l.setMonth(s.getMonth()-1):l.setDate(s.getDate()-1);let c=this.operations.filter(m=>m.timestamp>=l).length,p=Math.max(0,o-c),n=c/o*100;return {used:c,limit:o,remaining:p,percentUsed:n,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)}},Cr=new ui;function hc({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(Cr.getStats()),[s,l]=useState(Cr.checkLimit(a));if(useEffect(()=>{if(!e)return;let p=setInterval(()=>{o(Cr.getStats()),l(Cr.checkLimit(a));},1e3);return ()=>clearInterval(p)},[e,a]),useEffect(()=>{let p=n=>{n.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,t]),!e)return null;let c=Cr.getRecentOperations(5);return jsxs(tt,{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,n])=>{let m=r.costsByFeature[p]||0,d=r.totalOperations>0?n/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:[n," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:wo(m)})]})]}),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 vc({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[l,c]=useState(""),[p,n]=useState(""),[m,d]=useState(""),[i,u]=useState(false),[y,f]=useState(null),[g,x]=useState(null),[b,h]=useState(null),w=useRef(null),D=i||o;useEffect(()=>{e&&w.current&&w.current.focus();},[e]),useEffect(()=>{let T=k=>{k.key==="Escape"&&!D&&N();};if(e)return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[e,D]);let N=()=>{D||(c(""),n(""),d(""),f(null),x(null),h(null),t());},M=async()=>{if(!(!l.trim()||D)){u(true),f(null),x(null),h(null);try{let T=await r({prompt:l.trim(),projectName:s||"Mi Proyecto",startDate:p||void 0,endDate:m||void 0});x(T.tasks.tasks),h({from_cache:T.from_cache,tokens_used:T.tokens_used,mock_mode:T.mock_mode,similarity:T.similarity,tokens_saved:T.tokens_saved});}catch(T){f(T instanceof Error?T.message:"Failed to generate tasks");}finally{u(false);}}},v=()=>{g&&(a(g),N());};if(!e)return null;let L=b?.similarity?((b.similarity||0)*100).toFixed(0):"0";return jsxs(tt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:N}),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:T=>T.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:N,disabled:D,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:g?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:[b?.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"}),b?.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 (",L,"% 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:[b?.tokens_used||0," tokens"]}),b?.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:[b.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:[g.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:g.map((T,k)=>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:["#",k+1]}),jsx("p",{className:"text-sm font-medium text-white/90",children:T.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"})]}),T.start," \u2192 ",T.end]}),jsxs("span",{children:[T.duration," days"]}),T.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",T.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${T.priority==="high"?"bg-red-500/20 text-red-400":T.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:T.priority})]})},T.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:w,value:l,onChange:T=>c(T.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:D}),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:T=>n(T.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:D})]}),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:m,onChange:T=>d(T.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:D})]})]}),y&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:y}),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((T,k)=>jsx("button",{onClick:()=>c(T),disabled:D,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:T},k))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:D&&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:N,disabled:D,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"}),g?jsx("button",{onClick:v,className:"px-6 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #10B981 0%, #059669 100%)",color:"#ffffff"},children:"Apply Tasks to Gantt"}):jsx("button",{onClick:M,disabled:!l.trim()||D,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:D?"Generating...":"Generate Tasks"})]})]})]})})]})}function Nn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(g=>{t&&Io(()=>Promise.resolve(t(g)),{maxAttempts:3,initialDelay:1e3,onRetry:(x,b,h)=>{console.warn(`Retry attempt ${b} after ${h}ms: ${x.message}`);}}).then(x=>{x.success||console.error(`Failed to persist board after ${x.attempts} attempts:`,x.error);});},[t]),s=useCallback(async(g,x,b)=>{r(h=>{let w=h.cards.find(T=>T.id===g);if(!w)return h;let D=w.columnId,N={...w,columnId:x,position:b},M=h.cards.map(T=>T.id===g?N:T),v=h.columns.map(T=>{if(T.id===D)return {...T,cardIds:T.cardIds.filter(k=>k!==g)};if(T.id===x){let k=M.filter(F=>F.columnId===x).sort((F,P)=>F.position-P.position);return {...T,cardIds:k.map(F=>F.id)}}return T}),L={...h,cards:M,columns:v};return o(L),L});},[o]),l=useCallback(async(g,x)=>{r(b=>{let h=b.cards.map(D=>D.id===g?{...D,...x}:D),w={...b,cards:h};return o(w),w});},[o]),c=useCallback(async g=>{let x=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(b=>{let h={...g,id:x},w=b.columns.map(N=>N.id===g.columnId?{...N,cardIds:[...N.cardIds,x]}:N),D={...b,cards:[...b.cards,h],columns:w};return o(D),D});},[o]),p=useCallback(async g=>{r(x=>{let b=x.cards.find(N=>N.id===g);if(!b)return x;let h=x.cards.filter(N=>N.id!==g),w=x.columns.map(N=>N.id===b.columnId?{...N,cardIds:N.cardIds.filter(M=>M!==g)}:N),D={...x,cards:h,columns:w};return o(D),D});},[o]),n=useCallback(async g=>{let x=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(b=>{let h={...g,id:x,cardIds:[]},w={...b,columns:[...b.columns,h]};return o(w),w});},[o]),m=useCallback(async(g,x)=>{r(b=>{let h=b.columns.map(D=>D.id===g?{...D,...x}:D),w={...b,columns:h};return o(w),w});},[o]),d=useCallback(async g=>{r(x=>{let b=x.cards.filter(D=>D.columnId!==g),h=x.columns.filter(D=>D.id!==g),w={...x,cards:b,columns:h};return o(w),w});},[o]),i=useCallback(g=>{let x=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(g),x},[c]),u=useCallback(g=>{let x=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return n(g),x},[n]),y=useCallback(()=>{r(g=>{let x={...g,cards:[],columns:[]};return o(x),x});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:l,onCardCreate:c,onCardDelete:p,onColumnCreate:n,onColumnUpdate:m,onColumnDelete:d},setBoard:r,helpers:{addCard:i,addColumn:u,deleteCard:p,deleteColumn:d,clearBoard:y}}}function kc({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=Nn({initialBoard:e,onPersist:a}),l=useMemo(()=>({addCard:(p,n,m={})=>{s.addCard({title:n,columnId:p,position:r.cards.filter(d=>d.columnId===p).length,...m});},addColumn:(p,n)=>{let m=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:p,position:n??m+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:l}}var Co={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},Cc={by:"none",order:"asc"};function Tc({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...Co,...e}),[s,l]=useState({...Cc,...t}),c=useCallback(f=>{o(g=>({...g,...f}));},[]),p=useCallback(f=>{l(g=>({...g,...f}));},[]),n=useCallback(()=>{o(Co),l(Cc);},[]),m=useCallback(()=>{a&&o({...Co,assignees:[a]});},[a]),d=useCallback(()=>{o({...Co,dateFilter:"overdue"});},[]),i=useCallback(()=>{o({...Co,priorities:["HIGH","URGENT"]});},[]),u=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]),y=useCallback(f=>{let g=[...f];if(r.search){let x=r.search.toLowerCase();g=g.filter(b=>b.title.toLowerCase().includes(x)||b.description?.toLowerCase().includes(x));}if(r.dateFilter!=="all"){let x=new Date,b=x.getFullYear(),h=String(x.getMonth()+1).padStart(2,"0"),w=String(x.getDate()).padStart(2,"0"),D=`${b}-${h}-${w}`;g=g.filter(N=>{if(!N.endDate&&!N.dueDate)return false;let M=N.endDate||N.dueDate;if(!M)return false;let v;if(typeof M=="string")v=M.split("T")[0]||M;else {let L=M.getUTCFullYear(),T=String(M.getUTCMonth()+1).padStart(2,"0"),k=String(M.getUTCDate()).padStart(2,"0");v=`${L}-${T}-${k}`;}switch(r.dateFilter){case "overdue":return v<D;case "today":return v===D;case "this-week":let L=new Date(D+"T00:00:00"),T=new Date(v+"T00:00:00"),k=new Date(L);return k.setDate(k.getDate()+7),T>=L&&T<=k;case "custom":if(r.dateRange){let F=typeof M=="string"?new Date(M):M;return F>=r.dateRange.start&&F<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(g=g.filter(x=>x.priority&&r.priorities.includes(x.priority))),r.assignees.length>0&&(g=g.filter(x=>(x.assignedUserIds||(x.assigneeId?[x.assigneeId]:[])).some(h=>r.assignees.includes(h)))),r.labels.length>0&&(g=g.filter(x=>x.labels&&x.labels.some(b=>r.labels.includes(b)))),r.columns.length>0&&(g=g.filter(x=>r.columns.includes(x.columnId))),s.by!=="none"&&g.sort((x,b)=>{let h=0;switch(s.by){case "created":let w=x.createdAt?new Date(x.createdAt).getTime():0,D=b.createdAt?new Date(b.createdAt).getTime():0;h=w-D;break;case "priority":let N={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},M=N[x.priority||"LOW"],v=N[b.priority||"LOW"];h=M-v;break;case "dueDate":let L=x.endDate||x.dueDate,T=b.endDate||b.dueDate;if(!L)return 1;if(!T)return -1;let k=typeof L=="string"?new Date(L).getTime():L.getTime(),F=typeof T=="string"?new Date(T).getTime():T.getTime();h=k-F;break;case "title":h=x.title.localeCompare(b.title);break;case "estimate":let P=x.estimatedTime||0,H=b.estimatedTime||0;h=P-H;break;default:h=0;}return s.order==="asc"?h:-h}),g},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:p,resetFilters:n,filterMyTasks:m,filterOverdue:d,filterHighPriority:i,applyFilters:y,hasActiveFilters:u}}var Nc,Sc;if(typeof window<"u")try{let e=Po("ai");Nc=e.generateObject,Sc=e.generateText;}catch{}function Ec(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(Nc&&Sc&&e.apiKey),l=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 u=i instanceof Error?i:new Error("Failed to generate plan");throw o(u),u}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 u=i instanceof Error?i:new Error("Failed to suggest assignee");throw o(u),u}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 u=i instanceof Error?i:new Error("Failed to predict risks");throw o(u),u}finally{a(false);}},[s]),n=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 u=i instanceof Error?i:new Error("Failed to generate subtasks");throw o(u),u}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("Estimating effort for:",d.title),{hours:8,confidence:.75}}catch(i){let u=i instanceof Error?i:new Error("Failed to estimate effort");throw o(u),u}finally{a(false);}},[s]);return {onGeneratePlan:l,onSuggestAssignee:c,onPredictRisks:p,onGenerateSubtasks:n,onEstimateEffort:m,isAvailable:s,isLoading:t,error:r}}function fi(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function Pc(e){let{cards:t}=e,[a,r]=fi(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,i)=>{if(!i){r({selectedCardIds:[d],lastSelectedCardId:d});return}let u=i.ctrlKey||i.metaKey,y=i.shiftKey;if(u)a.selectedCardIds.includes(d)?r({selectedCardIds:a.selectedCardIds.filter(f=>f!==d),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});else if(y&&a.lastSelectedCardId){let f=t.find(x=>x.id===d),g=t.find(x=>x.id===a.lastSelectedCardId);if(f&&g&&f.columnId===g.columnId){let x=t.filter(v=>v.columnId===f.columnId).sort((v,L)=>v.position-L.position),b=x.findIndex(v=>v.id===a.lastSelectedCardId),h=x.findIndex(v=>v.id===d),[w,D]=b<h?[b,h]:[h,b],N=x.slice(w,D+1).map(v=>v.id),M=Array.from(new Set([...a.selectedCardIds,...N]));r({selectedCardIds:M,lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});},[t,a,r]),l=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]),n=useCallback(d=>{a.selectedCardIds.includes(d)?l(d):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});},[a,l,r]),m=useCallback(()=>t.filter(d=>a.selectedCardIds.includes(d.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:l,clearSelection:c,selectAll:p,toggleCard:n,getSelectedCards:m}}var Mc={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function Ac(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...Mc,...a}),[a]),[s,l]=useState([]),c=useCallback((f,g,x,b,h)=>{if(g.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let w={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:f,cardIds:g,columnId:x,strategy:b,color:h,isExpanded:true,position:s.filter(D=>D.columnId===x).length,createdAt:new Date};l(D=>[...D,w]);},[o.minCardsPerStack,s]),p=useCallback(f=>{l(g=>g.filter(x=>x.id!==f));},[]),n=useCallback(f=>{l(g=>g.map(x=>x.id===f?{...x,isExpanded:!x.isExpanded}:x));},[]),m=useCallback((f,g)=>{l(x=>x.map(b=>b.id===f&&!b.cardIds.includes(g)?{...b,cardIds:[...b.cardIds,g]}:b));},[]),d=useCallback((f,g)=>{l(x=>x.map(b=>{if(b.id===f){let h=b.cardIds.filter(w=>w!==g);return h.length<o.minCardsPerStack?null:{...b,cardIds:h}}return b}).filter(b=>b!==null));},[o.minCardsPerStack]),i=useCallback(f=>s.filter(g=>g.columnId===f).sort((g,x)=>g.position-x.position),[s]),u=useCallback(async f=>{let g=t.filter(D=>D.columnId===f);if(g.length<o.minCardsPerStack*2)return [];let x=[],b=new Map;g.forEach(D=>{D.labels&&D.labels.length>0&&D.labels.forEach(N=>{b.has(N)||b.set(N,[]),b.get(N).push(D);});}),b.forEach((D,N)=>{D.length>=o.minCardsPerStack&&x.push({stack:{title:`\u{1F4CC} ${N}`,cardIds:D.map(M=>M.id),columnId:f,strategy:"labels",color:"#3b82f6"},reason:`${D.length} cards with label "${N}"`,confidence:.85});});let h=new Map;g.forEach(D=>{D.assignedUserIds&&D.assignedUserIds.length>0&&D.assignedUserIds.forEach(N=>{h.has(N)||h.set(N,[]),h.get(N).push(D);});}),h.forEach((D,N)=>{D.length>=o.minCardsPerStack&&x.push({stack:{title:`\u{1F464} Assigned to user-${N.slice(-4)}`,cardIds:D.map(M=>M.id),columnId:f,strategy:"assignee",color:"#8b5cf6"},reason:`${D.length} cards assigned to the same user`,confidence:.8});});let w=new Map;if(g.forEach(D=>{D.priority&&(w.has(D.priority)||w.set(D.priority,[]),w.get(D.priority).push(D));}),w.forEach((D,N)=>{if(D.length>=o.minCardsPerStack){let M={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[N.toLowerCase()]||"\u26AA";x.push({stack:{title:`${M} ${N} Priority`,cardIds:D.map(v=>v.id),columnId:f,strategy:"priority",color:N==="high"||N==="urgent"?"#ef4444":"#10b981"},reason:`${D.length} cards with ${N} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let D of g){let M=(await r.findSimilar(D,g)).filter(v=>v.similarity>=o.autoStackConfidenceThreshold);if(M.length>=o.minCardsPerStack-1){let v=[D.id,...M.map(T=>T.card.id)],L=M.reduce((T,k)=>T+k.similarity,0)/M.length;x.push({stack:{title:`\u2728 Similar to "${D.title.substring(0,30)}${D.title.length>30?"...":""}"`,cardIds:v,columnId:f,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${M.length+1} similar tasks`,confidence:L});}}return x.filter(D=>D.confidence>=o.autoStackConfidenceThreshold).sort((D,N)=>N.confidence-D.confidence).slice(0,5)},[t,o,r]),y=useCallback(f=>{c(f.stack.title,f.stack.cardIds,f.stack.columnId,f.stack.strategy,f.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(g=>g.columnId)).forEach(async g=>{let x=await u(g),b=x[0];x.length>0&&b&&b.confidence>=.9&&y(b);});},[]),{stacks:s,createStack:c,deleteStack:p,toggleStack:n,addToStack:m,removeFromStack:d,getStacksForColumn:i,getSuggestions:u,applySuggestion:y,config:o}}var Ic=createContext(null);function Lc({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,l=new Map;t?.columns?.forEach(p=>{let{Column:n}=Po("@libxai/core");s.set(p.id,new n(p));}),t?.cards?.forEach(p=>{let{Card:n}=Po("@libxai/core");l.set(p.id,new n(p));});let c=null;if(t?.board){let{Board:p}=Po("@libxai/core");c=new p(t.board);}r.current=new BoardStore({board:c,columns:s,cards:l});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(Ic.Provider,{value:{store:o},children:e})}function Sn(){let e=useContext(Ic);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function Do(){let e=Sn(),[t,a]=useState(e.getBoard()),[r,o]=useState(e.getAllColumns()),[s,l]=useState(e.getAllCards());useEffect(()=>e.subscribeAll(()=>{a(e.getBoard()),o(e.getAllColumns()),l(e.getAllCards());}),[e]);let c=useCallback(b=>{e.updateBoard(b);},[e]),p=useCallback(b=>{e.addColumn(b);},[e]),n=useCallback((b,h)=>{e.updateColumn(b,h);},[e]),m=useCallback(b=>{e.deleteColumn(b);},[e]),d=useCallback(b=>e.getColumn(b),[e]),i=useCallback(b=>{e.addCard(b);},[e]),u=useCallback((b,h)=>{e.updateCard(b,h);},[e]),y=useCallback(b=>{e.deleteCard(b);},[e]),f=useCallback((b,h,w)=>{e.moveCard(b,h,w);},[e]),g=useCallback(b=>e.getCard(b),[e]),x=useCallback(b=>e.getCardsByColumn(b),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:p,updateColumn:n,deleteColumn:m,getColumn:d,addCard:i,updateCard:u,deleteCard:y,moveCard:f,getCard:g,getCardsByColumn:x}}function Bc(e){let{cards:t}=Do();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 Rc(e="position",t="asc"){let{cards:a}=Do();return useMemo(()=>[...a].sort((o,s)=>{let l=0;switch(e){case "title":l=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,n=s.priority?c[s.priority]:0;l=p-n;break}case "createdAt":l=o.createdAt.getTime()-s.createdAt.getTime();break;case "updatedAt":l=o.updatedAt.getTime()-s.updatedAt.getTime();break;case "position":l=o.position-s.position;break}return t==="asc"?l:-l}),[a,e,t])}var En=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=$i.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 l=s[t];if(typeof l=="function")try{let c=await Promise.resolve(l.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(l=>{this.pluginLogger.error(`Plugin hook failed: ${o.id}.${t}`,l,{plugin:o.id,hook:t});}));}await Promise.all(r);}},xh=new En;function zc({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:l=false,gap:c=0,getItemKey:p}){let n=useRef(null),m=useVirtualizer({count:e.length,getScrollElement:()=>n.current,estimateSize:()=>a,overscan:s,horizontal:l,gap:c}),d=m.getVirtualItems(),i={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},u=l?{width:`${m.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${m.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:n,style:i,className:o,children:jsx("div",{style:u,children:d.map(y=>{let f=e[y.index];if(!f)return null;let g=p?p(f,y.index):y.index,x={position:"absolute",top:l?0:y.start,left:l?y.start:0,width:l?y.size:"100%",height:l?"100%":y.size};return jsx("div",{style:x,"data-index":y.index,children:r(f,y.index)},g)})})})}function $c(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 Wc({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:l=3,gap:c=16,getItemKey:p,horizontal:n=true}){let m=useRef(null),d=useVirtualizer({horizontal:n,count:e.length,getScrollElement:()=>m.current,estimateSize:()=>r,overscan:l,gap:c}),i=d.getVirtualItems(),u={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},y={width:`${d.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:m,style:u,className:s,children:jsx("div",{style:y,children:i.map(f=>{let g=e[f.index];if(!g)return null;let x=p?p(g,f.index):f.index,b={position:"absolute",top:0,left:f.start,width:f.size,height:"100%"};return jsx("div",{style:b,"data-index":f.index,children:o(g,f.index)},x)})})})}function Hc(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 Gc(e,t=10){return e>t}var vi={none:0,xs:4,sm:8,md:12,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":40,"5xl":48,"6xl":64},xi={none:0,sm:4,md:8,lg:12,xl:16,"2xl":20,full:9999},ki={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48},wi={light:300,normal:400,medium:500,semibold:600,bold:700,extrabold:800},Ci={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},Ti={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Di={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Ni={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)"},Si={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)"},Ei={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},Pi={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}},Mi={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}},Pn={spacing:vi,borderRadius:xi,fontSize:ki,fontWeight:wi,lineHeight:Ci,zIndex:Ti,duration:Di,easing:Ni,shadows:Si,opacity:Ei,kanban:Pi,gantt:Mi};function _c(e,t,a){return e[t]??a}function Ai(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)?Ai(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function Ch(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function Ii(e="asakaa"){let t=Ai(Pn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,l=Ch(o);a.push(` ${s}: ${l};`);}return `:root {
389
+ Today's date: ${new Date().toISOString().split("T")[0]}`}function $d(e){let t=[],a=r=>{for(let o of r)t.push(o),o.subtasks?.length&&a(o.subtasks);};return a(e),t}function Ya(e,t){let a=$d(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 l=r.split(/\s+/);return a.find(c=>{let p=c.name.toLowerCase();return l.every(n=>p.includes(n))})}function _s(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 u={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(u!==void 0){let v=new Date(r),f=v.getDay(),g=u-f;return g<=0&&(g+=7),v.setDate(v.getDate()+g),v}}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),u=s[2].toLowerCase(),v=new Date(r);return u==="day"||u==="d\xEDa"||u==="dias"?v.setDate(v.getDate()+i):u==="week"||u==="semana"||u==="semanas"?v.setDate(v.getDate()+i*7):(u==="month"||u==="mes"||u==="meses")&&v.setMonth(v.getMonth()+i),v}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),u=parseInt(c[2],10)-1,v=parseInt(c[3],10);return new Date(v,u,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},n=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(n&&n[1]&&n[2]){let i=parseInt(n[1],10),u=p[n[2].toLowerCase()],v=n[3]?parseInt(n[3],10):r.getFullYear();if(u!==void 0)return new Date(v,u,i)}let m={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=m[d[1].toLowerCase()],u=parseInt(d[2],10),v=d[3]?parseInt(d[3],10):r.getFullYear();if(i!==void 0)return new Date(v,i,u)}return null}function Vs(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 js(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 Ud(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 Wd(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 n=r[1].trim(),m=r[2].trim(),d=Ya(t,n),i=_s(m);if(!d)return {type:"move_task",taskName:n,message:`Could not find a task named "${n}". 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 "${m}". Try using formats like "next Monday", "in 3 days", or "2024-01-15".`,success:false,error:"Invalid date"};let u=d.startDate&&d.endDate?Math.round((d.endDate.getTime()-d.startDate.getTime())/(1e3*60*60*24)):1,v=new Date(i);return v.setDate(v.getDate()+u),{type:"move_task",taskId:d.id,taskName:d.name,updates:{startDate:i,endDate:v},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 n=o[1].trim(),m=o[2].trim(),d=Ya(t,n),i=Vs(m);if(!d)return {type:"resize_task",taskName:n,message:`Could not find a task named "${n}".`,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 "${m}".`,success:false,error:"Invalid duration"};let u=new Date(d.endDate);return u.setDate(u.getDate()+i),{type:"resize_task",taskId:d.id,taskName:d.name,updates:{endDate:u},message:`Extended "${d.name}" by ${i} days. New end date: ${u.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 n=s[1].trim(),m=s[2].trim(),d=Ya(t,n),i=js(m);return d?i===null?{type:"set_progress",taskId:d.id,taskName:d.name,message:`Could not parse the progress value "${m}".`,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:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}let l=a.match(/(?:rename|renombrar|cambiar nombre de)\s+["""]?(.+?)["""]?\s+(?:to|a|por)\s+["""]?(.+?)["""]?$/i);if(l&&l[1]&&l[2]){let n=l[1].trim(),m=l[2].trim(),d=Ya(t,n);return d?{type:"rename_task",taskId:d.id,taskName:d.name,updates:{name:m},message:`Renamed "${d.name}" to "${m}".`,success:true}:{type:"rename_task",taskName:n,message:`Could not find a task named "${n}".`,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 n=c[1].trim(),m=c[2].trim(),d=Ya(t,n),i=Ya(t,m);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:m,message:`Could not find a task named "${m}".`,success:false,error:"Target task not found"}:{type:"link_tasks",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Source task not found"}}let p=a.match(/(?:delete|eliminar|borrar|remove|quitar)\s+["""]?(.+?)["""]?$/i);if(p&&p[1]){let n=p[1].trim(),m=Ya(t,n);return m?{type:"delete_task",taskId:m.id,taskName:m.name,message:`Deleted "${m.name}".`,success:true}:{type:"delete_task",taskName:n,message:`Could not find a task named "${n}".`,success:false,error:"Task not found"}}return null}function Hd(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 Tf(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 Df(e){switch(e){case "todo":return "TODO";case "in-progress":return "IN_PROGRESS";case "completed":return "DONE";default:return e||"TODO"}}function pn(e,t=[],a=[]){let r=e.assignedUserIds?.map(m=>{let d=a.find(i=>i.id===m);return d?{name:d.name,initials:d.initials,color:d.color}:null}).filter(m=>m!==null),o=t.filter(m=>m.metadata?.parentCardId===e.id).map(m=>pn(m,t,a)),s;e.dependencies&&(typeof e.dependencies[0]=="string"?s=e.dependencies:s=e.dependencies.filter(m=>m.type==="finish-to-start").map(m=>m.taskId));let l=m=>{if(m)return typeof m=="string"?new Date(m):m},c=l(e.startDate),p=l(e.endDate),n=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:Tf(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:n,isCriticalPath:e.metadata?.isCriticalPath===true}}function Gd(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:Df(e.status),isExpanded:e.isExpanded,isMilestone:e.isMilestone,isCriticalPath:e.isCriticalPath}}}function _d(e,t=[]){return e.filter(r=>!r.metadata?.parentCardId).map(r=>pn(r,e,t))}var Ks={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"}},Ys={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"}},mn={en:Ks,es:Ys};function qs(e){return mn[e]||mn.en}function un(e,t){let a=qs(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 Yd(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(...Yd(r.subtasks,t+1));return a}function Rf({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 qd({tasks:e,config:t={},callbacks:a={},isLoading:r=false,error:o,className:s,style:l}){let{theme:c="dark",locale:p="en",customTranslations:n,showSearch:m=true,showHierarchy:d=true}=t,i=un(p,n),u=c==="dark",[v,f]=useState(new Set),[g,x]=useState("startDate"),[b,h]=useState("asc"),[w,D]=useState("");useMemo(()=>{let T=new Set;function k(B){for(let P of B)P.subtasks?.length&&(T.add(P.id),k(P.subtasks));}k(e),f(T);},[e]);let N=useCallback(T=>{f(k=>{let B=new Set(k);return B.has(T)?B.delete(T):B.add(T),B}),a.onTaskToggleExpand?.(T);},[a]),A=useCallback(T=>{g===T?h(k=>k==="asc"?"desc":"asc"):(x(T),h("asc")),a.onSortChange?.({column:T,direction:b==="asc"?"desc":"asc"});},[g,b,a]),y=useMemo(()=>{let T=Yd(e);if(w.trim()){let B=w.toLowerCase();T=T.filter(P=>P.name.toLowerCase().includes(B));}let k=[];for(let B of T){let P=B.level===0;B.level>0&&(P=true),(P||w.trim())&&k.push(B);}return w.trim()&&k.sort((B,P)=>{let H,X;switch(g){case "name":H=B.name.toLowerCase(),X=P.name.toLowerCase();break;case "startDate":H=B.startDate?.getTime()||0,X=P.startDate?.getTime()||0;break;case "endDate":H=B.endDate?.getTime()||0,X=P.endDate?.getTime()||0;break;case "progress":H=B.progress||0,X=P.progress||0;break;case "status":H=B.status||"todo",X=P.status||"todo";break;default:return 0}return H<X?b==="asc"?-1:1:H>X?b==="asc"?1:-1:0}),k},[e,w,g,b]),R=T=>T?(T instanceof Date?T:new Date(T)).toLocaleDateString(p==="es"?"es-ES":"en-US",{day:"numeric",month:"short"}):"-";return r?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[i.empty.noTasks,"..."]})]})}):o?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-lg font-semibold mb-2",u?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:typeof o=="string"?o:o.message})]})]})}):e.length===0?jsx("div",{className:C("flex-1 flex items-center justify-center",u?"bg-[#0F1117]":"bg-white",s),style:l,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:C("text-lg font-semibold mb-2",u?"text-white":"text-gray-900"),children:i.empty.noTasks}),jsx("p",{className:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.addFirstTask})]})}):jsxs("div",{className:C("flex-1 flex flex-col w-full h-full overflow-hidden",u?"bg-[#0F1117]":"bg-white",s),style:l,children:[jsx("div",{className:C("flex-shrink-0 px-6 py-4 border-b",u?"border-white/10":"border-gray-200"),children:jsxs("div",{className:"flex items-center gap-4",children:[m&&jsxs("div",{className:"relative flex-1 max-w-md",children:[jsx(Search,{className:C("absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")}),jsx("input",{type:"text",value:w,onChange:T=>D(T.target.value),placeholder:i.toolbar.searchPlaceholder,className:C("w-full h-9 pl-10 pr-4 rounded-lg border outline-none focus:ring-2 focus:ring-[#3B82F6]/30",u?"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:C("text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[y.length," ",i.pagination.tasks]})]})}),jsxs("div",{className:C("flex-shrink-0 grid grid-cols-12 gap-4 px-6 py-3 border-b text-xs font-medium uppercase tracking-wider",u?"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:()=>A("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:()=>A("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:()=>A("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:()=>A("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:()=>A("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:y.map((T,k)=>{let B=v.has(T.id);return jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{delay:k*.02},className:C("grid grid-cols-12 gap-4 px-6 py-3 border-b transition-colors cursor-pointer",u?"border-white/5 hover:bg-white/5":"border-gray-100 hover:bg-gray-50"),style:{paddingLeft:d?`${24+T.level*24}px`:void 0},onClick:()=>a.onTaskClick?.(T),onDoubleClick:()=>a.onTaskDoubleClick?.(T),children:[jsxs("div",{className:"col-span-5 flex items-center gap-2 min-w-0",children:[d&&T.hasChildren&&jsx("button",{onClick:P=>{P.stopPropagation(),N(T.id);},className:C("p-0.5 rounded",u?"hover:bg-white/10":"hover:bg-gray-200"),children:B?jsx(ChevronDown,{className:C("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")}):jsx(ChevronRight,{className:C("w-4 h-4",u?"text-[#9CA3AF]":"text-gray-400")})}),d&&!T.hasChildren&&jsx("div",{className:"w-5"}),jsx("button",{onClick:P=>{P.stopPropagation(),a.onTaskUpdate?.({...T,progress:T.progress===100?0:100,status:T.progress===100?"todo":"completed"});},className:"flex-shrink-0",children:jsx(Rf,{status:T.status,progress:T.progress})}),jsx("span",{className:C("truncate",u?"text-white":"text-gray-900",T.progress===100&&(u?"line-through text-[#6B7280]":"line-through text-gray-400")),children:T.name})]}),jsx("div",{className:"col-span-2 flex items-center",children:jsx("span",{className:C("px-2 py-1 rounded-full text-xs font-medium",T.progress===100||T.status==="completed"?"bg-green-500/10 text-green-500":T.progress&&T.progress>0||T.status==="in-progress"?"bg-blue-500/10 text-blue-500":u?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:T.progress===100||T.status==="completed"?i.status.completed:T.progress&&T.progress>0||T.status==="in-progress"?i.status.inProgress:i.status.todo})}),jsxs("div",{className:C("col-span-2 flex items-center gap-1 text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Calendar,{className:"w-4 h-4"}),R(T.startDate)]}),jsxs("div",{className:C("col-span-2 flex items-center gap-1 text-sm",u?"text-[#9CA3AF]":"text-gray-600"),children:[jsx(Clock,{className:"w-4 h-4"}),R(T.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:C("flex-1 h-1.5 rounded-full overflow-hidden",u?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:C("h-full rounded-full transition-all",T.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${T.progress||0}%`}})}),jsxs("span",{className:C("text-xs w-8",u?"text-[#9CA3AF]":"text-gray-500"),children:[T.progress||0,"%"]})]})})]},T.id)})}),y.length===0&&w&&jsx("div",{className:"flex items-center justify-center py-12",children:jsxs("div",{className:"text-center",children:[jsx(List,{className:C("w-12 h-12 mx-auto mb-4",u?"text-[#6B7280]":"text-gray-400")}),jsx("p",{className:C(u?"text-[#9CA3AF]":"text-gray-600"),children:i.empty.noResults})]})})]})]})}var Xs={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"},Js={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"},Zs={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"},fn={dark:Xs,light:Js,neutral:Zs};function Xd(e){return fn[e]||fn.dark}var Qs={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"}},ei={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"}},hn={en:Qs,es:ei};function vo(e){return hn[e]||hn.en}function bn(e,t){let a=vo(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 Jd(e){let t=vo(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 Zd(e,t=0,a=true){let r=vo(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 qf(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 ni(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 tc({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 rc({tasks:e,config:t={},callbacks:a={},initialDate:r,isLoading:o=false,error:s,className:l,style:c}){let{theme:p="dark",locale:n="en",customTranslations:m}=t,d=bn(n,m),i=p==="dark",[u,v]=useState(r||new Date),[f,g]=useState(null),[x,b]=useState(null),[h,w]=useState(null),[D,N]=useState(new Date),[A,y]=useState({}),R=4,T=3,[k,B]=useState(false),[P,H]=useState(false),[X$1,be]=useState(false),[ke,Ae]=useState(null),[Fe,z]=useState(""),[F,W]=useState(void 0),[E,K]=useState(null),[te,O]=useState(false),[Me,he]=useState(false),[qe,me]=useState(null),[tt,we]=useState(false),[st,ht]=useState(new Date),Ft=useCallback(()=>{v(new Date(u.getFullYear(),u.getMonth()-1,1));},[u]),Xe=useCallback(()=>{v(new Date(u.getFullYear(),u.getMonth()+1,1));},[u]),$=useCallback(()=>{v(new Date);},[]),ne=useMemo(()=>{let I=u.getFullYear(),Y=u.getMonth(),He=new Date(I,Y,1),We=new Date(I,Y+1,0),bt=He.getDay(),J=We.getDate(),Q=qf(e),xe=new Date;xe.setHours(0,0,0,0);let Ce=[],ae=bt,Pe=new Date(I,Y,0).getDate();for(let Ne=ae-1;Ne>=0;Ne--){let se=new Date(I,Y-1,Pe-Ne);Ce.push({date:se,isCurrentMonth:false,isToday:false,isWeekend:se.getDay()===0||se.getDay()===6,events:Q.filter(Re=>ni(se,Re)).map(Re=>({id:Re.id,title:Re.name,start:Re.startDate,end:Re.endDate,task:Re}))});}for(let Ne=1;Ne<=J;Ne++){let se=new Date(I,Y,Ne),Re=se.getTime()===xe.getTime();Ce.push({date:se,isCurrentMonth:true,isToday:Re,isWeekend:se.getDay()===0||se.getDay()===6,events:Q.filter(Le=>ni(se,Le)).map(Le=>({id:Le.id,title:Le.name,start:Le.startDate,end:Le.endDate,task:Le}))});}let ye=42-Ce.length;for(let Ne=1;Ne<=ye;Ne++){let se=new Date(I,Y+1,Ne);Ce.push({date:se,isCurrentMonth:false,isToday:false,isWeekend:se.getDay()===0||se.getDay()===6,events:Q.filter(Re=>ni(se,Re)).map(Re=>({id:Re.id,title:Re.name,start:Re.startDate,end:Re.endDate,task:Re}))});}return Ce},[u,e]),ve=n==="es"?["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Te=u.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"}),De=useCallback((I,Y)=>{if(!f)return;let He={...f,[I]:Y};g(He),a.onTaskUpdate?.(He);},[f,a]),Ye=useCallback(I=>{if(!f)return;let Y=f.progress||0;I==="completed"?Y=100:I==="todo"&&(Y=0);let He={...f,status:I,progress:Y};g(He),a.onTaskUpdate?.(He),B(false);},[f,a]),mt=useCallback((I,Y)=>{if(!f)return;let He={...f,startDate:I,endDate:Y};g(He),a.onTaskUpdate?.(He);},[f,a]),Ie=useCallback(()=>{B(false),H(false),w(null);},[]);return o?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),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:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:[d.labels.noEvents,"..."]})]})}):s?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),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:C("text-lg font-semibold mb-2",i?"text-white":"text-gray-900"),children:"Error"}),jsx("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:typeof s=="string"?s:s.message})]})]})}):e.length===0?jsx("div",{className:C("flex-1 flex items-center justify-center",i?"bg-[#0F1117]":"bg-white",l),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:C("text-lg font-semibold mb-2",i?"text-white":"text-gray-900"),children:d.labels.noEvents}),jsx("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-600"),children:d.labels.newTask})]})}):jsxs("div",{className:C("flex-1 flex flex-col w-full h-full overflow-auto",i?"bg-[#0F1117]":"bg-white",l),style:c,children:[jsx("div",{className:C("flex-shrink-0 px-6 py-4 border-b",i?"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:C("text-xl font-semibold capitalize",i?"text-white":"text-gray-900"),children:Te}),jsx("button",{onClick:$,className:C("px-3 py-1.5 text-sm rounded-lg transition-colors",i?"bg-white/5 text-white hover:bg-white/10":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:d.navigation.today})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("button",{onClick:Ft,className:C("p-2 rounded-lg transition-colors",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:C("w-5 h-5",i?"text-[#9CA3AF]":"text-gray-600")})}),jsx("button",{onClick:Xe,className:C("p-2 rounded-lg transition-colors",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronRight,{className:C("w-5 h-5",i?"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:ve.map(I=>jsx("div",{className:C("py-2 text-center text-xs font-medium uppercase",i?"text-[#9CA3AF]":"text-gray-500"),children:I},I))}),jsx("div",{className:C("grid grid-cols-7 auto-rows-min gap-px rounded-lg",i?"bg-[#2D2D2D]":"bg-gray-300"),children:ne.map((I,Y)=>{let He=I.date.getDay()===0||I.date.getDay()===6;return jsxs("div",{className:C("min-h-[120px] p-2 transition-colors flex flex-col relative group",i?He?"bg-[#1C1F26]":I.isCurrentMonth?"bg-[#13161B]":"bg-[#0D0F13]":He?"bg-gray-100":I.isCurrentMonth?"bg-white":"bg-gray-50",I.isToday&&"ring-2 ring-[#3B82F6] ring-inset"),children:[(()=>{let We=A[Y]||R,bt=I.events.slice(0,We),J=I.events.length-We;return jsxs("div",{className:"space-y-1 flex-1",children:[bt.map(Q=>jsx("div",{className:"relative group",children:jsxs(motion.button,{onClick:()=>{g(Q.task),a.onEventClick?.(Q);},whileHover:{scale:1.02},className:C("w-full flex items-center gap-1 px-1.5 py-0.5 rounded text-xs truncate",Q.task.progress===100?i?"bg-green-500/20 text-green-400":"bg-green-500/10 text-green-600":i?"bg-[#3B82F6]/20 text-[#3B82F6]":"bg-[#3B82F6]/10 text-[#3B82F6]"),children:[jsx(tc,{task:Q.task}),jsx("span",{className:"truncate",children:Q.title})]})},Q.id)),J>0&&jsxs("button",{onClick:Q=>{Q.stopPropagation(),y(xe=>({...xe,[Y]:We+T}));},className:C("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",i?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:["+",J," ",n==="es"?"M\xC1S":"MORE"]}),We>R&&I.events.length>R&&jsx("button",{onClick:Q=>{Q.stopPropagation(),y(xe=>({...xe,[Y]:R}));},className:C("text-xs px-1.5 py-0.5 hover:underline cursor-pointer font-medium",i?"text-[#6B7280] hover:text-[#9CA3AF]":"text-gray-400 hover:text-gray-600"),children:n==="es"?"MENOS":"LESS"})]})})(),jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1",children:[(()=>{let We=Y>=28,bt=Y%7>=5;return jsxs("div",{className:"relative",children:[jsx("button",{onClick:J=>{J.stopPropagation(),ke===Y?Ae(null):(Ae(Y),z(""),W(void 0),K(null),me(null),O(false),he(false),we(false),ht(I.date));},className:C("w-5 h-5 rounded flex items-center justify-center transition-all",ke===Y?"opacity-100 bg-[#7C3AED] text-white":"opacity-0 group-hover:opacity-100",i?"hover:bg-[#7C3AED] text-[#6B7280] hover:text-white":"hover:bg-[#7C3AED] text-gray-400 hover:text-white"),children:jsx(Plus,{className:C("w-3.5 h-3.5 transition-transform",ke===Y&&"rotate-45")})}),jsx(AnimatePresence,{children:ke===Y&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{Ae(null),z(""),W(void 0),K(null),me(null),O(false),he(false),we(false);}}),jsxs(motion.div,{initial:{opacity:0,y:We?-5:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:We?-5:5,scale:.95},transition:{duration:.12},className:C("absolute w-[320px] rounded-lg shadow-2xl z-50",We?"bottom-full mb-1":"top-full mt-1",bt?"right-0":"left-0",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:J=>{J.stopPropagation(),O(false),he(false),we(false);},children:[jsx("div",{className:"p-2.5",children:jsx("input",{type:"text",value:Fe,onChange:J=>z(J.target.value),placeholder:n==="es"?'Escribe el nombre de la tarea o "/" para los comandos':'Type task name or "/" for commands',className:C("w-full bg-transparent text-sm outline-none placeholder:opacity-40",i?"text-white":"text-gray-900"),autoFocus:true,onKeyDown:J=>{if(J.key==="Enter"&&Fe.trim()){let Q=t.availableUsers?.find(Ce=>Ce.id===E),xe=qe||I.date;a.onTaskCreate?.({name:Fe.trim(),startDate:xe,endDate:xe,priority:F,assignees:Q?[Q]:void 0}),z(""),W(void 0),K(null),me(null),Ae(null);}J.key==="Escape"&&(Ae(null),z(""),W(void 0),K(null),me(null));}})}),jsxs("div",{className:C("px-2.5 py-2 flex items-center justify-between border-t",i?"border-white/10":"border-gray-100"),children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs("div",{className:"relative",children:[jsx("button",{onClick:J=>{J.stopPropagation(),O(!te),he(false);},className:C("p-1 rounded transition-colors",F?F==="urgent"||F==="high"?"text-red-400 bg-red-500/20":F==="medium"?"text-yellow-400 bg-yellow-500/20":"text-green-400 bg-green-500/20":i?"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:te&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[120px]",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:J=>J.stopPropagation(),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(J=>jsxs("button",{onClick:()=>{W(J.id),O(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",F===J.id&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",J.color)}),jsx("span",{className:i?"text-white":"text-gray-900",children:J.label})]},J.id||"none"))})})]}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:J=>{J.stopPropagation(),we(!tt),O(false),he(false),ht(qe||I.date);},className:C("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",qe?"bg-[#7C3AED]/20 text-[#7C3AED]":i?"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"}),(qe||I.date).toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})]}),jsx(AnimatePresence,{children:tt&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-xl shadow-2xl overflow-hidden flex",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:J=>J.stopPropagation(),children:[jsx("div",{className:C("w-40 py-2 border-r",i?"border-white/10":"border-gray-200"),children:(()=>{let J=new Date,Q=new Date(J);Q.setDate(J.getDate()+1);let xe=new Date(J);xe.setDate(J.getDate()+((6-J.getDay()+7)%7||7));let Ce=new Date(J);Ce.setDate(J.getDate()+((1-J.getDay()+7)%7||7));let ae=new Date(J);ae.setDate(J.getDate()+14);let Pe=new Date(J);return Pe.setDate(J.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:J,display:J.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:Q,display:Q.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:xe,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:Ce,display:n==="es"?"lun.":"mon."},{label:n==="es"?"2 semanas":"2 weeks",date:ae,display:ae.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Pe,display:Pe.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ne,se)=>jsxs("button",{className:C("w-full flex items-center justify-between px-3 py-1.5 text-xs transition-colors",i?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{me(Ne.date),we(false);},children:[jsx("span",{children:Ne.label}),jsx("span",{className:C("text-[10px]",i?"text-[#6B7280]":"text-gray-400"),children:Ne.display})]},se))})()}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("span",{className:C("text-xs font-medium",i?"text-white":"text-gray-900"),children:st.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{onClick:()=>ht(new Date),className:C("px-1.5 py-0.5 rounded text-[10px] transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>ht(new Date(st.getFullYear(),st.getMonth()-1)),className:C("p-0.5 rounded",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>ht(new Date(st.getFullYear(),st.getMonth()+1)),className:C("p-0.5 rounded",i?"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:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(J=>jsx("div",{className:C("w-6 h-6 flex items-center justify-center text-[10px]",i?"text-[#6B7280]":"text-gray-400"),children:J},J))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let J=st.getFullYear(),Q=st.getMonth(),xe=new Date(J,Q,1).getDay(),Ce=new Date(J,Q+1,0).getDate(),ae=new Date(J,Q,0).getDate(),Pe=new Date,ye=[];for(let se=xe-1;se>=0;se--)ye.push({dayNum:ae-se,isCurrentMonth:false,date:new Date(J,Q-1,ae-se)});for(let se=1;se<=Ce;se++)ye.push({dayNum:se,isCurrentMonth:true,date:new Date(J,Q,se)});let Ne=42-ye.length;for(let se=1;se<=Ne;se++)ye.push({dayNum:se,isCurrentMonth:false,date:new Date(J,Q+1,se)});return ye.map((se,Re)=>{let Le=se.date.toDateString()===Pe.toDateString(),$e=(qe||I.date).toDateString()===se.date.toDateString();return jsx("button",{className:C("w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",!se.isCurrentMonth&&(i?"text-[#4B5563]":"text-gray-300"),se.isCurrentMonth&&(i?"text-white":"text-gray-900"),Le&&"ring-1 ring-[#3B82F6]",$e&&"bg-[#7C3AED] text-white",!$e&&(i?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{me(se.date),we(false);},children:se.dayNum},Re)})})()})]})]})})]}),jsxs("div",{className:"relative",children:[jsx("button",{onClick:J=>{J.stopPropagation(),he(!Me),O(false);},className:C("p-1 rounded transition-colors",E?"text-[#7C3AED] bg-[#7C3AED]/20":i?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:E?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(J=>J.id===E)?.color||"#7C3AED"},children:t.availableUsers?.find(J=>J.id===E)?.initials||t.availableUsers?.find(J=>J.id===E)?.name?.slice(0,2).toUpperCase()}):jsx(User,{className:"w-3.5 h-3.5"})}),jsx(AnimatePresence,{children:Me&&jsxs(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-0 bottom-full mb-1 z-[60] rounded-lg shadow-xl overflow-hidden min-w-[160px] max-h-[200px] overflow-y-auto",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:J=>J.stopPropagation(),children:[jsxs("button",{onClick:()=>{K(null),he(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",!E&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("div",{className:C("w-5 h-5 rounded-full flex items-center justify-center",i?"bg-white/10":"bg-gray-200"),children:jsx(User,{className:"w-3 h-3 text-gray-400"})}),jsx("span",{className:i?"text-[#9CA3AF]":"text-gray-500",children:n==="es"?"Sin asignar":"Unassigned"})]}),t.availableUsers?.map(J=>jsxs("button",{onClick:()=>{K(J.id),he(false);},className:C("w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",E===J.id&&(i?"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:J.color||"#7C3AED"},children:J.initials||J.name?.slice(0,2).toUpperCase()}),jsx("span",{className:i?"text-white":"text-gray-900",children:J.name})]},J.id)),(!t.availableUsers||t.availableUsers.length===0)&&jsx("div",{className:C("px-3 py-2 text-xs",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"No hay usuarios disponibles":"No users available"})]})})]})]}),jsx("button",{onClick:()=>{if(Fe.trim()){let J=t.availableUsers?.find(xe=>xe.id===E),Q=qe||I.date;a.onTaskCreate?.({name:Fe.trim(),startDate:Q,endDate:Q,priority:F,assignees:J?[J]:void 0}),z(""),W(void 0),K(null),me(null),Ae(null);}},disabled:!Fe.trim(),className:C("px-2.5 py-1 rounded text-xs font-medium transition-colors",Fe.trim()?"bg-[#7C3AED] hover:bg-[#6D28D9] text-white":i?"bg-white/5 text-[#4B5563]":"bg-gray-100 text-gray-400"),children:n==="es"?"Guardar":"Save"})]})]})]})})]})})(),jsx("span",{className:C("text-sm font-medium",I.isToday?"text-[#3B82F6]":I.isCurrentMonth?i?"text-white":"text-gray-900":i?"text-[#6B7280]":"text-gray-400"),children:I.date.getDate()})]})]},Y)})})]})}),jsx(AnimatePresence,{children:f&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>g(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:C("fixed inset-4 md:inset-8 lg:inset-12 rounded-xl shadow-2xl z-50 flex overflow-hidden",i?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[jsxs("div",{className:C("px-6 py-3 border-b flex items-center gap-3",i?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Circle,{className:C("w-4 h-4",i?"text-[#9CA3AF]":"text-gray-500")}),jsxs("span",{className:C("text-xs px-2 py-0.5 rounded",i?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:[n==="es"?"Tarea":"Task"," \u2228"]}),jsx("span",{className:C("text-xs font-mono",i?"text-[#6B7280]":"text-gray-400"),children:f.id.slice(0,8)}),jsxs("button",{className:C("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-colors",i?"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:C("p-1.5 rounded transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(Maximize2,{className:"w-4 h-4"})}),jsx("button",{className:C("p-1.5 rounded transition-colors",i?"hover:bg-white/10 text-[#9CA3AF]":"hover:bg-gray-100 text-gray-500"),children:jsx(MoreHorizontal,{className:"w-5 h-5"})}),jsx("button",{onClick:()=>g(null),className:C("p-1.5 rounded transition-colors",i?"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 I=f.progress===100?0:100,He={...f,progress:I,status:I===100?"completed":"todo"};g(He),a.onTaskUpdate?.(He);},className:C("mt-1 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-colors",f.progress===100?"bg-green-500 border-green-500":i?"border-white/30 hover:border-white/50":"border-gray-300 hover:border-gray-400"),children:f.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("h2",{className:C("text-xl font-semibold flex-1",f.progress===100?"line-through text-[#6B7280]":i?"text-white":"text-gray-900"),children:f.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:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Estado":"Status"}),jsx("button",{onClick:()=>{Ie(),B(!k);},className:C("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",f.progress===100||f.status==="completed"?"bg-green-500/20 text-green-400":f.progress&&f.progress>0||f.status==="in-progress"?"bg-blue-500/20 text-blue-400":i?"bg-white/10 text-white":"bg-gray-100 text-gray-700"),children:f.progress===100||f.status==="completed"?n==="es"?"COMPLETADO":"DONE":f.progress&&f.progress>0||f.status==="in-progress"?n==="es"?"EN PROGRESO":"IN PROGRESS":n==="es"?"POR HACER":"TO DO"}),jsx(AnimatePresence,{children:k&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>B(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:C("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),children:[{id:"todo",label:n==="es"?"Por hacer":"To Do",color:"bg-white/10 text-white"},{id:"in-progress",label:n==="es"?"En progreso":"In Progress",color:"bg-blue-500/20 text-blue-400"},{id:"completed",label:n==="es"?"Completado":"Done",color:"bg-green-500/20 text-green-400"}].map(I=>jsxs("button",{onClick:()=>Ye(I.id),className:C("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",(f.status===I.id||I.id==="completed"&&f.progress===100||I.id==="in-progress"&&f.progress&&f.progress>0&&f.progress<100||I.id==="todo"&&(!f.progress||f.progress===0)&&f.status!=="in-progress"&&f.status!=="completed")&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",I.id==="completed"?"bg-green-500":I.id==="in-progress"?"bg-blue-500":"bg-gray-400")}),jsx("span",{className:i?"text-white":"text-gray-900",children:I.label})]},I.id))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(User,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Asignados":"Assignees"}),f.assignees&&f.assignees.length>0?jsxs("div",{className:"flex items-center gap-1",children:[f.assignees.slice(0,3).map((I,Y)=>jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:I.color||"#8B5CF6"},title:I.name,children:I.initials||I.name.slice(0,2).toUpperCase()},Y)),f.assignees.length>3&&jsxs("span",{className:C("text-xs",i?"text-[#6B7280]":"text-gray-400"),children:["+",f.assignees.length-3]})]}):jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Sin asignar":"Unassigned"})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(CalendarDays,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Fechas":"Dates"}),jsxs("button",{onClick:()=>{w(h?null:"start"),N(f.startDate||new Date);},className:C("flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors",i?"bg-white/5 hover:bg-white/10 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-900"),children:[f.startDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Inicio":"Start"),jsx("span",{className:C("mx-1",i?"text-[#6B7280]":"text-gray-400"),children:"\u2192"}),f.endDate?.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"short",day:"numeric"})||(n==="es"?"Fin":"End"),(f.startDate||f.endDate)&&jsx(X,{className:"w-3.5 h-3.5 ml-1 opacity-50 hover:opacity-100",onClick:I=>{I.stopPropagation();}})]}),jsx(AnimatePresence,{children:h&&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:C("absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",i?"bg-[#1A1D25] border border-white/10":"bg-white border border-gray-200"),onClick:I=>I.stopPropagation(),children:[jsxs("div",{className:C("w-44 py-2 border-r",i?"border-white/10":"border-gray-200"),children:[(()=>{let I=new Date,Y=new Date(I);Y.setDate(I.getDate()+1);let He=new Date(I);He.setDate(I.getDate()+((6-I.getDay()+7)%7||7));let We=new Date(I);We.setDate(I.getDate()+((1-I.getDay()+7)%7||7));let bt=new Date(I);bt.setDate(I.getDate()+(6-I.getDay()+7)%7+7);let J=new Date(I);J.setDate(I.getDate()+14);let Q=new Date(I);return Q.setDate(I.getDate()+28),[{label:n==="es"?"Hoy":"Today",date:I,display:I.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Ma\xF1ana":"Tomorrow",date:Y,display:Y.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"short"}).slice(0,3)+"."},{label:n==="es"?"Este fin de semana":"This weekend",date:He,display:n==="es"?"s\xE1b.":"sat."},{label:n==="es"?"Pr\xF3xima semana":"Next week",date:We,display:n==="es"?"lun.":"mon."},{label:n==="es"?"Pr\xF3ximo fin de semana":"Next weekend",date:bt,display:bt.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"2 semanas":"2 weeks",date:J,display:J.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})},{label:n==="es"?"4 semanas":"4 weeks",date:Q,display:Q.toLocaleDateString(n==="es"?"es-ES":"en-US",{day:"numeric",month:"short"})}].map((Ce,ae)=>jsxs("button",{className:C("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",i?"hover:bg-white/5 text-white":"hover:bg-gray-50 text-gray-900"),onClick:()=>{if(h==="start"){let Pe=f.endDate&&Ce.date>f.endDate?Ce.date:f.endDate;mt(Ce.date,Pe),w("end");}else {let Pe=f.startDate&&Ce.date<f.startDate?Ce.date:f.startDate;mt(Pe,Ce.date),w(null);}},children:[jsx("span",{children:Ce.label}),jsx("span",{className:C("text-xs",i?"text-[#6B7280]":"text-gray-400"),children:Ce.display})]},ae))})(),jsx("div",{className:C("border-t mt-2 pt-2",i?"border-white/10":"border-gray-200"),children:jsxs("button",{onClick:()=>{mt(void 0,void 0),w(null);},className:C("w-full flex items-center justify-between px-3 py-2 text-sm transition-colors",i?"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:C("text-xs mb-3 px-2 py-1 rounded",i?"bg-white/5 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:h==="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:C("font-medium",i?"text-white":"text-gray-900"),children:D.toLocaleDateString(n==="es"?"es-ES":"en-US",{month:"long",year:"numeric"})}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>N(new Date),className:C("p-1 rounded text-sm transition-colors",i?"hover:bg-white/10 text-white":"hover:bg-gray-100 text-gray-700"),children:n==="es"?"Hoy":"Today"}),jsx("button",{onClick:()=>N(new Date(D.getFullYear(),D.getMonth()-1)),className:C("p-1 rounded",i?"hover:bg-white/10":"hover:bg-gray-100"),children:jsx(ChevronLeft,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>N(new Date(D.getFullYear(),D.getMonth()+1)),className:C("p-1 rounded",i?"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:(n==="es"?["do","lu","ma","mi","ju","vi","s\xE1"]:["su","mo","tu","we","th","fr","sa"]).map(I=>jsx("div",{className:C("w-8 h-8 flex items-center justify-center text-xs",i?"text-[#6B7280]":"text-gray-400"),children:I},I))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let I=D.getFullYear(),Y=D.getMonth(),He=new Date(I,Y,1).getDay(),We=new Date(I,Y+1,0).getDate(),bt=new Date(I,Y,0).getDate(),J=new Date,Q=[];for(let Ce=He-1;Ce>=0;Ce--)Q.push({day:bt-Ce,isCurrentMonth:false,date:new Date(I,Y-1,bt-Ce)});for(let Ce=1;Ce<=We;Ce++)Q.push({day:Ce,isCurrentMonth:true,date:new Date(I,Y,Ce)});let xe=42-Q.length;for(let Ce=1;Ce<=xe;Ce++)Q.push({day:Ce,isCurrentMonth:false,date:new Date(I,Y+1,Ce)});return Q.map((Ce,ae)=>{let Pe=Ce.date.toDateString()===J.toDateString(),ye=f.startDate?.toDateString()===Ce.date.toDateString(),Ne=f.endDate?.toDateString()===Ce.date.toDateString(),se=ye||Ne,Re=f.startDate&&f.endDate&&Ce.date>=f.startDate&&Ce.date<=f.endDate;return jsx("button",{className:C("w-8 h-8 rounded-full flex items-center justify-center text-sm transition-colors",!Ce.isCurrentMonth&&(i?"text-[#4B5563]":"text-gray-300"),Ce.isCurrentMonth&&(i?"text-white":"text-gray-900"),Pe&&"ring-2 ring-[#3B82F6]",ye&&"bg-[#3B82F6] text-white",Ne&&!ye&&"bg-[#7C3AED] text-white",Re&&!se&&(i?"bg-[#7C3AED]/20":"bg-purple-100"),!se&&(i?"hover:bg-white/10":"hover:bg-gray-100")),onClick:()=>{let Le=new Date(Ce.date);if(h==="start"){let $e=f.endDate&&Le>f.endDate?Le:f.endDate;mt(Le,$e),w("end");}else {let $e=f.startDate&&Le<f.startDate?Le:f.startDate;mt($e,Le),w(null);}},children:Ce.day},ae)})})()})]})]})]})})]}),jsxs("div",{className:"flex items-center gap-3 relative",children:[jsx(Flag,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Prioridad":"Priority"}),jsx("button",{onClick:()=>{Ie(),H(!P);},className:C("text-xs px-2 py-1 rounded font-medium cursor-pointer transition-all hover:ring-2 hover:ring-white/20",f.priority==="high"||f.priority==="urgent"?"bg-red-500/20 text-red-400":f.priority==="medium"?"bg-yellow-500/20 text-yellow-400":f.priority==="low"?"bg-green-500/20 text-green-400":i?"bg-white/10 text-[#9CA3AF]":"bg-gray-100 text-gray-600"),children:f.priority?f.priority==="high"||f.priority==="urgent"?n==="es"?"Urgente":"Urgent":f.priority==="medium"?n==="es"?"Media":"Medium":n==="es"?"Baja":"Low":n==="es"?"Sin prioridad":"No priority"}),jsx(AnimatePresence,{children:P&&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:C("absolute left-32 top-full mt-1 z-50 rounded-lg shadow-xl overflow-hidden min-w-[140px]",i?"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(I=>jsxs("button",{onClick:()=>{De("priority",I.id),H(false);},className:C("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",i?"hover:bg-white/5":"hover:bg-gray-50",f.priority===I.id&&(i?"bg-white/5":"bg-gray-50")),children:[jsx("span",{className:C("w-2 h-2 rounded-full",I.color)}),jsx("span",{className:i?"text-white":"text-gray-900",children:I.label})]},I.id||"none"))})]})})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Duraci\xF3n":"Duration"}),jsx("span",{className:C("text-sm",i?"text-white":"text-gray-900"),children:f.startDate&&f.endDate?`${Math.ceil((f.endDate.getTime()-f.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:C("w-4 h-4 rounded-full border-2",i?"border-[#6B7280]":"border-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Progreso":"Progress"}),jsxs("div",{className:"flex items-center gap-2 flex-1",children:[X$1?jsx("input",{type:"range",min:"0",max:"100",step:"5",value:f.progress||0,onChange:I=>{let Y=parseInt(I.target.value),He=f.status;Y===100?He="completed":Y>0?He="in-progress":He="todo";let We={...f,progress:Y,status:He};g(We),a.onTaskUpdate?.(We);},onBlur:()=>be(false),className:C("flex-1 max-w-[120px] h-2 rounded-full appearance-none cursor-pointer",i?"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:()=>be(true),className:C("flex-1 h-2 rounded-full overflow-hidden max-w-[120px] cursor-pointer hover:ring-2 hover:ring-white/20 transition-all",i?"bg-white/10":"bg-gray-200"),children:jsx("div",{className:C("h-full rounded-full transition-all",f.progress===100?"bg-green-500":"bg-[#3B82F6]"),style:{width:`${f.progress||0}%`}})}),jsxs("span",{className:C("text-sm font-medium min-w-[40px]",i?"text-white":"text-gray-900"),children:[f.progress||0,"%"]})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Tag,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Etiquetas":"Tags"}),jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:n==="es"?"Vac\xEDo":"Empty"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Link2,{className:C("w-4 h-4",i?"text-[#6B7280]":"text-gray-400")}),jsx("span",{className:C("text-sm w-24",i?"text-[#9CA3AF]":"text-gray-500"),children:n==="es"?"Relaciones":"Relations"}),jsx("span",{className:C("text-sm",i?"text-[#6B7280]":"text-gray-400"),children:f.dependencies&&f.dependencies.length>0?`${f.dependencies.length} ${n==="es"?"dependencias":"dependencies"}`:n==="es"?"Vac\xEDo":"Empty"})]})]}),jsxs("div",{className:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsxs("button",{className:C("flex items-center gap-2 text-sm transition-colors",i?"text-[#9CA3AF] hover:text-white":"text-gray-500 hover:text-gray-900"),children:[jsx(FileText,{className:"w-4 h-4"}),n==="es"?"Agregar descripci\xF3n":"Add description"]}),jsxs("button",{className:C("flex items-center gap-2 text-sm mt-2 transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Campos personalizados":"Custom fields"}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Agregar subtarea":"Add subtask"}),f.subtasks&&f.subtasks.length>0&&jsx("div",{className:"space-y-2 mb-3",children:f.subtasks.map(I=>jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:C("w-4 h-4 rounded border flex items-center justify-center cursor-pointer",I.progress===100?"bg-green-500 border-green-500":i?"border-white/20 hover:border-white/40":"border-gray-300 hover:border-gray-400"),children:I.progress===100&&jsx(CheckCircle2,{className:"w-3 h-3 text-white"})}),jsx("span",{className:C("text-sm",I.progress===100?"line-through text-[#6B7280]":i?"text-white":"text-gray-900"),children:I.name})]},I.id))}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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"?"Add Tarea":"Add Task"]})]}),jsxs("div",{className:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("h3",{className:C("text-sm font-semibold",i?"text-white":"text-gray-900"),children:n==="es"?"Listas de control":"Checklists"}),jsx("button",{className:C("p-1 rounded transition-colors",i?"hover:bg-white/10 text-[#6B7280]":"hover:bg-gray-100 text-gray-400"),children:jsx(Plus,{className:"w-4 h-4"})})]}),jsxs("button",{className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",i?"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:C("mt-6 pt-4 border-t",i?"border-white/10":"border-gray-200"),children:[jsx("h3",{className:C("text-sm font-semibold mb-3",i?"text-white":"text-gray-900"),children:n==="es"?"Adjuntos":"Attachments"}),jsxs("div",{className:C("border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer",i?"border-white/10 hover:border-white/20":"border-gray-200 hover:border-gray-300"),children:[jsx(Upload,{className:C("w-6 h-6 mx-auto mb-2",i?"text-[#6B7280]":"text-gray-400")}),jsxs("p",{className:C("text-sm",i?"text-[#9CA3AF]":"text-gray-500"),children:[n==="es"?"Suelta tus archivos aqu\xED para ":"Drop your files here to ",jsx("span",{className:C("underline",i?"text-white":"text-gray-700"),children:n==="es"?"subir":"upload"})]})]})]})]})]}),jsxs("div",{className:C("w-[280px] border-l flex flex-col",i?"border-white/10 bg-[#141619]":"border-gray-200 bg-gray-50"),children:[jsx("div",{className:C("px-4 py-3 border-b flex items-center justify-between",i?"border-white/10":"border-gray-200"),children:jsx("span",{className:C("font-medium",i?"text-white":"text-gray-900"),children:n==="es"?"Actividad":"Activity"})}),jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:jsxs("div",{className:C("text-sm text-center py-8",i?"text-[#6B7280]":"text-gray-400"),children:[jsx(MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),n==="es"?"Sin actividad reciente":"No recent activity"]})}),jsx("div",{className:C("p-3 border-t",i?"border-white/10":"border-gray-200"),children:jsx("div",{className:C("flex items-center gap-2 px-3 py-2 rounded-lg",i?"bg-white/5":"bg-white border border-gray-200"),children:jsx("input",{type:"text",placeholder:n==="es"?"Escribe un comentario...":"Write a comment...",className:C("flex-1 bg-transparent text-sm outline-none",i?"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:()=>b(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:C("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",i?"bg-[#1A1D25]":"bg-white"),children:[jsxs("div",{className:C("px-4 py-3 border-b flex items-center justify-between",i?"border-white/10":"border-gray-200"),children:[jsx("span",{className:C("font-medium",i?"text-white":"text-gray-900"),children:x.date.toLocaleDateString(n==="es"?"es-ES":"en-US",{weekday:"long",month:"long",day:"numeric"})}),jsx("button",{onClick:()=>b(null),className:C("p-1 rounded",i?"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(I=>jsxs("button",{onClick:()=>{b(null),g(I.task);},className:C("w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors",i?"hover:bg-white/5":"hover:bg-gray-50"),children:[jsx(tc,{task:I.task}),jsx("span",{className:C("text-sm truncate flex-1",i?"text-white":"text-gray-900"),children:I.title}),I.task.priority==="high"||I.task.priority==="urgent"?jsx(Flag,{className:"w-3.5 h-3.5 text-red-400"}):null]},I.id))})]})]})})]})}var si={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"},kn={dark:si,light:ii,neutral:li};function oc(e){return kn[e]||kn.dark}function Jf({stack:e,cards:t,renderCard:a,onCardClick:r,onToggleExpand:o,onUnstack:s,onDeleteStack:l,className:c}){let[p,n]=useState(false),m=useMemo(()=>t.filter(u=>e.cardIds.includes(u.id)),[t,e.cardIds]),d=useMemo(()=>{let u=m.length,v=new Set(m.flatMap(x=>x.assignedUserIds||[])).size,f=m.map(x=>x.priority).filter(Boolean),g=new Set(m.flatMap(x=>x.labels||[])).size;return {totalCards:u,uniqueAssignees:v,priorities:f,labels:g}},[m]),i=()=>{o?.(e.id);};return jsxs("div",{className:C("card-stack",!e.isExpanded&&"card-stack-collapsed",c),onMouseEnter:()=>n(true),onMouseLeave:()=>n(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:C("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:u=>{u.stopPropagation(),l?.(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:m.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:m.map(u=>jsxs("div",{className:"card-stack-card-wrapper",children:[a?jsx("div",{onClick:()=>r?.(u),children:a(u)}):jsxs("div",{className:"card-stack-default-card",onClick:()=>r?.(u),children:[jsx("h4",{children:u.title}),u.description&&jsxs("p",{children:[u.description.substring(0,100),"..."]})]}),jsx("button",{className:"card-stack-unstack-btn",onClick:v=>{v.stopPropagation(),s?.(e.id,u.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"})]})})]},u.id))})})]})}var sc={showIcons:true,showAvatars:true,groupByDay:true,useRelativeTime:true,compact:false};function xo(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 ko(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 ic(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 lc({events:e,filter:t,onFilterChange:a,onClearFilter:r,onEventClick:o,selectedEventId:s,config:l,className:c}){let p=useMemo(()=>({...sc,...l}),[l]),[n,m]=useState(new Set),d=useRef(null),i=useMemo(()=>{if(!p.groupByDay)return [{date:null,events:e}];let b=new Map;return e.forEach(h=>{let w=h.timestamp.toISOString().split("T")[0],D=b.get(w);D?D.push(h):b.set(w,[h]);}),Array.from(b.entries()).sort((h,w)=>w[0].localeCompare(h[0])).map(([h,w])=>({date:new Date(h),events:w.sort((D,N)=>N.timestamp.getTime()-D.timestamp.getTime())}))},[e,p.groupByDay]),{uniqueUsers:u,uniqueTypes:v}=useMemo(()=>{let b=new Set,h=new Set;return e.forEach(w=>{b.add(w.userId),h.add(w.type);}),{uniqueUsers:Array.from(b),uniqueTypes:Array.from(h)}},[e]),f=b=>{m(h=>{let w=new Set(h);return w.has(b)?w.delete(b):w.add(b),w});},g=b=>{let w=new Date().getTime()-b.getTime(),D=Math.floor(w/6e4),N=Math.floor(w/36e5),A=Math.floor(w/864e5);return D<1?"just now":D<60?`${D}m ago`:N<24?`${N}h ago`:A<7?`${A}d ago`:b.toLocaleDateString()},x=useMemo(()=>{let b=0;return t.types&&t.types.length>0&&b++,t.users&&t.users.length>0&&b++,t.dateRange&&b++,t.searchTerm&&b++,b},[t]);return useEffect(()=>{if(s&&d.current){let b=d.current.querySelector(`[data-event-id="${s}"]`);b&&b.scrollIntoView({behavior:"smooth",block:"center"});}},[s]),e.length===0?jsxs("div",{className:C("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:C("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:b=>{let h=b.target.value;a({...t,types:h?[h]:void 0});},children:[jsx("option",{value:"",children:"All Events"}),v.map(b=>jsxs("option",{value:b,children:[ko(b)," ",b.replace("_"," ")]},b))]}),u.length>1&&jsxs("select",{className:"history-timeline-filter-select",value:t.users?.[0]||"",onChange:b=>{let h=b.target.value;a({...t,users:h?[h]:void 0});},children:[jsx("option",{value:"",children:"All Users"}),u.map(b=>jsx("option",{value:b,children:b},b))]}),jsx("input",{type:"text",className:"history-timeline-filter-search",placeholder:"Search history...",value:t.searchTerm||"",onChange:b=>a({...t,searchTerm:b.target.value})})]}),x>0&&jsxs("button",{className:"history-timeline-filter-clear",onClick:r,children:["Clear filters (",x,")"]})]}),jsx("div",{className:"history-timeline-container",ref:d,children:i.map(b=>jsxs("div",{className:"history-timeline-group",children:[p.groupByDay&&b.date&&jsxs("div",{className:"history-timeline-day-header",children:[jsx("span",{className:"history-timeline-day-date",children:b.date.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),jsxs("span",{className:"history-timeline-day-count",children:[b.events.length," events"]})]}),jsx("div",{className:"history-timeline-events",children:b.events.map((h,w)=>{let D=n.has(h.id),N=s===h.id,A=ic(h.type);return jsxs("div",{"data-event-id":h.id,className:C("history-timeline-event",D&&"expanded",N&&"selected"),onClick:()=>o?.(h),children:[jsxs("div",{className:"history-timeline-line",children:[jsx("div",{className:"history-timeline-dot",style:{backgroundColor:A},children:p.showIcons&&jsx("span",{className:"history-timeline-dot-icon",children:ko(h.type)})}),w<b.events.length-1&&jsx("div",{className:"history-timeline-connector",style:{borderColor:A}})]}),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&&h.userAvatar&&jsx("img",{src:h.userAvatar,alt:h.userName||h.userId,className:"history-timeline-event-avatar"}),jsxs("div",{className:"history-timeline-event-description",children:[jsx("span",{className:"history-timeline-event-user",children:h.userName||h.userId}),jsx("span",{className:"history-timeline-event-action",children:xo(h)})]})]}),jsx("div",{className:"history-timeline-event-time",children:p.useRelativeTime?g(h.timestamp):h.timestamp.toLocaleString()})]}),Object.keys(h.changes).length>0&&jsxs("button",{className:"history-timeline-event-toggle",onClick:y=>{y.stopPropagation(),f(h.id);},children:[D?"\u25BC":"\u25B6"," Show changes"]}),D&&jsxs("div",{className:"history-timeline-event-changes",children:[Object.entries(h.changes).map(([y,R])=>jsxs("div",{className:"history-timeline-event-change",children:[jsxs("span",{className:"history-timeline-event-change-key",children:[y,":"]}),jsxs("div",{className:"history-timeline-event-change-values",children:[jsx("span",{className:"history-timeline-event-change-from",children:JSON.stringify(R.from)}),jsx("span",{className:"history-timeline-event-change-arrow",children:"\u2192"}),jsx("span",{className:"history-timeline-event-change-to",children:JSON.stringify(R.to)})]})]},y)),h.metadata&&Object.keys(h.metadata).length>0&&jsxs("div",{className:"history-timeline-event-metadata",children:[jsx("div",{className:"history-timeline-event-metadata-title",children:"Additional Info:"}),Object.entries(h.metadata).map(([y,R])=>jsxs("div",{className:"history-timeline-event-metadata-item",children:[jsxs("span",{className:"history-timeline-event-metadata-key",children:[y,":"]}),jsx("span",{className:"history-timeline-event-metadata-value",children:JSON.stringify(R)})]},y))]})]})]})]},h.id)})})]},b.date?.toISOString()||"all"))})]})}function cc({replayState:e,events:t,onStartReplay:a,onStopReplay:r,onTogglePlayback:o,onPrevious:s,onNext:l,onGoToEvent:c,onSpeedChange:p,className:n}){let m=[.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:C("history-replay-empty",n),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:C("history-replay",n),children:[jsxs("div",{className:"history-replay-current-event",children:[jsx("div",{className:"history-replay-event-icon",children:d&&ko(d.type)}),jsxs("div",{className:"history-replay-event-info",children:[jsx("div",{className:"history-replay-event-description",children:d&&xo(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:u=>c(parseInt(u.target.value))}),jsx("div",{className:"history-replay-progress-fill",style:{width:`${i}%`}}),jsx("div",{className:"history-replay-progress-markers",children:t.map((u,v)=>jsx("div",{className:C("history-replay-progress-marker",v===e.currentIndex&&"active"),style:{left:`${v/(e.totalEvents-1)*100}%`},onClick:()=>c(v),title:xo(u)},u.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:l,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:m.map(u=>jsxs("button",{className:C("history-replay-speed-btn",e.speed===u&&"active"),onClick:()=>p(u),children:[u,"x"]},u))})]}),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(u=>jsx("span",{className:"history-replay-card-preview-label-tag",children:u},u))})]})]})]})]}):jsxs("div",{className:C("history-replay-start",n),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 di(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 ci(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 pc(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 mc(e){return ["blocks","blocked_by","depends_on","required_by","parent_of","child_of"].includes(e)}function rh(e,t,a,r,o,s=100){let l=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(l.map(p=>[p.id,p]));for(let p=0;p<s;p++){let n=1-p/s;l.forEach(m=>{let d=a/2,i=r/2;m.vx+=(d-m.x)*o.centerForce*n,m.vy+=(i-m.y)*o.centerForce*n,l.forEach(u=>{if(m.id===u.id)return;let v=m.x-u.x,f=m.y-u.y,g=Math.sqrt(v*v+f*f)||1,x=o.chargeStrength*n/(g*g);m.vx+=v/g*x,m.vy+=f/g*x;});}),t.forEach(m=>{let d=c.get(typeof m.source=="string"?m.source:m.source.id),i=c.get(typeof m.target=="string"?m.target:m.target.id);if(!d||!i)return;let u=i.x-d.x,v=i.y-d.y,f=Math.sqrt(u*u+v*v)||1,g=(f-o.linkDistance)/f*o.forceStrength*n;d.vx+=u*g,d.vy+=v*g,i.vx-=u*g,i.vy-=v*g;}),l.forEach(m=>{m.fx!==null&&m.fx!==void 0?(m.x=m.fx,m.vx=0):m.x+=m.vx,m.fy!==null&&m.fy!==void 0?(m.y=m.fy,m.vy=0):m.y+=m.vy,m.x=Math.max(o.nodeSize,Math.min(a-o.nodeSize,m.x)),m.y=Math.max(o.nodeSize,Math.min(r-o.nodeSize,m.y)),m.vx*=.9,m.vy*=.9;});}return l}function uc({nodes:e,edges:t,config:a,filter:r,onFilterChange:o,criticalPath:s,stats:l,onInteraction:c,className:p}){let n=useRef(null),[m,d]=useState([]),[i,u]=useState(null),[v,f]=useState(null),[g,x]=useState(null),[b,h]=useState(1),[w,D]=useState({x:0,y:0});useEffect(()=>{if(e.length===0)return;let P=rh(e,t,a.width,a.height,a,150);d(P);},[e,t,a]);let N=useCallback((P,H)=>{a.enableDragging&&(H.stopPropagation(),u(P));},[a.enableDragging]),A=useCallback(P=>{if(!i||!n.current)return;let X=n.current.getBoundingClientRect(),be=(P.clientX-X.left-w.x)/b,ke=(P.clientY-X.top-w.y)/b;d(Ae=>Ae.map(Fe=>Fe.id===i?{...Fe,x:be,y:ke,fx:be,fy:ke}:Fe));},[i,b,w]),y=useCallback(()=>{u(null);},[]),R=useCallback((P,H)=>{H.stopPropagation(),c?.({type:"node-click",node:P,position:{x:H.clientX,y:H.clientY}});},[c]),T=useCallback((P,H)=>{H.stopPropagation(),c?.({type:"edge-click",edge:P,position:{x:H.clientX,y:H.clientY}});},[c]),k=useCallback(P=>{let H=m.find(X=>X.id===P);return H?{x:H.x,y:H.y}:{x:0,y:0}},[m]),B=useCallback(P=>{if(P.onCriticalPath)return "#ef4444";switch(a.colorScheme){case "status":return P.card.columnId==="done"?"#10b981":"#3b82f6";case "priority":let H=P.card.priority;return H==="URGENT"?"#ef4444":H==="HIGH"?"#f59e0b":H==="MEDIUM"?"#3b82f6":"#6b7280";case "assignee":return P.card.assigneeId?"#8b5cf6":"#6b7280";default:return "#3b82f6"}},[a.colorScheme]);return e.length===0?jsxs("div",{className:C("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:C("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:l.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:l.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:()=>h(P=>Math.min(P+.2,3)),children:"+"}),jsxs("span",{className:"relationships-graph-zoom-value",children:[Math.round(b*100),"%"]}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>h(P=>Math.max(P-.2,.5)),children:"\u2212"}),jsx("button",{className:"relationships-graph-zoom-btn",onClick:()=>{h(1),D({x:0,y:0});},children:"Reset"})]})]}),jsx("div",{className:"relationships-graph-legend",children:Array.from(new Set(t.map(P=>P.type))).map(P=>jsxs("div",{className:"relationships-graph-legend-item",children:[jsx("div",{className:"relationships-graph-legend-color",style:{background:di(P)}}),jsxs("span",{className:"relationships-graph-legend-label",children:[pc(P)," ",ci(P)]})]},P))}),jsxs("svg",{ref:n,className:"relationships-graph-canvas",width:a.width,height:a.height,onMouseMove:A,onMouseUp:y,onMouseLeave:y,children:[jsxs("g",{transform:`translate(${w.x}, ${w.y}) scale(${b})`,children:[jsx("g",{className:"relationships-graph-edges",children:t.map(P=>{let H=k(typeof P.source=="string"?P.source:P.source.id),X=k(typeof P.target=="string"?P.target:P.target.id),be=mc(P.type),ke=g===P.id,Ae=P.onCriticalPath;return jsxs("g",{className:C("relationships-graph-edge",ke&&"hovered",Ae&&"critical"),onMouseEnter:()=>x(P.id),onMouseLeave:()=>x(null),onClick:Fe=>T(P,Fe),children:[jsx("line",{x1:H.x,y1:H.y,x2:X.x,y2:X.y,stroke:di(P.type),strokeWidth:Ae?a.edgeWidth*2:a.edgeWidth,strokeOpacity:ke?1:.6,markerEnd:be?"url(#arrowhead)":void 0}),a.showEdgeLabels&&ke&&jsx("text",{x:(H.x+X.x)/2,y:(H.y+X.y)/2,className:"relationships-graph-edge-label",textAnchor:"middle",children:ci(P.type)})]},P.id)})}),jsx("g",{className:"relationships-graph-nodes",children:m.map(P=>{let H=v===P.id,X=P.onCriticalPath;return jsxs("g",{className:C("relationships-graph-node",H&&"hovered",X&&"critical"),transform:`translate(${P.x}, ${P.y})`,onMouseDown:be=>N(P.id,be),onMouseEnter:()=>f(P.id),onMouseLeave:()=>f(null),onClick:be=>R(P,be),children:[jsx("circle",{r:X?a.nodeSize*1.2:a.nodeSize,fill:B(P),stroke:X?"#fbbf24":"#ffffff",strokeWidth:X?3:2,opacity:H?1:.9}),a.showLabels&&jsx("text",{y:a.nodeSize+20,className:"relationships-graph-node-label",textAnchor:"middle",children:P.card.title.length>20?P.card.title.substring(0,20)+"...":P.card.title})]},P.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 hc({isOpen:e,onClose:t,onPlanGenerated:a,onGeneratePlan:r,isLoading:o}){let[s,l]=useState(""),[c,p]=useState(false),[n,m]=useState(null),[d,i]=useState(null),u=useRef(null),v=c||o;useEffect(()=>{e&&u.current&&u.current.focus();},[e]),useEffect(()=>{let b=h=>{h.key==="Escape"&&!v&&f();};if(e)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,v]);let f=()=>{v||(l(""),m(null),i(null),t());},g=async()=>{if(!(!s.trim()||v)){p(true),m(null),i(null);try{let b=await r(s.trim());i(b);}catch(b){m(b instanceof Error?b.message:"Failed to generate plan");}finally{p(false);}}},x=()=>{d&&(a(d),f());};return e?jsxs(rt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:f}),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:b=>b.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:f,disabled:v,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((b,h)=>jsx("div",{className:"px-3 py-1.5 rounded-lg bg-white/5 border border-white/20 text-sm text-white/80",children:b.title},h))})]}),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((b,h)=>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:b.title}),b.description&&jsx("p",{className:"text-xs text-white/60 mt-1 line-clamp-2",children:b.description})]}),b.priority&&jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${b.priority==="URGENT"?"bg-red-500/20 text-red-400":b.priority==="HIGH"?"bg-orange-500/20 text-orange-400":b.priority==="MEDIUM"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:b.priority})]})},h)),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:u,value:s,onChange:b=>l(b.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:v}),jsx("p",{className:"text-xs text-white/50 mt-2",children:"Be as specific as possible. Include features, technologies, and any special requirements."})]}),n&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:n}),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((b,h)=>jsx("button",{onClick:()=>l(b),disabled:v,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:b},h))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:v&&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:f,disabled:v,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:x,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:g,disabled:!s.trim()||v,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:v?"Generating...":"Generate Plan"})]})]})]})})]}):null}var pi={"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 nh={hobby:{requestsPerMonth:50,maxConcurrent:1,maxTokensPerRequest:4096},pro:{requestsPerMonth:500,maxConcurrent:3,maxTokensPerRequest:8192},enterprise:{requestsPerMonth:2e3,maxConcurrent:10,maxTokensPerRequest:16384}},sh={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 ih(e,t,a){let r=pi[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 mi=class{constructor(){this.operations=[];this.listeners=[];}record(t){let a=ih(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),l=a.reduce((d,i)=>d+i.outputTokens,0),c=a.filter(d=>d.success),p=a.reduce((d,i)=>d+i.duration,0),n={},m={};return a.forEach(d=>{n[d.feature]=(n[d.feature]||0)+1,m[d.feature]=(m[d.feature]||0)+d.cost;}),{totalOperations:r,totalCost:o,totalInputTokens:s,totalOutputTokens:l,operationsByFeature:n,costsByFeature:m,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,l=new Date;a==="month"?l.setMonth(s.getMonth()-1):l.setDate(s.getDate()-1);let c=this.operations.filter(m=>m.timestamp>=l).length,p=Math.max(0,o-c),n=c/o*100;return {used:c,limit:o,remaining:p,percentUsed:n,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)}},Dr=new mi;function vc({isOpen:e,onClose:t,planTier:a="hobby"}){let[r,o]=useState(Dr.getStats()),[s,l]=useState(Dr.checkLimit(a));if(useEffect(()=>{if(!e)return;let p=setInterval(()=>{o(Dr.getStats()),l(Dr.checkLimit(a));},1e3);return ()=>clearInterval(p)},[e,a]),useEffect(()=>{let p=n=>{n.key==="Escape"&&t();};if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,t]),!e)return null;let c=Dr.getRecentOperations(5);return jsxs(rt,{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,n])=>{let m=r.costsByFeature[p]||0,d=r.totalOperations>0?n/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:[n," ops"]}),jsx("span",{className:"text-xs font-semibold text-green-400",children:wo(m)})]})]}),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 wc({isOpen:e,onClose:t,onTasksGenerated:a,onGenerateTasks:r,isLoading:o,projectName:s}){let[l,c]=useState(""),[p,n]=useState(""),[m,d]=useState(""),[i,u]=useState(false),[v,f]=useState(null),[g,x]=useState(null),[b,h]=useState(null),w=useRef(null),D=i||o;useEffect(()=>{e&&w.current&&w.current.focus();},[e]),useEffect(()=>{let T=k=>{k.key==="Escape"&&!D&&N();};if(e)return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[e,D]);let N=()=>{D||(c(""),n(""),d(""),f(null),x(null),h(null),t());},A=async()=>{if(!(!l.trim()||D)){u(true),f(null),x(null),h(null);try{let T=await r({prompt:l.trim(),projectName:s||"Mi Proyecto",startDate:p||void 0,endDate:m||void 0});x(T.tasks.tasks),h({from_cache:T.from_cache,tokens_used:T.tokens_used,mock_mode:T.mock_mode,similarity:T.similarity,tokens_saved:T.tokens_saved});}catch(T){f(T instanceof Error?T.message:"Failed to generate tasks");}finally{u(false);}}},y=()=>{g&&(a(g),N());};if(!e)return null;let R=b?.similarity?((b.similarity||0)*100).toFixed(0):"0";return jsxs(rt,{children:[jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[100000]",onClick:N}),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:T=>T.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:N,disabled:D,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:g?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:[b?.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"}),b?.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 (",R,"% 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:[b?.tokens_used||0," tokens"]}),b?.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:[b.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:[g.length," tasks"]})]}),jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:g.map((T,k)=>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:["#",k+1]}),jsx("p",{className:"text-sm font-medium text-white/90",children:T.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"})]}),T.start," \u2192 ",T.end]}),jsxs("span",{children:[T.duration," days"]}),T.dependencies.length>0&&jsxs("span",{className:"text-blue-400",children:["Depends: ",T.dependencies.join(", ")]})]})]}),jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${T.priority==="high"?"bg-red-500/20 text-red-400":T.priority==="medium"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:T.priority})]})},T.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:w,value:l,onChange:T=>c(T.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:D}),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:T=>n(T.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:D})]}),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:m,onChange:T=>d(T.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:D})]})]}),v&&jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm",children:v}),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((T,k)=>jsx("button",{onClick:()=>c(T),disabled:D,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:T},k))})]})]})}),jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex items-center justify-between",children:[jsx("div",{children:D&&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:N,disabled:D,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"}),g?jsx("button",{onClick:y,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:A,disabled:!l.trim()||D,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:D?"Generating...":"Generate Tasks"})]})]})]})})]})}function Tn({initialBoard:e,onPersist:t}){let[a,r]=useState(e),o=useCallback(g=>{t&&Mo(()=>Promise.resolve(t(g)),{maxAttempts:3,initialDelay:1e3,onRetry:(x,b,h)=>{console.warn(`Retry attempt ${b} after ${h}ms: ${x.message}`);}}).then(x=>{x.success||console.error(`Failed to persist board after ${x.attempts} attempts:`,x.error);});},[t]),s=useCallback(async(g,x,b)=>{r(h=>{let w=h.cards.find(T=>T.id===g);if(!w)return h;let D=w.columnId,N={...w,columnId:x,position:b},A=h.cards.map(T=>T.id===g?N:T),y=h.columns.map(T=>{if(T.id===D)return {...T,cardIds:T.cardIds.filter(k=>k!==g)};if(T.id===x){let k=A.filter(B=>B.columnId===x).sort((B,P)=>B.position-P.position);return {...T,cardIds:k.map(B=>B.id)}}return T}),R={...h,cards:A,columns:y};return o(R),R});},[o]),l=useCallback(async(g,x)=>{r(b=>{let h=b.cards.map(D=>D.id===g?{...D,...x}:D),w={...b,cards:h};return o(w),w});},[o]),c=useCallback(async g=>{let x=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(b=>{let h={...g,id:x},w=b.columns.map(N=>N.id===g.columnId?{...N,cardIds:[...N.cardIds,x]}:N),D={...b,cards:[...b.cards,h],columns:w};return o(D),D});},[o]),p=useCallback(async g=>{r(x=>{let b=x.cards.find(N=>N.id===g);if(!b)return x;let h=x.cards.filter(N=>N.id!==g),w=x.columns.map(N=>N.id===b.columnId?{...N,cardIds:N.cardIds.filter(A=>A!==g)}:N),D={...x,cards:h,columns:w};return o(D),D});},[o]),n=useCallback(async g=>{let x=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;r(b=>{let h={...g,id:x,cardIds:[]},w={...b,columns:[...b.columns,h]};return o(w),w});},[o]),m=useCallback(async(g,x)=>{r(b=>{let h=b.columns.map(D=>D.id===g?{...D,...x}:D),w={...b,columns:h};return o(w),w});},[o]),d=useCallback(async g=>{r(x=>{let b=x.cards.filter(D=>D.columnId!==g),h=x.columns.filter(D=>D.id!==g),w={...x,cards:b,columns:h};return o(w),w});},[o]),i=useCallback(g=>{let x=`card-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return c(g),x},[c]),u=useCallback(g=>{let x=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return n(g),x},[n]),v=useCallback(()=>{r(g=>{let x={...g,cards:[],columns:[]};return o(x),x});},[o]);return {board:a,callbacks:{onCardMove:s,onCardUpdate:l,onCardCreate:c,onCardDelete:p,onColumnCreate:n,onColumnUpdate:m,onColumnDelete:d},setBoard:r,helpers:{addCard:i,addColumn:u,deleteCard:p,deleteColumn:d,clearBoard:v}}}function Tc({initialData:e,availableUsers:t=[],onSave:a}){let{board:r,callbacks:o,helpers:s}=Tn({initialBoard:e,onPersist:a}),l=useMemo(()=>({addCard:(p,n,m={})=>{s.addCard({title:n,columnId:p,position:r.cards.filter(d=>d.columnId===p).length,...m});},addColumn:(p,n)=>{let m=r.columns.length>0?Math.max(...r.columns.map(d=>d.position)):0;s.addColumn({title:p,position:n??m+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:l}}var Co={dateFilter:"all",priorities:[],assignees:[],labels:[],columns:[],search:""},Nc={by:"none",order:"asc"};function Sc({initialFilters:e={},initialSort:t={},currentUserId:a}={}){let[r,o]=useState({...Co,...e}),[s,l]=useState({...Nc,...t}),c=useCallback(f=>{o(g=>({...g,...f}));},[]),p=useCallback(f=>{l(g=>({...g,...f}));},[]),n=useCallback(()=>{o(Co),l(Nc);},[]),m=useCallback(()=>{a&&o({...Co,assignees:[a]});},[a]),d=useCallback(()=>{o({...Co,dateFilter:"overdue"});},[]),i=useCallback(()=>{o({...Co,priorities:["HIGH","URGENT"]});},[]),u=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]),v=useCallback(f=>{let g=[...f];if(r.search){let x=r.search.toLowerCase();g=g.filter(b=>b.title.toLowerCase().includes(x)||b.description?.toLowerCase().includes(x));}if(r.dateFilter!=="all"){let x=new Date,b=x.getFullYear(),h=String(x.getMonth()+1).padStart(2,"0"),w=String(x.getDate()).padStart(2,"0"),D=`${b}-${h}-${w}`;g=g.filter(N=>{if(!N.endDate&&!N.dueDate)return false;let A=N.endDate||N.dueDate;if(!A)return false;let y;if(typeof A=="string")y=A.split("T")[0]||A;else {let R=A.getUTCFullYear(),T=String(A.getUTCMonth()+1).padStart(2,"0"),k=String(A.getUTCDate()).padStart(2,"0");y=`${R}-${T}-${k}`;}switch(r.dateFilter){case "overdue":return y<D;case "today":return y===D;case "this-week":let R=new Date(D+"T00:00:00"),T=new Date(y+"T00:00:00"),k=new Date(R);return k.setDate(k.getDate()+7),T>=R&&T<=k;case "custom":if(r.dateRange){let B=typeof A=="string"?new Date(A):A;return B>=r.dateRange.start&&B<=r.dateRange.end}return true;default:return true}});}return r.priorities.length>0&&(g=g.filter(x=>x.priority&&r.priorities.includes(x.priority))),r.assignees.length>0&&(g=g.filter(x=>(x.assignedUserIds||(x.assigneeId?[x.assigneeId]:[])).some(h=>r.assignees.includes(h)))),r.labels.length>0&&(g=g.filter(x=>x.labels&&x.labels.some(b=>r.labels.includes(b)))),r.columns.length>0&&(g=g.filter(x=>r.columns.includes(x.columnId))),s.by!=="none"&&g.sort((x,b)=>{let h=0;switch(s.by){case "created":let w=x.createdAt?new Date(x.createdAt).getTime():0,D=b.createdAt?new Date(b.createdAt).getTime():0;h=w-D;break;case "priority":let N={URGENT:4,HIGH:3,MEDIUM:2,LOW:1},A=N[x.priority||"LOW"],y=N[b.priority||"LOW"];h=A-y;break;case "dueDate":let R=x.endDate||x.dueDate,T=b.endDate||b.dueDate;if(!R)return 1;if(!T)return -1;let k=typeof R=="string"?new Date(R).getTime():R.getTime(),B=typeof T=="string"?new Date(T).getTime():T.getTime();h=k-B;break;case "title":h=x.title.localeCompare(b.title);break;case "estimate":let P=x.estimatedTime||0,H=b.estimatedTime||0;h=P-H;break;default:h=0;}return s.order==="asc"?h:-h}),g},[r,s]);return {filters:r,sort:s,setFilters:c,setSort:p,resetFilters:n,filterMyTasks:m,filterOverdue:d,filterHighPriority:i,applyFilters:v,hasActiveFilters:u}}var Pc,Mc;if(typeof window<"u")try{let e=So("ai");Pc=e.generateObject,Mc=e.generateText;}catch{}function Ac(e={}){let[t,a]=useState(false),[r,o]=useState(null),s=!!(Pc&&Mc&&e.apiKey),l=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 u=i instanceof Error?i:new Error("Failed to generate plan");throw o(u),u}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 u=i instanceof Error?i:new Error("Failed to suggest assignee");throw o(u),u}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 u=i instanceof Error?i:new Error("Failed to predict risks");throw o(u),u}finally{a(false);}},[s]),n=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 u=i instanceof Error?i:new Error("Failed to generate subtasks");throw o(u),u}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("Estimating effort for:",d.title),{hours:8,confidence:.75}}catch(i){let u=i instanceof Error?i:new Error("Failed to estimate effort");throw o(u),u}finally{a(false);}},[s]);return {onGeneratePlan:l,onSuggestAssignee:c,onPredictRisks:p,onGenerateSubtasks:n,onEstimateEffort:m,isAvailable:s,isLoading:t,error:r}}function gi(){let[e,t]=useState(()=>selectionStore.getState());useEffect(()=>selectionStore.subscribe(o=>{t(o);}),[]);let a=useCallback(r=>{selectionStore.setState(r);},[]);return [e,a]}function Ic(e){let{cards:t}=e,[a,r]=gi(),o=useCallback(d=>a.selectedCardIds.includes(d),[a.selectedCardIds]),s=useCallback((d,i)=>{if(!i){r({selectedCardIds:[d],lastSelectedCardId:d});return}let u=i.ctrlKey||i.metaKey,v=i.shiftKey;if(u)a.selectedCardIds.includes(d)?r({selectedCardIds:a.selectedCardIds.filter(f=>f!==d),lastSelectedCardId:a.lastSelectedCardId}):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});else if(v&&a.lastSelectedCardId){let f=t.find(x=>x.id===d),g=t.find(x=>x.id===a.lastSelectedCardId);if(f&&g&&f.columnId===g.columnId){let x=t.filter(y=>y.columnId===f.columnId).sort((y,R)=>y.position-R.position),b=x.findIndex(y=>y.id===a.lastSelectedCardId),h=x.findIndex(y=>y.id===d),[w,D]=b<h?[b,h]:[h,b],N=x.slice(w,D+1).map(y=>y.id),A=Array.from(new Set([...a.selectedCardIds,...N]));r({selectedCardIds:A,lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});}else r({selectedCardIds:[d],lastSelectedCardId:d});},[t,a,r]),l=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]),n=useCallback(d=>{a.selectedCardIds.includes(d)?l(d):r({selectedCardIds:[...a.selectedCardIds,d],lastSelectedCardId:d});},[a,l,r]),m=useCallback(()=>t.filter(d=>a.selectedCardIds.includes(d.id)),[t,a.selectedCardIds]);return {selectedCardIds:a.selectedCardIds,lastSelectedCardId:a.lastSelectedCardId,isCardSelected:o,selectCard:s,deselectCard:l,clearSelection:c,selectAll:p,toggleCard:n,getSelectedCards:m}}var Lc={enableAutoStacking:true,autoStackConfidenceThreshold:.7,minCardsPerStack:2,enableManualStacking:true,showStackSummaries:true,animationDuration:200};function Fc(e){let{cards:t,config:a,aiService:r}=e,o=useMemo(()=>({...Lc,...a}),[a]),[s,l]=useState([]),c=useCallback((f,g,x,b,h)=>{if(g.length<o.minCardsPerStack){console.warn(`Cannot create stack: minimum ${o.minCardsPerStack} cards required`);return}let w={id:`stack-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:f,cardIds:g,columnId:x,strategy:b,color:h,isExpanded:true,position:s.filter(D=>D.columnId===x).length,createdAt:new Date};l(D=>[...D,w]);},[o.minCardsPerStack,s]),p=useCallback(f=>{l(g=>g.filter(x=>x.id!==f));},[]),n=useCallback(f=>{l(g=>g.map(x=>x.id===f?{...x,isExpanded:!x.isExpanded}:x));},[]),m=useCallback((f,g)=>{l(x=>x.map(b=>b.id===f&&!b.cardIds.includes(g)?{...b,cardIds:[...b.cardIds,g]}:b));},[]),d=useCallback((f,g)=>{l(x=>x.map(b=>{if(b.id===f){let h=b.cardIds.filter(w=>w!==g);return h.length<o.minCardsPerStack?null:{...b,cardIds:h}}return b}).filter(b=>b!==null));},[o.minCardsPerStack]),i=useCallback(f=>s.filter(g=>g.columnId===f).sort((g,x)=>g.position-x.position),[s]),u=useCallback(async f=>{let g=t.filter(D=>D.columnId===f);if(g.length<o.minCardsPerStack*2)return [];let x=[],b=new Map;g.forEach(D=>{D.labels&&D.labels.length>0&&D.labels.forEach(N=>{b.has(N)||b.set(N,[]),b.get(N).push(D);});}),b.forEach((D,N)=>{D.length>=o.minCardsPerStack&&x.push({stack:{title:`\u{1F4CC} ${N}`,cardIds:D.map(A=>A.id),columnId:f,strategy:"labels",color:"#3b82f6"},reason:`${D.length} cards with label "${N}"`,confidence:.85});});let h=new Map;g.forEach(D=>{D.assignedUserIds&&D.assignedUserIds.length>0&&D.assignedUserIds.forEach(N=>{h.has(N)||h.set(N,[]),h.get(N).push(D);});}),h.forEach((D,N)=>{D.length>=o.minCardsPerStack&&x.push({stack:{title:`\u{1F464} Assigned to user-${N.slice(-4)}`,cardIds:D.map(A=>A.id),columnId:f,strategy:"assignee",color:"#8b5cf6"},reason:`${D.length} cards assigned to the same user`,confidence:.8});});let w=new Map;if(g.forEach(D=>{D.priority&&(w.has(D.priority)||w.set(D.priority,[]),w.get(D.priority).push(D));}),w.forEach((D,N)=>{if(D.length>=o.minCardsPerStack){let A={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}",urgent:"\u{1F6A8}"}[N.toLowerCase()]||"\u26AA";x.push({stack:{title:`${A} ${N} Priority`,cardIds:D.map(y=>y.id),columnId:f,strategy:"priority",color:N==="high"||N==="urgent"?"#ef4444":"#10b981"},reason:`${D.length} cards with ${N} priority`,confidence:.75});}}),r&&o.enableAutoStacking)for(let D of g){let A=(await r.findSimilar(D,g)).filter(y=>y.similarity>=o.autoStackConfidenceThreshold);if(A.length>=o.minCardsPerStack-1){let y=[D.id,...A.map(T=>T.card.id)],R=A.reduce((T,k)=>T+k.similarity,0)/A.length;x.push({stack:{title:`\u2728 Similar to "${D.title.substring(0,30)}${D.title.length>30?"...":""}"`,cardIds:y,columnId:f,strategy:"ai-similarity",color:"#f59e0b"},reason:`AI detected ${A.length+1} similar tasks`,confidence:R});}}return x.filter(D=>D.confidence>=o.autoStackConfidenceThreshold).sort((D,N)=>N.confidence-D.confidence).slice(0,5)},[t,o,r]),v=useCallback(f=>{c(f.stack.title,f.stack.cardIds,f.stack.columnId,f.stack.strategy,f.stack.color);},[c]);return useEffect(()=>{o.enableAutoStacking&&s.length===0&&new Set(t.map(g=>g.columnId)).forEach(async g=>{let x=await u(g),b=x[0];x.length>0&&b&&b.confidence>=.9&&v(b);});},[]),{stacks:s,createStack:c,deleteStack:p,toggleStack:n,addToStack:m,removeFromStack:d,getStacksForColumn:i,getSuggestions:u,applySuggestion:v,config:o}}var Bc=createContext(null);function Rc({children:e,initialData:t,onStateChange:a}){let r=useRef();if(!r.current){let s=new Map,l=new Map;t?.columns?.forEach(p=>{let{Column:n}=So("@libxai/core");s.set(p.id,new n(p));}),t?.cards?.forEach(p=>{let{Card:n}=So("@libxai/core");l.set(p.id,new n(p));});let c=null;if(t?.board){let{Board:p}=So("@libxai/core");c=new p(t.board);}r.current=new BoardStore({board:c,columns:s,cards:l});}let o=r.current;return useEffect(()=>{if(a)return o.subscribeAll(s=>{a(o.getState());})},[o,a]),jsx(Bc.Provider,{value:{store:o},children:e})}function Dn(){let e=useContext(Bc);if(!e)throw new Error("useBoardStore must be used within BoardProvider");return e.store}function Do(){let e=Dn(),[t,a]=useState(e.getBoard()),[r,o]=useState(e.getAllColumns()),[s,l]=useState(e.getAllCards());useEffect(()=>e.subscribeAll(()=>{a(e.getBoard()),o(e.getAllColumns()),l(e.getAllCards());}),[e]);let c=useCallback(b=>{e.updateBoard(b);},[e]),p=useCallback(b=>{e.addColumn(b);},[e]),n=useCallback((b,h)=>{e.updateColumn(b,h);},[e]),m=useCallback(b=>{e.deleteColumn(b);},[e]),d=useCallback(b=>e.getColumn(b),[e]),i=useCallback(b=>{e.addCard(b);},[e]),u=useCallback((b,h)=>{e.updateCard(b,h);},[e]),v=useCallback(b=>{e.deleteCard(b);},[e]),f=useCallback((b,h,w)=>{e.moveCard(b,h,w);},[e]),g=useCallback(b=>e.getCard(b),[e]),x=useCallback(b=>e.getCardsByColumn(b),[e]);return {board:t,columns:r,cards:s,updateBoard:c,addColumn:p,updateColumn:n,deleteColumn:m,getColumn:d,addCard:i,updateCard:u,deleteCard:v,moveCard:f,getCard:g,getCardsByColumn:x}}function zc(e){let{cards:t}=Do();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 $c(e="position",t="asc"){let{cards:a}=Do();return useMemo(()=>[...a].sort((o,s)=>{let l=0;switch(e){case "title":l=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,n=s.priority?c[s.priority]:0;l=p-n;break}case "createdAt":l=o.createdAt.getTime()-s.createdAt.getTime();break;case "updatedAt":l=o.updatedAt.getTime()-s.updatedAt.getTime();break;case "position":l=o.position-s.position;break}return t==="asc"?l:-l}),[a,e,t])}var Nn=class{constructor(){this.plugins=new Map;this.enabled=new Set;this.config=new Map;this.context=null;this.pluginLogger=Hi.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 l=s[t];if(typeof l=="function")try{let c=await Promise.resolve(l.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(l=>{this.pluginLogger.error(`Plugin hook failed: ${o.id}.${t}`,l,{plugin:o.id,hook:t});}));}await Promise.all(r);}},Th=new Nn;function Wc({items:e,height:t,estimateSize:a,renderItem:r,className:o="",overscan:s=5,horizontal:l=false,gap:c=0,getItemKey:p}){let n=useRef(null),m=useVirtualizer({count:e.length,getScrollElement:()=>n.current,estimateSize:()=>a,overscan:s,horizontal:l,gap:c}),d=m.getVirtualItems(),i={height:typeof t=="number"?`${t}px`:t,width:"100%",overflow:"auto",position:"relative"},u=l?{width:`${m.getTotalSize()}px`,height:"100%",position:"relative"}:{height:`${m.getTotalSize()}px`,width:"100%",position:"relative"};return jsx("div",{ref:n,style:i,className:o,children:jsx("div",{style:u,children:d.map(v=>{let f=e[v.index];if(!f)return null;let g=p?p(f,v.index):v.index,x={position:"absolute",top:l?0:v.start,left:l?v.start:0,width:l?v.size:"100%",height:l?"100%":v.size};return jsx("div",{style:x,"data-index":v.index,children:r(f,v.index)},g)})})})}function Hc(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 _c({items:e,height:t,width:a="100%",estimateColumnWidth:r,renderColumn:o,className:s="",overscan:l=3,gap:c=16,getItemKey:p,horizontal:n=true}){let m=useRef(null),d=useVirtualizer({horizontal:n,count:e.length,getScrollElement:()=>m.current,estimateSize:()=>r,overscan:l,gap:c}),i=d.getVirtualItems(),u={height:typeof t=="number"?`${t}px`:t,width:typeof a=="number"?`${a}px`:a,overflow:"auto",position:"relative"},v={width:`${d.getTotalSize()}px`,height:"100%",position:"relative"};return jsx("div",{ref:m,style:u,className:s,children:jsx("div",{style:v,children:i.map(f=>{let g=e[f.index];if(!g)return null;let x=p?p(g,f.index):f.index,b={position:"absolute",top:0,left:f.start,width:f.size,height:"100%"};return jsx("div",{style:b,"data-index":f.index,children:o(g,f.index)},x)})})})}function Vc(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 jc(e,t=10){return e>t}var yi={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},xi={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},wi={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},Ci={base:0,dropdown:1e3,sticky:1020,fixed:1030,modalBackdrop:1040,modal:1050,popover:1060,tooltip:1070},Ti={instant:0,fastest:75,faster:100,fast:150,normal:200,slow:300,slower:400,slowest:500},Di={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)"},Ni={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)"},Si={0:0,5:.05,10:.1,20:.2,30:.3,40:.4,50:.5,60:.6,70:.7,80:.8,90:.9,100:1},Ei={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}},Pi={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}},Sn={spacing:yi,borderRadius:vi,fontSize:xi,fontWeight:ki,lineHeight:wi,zIndex:Ci,duration:Ti,easing:Di,shadows:Ni,opacity:Si,kanban:Ei,gantt:Pi};function Kc(e,t,a){return e[t]??a}function Mi(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)?Mi(o,s,a):(typeof o=="string"||typeof o=="number")&&(a[s]=o);}return a}function Sh(e){return typeof e=="number"?e>0&&e<1e3?`${e}px`:e.toString():e}function Ai(e="asakaa"){let t=Mi(Sn),a=[];for(let[r,o]of Object.entries(t)){let s=`--${e}-${r}`,l=Sh(o);a.push(` ${s}: ${l};`);}return `:root {
390
390
  ${a.join(`
391
391
  `)}
392
- }`}function No(e,t="asakaa"){let a=[],r=Ai(e);for(let[o,s]of Object.entries(r)){let l=`--${t}-color-${o}`;a.push(` ${l}: ${s};`);}return `:root {
392
+ }`}function No(e,t="asakaa"){let a=[],r=Mi(e);for(let[o,s]of Object.entries(r)){let l=`--${t}-color-${o}`;a.push(` ${l}: ${s};`);}return `:root {
393
393
  ${a.join(`
394
394
  `)}
395
- }`}var Mn={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"}},Li={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"}},Fi={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 Bi(e=Mn,t="asakaa"){let a=Ii(t),r=No(e,t);return `${a}
395
+ }`}var En={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"}},Ii={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"}},Li={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 Fi(e=En,t="asakaa"){let a=Ai(t),r=No(e,t);return `${a}
396
396
 
397
- ${r}`}function Vc(){return `/**
397
+ ${r}`}function Yc(){return `/**
398
398
  * ASAKAA Design Tokens
399
399
  * Auto-generated from design-tokens.ts
400
400
  * Do not edit this file directly
401
401
  */
402
402
 
403
- ${Bi(Mn)}
403
+ ${Fi(En)}
404
404
 
405
405
  /* Light theme */
406
406
  [data-theme="light"] {
407
- ${No(Li,"asakaa").split(`
407
+ ${No(Ii,"asakaa").split(`
408
408
  `).slice(1,-1).join(`
409
409
  `)}
410
410
  }
411
411
 
412
412
  /* Neutral theme */
413
413
  [data-theme="neutral"] {
414
- ${No(Fi,"asakaa").split(`
414
+ ${No(Li,"asakaa").split(`
415
415
  `).slice(1,-1).join(`
416
416
  `)}
417
417
  }
418
- `}var Th=({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 jc({showLabels:e=true,compact:t=false,className:a=""}){let{theme:r,setTheme:o,themes:s}=$r();return jsx("div",{className:`theme-switcher ${t?"theme-switcher--compact":""} ${a}`,children:Object.entries(s).map(([l,c])=>{let p=l,n=p===r;return jsxs("button",{onClick:()=>o(p),className:`theme-switcher__button ${n?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${c.displayName} theme`,"aria-pressed":n,title:c.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(Th,{theme:p})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:c.displayName})]},p)})})}
419
- export{hc as AIUsageDashboard,ah as AI_FEATURES,mi as AI_MODELS,Yn as AddCardButton,Kn as AddColumnButton,za as AttachmentUploader,Lc as BoardProvider,_o as BulkOperationsToolbar,ls as BurnDownChart,ec as CalendarBoard,Ga as Card,es as CardDetailModal,ns as CardDetailModalV2,ic as CardHistoryReplay,nc as CardHistoryTimeline,cc as CardRelationshipsGraph,Kf as CardStack,fs as CardTemplateSelector,Ln as CircuitBreaker,Lr as Column,Xo as ColumnManager,Jn as CommandPalette,vs as ConfigMenu,Hr as ContextMenu,co as DEFAULT_SHORTCUTS,gs as DEFAULT_TEMPLATES,Zr as DateRangePicker,eo as DependenciesSelector,rn as DependencyLine,ds as DistributionCharts,Wn as EditableColumnTitle,Fr as ErrorBoundary,bs as ExportImportModal,ys as FilterBar,Fd as GANTT_AI_SYSTEM_PROMPT,pn as GanttAIAssistant,Ld as GanttBoard,Wr as GanttI18nContext,nn as GanttMilestone,qo as GanttToolbar,vc as GenerateGanttTasksDialog,uc as GeneratePlanModal,ms as GroupBySelector,Qa as KanbanBoard,Vn as KanbanToolbar,no as KanbanViewAdapter,us as KeyboardShortcutsHelp,jd as ListView,kt as MenuIcons,En as PluginManager,cr as PrioritySelector,th as RATE_LIMITS,cs as SwimlaneBoardView,rs as TagBadge,Al as TagList,Rr as TagPicker,en as TaskBar,cn as TaskFormModal,Qo as TaskGrid,Cs as ThemeModal,Kl as ThemeProvider,jc as ThemeSwitcher,ln as Timeline,mr as UserAssignmentSelector,is as VelocityChart,Wc as VirtualGrid,zc as VirtualList,Cr as aiUsageTracker,xi as borderRadius,Ao as calculatePosition,ii as calendarDarkTheme,ei as calendarEnTranslations,ti as calendarEsTranslations,li as calendarLightTheme,di as calendarNeutralTheme,Cn as calendarThemes,yn as calendarTranslations,un as cardToGanttTask,Wd as cardsToGanttTasks,C as cn,Tl as createKanbanView,dp as createRetryWrapper,xs as darkTheme,Mn as darkTokenTheme,jo as defaultTheme,Pn as designTokens,Di as duration,Ni as easing,Vc as exportTokensToCSS,Ka as findTaskByName,ki as fontSize,wi as fontWeight,wo as formatCost,Yo as ganttEnTranslations,ql as ganttEsTranslations,Ud as ganttTaskToCardUpdate,Ge as ganttThemes,Mi as ganttTokens,Ts as ganttTranslations,ne as ganttUtils,Ii as generateCSSVariables,Bi as generateCompleteCSS,np as generateInitialPositions,Bd as generateTasksContext,No as generateThemeVariables,tc as getCalendarTheme,vo as getCalendarTranslations,Kd as getListViewTheme,Xs as getListViewTranslations,Yd as getMonthNames,_c as getToken,Xl as getTranslations,qd as getWeekdayNames,Pi as kanbanTokens,ks as lightTheme,Li as lightTokenTheme,Ci as lineHeight,Js as listViewDarkTheme,Ys as listViewEnTranslations,qs as listViewEsTranslations,Zs as listViewLightTheme,Qs as listViewNeutralTheme,bn as listViewThemes,gn as listViewTranslations,vn as mergeCalendarTranslations,fn as mergeListViewTranslations,Ds as mergeTranslations,ws as neutralTheme,Fi as neutralTokenTheme,Ei as opacity,zd as parseLocalCommand,Vs as parseNaturalDate,js as parseNaturalDuration,Ks as parseProgress,Od as parseStatus,xh as pluginManager,lp as retrySyncOperation,Io as retryWithBackoff,Si as shadows,Gc as shouldVirtualizeGrid,vi as spacing,hr as themes,Ec as useAI,kc as useBoard,Do as useBoardCore,Sn as useBoardStore,Ac as useCardStacking,Gn as useDragState,Bc as useFilteredCards,Tc as useFilters,po as useGanttI18n,Nn as useKanbanState,_l as useKeyboardShortcuts,Pc as useMultiSelect,fi as useSelectionState,Rc as useSortedCards,$r as useTheme,Hc as useVirtualGrid,$c as useVirtualList,$d as validateAIResponse,qn as withErrorBoundary,Fo as wouldCreateCircularDependency,Ti as zIndex};//# sourceMappingURL=index.js.map
418
+ `}var Eh=({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 qc({showLabels:e=true,compact:t=false,className:a=""}){let{theme:r,setTheme:o,themes:s}=Hr();return jsx("div",{className:`theme-switcher ${t?"theme-switcher--compact":""} ${a}`,children:Object.entries(s).map(([l,c])=>{let p=l,n=p===r;return jsxs("button",{onClick:()=>o(p),className:`theme-switcher__button ${n?"theme-switcher__button--active":""}`,"aria-label":`Switch to ${c.displayName} theme`,"aria-pressed":n,title:c.displayName,children:[jsx("span",{className:"theme-switcher__icon","aria-hidden":"true",children:jsx(Eh,{theme:p})}),e&&!t&&jsx("span",{className:"theme-switcher__label",children:c.displayName})]},p)})})}
419
+ export{vc as AIUsageDashboard,sh as AI_FEATURES,pi as AI_MODELS,Kn as AddCardButton,jn as AddColumnButton,$a as AttachmentUploader,Rc as BoardProvider,Ho as BulkOperationsToolbar,is as BurnDownChart,rc as CalendarBoard,_a as Card,Qn as CardDetailModal,os as CardDetailModalV2,cc as CardHistoryReplay,lc as CardHistoryTimeline,uc as CardRelationshipsGraph,Jf as CardStack,gs as CardTemplateSelector,In as CircuitBreaker,Rr as Column,Yo as ColumnManager,Xn as CommandPalette,ys as ConfigMenu,Vr as ContextMenu,co as DEFAULT_SHORTCUTS,us as DEFAULT_TEMPLATES,Zr as DateRangePicker,eo as DependenciesSelector,tn as DependencyLine,ls as DistributionCharts,Un as EditableColumnTitle,Or as ErrorBoundary,hs as ExportImportModal,bs as FilterBar,Od as GANTT_AI_SYSTEM_PROMPT,dn as GanttAIAssistant,Rd as GanttBoard,_r as GanttI18nContext,rn as GanttMilestone,Ko as GanttToolbar,wc as GenerateGanttTasksDialog,hc as GeneratePlanModal,ps as GroupBySelector,er as KanbanBoard,_n as KanbanToolbar,no as KanbanViewAdapter,ms as KeyboardShortcutsHelp,qd as ListView,wt as MenuIcons,Nn as PluginManager,pr as PrioritySelector,nh as RATE_LIMITS,ds as SwimlaneBoardView,as as TagBadge,Fl as TagList,$r as TagPicker,Zo as TaskBar,ln as TaskFormModal,Jo as TaskGrid,ws as ThemeModal,Xl as ThemeProvider,qc as ThemeSwitcher,nn as Timeline,ur as UserAssignmentSelector,ss as VelocityChart,_c as VirtualGrid,Wc as VirtualList,Dr as aiUsageTracker,vi as borderRadius,Po as calculatePosition,si as calendarDarkTheme,Qs as calendarEnTranslations,ei as calendarEsTranslations,ii as calendarLightTheme,li as calendarNeutralTheme,kn as calendarThemes,hn as calendarTranslations,pn as cardToGanttTask,_d as cardsToGanttTasks,C as cn,Sl as createKanbanView,up as createRetryWrapper,vs as darkTheme,En as darkTokenTheme,_o as defaultTheme,Sn as designTokens,Ti as duration,Di as easing,Yc as exportTokensToCSS,Ya as findTaskByName,xi as fontSize,ki as fontWeight,wo as formatCost,jo as ganttEnTranslations,Zl as ganttEsTranslations,Gd as ganttTaskToCardUpdate,Ge as ganttThemes,Pi as ganttTokens,Cs as ganttTranslations,ie as ganttUtils,Ai as generateCSSVariables,Fi as generateCompleteCSS,dp as generateInitialPositions,zd as generateTasksContext,No as generateThemeVariables,oc as getCalendarTheme,vo as getCalendarTranslations,Xd as getListViewTheme,qs as getListViewTranslations,Jd as getMonthNames,Kc as getToken,Ql as getTranslations,Zd as getWeekdayNames,Ei as kanbanTokens,xs as lightTheme,Ii as lightTokenTheme,wi as lineHeight,Xs as listViewDarkTheme,Ks as listViewEnTranslations,Ys as listViewEsTranslations,Js as listViewLightTheme,Zs as listViewNeutralTheme,fn as listViewThemes,mn as listViewTranslations,bn as mergeCalendarTranslations,un as mergeListViewTranslations,Ts as mergeTranslations,ks as neutralTheme,Li as neutralTokenTheme,Si as opacity,Wd as parseLocalCommand,_s as parseNaturalDate,Vs as parseNaturalDuration,js as parseProgress,Ud as parseStatus,Th as pluginManager,mp as retrySyncOperation,Mo as retryWithBackoff,Ni as shadows,jc as shouldVirtualizeGrid,yi as spacing,br as themes,Ac as useAI,Tc as useBoard,Do as useBoardCore,Dn as useBoardStore,Fc as useCardStacking,Hn as useDragState,zc as useFilteredCards,Sc as useFilters,po as useGanttI18n,Tn as useKanbanState,Kl as useKeyboardShortcuts,Ic as useMultiSelect,gi as useSelectionState,$c as useSortedCards,Hr as useTheme,Vc as useVirtualGrid,Hc as useVirtualList,Hd as validateAIResponse,Yn as withErrorBoundary,Io as wouldCreateCircularDependency,Ci as zIndex};//# sourceMappingURL=index.js.map
420
420
  //# sourceMappingURL=index.js.map