@object-ui/plugin-gantt 14.0.0 → 14.1.0
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/CHANGELOG.md +37 -0
- package/dist/ObjectGantt.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @object-ui/plugin-gantt
|
|
2
2
|
|
|
3
|
+
## 14.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [82441e4]
|
|
8
|
+
- Updated dependencies [2efa9fd]
|
|
9
|
+
- Updated dependencies [0890fa7]
|
|
10
|
+
- Updated dependencies [2ded18c]
|
|
11
|
+
- Updated dependencies [e628d1f]
|
|
12
|
+
- Updated dependencies [5523fc4]
|
|
13
|
+
- Updated dependencies [887062c]
|
|
14
|
+
- Updated dependencies [471c5d3]
|
|
15
|
+
- Updated dependencies [579b24d]
|
|
16
|
+
- Updated dependencies [2b30583]
|
|
17
|
+
- Updated dependencies [23d65c3]
|
|
18
|
+
- Updated dependencies [055e1d2]
|
|
19
|
+
- Updated dependencies [f9a7907]
|
|
20
|
+
- Updated dependencies [9e2d58f]
|
|
21
|
+
- Updated dependencies [dea65f7]
|
|
22
|
+
- Updated dependencies [f30ff68]
|
|
23
|
+
- Updated dependencies [073e7aa]
|
|
24
|
+
- Updated dependencies [3e8bf07]
|
|
25
|
+
- Updated dependencies [6c0135c]
|
|
26
|
+
- Updated dependencies [5b52624]
|
|
27
|
+
- Updated dependencies [4afb251]
|
|
28
|
+
- Updated dependencies [d5b1bc0]
|
|
29
|
+
- Updated dependencies [f94905d]
|
|
30
|
+
- Updated dependencies [2712fc1]
|
|
31
|
+
- Updated dependencies [f0f10f5]
|
|
32
|
+
- @object-ui/i18n@14.1.0
|
|
33
|
+
- @object-ui/plugin-detail@14.1.0
|
|
34
|
+
- @object-ui/fields@14.1.0
|
|
35
|
+
- @object-ui/core@14.1.0
|
|
36
|
+
- @object-ui/types@14.1.0
|
|
37
|
+
- @object-ui/react@14.1.0
|
|
38
|
+
- @object-ui/components@14.1.0
|
|
39
|
+
|
|
3
40
|
## 14.0.0
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectGantt.d.ts","sourceRoot":"","sources":["../src/ObjectGantt.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAyB,MAAM,kBAAkB,CAAC;AA0B5F,OAAO,EAA6B,KAAK,eAAe,EAAsB,KAAK,aAAa,EAAsB,MAAM,aAAa,CAAC;AAO1I;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtE;AA2GD,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAUzE;AAiBD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,EAAE,CAqBrE;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC;AAiID,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ObjectGantt.d.ts","sourceRoot":"","sources":["../src/ObjectGantt.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAyB,MAAM,kBAAkB,CAAC;AA0B5F,OAAO,EAA6B,KAAK,eAAe,EAAsB,KAAK,aAAa,EAAsB,MAAM,aAAa,CAAC;AAO1I;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtE;AA2GD,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAUzE;AAiBD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,EAAE,CAqBrE;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC;AAiID,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA0nClD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3711,7 +3711,7 @@ var Pt = ({ schema: e, dataSource: o, className: f, onTaskClick: p, onRowClick:
|
|
|
3711
3711
|
if (t.options) continue;
|
|
3712
3712
|
let r = e[t.field] ?? e[t.field.split(".")[0]], i = r?.type;
|
|
3713
3713
|
if (i !== "lookup" && i !== "master_detail") continue;
|
|
3714
|
-
let a = r?.reference_to ?? r?.referenceTo;
|
|
3714
|
+
let a = r?.reference_to ?? r?.reference ?? r?.referenceTo;
|
|
3715
3715
|
if (a) try {
|
|
3716
3716
|
let e = c(await o.find(a, { $top: 1e3 }));
|
|
3717
3717
|
n[t.field] = e.map((e) => ({
|
package/dist/index.umd.cjs
CHANGED
|
@@ -92,4 +92,4 @@ endobj
|
|
|
92
92
|
bar. Hide it — the pane stays wheel/drag-scrollable and synced. */
|
|
93
93
|
.gantt-task-list::-webkit-scrollbar { width: 0; height: 0; }
|
|
94
94
|
.gantt-task-list { scrollbar-width: none; }
|
|
95
|
-
`}),(0,f.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":k(`gantt.toolbar.prevPeriod`),children:(0,f.jsx)(u.ChevronLeft,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":k(`gantt.toolbar.nextPeriod`),children:(0,f.jsx)(u.ChevronRight,{className:`h-4 w-4`})}),(0,f.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:K.start.toLocaleDateString(A,{month:`long`,year:`numeric`})}),N&&(0,f.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,"data-testid":`gantt-readonly-badge`,title:k(`gantt.readOnlyHint`),children:[(0,f.jsx)(u.Lock,{className:`h-3 w-3`}),k(`gantt.readOnly`)]})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":k(`gantt.toolbar.viewMode`),children:j.map(e=>(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:(0,c.cn)(`h-6 px-1.5 sm:px-2 text-xs`,z===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>Cn(e),"aria-pressed":z===e,"data-testid":`gantt-view-mode-${e}`,children:k(`gantt.viewMode.${e}`)},e))}),(0,f.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(nt>15)We(Math.max(15,nt-10));else{let e=j.indexOf(z);e<j.length-1&&(Cn(j[e+1]),We(Be))}},"aria-label":k(`gantt.toolbar.zoomOut`),children:(0,f.jsx)(u.ZoomOut,{className:`h-3 w-3`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(nt<120)We(Math.min(120,nt+10));else{let e=j.indexOf(z);e>0&&(Cn(j[e-1]),We(Be))}},"aria-label":k(`gantt.toolbar.zoomIn`),children:(0,f.jsx)(u.ZoomIn,{className:`h-3 w-3`})})]}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Qe(e=>!e),"aria-label":k(Ze?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":Ze,"data-testid":`gantt-toggle-task-list`,children:Ze?(0,f.jsx)(u.PanelLeft,{className:`h-4 w-4`}):(0,f.jsx)(u.PanelLeftClose,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Zn,disabled:Q==null,"aria-label":k(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:k(`gantt.toolbar.today`)}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:tr,"aria-label":k(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:k(`gantt.toolbar.thisWeek`)}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:nr,"aria-label":k(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:k(`gantt.toolbar.thisMonth`)}),le?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void le(),disabled:ue,"aria-label":k(`gantt.toolbar.refresh`),"aria-busy":ue,"data-testid":`gantt-refresh`,children:(0,f.jsx)(u.RefreshCw,{className:`h-4 w-4`})}):null,P?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:kt,disabled:!jt,"aria-label":k(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,f.jsx)(u.Undo2,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:At,disabled:!Mt,"aria-label":k(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,f.jsx)(u.Redo2,{className:`h-4 w-4`})})]}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Tr(e=>!e),"aria-label":k(`gantt.toolbar.criticalPath`),"aria-pressed":wr,"data-testid":`gantt-critical-path`,style:wr?{color:$}:void 0,children:(0,f.jsx)(u.Activity,{className:`h-4 w-4`})}),Re&&P?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Or,"aria-label":k(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,f.jsx)(u.Wand2,{className:`h-4 w-4`})}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Ar,"aria-label":k(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,f.jsx)(u.Download,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:jr,"aria-label":k(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,f.jsx)(u.FileDown,{className:`h-4 w-4`})}),ce||O?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Pr,"aria-label":k(`gantt.toolbar.saveLayout`),"aria-pressed":Mr,"data-testid":`gantt-save-layout`,style:Mr?{color:$}:void 0,children:(0,f.jsx)(u.Save,{className:`h-4 w-4`})}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Kn,"aria-label":k(Wn?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":Wn,"data-testid":`gantt-fullscreen`,children:Wn?(0,f.jsx)(u.Minimize2,{className:`h-4 w-4`}):(0,f.jsx)(u.Maximize2,{className:`h-4 w-4`})})]})]}),(0,f.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:hn,"data-testid":`gantt-body`,children:[!Ze&&B>0&&(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:B-3,width:7,cursor:`col-resize`},"data-testid":`gantt-list-resize`,role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=B,r=Math.max(160,Pe-200),i=e=>{let i=Math.max(160,Math.min(n+(e.clientX-t),r));Ke(i)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a),document.body.style.cursor=``};document.body.style.cursor=`col-resize`,window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},onDoubleClick:()=>Ke(null),children:(0,f.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover/splitter:w-[3px] group-hover/splitter:bg-primary transition-all`})}),(0,f.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,f.jsxs)(`div`,{className:`flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm`,style:{width:B,minWidth:B},children:[(0,f.jsx)(`div`,{className:`flex-1 truncate`,children:k(`gantt.column.taskName`)}),it&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:k(`gantt.column.start`)}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:k(`gantt.column.end`)})]})]}),(0,f.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:On,children:(0,f.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:yn},children:[(0,f.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:En.slice(Hn.start,Hn.end).map(e=>(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 flex items-center justify-center border-r text-[10px] font-medium text-muted-foreground overflow-hidden`,style:{left:e.offset,width:e.width},children:(0,f.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,f.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.start+t;return(0,f.jsxs)(`div`,{className:(0,c.cn)(`absolute top-0 bottom-0 flex items-center justify-center gap-1 border-r text-xs text-muted-foreground overflow-hidden`,e.isWeekend&&`bg-muted/50`),style:{left:J[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,f.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&nt>=32&&(0,f.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,f.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,f.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:kn,onScroll:ir,style:{width:B,minWidth:B},role:`tree`,"aria-label":k(`gantt.aria.taskList`),children:[Z.startIdx>0&&(0,f.jsx)(`div`,{style:{height:Z.startIdx*R},"aria-hidden":`true`}),G.slice(Z.startIdx,Z.endIdx).map(e=>{let t=e.task,n=Le&&at===t.id,r=dn.has(String(t.id)),i=on!=null&&String(on)===String(t.id);return(0,f.jsxs)(`div`,{className:(0,c.cn)(`group/task-row relative flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors`,i&&`bg-accent/50`),style:{height:R,touchAction:`manipulation`},role:`treeitem`,"data-testid":`gantt-task-row-${t.id}`,"aria-level":e.depth+1,"aria-selected":i,"aria-expanded":e.hasChildren?!r:void 0,draggable:!!L&&!n&&!t.locked,onDragStart:L?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:L?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:L?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=ft.get(n);r&&String(r.parent??``)===String(t.parent??``)&&L(r,t)}:void 0,onContextMenu:e=>ln(t,e),onClick:()=>{sn(t.id),n||er(e.start,e.end,t.id)},onDoubleClick:()=>{n||(Le&&P&&!e.isSummary&&!t.locked?(ot(t.id),ct({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})):o?.(t))},children:[(0,f.jsxs)(`div`,{className:`flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2`,style:e.depth>0?{paddingLeft:e.depth*14}:void 0,children:[e.hasChildren?(0,f.jsx)(`button`,{type:`button`,className:`h-4 w-4 shrink-0 flex items-center justify-center text-muted-foreground hover:text-foreground`,style:{marginLeft:-4},onClick:e=>{e.stopPropagation(),pn(t.id)},"aria-expanded":!r,"aria-label":k(r?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:r?(0,f.jsx)(u.ChevronRight,{className:`h-3.5 w-3.5`}):(0,f.jsx)(u.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,f.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,f.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),n?(0,f.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.title||``,onChange:e=>ct(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Ct([{task:t,changes:{title:st.title,start:new Date(st.start),end:new Date(st.end),progress:Number(st.progress)||0}}]),ot(null)):e.key===`Escape`&&ot(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,f.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,f.jsx)(`span`,{className:(0,c.cn)(`truncate`,e.isSummary&&`font-semibold`),children:t.title}),(0,f.jsxs)(`span`,{className:`text-[10px] text-muted-foreground gantt-sm-hidden`,children:[e.start.toLocaleDateString(A,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})]})]})]}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!it,style:it?void 0:{display:`none`},children:n?(0,f.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.start||``,onChange:e=>ct(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!it,style:it?void 0:{display:`none`},children:n?(0,f.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.end||``,onChange:e=>ct(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}),o&&(0,f.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!n&&(0,f.jsx)(`button`,{type:`button`,title:k(`gantt.row.open`),"aria-label":k(`gantt.row.open`),"data-testid":`gantt-row-open-${t.id}`,className:`gantt-row-open-btn h-6 w-6 rounded-md flex items-center justify-center hover:bg-accent text-muted-foreground hover:text-foreground`,onClick:e=>{e.stopPropagation(),o(t)},children:(0,f.jsx)(u.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),Z.endIdx<G.length&&(0,f.jsx)(`div`,{style:{height:(G.length-Z.endIdx)*R},"aria-hidden":`true`})]}),(0,f.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{An.current=e,X.current=e},onScroll:rr,onTouchStart:Jn,onTouchMove:Yn,onTouchEnd:Xn,"data-testid":`gantt-timeline`,children:(0,f.jsxs)(`div`,{className:`relative`,style:{width:yn},children:[Q!=null&&(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:Q,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":k(`gantt.toolbar.today`),children:(0,f.jsx)(`div`,{className:`absolute -translate-x-1/2 left-0 text-[10px] font-semibold text-white rounded-sm px-1 py-0.5 whitespace-nowrap z-30`,style:{top:2,backgroundColor:`#ef4444`},children:k(`gantt.toolbar.today`)})}),Dn.map(e=>(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:e.left,backgroundColor:e.color},"data-testid":`gantt-marker-${e.index}`,"aria-label":e.label,children:e.label&&(0,f.jsx)(`div`,{className:`absolute -translate-x-1/2 left-0 text-[10px] font-semibold text-white rounded-sm px-1 py-0.5 whitespace-nowrap z-30`,style:{top:2,backgroundColor:e.color},children:e.label})},e.index)),(0,f.jsxs)(`div`,{className:`relative`,ref:zt,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.start+t;return(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:J[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 8%, transparent)`:e.isWeekend?`hsl(var(--muted) / 0.4)`:void 0}},n)})}),gn&&S&&S.showMidnight&&(0,f.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.start+t,r=e.realMs??0;if(!r)return null;let i=e.date.getTime(),a=e.date,o=new Date(a.getFullYear(),a.getMonth(),a.getDate()+1,0,0,0,0).getTime();return o<=i||o>=i+r?null:(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0`,style:{left:J[n]+(o-i)/r*e.width,borderLeft:`1px dashed hsl(var(--muted-foreground) / 0.4)`},"data-testid":`gantt-midnight-${n}`,"aria-hidden":`true`},`midnight-${n}`)})}),Z.startIdx>0&&(0,f.jsx)(`div`,{style:{height:Z.startIdx*R},"aria-hidden":`true`}),G.slice(Z.startIdx,Z.endIdx).map(e=>{let n=e.task,r=Dr(n.id),i=ar(e.start,e.end),a=re&&n.baselineStart&&n.baselineEnd?ar(n.baselineStart,n.baselineEnd):null,o=a?(0,f.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:a.left,width:Math.max(2,a.width),top:yr,height:vr,backgroundColor:br,border:`1px solid ${xr}`},"data-testid":`gantt-baseline-${n.id}`,"aria-hidden":`true`}):null,s=H?.taskId===n.id,l=sr?.has(String(n.id))??!1,u=cr?.has(String(n.id))??!1,d=s||l||u?lr(e):i,p=!!n.locked,m=!!P&&!e.isSummary&&!p,h=N||p,g=U!=null&&U.targetId!=null&&String(U.targetId)===String(n.id)&&String(U.sourceId)!==String(n.id),_=U?e=>{let t=e.currentTarget.getBoundingClientRect(),r=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;Bt(e=>e&&Rt(e.sourceId,n)?{...e,targetId:n.id,targetEnd:r}:e)}:void 0,v=U?e=>{e.target===e.currentTarget&&Bt(e=>e&&{...e,targetId:null,targetEnd:null})}:void 0,ee=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/xe)),y=lt===n.id&&!H&&!Pt&&!U?(0,f.jsxs)(`div`,{className:`absolute z-30 pointer-events-none rounded-md border bg-popover text-popover-foreground px-2.5 py-1.5 text-xs shadow-md whitespace-nowrap`,style:{left:Math.max(d.left+8,4),top:R-8},role:`tooltip`,"data-testid":`gantt-tooltip-${n.id}`,children:[(0,f.jsx)(`div`,{className:`font-semibold`,children:n.title}),n.fields&&n.fields.length>0?(0,f.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:n.fields.map((e,n)=>(0,f.jsxs)(t.Fragment,{children:[(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,f.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,f.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(A,{month:`short`,day:`numeric`}),` → `,e.end.toLocaleDateString(A,{month:`short`,day:`numeric`}),` · `,ee,k(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),n.locked||N&&!P?(0,f.jsxs)(`div`,{className:`text-muted-foreground`,style:{marginTop:4},"data-testid":`gantt-tooltip-locked-${n.id}`,children:[`🚫 `,k(`gantt.lockedHint`)]}):null]}):null;if(n.type===`group`)return(0,f.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:y},n.id);if(e.isSummary){let t=n.color||`#0d9488`;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:[o,(0,f.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none`,P&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left,width:d.width,top:_r,height:gr,cursor:P?void 0:h?`not-allowed`:`pointer`,backgroundColor:t,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-summary-bar-${n.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),onPointerDown:t=>{t.button===0&&Nt(n,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})},onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),children:[(0,f.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${Math.round(e.progress)}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),(0,f.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:n.title})]}),s&&H&&(0,f.jsxs)(`div`,{className:`absolute z-30 pointer-events-none rounded border bg-popover text-popover-foreground px-1.5 py-0.5 text-[10px] shadow whitespace-nowrap`,style:{left:Math.max(d.left,4),top:_r+gr+2},"data-testid":`gantt-summary-drag-chip-${n.id}`,children:[_t(H).start.toLocaleDateString(A,{month:`numeric`,day:`numeric`}),` → `,_t(H).end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})]}),y]},n.id)}if(e.isMilestone){let e=mr;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:[o,(0,f.jsx)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,m&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left-e/2,top:(R-e)/2,width:e,height:e,cursor:m?void 0:h?`not-allowed`:`pointer`,backgroundColor:r?$:n.color||`#3b82f6`,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-milestone-${n.id}`,onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),onPointerMove:_,onPointerDown:m?e=>{e.button===0&&Nt(n,`move`,e)}:void 0}),y]},n.id)}let b=Pt&&Pt.taskId===n.id?Pt.value:n.progress;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),children:[s&&(0,f.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:i.left,width:i.width,top:dr,height:fr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),o,(0,f.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm bg-primary border shadow-sm flex items-center px-2 group select-none`,m&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left,width:d.width,top:dr,height:fr,cursor:m?void 0:h?`not-allowed`:`pointer`,backgroundColor:n.color||`#3b82f6`,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-task-bar-${n.id}`,onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),onPointerMove:_,onPointerDown:m?e=>{if(e.button!==0)return;let t=he(e.clientX,e.currentTarget.getBoundingClientRect());Nt(n,t,e)}:void 0,children:[m&&d.width>=14&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:me,height:pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${n.id}`,onPointerDown:e=>{e.button===0&&Nt(n,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,f.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:me,height:pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${n.id}`,onPointerDown:e=>{e.button===0&&Nt(n,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),b>0&&(0,f.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${b}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),m&&d.width>=30&&(0,f.jsx)(`div`,{className:(0,c.cn)(`absolute bottom-0 h-1/2 w-4 -translate-x-1/2 cursor-col-resize flex items-end justify-center pb-px`,Pt?.taskId===n.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${b}%`},"data-testid":`gantt-progress-handle-${n.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),Ft({taskId:n.id,originClientX:e.clientX,originProgress:n.progress,barWidth:d.width,value:n.progress}))},onClick:e=>e.stopPropagation(),children:(0,f.jsx)(`div`,{style:{width:0,height:0,borderLeft:`5px solid transparent`,borderRight:`5px solid transparent`,borderBottom:`7px solid #fff`,filter:`drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35))`}})}),F&&!p&&[`start`,`end`].map(e=>{let t=U!=null&&String(U.sourceId)===String(n.id)&&U.sourceEnd===e,r=t||lt===n.id,i=r&&U==null;return(0,f.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 z-20 flex items-center transition-opacity`,style:{[e===`start`?`left`:`right`]:-28,height:24,width:30,cursor:`crosshair`,opacity:+!!r,pointerEvents:i?`auto`:`none`,justifyContent:e===`start`?`flex-start`:`flex-end`,paddingLeft:e===`start`?4:0,paddingRight:e===`end`?4:0},"data-testid":`gantt-link-dot-${e}-${n.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let r=zt.current?.getBoundingClientRect();Bt({sourceId:n.id,sourceEnd:e,x:r?t.clientX-r.left:0,y:r?t.clientY-r.top:0,targetId:null,targetEnd:null})},onClick:e=>e.stopPropagation(),children:(0,f.jsx)(`div`,{className:`rounded-full`,style:{height:12,width:12,backgroundColor:`hsl(var(--background))`,border:`2px solid hsl(var(--primary))`,boxShadow:t?`0 0 0 3px hsl(var(--primary) / 0.25)`:`0 1px 2px rgba(0,0,0,0.25)`}})},e)}),(0,f.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:n.title}),(0,f.jsx)(`span`,{className:`absolute inset-0 flex items-center px-2 text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`,children:s?`${_t(H).start.toLocaleDateString(A,{month:`numeric`,day:`numeric`})} → ${_t(H).end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}`:`${Math.round(b)}%`})]}),y]},n.id)}),Z.endIdx<G.length&&(0,f.jsx)(`div`,{style:{height:(G.length-Z.endIdx)*R},"aria-hidden":`true`}),(ur.length>0||U)&&(0,f.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:yn,height:Un,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,f.jsxs)(`defs`,{children:[(0,f.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,f.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,f.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:$})})]}),ur.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<Z.startIdx-6||n>Z.endIdx+6)return null;let r=Sr(e);if(!r)return null;let i=Cr!=null&&(String(e.sourceId)===String(Cr)||String(e.targetId)===String(Cr)),a=Er?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(I||F);return(0,f.jsxs)(t.Fragment,{children:[(0,f.jsx)(`path`,{d:r,fill:`none`,stroke:a?$:i?`hsl(var(--primary))`:`hsl(var(--muted-foreground))`,strokeOpacity:a||i?1:.7,strokeWidth:a||i?2:1.5,markerEnd:`url(#${o})`,"data-testid":`gantt-link-${e.sourceId}-${e.targetId}`,"data-link-type":e.type,"data-active":i?`true`:`false`,"data-critical":a?`true`:void 0}),s&&(0,f.jsx)(`path`,{d:r,fill:`none`,stroke:`transparent`,strokeWidth:10,style:{pointerEvents:`stroke`,cursor:`context-menu`},"data-testid":`gantt-link-hit-${e.sourceId}-${e.targetId}`,onContextMenu:t=>un(e.sourceId,e.targetId,e.type,t)})]},e.key)}),U&&(()=>{let e=G.findIndex(e=>String(e.task.id)===String(U.sourceId));if(e<0)return null;let t=lr(G[e]),n=G[e].isMilestone?t.left+(U.sourceEnd===`start`?-hr:hr):U.sourceEnd===`start`?t.left:t.left+t.width,r=e*R+R/2;return(0,f.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(U.x)} ${Math.round(U.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),U&&(()=>{let t=e.find(e=>String(e.id)===String(U.sourceId));if(!t)return null;let n=U.targetId==null?null:e.find(e=>String(e.id)===String(U.targetId)),r=e=>k(`gantt.linkEnd.${e}`),i=n?`${t.title} (${r(U.sourceEnd)}) → ${n.title} (${r(U.targetEnd??`start`)})`:`${t.title} (${r(U.sourceEnd)})`;return(0,f.jsx)(`div`,{className:`absolute z-30 pointer-events-none rounded-md border bg-popover text-popover-foreground px-2 py-1 text-[11px] font-medium shadow-md whitespace-nowrap`,style:{left:U.x+12,top:U.y+12},"data-testid":`gantt-link-draft-hint`,children:i})})()]})]})})]})]}),Ht&&(()=>{let t=e.find(e=>String(e.id)===String(Ht.taskId));if(!t)return null;let n=G.find(e=>String(e.task.id)===String(Ht.taskId)),r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,f.jsxs)(`div`,{ref:Wt,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:Ht.x,top:Ht.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[o&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-view`,onClick:()=>{Ut(null),o(t)},children:k(`gantt.menu.view`)}),s&&(()=>{let e=s(t);return e?(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-qrcode`,onClick:()=>{Ut(null),Kt({task:t,url:e})},children:k(`gantt.menu.qrcode`)}):null})(),Le&&P&&n&&!n.isSummary&&!t.locked&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-edit`,onClick:()=>{Ut(null),ot(t.id),ct({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})},children:k(`gantt.menu.edit`)}),F&&n&&!n.isMilestone&&!t.locked&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let e=Ht;Ut(null),rn(``),tn({x:e.x,y:e.y,taskId:t.id,relation:`pred`})},children:k(`gantt.menu.addPredecessor`)}),(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let e=Ht;Ut(null),rn(``),tn({x:e.x,y:e.y,taskId:t.id,relation:`succ`})},children:k(`gantt.menu.addSuccessor`)})]}),Ie&&!t.locked&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,c.cn)(r,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{Ut(null),Ie(t)},children:k(`gantt.menu.delete`)})]})})(),Gt&&(0,f.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,"data-testid":`gantt-qr-dialog`,onClick:()=>Kt(null),children:(0,f.jsxs)(`div`,{role:`dialog`,"aria-label":k(`gantt.qr.title`),className:`w-[280px] rounded-lg border bg-popover text-popover-foreground p-4 shadow-lg`,onClick:e=>e.stopPropagation(),children:[(0,f.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-sm font-medium`,children:[(0,f.jsx)(u.QrCode,{className:`h-4 w-4 shrink-0`}),(0,f.jsx)(`span`,{className:`truncate`,children:Gt.task.title})]}),(0,f.jsx)(`div`,{className:`mb-2 text-xs text-muted-foreground`,children:k(`gantt.qr.hint`)}),qt?(0,f.jsx)(`img`,{src:qt,alt:k(`gantt.qr.title`),"data-testid":`gantt-qr-image`,className:`mx-auto block h-[220px] w-[220px] rounded bg-white`}):(0,f.jsx)(`div`,{className:`flex h-[220px] items-center justify-center text-sm text-muted-foreground`,children:`…`}),(0,f.jsx)(`div`,{className:`mt-2 break-all text-[11px] text-muted-foreground`,"data-testid":`gantt-qr-url`,children:Gt.url}),(0,f.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,f.jsxs)(c.Button,{variant:`outline`,size:`sm`,"data-testid":`gantt-qr-copy`,onClick:Zt,children:[Yt?(0,f.jsx)(u.Check,{className:`mr-1 h-3 w-3`}):(0,f.jsx)(u.Copy,{className:`mr-1 h-3 w-3`}),k(Yt?`gantt.qr.copied`:`gantt.qr.copy`)]}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,"data-testid":`gantt-qr-close`,onClick:()=>Kt(null),children:k(`gantt.qr.close`)})]})]})}),W&&(()=>{let t=e.find(e=>String(e.id)===String(W.sourceId)),n=e.find(e=>String(e.id)===String(W.targetId));if(!t||!n)return null;let r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`,i=[`fs`,`ss`,`ff`,`sf`],a=!!n.locked;return(0,f.jsxs)(`div`,{ref:$t,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:W.x,top:W.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,f.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[t.title,` → `,n.title]}),a&&(0,f.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,k(`gantt.lockedHint`)]}),F&&i.map(e=>(0,f.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":W.type===e,disabled:a,className:(0,c.cn)(r,W.type===e&&`font-semibold`,a&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${e}`,onClick:()=>{a||(Qt(null),e!==W.type&&F(t,n,e))},children:[W.type===e?`✓ `:`\xA0\xA0`,k(`gantt.linkType.${e}`)]},e)),I&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`my-1 border-t`}),(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:a,className:(0,c.cn)(r,`text-destructive`,a&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{a||(Qt(null),I(t,n))},children:k(`gantt.menu.removeDependency`)})]})]})})(),en&&F&&(()=>{let t=e.find(e=>String(e.id)===String(en.taskId));if(!t)return null;let n=new Set(ur.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),r=e.filter(e=>{if(String(e.id)===String(t.id)||e.type===`group`||e.locked)return!1;let r=en.relation===`pred`?`${String(e.id)}->${String(t.id)}`:`${String(t.id)}->${String(e.id)}`;return!n.has(r)}),i=nn.trim().toLowerCase(),a=i?r.filter(e=>String(e.title??``).toLowerCase().includes(i)):r;return(0,f.jsxs)(`div`,{ref:an,className:`fixed z-50 min-w-[200px] max-h-[280px] overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:en.x,top:en.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,f.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:en.relation===`pred`?k(`gantt.menu.addPredecessor`):k(`gantt.menu.addSuccessor`)}),(0,f.jsx)(`div`,{className:`px-2 pb-1`,children:(0,f.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:nn,onChange:e=>rn(e.target.value),placeholder:k(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),a.length===0?(0,f.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:k(`gantt.menu.noCandidates`)}):a.map(e=>(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none truncate`,"data-testid":`gantt-dep-picker-option-${e.id}`,onClick:()=>{tn(null),en.relation===`pred`?F(e,t,`fs`):F(t,e,`fs`)},children:e.title},String(e.id)))]})})(),wt&&(0,f.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>Tt(null),children:(0,f.jsxs)(`div`,{className:`min-w-[280px] max-w-[360px] rounded-lg border bg-popover text-popover-foreground shadow-lg p-4`,role:`alertdialog`,"aria-modal":`true`,"data-testid":`gantt-conflict-dialog`,onClick:e=>e.stopPropagation(),children:[(0,f.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:k(`gantt.conflict.title`)}),(0,f.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:k(`gantt.conflict.body`).replace(`{count}`,String(wt.length))}),(0,f.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,f.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md border hover:bg-accent outline-none`,"data-testid":`gantt-conflict-cancel`,onClick:()=>Tt(null),children:k(`gantt.conflict.cancel`)}),(0,f.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:opacity-90 outline-none`,"data-testid":`gantt-conflict-confirm`,onClick:Dt,children:k(`gantt.conflict.confirm`)})]})]})})]})}function Me(e,t,n,r){return t.getTime()===e.getTime()?e.getTime()>=n.getTime()&&e.getTime()<r.getTime():e.getTime()<r.getTime()&&t.getTime()>n.getTime()}function Ne(e,t,n){let{assignee:r,effort:i,capacity:a=1,unassignedLabel:o=`Unassigned`}=n,s=e=>typeof a==`function`?a(e):a,c=e=>{let t=i?i(e):1;return Number.isFinite(t)&&t>0?t:0},l=new Map;for(let t of e){let e=r(t),n=e?String(e.key):`__unassigned__`,i=e?e.label:o,a=l.get(n);a||(a={key:n,label:i,items:[]},l.set(n,a)),a.items.push(t)}let u=[];for(let e of l.values()){let n=s(e.key),r=0,i=0,a=t.map(t=>{let a=0;for(let n of e.items)Me(n.start,n.end,t.start,t.end)&&(a+=c(n));a>r&&(r=a);let o=a>n+1e-9;return o&&i++,{load:a,capacity:n,overloaded:o}});u.push({key:e.key,label:e.label,capacity:n,cells:a,peak:r,overloadedCount:i})}return u}var Pe={day:26,week:56,month:76,quarter:88,year:104},Fe=48,N=34,P=180;function Ie(e,t,n){return t===`day`?String(e.getDate()):t===`week`?e.toLocaleDateString(n,{month:`numeric`,day:`numeric`}):t===`month`?e.toLocaleDateString(n,{month:`short`}):t===`year`?String(e.getFullYear()):`Q${Math.floor(e.getMonth()/3)+1}`}function F({tasks:e,assignee:n,effort:r,capacity:i=1,viewMode:a=`day`,unassignedLabel:o=`Unassigned`,className:s}){let{t:c,language:l}=pe(),u=l||void 0,d=Pe[a],p=t.useMemo(()=>{if(!e.length)return[];let t=new Date(Math.min(...e.map(e=>e.start.getTime()))),n=new Date(Math.max(...e.map(e=>e.end.getTime()))),r=Se(t,a),i=we(Se(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=we(r,1,a);o.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:Ie(r,a,u)}),r=e}return o},[e,a,u]),m=t.useMemo(()=>Ne(e,p.map(e=>e.col),{assignee:n,effort:r,capacity:i,unassignedLabel:o}),[e,p,n,r,i,o]),h=t.useMemo(()=>{let e=0;for(let t of m)e=Math.max(e,t.peak,t.capacity);return e||1},[m]),g=p.length*d;return e.length?(0,f.jsx)(`div`,{className:s,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,f.jsxs)(`div`,{style:{display:`flex`,minWidth:P+g},children:[(0,f.jsxs)(`div`,{style:{width:P,flexShrink:0},children:[(0,f.jsx)(`div`,{style:{height:28,display:`flex`,alignItems:`center`,padding:`0 12px`,fontSize:12,fontWeight:600,borderBottom:`1px solid hsl(var(--border))`},children:c(`gantt.resource.header`)}),m.map(e=>(0,f.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:Fe,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,f.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,f.jsxs)(`span`,{"data-testid":`resource-peak-${e.key}`,"data-overloaded":e.overloadedCount>0?`true`:void 0,style:{fontSize:10,color:e.overloadedCount>0?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`},children:[c(`gantt.resource.peak`),`: `,Math.round(e.peak*100)/100,` / `,e.capacity,e.overloadedCount>0?` · ${e.overloadedCount} ${c(`gantt.resource.over`)}`:``]})]},e.key))]}),(0,f.jsxs)(`div`,{style:{flex:1},children:[(0,f.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:p.map((e,t)=>(0,f.jsx)(`div`,{style:{width:d,flexShrink:0,textAlign:`center`,fontSize:10,color:`hsl(var(--muted-foreground))`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:e.label},t))}),m.map(e=>{let t=N*(1-Math.min(e.capacity/h,1));return(0,f.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:Fe,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,f.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:(Fe-N)/2+t,borderTop:`1px dashed hsl(var(--muted-foreground) / 0.6)`,pointerEvents:`none`,zIndex:1}}),e.cells.map((t,n)=>{let r=Math.max(t.load>0?2:0,N*Math.min(t.load/h,1));return(0,f.jsx)(`div`,{"data-testid":`resource-cell-${e.key}-${n}`,"data-load":t.load,"data-overloaded":t.overloaded?`true`:void 0,title:`${p[n]?.date.toLocaleDateString(u)} — ${Math.round(t.load*100)/100} / ${t.capacity}`,style:{width:d,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:(Fe-N)/2},children:t.load>0&&(0,f.jsx)(`div`,{style:{width:d-6,height:r,borderRadius:2,backgroundColor:t.overloaded?`hsl(var(--destructive))`:`hsl(var(--primary))`,opacity:t.overloaded?.9:.75}})},n)})]},e.key)})]})]})}):(0,f.jsx)(`div`,{className:s,"data-testid":`resource-workload`,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:c(`gantt.resource.empty`)})})}var I={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},L={display:`inline-flex`,alignItems:`center`,gap:6,height:30,padding:`0 10px`,borderRadius:6,border:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,color:`hsl(var(--foreground))`,cursor:`pointer`,whiteSpace:`nowrap`,lineHeight:`28px`},Le={position:`absolute`,top:`calc(100% + 4px)`,left:0,zIndex:50,minWidth:200,maxHeight:320,overflowY:`auto`,padding:4,borderRadius:8,border:`1px solid hsl(var(--border))`,background:`hsl(var(--popover, var(--background)))`,color:`hsl(var(--popover-foreground, var(--foreground)))`,boxShadow:`0 8px 24px rgba(0,0,0,0.18)`},Re={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function ze({checked:e}){return(0,f.jsx)(`span`,{"aria-hidden":!0,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:15,height:15,flex:`0 0 auto`,borderRadius:3,border:`1px solid ${e?`hsl(var(--primary))`:`hsl(var(--border))`}`,background:e?`hsl(var(--primary))`:`transparent`,color:`hsl(var(--primary-foreground, var(--background)))`,fontSize:11,lineHeight:1},children:e?`✓`:``})}function R({filter:e,selected:n,onChange:r,labels:i}){let[a,o]=(0,t.useState)(!1),s=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);let c=new Set(n),l=n.length,u=e.options.length>0&&l===e.options.length,d=t=>{let n=new Set(c);n.has(t)?n.delete(t):n.add(t),n.size===e.options.length?r([]):r([...n])},p=()=>{r(l>0?[]:e.options.map(e=>e.value))},m=l===0?e.label:l===1?`${e.label}: ${e.options.find(e=>e.value===n[0])?.label??n[0]}`:`${e.label} · ${l}`;return(0,f.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,f.jsxs)(`button`,{type:`button`,style:{...L,borderColor:l>0?`hsl(var(--primary))`:`hsl(var(--border))`,color:l>0?`hsl(var(--primary))`:`hsl(var(--foreground))`},"aria-haspopup":`listbox`,"aria-expanded":a,"data-testid":`quick-filter-trigger-${e.field}`,onClick:()=>o(e=>!e),children:[(0,f.jsx)(`span`,{children:m}),(0,f.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,f.jsx)(`div`,{role:`listbox`,style:Le,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,f.jsx)(`div`,{style:{...Re,cursor:`default`,opacity:.6},children:i.empty}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...Re,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>p(),children:[(0,f.jsx)(ze,{checked:u}),(0,f.jsx)(`span`,{children:i.all})]}),(0,f.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,f.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...Re,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>d(t.value),children:[(0,f.jsx)(ze,{checked:n}),(0,f.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var Be=({filters:e,value:t,onChange:n,onClear:r,resultCount:i,totalCount:a,labels:o,className:s})=>{if(!e.length)return null;let c=o?.all??`All`,l=o?.empty??`No options`,u=o?.clear??`Clear`,d=e.some(e=>(t[e.field]?.length??0)>0);return(0,f.jsxs)(`div`,{style:I,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,f.jsx)(R,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),d&&(0,f.jsx)(`button`,{type:`button`,style:{...L,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,f.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function Ve(e){if(e==null)return;let t=String(e).toLowerCase().trim();if(t===`milestone`)return`milestone`;if(t===`group`||t===`folder`)return`group`;if(t===`summary`||t===`project`||t===`phase`)return`summary`;if(t===`task`)return`task`}var He={fs:`fs`,ss:`ss`,ff:`ff`,sf:`sf`,finish_to_start:`fs`,start_to_start:`ss`,finish_to_finish:`ff`,start_to_finish:`sf`,end_to_start:`fs`,end_to_end:`ff`,start_to_end:`sf`};function Ue(e){if(e==null||e===``)return[];if(typeof e==`string`)return e.split(`,`).map(e=>e.trim()).filter(Boolean);if(typeof e==`number`)return[e];if(!Array.isArray(e))return[];let t=[];for(let n of e)if(!(n==null||n===``))if(typeof n==`object`){let e=n.id??n._id??n.task??n.target;if(e==null||e===``)continue;let r=He[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n);return t}function We(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function Ge(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function Ke(e){let t=e instanceof Error?e.message:String(e??``),n=t.indexOf(`{`);if(n>=0)try{let e=JSON.parse(t.slice(n)),r=e?.message??e?.error;if(typeof r==`string`&&r.trim())return r}catch{}return null}function z(e){let t=null;if(e.startDateField&&e.endDateField)return t={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||`name`,progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField,borderColorField:e.borderColorField,parentField:e.parentField,typeField:e.typeField,lockField:e.lockField,objectField:e.objectField,summaryExtent:e.summaryExtent,defaultCollapsedDepth:e.defaultCollapsedDepth,tooltipFields:e.tooltipFields,baselineStartField:e.baselineStartField,baselineEndField:e.baselineEndField,groupByField:e.groupByField,resourceView:e.resourceView,assigneeField:e.assigneeField,effortField:e.effortField,capacity:e.capacity,quickFilters:e.quickFilters,autoZoomToFilter:e.autoZoomToFilter,timeSegments:e.timeSegments},t;if(e.gantt&&(t=e.gantt),t){let e=a.GanttConfigSchema.safeParse(t);return e.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,e.error.format()),t}return null}var qe=({schema:e,dataSource:a,className:u,onTaskClick:d,onRowClick:p,...m})=>{let[h,g]=(0,t.useState)([]),[_,v]=(0,t.useState)(!0),[ee,y]=(0,t.useState)(null),[b,te]=(0,t.useState)(null),{currency:ne}=(0,o.useLocalization)(),{t:x}=pe(),S=(0,t.useCallback)(e=>{i.toast.error(x(`gantt.writeFailed`),{description:Ke(e)??void 0})},[x]),re=We(e),C=(0,t.useMemo)(()=>re,[JSON.stringify(re)]),w=z(e),ie=C?.provider===`value`,T=(0,t.useMemo)(()=>(0,n.resolveDataSource)(C,a??null),[C,a]),E=C?.provider===`object`?C.object:e.objectName??``,[ae,oe]=(0,t.useState)(!1),se=(0,t.useRef)(0),D=(0,t.useCallback)(async({silent:t=!1}={})=>{let r=++se.current,i=()=>se.current===r;try{if(t?oe(!0):v(!0),m.data&&Array.isArray(m.data)){i()&&g(m.data);return}if(ie&&C?.provider===`value`){i()&&g(C.items);return}if(!T||typeof T.find!=`function`)throw Error(`DataSource required for object/api providers`);let r=(0,n.buildExpandFields)(b?.fields),a=await T.find(E,{$filter:e.filter,$orderby:Ge(e.sort),...r.length>0?{$expand:r}:{}});i()&&g((0,n.extractRecords)(a))}catch(e){t?console.error(`[ObjectGantt] Failed to refresh data:`,e):i()&&y(e)}finally{t?oe(!1):v(!1)}},[T,E,ie,C,e.filter,e.sort,b]);(0,t.useEffect)(()=>{D()},[D]),(0,t.useEffect)(()=>{!ie&&T&&(async()=>{try{if(!T||!E)return;let e=await T.getObjectSchema(E);te(e)}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[E,T,ie,C]);let O=(0,t.useMemo)(()=>{if(!w||!h.length)return[];let{startDateField:e,endDateField:t,titleField:r,progressField:i,dependenciesField:a,colorField:s,borderColorField:c,parentField:u,typeField:d,lockField:f,tooltipFields:p,baselineStartField:m,baselineEndField:g,quickFilters:_}=w,v=b?.fields??{},ee=new Map;for(let e of _??[]){if(!e?.field||!Array.isArray(e.options)||!e.options.length)continue;let t=new Map;for(let n of e.options)typeof n==`string`?t.set(n,n):n&&n.value!=null&&t.set(String(n.value),n.label??String(n.value));t.size&&ee.set(e.field,t)}let y=(e,t)=>{if(!t)return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r},te=e=>{let t=[y(e,r),e?.account?.name,e?.opportunity?.name,e?.contact&&[e.contact.first_name,e.contact.last_name].filter(Boolean).join(` `)];for(let e of t)if(e!=null&&String(e).trim()!==``)return String(e);return(0,n.getRecordDisplayName)(b,e)},x=(e,t)=>{if(t)return t;let n=v[e]??v[e.split(`.`)[0]];return n?.label?n.label:(0,l.humanizeLabel)(e)},S=(e,t)=>{if(e==null||e===``)return`—`;let n=v[t]??v[t.split(`.`)[0]],r=n?.type,i=n?.options;if(Array.isArray(i)&&i.length){let t=i.find(t=>String(t.value)===String(e));if(t)return t.label}if(typeof e!=`object`){let n=ee.get(t)?.get(String(e));if(n!=null)return n}if(r==null&&typeof e==`string`){if(/^\d{4}-\d{2}-\d{2}$/.test(e))return(0,l.formatDate)(e);if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(e)&&!isNaN(new Date(e).getTime()))return(0,l.formatDateTime)(e)}switch(r){case`date`:return(0,l.formatDate)(e);case`datetime`:return(0,l.formatDateTime)(e);case`number`:case`integer`:case`float`:case`decimal`:return(0,l.formatNumber)(Number(e));case`currency`:return(0,l.formatCurrency)(Number(e),(0,o.resolveFieldCurrency)(n,ne));case`percent`:return(0,l.formatPercent)(Number(e));case`boolean`:case`checkbox`:return e?`Yes`:`No`;default:if(Array.isArray(e)){let t=e.map(e=>{if(e==null)return``;if(typeof e==`object`){let t=e;return String(t.name??t.label??t.title??t.id??``)}return String(e)}).filter(Boolean);return t.length?t.join(`, `):`—`}if(typeof e==`object`){let t=e;return String(t.name??t.label??t.title??t.id??`—`)}return String(e)}},re=e=>{if(!p||!p.length)return;let t=[];for(let n of p){let r=typeof n==`string`?n:n?.field;if(!r)continue;let i=typeof n==`object`?n.label:void 0,a=y(e,r);a==null||a===``||Array.isArray(a)&&a.length===0||t.push({label:x(r,i),value:S(a,r)})}return t.length?t:void 0};return h.map((n,r)=>{let o=n[e],p=n[t],h=m?n[m]:void 0,_=g?n[g]:void 0,v=h?new Date(h):void 0,ee=_?new Date(_):void 0,y=te(n),b=i?n[i]:0,ne=a?n[a]:[],x=s?n[s]:void 0;if(!x){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,l.getSemanticColorName)(void 0,e);t&&(x=(0,l.getSemanticHex)(t))}}let S=c?n[c]:void 0,C=S!=null&&S!==``?(0,l.getSemanticHex)(String(S),String(S)):void 0;return{id:n.id||n._id||`task-${r}`,title:y,start:o?new Date(o):new Date,end:p?new Date(p):new Date,hasOwnDates:!!(o&&p),progress:Math.min(100,Math.max(0,b||0)),dependencies:Ue(ne),parent:u?n[u]??null:void 0,type:d?Ve(n[d]):void 0,locked:f?!!n[f]:void 0,color:x,borderColor:C,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:ee&&!isNaN(ee.getTime())?ee:void 0,fields:re(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[h,w,b]),ce=(0,t.useMemo)(()=>{let e=w?.groupByField;if(!e)return;let t=b?.fields??{},n=(e,t)=>{if(!t)return;let n=e;for(let e of t.split(`.`)){if(n==null)return;n=n[e]}return n},r=n=>{let r=(t[e]??t[e.split(`.`)[0]])?.options;if(Array.isArray(r)&&r.length){let e=r.find(e=>String(e.value)===String(n));if(e)return e.label}if(typeof n==`object`&&n){let e=n;return String(e.name??e.label??e.title??e.id??n)}return String(n)};return t=>{let i=n(t.data,e);return i==null||i===``?null:{key:typeof i==`object`&&i?String(i.id??i._id??r(i)):i,label:r(i)}}},[w?.groupByField,b]),le=(0,t.useMemo)(()=>{let e=w?.assigneeField;if(!e)return;let t=b?.fields??{},n=(e,t)=>{if(!t)return;let n=e;for(let e of t.split(`.`)){if(n==null)return;n=n[e]}return n},r=n=>{let r=(t[e]??t[e.split(`.`)[0]])?.options;if(Array.isArray(r)&&r.length){let e=r.find(e=>String(e.value)===String(n));if(e)return e.label}if(typeof n==`object`&&n){let e=n;return String(e.name??e.label??e.title??e.id??n)}return String(n)};return t=>{let i=n(t.data,e);return i==null||i===``?null:{key:typeof i==`object`&&i?String(i.id??i._id??r(i)):i,label:r(i)}}},[w?.assigneeField,b]),de=(0,t.useMemo)(()=>{let e=w?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[w?.effortField]),k=(0,t.useMemo)(()=>{let t=e.skipWeekends,n=e.holidays;if(!(!t&&(!n||n.length===0)))return{skipWeekends:!!t,holidays:n&&n.length?new Set(n):void 0}},[e]),fe=(0,t.useMemo)(()=>ue(w?.timeSegments),[w?.timeSegments]),A=(0,t.useCallback)((e,t)=>{if(!e||!t)return null;let n=e;for(let e of t.split(`.`)){if(n==null)return null;n=n[e]}if(n==null||n===``)return null;if(typeof n==`object`){let e=n;return String(e.id??e._id??e.value??e.name??``)}return String(n)},[]),me=w?.quickFilters,[he,ge]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!me?.length||!a||typeof a.find!=`function`)return;let e=b?.fields??{},t=!1;return(async()=>{let r={};for(let t of me){if(t.options)continue;let i=e[t.field]??e[t.field.split(`.`)[0]],o=i?.type;if(o!==`lookup`&&o!==`master_detail`)continue;let s=i?.reference_to??i?.referenceTo;if(s)try{let e=(0,n.extractRecords)(await a.find(s,{$top:1e3}));r[t.field]=e.map(e=>({value:String(e.id??e._id??e.value??``),label:String(e.name??e.label??e.title??e.id??e._id??``)}))}catch(e){console.warn(`[ObjectGantt] Failed to load quick-filter options for "${t.field}":`,e)}}t||ge(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(me),a,b]);let _e=(0,t.useMemo)(()=>{if(!me?.length)return[];let e=b?.fields??{};return me.map(t=>{let n=e[t.field]??e[t.field.split(`.`)[0]],r=t.label??n?.label??(0,l.humanizeLabel)(t.field),i=[];if(t.options?.length)i=t.options.map(e=>typeof e==`object`?{value:String(e.value),label:String(e.label??e.value)}:{value:String(e),label:String(e)});else if(Array.isArray(n?.options)&&n.options.length)i=n.options.map(e=>({value:String(e.value??e),label:String(e.label??e.value??e)}));else if(he[t.field]?.length)i=he[t.field];else{let e=new Map;for(let n of h){let r=A(n,t.field);if(r!=null&&!e.has(r)){let i=n;for(let e of t.field.split(`.`))i=i?.[e];let a=i&&typeof i==`object`?String(i.name??i.label??i.title??r):r;e.set(r,a)}}i=[...e.entries()].map(([e,t])=>({value:e,label:t}))}return{field:t.field,label:r,options:i}})},[me,b,he,h,A]),ve=e.persistLayout===!1?void 0:`${e.objectName||(C?.provider===`object`?C.object:``)||`gantt`}:${e.viewName||`default`}`,ye=ve?`gantt-layout:${ve}:filters`:null,[j,be]=(0,t.useState)(()=>{if(!ye||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(ye)||`null`);if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>typeof e==`string`));return t}catch{return{}}}),xe=(0,t.useCallback)(()=>{if(!(!ye||typeof window>`u`))try{window.localStorage.setItem(ye,JSON.stringify(j))}catch{}},[ye,j]),Se=(0,t.useCallback)((e,t)=>{be(n=>({...n,[e]:t}))},[]),Ce=(0,t.useCallback)(()=>be({}),[]),we=(0,t.useCallback)(e=>!!w?.objectField&&!String(e?.[w.objectField]??``).trim(),[w?.objectField]),Te=(0,t.useCallback)(e=>{let t=(w?.objectField?String(e[w.objectField]??``).trim():``)||E,n=e.id??e._id;if(!t||n==null)return null;let r=E?(0,s.deriveRecordPageHref)(E,n):null;return{objectName:t,recordId:n,href:!E||t===E?r:r?.replace(`/${E}/record/`,`/${t}/record/`)??null}},[w?.objectField,E]),Ee=(0,t.useMemo)(()=>{let e=Object.entries(j).filter(([,e])=>e.length>0);if(!e.length)return O;let t=new Map(O.map(e=>[String(e.id),e])),n=new Set;for(let r of O){if(!e.every(([e,t])=>{let n=A(r.data,e);return n!=null&&t.includes(n)}))continue;let i=r;for(;i&&!n.has(String(i.id));)n.add(String(i.id)),i=i.parent==null?void 0:t.get(String(i.parent))}return O.filter(e=>n.has(String(e.id)))},[O,j,A]),De=(0,t.useMemo)(()=>{if(w?.autoZoomToFilter!==!1||!O.length)return null;let e=O[0].start.getTime(),t=O[0].end.getTime();for(let n of O)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[O,w?.autoZoomToFilter]),Oe=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},ke=Oe.mode===`drawer`||Oe.mode===`modal`||Oe.mode===`split`||Oe.mode===`popover`,M=(0,r.useNavigationOverlay)({navigation:Oe,objectName:e.objectName,onRowClick:ke?void 0:p}),[Ae,Me]=(0,t.useState)(null),Ne=M.isOverlay&&M.isOpen?M.selectedRecord:null;(0,t.useEffect)(()=>{if(!Ne){Me(null);return}let e=Te(Ne);if(!e){Me(null);return}let{objectName:t,recordId:n}=e;if(!(C?.provider===`api`||t!==E)||!a||typeof a.findOne!=`function`){Me(null);return}let r=`${t}:${n}`,i=!1;return(async()=>{try{let[e,o]=await Promise.all([a.findOne(t,String(n)),typeof a.getObjectSchema==`function`?a.getObjectSchema(t).catch(()=>null):Promise.resolve(null)]);i||Me(e?{key:r,record:e,schema:o}:null)}catch(e){console.error(`[ObjectGantt] Failed to fetch drawer record, falling back to row payload:`,e),i||Me(null)}})(),()=>{i=!0}},[Ne,Te,C?.provider,E,a]);let Pe=(0,t.useCallback)(async(e,t)=>{if(!w||!T||typeof T.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=w,o={};if(t.start instanceof Date&&(o[n]=t.start.toISOString()),t.end instanceof Date&&(o[r]=t.end.toISOString()),typeof t.title==`string`&&i&&(o[i]=t.title),typeof t.progress==`number`&&a&&(o[a]=t.progress),Object.keys(o).length===0)return;let s=e.data?.id??e.data?._id??e.id;if(s==null)return;let c=h;g(e=>e.map(e=>String(e.id??e._id)===String(s)?{...e,...o}:e));try{await T.update(E,String(s),o),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),g(c),S(e)}},[w,T,E,h,D,S]),Fe=(e,t)=>{let n=t.some(e=>typeof e==`object`&&e.type&&e.type!==`fs`);return!n&&typeof e==`string`?t.map(e=>String(typeof e==`object`?e.id:e)).join(`,`):n?t.map(e=>typeof e==`object`?e.type&&e.type!==`fs`?{id:e.id,type:e.type}:e.id:e):t.map(e=>typeof e==`object`?e.id:e)},N=(0,t.useCallback)(async(e,t,n)=>{let r=w?.dependenciesField;if(!r||!T||typeof T.update!=`function`)return;let i=Fe(t,n),a=h;g(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await T.update(E,String(e),{[r]:i}),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),g(a),S(e)}},[w,T,E,h,D,S]),P=(0,t.useCallback)(async(e,t,n=`fs`)=>{let r=e.data?.id??e.data?._id??e.id,i=t.data?.id??t.data?._id??t.id;if(r==null||i==null)return;let a=w?.dependenciesField;if(!a)return;let o=h.find(e=>String(e.id??e._id)===String(i))?.[a],s=Ue(o),c=e=>String(typeof e==`object`?e.id:e),l=s.find(e=>c(e)===String(r)),u=l&&typeof l==`object`?l.type??`fs`:`fs`;if(l&&u===n)return;let d=n===`fs`?r:{id:r,type:n},f=l?s.map(e=>c(e)===String(r)?d:e):[...s,d];await N(i,o,f)},[w,h,N]),Ie=(0,t.useCallback)(async(e,t)=>{let n=e.data?.id??e.data?._id??e.id,r=t.data?.id??t.data?._id??t.id;if(n==null||r==null)return;let i=w?.dependenciesField;if(!i)return;let a=h.find(e=>String(e.id??e._id)===String(r))?.[i],o=Ue(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await N(r,a,c)},[w,h,N]),[I,L]=(0,t.useState)(null),[Le,Re]=(0,t.useState)(!1),ze=(0,t.useCallback)(e=>{L(e)},[]),R=(0,t.useCallback)(async()=>{if(!I)return;if(!T?.delete){L(null);return}let e=I.data?.id??I.data?._id??I.id;if(e==null){L(null);return}Re(!0);let t=h;g(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await T.delete(E,String(e))===!1)throw Error(x(`gantt.writeFailed`));L(null),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),g(t),L(null),S(e)}finally{Re(!1)}},[I,T,E,h,D,S,x]);return _?(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):ee?(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ee.message]})})}):w?(0,f.jsxs)(`div`,{className:u,children:[_e.length>0&&(0,f.jsx)(Be,{filters:_e,value:j,onChange:Se,onClear:Ce,resultCount:Ee.length,totalCount:O.length,labels:{all:`全部`,clear:`清除筛选`,empty:`无可选项`,resultSummary:(e,t)=>`显示 ${e} / ${t} 项任务`}}),(0,f.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:w?.resourceView&&le?(0,f.jsx)(F,{tasks:Ee,assignee:le,effort:de,capacity:w?.capacity??1,viewMode:e.viewMode||`day`}):(0,f.jsx)(je,{tasks:Ee,startDate:De?.start,endDate:De?.end,onTaskClick:e=>{we(e.data)||M.handleClick(e.data),d?.(e.data)},taskUrl:e=>{let t=e.data;if(!t||we(t))return null;let n=Te(t)?.href;return n?typeof window>`u`?n:new URL(n,window.location.href).toString():null},onTaskUpdate:Pe,onTaskDelete:ze,onDependencyCreate:w?.dependenciesField?P:void 0,onDependencyDelete:w?.dependenciesField?Ie:void 0,markers:e.markers,autoSchedule:!!w?.dependenciesField,rescheduleOnConflict:!!w?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:k,shiftSegments:fe,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:ve,onLayoutChange:ye?xe:void 0,groupBy:ce,defaultCollapsedDepth:w?.defaultCollapsedDepth,summaryExtent:w?.summaryExtent,inlineEdit:!0,onRefresh:(C?.provider===`object`||C?.provider===`api`)&&typeof T?.find==`function`?()=>D({silent:!0}):void 0,refreshing:ae})}),M.isOverlay&&M.isOpen&&M.selectedRecord&&(()=>{let t=M.selectedRecord,n=Te(t);if(!n||we(t))return null;let{objectName:r,recordId:i}=n,o=n.href??void 0,c=w?.titleField?String(t[w.titleField]??x(`gantt.drawer.fallbackTitle`)):x(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(w?.lockField?!!t[w.lockField]:!1),u=Ae?.key===`${r}:${i}`?Ae:null,d=u?.record??t,p=u?.schema??(r===E?b:void 0),m=u&&a?a:T;return(0,f.jsx)(s.RecordDetailDrawer,{open:!0,onClose:M.close,title:c,record:d,objectName:r,recordId:i,dataSource:m??void 0,objectSchema:p,width:M.width,fullPageHref:o,onFieldSave:l?void 0:async(e,t)=>{if(m?.update){try{await m.update(r,String(i),{[e]:t})}catch(e){let t=Ke(e);throw t?Error(t):e}u&&Me(n=>n&&n.key===u.key?{...n,record:{...n.record,[e]:t}}:n),g(n=>n.map(n=>String(n.id??n._id)===String(i)?{...n,[e]:t}:n)),D({silent:!0})}},onDelete:l?void 0:async()=>{if(T?.delete){try{if(await T.delete(r,String(i))===!1)throw Error(x(`gantt.writeFailed`))}catch(e){throw S(e),e}g(e=>e.filter(e=>String(e.id??e._id)!==String(i)))}}})})(),(0,f.jsx)(c.AlertDialog,{open:!!I,onOpenChange:e=>{!e&&!Le&&L(null)},children:(0,f.jsxs)(c.AlertDialogContent,{children:[(0,f.jsxs)(c.AlertDialogHeader,{children:[(0,f.jsx)(c.AlertDialogTitle,{children:x(`gantt.delete.title`)}),(0,f.jsx)(c.AlertDialogDescription,{children:I?x(`gantt.delete.body`,{title:I.title}):null})]}),(0,f.jsxs)(c.AlertDialogFooter,{children:[(0,f.jsx)(c.AlertDialogCancel,{disabled:Le,children:x(`gantt.delete.cancel`)}),(0,f.jsx)(c.AlertDialogAction,{onClick:e=>{e.preventDefault(),R()},disabled:Le,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:x(Le?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]}):(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},Je=({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{};return(0,f.jsx)(qe,{schema:e,dataSource:t})};n.ComponentRegistry.register(`object-gantt`,Je,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),n.ComponentRegistry.register(`gantt`,Je,{namespace:`view`,label:`Gantt View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),e.GanttView=je,e.ObjectGantt=qe,e.ObjectGanttRenderer=Je,e.QuickFilterBar=Be,e.ResourceWorkload=F,e.bandAt=k,e.computeWorkload=Ne,e.normalizeDependencies=Ue,e.normalizeShiftSegments=ue,e.normalizeTaskType=Ve,e.parseHHMM=le,e.shiftDayStart=de});
|
|
95
|
+
`}),(0,f.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":k(`gantt.toolbar.prevPeriod`),children:(0,f.jsx)(u.ChevronLeft,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":k(`gantt.toolbar.nextPeriod`),children:(0,f.jsx)(u.ChevronRight,{className:`h-4 w-4`})}),(0,f.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:K.start.toLocaleDateString(A,{month:`long`,year:`numeric`})}),N&&(0,f.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,"data-testid":`gantt-readonly-badge`,title:k(`gantt.readOnlyHint`),children:[(0,f.jsx)(u.Lock,{className:`h-3 w-3`}),k(`gantt.readOnly`)]})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":k(`gantt.toolbar.viewMode`),children:j.map(e=>(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:(0,c.cn)(`h-6 px-1.5 sm:px-2 text-xs`,z===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>Cn(e),"aria-pressed":z===e,"data-testid":`gantt-view-mode-${e}`,children:k(`gantt.viewMode.${e}`)},e))}),(0,f.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(nt>15)We(Math.max(15,nt-10));else{let e=j.indexOf(z);e<j.length-1&&(Cn(j[e+1]),We(Be))}},"aria-label":k(`gantt.toolbar.zoomOut`),children:(0,f.jsx)(u.ZoomOut,{className:`h-3 w-3`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(nt<120)We(Math.min(120,nt+10));else{let e=j.indexOf(z);e>0&&(Cn(j[e-1]),We(Be))}},"aria-label":k(`gantt.toolbar.zoomIn`),children:(0,f.jsx)(u.ZoomIn,{className:`h-3 w-3`})})]}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Qe(e=>!e),"aria-label":k(Ze?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":Ze,"data-testid":`gantt-toggle-task-list`,children:Ze?(0,f.jsx)(u.PanelLeft,{className:`h-4 w-4`}):(0,f.jsx)(u.PanelLeftClose,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Zn,disabled:Q==null,"aria-label":k(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:k(`gantt.toolbar.today`)}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:tr,"aria-label":k(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:k(`gantt.toolbar.thisWeek`)}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:nr,"aria-label":k(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:k(`gantt.toolbar.thisMonth`)}),le?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void le(),disabled:ue,"aria-label":k(`gantt.toolbar.refresh`),"aria-busy":ue,"data-testid":`gantt-refresh`,children:(0,f.jsx)(u.RefreshCw,{className:`h-4 w-4`})}):null,P?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:kt,disabled:!jt,"aria-label":k(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,f.jsx)(u.Undo2,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:At,disabled:!Mt,"aria-label":k(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,f.jsx)(u.Redo2,{className:`h-4 w-4`})})]}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Tr(e=>!e),"aria-label":k(`gantt.toolbar.criticalPath`),"aria-pressed":wr,"data-testid":`gantt-critical-path`,style:wr?{color:$}:void 0,children:(0,f.jsx)(u.Activity,{className:`h-4 w-4`})}),Re&&P?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Or,"aria-label":k(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,f.jsx)(u.Wand2,{className:`h-4 w-4`})}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Ar,"aria-label":k(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,f.jsx)(u.Download,{className:`h-4 w-4`})}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:jr,"aria-label":k(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,f.jsx)(u.FileDown,{className:`h-4 w-4`})}),ce||O?(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Pr,"aria-label":k(`gantt.toolbar.saveLayout`),"aria-pressed":Mr,"data-testid":`gantt-save-layout`,style:Mr?{color:$}:void 0,children:(0,f.jsx)(u.Save,{className:`h-4 w-4`})}):null,(0,f.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Kn,"aria-label":k(Wn?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":Wn,"data-testid":`gantt-fullscreen`,children:Wn?(0,f.jsx)(u.Minimize2,{className:`h-4 w-4`}):(0,f.jsx)(u.Maximize2,{className:`h-4 w-4`})})]})]}),(0,f.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:hn,"data-testid":`gantt-body`,children:[!Ze&&B>0&&(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:B-3,width:7,cursor:`col-resize`},"data-testid":`gantt-list-resize`,role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=B,r=Math.max(160,Pe-200),i=e=>{let i=Math.max(160,Math.min(n+(e.clientX-t),r));Ke(i)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a),document.body.style.cursor=``};document.body.style.cursor=`col-resize`,window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},onDoubleClick:()=>Ke(null),children:(0,f.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover/splitter:w-[3px] group-hover/splitter:bg-primary transition-all`})}),(0,f.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,f.jsxs)(`div`,{className:`flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm`,style:{width:B,minWidth:B},children:[(0,f.jsx)(`div`,{className:`flex-1 truncate`,children:k(`gantt.column.taskName`)}),it&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:k(`gantt.column.start`)}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:k(`gantt.column.end`)})]})]}),(0,f.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:On,children:(0,f.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:yn},children:[(0,f.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:En.slice(Hn.start,Hn.end).map(e=>(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 flex items-center justify-center border-r text-[10px] font-medium text-muted-foreground overflow-hidden`,style:{left:e.offset,width:e.width},children:(0,f.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,f.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.start+t;return(0,f.jsxs)(`div`,{className:(0,c.cn)(`absolute top-0 bottom-0 flex items-center justify-center gap-1 border-r text-xs text-muted-foreground overflow-hidden`,e.isWeekend&&`bg-muted/50`),style:{left:J[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,f.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&nt>=32&&(0,f.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,f.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,f.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:kn,onScroll:ir,style:{width:B,minWidth:B},role:`tree`,"aria-label":k(`gantt.aria.taskList`),children:[Z.startIdx>0&&(0,f.jsx)(`div`,{style:{height:Z.startIdx*R},"aria-hidden":`true`}),G.slice(Z.startIdx,Z.endIdx).map(e=>{let t=e.task,n=Le&&at===t.id,r=dn.has(String(t.id)),i=on!=null&&String(on)===String(t.id);return(0,f.jsxs)(`div`,{className:(0,c.cn)(`group/task-row relative flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors`,i&&`bg-accent/50`),style:{height:R,touchAction:`manipulation`},role:`treeitem`,"data-testid":`gantt-task-row-${t.id}`,"aria-level":e.depth+1,"aria-selected":i,"aria-expanded":e.hasChildren?!r:void 0,draggable:!!L&&!n&&!t.locked,onDragStart:L?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:L?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:L?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=ft.get(n);r&&String(r.parent??``)===String(t.parent??``)&&L(r,t)}:void 0,onContextMenu:e=>ln(t,e),onClick:()=>{sn(t.id),n||er(e.start,e.end,t.id)},onDoubleClick:()=>{n||(Le&&P&&!e.isSummary&&!t.locked?(ot(t.id),ct({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})):o?.(t))},children:[(0,f.jsxs)(`div`,{className:`flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2`,style:e.depth>0?{paddingLeft:e.depth*14}:void 0,children:[e.hasChildren?(0,f.jsx)(`button`,{type:`button`,className:`h-4 w-4 shrink-0 flex items-center justify-center text-muted-foreground hover:text-foreground`,style:{marginLeft:-4},onClick:e=>{e.stopPropagation(),pn(t.id)},"aria-expanded":!r,"aria-label":k(r?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:r?(0,f.jsx)(u.ChevronRight,{className:`h-3.5 w-3.5`}):(0,f.jsx)(u.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,f.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,f.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),n?(0,f.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.title||``,onChange:e=>ct(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Ct([{task:t,changes:{title:st.title,start:new Date(st.start),end:new Date(st.end),progress:Number(st.progress)||0}}]),ot(null)):e.key===`Escape`&&ot(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,f.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,f.jsx)(`span`,{className:(0,c.cn)(`truncate`,e.isSummary&&`font-semibold`),children:t.title}),(0,f.jsxs)(`span`,{className:`text-[10px] text-muted-foreground gantt-sm-hidden`,children:[e.start.toLocaleDateString(A,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})]})]})]}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!it,style:it?void 0:{display:`none`},children:n?(0,f.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.start||``,onChange:e=>ct(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}),(0,f.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!it,style:it?void 0:{display:`none`},children:n?(0,f.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:st.end||``,onChange:e=>ct(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}),o&&(0,f.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!n&&(0,f.jsx)(`button`,{type:`button`,title:k(`gantt.row.open`),"aria-label":k(`gantt.row.open`),"data-testid":`gantt-row-open-${t.id}`,className:`gantt-row-open-btn h-6 w-6 rounded-md flex items-center justify-center hover:bg-accent text-muted-foreground hover:text-foreground`,onClick:e=>{e.stopPropagation(),o(t)},children:(0,f.jsx)(u.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),Z.endIdx<G.length&&(0,f.jsx)(`div`,{style:{height:(G.length-Z.endIdx)*R},"aria-hidden":`true`})]}),(0,f.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{An.current=e,X.current=e},onScroll:rr,onTouchStart:Jn,onTouchMove:Yn,onTouchEnd:Xn,"data-testid":`gantt-timeline`,children:(0,f.jsxs)(`div`,{className:`relative`,style:{width:yn},children:[Q!=null&&(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:Q,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":k(`gantt.toolbar.today`),children:(0,f.jsx)(`div`,{className:`absolute -translate-x-1/2 left-0 text-[10px] font-semibold text-white rounded-sm px-1 py-0.5 whitespace-nowrap z-30`,style:{top:2,backgroundColor:`#ef4444`},children:k(`gantt.toolbar.today`)})}),Dn.map(e=>(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:e.left,backgroundColor:e.color},"data-testid":`gantt-marker-${e.index}`,"aria-label":e.label,children:e.label&&(0,f.jsx)(`div`,{className:`absolute -translate-x-1/2 left-0 text-[10px] font-semibold text-white rounded-sm px-1 py-0.5 whitespace-nowrap z-30`,style:{top:2,backgroundColor:e.color},children:e.label})},e.index)),(0,f.jsxs)(`div`,{className:`relative`,ref:zt,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.start+t;return(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:J[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 8%, transparent)`:e.isWeekend?`hsl(var(--muted) / 0.4)`:void 0}},n)})}),gn&&S&&S.showMidnight&&(0,f.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:q.slice(Bn.start,Bn.end).map((e,t)=>{let n=Bn.start+t,r=e.realMs??0;if(!r)return null;let i=e.date.getTime(),a=e.date,o=new Date(a.getFullYear(),a.getMonth(),a.getDate()+1,0,0,0,0).getTime();return o<=i||o>=i+r?null:(0,f.jsx)(`div`,{className:`absolute top-0 bottom-0`,style:{left:J[n]+(o-i)/r*e.width,borderLeft:`1px dashed hsl(var(--muted-foreground) / 0.4)`},"data-testid":`gantt-midnight-${n}`,"aria-hidden":`true`},`midnight-${n}`)})}),Z.startIdx>0&&(0,f.jsx)(`div`,{style:{height:Z.startIdx*R},"aria-hidden":`true`}),G.slice(Z.startIdx,Z.endIdx).map(e=>{let n=e.task,r=Dr(n.id),i=ar(e.start,e.end),a=re&&n.baselineStart&&n.baselineEnd?ar(n.baselineStart,n.baselineEnd):null,o=a?(0,f.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:a.left,width:Math.max(2,a.width),top:yr,height:vr,backgroundColor:br,border:`1px solid ${xr}`},"data-testid":`gantt-baseline-${n.id}`,"aria-hidden":`true`}):null,s=H?.taskId===n.id,l=sr?.has(String(n.id))??!1,u=cr?.has(String(n.id))??!1,d=s||l||u?lr(e):i,p=!!n.locked,m=!!P&&!e.isSummary&&!p,h=N||p,g=U!=null&&U.targetId!=null&&String(U.targetId)===String(n.id)&&String(U.sourceId)!==String(n.id),_=U?e=>{let t=e.currentTarget.getBoundingClientRect(),r=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;Bt(e=>e&&Rt(e.sourceId,n)?{...e,targetId:n.id,targetEnd:r}:e)}:void 0,v=U?e=>{e.target===e.currentTarget&&Bt(e=>e&&{...e,targetId:null,targetEnd:null})}:void 0,ee=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/xe)),y=lt===n.id&&!H&&!Pt&&!U?(0,f.jsxs)(`div`,{className:`absolute z-30 pointer-events-none rounded-md border bg-popover text-popover-foreground px-2.5 py-1.5 text-xs shadow-md whitespace-nowrap`,style:{left:Math.max(d.left+8,4),top:R-8},role:`tooltip`,"data-testid":`gantt-tooltip-${n.id}`,children:[(0,f.jsx)(`div`,{className:`font-semibold`,children:n.title}),n.fields&&n.fields.length>0?(0,f.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:n.fields.map((e,n)=>(0,f.jsxs)(t.Fragment,{children:[(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,f.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,f.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(A,{month:`short`,day:`numeric`}),` → `,e.end.toLocaleDateString(A,{month:`short`,day:`numeric`}),` · `,ee,k(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),n.locked||N&&!P?(0,f.jsxs)(`div`,{className:`text-muted-foreground`,style:{marginTop:4},"data-testid":`gantt-tooltip-locked-${n.id}`,children:[`🚫 `,k(`gantt.lockedHint`)]}):null]}):null;if(n.type===`group`)return(0,f.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:y},n.id);if(e.isSummary){let t=n.color||`#0d9488`;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:[o,(0,f.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none`,P&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left,width:d.width,top:_r,height:gr,cursor:P?void 0:h?`not-allowed`:`pointer`,backgroundColor:t,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-summary-bar-${n.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),onPointerDown:t=>{t.button===0&&Nt(n,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})},onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),children:[(0,f.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${Math.round(e.progress)}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),(0,f.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:n.title})]}),s&&H&&(0,f.jsxs)(`div`,{className:`absolute z-30 pointer-events-none rounded border bg-popover text-popover-foreground px-1.5 py-0.5 text-[10px] shadow whitespace-nowrap`,style:{left:Math.max(d.left,4),top:_r+gr+2},"data-testid":`gantt-summary-drag-chip-${n.id}`,children:[_t(H).start.toLocaleDateString(A,{month:`numeric`,day:`numeric`}),` → `,_t(H).end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})]}),y]},n.id)}if(e.isMilestone){let e=mr;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,children:[o,(0,f.jsx)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,m&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left-e/2,top:(R-e)/2,width:e,height:e,cursor:m?void 0:h?`not-allowed`:`pointer`,backgroundColor:r?$:n.color||`#3b82f6`,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-milestone-${n.id}`,onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),onPointerMove:_,onPointerDown:m?e=>{e.button===0&&Nt(n,`move`,e)}:void 0}),y]},n.id)}let b=Pt&&Pt.taskId===n.id?Pt.value:n.progress;return(0,f.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:R},onPointerMove:v,onMouseEnter:()=>ut(n.id),onMouseLeave:()=>ut(e=>e===n.id?null:e),children:[s&&(0,f.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:i.left,width:i.width,top:dr,height:fr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),o,(0,f.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm bg-primary border shadow-sm flex items-center px-2 group select-none`,m&&`cursor-grab active:cursor-grabbing`,s&&`ring-2 ring-primary z-10`,g&&`ring-2 ring-primary`,jn===n.id&&`gantt-flash z-10`),style:{left:d.left,width:d.width,top:dr,height:fr,cursor:m?void 0:h?`not-allowed`:`pointer`,backgroundColor:n.color||`#3b82f6`,borderColor:r?$:n.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:r?`0 0 0 2px ${$}`:n.borderColor?`0 0 0 2px ${n.borderColor}`:void 0},"data-critical":r?`true`:void 0,"data-testid":`gantt-task-bar-${n.id}`,onClick:()=>{gt.current||sn(n.id)},onContextMenu:e=>ln(n,e),onPointerMove:_,onPointerDown:m?e=>{if(e.button!==0)return;let t=he(e.clientX,e.currentTarget.getBoundingClientRect());Nt(n,t,e)}:void 0,children:[m&&d.width>=14&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:me,height:pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${n.id}`,onPointerDown:e=>{e.button===0&&Nt(n,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,f.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:me,height:pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${n.id}`,onPointerDown:e=>{e.button===0&&Nt(n,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),b>0&&(0,f.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${b}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),m&&d.width>=30&&(0,f.jsx)(`div`,{className:(0,c.cn)(`absolute bottom-0 h-1/2 w-4 -translate-x-1/2 cursor-col-resize flex items-end justify-center pb-px`,Pt?.taskId===n.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${b}%`},"data-testid":`gantt-progress-handle-${n.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),Ft({taskId:n.id,originClientX:e.clientX,originProgress:n.progress,barWidth:d.width,value:n.progress}))},onClick:e=>e.stopPropagation(),children:(0,f.jsx)(`div`,{style:{width:0,height:0,borderLeft:`5px solid transparent`,borderRight:`5px solid transparent`,borderBottom:`7px solid #fff`,filter:`drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35))`}})}),F&&!p&&[`start`,`end`].map(e=>{let t=U!=null&&String(U.sourceId)===String(n.id)&&U.sourceEnd===e,r=t||lt===n.id,i=r&&U==null;return(0,f.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 z-20 flex items-center transition-opacity`,style:{[e===`start`?`left`:`right`]:-28,height:24,width:30,cursor:`crosshair`,opacity:+!!r,pointerEvents:i?`auto`:`none`,justifyContent:e===`start`?`flex-start`:`flex-end`,paddingLeft:e===`start`?4:0,paddingRight:e===`end`?4:0},"data-testid":`gantt-link-dot-${e}-${n.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let r=zt.current?.getBoundingClientRect();Bt({sourceId:n.id,sourceEnd:e,x:r?t.clientX-r.left:0,y:r?t.clientY-r.top:0,targetId:null,targetEnd:null})},onClick:e=>e.stopPropagation(),children:(0,f.jsx)(`div`,{className:`rounded-full`,style:{height:12,width:12,backgroundColor:`hsl(var(--background))`,border:`2px solid hsl(var(--primary))`,boxShadow:t?`0 0 0 3px hsl(var(--primary) / 0.25)`:`0 1px 2px rgba(0,0,0,0.25)`}})},e)}),(0,f.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:n.title}),(0,f.jsx)(`span`,{className:`absolute inset-0 flex items-center px-2 text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`,children:s?`${_t(H).start.toLocaleDateString(A,{month:`numeric`,day:`numeric`})} → ${_t(H).end.toLocaleDateString(A,{month:`numeric`,day:`numeric`})}`:`${Math.round(b)}%`})]}),y]},n.id)}),Z.endIdx<G.length&&(0,f.jsx)(`div`,{style:{height:(G.length-Z.endIdx)*R},"aria-hidden":`true`}),(ur.length>0||U)&&(0,f.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:yn,height:Un,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,f.jsxs)(`defs`,{children:[(0,f.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,f.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,f.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,f.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:$})})]}),ur.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<Z.startIdx-6||n>Z.endIdx+6)return null;let r=Sr(e);if(!r)return null;let i=Cr!=null&&(String(e.sourceId)===String(Cr)||String(e.targetId)===String(Cr)),a=Er?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(I||F);return(0,f.jsxs)(t.Fragment,{children:[(0,f.jsx)(`path`,{d:r,fill:`none`,stroke:a?$:i?`hsl(var(--primary))`:`hsl(var(--muted-foreground))`,strokeOpacity:a||i?1:.7,strokeWidth:a||i?2:1.5,markerEnd:`url(#${o})`,"data-testid":`gantt-link-${e.sourceId}-${e.targetId}`,"data-link-type":e.type,"data-active":i?`true`:`false`,"data-critical":a?`true`:void 0}),s&&(0,f.jsx)(`path`,{d:r,fill:`none`,stroke:`transparent`,strokeWidth:10,style:{pointerEvents:`stroke`,cursor:`context-menu`},"data-testid":`gantt-link-hit-${e.sourceId}-${e.targetId}`,onContextMenu:t=>un(e.sourceId,e.targetId,e.type,t)})]},e.key)}),U&&(()=>{let e=G.findIndex(e=>String(e.task.id)===String(U.sourceId));if(e<0)return null;let t=lr(G[e]),n=G[e].isMilestone?t.left+(U.sourceEnd===`start`?-hr:hr):U.sourceEnd===`start`?t.left:t.left+t.width,r=e*R+R/2;return(0,f.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(U.x)} ${Math.round(U.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),U&&(()=>{let t=e.find(e=>String(e.id)===String(U.sourceId));if(!t)return null;let n=U.targetId==null?null:e.find(e=>String(e.id)===String(U.targetId)),r=e=>k(`gantt.linkEnd.${e}`),i=n?`${t.title} (${r(U.sourceEnd)}) → ${n.title} (${r(U.targetEnd??`start`)})`:`${t.title} (${r(U.sourceEnd)})`;return(0,f.jsx)(`div`,{className:`absolute z-30 pointer-events-none rounded-md border bg-popover text-popover-foreground px-2 py-1 text-[11px] font-medium shadow-md whitespace-nowrap`,style:{left:U.x+12,top:U.y+12},"data-testid":`gantt-link-draft-hint`,children:i})})()]})]})})]})]}),Ht&&(()=>{let t=e.find(e=>String(e.id)===String(Ht.taskId));if(!t)return null;let n=G.find(e=>String(e.task.id)===String(Ht.taskId)),r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,f.jsxs)(`div`,{ref:Wt,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:Ht.x,top:Ht.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[o&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-view`,onClick:()=>{Ut(null),o(t)},children:k(`gantt.menu.view`)}),s&&(()=>{let e=s(t);return e?(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-qrcode`,onClick:()=>{Ut(null),Kt({task:t,url:e})},children:k(`gantt.menu.qrcode`)}):null})(),Le&&P&&n&&!n.isSummary&&!t.locked&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-edit`,onClick:()=>{Ut(null),ot(t.id),ct({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})},children:k(`gantt.menu.edit`)}),F&&n&&!n.isMilestone&&!t.locked&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let e=Ht;Ut(null),rn(``),tn({x:e.x,y:e.y,taskId:t.id,relation:`pred`})},children:k(`gantt.menu.addPredecessor`)}),(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let e=Ht;Ut(null),rn(``),tn({x:e.x,y:e.y,taskId:t.id,relation:`succ`})},children:k(`gantt.menu.addSuccessor`)})]}),Ie&&!t.locked&&(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,c.cn)(r,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{Ut(null),Ie(t)},children:k(`gantt.menu.delete`)})]})})(),Gt&&(0,f.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,"data-testid":`gantt-qr-dialog`,onClick:()=>Kt(null),children:(0,f.jsxs)(`div`,{role:`dialog`,"aria-label":k(`gantt.qr.title`),className:`w-[280px] rounded-lg border bg-popover text-popover-foreground p-4 shadow-lg`,onClick:e=>e.stopPropagation(),children:[(0,f.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-sm font-medium`,children:[(0,f.jsx)(u.QrCode,{className:`h-4 w-4 shrink-0`}),(0,f.jsx)(`span`,{className:`truncate`,children:Gt.task.title})]}),(0,f.jsx)(`div`,{className:`mb-2 text-xs text-muted-foreground`,children:k(`gantt.qr.hint`)}),qt?(0,f.jsx)(`img`,{src:qt,alt:k(`gantt.qr.title`),"data-testid":`gantt-qr-image`,className:`mx-auto block h-[220px] w-[220px] rounded bg-white`}):(0,f.jsx)(`div`,{className:`flex h-[220px] items-center justify-center text-sm text-muted-foreground`,children:`…`}),(0,f.jsx)(`div`,{className:`mt-2 break-all text-[11px] text-muted-foreground`,"data-testid":`gantt-qr-url`,children:Gt.url}),(0,f.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,f.jsxs)(c.Button,{variant:`outline`,size:`sm`,"data-testid":`gantt-qr-copy`,onClick:Zt,children:[Yt?(0,f.jsx)(u.Check,{className:`mr-1 h-3 w-3`}):(0,f.jsx)(u.Copy,{className:`mr-1 h-3 w-3`}),k(Yt?`gantt.qr.copied`:`gantt.qr.copy`)]}),(0,f.jsx)(c.Button,{variant:`ghost`,size:`sm`,"data-testid":`gantt-qr-close`,onClick:()=>Kt(null),children:k(`gantt.qr.close`)})]})]})}),W&&(()=>{let t=e.find(e=>String(e.id)===String(W.sourceId)),n=e.find(e=>String(e.id)===String(W.targetId));if(!t||!n)return null;let r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`,i=[`fs`,`ss`,`ff`,`sf`],a=!!n.locked;return(0,f.jsxs)(`div`,{ref:$t,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:W.x,top:W.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,f.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[t.title,` → `,n.title]}),a&&(0,f.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,k(`gantt.lockedHint`)]}),F&&i.map(e=>(0,f.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":W.type===e,disabled:a,className:(0,c.cn)(r,W.type===e&&`font-semibold`,a&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${e}`,onClick:()=>{a||(Qt(null),e!==W.type&&F(t,n,e))},children:[W.type===e?`✓ `:`\xA0\xA0`,k(`gantt.linkType.${e}`)]},e)),I&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`my-1 border-t`}),(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:a,className:(0,c.cn)(r,`text-destructive`,a&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{a||(Qt(null),I(t,n))},children:k(`gantt.menu.removeDependency`)})]})]})})(),en&&F&&(()=>{let t=e.find(e=>String(e.id)===String(en.taskId));if(!t)return null;let n=new Set(ur.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),r=e.filter(e=>{if(String(e.id)===String(t.id)||e.type===`group`||e.locked)return!1;let r=en.relation===`pred`?`${String(e.id)}->${String(t.id)}`:`${String(t.id)}->${String(e.id)}`;return!n.has(r)}),i=nn.trim().toLowerCase(),a=i?r.filter(e=>String(e.title??``).toLowerCase().includes(i)):r;return(0,f.jsxs)(`div`,{ref:an,className:`fixed z-50 min-w-[200px] max-h-[280px] overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:en.x,top:en.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,f.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:en.relation===`pred`?k(`gantt.menu.addPredecessor`):k(`gantt.menu.addSuccessor`)}),(0,f.jsx)(`div`,{className:`px-2 pb-1`,children:(0,f.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:nn,onChange:e=>rn(e.target.value),placeholder:k(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),a.length===0?(0,f.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:k(`gantt.menu.noCandidates`)}):a.map(e=>(0,f.jsx)(`button`,{type:`button`,role:`menuitem`,className:`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none truncate`,"data-testid":`gantt-dep-picker-option-${e.id}`,onClick:()=>{tn(null),en.relation===`pred`?F(e,t,`fs`):F(t,e,`fs`)},children:e.title},String(e.id)))]})})(),wt&&(0,f.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>Tt(null),children:(0,f.jsxs)(`div`,{className:`min-w-[280px] max-w-[360px] rounded-lg border bg-popover text-popover-foreground shadow-lg p-4`,role:`alertdialog`,"aria-modal":`true`,"data-testid":`gantt-conflict-dialog`,onClick:e=>e.stopPropagation(),children:[(0,f.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:k(`gantt.conflict.title`)}),(0,f.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:k(`gantt.conflict.body`).replace(`{count}`,String(wt.length))}),(0,f.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,f.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md border hover:bg-accent outline-none`,"data-testid":`gantt-conflict-cancel`,onClick:()=>Tt(null),children:k(`gantt.conflict.cancel`)}),(0,f.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:opacity-90 outline-none`,"data-testid":`gantt-conflict-confirm`,onClick:Dt,children:k(`gantt.conflict.confirm`)})]})]})})]})}function Me(e,t,n,r){return t.getTime()===e.getTime()?e.getTime()>=n.getTime()&&e.getTime()<r.getTime():e.getTime()<r.getTime()&&t.getTime()>n.getTime()}function Ne(e,t,n){let{assignee:r,effort:i,capacity:a=1,unassignedLabel:o=`Unassigned`}=n,s=e=>typeof a==`function`?a(e):a,c=e=>{let t=i?i(e):1;return Number.isFinite(t)&&t>0?t:0},l=new Map;for(let t of e){let e=r(t),n=e?String(e.key):`__unassigned__`,i=e?e.label:o,a=l.get(n);a||(a={key:n,label:i,items:[]},l.set(n,a)),a.items.push(t)}let u=[];for(let e of l.values()){let n=s(e.key),r=0,i=0,a=t.map(t=>{let a=0;for(let n of e.items)Me(n.start,n.end,t.start,t.end)&&(a+=c(n));a>r&&(r=a);let o=a>n+1e-9;return o&&i++,{load:a,capacity:n,overloaded:o}});u.push({key:e.key,label:e.label,capacity:n,cells:a,peak:r,overloadedCount:i})}return u}var Pe={day:26,week:56,month:76,quarter:88,year:104},Fe=48,N=34,P=180;function Ie(e,t,n){return t===`day`?String(e.getDate()):t===`week`?e.toLocaleDateString(n,{month:`numeric`,day:`numeric`}):t===`month`?e.toLocaleDateString(n,{month:`short`}):t===`year`?String(e.getFullYear()):`Q${Math.floor(e.getMonth()/3)+1}`}function F({tasks:e,assignee:n,effort:r,capacity:i=1,viewMode:a=`day`,unassignedLabel:o=`Unassigned`,className:s}){let{t:c,language:l}=pe(),u=l||void 0,d=Pe[a],p=t.useMemo(()=>{if(!e.length)return[];let t=new Date(Math.min(...e.map(e=>e.start.getTime()))),n=new Date(Math.max(...e.map(e=>e.end.getTime()))),r=Se(t,a),i=we(Se(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=we(r,1,a);o.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:Ie(r,a,u)}),r=e}return o},[e,a,u]),m=t.useMemo(()=>Ne(e,p.map(e=>e.col),{assignee:n,effort:r,capacity:i,unassignedLabel:o}),[e,p,n,r,i,o]),h=t.useMemo(()=>{let e=0;for(let t of m)e=Math.max(e,t.peak,t.capacity);return e||1},[m]),g=p.length*d;return e.length?(0,f.jsx)(`div`,{className:s,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,f.jsxs)(`div`,{style:{display:`flex`,minWidth:P+g},children:[(0,f.jsxs)(`div`,{style:{width:P,flexShrink:0},children:[(0,f.jsx)(`div`,{style:{height:28,display:`flex`,alignItems:`center`,padding:`0 12px`,fontSize:12,fontWeight:600,borderBottom:`1px solid hsl(var(--border))`},children:c(`gantt.resource.header`)}),m.map(e=>(0,f.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:Fe,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,f.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,f.jsxs)(`span`,{"data-testid":`resource-peak-${e.key}`,"data-overloaded":e.overloadedCount>0?`true`:void 0,style:{fontSize:10,color:e.overloadedCount>0?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`},children:[c(`gantt.resource.peak`),`: `,Math.round(e.peak*100)/100,` / `,e.capacity,e.overloadedCount>0?` · ${e.overloadedCount} ${c(`gantt.resource.over`)}`:``]})]},e.key))]}),(0,f.jsxs)(`div`,{style:{flex:1},children:[(0,f.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:p.map((e,t)=>(0,f.jsx)(`div`,{style:{width:d,flexShrink:0,textAlign:`center`,fontSize:10,color:`hsl(var(--muted-foreground))`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:e.label},t))}),m.map(e=>{let t=N*(1-Math.min(e.capacity/h,1));return(0,f.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:Fe,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,f.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:(Fe-N)/2+t,borderTop:`1px dashed hsl(var(--muted-foreground) / 0.6)`,pointerEvents:`none`,zIndex:1}}),e.cells.map((t,n)=>{let r=Math.max(t.load>0?2:0,N*Math.min(t.load/h,1));return(0,f.jsx)(`div`,{"data-testid":`resource-cell-${e.key}-${n}`,"data-load":t.load,"data-overloaded":t.overloaded?`true`:void 0,title:`${p[n]?.date.toLocaleDateString(u)} — ${Math.round(t.load*100)/100} / ${t.capacity}`,style:{width:d,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:(Fe-N)/2},children:t.load>0&&(0,f.jsx)(`div`,{style:{width:d-6,height:r,borderRadius:2,backgroundColor:t.overloaded?`hsl(var(--destructive))`:`hsl(var(--primary))`,opacity:t.overloaded?.9:.75}})},n)})]},e.key)})]})]})}):(0,f.jsx)(`div`,{className:s,"data-testid":`resource-workload`,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:c(`gantt.resource.empty`)})})}var I={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},L={display:`inline-flex`,alignItems:`center`,gap:6,height:30,padding:`0 10px`,borderRadius:6,border:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,color:`hsl(var(--foreground))`,cursor:`pointer`,whiteSpace:`nowrap`,lineHeight:`28px`},Le={position:`absolute`,top:`calc(100% + 4px)`,left:0,zIndex:50,minWidth:200,maxHeight:320,overflowY:`auto`,padding:4,borderRadius:8,border:`1px solid hsl(var(--border))`,background:`hsl(var(--popover, var(--background)))`,color:`hsl(var(--popover-foreground, var(--foreground)))`,boxShadow:`0 8px 24px rgba(0,0,0,0.18)`},Re={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function ze({checked:e}){return(0,f.jsx)(`span`,{"aria-hidden":!0,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:15,height:15,flex:`0 0 auto`,borderRadius:3,border:`1px solid ${e?`hsl(var(--primary))`:`hsl(var(--border))`}`,background:e?`hsl(var(--primary))`:`transparent`,color:`hsl(var(--primary-foreground, var(--background)))`,fontSize:11,lineHeight:1},children:e?`✓`:``})}function R({filter:e,selected:n,onChange:r,labels:i}){let[a,o]=(0,t.useState)(!1),s=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);let c=new Set(n),l=n.length,u=e.options.length>0&&l===e.options.length,d=t=>{let n=new Set(c);n.has(t)?n.delete(t):n.add(t),n.size===e.options.length?r([]):r([...n])},p=()=>{r(l>0?[]:e.options.map(e=>e.value))},m=l===0?e.label:l===1?`${e.label}: ${e.options.find(e=>e.value===n[0])?.label??n[0]}`:`${e.label} · ${l}`;return(0,f.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,f.jsxs)(`button`,{type:`button`,style:{...L,borderColor:l>0?`hsl(var(--primary))`:`hsl(var(--border))`,color:l>0?`hsl(var(--primary))`:`hsl(var(--foreground))`},"aria-haspopup":`listbox`,"aria-expanded":a,"data-testid":`quick-filter-trigger-${e.field}`,onClick:()=>o(e=>!e),children:[(0,f.jsx)(`span`,{children:m}),(0,f.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,f.jsx)(`div`,{role:`listbox`,style:Le,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,f.jsx)(`div`,{style:{...Re,cursor:`default`,opacity:.6},children:i.empty}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...Re,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>p(),children:[(0,f.jsx)(ze,{checked:u}),(0,f.jsx)(`span`,{children:i.all})]}),(0,f.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,f.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...Re,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>d(t.value),children:[(0,f.jsx)(ze,{checked:n}),(0,f.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var Be=({filters:e,value:t,onChange:n,onClear:r,resultCount:i,totalCount:a,labels:o,className:s})=>{if(!e.length)return null;let c=o?.all??`All`,l=o?.empty??`No options`,u=o?.clear??`Clear`,d=e.some(e=>(t[e.field]?.length??0)>0);return(0,f.jsxs)(`div`,{style:I,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,f.jsx)(R,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),d&&(0,f.jsx)(`button`,{type:`button`,style:{...L,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,f.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function Ve(e){if(e==null)return;let t=String(e).toLowerCase().trim();if(t===`milestone`)return`milestone`;if(t===`group`||t===`folder`)return`group`;if(t===`summary`||t===`project`||t===`phase`)return`summary`;if(t===`task`)return`task`}var He={fs:`fs`,ss:`ss`,ff:`ff`,sf:`sf`,finish_to_start:`fs`,start_to_start:`ss`,finish_to_finish:`ff`,start_to_finish:`sf`,end_to_start:`fs`,end_to_end:`ff`,start_to_end:`sf`};function Ue(e){if(e==null||e===``)return[];if(typeof e==`string`)return e.split(`,`).map(e=>e.trim()).filter(Boolean);if(typeof e==`number`)return[e];if(!Array.isArray(e))return[];let t=[];for(let n of e)if(!(n==null||n===``))if(typeof n==`object`){let e=n.id??n._id??n.task??n.target;if(e==null||e===``)continue;let r=He[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n);return t}function We(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function Ge(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function Ke(e){let t=e instanceof Error?e.message:String(e??``),n=t.indexOf(`{`);if(n>=0)try{let e=JSON.parse(t.slice(n)),r=e?.message??e?.error;if(typeof r==`string`&&r.trim())return r}catch{}return null}function z(e){let t=null;if(e.startDateField&&e.endDateField)return t={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||`name`,progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField,borderColorField:e.borderColorField,parentField:e.parentField,typeField:e.typeField,lockField:e.lockField,objectField:e.objectField,summaryExtent:e.summaryExtent,defaultCollapsedDepth:e.defaultCollapsedDepth,tooltipFields:e.tooltipFields,baselineStartField:e.baselineStartField,baselineEndField:e.baselineEndField,groupByField:e.groupByField,resourceView:e.resourceView,assigneeField:e.assigneeField,effortField:e.effortField,capacity:e.capacity,quickFilters:e.quickFilters,autoZoomToFilter:e.autoZoomToFilter,timeSegments:e.timeSegments},t;if(e.gantt&&(t=e.gantt),t){let e=a.GanttConfigSchema.safeParse(t);return e.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,e.error.format()),t}return null}var qe=({schema:e,dataSource:a,className:u,onTaskClick:d,onRowClick:p,...m})=>{let[h,g]=(0,t.useState)([]),[_,v]=(0,t.useState)(!0),[ee,y]=(0,t.useState)(null),[b,te]=(0,t.useState)(null),{currency:ne}=(0,o.useLocalization)(),{t:x}=pe(),S=(0,t.useCallback)(e=>{i.toast.error(x(`gantt.writeFailed`),{description:Ke(e)??void 0})},[x]),re=We(e),C=(0,t.useMemo)(()=>re,[JSON.stringify(re)]),w=z(e),ie=C?.provider===`value`,T=(0,t.useMemo)(()=>(0,n.resolveDataSource)(C,a??null),[C,a]),E=C?.provider===`object`?C.object:e.objectName??``,[ae,oe]=(0,t.useState)(!1),se=(0,t.useRef)(0),D=(0,t.useCallback)(async({silent:t=!1}={})=>{let r=++se.current,i=()=>se.current===r;try{if(t?oe(!0):v(!0),m.data&&Array.isArray(m.data)){i()&&g(m.data);return}if(ie&&C?.provider===`value`){i()&&g(C.items);return}if(!T||typeof T.find!=`function`)throw Error(`DataSource required for object/api providers`);let r=(0,n.buildExpandFields)(b?.fields),a=await T.find(E,{$filter:e.filter,$orderby:Ge(e.sort),...r.length>0?{$expand:r}:{}});i()&&g((0,n.extractRecords)(a))}catch(e){t?console.error(`[ObjectGantt] Failed to refresh data:`,e):i()&&y(e)}finally{t?oe(!1):v(!1)}},[T,E,ie,C,e.filter,e.sort,b]);(0,t.useEffect)(()=>{D()},[D]),(0,t.useEffect)(()=>{!ie&&T&&(async()=>{try{if(!T||!E)return;let e=await T.getObjectSchema(E);te(e)}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[E,T,ie,C]);let O=(0,t.useMemo)(()=>{if(!w||!h.length)return[];let{startDateField:e,endDateField:t,titleField:r,progressField:i,dependenciesField:a,colorField:s,borderColorField:c,parentField:u,typeField:d,lockField:f,tooltipFields:p,baselineStartField:m,baselineEndField:g,quickFilters:_}=w,v=b?.fields??{},ee=new Map;for(let e of _??[]){if(!e?.field||!Array.isArray(e.options)||!e.options.length)continue;let t=new Map;for(let n of e.options)typeof n==`string`?t.set(n,n):n&&n.value!=null&&t.set(String(n.value),n.label??String(n.value));t.size&&ee.set(e.field,t)}let y=(e,t)=>{if(!t)return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r},te=e=>{let t=[y(e,r),e?.account?.name,e?.opportunity?.name,e?.contact&&[e.contact.first_name,e.contact.last_name].filter(Boolean).join(` `)];for(let e of t)if(e!=null&&String(e).trim()!==``)return String(e);return(0,n.getRecordDisplayName)(b,e)},x=(e,t)=>{if(t)return t;let n=v[e]??v[e.split(`.`)[0]];return n?.label?n.label:(0,l.humanizeLabel)(e)},S=(e,t)=>{if(e==null||e===``)return`—`;let n=v[t]??v[t.split(`.`)[0]],r=n?.type,i=n?.options;if(Array.isArray(i)&&i.length){let t=i.find(t=>String(t.value)===String(e));if(t)return t.label}if(typeof e!=`object`){let n=ee.get(t)?.get(String(e));if(n!=null)return n}if(r==null&&typeof e==`string`){if(/^\d{4}-\d{2}-\d{2}$/.test(e))return(0,l.formatDate)(e);if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(e)&&!isNaN(new Date(e).getTime()))return(0,l.formatDateTime)(e)}switch(r){case`date`:return(0,l.formatDate)(e);case`datetime`:return(0,l.formatDateTime)(e);case`number`:case`integer`:case`float`:case`decimal`:return(0,l.formatNumber)(Number(e));case`currency`:return(0,l.formatCurrency)(Number(e),(0,o.resolveFieldCurrency)(n,ne));case`percent`:return(0,l.formatPercent)(Number(e));case`boolean`:case`checkbox`:return e?`Yes`:`No`;default:if(Array.isArray(e)){let t=e.map(e=>{if(e==null)return``;if(typeof e==`object`){let t=e;return String(t.name??t.label??t.title??t.id??``)}return String(e)}).filter(Boolean);return t.length?t.join(`, `):`—`}if(typeof e==`object`){let t=e;return String(t.name??t.label??t.title??t.id??`—`)}return String(e)}},re=e=>{if(!p||!p.length)return;let t=[];for(let n of p){let r=typeof n==`string`?n:n?.field;if(!r)continue;let i=typeof n==`object`?n.label:void 0,a=y(e,r);a==null||a===``||Array.isArray(a)&&a.length===0||t.push({label:x(r,i),value:S(a,r)})}return t.length?t:void 0};return h.map((n,r)=>{let o=n[e],p=n[t],h=m?n[m]:void 0,_=g?n[g]:void 0,v=h?new Date(h):void 0,ee=_?new Date(_):void 0,y=te(n),b=i?n[i]:0,ne=a?n[a]:[],x=s?n[s]:void 0;if(!x){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,l.getSemanticColorName)(void 0,e);t&&(x=(0,l.getSemanticHex)(t))}}let S=c?n[c]:void 0,C=S!=null&&S!==``?(0,l.getSemanticHex)(String(S),String(S)):void 0;return{id:n.id||n._id||`task-${r}`,title:y,start:o?new Date(o):new Date,end:p?new Date(p):new Date,hasOwnDates:!!(o&&p),progress:Math.min(100,Math.max(0,b||0)),dependencies:Ue(ne),parent:u?n[u]??null:void 0,type:d?Ve(n[d]):void 0,locked:f?!!n[f]:void 0,color:x,borderColor:C,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:ee&&!isNaN(ee.getTime())?ee:void 0,fields:re(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[h,w,b]),ce=(0,t.useMemo)(()=>{let e=w?.groupByField;if(!e)return;let t=b?.fields??{},n=(e,t)=>{if(!t)return;let n=e;for(let e of t.split(`.`)){if(n==null)return;n=n[e]}return n},r=n=>{let r=(t[e]??t[e.split(`.`)[0]])?.options;if(Array.isArray(r)&&r.length){let e=r.find(e=>String(e.value)===String(n));if(e)return e.label}if(typeof n==`object`&&n){let e=n;return String(e.name??e.label??e.title??e.id??n)}return String(n)};return t=>{let i=n(t.data,e);return i==null||i===``?null:{key:typeof i==`object`&&i?String(i.id??i._id??r(i)):i,label:r(i)}}},[w?.groupByField,b]),le=(0,t.useMemo)(()=>{let e=w?.assigneeField;if(!e)return;let t=b?.fields??{},n=(e,t)=>{if(!t)return;let n=e;for(let e of t.split(`.`)){if(n==null)return;n=n[e]}return n},r=n=>{let r=(t[e]??t[e.split(`.`)[0]])?.options;if(Array.isArray(r)&&r.length){let e=r.find(e=>String(e.value)===String(n));if(e)return e.label}if(typeof n==`object`&&n){let e=n;return String(e.name??e.label??e.title??e.id??n)}return String(n)};return t=>{let i=n(t.data,e);return i==null||i===``?null:{key:typeof i==`object`&&i?String(i.id??i._id??r(i)):i,label:r(i)}}},[w?.assigneeField,b]),de=(0,t.useMemo)(()=>{let e=w?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[w?.effortField]),k=(0,t.useMemo)(()=>{let t=e.skipWeekends,n=e.holidays;if(!(!t&&(!n||n.length===0)))return{skipWeekends:!!t,holidays:n&&n.length?new Set(n):void 0}},[e]),fe=(0,t.useMemo)(()=>ue(w?.timeSegments),[w?.timeSegments]),A=(0,t.useCallback)((e,t)=>{if(!e||!t)return null;let n=e;for(let e of t.split(`.`)){if(n==null)return null;n=n[e]}if(n==null||n===``)return null;if(typeof n==`object`){let e=n;return String(e.id??e._id??e.value??e.name??``)}return String(n)},[]),me=w?.quickFilters,[he,ge]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!me?.length||!a||typeof a.find!=`function`)return;let e=b?.fields??{},t=!1;return(async()=>{let r={};for(let t of me){if(t.options)continue;let i=e[t.field]??e[t.field.split(`.`)[0]],o=i?.type;if(o!==`lookup`&&o!==`master_detail`)continue;let s=i?.reference_to??i?.reference??i?.referenceTo;if(s)try{let e=(0,n.extractRecords)(await a.find(s,{$top:1e3}));r[t.field]=e.map(e=>({value:String(e.id??e._id??e.value??``),label:String(e.name??e.label??e.title??e.id??e._id??``)}))}catch(e){console.warn(`[ObjectGantt] Failed to load quick-filter options for "${t.field}":`,e)}}t||ge(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(me),a,b]);let _e=(0,t.useMemo)(()=>{if(!me?.length)return[];let e=b?.fields??{};return me.map(t=>{let n=e[t.field]??e[t.field.split(`.`)[0]],r=t.label??n?.label??(0,l.humanizeLabel)(t.field),i=[];if(t.options?.length)i=t.options.map(e=>typeof e==`object`?{value:String(e.value),label:String(e.label??e.value)}:{value:String(e),label:String(e)});else if(Array.isArray(n?.options)&&n.options.length)i=n.options.map(e=>({value:String(e.value??e),label:String(e.label??e.value??e)}));else if(he[t.field]?.length)i=he[t.field];else{let e=new Map;for(let n of h){let r=A(n,t.field);if(r!=null&&!e.has(r)){let i=n;for(let e of t.field.split(`.`))i=i?.[e];let a=i&&typeof i==`object`?String(i.name??i.label??i.title??r):r;e.set(r,a)}}i=[...e.entries()].map(([e,t])=>({value:e,label:t}))}return{field:t.field,label:r,options:i}})},[me,b,he,h,A]),ve=e.persistLayout===!1?void 0:`${e.objectName||(C?.provider===`object`?C.object:``)||`gantt`}:${e.viewName||`default`}`,ye=ve?`gantt-layout:${ve}:filters`:null,[j,be]=(0,t.useState)(()=>{if(!ye||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(ye)||`null`);if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>typeof e==`string`));return t}catch{return{}}}),xe=(0,t.useCallback)(()=>{if(!(!ye||typeof window>`u`))try{window.localStorage.setItem(ye,JSON.stringify(j))}catch{}},[ye,j]),Se=(0,t.useCallback)((e,t)=>{be(n=>({...n,[e]:t}))},[]),Ce=(0,t.useCallback)(()=>be({}),[]),we=(0,t.useCallback)(e=>!!w?.objectField&&!String(e?.[w.objectField]??``).trim(),[w?.objectField]),Te=(0,t.useCallback)(e=>{let t=(w?.objectField?String(e[w.objectField]??``).trim():``)||E,n=e.id??e._id;if(!t||n==null)return null;let r=E?(0,s.deriveRecordPageHref)(E,n):null;return{objectName:t,recordId:n,href:!E||t===E?r:r?.replace(`/${E}/record/`,`/${t}/record/`)??null}},[w?.objectField,E]),Ee=(0,t.useMemo)(()=>{let e=Object.entries(j).filter(([,e])=>e.length>0);if(!e.length)return O;let t=new Map(O.map(e=>[String(e.id),e])),n=new Set;for(let r of O){if(!e.every(([e,t])=>{let n=A(r.data,e);return n!=null&&t.includes(n)}))continue;let i=r;for(;i&&!n.has(String(i.id));)n.add(String(i.id)),i=i.parent==null?void 0:t.get(String(i.parent))}return O.filter(e=>n.has(String(e.id)))},[O,j,A]),De=(0,t.useMemo)(()=>{if(w?.autoZoomToFilter!==!1||!O.length)return null;let e=O[0].start.getTime(),t=O[0].end.getTime();for(let n of O)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[O,w?.autoZoomToFilter]),Oe=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},ke=Oe.mode===`drawer`||Oe.mode===`modal`||Oe.mode===`split`||Oe.mode===`popover`,M=(0,r.useNavigationOverlay)({navigation:Oe,objectName:e.objectName,onRowClick:ke?void 0:p}),[Ae,Me]=(0,t.useState)(null),Ne=M.isOverlay&&M.isOpen?M.selectedRecord:null;(0,t.useEffect)(()=>{if(!Ne){Me(null);return}let e=Te(Ne);if(!e){Me(null);return}let{objectName:t,recordId:n}=e;if(!(C?.provider===`api`||t!==E)||!a||typeof a.findOne!=`function`){Me(null);return}let r=`${t}:${n}`,i=!1;return(async()=>{try{let[e,o]=await Promise.all([a.findOne(t,String(n)),typeof a.getObjectSchema==`function`?a.getObjectSchema(t).catch(()=>null):Promise.resolve(null)]);i||Me(e?{key:r,record:e,schema:o}:null)}catch(e){console.error(`[ObjectGantt] Failed to fetch drawer record, falling back to row payload:`,e),i||Me(null)}})(),()=>{i=!0}},[Ne,Te,C?.provider,E,a]);let Pe=(0,t.useCallback)(async(e,t)=>{if(!w||!T||typeof T.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=w,o={};if(t.start instanceof Date&&(o[n]=t.start.toISOString()),t.end instanceof Date&&(o[r]=t.end.toISOString()),typeof t.title==`string`&&i&&(o[i]=t.title),typeof t.progress==`number`&&a&&(o[a]=t.progress),Object.keys(o).length===0)return;let s=e.data?.id??e.data?._id??e.id;if(s==null)return;let c=h;g(e=>e.map(e=>String(e.id??e._id)===String(s)?{...e,...o}:e));try{await T.update(E,String(s),o),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),g(c),S(e)}},[w,T,E,h,D,S]),Fe=(e,t)=>{let n=t.some(e=>typeof e==`object`&&e.type&&e.type!==`fs`);return!n&&typeof e==`string`?t.map(e=>String(typeof e==`object`?e.id:e)).join(`,`):n?t.map(e=>typeof e==`object`?e.type&&e.type!==`fs`?{id:e.id,type:e.type}:e.id:e):t.map(e=>typeof e==`object`?e.id:e)},N=(0,t.useCallback)(async(e,t,n)=>{let r=w?.dependenciesField;if(!r||!T||typeof T.update!=`function`)return;let i=Fe(t,n),a=h;g(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await T.update(E,String(e),{[r]:i}),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),g(a),S(e)}},[w,T,E,h,D,S]),P=(0,t.useCallback)(async(e,t,n=`fs`)=>{let r=e.data?.id??e.data?._id??e.id,i=t.data?.id??t.data?._id??t.id;if(r==null||i==null)return;let a=w?.dependenciesField;if(!a)return;let o=h.find(e=>String(e.id??e._id)===String(i))?.[a],s=Ue(o),c=e=>String(typeof e==`object`?e.id:e),l=s.find(e=>c(e)===String(r)),u=l&&typeof l==`object`?l.type??`fs`:`fs`;if(l&&u===n)return;let d=n===`fs`?r:{id:r,type:n},f=l?s.map(e=>c(e)===String(r)?d:e):[...s,d];await N(i,o,f)},[w,h,N]),Ie=(0,t.useCallback)(async(e,t)=>{let n=e.data?.id??e.data?._id??e.id,r=t.data?.id??t.data?._id??t.id;if(n==null||r==null)return;let i=w?.dependenciesField;if(!i)return;let a=h.find(e=>String(e.id??e._id)===String(r))?.[i],o=Ue(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await N(r,a,c)},[w,h,N]),[I,L]=(0,t.useState)(null),[Le,Re]=(0,t.useState)(!1),ze=(0,t.useCallback)(e=>{L(e)},[]),R=(0,t.useCallback)(async()=>{if(!I)return;if(!T?.delete){L(null);return}let e=I.data?.id??I.data?._id??I.id;if(e==null){L(null);return}Re(!0);let t=h;g(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await T.delete(E,String(e))===!1)throw Error(x(`gantt.writeFailed`));L(null),D({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),g(t),L(null),S(e)}finally{Re(!1)}},[I,T,E,h,D,S,x]);return _?(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):ee?(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ee.message]})})}):w?(0,f.jsxs)(`div`,{className:u,children:[_e.length>0&&(0,f.jsx)(Be,{filters:_e,value:j,onChange:Se,onClear:Ce,resultCount:Ee.length,totalCount:O.length,labels:{all:`全部`,clear:`清除筛选`,empty:`无可选项`,resultSummary:(e,t)=>`显示 ${e} / ${t} 项任务`}}),(0,f.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:w?.resourceView&&le?(0,f.jsx)(F,{tasks:Ee,assignee:le,effort:de,capacity:w?.capacity??1,viewMode:e.viewMode||`day`}):(0,f.jsx)(je,{tasks:Ee,startDate:De?.start,endDate:De?.end,onTaskClick:e=>{we(e.data)||M.handleClick(e.data),d?.(e.data)},taskUrl:e=>{let t=e.data;if(!t||we(t))return null;let n=Te(t)?.href;return n?typeof window>`u`?n:new URL(n,window.location.href).toString():null},onTaskUpdate:Pe,onTaskDelete:ze,onDependencyCreate:w?.dependenciesField?P:void 0,onDependencyDelete:w?.dependenciesField?Ie:void 0,markers:e.markers,autoSchedule:!!w?.dependenciesField,rescheduleOnConflict:!!w?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:k,shiftSegments:fe,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:ve,onLayoutChange:ye?xe:void 0,groupBy:ce,defaultCollapsedDepth:w?.defaultCollapsedDepth,summaryExtent:w?.summaryExtent,inlineEdit:!0,onRefresh:(C?.provider===`object`||C?.provider===`api`)&&typeof T?.find==`function`?()=>D({silent:!0}):void 0,refreshing:ae})}),M.isOverlay&&M.isOpen&&M.selectedRecord&&(()=>{let t=M.selectedRecord,n=Te(t);if(!n||we(t))return null;let{objectName:r,recordId:i}=n,o=n.href??void 0,c=w?.titleField?String(t[w.titleField]??x(`gantt.drawer.fallbackTitle`)):x(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(w?.lockField?!!t[w.lockField]:!1),u=Ae?.key===`${r}:${i}`?Ae:null,d=u?.record??t,p=u?.schema??(r===E?b:void 0),m=u&&a?a:T;return(0,f.jsx)(s.RecordDetailDrawer,{open:!0,onClose:M.close,title:c,record:d,objectName:r,recordId:i,dataSource:m??void 0,objectSchema:p,width:M.width,fullPageHref:o,onFieldSave:l?void 0:async(e,t)=>{if(m?.update){try{await m.update(r,String(i),{[e]:t})}catch(e){let t=Ke(e);throw t?Error(t):e}u&&Me(n=>n&&n.key===u.key?{...n,record:{...n.record,[e]:t}}:n),g(n=>n.map(n=>String(n.id??n._id)===String(i)?{...n,[e]:t}:n)),D({silent:!0})}},onDelete:l?void 0:async()=>{if(T?.delete){try{if(await T.delete(r,String(i))===!1)throw Error(x(`gantt.writeFailed`))}catch(e){throw S(e),e}g(e=>e.filter(e=>String(e.id??e._id)!==String(i)))}}})})(),(0,f.jsx)(c.AlertDialog,{open:!!I,onOpenChange:e=>{!e&&!Le&&L(null)},children:(0,f.jsxs)(c.AlertDialogContent,{children:[(0,f.jsxs)(c.AlertDialogHeader,{children:[(0,f.jsx)(c.AlertDialogTitle,{children:x(`gantt.delete.title`)}),(0,f.jsx)(c.AlertDialogDescription,{children:I?x(`gantt.delete.body`,{title:I.title}):null})]}),(0,f.jsxs)(c.AlertDialogFooter,{children:[(0,f.jsx)(c.AlertDialogCancel,{disabled:Le,children:x(`gantt.delete.cancel`)}),(0,f.jsx)(c.AlertDialogAction,{onClick:e=>{e.preventDefault(),R()},disabled:Le,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:x(Le?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]}):(0,f.jsx)(`div`,{className:u,children:(0,f.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,f.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},Je=({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{};return(0,f.jsx)(qe,{schema:e,dataSource:t})};n.ComponentRegistry.register(`object-gantt`,Je,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),n.ComponentRegistry.register(`gantt`,Je,{namespace:`view`,label:`Gantt View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),e.GanttView=je,e.ObjectGantt=qe,e.ObjectGanttRenderer=Je,e.QuickFilterBar=Be,e.ResourceWorkload=F,e.bandAt=k,e.computeWorkload=Ne,e.normalizeDependencies=Ue,e.normalizeShiftSegments=ue,e.normalizeTaskType=Ve,e.parseHHMM=le,e.shiftDayStart=de});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-gantt",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Gantt chart plugin for Object UI",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"lucide-react": "^1.24.0",
|
|
29
29
|
"qrcode": "^1.5.4",
|
|
30
30
|
"sonner": "^2.0.7",
|
|
31
|
-
"@object-ui/components": "14.
|
|
32
|
-
"@object-ui/core": "14.
|
|
33
|
-
"@object-ui/fields": "14.
|
|
34
|
-
"@object-ui/i18n": "14.
|
|
35
|
-
"@object-ui/plugin-detail": "14.
|
|
36
|
-
"@object-ui/react": "14.
|
|
37
|
-
"@object-ui/types": "14.
|
|
31
|
+
"@object-ui/components": "14.1.0",
|
|
32
|
+
"@object-ui/core": "14.1.0",
|
|
33
|
+
"@object-ui/fields": "14.1.0",
|
|
34
|
+
"@object-ui/i18n": "14.1.0",
|
|
35
|
+
"@object-ui/plugin-detail": "14.1.0",
|
|
36
|
+
"@object-ui/react": "14.1.0",
|
|
37
|
+
"@object-ui/types": "14.1.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0",
|