@object-ui/plugin-gantt 17.1.0 → 17.3.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 +117 -0
- package/dist/ObjectGantt.d.ts.map +1 -1
- package/dist/index.js +75 -71
- package/dist/index.umd.cjs +3 -3
- package/dist/useGanttTranslation.d.ts.map +1 -1
- package/package.json +14 -14
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("sonner"),require("@objectstack/spec/ui"),require("@object-ui/i18n"),require("@object-ui/plugin-detail"),require("@object-ui/components"),require("@object-ui/fields"),require("lucide-react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`sonner`,`@objectstack/spec/ui`,`@object-ui/i18n`,`@object-ui/plugin-detail`,`@object-ui/components`,`@object-ui/fields`,`lucide-react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginGantt={},e.React,e.ObjectUICore,e.ObjectUIReact,e.sonner,e._objectstack_spec_ui,e._object_ui_i18n,e._object_ui_plugin_detail,e.ObjectUIComponents,e._object_ui_fields,e.LucideReact,e.react_jsx_runtime))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule?p(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var y=1e3*60*60*24,ee=e=>e.toISOString().slice(0,10);function te(e,t){if(t.skipWeekends){let t=e.getUTCDay();if(t===0||t===6)return!1}return!(t.holidays&&t.holidays.has(ee(e)))}function b(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t}function x(e,t){let n=b(e);for(;!te(n,t);)n=new Date(n.getTime()+y);return n.getTime()}function ne(e,t,n){if(t<=e)return 0;let r=0,i=b(e),a=b(t).getTime();for(;i.getTime()<a;)te(i,n)&&r++,i=new Date(i.getTime()+y);return r}function S(e,t,n){if(t<=0)return b(e).getTime();let r=b(e),i=t;for(;i>0;)te(r,n)&&i--,r=new Date(r.getTime()+y);return r.getTime()}function re(e,t,n){if(t<=0)return b(e).getTime();let r=b(e),i=t;for(;i>0;)r=new Date(r.getTime()-y),te(r,n)&&i--;return r.getTime()}var C=e=>String(e);function w(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function T(e){let t=new Set(e.map(e=>C(e.id))),n=[];for(let r of e){let e=C(r.id);for(let i of r.dependencies??[]){let r=typeof i==`object`&&!!i,a=r?i.id:i;if(a==null||a===``)continue;let o=C(a);o===e||!t.has(o)||n.push({pred:o,succ:e,type:w(r?i.type:void 0)})}}return n}function ie(e){let t=new Set;for(let n of e)n.parent!=null&&n.parent!==``&&t.add(C(n.parent));return t}function ae(e,t){let n=new Map,r=new Map;for(let t of e)n.set(t,0),r.set(t,[]);for(let e of t)r.get(e.pred).push(e.succ),n.set(e.succ,(n.get(e.succ)??0)+1);let i=e.filter(e=>(n.get(e)??0)===0),a=[];for(;i.length;){let e=i.shift();a.push(e);for(let t of r.get(e)??[]){let e=(n.get(t)??0)-1;n.set(t,e),e===0&&i.push(t)}}if(a.length<e.length){let t=new Set(a);for(let n of e)t.has(n)||a.push(n);return{order:a,hasCycle:!0}}return{order:a,hasCycle:!1}}function E(e,t){let n={criticalIds:new Set,criticalEdges:new Set};if(!e.length)return n;let r=new Map;for(let n of e){let e=t?ne(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/y;r.set(C(n.id),Number.isFinite(e)&&e>0?e:0)}let i=T(e),a=e.map(e=>C(e.id)),{order:o,hasCycle:s}=ae(a,i);if(s)return n;let c=new Map,l=new Map;for(let e of a)c.set(e,[]),l.set(e,[]);for(let e of i)c.get(e.succ).push(e),l.get(e.pred).push(e);let u=new Map,d=new Map;for(let e of o){let t=0;for(let n of c.get(e)??[])t=Math.max(t,d.get(n.pred)??0);u.set(e,t),d.set(e,t+(r.get(e)??0))}let f=Math.max(0,...a.map(e=>d.get(e)??0)),p=new Map,m=new Map;for(let e=o.length-1;e>=0;e--){let t=o[e],n=l.get(t)??[],i=f;n.length&&(i=Math.min(...n.map(e=>m.get(e.succ)??f))),p.set(t,i),m.set(t,i-(r.get(t)??0))}let h=1e-6,g=new Set;for(let e of a){let t=(m.get(e)??0)-(u.get(e)??0);Math.abs(t)<=h&&g.add(e)}let _=new Set;for(let e of i)_.add(e.pred),_.add(e.succ);for(let e of[...g])!_.has(e)&&(r.get(e)??0)===0&&g.delete(e);let v=new Set;for(let e of i)!g.has(e.pred)||!g.has(e.succ)||Math.abs((d.get(e.pred)??0)-(u.get(e.succ)??0))<=h&&v.add(`${e.pred}->${e.succ}`);return{criticalIds:g,criticalEdges:v}}function D(e,t,n){if(!e.length)return{changes:[],skippedLocked:[]};let r=T(e),i=e.map(e=>C(e.id)),{order:a,hasCycle:o}=ae(i,r);if(o)return{changes:[],skippedLocked:[]};let s=ie(e),c=new Map;for(let t of e)c.set(C(t.id),t);let l=new Map;for(let t of e){if(t.parent==null||t.parent===``)continue;let e=C(t.parent),n=l.get(e)??[];n.push(t),l.set(e,n)}let u=n?.summaryExtent===`self`,d=e=>u&&e.hasOwnDates!==!1&&!e.locked,f=new Map;for(let e of i)f.set(e,[]);for(let e of r)f.get(e.succ).push(e);let p=new Map,m=new Map;for(let t of e)p.set(C(t.id),t.start.getTime()),m.set(C(t.id),t.end.getTime());let h=[];for(let e of a){let r=c.get(e);if(!r)continue;let i=t?ne(p.get(e),m.get(e),t):m.get(e)-p.get(e),a=r.start.getTime(),o=a;for(let n of f.get(e)??[]){let e=p.get(n.pred),r=m.get(n.pred),a;switch(n.type){case`ss`:a=e;break;case`ff`:a=t?re(r,i,t):r-i;break;case`sf`:a=t?re(e,i,t):e-i;break;default:a=r;break}a>o&&(o=a)}let l=o>a;if(!(s.has(e)&&!d(r))){if(r.locked){l&&h.push(e);continue}if(l&&!t&&n?.snapStart&&(o=Math.max(o,n.snapStart(o))),t){let n=x(o,t);p.set(e,n),m.set(e,S(n,i,t))}else p.set(e,o),m.set(e,o+i)}}if(u)for(let t of e){let e=C(t.id);if(!s.has(e)||!d(t))continue;let n=p.get(e)-t.start.getTime();if(n<=0)continue;let r=[...l.get(e)??[]];for(;r.length;){let e=r.pop(),t=C(e.id);if(r.push(...l.get(t)??[]),e.locked)continue;let i=e.start.getTime()+n;if(i>p.get(t)){let e=m.get(t)-p.get(t);p.set(t,i),m.set(t,i+e)}}}let g=[];for(let t of e){let e=C(t.id),n=p.get(e),r=m.get(e);(n!==t.start.getTime()||r!==t.end.getTime())&&g.push({id:e,start:new Date(n),end:new Date(r)})}return{changes:g,skippedLocked:h}}function oe(e,t,n){let r=String(t),i=String(n);if(r===i)return!0;let a=new Map;for(let[t,n]of e){let e=a.get(t);e?e.push(n):a.set(t,[n])}let o=new Set([i]),s=[i];for(;s.length;){let e=s.pop();for(let t of a.get(e)??[]){if(t===r)return!0;o.has(t)||(o.add(t),s.push(t))}}return!1}var se=6e4;1440*se;var ce=1440;function O(e){if(typeof e!=`string`)return null;let t=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n<0||n>23||r<0||r>59?null:n*60+r}function le(e){if(!e||!Array.isArray(e.bands)||e.bands.length===0)return null;let t=O(e.dayStart)??0,n=[];for(let t=0;t<e.bands.length;t++){let r=e.bands[t],i=O(r.start),a=O(r.end);if(i==null||a==null||!r.label)return null;let o=(a-i+ce)%ce||ce;n.push({key:r.key??`band${t}`,label:r.label,color:r.color,durMs:o*se})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function k(e,t){let n=new Date(e);return n.setHours(0,0,0,0),n.setMinutes(t),n.getTime()>e.getTime()&&n.setDate(n.getDate()-1),n}function ue(e,t){if(t.bands.length===0)return null;let n=k(e,t.dayStartMin).getTime(),r=e.getTime()-n,i=0;for(let e of t.bands)if(i+=e.durMs,r<i)return e;return t.bands[t.bands.length-1]}var de={"gantt.column.taskName":`Task Name`,"gantt.column.start":`Start`,"gantt.column.end":`End`,"gantt.toolbar.prevPeriod":`Previous period`,"gantt.toolbar.nextPeriod":`Next period`,"gantt.toolbar.zoomIn":`Zoom in`,"gantt.toolbar.zoomOut":`Zoom out`,"gantt.toolbar.jumpToToday":`Jump to today`,"gantt.toolbar.today":`Today`,"gantt.toolbar.thisWeek":`This week`,"gantt.toolbar.thisMonth":`This month`,"gantt.toolbar.exportPdf":`Export PDF`,"gantt.toolbar.saveLayout":`Save layout`,"gantt.toolbar.showTaskList":`Show task list`,"gantt.toolbar.hideTaskList":`Hide task list`,"gantt.toolbar.viewMode":`Timeline granularity`,"gantt.toolbar.enterFullscreen":`Enter fullscreen`,"gantt.toolbar.exitFullscreen":`Exit fullscreen`,"gantt.toolbar.criticalPath":`Highlight critical path`,"gantt.toolbar.autoSchedule":`Auto-schedule dependencies`,"gantt.toolbar.exportPng":`Export as PNG`,"gantt.toolbar.refresh":`Refresh`,"gantt.toolbar.undo":`Undo`,"gantt.toolbar.redo":`Redo`,"gantt.viewMode.day":`Day`,"gantt.viewMode.week":`Week`,"gantt.viewMode.month":`Month`,"gantt.viewMode.quarter":`Quarter`,"gantt.viewMode.year":`Year`,"gantt.row.expand":`Expand`,"gantt.row.collapse":`Collapse`,"gantt.row.open":`Open details`,"gantt.aria.taskList":`Task list`,"gantt.tooltip.days":`d`,"gantt.menu.view":`View details`,"gantt.menu.edit":`Edit inline`,"gantt.menu.delete":`Delete`,"gantt.menu.addPredecessor":`Add predecessor…`,"gantt.menu.addSuccessor":`Add successor…`,"gantt.menu.removeDependency":`Remove dependency`,"gantt.menu.noCandidates":`No available tasks`,"gantt.menu.searchTasks":`Search tasks…`,"gantt.delete.title":`Delete this task?`,"gantt.delete.body":`"{{title}}" will be permanently removed. This action cannot be undone.`,"gantt.delete.cancel":`Cancel`,"gantt.delete.confirm":`Delete`,"gantt.delete.deleting":`Deleting…`,"gantt.drawer.fallbackTitle":`Task Details`,"gantt.linkType.fs":`Finish → Start`,"gantt.linkType.ss":`Start → Start`,"gantt.linkType.ff":`Finish → Finish`,"gantt.linkType.sf":`Start → Finish`,"gantt.linkEnd.start":`start`,"gantt.linkEnd.end":`end`,"gantt.conflict.title":`Schedule conflict`,"gantt.conflict.body":`This move conflicts with dependency constraints. Auto-reschedule {count} affected task(s)?`,"gantt.conflict.confirm":`Auto-reschedule`,"gantt.conflict.cancel":`Keep as is`,"gantt.autoScheduleDlg.title":`Auto-schedule`,"gantt.autoScheduleDlg.body":`Shift {count} task(s) later to satisfy dependency links?`,"gantt.autoScheduleDlg.skipped":`{count} locked task(s) also violate links and were skipped.`,"gantt.autoScheduleDlg.confirm":`Apply`,"gantt.autoScheduleDlg.cancel":`Cancel`,"gantt.autoScheduleDlg.none":`All dependencies satisfied — nothing to reschedule.`,"gantt.resource.header":`Resource`,"gantt.resource.peak":`Peak`,"gantt.resource.over":`overloaded`,"gantt.resource.empty":`No tasks to allocate.`,"gantt.readOnly":`Read-only`,"gantt.readOnlyHint":`Editing is disabled for this view.`,"gantt.lockedHint":`No edit permission`,"gantt.writeFailed":`Save failed — the change was rolled back`};function fe(e,t){let n=de[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function pe(){let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:fe(t,n)},language:e.language}}var me=8;function he(e,t){if(t.width<=0)return`move`;let n=Math.min(me,t.width/3),r=e-t.left;return r<=n?`resize-left`:r>=t.width-n?`resize-right`:`move`}function ge(e){return 110}function _e(e){return e<640?140:e<1024?220:320}function ve(e){return e>=280}function ye(e){return e<640?32:40}var be=[`day`,`week`,`month`,`quarter`,`year`],xe={day:1,week:7,month:30.44,quarter:91.31,year:365.25},A=1e3*60*60*24;function Se(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),r=e=>Number(n.formatToParts(t).find(t=>t.type===e)?.value??0);return Date.UTC(r(`year`),r(`month`)-1,r(`day`),r(`hour`)%24,r(`minute`),r(`second`))-Math.floor(t.getTime()/1e3)*1e3}function Ce(e){let t={delta:0,to:e=>e,from:e=>e,now:()=>new Date};if(!e)return t;try{Se(e,new Date)}catch{return console.warn(`[GanttView] invalid timeZone "${e}" — falling back to the browser zone`),t}let n=t=>Se(e,t)- -t.getTimezoneOffset()*6e4,r=n(new Date);return r===0?t:{delta:r,to:e=>new Date(e.getTime()+n(e)),from:e=>new Date(e.getTime()-n(e)),now:()=>new Date(Date.now()+n(new Date))}}function we(e,t){let n=new Date(e);return n.setHours(0,0,0,0),t===`week`?n.setDate(n.getDate()-(n.getDay()+6)%7):t===`month`?n.setDate(1):t===`quarter`?n.setMonth(Math.floor(n.getMonth()/3)*3,1):t===`year`&&n.setMonth(0,1),n}function Te(e,t,n){let r=e.length-1,i=0;for(;i<r&&e[i+1]<t;)i++;let a=i;for(;a<r&&e[a]<n;)a++;return{start:i,end:a}}function Ee(e,t,n){let r=new Date(e);if(n===`day`)r.setDate(r.getDate()+t);else if(n===`week`)r.setDate(r.getDate()+t*7);else{let e=t*(n===`month`?1:n===`quarter`?3:12),i=r.getDate();r.setDate(1),r.setMonth(r.getMonth()+e);let a=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();r.setDate(Math.min(i,a))}return r}function De(e,t,n,r=2){return new Promise(i=>{let a=new Blob([e],{type:`image/svg+xml;charset=utf-8`}),o=URL.createObjectURL(a),s=new Image;s.onload=()=>{let e=document.createElement(`canvas`);e.width=t*r,e.height=n*r;let a=e.getContext(`2d`);a&&(a.fillStyle=`#ffffff`,a.fillRect(0,0,e.width,e.height),a.scale(r,r),a.drawImage(s,0,0)),URL.revokeObjectURL(o),i(e)},s.onerror=()=>{URL.revokeObjectURL(o),i(null)},s.src=o})}function Oe(e,t){let n=document.createElement(`a`);n.href=URL.createObjectURL(e),n.download=t,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(n.href),1e3)}function ke(e,t,n){let r=e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t},i=`q ${t} 0 0 ${n} 0 0 cm /Im0 Do Q`,a=[],o=[],s=0,c=e=>{a.push(e),s+=e.length},l=()=>{o.push(s)};c(r(`%PDF-1.3
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("sonner"),require("@objectstack/spec/ui"),require("@object-ui/i18n"),require("@object-ui/plugin-detail"),require("@object-ui/components"),require("@object-ui/fields"),require("lucide-react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`sonner`,`@objectstack/spec/ui`,`@object-ui/i18n`,`@object-ui/plugin-detail`,`@object-ui/components`,`@object-ui/fields`,`lucide-react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginGantt={},e.React,e.ObjectUICore,e.ObjectUIReact,e.sonner,e._objectstack_spec_ui,e._object_ui_i18n,e._object_ui_plugin_detail,e.ObjectUIComponents,e._object_ui_fields,e.LucideReact,e.react_jsx_runtime))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule||!_.call(e,`default`)?p(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var y=864e5,ee=e=>e.toISOString().slice(0,10);function te(e,t){if(t.skipWeekends){let t=e.getUTCDay();if(t===0||t===6)return!1}return!(t.holidays&&t.holidays.has(ee(e)))}function b(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t}function x(e,t){let n=b(e);for(;!te(n,t);)n=new Date(n.getTime()+y);return n.getTime()}function ne(e,t,n){if(t<=e)return 0;let r=0,i=b(e),a=b(t).getTime();for(;i.getTime()<a;)te(i,n)&&r++,i=new Date(i.getTime()+y);return r}function S(e,t,n){if(t<=0)return b(e).getTime();let r=b(e),i=t;for(;i>0;)te(r,n)&&i--,r=new Date(r.getTime()+y);return r.getTime()}function C(e,t,n){if(t<=0)return b(e).getTime();let r=b(e),i=t;for(;i>0;)r=new Date(r.getTime()-y),te(r,n)&&i--;return r.getTime()}var w=e=>String(e);function T(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function E(e){let t=new Set(e.map(e=>w(e.id))),n=[];for(let r of e){let e=w(r.id);for(let i of r.dependencies??[]){let r=typeof i==`object`&&!!i,a=r?i.id:i;if(a==null||a===``)continue;let o=w(a);o===e||!t.has(o)||n.push({pred:o,succ:e,type:T(r?i.type:void 0)})}}return n}function re(e){let t=new Set;for(let n of e)n.parent!=null&&n.parent!==``&&t.add(w(n.parent));return t}function ie(e,t){let n=new Map,r=new Map;for(let t of e)n.set(t,0),r.set(t,[]);for(let e of t)r.get(e.pred).push(e.succ),n.set(e.succ,(n.get(e.succ)??0)+1);let i=e.filter(e=>(n.get(e)??0)===0),a=[];for(;i.length;){let e=i.shift();a.push(e);for(let t of r.get(e)??[]){let e=(n.get(t)??0)-1;n.set(t,e),e===0&&i.push(t)}}if(a.length<e.length){let t=new Set(a);for(let n of e)t.has(n)||a.push(n);return{order:a,hasCycle:!0}}return{order:a,hasCycle:!1}}function D(e,t){let n={criticalIds:new Set,criticalEdges:new Set};if(!e.length)return n;let r=new Map;for(let n of e){let e=t?ne(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/y;r.set(w(n.id),Number.isFinite(e)&&e>0?e:0)}let i=E(e),a=e.map(e=>w(e.id)),{order:o,hasCycle:s}=ie(a,i);if(s)return n;let c=new Map,l=new Map;for(let e of a)c.set(e,[]),l.set(e,[]);for(let e of i)c.get(e.succ).push(e),l.get(e.pred).push(e);let u=new Map,d=new Map;for(let e of o){let t=0;for(let n of c.get(e)??[])t=Math.max(t,d.get(n.pred)??0);u.set(e,t),d.set(e,t+(r.get(e)??0))}let f=Math.max(0,...a.map(e=>d.get(e)??0)),p=new Map,m=new Map;for(let e=o.length-1;e>=0;e--){let t=o[e],n=l.get(t)??[],i=f;n.length&&(i=Math.min(...n.map(e=>m.get(e.succ)??f))),p.set(t,i),m.set(t,i-(r.get(t)??0))}let h=1e-6,g=new Set;for(let e of a){let t=(m.get(e)??0)-(u.get(e)??0);Math.abs(t)<=h&&g.add(e)}let _=new Set;for(let e of i)_.add(e.pred),_.add(e.succ);for(let e of[...g])!_.has(e)&&(r.get(e)??0)===0&&g.delete(e);let v=new Set;for(let e of i)!g.has(e.pred)||!g.has(e.succ)||Math.abs((d.get(e.pred)??0)-(u.get(e.succ)??0))<=h&&v.add(`${e.pred}->${e.succ}`);return{criticalIds:g,criticalEdges:v}}function O(e,t,n){if(!e.length)return{changes:[],skippedLocked:[]};let r=E(e),i=e.map(e=>w(e.id)),{order:a,hasCycle:o}=ie(i,r);if(o)return{changes:[],skippedLocked:[]};let s=re(e),c=new Map;for(let t of e)c.set(w(t.id),t);let l=new Map;for(let t of e){if(t.parent==null||t.parent===``)continue;let e=w(t.parent),n=l.get(e)??[];n.push(t),l.set(e,n)}let u=n?.summaryExtent===`self`,d=e=>u&&e.hasOwnDates!==!1&&!e.locked,f=new Map;for(let e of i)f.set(e,[]);for(let e of r)f.get(e.succ).push(e);let p=new Map,m=new Map;for(let t of e)p.set(w(t.id),t.start.getTime()),m.set(w(t.id),t.end.getTime());let h=[];for(let e of a){let r=c.get(e);if(!r)continue;let i=t?ne(p.get(e),m.get(e),t):m.get(e)-p.get(e),a=r.start.getTime(),o=a;for(let n of f.get(e)??[]){let e=p.get(n.pred),r=m.get(n.pred),a;switch(n.type){case`ss`:a=e;break;case`ff`:a=t?C(r,i,t):r-i;break;case`sf`:a=t?C(e,i,t):e-i;break;default:a=r}a>o&&(o=a)}let l=o>a;if(!(s.has(e)&&!d(r))){if(r.locked){l&&h.push(e);continue}if(l&&!t&&n?.snapStart&&(o=Math.max(o,n.snapStart(o))),t){let n=x(o,t);p.set(e,n),m.set(e,S(n,i,t))}else p.set(e,o),m.set(e,o+i)}}if(u)for(let t of e){let e=w(t.id);if(!s.has(e)||!d(t))continue;let n=p.get(e)-t.start.getTime();if(n<=0)continue;let r=[...l.get(e)??[]];for(;r.length;){let e=r.pop(),t=w(e.id);if(r.push(...l.get(t)??[]),e.locked)continue;let i=e.start.getTime()+n;if(i>p.get(t)){let e=m.get(t)-p.get(t);p.set(t,i),m.set(t,i+e)}}}let g=[];for(let t of e){let e=w(t.id),n=p.get(e),r=m.get(e);(n!==t.start.getTime()||r!==t.end.getTime())&&g.push({id:e,start:new Date(n),end:new Date(r)})}return{changes:g,skippedLocked:h}}function ae(e,t,n){let r=String(t),i=String(n);if(r===i)return!0;let a=new Map;for(let[t,n]of e){let e=a.get(t);e?e.push(n):a.set(t,[n])}let o=new Set([i]),s=[i];for(;s.length;){let e=s.pop();for(let t of a.get(e)??[]){if(t===r)return!0;o.has(t)||(o.add(t),s.push(t))}}return!1}var oe=6e4;1440*oe;var se=1440;function k(e){if(typeof e!=`string`)return null;let t=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n<0||n>23||r<0||r>59?null:n*60+r}function ce(e){if(!e||!Array.isArray(e.bands)||e.bands.length===0)return null;let t=k(e.dayStart)??0,n=[];for(let t=0;t<e.bands.length;t++){let r=e.bands[t],i=k(r.start),a=k(r.end);if(i==null||a==null||!r.label)return null;let o=(a-i+se)%se||se;n.push({key:r.key??`band${t}`,label:r.label,color:r.color,durMs:o*oe})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function A(e,t){let n=new Date(e);return n.setHours(0,0,0,0),n.setMinutes(t),n.getTime()>e.getTime()&&n.setDate(n.getDate()-1),n}function le(e,t){if(t.bands.length===0)return null;let n=A(e,t.dayStartMin).getTime(),r=e.getTime()-n,i=0;for(let e of t.bands)if(i+=e.durMs,r<i)return e;return t.bands[t.bands.length-1]}var ue={"gantt.column.taskName":`Task Name`,"gantt.column.start":`Start`,"gantt.column.end":`End`,"gantt.toolbar.prevPeriod":`Previous period`,"gantt.toolbar.nextPeriod":`Next period`,"gantt.toolbar.zoomIn":`Zoom in`,"gantt.toolbar.zoomOut":`Zoom out`,"gantt.toolbar.jumpToToday":`Jump to today`,"gantt.toolbar.today":`Today`,"gantt.toolbar.thisWeek":`This week`,"gantt.toolbar.thisMonth":`This month`,"gantt.toolbar.exportPdf":`Export PDF`,"gantt.toolbar.saveLayout":`Save layout`,"gantt.toolbar.showTaskList":`Show task list`,"gantt.toolbar.hideTaskList":`Hide task list`,"gantt.toolbar.viewMode":`Timeline granularity`,"gantt.toolbar.enterFullscreen":`Enter fullscreen`,"gantt.toolbar.exitFullscreen":`Exit fullscreen`,"gantt.toolbar.criticalPath":`Highlight critical path`,"gantt.toolbar.autoSchedule":`Auto-schedule dependencies`,"gantt.toolbar.exportPng":`Export as PNG`,"gantt.toolbar.refresh":`Refresh`,"gantt.toolbar.undo":`Undo`,"gantt.toolbar.redo":`Redo`,"gantt.viewMode.day":`Day`,"gantt.viewMode.week":`Week`,"gantt.viewMode.month":`Month`,"gantt.viewMode.quarter":`Quarter`,"gantt.viewMode.year":`Year`,"gantt.row.expand":`Expand`,"gantt.row.collapse":`Collapse`,"gantt.row.open":`Open details`,"gantt.aria.taskList":`Task list`,"gantt.tooltip.days":`d`,"gantt.menu.view":`View details`,"gantt.menu.edit":`Edit inline`,"gantt.menu.delete":`Delete`,"gantt.menu.addPredecessor":`Add predecessor…`,"gantt.menu.addSuccessor":`Add successor…`,"gantt.menu.removeDependency":`Remove dependency`,"gantt.menu.noCandidates":`No available tasks`,"gantt.menu.searchTasks":`Search tasks…`,"gantt.delete.title":`Delete this task?`,"gantt.delete.body":`"{{title}}" will be permanently removed. This action cannot be undone.`,"gantt.delete.cancel":`Cancel`,"gantt.delete.confirm":`Delete`,"gantt.delete.deleting":`Deleting…`,"gantt.drawer.fallbackTitle":`Task Details`,"gantt.linkType.fs":`Finish → Start`,"gantt.linkType.ss":`Start → Start`,"gantt.linkType.ff":`Finish → Finish`,"gantt.linkType.sf":`Start → Finish`,"gantt.linkEnd.start":`start`,"gantt.linkEnd.end":`end`,"gantt.conflict.title":`Schedule conflict`,"gantt.conflict.body":`This move conflicts with dependency constraints. Auto-reschedule {count} affected task(s)?`,"gantt.conflict.confirm":`Auto-reschedule`,"gantt.conflict.cancel":`Keep as is`,"gantt.autoScheduleDlg.title":`Auto-schedule`,"gantt.autoScheduleDlg.body":`Shift {count} task(s) later to satisfy dependency links?`,"gantt.autoScheduleDlg.skipped":`{count} locked task(s) also violate links and were skipped.`,"gantt.autoScheduleDlg.confirm":`Apply`,"gantt.autoScheduleDlg.cancel":`Cancel`,"gantt.autoScheduleDlg.none":`All dependencies satisfied — nothing to reschedule.`,"gantt.quickFilter.all":`All`,"gantt.quickFilter.clear":`Clear filters`,"gantt.quickFilter.empty":`No options`,"gantt.quickFilter.resultSummary":`Showing {shown} / {total} tasks`,"gantt.resource.header":`Resource`,"gantt.resource.peak":`Peak`,"gantt.resource.over":`overloaded`,"gantt.resource.empty":`No tasks to allocate.`,"gantt.readOnly":`Read-only`,"gantt.readOnlyHint":`Editing is disabled for this view.`,"gantt.lockedHint":`No edit permission`,"gantt.writeFailed":`Save failed — the change was rolled back`};function de(e,t){let n=ue[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function fe(){let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:de(t,n)},language:e.language}}var pe=8;function me(e,t){if(t.width<=0)return`move`;let n=Math.min(pe,t.width/3),r=e-t.left;return r<=n?`resize-left`:r>=t.width-n?`resize-right`:`move`}function he(e){return 110}function ge(e){return e<640?140:e<1024?220:320}function _e(e){return e>=280}function ve(e){return e<640?32:40}var ye=[`day`,`week`,`month`,`quarter`,`year`],be={day:1,week:7,month:30.44,quarter:91.31,year:365.25},j=864e5;function xe(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),r=e=>Number(n.formatToParts(t).find(t=>t.type===e)?.value??0);return Date.UTC(r(`year`),r(`month`)-1,r(`day`),r(`hour`)%24,r(`minute`),r(`second`))-Math.floor(t.getTime()/1e3)*1e3}function Se(e){let t={delta:0,to:e=>e,from:e=>e,now:()=>new Date};if(!e)return t;try{xe(e,new Date)}catch{return console.warn(`[GanttView] invalid timeZone "${e}" — falling back to the browser zone`),t}let n=t=>xe(e,t)- -t.getTimezoneOffset()*6e4,r=n(new Date);return r===0?t:{delta:r,to:e=>new Date(e.getTime()+n(e)),from:e=>new Date(e.getTime()-n(e)),now:()=>new Date(Date.now()+n(new Date))}}function Ce(e,t){let n=new Date(e);return n.setHours(0,0,0,0),t===`week`?n.setDate(n.getDate()-(n.getDay()+6)%7):t===`month`?n.setDate(1):t===`quarter`?n.setMonth(Math.floor(n.getMonth()/3)*3,1):t===`year`&&n.setMonth(0,1),n}function we(e,t,n){let r=e.length-1,i=0;for(;i<r&&e[i+1]<t;)i++;let a=i;for(;a<r&&e[a]<n;)a++;return{start:i,end:a}}function Te(e,t,n){let r=new Date(e);if(n===`day`)r.setDate(r.getDate()+t);else if(n===`week`)r.setDate(r.getDate()+t*7);else{let e=t*(n===`month`?1:n===`quarter`?3:12),i=r.getDate();r.setDate(1),r.setMonth(r.getMonth()+e);let a=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();r.setDate(Math.min(i,a))}return r}function Ee(e,t,n,r=2){return new Promise(i=>{let a=new Blob([e],{type:`image/svg+xml;charset=utf-8`}),o=URL.createObjectURL(a),s=new Image;s.onload=()=>{let e=document.createElement(`canvas`);e.width=t*r,e.height=n*r;let a=e.getContext(`2d`);a&&(a.fillStyle=`#ffffff`,a.fillRect(0,0,e.width,e.height),a.scale(r,r),a.drawImage(s,0,0)),URL.revokeObjectURL(o),i(e)},s.onerror=()=>{URL.revokeObjectURL(o),i(null)},s.src=o})}function De(e,t){let n=document.createElement(`a`);n.href=URL.createObjectURL(e),n.download=t,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(n.href),1e3)}function Oe(e,t,n){let r=e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t},i=`q ${t} 0 0 ${n} 0 0 cm /Im0 Do Q`,a=[],o=[],s=0,c=e=>{a.push(e),s+=e.length},l=()=>{o.push(s)};c(r(`%PDF-1.3
|
|
2
2
|
%ÿÿÿÿ
|
|
3
3
|
`)),l(),c(r(`1 0 obj
|
|
4
4
|
<< /Type /Catalog /Pages 2 0 R >>
|
|
@@ -12,7 +12,7 @@ endobj
|
|
|
12
12
|
`)),l(),c(r(`5 0 obj\n<< /Length ${i.length} >>\nstream\n${i}\nendstream\nendobj\n`));let u=s,d=`xref
|
|
13
13
|
0 6
|
|
14
14
|
0000000000 65535 f
|
|
15
|
-
`;for(let e of o)d+=`${String(e).padStart(10,`0`)} 00000 n \n`;return d+=`trailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${u}\n%%EOF\n`,c(r(d)),new Blob(a,{type:`application/pdf`})}function Ae(e){let t=e.slice(e.indexOf(`,`)+1),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}var j=`gantt-layout:`;function je(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(j+e);if(!t)return null;let n=JSON.parse(t),r=n.viewMode&&be.includes(n.viewMode)?n.viewMode:null;if(!r)return null;let i=typeof n.columnWidth==`number`&&isFinite(n.columnWidth)?n.columnWidth:null,a=typeof n.taskListWidth==`number`&&isFinite(n.taskListWidth)?n.taskListWidth:null,o=Array.isArray(n.collapsedIds)?n.collapsedIds.filter(e=>typeof e==`string`):void 0;return{viewMode:r,columnWidth:i,taskListCollapsed:!!n.taskListCollapsed,taskListWidth:a,collapsedIds:o}}catch{return null}}function Me(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(j+e,JSON.stringify(t))}catch{}}function M({tasks:e,viewMode:n,startDate:r,endDate:i,markers:a,onTaskClick:o,onTaskUpdate:s,onTaskDelete:l,onViewChange:f,onDependencyCreate:p,onBeforeDependencyCreate:m,onDependencyDelete:h,onTaskReorder:g,className:_,inlineEdit:v=!1,autoSchedule:y=!1,rescheduleOnConflict:ee=!1,criticalPathDefault:te=!1,workingCalendar:b,shiftSegments:x,showBaselines:ne=!0,readOnly:S=!1,mobileReadOnly:re=!1,groupBy:C,ungroupedLabel:w=`Ungrouped`,defaultCollapsedDepth:T,summaryExtent:ie=`children`,persistLayoutKey:ae,onLayoutChange:se,onRefresh:ce,refreshing:O=!1,dependencyTypes:le=!0,timeZone:ue,exportFileName:de,interactions:fe,onBeforeTaskUpdate:Se}){let j=t.useMemo(()=>Ce(ue),[ue]),M=t.useMemo(()=>j.delta===0?e:e.map(e=>({...e,start:j.to(e.start),end:j.to(e.end),baselineStart:e.baselineStart?j.to(e.baselineStart):e.baselineStart,baselineEnd:e.baselineEnd?j.to(e.baselineEnd):e.baselineEnd})),[e,j]),Ne=t.useMemo(()=>r&&j.delta!==0?j.to(r):r,[r,j]),N=t.useMemo(()=>i&&j.delta!==0?j.to(i):i,[i,j]),Pe=t.useMemo(()=>!a||j.delta===0?a:a.map(e=>({...e,date:j.to(new Date(e.date))})),[a,j]),{t:P,language:Fe}=pe(),F=Fe||void 0,[Ie,Le]=t.useState(()=>j.now()),Re=t.useRef(null),{width:ze}=(0,c.useResizeObserver)(Re),I=ze||(typeof window<`u`?window.innerWidth:1024),Be=I<640,L=S||re&&Be,Ve=fe?.move!==!1,He=fe?.resize!==!1,Ue=fe?.progress!==!1,We=fe?.link!==!1,R=t.useMemo(()=>{if(!(L||!s))return j.delta===0?s:(e,t)=>{let n={...t};n.start instanceof Date&&(n.start=j.from(n.start)),n.end instanceof Date&&(n.end=j.from(n.end)),s(e,n)}},[L,s,j]),Ge=L?void 0:l,z=L||!We?void 0:p,Ke=L||!We?void 0:h,qe=L?void 0:g,Je=!L&&v,Ye=!L&&y,Xe=!L&&ee,B=ye(I),Ze=ge(I),Qe=t.useRef(void 0);Qe.current===void 0&&(Qe.current=je(ae));let $e=Qe.current,[et,tt]=t.useState($e?$e.columnWidth:null),[nt,rt]=t.useState($e?$e.taskListWidth??null:null),[V,it]=t.useState(n&&be.includes(n)?n:$e?.viewMode??`day`);t.useEffect(()=>{n&&be.includes(n)&&it(n)},[n]);let at=t.useRef(null),ot=t.useRef(null),st=t.useRef(!0),[ct,lt]=t.useState($e?$e.taskListCollapsed:!1),ut=t.useRef(!1);t.useEffect(()=>{!ut.current&&Be&&(lt(!0),ut.current=!0)},[Be]);let dt=Math.max(160,I-200),H=ct?0:nt==null?_e(I):Math.max(160,Math.min(nt,dt)),ft=t.useMemo(()=>{if(et!=null||N||M.length===0)return null;let e=Ne?new Date(Ne):new Date(Math.min(...M.map(e=>e.start.getTime()))),t=new Date(Math.max(...M.map(e=>e.end.getTime())));Ne||e.setDate(e.getDate()-7),t.setDate(t.getDate()+14),e=we(e,V),t.setHours(23,59,59,999);let n=Math.max(1,(t.getTime()-e.getTime())/A),r=Math.max(0,I-H);if(r<=0)return null;let i=r/n*xe[V];if(i<=Ze)return null;let a=Math.min(i,r*.6);return a>Ze?a:null},[et,M,Ne,N,V,I,H,Ze]),pt=et??ft??Ze,mt=pt/xe[V],ht=ve(H),[gt,_t]=t.useState(null),[vt,yt]=t.useState({}),[bt,xt]=t.useState(null),U=t.useMemo(()=>{if(!C)return M;let e=new Set;for(let t of M){let n=t.parent!=null&&t.parent!==``?String(t.parent):null;n&&e.add(n)}let t=new Map;for(let n of M){if(e.has(String(n.id)))continue;let r=C(n),i=r?String(r.key):`__ungrouped__`,a=r?r.label:w,o=t.get(i);o||(o={key:i,label:a,items:[]},t.set(i,o)),o.items.push(n)}let n=[];for(let e of t.values()){let t=`__group__${e.key}`,r=e.items[0];n.push({id:t,title:e.label,start:r.start,end:r.end,progress:0,type:`summary`,parent:null,data:{__group:!0}});for(let r of e.items)n.push({...r,parent:t})}return n},[C,M,w]),St=t.useMemo(()=>{let e=new Set(U.map(e=>String(e.id))),t=new Map;for(let n of U){let r=n.parent!=null&&n.parent!==``?String(n.parent):null;if(r&&r!==String(n.id)&&e.has(r)){let e=t.get(r);e?e.push(n):t.set(r,[n])}}return t},[U]),Ct=t.useMemo(()=>{let e=new Map;for(let t of U)e.set(String(t.id),t);return e},[U]),wt=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of St.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[St]),[W,Tt]=t.useState(null),Et=t.useRef(null);t.useEffect(()=>{Et.current=W},[W]);let Dt=t.useRef(!1),Ot=t.useCallback(e=>{let t=V===`day`&&x&&x.bands.length>0&&x?Math.min(...x.bands.map(e=>e.durMs)):A,n=(e,t)=>Mn.current?Mn.current(e,t):Ee(e,t,`day`),r=new Date(e.originStart),i=new Date(e.originEnd);return e.mode===`move`?(r=n(e.originStart,e.unitDelta),i=new Date(e.originEnd.getTime()+(r.getTime()-e.originStart.getTime()))):e.mode===`resize-left`?(r=n(e.originStart,e.unitDelta),i.getTime()-r.getTime()<t&&(r=new Date(i.getTime()-t))):e.mode===`resize-right`&&(i=n(e.originEnd,e.unitDelta),i.getTime()-r.getTime()<t&&(i=new Date(r.getTime()+t))),{start:r,end:i}},[V,x]),kt=t.useRef(M);kt.current=M;let At=t.useRef([]),jt=t.useRef([]),[Mt,Nt]=t.useState(0),Pt=t.useCallback(e=>{if(!R)return;let t=e.filter(e=>!e.task.locked);(async()=>{let e=t;if(Se){let n=[];for(let e of t){let t;try{t=await Se(e.task,e.changes)!==!1}catch{t=!1}t&&n.push(e)}e=n}let n=[];for(let{task:t,changes:r}of e){let e={},i={},a=!1;for(let n of Object.keys(r)){let o=r[n],s=t[n],c=o instanceof Date&&s instanceof Date?o.getTime()===s.getTime():o===s;e[n]=s,i[n]=o,c||(a=!0)}R(t,r),a&&n.push({taskId:String(t.id),before:e,after:i})}n.length&&(At.current.push(n),jt.current=[],Nt(e=>e+1))})()},[R,Se]),[Ft,It]=t.useState(null),Lt=t.useCallback(e=>{if(!x)return e;let t=new Date(e);t.setHours(0,0,0,0);for(let n=-1;n<=1;n++){let r=t.getTime()+n*A+x.dayStartMin*6e4;for(let t of x.bands){if(r>=e)return r;r+=t.durMs}}return e},[x]),Rt=t.useMemo(()=>({summaryExtent:ie,snapStart:x?Lt:void 0}),[ie,x,Lt]),zt=t.useCallback(e=>{if(!Xe)return;let t=new Map;for(let{task:n,changes:r}of e)t.set(String(n.id),{start:r.start??n.start,end:r.end??n.end});let{changes:n}=D(kt.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),b,Rt),r=n.filter(e=>{let n=t.get(e.id);return!n||e.start.getTime()!==n.start.getTime()||e.end.getTime()!==n.end.getTime()});r.length&&It(r)},[Xe,b,Rt]),Bt=t.useCallback(()=>{if(!Ft)return;let e=Ft.map(e=>{let t=kt.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&Pt(e),It(null)},[Ft,Pt]),Vt=t.useCallback((e,t)=>{if(R)for(let n of e){let e=kt.current.find(e=>String(e.id)===n.taskId);e&&R(e,t===`undo`?n.before:n.after)}},[R]),Ht=t.useCallback(()=>{let e=At.current.pop();e&&(Vt(e,`undo`),jt.current.push(e),Nt(e=>e+1))},[Vt]),Ut=t.useCallback(()=>{let e=jt.current.pop();e&&(Vt(e,`redo`),At.current.push(e),Nt(e=>e+1))},[Vt]),{canUndo:Wt,canRedo:Gt}=t.useMemo(()=>({canUndo:At.current.length>0,canRedo:jt.current.length>0}),[Mt]);t.useEffect(()=>{if(!W)return;let e=V===`day`&&x&&x.bands.length>0&&x?mt*Math.min(...x.bands.map(e=>e.durMs))/A:mt,t=t=>{let n=Et.current;if(!n)return;let r=Math.round((t.clientX-n.originClientX)/Math.max(e,1));r!==n.unitDelta&&Tt({...n,unitDelta:r})},n=()=>{let e=Et.current;if(e){if(e.unitDelta!==0){let t=M.find(t=>t.id===e.taskId);if(t&&R){let{start:n,end:r}=Ot(e);if(e.group){let r=n.getTime()-e.originStart.getTime(),i=[t,...wt(t.id).filter(e=>!e.locked)].map(e=>({task:e,changes:{start:new Date(e.start.getTime()+r),end:new Date(e.end.getTime()+r)}}));Pt(i),zt(i)}else{let e=[{task:t,changes:{start:n,end:r}}];Pt(e),zt(e)}}Dt.current=!0,window.setTimeout(()=>{Dt.current=!1},0)}Tt(null)}};return window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n),()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n)}},[W,pt,mt,V,x,M,R,Ot,wt,Pt,zt]);let Kt=t.useCallback((e,t,n,r)=>{!R||e.data?.__group||e.locked||(n.stopPropagation(),n.preventDefault(),Tt({taskId:e.id,mode:t,group:r?.group??!1,originStart:new Date(r?.originStart??e.start),originEnd:new Date(r?.originEnd??e.end),originClientX:n.clientX,unitDelta:0}))},[R]),[qt,Jt]=t.useState(null),Yt=t.useRef(null);t.useEffect(()=>{Yt.current=qt},[qt]),t.useEffect(()=>{if(!qt)return;let e=e=>{let t=Yt.current;if(!t)return;let n=Math.min(100,Math.max(0,Math.round(t.originProgress+(e.clientX-t.originClientX)/Math.max(t.barWidth,1)*100)));n!==t.value&&Jt({...t,value:n})},t=()=>{let e=Yt.current;if(e){if(e.value!==e.originProgress){let t=M.find(t=>t.id===e.taskId);t&&R&&Pt([{task:t,changes:{progress:e.value}}]),Dt.current=!0,window.setTimeout(()=>{Dt.current=!1},0)}Jt(null)}};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[qt,M,R,Pt]);let Xt=t.useMemo(()=>{let e=[];for(let t of M)for(let n of t.dependencies??[]){let r=typeof n==`object`&&n?n.id:n;r==null||r===``||e.push([String(r),String(t.id)])}return e},[M]),Zt=t.useCallback((e,t)=>String(t.id)!==String(e)&&!t.locked&&t.type!==`group`&&!oe(Xt,e,t.id),[Xt]),Qt=t.useRef(null),[G,$t]=t.useState(null),en=t.useRef(null);t.useEffect(()=>{en.current=G},[G]),t.useEffect(()=>{if(!G)return;let e=e=>{let t=Qt.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;$t(e=>e&&{...e,x:n,y:r})},t=()=>{let e=en.current;if(e&&e.targetId!=null&&z){let t=M.find(t=>String(t.id)===String(e.sourceId)),n=M.find(t=>String(t.id)===String(e.targetId)),r=e.targetEnd??`start`,i=le?`${e.sourceEnd===`end`?`f`:`s`}${r===`end`?`f`:`s`}`:`fs`;t&&n&&Zt(e.sourceId,n)&&(m?.(t,n,i)??!0)&&z(t,n,i)}Dt.current=!0,window.setTimeout(()=>{Dt.current=!1},0),$t(null)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[G,M,z,m,Zt,le]);let[tn,nn]=t.useState(null),rn=t.useRef(null);t.useEffect(()=>{if(!tn)return;let e=e=>{rn.current&&e.target instanceof Node&&rn.current.contains(e.target)||nn(null)},t=e=>{e.key===`Escape`&&nn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[tn]);let[an,on]=t.useState(null),sn=t.useRef(null);t.useEffect(()=>{if(!an)return;let e=e=>{sn.current&&e.target instanceof Node&&sn.current.contains(e.target)||on(null)},t=e=>{e.key===`Escape`&&on(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[an]);let[cn,ln]=t.useState(null),[un,dn]=t.useState(``),fn=t.useRef(null);t.useEffect(()=>{if(!cn)return;let e=e=>{fn.current&&e.target instanceof Node&&fn.current.contains(e.target)||ln(null)},t=e=>{e.key===`Escape`&&ln(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[cn]);let[pn,mn]=t.useState(null),hn=!!(o||R||z||Ge),gn=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),mn(e.id),hn&&nn({x:t.clientX,y:t.clientY,taskId:e.id})},[hn]),_n=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),!(!z&&!Ke)&&on({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[z,Ke]),[vn,yn]=t.useState(()=>new Set($e?.collapsedIds??[])),bn=t.useCallback(e=>{yn(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),xn=t.useRef($e?.collapsedIds!=null);t.useEffect(()=>{if(xn.current||T==null||U.length===0)return;xn.current=!0;let e=new Map(U.map(e=>[String(e.id),e])),t=new Set;for(let n of U){let r=n.parent!=null&&n.parent!==``?String(n.parent):null;r&&r!==String(n.id)&&e.has(r)&&t.add(r)}let n=t=>{let n=0,r=new Set([String(t.id)]),i=t.parent!=null&&t.parent!==``?e.get(String(t.parent)):void 0;for(;i&&!r.has(String(i.id));)n+=1,r.add(String(i.id)),i=i.parent!=null&&i.parent!==``?e.get(String(i.parent)):void 0;return n},r=new Set;for(let e of U){let i=String(e.id);t.has(i)&&n(e)>=T&&r.add(i)}r.size&&yn(e=>e.size?e:r)},[T,U]);let K=t.useMemo(()=>{let e=new Set(U.map(e=>String(e.id))),t=new Map,n=[];for(let r of U){let i=r.parent!=null&&r.parent!==``?String(r.parent):null;if(i&&i!==String(r.id)&&e.has(i)){let e=t.get(i);e?e.push(r):t.set(i,[r])}else n.push(r)}let r=new Map,i=(e,n)=>{let a=String(e.id),o=r.get(a);if(o)return o;let s=t.get(a)??[],c;if(!s.length||n.has(a))c={start:e.start,end:e.end,progress:e.progress};else{n.add(a);let e=null,t=null,r=0,o=0;for(let a of s){let s=i(a,n);(!e||s.start<e)&&(e=s.start),(!t||s.end>t)&&(t=s.end);let c=Math.max(s.end.getTime()-s.start.getTime(),A);r+=c*s.progress,o+=c}n.delete(a),c={start:e,end:t,progress:o?r/o:0}}return r.set(a,c),c},a=[],o=new Set,s=e=>{for(let n of t.get(String(e.id))??[])o.has(String(n.id))||(o.add(String(n.id)),s(n))},c=(e,n)=>{let r=String(e.id);if(o.has(r))return;o.add(r);let l=t.get(r)??[],u=l.length>0,d=u||e.type===`summary`,f=u&&ie===`self`&&e.hasOwnDates!==!1,p=u&&!f?i(e,new Set):{start:e.start,end:e.end,progress:e.progress},m=!d&&(e.type===`milestone`||e.end.getTime()<=e.start.getTime());if(a.push({task:e,depth:n,hasChildren:u,isSummary:d,isMilestone:m,...p}),u)if(vn.has(r))s(e);else for(let e of l)c(e,n+1)};for(let e of n)c(e,0);for(let e of U)o.has(String(e.id))||c(e,0);return a},[U,vn,ie]),Sn=t.useCallback(e=>{if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;if((e.ctrlKey||e.metaKey)&&(e.key===`z`||e.key===`Z`)){e.preventDefault(),e.shiftKey?Ut():Ht();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),Ut();return}if(!K.length)return;let t=pn==null?-1:K.findIndex(e=>String(e.task.id)===String(pn));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?Math.min(K.length-1,t+1):Math.max(0,t<=0?0:t-1);mn(K[n].task.id);let r=Z.current;if(r){let e=n*B;e<r.scrollTop?r.scrollTop=e:e+B>r.scrollTop+r.clientHeight&&(r.scrollTop=e+B-r.clientHeight)}return}if(t<0)return;let n=K[t];e.key===`Enter`?(e.preventDefault(),o?.(n.task)):e.key===`Delete`||e.key===`Backspace`?Ge&&(e.preventDefault(),Ge(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&vn.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!vn.has(String(n.task.id)))&&(e.preventDefault(),bn(n.task.id))},[K,pn,o,Ge,vn,bn,B,Ht,Ut]),q=t.useMemo(()=>{let e=Ne?new Date(Ne):j.now(),t=N?new Date(N):j.now();return!Ne&&M.length>0&&(e=new Date(Math.min(...M.map(e=>e.start.getTime()))),e.setDate(e.getDate()-7)),!N&&M.length>0&&(t=new Date(Math.max(...M.map(e=>e.end.getTime()))),t.setDate(t.getDate()+14)),e=V===`day`&&x&&x.bands.length>0?k(e,x.dayStartMin):we(e,V),t.setHours(23,59,59,999),{start:e,end:t}},[Ne,N,M,V,x,j]),Cn=V===`day`&&!!x&&x.bands.length>0,wn=!Cn&&V===`day`&&!!b&&(!!b.skipWeekends||!!(b.holidays&&b.holidays.size)),Tn=t.useCallback(e=>{if(!b)return!0;if(b.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}if(b.holidays&&b.holidays.size){let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(b.holidays.has(t))return!1}return!0},[b]),J=t.useMemo(()=>{let e=[];if(Cn&&x){let t=new Date(q.start);for(;t<=q.end;)for(let n of x.bands){let r=n.durMs/A*mt;e.push({date:new Date(t),label:n.label,isWeekend:!1,width:r,realMs:n.durMs,bandColor:n.color}),t=new Date(t.getTime()+n.durMs)}return e}let t=new Date(q.start);for(;t<=q.end;){let n=Ee(t,1,V);if(wn&&!Tn(t)){t=n;continue}let r=(n.getTime()-t.getTime())/A*mt,i,a;V===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(F,{weekday:`narrow`})):i=V===`week`?t.toLocaleDateString(F,{month:`numeric`,day:`numeric`}):V===`month`?t.toLocaleDateString(F,{month:`short`}):V===`quarter`?`Q${Math.floor(t.getMonth()/3)+1}`:String(t.getFullYear()),e.push({date:new Date(t),label:i,sublabel:a,isWeekend:V===`day`&&(t.getDay()===0||t.getDay()===6),width:r}),t=n}return e},[q,V,mt,F,wn,Tn,Cn,x]),Y=t.useMemo(()=>{let e=Array(J.length+1),t=0;for(let n=0;n<J.length;n++)e[n]=t,t+=J[n].width;return e[J.length]=t,e},[J]),En=Y[Y.length-1],Dn=t.useMemo(()=>J.map(e=>e.date.getTime()),[J]),On=t.useMemo(()=>J.map(e=>e.realMs==null?Ee(e.date,1,V).getTime()-e.date.getTime():e.realMs),[J,V]),X=t.useCallback(e=>{let t=J.length;if(t===0)return 0;let n=e.getTime(),r=0,i=t-1,a=0;for(;r<=i;){let e=r+i>>1;Dn[e]<=n?(a=e,r=e+1):i=e-1}let o=On[a]||864e5,s=(n-Dn[a])/o;return(wn||Cn)&&(s=Math.max(0,Math.min(s,1))),Y[a]+s*J[a].width},[J,Dn,On,Y,wn,Cn]),kn=t.useCallback(e=>{let t=J.length;if(t===0)return new Date(q.start);let n=0,r=t-1,i=0;for(;n<=r;){let t=n+r>>1;Y[t]<=e?(i=t,n=t+1):r=t-1}let a=J[i].width||1,o=(e-Y[i])/a;return new Date(Dn[i]+o*(On[i]||864e5))},[J,Dn,On,Y,q]),An=t.useCallback(e=>{let t=Z.current;ot.current==null&&t&&t.clientWidth>0&&(ot.current=kn(t.scrollLeft)),at.current=ot.current,st.current=!0,it(e),f?.(e)},[f,kn]);t.useLayoutEffect(()=>{let e=at.current;if(e==null)return;at.current=null;let t=Z.current;if(!t||t.clientWidth===0)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.max(0,Math.min(Math.round(X(we(e,V))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[V,X]);let jn=t.useCallback((e,t)=>{let n=J.length;if(n===0||t===0)return new Date(e);let r=e.getTime(),i=0,a=n-1,o=0;for(;i<=a;){let e=i+a>>1;Dn[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-Dn[o];return new Date(Dn[s]+c)},[J,Dn]),Mn=t.useRef(null);Mn.current=wn||Cn?jn:null;let Nn=t.useMemo(()=>{let e=[];if(Cn&&x){let t=0;for(let n of J){let r=String(k(n.date,x.dayStartMin).getTime()),i=e[e.length-1];i&&i.key===r?i.width+=n.width:e.push({key:r,label:n.date.toLocaleDateString(F,{month:`short`,day:`numeric`}),width:n.width,offset:t}),t+=n.width}return e}let t=V===`year`?`decade`:V===`month`||V===`quarter`?`year`:`month`,n=0;for(let r of J){let i=r.date.getFullYear(),a=Math.floor(i/10)*10,o=t===`decade`?String(a):t===`year`?String(i):`${i}-${r.date.getMonth()}`,s=e[e.length-1];s&&s.key===o?s.width+=r.width:e.push({key:o,label:t===`decade`?`${a}s`:t===`year`?String(i):r.date.toLocaleDateString(F,{month:`short`,year:`numeric`}),width:r.width,offset:n}),n+=r.width}return e},[J,V,F,Cn,x]),Pn=t.useMemo(()=>(Pe??[]).map((e,t)=>{let n=e.date instanceof Date?e.date:new Date(e.date);return{index:t,label:e.label,color:e.color||`hsl(var(--primary))`,left:Math.round(X(n)),valid:!isNaN(n.getTime())&&n>=q.start&&n<=q.end}}).filter(e=>e.valid),[Pe,q,X]),Fn=t.useRef(null),In=t.useRef(null),Ln=t.useRef(null),Z=t.useRef(null);t.useEffect(()=>{let e=Z.current;if(!e)return;let t=()=>{st.current=!1},n=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),r=e=>{n.has(e.key)&&t()};return e.addEventListener(`wheel`,t,{passive:!0}),e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`pointerdown`,t,{passive:!0}),e.addEventListener(`keydown`,r),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`touchstart`,t),e.removeEventListener(`pointerdown`,t),e.removeEventListener(`keydown`,r)}},[]);let[Rn,zn]=t.useState(null),Bn=t.useRef([]),Vn=t.useRef(null),[Hn,Un]=t.useState({top:0,left:0}),[Wn,Gn]=t.useState({width:4e3,height:600}),Kn=t.useCallback(()=>{let e=Z.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;Gn(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{Kn();let e=Z.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(Kn);return t.observe(e),()=>t.disconnect()},[Kn]);let qn=t.useMemo(()=>Te(Y,Hn.left-240,Hn.left+Wn.width+240),[Y,Hn.left,Wn.width]),Jn=t.useMemo(()=>{let e=Nn.map(e=>e.offset);return e.push(En),e},[Nn,En]),Yn=t.useMemo(()=>Te(Jn,Hn.left-240,Hn.left+Wn.width+240),[Jn,Hn.left,Wn.width]),Q=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(Hn.top/B)-6),endIdx:Math.min(K.length,Math.ceil((Hn.top+Wn.height)/B)+6)}),[Hn.top,Wn.height,B,K.length]),Xn=K.length*B,[Zn,Qn]=t.useState(!1);t.useEffect(()=>{let e=()=>Qn(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let $n=t.useCallback(()=>{let e=Re.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),er=t.useRef(null),tr=t.useCallback(e=>{if(e.touches.length===2){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;er.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:pt}}},[pt]),nr=t.useCallback(e=>{if(e.touches.length!==2||!er.current)return;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.max(1,Math.sqrt(t*t+n*n))/er.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(er.current.baseColumn*r)));tt(i)},[]),rr=t.useCallback(()=>{er.current=null},[]),ir=t.useMemo(()=>{let e=j.now();return e<q.start||e>q.end?null:Math.round(X(e))},[q,X,j]),ar=t.useCallback(()=>{if(ir==null||!Z.current)return;let e=Math.max(0,ir-Z.current.clientWidth/2);Z.current.scrollTo({left:e,behavior:`smooth`})},[ir]),or=t.useRef(!1);t.useEffect(()=>{if(or.current||M.length===0)return;let e=window.requestAnimationFrame(()=>{let e=Z.current;if(!e||e.clientWidth===0)return;let t=ir;if(t==null){let e=new Date(Math.min(...M.map(e=>e.start.getTime())));t=Math.round(X(e))}e.scrollLeft=Math.max(0,t-e.clientWidth/2),or.current=!0});return()=>window.cancelAnimationFrame(e)},[M,ir,X]);let sr=t.useCallback((e,t=`left`)=>{let n=Z.current;if(!n||e<q.start||e>q.end)return!1;let r=Math.round(X(e)),i=t===`center`?r-n.clientWidth/2:r-24;return n.scrollTo({left:Math.max(0,i),behavior:`smooth`}),!0},[q,X]),cr=t.useCallback((e,t,n)=>{let r=Z.current;if(!r)return;let i=X(e),a=X(t),o=Math.max(0,r.scrollWidth-r.clientWidth),s=Math.min(96,r.clientWidth*.15),c=a-i<=r.clientWidth-s?(i+a)/2-r.clientWidth/2:i-s,l=Math.max(0,Math.min(c,o));Bn.current.forEach(e=>window.clearTimeout(e)),Bn.current=[],Vn.current?.(),Vn.current=null,zn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{zn(n),Bn.current.push(window.setTimeout(()=>zn(e=>e===n?null:e),1500))});Vn.current=()=>window.cancelAnimationFrame(e)},d=Math.abs(r.scrollLeft-l)>2;if(r.scrollTo({left:l,behavior:`smooth`}),!d){u();return}let f=`onscrollend`in r,p=!1,m=()=>{p||(p=!0,r.removeEventListener(`scrollend`,m),u())};r.addEventListener(`scrollend`,m),Bn.current.push(window.setTimeout(m,f?1500:500)),Vn.current=()=>r.removeEventListener(`scrollend`,m)},[X]);t.useEffect(()=>()=>{Bn.current.forEach(e=>window.clearTimeout(e)),Vn.current?.()},[]);let lr=t.useCallback(()=>sr(we(j.now(),`week`)),[sr,j]),ur=t.useCallback(()=>sr(we(j.now(),`month`)),[sr,j]),dr=t.useRef(null),fr=t.useRef(null),pr=t.useRef(null),mr=t.useRef(null),hr=t.useRef(null),gr=t.useRef(null),_r=t.useRef(null),vr=t.useRef(null),yr=t.useCallback(()=>{let e=Ln.current,t=dr.current,n=fr.current,r=pr.current;if(e&&t&&n&&r){let i=e.scrollWidth>e.clientWidth+1;if(t.style.display=i?`block`:`none`,i){let t=n.clientWidth;if(t>0){let n=Math.min(t,Math.max(40,e.clientWidth/e.scrollWidth*t)),i=e.scrollWidth-e.clientWidth,a=i>0?e.scrollLeft/i*(t-n):0;r.style.width=`${n}px`,r.style.transform=`translateX(${a}px)`}}}let i=hr.current,a=gr.current,o=_r.current;if(e&&i&&a&&o){let t=e.scrollHeight>e.clientHeight+1;if(i.style.display=t?`block`:`none`,t){let t=a.clientHeight;if(t>0){let n=Math.min(t,Math.max(40,e.clientHeight/e.scrollHeight*t)),r=e.scrollHeight-e.clientHeight,i=r>0?e.scrollTop/r*(t-n):0;o.style.height=`${n}px`,o.style.transform=`translateY(${i}px)`}}}},[]);t.useEffect(()=>{yr()});let br=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=Ln.current,n=fr.current,r=pr.current;if(!t||!n||!r)return;mr.current={startX:e.clientX,startLeft:t.scrollLeft};let i=n.clientWidth,a=r.getBoundingClientRect().width,o=t.scrollWidth-t.clientWidth,s=i-a>0?o/(i-a):0,c=e=>{let n=mr.current;n&&(t.scrollLeft=n.startLeft+(e.clientX-n.startX)*s)},l=()=>{mr.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},xr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=Ln.current,n=fr.current,r=pr.current;if(!t||!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect().width,o=t.scrollWidth-t.clientWidth,s=i.width-a;s<=0||(t.scrollLeft=Math.min(Math.max(e.clientX-i.x-a/2,0),s)/s*o)},Sr=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=Ln.current,n=gr.current,r=_r.current;if(!t||!n||!r)return;vr.current={startY:e.clientY,startTop:t.scrollTop};let i=n.clientHeight,a=r.getBoundingClientRect().height,o=t.scrollHeight-t.clientHeight,s=i-a>0?o/(i-a):0,c=e=>{let n=vr.current;n&&(t.scrollTop=n.startTop+(e.clientY-n.startY)*s)},l=()=>{vr.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},Cr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=Ln.current,n=gr.current,r=_r.current;if(!t||!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect().height,o=t.scrollHeight-t.clientHeight,s=i.height-a;s<=0||(t.scrollTop=Math.min(Math.max(e.clientY-i.y-a/2,0),s)/s*o)},wr=e=>{let t=e.currentTarget;!st.current&&t.clientWidth>0&&(ot.current=kn(t.scrollLeft)),Fn.current&&(Fn.current.scrollLeft=t.scrollLeft),yr(),In.current&&In.current.scrollTop!==t.scrollTop&&(In.current.scrollTop=t.scrollTop),Un(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),Kn()},Tr=e=>{let t=e.currentTarget,n=Z.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),Un(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},Er=(e,t)=>{let n=X(e),r=Cn&&x?mt*Math.min(...x.bands.map(e=>e.durMs))/A:mt;return{left:n,width:Math.max(X(t)-n,r,3)}},Dr=W?.group?W.taskId:null,Or=t.useMemo(()=>{if(Dr==null)return null;let e=new Set([String(Dr)]);for(let t of wt(Dr))t.locked||e.add(String(t.id));return e},[Dr,wt]),kr=t.useMemo(()=>{if(!W||W.group)return null;let e=new Set,t=new Set,n=Ct.get(String(W.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!Ct.has(r))break;t.add(r),e.add(r),n=Ct.get(r)}return e.size?e:null},[W,Ct]),Ar=e=>{if(W){if(Or?.has(String(e.task.id))){let t=Ot(W).start.getTime()-W.originStart.getTime();return Er(new Date(e.start.getTime()+t),new Date(e.end.getTime()+t))}if(W.taskId===e.task.id&&!W.group){let e=Ot(W);return Er(e.start,e.end)}if(e.isSummary&&kr?.has(String(e.task.id))&&!(ie===`self`&&e.task.hasOwnDates!==!1)){let t=Ot(W),n=String(W.taskId),r=null,i=null;for(let a of wt(e.task.id)){if((St.get(String(a.id))??[]).length!==0)continue;let e=String(a.id)===n?t.start:a.start,o=String(a.id)===n?t.end:a.end;(!r||e<r)&&(r=e),(!i||o>i)&&(i=o)}if(r&&i)return Er(r,i)}}return Er(e.start,e.end)},jr=t.useMemo(()=>{let e=new Map;K.forEach((t,n)=>e.set(String(t.task.id),n));let t=[];return K.forEach(({task:n},r)=>{for(let i of n.dependencies??[]){let a=typeof i==`object`&&!!i,o=a?i.id:i;if(o==null||o===``)continue;let s=e.get(String(o));if(s==null||s===r)continue;let c=a?i.type:void 0,l=c===`ss`||c===`ff`||c===`sf`?c:`fs`;t.push({key:`${String(o)}->${String(n.id)}:${l}`,sourceId:o,targetId:n.id,type:l,sourceIndex:s,targetIndex:r})}}),t},[K]),Mr=Math.max(2,Math.round(B/2)-14),Nr=B-Mr*2,Pr=Math.round(Nr/2),Fr=Math.max(Math.round(B*.4),12),Ir=Fr*Math.SQRT2/2,Lr=Nr,Rr=Mr,zr=Math.max(3,Math.round(B*.13)),Br=B-zr-1,Vr=`rgba(100, 116, 139, 0.35)`,Hr=`rgba(100, 116, 139, 0.6)`,Ur=e=>{let t=K[e.sourceIndex],n=K[e.targetIndex];if(!t||!n)return null;let r=Ar(t),i=Ar(n),a=e=>e.isSummary?Rr+Lr/2:B/2,o=e.sourceIndex*B+a(t),s=e.targetIndex*B+a(n),c=e.type===`fs`||e.type===`ff`,l=e.type===`ff`||e.type===`sf`,u=t.isMilestone?r.left+(c?Ir:-Ir):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?Ir:-Ir):l?i.left+i.width:i.left,f=u+(c?10:-10),p=d+(l?10:-10),m=Math.round,h=[`M ${m(u)} ${m(o)}`,`L ${m(f)} ${m(o)}`];if(l?f>=p:f<=p)h.push(`L ${m(f)} ${m(s)}`,`L ${m(d)} ${m(s)}`);else{let t=s>=o?(e.sourceIndex+1)*B:e.sourceIndex*B;h.push(`L ${m(f)} ${m(t)}`,`L ${m(p)} ${m(t)}`,`L ${m(p)} ${m(s)}`,`L ${m(d)} ${m(s)}`)}return h.join(` `)},Wr=W?.taskId??bt,[Gr,Kr]=t.useState(te),qr=t.useMemo(()=>Gr?E(M,b):null,[Gr,M,b]),Jr=t.useCallback(e=>qr?.criticalIds.has(String(e))??!1,[qr]),$=`#dc2626`,[Yr,Xr]=t.useState(null),[Zr,Qr]=t.useState(!1);t.useEffect(()=>{if(!Zr)return;let e=setTimeout(()=>Qr(!1),2500);return()=>clearTimeout(e)},[Zr]);let $r=t.useCallback(()=>{if(!R)return;let{changes:e,skippedLocked:t}=D(M,b,Rt);if(!e.length){Qr(!0);return}Xr({changes:e,skipped:t.length})},[M,R,b,Rt]),ei=t.useCallback(()=>{if(!Yr)return;let e=[];for(let t of Yr.changes){let n=M.find(e=>String(e.id)===t.id);n&&e.push({task:n,changes:{start:t.start,end:t.end}})}e.length&&Pt(e),Xr(null)},[Yr,M,Pt]),ti=t.useCallback(()=>{if(typeof document>`u`||!M.length)return null;let e=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]),t=Math.max(H,200),n=Math.ceil(t+En),r=Math.ceil(36+K.length*B),i=qr?.criticalEdges??null,a=[];a.push(`<rect x="0" y="0" width="${n}" height="${r}" fill="#ffffff"/>`),a.push(`<rect x="0" y="0" width="${n}" height="36" fill="#f8fafc"/>`),a.push(`<g transform="translate(${t},0)" font-family="sans-serif" font-size="10" fill="#475569">`),Nn.forEach(t=>{a.push(`<line x1="${t.offset.toFixed(1)}" y1="0" x2="${t.offset.toFixed(1)}" y2="36" stroke="#e2e8f0"/>`),a.push(`<text x="${(t.offset+t.width/2).toFixed(1)}" y="12" text-anchor="middle" font-weight="600">${e(t.label)}</text>`)}),J.forEach((t,n)=>{let i=Y[n];a.push(`<line x1="${i.toFixed(1)}" y1="18" x2="${i.toFixed(1)}" y2="${r}" stroke="#eef2f7"/>`),a.push(`<text x="${(i+t.width/2).toFixed(1)}" y="30" text-anchor="middle" fill="#1f2937">${e(t.label)}</text>`)}),a.push(`</g>`),a.push(`<line x1="0" y1="18" x2="${n}" y2="18" stroke="#e2e8f0"/>`),a.push(`<line x1="0" y1="36" x2="${n}" y2="36" stroke="#cbd5e1"/>`),a.push(`<line x1="${t}" y1="0" x2="${t}" y2="${r}" stroke="#cbd5e1"/>`),a.push(`<g transform="translate(0,36)" font-family="sans-serif" font-size="11" fill="#1f2937">`),K.forEach((n,r)=>{let i=r*B;a.push(`<line x1="0" y1="${(i+B).toFixed(1)}" x2="${t}" y2="${(i+B).toFixed(1)}" stroke="#f1f5f9"/>`);let o=8+n.depth*14,s=Math.max(4,Math.floor((t-o)/6.5)),c=n.task.title.length>s?n.task.title.slice(0,s-1)+`…`:n.task.title,l=n.isSummary?` font-weight="600"`:``;a.push(`<text x="${o}" y="${(i+B/2+4).toFixed(1)}"${l}>${e(c)}</text>`)}),a.push(`</g>`);let o=(e,t)=>{let n=t-12;if(n<=9)return``;let r=0,i=``;for(let t of e){let a=t.charCodeAt(0)>255?9:5.5;if(r+a>n)return i.length<e.length?`${i.slice(0,-1)}…`:i;r+=a,i+=t}return i};a.push(`<g transform="translate(${t},36)" font-family="sans-serif" font-size="9">`),K.forEach((t,n)=>{if(t.task.type===`group`)return;let r=n*B,{left:i,width:s}=Er(t.start,t.end),c=Jr(t.task.id),l=c?` stroke="${$}" stroke-width="2"`:``;if(ne&&t.task.baselineStart&&t.task.baselineEnd){let e=Er(t.task.baselineStart,t.task.baselineEnd);a.push(`<rect x="${e.left.toFixed(1)}" y="${(r+Br).toFixed(1)}" width="${Math.max(2,e.width).toFixed(1)}" height="${zr}" rx="1" fill="${Vr}" stroke="${Hr}"/>`)}if(t.isMilestone){let e=i,n=r+B/2,o=Fr/2,s=c?$:t.task.color||`#3b82f6`;a.push(`<polygon points="${e},${n-o} ${e+o},${n} ${e},${n+o} ${e-o},${n}" fill="${s}"/>`)}else if(t.isSummary){let n=t.task.color||`#64748b`;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Rr).toFixed(1)}" width="${s.toFixed(1)}" height="${Lr}" rx="3" fill="${n}"${l}/>`);let c=s*Math.min(100,Math.max(0,t.progress))/100;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Rr).toFixed(1)}" width="${c.toFixed(1)}" height="${Lr}" rx="3" fill="rgba(0,0,0,0.2)"/>`);let u=o(t.task.title,s);u&&a.push(`<text x="${(i+6).toFixed(1)}" y="${(r+B/2+3).toFixed(1)}" fill="#ffffff" font-weight="500">${e(u)}</text>`)}else{let n=t.task.color||`#3b82f6`;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Mr).toFixed(1)}" width="${s.toFixed(1)}" height="${Nr}" rx="3" fill="${n}"${l}/>`);let c=s*Math.min(100,Math.max(0,t.progress))/100;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Mr).toFixed(1)}" width="${c.toFixed(1)}" height="${Nr}" rx="3" fill="rgba(0,0,0,0.18)"/>`);let u=o(t.task.title,s);u?a.push(`<text x="${(i+6).toFixed(1)}" y="${(r+B/2+3).toFixed(1)}" fill="#ffffff" font-weight="500">${e(u)}</text>`):s>=24&&a.push(`<text x="${(i+s/2).toFixed(1)}" y="${(r+B/2+3).toFixed(1)}" text-anchor="middle" fill="#ffffff">${Math.round(t.progress)}%</text>`)}}),jr.forEach(e=>{let t=Ur(e);if(!t)return;let n=i?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?$:`#94a3b8`;a.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),ir!=null&&a.push(`<line x1="${ir.toFixed(1)}" y1="0" x2="${ir.toFixed(1)}" y2="${K.length*B}" stroke="#ef4444" stroke-width="1.5"/>`);let s=K.length*B;return Pn.forEach(t=>{let n=/var\(/.test(t.color)?`#6366f1`:t.color;if(a.push(`<line x1="${t.left.toFixed(1)}" y1="0" x2="${t.left.toFixed(1)}" y2="${s}" stroke="${e(n)}" stroke-width="1.5"/>`),t.label){let r=t.label.length*6+8;a.push(`<rect x="${(t.left-r/2).toFixed(1)}" y="0" width="${r}" height="14" rx="2" fill="${e(n)}"/>`),a.push(`<text x="${t.left.toFixed(1)}" y="10" text-anchor="middle" font-size="9" font-weight="600" fill="#ffffff">${e(t.label)}</text>`)}}),a.push(`</g>`),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${n} ${r}">${a.join(``)}</svg>`,W:n,H:r}},[M,K,jr,Ur,Er,Jr,qr,J,Y,En,H,B,Mr,Nr,Rr,Lr,Fr,ir,V,ne,Br,zr,Vr,Hr,Pn,Nn]),ni=t.useCallback(()=>{let e=(de??``).replace(/[\\/:*?"<>|\s]+/g,` `).trim()||`gantt`,t=new Date,n=e=>String(e).padStart(2,`0`);return`${e}-${`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}-${n(t.getHours())}${n(t.getMinutes())}`}`},[de]),ri=t.useCallback(async()=>{let e=ti();if(!e)return;let t=await De(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&Oe(e,`${ni()}.png`)},`image/png`)},[ti,ni]),ii=t.useCallback(async()=>{let e=ti();if(!e)return;let t=await De(e.svg,e.W,e.H);t&&Oe(ke(Ae(t.toDataURL(`image/jpeg`,.92)),t.width,t.height),`${ni()}.pdf`)},[ti,ni]),[ai,oi]=t.useState(!1),si=t.useCallback(()=>{let e={viewMode:V,columnWidth:et,taskListCollapsed:ct,taskListWidth:nt,collapsedIds:Array.from(vn)};ae&&Me(ae,e),se?.(e),oi(!0)},[V,et,ct,nt,vn,ae,se]);return t.useEffect(()=>{if(!ai)return;let e=setTimeout(()=>oi(!1),1500);return()=>clearTimeout(e)},[ai]),(0,d.jsxs)(`div`,{ref:Re,className:(0,c.cn)(`flex flex-col h-full bg-background overflow-hidden min-w-0`,_),"data-readonly":L?`true`:void 0,"data-mobile-readonly":re&&Be?`true`:void 0,children:[(0,d.jsx)(`style`,{children:`
|
|
15
|
+
`;for(let e of o)d+=`${String(e).padStart(10,`0`)} 00000 n \n`;return d+=`trailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${u}\n%%EOF\n`,c(r(d)),new Blob(a,{type:`application/pdf`})}function ke(e){let t=e.slice(e.indexOf(`,`)+1),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}var M=`gantt-layout:`;function Ae(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(M+e);if(!t)return null;let n=JSON.parse(t),r=n.viewMode&&ye.includes(n.viewMode)?n.viewMode:null;if(!r)return null;let i=typeof n.columnWidth==`number`&&isFinite(n.columnWidth)?n.columnWidth:null,a=typeof n.taskListWidth==`number`&&isFinite(n.taskListWidth)?n.taskListWidth:null,o=Array.isArray(n.collapsedIds)?n.collapsedIds.filter(e=>typeof e==`string`):void 0;return{viewMode:r,columnWidth:i,taskListCollapsed:!!n.taskListCollapsed,taskListWidth:a,collapsedIds:o}}catch{return null}}function je(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(M+e,JSON.stringify(t))}catch{}}function N({tasks:e,viewMode:n,startDate:r,endDate:i,markers:a,onTaskClick:o,onTaskUpdate:s,onTaskDelete:l,onViewChange:f,onDependencyCreate:p,onBeforeDependencyCreate:m,onDependencyDelete:h,onTaskReorder:g,className:_,inlineEdit:v=!1,autoSchedule:y=!1,rescheduleOnConflict:ee=!1,criticalPathDefault:te=!1,workingCalendar:b,shiftSegments:x,showBaselines:ne=!0,readOnly:S=!1,mobileReadOnly:C=!1,groupBy:w,ungroupedLabel:T=`Ungrouped`,defaultCollapsedDepth:E,summaryExtent:re=`children`,persistLayoutKey:ie,onLayoutChange:oe,onRefresh:se,refreshing:k=!1,dependencyTypes:ce=!0,timeZone:le,exportFileName:ue,interactions:de,onBeforeTaskUpdate:xe}){let M=t.useMemo(()=>Se(le),[le]),N=t.useMemo(()=>M.delta===0?e:e.map(e=>({...e,start:M.to(e.start),end:M.to(e.end),baselineStart:e.baselineStart?M.to(e.baselineStart):e.baselineStart,baselineEnd:e.baselineEnd?M.to(e.baselineEnd):e.baselineEnd})),[e,M]),Me=t.useMemo(()=>r&&M.delta!==0?M.to(r):r,[r,M]),P=t.useMemo(()=>i&&M.delta!==0?M.to(i):i,[i,M]),Ne=t.useMemo(()=>!a||M.delta===0?a:a.map(e=>({...e,date:M.to(new Date(e.date))})),[a,M]),{t:F,language:Pe}=fe(),I=Pe||void 0,[Fe,Ie]=t.useState(()=>M.now()),Le=t.useRef(null),{width:Re}=(0,c.useResizeObserver)(Le),L=Re||(typeof window<`u`?window.innerWidth:1024),ze=L<640,R=S||C&&ze,Be=de?.move!==!1,Ve=de?.resize!==!1,He=de?.progress!==!1,Ue=de?.link!==!1,z=t.useMemo(()=>{if(!(R||!s))return M.delta===0?s:(e,t)=>{let n={...t};n.start instanceof Date&&(n.start=M.from(n.start)),n.end instanceof Date&&(n.end=M.from(n.end)),s(e,n)}},[R,s,M]),We=R?void 0:l,B=R||!Ue?void 0:p,Ge=R||!Ue?void 0:h,Ke=R?void 0:g,qe=!R&&v,Je=!R&&y,Ye=!R&&ee,V=ve(L),Xe=he(L),Ze=t.useRef(void 0);Ze.current===void 0&&(Ze.current=Ae(ie));let Qe=Ze.current,[$e,et]=t.useState(Qe?Qe.columnWidth:null),[tt,nt]=t.useState(Qe?Qe.taskListWidth??null:null),[H,rt]=t.useState(n&&ye.includes(n)?n:Qe?.viewMode??`day`);t.useEffect(()=>{n&&ye.includes(n)&&rt(n)},[n]);let it=t.useRef(null),at=t.useRef(null),ot=t.useRef(!0),[st,ct]=t.useState(Qe?Qe.taskListCollapsed:!1),lt=t.useRef(!1);t.useEffect(()=>{!lt.current&&ze&&(ct(!0),lt.current=!0)},[ze]);let ut=Math.max(160,L-200),dt=st?0:tt==null?ge(L):Math.max(160,Math.min(tt,ut)),ft=t.useMemo(()=>{if($e!=null||P||N.length===0)return null;let e=Me?new Date(Me):new Date(Math.min(...N.map(e=>e.start.getTime()))),t=new Date(Math.max(...N.map(e=>e.end.getTime())));Me||e.setDate(e.getDate()-7),t.setDate(t.getDate()+14),e=Ce(e,H),t.setHours(23,59,59,999);let n=Math.max(1,(t.getTime()-e.getTime())/j),r=Math.max(0,L-dt);if(r<=0)return null;let i=r/n*be[H];if(i<=Xe)return null;let a=Math.min(i,r*.6);return a>Xe?a:null},[$e,N,Me,P,H,L,dt,Xe]),pt=$e??ft??Xe,mt=pt/be[H],ht=_e(dt),[gt,_t]=t.useState(null),[vt,yt]=t.useState({}),[bt,xt]=t.useState(null),U=t.useMemo(()=>{if(!w)return N;let e=new Set;for(let t of N){let n=t.parent!=null&&t.parent!==``?String(t.parent):null;n&&e.add(n)}let t=new Map;for(let n of N){if(e.has(String(n.id)))continue;let r=w(n),i=r?String(r.key):`__ungrouped__`,a=r?r.label:T,o=t.get(i);o||(o={key:i,label:a,items:[]},t.set(i,o)),o.items.push(n)}let n=[];for(let e of t.values()){let t=`__group__${e.key}`,r=e.items[0];n.push({id:t,title:e.label,start:r.start,end:r.end,progress:0,type:`summary`,parent:null,data:{__group:!0}});for(let r of e.items)n.push({...r,parent:t})}return n},[w,N,T]),St=t.useMemo(()=>{let e=new Set(U.map(e=>String(e.id))),t=new Map;for(let n of U){let r=n.parent!=null&&n.parent!==``?String(n.parent):null;if(r&&r!==String(n.id)&&e.has(r)){let e=t.get(r);e?e.push(n):t.set(r,[n])}}return t},[U]),Ct=t.useMemo(()=>{let e=new Map;for(let t of U)e.set(String(t.id),t);return e},[U]),wt=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of St.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[St]),[W,Tt]=t.useState(null),Et=t.useRef(null);t.useEffect(()=>{Et.current=W},[W]);let Dt=t.useRef(!1),Ot=t.useCallback(e=>{let t=H===`day`&&x&&x.bands.length>0&&x?Math.min(...x.bands.map(e=>e.durMs)):j,n=(e,t)=>Mn.current?Mn.current(e,t):Te(e,t,`day`),r=new Date(e.originStart),i=new Date(e.originEnd);return e.mode===`move`?(r=n(e.originStart,e.unitDelta),i=new Date(e.originEnd.getTime()+(r.getTime()-e.originStart.getTime()))):e.mode===`resize-left`?(r=n(e.originStart,e.unitDelta),i.getTime()-r.getTime()<t&&(r=new Date(i.getTime()-t))):e.mode===`resize-right`&&(i=n(e.originEnd,e.unitDelta),i.getTime()-r.getTime()<t&&(i=new Date(r.getTime()+t))),{start:r,end:i}},[H,x]),kt=t.useRef(N);kt.current=N;let At=t.useRef([]),jt=t.useRef([]),[Mt,Nt]=t.useState(0),Pt=t.useCallback(e=>{if(!z)return;let t=e.filter(e=>!e.task.locked);(async()=>{let e=t;if(xe){let n=[];for(let e of t){let t;try{t=await xe(e.task,e.changes)!==!1}catch{t=!1}t&&n.push(e)}e=n}let n=[];for(let{task:t,changes:r}of e){let e={},i={},a=!1;for(let n of Object.keys(r)){let o=r[n],s=t[n],c=o instanceof Date&&s instanceof Date?o.getTime()===s.getTime():o===s;e[n]=s,i[n]=o,c||(a=!0)}z(t,r),a&&n.push({taskId:String(t.id),before:e,after:i})}n.length&&(At.current.push(n),jt.current=[],Nt(e=>e+1))})()},[z,xe]),[Ft,It]=t.useState(null),Lt=t.useCallback(e=>{if(!x)return e;let t=new Date(e);t.setHours(0,0,0,0);for(let n=-1;n<=1;n++){let r=t.getTime()+n*j+x.dayStartMin*6e4;for(let t of x.bands){if(r>=e)return r;r+=t.durMs}}return e},[x]),Rt=t.useMemo(()=>({summaryExtent:re,snapStart:x?Lt:void 0}),[re,x,Lt]),zt=t.useCallback(e=>{if(!Ye)return;let t=new Map;for(let{task:n,changes:r}of e)t.set(String(n.id),{start:r.start??n.start,end:r.end??n.end});let{changes:n}=O(kt.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),b,Rt),r=n.filter(e=>{let n=t.get(e.id);return!n||e.start.getTime()!==n.start.getTime()||e.end.getTime()!==n.end.getTime()});r.length&&It(r)},[Ye,b,Rt]),Bt=t.useCallback(()=>{if(!Ft)return;let e=Ft.map(e=>{let t=kt.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&Pt(e),It(null)},[Ft,Pt]),Vt=t.useCallback((e,t)=>{if(z)for(let n of e){let e=kt.current.find(e=>String(e.id)===n.taskId);e&&z(e,t===`undo`?n.before:n.after)}},[z]),Ht=t.useCallback(()=>{let e=At.current.pop();e&&(Vt(e,`undo`),jt.current.push(e),Nt(e=>e+1))},[Vt]),Ut=t.useCallback(()=>{let e=jt.current.pop();e&&(Vt(e,`redo`),At.current.push(e),Nt(e=>e+1))},[Vt]),{canUndo:Wt,canRedo:Gt}=t.useMemo(()=>({canUndo:At.current.length>0,canRedo:jt.current.length>0}),[Mt]);t.useEffect(()=>{if(!W)return;let e=H===`day`&&x&&x.bands.length>0&&x?mt*Math.min(...x.bands.map(e=>e.durMs))/j:mt,t=t=>{let n=Et.current;if(!n)return;let r=Math.round((t.clientX-n.originClientX)/Math.max(e,1));r!==n.unitDelta&&Tt({...n,unitDelta:r})},n=()=>{let e=Et.current;if(e){if(e.unitDelta!==0){let t=N.find(t=>t.id===e.taskId);if(t&&z){let{start:n,end:r}=Ot(e);if(e.group){let r=n.getTime()-e.originStart.getTime(),i=[t,...wt(t.id).filter(e=>!e.locked)].map(e=>({task:e,changes:{start:new Date(e.start.getTime()+r),end:new Date(e.end.getTime()+r)}}));Pt(i),zt(i)}else{let e=[{task:t,changes:{start:n,end:r}}];Pt(e),zt(e)}}Dt.current=!0,window.setTimeout(()=>{Dt.current=!1},0)}Tt(null)}};return window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n),()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n)}},[W,pt,mt,H,x,N,z,Ot,wt,Pt,zt]);let Kt=t.useCallback((e,t,n,r)=>{!z||e.data?.__group||e.locked||(n.stopPropagation(),n.preventDefault(),Tt({taskId:e.id,mode:t,group:r?.group??!1,originStart:new Date(r?.originStart??e.start),originEnd:new Date(r?.originEnd??e.end),originClientX:n.clientX,unitDelta:0}))},[z]),[qt,Jt]=t.useState(null),Yt=t.useRef(null);t.useEffect(()=>{Yt.current=qt},[qt]),t.useEffect(()=>{if(!qt)return;let e=e=>{let t=Yt.current;if(!t)return;let n=Math.min(100,Math.max(0,Math.round(t.originProgress+(e.clientX-t.originClientX)/Math.max(t.barWidth,1)*100)));n!==t.value&&Jt({...t,value:n})},t=()=>{let e=Yt.current;if(e){if(e.value!==e.originProgress){let t=N.find(t=>t.id===e.taskId);t&&z&&Pt([{task:t,changes:{progress:e.value}}]),Dt.current=!0,window.setTimeout(()=>{Dt.current=!1},0)}Jt(null)}};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[qt,N,z,Pt]);let Xt=t.useMemo(()=>{let e=[];for(let t of N)for(let n of t.dependencies??[]){let r=typeof n==`object`&&n?n.id:n;r!=null&&r!==``&&e.push([String(r),String(t.id)])}return e},[N]),Zt=t.useCallback((e,t)=>String(t.id)!==String(e)&&!t.locked&&t.type!==`group`&&!ae(Xt,e,t.id),[Xt]),Qt=t.useRef(null),[G,$t]=t.useState(null),en=t.useRef(null);t.useEffect(()=>{en.current=G},[G]),t.useEffect(()=>{if(!G)return;let e=e=>{let t=Qt.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;$t(e=>e&&{...e,x:n,y:r})},t=()=>{let e=en.current;if(e&&e.targetId!=null&&B){let t=N.find(t=>String(t.id)===String(e.sourceId)),n=N.find(t=>String(t.id)===String(e.targetId)),r=e.targetEnd??`start`,i=ce?`${e.sourceEnd===`end`?`f`:`s`}${r===`end`?`f`:`s`}`:`fs`;t&&n&&Zt(e.sourceId,n)&&(m?.(t,n,i)??!0)&&B(t,n,i)}Dt.current=!0,window.setTimeout(()=>{Dt.current=!1},0),$t(null)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[G,N,B,m,Zt,ce]);let[tn,nn]=t.useState(null),rn=t.useRef(null);t.useEffect(()=>{if(!tn)return;let e=e=>{rn.current&&e.target instanceof Node&&rn.current.contains(e.target)||nn(null)},t=e=>{e.key===`Escape`&&nn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[tn]);let[an,on]=t.useState(null),sn=t.useRef(null);t.useEffect(()=>{if(!an)return;let e=e=>{sn.current&&e.target instanceof Node&&sn.current.contains(e.target)||on(null)},t=e=>{e.key===`Escape`&&on(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[an]);let[cn,ln]=t.useState(null),[un,dn]=t.useState(``),fn=t.useRef(null);t.useEffect(()=>{if(!cn)return;let e=e=>{fn.current&&e.target instanceof Node&&fn.current.contains(e.target)||ln(null)},t=e=>{e.key===`Escape`&&ln(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[cn]);let[pn,mn]=t.useState(null),hn=!!(o||z||B||We),gn=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),mn(e.id),hn&&nn({x:t.clientX,y:t.clientY,taskId:e.id})},[hn]),_n=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),!(!B&&!Ge)&&on({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[B,Ge]),[vn,yn]=t.useState(()=>new Set(Qe?.collapsedIds??[])),bn=t.useCallback(e=>{yn(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),xn=t.useRef(Qe?.collapsedIds!=null);t.useEffect(()=>{if(xn.current||E==null||U.length===0)return;xn.current=!0;let e=new Map(U.map(e=>[String(e.id),e])),t=new Set;for(let n of U){let r=n.parent!=null&&n.parent!==``?String(n.parent):null;r&&r!==String(n.id)&&e.has(r)&&t.add(r)}let n=t=>{let n=0,r=new Set([String(t.id)]),i=t.parent!=null&&t.parent!==``?e.get(String(t.parent)):void 0;for(;i&&!r.has(String(i.id));)n+=1,r.add(String(i.id)),i=i.parent!=null&&i.parent!==``?e.get(String(i.parent)):void 0;return n},r=new Set;for(let e of U){let i=String(e.id);t.has(i)&&n(e)>=E&&r.add(i)}r.size&&yn(e=>e.size?e:r)},[E,U]);let K=t.useMemo(()=>{let e=new Set(U.map(e=>String(e.id))),t=new Map,n=[];for(let r of U){let i=r.parent!=null&&r.parent!==``?String(r.parent):null;if(i&&i!==String(r.id)&&e.has(i)){let e=t.get(i);e?e.push(r):t.set(i,[r])}else n.push(r)}let r=new Map,i=(e,n)=>{let a=String(e.id),o=r.get(a);if(o)return o;let s=t.get(a)??[],c;if(!s.length||n.has(a))c={start:e.start,end:e.end,progress:e.progress};else{n.add(a);let e=null,t=null,r=0,o=0;for(let a of s){let s=i(a,n);(!e||s.start<e)&&(e=s.start),(!t||s.end>t)&&(t=s.end);let c=Math.max(s.end.getTime()-s.start.getTime(),j);r+=c*s.progress,o+=c}n.delete(a),c={start:e,end:t,progress:o?r/o:0}}return r.set(a,c),c},a=[],o=new Set,s=e=>{for(let n of t.get(String(e.id))??[])o.has(String(n.id))||(o.add(String(n.id)),s(n))},c=(e,n)=>{let r=String(e.id);if(o.has(r))return;o.add(r);let l=t.get(r)??[],u=l.length>0,d=u||e.type===`summary`,f=u&&re===`self`&&e.hasOwnDates!==!1,p=u&&!f?i(e,new Set):{start:e.start,end:e.end,progress:e.progress},m=!d&&(e.type===`milestone`||e.end.getTime()<=e.start.getTime());if(a.push({task:e,depth:n,hasChildren:u,isSummary:d,isMilestone:m,...p}),u)if(vn.has(r))s(e);else for(let e of l)c(e,n+1)};for(let e of n)c(e,0);for(let e of U)o.has(String(e.id))||c(e,0);return a},[U,vn,re]),Sn=t.useCallback(e=>{if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;if((e.ctrlKey||e.metaKey)&&(e.key===`z`||e.key===`Z`)){e.preventDefault(),e.shiftKey?Ut():Ht();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),Ut();return}if(!K.length)return;let t=pn==null?-1:K.findIndex(e=>String(e.task.id)===String(pn));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?Math.min(K.length-1,t+1):Math.max(0,t<=0?0:t-1);mn(K[n].task.id);let r=Z.current;if(r){let e=n*V;e<r.scrollTop?r.scrollTop=e:e+V>r.scrollTop+r.clientHeight&&(r.scrollTop=e+V-r.clientHeight)}return}if(t<0)return;let n=K[t];e.key===`Enter`?(e.preventDefault(),o?.(n.task)):e.key===`Delete`||e.key===`Backspace`?We&&(e.preventDefault(),We(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&vn.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!vn.has(String(n.task.id)))&&(e.preventDefault(),bn(n.task.id))},[K,pn,o,We,vn,bn,V,Ht,Ut]),q=t.useMemo(()=>{let e=Me?new Date(Me):M.now(),t=P?new Date(P):M.now();return!Me&&N.length>0&&(e=new Date(Math.min(...N.map(e=>e.start.getTime()))),e.setDate(e.getDate()-7)),!P&&N.length>0&&(t=new Date(Math.max(...N.map(e=>e.end.getTime()))),t.setDate(t.getDate()+14)),e=H===`day`&&x&&x.bands.length>0?A(e,x.dayStartMin):Ce(e,H),t.setHours(23,59,59,999),{start:e,end:t}},[Me,P,N,H,x,M]),Cn=H===`day`&&!!x&&x.bands.length>0,wn=!Cn&&H===`day`&&!!b&&(!!b.skipWeekends||!!(b.holidays&&b.holidays.size)),Tn=t.useCallback(e=>{if(!b)return!0;if(b.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}if(b.holidays&&b.holidays.size){let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(b.holidays.has(t))return!1}return!0},[b]),J=t.useMemo(()=>{let e=[];if(Cn&&x){let t=new Date(q.start);for(;t<=q.end;)for(let n of x.bands){let r=n.durMs/j*mt;e.push({date:new Date(t),label:n.label,isWeekend:!1,width:r,realMs:n.durMs,bandColor:n.color}),t=new Date(t.getTime()+n.durMs)}return e}let t=new Date(q.start);for(;t<=q.end;){let n=Te(t,1,H);if(wn&&!Tn(t)){t=n;continue}let r=(n.getTime()-t.getTime())/j*mt,i,a;H===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(I,{weekday:`narrow`})):i=H===`week`?t.toLocaleDateString(I,{month:`numeric`,day:`numeric`}):H===`month`?t.toLocaleDateString(I,{month:`short`}):H===`quarter`?`Q${Math.floor(t.getMonth()/3)+1}`:String(t.getFullYear()),e.push({date:new Date(t),label:i,sublabel:a,isWeekend:H===`day`&&(t.getDay()===0||t.getDay()===6),width:r}),t=n}return e},[q,H,mt,I,wn,Tn,Cn,x]),Y=t.useMemo(()=>{let e=Array(J.length+1),t=0;for(let n=0;n<J.length;n++)e[n]=t,t+=J[n].width;return e[J.length]=t,e},[J]),En=Y[Y.length-1],Dn=t.useMemo(()=>J.map(e=>e.date.getTime()),[J]),On=t.useMemo(()=>J.map(e=>e.realMs==null?Te(e.date,1,H).getTime()-e.date.getTime():e.realMs),[J,H]),X=t.useCallback(e=>{let t=J.length;if(t===0)return 0;let n=e.getTime(),r=0,i=t-1,a=0;for(;r<=i;){let e=r+i>>1;Dn[e]<=n?(a=e,r=e+1):i=e-1}let o=On[a]||864e5,s=(n-Dn[a])/o;return(wn||Cn)&&(s=Math.max(0,Math.min(s,1))),Y[a]+s*J[a].width},[J,Dn,On,Y,wn,Cn]),kn=t.useCallback(e=>{let t=J.length;if(t===0)return new Date(q.start);let n=0,r=t-1,i=0;for(;n<=r;){let t=n+r>>1;Y[t]<=e?(i=t,n=t+1):r=t-1}let a=J[i].width||1,o=(e-Y[i])/a;return new Date(Dn[i]+o*(On[i]||864e5))},[J,Dn,On,Y,q]),An=t.useCallback(e=>{let t=Z.current;at.current==null&&t&&t.clientWidth>0&&(at.current=kn(t.scrollLeft)),it.current=at.current,ot.current=!0,rt(e),f?.(e)},[f,kn]);t.useLayoutEffect(()=>{let e=it.current;if(e==null)return;it.current=null;let t=Z.current;if(!t||t.clientWidth===0)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.max(0,Math.min(Math.round(X(Ce(e,H))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[H,X]);let jn=t.useCallback((e,t)=>{let n=J.length;if(n===0||t===0)return new Date(e);let r=e.getTime(),i=0,a=n-1,o=0;for(;i<=a;){let e=i+a>>1;Dn[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-Dn[o];return new Date(Dn[s]+c)},[J,Dn]),Mn=t.useRef(null);Mn.current=wn||Cn?jn:null;let Nn=t.useMemo(()=>{let e=[];if(Cn&&x){let t=0;for(let n of J){let r=String(A(n.date,x.dayStartMin).getTime()),i=e[e.length-1];i&&i.key===r?i.width+=n.width:e.push({key:r,label:n.date.toLocaleDateString(I,{month:`short`,day:`numeric`}),width:n.width,offset:t}),t+=n.width}return e}let t=H===`year`?`decade`:H===`month`||H===`quarter`?`year`:`month`,n=0;for(let r of J){let i=r.date.getFullYear(),a=Math.floor(i/10)*10,o=t===`decade`?String(a):t===`year`?String(i):`${i}-${r.date.getMonth()}`,s=e[e.length-1];s&&s.key===o?s.width+=r.width:e.push({key:o,label:t===`decade`?`${a}s`:t===`year`?String(i):r.date.toLocaleDateString(I,{month:`short`,year:`numeric`}),width:r.width,offset:n}),n+=r.width}return e},[J,H,I,Cn,x]),Pn=t.useMemo(()=>(Ne??[]).map((e,t)=>{let n=e.date instanceof Date?e.date:new Date(e.date);return{index:t,label:e.label,color:e.color||`hsl(var(--primary))`,left:Math.round(X(n)),valid:!isNaN(n.getTime())&&n>=q.start&&n<=q.end}}).filter(e=>e.valid),[Ne,q,X]),Fn=t.useRef(null),In=t.useRef(null),Ln=t.useRef(null),Z=t.useRef(null);t.useEffect(()=>{let e=Z.current;if(!e)return;let t=()=>{ot.current=!1},n=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),r=e=>{n.has(e.key)&&t()};return e.addEventListener(`wheel`,t,{passive:!0}),e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`pointerdown`,t,{passive:!0}),e.addEventListener(`keydown`,r),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`touchstart`,t),e.removeEventListener(`pointerdown`,t),e.removeEventListener(`keydown`,r)}},[]);let[Rn,zn]=t.useState(null),Bn=t.useRef([]),Vn=t.useRef(null),[Hn,Un]=t.useState({top:0,left:0}),[Wn,Gn]=t.useState({width:4e3,height:600}),Kn=t.useCallback(()=>{let e=Z.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;Gn(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{Kn();let e=Z.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(Kn);return t.observe(e),()=>t.disconnect()},[Kn]);let qn=t.useMemo(()=>we(Y,Hn.left-240,Hn.left+Wn.width+240),[Y,Hn.left,Wn.width]),Jn=t.useMemo(()=>{let e=Nn.map(e=>e.offset);return e.push(En),e},[Nn,En]),Yn=t.useMemo(()=>we(Jn,Hn.left-240,Hn.left+Wn.width+240),[Jn,Hn.left,Wn.width]),Q=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(Hn.top/V)-6),endIdx:Math.min(K.length,Math.ceil((Hn.top+Wn.height)/V)+6)}),[Hn.top,Wn.height,V,K.length]),Xn=K.length*V,[Zn,Qn]=t.useState(!1);t.useEffect(()=>{let e=()=>Qn(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let $n=t.useCallback(()=>{let e=Le.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),er=t.useRef(null),tr=t.useCallback(e=>{if(e.touches.length===2){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;er.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:pt}}},[pt]),nr=t.useCallback(e=>{if(e.touches.length!==2||!er.current)return;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.max(1,Math.sqrt(t*t+n*n))/er.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(er.current.baseColumn*r)));et(i)},[]),rr=t.useCallback(()=>{er.current=null},[]),ir=t.useMemo(()=>{let e=M.now();return e<q.start||e>q.end?null:Math.round(X(e))},[q,X,M]),ar=t.useCallback(()=>{if(ir==null||!Z.current)return;let e=Math.max(0,ir-Z.current.clientWidth/2);Z.current.scrollTo({left:e,behavior:`smooth`})},[ir]),or=t.useRef(!1);t.useEffect(()=>{if(or.current||N.length===0)return;let e=window.requestAnimationFrame(()=>{let e=Z.current;if(!e||e.clientWidth===0)return;let t=ir;if(t==null){let e=new Date(Math.min(...N.map(e=>e.start.getTime())));t=Math.round(X(e))}e.scrollLeft=Math.max(0,t-e.clientWidth/2),or.current=!0});return()=>window.cancelAnimationFrame(e)},[N,ir,X]);let sr=t.useCallback((e,t=`left`)=>{let n=Z.current;if(!n||e<q.start||e>q.end)return!1;let r=Math.round(X(e)),i=t===`center`?r-n.clientWidth/2:r-24;return n.scrollTo({left:Math.max(0,i),behavior:`smooth`}),!0},[q,X]),cr=t.useCallback((e,t,n)=>{let r=Z.current;if(!r)return;let i=X(e),a=X(t),o=Math.max(0,r.scrollWidth-r.clientWidth),s=Math.min(96,r.clientWidth*.15),c=a-i<=r.clientWidth-s?(i+a)/2-r.clientWidth/2:i-s,l=Math.max(0,Math.min(c,o));Bn.current.forEach(e=>window.clearTimeout(e)),Bn.current=[],Vn.current?.(),Vn.current=null,zn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{zn(n),Bn.current.push(window.setTimeout(()=>zn(e=>e===n?null:e),1500))});Vn.current=()=>window.cancelAnimationFrame(e)},d=Math.abs(r.scrollLeft-l)>2;if(r.scrollTo({left:l,behavior:`smooth`}),!d){u();return}let f=`onscrollend`in r,p=!1,m=()=>{p||(p=!0,r.removeEventListener(`scrollend`,m),u())};r.addEventListener(`scrollend`,m),Bn.current.push(window.setTimeout(m,f?1500:500)),Vn.current=()=>r.removeEventListener(`scrollend`,m)},[X]);t.useEffect(()=>()=>{Bn.current.forEach(e=>window.clearTimeout(e)),Vn.current?.()},[]);let lr=t.useCallback(()=>sr(Ce(M.now(),`week`)),[sr,M]),ur=t.useCallback(()=>sr(Ce(M.now(),`month`)),[sr,M]),dr=t.useRef(null),fr=t.useRef(null),pr=t.useRef(null),mr=t.useRef(null),hr=t.useRef(null),gr=t.useRef(null),_r=t.useRef(null),vr=t.useRef(null),yr=t.useCallback(()=>{let e=Ln.current,t=dr.current,n=fr.current,r=pr.current;if(e&&t&&n&&r){let i=e.scrollWidth>e.clientWidth+1;if(t.style.display=i?`block`:`none`,i){let t=n.clientWidth;if(t>0){let n=Math.min(t,Math.max(40,e.clientWidth/e.scrollWidth*t)),i=e.scrollWidth-e.clientWidth,a=i>0?e.scrollLeft/i*(t-n):0;r.style.width=`${n}px`,r.style.transform=`translateX(${a}px)`}}}let i=hr.current,a=gr.current,o=_r.current;if(e&&i&&a&&o){let t=e.scrollHeight>e.clientHeight+1;if(i.style.display=t?`block`:`none`,t){let t=a.clientHeight;if(t>0){let n=Math.min(t,Math.max(40,e.clientHeight/e.scrollHeight*t)),r=e.scrollHeight-e.clientHeight,i=r>0?e.scrollTop/r*(t-n):0;o.style.height=`${n}px`,o.style.transform=`translateY(${i}px)`}}}},[]);t.useEffect(()=>{yr()});let br=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=Ln.current,n=fr.current,r=pr.current;if(!t||!n||!r)return;mr.current={startX:e.clientX,startLeft:t.scrollLeft};let i=n.clientWidth,a=r.getBoundingClientRect().width,o=t.scrollWidth-t.clientWidth,s=i-a>0?o/(i-a):0,c=e=>{let n=mr.current;n&&(t.scrollLeft=n.startLeft+(e.clientX-n.startX)*s)},l=()=>{mr.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},xr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=Ln.current,n=fr.current,r=pr.current;if(!t||!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect().width,o=t.scrollWidth-t.clientWidth,s=i.width-a;s<=0||(t.scrollLeft=Math.min(Math.max(e.clientX-i.x-a/2,0),s)/s*o)},Sr=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=Ln.current,n=gr.current,r=_r.current;if(!t||!n||!r)return;vr.current={startY:e.clientY,startTop:t.scrollTop};let i=n.clientHeight,a=r.getBoundingClientRect().height,o=t.scrollHeight-t.clientHeight,s=i-a>0?o/(i-a):0,c=e=>{let n=vr.current;n&&(t.scrollTop=n.startTop+(e.clientY-n.startY)*s)},l=()=>{vr.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},Cr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=Ln.current,n=gr.current,r=_r.current;if(!t||!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect().height,o=t.scrollHeight-t.clientHeight,s=i.height-a;s<=0||(t.scrollTop=Math.min(Math.max(e.clientY-i.y-a/2,0),s)/s*o)},wr=e=>{let t=e.currentTarget;!ot.current&&t.clientWidth>0&&(at.current=kn(t.scrollLeft)),Fn.current&&(Fn.current.scrollLeft=t.scrollLeft),yr(),In.current&&In.current.scrollTop!==t.scrollTop&&(In.current.scrollTop=t.scrollTop),Un(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),Kn()},Tr=e=>{let t=e.currentTarget,n=Z.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),Un(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},Er=(e,t)=>{let n=X(e),r=Cn&&x?mt*Math.min(...x.bands.map(e=>e.durMs))/j:mt;return{left:n,width:Math.max(X(t)-n,r,3)}},Dr=W?.group?W.taskId:null,Or=t.useMemo(()=>{if(Dr==null)return null;let e=new Set([String(Dr)]);for(let t of wt(Dr))t.locked||e.add(String(t.id));return e},[Dr,wt]),kr=t.useMemo(()=>{if(!W||W.group)return null;let e=new Set,t=new Set,n=Ct.get(String(W.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!Ct.has(r))break;t.add(r),e.add(r),n=Ct.get(r)}return e.size?e:null},[W,Ct]),Ar=e=>{if(W){if(Or?.has(String(e.task.id))){let t=Ot(W).start.getTime()-W.originStart.getTime();return Er(new Date(e.start.getTime()+t),new Date(e.end.getTime()+t))}if(W.taskId===e.task.id&&!W.group){let e=Ot(W);return Er(e.start,e.end)}if(e.isSummary&&kr?.has(String(e.task.id))&&(re!==`self`||e.task.hasOwnDates===!1)){let t=Ot(W),n=String(W.taskId),r=null,i=null;for(let a of wt(e.task.id)){if((St.get(String(a.id))??[]).length!==0)continue;let e=String(a.id)===n?t.start:a.start,o=String(a.id)===n?t.end:a.end;(!r||e<r)&&(r=e),(!i||o>i)&&(i=o)}if(r&&i)return Er(r,i)}}return Er(e.start,e.end)},jr=t.useMemo(()=>{let e=new Map;K.forEach((t,n)=>e.set(String(t.task.id),n));let t=[];return K.forEach(({task:n},r)=>{for(let i of n.dependencies??[]){let a=typeof i==`object`&&!!i,o=a?i.id:i;if(o==null||o===``)continue;let s=e.get(String(o));if(s==null||s===r)continue;let c=a?i.type:void 0,l=c===`ss`||c===`ff`||c===`sf`?c:`fs`;t.push({key:`${String(o)}->${String(n.id)}:${l}`,sourceId:o,targetId:n.id,type:l,sourceIndex:s,targetIndex:r})}}),t},[K]),Mr=Math.max(2,Math.round(V/2)-14),Nr=V-Mr*2,Pr=Math.round(Nr/2),Fr=Math.max(Math.round(V*.4),12),Ir=Fr*Math.SQRT2/2,Lr=Nr,Rr=Mr,zr=Math.max(3,Math.round(V*.13)),Br=V-zr-1,Vr=`rgba(100, 116, 139, 0.35)`,Hr=`rgba(100, 116, 139, 0.6)`,Ur=e=>{let t=K[e.sourceIndex],n=K[e.targetIndex];if(!t||!n)return null;let r=Ar(t),i=Ar(n),a=e=>e.isSummary?Rr+Lr/2:V/2,o=e.sourceIndex*V+a(t),s=e.targetIndex*V+a(n),c=e.type===`fs`||e.type===`ff`,l=e.type===`ff`||e.type===`sf`,u=t.isMilestone?r.left+(c?Ir:-Ir):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?Ir:-Ir):l?i.left+i.width:i.left,f=u+(c?10:-10),p=d+(l?10:-10),m=Math.round,h=[`M ${m(u)} ${m(o)}`,`L ${m(f)} ${m(o)}`];if(l?f>=p:f<=p)h.push(`L ${m(f)} ${m(s)}`,`L ${m(d)} ${m(s)}`);else{let t=s>=o?(e.sourceIndex+1)*V:e.sourceIndex*V;h.push(`L ${m(f)} ${m(t)}`,`L ${m(p)} ${m(t)}`,`L ${m(p)} ${m(s)}`,`L ${m(d)} ${m(s)}`)}return h.join(` `)},Wr=W?.taskId??bt,[Gr,Kr]=t.useState(te),qr=t.useMemo(()=>Gr?D(N,b):null,[Gr,N,b]),Jr=t.useCallback(e=>qr?.criticalIds.has(String(e))??!1,[qr]),$=`#dc2626`,[Yr,Xr]=t.useState(null),[Zr,Qr]=t.useState(!1);t.useEffect(()=>{if(!Zr)return;let e=setTimeout(()=>Qr(!1),2500);return()=>clearTimeout(e)},[Zr]);let $r=t.useCallback(()=>{if(!z)return;let{changes:e,skippedLocked:t}=O(N,b,Rt);if(!e.length){Qr(!0);return}Xr({changes:e,skipped:t.length})},[N,z,b,Rt]),ei=t.useCallback(()=>{if(!Yr)return;let e=[];for(let t of Yr.changes){let n=N.find(e=>String(e.id)===t.id);n&&e.push({task:n,changes:{start:t.start,end:t.end}})}e.length&&Pt(e),Xr(null)},[Yr,N,Pt]),ti=t.useCallback(()=>{if(typeof document>`u`||!N.length)return null;let e=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]),t=Math.max(dt,200),n=Math.ceil(t+En),r=Math.ceil(36+K.length*V),i=qr?.criticalEdges??null,a=[];a.push(`<rect x="0" y="0" width="${n}" height="${r}" fill="#ffffff"/>`),a.push(`<rect x="0" y="0" width="${n}" height="36" fill="#f8fafc"/>`),a.push(`<g transform="translate(${t},0)" font-family="sans-serif" font-size="10" fill="#475569">`),Nn.forEach(t=>{a.push(`<line x1="${t.offset.toFixed(1)}" y1="0" x2="${t.offset.toFixed(1)}" y2="36" stroke="#e2e8f0"/>`),a.push(`<text x="${(t.offset+t.width/2).toFixed(1)}" y="12" text-anchor="middle" font-weight="600">${e(t.label)}</text>`)}),J.forEach((t,n)=>{let i=Y[n];a.push(`<line x1="${i.toFixed(1)}" y1="18" x2="${i.toFixed(1)}" y2="${r}" stroke="#eef2f7"/>`),a.push(`<text x="${(i+t.width/2).toFixed(1)}" y="30" text-anchor="middle" fill="#1f2937">${e(t.label)}</text>`)}),a.push(`</g>`),a.push(`<line x1="0" y1="18" x2="${n}" y2="18" stroke="#e2e8f0"/>`),a.push(`<line x1="0" y1="36" x2="${n}" y2="36" stroke="#cbd5e1"/>`),a.push(`<line x1="${t}" y1="0" x2="${t}" y2="${r}" stroke="#cbd5e1"/>`),a.push(`<g transform="translate(0,36)" font-family="sans-serif" font-size="11" fill="#1f2937">`),K.forEach((n,r)=>{let i=r*V;a.push(`<line x1="0" y1="${(i+V).toFixed(1)}" x2="${t}" y2="${(i+V).toFixed(1)}" stroke="#f1f5f9"/>`);let o=8+n.depth*14,s=Math.max(4,Math.floor((t-o)/6.5)),c=n.task.title.length>s?n.task.title.slice(0,s-1)+`…`:n.task.title,l=n.isSummary?` font-weight="600"`:``;a.push(`<text x="${o}" y="${(i+V/2+4).toFixed(1)}"${l}>${e(c)}</text>`)}),a.push(`</g>`);let o=(e,t)=>{let n=t-12;if(n<=9)return``;let r=0,i=``;for(let t of e){let a=t.charCodeAt(0)>255?9:5.5;if(r+a>n)return i.length<e.length?`${i.slice(0,-1)}…`:i;r+=a,i+=t}return i};a.push(`<g transform="translate(${t},36)" font-family="sans-serif" font-size="9">`),K.forEach((t,n)=>{if(t.task.type===`group`)return;let r=n*V,{left:i,width:s}=Er(t.start,t.end),c=Jr(t.task.id),l=c?` stroke="${$}" stroke-width="2"`:``;if(ne&&t.task.baselineStart&&t.task.baselineEnd){let e=Er(t.task.baselineStart,t.task.baselineEnd);a.push(`<rect x="${e.left.toFixed(1)}" y="${(r+Br).toFixed(1)}" width="${Math.max(2,e.width).toFixed(1)}" height="${zr}" rx="1" fill="${Vr}" stroke="${Hr}"/>`)}if(t.isMilestone){let e=i,n=r+V/2,o=Fr/2,s=c?$:t.task.color||`#3b82f6`;a.push(`<polygon points="${e},${n-o} ${e+o},${n} ${e},${n+o} ${e-o},${n}" fill="${s}"/>`)}else if(t.isSummary){let n=t.task.color||`#64748b`;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Rr).toFixed(1)}" width="${s.toFixed(1)}" height="${Lr}" rx="3" fill="${n}"${l}/>`);let c=s*Math.min(100,Math.max(0,t.progress))/100;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Rr).toFixed(1)}" width="${c.toFixed(1)}" height="${Lr}" rx="3" fill="rgba(0,0,0,0.2)"/>`);let u=o(t.task.title,s);u&&a.push(`<text x="${(i+6).toFixed(1)}" y="${(r+V/2+3).toFixed(1)}" fill="#ffffff" font-weight="500">${e(u)}</text>`)}else{let n=t.task.color||`#3b82f6`;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Mr).toFixed(1)}" width="${s.toFixed(1)}" height="${Nr}" rx="3" fill="${n}"${l}/>`);let c=s*Math.min(100,Math.max(0,t.progress))/100;a.push(`<rect x="${i.toFixed(1)}" y="${(r+Mr).toFixed(1)}" width="${c.toFixed(1)}" height="${Nr}" rx="3" fill="rgba(0,0,0,0.18)"/>`);let u=o(t.task.title,s);u?a.push(`<text x="${(i+6).toFixed(1)}" y="${(r+V/2+3).toFixed(1)}" fill="#ffffff" font-weight="500">${e(u)}</text>`):s>=24&&a.push(`<text x="${(i+s/2).toFixed(1)}" y="${(r+V/2+3).toFixed(1)}" text-anchor="middle" fill="#ffffff">${Math.round(t.progress)}%</text>`)}}),jr.forEach(e=>{let t=Ur(e);if(!t)return;let n=i?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?$:`#94a3b8`;a.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),ir!=null&&a.push(`<line x1="${ir.toFixed(1)}" y1="0" x2="${ir.toFixed(1)}" y2="${K.length*V}" stroke="#ef4444" stroke-width="1.5"/>`);let s=K.length*V;return Pn.forEach(t=>{let n=/var\(/.test(t.color)?`#6366f1`:t.color;if(a.push(`<line x1="${t.left.toFixed(1)}" y1="0" x2="${t.left.toFixed(1)}" y2="${s}" stroke="${e(n)}" stroke-width="1.5"/>`),t.label){let r=t.label.length*6+8;a.push(`<rect x="${(t.left-r/2).toFixed(1)}" y="0" width="${r}" height="14" rx="2" fill="${e(n)}"/>`),a.push(`<text x="${t.left.toFixed(1)}" y="10" text-anchor="middle" font-size="9" font-weight="600" fill="#ffffff">${e(t.label)}</text>`)}}),a.push(`</g>`),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${n} ${r}">${a.join(``)}</svg>`,W:n,H:r}},[N,K,jr,Ur,Er,Jr,qr,J,Y,En,dt,V,Mr,Nr,Rr,Lr,Fr,ir,H,ne,Br,zr,Vr,Hr,Pn,Nn]),ni=t.useCallback(()=>{let e=(ue??``).replace(/[\\/:*?"<>|\s]+/g,` `).trim()||`gantt`,t=new Date,n=e=>String(e).padStart(2,`0`);return`${e}-${`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}-${n(t.getHours())}${n(t.getMinutes())}`}`},[ue]),ri=t.useCallback(async()=>{let e=ti();if(!e)return;let t=await Ee(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&De(e,`${ni()}.png`)},`image/png`)},[ti,ni]),ii=t.useCallback(async()=>{let e=ti();if(!e)return;let t=await Ee(e.svg,e.W,e.H);t&&De(Oe(ke(t.toDataURL(`image/jpeg`,.92)),t.width,t.height),`${ni()}.pdf`)},[ti,ni]),[ai,oi]=t.useState(!1),si=t.useCallback(()=>{let e={viewMode:H,columnWidth:$e,taskListCollapsed:st,taskListWidth:tt,collapsedIds:Array.from(vn)};ie&&je(ie,e),oe?.(e),oi(!0)},[H,$e,st,tt,vn,ie,oe]);return t.useEffect(()=>{if(!ai)return;let e=setTimeout(()=>oi(!1),1500);return()=>clearTimeout(e)},[ai]),(0,d.jsxs)(`div`,{ref:Le,className:(0,c.cn)(`flex flex-col h-full bg-background overflow-hidden min-w-0`,_),"data-readonly":R?`true`:void 0,"data-mobile-readonly":C&&ze?`true`:void 0,children:[(0,d.jsx)(`style`,{children:`
|
|
16
16
|
.gantt-resize-handle:hover { background-color: rgba(255, 255, 255, 0.4); }
|
|
17
17
|
.gantt-bar-hover:hover { filter: brightness(1.1); }
|
|
18
18
|
.gantt-row-open-btn { opacity: 0; transition: opacity 0.15s ease; }
|
|
@@ -60,4 +60,4 @@ endobj
|
|
|
60
60
|
bar. Hide it — the pane stays wheel/drag-scrollable and synced. */
|
|
61
61
|
.gantt-task-list::-webkit-scrollbar { width: 0; height: 0; }
|
|
62
62
|
.gantt-task-list { scrollbar-width: none; }
|
|
63
|
-
`}),(0,d.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,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":P(`gantt.toolbar.prevPeriod`),children:(0,d.jsx)(u.ChevronLeft,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":P(`gantt.toolbar.nextPeriod`),children:(0,d.jsx)(u.ChevronRight,{className:`h-4 w-4`})}),(0,d.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:q.start.toLocaleDateString(F,{month:`long`,year:`numeric`})}),L&&(0,d.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:P(`gantt.readOnlyHint`),children:[(0,d.jsx)(u.Lock,{className:`h-3 w-3`}),P(`gantt.readOnly`)]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":P(`gantt.toolbar.viewMode`),children:be.map(e=>(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:(0,c.cn)(`h-6 px-1.5 sm:px-2 text-xs`,V===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>An(e),"aria-pressed":V===e,"data-testid":`gantt-view-mode-${e}`,children:P(`gantt.viewMode.${e}`)},e))}),(0,d.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(pt>15)tt(Math.max(15,pt-10));else{let e=be.indexOf(V);e<be.length-1&&(An(be[e+1]),tt(Ze))}},"aria-label":P(`gantt.toolbar.zoomOut`),children:(0,d.jsx)(u.ZoomOut,{className:`h-3 w-3`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(pt<120)tt(Math.min(120,pt+10));else{let e=be.indexOf(V);e>0&&(An(be[e-1]),tt(Ze))}},"aria-label":P(`gantt.toolbar.zoomIn`),children:(0,d.jsx)(u.ZoomIn,{className:`h-3 w-3`})})]}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>lt(e=>!e),"aria-label":P(ct?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":ct,"data-testid":`gantt-toggle-task-list`,children:ct?(0,d.jsx)(u.PanelLeft,{className:`h-4 w-4`}):(0,d.jsx)(u.PanelLeftClose,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:ar,disabled:ir==null,"aria-label":P(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:P(`gantt.toolbar.today`)}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:lr,"aria-label":P(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:P(`gantt.toolbar.thisWeek`)}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:ur,"aria-label":P(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:P(`gantt.toolbar.thisMonth`)}),ce?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void ce(),disabled:O,"aria-label":P(`gantt.toolbar.refresh`),"aria-busy":O,"data-testid":`gantt-refresh`,children:(0,d.jsx)(u.RefreshCw,{className:`h-4 w-4`})}):null,R?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Ht,disabled:!Wt,"aria-label":P(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,d.jsx)(u.Undo2,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Ut,disabled:!Gt,"aria-label":P(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,d.jsx)(u.Redo2,{className:`h-4 w-4`})})]}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Kr(e=>!e),"aria-label":P(`gantt.toolbar.criticalPath`),"aria-pressed":Gr,"data-testid":`gantt-critical-path`,style:Gr?{color:$}:void 0,children:(0,d.jsx)(u.Activity,{className:`h-4 w-4`})}),Ye&&R?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:$r,"aria-label":P(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,d.jsx)(u.Wand2,{className:`h-4 w-4`})}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:ri,"aria-label":P(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,d.jsx)(u.Download,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:ii,"aria-label":P(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,d.jsx)(u.FileDown,{className:`h-4 w-4`})}),se||ae?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:si,"aria-label":P(`gantt.toolbar.saveLayout`),"aria-pressed":ai,"data-testid":`gantt-save-layout`,style:ai?{color:$}:void 0,children:(0,d.jsx)(u.Save,{className:`h-4 w-4`})}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:$n,"aria-label":P(Zn?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":Zn,"data-testid":`gantt-fullscreen`,children:Zn?(0,d.jsx)(u.Minimize2,{className:`h-4 w-4`}):(0,d.jsx)(u.Maximize2,{className:`h-4 w-4`})})]})]}),(0,d.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:Sn,"data-testid":`gantt-body`,children:[!ct&&H>0&&(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:H-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=H,r=Math.max(160,I-200),i=e=>{let i=Math.max(160,Math.min(n+(e.clientX-t),r));rt(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:()=>rt(null),children:(0,d.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,d.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,d.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:H,minWidth:H},children:[(0,d.jsx)(`div`,{className:`flex-1 truncate`,children:P(`gantt.column.taskName`)}),ht&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:P(`gantt.column.start`)}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:P(`gantt.column.end`)})]}),o&&(0,d.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},"aria-hidden":`true`,"data-testid":`gantt-header-open-spacer`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:Fn,children:(0,d.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:En},children:[(0,d.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:Nn.slice(Yn.start,Yn.end).map(e=>(0,d.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,d.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,d.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:J.slice(qn.start,qn.end).map((e,t)=>{let n=qn.start+t;return(0,d.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:Y[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,d.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&pt>=32&&(0,d.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,d.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,d.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:In,onScroll:Tr,style:{width:H,minWidth:H},role:`tree`,"aria-label":P(`gantt.aria.taskList`),children:[Q.startIdx>0&&(0,d.jsx)(`div`,{style:{height:Q.startIdx*B},"aria-hidden":`true`}),K.slice(Q.startIdx,Q.endIdx).map(e=>{let t=e.task,n=Je&>===t.id,r=vn.has(String(t.id)),i=pn!=null&&String(pn)===String(t.id);return(0,d.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:B,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:!!qe&&!n&&!t.locked,onDragStart:qe?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:qe?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:qe?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=Ct.get(n);r&&String(r.parent??``)===String(t.parent??``)&&qe(r,t)}:void 0,onContextMenu:e=>gn(t,e),onClick:()=>{mn(t.id),n||cr(e.start,e.end,t.id)},onDoubleClick:()=>{n||(Je&&R&&!e.isSummary&&!t.locked?(_t(t.id),yt({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})):o?.(t))},children:[(0,d.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,d.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(),bn(t.id)},"aria-expanded":!r,"aria-label":P(r?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:r?(0,d.jsx)(u.ChevronRight,{className:`h-3.5 w-3.5`}):(0,d.jsx)(u.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,d.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,d.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),n?(0,d.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:vt.title||``,onChange:e=>yt(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Pt([{task:t,changes:{title:vt.title,start:new Date(vt.start),end:new Date(vt.end),progress:Number(vt.progress)||0}}]),_t(null)):e.key===`Escape`&&_t(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,d.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,d.jsx)(`span`,{className:(0,c.cn)(`truncate`,e.isSummary&&`font-semibold`),children:t.title}),(0,d.jsxs)(`span`,{className:`text-[10px] text-muted-foreground gantt-sm-hidden`,children:[e.start.toLocaleDateString(F,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(F,{month:`numeric`,day:`numeric`})]})]})]}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!ht,style:ht?void 0:{display:`none`},children:n?(0,d.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:vt.start||``,onChange:e=>yt(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(F,{month:`numeric`,day:`numeric`})}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!ht,style:ht?void 0:{display:`none`},children:n?(0,d.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:vt.end||``,onChange:e=>yt(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(F,{month:`numeric`,day:`numeric`})}),o&&(0,d.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!n&&(0,d.jsx)(`button`,{type:`button`,title:P(`gantt.row.open`),"aria-label":P(`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,d.jsx)(u.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),Q.endIdx<K.length&&(0,d.jsx)(`div`,{style:{height:(K.length-Q.endIdx)*B},"aria-hidden":`true`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{Ln.current=e,Z.current=e},onScroll:wr,onTouchStart:tr,onTouchMove:nr,onTouchEnd:rr,"data-testid":`gantt-timeline`,children:(0,d.jsxs)(`div`,{className:`relative`,style:{width:En},children:[ir!=null&&(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:ir,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":P(`gantt.toolbar.today`),children:(0,d.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:P(`gantt.toolbar.today`)})}),Pn.map(e=>(0,d.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,d.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,d.jsxs)(`div`,{className:`relative`,ref:Qt,children:[(0,d.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:J.slice(qn.start,qn.end).map((e,t)=>{let n=qn.start+t;return(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:Y[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)})}),Cn&&x&&x.showMidnight&&(0,d.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:J.slice(qn.start,qn.end).map((e,t)=>{let n=qn.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,d.jsx)(`div`,{className:`absolute top-0 bottom-0`,style:{left:Y[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}`)})}),Q.startIdx>0&&(0,d.jsx)(`div`,{style:{height:Q.startIdx*B},"aria-hidden":`true`}),K.slice(Q.startIdx,Q.endIdx).map((e,n)=>{let r=e.task,i=Q.startIdx+n,a=Jr(r.id),o=Er(e.start,e.end),s=ne&&r.baselineStart&&r.baselineEnd?Er(r.baselineStart,r.baselineEnd):null,l=s?(0,d.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:s.left,width:Math.max(2,s.width),top:Br,height:zr,backgroundColor:Vr,border:`1px solid ${Hr}`},"data-testid":`gantt-baseline-${r.id}`,"aria-hidden":`true`}):null,u=W?.taskId===r.id,f=Or?.has(String(r.id))??!1,p=kr?.has(String(r.id))??!1,m=u||f||p?Ar(e):o,h=!!r.locked,g=!!R&&!e.isSummary&&!h,_=g&&Ve,v=g&&He,y=g&&Ue,ee=_||v,te=L||h,b=G!=null&&G.targetId!=null&&String(G.targetId)===String(r.id)&&String(G.sourceId)!==String(r.id),x=G?e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;$t(e=>e&&Zt(e.sourceId,r)?{...e,targetId:r.id,targetEnd:n}:e)}:void 0,S=G?e=>{e.target===e.currentTarget&&$t(e=>e&&{...e,targetId:null,targetEnd:null})}:void 0,re=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/A)),C=(i+1)*B+300>Xn&&i*B>300,w=bt===r.id&&!W&&!qt&&!G?(0,d.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(m.left+8,4),...C?{bottom:B-8}:{top:B-8}},role:`tooltip`,"data-testid":`gantt-tooltip-${r.id}`,children:[(0,d.jsx)(`div`,{className:`font-semibold`,children:r.title}),r.fields&&r.fields.length>0?(0,d.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:r.fields.map((e,n)=>(0,d.jsxs)(t.Fragment,{children:[(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,d.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,d.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(F,{month:`short`,day:`numeric`}),` → `,e.end.toLocaleDateString(F,{month:`short`,day:`numeric`}),` · `,re,P(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),r.locked||L&&!R?(0,d.jsxs)(`div`,{className:`text-muted-foreground`,style:{marginTop:4},"data-testid":`gantt-tooltip-locked-${r.id}`,children:[`🚫 `,P(`gantt.lockedHint`)]}):null]}):null;if(r.type===`group`)return(0,d.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:B},onPointerMove:S,children:w},r.id);if(e.isSummary){let t=r.color||`#0d9488`,n=ie===`self`&&r.hasOwnDates!==!1,i=!!R&&Ve&&!h,o=!!R&&He&&n&&!h;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:B},onPointerMove:S,children:[l,(0,d.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none group`,i&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Rn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Rr,height:Lr,cursor:i||o?void 0:te?`not-allowed`:`pointer`,backgroundColor:t,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0},"data-critical":a?`true`:void 0,"data-testid":`gantt-summary-bar-${r.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>xt(r.id),onMouseLeave:()=>xt(e=>e===r.id?null:e),onPointerMove:x,onPointerDown:t=>{if(t.button===0){if(o){let e=he(t.clientX,t.currentTarget.getBoundingClientRect());if(e!==`move`){Kt(r,e,t);return}}i&&Kt(r,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})}},onClick:()=>{Dt.current||mn(r.id)},onContextMenu:e=>gn(r,e),children:[(0,d.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)`}}),o&&m.width>=14&&(0,d.jsxs)(d.Fragment,{children:[(0,d.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-${r.id}`,onPointerDown:e=>{e.button===0&&Kt(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,d.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-${r.id}`,onPointerDown:e=>{e.button===0&&Kt(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),(0,d.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:r.title}),z&&!h&&[`start`,`end`].map(e=>{let t=G!=null&&String(G.sourceId)===String(r.id)&&G.sourceEnd===e,n=t||bt===r.id,i=n&&G==null;return(0,d.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:+!!n,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}-${r.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let n=Qt.current?.getBoundingClientRect();$t({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null})},onClick:e=>e.stopPropagation(),children:(0,d.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)})]}),u&&W&&(0,d.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(m.left,4),top:Rr+Lr+2},"data-testid":`gantt-summary-drag-chip-${r.id}`,children:[Ot(W).start.toLocaleDateString(F,{month:`numeric`,day:`numeric`}),` → `,Ot(W).end.toLocaleDateString(F,{month:`numeric`,day:`numeric`})]}),w]},r.id)}if(e.isMilestone){let e=Fr;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:B},onPointerMove:S,children:[l,(0,d.jsx)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,_&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Rn===r.id&&`gantt-flash z-10`),style:{left:m.left-e/2,top:(B-e)/2,width:e,height:e,cursor:_?void 0:te?`not-allowed`:`pointer`,backgroundColor:a?$:r.color||`#3b82f6`,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0},"data-critical":a?`true`:void 0,"data-testid":`gantt-milestone-${r.id}`,onMouseEnter:()=>xt(r.id),onMouseLeave:()=>xt(e=>e===r.id?null:e),onClick:()=>{Dt.current||mn(r.id)},onContextMenu:e=>gn(r,e),onPointerMove:x,onPointerDown:_?e=>{e.button===0&&Kt(r,`move`,e)}:void 0}),w]},r.id)}let T=qt&&qt.taskId===r.id?qt.value:r.progress;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:B},onPointerMove:S,onMouseEnter:()=>xt(r.id),onMouseLeave:()=>xt(e=>e===r.id?null:e),children:[u&&(0,d.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:o.left,width:o.width,top:Mr,height:Nr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),l,(0,d.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`,ee&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Rn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Mr,height:Nr,cursor:ee?void 0:te?`not-allowed`:`pointer`,backgroundColor:r.color||`#3b82f6`,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0},"data-critical":a?`true`:void 0,"data-testid":`gantt-task-bar-${r.id}`,onClick:()=>{Dt.current||mn(r.id)},onContextMenu:e=>gn(r,e),onPointerMove:x,onPointerDown:ee?e=>{if(e.button!==0)return;let t=he(e.clientX,e.currentTarget.getBoundingClientRect()),n=t!==`move`&&v?t:_?`move`:null;n&&Kt(r,n,e)}:void 0,children:[v&&m.width>=14&&(0,d.jsxs)(d.Fragment,{children:[(0,d.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-${r.id}`,onPointerDown:e=>{e.button===0&&Kt(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,d.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-${r.id}`,onPointerDown:e=>{e.button===0&&Kt(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),T>0&&(0,d.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${T}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),y&&m.width>=30&&(0,d.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`,qt?.taskId===r.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${T}%`},"data-testid":`gantt-progress-handle-${r.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),Jt({taskId:r.id,originClientX:e.clientX,originProgress:r.progress,barWidth:m.width,value:r.progress}))},onClick:e=>e.stopPropagation(),children:(0,d.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))`}})}),z&&!h&&[`start`,`end`].map(e=>{let t=G!=null&&String(G.sourceId)===String(r.id)&&G.sourceEnd===e,n=t||bt===r.id,i=n&&G==null;return(0,d.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:+!!n,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}-${r.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let n=Qt.current?.getBoundingClientRect();$t({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null})},onClick:e=>e.stopPropagation(),children:(0,d.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,d.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:r.title}),(0,d.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:u?`${Ot(W).start.toLocaleDateString(F,{month:`numeric`,day:`numeric`})} → ${Ot(W).end.toLocaleDateString(F,{month:`numeric`,day:`numeric`})}`:`${Math.round(T)}%`})]}),w]},r.id)}),Q.endIdx<K.length&&(0,d.jsx)(`div`,{style:{height:(K.length-Q.endIdx)*B},"aria-hidden":`true`}),(jr.length>0||G)&&(0,d.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:En,height:Xn,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,d.jsxs)(`defs`,{children:[(0,d.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,d.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,d.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:$})})]}),jr.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<Q.startIdx-6||n>Q.endIdx+6)return null;let r=Ur(e);if(!r)return null;let i=Wr!=null&&(String(e.sourceId)===String(Wr)||String(e.targetId)===String(Wr)),a=qr?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(Ke||z);return(0,d.jsxs)(t.Fragment,{children:[(0,d.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,d.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=>_n(e.sourceId,e.targetId,e.type,t)})]},e.key)}),G&&(()=>{let e=K.findIndex(e=>String(e.task.id)===String(G.sourceId));if(e<0)return null;let t=Ar(K[e]),n=K[e].isMilestone?t.left+(G.sourceEnd===`start`?-Ir:Ir):G.sourceEnd===`start`?t.left:t.left+t.width,r=e*B+B/2;return(0,d.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(G.x)} ${Math.round(G.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),G&&(()=>{let e=M.find(e=>String(e.id)===String(G.sourceId));if(!e)return null;let t=G.targetId==null?null:M.find(e=>String(e.id)===String(G.targetId)),n=e=>P(`gantt.linkEnd.${e}`),r=t?`${e.title} (${n(G.sourceEnd)}) → ${t.title} (${n(G.targetEnd??`start`)})`:`${e.title} (${n(G.sourceEnd)})`;return(0,d.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:G.x+12,top:G.y+12},"data-testid":`gantt-link-draft-hint`,children:r})})()]})]})}),(0,d.jsx)(`div`,{ref:hr,className:`shrink-0 border-l bg-card/95 select-none`,style:{width:14,display:`none`},"data-testid":`gantt-vscrollbar`,children:(0,d.jsx)(`div`,{ref:gr,className:`relative h-full`,onPointerDown:Cr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`vertical`,children:(0,d.jsx)(`div`,{ref:_r,className:`absolute rounded-full`,style:{left:2,right:2,top:0,height:0,backgroundColor:`rgba(130,130,130,0.55)`,cursor:`grab`},"data-testid":`gantt-vscrollbar-thumb`,onPointerDown:Sr})})})]}),(0,d.jsx)(`div`,{ref:dr,className:`shrink-0 border-t bg-card/95 select-none`,style:{position:`sticky`,bottom:0,zIndex:30,display:`none`},"data-testid":`gantt-hscrollbar`,children:(0,d.jsx)(`div`,{ref:fr,className:`relative`,style:{marginLeft:H,height:14},onPointerDown:xr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`horizontal`,children:(0,d.jsx)(`div`,{ref:pr,className:`absolute rounded-full`,style:{top:2,bottom:2,left:0,width:0,backgroundColor:`rgba(130,130,130,0.55)`,cursor:`grab`},"data-testid":`gantt-hscrollbar-thumb`,onPointerDown:br})})})]}),tn&&(()=>{let e=M.find(e=>String(e.id)===String(tn.taskId));if(!e)return null;let t=K.find(e=>String(e.task.id)===String(tn.taskId)),n=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,d.jsxs)(`div`,{ref:rn,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:tn.x,top:tn.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[o&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-view`,onClick:()=>{nn(null),o(e)},children:P(`gantt.menu.view`)}),Je&&R&&t&&!t.isSummary&&!e.locked&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-edit`,onClick:()=>{nn(null),_t(e.id),yt({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:e.end.toLocaleDateString(`en-CA`),progress:String(e.progress)})},children:P(`gantt.menu.edit`)}),z&&t&&!t.isMilestone&&!e.locked&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let t=tn;nn(null),dn(``),ln({x:t.x,y:t.y,taskId:e.id,relation:`pred`})},children:P(`gantt.menu.addPredecessor`)}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let t=tn;nn(null),dn(``),ln({x:t.x,y:t.y,taskId:e.id,relation:`succ`})},children:P(`gantt.menu.addSuccessor`)})]}),Ge&&!e.locked&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,c.cn)(n,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{nn(null),Ge(e)},children:P(`gantt.menu.delete`)})]})})(),an&&(()=>{let e=M.find(e=>String(e.id)===String(an.sourceId)),t=M.find(e=>String(e.id)===String(an.targetId));if(!e||!t)return null;let n=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`,r=[`fs`,`ss`,`ff`,`sf`],i=!!t.locked;return(0,d.jsxs)(`div`,{ref:sn,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:an.x,top:an.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,d.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[e.title,` → `,t.title]}),i&&(0,d.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,P(`gantt.lockedHint`)]}),z&&le&&r.map(r=>(0,d.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":an.type===r,disabled:i,className:(0,c.cn)(n,an.type===r&&`font-semibold`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${r}`,onClick:()=>{i||(on(null),r!==an.type&&z(e,t,r))},children:[an.type===r?`✓ `:`\xA0\xA0`,P(`gantt.linkType.${r}`)]},r)),Ke&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`my-1 border-t`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:i,className:(0,c.cn)(n,`text-destructive`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{i||(on(null),Ke(e,t))},children:P(`gantt.menu.removeDependency`)})]})]})})(),cn&&z&&(()=>{let e=M.find(e=>String(e.id)===String(cn.taskId));if(!e)return null;let t=new Set(jr.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),n=M.filter(n=>{if(String(n.id)===String(e.id)||n.type===`group`||n.locked)return!1;let r=cn.relation===`pred`?`${String(n.id)}->${String(e.id)}`:`${String(e.id)}->${String(n.id)}`;return!t.has(r)}),r=un.trim().toLowerCase(),i=r?n.filter(e=>String(e.title??``).toLowerCase().includes(r)):n;return(0,d.jsxs)(`div`,{ref:fn,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:cn.x,top:cn.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,d.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:cn.relation===`pred`?P(`gantt.menu.addPredecessor`):P(`gantt.menu.addSuccessor`)}),(0,d.jsx)(`div`,{className:`px-2 pb-1`,children:(0,d.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:un,onChange:e=>dn(e.target.value),placeholder:P(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),i.length===0?(0,d.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:P(`gantt.menu.noCandidates`)}):i.map(t=>(0,d.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-${t.id}`,onClick:()=>{ln(null),cn.relation===`pred`?z(t,e,`fs`):z(e,t,`fs`)},children:t.title},String(t.id)))]})})(),Yr&&(0,d.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-autoschedule-overlay`,onClick:()=>Xr(null),children:(0,d.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-autoschedule-dialog`,onClick:e=>e.stopPropagation(),children:[(0,d.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-autoschedule-title`,children:P(`gantt.autoScheduleDlg.title`)}),(0,d.jsxs)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:[P(`gantt.autoScheduleDlg.body`).replace(`{count}`,String(Yr.changes.length)),Yr.skipped>0&&(0,d.jsxs)(d.Fragment,{children:[` `,(0,d.jsx)(`span`,{"data-testid":`gantt-autoschedule-skipped`,children:P(`gantt.autoScheduleDlg.skipped`).replace(`{count}`,String(Yr.skipped))})]})]}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md border hover:bg-accent outline-none`,"data-testid":`gantt-autoschedule-cancel`,onClick:()=>Xr(null),children:P(`gantt.autoScheduleDlg.cancel`)}),(0,d.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-autoschedule-confirm`,onClick:ei,children:P(`gantt.autoScheduleDlg.confirm`)})]})]})}),Zr&&(0,d.jsx)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-[60] rounded-md border bg-popover text-popover-foreground px-3 py-1.5 text-sm shadow-md`,role:`status`,"data-testid":`gantt-autoschedule-clean`,children:P(`gantt.autoScheduleDlg.none`)}),Ft&&(0,d.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>It(null),children:(0,d.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,d.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:P(`gantt.conflict.title`)}),(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:P(`gantt.conflict.body`).replace(`{count}`,String(Ft.length))}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,d.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:()=>It(null),children:P(`gantt.conflict.cancel`)}),(0,d.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:Bt,children:P(`gantt.conflict.confirm`)})]})]})})]})}function Ne(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 N(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)Ne(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},P=48,Fe=34,F=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 Le({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,f=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=we(t,a),i=Ee(we(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=Ee(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(()=>N(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*f;return e.length?(0,d.jsx)(`div`,{className:s,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,d.jsxs)(`div`,{style:{display:`flex`,minWidth:F+g},children:[(0,d.jsxs)(`div`,{style:{width:F,flexShrink:0},children:[(0,d.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,d.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:P,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,d.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,d.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,d.jsxs)(`div`,{style:{flex:1},children:[(0,d.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:p.map((e,t)=>(0,d.jsx)(`div`,{style:{width:f,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=Fe*(1-Math.min(e.capacity/h,1));return(0,d.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:P,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,d.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:(P-Fe)/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,Fe*Math.min(t.load/h,1));return(0,d.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:f,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:(P-Fe)/2},children:t.load>0&&(0,d.jsx)(`div`,{style:{width:f-6,height:r,borderRadius:2,backgroundColor:t.overloaded?`hsl(var(--destructive))`:`hsl(var(--primary))`,opacity:t.overloaded?.9:.75}})},n)})]},e.key)})]})]})}):(0,d.jsx)(`div`,{className:s,"data-testid":`resource-workload`,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:c(`gantt.resource.empty`)})})}var Re={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},ze={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`},I={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)`},Be={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function L({checked:e}){return(0,d.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 Ve({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,f=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,d.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,d.jsxs)(`button`,{type:`button`,style:{...ze,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,d.jsx)(`span`,{children:m}),(0,d.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,d.jsx)(`div`,{role:`listbox`,style:I,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,d.jsx)(`div`,{style:{...Be,cursor:`default`,opacity:.6},children:i.empty}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...Be,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>p(),children:[(0,d.jsx)(L,{checked:u}),(0,d.jsx)(`span`,{children:i.all})]}),(0,d.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,d.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...Be,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>f(t.value),children:[(0,d.jsx)(L,{checked:n}),(0,d.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var He=({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`,f=e.some(e=>(t[e.field]?.length??0)>0);return(0,d.jsxs)(`div`,{style:Re,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,d.jsx)(Ve,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),f&&(0,d.jsx)(`button`,{type:`button`,style:{...ze,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,d.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function Ue(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 We={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 R(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=We[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n);return t}function Ge(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function z(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 qe(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,interactions:e.interactions,exportFileName:e.exportFileName,timeZone:e.timeZone,dependencyTypes:e.dependencyTypes},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 Je=({schema:e,dataSource:a,className:u,onTaskClick:f,onRowClick:p,onBeforeTaskUpdate:m,...h})=>{let[g,_]=(0,t.useState)([]),[v,y]=(0,t.useState)(!0),[ee,te]=(0,t.useState)(null),[b,x]=(0,t.useState)(null),{currency:ne}=(0,o.useLocalization)(),{t:S}=pe(),re=(0,t.useCallback)(e=>{i.toast.error(S(`gantt.writeFailed`),{description:Ke(e)??void 0})},[S]),C=Ge(e),w=(0,t.useMemo)(()=>C,[JSON.stringify(C)]),T=qe(e),ie=w?.provider===`value`,ae=(0,t.useContext)(r.SchemaRendererContext)?.apiFetch,E=(0,t.useMemo)(()=>(0,n.resolveDataSource)(w,a??null,{fetch:ae}),[w,a,ae]),D=w?.provider===`object`?w.object:e.objectName??``,[oe,se]=(0,t.useState)(!1),ce=(0,t.useRef)(0),O=(0,t.useCallback)(async({silent:t=!1}={})=>{let r=++ce.current,i=()=>ce.current===r;try{if(t?se(!0):y(!0),h.data&&Array.isArray(h.data)){i()&&_(h.data);return}if(ie&&w?.provider===`value`){i()&&_(w.items);return}if(!E||typeof E.find!=`function`)throw Error(`DataSource required for object/api providers`);let r=(0,n.buildExpandFields)(b?.fields),a=await E.find(D,{$filter:e.filter,$orderby:z(e.sort),...r.length>0?{$expand:r}:{}});i()&&_((0,n.extractRecords)(a))}catch(e){t?console.error(`[ObjectGantt] Failed to refresh data:`,e):i()&&te(e)}finally{t?se(!1):y(!1)}},[E,D,ie,w,e.filter,e.sort,b]);(0,t.useEffect)(()=>{O()},[O]),(0,t.useEffect)(()=>{!ie&&E&&(async()=>{try{if(!E||!D)return;let e=await E.getObjectSchema(D);x(e)}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[D,E,ie,w]);let k=(0,t.useMemo)(()=>{if(!T||!g.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:h,quickFilters:_}=T,v=b?.fields??{},y=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&&y.set(e.field,t)}let ee=(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=[ee(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=y.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=ee(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 g.map((n,r)=>{let o=n[e],p=n[t],g=m?n[m]:void 0,_=h?n[h]:void 0,v=g?new Date(g):void 0,y=_?new Date(_):void 0,ee=te(n),b=i?n[i]:0,x=a?n[a]:[],ne=s?n[s]:void 0;if(!ne){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,l.getSemanticColorName)(void 0,e);t&&(ne=(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:ee,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:R(x),parent:u?n[u]??null:void 0,type:d?Ue(n[d]):void 0,locked:f?!!n[f]:void 0,color:ne,borderColor:C,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:y&&!isNaN(y.getTime())?y:void 0,fields:re(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[g,T,b]),ue=(0,t.useMemo)(()=>{let e=T?.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)}}},[T?.groupByField,b]),de=(0,t.useMemo)(()=>{let e=T?.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)}}},[T?.assigneeField,b]),fe=(0,t.useMemo)(()=>{let e=T?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[T?.effortField]),me=(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]),he=(0,t.useMemo)(()=>le(T?.timeSegments),[T?.timeSegments]),ge=(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)},[]),_e=T?.quickFilters,[ve,ye]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!_e?.length||!a||typeof a.find!=`function`)return;let e=b?.fields??{},t=!1;return(async()=>{let r={};for(let t of _e){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||ye(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(_e),a,b]);let be=(0,t.useMemo)(()=>{if(!_e?.length)return[];let e=b?.fields??{};return _e.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(ve[t.field]?.length)i=ve[t.field];else{let e=new Map;for(let n of g){let r=ge(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}})},[_e,b,ve,g,ge]),xe=e.persistLayout===!1?void 0:`${e.objectName||(w?.provider===`object`?w.object:``)||`gantt`}:${e.viewName||`default`}`,A=xe?`gantt-layout:${xe}:filters`:null,[Se,Ce]=(0,t.useState)(()=>{if(!A||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(A)||`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{}}}),we=(0,t.useCallback)(()=>{if(!(!A||typeof window>`u`))try{window.localStorage.setItem(A,JSON.stringify(Se))}catch{}},[A,Se]),Te=(0,t.useCallback)((e,t)=>{Ce(n=>({...n,[e]:t}))},[]),Ee=(0,t.useCallback)(()=>Ce({}),[]),De=(0,t.useCallback)(e=>!!T?.objectField&&!String(e?.[T.objectField]??``).trim(),[T?.objectField]),Oe=(0,t.useCallback)(e=>{let t=(T?.objectField?String(e[T.objectField]??``).trim():``)||D,n=e.id??e._id;if(!t||n==null)return null;let r=D?(0,s.deriveRecordPageHref)(D,n):null;return{objectName:t,recordId:n,href:!D||t===D?r:r?.replace(`/${D}/record/`,`/${t}/record/`)??null}},[T?.objectField,D]),ke=(0,t.useMemo)(()=>{let e=Object.entries(Se).filter(([,e])=>e.length>0);if(!e.length)return k;let t=new Map(k.map(e=>[String(e.id),e])),n=new Set;for(let r of k){if(!e.every(([e,t])=>{let n=ge(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 k.filter(e=>n.has(String(e.id)))},[k,Se,ge]),Ae=(0,t.useMemo)(()=>{if(T?.autoZoomToFilter!==!1||!k.length)return null;let e=k[0].start.getTime(),t=k[0].end.getTime();for(let n of k)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[k,T?.autoZoomToFilter]),j=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},je=j.mode===`drawer`||j.mode===`modal`||j.mode===`split`||j.mode===`popover`,Me=(0,r.useNavigationOverlay)({navigation:j,objectName:e.objectName,onRowClick:je?void 0:p}),[Ne,N]=(0,t.useState)(null),Pe=Me.isOverlay&&Me.isOpen?Me.selectedRecord:null;(0,t.useEffect)(()=>{if(!Pe){N(null);return}let e=Oe(Pe);if(!e){N(null);return}let{objectName:t,recordId:n}=e;if(!(w?.provider===`api`||t!==D)||!a||typeof a.findOne!=`function`){N(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||N(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||N(null)}})(),()=>{i=!0}},[Pe,Oe,w?.provider,D,a]);let P=(0,t.useCallback)(async(e,t)=>{if(!T||!E||typeof E.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=T,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=g;_(e=>e.map(e=>String(e.id??e._id)===String(s)?{...e,...o}:e));try{await E.update(D,String(s),o),O({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),_(c),re(e)}},[T,E,D,g,O,re]),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)},F=(0,t.useCallback)(async(e,t,n)=>{let r=T?.dependenciesField;if(!r||!E||typeof E.update!=`function`)return;let i=Fe(t,n),a=g;_(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await E.update(D,String(e),{[r]:i}),O({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),_(a),re(e)}},[T,E,D,g,O,re]),Ie=(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=T?.dependenciesField;if(!a)return;let o=g.find(e=>String(e.id??e._id)===String(i))?.[a],s=R(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 F(i,o,f)},[T,g,F]),Re=(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=T?.dependenciesField;if(!i)return;let a=g.find(e=>String(e.id??e._id)===String(r))?.[i],o=R(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await F(r,a,c)},[T,g,F]),[ze,I]=(0,t.useState)(null),[Be,L]=(0,t.useState)(!1),Ve=(0,t.useCallback)(e=>{I(e)},[]),We=(0,t.useCallback)(async()=>{if(!ze)return;if(!E?.delete){I(null);return}let e=ze.data?.id??ze.data?._id??ze.id;if(e==null){I(null);return}L(!0);let t=g;_(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await E.delete(D,String(e))===!1)throw Error(S(`gantt.writeFailed`));I(null),O({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),_(t),I(null),re(e)}finally{L(!1)}},[ze,E,D,g,O,re,S]);return v?(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):ee?(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ee.message]})})}):T?(0,d.jsxs)(`div`,{className:(0,c.cn)(`flex h-full min-h-0 flex-col`,u),children:[be.length>0&&(0,d.jsx)(He,{filters:be,value:Se,onChange:Te,onClear:Ee,resultCount:ke.length,totalCount:k.length,labels:{all:`全部`,clear:`清除筛选`,empty:`无可选项`,resultSummary:(e,t)=>`显示 ${e} / ${t} 项任务`}}),(0,d.jsx)(`div`,{className:`flex-1 min-h-[420px]`,children:T?.resourceView&&de?(0,d.jsx)(Le,{tasks:ke,assignee:de,effort:fe,capacity:T?.capacity??1,viewMode:e.viewMode||`day`}):(0,d.jsx)(M,{tasks:ke,startDate:Ae?.start,endDate:Ae?.end,onTaskClick:e=>{De(e.data)||Me.handleClick(e.data),f?.(e.data)},onTaskUpdate:P,onTaskDelete:Ve,onDependencyCreate:T?.dependenciesField?Ie:void 0,onDependencyDelete:T?.dependenciesField?Re:void 0,markers:e.markers,autoSchedule:!!T?.dependenciesField,rescheduleOnConflict:!!T?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:me,shiftSegments:he,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:xe,onLayoutChange:A?we:void 0,groupBy:ue,defaultCollapsedDepth:T?.defaultCollapsedDepth,summaryExtent:T?.summaryExtent,interactions:T?.interactions,dependencyTypes:T?.dependencyTypes,timeZone:T?.timeZone,onBeforeTaskUpdate:m,exportFileName:String(T?.exportFileName??e.label??b?.label??e.objectName??``)||void 0,inlineEdit:!0,onRefresh:(w?.provider===`object`||w?.provider===`api`)&&typeof E?.find==`function`?()=>O({silent:!0}):void 0,refreshing:oe})}),Me.isOverlay&&Me.isOpen&&Me.selectedRecord&&(()=>{let t=Me.selectedRecord,n=Oe(t);if(!n||De(t))return null;let{objectName:r,recordId:i}=n,o=n.href??void 0,c=T?.titleField?String(t[T.titleField]??S(`gantt.drawer.fallbackTitle`)):S(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(T?.lockField?!!t[T.lockField]:!1),u=Ne?.key===`${r}:${i}`?Ne:null,f=u?.record??t,p=u?.schema??(r===D?b:void 0),m=u&&a?a:E;return(0,d.jsx)(s.RecordDetailDrawer,{open:!0,onClose:Me.close,title:c,record:f,objectName:r,recordId:i,dataSource:m??void 0,objectSchema:p,width:Me.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&&N(n=>n&&n.key===u.key?{...n,record:{...n.record,[e]:t}}:n),_(n=>n.map(n=>String(n.id??n._id)===String(i)?{...n,[e]:t}:n)),O({silent:!0})}},onDelete:l?void 0:async()=>{if(E?.delete){try{if(await E.delete(r,String(i))===!1)throw Error(S(`gantt.writeFailed`))}catch(e){throw re(e),e}_(e=>e.filter(e=>String(e.id??e._id)!==String(i)))}}})})(),(0,d.jsx)(c.AlertDialog,{open:!!ze,onOpenChange:e=>{!e&&!Be&&I(null)},children:(0,d.jsxs)(c.AlertDialogContent,{children:[(0,d.jsxs)(c.AlertDialogHeader,{children:[(0,d.jsx)(c.AlertDialogTitle,{children:S(`gantt.delete.title`)}),(0,d.jsx)(c.AlertDialogDescription,{children:ze?S(`gantt.delete.body`,{title:ze.title}):null})]}),(0,d.jsxs)(c.AlertDialogFooter,{children:[(0,d.jsx)(c.AlertDialogCancel,{disabled:Be,children:S(`gantt.delete.cancel`)}),(0,d.jsx)(c.AlertDialogAction,{onClick:e=>{e.preventDefault(),We()},disabled:Be,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(Be?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]}):(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},Ye=({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{};return(0,d.jsx)(Je,{schema:e,dataSource:t})};n.ComponentRegistry.register(`object-gantt`,Ye,{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`,Ye,{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=M,e.ObjectGantt=Je,e.ObjectGanttRenderer=Ye,e.QuickFilterBar=He,e.ResourceWorkload=Le,e.bandAt=ue,e.computeWorkload=N,e.normalizeDependencies=R,e.normalizeShiftSegments=le,e.normalizeTaskType=Ue,e.parseHHMM=O,e.shiftDayStart=k});
|
|
63
|
+
`}),(0,d.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,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":F(`gantt.toolbar.prevPeriod`),children:(0,d.jsx)(u.ChevronLeft,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":F(`gantt.toolbar.nextPeriod`),children:(0,d.jsx)(u.ChevronRight,{className:`h-4 w-4`})}),(0,d.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:q.start.toLocaleDateString(I,{month:`long`,year:`numeric`})}),R&&(0,d.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:F(`gantt.readOnlyHint`),children:[(0,d.jsx)(u.Lock,{className:`h-3 w-3`}),F(`gantt.readOnly`)]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":F(`gantt.toolbar.viewMode`),children:ye.map(e=>(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:(0,c.cn)(`h-6 px-1.5 sm:px-2 text-xs`,H===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>An(e),"aria-pressed":H===e,"data-testid":`gantt-view-mode-${e}`,children:F(`gantt.viewMode.${e}`)},e))}),(0,d.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(pt>15)et(Math.max(15,pt-10));else{let e=ye.indexOf(H);e<ye.length-1&&(An(ye[e+1]),et(Xe))}},"aria-label":F(`gantt.toolbar.zoomOut`),children:(0,d.jsx)(u.ZoomOut,{className:`h-3 w-3`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(pt<120)et(Math.min(120,pt+10));else{let e=ye.indexOf(H);e>0&&(An(ye[e-1]),et(Xe))}},"aria-label":F(`gantt.toolbar.zoomIn`),children:(0,d.jsx)(u.ZoomIn,{className:`h-3 w-3`})})]}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>ct(e=>!e),"aria-label":F(st?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":st,"data-testid":`gantt-toggle-task-list`,children:st?(0,d.jsx)(u.PanelLeft,{className:`h-4 w-4`}):(0,d.jsx)(u.PanelLeftClose,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:ar,disabled:ir==null,"aria-label":F(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:F(`gantt.toolbar.today`)}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:lr,"aria-label":F(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:F(`gantt.toolbar.thisWeek`)}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:ur,"aria-label":F(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:F(`gantt.toolbar.thisMonth`)}),se?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void se(),disabled:k,"aria-label":F(`gantt.toolbar.refresh`),"aria-busy":k,"data-testid":`gantt-refresh`,children:(0,d.jsx)(u.RefreshCw,{className:`h-4 w-4`})}):null,z?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Ht,disabled:!Wt,"aria-label":F(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,d.jsx)(u.Undo2,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Ut,disabled:!Gt,"aria-label":F(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,d.jsx)(u.Redo2,{className:`h-4 w-4`})})]}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>Kr(e=>!e),"aria-label":F(`gantt.toolbar.criticalPath`),"aria-pressed":Gr,"data-testid":`gantt-critical-path`,style:Gr?{color:$}:void 0,children:(0,d.jsx)(u.Activity,{className:`h-4 w-4`})}),Je&&z?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:$r,"aria-label":F(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,d.jsx)(u.Wand2,{className:`h-4 w-4`})}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:ri,"aria-label":F(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,d.jsx)(u.Download,{className:`h-4 w-4`})}),(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:ii,"aria-label":F(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,d.jsx)(u.FileDown,{className:`h-4 w-4`})}),oe||ie?(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:si,"aria-label":F(`gantt.toolbar.saveLayout`),"aria-pressed":ai,"data-testid":`gantt-save-layout`,style:ai?{color:$}:void 0,children:(0,d.jsx)(u.Save,{className:`h-4 w-4`})}):null,(0,d.jsx)(c.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:$n,"aria-label":F(Zn?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":Zn,"data-testid":`gantt-fullscreen`,children:Zn?(0,d.jsx)(u.Minimize2,{className:`h-4 w-4`}):(0,d.jsx)(u.Maximize2,{className:`h-4 w-4`})})]})]}),(0,d.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:Sn,"data-testid":`gantt-body`,children:[!st&&dt>0&&(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:dt-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=dt,r=Math.max(160,L-200),i=e=>{let i=Math.max(160,Math.min(n+(e.clientX-t),r));nt(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:()=>nt(null),children:(0,d.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,d.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,d.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:dt,minWidth:dt},children:[(0,d.jsx)(`div`,{className:`flex-1 truncate`,children:F(`gantt.column.taskName`)}),ht&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:F(`gantt.column.start`)}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:F(`gantt.column.end`)})]}),o&&(0,d.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},"aria-hidden":`true`,"data-testid":`gantt-header-open-spacer`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:Fn,children:(0,d.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:En},children:[(0,d.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:Nn.slice(Yn.start,Yn.end).map(e=>(0,d.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,d.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,d.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:J.slice(qn.start,qn.end).map((e,t)=>{let n=qn.start+t;return(0,d.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:Y[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,d.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&pt>=32&&(0,d.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,d.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,d.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:In,onScroll:Tr,style:{width:dt,minWidth:dt},role:`tree`,"aria-label":F(`gantt.aria.taskList`),children:[Q.startIdx>0&&(0,d.jsx)(`div`,{style:{height:Q.startIdx*V},"aria-hidden":`true`}),K.slice(Q.startIdx,Q.endIdx).map(e=>{let t=e.task,n=qe&>===t.id,r=vn.has(String(t.id)),i=pn!=null&&String(pn)===String(t.id);return(0,d.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:V,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:!!Ke&&!n&&!t.locked,onDragStart:Ke?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:Ke?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:Ke?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=Ct.get(n);r&&String(r.parent??``)===String(t.parent??``)&&Ke(r,t)}:void 0,onContextMenu:e=>gn(t,e),onClick:()=>{mn(t.id),n||cr(e.start,e.end,t.id)},onDoubleClick:()=>{n||(qe&&z&&!e.isSummary&&!t.locked?(_t(t.id),yt({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:t.end.toLocaleDateString(`en-CA`),progress:String(t.progress)})):o?.(t))},children:[(0,d.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,d.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(),bn(t.id)},"aria-expanded":!r,"aria-label":F(r?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:r?(0,d.jsx)(u.ChevronRight,{className:`h-3.5 w-3.5`}):(0,d.jsx)(u.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,d.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,d.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),n?(0,d.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:vt.title||``,onChange:e=>yt(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Pt([{task:t,changes:{title:vt.title,start:new Date(vt.start),end:new Date(vt.end),progress:Number(vt.progress)||0}}]),_t(null)):e.key===`Escape`&&_t(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,d.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,d.jsx)(`span`,{className:(0,c.cn)(`truncate`,e.isSummary&&`font-semibold`),children:t.title}),(0,d.jsxs)(`span`,{className:`text-[10px] text-muted-foreground gantt-sm-hidden`,children:[e.start.toLocaleDateString(I,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(I,{month:`numeric`,day:`numeric`})]})]})]}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!ht,style:ht?void 0:{display:`none`},children:n?(0,d.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:vt.start||``,onChange:e=>yt(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(I,{month:`numeric`,day:`numeric`})}),(0,d.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground hidden sm:block`,hidden:!ht,style:ht?void 0:{display:`none`},children:n?(0,d.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:vt.end||``,onChange:e=>yt(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(I,{month:`numeric`,day:`numeric`})}),o&&(0,d.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!n&&(0,d.jsx)(`button`,{type:`button`,title:F(`gantt.row.open`),"aria-label":F(`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,d.jsx)(u.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),Q.endIdx<K.length&&(0,d.jsx)(`div`,{style:{height:(K.length-Q.endIdx)*V},"aria-hidden":`true`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{Ln.current=e,Z.current=e},onScroll:wr,onTouchStart:tr,onTouchMove:nr,onTouchEnd:rr,"data-testid":`gantt-timeline`,children:(0,d.jsxs)(`div`,{className:`relative`,style:{width:En},children:[ir!=null&&(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:ir,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":F(`gantt.toolbar.today`),children:(0,d.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:F(`gantt.toolbar.today`)})}),Pn.map(e=>(0,d.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,d.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,d.jsxs)(`div`,{className:`relative`,ref:Qt,children:[(0,d.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:J.slice(qn.start,qn.end).map((e,t)=>{let n=qn.start+t;return(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:Y[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)})}),Cn&&x&&x.showMidnight&&(0,d.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:J.slice(qn.start,qn.end).map((e,t)=>{let n=qn.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();if(o<=i||o>=i+r)return null;let s=Y[n]+(o-i)/r*e.width;return(0,d.jsx)(`div`,{className:`absolute top-0 bottom-0`,style:{left:s,borderLeft:`1px dashed hsl(var(--muted-foreground) / 0.4)`},"data-testid":`gantt-midnight-${n}`,"aria-hidden":`true`},`midnight-${n}`)})}),Q.startIdx>0&&(0,d.jsx)(`div`,{style:{height:Q.startIdx*V},"aria-hidden":`true`}),K.slice(Q.startIdx,Q.endIdx).map((e,n)=>{let r=e.task,i=Q.startIdx+n,a=Jr(r.id),o=Er(e.start,e.end),s=ne&&r.baselineStart&&r.baselineEnd?Er(r.baselineStart,r.baselineEnd):null,l=s?(0,d.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:s.left,width:Math.max(2,s.width),top:Br,height:zr,backgroundColor:Vr,border:`1px solid ${Hr}`},"data-testid":`gantt-baseline-${r.id}`,"aria-hidden":`true`}):null,u=W?.taskId===r.id,f=Or?.has(String(r.id))??!1,p=kr?.has(String(r.id))??!1,m=u||f||p?Ar(e):o,h=!!r.locked,g=!!z&&!e.isSummary&&!h,_=g&&Be,v=g&&Ve,y=g&&He,ee=_||v,te=R||h,b=G!=null&&G.targetId!=null&&String(G.targetId)===String(r.id)&&String(G.sourceId)!==String(r.id),x=G?e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;$t(e=>e&&Zt(e.sourceId,r)?{...e,targetId:r.id,targetEnd:n}:e)}:void 0,S=G?e=>{e.target===e.currentTarget&&$t(e=>e&&{...e,targetId:null,targetEnd:null})}:void 0,C=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/j)),w=(i+1)*V+300>Xn&&i*V>300,T=bt===r.id&&!W&&!qt&&!G?(0,d.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(m.left+8,4),...w?{bottom:V-8}:{top:V-8}},role:`tooltip`,"data-testid":`gantt-tooltip-${r.id}`,children:[(0,d.jsx)(`div`,{className:`font-semibold`,children:r.title}),r.fields&&r.fields.length>0?(0,d.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:r.fields.map((e,n)=>(0,d.jsxs)(t.Fragment,{children:[(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,d.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,d.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(I,{month:`short`,day:`numeric`}),` → `,e.end.toLocaleDateString(I,{month:`short`,day:`numeric`}),` · `,C,F(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),r.locked||R&&!z?(0,d.jsxs)(`div`,{className:`text-muted-foreground`,style:{marginTop:4},"data-testid":`gantt-tooltip-locked-${r.id}`,children:[`🚫 `,F(`gantt.lockedHint`)]}):null]}):null;if(r.type===`group`)return(0,d.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:S,children:T},r.id);if(e.isSummary){let t=r.color||`#0d9488`,n=re===`self`&&r.hasOwnDates!==!1,i=!!z&&Be&&!h,o=!!z&&Ve&&n&&!h;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:S,children:[l,(0,d.jsxs)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none group`,i&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Rn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Rr,height:Lr,cursor:i||o?void 0:te?`not-allowed`:`pointer`,backgroundColor:t,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0},"data-critical":a?`true`:void 0,"data-testid":`gantt-summary-bar-${r.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>xt(r.id),onMouseLeave:()=>xt(e=>e===r.id?null:e),onPointerMove:x,onPointerDown:t=>{if(t.button===0){if(o){let e=me(t.clientX,t.currentTarget.getBoundingClientRect());if(e!==`move`){Kt(r,e,t);return}}i&&Kt(r,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})}},onClick:()=>{Dt.current||mn(r.id)},onContextMenu:e=>gn(r,e),children:[(0,d.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)`}}),o&&m.width>=14&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:pe,height:Pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&Kt(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,d.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:pe,height:Pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&Kt(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),(0,d.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:r.title}),B&&!h&&[`start`,`end`].map(e=>{let t=G!=null&&String(G.sourceId)===String(r.id)&&G.sourceEnd===e,n=t||bt===r.id,i=n&&G==null;return(0,d.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:+!!n,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}-${r.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let n=Qt.current?.getBoundingClientRect();$t({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null})},onClick:e=>e.stopPropagation(),children:(0,d.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)})]}),u&&W&&(0,d.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(m.left,4),top:Rr+Lr+2},"data-testid":`gantt-summary-drag-chip-${r.id}`,children:[Ot(W).start.toLocaleDateString(I,{month:`numeric`,day:`numeric`}),` → `,Ot(W).end.toLocaleDateString(I,{month:`numeric`,day:`numeric`})]}),T]},r.id)}if(e.isMilestone){let e=Fr;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:S,children:[l,(0,d.jsx)(`div`,{className:(0,c.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,_&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Rn===r.id&&`gantt-flash z-10`),style:{left:m.left-e/2,top:(V-e)/2,width:e,height:e,cursor:_?void 0:te?`not-allowed`:`pointer`,backgroundColor:a?$:r.color||`#3b82f6`,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0},"data-critical":a?`true`:void 0,"data-testid":`gantt-milestone-${r.id}`,onMouseEnter:()=>xt(r.id),onMouseLeave:()=>xt(e=>e===r.id?null:e),onClick:()=>{Dt.current||mn(r.id)},onContextMenu:e=>gn(r,e),onPointerMove:x,onPointerDown:_?e=>{e.button===0&&Kt(r,`move`,e)}:void 0}),T]},r.id)}let E=qt&&qt.taskId===r.id?qt.value:r.progress;return(0,d.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:S,onMouseEnter:()=>xt(r.id),onMouseLeave:()=>xt(e=>e===r.id?null:e),children:[u&&(0,d.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:o.left,width:o.width,top:Mr,height:Nr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),l,(0,d.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`,ee&&`cursor-grab active:cursor-grabbing`,u&&`ring-2 ring-primary z-10`,b&&`ring-2 ring-primary`,Rn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Mr,height:Nr,cursor:ee?void 0:te?`not-allowed`:`pointer`,backgroundColor:r.color||`#3b82f6`,borderColor:a?$:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${$}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0},"data-critical":a?`true`:void 0,"data-testid":`gantt-task-bar-${r.id}`,onClick:()=>{Dt.current||mn(r.id)},onContextMenu:e=>gn(r,e),onPointerMove:x,onPointerDown:ee?e=>{if(e.button!==0)return;let t=me(e.clientX,e.currentTarget.getBoundingClientRect()),n=t!==`move`&&v?t:_?`move`:null;n&&Kt(r,n,e)}:void 0,children:[v&&m.width>=14&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:pe,height:Pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&Kt(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,d.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:pe,height:Pr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&Kt(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),E>0&&(0,d.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 pointer-events-none`,style:{width:`${E}%`,backgroundColor:`rgba(0, 0, 0, 0.2)`,borderTopLeftRadius:`var(--radius-sm)`,borderBottomLeftRadius:`var(--radius-sm)`}}),y&&m.width>=30&&(0,d.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`,qt?.taskId===r.id?`opacity-100`:`opacity-0 group-hover:opacity-100 transition-opacity`),style:{left:`${E}%`},"data-testid":`gantt-progress-handle-${r.id}`,onPointerDown:e=>{e.button===0&&(e.stopPropagation(),e.preventDefault(),Jt({taskId:r.id,originClientX:e.clientX,originProgress:r.progress,barWidth:m.width,value:r.progress}))},onClick:e=>e.stopPropagation(),children:(0,d.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))`}})}),B&&!h&&[`start`,`end`].map(e=>{let t=G!=null&&String(G.sourceId)===String(r.id)&&G.sourceEnd===e,n=t||bt===r.id,i=n&&G==null;return(0,d.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:+!!n,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}-${r.id}`,onPointerDown:t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault();let n=Qt.current?.getBoundingClientRect();$t({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null})},onClick:e=>e.stopPropagation(),children:(0,d.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,d.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:r.title}),(0,d.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:u?`${Ot(W).start.toLocaleDateString(I,{month:`numeric`,day:`numeric`})} → ${Ot(W).end.toLocaleDateString(I,{month:`numeric`,day:`numeric`})}`:`${Math.round(E)}%`})]}),T]},r.id)}),Q.endIdx<K.length&&(0,d.jsx)(`div`,{style:{height:(K.length-Q.endIdx)*V},"aria-hidden":`true`}),(jr.length>0||G)&&(0,d.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:En,height:Xn,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,d.jsxs)(`defs`,{children:[(0,d.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,d.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,d.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,d.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:$})})]}),jr.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<Q.startIdx-6||n>Q.endIdx+6)return null;let r=Ur(e);if(!r)return null;let i=Wr!=null&&(String(e.sourceId)===String(Wr)||String(e.targetId)===String(Wr)),a=qr?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(Ge||B);return(0,d.jsxs)(t.Fragment,{children:[(0,d.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,d.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=>_n(e.sourceId,e.targetId,e.type,t)})]},e.key)}),G&&(()=>{let e=K.findIndex(e=>String(e.task.id)===String(G.sourceId));if(e<0)return null;let t=Ar(K[e]),n=K[e].isMilestone?t.left+(G.sourceEnd===`start`?-Ir:Ir):G.sourceEnd===`start`?t.left:t.left+t.width,r=e*V+V/2;return(0,d.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(G.x)} ${Math.round(G.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),G&&(()=>{let e=N.find(e=>String(e.id)===String(G.sourceId));if(!e)return null;let t=G.targetId==null?null:N.find(e=>String(e.id)===String(G.targetId)),n=e=>F(`gantt.linkEnd.${e}`),r=t?`${e.title} (${n(G.sourceEnd)}) → ${t.title} (${n(G.targetEnd??`start`)})`:`${e.title} (${n(G.sourceEnd)})`;return(0,d.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:G.x+12,top:G.y+12},"data-testid":`gantt-link-draft-hint`,children:r})})()]})]})}),(0,d.jsx)(`div`,{ref:hr,className:`shrink-0 border-l bg-card/95 select-none`,style:{width:14,display:`none`},"data-testid":`gantt-vscrollbar`,children:(0,d.jsx)(`div`,{ref:gr,className:`relative h-full`,onPointerDown:Cr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`vertical`,children:(0,d.jsx)(`div`,{ref:_r,className:`absolute rounded-full`,style:{left:2,right:2,top:0,height:0,backgroundColor:`rgba(130,130,130,0.55)`,cursor:`grab`},"data-testid":`gantt-vscrollbar-thumb`,onPointerDown:Sr})})})]}),(0,d.jsx)(`div`,{ref:dr,className:`shrink-0 border-t bg-card/95 select-none`,style:{position:`sticky`,bottom:0,zIndex:30,display:`none`},"data-testid":`gantt-hscrollbar`,children:(0,d.jsx)(`div`,{ref:fr,className:`relative`,style:{marginLeft:dt,height:14},onPointerDown:xr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`horizontal`,children:(0,d.jsx)(`div`,{ref:pr,className:`absolute rounded-full`,style:{top:2,bottom:2,left:0,width:0,backgroundColor:`rgba(130,130,130,0.55)`,cursor:`grab`},"data-testid":`gantt-hscrollbar-thumb`,onPointerDown:br})})})]}),tn&&(()=>{let e=N.find(e=>String(e.id)===String(tn.taskId));if(!e)return null;let t=K.find(e=>String(e.task.id)===String(tn.taskId)),n=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,d.jsxs)(`div`,{ref:rn,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:tn.x,top:tn.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[o&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-view`,onClick:()=>{nn(null),o(e)},children:F(`gantt.menu.view`)}),qe&&z&&t&&!t.isSummary&&!e.locked&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-edit`,onClick:()=>{nn(null),_t(e.id),yt({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:e.end.toLocaleDateString(`en-CA`),progress:String(e.progress)})},children:F(`gantt.menu.edit`)}),B&&t&&!t.isMilestone&&!e.locked&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let t=tn;nn(null),dn(``),ln({x:t.x,y:t.y,taskId:e.id,relation:`pred`})},children:F(`gantt.menu.addPredecessor`)}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:n,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let t=tn;nn(null),dn(``),ln({x:t.x,y:t.y,taskId:e.id,relation:`succ`})},children:F(`gantt.menu.addSuccessor`)})]}),We&&!e.locked&&(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,c.cn)(n,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{nn(null),We(e)},children:F(`gantt.menu.delete`)})]})})(),an&&(()=>{let e=N.find(e=>String(e.id)===String(an.sourceId)),t=N.find(e=>String(e.id)===String(an.targetId));if(!e||!t)return null;let n=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`,r=[`fs`,`ss`,`ff`,`sf`],i=!!t.locked;return(0,d.jsxs)(`div`,{ref:sn,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:an.x,top:an.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,d.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[e.title,` → `,t.title]}),i&&(0,d.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,F(`gantt.lockedHint`)]}),B&&ce&&r.map(r=>(0,d.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":an.type===r,disabled:i,className:(0,c.cn)(n,an.type===r&&`font-semibold`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${r}`,onClick:()=>{i||(on(null),r!==an.type&&B(e,t,r))},children:[an.type===r?`✓ `:`\xA0\xA0`,F(`gantt.linkType.${r}`)]},r)),Ge&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`my-1 border-t`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:i,className:(0,c.cn)(n,`text-destructive`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{i||(on(null),Ge(e,t))},children:F(`gantt.menu.removeDependency`)})]})]})})(),cn&&B&&(()=>{let e=N.find(e=>String(e.id)===String(cn.taskId));if(!e)return null;let t=new Set(jr.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),n=N.filter(n=>{if(String(n.id)===String(e.id)||n.type===`group`||n.locked)return!1;let r=cn.relation===`pred`?`${String(n.id)}->${String(e.id)}`:`${String(e.id)}->${String(n.id)}`;return!t.has(r)}),r=un.trim().toLowerCase(),i=r?n.filter(e=>String(e.title??``).toLowerCase().includes(r)):n;return(0,d.jsxs)(`div`,{ref:fn,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:cn.x,top:cn.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,d.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:cn.relation===`pred`?F(`gantt.menu.addPredecessor`):F(`gantt.menu.addSuccessor`)}),(0,d.jsx)(`div`,{className:`px-2 pb-1`,children:(0,d.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:un,onChange:e=>dn(e.target.value),placeholder:F(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),i.length===0?(0,d.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:F(`gantt.menu.noCandidates`)}):i.map(t=>(0,d.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-${t.id}`,onClick:()=>{ln(null),cn.relation===`pred`?B(t,e,`fs`):B(e,t,`fs`)},children:t.title},String(t.id)))]})})(),Yr&&(0,d.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-autoschedule-overlay`,onClick:()=>Xr(null),children:(0,d.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-autoschedule-dialog`,onClick:e=>e.stopPropagation(),children:[(0,d.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-autoschedule-title`,children:F(`gantt.autoScheduleDlg.title`)}),(0,d.jsxs)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:[F(`gantt.autoScheduleDlg.body`).replace(`{count}`,String(Yr.changes.length)),Yr.skipped>0&&(0,d.jsxs)(d.Fragment,{children:[` `,(0,d.jsx)(`span`,{"data-testid":`gantt-autoschedule-skipped`,children:F(`gantt.autoScheduleDlg.skipped`).replace(`{count}`,String(Yr.skipped))})]})]}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,className:`px-3 py-1.5 text-sm rounded-md border hover:bg-accent outline-none`,"data-testid":`gantt-autoschedule-cancel`,onClick:()=>Xr(null),children:F(`gantt.autoScheduleDlg.cancel`)}),(0,d.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-autoschedule-confirm`,onClick:ei,children:F(`gantt.autoScheduleDlg.confirm`)})]})]})}),Zr&&(0,d.jsx)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-[60] rounded-md border bg-popover text-popover-foreground px-3 py-1.5 text-sm shadow-md`,role:`status`,"data-testid":`gantt-autoschedule-clean`,children:F(`gantt.autoScheduleDlg.none`)}),Ft&&(0,d.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>It(null),children:(0,d.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,d.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:F(`gantt.conflict.title`)}),(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:F(`gantt.conflict.body`).replace(`{count}`,String(Ft.length))}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,d.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:()=>It(null),children:F(`gantt.conflict.cancel`)}),(0,d.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:Bt,children:F(`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 P(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 Ne={day:26,week:56,month:76,quarter:88,year:104},F=48,Pe=34,I=180;function Fe(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 Ie({tasks:e,assignee:n,effort:r,capacity:i=1,viewMode:a=`day`,unassignedLabel:o=`Unassigned`,className:s}){let{t:c,language:l}=fe(),u=l||void 0,f=Ne[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=Ce(t,a),i=Te(Ce(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=Te(r,1,a);o.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:Fe(r,a,u)}),r=e}return o},[e,a,u]),m=t.useMemo(()=>P(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*f;return e.length?(0,d.jsx)(`div`,{className:s,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,d.jsxs)(`div`,{style:{display:`flex`,minWidth:I+g},children:[(0,d.jsxs)(`div`,{style:{width:I,flexShrink:0},children:[(0,d.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,d.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:F,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,d.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,d.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,d.jsxs)(`div`,{style:{flex:1},children:[(0,d.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:p.map((e,t)=>(0,d.jsx)(`div`,{style:{width:f,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=Pe*(1-Math.min(e.capacity/h,1));return(0,d.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:F,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,d.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:14/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,Pe*Math.min(t.load/h,1));return(0,d.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:f,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:14/2},children:t.load>0&&(0,d.jsx)(`div`,{style:{width:f-6,height:r,borderRadius:2,backgroundColor:t.overloaded?`hsl(var(--destructive))`:`hsl(var(--primary))`,opacity:t.overloaded?.9:.75}})},n)})]},e.key)})]})]})}):(0,d.jsx)(`div`,{className:s,"data-testid":`resource-workload`,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:c(`gantt.resource.empty`)})})}var Le={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},Re={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`},L={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)`},ze={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function R({checked:e}){return(0,d.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 Be({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,f=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,d.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,d.jsxs)(`button`,{type:`button`,style:{...Re,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,d.jsx)(`span`,{children:m}),(0,d.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,d.jsx)(`div`,{role:`listbox`,style:L,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,d.jsx)(`div`,{style:{...ze,cursor:`default`,opacity:.6},children:i.empty}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...ze,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>p(),children:[(0,d.jsx)(R,{checked:u}),(0,d.jsx)(`span`,{children:i.all})]}),(0,d.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,d.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...ze,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>f(t.value),children:[(0,d.jsx)(R,{checked:n}),(0,d.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var Ve=({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`,f=e.some(e=>(t[e.field]?.length??0)>0);return(0,d.jsxs)(`div`,{style:Le,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,d.jsx)(Be,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),f&&(0,d.jsx)(`button`,{type:`button`,style:{...Re,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,d.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function He(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 Ue={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 z(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=Ue[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 B(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 Ge(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 Ke(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,interactions:e.interactions,exportFileName:e.exportFileName,timeZone:e.timeZone,dependencyTypes:e.dependencyTypes},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:f,onRowClick:p,onBeforeTaskUpdate:m,...h})=>{let[g,_]=(0,t.useState)([]),[v,y]=(0,t.useState)(!0),[ee,te]=(0,t.useState)(null),[b,x]=(0,t.useState)(null),{currency:ne}=(0,o.useLocalization)(),{t:S}=fe(),C=(0,t.useCallback)(e=>{i.toast.error(S(`gantt.writeFailed`),{description:Ge(e)??void 0})},[S]),w=We(e),T=(0,t.useMemo)(()=>w,[JSON.stringify(w)]),E=Ke(e),re=T?.provider===`value`,ie=(0,t.useContext)(r.SchemaRendererContext)?.apiFetch,D=(0,t.useMemo)(()=>(0,n.resolveDataSource)(T,a??null,{fetch:ie}),[T,a,ie]),O=T?.provider===`object`?T.object:e.objectName??``,[ae,oe]=(0,t.useState)(!1),se=(0,t.useRef)(0),k=(0,t.useCallback)(async({silent:t=!1}={})=>{let r=++se.current,i=()=>se.current===r;try{if(t?oe(!0):y(!0),h.data&&Array.isArray(h.data)){i()&&_(h.data);return}if(re&&T?.provider===`value`){i()&&_(T.items);return}if(!D||typeof D.find!=`function`)throw Error(`DataSource required for object/api providers`);let r=(0,n.buildExpandFields)(b?.fields),a=await D.find(O,{$filter:e.filter,$orderby:B(e.sort),...r.length>0?{$expand:r}:{}});i()&&_((0,n.extractRecords)(a))}catch(e){t?console.error(`[ObjectGantt] Failed to refresh data:`,e):i()&&te(e)}finally{t?oe(!1):y(!1)}},[D,O,re,T,e.filter,e.sort,b]);(0,t.useEffect)(()=>{k()},[k]),(0,t.useEffect)(()=>{!re&&D&&(async()=>{try{if(!D||!O)return;let e=await D.getObjectSchema(O);x(e)}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[O,D,re,T]);let A=(0,t.useMemo)(()=>{if(!E||!g.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:h,quickFilters:_}=E,v=b?.fields??{},y=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&&y.set(e.field,t)}let ee=(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=[ee(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=y.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)}},C=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=ee(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 g.map((n,r)=>{let o=n[e],p=n[t],g=m?n[m]:void 0,_=h?n[h]:void 0,v=g?new Date(g):void 0,y=_?new Date(_):void 0,ee=te(n),b=i?n[i]:0,x=a?n[a]:[],ne=s?n[s]:void 0;if(!ne){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,l.getSemanticColorName)(void 0,e);t&&(ne=(0,l.getSemanticHex)(t))}}let S=c?n[c]:void 0,w=S!=null&&S!==``?(0,l.getSemanticHex)(String(S),String(S)):void 0;return{id:n.id||n._id||`task-${r}`,title:ee,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:z(x),parent:u?n[u]??null:void 0,type:d?He(n[d]):void 0,locked:f?!!n[f]:void 0,color:ne,borderColor:w,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:y&&!isNaN(y.getTime())?y:void 0,fields:C(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[g,E,b]),le=(0,t.useMemo)(()=>{let e=E?.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)}}},[E?.groupByField,b]),ue=(0,t.useMemo)(()=>{let e=E?.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)}}},[E?.assigneeField,b]),de=(0,t.useMemo)(()=>{let e=E?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[E?.effortField]),pe=(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]),me=(0,t.useMemo)(()=>ce(E?.timeSegments),[E?.timeSegments]),he=(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)},[]),ge=E?.quickFilters,[_e,ve]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!ge?.length||!a||typeof a.find!=`function`)return;let e=b?.fields??{},t=!1;return(async()=>{let r={};for(let t of ge){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=await a.find(s,{$top:1e3}),i=(0,n.extractRecords)(e);r[t.field]=i.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||ve(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(ge),a,b]);let ye=(0,t.useMemo)(()=>{if(!ge?.length)return[];let e=b?.fields??{};return ge.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(_e[t.field]?.length)i=_e[t.field];else{let e=new Map;for(let n of g){let r=he(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}})},[ge,b,_e,g,he]),be=e.persistLayout===!1?void 0:`${e.objectName||(T?.provider===`object`?T.object:``)||`gantt`}:${e.viewName||`default`}`,j=be?`gantt-layout:${be}:filters`:null,[xe,Se]=(0,t.useState)(()=>{if(!j||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(j)||`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{}}}),Ce=(0,t.useCallback)(()=>{if(!(!j||typeof window>`u`))try{window.localStorage.setItem(j,JSON.stringify(xe))}catch{}},[j,xe]),we=(0,t.useCallback)((e,t)=>{Se(n=>({...n,[e]:t}))},[]),Te=(0,t.useCallback)(()=>Se({}),[]),Ee=(0,t.useCallback)(e=>!!E?.objectField&&!String(e?.[E.objectField]??``).trim(),[E?.objectField]),De=(0,t.useCallback)(e=>{let t=(E?.objectField?String(e[E.objectField]??``).trim():``)||O,n=e.id??e._id;if(!t||n==null)return null;let r=O?(0,s.deriveRecordPageHref)(O,n):null;return{objectName:t,recordId:n,href:!O||t===O?r:r?.replace(`/${O}/record/`,`/${t}/record/`)??null}},[E?.objectField,O]),Oe=(0,t.useMemo)(()=>{let e=Object.entries(xe).filter(([,e])=>e.length>0);if(!e.length)return A;let t=new Map(A.map(e=>[String(e.id),e])),n=new Set;for(let r of A){if(!e.every(([e,t])=>{let n=he(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 A.filter(e=>n.has(String(e.id)))},[A,xe,he]),ke=(0,t.useMemo)(()=>{if(E?.autoZoomToFilter!==!1||!A.length)return null;let e=A[0].start.getTime(),t=A[0].end.getTime();for(let n of A)e=Math.min(e,n.start.getTime()),t=Math.max(t,n.end.getTime());return{start:new Date(e),end:new Date(t)}},[A,E?.autoZoomToFilter]),M=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},Ae=M.mode===`drawer`||M.mode===`modal`||M.mode===`split`||M.mode===`popover`,je=(0,r.useNavigationOverlay)({navigation:M,objectName:e.objectName,onRowClick:Ae?void 0:p}),[Me,P]=(0,t.useState)(null),Ne=je.isOverlay&&je.isOpen?je.selectedRecord:null;(0,t.useEffect)(()=>{if(!Ne){P(null);return}let e=De(Ne);if(!e){P(null);return}let{objectName:t,recordId:n}=e;if(T?.provider!==`api`&&t===O||!a||typeof a.findOne!=`function`){P(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||P(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||P(null)}})(),()=>{i=!0}},[Ne,De,T?.provider,O,a]);let F=(0,t.useCallback)(async(e,t)=>{if(!E||!D||typeof D.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=E,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=g;_(e=>e.map(e=>String(e.id??e._id)===String(s)?{...e,...o}:e));try{await D.update(O,String(s),o),k({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),_(c),C(e)}},[E,D,O,g,k,C]),Pe=(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)},I=(0,t.useCallback)(async(e,t,n)=>{let r=E?.dependenciesField;if(!r||!D||typeof D.update!=`function`)return;let i=Pe(t,n),a=g;_(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await D.update(O,String(e),{[r]:i}),k({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),_(a),C(e)}},[E,D,O,g,k,C]),Fe=(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=E?.dependenciesField;if(!a)return;let o=g.find(e=>String(e.id??e._id)===String(i))?.[a],s=z(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 I(i,o,f)},[E,g,I]),Le=(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=E?.dependenciesField;if(!i)return;let a=g.find(e=>String(e.id??e._id)===String(r))?.[i],o=z(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await I(r,a,c)},[E,g,I]),[Re,L]=(0,t.useState)(null),[ze,R]=(0,t.useState)(!1),Be=(0,t.useCallback)(e=>{L(e)},[]),Ue=(0,t.useCallback)(async()=>{if(!Re)return;if(!D?.delete){L(null);return}let e=Re.data?.id??Re.data?._id??Re.id;if(e==null){L(null);return}R(!0);let t=g;_(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await D.delete(O,String(e))===!1)throw Error(S(`gantt.writeFailed`));L(null),k({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),_(t),L(null),C(e)}finally{R(!1)}},[Re,D,O,g,k,C,S]);return v?(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):ee?(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ee.message]})})}):E?(0,d.jsxs)(`div`,{className:(0,c.cn)(`flex h-full min-h-0 flex-col`,u),children:[ye.length>0&&(0,d.jsx)(Ve,{filters:ye,value:xe,onChange:we,onClear:Te,resultCount:Oe.length,totalCount:A.length,labels:{all:S(`gantt.quickFilter.all`),clear:S(`gantt.quickFilter.clear`),empty:S(`gantt.quickFilter.empty`),resultSummary:(e,t)=>S(`gantt.quickFilter.resultSummary`).replace(`{shown}`,String(e)).replace(`{total}`,String(t))}}),(0,d.jsx)(`div`,{className:`flex-1 min-h-[420px]`,children:E?.resourceView&&ue?(0,d.jsx)(Ie,{tasks:Oe,assignee:ue,effort:de,capacity:E?.capacity??1,viewMode:e.viewMode||`day`}):(0,d.jsx)(N,{tasks:Oe,startDate:ke?.start,endDate:ke?.end,onTaskClick:e=>{Ee(e.data)||je.handleClick(e.data),f?.(e.data)},onTaskUpdate:F,onTaskDelete:Be,onDependencyCreate:E?.dependenciesField?Fe:void 0,onDependencyDelete:E?.dependenciesField?Le:void 0,markers:e.markers,autoSchedule:!!E?.dependenciesField,rescheduleOnConflict:!!E?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:pe,shiftSegments:me,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:be,onLayoutChange:j?Ce:void 0,groupBy:le,defaultCollapsedDepth:E?.defaultCollapsedDepth,summaryExtent:E?.summaryExtent,interactions:E?.interactions,dependencyTypes:E?.dependencyTypes,timeZone:E?.timeZone,onBeforeTaskUpdate:m,exportFileName:String(E?.exportFileName??e.label??b?.label??e.objectName??``)||void 0,inlineEdit:!0,onRefresh:(T?.provider===`object`||T?.provider===`api`)&&typeof D?.find==`function`?()=>k({silent:!0}):void 0,refreshing:ae})}),je.isOverlay&&je.isOpen&&je.selectedRecord&&(()=>{let t=je.selectedRecord,n=De(t);if(!n||Ee(t))return null;let{objectName:r,recordId:i}=n,o=n.href??void 0,c=E?.titleField?String(t[E.titleField]??S(`gantt.drawer.fallbackTitle`)):S(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(E?.lockField?!!t[E.lockField]:!1),u=Me?.key===`${r}:${i}`?Me:null,f=u?.record??t,p=u?.schema??(r===O?b:void 0),m=u&&a?a:D;return(0,d.jsx)(s.RecordDetailDrawer,{open:!0,onClose:je.close,title:c,record:f,objectName:r,recordId:i,dataSource:m??void 0,objectSchema:p,width:je.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=Ge(e);throw t?Error(t):e}u&&P(n=>n&&n.key===u.key?{...n,record:{...n.record,[e]:t}}:n),_(n=>n.map(n=>String(n.id??n._id)===String(i)?{...n,[e]:t}:n)),k({silent:!0})}},onDelete:l?void 0:async()=>{if(D?.delete){try{if(await D.delete(r,String(i))===!1)throw Error(S(`gantt.writeFailed`))}catch(e){throw C(e),e}_(e=>e.filter(e=>String(e.id??e._id)!==String(i)))}}})})(),(0,d.jsx)(c.AlertDialog,{open:!!Re,onOpenChange:e=>{!e&&!ze&&L(null)},children:(0,d.jsxs)(c.AlertDialogContent,{children:[(0,d.jsxs)(c.AlertDialogHeader,{children:[(0,d.jsx)(c.AlertDialogTitle,{children:S(`gantt.delete.title`)}),(0,d.jsx)(c.AlertDialogDescription,{children:Re?S(`gantt.delete.body`,{title:Re.title}):null})]}),(0,d.jsxs)(c.AlertDialogFooter,{children:[(0,d.jsx)(c.AlertDialogCancel,{disabled:ze,children:S(`gantt.delete.cancel`)}),(0,d.jsx)(c.AlertDialogAction,{onClick:e=>{e.preventDefault(),Ue()},disabled:ze,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(ze?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]}):(0,d.jsx)(`div`,{className:u,children:(0,d.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,d.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,d.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=N,e.ObjectGantt=qe,e.ObjectGanttRenderer=Je,e.QuickFilterBar=Ve,e.ResourceWorkload=Ie,e.bandAt=le,e.computeWorkload=P,e.normalizeDependencies=z,e.normalizeShiftSegments=ce,e.normalizeTaskType=He,e.parseHHMM=k,e.shiftDayStart=A});
|