@taskctrl/canvas-timeline 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/GridLayer.d.ts +2 -2
- package/dist/canvas/ItemsLayer.d.ts +2 -1
- package/dist/canvas/defaultSummaryRenderer.d.ts +2 -0
- package/dist/canvas-timeline.cjs.js +1 -1
- package/dist/canvas-timeline.cjs.js.map +1 -1
- package/dist/canvas-timeline.es.js +1048 -782
- package/dist/canvas-timeline.es.js.map +1 -1
- package/dist/core/HierarchyEngine.d.ts +31 -0
- package/dist/core/LayoutEngine.d.ts +4 -1
- package/dist/index.d.ts +2 -1
- package/dist/interaction/snapUtils.d.ts +15 -0
- package/dist/types.d.ts +14 -1
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Group, TimelineTheme, DayStyle, RowStyle } from '../types';
|
|
1
|
+
import type { Group, TimelineTheme, DayStyle, RowStyle, TimeRangeHighlight } from '../types';
|
|
2
2
|
import type { ViewState } from '../core/ViewState';
|
|
3
3
|
export declare class GridLayer {
|
|
4
|
-
draw(ctx: CanvasRenderingContext2D, view: ViewState, groups: Group[], theme: TimelineTheme, dayStyle?: (date: Date) => DayStyle | null, rowStyle?: (group: Group) => RowStyle | null): void;
|
|
4
|
+
draw(ctx: CanvasRenderingContext2D, view: ViewState, groups: Group[], theme: TimelineTheme, dayStyle?: (date: Date) => DayStyle | null, rowStyle?: (group: Group) => RowStyle | null, highlights?: TimeRangeHighlight[]): void;
|
|
5
5
|
}
|
|
@@ -2,7 +2,8 @@ import type { Item, Group, TimelineTheme, CanvasItemRenderer, CanvasGroupItemRen
|
|
|
2
2
|
import type { ViewState } from '../core/ViewState';
|
|
3
3
|
import type { IntervalTree } from '../core/IntervalTree';
|
|
4
4
|
import type { LayoutEngine } from '../core/LayoutEngine';
|
|
5
|
+
import type { HierarchyEngine } from '../core/HierarchyEngine';
|
|
5
6
|
export declare class ItemsLayer {
|
|
6
|
-
draw(ctx: CanvasRenderingContext2D, view: ViewState, groups: Group[],
|
|
7
|
+
draw(ctx: CanvasRenderingContext2D, view: ViewState, groups: Group[], items: Item[], tree: IntervalTree<Item>, layout: LayoutEngine, itemRenderer: CanvasItemRenderer, groupRenderer: CanvasGroupItemRenderer | undefined, theme: TimelineTheme, selected: number[], hoveredItemId: number | undefined, dependencies?: Dependency[], summaryRenderer?: CanvasItemRenderer, hierarchy?: HierarchyEngine): void;
|
|
7
8
|
private drawDependencies;
|
|
8
9
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react/jsx-runtime"),u=require("react"),er=require("react-dom"),ee=require("dayjs"),ae={primary:"#269bf7",trainColors:{},status:{red:"#EF5350",yellow:"#FBBF24",green:"#31c48d"},grid:{line:"#E5E5E5",rowAlt:"#F7F7F7",weekend:"rgba(0,0,0,0.03)"},item:{radius:3,text:"#374151",selectedRing:"#a3a3a3"},marker:{today:"#FD7171",milestone:"#3B82F6",cursor:"#269bf7"},sidebar:{bg:"#F9FAFB",border:"#E5E7EB",text:"#6c737f"},header:{bg:"#F9FAFB",border:"#E5E7EB",text:"#6c737f"}};class Ue{constructor(e){Object.defineProperty(this,"visibleTimeStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvasWidth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvasHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sidebarWidth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lineHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"groupCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"scrollTop",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleDuration",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pixelsPerMs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.visibleTimeStart=e.visibleTimeStart,this.visibleTimeEnd=e.visibleTimeEnd,this.canvasWidth=e.canvasWidth,this.canvasHeight=e.canvasHeight,this.sidebarWidth=e.sidebarWidth,this.lineHeight=e.lineHeight,this.groupCount=e.groupCount,this.buffer=e.buffer,this.scrollTop=e.scrollTop,this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration}update(e){e.visibleTimeStart!==void 0&&(this.visibleTimeStart=e.visibleTimeStart),e.visibleTimeEnd!==void 0&&(this.visibleTimeEnd=e.visibleTimeEnd),e.canvasWidth!==void 0&&(this.canvasWidth=e.canvasWidth),e.canvasHeight!==void 0&&(this.canvasHeight=e.canvasHeight),e.sidebarWidth!==void 0&&(this.sidebarWidth=e.sidebarWidth),e.lineHeight!==void 0&&(this.lineHeight=e.lineHeight),e.groupCount!==void 0&&(this.groupCount=e.groupCount),e.buffer!==void 0&&(this.buffer=e.buffer),e.scrollTop!==void 0&&(this.scrollTop=e.scrollTop),this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration}timeToX(e){return(e-this.visibleTimeStart)*this.pixelsPerMs}xToTime(e){return this.visibleTimeStart+e/this.pixelsPerMs}yToGroupIndex(e){const r=Math.floor((e+this.scrollTop)/this.lineHeight);return Math.max(0,Math.min(r,this.groupCount-1))}groupIndexToY(e){return e*this.lineHeight-this.scrollTop}getBufferBounds(){const e=this.visibleDuration*1.5;return{bufferStart:this.visibleTimeStart-e,bufferEnd:this.visibleTimeEnd+e}}getVisibleGroupRange(){const e=Math.max(0,Math.floor(this.scrollTop/this.lineHeight)),r=Math.ceil(this.canvasHeight/this.lineHeight),o=Math.min(this.groupCount-1,e+r);return{firstVisible:e,lastVisible:o}}isScrollInBuffer(e){const r=this.visibleDuration*1.5*this.pixelsPerMs;return Math.abs(e)<r}getTotalHeight(){return this.groupCount*this.lineHeight}}class tr{constructor(){Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:null})}buildFromItems(e,r,o){const l=e.map(c=>({item:c,start:r(c),end:o(c)}));this.root=this.buildNode(l)}buildNode(e){if(e.length===0)return null;let r=1/0,o=-1/0;for(const f of e)f.start<r&&(r=f.start),f.end>o&&(o=f.end);const l=(r+o)/2,c=[],a=[],b=[];for(const f of e)f.end<l?c.push(f):f.start>l?a.push(f):b.push(f);return{center:l,left:this.buildNode(c),right:this.buildNode(a),overlapping:b}}query(e,r){const o=[];return this.queryNode(this.root,e,r,o),o}queryNode(e,r,o,l){if(e!==null){for(const c of e.overlapping)c.start<=o&&c.end>=r&&l.push(c.item);r<=e.center&&e.left!==null&&this.queryNode(e.left,r,o,l),o>=e.center&&e.right!==null&&this.queryNode(e.right,r,o,l)}}}class rr{constructor(e,r){Object.defineProperty(this,"lineHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"itemHeightRatio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layoutCache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"groupMaxStack",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.lineHeight=e,this.itemHeightRatio=r}computeLayout(e,r){if(this.layoutCache=new Map,this.groupMaxStack=new Map,!r){const c=this.lineHeight*this.itemHeightRatio;for(const a of e)this.layoutCache.set(a.id,{stackLevel:0,itemHeight:c}),this.groupMaxStack.set(a.group,0);return this.layoutCache}const o=new Map;for(const c of e){let a=o.get(c.group);a||(a=[],o.set(c.group,a)),a.push(c)}const l=this.lineHeight*this.itemHeightRatio;for(const[c,a]of o){a.sort((v,T)=>{const y=v.start_time-T.start_time;return y!==0?y:T.end_time-T.start_time-(v.end_time-v.start_time)});const b=[];let f=0;for(const v of a){let T=-1;for(let y=0;y<b.length;y++)if(b[y]<=v.start_time){T=y;break}T===-1?(T=b.length,b.push(v.end_time)):b[T]=v.end_time,T>f&&(f=T),this.layoutCache.set(v.id,{stackLevel:T,itemHeight:l})}this.groupMaxStack.set(c,f)}return this.layoutCache}getLayout(e){return this.layoutCache.get(e)}getGroupHeight(e){return((this.groupMaxStack.get(e)??0)+1)*this.lineHeight}}function De(t,e,r,o,l,c){const a=r.xToTime(t),b=new Map;for(let y=0;y<c.length;y++)b.set(c[y].id,y);const f=o.query(a,a);let v=null,T=-1/0;for(const y of f){const H=b.get(y.group);if(H===void 0)continue;const k=l.getLayout(y.id);if(!k)continue;const M=r.timeToX(y.start_time),I=r.timeToX(y.end_time)-M;if(t<M||t>M+I)continue;const S=r.groupIndexToY(H)+k.stackLevel*r.lineHeight+(r.lineHeight-k.itemHeight)/2,O=k.itemHeight;e<S||e>S+O||S>T&&(T=S,v=y)}return v}function Ke(t,e,r){const o=e.yToGroupIndex(t);return r[o]??null}function yt(t,e,r,o=6){const l=r.timeToX(e.start_time),c=r.timeToX(e.end_time);return t-l<=o?"left":c-t<=o?"right":"body"}function Je(t,e,r){const o=window.devicePixelRatio||1,l=Math.round(e*o),c=Math.round(r*o);(t.width!==l||t.height!==c)&&(t.width=l,t.height=c,t.style.width=`${e}px`,t.style.height=`${r}px`);const a=t.getContext("2d");return a.setTransform(o,0,0,o,0,0),a}function Qe(t,e){const r=window.devicePixelRatio||1;t.clearRect(0,0,e.width/r,e.height/r)}class ir{constructor(e){Object.defineProperty(this,"dirty",{enumerable:!0,configurable:!0,writable:!0,value:{grid:!1,items:!1,overlay:!1}}),Object.defineProperty(this,"rafId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"drawCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.drawCallback=e}markDirty(e){this.dirty[e]=!0,this.schedule()}markAllDirty(){this.dirty.grid=!0,this.dirty.items=!0,this.dirty.overlay=!0,this.schedule()}dispose(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}schedule(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;const e={...this.dirty};this.dirty.grid=!1,this.dirty.items=!1,this.dirty.overlay=!1,this.drawCallback(e)}))}}class nr{draw(e,r,o,l,c,a){const{firstVisible:b,lastVisible:f}=r.getVisibleGroupRange();for(let S=b;S<=f;S++){const O=r.groupIndexToY(S),j=o[S];if(!j)continue;let N;const z=a==null?void 0:a(j);z!=null&&z.backgroundColor?N=z.backgroundColor:N=S%2===0?"#FFFFFF":l.grid.rowAlt,e.fillStyle=N,e.fillRect(0,O,r.canvasWidth,r.lineHeight),e.strokeStyle=(z==null?void 0:z.borderBottomColor)??l.grid.line,e.lineWidth=.5,e.beginPath(),e.moveTo(0,O+r.lineHeight),e.lineTo(r.canvasWidth,O+r.lineHeight),e.stroke()}const v=r.visibleTimeStart,T=r.visibleTimeEnd,k=864e5/(T-v)*r.canvasWidth;let M="day";k<2?M="month":k<8&&(M="week");{let S=ee(v).startOf("day");const O=ee(T).endOf("day");let j=null,N=1,z=0;const x=[],ie=V=>{j!==null&&(e.fillStyle=j,N!==1&&(e.globalAlpha=N),e.fillRect(z,0,V-z,r.canvasHeight),N!==1&&(e.globalAlpha=1),j=null,N=1)};for(;S.isBefore(O);){const V=r.timeToX(S.valueOf()),Ce=S.toDate(),Z=c==null?void 0:c(Ce);let te=null,ne=1;if(Z!=null&&Z.backgroundColor)te=Z.backgroundColor,ne=Z.opacity??1;else{const me=S.day();(me===0||me===6)&&(te=l.grid.weekend)}Z!=null&&Z.borderColor&&x.push({x:V,color:Z.borderColor}),te===j&&ne===N||(ie(V),te!==null&&(j=te,N=ne,z=V)),S=S.add(1,"day")}j!==null&&ie(r.timeToX(S.valueOf()));for(const V of x)e.strokeStyle=V.color,e.lineWidth=.5,e.beginPath(),e.moveTo(V.x,0),e.lineTo(V.x,r.canvasHeight),e.stroke()}let I=ee(v).startOf(M);const W=ee(T).add(1,M);for(e.strokeStyle=l.grid.line,e.lineWidth=.5,e.beginPath();I.isBefore(W);){const S=r.timeToX(I.valueOf());e.moveTo(S,0),e.lineTo(S,r.canvasHeight),I=I.add(1,M)}e.stroke()}}const Tt='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function Ht(t,e){return{roundRect(r,o,l,c,a=3){t.beginPath(),t.roundRect(r,o,l,c,a),t.fill()},fillText(r,o,l,c){if(t.font=Tt,c!==void 0&&t.measureText(r).width>c){let a=0,b=r.length;for(;a<b;){const f=Math.ceil((a+b)/2),v=r.slice(0,f)+"...";t.measureText(v).width<=c?a=f:b=f-1}t.fillText(r.slice(0,a)+"...",o,l)}else t.fillText(r,o,l)},gradient(r,o,l,c){const a=t.createLinearGradient(r,0,r+o,0);return a.addColorStop(0,l),a.addColorStop(.5,l),a.addColorStop(.5,c),a.addColorStop(1,c),a},leftBar(r,o=3){e&&(t.save(),t.fillStyle=r,t.fillRect(e.x,e.y,o,e.height),t.restore())},icon(r,o,l,c=14){t.save();const a=c/2;if(r==="check"){t.fillStyle="#31c48d",t.beginPath(),t.arc(o+a,l+a,a,0,Math.PI*2),t.fill(),t.strokeStyle="#ffffff",t.lineWidth=c*.12,t.beginPath();const b=o+a,f=l+a;t.moveTo(b-a*.45,f),t.lineTo(b-a*.1,f+a*.42),t.lineTo(b+a*.45,f-a*.35),t.stroke()}else if(r==="danger-red"||r==="danger-yellow"){const b=r==="danger-red"?"#EF5350":"#FBBF24";t.fillStyle=b,t.beginPath(),t.moveTo(o+a,l),t.lineTo(o+c,l+c),t.lineTo(o,l+c),t.closePath(),t.fill(),t.fillStyle="#ffffff";const f=c*.12,v=o+a-f/2;t.fillRect(v,l+c*.35,f,c*.35),t.beginPath(),t.arc(o+a,l+c*.82,f*.7,0,Math.PI*2),t.fill()}t.restore()},badge(r,o,l,c){t.save(),t.font=Tt;const b=t.measureText(r).width,f=8,T=12+3*2,y=b+f*2,H=T/2;t.fillStyle=c,t.beginPath(),t.roundRect(o,l,y,T,H),t.fill(),t.fillStyle="#ffffff",t.textAlign="center",t.textBaseline="middle",t.fillText(r,o+y/2,l+T/2),t.restore()}}}class sr{draw(e,r,o,l,c,a,b,f,v,T,y,H){const k=(r.visibleTimeEnd-r.visibleTimeStart)*.1,M=r.visibleTimeStart-k,I=r.visibleTimeEnd+k,W=c.query(M,I),S=new Map;for(let x=0;x<o.length;x++)S.set(o[x].id,x);const O=new Set(T),j=new Map,N=-r.lineHeight,z=r.canvasHeight+r.lineHeight;for(const x of W){const ie=S.get(x.group);if(ie===void 0)continue;const V=a.getLayout(x.id);if(!V)continue;const Z=r.groupIndexToY(ie)+V.stackLevel*r.lineHeight+(r.lineHeight-V.itemHeight)/2,te=V.itemHeight;if(Z+te<N||Z>z)continue;const ne=r.timeToX(x.start_time),me=r.timeToX(x.end_time)-ne,be={x:ne,y:Z,width:me,height:te};j.set(x.id,be);const Pe={selected:O.has(x.id),hovered:y===x.id,dragging:!1,filtered:x.filtered!==!1};e.save();const Ie=Ht(e,be);(f&&(x.type==="control_area_group"||x.type==="construction_train")?f:b)(e,x,be,Pe,Ie),e.restore()}H&&H.length>0&&this.drawDependencies(e,H,j,y,v)}drawDependencies(e,r,o,l,c){for(const a of r){const b=o.get(a.fromItemId),f=o.get(a.toItemId);if(!b||!f)continue;const v=l===a.fromItemId||l===a.toItemId;e.strokeStyle=v?c.primary:a.color??"#94A3B8",e.lineWidth=v?2:1.5,e.setLineDash([]);const T=b.x+b.width,y=b.y+b.height/2,H=f.x,k=f.y+f.height/2,M=Math.abs(H-T),I=Math.max(M*.4,30);e.beginPath(),e.moveTo(T,y),e.bezierCurveTo(T+I,y,H-I,k,H,k),e.stroke();const W=6;e.fillStyle=e.strokeStyle,e.beginPath(),e.moveTo(H,k),e.lineTo(H-W,k-W/2),e.lineTo(H-W,k+W/2),e.closePath(),e.fill()}}}class or{draw(e,r,o,l){const{cursorX:c,snapX:a,markers:b,interaction:f}=l;if(b)for(const v of b){const T=r.timeToX(v.date);if(e.fillStyle=v.color,e.fillRect(T-v.width/2,0,v.width,r.canvasHeight),v.label){e.save(),e.font='500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const y=e.measureText(v.label).width,H=8,k=200,M=Math.min(y+H*2,k),I=20,W=T-M/2,S=4;e.fillStyle=v.color,e.beginPath(),e.roundRect(W,S,M,I,3),e.fill(),e.fillStyle="#FFFFFF",e.textBaseline="middle";const O=k-H*2,j=y>O?v.label.slice(0,Math.floor(v.label.length*O/y))+"…":v.label;e.fillText(j,W+H,S+I/2),e.restore()}}if(c!=null&&(e.strokeStyle=o.marker.cursor,e.lineWidth=1,e.beginPath(),e.moveTo(c,0),e.lineTo(c,r.canvasHeight),e.stroke()),a!=null&&(e.strokeStyle=o.primary,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(a,0),e.lineTo(a,r.canvasHeight),e.stroke(),e.setLineDash([])),f){f.groupChanged&&f.targetGroupY!==void 0&&(e.fillStyle="rgba(59, 130, 246, 0.08)",e.fillRect(0,f.targetGroupY,r.canvasWidth,r.lineHeight)),e.save(),e.globalAlpha=.5;const v=Ht(e,f.bounds);f.renderer(e,f.item,f.bounds,{selected:!1,hovered:!1,dragging:!0,filtered:!0},v),e.restore()}}}const kt=120;function lr(t){let e=t.deltaY||t.deltaX;return t.deltaMode===1?e*=15:t.deltaMode===2&&(e*=800),Math.max(-kt,Math.min(kt,e))}class ar{constructor(e,r,o,l,c){Object.defineProperty(this,"onZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"minZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.onZoom=e,this.visibleTimeStart=r,this.visibleTimeEnd=o,this.minZoom=l,this.maxZoom=c}updateBounds(e,r){this.visibleTimeStart=e,this.visibleTimeEnd=r}handleWheelZoom(e,r){const o=lr(e),l=e.ctrlKey?10:e.metaKey?3:1,c=o>0?1+l*o/500:1/(1+l*-o/500),a=this.visibleTimeEnd-this.visibleTimeStart;let b=Math.round(a*c);b=Math.max(this.minZoom,Math.min(this.maxZoom,b));const f=Math.round(this.visibleTimeStart+(a-b)*r),v=f+b;this.onZoom(f,v)}}const ur=4;class cr{constructor(e){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"dragSnap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.dragSnap=e}startInteraction(e,r,o,l){this.state={item:e,mode:r,startX:o,startY:l,currentX:o,currentY:l,deltaX:0,originalGroup:e.group,currentGroup:e.group},this.activated=!1}update(e,r){this.state&&(this.state.currentX=e,this.state.currentY=r,this.state.deltaX=e-this.state.startX,!this.activated&&Math.abs(this.state.deltaX)>=ur&&(this.activated=!0))}setCurrentGroup(e){this.state&&(this.state.currentGroup=e)}endMove(e){if(!this.state)return null;const r=this.state.deltaX/e,o=this.state.item.start_time+r,l=Math.round(o/this.dragSnap)*this.dragSnap,c=this.state.currentGroup;return this.state=null,this.activated=!1,{newStartTime:l,newGroupId:c}}endResize(e){if(!this.state)return null;const r=this.state.deltaX/e,o=this.state.mode==="resize-left"?"left":"right",c=(o==="left"?this.state.item.start_time:this.state.item.end_time)+r,a=Math.round(c/this.dragSnap)*this.dragSnap;return this.state=null,this.activated=!1,{newTime:a,edge:o}}cancel(){this.state=null,this.activated=!1}getState(){return this.state}getMode(){var e;return((e=this.state)==null?void 0:e.mode)??null}isActive(){return this.state!==null&&this.activated}isPending(){return this.state!==null}}var Rt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Dt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pt={exports:{}};(function(t,e){(function(r,o){t.exports=o()})(Rt,function(){var r="day";return function(o,l,c){var a=function(v){return v.add(4-v.isoWeekday(),r)},b=l.prototype;b.isoWeekYear=function(){return a(this).year()},b.isoWeek=function(v){if(!this.$utils().u(v))return this.add(7*(v-this.isoWeek()),r);var T,y,H,k,M=a(this),I=(T=this.isoWeekYear(),y=this.$u,H=(y?c.utc:c)().year(T).startOf("year"),k=4-H.isoWeekday(),H.isoWeekday()>4&&(k+=7),H.add(k,r));return M.diff(I,"week")+1},b.isoWeekday=function(v){return this.$utils().u(v)?this.day()||7:this.day(this.day()%7?v:v-7)};var f=b.startOf;b.startOf=function(v,T){var y=this.$utils(),H=!!y.u(T)||T;return y.p(v)==="isoweek"?H?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):f.bind(this)(v,T)}}})})(Pt);var dr=Pt.exports;const fr=Dt(dr),wt=5;function Ct({groups:t,width:e,lineHeight:r,scrollTop:o,canvasHeight:l,theme:c,groupRenderer:a,onScroll:b}){var W;const f=u.useRef(null),v=u.useRef(!1),T=t.length*r,y=l,H=Math.max(0,Math.floor(o/r)-wt),k=Math.min(t.length-1,Math.ceil((o+l)/r)+wt),M=u.useCallback(S=>{v.current||b(S.currentTarget.scrollTop)},[b]);u.useEffect(()=>{f.current&&(v.current=!0,f.current.scrollTop=o,requestAnimationFrame(()=>{v.current=!1}))},[o]);const I=[];for(let S=H;S<=k;S++){const O=t[S];O&&I.push(X.jsx("div",{style:{position:"absolute",top:S*r,height:r,width:"100%",overflow:"hidden",display:"flex",alignItems:"stretch",borderBottom:`1px solid ${((W=c.grid)==null?void 0:W.line)??"#E5E5E5"}`,boxSizing:"border-box"},children:a(O)},O.id))}return X.jsx("div",{ref:f,onScroll:M,style:{width:e,height:y,overflowY:T>l?"auto":"hidden",overflowX:"hidden",position:"relative",borderRight:`1px solid ${c.sidebar.border}`,backgroundColor:c.sidebar.bg},children:X.jsx("div",{style:{height:T,position:"relative"},children:I})})}function It(t){return null}It.displayName="TodayMarker";function Et(t){return{date:Math.floor(Date.now()/6e4)*6e4,color:t.color??"#FD7171",width:t.width??6,label:t.label}}function hr(t){return t.interval??1e4}function Ot(t){return null}Ot.displayName="CustomMarker";function St(t){return{date:t.date,color:t.color??"#3B82F6",width:t.width??4,label:t.label}}ee.extend(fr);function mr(t){return t?{...ae,...t,status:{...ae.status,...t.status},grid:{...ae.grid,...t.grid},item:{...ae.item,...t.item},marker:{...ae.marker,...t.marker},sidebar:{...ae.sidebar,...t.sidebar},header:{...ae.header,...t.header}}:ae}const Mt=32,gr=u.memo(u.forwardRef(function(e,r){const{groups:o,items:l,defaultTimeStart:c,defaultTimeEnd:a,sidebarWidth:b,lineHeight:f,itemHeightRatio:v,stackItems:T,canMove:y,canChangeGroup:H,canResize:k,dragSnap:M,minZoom:I,maxZoom:W,theme:S,dayStyle:O,rowStyle:j,showCursorLine:N,itemRenderer:z,groupRenderer:x,sidebarGroupRenderer:ie,dependencies:V,onItemClick:Ce,onItemDoubleClick:Z,onItemContextMenu:te,onItemMove:ne,onItemResize:me,moveResizeValidator:be,onItemHover:Pe,onCanvasDoubleClick:Ie,onCanvasContextMenu:je,onTimeChange:et,onZoom:tt,selected:rt=[],rightSidebarWidth:Xe,rightSidebarGroupRenderer:it,onReady:Oe,children:ue}=e,ge=u.useMemo(()=>mr(S),[S]),nt=u.useCallback((s,i)=>{for(let d=0;d<i.length;d++)if(i[d].id===s)return d;return 0},[]),Xt=rt.join(","),Le=u.useMemo(()=>rt,[Xt]),st=u.useRef(null),ot=u.useRef(null),lt=u.useRef(null),Ee=u.useRef(null),at=u.useRef(null),Lt=u.useRef(null),[ut,_t]=u.useState({width:800,height:600});u.useEffect(()=>{const s=at.current;if(!s)return;const i=new ResizeObserver(d=>{const m=d[0];m&&_t({width:m.contentRect.width,height:m.contentRect.height})});return i.observe(s),()=>i.disconnect()},[]);const ce=Math.max(0,ut.width-b-(Xe??0)),de=o.length*f||ut.height,D=u.useRef(new Ue({visibleTimeStart:e.visibleTimeStart??c,visibleTimeEnd:e.visibleTimeEnd??a,canvasWidth:ce,canvasHeight:de,sidebarWidth:b,lineHeight:f,groupCount:o.length,buffer:e.buffer??3,scrollTop:0})),_e=u.useRef(null),Se=u.useRef(void 0),[ct,At]=u.useState(e.visibleTimeStart??c),[dt,Yt]=u.useState(e.visibleTimeEnd??a),[ft,Fe]=u.useState(0),Me=u.useRef(null),pe=u.useCallback(()=>{const s=D.current;At(s.visibleTimeStart),Yt(s.visibleTimeEnd),Fe(s.scrollTop),Me.current=null},[]),Ae=u.useCallback(()=>{Me.current===null&&(Me.current=setTimeout(pe,Mt))},[pe]);u.useEffect(()=>()=>{Me.current!==null&&clearTimeout(Me.current)},[]);const Ye=u.useMemo(()=>{const s=new tr;return s.buildFromItems(l,i=>i.start_time,i=>i.end_time),s},[l]),Ne=u.useMemo(()=>{const s=new rr(f,v);return s.computeLayout(l,T),s},[l,f,v,T]),ye=u.useMemo(()=>new nr,[]),Te=u.useMemo(()=>new sr,[]),ke=u.useMemo(()=>new or,[]),G=u.useMemo(()=>new cr(M),[M]),Be=u.useMemo(()=>{const s=[];return u.Children.forEach(ue,i=>{var m;if(!u.isValidElement(i))return;const d=(m=i.type)==null?void 0:m.displayName;d==="TodayMarker"?s.push(Et(i.props)):d==="CustomMarker"&&s.push(St(i.props))}),s},[ue]),We=u.useMemo(()=>Be.map(s=>`${s.date}|${s.color}|${s.width}|${s.label??""}`).join(";"),[Be]),He=u.useRef(Be);He.current=Be;const Ge=u.useMemo(()=>{let s=0;return u.Children.forEach(ue,i=>{var m;if(!u.isValidElement(i))return;((m=i.type)==null?void 0:m.displayName)==="TodayMarker"&&(s=hr(i.props))}),s},[ue]),F=u.useRef({groups:o,items:l,intervalTree:Ye,layoutEngine:Ne,itemRenderer:z,groupRenderer:x,theme:ge,selected:Le,dependencies:V,dayStyle:O,rowStyle:j,showCursorLine:N,canvasWidth:ce,canvasHeight:de,lineHeight:f,itemHeightRatio:v,onTimeChange:et,onZoom:tt,onItemHover:Pe,onItemClick:Ce,onItemDoubleClick:Z,onItemContextMenu:te,onItemMove:ne,onItemResize:me,onCanvasDoubleClick:Ie,onCanvasContextMenu:je,canMove:y,canResize:k,canChangeGroup:H,dragSnap:M,sidebarWidth:b,moveResizeValidator:be});F.current={groups:o,items:l,intervalTree:Ye,layoutEngine:Ne,itemRenderer:z,groupRenderer:x,theme:ge,selected:Le,dependencies:V,dayStyle:O,rowStyle:j,showCursorLine:N,canvasWidth:ce,canvasHeight:de,lineHeight:f,itemHeightRatio:v,onTimeChange:et,onZoom:tt,onItemHover:Pe,onItemClick:Ce,onItemDoubleClick:Z,onItemContextMenu:te,onItemMove:ne,onItemResize:me,onCanvasDoubleClick:Ie,onCanvasContextMenu:je,canMove:y,canResize:k,canChangeGroup:H,dragSnap:M,sidebarWidth:b,moveResizeValidator:be};const Nt=u.useCallback(()=>{const s=st.current;if(!s)return;const i=F.current,d=Je(s,i.canvasWidth,i.canvasHeight);Qe(d,s),ye.draw(d,D.current,i.groups,i.theme,i.dayStyle,i.rowStyle)},[ye]),Gt=u.useCallback(()=>{const s=ot.current;if(!s)return;const i=F.current,d=Je(s,i.canvasWidth,i.canvasHeight);Qe(d,s),Te.draw(d,D.current,i.groups,i.items,i.intervalTree,i.layoutEngine,i.itemRenderer,i.groupRenderer,i.theme,i.selected,Se.current,i.dependencies)},[Te]),ht=u.useCallback((s,i)=>{const d=D.current,m=F.current,n=m.canvasWidth/(d.visibleTimeEnd-d.visibleTimeStart),h=i/n,p=s.start_time+h,w=Math.round(p/m.dragSnap)*m.dragSnap;return d.timeToX(w)},[]),zt=u.useCallback(()=>{const s=lt.current;if(!s)return;const i=F.current,d=Je(s,i.canvasWidth,i.canvasHeight);Qe(d,s);const m=D.current,n=G.getState();let h=null;if(n){const p=m.timeToX(n.item.start_time),w=m.timeToX(n.item.end_time)-p;let R,P;n.mode==="resize-left"?(R=p+n.deltaX,P=w-n.deltaX):n.mode==="resize-right"?(R=p,P=w+n.deltaX):(R=p+n.deltaX,P=w);const _=nt(n.currentGroup,i.groups),$=m.groupIndexToY(_),A=n.currentGroup!==n.originalGroup;h={item:n.item,mode:n.mode,bounds:{x:R,y:$+(i.lineHeight-i.lineHeight*i.itemHeightRatio)/2,width:P,height:i.lineHeight*i.itemHeightRatio},renderer:i.itemRenderer,targetGroupY:$,groupChanged:A}}ke.draw(d,m,i.theme,{cursorX:i.showCursorLine?_e.current:null,snapX:n?ht(n.item,n.deltaX):null,markers:He.current,interaction:h})},[ke,G,ht,nt]),ze=u.useRef(null);ze.current||(ze.current=new ir(s=>{s.grid&&Nt(),s.items&&Gt(),s.overlay&&zt()}));const E=ze.current;u.useEffect(()=>()=>E.dispose(),[E]),u.useEffect(()=>{if(!Ge)return;const s=setInterval(()=>{const i=[];u.Children.forEach(ue,d=>{var n;if(!u.isValidElement(d))return;const m=(n=d.type)==null?void 0:n.displayName;m==="TodayMarker"?i.push(Et(d.props)):m==="CustomMarker"&&i.push(St(d.props))}),He.current=i,E.markDirty("overlay")},Ge);return()=>clearInterval(s)},[Ge,ue,E]),u.useEffect(()=>{D.current.update({canvasWidth:ce,canvasHeight:de,sidebarWidth:b,lineHeight:f,groupCount:o.length}),E.markAllDirty()},[ce,de,b,f,o.length,E]),u.useEffect(()=>{E.markDirty("grid"),E.markDirty("items")},[l,o,Le,ge,O,j,Ye,Ne,E]);const mt=u.useRef(We);u.useEffect(()=>{We!==mt.current&&(mt.current=We,E.markDirty("overlay"))},[We,E]);const gt=u.useRef(e.visibleTimeStart),vt=u.useRef(e.visibleTimeEnd);e.visibleTimeStart!==void 0&&e.visibleTimeStart!==gt.current&&(gt.current=e.visibleTimeStart,D.current.update({visibleTimeStart:e.visibleTimeStart}),E.markAllDirty()),e.visibleTimeEnd!==void 0&&e.visibleTimeEnd!==vt.current&&(vt.current=e.visibleTimeEnd,D.current.update({visibleTimeEnd:e.visibleTimeEnd}),E.markAllDirty());const Re=u.useRef(null),$e=u.useCallback(s=>{Re.current===null&&(Re.current=setTimeout(()=>{var m,n;Re.current=null;const i=D.current,d=F.current;s==="zoom"?(m=d.onZoom)==null||m.call(d,i.visibleTimeStart,i.visibleTimeEnd):(n=d.onTimeChange)==null||n.call(d,i.visibleTimeStart,i.visibleTimeEnd)},Mt))},[]);u.useEffect(()=>()=>{Re.current!==null&&clearTimeout(Re.current)},[]);const xe=u.useRef(null),Ve=u.useMemo(()=>new ar((s,i)=>{var d;D.current.update({visibleTimeStart:s,visibleTimeEnd:i}),(d=xe.current)==null||d.updateBounds(s,i),E.markAllDirty(),Ae(),$e("zoom")},c,a,I,W),[]);xe.current=Ve;const bt=u.useCallback(s=>{const i=D.current,d=i.groupCount*i.lineHeight,m=Math.max(0,d-i.canvasHeight),n=Math.max(0,Math.min(m,i.scrollTop+s));n!==i.scrollTop&&(i.update({scrollTop:n}),E.markDirty("grid"),E.markDirty("items"),E.markDirty("overlay"),Fe(n))},[E]),Ze=u.useCallback(s=>{var p,w,R;const i=D.current,d=i.canvasWidth/(i.visibleTimeEnd-i.visibleTimeStart),m=s/d,n=i.visibleTimeStart+m,h=i.visibleTimeEnd+m;i.update({visibleTimeStart:n,visibleTimeEnd:h}),(p=xe.current)==null||p.updateBounds(n,h),E.markAllDirty(),er.flushSync(()=>pe()),(R=(w=F.current).onTimeChange)==null||R.call(w,n,h)},[E,pe]);u.useEffect(()=>{const s=Ee.current;if(!s)return;const i=d=>{if(d.ctrlKey||d.metaKey||d.altKey){d.preventDefault();const m=s.getBoundingClientRect(),n=(d.clientX-m.left)/m.width;Ve.handleWheelZoom(d,n)}else if(d.shiftKey)d.preventDefault(),Ze(d.deltaY);else{const m=d.deltaX;m!==0&&Math.abs(m)>Math.abs(d.deltaY)?(d.preventDefault(),Ze(m)):d.deltaY!==0&&bt(d.deltaY)}};return s.addEventListener("wheel",i,{passive:!1}),()=>s.removeEventListener("wheel",i)},[Ve,bt,Ze]);const fe=u.useRef({lastDistance:null,lastCenter:null});u.useEffect(()=>{const s=Ee.current;if(!s)return;const i=(p,w)=>Math.abs(p.clientX-w.clientX),d=(p,w,R)=>(p.clientX+w.clientX)/2-R.left,m=p=>{p.touches.length===2&&(p.preventDefault(),fe.current.lastDistance=i(p.touches[0],p.touches[1]),fe.current.lastCenter=null)},n=p=>{var w;if(p.touches.length===2&&fe.current.lastDistance!==null){p.preventDefault();const R=i(p.touches[0],p.touches[1]),P=s.getBoundingClientRect(),$=d(p.touches[0],p.touches[1],P)/P.width;if(R!==0&&fe.current.lastDistance!==0){const A=fe.current.lastDistance/R,J=D.current,q=J.visibleTimeEnd-J.visibleTimeStart;let C=q*A;C=Math.max(I,Math.min(W,C));const g=J.visibleTimeStart+q*$,Q=g-C*$,L=g+C*(1-$);J.update({visibleTimeStart:Q,visibleTimeEnd:L}),(w=xe.current)==null||w.updateBounds(Q,L),E.markAllDirty(),Ae(),$e("zoom")}fe.current.lastDistance=R}},h=()=>{fe.current.lastDistance=null,fe.current.lastCenter=null};return s.addEventListener("touchstart",m,{passive:!1}),s.addEventListener("touchmove",n,{passive:!1}),s.addEventListener("touchend",h),()=>{s.removeEventListener("touchstart",m),s.removeEventListener("touchmove",n),s.removeEventListener("touchend",h)}},[E,Ae,$e]);const $t=u.useCallback(s=>{var R;const i=s.currentTarget,d=i.getBoundingClientRect(),m=s.clientX-d.left,n=s.clientY-d.top;if(_e.current=m,G.isPending()){if(G.update(m,n),G.isActive()){const P=G.getState();if(P&&P.mode==="move"&&F.current.canChangeGroup){const _=Ke(n,D.current,F.current.groups);_&&G.setCurrentGroup(_.id)}E.markDirty("overlay")}return}F.current.showCursorLine&&E.markDirty("overlay");const h=F.current,p=De(m,n,D.current,h.intervalTree,h.layoutEngine,h.groups),w=p==null?void 0:p.id;if(w!==Se.current&&(Se.current=w,E.markDirty("items"),(R=h.onItemHover)==null||R.call(h,w??null,s.nativeEvent)),p){const P=yt(m,p,D.current),_=h.canResize;P==="left"&&(_==="left"||_==="both")||P==="right"&&(_==="right"||_==="both")?i.style.cursor="col-resize":h.canMove?i.style.cursor="grab":i.style.cursor="default"}else i.style.cursor="default"},[G,E]),Vt=u.useCallback(s=>{const i=F.current,d=s.currentTarget.getBoundingClientRect(),m=s.clientX-d.left,n=s.clientY-d.top,h=De(m,n,D.current,i.intervalTree,i.layoutEngine,i.groups);if(!h)return;const p=yt(m,h,D.current),w=i.canResize;p==="left"&&(w==="left"||w==="both")?G.startInteraction(h,"resize-left",m,n):p==="right"&&(w==="right"||w==="both")?G.startInteraction(h,"resize-right",m,n):i.canMove&&G.startInteraction(h,"move",m,n)},[G]),Zt=u.useCallback(s=>{var p,w,R,P,_,$;const i=s.currentTarget;if(G.isActive()){const A=G.getState(),J=D.current,q=J.canvasWidth/(J.visibleTimeEnd-J.visibleTimeStart);if(A){const C=F.current.moveResizeValidator;if(A.mode==="move"){const g=G.endMove(q);if(g){const Q=C?C("move",A.item.id,g.newStartTime):g.newStartTime;(w=(p=F.current).onItemMove)==null||w.call(p,A.item.id,Q,g.newGroupId)}}else{const g=G.endResize(q);if(g){const Q=C?C("resize",A.item.id,g.newTime,g.edge):g.newTime;(P=(R=F.current).onItemResize)==null||P.call(R,A.item.id,Q,g.edge)}}}i.style.cursor="default",E.markDirty("overlay");return}G.isPending()&&G.cancel();const d=i.getBoundingClientRect(),m=s.clientX-d.left,n=s.clientY-d.top,h=De(m,n,D.current,F.current.intervalTree,F.current.layoutEngine,F.current.groups);h&&(($=(_=F.current).onItemClick)==null||$.call(_,h.id,s.nativeEvent))},[G,E]),qt=u.useCallback(s=>{var p,w;const i=s.currentTarget.getBoundingClientRect(),d=s.clientX-i.left,m=s.clientY-i.top,n=F.current,h=De(d,m,D.current,n.intervalTree,n.layoutEngine,n.groups);if(h)(p=n.onItemDoubleClick)==null||p.call(n,h.id,s.nativeEvent);else{const R=Ke(m,D.current,n.groups),P=D.current.xToTime(d);R&&((w=n.onCanvasDoubleClick)==null||w.call(n,R.id,P))}},[]),Ut=u.useCallback(s=>{var p,w;s.preventDefault();const i=s.currentTarget.getBoundingClientRect(),d=s.clientX-i.left,m=s.clientY-i.top,n=F.current,h=De(d,m,D.current,n.intervalTree,n.layoutEngine,n.groups);if(h)(p=n.onItemContextMenu)==null||p.call(n,h.id,s.nativeEvent);else{const R=Ke(m,D.current,n.groups),P=D.current.xToTime(d);R&&((w=n.onCanvasContextMenu)==null||w.call(n,R.id,P,s.nativeEvent))}},[]),Kt=u.useCallback(()=>{var s,i;_e.current=null,Ee.current&&(Ee.current.style.cursor="default"),Se.current!==void 0&&(Se.current=void 0,E.markDirty("items"),(i=(s=F.current).onItemHover)==null||i.call(s,null,new PointerEvent("pointerleave"))),F.current.showCursorLine&&E.markDirty("overlay")},[E]),Jt=u.useMemo(()=>{const s=[];return u.Children.forEach(ue,i=>{var m;if(!u.isValidElement(i))return;if(((m=i.type)==null?void 0:m.displayName)==="TimelineHeaders"){const n=i.props;s.push(u.cloneElement(i,{visibleTimeStart:n.visibleTimeStart??ct,visibleTimeEnd:n.visibleTimeEnd??dt,canvasWidth:n.canvasWidth??ce,sidebarWidth:n.sidebarWidth??b,theme:n.theme??ge,onZoomToInterval:n.onZoomToInterval??((h,p)=>{var w,R,P,_;D.current.update({visibleTimeStart:h,visibleTimeEnd:p}),E.markAllDirty(),pe(),(R=(w=F.current).onTimeChange)==null||R.call(w,h,p),(_=(P=F.current).onZoom)==null||_.call(P,h,p)})}))}}),s},[ue,ct,dt,ce,b,ge,E,pe]),pt=u.useRef(!1);u.useEffect(()=>{pt.current||(pt.current=!0,E.markAllDirty())},[E]),u.useImperativeHandle(r,()=>({captureToCanvas({timeStart:s,timeEnd:i,scale:d,sidebarWidth:m}){const n=F.current,h=28,p=h*3,w=n.groups.length*n.lineHeight,R=D.current,P=n.canvasWidth/(R.visibleTimeEnd-R.visibleTimeStart),_=i-s,$=Math.max(n.canvasWidth,Math.round(_*P)),A=(m+$)*d,J=(p+w)*d,q=document.createElement("canvas");q.width=A,q.height=J;const C=q.getContext("2d");C.scale(d,d);for(let L=0;L<n.groups.length;L++){const se=n.groups[L],oe=p+L*n.lineHeight;if(n.rowStyle){const Y=n.rowStyle(se);Y!=null&&Y.backgroundColor&&(C.fillStyle=Y.backgroundColor,C.fillRect(0,oe,m,n.lineHeight))}const B=se.type;let U="400",K=8;B==="project"?U="700":B==="CAG"?U="600":B==="CA"&&(U="400",K=24),C.fillStyle="#111",C.font=`${U} 12px sans-serif`,C.textBaseline="middle",C.fillText(se.title,K,oe+n.lineHeight/2,m-K-4)}const g=(L,se,oe)=>{var K,Y;C.fillStyle=((K=n.theme.header)==null?void 0:K.bg)??"#f5f5f5",C.fillRect(m,L,$,h),C.strokeStyle=((Y=n.theme.grid)==null?void 0:Y.line)??"#e0e0e0",C.lineWidth=1,C.strokeRect(m,L,$,h);let B=ee(s).startOf(oe);B.valueOf()<s&&(B=B.add(1,oe));const U=$/(i-s);for(;B.valueOf()<i;){const he=B.add(1,oe),re=m+(B.valueOf()-s)*U,le=m+(Math.min(he.valueOf(),i)-s)*U-re;C.beginPath(),C.moveTo(re,L),C.lineTo(re,L+h),C.stroke(),C.fillStyle="#333",C.font="600 11px sans-serif",C.textBaseline="middle",C.textAlign="center",C.fillText(se(B),re+le/2,L+h/2,le-4),B=he}C.textAlign="start"};g(0,L=>L.format("YYYY"),"year"),g(h,L=>L.format("MM"),"month"),g(h*2,L=>String(L.isoWeek()),"week");const Q=new Ue({visibleTimeStart:s,visibleTimeEnd:i,canvasWidth:$,canvasHeight:w,sidebarWidth:0,lineHeight:n.lineHeight,groupCount:n.groups.length,buffer:1,scrollTop:0});return C.save(),C.translate(m,p),C.beginPath(),C.rect(0,0,$,w),C.clip(),ye.draw(C,Q,n.groups,n.theme,n.dayStyle,n.rowStyle),Te.draw(C,Q,n.groups,n.items,n.intervalTree,n.layoutEngine,n.itemRenderer,n.groupRenderer,n.theme,n.selected,void 0,n.dependencies),ke.draw(C,Q,n.theme,{cursorX:null,snapX:null,markers:He.current,interaction:null}),C.restore(),q}}),[ye,Te,ke]),u.useEffect(()=>{const s={captureToCanvas({timeStart:i,timeEnd:d,scale:m,sidebarWidth:n}){var oe;const h=F.current,p=28,w=p*3,R=h.groups.length*h.lineHeight,P=D.current,_=h.canvasWidth/(P.visibleTimeEnd-P.visibleTimeStart),$=d-i,A=Math.max(h.canvasWidth,Math.round($*_)),J=n+A,q=w+R,C=document.createElement("canvas");C.width=J*m,C.height=q*m;const g=C.getContext("2d");g.scale(m,m),g.fillStyle="#FFFFFF",g.fillRect(0,0,J,q),g.save(),g.beginPath(),g.rect(0,0,n,q),g.clip(),g.fillStyle="#F9FAFB",g.fillRect(0,0,n,w),g.strokeStyle="#E5E7EB",g.lineWidth=1,g.strokeRect(0,0,n,w);for(let B=0;B<h.groups.length;B++){const U=h.groups[B],K=w+B*h.lineHeight,Y=(oe=h.rowStyle)==null?void 0:oe.call(h,U);g.fillStyle=(Y==null?void 0:Y.backgroundColor)??(B%2===0?"#FFFFFF":"#F7F7F7"),g.fillRect(0,K,n,h.lineHeight),g.strokeStyle="#E5E5E5",g.lineWidth=.5,g.beginPath(),g.moveTo(0,K+h.lineHeight),g.lineTo(n,K+h.lineHeight),g.stroke();const he=U.type??"";let re=8,ve="400",le=11;he==="project"?(ve="700",le=12):he==="control_area_group"?ve="600":he==="control_area"&&(re=24),g.fillStyle="#374151",g.font=`${ve} ${le}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,g.textBaseline="middle";const we=typeof U.title=="string"?U.title:String(U.title);g.fillText(we,re,K+h.lineHeight/2,n-re-8)}g.strokeStyle="#E5E7EB",g.lineWidth=1,g.beginPath(),g.moveTo(n,0),g.lineTo(n,q),g.stroke(),g.restore(),g.save(),g.beginPath(),g.rect(n,0,A,w),g.clip();const Q=d-i,L=[{unit:"year",row:0},{unit:"month",row:1},{unit:"week",row:2}];for(const{unit:B,row:U}of L){const K=U*p;g.fillStyle="#F9FAFB",g.fillRect(n,K,A,p);let Y=ee(i).startOf(B);const he=ee(d).add(1,B);for(;Y.isBefore(he);){const re=Y.add(1,B),ve=n+(Y.valueOf()-i)/Q*A,le=(re.valueOf()-Y.valueOf())/Q*A;g.strokeStyle="#E5E7EB",g.lineWidth=.5,g.strokeRect(ve,K,le,p);let we;B==="year"?we=Y.format("YYYY"):B==="month"?we=Y.format("MM"):we=`${Y.week()}`,g.fillStyle="#6c737f",g.font=B==="year"?'600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif':'400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',g.textBaseline="middle",g.textAlign="center",le>20&&g.fillText(we,ve+le/2,K+p/2),Y=re}}g.textAlign="start",g.restore(),g.save(),g.beginPath(),g.rect(n,w,A,R),g.clip(),g.translate(n,w);const se=new Ue({visibleTimeStart:i,visibleTimeEnd:d,canvasWidth:A,canvasHeight:R,sidebarWidth:0,lineHeight:h.lineHeight,groupCount:h.groups.length,buffer:1,scrollTop:0});return ye.draw(g,se,h.groups,h.theme,h.dayStyle,h.rowStyle),Te.draw(g,se,h.groups,h.items,h.intervalTree,h.layoutEngine,h.itemRenderer,h.groupRenderer,h.theme,h.selected,void 0,h.dependencies),ke.draw(g,se,h.theme,{cursorX:null,markers:He.current}),g.restore(),C}};Oe==null||Oe(s)},[Oe,ye,Te,ke]);const Qt={position:"relative",width:ce,height:de,overflow:"hidden",cursor:"default"},qe={position:"absolute",top:0,left:0};return X.jsxs("div",{ref:at,style:{display:"flex",flexDirection:"column",width:"100%"},children:[Jt,X.jsxs("div",{ref:Lt,style:{display:"flex",overflow:"hidden"},children:[X.jsx(Ct,{groups:o,width:b,lineHeight:f,scrollTop:ft,canvasHeight:de,theme:ge,groupRenderer:ie,onScroll:s=>{D.current.update({scrollTop:s}),E.markDirty("grid"),E.markDirty("items"),E.markDirty("overlay"),Fe(s)}}),X.jsxs("div",{ref:Ee,style:Qt,onPointerMove:$t,onPointerDown:Vt,onPointerUp:Zt,onDoubleClick:qt,onContextMenu:Ut,onPointerLeave:Kt,children:[X.jsx("canvas",{ref:st,style:{...qe,zIndex:0}}),X.jsx("canvas",{ref:ot,style:{...qe,zIndex:1}}),X.jsx("canvas",{ref:lt,style:{...qe,zIndex:2}})]}),Xe&&it?X.jsx(Ct,{groups:o,width:Xe,lineHeight:f,scrollTop:ft,canvasHeight:de,theme:ge,groupRenderer:it,onScroll:s=>{D.current.update({scrollTop:s}),E.markDirty("grid"),E.markDirty("items"),E.markDirty("overlay"),Fe(s)}}):null]})]})}));function Ft({children:t,theme:e,className:r,classNames:o,style:l,visibleTimeStart:c,visibleTimeEnd:a,canvasWidth:b,sidebarWidth:f=0,onZoomToInterval:v}){const T=u.Children.map(t,y=>{var k;if(!u.isValidElement(y))return y;if(((k=y.type)==null?void 0:k.displayName)==="DateHeader"){const M=y.props,I=u.cloneElement(y,{visibleTimeStart:M.visibleTimeStart??c,visibleTimeEnd:M.visibleTimeEnd??a,canvasWidth:M.canvasWidth??b,theme:M.theme??e,onZoomToInterval:M.onIntervalClick??M.onZoomToInterval??v});return X.jsxs("div",{style:{display:"flex"},children:[X.jsx("div",{style:{width:f,flexShrink:0}}),X.jsx("div",{style:{flex:1,overflow:"hidden"},children:I})]})}return y});return X.jsx("div",{className:r,style:{position:"sticky",top:0,zIndex:20,display:"flex",flexDirection:"column",backgroundColor:(e==null?void 0:e.header.bg)??"#F9FAFB",borderTop:`1px solid ${(e==null?void 0:e.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(e==null?void 0:e.header.border)??"#E5E7EB"}`,...l},children:T})}Ft.displayName="TimelineHeaders";var Bt={exports:{}};(function(t,e){(function(r,o){t.exports=o()})(Rt,function(){var r="week",o="year";return function(l,c,a){var b=c.prototype;b.week=function(f){if(f===void 0&&(f=null),f!==null)return this.add(7*(f-this.week()),"day");var v=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var T=a(this).startOf(o).add(1,o).date(v),y=a(this).endOf(r);if(T.isBefore(y))return 1}var H=a(this).startOf(o).date(v).startOf(r).subtract(1,"millisecond"),k=this.diff(H,r,!0);return k<0?a(this).startOf("week").week():Math.ceil(k)},b.weeks=function(f){return f===void 0&&(f=null),this.week(f)}}})})(Bt);var vr=Bt.exports;const br=Dt(vr);ee.extend(br);const pr={year:30,month:30,week:20,day:15,hour:30};function Wt({unit:t,visibleTimeStart:e=0,visibleTimeEnd:r=0,canvasWidth:o=0,theme:l,height:c=28,className:a,labelFormat:b,onIntervalClick:f,minCellWidth:v,onZoomToInterval:T}){const y=u.useMemo(()=>{if(!e||!r||!o)return[];const k=r-e,M=v??pr[t];if(M>0){const O=ee(e).startOf(t);if((O.add(1,t).valueOf()-O.valueOf())/k*o<M)return[]}const I=[];let W=ee(e).startOf(t).subtract(1,t);const S=ee(r).add(2,t).valueOf();for(;W.valueOf()<S;){const O=W.add(1,t),j=W.valueOf(),N=O.valueOf(),z=(j-e)/k*o,x=(N-j)/k*o,ie=yr(W,O,t,b);I.push({start:j,end:N,label:ie,left:z,width:x}),W=O}return I},[e,r,o,t,b,v]),H=u.useCallback((k,M)=>{f?f(k,M):T&&T(k,M)},[f,T]);return y.length===0?null:X.jsx("div",{style:{display:"flex",position:"relative",height:c,overflow:"hidden"},children:y.map(k=>X.jsx("div",{className:a,onClick:()=>H(k.start,k.end),style:{position:"absolute",left:k.left,width:k.width,height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRight:`1px solid ${(l==null?void 0:l.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(l==null?void 0:l.header.border)??"#E5E7EB"}`,fontSize:12,color:(l==null?void 0:l.header.text)??"#6c737f",backgroundColor:(l==null?void 0:l.header.bg)??"#F9FAFB",overflow:"hidden",whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",padding:"0 4px",boxSizing:"border-box"},children:X.jsx("span",{children:k.label})},k.start))})}Wt.displayName="DateHeader";function yr(t,e,r,o,l){return typeof o=="function"?o(t.toDate(),e.toDate(),r):typeof o=="string"?t.format(o):Tr(t,r)}function Tr(t,e){switch(e){case"year":return t.format("YYYY");case"month":return t.format("MM");case"week":return`${t.week()}`;case"day":return t.format("D");case"hour":return t.format("HH:mm")}}function xt({width:t,children:e,style:r}){const o=()=>({style:{width:t,...r}});return e?X.jsx(X.Fragment,{children:e({getRootProps:o})}):X.jsx("div",{style:{width:t}})}xt.displayName="SidebarHeader";function jt({children:t}){return X.jsx(X.Fragment,{children:t})}jt.displayName="CustomHeader";exports.CanvasTimeline=gr;exports.CustomHeader=jt;exports.CustomMarker=Ot;exports.DEFAULT_THEME=ae;exports.DateHeader=Wt;exports.SidebarHeader=xt;exports.TimelineHeaders=Ft;exports.TodayMarker=It;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react/jsx-runtime"),h=require("react"),ui=require("react-dom"),he=require("dayjs"),pe={primary:"#269bf7",trainColors:{},status:{red:"#EF5350",yellow:"#FBBF24",green:"#31c48d"},grid:{line:"#E5E5E5",rowAlt:"#F7F7F7",weekend:"rgba(0,0,0,0.03)"},item:{radius:3,text:"#374151",selectedRing:"#a3a3a3"},marker:{today:"#FD7171",milestone:"#3B82F6",cursor:"#269bf7"},sidebar:{bg:"#F9FAFB",border:"#E5E7EB",text:"#6c737f"},header:{bg:"#F9FAFB",border:"#E5E7EB",text:"#6c737f"}};class tt{constructor(e){Object.defineProperty(this,"visibleTimeStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvasWidth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvasHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sidebarWidth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lineHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"groupCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"scrollTop",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleDuration",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pixelsPerMs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.visibleTimeStart=e.visibleTimeStart,this.visibleTimeEnd=e.visibleTimeEnd,this.canvasWidth=e.canvasWidth,this.canvasHeight=e.canvasHeight,this.sidebarWidth=e.sidebarWidth,this.lineHeight=e.lineHeight,this.groupCount=e.groupCount,this.buffer=e.buffer,this.scrollTop=e.scrollTop,this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration}update(e){e.visibleTimeStart!==void 0&&(this.visibleTimeStart=e.visibleTimeStart),e.visibleTimeEnd!==void 0&&(this.visibleTimeEnd=e.visibleTimeEnd),e.canvasWidth!==void 0&&(this.canvasWidth=e.canvasWidth),e.canvasHeight!==void 0&&(this.canvasHeight=e.canvasHeight),e.sidebarWidth!==void 0&&(this.sidebarWidth=e.sidebarWidth),e.lineHeight!==void 0&&(this.lineHeight=e.lineHeight),e.groupCount!==void 0&&(this.groupCount=e.groupCount),e.buffer!==void 0&&(this.buffer=e.buffer),e.scrollTop!==void 0&&(this.scrollTop=e.scrollTop),this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration}timeToX(e){return(e-this.visibleTimeStart)*this.pixelsPerMs}xToTime(e){return this.visibleTimeStart+e/this.pixelsPerMs}yToGroupIndex(e){const t=Math.floor((e+this.scrollTop)/this.lineHeight);return Math.max(0,Math.min(t,this.groupCount-1))}groupIndexToY(e){return e*this.lineHeight-this.scrollTop}getBufferBounds(){const e=this.visibleDuration*1.5;return{bufferStart:this.visibleTimeStart-e,bufferEnd:this.visibleTimeEnd+e}}getVisibleGroupRange(){const e=Math.max(0,Math.floor(this.scrollTop/this.lineHeight)),t=Math.ceil(this.canvasHeight/this.lineHeight),n=Math.min(this.groupCount-1,e+t);return{firstVisible:e,lastVisible:n}}isScrollInBuffer(e){const t=this.visibleDuration*1.5*this.pixelsPerMs;return Math.abs(e)<t}getTotalHeight(){return this.groupCount*this.lineHeight}}class ci{constructor(){Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:null})}buildFromItems(e,t,n){const r=e.map(d=>({item:d,start:t(d),end:n(d)}));this.root=this.buildNode(r)}buildNode(e){if(e.length===0)return null;let t=1/0,n=-1/0;for(const u of e)u.start<t&&(t=u.start),u.end>n&&(n=u.end);const r=(t+n)/2,d=[],l=[],c=[];for(const u of e)u.end<r?d.push(u):u.start>r?l.push(u):c.push(u);return{center:r,left:this.buildNode(d),right:this.buildNode(l),overlapping:c}}query(e,t){const n=[];return this.queryNode(this.root,e,t,n),n}queryNode(e,t,n,r){if(e!==null){for(const d of e.overlapping)d.start<=n&&d.end>=t&&r.push(d.item);t<=e.center&&e.left!==null&&this.queryNode(e.left,t,n,r),n>=e.center&&e.right!==null&&this.queryNode(e.right,t,n,r)}}}class di{constructor(e,t){Object.defineProperty(this,"lineHeight",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"itemHeightRatio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"layoutCache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"groupMaxStack",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.lineHeight=e,this.itemHeightRatio=t}computeLayout(e,t,n){this.layoutCache=new Map,this.groupMaxStack=new Map;const r=this.lineHeight*this.itemHeightRatio,d=r*.6;if(!t){for(const c of e){const u=(n==null?void 0:n.isParent(c.id))??!1;this.layoutCache.set(c.id,{stackLevel:0,itemHeight:u?d:r}),this.groupMaxStack.set(c.group,0)}return this.layoutCache}const l=new Map;for(const c of e){let u=l.get(c.group);u||(u=[],l.set(c.group,u)),u.push(c)}for(const[c,u]of l)n?this.computeHierarchyLayout(u,n,r,d,c):this.computeFlatLayout(u,r,c);return this.layoutCache}computeFlatLayout(e,t,n){e.sort((l,c)=>{const u=l.start_time-c.start_time;return u!==0?u:c.end_time-c.start_time-(l.end_time-l.start_time)});const r=[];let d=0;for(const l of e){let c=-1;for(let u=0;u<r.length;u++)if(r[u]<=l.start_time){c=u;break}c===-1?(c=r.length,r.push(l.end_time)):r[c]=l.end_time,c>d&&(d=c),this.layoutCache.set(l.id,{stackLevel:c,itemHeight:t})}this.groupMaxStack.set(n,d)}computeHierarchyLayout(e,t,n,r,d){const l=[],c=[];for(const p of e)t.isParent(p.id)?c.push(p):l.push(p);l.sort((p,y)=>{const k=p.start_time-y.start_time;return k!==0?k:y.end_time-y.start_time-(p.end_time-p.start_time)});const u=[];let b=0;for(const p of l){let y=-1;for(let k=0;k<u.length;k++)if(u[k]<=p.start_time){y=k;break}y===-1?(y=u.length,u.push(p.end_time)):u[y]=p.end_time,y>b&&(b=y),this.layoutCache.set(p.id,{stackLevel:y,itemHeight:n})}c.sort((p,y)=>t.getNestingDepth(y.id)-t.getNestingDepth(p.id));let E=l.length>0?b+1:0;for(const p of c)this.layoutCache.set(p.id,{stackLevel:E,itemHeight:r}),E>b&&(b=E),E++;this.groupMaxStack.set(d,b)}getLayout(e){return this.layoutCache.get(e)}getGroupHeight(e){return((this.groupMaxStack.get(e)??0)+1)*this.lineHeight}}class Ot{constructor(){Object.defineProperty(this,"parentToChildren",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"childToParent",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"itemMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"depthCache",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}rebuild(e){this.parentToChildren=new Map,this.childToParent=new Map,this.itemMap=new Map,this.depthCache=new Map;for(const t of e)this.itemMap.set(t.id,t);for(const t of e)if(t.parentId!==void 0&&this.itemMap.has(t.parentId)){this.childToParent.set(t.id,t.parentId);let n=this.parentToChildren.get(t.parentId);n||(n=[],this.parentToChildren.set(t.parentId,n)),n.push(t.id)}for(const t of this.childToParent.keys()){const n=new Set;let r=t;for(;r!==void 0;){if(n.has(r)){const d=this.childToParent.get(t);this.childToParent.delete(t);const l=this.parentToChildren.get(d);if(l){const c=l.indexOf(t);c!==-1&&l.splice(c,1),l.length===0&&this.parentToChildren.delete(d)}break}n.add(r),r=this.childToParent.get(r)}}}isParent(e){const t=this.parentToChildren.get(e);return t!==void 0&&t.length>0}getParent(e){return this.childToParent.get(e)}getChildren(e){return this.parentToChildren.get(e)??[]}getDescendants(e){const t=[],n=[...this.getChildren(e)];for(;n.length>0;){const r=n.pop();t.push(r);const d=this.parentToChildren.get(r);d&&n.push(...d)}return t}getEffectiveSpan(e){const t=this.itemMap.get(e);if(!t)return{start:0,end:0};let n=t.start_time,r=t.end_time;const d=this.getDescendants(e);for(const l of d){const c=this.itemMap.get(l);c&&(c.start_time<n&&(n=c.start_time),c.end_time>r&&(r=c.end_time))}return{start:n,end:r}}getNestingDepth(e){const t=this.depthCache.get(e);if(t!==void 0)return t;let n=0,r=this.childToParent.get(e);for(;r!==void 0;)n++,r=this.childToParent.get(r);return this.depthCache.set(e,n),n}getMoveDelta(e,t){const n=this.itemMap.get(e);if(!n)return[];const r=t-n.start_time;return this.getDescendants(e).map(l=>{const c=this.itemMap.get(l);return{itemId:l,newStart:c.start_time+r}})}getResizeConstraint(e,t){const n=this.getDescendants(e);if(n.length===0)return t==="left"?{min:-1/0,max:1/0}:{min:-1/0,max:1/0};if(t==="left"){let r=1/0;for(const d of n){const l=this.itemMap.get(d);l&&l.start_time<r&&(r=l.start_time)}return{min:-1/0,max:r}}else{let r=-1/0;for(const d of n){const l=this.itemMap.get(d);l&&l.end_time>r&&(r=l.end_time)}return{min:r,max:1/0}}}}function hi(i,e,t,n,r,d){const{x:l,y:c,width:u,height:b}=t,E=d.primary;i.globalAlpha=.15,i.fillStyle=E,i.fillRect(l,c,u,b),i.globalAlpha=1,i.strokeStyle=E,i.lineWidth=1.5,i.strokeRect(l,c,u,b);const p=Math.min(b*.5,6),y=c+b/2;i.fillStyle=E,i.beginPath(),i.moveTo(l,y),i.lineTo(l+p,y-p),i.lineTo(l+p*2,y),i.lineTo(l+p,y+p),i.closePath(),i.fill(),i.beginPath(),i.moveTo(l+u,y),i.lineTo(l+u-p,y-p),i.lineTo(l+u-p*2,y),i.lineTo(l+u-p,y+p),i.closePath(),i.fill();const k=e.title;if(k&&u>30){i.fillStyle=d.item.text,i.font='500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',i.textBaseline="middle";const H=i.measureText(k).width,I=u-p*4-4;if(I>20){const X=H>I?k.slice(0,Math.floor(k.length*I/H))+"...":k;i.fillText(X,l+u/2-Math.min(H,I)/2,y)}}n.selected&&(i.strokeStyle=d.item.selectedRing,i.lineWidth=2,i.strokeRect(l-1,c-1,u+2,b+2))}function _e(i,e,t,n,r,d){const l=t.xToTime(i),c=new Map;for(let p=0;p<d.length;p++)c.set(d[p].id,p);const u=n.query(l,l);let b=null,E=-1/0;for(const p of u){const y=c.get(p.group);if(y===void 0)continue;const k=r.getLayout(p.id);if(!k)continue;const H=t.timeToX(p.start_time),I=t.timeToX(p.end_time)-H;if(i<H||i>H+I)continue;const $=t.groupIndexToY(y)+k.stackLevel*t.lineHeight+(t.lineHeight-k.itemHeight)/2,M=k.itemHeight;e<$||e>$+M||$>E&&(E=$,b=p)}return b}function it(i,e,t){const n=e.yToGroupIndex(i);return t[n]??null}function Ct(i,e,t,n=6){const r=t.timeToX(e.start_time),d=t.timeToX(e.end_time);return i-r<=n?"left":d-i<=n?"right":"body"}function nt(i,e,t){const n=window.devicePixelRatio||1,r=Math.round(e*n),d=Math.round(t*n);(i.width!==r||i.height!==d)&&(i.width=r,i.height=d,i.style.width=`${e}px`,i.style.height=`${t}px`);const l=i.getContext("2d");return l.setTransform(n,0,0,n,0,0),l}function rt(i,e){const t=window.devicePixelRatio||1;i.clearRect(0,0,e.width/t,e.height/t)}class fi{constructor(e){Object.defineProperty(this,"dirty",{enumerable:!0,configurable:!0,writable:!0,value:{grid:!1,items:!1,overlay:!1}}),Object.defineProperty(this,"rafId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"drawCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.drawCallback=e}markDirty(e){this.dirty[e]=!0,this.schedule()}markAllDirty(){this.dirty.grid=!0,this.dirty.items=!0,this.dirty.overlay=!0,this.schedule()}dispose(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}schedule(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;const e={...this.dirty};this.dirty.grid=!1,this.dirty.items=!1,this.dirty.overlay=!1,this.drawCallback(e)}))}}class mi{draw(e,t,n,r,d,l,c){const{firstVisible:u,lastVisible:b}=t.getVisibleGroupRange();for(let M=u;M<=b;M++){const _=t.groupIndexToY(M),j=n[M];if(!j)continue;let A;const V=l==null?void 0:l(j);V!=null&&V.backgroundColor?A=V.backgroundColor:A=M%2===0?"#FFFFFF":r.grid.rowAlt,e.fillStyle=A,e.fillRect(0,_,t.canvasWidth,t.lineHeight),e.strokeStyle=(V==null?void 0:V.borderBottomColor)??r.grid.line,e.lineWidth=.5,e.beginPath(),e.moveTo(0,_+t.lineHeight),e.lineTo(t.canvasWidth,_+t.lineHeight),e.stroke()}if(c&&c.length>0)for(const M of c){const _=t.timeToX(M.start),j=t.timeToX(M.end);if(j<0||_>t.canvasWidth)continue;const A=Math.max(0,_),V=Math.min(t.canvasWidth,j)-A,ne=M.opacity??.12,D=parseInt(M.color.slice(1,3),16),L=parseInt(M.color.slice(3,5),16),q=parseInt(M.color.slice(5,7),16);e.fillStyle=`rgb(${Math.round(D*ne+255*(1-ne))},${Math.round(L*ne+255*(1-ne))},${Math.round(q*ne+255*(1-ne))})`,e.fillRect(A,0,V,t.canvasHeight)}const E=t.visibleTimeStart,p=t.visibleTimeEnd,H=864e5/(p-E)*t.canvasWidth;let I="day";H<2?I="month":H<8&&(I="week");{let M=he(E).startOf("day");const _=he(p).endOf("day");let j=null,A=1,V=0;const ne=[],D=L=>{j!==null&&(e.fillStyle=j,A!==1&&(e.globalAlpha=A),e.fillRect(V,0,L-V,t.canvasHeight),A!==1&&(e.globalAlpha=1),j=null,A=1)};for(;M.isBefore(_);){const L=t.timeToX(M.valueOf()),q=M.toDate(),J=d==null?void 0:d(q);let ie=null,ae=1;if(J!=null&&J.backgroundColor)ie=J.backgroundColor,ae=J.opacity??1;else{const fe=M.day();(fe===0||fe===6)&&(ie=r.grid.weekend)}J!=null&&J.borderColor&&ne.push({x:L,color:J.borderColor}),ie===j&&ae===A||(D(L),ie!==null&&(j=ie,A=ae,V=L)),M=M.add(1,"day")}j!==null&&D(t.timeToX(M.valueOf()));for(const L of ne)e.strokeStyle=L.color,e.lineWidth=.5,e.beginPath(),e.moveTo(L.x,0),e.lineTo(L.x,t.canvasHeight),e.stroke()}let X=he(E).startOf(I);const $=he(p).add(1,I);for(e.strokeStyle=r.grid.line,e.lineWidth=.5,e.beginPath();X.isBefore($);){const M=t.timeToX(X.valueOf());e.moveTo(M,0),e.lineTo(M,t.canvasHeight),X=X.add(1,I)}if(e.stroke(),c&&c.length>0)for(const M of c){const _=t.timeToX(M.start),j=t.timeToX(M.end);if(!(j<0||_>t.canvasWidth)&&(e.strokeStyle=M.color,e.globalAlpha=.4,e.lineWidth=1,e.beginPath(),_>=0&&_<=t.canvasWidth&&(e.moveTo(_,0),e.lineTo(_,t.canvasHeight)),j>=0&&j<=t.canvasWidth&&(e.moveTo(j,0),e.lineTo(j,t.canvasHeight)),e.stroke(),e.globalAlpha=1,M.label)){const A=Math.max(0,_),V=Math.min(t.canvasWidth,j)-A;e.save(),e.font='600 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const ne=e.measureText(M.label).width,D=6,L=ne+D*2,q=18,J=A+(V-L)/2,ie=4;e.fillStyle=M.color,e.globalAlpha=.9,e.beginPath(),e.roundRect(J,ie,L,q,3),e.fill(),e.globalAlpha=1,e.fillStyle="#FFFFFF",e.textBaseline="middle",e.fillText(M.label,J+D,ie+q/2),e.restore()}}}}const wt='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function _t(i,e){return{roundRect(t,n,r,d,l=3){i.beginPath(),i.roundRect(t,n,r,d,l),i.fill()},fillText(t,n,r,d){if(i.font=wt,d!==void 0&&i.measureText(t).width>d){let l=0,c=t.length;for(;l<c;){const u=Math.ceil((l+c)/2),b=t.slice(0,u)+"...";i.measureText(b).width<=d?l=u:c=u-1}i.fillText(t.slice(0,l)+"...",n,r)}else i.fillText(t,n,r)},gradient(t,n,r,d){const l=i.createLinearGradient(t,0,t+n,0);return l.addColorStop(0,r),l.addColorStop(.5,r),l.addColorStop(.5,d),l.addColorStop(1,d),l},leftBar(t,n=3){e&&(i.save(),i.fillStyle=t,i.fillRect(e.x,e.y,n,e.height),i.restore())},icon(t,n,r,d=14){i.save();const l=d/2;if(t==="check"){i.fillStyle="#31c48d",i.beginPath(),i.arc(n+l,r+l,l,0,Math.PI*2),i.fill(),i.strokeStyle="#ffffff",i.lineWidth=d*.12,i.beginPath();const c=n+l,u=r+l;i.moveTo(c-l*.45,u),i.lineTo(c-l*.1,u+l*.42),i.lineTo(c+l*.45,u-l*.35),i.stroke()}else if(t==="danger-red"||t==="danger-yellow"){const c=t==="danger-red"?"#EF5350":"#FBBF24";i.fillStyle=c,i.beginPath(),i.moveTo(n+l,r),i.lineTo(n+d,r+d),i.lineTo(n,r+d),i.closePath(),i.fill(),i.fillStyle="#ffffff";const u=d*.12,b=n+l-u/2;i.fillRect(b,r+d*.35,u,d*.35),i.beginPath(),i.arc(n+l,r+d*.82,u*.7,0,Math.PI*2),i.fill()}i.restore()},badge(t,n,r,d){i.save(),i.font=wt;const c=i.measureText(t).width,u=8,E=12+3*2,p=c+u*2,y=E/2;i.fillStyle=d,i.beginPath(),i.roundRect(n,r,p,E,y),i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(t,n+p/2,r+E/2),i.restore()}}}class gi{draw(e,t,n,r,d,l,c,u,b,E,p,y,k,H){const I=(t.visibleTimeEnd-t.visibleTimeStart)*.1,X=t.visibleTimeStart-I,$=t.visibleTimeEnd+I,M=d.query(X,$),_=new Map;for(let D=0;D<n.length;D++)_.set(n[D].id,D);const j=new Set(E),A=new Map,V=-t.lineHeight,ne=t.canvasHeight+t.lineHeight;for(const D of M){const L=_.get(D.group);if(L===void 0)continue;const q=l.getLayout(D.id);if(!q)continue;const ie=t.groupIndexToY(L)+q.stackLevel*t.lineHeight+(t.lineHeight-q.itemHeight)/2,ae=q.itemHeight;if(ie+ae<V||ie>ne)continue;const fe=t.timeToX(D.start_time),Se=t.timeToX(D.end_time)-fe,me={x:fe,y:ie,width:Se,height:ae};A.set(D.id,me);const Ee={selected:j.has(D.id),hovered:p===D.id,dragging:!1,filtered:D.filtered!==!1};e.save();const We=_t(e,me);let ke;k&&(H!=null&&H.isParent(D.id))?ke=k:u&&(D.type==="control_area_group"||D.type==="construction_train")?ke=u:ke=c,ke(e,D,me,Ee,We),e.restore()}if(y&&y.length>0){const D=new Set;for(const L of y)A.has(L.fromItemId)||D.add(L.fromItemId),A.has(L.toItemId)||D.add(L.toItemId);if(D.size>0){const L=new Map;for(const q of r)D.has(q.id)&&L.set(q.id,q);for(const[q,J]of L){const ie=_.get(J.group);if(ie===void 0)continue;const ae=l.getLayout(q);if(!ae)continue;const Se=t.groupIndexToY(ie)+ae.stackLevel*t.lineHeight+(t.lineHeight-ae.itemHeight)/2,me=t.timeToX(J.start_time),Ee=t.timeToX(J.end_time)-me;A.set(q,{x:me,y:Se,width:Ee,height:ae.itemHeight})}}this.drawDependencies(e,y,A,p,b)}}drawDependencies(e,t,n,r,d){for(const l of t){const c=n.get(l.fromItemId),u=n.get(l.toItemId);if(!c||!u)continue;const b=r===l.fromItemId||r===l.toItemId;e.strokeStyle=b?d.primary:l.color??"#94A3B8",e.lineWidth=b?2:1.5,e.setLineDash([]);const E=c.x+c.width,p=c.y+c.height/2,y=u.x,k=u.y+u.height/2,H=Math.abs(y-E),I=Math.max(H*.4,30);e.beginPath(),e.moveTo(E,p),e.bezierCurveTo(E+I,p,y-I,k,y,k),e.stroke();const X=6;e.fillStyle=e.strokeStyle,e.beginPath(),e.moveTo(y,k),e.lineTo(y-X,k-X/2),e.lineTo(y-X,k+X/2),e.closePath(),e.fill()}}}class pi{draw(e,t,n,r){const{cursorX:d,snapX:l,markers:c,interaction:u}=r;if(c)for(const b of c){const E=t.timeToX(b.date);if(e.fillStyle=b.color,e.fillRect(E-b.width/2,0,b.width,t.canvasHeight),b.label){e.save(),e.font='500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const p=e.measureText(b.label).width,y=8,k=200,H=Math.min(p+y*2,k),I=20,X=E-H/2,$=4;e.fillStyle=b.color,e.beginPath(),e.roundRect(X,$,H,I,3),e.fill(),e.fillStyle="#FFFFFF",e.textBaseline="middle";const M=k-y*2,_=p>M?b.label.slice(0,Math.floor(b.label.length*M/p))+"…":b.label;e.fillText(_,X+y,$+I/2),e.restore()}}if(d!=null&&(e.strokeStyle=n.marker.cursor,e.lineWidth=1,e.beginPath(),e.moveTo(d,0),e.lineTo(d,t.canvasHeight),e.stroke()),l!=null&&(e.strokeStyle=n.primary,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(l,0),e.lineTo(l,t.canvasHeight),e.stroke(),e.setLineDash([])),u){u.groupChanged&&u.targetGroupY!==void 0&&(e.fillStyle="rgba(59, 130, 246, 0.08)",e.fillRect(0,u.targetGroupY,t.canvasWidth,t.lineHeight)),e.save(),e.globalAlpha=.5;const b=_t(e,u.bounds);u.renderer(e,u.item,u.bounds,{selected:!1,hovered:!1,dragging:!0,filtered:!0},b),e.restore()}}}const Ht=120;function vi(i){let e=i.deltaY||i.deltaX;return i.deltaMode===1?e*=15:i.deltaMode===2&&(e*=800),Math.max(-Ht,Math.min(Ht,e))}class bi{constructor(e,t,n,r,d){Object.defineProperty(this,"onZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"visibleTimeEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"minZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxZoom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.onZoom=e,this.visibleTimeStart=t,this.visibleTimeEnd=n,this.minZoom=r,this.maxZoom=d}updateBounds(e,t){this.visibleTimeStart=e,this.visibleTimeEnd=t}handleWheelZoom(e,t){const n=vi(e),r=e.ctrlKey?10:e.metaKey?3:1,d=n>0?1+r*n/500:1/(1+r*-n/500),l=this.visibleTimeEnd-this.visibleTimeStart;let c=Math.round(l*d);c=Math.max(this.minZoom,Math.min(this.maxZoom,c));const u=Math.round(this.visibleTimeStart+(l-c)*t),b=u+c;this.onZoom(u,b)}}const yi=4;class Ti{constructor(e){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"dragSnap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.dragSnap=e}startInteraction(e,t,n,r){this.state={item:e,mode:t,startX:n,startY:r,currentX:n,currentY:r,deltaX:0,originalGroup:e.group,currentGroup:e.group},this.activated=!1}update(e,t){this.state&&(this.state.currentX=e,this.state.currentY=t,this.state.deltaX=e-this.state.startX,!this.activated&&Math.abs(this.state.deltaX)>=yi&&(this.activated=!0))}setCurrentGroup(e){this.state&&(this.state.currentGroup=e)}endMove(e){if(!this.state)return null;const t=this.state.deltaX/e,n=this.state.item.start_time+t,r=Math.round(n/this.dragSnap)*this.dragSnap,d=this.state.currentGroup;return this.state=null,this.activated=!1,{newStartTime:r,newGroupId:d}}endResize(e){if(!this.state)return null;const t=this.state.deltaX/e,n=this.state.mode==="resize-left"?"left":"right",d=(n==="left"?this.state.item.start_time:this.state.item.end_time)+t,l=Math.round(d/this.dragSnap)*this.dragSnap;return this.state=null,this.activated=!1,{newTime:l,edge:n}}cancel(){this.state=null,this.activated=!1}getState(){return this.state}getMode(){var e;return((e=this.state)==null?void 0:e.mode)??null}isActive(){return this.state!==null&&this.activated}isPending(){return this.state!==null}}function st(i,e,t){const n=[];for(const r of i)r.id!==e&&(n.push(t(r.start_time)),n.push(t(r.end_time)));return n}function Ye(i,e,t,n,r){if(e.length===0)return null;let d=e[0],l=Math.abs(i-d);for(let c=1;c<e.length;c++){const u=Math.abs(i-e[c]);u<l&&(l=u,d=e[c])}return l<=t?d:null}var Wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Bt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(Wt,function(){var t="day";return function(n,r,d){var l=function(b){return b.add(4-b.isoWeekday(),t)},c=r.prototype;c.isoWeekYear=function(){return l(this).year()},c.isoWeek=function(b){if(!this.$utils().u(b))return this.add(7*(b-this.isoWeek()),t);var E,p,y,k,H=l(this),I=(E=this.isoWeekYear(),p=this.$u,y=(p?d.utc:d)().year(E).startOf("year"),k=4-y.isoWeekday(),y.isoWeekday()>4&&(k+=7),y.add(k,t));return H.diff(I,"week")+1},c.isoWeekday=function(b){return this.$utils().u(b)?this.day()||7:this.day(this.day()%7?b:b-7)};var u=c.startOf;c.startOf=function(b,E){var p=this.$utils(),y=!!p.u(E)||E;return p.p(b)==="isoweek"?y?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):u.bind(this)(b,E)}}})})(Bt);var ki=Bt.exports;const Mi=Xt(ki),Rt=5;function It({groups:i,width:e,lineHeight:t,scrollTop:n,canvasHeight:r,theme:d,groupRenderer:l,onScroll:c}){var X;const u=h.useRef(null),b=h.useRef(!1),E=i.length*t,p=r,y=Math.max(0,Math.floor(n/t)-Rt),k=Math.min(i.length-1,Math.ceil((n+r)/t)+Rt),H=h.useCallback($=>{b.current||c($.currentTarget.scrollTop)},[c]);h.useEffect(()=>{u.current&&(b.current=!0,u.current.scrollTop=n,requestAnimationFrame(()=>{b.current=!1}))},[n]);const I=[];for(let $=y;$<=k;$++){const M=i[$];M&&I.push(z.jsx("div",{style:{position:"absolute",top:$*t,height:t,width:"100%",overflow:"hidden",display:"flex",alignItems:"stretch",borderBottom:`1px solid ${((X=d.grid)==null?void 0:X.line)??"#E5E5E5"}`,boxSizing:"border-box"},children:l(M)},M.id))}return z.jsx("div",{ref:u,onScroll:H,style:{width:e,height:p,overflowY:E>r?"auto":"hidden",overflowX:"hidden",position:"relative",borderRight:`1px solid ${d.sidebar.border}`,backgroundColor:d.sidebar.bg},children:z.jsx("div",{style:{height:E,position:"relative"},children:I})})}function jt(i){return null}jt.displayName="TodayMarker";function Pt(i){return{date:Math.floor(Date.now()/6e4)*6e4,color:i.color??"#FD7171",width:i.width??6,label:i.label}}function Si(i){return i.interval??1e4}function Lt(i){return null}Lt.displayName="CustomMarker";function Dt(i){return{date:i.date,color:i.color??"#3B82F6",width:i.width??4,label:i.label}}he.extend(Mi);function Ei(i){return i?{...pe,...i,status:{...pe.status,...i.status},grid:{...pe.grid,...i.grid},item:{...pe.item,...i.item},marker:{...pe.marker,...i.marker},sidebar:{...pe.sidebar,...i.sidebar},header:{...pe.header,...i.header}}:pe}const Ft=32,Ci=h.memo(h.forwardRef(function(e,t){const{groups:n,items:r,defaultTimeStart:d,defaultTimeEnd:l,sidebarWidth:c,lineHeight:u,itemHeightRatio:b,stackItems:E,canMove:p,canChangeGroup:y,canResize:k,dragSnap:H,minZoom:I,maxZoom:X,theme:$,dayStyle:M,rowStyle:_,showCursorLine:j,itemRenderer:A,groupRenderer:V,sidebarGroupRenderer:ne,dependencies:D,highlights:L,onItemClick:q,onItemDoubleClick:J,onItemContextMenu:ie,onItemMove:ae,onItemResize:fe,moveResizeValidator:Se,onItemHover:me,onCanvasDoubleClick:Ee,onCanvasContextMenu:We,onTimeChange:ke,onZoom:ot,selected:lt=[],rightSidebarWidth:Ne,rightSidebarGroupRenderer:at,onReady:Xe,children:ve}=e,ge=h.useMemo(()=>Ei($),[$]),ut=h.useCallback((a,s)=>{for(let f=0;f<s.length;f++)if(s[f].id===a)return f;return 0},[]),Gt=lt.join(","),$e=h.useMemo(()=>lt,[Gt]),ct=h.useRef(null),dt=h.useRef(null),ht=h.useRef(null),Ie=h.useRef(null),ft=h.useRef(null),zt=h.useRef(null),[Vt,Zt]=h.useState(800);h.useEffect(()=>{const a=ft.current;if(!a)return;const s=new ResizeObserver(f=>{const m=f[0];m&&Zt(m.contentRect.width)});return s.observe(a),()=>s.disconnect()},[]);const be=Math.max(0,Vt-c-(Ne??0)),ye=n.length*u,F=h.useRef(new tt({visibleTimeStart:e.visibleTimeStart??d,visibleTimeEnd:e.visibleTimeEnd??l,canvasWidth:be,canvasHeight:ye,sidebarWidth:c,lineHeight:u,groupCount:n.length,buffer:e.buffer??3,scrollTop:0})),Ge=h.useRef(null),Pe=h.useRef(void 0),[mt,qt]=h.useState(e.visibleTimeStart??d),[gt,Ut]=h.useState(e.visibleTimeEnd??l),[pt,Be]=h.useState(0),De=h.useRef(null),Ce=h.useCallback(()=>{const a=F.current;qt(a.visibleTimeStart),Ut(a.visibleTimeEnd),Be(a.scrollTop),De.current=null},[]),ze=h.useCallback(()=>{De.current===null&&(De.current=setTimeout(Ce,Ft))},[Ce]);h.useEffect(()=>()=>{De.current!==null&&clearTimeout(De.current)},[]);const Me=h.useMemo(()=>{const a=new Ot;return a.rebuild(r),a},[r]),Ve=h.useMemo(()=>{const a=new ci;return a.buildFromItems(r,s=>Me.getEffectiveSpan(s.id).start,s=>Me.getEffectiveSpan(s.id).end),a},[r,Me]),Ze=h.useMemo(()=>{const a=new di(u,b);return a.computeLayout(r,E,Me),a},[r,u,b,E,Me]),vt=h.useMemo(()=>e.summaryRenderer?e.summaryRenderer:(a,s,f,m,o)=>{hi(a,s,f,m,o,ge)},[e.summaryRenderer,ge]),we=h.useMemo(()=>new mi,[]),He=h.useMemo(()=>new gi,[]),Re=h.useMemo(()=>new pi,[]),ee=h.useMemo(()=>new Ti(H),[H]),je=h.useMemo(()=>{const a=[];return h.Children.forEach(ve,s=>{var m;if(!h.isValidElement(s))return;const f=(m=s.type)==null?void 0:m.displayName;f==="TodayMarker"?a.push(Pt(s.props)):f==="CustomMarker"&&a.push(Dt(s.props))}),a},[ve]),Le=h.useMemo(()=>je.map(a=>`${a.date}|${a.color}|${a.width}|${a.label??""}`).join(";"),[je]),Fe=h.useRef(je);Fe.current=je;const qe=h.useMemo(()=>{let a=0;return h.Children.forEach(ve,s=>{var m;if(!h.isValidElement(s))return;((m=s.type)==null?void 0:m.displayName)==="TodayMarker"&&(a=Si(s.props))}),a},[ve]),O=h.useRef({groups:n,items:r,intervalTree:Ve,layoutEngine:Ze,itemRenderer:A,groupRenderer:V,theme:ge,selected:$e,dependencies:D,highlights:L,dayStyle:M,rowStyle:_,showCursorLine:j,canvasWidth:be,canvasHeight:ye,lineHeight:u,itemHeightRatio:b,onTimeChange:ke,onZoom:ot,onItemHover:me,onItemClick:q,onItemDoubleClick:J,onItemContextMenu:ie,onItemMove:ae,onItemResize:fe,onCanvasDoubleClick:Ee,onCanvasContextMenu:We,canMove:p,canResize:k,canChangeGroup:y,dragSnap:H,sidebarWidth:c,moveResizeValidator:Se,summaryRenderer:vt,hierarchyEngine:Me});O.current={groups:n,items:r,intervalTree:Ve,layoutEngine:Ze,itemRenderer:A,groupRenderer:V,theme:ge,selected:$e,dependencies:D,highlights:L,dayStyle:M,rowStyle:_,showCursorLine:j,canvasWidth:be,canvasHeight:ye,lineHeight:u,itemHeightRatio:b,onTimeChange:ke,onZoom:ot,onItemHover:me,onItemClick:q,onItemDoubleClick:J,onItemContextMenu:ie,onItemMove:ae,onItemResize:fe,onCanvasDoubleClick:Ee,onCanvasContextMenu:We,canMove:p,canResize:k,canChangeGroup:y,dragSnap:H,sidebarWidth:c,moveResizeValidator:Se,summaryRenderer:vt,hierarchyEngine:Me};const Kt=h.useCallback(()=>{const a=ct.current;if(!a)return;const s=O.current,f=nt(a,s.canvasWidth,s.canvasHeight);rt(f,a),we.draw(f,F.current,s.groups,s.theme,s.dayStyle,s.rowStyle,s.highlights)},[we]),Jt=h.useCallback(()=>{const a=dt.current;if(!a)return;const s=O.current,f=nt(a,s.canvasWidth,s.canvasHeight);rt(f,a),He.draw(f,F.current,s.groups,s.items,s.intervalTree,s.layoutEngine,s.itemRenderer,s.groupRenderer,s.theme,s.selected,Pe.current,s.dependencies,s.summaryRenderer,s.hierarchyEngine)},[He]),bt=h.useCallback((a,s,f)=>{const m=F.current,o=O.current,g=o.canvasWidth/(m.visibleTimeEnd-m.visibleTimeStart),T=s/g,S=[];f==="move"?(S.push(m.timeToX(a.start_time+T)),S.push(m.timeToX(a.end_time+T))):f==="resize-left"?S.push(m.timeToX(a.start_time+T)):S.push(m.timeToX(a.end_time+T));const R=(m.visibleTimeEnd-m.visibleTimeStart)*.1,W=o.intervalTree.query(m.visibleTimeStart-R,m.visibleTimeEnd+R),Z=st(W,a.id,re=>m.timeToX(re));for(const re of S){const G=Ye(re,Z,8,g,o.dragSnap);if(G!==null)return G}const Q=a.start_time+T,P=Math.round(Q/o.dragSnap)*o.dragSnap;return m.timeToX(P)},[]),Qt=h.useCallback(()=>{const a=ht.current;if(!a)return;const s=O.current,f=nt(a,s.canvasWidth,s.canvasHeight);rt(f,a);const m=F.current,o=ee.getState();let g=null;if(o){const T=m.timeToX(o.item.start_time),S=m.timeToX(o.item.end_time)-T;let R,W;o.mode==="resize-left"?(R=T+o.deltaX,W=S-o.deltaX):o.mode==="resize-right"?(R=T,W=S+o.deltaX):(R=T+o.deltaX,W=S);const Z=ut(o.currentGroup,s.groups),Q=m.groupIndexToY(Z),P=o.currentGroup!==o.originalGroup;g={item:o.item,mode:o.mode,bounds:{x:R,y:Q+(s.lineHeight-s.lineHeight*s.itemHeightRatio)/2,width:W,height:s.lineHeight*s.itemHeightRatio},renderer:s.itemRenderer,targetGroupY:Q,groupChanged:P}}Re.draw(f,m,s.theme,{cursorX:s.showCursorLine?Ge.current:null,snapX:o?bt(o.item,o.deltaX,o.mode):null,markers:Fe.current,interaction:g})},[Re,ee,bt,ut]),Ue=h.useRef(null);Ue.current||(Ue.current=new fi(a=>{a.grid&&Kt(),a.items&&Jt(),a.overlay&&Qt()}));const w=Ue.current;h.useEffect(()=>()=>w.dispose(),[w]),h.useEffect(()=>{if(!qe)return;const a=setInterval(()=>{const s=[];h.Children.forEach(ve,f=>{var o;if(!h.isValidElement(f))return;const m=(o=f.type)==null?void 0:o.displayName;m==="TodayMarker"?s.push(Pt(f.props)):m==="CustomMarker"&&s.push(Dt(f.props))}),Fe.current=s,w.markDirty("overlay")},qe);return()=>clearInterval(a)},[qe,ve,w]),h.useEffect(()=>{F.current.update({canvasWidth:be,canvasHeight:ye,sidebarWidth:c,lineHeight:u,groupCount:n.length}),w.markAllDirty()},[be,ye,c,u,n.length,w]),h.useEffect(()=>{w.markDirty("grid"),w.markDirty("items")},[r,n,$e,ge,M,_,Ve,Ze,w]);const xe=h.useMemo(()=>{var a;return((a=e.highlights)==null?void 0:a.map(s=>`${s.start}|${s.end}|${s.color}|${s.label??""}|${s.opacity??""}`).join(";"))??""},[e.highlights]),yt=h.useRef(xe);h.useEffect(()=>{xe!==yt.current&&(yt.current=xe,w.markDirty("grid"))},[xe,w]);const Tt=h.useRef(Le);h.useEffect(()=>{Le!==Tt.current&&(Tt.current=Le,w.markDirty("overlay"))},[Le,w]);const kt=h.useRef(e.visibleTimeStart),Mt=h.useRef(e.visibleTimeEnd);e.visibleTimeStart!==void 0&&e.visibleTimeStart!==kt.current&&(kt.current=e.visibleTimeStart,F.current.update({visibleTimeStart:e.visibleTimeStart}),w.markAllDirty()),e.visibleTimeEnd!==void 0&&e.visibleTimeEnd!==Mt.current&&(Mt.current=e.visibleTimeEnd,F.current.update({visibleTimeEnd:e.visibleTimeEnd}),w.markAllDirty());const Oe=h.useRef(null),Ke=h.useCallback(a=>{Oe.current===null&&(Oe.current=setTimeout(()=>{var m,o;Oe.current=null;const s=F.current,f=O.current;a==="zoom"?(m=f.onZoom)==null||m.call(f,s.visibleTimeStart,s.visibleTimeEnd):(o=f.onTimeChange)==null||o.call(f,s.visibleTimeStart,s.visibleTimeEnd)},Ft))},[]);h.useEffect(()=>()=>{Oe.current!==null&&clearTimeout(Oe.current)},[]);const Ae=h.useRef(null),Je=h.useMemo(()=>new bi((a,s)=>{var f;F.current.update({visibleTimeStart:a,visibleTimeEnd:s}),(f=Ae.current)==null||f.updateBounds(a,s),w.markAllDirty(),ze(),Ke("zoom")},d,l,I,X),[]);Ae.current=Je;const St=h.useCallback(a=>{const s=F.current,f=s.groupCount*s.lineHeight,m=Math.max(0,f-s.canvasHeight),o=Math.max(0,Math.min(m,s.scrollTop+a));o!==s.scrollTop&&(s.update({scrollTop:o}),w.markDirty("grid"),w.markDirty("items"),w.markDirty("overlay"),Be(o))},[w]),Qe=h.useCallback(a=>{var T,S,R;const s=F.current,f=s.canvasWidth/(s.visibleTimeEnd-s.visibleTimeStart),m=a/f,o=s.visibleTimeStart+m,g=s.visibleTimeEnd+m;s.update({visibleTimeStart:o,visibleTimeEnd:g}),(T=Ae.current)==null||T.updateBounds(o,g),w.markAllDirty(),ui.flushSync(()=>Ce()),(R=(S=O.current).onTimeChange)==null||R.call(S,o,g)},[w,Ce]);h.useEffect(()=>{const a=Ie.current;if(!a)return;const s=f=>{if(f.ctrlKey||f.metaKey||f.altKey){f.preventDefault();const m=a.getBoundingClientRect(),o=(f.clientX-m.left)/m.width;Je.handleWheelZoom(f,o)}else if(f.shiftKey)f.preventDefault(),Qe(f.deltaY);else{const m=f.deltaX;m!==0&&Math.abs(m)>Math.abs(f.deltaY)?(f.preventDefault(),Qe(m)):f.deltaY!==0&&St(f.deltaY)}};return a.addEventListener("wheel",s,{passive:!1}),()=>a.removeEventListener("wheel",s)},[Je,St,Qe]);const Te=h.useRef({lastDistance:null,lastCenter:null});h.useEffect(()=>{const a=Ie.current;if(!a)return;const s=(T,S)=>Math.abs(T.clientX-S.clientX),f=(T,S,R)=>(T.clientX+S.clientX)/2-R.left,m=T=>{T.touches.length===2&&(T.preventDefault(),Te.current.lastDistance=s(T.touches[0],T.touches[1]),Te.current.lastCenter=null)},o=T=>{var S;if(T.touches.length===2&&Te.current.lastDistance!==null){T.preventDefault();const R=s(T.touches[0],T.touches[1]),W=a.getBoundingClientRect(),Q=f(T.touches[0],T.touches[1],W)/W.width;if(R!==0&&Te.current.lastDistance!==0){const P=Te.current.lastDistance/R,re=F.current,G=re.visibleTimeEnd-re.visibleTimeStart;let C=G*P;C=Math.max(I,Math.min(X,C));const v=re.visibleTimeStart+G*Q,Y=v-C*Q,x=v+C*(1-Q);re.update({visibleTimeStart:Y,visibleTimeEnd:x}),(S=Ae.current)==null||S.updateBounds(Y,x),w.markAllDirty(),ze(),Ke("zoom")}Te.current.lastDistance=R}},g=()=>{Te.current.lastDistance=null,Te.current.lastCenter=null};return a.addEventListener("touchstart",m,{passive:!1}),a.addEventListener("touchmove",o,{passive:!1}),a.addEventListener("touchend",g),()=>{a.removeEventListener("touchstart",m),a.removeEventListener("touchmove",o),a.removeEventListener("touchend",g)}},[w,ze,Ke]);const ei=h.useCallback(a=>{var R;const s=a.currentTarget,f=s.getBoundingClientRect(),m=a.clientX-f.left,o=a.clientY-f.top;if(Ge.current=m,ee.isPending()){if(ee.update(m,o),ee.isActive()){const W=ee.getState();if(W&&W.mode==="move"&&O.current.canChangeGroup){const Z=it(o,F.current,O.current.groups);Z&&ee.setCurrentGroup(Z.id)}w.markDirty("overlay")}return}O.current.showCursorLine&&w.markDirty("overlay");const g=O.current,T=_e(m,o,F.current,g.intervalTree,g.layoutEngine,g.groups),S=T==null?void 0:T.id;if(S!==Pe.current&&(Pe.current=S,w.markDirty("items"),(R=g.onItemHover)==null||R.call(g,S??null,a.nativeEvent)),T){const W=Ct(m,T,F.current),Z=g.canResize;W==="left"&&(Z==="left"||Z==="both")||W==="right"&&(Z==="right"||Z==="both")?s.style.cursor="col-resize":g.canMove?s.style.cursor="grab":s.style.cursor="default"}else s.style.cursor="default"},[ee,w]),ti=h.useCallback(a=>{const s=O.current,f=a.currentTarget.getBoundingClientRect(),m=a.clientX-f.left,o=a.clientY-f.top,g=_e(m,o,F.current,s.intervalTree,s.layoutEngine,s.groups);if(!g)return;const T=Ct(m,g,F.current),S=s.canResize;T==="left"&&(S==="left"||S==="both")?ee.startInteraction(g,"resize-left",m,o):T==="right"&&(S==="right"||S==="both")?ee.startInteraction(g,"resize-right",m,o):s.canMove&&ee.startInteraction(g,"move",m,o)},[ee]),ii=h.useCallback(a=>{var T,S,R,W,Z,Q;const s=a.currentTarget;if(ee.isActive()){const P=ee.getState(),re=F.current,G=re.canvasWidth/(re.visibleTimeEnd-re.visibleTimeStart);if(P){const C=O.current.moveResizeValidator;if(P.mode==="move"){const v=ee.endMove(G);if(v){const Y=F.current,x=O.current,oe=P.deltaX/G,ce=Y.timeToX(P.item.start_time+oe),B=Y.timeToX(P.item.end_time+oe),U=(Y.visibleTimeEnd-Y.visibleTimeStart)*.1,te=x.intervalTree.query(Y.visibleTimeStart-U,Y.visibleTimeEnd+U),N=st(te,P.item.id,de=>Y.timeToX(de));let se=v.newStartTime;const K=Ye(ce,N,8,G,x.dragSnap);if(K!==null)se=Y.xToTime(K);else{const de=Ye(B,N,8,G,x.dragSnap);if(de!==null){const ai=P.item.end_time-P.item.start_time;se=Y.xToTime(de)-ai}}const le=C?C("move",P.item.id,se):se,ue=O.current.hierarchyEngine.getMoveDelta(P.item.id,le);(S=(T=O.current).onItemMove)==null||S.call(T,P.item.id,le,v.newGroupId,ue.length>0?ue:void 0)}}else{const v=ee.endResize(G);if(v){const Y=F.current,x=O.current,oe=P.deltaX/G,ce=v.edge==="left"?P.item.start_time+oe:P.item.end_time+oe,B=Y.timeToX(ce),U=(Y.visibleTimeEnd-Y.visibleTimeStart)*.1,te=x.intervalTree.query(Y.visibleTimeStart-U,Y.visibleTimeEnd+U),N=st(te,P.item.id,de=>Y.timeToX(de)),se=Ye(B,N,8,G,x.dragSnap);let K=se!==null?Y.xToTime(se):v.newTime;const le=O.current.hierarchyEngine.getResizeConstraint(P.item.id,v.edge);v.edge==="left"&&K>le.max?K=le.max:v.edge==="right"&&K<le.min&&(K=le.min);const ue=C?C("resize",P.item.id,K,v.edge):K;(W=(R=O.current).onItemResize)==null||W.call(R,P.item.id,ue,v.edge)}}}s.style.cursor="default",w.markDirty("overlay");return}ee.isPending()&&ee.cancel();const f=s.getBoundingClientRect(),m=a.clientX-f.left,o=a.clientY-f.top,g=_e(m,o,F.current,O.current.intervalTree,O.current.layoutEngine,O.current.groups);g&&((Q=(Z=O.current).onItemClick)==null||Q.call(Z,g.id,a.nativeEvent))},[ee,w]),ni=h.useCallback(a=>{var T,S;const s=a.currentTarget.getBoundingClientRect(),f=a.clientX-s.left,m=a.clientY-s.top,o=O.current,g=_e(f,m,F.current,o.intervalTree,o.layoutEngine,o.groups);if(g)(T=o.onItemDoubleClick)==null||T.call(o,g.id,a.nativeEvent);else{const R=it(m,F.current,o.groups),W=F.current.xToTime(f);R&&((S=o.onCanvasDoubleClick)==null||S.call(o,R.id,W))}},[]),ri=h.useCallback(a=>{var T,S;a.preventDefault();const s=a.currentTarget.getBoundingClientRect(),f=a.clientX-s.left,m=a.clientY-s.top,o=O.current,g=_e(f,m,F.current,o.intervalTree,o.layoutEngine,o.groups);if(g)(T=o.onItemContextMenu)==null||T.call(o,g.id,a.nativeEvent);else{const R=it(m,F.current,o.groups),W=F.current.xToTime(f);R&&((S=o.onCanvasContextMenu)==null||S.call(o,R.id,W,a.nativeEvent))}},[]),si=h.useCallback(()=>{var a,s;Ge.current=null,Ie.current&&(Ie.current.style.cursor="default"),Pe.current!==void 0&&(Pe.current=void 0,w.markDirty("items"),(s=(a=O.current).onItemHover)==null||s.call(a,null,new PointerEvent("pointerleave"))),O.current.showCursorLine&&w.markDirty("overlay")},[w]),oi=h.useMemo(()=>{const a=[];return h.Children.forEach(ve,s=>{var m;if(!h.isValidElement(s))return;if(((m=s.type)==null?void 0:m.displayName)==="TimelineHeaders"){const o=s.props;a.push(h.cloneElement(s,{visibleTimeStart:o.visibleTimeStart??mt,visibleTimeEnd:o.visibleTimeEnd??gt,canvasWidth:o.canvasWidth??be,sidebarWidth:o.sidebarWidth??c,theme:o.theme??ge,onZoomToInterval:o.onZoomToInterval??((g,T)=>{var S,R,W,Z;F.current.update({visibleTimeStart:g,visibleTimeEnd:T}),w.markAllDirty(),Ce(),(R=(S=O.current).onTimeChange)==null||R.call(S,g,T),(Z=(W=O.current).onZoom)==null||Z.call(W,g,T)})}))}}),a},[ve,mt,gt,be,c,ge,w,Ce]),Et=h.useRef(!1);h.useEffect(()=>{Et.current||(Et.current=!0,w.markAllDirty())},[w]),h.useImperativeHandle(t,()=>({captureToCanvas({timeStart:a,timeEnd:s,scale:f,sidebarWidth:m}){const o=O.current,g=28,T=g*3,S=o.groups.length*o.lineHeight,R=F.current,W=o.canvasWidth/(R.visibleTimeEnd-R.visibleTimeStart),Z=s-a,Q=Math.max(o.canvasWidth,Math.round(Z*W)),P=(m+Q)*f,re=(T+S)*f,G=document.createElement("canvas");G.width=P,G.height=re;const C=G.getContext("2d");C.scale(f,f);for(let x=0;x<o.groups.length;x++){const oe=o.groups[x],ce=T+x*o.lineHeight;if(o.rowStyle){const N=o.rowStyle(oe);N!=null&&N.backgroundColor&&(C.fillStyle=N.backgroundColor,C.fillRect(0,ce,m,o.lineHeight))}const B=oe.type;let U="400",te=8;B==="project"?U="700":B==="CAG"?U="600":B==="CA"&&(U="400",te=24),C.fillStyle="#111",C.font=`${U} 12px sans-serif`,C.textBaseline="middle",C.fillText(oe.title,te,ce+o.lineHeight/2,m-te-4)}const v=(x,oe,ce)=>{var te,N;C.fillStyle=((te=o.theme.header)==null?void 0:te.bg)??"#f5f5f5",C.fillRect(m,x,Q,g),C.strokeStyle=((N=o.theme.grid)==null?void 0:N.line)??"#e0e0e0",C.lineWidth=1,C.strokeRect(m,x,Q,g);let B=he(a).startOf(ce);B.valueOf()<a&&(B=B.add(1,ce));const U=Q/(s-a);for(;B.valueOf()<s;){const se=B.add(1,ce),K=m+(B.valueOf()-a)*U,ue=m+(Math.min(se.valueOf(),s)-a)*U-K;C.beginPath(),C.moveTo(K,x),C.lineTo(K,x+g),C.stroke(),C.fillStyle="#333",C.font="600 11px sans-serif",C.textBaseline="middle",C.textAlign="center",C.fillText(oe(B),K+ue/2,x+g/2,ue-4),B=se}C.textAlign="start"};v(0,x=>x.format("YYYY"),"year"),v(g,x=>x.format("MM"),"month"),v(g*2,x=>String(x.isoWeek()),"week");const Y=new tt({visibleTimeStart:a,visibleTimeEnd:s,canvasWidth:Q,canvasHeight:S,sidebarWidth:0,lineHeight:o.lineHeight,groupCount:o.groups.length,buffer:1,scrollTop:0});return C.save(),C.translate(m,T),C.beginPath(),C.rect(0,0,Q,S),C.clip(),we.draw(C,Y,o.groups,o.theme,o.dayStyle,o.rowStyle,o.highlights),He.draw(C,Y,o.groups,o.items,o.intervalTree,o.layoutEngine,o.itemRenderer,o.groupRenderer,o.theme,o.selected,void 0,o.dependencies,o.summaryRenderer,o.hierarchyEngine),Re.draw(C,Y,o.theme,{cursorX:null,snapX:null,markers:Fe.current,interaction:null}),C.restore(),G}}),[we,He,Re]),h.useEffect(()=>{const a={captureToCanvas({timeStart:s,timeEnd:f,scale:m,sidebarWidth:o}){var ce;const g=O.current,T=28,S=T*3,R=g.groups.length*g.lineHeight,W=F.current,Z=g.canvasWidth/(W.visibleTimeEnd-W.visibleTimeStart),Q=f-s,P=Math.max(g.canvasWidth,Math.round(Q*Z)),re=o+P,G=S+R,C=document.createElement("canvas");C.width=re*m,C.height=G*m;const v=C.getContext("2d");v.scale(m,m),v.fillStyle="#FFFFFF",v.fillRect(0,0,re,G),v.save(),v.beginPath(),v.rect(0,0,o,G),v.clip(),v.fillStyle="#F9FAFB",v.fillRect(0,0,o,S),v.strokeStyle="#E5E7EB",v.lineWidth=1,v.strokeRect(0,0,o,S);for(let B=0;B<g.groups.length;B++){const U=g.groups[B],te=S+B*g.lineHeight,N=(ce=g.rowStyle)==null?void 0:ce.call(g,U);v.fillStyle=(N==null?void 0:N.backgroundColor)??(B%2===0?"#FFFFFF":"#F7F7F7"),v.fillRect(0,te,o,g.lineHeight),v.strokeStyle="#E5E5E5",v.lineWidth=.5,v.beginPath(),v.moveTo(0,te+g.lineHeight),v.lineTo(o,te+g.lineHeight),v.stroke();const se=U.type??"";let K=8,le="400",ue=11;se==="project"?(le="700",ue=12):se==="control_area_group"?le="600":se==="control_area"&&(K=24),v.fillStyle="#374151",v.font=`${le} ${ue}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,v.textBaseline="middle";const de=typeof U.title=="string"?U.title:String(U.title);v.fillText(de,K,te+g.lineHeight/2,o-K-8)}v.strokeStyle="#E5E7EB",v.lineWidth=1,v.beginPath(),v.moveTo(o,0),v.lineTo(o,G),v.stroke(),v.restore(),v.save(),v.beginPath(),v.rect(o,0,P,S),v.clip();const Y=f-s,x=[{unit:"year",row:0},{unit:"month",row:1},{unit:"week",row:2}];for(const{unit:B,row:U}of x){const te=U*T;v.fillStyle="#F9FAFB",v.fillRect(o,te,P,T);let N=he(s).startOf(B);const se=he(f).add(1,B);for(;N.isBefore(se);){const K=N.add(1,B),le=o+(N.valueOf()-s)/Y*P,ue=(K.valueOf()-N.valueOf())/Y*P;v.strokeStyle="#E5E7EB",v.lineWidth=.5,v.strokeRect(le,te,ue,T);let de;B==="year"?de=N.format("YYYY"):B==="month"?de=N.format("MM"):de=`${N.week()}`,v.fillStyle="#6c737f",v.font=B==="year"?'600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif':'400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',v.textBaseline="middle",v.textAlign="center",ue>20&&v.fillText(de,le+ue/2,te+T/2),N=K}}v.textAlign="start",v.restore(),v.save(),v.beginPath(),v.rect(o,S,P,R),v.clip(),v.translate(o,S);const oe=new tt({visibleTimeStart:s,visibleTimeEnd:f,canvasWidth:P,canvasHeight:R,sidebarWidth:0,lineHeight:g.lineHeight,groupCount:g.groups.length,buffer:1,scrollTop:0});return we.draw(v,oe,g.groups,g.theme,g.dayStyle,g.rowStyle,g.highlights),He.draw(v,oe,g.groups,g.items,g.intervalTree,g.layoutEngine,g.itemRenderer,g.groupRenderer,g.theme,g.selected,void 0,g.dependencies,g.summaryRenderer,g.hierarchyEngine),Re.draw(v,oe,g.theme,{cursorX:null,markers:Fe.current}),v.restore(),C}};Xe==null||Xe(a)},[Xe,we,He,Re]);const li={position:"relative",width:be,height:ye,overflow:"hidden",cursor:"default"},et={position:"absolute",top:0,left:0};return z.jsxs("div",{ref:ft,style:{display:"flex",flexDirection:"column",width:"100%"},children:[oi,z.jsxs("div",{ref:zt,style:{display:"flex",overflow:"hidden"},children:[z.jsx(It,{groups:n,width:c,lineHeight:u,scrollTop:pt,canvasHeight:ye,theme:ge,groupRenderer:ne,onScroll:a=>{F.current.update({scrollTop:a}),w.markDirty("grid"),w.markDirty("items"),w.markDirty("overlay"),Be(a)}}),z.jsxs("div",{ref:Ie,style:li,onPointerMove:ei,onPointerDown:ti,onPointerUp:ii,onDoubleClick:ni,onContextMenu:ri,onPointerLeave:si,children:[z.jsx("canvas",{ref:ct,style:{...et,zIndex:0}}),z.jsx("canvas",{ref:dt,style:{...et,zIndex:1}}),z.jsx("canvas",{ref:ht,style:{...et,zIndex:2}})]}),Ne&&at?z.jsx(It,{groups:n,width:Ne,lineHeight:u,scrollTop:pt,canvasHeight:ye,theme:ge,groupRenderer:at,onScroll:a=>{F.current.update({scrollTop:a}),w.markDirty("grid"),w.markDirty("items"),w.markDirty("overlay"),Be(a)}}):null]})]})}));function xt({children:i,theme:e,className:t,classNames:n,style:r,visibleTimeStart:d,visibleTimeEnd:l,canvasWidth:c,sidebarWidth:u=0,onZoomToInterval:b}){const E=h.Children.map(i,p=>{var k;if(!h.isValidElement(p))return p;if(((k=p.type)==null?void 0:k.displayName)==="DateHeader"){const H=p.props,I=h.cloneElement(p,{visibleTimeStart:H.visibleTimeStart??d,visibleTimeEnd:H.visibleTimeEnd??l,canvasWidth:H.canvasWidth??c,theme:H.theme??e,onZoomToInterval:H.onIntervalClick??H.onZoomToInterval??b});return z.jsxs("div",{style:{display:"flex"},children:[z.jsx("div",{style:{width:u,flexShrink:0}}),z.jsx("div",{style:{flex:1,overflow:"hidden"},children:I})]})}return p});return z.jsx("div",{className:t,style:{position:"sticky",top:0,zIndex:20,display:"flex",flexDirection:"column",backgroundColor:(e==null?void 0:e.header.bg)??"#F9FAFB",borderTop:`1px solid ${(e==null?void 0:e.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(e==null?void 0:e.header.border)??"#E5E7EB"}`,...r},children:E})}xt.displayName="TimelineHeaders";var At={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(Wt,function(){var t="week",n="year";return function(r,d,l){var c=d.prototype;c.week=function(u){if(u===void 0&&(u=null),u!==null)return this.add(7*(u-this.week()),"day");var b=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var E=l(this).startOf(n).add(1,n).date(b),p=l(this).endOf(t);if(E.isBefore(p))return 1}var y=l(this).startOf(n).date(b).startOf(t).subtract(1,"millisecond"),k=this.diff(y,t,!0);return k<0?l(this).startOf("week").week():Math.ceil(k)},c.weeks=function(u){return u===void 0&&(u=null),this.week(u)}}})})(At);var wi=At.exports;const Hi=Xt(wi);he.extend(Hi);const Ri={year:30,month:30,week:20,day:15,hour:30};function Yt({unit:i,visibleTimeStart:e=0,visibleTimeEnd:t=0,canvasWidth:n=0,theme:r,height:d=28,className:l,labelFormat:c,onIntervalClick:u,minCellWidth:b,onZoomToInterval:E}){const p=h.useMemo(()=>{if(!e||!t||!n)return[];const k=t-e,H=b??Ri[i];if(H>0){const M=he(e).startOf(i);if((M.add(1,i).valueOf()-M.valueOf())/k*n<H)return[]}const I=[];let X=he(e).startOf(i).subtract(1,i);const $=he(t).add(2,i).valueOf();for(;X.valueOf()<$;){const M=X.add(1,i),_=X.valueOf(),j=M.valueOf(),A=(_-e)/k*n,V=(j-_)/k*n,ne=Ii(X,M,i,c);I.push({start:_,end:j,label:ne,left:A,width:V}),X=M}return I},[e,t,n,i,c,b]),y=h.useCallback((k,H)=>{u?u(k,H):E&&E(k,H)},[u,E]);return p.length===0?null:z.jsx("div",{style:{display:"flex",position:"relative",height:d,overflow:"hidden"},children:p.map(k=>z.jsx("div",{className:l,onClick:()=>y(k.start,k.end),style:{position:"absolute",left:k.left,width:k.width,height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRight:`1px solid ${(r==null?void 0:r.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(r==null?void 0:r.header.border)??"#E5E7EB"}`,fontSize:12,color:(r==null?void 0:r.header.text)??"#6c737f",backgroundColor:(r==null?void 0:r.header.bg)??"#F9FAFB",overflow:"hidden",whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",padding:"0 4px",boxSizing:"border-box"},children:z.jsx("span",{children:k.label})},k.start))})}Yt.displayName="DateHeader";function Ii(i,e,t,n,r){return typeof n=="function"?n(i.toDate(),e.toDate(),t):typeof n=="string"?i.format(n):Pi(i,t)}function Pi(i,e){switch(e){case"year":return i.format("YYYY");case"month":return i.format("MM");case"week":return`${i.week()}`;case"day":return i.format("D");case"hour":return i.format("HH:mm")}}function Nt({width:i,children:e,style:t}){const n=()=>({style:{width:i,...t}});return e?z.jsx(z.Fragment,{children:e({getRootProps:n})}):z.jsx("div",{style:{width:i}})}Nt.displayName="SidebarHeader";function $t({children:i}){return z.jsx(z.Fragment,{children:i})}$t.displayName="CustomHeader";exports.CanvasTimeline=Ci;exports.CustomHeader=$t;exports.CustomMarker=Lt;exports.DEFAULT_THEME=pe;exports.DateHeader=Yt;exports.HierarchyEngine=Ot;exports.SidebarHeader=Nt;exports.TimelineHeaders=xt;exports.TodayMarker=jt;
|
|
2
2
|
//# sourceMappingURL=canvas-timeline.cjs.js.map
|