@object-ui/plugin-gantt 17.7.0 → 18.0.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 +483 -0
- package/README.md +9 -5
- package/dist/GanttView.d.ts.map +1 -1
- package/dist/ObjectGantt.d.ts +4 -3
- package/dist/ObjectGantt.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1308 -1338
- package/dist/index.umd.cjs +3 -3
- package/package.json +11 -11
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("@objectstack/spec/data"),require("@object-ui/i18n"),require("@object-ui/plugin-detail"),require("@object-ui/permissions"),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`,`@objectstack/spec/data`,`@object-ui/i18n`,`@object-ui/plugin-detail`,`@object-ui/permissions`,`@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._objectstack_spec_data,e._object_ui_i18n,e._object_ui_plugin_detail,e._object_ui_permissions,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,f,p){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var m=Object.create,h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,b=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!y.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:m(v(e)),b(t||!e||!e.__esModule||!y.call(e,`default`)?h(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var ee=864e5,te=e=>String(e).padStart(2,`0`),ne=e=>`${e.getFullYear()}-${te(e.getMonth()+1)}-${te(e.getDate())}`;function re(e,t){if(t.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}return!(t.holidays&&t.holidays.has(ne(e)))}function x(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function S(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function ie(e,t){let n=x(e);for(;!re(n,t);)n=S(n,1);return n.getTime()}function C(e,t,n){if(t<=e)return 0;let r=0,i=x(e),a=x(t).getTime();for(;i.getTime()<a;)re(i,n)&&r++,i=S(i,1);return r}function w(e,t,n){if(t<=0)return x(e).getTime();let r=x(e),i=t;for(;i>0;)re(r,n)&&i--,r=S(r,1);return r.getTime()}function T(e,t,n){if(t<=0)return x(e).getTime();let r=x(e),i=t;for(;i>0;)r=S(r,-1),re(r,n)&&i--;return r.getTime()}var E=e=>String(e);function ae(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function D(e){let t=new Set(e.map(e=>E(e.id))),n=[];for(let r of e){let e=E(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=E(a);o!==e&&t.has(o)&&n.push({pred:o,succ:e,type:ae(r?i.type:void 0)})}}return n}function O(e){let t=new Set;for(let n of e)n.parent!=null&&n.parent!==``&&t.add(E(n.parent));return t}function oe(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 se(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?C(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/ee;r.set(E(n.id),Number.isFinite(e)&&e>0?e:0)}let i=D(e),a=e.map(e=>E(e.id)),{order:o,hasCycle:s}=oe(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 ce(e,t,n){if(!e.length)return{changes:[],skippedLocked:[]};let r=D(e),i=e.map(e=>E(e.id)),{order:a,hasCycle:o}=oe(i,r);if(o)return{changes:[],skippedLocked:[]};let s=O(e),c=new Map;for(let t of e)c.set(E(t.id),t);let l=new Map;for(let t of e){if(t.parent==null||t.parent===``)continue;let e=E(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(E(t.id),t.start.getTime()),m.set(E(t.id),t.end.getTime());let h=[];for(let e of a){let r=c.get(e);if(!r)continue;let i=t?C(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?T(r,i,t):r-i;break;case`sf`:a=t?T(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=ie(o,t);p.set(e,n),m.set(e,w(n,i,t))}else p.set(e,o),m.set(e,o+i)}}if(u)for(let t of e){let e=E(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=E(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=E(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 k(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 le=6e4;1440*le;var ue=1440;function A(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 de(e){if(!e||!Array.isArray(e.bands)||e.bands.length===0)return null;let t=A(e.dayStart)??0,n=[];for(let t=0;t<e.bands.length;t++){let r=e.bands[t],i=A(r.start),a=A(r.end);if(i==null||a==null||!r.label)return null;let o=(a-i+ue)%ue||ue;n.push({key:r.key??`band${t}`,label:r.label,color:r.color,durMs:o*le})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function fe(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 j(e,t){if(t.bands.length===0)return null;let n=fe(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]}function pe(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 me(e){let t={delta:0,to:e=>e,from:e=>e,now:()=>new Date};if(!e)return t;try{pe(e,new Date)}catch{return console.warn(`[GanttView] invalid timeZone "${e}" — falling back to the browser zone`),t}let n=t=>pe(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))}}var he=18e5;function M(e,t,n){let r=t.getTime(),i=new Map,a=t=>{let n=i.get(t);return n===void 0&&(n=e(new Date(t)).getTime(),i.set(t,n)),n},o=r-(a(r)-r);if(n===`any`&&a(o)===r)return new Date(o);let s=new Set([o]);for(let e=-6;e<=6;e++){let t=o+e*he;s.add(r-(a(t)-t))}let c=[...s].filter(e=>a(e)===r).sort((e,t)=>e-t);if(c.length>0)return new Date(n===`latest`?c[c.length-1]:c[0]);let l=[...s].filter(e=>a(e)>r).sort((e,t)=>a(e)-a(t));return new Date(l.length>0?l[0]:o)}function N(e,t){return e.delta===0?t:M(e.to,t,`any`)}function ge(e,t){return e.delta===0?t:M(e.from,t,`latest`)}var _e={"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.aria.refreshing":`Refreshing…`,"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.link.rejected.self":`A task cannot depend on itself.`,"gantt.link.rejected.locked":`This row is locked and cannot take a new dependency.`,"gantt.link.rejected.group":`A summary row cannot take a dependency — link one of its tasks instead.`,"gantt.link.rejected.cycle":`That link would create a circular dependency.`,"gantt.conflict.title":`Schedule conflict`,"gantt.conflict.body":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected task(s)?`,"gantt.conflict.body_one":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected task?`,"gantt.conflict.body_other":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected tasks?`,"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.body_one":`Shift {{count}} task later to satisfy dependency links?`,"gantt.autoScheduleDlg.body_other":`Shift {{count}} tasks later to satisfy dependency links?`,"gantt.autoScheduleDlg.skipped":`{{count}} locked task(s) also violate links and were skipped.`,"gantt.autoScheduleDlg.skipped_one":`{{count}} locked task also violates links and was skipped.`,"gantt.autoScheduleDlg.skipped_other":`{{count}} locked tasks 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`},ve=new Intl.PluralRules(`en`);function P(e,t){let n=t?.count,r=(typeof n==`number`&&Number.isFinite(n)?_e[`${e}_${ve.select(n)}`]:void 0)||_e[e]||e;if(t)for(let[e,n]of Object.entries(t))r=r.split(`{{${e}}}`).join(String(n));return r}function ye(){let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:P(t,n)},language:e.language}}var be=8;function xe(e,t){if(t.width<=0)return`move`;let n=Math.min(be,t.width/3),r=e-t.left;return r<=n?`resize-left`:r>=t.width-n?`resize-right`:`move`}var Se=110,Ce=160,F=.375,we=320,Te=560;function Ee(e){return e<640?140:e<1024?220:Math.round(Math.min(Te,Math.max(we,e*F)))}var De=412;function Oe(e){return e>=De}function ke(e){return e<640?32:40}var I=[`day`,`week`,`month`,`quarter`,`year`],Ae={day:1,week:7,month:30.44,quarter:91.31,year:365.25},je=864e5;function Me(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 Ne(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 L(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 Pe(e,t){return(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())-Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()))/je}function Fe(e,t,n){if(n){let n=t.getTime()-e.getTime();return e=>new Date(e.getTime()+n)}let r=Pe(e,t);return e=>L(e,r,`day`)}function Ie(e,t){return t.getTime()>e.getTime()?(0,n.toInclusiveEndDay)(t):t}function Le(e,t){return t.end.getTime()>t.start.getTime()?(0,n.toDisplayEndDate)(e):(0,n.toDisplayDate)(e)}function Re(e,t){return t?`shiftDay`:e===`year`?`decade`:e===`month`||e===`quarter`?`year`:`month`}function ze(e,t,n=0){if(t===`shiftDay`)return fe(e,n);let r=new Date(e);return r.setHours(0,0,0,0),t===`month`?r.setDate(1):t===`year`?r.setMonth(0,1):(r.setMonth(0,1),r.setFullYear(Math.floor(r.getFullYear()/10)*10)),r}function Be(e,t,n){return n===`shiftDay`?L(e,t,`day`):n===`month`?L(e,t,`month`):L(e,t*(n===`decade`?10:1),`year`)}function Ve(e,t,n){return t===`decade`?`${Math.floor(e.getFullYear()/10)*10}s`:t===`year`?String(e.getFullYear()):t===`shiftDay`?e.toLocaleDateString(n,{year:`numeric`,month:`long`,day:`numeric`}):e.toLocaleDateString(n,{month:`long`,year:`numeric`})}function He(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 Ue(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 We(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("@object-ui/i18n"),require("sonner"),require("@objectstack/spec/ui"),require("@objectstack/spec/data"),require("@object-ui/plugin-detail"),require("@object-ui/permissions"),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`,`@object-ui/i18n`,`sonner`,`@objectstack/spec/ui`,`@objectstack/spec/data`,`@object-ui/plugin-detail`,`@object-ui/permissions`,`@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._object_ui_i18n,e.sonner,e._objectstack_spec_ui,e._objectstack_spec_data,e._object_ui_plugin_detail,e._object_ui_permissions,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,f,p){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var m=Object.create,h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,b=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!y.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:m(v(e)),b(t||!e||!e.__esModule||!y.call(e,`default`)?h(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var ee=864e5,te=e=>String(e).padStart(2,`0`),ne=e=>`${e.getFullYear()}-${te(e.getMonth()+1)}-${te(e.getDate())}`;function x(e,t){if(t.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}return!(t.holidays&&t.holidays.has(ne(e)))}function S(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function C(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function re(e,t){let n=S(e);for(;!x(n,t);)n=C(n,1);return n.getTime()}function w(e,t,n){if(t<=e)return 0;let r=0,i=S(e),a=S(t).getTime();for(;i.getTime()<a;)x(i,n)&&r++,i=C(i,1);return r}function T(e,t,n){if(t<=0)return S(e).getTime();let r=S(e),i=t;for(;i>0;)x(r,n)&&i--,r=C(r,1);return r.getTime()}function E(e,t,n){if(t<=0)return S(e).getTime();let r=S(e),i=t;for(;i>0;)r=C(r,-1),x(r,n)&&i--;return r.getTime()}var D=e=>String(e);function ie(e){return e===`ss`||e===`ff`||e===`sf`?e:`fs`}function O(e){let t=new Set(e.map(e=>D(e.id))),n=[];for(let r of e){let e=D(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=D(a);o!==e&&t.has(o)&&n.push({pred:o,succ:e,type:ie(r?i.type:void 0)})}}return n}function k(e){let t=new Set;for(let n of e)n.parent!=null&&n.parent!==``&&t.add(D(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 oe(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?w(n.start.getTime(),n.end.getTime(),t):(n.end.getTime()-n.start.getTime())/ee;r.set(D(n.id),Number.isFinite(e)&&e>0?e:0)}let i=O(e),a=e.map(e=>D(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 A(e,t,n){if(!e.length)return{changes:[],skippedLocked:[]};let r=O(e),i=e.map(e=>D(e.id)),{order:a,hasCycle:o}=ae(i,r);if(o)return{changes:[],skippedLocked:[]};let s=k(e),c=new Map;for(let t of e)c.set(D(t.id),t);let l=new Map;for(let t of e){if(t.parent==null||t.parent===``)continue;let e=D(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(D(t.id),t.start.getTime()),m.set(D(t.id),t.end.getTime());let h=[];for(let e of a){let r=c.get(e);if(!r)continue;let i=t?w(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?E(r,i,t):r-i;break;case`sf`:a=t?E(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=re(o,t);p.set(e,n),m.set(e,T(n,i,t))}else p.set(e,o),m.set(e,o+i)}}if(u)for(let t of e){let e=D(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=D(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=D(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 se(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 ce=6e4;1440*ce;var j=1440;function le(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 ue(e){if(!e||!Array.isArray(e.bands)||e.bands.length===0)return null;let t=le(e.dayStart)??0,n=[];for(let t=0;t<e.bands.length;t++){let r=e.bands[t],i=le(r.start),a=le(r.end);if(i==null||a==null||!r.label)return null;let o=(a-i+j)%j||j;n.push({key:r.key??`band${t}`,label:r.label,color:r.color,durMs:o*ce})}return{dayStartMin:t,bands:n,showMidnight:e.showMidnight!==!1}}function M(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 de(e,t){if(t.bands.length===0)return null;let n=M(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]}function fe(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 pe(e){let t={delta:0,to:e=>e,from:e=>e,now:()=>new Date};if(!e)return t;try{fe(e,new Date)}catch{return console.warn(`[GanttView] invalid timeZone "${e}" — falling back to the browser zone`),t}let n=t=>fe(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))}}var me=18e5;function N(e,t,n){let r=t.getTime(),i=new Map,a=t=>{let n=i.get(t);return n===void 0&&(n=e(new Date(t)).getTime(),i.set(t,n)),n},o=r-(a(r)-r);if(n===`any`&&a(o)===r)return new Date(o);let s=new Set([o]);for(let e=-6;e<=6;e++){let t=o+e*me;s.add(r-(a(t)-t))}let c=[...s].filter(e=>a(e)===r).sort((e,t)=>e-t);if(c.length>0)return new Date(n===`latest`?c[c.length-1]:c[0]);let l=[...s].filter(e=>a(e)>r).sort((e,t)=>a(e)-a(t));return new Date(l.length>0?l[0]:o)}function P(e,t){return e.delta===0?t:N(e.to,t,`any`)}function he(e,t){return e.delta===0?t:N(e.from,t,`latest`)}var ge={"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.aria.refreshing":`Refreshing…`,"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.link.rejected.self":`A task cannot depend on itself.`,"gantt.link.rejected.locked":`This row is locked and cannot take a new dependency.`,"gantt.link.rejected.group":`A summary row cannot take a dependency — link one of its tasks instead.`,"gantt.link.rejected.cycle":`That link would create a circular dependency.`,"gantt.conflict.title":`Schedule conflict`,"gantt.conflict.body":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected task(s)?`,"gantt.conflict.body_one":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected task?`,"gantt.conflict.body_other":`This move conflicts with dependency constraints. Auto-reschedule {{count}} affected tasks?`,"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.body_one":`Shift {{count}} task later to satisfy dependency links?`,"gantt.autoScheduleDlg.body_other":`Shift {{count}} tasks later to satisfy dependency links?`,"gantt.autoScheduleDlg.skipped":`{{count}} locked task(s) also violate links and were skipped.`,"gantt.autoScheduleDlg.skipped_one":`{{count}} locked task also violates links and was skipped.`,"gantt.autoScheduleDlg.skipped_other":`{{count}} locked tasks 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`},_e=new Intl.PluralRules(`en`);function F(e,t){let n=t?.count,r=(typeof n==`number`&&Number.isFinite(n)?ge[`${e}_${_e.select(n)}`]:void 0)||ge[e]||e;if(t)for(let[e,n]of Object.entries(t))r=r.split(`{{${e}}}`).join(String(n));return r}function ve(){let e=(0,r.useObjectTranslation)();return{t:(t,n)=>{let r=e.t(t,n);return typeof r==`string`&&r!==t?r:F(t,n)},language:e.language}}var ye=8;function be(e,t){if(t.width<=0)return`move`;let n=Math.min(ye,t.width/3),r=e-t.left;return r<=n?`resize-left`:r>=t.width-n?`resize-right`:`move`}var xe=110,Se=160,Ce=.375,we=320,I=560;function Te(e){return e<640?140:e<1024?220:Math.round(Math.min(I,Math.max(we,e*Ce)))}var Ee=412;function De(e){return e>=Ee}function Oe(e){return e<640?32:40}var ke=[`day`,`week`,`month`,`quarter`,`year`],Ae={day:1,week:7,month:30.44,quarter:91.31,year:365.25},je=864e5;function Me(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 Ne(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 L(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 Pe(e,t){return(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())-Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()))/je}function Fe(e,t,n){if(n){let n=t.getTime()-e.getTime();return e=>new Date(e.getTime()+n)}let r=Pe(e,t);return e=>L(e,r,`day`)}function Ie(e,t){return t.getTime()>e.getTime()?(0,n.toInclusiveEndDay)(t):t}function Le(e,t){return t.end.getTime()>t.start.getTime()?(0,n.toDisplayEndDate)(e):(0,n.toDisplayDate)(e)}function Re(e,t){return t?`shiftDay`:e===`year`?`decade`:e===`month`||e===`quarter`?`year`:`month`}function ze(e,t,n=0){if(t===`shiftDay`)return M(e,n);let r=new Date(e);return r.setHours(0,0,0,0),t===`month`?r.setDate(1):t===`year`?r.setMonth(0,1):(r.setMonth(0,1),r.setFullYear(Math.floor(r.getFullYear()/10)*10)),r}function Be(e,t,n){return n===`shiftDay`?L(e,t,`day`):n===`month`?L(e,t,`month`):L(e,t*(n===`decade`?10:1),`year`)}function Ve(e,t,n){return t===`decade`?`${Math.floor(e.getFullYear()/10)*10}s`:t===`year`?String(e.getFullYear()):t===`shiftDay`?e.toLocaleDateString(n,{year:`numeric`,month:`long`,day:`numeric`}):e.toLocaleDateString(n,{month:`long`,year:`numeric`})}function He(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 Ue(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 We(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 Ge(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 Ke=`gantt-layout:`;function qe(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(Ke+e);if(!t)return null;let n=JSON.parse(t),r=n.viewMode&&I.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(Ke+e,JSON.stringify(t))}catch{}}function R({tasks:e,viewMode:r,startDate:a,endDate:o,markers:c,onTaskClick:l,onTaskUpdate:d,onTaskDelete:m,onViewChange:h,onDependencyCreate:g,onBeforeDependencyCreate:_,onDependencyDelete:v,onTaskReorder:y,className:b,inlineEdit:ee=!1,autoSchedule:te=!1,rescheduleOnConflict:ne=!1,criticalPathDefault:re=!1,workingCalendar:x,shiftSegments:S,showBaselines:ie=!0,readOnly:C=!1,mobileReadOnly:w=!1,groupBy:T,ungroupedLabel:E=`Ungrouped`,defaultCollapsedDepth:ae,summaryExtent:D=`children`,persistLayoutKey:O,onLayoutChange:oe,onRefresh:le,refreshing:ue=!1,dependencyTypes:A=!0,timeZone:de,exportFileName:j,interactions:pe,onBeforeTaskUpdate:he}){let M=t.useMemo(()=>me(de),[de]),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]),ge=t.useMemo(()=>a&&M.delta!==0?M.to(a):a,[a,M]),_e=t.useMemo(()=>o&&M.delta!==0?M.to(o):o,[o,M]),ve=t.useMemo(()=>!c||M.delta===0?c:c.map(e=>typeof e.date==`string`&&(0,n.isRealCalendarDate)(e.date)?{...e,date:(0,n.toDisplayDate)(e.date)}:{...e,date:M.to((0,n.toDisplayDate)(e.date))}),[c,M]),{t:P}=ye(),F=(0,s.useDisplayLocale)(),we=t.useRef(null),{width:Te}=(0,u.useResizeObserver)(we),De=Te||(typeof window<`u`?window.innerWidth:1024),Ke=De<640,R=C||w&&Ke,Ye=pe?.move!==!1,Xe=pe?.resize!==!1,Ze=pe?.progress!==!1,Qe=pe?.link!==!1,z=t.useMemo(()=>{if(!R&&d)return M.delta===0?d:(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)),d(e,n)}},[R,d,M]),$e=R?void 0:m,B=R||!Qe?void 0:g,et=R||!Qe?void 0:v,tt=R?void 0:y,nt=!R&&ee,rt=!R&&te,it=!R&&ne,V=ke(De),at=t.useRef(void 0);at.current===void 0&&(at.current=qe(O));let ot=at.current,[st,ct]=t.useState(ot?ot.columnWidth:null),[lt,ut]=t.useState(ot?ot.taskListWidth??null:null),[H,dt]=t.useState(r&&I.includes(r)?r:ot?.viewMode??`day`);t.useEffect(()=>{r&&I.includes(r)&&dt(r)},[r]);let ft=t.useRef(null),pt=t.useRef(null),mt=t.useRef(!0),[U,ht]=t.useState(ot?ot.taskListCollapsed:!1),gt=t.useRef(!1);t.useEffect(()=>{!gt.current&&Ke&&(ht(!0),gt.current=!0)},[Ke]);let _t=Math.max(Ce,De-200),W=U?0:lt==null?Ee(De):Math.max(Ce,Math.min(lt,_t)),vt=t.useMemo(()=>{if(st!=null||_e||N.length===0)return null;let e=ge?new Date(ge):new Date(Math.min(...N.map(e=>e.start.getTime()))),t=new Date(Math.max(...N.map(e=>e.end.getTime())));ge||e.setDate(e.getDate()-7),t.setDate(t.getDate()+14),e=Me(e,H),t.setHours(23,59,59,999);let n=Math.max(1,(t.getTime()-e.getTime())/je),r=Math.max(0,De-W);if(r<=0)return null;let i=r/n*Ae[H];if(i<=Se)return null;let a=Math.min(i,r*.6);return a>Se?a:null},[st,N,ge,_e,H,De,W]),yt=st??vt??Se,bt=yt/Ae[H],xt=Oe(W),[St,Ct]=t.useState(null),[wt,Tt]=t.useState({}),[Et,Dt]=t.useState(null),Ot=t.useMemo(()=>{if(!T)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=T(n),i=r?String(r.key):`__ungrouped__`,a=r?r.label:E,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},[T,N,E]),kt=t.useMemo(()=>{let e=new Set(Ot.map(e=>String(e.id))),t=new Map;for(let n of Ot){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},[Ot]),At=t.useMemo(()=>{let e=new Map;for(let t of Ot)e.set(String(t.id),t);return e},[Ot]),jt=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of kt.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[kt]),[G,Mt]=t.useState(null),Nt=t.useRef(null);t.useEffect(()=>{Nt.current=G},[G]);let Pt=t.useRef(!1),Ft=t.useCallback(e=>{let t=H===`day`&&!!S&&S.bands.length>0,n=(e,t)=>Hn.current?Hn.current(e,t):L(e,t,`day`),r=new Date(e.originStart),i=new Date(e.originEnd);if(t&&S){let t=Math.min(...S.bands.map(e=>e.durMs));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}}let a=t=>Pe(t,n(t,e.unitDelta));if(e.mode===`move`){let t=a(e.originStart);r=L(e.originStart,t,`day`),i=L(e.originEnd,t,`day`)}else if(e.mode===`resize-left`){r=L(e.originStart,a(e.originStart),`day`);let t=L(i,-1,`day`);r.getTime()>t.getTime()&&(r=t)}else if(e.mode===`resize-right`){i=L(e.originEnd,a(e.originEnd),`day`);let t=L(r,1,`day`);i.getTime()<t.getTime()&&(i=t)}return{start:r,end:i}},[H,S]),It=e=>{let t=Ft(e);return Ie(t.start,t.end)},Lt=t.useRef(N);Lt.current=N;let Rt=t.useRef([]),zt=t.useRef([]),[Bt,Vt]=t.useState(0),Ht=t.useCallback(e=>{if(!z)return;let t=e.filter(e=>!e.task.locked);(async()=>{let e=t;if(he){let n=[];for(let e of t){let t;try{t=await he(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&&(Rt.current.push(n),zt.current=[],Vt(e=>e+1))})()},[z,he]),[Ut,Wt]=t.useState(null),Gt=t.useCallback(e=>{if(!S)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*je+S.dayStartMin*6e4;for(let t of S.bands){if(r>=e)return r;r+=t.durMs}}return e},[S]),Kt=t.useMemo(()=>({summaryExtent:D,snapStart:S?Gt:void 0}),[D,S,Gt]),qt=t.useCallback(e=>{if(!it)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}=ce(Lt.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),x,Kt),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&&Wt(r)},[it,x,Kt]),Jt=t.useCallback(()=>{if(!Ut)return;let e=Ut.map(e=>{let t=Lt.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&Ht(e),Wt(null)},[Ut,Ht]),Yt=t.useCallback((e,t)=>{if(z)for(let n of e){let e=Lt.current.find(e=>String(e.id)===n.taskId);e&&z(e,t===`undo`?n.before:n.after)}},[z]),Xt=t.useCallback(()=>{let e=Rt.current.pop();e&&(Yt(e,`undo`),zt.current.push(e),Vt(e=>e+1))},[Yt]),Zt=t.useCallback(()=>{let e=zt.current.pop();e&&(Yt(e,`redo`),Rt.current.push(e),Vt(e=>e+1))},[Yt]),{canUndo:Qt,canRedo:$t}=t.useMemo(()=>({canUndo:Rt.current.length>0,canRedo:zt.current.length>0}),[Bt]);t.useEffect(()=>{if(!G)return;let e=H===`day`&&!!S&&S.bands.length>0,t=e&&S?bt*Math.min(...S.bands.map(e=>e.durMs))/je:bt,n=e=>{let n=Nt.current;if(!n)return;let r=Math.round((e.clientX-n.originClientX)/Math.max(t,1));r!==n.unitDelta&&Mt({...n,unitDelta:r})},r=()=>{let t=Nt.current;if(t){if(t.unitDelta!==0){let n=N.find(e=>e.id===t.taskId);if(n&&z){let{start:r,end:i}=Ft(t);if(t.group){let i=Fe(t.originStart,r,e),a=[n,...jt(n.id).filter(e=>!e.locked)].map(e=>({task:e,changes:{start:i(e.start),end:i(e.end)}}));Ht(a),qt(a)}else{let e=[{task:n,changes:{start:r,end:i}}];Ht(e),qt(e)}}Pt.current=!0,window.setTimeout(()=>{Pt.current=!1},0)}Mt(null)}};return window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r)}},[G,yt,bt,H,S,N,z,Ft,jt,Ht,qt]);let en=t.useCallback((e,t,n,r)=>{!z||e.data?.__group||e.locked||(n.stopPropagation(),n.preventDefault(),Mt({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]),[tn,nn]=t.useState(null),rn=t.useRef(null);t.useEffect(()=>{rn.current=tn},[tn]),t.useEffect(()=>{if(!tn)return;let e=e=>{let t=rn.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&&nn({...t,value:n})},t=()=>{let e=rn.current;if(e){if(e.value!==e.originProgress){let t=N.find(t=>t.id===e.taskId);t&&z&&Ht([{task:t,changes:{progress:e.value}}]),Pt.current=!0,window.setTimeout(()=>{Pt.current=!1},0)}nn(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)}},[tn,N,z,Ht]);let an=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]),on=t.useCallback((e,t)=>String(t.id)===String(e)?`self`:t.locked?`locked`:t.type===`group`?`group`:k(an,e,t.id)?`cycle`:null,[an]),sn=t.useCallback((e,t)=>on(e,t)===null,[on]),cn=t.useRef(null),[K,ln]=t.useState(null),un=t.useRef(null);t.useEffect(()=>{un.current=K},[K]),t.useEffect(()=>{if(!K)return;let e=e=>{let t=cn.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;ln(e=>e&&{...e,x:n,y:r})},t=()=>{let e=un.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=A?`${e.sourceEnd===`end`?`f`:`s`}${r===`end`?`f`:`s`}`:`fs`;t&&n&&sn(e.sourceId,n)&&(_?.(t,n,i)??!0)&&B(t,n,i)}else e&&e.rejectedReason&&B&&i.toast.error(P(`gantt.link.rejected.${e.rejectedReason}`));Pt.current=!0,window.setTimeout(()=>{Pt.current=!1},0),ln(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)}},[K,N,B,_,sn,A,P]);let[dn,fn]=t.useState(null),pn=t.useRef(null);t.useEffect(()=>{if(!dn)return;let e=e=>{pn.current&&e.target instanceof Node&&pn.current.contains(e.target)||fn(null)},t=e=>{e.key===`Escape`&&fn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[dn]);let[mn,hn]=t.useState(null),gn=t.useRef(null);t.useEffect(()=>{if(!mn)return;let e=e=>{gn.current&&e.target instanceof Node&&gn.current.contains(e.target)||hn(null)},t=e=>{e.key===`Escape`&&hn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[mn]);let[_n,vn]=t.useState(null),[yn,bn]=t.useState(``),xn=t.useRef(null);t.useEffect(()=>{if(!_n)return;let e=e=>{xn.current&&e.target instanceof Node&&xn.current.contains(e.target)||vn(null)},t=e=>{e.key===`Escape`&&vn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[_n]);let[Sn,Cn]=t.useState(null),wn=!!(l||z||B||$e),Tn=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),Cn(e.id),wn&&fn({x:t.clientX,y:t.clientY,taskId:e.id})},[wn]),En=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),(B||et)&&hn({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[B,et]),[Dn,On]=t.useState(()=>new Set(ot?.collapsedIds??[])),kn=t.useCallback(e=>{On(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),An=t.useRef(ot?.collapsedIds!=null);t.useEffect(()=>{if(An.current||ae==null||Ot.length===0)return;An.current=!0;let e=new Map(Ot.map(e=>[String(e.id),e])),t=new Set;for(let n of Ot){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 Ot){let i=String(e.id);t.has(i)&&n(e)>=ae&&r.add(i)}r.size&&On(e=>e.size?e:r)},[ae,Ot]);let q=t.useMemo(()=>{let e=new Set(Ot.map(e=>String(e.id))),t=new Map,n=[];for(let r of Ot){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(),je);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&&D===`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(Dn.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 Ot)o.has(String(e.id))||c(e,0);return a},[Ot,Dn,D]),jn=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?Zt():Xt();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),Zt();return}if(!q.length)return;let t=Sn==null?-1:q.findIndex(e=>String(e.task.id)===String(Sn));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?Math.min(q.length-1,t+1):Math.max(0,t<=0?0:t-1);Cn(q[n].task.id);let r=Q.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=q[t];e.key===`Enter`?(e.preventDefault(),l?.(n.task)):e.key===`Delete`||e.key===`Backspace`?$e&&(e.preventDefault(),$e(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&Dn.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!Dn.has(String(n.task.id)))&&(e.preventDefault(),kn(n.task.id))},[q,Sn,l,$e,Dn,kn,V,Xt,Zt]),J=t.useMemo(()=>{let e=ge?new Date(ge):M.now(),t=_e?new Date(_e):M.now();return!ge&&N.length>0&&(e=new Date(Math.min(...N.map(e=>e.start.getTime()))),e.setDate(e.getDate()-7)),!_e&&N.length>0&&(t=new Date(Math.max(...N.map(e=>e.end.getTime()))),t.setDate(t.getDate()+14)),e=H===`day`&&S&&S.bands.length>0?fe(e,S.dayStartMin):Me(e,H),t.setHours(23,59,59,999),{start:e,end:t}},[ge,_e,N,H,S,M]),Mn=H===`day`&&!!S&&S.bands.length>0,Nn=!Mn&&H===`day`&&!!x&&(!!x.skipWeekends||!!(x.holidays&&x.holidays.size)),Pn=t.useCallback(e=>{if(!x)return!0;if(x.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}if(x.holidays&&x.holidays.size){let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(x.holidays.has(t))return!1}return!0},[x]),Y=t.useMemo(()=>{let e=[];if(Mn&&S){let t=new Date(J.start);for(;t<=J.end;)for(let n of S.bands){let r=n.durMs/je*bt;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(J.start);for(;t<=J.end;){let n=L(t,1,H);if(Nn&&!Pn(t)){t=n;continue}let r=(n.getTime()-t.getTime())/je*bt,i,a;H===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(F,{weekday:`narrow`})):i=H===`week`?t.toLocaleDateString(F,{month:`numeric`,day:`numeric`}):H===`month`?t.toLocaleDateString(F,{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},[J,H,bt,F,Nn,Pn,Mn,S]),X=t.useMemo(()=>{let e=Array(Y.length+1),t=0;for(let n=0;n<Y.length;n++)e[n]=t,t+=Y[n].width;return e[Y.length]=t,e},[Y]),Fn=X[X.length-1],In=t.useMemo(()=>Y.map(e=>e.date.getTime()),[Y]),Ln=t.useMemo(()=>Y.map(e=>e.realMs==null?L(e.date,1,H).getTime()-e.date.getTime():e.realMs),[Y,H]),Z=t.useCallback(e=>{let t=Y.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;In[e]<=n?(a=e,r=e+1):i=e-1}let o=Ln[a]||864e5,s=(n-In[a])/o;return(Nn||Mn)&&(s=Math.max(0,Math.min(s,1))),X[a]+s*Y[a].width},[Y,In,Ln,X,Nn,Mn]),Rn=t.useCallback(e=>{let t=Y.length;if(t===0)return-1;let n=0,r=t-1,i=0;for(;n<=r;){let t=n+r>>1;X[t]<=e?(i=t,n=t+1):r=t-1}return i},[Y,X]),zn=t.useCallback(e=>{let t=Rn(e);if(t<0)return new Date(J.start);let n=Y[t].width||1,r=(e-X[t])/n;return new Date(In[t]+r*(Ln[t]||864e5))},[Rn,Y,In,Ln,X,J]),Bn=t.useCallback(e=>{let t=Q.current;pt.current==null&&t&&t.clientWidth>0&&(pt.current=zn(t.scrollLeft)),ft.current=pt.current,mt.current=!0,dt(e),h?.(e)},[h,zn]);t.useLayoutEffect(()=>{let e=ft.current;if(e==null)return;ft.current=null;let t=Q.current;if(!t||t.clientWidth===0)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.max(0,Math.min(Math.round(Z(Me(e,H))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[H,Z]);let Vn=t.useCallback((e,t)=>{let n=Y.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;In[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-In[o];return new Date(In[s]+c)},[Y,In]),Hn=t.useRef(null);Hn.current=Nn||Mn?Vn:null;let Un=t.useMemo(()=>{let e=[];if(Mn&&S){let t=0;for(let n of Y){let r=String(fe(n.date,S.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=H===`year`?`decade`:H===`month`||H===`quarter`?`year`:`month`,n=0;for(let r of Y){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},[Y,H,F,Mn,S]),Wn=t.useMemo(()=>(ve??[]).map((e,t)=>{let r=(0,n.toDisplayDate)(e.date);return{index:t,label:e.label,color:e.color||`hsl(var(--primary))`,left:Math.round(Z(r)),valid:!isNaN(r.getTime())&&r>=J.start&&r<=J.end}}).filter(e=>e.valid),[ve,J,Z]),Gn=t.useRef(null),Kn=t.useRef(null),qn=t.useRef(null),Q=t.useRef(null);t.useEffect(()=>{let e=Q.current;if(!e)return;let t=()=>{mt.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[Jn,Yn]=t.useState(null),Xn=t.useRef([]),Zn=t.useRef(null),[Qn,$n]=t.useState({top:0,left:0}),[er,tr]=t.useState({width:4e3,height:600}),nr=t.useCallback(()=>{let e=Q.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;tr(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{nr();let e=Q.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(nr);return t.observe(e),()=>t.disconnect()},[nr]);let rr=t.useMemo(()=>Ne(X,Qn.left-240,Qn.left+er.width+240),[X,Qn.left,er.width]),ir=t.useMemo(()=>{let e=Un.map(e=>e.offset);return e.push(Fn),e},[Un,Fn]),ar=t.useMemo(()=>Ne(ir,Qn.left-240,Qn.left+er.width+240),[ir,Qn.left,er.width]),$=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(Qn.top/V)-6),endIdx:Math.min(q.length,Math.ceil((Qn.top+er.height)/V)+6)}),[Qn.top,er.height,V,q.length]),or=q.length*V,sr=Re(H,Mn),cr=t.useMemo(()=>{let e=Rn(Qn.left);return ze(e>=0?Y[e].date:J.start,sr,S?.dayStartMin??0)},[Rn,Qn.left,Y,J,sr,S]),lr=t.useMemo(()=>Ve(cr,sr,F),[cr,sr,F]),ur=t.useCallback(e=>{let t=Q.current;if(!t)return;let n=Be(cr,e,sr),r=Math.max(0,Fn-er.width),i=Math.max(0,Math.min(Math.round(Z(n)),r));t.scrollLeft=i,$n(e=>e.left===i?e:{...e,left:i})},[cr,sr,Fn,er.width,Z]),[dr,fr]=t.useState(!1);t.useEffect(()=>{let e=()=>fr(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let pr=t.useCallback(()=>{let e=we.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),mr=t.useRef(null),hr=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;mr.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:yt}}},[yt]),gr=t.useCallback(e=>{if(e.touches.length!==2||!mr.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))/mr.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(mr.current.baseColumn*r)));ct(i)},[]),_r=t.useCallback(()=>{mr.current=null},[]),vr=t.useMemo(()=>{let e=M.now();return e<J.start||e>J.end?null:Math.round(Z(e))},[J,Z,M]),yr=t.useCallback(()=>{if(vr==null||!Q.current)return;let e=Math.max(0,vr-Q.current.clientWidth/2);Q.current.scrollTo({left:e,behavior:`smooth`})},[vr]),br=t.useRef(!1);t.useEffect(()=>{if(br.current||N.length===0)return;let e=window.requestAnimationFrame(()=>{let e=Q.current;if(!e||e.clientWidth===0)return;let t=vr;if(t==null){let e=new Date(Math.min(...N.map(e=>e.start.getTime())));t=Math.round(Z(e))}e.scrollLeft=Math.max(0,t-e.clientWidth/2),br.current=!0});return()=>window.cancelAnimationFrame(e)},[N,vr,Z]);let xr=t.useCallback((e,t=`left`)=>{let n=Q.current;if(!n||e<J.start||e>J.end)return!1;let r=Math.round(Z(e)),i=t===`center`?r-n.clientWidth/2:r-24;return n.scrollTo({left:Math.max(0,i),behavior:`smooth`}),!0},[J,Z]),Sr=t.useCallback((e,t,n)=>{let r=Q.current;if(!r)return;let i=Z(e),a=Z(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));Xn.current.forEach(e=>window.clearTimeout(e)),Xn.current=[],Zn.current?.(),Zn.current=null,Yn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{Yn(n),Xn.current.push(window.setTimeout(()=>Yn(e=>e===n?null:e),1500))});Zn.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),Xn.current.push(window.setTimeout(m,f?1500:500)),Zn.current=()=>r.removeEventListener(`scrollend`,m)},[Z]);t.useEffect(()=>()=>{Xn.current.forEach(e=>window.clearTimeout(e)),Zn.current?.()},[]);let Cr=t.useCallback(()=>xr(Me(M.now(),`week`)),[xr,M]),wr=t.useCallback(()=>xr(Me(M.now(),`month`)),[xr,M]),Tr=t.useRef(null),Er=t.useRef(null),Dr=t.useRef(null),Or=t.useRef(null),kr=t.useRef(null),Ar=t.useRef(null),jr=t.useRef(null),Mr=t.useRef(null),Nr=t.useCallback(()=>{let e=qn.current,t=Tr.current,n=Er.current,r=Dr.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=kr.current,a=Ar.current,o=jr.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(()=>{Nr()});let Pr=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=qn.current,n=Er.current,r=Dr.current;if(!t||!n||!r)return;Or.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=Or.current;n&&(t.scrollLeft=n.startLeft+(e.clientX-n.startX)*s)},l=()=>{Or.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)},Fr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=qn.current,n=Er.current,r=Dr.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)},Ir=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=qn.current,n=Ar.current,r=jr.current;if(!t||!n||!r)return;Mr.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=Mr.current;n&&(t.scrollTop=n.startTop+(e.clientY-n.startY)*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)},Lr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=qn.current,n=Ar.current,r=jr.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)},Rr=e=>{let t=e.currentTarget;!mt.current&&t.clientWidth>0&&(pt.current=zn(t.scrollLeft)),Gn.current&&(Gn.current.scrollLeft=t.scrollLeft),Nr(),Kn.current&&Kn.current.scrollTop!==t.scrollTop&&(Kn.current.scrollTop=t.scrollTop),$n(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),nr()},zr=e=>{let t=e.currentTarget,n=Q.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),$n(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},Br=(e,t)=>{let n=Z(e),r=Mn&&S?bt*Math.min(...S.bands.map(e=>e.durMs))/je:bt;return{left:n,width:Math.max(Z(t)-n,r,3)}},Vr=G?.group?G.taskId:null,Hr=t.useMemo(()=>{if(Vr==null)return null;let e=new Set([String(Vr)]);for(let t of jt(Vr))t.locked||e.add(String(t.id));return e},[Vr,jt]),Ur=t.useMemo(()=>{if(!G||G.group)return null;let e=new Set,t=new Set,n=At.get(String(G.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!At.has(r))break;t.add(r),e.add(r),n=At.get(r)}return e.size?e:null},[G,At]),Wr=e=>{if(G){if(Hr?.has(String(e.task.id))){let t=Ft(G),n=Fe(G.originStart,t.start,Mn);return Br(n(e.start),n(e.end))}if(G.taskId===e.task.id&&!G.group){let e=Ft(G);return Br(e.start,e.end)}if(e.isSummary&&Ur?.has(String(e.task.id))&&(D!==`self`||e.task.hasOwnDates===!1)){let t=Ft(G),n=String(G.taskId),r=null,i=null;for(let a of jt(e.task.id)){if((kt.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 Br(r,i)}}return Br(e.start,e.end)},Gr=t.useMemo(()=>{let e=new Map;q.forEach((t,n)=>e.set(String(t.task.id),n));let t=[];return q.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},[q]),Kr=Math.max(2,Math.round(V/2)-14),qr=V-Kr*2,Jr=Math.round(qr/2),Yr=Math.max(Math.round(V*.4),12),Xr=Yr*Math.SQRT2/2,Zr=qr,Qr=Kr,$r=Math.max(3,Math.round(V*.13)),ei=V-$r-1,ti=`rgba(100, 116, 139, 0.35)`,ni=`rgba(100, 116, 139, 0.6)`,ri=e=>{let t=q[e.sourceIndex],n=q[e.targetIndex];if(!t||!n)return null;let r=Wr(t),i=Wr(n),a=e=>e.isSummary?Qr+Zr/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?Xr:-Xr):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?Xr:-Xr):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(` `)},ii=G?.taskId??Et,[ai,oi]=t.useState(re),si=t.useMemo(()=>ai?se(N,x):null,[ai,N,x]),ci=t.useCallback(e=>si?.criticalIds.has(String(e))??!1,[si]),li=`#dc2626`,[ui,di]=t.useState(null),[fi,pi]=t.useState(!1);t.useEffect(()=>{if(!fi)return;let e=setTimeout(()=>pi(!1),2500);return()=>clearTimeout(e)},[fi]);let mi=t.useCallback(()=>{if(!z)return;let{changes:e,skippedLocked:t}=ce(N,x,Kt);if(!e.length){pi(!0);return}di({changes:e,skipped:t.length})},[N,z,x,Kt]),hi=t.useCallback(()=>{if(!ui)return;let e=[];for(let t of ui.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&&Ht(e),di(null)},[ui,N,Ht]),gi=t.useCallback(()=>{if(typeof document>`u`||!N.length)return null;let e=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]),t=Math.max(W,200),n=Math.ceil(t+Fn),r=Math.ceil(36+q.length*V),i=si?.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">`),Un.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>`)}),Y.forEach((t,n)=>{let i=X[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">`),q.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">`),q.forEach((t,n)=>{if(t.task.type===`group`)return;let r=n*V,{left:i,width:s}=Br(t.start,t.end),c=ci(t.task.id),l=c?` stroke="${li}" stroke-width="2"`:``;if(ie&&t.task.baselineStart&&t.task.baselineEnd){let e=Br(t.task.baselineStart,t.task.baselineEnd);a.push(`<rect x="${e.left.toFixed(1)}" y="${(r+ei).toFixed(1)}" width="${Math.max(2,e.width).toFixed(1)}" height="${$r}" rx="1" fill="${ti}" stroke="${ni}"/>`)}if(t.isMilestone){let e=i,n=r+V/2,o=Yr/2,s=c?li: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+Qr).toFixed(1)}" width="${s.toFixed(1)}" height="${Zr}" 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+Qr).toFixed(1)}" width="${c.toFixed(1)}" height="${Zr}" 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+Kr).toFixed(1)}" width="${s.toFixed(1)}" height="${qr}" 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+Kr).toFixed(1)}" width="${c.toFixed(1)}" height="${qr}" 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>`)}}),Gr.forEach(e=>{let t=ri(e);if(!t)return;let n=i?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?li:`#94a3b8`;a.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),vr!=null&&a.push(`<line x1="${vr.toFixed(1)}" y1="0" x2="${vr.toFixed(1)}" y2="${q.length*V}" stroke="#ef4444" stroke-width="1.5"/>`);let s=q.length*V;return Wn.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,q,Gr,ri,Br,ci,si,Y,X,Fn,W,V,Kr,qr,Qr,Zr,Yr,vr,H,ie,ei,$r,ti,ni,Wn,Un]),_i=t.useCallback(()=>{let e=(j??``).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())}`}`},[j]),vi=t.useCallback(async()=>{let e=gi();if(!e)return;let t=await He(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&Ue(e,`${_i()}.png`)},`image/png`)},[gi,_i]),yi=t.useCallback(async()=>{let e=gi();if(!e)return;let t=await He(e.svg,e.W,e.H);t&&Ue(We(Ge(t.toDataURL(`image/jpeg`,.92)),t.width,t.height),`${_i()}.pdf`)},[gi,_i]),[bi,xi]=t.useState(!1),Si=t.useCallback(()=>{let e={viewMode:H,columnWidth:st,taskListCollapsed:U,taskListWidth:lt,collapsedIds:Array.from(Dn)};O&&Je(O,e),oe?.(e),xi(!0)},[H,st,U,lt,Dn,O,oe]);return t.useEffect(()=>{if(!bi)return;let e=setTimeout(()=>xi(!1),1500);return()=>clearTimeout(e)},[bi]),(0,p.jsxs)(`div`,{ref:we,className:(0,u.cn)(`flex flex-col h-full bg-background overflow-hidden min-w-0`,b),"data-readonly":R?`true`:void 0,"data-mobile-readonly":w&&Ke?`true`:void 0,children:[(0,p.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 Ge(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 Ke=`gantt-layout:`;function qe(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(Ke+e);if(!t)return null;let n=JSON.parse(t),r=n.viewMode&&ke.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(Ke+e,JSON.stringify(t))}catch{}}function Ye({tasks:e,viewMode:r,startDate:o,endDate:s,markers:c,onTaskClick:l,onTaskUpdate:d,onTaskDelete:m,onViewChange:h,onDependencyCreate:g,onBeforeDependencyCreate:_,onDependencyDelete:v,onTaskReorder:y,className:b,inlineEdit:ee=!1,autoSchedule:te=!1,rescheduleOnConflict:ne=!1,criticalPathDefault:x=!1,workingCalendar:S,shiftSegments:C,showBaselines:re=!0,readOnly:w=!1,mobileReadOnly:T=!1,groupBy:E,ungroupedLabel:D=`Ungrouped`,defaultCollapsedDepth:ie,summaryExtent:O=`children`,persistLayoutKey:k,onLayoutChange:ae,onRefresh:ce,refreshing:j=!1,dependencyTypes:le=!0,timeZone:ue,exportFileName:de,interactions:fe,onBeforeTaskUpdate:me}){let N=t.useMemo(()=>pe(ue),[ue]),P=t.useMemo(()=>N.delta===0?e:e.map(e=>({...e,start:N.to(e.start),end:N.to(e.end),baselineStart:e.baselineStart?N.to(e.baselineStart):e.baselineStart,baselineEnd:e.baselineEnd?N.to(e.baselineEnd):e.baselineEnd})),[e,N]),he=t.useMemo(()=>o&&N.delta!==0?N.to(o):o,[o,N]),ge=t.useMemo(()=>s&&N.delta!==0?N.to(s):s,[s,N]),_e=t.useMemo(()=>!c||N.delta===0?c:c.map(e=>typeof e.date==`string`&&(0,n.isRealCalendarDate)(e.date)?{...e,date:(0,n.toDisplayDate)(e.date)}:{...e,date:N.to((0,n.toDisplayDate)(e.date))}),[c,N]),{t:F}=ve(),Ce=(0,i.useDisplayLocale)(),we=N.now().getFullYear(),I=(e,t)=>e.toLocaleDateString(Ce,e.getFullYear()===we?{month:t,day:`numeric`}:{month:t,day:`numeric`,year:t===`numeric`?`2-digit`:`numeric`}),Ee=t.useRef(null),{width:Ke}=(0,u.useResizeObserver)(Ee),Ye=Ke||(typeof window<`u`?window.innerWidth:1024),Xe=Ye<640,R=w||T&&Xe,Ze=fe?.move!==!1,z=fe?.resize!==!1,Qe=fe?.progress!==!1,$e=fe?.link!==!1,B=t.useMemo(()=>{if(!R&&d)return N.delta===0?d:(e,t)=>{let n={...t};n.start instanceof Date&&(n.start=N.from(n.start)),n.end instanceof Date&&(n.end=N.from(n.end)),d(e,n)}},[R,d,N]),et=R?void 0:m,V=R||!$e?void 0:g,tt=R||!$e?void 0:v,nt=R?void 0:y,rt=!R&&ee,it=!R&&te,at=!R&&ne,H=Oe(Ye),ot=t.useRef(void 0);ot.current===void 0&&(ot.current=qe(k));let st=ot.current,[ct,lt]=t.useState(st?st.columnWidth:null),[ut,dt]=t.useState(st?st.taskListWidth??null:null),[U,ft]=t.useState(r&&ke.includes(r)?r:st?.viewMode??`day`);t.useEffect(()=>{r&&ke.includes(r)&&ft(r)},[r]);let pt=t.useRef(null),mt=t.useRef(null),ht=t.useRef(!0),[gt,_t]=t.useState(st?st.taskListCollapsed:!1),vt=t.useRef(!1);t.useEffect(()=>{!vt.current&&Xe&&(_t(!0),vt.current=!0)},[Xe]);let yt=Math.max(Se,Ye-200),W=gt?0:ut==null?Te(Ye):Math.max(Se,Math.min(ut,yt)),bt=t.useMemo(()=>{if(ct!=null||ge||P.length===0)return null;let e=he?new Date(he):new Date(Math.min(...P.map(e=>e.start.getTime()))),t=new Date(Math.max(...P.map(e=>e.end.getTime())));he||e.setDate(e.getDate()-7),t.setDate(t.getDate()+14),e=Me(e,U),t.setHours(23,59,59,999);let n=Math.max(1,(t.getTime()-e.getTime())/je),r=Math.max(0,Ye-W);if(r<=0)return null;let i=r/n*Ae[U];if(i<=xe)return null;let a=Math.min(i,r*.6);return a>xe?a:null},[ct,P,he,ge,U,Ye,W]),xt=ct??bt??xe,St=xt/Ae[U],Ct=De(W),[wt,Tt]=t.useState(null),[Et,Dt]=t.useState({}),[Ot,kt]=t.useState(null),At=t.useMemo(()=>{if(!E)return P;let e=new Set;for(let t of P){let n=t.parent!=null&&t.parent!==``?String(t.parent):null;n&&e.add(n)}let t=new Map;for(let n of P){if(e.has(String(n.id)))continue;let r=E(n),i=r?String(r.key):`__ungrouped__`,a=r?r.label:D,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},[E,P,D]),jt=t.useMemo(()=>{let e=new Set(At.map(e=>String(e.id))),t=new Map;for(let n of At){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},[At]),Mt=t.useMemo(()=>{let e=new Map;for(let t of At)e.set(String(t.id),t);return e},[At]),Nt=t.useCallback(e=>{let t=[],n=new Set,r=e=>{for(let i of jt.get(e)??[]){let e=String(i.id);n.has(e)||(n.add(e),t.push(i),r(e))}};return r(String(e)),t},[jt]),[G,Pt]=t.useState(null),Ft=t.useRef(null);t.useEffect(()=>{Ft.current=G},[G]);let It=t.useRef(!1),Lt=t.useCallback(e=>{let t=U===`day`&&!!C&&C.bands.length>0,n=(e,t)=>Wn.current?Wn.current(e,t):L(e,t,`day`),r=new Date(e.originStart),i=new Date(e.originEnd);if(t&&C){let t=Math.min(...C.bands.map(e=>e.durMs));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}}let a=t=>Pe(t,n(t,e.unitDelta));if(e.mode===`move`){let t=a(e.originStart);r=L(e.originStart,t,`day`),i=L(e.originEnd,t,`day`)}else if(e.mode===`resize-left`){r=L(e.originStart,a(e.originStart),`day`);let t=L(i,-1,`day`);r.getTime()>t.getTime()&&(r=t)}else if(e.mode===`resize-right`){i=L(e.originEnd,a(e.originEnd),`day`);let t=L(r,1,`day`);i.getTime()<t.getTime()&&(i=t)}return{start:r,end:i}},[U,C]),Rt=e=>{let t=Lt(e);return Ie(t.start,t.end)},zt=t.useRef(P);zt.current=P;let Bt=t.useRef([]),Vt=t.useRef([]),[Ht,Ut]=t.useState(0),Wt=t.useCallback(e=>{if(!B)return;let t=e.filter(e=>!e.task.locked);(async()=>{let e=t;if(me){let n=[];for(let e of t){let t;try{t=await me(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)}B(t,r),a&&n.push({taskId:String(t.id),before:e,after:i})}n.length&&(Bt.current.push(n),Vt.current=[],Ut(e=>e+1))})()},[B,me]),[Gt,Kt]=t.useState(null),qt=t.useCallback(e=>{if(!C)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*je+C.dayStartMin*6e4;for(let t of C.bands){if(r>=e)return r;r+=t.durMs}}return e},[C]),Jt=t.useMemo(()=>({summaryExtent:O,snapStart:C?qt:void 0}),[O,C,qt]),Yt=t.useCallback(e=>{if(!at)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}=A(zt.current.map(e=>{let n=t.get(String(e.id));return n?{...e,start:n.start,end:n.end}:e}),S,Jt),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&&Kt(r)},[at,S,Jt]),Xt=t.useCallback(()=>{if(!Gt)return;let e=Gt.map(e=>{let t=zt.current.find(t=>String(t.id)===e.id);return t?{task:t,changes:{start:e.start,end:e.end}}:null}).filter(Boolean);e.length&&Wt(e),Kt(null)},[Gt,Wt]),Zt=t.useCallback((e,t)=>{if(B)for(let n of e){let e=zt.current.find(e=>String(e.id)===n.taskId);e&&B(e,t===`undo`?n.before:n.after)}},[B]),Qt=t.useCallback(()=>{let e=Bt.current.pop();e&&(Zt(e,`undo`),Vt.current.push(e),Ut(e=>e+1))},[Zt]),$t=t.useCallback(()=>{let e=Vt.current.pop();e&&(Zt(e,`redo`),Bt.current.push(e),Ut(e=>e+1))},[Zt]),{canUndo:en,canRedo:tn}=t.useMemo(()=>({canUndo:Bt.current.length>0,canRedo:Vt.current.length>0}),[Ht]);t.useEffect(()=>{if(!G)return;let e=U===`day`&&!!C&&C.bands.length>0,t=e&&C?St*Math.min(...C.bands.map(e=>e.durMs))/je:St,n=e=>{let n=Ft.current;if(!n)return;let r=Math.round((e.clientX-n.originClientX)/Math.max(t,1));r!==n.unitDelta&&Pt({...n,unitDelta:r})},r=()=>{let t=Ft.current;if(t){if(t.unitDelta!==0){let n=P.find(e=>e.id===t.taskId);if(n&&B){let{start:r,end:i}=Lt(t);if(t.group){let i=Fe(t.originStart,r,e),a=[n,...Nt(n.id).filter(e=>!e.locked)].map(e=>({task:e,changes:{start:i(e.start),end:i(e.end)}}));Wt(a),Yt(a)}else{let e=[{task:n,changes:{start:r,end:i}}];Wt(e),Yt(e)}}It.current=!0,window.setTimeout(()=>{It.current=!1},0)}Pt(null)}};return window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r)}},[G,xt,St,U,C,P,B,Lt,Nt,Wt,Yt]);let nn=t.useCallback((e,t,n,r)=>{!B||e.data?.__group||e.locked||(n.stopPropagation(),n.preventDefault(),Pt({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}))},[B]),[rn,an]=t.useState(null),on=t.useRef(null);t.useEffect(()=>{on.current=rn},[rn]),t.useEffect(()=>{if(!rn)return;let e=e=>{let t=on.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&&an({...t,value:n})},t=()=>{let e=on.current;if(e){if(e.value!==e.originProgress){let t=P.find(t=>t.id===e.taskId);t&&B&&Wt([{task:t,changes:{progress:e.value}}]),It.current=!0,window.setTimeout(()=>{It.current=!1},0)}an(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)}},[rn,P,B,Wt]);let sn=t.useMemo(()=>{let e=[];for(let t of P)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},[P]),cn=t.useCallback((e,t)=>String(t.id)===String(e)?`self`:t.locked?`locked`:t.type===`group`?`group`:se(sn,e,t.id)?`cycle`:null,[sn]),ln=t.useCallback((e,t)=>cn(e,t)===null,[cn]),un=t.useRef(null),[K,dn]=t.useState(null),fn=t.useRef(null);t.useEffect(()=>{fn.current=K},[K]),t.useEffect(()=>{if(!K)return;let e=e=>{let t=un.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;dn(e=>e&&{...e,x:n,y:r})},t=()=>{let e=fn.current;if(e&&e.targetId!=null&&V){let t=P.find(t=>String(t.id)===String(e.sourceId)),n=P.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&&ln(e.sourceId,n)&&(_?.(t,n,i)??!0)&&V(t,n,i)}else e&&e.rejectedReason&&V&&a.toast.error(F(`gantt.link.rejected.${e.rejectedReason}`));It.current=!0,window.setTimeout(()=>{It.current=!1},0),dn(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)}},[K,P,V,_,ln,le,F]);let[pn,mn]=t.useState(null),hn=t.useRef(null);t.useEffect(()=>{if(!pn)return;let e=e=>{hn.current&&e.target instanceof Node&&hn.current.contains(e.target)||mn(null)},t=e=>{e.key===`Escape`&&mn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[pn]);let[gn,_n]=t.useState(null),vn=t.useRef(null);t.useEffect(()=>{if(!gn)return;let e=e=>{vn.current&&e.target instanceof Node&&vn.current.contains(e.target)||_n(null)},t=e=>{e.key===`Escape`&&_n(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[gn]);let[yn,bn]=t.useState(null),[xn,Sn]=t.useState(``),Cn=t.useRef(null);t.useEffect(()=>{if(!yn)return;let e=e=>{Cn.current&&e.target instanceof Node&&Cn.current.contains(e.target)||bn(null)},t=e=>{e.key===`Escape`&&bn(null)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[yn]);let[wn,Tn]=t.useState(null),En=!!(l||B||V||et),Dn=t.useCallback((e,t)=>{t.preventDefault(),t.stopPropagation(),Tn(e.id),En&&mn({x:t.clientX,y:t.clientY,taskId:e.id})},[En]),On=t.useCallback((e,t,n,r)=>{r.preventDefault(),r.stopPropagation(),(V||tt)&&_n({x:r.clientX,y:r.clientY,sourceId:e,targetId:t,type:n})},[V,tt]),[kn,An]=t.useState(()=>new Set(st?.collapsedIds??[])),jn=t.useCallback(e=>{An(t=>{let n=new Set(t),r=String(e);return n.has(r)?n.delete(r):n.add(r),n})},[]),Mn=t.useRef(st?.collapsedIds!=null);t.useEffect(()=>{if(Mn.current||ie==null||At.length===0)return;Mn.current=!0;let e=new Map(At.map(e=>[String(e.id),e])),t=new Set;for(let n of At){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 At){let i=String(e.id);t.has(i)&&n(e)>=ie&&r.add(i)}r.size&&An(e=>e.size?e:r)},[ie,At]);let q=t.useMemo(()=>{let e=new Set(At.map(e=>String(e.id))),t=new Map,n=[];for(let r of At){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(),je);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&&O===`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(kn.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 At)o.has(String(e.id))||c(e,0);return a},[At,kn,O]),Nn=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?$t():Qt();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`Y`)){e.preventDefault(),$t();return}if(!q.length)return;let t=wn==null?-1:q.findIndex(e=>String(e.task.id)===String(wn));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?Math.min(q.length-1,t+1):Math.max(0,t<=0?0:t-1);Tn(q[n].task.id);let r=Q.current;if(r){let e=n*H;e<r.scrollTop?r.scrollTop=e:e+H>r.scrollTop+r.clientHeight&&(r.scrollTop=e+H-r.clientHeight)}return}if(t<0)return;let n=q[t];e.key===`Enter`?(e.preventDefault(),l?.(n.task)):e.key===`Delete`||e.key===`Backspace`?et&&(e.preventDefault(),et(n.task)):(e.key===`ArrowRight`&&n.hasChildren&&kn.has(String(n.task.id))||e.key===`ArrowLeft`&&n.hasChildren&&!kn.has(String(n.task.id)))&&(e.preventDefault(),jn(n.task.id))},[q,wn,l,et,kn,jn,H,Qt,$t]),J=t.useMemo(()=>{let e=he?new Date(he):N.now(),t=ge?new Date(ge):N.now();return!he&&P.length>0&&(e=new Date(Math.min(...P.map(e=>e.start.getTime()))),e.setDate(e.getDate()-7)),!ge&&P.length>0&&(t=new Date(Math.max(...P.map(e=>e.end.getTime()))),t.setDate(t.getDate()+14)),e=U===`day`&&C&&C.bands.length>0?M(e,C.dayStartMin):Me(e,U),t.setHours(23,59,59,999),{start:e,end:t}},[he,ge,P,U,C,N]),Pn=U===`day`&&!!C&&C.bands.length>0,Fn=!Pn&&U===`day`&&!!S&&(!!S.skipWeekends||!!(S.holidays&&S.holidays.size)),In=t.useCallback(e=>{if(!S)return!0;if(S.skipWeekends){let t=e.getDay();if(t===0||t===6)return!1}if(S.holidays&&S.holidays.size){let t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(S.holidays.has(t))return!1}return!0},[S]),Y=t.useMemo(()=>{let e=[];if(Pn&&C){let t=new Date(J.start);for(;t<=J.end;)for(let n of C.bands){let r=n.durMs/je*St;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(J.start);for(;t<=J.end;){let n=L(t,1,U);if(Fn&&!In(t)){t=n;continue}let r=(n.getTime()-t.getTime())/je*St,i,a;U===`day`?(i=String(t.getDate()),a=t.toLocaleDateString(Ce,{weekday:`narrow`})):i=U===`week`?t.toLocaleDateString(Ce,{month:`numeric`,day:`numeric`}):U===`month`?t.toLocaleDateString(Ce,{month:`short`}):U===`quarter`?`Q${Math.floor(t.getMonth()/3)+1}`:String(t.getFullYear()),e.push({date:new Date(t),label:i,sublabel:a,isWeekend:U===`day`&&(t.getDay()===0||t.getDay()===6),width:r}),t=n}return e},[J,U,St,Ce,Fn,In,Pn,C]),X=t.useMemo(()=>{let e=Array(Y.length+1),t=0;for(let n=0;n<Y.length;n++)e[n]=t,t+=Y[n].width;return e[Y.length]=t,e},[Y]),Ln=X[X.length-1],Rn=t.useMemo(()=>Y.map(e=>e.date.getTime()),[Y]),zn=t.useMemo(()=>Y.map(e=>e.realMs==null?L(e.date,1,U).getTime()-e.date.getTime():e.realMs),[Y,U]),Z=t.useCallback(e=>{let t=Y.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;Rn[e]<=n?(a=e,r=e+1):i=e-1}let o=zn[a]||864e5,s=(n-Rn[a])/o;return(Fn||Pn)&&(s=Math.max(0,Math.min(s,1))),X[a]+s*Y[a].width},[Y,Rn,zn,X,Fn,Pn]),Bn=t.useCallback(e=>{let t=Y.length;if(t===0)return-1;let n=0,r=t-1,i=0;for(;n<=r;){let t=n+r>>1;X[t]<=e?(i=t,n=t+1):r=t-1}return i},[Y,X]),Vn=t.useCallback(e=>{let t=Bn(e);if(t<0)return new Date(J.start);let n=Y[t].width||1,r=(e-X[t])/n;return new Date(Rn[t]+r*(zn[t]||864e5))},[Bn,Y,Rn,zn,X,J]),Hn=t.useCallback(e=>{let t=Q.current;mt.current==null&&t&&t.clientWidth>0&&(mt.current=Vn(t.scrollLeft)),pt.current=mt.current,ht.current=!0,ft(e),h?.(e)},[h,Vn]);t.useLayoutEffect(()=>{let e=pt.current;if(e==null)return;pt.current=null;let t=Q.current;if(!t||t.clientWidth===0)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.max(0,Math.min(Math.round(Z(Me(e,U))),n));t.scrollLeft!==r&&(t.scrollLeft=r)},[U,Z]);let Un=t.useCallback((e,t)=>{let n=Y.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;Rn[e]<=r?(o=e,i=e+1):a=e-1}let s=Math.min(n-1,Math.max(0,o+t)),c=r-Rn[o];return new Date(Rn[s]+c)},[Y,Rn]),Wn=t.useRef(null);Wn.current=Fn||Pn?Un:null;let Gn=t.useMemo(()=>{let e=[];if(Pn&&C){let t=0;for(let n of Y){let r=String(M(n.date,C.dayStartMin).getTime()),i=e[e.length-1];i&&i.key===r?i.width+=n.width:e.push({key:r,label:n.date.toLocaleDateString(Ce,{month:`short`,day:`numeric`}),width:n.width,offset:t}),t+=n.width}return e}let t=U===`year`?`decade`:U===`month`||U===`quarter`?`year`:`month`,n=0;for(let r of Y){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(Ce,{month:`short`,year:`numeric`}),width:r.width,offset:n}),n+=r.width}return e},[Y,U,Ce,Pn,C]),Kn=t.useMemo(()=>(_e??[]).map((e,t)=>{let r=(0,n.toDisplayDate)(e.date);return{index:t,label:e.label,color:e.color||`hsl(var(--primary))`,left:Math.round(Z(r)),valid:!isNaN(r.getTime())&&r>=J.start&&r<=J.end}}).filter(e=>e.valid),[_e,J,Z]),qn=t.useRef(null),Jn=t.useRef(null),Yn=t.useRef(null),Q=t.useRef(null);t.useEffect(()=>{let e=Q.current;if(!e)return;let t=()=>{ht.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[Xn,Zn]=t.useState(null),Qn=t.useRef([]),$n=t.useRef(null),[er,tr]=t.useState({top:0,left:0}),[nr,rr]=t.useState({width:4e3,height:600}),ir=t.useCallback(()=>{let e=Q.current;if(!e)return;let t=e.clientWidth||4e3,n=e.clientHeight||600;rr(e=>e.width===t&&e.height===n?e:{width:t,height:n})},[]);t.useLayoutEffect(()=>{ir();let e=Q.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(ir);return t.observe(e),()=>t.disconnect()},[ir]);let ar=t.useMemo(()=>Ne(X,er.left-240,er.left+nr.width+240),[X,er.left,nr.width]),or=t.useMemo(()=>{let e=Gn.map(e=>e.offset);return e.push(Ln),e},[Gn,Ln]),sr=t.useMemo(()=>Ne(or,er.left-240,er.left+nr.width+240),[or,er.left,nr.width]),$=t.useMemo(()=>({startIdx:Math.max(0,Math.floor(er.top/H)-6),endIdx:Math.min(q.length,Math.ceil((er.top+nr.height)/H)+6)}),[er.top,nr.height,H,q.length]),cr=q.length*H,lr=Re(U,Pn),ur=t.useMemo(()=>{let e=Bn(er.left);return ze(e>=0?Y[e].date:J.start,lr,C?.dayStartMin??0)},[Bn,er.left,Y,J,lr,C]),dr=t.useMemo(()=>Ve(ur,lr,Ce),[ur,lr,Ce]),fr=t.useCallback(e=>{let t=Q.current;if(!t)return;let n=Be(ur,e,lr),r=Math.max(0,Ln-nr.width),i=Math.max(0,Math.min(Math.round(Z(n)),r));t.scrollLeft=i,tr(e=>e.left===i?e:{...e,left:i})},[ur,lr,Ln,nr.width,Z]),[pr,mr]=t.useState(!1);t.useEffect(()=>{let e=()=>mr(!!document.fullscreenElement);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let hr=t.useCallback(()=>{let e=Ee.current;e&&(document.fullscreenElement?document.exitFullscreen?.():e.requestFullscreen?.())},[]),gr=t.useRef(null),_r=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;gr.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:xt}}},[xt]),vr=t.useCallback(e=>{if(e.touches.length!==2||!gr.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))/gr.current.baseDistance,i=Math.max(15,Math.min(120,Math.round(gr.current.baseColumn*r)));lt(i)},[]),yr=t.useCallback(()=>{gr.current=null},[]),br=t.useMemo(()=>{let e=N.now();return e<J.start||e>J.end?null:Math.round(Z(e))},[J,Z,N]),xr=t.useCallback(()=>{if(br==null||!Q.current)return;let e=Math.max(0,br-Q.current.clientWidth/2);Q.current.scrollTo({left:e,behavior:`smooth`})},[br]),Sr=t.useRef(!1);t.useEffect(()=>{if(Sr.current||P.length===0)return;let e=window.requestAnimationFrame(()=>{let e=Q.current;if(!e||e.clientWidth===0)return;let t=br;if(t==null){let e=new Date(Math.min(...P.map(e=>e.start.getTime())));t=Math.round(Z(e))}e.scrollLeft=Math.max(0,t-e.clientWidth/2),Sr.current=!0});return()=>window.cancelAnimationFrame(e)},[P,br,Z]);let Cr=t.useCallback((e,t=`left`)=>{let n=Q.current;if(!n||e<J.start||e>J.end)return!1;let r=Math.round(Z(e)),i=t===`center`?r-n.clientWidth/2:r-24;return n.scrollTo({left:Math.max(0,i),behavior:`smooth`}),!0},[J,Z]),wr=t.useCallback((e,t,n)=>{let r=Q.current;if(!r)return;let i=Z(e),a=Z(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));Qn.current.forEach(e=>window.clearTimeout(e)),Qn.current=[],$n.current?.(),$n.current=null,Zn(null);let u=()=>{if(n==null)return;let e=window.requestAnimationFrame(()=>{Zn(n),Qn.current.push(window.setTimeout(()=>Zn(e=>e===n?null:e),1500))});$n.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),Qn.current.push(window.setTimeout(m,f?1500:500)),$n.current=()=>r.removeEventListener(`scrollend`,m)},[Z]);t.useEffect(()=>()=>{Qn.current.forEach(e=>window.clearTimeout(e)),$n.current?.()},[]);let Tr=t.useCallback(()=>Cr(Me(N.now(),`week`)),[Cr,N]),Er=t.useCallback(()=>Cr(Me(N.now(),`month`)),[Cr,N]),Dr=t.useRef(null),Or=t.useRef(null),kr=t.useRef(null),Ar=t.useRef(null),jr=t.useRef(null),Mr=t.useRef(null),Nr=t.useRef(null),Pr=t.useRef(null),Fr=t.useCallback(()=>{let e=Yn.current,t=Dr.current,n=Or.current,r=kr.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=jr.current,a=Mr.current,o=Nr.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(()=>{Fr()});let Ir=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=Yn.current,n=Or.current,r=kr.current;if(!t||!n||!r)return;Ar.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=Ar.current;n&&(t.scrollLeft=n.startLeft+(e.clientX-n.startX)*s)},l=()=>{Ar.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)},Lr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=Yn.current,n=Or.current,r=kr.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)},Rr=e=>{if(e.button!==0)return;e.preventDefault(),e.stopPropagation();let t=Yn.current,n=Mr.current,r=Nr.current;if(!t||!n||!r)return;Pr.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=Pr.current;n&&(t.scrollTop=n.startTop+(e.clientY-n.startY)*s)},l=()=>{Pr.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)},zr=e=>{if(e.button!==0||e.target!==e.currentTarget)return;let t=Yn.current,n=Mr.current,r=Nr.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)},Br=e=>{let t=e.currentTarget;!ht.current&&t.clientWidth>0&&(mt.current=Vn(t.scrollLeft)),qn.current&&(qn.current.scrollLeft=t.scrollLeft),Fr(),Jn.current&&Jn.current.scrollTop!==t.scrollTop&&(Jn.current.scrollTop=t.scrollTop),tr(e=>e.top===t.scrollTop&&e.left===t.scrollLeft?e:{top:t.scrollTop,left:t.scrollLeft}),ir()},Vr=e=>{let t=e.currentTarget,n=Q.current;n&&n.scrollTop!==t.scrollTop&&(n.scrollTop=t.scrollTop),tr(e=>e.top===t.scrollTop?e:{...e,top:t.scrollTop})},Hr=(e,t)=>{let n=Z(e),r=Pn&&C?St*Math.min(...C.bands.map(e=>e.durMs))/je:St;return{left:n,width:Math.max(Z(t)-n,r,3)}},Ur=G?.group?G.taskId:null,Wr=t.useMemo(()=>{if(Ur==null)return null;let e=new Set([String(Ur)]);for(let t of Nt(Ur))t.locked||e.add(String(t.id));return e},[Ur,Nt]),Gr=t.useMemo(()=>{if(!G||G.group)return null;let e=new Set,t=new Set,n=Mt.get(String(G.taskId));for(;n&&n.parent!=null&&n.parent!==``;){let r=String(n.parent);if(t.has(r)||!Mt.has(r))break;t.add(r),e.add(r),n=Mt.get(r)}return e.size?e:null},[G,Mt]),Kr=e=>{if(G){if(Wr?.has(String(e.task.id))){let t=Lt(G),n=Fe(G.originStart,t.start,Pn);return Hr(n(e.start),n(e.end))}if(G.taskId===e.task.id&&!G.group){let e=Lt(G);return Hr(e.start,e.end)}if(e.isSummary&&Gr?.has(String(e.task.id))&&(O!==`self`||e.task.hasOwnDates===!1)){let t=Lt(G),n=String(G.taskId),r=null,i=null;for(let a of Nt(e.task.id)){if((jt.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 Hr(r,i)}}return Hr(e.start,e.end)},qr=t.useMemo(()=>{let e=new Map;q.forEach((t,n)=>e.set(String(t.task.id),n));let t=[];return q.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},[q]),Jr=Math.max(2,Math.round(H/2)-14),Yr=H-Jr*2,Xr=Math.round(Yr/2),Zr=Math.max(Math.round(H*.4),12),Qr=Zr*Math.SQRT2/2,$r=Yr,ei=Jr,ti=Math.max(3,Math.round(H*.13)),ni=H-ti-1,ri=`rgba(100, 116, 139, 0.35)`,ii=`rgba(100, 116, 139, 0.6)`,ai=e=>{let t=q[e.sourceIndex],n=q[e.targetIndex];if(!t||!n)return null;let r=Kr(t),i=Kr(n),a=e=>e.isSummary?ei+$r/2:H/2,o=e.sourceIndex*H+a(t),s=e.targetIndex*H+a(n),c=e.type===`fs`||e.type===`ff`,l=e.type===`ff`||e.type===`sf`,u=t.isMilestone?r.left+(c?Qr:-Qr):c?r.left+r.width:r.left,d=n.isMilestone?i.left+(l?Qr:-Qr):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)*H:e.sourceIndex*H;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(` `)},oi=G?.taskId??Ot,[si,ci]=t.useState(x),li=t.useMemo(()=>si?oe(P,S):null,[si,P,S]),ui=t.useCallback(e=>li?.criticalIds.has(String(e))??!1,[li]),di=`#dc2626`,[fi,pi]=t.useState(null),[mi,hi]=t.useState(!1);t.useEffect(()=>{if(!mi)return;let e=setTimeout(()=>hi(!1),2500);return()=>clearTimeout(e)},[mi]);let gi=t.useCallback(()=>{if(!B)return;let{changes:e,skippedLocked:t}=A(P,S,Jt);if(!e.length){hi(!0);return}pi({changes:e,skipped:t.length})},[P,B,S,Jt]),_i=t.useCallback(()=>{if(!fi)return;let e=[];for(let t of fi.changes){let n=P.find(e=>String(e.id)===t.id);n&&e.push({task:n,changes:{start:t.start,end:t.end}})}e.length&&Wt(e),pi(null)},[fi,P,Wt]),vi=t.useCallback(()=>{if(typeof document>`u`||!P.length)return null;let e=e=>String(e).replace(/[&<>"]/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]),t=Math.max(W,200),n=Math.ceil(t+Ln),r=Math.ceil(36+q.length*H),i=li?.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">`),Gn.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>`)}),Y.forEach((t,n)=>{let i=X[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">`),q.forEach((n,r)=>{let i=r*H;a.push(`<line x1="0" y1="${(i+H).toFixed(1)}" x2="${t}" y2="${(i+H).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+H/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">`),q.forEach((t,n)=>{if(t.task.type===`group`)return;let r=n*H,{left:i,width:s}=Hr(t.start,t.end),c=ui(t.task.id),l=c?` stroke="${di}" stroke-width="2"`:``;if(re&&t.task.baselineStart&&t.task.baselineEnd){let e=Hr(t.task.baselineStart,t.task.baselineEnd);a.push(`<rect x="${e.left.toFixed(1)}" y="${(r+ni).toFixed(1)}" width="${Math.max(2,e.width).toFixed(1)}" height="${ti}" rx="1" fill="${ri}" stroke="${ii}"/>`)}if(t.isMilestone){let e=i,n=r+H/2,o=Zr/2,s=c?di: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+ei).toFixed(1)}" width="${s.toFixed(1)}" height="${$r}" 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+ei).toFixed(1)}" width="${c.toFixed(1)}" height="${$r}" 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+H/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+Jr).toFixed(1)}" width="${s.toFixed(1)}" height="${Yr}" 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+Jr).toFixed(1)}" width="${c.toFixed(1)}" height="${Yr}" 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+H/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+H/2+3).toFixed(1)}" text-anchor="middle" fill="#ffffff">${Math.round(t.progress)}%</text>`)}}),qr.forEach(e=>{let t=ai(e);if(!t)return;let n=i?.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,r=n?di:`#94a3b8`;a.push(`<path d="${t}" fill="none" stroke="${r}" stroke-width="${n?2:1.5}"/>`)}),br!=null&&a.push(`<line x1="${br.toFixed(1)}" y1="0" x2="${br.toFixed(1)}" y2="${q.length*H}" stroke="#ef4444" stroke-width="1.5"/>`);let s=q.length*H;return Kn.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}},[P,q,qr,ai,Hr,ui,li,Y,X,Ln,W,H,Jr,Yr,ei,$r,Zr,br,U,re,ni,ti,ri,ii,Kn,Gn]),yi=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]),bi=t.useCallback(async()=>{let e=vi();if(!e)return;let t=await He(e.svg,e.W,e.H);t&&t.toBlob(e=>{e&&Ue(e,`${yi()}.png`)},`image/png`)},[vi,yi]),xi=t.useCallback(async()=>{let e=vi();if(!e)return;let t=await He(e.svg,e.W,e.H);t&&Ue(We(Ge(t.toDataURL(`image/jpeg`,.92)),t.width,t.height),`${yi()}.pdf`)},[vi,yi]),[Si,Ci]=t.useState(!1),wi=t.useCallback(()=>{let e={viewMode:U,columnWidth:ct,taskListCollapsed:gt,taskListWidth:ut,collapsedIds:Array.from(kn)};k&&Je(k,e),ae?.(e),Ci(!0)},[U,ct,gt,ut,kn,k,ae]);return t.useEffect(()=>{if(!Si)return;let e=setTimeout(()=>Ci(!1),1500);return()=>clearTimeout(e)},[Si]),(0,p.jsxs)(`div`,{ref:Ee,className:(0,u.cn)(`flex flex-col h-full bg-background overflow-hidden min-w-0`,b),"data-readonly":R?`true`:void 0,"data-mobile-readonly":T&&Xe?`true`:void 0,children:[(0,p.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,p.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,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":P(`gantt.toolbar.prevPeriod`),"data-testid":`gantt-toolbar-prev-period`,onClick:()=>ur(-1),children:(0,p.jsx)(f.ChevronLeft,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":P(`gantt.toolbar.nextPeriod`),"data-testid":`gantt-toolbar-next-period`,onClick:()=>ur(1),children:(0,p.jsx)(f.ChevronRight,{className:`h-4 w-4`})}),(0,p.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,"data-testid":`gantt-toolbar-period`,children:lr}),R&&(0,p.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,p.jsx)(f.Lock,{className:`h-3 w-3`}),P(`gantt.readOnly`)]})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":P(`gantt.toolbar.viewMode`),children:I.map(e=>(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:(0,u.cn)(`h-6 px-1.5 sm:px-2 text-xs`,H===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>Bn(e),"aria-pressed":H===e,"data-testid":`gantt-view-mode-${e}`,children:P(`gantt.viewMode.${e}`)},e))}),(0,p.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(yt>15)ct(Math.max(15,yt-10));else{let e=I.indexOf(H);e<I.length-1&&(Bn(I[e+1]),ct(Se))}},"aria-label":P(`gantt.toolbar.zoomOut`),children:(0,p.jsx)(f.ZoomOut,{className:`h-3 w-3`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(yt<120)ct(Math.min(120,yt+10));else{let e=I.indexOf(H);e>0&&(Bn(I[e-1]),ct(Se))}},"aria-label":P(`gantt.toolbar.zoomIn`),children:(0,p.jsx)(f.ZoomIn,{className:`h-3 w-3`})})]}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>ht(e=>!e),"aria-label":P(U?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":U,"data-testid":`gantt-toggle-task-list`,children:U?(0,p.jsx)(f.PanelLeft,{className:`h-4 w-4`}):(0,p.jsx)(f.PanelLeftClose,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:yr,disabled:vr==null,"aria-label":P(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:P(`gantt.toolbar.today`)}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Cr,"aria-label":P(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:P(`gantt.toolbar.thisWeek`)}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:wr,"aria-label":P(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:P(`gantt.toolbar.thisMonth`)}),le?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void le(),disabled:ue,"aria-label":P(`gantt.toolbar.refresh`),"aria-busy":ue,"data-testid":`gantt-refresh`,children:(0,p.jsx)(f.RefreshCw,{className:`h-4 w-4`})}):null,z?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Xt,disabled:!Qt,"aria-label":P(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,p.jsx)(f.Undo2,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Zt,disabled:!$t,"aria-label":P(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,p.jsx)(f.Redo2,{className:`h-4 w-4`})})]}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>oi(e=>!e),"aria-label":P(`gantt.toolbar.criticalPath`),"aria-pressed":ai,"data-testid":`gantt-critical-path`,style:ai?{color:li}:void 0,children:(0,p.jsx)(f.Activity,{className:`h-4 w-4`})}),rt&&z?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:mi,"aria-label":P(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,p.jsx)(f.Wand2,{className:`h-4 w-4`})}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:vi,"aria-label":P(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,p.jsx)(f.Download,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:yi,"aria-label":P(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,p.jsx)(f.FileDown,{className:`h-4 w-4`})}),oe||O?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Si,"aria-label":P(`gantt.toolbar.saveLayout`),"aria-pressed":bi,"data-testid":`gantt-save-layout`,style:bi?{color:li}:void 0,children:(0,p.jsx)(f.Save,{className:`h-4 w-4`})}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:pr,"aria-label":P(dr?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":dr,"data-testid":`gantt-fullscreen`,children:dr?(0,p.jsx)(f.Minimize2,{className:`h-4 w-4`}):(0,p.jsx)(f.Maximize2,{className:`h-4 w-4`})})]})]}),(0,p.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:jn,"data-testid":`gantt-body`,children:[!U&&W>0&&(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:W-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=W,r=Math.max(Ce,De-200),i=e=>{let i=Math.max(Ce,Math.min(n+(e.clientX-t),r));ut(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:()=>ut(null),children:(0,p.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,p.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,p.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:W,minWidth:W},children:[(0,p.jsx)(`div`,{className:`flex-1 truncate`,children:P(`gantt.column.taskName`)}),xt&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:P(`gantt.column.start`)}),(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:P(`gantt.column.end`)})]}),l&&(0,p.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},"aria-hidden":`true`,"data-testid":`gantt-header-open-spacer`})]}),(0,p.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:Gn,children:(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:Fn},children:[(0,p.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:Un.slice(ar.start,ar.end).map(e=>(0,p.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,p.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,p.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:Y.slice(rr.start,rr.end).map((e,t)=>{let n=rr.start+t;return(0,p.jsxs)(`div`,{className:(0,u.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:X[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,p.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&yt>=32&&(0,p.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:Kn,onScroll:zr,style:{width:W,minWidth:W},role:`tree`,"aria-label":P(`gantt.aria.taskList`),children:[$.startIdx>0&&(0,p.jsx)(`div`,{style:{height:$.startIdx*V},"aria-hidden":`true`}),q.slice($.startIdx,$.endIdx).map(e=>{let t=e.task,r=nt&&St===t.id,i=Dn.has(String(t.id)),a=Sn!=null&&String(Sn)===String(t.id);return(0,p.jsxs)(`div`,{className:(0,u.cn)(`group/task-row relative flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors`,a&&`bg-accent/50`),style:{height:V,touchAction:`manipulation`},role:`treeitem`,"data-testid":`gantt-task-row-${t.id}`,"aria-level":e.depth+1,"aria-selected":a,"aria-expanded":e.hasChildren?!i:void 0,draggable:!!tt&&!r&&!t.locked,onDragStart:tt?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:tt?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:tt?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=At.get(n);r&&String(r.parent??``)===String(t.parent??``)&&tt(r,t)}:void 0,onContextMenu:e=>Tn(t,e),onClick:()=>{Cn(t.id),r||Sr(e.start,e.end,t.id)},onDoubleClick:()=>{r||(nt&&z&&!e.isSummary&&!t.locked?(Ct(t.id),Tt({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:(0,n.toDateInputValue)(Ie(t.start,t.end)),progress:String(t.progress)})):l?.(t))},children:[(0,p.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,p.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(),kn(t.id)},"aria-expanded":!i,"aria-label":P(i?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:i?(0,p.jsx)(f.ChevronRight,{className:`h-3.5 w-3.5`}):(0,p.jsx)(f.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,p.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,p.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),r?(0,p.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:wt.title||``,onChange:e=>Tt(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Ht([{task:t,changes:{title:wt.title,start:(0,n.toDisplayDate)(wt.start),end:Le(wt.end,t),progress:Number(wt.progress)||0}}]),Ct(null)):e.key===`Escape`&&Ct(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,p.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,p.jsx)(`span`,{className:(0,u.cn)(`truncate`,e.isSummary&&`font-semibold`),"data-testid":`gantt-row-title-${t.id}`,children:t.title}),!xt&&(0,p.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`gantt-row-dates-${t.id}`,children:[e.start.toLocaleDateString(F,{month:`numeric`,day:`numeric`}),` → `,Ie(e.start,e.end).toLocaleDateString(F,{month:`numeric`,day:`numeric`})]})]})]}),xt&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground`,"data-testid":`gantt-row-start-${t.id}`,children:r?(0,p.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:wt.start||``,onChange:e=>Tt(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(F,{month:`numeric`,day:`numeric`})}),(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground`,"data-testid":`gantt-row-end-${t.id}`,children:r?(0,p.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:wt.end||``,onChange:e=>Tt(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):Ie(e.start,e.end).toLocaleDateString(F,{month:`numeric`,day:`numeric`})})]}),l&&(0,p.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!r&&(0,p.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(),l(t)},children:(0,p.jsx)(f.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),$.endIdx<q.length&&(0,p.jsx)(`div`,{style:{height:(q.length-$.endIdx)*V},"aria-hidden":`true`})]}),(0,p.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{qn.current=e,Q.current=e},onScroll:Rr,onTouchStart:hr,onTouchMove:gr,onTouchEnd:_r,"data-testid":`gantt-timeline`,children:(0,p.jsxs)(`div`,{className:`relative`,style:{width:Fn},children:[vr!=null&&(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:vr,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":P(`gantt.toolbar.today`),children:(0,p.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`)})}),Wn.map(e=>(0,p.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,p.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,p.jsxs)(`div`,{className:`relative`,ref:cn,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:Y.slice(rr.start,rr.end).map((e,t)=>{let n=rr.start+t;return(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:X[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)})}),Mn&&S&&S.showMidnight&&(0,p.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:Y.slice(rr.start,rr.end).map((e,t)=>{let n=rr.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=X[n]+(o-i)/r*e.width;return(0,p.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}`)})}),$.startIdx>0&&(0,p.jsx)(`div`,{style:{height:$.startIdx*V},"aria-hidden":`true`}),q.slice($.startIdx,$.endIdx).map((e,n)=>{let r=e.task,i=$.startIdx+n,a=ci(r.id),o=Br(e.start,e.end),s=ie&&r.baselineStart&&r.baselineEnd?Br(r.baselineStart,r.baselineEnd):null,c=s?(0,p.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:s.left,width:Math.max(2,s.width),top:ei,height:$r,backgroundColor:ti,border:`1px solid ${ni}`},"data-testid":`gantt-baseline-${r.id}`,"aria-hidden":`true`}):null,l=G?.taskId===r.id,d=Hr?.has(String(r.id))??!1,f=Ur?.has(String(r.id))??!1,m=l||d||f?Wr(e):o,h=!!r.locked,g=!!z&&!e.isSummary&&!h,_=g&&Ye,v=g&&Xe,y=g&&Ze,b=_||v,ee=R||h,te=K!=null&&K.targetId!=null&&String(K.targetId)===String(r.id)&&String(K.sourceId)!==String(r.id),ne=K!=null&&K.rejectedId!=null&&String(K.rejectedId)===String(r.id)?{cursor:`not-allowed`,boxShadow:`0 0 0 2px hsl(var(--destructive))`}:void 0,re=K?e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;ln(e=>{if(!e)return e;let t=on(e.sourceId,r);return t===null?{...e,targetId:r.id,targetEnd:n,rejectedId:null,rejectedReason:null}:{...e,targetId:null,targetEnd:null,rejectedId:r.id,rejectedReason:t}})}:void 0,x=K?e=>{e.target===e.currentTarget&&ln(e=>e&&{...e,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})}:void 0,S=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/je)),C=(i+1)*V+300>or&&i*V>300,w=Et===r.id&&!G&&!tn&&!K?(0,p.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:V-8}:{top:V-8}},role:`tooltip`,"data-testid":`gantt-tooltip-${r.id}`,children:[(0,p.jsx)(`div`,{className:`font-semibold`,children:r.title}),r.fields&&r.fields.length>0?(0,p.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:r.fields.map((e,n)=>(0,p.jsxs)(t.Fragment,{children:[(0,p.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,p.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,p.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.start.toLocaleDateString(F,{month:`short`,day:`numeric`}),` → `,Ie(e.start,e.end).toLocaleDateString(F,{month:`short`,day:`numeric`}),` · `,S,P(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),r.locked||R&&!z?(0,p.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,p.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:x,children:w},r.id);if(e.isSummary){let t=r.color||`#0d9488`,n=D===`self`&&r.hasOwnDates!==!1,i=!!z&&Ye&&!h,o=!!z&&Xe&&n&&!h;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:x,children:[c,(0,p.jsxs)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none group`,i&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Jn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Qr,height:Zr,cursor:i||o?void 0:ee?`not-allowed`:`pointer`,backgroundColor:t,borderColor:a?li:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${li}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-summary-bar-${r.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>Dt(r.id),onMouseLeave:()=>Dt(e=>e===r.id?null:e),onPointerMove:re,onPointerDown:t=>{if(t.button===0){if(o){let e=xe(t.clientX,t.currentTarget.getBoundingClientRect());if(e!==`move`){en(r,e,t);return}}i&&en(r,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})}},onClick:()=>{Pt.current||Cn(r.id)},onContextMenu:e=>Tn(r,e),children:[(0,p.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,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:be,height:Jr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&en(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:be,height:Jr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&en(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),(0,p.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=K!=null&&String(K.sourceId)===String(r.id)&&K.sourceEnd===e,n=t||Et===r.id,i=n&&K==null;return(0,p.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=cn.current?.getBoundingClientRect();ln({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})},onClick:e=>e.stopPropagation(),children:(0,p.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)})]}),l&&G&&(0,p.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:Qr+Zr+2},"data-testid":`gantt-summary-drag-chip-${r.id}`,children:[Ft(G).start.toLocaleDateString(F,{month:`numeric`,day:`numeric`}),` → `,It(G).toLocaleDateString(F,{month:`numeric`,day:`numeric`})]}),w]},r.id)}if(e.isMilestone){let e=Yr;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:x,children:[c,(0,p.jsx)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,_&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Jn===r.id&&`gantt-flash z-10`),style:{left:m.left-e/2,top:(V-e)/2,width:e,height:e,cursor:_?void 0:ee?`not-allowed`:`pointer`,backgroundColor:a?li:r.color||`#3b82f6`,borderColor:a?li:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${li}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-milestone-${r.id}`,onMouseEnter:()=>Dt(r.id),onMouseLeave:()=>Dt(e=>e===r.id?null:e),onClick:()=>{Pt.current||Cn(r.id)},onContextMenu:e=>Tn(r,e),onPointerMove:re,onPointerDown:_?e=>{e.button===0&&en(r,`move`,e)}:void 0}),w]},r.id)}let T=tn&&tn.taskId===r.id?tn.value:r.progress;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:V},onPointerMove:x,onMouseEnter:()=>Dt(r.id),onMouseLeave:()=>Dt(e=>e===r.id?null:e),children:[l&&(0,p.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:o.left,width:o.width,top:Kr,height:qr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),c,(0,p.jsxs)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rounded-sm bg-primary border shadow-sm flex items-center px-2 group select-none`,b&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Jn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Kr,height:qr,cursor:b?void 0:ee?`not-allowed`:`pointer`,backgroundColor:r.color||`#3b82f6`,borderColor:a?li:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${li}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-task-bar-${r.id}`,onClick:()=>{Pt.current||Cn(r.id)},onContextMenu:e=>Tn(r,e),onPointerMove:re,onPointerDown:b?e=>{if(e.button!==0)return;let t=xe(e.clientX,e.currentTarget.getBoundingClientRect()),n=t!==`move`&&v?t:_?`move`:null;n&&en(r,n,e)}:void 0,children:[v&&m.width>=14&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:be,height:Jr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&en(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:be,height:Jr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&en(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),T>0&&(0,p.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,p.jsx)(`div`,{className:(0,u.cn)(`absolute bottom-0 h-1/2 w-4 -translate-x-1/2 cursor-col-resize flex items-end justify-center pb-px`,tn?.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(),nn({taskId:r.id,originClientX:e.clientX,originProgress:r.progress,barWidth:m.width,value:r.progress}))},onClick:e=>e.stopPropagation(),children:(0,p.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=K!=null&&String(K.sourceId)===String(r.id)&&K.sourceEnd===e,n=t||Et===r.id,i=n&&K==null;return(0,p.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=cn.current?.getBoundingClientRect();ln({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})},onClick:e=>e.stopPropagation(),children:(0,p.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,p.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:r.title}),(0,p.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:l?`${Ft(G).start.toLocaleDateString(F,{month:`numeric`,day:`numeric`})} → ${It(G).toLocaleDateString(F,{month:`numeric`,day:`numeric`})}`:`${Math.round(T)}%`})]}),w]},r.id)}),$.endIdx<q.length&&(0,p.jsx)(`div`,{style:{height:(q.length-$.endIdx)*V},"aria-hidden":`true`}),(Gr.length>0||K)&&(0,p.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:Fn,height:or,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,p.jsxs)(`defs`,{children:[(0,p.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,p.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,p.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:li})})]}),Gr.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<$.startIdx-6||n>$.endIdx+6)return null;let r=ri(e);if(!r)return null;let i=ii!=null&&(String(e.sourceId)===String(ii)||String(e.targetId)===String(ii)),a=si?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(et||B);return(0,p.jsxs)(t.Fragment,{children:[(0,p.jsx)(`path`,{d:r,fill:`none`,stroke:a?li: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,p.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=>En(e.sourceId,e.targetId,e.type,t)})]},e.key)}),K&&(()=>{let e=q.findIndex(e=>String(e.task.id)===String(K.sourceId));if(e<0)return null;let t=Wr(q[e]),n=q[e].isMilestone?t.left+(K.sourceEnd===`start`?-Xr:Xr):K.sourceEnd===`start`?t.left:t.left+t.width,r=e*V+V/2;return(0,p.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(K.x)} ${Math.round(K.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),K&&(()=>{let e=N.find(e=>String(e.id)===String(K.sourceId));if(!e)return null;let t=K.targetId==null?null:N.find(e=>String(e.id)===String(K.targetId)),n=e=>P(`gantt.linkEnd.${e}`),r=t?`${e.title} (${n(K.sourceEnd)}) → ${t.title} (${n(K.targetEnd??`start`)})`:`${e.title} (${n(K.sourceEnd)})`;return(0,p.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:K.x+12,top:K.y+12},"data-testid":`gantt-link-draft-hint`,children:r})})()]})]})}),(0,p.jsx)(`div`,{ref:kr,className:`shrink-0 border-l bg-card/95 select-none`,style:{width:14,display:`none`},"data-testid":`gantt-vscrollbar`,children:(0,p.jsx)(`div`,{ref:Ar,className:`relative h-full`,onPointerDown:Lr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`vertical`,children:(0,p.jsx)(`div`,{ref:jr,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:Ir})})})]}),(0,p.jsx)(`div`,{ref:Tr,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,p.jsx)(`div`,{ref:Er,className:`relative`,style:{marginLeft:W,height:14},onPointerDown:Fr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`horizontal`,children:(0,p.jsx)(`div`,{ref:Dr,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:Pr})})})]}),dn&&(()=>{let e=N.find(e=>String(e.id)===String(dn.taskId));if(!e)return null;let t=q.find(e=>String(e.task.id)===String(dn.taskId)),r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,p.jsxs)(`div`,{ref:pn,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:dn.x,top:dn.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[l&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-view`,onClick:()=>{fn(null),l(e)},children:P(`gantt.menu.view`)}),nt&&z&&t&&!t.isSummary&&!e.locked&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-edit`,onClick:()=>{fn(null),Ct(e.id),Tt({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:(0,n.toDateInputValue)(Ie(e.start,e.end)),progress:String(e.progress)})},children:P(`gantt.menu.edit`)}),B&&t&&!t.isMilestone&&!e.locked&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let t=dn;fn(null),bn(``),vn({x:t.x,y:t.y,taskId:e.id,relation:`pred`})},children:P(`gantt.menu.addPredecessor`)}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let t=dn;fn(null),bn(``),vn({x:t.x,y:t.y,taskId:e.id,relation:`succ`})},children:P(`gantt.menu.addSuccessor`)})]}),$e&&!e.locked&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,u.cn)(r,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{fn(null),$e(e)},children:P(`gantt.menu.delete`)})]})})(),mn&&(()=>{let e=N.find(e=>String(e.id)===String(mn.sourceId)),t=N.find(e=>String(e.id)===String(mn.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,p.jsxs)(`div`,{ref:gn,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:mn.x,top:mn.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[e.title,` → `,t.title]}),i&&(0,p.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,P(`gantt.lockedHint`)]}),B&&A&&r.map(r=>(0,p.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":mn.type===r,disabled:i,className:(0,u.cn)(n,mn.type===r&&`font-semibold`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${r}`,onClick:()=>{i||(hn(null),r!==mn.type&&B(e,t,r))},children:[mn.type===r?`✓ `:`\xA0\xA0`,P(`gantt.linkType.${r}`)]},r)),et&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`my-1 border-t`}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:i,className:(0,u.cn)(n,`text-destructive`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{i||(hn(null),et(e,t))},children:P(`gantt.menu.removeDependency`)})]})]})})(),_n&&B&&(()=>{let e=N.find(e=>String(e.id)===String(_n.taskId));if(!e)return null;let t=new Set(Gr.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=_n.relation===`pred`?`${String(n.id)}->${String(e.id)}`:`${String(e.id)}->${String(n.id)}`;return!t.has(r)}),r=yn.trim().toLowerCase(),i=r?n.filter(e=>String(e.title??``).toLowerCase().includes(r)):n;return(0,p.jsxs)(`div`,{ref:xn,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:_n.x,top:_n.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,p.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:_n.relation===`pred`?P(`gantt.menu.addPredecessor`):P(`gantt.menu.addSuccessor`)}),(0,p.jsx)(`div`,{className:`px-2 pb-1`,children:(0,p.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:yn,onChange:e=>bn(e.target.value),placeholder:P(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),i.length===0?(0,p.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:P(`gantt.menu.noCandidates`)}):i.map(t=>(0,p.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:()=>{vn(null),_n.relation===`pred`?B(t,e,`fs`):B(e,t,`fs`)},children:t.title},String(t.id)))]})})(),ui&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-autoschedule-overlay`,onClick:()=>di(null),children:(0,p.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,p.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-autoschedule-title`,children:P(`gantt.autoScheduleDlg.title`)}),(0,p.jsxs)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:[P(`gantt.autoScheduleDlg.body`,{count:ui.changes.length}),ui.skipped>0&&(0,p.jsxs)(p.Fragment,{children:[` `,(0,p.jsx)(`span`,{"data-testid":`gantt-autoschedule-skipped`,children:P(`gantt.autoScheduleDlg.skipped`,{count:ui.skipped})})]})]}),(0,p.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,p.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:()=>di(null),children:P(`gantt.autoScheduleDlg.cancel`)}),(0,p.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:hi,children:P(`gantt.autoScheduleDlg.confirm`)})]})]})}),fi&&(0,p.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`)}),Ut&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>Wt(null),children:(0,p.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,p.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:P(`gantt.conflict.title`)}),(0,p.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:P(`gantt.conflict.body`,{count:Ut.length})}),(0,p.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,p.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:()=>Wt(null),children:P(`gantt.conflict.cancel`)}),(0,p.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:Jt,children:P(`gantt.conflict.confirm`)})]})]})})]})}function Ye(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 Xe(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)Ye(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 Ze={day:26,week:56,month:76,quarter:88,year:104},Qe=48,z=34,$e=180;function B(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 et({tasks:e,assignee:n,effort:r,capacity:i=1,viewMode:a=`day`,unassignedLabel:o=`Unassigned`,className:c}){let{t:l}=ye(),u=(0,s.useDisplayLocale)(),d=Ze[a],f=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=Me(t,a),i=L(Me(n,a),1,a),o=[],s=0;for(;r<i&&s++<4e3;){let e=L(r,1,a);o.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:B(r,a,u)}),r=e}return o},[e,a,u]),m=t.useMemo(()=>Xe(e,f.map(e=>e.col),{assignee:n,effort:r,capacity:i,unassignedLabel:o}),[e,f,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=f.length*d;return e.length?(0,p.jsx)(`div`,{className:c,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,p.jsxs)(`div`,{style:{display:`flex`,minWidth:$e+g},children:[(0,p.jsxs)(`div`,{style:{width:$e,flexShrink:0},children:[(0,p.jsx)(`div`,{style:{height:28,display:`flex`,alignItems:`center`,padding:`0 12px`,fontSize:12,fontWeight:600,borderBottom:`1px solid hsl(var(--border))`},children:l(`gantt.resource.header`)}),m.map(e=>(0,p.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:Qe,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,p.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,p.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:[l(`gantt.resource.peak`),`: `,Math.round(e.peak*100)/100,` / `,e.capacity,e.overloadedCount>0?` · ${e.overloadedCount} ${l(`gantt.resource.over`)}`:``]})]},e.key))]}),(0,p.jsxs)(`div`,{style:{flex:1},children:[(0,p.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:f.map((e,t)=>(0,p.jsx)(`div`,{style:{width:d,flexShrink:0,textAlign:`center`,fontSize:10,color:`hsl(var(--muted-foreground))`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:e.label},t))}),m.map(e=>{let t=z*(1-Math.min(e.capacity/h,1));return(0,p.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:Qe,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,p.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:7+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,z*Math.min(t.load/h,1));return(0,p.jsx)(`div`,{"data-testid":`resource-cell-${e.key}-${n}`,"data-load":t.load,"data-overloaded":t.overloaded?`true`:void 0,title:`${f[n]?.date.toLocaleDateString(u)} — ${Math.round(t.load*100)/100} / ${t.capacity}`,style:{width:d,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:7},children:t.load>0&&(0,p.jsx)(`div`,{style:{width:d-6,height:r,borderRadius:2,backgroundColor:t.overloaded?`hsl(var(--destructive))`:`hsl(var(--primary))`,opacity:t.overloaded?.9:.75}})},n)})]},e.key)})]})]})}):(0,p.jsx)(`div`,{className:c,"data-testid":`resource-workload`,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:l(`gantt.resource.empty`)})})}var tt={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},nt={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`},rt={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)`},it={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function V({checked:e}){return(0,p.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 at({filter:e,selected:n,onChange:r,labels:i}){let[a,o]=(0,t.useState)(!1),s=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);let c=new Set(n),l=n.length,u=e.options.length>0&&l===e.options.length,d=t=>{let n=new Set(c);n.has(t)?n.delete(t):n.add(t),n.size===e.options.length?r([]):r([...n])},f=()=>{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,p.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,p.jsxs)(`button`,{type:`button`,style:{...nt,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,p.jsx)(`span`,{children:m}),(0,p.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,p.jsx)(`div`,{role:`listbox`,style:rt,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,p.jsx)(`div`,{style:{...it,cursor:`default`,opacity:.6},children:i.empty}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...it,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>f(),children:[(0,p.jsx)(V,{checked:u}),(0,p.jsx)(`span`,{children:i.all})]}),(0,p.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,p.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...it,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>d(t.value),children:[(0,p.jsx)(V,{checked:n}),(0,p.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var ot=({filters:e,value:t,onChange:n,onClear:r,resultCount:i,totalCount:a,labels:o,className:s})=>{if(!e.length)return null;let c=o?.all??`All`,l=o?.empty??`No options`,u=o?.clear??`Clear`,d=e.some(e=>(t[e.field]?.length??0)>0);return(0,p.jsxs)(`div`,{style:tt,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,p.jsx)(at,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),d&&(0,p.jsx)(`button`,{type:`button`,style:{...nt,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,p.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function st(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 ct={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 lt(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=ct[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n)}return t}function ut(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 H(e,t){let r=(0,n.toDisplayDate)(e);return typeof e==`string`&&(0,n.isRealCalendarDate)(e)?N(t,r):r}function dt(e,t){let r=(0,n.toDisplayEndDate)(e);if(typeof e!=`string`||!(0,n.isRealCalendarDate)(e))return r;let i=N(t,r);return t.to(i).getTime()===r.getTime()?i:N(t,new Date(r.getTime()-1))}function ft(e,t,r,i,a=`start`){if(!(typeof t==`string`?t===`date`:typeof r==`string`&&(0,n.isRealCalendarDate)(r)))return e.toISOString();let o=ge(i,e);return(0,n.toDateInputValue)(a===`end`?(0,n.toInclusiveEndDay)(o):o)}var pt=()=>globalThis.process?.env?.NODE_ENV!==`production`,mt=[...Object.keys(a.GanttConfigSchema.shape),`dependencyField`],U=new Set;function ht(e){if(!pt())return;let t=mt.filter(t=>e[t]!==void 0);if(t.length===0)return;let n=`${e.type??`gantt`}::${e.objectName??``}::${t.join(`,`)}`;U.has(n)||(U.add(n),console.warn(`[ObjectGantt] The \`gantt\` block configures this chart, so these top-level keys are IGNORED: ${t.map(e=>`\`${e}\``).join(`, `)}. The \`gantt\` block is the authoring shape; the flat top-level spelling is the internal form ObjectView/ListView produce when they flatten \`options.gantt\`, and what the author wrote outranks it. The block is taken WHOLE — the flat keys are not merged into it — so move anything you still need into \`gantt\`, or drop the \`gantt\` block. objectui#6469.`))}function gt(e){if(e.gantt){let t=e.gantt,n=a.GanttConfigSchema.safeParse(t);return n.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,n.error.format()),ht(e),t}return e.startDateField&&e.endDateField?{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,viewMode:e.viewMode,timeSegments:e.timeSegments,interactions:e.interactions,exportFileName:e.exportFileName,timeZone:e.timeZone,dependencyTypes:e.dependencyTypes}:null}var _t=({schema:e,dataSource:f,className:m,onTaskClick:h,onRowClick:g,onBeforeTaskUpdate:_,...v})=>{let[y,b]=(0,t.useState)([]),[ee,te]=(0,t.useState)(!0),[ne,re]=(0,t.useState)(null),[x,S]=(0,t.useState)(null),{currency:ie}=(0,s.useLocalization)(),C=(0,s.useDisplayLocale)(),{t:w}=ye(),T=(0,t.useCallback)(e=>{i.toast.error(w(`gantt.writeFailed`),{description:ut(e)??void 0})},[w]),E=(0,n.resolveRecordSourceConfig)(e,`view-data`),ae=JSON.stringify(E),D=(0,t.useMemo)(()=>E,[ae]),O=gt(e),oe=D?.provider,se=oe===`value`,ce=(0,t.useContext)(r.SchemaRendererContext)?.apiFetch,k=(0,t.useMemo)(()=>(0,n.resolveDataSource)(D,f??null,{fetch:ce}),[D,f,ce]),le=(0,t.useRef)(k);le.current=k;let ue=JSON.stringify(E?.provider===`api`?{provider:`api`,read:E.read,write:E.write}:E?.provider===`value`?{provider:`value`,items:E.items}:{provider:E?.provider??null}),A=(0,n.resolveRecordSourceObjectName)(e,D)??``,{ready:fe,def:j}=(0,r.useSettledSchema)(A,se?void 0:k),pe=(0,l.usePermissions)(),he=typeof e.search==`string`&&e.search!==``?e.search:void 0,M=he&&Array.isArray(e.searchableFields)&&e.searchableFields.length>0?e.searchableFields:void 0,N=M?JSON.stringify(M):``,[ge,_e]=(0,t.useState)(!1),ve=(0,r.useFilterScope)(),P=(0,r.useResolvedFilter)(e.filter,ve),be=(0,t.useRef)(0),xe=(0,t.useRef)(!1),Se=(0,t.useRef)(!1),Ce=v.data,F=Array.isArray(Ce)&&Ce.length>0?Ce:null,we=(0,t.useRef)(F);we.current=F;let Te=(0,t.useCallback)(async({silent:t=!1,inPlace:r=t}={})=>{let i=++be.current,a=()=>be.current===i,o=!t||Se.current;Se.current=o;try{r?_e(!0):te(!0);let t=we.current;if(t){a()&&(b(t),S(null),re(null),xe.current=!0);return}let i=le.current;if(!i||typeof i.find!=`function`)throw Error(`DataSource required for object/api providers`);let o=(0,n.buildExpandFields)(j?.fields),s=!pe?.isLoaded||!A?o:o.filter(e=>pe.checkField(A,e,`read`)),c=await i.find(A,{$filter:P,$orderby:(0,n.convertSortToQueryParams)(e.sort),...(0,n.nonGridRowCeilingQuery)(),...s.length>0?{$expand:s}:{},...he?{$search:he,...M?{$searchFields:M}:{}}:{}}),l=(0,n.applyNonGridRowCeiling)(c);a()&&(b(l.rows),S(l),re(null),xe.current=!0)}catch(e){o?a()&&re(e):console.error(`[ObjectGantt] Failed to refresh data:`,e)}finally{a()&&(Se.current=!1,_e(!1),te(!1))}},[ue,f,ce,A,se,oe,P,e.sort,he,N,j,pe]),Ee=F===null&&!se,De=(0,t.useRef)(Te);De.current=Te,(0,t.useEffect)(()=>{(!Ee||fe)&&De.current(xe.current?{inPlace:!0}:{})},[ue,f,ce,A,se,oe,P,e.sort,he,N,j,pe,Ee,fe]);let Oe=(0,r.useDataInvalidation)(Ee&&A?A:void 0),ke=(0,t.useRef)(0);(0,t.useEffect)(()=>{Oe!==ke.current&&(ke.current=Oe,(!Ee||fe)&&De.current({silent:!0}))},[Oe,Ee,fe]);let I=(0,t.useMemo)(()=>{if(!O||!y.length)return[];let{startDateField:e,endDateField:t,titleField:r,progressField:i,dependenciesField:a,colorField:c,borderColorField:l,parentField:u,typeField:f,lockField:p,tooltipFields:m,baselineStartField:h,baselineEndField:g,quickFilters:_}=O,v=j?.fields??{},b=me(O.timeZone),ee=(0,n.createFieldColorResolver)(v[c??``]),te=(0,n.createFieldColorResolver)(v[l??``]),ne=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&&ne.set(e.field,t)}let re=(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},x=e=>{let t=[re(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)(j,e)},S=(e,t)=>{if(t)return t;let n=v[e]??v[e.split(`.`)[0]];return n?.label?n.label:(0,d.humanizeLabel)(e)},w=(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=ne.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,d.formatDate)(e,void 0,{locale:C});if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(e)&&!isNaN(new Date(e).getTime()))return(0,d.formatDateTime)(e,{locale:C})}switch(r){case`date`:return(0,d.formatDate)(e,void 0,{locale:C});case`datetime`:return(0,d.formatDateTime)(e,{locale:C});case`number`:case`integer`:case`float`:case`decimal`:{let t=(0,o.resolveFieldScale)({type:n?.type,scale:n?.scale});return(0,s.formatDisplayNumber)(Number(e),t===void 0?{locale:C,minimumFractionDigits:0,maximumFractionDigits:20}:{locale:C,minimumFractionDigits:t,maximumFractionDigits:t})}case`currency`:return(0,d.formatCurrency)(Number(e),(0,s.resolveFieldCurrency)(n,ie),C);case`percent`:return(0,d.formatPercent)(Number(e),(0,d.percentCellScale)(n),(0,o.resolveFieldScale)({type:n?.type,scale:n?.scale}),C);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)}},T=e=>{if(!m||!m.length)return;let t=[];for(let n of m){let r=typeof n==`string`?n:n?.field;if(!r)continue;let i=typeof n==`object`?n.label:void 0,a=re(e,r);a==null||a===``||Array.isArray(a)&&a.length===0||t.push({label:S(r,i),value:w(a,r)})}return t.length?t:void 0};return y.map((n,r)=>{let o=n[e],s=n[t],m=h?n[h]:void 0,_=g?n[g]:void 0,v=m?H(m,b):void 0,y=_?dt(_,b):void 0,ne=x(n),re=i?n[i]:0,S=a?n[a]:[],ie=c?n[c]:void 0,C=ee(ie);if(!C&&ie!=null&&ie!==``&&(C=(0,d.getSemanticHex)((0,d.getSemanticColorName)(String(ie),ie))),!C){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,d.getSemanticColorName)(void 0,e);t&&(C=(0,d.getSemanticHex)(t))}}let w=l?n[l]:void 0,E=w!=null&&w!==``?te(w)??(0,d.getSemanticHex)(String(w),String(w)):void 0;return{id:n.id||n._id||`task-${r}`,title:ne,start:o?H(o,b):new Date,end:s?dt(s,b):new Date,hasOwnDates:!!(o&&s),progress:Math.min(100,Math.max(0,re||0)),dependencies:lt(S),parent:u?n[u]??null:void 0,type:f?st(n[f]):void 0,locked:p?!!n[p]:void 0,color:C,borderColor:E,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:y&&!isNaN(y.getTime())?y:void 0,fields:T(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[y,O,j,C,ie]),Ae=(0,t.useMemo)(()=>{let e=O?.groupByField;if(!e)return;let t=j?.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)}}},[O?.groupByField,j]),je=(0,t.useMemo)(()=>{let e=O?.assigneeField;if(!e)return;let t=j?.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)}}},[O?.assigneeField,j]),Me=(0,t.useMemo)(()=>{let e=O?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[O?.effortField]),Ne=(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]),L=(0,t.useMemo)(()=>de(O?.timeSegments),[O?.timeSegments]),Pe=(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)},[]),Fe=O?.quickFilters,[Ie,Le]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!Fe?.length||!f||typeof f.find!=`function`)return;let e=j?.fields??{},t=!1;return(async()=>{let r={};for(let t of Fe){if(t.options)continue;let i=e[t.field]??e[t.field.split(`.`)[0]],a=i?.type;if(a!==`lookup`&&a!==`master_detail`)continue;let o=i?.reference;if(o)try{let e=await f.find(o,{$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||Le(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(Fe),f,j]);let Re=(0,t.useMemo)(()=>{if(!Fe?.length)return[];let e=j?.fields??{};return Fe.map(t=>{let n=e[t.field]??e[t.field.split(`.`)[0]],r=t.label??n?.label??(0,d.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(Ie[t.field]?.length)i=Ie[t.field];else{let e=new Map;for(let n of y){let r=Pe(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}})},[Fe,j,Ie,y,Pe]),ze=e.persistLayout===!1?void 0:`${e.objectName||(D?.provider===`object`?D.object:``)||`gantt`}:${e.viewName||`default`}`,Be=ze?`gantt-layout:${ze}:filters`:null,[Ve,He]=(0,t.useState)(()=>{if(!Be||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(Be)||`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{}}}),Ue=(0,t.useCallback)(()=>{if(!(!Be||typeof window>`u`))try{window.localStorage.setItem(Be,JSON.stringify(Ve))}catch{}},[Be,Ve]),We=(0,t.useCallback)((e,t)=>{He(n=>({...n,[e]:t}))},[]),Ge=(0,t.useCallback)(()=>He({}),[]),Ke=(0,t.useCallback)(e=>!!O?.objectField&&!String(e?.[O.objectField]??``).trim(),[O?.objectField]),qe=(0,t.useCallback)(e=>{let t=(O?.objectField?String(e[O.objectField]??``).trim():``)||A,n=e.id??e._id;if(!t||n==null)return null;let r=A?(0,c.deriveRecordPageHref)(A,n):null;return{objectName:t,recordId:n,href:!A||t===A?r:r?.replace(`/${A}/record/`,`/${t}/record/`)??null}},[O?.objectField,A]),Je=(0,t.useMemo)(()=>{let e=Object.entries(Ve).filter(([,e])=>e.length>0);if(!e.length)return I;let t=new Map(I.map(e=>[String(e.id),e])),n=new Set;for(let r of I){if(!e.every(([e,t])=>{let n=Pe(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 I.filter(e=>n.has(String(e.id)))},[I,Ve,Pe]),Ye=(0,t.useMemo)(()=>{if(O?.autoZoomToFilter!==!1||!I.length)return null;let e=1/0,t=-1/0;for(let n of I){let r=n.start.getTime(),i=n.end.getTime();e=Math.min(e,r),t=Math.max(t,i>r?i-1:r)}return{start:new Date(e),end:new Date(t)}},[I,O?.autoZoomToFilter]),Xe=e.navigation??{mode:`drawer`},Ze=Xe.mode===`drawer`||Xe.mode===`modal`||Xe.mode===`split`||Xe.mode===`popover`,Qe=(0,t.useCallback)((e,t)=>{if(typeof window>`u`)return;let n=String(e),r=I.find(e=>{let t=e.data;return!!t&&String(t.id??t._id)===n})?.data,i=r?qe(r)?.href??null:A?(0,c.deriveRecordPageHref)(A,e):null;if(i){if(t===`new_window`){window.open(i,`_blank`);return}window.history.pushState({},``,i),window.dispatchEvent(new PopStateEvent(`popstate`))}},[I,qe,A]),z=(0,r.useNavigationOverlay)({navigation:Xe,objectName:e.objectName,onNavigate:Qe,onRowClick:Ze?void 0:g}),{anchorRef:$e,anchorCaptureProps:B}=(0,u.useOverlayAnchor)(),[tt,nt]=(0,t.useState)(null),rt=z.isOverlay&&z.isOpen?z.selectedRecord:null;(0,t.useEffect)(()=>{if(!rt){nt(null);return}let e=qe(rt);if(!e){nt(null);return}let{objectName:t,recordId:n}=e;if(D?.provider!==`api`&&t===A||!f||typeof f.findOne!=`function`){nt(null);return}let r=`${t}:${n}`,i=!1;return(async()=>{try{let[e,a]=await Promise.all([f.findOne(t,String(n)),typeof f.getObjectSchema==`function`?f.getObjectSchema(t).catch(()=>null):Promise.resolve(null)]);i||nt(e?{key:r,record:e,schema:a}:null)}catch(e){console.error(`[ObjectGantt] Failed to fetch drawer record, falling back to row payload:`,e),i||nt(null)}})(),()=>{i=!0}},[rt,qe,D?.provider,A,f]);let it=(0,t.useCallback)(async(e,t)=>{if(!O||!k||typeof k.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=O,o=j?.fields,s=e.data??{},c=me(O.timeZone),l={};if(t.start instanceof Date&&(l[n]=ft(t.start,o?.[n]?.type,s[n],c)),t.end instanceof Date&&(l[r]=ft(t.end,o?.[r]?.type,s[r],c,`end`)),typeof t.title==`string`&&i&&(l[i]=t.title),typeof t.progress==`number`&&a&&(l[a]=t.progress),Object.keys(l).length===0)return;let u=e.data?.id??e.data?._id??e.id;if(u==null)return;let d=y;b(e=>e.map(e=>String(e.id??e._id)===String(u)?{...e,...l}:e));try{await k.update(A,String(u),l),Te({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),b(d),T(e)}},[O,k,A,y,Te,T,j]),V=(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)},at=(0,t.useCallback)(async(e,t,n)=>{let r=O?.dependenciesField;if(!r||!k||typeof k.update!=`function`)return;let i=V(t,n),a=y;b(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await k.update(A,String(e),{[r]:i}),Te({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),b(a),T(e)}},[O,k,A,y,Te,T]),ct=(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=O?.dependenciesField;if(!a)return;let o=y.find(e=>String(e.id??e._id)===String(i))?.[a],s=lt(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 at(i,o,f)},[O,y,at]),pt=(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=O?.dependenciesField;if(!i)return;let a=y.find(e=>String(e.id??e._id)===String(r))?.[i],o=lt(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await at(r,a,c)},[O,y,at]),[mt,U]=(0,t.useState)(null),[ht,_t]=(0,t.useState)(!1),W=(0,t.useCallback)(e=>{U(e)},[]),vt=(0,t.useCallback)(async()=>{if(!mt)return;if(!k?.delete){U(null);return}let e=mt.data?.id??mt.data?._id??mt.id;if(e==null){U(null);return}_t(!0);let t=y;b(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await k.delete(A,String(e))===!1)throw Error(w(`gantt.writeFailed`));U(null),Te({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),b(t),U(null),T(e)}finally{_t(!1)}},[mt,k,A,y,Te,T,w]);if(ee)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})});if(ne)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ne.message]})})});if(!O)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})});let yt=t=>{if(!z.isOverlay||!z.isOpen||!z.selectedRecord)return null;let n=z.selectedRecord,r=qe(n);if(!r||Ke(n))return null;let{objectName:i,recordId:a}=r,o=r.href??void 0,s=O?.titleField?String(n[O.titleField]??w(`gantt.drawer.fallbackTitle`)):w(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(O?.lockField?!!n[O.lockField]:!1),d=tt?.key===`${i}:${a}`?tt:null,m=d?.record??n,h=d?.schema??(i===A?j:void 0),g=d&&f?f:k;return(0,p.jsx)(u.NavigationOverlay,{...z,title:s,mainContent:t,popoverAnchorRef:$e,storageKey:(0,u.recordOverlayWidthStorageKey)(i),legacyStorageKey:(0,u.legacyRecordDrawerWidthKey)(i),width:z.width??c.RECORD_OVERLAY_DEFAULT_WIDTH,children:()=>(0,p.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,p.jsx)(c.RecordDetailPanel,{record:m,objectName:i,recordId:a,dataSource:g??void 0,objectSchema:h,onClose:z.close,fullPageHref:o,onFieldSave:l?void 0:async(e,t)=>{if(g?.update){try{await g.update(i,String(a),{[e]:t})}catch(e){let t=ut(e);throw t?Error(t):e}d&&nt(n=>n&&n.key===d.key?{...n,record:{...n.record,[e]:t}}:n),b(n=>n.map(n=>String(n.id??n._id)===String(a)?{...n,[e]:t}:n)),Te({silent:!0})}},onDelete:l?void 0:async()=>{if(k?.delete){try{if(await k.delete(i,String(a))===!1)throw Error(w(`gantt.writeFailed`))}catch(e){throw T(e),e}b(e=>e.filter(e=>String(e.id??e._id)!==String(a)))}}})})})},bt=(0,p.jsxs)(`div`,{className:(0,u.cn)(`flex h-full min-h-0 flex-col`,m),...B,children:[Re.length>0&&(0,p.jsx)(ot,{filters:Re,value:Ve,onChange:We,onClear:Ge,resultCount:Je.length,totalCount:I.length,labels:{all:w(`gantt.quickFilter.all`),clear:w(`gantt.quickFilter.clear`),empty:w(`gantt.quickFilter.empty`),resultSummary:(e,t)=>w(`gantt.quickFilter.resultSummary`).replace(`{shown}`,String(e)).replace(`{total}`,String(t))}}),(0,p.jsxs)(`div`,{className:`relative flex-1 min-h-[420px]`,children:[(0,p.jsx)(u.RefreshIndicator,{active:ge,ariaLabel:w(`gantt.aria.refreshing`)}),O?.resourceView&&je?(0,p.jsx)(et,{tasks:Je,assignee:je,effort:Me,capacity:O?.capacity??1,viewMode:O?.viewMode||`day`}):(0,p.jsx)(R,{tasks:Je,viewMode:O?.viewMode,startDate:Ye?.start,endDate:Ye?.end,onTaskClick:e=>{Ke(e.data)||z.handleClick(e.data),h?.(e.data)},onTaskUpdate:it,onTaskDelete:W,onDependencyCreate:O?.dependenciesField?ct:void 0,onDependencyDelete:O?.dependenciesField?pt:void 0,markers:e.markers,autoSchedule:!!O?.dependenciesField,rescheduleOnConflict:!!O?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:Ne,shiftSegments:L,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:ze,onLayoutChange:Be?Ue:void 0,groupBy:Ae,defaultCollapsedDepth:O?.defaultCollapsedDepth,summaryExtent:O?.summaryExtent,interactions:O?.interactions,dependencyTypes:O?.dependencyTypes,timeZone:O?.timeZone,onBeforeTaskUpdate:_,exportFileName:String(O?.exportFileName??(0,a.resolveI18nLabel)(e.label,C)??j?.label??e.objectName??``)||void 0,inlineEdit:!0,onRefresh:(D?.provider===`object`||D?.provider===`api`)&&typeof k?.find==`function`?()=>Te({silent:!0}):void 0,refreshing:ge})]}),x&&(0,p.jsx)(r.NonGridRowCeilingNote,{result:x}),(0,p.jsx)(u.AlertDialog,{open:!!mt,onOpenChange:e=>{!e&&!ht&&U(null)},children:(0,p.jsxs)(u.AlertDialogContent,{children:[(0,p.jsxs)(u.AlertDialogHeader,{children:[(0,p.jsx)(u.AlertDialogTitle,{children:w(`gantt.delete.title`)}),(0,p.jsx)(u.AlertDialogDescription,{children:mt?w(`gantt.delete.body`,{title:mt.title}):null})]}),(0,p.jsxs)(u.AlertDialogFooter,{children:[(0,p.jsx)(u.AlertDialogCancel,{disabled:ht,children:w(`gantt.delete.cancel`)}),(0,p.jsx)(u.AlertDialogAction,{onClick:e=>{e.preventDefault(),vt()},disabled:ht,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:w(ht?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]});if(z.isOverlay&&z.mode===`split`&&z.isOpen&&z.selectedRecord){let e=yt(bt);if(e)return(0,p.jsx)(p.Fragment,{children:e})}return(0,p.jsxs)(p.Fragment,{children:[bt,yt()]})},W={filter:!0,sort:!0},vt=(0,n.elementDataSourceBlock)(({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{},n=t??void 0;return(0,p.jsx)(r.ElementDataSourceGate,{schema:e,mapping:W,dataSource:n,testId:`object-gantt`,errorTitle:`This gantt chart’s data source could not be resolved`,children:e=>(0,p.jsx)(_t,{schema:e,dataSource:n})})});n.ComponentRegistry.register(`object-gantt`,vt,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,description:"ObjectQL object name. The record source is one of `data`, `staticData` and `objectName`; the `object-gantt` schema refuses a block that declares none of them, unless the node's `dataSource.object` names the object, which then lands on this key."},{name:`gantt`,type:`object`,description:"Gantt-timeline configuration, the author face — the same block `ListViewSchema.gantt` declares, and the one the renderer validates this node against. Taken WHOLE when present: the flat top-level spelling beside it is ignored. The spec requires `startDateField`, `endDateField` and `titleField`, which name the record fields a task's bar starts at, ends at and is titled by; the other members (`progressField`, `colorField`, `dependenciesField`, `parentField`, `viewMode`, `exportFileName`, …) are optional."},{name:`data`,type:`object`,description:"A `{ provider, … }` data-source configuration, read FIRST on the record-source ladder: a gantt carrying one never reaches `staticData` and never queries `objectName`. `{ provider: 'value', items }` charts those rows, `{ provider: 'object', object }` queries that object and `{ provider: 'api', read }` reads through that request. A bare array is not this key’s shape and is not a record source: the gantt falls through to `staticData`, then `objectName`, so inline rows belong under `staticData`."},{name:`staticData`,type:`array`,description:"Inline records, read SECOND on the record-source ladder: a `data` configuration wins and this key is then never reached, while `objectName` is read AFTER it, so a gantt carrying both charts these rows and never queries that object. `filter` and `sort` narrow and order these rows exactly as they do fetched ones."},{name:`filter`,type:`array`,description:"Base query filter in the rule-array form `[{ field, operator, value }, ...]`, narrowing the tasks the gantt charts — from every record source it reads: the object, an `api` request, or inline rows. Context tokens such as `{current_user_id}` are resolved first, then the filter is lowered to `$filter` on the query. The MongoDB-style record form is not this key’s shape."},{name:`sort`,type:`array`,description:"Task order in `[{ field, order }]` form, ordering the rows the gantt charts. Lowered to `$orderby` on the same query."},{name:`navigation`,type:`object`,description:"What a task click opens — the `{ mode, size, openNewTab, preventNavigation }` block a list view declares. With the key ABSENT a click opens the task's record in a drawer, this renderer's own default. `mode` is an overlay (`drawer`, `modal`, `split`, `popover`), `new_window`, `page` or `none`, and a block written without `mode` takes the spec's `page` default. `drawer`, `modal` and `popover` open the task's record in that overlay, and `split` opens it beside the chart, which stays drawn; `none` opens nothing. `page` opens the task's record page in the same tab and `new_window` opens it in a new tab. The gantt builds that address itself from the page it is on and does not use a record navigator the host publishes, so a host that publishes one changes nothing: on the object's own list or view route (`…/OBJECT/view/VIEW`) the address is the record page `…/OBJECT/record/ID`, while on any other page, such as a custom page, `/OBJECT/record/ID` is appended to the current address. The object is `data.object` when `data` is the object provider, else `objectName`; on inline rows that name neither there is no record to open, and every mode, the default drawer included, opens nothing. `preventNavigation: true` opens nothing whatever the mode, `openNewTab: true` opens the record page in a new tab and outranks every mode except `none`, and `size` sets the overlay width."},{name:`label`,type:[`string`,`object`],description:'Gantt label — the second link of the exported PNG/PDF file-name chain, after `gantt.exportFileName` and before the bound object\'s own label. A string is used as written, and an inline locale map (`{ en, "zh-CN", … }`) gives the entry for the display locale. The chart draws it nowhere else.'},{name:`skipWeekends`,type:`boolean`,description:`Measure duration and auto-schedule math in WORKING days, skipping Saturdays and Sundays. The day view also folds the Saturday and Sunday columns out of its axis.`},{name:`holidays`,type:`array`,of:`string`,description:"Additional non-working dates for the working calendar, ISO `yyyy-mm-dd` strings; folded into a Set for the duration math. A non-empty list turns the working calendar on by itself, without `skipWeekends`, and the day view folds each listed date's column out of its axis."},{name:`persistLayout`,type:`boolean`,description:"Opt OUT of layout and filter-chip persistence — only an explicit `false` disables it; the storage key is `objectName:viewName`. The object half is `objectName`, else `data.object`, and `gantt` on inline rows that name neither. With `false` the toolbar has no save-layout button and nothing is stored."},{name:`viewName`,type:`string`,description:"Layout-persistence scope, the second half of the `objectName:viewName` storage key (renderer default `'default'`). Two gantts on the same object with different names keep separate saved layouts, and a gantt restores only the layout saved under its own name."},{name:`markers`,type:`array`,description:"Extra vertical reference lines drawn like the Today marker ({ date, label?, color? }). `date` places the line, and a date outside the chart's range draws none; `label` is the text drawn against it; `color` is its CSS colour, the theme's primary colour when omitted."},{name:`criticalPath`,type:`boolean`,description:`Seed the critical-path highlight ON; the toolbar toggle stays available either way`},{name:`showBaselines`,type:`boolean`,description:"Render the planned-vs-actual baseline bars — ON unless an explicit `false` disables it. A task draws one only when `gantt.baselineStartField` and `gantt.baselineEndField` give it both baseline dates."},{name:`readOnly`,type:`boolean`,description:`Disable every write path on this gantt and lock the record drawer. A task click still opens the record, read-only.`},{name:`mobileReadOnly`,type:`boolean`,description:"Auto read-only on narrow viewports — ON unless an explicit `false` disables it. Narrow is under 640px: the chart's own width once it is measured, the viewport's until then. A narrow chart's own write paths are gated as under `readOnly`, read-only badge included, but the record drawer is locked by `readOnly` alone, so a task's record still opens writable. `false` keeps a narrow chart editable, and `readOnly: true` locks the chart and the drawer at any width."}]}),e.GanttView=R,e.ObjectGantt=_t,e.ObjectGanttRenderer=vt,e.QuickFilterBar=ot,e.ResourceWorkload=et,e.bandAt=j,e.computeWorkload=Xe,e.normalizeDependencies=lt,e.normalizeShiftSegments=de,e.normalizeTaskType=st,e.parseHHMM=A,e.shiftDayStart=fe});
|
|
63
|
+
`}),(0,p.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,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":F(`gantt.toolbar.prevPeriod`),"data-testid":`gantt-toolbar-prev-period`,onClick:()=>fr(-1),children:(0,p.jsx)(f.ChevronLeft,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":F(`gantt.toolbar.nextPeriod`),"data-testid":`gantt-toolbar-next-period`,onClick:()=>fr(1),children:(0,p.jsx)(f.ChevronRight,{className:`h-4 w-4`})}),(0,p.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,"data-testid":`gantt-toolbar-period`,children:dr}),R&&(0,p.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,p.jsx)(f.Lock,{className:`h-3 w-3`}),F(`gantt.readOnly`)]})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`div`,{className:`flex bg-muted rounded-md p-1`,role:`group`,"aria-label":F(`gantt.toolbar.viewMode`),children:ke.map(e=>(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:(0,u.cn)(`h-6 px-1.5 sm:px-2 text-xs`,U===e&&`bg-background shadow-sm hover:bg-background`),onClick:()=>Hn(e),"aria-pressed":U===e,"data-testid":`gantt-view-mode-${e}`,children:F(`gantt.viewMode.${e}`)},e))}),(0,p.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(xt>15)lt(Math.max(15,xt-10));else{let e=ke.indexOf(U);e<ke.length-1&&(Hn(ke[e+1]),lt(xe))}},"aria-label":F(`gantt.toolbar.zoomOut`),children:(0,p.jsx)(f.ZoomOut,{className:`h-3 w-3`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>{if(xt<120)lt(Math.min(120,xt+10));else{let e=ke.indexOf(U);e>0&&(Hn(ke[e-1]),lt(xe))}},"aria-label":F(`gantt.toolbar.zoomIn`),children:(0,p.jsx)(f.ZoomIn,{className:`h-3 w-3`})})]}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>_t(e=>!e),"aria-label":F(gt?`gantt.toolbar.showTaskList`:`gantt.toolbar.hideTaskList`),"aria-pressed":gt,"data-testid":`gantt-toggle-task-list`,children:gt?(0,p.jsx)(f.PanelLeft,{className:`h-4 w-4`}):(0,p.jsx)(f.PanelLeftClose,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:xr,disabled:br==null,"aria-label":F(`gantt.toolbar.jumpToToday`),"data-testid":`gantt-jump-today`,children:F(`gantt.toolbar.today`)}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Tr,"aria-label":F(`gantt.toolbar.thisWeek`),"data-testid":`gantt-jump-week`,children:F(`gantt.toolbar.thisWeek`)}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-xs`,onClick:Er,"aria-label":F(`gantt.toolbar.thisMonth`),"data-testid":`gantt-jump-month`,children:F(`gantt.toolbar.thisMonth`)}),ce?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>void ce(),disabled:j,"aria-label":F(`gantt.toolbar.refresh`),"aria-busy":j,"data-testid":`gantt-refresh`,children:(0,p.jsx)(f.RefreshCw,{className:`h-4 w-4`})}):null,B?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:Qt,disabled:!en,"aria-label":F(`gantt.toolbar.undo`),"data-testid":`gantt-undo`,children:(0,p.jsx)(f.Undo2,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:$t,disabled:!tn,"aria-label":F(`gantt.toolbar.redo`),"data-testid":`gantt-redo`,children:(0,p.jsx)(f.Redo2,{className:`h-4 w-4`})})]}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>ci(e=>!e),"aria-label":F(`gantt.toolbar.criticalPath`),"aria-pressed":si,"data-testid":`gantt-critical-path`,style:si?{color:di}:void 0,children:(0,p.jsx)(f.Activity,{className:`h-4 w-4`})}),it&&B?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:gi,"aria-label":F(`gantt.toolbar.autoSchedule`),"data-testid":`gantt-auto-schedule`,children:(0,p.jsx)(f.Wand2,{className:`h-4 w-4`})}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:bi,"aria-label":F(`gantt.toolbar.exportPng`),"data-testid":`gantt-export-png`,children:(0,p.jsx)(f.Download,{className:`h-4 w-4`})}),(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:xi,"aria-label":F(`gantt.toolbar.exportPdf`),"data-testid":`gantt-export-pdf`,children:(0,p.jsx)(f.FileDown,{className:`h-4 w-4`})}),ae||k?(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:wi,"aria-label":F(`gantt.toolbar.saveLayout`),"aria-pressed":Si,"data-testid":`gantt-save-layout`,style:Si?{color:di}:void 0,children:(0,p.jsx)(f.Save,{className:`h-4 w-4`})}):null,(0,p.jsx)(u.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:hr,"aria-label":F(pr?`gantt.toolbar.exitFullscreen`:`gantt.toolbar.enterFullscreen`),"aria-pressed":pr,"data-testid":`gantt-fullscreen`,children:pr?(0,p.jsx)(f.Minimize2,{className:`h-4 w-4`}):(0,p.jsx)(f.Maximize2,{className:`h-4 w-4`})})]})]}),(0,p.jsxs)(`div`,{className:`relative flex flex-col flex-1 overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-ring`,tabIndex:0,onKeyDown:Nn,"data-testid":`gantt-body`,children:[!gt&&W>0&&(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 z-30 group/splitter`,style:{left:W-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=W,r=Math.max(Se,Ye-200),i=e=>{let i=Math.max(Se,Math.min(n+(e.clientX-t),r));dt(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:()=>dt(null),children:(0,p.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,p.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 gantt-sm-h50`,children:[(0,p.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:W,minWidth:W},children:[(0,p.jsx)(`div`,{className:`flex-1 truncate`,children:F(`gantt.column.taskName`)}),Ct&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:F(`gantt.column.start`)}),(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right`,children:F(`gantt.column.end`)})]}),l&&(0,p.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},"aria-hidden":`true`,"data-testid":`gantt-header-open-spacer`})]}),(0,p.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:qn,children:(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,style:{width:Ln},children:[(0,p.jsx)(`div`,{className:`relative border-b`,style:{height:`45%`},"data-testid":`gantt-header-groups`,children:Gn.slice(sr.start,sr.end).map(e=>(0,p.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,p.jsx)(`span`,{className:`truncate px-1`,children:e.label})},e.key))}),(0,p.jsx)(`div`,{className:`relative flex-1`,"data-testid":`gantt-header-units`,children:Y.slice(ar.start,ar.end).map((e,t)=>{let n=ar.start+t;return(0,p.jsxs)(`div`,{className:(0,u.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:X[n],width:e.width,backgroundColor:e.bandColor?`color-mix(in srgb, ${e.bandColor} 16%, transparent)`:void 0},children:[(0,p.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.label}),e.sublabel&&xt>=32&&(0,p.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.sublabel})]},n)})})]})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`gantt-task-list overflow-y-auto overflow-x-hidden border-r bg-card z-10 shadow-sm`,ref:Jn,onScroll:Vr,style:{width:W,minWidth:W},role:`tree`,"aria-label":F(`gantt.aria.taskList`),children:[$.startIdx>0&&(0,p.jsx)(`div`,{style:{height:$.startIdx*H},"aria-hidden":`true`}),q.slice($.startIdx,$.endIdx).map(e=>{let t=e.task,r=rt&&wt===t.id,i=kn.has(String(t.id)),a=wn!=null&&String(wn)===String(t.id);return(0,p.jsxs)(`div`,{className:(0,u.cn)(`group/task-row relative flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors`,a&&`bg-accent/50`),style:{height:H,touchAction:`manipulation`},role:`treeitem`,"data-testid":`gantt-task-row-${t.id}`,"aria-level":e.depth+1,"aria-selected":a,"aria-expanded":e.hasChildren?!i:void 0,draggable:!!nt&&!r&&!t.locked,onDragStart:nt?e=>{e.dataTransfer.setData(`text/plain`,String(t.id)),e.dataTransfer.effectAllowed=`move`}:void 0,onDragOver:nt?e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}:void 0,onDrop:nt?e=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);if(!n||n===String(t.id))return;let r=Mt.get(n);r&&String(r.parent??``)===String(t.parent??``)&&nt(r,t)}:void 0,onContextMenu:e=>Dn(t,e),onClick:()=>{Tn(t.id),r||wr(e.start,e.end,t.id)},onDoubleClick:()=>{r||(rt&&B&&!e.isSummary&&!t.locked?(Tt(t.id),Dt({title:t.title,start:t.start.toLocaleDateString(`en-CA`),end:(0,n.toDateInputValue)(Ie(t.start,t.end)),progress:String(t.progress)})):l?.(t))},children:[(0,p.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,p.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(),jn(t.id)},"aria-expanded":!i,"aria-label":F(i?`gantt.row.expand`:`gantt.row.collapse`),"data-testid":`gantt-row-toggle-${t.id}`,children:i?(0,p.jsx)(f.ChevronRight,{className:`h-3.5 w-3.5`}):(0,p.jsx)(f.ChevronDown,{className:`h-3.5 w-3.5`})}):(0,p.jsx)(`span`,{className:`w-3 shrink-0`,style:{marginLeft:-4},"aria-hidden":`true`}),(0,p.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:t.color||`#3b82f6`}}),r?(0,p.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:Et.title||``,onChange:e=>Dt(t=>({...t,title:e.target.value})),onKeyDown:e=>{e.key===`Enter`?(Wt([{task:t,changes:{title:Et.title,start:(0,n.toDisplayDate)(Et.start),end:Le(Et.end,t),progress:Number(Et.progress)||0}}]),Tt(null)):e.key===`Escape`&&Tt(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,p.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,p.jsx)(`span`,{className:(0,u.cn)(`truncate`,e.isSummary&&`font-semibold`),"data-testid":`gantt-row-title-${t.id}`,children:t.title}),!Ct&&(0,p.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`gantt-row-dates-${t.id}`,children:[I(e.start,`numeric`),` → `,I(Ie(e.start,e.end),`numeric`)]})]})]}),Ct&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground`,"data-testid":`gantt-row-start-${t.id}`,children:r?(0,p.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:Et.start||``,onChange:e=>Dt(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):I(e.start,`numeric`)}),(0,p.jsx)(`div`,{className:`w-16 gantt-sm-w20 text-right text-xs text-muted-foreground`,"data-testid":`gantt-row-end-${t.id}`,children:r?(0,p.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:Et.end||``,onChange:e=>Dt(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):I(Ie(e.start,e.end),`numeric`)})]}),l&&(0,p.jsx)(`div`,{className:`w-6 shrink-0 hidden sm:block`,style:{marginLeft:4},children:!r&&(0,p.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(),l(t)},children:(0,p.jsx)(f.ArrowRight,{className:`h-3.5 w-3.5`})})})]},t.id)}),$.endIdx<q.length&&(0,p.jsx)(`div`,{style:{height:(q.length-$.endIdx)*H},"aria-hidden":`true`})]}),(0,p.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{Yn.current=e,Q.current=e},onScroll:Br,onTouchStart:_r,onTouchMove:vr,onTouchEnd:yr,"data-testid":`gantt-timeline`,children:(0,p.jsxs)(`div`,{className:`relative`,style:{width:Ln},children:[br!=null&&(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px z-20 pointer-events-none`,style:{left:br,backgroundColor:`rgba(239, 68, 68, 0.8)`},"data-testid":`gantt-today-marker`,"aria-label":F(`gantt.toolbar.today`),children:(0,p.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`)})}),Kn.map(e=>(0,p.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,p.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,p.jsxs)(`div`,{className:`relative`,ref:un,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:Y.slice(ar.start,ar.end).map((e,t)=>{let n=ar.start+t;return(0,p.jsx)(`div`,{className:`absolute top-0 bottom-0 border-r`,style:{left:X[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)})}),Pn&&C&&C.showMidnight&&(0,p.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:0},children:Y.slice(ar.start,ar.end).map((e,t)=>{let n=ar.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=X[n]+(o-i)/r*e.width;return(0,p.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}`)})}),$.startIdx>0&&(0,p.jsx)(`div`,{style:{height:$.startIdx*H},"aria-hidden":`true`}),q.slice($.startIdx,$.endIdx).map((e,n)=>{let r=e.task,i=$.startIdx+n,a=ui(r.id),o=Hr(e.start,e.end),s=re&&r.baselineStart&&r.baselineEnd?Hr(r.baselineStart,r.baselineEnd):null,c=s?(0,p.jsx)(`div`,{className:`absolute pointer-events-none rounded-[1px]`,style:{left:s.left,width:Math.max(2,s.width),top:ni,height:ti,backgroundColor:ri,border:`1px solid ${ii}`},"data-testid":`gantt-baseline-${r.id}`,"aria-hidden":`true`}):null,l=G?.taskId===r.id,d=Wr?.has(String(r.id))??!1,f=Gr?.has(String(r.id))??!1,m=l||d||f?Kr(e):o,h=!!r.locked,g=!!B&&!e.isSummary&&!h,_=g&&Ze,v=g&&z,y=g&&Qe,b=_||v,ee=R||h,te=K!=null&&K.targetId!=null&&String(K.targetId)===String(r.id)&&String(K.sourceId)!==String(r.id),ne=K!=null&&K.rejectedId!=null&&String(K.rejectedId)===String(r.id)?{cursor:`not-allowed`,boxShadow:`0 0 0 2px hsl(var(--destructive))`}:void 0,x=K?e=>{let t=e.currentTarget.getBoundingClientRect(),n=t.width>0&&e.clientX-t.left>t.width/2?`end`:`start`;dn(e=>{if(!e)return e;let t=cn(e.sourceId,r);return t===null?{...e,targetId:r.id,targetEnd:n,rejectedId:null,rejectedReason:null}:{...e,targetId:null,targetEnd:null,rejectedId:r.id,rejectedReason:t}})}:void 0,S=K?e=>{e.target===e.currentTarget&&dn(e=>e&&{...e,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})}:void 0,C=Math.max(1,Math.round((e.end.getTime()-e.start.getTime())/je)),w=(i+1)*H+300>cr&&i*H>300,T=Ot===r.id&&!G&&!rn&&!K?(0,p.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:H-8}:{top:H-8}},role:`tooltip`,"data-testid":`gantt-tooltip-${r.id}`,children:[(0,p.jsx)(`div`,{className:`font-semibold`,children:r.title}),r.fields&&r.fields.length>0?(0,p.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto 1fr`,columnGap:10,rowGap:2,marginTop:4},children:r.fields.map((e,n)=>(0,p.jsxs)(t.Fragment,{children:[(0,p.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,p.jsx)(`span`,{style:{fontWeight:500},children:e.value})]},n))}):(0,p.jsxs)(`div`,{className:`text-muted-foreground`,children:[I(e.start,`short`),` → `,I(Ie(e.start,e.end),`short`),` · `,C,F(`gantt.tooltip.days`),` · `,Math.round(e.progress),`%`]}),r.locked||R&&!B?(0,p.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,p.jsx)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:H},onPointerMove:S,children:T},r.id);if(e.isSummary){let t=r.color||`#0d9488`,n=O===`self`&&r.hasOwnDates!==!1,i=!!B&&Ze&&!h,o=!!B&&z&&n&&!h;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:H},onPointerMove:S,children:[c,(0,p.jsxs)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rounded-sm border shadow-sm flex items-center px-2 select-none group`,i&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Xn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:ei,height:$r,cursor:i||o?void 0:ee?`not-allowed`:`pointer`,backgroundColor:t,borderColor:a?di:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${di}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-summary-bar-${r.id}`,"data-progress":Math.round(e.progress),onMouseEnter:()=>kt(r.id),onMouseLeave:()=>kt(e=>e===r.id?null:e),onPointerMove:x,onPointerDown:t=>{if(t.button===0){if(o){let e=be(t.clientX,t.currentTarget.getBoundingClientRect());if(e!==`move`){nn(r,e,t);return}}i&&nn(r,`move`,t,{group:!0,originStart:e.start,originEnd:e.end})}},onClick:()=>{It.current||Tn(r.id)},onContextMenu:e=>Dn(r,e),children:[(0,p.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,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:ye,height:Xr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&nn(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:ye,height:Xr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&nn(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),(0,p.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none`,children:r.title}),V&&!h&&[`start`,`end`].map(e=>{let t=K!=null&&String(K.sourceId)===String(r.id)&&K.sourceEnd===e,n=t||Ot===r.id,i=n&&K==null;return(0,p.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=un.current?.getBoundingClientRect();dn({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})},onClick:e=>e.stopPropagation(),children:(0,p.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)})]}),l&&G&&(0,p.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:ei+$r+2},"data-testid":`gantt-summary-drag-chip-${r.id}`,children:[I(Lt(G).start,`numeric`),` → `,I(Rt(G),`numeric`)]}),T]},r.id)}if(e.isMilestone){let e=Zr;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:H},onPointerMove:S,children:[c,(0,p.jsx)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rotate-45 rounded-[2px] border shadow-sm select-none`,_&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Xn===r.id&&`gantt-flash z-10`),style:{left:m.left-e/2,top:(H-e)/2,width:e,height:e,cursor:_?void 0:ee?`not-allowed`:`pointer`,backgroundColor:a?di:r.color||`#3b82f6`,borderColor:a?di:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${di}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-milestone-${r.id}`,onMouseEnter:()=>kt(r.id),onMouseLeave:()=>kt(e=>e===r.id?null:e),onClick:()=>{It.current||Tn(r.id)},onContextMenu:e=>Dn(r,e),onPointerMove:x,onPointerDown:_?e=>{e.button===0&&nn(r,`move`,e)}:void 0}),T]},r.id)}let E=rn&&rn.taskId===r.id?rn.value:r.progress;return(0,p.jsxs)(`div`,{className:`relative border-b hover:bg-accent/50`,style:{height:H},onPointerMove:S,onMouseEnter:()=>kt(r.id),onMouseLeave:()=>kt(e=>e===r.id?null:e),children:[l&&(0,p.jsx)(`div`,{className:`absolute rounded-sm border border-dashed pointer-events-none`,style:{left:o.left,width:o.width,top:Jr,height:Yr,opacity:.35,borderColor:`hsl(var(--primary) / 0.6)`},"aria-hidden":`true`}),c,(0,p.jsxs)(`div`,{className:(0,u.cn)(`gantt-bar-hover absolute rounded-sm bg-primary border shadow-sm flex items-center px-2 group select-none`,b&&`cursor-grab active:cursor-grabbing`,l&&`ring-2 ring-primary z-10`,te&&`ring-2 ring-primary`,Xn===r.id&&`gantt-flash z-10`),style:{left:m.left,width:m.width,top:Jr,height:Yr,cursor:b?void 0:ee?`not-allowed`:`pointer`,backgroundColor:r.color||`#3b82f6`,borderColor:a?di:r.borderColor||`hsl(var(--primary-foreground) / 0.2)`,boxShadow:a?`0 0 0 2px ${di}`:r.borderColor?`0 0 0 2px ${r.borderColor}`:void 0,...ne},"data-critical":a?`true`:void 0,"data-testid":`gantt-task-bar-${r.id}`,onClick:()=>{It.current||Tn(r.id)},onContextMenu:e=>Dn(r,e),onPointerMove:x,onPointerDown:b?e=>{if(e.button!==0)return;let t=be(e.clientX,e.currentTarget.getBoundingClientRect()),n=t!==`move`&&v?t:_?`move`:null;n&&nn(r,n,e)}:void 0,children:[v&&m.width>=14&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute left-0 top-0`,style:{width:ye,height:Xr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-left-${r.id}`,onPointerDown:e=>{e.button===0&&nn(r,`resize-left`,e)},onClick:e=>e.stopPropagation()}),(0,p.jsx)(`div`,{className:`gantt-resize-handle absolute right-0 top-0`,style:{width:ye,height:Xr,cursor:`ew-resize`},"data-testid":`gantt-task-resize-right-${r.id}`,onPointerDown:e=>{e.button===0&&nn(r,`resize-right`,e)},onClick:e=>e.stopPropagation()})]}),E>0&&(0,p.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,p.jsx)(`div`,{className:(0,u.cn)(`absolute bottom-0 h-1/2 w-4 -translate-x-1/2 cursor-col-resize flex items-end justify-center pb-px`,rn?.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(),an({taskId:r.id,originClientX:e.clientX,originProgress:r.progress,barWidth:m.width,value:r.progress}))},onClick:e=>e.stopPropagation(),children:(0,p.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))`}})}),V&&!h&&[`start`,`end`].map(e=>{let t=K!=null&&String(K.sourceId)===String(r.id)&&K.sourceEnd===e,n=t||Ot===r.id,i=n&&K==null;return(0,p.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=un.current?.getBoundingClientRect();dn({sourceId:r.id,sourceEnd:e,x:n?t.clientX-n.left:0,y:n?t.clientY-n.top:0,targetId:null,targetEnd:null,rejectedId:null,rejectedReason:null})},onClick:e=>e.stopPropagation(),children:(0,p.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,p.jsx)(`span`,{className:`relative text-[10px] text-white font-medium truncate pointer-events-none group-hover:opacity-0 transition-opacity`,children:r.title}),(0,p.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:l?`${I(Lt(G).start,`numeric`)} → ${I(Rt(G),`numeric`)}`:`${Math.round(E)}%`})]}),T]},r.id)}),$.endIdx<q.length&&(0,p.jsx)(`div`,{style:{height:(q.length-$.endIdx)*H},"aria-hidden":`true`}),(qr.length>0||K)&&(0,p.jsxs)(`svg`,{className:`absolute top-0 left-0 pointer-events-none z-10`,width:Ln,height:cr,"data-testid":`gantt-links`,"aria-hidden":`true`,children:[(0,p.jsxs)(`defs`,{children:[(0,p.jsx)(`marker`,{id:`gantt-link-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--muted-foreground))`})}),(0,p.jsx)(`marker`,{id:`gantt-link-arrow-active`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:`hsl(var(--primary))`})}),(0,p.jsx)(`marker`,{id:`gantt-link-arrow-critical`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,p.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,fill:di})})]}),qr.map(e=>{let n=Math.min(e.sourceIndex,e.targetIndex);if(Math.max(e.sourceIndex,e.targetIndex)<$.startIdx-6||n>$.endIdx+6)return null;let r=ai(e);if(!r)return null;let i=oi!=null&&(String(e.sourceId)===String(oi)||String(e.targetId)===String(oi)),a=li?.criticalEdges.has(`${String(e.sourceId)}->${String(e.targetId)}`)??!1,o=a?`gantt-link-arrow-critical`:i?`gantt-link-arrow-active`:`gantt-link-arrow`,s=!!(tt||V);return(0,p.jsxs)(t.Fragment,{children:[(0,p.jsx)(`path`,{d:r,fill:`none`,stroke:a?di: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,p.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=>On(e.sourceId,e.targetId,e.type,t)})]},e.key)}),K&&(()=>{let e=q.findIndex(e=>String(e.task.id)===String(K.sourceId));if(e<0)return null;let t=Kr(q[e]),n=q[e].isMilestone?t.left+(K.sourceEnd===`start`?-Qr:Qr):K.sourceEnd===`start`?t.left:t.left+t.width,r=e*H+H/2;return(0,p.jsx)(`path`,{d:`M ${Math.round(n)} ${Math.round(r)} L ${Math.round(K.x)} ${Math.round(K.y)}`,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,strokeDasharray:`4 3`,"data-testid":`gantt-link-draft`})})()]}),K&&(()=>{let e=P.find(e=>String(e.id)===String(K.sourceId));if(!e)return null;let t=K.targetId==null?null:P.find(e=>String(e.id)===String(K.targetId)),n=e=>F(`gantt.linkEnd.${e}`),r=t?`${e.title} (${n(K.sourceEnd)}) → ${t.title} (${n(K.targetEnd??`start`)})`:`${e.title} (${n(K.sourceEnd)})`;return(0,p.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:K.x+12,top:K.y+12},"data-testid":`gantt-link-draft-hint`,children:r})})()]})]})}),(0,p.jsx)(`div`,{ref:jr,className:`shrink-0 border-l bg-card/95 select-none`,style:{width:14,display:`none`},"data-testid":`gantt-vscrollbar`,children:(0,p.jsx)(`div`,{ref:Mr,className:`relative h-full`,onPointerDown:zr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`vertical`,children:(0,p.jsx)(`div`,{ref:Nr,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:Rr})})})]}),(0,p.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,p.jsx)(`div`,{ref:Or,className:`relative`,style:{marginLeft:W,height:14},onPointerDown:Lr,role:`scrollbar`,"aria-controls":`gantt-timeline`,"aria-orientation":`horizontal`,children:(0,p.jsx)(`div`,{ref:kr,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:Ir})})})]}),pn&&(()=>{let e=P.find(e=>String(e.id)===String(pn.taskId));if(!e)return null;let t=q.find(e=>String(e.task.id)===String(pn.taskId)),r=`w-full text-left px-3 py-1.5 hover:bg-accent focus:bg-accent outline-none`;return(0,p.jsxs)(`div`,{ref:hn,className:`fixed z-50 min-w-[160px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:pn.x,top:pn.y},role:`menu`,"data-testid":`gantt-context-menu`,children:[l&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-view`,onClick:()=>{mn(null),l(e)},children:F(`gantt.menu.view`)}),rt&&B&&t&&!t.isSummary&&!e.locked&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-edit`,onClick:()=>{mn(null),Tt(e.id),Dt({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:(0,n.toDateInputValue)(Ie(e.start,e.end)),progress:String(e.progress)})},children:F(`gantt.menu.edit`)}),V&&t&&!t.isMilestone&&!e.locked&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-predecessor`,onClick:()=>{let t=pn;mn(null),Sn(``),bn({x:t.x,y:t.y,taskId:e.id,relation:`pred`})},children:F(`gantt.menu.addPredecessor`)}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:r,"data-testid":`gantt-context-menu-add-successor`,onClick:()=>{let t=pn;mn(null),Sn(``),bn({x:t.x,y:t.y,taskId:e.id,relation:`succ`})},children:F(`gantt.menu.addSuccessor`)})]}),et&&!e.locked&&(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,className:(0,u.cn)(r,`text-destructive`),"data-testid":`gantt-context-menu-delete`,onClick:()=>{mn(null),et(e)},children:F(`gantt.menu.delete`)})]})})(),gn&&(()=>{let e=P.find(e=>String(e.id)===String(gn.sourceId)),t=P.find(e=>String(e.id)===String(gn.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,p.jsxs)(`div`,{ref:vn,className:`fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md py-1 text-sm`,style:{left:gn.x,top:gn.y},role:`menu`,"data-testid":`gantt-link-context-menu`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground truncate`,children:[e.title,` → `,t.title]}),i&&(0,p.jsxs)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,"data-testid":`gantt-link-menu-locked`,children:[`🚫 `,F(`gantt.lockedHint`)]}),V&&le&&r.map(r=>(0,p.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":gn.type===r,disabled:i,className:(0,u.cn)(n,gn.type===r&&`font-semibold`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-type-${r}`,onClick:()=>{i||(_n(null),r!==gn.type&&V(e,t,r))},children:[gn.type===r?`✓ `:`\xA0\xA0`,F(`gantt.linkType.${r}`)]},r)),tt&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`my-1 border-t`}),(0,p.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:i,className:(0,u.cn)(n,`text-destructive`,i&&`opacity-50 cursor-not-allowed hover:bg-transparent`),"data-testid":`gantt-link-menu-remove`,onClick:()=>{i||(_n(null),tt(e,t))},children:F(`gantt.menu.removeDependency`)})]})]})})(),yn&&V&&(()=>{let e=P.find(e=>String(e.id)===String(yn.taskId));if(!e)return null;let t=new Set(qr.map(e=>`${String(e.sourceId)}->${String(e.targetId)}`)),n=P.filter(n=>{if(String(n.id)===String(e.id)||n.type===`group`||n.locked)return!1;let r=yn.relation===`pred`?`${String(n.id)}->${String(e.id)}`:`${String(e.id)}->${String(n.id)}`;return!t.has(r)}),r=xn.trim().toLowerCase(),i=r?n.filter(e=>String(e.title??``).toLowerCase().includes(r)):n;return(0,p.jsxs)(`div`,{ref:Cn,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:yn.x,top:yn.y},role:`menu`,"data-testid":`gantt-dep-picker`,children:[(0,p.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:yn.relation===`pred`?F(`gantt.menu.addPredecessor`):F(`gantt.menu.addSuccessor`)}),(0,p.jsx)(`div`,{className:`px-2 pb-1`,children:(0,p.jsx)(`input`,{className:`border rounded px-2 py-1 text-sm w-full bg-background`,value:xn,onChange:e=>Sn(e.target.value),placeholder:F(`gantt.menu.searchTasks`),"data-testid":`gantt-dep-picker-search`,autoFocus:!0})}),i.length===0?(0,p.jsx)(`div`,{className:`px-3 py-1.5 text-muted-foreground`,children:F(`gantt.menu.noCandidates`)}):i.map(t=>(0,p.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:()=>{bn(null),yn.relation===`pred`?V(t,e,`fs`):V(e,t,`fs`)},children:t.title},String(t.id)))]})})(),fi&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-autoschedule-overlay`,onClick:()=>pi(null),children:(0,p.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,p.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-autoschedule-title`,children:F(`gantt.autoScheduleDlg.title`)}),(0,p.jsxs)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:[F(`gantt.autoScheduleDlg.body`,{count:fi.changes.length}),fi.skipped>0&&(0,p.jsxs)(p.Fragment,{children:[` `,(0,p.jsx)(`span`,{"data-testid":`gantt-autoschedule-skipped`,children:F(`gantt.autoScheduleDlg.skipped`,{count:fi.skipped})})]})]}),(0,p.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,p.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:()=>pi(null),children:F(`gantt.autoScheduleDlg.cancel`)}),(0,p.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:_i,children:F(`gantt.autoScheduleDlg.confirm`)})]})]})}),mi&&(0,p.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`)}),Gt&&(0,p.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/30`,"data-testid":`gantt-conflict-overlay`,onClick:()=>Kt(null),children:(0,p.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,p.jsx)(`div`,{className:`text-sm font-semibold mb-1`,"data-testid":`gantt-conflict-title`,children:F(`gantt.conflict.title`)}),(0,p.jsx)(`div`,{className:`text-sm text-muted-foreground mb-3`,children:F(`gantt.conflict.body`,{count:Gt.length})}),(0,p.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,p.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:()=>Kt(null),children:F(`gantt.conflict.cancel`)}),(0,p.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:Xt,children:F(`gantt.conflict.confirm`)})]})]})})]})}function Xe(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 R(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)Xe(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 Ze={day:26,week:56,month:76,quarter:88,year:104},z=48,Qe=34,$e=180;function B(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 et({tasks:e,assignee:n,effort:r,capacity:a=1,viewMode:o=`day`,unassignedLabel:s=`Unassigned`,className:c}){let{t:l}=ve(),u=(0,i.useDisplayLocale)(),d=Ze[o],f=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=Me(t,o),i=L(Me(n,o),1,o),a=[],s=0;for(;r<i&&s++<4e3;){let e=L(r,1,o);a.push({date:new Date(r),col:{start:new Date(r),end:new Date(e)},label:B(r,o,u)}),r=e}return a},[e,o,u]),m=t.useMemo(()=>R(e,f.map(e=>e.col),{assignee:n,effort:r,capacity:a,unassignedLabel:s}),[e,f,n,r,a,s]),h=t.useMemo(()=>{let e=0;for(let t of m)e=Math.max(e,t.peak,t.capacity);return e||1},[m]),g=f.length*d;return e.length?(0,p.jsx)(`div`,{className:c,"data-testid":`resource-workload`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`auto`},children:(0,p.jsxs)(`div`,{style:{display:`flex`,minWidth:$e+g},children:[(0,p.jsxs)(`div`,{style:{width:$e,flexShrink:0},children:[(0,p.jsx)(`div`,{style:{height:28,display:`flex`,alignItems:`center`,padding:`0 12px`,fontSize:12,fontWeight:600,borderBottom:`1px solid hsl(var(--border))`},children:l(`gantt.resource.header`)}),m.map(e=>(0,p.jsxs)(`div`,{"data-testid":`resource-row-${e.key}`,style:{height:z,display:`flex`,flexDirection:`column`,justifyContent:`center`,padding:`0 12px`,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,p.jsx)(`span`,{style:{fontSize:13,fontWeight:500,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,p.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:[l(`gantt.resource.peak`),`: `,Math.round(e.peak*100)/100,` / `,e.capacity,e.overloadedCount>0?` · ${e.overloadedCount} ${l(`gantt.resource.over`)}`:``]})]},e.key))]}),(0,p.jsxs)(`div`,{style:{flex:1},children:[(0,p.jsx)(`div`,{style:{display:`flex`,height:28,borderBottom:`1px solid hsl(var(--border))`},children:f.map((e,t)=>(0,p.jsx)(`div`,{style:{width:d,flexShrink:0,textAlign:`center`,fontSize:10,color:`hsl(var(--muted-foreground))`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:e.label},t))}),m.map(e=>{let t=Qe*(1-Math.min(e.capacity/h,1));return(0,p.jsxs)(`div`,{style:{position:`relative`,display:`flex`,height:z,borderBottom:`1px solid hsl(var(--border) / 0.5)`},children:[(0,p.jsx)(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:0,right:0,top:7+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,Qe*Math.min(t.load/h,1));return(0,p.jsx)(`div`,{"data-testid":`resource-cell-${e.key}-${n}`,"data-load":t.load,"data-overloaded":t.overloaded?`true`:void 0,title:`${f[n]?.date.toLocaleDateString(u)} — ${Math.round(t.load*100)/100} / ${t.capacity}`,style:{width:d,flexShrink:0,position:`relative`,borderLeft:`1px solid hsl(var(--border) / 0.4)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,paddingBottom:7},children:t.load>0&&(0,p.jsx)(`div`,{style:{width:d-6,height:r,borderRadius:2,backgroundColor:t.overloaded?`hsl(var(--destructive))`:`hsl(var(--primary))`,opacity:t.overloaded?.9:.75}})},n)})]},e.key)})]})]})}):(0,p.jsx)(`div`,{className:c,"data-testid":`resource-workload`,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-40 text-sm text-muted-foreground`,children:l(`gantt.resource.empty`)})})}var V={display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid hsl(var(--border))`,background:`hsl(var(--background))`,fontSize:13},tt={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`},nt={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)`},rt={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,borderRadius:6,cursor:`pointer`,userSelect:`none`};function it({checked:e}){return(0,p.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 at({filter:e,selected:n,onChange:r,labels:i}){let[a,o]=(0,t.useState)(!1),s=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);let c=new Set(n),l=n.length,u=e.options.length>0&&l===e.options.length,d=t=>{let n=new Set(c);n.has(t)?n.delete(t):n.add(t),n.size===e.options.length?r([]):r([...n])},f=()=>{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,p.jsxs)(`div`,{ref:s,style:{position:`relative`},"data-testid":`quick-filter-${e.field}`,children:[(0,p.jsxs)(`button`,{type:`button`,style:{...tt,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,p.jsx)(`span`,{children:m}),(0,p.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:10,opacity:.7},children:`▾`})]}),a&&(0,p.jsx)(`div`,{role:`listbox`,style:nt,"data-testid":`quick-filter-panel-${e.field}`,children:e.options.length===0?(0,p.jsx)(`div`,{style:{...rt,cursor:`default`,opacity:.6},children:i.empty}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{role:`option`,"aria-selected":u,style:{...rt,fontWeight:600},"data-testid":`quick-filter-all-${e.field}`,onClick:()=>f(),children:[(0,p.jsx)(it,{checked:u}),(0,p.jsx)(`span`,{children:i.all})]}),(0,p.jsx)(`div`,{style:{height:1,background:`hsl(var(--border))`,margin:`2px 0`}}),e.options.map(t=>{let n=c.has(t.value);return(0,p.jsxs)(`div`,{role:`option`,"aria-selected":n,style:{...rt,background:n?`hsl(var(--accent, var(--muted)))`:`transparent`},"data-testid":`quick-filter-option-${e.field}-${t.value}`,onClick:()=>d(t.value),children:[(0,p.jsx)(it,{checked:n}),(0,p.jsx)(`span`,{children:t.label})]},t.value)})]})})]})}var H=({filters:e,value:t,onChange:n,onClear:r,resultCount:i,totalCount:a,labels:o,className:s})=>{if(!e.length)return null;let c=o?.all??`All`,l=o?.empty??`No options`,u=o?.clear??`Clear`,d=e.some(e=>(t[e.field]?.length??0)>0);return(0,p.jsxs)(`div`,{style:V,className:s,"data-testid":`quick-filter-bar`,children:[e.map(e=>(0,p.jsx)(at,{filter:e,selected:t[e.field]??[],onChange:t=>n(e.field,t),labels:{all:c,empty:l}},e.field)),d&&(0,p.jsx)(`button`,{type:`button`,style:{...tt,height:28,color:`hsl(var(--muted-foreground))`},"data-testid":`quick-filter-clear`,onClick:r,children:u}),o?.resultSummary&&i!=null&&a!=null&&(0,p.jsx)(`span`,{"data-testid":`quick-filter-summary`,style:{marginLeft:`auto`,color:`hsl(var(--muted-foreground))`},children:o.resultSummary(i,a)})]})};function ot(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 st={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 ct(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=st[String(n.type??``).toLowerCase().replace(/-/g,`_`)];t.push(r?{id:e,type:r}:{id:e})}else t.push(n)}return t}function lt(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 ut(e,t){let r=(0,n.toDisplayDate)(e);return typeof e==`string`&&(0,n.isRealCalendarDate)(e)?P(t,r):r}function dt(e,t){let r=(0,n.toDisplayEndDate)(e);if(typeof e!=`string`||!(0,n.isRealCalendarDate)(e))return r;let i=P(t,r);return t.to(i).getTime()===r.getTime()?i:P(t,new Date(r.getTime()-1))}function U(e,t,r,i,a=`start`){if(!(typeof t==`string`?t===`date`:typeof r==`string`&&(0,n.isRealCalendarDate)(r)))return e.toISOString();let o=he(i,e);return(0,n.toDateInputValue)(a===`end`?(0,n.toInclusiveEndDay)(o):o)}var ft=()=>globalThis.process?.env?.NODE_ENV!==`production`,pt=[...Object.keys(o.GanttConfigSchema.shape),`dependencyField`],mt=new Set;function ht(e){if(!ft())return;let t=pt.filter(t=>e[t]!==void 0);if(t.length===0)return;let n=`${e.type??`gantt`}::${e.objectName??``}::${t.join(`,`)}`;mt.has(n)||(mt.add(n),console.warn(`[ObjectGantt] The \`gantt\` block configures this chart, so these top-level keys are IGNORED: ${t.map(e=>`\`${e}\``).join(`, `)}. The \`gantt\` block is the authoring shape; the flat top-level spelling is the internal form ObjectView/ListView produce when they flatten \`options.gantt\`, and what the author wrote outranks it. The block is taken WHOLE — the flat keys are not merged into it — so move anything you still need into \`gantt\`, or drop the \`gantt\` block. objectui#6469.`))}function gt(e){if(e.gantt){let t=e.gantt,n=o.GanttConfigSchema.safeParse(t);return n.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,n.error.format()),ht(e),t}return e.startDateField&&e.endDateField?{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,viewMode:e.viewMode,timeSegments:e.timeSegments,interactions:e.interactions,exportFileName:e.exportFileName,timeZone:e.timeZone,dependencyTypes:e.dependencyTypes}:null}var _t=({schema:e,dataSource:f,className:m,onTaskClick:h,onRowClick:g,onBeforeTaskUpdate:_,...v})=>{let[y,b]=(0,t.useState)([]),[ee,te]=(0,t.useState)(!0),[ne,x]=(0,t.useState)(null),[S,C]=(0,t.useState)(null),{currency:re}=(0,i.useLocalization)(),w=(0,i.useDisplayLocale)(),{t:T}=ve(),E=(0,t.useCallback)(e=>{a.toast.error(T(`gantt.writeFailed`),{description:lt(e)??void 0})},[T]),D=(0,n.resolveRecordSourceConfig)(e,`view-data`),ie=JSON.stringify(D),O=(0,t.useMemo)(()=>D,[ie]),k=gt(e),ae=O?.provider,oe=ae===`value`,A=(0,t.useMemo)(()=>(0,n.resolveDataSource)(O,f??null),[O,f]),se=(0,t.useRef)(A);se.current=A;let ce=JSON.stringify(D?.provider===`value`?{provider:`value`,items:D.items}:{provider:D?.provider??null}),j=(0,n.resolveRecordSourceObjectName)(e,O)??``,{ready:le,def:M}=(0,r.useSettledSchema)(j,oe?void 0:A),de=(0,l.usePermissions)(),fe=typeof e.search==`string`&&e.search!==``?e.search:void 0,me=fe&&Array.isArray(e.searchableFields)&&e.searchableFields.length>0?e.searchableFields:void 0,N=me?JSON.stringify(me):``,[P,he]=(0,t.useState)(!1),ge=(0,r.useFilterScope)(),_e=(0,r.useResolvedFilter)(e.filter,ge),F=(0,t.useRef)(0),ye=(0,t.useRef)(!1),be=(0,t.useRef)(!1),xe=v.data,Se=Array.isArray(xe)&&xe.length>0?xe:null,Ce=(0,t.useRef)(Se);Ce.current=Se;let we=(0,t.useCallback)(async({silent:t=!1,inPlace:r=t}={})=>{let i=++F.current,a=()=>F.current===i,o=!t||be.current;be.current=o;try{r?he(!0):te(!0);let t=Ce.current;if(t){a()&&(b(t),C(null),x(null),ye.current=!0);return}let i=se.current;if(!i||typeof i.find!=`function`)throw Error(`DataSource required for the object provider`);let o=(0,n.buildExpandFields)(M?.fields),s=!de?.isLoaded||!j?o:o.filter(e=>de.checkField(j,e,`read`)),c=await i.find(j,{$filter:_e,$orderby:(0,n.convertSortToQueryParams)(e.sort),...(0,n.nonGridRowCeilingQuery)(),...s.length>0?{$expand:s}:{},...fe?{$search:fe,...me?{$searchFields:me}:{}}:{}}),l=(0,n.applyNonGridRowCeiling)(c);a()&&(b(l.rows),C(l),x(null),ye.current=!0)}catch(e){o?a()&&x(e):console.error(`[ObjectGantt] Failed to refresh data:`,e)}finally{a()&&(be.current=!1,he(!1),te(!1))}},[ce,f,j,oe,ae,_e,e.sort,fe,N,M,de]),I=Se===null&&!oe,Te=(0,t.useRef)(we);Te.current=we,(0,t.useEffect)(()=>{(!I||le)&&Te.current(ye.current?{inPlace:!0}:{})},[ce,f,j,oe,ae,_e,e.sort,fe,N,M,de,I,le]);let Ee=(0,r.useDataInvalidation)(I&&j?j:void 0),De=(0,t.useRef)(0);(0,t.useEffect)(()=>{Ee!==De.current&&(De.current=Ee,(!I||le)&&Te.current({silent:!0}))},[Ee,I,le]);let Oe=(0,t.useMemo)(()=>{if(!k||!y.length)return[];let{startDateField:e,endDateField:t,titleField:r,progressField:a,dependenciesField:o,colorField:c,borderColorField:l,parentField:u,typeField:f,lockField:p,tooltipFields:m,baselineStartField:h,baselineEndField:g,quickFilters:_}=k,v=M?.fields??{},b=pe(k.timeZone),ee=(0,n.createFieldColorResolver)(v[c??``]),te=(0,n.createFieldColorResolver)(v[l??``]),ne=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&&ne.set(e.field,t)}let x=(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},S=e=>{let t=[x(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)(M,e)},C=(e,t)=>{if(t)return t;let n=v[e]??v[e.split(`.`)[0]];return n?.label?n.label:(0,d.humanizeLabel)(e)},T=(e,t)=>{if(e==null||e===``)return`—`;let n=v[t]??v[t.split(`.`)[0]],r=n?.type,a=n?.options;if(Array.isArray(a)&&a.length){let t=a.find(t=>String(t.value)===String(e));if(t)return t.label}if(typeof e!=`object`){let n=ne.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,d.formatDate)(e,void 0,{locale:w});if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(e)&&!isNaN(new Date(e).getTime()))return(0,d.formatDateTime)(e,{locale:w})}switch(r){case`date`:return(0,d.formatDate)(e,void 0,{locale:w});case`datetime`:return(0,d.formatDateTime)(e,{locale:w});case`number`:case`integer`:case`float`:case`decimal`:{let t=(0,s.resolveFieldScale)({type:n?.type,scale:n?.scale});return(0,i.formatDisplayNumber)(Number(e),t===void 0?{locale:w,minimumFractionDigits:0,maximumFractionDigits:20}:{locale:w,minimumFractionDigits:t,maximumFractionDigits:t})}case`currency`:return(0,d.formatCurrency)(Number(e),(0,i.resolveFieldCurrency)(n,re),w);case`percent`:return(0,d.formatPercent)(Number(e),(0,d.percentCellScale)(n),(0,s.resolveFieldScale)({type:n?.type,scale:n?.scale}),w);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)}},E=e=>{if(!m||!m.length)return;let t=[];for(let n of m){let r=typeof n==`string`?n:n?.field;if(!r)continue;let i=typeof n==`object`?n.label:void 0,a=x(e,r);a==null||a===``||Array.isArray(a)&&a.length===0||t.push({label:C(r,i),value:T(a,r)})}return t.length?t:void 0};return y.map((n,r)=>{let i=n[e],s=n[t],m=h?n[h]:void 0,_=g?n[g]:void 0,v=m?ut(m,b):void 0,y=_?dt(_,b):void 0,ne=S(n),x=a?n[a]:0,C=o?n[o]:[],re=c?n[c]:void 0,w=ee(re);if(!w&&re!=null&&re!==``&&(w=(0,d.getSemanticHex)((0,d.getSemanticColorName)(String(re),re))),!w){let e=n.status??n.state??n.priority??n.severity;if(e!=null&&e!==``){let t=(0,d.getSemanticColorName)(void 0,e);t&&(w=(0,d.getSemanticHex)(t))}}let T=l?n[l]:void 0,D=T!=null&&T!==``?te(T)??(0,d.getSemanticHex)(String(T),String(T)):void 0;return{id:n.id||n._id||`task-${r}`,title:ne,start:i?ut(i,b):new Date,end:s?dt(s,b):new Date,hasOwnDates:!!(i&&s),progress:Math.min(100,Math.max(0,x||0)),dependencies:ct(C),parent:u?n[u]??null:void 0,type:f?ot(n[f]):void 0,locked:p?!!n[p]:void 0,color:w,borderColor:D,baselineStart:v&&!isNaN(v.getTime())?v:void 0,baselineEnd:y&&!isNaN(y.getTime())?y:void 0,fields:E(n),data:n}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[y,k,M,w,re]),ke=(0,t.useMemo)(()=>{let e=k?.groupByField;if(!e)return;let t=M?.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)}}},[k?.groupByField,M]),Ae=(0,t.useMemo)(()=>{let e=k?.assigneeField;if(!e)return;let t=M?.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)}}},[k?.assigneeField,M]),je=(0,t.useMemo)(()=>{let e=k?.effortField;if(e)return t=>{let n=t.data?.[e],r=Number(n);return Number.isFinite(r)&&r>0?r:1}},[k?.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]),Ne=(0,t.useMemo)(()=>ue(k?.timeSegments),[k?.timeSegments]),L=(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)},[]),Pe=k?.quickFilters,[Fe,Ie]=(0,t.useState)({});(0,t.useEffect)(()=>{if(!Pe?.length||!f||typeof f.find!=`function`)return;let e=M?.fields??{},t=!1;return(async()=>{let r={};for(let t of Pe){if(t.options)continue;let i=e[t.field]??e[t.field.split(`.`)[0]],a=i?.type;if(a!==`lookup`&&a!==`master_detail`)continue;let o=i?.reference;if(o)try{let e=await f.find(o,{$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||Ie(e=>({...e,...r}))})(),()=>{t=!0}},[JSON.stringify(Pe),f,M]);let Le=(0,t.useMemo)(()=>{if(!Pe?.length)return[];let e=M?.fields??{};return Pe.map(t=>{let n=e[t.field]??e[t.field.split(`.`)[0]],r=t.label??n?.label??(0,d.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(Fe[t.field]?.length)i=Fe[t.field];else{let e=new Map;for(let n of y){let r=L(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}})},[Pe,M,Fe,y,L]),Re=e.persistLayout===!1?void 0:`${e.objectName||(O?.provider===`object`?O.object:``)||`gantt`}:${e.viewName||`default`}`,ze=Re?`gantt-layout:${Re}:filters`:null,[Be,Ve]=(0,t.useState)(()=>{if(!ze||typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(ze)||`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{}}}),He=(0,t.useCallback)(()=>{if(!(!ze||typeof window>`u`))try{window.localStorage.setItem(ze,JSON.stringify(Be))}catch{}},[ze,Be]),Ue=(0,t.useCallback)((e,t)=>{Ve(n=>({...n,[e]:t}))},[]),We=(0,t.useCallback)(()=>Ve({}),[]),Ge=(0,t.useCallback)(e=>!!k?.objectField&&!String(e?.[k.objectField]??``).trim(),[k?.objectField]),Ke=(0,t.useCallback)(e=>{let t=(k?.objectField?String(e[k.objectField]??``).trim():``)||j,n=e.id??e._id;if(!t||n==null)return null;let r=j?(0,c.deriveRecordPageHref)(j,n):null;return{objectName:t,recordId:n,href:!j||t===j?r:r?.replace(`/${j}/record/`,`/${t}/record/`)??null}},[k?.objectField,j]),qe=(0,t.useMemo)(()=>{let e=Object.entries(Be).filter(([,e])=>e.length>0);if(!e.length)return Oe;let t=new Map(Oe.map(e=>[String(e.id),e])),n=new Set;for(let r of Oe){if(!e.every(([e,t])=>{let n=L(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 Oe.filter(e=>n.has(String(e.id)))},[Oe,Be,L]),Je=(0,t.useMemo)(()=>{if(k?.autoZoomToFilter!==!1||!Oe.length)return null;let e=1/0,t=-1/0;for(let n of Oe){let r=n.start.getTime(),i=n.end.getTime();e=Math.min(e,r),t=Math.max(t,i>r?i-1:r)}return{start:new Date(e),end:new Date(t)}},[Oe,k?.autoZoomToFilter]),Xe=e.navigation??{mode:`drawer`},R=Xe.mode===`drawer`||Xe.mode===`modal`||Xe.mode===`split`||Xe.mode===`popover`,Ze=(0,t.useCallback)((e,t)=>{if(typeof window>`u`)return;let n=String(e),r=Oe.find(e=>{let t=e.data;return!!t&&String(t.id??t._id)===n})?.data,i=r?Ke(r)?.href??null:j?(0,c.deriveRecordPageHref)(j,e):null;if(i){if(t===`new_window`){window.open(i,`_blank`);return}window.history.pushState({},``,i),window.dispatchEvent(new PopStateEvent(`popstate`))}},[Oe,Ke,j]),z=(0,r.useNavigationOverlay)({navigation:Xe,objectName:e.objectName,onNavigate:Ze,onRowClick:R?void 0:g}),{anchorRef:Qe,anchorCaptureProps:$e}=(0,u.useOverlayAnchor)(),[B,V]=(0,t.useState)(null),tt=z.isOverlay&&z.isOpen?z.selectedRecord:null;(0,t.useEffect)(()=>{if(!tt){V(null);return}let e=Ke(tt);if(!e){V(null);return}let{objectName:t,recordId:n}=e;if(t===j||!f||typeof f.findOne!=`function`){V(null);return}let r=`${t}:${n}`,i=!1;return(async()=>{try{let[e,a]=await Promise.all([f.findOne(t,String(n)),typeof f.getObjectSchema==`function`?f.getObjectSchema(t).catch(()=>null):Promise.resolve(null)]);i||V(e?{key:r,record:e,schema:a}:null)}catch(e){console.error(`[ObjectGantt] Failed to fetch drawer record, falling back to row payload:`,e),i||V(null)}})(),()=>{i=!0}},[tt,Ke,j,f]);let nt=(0,t.useCallback)(async(e,t)=>{if(!k||!A||typeof A.update!=`function`)return;let{startDateField:n,endDateField:r,titleField:i,progressField:a}=k,o=M?.fields,s=e.data??{},c=pe(k.timeZone),l={};if(t.start instanceof Date&&(l[n]=U(t.start,o?.[n]?.type,s[n],c)),t.end instanceof Date&&(l[r]=U(t.end,o?.[r]?.type,s[r],c,`end`)),typeof t.title==`string`&&i&&(l[i]=t.title),typeof t.progress==`number`&&a&&(l[a]=t.progress),Object.keys(l).length===0)return;let u=e.data?.id??e.data?._id??e.id;if(u==null)return;let d=y;b(e=>e.map(e=>String(e.id??e._id)===String(u)?{...e,...l}:e));try{await A.update(j,String(u),l),we({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist task update:`,e),b(d),E(e)}},[k,A,j,y,we,E,M]),rt=(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)},it=(0,t.useCallback)(async(e,t,n)=>{let r=k?.dependenciesField;if(!r||!A||typeof A.update!=`function`)return;let i=rt(t,n),a=y;b(t=>t.map(t=>String(t.id??t._id)===String(e)?{...t,[r]:i}:t));try{await A.update(j,String(e),{[r]:i}),we({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to persist dependency:`,e),b(a),E(e)}},[k,A,j,y,we,E]),at=(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=k?.dependenciesField;if(!a)return;let o=y.find(e=>String(e.id??e._id)===String(i))?.[a],s=ct(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 it(i,o,f)},[k,y,it]),st=(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=k?.dependenciesField;if(!i)return;let a=y.find(e=>String(e.id??e._id)===String(r))?.[i],o=ct(a),s=e=>String(typeof e==`object`?e.id:e),c=o.filter(e=>s(e)!==String(n));c.length!==o.length&&await it(r,a,c)},[k,y,it]),[ft,pt]=(0,t.useState)(null),[mt,ht]=(0,t.useState)(!1),_t=(0,t.useCallback)(e=>{pt(e)},[]),vt=(0,t.useCallback)(async()=>{if(!ft)return;if(!A?.delete){pt(null);return}let e=ft.data?.id??ft.data?._id??ft.id;if(e==null){pt(null);return}ht(!0);let t=y;b(t=>t.filter(t=>String(t.id??t._id)!==String(e)));try{if(await A.delete(j,String(e))===!1)throw Error(T(`gantt.writeFailed`));pt(null),we({silent:!0})}catch(e){console.error(`[ObjectGantt] Failed to delete:`,e),b(t),pt(null),E(e)}finally{ht(!1)}},[ft,A,j,y,we,E,T]),yt={objectSchema:M,objectName:j,perms:de},W=(0,n.resolveAffordance)(`rowEdit`,yt).allowed,bt=(0,n.resolveAffordance)(`rowDelete`,yt).allowed;if(ee)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})});if(ne)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,ne.message]})})});if(!k)return(0,p.jsx)(`div`,{className:m,children:(0,p.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,p.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})});let xt=t=>{if(!z.isOverlay||!z.isOpen||!z.selectedRecord)return null;let n=z.selectedRecord,r=Ke(n);if(!r||Ge(n))return null;let{objectName:i,recordId:a}=r,o=r.href??void 0,s=k?.titleField?String(n[k.titleField]??T(`gantt.drawer.fallbackTitle`)):T(`gantt.drawer.fallbackTitle`),l=!!e.readOnly||(k?.lockField?!!n[k.lockField]:!1),d=B?.key===`${i}:${a}`?B:null,m=d?.record??n,h=d?.schema??(i===j?M:void 0),g=d&&f?f:A;return(0,p.jsx)(u.NavigationOverlay,{...z,title:s,mainContent:t,popoverAnchorRef:Qe,storageKey:(0,u.recordOverlayWidthStorageKey)(i),legacyStorageKey:(0,u.legacyRecordDrawerWidthKey)(i),width:z.width??c.RECORD_OVERLAY_DEFAULT_WIDTH,children:()=>(0,p.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,p.jsx)(c.RecordDetailPanel,{record:m,objectName:i,recordId:a,dataSource:g??void 0,objectSchema:h,onClose:z.close,fullPageHref:o,onFieldSave:l?void 0:async(e,t)=>{if(g?.update){try{await g.update(i,String(a),{[e]:t})}catch(e){let t=lt(e);throw t?Error(t):e}d&&V(n=>n&&n.key===d.key?{...n,record:{...n.record,[e]:t}}:n),b(n=>n.map(n=>String(n.id??n._id)===String(a)?{...n,[e]:t}:n)),we({silent:!0})}},onDelete:l?void 0:async()=>{if(A?.delete){try{if(await A.delete(i,String(a))===!1)throw Error(T(`gantt.writeFailed`))}catch(e){throw E(e),e}b(e=>e.filter(e=>String(e.id??e._id)!==String(a)))}}})})})},St=(0,p.jsxs)(`div`,{className:(0,u.cn)(`flex h-full min-h-0 flex-col`,m),...$e,children:[Le.length>0&&(0,p.jsx)(H,{filters:Le,value:Be,onChange:Ue,onClear:We,resultCount:qe.length,totalCount:Oe.length,labels:{all:T(`gantt.quickFilter.all`),clear:T(`gantt.quickFilter.clear`),empty:T(`gantt.quickFilter.empty`),resultSummary:(e,t)=>T(`gantt.quickFilter.resultSummary`).replace(`{shown}`,String(e)).replace(`{total}`,String(t))}}),(0,p.jsxs)(`div`,{className:`relative flex-1 min-h-[420px]`,children:[(0,p.jsx)(u.RefreshIndicator,{active:P,ariaLabel:T(`gantt.aria.refreshing`)}),k?.resourceView&&Ae?(0,p.jsx)(et,{tasks:qe,assignee:Ae,effort:je,capacity:k?.capacity??1,viewMode:k?.viewMode||`day`}):(0,p.jsx)(Ye,{tasks:qe,viewMode:k?.viewMode,startDate:Je?.start,endDate:Je?.end,onTaskClick:e=>{Ge(e.data)||z.handleClick(e.data),h?.(e.data)},onTaskUpdate:W?nt:void 0,onTaskDelete:bt?_t:void 0,onDependencyCreate:W&&k?.dependenciesField?at:void 0,onDependencyDelete:W&&k?.dependenciesField?st:void 0,markers:e.markers,autoSchedule:!!k?.dependenciesField,rescheduleOnConflict:!!k?.dependenciesField,criticalPathDefault:!!e.criticalPath,workingCalendar:Me,shiftSegments:Ne,showBaselines:e.showBaselines!==!1,readOnly:!!e.readOnly,mobileReadOnly:e.mobileReadOnly!==!1,persistLayoutKey:Re,onLayoutChange:ze?He:void 0,groupBy:ke,defaultCollapsedDepth:k?.defaultCollapsedDepth,summaryExtent:k?.summaryExtent,interactions:k?.interactions,dependencyTypes:k?.dependencyTypes,timeZone:k?.timeZone,onBeforeTaskUpdate:_,exportFileName:String(k?.exportFileName??(0,o.resolveI18nLabel)(e.label,w)??M?.label??e.objectName??``)||void 0,inlineEdit:!0,onRefresh:O?.provider===`object`&&typeof A?.find==`function`?()=>we({silent:!0}):void 0,refreshing:P})]}),S&&(0,p.jsx)(r.NonGridRowCeilingNote,{result:S}),(0,p.jsx)(u.AlertDialog,{open:!!ft,onOpenChange:e=>{!e&&!mt&&pt(null)},children:(0,p.jsxs)(u.AlertDialogContent,{children:[(0,p.jsxs)(u.AlertDialogHeader,{children:[(0,p.jsx)(u.AlertDialogTitle,{children:T(`gantt.delete.title`)}),(0,p.jsx)(u.AlertDialogDescription,{children:ft?T(`gantt.delete.body`,{title:ft.title}):null})]}),(0,p.jsxs)(u.AlertDialogFooter,{children:[(0,p.jsx)(u.AlertDialogCancel,{disabled:mt,children:T(`gantt.delete.cancel`)}),(0,p.jsx)(u.AlertDialogAction,{onClick:e=>{e.preventDefault(),vt()},disabled:mt,"data-testid":`gantt-delete-confirm`,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:T(mt?`gantt.delete.deleting`:`gantt.delete.confirm`)})]})]})})]});if(z.isOverlay&&z.mode===`split`&&z.isOpen&&z.selectedRecord){let e=xt(St);if(e)return(0,p.jsx)(p.Fragment,{children:e})}return(0,p.jsxs)(p.Fragment,{children:[St,xt()]})},vt={filter:!0,sort:!0},yt=(0,n.elementDataSourceBlock)(({schema:e})=>{let{dataSource:t}=(0,r.useSchemaContext)()||{},n=t??void 0,{t:a}=(0,i.useObjectTranslation)();return(0,p.jsx)(r.ElementDataSourceGate,{schema:e,mapping:vt,dataSource:n,testId:`object-gantt`,errorTitle:a(`element.gantt.sourceUnresolved`,{defaultValue:`This gantt chart’s data source could not be resolved`}),children:e=>(0,p.jsx)(_t,{schema:e,dataSource:n})})});n.ComponentRegistry.register(`object-gantt`,yt,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,description:"ObjectQL object name. The record source is one of `data`, `staticData` and `objectName`; the `object-gantt` schema refuses a block that declares none of them, unless the node's `dataSource.object` names the object, which then lands on this key."},{name:`gantt`,type:`object`,description:"Gantt-timeline configuration, the author face — the same block `ListViewSchema.gantt` declares, and the one the renderer validates this node against. Taken WHOLE when present: the flat top-level spelling beside it is ignored. The spec requires `startDateField`, `endDateField` and `titleField`, which name the record fields a task's bar starts at, ends at and is titled by; the other members (`progressField`, `colorField`, `dependenciesField`, `parentField`, `viewMode`, `exportFileName`, …) are optional."},{name:`data`,type:`object`,description:"A `{ provider, … }` data-source configuration, read FIRST on the record-source ladder: a gantt carrying one never reaches `staticData` and never queries `objectName`. `{ provider: 'value', items }` charts those rows, `{ provider: 'object', object }` queries that object and `{ provider: 'api', read }` reads through that request. A bare array is not this key’s shape and is not a record source: the gantt falls through to `staticData`, then `objectName`, so inline rows belong under `staticData`."},{name:`staticData`,type:`array`,description:"Inline records, read SECOND on the record-source ladder: a `data` configuration wins and this key is then never reached, while `objectName` is read AFTER it, so a gantt carrying both charts these rows and never queries that object. `filter` and `sort` narrow and order these rows exactly as they do fetched ones."},{name:`filter`,type:`array`,description:"Base query filter in the rule-array form `[{ field, operator, value }, ...]`, narrowing the tasks the gantt charts — from every record source it reads: the object, an `api` request, or inline rows. Context tokens such as `{current_user_id}` are resolved first, then the filter is lowered to `$filter` on the query. The MongoDB-style record form is not this key’s shape."},{name:`sort`,type:`array`,description:"Task order in `[{ field, order }]` form, ordering the rows the gantt charts. Lowered to `$orderby` on the same query."},{name:`navigation`,type:`object`,description:"What a task click opens — the `{ mode, size, openNewTab, preventNavigation }` block a list view declares. With the key ABSENT a click opens the task's record in a drawer, this renderer's own default. `mode` is an overlay (`drawer`, `modal`, `split`, `popover`), `new_window`, `page` or `none`, and a block written without `mode` takes the spec's `page` default. `drawer`, `modal` and `popover` open the task's record in that overlay, and `split` opens it beside the chart, which stays drawn; `none` opens nothing. `page` opens the task's record page in the same tab and `new_window` opens it in a new tab. The gantt builds that address itself from the page it is on and does not use a record navigator the host publishes, so a host that publishes one changes nothing: on the object's own list or view route (`…/OBJECT/view/VIEW`) the address is the record page `…/OBJECT/record/ID`, while on any other page, such as a custom page, `/OBJECT/record/ID` is appended to the current address. The object is `data.object` when `data` is the object provider, else `objectName`; on inline rows that name neither there is no record to open, and every mode, the default drawer included, opens nothing. `preventNavigation: true` opens nothing whatever the mode, `openNewTab: true` opens the record page in a new tab and outranks every mode except `none`, and `size` sets the overlay width."},{name:`label`,type:[`string`,`object`],description:'Gantt label — the second link of the exported PNG/PDF file-name chain, after `gantt.exportFileName` and before the bound object\'s own label. A string is used as written, and an inline locale map (`{ en, "zh-CN", … }`) gives the entry for the display locale. The chart draws it nowhere else.'},{name:`skipWeekends`,type:`boolean`,description:`Measure duration and auto-schedule math in WORKING days, skipping Saturdays and Sundays. The day view also folds the Saturday and Sunday columns out of its axis.`},{name:`holidays`,type:`array`,of:`string`,description:"Additional non-working dates for the working calendar, ISO `yyyy-mm-dd` strings; folded into a Set for the duration math. A non-empty list turns the working calendar on by itself, without `skipWeekends`, and the day view folds each listed date's column out of its axis."},{name:`persistLayout`,type:`boolean`,description:"Opt OUT of layout and filter-chip persistence — only an explicit `false` disables it; the storage key is `objectName:viewName`. The object half is `objectName`, else `data.object`, and `gantt` on inline rows that name neither. With `false` the toolbar has no save-layout button and nothing is stored."},{name:`viewName`,type:`string`,description:"Layout-persistence scope, the second half of the `objectName:viewName` storage key (renderer default `'default'`). Two gantts on the same object with different names keep separate saved layouts, and a gantt restores only the layout saved under its own name."},{name:`markers`,type:`array`,description:"Extra vertical reference lines drawn like the Today marker — each `{ date, label?, color? }`: `date` places the line (a date outside the drawn range draws none), `label` is drawn against it, `color` paints it. `color` is a CSS colour, the theme's primary colour when omitted."},{name:`criticalPath`,type:`boolean`,description:`Seed the critical-path highlight ON; the toolbar toggle stays available either way`},{name:`showBaselines`,type:`boolean`,description:"Render the planned-vs-actual baseline bars — ON unless an explicit `false` disables it. A task draws one only when `gantt.baselineStartField` and `gantt.baselineEndField` give it both baseline dates."},{name:`readOnly`,type:`boolean`,description:`Disable every write path on this gantt and lock the record drawer. A task click still opens the record, read-only.`},{name:`mobileReadOnly`,type:`boolean`,description:"Auto read-only on narrow viewports — ON unless an explicit `false` disables it. Narrow is under 640px: the chart's own width once it is measured, the viewport's until then. A narrow chart's own write paths are gated as under `readOnly`, read-only badge included, but the record drawer is locked by `readOnly` alone, so a task's record still opens writable. `false` keeps a narrow chart editable, and `readOnly: true` locks the chart and the drawer at any width."}]}),e.GanttView=Ye,e.ObjectGantt=_t,e.ObjectGanttRenderer=yt,e.QuickFilterBar=H,e.ResourceWorkload=et,e.bandAt=de,e.computeWorkload=R,e.normalizeDependencies=ct,e.normalizeShiftSegments=ue,e.normalizeTaskType=ot,e.parseHHMM=le,e.shiftDayStart=M});
|