@svar-ui/gantt-store 2.2.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var yt=new Date().valueOf(),ce=()=>yt++;function kt(){return"temp://"+yt++}var wt=class{constructor(t){this._data=t,this._pool=new Map;for(let e=0;e<t.length;e++){const n=t[e];this._pool.set(n.id,n)}}add(t){t={id:ce(),...t},this._data.push(t),this._pool.set(t.id,t)}update(t,e){const n=this._data.findIndex(s=>s.id==t),a={...this._data[n],...e};this._data[n]=a,this._pool.set(a.id,a)}remove(t){this._data=this._data.filter(e=>e.id!=t),this._pool.delete(t)}filter(t){this._data=this._data.filter(e=>{const n=t(e);return n||this._pool.delete(e.id),n})}byId(t){return this._pool.get(t)}map(t){return this._data.map(t)}forEach(t){this._data.forEach(t)}},ue=class{constructor(t){const e={id:0,$level:0,data:[],parent:null},n=new Map;n.set(0,e),this._pool=n,t&&t.length&&this.parse(t,0)}parse(t,e){const n=this._pool;for(let s=0;s<t.length;s++){const r=t[s];r.parent=r.parent||e,r.data=null,n.set(r.id,r)}for(let s=0;s<t.length;s++){const r=t[s],i=n.get(r.parent);i&&(i.data||(i.data=[]),i.data.push(r))}const a=n.get(e);this.setLevel(a,a.$level+1,!1)}add(t,e){const n=this._pool.get(t.parent||0);t.$level=n.$level+1,this._pool.set(t.id,t),n.data?e===-1?n.data=[...n.data,t]:xt(n,e,t):n.data=[t]}addAfter(t,e){if(!e)return this.add(t,-1);const n=this.byId(e),a=this.byId(n.parent),s=L(a,n.id)+1;t.parent=a.id,t.$level=a.$level+1,this.add(t,s)}remove(t){const e=this._pool.get(t);this._remove(e);const n=this._pool.get(e.parent);n.data=n.data.filter(a=>a.id!=t),this._clearBranch(n)}_remove(t){t.data&&t.data.forEach(e=>this._remove(e)),this._pool.delete(t.id)}update(t,e){let n=this._pool.get(t);const a=this._pool.get(n.parent),s=L(a,n.id);n={...n,...e},a&&s>=0&&(a.data[s]=n,a.data=[...a.data]),this._pool.set(n.id,n)}move(t,e,n){const a=this._pool.get(t),s=e==="child",r=this._pool.get(n),i=r.$level+(s?1:0);if(!a||!r)return;const o=this._pool.get(a.parent),c=s?r:this._pool.get(r.parent);c.data||(c.data=[]);const u=L(o,a.id);de(o,u);const l=s?c.data.length:L(c,r.id)+(e==="after"?1:0);if(xt(c,l,a),o.id===c.id&&u===l)return null;a.parent=c.id,a.$level!==i&&(a.$level=i,this.setLevel(a,i+1,!0)),this.update(a.id,a),this._clearBranch(o)}_clearBranch(t){t.data&&!t.data.length&&(t.open&&delete t.open,this.update(t.id,{data:null}))}toArray(){const t=[],e=this._pool.get(0).data;return e&&bt(e,t),t}byId(t){return this._pool.get(t)}getBranch(t){return this._pool.get(t).data}forEach(t){this._pool.forEach((e,n)=>{n!==0&&t(e)})}eachChild(t,e){const n=this.byId(e);!n||!n.data||n.data.forEach((a,s)=>{t(this.byId(a.id),s),this.eachChild(t,a.id)})}setLevel(t,e,n){t.data&&(t.data=t.data.map(a=>(n&&(a={...a},this._pool.set(a.id,a)),a.$level=e,a.data&&this.setLevel(a,e+1,n),a)))}};function bt(t,e){t.forEach(n=>{e.push(n),n.open===!0&&bt(n.data,e)})}function de(t,e){const n=[...t.data];n.splice(e,1),t.data=n}function xt(t,e,n){const a=[...t.data];a.splice(e,0,n),t.data=a}function L(t,e){return t?.data.findIndex(n=>n.id===e)}var _t=2,le=class{constructor(t){t&&(this._writable=t.writable,this._async=t.async),this._values={},this._state={}}setState(t,e=0){const n={};return this._wrapProperties(t,this._state,this._values,"",n,e),n}getState(){return this._values}getReactive(){return this._state}_wrapProperties(t,e,n,a,s,r){for(const i in t){const o=e[i],c=n[i],u=t[i];if(o&&(c===u&&typeof u!="object"||u instanceof Date&&c instanceof Date&&c.getTime()===u.getTime()))continue;const l=a+(a?".":"")+i;o?(o.__parse(u,l,s,r)&&(n[i]=u),r&_t?s[l]=o.__trigger:o.__trigger()):(u&&u.__reactive?e[i]=this._wrapNested(u,u,l,s):e[i]=this._wrapWritable(u),n[i]=u),s[l]=s[l]||null}}_wrapNested(t,e,n,a){const s=this._wrapWritable(t);return this._wrapProperties(t,s,e,n,a,0),s.__parse=(r,i,o,c)=>(this._wrapProperties(r,s,e,i,o,c),!1),s}_wrapWritable(t){const e=[],n=function(){for(let a=0;a<e.length;a++)e[a](t)};return{subscribe:a=>(e.push(a),this._async?setTimeout(a,1,t):a(t),()=>{const s=e.indexOf(a);s>=0&&e.splice(s,1)}),__trigger:()=>{e.length&&(this._async?setTimeout(n,1):n())},__parse:function(a){return t=a,!0}}}},he=class{constructor(t,e,n,a){typeof t=="function"?this._setter=t:this._setter=t.setState.bind(t),this._routes=e,this._parsers=n,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(s=>{s.in.forEach(r=>{const i=this._triggers.get(r)||[];i.push(s),this._triggers.set(r,i)}),s.out.forEach(r=>{const i=this._sources.get(r)||{};s.in.forEach(o=>i[o]=!0),this._sources.set(r,i)})}),this._routes.forEach(s=>{s.length=Math.max(...s.in.map(r=>vt(r,this._sources,1)))}),this._bus=a}init(t){const e={};for(const n in t)if(this._prev[n]!==t[n]){const a=this._parsers[n];e[n]=a?a(t[n]):t[n]}this._prev=this._prev?{...this._prev,...t}:{...t},this.setState(e),this._bus&&this._bus.exec("init-state",e)}setStateAsync(t){const e=this._setter(t,_t);return this._async?Object.assign(this._async.signals,e):this._async={signals:e,timer:setTimeout(this._applyState.bind(this),1)},e}_applyState(){const t=this._async;if(t){this._async=null,this._triggerUpdates(t.signals,[]);for(const e in t.signals){const n=t.signals[e];n&&n()}}}setState(t,e=[]){const n=this._setter(t);return this._triggerUpdates(n,e),n}_triggerUpdates(t,e){const n=Object.keys(t),a=!e.length;e=e||[];for(let s=0;s<n.length;s++){const r=n[s],i=this._triggers.get(r);i&&i.forEach(o=>{e.indexOf(o)==-1&&e.push(o)})}a&&this._execNext(e)}_execNext(t){for(;t.length;){t.sort((n,a)=>n.length<a.length?1:-1);const e=t[t.length-1];t.splice(t.length-1),e.exec(t)}}};function vt(t,e,n){const a=e.get(t);if(!a)return n;const s=Object.keys(a).map(r=>vt(r,e,n+1));return Math.max(...s)}var fe=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(t,e,n){let a=this._handlers[t];a?n&&n.intercept?a.unshift(e):a.push(e):a=this._handlers[t]=[e],n&&n.tag&&this._tag.set(e,n.tag)}intercept(t,e,n){this.on(t,e,{...n,intercept:!0})}detach(t){for(const e in this._handlers){const n=this._handlers[e];for(let a=n.length-1;a>=0;a--)this._tag.get(n[a])===t&&n.splice(a,1)}}async exec(t,e){const n=this._handlers[t];if(n)for(let a=0;a<n.length;a++){const s=n[a](e);if(s===!1||s&&s.then&&await s===!1)return}return this._nextHandler&&await this._nextHandler.exec(t,e),e}setNext(t){return this._nextHandler=t}};function me(t,e){return typeof t=="string"?t.localeCompare(e,void 0,{numeric:!0}):typeof t=="object"?t.getTime()-e.getTime():(t??0)-(e??0)}function ge(t,e){return typeof t=="string"?-t.localeCompare(e,void 0,{numeric:!0}):typeof e=="object"?e.getTime()-t.getTime():(e??0)-(t??0)}function pe({key:t,order:e}){const n=e==="asc"?me:ge;return(a,s)=>n(a[t],s[t])}function ye(t){if(!t||!t.length)return;const e=t.map(n=>pe(n));return t.length===1?e[0]:function(n,a){for(let s=0;s<e.length;s++){const r=e[s](n,a);if(r!==0)return r}return 0}}function ke(t,e){return t.sort(ye(e))}function y(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function S(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function St(t,e){const n=y(t);return isNaN(e)?S(t,NaN):(e&&n.setDate(n.getDate()+e),n)}function Z(t,e){const n=y(t);if(isNaN(e))return S(t,NaN);if(!e)return n;const a=n.getDate(),s=S(t,n.getTime());s.setMonth(n.getMonth()+e+1,0);const r=s.getDate();return a>=r?s:(n.setFullYear(s.getFullYear(),s.getMonth(),a),n)}function Mt(t,e){const n=+y(t);return S(t,n+e)}const U=6048e5,we=864e5,Wt=6e4,Dt=36e5;function be(t,e){return Mt(t,e*Dt)}let xe={};function j(){return xe}function $(t,e){const n=j(),a=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=y(t),r=s.getDay(),i=(r<a?7:0)+r-a;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function P(t){return $(t,{weekStartsOn:1})}function $t(t){const e=y(t),n=e.getFullYear(),a=S(t,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const s=P(a),r=S(t,0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);const i=P(r);return e.getTime()>=s.getTime()?n+1:e.getTime()>=i.getTime()?n:n-1}function N(t){const e=y(t);return e.setHours(0,0,0,0),e}function X(t){const e=y(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function tt(t,e){const n=N(t),a=N(e),s=+n-X(n),r=+a-X(a);return Math.round((s-r)/we)}function et(t){const e=$t(t),n=S(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),P(n)}function _e(t,e){return Mt(t,e*Wt)}function ve(t,e){const n=e*3;return Z(t,n)}function Tt(t,e){const n=e*7;return St(t,n)}function Se(t,e){return Z(t,e*12)}function z(t,e){const n=y(t),a=y(e),s=n.getTime()-a.getTime();return s<0?-1:s>0?1:s}function Me(t,e){const n=N(t),a=N(e);return+n==+a}function We(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function De(t){if(!We(t)&&typeof t!="number")return!1;const e=y(t);return!isNaN(Number(e))}function nt(t,e){const n=P(t),a=P(e),s=+n-X(n),r=+a-X(a);return Math.round((s-r)/U)}function $e(t,e){const n=y(t),a=y(e),s=n.getFullYear()-a.getFullYear(),r=n.getMonth()-a.getMonth();return s*12+r}function Te(t,e){const n=y(t),a=y(e);return n.getFullYear()-a.getFullYear()}function at(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return n===0?0:n}}function Ct(t,e){return+y(t)-+y(e)}function Ce(t,e,n){const a=Ct(t,e)/Dt;return at(n?.roundingMethod)(a)}function Ie(t,e,n){const a=Ct(t,e)/Wt;return at(n?.roundingMethod)(a)}function It(t){const e=y(t);return e.setHours(23,59,59,999),e}function st(t){const e=y(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function Pe(t){const e=y(t);return+It(e)==+st(e)}function Pt(t,e){const n=y(t),a=y(e),s=z(n,a),r=Math.abs($e(n,a));let i;if(r<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-s*r);let o=z(n,a)===-s;Pe(y(t))&&r===1&&z(t,a)===1&&(o=!1),i=s*(r-Number(o))}return i===0?0:i}function Ee(t,e,n){const a=Pt(t,e)/3;return at(n?.roundingMethod)(a)}function Oe(t,e){const n=y(t),a=y(e),s=z(n,a),r=Math.abs(Te(n,a));n.setFullYear(1584),a.setFullYear(1584);const i=z(n,a)===-s,o=s*(r-+i);return o===0?0:o}function F(t){const e=y(t),n=e.getMonth(),a=n-n%3;return e.setMonth(a,1),e.setHours(0,0,0,0),e}function Et(t){const e=y(t);return e.setDate(1),e.setHours(0,0,0,0),e}function Ye(t){const e=y(t),n=e.getFullYear();return e.setFullYear(n+1,0,0),e.setHours(23,59,59,999),e}function Ot(t){const e=y(t),n=S(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Ne(t){const e=y(t);return e.setMinutes(59,59,999),e}function ze(t,e){const n=e?.weekStartsOn,a=y(t),s=a.getDay(),r=(s<n?-7:0)+6-(s-n);return a.setDate(a.getDate()+r),a.setHours(23,59,59,999),a}function rt(t){const e=y(t),n=e.getMonth(),a=n-n%3+3;return e.setMonth(a,0),e.setHours(23,59,59,999),e}const Fe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},He=(t,e,n)=>{let a;const s=Fe[t];return typeof s=="string"?a=s:e===1?a=s.one:a=s.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function it(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const Ae={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},qe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Be={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Le={date:it({formats:Ae,defaultWidth:"full"}),time:it({formats:qe,defaultWidth:"full"}),dateTime:it({formats:Be,defaultWidth:"full"})},Ue={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},je=(t,e,n,a)=>Ue[t];function H(t){return(e,n)=>{const a=n?.context?String(n.context):"standalone";let s;if(a==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,o=n?.width?String(n.width):i;s=t.formattingValues[o]||t.formattingValues[i]}else{const i=t.defaultWidth,o=n?.width?String(n.width):t.defaultWidth;s=t.values[o]||t.values[i]}const r=t.argumentCallback?t.argumentCallback(e):e;return s[r]}}const Xe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Qe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ge={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Re={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Je={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Ve={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Ke=(t,e)=>{const n=Number(t),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Ze={ordinalNumber:Ke,era:H({values:Xe,defaultWidth:"wide"}),quarter:H({values:Qe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:H({values:Ge,defaultWidth:"wide"}),day:H({values:Re,defaultWidth:"wide"}),dayPeriod:H({values:Je,defaultWidth:"wide",formattingValues:Ve,defaultFormattingWidth:"wide"})};function A(t){return(e,n={})=>{const a=n.width,s=a&&t.matchPatterns[a]||t.matchPatterns[t.defaultMatchWidth],r=e.match(s);if(!r)return null;const i=r[0],o=a&&t.parsePatterns[a]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(o)?en(o,h=>h.test(i)):tn(o,h=>h.test(i));let u;u=t.valueCallback?t.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const l=e.slice(i.length);return{value:u,rest:l}}}function tn(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function en(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function nn(t){return(e,n={})=>{const a=e.match(t.matchPattern);if(!a)return null;const s=a[0],r=e.match(t.parsePattern);if(!r)return null;let i=t.valueCallback?t.valueCallback(r[0]):r[0];i=n.valueCallback?n.valueCallback(i):i;const o=e.slice(s.length);return{value:i,rest:o}}}const an=/^(\d+)(th|st|nd|rd)?/i,sn=/\d+/i,rn={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},on={any:[/^b/i,/^(a|c)/i]},cn={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},un={any:[/1/i,/2/i,/3/i,/4/i]},dn={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ln={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},hn={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},fn={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},mn={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},gn={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},pn={ordinalNumber:nn({matchPattern:an,parsePattern:sn,valueCallback:t=>parseInt(t,10)}),era:A({matchPatterns:rn,defaultMatchWidth:"wide",parsePatterns:on,defaultParseWidth:"any"}),quarter:A({matchPatterns:cn,defaultMatchWidth:"wide",parsePatterns:un,defaultParseWidth:"any",valueCallback:t=>t+1}),month:A({matchPatterns:dn,defaultMatchWidth:"wide",parsePatterns:ln,defaultParseWidth:"any"}),day:A({matchPatterns:hn,defaultMatchWidth:"wide",parsePatterns:fn,defaultParseWidth:"any"}),dayPeriod:A({matchPatterns:mn,defaultMatchWidth:"any",parsePatterns:gn,defaultParseWidth:"any"})},yn={code:"en-US",formatDistance:He,formatLong:Le,formatRelative:je,localize:Ze,match:pn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function kn(t){const e=y(t);return tt(e,Ot(e))+1}function wn(t){const e=y(t),n=+P(e)-+et(e);return Math.round(n/U)+1}function Yt(t,e){const n=y(t),a=n.getFullYear(),s=j(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,i=S(t,0);i.setFullYear(a+1,0,r),i.setHours(0,0,0,0);const o=$(i,e),c=S(t,0);c.setFullYear(a,0,r),c.setHours(0,0,0,0);const u=$(c,e);return n.getTime()>=o.getTime()?a+1:n.getTime()>=u.getTime()?a:a-1}function bn(t,e){const n=j(),a=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=Yt(t,e),r=S(t,0);return r.setFullYear(s,0,a),r.setHours(0,0,0,0),$(r,e)}function xn(t,e){const n=y(t),a=+$(n,e)-+bn(n,e);return Math.round(a/U)+1}function b(t,e){const n=t<0?"-":"",a=Math.abs(t).toString().padStart(e,"0");return n+a}const T={y(t,e){const n=t.getFullYear(),a=n>0?n:1-n;return b(e==="yy"?a%100:a,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):b(n+1,2)},d(t,e){return b(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return b(t.getHours()%12||12,e.length)},H(t,e){return b(t.getHours(),e.length)},m(t,e){return b(t.getMinutes(),e.length)},s(t,e){return b(t.getSeconds(),e.length)},S(t,e){const n=e.length,a=t.getMilliseconds(),s=Math.trunc(a*Math.pow(10,n-3));return b(s,e.length)}},E={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Nt={G:function(t,e,n){const a=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});case"GGGG":default:return n.era(a,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const a=t.getFullYear(),s=a>0?a:1-a;return n.ordinalNumber(s,{unit:"year"})}return T.y(t,e)},Y:function(t,e,n,a){const s=Yt(t,a),r=s>0?s:1-s;if(e==="YY"){const i=r%100;return b(i,2)}return e==="Yo"?n.ordinalNumber(r,{unit:"year"}):b(r,e.length)},R:function(t,e){const n=$t(t);return b(n,e.length)},u:function(t,e){const n=t.getFullYear();return b(n,e.length)},Q:function(t,e,n){const a=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(a);case"QQ":return b(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(t,e,n){const a=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(a);case"qq":return b(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(t,e,n){const a=t.getMonth();switch(e){case"M":case"MM":return T.M(t,e);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(t,e,n){const a=t.getMonth();switch(e){case"L":return String(a+1);case"LL":return b(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(t,e,n,a){const s=xn(t,a);return e==="wo"?n.ordinalNumber(s,{unit:"week"}):b(s,e.length)},I:function(t,e,n){const a=wn(t);return e==="Io"?n.ordinalNumber(a,{unit:"week"}):b(a,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):T.d(t,e)},D:function(t,e,n){const a=kn(t);return e==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):b(a,e.length)},E:function(t,e,n){const a=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});case"EEEE":default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(t,e,n,a){const s=t.getDay(),r=(s-a.weekStartsOn+8)%7||7;switch(e){case"e":return String(r);case"ee":return b(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,n,a){const s=t.getDay(),r=(s-a.weekStartsOn+8)%7||7;switch(e){case"c":return String(r);case"cc":return b(r,e.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,n){const a=t.getDay(),s=a===0?7:a;switch(e){case"i":return String(s);case"ii":return b(s,e.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});case"iiii":default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(t,e,n){const a=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,e,n){const a=t.getHours();let s;switch(a===12?s=E.noon:a===0?s=E.midnight:s=a/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,n){const a=t.getHours();let s;switch(a>=17?s=E.evening:a>=12?s=E.afternoon:a>=4?s=E.morning:s=E.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let a=t.getHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return T.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):T.H(t,e)},K:function(t,e,n){const a=t.getHours()%12;return e==="Ko"?n.ordinalNumber(a,{unit:"hour"}):b(a,e.length)},k:function(t,e,n){let a=t.getHours();return a===0&&(a=24),e==="ko"?n.ordinalNumber(a,{unit:"hour"}):b(a,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):T.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):T.s(t,e)},S:function(t,e){return T.S(t,e)},X:function(t,e,n){const a=t.getTimezoneOffset();if(a===0)return"Z";switch(e){case"X":return Ft(a);case"XXXX":case"XX":return I(a);case"XXXXX":case"XXX":default:return I(a,":")}},x:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"x":return Ft(a);case"xxxx":case"xx":return I(a);case"xxxxx":case"xxx":default:return I(a,":")}},O:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+zt(a,":");case"OOOO":default:return"GMT"+I(a,":")}},z:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+zt(a,":");case"zzzz":default:return"GMT"+I(a,":")}},t:function(t,e,n){const a=Math.trunc(t.getTime()/1e3);return b(a,e.length)},T:function(t,e,n){const a=t.getTime();return b(a,e.length)}};function zt(t,e=""){const n=t>0?"-":"+",a=Math.abs(t),s=Math.trunc(a/60),r=a%60;return r===0?n+String(s):n+String(s)+e+b(r,2)}function Ft(t,e){return t%60===0?(t>0?"-":"+")+b(Math.abs(t)/60,2):I(t,e)}function I(t,e=""){const n=t>0?"-":"+",a=Math.abs(t),s=b(Math.trunc(a/60),2),r=b(a%60,2);return n+s+e+r}const Ht=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},At=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},_n=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],a=n[1],s=n[2];if(!s)return Ht(t,e);let r;switch(a){case"P":r=e.dateTime({width:"short"});break;case"PP":r=e.dateTime({width:"medium"});break;case"PPP":r=e.dateTime({width:"long"});break;case"PPPP":default:r=e.dateTime({width:"full"});break}return r.replace("{{date}}",Ht(a,e)).replace("{{time}}",At(s,e))},vn={p:At,P:_n},Sn=/^D+$/,Mn=/^Y+$/,Wn=["D","DD","YY","YYYY"];function Dn(t){return Sn.test(t)}function $n(t){return Mn.test(t)}function Tn(t,e,n){const a=Cn(t,e,n);if(console.warn(a),Wn.includes(t))throw new RangeError(a)}function Cn(t,e,n){const a=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${a} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const In=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Pn=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,En=/^'([^]*?)'?$/,On=/''/g,Yn=/[a-zA-Z]/;function Q(t,e,n){const a=j(),s=n?.locale??a.locale??yn,r=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,o=y(t);if(!De(o))throw new RangeError("Invalid time value");let c=e.match(Pn).map(l=>{const h=l[0];if(h==="p"||h==="P"){const d=vn[h];return d(l,s.formatLong)}return l}).join("").match(In).map(l=>{if(l==="''")return{isToken:!1,value:"'"};const h=l[0];if(h==="'")return{isToken:!1,value:Nn(l)};if(Nt[h])return{isToken:!0,value:l};if(h.match(Yn))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:l}});s.localize.preprocessor&&(c=s.localize.preprocessor(o,c));const u={firstWeekContainsDate:r,weekStartsOn:i,locale:s};return c.map(l=>{if(!l.isToken)return l.value;const h=l.value;(!n?.useAdditionalWeekYearTokens&&$n(h)||!n?.useAdditionalDayOfYearTokens&&Dn(h))&&Tn(h,e,String(t));const d=Nt[h[0]];return d(o,h,s.localize,u)}).join("")}function Nn(t){const e=t.match(En);return e?e[1].replace(On,"'"):t}function qt(t){const e=y(t),n=e.getFullYear(),a=e.getMonth(),s=S(t,0);return s.setFullYear(n,a+1,0),s.setHours(0,0,0,0),s.getDate()}function zn(t){const e=y(t).getFullYear();return e%400===0||e%4===0&&e%100!==0}function Bt(t){const e=y(t);return String(new Date(e))==="Invalid Date"?NaN:zn(e)?366:365}function Fn(t){const e=et(t),n=+et(Tt(e,60))-+e;return Math.round(n/U)}function O(t,e){const n=y(t),a=y(e);return+n==+a}function Hn(t){const e=y(t);return e.setMinutes(0,0,0),e}function An(t,e,n){const a=$(t,n),s=$(e,n);return+a==+s}function qn(t,e){const n=y(t),a=y(e);return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()}function Bn(t,e){const n=F(t),a=F(e);return+n==+a}function Ln(t,e){const n=y(t),a=y(e);return n.getFullYear()===a.getFullYear()}const ot=8,Lt=4,Un=3,Ut=7,jn=ot+Lt;function jt(t,e){(t.open||t.type!="summary")&&t.data?.forEach(n=>{n.$x+=e,jt(n,e)})}function ct(t,e,n,a){const s=t.getSummaryId(e.id);if(s){const r=t.byId(s),i={xMin:1/0,xMax:0};Xt(r,i,n,a),r.$x=i.xMin,r.$w=i.xMax-i.xMin,ct(t,r,n,a)}}function Xt(t,e,n,a){const{lengthUnit:s,start:r}=n;t.data?.forEach(i=>{if(!i.unscheduled){typeof i.$x>"u"&&(i.$x=Math.round(n.diff(i.start,r,s)*a),i.$w=Math.round(n.diff(i.end,i.start,s,!0)*a));const o=i.type==="milestone"&&i.$h?i.$h/2:0;e.xMin>i.$x&&(e.xMin=i.$x+o);const c=i.$x+i.$w-o;e.xMax<c&&(e.xMax=c)}i.type!=="summary"&&Xt(i,e,n,a)})}function ut(t,e){let n;e&&(n=e.filter(s=>s.parent==t.id));const a={data:n,...t};if(a.data?.length)a.data.forEach(s=>{if(s.unscheduled&&!s.data)return;(e||s.type!="summary"&&s.data)&&(s.unscheduled&&(s={...s,start:void 0,end:void 0}),s=ut(s,e)),s.start&&(!a.start||a.start>s.start)&&(a.start=new Date(s.start));const r=s.type==="milestone"?s.start:s.end;r&&(!a.end||a.end<r)&&(a.end=new Date(r))});else if(t.type==="summary")throw Error("Summary tasks must have start and end dates if they have no subtasks");return a}function Xn(t,e,n,a,s,r){return Qt(t,e,n,a,s,r,!1),r&&Qt(t,e,n,a,s,r,!0),t}function Qt(t,e,n,a,s,r,i){const{start:o,end:c,lengthUnit:u,diff:l}=s,h=(i?"base_":"")+"start",d=(i?"base_":"")+"end",p="$x"+(i?"_base":""),m="$y"+(i?"_base":""),f="$w"+(i?"_base":""),k="$h"+(i?"_base":""),g="$skip"+(i?"_baseline":"");let w=t[h],x=t[d];if(i&&!w){t[g]=!0;return}t[h]<o&&(t[d]<o||O(t[d],o))?w=x=o:t[h]>c&&(w=x=c),t[p]=Math.round(l(w,o,u)*n),t[m]=i?t.$y+t.$h+Lt:a*e+Un,t[f]=Math.round(l(x,w,u,!0)*n),t[k]=i?ot:r?a-Ut-jn:a-Ut,t.type==="milestone"&&(t[p]=t[p]-t.$h/2,t[f]=t.$h,i&&(t[m]=t.$y+ot,t[f]=t[k]=t.$h)),t.unscheduled&&!i?t.$skip=!0:t[g]=O(w,x)}class Qn extends ue{_sort;constructor(e){super(),this.parse(e,0)}parse(e,n){if(!e||!e.length)return;const a=e.map(s=>this.normalizeTask(s,e));super.parse(a,n),this._sort&&this.sortBranch(this._sort,n)}getBranch(e){const n=this._pool.get(e);return this._pool.get(n.parent||0).data}contains(e,n){const a=this._pool.get(e).data;let s=!1;if(a)for(let r=0;r<a.length;r++){if(a[r].id===n){s=!0;break}if(a[r].data&&(s=this.contains(a[r].id,n),s))break}return s}getIndexById(e){return this.getBranch(e).findIndex(n=>n.id===e)}add(e,n){const a=this.normalizeTask(e);return super.add(a,n),a}copy(e,n,a){const s=this.add({...e,id:null,data:null,parent:n},a);let r=[[e.id,s.id]];return e.data?.forEach((i,o)=>{const c=this.copy(i,s.id,o);r=r.concat(c)}),r}normalizeTask(e,n){const a=e.id||kt(),s=e.parent||0,r=e.text||"",i=e.type||"task",o=e.progress||0,c=e.details||"",u={...e,id:a,text:r,parent:s,progress:o,type:i,details:c};if(u.type==="summary"&&!(u.start&&u.end)){const{start:l,end:h}=ut({...u},n);u.start=l,u.end=h}return u}getSummaryId(e){const n=this._pool.get(e);if(!n.parent)return null;const a=this._pool.get(n.parent);return a.type==="summary"?a.id:this.getSummaryId(a.id)}sort(e){this._sort=e,e&&this.sortBranch(e,0)}sortBranch(e,n){const a=this._pool.get(n||0).data;a&&(ke(a,e),a.forEach(s=>{this.sortBranch(e,s.id)}))}serialize(){const e=[],n=this._pool.get(0).data;return n&&Gt(n,e),e}}function Gt(t,e){t.forEach(n=>{e.push(n),n.data&&Gt(n.data,e)})}const dt={year:Oe,quarter:Ee,month:Pt,week:nt,day:tt,hour:Ce,minute:Ie},C={year:{quarter:4,month:12,week:Fn,day:Gn,hour:Rn},quarter:{month:3,week:Jn,day:Rt,hour:Vn},month:{week:Kn,day:Zn,hour:ta},week:{day:7,hour:24*7},day:{hour:24},hour:{minute:60}};function Gn(t){return t?Bt(t):365}function Rn(t){return Bt(t)*24}function Jn(t){const e=F(t),n=rt(t);return nt(n,e)}function Rt(t){if(t){const e=F(t),n=rt(t);return tt(n,e)}return 91}function Vn(t){return Rt(t)*24}function Kn(t){if(t){const e=Et(t),n=st(t);return nt(n,e)}return 5}function Zn(t){return t?qt(t):30}function ta(t){return qt(t)*24}function G(t,e,n){const a=C[t][e];return a?typeof a=="number"?a:a(n):1}function ea(t,e){return t===e||!!(C[t]&&C[t][e])}const lt={year:Se,quarter:ve,month:Z,week:Tt,day:St,hour:be,minute:_e};function R(t){return(e,n,a,s)=>!C[t][a]||typeof C[t][a]=="number"||Zt(t,e,n)?q(t,e,n,a,s):na(e,n,t,a,s)}function q(t,e,n,a,s){const r=a||t;let i=n,o=e;if(s&&(i=D(r,n),o=D(r,e),o<e&&(o=M(r)(o,1))),t!==r){const c=dt[r](o,i),u=G(t,r,n);return c/u}else return dt[r](o,i)}function na(t,e,n,a,s){let r=0;if(e>D(n,e)){const o=aa(n,e);r=q(n,o,e,a),e=o}let i=0;return Zt(n,e,t)||(i=q(n,D(n,t),e),e=lt[n](e,i)),i+=r+q(n,t,e,a),!i&&s&&(i=q(n,t,e,a,s)),i}function M(t){return lt[t]}const Jt={year:Ot,quarter:F,month:Et,week:t=>$(t,{weekStartsOn:1}),day:N,hour:Hn};function D(t,e){const n=Jt[t];return n?n(e):new Date(e)}const Vt={year:Ye,quarter:rt,month:st,week:t=>ze(t,{weekStartsOn:1}),day:It,hour:Ne};function aa(t,e){const n=Vt[t];return n?n(e):new Date(e)}const Kt={year:Ln,quarter:Bn,month:qn,week:(t,e)=>An(t,e,{weekStartsOn:1}),day:Me};function Zt(t,e,n){const a=Kt[t];return a?a(e,n):!1}const sa={start:Jt,end:Vt,add:lt,isSame:Kt,diff:dt,smallerCount:C},te=t=>typeof t=="function"?t(new Date):t;function ra(t,e){for(const n in e){if(n==="smallerCount"){const a=Object.keys(e[n]).sort((o,c)=>W.indexOf(o)-W.indexOf(c)).shift();let s=W.indexOf(a);const r=e[n][a],i=te(r);for(let o=s-1;o>=0;o--){const c=W[o],u=te(C[c][a]);if(i<=u)break;s=o}W.splice(s,0,t)}if(n==="biggerCount")for(const a in e[n])C[a][t]=e[n][a];else sa[n][t]=e[n]}}function Y(t){const e=new Date;return t.map(n=>({item:n,len:M(n.unit)(e,1)})).sort((n,a)=>n.len<a.len?-1:1)[0].item}const W=["year","quarter","month","week","day","hour"],J={year:"yyyy",quarter:"QQQ",month:"MMM",week:"w",day:"MMM d",hour:"HH:mm"},ht=50,ft=300;function ia(t,e,n,a,s){let r=t,i=e,o=!1,c=!1;s&&s.forEach(l=>{(!t||n)&&(!r||l.start<=r)&&(r=l.start,o=!0);const h=l.type==="milestone"?l.start:l.end;(!e||n)&&(!i||h>=i)&&(i=h,c=!0)});const u=M(a||"day");return r?o&&(r=u(r,-1)):i?r=u(i,-30):r=new Date,i?c&&(i=u(i,1)):i=u(r,30),{_start:r,_end:i}}function oa(t,e,n,a,s,r){const i=Y(r).unit,o=R(i),c=o(e,t,"",!0),u=D(i,e);t=D(i,t),e=u<e?M(i)(u,1):u;const l=c*a,h=s*r.length,d=r.map(m=>{const f=[],k=M(m.unit);let g=D(m.unit,t);for(;g<e;){let w=k(g,m.step);g<t&&(g=t),w>e&&(w=e);const x=o(w,g,"",!0)*a,v=typeof m.format=="function"?m.format(g,w):Q(g,m.format,{firstWeekContainsDate:4,weekStartsOn:1});let _="";m.css&&(_+=typeof m.css=="function"?m.css(g):m.css),f.push({width:x,value:v,date:g,css:_,unit:m.unit}),g=w}return{cells:f,add:k,height:s}});let p=a;return i!==n&&(p=Math.round(p/G(i,n))||1),{rows:d,width:l,height:h,diff:o,start:t,end:e,lengthUnit:n,minUnit:i,lengthUnitWidth:p}}function ca(t,e,n){const a=typeof t=="boolean"?{}:t,s=W.indexOf(Y(e).unit);if(typeof a.level>"u"&&(a.level=s),a.levels)a.levels.forEach(o=>{o.minCellWidth||(o.minCellWidth=V(a.minCellWidth,ht)),o.maxCellWidth||(o.maxCellWidth=V(a.maxCellWidth,ft))});else{const o=[],c=e.length||1,u=V(a.minCellWidth,ht),l=V(a.maxCellWidth,ft);e.forEach(h=>{h.format&&!J[h.unit]&&(J[h.unit]=h.format)}),W.forEach((h,d)=>{if(d===s)o.push({minCellWidth:u,maxCellWidth:l,scales:e});else{const p=[];if(d)for(let m=c-1;m>0;m--){const f=W[d-m];f&&p.push({unit:f,step:1,format:J[f]})}p.push({unit:h,step:1,format:J[h]}),o.push({minCellWidth:u,maxCellWidth:l,scales:p})}}),a.levels=o}a.levels[a.level]||(a.level=0);const r=a.levels[a.level],i=Math.min(Math.max(n,r.minCellWidth),r.maxCellWidth);return{_zoom:a,scales:r.scales,cellWidth:i}}function ua(t,e,n,a,s,r,i){t.level=n;let o;const c=a.scales||a,u=Y(c).unit,l=da(u,s);if(e===-1){const p=G(u,s);o=i*p}else{const p=G(Y(r).unit,u);o=Math.round(i/p)}const h=a.minCellWidth??ht,d=a.maxCellWidth??ft;return{scales:c,cellWidth:Math.min(d,Math.max(h,o)),lengthUnit:l,zoom:t}}function da(t,e){const n=W.indexOf(t),a=W.indexOf(e);return a>=n?t==="hour"?"hour":"day":W[a]}function V(t,e){return t??e}const mt=20,la=function(t,e,n,a,s){const r=Math.round(a/2)-3;if(!e||!n||!e.$y||!n.$y||e.$skip||n.$skip)return t.$p="",t;let i=!1,o=!1;switch(t.type){case"e2s":o=!0;break;case"s2s":i=!0,o=!0;break;case"s2e":i=!0;break}const c=i?e.$x:e.$x+e.$w,u=s?e.$y-7:e.$y,l=o?n.$x:n.$x+n.$w,h=s?n.$y-7:n.$y;if(c!==l||u!==h){const d=ha(c,u+r,l,h+r,i,o,a/2,s),p=fa(l,h+r,o);t.$p=`${d},${p}`}return t};function ha(t,e,n,a,s,r,i,o){const c=mt*(s?-1:1),u=mt*(r?-1:1),l=t+c,h=n+u,d=[t,e,l,e,0,0,0,0,h,a,n,a],p=h-l;let m=a-e;const f=r===s;return f||(h<=t+mt-2&&r||h>t&&!r)&&(m=o?m-i+6:m-i),f&&r&&l>h||f&&!r&&l<h?(d[4]=d[2]+p,d[5]=d[3],d[6]=d[4],d[7]=d[5]+m):(d[4]=d[2],d[5]=d[3]+m,d[6]=d[4]+p,d[7]=d[5]),d.join(",")}function fa(t,e,n){return n?`${t-5},${e-3},${t-5},${e+3},${t},${e}`:`${t+5},${e+3},${t+5},${e-3},${t},${e}`}function ma(t,e,n){if(e&&n){const a=n.x-e.x,s=n.y-e.y,r=(a>0?e.x:n.x)-t.left,i=(s>0?e.y:n.y)-t.top,o=`${a>0?0:-a},${s>0?0:-s},${a>0?a:0},${s>0?s:0}`;return{width:Math.abs(a),height:Math.abs(s),left:r,top:i,p:o}}else return null}const ee=["start","end","duration"];function ga(t,e){const{type:n,unscheduled:a}=t;return a||n==="summary"?!ee.includes(e):n==="milestone"?!["end","duration"].includes(e):!0}function pa(t,e){return typeof e=="function"?e:ee.includes(t)?(typeof e=="string"&&(e={type:e,config:{}}),e.type==="datepicker"&&(e.config.buttons=["today"]),(n,a)=>ga(n,a.id)?e:null):e}function ya(t){return!t||!t.length?[]:t.map(e=>{const n=e.align||"left",a=e.id==="add-task",s=!a&&e.flexgrow?e.flexgrow:null,r=s?1:e.width||(a?50:120);let i=e.template;if(!i)switch(e.id){case"start":i=c=>Q(c,"dd-MM-yyyy");break;case"end":i=c=>c?Q(c,"dd-MM-yyyy"):"-";break}const o=e.editor&&pa(e.id,e.editor);return{width:r,align:n,header:e.header,id:e.id,template:i,...s&&{flexgrow:s},cell:e.cell,resize:e.resize??!0,sort:e.sort??!a,...o&&{editor:o},...e.options&&{options:e.options}}})}const ka=[{id:"text",header:"Task name",flexgrow:1,sort:!0},{id:"start",header:"Start date",align:"center",sort:!0},{id:"duration",header:"Duration",width:100,align:"center",sort:!0},{id:"add-task",header:"Add task",width:50,align:"center",sort:!1,resize:!1}];function wa(){let t=!0;return t=!1,t}function B(t,e,n,a){const{selected:s,tasks:r}=t.getState(),i=s.length,o=!i&&e==="add-task",c=["edit-task","paste-task"],u=["copy-task","cut-task"],l=["copy-task","cut-task","delete-task","indent-task:remove","move-task:down"],h=["indent-task:add","move-task:down","move-task:up"],d={"indent-task:remove":2},p={parent:h.includes(e),level:d[e]};if(n=n||(i?s[s.length-1]:null),!(!n&&!o)){if(e!=="paste-task"&&(t._temp=null),c.includes(e)||o||s.length===1)ne(t,e,n,a);else if(i){const m=u.includes(e)?s:ba(s,r,p);l.includes(e)&&m.reverse(),m.forEach(f=>ne(t,e,f,a))}}}function ba(t,e,n){let a=t.map(s=>{const r=e.byId(s);return{id:s,level:r.$level,parent:r.parent,index:e.getIndexById(s)}});return(n.parent||n.level)&&(a=a.filter(s=>n.level&&s.level<=n.level||!t.includes(s.parent))),a.sort((s,r)=>s.level-r.level||s.index-r.index),a.map(s=>s.id)}function ne(t,e,n,a){const s=t.exec?t.exec:t.in.exec;let r=e.split(":")[0],i=e.split(":")[1],o={id:n},c={};if(r=="copy-task"||r=="cut-task"){t._temp||(t._temp=[]),t._temp.push({id:n,cut:r=="cut-task"});return}else if(r=="paste-task"){t._temp&&t._temp.length&&(t._temp.forEach(u=>{s(u.cut?"move-task":"copy-task",{id:u.id,target:n,mode:"after"})}),t._temp=null);return}else r==="add-task"?(c={task:{type:"task",text:a("New Task")},target:n},o={}):r==="edit-task"?r="show-editor":r==="convert-task"?(r="update-task",c={task:{type:i}},i=void 0):r==="indent-task"&&(i=i==="add");typeof i<"u"&&(c={mode:i,...c}),o={...o,...c},s(r,o)}function ae(t,e){return t.some(n=>n.data?ae(n.data,e):n.id===e)}const xa=t=>M(t),_a=t=>R(t);function se(t,e,n){re(t,e),t.base_start&&re(t,e,!0),K(e,n)}function K(t,e,n,a){t.unscheduled||(n&&va(t,a),ie(t,e)),t.base_start&&ie(t,e,!0)}function re(t,e,n=!1){e.type=e.type||t.type;const[a,s,r]=oe(n);e.type!=="milestone"?(t[s]&&e[a]||(e[a]=t[a]),e[a]&&!(e[r]||e[s])?(e[s]=t[s]>e[a]?t[s]:null,e[s]||(e[r]=1)):e[s]&&!(e[r]||e[a])?(e[a]=t[a]<e[s]?t[a]:e[s],e[a]===e[s]&&(e[r]=1,delete e[s])):e[r]&&!(e[a]||e[s])&&(e[a]=t[a])):(e[s]&&delete e[s],t[s]&&delete t[s])}function ie(t,e="day",n){const[a,s,r]=oe(n);t.type==="milestone"?t[r]=0:t[a]&&(t[r]?t[s]||(t[s]=xa(e)(t[a],t[r])):t[s]?t[r]=_a(e)(t[s],t[a]):(t[s]=t[a],t[r]=0))}function oe(t){return t?["base_start","base_end","base_duration"]:["start","end","duration"]}function va(t,e){e==="duration"&&(t.end=null),t.start&&t.end&&(t.start>=t.end?t.end=null:t.duration=null),t.base_start&&t.base_end&&(t.base_start>=t.base_end?t.base_end=null:t.base_duration=null)}class Sa extends le{in;_router;constructor(e){super({writable:e,async:!1}),this._router=new he(super.setState.bind(this),[{in:["tasks","start","end","scales","autoScale"],out:["_start","_end"],exec:s=>{const{_end:r,_start:i,start:o,end:c,tasks:u,scales:l,autoScale:h}=this.getState();if(!o||!c||h){const d=Y(l).unit,p=ia(o,c,h,d,u);(p._end!=r||p._start!=i)&&this.setState(p,s)}else this.setState({_start:o,_end:c},s)}},{in:["_start","_end","cellWidth","scaleHeight","scales","lengthUnit"],out:["_scales"],exec:s=>{const r=this.getState();let{lengthUnit:i}=r;const{_start:o,_end:c,cellWidth:u,scaleHeight:l,scales:h}=r,d=Y(h).unit;ea(d,i)||(i=d);const p=oa(o,c,i,u,l,h);this.setState({_scales:p},s)}},{in:["_scales","tasks","cellHeight","baselines"],out:["_tasks"],exec:s=>{const{cellWidth:r,cellHeight:i,tasks:o,_scales:c,baselines:u}=this.getState(),l=o.toArray().map((h,d)=>Xn(h,d,r,i,c,u));this.setState({_tasks:l},s)}},{in:["_tasks","links","cellHeight"],out:["_links"],exec:s=>{const{tasks:r,links:i,cellHeight:o,baselines:c}=this.getState(),u=i.map(l=>{const h=r.byId(l.source),d=r.byId(l.target);return la(l,h,d,o,c)}).filter(l=>l!==null);this.setState({_links:u},s)}},{in:["tasks","activeTask"],out:["_activeTask"],exec:s=>{const{tasks:r,activeTask:i}=this.getState();this.setState({_activeTask:r.byId(i)||null},s)}},{in:["tasks","selected"],out:["_selected"],exec:s=>{const{tasks:r,selected:i}=this.getState(),o=i.map(c=>r.byId(c)).filter(c=>!!c);this.setState({_selected:o},s)}},{in:["start","end"],out:["cellWidth"],exec:s=>{const{_cellWidth:r,cellWidth:i}=this.getState();r!=i&&this.setState({cellWidth:r},s)}},{in:["markers","_scales","cellWidth"],out:["_markers"],exec:s=>{const{markers:r,_scales:i,cellWidth:o}=this.getState(),{start:c,diff:u}=i,l=r.map(h=>(h.left=u(h.start,c)*o,h));this.setState({_markers:l},s)}}],{tasks:s=>new Qn(s),links:s=>new wt(s),columns:s=>ya(s)});const n=this.in=new fe;n.on("show-editor",({id:s})=>{this.setStateAsync({activeTask:s})}),n.on("select-task",({id:s,toggle:r,range:i,show:o})=>{const{selected:c,_tasks:u,activeTask:l}=this.getState();let h=!1,d;if(c.length&&(r||i)){const m=[...c];if(i){const f=m[m.length-1],k=u.findIndex(_=>_.id==f),g=u.findIndex(_=>_.id==s),w=Math.min(k,g),x=Math.max(k,g)+1,v=u.slice(w,x).map(_=>_.id);k>g&&v.reverse(),v.forEach(_=>{m.includes(_)||m.push(_)})}else if(r){const f=m.findIndex(k=>k==s);f===-1?m.push(s):(h=!0,m.splice(f,1))}d=m}else d=[s];const p={selected:d};o&&d.length&&(p._scrollTask={id:d[0],mode:o}),this.setStateAsync(p),!h&&l&&l!=s&&n.exec("show-editor",{id:s})}),n.on("delete-link",({id:s})=>{const{links:r}=this.getState();r.remove(s),this.setStateAsync({links:r})}),n.on("update-link",s=>{const{links:r}=this.getState(),{id:i,link:o}=s;r.update(i,o),this.setStateAsync({links:r}),s.link=r.byId(i)}),n.on("add-link",s=>{const{link:r}=s,{links:i}=this.getState();!r.source||!r.target||(r.type||(r.type="e2s"),r.id=r.id||kt(),i.add(r),this.setStateAsync({links:i}),s.id=r.id,s.link=i.byId(r.id))});let a=null;n.on("move-task",s=>{const{tasks:r}=this.getState();let{mode:i,target:o}=s;const{id:c,inProgress:u}=s,l=r.byId(c);if(typeof u>"u"?s.source=l.parent:s.source=a=a??l.parent,u===!1){r.update(l.id,{$reorder:!1}),this.setState({tasks:r}),a=null;return}if(o===c||r.contains(c,o)){s.skipProvider=!0;return}if(i==="up"||i==="down"){const h=r.getBranch(c);let d=r.getIndexById(c);if(i==="up"){const p=l.parent===0;if(d===0&&p){s.skipProvider=!0;return}d-=1,i="before"}else if(i==="down"){const p=d===h.length-1,m=l.parent===0;if(p&&m){s.skipProvider=!0;return}d+=1,i="after"}if(o=h[d]&&h[d].id||l.parent,o){const p=r.getBranch(o);let m=r.getIndexById(o),f=p[m];if(f.data){if(i==="before"){if(f.parent===l.parent){for(;f.data;)f.open||n.exec("open-task",{id:f.id,mode:!0}),f=f.data[f.data.length-1];o=f.id}}else if(i==="after"){let w;f.parent===l.parent?(w=f,f=f.data[0],o=f.id,i="before"):p.length-1!==m&&(w=f,m+=1,f=p[m],l.$level>f.$level&&f.data?(w=f,f=f.data[0],o=f.id,i="before"):o=f.id),w&&!w.open&&n.exec("open-task",{id:w.id,mode:!0})}}const k=r.getSummaryId(l.id);r.move(c,i,o);const g=r.getSummaryId(c);k!=g&&(k&&this.resetSummaryDates(k,"move-task"),g&&this.resetSummaryDates(g,"move-task"))}}else{const h=r.byId(o);let d=h,p=!1;for(;d.$level>l.$level;)d=r.byId(d.parent),d.id===c&&(p=!0);if(p)return;const m=r.getSummaryId(l.id);if(r.move(c,i,o),i=="child"){let k=h;for(;k.id!==0&&!k.open;)n.exec("open-task",{id:k.id,mode:!0}),k=r.byId(k.parent)}const f=r.getSummaryId(c);m!=f&&(m&&this.resetSummaryDates(m,"move-task"),f&&this.resetSummaryDates(f,"move-task"))}u?this.setState({tasks:r}):this.setStateAsync({tasks:r}),s.target=o,s.mode=i}),n.on("drag-task",s=>{const{id:r,width:i,left:o,top:c,inProgress:u}=s,l=this.getState(),{tasks:h,_tasks:d,_selected:p,_scales:m,cellWidth:f}=l,k={_tasks:d,_selected:p},g=h.byId(r);typeof i<"u"&&(g.$w=i,ct(h,g,m,f)),typeof o<"u"&&(g.type==="summary"&&jt(g,o-g.$x),g.$x=o,ct(h,g,m,f)),typeof c<"u"&&(g.$y=c+4,g.$reorder=u),typeof i<"u"&&(g.$w=i),typeof o<"u"&&(g.$x=o),typeof c<"u"&&(g.$y=c+4,g.$reorder=u),this.setState(k)}),n.on("update-task",s=>{const{id:r,task:i,eventSource:o}=s;let c=s.diff;const{tasks:u,_scales:l,durationUnit:h}=this.getState(),d=u.byId(r);if(o==="add-task"||o==="copy-task"||o==="move-task"||o==="update-task"||o==="delete-task"){se(d,i,h),u.update(r,i);return}const p=l.lengthUnit,m=M(p),f=R(p);if(c&&(i.start&&(i.start=m(i.start,c)),i.end&&(i.end=m(i.end,c))),i.start&&i.end){if((!O(i.start,d.start)||!O(i.end,d.end))&&d.type==="summary"&&(!i.type||i.type==="summary")&&d.data?.length){if(!c&&(c=f(i.start,d.start),f(i.end,d.end)!==c))return;this.moveSummaryKids(d,g=>m(g,c),"update-task")}}else if(d.type=="summary"&&(i.start&&!i.end||i.end&&!i.start||i.duration))return;se(d,i,h),u.update(r,i),i.type==="summary"&&d.type!=="summary"&&this.resetSummaryDates(r,"update-task");const k=u.getSummaryId(r);k&&this.resetSummaryDates(k,"update-task"),this.setStateAsync({tasks:u}),s.task=u.byId(r)}),n.on("add-task",s=>{const{tasks:r,_scales:i,baselines:o,unscheduledTasks:c,durationUnit:u}=this.getState(),{target:l,mode:h,task:d,show:p}=s;d.unscheduled=c;let m=-1,f,k;if(l?(k=r.byId(l),h=="child"?(f=k,d.parent=f.id):(k.parent!==null&&(f=r.byId(k.parent),d.parent=f.id),m=r.getIndexById(l),h=="after"&&(m+=1))):d.parent&&(f=r.byId(d.parent)),!d.start){if(f?.start)d.start=new Date(f.start.valueOf());else if(k)d.start=new Date(k.start.valueOf());else{const x=r.getBranch(0);let v;if(x?.length){const _=x[x.length-1];if(!_.$skip){const pt=new Date(_.start.valueOf());i.start<=pt&&(v=pt)}}d.start=v||M(u)(i.start,1)}d.duration=1,o&&(d.base_start=d.start,d.base_duration=d.duration)}K(d,u);const g=r.add(d,m);if(f)for(;f&&f.id;)n.exec("open-task",{id:f.id,mode:!0}),f=r.byId(f.parent);s.id=g.id;const w=r.getSummaryId(g.id);w&&this.resetSummaryDates(w,"add-task"),this.setStateAsync({tasks:r}),n.exec("select-task",{id:g.id,show:p||!1}),s.id=g.id,s.task=g}),n.on("delete-task",s=>{const{id:r}=s,{tasks:i,links:o,selected:c}=this.getState();s.source=i.byId(r).parent;const u=i.getSummaryId(r),l=[r];i.eachChild(d=>l.push(d.id),r),o.filter(d=>!(l.includes(d.source)||l.includes(d.target)));const h={tasks:i,links:o};c.includes(r)&&(h.selected=c.filter(d=>d!==r)),i.remove(r),u&&this.resetSummaryDates(u,"delete-task"),this.setStateAsync(h)}),n.on("indent-task",({id:s,mode:r})=>{const{tasks:i}=this.getState();if(r){const o=i.getBranch(s)[i.getIndexById(s)-1];o&&n.exec("move-task",{id:s,mode:"child",target:o.id})}else{const o=i.byId(s),c=i.byId(o.parent);c&&c.parent!==null&&n.exec("move-task",{id:s,mode:"after",target:o.parent})}}),n.on("copy-task",s=>{const{id:r,target:i,mode:o,eventSource:c}=s;if(c==="copy-task")return;const{tasks:u,links:l}=this.getState();if(u.contains(r,i)){s.skipProvider=!0;return}const h=u.getSummaryId(r),d=u.getSummaryId(i);let p=u.getIndexById(i);o=="before"&&(p-=1);const m=u.byId(r),f=u.copy(m,u.byId(i).parent,p+1);s.source=s.id,s.id=f[0][1],m.lazy&&(s.lazy=!0),h!=d&&d&&this.resetSummaryDates(d,"copy-task");let k=[];for(let g=1;g<f.length;g++){const[w,x]=f[g];l.forEach(v=>{if(v.source===w){const _={...v};delete _.target,k.push({..._,source:x})}else if(v.target===w){const _={...v};delete _.source,k.push({..._,target:x})}})}k=k.reduce((g,w)=>{const x=g.findIndex(v=>v.id===w.id);return x>-1?g[x]={...g[x],...w}:g.push(w),g},[]);for(let g=1;g<f.length;g++){const[w,x]=f[g],v=u.byId(x);n.exec("copy-task",{source:w,id:x,lazy:!!v.lazy,eventSource:"copy-task",target:v.parent,mode:"child"})}k.forEach(g=>{n.exec("add-link",{link:{source:g.source,target:g.target,type:g.type}})}),this.setStateAsync({tasks:u})}),n.on("open-task",({id:s,mode:r})=>{const{tasks:i}=this.getState(),o=i.byId(s);o.lazy?n.exec("request-data",{id:o.id}):(i.toArray().forEach(c=>c.$y=0),i.update(s,{open:r}),this.setState({tasks:i}))}),n.on("scroll-chart",({left:s,top:r})=>{if(!isNaN(s)){const i=this.calcScaleDate(s);this.setState({scrollLeft:s,_scaleDate:i})}isNaN(r)||this.setState({scrollTop:r})}),n.on("render-data",s=>{this.setState({area:s})}),n.on("provide-data",s=>{const{tasks:r,links:i}=this.getState(),o=r.byId(s.id);o.lazy?(o.lazy=!1,o.open=!0):o.data=[],r.parse(s.data.tasks,s.id),this.setStateAsync({tasks:r,links:new wt(i.map(c=>c).concat(s.data.links))})}),n.on("zoom-scale",({dir:s,offset:r})=>{const{zoom:i,cellWidth:o,_cellWidth:c,scrollLeft:u}=this.getState(),l=r+u,h=this.calcScaleDate(l);let d=o;s<0&&(d=c||o);const p=d+s*50,m=i.levels[i.level],f=s<0&&o>m.maxCellWidth;if(p<m.minCellWidth||p>m.maxCellWidth||f){if(!this.changeScale(i,s))return}else this.setState({cellWidth:p,_cellWidth:p});const{_scales:k,_start:g,cellWidth:w}=this.getState(),x=D(k.minUnit,g),v=k.diff(h,x,"hour");typeof r>"u"&&(r=w);let _=Math.round(v*w)-r;_<0&&(_=0),this.setState({scrollLeft:_,_scaleDate:h,_zoomOffset:r})}),n.on("expand-scale",({minWidth:s})=>{const{_start:r,_scales:i,start:o,end:c,_end:u,cellWidth:l,_scaleDate:h,_zoomOffset:d}=this.getState(),p=M(i.minUnit);let m=i.width;if(o&&c){if(m<s&&m){const x=s/m;this.setState({cellWidth:l*x})}return!0}let f=0;for(;m<s;)m+=l,f++;const k=f?c?-f:-1:0,g=o||p(r,k);let w=0;if(h){const x=i.diff(h,g,"hour");w=Math.max(0,Math.round(x*l)-(d||0))}this.setState({_start:g,_end:c||p(u,f),scrollLeft:w})}),n.on("sort-tasks",({key:s,order:r,add:i})=>{const o=this.getState(),{tasks:c}=o;let u=o._sort;const l={key:s,order:r};let h=u?.length||0;h&&i?(u.forEach((d,p)=>{d.key===s&&(h=p)}),u[h]=l):u=[l],c.sort(u),this.setState({_sort:u,tasks:c})}),n.on("hotkey",({key:s,event:r,eventSource:i})=>{switch(s){case"arrowup":case"arrowdown":{const{selected:o,_tasks:c}=this.getState();r.preventDefault();const u=o.length;let l;if(s==="arrowup"?l=u?this.getPrevRow(o[u-1])?.id:c[c.length-1]?.id:l=u?this.getNextRow(o[u-1])?.id:c[0]?.id,l){const h=i==="chart"?"xy":!0;this.in.exec("select-task",{id:l,show:h})}break}case"ctrl+c":{B(this,"copy-task",null,null);break}case"ctrl+x":{B(this,"cut-task",null,null);break}case"ctrl+v":{B(this,"paste-task",null,null);break}case"ctrl+d":case"backspace":{r.preventDefault(),B(this,"delete-task",null,null);break}}})}init(e){const n=this.getState().area?{}:{scrollLeft:0,scrollTop:0,area:{from:0,start:0,end:0}};if(e.cellWidth&&(e._cellWidth=e.cellWidth),e._sort=null,wa()&&(e.unscheduledTasks=!1,e.baselines=!1,e.markers=[]),Array.isArray(e.tasks)&&e.tasks.forEach(a=>K(a,e.durationUnit)),this._router.init({_scrollTask:null,selected:[],markers:[],autoScale:!0,durationUnit:"day",...n,...e}),e.zoom){const a=ca(e.zoom,e.scales,e.cellWidth);this.setState({zoom:a._zoom,cellWidth:a.cellWidth,_cellWidth:a.cellWidth,scales:a.scales})}}setState(e,n){return this._router.setState(e,n)}setStateAsync(e){this._router.setStateAsync(e)}getTask(e){const{tasks:n}=this.getState();return n.byId(e)}serialize(){const{tasks:e}=this.getState();return e.serialize()}changeScale(e,n){const a=e.level+n,s=e.levels[a];if(s){const{cellWidth:r,scales:i,_scales:o}=this.getState(),c=ua(e,n,a,s,o.lengthUnit,i,r);return c._cellWidth=c.cellWidth,this.setState(c),!0}return!1}isScheduled(e){return this.getState().unscheduledTasks?e.some(n=>!n.unscheduled||n.data&&this.isScheduled(n.data)):!0}resetSummaryDates(e,n){const{tasks:a}=this.getState(),s=a.byId(e),r=s.data;if(r?.length&&this.isScheduled(r)){const i=ut({...s,start:void 0,end:void 0,duration:void 0});if(!O(s.start,i.start)||!O(s.end,i.end)){this.in.exec("update-task",{id:e,task:i,eventSource:n});const o=a.getSummaryId(e);o&&this.resetSummaryDates(o,n)}}}moveSummaryKids(e,n,a){const{tasks:s}=this.getState();e.data.forEach(r=>{const i={...s.byId(r.id),start:n(r.start)};i.type!=="milestone"&&(i.end=n(r.end)),delete i.id,this.in.exec("update-task",{id:r.id,task:i,eventSource:a}),r.data?.length&&this.moveSummaryKids(r,n,a)})}calcScaleDate(e){const{_scales:n,_start:a}=this.getState(),s=n.lengthUnit==="day"?n.lengthUnitWidth/24:n.lengthUnitWidth;return M("hour")(D(n.minUnit,a),Math.floor(e/s))}getNextRow(e){const n=this.getState()._tasks,a=n.findIndex(s=>s.id==e);return n[a+1]}getPrevRow(e){const n=this.getState()._tasks,a=n.findIndex(s=>s.id==e);return n[a-1]}}function Ma(t,e,n,a){if(typeof document>"u")return"";const s=document.createElement("canvas");{const r=Wa(s,t,e,1,n);Da(r,a,0,t,0,e)}return s.toDataURL()}function Wa(t,e,n,a,s){t.setAttribute("width",(e*a).toString()),t.setAttribute("height",(n*a).toString());const r=t.getContext("2d");return r.translate(-.5,-.5),r.strokeStyle=s,r}function Da(t,e,n,a,s,r){t.beginPath(),t.moveTo(a,s),t.lineTo(a,r),e==="full"&&t.lineTo(n,r),t.stroke()}function gt(t){return t.map(e=>{switch(e.data&&gt(e.data),e.id){case"add-task:before":case"move-task:up":e.check=(n,a)=>!Ta(n,a);break;case"move-task:down":e.check=(n,a)=>!Ca(n,a);break;case"indent-task:add":e.check=(n,a)=>Ia(n,a)!==n.parent;break;case"indent-task:remove":e.check=n=>!$a(n);break}return e})}function $a(t){return t.parent===0}function Ta(t,e){return e[0]?.id===t.id}function Ca(t,e){return e[e.length-1]?.id===t.id}function Ia(t,e){const n=e.findIndex(a=>a.id===t.id);return e[n-1]?.id??t.parent}const Pa=t=>e=>e.type!==t,Ea=gt([{id:"add-task",text:"Add",icon:"wxi-plus",data:[{id:"add-task:child",text:"Child task"},{id:"add-task:before",text:"Task above"},{id:"add-task:after",text:"Task below"}]},{type:"separator"},{id:"convert-task",text:"Convert to",icon:"wxi-swap-horizontal",dataFactory:t=>({id:`convert-task:${t.id}`,text:`${t.label}`,check:Pa(t.id)})},{id:"edit-task",text:"Edit",icon:"wxi-edit",subtext:"Ctrl+E"},{id:"cut-task",text:"Cut",icon:"wxi-content-cut",subtext:"Ctrl+X"},{id:"copy-task",text:"Copy",icon:"wxi-content-copy",subtext:"Ctrl+C"},{id:"paste-task",text:"Paste",icon:"wxi-content-paste",subtext:"Ctrl+V"},{id:"move-task",text:"Move",icon:"wxi-swap-vertical",data:[{id:"move-task:up",text:"Up"},{id:"move-task:down",text:"Down"}]},{type:"separator"},{id:"indent-task:add",text:"Indent",icon:"wxi-indent"},{id:"indent-task:remove",text:"Outdent",icon:"wxi-unindent"},{type:"separator"},{id:"delete-task",icon:"wxi-delete",text:"Delete",subtext:"Ctrl+D / BS"}]),Oa=gt([{id:"add-task",comp:"button",icon:"wxi-plus",text:"New task",type:"primary"},{id:"edit-task",comp:"icon",icon:"wxi-edit",menuText:"Edit",text:"Ctrl+E"},{id:"delete-task",comp:"icon",icon:"wxi-delete",menuText:"Delete",text:"Ctrl+D, Backspace"},{comp:"separator"},{id:"move-task:up",comp:"icon",icon:"wxi-angle-up",menuText:"Move up"},{id:"move-task:down",comp:"icon",icon:"wxi-angle-down",menuText:"Move down"},{comp:"separator"},{id:"copy-task",comp:"icon",icon:"wxi-content-copy",menuText:"Copy",text:"Ctrl+V"},{id:"cut-task",comp:"icon",icon:"wxi-content-cut",menuText:"Cut",text:"Ctrl+X"},{id:"paste-task",comp:"icon",icon:"wxi-content-paste",menuText:"Paste",text:"Ctrl+V"},{comp:"separator"},{id:"indent-task:add",comp:"icon",icon:"wxi-indent",menuText:"Indent"},{id:"indent-task:remove",comp:"icon",icon:"wxi-unindent",menuText:"Outdent"}]),Ya=[{key:"text",comp:"text",label:"Name",config:{placeholder:"Add task name"}},{key:"details",comp:"textarea",label:"Description",config:{placeholder:"Add description"}},{key:"type",comp:"select",label:"Type"},{key:"start",comp:"date",label:"Start date"},{key:"end",comp:"date",label:"End date"},{key:"duration",comp:"counter",label:"Duration",config:{min:1}},{key:"unscheduled",comp:"twostate",label:"",config:{value:!0,text:"Unschedule",textActive:"Schedule"}},{key:"progress",comp:"slider",label:"Progress",config:{min:1,max:100}},{key:"links",comp:"links",label:""}],Na=[{id:"task",label:"Task"},{id:"summary",label:"Summary task"},{id:"milestone",label:"Milestone"}];export{Sa as DataStore,ka as defaultColumns,Ya as defaultEditorItems,Ea as defaultMenuOptions,Na as defaultTaskTypes,Oa as defaultToolbarButtons,Q as format,M as getAdder,R as getDiffer,D as getUnitStart,Ma as grid,B as handleAction,ae as isHandledAction,K as normalizeDates,ma as placeLink,ra as registerScaleUnit};
1
+ var kt=new Date().valueOf(),oe=()=>kt++;function wt(){return"temp://"+kt++}var bt=class{constructor(t){this._data=t,this._pool=new Map;for(let e=0;e<t.length;e++){const n=t[e];this._pool.set(n.id,n)}}add(t){t={id:oe(),...t},this._data.push(t),this._pool.set(t.id,t)}update(t,e){const n=this._data.findIndex(s=>s.id==t),a={...this._data[n],...e};this._data[n]=a,this._pool.set(a.id,a)}remove(t){this._data=this._data.filter(e=>e.id!=t),this._pool.delete(t)}filter(t){this._data=this._data.filter(e=>{const n=t(e);return n||this._pool.delete(e.id),n})}byId(t){return this._pool.get(t)}map(t){return this._data.map(t)}forEach(t){this._data.forEach(t)}},ce=class{constructor(t){const e={id:0,$level:0,data:[],parent:null},n=new Map;n.set(0,e),this._pool=n,t&&t.length&&this.parse(t,0)}parse(t,e){const n=this._pool;for(let s=0;s<t.length;s++){const r=t[s];r.parent=r.parent||e,r.data=null,n.set(r.id,r)}for(let s=0;s<t.length;s++){const r=t[s],i=n.get(r.parent);i&&(i.data||(i.data=[]),i.data.push(r))}const a=n.get(e);this.setLevel(a,a.$level+1,!1)}add(t,e){const n=this._pool.get(t.parent||0);t.$level=n.$level+1,this._pool.set(t.id,t),n.data?e===-1?n.data=[...n.data,t]:_t(n,e,t):n.data=[t]}addAfter(t,e){if(!e)return this.add(t,-1);const n=this.byId(e),a=this.byId(n.parent),s=L(a,n.id)+1;t.parent=a.id,t.$level=a.$level+1,this.add(t,s)}remove(t){const e=this._pool.get(t);this._remove(e);const n=this._pool.get(e.parent);n.data=n.data.filter(a=>a.id!=t),this._clearBranch(n)}_remove(t){t.data&&t.data.forEach(e=>this._remove(e)),this._pool.delete(t.id)}update(t,e){let n=this._pool.get(t);const a=this._pool.get(n.parent),s=L(a,n.id);n={...n,...e},a&&s>=0&&(a.data[s]=n,a.data=[...a.data]),this._pool.set(n.id,n)}move(t,e,n){const a=this._pool.get(t),s=e==="child",r=this._pool.get(n),i=r.$level+(s?1:0);if(!a||!r)return;const o=this._pool.get(a.parent),c=s?r:this._pool.get(r.parent);c.data||(c.data=[]);const u=L(o,a.id);ue(o,u);const l=s?c.data.length:L(c,r.id)+(e==="after"?1:0);if(_t(c,l,a),o.id===c.id&&u===l)return null;a.parent=c.id,a.$level!==i&&(a.$level=i,this.setLevel(a,i+1,!0)),this.update(a.id,a),this._clearBranch(o)}_clearBranch(t){t.data&&!t.data.length&&(t.open&&delete t.open,this.update(t.id,{data:null}))}toArray(){const t=[],e=this._pool.get(0).data;return e&&xt(e,t),t}byId(t){return this._pool.get(t)}getBranch(t){return this._pool.get(t).data}forEach(t){this._pool.forEach((e,n)=>{n!==0&&t(e)})}eachChild(t,e){const n=this.byId(e);!n||!n.data||n.data.forEach((a,s)=>{t(this.byId(a.id),s),this.eachChild(t,a.id)})}setLevel(t,e,n){t.data&&(t.data=t.data.map(a=>(n&&(a={...a},this._pool.set(a.id,a)),a.$level=e,a.data&&this.setLevel(a,e+1,n),a)))}};function xt(t,e){t.forEach(n=>{e.push(n),n.open===!0&&xt(n.data,e)})}function ue(t,e){const n=[...t.data];n.splice(e,1),t.data=n}function _t(t,e,n){const a=[...t.data];a.splice(e,0,n),t.data=a}function L(t,e){return t?.data.findIndex(n=>n.id===e)}var vt=2,de=class{constructor(t){t&&(this._writable=t.writable,this._async=t.async),this._values={},this._state={}}setState(t,e=0){const n={};return this._wrapProperties(t,this._state,this._values,"",n,e),n}getState(){return this._values}getReactive(){return this._state}_wrapProperties(t,e,n,a,s,r){for(const i in t){const o=e[i],c=n[i],u=t[i];if(o&&(c===u&&typeof u!="object"||u instanceof Date&&c instanceof Date&&c.getTime()===u.getTime()))continue;const l=a+(a?".":"")+i;o?(o.__parse(u,l,s,r)&&(n[i]=u),r&vt?s[l]=o.__trigger:o.__trigger()):(u&&u.__reactive?e[i]=this._wrapNested(u,u,l,s):e[i]=this._wrapWritable(u),n[i]=u),s[l]=s[l]||null}}_wrapNested(t,e,n,a){const s=this._wrapWritable(t);return this._wrapProperties(t,s,e,n,a,0),s.__parse=(r,i,o,c)=>(this._wrapProperties(r,s,e,i,o,c),!1),s}_wrapWritable(t){const e=[],n=function(){for(let a=0;a<e.length;a++)e[a](t)};return{subscribe:a=>(e.push(a),this._async?setTimeout(a,1,t):a(t),()=>{const s=e.indexOf(a);s>=0&&e.splice(s,1)}),__trigger:()=>{e.length&&(this._async?setTimeout(n,1):n())},__parse:function(a){return t=a,!0}}}},le=class{constructor(t,e,n,a){typeof t=="function"?this._setter=t:this._setter=t.setState.bind(t),this._routes=e,this._parsers=n,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(s=>{s.in.forEach(r=>{const i=this._triggers.get(r)||[];i.push(s),this._triggers.set(r,i)}),s.out.forEach(r=>{const i=this._sources.get(r)||{};s.in.forEach(o=>i[o]=!0),this._sources.set(r,i)})}),this._routes.forEach(s=>{s.length=Math.max(...s.in.map(r=>St(r,this._sources,1)))}),this._bus=a}init(t){const e={};for(const n in t)if(this._prev[n]!==t[n]){const a=this._parsers[n];e[n]=a?a(t[n]):t[n]}this._prev=this._prev?{...this._prev,...t}:{...t},this.setState(e),this._bus&&this._bus.exec("init-state",e)}setStateAsync(t){const e=this._setter(t,vt);return this._async?Object.assign(this._async.signals,e):this._async={signals:e,timer:setTimeout(this._applyState.bind(this),1)},e}_applyState(){const t=this._async;if(t){this._async=null,this._triggerUpdates(t.signals,[]);for(const e in t.signals){const n=t.signals[e];n&&n()}}}setState(t,e=[]){const n=this._setter(t);return this._triggerUpdates(n,e),n}_triggerUpdates(t,e){const n=Object.keys(t),a=!e.length;e=e||[];for(let s=0;s<n.length;s++){const r=n[s],i=this._triggers.get(r);i&&i.forEach(o=>{e.indexOf(o)==-1&&e.push(o)})}a&&this._execNext(e)}_execNext(t){for(;t.length;){t.sort((n,a)=>n.length<a.length?1:-1);const e=t[t.length-1];t.splice(t.length-1),e.exec(t)}}};function St(t,e,n){const a=e.get(t);if(!a)return n;const s=Object.keys(a).map(r=>St(r,e,n+1));return Math.max(...s)}var he=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(t,e,n){let a=this._handlers[t];a?n&&n.intercept?a.unshift(e):a.push(e):a=this._handlers[t]=[e],n&&n.tag&&this._tag.set(e,n.tag)}intercept(t,e,n){this.on(t,e,{...n,intercept:!0})}detach(t){for(const e in this._handlers){const n=this._handlers[e];for(let a=n.length-1;a>=0;a--)this._tag.get(n[a])===t&&n.splice(a,1)}}async exec(t,e){const n=this._handlers[t];if(n)for(let a=0;a<n.length;a++){const s=n[a](e);if(s===!1||s&&s.then&&await s===!1)return}return this._nextHandler&&await this._nextHandler.exec(t,e),e}setNext(t){return this._nextHandler=t}};function fe(t,e){return typeof t=="string"?t.localeCompare(e,void 0,{numeric:!0}):typeof t=="object"?t.getTime()-e.getTime():(t??0)-(e??0)}function me(t,e){return typeof t=="string"?-t.localeCompare(e,void 0,{numeric:!0}):typeof e=="object"?e.getTime()-t.getTime():(e??0)-(t??0)}function ge({key:t,order:e}){const n=e==="asc"?fe:me;return(a,s)=>n(a[t],s[t])}function pe(t){if(!t||!t.length)return;const e=t.map(n=>ge(n));return t.length===1?e[0]:function(n,a){for(let s=0;s<e.length;s++){const r=e[s](n,a);if(r!==0)return r}return 0}}function ye(t,e){return t.sort(pe(e))}function y(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function S(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function U(t,e){const n=y(t);return isNaN(e)?S(t,NaN):(e&&n.setDate(n.getDate()+e),n)}function et(t,e){const n=y(t);if(isNaN(e))return S(t,NaN);if(!e)return n;const a=n.getDate(),s=S(t,n.getTime());s.setMonth(n.getMonth()+e+1,0);const r=s.getDate();return a>=r?s:(n.setFullYear(s.getFullYear(),s.getMonth(),a),n)}function Mt(t,e){const n=+y(t);return S(t,n+e)}const j=6048e5,ke=864e5,Wt=6e4,Dt=36e5;function we(t,e){return Mt(t,e*Dt)}let be={};function X(){return be}function $(t,e){const n=X(),a=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=y(t),r=s.getDay(),i=(r<a?7:0)+r-a;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function E(t){return $(t,{weekStartsOn:1})}function $t(t){const e=y(t),n=e.getFullYear(),a=S(t,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const s=E(a),r=S(t,0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);const i=E(r);return e.getTime()>=s.getTime()?n+1:e.getTime()>=i.getTime()?n:n-1}function I(t){const e=y(t);return e.setHours(0,0,0,0),e}function Q(t){const e=y(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function nt(t,e){const n=I(t),a=I(e),s=+n-Q(n),r=+a-Q(a);return Math.round((s-r)/ke)}function at(t){const e=$t(t),n=S(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),E(n)}function xe(t,e){return Mt(t,e*Wt)}function _e(t,e){const n=e*3;return et(t,n)}function Tt(t,e){const n=e*7;return U(t,n)}function ve(t,e){return et(t,e*12)}function z(t,e){const n=y(t),a=y(e),s=n.getTime()-a.getTime();return s<0?-1:s>0?1:s}function Se(t,e){const n=I(t),a=I(e);return+n==+a}function Me(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function We(t){if(!Me(t)&&typeof t!="number")return!1;const e=y(t);return!isNaN(Number(e))}function st(t,e){const n=E(t),a=E(e),s=+n-Q(n),r=+a-Q(a);return Math.round((s-r)/j)}function De(t,e){const n=y(t),a=y(e),s=n.getFullYear()-a.getFullYear(),r=n.getMonth()-a.getMonth();return s*12+r}function $e(t,e){const n=y(t),a=y(e);return n.getFullYear()-a.getFullYear()}function rt(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return n===0?0:n}}function Ct(t,e){return+y(t)-+y(e)}function Te(t,e,n){const a=Ct(t,e)/Dt;return rt(n?.roundingMethod)(a)}function Ce(t,e,n){const a=Ct(t,e)/Wt;return rt(n?.roundingMethod)(a)}function It(t){const e=y(t);return e.setHours(23,59,59,999),e}function it(t){const e=y(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function Ie(t){const e=y(t);return+It(e)==+it(e)}function Pt(t,e){const n=y(t),a=y(e),s=z(n,a),r=Math.abs(De(n,a));let i;if(r<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-s*r);let o=z(n,a)===-s;Ie(y(t))&&r===1&&z(t,a)===1&&(o=!1),i=s*(r-Number(o))}return i===0?0:i}function Pe(t,e,n){const a=Pt(t,e)/3;return rt(n?.roundingMethod)(a)}function Ee(t,e){const n=y(t),a=y(e),s=z(n,a),r=Math.abs($e(n,a));n.setFullYear(1584),a.setFullYear(1584);const i=z(n,a)===-s,o=s*(r-+i);return o===0?0:o}function H(t){const e=y(t),n=e.getMonth(),a=n-n%3;return e.setMonth(a,1),e.setHours(0,0,0,0),e}function Et(t){const e=y(t);return e.setDate(1),e.setHours(0,0,0,0),e}function Oe(t){const e=y(t),n=e.getFullYear();return e.setFullYear(n+1,0,0),e.setHours(23,59,59,999),e}function Ot(t){const e=y(t),n=S(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Ye(t){const e=y(t);return e.setMinutes(59,59,999),e}function Ne(t,e){const n=e?.weekStartsOn,a=y(t),s=a.getDay(),r=(s<n?-7:0)+6-(s-n);return a.setDate(a.getDate()+r),a.setHours(23,59,59,999),a}function ot(t){const e=y(t),n=e.getMonth(),a=n-n%3+3;return e.setMonth(a,0),e.setHours(23,59,59,999),e}const ze={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},He=(t,e,n)=>{let a;const s=ze[t];return typeof s=="string"?a=s:e===1?a=s.one:a=s.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function ct(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const Ae={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Fe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},qe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Be={date:ct({formats:Ae,defaultWidth:"full"}),time:ct({formats:Fe,defaultWidth:"full"}),dateTime:ct({formats:qe,defaultWidth:"full"})},Le={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ue=(t,e,n,a)=>Le[t];function A(t){return(e,n)=>{const a=n?.context?String(n.context):"standalone";let s;if(a==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,o=n?.width?String(n.width):i;s=t.formattingValues[o]||t.formattingValues[i]}else{const i=t.defaultWidth,o=n?.width?String(n.width):t.defaultWidth;s=t.values[o]||t.values[i]}const r=t.argumentCallback?t.argumentCallback(e):e;return s[r]}}const je={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Xe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Qe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Ge={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Re={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Je={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Ve=(t,e)=>{const n=Number(t),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Ke={ordinalNumber:Ve,era:A({values:je,defaultWidth:"wide"}),quarter:A({values:Xe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:A({values:Qe,defaultWidth:"wide"}),day:A({values:Ge,defaultWidth:"wide"}),dayPeriod:A({values:Re,defaultWidth:"wide",formattingValues:Je,defaultFormattingWidth:"wide"})};function F(t){return(e,n={})=>{const a=n.width,s=a&&t.matchPatterns[a]||t.matchPatterns[t.defaultMatchWidth],r=e.match(s);if(!r)return null;const i=r[0],o=a&&t.parsePatterns[a]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(o)?tn(o,h=>h.test(i)):Ze(o,h=>h.test(i));let u;u=t.valueCallback?t.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const l=e.slice(i.length);return{value:u,rest:l}}}function Ze(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function tn(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function en(t){return(e,n={})=>{const a=e.match(t.matchPattern);if(!a)return null;const s=a[0],r=e.match(t.parsePattern);if(!r)return null;let i=t.valueCallback?t.valueCallback(r[0]):r[0];i=n.valueCallback?n.valueCallback(i):i;const o=e.slice(s.length);return{value:i,rest:o}}}const nn=/^(\d+)(th|st|nd|rd)?/i,an=/\d+/i,sn={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},rn={any:[/^b/i,/^(a|c)/i]},on={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},cn={any:[/1/i,/2/i,/3/i,/4/i]},un={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},dn={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ln={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},hn={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},fn={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},mn={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},gn={ordinalNumber:en({matchPattern:nn,parsePattern:an,valueCallback:t=>parseInt(t,10)}),era:F({matchPatterns:sn,defaultMatchWidth:"wide",parsePatterns:rn,defaultParseWidth:"any"}),quarter:F({matchPatterns:on,defaultMatchWidth:"wide",parsePatterns:cn,defaultParseWidth:"any",valueCallback:t=>t+1}),month:F({matchPatterns:un,defaultMatchWidth:"wide",parsePatterns:dn,defaultParseWidth:"any"}),day:F({matchPatterns:ln,defaultMatchWidth:"wide",parsePatterns:hn,defaultParseWidth:"any"}),dayPeriod:F({matchPatterns:fn,defaultMatchWidth:"any",parsePatterns:mn,defaultParseWidth:"any"})},pn={code:"en-US",formatDistance:He,formatLong:Be,formatRelative:Ue,localize:Ke,match:gn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function yn(t){const e=y(t);return nt(e,Ot(e))+1}function kn(t){const e=y(t),n=+E(e)-+at(e);return Math.round(n/j)+1}function Yt(t,e){const n=y(t),a=n.getFullYear(),s=X(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,i=S(t,0);i.setFullYear(a+1,0,r),i.setHours(0,0,0,0);const o=$(i,e),c=S(t,0);c.setFullYear(a,0,r),c.setHours(0,0,0,0);const u=$(c,e);return n.getTime()>=o.getTime()?a+1:n.getTime()>=u.getTime()?a:a-1}function wn(t,e){const n=X(),a=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=Yt(t,e),r=S(t,0);return r.setFullYear(s,0,a),r.setHours(0,0,0,0),$(r,e)}function bn(t,e){const n=y(t),a=+$(n,e)-+wn(n,e);return Math.round(a/j)+1}function b(t,e){const n=t<0?"-":"",a=Math.abs(t).toString().padStart(e,"0");return n+a}const T={y(t,e){const n=t.getFullYear(),a=n>0?n:1-n;return b(e==="yy"?a%100:a,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):b(n+1,2)},d(t,e){return b(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return b(t.getHours()%12||12,e.length)},H(t,e){return b(t.getHours(),e.length)},m(t,e){return b(t.getMinutes(),e.length)},s(t,e){return b(t.getSeconds(),e.length)},S(t,e){const n=e.length,a=t.getMilliseconds(),s=Math.trunc(a*Math.pow(10,n-3));return b(s,e.length)}},O={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Nt={G:function(t,e,n){const a=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});case"GGGG":default:return n.era(a,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const a=t.getFullYear(),s=a>0?a:1-a;return n.ordinalNumber(s,{unit:"year"})}return T.y(t,e)},Y:function(t,e,n,a){const s=Yt(t,a),r=s>0?s:1-s;if(e==="YY"){const i=r%100;return b(i,2)}return e==="Yo"?n.ordinalNumber(r,{unit:"year"}):b(r,e.length)},R:function(t,e){const n=$t(t);return b(n,e.length)},u:function(t,e){const n=t.getFullYear();return b(n,e.length)},Q:function(t,e,n){const a=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(a);case"QQ":return b(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(t,e,n){const a=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(a);case"qq":return b(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(t,e,n){const a=t.getMonth();switch(e){case"M":case"MM":return T.M(t,e);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(t,e,n){const a=t.getMonth();switch(e){case"L":return String(a+1);case"LL":return b(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(t,e,n,a){const s=bn(t,a);return e==="wo"?n.ordinalNumber(s,{unit:"week"}):b(s,e.length)},I:function(t,e,n){const a=kn(t);return e==="Io"?n.ordinalNumber(a,{unit:"week"}):b(a,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):T.d(t,e)},D:function(t,e,n){const a=yn(t);return e==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):b(a,e.length)},E:function(t,e,n){const a=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});case"EEEE":default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(t,e,n,a){const s=t.getDay(),r=(s-a.weekStartsOn+8)%7||7;switch(e){case"e":return String(r);case"ee":return b(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,n,a){const s=t.getDay(),r=(s-a.weekStartsOn+8)%7||7;switch(e){case"c":return String(r);case"cc":return b(r,e.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,n){const a=t.getDay(),s=a===0?7:a;switch(e){case"i":return String(s);case"ii":return b(s,e.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});case"iiii":default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(t,e,n){const a=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,e,n){const a=t.getHours();let s;switch(a===12?s=O.noon:a===0?s=O.midnight:s=a/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,n){const a=t.getHours();let s;switch(a>=17?s=O.evening:a>=12?s=O.afternoon:a>=4?s=O.morning:s=O.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let a=t.getHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return T.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):T.H(t,e)},K:function(t,e,n){const a=t.getHours()%12;return e==="Ko"?n.ordinalNumber(a,{unit:"hour"}):b(a,e.length)},k:function(t,e,n){let a=t.getHours();return a===0&&(a=24),e==="ko"?n.ordinalNumber(a,{unit:"hour"}):b(a,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):T.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):T.s(t,e)},S:function(t,e){return T.S(t,e)},X:function(t,e,n){const a=t.getTimezoneOffset();if(a===0)return"Z";switch(e){case"X":return Ht(a);case"XXXX":case"XX":return P(a);case"XXXXX":case"XXX":default:return P(a,":")}},x:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"x":return Ht(a);case"xxxx":case"xx":return P(a);case"xxxxx":case"xxx":default:return P(a,":")}},O:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+zt(a,":");case"OOOO":default:return"GMT"+P(a,":")}},z:function(t,e,n){const a=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+zt(a,":");case"zzzz":default:return"GMT"+P(a,":")}},t:function(t,e,n){const a=Math.trunc(t.getTime()/1e3);return b(a,e.length)},T:function(t,e,n){const a=t.getTime();return b(a,e.length)}};function zt(t,e=""){const n=t>0?"-":"+",a=Math.abs(t),s=Math.trunc(a/60),r=a%60;return r===0?n+String(s):n+String(s)+e+b(r,2)}function Ht(t,e){return t%60===0?(t>0?"-":"+")+b(Math.abs(t)/60,2):P(t,e)}function P(t,e=""){const n=t>0?"-":"+",a=Math.abs(t),s=b(Math.trunc(a/60),2),r=b(a%60,2);return n+s+e+r}const At=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},Ft=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},xn=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],a=n[1],s=n[2];if(!s)return At(t,e);let r;switch(a){case"P":r=e.dateTime({width:"short"});break;case"PP":r=e.dateTime({width:"medium"});break;case"PPP":r=e.dateTime({width:"long"});break;case"PPPP":default:r=e.dateTime({width:"full"});break}return r.replace("{{date}}",At(a,e)).replace("{{time}}",Ft(s,e))},_n={p:Ft,P:xn},vn=/^D+$/,Sn=/^Y+$/,Mn=["D","DD","YY","YYYY"];function Wn(t){return vn.test(t)}function Dn(t){return Sn.test(t)}function $n(t,e,n){const a=Tn(t,e,n);if(console.warn(a),Mn.includes(t))throw new RangeError(a)}function Tn(t,e,n){const a=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${a} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Cn=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,In=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Pn=/^'([^]*?)'?$/,En=/''/g,On=/[a-zA-Z]/;function G(t,e,n){const a=X(),s=n?.locale??a.locale??pn,r=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,o=y(t);if(!We(o))throw new RangeError("Invalid time value");let c=e.match(In).map(l=>{const h=l[0];if(h==="p"||h==="P"){const d=_n[h];return d(l,s.formatLong)}return l}).join("").match(Cn).map(l=>{if(l==="''")return{isToken:!1,value:"'"};const h=l[0];if(h==="'")return{isToken:!1,value:Yn(l)};if(Nt[h])return{isToken:!0,value:l};if(h.match(On))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:l}});s.localize.preprocessor&&(c=s.localize.preprocessor(o,c));const u={firstWeekContainsDate:r,weekStartsOn:i,locale:s};return c.map(l=>{if(!l.isToken)return l.value;const h=l.value;(!n?.useAdditionalWeekYearTokens&&Dn(h)||!n?.useAdditionalDayOfYearTokens&&Wn(h))&&$n(h,e,String(t));const d=Nt[h[0]];return d(o,h,s.localize,u)}).join("")}function Yn(t){const e=t.match(Pn);return e?e[1].replace(En,"'"):t}function qt(t){const e=y(t),n=e.getFullYear(),a=e.getMonth(),s=S(t,0);return s.setFullYear(n,a+1,0),s.setHours(0,0,0,0),s.getDate()}function Nn(t){const e=y(t).getFullYear();return e%400===0||e%4===0&&e%100!==0}function Bt(t){const e=y(t);return String(new Date(e))==="Invalid Date"?NaN:Nn(e)?366:365}function zn(t){const e=at(t),n=+at(Tt(e,60))-+e;return Math.round(n/j)}function Y(t,e){const n=y(t),a=y(e);return+n==+a}function Hn(t){const e=y(t);return e.setMinutes(0,0,0),e}function An(t,e,n){const a=$(t,n),s=$(e,n);return+a==+s}function Fn(t,e){const n=y(t),a=y(e);return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()}function qn(t,e){const n=H(t),a=H(e);return+n==+a}function Bn(t,e){const n=y(t),a=y(e);return n.getFullYear()===a.getFullYear()}const ut=8,Lt=4,Ln=3,Ut=7,Un=ut+Lt;function jt(t,e){(t.open||t.type!="summary")&&t.data?.forEach(n=>{n.$x+=e,jt(n,e)})}function dt(t,e,n,a){const s=t.getSummaryId(e.id);if(s){const r=t.byId(s),i={xMin:1/0,xMax:0};Xt(r,i,n,a),r.$x=i.xMin,r.$w=i.xMax-i.xMin,dt(t,r,n,a)}}function Xt(t,e,n,a){const{lengthUnit:s,start:r}=n;t.data?.forEach(i=>{if(!i.unscheduled){typeof i.$x>"u"&&(i.$x=Math.round(n.diff(i.start,r,s)*a),i.$w=Math.round(n.diff(i.end,i.start,s,!0)*a));const o=i.type==="milestone"&&i.$h?i.$h/2:0;e.xMin>i.$x&&(e.xMin=i.$x+o);const c=i.$x+i.$w-o;e.xMax<c&&(e.xMax=c)}i.type!=="summary"&&Xt(i,e,n,a)})}function lt(t,e){let n;e&&(n=e.filter(s=>s.parent==t.id));const a={data:n,...t};if(a.data?.length)a.data.forEach(s=>{if(s.unscheduled&&!s.data)return;(e||s.type!="summary"&&s.data)&&(s.unscheduled&&(s={...s,start:void 0,end:void 0}),s=lt(s,e)),s.start&&(!a.start||a.start>s.start)&&(a.start=new Date(s.start));const r=s.type==="milestone"?s.start:s.end;r&&(!a.end||a.end<r)&&(a.end=new Date(r))});else if(t.type==="summary")throw Error("Summary tasks must have start and end dates if they have no subtasks");return a}function jn(t,e,n,a,s,r){return Qt(t,e,n,a,s,r,!1),r&&Qt(t,e,n,a,s,r,!0),t}function Qt(t,e,n,a,s,r,i){const{start:o,end:c,lengthUnit:u,diff:l}=s,h=(i?"base_":"")+"start",d=(i?"base_":"")+"end",p="$x"+(i?"_base":""),m="$y"+(i?"_base":""),f="$w"+(i?"_base":""),k="$h"+(i?"_base":""),g="$skip"+(i?"_baseline":"");let w=t[h],x=t[d];if(i&&!w){t[g]=!0;return}t[h]<o&&(t[d]<o||Y(t[d],o))?w=x=o:t[h]>c&&(w=x=c),t[p]=Math.round(l(w,o,u)*n),t[m]=i?t.$y+t.$h+Lt:a*e+Ln,t[f]=Math.round(l(x,w,u,!0)*n),t[k]=i?ut:r?a-Ut-Un:a-Ut,t.type==="milestone"&&(t[p]=t[p]-t.$h/2,t[f]=t.$h,i&&(t[m]=t.$y+ut,t[f]=t[k]=t.$h)),t.unscheduled&&!i?t.$skip=!0:t[g]=Y(w,x)}class Xn extends ce{_sort;constructor(e){super(),this.parse(e,0)}parse(e,n){if(!e||!e.length)return;const a=e.map(s=>this.normalizeTask(s,e));super.parse(a,n),this._sort&&this.sortBranch(this._sort,n)}getBranch(e){const n=this._pool.get(e);return this._pool.get(n.parent||0).data}contains(e,n){const a=this._pool.get(e).data;let s=!1;if(a)for(let r=0;r<a.length;r++){if(a[r].id===n){s=!0;break}if(a[r].data&&(s=this.contains(a[r].id,n),s))break}return s}getIndexById(e){return this.getBranch(e).findIndex(n=>n.id===e)}add(e,n){const a=this.normalizeTask(e);return super.add(a,n),a}copy(e,n,a){const s=this.add({...e,id:null,data:null,parent:n},a);let r=[[e.id,s.id]];return e.data?.forEach((i,o)=>{const c=this.copy(i,s.id,o);r=r.concat(c)}),r}normalizeTask(e,n){const a=e.id||wt(),s=e.parent||0,r=e.text||"",i=e.type||"task",o=e.progress||0,c=e.details||"",u={...e,id:a,text:r,parent:s,progress:o,type:i,details:c};if(u.type==="summary"&&!(u.start&&u.end)){const{start:l,end:h}=lt({...u},n);u.start=l,u.end=h}return u}getSummaryId(e){const n=this._pool.get(e);if(!n.parent)return null;const a=this._pool.get(n.parent);return a.type==="summary"?a.id:this.getSummaryId(a.id)}sort(e){this._sort=e,e&&this.sortBranch(e,0)}sortBranch(e,n){const a=this._pool.get(n||0).data;a&&(ye(a,e),a.forEach(s=>{this.sortBranch(e,s.id)}))}serialize(){const e=[],n=this._pool.get(0).data;return n&&Gt(n,e),e}}function Gt(t,e){t.forEach(n=>{e.push(n),n.data&&Gt(n.data,e)})}const ht={year:Ee,quarter:Pe,month:Pt,week:st,day:nt,hour:Te,minute:Ce},C={year:{quarter:4,month:12,week:zn,day:Qn,hour:Gn},quarter:{month:3,week:Rn,day:Rt,hour:Jn},month:{week:Vn,day:Kn,hour:Zn},week:{day:7,hour:24*7},day:{hour:24},hour:{minute:60}};function Qn(t){return t?Bt(t):365}function Gn(t){return Bt(t)*24}function Rn(t){const e=H(t),n=U(I(ot(t)),1);return st(n,e)}function Rt(t){if(t){const e=H(t),n=ot(t);return nt(n,e)+1}return 91}function Jn(t){return Rt(t)*24}function Vn(t){if(t){const e=Et(t),n=U(I(it(t)),1);return st(n,e)}return 5}function Kn(t){return t?qt(t):30}function Zn(t){return qt(t)*24}function R(t,e,n){const a=C[t][e];return a?typeof a=="number"?a:a(n):1}function ta(t,e){return t===e||!!(C[t]&&C[t][e])}const J={year:ve,quarter:_e,month:et,week:Tt,day:U,hour:we,minute:xe};function V(t){return(e,n,a,s)=>!C[t][a]||typeof C[t][a]=="number"||Kt(t,e,n)?q(t,e,n,a,s):ea(e,n,t,a,s)}function q(t,e,n,a,s){const r=a||t;let i=n,o=e;if(s&&(i=D(r,n),o=D(r,e),o<e&&(o=M(r)(o,1))),t!==r){const c=ht[r](o,i),u=R(t,r,n);return c/u}else return ht[r](o,i)}function ea(t,e,n,a,s){let r=0;const i=D(n,e);if(e>i){const c=J[n](i,1);r=q(n,c,e,a),e=c}let o=0;return Kt(n,e,t)||(o=q(n,D(n,t),e),e=J[n](e,o)),o+=r+q(n,t,e,a),!o&&s&&(o=q(n,t,e,a,s)),o}function M(t){return J[t]}const Jt={year:Ot,quarter:H,month:Et,week:t=>$(t,{weekStartsOn:1}),day:I,hour:Hn};function D(t,e){const n=Jt[t];return n?n(e):new Date(e)}const na={year:Oe,quarter:ot,month:it,week:t=>Ne(t,{weekStartsOn:1}),day:It,hour:Ye},Vt={year:Bn,quarter:qn,month:Fn,week:(t,e)=>An(t,e,{weekStartsOn:1}),day:Se};function Kt(t,e,n){const a=Vt[t];return a?a(e,n):!1}const aa={start:Jt,end:na,add:J,isSame:Vt,diff:ht,smallerCount:C},Zt=t=>typeof t=="function"?t(new Date):t;function sa(t,e){for(const n in e){if(n==="smallerCount"){const a=Object.keys(e[n]).sort((o,c)=>W.indexOf(o)-W.indexOf(c)).shift();let s=W.indexOf(a);const r=e[n][a],i=Zt(r);for(let o=s-1;o>=0;o--){const c=W[o],u=Zt(C[c][a]);if(i<=u)break;s=o}W.splice(s,0,t)}if(n==="biggerCount")for(const a in e[n])C[a][t]=e[n][a];else aa[n][t]=e[n]}}function N(t){const e=new Date;return t.map(n=>({item:n,len:M(n.unit)(e,1)})).sort((n,a)=>n.len<a.len?-1:1)[0].item}const W=["year","quarter","month","week","day","hour"],K={year:"yyyy",quarter:"QQQ",month:"MMM",week:"w",day:"MMM d",hour:"HH:mm"},ft=50,mt=300;function ra(t,e,n,a,s){let r=t,i=e,o=!1,c=!1;s&&s.forEach(l=>{(!t||n)&&(!r||l.start<=r)&&(r=l.start,o=!0);const h=l.type==="milestone"?l.start:l.end;(!e||n)&&(!i||h>=i)&&(i=h,c=!0)});const u=M(a||"day");return r?o&&(r=u(r,-1)):i?r=u(i,-30):r=new Date,i?c&&(i=u(i,1)):i=u(r,30),{_start:r,_end:i}}function ia(t,e,n,a,s,r){const i=N(r).unit,o=V(i),c=o(e,t,"",!0),u=D(i,e);t=D(i,t),e=u<e?M(i)(u,1):u;const l=c*a,h=s*r.length,d=r.map(m=>{const f=[],k=M(m.unit);let g=D(m.unit,t);for(;g<e;){let w=k(g,m.step);g<t&&(g=t),w>e&&(w=e);const x=o(w,g,"",!0)*a,v=typeof m.format=="function"?m.format(g,w):G(g,m.format,{firstWeekContainsDate:4,weekStartsOn:1});let _="";m.css&&(_+=typeof m.css=="function"?m.css(g):m.css),f.push({width:x,value:v,date:g,css:_,unit:m.unit}),g=w}return{cells:f,add:k,height:s}});let p=a;return i!==n&&(p=Math.round(p/R(i,n))||1),{rows:d,width:l,height:h,diff:o,start:t,end:e,lengthUnit:n,minUnit:i,lengthUnitWidth:p}}function oa(t,e,n){const a=typeof t=="boolean"?{}:t,s=W.indexOf(N(e).unit);if(typeof a.level>"u"&&(a.level=s),a.levels)a.levels.forEach(o=>{o.minCellWidth||(o.minCellWidth=Z(a.minCellWidth,ft)),o.maxCellWidth||(o.maxCellWidth=Z(a.maxCellWidth,mt))});else{const o=[],c=e.length||1,u=Z(a.minCellWidth,ft),l=Z(a.maxCellWidth,mt);e.forEach(h=>{h.format&&!K[h.unit]&&(K[h.unit]=h.format)}),W.forEach((h,d)=>{if(d===s)o.push({minCellWidth:u,maxCellWidth:l,scales:e});else{const p=[];if(d)for(let m=c-1;m>0;m--){const f=W[d-m];f&&p.push({unit:f,step:1,format:K[f]})}p.push({unit:h,step:1,format:K[h]}),o.push({minCellWidth:u,maxCellWidth:l,scales:p})}}),a.levels=o}a.levels[a.level]||(a.level=0);const r=a.levels[a.level],i=Math.min(Math.max(n,r.minCellWidth),r.maxCellWidth);return{_zoom:a,scales:r.scales,cellWidth:i}}function ca(t,e,n,a,s,r,i){t.level=n;let o;const c=a.scales||a,u=N(c).unit,l=ua(u,s);if(e===-1){const p=R(u,s);o=i*p}else{const p=R(N(r).unit,u);o=Math.round(i/p)}const h=a.minCellWidth??ft,d=a.maxCellWidth??mt;return{scales:c,cellWidth:Math.min(d,Math.max(h,o)),lengthUnit:l,zoom:t}}function ua(t,e){const n=W.indexOf(t),a=W.indexOf(e);return a>=n?t==="hour"?"hour":"day":W[a]}function Z(t,e){return t??e}const gt=20,da=function(t,e,n,a,s){const r=Math.round(a/2)-3;if(!e||!n||!e.$y||!n.$y||e.$skip||n.$skip)return t.$p="",t;let i=!1,o=!1;switch(t.type){case"e2s":o=!0;break;case"s2s":i=!0,o=!0;break;case"s2e":i=!0;break}const c=i?e.$x:e.$x+e.$w,u=s?e.$y-7:e.$y,l=o?n.$x:n.$x+n.$w,h=s?n.$y-7:n.$y;if(c!==l||u!==h){const d=la(c,u+r,l,h+r,i,o,a/2,s),p=ha(l,h+r,o);t.$p=`${d},${p}`}return t};function la(t,e,n,a,s,r,i,o){const c=gt*(s?-1:1),u=gt*(r?-1:1),l=t+c,h=n+u,d=[t,e,l,e,0,0,0,0,h,a,n,a],p=h-l;let m=a-e;const f=r===s;return f||(h<=t+gt-2&&r||h>t&&!r)&&(m=o?m-i+6:m-i),f&&r&&l>h||f&&!r&&l<h?(d[4]=d[2]+p,d[5]=d[3],d[6]=d[4],d[7]=d[5]+m):(d[4]=d[2],d[5]=d[3]+m,d[6]=d[4]+p,d[7]=d[5]),d.join(",")}function ha(t,e,n){return n?`${t-5},${e-3},${t-5},${e+3},${t},${e}`:`${t+5},${e+3},${t+5},${e-3},${t},${e}`}function fa(t,e,n){if(e&&n){const a=n.x-e.x,s=n.y-e.y,r=(a>0?e.x:n.x)-t.left,i=(s>0?e.y:n.y)-t.top,o=`${a>0?0:-a},${s>0?0:-s},${a>0?a:0},${s>0?s:0}`;return{width:Math.abs(a),height:Math.abs(s),left:r,top:i,p:o}}else return null}const te=["start","end","duration"];function ma(t,e){const{type:n,unscheduled:a}=t;return a||n==="summary"?!te.includes(e):n==="milestone"?!["end","duration"].includes(e):!0}function ga(t,e){return typeof e=="function"?e:te.includes(t)?(typeof e=="string"&&(e={type:e,config:{}}),e.config||(e.config={}),e.type==="datepicker"&&(e.config.buttons=["today"]),(n,a)=>ma(n,a.id)?e:null):e}function pa(t){return!t||!t.length?[]:t.map(e=>{const n=e.align||"left",a=e.id==="add-task",s=!a&&e.flexgrow?e.flexgrow:null,r=s?1:e.width||(a?50:120);let i=e.template;if(!i)switch(e.id){case"start":i=c=>G(c,"dd-MM-yyyy");break;case"end":i=c=>c?G(c,"dd-MM-yyyy"):"-";break}const o=e.editor&&ga(e.id,e.editor);return{width:r,align:n,header:e.header,id:e.id,template:i,...s&&{flexgrow:s},cell:e.cell,resize:e.resize??!0,sort:e.sort??!a,...o&&{editor:o},...e.options&&{options:e.options}}})}const ya=[{id:"text",header:"Task name",flexgrow:1,sort:!0},{id:"start",header:"Start date",align:"center",sort:!0},{id:"duration",header:"Duration",width:100,align:"center",sort:!0},{id:"add-task",header:"Add task",width:50,align:"center",sort:!1,resize:!1}];function ka(){let t=!0;return t=!1,t}function B(t,e,n,a){const{selected:s,tasks:r}=t.getState(),i=s.length,o=!i&&e==="add-task",c=["edit-task","paste-task"],u=["copy-task","cut-task"],l=["copy-task","cut-task","delete-task","indent-task:remove","move-task:down"],h=["indent-task:add","move-task:down","move-task:up"],d={"indent-task:remove":2},p={parent:h.includes(e),level:d[e]};if(n=n||(i?s[s.length-1]:null),!(!n&&!o)){if(e!=="paste-task"&&(t._temp=null),c.includes(e)||o||s.length===1)ee(t,e,n,a);else if(i){const m=u.includes(e)?s:wa(s,r,p);l.includes(e)&&m.reverse(),m.forEach(f=>ee(t,e,f,a))}}}function wa(t,e,n){let a=t.map(s=>{const r=e.byId(s);return{id:s,level:r.$level,parent:r.parent,index:e.getIndexById(s)}});return(n.parent||n.level)&&(a=a.filter(s=>n.level&&s.level<=n.level||!t.includes(s.parent))),a.sort((s,r)=>s.level-r.level||s.index-r.index),a.map(s=>s.id)}function ee(t,e,n,a){const s=t.exec?t.exec:t.in.exec;let r=e.split(":")[0],i=e.split(":")[1],o={id:n},c={};if(r=="copy-task"||r=="cut-task"){t._temp||(t._temp=[]),t._temp.push({id:n,cut:r=="cut-task"});return}else if(r=="paste-task"){t._temp&&t._temp.length&&(t._temp.forEach(u=>{s(u.cut?"move-task":"copy-task",{id:u.id,target:n,mode:"after"})}),t._temp=null);return}else r==="add-task"?(c={task:{type:"task",text:a("New Task")},target:n},o={}):r==="edit-task"?r="show-editor":r==="convert-task"?(r="update-task",c={task:{type:i}},i=void 0):r==="indent-task"&&(i=i==="add");typeof i<"u"&&(c={mode:i,...c}),o={...o,...c},s(r,o)}function ne(t,e){return t.some(n=>n.data?ne(n.data,e):n.id===e)}const ba=t=>M(t),xa=t=>V(t);function ae(t,e,n){se(t,e),t.base_start&&se(t,e,!0),tt(e,n)}function tt(t,e,n,a){t.unscheduled||(n&&_a(t,a),re(t,e)),t.base_start&&re(t,e,!0)}function se(t,e,n=!1){e.type=e.type||t.type;const[a,s,r]=ie(n);e.type!=="milestone"?(t[s]&&e[a]||(e[a]=t[a]),e[a]&&!(e[r]||e[s])?(e[s]=t[s]>e[a]?t[s]:null,e[s]||(e[r]=1)):e[s]&&!(e[r]||e[a])?(e[a]=t[a]<e[s]?t[a]:e[s],e[a]===e[s]&&(e[r]=1,delete e[s])):e[r]&&!(e[a]||e[s])&&(e[a]=t[a])):(e[s]&&delete e[s],t[s]&&delete t[s])}function re(t,e="day",n){const[a,s,r]=ie(n);t.type==="milestone"?t[r]=0:t[a]&&(t[r]?t[s]||(t[s]=ba(e)(t[a],t[r])):t[s]?t[r]=xa(e)(t[s],t[a]):(t[s]=t[a],t[r]=0))}function ie(t){return t?["base_start","base_end","base_duration"]:["start","end","duration"]}function _a(t,e){e==="duration"&&(t.end=null),t.start&&t.end&&(t.start>=t.end?t.end=null:t.duration=null),t.base_start&&t.base_end&&(t.base_start>=t.base_end?t.base_end=null:t.base_duration=null)}class va extends de{in;_router;constructor(e){super({writable:e,async:!1}),this._router=new le(super.setState.bind(this),[{in:["tasks","start","end","scales","autoScale"],out:["_start","_end"],exec:s=>{const{_end:r,_start:i,start:o,end:c,tasks:u,scales:l,autoScale:h}=this.getState();if(!o||!c||h){const d=N(l).unit,p=ra(o,c,h,d,u);(p._end!=r||p._start!=i)&&this.setState(p,s)}else this.setState({_start:o,_end:c},s)}},{in:["_start","_end","cellWidth","scaleHeight","scales","lengthUnit"],out:["_scales"],exec:s=>{const r=this.getState();let{lengthUnit:i}=r;const{_start:o,_end:c,cellWidth:u,scaleHeight:l,scales:h}=r,d=N(h).unit;ta(d,i)||(i=d);const p=ia(o,c,i,u,l,h);this.setState({_scales:p},s)}},{in:["_scales","tasks","cellHeight","baselines"],out:["_tasks"],exec:s=>{const{cellWidth:r,cellHeight:i,tasks:o,_scales:c,baselines:u}=this.getState(),l=o.toArray().map((h,d)=>jn(h,d,r,i,c,u));this.setState({_tasks:l},s)}},{in:["_tasks","links","cellHeight"],out:["_links"],exec:s=>{const{tasks:r,links:i,cellHeight:o,baselines:c}=this.getState(),u=i.map(l=>{const h=r.byId(l.source),d=r.byId(l.target);return da(l,h,d,o,c)}).filter(l=>l!==null);this.setState({_links:u},s)}},{in:["tasks","activeTask"],out:["_activeTask"],exec:s=>{const{tasks:r,activeTask:i}=this.getState();this.setState({_activeTask:r.byId(i)||null},s)}},{in:["tasks","selected"],out:["_selected"],exec:s=>{const{tasks:r,selected:i}=this.getState(),o=i.map(c=>r.byId(c)).filter(c=>!!c);this.setState({_selected:o},s)}},{in:["start","end"],out:["cellWidth"],exec:s=>{const{_cellWidth:r,cellWidth:i}=this.getState();r!=i&&this.setState({cellWidth:r},s)}},{in:["markers","_scales","cellWidth"],out:["_markers"],exec:s=>{const{markers:r,_scales:i,cellWidth:o}=this.getState(),{start:c,diff:u}=i,l=r.map(h=>(h.left=u(h.start,c)*o,h));this.setState({_markers:l},s)}}],{tasks:s=>new Xn(s),links:s=>new bt(s),columns:s=>pa(s)});const n=this.in=new he;n.on("show-editor",({id:s})=>{this.setStateAsync({activeTask:s})}),n.on("select-task",({id:s,toggle:r,range:i,show:o})=>{const{selected:c,_tasks:u,activeTask:l}=this.getState();let h=!1,d;if(c.length&&(r||i)){const m=[...c];if(i){const f=m[m.length-1],k=u.findIndex(_=>_.id==f),g=u.findIndex(_=>_.id==s),w=Math.min(k,g),x=Math.max(k,g)+1,v=u.slice(w,x).map(_=>_.id);k>g&&v.reverse(),v.forEach(_=>{m.includes(_)||m.push(_)})}else if(r){const f=m.findIndex(k=>k==s);f===-1?m.push(s):(h=!0,m.splice(f,1))}d=m}else d=[s];const p={selected:d};o&&d.length&&(p._scrollTask={id:d[0],mode:o}),this.setStateAsync(p),!h&&l&&l!=s&&n.exec("show-editor",{id:s})}),n.on("delete-link",({id:s})=>{const{links:r}=this.getState();r.remove(s),this.setStateAsync({links:r})}),n.on("update-link",s=>{const{links:r}=this.getState(),{id:i,link:o}=s;r.update(i,o),this.setStateAsync({links:r}),s.link=r.byId(i)}),n.on("add-link",s=>{const{link:r}=s,{links:i}=this.getState();!r.source||!r.target||(r.type||(r.type="e2s"),r.id=r.id||wt(),i.add(r),this.setStateAsync({links:i}),s.id=r.id,s.link=i.byId(r.id))});let a=null;n.on("move-task",s=>{const{tasks:r}=this.getState();let{mode:i,target:o}=s;const{id:c,inProgress:u}=s,l=r.byId(c);if(typeof u>"u"?s.source=l.parent:s.source=a=a??l.parent,u===!1){r.update(l.id,{$reorder:!1}),this.setState({tasks:r}),a=null;return}if(o===c||r.contains(c,o)){s.skipProvider=!0;return}if(i==="up"||i==="down"){const h=r.getBranch(c);let d=r.getIndexById(c);if(i==="up"){const p=l.parent===0;if(d===0&&p){s.skipProvider=!0;return}d-=1,i="before"}else if(i==="down"){const p=d===h.length-1,m=l.parent===0;if(p&&m){s.skipProvider=!0;return}d+=1,i="after"}if(o=h[d]&&h[d].id||l.parent,o){const p=r.getBranch(o);let m=r.getIndexById(o),f=p[m];if(f.data){if(i==="before"){if(f.parent===l.parent){for(;f.data;)f.open||n.exec("open-task",{id:f.id,mode:!0}),f=f.data[f.data.length-1];o=f.id}}else if(i==="after"){let w;f.parent===l.parent?(w=f,f=f.data[0],o=f.id,i="before"):p.length-1!==m&&(w=f,m+=1,f=p[m],l.$level>f.$level&&f.data?(w=f,f=f.data[0],o=f.id,i="before"):o=f.id),w&&!w.open&&n.exec("open-task",{id:w.id,mode:!0})}}const k=r.getSummaryId(l.id);r.move(c,i,o);const g=r.getSummaryId(c);k!=g&&(k&&this.resetSummaryDates(k,"move-task"),g&&this.resetSummaryDates(g,"move-task"))}}else{const h=r.byId(o);let d=h,p=!1;for(;d.$level>l.$level;)d=r.byId(d.parent),d.id===c&&(p=!0);if(p)return;const m=r.getSummaryId(l.id);if(r.move(c,i,o),i=="child"){let k=h;for(;k.id!==0&&!k.open;)n.exec("open-task",{id:k.id,mode:!0}),k=r.byId(k.parent)}const f=r.getSummaryId(c);m!=f&&(m&&this.resetSummaryDates(m,"move-task"),f&&this.resetSummaryDates(f,"move-task"))}u?this.setState({tasks:r}):this.setStateAsync({tasks:r}),s.target=o,s.mode=i}),n.on("drag-task",s=>{const{id:r,width:i,left:o,top:c,inProgress:u}=s,l=this.getState(),{tasks:h,_tasks:d,_selected:p,_scales:m,cellWidth:f}=l,k={_tasks:d,_selected:p},g=h.byId(r);typeof i<"u"&&(g.$w=i,dt(h,g,m,f)),typeof o<"u"&&(g.type==="summary"&&jt(g,o-g.$x),g.$x=o,dt(h,g,m,f)),typeof c<"u"&&(g.$y=c+4,g.$reorder=u),typeof i<"u"&&(g.$w=i),typeof o<"u"&&(g.$x=o),typeof c<"u"&&(g.$y=c+4,g.$reorder=u),this.setState(k)}),n.on("update-task",s=>{const{id:r,task:i,eventSource:o}=s;let c=s.diff;const{tasks:u,_scales:l,durationUnit:h}=this.getState(),d=u.byId(r);if(o==="add-task"||o==="copy-task"||o==="move-task"||o==="update-task"||o==="delete-task"){ae(d,i,h),u.update(r,i);return}const p=l.lengthUnit,m=M(p),f=V(p);if(c&&(i.start&&(i.start=m(i.start,c)),i.end&&(i.end=m(i.end,c))),i.start&&i.end){if((!Y(i.start,d.start)||!Y(i.end,d.end))&&d.type==="summary"&&(!i.type||i.type==="summary")&&d.data?.length){if(!c&&(c=f(i.start,d.start),f(i.end,d.end)!==c))return;this.moveSummaryKids(d,g=>m(g,c),"update-task")}}else if(d.type=="summary"&&(i.start&&!i.end||i.end&&!i.start||i.duration))return;ae(d,i,h),u.update(r,i),i.type==="summary"&&d.type!=="summary"&&this.resetSummaryDates(r,"update-task");const k=u.getSummaryId(r);k&&this.resetSummaryDates(k,"update-task"),this.setStateAsync({tasks:u}),s.task=u.byId(r)}),n.on("add-task",s=>{const{tasks:r,_scales:i,baselines:o,unscheduledTasks:c,durationUnit:u}=this.getState(),{target:l,mode:h,task:d,show:p}=s;d.unscheduled=c;let m=-1,f,k;if(l?(k=r.byId(l),h=="child"?(f=k,d.parent=f.id):(k.parent!==null&&(f=r.byId(k.parent),d.parent=f.id),m=r.getIndexById(l),h=="after"&&(m+=1))):d.parent&&(f=r.byId(d.parent)),!d.start){if(f?.start)d.start=new Date(f.start.valueOf());else if(k)d.start=new Date(k.start.valueOf());else{const x=r.getBranch(0);let v;if(x?.length){const _=x[x.length-1];if(!_.$skip){const yt=new Date(_.start.valueOf());i.start<=yt&&(v=yt)}}d.start=v||M(u)(i.start,1)}d.duration=1,o&&(d.base_start=d.start,d.base_duration=d.duration)}tt(d,u);const g=r.add(d,m);if(f)for(;f&&f.id;)n.exec("open-task",{id:f.id,mode:!0}),f=r.byId(f.parent);s.id=g.id;const w=r.getSummaryId(g.id);w&&this.resetSummaryDates(w,"add-task"),this.setStateAsync({tasks:r}),n.exec("select-task",{id:g.id,show:p||!1}),s.id=g.id,s.task=g}),n.on("delete-task",s=>{const{id:r}=s,{tasks:i,links:o,selected:c}=this.getState();s.source=i.byId(r).parent;const u=i.getSummaryId(r),l=[r];i.eachChild(d=>l.push(d.id),r),o.filter(d=>!(l.includes(d.source)||l.includes(d.target)));const h={tasks:i,links:o};c.includes(r)&&(h.selected=c.filter(d=>d!==r)),i.remove(r),u&&this.resetSummaryDates(u,"delete-task"),this.setStateAsync(h)}),n.on("indent-task",({id:s,mode:r})=>{const{tasks:i}=this.getState();if(r){const o=i.getBranch(s)[i.getIndexById(s)-1];o&&n.exec("move-task",{id:s,mode:"child",target:o.id})}else{const o=i.byId(s),c=i.byId(o.parent);c&&c.parent!==null&&n.exec("move-task",{id:s,mode:"after",target:o.parent})}}),n.on("copy-task",s=>{const{id:r,target:i,mode:o,eventSource:c}=s;if(c==="copy-task")return;const{tasks:u,links:l}=this.getState();if(u.contains(r,i)){s.skipProvider=!0;return}const h=u.getSummaryId(r),d=u.getSummaryId(i);let p=u.getIndexById(i);o=="before"&&(p-=1);const m=u.byId(r),f=u.copy(m,u.byId(i).parent,p+1);s.source=s.id,s.id=f[0][1],m.lazy&&(s.lazy=!0),h!=d&&d&&this.resetSummaryDates(d,"copy-task");let k=[];for(let g=1;g<f.length;g++){const[w,x]=f[g];l.forEach(v=>{if(v.source===w){const _={...v};delete _.target,k.push({..._,source:x})}else if(v.target===w){const _={...v};delete _.source,k.push({..._,target:x})}})}k=k.reduce((g,w)=>{const x=g.findIndex(v=>v.id===w.id);return x>-1?g[x]={...g[x],...w}:g.push(w),g},[]);for(let g=1;g<f.length;g++){const[w,x]=f[g],v=u.byId(x);n.exec("copy-task",{source:w,id:x,lazy:!!v.lazy,eventSource:"copy-task",target:v.parent,mode:"child"})}k.forEach(g=>{n.exec("add-link",{link:{source:g.source,target:g.target,type:g.type}})}),this.setStateAsync({tasks:u})}),n.on("open-task",({id:s,mode:r})=>{const{tasks:i}=this.getState(),o=i.byId(s);o.lazy?n.exec("request-data",{id:o.id}):(i.toArray().forEach(c=>c.$y=0),i.update(s,{open:r}),this.setState({tasks:i}))}),n.on("scroll-chart",({left:s,top:r})=>{if(!isNaN(s)){const i=this.calcScaleDate(s);this.setState({scrollLeft:s,_scaleDate:i})}isNaN(r)||this.setState({scrollTop:r})}),n.on("render-data",s=>{this.setState({area:s})}),n.on("provide-data",s=>{const{tasks:r,links:i}=this.getState(),o=r.byId(s.id);o.lazy?(o.lazy=!1,o.open=!0):o.data=[],r.parse(s.data.tasks,s.id),this.setStateAsync({tasks:r,links:new bt(i.map(c=>c).concat(s.data.links))})}),n.on("zoom-scale",({dir:s,offset:r})=>{const{zoom:i,cellWidth:o,_cellWidth:c,scrollLeft:u}=this.getState(),l=r+u,h=this.calcScaleDate(l);let d=o;s<0&&(d=c||o);const p=d+s*50,m=i.levels[i.level],f=s<0&&o>m.maxCellWidth;if(p<m.minCellWidth||p>m.maxCellWidth||f){if(!this.changeScale(i,s))return}else this.setState({cellWidth:p,_cellWidth:p});const{_scales:k,_start:g,cellWidth:w}=this.getState(),x=D(k.minUnit,g),v=k.diff(h,x,"hour");typeof r>"u"&&(r=w);let _=Math.round(v*w)-r;_<0&&(_=0),this.setState({scrollLeft:_,_scaleDate:h,_zoomOffset:r})}),n.on("expand-scale",({minWidth:s})=>{const{_start:r,_scales:i,start:o,end:c,_end:u,cellWidth:l,_scaleDate:h,_zoomOffset:d}=this.getState(),p=M(i.minUnit);let m=i.width;if(o&&c){if(m<s&&m){const x=s/m;this.setState({cellWidth:l*x})}return!0}let f=0;for(;m<s;)m+=l,f++;const k=f?c?-f:-1:0,g=o||p(r,k);let w=0;if(h){const x=i.diff(h,g,"hour");w=Math.max(0,Math.round(x*l)-(d||0))}this.setState({_start:g,_end:c||p(u,f),scrollLeft:w})}),n.on("sort-tasks",({key:s,order:r,add:i})=>{const o=this.getState(),{tasks:c}=o;let u=o._sort;const l={key:s,order:r};let h=u?.length||0;h&&i?(u.forEach((d,p)=>{d.key===s&&(h=p)}),u[h]=l):u=[l],c.sort(u),this.setState({_sort:u,tasks:c})}),n.on("hotkey",({key:s,event:r,eventSource:i})=>{switch(s){case"arrowup":case"arrowdown":{const{selected:o,_tasks:c}=this.getState();r.preventDefault();const u=o.length;let l;if(s==="arrowup"?l=u?this.getPrevRow(o[u-1])?.id:c[c.length-1]?.id:l=u?this.getNextRow(o[u-1])?.id:c[0]?.id,l){const h=i==="chart"?"xy":!0;this.in.exec("select-task",{id:l,show:h})}break}case"ctrl+c":{B(this,"copy-task",null,null);break}case"ctrl+x":{B(this,"cut-task",null,null);break}case"ctrl+v":{B(this,"paste-task",null,null);break}case"ctrl+d":case"backspace":{r.preventDefault(),B(this,"delete-task",null,null);break}}})}init(e){const n=this.getState().area?{}:{scrollLeft:0,scrollTop:0,area:{from:0,start:0,end:0}};if(e.cellWidth&&(e._cellWidth=e.cellWidth),e._sort=null,ka()&&(e.unscheduledTasks=!1,e.baselines=!1,e.markers=[]),Array.isArray(e.tasks)&&e.tasks.forEach(a=>tt(a,e.durationUnit)),this._router.init({_scrollTask:null,selected:[],markers:[],autoScale:!0,durationUnit:"day",...n,...e}),e.zoom){const a=oa(e.zoom,e.scales,e.cellWidth);this.setState({zoom:a._zoom,cellWidth:a.cellWidth,_cellWidth:a.cellWidth,scales:a.scales})}}setState(e,n){return this._router.setState(e,n)}setStateAsync(e){this._router.setStateAsync(e)}getTask(e){const{tasks:n}=this.getState();return n.byId(e)}serialize(){const{tasks:e}=this.getState();return e.serialize()}changeScale(e,n){const a=e.level+n,s=e.levels[a];if(s){const{cellWidth:r,scales:i,_scales:o}=this.getState(),c=ca(e,n,a,s,o.lengthUnit,i,r);return c._cellWidth=c.cellWidth,this.setState(c),!0}return!1}isScheduled(e){return this.getState().unscheduledTasks?e.some(n=>!n.unscheduled||n.data&&this.isScheduled(n.data)):!0}resetSummaryDates(e,n){const{tasks:a}=this.getState(),s=a.byId(e),r=s.data;if(r?.length&&this.isScheduled(r)){const i=lt({...s,start:void 0,end:void 0,duration:void 0});if(!Y(s.start,i.start)||!Y(s.end,i.end)){this.in.exec("update-task",{id:e,task:i,eventSource:n});const o=a.getSummaryId(e);o&&this.resetSummaryDates(o,n)}}}moveSummaryKids(e,n,a){const{tasks:s}=this.getState();e.data.forEach(r=>{const i={...s.byId(r.id),start:n(r.start)};i.type!=="milestone"&&(i.end=n(r.end)),delete i.id,this.in.exec("update-task",{id:r.id,task:i,eventSource:a}),r.data?.length&&this.moveSummaryKids(r,n,a)})}calcScaleDate(e){const{_scales:n,_start:a}=this.getState(),s=n.lengthUnit==="day"?n.lengthUnitWidth/24:n.lengthUnitWidth;return M("hour")(D(n.minUnit,a),Math.floor(e/s))}getNextRow(e){const n=this.getState()._tasks,a=n.findIndex(s=>s.id==e);return n[a+1]}getPrevRow(e){const n=this.getState()._tasks,a=n.findIndex(s=>s.id==e);return n[a-1]}}function Sa(t,e,n,a){if(typeof document>"u")return"";const s=document.createElement("canvas");{const r=Ma(s,t,e,1,n);Wa(r,a,0,t,0,e)}return s.toDataURL()}function Ma(t,e,n,a,s){t.setAttribute("width",(e*a).toString()),t.setAttribute("height",(n*a).toString());const r=t.getContext("2d");return r.translate(-.5,-.5),r.strokeStyle=s,r}function Wa(t,e,n,a,s,r){t.beginPath(),t.moveTo(a,s),t.lineTo(a,r),e==="full"&&t.lineTo(n,r),t.stroke()}function pt(t){return t.map(e=>{switch(e.data&&pt(e.data),e.id){case"add-task:before":case"move-task:up":e.check=(n,a)=>!$a(n,a);break;case"move-task:down":e.check=(n,a)=>!Ta(n,a);break;case"indent-task:add":e.check=(n,a)=>Ca(n,a)!==n.parent;break;case"indent-task:remove":e.check=n=>!Da(n);break}return e})}function Da(t){return t.parent===0}function $a(t,e){return e[0]?.id===t.id}function Ta(t,e){return e[e.length-1]?.id===t.id}function Ca(t,e){const n=e.findIndex(a=>a.id===t.id);return e[n-1]?.id??t.parent}const Ia=t=>e=>e.type!==t,Pa=pt([{id:"add-task",text:"Add",icon:"wxi-plus",data:[{id:"add-task:child",text:"Child task"},{id:"add-task:before",text:"Task above"},{id:"add-task:after",text:"Task below"}]},{type:"separator"},{id:"convert-task",text:"Convert to",icon:"wxi-swap-horizontal",dataFactory:t=>({id:`convert-task:${t.id}`,text:`${t.label}`,check:Ia(t.id)})},{id:"edit-task",text:"Edit",icon:"wxi-edit",subtext:"Ctrl+E"},{id:"cut-task",text:"Cut",icon:"wxi-content-cut",subtext:"Ctrl+X"},{id:"copy-task",text:"Copy",icon:"wxi-content-copy",subtext:"Ctrl+C"},{id:"paste-task",text:"Paste",icon:"wxi-content-paste",subtext:"Ctrl+V"},{id:"move-task",text:"Move",icon:"wxi-swap-vertical",data:[{id:"move-task:up",text:"Up"},{id:"move-task:down",text:"Down"}]},{type:"separator"},{id:"indent-task:add",text:"Indent",icon:"wxi-indent"},{id:"indent-task:remove",text:"Outdent",icon:"wxi-unindent"},{type:"separator"},{id:"delete-task",icon:"wxi-delete",text:"Delete",subtext:"Ctrl+D / BS"}]),Ea=pt([{id:"add-task",comp:"button",icon:"wxi-plus",text:"New task",type:"primary"},{id:"edit-task",comp:"icon",icon:"wxi-edit",menuText:"Edit",text:"Ctrl+E"},{id:"delete-task",comp:"icon",icon:"wxi-delete",menuText:"Delete",text:"Ctrl+D, Backspace"},{comp:"separator"},{id:"move-task:up",comp:"icon",icon:"wxi-angle-up",menuText:"Move up"},{id:"move-task:down",comp:"icon",icon:"wxi-angle-down",menuText:"Move down"},{comp:"separator"},{id:"copy-task",comp:"icon",icon:"wxi-content-copy",menuText:"Copy",text:"Ctrl+V"},{id:"cut-task",comp:"icon",icon:"wxi-content-cut",menuText:"Cut",text:"Ctrl+X"},{id:"paste-task",comp:"icon",icon:"wxi-content-paste",menuText:"Paste",text:"Ctrl+V"},{comp:"separator"},{id:"indent-task:add",comp:"icon",icon:"wxi-indent",menuText:"Indent"},{id:"indent-task:remove",comp:"icon",icon:"wxi-unindent",menuText:"Outdent"}]),Oa=[{key:"text",comp:"text",label:"Name",config:{placeholder:"Add task name"}},{key:"details",comp:"textarea",label:"Description",config:{placeholder:"Add description"}},{key:"type",comp:"select",label:"Type"},{key:"start",comp:"date",label:"Start date"},{key:"end",comp:"date",label:"End date"},{key:"duration",comp:"counter",label:"Duration",config:{min:1}},{key:"unscheduled",comp:"twostate",label:"",config:{value:!0,text:"Unschedule",textActive:"Schedule"}},{key:"progress",comp:"slider",label:"Progress",config:{min:1,max:100}},{key:"links",comp:"links",label:""}],Ya=[{id:"task",label:"Task"},{id:"summary",label:"Summary task"},{id:"milestone",label:"Milestone"}];export{va as DataStore,ya as defaultColumns,Oa as defaultEditorItems,Pa as defaultMenuOptions,Ya as defaultTaskTypes,Ea as defaultToolbarButtons,G as format,M as getAdder,V as getDiffer,D as getUnitStart,Sa as grid,B as handleAction,ne as isHandledAction,tt as normalizeDates,fa as placeLink,sa as registerScaleUnit};