@xpyjs/gantt-core 0.0.1-alpha.1 → 0.0.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +1 -1
- package/dist/x-gantt.js +813 -753
- package/dist/x-gantt.umd.cjs +2 -2
- package/package.json +2 -2
- package/types/XGantt.d.ts +13 -8
- package/types/event/index.d.ts +5 -3
- package/types/index.d.ts +3 -2
- package/types/rendering/Renderer.d.ts +1 -0
- package/types/rendering/chart/ChartLink.d.ts +2 -0
- package/types/rendering/table/TableRow.d.ts +1 -1
- package/types/types/event.d.ts +1 -0
- package/types/types/options.d.ts +14 -7
- package/types/types/table.d.ts +1 -1
package/dist/x-gantt.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(R,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("dayjs"),require("lodash-es"),require("konva")):typeof define=="function"&&define.amd?define(["exports","dayjs","lodash-es","konva"],D):(R=typeof globalThis<"u"?globalThis:R||self,D(R.XGantt={},R.dayjs,R._,R.Konva))})(this,function(R,D,E,S){"use strict";var Oe=Object.defineProperty;var De=(R,D,E)=>D in R?Oe(R,D,{enumerable:!0,configurable:!0,writable:!0,value:E}):R[D]=E;var r=(R,D,E)=>De(R,typeof D!="symbol"?D+"":D,E);const it="0.0.1-alpha.1";function vt(){const f="#eca710",t="#ffffff",e="#e7209e",i="#ffffff",s="#1c42e8";[" __ __ _____ _____ _____ _____ _____ ","| | || __|| _ || | ||_ _||_ _|","|- -|| | || || | | | | | | | ","|__|__||_____||__|__||_|___| |_| |_| "].forEach(o=>{console.log(`%c${o}`,`color: ${f}; font-weight: bold; font-family: monospace;`)}),console.log(`%c 🚀 欢迎使用 XGantt %c Version: ${it} `,`background-color: ${e}; color: ${t}; padding: 2px 4px; border-radius: 6px 0 0 6px; font-weight: bold; margin: 4px 0;`,`background-color: ${s}; color: ${i}; padding: 2px 4px; border-radius: 0 6px 6px 0; font-weight: normal; margin: 4px 0;`)}const W=class W{static setOptions(t){W.options={...W.options,...t}}static getLevel(){return W.options.level}static debug(...t){W.logWithLevel(1,console.debug,...t)}static info(...t){W.logWithLevel(2,console.info,...t)}static warn(...t){W.logWithLevel(3,console.warn,...t)}static error(...t){W.logWithLevel(4,console.error,...t)}static assert(t,...e){if(!t&&W.options.level<=4){const i=W.formatArgs("Assertion failed:",...e);console.error(...i)}}static getMessage(...t){return W.formatArgs(...t).join("")}static exception(...t){return new Error(W.getMessage(...t))}static logWithLevel(t,e,...i){if(W.options.level<=t){const s=W.formatArgs(...i);e(...s)}}static formatArgs(...t){const e=[W.Prefix];return W.options.showTimestamp&&e.unshift(`[${D().format("YYYY-MM-DD HH:mm:ss.SSS")}]`),[e.join(""),...t]}};r(W,"Prefix","[XGantt]"),r(W,"options",{level:2,showTimestamp:!1});let C=W;const V=()=>({data:[],links:{show:!1,key:"id",data:[],distance:20,dash:[6,3],width:1,gap:5,arrow:{width:6,height:8},radius:3,create:{enabled:!1,mode:"hover",radius:3,width:2,from:!0,to:!0}},fields:{id:"id",startTime:"startTime",endTime:"endTime",name:"name",progress:"progress",children:"children"},selection:{enabled:!1,includeSelf:!0},expand:{show:!0,enabled:!0},dateFormat:"YYYY-MM-DD HH:mm:ss",locale:"en",unit:"day",table:{width:100,ellipsis:!0,align:"center",headerAlign:"center",emptyText:"-"},chart:{autoCellWidth:!1,cellWidth:"normal"},primaryColor:"#eca710",border:{color:"#e5e5e5"},header:{height:80,color:"#000",fontSize:14,fontWeight:600,fontFamily:"Arial"},row:{height:30,indent:16,hover:{backgroundColor:"#000",opacity:.05},select:{backgroundColor:"#000",opacity:.1}},bar:{height:20,move:{byUnit:!1,link:{child:"none",parent:"none"}}},today:{show:!0,type:"line",backgroundColor:"lightblue",opacity:1,width:1},weekend:{show:!0,backgroundColor:"#c9c9c9",opacity:.1},holiday:{opacity:.1}});class St{constructor(){r(this,"options",V())}getOptions(){return this.options}setOptions(t,e={merge:!0}){var i;this.options=e.merge?E.merge(V(),this.options,t):E.merge(V(),t),E.isArray((i=t.links)==null?void 0:i.data)&&(this.options.links.data=t.links.data)}update(t){this.setOptions(t)}getRowBackgroundColor(t){var s;let e="";const i=(s=this.options.row)==null?void 0:s.backgroundColor;return E.isString(i)?e=i:E.isArray(i)&&i.length>0?e=i[t.level]:E.isFunction(i)&&(e=i(t.getEmitData())),e}}class kt{constructor(){r(this,"events",new Map)}on(t,e){var i;this.events.has(t)||this.events.set(t,[]),(i=this.events.get(t))==null||i.push(e)}emit(t,...e){var i;this.events.has(t)&&((i=this.events.get(t))==null||i.forEach(s=>s(...e)))}off(t,e){var i;this.events.has(t)&&this.events.set(t,((i=this.events.get(t))==null?void 0:i.filter(s=>s!==e))||[])}offAll(){this.events.clear()}}var b=(f=>(f.COLUMN_WIDTH_CHANGE="column-width-change",f.MOVE_GUIDELINE="move-guideline",f.SHOW_GUIDELINE="show-guideline",f.HIDE_GUIDELINE="hide-guideline",f.SCROLL="scroll",f.CHART_OFFSET_CHANGE="chart_offset_change",f.DATA_UPDATE="data-update",f.VIEW_UPDATE="view-update",f.UPDATE_TABLE_HEADER="update_table_header",f.UPDATE_TABLE_BODY="update_table_body",f.UPDATE_CHART_HEADER="update_chart_header",f.UPDATE_TASK="update_task",f.UPDATE_LINK="update_link",f.CREATE_LINK="create_link",f.TASK_SELECTED="task_selected",f.TASK_UNSELECTED="task_unselected",f.SELECT_LINK="select_link",f.CHECK_TASK="check_task",f.ROW_CLICK="row-click",f.ROW_DBL_CLICK="row-dbl-click",f.ROW_CONTEXTMENU="row-contextmenu",f.SLIDER_CLICK="slider-click",f.SLIDER_DBL_CLICK="slider-dbl-click",f.SLIDER_CONTEXTMENU="slider-contextmenu",f.ROW_HIGHLIGHT="row-highlight",f.ROW_UNHIGHLIGHT="row-unhighlight",f.TASK_DRAG_START="task-drag-start",f.TASK_DRAG_MOVE="task-drag-move",f.TASK_DRAG_END="task-drag-end",f.ERROR="error",f))(b||{}),N=(f=>(f.LINK_NOT_ALLOWED="link:not-allowed",f.LINK_SAME="link:same",f.LINK_EXIST="link:exist",f))(N||{});function U(){return Math.random().toString(36).substring(2,15)}class q{constructor(t,e,i,s,n){r(this,"__key__",U());r(this,"id");r(this,"name");r(this,"startTime");r(this,"endTime");r(this,"progress");r(this,"expanded");r(this,"children");r(this,"parent");r(this,"level");r(this,"flatIndex");r(this,"data");r(this,"fields");this.store=t,this.event=e,this.fields=this.store.getOptionManager().getOptions().fields,this.id=n||i[this.fields.id]||U(),this.data=i,this.name=i[this.fields.name]||"";const o=i[this.fields.startTime];this.startTime=o?D(o):void 0;const h=i[this.fields.endTime];this.endTime=h?D(h):void 0,this.progress=i[this.fields.progress],this.expanded=this.store.getOptionManager().getOptions().expand.show?this.store.getOptionManager().getOptions().expand.enabled:!0,this.children=[],this.level=s&&s.level!==void 0?s.level+1:0,this.parent=s,this.flatIndex=0,this.store.updateTime(this.startTime,this.endTime)}getField(t){if(!t||E.isString(t)&&t.trim()==="")return;if(!t.includes("."))return this.data[t];const e=t.split(".");let i=this.data;for(let s=0;s<e.length;s++){const n=e[s];if(i==null||typeof i!="object"||!(n in i))return;i=i[n]}return E.isObject(i)?E.cloneDeep(i):i}updateData(t){this.data=t,t[this.fields.name]&&(this.name=t[this.fields.name]),t[this.fields.startTime]&&(this.startTime=D(t[this.fields.startTime])),t[this.fields.endTime]&&(this.endTime=D(t[this.fields.endTime])),t[this.fields.progress]!==void 0&&(this.progress=t[this.fields.progress]),this.event.emit(b.UPDATE_TASK,this)}updateTime(t,e){var s,n;this.startTime=t,this.endTime=e;const i=(n=(s=this.store)==null?void 0:s.getOptionManager().getOptions())==null?void 0:n.dateFormat;this.data[this.fields.startTime||"startTime"]=this.startTime.format(i),this.data[this.fields.endTime||"endTime"]=this.endTime.format(i),this.event.emit(b.UPDATE_TASK,this)}clone(){return new q(this.store,this.event,E.cloneDeep(this.data),this.parent,this.id)}getEmitData(){return{data:this.data,$index:this.flatIndex,level:this.level+1}}getAllChildren(){const t=[],e=i=>{i.forEach(s=>{t.push(s),E.isArray(s.children)&&s.children.length>0&&e(s.children)})};return e(this.children),t}}class Lt{constructor(t,e){r(this,"rawData",[]);r(this,"tasks",[]);r(this,"taskMap",new Map);r(this,"visibleTasksCache",[]);r(this,"isDirty",!0);r(this,"collapsedTaskIds",new Set);r(this,"selectedTaskId",null);r(this,"checkedList",[]);r(this,"dataLevel",0);this.store=t,this.event=e}setData(t,e=!1){this.rawData=t,this.initTasks(e),this.invalidateCache(),this.event.emit(b.DATA_UPDATE)}initTasks(t=!1){this.dataLevel=0,t?(this.tasks=[],this.taskMap.clear(),this.collapsedTaskIds.clear(),this.rawData.forEach(e=>{this.tasks.push(this.createTask(e))})):this.updateTask(this.rawData,this.tasks)}createTask(t,e){const i=this.store.getOptionManager().getOptions().fields,s=new q(this.store,this.event,t,e);return Array.isArray(t[i.children])&&(s.children=t[i.children].map(n=>this.createTask(n,s))),this.taskMap.set(s.id,s),this.dataLevel=Math.max(this.dataLevel,s.level),s}updateTask(t,e,i){let s=0;for(;s<t.length;){const n=t[s],o=e[s];if(n&&!o){const h=this.createTask(n,i);e.push(h),this.taskMap.set(h.id,h),this.dataLevel=Math.max(this.dataLevel,h.level)}else!n&&o?(this.taskMap.delete(o.id),e.splice(s,1)):n&&o&&(n[this.store.getOptionManager().getOptions().fields.id]===o.id?(o.updateData(n),this.dataLevel=Math.max(this.dataLevel,o.level)):(this.taskMap.delete(o.id),e[s]=this.createTask(n,o.parent),this.taskMap.set(e[s].id,e[s]),this.dataLevel=Math.max(this.dataLevel,e[s].level)));if(n[this.store.getOptionManager().getOptions().fields.children]){const h=n[this.store.getOptionManager().getOptions().fields.children];if(o&&o.children)this.updateTask(h,o.children,o.parent);else{const a=h.map(d=>this.createTask(d,e[s]));e[s].children=a}}else o&&o.children&&(o.children=[]);s++}}getData(){return this.rawData}getTasks(t=!0){return t?this.tasks:Array.from(this.taskMap.values())}getTaskById(t){return this.taskMap.get(t)}expandTask(t,e=!1){const i=this.getTaskById(t);return i?(i.expanded=!i.expanded,i.expanded?this.collapsedTaskIds.delete(i.id):this.collapsedTaskIds.add(i.id),e&&i.children&&i.children.length>0&&i.children.forEach(s=>{this.expandTask(s.id,e)}),this.invalidateCache(),this.event.emit(b.VIEW_UPDATE),!0):!1}getVisibleTasks(){if(!this.isDirty&&this.visibleTasksCache.length>0)return this.visibleTasksCache;const t=[];let e=0;const i=(s,n)=>{this.collapsedTaskIds.has(s.id)&&s.expanded&&(s.expanded=!1),s.flatIndex=e++,t.push(s),s.expanded&&s.children&&s.children.length>0&&s.children.forEach(o=>i(o))};return this.tasks.forEach(s=>i(s)),this.visibleTasksCache=t,this.isDirty=!1,t}getVisibleSize(){return this.getVisibleTasks().length}isTaskVisible(t){return this.getVisibleTasks().some(e=>e.id===t.id)}clear(){this.rawData=[],this.tasks=[],this.taskMap.clear(),this.visibleTasksCache=[],this.isDirty=!0,this.collapsedTaskIds.clear(),this.event.emit(b.DATA_UPDATE)}invalidateCache(){this.isDirty=!0}selectTask(t){const e=this.getTaskById(t);return e?(this.selectedTaskId===t||(this.unselectTask(),this.selectedTaskId=t,this.event.emit(b.TASK_SELECTED,e)),!0):!1}unselectTask(){if(this.selectedTaskId){const t=this.selectedTaskId;this.selectedTaskId=null,this.event.emit(b.TASK_UNSELECTED,t)}}isTaskSelected(t){return this.selectedTaskId===t}getSelectedTask(){return this.selectedTaskId?this.getTaskById(this.selectedTaskId):void 0}getCheckedList(){return this.checkedList}updateCheckedList(t,e){const i=this.checkedList.findIndex(s=>s.id===e.id);t?i===-1?this.checkedList.push(e):this.checkedList.splice(i,1,e):i!==-1&&this.checkedList.splice(i,1)}toggleAllChecked(t){t?this.checkedList=this.getVisibleTasks().slice():this.checkedList=[]}isTaskChecked(t){return this.checkedList.findIndex(e=>e.id===t.id)!==-1}updateTaskTime(t,e,i,s,n=[]){let o=e,h=i;const a=this.store.getOptionManager().getOptions().bar.move.link.child,d=this.store.getOptionManager().getOptions().bar.move.link.parent,u=this.store.getTimeAxis().getCellUnit();let l=t.parent;for(;d!=="none"&&l;){if(d==="expand"){let p=l.startTime||o,m=l.endTime||h;(!l.startTime||o.isBefore(l.startTime))&&(p=o),(!l.endTime||h.isAfter(l.endTime))&&(m=h),(l.startTime===void 0||l.endTime===void 0||!p.isSame(l.startTime)||!m.isSame(l.endTime))&&(n.findIndex(g=>g.id===l.id)===-1&&n.push(l.clone()),l.updateTime(p,m))}else d==="strict"&&(l.startTime&&o.isBefore(l.startTime)&&(o=l.startTime,h.isSameOrBefore(o)&&(h=o.add(1,u))),l.endTime&&h.isAfter(l.endTime)&&(h=l.endTime,o.isAfter(h)&&(o=h.subtract(1,u))));l=l.parent}let c=t.children||[];for(;a!=="none"&&c.length>0;){const p=[];c.forEach(m=>{let g=m.startTime||o,x=m.endTime||h,T=o.diff(t.startTime),v=h.diff(t.endTime);a==="scale"?s==="both"?(n.findIndex(y=>y.id===m.id)===-1&&n.push(m.clone()),m.updateTime(g.add(T),x.add(v))):s==="left"?(g=g.add(T),g.isSameOrAfter(x.subtract(1,u))&&(x.isBefore(t.endTime)?x=g.add(1,u):g=x.subtract(1,u),g.isSameOrBefore(o)&&(o=g)),n.findIndex(y=>y.id===m.id)===-1&&n.push(m.clone()),m.updateTime(g,x)):s==="right"&&(x=x.add(v),x.isSameOrBefore(g.add(1,u))&&(g.isAfter(t.startTime)?g=x.subtract(1,u):x=g.add(1,u)),x.isSameOrAfter(h)&&(h=x),n.findIndex(y=>y.id===m.id)===-1&&n.push(m.clone()),m.updateTime(g,x)):a==="fixed"&&(s==="both"?(n.findIndex(y=>y.id===m.id)===-1&&n.push(m.clone()),m.updateTime(g.add(T),x.add(v))):s==="left"?g.isSameOrBefore(o)&&(g=o,g.isSameOrAfter(x.subtract(1,u))&&(x.isBefore(t.endTime)?x=g.add(1,u):g=x.subtract(1,u),g.isSameOrBefore(o)&&(o=g)),n.findIndex(y=>y.id===m.id)===-1&&n.push(m.clone()),m.updateTime(g,x)):s==="right"&&x.isSameOrAfter(h)&&(x=h,x.isSameOrBefore(g.add(1,u))&&(g.isAfter(t.startTime)?g=x.subtract(1,u):x=g.add(1,u)),x.isSameOrAfter(h)&&(h=x),n.findIndex(y=>y.id===m.id)===-1&&n.push(m.clone()),m.updateTime(g,x))),m.children&&m.children.length>0&&p.push(...m.children)}),c=p}n.findIndex(p=>p.id===t.id)===-1&&n.push(t.clone()),t.updateTime(o,h)}}function A(f,t,e){if(!Number.isFinite(f)||!Number.isFinite(t)||!Number.isFinite(e))return Number.isFinite(t)?t:0;const i=Math.min(t,e),s=Math.max(t,e);return Math.min(Math.max(i,f),s)}function st(f,t){let e=f;return E.isString(e)&&(/%$/.test(e)?e=t*parseFloat(e)/100:e=parseFloat(e)),isNaN(e)?0:e}function nt(f,t){if(t===0)throw new Error("基准值不能为0");if(Math.abs(f)<=t/2)return 0;const e=Math.floor(f/t),i=Math.ceil(f/t),s=e*t,n=i*t,o=Math.abs(f-s),h=Math.abs(f-n);return o<=h?s:n}function Q(f,t=4){return typeof f=="number"?[f,f,f,f]:Array.isArray(f)?[f[0]??t,f[1]??t,f[2]??t,f[3]??t]:[t,t,t,t]}function Et(f,t=100){if(!Number.isFinite(f)||!Number.isFinite(t)||t===0||f<0)return 0;const e=f/Math.abs(t);return Math.min(e,1)}function Mt(f,t=2,e=!1){const i=f.toFixed(t);return e?i:i.replace(/\.?0+$/,"")}function Ct(f){var s;if(typeof f=="object"&&f!==null)return{r:A(f.r??0,0,255),g:A(f.g??0,0,255),b:A(f.b??0,0,255),a:A(f.a??1,0,1)};if(typeof f!="string")return C.warn(`Invalid color value type: ${typeof f}`),null;let t=f.trim();const e=(s=document==null?void 0:document.createElement("canvas"))==null?void 0:s.getContext("2d");if(e&&(e.fillStyle=t,t=e.fillStyle),t.startsWith("#")){const n=t.slice(1);let o,h,a,d,u=1;try{o=parseInt(n,16)}catch{return C.warn(`Invalid hex color: ${f}`),null}if(n.length===3)h=(o>>8&15)*17,a=(o>>4&15)*17,d=(o&15)*17;else if(n.length===6)h=o>>16&255,a=o>>8&255,d=o&255;else if(n.length===8)h=o>>24&255,a=o>>16&255,d=o>>8&255,u=(o&255)/255;else return C.warn(`Invalid hex color length: ${f}`),null;return{r:h,g:a,b:d,a:u}}let i=t.match(/rgba?\(\s*(\d+%?)\s*,\s*(\d+%?)\s*,\s*(\d+%?)\s*(?:,\s*([\d.]+)\s*)?\)/i);if(i){const n=o=>o.endsWith("%")?A(parseFloat(o)/100*255,0,255):A(parseInt(o,10),0,255);return{r:n(i[1]),g:n(i[2]),b:n(i[3]),a:i[4]!==void 0?A(parseFloat(i[4]),0,1):1}}return C.warn(`Could not parse color: ${f}`),null}function Ot(f,t,e,i,s=!1,n=!1){const o=c=>{const p=Math.round(A(c,0,255)).toString(16);return p.length===1?"0"+p:p},h=o(f),a=o(t),d=o(e),u=o(i*255);if(s&&h[0]===h[1]&&a[0]===a[1]&&d[0]===d[1]&&i===1&&!n)return`#${h[0]}${a[0]}${d[0]}`;const l=`#${h}${a}${d}`;return n||i<1?`${l}${u}`:l}class X{constructor(t){r(this,"_r");r(this,"_g");r(this,"_b");r(this,"_a");const e=Ct(t);e===null?(C.error(`Failed to parse color: ${t}. Using default black.`),this._r=0,this._g=0,this._b=0,this._a=1):(this._r=Math.round(e.r),this._g=Math.round(e.g),this._b=Math.round(e.b),this._a=e.a)}get R(){return this._r}get G(){return this._g}get B(){return this._b}get A(){return this._a}red(t){return t===void 0?this._r:(this._r=Math.round(A(t,0,255)),this)}green(t){return t===void 0?this._g:(this._g=Math.round(A(t,0,255)),this)}blue(t){return t===void 0?this._b:(this._b=Math.round(A(t,0,255)),this)}alpha(t){return t===void 0?this._a:(this._a=A(t,0,1),this)}toHex(t=!1,e=!1){return Ot(this._r,this._g,this._b,this._a,t,e)}toRgb(){const t=Math.round(this._r),e=Math.round(this._g),i=Math.round(this._b);if(this._a===1)return`rgb(${t}, ${e}, ${i})`;{const s=parseFloat(this._a.toFixed(2));return`rgba(${t}, ${e}, ${i}, ${s})`}}toObject(){return{r:this._r,g:this._g,b:this._b,a:this._a}}toString(){return this.toRgb()}brighten(t=10){if(t<0)return this.darken(-t);const e=A(t,0,100)/100;return this._r=Math.round(A(this._r+(255-this._r)*e,0,255)),this._g=Math.round(A(this._g+(255-this._g)*e,0,255)),this._b=Math.round(A(this._b+(255-this._b)*e,0,255)),this}darken(t=10){if(t<0)return this.brighten(-t);const e=A(t,0,100)/100;return this._r=Math.round(A(this._r*(1-e),0,255)),this._g=Math.round(A(this._g*(1-e),0,255)),this._b=Math.round(A(this._b*(1-e),0,255)),this}isLight(){return(this._r*299+this._g*587+this._b*114)/1e3>128}isDark(){return!this.isLight()}mix(t,e=50){const i=A(e,0,100)/100,s=$(t);return this._r=Math.round(A(this._r*(1-i)+s.R*i,0,255)),this._g=Math.round(A(this._g*(1-i)+s.G*i,0,255)),this._b=Math.round(A(this._b*(1-i)+s.B*i,0,255)),this._a=A(this._a*(1-i)+s.A*i,0,1),this}clone(){return new X({r:this._r,g:this._g,b:this._b,a:this._a})}static extend(t,e){typeof t=="function"?t(e,X,$):C.warn("Invalid plugin provided to Colorjs.extend. Expected a function.")}}const $=f=>f instanceof X?f:new X(f);class ot{constructor(t,e,i){r(this,"element");r(this,"iconElement");r(this,"_state",0);r(this,"options");var o;this.context=t,this.container=e,this.task=i;const n=(this.task?this.context.store.getDataManager().isTaskChecked(this.task):!1)?1:0;this.options={initialState:n,size:14},this.element=document.createElement("div"),this.iconElement=document.createElement("div"),this._state=this.options.initialState,this.createElement(),this.updateIcon(),this.bindEvents(),this.registerEvents(),(o=this.container)==null||o.appendChild(this.element)}createElement(){this.element.className="x-gantt-checkbox",this.element.style.width=`${this.options.size}px`,this.element.style.height=`${this.options.size}px`,this.element.style.setProperty("border",`1px solid ${this.context.store.getOptionManager().getOptions().border.color}`,"important"),this.iconElement.className="x-gantt-checkbox__icon",this.iconElement.style.cssText=`
|
|
1
|
+
(function(R,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("dayjs"),require("lodash-es"),require("konva")):typeof define=="function"&&define.amd?define(["exports","dayjs","lodash-es","konva"],D):(R=typeof globalThis<"u"?globalThis:R||self,D(R.XGantt={},R.dayjs,R._,R.Konva))})(this,function(R,D,O,L){"use strict";var Ce=Object.defineProperty;var De=(R,D,O)=>D in R?Ce(R,D,{enumerable:!0,configurable:!0,writable:!0,value:O}):R[D]=O;var r=(R,D,O)=>De(R,typeof D!="symbol"?D+"":D,O);const it="0.0.1-alpha.3";function St(){const f="#eca710",t="#ffffff",e="#e7209e",i="#ffffff",s="#1c42e8";[" __ __ _____ _____ _____ _____ _____ ","| | || __|| _ || | ||_ _||_ _|","|- -|| | || || | | | | | | | ","|__|__||_____||__|__||_|___| |_| |_| "].forEach(o=>{console.log(`%c${o}`,`color: ${f}; font-weight: bold; font-family: monospace;`)}),console.log(`%c 🚀 欢迎使用 XGantt %c Version: ${it} `,`background-color: ${e}; color: ${t}; padding: 2px 4px; border-radius: 6px 0 0 6px; font-weight: bold; margin: 4px 0;`,`background-color: ${s}; color: ${i}; padding: 2px 4px; border-radius: 0 6px 6px 0; font-weight: normal; margin: 4px 0;`)}const W=class W{static setOptions(t){W.options={...W.options,...t}}static getLevel(){return W.options.level}static debug(...t){W.logWithLevel(1,console.debug,...t)}static info(...t){W.logWithLevel(2,console.info,...t)}static warn(...t){W.logWithLevel(3,console.warn,...t)}static error(...t){W.logWithLevel(4,console.error,...t)}static assert(t,...e){if(!t&&W.options.level<=4){const i=W.formatArgs("Assertion failed:",...e);console.error(...i)}}static getMessage(...t){return W.formatArgs(...t).join("")}static exception(...t){return new Error(W.getMessage(...t))}static logWithLevel(t,e,...i){if(W.options.level<=t){const s=W.formatArgs(...i);e(...s)}}static formatArgs(...t){const e=[W.Prefix];return W.options.showTimestamp&&e.unshift(`[${D().format("YYYY-MM-DD HH:mm:ss.SSS")}]`),[e.join(""),...t]}};r(W,"Prefix","[XGantt]"),r(W,"options",{level:2,showTimestamp:!1});let C=W;const q=()=>({data:[],links:{show:!1,key:"id",data:[],distance:20,dash:[6,3],width:1,gap:5,arrow:{width:6,height:8},radius:3,create:{enabled:!1,mode:"hover",radius:3,width:2,from:!0,to:!0}},fields:{id:"id",startTime:"startTime",endTime:"endTime",name:"name",progress:"progress",children:"children"},selection:{enabled:!1,includeSelf:!0},expand:{show:!0,enabled:!0},dateFormat:"YYYY-MM-DD HH:mm:ss",locale:"en",unit:"day",table:{width:100,ellipsis:!0,align:"center",headerAlign:"center",emptyText:"-"},chart:{autoCellWidth:!1,cellWidth:"normal"},primaryColor:"#eca710",border:{color:"#e5e5e5"},header:{height:80,color:"#000",fontSize:14,fontWeight:600,fontFamily:"Arial"},row:{height:30,indent:16,hover:{backgroundColor:"#000",opacity:.05},select:{backgroundColor:"#000",opacity:.1}},bar:{height:20,move:{byUnit:!1,link:{child:"none",parent:"none"}}},today:{show:!0,type:"line",backgroundColor:"lightblue",opacity:1,width:1},weekend:{show:!0,backgroundColor:"#c9c9c9",opacity:.1},holiday:{opacity:.1}});class vt{constructor(){r(this,"options",q())}getOptions(){return this.options}setOptions(t,e={merge:!0}){var i;this.options=e.merge?O.merge(q(),this.options,t):O.merge(q(),t),O.isArray((i=t.links)==null?void 0:i.data)&&(this.options.links.data=t.links.data)}update(t){this.setOptions(t)}getRowBackgroundColor(t){var s;let e="";const i=(s=this.options.row)==null?void 0:s.backgroundColor;return O.isString(i)?e=i:O.isArray(i)&&i.length>0?e=i[t.level]:O.isFunction(i)&&(e=i(t.getEmitData())),e}}class Lt{constructor(){r(this,"events",new Map)}on(t,e){var i;this.events.has(t)||this.events.set(t,[]),(i=this.events.get(t))==null||i.push(e)}emit(t,...e){var i;this.events.has(t)&&((i=this.events.get(t))==null||i.forEach(s=>s(...e)))}off(t,e){var i;this.events.has(t)&&this.events.set(t,((i=this.events.get(t))==null?void 0:i.filter(s=>s!==e))||[])}offAll(){this.events.clear()}}var y=(f=>(f.LOADED="loaded",f.COLUMN_WIDTH_CHANGE="column-width-change",f.MOVE_GUIDELINE="move-guideline",f.SHOW_GUIDELINE="show-guideline",f.HIDE_GUIDELINE="hide-guideline",f.SCROLL="scroll",f.CHART_OFFSET_CHANGE="chart_offset_change",f.DATA_UPDATE="data-update",f.VIEW_UPDATE="view-update",f.UPDATE_TABLE_HEADER="update_table_header",f.UPDATE_TABLE_BODY="update_table_body",f.UPDATE_CHART_HEADER="update_chart_header",f.UPDATE_TASK="update_task",f.UPDATE_LINK="update_link",f.CREATE_LINK="create_link",f.TASK_SELECTED="task_selected",f.TASK_UNSELECTED="task_unselected",f.SELECT_LINK="select_link",f.CHECK_TASK="check_task",f.ROW_CLICK="row-click",f.ROW_DBL_CLICK="row-dbl-click",f.ROW_CONTEXTMENU="row-contextmenu",f.SLIDER_CLICK="slider-click",f.SLIDER_DBL_CLICK="slider-dbl-click",f.SLIDER_CONTEXTMENU="slider-contextmenu",f.SLIDER_MOVING="slider-moving",f.ROW_HIGHLIGHT="row-highlight",f.ROW_UNHIGHLIGHT="row-unhighlight",f.TASK_DRAG_START="task-drag-start",f.TASK_DRAG_MOVE="task-drag-move",f.TASK_DRAG_END="task-drag-end",f.ERROR="error",f))(y||{}),N=(f=>(f.LINK_NOT_ALLOWED="LINK_NOT_ALLOWED",f.LINK_SAME="LINK_SAME",f.LINK_EXIST="LINK_EXIST",f))(N||{});function U(){return Math.random().toString(36).substring(2,15)}class Q{constructor(t,e,i,s,n){r(this,"__key__",U());r(this,"id");r(this,"name");r(this,"startTime");r(this,"endTime");r(this,"progress");r(this,"expanded");r(this,"children");r(this,"parent");r(this,"level");r(this,"flatIndex");r(this,"data");r(this,"fields");this.store=t,this.event=e,this.fields=this.store.getOptionManager().getOptions().fields,this.id=n||i[this.fields.id]||U(),this.data=i,this.name=i[this.fields.name]||"";const o=i[this.fields.startTime];this.startTime=o?D(o):void 0;const h=i[this.fields.endTime];this.endTime=h?D(h):void 0,this.progress=i[this.fields.progress],this.expanded=this.store.getOptionManager().getOptions().expand.show?this.store.getOptionManager().getOptions().expand.enabled:!0,this.children=[],this.level=s&&s.level!==void 0?s.level+1:0,this.parent=s,this.flatIndex=0,this.store.updateTime(this.startTime,this.endTime)}getField(t){if(!t||O.isString(t)&&t.trim()==="")return;if(!t.includes("."))return this.data[t];const e=t.split(".");let i=this.data;for(let s=0;s<e.length;s++){const n=e[s];if(i==null||typeof i!="object"||!(n in i))return;i=i[n]}return O.isObject(i)?O.cloneDeep(i):i}updateData(t){this.data=t,t[this.fields.name]&&(this.name=t[this.fields.name]),t[this.fields.startTime]&&(this.startTime=D(t[this.fields.startTime])),t[this.fields.endTime]&&(this.endTime=D(t[this.fields.endTime])),t[this.fields.progress]!==void 0&&(this.progress=t[this.fields.progress]),this.event.emit(y.UPDATE_TASK,this)}updateTime(t,e){var s,n;this.startTime=t,this.endTime=e;const i=(n=(s=this.store)==null?void 0:s.getOptionManager().getOptions())==null?void 0:n.dateFormat;this.data[this.fields.startTime||"startTime"]=this.startTime.format(i),this.data[this.fields.endTime||"endTime"]=this.endTime.format(i),this.event.emit(y.UPDATE_TASK,this)}clone(){return new Q(this.store,this.event,O.cloneDeep(this.data),this.parent,this.id)}getEmitData(){return{data:this.data,$index:this.flatIndex,level:this.level+1}}getAllChildren(){const t=[],e=i=>{i.forEach(s=>{t.push(s),O.isArray(s.children)&&s.children.length>0&&e(s.children)})};return e(this.children),t}}class kt{constructor(t,e){r(this,"rawData",[]);r(this,"tasks",[]);r(this,"taskMap",new Map);r(this,"visibleTasksCache",[]);r(this,"isDirty",!0);r(this,"collapsedTaskIds",new Set);r(this,"selectedTaskId",null);r(this,"checkedList",[]);r(this,"dataLevel",0);this.store=t,this.event=e}setData(t,e=!1){this.rawData=t,this.initTasks(e),this.invalidateCache(),this.event.emit(y.DATA_UPDATE)}initTasks(t=!1){this.dataLevel=0,t?(this.tasks=[],this.taskMap.clear(),this.collapsedTaskIds.clear(),this.rawData.forEach(e=>{this.tasks.push(this.createTask(e))})):this.rawData.length>0?this.updateTask(this.rawData,this.tasks):(this.tasks=[],this.taskMap.clear(),this.collapsedTaskIds.clear())}createTask(t,e){const i=this.store.getOptionManager().getOptions().fields,s=new Q(this.store,this.event,t,e);return Array.isArray(t[i.children])&&(s.children=t[i.children].map(n=>this.createTask(n,s))),this.taskMap.set(s.id,s),this.dataLevel=Math.max(this.dataLevel,s.level),s}updateTask(t,e,i){let s=0;for(;s<t.length;){const n=t[s],o=e[s];if(n&&!o){const h=this.createTask(n,i);e.push(h),this.taskMap.set(h.id,h),this.dataLevel=Math.max(this.dataLevel,h.level)}else!n&&o?(this.taskMap.delete(o.id),e.splice(s,1)):n&&o&&(n[this.store.getOptionManager().getOptions().fields.id]===o.id?(o.updateData(n),this.dataLevel=Math.max(this.dataLevel,o.level)):(this.taskMap.delete(o.id),e[s]=this.createTask(n,o.parent),this.taskMap.set(e[s].id,e[s]),this.dataLevel=Math.max(this.dataLevel,e[s].level)));if(n[this.store.getOptionManager().getOptions().fields.children]){const h=n[this.store.getOptionManager().getOptions().fields.children];if(o&&o.children)this.updateTask(h,o.children,o);else{const a=h.map(d=>this.createTask(d,e[s]));e[s].children=a}}else o&&o.children&&(o.children=[]);s++}e.length>=s&&e.splice(s).forEach(o=>{this.taskMap.delete(o.id)})}getData(){return this.rawData}getTasks(t=!0){return t?this.tasks:Array.from(this.taskMap.values())}getTaskById(t){return this.taskMap.get(t)}expandTask(t,e=!1){const i=this.getTaskById(t);return i?(i.expanded=!i.expanded,i.expanded?this.collapsedTaskIds.delete(i.id):this.collapsedTaskIds.add(i.id),e&&i.children&&i.children.length>0&&i.children.forEach(s=>{this.expandTask(s.id,e)}),this.invalidateCache(),this.event.emit(y.VIEW_UPDATE),!0):!1}getVisibleTasks(){if(!this.isDirty&&this.visibleTasksCache.length>0)return this.visibleTasksCache;const t=[];let e=0;const i=(s,n)=>{this.collapsedTaskIds.has(s.id)&&s.expanded&&(s.expanded=!1),s.flatIndex=e++,t.push(s),s.expanded&&s.children&&s.children.length>0&&s.children.forEach(o=>i(o))};return this.tasks.forEach(s=>i(s)),this.visibleTasksCache=t,this.isDirty=!1,t}getVisibleSize(){return this.getVisibleTasks().length}isTaskVisible(t){return this.getVisibleTasks().some(e=>e.id===t.id)}clear(){this.rawData=[],this.tasks=[],this.taskMap.clear(),this.visibleTasksCache=[],this.isDirty=!0,this.collapsedTaskIds.clear(),this.event.emit(y.DATA_UPDATE)}invalidateCache(){this.isDirty=!0}selectTask(t){const e=this.getTaskById(t);return e?(this.selectedTaskId===t||(this.unselectTask(),this.selectedTaskId=t,this.event.emit(y.TASK_SELECTED,e)),!0):!1}unselectTask(){if(this.selectedTaskId){const t=this.selectedTaskId;this.selectedTaskId=null,this.event.emit(y.TASK_UNSELECTED,t)}}isTaskSelected(t){return this.selectedTaskId===t}getSelectedTask(){return this.selectedTaskId?this.getTaskById(this.selectedTaskId):void 0}getCheckedList(){return this.checkedList}updateCheckedList(t,e){const i=this.checkedList.findIndex(s=>s.id===e.id);t?i===-1?this.checkedList.push(e):this.checkedList.splice(i,1,e):i!==-1&&this.checkedList.splice(i,1)}toggleAllChecked(t){t?this.checkedList=this.getVisibleTasks().slice():this.checkedList=[]}isTaskChecked(t){return this.checkedList.findIndex(e=>e.id===t.id)!==-1}updateTaskTime(t,e,i,s,n=[]){let o=e,h=i;const a=this.store.getOptionManager().getOptions().bar.move.link.child,d=this.store.getOptionManager().getOptions().bar.move.link.parent,u=this.store.getTimeAxis().getCellUnit();let l=t.parent;for(;d!=="none"&&l;){if(d==="expand"){let m=l.startTime||o,p=l.endTime||h;(!l.startTime||o.isBefore(l.startTime))&&(m=o),(!l.endTime||h.isAfter(l.endTime))&&(p=h),(l.startTime===void 0||l.endTime===void 0||!m.isSame(l.startTime)||!p.isSame(l.endTime))&&(n.findIndex(g=>g.id===l.id)===-1&&n.push(l.clone()),l.updateTime(m,p))}else d==="strict"&&(l.startTime&&o.isBefore(l.startTime)&&(o=l.startTime,h.isSameOrBefore(o)&&(h=o.add(1,u))),l.endTime&&h.isAfter(l.endTime)&&(h=l.endTime,o.isAfter(h)&&(o=h.subtract(1,u))));l=l.parent}let c=t.children||[];for(;a!=="none"&&c.length>0;){const m=[];c.forEach(p=>{let g=p.startTime||o,x=p.endTime||h,T=o.diff(t.startTime),v=h.diff(t.endTime);a==="scale"?s==="both"?(n.findIndex(b=>b.id===p.id)===-1&&n.push(p.clone()),p.updateTime(g.add(T),x.add(v))):s==="left"?(g=g.add(T),g.isSameOrAfter(x.subtract(1,u))&&(x.isBefore(t.endTime)?x=g.add(1,u):g=x.subtract(1,u),g.isSameOrBefore(o)&&(o=g)),n.findIndex(b=>b.id===p.id)===-1&&n.push(p.clone()),p.updateTime(g,x)):s==="right"&&(x=x.add(v),x.isSameOrBefore(g.add(1,u))&&(g.isAfter(t.startTime)?g=x.subtract(1,u):x=g.add(1,u)),x.isSameOrAfter(h)&&(h=x),n.findIndex(b=>b.id===p.id)===-1&&n.push(p.clone()),p.updateTime(g,x)):a==="fixed"&&(s==="both"?(n.findIndex(b=>b.id===p.id)===-1&&n.push(p.clone()),p.updateTime(g.add(T),x.add(v))):s==="left"?g.isSameOrBefore(o)&&(g=o,g.isSameOrAfter(x.subtract(1,u))&&(x.isBefore(t.endTime)?x=g.add(1,u):g=x.subtract(1,u),g.isSameOrBefore(o)&&(o=g)),n.findIndex(b=>b.id===p.id)===-1&&n.push(p.clone()),p.updateTime(g,x)):s==="right"&&x.isSameOrAfter(h)&&(x=h,x.isSameOrBefore(g.add(1,u))&&(g.isAfter(t.startTime)?g=x.subtract(1,u):x=g.add(1,u)),x.isSameOrAfter(h)&&(h=x),n.findIndex(b=>b.id===p.id)===-1&&n.push(p.clone()),p.updateTime(g,x))),p.children&&p.children.length>0&&m.push(...p.children)}),c=m}n.findIndex(m=>m.id===t.id)===-1&&n.push(t.clone()),t.updateTime(o,h)}}function A(f,t,e){if(!Number.isFinite(f)||!Number.isFinite(t)||!Number.isFinite(e))return Number.isFinite(t)?t:0;const i=Math.min(t,e),s=Math.max(t,e);return Math.min(Math.max(i,f),s)}function st(f,t){let e=f;return O.isString(e)&&(/%$/.test(e)?e=t*parseFloat(e)/100:e=parseFloat(e)),isNaN(e)?0:e}function nt(f,t){if(t===0)throw new Error("基准值不能为0");if(Math.abs(f)<=t/2)return 0;const e=Math.floor(f/t),i=Math.ceil(f/t),s=e*t,n=i*t,o=Math.abs(f-s),h=Math.abs(f-n);return o<=h?s:n}function K(f,t=4){return typeof f=="number"?[f,f,f,f]:Array.isArray(f)?[f[0]??t,f[1]??t,f[2]??t,f[3]??t]:[t,t,t,t]}function Mt(f,t=100){if(!Number.isFinite(f)||!Number.isFinite(t)||t===0||f<0)return 0;const e=f/Math.abs(t);return Math.min(e,1)}function Et(f,t=2,e=!1){const i=f.toFixed(t);return e?i:i.replace(/\.?0+$/,"")}function Ot(f){var s;if(typeof f=="object"&&f!==null)return{r:A(f.r??0,0,255),g:A(f.g??0,0,255),b:A(f.b??0,0,255),a:A(f.a??1,0,1)};if(typeof f!="string")return C.warn(`Invalid color value type: ${typeof f}`),null;let t=f.trim();const e=(s=document==null?void 0:document.createElement("canvas"))==null?void 0:s.getContext("2d");if(e&&(e.fillStyle=t,t=e.fillStyle),t.startsWith("#")){const n=t.slice(1);let o,h,a,d,u=1;try{o=parseInt(n,16)}catch{return C.warn(`Invalid hex color: ${f}`),null}if(n.length===3)h=(o>>8&15)*17,a=(o>>4&15)*17,d=(o&15)*17;else if(n.length===6)h=o>>16&255,a=o>>8&255,d=o&255;else if(n.length===8)h=o>>24&255,a=o>>16&255,d=o>>8&255,u=(o&255)/255;else return C.warn(`Invalid hex color length: ${f}`),null;return{r:h,g:a,b:d,a:u}}let i=t.match(/rgba?\(\s*(\d+%?)\s*,\s*(\d+%?)\s*,\s*(\d+%?)\s*(?:,\s*([\d.]+)\s*)?\)/i);if(i){const n=o=>o.endsWith("%")?A(parseFloat(o)/100*255,0,255):A(parseInt(o,10),0,255);return{r:n(i[1]),g:n(i[2]),b:n(i[3]),a:i[4]!==void 0?A(parseFloat(i[4]),0,1):1}}return C.warn(`Could not parse color: ${f}`),null}function Ct(f,t,e,i,s=!1,n=!1){const o=c=>{const m=Math.round(A(c,0,255)).toString(16);return m.length===1?"0"+m:m},h=o(f),a=o(t),d=o(e),u=o(i*255);if(s&&h[0]===h[1]&&a[0]===a[1]&&d[0]===d[1]&&i===1&&!n)return`#${h[0]}${a[0]}${d[0]}`;const l=`#${h}${a}${d}`;return n||i<1?`${l}${u}`:l}class B{constructor(t){r(this,"_r");r(this,"_g");r(this,"_b");r(this,"_a");const e=Ot(t);e===null?(C.error(`Failed to parse color: ${t}. Using default black.`),this._r=0,this._g=0,this._b=0,this._a=1):(this._r=Math.round(e.r),this._g=Math.round(e.g),this._b=Math.round(e.b),this._a=e.a)}get R(){return this._r}get G(){return this._g}get B(){return this._b}get A(){return this._a}red(t){return t===void 0?this._r:(this._r=Math.round(A(t,0,255)),this)}green(t){return t===void 0?this._g:(this._g=Math.round(A(t,0,255)),this)}blue(t){return t===void 0?this._b:(this._b=Math.round(A(t,0,255)),this)}alpha(t){return t===void 0?this._a:(this._a=A(t,0,1),this)}toHex(t=!1,e=!1){return Ct(this._r,this._g,this._b,this._a,t,e)}toRgb(){const t=Math.round(this._r),e=Math.round(this._g),i=Math.round(this._b);if(this._a===1)return`rgb(${t}, ${e}, ${i})`;{const s=parseFloat(this._a.toFixed(2));return`rgba(${t}, ${e}, ${i}, ${s})`}}toObject(){return{r:this._r,g:this._g,b:this._b,a:this._a}}toString(){return this.toRgb()}brighten(t=10){if(t<0)return this.darken(-t);const e=A(t,0,100)/100;return this._r=Math.round(A(this._r+(255-this._r)*e,0,255)),this._g=Math.round(A(this._g+(255-this._g)*e,0,255)),this._b=Math.round(A(this._b+(255-this._b)*e,0,255)),this}darken(t=10){if(t<0)return this.brighten(-t);const e=A(t,0,100)/100;return this._r=Math.round(A(this._r*(1-e),0,255)),this._g=Math.round(A(this._g*(1-e),0,255)),this._b=Math.round(A(this._b*(1-e),0,255)),this}isLight(){return(this._r*299+this._g*587+this._b*114)/1e3>128}isDark(){return!this.isLight()}mix(t,e=50){const i=A(e,0,100)/100,s=$(t);return this._r=Math.round(A(this._r*(1-i)+s.R*i,0,255)),this._g=Math.round(A(this._g*(1-i)+s.G*i,0,255)),this._b=Math.round(A(this._b*(1-i)+s.B*i,0,255)),this._a=A(this._a*(1-i)+s.A*i,0,1),this}clone(){return new B({r:this._r,g:this._g,b:this._b,a:this._a})}static extend(t,e){typeof t=="function"?t(e,B,$):C.warn("Invalid plugin provided to Colorjs.extend. Expected a function.")}}const $=f=>f instanceof B?f:new B(f);class ot{constructor(t,e,i){r(this,"element");r(this,"iconElement");r(this,"_state",0);r(this,"options");var o;this.context=t,this.container=e,this.task=i;const n=(this.task?this.context.store.getDataManager().isTaskChecked(this.task):!1)?1:0;this.options={initialState:n,size:14},this.element=document.createElement("div"),this.iconElement=document.createElement("div"),this._state=this.options.initialState,this.createElement(),this.updateIcon(),this.bindEvents(),this.registerEvents(),(o=this.container)==null||o.appendChild(this.element)}createElement(){this.element.className="x-gantt-checkbox",this.element.style.width=`${this.options.size}px`,this.element.style.height=`${this.options.size}px`,this.element.style.setProperty("border",`1px solid ${this.context.store.getOptionManager().getOptions().border.color}`,"important"),this.iconElement.className="x-gantt-checkbox__icon",this.iconElement.style.cssText=`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
<svg width="8" height="2" viewBox="0 0 8 2" fill="none">
|
|
16
16
|
<rect width="8" height="2" fill="currentColor" rx="1"/>
|
|
17
17
|
</svg>
|
|
18
|
-
`;break}this.iconElement.style.setProperty("background-color",e,"important"),this.iconElement.style.setProperty("border-color",i,"important")}bindEvents(){this.element.addEventListener("click",t=>{if(t.preventDefault(),t.stopPropagation(),this.task){const e=this.context.store.getDataManager().isTaskChecked(this.task);e?(this.context.store.getDataManager().updateCheckedList(!1,this.task),this.setState(0)):(this.context.store.getDataManager().updateCheckedList(!0,this.task),this.setState(1)),this.context.event.emit(b.CHECK_TASK,[this.task],!e)}else{const e=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(e?1:0),this.context.store.getDataManager().toggleAllChecked(!e),this.context.event.emit(b.CHECK_TASK,this.context.store.getDataManager().getVisibleTasks(),!e)}}),this.element.addEventListener("contextmenu",t=>{if(t.preventDefault(),t.stopPropagation(),this.task){const e=this.task.getAllChildren();if(e.length===0)return;this.context.store.getOptionManager().getOptions().selection.includeSelf&&e.unshift(this.task);const i=e.every(s=>this.context.store.getDataManager().isTaskChecked(s));i?(e.forEach(s=>{this.context.store.getDataManager().updateCheckedList(!1,s)}),this.setState(0)):(e.forEach(s=>{this.context.store.getDataManager().updateCheckedList(!0,s)}),this.setState(1)),this.context.event.emit(b.CHECK_TASK,e,!i)}else{const e=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(e?1:0),this.context.store.getDataManager().toggleAllChecked(!e),this.context.event.emit(b.CHECK_TASK,this.context.store.getDataManager().getVisibleTasks(),!e)}})}registerEvents(){this.context.event.on(b.CHECK_TASK,this.updateState.bind(this))}getElement(){return this.element}setState(t){this._state!==t&&(this._state=t,this.updateIcon())}updateState(){if(this.task){const t=this.context.store.getDataManager().isTaskChecked(this.task);this.setState(t?1:0)}else{const t=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(t?1:0)}}destroy(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}const rt="handler_column";class Dt{constructor(t){r(this,"sourceColumns",[]);r(this,"columns",[]);r(this,"leafColumns",[]);r(this,"temporaryLeafColumns",[]);r(this,"mergeInfo",new Map);this.context=t}init(t){t!=null&&t.length&&(this.sourceColumns=t),this.columns=[],this.leafColumns=[],this.processColumns(this.sourceColumns,this.columns)}processColumns(t,e=[],i,s=1){t.forEach((n,o)=>{var m;const h="children"in n&&Array.isArray(n.children)&&n.children.length>0,a=!h;let d="";h?d=`group-${o}`:d=`field-${n.field}`;const u=[...(i==null?void 0:i.path)||[],d];d="column-"+o+"-"+u.join("-");const l=n.label||(a?n.field:""),c=a?((m=this.temporaryLeafColumns.find(g=>g.key===d))==null?void 0:m.width)||n.width||100:"auto",p={label:l,level:s,maxLevel:s,column:n,children:[],path:u,key:d,isLeaf:a,width:c};if(e.push(p),a)this.leafColumns.push(p);else if(h){const g=n.children;this.processColumns(g,p.children,p,s+1),p.maxLevel=Math.max(p.maxLevel,p.children.reduce((x,T)=>Math.max(x,T.maxLevel),0))}}),this.temporaryLeafColumns=E.cloneDeep(this.leafColumns)}findColumnByKey(t){return this.columns.find(e=>e.key===t)}update(t){this.init(t)}getColumns(){return this.columns}getColumn(t){return this.leafColumns.find(e=>e.key===t)}getLeafColumns(){return this.leafColumns}getTotalWidth(){return this.leafColumns.reduce((t,e)=>t+e.width,this.getHandlerColumn().width)}getColumnWidth(t){if(t===rt)return this.getHandlerColumn().width;const e=this.leafColumns.find(i=>i.key===t);return typeof(e==null?void 0:e.width)=="number"?e.width:0}setColumnWidth(t,e){const i=this.leafColumns.find(s=>s.key===t);i&&(i.width=e),this.context.event.emit(b.COLUMN_WIDTH_CHANGE,t,e)}isLastColumn(t){return this.leafColumns.findIndex(i=>i.key===t)===this.leafColumns.length-1}addMergeInfo(t,e,i){this.mergeInfo.has(t)||this.mergeInfo.set(t,new Map),this.mergeInfo.get(t).set(e,i)}getMergeInfo(t,e){var i;return(i=this.mergeInfo.get(t))==null?void 0:i.get(e)}clearMergeInfo(){this.mergeInfo.clear()}getHandlerColumn(){let t=0;return this.context.store.getOptionManager().getOptions().selection.enabled&&(t+=40),this.context.store.getDataManager().dataLevel>0&&this.context.store.getOptionManager().getOptions().expand.show&&(t+=40),{label:"",level:1,maxLevel:1,column:{field:"",resizable:!1,align:"left",headerAlign:"left",customStyle:{paddingLeft:this.context.store.getOptionManager().getOptions().expand.show?"8px":0},headerRender:()=>this.context.store.getOptionManager().getOptions().selection.enabled?new ot(this.context).getElement():null,ellipsis:!1},children:[],path:[],key:rt,isLeaf:!0,width:t}}isMultiHeader(){return this.columns.some(t=>t.maxLevel>1)}}var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function F(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var ht={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e,i,s=1e3,n=6e4,o=36e5,h=864e5,a=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d=31536e6,u=2628e6,l=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,c={years:d,months:u,days:h,hours:o,minutes:n,seconds:s,milliseconds:1,weeks:6048e5},p=function(L){return L instanceof O},m=function(L,k,w){return new O(L,w,k.$l)},g=function(L){return i.p(L)+"s"},x=function(L){return L<0},T=function(L){return x(L)?Math.ceil(L):Math.floor(L)},v=function(L){return Math.abs(L)},y=function(L,k){return L?x(L)?{negative:!0,format:""+v(L)+k}:{negative:!1,format:""+L+k}:{negative:!1,format:""}},O=function(){function L(w,_,H){var I=this;if(this.$d={},this.$l=H,w===void 0&&(this.$ms=0,this.parseFromMilliseconds()),_)return m(w*c[g(_)],this);if(typeof w=="number")return this.$ms=w,this.parseFromMilliseconds(),this;if(typeof w=="object")return Object.keys(w).forEach(function(z){I.$d[g(z)]=w[z]}),this.calMilliseconds(),this;if(typeof w=="string"){var Y=w.match(l);if(Y){var P=Y.slice(2).map(function(z){return z!=null?Number(z):0});return this.$d.years=P[0],this.$d.months=P[1],this.$d.weeks=P[2],this.$d.days=P[3],this.$d.hours=P[4],this.$d.minutes=P[5],this.$d.seconds=P[6],this.calMilliseconds(),this}}return this}var k=L.prototype;return k.calMilliseconds=function(){var w=this;this.$ms=Object.keys(this.$d).reduce(function(_,H){return _+(w.$d[H]||0)*c[H]},0)},k.parseFromMilliseconds=function(){var w=this.$ms;this.$d.years=T(w/d),w%=d,this.$d.months=T(w/u),w%=u,this.$d.days=T(w/h),w%=h,this.$d.hours=T(w/o),w%=o,this.$d.minutes=T(w/n),w%=n,this.$d.seconds=T(w/s),w%=s,this.$d.milliseconds=w},k.toISOString=function(){var w=y(this.$d.years,"Y"),_=y(this.$d.months,"M"),H=+this.$d.days||0;this.$d.weeks&&(H+=7*this.$d.weeks);var I=y(H,"D"),Y=y(this.$d.hours,"H"),P=y(this.$d.minutes,"M"),z=this.$d.seconds||0;this.$d.milliseconds&&(z+=this.$d.milliseconds/1e3,z=Math.round(1e3*z)/1e3);var tt=y(z,"S"),Me=w.negative||_.negative||I.negative||Y.negative||P.negative||tt.negative,Ce=Y.format||P.format||tt.format?"T":"",et=(Me?"-":"")+"P"+w.format+_.format+I.format+Ce+Y.format+P.format+tt.format;return et==="P"||et==="-P"?"P0D":et},k.toJSON=function(){return this.toISOString()},k.format=function(w){var _=w||"YYYY-MM-DDTHH:mm:ss",H={Y:this.$d.years,YY:i.s(this.$d.years,2,"0"),YYYY:i.s(this.$d.years,4,"0"),M:this.$d.months,MM:i.s(this.$d.months,2,"0"),D:this.$d.days,DD:i.s(this.$d.days,2,"0"),H:this.$d.hours,HH:i.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:i.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:i.s(this.$d.seconds,2,"0"),SSS:i.s(this.$d.milliseconds,3,"0")};return _.replace(a,function(I,Y){return Y||String(H[I])})},k.as=function(w){return this.$ms/c[g(w)]},k.get=function(w){var _=this.$ms,H=g(w);return H==="milliseconds"?_%=1e3:_=H==="weeks"?T(_/c[H]):this.$d[H],_||0},k.add=function(w,_,H){var I;return I=_?w*c[g(_)]:p(w)?w.$ms:m(w,this).$ms,m(this.$ms+I*(H?-1:1),this)},k.subtract=function(w,_){return this.add(w,_,!0)},k.locale=function(w){var _=this.clone();return _.$l=w,_},k.clone=function(){return m(this.$ms,this)},k.humanize=function(w){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!w)},k.valueOf=function(){return this.asMilliseconds()},k.milliseconds=function(){return this.get("milliseconds")},k.asMilliseconds=function(){return this.as("milliseconds")},k.seconds=function(){return this.get("seconds")},k.asSeconds=function(){return this.as("seconds")},k.minutes=function(){return this.get("minutes")},k.asMinutes=function(){return this.as("minutes")},k.hours=function(){return this.get("hours")},k.asHours=function(){return this.as("hours")},k.days=function(){return this.get("days")},k.asDays=function(){return this.as("days")},k.weeks=function(){return this.get("weeks")},k.asWeeks=function(){return this.as("weeks")},k.months=function(){return this.get("months")},k.asMonths=function(){return this.as("months")},k.years=function(){return this.get("years")},k.asYears=function(){return this.as("years")},L}(),M=function(L,k,w){return L.add(k.years()*w,"y").add(k.months()*w,"M").add(k.days()*w,"d").add(k.hours()*w,"h").add(k.minutes()*w,"m").add(k.seconds()*w,"s").add(k.milliseconds()*w,"ms")};return function(L,k,w){e=w,i=w().$utils(),w.duration=function(I,Y){var P=w.locale();return m(I,{$l:P},Y)},w.isDuration=p;var _=k.prototype.add,H=k.prototype.subtract;k.prototype.add=function(I,Y){return p(I)?M(this,I,1):_.bind(this)(I,Y)},k.prototype.subtract=function(I,Y){return p(I)?M(this,I,-1):H.bind(this)(I,Y)}}})})(ht);var _t=ht.exports;const Ht=F(_t);var at={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i,s){i.prototype.isBetween=function(n,o,h,a){var d=s(n),u=s(o),l=(a=a||"()")[0]==="(",c=a[1]===")";return(l?this.isAfter(d,h):!this.isBefore(d,h))&&(c?this.isBefore(u,h):!this.isAfter(u,h))||(l?this.isBefore(d,h):!this.isAfter(d,h))&&(c?this.isAfter(u,h):!this.isBefore(u,h))}}})})(at);var At=at.exports;const It=F(At);var lt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i){i.prototype.isSameOrBefore=function(s,n){return this.isSame(s,n)||this.isBefore(s,n)}}})})(lt);var Rt=lt.exports;const Wt=F(Rt);var ct={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i){i.prototype.isSameOrAfter=function(s,n){return this.isSame(s,n)||this.isAfter(s,n)}}})})(ct);var $t=ct.exports;const Gt=F($t);var dt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i,s){var n=i.prototype,o=function(l){return l&&(l.indexOf?l:l.s)},h=function(l,c,p,m,g){var x=l.name?l:l.$locale(),T=o(x[c]),v=o(x[p]),y=T||v.map(function(M){return M.slice(0,m)});if(!g)return y;var O=x.weekStart;return y.map(function(M,L){return y[(L+(O||0))%7]})},a=function(){return s.Ls[s.locale()]},d=function(l,c){return l.formats[c]||function(p){return p.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(m,g,x){return g||x.slice(1)})}(l.formats[c.toUpperCase()])},u=function(){var l=this;return{months:function(c){return c?c.format("MMMM"):h(l,"months")},monthsShort:function(c){return c?c.format("MMM"):h(l,"monthsShort","months",3)},firstDayOfWeek:function(){return l.$locale().weekStart||0},weekdays:function(c){return c?c.format("dddd"):h(l,"weekdays")},weekdaysMin:function(c){return c?c.format("dd"):h(l,"weekdaysMin","weekdays",2)},weekdaysShort:function(c){return c?c.format("ddd"):h(l,"weekdaysShort","weekdays",3)},longDateFormat:function(c){return d(l.$locale(),c)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};n.localeData=function(){return u.bind(this)()},s.localeData=function(){var l=a();return{firstDayOfWeek:function(){return l.weekStart||0},weekdays:function(){return s.weekdays()},weekdaysShort:function(){return s.weekdaysShort()},weekdaysMin:function(){return s.weekdaysMin()},months:function(){return s.months()},monthsShort:function(){return s.monthsShort()},longDateFormat:function(c){return d(l,c)},meridiem:l.meridiem,ordinal:l.ordinal}},s.months=function(){return h(a(),"months")},s.monthsShort=function(){return h(a(),"monthsShort","months",3)},s.weekdays=function(l){return h(a(),"weekdays",null,null,l)},s.weekdaysShort=function(l){return h(a(),"weekdaysShort","weekdays",3,l)},s.weekdaysMin=function(l){return h(a(),"weekdaysMin","weekdays",2,l)}}})})(dt);var Yt=dt.exports;const Pt=F(Yt);var ut={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e="week",i="year";return function(s,n,o){var h=n.prototype;h.week=function(a){if(a===void 0&&(a=null),a!==null)return this.add(7*(a-this.week()),"day");var d=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var u=o(this).startOf(i).add(1,i).date(d),l=o(this).endOf(e);if(u.isBefore(l))return 1}var c=o(this).startOf(i).date(d).startOf(e).subtract(1,"millisecond"),p=this.diff(c,e,!0);return p<0?o(this).startOf("week").week():Math.ceil(p)},h.weeks=function(a){return a===void 0&&(a=null),this.week(a)}}})})(ut);var Ft=ut.exports;const zt=F(Ft);var gt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i){i.prototype.weekYear=function(){var s=this.month(),n=this.week(),o=this.year();return n===1&&s===11?o+1:s===0&&n>=52?o-1:o}}})})(gt);var Nt=gt.exports;const Ut=F(Nt);var ft={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i){var s=i.prototype,n=s.format;s.format=function(o){var h=this,a=this.$locale();if(!this.isValid())return n.bind(this)(o);var d=this.$utils(),u=(o||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(l){switch(l){case"Q":return Math.ceil((h.$M+1)/3);case"Do":return a.ordinal(h.$D);case"gggg":return h.weekYear();case"GGGG":return h.isoWeekYear();case"wo":return a.ordinal(h.week(),"W");case"w":case"ww":return d.s(h.week(),l==="w"?1:2,"0");case"W":case"WW":return d.s(h.isoWeek(),l==="W"?1:2,"0");case"k":case"kk":return d.s(String(h.$H===0?24:h.$H),l==="k"?1:2,"0");case"X":return Math.floor(h.$d.getTime()/1e3);case"x":return h.$d.getTime();case"z":return"["+h.offsetName()+"]";case"zzz":return"["+h.offsetName("long")+"]";default:return l}});return n.bind(this)(u)}}})})(ft);var Bt=ft.exports;const Xt=F(Bt);var mt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i,s){s.updateLocale=function(n,o){var h=s.Ls[n];if(h)return(o?Object.keys(o):[]).forEach(function(a){h[a]=o[a]}),h}}})})(mt);var Vt=mt.exports;const qt=F(Vt);var pt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e="day";return function(i,s,n){var o=function(d){return d.add(4-d.isoWeekday(),e)},h=s.prototype;h.isoWeekYear=function(){return o(this).year()},h.isoWeek=function(d){if(!this.$utils().u(d))return this.add(7*(d-this.isoWeek()),e);var u,l,c,p,m=o(this),g=(u=this.isoWeekYear(),l=this.$u,c=(l?n.utc:n)().year(u).startOf("year"),p=4-c.isoWeekday(),c.isoWeekday()>4&&(p+=7),c.add(p,e));return m.diff(g,"week")+1},h.isoWeekday=function(d){return this.$utils().u(d)?this.day()||7:this.day(this.day()%7?d:d-7)};var a=h.startOf;h.startOf=function(d,u){var l=this.$utils(),c=!!l.u(u)||u;return l.p(d)==="isoweek"?c?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):a.bind(this)(d,u)}}})})(pt);var Qt=pt.exports;const Zt=F(Qt);var xt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},i={};return function(s,n,o){var h,a=function(c,p,m){m===void 0&&(m={});var g=new Date(c),x=function(T,v){v===void 0&&(v={});var y=v.timeZoneName||"short",O=T+"|"+y,M=i[O];return M||(M=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:T,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:y}),i[O]=M),M}(p,m);return x.formatToParts(g)},d=function(c,p){for(var m=a(c,p),g=[],x=0;x<m.length;x+=1){var T=m[x],v=T.type,y=T.value,O=e[v];O>=0&&(g[O]=parseInt(y,10))}var M=g[3],L=M===24?0:M,k=g[0]+"-"+g[1]+"-"+g[2]+" "+L+":"+g[4]+":"+g[5]+":000",w=+c;return(o.utc(k).valueOf()-(w-=w%1e3))/6e4},u=n.prototype;u.tz=function(c,p){c===void 0&&(c=h);var m,g=this.utcOffset(),x=this.toDate(),T=x.toLocaleString("en-US",{timeZone:c}),v=Math.round((x-new Date(T))/1e3/60),y=15*-Math.round(x.getTimezoneOffset()/15)-v;if(!Number(y))m=this.utcOffset(0,p);else if(m=o(T,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(y,!0),p){var O=m.utcOffset();m=m.add(g-O,"minute")}return m.$x.$timezone=c,m},u.offsetName=function(c){var p=this.$x.$timezone||o.tz.guess(),m=a(this.valueOf(),p,{timeZoneName:c}).find(function(g){return g.type.toLowerCase()==="timezonename"});return m&&m.value};var l=u.startOf;u.startOf=function(c,p){if(!this.$x||!this.$x.$timezone)return l.call(this,c,p);var m=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return l.call(m,c,p).tz(this.$x.$timezone,!0)},o.tz=function(c,p,m){var g=m&&p,x=m||p||h,T=d(+o(),x);if(typeof c!="string")return o(c).tz(x);var v=function(L,k,w){var _=L-60*k*1e3,H=d(_,w);if(k===H)return[_,k];var I=d(_-=60*(H-k)*1e3,w);return H===I?[_,H]:[L-60*Math.min(H,I)*1e3,Math.max(H,I)]}(o.utc(c,g).valueOf(),T,x),y=v[0],O=v[1],M=o(y).utcOffset(O);return M.$x.$timezone=x,M},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(c){h=c}}})})(xt);var jt=xt.exports;const Jt=F(jt);var yt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e="minute",i=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(n,o,h){var a=o.prototype;h.utc=function(g){var x={date:g,utc:!0,args:arguments};return new o(x)},a.utc=function(g){var x=h(this.toDate(),{locale:this.$L,utc:!0});return g?x.add(this.utcOffset(),e):x},a.local=function(){return h(this.toDate(),{locale:this.$L,utc:!1})};var d=a.parse;a.parse=function(g){g.utc&&(this.$u=!0),this.$utils().u(g.$offset)||(this.$offset=g.$offset),d.call(this,g)};var u=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 u.call(this)};var l=a.utcOffset;a.utcOffset=function(g,x){var T=this.$utils().u;if(T(g))return this.$u?0:T(this.$offset)?l.call(this):this.$offset;if(typeof g=="string"&&(g=function(M){M===void 0&&(M="");var L=M.match(i);if(!L)return null;var k=(""+L[0]).match(s)||["-",0,0],w=k[0],_=60*+k[1]+ +k[2];return _===0?0:w==="+"?_:-_}(g),g===null))return this;var v=Math.abs(g)<=16?60*g:g,y=this;if(x)return y.$offset=v,y.$u=g===0,y;if(g!==0){var O=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(y=this.local().add(v+O,e)).$offset=v,y.$x.$localOffset=O}else y=this.utc();return y};var c=a.format;a.format=function(g){var x=g||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,x)},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 p=a.toDate;a.toDate=function(g){return g==="s"&&this.$offset?h(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():p.call(this)};var m=a.diff;a.diff=function(g,x,T){if(g&&this.$u===g.$u)return m.call(this,g,x,T);var v=this.local(),y=h(g).local();return m.call(v,y,x,T)}}})})(yt);var Kt=yt.exports;const te=F(Kt);var ee={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var i=["th","st","nd","rd"],s=e%100;return"["+e+(i[(s-20)%10]||i[s]||i[0])+"]"}}})})(ee);var ie={exports:{}};(function(f,t){(function(e,i){f.exports=i(D)})(G,function(e){function i(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var s=i(e),n={name:"zh",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(o,h){return h==="W"?o+"周":o+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s后",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(o,h){var a=100*o+h;return a<600?"凌晨":a<900?"早上":a<1100?"上午":a<1300?"中午":a<1800?"下午":"晚上"}};return s.default.locale(n,null,!0),n})})(ie);const se=(f,t)=>{const e=t.prototype;e.setLocale=function(s){return this.$locale=s||D().locale(),this.$L=this.$locale,this};const i=e.format;e.format=function(s){return this.$L=D().locale(),i.bind(this)(s)}};D.extend(Ht),D.extend(It),D.extend(Wt),D.extend(Gt),D.extend(zt),D.extend(Pt),D.extend(Ut),D.extend(Xt),D.extend(qt),D.extend(Zt),D.extend(Jt),D.extend(te),D.extend(se);function wt(f){try{if(D.locale()===f)return;if(D.locale(f)!==f)throw Error();C.info(`Locale set to ${f}`)}catch{C.warn(`Failed to set locale ${f}, fallback to en`),D.locale("en")}}const Z=()=>({small:{hour:15,day:15,week:5,month:3,quarter:3},normal:{hour:30,day:30,week:10,month:7,quarter:7},large:{hour:60,day:60,week:20,month:14,quarter:14}});class ne{constructor(){r(this,"startTime",D().startOf("day"));r(this,"endTime",D().endOf("day"));r(this,"targetEnd",D().endOf("day"));r(this,"strictStart",!1);r(this,"strictEnd",!1);r(this,"isStrict",!1);r(this,"isAuto",!1);r(this,"timeline",[]);r(this,"headerGroupFormat");r(this,"headerCellFormat");r(this,"isDirty",!0);r(this,"isFirstTime",!0);r(this,"allWidth",0);r(this,"cellWidth");r(this,"unit","day");this.cellWidth=E.cloneDeep(Z().normal)}getStartTime(){return this.startTime}getEndTime(){return this.endTime}getCellWidth(){const t=this.cellWidth[this.getChildUnit()];if(this.isAuto){const e=this.allWidth/this.getCellCount();return Math.max(isNaN(e)?0:e,t)}return t}getCellCount(){return this.timeline.reduce((t,e)=>{var i;return t+(((i=e.children)==null?void 0:i.length)||0)},0)}getCellUnit(){return this.getFinelyUnit()}setAllWidth(t){if(this.allWidth=t,!this.strictEnd){const e=this.getCellWidth(),i=this.targetEnd.diff(this.startTime,this.getFinelyUnit());if(e*i<this.allWidth){const s=this.allWidth-e*i,n=Math.ceil(s/e);this.endTime=this.targetEnd.add(n,this.getFinelyUnit()),this.invalidateCache()}}}getTimeLeft(t){const e=this.getCellWidth(),i=this.getFinelyUnit(),s=60*60*(i==="day"?24:1)/e;return t.diff(this.startTime,"second")/s}getTimeByLeft(t){const e=this.getCellWidth(),i=this.getFinelyUnit(),s=60*60*(i==="day"?24:1)/e,n=t*s;return this.startTime.add(n,"second")}init(t){this.isDirty=!0;const{unit:e,chart:i}=t;this.isAuto=!!i.autoCellWidth;const s={hour:"hour",day:"day",week:"week",month:"month",quarter:"quarter"}[e];s||C.warn(`Unknown unit: [${e}]. Falling back to "day".`),this.unit=s||"day",i.startTime&&(this.startTime=D(i.startTime).startOf(this.getFinelyUnit()),this.strictStart=!0),i.endTime&&(this.endTime=D(i.endTime).endOf(this.getFinelyUnit()),this.strictEnd=!0),this.isStrict=this.strictStart&&this.strictEnd,i.cellWidth&&(E.isNumber(i.cellWidth)?this.cellWidth={hour:i.cellWidth,day:i.cellWidth,week:i.cellWidth,month:i.cellWidth,quarter:i.cellWidth}:E.isString(i.cellWidth)?this.cellWidth=E.cloneDeep(Z()[i.cellWidth]||Z().normal):E.isObject(i.cellWidth)&&(this.cellWidth=Object.assign(this.cellWidth,i.cellWidth))),this.headerCellFormat=i.headerCellFormat,this.headerGroupFormat=i.headerGroupFormat}update(t){this.init(t),this.endTime=this.targetEnd.clone()}setDate(t,e){this.isStrict||(!this.strictStart&&t&&(this.isFirstTime||t.isBefore(this.startTime))&&(this.startTime=t.startOf(this.getFinelyUnit())),!this.strictEnd&&e&&(this.isFirstTime||e.isAfter(this.endTime))&&(this.endTime=e.endOf(this.getFinelyUnit())),this.targetEnd=this.endTime.clone(),this.isFirstTime=!1,this.invalidateCache())}getTimeline(){if(!this.isDirty&&this.timeline.length>0)return this.timeline;const t=[];let e=this.startTime.clone();for(t.push({date:e,label:this.formatterGroupLabel(e),children:[{date:e,label:this.formatterCellLabel(e)}]});e.isSameOrBefore(this.endTime,this.getFinelyUnit());){const i=e.add(1,this.getFinelyUnit()).startOf(this.getFinelyUnit()).clone(),s=this.formatterGroupLabel(i),n=t.find(o=>o.label===s);n?(n.children||(n.children=[]),n.children.push({date:i,label:this.formatterCellLabel(i)})):t.push({date:i,label:s,children:[{date:i,label:this.formatterCellLabel(i)}]}),e=i}return this.isDirty=!1,this.timeline=t,t}clear(){this.isDirty=!0,this.isFirstTime=!0}invalidateCache(){this.isDirty=!0}getFinelyUnit(){return this.unit==="hour"?"hour":"day"}getChildUnit(){return this.unit}getGroupUnit(){switch(this.unit){case"hour":return"day";case"month":case"quarter":return"year";case"day":case"week":default:return"month"}}formatterGroupLabel(t){if(E.isFunction(this.headerGroupFormat)){const i=this.headerGroupFormat(t.toDate(),this.unit);if(i)return i}if(E.isString(this.headerGroupFormat))return t.format(this.headerGroupFormat);switch(this.getGroupUnit()){case"month":return t.format("YYYY-MM");case"year":return t.format("YYYY");case"day":default:return t.format("YYYY-MM-DD")}}formatterCellLabel(t){if(E.isFunction(this.headerCellFormat)){const i=this.headerCellFormat(t.toDate(),this.unit);if(i)return i}if(E.isString(this.headerCellFormat))return t.format(this.headerCellFormat);switch(this.getChildUnit()){case"hour":return t.format("H");case"week":return t.format("wo");case"month":return t.format("MMM");case"quarter":return t.format("[Q]Q");case"day":default:return t.format("Do")}}getTotalWidth(){return this.getCellCount()*this.getCellWidth()}expand(t,e=1){t==="left"?this.startTime=this.startTime.subtract(e,this.getFinelyUnit()):t==="right"?this.endTime=this.endTime.add(e,this.getFinelyUnit()):t==="all"&&(this.startTime=this.startTime.subtract(e,this.getFinelyUnit()),this.endTime=this.endTime.add(e,this.getFinelyUnit())),this.targetEnd=this.endTime.clone(),this.invalidateCache()}isInTimeAxis(t){return t.isSameOrAfter(this.startTime)&&t.isSameOrBefore(this.endTime)}}class oe{constructor(t,e){r(this,"optionManager");r(this,"dataManager");r(this,"columnManager");r(this,"timeAxis");this.context=t;const i=E.omit(e,["data"]),s=e==null?void 0:e.data;if(s&&!E.isArray(s))throw C.exception("Data should be a array.");this.optionManager=new St,this.optionManager.setOptions(i),i.locale&&wt(i.locale),this.timeAxis=new ne,this.timeAxis.init(this.optionManager.getOptions()),this.columnManager=new Dt(this.context),i.table&&i.table.columns&&this.columnManager.init(i.table.columns),this.dataManager=new Lt(this,this.context.event),s&&this.dataManager.setData(s,!0)}getOptionManager(){return this.optionManager}getDataManager(){return this.dataManager}getColumnManager(){return this.columnManager}getTimeAxis(){return this.timeAxis}setOption(t,e={merge:!0}){const i=E.omit(t,["data"]),s=t==null?void 0:t.data;E.isArray(s)&&this.dataManager.setData(s,!1),this.optionManager.setOptions(i,e),i.locale&&wt(i.locale),i.table&&i.table.columns&&this.columnManager.update(i.table.columns),this.timeAxis.update(this.optionManager.getOptions())}updateTime(t,e){this.timeAxis.setDate(t,e)}}class re{constructor(t,e,i){r(this,"rootElement");r(this,"options");r(this,"hScrollbar");r(this,"vScrollbar");r(this,"hScrollThumb");r(this,"vScrollThumb");r(this,"scrollbarContainer");r(this,"viewportWidth",0);r(this,"viewportHeight",0);r(this,"contentWidth",0);r(this,"contentHeight",0);r(this,"scrollLeft",0);r(this,"scrollTop",0);r(this,"isDraggingHScroll",!1);r(this,"isDraggingVScroll",!1);r(this,"isMouseOverRoot",!1);r(this,"isMouseOverScrollbar",!1);r(this,"hideTimeout",null);r(this,"showTimeout",null);r(this,"isVisible",!1);r(this,"dragStartX",0);r(this,"dragStartY",0);r(this,"thumbStartScrollLeft",0);r(this,"thumbStartScrollTop",0);r(this,"isAnimating",!1);r(this,"animationFrameId",null);r(this,"animationStartTime",0);r(this,"animationStartScrollLeft",0);r(this,"animationStartScrollTop",0);r(this,"animationTargetScrollLeft",0);r(this,"animationTargetScrollTop",0);r(this,"animationSource","api");r(this,"throttledHandleMouseMove");r(this,"throttledHandleWheel");r(this,"handleRootMouseMove",()=>{!this.isVisible&&this.isMouseOverRoot?this.scheduleShow():this.isVisible&&!this.isMouseOverScrollbar&&this.scheduleHide()});r(this,"handleScrollbarMouseEnter",()=>{this.isMouseOverScrollbar=!0,this.scheduleShow()});r(this,"handleScrollbarMouseLeave",()=>{this.isMouseOverScrollbar=!1,this.isMouseOverRoot&&this.scheduleHide()});r(this,"handleMouseEnter",()=>{this.isMouseOverRoot=!0,this.scheduleShow()});r(this,"handleMouseLeave",()=>{this.isMouseOverRoot=!1,!this.isDraggingHScroll&&!this.isDraggingVScroll&&!this.isMouseOverScrollbar&&(this.clearTimeouts(!0,!1),this.scheduleHide())});r(this,"handleHorizontalThumbMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.isDraggingHScroll=!0,this.dragStartX=t.clientX,this.thumbStartScrollLeft=this.scrollLeft,this.hScrollThumb.style.backgroundColor=this.options.thumb.color,this.scheduleShow(),document.addEventListener("mousemove",this.throttledHandleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)});r(this,"handleVerticalThumbMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.isDraggingVScroll=!0,this.dragStartY=t.clientY,this.thumbStartScrollTop=this.scrollTop,this.vScrollThumb.style.backgroundColor=this.options.thumb.color,this.scheduleShow(),document.addEventListener("mousemove",this.throttledHandleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)});r(this,"handleHorizontalTrackMouseDown",t=>{if(t.target!==this.hScrollbar)return;t.preventDefault();const e=this.hScrollbar.getBoundingClientRect(),i=this.hScrollThumb.offsetWidth,s=t.clientX-e.left,n=this.hScrollbar.clientWidth,o=this.contentWidth-this.viewportWidth,h=n-i,a=(s-i/2)/h*o;this.scrollTo({x:a,y:this.scrollTop},"track")});r(this,"handleVerticalTrackMouseDown",t=>{if(t.target!==this.vScrollbar)return;t.preventDefault();const e=this.vScrollbar.getBoundingClientRect(),i=this.vScrollThumb.offsetHeight,s=t.clientY-e.top,n=this.vScrollbar.clientHeight,o=this.contentHeight-this.viewportHeight,h=n-i,a=(s-i/2)/h*o;this.scrollTo({x:this.scrollLeft,y:a},"track")});r(this,"handleMouseUp",()=>{if(this.isDraggingHScroll||this.isDraggingVScroll){const t=this.isDraggingHScroll,e=this.isDraggingVScroll;this.isDraggingHScroll=!1,this.isDraggingVScroll=!1,t&&(this.hScrollThumb.style.backgroundColor=this.options.thumb.color),e&&(this.vScrollThumb.style.backgroundColor=this.options.thumb.color),document.removeEventListener("mousemove",this.throttledHandleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),!this.isMouseOverRoot&&!this.isMouseOverScrollbar?this.scheduleHide():this.scheduleHide()}});r(this,"animationStep",t=>{if(!this.isAnimating)return;const e=t-this.animationStartTime,i=this.options.animationDuration,s=Math.min(1,e/i),n=s*(2-s),o=this.animationStartScrollLeft+(this.animationTargetScrollLeft-this.animationStartScrollLeft)*n,h=this.animationStartScrollTop+(this.animationTargetScrollTop-this.animationStartScrollTop)*n,a=this.scrollLeft!==o,d=this.scrollTop!==h;(a||d)&&(this.scrollLeft=o,this.scrollTop=h,this.updateThumbStyles(),this.root.event.emit(b.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:this.animationSource})),s<1?this.animationFrameId=requestAnimationFrame(this.animationStep):(this.isAnimating=!1,this.animationFrameId=null,(this.scrollLeft!==this.animationTargetScrollLeft||this.scrollTop!==this.animationTargetScrollTop)&&(this.scrollLeft=this.animationTargetScrollLeft,this.scrollTop=this.animationTargetScrollTop,this.updateThumbStyles(),this.root.event.emit(b.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:this.animationSource})),this.scheduleHide())});this.root=t,this.rootElement=e,this.options=E.merge({showHorizontal:!0,showVertical:!0,track:{size:8,radius:4,color:"transparent"},thumb:{size:30,radius:4,color:"rgba(0, 0, 0, 0.4)"},showDelay:0,hideDelay:500,animationDuration:100,showDuration:200,hideDuration:200},i),this.throttledHandleMouseMove=E.throttle(this.handleMouseMove.bind(this),16),this.throttledHandleWheel=E.throttle(this.handleWheel.bind(this),16,{leading:!0,trailing:!1}),this.createElements(),this.applyStyles(),this.bindEvents(),this.rootElement.matches(":hover")?this.handleMouseEnter():(this.clearTimeouts(),this.hideScrollbars(!0))}createElements(){this.scrollbarContainer=document.createElement("div"),this.scrollbarContainer.className="x-gantt-scrollbar-container",this.rootElement.appendChild(this.scrollbarContainer),this.hScrollbar=this.createScrollbarElement("horizontal"),this.hScrollThumb=this.createScrollThumbElement("horizontal"),this.hScrollbar.appendChild(this.hScrollThumb),this.vScrollbar=this.createScrollbarElement("vertical"),this.vScrollThumb=this.createScrollThumbElement("vertical"),this.vScrollbar.appendChild(this.vScrollThumb),this.scrollbarContainer.appendChild(this.hScrollbar),this.scrollbarContainer.appendChild(this.vScrollbar)}createScrollbarElement(t){const e=document.createElement("div");return e.className=`x-gantt-scrollbar x-gantt-${t}-scrollbar`,e}createScrollThumbElement(t){const e=document.createElement("div");return e.className=`x-gantt-scrollbar-thumb x-gantt-${t}-thumb`,e}applyStyles(){const t=this.scrollbarContainer.style;t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="none",t.zIndex="100",this.applyScrollbarStyles(this.hScrollbar,"horizontal"),this.applyScrollbarStyles(this.vScrollbar,"vertical"),this.applyThumbStyles(this.hScrollThumb,"horizontal"),this.applyThumbStyles(this.vScrollThumb,"vertical")}applyScrollbarStyles(t,e){const i=t.style;i.position="absolute",i.backgroundColor=this.options.track.color,i.borderRadius=`${this.options.track.size/2}px`,i.opacity="0",i.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`,i.pointerEvents="auto",e==="horizontal"?(i.bottom="0px",i.left="0px",i.height=`${this.options.track.size}px`,i.width="0px"):(i.right="0px",i.top="0px",i.width=`${this.options.track.size}px`,i.height="0px")}applyThumbStyles(t,e){const i=t.style;i.position="absolute",i.backgroundColor=this.options.thumb.color,i.borderRadius=`${this.options.thumb.radius}px`,i.cursor="pointer",i.transition="background-color 0.2s",i.pointerEvents="auto",e==="horizontal"?(i.height="100%",i.top="0",i.left="0"):(i.width="100%",i.left="0",i.top="0")}bindEvents(){this.rootElement.addEventListener("mouseenter",this.handleMouseEnter),this.rootElement.addEventListener("mouseleave",this.handleMouseLeave),this.rootElement.addEventListener("mousemove",this.handleRootMouseMove),this.hScrollThumb.addEventListener("mousedown",this.handleHorizontalThumbMouseDown),this.vScrollThumb.addEventListener("mousedown",this.handleVerticalThumbMouseDown),this.hScrollbar.addEventListener("mousedown",this.handleHorizontalTrackMouseDown),this.vScrollbar.addEventListener("mousedown",this.handleVerticalTrackMouseDown),this.hScrollbar.addEventListener("mouseenter",this.handleScrollbarMouseEnter),this.vScrollbar.addEventListener("mouseenter",this.handleScrollbarMouseEnter),this.hScrollbar.addEventListener("mouseleave",this.handleScrollbarMouseLeave),this.vScrollbar.addEventListener("mouseleave",this.handleScrollbarMouseLeave),this.rootElement.addEventListener("wheel",this.throttledHandleWheel,{passive:!1})}unbindEvents(){this.rootElement.removeEventListener("mouseenter",this.handleMouseEnter),this.rootElement.removeEventListener("mouseleave",this.handleMouseLeave),this.rootElement.removeEventListener("mousemove",this.handleRootMouseMove),this.hScrollThumb.removeEventListener("mousedown",this.handleHorizontalThumbMouseDown),this.vScrollThumb.removeEventListener("mousedown",this.handleVerticalThumbMouseDown),this.hScrollbar.removeEventListener("mousedown",this.handleHorizontalTrackMouseDown),this.vScrollbar.removeEventListener("mousedown",this.handleVerticalTrackMouseDown),this.hScrollbar.removeEventListener("mouseenter",this.handleScrollbarMouseEnter),this.vScrollbar.removeEventListener("mouseenter",this.handleScrollbarMouseEnter),this.hScrollbar.removeEventListener("mouseleave",this.handleScrollbarMouseLeave),this.vScrollbar.removeEventListener("mouseleave",this.handleScrollbarMouseLeave),this.rootElement.removeEventListener("wheel",this.throttledHandleWheel),document.removeEventListener("mousemove",this.throttledHandleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}handleMouseMove(t){if(!(!this.isDraggingHScroll&&!this.isDraggingVScroll)){if(this.scheduleShow(),this.isDraggingHScroll){const e=t.clientX-this.dragStartX,i=this.hScrollbar.clientWidth,s=this.hScrollThumb.offsetWidth,n=Math.max(0,i-s),o=Math.max(0,this.contentWidth-this.viewportWidth);if(n===0||o===0)return;const h=e/n*o,a=this.thumbStartScrollLeft+h;this.scrollTo({x:a,y:this.scrollTop},"drag")}if(this.isDraggingVScroll){const e=t.clientY-this.dragStartY,i=this.vScrollbar.clientHeight,s=this.vScrollThumb.offsetHeight,n=Math.max(0,i-s),o=Math.max(0,this.contentHeight-this.viewportHeight);if(n===0||o===0)return;const h=e/n*o,a=this.thumbStartScrollTop+h;this.scrollTo({x:this.scrollLeft,y:a},"drag")}}}handleWheel(t){if(t.target!==this.rootElement&&!this.rootElement.contains(t.target)&&C.debug("Wheel event ignored, target not root or descendant:",t.target),!this.isMouseOverRoot&&!this.isMouseOverScrollbar){C.debug("Wheel event ignored, mouse not over root or scrollbar");return}const e=this.canScrollHorizontal(),i=this.canScrollVertical();if(!e&&!i)return;t.preventDefault();let s=t.deltaX,n=t.deltaY;Math.abs(t.deltaX)<Math.abs(t.deltaY)&&t.shiftKey&&e&&(s=n,n=0);const o=this.scrollLeft+s,h=this.scrollTop+n;this.scrollLeft=o,this.scrollTop=h,this.updateThumbStyles(),this.root.event.emit(b.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:"wheel"})}animateWheelScroll(t,e){this.cancelAnimation();const i=this.clampScroll({x:t,y:e});if(this.scrollLeft===i.x&&this.scrollTop===i.y)return;this.isAnimating=!0,this.animationStartTime=performance.now(),this.animationStartScrollLeft=this.scrollLeft,this.animationStartScrollTop=this.scrollTop,this.animationTargetScrollLeft=i.x,this.animationTargetScrollTop=i.y,this.animationSource="wheel";const s=150,n=o=>{if(!this.isAnimating)return;const h=o-this.animationStartTime,a=Math.min(1,h/s),d=a*(2-a),u=this.animationStartScrollLeft+(this.animationTargetScrollLeft-this.animationStartScrollLeft)*d,l=this.animationStartScrollTop+(this.animationTargetScrollTop-this.animationStartScrollTop)*d,c=this.scrollLeft!==u,p=this.scrollTop!==l;(c||p)&&(this.scrollLeft=u,this.scrollTop=l,this.updateThumbStyles(),this.root.event.emit(b.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:"wheel"})),a<1?this.animationFrameId=requestAnimationFrame(n):(this.isAnimating=!1,this.animationFrameId=null,(this.scrollLeft!==this.animationTargetScrollLeft||this.scrollTop!==this.animationTargetScrollTop)&&(this.scrollLeft=this.animationTargetScrollLeft,this.scrollTop=this.animationTargetScrollTop,this.updateThumbStyles(),this.root.event.emit(b.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:"wheel"})),this.scheduleHide())};this.animationFrameId=requestAnimationFrame(n)}clearTimeouts(t=!0,e=!0){t&&this.showTimeout!==null&&(window.clearTimeout(this.showTimeout),this.showTimeout=null),e&&this.hideTimeout!==null&&(window.clearTimeout(this.hideTimeout),this.hideTimeout=null)}scheduleShow(){if(this.isVisible||this.showTimeout!==null){this.hideTimeout!==null&&this.clearTimeouts(!1,!0);return}this.clearTimeouts(!0,!0),this.options.showDelay<=0?this.showScrollbars():this.showTimeout=window.setTimeout(()=>{this.showScrollbars(),this.showTimeout=null},this.options.showDelay)}showScrollbars(){this.clearTimeouts(),this.isVisible=!0,this.hScrollbar.style.transition=`opacity ${this.options.showDuration/1e3}s ease-in`,this.vScrollbar.style.transition=`opacity ${this.options.showDuration/1e3}s ease-in`,requestAnimationFrame(()=>{this.canScrollHorizontal()&&this.options.showHorizontal?this.hScrollbar.style.opacity="1":this.hScrollbar.style.opacity="0",this.canScrollVertical()&&this.options.showVertical?this.vScrollbar.style.opacity="1":this.vScrollbar.style.opacity="0",setTimeout(()=>{this.isVisible&&(this.hScrollbar.style.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`,this.vScrollbar.style.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`)},this.options.showDuration)}),this.scheduleHide()}scheduleHide(){if(this.isDraggingHScroll||this.isDraggingVScroll||this.isMouseOverScrollbar){this.clearTimeouts(!0,!0);return}this.hideTimeout===null&&(this.clearTimeouts(!0,!1),this.hideTimeout=window.setTimeout(()=>{!this.isMouseOverRoot&&!this.isDraggingHScroll&&!this.isDraggingVScroll&&!this.isMouseOverScrollbar&&this.hideScrollbars(),this.hideTimeout=null},this.options.hideDelay))}hideScrollbars(t=!1){!t&&(this.isDraggingHScroll||this.isDraggingVScroll||this.isMouseOverScrollbar)||(this.clearTimeouts(!0,!0),this.isVisible=!1,this.hScrollbar.style.opacity="0",this.vScrollbar.style.opacity="0")}updateSize(t,e,i,s,n=0,o=0){this.viewportWidth=Math.max(0,t),this.viewportHeight=Math.max(0,e),this.contentWidth=Math.max(this.viewportWidth,i),this.contentHeight=Math.max(this.viewportHeight,s);const h=this.canScrollHorizontal()&&this.options.showHorizontal,a=this.canScrollVertical()&&this.options.showVertical;if(h){const u=this.viewportWidth-(a?this.options.track.size:0);this.hScrollbar.style.display="block",this.hScrollbar.style.left=`${n}px`,this.hScrollbar.style.width=`${Math.max(0,u)}px`,this.hScrollbar.style.bottom="0px",this.hScrollbar.style.right=a?`${this.options.track.size}px`:"0px"}else this.hScrollbar.style.display="none";if(a){const u=this.viewportHeight-o-(h?this.options.track.size:0);this.vScrollbar.style.display="block",this.vScrollbar.style.top=`${o}px`,this.vScrollbar.style.height=`${Math.max(0,u)}px`,this.vScrollbar.style.right="0px",this.vScrollbar.style.bottom=h?`${this.options.track.size}px`:"0px"}else this.vScrollbar.style.display="none";this.updateThumbStyles();const d=this.clampScroll({x:this.scrollLeft,y:this.scrollTop});(d.x!==this.scrollLeft||d.y!==this.scrollTop)&&(this.scrollLeft=d.x,this.scrollTop=d.y,this.updateThumbStyles(),this.root.event.emit(b.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:"api"})),this.isMouseOverRoot||this.isDraggingHScroll||this.isDraggingVScroll?this.scheduleShow():!h&&!a?this.hideScrollbars(!0):this.isVisible?this.scheduleShow():this.hideScrollbars(!0)}updateThumbStyles(){if(this.canScrollHorizontal()&&this.options.showHorizontal){const t=this.hScrollbar.clientWidth,e=Math.max(this.options.thumb.size,t*(this.viewportWidth/this.contentWidth)),i=Math.min(t,e);this.hScrollThumb.style.width=`${i}px`;const s=this.contentWidth-this.viewportWidth,n=t-i,o=s>0?this.scrollLeft/s*n:0;this.hScrollThumb.style.transform=`translateX(${Math.max(0,Math.min(o,n))}px)`,this.hScrollThumb.style.left="0px"}else this.hScrollThumb.style.width="0px";if(this.canScrollVertical()&&this.options.showVertical){const t=this.vScrollbar.clientHeight,e=Math.max(this.options.thumb.size,t*(this.viewportHeight/this.contentHeight)),i=Math.min(t,e);this.vScrollThumb.style.height=`${i}px`;const s=this.contentHeight-this.viewportHeight,n=t-i,o=s>0?this.scrollTop/s*n:0;this.vScrollThumb.style.transform=`translateY(${Math.max(0,Math.min(o,n))}px)`,this.vScrollThumb.style.top="0px"}else this.vScrollThumb.style.height="0px"}canScrollHorizontal(){return this.contentWidth>this.viewportWidth}canScrollVertical(){return this.contentHeight>this.viewportHeight}clampScroll(t){const e=Math.max(0,this.contentWidth-this.viewportWidth),i=Math.max(0,this.contentHeight-this.viewportHeight);return{x:Math.max(0,Math.min(t.x,e)),y:Math.max(0,Math.min(t.y,i))}}scrollTo(t,e="api"){this.scheduleShow();const i=this.clampScroll(E.merge(this.getScrollPosition(),t));if(this.scrollLeft===i.x&&this.scrollTop===i.y){if(this.isAnimating&&this.animationTargetScrollLeft===i.x&&this.animationTargetScrollTop===i.y)return;this.cancelAnimation();return}const s=(e==="api"||e==="track")&&this.options.animationDuration>0;if(this.cancelAnimation(),s)this.isAnimating=!0,this.animationStartTime=performance.now(),this.animationStartScrollLeft=this.scrollLeft,this.animationStartScrollTop=this.scrollTop,this.animationTargetScrollLeft=i.x,this.animationTargetScrollTop=i.y,this.animationSource=e,this.animationFrameId=requestAnimationFrame(this.animationStep);else{this.isAnimating=!1;const n=this.scrollLeft!==i.x,o=this.scrollTop!==i.y;(n||o)&&(this.scrollLeft=i.x,this.scrollTop=i.y,this.updateThumbStyles(),this.root.event.emit(b.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:e}))}}cancelAnimation(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isAnimating=!1}getScrollPosition(){return{x:this.scrollLeft,y:this.scrollTop}}destroy(){this.unbindEvents(),this.clearTimeouts(),this.cancelAnimation(),this.scrollbarContainer.parentNode&&this.scrollbarContainer.parentNode.removeChild(this.scrollbarContainer),this.rootElement=null,this.eventManager=null,this.hScrollbar=null,this.vScrollbar=null,this.hScrollThumb=null,this.vScrollThumb=null,this.scrollbarContainer=null,C.debug("Scrollbar destroyed")}}function B(f,t=""){const e=["px","%","vh","vw","rem","em"];if(f==null)return t;if(typeof f=="number")return isFinite(f)?`${f}px`:t;if(typeof f=="string"){const i=f.trim();if(i==="")return t;for(const n of e)if(i.endsWith(n)){const o=i.substring(0,i.length-n.length).trim(),h=Number(o);if(!isNaN(h)&&isFinite(h))return`${h}${n}`;break}const s=Number(i);if(!isNaN(s)&&isFinite(s))return`${s}px`}return t}class j{constructor(t,e,i,s,n,o,h=1,a=1,d){r(this,"element");r(this,"isEmpty",!1);r(this,"isHandler",!1);this.context=t,this.container=e,this.column=i,this.task=s,this.rowIndex=n,this.colIndex=o,this.colspan=h,this.rowspan=a,this.isEmpty=d==="empty",this.isHandler=d==="handler",this.element=document.createElement("div"),this.element.className="x-gantt-table-cell",this.element.style.boxSizing="border-box",this.element.style.display="inline-flex",this.element.style.flexShrink="0",this.element.style.flexGrow="0",this.element.style.flexBasis="auto",this.element.style.pointerEvents="all",this.element.style.setProperty("border-color",this.context.getOptions().border.color,"important"),this.element.style.textAlign=this.column.column.align||this.context.getOptions().table.align,!this.context.store.getColumnManager().isLastColumn(this.column.key)&&this.context.getOptions().border.show&&!this.isEmpty&&this.element.classList.add("border"),this.updateWidth(),this.updateHeight(),this.isEmpty?(this.element.style.borderBottom="none",this.element.style.pointerEvents="none",this.element.style.backgroundColor="transparent",this.element.style.setProperty("border-color","transparent","important")):this.isHandler?this.setHandler():this.setContent(),this.container.appendChild(this.element)}setContent(){const t=document.createElement("div");if(t.className="x-gantt-table-cell__content",t.style.overflow="hidden",(this.column.column.ellipsis??!0??this.context.getOptions().table.ellipsis)&&(t.style.textOverflow="ellipsis"),t.style.whiteSpace="nowrap",t.style.flex="1",t.style.height="100%",t.style.alignContent="center",this.colIndex===0&&(t.style.paddingLeft=B(this.task.level*this.context.getOptions().row.indent,"16px")),typeof this.column.column.render=="function")try{const e=this.column.column.render(this.task.getEmitData());typeof e=="string"?t.innerHTML=e:e instanceof HTMLElement?t.appendChild(e):C.warn("Table cell render function does not return a valid value.",e)}catch(e){C.error("Table cell render error:",e),t.textContent=this.task.getField(this.column.column.field)??this.context.getOptions().table.emptyText}else t.textContent=this.task.getField(this.column.column.field)??this.context.getOptions().table.emptyText;this.column.column.customStyle&&Object.assign(t.style,this.column.column.customStyle),this.element.appendChild(t)}setHandler(){const t=document.createElement("div");if(t.className="x-gantt-table-cell__content",t.style.overflow="hidden",t.style.whiteSpace="nowrap",t.style.display="inline-flex",t.style.flex="1",t.style.height="100%",this.context.getOptions().selection.enabled){const e=document.createElement("div");e.style.display="flex",e.style.flex="0.5",e.style.justifyContent="center",e.style.alignItems="center",new ot(this.context,e,this.task),t.appendChild(e)}if(this.context.getOptions().expand.show&&this.task.children&&this.task.children.length>0){const e=document.createElement("div");e.className="x-gantt-table-cell__expand",e.style.display="flex",e.style.flex="0.5",e.style.color=this.context.getOptions().primaryColor,e.style.alignItems="center",e.style.justifyContent="center",e.style.height="100%",e.style.width="14px",e.style.height="100%",e.style.cursor="pointer",e.innerHTML='<svg t="1746693752280" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2612" width="14" height="14"><path d="M724.48 521.728c-1.8432 7.7824-5.7344 14.848-11.3664 20.48l-341.9136 342.016c-16.6912 16.6912-43.7248 16.6912-60.3136 0s-16.6912-43.7248 0-60.3136L622.6944 512 310.8864 200.0896c-16.6912-16.6912-16.6912-43.7248 0-60.3136 16.6912-16.6912 43.7248-16.6912 60.3136 0l341.9136 341.9136c10.8544 10.8544 14.6432 26.112 11.3664 40.0384z" fill="currentColor" p-id="2613"></path></svg>',e.style.transform=this.task.expanded?"rotate(90deg)":"",e.addEventListener("click",i=>{i.stopPropagation(),this.context.store.getDataManager().expandTask(this.task.id,!1)}),t.appendChild(e)}this.element.appendChild(t)}remove(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}updateWidth(){if(this.isHandler){this.element.style.width=B(this.context.store.getColumnManager().getHandlerColumn().width);return}const t=this.context.store.getColumnManager().getLeafColumns().slice(this.colIndex,this.colIndex+Math.max(1,this.colspan)).reduce((e,i)=>e+i.width,0);this.element.style.width=B(t)}updateHeight(){const t=this.context.getOptions().row.height;this.element.style.height=B(t*Math.max(1,this.rowspan))}}class bt{constructor(t,e,i,s,n=!1){r(this,"element");r(this,"cells",[]);this.context=t,this.container=e,this.task=i,this.top=s,this.element=document.createElement("div"),this.element.className="x-gantt-table-row",this.element.style.display="flex",this.element.style.flexDirection="row",this.element.style.flexWrap="nowrap",this.element.style.position="absolute",this.element.style.pointerEvents="none",this.element.style.width=`${this.context.store.getColumnManager().getTotalWidth()}px`,n&&this.raise(),this.updateStyles(),this.container.appendChild(this.element),this.bindEvents(),this.registerEvents()}bindEvents(){this.element.addEventListener("mouseenter",()=>{this.context.event.emit(b.ROW_HIGHLIGHT,this.task.id)}),this.element.addEventListener("mouseleave",()=>{this.context.event.emit(b.ROW_UNHIGHLIGHT,this.task.id)}),this.element.addEventListener("click",t=>{this.context.store.getDataManager().isTaskSelected(this.task.id)||(this.context.store.getDataManager().selectTask(this.task.id),this.context.event.emit(b.ROW_CLICK,t,this.task))}),this.element.addEventListener("dblclick",t=>{this.context.event.emit(b.ROW_DBL_CLICK,t,this.task)}),this.element.addEventListener("contextmenu",t=>{t.preventDefault(),this.context.store.getDataManager().selectTask(this.task.id),this.context.event.emit(b.ROW_CONTEXTMENU,t,this.task.id)})}registerEvents(){this.context.event.on(b.ROW_HIGHLIGHT,t=>{this.task.id===t?this.element.classList.add("hover"):this.element.classList.remove("hover")}),this.context.event.on(b.ROW_UNHIGHLIGHT,t=>{this.task.id===t&&this.element.classList.remove("hover")}),this.context.event.on(b.TASK_SELECTED,t=>{this.task.id===t.id&&this.element.classList.add("selected")}),this.context.event.on(b.TASK_UNSELECTED,t=>{this.task.id===t&&this.element.classList.remove("selected")})}updateStyles(){this.updateTop(this.top),this.context.store.getDataManager().isTaskSelected(this.task.id),this.element.style.backgroundColor=this.context.store.getOptionManager().getRowBackgroundColor(this.task)}raise(){this.element.style.zIndex="2"}updateTop(t){this.top=t;const e=this.context.store.getOptionManager().getOptions().row.height;this.element.style.top=`${-this.top+this.task.flatIndex*e}px`}create(){var i,s;this.clearCells();const t=this.context.store.getColumnManager().getHandlerColumn();if(t.width!==0){const n=new j(this.context,this.element,t,this.task,this.task.flatIndex,-1,1,1,"handler");this.cells.push(n)}const e=this.context.store.getColumnManager().getLeafColumns();for(let n=0;n<e.length;n++){const o=e[n],h=this.context.store.getColumnManager().getMergeInfo(this.task.id,n);if(h){if(h.task.id!==this.task.id){const a=new j(this.context,this.element,o,this.task,this.task.flatIndex,n,1,1,"empty");this.element.style.backgroundColor="transparent",this.raise(),this.cells.push(a)}}else{let a=1,d=1;const u=(s=(i=o.column).merge)==null?void 0:s.call(i,this.task.getField(o.column.field),this.task.data,n,this.task.level);if(u&&(typeof u.col!="number"?C.error("colspan function must returned a number"):a=u.col,typeof u.row!="number"?C.error("rowspan function must returned a number"):d=u.row),a>1||d>1){if(d>1)for(let m=1;m<d;m++){const g=this.context.store.getDataManager().getVisibleTasks()[this.task.flatIndex+m];if(g&&this.task.level!==g.level){d=m;break}}const c={task:this.task,originColumnIndex:n,colspan:a,rowspan:d};let p=this.task;for(let m=d;m>0;m--)if(p){for(let g=n+(m===d?1:0);g<a;g++)this.context.store.getColumnManager().addMergeInfo(p.id,g,c);p=this.context.store.getDataManager().getVisibleTasks().at(p.flatIndex+1)}for(let m=n+1;m<a;m++)this.context.store.getColumnManager().addMergeInfo(this.task.id,m,c)}const l=new j(this.context,this.element,o,this.task,this.task.flatIndex,n,a,d);this.cells.push(l)}}this.context.store.getDataManager().isTaskSelected(this.task.id)&&this.element.classList.add("selected")}update(){this.create()}updateWidth(){this.element.style.width=`${this.context.store.getColumnManager().getTotalWidth()}px`,this.cells.forEach(t=>t.updateWidth())}clearCells(){for(this.cells.forEach(t=>t.remove()),this.cells=[];this.element.firstChild;)this.element.removeChild(this.element.firstChild)}remove(){this.clearCells(),this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class he{constructor(t,e){r(this,"element");r(this,"rows",new Map);r(this,"mergeRows",new Map);this.context=t,this.container=e,this.element=document.createElement("div"),this.element.className="x-gantt-table-body",this.element.style.width="100%",this.element.style.position="relative",this.container.appendChild(this.element)}render(t,e){this.mergeRows.forEach(n=>n.remove()),this.mergeRows.clear();const i=new Set;e.forEach(n=>{i.add(n.id)});const s=[];this.rows.forEach((n,o)=>{i.has(o)||s.push(o)}),s.forEach(n=>{const o=this.rows.get(n);o&&o.remove(),this.rows.delete(n)}),e.forEach((n,o)=>{const h=n.id;if(this.rows.has(h)){const a=this.rows.get(h);a.update(),a.updateTop(t)}else{const a=new bt(this.context,this.element,n,t);a.create(),this.rows.set(h,a)}this.context.store.getColumnManager().getLeafColumns().forEach((a,d)=>{const u=this.context.store.getColumnManager().getMergeInfo(n.id,d);if(u&&u.rowspan>1){const l=u.task.id;if(!this.rows.has(l)&&!this.mergeRows.has(l)){const c=new bt(this.context,this.element,u.task,t,!0);c.create(),this.mergeRows.set(l,c)}}})})}refresh(t,e){this.rows.forEach(i=>{i.remove()}),this.rows.clear(),this.render(t,e)}updateTask(t){this.rows.has(t.id)&&this.rows.get(t.id).update()}update(){this.rows.forEach(t=>{t.update()})}updateWidth(){this.rows.forEach(t=>{t.updateWidth()}),this.mergeRows.forEach(t=>{t.updateWidth()})}}class J{constructor(t,e,i,s){r(this,"columnElement");this.context=t,this.root=e,this.container=i,this.column=s,this.columnElement=document.createElement("div"),this.initElement(),this.container.appendChild(this.columnElement)}initElement(){const t=this.context.store.getColumnManager(),e=t.getColumnWidth(this.column.key),i=this.column.column.headerAlign||this.context.getOptions().table.headerAlign,s=this.column.column.ellipsis??!0??this.context.getOptions().table.ellipsis;this.columnElement.className="x-gantt-table-header-cell",(t.isMultiHeader()||this.context.getOptions().border.show)&&this.columnElement.classList.add("border"),this.columnElement.style.height="100%",this.columnElement.style.width=`${e}px`,this.columnElement.style.display="flex",this.columnElement.style.flexShrink="0",this.columnElement.style.alignItems="center",this.columnElement.style.padding="0 8px",this.columnElement.style.boxSizing="border-box",this.columnElement.style.setProperty("border-color",this.context.getOptions().border.color,"important");const n=document.createElement("div");if(n.className="x-gantt-table-header-cell__content",n.style.flex="1",n.style.textAlign=i,n.style.overflow="hidden",n.style.whiteSpace="nowrap",s&&(n.style.textOverflow="ellipsis"),n.style.position="relative",n.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,n.style.fontSize=B(this.context.getOptions().header.fontSize),n.style.setProperty("color",this.context.getOptions().header.color,"important"),n.style.fontFamily=this.context.getOptions().header.fontFamily,this.column.column.headerRender){const o=this.column.column.headerRender();typeof o=="string"?n.innerHTML=o:o instanceof HTMLElement&&(n.innerHTML="",n.appendChild(o))}else n.textContent=this.column.label||this.column.column.label||"";this.column.column.customStyle&&Object.assign(n.style,this.column.column.customStyle),this.columnElement.appendChild(n),this.addResizeHandle()}setWidth(t){this.columnElement.style.width=`${t}px`,this.context.store.getColumnManager().setColumnWidth(this.column.key,t)}addResizeHandle(){if(this.column.column.resizable===!1||this.context.store.getColumnManager().isLastColumn(this.column.key))return;const t=document.createElement("div");t.className="x-gantt-column-resize-handle",t.style.position="absolute",t.style.top="0",t.style.right="0",t.style.width="5px",t.style.height="100%",t.style.cursor="col-resize",t.style.zIndex="2",this.columnElement.appendChild(t);let e=0,i=0,s=null,n=0;const o=d=>{d.preventDefault(),d.stopPropagation(),e=d.clientX,i=this.columnElement.offsetWidth,s=this.root.getBoundingClientRect();const u=c=>h(c),l=c=>a(c,u,l);document.addEventListener("mousemove",u),document.addEventListener("mouseup",l),n=e-s.left,this.context.event.emit(b.SHOW_GUIDELINE,n)},h=d=>{if(d.preventDefault(),!s)return;const u=d.clientX-e,l=i+u,c=Math.max(50,l),p=e-s.left-i,g=this.root.clientWidth-20;let x=p+c;x=Math.min(g,x),this.context.event.emit(b.MOVE_GUIDELINE,x)},a=(d,u,l)=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",l),this.context.event.emit(b.HIDE_GUIDELINE);const c=d.clientX-e,p=Math.max(50,i+c);this.setWidth(p)};t.addEventListener("mousedown",o)}}class K{constructor(t,e,i,s){r(this,"groupElement");r(this,"titleContainer");r(this,"childContainer");r(this,"children",[]);this.context=t,this.root=e,this.container=i,this.column=s,this.groupElement=document.createElement("div"),this.titleContainer=document.createElement("div"),this.childContainer=document.createElement("div"),this.initElement(),this.initChildren(),this.container.appendChild(this.groupElement)}initElement(){const e=this.context.getOptions().header.height/this.column.maxLevel;this.groupElement.className="x-gantt-table-header-group",(this.context.store.getColumnManager().isMultiHeader()||this.context.getOptions().border.show)&&this.groupElement.classList.add("border"),this.groupElement.style.display="flex",this.groupElement.style.flexShrink="0",this.groupElement.style.flexGrow="0",this.groupElement.style.flexDirection="column",this.groupElement.style.height="100%",this.groupElement.style.overflow="hidden",this.groupElement.style.boxSizing="border-box",this.titleContainer.className="x-gantt-table-header-cell",(this.context.store.getColumnManager().isMultiHeader()||this.context.getOptions().border.show)&&this.titleContainer.classList.add("border"),this.titleContainer.style.height=`${e}px`,this.titleContainer.style.flex="0 0 auto",this.titleContainer.style.display="flex",this.titleContainer.style.alignItems=this.context.getOptions().table.headerAlign,this.titleContainer.style.justifyContent="center",this.titleContainer.style.padding="0 8px",this.titleContainer.style.boxSizing="border-box",this.titleContainer.style.overflow="hidden",this.titleContainer.style.whiteSpace="nowrap",this.context.getOptions().table.ellipsis&&(this.titleContainer.style.textOverflow="ellipsis"),this.titleContainer.style.borderBottom=`1px solid ${this.context.getOptions().border.color}`,this.titleContainer.style.setProperty("border-color",this.context.getOptions().border.color,"important"),this.titleContainer.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,this.titleContainer.style.fontSize=B(this.context.getOptions().header.fontSize),this.titleContainer.style.fontFamily=this.context.getOptions().header.fontFamily,this.titleContainer.style.setProperty("color",this.context.getOptions().header.color,"important"),this.titleContainer.textContent=this.column.label||"",this.childContainer.className="x-gantt-table-header-children",this.childContainer.style.flex="1 0 auto",this.childContainer.style.display="flex",this.childContainer.style.width="100%",this.groupElement.appendChild(this.titleContainer),this.groupElement.appendChild(this.childContainer)}initChildren(){this.column.children.forEach(t=>{if(t.isLeaf){const e=new J(this.context,this.root,this.childContainer,t);this.children.push(e)}else if(t.children.length>0){const e=new K(this.context,this.root,this.childContainer,t);this.children.push(e)}})}}class ae{constructor(t,e){r(this,"headerElement");r(this,"headerColumns",[]);this.context=t,this.container=e,this.headerElement=document.createElement("div"),this.initElement(),this.container.appendChild(this.headerElement)}initElement(){this.headerElement.className="x-gantt-table-header",this.headerElement.style.display="flex",this.headerElement.style.height=`${this.context.getOptions().header.height}px`,this.headerElement.style.minHeight=`${Math.max(this.context.getOptions().header.height,30)}px`,this.headerElement.style.setProperty("background-color",this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,"important"),this.headerElement.style.setProperty("color",this.context.getOptions().header.color,"important"),this.headerElement.style.fontSize=`${this.context.getOptions().header.fontSize}px`,this.headerElement.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,this.headerElement.style.zIndex="10",this.headerElement.style.width="100%",this.headerElement.style.flexShrink="0",this.headerElement.style.borderBottom=`1px solid ${this.context.getOptions().border.color}`,this.headerElement.style.setProperty("border-color",this.context.getOptions().border.color,"important")}render(){this.headerColumns=[],this.headerElement.innerHTML="",this.initElement();const t=this.context.store.getColumnManager(),e=t.getColumns();if(t.getHandlerColumn().width!==0){const i=new J(this.context,this.headerElement,this.headerElement,t.getHandlerColumn());this.headerColumns.push(i)}e.forEach(i=>{if(i.isLeaf){const s=new J(this.context,this.headerElement,this.headerElement,i);this.headerColumns.push(s)}else if(i.children.length>0){const s=new K(this.context,this.headerElement,this.headerElement,i);this.headerColumns.push(s)}})}}class le{constructor(t,e){r(this,"tableContainer");r(this,"tableHeader");r(this,"tableBody");this.context=t,this.container=e,this.tableContainer=document.createElement("div"),this.tableContainer.className="x-gantt-table-container",this.tableContainer.style.position="relative",this.tableContainer.style.width="100%",this.tableContainer.style.height="100%",this.tableContainer.style.overflow="hidden",this.tableContainer.style.display="flex",this.tableContainer.style.flexDirection="column",this.container.appendChild(this.tableContainer),this.tableHeader=new ae(t,this.tableContainer),this.tableBody=new he(t,this.tableContainer),this.listenEvents()}render(t,e){this.tableHeader.render(),this.tableBody.render(t,e)}refresh(t,e){this.tableBody.render(t,e)}updateWidth(){this.tableBody.updateWidth()}updateTask(t){this.tableBody.updateTask(t)}listenEvents(){this.context.event.on(b.UPDATE_TABLE_HEADER,()=>{this.tableHeader.render()}),this.context.event.on(b.UPDATE_TABLE_BODY,()=>{this.tableBody.update()})}}class ce{constructor(t,e){r(this,"layer");r(this,"background");r(this,"groupHeader");r(this,"cellHeader");r(this,"cellCache",new Map);r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);this.context=t,this.stage=e,this.layer=new S.Layer,this.stage.add(this.layer),this.background=new S.Rect({fill:this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,name:"header-background"}),this.layer.add(this.background),this.groupHeader=new S.Group({name:"primary-header"}),this.cellHeader=new S.Group({name:"secondary-header"}),this.layer.add(this.groupHeader),this.layer.add(this.cellHeader),this.resize(this.stage.width()),this.registerEvents()}resize(t){this.width=t,this.height=this.context.getOptions().header.height,this.background.width(t),this.background.height(this.height),this.calculateHeader()}setOffset(t,e){this.offsetX!==t&&(this.offsetX=t,this.groupHeader.x(t),this.cellHeader.x(t),this.calculateHeader())}registerEvents(){this.context.event.on(b.ROW_HIGHLIGHT,t=>{this.highlightDate(t)}),this.context.event.on(b.ROW_UNHIGHLIGHT,t=>{this.unhighlightDate(t)}),this.context.event.on(b.UPDATE_TASK,t=>{this.highlightDate(t.id)})}render(){this.calculateHeader(),this.layer.moveToTop(),this.layer.batchDraw()}calculateHeader(){var d;this.clearHeader();const t=this.context.store.getTimeAxis(),e=t.getCellWidth(),i=Math.max(0,-this.offsetX),s=i+this.width,n=Math.floor(this.height/2),o=this.context.getOptions().border.color;this.layer.add(new S.Line({points:[0,n,this.width,n],stroke:o,strokeWidth:1})),this.layer.add(new S.Line({points:[0,this.height,this.width,this.height],stroke:o,strokeWidth:1}));const h=t.getTimeline();let a=0;for(let u=0;u<h.length;u++){const l=h[u],c=e*(((d=l.children)==null?void 0:d.length)??0);if(a+c<i){a+=c;continue}if(a>s)break;const m=this.createCell(`group-${l.date.format("YYYY-MM-DD")}`,a,0,c,n,o,l.label);if(this.groupHeader.add(m),E.isArray(l.children)&&l.children.length>0){let g=a;for(let x=0;x<l.children.length;){const T=l.children[x];let v=1;for(;l.children[x+v]&&T.label===l.children[x+v].label;)v++;if(x+=v,x>=l.children.length&&h[u+1]&&h[u+1].children){let L=0;for(;h[u+1].children[L]&&T.label===h[u+1].children[L].label;)h[u+1].children[L].hide=!0,L++;L>0&&(v+=L)}const y=e*v;if(g+y<i){g+=y;continue}if(g>s)break;const M=this.createCell(`cell-${T.date.format("YYYY-MM-DD")}`,g,n,y,n,T.hide?"transparent":o,T.hide?"":T.label);this.cellHeader.add(M),T.hide&&M.visible(!1),g+=y}}a+=c}this.layer.batchDraw()}createCell(t,e,i,s,n,o,h){const a=new S.Group;a.x(e),a.y(i);const d=new S.Rect({id:t,x:0,y:0,width:s,height:n,fill:this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,name:"header-cell-bg"});a.add(d);let u=this.context.getOptions().header.fontSize;t.startsWith("cell-")&&(this.cellCache.set(t,d),u-=2);const l=new S.Line({points:[s,0,s,n],stroke:o,strokeWidth:1,name:"header-cell-right-border"});a.add(l);const c=new S.Text({x:0,y:0,width:s,height:n,text:h,fontSize:u,fontFamily:this.context.getOptions().header.fontFamily,fontStyle:`${this.context.getOptions().header.fontWeight}`,fill:this.context.getOptions().header.color,align:"center",verticalAlign:"middle",wrap:"none",ellipsis:!0,name:"header-cell-text"});return a.add(c),a}clearHeader(){this.groupHeader.destroyChildren(),this.cellHeader.destroyChildren(),this.cellCache.clear()}destroy(){this.layer.destroy(),this.cellCache.clear()}highlightDate(t){const e=this.context.store.getDataManager().getTaskById(t);e&&e.startTime&&e.endTime&&this.handleHighlight("in",e)}unhighlightDate(t){const e=this.context.store.getDataManager().getTaskById(t);e&&e.startTime&&e.endTime&&this.handleHighlight("out",e)}handleHighlight(t,e){var o,h;if(!this.context.getOptions().highlight||this.context.getOptions().unit!=="day")return;const i=this.cellCache.get(`cell-${(o=e==null?void 0:e.startTime)==null?void 0:o.format("YYYY-MM-DD")}`),s=this.cellCache.get(`cell-${(h=e==null?void 0:e.endTime)==null?void 0:h.format("YYYY-MM-DD")}`),n=this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor;n&&(this.cellCache.forEach(a=>{new S.Tween({node:a,fill:n,duration:.02}).play()}),t==="in"&&(i&&new S.Tween({node:i,fill:$(n).brighten(30).toHex(),duration:.02}).play(),s&&new S.Tween({node:s,fill:$(n).brighten(30).toHex(),duration:0}).play()))}}class de{constructor(t,e){r(this,"verticalLines");r(this,"horizontalLines");r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);this.context=t,this.layer=e,this.verticalLines=new S.Group({name:"vertical-grid-lines"}),this.horizontalLines=new S.Group({name:"horizontal-grid-lines"}),this.layer.add(this.verticalLines),this.layer.add(this.horizontalLines)}resize(t,e){this.width=t,this.height=e,this.clearGrid(),this.calculateGrid()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.verticalLines.x(t),this.horizontalLines.y(e),this.calculateGrid()}render(){this.layer.batchDraw()}destroy(){this.layer.destroy()}calculateGrid(){this.clearGrid();const t=this.context.getOptions().header.height,e=this.width,i=this.context.store.getTimeAxis().getCellWidth(),s=this.context.getOptions().row.height,n=this.context.store.getDataManager().getVisibleSize(),o=n*s,h=Math.max(0,Math.floor(-this.offsetX/i)-2),a=Math.min(this.context.store.getTimeAxis().getCellCount(),Math.ceil((-this.offsetX+this.width)/i)+2),d=Math.max(0,Math.floor((-this.offsetY+t)/s)-2),u=Math.min(n,Math.ceil((-this.offsetY+this.height)/s)+2);if(this.context.getOptions().border.show&&["day","hour"].includes(this.context.getOptions().unit))for(let l=h;l<=a;l++){const c=l*i,p=new S.Line({points:[c,t,c,o+t],stroke:this.context.getOptions().border.color,strokeWidth:.5,name:"vertical-grid-line"});this.verticalLines.add(p)}for(let l=d;l<=u;l++){const c=l*s+t,p=new S.Line({points:[0,c,Math.max(this.width,e),c],stroke:this.context.getOptions().border.color,strokeWidth:.5,name:"horizontal-grid-line"});this.horizontalLines.add(p)}}clearGrid(){this.verticalLines.destroyChildren(),this.horizontalLines.destroyChildren()}}class ue{constructor(t,e,i,s,n){r(this,"offsetX",0);r(this,"offsetY",0);r(this,"sliderGroup");r(this,"slider");r(this,"sliderBg");r(this,"leftHandler",null);r(this,"rightHandler",null);r(this,"progressGroup",null);r(this,"handlerWidth",10);r(this,"autoMoveTimer",null);r(this,"autoScrollTimer",null);r(this,"autoExpandTimer",null);r(this,"EDGE_THRESHOLD",20);r(this,"SCROLL_STEP",5);r(this,"MOVE_INTERVAL",1e3/60);r(this,"AUTO_EXPAND_INTERVAL",500);r(this,"isDragging",!1);r(this,"draggingDirection","none");r(this,"oldTasks",[]);this.context=t,this.x=e,this.y=i,this.task=s,this.rowWidth=n,this.sliderGroup=new S.Group({x:e,y:i,id:`chart-slider-bar-${s.id}`}),this.render(),this.bindEvents()}update(t,e){this.x=t,this.y=e,this.sliderGroup.position({x:t,y:e}),this.render()}setOffset(t,e){this.offsetX=t,this.offsetY=e}updateSize(){const t=this.context.getOptions().row.height,e=st(this.context.getOptions().bar.height,t),i=(t-e)/2,s=this.context.store.getTimeAxis().getTimeLeft(this.task.startTime),o=this.context.store.getTimeAxis().getTimeLeft(this.task.endTime)-s;this.slider.position({x:s,y:i}),this.slider.size({width:o,height:e}),this.sliderBg.size({width:o,height:e}),this.leftHandler,this.rightHandler&&(this.rightHandler.x(o-this.handlerWidth),this.rightHandler.size({width:this.handlerWidth,height:e})),this.renderProgress(o,e),this.renderText(o,e)}render(){var x,T,v,y,O;if(!this.task.startTime||!this.task.endTime)return;const t=this.context.getOptions().row.height,e=st(this.context.getOptions().bar.height,t),i=(t-e)/2,s=this.context.store.getTimeAxis().getTimeLeft(this.task.startTime),o=this.context.store.getTimeAxis().getTimeLeft(this.task.endTime)-s,h=this.context.getOptions().bar.backgroundColor||this.context.getOptions().primaryColor,a=Q(this.context.getOptions().bar.radius);this.slider||(this.slider=new S.Group({dragBoundFunc:M=>{let L=0,k=Math.abs(this.rowWidth-this.slider.width());if(this.context.getOptions().bar.move.link.parent==="strict"&&this.task.parent){if(this.task.parent.startTime){const _=this.task.parent.startTime;L=this.context.store.getTimeAxis().getTimeLeft(_)}if(this.task.parent.endTime){const _=this.task.parent.endTime,H=this.context.store.getTimeAxis().getTimeLeft(_);k=Math.abs(H-this.slider.width())}}return{x:A(M.x,L,k),y:this.y+i+this.offsetY}}})),this.slider.position({x:s,y:i}),this.slider.size({width:o,height:e});const d=this.context.getOptions().bar.move.enabled;let u=!1;E.isBoolean(d)?u=d:E.isFunction(d)&&(u=d(this.task.getEmitData())),this.slider.draggable(u),this.sliderBg||(this.sliderBg=new S.Rect({x:0,y:0}),this.slider.add(this.sliderBg)),this.sliderBg.setAttrs({width:o,height:e,fill:h,cornerRadius:a,shadowColor:this.context.getOptions().bar.shadowColor,shadowBlur:this.context.getOptions().bar.shadowBlur,shadowOffsetX:this.context.getOptions().bar.shadowOffsetX,shadowOffsetY:this.context.getOptions().bar.shadowOffsetY}),this.renderProgress(o,e);const l=$(h).brighten(30*((x=this.context.getOptions().bar.progress)!=null&&x.show?-1:1)).toHex(),c=(T=this.context.getOptions().bar.move.single)==null?void 0:T.left;let p=!1;E.isBoolean(c)?p=c:E.isFunction(c)&&(p=c(this.task.getEmitData())),p?(this.leftHandler||(this.leftHandler=new S.Rect({x:0,y:0,opacity:0}),this.slider.add(this.leftHandler),this.leftHandler.on("mousedown",M=>{this.resizeMove(M,"left")})),this.leftHandler.setAttrs({width:this.handlerWidth,height:e,fill:l,cornerRadius:[a[0],0,0,a[3]]})):this.leftHandler&&(this.leftHandler.remove(),this.leftHandler=null);const m=(v=this.context.getOptions().bar.move.single)==null?void 0:v.right;let g=!1;E.isBoolean(m)?g=m:E.isFunction(m)&&(g=m(this.task.getEmitData())),g?(this.rightHandler||(this.rightHandler=new S.Rect({y:0,opacity:0}),this.slider.add(this.rightHandler),this.rightHandler.on("mousedown",M=>{this.resizeMove(M,"right")})),this.rightHandler.setAttrs({x:o-this.handlerWidth,width:this.handlerWidth,height:e,fill:l,cornerRadius:[0,a[1],a[2],0]})):this.rightHandler&&(this.rightHandler.remove(),this.rightHandler=null),this.renderText(o,e),this.sliderGroup.add(this.slider),(y=this.leftHandler)==null||y.moveToTop(),(O=this.rightHandler)==null||O.moveToTop()}renderText(t,e){const i=`chart-slider-text-${this.task.id}`,s=()=>{this.slider.find(`#${i}`)&&this.slider.find(`#${i}`).forEach(a=>a.remove())};if(!this.context.getOptions().bar.field&&!this.context.getOptions().bar.label){s();return}const n=this.context.getOptions().bar.label;let o="";if(n?E.isString(n)?o=n:E.isFunction(n)&&(o=n(this.task.getEmitData())):this.context.getOptions().bar.field&&(o=this.task.getField(this.context.getOptions().bar.field)),!o){C.info("Bar content is empty");return}s();const h=t-(this.leftHandler?this.handlerWidth:0)-(this.rightHandler?this.handlerWidth:0);if(h>20){const a=new S.Text({id:i,x:this.leftHandler?10:0,y:0,width:h,height:e,padding:10,text:o,fill:this.context.getOptions().bar.color||"#000",fontSize:this.context.getOptions().bar.fontSize||12,fontFamily:this.context.getOptions().bar.fontFamily||"Arial",align:this.context.getOptions().bar.align,verticalAlign:this.context.getOptions().bar.verticalAlign||"middle",ellipsis:!0});this.slider.add(a)}}renderProgress(t,e){var i,s,n,o,h,a,d,u,l,c,p,m,g,x;if(!((i=this.context.getOptions().bar.progress)!=null&&i.show)){this.progressGroup&&(this.progressGroup.destroy(),this.progressGroup=null);return}if(this.task.progress){const T=Et(this.task.progress,((s=this.context.getOptions().bar.progress)==null?void 0:s.targetVal)??100);if(T===0)return;const v=((n=this.context.getOptions().bar.progress)==null?void 0:n.backgroundColor)||$(this.context.getOptions().bar.backgroundColor||this.context.getOptions().primaryColor).brighten(((o=this.context.getOptions().bar.progress)==null?void 0:o.amount)||30).toHex(),y=Q(this.context.getOptions().bar.radius),O=Q((h=this.context.getOptions().bar.progress)==null?void 0:h.radius);O[0]=y[0],O[3]=y[3],T===1&&(O[1]=y[1],O[2]=y[2]);const M=t*T;this.progressGroup?(this.progressGroup.width(M),this.progressGroup.destroyChildren()):(this.progressGroup=new S.Group({x:0,y:0,width:M,height:e,listening:!1}),this.slider.add(this.progressGroup));const L=new S.Rect({x:0,y:0,width:M,height:e,fill:v,cornerRadius:O,opacity:(a=this.context.getOptions().bar.progress)==null?void 0:a.opacity});this.progressGroup.add(L);const k=`${Mt(T*100,(d=this.context.getOptions().bar.progress)==null?void 0:d.decimal)}%`,w=new S.Text().measureSize(k).width,_=new S.Text({x:0,y:((u=this.context.getOptions().bar.progress)==null?void 0:u.textAlign)==="top"?-e:0,width:((l=this.context.getOptions().bar.progress)==null?void 0:l.textAlign)==="right"?M+w:Math.max(M,w),height:e,fill:((c=this.context.getOptions().bar.progress)==null?void 0:c.color)||$("#000000").mix(v,50).alpha(.7).toHex(),text:k,fontSize:((p=this.context.getOptions().bar.progress)==null?void 0:p.fontSize)||10,fontStyle:((m=this.context.getOptions().bar.progress)==null?void 0:m.fontStyle)||"italic",fontFamily:"Arial",verticalAlign:((g=this.context.getOptions().bar.progress)==null?void 0:g.textAlign)==="top"?"bottom":"middle",align:"right"});(x=this.progressGroup)==null||x.add(_)}}bindEvents(){this.slider&&(this.slider.on("dragstart",t=>this.handleDragStart(t)),this.slider.on("dragend",()=>this.handleDragEnd()),this.slider.on("dragmove",t=>this.handleDragMove(t)),this.slider.on("pointerover",()=>this.handleMouseEnter()),this.slider.on("pointerout",()=>this.handleMouseLeave()),this.slider.on("click",t=>{t.evt.button===0&&(t.cancelBubble=!0,this.isDragging=!1,this.context.event.emit(b.SLIDER_CLICK,t.evt,this.task))}),this.slider.on("contextmenu",t=>{t.cancelBubble=!0,t.evt.stopPropagation(),t.evt.preventDefault(),this.context.event.emit(b.SLIDER_CONTEXTMENU,t.evt,this.task)}),this.slider.on("dblclick",t=>{t.evt.button===0&&(t.cancelBubble=!0,this.context.event.emit(b.SLIDER_DBL_CLICK,t.evt,this.task))}))}emitUpdate(t){let e=this.task.startTime.clone(),i=this.task.endTime.clone();t!=="right"&&(e=this.context.store.getTimeAxis().getTimeByLeft(this.slider.x())),t!=="left"&&(i=this.context.store.getTimeAxis().getTimeByLeft(this.slider.x()+this.slider.width())),(!(e!=null&&e.isSame(this.task.startTime))||!(i!=null&&i.isSame(this.task.endTime)))&&this.context.store.getDataManager().updateTaskTime(this.task,e,i,t,this.oldTasks)}handleDragStart(t){const e=t.target.getStage();e&&(this.isDragging=!0,this.oldTasks=[],this.handleMove(t,e))}handleDragMove(t){if(!this.isDragging)return;if(t.evt.movementX>0?this.draggingDirection="right":t.evt.movementX<0&&(this.draggingDirection="left"),!!this.context.getOptions().bar.move.byUnit){const i=t.target.x(),s=this.context.store.getTimeAxis().getCellWidth(),n=nt(i,s);t.target.x(n)}}handleDragEnd(){this.stopAutoMove(),this.stopAutoScroll(),this.stopAutoExpand(),this.isDragging=!1,this.draggingDirection="none",this.oldTasks.length>0&&(this.context.event.emit(b.TASK_DRAG_END,this.task,this.oldTasks),this.oldTasks=[])}handleMove(t,e){const i=e.width(),s=!!this.context.getOptions().bar.move.lock,n=!!this.context.getOptions().bar.move.byUnit,o=this.context.store.getTimeAxis().getCellWidth();this.autoMoveTimer=window.setInterval(()=>{const h=t.target.width(),a=t.target.x()-this.offsetX,d=a+h,u=-this.offsetX,l=u+i,c=a<=u-this.offsetX+this.EDGE_THRESHOLD,p=d>=l-this.offsetX-this.EDGE_THRESHOLD;if(c)if(u<=0)t.target.x(0),this.stopAutoScroll(),s||(this.draggingDirection==="left"?this.startAutoExpand("left"):this.stopAutoExpand());else if(this.draggingDirection==="left"){const m=n?-o:-this.SCROLL_STEP;this.startAutoScroll(m,n,()=>{t.target.x(t.target.x()+m)})}else this.stopAutoScroll();else if(p)if(l>=this.context.store.getTimeAxis().getTotalWidth())t.target.x(this.context.store.getTimeAxis().getTotalWidth()-h),this.stopAutoScroll(),s||(this.draggingDirection==="right"?this.startAutoExpand("right"):this.stopAutoExpand());else if(this.draggingDirection==="right"){const m=n?o:this.SCROLL_STEP;this.startAutoScroll(m,n,()=>{t.target.x(t.target.x()+m)})}else this.stopAutoScroll();else this.stopAutoExpand(),this.stopAutoScroll();this.emitUpdate("both")},this.MOVE_INTERVAL)}resizeMove(t,e){var x;t.cancelBubble=!0;const i=t.target.getStage();if(!i)return;let s=((x=i.getPointerPosition())==null?void 0:x.x)||0;const n=!!this.context.getOptions().bar.move.byUnit,o=this.context.store.getTimeAxis().getCellWidth(),h=!!this.context.getOptions().bar.move.lock,a=i.width();let d=0,u=0;this.autoMoveTimer=window.setInterval(()=>{const T=this.slider.width(),v=this.slider.x(),y=v+T,O=-this.offsetX,M=O+a,L=v<=O+this.EDGE_THRESHOLD,k=y>=M-this.EDGE_THRESHOLD;if(L&&e==="left"){if(O<=0)this.slider.x(0),this.stopAutoScroll(),h||(this.draggingDirection==="left"?this.startAutoExpand("left"):this.stopAutoExpand());else if(this.draggingDirection==="left"){const w=n?-o:-this.SCROLL_STEP;this.startAutoScroll(w,n,()=>{d+=w,this.slider.x(this.slider.x()+w)})}else this.stopAutoScroll();this.emitUpdate("left")}else if(k&&e==="right"){if(M>=this.context.store.getTimeAxis().getTotalWidth())this.slider.width(this.context.store.getTimeAxis().getTotalWidth()-this.slider.x()),this.stopAutoScroll(),h||(this.draggingDirection==="right"?this.startAutoExpand("right"):this.stopAutoExpand());else if(this.draggingDirection==="right"){const w=n?o:this.SCROLL_STEP;this.startAutoScroll(w,n,()=>{u+=w,this.slider.x(this.slider.x()+w)})}else this.stopAutoScroll();this.emitUpdate("right")}else if(e==="right"&&v<=O&&y<=O+this.EDGE_THRESHOLD+o){const w=n?-o:-this.SCROLL_STEP;this.startAutoScroll(w,n,()=>{u+=w,this.slider.width(Math.max(this.slider.width(),o)),this.slider.width()>o&&this.slider.x(this.slider.x()+w),this.emitUpdate("right")})}else if(e==="left"&&y>=M&&v>=M-this.EDGE_THRESHOLD-o){const w=n?o:this.SCROLL_STEP;this.startAutoScroll(w,n,()=>{d+=w,this.slider.width(Math.max(this.slider.width(),o)),this.slider.width()>o&&this.slider.x(this.slider.x()+w),this.emitUpdate("left")})}else this.stopAutoExpand(),this.stopAutoScroll()},this.MOVE_INTERVAL);let l;const c=this.slider.x(),p=this.slider.width(),m=T=>{var O;T.movementX>0?this.draggingDirection="right":T.movementX<0&&(this.draggingDirection="left");const v=Math.max(((O=i.getPointerPosition())==null?void 0:O.x)||0,0);let y=v-s;n&&(y=nt(y,o)),(l===void 0||l!==y)&&(e==="left"?p-y-d>=o&&v<a-this.EDGE_THRESHOLD&&(this.slider.width(p-y-d),this.slider.x(c+y+d),this.emitUpdate("left")):p+y+u>=o&&v>this.EDGE_THRESHOLD&&(this.slider.width(p+y+u),this.emitUpdate("right")),l=y)},g=()=>{this.handleDragEnd(),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",g)}startAutoExpand(t){if(this.autoExpandTimer)return;const e=this.context.store.getTimeAxis();this.autoExpandTimer=window.setInterval(()=>{e.expand(t,1),this.context.event.emit(b.CHART_OFFSET_CHANGE),t==="left"&&this.slider.x(0)},this.AUTO_EXPAND_INTERVAL)}startAutoScroll(t,e,i){if(this.autoScrollTimer)return;const s=this.context.getScrollbar();s&&(this.autoScrollTimer=window.setInterval(()=>{const n=s.getScrollPosition();s.scrollTo({x:n.x+t,y:n.y},"drag"),i==null||i()},e?300:this.MOVE_INTERVAL))}stopAutoMove(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=null)}stopAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}stopAutoExpand(){this.autoExpandTimer&&(clearInterval(this.autoExpandTimer),this.autoExpandTimer=null)}handleMouseEnter(){this.handleResizeHighlight(1)}handleMouseLeave(){this.handleResizeHighlight(0)}handleResizeHighlight(t){this.leftHandler&&new S.Tween({node:this.leftHandler,opacity:t,duration:.2}).play(),this.rightHandler&&new S.Tween({node:this.rightHandler,opacity:t,duration:.2}).play()}}class ge{constructor(t,e,i,s,n,o,h){r(this,"row");r(this,"slider");r(this,"cacheKey","");this.context=t,this.task=e,this.width=o,this.height=h,this.row=new S.Group;const a=new S.Rect({x:s,y:n,width:o,height:h,id:i,listening:!1});this.row.add(a),this.slider=new ue(this.context,0,n,this.task,this.width),this.row.add(this.slider.sliderGroup)}update(t,e){this.slider.update(t,e)}setOffset(t,e){this.slider.setOffset(t,e)}destroy(){this.row.destroy()}}class fe{constructor(t,e,i,s){r(this,"rowsGroup");r(this,"rowsCache",new Map);r(this,"rowBgGroup");r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);r(this,"highlightedRowId",null);r(this,"highlightRect",null);r(this,"selectedRowId",null);r(this,"selectedRect",null);this.context=t,this.stage=e,this.layer=i,this.bgLayer=s,this.rowsGroup=new S.Group({name:"chart-body-rows"}),this.layer.add(this.rowsGroup),this.rowBgGroup=new S.Group({name:"chart-body-row-bgs"}),this.bgLayer.add(this.rowBgGroup),this.registerEvents(),this.bindEvents()}resize(t,e){this.width=t,this.height=e}setOffset(t,e){const i=e-this.offsetY;this.offsetX=t,this.offsetY=e,this.rowsGroup.x(t),this.rowsGroup.y(e),this.updateHighlightPosition(i),this.updateSelectedPosition(i)}render(t){const e=this.context.getOptions().row.height,i=U();this.rowBgGroup.destroyChildren(),t.forEach((s,n)=>{const o=`chart-row-${s.id}`;let h=this.rowsCache.get(o);const d=s.flatIndex*e+this.context.getOptions().header.height;h?(h.update(0,d),h.setOffset(this.offsetX,this.offsetY)):(h=new ge(this.context,s,o,0,d,this.width,e),h.setOffset(this.offsetX,this.offsetY),this.rowsGroup.add(h.row),this.rowsCache.set(o,h)),h.cacheKey=i,this.context.store.getDataManager().isTaskSelected(s.id)&&this.selectRow(s.id);const u=new S.Rect({x:0,y:d+this.offsetY,width:this.width,height:e,fill:this.context.store.getOptionManager().getRowBackgroundColor(s),id:`chart-row-bg-${s.id}`,listening:!1});this.rowBgGroup.add(u),this.rowBgGroup.moveToBottom()}),this.rowsCache.forEach((s,n)=>{s.cacheKey!==i&&(s.destroy(),this.rowsCache.delete(n))}),this.layer.batchDraw()}updateTask(t){const e=this.rowsCache.get(`chart-row-${t.id}`);e&&e.update(0,t.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height)}bindEvents(){this.stage.on("mousemove",this.handleMouseMove.bind(this)),this.stage.on("mouseleave",this.handleMouseLeave.bind(this)),this.stage.on("click",this.handleClick.bind(this)),this.stage.on("dblclick",this.handleDblClick.bind(this)),this.stage.on("contextmenu",this.handleContextMenu.bind(this))}registerEvents(){this.context.event.on(b.ROW_HIGHLIGHT,t=>{this.highlightRow(t)}),this.context.event.on(b.ROW_UNHIGHLIGHT,t=>{this.unhighlightRow(t)}),this.context.event.on(b.TASK_SELECTED,t=>{this.selectRow(t.id)}),this.context.event.on(b.TASK_UNSELECTED,t=>{this.unselectRow(t)})}handleMouseMove(t){const e=this.stage.getPointerPosition();if(!e)return;const i=this.getTaskByPosition(e);this.highlightedRowId&&i&&i.id!==this.highlightedRowId&&this.context.event.emit(b.ROW_UNHIGHLIGHT,this.highlightedRowId),i&&this.context.event.emit(b.ROW_HIGHLIGHT,i.id)}handleMouseLeave(t){this.unhighlightRow()}handleClick(t){if(t.evt.button!==0)return;const e=this.stage.getPointerPosition();if(!e)return;const i=this.getTaskByPosition(e);if(i){if(this.context.store.getDataManager().isTaskSelected(i.id))return;this.context.store.getDataManager().selectTask(i.id),this.context.event.emit(b.ROW_CLICK,t.evt,i)}}handleDblClick(t){if(t.evt.button!==0)return;const e=this.stage.getPointerPosition();if(!e)return;const i=this.getTaskByPosition(e);i&&this.context.event.emit(b.ROW_DBL_CLICK,t.evt,i)}handleContextMenu(t){if(t.evt.button!==2)return;t.evt.preventDefault(),t.cancelBubble=!0;const e=this.stage.getPointerPosition();if(!e)return;const i=this.getTaskByPosition(e);i&&this.context.event.emit(b.ROW_CONTEXTMENU,t.evt,i)}getTaskByPosition(t){const e=this.context.getOptions().header.height;if(t.y<=e)return null;const i=t.y-this.offsetY,s=Math.floor((i-e)/this.context.getOptions().row.height);return this.context.store.getDataManager().getVisibleTasks()[s]||null}highlightRow(t){if(this.highlightedRowId===t)return;this.highlightedRowId=t;const e=this.rowsCache.get(`chart-row-${t}`);if(!e)return;this.highlightRect&&this.highlightRect.destroy();const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.selectedRowId!==t&&(this.highlightRect=new S.Rect({x:0,y:s+this.offsetY,width:this.width,height:this.context.getOptions().row.height,fill:$(this.context.getOptions().row.hover.backgroundColor).alpha(this.context.getOptions().row.hover.opacity).toHex(),name:"highlight-rect"}),this.layer.add(this.highlightRect),this.highlightRect.moveToBottom(),this.layer.batchDraw())}unhighlightRow(t){this.highlightedRowId===t&&(this.highlightedRowId=null,this.highlightRect&&(this.highlightRect.destroy(),this.highlightRect=null,this.layer.batchDraw()))}updateHighlightPosition(t){if(!this.highlightRect||this.highlightedRowId===null)return;const e=this.rowsCache.get(`chart-row-${this.highlightedRowId}`);if(!e){this.clearHighlight();return}if(t)this.highlightRect.y(this.highlightRect.y()+t);else{const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.highlightRect.y(s+this.offsetY)}this.layer.batchDraw()}clearHighlight(){this.highlightRect&&(this.highlightRect.destroy(),this.highlightRect=null),this.highlightedRowId=null}selectRow(t){var n;this.selectedRowId=t;const e=this.rowsCache.get(`chart-row-${t}`);if(!e)return;this.selectedRect&&this.selectedRect.destroy(),this.selectedRowId===this.highlightedRowId&&((n=this.highlightRect)==null||n.fill("transparent"));const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.selectedRect=new S.Rect({x:0,y:s+this.offsetY,width:this.width,height:this.context.getOptions().row.height,fill:$(this.context.getOptions().row.select.backgroundColor).alpha(this.context.getOptions().row.select.opacity).toHex(),name:"selected-rect"}),this.layer.add(this.selectedRect),this.selectedRect.moveToBottom(),this.layer.batchDraw()}unselectRow(t){this.selectedRowId===t&&(this.selectedRowId=null,this.selectedRect&&(this.selectedRect.destroy(),this.selectedRect=null,this.layer.batchDraw()))}updateSelectedPosition(t){if(!this.selectedRect||this.selectedRowId===null)return;const e=this.rowsCache.get(`chart-row-${this.selectedRowId}`);if(!e)return;const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.selectedRect.y(s+this.offsetY),this.layer.batchDraw()}destroy(){this.rowsCache.clear(),this.rowsGroup.destroy(),this.rowBgGroup.destroy()}}class Tt{constructor(){}static async createPattern(t){if(!(t!=null&&t.pattern))return null;const e=t.patternOptions||{};switch(e.color=e.color||t.backgroundColor,t.pattern){case"stripe":return this.createStripePattern(e);case"dot":return this.createDotPattern(e);case"grid":return this.createGridPattern(e);case"custom":if(e.image){const i=new Image;return i.src=e.image,new Promise(s=>{i.onload=()=>s(i)})}return null;default:return null}}static createStripePattern(t){const{color:e=(t==null?void 0:t.color)||"#c9c9c9",width:i=(t==null?void 0:t.width)||1,angle:s=(t==null?void 0:t.angle)??30,spacing:n=(t==null?void 0:t.spacing)||10}=t||{},o=s%180,h=o*Math.PI/180;let a,d;o===0?(a=n,d=i+n):o===90?(a=i+n,d=n):(a=Math.abs(Math.ceil((i+n)/Math.sin(h))),d=Math.abs(Math.ceil((i+n)/Math.cos(h))));const u=new S.Stage({container:document.createElement("div"),width:a,height:d}),l=new S.Layer;u.add(l);const c=new S.Group;if(o===0||o===90){const m=new S.Line({points:[0,0,o===0?a:0,o===0?0:d],stroke:e,strokeWidth:i,perfectDrawEnabled:!0});c.add(m)}else for(let m=-a;m<a*2;m+=a){const g=m+i/2,x=0,T=m+i/2+(Math.cos(h)<0?-a:a),v=d,y=new S.Line({points:[Math.ceil(g),Math.ceil(x),Math.ceil(T),Math.ceil(v)],stroke:e,strokeWidth:i,perfectDrawEnabled:!0,lineCap:"square",lineJoin:"miter"});c.add(y)}l.add(c),l.draw();const p=new Image;return p.src=u.toDataURL(),u.destroy(),p}static createDotPattern(t){const{color:e=(t==null?void 0:t.color)||"#f9f9f9",width:i=(t==null?void 0:t.width)||2,spacing:s=(t==null?void 0:t.spacing)||4}=t||{},n=i*2+s*2,o=n,h=$(e),a=new S.Stage({container:document.createElement("div"),width:n,height:o}),d=new S.Layer;a.add(d),[{x:s/2+i/2,y:s/2+i/2},{x:n-s/2-i/2,y:s/2+i/2},{x:s/2+i/2,y:o-s/2-i/2},{x:n-s/2-i/2,y:o-s/2-i/2}].forEach(c=>{const p=new S.Circle({x:c.x,y:c.y,radius:i/2,fill:h.toString()});d.add(p)}),d.draw();const l=new Image;return l.src=a.toDataURL(),a.destroy(),l}static createGridPattern(t){const{color:e=(t==null?void 0:t.color)||"#f9f9f9",width:i=(t==null?void 0:t.width)||1,spacing:s=(t==null?void 0:t.spacing)||20}=t||{},n=i+s,o=n,h=n,a=new S.Stage({container:document.createElement("div"),width:o,height:h}),d=new S.Layer;a.add(d);const u=new S.Group;u.add(new S.Line({points:[0,0,o,h],stroke:e,strokeWidth:i,perfectDrawEnabled:!0})),u.add(new S.Line({points:[0,h,o,0],stroke:e,strokeWidth:i,perfectDrawEnabled:!0})),d.add(u),d.draw();const l=new Image;return l.src=a.toDataURL(),a.destroy(),l}}class me{constructor(t,e){r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);r(this,"weekendGroup");r(this,"patternImage",null);this.context=t,this.layer=e,this.weekendGroup=new S.Group,this.layer.add(this.weekendGroup)}isWeekend(t){return t.day()===6||t.day()===0}resize(t,e){this.width=t,this.height=e,this.calculateWeekend()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.weekendGroup.x(t),this.weekendGroup.y(e),this.calculateWeekend()}render(){this.layer.batchDraw()}destroy(){this.weekendGroup.destroy(),this.patternImage=null}clearWeekend(){this.weekendGroup.destroyChildren(),this.patternImage=null}async calculateWeekend(){if(this.clearWeekend(),!this.context.getOptions().weekend.show)return;const t=this.context.store.getTimeAxis().getStartTime(),e=this.context.store.getTimeAxis().getEndTime(),i=this.context.store.getTimeAxis().getCellUnit(),s=this.context.store.getTimeAxis().getCellWidth(),n=this.context.getOptions().header.height,o=this.context.getOptions().row.height,a=this.context.store.getDataManager().getVisibleSize()*o,d=Math.max(0,-this.offsetX),u=d+this.width;for(let l=t;l<=e;){let c=s;if(c=s*2*(i==="day"?1:24),this.isWeekend(l)){const p=this.context.store.getTimeAxis().getTimeLeft(l),m=n,g=a;if(p+c<d){l=l.add(2,"day");continue}if(p>u)break;!this.patternImage&&this.context.getOptions().weekend.pattern&&(this.patternImage=await Tt.createPattern(this.context.getOptions().weekend));const T=new S.Rect({name:"weekend-rect",x:p,y:m,width:c,height:g,...this.patternImage?{fillPatternImage:this.patternImage,fillPatternRepeat:"repeat",fillPatternOffset:{x:0,y:0},fillPatternScale:{x:1,y:1}}:{fill:this.context.getOptions().weekend.backgroundColor||"#c9c9c9"},opacity:this.context.getOptions().weekend.opacity});this.weekendGroup.add(T),l=l.add(2,"day")}else l=l.add(1,"day")}this.layer.batchDraw()}}class pe{constructor(t,e,i){r(this,"arrowAnimation");r(this,"todayLine");r(this,"triangle");r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);this.context=t,this.bgLayer=e,this.headerLayer=i}resize(t,e){this.width=t,this.height=e,this.render()}setOffset(t,e){t!==this.offsetX&&(this.offsetX=t,this.render())}render(){const t=Object.assign({show:!0,type:"line",backgroundColor:$("lightblue").toHex(),opacity:1,width:1},this.context.getOptions().today||{});if(!t.show)return;let e=D();const i=this.context.store.getTimeAxis().getCellUnit();t.type==="block"&&(e=e.startOf(i));const s=this.context.store.getTimeAxis().getTimeLeft(e),n=this.context.store.getTimeAxis().getCellWidth(),o=this.context.getOptions().header.height,h=$(t.backgroundColor).alpha(t.opacity).toHex(),a=(t.type==="block"?s+n/2:s)+this.offsetX,d=[a,o,a,this.height],u=t.type==="line"?t.width:n;this.todayLine?(this.todayLine.points(d),this.todayLine.stroke(h),this.todayLine.strokeWidth(u)):(this.todayLine=new S.Line({points:d,stroke:h,strokeWidth:u}),this.bgLayer.add(this.todayLine)),t.type==="line"&&(this.triangle?(this.triangle.x(a),this.triangle.fill(h)):(this.triangle=new S.RegularPolygon({x:a,y:o-8,sides:3,radius:8,fill:h,rotation:180,name:"today-triangle"}),this.arrowAnimation=new S.Animation(l=>{var p;const c=Math.sin(l.time*4*Math.PI/2e3)+o-8;(p=this.triangle)==null||p.y(c)},this.headerLayer),this.headerLayer.add(this.triangle),this.triangle.moveToTop(),this.arrowAnimation.start())),this.bgLayer.batchDraw()}destroy(){var t,e,i;(t=this.todayLine)==null||t.destroy(),(e=this.triangle)==null||e.destroy(),(i=this.arrowAnimation)==null||i.stop(),this.arrowAnimation=void 0}}class xe{constructor(t,e){r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);r(this,"holidayGroup");r(this,"patternImage",null);this.context=t,this.layer=e,this.holidayGroup=new S.Group,this.layer.add(this.holidayGroup)}resize(t,e){this.width=t,this.height=e,this.calculateHoliday()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.holidayGroup.x(t),this.holidayGroup.y(e),this.calculateHoliday()}render(){this.layer.batchDraw()}destroy(){this.holidayGroup.destroy(),this.patternImage=null}clearHoliday(){this.holidayGroup.destroyChildren(),this.patternImage=null}async calculateHoliday(){if(this.clearHoliday(),!this.context.getOptions().holiday.show)return;const t=this.context.getOptions().holiday.holidays;if(!t||t.length===0)return;const e=Math.max(0,-this.offsetX),i=e+this.width,s=this.context.store.getTimeAxis().getStartTime(),n=this.context.store.getTimeAxis().getEndTime();this.context.store.getTimeAxis().getCellUnit();const o=this.context.store.getTimeAxis().getCellWidth(),h=this.context.getOptions().header.height,a=this.context.getOptions().row.height,u=this.context.store.getDataManager().getVisibleSize()*a;for(let l=s;l<=n;l=l.add(1,"day")){const c=t.find(p=>{if(E.isArray(p.date)){if(p.date.some(m=>D(m).isSame(l,"day")))return p}else if(D(p.date).isSame(l,"day"))return p});if(c){const p=this.context.store.getTimeAxis().getTimeLeft(l),m=h,g=u;if(p+o<e)continue;if(p>i)break;!this.patternImage&&this.context.getOptions().holiday.pattern&&(this.patternImage=await Tt.createPattern(this.context.getOptions().holiday));const T=new S.Rect({name:"holiday-rect",x:p,y:m,width:o,height:g,...this.patternImage?{fillPatternImage:this.patternImage,fillPatternRepeat:"repeat",fillPatternOffset:{x:0,y:0},fillPatternScale:{x:1,y:1},opacity:this.context.getOptions().holiday.opacity}:{fill:c.backgroundColor||this.context.getOptions().holiday.backgroundColor||this.context.getOptions().primaryColor,opacity:c.opacity||this.context.getOptions().holiday.opacity}});this.holidayGroup.add(T)}}this.layer.batchDraw()}}class ye{constructor(t,e,i){r(this,"tasks",[]);r(this,"pointGroup");r(this,"linksGroup");r(this,"templateArrow");r(this,"isDragging",!1);r(this,"selectedMap",new Map);r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);this.context=t,this.stage=e,this.layer=i,this.linksGroup=new S.Group({name:"links-group"}),this.pointGroup=new S.Group({name:"point-group"}),this.templateArrow=new S.Arrow({points:[],stroke:this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:this.context.getOptions().links.width,pointerLength:this.context.getOptions().links.arrow.height,pointerWidth:this.context.getOptions().links.arrow.width,fill:this.context.getOptions().links.arrow.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:this.context.getOptions().links.dash,opacity:.4}),this.templateArrow.visible(!1),this.layer.add(this.linksGroup),this.layer.add(this.pointGroup),this.layer.add(this.templateArrow),this.registerEvents()}registerEvents(){this.context.event.on(b.ROW_HIGHLIGHT,t=>{this.highlightPoint(t)}),this.context.event.on(b.ROW_UNHIGHLIGHT,t=>{this.unhighlightPoint(t)})}resize(t,e){this.width=t,this.height=e,this.calculateLinks(),this.calculatePoints()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.linksGroup.x(t),this.linksGroup.y(e),this.pointGroup.x(t),this.pointGroup.y(e),this.templateArrow.x(t),this.templateArrow.y(e),this.calculateLinks(),this.calculatePoints()}update(){this.calculateLinks(),this.calculatePoints()}render(t){this.tasks=t,this.layer.batchDraw()}destroy(){this.linksGroup.destroy(),this.pointGroup.destroy(),this.templateArrow.destroy(),this.selectedMap.clear()}calculatePoints(){if(this.pointGroup.destroyChildren(),!this.context.getOptions().links.create.enabled)return;const t=this.context.getOptions().header.height,e=this.context.getOptions().row.height,i=e/2+t,s=this.context.getOptions().links.gap,n=this.context.getOptions().links.create.radius,o=this.context.getOptions().links.create.mode==="always"?.5:0,h=this.context.getOptions().links.create.color||this.context.getOptions().primaryColor,a=$(h).alpha(this.context.getOptions().links.create.opacity??1).toHex(),d=this.context.getOptions().links.create.width;this.tasks.forEach(u=>{if(this.context.store.getDataManager().isTaskVisible(u)&&u.startTime&&u.endTime){const l=this.context.store.getTimeAxis().getTimeLeft(u.startTime),c=this.context.store.getTimeAxis().getTimeLeft(u.endTime),p=i+e*u.flatIndex;let m=!0,g=!0,x=this.context.getOptions().links.create.from;if(E.isFunction(x)&&(x=x(u.getEmitData())),E.isBoolean(x)?m=g=x:E.isString(x)&&(m=x==="S",g=x==="F"),m){const T=new S.Circle({id:`point-${u.id}-left`,x:l-s,y:p,radius:n,opacity:o,stroke:a,strokeWidth:d});this.pointGroup.add(T),T.on("mousedown",v=>{this.isDragging=!0,this.createLink(v,"S",h,[l-s,p],u.id)}),T.on("mouseover",v=>{this.stage.container().style.cursor="pointer"}),T.on("mouseout",v=>{this.isDragging||(this.stage.container().style.cursor="default")})}if(g){const T=new S.Circle({id:`point-${u.id}-right`,x:c+s,y:p,radius:n,opacity:o,stroke:a,strokeWidth:d});this.pointGroup.add(T),T.on("mousedown",v=>{this.isDragging=!0,this.createLink(v,"F",h,[c+s,p],u.id)}),T.on("mouseover",v=>{this.stage.container().style.cursor="pointer"}),T.on("mouseout",v=>{this.isDragging||(this.stage.container().style.cursor="default")})}}})}calculateLinks(){if(this.linksGroup.destroyChildren(),!this.context.getOptions().links.show)return;this.context.getOptions().links.data.forEach(e=>{var n,o,h;const i=this.context.store.getDataManager().getTaskById(e.from),s=this.context.store.getDataManager().getTaskById(e.to);if(i||C.warn(`No corresponding FROM task [${e.from}] was found for the link. Info:`,e),s||C.warn(`No corresponding TO task [${e.to}] was found for the link. Info:`,e),i&&this.context.store.getDataManager().isTaskVisible(i)&&i.startTime&&i.endTime&&s&&this.context.store.getDataManager().isTaskVisible(s)&&s.startTime&&s.endTime){const a=this.context.store.getTimeAxis().getTimeLeft(i.startTime),d=this.context.store.getTimeAxis().getTimeLeft(i.endTime),u=this.context.store.getTimeAxis().getTimeLeft(s.startTime),l=this.context.store.getTimeAxis().getTimeLeft(s.endTime);let c=[];switch(e.type||"FS"){case"FF":c=this.createFF(e,i,s,a,d,u,l);break;case"SS":c=this.createSS(e,i,s,a,d,u,l);break;case"SF":c=this.createSF(e,i,s,a,d,u,l);break;case"FS":default:c=this.createFS(e,i,s,a,d,u,l)}if(c.length<=2)C.warn("The link position has some error.",e);else{const m=`link-group-${e[this.context.getOptions().links.key]}-${e.from}-${e.to}-${e.type||"FS"}`,g=e.radius??this.context.getOptions().links.radius,x=((n=e.arrow)==null?void 0:n.width)??this.context.getOptions().links.arrow.width,T=((o=e.arrow)==null?void 0:o.height)??this.context.getOptions().links.arrow.height,v=e.width??this.context.getOptions().links.width,y=new S.Group({id:m}),O=new S.Circle({radius:g,fill:e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,x:c[0],y:c[1]});y.add(O),O.on("mousedown",L=>{this.handleDrag(L,e,"S",[c[c.length-2],c[c.length-1]],m)});const M=new S.Arrow({points:c,stroke:e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:v,pointerLength:T,pointerWidth:x,fill:((h=e.arrow)==null?void 0:h.color)||this.context.getOptions().links.arrow.color||e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:e.data||this.context.getOptions().links.dash,hitStrokeWidth:10});y.add(M),M.on("mousedown",L=>{this.handleDrag(L,e,"F",[c[0],c[1]],m)}),this.linksGroup.add(y),y.on("mouseover",L=>{L.target.moveToTop(),this.stage.container().style.cursor="pointer",this.selectedMap.has(m)||this.handleHighlight(y,g,x,T,v,2)}),y.on("mouseout",L=>{this.selectedMap.has(m)||this.handleHighlight(y,g,x,T,v,0),!this.isDragging&&(this.stage.container().style.cursor="default")}),y.on("mousedown",L=>{this.isDragging=!0}),y.on("click",L=>{L.cancelBubble=!0,this.isDragging=!1,L.target.moveToTop(),this.selectedMap.has(m)?(this.selectedMap.delete(m),this.context.event.emit(b.SELECT_LINK,null,e,this.selectedMap.values().toArray())):(this.selectedMap.set(m,e),this.context.event.emit(b.SELECT_LINK,e,null,this.selectedMap.values().toArray()))}),this.selectedMap.has(m)&&this.handleHighlight(y,g,x,T,v,2,!0)}}})}createFS(t,e,i,s,n,o,h){const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=t.gap||this.context.getOptions().links.gap,c=[n+l,u+d*e.flatIndex];{const p=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(p))C.error("Link's distance must be a Numeric");else{const m=n+l+p,g=o-l-p,x=[Math.max(m,g),u+d*e.flatIndex];c.push(...x);const T=d*e.flatIndex+a+(e.flatIndex<=i.flatIndex?d:0);c.push(x[0],T),c.push(g,T),c.push(g,u+d*i.flatIndex)}}return c.push(o-l,u+d*i.flatIndex),c}createFF(t,e,i,s,n,o,h){const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=t.gap||this.context.getOptions().links.gap,c=[n+l,u+d*e.flatIndex];{const p=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(p))C.error("Link's distance must be a Numeric");else{const m=n+l+p,g=h+l+p,x=[m<=g?g:m,u+d*e.flatIndex];c.push(...x),c.push(Math.max(g,m),u+d*i.flatIndex)}}return c.push(h+l,u+d*i.flatIndex),c}createSS(t,e,i,s,n,o,h){const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=t.gap||this.context.getOptions().links.gap,c=[s-l,u+d*e.flatIndex];{const p=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(p))C.error("Link's distance must be a Numeric");else{const m=s-l-p,g=o-l-p;c.push(Math.min(g,m),u+d*e.flatIndex),c.push(Math.min(g,m),u+d*i.flatIndex)}}return c.push(o-l,u+d*i.flatIndex),c}createSF(t,e,i,s,n,o,h){const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=t.gap||this.context.getOptions().links.gap,c=[s-l,u+d*e.flatIndex];{const p=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(p))C.error("Link's distance must be a Numeric");else{const m=s-l-p,g=h+l+p,x=[Math.min(m,g),u+d*e.flatIndex];c.push(...x);const T=d*e.flatIndex+a+(e.flatIndex<=i.flatIndex?d:0);c.push(x[0],T),c.push(g,T),c.push(g,u+d*i.flatIndex)}}return c.push(h+l,u+d*i.flatIndex),c}handleDrag(t,e,i,s,n){var g,x,T;if(!this.isDragging)return;this.stage.container().style.cursor="pointer";const o=this.linksGroup.findOne(`#${n}`);this.templateArrow.setAttrs({stroke:e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:e.width??this.context.getOptions().links.width,pointerLength:((g=e.arrow)==null?void 0:g.height)??this.context.getOptions().links.arrow.height,pointerWidth:((x=e.arrow)==null?void 0:x.width)??this.context.getOptions().links.arrow.width,fill:((T=e.arrow)==null?void 0:T.color)||this.context.getOptions().links.arrow.color||e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:e.data||this.context.getOptions().links.dash}),this.templateArrow.visible(!1);let h=null;const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=e.gap||this.context.getOptions().links.gap;let c=null;const p=()=>{const v=this.stage.getPointerPosition();if(!v||(c=this.getTaskByPosition(v),!c))return;const{allowLeft:y,allowRight:O}=this.isAllowDrop(c);if(this.templateArrow.visible(!0),o==null||o.visible(!1),c!=null&&c.startTime&&(c!=null&&c.endTime)){const M=this.context.store.getTimeAxis().getTimeLeft(c.startTime),L=this.context.store.getTimeAxis().getTimeLeft(c.endTime),k=(L+M)/2+this.offsetX;let w=M-l;v.x<=k?h="S":(h="F",w=L+l),i==="S"?(this.templateArrow.points([w,u+d*c.flatIndex,...s]),O?this.stage.container().style.cursor="pointer":this.stage.container().style.cursor="not-allowed"):i==="F"&&(this.templateArrow.points([...s,w,u+d*c.flatIndex]),y?this.stage.container().style.cursor="pointer":this.stage.container().style.cursor="not-allowed")}},m=()=>{var O,M;let v;const y=E.cloneDeep(e);if(h&&c&&(i==="S"?(v=`${h}${(e.type||"FS")[1]}`,y.from=c.id):i==="F"&&(v=`${(e.type||"FS")[0]}${h}`,y.to=c.id)),v&&c&&!(y.from===y.to&&["FF","SS"].includes(v))){const{allowLeft:L,allowRight:k}=this.isAllowDrop(c);y.type=v,((O=y.type)==null?void 0:O.slice(1))==="S"&&L||((M=y.type)==null?void 0:M.slice(1))==="F"&&k?this.context.event.emit(b.UPDATE_LINK,y):(this.context.event.emit(b.ERROR,N.LINK_NOT_ALLOWED),this.calculateLinks())}else this.context.event.emit(b.ERROR,N.LINK_SAME),this.calculateLinks();this.templateArrow.visible(!1),this.stage.container().style.cursor="default",this.isDragging=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",m)}createLink(t,e,i,s,n){this.stage.container().style.cursor="pointer",this.templateArrow.setAttrs({points:[],stroke:i,strokeWidth:this.context.getOptions().links.width,pointerLength:this.context.getOptions().links.arrow.height,pointerWidth:this.context.getOptions().links.arrow.width,fill:i,dash:this.context.getOptions().links.dash}),this.templateArrow.visible(!1);let o=null;const h=this.context.getOptions().header.height,a=this.context.getOptions().row.height,d=a/2+h,u=this.context.getOptions().links.gap;let l=null;const c=()=>{const m=this.stage.getPointerPosition();if(!m||(l=this.getTaskByPosition(m),!l))return;const{allowLeft:g,allowRight:x}=this.isAllowDrop(l);if(this.templateArrow.visible(!0),l.startTime&&l.endTime){const T=this.context.store.getTimeAxis().getTimeLeft(l.startTime),v=this.context.store.getTimeAxis().getTimeLeft(l.endTime),y=(v+T)/2+this.offsetX;let O=T-u;m.x<=y?o="S":(o="F",O=v+u),this.templateArrow.points([...s,O,d+a*l.flatIndex]),o==="S"&&!g?this.stage.container().style.cursor="not-allowed":o==="F"&&!x?this.stage.container().style.cursor="not-allowed":this.stage.container().style.cursor="pointer"}},p=()=>{let m;if(o&&(m=`${e}${o}`),m&&l)if(this.context.getOptions().links.data.some(g=>g.from===n&&g.to===l.id&&g.type===m))this.context.event.emit(b.ERROR,N.LINK_EXIST);else if(n===l.id&&e===o)this.context.event.emit(b.ERROR,N.LINK_SAME);else{const{allowLeft:g,allowRight:x}=this.isAllowDrop(l);o==="S"&&g||o==="F"&&x?this.context.event.emit(b.CREATE_LINK,{from:n,to:l.id,type:m,color:i}):this.context.event.emit(b.ERROR,N.LINK_NOT_ALLOWED)}this.templateArrow.visible(!1),this.stage.container().style.cursor="default",this.isDragging=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",p)}getTaskByPosition(t){const e=this.context.getOptions().header.height;if(t.y<=e)return null;const i=t.y-this.offsetY,s=Math.floor((i-e)/this.context.getOptions().row.height);return this.context.store.getDataManager().getVisibleTasks()[s]||null}isAllowDrop(t){let e=!0,i=!0,s=this.context.getOptions().links.create.to;return E.isFunction(s)&&(s=s(t.getEmitData())),E.isBoolean(s)?e=i=s:E.isString(s)&&(e=s==="S",i=s==="F"),{allowLeft:e,allowRight:i}}handleHighlight(t,e,i,s,n,o,h=!1){const a=t.findOne("Circle"),d=t.findOne("Arrow");a&&new S.Tween({node:a,radius:e+o,duration:h?0:.1}).play(),d&&new S.Tween({node:d,pointerWidth:i+o,pointerLength:s+o,strokeWidth:n+o,duration:h?0:.1}).play()}highlightPoint(t){this.handlePointHighlight(t,1)}unhighlightPoint(t){const e=this.context.getOptions().links.create.mode==="always"?.5:0;this.handlePointHighlight(t,e)}handlePointHighlight(t,e){const i=this.pointGroup.findOne(`#point-${t}-left`),s=this.pointGroup.findOne(`#point-${t}-right`);i&&new S.Tween({node:i,opacity:e,duration:.1}).play(),s&&new S.Tween({node:s,opacity:e,duration:.1}).play()}}class we{constructor(t,e){r(this,"stage");r(this,"headerLayer");r(this,"bodyGroup");r(this,"gridGroup");r(this,"weekendGroup");r(this,"holidayGroup");r(this,"todayLayer");r(this,"linkGroup");r(this,"bgLayer");r(this,"bodyLayer");r(this,"width",0);r(this,"height",0);this.context=t,this.container=e,this.stage=new S.Stage({container:this.container,width:this.container.clientWidth,height:this.container.clientHeight}),this.bgLayer=new S.Layer,this.weekendGroup=new me(this.context,this.bgLayer),this.holidayGroup=new xe(this.context,this.bgLayer),this.gridGroup=new de(this.context,this.bgLayer),this.stage.add(this.bgLayer),this.headerLayer=new ce(this.context,this.stage),this.todayLayer=new pe(this.context,this.bgLayer,this.headerLayer.layer),this.bodyLayer=new S.Layer,this.linkGroup=new ye(this.context,this.stage,this.bodyLayer),this.bodyGroup=new fe(this.context,this.stage,this.bodyLayer,this.bgLayer),this.stage.add(this.bodyLayer)}resize(t,e){this.width=t,this.height=e,this.context.store.getTimeAxis().setAllWidth(t),this.stage.width(t),this.stage.height(e),this.headerLayer.resize(t),this.gridGroup.resize(t,e),this.linkGroup.resize(t,e),this.holidayGroup.resize(t,e),this.weekendGroup.resize(t,e),this.bodyGroup.resize(t,e),this.todayLayer.resize(t,e)}render(t,e,i){this.headerLayer.setOffset(-t,0),this.gridGroup.setOffset(-t,-e),this.linkGroup.setOffset(-t,-e),this.weekendGroup.setOffset(-t,-e),this.holidayGroup.setOffset(-t,-e),this.bodyGroup.setOffset(-t,-e),this.todayLayer.setOffset(-t,-e),this.gridGroup.render(),this.holidayGroup.render(),this.weekendGroup.render(),this.linkGroup.render(i),this.bodyGroup.render(i),this.headerLayer.render(),this.todayLayer.render()}refresh(t,e,i){this.render(t,e,i)}updateTask(t){this.bodyGroup.updateTask(t),this.linkGroup.update()}destroy(){this.headerLayer.destroy(),this.gridGroup.destroy(),this.bodyLayer.destroy(),this.todayLayer.destroy(),this.holidayGroup.destroy(),this.weekendGroup.destroy(),this.linkGroup.destroy(),this.bgLayer.destroy(),this.stage.destroy()}}class be{constructor(t,e){r(this,"line");r(this,"initialX",0);r(this,"initialWidth",0);this.root=t,this.container=e,this.line=document.createElement("div"),this.line.className="x-gantt-middle-resize-line",this.line.style.position="absolute",this.line.style.zIndex="99",this.line.style.width="5px",this.line.style.height="100%",this.line.style.borderLeft="2px solid",this.line.style.setProperty("border-left-color",this.root.store.getOptionManager().getOptions().border.color,"important"),this.line.style.cursor="col-resize",this.container.appendChild(this.line),this.addDragEvents()}setOffset(t){this.line.style.left=`${t-2}px`,this.initialX=t}addDragEvents(){let t=0,e=null;const i=this.root.store.getColumnManager(),s=i.getLeafColumns(),n=a=>{a.preventDefault(),a.stopPropagation(),t=a.clientX,e=this.container.getBoundingClientRect();const d=s[s.length-1].key;this.initialWidth=i.getColumnWidth(d);const u=parseInt(this.line.style.left)+2;this.root.event.emit(b.SHOW_GUIDELINE,u);const l=p=>o(p),c=p=>h(p,l,c);document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)},o=a=>{if(a.preventDefault(),!e)return;const d=a.clientX-t;s[s.length-1].key;const u=50-this.initialWidth,c=e.width-20-this.initialX,p=Math.max(u,Math.min(c,d)),m=this.initialX+p;this.root.event.emit(b.MOVE_GUIDELINE,m)},h=(a,d,u)=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",u),this.root.event.emit(b.HIDE_GUIDELINE);const l=a.clientX-t,c=s[s.length-1].key,p=Math.max(50,this.initialWidth+l);i.setColumnWidth(c,p),this.root.event.emit(b.UPDATE_TABLE_HEADER)};this.line.addEventListener("mousedown",n)}}class Te{constructor(t,e){r(this,"element");r(this,"container");r(this,"visible",!1);if(this.context=t,!e)throw new Error("Container is required for GuideLine instance");this.container=e,this.element=document.createElement("div"),this.initElement(),this.initEvents()}initElement(){this.element.className="x-gantt-guide-line",this.element.style.position="absolute",this.element.style.top="0",this.element.style.left="0",this.element.style.width="0",this.element.style.height="100%",this.element.style.setProperty("border-left",`1px dashed ${this.context.getOptions().border.color}`,"important"),this.element.style.zIndex="9999",this.element.style.pointerEvents="none",this.element.style.display="none",this.element.style.transform="translateX(-0.5px)",getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.appendChild(this.element)}initEvents(){this.context.event.on(b.SHOW_GUIDELINE,t=>{this.show(t)}),this.context.event.on(b.HIDE_GUIDELINE,()=>{this.hide()}),this.context.event.on(b.MOVE_GUIDELINE,t=>{this.setLeft(t)})}setContainer(t){this.element.parentElement&&this.element.parentElement.removeChild(this.element),this.container=t,getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.appendChild(this.element)}setLeft(t){const e=this.container.clientWidth,i=Math.max(0,Math.min(e-20,t));this.element.style.left=`${i}px`}show(t){t!==void 0&&this.setLeft(t),this.element.style.display="block",this.visible=!0}hide(){this.element.style.display="none",this.visible=!1}isVisible(){return this.visible}getLeft(){return this.element.offsetLeft}}class ve{constructor(t=16){r(this,"taskQueue",new Map);r(this,"taskHandlers",new Map);r(this,"isScheduled",!1);r(this,"delay");r(this,"debouncedFlush");this.delay=t,this.debouncedFlush=E.debounce(()=>{this.flushTaskQueue()},t)}registerHandler(t,e){this.taskHandlers.set(t,e),C.debug(`RenderScheduler: 注册任务处理器 ${t}`)}registerSimpleHandler(t,e,i=!1){this.registerHandler(t,{callback:e,immediate:i})}scheduleTask(t,e=[],i={}){const s=this.taskHandlers.get(t);if(!s){C.warn(`RenderScheduler: 未找到任务类型 ${t} 的处理器`);return}const n={type:t,refresh:i.refresh,callback:s.callback,args:e,immediate:i.immediate??s.immediate??!1};if(n.immediate){C.debug(`RenderScheduler: 立即执行任务 ${t}`),this.executeTask(n);return}this.taskQueue.set(t,n),C.debug(`RenderScheduler: 添加任务到队列 ${t}`),this.debouncedFlush()}immediateExecuteTask(t,e=[],i=!1){const s=this.taskHandlers.get(t);if(!s){C.warn(`RenderScheduler: 未找到任务类型 ${t} 的处理器`);return}C.debug(`RenderScheduler: 立即执行任务 ${t}`);const n={type:t,refresh:i,callback:s.callback,args:e,immediate:!0};this.executeTask(n)}immediateFlushAll(){C.debug("RenderScheduler: 立即执行所有队列任务"),this.cancelScheduled(),this.flushTaskQueue()}executeTask(t){try{t.callback(...t.args||[])}catch(e){C.error(`RenderScheduler: 执行任务 ${t.type} 时出错:`,e)}}flushTaskQueue(){if(this.taskQueue.size===0)return;C.debug(`RenderScheduler: 执行任务队列,任务数量: ${this.taskQueue.size}`);const t=Array.from(this.taskQueue.values()).sort((e,i)=>e.immediate!==i.immediate?e.immediate?-1:1:e.refresh!==i.refresh?e.refresh?-1:1:0);this.taskQueue.clear(),this.isScheduled=!1;for(const e of t)this.executeTask(e)}cancelScheduled(){this.debouncedFlush.cancel(),this.taskQueue.clear(),this.isScheduled=!1}unregisterHandler(t){this.taskHandlers.delete(t),this.taskQueue.delete(t),C.debug(`RenderScheduler: 移除任务处理器 ${t}`)}getQueueSize(){return this.taskQueue.size}getRegisteredHandlers(){return Array.from(this.taskHandlers.keys())}destroy(){this.cancelScheduled(),this.taskHandlers.clear(),C.debug("RenderScheduler: 已销毁")}}class Se{constructor(t,e){r(this,"scrollbar");r(this,"rootElement");r(this,"tableContainer");r(this,"chartContainer");r(this,"table");r(this,"chart");r(this,"middleLine");r(this,"renderScheduler");r(this,"_id",U());r(this,"width",0);r(this,"height",0);r(this,"updateSize",()=>{this.width=this.context.store.getOptionManager().getOptions().width||this.container.clientWidth,this.height=this.context.store.getOptionManager().getOptions().height||this.container.clientHeight,this.rootElement.style.width=this.width?`${this.width}px`:"100%",this.rootElement.style.height=this.height?`${this.height}px`:"100%";const t=this.context.store.getColumnManager().getTotalWidth();this.tableContainer.style.width=`${t}px`,this.tableContainer.style.height=this.height?`${this.height}px`:"100%";const e=this.width-t;this.chartContainer.style.width=`${e}px`,this.chartContainer.style.height=this.height?`${this.height}px`:"100%",this.chart.resize(e,this.height),this.middleLine.setOffset(t);const i=this.context.store.getTimeAxis().getTotalWidth();this.scrollbar.updateSize(e,this.height,i,this.context.store.getDataManager().getVisibleSize()*this.context.store.getOptionManager().getOptions().row.height+this.context.store.getOptionManager().getOptions().header.height,t)});r(this,"setStyleValue",()=>{const t=this.context.store.getOptionManager().getOptions();this.rootElement.style.setProperty("--x-gantt-primary-color",`${t.primaryColor}`),this.rootElement.style.setProperty("--x-gantt-border-color",`${t.border.color}`),this.rootElement.style.setProperty("--x-gantt-row-hover-color",`${$(t.row.hover.backgroundColor).alpha(t.row.hover.opacity)}`),this.rootElement.style.setProperty("--x-gantt-row-selected-color",`${$(t.row.select.backgroundColor).alpha(t.row.select.opacity)}`),this.rootElement.style.setProperty("--x-gantt-header-font-weight",`${t.header.fontWeight}`)});r(this,"handleUpdateTask",t=>{this.table.updateTask(t),this.chart.updateTask(t)});r(this,"handleColumnWidthChange",()=>{this.table.updateWidth(),this.updateSize()});this.context=t,this.container=e,this.rootElement=document.createElement("div"),this.rootElement.id=`x-gantt-${this._id}`,this.rootElement.className="x-gantt",this.rootElement.style.overflow="hidden",this.rootElement.style.display="flex",this.rootElement.style.position="relative",this.container.appendChild(this.rootElement),this.tableContainer=document.createElement("div"),this.tableContainer.className="x-gantt-table",this.rootElement.appendChild(this.tableContainer),new Te(this.context,this.container),this.middleLine=new be(this.context,this.rootElement),this.chartContainer=document.createElement("div"),this.chartContainer.className="x-gantt-chart",this.rootElement.appendChild(this.chartContainer),this.table=new le(this.context,this.tableContainer),this.chart=new we(this.context,this.chartContainer),this.scrollbar=new re(this.context,this.rootElement,this.context.store.getOptionManager().getOptions().scrollbar||{}),this.renderScheduler=new ve(16),this.setupTaskHandlers(),this.updateSize(),this.setupEventListeners()}getScrollbar(){return this.scrollbar}setupTaskHandlers(){this.renderScheduler.registerSimpleHandler("DATA_UPDATE",(t=!1)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("VIEW_UPDATE",(t=!0)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("MANUAL_RENDER",(t=!1)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("SCROLL",(t=!0)=>this.performRender(t),!0),this.renderScheduler.registerSimpleHandler("UPDATE_TASK",t=>this.handleUpdateTask(t)),this.renderScheduler.registerSimpleHandler("COLUMN_WIDTH_CHANGE",()=>this.handleColumnWidthChange()),this.renderScheduler.registerSimpleHandler("CHART_OFFSET_CHANGE",(t=!1)=>this.performRender(t))}setupEventListeners(){this.context.event.on(b.DATA_UPDATE,()=>{this.renderScheduler.scheduleTask("DATA_UPDATE",[!1])}),this.context.event.on(b.SCROLL,()=>{this.renderScheduler.scheduleTask("SCROLL",[!0],{immediate:!0})}),this.context.event.on(b.COLUMN_WIDTH_CHANGE,()=>{this.renderScheduler.scheduleTask("COLUMN_WIDTH_CHANGE")}),this.context.event.on(b.VIEW_UPDATE,()=>{this.renderScheduler.scheduleTask("VIEW_UPDATE",[!0])}),this.context.event.on(b.UPDATE_TASK,t=>{this.renderScheduler.scheduleTask("UPDATE_TASK",[t])}),this.context.event.on(b.CHART_OFFSET_CHANGE,()=>{this.renderScheduler.scheduleTask("CHART_OFFSET_CHANGE",[!1])})}performRender(t=!1){this.setStyleValue();const{x:e,y:i}=this.scrollbar.getScrollPosition(),s=this.context.store.getOptionManager().getOptions().row.height,n=this.context.store.getOptionManager().getOptions().header.height,o=Math.floor(i/s),h=Math.ceil((this.height-n)/s),a=2,d=Math.max(0,o),u=h+a,l=this.context.store.getDataManager().getVisibleTasks().slice(d,d+u);t?(this.table.refresh(i,l),this.chart.refresh(e,i,l)):(this.table.render(i,l),this.chart.render(e,i,l)),this.updateSize()}render(t=!1){this.renderScheduler.scheduleTask("MANUAL_RENDER",[t])}immediateRender(t=!1){this.renderScheduler.immediateExecuteTask("MANUAL_RENDER",[t],t)}destroy(){C.debug("Renderer destroy"),this.renderScheduler.destroy(),this.scrollbar.destroy(),this.context.event.offAll()}}class ke{constructor(t,e,i){r(this,"_id",U());r(this,"store");r(this,"event",new kt);r(this,"renderer");this.container=t,this.events=e,this.container.innerHTML="",this.store=new oe(this,i),this.renderer=new Se(this,this.container),this.render(),this.registerEvents(),C.debug("----Gantt initialized for element:",this._id,this.container)}getScrollbar(){var t;return(t=this.renderer)==null?void 0:t.getScrollbar()}getOptions(){return this.store.getOptionManager().getOptions()}setOptions(t,e){this.store.setOption(t,e)}render(){this.renderer.render()}updateOptions(t,e){this.setOptions(t,e),C.debug("GanttChart options updated"),this.render()}destroy(){C.debug("Gantt destroying..."),this.event.offAll(),this.renderer.destroy(),this.container.innerHTML=""}jumpTo(t){const e=D(t);if(!this.store.getTimeAxis().isInTimeAxis(e))return!1;const i=this.store.getTimeAxis().getTimeLeft(e)-100;return this.renderer.getScrollbar().scrollTo({x:Math.max(i,0)}),!0}_emit(t,...e){var i;this.events.has(t)&&((i=this.events.get(t))==null||i.forEach(s=>s(...e)))}registerEvents(){this.event.on(b.ERROR,t=>{this._emit("error",t)}),this.event.on(b.TASK_DRAG_END,(t,e)=>{this._emit("move",e.map(i=>{var s;return{row:(s=this.store.getDataManager().getTaskById(i.id))==null?void 0:s.data,old:i.data}}))}),this.event.on(b.CHECK_TASK,(t,e)=>{this._emit("select",t.map(i=>i.data),e,this.store.getDataManager().getCheckedList().map(i=>i.data))}),this.event.on(b.UPDATE_LINK,t=>{this._emit("update:link",t)}),this.event.on(b.CREATE_LINK,t=>{this._emit("create:link",t)}),this.event.on(b.SELECT_LINK,(t,e,i)=>{this._emit("select:link",t,e,i)}),this.event.on(b.ROW_CLICK,(t,e)=>{this._emit("click:row",t,e.data)}),this.event.on(b.ROW_DBL_CLICK,(t,e)=>{this._emit("dblclick:row",t,e.data)}),this.event.on(b.ROW_CONTEXTMENU,(t,e)=>{this._emit("contextmenu:row",t,e.data)}),this.event.on(b.SLIDER_CLICK,(t,e)=>{this._emit("click:slider",t,e.data)}),this.event.on(b.SLIDER_DBL_CLICK,(t,e)=>{this._emit("dblclick:slider",t,e.data)}),this.event.on(b.SLIDER_CONTEXTMENU,(t,e)=>{this._emit("contextmenu:slider",t,e.data)})}}class Le{constructor(t,e){r(this,"context");r(this,"events",new Map);e!=null&&e.logLevel&&C.setOptions({showTimestamp:e.logLevel==="debug",level:{debug:1,info:2,warn:3,error:4,none:5}[e.logLevel]||2});const i=typeof t=="string"?document.querySelector(t):t;if(!i)throw C.exception(`Container ${t} not found or invalid.`);i.innerHTML="",this.context=new ke(i,this.events,e)}updateOptions(t,e={merge:!0}){this.context.updateOptions(t,e)}render(){this.context.render(),C.info("Gantt rendered successfully.")}destroy(){C.info("Gantt destroying..."),this.events.clear(),this.context.destroy(),C.info("Gantt destroyed successfully.")}jumpTo(t){return this.context.jumpTo(t)}on(t,e){var i;this.events.has(t)||this.events.set(t,[]),(i=this.events.get(t))==null||i.push(e)}}vt();const Ee=it;R.dayjs=D,R.XGantt=Le,R.colorjs=$,R.generateId=U,R.version=Ee,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
|
|
18
|
+
`;break}this.iconElement.style.setProperty("background-color",e,"important"),this.iconElement.style.setProperty("border-color",i,"important")}bindEvents(){this.element.addEventListener("click",t=>{if(t.preventDefault(),t.stopPropagation(),this.task){const e=this.context.store.getDataManager().isTaskChecked(this.task);e?(this.context.store.getDataManager().updateCheckedList(!1,this.task),this.setState(0)):(this.context.store.getDataManager().updateCheckedList(!0,this.task),this.setState(1)),this.context.event.emit(y.CHECK_TASK,[this.task],!e)}else{const e=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(e?1:0),this.context.store.getDataManager().toggleAllChecked(!e),this.context.event.emit(y.CHECK_TASK,this.context.store.getDataManager().getVisibleTasks(),!e)}}),this.element.addEventListener("contextmenu",t=>{if(t.preventDefault(),t.stopPropagation(),this.task){const e=this.task.getAllChildren();if(e.length===0)return;this.context.store.getOptionManager().getOptions().selection.includeSelf&&e.unshift(this.task);const i=e.every(s=>this.context.store.getDataManager().isTaskChecked(s));i?(e.forEach(s=>{this.context.store.getDataManager().updateCheckedList(!1,s)}),this.setState(0)):(e.forEach(s=>{this.context.store.getDataManager().updateCheckedList(!0,s)}),this.setState(1)),this.context.event.emit(y.CHECK_TASK,e,!i)}else{const e=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(e?1:0),this.context.store.getDataManager().toggleAllChecked(!e),this.context.event.emit(y.CHECK_TASK,this.context.store.getDataManager().getVisibleTasks(),!e)}})}registerEvents(){this.context.event.on(y.CHECK_TASK,this.updateState.bind(this))}getElement(){return this.element}setState(t){this._state!==t&&(this._state=t,this.updateIcon())}updateState(){if(this.task){const t=this.context.store.getDataManager().isTaskChecked(this.task);this.setState(t?1:0)}else{const t=this.context.store.getDataManager().getCheckedList().length===this.context.store.getDataManager().getVisibleSize();this.setState(t?1:0)}}destroy(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}const rt="handler_column";class Dt{constructor(t){r(this,"sourceColumns",[]);r(this,"columns",[]);r(this,"leafColumns",[]);r(this,"temporaryLeafColumns",[]);r(this,"mergeInfo",new Map);this.context=t}init(t){t!=null&&t.length&&(this.sourceColumns=t),this.columns=[],this.leafColumns=[],this.processColumns(this.sourceColumns,this.columns)}processColumns(t,e=[],i,s=1){t.forEach((n,o)=>{var p;const h="children"in n&&Array.isArray(n.children)&&n.children.length>0,a=!h;let d="";h?d=`group-${o}`:d=`field-${n.field}`;const u=[...(i==null?void 0:i.path)||[],d];d="column-"+o+"-"+u.join("-");const l=n.label||(a?n.field:""),c=a?((p=this.temporaryLeafColumns.find(g=>g.key===d))==null?void 0:p.width)||n.width||100:"auto",m={label:l,level:s,maxLevel:s,column:n,children:[],path:u,key:d,isLeaf:a,width:c};if(e.push(m),a)this.leafColumns.push(m);else if(h){const g=n.children;this.processColumns(g,m.children,m,s+1),m.maxLevel=Math.max(m.maxLevel,m.children.reduce((x,T)=>Math.max(x,T.maxLevel),0))}}),this.temporaryLeafColumns=O.cloneDeep(this.leafColumns)}findColumnByKey(t){return this.columns.find(e=>e.key===t)}update(t){this.init(t),this.clearMergeInfo()}getColumns(){return this.columns}getColumn(t){return this.leafColumns.find(e=>e.key===t)}getLeafColumns(){return this.leafColumns}getTotalWidth(){return this.leafColumns.reduce((t,e)=>t+e.width,this.getHandlerColumn().width)}getColumnWidth(t){if(t===rt)return this.getHandlerColumn().width;const e=this.leafColumns.find(i=>i.key===t);return typeof(e==null?void 0:e.width)=="number"?e.width:0}setColumnWidth(t,e){const i=this.leafColumns.find(s=>s.key===t);i&&(i.width=e),this.context.event.emit(y.COLUMN_WIDTH_CHANGE,t,e)}isLastColumn(t){return this.leafColumns.findIndex(i=>i.key===t)===this.leafColumns.length-1}addMergeInfo(t,e,i){this.mergeInfo.has(t)||this.mergeInfo.set(t,new Map),this.mergeInfo.get(t).set(e,i)}getMergeInfo(t,e){var i;return(i=this.mergeInfo.get(t))==null?void 0:i.get(e)}clearMergeInfo(){this.mergeInfo.clear()}getHandlerColumn(){let t=0;return this.context.store.getOptionManager().getOptions().selection.enabled&&(t+=40),this.context.store.getDataManager().dataLevel>0&&this.context.store.getOptionManager().getOptions().expand.show&&(t+=40),{label:"",level:1,maxLevel:1,column:{field:"",resizable:!1,align:"left",headerAlign:"left",customStyle:{paddingLeft:this.context.store.getOptionManager().getOptions().expand.show?"8px":0},headerRender:()=>this.context.store.getOptionManager().getOptions().selection.enabled?new ot(this.context).getElement():null,ellipsis:!1},children:[],path:[],key:rt,isLeaf:!0,width:t}}isMultiHeader(){return this.columns.some(t=>t.maxLevel>1)}}var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function F(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var ht={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e,i,s=1e3,n=6e4,o=36e5,h=864e5,a=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d=31536e6,u=2628e6,l=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,c={years:d,months:u,days:h,hours:o,minutes:n,seconds:s,milliseconds:1,weeks:6048e5},m=function(M){return M instanceof E},p=function(M,S,w){return new E(M,w,S.$l)},g=function(M){return i.p(M)+"s"},x=function(M){return M<0},T=function(M){return x(M)?Math.ceil(M):Math.floor(M)},v=function(M){return Math.abs(M)},b=function(M,S){return M?x(M)?{negative:!0,format:""+v(M)+S}:{negative:!1,format:""+M+S}:{negative:!1,format:""}},E=function(){function M(w,_,H){var I=this;if(this.$d={},this.$l=H,w===void 0&&(this.$ms=0,this.parseFromMilliseconds()),_)return p(w*c[g(_)],this);if(typeof w=="number")return this.$ms=w,this.parseFromMilliseconds(),this;if(typeof w=="object")return Object.keys(w).forEach(function(z){I.$d[g(z)]=w[z]}),this.calMilliseconds(),this;if(typeof w=="string"){var Y=w.match(l);if(Y){var P=Y.slice(2).map(function(z){return z!=null?Number(z):0});return this.$d.years=P[0],this.$d.months=P[1],this.$d.weeks=P[2],this.$d.days=P[3],this.$d.hours=P[4],this.$d.minutes=P[5],this.$d.seconds=P[6],this.calMilliseconds(),this}}return this}var S=M.prototype;return S.calMilliseconds=function(){var w=this;this.$ms=Object.keys(this.$d).reduce(function(_,H){return _+(w.$d[H]||0)*c[H]},0)},S.parseFromMilliseconds=function(){var w=this.$ms;this.$d.years=T(w/d),w%=d,this.$d.months=T(w/u),w%=u,this.$d.days=T(w/h),w%=h,this.$d.hours=T(w/o),w%=o,this.$d.minutes=T(w/n),w%=n,this.$d.seconds=T(w/s),w%=s,this.$d.milliseconds=w},S.toISOString=function(){var w=b(this.$d.years,"Y"),_=b(this.$d.months,"M"),H=+this.$d.days||0;this.$d.weeks&&(H+=7*this.$d.weeks);var I=b(H,"D"),Y=b(this.$d.hours,"H"),P=b(this.$d.minutes,"M"),z=this.$d.seconds||0;this.$d.milliseconds&&(z+=this.$d.milliseconds/1e3,z=Math.round(1e3*z)/1e3);var tt=b(z,"S"),Ee=w.negative||_.negative||I.negative||Y.negative||P.negative||tt.negative,Oe=Y.format||P.format||tt.format?"T":"",et=(Ee?"-":"")+"P"+w.format+_.format+I.format+Oe+Y.format+P.format+tt.format;return et==="P"||et==="-P"?"P0D":et},S.toJSON=function(){return this.toISOString()},S.format=function(w){var _=w||"YYYY-MM-DDTHH:mm:ss",H={Y:this.$d.years,YY:i.s(this.$d.years,2,"0"),YYYY:i.s(this.$d.years,4,"0"),M:this.$d.months,MM:i.s(this.$d.months,2,"0"),D:this.$d.days,DD:i.s(this.$d.days,2,"0"),H:this.$d.hours,HH:i.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:i.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:i.s(this.$d.seconds,2,"0"),SSS:i.s(this.$d.milliseconds,3,"0")};return _.replace(a,function(I,Y){return Y||String(H[I])})},S.as=function(w){return this.$ms/c[g(w)]},S.get=function(w){var _=this.$ms,H=g(w);return H==="milliseconds"?_%=1e3:_=H==="weeks"?T(_/c[H]):this.$d[H],_||0},S.add=function(w,_,H){var I;return I=_?w*c[g(_)]:m(w)?w.$ms:p(w,this).$ms,p(this.$ms+I*(H?-1:1),this)},S.subtract=function(w,_){return this.add(w,_,!0)},S.locale=function(w){var _=this.clone();return _.$l=w,_},S.clone=function(){return p(this.$ms,this)},S.humanize=function(w){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!w)},S.valueOf=function(){return this.asMilliseconds()},S.milliseconds=function(){return this.get("milliseconds")},S.asMilliseconds=function(){return this.as("milliseconds")},S.seconds=function(){return this.get("seconds")},S.asSeconds=function(){return this.as("seconds")},S.minutes=function(){return this.get("minutes")},S.asMinutes=function(){return this.as("minutes")},S.hours=function(){return this.get("hours")},S.asHours=function(){return this.as("hours")},S.days=function(){return this.get("days")},S.asDays=function(){return this.as("days")},S.weeks=function(){return this.get("weeks")},S.asWeeks=function(){return this.as("weeks")},S.months=function(){return this.get("months")},S.asMonths=function(){return this.as("months")},S.years=function(){return this.get("years")},S.asYears=function(){return this.as("years")},M}(),k=function(M,S,w){return M.add(S.years()*w,"y").add(S.months()*w,"M").add(S.days()*w,"d").add(S.hours()*w,"h").add(S.minutes()*w,"m").add(S.seconds()*w,"s").add(S.milliseconds()*w,"ms")};return function(M,S,w){e=w,i=w().$utils(),w.duration=function(I,Y){var P=w.locale();return p(I,{$l:P},Y)},w.isDuration=m;var _=S.prototype.add,H=S.prototype.subtract;S.prototype.add=function(I,Y){return m(I)?k(this,I,1):_.bind(this)(I,Y)},S.prototype.subtract=function(I,Y){return m(I)?k(this,I,-1):H.bind(this)(I,Y)}}})})(ht);var _t=ht.exports;const Ht=F(_t);var at={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i,s){i.prototype.isBetween=function(n,o,h,a){var d=s(n),u=s(o),l=(a=a||"()")[0]==="(",c=a[1]===")";return(l?this.isAfter(d,h):!this.isBefore(d,h))&&(c?this.isBefore(u,h):!this.isAfter(u,h))||(l?this.isBefore(d,h):!this.isAfter(d,h))&&(c?this.isAfter(u,h):!this.isBefore(u,h))}}})})(at);var At=at.exports;const It=F(At);var lt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i){i.prototype.isSameOrBefore=function(s,n){return this.isSame(s,n)||this.isBefore(s,n)}}})})(lt);var Rt=lt.exports;const Wt=F(Rt);var ct={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i){i.prototype.isSameOrAfter=function(s,n){return this.isSame(s,n)||this.isAfter(s,n)}}})})(ct);var $t=ct.exports;const Gt=F($t);var dt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i,s){var n=i.prototype,o=function(l){return l&&(l.indexOf?l:l.s)},h=function(l,c,m,p,g){var x=l.name?l:l.$locale(),T=o(x[c]),v=o(x[m]),b=T||v.map(function(k){return k.slice(0,p)});if(!g)return b;var E=x.weekStart;return b.map(function(k,M){return b[(M+(E||0))%7]})},a=function(){return s.Ls[s.locale()]},d=function(l,c){return l.formats[c]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(p,g,x){return g||x.slice(1)})}(l.formats[c.toUpperCase()])},u=function(){var l=this;return{months:function(c){return c?c.format("MMMM"):h(l,"months")},monthsShort:function(c){return c?c.format("MMM"):h(l,"monthsShort","months",3)},firstDayOfWeek:function(){return l.$locale().weekStart||0},weekdays:function(c){return c?c.format("dddd"):h(l,"weekdays")},weekdaysMin:function(c){return c?c.format("dd"):h(l,"weekdaysMin","weekdays",2)},weekdaysShort:function(c){return c?c.format("ddd"):h(l,"weekdaysShort","weekdays",3)},longDateFormat:function(c){return d(l.$locale(),c)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};n.localeData=function(){return u.bind(this)()},s.localeData=function(){var l=a();return{firstDayOfWeek:function(){return l.weekStart||0},weekdays:function(){return s.weekdays()},weekdaysShort:function(){return s.weekdaysShort()},weekdaysMin:function(){return s.weekdaysMin()},months:function(){return s.months()},monthsShort:function(){return s.monthsShort()},longDateFormat:function(c){return d(l,c)},meridiem:l.meridiem,ordinal:l.ordinal}},s.months=function(){return h(a(),"months")},s.monthsShort=function(){return h(a(),"monthsShort","months",3)},s.weekdays=function(l){return h(a(),"weekdays",null,null,l)},s.weekdaysShort=function(l){return h(a(),"weekdaysShort","weekdays",3,l)},s.weekdaysMin=function(l){return h(a(),"weekdaysMin","weekdays",2,l)}}})})(dt);var Yt=dt.exports;const Pt=F(Yt);var ut={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e="week",i="year";return function(s,n,o){var h=n.prototype;h.week=function(a){if(a===void 0&&(a=null),a!==null)return this.add(7*(a-this.week()),"day");var d=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var u=o(this).startOf(i).add(1,i).date(d),l=o(this).endOf(e);if(u.isBefore(l))return 1}var c=o(this).startOf(i).date(d).startOf(e).subtract(1,"millisecond"),m=this.diff(c,e,!0);return m<0?o(this).startOf("week").week():Math.ceil(m)},h.weeks=function(a){return a===void 0&&(a=null),this.week(a)}}})})(ut);var Ft=ut.exports;const zt=F(Ft);var gt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i){i.prototype.weekYear=function(){var s=this.month(),n=this.week(),o=this.year();return n===1&&s===11?o+1:s===0&&n>=52?o-1:o}}})})(gt);var Nt=gt.exports;const Ut=F(Nt);var ft={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i){var s=i.prototype,n=s.format;s.format=function(o){var h=this,a=this.$locale();if(!this.isValid())return n.bind(this)(o);var d=this.$utils(),u=(o||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(l){switch(l){case"Q":return Math.ceil((h.$M+1)/3);case"Do":return a.ordinal(h.$D);case"gggg":return h.weekYear();case"GGGG":return h.isoWeekYear();case"wo":return a.ordinal(h.week(),"W");case"w":case"ww":return d.s(h.week(),l==="w"?1:2,"0");case"W":case"WW":return d.s(h.isoWeek(),l==="W"?1:2,"0");case"k":case"kk":return d.s(String(h.$H===0?24:h.$H),l==="k"?1:2,"0");case"X":return Math.floor(h.$d.getTime()/1e3);case"x":return h.$d.getTime();case"z":return"["+h.offsetName()+"]";case"zzz":return"["+h.offsetName("long")+"]";default:return l}});return n.bind(this)(u)}}})})(ft);var Xt=ft.exports;const Bt=F(Xt);var mt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return function(e,i,s){s.updateLocale=function(n,o){var h=s.Ls[n];if(h)return(o?Object.keys(o):[]).forEach(function(a){h[a]=o[a]}),h}}})})(mt);var Vt=mt.exports;const qt=F(Vt);var pt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e="day";return function(i,s,n){var o=function(d){return d.add(4-d.isoWeekday(),e)},h=s.prototype;h.isoWeekYear=function(){return o(this).year()},h.isoWeek=function(d){if(!this.$utils().u(d))return this.add(7*(d-this.isoWeek()),e);var u,l,c,m,p=o(this),g=(u=this.isoWeekYear(),l=this.$u,c=(l?n.utc:n)().year(u).startOf("year"),m=4-c.isoWeekday(),c.isoWeekday()>4&&(m+=7),c.add(m,e));return p.diff(g,"week")+1},h.isoWeekday=function(d){return this.$utils().u(d)?this.day()||7:this.day(this.day()%7?d:d-7)};var a=h.startOf;h.startOf=function(d,u){var l=this.$utils(),c=!!l.u(u)||u;return l.p(d)==="isoweek"?c?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):a.bind(this)(d,u)}}})})(pt);var Qt=pt.exports;const Kt=F(Qt);var xt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},i={};return function(s,n,o){var h,a=function(c,m,p){p===void 0&&(p={});var g=new Date(c),x=function(T,v){v===void 0&&(v={});var b=v.timeZoneName||"short",E=T+"|"+b,k=i[E];return k||(k=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:T,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),i[E]=k),k}(m,p);return x.formatToParts(g)},d=function(c,m){for(var p=a(c,m),g=[],x=0;x<p.length;x+=1){var T=p[x],v=T.type,b=T.value,E=e[v];E>=0&&(g[E]=parseInt(b,10))}var k=g[3],M=k===24?0:k,S=g[0]+"-"+g[1]+"-"+g[2]+" "+M+":"+g[4]+":"+g[5]+":000",w=+c;return(o.utc(S).valueOf()-(w-=w%1e3))/6e4},u=n.prototype;u.tz=function(c,m){c===void 0&&(c=h);var p,g=this.utcOffset(),x=this.toDate(),T=x.toLocaleString("en-US",{timeZone:c}),v=Math.round((x-new Date(T))/1e3/60),b=15*-Math.round(x.getTimezoneOffset()/15)-v;if(!Number(b))p=this.utcOffset(0,m);else if(p=o(T,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(b,!0),m){var E=p.utcOffset();p=p.add(g-E,"minute")}return p.$x.$timezone=c,p},u.offsetName=function(c){var m=this.$x.$timezone||o.tz.guess(),p=a(this.valueOf(),m,{timeZoneName:c}).find(function(g){return g.type.toLowerCase()==="timezonename"});return p&&p.value};var l=u.startOf;u.startOf=function(c,m){if(!this.$x||!this.$x.$timezone)return l.call(this,c,m);var p=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return l.call(p,c,m).tz(this.$x.$timezone,!0)},o.tz=function(c,m,p){var g=p&&m,x=p||m||h,T=d(+o(),x);if(typeof c!="string")return o(c).tz(x);var v=function(M,S,w){var _=M-60*S*1e3,H=d(_,w);if(S===H)return[_,S];var I=d(_-=60*(H-S)*1e3,w);return H===I?[_,H]:[M-60*Math.min(H,I)*1e3,Math.max(H,I)]}(o.utc(c,g).valueOf(),T,x),b=v[0],E=v[1],k=o(b).utcOffset(E);return k.$x.$timezone=x,k},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(c){h=c}}})})(xt);var Zt=xt.exports;const jt=F(Zt);var yt={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){var e="minute",i=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(n,o,h){var a=o.prototype;h.utc=function(g){var x={date:g,utc:!0,args:arguments};return new o(x)},a.utc=function(g){var x=h(this.toDate(),{locale:this.$L,utc:!0});return g?x.add(this.utcOffset(),e):x},a.local=function(){return h(this.toDate(),{locale:this.$L,utc:!1})};var d=a.parse;a.parse=function(g){g.utc&&(this.$u=!0),this.$utils().u(g.$offset)||(this.$offset=g.$offset),d.call(this,g)};var u=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 u.call(this)};var l=a.utcOffset;a.utcOffset=function(g,x){var T=this.$utils().u;if(T(g))return this.$u?0:T(this.$offset)?l.call(this):this.$offset;if(typeof g=="string"&&(g=function(k){k===void 0&&(k="");var M=k.match(i);if(!M)return null;var S=(""+M[0]).match(s)||["-",0,0],w=S[0],_=60*+S[1]+ +S[2];return _===0?0:w==="+"?_:-_}(g),g===null))return this;var v=Math.abs(g)<=16?60*g:g,b=this;if(x)return b.$offset=v,b.$u=g===0,b;if(g!==0){var E=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(v+E,e)).$offset=v,b.$x.$localOffset=E}else b=this.utc();return b};var c=a.format;a.format=function(g){var x=g||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,x)},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 m=a.toDate;a.toDate=function(g){return g==="s"&&this.$offset?h(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():m.call(this)};var p=a.diff;a.diff=function(g,x,T){if(g&&this.$u===g.$u)return p.call(this,g,x,T);var v=this.local(),b=h(g).local();return p.call(v,b,x,T)}}})})(yt);var Jt=yt.exports;const te=F(Jt);var ee={exports:{}};(function(f,t){(function(e,i){f.exports=i()})(G,function(){return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var i=["th","st","nd","rd"],s=e%100;return"["+e+(i[(s-20)%10]||i[s]||i[0])+"]"}}})})(ee);var ie={exports:{}};(function(f,t){(function(e,i){f.exports=i(D)})(G,function(e){function i(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var s=i(e),n={name:"zh",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(o,h){return h==="W"?o+"周":o+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s后",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(o,h){var a=100*o+h;return a<600?"凌晨":a<900?"早上":a<1100?"上午":a<1300?"中午":a<1800?"下午":"晚上"}};return s.default.locale(n,null,!0),n})})(ie);const se=(f,t)=>{const e=t.prototype;e.setLocale=function(s){return this.$locale=s||D().locale(),this.$L=this.$locale,this};const i=e.format;e.format=function(s){return this.$L=D().locale(),i.bind(this)(s)}};D.extend(Ht),D.extend(It),D.extend(Wt),D.extend(Gt),D.extend(zt),D.extend(Pt),D.extend(Ut),D.extend(Bt),D.extend(qt),D.extend(Kt),D.extend(jt),D.extend(te),D.extend(se);function wt(f){try{if(D.locale()===f)return;if(D.locale(f)!==f)throw Error();C.info(`Locale set to ${f}`)}catch{C.warn(`Failed to set locale ${f}, fallback to en`),D.locale("en")}}const Z=()=>({small:{hour:15,day:15,week:5,month:3,quarter:3},normal:{hour:30,day:30,week:10,month:7,quarter:7},large:{hour:60,day:60,week:20,month:14,quarter:14}});class ne{constructor(){r(this,"startTime",D().startOf("day"));r(this,"endTime",D().endOf("day"));r(this,"targetEnd",D().endOf("day"));r(this,"strictStart",!1);r(this,"strictEnd",!1);r(this,"isStrict",!1);r(this,"isAuto",!1);r(this,"timeline",[]);r(this,"headerGroupFormat");r(this,"headerCellFormat");r(this,"isDirty",!0);r(this,"isFirstTime",!0);r(this,"allWidth",0);r(this,"cellWidth");r(this,"unit","day");this.cellWidth=O.cloneDeep(Z().normal)}getStartTime(){return this.startTime}getEndTime(){return this.endTime}getCellWidth(){const t=this.cellWidth[this.getChildUnit()];if(this.isAuto){const e=this.allWidth/this.getCellCount();return Math.max(isNaN(e)?0:e,t)}return t}getCellCount(){return this.timeline.reduce((t,e)=>{var i;return t+(((i=e.children)==null?void 0:i.length)||0)},0)}getCellUnit(){return this.getFinelyUnit()}setAllWidth(t){if(this.allWidth=t,!this.strictEnd){const e=this.getCellWidth(),i=this.targetEnd.diff(this.startTime,this.getFinelyUnit());if(e*i<this.allWidth){const s=this.allWidth-e*i,n=Math.ceil(s/e);this.endTime=this.targetEnd.add(n,this.getFinelyUnit()),this.invalidateCache()}}}getTimeLeft(t){const e=this.getCellWidth(),i=this.getFinelyUnit(),s=60*60*(i==="day"?24:1)/e;return t.diff(this.startTime,"second")/s}getTimeByLeft(t){const e=this.getCellWidth(),i=this.getFinelyUnit(),s=60*60*(i==="day"?24:1)/e,n=t*s;return this.startTime.add(n,"second")}init(t){this.isDirty=!0;const{unit:e,chart:i}=t;this.isAuto=!!i.autoCellWidth;const s={hour:"hour",day:"day",week:"week",month:"month",quarter:"quarter"}[e];s||C.warn(`Unknown unit: [${e}]. Falling back to "day".`),this.unit=s||"day",i.startTime&&(this.startTime=D(i.startTime).startOf(this.getFinelyUnit()),this.strictStart=!0),i.endTime&&(this.endTime=D(i.endTime).endOf(this.getFinelyUnit()),this.strictEnd=!0),this.isStrict=this.strictStart&&this.strictEnd,i.cellWidth&&(O.isNumber(i.cellWidth)?this.cellWidth={hour:i.cellWidth,day:i.cellWidth,week:i.cellWidth,month:i.cellWidth,quarter:i.cellWidth}:O.isString(i.cellWidth)?this.cellWidth=O.cloneDeep(Z()[i.cellWidth]||Z().normal):O.isObject(i.cellWidth)&&(this.cellWidth=Object.assign(this.cellWidth,i.cellWidth))),this.headerCellFormat=i.headerCellFormat,this.headerGroupFormat=i.headerGroupFormat}update(t){this.init(t),this.endTime=this.targetEnd.clone()}setDate(t,e){this.isStrict||(!this.strictStart&&t&&(this.isFirstTime||t.isBefore(this.startTime))&&(this.startTime=t.startOf(this.getFinelyUnit())),!this.strictEnd&&e&&(this.isFirstTime||e.isAfter(this.endTime))&&(this.endTime=e.endOf(this.getFinelyUnit())),this.targetEnd=this.endTime.clone(),this.isFirstTime=!1,this.invalidateCache())}getTimeline(){if(!this.isDirty&&this.timeline.length>0)return this.timeline;const t=[];let e=this.startTime.clone();for(t.push({date:e,label:this.formatterGroupLabel(e),children:[{date:e,label:this.formatterCellLabel(e)}]});e.isSameOrBefore(this.endTime,this.getFinelyUnit());){const i=e.add(1,this.getFinelyUnit()).startOf(this.getFinelyUnit()).clone(),s=this.formatterGroupLabel(i),n=t.find(o=>o.label===s);n?(n.children||(n.children=[]),n.children.push({date:i,label:this.formatterCellLabel(i)})):t.push({date:i,label:s,children:[{date:i,label:this.formatterCellLabel(i)}]}),e=i}return this.isDirty=!1,this.timeline=t,t}clear(){this.isDirty=!0,this.isFirstTime=!0}invalidateCache(){this.isDirty=!0}getFinelyUnit(){return this.unit==="hour"?"hour":"day"}getChildUnit(){return this.unit}getGroupUnit(){switch(this.unit){case"hour":return"day";case"month":case"quarter":return"year";case"day":case"week":default:return"month"}}formatterGroupLabel(t){if(O.isFunction(this.headerGroupFormat)){const i=this.headerGroupFormat(t.toDate(),this.unit);if(i)return i}if(O.isString(this.headerGroupFormat))return t.format(this.headerGroupFormat);switch(this.getGroupUnit()){case"month":return t.format("YYYY-MM");case"year":return t.format("YYYY");case"day":default:return t.format("YYYY-MM-DD")}}formatterCellLabel(t){if(O.isFunction(this.headerCellFormat)){const i=this.headerCellFormat(t.toDate(),this.unit);if(i)return i}if(O.isString(this.headerCellFormat))return t.format(this.headerCellFormat);switch(this.getChildUnit()){case"hour":return t.format("H");case"week":return t.format("wo");case"month":return t.format("MMM");case"quarter":return t.format("[Q]Q");case"day":default:return t.format("Do")}}getTotalWidth(){return this.getCellCount()*this.getCellWidth()}expand(t,e=1){t==="left"?this.startTime=this.startTime.subtract(e,this.getFinelyUnit()):t==="right"?this.endTime=this.endTime.add(e,this.getFinelyUnit()):t==="all"&&(this.startTime=this.startTime.subtract(e,this.getFinelyUnit()),this.endTime=this.endTime.add(e,this.getFinelyUnit())),this.targetEnd=this.endTime.clone(),this.invalidateCache()}isInTimeAxis(t){return t.isSameOrAfter(this.startTime)&&t.isSameOrBefore(this.endTime)}}class oe{constructor(t,e){r(this,"optionManager");r(this,"dataManager");r(this,"columnManager");r(this,"timeAxis");this.context=t;const i=O.omit(e,["data"]),s=e==null?void 0:e.data;if(s&&!O.isArray(s))throw C.exception("Data should be a array.");this.optionManager=new vt,this.optionManager.setOptions(i),i.locale&&wt(i.locale),this.timeAxis=new ne,this.timeAxis.init(this.optionManager.getOptions()),this.columnManager=new Dt(this.context),i.table&&i.table.columns&&this.columnManager.init(i.table.columns),this.dataManager=new kt(this,this.context.event),s&&this.dataManager.setData(s,!0)}getOptionManager(){return this.optionManager}getDataManager(){return this.dataManager}getColumnManager(){return this.columnManager}getTimeAxis(){return this.timeAxis}setOption(t,e={merge:!0}){const i=O.omit(t,["data"]),s=t==null?void 0:t.data;O.isArray(s)&&this.dataManager.setData(s,!1),this.optionManager.setOptions(i,e),i.locale&&wt(i.locale),i.table&&i.table.columns&&this.columnManager.update(i.table.columns),this.timeAxis.update(this.optionManager.getOptions())}updateTime(t,e){this.timeAxis.setDate(t,e)}}class re{constructor(t,e,i){r(this,"rootElement");r(this,"options");r(this,"hScrollbar");r(this,"vScrollbar");r(this,"hScrollThumb");r(this,"vScrollThumb");r(this,"scrollbarContainer");r(this,"viewportWidth",0);r(this,"viewportHeight",0);r(this,"contentWidth",0);r(this,"contentHeight",0);r(this,"scrollLeft",0);r(this,"scrollTop",0);r(this,"isDraggingHScroll",!1);r(this,"isDraggingVScroll",!1);r(this,"isMouseOverRoot",!1);r(this,"isMouseOverScrollbar",!1);r(this,"hideTimeout",null);r(this,"showTimeout",null);r(this,"isVisible",!1);r(this,"dragStartX",0);r(this,"dragStartY",0);r(this,"thumbStartScrollLeft",0);r(this,"thumbStartScrollTop",0);r(this,"isAnimating",!1);r(this,"animationFrameId",null);r(this,"animationStartTime",0);r(this,"animationStartScrollLeft",0);r(this,"animationStartScrollTop",0);r(this,"animationTargetScrollLeft",0);r(this,"animationTargetScrollTop",0);r(this,"animationSource","api");r(this,"throttledHandleMouseMove");r(this,"throttledHandleWheel");r(this,"handleRootMouseMove",()=>{!this.isVisible&&this.isMouseOverRoot?this.scheduleShow():this.isVisible&&!this.isMouseOverScrollbar&&this.scheduleHide()});r(this,"handleScrollbarMouseEnter",()=>{this.isMouseOverScrollbar=!0,this.scheduleShow()});r(this,"handleScrollbarMouseLeave",()=>{this.isMouseOverScrollbar=!1,this.isMouseOverRoot&&this.scheduleHide()});r(this,"handleMouseEnter",()=>{this.isMouseOverRoot=!0,this.scheduleShow()});r(this,"handleMouseLeave",()=>{this.isMouseOverRoot=!1,!this.isDraggingHScroll&&!this.isDraggingVScroll&&!this.isMouseOverScrollbar&&(this.clearTimeouts(!0,!1),this.scheduleHide())});r(this,"handleHorizontalThumbMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.isDraggingHScroll=!0,this.dragStartX=t.clientX,this.thumbStartScrollLeft=this.scrollLeft,this.hScrollThumb.style.backgroundColor=this.options.thumb.color,this.scheduleShow(),document.addEventListener("mousemove",this.throttledHandleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)});r(this,"handleVerticalThumbMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.isDraggingVScroll=!0,this.dragStartY=t.clientY,this.thumbStartScrollTop=this.scrollTop,this.vScrollThumb.style.backgroundColor=this.options.thumb.color,this.scheduleShow(),document.addEventListener("mousemove",this.throttledHandleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)});r(this,"handleHorizontalTrackMouseDown",t=>{if(t.target!==this.hScrollbar)return;t.preventDefault();const e=this.hScrollbar.getBoundingClientRect(),i=this.hScrollThumb.offsetWidth,s=t.clientX-e.left,n=this.hScrollbar.clientWidth,o=this.contentWidth-this.viewportWidth,h=n-i,a=(s-i/2)/h*o;this.scrollTo({x:a,y:this.scrollTop},"track")});r(this,"handleVerticalTrackMouseDown",t=>{if(t.target!==this.vScrollbar)return;t.preventDefault();const e=this.vScrollbar.getBoundingClientRect(),i=this.vScrollThumb.offsetHeight,s=t.clientY-e.top,n=this.vScrollbar.clientHeight,o=this.contentHeight-this.viewportHeight,h=n-i,a=(s-i/2)/h*o;this.scrollTo({x:this.scrollLeft,y:a},"track")});r(this,"handleMouseUp",()=>{if(this.isDraggingHScroll||this.isDraggingVScroll){const t=this.isDraggingHScroll,e=this.isDraggingVScroll;this.isDraggingHScroll=!1,this.isDraggingVScroll=!1,t&&(this.hScrollThumb.style.backgroundColor=this.options.thumb.color),e&&(this.vScrollThumb.style.backgroundColor=this.options.thumb.color),document.removeEventListener("mousemove",this.throttledHandleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),!this.isMouseOverRoot&&!this.isMouseOverScrollbar?this.scheduleHide():this.scheduleHide()}});r(this,"animationStep",t=>{if(!this.isAnimating)return;const e=t-this.animationStartTime,i=this.options.animationDuration,s=Math.min(1,e/i),n=s*(2-s),o=this.animationStartScrollLeft+(this.animationTargetScrollLeft-this.animationStartScrollLeft)*n,h=this.animationStartScrollTop+(this.animationTargetScrollTop-this.animationStartScrollTop)*n,a=this.scrollLeft!==o,d=this.scrollTop!==h;(a||d)&&(this.scrollLeft=o,this.scrollTop=h,this.updateThumbStyles(),this.root.event.emit(y.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:this.animationSource})),s<1?this.animationFrameId=requestAnimationFrame(this.animationStep):(this.isAnimating=!1,this.animationFrameId=null,(this.scrollLeft!==this.animationTargetScrollLeft||this.scrollTop!==this.animationTargetScrollTop)&&(this.scrollLeft=this.animationTargetScrollLeft,this.scrollTop=this.animationTargetScrollTop,this.updateThumbStyles(),this.root.event.emit(y.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:this.animationSource})),this.scheduleHide())});this.root=t,this.rootElement=e,this.options=O.merge({showHorizontal:!0,showVertical:!0,track:{size:8,radius:4,color:"transparent"},thumb:{size:30,radius:4,color:"rgba(0, 0, 0, 0.4)"},showDelay:0,hideDelay:500,animationDuration:100,showDuration:200,hideDuration:200},i),this.throttledHandleMouseMove=O.throttle(this.handleMouseMove.bind(this),16),this.throttledHandleWheel=O.throttle(this.handleWheel.bind(this),16,{leading:!0,trailing:!1}),this.createElements(),this.applyStyles(),this.bindEvents(),this.rootElement.matches(":hover")?this.handleMouseEnter():(this.clearTimeouts(),this.hideScrollbars(!0))}createElements(){this.scrollbarContainer=document.createElement("div"),this.scrollbarContainer.className="x-gantt-scrollbar-container",this.rootElement.appendChild(this.scrollbarContainer),this.hScrollbar=this.createScrollbarElement("horizontal"),this.hScrollThumb=this.createScrollThumbElement("horizontal"),this.hScrollbar.appendChild(this.hScrollThumb),this.vScrollbar=this.createScrollbarElement("vertical"),this.vScrollThumb=this.createScrollThumbElement("vertical"),this.vScrollbar.appendChild(this.vScrollThumb),this.scrollbarContainer.appendChild(this.hScrollbar),this.scrollbarContainer.appendChild(this.vScrollbar)}createScrollbarElement(t){const e=document.createElement("div");return e.className=`x-gantt-scrollbar x-gantt-${t}-scrollbar`,e}createScrollThumbElement(t){const e=document.createElement("div");return e.className=`x-gantt-scrollbar-thumb x-gantt-${t}-thumb`,e}applyStyles(){const t=this.scrollbarContainer.style;t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="none",t.zIndex="100",this.applyScrollbarStyles(this.hScrollbar,"horizontal"),this.applyScrollbarStyles(this.vScrollbar,"vertical"),this.applyThumbStyles(this.hScrollThumb,"horizontal"),this.applyThumbStyles(this.vScrollThumb,"vertical")}applyScrollbarStyles(t,e){const i=t.style;i.position="absolute",i.backgroundColor=this.options.track.color,i.borderRadius=`${this.options.track.size/2}px`,i.opacity="0",i.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`,i.pointerEvents="auto",e==="horizontal"?(i.bottom="0px",i.left="0px",i.height=`${this.options.track.size}px`,i.width="0px"):(i.right="0px",i.top="0px",i.width=`${this.options.track.size}px`,i.height="0px")}applyThumbStyles(t,e){const i=t.style;i.position="absolute",i.backgroundColor=this.options.thumb.color,i.borderRadius=`${this.options.thumb.radius}px`,i.cursor="pointer",i.transition="background-color 0.2s",i.pointerEvents="auto",e==="horizontal"?(i.height="100%",i.top="0",i.left="0"):(i.width="100%",i.left="0",i.top="0")}bindEvents(){this.rootElement.addEventListener("mouseenter",this.handleMouseEnter),this.rootElement.addEventListener("mouseleave",this.handleMouseLeave),this.rootElement.addEventListener("mousemove",this.handleRootMouseMove),this.hScrollThumb.addEventListener("mousedown",this.handleHorizontalThumbMouseDown),this.vScrollThumb.addEventListener("mousedown",this.handleVerticalThumbMouseDown),this.hScrollbar.addEventListener("mousedown",this.handleHorizontalTrackMouseDown),this.vScrollbar.addEventListener("mousedown",this.handleVerticalTrackMouseDown),this.hScrollbar.addEventListener("mouseenter",this.handleScrollbarMouseEnter),this.vScrollbar.addEventListener("mouseenter",this.handleScrollbarMouseEnter),this.hScrollbar.addEventListener("mouseleave",this.handleScrollbarMouseLeave),this.vScrollbar.addEventListener("mouseleave",this.handleScrollbarMouseLeave),this.rootElement.addEventListener("wheel",this.throttledHandleWheel,{passive:!1})}unbindEvents(){this.rootElement.removeEventListener("mouseenter",this.handleMouseEnter),this.rootElement.removeEventListener("mouseleave",this.handleMouseLeave),this.rootElement.removeEventListener("mousemove",this.handleRootMouseMove),this.hScrollThumb.removeEventListener("mousedown",this.handleHorizontalThumbMouseDown),this.vScrollThumb.removeEventListener("mousedown",this.handleVerticalThumbMouseDown),this.hScrollbar.removeEventListener("mousedown",this.handleHorizontalTrackMouseDown),this.vScrollbar.removeEventListener("mousedown",this.handleVerticalTrackMouseDown),this.hScrollbar.removeEventListener("mouseenter",this.handleScrollbarMouseEnter),this.vScrollbar.removeEventListener("mouseenter",this.handleScrollbarMouseEnter),this.hScrollbar.removeEventListener("mouseleave",this.handleScrollbarMouseLeave),this.vScrollbar.removeEventListener("mouseleave",this.handleScrollbarMouseLeave),this.rootElement.removeEventListener("wheel",this.throttledHandleWheel),document.removeEventListener("mousemove",this.throttledHandleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}handleMouseMove(t){if(!(!this.isDraggingHScroll&&!this.isDraggingVScroll)){if(this.scheduleShow(),this.isDraggingHScroll){const e=t.clientX-this.dragStartX,i=this.hScrollbar.clientWidth,s=this.hScrollThumb.offsetWidth,n=Math.max(0,i-s),o=Math.max(0,this.contentWidth-this.viewportWidth);if(n===0||o===0)return;const h=e/n*o,a=this.thumbStartScrollLeft+h;this.scrollTo({x:a,y:this.scrollTop},"drag")}if(this.isDraggingVScroll){const e=t.clientY-this.dragStartY,i=this.vScrollbar.clientHeight,s=this.vScrollThumb.offsetHeight,n=Math.max(0,i-s),o=Math.max(0,this.contentHeight-this.viewportHeight);if(n===0||o===0)return;const h=e/n*o,a=this.thumbStartScrollTop+h;this.scrollTo({x:this.scrollLeft,y:a},"drag")}}}handleWheel(t){if(t.target!==this.rootElement&&!this.rootElement.contains(t.target)&&C.debug("Wheel event ignored, target not root or descendant:",t.target),!this.isMouseOverRoot&&!this.isMouseOverScrollbar){C.debug("Wheel event ignored, mouse not over root or scrollbar");return}const e=this.canScrollHorizontal(),i=this.canScrollVertical();if(!e&&!i)return;t.preventDefault();let s=t.deltaX,n=t.deltaY;Math.abs(t.deltaX)<Math.abs(t.deltaY)&&t.shiftKey&&e&&(s=n,n=0);const o=this.scrollLeft+s,h=this.scrollTop+n;this.scrollLeft=o,this.scrollTop=h,this.updateThumbStyles(),this.root.event.emit(y.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:"wheel"})}animateWheelScroll(t,e){this.cancelAnimation();const i=this.clampScroll({x:t,y:e});if(this.scrollLeft===i.x&&this.scrollTop===i.y)return;this.isAnimating=!0,this.animationStartTime=performance.now(),this.animationStartScrollLeft=this.scrollLeft,this.animationStartScrollTop=this.scrollTop,this.animationTargetScrollLeft=i.x,this.animationTargetScrollTop=i.y,this.animationSource="wheel";const s=150,n=o=>{if(!this.isAnimating)return;const h=o-this.animationStartTime,a=Math.min(1,h/s),d=a*(2-a),u=this.animationStartScrollLeft+(this.animationTargetScrollLeft-this.animationStartScrollLeft)*d,l=this.animationStartScrollTop+(this.animationTargetScrollTop-this.animationStartScrollTop)*d,c=this.scrollLeft!==u,m=this.scrollTop!==l;(c||m)&&(this.scrollLeft=u,this.scrollTop=l,this.updateThumbStyles(),this.root.event.emit(y.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:"wheel"})),a<1?this.animationFrameId=requestAnimationFrame(n):(this.isAnimating=!1,this.animationFrameId=null,(this.scrollLeft!==this.animationTargetScrollLeft||this.scrollTop!==this.animationTargetScrollTop)&&(this.scrollLeft=this.animationTargetScrollLeft,this.scrollTop=this.animationTargetScrollTop,this.updateThumbStyles(),this.root.event.emit(y.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:"wheel"})),this.scheduleHide())};this.animationFrameId=requestAnimationFrame(n)}clearTimeouts(t=!0,e=!0){t&&this.showTimeout!==null&&(window.clearTimeout(this.showTimeout),this.showTimeout=null),e&&this.hideTimeout!==null&&(window.clearTimeout(this.hideTimeout),this.hideTimeout=null)}scheduleShow(){if(this.isVisible||this.showTimeout!==null){this.hideTimeout!==null&&this.clearTimeouts(!1,!0);return}this.clearTimeouts(!0,!0),this.options.showDelay<=0?this.showScrollbars():this.showTimeout=window.setTimeout(()=>{this.showScrollbars(),this.showTimeout=null},this.options.showDelay)}showScrollbars(){this.clearTimeouts(),this.isVisible=!0,this.hScrollbar.style.transition=`opacity ${this.options.showDuration/1e3}s ease-in`,this.vScrollbar.style.transition=`opacity ${this.options.showDuration/1e3}s ease-in`,requestAnimationFrame(()=>{this.canScrollHorizontal()&&this.options.showHorizontal?this.hScrollbar.style.opacity="1":this.hScrollbar.style.opacity="0",this.canScrollVertical()&&this.options.showVertical?this.vScrollbar.style.opacity="1":this.vScrollbar.style.opacity="0",setTimeout(()=>{this.isVisible&&(this.hScrollbar.style.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`,this.vScrollbar.style.transition=`opacity ${this.options.hideDuration/1e3}s ease-out`)},this.options.showDuration)}),this.scheduleHide()}scheduleHide(){if(this.isDraggingHScroll||this.isDraggingVScroll||this.isMouseOverScrollbar){this.clearTimeouts(!0,!0);return}this.hideTimeout===null&&(this.clearTimeouts(!0,!1),this.hideTimeout=window.setTimeout(()=>{!this.isMouseOverRoot&&!this.isDraggingHScroll&&!this.isDraggingVScroll&&!this.isMouseOverScrollbar&&this.hideScrollbars(),this.hideTimeout=null},this.options.hideDelay))}hideScrollbars(t=!1){!t&&(this.isDraggingHScroll||this.isDraggingVScroll||this.isMouseOverScrollbar)||(this.clearTimeouts(!0,!0),this.isVisible=!1,this.hScrollbar.style.opacity="0",this.vScrollbar.style.opacity="0")}updateSize(t,e,i,s,n=0,o=0){this.viewportWidth=Math.max(0,t),this.viewportHeight=Math.max(0,e),this.contentWidth=Math.max(this.viewportWidth,i),this.contentHeight=Math.max(this.viewportHeight,s);const h=this.canScrollHorizontal()&&this.options.showHorizontal,a=this.canScrollVertical()&&this.options.showVertical;if(h){const u=this.viewportWidth-(a?this.options.track.size:0);this.hScrollbar.style.display="block",this.hScrollbar.style.left=`${n}px`,this.hScrollbar.style.width=`${Math.max(0,u)}px`,this.hScrollbar.style.bottom="0px",this.hScrollbar.style.right=a?`${this.options.track.size}px`:"0px"}else this.hScrollbar.style.display="none";if(a){const u=this.viewportHeight-o-(h?this.options.track.size:0);this.vScrollbar.style.display="block",this.vScrollbar.style.top=`${o}px`,this.vScrollbar.style.height=`${Math.max(0,u)}px`,this.vScrollbar.style.right="0px",this.vScrollbar.style.bottom=h?`${this.options.track.size}px`:"0px"}else this.vScrollbar.style.display="none";this.updateThumbStyles();const d=this.clampScroll({x:this.scrollLeft,y:this.scrollTop});(d.x!==this.scrollLeft||d.y!==this.scrollTop)&&(this.scrollLeft=d.x,this.scrollTop=d.y,this.updateThumbStyles(),this.root.event.emit(y.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:"api"})),this.isMouseOverRoot||this.isDraggingHScroll||this.isDraggingVScroll?this.scheduleShow():!h&&!a?this.hideScrollbars(!0):this.isVisible?this.scheduleShow():this.hideScrollbars(!0)}updateThumbStyles(){if(this.canScrollHorizontal()&&this.options.showHorizontal){const t=this.hScrollbar.clientWidth,e=Math.max(this.options.thumb.size,t*(this.viewportWidth/this.contentWidth)),i=Math.min(t,e);this.hScrollThumb.style.width=`${i}px`;const s=this.contentWidth-this.viewportWidth,n=t-i,o=s>0?this.scrollLeft/s*n:0;this.hScrollThumb.style.transform=`translateX(${Math.max(0,Math.min(o,n))}px)`,this.hScrollThumb.style.left="0px"}else this.hScrollThumb.style.width="0px";if(this.canScrollVertical()&&this.options.showVertical){const t=this.vScrollbar.clientHeight,e=Math.max(this.options.thumb.size,t*(this.viewportHeight/this.contentHeight)),i=Math.min(t,e);this.vScrollThumb.style.height=`${i}px`;const s=this.contentHeight-this.viewportHeight,n=t-i,o=s>0?this.scrollTop/s*n:0;this.vScrollThumb.style.transform=`translateY(${Math.max(0,Math.min(o,n))}px)`,this.vScrollThumb.style.top="0px"}else this.vScrollThumb.style.height="0px"}canScrollHorizontal(){return this.contentWidth>this.viewportWidth}canScrollVertical(){return this.contentHeight>this.viewportHeight}clampScroll(t){const e=Math.max(0,this.contentWidth-this.viewportWidth),i=Math.max(0,this.contentHeight-this.viewportHeight);return{x:Math.max(0,Math.min(t.x,e)),y:Math.max(0,Math.min(t.y,i))}}scrollTo(t,e="api"){this.scheduleShow();const i=this.clampScroll(O.merge(this.getScrollPosition(),t));if(this.scrollLeft===i.x&&this.scrollTop===i.y){if(this.isAnimating&&this.animationTargetScrollLeft===i.x&&this.animationTargetScrollTop===i.y)return;this.cancelAnimation();return}const s=(e==="api"||e==="track")&&this.options.animationDuration>0;if(this.cancelAnimation(),s)this.isAnimating=!0,this.animationStartTime=performance.now(),this.animationStartScrollLeft=this.scrollLeft,this.animationStartScrollTop=this.scrollTop,this.animationTargetScrollLeft=i.x,this.animationTargetScrollTop=i.y,this.animationSource=e,this.animationFrameId=requestAnimationFrame(this.animationStep);else{this.isAnimating=!1;const n=this.scrollLeft!==i.x,o=this.scrollTop!==i.y;(n||o)&&(this.scrollLeft=i.x,this.scrollTop=i.y,this.updateThumbStyles(),this.root.event.emit(y.SCROLL,{x:this.scrollLeft,y:this.scrollTop,source:e}))}}cancelAnimation(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isAnimating=!1}getScrollPosition(){return{x:this.scrollLeft,y:this.scrollTop}}destroy(){this.unbindEvents(),this.clearTimeouts(),this.cancelAnimation(),this.scrollbarContainer.parentNode&&this.scrollbarContainer.parentNode.removeChild(this.scrollbarContainer),this.rootElement=null,this.eventManager=null,this.hScrollbar=null,this.vScrollbar=null,this.hScrollThumb=null,this.vScrollThumb=null,this.scrollbarContainer=null,C.debug("Scrollbar destroyed")}}function X(f,t=""){const e=["px","%","vh","vw","rem","em"];if(f==null)return t;if(typeof f=="number")return isFinite(f)?`${f}px`:t;if(typeof f=="string"){const i=f.trim();if(i==="")return t;for(const n of e)if(i.endsWith(n)){const o=i.substring(0,i.length-n.length).trim(),h=Number(o);if(!isNaN(h)&&isFinite(h))return`${h}${n}`;break}const s=Number(i);if(!isNaN(s)&&isFinite(s))return`${s}px`}return t}class V{constructor(t,e,i,s,n,o,h=1,a=1,d){r(this,"element");r(this,"isEmpty",!1);r(this,"isHandler",!1);this.context=t,this.container=e,this.column=i,this.task=s,this.rowIndex=n,this.colIndex=o,this.colspan=h,this.rowspan=a,this.isEmpty=d==="empty",this.isHandler=d==="handler",this.element=document.createElement("div"),this.element.className="x-gantt-table-cell",this.element.style.boxSizing="border-box",this.element.style.display="inline-flex",this.element.style.flexShrink="0",this.element.style.flexGrow="0",this.element.style.flexBasis="auto",this.element.style.pointerEvents="all",this.element.style.setProperty("border-color",this.context.getOptions().border.color,"important"),this.element.style.textAlign=this.column.column.align||this.context.getOptions().table.align,!this.context.store.getColumnManager().isLastColumn(this.column.key)&&this.context.getOptions().border.show&&!this.isEmpty&&this.element.classList.add("border"),this.updateWidth(),this.updateHeight(),this.isEmpty?(this.element.style.borderBottom="none",this.element.style.pointerEvents="none",this.element.style.backgroundColor="transparent",this.element.style.setProperty("border-color","transparent","important")):this.isHandler?this.setHandler():this.setContent(),this.container.appendChild(this.element)}setContent(){const t=document.createElement("div");if(t.className="x-gantt-table-cell__content",t.style.overflow="hidden",(this.column.column.ellipsis??!0??this.context.getOptions().table.ellipsis)&&(t.style.textOverflow="ellipsis"),t.style.whiteSpace="nowrap",t.style.flex="1",t.style.height="100%",t.style.alignContent="center",this.colIndex===0&&(t.style.paddingLeft=X(this.task.level*this.context.getOptions().row.indent,"16px")),typeof this.column.column.render=="function")try{const e=this.column.column.render(this.task.getEmitData());typeof e=="string"?t.innerHTML=e:e instanceof HTMLElement?t.appendChild(e):C.warn("Table cell render function does not return a valid value.",e)}catch(e){C.error("Table cell render error:",e),t.textContent=this.task.getField(this.column.column.field)??this.context.getOptions().table.emptyText}else t.textContent=this.task.getField(this.column.column.field)??this.context.getOptions().table.emptyText;this.column.column.customStyle&&Object.assign(t.style,this.column.column.customStyle),this.element.appendChild(t)}setHandler(){const t=document.createElement("div");if(t.className="x-gantt-table-cell__content",t.style.overflow="hidden",t.style.whiteSpace="nowrap",t.style.display="inline-flex",t.style.flex="1",t.style.height="100%",this.context.getOptions().selection.enabled){const e=document.createElement("div");e.style.display="flex",e.style.flex="0.5",e.style.justifyContent="center",e.style.alignItems="center",new ot(this.context,e,this.task),t.appendChild(e)}if(this.context.getOptions().expand.show&&this.task.children&&this.task.children.length>0){const e=document.createElement("div");e.className="x-gantt-table-cell__expand",e.style.display="flex",e.style.flex="0.5",e.style.color=this.context.getOptions().primaryColor,e.style.alignItems="center",e.style.justifyContent="center",e.style.height="100%",e.style.width="14px",e.style.height="100%",e.style.cursor="pointer",e.innerHTML='<svg t="1746693752280" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2612" width="14" height="14"><path d="M724.48 521.728c-1.8432 7.7824-5.7344 14.848-11.3664 20.48l-341.9136 342.016c-16.6912 16.6912-43.7248 16.6912-60.3136 0s-16.6912-43.7248 0-60.3136L622.6944 512 310.8864 200.0896c-16.6912-16.6912-16.6912-43.7248 0-60.3136 16.6912-16.6912 43.7248-16.6912 60.3136 0l341.9136 341.9136c10.8544 10.8544 14.6432 26.112 11.3664 40.0384z" fill="currentColor" p-id="2613"></path></svg>',e.style.transform=this.task.expanded?"rotate(90deg)":"",e.addEventListener("click",i=>{i.stopPropagation(),this.context.store.getDataManager().expandTask(this.task.id,!1)}),t.appendChild(e)}this.element.appendChild(t)}remove(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}updateWidth(){if(this.isHandler){this.element.style.width=X(this.context.store.getColumnManager().getHandlerColumn().width);return}const t=this.context.store.getColumnManager().getLeafColumns().slice(this.colIndex,this.colIndex+Math.max(1,this.colspan)).reduce((e,i)=>e+i.width,0);this.element.style.width=X(t)}updateHeight(){const t=this.context.getOptions().row.height;this.element.style.height=X(t*Math.max(1,this.rowspan))}}class bt{constructor(t,e,i,s,n=!1){r(this,"element");r(this,"cells",[]);this.context=t,this.container=e,this.task=i,this.top=s,this.element=document.createElement("div"),this.element.className="x-gantt-table-row",this.element.style.display="flex",this.element.style.flexDirection="row",this.element.style.flexWrap="nowrap",this.element.style.position="absolute",this.element.style.pointerEvents="none",this.element.style.width=`${this.context.store.getColumnManager().getTotalWidth()}px`,n&&this.raise(),this.updateStyles(),this.container.appendChild(this.element),this.bindEvents(),this.registerEvents()}bindEvents(){this.element.addEventListener("mouseenter",()=>{this.context.event.emit(y.ROW_HIGHLIGHT,this.task.id)}),this.element.addEventListener("mouseleave",()=>{this.context.event.emit(y.ROW_UNHIGHLIGHT,this.task.id)}),this.element.addEventListener("click",t=>{this.context.store.getDataManager().isTaskSelected(this.task.id)||(this.context.store.getDataManager().selectTask(this.task.id),this.context.event.emit(y.ROW_CLICK,t,this.task))}),this.element.addEventListener("dblclick",t=>{this.context.event.emit(y.ROW_DBL_CLICK,t,this.task)}),this.element.addEventListener("contextmenu",t=>{t.preventDefault(),this.context.store.getDataManager().selectTask(this.task.id),this.context.event.emit(y.ROW_CONTEXTMENU,t,this.task.id)})}registerEvents(){this.context.event.on(y.ROW_HIGHLIGHT,t=>{this.task.id===t?this.element.classList.add("hover"):this.element.classList.remove("hover")}),this.context.event.on(y.ROW_UNHIGHLIGHT,t=>{this.task.id===t&&this.element.classList.remove("hover")}),this.context.event.on(y.TASK_SELECTED,t=>{this.task.id===t.id&&this.element.classList.add("selected")}),this.context.event.on(y.TASK_UNSELECTED,t=>{this.task.id===t&&this.element.classList.remove("selected")})}updateStyles(){this.updateTop(this.top),this.context.store.getDataManager().isTaskSelected(this.task.id),this.element.style.backgroundColor=this.context.store.getOptionManager().getRowBackgroundColor(this.task)}raise(){this.element.style.zIndex="2"}updateTop(t){this.top=t;const e=this.context.store.getOptionManager().getOptions().row.height;this.element.style.top=`${-this.top+this.task.flatIndex*e}px`}create(){var i,s;this.clearCells();const t=this.context.store.getColumnManager().getHandlerColumn();if(t.width!==0){const n=new V(this.context,this.element,t,this.task,this.task.flatIndex,-1,1,1,"handler");this.cells.push(n)}const e=this.context.store.getColumnManager().getLeafColumns();for(let n=0;n<e.length;n++){const o=e[n],h=this.context.store.getColumnManager().getMergeInfo(this.task.id,n);if(h)if(h.task.id!==this.task.id){const a=new V(this.context,this.element,o,this.task,this.task.flatIndex,n,1,1,"empty");this.element.style.backgroundColor="transparent",this.raise(),this.cells.push(a)}else{const a=new V(this.context,this.element,o,h.task,h.task.flatIndex,n,h.colspan,h.rowspan);this.cells.push(a)}else{let a=1,d=1;const u=(s=(i=o.column).merge)==null?void 0:s.call(i,this.task.getField(o.column.field),this.task.data,n,this.task.level+1);if(u&&(typeof u.col!="number"?C.error("colspan function must returned a number"):a=u.col,typeof u.row!="number"?C.error("rowspan function must returned a number"):d=u.row),a>1||d>1){if(d>1)for(let p=1;p<d;p++){const g=this.context.store.getDataManager().getVisibleTasks()[this.task.flatIndex+p];if(g&&this.task.level!==g.level){d=p;break}}const c={task:this.task,originColumnIndex:n,colspan:a,rowspan:d};let m=this.task;for(let p=d;p>0;p--)if(m){for(let g=0;g<a;g++)this.context.store.getColumnManager().addMergeInfo(m.id,g+n,c);m=this.context.store.getDataManager().getVisibleTasks().at(m.flatIndex+1)}for(let p=0;p<a;p++)this.context.store.getColumnManager().addMergeInfo(this.task.id,p+n,c)}const l=new V(this.context,this.element,o,this.task,this.task.flatIndex,n,a,d);this.cells.push(l)}}this.context.store.getDataManager().isTaskSelected(this.task.id)&&this.element.classList.add("selected")}update(t){this.task=t,this.create()}updateWidth(){this.element.style.width=`${this.context.store.getColumnManager().getTotalWidth()}px`,this.cells.forEach(t=>t.updateWidth())}clearCells(){for(this.cells.forEach(t=>t.remove()),this.cells=[];this.element.firstChild;)this.element.removeChild(this.element.firstChild)}remove(){this.clearCells(),this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class he{constructor(t,e){r(this,"element");r(this,"rows",new Map);r(this,"mergeRows",new Map);this.context=t,this.container=e,this.element=document.createElement("div"),this.element.className="x-gantt-table-body",this.element.style.width="100%",this.element.style.position="relative",this.container.appendChild(this.element)}render(t,e){this.mergeRows.forEach(n=>n.remove()),this.mergeRows.clear();const i=new Set;e.forEach(n=>{i.add(n.id)});const s=[];this.rows.forEach((n,o)=>{i.has(o)||s.push(o)}),s.forEach(n=>{const o=this.rows.get(n);o&&o.remove(),this.rows.delete(n)}),e.forEach((n,o)=>{const h=n.id;if(this.rows.has(h)){const a=this.rows.get(h);a.update(n),a.updateTop(t)}else{const a=new bt(this.context,this.element,n,t);a.create(),this.rows.set(h,a)}this.context.store.getColumnManager().getLeafColumns().forEach((a,d)=>{const u=this.context.store.getColumnManager().getMergeInfo(n.id,d);if(u&&u.rowspan>1){const l=u.task.id;if(!this.rows.has(l)&&!this.mergeRows.has(l)){const c=new bt(this.context,this.element,u.task,t,!0);c.create(),this.mergeRows.set(l,c)}}})})}refresh(t,e){this.rows.forEach(i=>{i.remove()}),this.rows.clear(),this.render(t,e)}updateTask(t){this.rows.has(t.id)&&this.rows.get(t.id).update(t)}update(){this.rows.forEach(t=>{t.create()})}updateWidth(){this.rows.forEach(t=>{t.updateWidth()}),this.mergeRows.forEach(t=>{t.updateWidth()})}}class j{constructor(t,e,i,s){r(this,"columnElement");this.context=t,this.root=e,this.container=i,this.column=s,this.columnElement=document.createElement("div"),this.initElement(),this.container.appendChild(this.columnElement)}initElement(){const t=this.context.store.getColumnManager(),e=t.getColumnWidth(this.column.key),i=this.column.column.headerAlign||this.context.getOptions().table.headerAlign,s=this.column.column.ellipsis??!0??this.context.getOptions().table.ellipsis;this.columnElement.className="x-gantt-table-header-cell",(t.isMultiHeader()||this.context.getOptions().border.show)&&this.columnElement.classList.add("border"),this.columnElement.style.height="100%",this.columnElement.style.width=`${e}px`,this.columnElement.style.display="flex",this.columnElement.style.flexShrink="0",this.columnElement.style.alignItems="center",this.columnElement.style.padding="0 8px",this.columnElement.style.boxSizing="border-box",this.columnElement.style.setProperty("border-color",this.context.getOptions().border.color,"important");const n=document.createElement("div");if(n.className="x-gantt-table-header-cell__content",n.style.flex="1",n.style.textAlign=i,n.style.overflow="hidden",n.style.whiteSpace="nowrap",s&&(n.style.textOverflow="ellipsis"),n.style.position="relative",n.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,n.style.fontSize=X(this.context.getOptions().header.fontSize),n.style.setProperty("color",this.context.getOptions().header.color,"important"),n.style.fontFamily=this.context.getOptions().header.fontFamily,this.column.column.headerRender){const o=this.column.column.headerRender();typeof o=="string"?n.innerHTML=o:o instanceof HTMLElement&&(n.innerHTML="",n.appendChild(o))}else n.textContent=this.column.label||this.column.column.label||"";this.column.column.customStyle&&Object.assign(n.style,this.column.column.customStyle),this.columnElement.appendChild(n),this.addResizeHandle()}setWidth(t){this.columnElement.style.width=`${t}px`,this.context.store.getColumnManager().setColumnWidth(this.column.key,t)}addResizeHandle(){if(this.column.column.resizable===!1||this.context.store.getColumnManager().isLastColumn(this.column.key))return;const t=document.createElement("div");t.className="x-gantt-column-resize-handle",t.style.position="absolute",t.style.top="0",t.style.right="0",t.style.width="5px",t.style.height="100%",t.style.cursor="col-resize",t.style.zIndex="2",this.columnElement.appendChild(t);let e=0,i=0,s=null,n=0;const o=d=>{d.preventDefault(),d.stopPropagation(),e=d.clientX,i=this.columnElement.offsetWidth,s=this.root.getBoundingClientRect();const u=c=>h(c),l=c=>a(c,u,l);document.addEventListener("mousemove",u),document.addEventListener("mouseup",l),n=e-s.left,this.context.event.emit(y.SHOW_GUIDELINE,n)},h=d=>{if(d.preventDefault(),!s)return;const u=d.clientX-e,l=i+u,c=Math.max(50,l),m=e-s.left-i,g=this.root.clientWidth-20;let x=m+c;x=Math.min(g,x),this.context.event.emit(y.MOVE_GUIDELINE,x)},a=(d,u,l)=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",l),this.context.event.emit(y.HIDE_GUIDELINE);const c=d.clientX-e,m=Math.max(50,i+c);this.setWidth(m)};t.addEventListener("mousedown",o)}}class J{constructor(t,e,i,s){r(this,"groupElement");r(this,"titleContainer");r(this,"childContainer");r(this,"children",[]);this.context=t,this.root=e,this.container=i,this.column=s,this.groupElement=document.createElement("div"),this.titleContainer=document.createElement("div"),this.childContainer=document.createElement("div"),this.initElement(),this.initChildren(),this.container.appendChild(this.groupElement)}initElement(){const e=this.context.getOptions().header.height/this.column.maxLevel;this.groupElement.className="x-gantt-table-header-group",(this.context.store.getColumnManager().isMultiHeader()||this.context.getOptions().border.show)&&this.groupElement.classList.add("border"),this.groupElement.style.display="flex",this.groupElement.style.flexShrink="0",this.groupElement.style.flexGrow="0",this.groupElement.style.flexDirection="column",this.groupElement.style.height="100%",this.groupElement.style.overflow="hidden",this.groupElement.style.boxSizing="border-box",this.titleContainer.className="x-gantt-table-header-cell",(this.context.store.getColumnManager().isMultiHeader()||this.context.getOptions().border.show)&&this.titleContainer.classList.add("border"),this.titleContainer.style.height=`${e}px`,this.titleContainer.style.flex="0 0 auto",this.titleContainer.style.display="flex",this.titleContainer.style.alignItems=this.context.getOptions().table.headerAlign,this.titleContainer.style.justifyContent="center",this.titleContainer.style.padding="0 8px",this.titleContainer.style.boxSizing="border-box",this.titleContainer.style.overflow="hidden",this.titleContainer.style.whiteSpace="nowrap",this.context.getOptions().table.ellipsis&&(this.titleContainer.style.textOverflow="ellipsis"),this.titleContainer.style.borderBottom=`1px solid ${this.context.getOptions().border.color}`,this.titleContainer.style.setProperty("border-color",this.context.getOptions().border.color,"important"),this.titleContainer.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,this.titleContainer.style.fontSize=X(this.context.getOptions().header.fontSize),this.titleContainer.style.fontFamily=this.context.getOptions().header.fontFamily,this.titleContainer.style.setProperty("color",this.context.getOptions().header.color,"important"),this.titleContainer.textContent=this.column.label||"",this.childContainer.className="x-gantt-table-header-children",this.childContainer.style.flex="1 0 auto",this.childContainer.style.display="flex",this.childContainer.style.width="100%",this.groupElement.appendChild(this.titleContainer),this.groupElement.appendChild(this.childContainer)}initChildren(){this.column.children.forEach(t=>{if(t.isLeaf){const e=new j(this.context,this.root,this.childContainer,t);this.children.push(e)}else if(t.children.length>0){const e=new J(this.context,this.root,this.childContainer,t);this.children.push(e)}})}}class ae{constructor(t,e){r(this,"headerElement");r(this,"headerColumns",[]);this.context=t,this.container=e,this.headerElement=document.createElement("div"),this.initElement(),this.container.appendChild(this.headerElement)}initElement(){this.headerElement.className="x-gantt-table-header",this.headerElement.style.display="flex",this.headerElement.style.height=`${this.context.getOptions().header.height}px`,this.headerElement.style.minHeight=`${Math.max(this.context.getOptions().header.height,30)}px`,this.headerElement.style.setProperty("background-color",this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,"important"),this.headerElement.style.setProperty("color",this.context.getOptions().header.color,"important"),this.headerElement.style.fontSize=`${this.context.getOptions().header.fontSize}px`,this.headerElement.style.fontWeight=`${this.context.getOptions().header.fontWeight}`,this.headerElement.style.zIndex="10",this.headerElement.style.width="100%",this.headerElement.style.flexShrink="0",this.headerElement.style.borderBottom=`1px solid ${this.context.getOptions().border.color}`,this.headerElement.style.setProperty("border-color",this.context.getOptions().border.color,"important")}render(){this.headerColumns=[],this.headerElement.innerHTML="",this.initElement();const t=this.context.store.getColumnManager(),e=t.getColumns();if(t.getHandlerColumn().width!==0){const i=new j(this.context,this.headerElement,this.headerElement,t.getHandlerColumn());this.headerColumns.push(i)}e.forEach(i=>{if(i.isLeaf){const s=new j(this.context,this.headerElement,this.headerElement,i);this.headerColumns.push(s)}else if(i.children.length>0){const s=new J(this.context,this.headerElement,this.headerElement,i);this.headerColumns.push(s)}})}}class le{constructor(t,e){r(this,"tableContainer");r(this,"tableHeader");r(this,"tableBody");this.context=t,this.container=e,this.tableContainer=document.createElement("div"),this.tableContainer.className="x-gantt-table-container",this.tableContainer.style.position="relative",this.tableContainer.style.width="100%",this.tableContainer.style.height="100%",this.tableContainer.style.overflow="hidden",this.tableContainer.style.display="flex",this.tableContainer.style.flexDirection="column",this.container.appendChild(this.tableContainer),this.tableHeader=new ae(t,this.tableContainer),this.tableBody=new he(t,this.tableContainer),this.listenEvents()}render(t,e){this.tableHeader.render(),this.refresh(t,e)}refresh(t,e){this.context.store.getColumnManager().clearMergeInfo(),this.tableBody.render(t,e)}updateWidth(){this.tableBody.updateWidth()}updateTask(t){this.tableBody.updateTask(t)}listenEvents(){this.context.event.on(y.UPDATE_TABLE_HEADER,()=>{this.tableHeader.render()}),this.context.event.on(y.UPDATE_TABLE_BODY,()=>{this.tableBody.update()})}}class ce{constructor(t,e){r(this,"layer");r(this,"background");r(this,"groupHeader");r(this,"cellHeader");r(this,"cellCache",new Map);r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);this.context=t,this.stage=e,this.layer=new L.Layer,this.stage.add(this.layer),this.background=new L.Rect({fill:this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,name:"header-background"}),this.layer.add(this.background),this.groupHeader=new L.Group({name:"primary-header"}),this.cellHeader=new L.Group({name:"secondary-header"}),this.layer.add(this.groupHeader),this.layer.add(this.cellHeader),this.resize(this.stage.width()),this.registerEvents()}resize(t){this.width=t,this.height=this.context.getOptions().header.height,this.background.width(t),this.background.height(this.height),this.calculateHeader()}setOffset(t,e){this.offsetX!==t&&(this.offsetX=t,this.groupHeader.x(t),this.cellHeader.x(t),this.calculateHeader())}registerEvents(){this.context.event.on(y.ROW_HIGHLIGHT,t=>{this.highlightDate(t)}),this.context.event.on(y.ROW_UNHIGHLIGHT,t=>{this.unhighlightDate(t)}),this.context.event.on(y.UPDATE_TASK,t=>{this.highlightDate(t.id)})}render(){this.calculateHeader(),this.layer.moveToTop(),this.layer.batchDraw()}calculateHeader(){var d;this.clearHeader();const t=this.context.store.getTimeAxis(),e=t.getCellWidth(),i=Math.max(0,-this.offsetX),s=i+this.width,n=Math.floor(this.height/2),o=this.context.getOptions().border.color;this.layer.add(new L.Line({points:[0,n,this.width,n],stroke:o,strokeWidth:1})),this.layer.add(new L.Line({points:[0,this.height,this.width,this.height],stroke:o,strokeWidth:1}));const h=t.getTimeline();let a=0;for(let u=0;u<h.length;u++){const l=h[u],c=e*(((d=l.children)==null?void 0:d.length)??0);if(a+c<i){a+=c;continue}if(a>s)break;const p=this.createCell(`group-${l.date.format("YYYY-MM-DD")}`,a,0,c,n,o,l.label);if(this.groupHeader.add(p),O.isArray(l.children)&&l.children.length>0){let g=a;for(let x=0;x<l.children.length;){const T=l.children[x];let v=1;for(;l.children[x+v]&&T.label===l.children[x+v].label;)v++;if(x+=v,x>=l.children.length&&h[u+1]&&h[u+1].children){let M=0;for(;h[u+1].children[M]&&T.label===h[u+1].children[M].label;)h[u+1].children[M].hide=!0,M++;M>0&&(v+=M)}const b=e*v;if(g+b<i){g+=b;continue}if(g>s)break;const k=this.createCell(`cell-${T.date.format("YYYY-MM-DD")}`,g,n,b,n,T.hide?"transparent":o,T.hide?"":T.label);this.cellHeader.add(k),T.hide&&k.visible(!1),g+=b}}a+=c}this.layer.batchDraw()}createCell(t,e,i,s,n,o,h){const a=new L.Group;a.x(e),a.y(i);const d=new L.Rect({id:t,x:0,y:0,width:s,height:n,fill:this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor,name:"header-cell-bg"});a.add(d);let u=this.context.getOptions().header.fontSize;t.startsWith("cell-")&&(this.cellCache.set(t,d),u-=2);const l=new L.Line({points:[s,0,s,n],stroke:o,strokeWidth:1,name:"header-cell-right-border"});a.add(l);const c=new L.Text({x:0,y:0,width:s,height:n,text:h,fontSize:u,fontFamily:this.context.getOptions().header.fontFamily,fontStyle:`${this.context.getOptions().header.fontWeight}`,fill:this.context.getOptions().header.color,align:"center",verticalAlign:"middle",wrap:"none",ellipsis:!0,name:"header-cell-text"});return a.add(c),a}clearHeader(){this.groupHeader.destroyChildren(),this.cellHeader.destroyChildren(),this.cellCache.clear()}destroy(){this.layer.destroy(),this.cellCache.clear()}highlightDate(t){const e=this.context.store.getDataManager().getTaskById(t);e&&e.startTime&&e.endTime&&this.handleHighlight("in",e)}unhighlightDate(t){const e=this.context.store.getDataManager().getTaskById(t);e&&e.startTime&&e.endTime&&this.handleHighlight("out",e)}handleHighlight(t,e){var o,h;if(!this.context.getOptions().highlight||this.context.getOptions().unit!=="day")return;const i=this.cellCache.get(`cell-${(o=e==null?void 0:e.startTime)==null?void 0:o.format("YYYY-MM-DD")}`),s=this.cellCache.get(`cell-${(h=e==null?void 0:e.endTime)==null?void 0:h.format("YYYY-MM-DD")}`),n=this.context.getOptions().header.backgroundColor||this.context.getOptions().primaryColor;n&&(this.cellCache.forEach(a=>{new L.Tween({node:a,fill:n,duration:.02}).play()}),t==="in"&&(i&&new L.Tween({node:i,fill:$(n).brighten(30).toHex(),duration:.02}).play(),s&&new L.Tween({node:s,fill:$(n).brighten(30).toHex(),duration:0}).play()))}}class de{constructor(t,e){r(this,"verticalLines");r(this,"horizontalLines");r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);this.context=t,this.layer=e,this.verticalLines=new L.Group({name:"vertical-grid-lines"}),this.horizontalLines=new L.Group({name:"horizontal-grid-lines"}),this.layer.add(this.verticalLines),this.layer.add(this.horizontalLines)}resize(t,e){this.width=t,this.height=e,this.clearGrid(),this.calculateGrid()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.verticalLines.x(t),this.horizontalLines.y(e),this.calculateGrid()}render(){this.layer.batchDraw()}destroy(){this.layer.destroy()}calculateGrid(){this.clearGrid();const t=this.context.getOptions().header.height,e=this.width,i=this.context.store.getTimeAxis().getCellWidth(),s=this.context.getOptions().row.height,n=this.context.store.getDataManager().getVisibleSize(),o=n*s,h=Math.max(0,Math.floor(-this.offsetX/i)-2),a=Math.min(this.context.store.getTimeAxis().getCellCount(),Math.ceil((-this.offsetX+this.width)/i)+2),d=Math.max(0,Math.floor((-this.offsetY+t)/s)-2),u=Math.min(n,Math.ceil((-this.offsetY+this.height)/s)+2);if(this.context.getOptions().border.show&&["day","hour"].includes(this.context.getOptions().unit))for(let l=h;l<=a;l++){const c=l*i,m=new L.Line({points:[c,t,c,o+t],stroke:this.context.getOptions().border.color,strokeWidth:.5,name:"vertical-grid-line"});this.verticalLines.add(m)}for(let l=d;l<=u;l++){const c=l*s+t,m=new L.Line({points:[0,c,Math.max(this.width,e),c],stroke:this.context.getOptions().border.color,strokeWidth:.5,name:"horizontal-grid-line"});this.horizontalLines.add(m)}}clearGrid(){this.verticalLines.destroyChildren(),this.horizontalLines.destroyChildren()}}class ue{constructor(t,e,i,s,n){r(this,"offsetX",0);r(this,"offsetY",0);r(this,"sliderGroup");r(this,"slider");r(this,"sliderBg");r(this,"leftHandler",null);r(this,"rightHandler",null);r(this,"progressGroup",null);r(this,"handlerWidth",10);r(this,"autoMoveTimer",null);r(this,"autoScrollTimer",null);r(this,"autoExpandTimer",null);r(this,"EDGE_THRESHOLD",20);r(this,"SCROLL_STEP",5);r(this,"MOVE_INTERVAL",1e3/60);r(this,"AUTO_EXPAND_INTERVAL",500);r(this,"isDragging",!1);r(this,"draggingDirection","none");r(this,"oldTasks",[]);this.context=t,this.x=e,this.y=i,this.task=s,this.rowWidth=n,this.sliderGroup=new L.Group({x:e,y:i,id:`chart-slider-bar-${s.id}`}),this.render(),this.bindEvents()}update(t,e){this.x=t,this.y=e,this.sliderGroup.position({x:t,y:e}),this.render()}setOffset(t,e){this.offsetX=t,this.offsetY=e}updateSize(){const t=this.context.getOptions().row.height,e=st(this.context.getOptions().bar.height,t),i=(t-e)/2,s=this.context.store.getTimeAxis().getTimeLeft(this.task.startTime),o=this.context.store.getTimeAxis().getTimeLeft(this.task.endTime)-s;this.slider.position({x:s,y:i}),this.slider.size({width:o,height:e}),this.sliderBg.size({width:o,height:e}),this.leftHandler,this.rightHandler&&(this.rightHandler.x(o-this.handlerWidth),this.rightHandler.size({width:this.handlerWidth,height:e})),this.renderProgress(o,e),this.renderText(o,e)}render(){var x,T,v,b,E;if(!this.task.startTime||!this.task.endTime)return;const t=this.context.getOptions().row.height,e=st(this.context.getOptions().bar.height,t),i=(t-e)/2,s=this.context.store.getTimeAxis().getTimeLeft(this.task.startTime),o=this.context.store.getTimeAxis().getTimeLeft(this.task.endTime)-s,h=this.context.getOptions().bar.backgroundColor||this.context.getOptions().primaryColor,a=K(this.context.getOptions().bar.radius);this.slider||(this.slider=new L.Group({dragBoundFunc:k=>{let M=0,S=Math.abs(this.rowWidth-this.slider.width());if(this.context.getOptions().bar.move.link.parent==="strict"&&this.task.parent){if(this.task.parent.startTime){const _=this.task.parent.startTime;M=this.context.store.getTimeAxis().getTimeLeft(_)}if(this.task.parent.endTime){const _=this.task.parent.endTime,H=this.context.store.getTimeAxis().getTimeLeft(_);S=Math.abs(H-this.slider.width())}}return{x:A(k.x,M,S),y:this.y+i+this.offsetY}}})),this.slider.position({x:s,y:i}),this.slider.size({width:o,height:e});const d=this.context.getOptions().bar.move.enabled;let u=!1;O.isBoolean(d)?u=d:O.isFunction(d)&&(u=d(this.task.getEmitData())),this.slider.draggable(u),u&&(this.slider.on("pointerover",k=>{this.isDragging||(k.target.getStage().container().style.cursor="grab")}),this.slider.on("pointerout",k=>{this.isDragging||(k.target.getStage().container().style.cursor="default")})),this.sliderBg||(this.sliderBg=new L.Rect({x:0,y:0}),this.slider.add(this.sliderBg)),this.sliderBg.setAttrs({width:o,height:e,fill:h,cornerRadius:a,shadowColor:this.context.getOptions().bar.shadowColor,shadowBlur:this.context.getOptions().bar.shadowBlur,shadowOffsetX:this.context.getOptions().bar.shadowOffsetX,shadowOffsetY:this.context.getOptions().bar.shadowOffsetY}),this.renderProgress(o,e);const l=$(h).brighten(30*((x=this.context.getOptions().bar.progress)!=null&&x.show?-1:1)).toHex(),c=(T=this.context.getOptions().bar.move.single)==null?void 0:T.left;let m=!1;O.isBoolean(c)?m=c:O.isFunction(c)&&(m=c(this.task.getEmitData())),m?(this.leftHandler||(this.leftHandler=new L.Rect({x:0,y:0,opacity:0}),this.slider.add(this.leftHandler),this.leftHandler.on("mousedown",k=>{this.resizeMove(k,"left")}),this.leftHandler.on("pointerover",k=>{setTimeout(()=>{k.target.getStage().container().style.cursor="ew-resize"},0)}),this.leftHandler.on("pointerout",k=>{this.isDragging||(k.target.getStage().container().style.cursor="default")})),this.leftHandler.setAttrs({width:this.handlerWidth,height:e,fill:l,cornerRadius:[a[0],0,0,a[3]]})):this.leftHandler&&(this.leftHandler.remove(),this.leftHandler=null);const p=(v=this.context.getOptions().bar.move.single)==null?void 0:v.right;let g=!1;O.isBoolean(p)?g=p:O.isFunction(p)&&(g=p(this.task.getEmitData())),g?(this.rightHandler||(this.rightHandler=new L.Rect({y:0,opacity:0}),this.slider.add(this.rightHandler),this.rightHandler.on("mousedown",k=>{this.resizeMove(k,"right")}),this.rightHandler.on("pointerover",k=>{setTimeout(()=>{k.target.getStage().container().style.cursor="ew-resize"},0)}),this.rightHandler.on("pointerout",k=>{this.isDragging||(k.target.getStage().container().style.cursor="default")})),this.rightHandler.setAttrs({x:o-this.handlerWidth,width:this.handlerWidth,height:e,fill:l,cornerRadius:[0,a[1],a[2],0]})):this.rightHandler&&(this.rightHandler.remove(),this.rightHandler=null),this.renderText(o,e),this.sliderGroup.add(this.slider),(b=this.leftHandler)==null||b.moveToTop(),(E=this.rightHandler)==null||E.moveToTop()}renderText(t,e){const i=`chart-slider-text-${this.task.id}`,s=()=>{this.slider.find(`#${i}`)&&this.slider.find(`#${i}`).forEach(a=>a.remove())};if(!this.context.getOptions().bar.field&&!this.context.getOptions().bar.label){s();return}const n=this.context.getOptions().bar.label;let o="";n?O.isString(n)?o=n:O.isFunction(n)&&(o=n(this.task.getEmitData())):this.context.getOptions().bar.field&&(o=this.task.getField(this.context.getOptions().bar.field)),s();const h=t-(this.leftHandler?this.handlerWidth:0)-(this.rightHandler?this.handlerWidth:0);if(h>20){const a=new L.Text({id:i,x:this.leftHandler?10:0,y:0,width:h,height:e,padding:10,text:o,fill:this.context.getOptions().bar.color||"#000",fontSize:this.context.getOptions().bar.fontSize||12,fontFamily:this.context.getOptions().bar.fontFamily||"Arial",align:this.context.getOptions().bar.align,verticalAlign:this.context.getOptions().bar.verticalAlign||"middle",ellipsis:!0});this.slider.add(a)}}renderProgress(t,e){var i,s,n,o,h,a,d,u,l,c,m,p,g,x;if(!((i=this.context.getOptions().bar.progress)!=null&&i.show)){this.progressGroup&&(this.progressGroup.destroy(),this.progressGroup=null);return}if(this.task.progress){const T=Mt(this.task.progress,((s=this.context.getOptions().bar.progress)==null?void 0:s.targetVal)??100);if(T===0)return;const v=((n=this.context.getOptions().bar.progress)==null?void 0:n.backgroundColor)||$(this.context.getOptions().bar.backgroundColor||this.context.getOptions().primaryColor).brighten(((o=this.context.getOptions().bar.progress)==null?void 0:o.amount)||30).toHex(),b=K(this.context.getOptions().bar.radius),E=K((h=this.context.getOptions().bar.progress)==null?void 0:h.radius);E[0]=b[0],E[3]=b[3],T===1&&(E[1]=b[1],E[2]=b[2]);const k=t*T;this.progressGroup?(this.progressGroup.width(k),this.progressGroup.destroyChildren()):(this.progressGroup=new L.Group({x:0,y:0,width:k,height:e,listening:!1}),this.slider.add(this.progressGroup));const M=new L.Rect({x:0,y:0,width:k,height:e,fill:v,cornerRadius:E,opacity:(a=this.context.getOptions().bar.progress)==null?void 0:a.opacity});this.progressGroup.add(M);const S=`${Et(T*100,(d=this.context.getOptions().bar.progress)==null?void 0:d.decimal)}%`,w=new L.Text().measureSize(S).width,_=new L.Text({x:0,y:((u=this.context.getOptions().bar.progress)==null?void 0:u.textAlign)==="top"?-e:0,width:((l=this.context.getOptions().bar.progress)==null?void 0:l.textAlign)==="right"?k+w:Math.max(k,w),height:e,fill:((c=this.context.getOptions().bar.progress)==null?void 0:c.color)||$("#000000").mix(v,50).alpha(.7).toHex(),text:S,fontSize:((m=this.context.getOptions().bar.progress)==null?void 0:m.fontSize)||10,fontStyle:((p=this.context.getOptions().bar.progress)==null?void 0:p.fontStyle)||"italic",fontFamily:"Arial",verticalAlign:((g=this.context.getOptions().bar.progress)==null?void 0:g.textAlign)==="top"?"bottom":"middle",align:"right"});(x=this.progressGroup)==null||x.add(_)}}bindEvents(){this.slider&&(this.slider.on("dragstart",t=>this.handleDragStart(t)),this.slider.on("dragend",t=>this.handleDragEnd(t)),this.slider.on("dragmove",t=>this.handleDragMove(t)),this.slider.on("pointerover",()=>this.handleMouseEnter()),this.slider.on("pointerout",()=>this.handleMouseLeave()),this.slider.on("click",t=>{t.evt.button===0&&(t.cancelBubble=!0,this.isDragging=!1,this.context.event.emit(y.SLIDER_CLICK,t.evt,this.task))}),this.slider.on("contextmenu",t=>{t.cancelBubble=!0,t.evt.stopPropagation(),t.evt.preventDefault(),this.context.event.emit(y.SLIDER_CONTEXTMENU,t.evt,this.task)}),this.slider.on("dblclick",t=>{t.evt.button===0&&(t.cancelBubble=!0,this.context.event.emit(y.SLIDER_DBL_CLICK,t.evt,this.task))}))}emitUpdate(t){let e=this.task.startTime.clone(),i=this.task.endTime.clone();t!=="right"&&(e=this.context.store.getTimeAxis().getTimeByLeft(this.slider.x())),t!=="left"&&(i=this.context.store.getTimeAxis().getTimeByLeft(this.slider.x()+this.slider.width())),(!(e!=null&&e.isSame(this.task.startTime))||!(i!=null&&i.isSame(this.task.endTime)))&&this.context.store.getDataManager().updateTaskTime(this.task,e,i,t,this.oldTasks)}handleDragStart(t){const e=t.target.getStage();e&&(this.isDragging=!0,this.oldTasks=[],this.context.event.emit(y.SLIDER_MOVING,!0),e.container().style.cursor="grabbing",this.handleMove(t,e))}handleDragMove(t){if(!this.isDragging)return;if(t.evt.movementX>0?this.draggingDirection="right":t.evt.movementX<0&&(this.draggingDirection="left"),!!this.context.getOptions().bar.move.byUnit){const i=t.target.x(),s=this.context.store.getTimeAxis().getCellWidth(),n=nt(i,s);t.target.x(n)}}handleDragEnd(t){this.stopAutoMove(),this.stopAutoScroll(),this.stopAutoExpand(),this.isDragging=!1,this.draggingDirection="none",t.target.getStage().container().style.cursor="default",this.oldTasks.length>0&&(this.context.event.emit(y.TASK_DRAG_END,this.task,this.oldTasks),this.oldTasks=[]),this.context.event.emit(y.SLIDER_MOVING,!1)}handleMove(t,e){const i=e.width(),s=!!this.context.getOptions().bar.move.lock,n=!!this.context.getOptions().bar.move.byUnit,o=this.context.store.getTimeAxis().getCellWidth();this.autoMoveTimer=window.setInterval(()=>{const h=t.target.width(),a=t.target.x()-this.offsetX,d=a+h,u=-this.offsetX,l=u+i,c=a<=u-this.offsetX+this.EDGE_THRESHOLD,m=d>=l-this.offsetX-this.EDGE_THRESHOLD;if(c)if(u<=0)t.target.x(0),this.stopAutoScroll(),s||(this.draggingDirection==="left"?this.startAutoExpand("left"):this.stopAutoExpand());else if(this.draggingDirection==="left"){const p=n?-o:-this.SCROLL_STEP;this.startAutoScroll(p,n,()=>{t.target.x(t.target.x()+p)})}else this.stopAutoScroll();else if(m)if(l>=this.context.store.getTimeAxis().getTotalWidth())t.target.x(this.context.store.getTimeAxis().getTotalWidth()-h),this.stopAutoScroll(),s||(this.draggingDirection==="right"?this.startAutoExpand("right"):this.stopAutoExpand());else if(this.draggingDirection==="right"){const p=n?o:this.SCROLL_STEP;this.startAutoScroll(p,n,()=>{t.target.x(t.target.x()+p)})}else this.stopAutoScroll();else this.stopAutoExpand(),this.stopAutoScroll();this.emitUpdate("both")},this.MOVE_INTERVAL)}resizeMove(t,e){var x;t.cancelBubble=!0;const i=t.target.getStage();if(!i)return;this.isDragging=!0,this.context.event.emit(y.SLIDER_MOVING,!0);let s=((x=i.getPointerPosition())==null?void 0:x.x)||0;const n=!!this.context.getOptions().bar.move.byUnit,o=this.context.store.getTimeAxis().getCellWidth(),h=!!this.context.getOptions().bar.move.lock,a=i.width();let d=0,u=0;this.autoMoveTimer=window.setInterval(()=>{const T=this.slider.width(),v=this.slider.x(),b=v+T,E=-this.offsetX,k=E+a,M=v<=E+this.EDGE_THRESHOLD,S=b>=k-this.EDGE_THRESHOLD;if(M&&e==="left"){if(E<=0)this.slider.x(0),this.stopAutoScroll(),h||(this.draggingDirection==="left"?this.startAutoExpand("left"):this.stopAutoExpand());else if(this.draggingDirection==="left"){const w=n?-o:-this.SCROLL_STEP;this.startAutoScroll(w,n,()=>{d+=w,this.slider.x(this.slider.x()+w)})}else this.stopAutoScroll();this.emitUpdate("left")}else if(S&&e==="right"){if(k>=this.context.store.getTimeAxis().getTotalWidth())this.slider.width(this.context.store.getTimeAxis().getTotalWidth()-this.slider.x()),this.stopAutoScroll(),h||(this.draggingDirection==="right"?this.startAutoExpand("right"):this.stopAutoExpand());else if(this.draggingDirection==="right"){const w=n?o:this.SCROLL_STEP;this.startAutoScroll(w,n,()=>{u+=w,this.slider.x(this.slider.x()+w)})}else this.stopAutoScroll();this.emitUpdate("right")}else if(e==="right"&&v<=E&&b<=E+this.EDGE_THRESHOLD+o){const w=n?-o:-this.SCROLL_STEP;this.startAutoScroll(w,n,()=>{u+=w,this.slider.width(Math.max(this.slider.width(),o)),this.slider.width()>o&&this.slider.x(this.slider.x()+w),this.emitUpdate("right")})}else if(e==="left"&&b>=k&&v>=k-this.EDGE_THRESHOLD-o){const w=n?o:this.SCROLL_STEP;this.startAutoScroll(w,n,()=>{d+=w,this.slider.width(Math.max(this.slider.width(),o)),this.slider.width()>o&&this.slider.x(this.slider.x()+w),this.emitUpdate("left")})}else this.stopAutoExpand(),this.stopAutoScroll()},this.MOVE_INTERVAL);let l;const c=this.slider.x(),m=this.slider.width(),p=T=>{var E;T.movementX>0?this.draggingDirection="right":T.movementX<0&&(this.draggingDirection="left");const v=Math.max(((E=i.getPointerPosition())==null?void 0:E.x)||0,0);let b=v-s;n&&(b=nt(b,o)),(l===void 0||l!==b)&&(e==="left"?m-b-d>=o&&v<a-this.EDGE_THRESHOLD&&(this.slider.width(m-b-d),this.slider.x(c+b+d),this.emitUpdate("left")):m+b+u>=o&&v>this.EDGE_THRESHOLD&&(this.slider.width(m+b+u),this.emitUpdate("right")),l=b)},g=()=>{this.handleDragEnd(t),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",g)}startAutoExpand(t){if(this.autoExpandTimer)return;const e=this.context.store.getTimeAxis();this.autoExpandTimer=window.setInterval(()=>{e.expand(t,1),this.context.event.emit(y.CHART_OFFSET_CHANGE),t==="left"&&this.slider.x(0)},this.AUTO_EXPAND_INTERVAL)}startAutoScroll(t,e,i){if(this.autoScrollTimer)return;const s=this.context.getScrollbar();s&&(this.autoScrollTimer=window.setInterval(()=>{const n=s.getScrollPosition();s.scrollTo({x:n.x+t,y:n.y},"drag"),i==null||i()},e?300:this.MOVE_INTERVAL))}stopAutoMove(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=null)}stopAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}stopAutoExpand(){this.autoExpandTimer&&(clearInterval(this.autoExpandTimer),this.autoExpandTimer=null)}handleMouseEnter(){this.handleResizeHighlight(1)}handleMouseLeave(){this.handleResizeHighlight(0)}handleResizeHighlight(t){this.leftHandler&&new L.Tween({node:this.leftHandler,opacity:t,duration:.2}).play(),this.rightHandler&&new L.Tween({node:this.rightHandler,opacity:t,duration:.2}).play()}}class ge{constructor(t,e,i,s,n,o,h){r(this,"row");r(this,"slider");r(this,"cacheKey","");this.context=t,this.task=e,this.width=o,this.height=h,this.row=new L.Group;const a=new L.Rect({x:s,y:n,width:o,height:h,id:i,listening:!1});this.row.add(a),this.slider=new ue(this.context,0,n,this.task,this.width),this.row.add(this.slider.sliderGroup)}update(t,e){this.slider.update(t,e)}setOffset(t,e){this.slider.setOffset(t,e)}destroy(){this.row.destroy()}}class fe{constructor(t,e,i,s){r(this,"rowsGroup");r(this,"rowsCache",new Map);r(this,"rowBgGroup");r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);r(this,"highlightedRowId",null);r(this,"highlightRect",null);r(this,"selectedRowId",null);r(this,"selectedRect",null);this.context=t,this.stage=e,this.layer=i,this.bgLayer=s,this.rowsGroup=new L.Group({name:"chart-body-rows"}),this.layer.add(this.rowsGroup),this.rowBgGroup=new L.Group({name:"chart-body-row-bgs"}),this.bgLayer.add(this.rowBgGroup),this.registerEvents(),this.bindEvents()}resize(t,e){this.width=t,this.height=e}setOffset(t,e){const i=e-this.offsetY;this.offsetX=t,this.offsetY=e,this.rowsGroup.x(t),this.rowsGroup.y(e),this.updateHighlightPosition(i),this.updateSelectedPosition(i)}render(t){const e=this.context.getOptions().row.height,i=U();this.rowBgGroup.destroyChildren(),t.forEach((s,n)=>{const o=`chart-row-${s.id}`;let h=this.rowsCache.get(o);const d=s.flatIndex*e+this.context.getOptions().header.height;h?(h.update(0,d),h.setOffset(this.offsetX,this.offsetY)):(h=new ge(this.context,s,o,0,d,this.width,e),h.setOffset(this.offsetX,this.offsetY),this.rowsGroup.add(h.row),this.rowsCache.set(o,h)),h.cacheKey=i,this.context.store.getDataManager().isTaskSelected(s.id)&&this.selectRow(s.id);const u=new L.Rect({x:0,y:d+this.offsetY,width:this.width,height:e,fill:this.context.store.getOptionManager().getRowBackgroundColor(s),id:`chart-row-bg-${s.id}`,listening:!1});this.rowBgGroup.add(u),this.rowBgGroup.moveToBottom()}),this.rowsCache.forEach((s,n)=>{s.cacheKey!==i&&(s.destroy(),this.rowsCache.delete(n))}),this.layer.batchDraw()}updateTask(t){const e=this.rowsCache.get(`chart-row-${t.id}`);e&&e.update(0,t.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height)}bindEvents(){this.stage.on("mousemove",this.handleMouseMove.bind(this)),this.stage.on("mouseleave",this.handleMouseLeave.bind(this)),this.stage.on("click",this.handleClick.bind(this)),this.stage.on("dblclick",this.handleDblClick.bind(this)),this.stage.on("contextmenu",this.handleContextMenu.bind(this))}registerEvents(){this.context.event.on(y.ROW_HIGHLIGHT,t=>{this.highlightRow(t)}),this.context.event.on(y.ROW_UNHIGHLIGHT,t=>{this.unhighlightRow(t)}),this.context.event.on(y.TASK_SELECTED,t=>{this.selectRow(t.id)}),this.context.event.on(y.TASK_UNSELECTED,t=>{this.unselectRow(t)})}handleMouseMove(t){const e=this.stage.getPointerPosition();if(!e)return;const i=this.getTaskByPosition(e);this.highlightedRowId&&i&&i.id!==this.highlightedRowId&&this.context.event.emit(y.ROW_UNHIGHLIGHT,this.highlightedRowId),i&&this.context.event.emit(y.ROW_HIGHLIGHT,i.id)}handleMouseLeave(t){this.unhighlightRow()}handleClick(t){if(t.evt.button!==0)return;const e=this.stage.getPointerPosition();if(!e)return;const i=this.getTaskByPosition(e);if(i){if(this.context.store.getDataManager().isTaskSelected(i.id))return;this.context.store.getDataManager().selectTask(i.id),this.context.event.emit(y.ROW_CLICK,t.evt,i)}}handleDblClick(t){if(t.evt.button!==0)return;const e=this.stage.getPointerPosition();if(!e)return;const i=this.getTaskByPosition(e);i&&this.context.event.emit(y.ROW_DBL_CLICK,t.evt,i)}handleContextMenu(t){if(t.evt.button!==2)return;t.evt.preventDefault(),t.cancelBubble=!0;const e=this.stage.getPointerPosition();if(!e)return;const i=this.getTaskByPosition(e);i&&this.context.event.emit(y.ROW_CONTEXTMENU,t.evt,i)}getTaskByPosition(t){const e=this.context.getOptions().header.height;if(t.y<=e)return null;const i=t.y-this.offsetY,s=Math.floor((i-e)/this.context.getOptions().row.height);return this.context.store.getDataManager().getVisibleTasks()[s]||null}highlightRow(t){if(this.highlightedRowId===t)return;this.highlightedRowId=t;const e=this.rowsCache.get(`chart-row-${t}`);if(!e)return;this.highlightRect&&this.highlightRect.destroy();const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.selectedRowId!==t&&(this.highlightRect=new L.Rect({x:0,y:s+this.offsetY,width:this.width,height:this.context.getOptions().row.height,fill:$(this.context.getOptions().row.hover.backgroundColor).alpha(this.context.getOptions().row.hover.opacity).toHex(),name:"highlight-rect"}),this.layer.add(this.highlightRect),this.highlightRect.moveToBottom(),this.layer.batchDraw())}unhighlightRow(t){this.highlightedRowId===t&&(this.highlightedRowId=null,this.highlightRect&&(this.highlightRect.destroy(),this.highlightRect=null,this.layer.batchDraw()))}updateHighlightPosition(t){if(!this.highlightRect||this.highlightedRowId===null)return;const e=this.rowsCache.get(`chart-row-${this.highlightedRowId}`);if(!e){this.clearHighlight();return}if(t)this.highlightRect.y(this.highlightRect.y()+t);else{const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.highlightRect.y(s+this.offsetY)}this.layer.batchDraw()}clearHighlight(){this.highlightRect&&(this.highlightRect.destroy(),this.highlightRect=null),this.highlightedRowId=null}selectRow(t){var n;this.selectedRowId=t;const e=this.rowsCache.get(`chart-row-${t}`);if(!e)return;this.selectedRect&&this.selectedRect.destroy(),this.selectedRowId===this.highlightedRowId&&((n=this.highlightRect)==null||n.fill("transparent"));const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.selectedRect=new L.Rect({x:0,y:s+this.offsetY,width:this.width,height:this.context.getOptions().row.height,fill:$(this.context.getOptions().row.select.backgroundColor).alpha(this.context.getOptions().row.select.opacity).toHex(),name:"selected-rect"}),this.layer.add(this.selectedRect),this.selectedRect.moveToBottom(),this.layer.batchDraw()}unselectRow(t){this.selectedRowId===t&&(this.selectedRowId=null,this.selectedRect&&(this.selectedRect.destroy(),this.selectedRect=null,this.layer.batchDraw()))}updateSelectedPosition(t){if(!this.selectedRect||this.selectedRowId===null)return;const e=this.rowsCache.get(`chart-row-${this.selectedRowId}`);if(e)if(this.context.store.getDataManager().isTaskVisible(e.task)){const s=e.task.flatIndex*this.context.getOptions().row.height+this.context.getOptions().header.height;this.selectedRect.y(s+this.offsetY),this.layer.batchDraw()}else this.selectedRect.destroy(),this.selectedRect=null,this.selectedRowId=null}destroy(){this.rowsCache.clear(),this.rowsGroup.destroy(),this.rowBgGroup.destroy()}}class Tt{constructor(){}static async createPattern(t){if(!(t!=null&&t.pattern))return null;const e=t.patternOptions||{};switch(e.color=e.color||t.backgroundColor,t.pattern){case"stripe":return this.createStripePattern(e);case"dot":return this.createDotPattern(e);case"grid":return this.createGridPattern(e);case"custom":if(e.image){const i=new Image;return i.src=e.image,new Promise(s=>{i.onload=()=>s(i)})}return null;default:return null}}static createStripePattern(t){const{color:e=(t==null?void 0:t.color)||"#c9c9c9",width:i=(t==null?void 0:t.width)||1,angle:s=(t==null?void 0:t.angle)??30,spacing:n=(t==null?void 0:t.spacing)||10}=t||{},o=s%180,h=o*Math.PI/180;let a,d;o===0?(a=n,d=i+n):o===90?(a=i+n,d=n):(a=Math.abs(Math.ceil((i+n)/Math.sin(h))),d=Math.abs(Math.ceil((i+n)/Math.cos(h))));const u=new L.Stage({container:document.createElement("div"),width:a,height:d}),l=new L.Layer;u.add(l);const c=new L.Group;if(o===0||o===90){const p=new L.Line({points:[0,0,o===0?a:0,o===0?0:d],stroke:e,strokeWidth:i,perfectDrawEnabled:!0});c.add(p)}else for(let p=-a;p<a*2;p+=a){const g=p+i/2,x=0,T=p+i/2+(Math.cos(h)<0?-a:a),v=d,b=new L.Line({points:[Math.ceil(g),Math.ceil(x),Math.ceil(T),Math.ceil(v)],stroke:e,strokeWidth:i,perfectDrawEnabled:!0,lineCap:"square",lineJoin:"miter"});c.add(b)}l.add(c),l.draw();const m=new Image;return m.src=u.toDataURL(),u.destroy(),m}static createDotPattern(t){const{color:e=(t==null?void 0:t.color)||"#f9f9f9",width:i=(t==null?void 0:t.width)||2,spacing:s=(t==null?void 0:t.spacing)||4}=t||{},n=i*2+s*2,o=n,h=$(e),a=new L.Stage({container:document.createElement("div"),width:n,height:o}),d=new L.Layer;a.add(d),[{x:s/2+i/2,y:s/2+i/2},{x:n-s/2-i/2,y:s/2+i/2},{x:s/2+i/2,y:o-s/2-i/2},{x:n-s/2-i/2,y:o-s/2-i/2}].forEach(c=>{const m=new L.Circle({x:c.x,y:c.y,radius:i/2,fill:h.toString()});d.add(m)}),d.draw();const l=new Image;return l.src=a.toDataURL(),a.destroy(),l}static createGridPattern(t){const{color:e=(t==null?void 0:t.color)||"#f9f9f9",width:i=(t==null?void 0:t.width)||1,spacing:s=(t==null?void 0:t.spacing)||20}=t||{},n=i+s,o=n,h=n,a=new L.Stage({container:document.createElement("div"),width:o,height:h}),d=new L.Layer;a.add(d);const u=new L.Group;u.add(new L.Line({points:[0,0,o,h],stroke:e,strokeWidth:i,perfectDrawEnabled:!0})),u.add(new L.Line({points:[0,h,o,0],stroke:e,strokeWidth:i,perfectDrawEnabled:!0})),d.add(u),d.draw();const l=new Image;return l.src=a.toDataURL(),a.destroy(),l}}class me{constructor(t,e){r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);r(this,"weekendGroup");r(this,"patternImage",null);this.context=t,this.layer=e,this.weekendGroup=new L.Group,this.layer.add(this.weekendGroup)}isWeekend(t){return t.day()===6||t.day()===0}resize(t,e){this.width=t,this.height=e,this.calculateWeekend()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.weekendGroup.x(t),this.weekendGroup.y(e),this.calculateWeekend()}render(){this.layer.batchDraw()}destroy(){this.weekendGroup.destroy(),this.patternImage=null}clearWeekend(){this.weekendGroup.destroyChildren(),this.patternImage=null}async calculateWeekend(){if(this.clearWeekend(),!this.context.getOptions().weekend.show)return;const t=this.context.store.getTimeAxis().getStartTime(),e=this.context.store.getTimeAxis().getEndTime(),i=this.context.store.getTimeAxis().getCellUnit(),s=this.context.store.getTimeAxis().getCellWidth(),n=this.context.getOptions().header.height,o=this.context.getOptions().row.height,a=this.context.store.getDataManager().getVisibleSize()*o,d=Math.max(0,-this.offsetX),u=d+this.width;for(let l=t;l<=e;){let c=s;if(c=s*2*(i==="day"?1:24),this.isWeekend(l)){const m=this.context.store.getTimeAxis().getTimeLeft(l),p=n,g=a;if(m+c<d){l=l.add(2,"day");continue}if(m>u)break;!this.patternImage&&this.context.getOptions().weekend.pattern&&(this.patternImage=await Tt.createPattern(this.context.getOptions().weekend));const T=new L.Rect({name:"weekend-rect",x:m,y:p,width:c,height:g,...this.patternImage?{fillPatternImage:this.patternImage,fillPatternRepeat:"repeat",fillPatternOffset:{x:0,y:0},fillPatternScale:{x:1,y:1}}:{fill:this.context.getOptions().weekend.backgroundColor||"#c9c9c9"},opacity:this.context.getOptions().weekend.opacity});this.weekendGroup.add(T),l=l.add(2,"day")}else l=l.add(1,"day")}this.layer.batchDraw()}}class pe{constructor(t,e,i){r(this,"arrowAnimation");r(this,"todayLine");r(this,"triangle");r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);this.context=t,this.bgLayer=e,this.headerLayer=i}resize(t,e){this.width=t,this.height=e,this.render()}setOffset(t,e){t!==this.offsetX&&(this.offsetX=t,this.render())}render(){const t=Object.assign({show:!0,type:"line",backgroundColor:$("lightblue").toHex(),opacity:1,width:1},this.context.getOptions().today||{});if(!t.show)return;let e=D();const i=this.context.store.getTimeAxis().getCellUnit();t.type==="block"&&(e=e.startOf(i));const s=this.context.store.getTimeAxis().getTimeLeft(e),n=this.context.store.getTimeAxis().getCellWidth(),o=this.context.getOptions().header.height,h=$(t.backgroundColor).alpha(t.opacity).toHex(),a=(t.type==="block"?s+n/2:s)+this.offsetX,d=[a,o,a,this.height],u=t.type==="line"?t.width:n;this.todayLine?(this.todayLine.points(d),this.todayLine.stroke(h),this.todayLine.strokeWidth(u)):(this.todayLine=new L.Line({points:d,stroke:h,strokeWidth:u}),this.bgLayer.add(this.todayLine)),t.type==="line"&&(this.triangle?(this.triangle.x(a),this.triangle.fill(h)):(this.triangle=new L.RegularPolygon({x:a,y:o-8,sides:3,radius:8,fill:h,rotation:180,name:"today-triangle"}),this.arrowAnimation=new L.Animation(l=>{var m;const c=Math.sin(l.time*4*Math.PI/2e3)+o-8;(m=this.triangle)==null||m.y(c)},this.headerLayer),this.headerLayer.add(this.triangle),this.triangle.moveToTop(),this.arrowAnimation.start())),this.bgLayer.batchDraw()}destroy(){var t,e,i;(t=this.todayLine)==null||t.destroy(),(e=this.triangle)==null||e.destroy(),(i=this.arrowAnimation)==null||i.stop(),this.arrowAnimation=void 0}}class xe{constructor(t,e){r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);r(this,"holidayGroup");r(this,"patternImage",new WeakMap);this.context=t,this.layer=e,this.holidayGroup=new L.Group,this.layer.add(this.holidayGroup)}resize(t,e){this.width=t,this.height=e,this.calculateHoliday()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.holidayGroup.x(t),this.holidayGroup.y(e),this.calculateHoliday()}render(){this.layer.batchDraw()}destroy(){this.holidayGroup.destroy()}clearHoliday(){this.holidayGroup.destroyChildren()}async calculateHoliday(){if(this.clearHoliday(),!this.context.getOptions().holiday.show)return;const t=this.context.getOptions().holiday.holidays;if(!t||t.length===0)return;const e=Math.max(0,-this.offsetX),i=e+this.width,s=this.context.store.getTimeAxis().getStartTime(),n=this.context.store.getTimeAxis().getEndTime();this.context.store.getTimeAxis().getCellUnit();const o=this.context.store.getTimeAxis().getCellWidth(),h=this.context.getOptions().header.height,a=this.context.getOptions().row.height,u=this.context.store.getDataManager().getVisibleSize()*a;for(let l=s;l<=n;l=l.add(1,"day")){const c=t.find(m=>{if(O.isArray(m.date)){if(m.date.some(p=>D(p).isSame(l,"day")))return m}else if(D(m.date).isSame(l,"day"))return m});if(c){const m=this.context.store.getTimeAxis().getTimeLeft(l),p=h,g=u;if(m+o<e)continue;if(m>i)break;!this.patternImage.has(c)&&(c.pattern||this.context.getOptions().holiday.pattern)&&this.patternImage.set(c,await Tt.createPattern({backgroundColor:this.context.getOptions().primaryColor,...c,...this.context.getOptions().holiday}));const T=new L.Rect({name:"holiday-rect",x:m,y:p,width:o,height:g,...this.patternImage.get(c)?{fillPatternImage:this.patternImage.get(c)??void 0,fillPatternRepeat:"repeat",fillPatternOffset:{x:0,y:0},fillPatternScale:{x:1,y:1},opacity:c.opacity||this.context.getOptions().holiday.opacity}:{fill:c.backgroundColor||this.context.getOptions().holiday.backgroundColor||this.context.getOptions().primaryColor,opacity:c.opacity||this.context.getOptions().holiday.opacity}});this.holidayGroup.add(T)}}this.layer.batchDraw()}}class ye{constructor(t,e,i){r(this,"tasks",[]);r(this,"pointGroup");r(this,"linksGroup");r(this,"templateArrow");r(this,"isDragging",!1);r(this,"isSliderMoving",!1);r(this,"selectedMap",new Map);r(this,"width",0);r(this,"height",0);r(this,"offsetX",0);r(this,"offsetY",0);this.context=t,this.stage=e,this.layer=i,this.linksGroup=new L.Group({name:"links-group"}),this.pointGroup=new L.Group({name:"point-group"}),this.templateArrow=new L.Arrow({points:[],stroke:this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:this.context.getOptions().links.width,pointerLength:this.context.getOptions().links.arrow.height,pointerWidth:this.context.getOptions().links.arrow.width,fill:this.context.getOptions().links.arrow.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:this.context.getOptions().links.dash,opacity:.4}),this.templateArrow.visible(!1),this.layer.add(this.linksGroup),this.layer.add(this.pointGroup),this.layer.add(this.templateArrow),this.registerEvents()}registerEvents(){this.context.event.on(y.ROW_HIGHLIGHT,t=>{this.highlightPoint(t)}),this.context.event.on(y.ROW_UNHIGHLIGHT,t=>{this.unhighlightPoint(t)}),this.context.event.on(y.SLIDER_MOVING,t=>{this.isSliderMoving=t})}resize(t,e){this.width=t,this.height=e,this.calculateLinks(),this.calculatePoints()}setOffset(t,e){this.offsetX=t,this.offsetY=e,this.linksGroup.x(t),this.linksGroup.y(e),this.pointGroup.x(t),this.pointGroup.y(e),this.templateArrow.x(t),this.templateArrow.y(e),this.calculateLinks(),this.calculatePoints()}update(){this.calculateLinks(),this.calculatePoints()}render(t){this.tasks=t,this.layer.batchDraw()}destroy(){this.linksGroup.destroy(),this.pointGroup.destroy(),this.templateArrow.destroy(),this.selectedMap.clear()}calculatePoints(){if(this.pointGroup.destroyChildren(),!this.context.getOptions().links.create.enabled)return;const t=this.context.getOptions().header.height,e=this.context.getOptions().row.height,i=e/2+t,s=this.context.getOptions().links.gap,n=this.context.getOptions().links.create.radius,o=this.context.getOptions().links.create.mode==="always"?.5:0,h=this.context.getOptions().links.create.color||this.context.getOptions().primaryColor,a=$(h).alpha(this.context.getOptions().links.create.opacity??1).toHex(),d=this.context.getOptions().links.create.width;this.tasks.forEach(u=>{if(this.context.store.getDataManager().isTaskVisible(u)&&u.startTime&&u.endTime){const l=this.context.store.getTimeAxis().getTimeLeft(u.startTime),c=this.context.store.getTimeAxis().getTimeLeft(u.endTime),m=i+e*u.flatIndex;let p=!0,g=!0,x=this.context.getOptions().links.create.from;if(O.isFunction(x)&&(x=x(u.getEmitData())),O.isBoolean(x)?p=g=x:O.isString(x)&&(p=x==="S",g=x==="F"),p){const T=new L.Circle({id:`point-${u.id}-left`,x:l-s,y:m,radius:n,opacity:o,stroke:a,strokeWidth:d});this.pointGroup.add(T),T.on("mousedown",v=>{this.isDragging=!0,this.createLink(v,"S",h,[l-s,m],u.id)}),T.on("mouseover",v=>{this.isSliderMoving||(this.stage.container().style.cursor="pointer")}),T.on("mouseout",v=>{this.isDragging||this.isSliderMoving||(this.stage.container().style.cursor="default")})}if(g){const T=new L.Circle({id:`point-${u.id}-right`,x:c+s,y:m,radius:n,opacity:o,stroke:a,strokeWidth:d});this.pointGroup.add(T),T.on("mousedown",v=>{this.isDragging=!0,this.createLink(v,"F",h,[c+s,m],u.id)}),T.on("mouseover",v=>{this.isSliderMoving||(this.stage.container().style.cursor="pointer")}),T.on("mouseout",v=>{this.isDragging||this.isSliderMoving||(this.stage.container().style.cursor="default")})}}})}calculateLinks(){if(this.linksGroup.destroyChildren(),!this.context.getOptions().links.show)return;const t=this.context.getOptions().links.data,e=[];t.forEach(i=>{const s=this.createId(i);this.selectedMap.has(s)&&e.push(s)}),this.selectedMap.forEach((i,s)=>{e.includes(s)||this.selectedMap.delete(s)}),t.forEach(i=>{var o,h,a;const s=this.context.store.getDataManager().getTaskById(i.from),n=this.context.store.getDataManager().getTaskById(i.to);if(s||C.warn(`No corresponding FROM task [${i.from}] was found for the link. Info:`,i),n||C.warn(`No corresponding TO task [${i.to}] was found for the link. Info:`,i),s&&this.context.store.getDataManager().isTaskVisible(s)&&s.startTime&&s.endTime&&n&&this.context.store.getDataManager().isTaskVisible(n)&&n.startTime&&n.endTime){const d=this.context.store.getTimeAxis().getTimeLeft(s.startTime),u=this.context.store.getTimeAxis().getTimeLeft(s.endTime),l=this.context.store.getTimeAxis().getTimeLeft(n.startTime),c=this.context.store.getTimeAxis().getTimeLeft(n.endTime);let m=[];switch(i.type||"FS"){case"FF":m=this.createFF(i,s,n,d,u,l,c);break;case"SS":m=this.createSS(i,s,n,d,u,l,c);break;case"SF":m=this.createSF(i,s,n,d,u,l,c);break;case"FS":default:m=this.createFS(i,s,n,d,u,l,c)}if(m.length<=2)C.warn("The link position has some error.",i);else{const g=this.createId(i),x=i.radius??this.context.getOptions().links.radius,T=((o=i.arrow)==null?void 0:o.width)??this.context.getOptions().links.arrow.width,v=((h=i.arrow)==null?void 0:h.height)??this.context.getOptions().links.arrow.height,b=i.width??this.context.getOptions().links.width,E=new L.Group({id:g}),k=new L.Circle({radius:x,fill:i.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,x:m[0],y:m[1]});E.add(k),k.on("mousedown",S=>{this.handleDrag(S,i,"S",[m[m.length-2],m[m.length-1]],g)});const M=new L.Arrow({points:m,stroke:i.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:b,pointerLength:v,pointerWidth:T,fill:((a=i.arrow)==null?void 0:a.color)||this.context.getOptions().links.arrow.color||i.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:i.data||this.context.getOptions().links.dash,hitStrokeWidth:10});E.add(M),M.on("mousedown",S=>{this.handleDrag(S,i,"F",[m[0],m[1]],g)}),this.linksGroup.add(E),E.on("mouseover",S=>{S.target.moveToTop(),this.stage.container().style.cursor="pointer",this.selectedMap.has(g)||this.handleHighlight(E,x,T,v,b,2)}),E.on("mouseout",S=>{this.selectedMap.has(g)||this.handleHighlight(E,x,T,v,b,0),!this.isDragging&&(this.stage.container().style.cursor="default")}),E.on("mousedown",S=>{this.isDragging=!0}),E.on("click",S=>{S.cancelBubble=!0,this.isDragging=!1,S.target.moveToTop(),this.selectedMap.has(g)?(this.selectedMap.delete(g),this.context.event.emit(y.SELECT_LINK,null,i,this.selectedMap.values().toArray())):(this.selectedMap.set(g,i),this.context.event.emit(y.SELECT_LINK,i,null,this.selectedMap.values().toArray()))}),this.selectedMap.has(g)&&this.handleHighlight(E,x,T,v,b,2,!0)}}})}createId(t){return`link-group-${t[this.context.getOptions().links.key]}-${t.from}-${t.to}-${t.type||"FS"}`}createFS(t,e,i,s,n,o,h){const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=t.gap||this.context.getOptions().links.gap,c=[n+l,u+d*e.flatIndex];{const m=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(m))C.error("Link's distance must be a Numeric");else{const p=n+l+m,g=o-l-m,x=[Math.max(p,g),u+d*e.flatIndex];c.push(...x);const T=d*e.flatIndex+a+(e.flatIndex<=i.flatIndex?d:0);c.push(x[0],T),c.push(g,T),c.push(g,u+d*i.flatIndex)}}return c.push(o-l,u+d*i.flatIndex),c}createFF(t,e,i,s,n,o,h){const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=t.gap||this.context.getOptions().links.gap,c=[n+l,u+d*e.flatIndex];{const m=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(m))C.error("Link's distance must be a Numeric");else{const p=n+l+m,g=h+l+m,x=[p<=g?g:p,u+d*e.flatIndex];c.push(...x),c.push(Math.max(g,p),u+d*i.flatIndex)}}return c.push(h+l,u+d*i.flatIndex),c}createSS(t,e,i,s,n,o,h){const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=t.gap||this.context.getOptions().links.gap,c=[s-l,u+d*e.flatIndex];{const m=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(m))C.error("Link's distance must be a Numeric");else{const p=s-l-m,g=o-l-m;c.push(Math.min(g,p),u+d*e.flatIndex),c.push(Math.min(g,p),u+d*i.flatIndex)}}return c.push(o-l,u+d*i.flatIndex),c}createSF(t,e,i,s,n,o,h){const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=t.gap||this.context.getOptions().links.gap,c=[s-l,u+d*e.flatIndex];{const m=t.distance?parseInt(t.distance):this.context.getOptions().links.distance;if(isNaN(m))C.error("Link's distance must be a Numeric");else{const p=s-l-m,g=h+l+m,x=[Math.min(p,g),u+d*e.flatIndex];c.push(...x);const T=d*e.flatIndex+a+(e.flatIndex<=i.flatIndex?d:0);c.push(x[0],T),c.push(g,T),c.push(g,u+d*i.flatIndex)}}return c.push(h+l,u+d*i.flatIndex),c}handleDrag(t,e,i,s,n){var g,x,T;if(!this.isDragging)return;this.stage.container().style.cursor="pointer";const o=this.linksGroup.findOne(`#${n}`);this.templateArrow.setAttrs({stroke:e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,strokeWidth:e.width??this.context.getOptions().links.width,pointerLength:((g=e.arrow)==null?void 0:g.height)??this.context.getOptions().links.arrow.height,pointerWidth:((x=e.arrow)==null?void 0:x.width)??this.context.getOptions().links.arrow.width,fill:((T=e.arrow)==null?void 0:T.color)||this.context.getOptions().links.arrow.color||e.color||this.context.getOptions().links.color||this.context.getOptions().primaryColor,lineJoin:"round",dash:e.data||this.context.getOptions().links.dash}),this.templateArrow.visible(!1);let h=null;const a=this.context.getOptions().header.height,d=this.context.getOptions().row.height,u=d/2+a,l=e.gap||this.context.getOptions().links.gap;let c=null;const m=()=>{const v=this.stage.getPointerPosition();if(!v||(c=this.getTaskByPosition(v),!c))return;const{allowLeft:b,allowRight:E}=this.isAllowDrop(c,e.from);if(this.templateArrow.visible(!0),o==null||o.visible(!1),c!=null&&c.startTime&&(c!=null&&c.endTime)){const k=this.context.store.getTimeAxis().getTimeLeft(c.startTime),M=this.context.store.getTimeAxis().getTimeLeft(c.endTime),S=(M+k)/2+this.offsetX;let w=k-l;v.x<=S?h="S":(h="F",w=M+l),i==="S"?(this.templateArrow.points([w,u+d*c.flatIndex,...s]),E?this.stage.container().style.cursor="pointer":this.stage.container().style.cursor="not-allowed"):i==="F"&&(this.templateArrow.points([...s,w,u+d*c.flatIndex]),b?this.stage.container().style.cursor="pointer":this.stage.container().style.cursor="not-allowed")}},p=()=>{var E,k;let v;const b=O.cloneDeep(e);if(h&&c&&(i==="S"?(v=`${h}${(e.type||"FS")[1]}`,b.from=c.id):i==="F"&&(v=`${(e.type||"FS")[0]}${h}`,b.to=c.id)),v&&c&&!(b.from===b.to&&["FF","SS"].includes(v))){const{allowLeft:M,allowRight:S}=this.isAllowDrop(c,b.from);b.type=v,((E=b.type)==null?void 0:E.slice(1))==="S"&&M||((k=b.type)==null?void 0:k.slice(1))==="F"&&S?this.context.event.emit(y.UPDATE_LINK,b):(this.context.event.emit(y.ERROR,N.LINK_NOT_ALLOWED),this.calculateLinks())}else this.context.event.emit(y.ERROR,N.LINK_SAME),this.calculateLinks();this.templateArrow.visible(!1),this.stage.container().style.cursor="default",this.isDragging=!1,document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",p)}createLink(t,e,i,s,n){this.stage.container().style.cursor="pointer",this.templateArrow.setAttrs({points:[],stroke:i,strokeWidth:this.context.getOptions().links.width,pointerLength:this.context.getOptions().links.arrow.height,pointerWidth:this.context.getOptions().links.arrow.width,fill:i,dash:this.context.getOptions().links.dash}),this.templateArrow.visible(!1);let o=null;const h=this.context.getOptions().header.height,a=this.context.getOptions().row.height,d=a/2+h,u=this.context.getOptions().links.gap;let l=null;const c=()=>{const p=this.stage.getPointerPosition();if(!p||(l=this.getTaskByPosition(p),!l))return;const{allowLeft:g,allowRight:x}=this.isAllowDrop(l,n);if(this.templateArrow.visible(!0),l.startTime&&l.endTime){const T=this.context.store.getTimeAxis().getTimeLeft(l.startTime),v=this.context.store.getTimeAxis().getTimeLeft(l.endTime),b=(v+T)/2+this.offsetX;let E=T-u;p.x<=b?o="S":(o="F",E=v+u),this.templateArrow.points([...s,E,d+a*l.flatIndex]),o==="S"&&!g?this.stage.container().style.cursor="not-allowed":o==="F"&&!x?this.stage.container().style.cursor="not-allowed":this.stage.container().style.cursor="pointer"}},m=()=>{let p;if(o&&(p=`${e}${o}`),p&&l)if(this.context.getOptions().links.data.some(g=>g.from===n&&g.to===l.id&&g.type===p))this.context.event.emit(y.ERROR,N.LINK_EXIST);else if(n===l.id&&e===o)this.context.event.emit(y.ERROR,N.LINK_SAME);else{const{allowLeft:g,allowRight:x}=this.isAllowDrop(l,n);o==="S"&&g||o==="F"&&x?this.context.event.emit(y.CREATE_LINK,{from:n,to:l.id,type:p,color:i}):this.context.event.emit(y.ERROR,N.LINK_NOT_ALLOWED)}this.templateArrow.visible(!1),this.stage.container().style.cursor="default",this.isDragging=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",m)}getTaskByPosition(t){const e=this.context.getOptions().header.height;if(t.y<=e)return null;const i=t.y-this.offsetY,s=Math.floor((i-e)/this.context.getOptions().row.height);return this.context.store.getDataManager().getVisibleTasks()[s]||null}isAllowDrop(t,e){let i=!0,s=!0,n=this.context.getOptions().links.create.to;return O.isFunction(n)&&(n=n(t.getEmitData(),this.context.store.getDataManager().getTaskById(e).getEmitData())),O.isBoolean(n)?i=s=n:O.isString(n)&&(i=n==="S",s=n==="F"),{allowLeft:i,allowRight:s}}handleHighlight(t,e,i,s,n,o,h=!1){const a=t.findOne("Circle"),d=t.findOne("Arrow");a&&new L.Tween({node:a,radius:e+o,duration:h?0:.1}).play(),d&&new L.Tween({node:d,pointerWidth:i+o,pointerLength:s+o,strokeWidth:n+o,duration:h?0:.1}).play()}highlightPoint(t){this.handlePointHighlight(t,1)}unhighlightPoint(t){const e=this.context.getOptions().links.create.mode==="always"?.5:0;this.handlePointHighlight(t,e)}handlePointHighlight(t,e){const i=this.pointGroup.findOne(`#point-${t}-left`),s=this.pointGroup.findOne(`#point-${t}-right`);i&&new L.Tween({node:i,opacity:e,duration:.1}).play(),s&&new L.Tween({node:s,opacity:e,duration:.1}).play()}}class we{constructor(t,e){r(this,"stage");r(this,"headerLayer");r(this,"bodyGroup");r(this,"gridGroup");r(this,"weekendGroup");r(this,"holidayGroup");r(this,"todayLayer");r(this,"linkGroup");r(this,"bgLayer");r(this,"bodyLayer");r(this,"width",0);r(this,"height",0);this.context=t,this.container=e,this.stage=new L.Stage({container:this.container,width:this.container.clientWidth,height:this.container.clientHeight}),this.bgLayer=new L.Layer,this.weekendGroup=new me(this.context,this.bgLayer),this.holidayGroup=new xe(this.context,this.bgLayer),this.gridGroup=new de(this.context,this.bgLayer),this.stage.add(this.bgLayer),this.headerLayer=new ce(this.context,this.stage),this.todayLayer=new pe(this.context,this.bgLayer,this.headerLayer.layer),this.bodyLayer=new L.Layer,this.linkGroup=new ye(this.context,this.stage,this.bodyLayer),this.bodyGroup=new fe(this.context,this.stage,this.bodyLayer,this.bgLayer),this.stage.add(this.bodyLayer)}resize(t,e){this.width=t,this.height=e,this.context.store.getTimeAxis().setAllWidth(t),this.stage.width(t),this.stage.height(e),this.headerLayer.resize(t),this.gridGroup.resize(t,e),this.linkGroup.resize(t,e),this.holidayGroup.resize(t,e),this.weekendGroup.resize(t,e),this.bodyGroup.resize(t,e),this.todayLayer.resize(t,e)}render(t,e,i){this.headerLayer.setOffset(-t,0),this.gridGroup.setOffset(-t,-e),this.linkGroup.setOffset(-t,-e),this.weekendGroup.setOffset(-t,-e),this.holidayGroup.setOffset(-t,-e),this.bodyGroup.setOffset(-t,-e),this.todayLayer.setOffset(-t,-e),this.gridGroup.render(),this.holidayGroup.render(),this.weekendGroup.render(),this.linkGroup.render(i),this.bodyGroup.render(i),this.headerLayer.render(),this.todayLayer.render()}refresh(t,e,i){this.render(t,e,i)}updateTask(t){this.bodyGroup.updateTask(t),this.linkGroup.update()}destroy(){this.headerLayer.destroy(),this.gridGroup.destroy(),this.bodyLayer.destroy(),this.todayLayer.destroy(),this.holidayGroup.destroy(),this.weekendGroup.destroy(),this.linkGroup.destroy(),this.bgLayer.destroy(),this.stage.destroy()}}class be{constructor(t,e){r(this,"line");r(this,"initialX",0);r(this,"initialWidth",0);this.root=t,this.container=e,this.line=document.createElement("div"),this.line.className="x-gantt-middle-resize-line",this.line.style.position="absolute",this.line.style.zIndex="99",this.line.style.width="5px",this.line.style.height="100%",this.line.style.borderLeft="2px solid",this.line.style.setProperty("border-left-color",this.root.store.getOptionManager().getOptions().border.color,"important"),this.line.style.cursor="col-resize",this.container.appendChild(this.line),this.addDragEvents()}setOffset(t){this.line.style.left=`${t-2}px`,this.initialX=t}addDragEvents(){let t=0,e=null;const i=this.root.store.getColumnManager(),s=i.getLeafColumns(),n=a=>{a.preventDefault(),a.stopPropagation(),t=a.clientX,e=this.container.getBoundingClientRect();const d=s[s.length-1].key;this.initialWidth=i.getColumnWidth(d);const u=parseInt(this.line.style.left)+2;this.root.event.emit(y.SHOW_GUIDELINE,u);const l=m=>o(m),c=m=>h(m,l,c);document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)},o=a=>{if(a.preventDefault(),!e)return;const d=a.clientX-t;s[s.length-1].key;const u=50-this.initialWidth,c=e.width-20-this.initialX,m=Math.max(u,Math.min(c,d)),p=this.initialX+m;this.root.event.emit(y.MOVE_GUIDELINE,p)},h=(a,d,u)=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",u),this.root.event.emit(y.HIDE_GUIDELINE);const l=a.clientX-t,c=s[s.length-1].key,m=Math.max(50,this.initialWidth+l);i.setColumnWidth(c,m),this.root.event.emit(y.UPDATE_TABLE_HEADER)};this.line.addEventListener("mousedown",n)}}class Te{constructor(t,e){r(this,"element");r(this,"container");r(this,"visible",!1);if(this.context=t,!e)throw new Error("Container is required for GuideLine instance");this.container=e,this.element=document.createElement("div"),this.initElement(),this.initEvents()}initElement(){this.element.className="x-gantt-guide-line",this.element.style.position="absolute",this.element.style.top="0",this.element.style.left="0",this.element.style.width="0",this.element.style.height="100%",this.element.style.setProperty("border-left",`1px dashed ${this.context.getOptions().border.color}`,"important"),this.element.style.zIndex="9999",this.element.style.pointerEvents="none",this.element.style.display="none",this.element.style.transform="translateX(-0.5px)",getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.appendChild(this.element)}initEvents(){this.context.event.on(y.SHOW_GUIDELINE,t=>{this.show(t)}),this.context.event.on(y.HIDE_GUIDELINE,()=>{this.hide()}),this.context.event.on(y.MOVE_GUIDELINE,t=>{this.setLeft(t)})}setContainer(t){this.element.parentElement&&this.element.parentElement.removeChild(this.element),this.container=t,getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.appendChild(this.element)}setLeft(t){const e=this.container.clientWidth,i=Math.max(0,Math.min(e-20,t));this.element.style.left=`${i}px`}show(t){t!==void 0&&this.setLeft(t),this.element.style.display="block",this.visible=!0}hide(){this.element.style.display="none",this.visible=!1}isVisible(){return this.visible}getLeft(){return this.element.offsetLeft}}class Se{constructor(t=16){r(this,"taskQueue",new Map);r(this,"taskHandlers",new Map);r(this,"isScheduled",!1);r(this,"delay");r(this,"debouncedFlush");this.delay=t,this.debouncedFlush=O.debounce(()=>{this.flushTaskQueue()},t)}registerHandler(t,e){this.taskHandlers.set(t,e),C.debug(`RenderScheduler: 注册任务处理器 ${t}`)}registerSimpleHandler(t,e,i=!1){this.registerHandler(t,{callback:e,immediate:i})}scheduleTask(t,e=[],i={}){const s=this.taskHandlers.get(t);if(!s){C.warn(`RenderScheduler: 未找到任务类型 ${t} 的处理器`);return}const n={type:t,refresh:i.refresh,callback:s.callback,args:e,immediate:i.immediate??s.immediate??!1};if(n.immediate){C.debug(`RenderScheduler: 立即执行任务 ${t}`),this.executeTask(n);return}this.taskQueue.set(t,n),C.debug(`RenderScheduler: 添加任务到队列 ${t}`),this.debouncedFlush()}immediateExecuteTask(t,e=[],i=!1){const s=this.taskHandlers.get(t);if(!s){C.warn(`RenderScheduler: 未找到任务类型 ${t} 的处理器`);return}C.debug(`RenderScheduler: 立即执行任务 ${t}`);const n={type:t,refresh:i,callback:s.callback,args:e,immediate:!0};this.executeTask(n)}immediateFlushAll(){C.debug("RenderScheduler: 立即执行所有队列任务"),this.cancelScheduled(),this.flushTaskQueue()}executeTask(t){try{t.callback(...t.args||[])}catch(e){C.error(`RenderScheduler: 执行任务 ${t.type} 时出错:`,e)}}flushTaskQueue(){if(this.taskQueue.size===0)return;C.debug(`RenderScheduler: 执行任务队列,任务数量: ${this.taskQueue.size}`);const t=Array.from(this.taskQueue.values()).sort((e,i)=>e.immediate!==i.immediate?e.immediate?-1:1:e.refresh!==i.refresh?e.refresh?-1:1:0);this.taskQueue.clear(),this.isScheduled=!1;for(const e of t)this.executeTask(e)}cancelScheduled(){this.debouncedFlush.cancel(),this.taskQueue.clear(),this.isScheduled=!1}unregisterHandler(t){this.taskHandlers.delete(t),this.taskQueue.delete(t),C.debug(`RenderScheduler: 移除任务处理器 ${t}`)}getQueueSize(){return this.taskQueue.size}getRegisteredHandlers(){return Array.from(this.taskHandlers.keys())}destroy(){this.cancelScheduled(),this.taskHandlers.clear(),C.debug("RenderScheduler: 已销毁")}}class ve{constructor(t,e){r(this,"scrollbar");r(this,"rootElement");r(this,"tableContainer");r(this,"chartContainer");r(this,"table");r(this,"chart");r(this,"middleLine");r(this,"renderScheduler");r(this,"_id",U());r(this,"width",0);r(this,"height",0);r(this,"isInitialized",!0);r(this,"updateSize",()=>{this.width=this.context.store.getOptionManager().getOptions().width||this.container.clientWidth,this.height=this.context.store.getOptionManager().getOptions().height||this.container.clientHeight,this.rootElement.style.width=this.width?`${this.width}px`:"100%",this.rootElement.style.height=this.height?`${this.height}px`:"100%";const t=this.context.store.getColumnManager().getTotalWidth();this.tableContainer.style.width=`${t}px`,this.tableContainer.style.height=this.height?`${this.height}px`:"100%";const e=this.width-t;this.chartContainer.style.width=`${e}px`,this.chartContainer.style.height=this.height?`${this.height}px`:"100%",this.chart.resize(e,this.height),this.middleLine.setOffset(t);const i=this.context.store.getTimeAxis().getTotalWidth();this.scrollbar.updateSize(e,this.height,i,this.context.store.getDataManager().getVisibleSize()*this.context.store.getOptionManager().getOptions().row.height+this.context.store.getOptionManager().getOptions().header.height,t)});r(this,"setStyleValue",()=>{const t=this.context.store.getOptionManager().getOptions();this.rootElement.style.setProperty("--x-gantt-primary-color",`${t.primaryColor}`),this.rootElement.style.setProperty("--x-gantt-border-color",`${t.border.color}`),this.rootElement.style.setProperty("--x-gantt-row-hover-color",`${$(t.row.hover.backgroundColor).alpha(t.row.hover.opacity)}`),this.rootElement.style.setProperty("--x-gantt-row-selected-color",`${$(t.row.select.backgroundColor).alpha(t.row.select.opacity)}`),this.rootElement.style.setProperty("--x-gantt-header-font-weight",`${t.header.fontWeight}`)});r(this,"handleUpdateTask",t=>{this.table.updateTask(t),this.chart.updateTask(t)});r(this,"handleColumnWidthChange",()=>{this.table.updateWidth(),this.updateSize()});this.context=t,this.container=e,this.rootElement=document.createElement("div"),this.rootElement.id=`x-gantt-${this._id}`,this.rootElement.className="x-gantt",this.rootElement.style.overflow="hidden",this.rootElement.style.display="flex",this.rootElement.style.position="relative",this.container.appendChild(this.rootElement),this.tableContainer=document.createElement("div"),this.tableContainer.className="x-gantt-table",this.rootElement.appendChild(this.tableContainer),new Te(this.context,this.container),this.middleLine=new be(this.context,this.rootElement),this.chartContainer=document.createElement("div"),this.chartContainer.className="x-gantt-chart",this.rootElement.appendChild(this.chartContainer),this.table=new le(this.context,this.tableContainer),this.chart=new we(this.context,this.chartContainer),this.scrollbar=new re(this.context,this.rootElement,this.context.store.getOptionManager().getOptions().scrollbar||{}),this.renderScheduler=new Se(16),this.setupTaskHandlers(),this.updateSize(),this.setupEventListeners()}getScrollbar(){return this.scrollbar}setupTaskHandlers(){this.renderScheduler.registerSimpleHandler("DATA_UPDATE",(t=!0)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("VIEW_UPDATE",(t=!0)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("MANUAL_RENDER",(t=!1)=>this.performRender(t)),this.renderScheduler.registerSimpleHandler("SCROLL",(t=!0)=>this.performRender(t),!0),this.renderScheduler.registerSimpleHandler("UPDATE_TASK",t=>this.handleUpdateTask(t)),this.renderScheduler.registerSimpleHandler("COLUMN_WIDTH_CHANGE",()=>this.handleColumnWidthChange()),this.renderScheduler.registerSimpleHandler("CHART_OFFSET_CHANGE",(t=!1)=>this.performRender(t))}setupEventListeners(){this.context.event.on(y.DATA_UPDATE,()=>{this.renderScheduler.scheduleTask("DATA_UPDATE",[!0])}),this.context.event.on(y.SCROLL,()=>{this.renderScheduler.scheduleTask("SCROLL",[!0],{immediate:!0})}),this.context.event.on(y.COLUMN_WIDTH_CHANGE,()=>{this.renderScheduler.scheduleTask("COLUMN_WIDTH_CHANGE")}),this.context.event.on(y.VIEW_UPDATE,()=>{this.renderScheduler.scheduleTask("VIEW_UPDATE",[!0])}),this.context.event.on(y.UPDATE_TASK,t=>{this.renderScheduler.scheduleTask("UPDATE_TASK",[t],{immediate:!0})}),this.context.event.on(y.CHART_OFFSET_CHANGE,()=>{this.renderScheduler.scheduleTask("CHART_OFFSET_CHANGE",[!1])})}performRender(t=!1){this.setStyleValue();const{x:e,y:i}=this.scrollbar.getScrollPosition(),s=this.context.store.getOptionManager().getOptions().row.height,n=this.context.store.getOptionManager().getOptions().header.height,o=Math.floor(i/s),h=Math.ceil((this.height-n)/s),a=2,d=Math.max(0,o),u=h+a,l=this.context.store.getDataManager().getVisibleTasks().slice(d,d+u);t?(this.table.refresh(i,l),this.chart.refresh(e,i,l)):(this.table.render(i,l),this.chart.render(e,i,l)),this.updateSize(),this.isInitialized&&(this.context.event.emit(y.LOADED),this.isInitialized=!1),C.debug("execute render")}render(t=!1){this.renderScheduler.scheduleTask("MANUAL_RENDER",[t])}immediateRender(t=!1){this.renderScheduler.immediateExecuteTask("MANUAL_RENDER",[t],t)}destroy(){C.debug("Renderer destroy"),this.renderScheduler.destroy(),this.scrollbar.destroy(),this.context.event.offAll()}}class Le{constructor(t,e,i){r(this,"_id",U());r(this,"store");r(this,"event",new Lt);r(this,"renderer");this.container=t,this.events=e,this.container.innerHTML="",this.store=new oe(this,i),this.renderer=new ve(this,this.container),this.render(),this.registerEvents(),C.debug("----Gantt initialized for element:",this._id,this.container)}getScrollbar(){var t;return(t=this.renderer)==null?void 0:t.getScrollbar()}getOptions(){return this.store.getOptionManager().getOptions()}setOptions(t,e){this.store.setOption(t,e)}render(){this.renderer.render()}updateOptions(t,e){this.setOptions(t,e),C.debug("GanttChart options updated"),this.render()}destroy(){C.debug("Gantt destroying..."),this.event.offAll(),this.renderer.destroy(),this.container.innerHTML=""}jumpTo(t){const e=D(t);if(!this.store.getTimeAxis().isInTimeAxis(e))return!1;const i=this.store.getTimeAxis().getTimeLeft(e)-100;return this.renderer.getScrollbar().scrollTo({x:Math.max(i,0)}),!0}_emit(t,...e){var i;this.events.has(t)&&((i=this.events.get(t))==null||i.forEach(s=>s(...e)))}registerEvents(){this.event.on(y.ERROR,t=>{this._emit("error",t)}),this.event.on(y.LOADED,()=>{this._emit("loaded")}),this.event.on(y.TASK_DRAG_END,(t,e)=>{this._emit("move",e.map(i=>{var s;return{row:(s=this.store.getDataManager().getTaskById(i.id))==null?void 0:s.data,old:i.data}}))}),this.event.on(y.CHECK_TASK,(t,e)=>{this._emit("select",t.map(i=>i.data),e,this.store.getDataManager().getCheckedList().map(i=>i.data))}),this.event.on(y.UPDATE_LINK,t=>{this._emit("update:link",t)}),this.event.on(y.CREATE_LINK,t=>{this._emit("create:link",t)}),this.event.on(y.SELECT_LINK,(t,e,i)=>{this._emit("select:link",t,e,i)}),this.event.on(y.ROW_CLICK,(t,e)=>{this._emit("click:row",t,e.data)}),this.event.on(y.ROW_DBL_CLICK,(t,e)=>{this._emit("dblclick:row",t,e.data)}),this.event.on(y.ROW_CONTEXTMENU,(t,e)=>{this._emit("contextmenu:row",t,e.data)}),this.event.on(y.SLIDER_CLICK,(t,e)=>{this._emit("click:slider",t,e.data)}),this.event.on(y.SLIDER_DBL_CLICK,(t,e)=>{this._emit("dblclick:slider",t,e.data)}),this.event.on(y.SLIDER_CONTEXTMENU,(t,e)=>{this._emit("contextmenu:slider",t,e.data)})}}class ke{constructor(t,e){r(this,"context");r(this,"events",new Map);e!=null&&e.logLevel&&C.setOptions({showTimestamp:e.logLevel==="debug",level:{debug:1,info:2,warn:3,error:4,none:5}[e.logLevel]||2});const i=typeof t=="string"?document.querySelector(t):t;if(!i)throw C.exception(`Container ${t} not found or invalid.`);i.innerHTML="",i.classList.add("x-gantt-container"),this.context=new Le(i,this.events,e)}update(t,e={merge:!0}){this.context.updateOptions(t,e)}render(){this.context.render(),C.info("Gantt rendered successfully.")}destroy(){C.info("Gantt destroying..."),this.events.clear(),this.context.destroy(),C.info("Gantt destroyed successfully.")}jumpTo(t){return this.context.jumpTo(t)}on(t,e){var i;this.events.has(t)||this.events.set(t,[]),(i=this.events.get(t))==null||i.push(e)}}St();const Me=it;R.dayjs=D,R.XGantt=ke,R.colorjs=$,R.generateId=U,R.version=Me,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
|