@taskctrl/canvas-timeline 0.8.0 → 0.8.1

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),f=require("react"),Hi=require("react-dom"),$e=require("dayjs"),Te={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 ht{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,"groupHeights",{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}),Object.defineProperty(this,"groupYOffsets",{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.groupHeights=e.groupHeights??null,this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration,this.groupYOffsets=[],this.recomputeGroupYOffsets()}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),e.groupHeights!==void 0&&(this.groupHeights=e.groupHeights??null),this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration,this.recomputeGroupYOffsets()}recomputeGroupYOffsets(){var t;const e=new Array(this.groupCount+1);e[0]=0;for(let n=0;n<this.groupCount;n++){const s=((t=this.groupHeights)==null?void 0:t[n])??this.lineHeight;e[n+1]=e[n]+s}this.groupYOffsets=e}timeToX(e){return(e-this.visibleTimeStart)*this.pixelsPerMs}xToTime(e){return this.visibleTimeStart+e/this.pixelsPerMs}yToGroupIndex(e){if(this.groupCount===0)return 0;const t=e+this.scrollTop;if(t<=0)return 0;if(t>=this.groupYOffsets[this.groupCount])return this.groupCount-1;let n=0,s=this.groupCount-1;for(;n<s;){const d=n+s>>>1;this.groupYOffsets[d+1]>t?s=d:n=d+1}return n}groupIndexToY(e){return e<0?-this.scrollTop:e>=this.groupCount?(this.groupYOffsets[this.groupCount]??0)-this.scrollTop:this.groupYOffsets[e]-this.scrollTop}groupIndexToHeight(e){var t;return e<0||e>=this.groupCount?this.lineHeight:((t=this.groupHeights)==null?void 0:t[e])??this.lineHeight}getBufferBounds(){const e=this.visibleDuration*1.5;return{bufferStart:this.visibleTimeStart-e,bufferEnd:this.visibleTimeEnd+e}}getVisibleGroupRange(){if(this.groupCount===0)return{firstVisible:0,lastVisible:-1};const e=this.yToGroupIndex(0),t=this.yToGroupIndex(this.canvasHeight);return{firstVisible:e,lastVisible:t}}isScrollInBuffer(e){const t=this.visibleDuration*1.5*this.pixelsPerMs;return Math.abs(e)<t}getTotalHeight(){return this.groupYOffsets[this.groupCount]??0}}class Ri{constructor(){Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:null})}buildFromItems(e,t,n){const s=e.map(d=>({item:d,start:t(d),end:n(d)}));this.root=this.buildNode(s)}buildNode(e){if(e.length===0)return null;let t=1/0,n=-1/0;for(const l of e)l.start<t&&(t=l.start),l.end>n&&(n=l.end);const s=(t+n)/2,d=[],o=[],c=[];for(const l of e)l.end<s?d.push(l):l.start>s?o.push(l):c.push(l);return{center:s,left:this.buildNode(d),right:this.buildNode(o),overlapping:c}}query(e,t){const n=[];return this.queryNode(this.root,e,t,n),n}queryNode(e,t,n,s){if(e!==null){for(const d of e.overlapping)d.start<=n&&d.end>=t&&s.push(d.item);t<=e.center&&e.left!==null&&this.queryNode(e.left,t,n,s),n>=e.center&&e.right!==null&&this.queryNode(e.right,t,n,s)}}}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 s=this.lineHeight*this.itemHeightRatio,d=s*.6;if(!t){for(const c of e){const l=(n==null?void 0:n.isParent(c.id))??!1;this.layoutCache.set(c.id,{stackLevel:0,itemHeight:l?d:s}),this.groupMaxStack.set(c.group,0)}return this.layoutCache}const o=new Map;for(const c of e){let l=o.get(c.group);l||(l=[],o.set(c.group,l)),l.push(c)}for(const[c,l]of o)n?this.computeHierarchyLayout(l,n,s,d,c):this.computeFlatLayout(l,s,c);return this.layoutCache}computeFlatLayout(e,t,n){e.sort((o,c)=>{const l=o.start_time-c.start_time;return l!==0?l:c.end_time-c.start_time-(o.end_time-o.start_time)});const s=[];let d=0;for(const o of e){let c=-1;for(let l=0;l<s.length;l++)if(s[l]<=o.start_time){c=l;break}c===-1?(c=s.length,s.push(o.end_time)):s[c]=o.end_time,c>d&&(d=c),this.layoutCache.set(o.id,{stackLevel:c,itemHeight:t})}this.groupMaxStack.set(n,d)}computeHierarchyLayout(e,t,n,s,d){const o=[],c=[];for(const v of e)t.isParent(v.id)?c.push(v):o.push(v);o.sort((v,h)=>{const C=v.start_time-h.start_time;return C!==0?C:h.end_time-h.start_time-(v.end_time-v.start_time)});const l=[];let y=0;for(const v of o){let h=-1;for(let C=0;C<l.length;C++)if(l[C]<=v.start_time){h=C;break}h===-1?(h=l.length,l.push(v.end_time)):l[h]=v.end_time,h>y&&(y=h),this.layoutCache.set(v.id,{stackLevel:h,itemHeight:n})}c.sort((v,h)=>t.getNestingDepth(h.id)-t.getNestingDepth(v.id));let R=o.length>0?y+1:0;for(const v of c)this.layoutCache.set(v.id,{stackLevel:R,itemHeight:s}),R>y&&(y=R),R++;this.groupMaxStack.set(d,y)}getLayout(e){return this.layoutCache.get(e)}getGroupHeight(e){return((this.groupMaxStack.get(e)??0)+1)*this.lineHeight}}class Vt{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 s=t;for(;s!==void 0;){if(n.has(s)){const d=this.childToParent.get(t);this.childToParent.delete(t);const o=this.parentToChildren.get(d);if(o){const c=o.indexOf(t);c!==-1&&o.splice(c,1),o.length===0&&this.parentToChildren.delete(d)}break}n.add(s),s=this.childToParent.get(s)}}}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 s=n.pop();t.push(s);const d=this.parentToChildren.get(s);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,s=t.end_time;const d=this.getDescendants(e);for(const o of d){const c=this.itemMap.get(o);c&&(c.start_time<n&&(n=c.start_time),c.end_time>s&&(s=c.end_time))}return{start:n,end:s}}getNestingDepth(e){const t=this.depthCache.get(e);if(t!==void 0)return t;let n=0,s=this.childToParent.get(e);for(;s!==void 0;)n++,s=this.childToParent.get(s);return this.depthCache.set(e,n),n}getMoveDelta(e,t){const n=this.itemMap.get(e);if(!n)return[];const s=t-n.start_time;return this.getDescendants(e).map(o=>{const c=this.itemMap.get(o);return{itemId:o,newStart:c.start_time+s}})}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 s=1/0;for(const d of n){const o=this.itemMap.get(d);o&&o.start_time<s&&(s=o.start_time)}return{min:-1/0,max:s}}else{let s=-1/0;for(const d of n){const o=this.itemMap.get(d);o&&o.end_time>s&&(s=o.end_time)}return{min:s,max:1/0}}}}function Ii(i,e,t,n,s,d){const{x:o,y:c,width:l,height:y}=t,R=d.primary;i.globalAlpha=.15,i.fillStyle=R,i.fillRect(o,c,l,y),i.globalAlpha=1,i.strokeStyle=R,i.lineWidth=1.5,i.strokeRect(o,c,l,y);const v=Math.min(y*.5,6),h=c+y/2;i.fillStyle=R,i.beginPath(),i.moveTo(o,h),i.lineTo(o+v,h-v),i.lineTo(o+v*2,h),i.lineTo(o+v,h+v),i.closePath(),i.fill(),i.beginPath(),i.moveTo(o+l,h),i.lineTo(o+l-v,h-v),i.lineTo(o+l-v*2,h),i.lineTo(o+l-v,h+v),i.closePath(),i.fill();const C=e.title;if(C&&l>30){i.fillStyle=d.item.text,i.font='500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',i.textBaseline="middle";const M=i.measureText(C).width,m=l-v*4-4;if(m>20){const H=M>m?C.slice(0,Math.floor(C.length*m/M))+"...":C;i.fillText(H,o+l/2-Math.min(M,m)/2,h)}}n.selected&&(i.strokeStyle=d.item.selectedRing,i.lineWidth=2,i.strokeRect(o-1,c-1,l+2,y+2))}function ze(i,e,t,n,s,d){const o=t.xToTime(i),c=new Map;for(let v=0;v<d.length;v++)c.set(d[v].id,v);const l=n.query(o,o);let y=null,R=-1/0;for(const v of l){const h=c.get(v.group);if(h===void 0)continue;const C=s.getLayout(v.id);if(!C)continue;const M=t.timeToX(v.start_time),m=t.timeToX(v.end_time)-M;if(i<M||i>M+m)continue;const X=t.groupIndexToY(h)+C.stackLevel*t.lineHeight+(t.lineHeight-C.itemHeight)/2,x=C.itemHeight;e<X||e>X+x||X>R&&(R=X,y=v)}return y}function mt(i,e,t){const n=e.yToGroupIndex(i);return t[n]??null}function xt(i,e,t,n=6){const s=t.timeToX(e.start_time),d=t.timeToX(e.end_time);return i-s<=n?"left":d-i<=n?"right":"body"}function Bt(i,e){return i.canResize??e}function jt(i,e){return i.canMove??e}function gt(i,e,t){const n=window.devicePixelRatio||1,s=Math.round(e*n),d=Math.round(t*n);(i.width!==s||i.height!==d)&&(i.width=s,i.height=d,i.style.width=`${e}px`,i.style.height=`${t}px`);const o=i.getContext("2d");return o.setTransform(n,0,0,n,0,0),o}function pt(i,e){const t=window.devicePixelRatio||1;i.clearRect(0,0,e.width/t,e.height/t)}class Oi{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)}))}}var tt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function it(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var qt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="minute",n=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(d,o,c){var l=o.prototype;c.utc=function(m){var H={date:m,utc:!0,args:arguments};return new o(H)},l.utc=function(m){var H=c(this.toDate(),{locale:this.$L,utc:!0});return m?H.add(this.utcOffset(),t):H},l.local=function(){return c(this.toDate(),{locale:this.$L,utc:!1})};var y=l.parse;l.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),y.call(this,m)};var R=l.init;l.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else R.call(this)};var v=l.utcOffset;l.utcOffset=function(m,H){var X=this.$utils().u;if(X(m))return this.$u?0:X(this.$offset)?v.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var F=E.match(n);if(!F)return null;var B=(""+F[0]).match(s)||["-",0,0],I=B[0],A=60*+B[1]+ +B[2];return A===0?0:I==="+"?A:-A}(m),m===null))return this;var x=Math.abs(m)<=16?60*m:m;if(x===0)return this.utc(H);var T=this.clone();if(H)return T.$offset=x,T.$u=!1,T;var D=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(T=this.local().add(x+D,t)).$offset=x,T.$x.$localOffset=D,T};var h=l.format;l.format=function(m){var H=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,H)},l.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var C=l.toDate;l.toDate=function(m){return m==="s"&&this.$offset?c(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():C.call(this)};var M=l.diff;l.diff=function(m,H,X){if(m&&this.$u===m.$u)return M.call(this,m,H,X);var x=this.local(),T=c(m).local();return M.call(x,T,H,X)}}})})(qt);var Pi=qt.exports;const Xi=it(Pi);var Kt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},n={};return function(s,d,o){var c,l=function(h,C,M){M===void 0&&(M={});var m=new Date(h),H=function(X,x){x===void 0&&(x={});var T=x.timeZoneName||"short",D=X+"|"+T,E=n[D];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:X,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:T}),n[D]=E),E}(C,M);return H.formatToParts(m)},y=function(h,C){for(var M=l(h,C),m=[],H=0;H<M.length;H+=1){var X=M[H],x=X.type,T=X.value,D=t[x];D>=0&&(m[D]=parseInt(T,10))}var E=m[3],F=E===24?0:E,B=m[0]+"-"+m[1]+"-"+m[2]+" "+F+":"+m[4]+":"+m[5]+":000",I=+h;return(o.utc(B).valueOf()-(I-=I%1e3))/6e4},R=d.prototype;R.tz=function(h,C){h===void 0&&(h=c);var M,m=this.utcOffset(),H=this.toDate(),X=H.toLocaleString("en-US",{timeZone:h}),x=Math.round((H-new Date(X))/1e3/60),T=15*-Math.round(H.getTimezoneOffset()/15)-x;if(!Number(T))M=this.utcOffset(0,C);else if(M=o(X,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(T,!0),C){var D=M.utcOffset();M=M.add(m-D,"minute")}return M.$x.$timezone=h,M},R.offsetName=function(h){var C=this.$x.$timezone||o.tz.guess(),M=l(this.valueOf(),C,{timeZoneName:h}).find(function(m){return m.type.toLowerCase()==="timezonename"});return M&&M.value};var v=R.startOf;R.startOf=function(h,C){if(!this.$x||!this.$x.$timezone)return v.call(this,h,C);var M=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return v.call(M,h,C).tz(this.$x.$timezone,!0)},o.tz=function(h,C,M){var m=M&&C,H=M||C||c,X=y(+o(),H);if(typeof h!="string")return o(h).tz(H);var x=function(F,B,I){var A=F-60*B*1e3,_=y(A,I);if(B===_)return[A,B];var se=y(A-=60*(_-B)*1e3,I);return _===se?[A,_]:[F-60*Math.min(_,se)*1e3,Math.max(_,se)]}(o.utc(h,m).valueOf(),X,H),T=x[0],D=x[1],E=o(T).utcOffset(D);return E.$x.$timezone=H,E},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(h){c=h}}})})(Kt);var $i=Kt.exports;const Fi=it($i);$e.extend(Xi);$e.extend(Fi);function pe(i,e){return e?$e(i).tz(e):$e(i)}class _i{draw(e,t,n,s,d,o,c,l){const{firstVisible:y,lastVisible:R}=t.getVisibleGroupRange();for(let T=y;T<=R;T++){const D=t.groupIndexToY(T),E=t.groupIndexToHeight(T),F=n[T];if(!F)continue;let B;const I=o==null?void 0:o(F);I!=null&&I.backgroundColor?B=I.backgroundColor:B=T%2===0?"#FFFFFF":s.grid.rowAlt,e.fillStyle=B,e.fillRect(0,D,t.canvasWidth,E),e.strokeStyle=(I==null?void 0:I.borderBottomColor)??s.grid.line,e.lineWidth=.5,e.beginPath(),e.moveTo(0,D+E),e.lineTo(t.canvasWidth,D+E),e.stroke()}if(c&&c.length>0)for(const T of c){const D=t.timeToX(T.start),E=t.timeToX(T.end);if(E<0||D>t.canvasWidth)continue;const F=Math.max(0,D),B=Math.min(t.canvasWidth,E)-F,I=T.opacity??.12,A=parseInt(T.color.slice(1,3),16),_=parseInt(T.color.slice(3,5),16),se=parseInt(T.color.slice(5,7),16);e.fillStyle=`rgb(${Math.round(A*I+255*(1-I))},${Math.round(_*I+255*(1-I))},${Math.round(se*I+255*(1-I))})`,e.fillRect(F,0,B,t.canvasHeight)}const v=t.visibleTimeStart,h=t.visibleTimeEnd,m=864e5/(h-v)*t.canvasWidth;let H="day";m<2?H="month":m<8&&(H="week");{let T=pe(v,l).startOf("day");const D=pe(h,l).endOf("day");let E=null,F=1,B=0;const I=[],A=_=>{E!==null&&(e.fillStyle=E,F!==1&&(e.globalAlpha=F),e.fillRect(B,0,_-B,t.canvasHeight),F!==1&&(e.globalAlpha=1),E=null,F=1)};for(;T.isBefore(D);){const _=t.timeToX(T.valueOf()),se=T.toDate(),J=d==null?void 0:d(se);let te=null,me=1;if(J!=null&&J.backgroundColor)te=J.backgroundColor,me=J.opacity??1;else{const ve=T.day();(ve===0||ve===6)&&(te=s.grid.weekend)}J!=null&&J.borderColor&&I.push({x:_,color:J.borderColor}),te===E&&me===F||(A(_),te!==null&&(E=te,F=me,B=_)),T=T.add(1,"day")}E!==null&&A(t.timeToX(T.valueOf()));for(const _ of I)e.strokeStyle=_.color,e.lineWidth=.5,e.beginPath(),e.moveTo(_.x,0),e.lineTo(_.x,t.canvasHeight),e.stroke()}let X=pe(v,l).startOf(H);const x=pe(h,l).add(1,H);for(e.strokeStyle=s.grid.line,e.lineWidth=.5,e.beginPath();X.isBefore(x);){const T=t.timeToX(X.valueOf());e.moveTo(T,0),e.lineTo(T,t.canvasHeight),X=X.add(1,H)}if(e.stroke(),c&&c.length>0)for(const T of c){const D=t.timeToX(T.start),E=t.timeToX(T.end);if(!(E<0||D>t.canvasWidth)&&(e.strokeStyle=T.color,e.globalAlpha=.4,e.lineWidth=1,e.beginPath(),D>=0&&D<=t.canvasWidth&&(e.moveTo(D,0),e.lineTo(D,t.canvasHeight)),E>=0&&E<=t.canvasWidth&&(e.moveTo(E,0),e.lineTo(E,t.canvasHeight)),e.stroke(),e.globalAlpha=1,T.label)){const F=Math.max(0,D),B=Math.min(t.canvasWidth,E)-F;e.save(),e.font='600 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const I=e.measureText(T.label).width,A=6,_=I+A*2,se=18,J=F+(B-_)/2,te=4;e.fillStyle=T.color,e.globalAlpha=.9,e.beginPath(),e.roundRect(J,te,_,se,3),e.fill(),e.globalAlpha=1,e.fillStyle="#FFFFFF",e.textBaseline="middle",e.fillText(T.label,J+A,te+se/2),e.restore()}}}}const Lt='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function Jt(i,e){return{roundRect(t,n,s,d,o=3){i.beginPath(),i.roundRect(t,n,s,d,o),i.fill()},fillText(t,n,s,d){if(i.font=Lt,d!==void 0&&i.measureText(t).width>d){let o=0,c=t.length;for(;o<c;){const l=Math.ceil((o+c)/2),y=t.slice(0,l)+"...";i.measureText(y).width<=d?o=l:c=l-1}i.fillText(t.slice(0,o)+"...",n,s)}else i.fillText(t,n,s)},gradient(t,n,s,d){const o=i.createLinearGradient(t,0,t+n,0);return o.addColorStop(0,s),o.addColorStop(.5,s),o.addColorStop(.5,d),o.addColorStop(1,d),o},leftBar(t,n=3){e&&(i.save(),i.fillStyle=t,i.fillRect(e.x,e.y,n,e.height),i.restore())},icon(t,n,s,d=14){i.save();const o=d/2;if(t==="check"){i.fillStyle="#31c48d",i.beginPath(),i.arc(n+o,s+o,o,0,Math.PI*2),i.fill(),i.strokeStyle="#ffffff",i.lineWidth=d*.12,i.beginPath();const c=n+o,l=s+o;i.moveTo(c-o*.45,l),i.lineTo(c-o*.1,l+o*.42),i.lineTo(c+o*.45,l-o*.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+o,s),i.lineTo(n+d,s+d),i.lineTo(n,s+d),i.closePath(),i.fill(),i.fillStyle="#ffffff";const l=d*.12,y=n+o-l/2;i.fillRect(y,s+d*.35,l,d*.35),i.beginPath(),i.arc(n+o,s+d*.82,l*.7,0,Math.PI*2),i.fill()}i.restore()},badge(t,n,s,d){i.save(),i.font=Lt;const c=i.measureText(t).width,l=8,R=12+3*2,v=c+l*2,h=R/2;i.fillStyle=d,i.beginPath(),i.roundRect(n,s,v,R,h),i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(t,n+v/2,s+R/2),i.restore()}}}class Yi{draw(e,t,n,s,d,o,c,l,y,R,v,h,C,M){const m=(t.visibleTimeEnd-t.visibleTimeStart)*.1,H=t.visibleTimeStart-m,X=t.visibleTimeEnd+m,x=d.query(H,X),T=new Map;for(let I=0;I<n.length;I++)T.set(n[I].id,I);const D=new Set(R),E=new Map,F=-t.lineHeight,B=t.canvasHeight+t.lineHeight;for(const I of x){const A=T.get(I.group);if(A===void 0)continue;const _=o.getLayout(I.id);if(!_)continue;const J=t.groupIndexToY(A)+_.stackLevel*t.lineHeight+(t.lineHeight-_.itemHeight)/2,te=_.itemHeight;if(J+te<F||J>B)continue;const me=t.timeToX(I.start_time),ve=t.timeToX(I.end_time)-me,be={x:me,y:J,width:ve,height:te};E.set(I.id,be);const De={selected:D.has(I.id),hovered:v===I.id,dragging:!1,filtered:I.filtered!==!1};e.save();const Ae=Jt(e,be);let Ce;C&&(M!=null&&M.isParent(I.id))?Ce=C:l&&(I.type==="control_area_group"||I.type==="construction_train")?Ce=l:Ce=c,Ce(e,I,be,De,Ae),e.restore()}if(h&&h.length>0){const I=new Set;for(const A of h)E.has(A.fromItemId)||I.add(A.fromItemId),E.has(A.toItemId)||I.add(A.toItemId);if(I.size>0){const A=new Map;for(const _ of s)I.has(_.id)&&A.set(_.id,_);for(const[_,se]of A){const J=T.get(se.group);if(J===void 0)continue;const te=o.getLayout(_);if(!te)continue;const ve=t.groupIndexToY(J)+te.stackLevel*t.lineHeight+(t.lineHeight-te.itemHeight)/2,be=t.timeToX(se.start_time),De=t.timeToX(se.end_time)-be;E.set(_,{x:be,y:ve,width:De,height:te.itemHeight})}}this.drawDependencies(e,h,E,v,y)}}drawDependencies(e,t,n,s,d){for(const o of t){const c=n.get(o.fromItemId),l=n.get(o.toItemId);if(!c||!l)continue;const y=s===o.fromItemId||s===o.toItemId;e.strokeStyle=y?d.primary:o.color??"#94A3B8",e.lineWidth=y?2:1.5,e.setLineDash([]);const R=c.x+c.width,v=c.y+c.height/2,h=l.x,C=l.y+l.height/2,M=Math.abs(h-R),m=Math.max(M*.4,30);e.beginPath(),e.moveTo(R,v),e.bezierCurveTo(R+m,v,h-m,C,h,C),e.stroke();const H=6;e.fillStyle=e.strokeStyle,e.beginPath(),e.moveTo(h,C),e.lineTo(h-H,C-H/2),e.lineTo(h-H,C+H/2),e.closePath(),e.fill()}}}class Wi{draw(e,t,n,s){const{cursorX:d,snapX:o,markers:c,interaction:l}=s;if(c)for(const y of c){const R=t.timeToX(y.date);if(e.fillStyle=y.color,e.fillRect(R-y.width/2,0,y.width,t.canvasHeight),y.label){e.save(),e.font='500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const v=e.measureText(y.label).width,h=8,C=200,M=Math.min(v+h*2,C),m=20,H=R-M/2,X=4;e.fillStyle=y.color,e.beginPath(),e.roundRect(H,X,M,m,3),e.fill(),e.fillStyle="#FFFFFF",e.textBaseline="middle";const x=C-h*2,T=v>x?y.label.slice(0,Math.floor(y.label.length*x/v))+"…":y.label;e.fillText(T,H+h,X+m/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()),o!=null&&(e.strokeStyle=n.primary,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(o,0),e.lineTo(o,t.canvasHeight),e.stroke(),e.setLineDash([])),l){l.groupChanged&&l.targetGroupY!==void 0&&(e.fillStyle="rgba(59, 130, 246, 0.08)",e.fillRect(0,l.targetGroupY,t.canvasWidth,t.lineHeight)),e.save(),e.globalAlpha=.5;const y=Jt(e,l.bounds);l.renderer(e,l.item,l.bounds,{selected:!1,hovered:!1,dragging:!0,filtered:!0},y),e.restore()}}}const zt=120;function xi(i){let e=i.deltaY||i.deltaX;return i.deltaMode===1?e*=15:i.deltaMode===2&&(e*=800),Math.max(-zt,Math.min(zt,e))}class Bi{constructor(e,t,n,s,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=s,this.maxZoom=d}updateBounds(e,t){this.visibleTimeStart=e,this.visibleTimeEnd=t}handleWheelZoom(e,t){const n=xi(e),s=e.ctrlKey?10:e.metaKey?3:1,d=n>0?1+s*n/500:1/(1+s*-n/500),o=this.visibleTimeEnd-this.visibleTimeStart;let c=Math.round(o*d);c=Math.max(this.minZoom,Math.min(this.maxZoom,c));const l=Math.round(this.visibleTimeStart+(o-c)*t),y=l+c;this.onZoom(l,y)}}const ji=4;class Li{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,s){this.state={item:e,mode:t,startX:n,startY:s,currentX:n,currentY:s,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)>=ji&&(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,s=Math.round(n/this.dragSnap)*this.dragSnap,d=this.state.currentGroup;return this.state=null,this.activated=!1,{newStartTime:s,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,o=Math.round(d/this.dragSnap)*this.dragSnap;return this.state=null,this.activated=!1,{newTime:o,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 vt(i,e,t){const n=[];for(const s of i)s.id!==e&&(n.push(t(s.start_time)),n.push(t(s.end_time)));return n}function et(i,e,t,n,s){if(e.length===0)return null;let d=e[0],o=Math.abs(i-d);for(let c=1;c<e.length;c++){const l=Math.abs(i-e[c]);l<o&&(o=l,d=e[c])}return o<=t?d:null}var Qt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="day";return function(n,s,d){var o=function(y){return y.add(4-y.isoWeekday(),t)},c=s.prototype;c.isoWeekYear=function(){return o(this).year()},c.isoWeek=function(y){if(!this.$utils().u(y))return this.add(7*(y-this.isoWeek()),t);var R,v,h,C,M=o(this),m=(R=this.isoWeekYear(),v=this.$u,h=(v?d.utc:d)().year(R).startOf("year"),C=4-h.isoWeekday(),h.isoWeekday()>4&&(C+=7),h.add(C,t));return M.diff(m,"week")+1},c.isoWeekday=function(y){return this.$utils().u(y)?this.day()||7:this.day(this.day()%7?y:y-7)};var l=c.startOf;c.startOf=function(y,R){var v=this.$utils(),h=!!v.u(R)||R;return v.p(y)==="isoweek"?h?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):l.bind(this)(y,R)}}})})(Qt);var zi=Qt.exports;const Ai=it(zi),At=200;function Gt({groups:i,width:e,lineHeight:t,groupHeights:n,scrollTop:s,canvasHeight:d,theme:o,groupRenderer:c,onScroll:l}){var T;const y=f.useRef(null),R=f.useRef(!1),v=f.useMemo(()=>{const D=new Array(i.length+1);D[0]=0;for(let E=0;E<i.length;E++)D[E+1]=D[E]+((n==null?void 0:n[E])??t);return D},[i.length,n,t]),h=v[i.length]??0,C=d,M=f.useCallback(D=>{if(i.length===0||D<=0)return 0;if(D>=h)return i.length-1;let E=0,F=i.length-1;for(;E<F;){const B=E+F>>>1;v[B+1]>D?F=B:E=B+1}return E},[i.length,v,h]),m=M(s-At),H=M(s+d+At),X=f.useCallback(D=>{R.current||l(D.currentTarget.scrollTop)},[l]);f.useEffect(()=>{y.current&&(R.current=!0,y.current.scrollTop=s,requestAnimationFrame(()=>{R.current=!1}))},[s]);const x=[];for(let D=m;D<=H;D++){const E=i[D];if(!E)continue;const F=v[D],B=v[D+1]-F;x.push(q.jsx("div",{style:{position:"absolute",top:F,height:B,width:"100%",overflow:"hidden",display:"flex",alignItems:"stretch",borderBottom:`1px solid ${((T=o.grid)==null?void 0:T.line)??"#E5E5E5"}`,boxSizing:"border-box"},children:c(E)},E.id))}return q.jsx("div",{ref:y,onScroll:X,style:{width:e,height:C,overflowY:h>d?"auto":"hidden",overflowX:"hidden",position:"relative",borderRight:`1px solid ${o.sidebar.border}`,backgroundColor:o.sidebar.bg},children:q.jsx("div",{style:{height:h,position:"relative"},children:x})})}function ei(i){return null}ei.displayName="TodayMarker";function Nt(i){return{date:Math.floor(Date.now()/6e4)*6e4,color:i.color??"#FD7171",width:i.width??6,label:i.label}}function Gi(i){return i.interval??1e4}function ti(i){return null}ti.displayName="CustomMarker";function Zt(i){return{date:i.date,color:i.color??"#3B82F6",width:i.width??4,label:i.label}}$e.extend(Ai);function Ni(i){return i?{...Te,...i,status:{...Te.status,...i.status},grid:{...Te.grid,...i.grid},item:{...Te.item,...i.item},marker:{...Te.marker,...i.marker},sidebar:{...Te.sidebar,...i.sidebar},header:{...Te.header,...i.header}}:Te}const Ut=32,Zi=f.memo(f.forwardRef(function(e,t){const{groups:n,items:s,defaultTimeStart:d,defaultTimeEnd:o,sidebarWidth:c,lineHeight:l,itemHeightRatio:y,stackItems:R,canMove:v,canChangeGroup:h,canResize:C,dragSnap:M,minZoom:m,maxZoom:H,theme:X,dayStyle:x,rowStyle:T,showCursorLine:D,itemRenderer:E,groupRenderer:F,sidebarGroupRenderer:B,dependencies:I,highlights:A,onItemClick:_,onItemDoubleClick:se,onItemContextMenu:J,onItemMove:te,onItemResize:me,moveResizeValidator:ve,onItemHover:be,onCanvasDoubleClick:De,onCanvasContextMenu:Ae,onTimeChange:Ce,onZoom:bt,selected:yt=[],rightSidebarWidth:nt,rightSidebarGroupRenderer:Tt,onReady:Ge,maxHeight:Fe,timezone:Ne,devBadge:ai,children:Me}=e,ye=f.useMemo(()=>Ni(X),[X]),Mt=f.useCallback((r,a)=>{for(let g=0;g<a.length;g++)if(a[g].id===r)return g;return 0},[]),li=yt.join(","),rt=f.useMemo(()=>yt,[li]),St=f.useRef(null),kt=f.useRef(null),Ct=f.useRef(null),_e=f.useRef(null),Et=f.useRef(null),wt=f.useRef(null),[ui,ci]=f.useState(800),[di,fi]=f.useState(null);f.useEffect(()=>{const r=Et.current;if(!r)return;const a=new ResizeObserver(g=>{const p=g[0];p&&ci(p.contentRect.width)});return a.observe(r),()=>a.disconnect()},[]),f.useEffect(()=>{const r=wt.current;if(!r||!Fe)return;const a=new ResizeObserver(g=>{const p=g[0];p&&fi(p.contentRect.height)});return a.observe(r),()=>a.disconnect()},[Fe]);const Se=Math.max(0,ui-c-(nt??0)),Ee=f.useMemo(()=>{const r=new Vt;return r.rebuild(s),r},[s]),st=f.useMemo(()=>{const r=new Ri;return r.buildFromItems(s,a=>Ee.getEffectiveSpan(a.id).start,a=>Ee.getEffectiveSpan(a.id).end),r},[s,Ee]),Ye=f.useMemo(()=>{const r=new Di(l,y);return r.computeLayout(s,R,Ee),r},[s,l,y,R,Ee]),we=f.useMemo(()=>n.map(r=>Ye.getGroupHeight(r.id)),[n,Ye]),Ze=f.useMemo(()=>we.reduce((r,a)=>r+a,0),[we]),Ht=typeof Fe=="number"?Fe:di,ge=Ht?Math.min(Ze,Ht):Ze,j=f.useRef(new ht({visibleTimeStart:e.visibleTimeStart??d,visibleTimeEnd:e.visibleTimeEnd??o,canvasWidth:Se,canvasHeight:ge,sidebarWidth:c,lineHeight:l,groupCount:n.length,buffer:e.buffer??3,scrollTop:0,groupHeights:we})),ot=f.useRef(null),We=f.useRef(void 0),he=f.useRef(null),He=f.useRef(!1),Rt=4,[Dt,hi]=f.useState(e.visibleTimeStart??d),[It,mi]=f.useState(e.visibleTimeEnd??o),[Ot,Ue]=f.useState(0),xe=f.useRef(null),Ie=f.useCallback(()=>{const r=j.current;hi(r.visibleTimeStart),mi(r.visibleTimeEnd),Ue(r.scrollTop),xe.current=null},[]),at=f.useCallback(()=>{xe.current===null&&(xe.current=setTimeout(Ie,Ut))},[Ie]);f.useEffect(()=>()=>{xe.current!==null&&clearTimeout(xe.current)},[]);const Pt=f.useMemo(()=>e.summaryRenderer?e.summaryRenderer:(r,a,g,p,u)=>{Ii(r,a,g,p,u,ye)},[e.summaryRenderer,ye]),Oe=f.useMemo(()=>new _i,[]),Pe=f.useMemo(()=>new Yi,[]),Xe=f.useMemo(()=>new Wi,[]),ie=f.useMemo(()=>new Li(M),[M]),Ve=f.useMemo(()=>{const r=[];return f.Children.forEach(Me,a=>{var p;if(!f.isValidElement(a))return;const g=(p=a.type)==null?void 0:p.displayName;g==="TodayMarker"?r.push(Nt(a.props)):g==="CustomMarker"&&r.push(Zt(a.props))}),r},[Me]),qe=f.useMemo(()=>Ve.map(r=>`${r.date}|${r.color}|${r.width}|${r.label??""}`).join(";"),[Ve]),Be=f.useRef(Ve);Be.current=Ve;const lt=f.useMemo(()=>{let r=0;return f.Children.forEach(Me,a=>{var p;if(!f.isValidElement(a))return;((p=a.type)==null?void 0:p.displayName)==="TodayMarker"&&(r=Gi(a.props))}),r},[Me]),z=f.useRef({groups:n,items:s,intervalTree:st,layoutEngine:Ye,itemRenderer:E,groupRenderer:F,theme:ye,selected:rt,dependencies:I,highlights:A,dayStyle:x,rowStyle:T,showCursorLine:D,canvasWidth:Se,canvasHeight:ge,lineHeight:l,itemHeightRatio:y,onTimeChange:Ce,onZoom:bt,onItemHover:be,onItemClick:_,onItemDoubleClick:se,onItemContextMenu:J,onItemMove:te,onItemResize:me,onCanvasDoubleClick:De,onCanvasContextMenu:Ae,canMove:v,canResize:C,canChangeGroup:h,dragSnap:M,sidebarWidth:c,moveResizeValidator:ve,summaryRenderer:Pt,hierarchyEngine:Ee,timezone:Ne});z.current={groups:n,items:s,intervalTree:st,layoutEngine:Ye,itemRenderer:E,groupRenderer:F,theme:ye,selected:rt,dependencies:I,highlights:A,dayStyle:x,rowStyle:T,showCursorLine:D,canvasWidth:Se,canvasHeight:ge,lineHeight:l,itemHeightRatio:y,onTimeChange:Ce,onZoom:bt,onItemHover:be,onItemClick:_,onItemDoubleClick:se,onItemContextMenu:J,onItemMove:te,onItemResize:me,onCanvasDoubleClick:De,onCanvasContextMenu:Ae,canMove:v,canResize:C,canChangeGroup:h,dragSnap:M,sidebarWidth:c,moveResizeValidator:ve,summaryRenderer:Pt,hierarchyEngine:Ee,timezone:Ne};const gi=f.useCallback(()=>{const r=St.current;if(!r)return;const a=z.current,g=gt(r,a.canvasWidth,a.canvasHeight);pt(g,r),Oe.draw(g,j.current,a.groups,a.theme,a.dayStyle,a.rowStyle,a.highlights,a.timezone)},[Oe]),pi=f.useCallback(()=>{const r=kt.current;if(!r)return;const a=z.current,g=gt(r,a.canvasWidth,a.canvasHeight);pt(g,r),Pe.draw(g,j.current,a.groups,a.items,a.intervalTree,a.layoutEngine,a.itemRenderer,a.groupRenderer,a.theme,a.selected,We.current,a.dependencies,a.summaryRenderer,a.hierarchyEngine)},[Pe]),Xt=f.useCallback((r,a,g)=>{const p=j.current,u=z.current,b=u.canvasWidth/(p.visibleTimeEnd-p.visibleTimeStart),k=a/b,O=[];g==="move"?(O.push(p.timeToX(r.start_time+k)),O.push(p.timeToX(r.end_time+k))):g==="resize-left"?O.push(p.timeToX(r.start_time+k)):O.push(p.timeToX(r.end_time+k));const $=(p.visibleTimeEnd-p.visibleTimeStart)*.1,Y=u.intervalTree.query(p.visibleTimeStart-$,p.visibleTimeEnd+$),Z=vt(Y,r.id,Q=>p.timeToX(Q));for(const Q of O){const K=et(Q,Z,8,b,u.dragSnap);if(K!==null)return K}const ne=g==="resize-right"?r.end_time+k:r.start_time+k,L=Math.round(ne/u.dragSnap)*u.dragSnap;return p.timeToX(L)},[]),vi=f.useCallback(()=>{const r=Ct.current;if(!r)return;const a=z.current,g=gt(r,a.canvasWidth,a.canvasHeight);pt(g,r);const p=j.current,u=ie.getState();let b=null;if(u){const k=p.timeToX(u.item.start_time),O=p.timeToX(u.item.end_time)-k;let $,Y;u.mode==="resize-left"?($=k+u.deltaX,Y=O-u.deltaX):u.mode==="resize-right"?($=k,Y=O+u.deltaX):($=k+u.deltaX,Y=O);const Z=Mt(u.currentGroup,a.groups),ne=p.groupIndexToY(Z),L=u.currentGroup!==u.originalGroup;b={item:u.item,mode:u.mode,bounds:{x:$,y:ne+(a.lineHeight-a.lineHeight*a.itemHeightRatio)/2,width:Y,height:a.lineHeight*a.itemHeightRatio},renderer:a.itemRenderer,targetGroupY:ne,groupChanged:L}}Xe.draw(g,p,a.theme,{cursorX:a.showCursorLine?ot.current:null,snapX:u?Xt(u.item,u.deltaX,u.mode):null,markers:Be.current,interaction:b})},[Xe,ie,Xt,Mt]),ut=f.useRef(null);ut.current||(ut.current=new Oi(r=>{r.grid&&gi(),r.items&&pi(),r.overlay&&vi()}));const P=ut.current;f.useEffect(()=>()=>P.dispose(),[P]),f.useEffect(()=>{if(!lt)return;const r=setInterval(()=>{const a=[];f.Children.forEach(Me,g=>{var u;if(!f.isValidElement(g))return;const p=(u=g.type)==null?void 0:u.displayName;p==="TodayMarker"?a.push(Nt(g.props)):p==="CustomMarker"&&a.push(Zt(g.props))}),Be.current=a,P.markDirty("overlay")},lt);return()=>clearInterval(r)},[lt,Me,P]),f.useEffect(()=>{j.current.update({canvasWidth:Se,canvasHeight:ge,sidebarWidth:c,lineHeight:l,groupCount:n.length,groupHeights:we}),P.markAllDirty()},[Se,ge,c,l,n.length,we,P]),f.useEffect(()=>{P.markDirty("grid"),P.markDirty("items")},[s,n,rt,ye,x,T,st,Ye,P]);const Ke=f.useMemo(()=>{var r;return((r=e.highlights)==null?void 0:r.map(a=>`${a.start}|${a.end}|${a.color}|${a.label??""}|${a.opacity??""}`).join(";"))??""},[e.highlights]),$t=f.useRef(Ke);f.useEffect(()=>{Ke!==$t.current&&($t.current=Ke,P.markDirty("grid"))},[Ke,P]);const Ft=f.useRef(qe);f.useEffect(()=>{qe!==Ft.current&&(Ft.current=qe,P.markDirty("overlay"))},[qe,P]);const _t=f.useRef(e.visibleTimeStart),Yt=f.useRef(e.visibleTimeEnd);e.visibleTimeStart!==void 0&&e.visibleTimeStart!==_t.current&&(_t.current=e.visibleTimeStart,j.current.update({visibleTimeStart:e.visibleTimeStart}),P.markAllDirty()),e.visibleTimeEnd!==void 0&&e.visibleTimeEnd!==Yt.current&&(Yt.current=e.visibleTimeEnd,j.current.update({visibleTimeEnd:e.visibleTimeEnd}),P.markAllDirty());const je=f.useRef(null),ct=f.useCallback(r=>{je.current===null&&(je.current=setTimeout(()=>{var p,u;je.current=null;const a=j.current,g=z.current;r==="zoom"?(p=g.onZoom)==null||p.call(g,a.visibleTimeStart,a.visibleTimeEnd):(u=g.onTimeChange)==null||u.call(g,a.visibleTimeStart,a.visibleTimeEnd)},Ut))},[]);f.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const Je=f.useRef(null),dt=f.useMemo(()=>new Bi((r,a)=>{var g;j.current.update({visibleTimeStart:r,visibleTimeEnd:a}),(g=Je.current)==null||g.updateBounds(r,a),P.markAllDirty(),at(),ct("zoom")},d,o,m,H),[]);Je.current=dt;const Qe=f.useCallback(r=>{const a=j.current,g=a.getTotalHeight(),p=Math.max(0,g-a.canvasHeight),u=Math.max(0,Math.min(p,a.scrollTop+r));u!==a.scrollTop&&(a.update({scrollTop:u}),P.markDirty("grid"),P.markDirty("items"),P.markDirty("overlay"),Ue(u))},[P]),Le=f.useCallback(r=>{var k,O,$;const a=j.current,g=a.canvasWidth/(a.visibleTimeEnd-a.visibleTimeStart),p=r/g,u=a.visibleTimeStart+p,b=a.visibleTimeEnd+p;a.update({visibleTimeStart:u,visibleTimeEnd:b}),(k=Je.current)==null||k.updateBounds(u,b),P.markAllDirty(),Hi.flushSync(()=>Ie()),($=(O=z.current).onTimeChange)==null||$.call(O,u,b)},[P,Ie]);f.useEffect(()=>{const r=_e.current;if(!r)return;const a=g=>{if(g.ctrlKey||g.metaKey||g.altKey){g.preventDefault();const p=r.getBoundingClientRect(),u=(g.clientX-p.left)/p.width;dt.handleWheelZoom(g,u)}else if(g.shiftKey)g.preventDefault(),Le(g.deltaY||g.deltaX);else{const p=g.deltaX;p!==0&&Math.abs(p)>Math.abs(g.deltaY)?(g.preventDefault(),Le(p)):g.deltaY!==0&&(Ze>ge&&g.preventDefault(),Qe(g.deltaY))}};return r.addEventListener("wheel",a,{passive:!1}),()=>r.removeEventListener("wheel",a)},[dt,Qe,Le,Ze,ge]);const ke=f.useRef({lastDistance:null,lastCenter:null});f.useEffect(()=>{const r=_e.current;if(!r)return;const a=(k,O)=>Math.abs(k.clientX-O.clientX),g=(k,O,$)=>(k.clientX+O.clientX)/2-$.left,p=k=>{k.touches.length===2&&(k.preventDefault(),ke.current.lastDistance=a(k.touches[0],k.touches[1]),ke.current.lastCenter=null)},u=k=>{var O;if(k.touches.length===2&&ke.current.lastDistance!==null){k.preventDefault();const $=a(k.touches[0],k.touches[1]),Y=r.getBoundingClientRect(),ne=g(k.touches[0],k.touches[1],Y)/Y.width;if($!==0&&ke.current.lastDistance!==0){const L=ke.current.lastDistance/$,Q=j.current,K=Q.visibleTimeEnd-Q.visibleTimeStart;let le=K*L;le=Math.max(m,Math.min(H,le));const U=Q.visibleTimeStart+K*ne,w=U-le*ne,S=U+le*(1-ne);Q.update({visibleTimeStart:w,visibleTimeEnd:S}),(O=Je.current)==null||O.updateBounds(w,S),P.markAllDirty(),at(),ct("zoom")}ke.current.lastDistance=$}},b=()=>{ke.current.lastDistance=null,ke.current.lastCenter=null};return r.addEventListener("touchstart",p,{passive:!1}),r.addEventListener("touchmove",u,{passive:!1}),r.addEventListener("touchend",b),()=>{r.removeEventListener("touchstart",p),r.removeEventListener("touchmove",u),r.removeEventListener("touchend",b)}},[P,at,ct]);const bi=f.useCallback(r=>{var $;const a=r.currentTarget,g=a.getBoundingClientRect(),p=r.clientX-g.left,u=r.clientY-g.top;if(ot.current=p,he.current){const Y=r.clientX-he.current.startX,Z=r.clientY-he.current.startY;if(!He.current&&(Math.abs(Y)>=Rt||Math.abs(Z)>=Rt)&&(He.current=!0,a.style.cursor="grabbing",a.setPointerCapture(r.pointerId)),He.current){const ne=r.clientX-he.current.lastX,L=r.clientY-he.current.lastY;he.current.lastX=r.clientX,he.current.lastY=r.clientY,Math.abs(ne)>0&&Le(-ne),Math.abs(L)>0&&Qe(-L)}return}if(ie.isPending()){if(ie.update(p,u),ie.isActive()){const Y=ie.getState();if(Y&&Y.mode==="move"&&z.current.canChangeGroup){const Z=mt(u,j.current,z.current.groups);Z&&ie.setCurrentGroup(Z.id)}P.markDirty("overlay")}return}z.current.showCursorLine&&P.markDirty("overlay");const b=z.current,k=ze(p,u,j.current,b.intervalTree,b.layoutEngine,b.groups),O=k==null?void 0:k.id;if(O!==We.current&&(We.current=O,P.markDirty("items"),($=b.onItemHover)==null||$.call(b,O??null,r.nativeEvent)),k){const Y=xt(p,k,j.current),Z=Bt(k,b.canResize);Y==="left"&&(Z==="left"||Z==="both")||Y==="right"&&(Z==="right"||Z==="both")?a.style.cursor="col-resize":jt(k,b.canMove)?a.style.cursor="grab":a.style.cursor="default"}else a.style.cursor="default"},[ie,P,Le,Qe]),yi=f.useCallback(r=>{const a=z.current,g=r.currentTarget.getBoundingClientRect(),p=r.clientX-g.left,u=r.clientY-g.top,b=ze(p,u,j.current,a.intervalTree,a.layoutEngine,a.groups);if(!b){he.current={startX:r.clientX,startY:r.clientY,lastX:r.clientX,lastY:r.clientY},He.current=!1;return}const k=xt(p,b,j.current),O=Bt(b,a.canResize);k==="left"&&(O==="left"||O==="both")?ie.startInteraction(b,"resize-left",p,u):k==="right"&&(O==="right"||O==="both")?ie.startInteraction(b,"resize-right",p,u):jt(b,a.canMove)&&ie.startInteraction(b,"move",p,u)},[ie]),Ti=f.useCallback(r=>{var k,O,$,Y,Z,ne;const a=r.currentTarget;if(he.current){const L=He.current;if(he.current=null,He.current=!1,a.style.cursor="default",L)return}if(ie.isActive()){const L=ie.getState(),Q=j.current,K=Q.canvasWidth/(Q.visibleTimeEnd-Q.visibleTimeStart);if(L){const le=z.current.moveResizeValidator;if(L.mode==="move"){const U=ie.endMove(K);if(U){const w=j.current,S=z.current,de=L.deltaX/K,G=w.timeToX(L.item.start_time+de),ce=w.timeToX(L.item.end_time+de),ae=(w.visibleTimeEnd-w.visibleTimeStart)*.1,W=S.intervalTree.query(w.visibleTimeStart-ae,w.visibleTimeEnd+ae),re=vt(W,L.item.id,ue=>w.timeToX(ue));let V=U.newStartTime;const N=et(G,re,8,K,S.dragSnap);if(N!==null)V=w.xToTime(N);else{const ue=et(ce,re,8,K,S.dragSnap);if(ue!==null){const fe=L.item.end_time-L.item.start_time;V=w.xToTime(ue)-fe}}const ee=le?le("move",L.item.id,V):V,oe=z.current.hierarchyEngine.getMoveDelta(L.item.id,ee);(O=(k=z.current).onItemMove)==null||O.call(k,L.item.id,ee,U.newGroupId,oe.length>0?oe:void 0)}}else{const U=ie.endResize(K);if(U){const w=j.current,S=z.current,de=L.deltaX/K,G=U.edge==="left"?L.item.start_time+de:L.item.end_time+de,ce=w.timeToX(G),ae=(w.visibleTimeEnd-w.visibleTimeStart)*.1,W=S.intervalTree.query(w.visibleTimeStart-ae,w.visibleTimeEnd+ae),re=vt(W,L.item.id,ue=>w.timeToX(ue)),V=et(ce,re,8,K,S.dragSnap);let N=V!==null?w.xToTime(V):U.newTime;const ee=z.current.hierarchyEngine.getResizeConstraint(L.item.id,U.edge);U.edge==="left"&&N>ee.max?N=ee.max:U.edge==="right"&&N<ee.min&&(N=ee.min);const oe=le?le("resize",L.item.id,N,U.edge):N;(Y=($=z.current).onItemResize)==null||Y.call($,L.item.id,oe,U.edge)}}}a.style.cursor="default",P.markDirty("overlay");return}ie.isPending()&&ie.cancel();const g=a.getBoundingClientRect(),p=r.clientX-g.left,u=r.clientY-g.top,b=ze(p,u,j.current,z.current.intervalTree,z.current.layoutEngine,z.current.groups);b&&((ne=(Z=z.current).onItemClick)==null||ne.call(Z,b.id,r.nativeEvent))},[ie,P]),Mi=f.useCallback(r=>{var k,O;const a=r.currentTarget.getBoundingClientRect(),g=r.clientX-a.left,p=r.clientY-a.top,u=z.current,b=ze(g,p,j.current,u.intervalTree,u.layoutEngine,u.groups);if(b)(k=u.onItemDoubleClick)==null||k.call(u,b.id,r.nativeEvent);else{const $=mt(p,j.current,u.groups),Y=j.current.xToTime(g);$&&((O=u.onCanvasDoubleClick)==null||O.call(u,$.id,Y))}},[]),Si=f.useCallback(r=>{var k,O;r.preventDefault();const a=r.currentTarget.getBoundingClientRect(),g=r.clientX-a.left,p=r.clientY-a.top,u=z.current,b=ze(g,p,j.current,u.intervalTree,u.layoutEngine,u.groups);if(b)(k=u.onItemContextMenu)==null||k.call(u,b.id,r.nativeEvent);else{const $=mt(p,j.current,u.groups),Y=j.current.xToTime(g);$&&((O=u.onCanvasContextMenu)==null||O.call(u,$.id,Y,r.nativeEvent))}},[]),ki=f.useCallback(()=>{var r,a;he.current=null,He.current=!1,ot.current=null,_e.current&&(_e.current.style.cursor="default"),We.current!==void 0&&(We.current=void 0,P.markDirty("items"),(a=(r=z.current).onItemHover)==null||a.call(r,null,new PointerEvent("pointerleave"))),z.current.showCursorLine&&P.markDirty("overlay")},[P]),Ci=f.useMemo(()=>{const r=[];return f.Children.forEach(Me,a=>{var p;if(!f.isValidElement(a))return;if(((p=a.type)==null?void 0:p.displayName)==="TimelineHeaders"){const u=a.props;r.push(f.cloneElement(a,{visibleTimeStart:u.visibleTimeStart??Dt,visibleTimeEnd:u.visibleTimeEnd??It,canvasWidth:u.canvasWidth??Se,sidebarWidth:u.sidebarWidth??c,theme:u.theme??ye,timezone:u.timezone??Ne,onZoomToInterval:u.onZoomToInterval??((b,k)=>{var O,$,Y,Z;j.current.update({visibleTimeStart:b,visibleTimeEnd:k}),P.markAllDirty(),Ie(),($=(O=z.current).onTimeChange)==null||$.call(O,b,k),(Z=(Y=z.current).onZoom)==null||Z.call(Y,b,k)})}))}}),r},[Me,Dt,It,Se,c,ye,Ne,P,Ie]),Wt=f.useRef(!1);f.useEffect(()=>{Wt.current||(Wt.current=!0,P.markAllDirty())},[P]),f.useImperativeHandle(t,()=>({captureToCanvas({timeStart:r,timeEnd:a,scale:g,sidebarWidth:p}){const u=z.current,b=28,k=b*3,O=u.groups.map(G=>u.layoutEngine.getGroupHeight(G.id)),$=[0];for(let G=0;G<O.length;G++)$.push($[G]+O[G]);const Y=$[O.length],Z=j.current,ne=u.canvasWidth/(Z.visibleTimeEnd-Z.visibleTimeStart),L=a-r,Q=Math.max(u.canvasWidth,Math.round(L*ne)),K=(p+Q)*g,le=(k+Y)*g,U=document.createElement("canvas");U.width=K,U.height=le;const w=U.getContext("2d");w.scale(g,g);for(let G=0;G<u.groups.length;G++){const ce=u.groups[G],ae=O[G],W=k+$[G];if(u.rowStyle){const ee=u.rowStyle(ce);ee!=null&&ee.backgroundColor&&(w.fillStyle=ee.backgroundColor,w.fillRect(0,W,p,ae))}const re=ce.type;let V="400",N=8;re==="project"?V="700":re==="CAG"?V="600":re==="CA"&&(V="400",N=24),w.fillStyle="#111",w.font=`${V} 12px sans-serif`,w.textBaseline="middle",w.fillText(ce.title,N,W+ae/2,p-N-4)}const S=(G,ce,ae)=>{var V,N;w.fillStyle=((V=u.theme.header)==null?void 0:V.bg)??"#f5f5f5",w.fillRect(p,G,Q,b),w.strokeStyle=((N=u.theme.grid)==null?void 0:N.line)??"#e0e0e0",w.lineWidth=1,w.strokeRect(p,G,Q,b);let W=pe(r,u.timezone).startOf(ae);W.valueOf()<r&&(W=W.add(1,ae));const re=Q/(a-r);for(;W.valueOf()<a;){const ee=W.add(1,ae),oe=p+(W.valueOf()-r)*re,fe=p+(Math.min(ee.valueOf(),a)-r)*re-oe;w.beginPath(),w.moveTo(oe,G),w.lineTo(oe,G+b),w.stroke(),w.fillStyle="#333",w.font="600 11px sans-serif",w.textBaseline="middle",w.textAlign="center",w.fillText(ce(W),oe+fe/2,G+b/2,fe-4),W=ee}w.textAlign="start"};S(0,G=>G.format("YYYY"),"year"),S(b,G=>G.format("MM"),"month"),S(b*2,G=>String(G.isoWeek()),"week");const de=new ht({visibleTimeStart:r,visibleTimeEnd:a,canvasWidth:Q,canvasHeight:Y,sidebarWidth:0,lineHeight:u.lineHeight,groupCount:u.groups.length,buffer:1,scrollTop:0,groupHeights:O});return w.save(),w.translate(p,k),w.beginPath(),w.rect(0,0,Q,Y),w.clip(),Oe.draw(w,de,u.groups,u.theme,u.dayStyle,u.rowStyle,u.highlights,u.timezone),Pe.draw(w,de,u.groups,u.items,u.intervalTree,u.layoutEngine,u.itemRenderer,u.groupRenderer,u.theme,u.selected,void 0,u.dependencies,u.summaryRenderer,u.hierarchyEngine),Xe.draw(w,de,u.theme,{cursorX:null,snapX:null,markers:Be.current,interaction:null}),w.restore(),U}}),[Oe,Pe,Xe]),f.useEffect(()=>{const r={captureToCanvas({timeStart:a,timeEnd:g,scale:p,sidebarWidth:u}){var ae;const b=z.current,k=28,O=k*3,$=b.groups.map(W=>b.layoutEngine.getGroupHeight(W.id)),Y=[0];for(let W=0;W<$.length;W++)Y.push(Y[W]+$[W]);const Z=Y[$.length],ne=j.current,L=b.canvasWidth/(ne.visibleTimeEnd-ne.visibleTimeStart),Q=g-a,K=Math.max(b.canvasWidth,Math.round(Q*L)),le=u+K,U=O+Z,w=document.createElement("canvas");w.width=le*p,w.height=U*p;const S=w.getContext("2d");S.scale(p,p),S.fillStyle="#FFFFFF",S.fillRect(0,0,le,U),S.save(),S.beginPath(),S.rect(0,0,u,U),S.clip(),S.fillStyle="#F9FAFB",S.fillRect(0,0,u,O),S.strokeStyle="#E5E7EB",S.lineWidth=1,S.strokeRect(0,0,u,O);for(let W=0;W<b.groups.length;W++){const re=b.groups[W],V=$[W],N=O+Y[W],ee=(ae=b.rowStyle)==null?void 0:ae.call(b,re);S.fillStyle=(ee==null?void 0:ee.backgroundColor)??(W%2===0?"#FFFFFF":"#F7F7F7"),S.fillRect(0,N,u,V),S.strokeStyle="#E5E5E5",S.lineWidth=.5,S.beginPath(),S.moveTo(0,N+V),S.lineTo(u,N+V),S.stroke();const oe=re.type??"";let ue=8,fe="400",Re=11;oe==="project"?(fe="700",Re=12):oe==="control_area_group"?fe="600":oe==="control_area"&&(ue=24),S.fillStyle="#374151",S.font=`${fe} ${Re}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,S.textBaseline="middle";const wi=typeof re.title=="string"?re.title:String(re.title);S.fillText(wi,ue,N+V/2,u-ue-8)}S.strokeStyle="#E5E7EB",S.lineWidth=1,S.beginPath(),S.moveTo(u,0),S.lineTo(u,U),S.stroke(),S.restore(),S.save(),S.beginPath(),S.rect(u,0,K,O),S.clip();const de=g-a,G=[{unit:"year",row:0},{unit:"month",row:1},{unit:"week",row:2}];for(const{unit:W,row:re}of G){const V=re*k;S.fillStyle="#F9FAFB",S.fillRect(u,V,K,k);let N=pe(a,b.timezone).startOf(W);const ee=pe(g,b.timezone).add(1,W);for(;N.isBefore(ee);){const oe=N.add(1,W),ue=u+(N.valueOf()-a)/de*K,fe=(oe.valueOf()-N.valueOf())/de*K;S.strokeStyle="#E5E7EB",S.lineWidth=.5,S.strokeRect(ue,V,fe,k);let Re;W==="year"?Re=N.format("YYYY"):W==="month"?Re=N.format("MM"):Re=`${N.week()}`,S.fillStyle="#6c737f",S.font=W==="year"?'600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif':'400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',S.textBaseline="middle",S.textAlign="center",fe>20&&S.fillText(Re,ue+fe/2,V+k/2),N=oe}}S.textAlign="start",S.restore(),S.save(),S.beginPath(),S.rect(u,O,K,Z),S.clip(),S.translate(u,O);const ce=new ht({visibleTimeStart:a,visibleTimeEnd:g,canvasWidth:K,canvasHeight:Z,sidebarWidth:0,lineHeight:b.lineHeight,groupCount:b.groups.length,buffer:1,scrollTop:0,groupHeights:$});return Oe.draw(S,ce,b.groups,b.theme,b.dayStyle,b.rowStyle,b.highlights,b.timezone),Pe.draw(S,ce,b.groups,b.items,b.intervalTree,b.layoutEngine,b.itemRenderer,b.groupRenderer,b.theme,b.selected,void 0,b.dependencies,b.summaryRenderer,b.hierarchyEngine),Xe.draw(S,ce,b.theme,{cursorX:null,markers:Be.current}),S.restore(),w}};Ge==null||Ge(r)},[Ge,Oe,Pe,Xe]);const Ei={position:"relative",width:Se,height:ge,overflow:"hidden",cursor:"default"},ft={position:"absolute",top:0,left:0};return q.jsxs("div",{ref:Et,style:{display:"flex",flexDirection:"column",width:"100%",position:"relative"},children:[ai?q.jsxs("div",{style:{position:"absolute",top:0,left:0,zIndex:9999,padding:"2px 6px",fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1.4,color:"#fff",background:"rgba(17, 24, 39, 0.78)",borderBottomRightRadius:4,pointerEvents:"none",userSelect:"none"},children:["v","0.8.0"," · ","08:36:05"]}):null,Ci,q.jsxs("div",{ref:wt,style:{display:"flex",overflow:"hidden",maxHeight:Fe??void 0},children:[q.jsx(Gt,{groups:n,width:c,lineHeight:l,groupHeights:we,scrollTop:Ot,canvasHeight:ge,theme:ye,groupRenderer:B,onScroll:r=>{j.current.update({scrollTop:r}),P.markDirty("grid"),P.markDirty("items"),P.markDirty("overlay"),Ue(r)}}),q.jsxs("div",{ref:_e,style:Ei,onPointerMove:bi,onPointerDown:yi,onPointerUp:Ti,onDoubleClick:Mi,onContextMenu:Si,onPointerLeave:ki,children:[q.jsx("canvas",{ref:St,style:{...ft,zIndex:0}}),q.jsx("canvas",{ref:kt,style:{...ft,zIndex:1}}),q.jsx("canvas",{ref:Ct,style:{...ft,zIndex:2}})]}),nt&&Tt?q.jsx(Gt,{groups:n,width:nt,lineHeight:l,groupHeights:we,scrollTop:Ot,canvasHeight:ge,theme:ye,groupRenderer:Tt,onScroll:r=>{j.current.update({scrollTop:r}),P.markDirty("grid"),P.markDirty("items"),P.markDirty("overlay"),Ue(r)}}):null]})]})}));function ii({children:i,theme:e,className:t,classNames:n,style:s,visibleTimeStart:d,visibleTimeEnd:o,canvasWidth:c,sidebarWidth:l=0,onZoomToInterval:y,timezone:R}){const v=f.Children.map(i,h=>{var M;if(!f.isValidElement(h))return h;if(((M=h.type)==null?void 0:M.displayName)==="DateHeader"){const m=h.props,H=f.cloneElement(h,{visibleTimeStart:m.visibleTimeStart??d,visibleTimeEnd:m.visibleTimeEnd??o,canvasWidth:m.canvasWidth??c,theme:m.theme??e,onZoomToInterval:m.onIntervalClick??m.onZoomToInterval??y,timezone:m.timezone??R});return q.jsxs("div",{style:{display:"flex"},children:[q.jsx("div",{style:{width:l,flexShrink:0}}),q.jsx("div",{style:{flex:1,overflow:"hidden"},children:H})]})}return h});return q.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"}`,...s},children:v})}ii.displayName="TimelineHeaders";var ni={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="week",n="year";return function(s,d,o){var c=d.prototype;c.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-this.week()),"day");var y=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var R=o(this).startOf(n).add(1,n).date(y),v=o(this).endOf(t);if(R.isBefore(v))return 1}var h=o(this).startOf(n).date(y).startOf(t).subtract(1,"millisecond"),C=this.diff(h,t,!0);return C<0?o(this).startOf("week").week():Math.ceil(C)},c.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}})})(ni);var Ui=ni.exports;const Vi=it(Ui);$e.extend(Vi);const qi={year:30,month:30,week:20,day:15,hour:30};function ri({unit:i,visibleTimeStart:e=0,visibleTimeEnd:t=0,canvasWidth:n=0,theme:s,height:d=28,className:o,labelFormat:c,onIntervalClick:l,minCellWidth:y,onZoomToInterval:R,timezone:v}){const h=f.useMemo(()=>{if(!e||!t||!n)return[];const M=t-e,m=y??qi[i];if(m>0){const T=pe(e,v).startOf(i);if((T.add(1,i).valueOf()-T.valueOf())/M*n<m)return[]}const H=[];let X=pe(e,v).startOf(i).subtract(1,i);const x=pe(t,v).add(2,i).valueOf();for(;X.valueOf()<x;){const T=X.add(1,i),D=X.valueOf(),E=T.valueOf(),F=(D-e)/M*n,B=(E-D)/M*n,I=Ki(X,T,i,c);H.push({start:D,end:E,label:I,left:F,width:B}),X=T}return H},[e,t,n,i,c,y,v]),C=f.useCallback((M,m)=>{l?l(M,m):R&&R(M,m)},[l,R]);return h.length===0?null:q.jsx("div",{style:{display:"flex",position:"relative",height:d,overflow:"hidden"},children:h.map(M=>q.jsx("div",{className:o,onClick:()=>C(M.start,M.end),style:{position:"absolute",left:M.left,width:M.width,height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRight:`1px solid ${(s==null?void 0:s.header.border)??"#E5E7EB"}`,borderBottom:`1px solid ${(s==null?void 0:s.header.border)??"#E5E7EB"}`,fontSize:12,color:(s==null?void 0:s.header.text)??"#6c737f",backgroundColor:(s==null?void 0:s.header.bg)??"#F9FAFB",overflow:"hidden",whiteSpace:"nowrap",cursor:"pointer",userSelect:"none",padding:"0 4px",boxSizing:"border-box"},children:q.jsx("span",{children:M.label})},M.start))})}ri.displayName="DateHeader";function Ki(i,e,t,n,s){return typeof n=="function"?n(i.toDate(),e.toDate(),t):typeof n=="string"?i.format(n):Ji(i,t)}function Ji(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 si({width:i,children:e,style:t}){const n=()=>({style:{width:i,...t}});return e?q.jsx(q.Fragment,{children:e({getRootProps:n})}):q.jsx("div",{style:{width:i}})}si.displayName="SidebarHeader";function oi({children:i}){return q.jsx(q.Fragment,{children:i})}oi.displayName="CustomHeader";exports.CanvasTimeline=Zi;exports.CustomHeader=oi;exports.CustomMarker=ti;exports.DEFAULT_THEME=Te;exports.DateHeader=ri;exports.HierarchyEngine=Vt;exports.SidebarHeader=si;exports.TimelineHeaders=ii;exports.TodayMarker=ei;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react/jsx-runtime"),h=require("react"),Oi=require("react-dom"),$e=require("dayjs"),be={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 mt{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,"groupHeights",{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}),Object.defineProperty(this,"groupYOffsets",{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.groupHeights=e.groupHeights??null,this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration,this.groupYOffsets=[],this.recomputeGroupYOffsets()}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),e.groupHeights!==void 0&&(this.groupHeights=e.groupHeights??null),this.visibleDuration=this.visibleTimeEnd-this.visibleTimeStart,this.pixelsPerMs=this.canvasWidth/this.visibleDuration,this.recomputeGroupYOffsets()}recomputeGroupYOffsets(){var t;const e=new Array(this.groupCount+1);e[0]=0;for(let n=0;n<this.groupCount;n++){const r=((t=this.groupHeights)==null?void 0:t[n])??this.lineHeight;e[n+1]=e[n]+r}this.groupYOffsets=e}timeToX(e){return(e-this.visibleTimeStart)*this.pixelsPerMs}xToTime(e){return this.visibleTimeStart+e/this.pixelsPerMs}yToGroupIndex(e){if(this.groupCount===0)return 0;const t=e+this.scrollTop;if(t<=0)return 0;if(t>=this.groupYOffsets[this.groupCount])return this.groupCount-1;let n=0,r=this.groupCount-1;for(;n<r;){const d=n+r>>>1;this.groupYOffsets[d+1]>t?r=d:n=d+1}return n}groupIndexToY(e){return e<0?-this.scrollTop:e>=this.groupCount?(this.groupYOffsets[this.groupCount]??0)-this.scrollTop:this.groupYOffsets[e]-this.scrollTop}groupIndexToHeight(e){var t;return e<0||e>=this.groupCount?this.lineHeight:((t=this.groupHeights)==null?void 0:t[e])??this.lineHeight}getBufferBounds(){const e=this.visibleDuration*1.5;return{bufferStart:this.visibleTimeStart-e,bufferEnd:this.visibleTimeEnd+e}}getVisibleGroupRange(){if(this.groupCount===0)return{firstVisible:0,lastVisible:-1};const e=this.yToGroupIndex(0),t=this.yToGroupIndex(this.canvasHeight);return{firstVisible:e,lastVisible:t}}isScrollInBuffer(e){const t=this.visibleDuration*1.5*this.pixelsPerMs;return Math.abs(e)<t}getTotalHeight(){return this.groupYOffsets[this.groupCount]??0}}class Pi{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 a of e)a.start<t&&(t=a.start),a.end>n&&(n=a.end);const r=(t+n)/2,d=[],s=[],c=[];for(const a of e)a.end<r?d.push(a):a.start>r?s.push(a):c.push(a);return{center:r,left:this.buildNode(d),right:this.buildNode(s),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 Xi{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 a=(n==null?void 0:n.isParent(c.id))??!1;this.layoutCache.set(c.id,{stackLevel:0,itemHeight:a?d:r}),this.groupMaxStack.set(c.group,0)}return this.layoutCache}const s=new Map;for(const c of e){let a=s.get(c.group);a||(a=[],s.set(c.group,a)),a.push(c)}for(const[c,a]of s)n?this.computeHierarchyLayout(a,n,r,d,c):this.computeFlatLayout(a,r,c);return this.layoutCache}computeFlatLayout(e,t,n){e.sort((s,c)=>{const a=s.start_time-c.start_time;return a!==0?a:c.end_time-c.start_time-(s.end_time-s.start_time)});const r=[];let d=0;for(const s of e){let c=-1;for(let a=0;a<r.length;a++)if(r[a]<=s.start_time){c=a;break}c===-1?(c=r.length,r.push(s.end_time)):r[c]=s.end_time,c>d&&(d=c),this.layoutCache.set(s.id,{stackLevel:c,itemHeight:t})}this.groupMaxStack.set(n,d)}computeHierarchyLayout(e,t,n,r,d){const s=[],c=[];for(const m of e)t.isParent(m.id)?c.push(m):s.push(m);s.sort((m,f)=>{const k=m.start_time-f.start_time;return k!==0?k:f.end_time-f.start_time-(m.end_time-m.start_time)});const a=[];let b=0;for(const m of s){let f=-1;for(let k=0;k<a.length;k++)if(a[k]<=m.start_time){f=k;break}f===-1?(f=a.length,a.push(m.end_time)):a[f]=m.end_time,f>b&&(b=f),this.layoutCache.set(m.id,{stackLevel:f,itemHeight:n})}c.sort((m,f)=>t.getNestingDepth(f.id)-t.getNestingDepth(m.id));let w=s.length>0?b+1:0;for(const m of c)this.layoutCache.set(m.id,{stackLevel:w,itemHeight:r}),w>b&&(b=w),w++;this.groupMaxStack.set(d,b)}getLayout(e){return this.layoutCache.get(e)}getGroupHeight(e){return((this.groupMaxStack.get(e)??0)+1)*this.lineHeight}}class Kt{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 s=this.parentToChildren.get(d);if(s){const c=s.indexOf(t);c!==-1&&s.splice(c,1),s.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 s of d){const c=this.itemMap.get(s);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(s=>{const c=this.itemMap.get(s);return{itemId:s,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 s=this.itemMap.get(d);s&&s.start_time<r&&(r=s.start_time)}return{min:-1/0,max:r}}else{let r=-1/0;for(const d of n){const s=this.itemMap.get(d);s&&s.end_time>r&&(r=s.end_time)}return{min:r,max:1/0}}}}function $i(i,e,t,n,r,d){const{x:s,y:c,width:a,height:b}=t,w=d.primary;i.globalAlpha=.15,i.fillStyle=w,i.fillRect(s,c,a,b),i.globalAlpha=1,i.strokeStyle=w,i.lineWidth=1.5,i.strokeRect(s,c,a,b);const m=Math.min(b*.5,6),f=c+b/2;i.fillStyle=w,i.beginPath(),i.moveTo(s,f),i.lineTo(s+m,f-m),i.lineTo(s+m*2,f),i.lineTo(s+m,f+m),i.closePath(),i.fill(),i.beginPath(),i.moveTo(s+a,f),i.lineTo(s+a-m,f-m),i.lineTo(s+a-m*2,f),i.lineTo(s+a-m,f+m),i.closePath(),i.fill();const k=e.title;if(k&&a>30){i.fillStyle=d.item.text,i.font='500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',i.textBaseline="middle";const M=i.measureText(k).width,g=a-m*4-4;if(g>20){const H=M>g?k.slice(0,Math.floor(k.length*g/M))+"...":k;i.fillText(H,s+a/2-Math.min(M,g)/2,f)}}n.selected&&(i.strokeStyle=d.item.selectedRing,i.lineWidth=2,i.strokeRect(s-1,c-1,a+2,b+2))}function Le(i,e,t,n,r,d){const s=t.xToTime(i),c=new Map;for(let m=0;m<d.length;m++)c.set(d[m].id,m);const a=n.query(s,s);let b=null,w=-1/0;for(const m of a){const f=c.get(m.group);if(f===void 0)continue;const k=r.getLayout(m.id);if(!k)continue;const M=t.timeToX(m.start_time),g=t.timeToX(m.end_time)-M;if(i<M||i>M+g)continue;const X=t.groupIndexToY(f)+k.stackLevel*t.lineHeight+(t.lineHeight-k.itemHeight)/2,Y=k.itemHeight;e<X||e>X+Y||X>w&&(w=X,b=m)}return b}function gt(i,e,t){const n=e.yToGroupIndex(i);return t[n]??null}function zt(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 _i(i,e){return i.canResize??e}function Fi(i,e){return i.canMove??e}function Lt(i,e,t,n){const r=_i(i,t);return e==="left"&&(r==="left"||r==="both")?"resize-left":e==="right"&&(r==="right"||r==="both")?"resize-right":i.canResize===!1&&e!=="body"?null:Fi(i,n)?"move":null}function pt(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 s=i.getContext("2d");return s.setTransform(n,0,0,n,0,0),s}function vt(i,e){const t=window.devicePixelRatio||1;i.clearRect(0,0,e.width/t,e.height/t)}class Yi{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)}))}}var tt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function it(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Jt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="minute",n=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(d,s,c){var a=s.prototype;c.utc=function(g){var H={date:g,utc:!0,args:arguments};return new s(H)},a.utc=function(g){var H=c(this.toDate(),{locale:this.$L,utc:!0});return g?H.add(this.utcOffset(),t):H},a.local=function(){return c(this.toDate(),{locale:this.$L,utc:!1})};var b=a.parse;a.parse=function(g){g.utc&&(this.$u=!0),this.$utils().u(g.$offset)||(this.$offset=g.$offset),b.call(this,g)};var w=a.init;a.init=function(){if(this.$u){var g=this.$d;this.$y=g.getUTCFullYear(),this.$M=g.getUTCMonth(),this.$D=g.getUTCDate(),this.$W=g.getUTCDay(),this.$H=g.getUTCHours(),this.$m=g.getUTCMinutes(),this.$s=g.getUTCSeconds(),this.$ms=g.getUTCMilliseconds()}else w.call(this)};var m=a.utcOffset;a.utcOffset=function(g,H){var X=this.$utils().u;if(X(g))return this.$u?0:X(this.$offset)?m.call(this):this.$offset;if(typeof g=="string"&&(g=function(C){C===void 0&&(C="");var _=C.match(n);if(!_)return null;var B=(""+_[0]).match(r)||["-",0,0],I=B[0],L=60*+B[1]+ +B[2];return L===0?0:I==="+"?L:-L}(g),g===null))return this;var Y=Math.abs(g)<=16?60*g:g;if(Y===0)return this.utc(H);var T=this.clone();if(H)return T.$offset=Y,T.$u=!1,T;var R=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(T=this.local().add(Y+R,t)).$offset=Y,T.$x.$localOffset=R,T};var f=a.format;a.format=function(g){var H=g||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return f.call(this,H)},a.valueOf=function(){var g=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*g},a.isUTC=function(){return!!this.$u},a.toISOString=function(){return this.toDate().toISOString()},a.toString=function(){return this.toDate().toUTCString()};var k=a.toDate;a.toDate=function(g){return g==="s"&&this.$offset?c(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():k.call(this)};var M=a.diff;a.diff=function(g,H,X){if(g&&this.$u===g.$u)return M.call(this,g,H,X);var Y=this.local(),T=c(g).local();return M.call(Y,T,H,X)}}})})(Jt);var Wi=Jt.exports;const xi=it(Wi);var Qt={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},n={};return function(r,d,s){var c,a=function(f,k,M){M===void 0&&(M={});var g=new Date(f),H=function(X,Y){Y===void 0&&(Y={});var T=Y.timeZoneName||"short",R=X+"|"+T,C=n[R];return C||(C=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:X,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:T}),n[R]=C),C}(k,M);return H.formatToParts(g)},b=function(f,k){for(var M=a(f,k),g=[],H=0;H<M.length;H+=1){var X=M[H],Y=X.type,T=X.value,R=t[Y];R>=0&&(g[R]=parseInt(T,10))}var C=g[3],_=C===24?0:C,B=g[0]+"-"+g[1]+"-"+g[2]+" "+_+":"+g[4]+":"+g[5]+":000",I=+f;return(s.utc(B).valueOf()-(I-=I%1e3))/6e4},w=d.prototype;w.tz=function(f,k){f===void 0&&(f=c);var M,g=this.utcOffset(),H=this.toDate(),X=H.toLocaleString("en-US",{timeZone:f}),Y=Math.round((H-new Date(X))/1e3/60),T=15*-Math.round(H.getTimezoneOffset()/15)-Y;if(!Number(T))M=this.utcOffset(0,k);else if(M=s(X,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(T,!0),k){var R=M.utcOffset();M=M.add(g-R,"minute")}return M.$x.$timezone=f,M},w.offsetName=function(f){var k=this.$x.$timezone||s.tz.guess(),M=a(this.valueOf(),k,{timeZoneName:f}).find(function(g){return g.type.toLowerCase()==="timezonename"});return M&&M.value};var m=w.startOf;w.startOf=function(f,k){if(!this.$x||!this.$x.$timezone)return m.call(this,f,k);var M=s(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return m.call(M,f,k).tz(this.$x.$timezone,!0)},s.tz=function(f,k,M){var g=M&&k,H=M||k||c,X=b(+s(),H);if(typeof f!="string")return s(f).tz(H);var Y=function(_,B,I){var L=_-60*B*1e3,F=b(L,I);if(B===F)return[L,B];var Q=b(L-=60*(F-B)*1e3,I);return F===Q?[L,F]:[_-60*Math.min(F,Q)*1e3,Math.max(F,Q)]}(s.utc(f,g).valueOf(),X,H),T=Y[0],R=Y[1],C=s(T).utcOffset(R);return C.$x.$timezone=H,C},s.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},s.tz.setDefault=function(f){c=f}}})})(Qt);var Bi=Qt.exports;const ji=it(Bi);$e.extend(xi);$e.extend(ji);function fe(i,e){return e?$e(i).tz(e):$e(i)}class zi{draw(e,t,n,r,d,s,c,a){const{firstVisible:b,lastVisible:w}=t.getVisibleGroupRange();for(let T=b;T<=w;T++){const R=t.groupIndexToY(T),C=t.groupIndexToHeight(T),_=n[T];if(!_)continue;let B;const I=s==null?void 0:s(_);I!=null&&I.backgroundColor?B=I.backgroundColor:B=T%2===0?"#FFFFFF":r.grid.rowAlt,e.fillStyle=B,e.fillRect(0,R,t.canvasWidth,C),e.strokeStyle=(I==null?void 0:I.borderBottomColor)??r.grid.line,e.lineWidth=.5,e.beginPath(),e.moveTo(0,R+C),e.lineTo(t.canvasWidth,R+C),e.stroke()}if(c&&c.length>0)for(const T of c){const R=t.timeToX(T.start),C=t.timeToX(T.end);if(C<0||R>t.canvasWidth)continue;const _=Math.max(0,R),B=Math.min(t.canvasWidth,C)-_,I=T.opacity??.12,L=parseInt(T.color.slice(1,3),16),F=parseInt(T.color.slice(3,5),16),Q=parseInt(T.color.slice(5,7),16);e.fillStyle=`rgb(${Math.round(L*I+255*(1-I))},${Math.round(F*I+255*(1-I))},${Math.round(Q*I+255*(1-I))})`,e.fillRect(_,0,B,t.canvasHeight)}const m=t.visibleTimeStart,f=t.visibleTimeEnd,g=864e5/(f-m)*t.canvasWidth;let H="day";g<2?H="month":g<8&&(H="week");{let T=fe(m,a).startOf("day");const R=fe(f,a).endOf("day");let C=null,_=1,B=0;const I=[],L=F=>{C!==null&&(e.fillStyle=C,_!==1&&(e.globalAlpha=_),e.fillRect(B,0,F-B,t.canvasHeight),_!==1&&(e.globalAlpha=1),C=null,_=1)};for(;T.isBefore(R);){const F=t.timeToX(T.valueOf()),Q=T.toDate(),Z=d==null?void 0:d(Q);let J=null,ue=1;if(Z!=null&&Z.backgroundColor)J=Z.backgroundColor,ue=Z.opacity??1;else{const he=T.day();(he===0||he===6)&&(J=r.grid.weekend)}Z!=null&&Z.borderColor&&I.push({x:F,color:Z.borderColor}),J===C&&ue===_||(L(F),J!==null&&(C=J,_=ue,B=F)),T=T.add(1,"day")}C!==null&&L(t.timeToX(T.valueOf()));for(const F of I)e.strokeStyle=F.color,e.lineWidth=.5,e.beginPath(),e.moveTo(F.x,0),e.lineTo(F.x,t.canvasHeight),e.stroke()}let X=fe(m,a).startOf(H);const Y=fe(f,a).add(1,H);for(e.strokeStyle=r.grid.line,e.lineWidth=.5,e.beginPath();X.isBefore(Y);){const T=t.timeToX(X.valueOf());e.moveTo(T,0),e.lineTo(T,t.canvasHeight),X=X.add(1,H)}if(e.stroke(),c&&c.length>0)for(const T of c){const R=t.timeToX(T.start),C=t.timeToX(T.end);if(!(C<0||R>t.canvasWidth)&&(e.strokeStyle=T.color,e.globalAlpha=.4,e.lineWidth=1,e.beginPath(),R>=0&&R<=t.canvasWidth&&(e.moveTo(R,0),e.lineTo(R,t.canvasHeight)),C>=0&&C<=t.canvasWidth&&(e.moveTo(C,0),e.lineTo(C,t.canvasHeight)),e.stroke(),e.globalAlpha=1,T.label)){const _=Math.max(0,R),B=Math.min(t.canvasWidth,C)-_;e.save(),e.font='600 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';const I=e.measureText(T.label).width,L=6,F=I+L*2,Q=18,Z=_+(B-F)/2,J=4;e.fillStyle=T.color,e.globalAlpha=.9,e.beginPath(),e.roundRect(Z,J,F,Q,3),e.fill(),e.globalAlpha=1,e.fillStyle="#FFFFFF",e.textBaseline="middle",e.fillText(T.label,Z+L,J+Q/2),e.restore()}}}}const At='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function ei(i,e){return{roundRect(t,n,r,d,s=3){i.beginPath(),i.roundRect(t,n,r,d,s),i.fill()},fillText(t,n,r,d){if(i.font=At,d!==void 0&&i.measureText(t).width>d){let s=0,c=t.length;for(;s<c;){const a=Math.ceil((s+c)/2),b=t.slice(0,a)+"...";i.measureText(b).width<=d?s=a:c=a-1}i.fillText(t.slice(0,s)+"...",n,r)}else i.fillText(t,n,r)},gradient(t,n,r,d){const s=i.createLinearGradient(t,0,t+n,0);return s.addColorStop(0,r),s.addColorStop(.5,r),s.addColorStop(.5,d),s.addColorStop(1,d),s},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 s=d/2;if(t==="check"){i.fillStyle="#31c48d",i.beginPath(),i.arc(n+s,r+s,s,0,Math.PI*2),i.fill(),i.strokeStyle="#ffffff",i.lineWidth=d*.12,i.beginPath();const c=n+s,a=r+s;i.moveTo(c-s*.45,a),i.lineTo(c-s*.1,a+s*.42),i.lineTo(c+s*.45,a-s*.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+s,r),i.lineTo(n+d,r+d),i.lineTo(n,r+d),i.closePath(),i.fill(),i.fillStyle="#ffffff";const a=d*.12,b=n+s-a/2;i.fillRect(b,r+d*.35,a,d*.35),i.beginPath(),i.arc(n+s,r+d*.82,a*.7,0,Math.PI*2),i.fill()}i.restore()},badge(t,n,r,d){i.save(),i.font=At;const c=i.measureText(t).width,a=8,w=12+3*2,m=c+a*2,f=w/2;i.fillStyle=d,i.beginPath(),i.roundRect(n,r,m,w,f),i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(t,n+m/2,r+w/2),i.restore()}}}class Li{draw(e,t,n,r,d,s,c,a,b,w,m,f,k,M){const g=(t.visibleTimeEnd-t.visibleTimeStart)*.1,H=t.visibleTimeStart-g,X=t.visibleTimeEnd+g,Y=d.query(H,X),T=new Map;for(let I=0;I<n.length;I++)T.set(n[I].id,I);const R=new Set(w),C=new Map,_=-t.lineHeight,B=t.canvasHeight+t.lineHeight;for(const I of Y){const L=T.get(I.group);if(L===void 0)continue;const F=s.getLayout(I.id);if(!F)continue;const Z=t.groupIndexToY(L)+F.stackLevel*t.lineHeight+(t.lineHeight-F.itemHeight)/2,J=F.itemHeight;if(Z+J<_||Z>B)continue;const ue=t.timeToX(I.start_time),he=t.timeToX(I.end_time)-ue,me={x:ue,y:Z,width:he,height:J};C.set(I.id,me);const Re={selected:R.has(I.id),hovered:m===I.id,dragging:!1,filtered:I.filtered!==!1};e.save();const Ae=ei(e,me);let Se;k&&(M!=null&&M.isParent(I.id))?Se=k:a&&(I.type==="control_area_group"||I.type==="construction_train")?Se=a:Se=c,Se(e,I,me,Re,Ae),e.restore()}if(f&&f.length>0){const I=new Set;for(const L of f)C.has(L.fromItemId)||I.add(L.fromItemId),C.has(L.toItemId)||I.add(L.toItemId);if(I.size>0){const L=new Map;for(const F of r)I.has(F.id)&&L.set(F.id,F);for(const[F,Q]of L){const Z=T.get(Q.group);if(Z===void 0)continue;const J=s.getLayout(F);if(!J)continue;const he=t.groupIndexToY(Z)+J.stackLevel*t.lineHeight+(t.lineHeight-J.itemHeight)/2,me=t.timeToX(Q.start_time),Re=t.timeToX(Q.end_time)-me;C.set(F,{x:me,y:he,width:Re,height:J.itemHeight})}}this.drawDependencies(e,f,C,m,b)}}drawDependencies(e,t,n,r,d){for(const s of t){const c=n.get(s.fromItemId),a=n.get(s.toItemId);if(!c||!a)continue;const b=r===s.fromItemId||r===s.toItemId;e.strokeStyle=b?d.primary:s.color??"#94A3B8",e.lineWidth=b?2:1.5,e.setLineDash([]);const w=c.x+c.width,m=c.y+c.height/2,f=a.x,k=a.y+a.height/2,M=Math.abs(f-w),g=Math.max(M*.4,30);e.beginPath(),e.moveTo(w,m),e.bezierCurveTo(w+g,m,f-g,k,f,k),e.stroke();const H=6;e.fillStyle=e.strokeStyle,e.beginPath(),e.moveTo(f,k),e.lineTo(f-H,k-H/2),e.lineTo(f-H,k+H/2),e.closePath(),e.fill()}}}class Ai{draw(e,t,n,r){const{cursorX:d,snapX:s,markers:c,interaction:a}=r;if(c)for(const b of c){const w=t.timeToX(b.date);if(e.fillStyle=b.color,e.fillRect(w-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 m=e.measureText(b.label).width,f=8,k=200,M=Math.min(m+f*2,k),g=20,H=w-M/2,X=4;e.fillStyle=b.color,e.beginPath(),e.roundRect(H,X,M,g,3),e.fill(),e.fillStyle="#FFFFFF",e.textBaseline="middle";const Y=k-f*2,T=m>Y?b.label.slice(0,Math.floor(b.label.length*Y/m))+"…":b.label;e.fillText(T,H+f,X+g/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()),s!=null&&(e.strokeStyle=n.primary,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(s,0),e.lineTo(s,t.canvasHeight),e.stroke(),e.setLineDash([])),a){a.groupChanged&&a.targetGroupY!==void 0&&(e.fillStyle="rgba(59, 130, 246, 0.08)",e.fillRect(0,a.targetGroupY,t.canvasWidth,t.lineHeight)),e.save(),e.globalAlpha=.5;const b=ei(e,a.bounds);a.renderer(e,a.item,a.bounds,{selected:!1,hovered:!1,dragging:!0,filtered:!0},b),e.restore()}}}const Gt=120;function Gi(i){let e=i.deltaY||i.deltaX;return i.deltaMode===1?e*=15:i.deltaMode===2&&(e*=800),Math.max(-Gt,Math.min(Gt,e))}class Ni{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=Gi(e),r=e.ctrlKey?10:e.metaKey?3:1,d=n>0?1+r*n/500:1/(1+r*-n/500),s=this.visibleTimeEnd-this.visibleTimeStart;let c=Math.round(s*d);c=Math.max(this.minZoom,Math.min(this.maxZoom,c));const a=Math.round(this.visibleTimeStart+(s-c)*t),b=a+c;this.onZoom(a,b)}}const Ui=4;class Zi{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)>=Ui&&(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,s=Math.round(d/this.dragSnap)*this.dragSnap;return this.state=null,this.activated=!1,{newTime:s,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 bt(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 et(i,e,t,n,r){if(e.length===0)return null;let d=e[0],s=Math.abs(i-d);for(let c=1;c<e.length;c++){const a=Math.abs(i-e[c]);a<s&&(s=a,d=e[c])}return s<=t?d:null}function ti(i,e,t){const n=t.canvasWidth/(e.visibleTimeEnd-e.visibleTimeStart),r=i.deltaX/n,d=i.item.start_time+r,s=(e.visibleTimeEnd-e.visibleTimeStart)*.1,c=t.intervalTree.query(e.visibleTimeStart-s,e.visibleTimeEnd+s),a=bt(c,i.item.id,m=>e.timeToX(m)),b=et(e.timeToX(d),a,8,n,t.dragSnap);if(b!==null)return e.xToTime(b);const w=et(e.timeToX(i.item.end_time+r),a,8,n,t.dragSnap);return w!==null?e.xToTime(w)-(i.item.end_time-i.item.start_time):Math.round(d/t.dragSnap)*t.dragSnap}function ii(i,e,t){const n=t.canvasWidth/(e.visibleTimeEnd-e.visibleTimeStart),r=i.deltaX/n,d=i.mode==="resize-left"?"left":"right",s=(d==="left"?i.item.start_time:i.item.end_time)+r,c=(e.visibleTimeEnd-e.visibleTimeStart)*.1,a=t.intervalTree.query(e.visibleTimeStart-c,e.visibleTimeEnd+c),b=bt(a,i.item.id,k=>e.timeToX(k)),w=et(e.timeToX(s),b,8,n,t.dragSnap);let m=w!==null?e.xToTime(w):Math.round(s/t.dragSnap)*t.dragSnap;const f=t.hierarchyEngine.getResizeConstraint(i.item.id,d);return d==="left"&&m>f.max?m=f.max:d==="right"&&m<f.min&&(m=f.min),{edge:d,time:m}}function Vi(i,e,t,n){if(i.mode==="move"){const a=ti(i,e,t),b=i.item.end_time-i.item.start_time;return{itemId:i.item.id,mode:"move",time:a,startTime:a,endTime:a+b,pointerX:n.x,pointerY:n.y}}const{edge:r,time:d}=ii(i,e,t),s=r==="left"?d:i.item.start_time,c=r==="right"?d:i.item.end_time;return{itemId:i.item.id,mode:i.mode,edge:r,time:d,startTime:s,endTime:c,pointerX:n.x,pointerY:n.y}}var ni={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="day";return function(n,r,d){var s=function(b){return b.add(4-b.isoWeekday(),t)},c=r.prototype;c.isoWeekYear=function(){return s(this).year()},c.isoWeek=function(b){if(!this.$utils().u(b))return this.add(7*(b-this.isoWeek()),t);var w,m,f,k,M=s(this),g=(w=this.isoWeekYear(),m=this.$u,f=(m?d.utc:d)().year(w).startOf("year"),k=4-f.isoWeekday(),f.isoWeekday()>4&&(k+=7),f.add(k,t));return M.diff(g,"week")+1},c.isoWeekday=function(b){return this.$utils().u(b)?this.day()||7:this.day(this.day()%7?b:b-7)};var a=c.startOf;c.startOf=function(b,w){var m=this.$utils(),f=!!m.u(w)||w;return m.p(b)==="isoweek"?f?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):a.bind(this)(b,w)}}})})(ni);var qi=ni.exports;const Ki=it(qi),Nt=200;function Ut({groups:i,width:e,lineHeight:t,groupHeights:n,scrollTop:r,canvasHeight:d,theme:s,groupRenderer:c,onScroll:a}){var T;const b=h.useRef(null),w=h.useRef(!1),m=h.useMemo(()=>{const R=new Array(i.length+1);R[0]=0;for(let C=0;C<i.length;C++)R[C+1]=R[C]+((n==null?void 0:n[C])??t);return R},[i.length,n,t]),f=m[i.length]??0,k=d,M=h.useCallback(R=>{if(i.length===0||R<=0)return 0;if(R>=f)return i.length-1;let C=0,_=i.length-1;for(;C<_;){const B=C+_>>>1;m[B+1]>R?_=B:C=B+1}return C},[i.length,m,f]),g=M(r-Nt),H=M(r+d+Nt),X=h.useCallback(R=>{w.current||a(R.currentTarget.scrollTop)},[a]);h.useEffect(()=>{b.current&&(w.current=!0,b.current.scrollTop=r,requestAnimationFrame(()=>{w.current=!1}))},[r]);const Y=[];for(let R=g;R<=H;R++){const C=i[R];if(!C)continue;const _=m[R],B=m[R+1]-_;Y.push(U.jsx("div",{style:{position:"absolute",top:_,height:B,width:"100%",overflow:"hidden",display:"flex",alignItems:"stretch",borderBottom:`1px solid ${((T=s.grid)==null?void 0:T.line)??"#E5E5E5"}`,boxSizing:"border-box"},children:c(C)},C.id))}return U.jsx("div",{ref:b,onScroll:X,style:{width:e,height:k,overflowY:f>d?"auto":"hidden",overflowX:"hidden",position:"relative",borderRight:`1px solid ${s.sidebar.border}`,backgroundColor:s.sidebar.bg},children:U.jsx("div",{style:{height:f,position:"relative"},children:Y})})}function ri(i){return null}ri.displayName="TodayMarker";function Zt(i){return{date:Math.floor(Date.now()/6e4)*6e4,color:i.color??"#FD7171",width:i.width??6,label:i.label}}function Ji(i){return i.interval??1e4}function si(i){return null}si.displayName="CustomMarker";function Vt(i){return{date:i.date,color:i.color??"#3B82F6",width:i.width??4,label:i.label}}$e.extend(Ki);function Qi(i){return i?{...be,...i,status:{...be.status,...i.status},grid:{...be.grid,...i.grid},item:{...be.item,...i.item},marker:{...be.marker,...i.marker},sidebar:{...be.sidebar,...i.sidebar},header:{...be.header,...i.header}}:be}const qt=32,en=h.memo(h.forwardRef(function(e,t){const{groups:n,items:r,defaultTimeStart:d,defaultTimeEnd:s,sidebarWidth:c,lineHeight:a,itemHeightRatio:b,stackItems:w,canMove:m,canChangeGroup:f,canResize:k,dragSnap:M,minZoom:g,maxZoom:H,theme:X,dayStyle:Y,rowStyle:T,showCursorLine:R,itemRenderer:C,groupRenderer:_,sidebarGroupRenderer:B,dependencies:I,highlights:L,onItemClick:F,onItemDoubleClick:Q,onItemContextMenu:Z,onItemMove:J,onItemResize:ue,moveResizeValidator:he,onItemHover:me,onInteractionUpdate:Re,onCanvasDoubleClick:Ae,onCanvasContextMenu:Se,onTimeChange:yt,onZoom:Tt,selected:Mt=[],rightSidebarWidth:nt,rightSidebarGroupRenderer:St,onReady:Ge,maxHeight:_e,timezone:Ne,devBadge:di,children:ye}=e,ge=h.useMemo(()=>Qi(X),[X]),kt=h.useCallback((o,l)=>{for(let p=0;p<l.length;p++)if(l[p].id===o)return p;return 0},[]),fi=Mt.join(","),rt=h.useMemo(()=>Mt,[fi]),Ct=h.useRef(null),Et=h.useRef(null),wt=h.useRef(null),Fe=h.useRef(null),Ht=h.useRef(null),Rt=h.useRef(null),[hi,mi]=h.useState(800),[gi,pi]=h.useState(null);h.useEffect(()=>{const o=Ht.current;if(!o)return;const l=new ResizeObserver(p=>{const v=p[0];v&&mi(v.contentRect.width)});return l.observe(o),()=>l.disconnect()},[]),h.useEffect(()=>{const o=Rt.current;if(!o||!_e)return;const l=new ResizeObserver(p=>{const v=p[0];v&&pi(v.contentRect.height)});return l.observe(o),()=>l.disconnect()},[_e]);const Te=Math.max(0,hi-c-(nt??0)),ke=h.useMemo(()=>{const o=new Kt;return o.rebuild(r),o},[r]),st=h.useMemo(()=>{const o=new Pi;return o.buildFromItems(r,l=>ke.getEffectiveSpan(l.id).start,l=>ke.getEffectiveSpan(l.id).end),o},[r,ke]),Ye=h.useMemo(()=>{const o=new Xi(a,b);return o.computeLayout(r,w,ke),o},[r,a,b,w,ke]),Ce=h.useMemo(()=>n.map(o=>Ye.getGroupHeight(o.id)),[n,Ye]),Ue=h.useMemo(()=>Ce.reduce((o,l)=>o+l,0),[Ce]),It=typeof _e=="number"?_e:gi,ce=It?Math.min(Ue,It):Ue,z=h.useRef(new mt({visibleTimeStart:e.visibleTimeStart??d,visibleTimeEnd:e.visibleTimeEnd??s,canvasWidth:Te,canvasHeight:ce,sidebarWidth:c,lineHeight:a,groupCount:n.length,buffer:e.buffer??3,scrollTop:0,groupHeights:Ce})),ot=h.useRef(null),We=h.useRef(void 0),Dt=h.useRef({x:0,y:0}),at=h.useRef(!1),ae=h.useRef(null),Ee=h.useRef(!1),Ot=4,[Pt,vi]=h.useState(e.visibleTimeStart??d),[Xt,bi]=h.useState(e.visibleTimeEnd??s),[$t,Ze]=h.useState(0),xe=h.useRef(null),Ie=h.useCallback(()=>{const o=z.current;vi(o.visibleTimeStart),bi(o.visibleTimeEnd),Ze(o.scrollTop),xe.current=null},[]),lt=h.useCallback(()=>{xe.current===null&&(xe.current=setTimeout(Ie,qt))},[Ie]);h.useEffect(()=>()=>{xe.current!==null&&clearTimeout(xe.current)},[]);const _t=h.useMemo(()=>e.summaryRenderer?e.summaryRenderer:(o,l,p,v,u)=>{$i(o,l,p,v,u,ge)},[e.summaryRenderer,ge]),De=h.useMemo(()=>new zi,[]),Oe=h.useMemo(()=>new Li,[]),Pe=h.useMemo(()=>new Ai,[]),te=h.useMemo(()=>new Zi(M),[M]),Ve=h.useMemo(()=>{const o=[];return h.Children.forEach(ye,l=>{var v;if(!h.isValidElement(l))return;const p=(v=l.type)==null?void 0:v.displayName;p==="TodayMarker"?o.push(Zt(l.props)):p==="CustomMarker"&&o.push(Vt(l.props))}),o},[ye]),qe=h.useMemo(()=>Ve.map(o=>`${o.date}|${o.color}|${o.width}|${o.label??""}`).join(";"),[Ve]),Be=h.useRef(Ve);Be.current=Ve;const ut=h.useMemo(()=>{let o=0;return h.Children.forEach(ye,l=>{var v;if(!h.isValidElement(l))return;((v=l.type)==null?void 0:v.displayName)==="TodayMarker"&&(o=Ji(l.props))}),o},[ye]),A=h.useRef({groups:n,items:r,intervalTree:st,layoutEngine:Ye,itemRenderer:C,groupRenderer:_,theme:ge,selected:rt,dependencies:I,highlights:L,dayStyle:Y,rowStyle:T,showCursorLine:R,canvasWidth:Te,canvasHeight:ce,lineHeight:a,itemHeightRatio:b,onTimeChange:yt,onZoom:Tt,onItemHover:me,onItemClick:F,onItemDoubleClick:Q,onItemContextMenu:Z,onItemMove:J,onItemResize:ue,onInteractionUpdate:Re,onCanvasDoubleClick:Ae,onCanvasContextMenu:Se,canMove:m,canResize:k,canChangeGroup:f,dragSnap:M,sidebarWidth:c,moveResizeValidator:he,summaryRenderer:_t,hierarchyEngine:ke,timezone:Ne});A.current={groups:n,items:r,intervalTree:st,layoutEngine:Ye,itemRenderer:C,groupRenderer:_,theme:ge,selected:rt,dependencies:I,highlights:L,dayStyle:Y,rowStyle:T,showCursorLine:R,canvasWidth:Te,canvasHeight:ce,lineHeight:a,itemHeightRatio:b,onTimeChange:yt,onZoom:Tt,onItemHover:me,onItemClick:F,onItemDoubleClick:Q,onItemContextMenu:Z,onItemMove:J,onItemResize:ue,onInteractionUpdate:Re,onCanvasDoubleClick:Ae,onCanvasContextMenu:Se,canMove:m,canResize:k,canChangeGroup:f,dragSnap:M,sidebarWidth:c,moveResizeValidator:he,summaryRenderer:_t,hierarchyEngine:ke,timezone:Ne};const yi=h.useCallback(()=>{const o=Ct.current;if(!o)return;const l=A.current,p=pt(o,l.canvasWidth,l.canvasHeight);vt(p,o),De.draw(p,z.current,l.groups,l.theme,l.dayStyle,l.rowStyle,l.highlights,l.timezone)},[De]),Ti=h.useCallback(()=>{const o=Et.current;if(!o)return;const l=A.current,p=pt(o,l.canvasWidth,l.canvasHeight);vt(p,o),Oe.draw(p,z.current,l.groups,l.items,l.intervalTree,l.layoutEngine,l.itemRenderer,l.groupRenderer,l.theme,l.selected,We.current,l.dependencies,l.summaryRenderer,l.hierarchyEngine)},[Oe]),Ft=h.useCallback((o,l,p)=>{const v=z.current,u=A.current,y=u.canvasWidth/(v.visibleTimeEnd-v.visibleTimeStart),E=l/y,D=[];p==="move"?(D.push(v.timeToX(o.start_time+E)),D.push(v.timeToX(o.end_time+E))):p==="resize-left"?D.push(v.timeToX(o.start_time+E)):D.push(v.timeToX(o.end_time+E));const $=(v.visibleTimeEnd-v.visibleTimeStart)*.1,W=u.intervalTree.query(v.visibleTimeStart-$,v.visibleTimeEnd+$),x=bt(W,o.id,q=>v.timeToX(q));for(const q of D){const N=et(q,x,8,y,u.dragSnap);if(N!==null)return N}const V=p==="resize-right"?o.end_time+E:o.start_time+E,ne=Math.round(V/u.dragSnap)*u.dragSnap;return v.timeToX(ne)},[]),Mi=h.useCallback(()=>{const o=wt.current;if(!o)return;const l=A.current,p=pt(o,l.canvasWidth,l.canvasHeight);vt(p,o);const v=z.current,u=te.getState();let y=null;if(u){const E=v.timeToX(u.item.start_time),D=v.timeToX(u.item.end_time)-E;let $,W;u.mode==="resize-left"?($=E+u.deltaX,W=D-u.deltaX):u.mode==="resize-right"?($=E,W=D+u.deltaX):($=E+u.deltaX,W=D);const x=kt(u.currentGroup,l.groups),V=v.groupIndexToY(x),ne=u.currentGroup!==u.originalGroup;y={item:u.item,mode:u.mode,bounds:{x:$,y:V+(l.lineHeight-l.lineHeight*l.itemHeightRatio)/2,width:W,height:l.lineHeight*l.itemHeightRatio},renderer:l.itemRenderer,targetGroupY:V,groupChanged:ne}}Pe.draw(p,v,l.theme,{cursorX:l.showCursorLine?ot.current:null,snapX:u?Ft(u.item,u.deltaX,u.mode):null,markers:Be.current,interaction:y}),l.onInteractionUpdate&&(u?(l.onInteractionUpdate(Vi(u,v,l,Dt.current)),at.current=!0):at.current&&(at.current=!1,l.onInteractionUpdate(null)))},[Pe,te,Ft,kt]),ct=h.useRef(null);ct.current||(ct.current=new Yi(o=>{o.grid&&yi(),o.items&&Ti(),o.overlay&&Mi()}));const O=ct.current;h.useEffect(()=>()=>O.dispose(),[O]),h.useEffect(()=>{if(!ut)return;const o=setInterval(()=>{const l=[];h.Children.forEach(ye,p=>{var u;if(!h.isValidElement(p))return;const v=(u=p.type)==null?void 0:u.displayName;v==="TodayMarker"?l.push(Zt(p.props)):v==="CustomMarker"&&l.push(Vt(p.props))}),Be.current=l,O.markDirty("overlay")},ut);return()=>clearInterval(o)},[ut,ye,O]),h.useEffect(()=>{z.current.update({canvasWidth:Te,canvasHeight:ce,sidebarWidth:c,lineHeight:a,groupCount:n.length,groupHeights:Ce}),O.markAllDirty()},[Te,ce,c,a,n.length,Ce,O]),h.useEffect(()=>{O.markDirty("grid"),O.markDirty("items")},[r,n,rt,ge,Y,T,st,Ye,O]);const Ke=h.useMemo(()=>{var o;return((o=e.highlights)==null?void 0:o.map(l=>`${l.start}|${l.end}|${l.color}|${l.label??""}|${l.opacity??""}`).join(";"))??""},[e.highlights]),Yt=h.useRef(Ke);h.useEffect(()=>{Ke!==Yt.current&&(Yt.current=Ke,O.markDirty("grid"))},[Ke,O]);const Wt=h.useRef(qe);h.useEffect(()=>{qe!==Wt.current&&(Wt.current=qe,O.markDirty("overlay"))},[qe,O]);const xt=h.useRef(e.visibleTimeStart),Bt=h.useRef(e.visibleTimeEnd);e.visibleTimeStart!==void 0&&e.visibleTimeStart!==xt.current&&(xt.current=e.visibleTimeStart,z.current.update({visibleTimeStart:e.visibleTimeStart}),O.markAllDirty()),e.visibleTimeEnd!==void 0&&e.visibleTimeEnd!==Bt.current&&(Bt.current=e.visibleTimeEnd,z.current.update({visibleTimeEnd:e.visibleTimeEnd}),O.markAllDirty());const je=h.useRef(null),dt=h.useCallback(o=>{je.current===null&&(je.current=setTimeout(()=>{var v,u;je.current=null;const l=z.current,p=A.current;o==="zoom"?(v=p.onZoom)==null||v.call(p,l.visibleTimeStart,l.visibleTimeEnd):(u=p.onTimeChange)==null||u.call(p,l.visibleTimeStart,l.visibleTimeEnd)},qt))},[]);h.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const Je=h.useRef(null),ft=h.useMemo(()=>new Ni((o,l)=>{var p;z.current.update({visibleTimeStart:o,visibleTimeEnd:l}),(p=Je.current)==null||p.updateBounds(o,l),O.markAllDirty(),lt(),dt("zoom")},d,s,g,H),[]);Je.current=ft;const Qe=h.useCallback(o=>{const l=z.current,p=l.getTotalHeight(),v=Math.max(0,p-l.canvasHeight),u=Math.max(0,Math.min(v,l.scrollTop+o));u!==l.scrollTop&&(l.update({scrollTop:u}),O.markDirty("grid"),O.markDirty("items"),O.markDirty("overlay"),Ze(u))},[O]),ze=h.useCallback(o=>{var E,D,$;const l=z.current,p=l.canvasWidth/(l.visibleTimeEnd-l.visibleTimeStart),v=o/p,u=l.visibleTimeStart+v,y=l.visibleTimeEnd+v;l.update({visibleTimeStart:u,visibleTimeEnd:y}),(E=Je.current)==null||E.updateBounds(u,y),O.markAllDirty(),Oi.flushSync(()=>Ie()),($=(D=A.current).onTimeChange)==null||$.call(D,u,y)},[O,Ie]);h.useEffect(()=>{const o=Fe.current;if(!o)return;const l=p=>{if(p.ctrlKey||p.metaKey||p.altKey){p.preventDefault();const v=o.getBoundingClientRect(),u=(p.clientX-v.left)/v.width;ft.handleWheelZoom(p,u)}else if(p.shiftKey)p.preventDefault(),ze(p.deltaY||p.deltaX);else{const v=p.deltaX;v!==0&&Math.abs(v)>Math.abs(p.deltaY)?(p.preventDefault(),ze(v)):p.deltaY!==0&&(Ue>ce&&p.preventDefault(),Qe(p.deltaY))}};return o.addEventListener("wheel",l,{passive:!1}),()=>o.removeEventListener("wheel",l)},[ft,Qe,ze,Ue,ce]);const Me=h.useRef({lastDistance:null,lastCenter:null});h.useEffect(()=>{const o=Fe.current;if(!o)return;const l=(E,D)=>Math.abs(E.clientX-D.clientX),p=(E,D,$)=>(E.clientX+D.clientX)/2-$.left,v=E=>{E.touches.length===2&&(E.preventDefault(),Me.current.lastDistance=l(E.touches[0],E.touches[1]),Me.current.lastCenter=null)},u=E=>{var D;if(E.touches.length===2&&Me.current.lastDistance!==null){E.preventDefault();const $=l(E.touches[0],E.touches[1]),W=o.getBoundingClientRect(),V=p(E.touches[0],E.touches[1],W)/W.width;if($!==0&&Me.current.lastDistance!==0){const ne=Me.current.lastDistance/$,q=z.current,N=q.visibleTimeEnd-q.visibleTimeStart;let re=N*ne;re=Math.max(g,Math.min(H,re));const ee=q.visibleTimeStart+N*V,P=ee-re*V,S=ee+re*(1-V);q.update({visibleTimeStart:P,visibleTimeEnd:S}),(D=Je.current)==null||D.updateBounds(P,S),O.markAllDirty(),lt(),dt("zoom")}Me.current.lastDistance=$}},y=()=>{Me.current.lastDistance=null,Me.current.lastCenter=null};return o.addEventListener("touchstart",v,{passive:!1}),o.addEventListener("touchmove",u,{passive:!1}),o.addEventListener("touchend",y),()=>{o.removeEventListener("touchstart",v),o.removeEventListener("touchmove",u),o.removeEventListener("touchend",y)}},[O,lt,dt]);const Si=h.useCallback(o=>{var $;const l=o.currentTarget,p=l.getBoundingClientRect(),v=o.clientX-p.left,u=o.clientY-p.top;if(ot.current=v,Dt.current={x:o.clientX,y:o.clientY},ae.current){const W=o.clientX-ae.current.startX,x=o.clientY-ae.current.startY;if(!Ee.current&&(Math.abs(W)>=Ot||Math.abs(x)>=Ot)&&(Ee.current=!0,l.style.cursor="grabbing",l.setPointerCapture(o.pointerId)),Ee.current){const V=o.clientX-ae.current.lastX,ne=o.clientY-ae.current.lastY;ae.current.lastX=o.clientX,ae.current.lastY=o.clientY,Math.abs(V)>0&&ze(-V),Math.abs(ne)>0&&Qe(-ne)}return}if(te.isPending()){if(te.update(v,u),te.isActive()){const W=te.getState();if(W&&W.mode==="move"&&A.current.canChangeGroup){const x=gt(u,z.current,A.current.groups);x&&te.setCurrentGroup(x.id)}O.markDirty("overlay")}return}A.current.showCursorLine&&O.markDirty("overlay");const y=A.current,E=Le(v,u,z.current,y.intervalTree,y.layoutEngine,y.groups),D=E==null?void 0:E.id;if(D!==We.current&&(We.current=D,O.markDirty("items"),($=y.onItemHover)==null||$.call(y,D??null,o.nativeEvent)),E){const W=zt(v,E,z.current),x=Lt(E,W,y.canResize,y.canMove);l.style.cursor=x==="resize-left"||x==="resize-right"?"col-resize":x==="move"?"grab":"default"}else l.style.cursor="default"},[te,O,ze,Qe]),ki=h.useCallback(o=>{const l=A.current,p=o.currentTarget.getBoundingClientRect(),v=o.clientX-p.left,u=o.clientY-p.top,y=Le(v,u,z.current,l.intervalTree,l.layoutEngine,l.groups);if(!y){ae.current={startX:o.clientX,startY:o.clientY,lastX:o.clientX,lastY:o.clientY},Ee.current=!1;return}const E=zt(v,y,z.current),D=Lt(y,E,l.canResize,l.canMove);D&&te.startInteraction(y,D,v,u)},[te]),Ci=h.useCallback(o=>{var E,D,$,W;const l=o.currentTarget;if(ae.current){const x=Ee.current;if(ae.current=null,Ee.current=!1,l.style.cursor="default",x)return}if(te.isActive()){const x=te.getState(),V=z.current,ne=V.canvasWidth/(V.visibleTimeEnd-V.visibleTimeStart);if(x){const q=A.current.moveResizeValidator,N=A.current;if(x.mode==="move"){const re=ti(x,V,N),ee=te.endMove(ne);if(ee){const P=q?q("move",x.item.id,re):re,S=N.hierarchyEngine.getMoveDelta(x.item.id,P);(E=N.onItemMove)==null||E.call(N,x.item.id,P,ee.newGroupId,S.length>0?S:void 0)}}else{const{edge:re,time:ee}=ii(x,V,N);if(te.endResize(ne)){const S=q?q("resize",x.item.id,ee,re):ee;(D=N.onItemResize)==null||D.call(N,x.item.id,S,re)}}}l.style.cursor="default",O.markDirty("overlay");return}te.isPending()&&te.cancel();const p=l.getBoundingClientRect(),v=o.clientX-p.left,u=o.clientY-p.top,y=Le(v,u,z.current,A.current.intervalTree,A.current.layoutEngine,A.current.groups);y&&((W=($=A.current).onItemClick)==null||W.call($,y.id,o.nativeEvent))},[te,O]),Ei=h.useCallback(o=>{var E,D;const l=o.currentTarget.getBoundingClientRect(),p=o.clientX-l.left,v=o.clientY-l.top,u=A.current,y=Le(p,v,z.current,u.intervalTree,u.layoutEngine,u.groups);if(y)(E=u.onItemDoubleClick)==null||E.call(u,y.id,o.nativeEvent);else{const $=gt(v,z.current,u.groups),W=z.current.xToTime(p);$&&((D=u.onCanvasDoubleClick)==null||D.call(u,$.id,W))}},[]),wi=h.useCallback(o=>{var E,D;o.preventDefault();const l=o.currentTarget.getBoundingClientRect(),p=o.clientX-l.left,v=o.clientY-l.top,u=A.current,y=Le(p,v,z.current,u.intervalTree,u.layoutEngine,u.groups);if(y)(E=u.onItemContextMenu)==null||E.call(u,y.id,o.nativeEvent);else{const $=gt(v,z.current,u.groups),W=z.current.xToTime(p);$&&((D=u.onCanvasContextMenu)==null||D.call(u,$.id,W,o.nativeEvent))}},[]),Hi=h.useCallback(()=>{var o,l;ae.current=null,Ee.current=!1,ot.current=null,Fe.current&&(Fe.current.style.cursor="default"),We.current!==void 0&&(We.current=void 0,O.markDirty("items"),(l=(o=A.current).onItemHover)==null||l.call(o,null,new PointerEvent("pointerleave"))),A.current.showCursorLine&&O.markDirty("overlay")},[O]),Ri=h.useMemo(()=>{const o=[];return h.Children.forEach(ye,l=>{var v;if(!h.isValidElement(l))return;if(((v=l.type)==null?void 0:v.displayName)==="TimelineHeaders"){const u=l.props;o.push(h.cloneElement(l,{visibleTimeStart:u.visibleTimeStart??Pt,visibleTimeEnd:u.visibleTimeEnd??Xt,canvasWidth:u.canvasWidth??Te,sidebarWidth:u.sidebarWidth??c,theme:u.theme??ge,timezone:u.timezone??Ne,onZoomToInterval:u.onZoomToInterval??((y,E)=>{var D,$,W,x;z.current.update({visibleTimeStart:y,visibleTimeEnd:E}),O.markAllDirty(),Ie(),($=(D=A.current).onTimeChange)==null||$.call(D,y,E),(x=(W=A.current).onZoom)==null||x.call(W,y,E)})}))}}),o},[ye,Pt,Xt,Te,c,ge,Ne,O,Ie]),jt=h.useRef(!1);h.useEffect(()=>{jt.current||(jt.current=!0,O.markAllDirty())},[O]),h.useImperativeHandle(t,()=>({captureToCanvas({timeStart:o,timeEnd:l,scale:p,sidebarWidth:v}){const u=A.current,y=28,E=y*3,D=u.groups.map(G=>u.layoutEngine.getGroupHeight(G.id)),$=[0];for(let G=0;G<D.length;G++)$.push($[G]+D[G]);const W=$[D.length],x=z.current,V=u.canvasWidth/(x.visibleTimeEnd-x.visibleTimeStart),ne=l-o,q=Math.max(u.canvasWidth,Math.round(ne*V)),N=(v+q)*p,re=(E+W)*p,ee=document.createElement("canvas");ee.width=N,ee.height=re;const P=ee.getContext("2d");P.scale(p,p);for(let G=0;G<u.groups.length;G++){const pe=u.groups[G],ve=D[G],j=E+$[G];if(u.rowStyle){const oe=u.rowStyle(pe);oe!=null&&oe.backgroundColor&&(P.fillStyle=oe.backgroundColor,P.fillRect(0,j,v,ve))}const se=pe.type;let ie="400",K=8;se==="project"?ie="700":se==="CAG"?ie="600":se==="CA"&&(ie="400",K=24),P.fillStyle="#111",P.font=`${ie} 12px sans-serif`,P.textBaseline="middle",P.fillText(pe.title,K,j+ve/2,v-K-4)}const S=(G,pe,ve)=>{var ie,K;P.fillStyle=((ie=u.theme.header)==null?void 0:ie.bg)??"#f5f5f5",P.fillRect(v,G,q,y),P.strokeStyle=((K=u.theme.grid)==null?void 0:K.line)??"#e0e0e0",P.lineWidth=1,P.strokeRect(v,G,q,y);let j=fe(o,u.timezone).startOf(ve);j.valueOf()<o&&(j=j.add(1,ve));const se=q/(l-o);for(;j.valueOf()<l;){const oe=j.add(1,ve),le=v+(j.valueOf()-o)*se,de=v+(Math.min(oe.valueOf(),l)-o)*se-le;P.beginPath(),P.moveTo(le,G),P.lineTo(le,G+y),P.stroke(),P.fillStyle="#333",P.font="600 11px sans-serif",P.textBaseline="middle",P.textAlign="center",P.fillText(pe(j),le+de/2,G+y/2,de-4),j=oe}P.textAlign="start"};S(0,G=>G.format("YYYY"),"year"),S(y,G=>G.format("MM"),"month"),S(y*2,G=>String(G.isoWeek()),"week");const Xe=new mt({visibleTimeStart:o,visibleTimeEnd:l,canvasWidth:q,canvasHeight:W,sidebarWidth:0,lineHeight:u.lineHeight,groupCount:u.groups.length,buffer:1,scrollTop:0,groupHeights:D});return P.save(),P.translate(v,E),P.beginPath(),P.rect(0,0,q,W),P.clip(),De.draw(P,Xe,u.groups,u.theme,u.dayStyle,u.rowStyle,u.highlights,u.timezone),Oe.draw(P,Xe,u.groups,u.items,u.intervalTree,u.layoutEngine,u.itemRenderer,u.groupRenderer,u.theme,u.selected,void 0,u.dependencies,u.summaryRenderer,u.hierarchyEngine),Pe.draw(P,Xe,u.theme,{cursorX:null,snapX:null,markers:Be.current,interaction:null}),P.restore(),ee}}),[De,Oe,Pe]),h.useEffect(()=>{const o={captureToCanvas({timeStart:l,timeEnd:p,scale:v,sidebarWidth:u}){var ve;const y=A.current,E=28,D=E*3,$=y.groups.map(j=>y.layoutEngine.getGroupHeight(j.id)),W=[0];for(let j=0;j<$.length;j++)W.push(W[j]+$[j]);const x=W[$.length],V=z.current,ne=y.canvasWidth/(V.visibleTimeEnd-V.visibleTimeStart),q=p-l,N=Math.max(y.canvasWidth,Math.round(q*ne)),re=u+N,ee=D+x,P=document.createElement("canvas");P.width=re*v,P.height=ee*v;const S=P.getContext("2d");S.scale(v,v),S.fillStyle="#FFFFFF",S.fillRect(0,0,re,ee),S.save(),S.beginPath(),S.rect(0,0,u,ee),S.clip(),S.fillStyle="#F9FAFB",S.fillRect(0,0,u,D),S.strokeStyle="#E5E7EB",S.lineWidth=1,S.strokeRect(0,0,u,D);for(let j=0;j<y.groups.length;j++){const se=y.groups[j],ie=$[j],K=D+W[j],oe=(ve=y.rowStyle)==null?void 0:ve.call(y,se);S.fillStyle=(oe==null?void 0:oe.backgroundColor)??(j%2===0?"#FFFFFF":"#F7F7F7"),S.fillRect(0,K,u,ie),S.strokeStyle="#E5E5E5",S.lineWidth=.5,S.beginPath(),S.moveTo(0,K+ie),S.lineTo(u,K+ie),S.stroke();const le=se.type??"";let we=8,de="400",He=11;le==="project"?(de="700",He=12):le==="control_area_group"?de="600":le==="control_area"&&(we=24),S.fillStyle="#374151",S.font=`${de} ${He}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,S.textBaseline="middle";const Di=typeof se.title=="string"?se.title:String(se.title);S.fillText(Di,we,K+ie/2,u-we-8)}S.strokeStyle="#E5E7EB",S.lineWidth=1,S.beginPath(),S.moveTo(u,0),S.lineTo(u,ee),S.stroke(),S.restore(),S.save(),S.beginPath(),S.rect(u,0,N,D),S.clip();const Xe=p-l,G=[{unit:"year",row:0},{unit:"month",row:1},{unit:"week",row:2}];for(const{unit:j,row:se}of G){const ie=se*E;S.fillStyle="#F9FAFB",S.fillRect(u,ie,N,E);let K=fe(l,y.timezone).startOf(j);const oe=fe(p,y.timezone).add(1,j);for(;K.isBefore(oe);){const le=K.add(1,j),we=u+(K.valueOf()-l)/Xe*N,de=(le.valueOf()-K.valueOf())/Xe*N;S.strokeStyle="#E5E7EB",S.lineWidth=.5,S.strokeRect(we,ie,de,E);let He;j==="year"?He=K.format("YYYY"):j==="month"?He=K.format("MM"):He=`${K.week()}`,S.fillStyle="#6c737f",S.font=j==="year"?'600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif':'400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',S.textBaseline="middle",S.textAlign="center",de>20&&S.fillText(He,we+de/2,ie+E/2),K=le}}S.textAlign="start",S.restore(),S.save(),S.beginPath(),S.rect(u,D,N,x),S.clip(),S.translate(u,D);const pe=new mt({visibleTimeStart:l,visibleTimeEnd:p,canvasWidth:N,canvasHeight:x,sidebarWidth:0,lineHeight:y.lineHeight,groupCount:y.groups.length,buffer:1,scrollTop:0,groupHeights:$});return De.draw(S,pe,y.groups,y.theme,y.dayStyle,y.rowStyle,y.highlights,y.timezone),Oe.draw(S,pe,y.groups,y.items,y.intervalTree,y.layoutEngine,y.itemRenderer,y.groupRenderer,y.theme,y.selected,void 0,y.dependencies,y.summaryRenderer,y.hierarchyEngine),Pe.draw(S,pe,y.theme,{cursorX:null,markers:Be.current}),S.restore(),P}};Ge==null||Ge(o)},[Ge,De,Oe,Pe]);const Ii={position:"relative",width:Te,height:ce,overflow:"hidden",cursor:"default"},ht={position:"absolute",top:0,left:0};return U.jsxs("div",{ref:Ht,style:{display:"flex",flexDirection:"column",width:"100%",position:"relative"},children:[di?U.jsxs("div",{style:{position:"absolute",top:0,left:0,zIndex:9999,padding:"2px 6px",fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1.4,color:"#fff",background:"rgba(17, 24, 39, 0.78)",borderBottomRightRadius:4,pointerEvents:"none",userSelect:"none"},children:["v","0.8.1"," · ","08:37:39"]}):null,Ri,U.jsxs("div",{ref:Rt,style:{display:"flex",overflow:"hidden",maxHeight:_e??void 0},children:[U.jsx(Ut,{groups:n,width:c,lineHeight:a,groupHeights:Ce,scrollTop:$t,canvasHeight:ce,theme:ge,groupRenderer:B,onScroll:o=>{z.current.update({scrollTop:o}),O.markDirty("grid"),O.markDirty("items"),O.markDirty("overlay"),Ze(o)}}),U.jsxs("div",{ref:Fe,style:Ii,onPointerMove:Si,onPointerDown:ki,onPointerUp:Ci,onDoubleClick:Ei,onContextMenu:wi,onPointerLeave:Hi,children:[U.jsx("canvas",{ref:Ct,style:{...ht,zIndex:0}}),U.jsx("canvas",{ref:Et,style:{...ht,zIndex:1}}),U.jsx("canvas",{ref:wt,style:{...ht,zIndex:2}})]}),nt&&St?U.jsx(Ut,{groups:n,width:nt,lineHeight:a,groupHeights:Ce,scrollTop:$t,canvasHeight:ce,theme:ge,groupRenderer:St,onScroll:o=>{z.current.update({scrollTop:o}),O.markDirty("grid"),O.markDirty("items"),O.markDirty("overlay"),Ze(o)}}):null]})]})}));function oi({children:i,theme:e,className:t,classNames:n,style:r,visibleTimeStart:d,visibleTimeEnd:s,canvasWidth:c,sidebarWidth:a=0,onZoomToInterval:b,timezone:w}){const m=h.Children.map(i,f=>{var M;if(!h.isValidElement(f))return f;if(((M=f.type)==null?void 0:M.displayName)==="DateHeader"){const g=f.props,H=h.cloneElement(f,{visibleTimeStart:g.visibleTimeStart??d,visibleTimeEnd:g.visibleTimeEnd??s,canvasWidth:g.canvasWidth??c,theme:g.theme??e,onZoomToInterval:g.onIntervalClick??g.onZoomToInterval??b,timezone:g.timezone??w});return U.jsxs("div",{style:{display:"flex"},children:[U.jsx("div",{style:{width:a,flexShrink:0}}),U.jsx("div",{style:{flex:1,overflow:"hidden"},children:H})]})}return f});return U.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:m})}oi.displayName="TimelineHeaders";var ai={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(tt,function(){var t="week",n="year";return function(r,d,s){var c=d.prototype;c.week=function(a){if(a===void 0&&(a=null),a!==null)return this.add(7*(a-this.week()),"day");var b=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var w=s(this).startOf(n).add(1,n).date(b),m=s(this).endOf(t);if(w.isBefore(m))return 1}var f=s(this).startOf(n).date(b).startOf(t).subtract(1,"millisecond"),k=this.diff(f,t,!0);return k<0?s(this).startOf("week").week():Math.ceil(k)},c.weeks=function(a){return a===void 0&&(a=null),this.week(a)}}})})(ai);var tn=ai.exports;const nn=it(tn);$e.extend(nn);const rn={year:30,month:30,week:20,day:15,hour:30};function li({unit:i,visibleTimeStart:e=0,visibleTimeEnd:t=0,canvasWidth:n=0,theme:r,height:d=28,className:s,labelFormat:c,onIntervalClick:a,minCellWidth:b,onZoomToInterval:w,timezone:m}){const f=h.useMemo(()=>{if(!e||!t||!n)return[];const M=t-e,g=b??rn[i];if(g>0){const T=fe(e,m).startOf(i);if((T.add(1,i).valueOf()-T.valueOf())/M*n<g)return[]}const H=[];let X=fe(e,m).startOf(i).subtract(1,i);const Y=fe(t,m).add(2,i).valueOf();for(;X.valueOf()<Y;){const T=X.add(1,i),R=X.valueOf(),C=T.valueOf(),_=(R-e)/M*n,B=(C-R)/M*n,I=sn(X,T,i,c);H.push({start:R,end:C,label:I,left:_,width:B}),X=T}return H},[e,t,n,i,c,b,m]),k=h.useCallback((M,g)=>{a?a(M,g):w&&w(M,g)},[a,w]);return f.length===0?null:U.jsx("div",{style:{display:"flex",position:"relative",height:d,overflow:"hidden"},children:f.map(M=>U.jsx("div",{className:s,onClick:()=>k(M.start,M.end),style:{position:"absolute",left:M.left,width:M.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:U.jsx("span",{children:M.label})},M.start))})}li.displayName="DateHeader";function sn(i,e,t,n,r){return typeof n=="function"?n(i.toDate(),e.toDate(),t):typeof n=="string"?i.format(n):on(i,t)}function on(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 ui({width:i,children:e,style:t}){const n=()=>({style:{width:i,...t}});return e?U.jsx(U.Fragment,{children:e({getRootProps:n})}):U.jsx("div",{style:{width:i}})}ui.displayName="SidebarHeader";function ci({children:i}){return U.jsx(U.Fragment,{children:i})}ci.displayName="CustomHeader";exports.CanvasTimeline=en;exports.CustomHeader=ci;exports.CustomMarker=si;exports.DEFAULT_THEME=be;exports.DateHeader=li;exports.HierarchyEngine=Kt;exports.SidebarHeader=ui;exports.TimelineHeaders=oi;exports.TodayMarker=ri;
2
2
  //# sourceMappingURL=canvas-timeline.cjs.js.map