ezux 1.1.8 → 1.1.9
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-B6tOG5n-.cjs +2 -0
- package/dist/{index-DI80c2kw.js → index-BppkFW5-.js} +1154 -1135
- package/dist/index.cjs +1 -1
- package/dist/index.es.js +1 -1
- package/dist/kanban.cjs +1 -1
- package/dist/kanban.es.js +1 -1
- package/package.json +2 -2
- package/dist/index-DllNLSm8.cjs +0 -2
- package/dist/theme-vars.css +0 -156
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),v=require("react"),J=require("./TooltipWrapper-gco5CexX.cjs"),Z=require("./EzErrorBoundary-CEdz_hDo.cjs"),z=require("./button-DT4Inu2c.cjs"),_e=require("./NotificationPanel-HoqM63z8.cjs"),ve=require("@tanstack/react-store"),rt=require("@tanstack/store"),_=require("./useInitCoreServices-BCuuNsu5.cjs"),it=require("./useServiceState-BGQiGyXF.cjs"),se=require("./index-D4eq_ohu.cjs"),ye=require("./input-BwEWZkMW.cjs"),$=require("./select-CyzLABFE.cjs"),Ie=require("./popover-2vzx8NRx.cjs"),re=require("./checkbox-DrL8aED5.cjs"),oe=require("./label-Cm2Ayqls.cjs"),lt=require("./scroll-area-BCstMooj.cjs"),ot=require("./layers-xSPd-hz3.cjs"),Re=require("./download-0ZhO2XaW.cjs"),ct=require("@tanstack/react-form"),je=require("./date-time-picker-Cl9JFWO8.cjs"),he=require("./avatar-m3tSATGp.cjs"),Pe=require("./calendar-BE2zOlsW.cjs"),ce=require("./EzContextMenu-C5fEFGzp.cjs"),xe=require("./sortable.esm-DU16Scox.cjs"),dt=require("./isBefore-CTwR56mw.cjs"),ut=require("@tanstack/react-virtual"),Se=require("./dropdown-menu-BWyO06-P.cjs"),Le=require("./ellipsis-CzlqJf-i.cjs"),Qe=require("./chevron-down-DZVL7VHW.cjs");function mt(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(s,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return s.default=t,Object.freeze(s)}const te=mt(v);const ht=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],xt=Z.createLucideIcon("activity",ht);const gt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],pt=Z.createLucideIcon("image",gt);const ft=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Ct=Z.createLucideIcon("list",ft);const vt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],yt=Z.createLucideIcon("message-square",vt);const jt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],Ke=Z.createLucideIcon("panels-top-left",jt);const wt=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],bt=Z.createLucideIcon("pen",wt);const Nt=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],St=Z.createLucideIcon("redo-2",Nt);const kt=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Dt=Z.createLucideIcon("square-check-big",kt);const It=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Bt=Z.createLucideIcon("undo-2",It),ge=()=>_.useI18nService(),Tt=()=>e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md",children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-destructive/10",children:e.jsx(Z.TriangleAlert,{className:"w-8 h-8 text-destructive"})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Kanban Board Error"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"An error occurred while rendering the Kanban board. Please refresh the page or contact support if the issue persists."})]}),e.jsx(z.Button,{onClick:()=>window.location.reload(),children:"Reload Board"})]})}),At=(t,s="standard")=>new rt.Store({board:t,selectedCards:[],selectedColumnId:null,view:s,searchQuery:"",activeFilters:{},history:[t],historyIndex:0}),Ft=t=>({setBoard:s=>{t.setState(n=>{const r=[...n.history.slice(0,n.historyIndex+1),s];return{...n,board:s,history:r,historyIndex:r.length-1}})},addCard:s=>{t.setState(n=>{const r={...n.board,cards:[...n.board.cards,s]},l=[...n.history.slice(0,n.historyIndex+1),r];return{...n,board:r,history:l,historyIndex:l.length-1}})},updateCard:(s,n)=>{t.setState(r=>{const l={...r.board,cards:r.board.cards.map(C=>C.id===s?{...C,...n}:C)},u=[...r.history.slice(0,r.historyIndex+1),l];return{...r,board:l,history:u,historyIndex:u.length-1}})},deleteCard:s=>{t.setState(n=>{const r={...n.board,cards:n.board.cards.filter(u=>u.id!==s)},l=[...n.history.slice(0,n.historyIndex+1),r];return{...n,board:r,history:l,historyIndex:l.length-1}})},moveCard:(s,n)=>{t.setState(r=>{const l={...r.board,cards:r.board.cards.map(C=>C.id===s?{...C,columnId:n}:C)},u=[...r.history.slice(0,r.historyIndex+1),l];return{...r,board:l,history:u,historyIndex:u.length-1}})},addColumn:s=>{t.setState(n=>{const r={...n.board,columns:[...n.board.columns,s]},l=[...n.history.slice(0,n.historyIndex+1),r];return{...n,board:r,history:l,historyIndex:l.length-1}})},updateColumn:(s,n)=>{t.setState(r=>{const l={...r.board,columns:r.board.columns.map(C=>C.id===s?{...C,...n}:C)},u=[...r.history.slice(0,r.historyIndex+1),l];return{...r,board:l,history:u,historyIndex:u.length-1}})},deleteColumn:s=>{t.setState(n=>{const r={...n.board,columns:n.board.columns.filter(u=>u.id!==s),cards:n.board.cards.filter(u=>u.columnId!==s)},l=[...n.history.slice(0,n.historyIndex+1),r];return{...n,board:r,history:l,historyIndex:l.length-1}})},setSelectedCards:s=>{t.setState(n=>({...n,selectedCards:s}))},setSelectedColumnId:s=>{t.setState(n=>({...n,selectedColumnId:s}))},setView:s=>{t.setState(n=>({...n,view:s}))},setSearchQuery:s=>{t.setState(n=>({...n,searchQuery:s}))},setActiveFilters:s=>{t.setState(n=>({...n,activeFilters:s}))},undo:()=>{t.setState(s=>s.historyIndex>0?{...s,board:s.history[s.historyIndex-1],historyIndex:s.historyIndex-1}:s)},redo:()=>{t.setState(s=>s.historyIndex<s.history.length-1?{...s,board:s.history[s.historyIndex+1],historyIndex:s.historyIndex+1}:s)},canUndo:()=>t.state.historyIndex>0,canRedo:()=>t.state.historyIndex<t.state.history.length-1}),Et=t=>{const s=v.useMemo(()=>At(t.board,t.view),[t.board.id,t.view]),n=v.useMemo(()=>Ft(s),[s]),r=ve.useStore(s,f=>f.board),l=ve.useStore(s,f=>f.selectedCards),u=ve.useStore(s,f=>f.selectedColumnId),C=ve.useStore(s,f=>f.view),m=ve.useStore(s,f=>f.searchQuery),g=ve.useStore(s,f=>f.activeFilters),S=v.useRef(JSON.stringify(t.board)),j=v.useRef(t.view);return v.useEffect(()=>{const f=JSON.stringify(t.board);f!==S.current&&(S.current=f,n.setBoard(t.board)),t.view&&t.view!==j.current&&(j.current=t.view,n.setView(t.view))},[t.board,t.view,n]),{board:r,selectedCards:l,selectedColumnId:u,view:C,searchQuery:m,activeFilters:g,setBoard:n.setBoard,setSelectedCards:n.setSelectedCards,setSelectedColumnId:n.setSelectedColumnId,setView:n.setView,setSearchQuery:n.setSearchQuery,setActiveFilters:n.setActiveFilters,addCard:n.addCard,updateCard:n.updateCard,deleteCard:n.deleteCard,moveCard:n.moveCard,addColumn:n.addColumn,updateColumn:n.updateColumn,deleteColumn:n.deleteColumn,undo:n.undo,redo:n.redo,canUndo:n.canUndo(),canRedo:n.canRedo(),store:s,actions:n}},Mt=(t,s)=>{const n=_.useEzServiceRegistry(),r=J.useQueryClient(),l=()=>n.get("KanbanService"),u=(a,o,d=3e3)=>{const p=n.get("NotificationService");p&&p.add({type:a,message:o,duration:d})},C=a=>{r.setQueryData(["board",s.id],a),t.onBoardChange?.(a)},m=J.useMutation({mutationFn:async a=>{const o=l();return o?await o.createCard(s.id,a):await t.onCardCreate?.(a),a},onMutate:async a=>{await r.cancelQueries({queryKey:["board",s.id]});const o=r.getQueryData(["board",s.id]),d={...s,cards:[...s.cards,a]};return C(d),{previousBoard:o}},onError:(a,o,d)=>{d?.previousBoard&&C(d.previousBoard),u("error","Failed to create card. Please try again.",5e3)},onSuccess:a=>{u("success",`Card "${a.title}" created successfully`)}}),g=v.useCallback(async a=>{const o={id:`card-${Date.now()}`,type:a.type||"standard",title:a.title||"New Card",description:a.description,columnId:a.columnId||s.columns[0]?.id||"",position:a.position??s.cards.filter(d=>d.columnId===a.columnId).length,assignees:a.assignees||[],tags:a.tags||[],priority:a.priority,metadata:a.metadata||{},createdBy:"current-user",createdAt:new Date,updatedBy:"current-user",updatedAt:new Date,...a};return m.mutateAsync(o)},[s,m]),S=J.useMutation({mutationFn:async({cardId:a,updates:o})=>{const d=l();if(d)await d.updateCard(a,o);else{const p=s.cards.find(k=>k.id===a);p&&await t.onCardUpdate?.({...p,...o},"edit")}return{cardId:a,updates:o}},onMutate:async({cardId:a,updates:o})=>{await r.cancelQueries({queryKey:["board",s.id]});const d=r.getQueryData(["board",s.id]),p=s.cards.map(E=>E.id===a?{...E,...o,updatedAt:new Date}:E),k={...s,cards:p};return C(k),{previousBoard:d}},onError:(a,o,d)=>{d?.previousBoard&&C(d.previousBoard),u("error","Failed to update card",5e3)},onSuccess:()=>{u("success","Card updated successfully",2e3)}}),j=v.useCallback(async(a,o)=>S.mutateAsync({cardId:a,updates:o}),[S]),f=J.useMutation({mutationFn:async a=>{const o=l();return o?await o.deleteCard(a):await t.onCardDelete?.(a),a},onMutate:async a=>{await r.cancelQueries({queryKey:["board",s.id]});const o=r.getQueryData(["board",s.id]),d={...s,cards:s.cards.filter(p=>p.id!==a)};return C(d),{previousBoard:o,deletedCardTitle:o?.cards.find(p=>p.id===a)?.title}},onError:(a,o,d)=>{d?.previousBoard&&C(d.previousBoard),u("error","Failed to delete card",5e3)},onSuccess:(a,o,d)=>{const p=d?.deletedCardTitle||"Card";u("success",`Card "${p}" deleted`)}}),A=v.useCallback(async a=>f.mutateAsync(a),[f]),c=J.useMutation({mutationFn:async a=>{const{cardId:o,targetColumnId:d,targetSwimlaneId:p,targetPosition:k}=a,E=l();if(E)await E.moveCard(o,d,p,k);else{const F=s.cards.find(T=>T.id===o);F&&await t.onCardUpdate?.({...F,columnId:d,swimlaneId:p},"move")}},onMutate:async({cardId:a,targetColumnId:o,targetSwimlaneId:d,targetPosition:p})=>{await r.cancelQueries({queryKey:["board",s.id]});const k=r.getQueryData(["board",s.id]),E=s.cards.find(b=>b.id===a);if(!E)return{previousBoard:k};const F=s.cards.filter(b=>b.id!==a),T=F.filter(b=>b.columnId===o).sort((b,I)=>(b.position??0)-(I.position??0)),N=p!==void 0?Math.min(p,T.length):T.length,M=[...T.slice(0,N),{...E,columnId:o,swimlaneId:d,updatedAt:new Date},...T.slice(N)].map((b,I)=>({...b,position:I})),O=E.columnId,H=F.filter(b=>b.columnId===O).sort((b,I)=>(b.position??0)-(I.position??0)).map((b,I)=>({...b,position:I})),V=[...F.filter(b=>b.columnId!==o&&b.columnId!==O),...H,...M],U={...s,cards:V};return C(U),{previousBoard:k}},onError:(a,o,d)=>{d?.previousBoard&&C(d.previousBoard),u("error","Failed to move card",3e3)}}),y=v.useCallback(async(a,o,d,p)=>c.mutateAsync({cardId:a,targetColumnId:o,targetSwimlaneId:d,targetPosition:p}),[c]),w=v.useCallback(async a=>{const o=s.cards.find(p=>p.id===a);if(!o)throw new Error("Card not found");const d={...o,id:`card-${Date.now()}`,title:`${o.title} (Copy)`,position:(o.position??0)+1,createdAt:new Date,updatedAt:new Date};return g(d)},[s.cards,g]),D=v.useCallback(async a=>j(a,{isArchived:!0}),[j]),i=v.useCallback(async a=>j(a,{isArchived:!1}),[j]);return{createCard:g,updateCard:j,deleteCard:A,moveCard:y,duplicateCard:w,archiveCard:D,restoreCard:i}},Vt=(t,s)=>{const n=_.useEzServiceRegistry(),r=J.useQueryClient(),l=()=>n.get("KanbanService"),u=(i,a,o=3e3)=>{const d=n.get("NotificationService");d&&d.add({type:i,message:a,duration:o})},C=i=>{r.setQueryData(["board",s.id],i),t.onBoardChange?.(i)},m=J.useMutation({mutationFn:async i=>{const a=l();return a?await a.createColumn(s.id,i):await t.onColumnCreate?.(i),i},onMutate:async i=>{await r.cancelQueries({queryKey:["board",s.id]});const a=r.getQueryData(["board",s.id]),o={...s,columns:[...s.columns,i]};return C(o),{previousBoard:a}},onError:(i,a,o)=>{o?.previousBoard&&C(o.previousBoard),u("error","Failed to create column",5e3)},onSuccess:i=>{u("success",`Column "${i.name}" added`)}}),g=v.useCallback(async i=>{const a={id:`column-${Date.now()}`,name:i.name||"New Column",color:i.color,icon:i.icon,wipLimit:i.wipLimit,position:i.position??s.columns.length,isCollapsed:!1,...i};return m.mutateAsync(a)},[s.columns.length,m]),S=J.useMutation({mutationFn:async({columnId:i,updates:a})=>{const o=l();if(o)await o.updateColumn(i,a);else{const d=s.columns.find(p=>p.id===i);d&&await t.onColumnUpdate?.({...d,...a})}return{columnId:i,updates:a}},onMutate:async({columnId:i,updates:a})=>{await r.cancelQueries({queryKey:["board",s.id]});const o=r.getQueryData(["board",s.id]),d={...s,columns:s.columns.map(p=>p.id===i?{...p,...a}:p)};return C(d),{previousBoard:o}},onError:(i,a,o)=>{o?.previousBoard&&C(o.previousBoard),u("error","Failed to update column",5e3)}}),j=v.useCallback(async(i,a)=>S.mutateAsync({columnId:i,updates:a}),[S]),f=J.useMutation({mutationFn:async i=>{const a=l();return a?await a.deleteColumn(i):await t.onColumnDelete?.(i),i},onMutate:async i=>{await r.cancelQueries({queryKey:["board",s.id]});const a=r.getQueryData(["board",s.id]),o=a?.columns.find(p=>p.id===i),d={...s,columns:s.columns.filter(p=>p.id!==i),cards:s.cards.filter(p=>p.columnId!==i)};return C(d),{previousBoard:a,deletedColumnName:o?.name}},onError:(i,a,o)=>{o?.previousBoard&&C(o.previousBoard),u("error","Failed to delete column",5e3)},onSuccess:(i,a,o)=>{const d=o?.deletedColumnName||"Column";u("success",`Column "${d}" deleted`)}}),A=v.useCallback(async i=>f.mutateAsync(i),[f]),c=J.useMutation({mutationFn:async i=>{const a=l();if(a){const o=i.map((d,p)=>a.updateColumn(d,{position:p}));await Promise.all(o)}return i},onMutate:async i=>{await r.cancelQueries({queryKey:["board",s.id]});const a=r.getQueryData(["board",s.id]),o={...s,columns:i.map((d,p)=>{const k=s.columns.find(E=>E.id===d);if(!k)throw new Error(`Column ${d} not found`);return{...k,position:p}})};return C(o),{previousBoard:a}},onError:(i,a,o)=>{o?.previousBoard&&C(o.previousBoard),u("error","Failed to reorder columns",3e3)}}),y=v.useCallback(async i=>c.mutateAsync(i),[c]),w=v.useCallback(i=>{j(i,{isCollapsed:!0})},[j]),D=v.useCallback(i=>{j(i,{isCollapsed:!1})},[j]);return{createColumn:g,updateColumn:j,deleteColumn:A,reorderColumns:y,collapseColumn:w,expandColumn:D}},zt=(t,s)=>{const n=_.useEzServiceRegistry(),r=J.useQueryClient(),l=()=>n.get("KanbanService"),u=(i,a,o=3e3)=>{const d=n.get("NotificationService");d&&d.add({type:i,message:a,duration:o})},C=i=>{r.setQueryData(["board",s.id],i),t.onBoardChange?.(i)},m=J.useMutation({mutationFn:async i=>{const a=l();return a?await a.createSwimlane(s.id,i):await t.onSwimlaneCreate?.(i),i},onMutate:async i=>{await r.cancelQueries({queryKey:["board",s.id]});const a=r.getQueryData(["board",s.id]),o={...s,swimlanes:[...s.swimlanes||[],i]};return C(o),{previousBoard:a}},onError:(i,a,o)=>{o?.previousBoard&&C(o.previousBoard),u("error","Failed to create swimlane",5e3)},onSuccess:i=>{u("success",`Swimlane "${i.name}" added`)}}),g=v.useCallback(async i=>{const a={id:`swimlane-${Date.now()}`,name:i.name||"New Swimlane",type:i.type||"custom",color:i.color,position:i.position??(s.swimlanes?.length||0),isCollapsed:!1,...i};return m.mutateAsync(a)},[s.swimlanes,m]),S=J.useMutation({mutationFn:async({swimlaneId:i,updates:a})=>{const o=l();if(o)await o.updateSwimlane(i,a);else{const d=s.swimlanes?.find(p=>p.id===i);d&&await t.onSwimlaneUpdate?.({...d,...a})}return{swimlaneId:i,updates:a}},onMutate:async({swimlaneId:i,updates:a})=>{await r.cancelQueries({queryKey:["board",s.id]});const o=r.getQueryData(["board",s.id]),d={...s,swimlanes:(s.swimlanes||[]).map(p=>p.id===i?{...p,...a}:p)};return C(d),{previousBoard:o}},onError:(i,a,o)=>{o?.previousBoard&&C(o.previousBoard),u("error","Failed to update swimlane",5e3)}}),j=v.useCallback(async(i,a)=>S.mutateAsync({swimlaneId:i,updates:a}),[S]),f=J.useMutation({mutationFn:async i=>{const a=l();return a?await a.deleteSwimlane(i):await t.onSwimlaneDelete?.(i),i},onMutate:async i=>{await r.cancelQueries({queryKey:["board",s.id]});const a=r.getQueryData(["board",s.id]),o=a?.swimlanes?.find(p=>p.id===i),d={...s,swimlanes:(s.swimlanes||[]).filter(p=>p.id!==i),cards:s.cards.map(p=>p.swimlaneId===i?{...p,swimlaneId:void 0}:p)};return C(d),{previousBoard:a,deletedSwimlaneName:o?.name}},onError:(i,a,o)=>{o?.previousBoard&&C(o.previousBoard),u("error","Failed to delete swimlane",5e3)},onSuccess:(i,a,o)=>{const d=o?.deletedSwimlaneName||"Swimlane";u("success",`Swimlane "${d}" deleted`)}}),A=v.useCallback(async i=>f.mutateAsync(i),[f]),c=J.useMutation({mutationFn:async i=>{const a=l();if(a){const o=i.map((d,p)=>a.updateSwimlane(d,{position:p}));await Promise.all(o)}return i},onMutate:async i=>{await r.cancelQueries({queryKey:["board",s.id]});const a=r.getQueryData(["board",s.id]),o={...s,swimlanes:i.map((d,p)=>{const k=s.swimlanes?.find(E=>E.id===d);return k?{...k,position:p}:null}).filter(Boolean)};return C(o),{previousBoard:a}},onError:(i,a,o)=>{o?.previousBoard&&C(o.previousBoard),u("error","Failed to reorder swimlanes",3e3)}}),y=v.useCallback(async i=>c.mutateAsync(i),[c]),w=v.useCallback(i=>{j(i,{isCollapsed:!0}),t.onSwimlaneToggle?.({swimlaneId:i,isCollapsed:!0})},[j,t.onSwimlaneToggle]),D=v.useCallback(i=>{j(i,{isCollapsed:!1}),t.onSwimlaneToggle?.({swimlaneId:i,isCollapsed:!1})},[j,t.onSwimlaneToggle]);return{createSwimlane:g,updateSwimlane:j,deleteSwimlane:A,reorderSwimlanes:y,collapseSwimlane:w,expandSwimlane:D}},_t=t=>{const[s,n]=v.useState(""),[r,l]=v.useState({});return{filteredCards:v.useMemo(()=>t.cards.filter(m=>{if(s){const g=s.toLowerCase();if(!(m.title.toLowerCase().includes(g)||m.description?.toLowerCase().includes(g)||m.tags.some(j=>j.name.toLowerCase().includes(g))))return!1}return!(r.tags&&r.tags.length>0&&!m.tags.some(S=>r.tags?.includes(S.id))||r.assignees&&r.assignees.length>0&&!m.assignees.some(S=>r.assignees?.includes(S.id))||r.priority&&r.priority.length>0&&m.priority&&!r.priority.includes(m.priority)||r.columns&&r.columns.length>0&&!r.columns.includes(m.columnId))}),[t.cards,s,r]),searchQuery:s,setSearchQuery:n,activeFilters:r,setActiveFilters:l,clearFilters:()=>{n(""),l({})}}},Rt=(t,s,n=!1,r)=>{const l=_.useEzServiceRegistry(),[u,C]=v.useState(null),[m,g]=v.useState(null),[S,j]=v.useState(null),f=v.useCallback(w=>{if(r?.onCardDragStart){const D={card:w,columnId:w.columnId,cancel:!1};if(r.onCardDragStart(D),D.cancel)return}C(w)},[r?.onCardDragStart]),A=v.useCallback((w,D)=>{u&&m!==w&&(m&&r?.onCardDragLeave&&r.onCardDragLeave({card:u,targetColumnId:m}),r?.onCardDragEnter&&r.onCardDragEnter({card:u,targetColumnId:w})),g(w),D&&j(D)},[u,r,m]),c=v.useCallback(()=>{u&&r?.onCardDragStop&&r.onCardDragStop({card:u,columnId:u.columnId}),C(null),g(null),j(null)},[u,r?.onCardDragStop]),y=v.useCallback((w,D,i)=>{if(!u)return;const a=t.columns.find(o=>o.id===w);if(a?.wipLimit&&t.cards.filter(d=>d.columnId===w&&!d.isArchived).length>=a.wipLimit&&(u.columnId!==w||u.swimlaneId!==D)){const d=l.get("NotificationService");if(d&&d.add({type:"warning",message:`WIP limit reached for "${a.name}" (${a.wipLimit} cards)`,duration:4e3}),n){d?.add({type:"error",message:`Cannot move card: "${a.name}" is full (Strict WIP)`,duration:4e3}),C(null),g(null),j(null);return}}s(u.id,w,D,i),r?.onCardDragStop&&r.onCardDragStop({card:u,columnId:w}),C(null),g(null),j(null)},[u,t,s,r?.onCardDragStop]);return{draggedCard:u,dragOverColumn:m,dragOverSwimlane:S,handleDragStart:f,handleDragOver:A,handleDragEnd:c,handleDrop:y}},Oe=(t,s={})=>{const r=it.useServiceState("I18nService")?.dir||"ltr",l=t.dir==="auto"||!t.dir?r:t.dir,u={showSpinner:()=>{},hideSpinner:()=>{}},C=null,{board:m,setBoard:g,selectedCards:S,setSelectedCards:j,selectedColumnId:f,setSelectedColumnId:A,view:c,setView:y,undo:w,redo:D,canUndo:i,canRedo:a}=Et(t),[o,d]=v.useState(null),{createCard:p,updateCard:k,deleteCard:E,moveCard:F,duplicateCard:T,archiveCard:N,restoreCard:M}=Mt(t,m),{createColumn:O,updateColumn:H,deleteColumn:Y,reorderColumns:V,collapseColumn:U,expandColumn:b}=Vt(t,m),{createSwimlane:I,updateSwimlane:q,deleteSwimlane:W,reorderSwimlanes:ne,collapseSwimlane:P,expandSwimlane:Q}=zt(t,m),{draggedCard:G,dragOverColumn:le,handleDragStart:X,handleDragOver:ae,handleDragEnd:be,handleDrop:Ne}=Rt(m,F,t.wipStrict,t),{filteredCards:ie,searchQuery:pe,setSearchQuery:fe,activeFilters:x,setActiveFilters:h,clearFilters:B}=_t(m),{selectedIndex:K,setSelectedIndex:ee}=se.useKeyboardNavigation({totalItems:ie.length,columns:1,enabled:!t.readOnly,onSelect:L=>{const R=ie[L];R&&(d(R.id),(document.getElementById(R.id)||document.querySelector(`[data-card-id="${R.id}"]`))?.scrollIntoView({behavior:"smooth",block:"nearest"}))},onAction:L=>{const R=ie[L];R&&s.onCardClick&&s.onCardClick(R)}}),de=v.useMemo(()=>({addCard:p,updateCard:k,deleteCard:E,moveCard:F,duplicateCard:T,archiveCard:N,restoreCard:M,getCard:L=>m.cards.find(R=>R.id===L),getCards:()=>m.cards,getCardsInColumn:L=>m.cards.filter(R=>R.columnId===L),getOrderedCards:L=>m.cards.filter(R=>R.columnId===L).sort((R,Ce)=>(R.position??0)-(Ce.position??0)),addColumn:O,updateColumn:H,deleteColumn:Y,reorderColumns:V,collapseColumn:U,expandColumn:b,getColumn:L=>m.columns.find(R=>R.id===L),getColumns:()=>m.columns,addSwimlane:I,updateSwimlane:q,deleteSwimlane:W,reorderSwimlanes:ne,collapseSwimlane:P,expandSwimlane:Q,getSwimlane:L=>m.swimlanes?.find(R=>R.id===L),getSwimlanes:()=>m.swimlanes||[],selectCard:L=>j([L]),selectCards:j,deselectCard:L=>{const R=S.filter(Ce=>Ce!==L);j(R)},deselectAllCards:()=>j([]),getSelectedCards:()=>m.cards.filter(L=>S.includes(L.id)),focusCard:L=>{const R=document.getElementById(L)||document.querySelector(`[data-card-id="${L}"]`);R instanceof HTMLElement&&(R.focus(),R.scrollIntoView({behavior:"smooth",block:"center"}))},highlightCard:(L,R=2e3)=>{d(L),setTimeout(()=>d(null),R)},setView:y,getView:()=>c,scrollToColumn:(L,R)=>{(document.getElementById(`column-${L}`)||document.querySelector(`[data-column-id="${L}"]`))?.scrollIntoView(R||{behavior:"smooth",block:"center",inline:"center"})},scrollToCard:(L,R)=>{(document.getElementById(L)||document.querySelector(`[data-card-id="${L}"]`))?.scrollIntoView(R||{behavior:"smooth",block:"center"})},setSearchQuery:fe,getSearchQuery:()=>pe,setActiveFilters:h,getActiveFilters:()=>x,clearFilters:B,getFilteredCards:()=>ie,getBoard:()=>m,setBoard:g,refresh:async()=>{},reset:()=>g(t.board),showSpinner:u.showSpinner,hideSpinner:u.hideSpinner,forceUpdate:()=>{},getStatistics:()=>({totalCards:m.cards.length,totalColumns:m.columns.length}),validate:()=>({isValid:!0,errors:[]}),...s}),[m,p,k,E,F,T,N,M,O,H,Y,V,U,b,I,q,W,ne,P,Q,S,j,f,A,pe,fe,x,h,B,ie,g,t.board,u,s,c,t.wipStrict,t]);return v.useMemo(()=>({state:{board:m,selectedCards:S,highlightedCardId:o,selectedColumnId:f,view:c,draggedCard:G,dragOverColumn:le,filteredCards:ie,searchQuery:pe,activeFilters:x,selectedIndex:K,canUndo:i,canRedo:a},actions:{setBoard:g,setSelectedCards:j,setSelectedColumnId:A,setView:y,createCard:p,updateCard:k,deleteCard:E,moveCard:F,duplicateCard:T,archiveCard:N,restoreCard:M,createColumn:O,updateColumn:H,deleteColumn:Y,reorderColumns:V,collapseColumn:U,expandColumn:b,createSwimlane:I,updateSwimlane:q,deleteSwimlane:W,reorderSwimlanes:ne,collapseSwimlane:P,expandSwimlane:Q,handleDragStart:X,handleDragOver:ae,handleDragEnd:be,handleDrop:Ne,setSearchQuery:fe,setActiveFilters:h,clearFilters:B,setSelectedIndex:ee,undo:w,redo:D},services:{serviceRegistry:C},imperativeAPI:de,dir:l,baseApi:u}),[u,de,m,g,S,j,o,f,A,c,y,l,p,k,E,F,T,N,M,O,H,Y,V,U,b,I,q,W,ne,P,Q,G,le,X,ae,be,Ne,ie,pe,fe,x,h,B,C,K,ee,w,D,i,a])};function Ue(t,s=300){const[n,r]=v.useState(t);return v.useEffect(()=>{const l=setTimeout(()=>{r(t)},s);return()=>{clearTimeout(l)}},[t,s]),n}const He=z.cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Te({className:t,variant:s,...n}){return e.jsx("div",{className:_.cn(He({variant:s}),t),...n})}const Lt=({board:t,activeFilters:s,onFiltersChange:n,onClearFilters:r})=>{const u=Array.from(new Set(t.cards.flatMap(c=>c.tags).map(c=>JSON.stringify(c)))).map(c=>JSON.parse(c)).filter((c,y,w)=>y===w.findIndex(D=>D.id===c.id)),m=Array.from(new Set(t.cards.flatMap(c=>c.assignees).map(c=>JSON.stringify(c)))).map(c=>JSON.parse(c)).filter((c,y,w)=>y===w.findIndex(D=>D.id===c.id)),g=["low","medium","high","critical"],S=c=>{const y=s.priority||[],w=y.includes(c)?y.filter(D=>D!==c):[...y,c];n({...s,priority:w.length?w:void 0})},j=c=>{const y=s.tags||[],w=y.includes(c)?y.filter(D=>D!==c):[...y,c];n({...s,tags:w.length?w:void 0})},f=c=>{const y=s.assignees||[],w=y.includes(c)?y.filter(D=>D!==c):[...y,c];n({...s,assignees:w.length?w:void 0})},A=(s.priority?.length||0)+(s.tags?.length||0)+(s.assignees?.length||0);return e.jsxs(Ie.Popover,{children:[e.jsx(Ie.PopoverTrigger,{asChild:!0,children:e.jsxs(z.Button,{variant:"outline",size:"sm",className:"relative",children:[e.jsx(re.Funnel,{className:"h-4 w-4 mr-2"}),"Filters",A>0&&e.jsx(Te,{variant:"secondary",className:"ml-2 h-5 min-w-[20px] px-1 text-[10px] flex items-center justify-center",children:A})]})}),e.jsxs(Ie.PopoverContent,{className:"w-80 p-4",align:"start",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Filters"}),A>0&&e.jsx(z.Button,{variant:"ghost",size:"sm",className:"h-auto p-0 text-xs text-muted-foreground",onClick:r,children:"Clear all"})]}),e.jsx(lt.ScrollArea,{className:"h-[300px] pr-4",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h5",{className:"text-sm font-medium text-muted-foreground",children:"Priority"}),e.jsx("div",{className:"space-y-2",children:g.map(c=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(re.Checkbox,{id:`priority-${c}`,checked:s.priority?.includes(c),onCheckedChange:()=>S(c)}),e.jsx(oe.Label,{htmlFor:`priority-${c}`,className:"capitalize text-sm font-normal cursor-pointer",children:c})]},c))})]}),m.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h5",{className:"text-sm font-medium text-muted-foreground",children:"Assignees"}),e.jsx("div",{className:"space-y-2",children:m.map(c=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(re.Checkbox,{id:`assignee-${c.id}`,checked:s.assignees?.includes(c.id),onCheckedChange:()=>f(c.id)}),e.jsxs(oe.Label,{htmlFor:`assignee-${c.id}`,className:"text-sm font-normal cursor-pointer flex items-center gap-2",children:[c.avatarUrl&&e.jsx("img",{src:c.avatarUrl,alt:"",className:"w-4 h-4 rounded-full"}),c.name]})]},c.id))})]}),u.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h5",{className:"text-sm font-medium text-muted-foreground",children:"Tags"}),e.jsx("div",{className:"space-y-2",children:u.map(c=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(re.Checkbox,{id:`tag-${c.id}`,checked:s.tags?.includes(c.id),onCheckedChange:()=>j(c.id)}),e.jsxs(oe.Label,{htmlFor:`tag-${c.id}`,className:"text-sm font-normal cursor-pointer flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c.color}}),c.name]})]},c.id))})]})]})})]})]})},We=({searchQuery:t,onSearchChange:s,onAddCardClick:n,onAddColumn:r,board:l,className:u,view:C="standard",onViewChange:m,onUndo:g,onRedo:S,canUndo:j,canRedo:f,activeFilters:A,onFiltersChange:c})=>{const y=_.useEzServiceRegistry(),[w,D]=v.useState(t),{t:i}=ge(),a=Ue(w,300);v.useEffect(()=>{s(a)},[a,s]),v.useEffect(()=>{D(t)},[t]);const o=()=>{n?.()},d=p=>{if(l)try{const k=y.get("ExportService");if(p==="csv"){const F=l.cards.map(T=>({id:T.id,title:T.title,description:T.description||"",column:l.columns.find(N=>N.id===T.columnId)?.name||"",priority:T.priority||"",assignees:T.assignees?.map(N=>N.name).join("; ")||"",tags:T.tags?.map(N=>N.name).join("; ")||"",dueDate:T.dueDate?new Date(T.dueDate).toISOString().split("T")[0]:"",isArchived:T.isArchived?"Yes":"No"}));if(k)k.exportToCSV(F,[{header:"ID",accessorKey:"id"},{header:"Title",accessorKey:"title"},{header:"Description",accessorKey:"description"},{header:"Column",accessorKey:"column"},{header:"Priority",accessorKey:"priority"},{header:"Assignees",accessorKey:"assignees"},{header:"Tags",accessorKey:"tags"},{header:"Due Date",accessorKey:"dueDate"},{header:"Archived",accessorKey:"isArchived"}],{fileName:`kanban-board-${l.id}`});else{const T=Object.keys(F[0]||{}),N=[T.join(","),...F.map(Y=>T.map(V=>`"${Y[V]}"`).join(","))].join(`
|
|
2
|
+
`),M=new Blob([N],{type:"text/csv"}),O=URL.createObjectURL(M),H=document.createElement("a");H.href=O,H.download=`kanban-board-${l.id}.csv`,H.click(),URL.revokeObjectURL(O)}}else{const F=JSON.stringify(l,null,2);if(k&&k.download)k.download(F,`kanban-board-${l.id}.json`);else{const T=new Blob([F],{type:"application/json"}),N=URL.createObjectURL(T),M=document.createElement("a");M.href=N,M.download=`kanban-board-${l.id}.json`,M.click(),URL.revokeObjectURL(N)}}const E=y.get("NotificationService");E&&E.add({type:"success",message:`Board exported as ${p.toUpperCase()}`,duration:3e3})}catch(k){const E=y.get("NotificationService");E&&E.add({type:"error",message:`Failed to export board: ${k instanceof Error?k.message:"Unknown error"}`,duration:4e3})}};return e.jsx(e.Fragment,{children:e.jsxs("div",{className:`flex items-center gap-4 p-4 border-b ${u||""}`,children:[e.jsxs("div",{className:"flex gap-1 mr-2",children:[e.jsx(z.Button,{variant:"ghost",size:"icon",onClick:g,disabled:!j,title:"Undo (Ctrl+Z)",children:e.jsx(Bt,{className:"h-4 w-4"})}),e.jsx(z.Button,{variant:"ghost",size:"icon",onClick:S,disabled:!f,title:"Redo (Ctrl+Shift+Z)",children:e.jsx(St,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx($.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ye.Input,{placeholder:i("search_placeholder"),value:w,onChange:p=>D(p.target.value),className:"pl-9"})]}),e.jsx("div",{className:"w-[180px]",children:e.jsxs($.Select,{value:C,onValueChange:p=>m?.(p),children:[e.jsx($.SelectTrigger,{children:e.jsx($.SelectValue,{placeholder:"Select view"})}),e.jsxs($.SelectContent,{children:[e.jsx($.SelectItem,{value:"standard",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Ke,{className:"h-4 w-4 mr-2"}),i("view_standard")]})}),e.jsx($.SelectItem,{value:"swimlane",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(ot.Layers,{className:"h-4 w-4 mr-2"}),i("view_swimlane")]})}),e.jsx($.SelectItem,{value:"timeline",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Ke,{className:"h-4 w-4 mr-2"})," ",i("view_timeline")]})})]})]})}),l&&e.jsx(Lt,{board:l,activeFilters:A||{},onFiltersChange:p=>c?.(p),onClearFilters:()=>c?.({})}),l&&e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(z.Button,{variant:"outline",size:"sm",onClick:()=>d("csv"),title:"Export as CSV",children:[e.jsx(Re.Download,{className:"h-4 w-4 mr-2"}),"CSV"]}),e.jsxs(z.Button,{variant:"outline",size:"sm",onClick:()=>d("json"),title:"Export as JSON",children:[e.jsx(Re.Download,{className:"h-4 w-4 mr-2"}),"JSON"]})]}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsxs(z.Button,{variant:"outline",size:"sm",onClick:r,children:[e.jsx(re.Plus,{className:"h-4 w-4 mr-2"}),i("add_column")]}),e.jsxs(z.Button,{size:"sm",onClick:o,children:[e.jsx(re.Plus,{className:"h-4 w-4 mr-2"}),i("add_card")]})]})]})})},we=te.forwardRef(({className:t,...s},n)=>e.jsx("textarea",{className:_.cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...s}));we.displayName="Textarea";const Ae=te.createContext(void 0),Fe=te.forwardRef(({className:t,defaultValue:s,value:n,onValueChange:r,children:l,...u},C)=>{const[m,g]=te.useState(s||""),S=n!==void 0,j=S?n:m,f=te.useCallback(A=>{S||g(A),r?.(A)},[S,r]);return e.jsx(Ae.Provider,{value:{value:j,onValueChange:f},children:e.jsx("div",{ref:C,className:_.cn(t),...u,children:l})})});Fe.displayName="Tabs";const Ee=te.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:_.cn("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));Ee.displayName="TabsList";const ue=te.forwardRef(({className:t,value:s,onClick:n,...r},l)=>{const u=te.useContext(Ae);if(!u)throw new Error("TabsTrigger must be used within Tabs");const C=u.value===s;return e.jsx("button",{ref:l,type:"button",className:_.cn("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",C&&"bg-background text-foreground shadow-sm",t),onClick:m=>{u.onValueChange(s),n?.(m)},...r})});ue.displayName="TabsTrigger";const me=te.forwardRef(({className:t,value:s,children:n,...r},l)=>{const u=te.useContext(Ae);if(!u)throw new Error("TabsContent must be used within Tabs");return u.value!==s?null:e.jsx("div",{ref:l,className:_.cn("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...r,children:n})});me.displayName="TabsContent";const Je=({isOpen:t,onClose:s,onSave:n,onDelete:r,card:l,columns:u=[],columnId:C,customFields:m=[],currentUser:g={id:"current-user",name:"Current User"}})=>{const{t:S}=ge(),j=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`id-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,f=ct.useForm({defaultValues:{title:l?.title||"",description:l?.description||"",columnId:l?.columnId||C||u[0]?.id||"",priority:l?.priority||"medium",startDate:l?.startDate?new Date(l.startDate):void 0,dueDate:l?.dueDate?new Date(l.dueDate):void 0,checklists:l?.checklists||[],attachments:l?.attachments||[],comments:l?.comments||[],coverImage:l?.coverImage||"",customFieldValues:l?.customFieldValues||{},subtasks:l?.subtasks||[],timeTracking:l?.timeTracking||{estimated:0,actual:0},activity:l?.activity||[],assignees:l?.assignees||[],tags:l?.tags||[],...l},onSubmit:async({value:x})=>{n(x),s()}});v.useEffect(()=>{},[t,l]);const A=()=>{l?.id&&r&&r(l.id)},[c,y]=v.useState({}),w=()=>{const x={id:j(),title:"Checklist",items:[]};f.pushFieldValue("checklists",x)},D=(x,h)=>{y(B=>({...B,[x]:h}))},i=x=>{const h=c[x]?.trim();if(!h)return;const K=(f.getFieldValue("checklists")||[]).map(ee=>ee.id===x?{...ee,items:[...ee.items,{id:j(),text:h,isChecked:!1}]}:ee);f.setFieldValue("checklists",K),y(ee=>({...ee,[x]:""}))},a=(x,h)=>{const K=(f.getFieldValue("checklists")||[]).map(ee=>ee.id===x?{...ee,items:ee.items.map(de=>de.id===h?{...de,isChecked:!de.isChecked}:de)}:ee);f.setFieldValue("checklists",K)},[o,d]=v.useState(""),[p,k]=v.useState(null),[E,F]=v.useState(""),[T,N]=v.useState(null),M=()=>{if(!o.trim())return;const x={id:j(),text:o,authorId:g.id,authorName:g.name,createdAt:new Date};f.pushFieldValue("comments",x),d("");const h={id:j(),type:"comment",text:`commented "${o.slice(0,20)}${o.length>20?"...":""}"`,userId:g.id,userName:g.name,createdAt:new Date};f.pushFieldValue("activity",h)},O=x=>{k(x.id),F(x.text)},H=()=>{if(p&&E.trim()){const h=(f.getFieldValue("comments")||[]).map(B=>B.id===p?{...B,text:E}:B);f.setFieldValue("comments",h),k(null),F("")}},Y=()=>{k(null),F("")},V=x=>{N(x)},U=()=>{N(null)},b=x=>{const h=f.getFieldValue("comments")||[];f.setFieldValue("comments",h.filter(K=>K.id!==x)),N(null);const B={id:j(),type:"delete",text:"deleted a comment",userId:g.id,userName:g.name,createdAt:new Date};f.pushFieldValue("activity",B)},[I,q]=v.useState(""),W=()=>{if(!I.trim())return;const x={id:j(),title:I,isCompleted:!1};f.pushFieldValue("subtasks",x),q("")},ne=x=>{const B=(f.getFieldValue("subtasks")||[]).map(K=>K.id===x?{...K,isCompleted:!K.isCompleted}:K);f.setFieldValue("subtasks",B)},P=x=>{const h=f.getFieldValue("subtasks")||[];f.setFieldValue("subtasks",h.filter(B=>B.id!==x))},Q=v.useRef(null),[G,le]=v.useState(!1),[X,ae]=v.useState(null),be=async x=>{const h=x.target.files?.[0];if(!h)return;le(!0),ae(null),await new Promise(ee=>setTimeout(ee,1500));const B={id:j(),name:h.name,url:URL.createObjectURL(h),type:h.type.startsWith("image/")?"image":"file",size:h.size,uploadedAt:new Date};f.pushFieldValue("attachments",B),le(!1),Q.current&&(Q.current.value="");const K={id:j(),type:"attachment",text:`attached ${h.name}`,userId:g.id,userName:g.name,createdAt:new Date};f.pushFieldValue("activity",K)},Ne=x=>{const h=f.getFieldValue("attachments")||[];f.setFieldValue("attachments",h.filter(K=>K.id!==x));const B={id:j(),type:"delete",text:"removed an attachment",userId:g.id,userName:g.name,createdAt:new Date};f.pushFieldValue("activity",B)},ie=!!l?.id,pe=x=>{x.preventDefault(),x.stopPropagation(),f.handleSubmit()},fe=e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsx(f.Field,{name:"title",children:x=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe.Label,{htmlFor:"title",className:"text-right",children:S("common.title")}),e.jsx(ye.Input,{id:"title",value:x.state.value,onChange:h=>x.handleChange(h.target.value),placeholder:S("kanban.cardTitlePlaceholder"),className:"text-lg font-semibold"})]})}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsx("div",{className:"w-[200px]",children:e.jsx(f.Field,{name:"columnId",children:x=>e.jsxs($.Select,{value:x.state.value,onValueChange:h=>x.handleChange(h),children:[e.jsx($.SelectTrigger,{children:e.jsx($.SelectValue,{placeholder:"Status"})}),e.jsx($.SelectContent,{children:u.map(h=>e.jsx($.SelectItem,{value:h.id,children:h.name},h.id))})]})})}),ie&&e.jsxs("span",{className:"text-sm text-muted-foreground font-mono",children:["#",l?.id?.slice(0,8)]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(f.Field,{name:"priority",children:x=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe.Label,{children:"Priority"}),e.jsxs($.Select,{value:x.state.value,onValueChange:h=>x.handleChange(h),children:[e.jsx($.SelectTrigger,{children:e.jsx($.SelectValue,{placeholder:"Priority"})}),e.jsxs($.SelectContent,{children:[e.jsx($.SelectItem,{value:"low",children:"Low"}),e.jsx($.SelectItem,{value:"medium",children:"Medium"}),e.jsx($.SelectItem,{value:"high",children:"High"}),e.jsx($.SelectItem,{value:"critical",children:"Critical"})]})]})]})}),e.jsx(f.Field,{name:"startDate",children:x=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe.Label,{children:"Start Date"}),e.jsx(je.DateTimePicker,{date:x.state.value,setDate:h=>x.handleChange(h),mode:"date"})]})}),e.jsx(f.Field,{name:"dueDate",children:x=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe.Label,{children:"Due Date"}),e.jsx(je.DateTimePicker,{date:x.state.value,setDate:h=>x.handleChange(h),mode:"date"})]})})]}),e.jsx(f.Field,{name:"description",children:x=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe.Label,{children:"Description"}),e.jsx(we,{value:x.state.value||"",onChange:h=>x.handleChange(h.target.value),className:"min-h-[150px]"})]})}),m.length>0&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 border-t pt-4",children:m.map(x=>e.jsx(f.Field,{name:`customFieldValues.${x.id}`,children:h=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe.Label,{children:x.name}),x.type==="text"&&e.jsx(ye.Input,{value:h.state.value||"",onChange:B=>h.handleChange(B.target.value)}),x.type==="number"&&e.jsx(ye.Input,{type:"number",value:h.state.value||"",onChange:B=>h.handleChange(Number(B.target.value))}),x.type==="date"&&e.jsx(je.DateTimePicker,{date:h.state.value,setDate:B=>h.handleChange(B),mode:"date"}),x.type==="select"&&e.jsxs($.Select,{value:h.state.value||"",onValueChange:B=>h.handleChange(B),children:[e.jsx($.SelectTrigger,{children:e.jsx($.SelectValue,{placeholder:"Select..."})}),e.jsx($.SelectContent,{children:x.options?.map(B=>e.jsx($.SelectItem,{value:B,children:B},B))})]}),x.type==="checkbox"&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(re.Checkbox,{checked:!!h.state.value,onCheckedChange:B=>h.handleChange(!!B)}),e.jsx("span",{className:"text-sm font-medium",children:x.name})]})]})},x.id))}),e.jsxs(Fe,{defaultValue:"subtasks",className:"w-full",children:[e.jsxs(Ee,{className:"grid w-full grid-cols-5",children:[e.jsx(ue,{value:"subtasks",children:"Subtasks"}),e.jsx(ue,{value:"checklists",children:"Checklists"}),e.jsx(ue,{value:"attachments",children:"Attachments"}),e.jsx(ue,{value:"comments",children:"Comments"}),e.jsx(ue,{value:"activity",children:"Activity"})]}),e.jsxs(me,{value:"subtasks",className:"space-y-4 pt-4",children:[e.jsx(f.Field,{name:"subtasks",children:x=>e.jsxs("div",{className:"space-y-2",children:[x.state.value?.map(h=>e.jsxs("div",{className:"flex items-center gap-2 border p-3 rounded-md",children:[e.jsx(re.Checkbox,{checked:h.isCompleted,onCheckedChange:()=>ne(h.id)}),e.jsx("span",{className:h.isCompleted?"line-through text-muted-foreground flex-1":"flex-1",children:h.title}),e.jsx(z.Button,{variant:"ghost",size:"icon",onClick:()=>P(h.id),children:e.jsx(z.X,{className:"w-4 h-4"})})]},h.id)),(!x.state.value||x.state.value.length===0)&&e.jsx("div",{className:"text-center py-8 text-muted-foreground border border-dashed rounded-lg",children:"No subtasks yet."})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ye.Input,{value:I,onChange:x=>q(x.target.value),placeholder:"Add a subtask...",onKeyDown:x=>x.key==="Enter"&&W()}),e.jsx(z.Button,{onClick:W,disabled:!I.trim(),children:"Add"})]})]}),e.jsxs(me,{value:"checklists",className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"font-medium",children:"Checklists"}),e.jsxs(z.Button,{size:"sm",onClick:w,variant:"outline",children:[e.jsx(re.Plus,{className:"w-4 h-4 mr-2"})," Add Checklist"]})]}),e.jsx(f.Field,{name:"checklists",children:x=>e.jsxs("div",{className:"space-y-4",children:[x.state.value?.map(h=>{const B=h.items.length>0?Math.round(h.items.filter(K=>K.isChecked).length/h.items.length*100):0;return e.jsxs("div",{className:"border rounded-md p-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("div",{className:"font-medium",children:h.title}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[B,"%"]})]}),e.jsx("div",{className:"h-2 w-full bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${B}%`}})}),e.jsx("div",{className:"space-y-2",children:h.items.map(K=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re.Checkbox,{checked:K.isChecked,onCheckedChange:()=>a(h.id,K.id)}),e.jsx("span",{className:K.isChecked?"line-through text-muted-foreground":"",children:K.text})]},K.id))}),e.jsxs("div",{className:"pt-2 flex gap-2",children:[e.jsx(ye.Input,{placeholder:"Add an item...",className:"h-8 text-sm",value:c[h.id]||"",onChange:K=>D(h.id,K.target.value),onKeyDown:K=>K.key==="Enter"&&i(h.id)}),e.jsx(z.Button,{size:"sm",onClick:()=>i(h.id),disabled:!c[h.id]?.trim(),children:"Add"})]})]},h.id)}),(!x.state.value||x.state.value.length===0)&&e.jsx("div",{className:"text-center py-8 text-muted-foreground border border-dashed rounded-lg",children:"No checklists yet."})]})})]}),e.jsxs(me,{value:"attachments",className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"font-medium",children:"Attachments"}),e.jsx("input",{type:"file",className:"hidden",ref:Q,onChange:be}),e.jsxs("div",{className:"flex items-center gap-2",children:[X&&e.jsx("span",{className:"text-xs text-red-500",children:X}),e.jsxs(z.Button,{size:"sm",variant:"outline",onClick:()=>Q.current?.click(),disabled:G,children:[G?e.jsx(Z.LoaderCircle,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(je.Paperclip,{className:"w-4 h-4 mr-2"}),G?"Uploading...":"Upload"]})]})]}),e.jsx(f.Field,{name:"attachments",children:x=>e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[x.state.value?.map(h=>e.jsxs("div",{className:"border p-2 rounded flex items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 bg-muted flex items-center justify-center rounded",children:e.jsx(pt,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{className:"overflow-hidden",children:[e.jsx("div",{className:"truncate font-medium text-sm",children:h.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:h.type})]}),e.jsx(z.Button,{variant:"ghost",size:"icon",className:"ml-auto",onClick:()=>Ne(h.id),children:e.jsx(z.X,{className:"w-4 h-4 text-muted-foreground"})})]},h.id)),(!x.state.value||x.state.value.length===0)&&!G&&e.jsx("div",{className:"text-center py-8 text-muted-foreground border border-dashed rounded-lg",children:"No attachments yet."})]})})]}),e.jsxs(me,{value:"comments",className:"space-y-4 pt-4",children:[e.jsx(f.Field,{name:"comments",children:x=>e.jsxs("div",{className:"space-y-4",children:[x.state.value?.map(h=>e.jsxs("div",{className:"flex gap-3",children:[e.jsx(he.Avatar,{className:"w-8 h-8",children:e.jsx(he.AvatarFallback,{children:h.authorName[0]})}),e.jsxs("div",{className:"space-y-1 w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-sm",children:h.authorName}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(h.createdAt).toLocaleString()})]}),p===h.id?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(we,{value:E,onChange:B=>F(B.target.value),onKeyDown:B=>{B.key==="Enter"&&(B.metaKey||B.ctrlKey)?H():B.key==="Escape"&&Y()},autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(z.Button,{size:"sm",variant:"ghost",onClick:Y,children:"Cancel"}),e.jsx(z.Button,{size:"sm",onClick:H,children:"Save"})]})]}):e.jsx("div",{className:"text-sm bg-muted/50 p-2 rounded-md",children:h.text}),T===h.id&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-red-50 text-red-800 rounded-md text-sm mt-2",children:[e.jsx(Z.TriangleAlert,{className:"w-4 h-4"}),e.jsx("span",{className:"flex-1",children:"Delete this comment?"}),e.jsx(z.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-red-100 text-red-800",onClick:U,children:"No"}),e.jsx(z.Button,{size:"sm",variant:"destructive",className:"h-6 px-2",onClick:()=>b(h.id),children:"Yes"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(z.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>O(h),disabled:!!T,children:e.jsx(bt,{className:"w-3 h-3 text-muted-foreground"})}),e.jsx(z.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>V(h.id),disabled:!!T,children:e.jsx(Pe.Trash2,{className:"w-3 h-3 text-muted-foreground"})})]})]},h.id)),(!x.state.value||x.state.value.length===0)&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No comments yet."})]})}),e.jsx("div",{className:"pt-4 border-t sticky bottom-0 bg-background",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he.Avatar,{className:"w-8 h-8",children:e.jsx(he.AvatarFallback,{children:g?.name?.[0]||"U"})}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(we,{value:o,onChange:x=>d(x.target.value),placeholder:"Write a comment...",rows:2}),e.jsx("div",{className:"flex justify-end",children:e.jsx(z.Button,{size:"sm",onClick:M,disabled:!o.trim(),children:"Send"})})]})]})})]}),e.jsx(me,{value:"activity",className:"space-y-4 pt-4",children:e.jsx(f.Field,{name:"activity",children:x=>e.jsxs("div",{className:"space-y-4",children:[x.state.value?.map(h=>e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-1",children:e.jsx(xt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:h.userName})," ",e.jsx("span",{className:"text-muted-foreground",children:h.text}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:new Date(h.createdAt).toLocaleString()})]})]},h.id)),(!x.state.value||x.state.value.length===0)&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No activity yet."})]})})})]})]});return e.jsxs(se.Modal,{isOpen:t,onClose:s,title:ie?"Edit Card":"New Card",className:"sm:max-w-[800px] h-[85vh] flex flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto pr-2",children:fe}),e.jsxs("div",{className:"flex justify-between pt-4 border-t mt-4",children:[ie&&e.jsx(z.Button,{variant:"destructive",onClick:A,children:"Delete Card"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsx(z.Button,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(z.Button,{onClick:x=>pe(x),children:"Save"})]})]})]})},De=te.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:_.cn("rounded-xl border bg-card text-card-foreground shadow",t),...s}));De.displayName="Card";const Me=te.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:_.cn("flex flex-col space-y-1.5 p-6",t),...s}));Me.displayName="CardHeader";const Ye=te.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:_.cn("font-semibold leading-none tracking-tight",t),...s}));Ye.displayName="CardTitle";const Xe=te.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:_.cn("text-sm text-muted-foreground",t),...s}));Xe.displayName="CardDescription";const ke=te.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:_.cn("p-6 pt-0",t),...s}));ke.displayName="CardContent";const Ze=te.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:_.cn("flex items-center p-6 pt-0",t),...s}));Ze.displayName="CardFooter";const $e={Active:"success",Verified:"success",Completed:"info","In Progress":"info",Pending:"warning",Inactive:"error",Unverified:"error","On Leave":"error",Archived:"neutral",Default:"neutral"},Ve=v.memo(({status:t,className:s,showDot:n=!0,variant:r="solid"})=>{const l=$e[t]||$e.Default,u=r==="outline"||t==="Archived";return e.jsxs("div",{className:_.cn("inline-flex items-center justify-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold border tracking-wide transition-all duration-300 shadow-sm whitespace-nowrap",s),style:{backgroundColor:u?"transparent":`var(--ez-status-${l}-bg)`,color:u?l==="neutral"?`var(--ez-status-${l}-text)`:`var(--ez-status-${l}-bg)`:`var(--ez-status-${l}-text)`,borderColor:`var(--ez-status-${l}-border)`,minWidth:"120px"},children:[n&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shadow-[0_0_8px_rgba(0,0,0,0.1)] flex-shrink-0",style:{backgroundColor:`var(--ez-status-${l}-dot)`}}),t]})});Ve.displayName="StatusBadge";const qe={formatDate:(t,s="PP")=>{if(!t)return"";const n=new Date(t);return se.isValid(n)?se.format(n,s):""},formatDateTime:(t,s="PP p")=>{if(!t)return"";const n=new Date(t);return se.isValid(n)?se.format(n,s):""},isValidDate:t=>{const s=new Date(t);return se.isValid(s)}},Ge=({card:t,onClick:s,onDoubleClick:n,isDragging:r,isHighlighted:l,enableTooltip:u,tooltipTemplate:C,customFields:m,slots:g,slotProps:S,className:j,dir:f})=>{const A=f==="rtl",{attributes:c,listeners:y,setNodeRef:w,transform:D,transition:i,isDragging:a}=xe.useSortable({id:t.id,data:{type:"card",card:t}}),o=r||a,d={transform:ce.CSS.Translate.toString(D),transition:i},p={low:"Pending",medium:"In Progress",high:"Active",critical:"Inactive"},k=t.checklists?.reduce((V,U)=>V+U.items.length,0)||0,E=t.checklists?.reduce((V,U)=>V+U.items.filter(b=>b.isChecked).length,0)||0,F=t.subtasks?.length||0,T=t.subtasks?.filter(V=>V.isCompleted).length||0,N=e.jsxs("div",{className:"p-0 space-y-2",children:[t.coverImage&&e.jsx("div",{className:"h-32 w-full overflow-hidden rounded-t-lg",children:e.jsx("img",{src:t.coverImage,alt:"Cover",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:_.cn("p-3 space-y-2",t.coverImage?"pt-1":""),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h4",{className:"font-medium text-sm line-clamp-2 flex-1",children:t.title}),t.priority&&e.jsx(Ve,{status:p[t.priority]||"Pending",className:"shrink-0"})]}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:t.description}),t.tags&&t.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:t.tags.map(V=>e.jsx(Te,{variant:"secondary",className:"text-xs px-2 py-0",style:{backgroundColor:V.color,color:"#fff"},children:V.name},V.id))}),(k>0||t.attachments&&t.attachments.length>0||t.comments&&t.comments.length>0||F>0||t.timeTracking)&&e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground pt-1 flex-wrap",children:[t.attachments&&t.attachments.length>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(je.Paperclip,{className:"w-3 h-3"}),e.jsx("span",{children:t.attachments.length})]}),t.comments&&t.comments.length>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(yt,{className:"w-3 h-3"}),e.jsx("span",{children:t.comments.length})]}),k>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(Dt,{className:"w-3 h-3"}),e.jsxs("span",{children:[E,"/",k]})]}),F>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(Ct,{className:"w-3 h-3"}),e.jsxs("span",{children:[T,"/",F]})]}),t.timeTracking&&(t.timeTracking.estimated>0||t.timeTracking.actual>0)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",title:`Estimated: ${t.timeTracking.estimated}h, Actual: ${t.timeTracking.actual}h`,children:[e.jsx(se.Clock,{className:"w-3 h-3"}),e.jsxs("span",{children:[t.timeTracking.actual,"h / ",t.timeTracking.estimated,"h"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[t.assignees&&t.assignees.length>0&&e.jsxs("div",{className:"flex -space-x-2",children:[t.assignees.slice(0,3).map(V=>e.jsx(he.Avatar,{className:"w-6 h-6 border-2 border-background",children:V.avatarUrl?e.jsx(he.AvatarImage,{src:V.avatarUrl,alt:V.name}):e.jsx(he.AvatarFallback,{className:"text-xs",children:V.name.substring(0,2).toUpperCase()})},V.id)),t.assignees.length>3&&e.jsx("div",{className:"w-6 h-6 rounded-full bg-muted border-2 border-background flex items-center justify-center",children:e.jsxs("span",{className:"text-xs",children:["+",t.assignees.length-3]})})]}),t.dueDate&&e.jsxs("div",{className:_.cn("flex items-center gap-1 text-xs text-muted-foreground",A?"mr-auto":"ml-auto"),children:[e.jsx(dt.Calendar,{className:"w-3 h-3"}),e.jsx("span",{children:qe.formatDate(t.dueDate)})]})]})]}),m&&m.length>0&&t.customFieldValues&&e.jsx("div",{className:"px-3 pb-3 gap-1 flex flex-wrap",children:m.map(V=>{const U=t.customFieldValues?.[V.id];return U==null||U===""?null:e.jsxs("div",{className:"text-xs bg-muted px-1.5 py-0.5 rounded flex items-center gap-1 max-w-full truncate",children:[e.jsxs("span",{className:"text-muted-foreground opacity-70",children:[V.name,":"]}),e.jsx("span",{className:"font-medium truncate",children:V.type==="date"?qe.formatDate(U):String(U)})]},V.id)})})]}),M=g?.cardContent,O=M?e.jsx(M,{card:t,...S?.cardContent}):N,H=e.jsx(De,{ref:w,style:d,...c,...y,onClick:()=>s?.(t),onDoubleClick:()=>n?.(t),id:t.id,"data-card-id":t.id,className:_.cn("cursor-pointer transition-all hover:shadow-md overflow-hidden",o&&"opacity-50 ring-2 ring-primary/50",l&&"ring-2 ring-primary bg-primary/5 transition-colors duration-300",j),children:O}),Y=g?.card;return Y?e.jsx(Y,{card:t,defaultContent:H,...S?.card}):e.jsx(J.TooltipWrapper,{enabled:u,content:C?C(t):null,children:H})};Ge.displayName="KanbanCard";const ze=v.memo(Ge),Kt=({cards:t,estimateSize:s=120,overscan:n=5})=>{const r=v.useRef(null),l=ut.useVirtualizer({count:t.length,getScrollElement:()=>r.current,estimateSize:()=>s,overscan:n});return{parentRef:r,virtualizer:l,virtualItems:l.getVirtualItems(),totalSize:l.getTotalSize()}},et=({column:t,cards:s,onCardClick:n,onCardDoubleClick:r,onCardDragStart:l,onAddCard:u,onToggleCollapse:C,onDeleteColumn:m,onUpdateColumn:g,onColumnClick:S,selectedColumnId:j,draggedCardId:f,highlightedCardId:A,isDropTarget:c,customFields:y,className:w,dir:D,slots:i,slotProps:a})=>{const o=D==="rtl",{t:d}=ge(),[p,k]=v.useState(!1),E=i?.card||ze,[F,T]=v.useState(t.name),N=v.useRef(null);v.useEffect(()=>{p&&N.current&&(N.current.focus(),N.current.select())},[p]);const M=()=>{F.trim()&&F!==t.name?g?.(t.id,{name:F}):T(t.name),k(!1)},O=P=>{P.key==="Enter"?M():P.key==="Escape"&&(T(t.name),k(!1))},H=t.wipLimit&&s.length>t.wipLimit,Y=t.wipLimit&&s.length===t.wipLimit,{setNodeRef:V,attributes:U,listeners:b,transform:I,transition:q,isDragging:W}=xe.useSortable({id:t.id,data:{type:"column",column:t}}),ne={transform:ce.CSS.Translate.toString(I),transition:q};return e.jsxs(De,{ref:V,style:ne,className:_.cn("flex flex-col w-80 shrink-0 transition-all duration-200",j===t.id?"ring-2 ring-primary border-primary":"",W?"opacity-50":"",c?"ring-2 ring-primary/70 border-primary/50 bg-primary/5":"",w),onClick:()=>S?.(t.id),children:[e.jsxs(Me,{className:"pb-3",onDoubleClick:()=>k(!0),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{...U,...b,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-muted rounded text-muted-foreground/50 hover:text-primary transition-colors",children:e.jsx(Le.Ellipsis,{className:"h-4 w-4"})}),e.jsx(z.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>C?.(t.id),children:t.isCollapsed?o?e.jsx(Z.ChevronRight,{className:"h-4 w-4 rotate-180"}):e.jsx(Z.ChevronRight,{className:"h-4 w-4"}):e.jsx(Qe.ChevronDown,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[p?e.jsx("input",{ref:N,value:F,onChange:P=>T(P.target.value),onBlur:M,onKeyDown:O,className:"h-6 w-full text-sm font-semibold border rounded px-1 bg-background",onClick:P=>P.stopPropagation()}):e.jsx("h3",{className:"font-semibold text-sm truncate",title:t.name,children:t.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.length," ",d("items")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(Se.DropdownMenu,{children:[e.jsx(Se.DropdownMenuTrigger,{asChild:!0,children:e.jsx(z.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:e.jsx(Le.Ellipsis,{className:"h-4 w-4"})})}),e.jsx(Se.DropdownMenuContent,{align:"end",children:e.jsxs(Se.DropdownMenuItem,{className:"text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>m?.(t.id),children:[e.jsx(Pe.Trash2,{className:"h-4 w-4 me-2"}),d("delete_column")||"Delete Column"]})})]}),e.jsx(z.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>u?.(t.id),children:e.jsx(re.Plus,{className:"h-4 w-4"})})]})]}),t.wipLimit&&e.jsx("div",{className:"mt-2",children:e.jsx("div",{className:"h-1 w-full bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:_.cn("h-full transition-all",H?"bg-red-500":Y?"bg-yellow-500":"bg-green-500"),style:{width:`${Math.min(s.length/t.wipLimit*100,100)}%`}})})})]}),!t.isCollapsed&&(()=>{const P=s.sort((Q,G)=>Q.position-G.position);if(P.length>50){const{parentRef:Q,virtualItems:G,totalSize:le}=Kt({cards:P,estimateSize:120,overscan:5});return e.jsxs(ke,{ref:Q,className:"flex-1 overflow-y-auto max-h-[calc(100vh-200px)]",children:[e.jsx("div",{style:{height:`${le}px`,position:"relative"},children:G.map(X=>{const ae=P[X.index];return e.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${X.start}px)`,paddingBottom:"8px"},children:e.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${X.start}px)`,paddingBottom:"8px"},children:e.jsx(E,{card:ae,onClick:n,onDoubleClick:r,onDragStart:l,isDragging:f===ae.id,isHighlighted:A===ae.id,customFields:y,dir:D,...a?.card})},ae.id)},ae.id)})}),P.length===0&&e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:d("no_cards")})]})}return e.jsxs(ke,{className:"flex-1 overflow-y-auto max-h-[calc(100vh-200px)] space-y-2",children:[e.jsx(xe.SortableContext,{items:s.map(Q=>Q.id),strategy:xe.verticalListSortingStrategy,children:P.map(Q=>e.jsx(E,{card:Q,onClick:n,onDoubleClick:r,onDragStart:l,isDragging:f===Q.id,isHighlighted:A===Q.id,customFields:y,dir:D,...a?.card},Q.id))}),s.length===0&&e.jsx("div",{className:_.cn("flex h-32 items-center justify-center rounded-lg border border-dashed text-sm transition-all duration-150",c?"border-primary/60 bg-primary/5 text-primary/70":"text-muted-foreground"),children:c?"✦ Drop here":d("no_cards")})]})})()]})},$t=({swimlaneId:t,columnId:s,children:n,className:r})=>{const{isOver:l,setNodeRef:u}=ce.useDroppable({id:`swimlane-cell-${t}-${s}`,data:{type:"swimlane-cell",swimlaneId:t,columnId:s}});return e.jsx("div",{ref:u,className:_.cn(r,l&&"bg-primary/5 transition-colors"),children:n})},Be=({swimlane:t,columns:s,cards:n,onCardClick:r,onCardDoubleClick:l,onCardDragStart:u,onCardDragEnd:C,onToggleCollapse:m,draggedCardId:g,highlightedCardId:S,customFields:j,className:f,dir:A,slots:c,slotProps:y})=>{const w=A==="rtl",{t:D}=ge(),i=c?.card||ze;return e.jsxs("div",{className:_.cn("flex flex-col border rounded-lg bg-card text-card-foreground shadow-sm mb-4",f),children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 border-b bg-muted/30",children:[e.jsx(z.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>m?.(t.id),children:t.isCollapsed?w?e.jsx(Z.ChevronRight,{className:"h-4 w-4 rotate-180"}):e.jsx(Z.ChevronRight,{className:"h-4 w-4"}):e.jsx(Qe.ChevronDown,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold text-sm",children:t.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",n.length," ",D("items"),")"]})]}),!t.isCollapsed&&e.jsx("div",{className:_.cn("flex divide-x",w&&"divide-x-reverse"),children:s.map(a=>{const o=n.filter(d=>d.columnId===a.id);return e.jsx($t,{swimlaneId:t.id,columnId:a.id,className:"flex-1 min-w-[280px] p-2 min-h-[100px]",children:e.jsx("div",{className:"space-y-2",children:o.map(d=>e.jsx(i,{card:d,onClick:r,onDoubleClick:l,onDragStart:u,onDragEnd:C,isDragging:g===d.id,isHighlighted:S===d.id,customFields:j,dir:A,...y?.card},d.id))})},a.id)})})]})},qt=(t,s)=>s.find(r=>r.id===t.columnId)?.color||"hsl(var(--primary))",tt=({cards:t,columns:s,swimlanes:n,onCardUpdate:r,onCardClick:l,onCardCreate:u,className:C,dir:m})=>{const g=v.useMemo(()=>{let c=[];return n&&n.length>0?(c=n.sort((y,w)=>y.position-w.position).map(y=>({id:y.id,name:y.name,color:y.color})),t.some(y=>!y.swimlaneId)&&c.push({id:"uncategorized",name:"Uncategorized",color:"hsl(var(--muted-foreground))"}),c):s.sort((y,w)=>y.position-w.position).map(y=>({id:y.id,name:y.name,color:y.color}))},[n,s,t]),S=v.useMemo(()=>t.map(c=>{const y=n&&n.length>0?c.swimlaneId||"uncategorized":c.columnId||"uncategorized",w=c.startDate?new Date(c.startDate):c.dueDate?se.startOfDay(new Date(c.dueDate)):se.startOfDay(new Date),D=c.dueDate?new Date(c.dueDate):se.addDays(w,1),i=s.find(a=>a.id===c.columnId);return{id:c.id,title:c.title,start:w,end:D,resourceId:y||"uncategorized",description:c.description,color:qt(c,s),status:i?.name,originalCard:c}}),[t,n,s]),j=v.useCallback(c=>{const y=c.originalCard;if(!y)return;const w={...y,startDate:c.start,dueDate:c.end,...n&&n.length>0?{swimlaneId:c.resourceId}:{columnId:c.resourceId||y.columnId||s[0]?.id||""}};r?.(w,"move")},[r,n,s]),f=v.useCallback(c=>{const y=n&&n.length>0,w={title:c.title||"New Card",startDate:c.start,dueDate:c.end,columnId:!y&&c.resourceId?c.resourceId:s[0]?.id||"",swimlaneId:y&&c.resourceId?c.resourceId:void 0,description:c.description||"",priority:"medium"};u?.(w)},[n,s,u]),A=v.useCallback(c=>{const y=c.originalCard;y&&l?.(y)},[l]);return e.jsx("div",{className:C,style:{height:"100%",minHeight:"600px"},children:e.jsx(se.EzScheduler,{events:S,resources:g,selectedDate:new Date,view:"TimelineMonth",views:["TimelineWeek","TimelineMonth"],onEventChange:j,onEventCreate:f,onEventClick:A,showHeaderBar:!0,showResourceHeaders:!0,dir:m})})},st=({board:t,onCardClick:s,onCardDoubleClick:n,onCardDragStart:r,onCardDragEnd:l,onCardDrop:u,onAddCard:C,onToggleColumnCollapse:m,onToggleSwimlaneCollapse:g,onAddColumn:S,onDeleteColumn:j,onUpdateColumn:f,onColumnClick:A,onCreateCard:c,selectedColumnId:y,draggedCardId:w,filteredCards:D,slots:i,slotProps:a,className:o,view:d="standard",dir:p})=>{const k=D||t.cards,{t:E}=ge(),[F,T]=v.useState(null),[N,M]=v.useState(null);if(d==="timeline")return e.jsx(tt,{cards:k,columns:t.columns,swimlanes:t.swimlanes,onCardUpdate:u?async(b,I)=>{I==="move"&&u(b.columnId,b.swimlaneId)}:void 0,onCardClick:s,onCardCreate:c,className:o,dir:p});const O=()=>!t.swimlanes||t.swimlanes.length===0?null:e.jsx("div",{className:_.cn("flex flex-col p-4 overflow-y-auto h-full",o),children:e.jsxs(xe.SortableContext,{items:k.map(b=>b.id),children:[t.swimlanes.sort((b,I)=>b.position-I.position).map(b=>{const I=k.filter(q=>q.swimlaneId===b.id);return e.jsx(Be,{swimlane:b,columns:t.columns.sort((q,W)=>q.position-W.position),cards:I,onCardClick:s,onCardDoubleClick:n,onCardDragStart:r,onCardDragEnd:l,onDrop:u,onToggleCollapse:g,draggedCardId:w,customFields:t.customFields,slots:i,slotProps:a,dir:p},b.id)}),k.some(b=>!b.swimlaneId)&&e.jsx(Be,{swimlane:{id:"uncategorized",name:E("uncategorized"),type:"custom",position:9999,isCollapsed:!1},columns:t.columns.sort((b,I)=>b.position-I.position),cards:k.filter(b=>!b.swimlaneId),onCardClick:s,onCardDoubleClick:n,onCardDragStart:r,onCardDragEnd:l,onDrop:u,onToggleCollapse:()=>{},draggedCardId:w,customFields:t.customFields,slots:i,slotProps:a,dir:p})]})}),H=ce.useSensors(ce.useSensor(ce.PointerSensor,{activationConstraint:{distance:5}})),Y=b=>{const{active:I}=b;I.data.current?.type==="card"&&(T(I.data.current.card),r?.(I.data.current.card))},V=b=>{const{over:I}=b;if(!I){M(null);return}I.data.current?.type==="column"?M(I.data.current.column.id):I.data.current?.type==="card"?M(I.data.current.card.columnId):I.data.current?.type==="swimlane-cell"?M(I.data.current.columnId):M(null)},U=b=>{const{active:I,over:q}=b;if(T(null),M(null),!q){l?.();return}if(I.data.current?.type==="card"){let W,ne,P;if(q.data.current?.type==="column")W=q.data.current.column.id,ne=void 0;else if(q.data.current?.type==="swimlane-cell")W=q.data.current.columnId,P=q.data.current.swimlaneId;else if(q.data.current?.type==="card"){const Q=q.data.current.card;W=Q.columnId,P=Q.swimlaneId;let G=t.cards.filter(X=>X.columnId===W);P&&(G=G.filter(X=>X.swimlaneId===P)),G.sort((X,ae)=>(X.position??0)-(ae.position??0));const le=G.findIndex(X=>X.id===Q.id);ne=le>=0?le:void 0}W?u?.(W,P,ne):l?.()}else I.data.current?.type==="column"&&q.data.current?.type,l?.()};return e.jsxs(ce.DndContext,{sensors:H,onDragStart:Y,onDragOver:V,onDragEnd:U,children:[d==="swimlane"?O():e.jsxs("div",{className:_.cn("flex gap-4 overflow-x-auto p-4",o),children:[e.jsx(xe.SortableContext,{items:t.columns.map(b=>b.id),strategy:xe.horizontalListSortingStrategy,children:t.columns.sort((b,I)=>b.position-I.position).map(b=>{const I=k.filter(q=>q.columnId===b.id);return e.jsx(et,{column:b,cards:I,onCardClick:s,onCardDoubleClick:n,onCardDragStart:r,onCardDragEnd:l,onDrop:u,onAddCard:C,onToggleCollapse:m,onDeleteColumn:j,onUpdateColumn:f,onColumnClick:A,selectedColumnId:y,draggedCardId:w,isDropTarget:N===b.id,customFields:t.customFields,slots:i,slotProps:a,dir:p},b.id)})}),S&&e.jsx("div",{className:"w-80 shrink-0",children:e.jsxs(z.Button,{variant:"outline",className:"w-full h-12 border-dashed",onClick:S,children:[e.jsx(re.Plus,{className:"me-2 h-4 w-4"}),E("add_column")||"Add Column"]})})]}),e.jsx(ce.DragOverlay,{dropAnimation:{duration:200,easing:"ease"},children:F?e.jsx("div",{className:"rotate-2 opacity-90 shadow-2xl ring-2 ring-primary/60 rounded-lg pointer-events-none w-72",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg p-3 space-y-1",children:[e.jsx("p",{className:"font-medium text-sm",children:F.title}),F.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:F.description})]})}):null})]})},Pt=({isOpen:t,onClose:s,onConfirm:n,title:r,message:l,description:u})=>{const{t:C}=ge(),m=()=>{n(),s()};return e.jsx(se.Modal,{isOpen:t,onClose:s,title:r||C("confirm_delete")||"Confirm Delete",size:"sm",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(z.Button,{variant:"ghost",onClick:s,children:C("cancel")||"Cancel"}),e.jsx(z.Button,{variant:"destructive",onClick:m,children:C("delete")||"Delete"})]}),children:e.jsxs("div",{className:"py-2",children:[e.jsx("p",{children:l||C("confirm_delete_message")||"Are you sure you want to delete this item?"}),(u||C("action_cannot_be_undone"))&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:u||C("action_cannot_be_undone")||"This action cannot be undone."})]})})},Qt=new J.QueryClient,nt=v.forwardRef((t,s)=>{const{className:n,readOnly:r,...l}=t;return _.useInitCoreServices(),e.jsx(J.QueryClientProvider,{client:Qt,children:e.jsx(Z.EzErrorBoundary,{fallback:e.jsx(Tt,{}),children:e.jsx(at,{ref:s,className:n,readOnly:r,...l})})})});nt.displayName="EzKanban";const at=v.forwardRef((t,s)=>{const{className:n,readOnly:r,onCardClick:l,onCardDoubleClick:u}=t,C=Oe(t,s),{state:m,actions:g,dir:S,imperativeAPI:j}=C,[f,A]=v.useState(!1),[c,y]=v.useState(void 0),[w,D]=v.useState(!1),[i,a]=v.useState(null);v.useImperativeHandle(s,()=>j,[j]);const o=N=>{const M=N||m.selectedColumnId||m.board.columns[0]?.id;y({columnId:M,title:"",description:"",priority:"medium"}),A(!0)},d=async N=>{N.id?await g.updateCard(N.id,N):await g.createCard(N),A(!1)},p=N=>{t.confirmOnDelete!==!1?(a(N),D(!0),A(!1)):(g.deleteCard(N),A(!1))},k=async()=>{i&&(await g.deleteCard(i),D(!1),a(null))},E=N=>{r||(y(N),A(!0)),l?.(N)},F=N=>{const M=m.board.columns.find(O=>O.id===N);M&&(M.isCollapsed?g.expandColumn(N):g.collapseColumn(N))},T=N=>{const M=m.board.swimlanes?.find(O=>O.id===N);M&&(M.isCollapsed?g.expandSwimlane(N):g.collapseSwimlane(N))};return e.jsxs("div",{className:_.cn("flex flex-col h-full bg-background",n),dir:S,children:[e.jsx(_e.NotificationPanel,{}),e.jsx(_e.NotificationPanel,{}),!r&&(t.slots?.toolbar?e.jsx(t.slots.toolbar,{searchQuery:m.searchQuery,onSearchChange:g.setSearchQuery,onAddCardClick:()=>o(),onAddColumn:()=>{g.createColumn({name:"New Column",position:m.board.columns.length}).then(N=>{g.setSelectedColumnId(N.id)})},activeFilters:m.activeFilters,onFiltersChange:g.setActiveFilters,view:m.view,onViewChange:g.setView,onUndo:g.undo,onRedo:g.redo,canUndo:m.canUndo,canRedo:m.canRedo,...t.slotProps?.toolbar||{}}):e.jsx(We,{searchQuery:m.searchQuery,onSearchChange:g.setSearchQuery,onAddCardClick:()=>o(),onAddColumn:()=>{g.createColumn({name:"New Column",position:m.board.columns.length}).then(N=>{g.setSelectedColumnId(N.id)})},activeFilters:m.activeFilters,onFiltersChange:g.setActiveFilters,view:m.view,onViewChange:g.setView,onUndo:g.undo,onRedo:g.redo,canUndo:m.canUndo,canRedo:m.canRedo})),e.jsx("div",{className:"flex-1 overflow-hidden h-full",children:t.slots?.board?e.jsx(t.slots.board,{board:m.board,onCardClick:E,onCardDoubleClick:u,onCardDragStart:g.handleDragStart,onCardDragEnd:g.handleDragEnd,onCardDrop:g.handleDrop,onAddCard:o,onToggleColumnCollapse:F,onToggleSwimlaneCollapse:T,onDeleteColumn:g.deleteColumn,onUpdateColumn:g.updateColumn,onColumnClick:g.setSelectedColumnId,onCreateCard:d,selectedColumnId:m.selectedColumnId,draggedCardId:m.draggedCard?.id,filteredCards:m.filteredCards,slots:t.slots,slotProps:t.slotProps,view:m.view,dir:S,className:"flex-1 h-full",...t.slotProps?.board||{}}):e.jsx(st,{board:m.board,onCardClick:E,onCardDoubleClick:u,onCardDragStart:g.handleDragStart,onCardDragEnd:g.handleDragEnd,onCardDrop:g.handleDrop,onAddCard:o,onToggleColumnCollapse:F,onToggleSwimlaneCollapse:T,onDeleteColumn:g.deleteColumn,onUpdateColumn:g.updateColumn,onColumnClick:g.setSelectedColumnId,onCreateCard:d,selectedColumnId:m.selectedColumnId,draggedCardId:m.draggedCard?.id,filteredCards:m.filteredCards,slots:t.slots,slotProps:t.slotProps,view:m.view,dir:S,className:"flex-1 h-full"})}),t.slots?.cardEditor?e.jsx(t.slots.cardEditor,{isOpen:f,onClose:()=>A(!1),onSave:d,onDelete:p,card:c,columns:m.board.columns,...t.slotProps?.cardEditor||{}}):e.jsx(Je,{isOpen:f,onClose:()=>A(!1),onSave:d,onDelete:p,card:c,columns:m.board.columns}),e.jsx(Pt,{isOpen:w,onClose:()=>D(!1),onConfirm:k,title:"Confirm Delete",message:"Are you sure you want to delete this card?",description:"This action cannot be undone."})]})});at.displayName="EzKanbanInner";exports.Badge=Te;exports.Card=De;exports.CardContent=ke;exports.CardDescription=Xe;exports.CardEditorModal=Je;exports.CardFooter=Ze;exports.CardHeader=Me;exports.CardTitle=Ye;exports.EzKanban=nt;exports.KanbanBoardComponent=st;exports.KanbanCard=ze;exports.KanbanColumn=et;exports.KanbanSwimlane=Be;exports.KanbanTimelineView=tt;exports.KanbanToolbar=We;exports.StatusBadge=Ve;exports.Tabs=Fe;exports.TabsContent=me;exports.TabsList=Ee;exports.TabsTrigger=ue;exports.Textarea=we;exports.badgeVariants=He;exports.useDebounce=Ue;exports.useEzKanban=Oe;exports.useI18n=ge;
|