UNPKG

@svar-ui/react-gantt

Version:

A customizable, high-performance React Gantt chart component for building project timelines.

2 lines (1 loc) 44.1 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),e=require("react"),oe=require("@svar-ui/react-core"),Ee=require("@svar-ui/gantt-locales"),ze=require("@svar-ui/lib-state"),ae=require("@svar-ui/gantt-store"),M=require("@svar-ui/lib-react"),Ie=require("@svar-ui/grid-store"),xe=require("@svar-ui/lib-dom"),He=require("@svar-ui/react-grid"),Le=require("@svar-ui/react-toolbar"),Pe=require("@svar-ui/react-menu"),We=require("@svar-ui/core-locales"),ve=require("@svar-ui/react-editor"),Ce=e.createContext(null);function Re(t){const s=t.getAttribute("data-id"),n=parseInt(s);return isNaN(n)||n.toString()!=s?s:n}function _e(t,s,n){const r=t.getBoundingClientRect(),a=s.querySelector(".wx-body").getBoundingClientRect();return{top:r.top-a.top,left:r.left-a.left,dt:r.bottom-n.clientY,db:n.clientY-r.top}}function $e(t){return t&&t.getAttribute("data-context-id")}const Ne=5;function Oe(t,s){let n,r,a,R,w,i,m,$,p;function W(h){R=h.clientX,w=h.clientY,i={..._e(n,t,h),y:s.getTask(a).$y},document.body.style.userSelect="none"}function g(h){n=xe.locate(h),$e(n)&&(a=Re(n),p=setTimeout(()=>{$=!0,s&&s.touchStart&&s.touchStart(),W(h.touches[0])},500),t.addEventListener("touchmove",O),t.addEventListener("contextmenu",u),window.addEventListener("touchend",G))}function u(h){if($||p)return h.preventDefault(),!1}function S(h){h.which===1&&(n=xe.locate(h),$e(n)&&(a=Re(n),t.addEventListener("mousemove",N),window.addEventListener("mouseup",f),W(h)))}function v(h){t.removeEventListener("mousemove",N),t.removeEventListener("touchmove",O),document.body.removeEventListener("mouseup",f),document.body.removeEventListener("touchend",G),document.body.style.userSelect="",h&&(t.removeEventListener("mousedown",S),t.removeEventListener("touchstart",g))}function I(h){const F=h.clientX-R,P=h.clientY-w;if(!r){if(Math.abs(F)<Ne&&Math.abs(P)<Ne||s&&s.start&&s.start({id:a,e:h})===!1)return;r=n.cloneNode(!0),r.style.pointerEvents="none",r.classList.add("wx-reorder-task"),r.style.position="absolute",r.style.left=i.left+"px",r.style.top=i.top+"px",n.style.visibility="hidden",n.parentNode.insertBefore(r,n)}if(r){const q=Math.round(Math.max(0,i.top+P));if(s&&s.move&&s.move({id:a,top:q,detail:m})===!1)return;const U=s.getTask(a),D=U.$y;if(!i.start&&i.y==D)return E();i.start=!0,i.y=U.$y-4,r.style.top=q+"px";const y=document.elementFromPoint(h.clientX,h.clientY),H=xe.locate(y);if(H&&H!==n){const k=Re(H),C=H.getBoundingClientRect(),V=C.top+C.height/2,d=h.clientY+i.db>V&&H.nextElementSibling!==n,L=h.clientY-i.dt<V&&H.previousElementSibling!==n;m?.after==k||m?.before==k?m=null:d?m={id:a,after:k}:L&&(m={id:a,before:k})}}}function N(h){I(h)}function O(h){$?(h.preventDefault(),I(h.touches[0])):p&&(clearTimeout(p),p=null)}function G(){$=null,p&&(clearTimeout(p),p=null),E()}function f(){E()}function E(){n&&(n.style.visibility=""),r&&(r.parentNode.removeChild(r),s&&s.end&&s.end({id:a,top:i.top})),a=n=r=i=m=null,v()}return t.style.position!=="absolute"&&(t.style.position="relative"),t.addEventListener("mousedown",S),t.addEventListener("touchstart",g),{destroy(){v(!0)}}}function Fe({row:t,column:s}){function n(a,R){return{justifyContent:R.align,paddingLeft:`${(a.$level-1)*20}px`}}const r=s&&s._cell;return c.jsxs("div",{className:"wx-pqc08MHU wx-content",style:n(t,s),children:[t.data||t.lazy?c.jsx("i",{className:`wx-pqc08MHU wx-toggle-icon wxi-menu-${t.open?"down":"right"}`,"data-action":"open-task"}):c.jsx("i",{className:"wx-pqc08MHU wx-toggle-placeholder"}),c.jsx("div",{className:"wx-pqc08MHU wx-text",children:r?c.jsx(r,{row:t,column:s}):t.text})]})}function De({column:t,cell:s}){const n=e.useMemo(()=>t.id,[t?.id]);return s||t.id=="add-task"?c.jsx("div",{style:{textAlign:t.align},children:c.jsx("i",{className:"wx-9DAESAHW wx-action-icon wxi-plus","data-action":n})}):null}function Ke(t){const{readonly:s,compactMode:n,width:r=0,display:a="all",columnWidth:R=0,onTableAPIChange:w}=t,[i,m]=M.useWritableProp(R),[$,p]=e.useState(),W=e.useContext(oe.context.i18n),g=e.useMemo(()=>W.getGroup("gantt"),[W]),u=e.useContext(Ce),S=M.useStore(u,"scrollTop"),v=M.useStore(u,"cellHeight"),I=M.useStore(u,"_scrollTask"),N=M.useStore(u,"_selected"),O=M.useStore(u,"area"),G=M.useStore(u,"_tasks"),f=M.useStore(u,"_scales"),E=M.useStore(u,"columns"),h=M.useStore(u,"_sort"),F=M.useStore(u,"durationUnit"),P=e.useRef(null),q=e.useRef(!0),[U,D]=e.useState(null),y=e.useMemo(()=>!G||!O?[]:G.slice(O.start,O.end),[G,O]),H=e.useCallback((o,x)=>{if(x==="add-task")u.exec(x,{target:o,task:{text:g("New Task")},mode:"child",show:!0});else if(x==="open-task"){const b=y.find(z=>z.id===o);(b?.data||b?.lazy)&&u.exec(x,{id:o,mode:!b.open})}},[y]),k=e.useCallback(o=>{const x=xe.locateID(o),b=o.target.dataset.action;b&&o.preventDefault(),x?b==="add-task"||b==="open-task"?H(x,b):u.exec("select-task",{id:x,toggle:o.ctrlKey||o.metaKey,range:o.shiftKey,show:!0}):b==="add-task"&&H(null,b)},[u,H]),C=e.useRef(null),V=e.useRef(null),[d,L]=e.useState(0),[Z,Y]=e.useState(!1);e.useEffect(()=>{const o=V.current;if(!o||typeof ResizeObserver>"u")return;const x=()=>L(o.clientWidth);x();const b=new ResizeObserver(x);return b.observe(o),()=>b.disconnect()},[]);const Q=e.useRef(null),se=e.useCallback(o=>{const x=o.id,{before:b,after:z}=o,te=o.onMove;let ee=b||z,fe=b?"before":"after";if(te){if(fe==="after"){const ke=u.getTask(ee);ke.data?.length&&ke.open&&(fe="before",ee=ke.data[0].id)}Q.current={id:x,[fe]:ee}}else Q.current=null;u.exec("move-task",{id:x,mode:fe,target:ee,inProgress:te})},[u]),ce=e.useMemo(()=>O?.from??0,[O]),pe=e.useMemo(()=>f?.height??0,[f]),A=e.useMemo(()=>!n&&a!=="grid"?(i??0)>(r??0):(i??0)>(d??0),[n,a,i,r,d]),ne=e.useMemo(()=>{const o={};return A&&a==="all"||a==="grid"&&A?o.width=i:a==="grid"&&(o.width="100%"),o},[A,a,i]),ue=e.useMemo(()=>U&&!y.find(o=>o.id===U.id)?[...y,U]:y,[y,U]),T=e.useMemo(()=>{let o=(E||[]).map(z=>{z={...z};const te=z.header;if(typeof te=="object"){const ee=te.text&&g(te.text);z.header={...te,text:ee}}else z.header=g(te);return z});const x=o.findIndex(z=>z.id==="text"),b=o.findIndex(z=>z.id==="add-task");if(x!==-1&&(o[x].cell&&(o[x]._cell=o[x].cell),o[x].cell=Fe),b!==-1){o[b].cell=o[b].cell||De;const z=o[b].header;if(typeof z!="object"&&(o[b].header={text:z}),o[b].header.cell=z.cell||De,s)o.splice(b,1);else if(n){const[te]=o.splice(b,1);o.unshift(te)}}return o.length>0&&(o[o.length-1].resize=!1),o},[E,g,s,n]),K=e.useMemo(()=>a==="all"?`${r}px`:a==="grid"?"calc(100% - 4px)":T.find(o=>o.id==="add-task")?"50px":"0",[a,r,T]),re=e.useMemo(()=>{if(ue&&h?.length){const o={};return h.forEach(({key:x,order:b},z)=>{o[x]={order:b,...h.length>1&&{index:z}}}),o}return{}},[ue,h]),le=e.useCallback(()=>T.some(o=>o.flexgrow&&!o.hidden),[]),B=e.useMemo(()=>le(),[le,Z]),he=e.useMemo(()=>{let o=a==="chart"?T.filter(b=>b.id==="add-task"):T;const x=a==="all"?r:d;if(!B){let b=i,z=!1;if(T.some(te=>te.$width)){let te=0;b=T.reduce((ee,fe)=>(fe.hidden||(te+=fe.width,ee+=fe.$width||fe.width),ee),0),te>b&&b>x&&(z=!0)}if(z||b<x){let te=1;return z||(te=(x-50)/(b-50||1)),o.map(ee=>(ee.id!=="add-task"&&!ee.hidden&&(ee.$width||(ee.$width=ee.width),ee.width=ee.$width*te),ee))}}return o},[a,T,B,i,r,d]),we=e.useCallback(o=>{if(!le()){const x=he.reduce((b,z)=>(o&&z.$width&&(z.$width=z.width),b+(z.hidden?0:z.width)),0);x!==i&&m(x)}Y(!0),Y(!1)},[le,he,i,m]),ye=e.useCallback(()=>{T.filter(x=>x.flexgrow&&!x.hidden).length===1&&T.forEach(x=>{x.$width&&!x.flexgrow&&!x.hidden&&(x.width=x.$width)})},[]),Te=e.useCallback(o=>{if(!s){const x=xe.locateID(o),b=xe.locateAttr(o,"data-col-id");!(b&&T.find(te=>te.id==b))?.editor&&x&&u.exec("show-editor",{id:x})}},[u,s]),l=e.useCallback(()=>{q.current=!1},[]),j=e.useCallback(o=>{q.current=!0,P.current=o.touches[0].clientY+(S??0)},[S]),X=e.useCallback(o=>{if(q.current){const x=(P.current??0)-o.touches[0].clientY;return u.exec("scroll-chart",{top:x}),o.preventDefault(),!1}},[u]),_=e.useMemo(()=>Array.isArray(N)?N.map(o=>o.id):[],[N]);e.useEffect(()=>{const o=()=>l();return window.addEventListener("touchend",o),()=>window.removeEventListener("touchend",o)},[l]);const J=e.useCallback(()=>{if(C.current&&ue!==null){const o=C.current.querySelector(".wx-body");o&&(o.style.top=-((S??0)-(ce??0))+"px")}V.current&&(V.current.scrollTop=0)},[ue,S,ce]);e.useEffect(()=>{C.current&&J()},[S,ce,J]),e.useEffect(()=>{const o=C.current;if(!o)return;const x=o.querySelector(".wx-table-box .wx-body");if(!x||typeof ResizeObserver>"u")return;const b=new ResizeObserver(()=>{J()});return b.observe(x),()=>{b.disconnect()}},[he,ne,a,K,ue,J]),e.useEffect(()=>{if(!I||!$)return;const{id:o}=I,x=$.getState().focusCell;x&&x.row!==o&&C.current&&C.current.contains(document.activeElement)&&$.exec("focus-cell",{row:o,column:x.column})},[I,$]);const de=e.useCallback(({id:o})=>{if(s)return!1;u.getTask(o).open&&u.exec("open-task",{id:o,mode:!1});const x=u.getState()._tasks.find(b=>b.id===o);if(D(x||null),!x)return!1},[u,s]),me=e.useCallback(({id:o,top:x})=>{Q.current?se({...Q.current,onMove:!1}):u.exec("drag-task",{id:o,top:x+(ce??0),inProgress:!1}),D(null)},[u,se,ce]),ge=e.useCallback(({id:o,top:x,detail:b})=>{b&&se({...b,onMove:!0}),u.exec("drag-task",{id:o,top:x+(ce??0),inProgress:!0})},[u,se,ce]);e.useEffect(()=>{const o=C.current;return o?Oe(o,{start:de,touchStart:l,end:me,move:ge,getTask:u.getTask}).destroy:void 0},[u,de,l,me,ge]);const be=e.useCallback(o=>{const{key:x,isInput:b}=o;if(!b&&(x==="arrowup"||x==="arrowdown"))return o.eventSource="grid",u.exec("hotkey",o),!1;if(x==="enter"){const z=$?.getState().focusCell;if(z){const{row:te,column:ee}=z;ee==="add-task"?H(te,"add-task"):ee==="text"&&H(te,"open-task")}}},[u,H,$]),ie=e.useRef(null),Se=()=>{ie.current={setTableAPI:p,handleHotkey:be,sortVal:h,api:u,adjustColumns:ye,setColumnWidth:we,tasks:y,durationUnitVal:F,onTableAPIChange:w}};Se(),e.useEffect(()=>{Se()},[p,be,h,u,ye,we,y,F,w]);const je=e.useCallback(o=>{p(o),o.intercept("hotkey",x=>ie.current.handleHotkey(x)),o.intercept("scroll",()=>!1),o.intercept("select-row",()=>!1),o.intercept("sort-rows",x=>{const b=ie.current.sortVal,{key:z,add:te}=x,ee=b?b.find(ke=>ke.key===z):null;let fe="asc";return ee&&(fe=!ee||ee.order==="asc"?"desc":"asc"),u.exec("sort-tasks",{key:z,order:fe,add:te}),!1}),o.on("resize-column",()=>{ie.current.setColumnWidth(!0)}),o.on("hide-column",x=>{x.mode||ie.current.adjustColumns(),ie.current.setColumnWidth()}),o.intercept("update-cell",x=>{const{id:b,column:z,value:te}=x,ee=ie.current.tasks.find(fe=>fe.id===b);if(ee){const fe={...ee};let ke=te;ke&&!isNaN(ke)&&!(ke instanceof Date)&&(ke*=1),fe[z]=ke,ae.normalizeDates(fe,ie.current.durationUnitVal,!0,z),u.exec("update-task",{id:b,task:fe})}return!1}),w&&w(o)},[]);return c.jsx("div",{className:"wx-rHj6070p wx-table-container",style:{flex:`0 0 ${K}`},ref:V,children:c.jsx("div",{ref:C,style:ne,className:"wx-rHj6070p wx-table",onTouchStart:j,onTouchMove:X,onClick:k,onDoubleClick:Te,children:c.jsx(He.Grid,{init:je,sizes:{rowHeight:v,headerHeight:(pe??0)-1},rowStyle:o=>o.$reorder?"wx-rHj6070p wx-reorder-task":"wx-rHj6070p",columnStyle:o=>`wx-rHj6070p wx-text-${o.align}${o.id==="add-task"?" wx-action":""}`,data:ue,columns:he,selectedRows:[..._],sortMarks:re})})})}function Ve({borders:t=""}){const s=e.useContext(Ce),n=M.useStore(s,"cellWidth"),r=M.useStore(s,"cellHeight"),a=e.useRef(null),[R,w]=e.useState("#e4e4e4");e.useEffect(()=>{if(typeof getComputedStyle<"u"&&a.current){const m=getComputedStyle(a.current).getPropertyValue("--wx-gantt-border");w(m?m.substring(m.indexOf("#")):"#1d1e261a")}},[]);const i={width:"100%",height:"100%",background:n!=null&&r!=null?`url(${ae.grid(n,r,R,t)})`:void 0,position:"absolute"};return c.jsx("div",{ref:a,style:i})}function qe(t){const{readonly:s,taskTemplate:n}=t,r=e.useContext(Ce),[a,R]=M.useStoreWithCounter(r,"_tasks"),[w,i]=M.useStoreWithCounter(r,"_links"),m=M.useStore(r,"area"),$=M.useStore(r,"_scales"),p=M.useStore(r,"taskTypes"),W=M.useStore(r,"baselines"),g=M.useStore(r,"_selected"),u=M.useStore(r,"_scrollTask"),S=e.useMemo(()=>{if(!m||!Array.isArray(a))return[];const l=m.start??0,j=m.end??0;return a.slice(l,j).map(X=>({...X}))},[R,m]),v=e.useMemo(()=>$.lengthUnitWidth,[$]),I=e.useRef(!1),[N,O]=e.useState(void 0),[G,f]=e.useState(null),E=e.useRef(null),[h,F]=e.useState(void 0),P=e.useRef(null),[q,U]=e.useState(0),D=e.useRef(null),y=e.useMemo(()=>{const l=D.current;return!!(g.length&&l&&l.contains(document.activeElement))},[g,D.current]),H=e.useMemo(()=>y&&g[g.length-1]?.id,[y,g]);e.useEffect(()=>{if(u&&y&&u){const{id:l}=u,j=D.current?.querySelector(`.wx-bar[data-id='${l}']`);j&&j.focus({preventScroll:!0})}},[u]),e.useEffect(()=>{const l=D.current;if(l&&(U(l.offsetWidth||0),typeof ResizeObserver<"u")){const j=new ResizeObserver(X=>{X[0]&&U(X[0].contentRect.width)});return j.observe(l),()=>j.disconnect()}},[D.current]);const k=e.useCallback(()=>{document.body.style.userSelect="none"},[]),C=e.useCallback(()=>{document.body.style.userSelect=""},[]),V=e.useCallback((l,j,X)=>{if(X||(X=r.getTask(Re(l))),X.type==="milestone"||X.type=="summary")return"";const _=l.getBoundingClientRect(),J=(j.clientX-_.left)/_.width;let de=.2/(_.width>200?_.width/200:1);return J<de?"start":J>1-de?"end":""},[r]),d=e.useCallback((l,j)=>{const{clientX:X}=j,_=Re(l),J=r.getTask(_),de=j.target.classList;if(!s){if(de.contains("wx-progress-marker")){const{progress:me}=r.getTask(_);E.current={id:_,x:X,progress:me,dx:0,node:l,marker:j.target},j.target.classList.add("wx-progress-in-drag")}else{const me=V(l,j,J)||"move";f({id:_,mode:me,x:X,dx:0,l:J.$x,w:J.$w})}k()}},[r,s,V,k]),L=e.useCallback(l=>{if(l.button!==0)return;const j=xe.locate(l);j&&d(j,l)},[s,v,q,G,N]),Z=e.useCallback(l=>{const j=xe.locate(l);j&&(P.current=setTimeout(()=>{F(!0),d(j,l.touches[0])},300))},[s]),Y=e.useCallback(()=>{if(E.current){const{dx:l,id:j,marker:X,value:_}=E.current;E.current=null,typeof _<"u"&&l&&r.exec("update-task",{id:j,task:{progress:_}}),X.classList.remove("wx-progress-in-drag"),I.current=!0,C()}else if(G){const{id:l,mode:j,dx:X,l:_,w:J,start:de}=G;if(f(null),de){const me=Math.round(X/v);if(!me)r.exec("drag-task",{id:l,width:J,left:_,inProgress:!1});else{let ge={},be=r.getTask(l);j=="move"?(ge.start=be.start,ge.end=be.end):ge[j]=be[j],r.exec("update-task",{id:l,task:ge,diff:me})}I.current=!0}C()}},[r,C,G,v]),Q=e.useCallback((l,j)=>{const{clientX:X}=j;if(!s)if(E.current){const{node:_,x:J,id:de}=E.current,me=E.current.dx=X-J,ge=Math.round(me/_.offsetWidth*100);let be=E.current.progress+ge;E.current.value=be=Math.min(Math.max(0,be),100),r.exec("update-task",{id:de,task:{progress:be},inProgress:!0})}else if(G){const{mode:_,l:J,w:de,x:me,id:ge,start:be}=G,ie=X-me;if(!be&&Math.abs(ie)<20||_==="start"&&de-ie<v||_==="end"&&de+ie<v||_=="move"&&(ie<0&&J+ie<0||ie>0&&J+de+ie>q))return;const Se={...G,dx:ie};let je,o;_==="start"?(je=J+ie,o=de-ie):_==="end"?(je=J,o=de+ie):_==="move"&&(je=J+ie,o=de);let x={id:ge,width:o,left:je,inProgress:!0};r.exec("drag-task",x);const b=r.getTask(ge);if(!Se.start&&(_=="move"&&b.$x==J||_!="move"&&b.$w==de)){I.current=!0,Y();return}Se.start=!0,f(Se)}else{const _=xe.locate(l);if(_){const J=V(_,j);_.style.cursor=J&&!s?"col-resize":"pointer"}}},[r,s,G,v,q,V]),se=e.useCallback(l=>{Q(l,l)},[Q]),ce=e.useCallback(l=>{h?(l.preventDefault(),Q(l,l.touches[0])):P.current&&(clearTimeout(P.current),P.current=null)},[h,Q]),pe=e.useCallback(()=>{Y()},[Y]),A=e.useCallback(()=>{F(null),P.current&&(clearTimeout(P.current),P.current=null),Y()},[Y]);e.useEffect(()=>(window.addEventListener("mouseup",pe),()=>{window.removeEventListener("mouseup",pe)}),[pe]);const ne=e.useCallback(l=>{if(!s){const j=xe.locateID(l.target);j&&!l.target.classList.contains("wx-link")&&r.exec("show-editor",{id:j})}},[r,s]),ue=["e2s","s2s","e2e","s2e"],T=e.useCallback((l,j)=>ue[(l?1:0)+(j?0:2)],[]),K=e.useCallback((l,j)=>{const X=N.id,_=N.start;return l===X?!0:!!w.find(J=>J.target==l&&J.source==X&&J.type===T(_,j))},[N,i,T]),re=e.useCallback(()=>{N&&O(null)},[N]),le=e.useCallback(l=>{if(I.current){I.current=!1;return}const j=xe.locateID(l.target);if(j){const X=l.target.classList;if(X.contains("wx-link")){const _=X.contains("wx-left");if(!N){O({id:j,start:_});return}N.id!==j&&!K(j,_)&&r.exec("add-link",{link:{source:N.id,target:j,type:T(N.start,_)}})}else r.exec("select-task",{id:j,toggle:l.ctrlKey||l.metaKey,range:l.shiftKey})}re()},[r,N,i]),B=e.useCallback(l=>({left:`${l.$x}px`,top:`${l.$y}px`,width:`${l.$w}px`,height:`${l.$h}px`}),[]),he=e.useCallback(l=>({left:`${l.$x_base}px`,top:`${l.$y_base}px`,width:`${l.$w_base}px`,height:`${l.$h_base}px`}),[]),we=e.useCallback(l=>{if(h||P.current)return l.preventDefault(),!1},[h]),ye=e.useCallback(l=>{let j=p.some(X=>l===X.id)?l:"task";return j!=="task"&&j!=="milestone"&&j!=="summary"&&(j=`task ${j}`),j},[p]),Te=e.useCallback(l=>{r.exec(l.action,l.data)},[r]);return c.jsx("div",{className:"wx-GKbcLEGA wx-bars",style:{lineHeight:`${S.length?S[0].$h:0}px`},ref:D,onContextMenu:we,onMouseDown:L,onMouseMove:se,onTouchStart:Z,onTouchMove:ce,onTouchEnd:A,onClick:le,onDoubleClick:ne,onDragStart:l=>(l.preventDefault(),!1),children:S.map(l=>{if(l.$skip&&l.$skip_baseline)return null;const j=`wx-bar wx-${ye(l.type)}`+(h&&G&&l.id===G.id?" wx-touch":"")+(N&&N.id===l.id?" wx-selected":"")+(l.$reorder?" wx-reorder-task":""),X="wx-link wx-left"+(N?" wx-visible":"")+(!N||!K(l.id,!0)?" wx-target":"")+(N&&N.id===l.id&&N.start?" wx-selected":""),_="wx-link wx-right"+(N?" wx-visible":"")+(!N||!K(l.id,!1)?" wx-target":"")+(N&&N.id===l.id&&!N.start?" wx-selected":"");return c.jsxs(e.Fragment,{children:[!l.$skip&&c.jsxs("div",{className:"wx-GKbcLEGA "+j,style:B(l),"data-tooltip-id":l.id,"data-id":l.id,tabIndex:H===l.id?0:-1,children:[s?null:c.jsx("div",{className:"wx-GKbcLEGA "+X,children:c.jsx("div",{className:"wx-GKbcLEGA wx-inner"})}),l.type!=="milestone"?c.jsxs(c.Fragment,{children:[l.progress?c.jsx("div",{className:"wx-GKbcLEGA wx-progress-wrapper",children:c.jsx("div",{className:"wx-GKbcLEGA wx-progress-percent",style:{width:`${l.progress}%`}})}):null,s?null:c.jsx("div",{className:"wx-GKbcLEGA wx-progress-marker",style:{left:`calc(${l.progress}% - 10px)`},children:l.progress}),n?c.jsx(n,{data:l,api:r,onAction:Te}):c.jsx("div",{className:"wx-GKbcLEGA wx-content",children:l.text||""})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"wx-GKbcLEGA wx-content"}),n?c.jsx(n,{data:l,api:r,onAction:Te}):c.jsx("div",{className:"wx-GKbcLEGA wx-text-out",children:l.text})]}),s?null:c.jsx("div",{className:"wx-GKbcLEGA "+_,children:c.jsx("div",{className:"wx-GKbcLEGA wx-inner"})})]}),W&&!l.$skip_baseline?c.jsx("div",{className:"wx-GKbcLEGA wx-baseline"+(l.type==="milestone"?" wx-milestone":""),style:he(l)}):null]},l.id)})})}function Be(){const t=e.useContext(Ce),s=M.useStore(t,"_links");return c.jsx("svg",{className:"wx-dkx3NwEn wx-links",children:(s||[]).map(n=>c.jsx("polyline",{className:"wx-dkx3NwEn wx-line",points:n.$p},n.id))})}function Xe(t){const{highlightTime:s}=t,n=e.useContext(Ce),r=M.useStore(n,"_scales"),a={width:`${(r&&r.width)!=null?r.width:0}px`};return c.jsx("div",{className:"wx-ZkvhDKir wx-scale",style:a,children:(r?.rows||[]).map((R,w)=>c.jsx("div",{className:"wx-ZkvhDKir wx-row",style:{height:`${R.height}px`},children:(R.cells||[]).map((i,m)=>{const $=s?s(i.date,i.unit):"",p=["wx-cell",i.css,$].filter(Boolean).join(" ");return c.jsx("div",{className:"wx-ZkvhDKir "+p,style:{width:`${i.width}px`},children:i.value},m)})},w))})}function Ye(t){const{readonly:s,fullWidth:n,fullHeight:r,taskTemplate:a,cellBorders:R,highlightTime:w}=t,i=e.useContext(Ce),[m,$]=M.useStoreWithCounter(i,"_selected"),p=M.useStore(i,"scrollLeft"),W=M.useStore(i,"scrollTop"),g=M.useStore(i,"cellHeight"),u=M.useStore(i,"cellWidth"),S=M.useStore(i,"_scales"),v=M.useStore(i,"_markers"),I=M.useStore(i,"_scrollTask"),N=M.useStore(i,"zoom"),[O,G]=e.useState(),f=e.useRef(null),E=1+(S?.rows?.length||0),h=e.useMemo(()=>{const d=[];return m&&m.length&&g&&m.forEach(L=>{d.push({height:`${g}px`,top:`${L.$y-3}px`})}),d},[$,g]),F=e.useMemo(()=>Math.max(O||0,r),[O,r]);e.useEffect(()=>{const d=f.current;d&&typeof W=="number"&&(d.scrollTop=W)},[W]);const P=()=>{q()};function q(d){const L=f.current;if(!L)return;const Z={};Z.left=L.scrollLeft,i.exec("scroll-chart",Z)}function U(){const d=f.current,Z=Math.ceil((O||0)/(g||1))+1,Y=Math.floor((d&&d.scrollTop||0)/(g||1)),Q=Math.max(0,Y-E),se=Y+Z+E,ce=Q*(g||0);i.exec("render-data",{start:Q,end:se,from:ce})}e.useEffect(()=>{U()},[O,W,p]);const D=e.useCallback(d=>{if(!d)return;const{id:L,mode:Z}=d;if(Z.toString().indexOf("x")<0)return;const Y=f.current;if(!Y)return;const{clientWidth:Q}=Y,se=i.getTask(L);if(se.$x+se.$w<Y.scrollLeft)i.exec("scroll-chart",{left:se.$x-(u||0)}),Y.scrollLeft=se.$x-(u||0);else if(se.$x>=Q+Y.scrollLeft){const ce=Q<se.$w?u||0:se.$w;i.exec("scroll-chart",{left:se.$x-Q+ce}),Y.scrollLeft=se.$x-Q+ce}},[i,u,p]);e.useEffect(()=>{D(I)},[I]);function y(d){if(N&&(d.ctrlKey||d.metaKey)){d.preventDefault();const L=f.current,Z=-Math.sign(d.deltaY),Y=d.clientX-(L?L.getBoundingClientRect().left:0);i.exec("zoom-scale",{dir:Z,offset:Y})}}function H(d){const L=w(d.date,d.unit);return L?{css:L,width:d.width}:null}const k=e.useMemo(()=>S&&(S.minUnit==="hour"||S.minUnit==="day")&&w?S.rows[S.rows.length-1].cells.map(H):null,[S,w]),C=e.useCallback(d=>{d.eventSource="chart",i.exec("hotkey",d)},[i]);e.useEffect(()=>{const d=f.current;if(!d)return;const L=()=>G(d.clientHeight);L();const Z=new ResizeObserver(()=>L());return Z.observe(d),()=>{Z.disconnect()}},[f.current]);const V=e.useRef(null);return e.useEffect(()=>{const d=f.current;if(d&&!V.current)return V.current=Ie.hotkeys(d,{keys:{arrowup:!0,arrowdown:!0},exec:L=>C(L)}),()=>{V.current?.destroy(),V.current=null}},[]),e.useEffect(()=>{const d=f.current;if(!d)return;const L=y;return d.addEventListener("wheel",L),()=>{d.removeEventListener("wheel",L)}},[y]),c.jsxs("div",{className:"wx-mR7v2Xag wx-chart",tabIndex:-1,ref:f,onScroll:P,children:[c.jsx(Xe,{highlightTime:w,scales:S}),v&&v.length?c.jsx("div",{className:"wx-mR7v2Xag wx-markers",style:{height:`${F}px`},children:v.map((d,L)=>c.jsx("div",{className:`wx-mR7v2Xag wx-marker ${d.css||"wx-default"}`,style:{left:`${d.left}px`},children:c.jsx("div",{className:"wx-mR7v2Xag wx-content",children:d.text})},L))}):null,c.jsxs("div",{className:"wx-mR7v2Xag wx-area",style:{width:`${n}px`,height:`${F}px`},children:[k?c.jsx("div",{className:"wx-mR7v2Xag wx-gantt-holidays",style:{height:"100%"},children:k.map((d,L)=>d?c.jsx("div",{className:"wx-mR7v2Xag "+d.css,style:{width:`${d.width}px`,left:`${L*d.width}px`}},L):null)}):null,c.jsx(Ve,{borders:R}),m&&m.length?m.map((d,L)=>d.$y?c.jsx("div",{className:"wx-mR7v2Xag wx-selected","data-id":d.id,style:h[L]},d.id):null):null,c.jsx(Be,{}),c.jsx(qe,{readonly:s,taskTemplate:a})]})]})}function Ue(t){const{position:s="after",size:n=4,dir:r="x",minValue:a=0,maxValue:R=0,onMove:w,onDisplayChange:i,compactMode:m}=t,[$,p]=M.useWritableProp(t.value??0),[W,g]=M.useWritableProp(t.display??"all");function u(D){let y=0;s=="center"?y=n/2:s=="before"&&(y=n);const H={size:[n+"px","auto"],p:[D-y+"px","0px"],p2:["auto","0px"]};if(r!="x")for(let k in H)H[k]=H[k].reverse();return H}const[S,v]=e.useState(!1),I=e.useRef(0),N=e.useRef();function O(D){return r=="x"?D.clientX:D.clientY}const G=e.useCallback(D=>{const y=N.current+O(D)-I.current;(!a||a<=y)&&(!R||R>=y)&&(p(y),w(y))},[]),f=e.useCallback(()=>{document.body.style.cursor="",document.body.style.userSelect="",v(!1),window.removeEventListener("mousemove",G),window.removeEventListener("mouseup",f)},[G]),E=e.useMemo(()=>W!=="all"?"auto":r=="x"?"ew-resize":"ns-resize",[W,r]),h=e.useCallback(D=>{I.current=O(D),N.current=$,v(!0),document.body.style.cursor=E,document.body.style.userSelect="none",window.addEventListener("mousemove",G),window.addEventListener("mouseup",f)},[E,G,f,$]);function F(){let D;m?D=W==="chart"?"grid":"chart":D=W==="all"?"chart":"all",g(D),i(D)}function P(){let D;m?D=W==="grid"?"chart":"grid":D=W==="all"?"grid":"all",g(D),i(D)}const q=e.useMemo(()=>u($),[$,s,n,r]),U=["wx-resizer",`wx-resizer-${r}`,`wx-resizer-display-${W}`,S?"wx-resizer-active":""].filter(Boolean).join(" ");return c.jsxs("div",{className:"wx-pFykzMlT "+U,onMouseDown:h,style:{width:q.size[0],height:q.size[1],cursor:E},children:[c.jsxs("div",{className:"wx-pFykzMlT wx-button-expand-box",children:[c.jsx("div",{className:"wx-pFykzMlT wx-button-expand-content wx-button-expand-left",children:c.jsx("i",{className:"wx-pFykzMlT wxi-menu-left",onClick:F})}),c.jsx("div",{className:"wx-pFykzMlT wx-button-expand-content wx-button-expand-right",children:c.jsx("i",{className:"wx-pFykzMlT wxi-menu-right",onClick:P})})]}),c.jsx("div",{className:"wx-pFykzMlT wx-resizer-line"})]})}const Qe=650;function Ge(t){let s;function n(){s=new ResizeObserver(a=>{for(let R of a)if(R.target===document.body){let w=R.contentRect.width<=Qe;t(w)}}),s.observe(document.body)}function r(){s&&(s.disconnect(),s=null)}return{observe:n,disconnect:r}}function Ze(t){const{taskTemplate:s,readonly:n,cellBorders:r,highlightTime:a,onTableAPIChange:R}=t,w=e.useContext(Ce),i=M.useStore(w,"_tasks"),m=M.useStore(w,"_scales"),$=M.useStore(w,"cellHeight"),p=M.useStore(w,"columns"),W=M.useStore(w,"_scrollTask"),[g,u]=e.useState(!1);let[S,v]=e.useState(0);const[I,N]=e.useState(void 0),[O,G]=e.useState(void 0),[f,E]=e.useState(void 0),[h,F]=e.useState("all"),P=e.useRef(null),q=e.useCallback(A=>{u(ne=>(A!==ne&&(A?(P.current=h,h==="all"&&F("grid")):(!P.current||P.current==="all")&&F("all")),A))},[h]);e.useEffect(()=>{const A=Ge(q);return A.observe(),()=>{A.disconnect()}},[q]);const U=e.useMemo(()=>{let A;return p.every(ne=>ne.width&&!ne.flexgrow)?A=p.reduce((ne,ue)=>ne+parseInt(ue.width),0):g&&h==="chart"?A=parseInt(p.find(ne=>ne.id==="action")?.width)||50:A=440,S=A,A},[p,g,h]);e.useEffect(()=>{v(U)},[U]);const D=e.useMemo(()=>(I??0)-(f??0),[I,f]),y=e.useMemo(()=>m.width,[m]),H=e.useMemo(()=>i.length*$,[i,$]),k=e.useMemo(()=>m.height+H+D,[m,H,D]),C=e.useMemo(()=>S+y,[S,y]),V=e.useRef(null),d=e.useCallback(()=>{Promise.resolve().then(()=>{if((I??0)>(C??0)){const A=(I??0)-S;w.exec("expand-scale",{minWidth:A})}})},[I,C,S,w]);e.useEffect(()=>{let A;return V.current&&(A=new ResizeObserver(d),A.observe(V.current)),()=>{A&&A.disconnect()}},[V.current,d]);const L=e.useRef(null),Z=e.useRef(null),Y=e.useCallback(()=>{const A=L.current;A&&w.exec("scroll-chart",{top:A.scrollTop})},[w]),Q=e.useRef({rTasks:[],rScales:{height:0},rCellHeight:0,scrollSize:0,ganttDiv:null,ganttHeight:0});e.useEffect(()=>{Q.current={rTasks:i,rScales:m,rCellHeight:$,scrollSize:D,ganttDiv:L.current,ganttHeight:O??0}},[i,m,$,D,O]);const se=e.useCallback(A=>{if(!A)return;const{rTasks:ne,rScales:ue,rCellHeight:T,scrollSize:K,ganttDiv:re,ganttHeight:le}=Q.current;if(!re)return;const{id:B}=A,he=ne.findIndex(we=>we.id===B);if(he>-1){const we=le-ue.height,ye=he*T,Te=re.scrollTop;let l=null;ye<Te?l=ye:ye+T>Te+we&&(l=ye-we+T+K),l!==null&&(w.exec("scroll-chart",{top:Math.max(l,0)}),L.current.scrollTop=Math.max(l,0))}},[w]);e.useEffect(()=>{se(W)},[W]),e.useEffect(()=>{const A=L.current;if(!A)return;const ne=()=>{G(A.offsetHeight),N(A.offsetWidth)};ne();const ue=new ResizeObserver(ne);return ue.observe(A),()=>ue.disconnect()},[L.current]),e.useEffect(()=>{const A=Z.current;if(!A)return;const ne=()=>{E(A.offsetWidth)};ne();const ue=new ResizeObserver(ne);return ue.observe(A),()=>ue.disconnect()},[Z.current]);const ce=e.useRef(null),pe=e.useRef(null);return e.useEffect(()=>{if(pe.current)return;const A=ce.current;if(A)return pe.current=Ie.hotkeys(A,{keys:{"ctrl+c":!0,"ctrl+v":!0,"ctrl+x":!0,"ctrl+d":!0,backspace:!0},exec:ne=>{ne.isInput||w.exec("hotkey",ne)}}),()=>{pe.current?.destroy(),pe.current=null}},[]),c.jsx("div",{className:"wx-jlbQoHOz wx-gantt",ref:L,onScroll:Y,children:c.jsx("div",{className:"wx-jlbQoHOz wx-pseudo-rows",style:{height:k,width:"100%"},ref:Z,children:c.jsx("div",{className:"wx-jlbQoHOz wx-stuck",style:{height:O,width:f},children:c.jsxs("div",{tabIndex:0,className:"wx-jlbQoHOz wx-layout",ref:ce,children:[p.length?c.jsxs(c.Fragment,{children:[c.jsx(Ke,{display:h,compactMode:g,columnWidth:U,width:S,readonly:n,fullHeight:H,onTableAPIChange:R}),c.jsx(Ue,{value:S,display:h,compactMode:g,minValue:"50",maxValue:"800",onMove:A=>v(A),onDisplayChange:A=>F(A)})]}):null,c.jsx("div",{className:"wx-jlbQoHOz wx-content",ref:V,children:c.jsx(Ye,{readonly:n,fullWidth:y,fullHeight:H,taskTemplate:s,cellBorders:r,highlightTime:a})})]})})})})}const Je=t=>t.split("-").map(s=>s?s.charAt(0).toUpperCase()+s.slice(1):"").join(""),et=[{unit:"month",step:1,format:"MMMM yyy"},{unit:"day",step:1,format:"d"}],tt=e.forwardRef(function({taskTemplate:s=null,markers:n=[],taskTypes:r=ae.defaultTaskTypes,tasks:a=[],selected:R=[],activeTask:w=null,links:i=[],scales:m=et,columns:$=ae.defaultColumns,start:p=null,end:W=null,lengthUnit:g="day",durationUnit:u="day",cellWidth:S=100,cellHeight:v=38,scaleHeight:I=36,readonly:N=!1,cellBorders:O="full",zoom:G=!1,baselines:f=!1,highlightTime:E=null,init:h=null,autoScale:F=!0,unscheduledTasks:P=!1,...q},U){const D=e.useRef();D.current=q;const y=e.useMemo(()=>new ae.DataStore(M.writable),[]),H=e.useMemo(()=>y.in,[y]),k=e.useRef(null);k.current===null&&(k.current=new ze.EventBusRouter((Y,Q)=>{const se="on"+Je(Y);D.current&&D.current[se]&&D.current[se](Q)}),H.setNext(k.current));const[C,V]=e.useState(null),d=e.useRef(null);d.current=C;const L=e.useMemo(()=>({getState:y.getState.bind(y),getReactiveState:y.getReactive.bind(y),getStores:()=>({data:y}),exec:H.exec,setNext:Y=>(k.current=k.current.setNext(Y),k.current),intercept:H.intercept.bind(H),on:H.on.bind(H),detach:H.detach.bind(H),getTask:y.getTask.bind(y),serialize:y.serialize.bind(y),getTable:Y=>Y?new Promise(Q=>setTimeout(()=>Q(d.current),1)):d.current}),[y,H]);e.useImperativeHandle(U,()=>({...L}),[L]);const Z=e.useRef(0);return e.useEffect(()=>{Z.current?y.init({tasks:a,links:i,start:p,columns:$,end:W,lengthUnit:g,cellWidth:S,cellHeight:v,scaleHeight:I,scales:m,taskTypes:r,zoom:G,selected:R,activeTask:w,baselines:f,autoScale:F,unscheduledTasks:P,markers:n,durationUnit:u}):h&&h(L),Z.current++},[a,i,p,$,W,g,S,v,I,m,r,G,R,w,f,F,P,n,u]),Z.current===0&&y.init({tasks:a,links:i,start:p,columns:$,end:W,lengthUnit:g,cellWidth:S,cellHeight:v,scaleHeight:I,scales:m,taskTypes:r,zoom:G,selected:R,activeTask:w,baselines:f,autoScale:F,unscheduledTasks:P,markers:n,durationUnit:u}),c.jsx(oe.Locale,{words:Ee.en,optional:!0,children:c.jsx(Ce.Provider,{value:L,children:c.jsx(Ze,{taskTemplate:s,readonly:N,cellBorders:O,highlightTime:E,onTableAPIChange:V})})})});function st({appearance:t="primary",icon:s="",onClick:n}){return c.jsx("button",{className:`wx-TyZ1fHBj wx-button ${t}`,onClick:n,children:s?c.jsx("i",{className:`wx-TyZ1fHBj wx-button-icon ${s}`}):null})}class nt{constructor(){this.store=new Map}limit(s){this._scope=s}isActive(){return!this._scope||this._scope()}add(s,n){this.store.set(s.toLowerCase().replace(/[ ]/g,""),n)}}const Me=[],rt={subscribe:t=>{ot();const s=new nt;return Me.push(s),t(s),()=>{const n=Me.findIndex(r=>r===s);n>=0&&Me.splice(n,1)}}};var Ae=!1;function ot(){Ae||(Ae=!0,document.addEventListener("keydown",t=>{if(Me.length&&(t.ctrlKey||t.altKey||t.metaKey||t.shiftKey||t.key.length>1||t.key===" ")){const s=[];t.ctrlKey&&s.push("ctrl"),t.altKey&&s.push("alt"),t.metaKey&&s.push("meta"),t.shiftKey&&s.push("shift");let n=t.key.toLocaleLowerCase();t.key===" "&&(n="space"),s.push(n);const r=s.join("+");for(let a=Me.length-1;a>=0;a--){const R=Me[a],w=R.store.get(r)||R.store.get(n),i=t.target.tagName;if(w&&i!=="INPUT"&&i!=="TEXTAREA"&&R.isActive()){w(t),t.preventDefault();return}}}}))}function lt({hotkey:t=null,children:s}){const n=e.useRef(null),[r,a]=e.useState(!1),R=e.useRef(r);e.useEffect(()=>{R.current=r},[r]);const w=e.useRef(()=>{const i=n.current,m=!R.current;m&&i?i.requestFullscreen():R.current&&document.exitFullscreen(),a(m)});return e.useEffect(()=>{t&&rt.subscribe(i=>i.add(t,w.current))},[]),e.useEffect(()=>{const i=()=>{a(document.fullscreenElement===n.current)};return document.addEventListener("fullscreenchange",i),()=>{document.removeEventListener("fullscreenchange",i)}},[]),c.jsxs("div",{tabIndex:0,className:"wx-KG2RkQhB wx-fullscreen",ref:n,children:[s,c.jsx("div",{className:"wx-KG2RkQhB wx-fullscreen-icon",children:c.jsx(st,{appearance:"transparent",icon:`wxi-${r?"collapse":"expand"}`,onClick:()=>w.current()})})]})}function ct({api:t=null,items:s=[...ae.defaultToolbarButtons]}){const n=e.useContext(oe.context.i18n),r=e.useMemo(()=>n||xe.locale(Ee.en),[n]),a=e.useMemo(()=>r.getGroup("gantt"),[r]),R=M.useStoreLater(t,"_selected"),w=M.useStoreLater(t,"_tasks"),i=e.useMemo(()=>s.map($=>{let p={...$,disabled:!1};return p.handler=ae.isHandledAction(ae.defaultToolbarButtons,p.id)?W=>ae.handleAction(t,W.id,null,a):p.handler,p.text&&(p.text=a(p.text)),p.menuText&&(p.menuText=a(p.menuText)),p}),[s,t,a]),m=e.useMemo(()=>t&&R?.length?i.map($=>{if(!$.check)return $;const p=R.some(W=>!$.check(W,w));return{...$,disabled:p}}):[{...i[0],disabled:!1}],[t,R,w,i]);return n?c.jsx(Le.Toolbar,{items:m}):c.jsx(oe.context.i18n.Provider,{value:r,children:c.jsx(Le.Toolbar,{items:m})})}const it=e.forwardRef(function({options:s,api:n=null,resolver:r=null,filter:a=null,at:R="point",children:w,onClick:i,css:m},$){const p=e.useMemo(()=>s??[...ae.defaultMenuOptions],[s]),[W]=M.useWritableProp(p),g=e.useRef(null),u=e.useRef(null),S=e.useContext(oe.context.i18n),v=e.useMemo(()=>S||xe.locale({...Ee.en,...We.en}),[S]),I=e.useMemo(()=>v.getGroup("gantt"),[v]),N=M.useStoreLater(n,"taskTypes"),O=M.useStoreLater(n,"_tasks"),G=M.useStoreLater(n,"selected"),f=M.useStoreLater(n,"_selected");e.useEffect(()=>{n&&(n.on("scroll-chart",()=>{g.current&&g.current.show&&g.current.show()}),n.on("drag-task",()=>{g.current&&g.current.show&&g.current.show()}))},[n]);function E(k){return k.map(C=>(C={...C},C.text&&(C.text=I(C.text)),C.subtext&&(C.subtext=I(C.subtext)),C.data&&(C.data=E(C.data)),C))}function h(){const k=W.find(C=>C.id==="convert-task");return k&&(k.data=[],(N||[]).forEach(C=>{k.data.push(k.dataFactory(C))})),E(W)}const F=e.useMemo(()=>n?h():null,[n,W,N,I]),P=e.useMemo(()=>f&&f.length?f:[],[f]),q=e.useCallback((k,C)=>{let V=k?n?.getTask(k):null;if(r){const d=r(k,C);V=d===!0?V:d}return V&&(u.current=V.id,(!Array.isArray(G)||!G.includes(V.id))&&n&&n.exec&&n.exec("select-task",{id:V.id})),V},[n,r,G]),U=e.useCallback(k=>{const C=k.action;C&&(ae.isHandledAction(ae.defaultMenuOptions,C.id)&&ae.handleAction(n,C.id,u.current,I),i&&i(k))},[n,I,i]),D=e.useCallback((k,C)=>{const V=P.length?P:C?[C]:[];let d=a?a(k,C):!0;if(k.check&&d){const L=V.some(Z=>!k.check(Z,O));k.css=L?"wx-disabled":""}return d},[a,P,O]);e.useImperativeHandle($,()=>({show:(k,C)=>{g.current&&g.current.show&&g.current.show(k,C)}}));const y=e.useCallback(k=>{g.current&&g.current.show&&g.current.show(k)},[]),H=c.jsxs(c.Fragment,{children:[c.jsx(Pe.ContextMenu,{filter:D,options:F,dataKey:"id",resolver:q,onClick:U,at:R,ref:g,css:m}),c.jsx("span",{onContextMenu:y,"data-menu-ignore":"true",children:typeof w=="function"?w():w})]});if(!S&&oe.context.i18n?.Provider){const k=oe.context.i18n.Provider;return c.jsx(k,{value:v,children:H})}return H});function at({api:t,autoSave:s,onLinksChange:n}){const a=e.useContext(oe.context.i18n).getGroup("gantt"),R=M.useStore(t,"activeTask"),w=M.useStore(t,"_links"),[i,m]=e.useState();function $(){if(R){const u=w.filter(v=>v.target==R).map(v=>({link:v,task:t.getTask(v.source)})),S=w.filter(v=>v.source==R).map(v=>({link:v,task:t.getTask(v.target)}));return[{title:a("Predecessors"),data:u},{title:a("Successors"),data:S}]}}e.useEffect(()=>{m($())},[R,w]);const p=e.useMemo(()=>[{id:"e2s",label:a("End-to-start")},{id:"s2s",label:a("Start-to-start")},{id:"e2e",label:a("End-to-end")},{id:"s2e",label:a("Start-to-end")}],[a]);function W(u){s?t.exec("delete-link",{id:u}):(m(S=>(S||[]).map(v=>({...v,data:v.data.filter(I=>I.link.id!==u)}))),n&&n({id:u,action:"delete-link",data:{id:u}}))}function g(u,S){const v=u.value;s?t.exec("update-link",{id:S,link:{type:v}}):(m(I=>(I||[]).map(N=>({...N,data:N.data.map(O=>O.link.id===S?{...O,link:{...O.link,type:v}}:O)}))),n&&n({id:S,action:"update-link",data:{id:S,link:{type:v}}}))}return c.jsx(c.Fragment,{children:(i||[]).map((u,S)=>u.data.length?c.jsx("div",{className:"wx-j93aYGQf wx-links",children:c.jsx(oe.Field,{label:u.title,position:"top",children:c.jsx("table",{children:c.jsx("tbody",{children:u.data.map(v=>c.jsxs("tr",{children:[c.jsx("td",{className:"wx-j93aYGQf wx-cell",children:c.jsx("div",{className:"wx-j93aYGQf wx-task-name",children:v.task.text||""})}),c.jsx("td",{className:"wx-j93aYGQf wx-cell",children:c.jsx("div",{className:"wx-j93aYGQf wx-wrapper",children:c.jsx(oe.Combo,{value:v.link.type,placeholder:a("Select link type"),options:p,onChange:I=>g(I,v.link.id),children:({option:I})=>I.label})})}),c.jsx("td",{className:"wx-j93aYGQf wx-cell",children:c.jsx("i",{className:"wx-j93aYGQf wxi-delete wx-delete-icon",onClick:()=>W(v.link.id),role:"button"})})]},v.link.id))})})})},S):null)})}function ut(t){const{value:s,time:n,format:r,onchange:a,onChange:R,...w}=t,i=R??a;function m($){const p=new Date($.value);p.setHours(s.getHours()),p.setMinutes(s.getMinutes()),i&&i({value:p})}return c.jsxs("div",{className:"wx-hFsbgDln date-time-controll",children:[c.jsx(oe.DatePicker,{...w,value:s,onChange:m,format:r,buttons:["today"],clear:!1}),n?c.jsx(oe.TimePicker,{value:s,onChange:i,format:r}):null]})}ve.registerEditorItem("select",oe.RichSelect);ve.registerEditorItem("date",ut);ve.registerEditorItem("twostate",oe.TwoState);ve.registerEditorItem("slider",oe.Slider);ve.registerEditorItem("counter",oe.Counter);ve.registerEditorItem("links",at);function dt({api:t,items:s=ae.defaultEditorItems,css:n="",layout:r="default",readonly:a=!1,placement:R="sidebar",bottomBar:w=!0,topBar:i=!0,autoSave:m=!0,focus:$=!1}){const p=e.useContext(oe.context.i18n),W=e.useMemo(()=>p||xe.locale({...Ee.en,...We.en}),[p]),g=e.useMemo(()=>W.getGroup("gantt"),[W]),u=W.getRaw(),S=e.useMemo(()=>{const T=u.gantt?.dateFormat||u.formats?.dateFormat;return xe.dateToString(T,u.calendar)},[u]),v=e.useMemo(()=>{if(i===!0&&!a){const T=[{comp:"icon",icon:"wxi-close",id:"close"},{comp:"spacer"},{comp:"button",type:"danger",text:g("Delete"),id:"delete"}];return m?{items:T}:{items:[...T,{comp:"button",type:"primary",text:g("Save"),id:"save"}]}}return i},[i,a,m,g]),[I,N]=e.useState(!1),O=e.useMemo(()=>I?"wx-full-screen":"",[I]),G=e.useCallback(T=>{N(T)},[]);e.useEffect(()=>{const T=Ge(G);return T.observe(),()=>{T.disconnect()}},[G]);const f=M.useStore(t,"_activeTask"),E=e.useMemo(()=>f?.id,[f]),h=M.useStore(t,"durationUnit"),F=M.useStore(t,"unscheduledTasks"),P=M.useStore(t,"taskTypes"),[q,U]=M.useWritableProp(f?.type),D=e.useMemo(()=>f?.unscheduled,[f]),[y,H]=e.useState({});e.useEffect(()=>{H({})},[E]);const k=e.useMemo(()=>q==="milestone",[q]),C=e.useMemo(()=>q==="summary",[q]);function V(T,K){const re={start:1,end:1,duration:1};return T.map(le=>{const B={...le};if(le.config&&(B.config={...B.config}),B.comp==="links"&&t&&(B.api=t,B.autoSave=m,B.onLinksChange=Y),B.comp==="select"&&B.key==="type"){let he=B.options??(P||[]);B.options=he.map(we=>({...we,label:g(we.label)}))}return B.comp==="slider"&&B.key==="progress"&&(B.labelTemplate=he=>`${g(B.label)} ${he}%`),B.label&&(B.label=g(B.label)),B.config?.placeholder&&(B.config.placeholder=g(B.config.placeholder)),F&&re[B.key]&&(K?B.disabled=!0:delete B.disabled),B})}function d(T){return T.filter(({comp:K,key:re,options:le})=>{switch(K){case"date":return(!k||re!=="end"&&re!=="base_end")&&!C;case"select":return le.length>1;case"twostate":return F&&!C;case"counter":return!C&&!k;case"slider":return!k;default:return!0}})}const L=e.useMemo(()=>{const T=V(s,D);return d(T)},[s,D,k,C,F,P,g,t,m]),Z=e.useMemo(()=>{if(a&&f){let T={};return L.forEach(({key:K,comp:re})=>{if(re!=="links"){const le=f[K];re==="date"&&le instanceof Date?T[K]=S(le):re==="slider"&&K==="progress"?T[K]=`${le}%`:T[K]=le}}),T}return f?{...f}:null},[a,f,L,S]);function Y({id:T,action:K,data:re}){H(le=>({...le,[T]:{action:K,data:re}}))}const Q=e.useCallback(()=>{for(let T in y){const{action:K,data:re}=y[T];t.exec(K,re)}},[t,y]),se=e.useCallback(()=>{t.exec("delete-task",{id:E})},[t,E]),ce=e.useCallback(()=>{t.exec("show-editor",{id:null})},[t]),pe=e.useCallback(T=>{const{item:K,changes:re}=T;K.id==="delete"&&se(),K.id==="save"&&(re.length?ce():Q()),K.comp&&ce()},[t,E,m,Q,se,ce]),A=e.useCallback((T,K)=>(F&&T.type==="summary"&&(T.unscheduled=!1),ae.normalizeDates(T,h,!0,K),T),[F,h]),ne=e.useCallback(T=>{let{update:K,key:re,value:le}=T;T.update=A({...K},re),m||re==="type"&&U(le)},[t,m]),ue=e.useCallback(T=>{let{values:K}=T;K={...K,unscheduled:F&&K.unscheduled&&K.type!=="summary"},delete K.links,delete K.data,t.exec("update-task",{id:E,task:K}),m||Q()},[t,E,F,m,Q]);return Z?c.jsx(oe.Locale,{children:c.jsx(ve.Editor,{css:`wx-XkvqDXuw wx-gantt-editor ${O} ${n}`,items:L,values:Z,topBar:v,bottomBar:w,placement:R,layout:r,readonly:a,autoSave:m,focus:$,onAction:pe,onSave:ue,onChange:ne})}):null}const ft=({children:t,columns:s=null,api:n})=>{const[r,a]=e.useState(null);return e.useEffect(()=>{n&&n.getTable(!0).then(a)},[n]),c.jsx(He.HeaderMenu,{api:r,columns:s,children:t})};function xt(t){const{api:s,content:n,children:r}=t,a=e.useRef(null),R=e.useRef(null),[w,i]=e.useState({}),[m,$]=e.useState(null),[p,W]=e.useState({});function g(f){for(;f;){if(f.getAttribute){const E=f.getAttribute("data-tooltip-id"),h=f.getAttribute("data-tooltip-at"),F=f.getAttribute("data-tooltip");if(E||F)return{id:E,tooltip:F,target:f,at:h}}f=f.parentNode}return{id:null,tooltip:null,target:null,at:null}}e.useEffect(()=>{const f=R.current;if(f&&p&&(p.text||n)){const E=f.getBoundingClientRect();let h=!1,F=p.left,P=p.top;E.right>=w.right&&(F=w.width-E.width-5,h=!0),E.bottom>=w.bottom&&(P=p.top-(E.bottom-w.bottom+2),h=!0),h&&W(q=>q&&{...q,left:F,top:P})}},[p,w,n]);const u=e.useRef(null),S=300,v=f=>{clearTimeout(u.current),u.current=setTimeout(()=>{f()},S)};function I(f){let{id:E,tooltip:h,target:F,at:P}=g(f.target);if(W(null),$(null),!h)if(E)h=O(E);else{clearTimeout(u.current);return}const q=f.clientX;v(()=>{E&&$(N(G(E)));const U=F.getBoundingClientRect(),D=a.current,y=D?D.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0};let H,k;P==="left"?(H=U.top+5-y.top,k=U.right+5-y.left):(H=U.top+U.height-y.top,k=q-y.left),i(y),W({top:H,left:k,text:h})})}function N(f){return s?.getTask(G(f))||null}function O(f){return N(f)?.text||""}function G(f){const E=parseInt(f);return isNaN(E)?f:E}return c.jsxs("div",{className:"wx-KG0Lwsqo wx-tooltip-area",ref:a,onMouseMove:I,children:[p&&(p.text||n)?c.jsx("div",{className:"wx-KG0Lwsqo wx-gantt-tooltip",ref:R,style:{top:`${p.top}px`,left:`${p.left}px`},children:n?c.jsx(n,{data:m}):p.text?c.jsx("div",{className:"wx-KG0Lwsqo wx-gantt-tooltip-text",children:p.text}):null}):null,r]})}function ht({fonts:t=!0,children:s}){return s?c.jsx(oe.Material,{fonts:t,children:s()}):c.jsx(oe.Material,{fonts:t})}function mt({fonts:t=!0,children:s}){return s?c.jsx(oe.Willow,{fonts:t,children:s}):c.jsx(oe.Willow,{fonts:t})}function pt({fonts:t=!0,children:s}){return s?c.jsx(oe.WillowDark,{fonts:t,children:s}):c.jsx(oe.WillowDark,{fonts:t})}Object.defineProperty(exports,"defaultColumns",{enumerable:!0,get:()=>ae.defaultColumns});Object.defineProperty(exports,"defaultEditorItems",{enumerable:!0,get:()=>ae.defaultEditorItems});Object.defineProperty(exports,"defaultMenuOptions",{enumerable:!0,get:()=>ae.defaultMenuOptions});Object.defineProperty(exports,"defaultTaskTypes",{enumerable:!0,get:()=>ae.defaultTaskTypes});Object.defineProperty(exports,"defaultToolbarButtons",{enumerable:!0,get:()=>ae.defaultToolbarButtons});Object.defineProperty(exports,"registerScaleUnit",{enumerable:!0,get:()=>ae.registerScaleUnit});Object.defineProperty(exports,"registerEditorItem",{enumerable:!0,get:()=>ve.registerEditorItem});exports.ContextMenu=it;exports.Editor=dt;exports.Fullscreen=lt;exports.Gantt=tt;exports.HeaderMenu=ft;exports.Material=ht;exports.Toolbar=ct;exports.Tooltip=xt;exports.Willow=mt;exports.WillowDark=pt;