@svar-ui/gantt-store 2.7.2 → 2.8.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 Ft=new Date().valueOf(),je=()=>Ft++;function Nt(){return"temp://"+Ft++}function Le(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in t){const s=e[n],r=t[n];if(!J(s,r))return!1}return!0}function J(e,t){if(typeof e=="number"||typeof e=="string"||typeof e=="boolean"||e===null)return e===t;if(typeof e!=typeof t||(e===null||t===null)&&e!==t||e instanceof Date&&t instanceof Date&&e.getTime()!==t.getTime())return!1;if(typeof e=="object")if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=e.length-1;n>=0;n--)if(!J(e[n],t[n]))return!1;return!0}else return Le(e,t);return e===t}var K=class{constructor(e){this._data=e,this._pool=new Map;for(let t=0;t<e.length;t++){const n=e[t];this._pool.set(n.id,n)}}add(e){e={id:je(),...e},this._data.push(e),this._pool.set(e.id,e)}update(e,t){const n=this._data.findIndex(r=>r.id==e),s={...this._data[n],...t};this._data[n]=s,this._pool.set(s.id,s)}remove(e){this._data=this._data.filter(t=>t.id!=e),this._pool.delete(e)}filter(e){this._data=this._data.filter(t=>{const n=e(t);return n||this._pool.delete(t.id),n})}byId(e){return this._pool.get(e)}map(e){return this._data.map(e)}forEach(e){this._data.forEach(e)}},zt=class{constructor(e){const t={id:0,$level:0,data:[],parent:null},n=new Map;n.set(0,t),this._pool=n,e&&e.length&&this.parse(e,0)}parse(e,t){const n=this._pool;for(let r=0;r<e.length;r++){const a=e[r];a.parent=a.parent||t,a.data=null,n.set(a.id,a)}for(let r=0;r<e.length;r++){const a=e[r],i=n.get(a.parent);i&&(i.data||(i.data=[]),i.data.push(a))}const s=n.get(t);this.setLevel(s,s.$level+1,!1)}add(e,t){const n=this._pool.get(e.parent||0);e.$level=n.$level+1,this._pool.set(e.id,e),n.data?t===-1?n.data=[...n.data,e]:Yt(n,t,e):n.data=[e]}addAfter(e,t){if(!t)return this.add(e,-1);const n=this.byId(t),s=this.byId(n.parent),r=Z(s,n.id)+1;e.parent=s.id,e.$level=s.$level+1,this.add(e,r)}remove(e){const t=this._pool.get(e);this._remove(t);const n=this._pool.get(t.parent);n.data=n.data.filter(s=>s.id!=e),this._clearBranch(n)}_remove(e){e.data&&e.data.forEach(t=>this._remove(t)),this._pool.delete(e.id)}update(e,t){let n=this._pool.get(e);const s=this._pool.get(n.parent),r=Z(s,n.id);n={...n,...t},s&&r>=0&&(s.data[r]=n,s.data=[...s.data]),this._pool.set(n.id,n)}move(e,t,n){const s=this._pool.get(e),r=t==="child",a=this._pool.get(n),i=a.$level+(r?1:0);if(!s||!a)return;const c=this._pool.get(s.parent),o=r?a:this._pool.get(a.parent);o.data||(o.data=[]);const d=Z(c,s.id);Ue(c,d);const l=r?o.data.length:Z(o,a.id)+(t==="after"?1:0);if(Yt(o,l,s),c.id===o.id&&d===l)return null;s.parent=o.id,s.$level!==i&&(s.$level=i,this.setLevel(s,i+1,!0)),this.update(s.id,s),this._clearBranch(c)}_clearBranch(e){e.data&&!e.data.length&&(e.open&&delete e.open,this.update(e.id,{data:null}))}toArray(){const e=[],t=this._pool.get(0).data;return t&&Bt(t,e),e}byId(e){return this._pool.get(e)}getBranch(e){return this._pool.get(e).data}forEach(e){this._pool.forEach((t,n)=>{n!==0&&e(t)})}eachChild(e,t){const n=this.byId(t);!n||!n.data||n.data.forEach((s,r)=>{e(this.byId(s.id),r),this.eachChild(e,s.id)})}setLevel(e,t,n){e.data&&(e.data=e.data.map(s=>(n&&(s={...s},this._pool.set(s.id,s)),s.$level=t,s.data&&this.setLevel(s,t+1,n),s)))}};function Bt(e,t){e.forEach(n=>{t.push(n),n.open===!0&&Bt(n.data,t)})}function Ue(e,t){const n=[...e.data];n.splice(t,1),e.data=n}function Yt(e,t,n){const s=[...e.data];s.splice(t,0,n),e.data=s}function Z(e,t){return e?.data.findIndex(n=>n.id===t)}var jt=2,qe=class{constructor(e){e&&(this._writable=e.writable,this._async=e.async),this._values={},this._state={}}setState(e,t=0){const n={};return this._wrapProperties(e,this._state,this._values,"",n,t),n}getState(){return this._values}getReactive(){return this._state}_wrapProperties(e,t,n,s,r,a){for(const i in e){const c=t[i],o=n[i],d=e[i];if(c&&(o===d&&typeof d!="object"||d instanceof Date&&o instanceof Date&&o.getTime()===d.getTime()))continue;const l=s+(s?".":"")+i;c?(c.__parse(d,l,r,a)&&(n[i]=d),a&jt?r[l]=c.__trigger:c.__trigger()):(d&&d.__reactive?t[i]=this._wrapNested(d,d,l,r):t[i]=this._wrapWritable(d),n[i]=d),r[l]=r[l]||null}}_wrapNested(e,t,n,s){const r=this._wrapWritable(e);return this._wrapProperties(e,r,t,n,s,0),r.__parse=(a,i,c,o)=>(this._wrapProperties(a,r,t,i,c,o),!1),r}_wrapWritable(e){const t=[],n=function(){for(let s=0;s<t.length;s++)t[s](e)};return{subscribe:s=>(t.push(s),this._async?setTimeout(s,1,e):s(e),()=>{const r=t.indexOf(s);r>=0&&t.splice(r,1)}),__trigger:()=>{t.length&&(this._async?setTimeout(n,1):n())},__parse:function(s){return e=s,!0}}}},Xe=class{constructor(e,t,n,s){typeof e=="function"?this._setter=e:this._setter=e.setState.bind(e),this._routes=t,this._parsers=n,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(r=>{r.in.forEach(a=>{const i=this._triggers.get(a)||[];i.push(r),this._triggers.set(a,i)}),r.out.forEach(a=>{const i=this._sources.get(a)||{};r.in.forEach(c=>i[c]=!0),this._sources.set(a,i)})}),this._routes.forEach(r=>{r.length=Math.max(...r.in.map(a=>Lt(a,this._sources,1)))}),this._bus=s}init(e){const t={};for(const n in e)if(this._prev[n]!==e[n]){const s=this._parsers[n];t[n]=s?s(e[n]):e[n]}this._prev=this._prev?{...this._prev,...e}:{...e},this.setState(t),this._bus&&this._bus.exec("init-state",t)}setStateAsync(e){const t=this._setter(e,jt);return this._async?Object.assign(this._async.signals,t):this._async={signals:t,timer:setTimeout(this._applyState.bind(this),1)},t}_applyState(){const e=this._async;if(e){this._async=null,this._triggerUpdates(e.signals,[]);for(const t in e.signals){const n=e.signals[t];n&&n()}}}setState(e,t=[]){const n=this._setter(e);return this._triggerUpdates(n,t),n}_triggerUpdates(e,t){const n=Object.keys(e),s=!t.length;t=t||[];for(let r=0;r<n.length;r++){const a=n[r],i=this._triggers.get(a);i&&i.forEach(c=>{t.indexOf(c)==-1&&t.push(c)})}s&&this._execNext(t)}_execNext(e){for(;e.length;){e.sort((n,s)=>n.length<s.length?1:-1);const t=e[e.length-1];e.splice(e.length-1),t.exec(e)}}};function Lt(e,t,n){const s=t.get(e);if(!s)return n;const r=Object.keys(s).map(a=>Lt(a,t,n+1));return Math.max(...r)}var Ge=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(e,t,n){let s=this._handlers[e];s?n&&n.intercept?s.unshift(t):s.push(t):s=this._handlers[e]=[t],n&&n.tag&&this._tag.set(t,n.tag)}intercept(e,t,n){this.on(e,t,{...n,intercept:!0})}detach(e){for(const t in this._handlers){const n=this._handlers[t];for(let s=n.length-1;s>=0;s--)this._tag.get(n[s])===e&&n.splice(s,1)}}async exec(e,t){const n=this._handlers[e];if(n)for(let s=0;s<n.length;s++){const r=n[s](t);if(r===!1||r&&r.then&&await r===!1)return}return this._nextHandler&&await this._nextHandler.exec(e,t),t}setNext(e){return this._nextHandler=e}};new Date().valueOf();function Re(e){return t=>t[e]}function lt(e,t){return(t.getter||Re(t.id))(e)}const Qe={text:(e,t)=>e?e.toString().toLowerCase().indexOf(t.toLowerCase())!==-1:!t,richselect:(e,t)=>typeof t!="number"&&!t?!0:e==t,datepicker:(e,t)=>t?e&&Ke(e,t):!0,multiselect:(e,t)=>!t||t?.length===0?!0:Array.isArray(e)?e?.some(n=>t.includes(n)):e&&t.includes(e)};function Ve(e){return Qe[e]}function Je(e,t){const n=[];for(const s in e){const r=t.find(o=>o.id==s),{config:a,type:i}=r.header.find(o=>o.filter).filter,c=e[s];n.push(o=>{const d=lt(o,r);return a?.handler?a.handler(d,c):Ve(i)(d,c)})}return s=>{for(let r=0;r<n.length;r++)if(!n[r](s))return!1;return!0}}function Ke(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}new Date().valueOf(),new Date().valueOf();function Ze(e,t){return typeof e=="string"?e.localeCompare(t,void 0,{numeric:!0}):e instanceof Date||t instanceof Date?e?t?e.getTime()-t.getTime():-1:1:(e??0)-(t??0)}function tn(e,t){return typeof e=="string"?-e.localeCompare(t,void 0,{numeric:!0}):e instanceof Date||t instanceof Date?t?e?t.getTime()-e.getTime():-1:1:(t??0)-(e??0)}function en({order:e,key:t},n){if(typeof n?.sort=="function")return function(r,a){const i=n.sort(r,a);return e==="asc"?i:-i};const s=e==="asc"?Ze:tn;return(r,a)=>s(n?lt(r,n):r[t],n?lt(a,n):a[t])}function nn(e,t){if(!e||!e.length)return;const n=e.map(s=>{const r=t.find(a=>a.id==s.key);return en(s,r)});return e.length===1?n[0]:function(s,r){for(let a=0;a<n.length;a++){const i=n[a](s,r);if(i!==0)return i}return 0}}function sn(e,t,n){return e.sort(nn(t,n))}function Ut(e,t,n,s){const r=e.id===0||t(e);let a=!1;if(Array.isArray(e.data)){for(const i of e.data)Ut(i,t,n,s)&&(a=!0);a?(delete e.$empty,s&&(e.open=!0)):e.$empty=!0}return(r||a)&&e.id!==0?(n.add(e.id),!0):!1}function qt(e,t,n){e.has(t)&&e.delete(t),n?.length&&n.forEach(s=>qt(e,s.id,s.data))}function Xt(e){e.id!==0&&delete e.$empty,Array.isArray(e.data)&&e.data.forEach(t=>Xt(t))}class Gt extends zt{_filteredIds;constructor(t){super(),this.parse(t,0)}parse(t,n){if(!t||!t.length)return;const s=t.map(r=>this.normalizeTask(r));super.parse(s,n)}getBranch(t){const n=this._pool.get(t);return this._pool.get(n.parent||0).data}contains(t,n){const s=this._pool.get(t).data;let r=!1;if(s)for(let a=0;a<s.length;a++){if(s[a].id===n){r=!0;break}if(s[a].data&&(r=this.contains(s[a].id,n),r))break}return r}getIndexById(t){return this.getBranch(t).findIndex(n=>n.id===t)}add(t,n){const s=this.normalizeTask(t);if(super.add(s,n),this._filteredIds&&this._filteredIds.add(s.id),this._filteredIds&&t.parent){const r=this.byId(t.parent);this.hasChildItems(r)&&delete r.$empty}return s}copy(t,n,s){const r=this.add({...t,id:null,data:null,parent:n},s);let a=[[t.id,r.id]];return t.data?.forEach((i,c)=>{const o=this.copy(i,r.id,c);a=a.concat(o)}),a}remove(t){const n=this.byId(t);if(this._filteredIds&&qt(this._filteredIds,t,n.data),super.remove(t),this._filteredIds&&n.parent){const s=this.byId(n.parent);this.hasChildItems(s)||(s.$empty=!0)}}normalizeTask(t){const n=t.id||Nt(),s=t.parent||0,r=t.text??"",a=t.type||"task",i=t.progress||0,c=t.details||"",o={...t,id:n,text:r,parent:s,progress:i,type:a,details:c};return t.segments&&(o.segments=t.segments.map(d=>({...d}))),t.segments&&(o.segments=t.segments.map(d=>({...d}))),o}getSummaryId(t,n=!1){const s=this._pool.get(t);if(!s.parent)return null;const r=this._pool.get(s.parent);if(n){let a=t,i=this.getSummaryId(a);const c=[];for(;i;)a=i,c.push(i),i=this.getSummaryId(a);return c}return r.type==="summary"?r.id:this.getSummaryId(r.id)}sort(t,n){t&&this.sortBranch(t,0,n)}sortBranch(t,n,s){const r=this._pool.get(n||0).data;r&&(sn(r,t,s),r.forEach(a=>{this.sortBranch(t,a.id,s)}))}serialize(){const t=[],n=this._pool.get(0).data;return n&&Rt(n,t),t}clear(){this.forEach(t=>{this.remove(t.id)})}filterTree(t,n){if(t){const s=this._pool.get(0),r=new Set;Ut(s,t,r,n),this._filteredIds=r}else{const s=this._pool.get(0);Xt(s),this._filteredIds=null}}toArray(t){let n=super.toArray();return!t&&this._filteredIds&&(n=n.filter(s=>this.isFilteredId(s.id))),n}isFilteredId(t){return this._filteredIds?.has(t)}hasChildItems(t){const n=t.data?.length;return n&&this._filteredIds?t.data.some(s=>this.isFilteredId(s.id)):!!n}}function Rt(e,t){e.forEach(n=>{t.push(n),n.data&&Rt(n.data,t)})}function x(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function W(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function tt(e,t){const n=x(e);return isNaN(t)?W(e,NaN):(t&&n.setDate(n.getDate()+t),n)}function ut(e,t){const n=x(e);if(isNaN(t))return W(e,NaN);if(!t)return n;const s=n.getDate(),r=W(e,n.getTime());r.setMonth(n.getMonth()+t+1,0);const a=r.getDate();return s>=a?r:(n.setFullYear(r.getFullYear(),r.getMonth(),s),n)}function Qt(e,t){const n=+x(e);return W(e,n+t)}const et=6048e5,an=864e5,Vt=6e4,Jt=36e5;function rn(e,t){return Qt(e,t*Jt)}let on={};function U(){return on}function E(e,t){const n=U(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=x(e),a=r.getDay(),i=(a<s?7:0)+a-s;return r.setDate(r.getDate()-i),r.setHours(0,0,0,0),r}function B(e){return E(e,{weekStartsOn:1})}function Kt(e){const t=x(e),n=t.getFullYear(),s=W(e,0);s.setFullYear(n+1,0,4),s.setHours(0,0,0,0);const r=B(s),a=W(e,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);const i=B(a);return t.getTime()>=r.getTime()?n+1:t.getTime()>=i.getTime()?n:n-1}function A(e){const t=x(e);return t.setHours(0,0,0,0),t}function nt(e){const t=x(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function ht(e,t){const n=A(e),s=A(t),r=+n-nt(n),a=+s-nt(s);return Math.round((r-a)/an)}function ft(e){const t=Kt(e),n=W(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),B(n)}function cn(e,t){return Qt(e,t*Vt)}function dn(e,t){const n=t*3;return ut(e,n)}function Zt(e,t){const n=t*7;return tt(e,n)}function ln(e,t){return ut(e,t*12)}function q(e,t){const n=x(e),s=x(t),r=n.getTime()-s.getTime();return r<0?-1:r>0?1:r}function un(e,t){const n=A(e),s=A(t);return+n==+s}function hn(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function fn(e){if(!hn(e)&&typeof e!="number")return!1;const t=x(e);return!isNaN(Number(t))}function gt(e,t){const n=B(e),s=B(t),r=+n-nt(n),a=+s-nt(s);return Math.round((r-a)/et)}function gn(e,t){const n=x(e),s=x(t),r=n.getFullYear()-s.getFullYear(),a=n.getMonth()-s.getMonth();return r*12+a}function mn(e,t){const n=x(e),s=x(t);return n.getFullYear()-s.getFullYear()}function mt(e){return t=>{const n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function te(e,t){return+x(e)-+x(t)}function pn(e,t,n){const s=te(e,t)/Jt;return mt(n?.roundingMethod)(s)}function yn(e,t,n){const s=te(e,t)/Vt;return mt(n?.roundingMethod)(s)}function ee(e){const t=x(e);return t.setHours(23,59,59,999),t}function pt(e){const t=x(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function kn(e){const t=x(e);return+ee(t)==+pt(t)}function ne(e,t){const n=x(e),s=x(t),r=q(n,s),a=Math.abs(gn(n,s));let i;if(a<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let c=q(n,s)===-r;kn(x(e))&&a===1&&q(e,s)===1&&(c=!1),i=r*(a-Number(c))}return i===0?0:i}function _n(e,t,n){const s=ne(e,t)/3;return mt(n?.roundingMethod)(s)}function wn(e,t){const n=x(e),s=x(t),r=q(n,s),a=Math.abs(mn(n,s));n.setFullYear(1584),s.setFullYear(1584);const i=q(n,s)===-r,c=r*(a-+i);return c===0?0:c}function X(e){const t=x(e),n=t.getMonth(),s=n-n%3;return t.setMonth(s,1),t.setHours(0,0,0,0),t}function se(e){const t=x(e);return t.setDate(1),t.setHours(0,0,0,0),t}function bn(e){const t=x(e),n=t.getFullYear();return t.setFullYear(n+1,0,0),t.setHours(23,59,59,999),t}function ae(e){const t=x(e),n=W(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function xn(e){const t=x(e);return t.setMinutes(59,59,999),t}function Sn(e,t){const n=U(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=x(e),a=r.getDay(),i=(a<s?-7:0)+6-(a-s);return r.setDate(r.getDate()+i),r.setHours(23,59,59,999),r}function yt(e){const t=x(e),n=t.getMonth(),s=n-n%3+3;return t.setMonth(s,0),t.setHours(23,59,59,999),t}const vn={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"}},Mn=(e,t,n)=>{let s;const r=vn[e];return typeof r=="string"?s=r:t===1?s=r.one:s=r.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+s:s+" ago":s};function kt(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Tn={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},$n={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Dn={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Wn={date:kt({formats:Tn,defaultWidth:"full"}),time:kt({formats:$n,defaultWidth:"full"}),dateTime:kt({formats:Dn,defaultWidth:"full"})},In={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Cn=(e,t,n,s)=>In[e];function G(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let r;if(s==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,c=n?.width?String(n.width):i;r=e.formattingValues[c]||e.formattingValues[i]}else{const i=e.defaultWidth,c=n?.width?String(n.width):e.defaultWidth;r=e.values[c]||e.values[i]}const a=e.argumentCallback?e.argumentCallback(t):t;return r[a]}}const Pn={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},En={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},On={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"]},An={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"]},Hn={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"}},Fn={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"}},Nn=(e,t)=>{const n=Number(e),s=n%100;if(s>20||s<10)switch(s%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},zn={ordinalNumber:Nn,era:G({values:Pn,defaultWidth:"wide"}),quarter:G({values:En,defaultWidth:"wide",argumentCallback:e=>e-1}),month:G({values:On,defaultWidth:"wide"}),day:G({values:An,defaultWidth:"wide"}),dayPeriod:G({values:Hn,defaultWidth:"wide",formattingValues:Fn,defaultFormattingWidth:"wide"})};function R(e){return(t,n={})=>{const s=n.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],a=t.match(r);if(!a)return null;const i=a[0],c=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],o=Array.isArray(c)?Yn(c,f=>f.test(i)):Bn(c,f=>f.test(i));let d;d=e.valueCallback?e.valueCallback(o):o,d=n.valueCallback?n.valueCallback(d):d;const l=t.slice(i.length);return{value:d,rest:l}}}function Bn(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Yn(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function jn(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],a=t.match(e.parsePattern);if(!a)return null;let i=e.valueCallback?e.valueCallback(a[0]):a[0];i=n.valueCallback?n.valueCallback(i):i;const c=t.slice(r.length);return{value:i,rest:c}}}const Ln=/^(\d+)(th|st|nd|rd)?/i,Un=/\d+/i,qn={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},Xn={any:[/^b/i,/^(a|c)/i]},Gn={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Rn={any:[/1/i,/2/i,/3/i,/4/i]},Qn={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},Vn={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]},Jn={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},Kn={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]},Zn={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},ts={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}},es={ordinalNumber:jn({matchPattern:Ln,parsePattern:Un,valueCallback:e=>parseInt(e,10)}),era:R({matchPatterns:qn,defaultMatchWidth:"wide",parsePatterns:Xn,defaultParseWidth:"any"}),quarter:R({matchPatterns:Gn,defaultMatchWidth:"wide",parsePatterns:Rn,defaultParseWidth:"any",valueCallback:e=>e+1}),month:R({matchPatterns:Qn,defaultMatchWidth:"wide",parsePatterns:Vn,defaultParseWidth:"any"}),day:R({matchPatterns:Jn,defaultMatchWidth:"wide",parsePatterns:Kn,defaultParseWidth:"any"}),dayPeriod:R({matchPatterns:Zn,defaultMatchWidth:"any",parsePatterns:ts,defaultParseWidth:"any"})},ns={code:"en-US",formatDistance:Mn,formatLong:Wn,formatRelative:Cn,localize:zn,match:es,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ss(e){const t=x(e);return ht(t,ae(t))+1}function as(e){const t=x(e),n=+B(t)-+ft(t);return Math.round(n/et)+1}function re(e,t){const n=x(e),s=n.getFullYear(),r=U(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,i=W(e,0);i.setFullYear(s+1,0,a),i.setHours(0,0,0,0);const c=E(i,t),o=W(e,0);o.setFullYear(s,0,a),o.setHours(0,0,0,0);const d=E(o,t);return n.getTime()>=c.getTime()?s+1:n.getTime()>=d.getTime()?s:s-1}function rs(e,t){const n=U(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,r=re(e,t),a=W(e,0);return a.setFullYear(r,0,s),a.setHours(0,0,0,0),E(a,t)}function is(e,t){const n=x(e),s=+E(n,t)-+rs(n,t);return Math.round(s/et)+1}function S(e,t){const n=e<0?"-":"",s=Math.abs(e).toString().padStart(t,"0");return n+s}const O={y(e,t){const n=e.getFullYear(),s=n>0?n:1-n;return S(t==="yy"?s%100:s,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):S(n+1,2)},d(e,t){return S(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){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(e,t){return S(e.getHours()%12||12,t.length)},H(e,t){return S(e.getHours(),t.length)},m(e,t){return S(e.getMinutes(),t.length)},s(e,t){return S(e.getSeconds(),t.length)},S(e,t){const n=t.length,s=e.getMilliseconds(),r=Math.trunc(s*Math.pow(10,n-3));return S(r,t.length)}},Y={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ie={G:function(e,t,n){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(s,{width:"abbreviated"});case"GGGGG":return n.era(s,{width:"narrow"});case"GGGG":default:return n.era(s,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const s=e.getFullYear(),r=s>0?s:1-s;return n.ordinalNumber(r,{unit:"year"})}return O.y(e,t)},Y:function(e,t,n,s){const r=re(e,s),a=r>0?r:1-r;if(t==="YY"){const i=a%100;return S(i,2)}return t==="Yo"?n.ordinalNumber(a,{unit:"year"}):S(a,t.length)},R:function(e,t){const n=Kt(e);return S(n,t.length)},u:function(e,t){const n=e.getFullYear();return S(n,t.length)},Q:function(e,t,n){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return S(s,2);case"Qo":return n.ordinalNumber(s,{unit:"quarter"});case"QQQ":return n.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,n){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return S(s,2);case"qo":return n.ordinalNumber(s,{unit:"quarter"});case"qqq":return n.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,n){const s=e.getMonth();switch(t){case"M":case"MM":return O.M(e,t);case"Mo":return n.ordinalNumber(s+1,{unit:"month"});case"MMM":return n.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,n){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return S(s+1,2);case"Lo":return n.ordinalNumber(s+1,{unit:"month"});case"LLL":return n.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,n,s){const r=is(e,s);return t==="wo"?n.ordinalNumber(r,{unit:"week"}):S(r,t.length)},I:function(e,t,n){const s=as(e);return t==="Io"?n.ordinalNumber(s,{unit:"week"}):S(s,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):O.d(e,t)},D:function(e,t,n){const s=ss(e);return t==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):S(s,t.length)},E:function(e,t,n){const s=e.getDay();switch(t){case"E":case"EE":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"})}},e:function(e,t,n,s){const r=e.getDay(),a=(r-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(a);case"ee":return S(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(r,{width:"short",context:"formatting"});case"eeee":default:return n.day(r,{width:"wide",context:"formatting"})}},c:function(e,t,n,s){const r=e.getDay(),a=(r-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(a);case"cc":return S(a,t.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(r,{width:"narrow",context:"standalone"});case"cccccc":return n.day(r,{width:"short",context:"standalone"});case"cccc":default:return n.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,n){const s=e.getDay(),r=s===0?7:s;switch(t){case"i":return String(r);case"ii":return S(r,t.length);case"io":return n.ordinalNumber(r,{unit:"day"});case"iii":return n.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(s,{width:"short",context:"formatting"});case"iiii":default:return n.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,n){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,n){const s=e.getHours();let r;switch(s===12?r=Y.noon:s===0?r=Y.midnight:r=s/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,n){const s=e.getHours();let r;switch(s>=17?r=Y.evening:s>=12?r=Y.afternoon:s>=4?r=Y.morning:r=Y.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let s=e.getHours()%12;return s===0&&(s=12),n.ordinalNumber(s,{unit:"hour"})}return O.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):O.H(e,t)},K:function(e,t,n){const s=e.getHours()%12;return t==="Ko"?n.ordinalNumber(s,{unit:"hour"}):S(s,t.length)},k:function(e,t,n){let s=e.getHours();return s===0&&(s=24),t==="ko"?n.ordinalNumber(s,{unit:"hour"}):S(s,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):O.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):O.s(e,t)},S:function(e,t){return O.S(e,t)},X:function(e,t,n){const s=e.getTimezoneOffset();if(s===0)return"Z";switch(t){case"X":return ce(s);case"XXXX":case"XX":return H(s);case"XXXXX":case"XXX":default:return H(s,":")}},x:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"x":return ce(s);case"xxxx":case"xx":return H(s);case"xxxxx":case"xxx":default:return H(s,":")}},O:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+oe(s,":");case"OOOO":default:return"GMT"+H(s,":")}},z:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+oe(s,":");case"zzzz":default:return"GMT"+H(s,":")}},t:function(e,t,n){const s=Math.trunc(e.getTime()/1e3);return S(s,t.length)},T:function(e,t,n){const s=e.getTime();return S(s,t.length)}};function oe(e,t=""){const n=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),a=s%60;return a===0?n+String(r):n+String(r)+t+S(a,2)}function ce(e,t){return e%60===0?(e>0?"-":"+")+S(Math.abs(e)/60,2):H(e,t)}function H(e,t=""){const n=e>0?"-":"+",s=Math.abs(e),r=S(Math.trunc(s/60),2),a=S(s%60,2);return n+r+t+a}const de=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},le=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},os=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],s=n[1],r=n[2];if(!r)return de(e,t);let a;switch(s){case"P":a=t.dateTime({width:"short"});break;case"PP":a=t.dateTime({width:"medium"});break;case"PPP":a=t.dateTime({width:"long"});break;case"PPPP":default:a=t.dateTime({width:"full"});break}return a.replace("{{date}}",de(s,t)).replace("{{time}}",le(r,t))},cs={p:le,P:os},ds=/^D+$/,ls=/^Y+$/,us=["D","DD","YY","YYYY"];function hs(e){return ds.test(e)}function fs(e){return ls.test(e)}function gs(e,t,n){const s=ms(e,t,n);if(console.warn(s),us.includes(e))throw new RangeError(s)}function ms(e,t,n){const s=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const ps=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ys=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ks=/^'([^]*?)'?$/,_s=/''/g,ws=/[a-zA-Z]/;function ue(e,t,n){const s=U(),r=n?.locale??s.locale??ns,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,c=x(e);if(!fn(c))throw new RangeError("Invalid time value");let o=t.match(ys).map(l=>{const f=l[0];if(f==="p"||f==="P"){const u=cs[f];return u(l,r.formatLong)}return l}).join("").match(ps).map(l=>{if(l==="''")return{isToken:!1,value:"'"};const f=l[0];if(f==="'")return{isToken:!1,value:bs(l)};if(ie[f])return{isToken:!0,value:l};if(f.match(ws))throw new RangeError("Format string contains an unescaped latin alphabet character `"+f+"`");return{isToken:!1,value:l}});r.localize.preprocessor&&(o=r.localize.preprocessor(c,o));const d={firstWeekContainsDate:a,weekStartsOn:i,locale:r};return o.map(l=>{if(!l.isToken)return l.value;const f=l.value;(!n?.useAdditionalWeekYearTokens&&fs(f)||!n?.useAdditionalDayOfYearTokens&&hs(f))&&gs(f,t,String(e));const u=ie[f[0]];return u(c,f,r.localize,d)}).join("")}function bs(e){const t=e.match(ks);return t?t[1].replace(_s,"'"):e}function he(e){const t=x(e),n=t.getFullYear(),s=t.getMonth(),r=W(e,0);return r.setFullYear(n,s+1,0),r.setHours(0,0,0,0),r.getDate()}function xs(e){const t=x(e).getFullYear();return t%400===0||t%4===0&&t%100!==0}function fe(e){const t=x(e);return String(new Date(t))==="Invalid Date"?NaN:xs(t)?366:365}function Ss(e){const t=ft(e),n=+ft(Zt(t,60))-+t;return Math.round(n/et)}function j(e,t){const n=x(e),s=x(t);return+n==+s}function vs(e){const t=x(e);return t.setMinutes(0,0,0),t}function Ms(e,t,n){const s=E(e,n),r=E(t,n);return+s==+r}function Ts(e,t){const n=x(e),s=x(t);return n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()}function $s(e,t){const n=X(e),s=X(t);return+n==+s}function Ds(e,t){const n=x(e),s=x(t);return n.getFullYear()===s.getFullYear()}const _t={year:wn,quarter:_n,month:ne,week:gt,day:ht,hour:pn,minute:yn},F={year:{quarter:4,month:12,week:Ss,day:Ws,hour:Is},quarter:{month:3,week:Cs,day:ge,hour:Ps},month:{week:Es,day:Os,hour:As},week:{day:7,hour:24*7},day:{hour:24},hour:{minute:60}};function Ws(e){return e?fe(e):365}function Is(e){return fe(e)*24}function Cs(e){const t=X(e),n=tt(A(yt(e)),1);return gt(n,t)}function ge(e){if(e){const t=X(e),n=yt(e);return ht(n,t)+1}return 91}function Ps(e){return ge(e)*24}function Es(e){if(e){const t=se(e),n=tt(A(pt(e)),1);return gt(n,t)}return 5}function Os(e){return e?he(e):30}function As(e){return he(e)*24}function st(e,t,n){const s=F[e][t];return s?typeof s=="number"?s:s(n):1}function Hs(e,t){return e===t||!!(F[e]&&F[e][t])}const at={year:ln,quarter:dn,month:ut,week:Zt,day:tt,hour:rn,minute:cn};function rt(e,t,n){if(t){if(e==="day")return(s,r)=>t.getWorkingDays(r,s,!0);if(e==="hour")return(s,r)=>t.getWorkingHours(r,s,!0)}return(s,r,a,i)=>{const c=F[e]?.[a];return!c||typeof c=="number"||ye(e,s,r,n)?Q(e,s,r,a,i,n):Fs(s,r,e,a,i,n)}}function Q(e,t,n,s,r,a){const i=s||e;let c=n,o=t;if(r&&(c=C(i,n,a),o=C(i,t,a),o<t&&(o=I(i)(o,1))),e!==i){const d=_t[i](o,c),l=st(e,i,n);return d/l}else return _t[i](o,c)}function Fs(e,t,n,s,r,a){let i=0;const c=C(n,t,a);if(t>c){const d=at[n](c,1);i=Q(n,d,t,s,void 0,a),t=d}let o=0;return ye(n,t,e,a)||(o=Q(n,C(n,e,a),t,void 0,void 0,a),t=at[n](t,o)),o+=i+Q(n,e,t,s,void 0,a),!o&&r&&(o=Q(n,e,t,s,r,a)),o}function I(e,t){if(t){if(e==="day")return(n,s)=>t.addWorkingDays(n,s,!0);if(e==="hour")return(n,s)=>t.addWorkingHours(n,s)}return at[e]}const me={year:ae,quarter:X,month:se,week:(e,t)=>E(e,{weekStartsOn:t}),day:A,hour:vs};function C(e,t,n){const s=me[e];return s?s(t,n):new Date(t)}const Ns={year:bn,quarter:yt,month:pt,week:(e,t)=>Sn(e,{weekStartsOn:t}),day:ee,hour:xn},pe={year:Ds,quarter:$s,month:Ts,week:(e,t,n)=>Ms(e,t,{weekStartsOn:n}),day:un};function ye(e,t,n,s){const r=pe[e];return r?r(t,n,s):!1}const zs={start:me,end:Ns,add:at,isSame:pe,diff:_t,smallerCount:F},ke=e=>typeof e=="function"?e(new Date):e;function Bs(e,t){for(const n in t){if(n==="smallerCount"){const s=Object.keys(t[n]).sort((c,o)=>P.indexOf(c)-P.indexOf(o)).shift();let r=P.indexOf(s);const a=t[n][s],i=ke(a);for(let c=r-1;c>=0;c--){const o=P[c],d=ke(F[o][s]);if(i<=d)break;r=c}P.splice(r,0,e)}if(n==="biggerCount")for(const s in t[n])F[s][e]=t[n][s];else zs[n][e]=t[n]}}function wt(e,t=1,n){return n.isWorkingDay(e)||(e=t>0?n.getNextWorkingDay(e):n.getPreviousWorkingDay(e)),e}function Ys(e){return(t,n)=>{if(n>0)for(let s=0;s<n;s++)t=e.getNextWorkingDay(t);if(n<0)for(let s=0;s>n;s--)t=e.getPreviousWorkingDay(t);return t}}function _e(e){return ue(e,"yyyy-MM-dd")}function L(e){const t=new Date;return e.map(n=>({item:n,len:I(n.unit)(t,1)})).sort((n,s)=>n.len<s.len?-1:1)[0].item}const P=["year","quarter","month","week","day","hour"],bt=50,xt=300;function js(e,t,n,s,r,a,i,c,o){const d=!e||n,l=!t||n;let f=e,u=t,g=!1,m=!1;(d||l)&&r?.forEach(h=>{let y=h.start;o&&h.base_start<h.start&&(y=h.base_start),d&&(!f||y<=f)&&(f=y,g=!0);let _=h.type==="milestone"?h.start:h.end;if(o){const k=h.type==="milestone"?h.base_start:h.base_end;k&&k>_&&(_=k)}l&&(!u||_>=u)&&(u=_,m=!0)});const p=I(s||"day");return f?g&&(f=p(f,-1)):u?f=p(u,-30):f=new Date,u?m&&(u=p(u,1)):u=p(f,30),{_start:f,_end:u}}function Ls(e,t,n,s,r,a,i,c){const o=L(i).unit,d=rt(o,void 0,a),l=d(t,e,"",!0),f=C(o,t,a);e=C(o,e,a),t=f<t?I(o)(f,1):f;const u=l*s,g=r*Math.max(c,i.length),m=i.map(h=>{const y=[],_=I(h.unit);let k=C(h.unit,e,a);for(;k<t;){const b=_(k,h.step),w=k<e?e:k,v=b>t?t:b,$=d(v,w,"",!0)*s,M=typeof h.format=="function"?h.format(k,b):h.format;let T="";h.css&&(T+=typeof h.css=="function"?h.css(k):h.css),y.push({width:$,value:M,date:w,key:_e(w),css:T,unit:h.unit}),k=b}return{cells:y,add:_,height:g/i.length}});let p=s;return o!==n&&(p=p/st(o,n)),{rows:m,width:u,height:g,diff:d,start:e,end:t,lengthUnit:n,minUnit:o,lengthUnitWidth:p}}function Us(e,t,n,s){const r=typeof e=="boolean"?{}:e,a=P.indexOf(L(n).unit);if(typeof r.level>"u"&&(r.level=a),r.levels)r.levels.forEach(o=>{o.minCellWidth||(o.minCellWidth=it(r.minCellWidth,bt)),o.maxCellWidth||(o.maxCellWidth=it(r.maxCellWidth,xt))});else{const o=[],d=n.length||1,l=it(r.minCellWidth,bt),f=it(r.maxCellWidth,xt);n.forEach(u=>{u.format&&!t[u.unit]&&(t[u.unit]=u.format)}),P.forEach((u,g)=>{if(g===a)o.push({minCellWidth:l,maxCellWidth:f,scales:n});else{const m=[];if(g)for(let p=d-1;p>0;p--){const h=P[g-p];h&&m.push({unit:h,step:1,format:t[h]})}m.push({unit:u,step:1,format:t[u]}),o.push({minCellWidth:l,maxCellWidth:f,scales:m})}}),r.levels=o}r.levels[r.level]||(r.level=0);const i=r.levels[r.level],c=Math.min(Math.max(s,i.minCellWidth),i.maxCellWidth);return{zoom:r,scales:i.scales,cellWidth:c}}function qs(e,t,n,s,r,a,i){e.level=n;let c;const o=s.scales||s,d=L(o).unit,l=Gs(d,r);if(t<0){const g=st(d,r);c=i*g}else{const g=st(L(a).unit,d);c=Math.round(i/g)}const f=s.minCellWidth??bt,u=s.maxCellWidth??xt;return{scales:o,cellWidth:Math.min(u,Math.max(f,c)),lengthUnit:l,zoom:e}}function Xs(e,t){const{_start:n,_scales:s,start:r,end:a,_end:i,cellWidth:c,_scaleDate:o,_zoomOffset:d,_weekStart:l}=t,f=I(s.minUnit);let u=s.width;if(r&&a){if(u<e&&u){const y=e/u;return{cellWidth:Math.ceil(c*y)}}return{}}let g=0;for(;u<e;)u+=c,g++;let m=0;if(g){if(a)m=-g;else if(o&&d!==null){const y=d/c,_=s.diff(o,n,"hour");m=Math.floor(_-y)}}let p=r;r||(p=C(s.minUnit,f(n,m),l));let h=0;if(o){const y=s.diff(o,p,"hour");h=Math.max(0,Math.round(y*c)-(d||0))}return{_start:p,_end:a||f(i,g-m),scrollLeft:h}}function Gs(e,t){const n=P.indexOf(e),s=P.indexOf(t);return s>=n?e==="hour"?"hour":"day":P[s]}function it(e,t){return e??t}function we(e,t){const{_scales:n,_start:s,_weekStart:r}=t,a=n.lengthUnit==="day"?n.lengthUnitWidth/24:n.lengthUnitWidth;return I("hour")(C(n.minUnit,s,r),Math.floor(e/a))}const St=7,Rs=3,vt=8,be=4,Qs=vt+be;function xe(e,t,n){(e.open||e.type!=="summary"||n)&&e.data?.forEach(s=>{s.$x+=t,s.$x_rollup&&(s.$x_rollup+=t),xe(s,t,n)})}function Mt(e,t){const n=e.getSummaryId(t.id);if(n){const s=e.byId(n),r={xMin:1/0,xMax:0};Se(s,r),s.$x=r.xMin,s.$w=r.xMax-r.xMin,Mt(e,s)}}function Se(e,t){e.data?.forEach(n=>{if(!n.unscheduled){const s=n.type==="milestone"&&n.$h?n.$h/2:0;t.xMin>n.$x+s&&(t.xMin=n.$x+s);const r=n.$x+n.$w-s;t.xMax<r&&(t.xMax=r)}n.type!=="summary"&&Se(n,t)})}function Tt(e,t){let n;t&&(n=t.filter(r=>r.parent===e.id));const s={data:n,...e};if(s.data?.length)s.data.forEach(r=>{if(r.unscheduled&&!r.data)return;(t||r.type!=="summary"&&r.data)&&(r.unscheduled&&(r={...r,start:void 0,end:void 0}),r=Tt(r,t)),r.start&&(!s.start||s.start>r.start)&&(s.start=new Date(r.start));const a=r.end||r.start;a&&(!s.end||s.end<a)&&(s.end=new Date(a))});else if(e.type==="summary")throw Error("Summary tasks must have start and end dates if they have no subtasks");return s}function ve(e,t,n){return $t(e,t,n,!1),n.splitTasks&&e.segments?.forEach(s=>{ve(s,t,{...n,baselines:!1}),s.$x-=e.$x}),n.baselines&&$t(e,t,n,!0),e.data&&!e.open&&Me(e,n),e}function $t(e,t,n,s){const{cellWidth:r,cellHeight:a,_scales:i,baselines:c,_rollups:o}=n,{start:d,end:l,lengthUnit:f,diff:u}=i,g=(s?"base_":"")+"start",m=(s?"base_":"")+"end",p="$x"+(s?"_base":""),h="$y"+(s?"_base":""),y="$w"+(s?"_base":""),_="$h"+(s?"_base":""),k="$skip"+(s?"_baseline":"");let b=e[g],w=e[m];if(s&&!b){e[k]=!0;return}e[g]<d&&(e[m]<d||j(e[m],d))?b=w=d:e[g]>l&&(b=w=l),e[p]=Math.round(u(b,d,f)*r),e[y]=Math.round(u(w,b,f,!0)*r),t!==null&&(e[h]=s?e.$y+e.$h+be:a*t+Rs),e[_]=s?vt:c?a-St-Qs:a-St,e.type==="milestone"&&(e[p]=e[p]-e.$h/2,e[y]=e.$h,s&&(e[h]=e.$y+vt,e[y]=e[_]=e.$h)),n.unscheduledTasks&&e.unscheduled&&!s||n.groupBy&&e.$group?e.$skip=!0:e[k]=j(b,w)}function Me(e,t,n){n=n??e.type!=="summary",e.data&&!e.$skip&&(n||t._rollups)&&e.data.forEach(s=>{(n||s.rollup)&&$t(s,null,t,!1),Me(s,t,n)})}function Vs(e,t){return!1}function Js(e,t){}var Te=new Date().valueOf();function Ks(){return Te+=1,Te}const Dt=20,Zs=function(e,t,n,s){if(!t||!n||!t.$y||!n.$y||t.$skip||n.$skip)return e.$p="",e.$pl=0,e.$x1=e.$x2=e.$y1=e.$y2=0,e;let r=!1,a=!1;switch(e.type){case"e2s":a=!0;break;case"s2s":r=!0,a=!0;break;case"s2e":r=!0;break}const i=r?t.$x:t.$x+t.$w,c=t.$y+t.$h/2,o=a?n.$x:n.$x+n.$w,d=n.$y+n.$h/2,l=(s-St-n.$h)/2;if(i!==o||c!==d){const{coords:f,pl:u,x1:g,x2:m,y1:p,y2:h}=ta(i,c,o,d,r,a,s/2,l),y=ea(o,d,a);e.$p=`${f},${y}`,e.$pl=u,e.$x1=Math.min(g,o-5),e.$x2=Math.max(m,o+5),e.$y1=Math.min(p,d-3),e.$y2=Math.max(h,d+3)}return e};function ta(e,t,n,s,r,a,i,c){const o=Dt*(r?-1:1),d=Dt*(a?-1:1),l=e+o,f=n+d,u=[e,t,l,t,0,0,0,0,f,s,n,s],g=f-l;let m=s-t;const p=a===r;p||(f<=e+Dt-2&&a||f>e&&!a)&&(m=m-i+c),p&&a&&l>f||p&&!a&&l<f?(u[4]=u[2]+g,u[5]=u[3],u[6]=u[4],u[7]=u[5]+m):(u[4]=u[2],u[5]=u[3]+m,u[6]=u[4]+g,u[7]=u[5]);let h=1/0,y=-1/0,_=1/0,k=-1/0,b=0;for(let w=0;w<u.length-1;w+=2)u[w]<h&&(h=u[w]),u[w]>y&&(y=u[w]),u[w+1]<_&&(_=u[w+1]),u[w+1]>k&&(k=u[w+1]),w<u.length-3&&(b+=Math.hypot(u[w+2]-u[w],u[w+3]-u[w+1]));return{coords:u.join(","),pl:b,x1:h,x2:y,y1:_,y2:k}}function ea(e,t,n){return n?`${e-5},${t-3},${e-5},${t+3},${e},${t}`:`${e+5},${t+3},${e+5},${t-3},${e},${t}`}function na(e,t,n){if(t&&n){const s=n.x-t.x,r=n.y-t.y,a=(s>0?t.x:n.x)-e.left,i=(r>0?t.y:n.y)-e.top,c=`${s>0?0:-s},${r>0?0:-r},${s>0?s:0},${r>0?r:0}`;return{width:Math.abs(s),height:Math.abs(r),left:a,top:i,p:c}}else return null}function Wt(e){return e?.map(t=>{const n=t.id||Ks();return{...t,id:n}})}const ot=37,$e=["start","end","duration"];function sa(e,t){const{type:n,unscheduled:s}=e;return s||n==="summary"?!$e.includes(t):n==="milestone"?!["end","duration"].includes(t):!0}function aa(e,t){if(typeof t=="function")return t;const n=$e.includes(e);return(n||e==="resources")&&(typeof t=="string"&&(t={type:t,config:{}}),t.config||(t.config={}),t.type==="datepicker"&&(t.config.buttons=["today"]),n)?(s,r)=>sa(s,r.id)?t:null:t}function ra(e){if(!e||!e.length)return[];const t=e.map(n=>{const s=n.align||"left",r=n.id==="add-task",a=r?null:n.flexgrow,i=a?1:n.width||(r?ot:120),c=n.editor&&aa(n.id,n.editor);let o=Array.isArray(n.header)?n.header:[n.header];return o=o.map(d=>(typeof d!="object"&&(d={text:d}),d.filter&&typeof d.filter!="object"&&(d.filter={type:d.filter}),d)),{width:i,align:s,header:o,id:n.id,template:n.template,_template:n._template,...a&&{flexgrow:a},...n.hidden&&{hidden:n.hidden},cell:n.cell,resize:n.resize??!0,sort:n.sort??!r,...c&&{editor:c},...n.options&&{options:n.options},getter:n.getter}});return De(t),t}function De(e){if(e.some(n=>n.flexgrow&&!n.hidden))return;const t=e.find(n=>n.id==="text"&&!n.hidden)||e.find(n=>n.id!=="add-task"&&!n.hidden);t&&(t.flexgrow=1)}const We=[{id:"text",header:"Task name",width:183,flexgrow:1,sort:!0},{id:"start",header:"Start date",width:120,align:"center",sort:!0},{id:"duration",header:"Duration",width:100,align:"center",sort:!0},{id:"add-task",header:"Add task",width:ot,align:"center",sort:!1,resize:!1}];function ia(e={}){return We.map(t=>({...t}))}function oa(e){return e.reduce((t,n)=>t+(n.width??0),0)}function ca(){return[]}function da(e){if(!e||!e.length)return[];const t=e.map(n=>({...n}));if(!t.some(n=>n.flexgrow)){const n=t.find(s=>s.id==="name")||t[0];n&&(n.flexgrow=1)}return t}function V(e,t,n,s){const r=e.getState(),a=r._selected.map(p=>p.id),i=a.length,c=["edit-task","paste-task","undo","redo"],o=["copy-task","cut-task"],d=["copy-task","cut-task","delete-task","indent-task:remove","move-task:down"],l=["add-task","undo","redo"],f=["indent-task:add","move-task:down","move-task:up","copy-task","cut-task"],u={"indent-task:remove":2},g=!i&&l.includes(t),m={parent:f.includes(t),level:u[t],sort:!o.includes(t)};if(n=n||(i?a[a.length-1]:null),!(!n&&!g)){if(t!=="paste-task"&&(e._temp=null),c.includes(t)||g||a.length===1)Ie(e,t,n,s);else if(i){const p=la(a,m,r);d.includes(t)&&p.reverse();const h=e.getHistory();h&&h.startBatch(),p.forEach((y,_)=>Ie(e,t,y,s,_)),h&&h.endBatch()}}}function la(e,t,n){const{tasks:s,tree:r,groupBy:a}=n;let i=e.map(c=>{let o=c;a?.field&&(o=r.byId(o)?.$id||o);const d=s.byId(o);return{id:o,level:d.$level,parent:d.parent,index:s.getIndexById(o)}});return(t.parent||t.level)&&(i=i.filter(c=>t.level&&c.level<=t.level||!e.includes(c.parent))),t.sort&&i.sort((c,o)=>c.level-o.level||c.index-o.index),i.map(c=>c.id)}function Ie(e,t,n,s,r){const a=e.exec?e.exec:e.in.exec;let i=t.split(":")[0],c=t.split(":")[1];const o=n?.id||n;let d={id:o},l={},f=!1;if(i==="copy-task"||i==="cut-task"){e._temp||(e._temp=[]),e._temp.push({id:o,cut:i==="cut-task"});return}else if(i==="paste-task"){const{tasks:u}=e.getState(),g=e._temp?.filter(m=>u.byId(m.id));if(g&&g.length){const m=e.getHistory();m&&m.startBatch();const p=new Map;if(g.forEach(h=>{const y={id:h.id,target:o,mode:"after"};a(h.cut?"move-task":"copy-task",y),p.set(h.id,y.id)}),!g[0].cut){const{links:h}=e.getState(),y=g.map(k=>k.id),_=[];h.forEach(k=>{y.includes(k.source)&&y.includes(k.target)&&_.push(k)}),_.forEach(k=>{a("add-link",{link:{source:p.get(k.source),target:p.get(k.target),type:k.type}})}),g.forEach((k,b)=>{a("select-task",{id:p.get(k.id),toggle:!!b})})}m&&m.endBatch()}e._temp=null;return}else i==="add-task"?(l={task:{type:"task",text:s("New Task")},target:o,show:!0,mode:"after",select:!1},d={},f=!0):i==="edit-task"?i="show-editor":i==="convert-task"?(i="update-task",l={task:{type:c}},c=void 0):i==="indent-task"&&(c=c==="add");if(i==="split-task"&&typeof n=="object")l=n;else if(i==="delete-task"&&c==="segment"&&typeof n=="object"){const u=e.getTask(o),{segmentIndex:g}=n,m=u.segments.filter((p,h)=>h!==g);a("update-task",{id:o,task:{segments:m}});return}typeof c<"u"&&(l={...l,mode:c}),d={...d,...l},a(i,d),f&&a("select-task",{id:d.id,toggle:!!r,eventSource:i})}function Ce(e,t){return e.some(n=>n.data?Ce(n.data,t):n.id===t)}function Pe(e,t,n,s=1){const r=n[0].width,a=Math.max(0,Math.floor(e/r)-s),i=Math.min(n.length,Math.ceil((e+t)/r)+s);return{from:a*r,to:i*r,start:a,end:i}}const It=null,Ee=(e,t)=>I(e,t),ua=(e,t)=>rt(e,t);function Ct(e,t,n){Array.isArray(e)&&(e.forEach(s=>N(s,t,n(s))),e.forEach(s=>{if(s.type==="summary"&&!(s.start&&s.end)){const{start:r,end:a}=Tt(s,e);s.start=r,s.end=a,N(s,t,n(s))}}))}function N(e,t,n){e.unscheduled||Oe(e,t,n,!1),e.base_start&&Oe(e,t,n,!0)}function Oe(e,t,n,s){const{durationUnit:r}=t,a=r||"day",[i,c,o]=Ae(s);e.type==="milestone"?(e[o]=0,e[c]=void 0):e[i]&&(e[o]?e[c]=Ee(a,n)(e[i],e[o]):e[c]?e[o]=ua(a,n)(e[c],e[i]):(e[c]=Ee(a,n)(e[i],1),e[o]=1))}function Ae(e){return e?["base_start","base_end","base_duration"]:["start","end","duration"]}function He(e,t,n){const[s,r,a]=Ae(n);(t===a||t===s)&&(t===a&&e[a]<1&&(e[a]=1),e[r]=null),t===r&&(e[a]=0,e[s]&&e[s]>=e[r]&&(e[r]=null,e[a]=1))}function ha(e,t,n,s){He(e,s,!1),e.base_start&&He(e,s,!0),N(e,t,n)}class fa extends qe{in;_router;_modules=new Map;_prevScaleMinUnit;_prevConfig={};constructor(t){super({writable:t,async:!1}),this._router=new Xe(super.setState.bind(this),[{in:["tasks","start","end","scales","autoScale","markers","projectStart","projectEnd","baselines"],out:["_start","_end"],exec:a=>{const{_end:i,_start:c,start:o,end:d,tasks:l,scales:f,autoScale:u,markers:g,projectStart:m,projectEnd:p,baselines:h,_tasksPatch:y}=this.getState();if(!y)if(!o||!d||u){const _=L(f).unit,k=js(o,d,u,_,l,g,m,p,h);(k._end!==i||k._start!==c)&&this.setState(k,a)}else this.setState({_start:o,_end:d},a)}},{in:["columns"],out:["_headerLength","_gridCollapseThreshold"],exec:a=>{const i=this.getState().columns;let c=1,o=ot;i.length&&i.forEach(d=>{d.id==="add-task"&&d.width&&(o=d.width),c=Math.max(d.header.length,c)}),this.setState({_headerLength:c,_gridCollapseThreshold:o},a)}},{in:["_compactMode"],out:["displayMode"],exec:a=>{const{displayMode:i,_compactMode:c}=this.getState();let o=i;c?o=i==="all"?"grid":o:o="all",this.setState({displayMode:o},a)}},{in:["displayMode","columns","gridWidth"],out:["_columnsWidth"],exec:a=>{const{columns:i,displayMode:c,gridWidth:o}=this.getState();if(!i?.length){this.setState({_columnsWidth:0},a);return}let d=0;c==="chart"&&(d=i?.find(l=>l.id==="add-task")?.width||ot),c==="all"&&(d=o),d&&this.setState({_columnsWidth:d},a)}},{in:["start","end"],out:["cellWidth"],exec:a=>{const{_cellWidth:i,cellWidth:c}=this.getState();i!==c&&this.setState({cellWidth:i},a)}},{in:["_start","_end","cellWidth","scaleHeight","scales","lengthUnit","_weekStart","_headerLength"],out:["_scales"],exec:a=>{const i=this.getState();let{lengthUnit:c}=i;const{_start:o,_end:d,cellWidth:l,scaleHeight:f,scales:u,_weekStart:g,_headerLength:m}=i,p=L(u).unit;Hs(p,c)||(c=p);const h=Ls(o,d,c,l,f,g,u,m);this.setState({_scales:h,_scaleMinUnit:p},a)}},{in:["assignments"],out:["_assignments"],exec:a=>{const{assignments:i}=this.getState(),c={byTask:{},byResource:{}};i&&i.forEach(o=>{const d=o.task,l=o.resource;c.byTask[d]||(c.byTask[d]=[]),c.byTask[d].push(o),c.byResource[l]||(c.byResource[l]=[]),c.byResource[l].push(o)}),this.setState({_assignments:c},a)}},{in:["_scales","scrollLeft","_chartWidth"],out:["xArea"],exec:a=>{const{_scales:i,scrollLeft:c,_chartWidth:o}=this.getState();if(!i||!o){this.setState({xArea:{from:0,to:0,start:0,end:0}},a);return}const d=i.rows[i.rows.length-1].cells;this.setState({xArea:Pe(c||0,o,d)},a)}},{in:["tasks","_assignments","groupBy","_scales"],out:["tree"],exec:a=>{this.getState();const{tasks:i,_scales:c}=this.getState(),o=this.getGrouping();if(o){if(!c)return;const d=o.buildTree();this.setState({tree:d});return}this.setState({tree:i},a)}},{in:["tree","_scales","_rollups","cellHeight","baselines","unscheduledTasks"],out:["_tasks"],exec:a=>{const{cellWidth:i,cellHeight:c,tree:o,_scales:d,baselines:l,splitTasks:f,unscheduledTasks:u,_rollups:g,groupBy:m,_tasksPatch:p}=this.getState(),h=o.toArray();if(p&&h.every(_=>_.$skip||typeof _.$x=="number")){this.setState({_tasks:h,_tasksPatch:null},a);return}const y=h.map((_,k)=>ve(_,k,{cellWidth:i,cellHeight:c,_scales:d,baselines:l,splitTasks:f,unscheduledTasks:u,_rollups:g,groupBy:m}));this.setState({_tasks:y,_tasksPatch:null},a)}},{in:["_tasks","links","cellHeight"],out:["_links"],exec:a=>{const{tree:i,links:c,cellHeight:o,criticalPath:d,_isFiltered:l}=this.getState(),f=c.map(u=>{const g=i.byId(u.source),m=i.byId(u.target);return!g||!m?null:Zs(u,g,m,o)}).toSorted((u,g)=>!u||!g?0:d?!!u.critical==!!g.critical?g.$pl-u.$pl:u.critical?1:-1:g.$pl-u.$pl).filter(u=>u&&l?i.isFilteredId(u.source)&&i.isFilteredId(u.target):u!==null);this.setState({_links:f},a)}},{in:["_links"],out:["_linksIndex"],exec:a=>{const{_links:i}=this.getState(),c=new Map;for(const o of i){if(!o.$p)continue;const d=Math.floor(o.$x1/2048),l=Math.floor(o.$x2/2048),f=Math.floor(o.$y1/2048),u=Math.floor(o.$y2/2048);for(let g=f;g<=u;g++)for(let m=d;m<=l;m++){const p=g*65536+m;let h=c.get(p);h||c.set(p,h=[]),h.push(o)}}this.setState({_linksIndex:c},a)}},{in:["_linksIndex","area","xArea","cellHeight"],out:["_visibleLinks"],exec:a=>{const{_linksIndex:i,area:c,xArea:o,cellHeight:d}=this.getState(),l=c.to??c.end*d,f=Math.floor(o.from/2048),u=Math.floor(o.to/2048),g=Math.floor(c.from/2048),m=Math.floor(l/2048);let p;if(f===u&&g===m)p=i.get(g*65536+f)??[];else{const y=new Set;for(let _=g;_<=m;_++)for(let k=f;k<=u;k++){const b=i.get(_*65536+k);if(b)for(const w of b)y.add(w)}p=Array.from(y)}const h=p.filter(y=>y.$y2>=c.from&&y.$y1<=l&&y.$x2>=o.from&&y.$x1<=o.to);this.setState({_visibleLinks:h},a)}},{in:["tasks","activeTask"],out:["_activeTask"],exec:a=>{const{activeTask:i,tasks:c}=this.getState(),o=c.byId(i);this.setState({_activeTask:o||null},a)}},{in:["tree","selected"],out:["_selected"],exec:a=>{const{tree:i,selected:c,_isFiltered:o}=this.getState(),d=c.map(l=>i.byId(l)).filter(l=>l?!o||i.isFilteredId(l.id):!1);this.setState({_selected:d},a)}}],{tasks:a=>new Gt(a),links:a=>new K(Wt(a)),columns:a=>ra(a)});const n=this.in=new Ge;n.on("show-editor",a=>{this.setStateAsync({activeTask:a.id})}),n.on("select-task",({id:a,toggle:i,range:c,show:o=!0,focus:d,eventSource:l})=>{const{selected:f,_tasks:u,activeTask:g}=this.getState();let m=!1,p;if(f.length&&(i||c)){const y=[...f];if(c){const _=y[y.length-1],k=u.findIndex(M=>M.id===_),b=u.findIndex(M=>M.id===a),w=Math.min(k,b),v=Math.max(k,b)+1,$=u.slice(w,v).map(M=>M.id);k>b&&$.reverse(),$.forEach(M=>{y.includes(M)||y.push(M)})}else if(i){const _=y.findIndex(k=>k===a);_===-1?y.push(a):(m=!0,y.splice(_,1))}p=y}else p=[a];const h={selected:p};if(this.setState(h),p.length&&(d&&(o=d==="chart"?"xy":o||"y"),o)){const y=()=>{this.scrollToTask(p[0],o),d&&this.setStateAsync({focusTask:{id:p[0],column:d==="grid"}})};l==="add-task"?setTimeout(y,1):y()}!m&&g&&g!==a&&n.exec("show-editor",{id:a})}),n.on("delete-link",({id:a})=>{const{links:i}=this.getState();i.remove(a),this.setStateAsync({links:i})}),n.on("update-link",a=>{const{links:i}=this.getState(),c=a.id;let o=a.link;i.update(c,o),o=i.byId(c),!o.lag&&o.lag!==0?delete o.lag:o.lag=Number(o.lag)||0,this.setStateAsync({links:i}),a.link=o}),n.on("add-link",a=>{const{link:i}=a,{links:c}=this.getState();!i.source||!i.target||(i.type||(i.type="e2s"),i.id=i.id||Nt(),c.add(i),this.setStateAsync({links:c}),a.id=i.id,a.link=c.byId(i.id))});let s=null;n.on("move-task",a=>{const{tasks:i}=this.getState();let{mode:c,target:o}=a;const{id:d,inProgress:l}=a,f=i.byId(d);if(typeof l>"u"?a.source=f.parent:a.source=s=s??f.parent,l===!1){i.update(f.id,{$reorder:!1}),this.setState({tasks:i}),s=null;return}if(o===d||i.contains(d,o)){a.skipProvider=!0;return}if(c==="up"||c==="down"){const u=i.getBranch(d);let g=i.getIndexById(d);if(c==="up"){const m=f.parent===0;if(g===0&&m){a.skipProvider=!0;return}g-=1,c="before"}else if(c==="down"){const m=g===u.length-1,p=f.parent===0;if(m&&p){a.skipProvider=!0;return}g+=1,c="after"}if(o=u[g]&&u[g].id||f.parent,o){const m=i.getBranch(o);let p=i.getIndexById(o),h=m[p];if(h.data){if(c==="before"){if(h.parent===f.parent){for(;h.data;)h.open||n.exec("open-task",{id:h.id,mode:!0}),h=h.data[h.data.length-1];o=h.id}}else if(c==="after"){let k;h.parent===f.parent?(k=h,h=h.data[0],o=h.id,c="before"):m.length-1!==p&&(k=h,p+=1,h=m[p],f.$level>h.$level&&h.data?(k=h,h=h.data[0],o=h.id,c="before"):o=h.id),k&&!k.open&&n.exec("open-task",{id:k.id,mode:!0})}}const y=i.getSummaryId(f.id);i.move(d,c,o);const _=i.getSummaryId(d);y!==_&&(y&&this.resetSummaryDates(y,"move-task"),_&&this.resetSummaryDates(_,"move-task"))}}else{const u=i.byId(o);let g=u,m=!1;for(;g.$level>f.$level;)g=i.byId(g.parent),g.id===d&&(m=!0);if(m)return;const p=i.getSummaryId(f.id);if(i.move(d,c,o),c==="child"){let y=u;for(;y.id!==0&&!y.open;)n.exec("open-task",{id:y.id,mode:!0}),y=i.byId(y.parent)}const h=i.getSummaryId(d);p!==h&&(p&&this.resetSummaryDates(p,"move-task"),h&&this.resetSummaryDates(h,"move-task"))}l?this.setState({tasks:i}):this.setStateAsync({tasks:i}),a.target=o,a.mode=c}),n.on("drag-task",a=>{const i=this.getState(),{tree:c,_tasks:o,_selected:d,rollups:l,slack:f}=i,u=c.byId(a.id),{left:g,top:m,width:p,inProgress:h}=a,y={_tasks:o,_selected:d};if(typeof p<"u"&&(u.$w=p,Mt(c,u)),typeof g<"u"){if(u.type==="summary"){const _=g-u.$x;xe(u,_,!!l)}u.$x=g,Mt(c,u)}typeof m<"u"&&(u.$y=m+4,u.$reorder=h),this.setState(y)});const r=new Set(["start","end","duration","type","unscheduled","base_start","base_end","base_duration","segments","rollup"]);n.on("update-task",a=>{const{id:i,segmentIndex:c,diff:o,eventSource:d}=a;let{task:l}=a;const f=this.getState(),{tasks:u,_scales:g,durationUnit:m,splitTasks:p,_calendars:h}=f,y={tasks:u,_tasksPatch:!1},_=u.byId(i),k=this.getTaskCalendar({..._,...l}),b={durationUnit:m};if(d==="add-task"||d==="copy-task"||d==="move-task"||d==="update-task"||d==="delete-task"||d==="provide-data"||d==="schedule-tasks"){d==="schedule-tasks"?(u.update(i,l),this.setState({tasks:u})):(N(l,b,k),u.update(i,l));return}if(!(o||c>=0||"type"in l&&l.type!==_.type||Object.keys(l).some(T=>{if(!r.has(T)||T==="type")return!1;const D=l[T],z=_[T];return!J(D,z)}))){u.update(i,l);const T=u.byId(i),D=!this.getGrouping()&&typeof T.$x=="number";this.setStateAsync({tasks:u,_tasksPatch:D}),a.task=T;return}const w=g.lengthUnit;let v=I(w);const $=rt(m,k);if(o&&(l.start&&(l.start=v(l.start,o)),!c&&c!==0&&(l.start&&l.end?l.duration=_.duration:(l.start?l.end=_.end:(l.end=v(l.end,o),l.start=_.start,l.duration=$(l.end,l.start)),$(l.end,l.start)||(l.duration=1)))),l.type=l.type??_.type,k&&l.start&&(l.start=wt(l.start,o,k)),l.start&&l.end&&(!j(l.start,_.start)||!j(l.end,_.end))&&l.type==="summary"&&_.data?.length){let T=o||$(l.start,_.start);k&&(T=l.start>_.start?$(l.start,_.start):-$(_.start,l.start),v=Ys(k)),this.moveSummaryKids(_,(D,z)=>{if(D=v(D,T),!k)return D;const Ye=h?this.getTaskCalendar(z):k;return wt(D,o,Ye)},"update-task")}l.start||(l.start=_.start),!l.end&&!l.duration&&(l.duration=_.duration),N(l,b,k),u.update(i,l),(k&&l.type==="summary"||l.type==="summary"&&_.type!=="summary")&&this.resetSummaryDates(i,"update-task",!0);const M=u.getSummaryId(i);M&&this.resetSummaryDates(M,"update-task"),this.setStateAsync(y),a.task=u.byId(i)}),n.on("add-task",a=>{const{tasks:i,_scales:c,unscheduledTasks:o,durationUnit:d,splitTasks:l,tree:f}=this.getState(),{target:u,mode:g,task:m,show:p,select:h=!0}=a;!a.eventSource&&o&&(m.unscheduled=!0);const y=this.getTaskCalendar(m);let _=-1,k,b;if(u?(b=i.byId(u),g==="child"?(k=b,m.parent=k.id):(b.parent!==null&&(k=i.byId(b.parent),m.parent=k.id),_=i.getIndexById(u),g==="after"&&(_+=1))):m.parent&&(k=i.byId(m.parent)),!m.start){if(k?.start)m.start=new Date(k.start.valueOf());else if(b)m.start=new Date(b.start.valueOf());else{const M=i.getBranch(0);let T;if(M?.length){const D=M[M.length-1];if(!D.$skip){const z=new Date(D.start.valueOf());c.start<=z&&(T=z)}}m.start=T||I(d,y)(c.start,1)}m.duration=m.duration||1}y&&(m.start=wt(m.start,1,y)),this.getState().baselines&&(m.base_start=m.start,m.base_duration=m.duration),N(m,{durationUnit:d},y);const w=i.add(m,_),v={tasks:i};if(p)for(;k&&k.id;)n.exec("open-task",{id:k.id,mode:!0}),k=f.byId(k.parent);a.id=w.id;const $=i.getSummaryId(w.id);$&&this.resetSummaryDates($,"add-task"),this.setStateAsync(v),a.id=w.id,a.task=w,h?n.exec("select-task",{id:w.id,show:p,eventSource:"add-task"}):p&&this.scrollToTask(w.id,p)}),n.on("delete-task",a=>{const{id:i}=a,c=this.getState(),{tasks:o,links:d,selected:l}=c,f=o.byId(i);a.source=f.parent;const u=o.getSummaryId(i),g=[i];o.eachChild(h=>g.push(h.id),i),d.filter(h=>!(g.includes(h.source)||g.includes(h.target)));const m={tasks:o,links:d},p=c.groupBy?.field==="resource";(l.includes(i)||p)&&(m.selected=l.filter(h=>h!==i&&(!p||c.tree.byId(h)?.$id!==i))),o.remove(i),u&&this.resetSummaryDates(u,"delete-task"),this.setStateAsync(m)}),n.on("indent-task",({id:a,mode:i})=>{const{tasks:c}=this.getState();if(i){const o=c.getBranch(a)[c.getIndexById(a)-1];o&&n.exec("move-task",{id:a,mode:"child",target:o.id})}else{const o=c.byId(a),d=c.byId(o.parent);d&&d.parent!==null&&n.exec("move-task",{id:a,mode:"after",target:o.parent})}}),n.on("copy-task",a=>{const{id:i,target:c,mode:o,eventSource:d}=a;if(d==="copy-task")return;const{tasks:l,links:f}=this.getState();if(l.contains(i,c)){a.skipProvider=!0;return}const u=l.getSummaryId(i),g=l.getSummaryId(c);let m=l.getIndexById(c);o==="before"&&(m-=1);const p=l.byId(i),h=l.copy(p,l.byId(c).parent,m+1);a.source=a.id,a.id=h[0][1],p.lazy&&(a.lazy=!0),u!==g&&g&&this.resetSummaryDates(g,"copy-task");let y=[];for(let _=1;_<h.length;_++){const[k,b]=h[_];f.forEach(w=>{if(w.source===k){const v={...w};delete v.target,y.push({...v,source:b})}else if(w.target===k){const v={...w};delete v.source,y.push({...v,target:b})}})}y=y.reduce((_,k)=>{const b=_.findIndex(w=>w.id===k.id);return b>-1?_[b]={..._[b],...k}:_.push(k),_},[]);for(let _=1;_<h.length;_++){const[k,b]=h[_],w=l.byId(b);n.exec("copy-task",{source:k,id:b,lazy:!!w.lazy,eventSource:"copy-task",target:w.parent,mode:"child",skipUndo:!0})}y.forEach(_=>{n.exec("add-link",{link:{source:_.source,target:_.target,type:_.type},eventSource:"copy-task",skipUndo:!0})}),this.setStateAsync({tasks:l})}),n.on("open-task",({id:a,mode:i})=>{const{tree:c}=this.getState(),o=c.byId(a);o.lazy?n.exec("request-data",{id:o.id}):(c.toArray().forEach(d=>d.$y=0),c.update(a,{open:i}),this.setState({tree:c}))}),n.on("scroll-chart",({left:a,top:i,date:c})=>{const{_chartWidth:o,_chartHeight:d,_tasks:l,cellHeight:f,_scales:u,cellWidth:g,_start:m,_weekStart:p}=this.getState();let h={};if(c){const y=u.diff(c,m,"hour");a=Math.round(y*g)}if(!isNaN(a)){if(typeof o<"u"&&!isNaN(u.width)){const y=u.width-o;a=Math.max(Math.min(a,y),0)}h={scrollLeft:a,_scaleDate:we(a,{_scales:u,_start:m,_weekStart:p}),_zoomOffset:null}}if(!isNaN(i)){if(typeof d<"u"){const y=u.height+l.length*f-d;i=Math.max(Math.min(i,y),0)}h.scrollTop=i}this.setState(h)}),n.on("render-data",a=>{this.setState({area:a})}),n.on("provide-data",a=>{const{tasks:i,links:c,assignments:o,durationUnit:d,splitTasks:l}=this.getState(),f=i.byId(a.id);f.lazy?(f.lazy=!1,f.open=!0):f.data=[],Ct(a.data.tasks,{durationUnit:d},this.getTaskCalendar.bind(this)),i.parse(a.data.tasks,a.id),f.type==="summary"&&this.resetSummaryDates(f.id,"provide-data");const u={tasks:i,links:new K(c.map(g=>g).concat(Wt(a.data.links)))};a.data.assignments&&o&&(u.assignments=new K(o.map(g=>g).concat(normalizeAssignments(a.data.assignments)))),this.setStateAsync(u)}),n.on("zoom-scale",({dir:a,ratio:i,offset:c})=>{const o=this.getState(),{zoom:d,cellWidth:l,_cellWidth:f,scrollLeft:u}=o,g=(c||0)+u,m=we(g,o),p=a<0&&f||l;let h=Math.round(p*(1+a*(i??.15)));const{maxCellWidth:y,minCellWidth:_}=d.levels[d.level],k=a<0&&l>y;if(this.shouldExpandScale(h)){this.changeScale(d,a)&&this.setState({cellWidth:h,_cellWidth:h});return}if(h<_||h>y||k){if(!this.changeScale(d,a))if(h=Math.max(Math.min(h,y),_),h!==l)this.setState({cellWidth:h,_cellWidth:h});else return}else this.setState({cellWidth:h,_cellWidth:h});const{_scales:b,_start:w,cellWidth:v,_weekStart:$}=this.getState(),M=C(b.minUnit,w,$),T=b.diff(m,M,"hour");typeof c>"u"&&(c=v);let D=Math.round(T*v)-c;D<0&&(D=0),this.setState({scrollLeft:D,_scaleDate:m,_zoomOffset:c})}),n.on("sort-tasks",({key:a,order:i,add:c})=>{const o=this.getState(),{tasks:d,tree:l,columns:f}=o;let u=o._sort;const g={key:a,order:i};let m=u?.length||0;m&&c?(u.forEach((p,h)=>{p.key===a&&(m=h)}),u[m]=g):u=[g],l.sort(u,f),this.setState({_sort:u,tree:l})}),n.on("filter-tasks",a=>{const{open:i,key:c,value:o}=a;let d=a.filter;const l=this.getState(),{tasks:f,columns:u}=l;let g=l.filterValues;c?g={...g,[c]:o}:Object.keys(a).length||(g={}),!d&&Object.values(g).some(m=>m||m===0)&&(d=Je(g,u)),f.filterTree(d,i??!0),this.setState({tasks:f,_isFiltered:!!d,filterValues:g})}),n.on("hotkey",({key:a,event:i,eventSource:c})=>{switch(a){case"arrowup":case"arrowdown":{const{selected:o,_tasks:d}=this.getState();i.preventDefault();const l=o.length;let f;if(a==="arrowup"?f=l?this.getPrevRow(o[l-1])?.id:d[d.length-1]?.id:f=l?this.getNextRow(o[l-1])?.id:d[0]?.id,f){const u=c==="chart"?"xy":!0,g=c;this.in.exec("select-task",{id:f,show:u,focus:g})}break}case"ctrl+c":{V(this,"copy-task",null,null);break}case"ctrl+x":{V(this,"cut-task",null,null);break}case"ctrl+v":{V(this,"paste-task",null,null);break}case"ctrl+d":case"backspace":{i.preventDefault(),V(this,"delete-task",null,null);break}case"ctrl+z":{this.in.exec("undo",{});break}case"ctrl+y":{this.in.exec("redo",{});break}}}),n.on("resize-chart",({width:a,height:i,scrollSize:c})=>{let o={};const d=this.getState();a>d._scales?.width&&(o=Xs(a,d)),this.setState({...o,_chartWidth:a,_chartHeight:i,_scrollSize:c})}),n.on("resize-grid",({width:a})=>{this.setState({gridWidth:a})}),n.on("set-columns",({columns:a})=>{const i=this.getState().columns.map(c=>{const o=a.find(d=>d.id===c.id);return o?{...c,width:o.width,hidden:o.hidden,flexgrow:o.flexgrow}:c});De(i),this.setState({columns:i})}),n.on("set-display-mode",({mode:a})=>{this.getState()._compactMode&&a==="all"||this.setState({displayMode:a})}),n.on("open-resource-row",({id:a,mode:i})=>{const{resources:c}=this.getState();c.update(a,{open:i}),this.setState({resources:c})}),n.on("sort-resources",({key:a,order:i,add:c,_columns:o})=>{const d=this.getState(),{resources:l}=d;let f=d._resourceSort;const u={key:a,order:i};let g=f?.length||0;g&&c?(f.forEach((m,p)=>{m.key===a&&(g=p)}),f[g]=u):f=[u],l.sort(f,o),this.setState({_resourceSort:f,resources:l})})}init(t){const n=this.getState().area?{}:{scrollLeft:0,scrollTop:0,area:{from:0,start:0,end:0},xArea:{from:0,to:0,start:0,end:0},_isFiltered:!1,filterValues:{},groupBy:{field:null},tree:[]};t.cellWidth&&(t._cellWidth=t.cellWidth),t._compactMode&&t.displayMode!==this.getState().displayMode&&(t.displayMode=t.displayMode==="all"?"grid":t.displayMode),t.unscheduledTasks=!1,t.baselines=!1,t.markers=[],t._markers=[],t.undo=!1,t.schedule={},t.criticalPath=null,t.splitTasks=!1,t.summary={},t.rollups=!1,t._rollups={},t.slack=!1,t.resources=null,t._resources=[],t.assignments=[],t.calendar=null,t.calendars=[],t._calendar=null,t._calendars={},t.groupBy=null,t.wbs=null;const s=this.getState();if(Array.isArray(t.calendars)&&t.calendars.length>0?s.calendars===t.calendars?t._calendars=s._calendars:(t._calendars={},t.calendars.forEach(({id:o,...d})=>{t._calendars[o]=new It(d),t._calendars[o].css=d.css})):s._calendars||(t._calendars={}),s.calendar===t.calendar&&s._calendar)t._calendar=s._calendar;else if(typeof t.calendar=="string"){const o=t._calendars?.[t.calendar];o&&(t._calendar=o)}else t.calendar&&typeof t.calendar=="object"?t._calendar=new It(t.calendar):t.calendar===!0&&(t._calendar=new It);t._calendar&&t.tasks&&(t.highlightTime=(o,d)=>{const l=this.getCalendar();return l&&(d==="day"||d==="hour")&&!l.isWorkingDay(o)?"wx-weekend":""});const r=this.changed(t,"tasks"),a=this.changed(t,"links"),i=this.changed(t,"resources"),c=this.changed(t,"assignments");this.changed(t,"projectStart"),r||a||this.changed(t,"criticalPath","slack","unscheduledTasks");for(const o in t)o[0]!=="_"&&(this._prevConfig[o]=t[o]);if(t.tasks)if(r){const o=t.tasks.map(d=>{const l={...d};return d.segments&&(l.segments=d.segments.map(f=>({...f}))),l});Ct(o,{durationUnit:t.durationUnit,splitTasks:t.splitTasks},d=>{const l=d?.calendar;return l!=null&&t._calendars?.[l]?t._calendars[l]:t._calendar}),t.tasks=o}else delete t.tasks;if((r||a||i||c)&&this.getHistory()?.resetHistory(),r){const o=this.getState();o._isFiltered&&this.setState({_isFiltered:!1,filterValues:{}}),o._sort&&this.setState({_sort:null})}i&&this.getState()._resourceSort&&this.setState({_resourceSort:null}),this._router.init({selected:[],markers:[],autoScale:!0,durationUnit:"day",highlightTime:null,focusTask:null,gridWidth:440,_compactMode:!1,_sort:null,_resourceSort:null,...n,...t})}changed(t,...n){return n.some(s=>{if(!(s in t))return!1;const r=this._prevConfig[s],a=t[s];return r!==a&&!J(r,a)})}setState(t,n){return this._router.setState(t,n)}setStateAsync(t){this._router.setStateAsync(t)}getTask(t){const{tree:n}=this.getState();return n.byId(t)}getResource(t){const{resources:n}=this.getState();return n.byId(t)}getHistory(){return this.getState().undo?this._modules.get("historyManager"):null}getCalendar(t){const{_calendar:n,_calendars:s}=this.getState();return s?.[t]??n??void 0}getTaskCalendar(t){return this.getCalendar(t?.calendar)}getResourceCalendar(t){return this.getCalendar(t?.calendar)}getLoadHours(t,n,s){const r=this.getTaskCalendar(n),a=this.getResourceCalendar(s);return r&&a?Math.min(r.getWorkingHours(t),a.getWorkingHours(t)):a?.getWorkingHours(t)??r?.getWorkingHours(t)}getGrouping(){return this.getState().groupBy?.field?this._modules.get("groupManager"):null}serialize(t){const n=t?.data||"tasks";if(n==="calendars"){const{_calendars:r}=this.getState();return r?Object.entries(r).map(([a,i])=>({...i?.serialize?.()||{},...i?.css?{css:i.css}:{},id:a})):null}const s=this.getState()[n];if(s){if(s instanceof Gt)return s.serialize();if(s instanceof K)return s.map(r=>r);if(s instanceof zt)return s.toArray()}return null}getTaskResources(t){const{_assignments:n,resources:s}=this.getState();if(!s||!n)return[];const r=n.byTask[t];return r?r.map(a=>{const i=s.byId(a.resource),c={...a};return delete c.resource,delete c.task,i?{...c,...i,assignmentId:a.id}:null}).filter(Boolean):[]}getResourceTasks(t){const{_assignments:n,tasks:s}=this.getState();if(!n)return[];const r=n.byResource[t];return r?r.map(a=>s.byId(a.task)||null).filter(Boolean):[]}changeScale(t,n){const s=t.level+n,r=t.levels[s];if(r){const{cellWidth:a,scales:i,_scales:c}=this.getState(),o=qs(t,n,s,r,c.lengthUnit,i,a);return o._cellWidth=o.cellWidth,this.setState(o),!0}return!1}shouldExpandScale(t){const{start:n,end:s,_chartWidth:r,_scales:a,cellWidth:i}=this.getState();return n&&s&&r&&a?.width&&i?a.width/i*t<r:!1}isScheduled(t){return this.getState().unscheduledTasks?t.some(n=>!n.unscheduled||n.data&&this.isScheduled(n.data)):!0}resetSummaryDates(t,n,s){const{tasks:r,durationUnit:a,splitTasks:i}=this.getState(),c=r.byId(t),o=c.data;if(o?.length&&this.isScheduled(o)){const d=Tt({...c,start:void 0,end:void 0,duration:void 0});if(!j(c.start,d.start)||!j(c.end,d.end)){s?(N(d,{durationUnit:a},this.getTaskCalendar(d)),r.update(t,d)):this.in.exec("update-task",{id:t,task:d,eventSource:n,skipUndo:!0});const l=r.getSummaryId(t);l&&this.resetSummaryDates(l,n)}}}moveSummaryKids(t,n,s){const{tasks:r}=this.getState();t.data.forEach(a=>{const i={...r.byId(a.id),start:n(a.start,a)};delete i.end,delete i.id,this.in.exec("update-task",{id:a.id,task:i,eventSource:s,skipUndo:!0}),a.data?.length&&this.moveSummaryKids(a,n,s)})}getNextRow(t){const n=this.getState()._tasks,s=n.findIndex(r=>r.id===t);return n[s+1]}getPrevRow(t){const n=this.getState()._tasks,s=n.findIndex(r=>r.id===t);return n[s-1]}scrollToTask(t,n){const{_chartWidth:s,_chartHeight:r,scrollLeft:a,scrollTop:i,cellWidth:c,cellHeight:o,_tasks:d,_scrollSize:l}=this.getState(),f=d.findIndex(h=>h.id===t||h.$id===t);if(f<0)return;const u=this.getTask(d[f].id),g={};if(n?.toString().indexOf("x")!==-1){if(u.$x+u.$w/2<a)g.left=Math.max(u.$x-(c||0),0);else if(u.$x+u.$w/2>=s+a){const h=s<u.$w?c:u.$w;g.left=u.$x-s+h}}const m=f*o;let p=null;m<i?p=m:m+o>i+r&&(p=m-r+o+l),p!==null&&(g.top=Math.max(p,0)),this.in.exec("scroll-chart",g)}}function ga(e,t,n,s){if(typeof document>"u")return"";const r=document.createElement("canvas");{const a=ma(r,e,t,1,n);pa(a,s,0,e,0,t)}return r.toDataURL()}function ma(e,t,n,s,r){e.setAttribute("width",(t*s).toString()),e.setAttribute("height",(n*s).toString());const a=e.getContext("2d");return a.translate(-.5,-.5),a.strokeStyle=r,a}function pa(e,t,n,s,r,a){e.beginPath(),e.moveTo(s,r),e.lineTo(s,a),t==="full"&&e.lineTo(n,a),e.stroke()}const Pt=[{id:"task",label:"Task"},{id:"summary",label:"Summary task"},{id:"milestone",label:"Milestone"}];function Fe(e){return!e.$group&&typeof e.$groupValue<"u"}function ya(e){return e.$group}function ka(e){let t=Ne.map(r=>({...r}));const n=e?.taskTypes||Pt,s=t.find(r=>r.id==="convert-task");return s.data=[],n.forEach(r=>{(!e?.summary?.autoConvert||r.id!=="summary")&&s.data.push(s.dataFactory(r))}),t}function Et(e){return e.map(t=>{switch(t.data&&Et(t.data),t.id){case"add-task:before":case"move-task:up":t.isDisabled=(n,s)=>wa(n,s)||Fe(n)||ya(n);break;case"move-task:down":t.isDisabled=(n,s)=>ba(n,s);break;case"indent-task:add":t.isDisabled=(n,s)=>xa(n,s)===n.parent;break;case"indent-task:remove":t.isDisabled=n=>_a(n);break}return t})}function _a(e){return e.parent===0}function wa(e,t){const{_tasks:n}=t;return n[0]?.id===e.id}function ba(e,t){const{_tasks:n}=t;return n[n.length-1]?.id===e.id}function xa(e,t){const{_tasks:n}=t,s=n.findIndex(r=>r.id===e.id);return n[s-1]?.id??e.parent}function Sa(e){return e&&typeof e=="object"}function va(e){return!e.selected||e.selected.length<2}const Ma=e=>t=>t.type===e||e==="summary"&&Fe(t),Ne=Et([{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"}]},{comp:"separator"},{id:"convert-task",text:"Convert to",icon:"wxi-swap-horizontal",dataFactory:e=>({id:`convert-task:${e.id}`,text:`${e.label}`,isDisabled:Ma(e.id)})},{id:"edit-task",text:"Edit",icon:"wxi-edit"},{comp:"separator"},{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"}]},{comp:"separator"},{id:"indent-task:add",text:"Indent",icon:"wxi-indent"},{id:"indent-task:remove",text:"Outdent",icon:"wxi-unindent"},{comp:"separator"},{id:"delete-task",icon:"wxi-delete",text:"Delete",subtext:"Ctrl+D / BS",isHidden:(e,t,n)=>va(t)&&Sa(n)}]);function Ta(e){return[...ze]}const ze=Et([{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"}]);function ct(e){return e.type==="summary"}function Ot(e){return e.type==="milestone"}function dt(e){return typeof e.parent>"u"}function At(e,t){return t.unscheduledTasks&&e.unscheduled}function $a(e){const t=Be.map(s=>({...s})),n=t.find(s=>s.key==="type");return n.options=e?.taskTypes||Pt,t}const Be=[{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",isHidden:e=>dt(e)},{key:"start",comp:"date",label:"Start date",config:{format:"%d-%m-%Y"},isHidden:e=>ct(e),isDisabled:At},{key:"end",comp:"date",label:"End date",config:{format:"%d-%m-%Y"},isHidden:e=>ct(e)||Ot(e),isDisabled:At},{key:"duration",comp:"counter",label:"Duration",config:{min:1},isHidden:e=>ct(e)||Ot(e),isDisabled:At},{key:"progress",comp:"slider",label:"Progress",config:{min:1,max:100},isHidden:e=>Ot(e)||dt(e)},{key:"links",comp:"links",label:"",batch:"links",isHidden:e=>dt(e)}];function Ht(e,t){return!e||!Array.isArray(e)?e:e.filter(t).map(n=>n.items&&Array.isArray(n.items)?{...n,items:Ht(n.items,t)}:{...n})}const Da=[{items:[{comp:"icon",icon:"wxi-close",id:"close"},{comp:"spacer"},{comp:"button",type:"danger",text:"Delete",id:"delete"},{comp:"button",type:"primary",text:"Save",id:"save"}]},{id:"tabs",comp:"tabs",css:"wx-toolbar-tabs",options:[{id:"general",label:"General"},{id:"links",label:"Links"}]}];function Wa(e){let t=Da.map(s=>({...s}));e?.autoSave!==!1&&(t=Ht(t,s=>s.id!=="save"));const n=t.find(s=>s.id==="tabs");return n?.options&&(n.options=[...n.options]),e?.resources&&n?.options.push({id:"resources",label:"Resources",isHidden:s=>ct(s)||dt(s)}),e?.splitTasks&&n?.options.push({id:"segments",label:"Segments",isHidden:s=>!s.segments?.length}),t}function Ia(e){return null}export{fa as DataStore,Pe as calculateArea,Ia as createCalendar,We as defaultColumns,Be as defaultEditorItems,Ne as defaultMenuOptions,Pt as defaultTaskTypes,ze as defaultToolbarButtons,Js as extendDragOptions,Ht as filterEditorButtons,ue as format,_e as formatDay,I as getAdder,ia as getDefaultColumns,oa as getDefaultGridWidth,rt as getDiffer,Wa as getEditorButtons,$a as getEditorItems,ka as getMenuOptions,ca as getResourceColumns,Ta as getToolbarButtons,C as getUnitStart,ga as grid,V as handleAction,Ce as isHandledAction,Vs as isSegmentMoveAllowed,Wt as normalizeLinks,da as normalizeResourceColumns,Us as normalizeZoom,Ct as parseTaskDates,na as placeLink,ha as prepareEditTask,Bs as registerScaleUnit};
1
+ var te=new Date().valueOf(),Wn=()=>te++;function ee(){return"temp://"+te++}function Tn(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in e){const s=t[n],a=e[n];if(!dt(s,a))return!1}return!0}function dt(t,e){if(typeof t=="number"||typeof t=="string"||typeof t=="boolean"||t===null)return t===e;if(typeof t!=typeof e||(t===null||e===null)&&t!==e||t instanceof Date&&e instanceof Date&&t.getTime()!==e.getTime())return!1;if(typeof t=="object")if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let n=t.length-1;n>=0;n--)if(!dt(t[n],e[n]))return!1;return!0}else return Tn(t,e);return t===e}var kt=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:Wn(),...t},this._data.push(t),this._pool.set(t.id,t)}update(t,e){const n=this._data.findIndex(a=>a.id==t),s={...this._data[n],...e};this._data[n]=s,this._pool.set(s.id,s)}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)}},ne=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 a=0;a<t.length;a++){const o=t[a];o.parent=o.parent||e,o.data=null,n.set(o.id,o)}for(let a=0;a<t.length;a++){const o=t[a],r=n.get(o.parent);r&&(r.data||(r.data=[]),r.data.push(o))}const s=n.get(e);this.setLevel(s,s.$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]:ae(n,e,t):n.data=[t]}addAfter(t,e){if(!e)return this.add(t,-1);const n=this.byId(e),s=this.byId(n.parent),a=ct(s,n.id)+1;t.parent=s.id,t.$level=s.$level+1,this.add(t,a)}remove(t){const e=this._pool.get(t);this._remove(e);const n=this._pool.get(e.parent);n.data=n.data.filter(s=>s.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 s=this._pool.get(n.parent),a=ct(s,n.id);n={...n,...e},s&&a>=0&&(s.data[a]=n,s.data=[...s.data]),this._pool.set(n.id,n)}move(t,e,n){const s=this._pool.get(t),a=e==="child",o=this._pool.get(n),r=o.$level+(a?1:0);if(!s||!o)return;const i=this._pool.get(s.parent),d=a?o:this._pool.get(o.parent);d.data||(d.data=[]);const c=ct(i,s.id);Dn(i,c);const l=a?d.data.length:ct(d,o.id)+(e==="after"?1:0);if(ae(d,l,s),i.id===d.id&&c===l)return null;s.parent=d.id,s.$level!==r&&(s.$level=r,this.setLevel(s,r+1,!0)),this.update(s.id,s),this._clearBranch(i)}_clearBranch(t){t.data&&!t.data.length&&(t.open&&delete t.open,this.update(t.id,{data:null}))}toArray(){return this._flatten(!1)}serialize(){return this._flatten(!0)}_flatten(t){const e=[],n=this._pool.get(0).data;return n&&se(n,e,t),e}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((s,a)=>{t(this.byId(s.id),a),this.eachChild(t,s.id)})}setLevel(t,e,n){t.data&&(t.data=t.data.map(s=>(n&&(s={...s},this._pool.set(s.id,s)),s.$level=e,s.data&&this.setLevel(s,e+1,n),s)))}};function se(t,e,n){t.forEach(s=>{e.push(s),s.data&&(n||s.open)&&se(s.data,e,n)})}function Dn(t,e){const n=[...t.data];n.splice(e,1),t.data=n}function ae(t,e,n){const s=[...t.data];s.splice(e,0,n),t.data=s}function ct(t,e){return t?.data.findIndex(n=>n.id===e)}var re=2,In=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,s,a,o){for(const r in t){const i=e[r],d=n[r],c=t[r];if(i&&(d===c&&typeof c!="object"||c instanceof Date&&d instanceof Date&&d.getTime()===c.getTime()))continue;const l=s+(s?".":"")+r;i?(i.__parse(c,l,a,o)&&(n[r]=c),o&re?a[l]=i.__trigger:i.__trigger()):(c&&c.__reactive?e[r]=this._wrapNested(c,c,l,a):e[r]=this._wrapWritable(c),n[r]=c),a[l]=a[l]||null}}_wrapNested(t,e,n,s){const a=this._wrapWritable(t);return this._wrapProperties(t,a,e,n,s,0),a.__parse=(o,r,i,d)=>(this._wrapProperties(o,a,e,r,i,d),!1),a}_wrapWritable(t){const e=[],n=function(){for(let s=0;s<e.length;s++)e[s](t)};return{subscribe:s=>(e.push(s),this._async?setTimeout(s,1,t):s(t),()=>{const a=e.indexOf(s);a>=0&&e.splice(a,1)}),__trigger:()=>{e.length&&(this._async?setTimeout(n,1):n())},__parse:function(s){return t=s,!0}}}},$n=class{constructor(t,e,n,s){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(a=>{a.in.forEach(o=>{const r=this._triggers.get(o)||[];r.push(a),this._triggers.set(o,r)}),a.out.forEach(o=>{const r=this._sources.get(o)||{};a.in.forEach(i=>r[i]=!0),this._sources.set(o,r)})}),this._routes.forEach(a=>{a.length=Math.max(...a.in.map(o=>ie(o,this._sources,1)))}),this._bus=s}init(t){const e={};for(const n in t)if(this._prev[n]!==t[n]){const s=this._parsers[n];e[n]=s?s(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,re);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),s=!e.length;e=e||[];for(let a=0;a<n.length;a++){const o=n[a],r=this._triggers.get(o);r&&r.forEach(i=>{e.indexOf(i)==-1&&e.push(i)})}s&&this._execNext(e)}_execNext(t){for(;t.length;){t.sort((n,s)=>n.length<s.length?1:-1);const e=t[t.length-1];t.splice(t.length-1),e.exec(t)}}};function ie(t,e,n){const s=e.get(t);if(!s)return n;const a=Object.keys(s).map(o=>ie(o,e,n+1));return Math.max(...a)}var Cn=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(t,e,n){let s=this._handlers[t];s?n&&n.intercept?s.unshift(e):s.push(e):s=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 s=n.length-1;s>=0;s--)this._tag.get(n[s])===t&&n.splice(s,1)}}async exec(t,e){const n=this._handlers[t];if(n)for(let s=0;s<n.length;s++){const a=n[s](e);if(a===!1||a&&a.then&&await a===!1)return}return this._nextHandler&&await this._nextHandler.exec(t,e),e}setNext(t){return this._nextHandler=t}};new Date().valueOf();function Pn(t){return e=>e[t]}function bt(t,e){return(e.getter||Pn(e.id))(t)}const En={text:(t,e)=>t?t.toString().toLowerCase().indexOf(e.toLowerCase())!==-1:!e,richselect:(t,e)=>typeof e!="number"&&!e?!0:t==e,datepicker:(t,e)=>e?t&&An(t,e):!0,multiselect:(t,e)=>!e||e?.length===0?!0:Array.isArray(t)?t?.some(n=>e.includes(n)):t&&e.includes(t)};function On(t){return En[t]}function Gn(t,e){const n=[];for(const s in t){const a=e.find(d=>d.id==s),{config:o,type:r}=a.header.find(d=>d.filter).filter,i=t[s];n.push(d=>{const c=bt(d,a);return o?.handler?o.handler(c,i):On(r)(c,i)})}return s=>{for(let a=0;a<n.length;a++)if(!n[a](s))return!1;return!0}}function An(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}new Date().valueOf(),new Date().valueOf();function Hn(t,e){return typeof t=="string"?t.localeCompare(e,void 0,{numeric:!0}):t instanceof Date||e instanceof Date?t?e?t.getTime()-e.getTime():-1:1:(t??0)-(e??0)}function zn(t,e){return typeof t=="string"?-t.localeCompare(e,void 0,{numeric:!0}):t instanceof Date||e instanceof Date?e?t?e.getTime()-t.getTime():-1:1:(e??0)-(t??0)}function Fn({order:t,key:e},n){if(typeof n?.sort=="function")return function(a,o){const r=n.sort(a,o);return t==="asc"?r:-r};const s=t==="asc"?Hn:zn;return(a,o)=>s(n?bt(a,n):a[e],n?bt(o,n):o[e])}function Bn(t,e){if(!t||!t.length)return;const n=t.map(s=>{const a=e.find(o=>o.id==s.key);return Fn(s,a)});return t.length===1?n[0]:function(s,a){for(let o=0;o<n.length;o++){const r=n[o](s,a);if(r!==0)return r}return 0}}function Ln(t,e,n){return t.sort(Bn(e,n))}function oe(t,e,n,s){const a=t.id===0||e(t);let o=!1;if(Array.isArray(t.data)){for(const r of t.data)oe(r,e,n,s)&&(o=!0);o?(delete t.$empty,s&&(t.open=!0)):t.$empty=!0}return(a||o)&&t.id!==0?(n.add(t.id),!0):!1}function de(t,e,n){t.has(e)&&t.delete(e),n?.length&&n.forEach(s=>de(t,s.id,s.data))}function ce(t){t.id!==0&&delete t.$empty,Array.isArray(t.data)&&t.data.forEach(e=>ce(e))}const le=new WeakMap;class Nn extends ne{_filteredIds;constructor(e){super(),this.parse(e,0)}parse(e,n){if(!e||!e.length)return;const s=e.map(a=>this.normalizeTask(a));super.parse(s,n)}getBranch(e){const n=this._pool.get(e);return this._pool.get(n.parent||0).data}contains(e,n){const s=this._pool.get(e).data;let a=!1;if(s)for(let o=0;o<s.length;o++){if(s[o].id===n){a=!0;break}if(s[o].data&&(a=this.contains(s[o].id,n),a))break}return a}getIndexById(e){return this._indexOf(this.getBranch(e),e)}update(e,n){let s=this._pool.get(e);const a=this._pool.get(s.parent)?.data,o=a?this._indexOf(a,e):-1;s={...s,...n},o>=0&&(a[o]=s),this._pool.set(s.id,s)}_indexOf(e,n){let s=le.get(e);if(s&&s.size===e.length){const o=s.get(n);if(o!==void 0&&e[o].id===n)return o}s=new Map;for(let o=0;o<e.length;o++)s.set(e[o].id,o);le.set(e,s);const a=s.get(n);return a===void 0?-1:a}add(e,n){const s=this.normalizeTask(e);if(super.add(s,n),this._filteredIds&&this._filteredIds.add(s.id),this._filteredIds&&e.parent){const a=this.byId(e.parent);this.hasChildItems(a)&&delete a.$empty}return s}copy(e,n,s){const a=this.add({...e,id:null,data:null,parent:n},s);let o=[[e.id,a.id]];return e.data?.forEach((r,i)=>{const d=this.copy(r,a.id,i);o=o.concat(d)}),o}remove(e){const n=this.byId(e);if(this._filteredIds&&de(this._filteredIds,e,n.data),super.remove(e),this._filteredIds&&n.parent){const s=this.byId(n.parent);this.hasChildItems(s)||(s.$empty=!0)}}normalizeTask(e){const n=e.id||ee(),s=e.parent||0,a=e.text??"",o=e.type||"task",r=e.progress||0,i=e.details||"",d={...e,id:n,text:a,parent:s,progress:r,type:o,details:i};return e.segments&&(d.segments=e.segments.map(c=>({...c}))),e.segments&&(d.segments=e.segments.map(c=>({...c}))),d}getSummaryId(e,n=!1){const s=this._pool.get(e);if(!s.parent)return null;const a=this._pool.get(s.parent);if(n){let o=e,r=this.getSummaryId(o);const i=[];for(;r;)o=r,i.push(r),r=this.getSummaryId(o);return i}return a.type==="summary"?a.id:this.getSummaryId(a.id)}sort(e,n){e&&this.sortBranch(e,0,n)}sortBranch(e,n,s){const a=this._pool.get(n||0).data;a&&(Ln(a,e,s),a.forEach(o=>{this.sortBranch(e,o.id,s)}))}clear(){this.forEach(e=>{this.remove(e.id)})}filterTree(e,n){if(e){const s=this._pool.get(0),a=new Set;oe(s,e,a,n),this._filteredIds=a}else{const s=this._pool.get(0);ce(s),this._filteredIds=null}}toArray(e){let n=super.toArray();return!e&&this._filteredIds&&(n=n.filter(s=>this.isFilteredId(s.id))),n}isFilteredId(e){return this._filteredIds?.has(e)}hasChildItems(e){const n=e.data?.length;return n&&this._filteredIds?e.data.some(s=>this.isFilteredId(s.id)):!!n}}function x(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 C(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function E(t,e){const n=x(t);return isNaN(e)?C(t,NaN):(e&&n.setDate(n.getDate()+e),n)}function _t(t,e){const n=x(t);if(isNaN(e))return C(t,NaN);if(!e)return n;const s=n.getDate(),a=C(t,n.getTime());a.setMonth(n.getMonth()+e+1,0);const o=a.getDate();return s>=o?a:(n.setFullYear(a.getFullYear(),a.getMonth(),s),n)}function ue(t,e){const n=+x(t);return C(t,n+e)}const lt=6048e5,Yn=864e5,he=6e4,fe=36e5;function Un(t,e){return ue(t,e*fe)}let jn={};function V(){return jn}function H(t,e){const n=V(),s=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=x(t),o=a.getDay(),r=(o<s?7:0)+o-s;return a.setDate(a.getDate()-r),a.setHours(0,0,0,0),a}function R(t){return H(t,{weekStartsOn:1})}function ge(t){const e=x(t),n=e.getFullYear(),s=C(t,0);s.setFullYear(n+1,0,4),s.setHours(0,0,0,0);const a=R(s),o=C(t,0);o.setFullYear(n,0,4),o.setHours(0,0,0,0);const r=R(o);return e.getTime()>=a.getTime()?n+1:e.getTime()>=r.getTime()?n:n-1}function L(t){const e=x(t);return e.setHours(0,0,0,0),e}function ut(t){const e=x(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 wt(t,e){const n=L(t),s=L(e),a=+n-ut(n),o=+s-ut(s);return Math.round((a-o)/Yn)}function St(t){const e=ge(t),n=C(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),R(n)}function Rn(t,e){return ue(t,e*he)}function qn(t,e){const n=e*3;return _t(t,n)}function me(t,e){const n=e*7;return E(t,n)}function Xn(t,e){return _t(t,e*12)}function J(t,e){const n=x(t),s=x(e),a=n.getTime()-s.getTime();return a<0?-1:a>0?1:a}function pe(t,e){const n=L(t),s=L(e);return+n==+s}function Qn(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Vn(t){if(!Qn(t)&&typeof t!="number")return!1;const e=x(t);return!isNaN(Number(e))}function xt(t,e){const n=R(t),s=R(e),a=+n-ut(n),o=+s-ut(s);return Math.round((a-o)/lt)}function Jn(t,e){const n=x(t),s=x(e),a=n.getFullYear()-s.getFullYear(),o=n.getMonth()-s.getMonth();return a*12+o}function Kn(t,e){const n=x(t),s=x(e);return n.getFullYear()-s.getFullYear()}function vt(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return n===0?0:n}}function ye(t,e){return+x(t)-+x(e)}function Zn(t,e,n){const s=ye(t,e)/fe;return vt(n?.roundingMethod)(s)}function ts(t,e,n){const s=ye(t,e)/he;return vt(n?.roundingMethod)(s)}function ke(t){const e=x(t);return e.setHours(23,59,59,999),e}function Mt(t){const e=x(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function es(t){const e=x(t);return+ke(e)==+Mt(e)}function be(t,e){const n=x(t),s=x(e),a=J(n,s),o=Math.abs(Jn(n,s));let r;if(o<1)r=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*o);let i=J(n,s)===-a;es(x(t))&&o===1&&J(t,s)===1&&(i=!1),r=a*(o-Number(i))}return r===0?0:r}function ns(t,e,n){const s=be(t,e)/3;return vt(n?.roundingMethod)(s)}function ss(t,e){const n=x(t),s=x(e),a=J(n,s),o=Math.abs(Kn(n,s));n.setFullYear(1584),s.setFullYear(1584);const r=J(n,s)===-a,i=a*(o-+r);return i===0?0:i}function K(t){const e=x(t),n=e.getMonth(),s=n-n%3;return e.setMonth(s,1),e.setHours(0,0,0,0),e}function _e(t){const e=x(t);return e.setDate(1),e.setHours(0,0,0,0),e}function as(t){const e=x(t),n=e.getFullYear();return e.setFullYear(n+1,0,0),e.setHours(23,59,59,999),e}function we(t){const e=x(t),n=C(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}function rs(t){const e=x(t);return e.setMinutes(59,59,999),e}function is(t,e){const n=V(),s=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=x(t),o=a.getDay(),r=(o<s?-7:0)+6-(o-s);return a.setDate(a.getDate()+r),a.setHours(23,59,59,999),a}function Wt(t){const e=x(t),n=e.getMonth(),s=n-n%3+3;return e.setMonth(s,0),e.setHours(23,59,59,999),e}const os={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"}},ds=(t,e,n)=>{let s;const a=os[t];return typeof a=="string"?s=a:e===1?s=a.one:s=a.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+s:s+" ago":s};function Tt(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const cs={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ls={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},us={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},hs={date:Tt({formats:cs,defaultWidth:"full"}),time:Tt({formats:ls,defaultWidth:"full"}),dateTime:Tt({formats:us,defaultWidth:"full"})},fs={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},gs=(t,e,n,s)=>fs[t];function Z(t){return(e,n)=>{const s=n?.context?String(n.context):"standalone";let a;if(s==="formatting"&&t.formattingValues){const r=t.defaultFormattingWidth||t.defaultWidth,i=n?.width?String(n.width):r;a=t.formattingValues[i]||t.formattingValues[r]}else{const r=t.defaultWidth,i=n?.width?String(n.width):t.defaultWidth;a=t.values[i]||t.values[r]}const o=t.argumentCallback?t.argumentCallback(e):e;return a[o]}}const ms={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ps={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ys={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"]},ks={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"]},bs={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"}},_s={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"}},ws=(t,e)=>{const n=Number(t),s=n%100;if(s>20||s<10)switch(s%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Ss={ordinalNumber:ws,era:Z({values:ms,defaultWidth:"wide"}),quarter:Z({values:ps,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Z({values:ys,defaultWidth:"wide"}),day:Z({values:ks,defaultWidth:"wide"}),dayPeriod:Z({values:bs,defaultWidth:"wide",formattingValues:_s,defaultFormattingWidth:"wide"})};function tt(t){return(e,n={})=>{const s=n.width,a=s&&t.matchPatterns[s]||t.matchPatterns[t.defaultMatchWidth],o=e.match(a);if(!o)return null;const r=o[0],i=s&&t.parsePatterns[s]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(i)?vs(i,f=>f.test(r)):xs(i,f=>f.test(r));let c;c=t.valueCallback?t.valueCallback(d):d,c=n.valueCallback?n.valueCallback(c):c;const l=e.slice(r.length);return{value:c,rest:l}}}function xs(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function vs(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function Ms(t){return(e,n={})=>{const s=e.match(t.matchPattern);if(!s)return null;const a=s[0],o=e.match(t.parsePattern);if(!o)return null;let r=t.valueCallback?t.valueCallback(o[0]):o[0];r=n.valueCallback?n.valueCallback(r):r;const i=e.slice(a.length);return{value:r,rest:i}}}const Ws=/^(\d+)(th|st|nd|rd)?/i,Ts=/\d+/i,Ds={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},Is={any:[/^b/i,/^(a|c)/i]},$s={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Cs={any:[/1/i,/2/i,/3/i,/4/i]},Ps={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},Es={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]},Os={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},Gs={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]},As={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},Hs={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}},zs={ordinalNumber:Ms({matchPattern:Ws,parsePattern:Ts,valueCallback:t=>parseInt(t,10)}),era:tt({matchPatterns:Ds,defaultMatchWidth:"wide",parsePatterns:Is,defaultParseWidth:"any"}),quarter:tt({matchPatterns:$s,defaultMatchWidth:"wide",parsePatterns:Cs,defaultParseWidth:"any",valueCallback:t=>t+1}),month:tt({matchPatterns:Ps,defaultMatchWidth:"wide",parsePatterns:Es,defaultParseWidth:"any"}),day:tt({matchPatterns:Os,defaultMatchWidth:"wide",parsePatterns:Gs,defaultParseWidth:"any"}),dayPeriod:tt({matchPatterns:As,defaultMatchWidth:"any",parsePatterns:Hs,defaultParseWidth:"any"})},Fs={code:"en-US",formatDistance:ds,formatLong:hs,formatRelative:gs,localize:Ss,match:zs,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Bs(t){const e=x(t);return wt(e,we(e))+1}function Ls(t){const e=x(t),n=+R(e)-+St(e);return Math.round(n/lt)+1}function Se(t,e){const n=x(t),s=n.getFullYear(),a=V(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,r=C(t,0);r.setFullYear(s+1,0,o),r.setHours(0,0,0,0);const i=H(r,e),d=C(t,0);d.setFullYear(s,0,o),d.setHours(0,0,0,0);const c=H(d,e);return n.getTime()>=i.getTime()?s+1:n.getTime()>=c.getTime()?s:s-1}function Ns(t,e){const n=V(),s=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=Se(t,e),o=C(t,0);return o.setFullYear(a,0,s),o.setHours(0,0,0,0),H(o,e)}function Ys(t,e){const n=x(t),s=+H(n,e)-+Ns(n,e);return Math.round(s/lt)+1}function M(t,e){const n=t<0?"-":"",s=Math.abs(t).toString().padStart(e,"0");return n+s}const z={y(t,e){const n=t.getFullYear(),s=n>0?n:1-n;return M(e==="yy"?s%100:s,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):M(n+1,2)},d(t,e){return M(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 M(t.getHours()%12||12,e.length)},H(t,e){return M(t.getHours(),e.length)},m(t,e){return M(t.getMinutes(),e.length)},s(t,e){return M(t.getSeconds(),e.length)},S(t,e){const n=e.length,s=t.getMilliseconds(),a=Math.trunc(s*Math.pow(10,n-3));return M(a,e.length)}},q={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},xe={G:function(t,e,n){const s=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(s,{width:"abbreviated"});case"GGGGG":return n.era(s,{width:"narrow"});case"GGGG":default:return n.era(s,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const s=t.getFullYear(),a=s>0?s:1-s;return n.ordinalNumber(a,{unit:"year"})}return z.y(t,e)},Y:function(t,e,n,s){const a=Se(t,s),o=a>0?a:1-a;if(e==="YY"){const r=o%100;return M(r,2)}return e==="Yo"?n.ordinalNumber(o,{unit:"year"}):M(o,e.length)},R:function(t,e){const n=ge(t);return M(n,e.length)},u:function(t,e){const n=t.getFullYear();return M(n,e.length)},Q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(s);case"QQ":return M(s,2);case"Qo":return n.ordinalNumber(s,{unit:"quarter"});case"QQQ":return n.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(s,{width:"wide",context:"formatting"})}},q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(s);case"qq":return M(s,2);case"qo":return n.ordinalNumber(s,{unit:"quarter"});case"qqq":return n.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(s,{width:"wide",context:"standalone"})}},M:function(t,e,n){const s=t.getMonth();switch(e){case"M":case"MM":return z.M(t,e);case"Mo":return n.ordinalNumber(s+1,{unit:"month"});case"MMM":return n.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(s,{width:"wide",context:"formatting"})}},L:function(t,e,n){const s=t.getMonth();switch(e){case"L":return String(s+1);case"LL":return M(s+1,2);case"Lo":return n.ordinalNumber(s+1,{unit:"month"});case"LLL":return n.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(s,{width:"wide",context:"standalone"})}},w:function(t,e,n,s){const a=Ys(t,s);return e==="wo"?n.ordinalNumber(a,{unit:"week"}):M(a,e.length)},I:function(t,e,n){const s=Ls(t);return e==="Io"?n.ordinalNumber(s,{unit:"week"}):M(s,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):z.d(t,e)},D:function(t,e,n){const s=Bs(t);return e==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):M(s,e.length)},E:function(t,e,n){const s=t.getDay();switch(e){case"E":case"EE":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"})}},e:function(t,e,n,s){const a=t.getDay(),o=(a-s.weekStartsOn+8)%7||7;switch(e){case"e":return String(o);case"ee":return M(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});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"})}},c:function(t,e,n,s){const a=t.getDay(),o=(a-s.weekStartsOn+8)%7||7;switch(e){case"c":return String(o);case"cc":return M(o,e.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,e,n){const s=t.getDay(),a=s===0?7:s;switch(e){case"i":return String(a);case"ii":return M(a,e.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(s,{width:"short",context:"formatting"});case"iiii":default:return n.day(s,{width:"wide",context:"formatting"})}},a:function(t,e,n){const s=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(t,e,n){const s=t.getHours();let a;switch(s===12?a=q.noon:s===0?a=q.midnight:a=s/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,e,n){const s=t.getHours();let a;switch(s>=17?a=q.evening:s>=12?a=q.afternoon:s>=4?a=q.morning:a=q.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let s=t.getHours()%12;return s===0&&(s=12),n.ordinalNumber(s,{unit:"hour"})}return z.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):z.H(t,e)},K:function(t,e,n){const s=t.getHours()%12;return e==="Ko"?n.ordinalNumber(s,{unit:"hour"}):M(s,e.length)},k:function(t,e,n){let s=t.getHours();return s===0&&(s=24),e==="ko"?n.ordinalNumber(s,{unit:"hour"}):M(s,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):z.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):z.s(t,e)},S:function(t,e){return z.S(t,e)},X:function(t,e,n){const s=t.getTimezoneOffset();if(s===0)return"Z";switch(e){case"X":return Me(s);case"XXXX":case"XX":return N(s);case"XXXXX":case"XXX":default:return N(s,":")}},x:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"x":return Me(s);case"xxxx":case"xx":return N(s);case"xxxxx":case"xxx":default:return N(s,":")}},O:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+ve(s,":");case"OOOO":default:return"GMT"+N(s,":")}},z:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+ve(s,":");case"zzzz":default:return"GMT"+N(s,":")}},t:function(t,e,n){const s=Math.trunc(t.getTime()/1e3);return M(s,e.length)},T:function(t,e,n){const s=t.getTime();return M(s,e.length)}};function ve(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),a=Math.trunc(s/60),o=s%60;return o===0?n+String(a):n+String(a)+e+M(o,2)}function Me(t,e){return t%60===0?(t>0?"-":"+")+M(Math.abs(t)/60,2):N(t,e)}function N(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),a=M(Math.trunc(s/60),2),o=M(s%60,2);return n+a+e+o}const We=(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"})}},Te=(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"})}},Us=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],s=n[1],a=n[2];if(!a)return We(t,e);let o;switch(s){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;case"PPPP":default:o=e.dateTime({width:"full"});break}return o.replace("{{date}}",We(s,e)).replace("{{time}}",Te(a,e))},js={p:Te,P:Us},Rs=/^D+$/,qs=/^Y+$/,Xs=["D","DD","YY","YYYY"];function Qs(t){return Rs.test(t)}function Vs(t){return qs.test(t)}function Js(t,e,n){const s=Ks(t,e,n);if(console.warn(s),Xs.includes(t))throw new RangeError(s)}function Ks(t,e,n){const s=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${s} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Zs=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ta=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ea=/^'([^]*?)'?$/,na=/''/g,sa=/[a-zA-Z]/;function De(t,e,n){const s=V(),a=n?.locale??s.locale??Fs,o=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,r=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,i=x(t);if(!Vn(i))throw new RangeError("Invalid time value");let d=e.match(ta).map(l=>{const f=l[0];if(f==="p"||f==="P"){const h=js[f];return h(l,a.formatLong)}return l}).join("").match(Zs).map(l=>{if(l==="''")return{isToken:!1,value:"'"};const f=l[0];if(f==="'")return{isToken:!1,value:aa(l)};if(xe[f])return{isToken:!0,value:l};if(f.match(sa))throw new RangeError("Format string contains an unescaped latin alphabet character `"+f+"`");return{isToken:!1,value:l}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const c={firstWeekContainsDate:o,weekStartsOn:r,locale:a};return d.map(l=>{if(!l.isToken)return l.value;const f=l.value;(!n?.useAdditionalWeekYearTokens&&Vs(f)||!n?.useAdditionalDayOfYearTokens&&Qs(f))&&Js(f,e,String(t));const h=xe[f[0]];return h(i,f,a.localize,c)}).join("")}function aa(t){const e=t.match(ea);return e?e[1].replace(na,"'"):t}function Ie(t){const e=x(t),n=e.getFullYear(),s=e.getMonth(),a=C(t,0);return a.setFullYear(n,s+1,0),a.setHours(0,0,0,0),a.getDate()}function ra(t){const e=x(t).getFullYear();return e%400===0||e%4===0&&e%100!==0}function $e(t){const e=x(t);return String(new Date(e))==="Invalid Date"?NaN:ra(e)?366:365}function ia(t){const e=St(t),n=+St(me(e,60))-+e;return Math.round(n/lt)}function F(t,e){const n=x(t),s=x(e);return+n==+s}function oa(t){const e=x(t);return e.setMinutes(0,0,0),e}function da(t,e,n){const s=H(t,n),a=H(e,n);return+s==+a}function ca(t,e){const n=x(t),s=x(e);return n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()}function la(t,e){const n=K(t),s=K(e);return+n==+s}function ua(t,e){const n=x(t),s=x(e);return n.getFullYear()===s.getFullYear()}const Dt={year:ss,quarter:ns,month:be,week:xt,day:wt,hour:Zn,minute:ts},Y={year:{quarter:4,month:12,week:ia,day:ha,hour:fa},quarter:{month:3,week:ga,day:Ce,hour:ma},month:{week:pa,day:ya,hour:ka},week:{day:7,hour:24*7},day:{hour:24},hour:{minute:60}};function ha(t){return t?$e(t):365}function fa(t){return $e(t)*24}function ga(t){const e=K(t),n=E(L(Wt(t)),1);return xt(n,e)}function Ce(t){if(t){const e=K(t),n=Wt(t);return wt(n,e)+1}return 91}function ma(t){return Ce(t)*24}function pa(t){if(t){const e=_e(t),n=E(L(Mt(t)),1);return xt(n,e)}return 5}function ya(t){return t?Ie(t):30}function ka(t){return Ie(t)*24}function et(t,e,n){const s=Y[t][e];return s?typeof s=="number"?s:s(n):1}function ba(t,e){return t===e||!!(Y[t]&&Y[t][e])}const ht={year:Xn,quarter:qn,month:_t,week:me,day:E,hour:Un,minute:Rn};function ft(t,e,n){if(e){if(t==="day")return(s,a)=>e.getWorkingDays(a,s,!0);if(t==="hour")return(s,a)=>e.getWorkingHours(a,s,!0)}return(s,a,o,r)=>{const i=Y[t]?.[o];return!i||typeof i=="number"||Oe(t,s,a,n)?nt(t,s,a,o,r,n):_a(s,a,t,o,r,n)}}function nt(t,e,n,s,a,o){const r=s||t;let i=n,d=e;if(a&&(i=$(r,n,o),d=$(r,e,o),d<e&&(d=I(r)(d,1))),t!==r){const c=Dt[r](d,i),l=et(t,r,n);return c/l}else return Dt[r](d,i)}function _a(t,e,n,s,a,o){let r=0;const i=$(n,e,o);if(e>i){const c=ht[n](i,1);r=nt(n,c,e,s,void 0,o),e=c}let d=0;return Oe(n,e,t,o)||(d=nt(n,$(n,t,o),e,void 0,void 0,o),e=ht[n](e,d)),d+=r+nt(n,t,e,s,void 0,o),!d&&a&&(d=nt(n,t,e,s,a,o)),d}function I(t,e){if(e){if(t==="day")return(n,s)=>e.addWorkingDays(n,s,!0);if(t==="hour")return(n,s)=>e.addWorkingHours(n,s)}return ht[t]}const Pe={year:we,quarter:K,month:_e,week:(t,e)=>H(t,{weekStartsOn:e}),day:L,hour:oa};function $(t,e,n){const s=Pe[t];return s?s(e,n):new Date(e)}const wa={year:as,quarter:Wt,month:Mt,week:(t,e)=>is(t,{weekStartsOn:e}),day:ke,hour:rs},Ee={year:ua,quarter:la,month:ca,week:(t,e,n)=>da(t,e,{weekStartsOn:n}),day:pe};function Oe(t,e,n,s){const a=Ee[t];return a?a(e,n,s):!1}const Sa={start:Pe,end:wa,add:ht,isSame:Ee,diff:Dt,smallerCount:Y},Ge=t=>typeof t=="function"?t(new Date):t;function xa(t,e){for(const n in e){if(n==="smallerCount"){const s=Object.keys(e[n]).sort((i,d)=>O.indexOf(i)-O.indexOf(d)).shift();let a=O.indexOf(s);const o=e[n][s],r=Ge(o);for(let i=a-1;i>=0;i--){const d=O[i],c=Ge(Y[d][s]);if(r<=c)break;a=i}O.includes(t)||O.splice(a,0,t)}if(n==="biggerCount")for(const s in e[n])Y[s][t]=e[n][s];else Sa[n][t]=e[n]}}function It(t,e=1,n){const s=e>0?n.getNextWorkingDay(E(t,-1)):n.getPreviousWorkingDay(E(t,1));return s&&pe(s,t)?t:s}function va(t){return(e,n)=>{if(n>0)for(let s=0;s<n;s++)e=t.getNextWorkingDay(e);if(n<0)for(let s=0;s>n;s--)e=t.getPreviousWorkingDay(e);return e}}function Ae(t){return De(t,"yyyy-MM-dd")}function st(t,e){for(const n in e)e[n]===void 0&&n[0]!=="$"&&delete t[n]}function $t(t,e,n){const s=Math.max(Math.min(+t,+n),+e);return t instanceof Date?new Date(s):s}function X(t){const e=new Date;return t.map(n=>({item:n,len:I(n.unit)(e,1)})).sort((n,s)=>n.len<s.len?-1:1)[0].item}const O=["year","quarter","month","week","day","hour"],Ct=50,Pt=300;function Ma(t,e,n,s,a,o){const r=!t||n,i=!e||n;let d=t,c=e,l=!1,f=!1;(r||i)&&a?.forEach(u=>{let g=u.start,m=u.type==="milestone"?u.start:u.end;r&&(!d||g<=d)&&(d=g,l=!0),i&&(!c||m>=c)&&(c=m,f=!0)});const h=I(s||"day");return d?l&&(d=h(d,-1)):c?d=h(c,-30):d=new Date,c?f&&(c=h(c,1)):c=h(d,30),{_start:d,_end:c}}function Wa(t,e,n,s,a,o,r,i){const d=X(r).unit,c=ft(d,void 0,o),l=c(e,t,"",!0),f=$(d,e,o);t=$(d,t,o),e=f<e?I(d)(f,1):f;const h=l*s,u=a*Math.max(i,r.length),g=r.map(y=>{const p=[],b=I(y.unit);let k=$(y.unit,t,o);for(;k<e;){const w=b(k,y.step),_=k<t?t:k,v=w>e?e:w,S=c(v,_,"",!0)*s,W=typeof y.format=="function"?y.format(k,w):y.format;let T="";y.css&&(T+=typeof y.css=="function"?y.css(k):y.css),p.push({width:S,value:W,date:_,key:Ae(_),css:T,unit:y.unit}),k=w}return{cells:p,add:b,height:u/r.length}});let m=s;return d!==n&&(m=m/et(d,n)),{rows:g,width:h,height:u,diff:c,start:t,end:e,lengthUnit:n,minUnit:d,lengthUnitWidth:m}}function Ta(t,e,n,s){const a=typeof t=="boolean"?{}:t;n.forEach(c=>{c.format&&!e[c.unit]&&(e[c.unit]=c.format)});const o=O.filter(c=>e[c]||n.some(l=>l.unit===c)),r=o.indexOf(X(n).unit);if(typeof a.level>"u"&&(a.level=r),a.levels)a.levels.forEach(c=>{c.minCellWidth||(c.minCellWidth=gt(a.minCellWidth,Ct)),c.maxCellWidth||(c.maxCellWidth=gt(a.maxCellWidth,Pt))});else{const c=[],l=n.length||1,f=gt(a.minCellWidth,Ct),h=gt(a.maxCellWidth,Pt);o.forEach((u,g)=>{if(g===r)c.push({minCellWidth:f,maxCellWidth:h,scales:n});else{const m=[];if(g)for(let y=l-1;y>0;y--){const p=o[g-y];p&&m.push({unit:p,step:1,format:e[p]})}m.push({unit:u,step:1,format:e[u]}),c.push({minCellWidth:f,maxCellWidth:h,scales:m})}}),a.levels=c}a.levels[a.level]||(a.level=0);const i=a.levels[a.level],d=Math.min(Math.max(s,i.minCellWidth),i.maxCellWidth);return{zoom:a,scales:i.scales,cellWidth:d}}function Da(t,e,n,s,a,o,r){t.level=n;let i;const d=s.scales||s,c=X(d).unit,l=$a(c,a);if(e<0){const u=et(c,a);i=r*u}else{const u=et(X(o).unit,c);i=Math.round(r/u)}const f=s.minCellWidth??Ct,h=s.maxCellWidth??Pt;return{scales:d,cellWidth:$t(i,f,h),lengthUnit:l,zoom:t}}function Ia(t,e){const{_start:n,_scales:s,start:a,end:o,_end:r,cellWidth:i,_scaleDate:d,_zoomOffset:c,_weekStart:l}=e,f=I(s.minUnit);let h=s.width;if(a&&o){if(h<t&&h){const p=t/h;return{cellWidth:Math.ceil(i*p)}}return{}}let u=0;for(;h<t;)h+=i,u++;let g=0;if(u){if(o)g=-u;else if(d&&c!==null){const p=c/i,b=s.diff(d,n,"hour");g=Math.floor(b-p)}}let m=a;a||(m=$(s.minUnit,f(n,g),l));let y=0;if(d){const p=s.diff(d,m,"hour");y=Math.max(0,Math.round(p*i)-(c||0))}return{_start:m,_end:o||f(r,u-g),scrollLeft:y}}function $a(t,e){const n=O.indexOf(t),s=O.indexOf(e);return s>=n?t==="hour"?"hour":"day":O[s]}function gt(t,e){return t??e}function He(t,e){const{_scales:n,_start:s,_weekStart:a}=e,o=n.lengthUnit==="day"?n.lengthUnitWidth/24:n.lengthUnitWidth;return I("hour")($(n.minUnit,s,a),Math.floor(t/o))}function Ca(t,e){const{_scales:n,_weekStart:s,cellWidth:a,durationUnit:o}=e,{minUnit:r,lengthUnit:i,lengthUnitWidth:d}=n,c=$(r,n.start,s);if(a===d){const m=I(i)(c,Math.round(t/d));return o!==r?$(o,m,s):m}const l=Math.trunc(t/a),f=I(r)(c,l),h=t-l*a;if(h<=0)return f;const u=et(r,i,f),g=Math.min(u-1,Math.round(h/d));return I(i)(f,g)}const ze=7,Fe=3,Pa=8,Ea=4,Oa=Pa+Ea;function at(t,e){return t.type==="summary"&&!!t.manual&&!!e?.schedule?.auto}function Be(t,e,n,s){(t.open||t.type!=="summary"||n)&&t.data?.forEach(a=>{s&&a.manual||(a.$x+=e,a.$x_rollup&&(a.$x_rollup+=e),Be(a,e,n,s))})}function Et(t,e,n,s){const a=t.getSummaryId(e.id);if(a){const o=t.byId(a);if(s&&o.manual)return;const r={xMin:1/0,xMax:0};Le(o,r,!!n&&!o.inactive),Number.isFinite(r.xMin)&&(o.$x=r.xMin,o.$w=r.xMax-r.xMin),Et(t,o,n,s)}}function Le(t,e,n){t.data?.forEach(s=>{if(!s.unscheduled&&!(n&&s.inactive)){const a=s.type==="milestone"&&s.$h?s.$h/2:0;e.xMin>s.$x+a&&(e.xMin=s.$x+a);const o=s.$x+s.$w-a;e.xMax<o&&(e.xMax=o)}s.type!=="summary"&&Le(s,e,n)})}function Ot(t,e,n,s){const a={...t};return a.data?.length?a.data.forEach(o=>{const r=!!(s&&o.inactive);if(e&&o.unscheduled&&!o.data||r&&(o.type==="summary"||!o.data))return;o.type!=="summary"&&o.data&&((e&&o.unscheduled||r)&&(o={...o,start:void 0,end:void 0}),o=Ot(o,e,n,s)),o.start&&(!a.start||a.start>o.start)&&(a.start=new Date(o.start));const i=o.end||o.start;i&&(!a.end||a.end<i)&&(a.end=new Date(i))}):t.type==="summary"&&console.warn(`Summary task ${t.id} has no subtasks, so its dates cannot be derived. Provide start and end dates for it.`),a}function Ne(t,e,n){return Ye(t,e,n),t.data&&!t.open&&Ue(t,n),t}function Ye(t,e,n,s){const{cellWidth:a,cellHeight:o,_scales:r,baselines:i,_rollups:d}=n,{start:c,end:l,lengthUnit:f,diff:h}=r,u="start",g="end",m="$x",y="$y",p="$w",b="$h",k="$skip",w=o-ze-(i?Oa:0);let _=t[u],v=t[g];if(n.unscheduledTasks&&t.unscheduled||t.$placeholder){e!==null&&(t[y]=o*e+Fe),t[b]=w,t[k]=!0;return}t[u]<c&&(t[g]<c||F(t[g],c))?_=v=c:t[u]>l&&(_=v=l),t[m]=Math.round(h(_,c,f)*a),t[p]=Math.round(h(v,_,f,!0)*a),e!==null&&(t[y]=o*e+Fe),t[b]=w,t.type==="milestone"&&(t[m]=t[m]-t.$h/2,t[p]=t.$h),n.groupBy&&t.$group?t.$skip=!0:t[k]=F(_,v)}function Ue(t,e,n){n=n??t.type!=="summary",t.data&&!t.$skip&&(n||e._rollups)&&t.data.forEach(s=>{(n||s.rollup)&&Ye(s,null,e),Ue(s,e,n)})}function Ga(t,e){return!1}function Aa(t,e){}function Ha(t,e,n){}function za(t,e){const{tasks:n,durationUnit:s,_scales:a}=t,o=n.getBranch(0);if(o?.length){const r=o[o.length-1];if(!r.$skip&&r.start){const i=new Date(r.start.valueOf());if(a.start<=i)return i}}return I(s,e)(a.start,1)}var je=new Date().valueOf();function Fa(){return je+=1,je}const Gt=20,Ba=function(t,e,n,s){if(!e||!n||!e.$y||!n.$y||e.$skip||n.$skip)return t.$p="",t.$pl=0,t.$x1=t.$x2=t.$y1=t.$y2=0,t;let a=!1,o=!1;switch(t.type){case"e2s":o=!0;break;case"s2s":a=!0,o=!0;break;case"s2e":a=!0;break}const r=a?e.$x:e.$x+e.$w,i=e.$y+e.$h/2,d=o?n.$x:n.$x+n.$w,c=n.$y+n.$h/2,l=(s-ze-n.$h)/2;if(r!==d||i!==c){const{coords:f,pl:h,x1:u,x2:g,y1:m,y2:y}=La(r,i,d,c,a,o,s/2,l),p=Na(d,c,o);t.$p=`${f},${p}`,t.$pl=h,t.$x1=Math.min(u,d-5),t.$x2=Math.max(g,d+5),t.$y1=Math.min(m,c-3),t.$y2=Math.max(y,c+3)}return t};function La(t,e,n,s,a,o,r,i){const d=Gt*(a?-1:1),c=Gt*(o?-1:1),l=t+d,f=n+c,h=[t,e,l,e,0,0,0,0,f,s,n,s],u=f-l;let g=s-e;const m=o===a;m||(f<=t+Gt-2&&o||f>t&&!o)&&(g=g-r+i),m&&o&&l>f||m&&!o&&l<f?(h[4]=h[2]+u,h[5]=h[3],h[6]=h[4],h[7]=h[5]+g):(h[4]=h[2],h[5]=h[3]+g,h[6]=h[4]+u,h[7]=h[5]);let y=1/0,p=-1/0,b=1/0,k=-1/0,w=0;for(let _=0;_<h.length-1;_+=2)h[_]<y&&(y=h[_]),h[_]>p&&(p=h[_]),h[_+1]<b&&(b=h[_+1]),h[_+1]>k&&(k=h[_+1]),_<h.length-3&&(w+=Math.hypot(h[_+2]-h[_],h[_+3]-h[_+1]));return{coords:h.join(","),pl:w,x1:y,x2:p,y1:b,y2:k}}function Na(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 Ya(t,e,n){if(e&&n){const s=n.x-e.x,a=n.y-e.y,o=(s>0?e.x:n.x)-t.left,r=(a>0?e.y:n.y)-t.top,i=`${s>0?0:-s},${a>0?0:-a},${s>0?s:0},${a>0?a:0}`;return{width:Math.abs(s),height:Math.abs(a),left:o,top:r,p:i}}else return null}function At(t){return t?.map(e=>{const n=e.id||Fa(),s=Number(e.lag)||0;return{...e,id:n,lag:s}})}const Ht="wx_placeholder_row";function U(t){return t===Ht}function Ua(t,e){const n={...t};return delete n.id,delete n.unscheduled,Object.keys(n).forEach(s=>{s.startsWith("$")&&delete n[s]}),n.text||(n.text=e),n}function ja(){return null}const rt={end:"start",base_end:"base_start",deadline:null},Ra=["fnlt","fnet","mfo"];function Re(t){const e=t.constraint;return!!e?.date&&Ra.includes(e.type)&&t.type!=="milestone"}function qe(t,e,n){if(n&&t<=n)return n;const s=e?.getPreviousWorkingDay(t)??E(t,-1);return n&&s<n?n:s}function zt(t,e,n){const s=t[e];if(!s)return s;const a=rt[e];return qe(s,n,a&&t[a])}function qa(t,e){const n={...t};for(const s in rt)t[s]&&(n[s]=zt(t,s,e));return Re(t)&&(n.constraint={...t.constraint,date:qe(t.constraint.date,e)}),t.segments&&(n.segments=t.segments.map(s=>s.end?{...s,end:zt(s,"end",e)}:s)),n}const Xa=[...Object.keys(rt),"constraint","segments"];function Qa(t,e,n){const s={...t};for(const o of Xa)o!==e&&o in n&&(s[o]=n[o]);const a=s[e];return a&&(e in rt?s[e]=E(a,1):e==="constraint"&&Re(s)&&(s.constraint={...a,date:E(a.date,1)})),s}function Va(t,e,n){const{id:s,template:a}=t;if(!(s in rt)||t.getter||t.setter)return t;const o={...t,getter:r=>e().inclusiveEnd?zt(r,s,n?.(r)):r[s],setter:(r,i)=>{r[s]=e().inclusiveEnd&&i?E(i,1):i}};return a&&!t._template&&(o.template=(r,i,d)=>a(i[s],i,d)),o}function Xe(t,e="grid"){return t.filter(n=>(n.section||"grid")===e)}const it=37,Ja=120;function Qe(t){return t.width||(t.id==="add-task"?it:Ja)}const Ve=["start","end","duration"];function Je(t,e){return t==="start"&&e?["Unschedule","today"]:["today"]}function Ka(t,e){const{type:n,unscheduled:s}=t;return n==="summary"?!Ve.includes(e):s||n==="milestone"?!["end","duration"].includes(e):!0}function Za(t,e,n){if(typeof e=="function"||!e)return e;const s=Ve.includes(t);if(!s&&t!=="resources")return e;const a=typeof e=="string"?{type:e}:e,o=a.config??={};return s?(r,i)=>{const d=String(i?.id??"");return!r||!Ka(r,d)?null:(a.type==="datepicker"&&(o.buttons=Je(d,!r.$placeholder&&n().unscheduledTasks)),a)}:a}function Ke(t){let e=1;return t?.length&&t.forEach(n=>{if(n.hidden)return;const s=n.header,a=Array.isArray(s)?s.length:s?1:0;e=Math.max(a,e)}),e}function tr(t,e,n){if(!t||!t.length)return[];t=t.filter(a=>a.section!=="subGrid");const s=t.map(a=>{const o=a.align||"left",r=a.id==="add-task",i=r?null:a.flexgrow,d=i?1:Qe(a),c=a.editor&&Za(a.id,a.editor,e);let l=Array.isArray(a.header)?a.header:[a.header];l=l.map(h=>(typeof h!="object"&&(h={text:h}),h.filter&&typeof h.filter!="object"&&(h.filter={type:h.filter}),h));const f={width:d,align:o,header:l,id:a.id,template:a.template,_template:a._template,...i&&{flexgrow:i},...a.hidden&&{hidden:a.hidden},...a.section&&{section:a.section},cell:a.cell,resize:a.resize??!0,sort:a.sort??!r,...c&&{editor:c},...a.options&&{options:a.options},getter:a.getter,setter:a.setter};return Va(f,e,n)});return tn(s),s}function Ze(t,e){const n=Xe(t,e).filter(a=>!a.hidden);if(!n.length||n.some(a=>a.flexgrow))return;const s=n.find(a=>a.id==="text")||n.find(a=>a.id!=="add-task");s&&(s.flexgrow=1)}function tn(t){Ze(t,"grid"),Ze(t,"subGrid")}const en=[{id:"text",header:"Task name",width:183,flexgrow:1,sort:!0},{id:"start",header:"Start date",width:120,align:"center",sort:!0},{id:"duration",header:"Duration",width:100,align:"center",sort:!0},{id:"add-task",header:"Add task",width:it,align:"center",sort:!1,resize:!1}];function nn(t={}){return en.map(e=>({...e}))}function Ft(t,e="grid"){return Xe(t,e).reduce((n,s)=>n+Qe(s),0)}function er(){return[]}function nr(t){if(!t||!t.length)return[];const e=t.map(n=>({...n}));if(!e.some(n=>n.flexgrow)){const n=e.find(s=>s.id==="name")||e[0];n&&(n.flexgrow=1)}return e}function Bt(t){return!1}function Lt(t,e){const n=["grid","chart"];let s;if(Array.isArray(t))s=[...t];else switch(t){case"grid":case"chart":s=[t];break;case"all":default:s=n;break}return s=s.filter(a=>a!=="subGrid"),s.length||(s=n),s}function Nt(t,e){if(t.length<=1)return t.length?t:["grid"];const n=e?.find(s=>t.includes(s));return n?[n]:t.includes("grid")?["grid"]:[t[0]]}function sr(t,e,n=!1){if(n)return t.includes("grid")?["chart"]:["grid"];const s=t.includes("grid"),a=t.includes("chart");return t.includes("subGrid"),s&&a?e==="start"?["chart"]:["grid"]:["grid","chart"]}function ar(t,e,n=!1){return t}const sn=4,Yt=100,rr=650;function an(t,e){return!t||!e?.includes("chart")?sn:2*sn}function ir(t,e,n,s,a=0){const o=n+a+Yt;return or(t,e,o,s)}function or(t,e,n,s=0){const a=Math.max(e-n,0);return Math.max(s,Math.min(t,a))}function Ut(t,e){return t.length===e.length&&t.every(n=>e.includes(n))}function rn(t){const e=["chart"];return t.includes("subGrid")&&e.push("subGrid"),e}function on(t){return t._gridCollapseThreshold??it}function jt(t,e,n){return{ganttWidth:e,gridWidth:t.gridWidth,subGridWidth:t.subGridWidth,hasSubGrid:Bt(t.columns),scrollSize:n??t._scrollSize??0,collapseThreshold:on(t)}}function dn(t,e,n=!1){const{ganttWidth:s,subGridWidth:a,hasSubGrid:o,scrollSize:r=0,collapseThreshold:i}=e;let d=e.gridWidth,c=[...t];const l=c.includes("chart"),f=an(o,c),h=f+r;let u=0,g=s-d-u-h;return l&&g<Yt&&n&&(d=ir(d,s,f,i,r),g=s-d-u-h),l&&g<Yt&&(c=c.filter(m=>m!=="chart")),{gridWidth:d,subGridWidth:a,panels:c}}function dr(t,e){const n=e.width,s=e.scrollSize??t._scrollSize??0,a=n==null||n<=rr,o={compactMode:a,gridWidth:t.gridWidth,subGridWidth:t.subGridWidth};!t._compactMode&&a&&(o.displayPanels=Nt(t.displayMode,t._displayPanels));const r=t.displayMode;if(a||n==null||!r?.includes("grid")||!r.includes("chart"))return o;const i=dn(t.displayMode,jt(t,n,s),!0);o.gridWidth=i.gridWidth,o.subGridWidth=i.subGridWidth;const d=t._displayPanels??t.displayMode;return Ut(i.panels,d)||(o.displayPanels=i.panels),o}function cr(t,e){if(e.gridWidth<=e.collapseThreshold){const n=e.preferredGridWidth;return{gridWidth:n!=null&&n>e.collapseThreshold?n:e.gridWidth,subGridWidth:e.subGridWidth,panels:rn(t)}}return dn(t,e)}function lr(t,e){return{subGridWidth:0,panels:t}}function ur(t,e){const{ganttWidth:n,hasSubGrid:s,scrollSize:a=0,collapseThreshold:o}=e,r=Math.max(0,n-an(s,t)-a-(t.includes("subGrid")?e.subGridWidth:0)),i=Math.min(o,r);return{gridWidth:Math.max(i,Math.min(e.gridWidth,r)),panels:e.gridWidth<=o?rn(t):t}}function hr(t,e){return{subGridWidth:0,panels:t}}function fr(t,e,n){return e}function ot(t,e,n,s){const a=t.getState(),o=a._selected.filter(m=>!U(m.id)).map(m=>m.id);U(n)&&(n=null);const r=o.length,i=["edit-task","paste-task","undo","redo","add-task","add-task:child","add-task:before","add-task:after","show-conflicts"],d=["copy-task","cut-task"],c=["copy-task","cut-task","delete-task","indent-task:remove","move-task:down"],l=["add-task","undo","redo","show-conflicts"],f=["indent-task:add","move-task:down","move-task:up","copy-task","cut-task","delete-task"],h={"indent-task:remove":2},u=!r&&l.includes(e),g={parent:f.includes(e),level:h[e],sort:!d.includes(e)};if(n=n||(r?o[o.length-1]:null),!(!n&&!u)){if(e!=="paste-task"&&(t._temp=null),i.includes(e)||u||o.length===1)cn(t,e,n,s);else if(r){const m=gr(o,g,a);c.includes(e)&&m.reverse();const y=t.getHistory();y&&y.startBatch(),m.forEach((p,b)=>cn(t,e,p,s,b)),y&&y.endBatch()}}}function gr(t,e,n){const{tasks:s,tree:a,groupBy:o}=n;let r=t.map(i=>{let d=i;o?.field&&(d=a.byId(d)?.$id||d);const c=s.byId(d);return{id:d,level:c?.$level,parent:c?.parent,index:s.getIndexById(d)}});return(e.parent||e.level)&&(r=r.filter(i=>e.level&&i.level<=e.level||!t.includes(i.parent))),e.sort&&r.sort((i,d)=>i.level-d.level||i.index-d.index),r.map(i=>i.id)}function cn(t,e,n,s,a){const o=t.exec?t.exec:t.in.exec;let r=e.split(":")[0],i=e.split(":")[1];const d=n?.id||n;let c={id:d},l={},f=!1;if(r==="copy-task"||r==="cut-task"){t._temp||(t._temp=[]),t._temp.push({id:d,cut:r==="cut-task"});return}else if(r==="paste-task"){const{tasks:h}=t.getState(),u=t._temp?.filter(g=>h.byId(g.id));if(u&&u.length){const g=t.getHistory();g&&g.startBatch();const m=new Map;if(u.forEach(y=>{const p={id:y.id,target:d,mode:"after"};o(y.cut?"move-task":"copy-task",p),m.set(y.id,p.id)}),!u[0].cut){const{links:y}=t.getState(),p=u.map(k=>k.id),b=[];y.forEach(k=>{p.includes(k.source)&&p.includes(k.target)&&b.push(k)}),b.forEach(k=>{o("add-link",{link:{...k,id:void 0,source:m.get(k.source),target:m.get(k.target)}})}),u.forEach((k,w)=>{o("select-task",{id:m.get(k.id),toggle:!!w})})}g&&g.endBatch()}t._temp=null;return}else r==="add-task"?(l={task:{type:"task",text:s("New task")},target:d,show:!0,mode:"after",select:!1},c={},f=!0):r==="edit-task"?r="show-editor":r==="convert-task"?(r="update-task",l={task:{type:i}},i=void 0):r==="indent-task"&&(i=i==="add");if(r==="split-task"&&typeof n=="object")l=n;else if(r==="delete-task"&&i==="segment"&&typeof n=="object"){const h=t.getTask(d),{segmentIndex:u}=n,g=h.segments.filter((m,y)=>y!==u);o("update-task",{id:d,task:{segments:g}});return}typeof i<"u"&&(l={...l,mode:i}),c={...c,...l},o(r,c),f&&o("select-task",{id:c.id,toggle:!!a,eventSource:r})}function ln(t,e){return t.some(n=>n.data?ln(n.data,e):n.id===e)}function un(t,e,n,s=1){const a=n[0].width,o=Math.max(0,Math.floor(t/a)-s),r=Math.min(n.length,Math.ceil((t+e)/a)+s);return{from:o*a,to:r*a,start:o,end:r}}const hn=(t,e)=>I(t,e),mr=(t,e)=>ft(t,e);function fn(t,e,n,s=0){const a=o=>{o&&o.forEach(r=>{if(a(r.data),j(r,e,n(r)),r.type!=="summary")return;const i=!(r.start&&r.end),d=e.inactiveTasks&&r.inactive===void 0;if(!i&&!d)return;const c=Ot(r,e.unscheduledTasks,e.inactiveTasks,e.inactiveTasks&&!d?!r.inactive:void 0);d&&c.inactive&&(r.inactive=!0),i&&(r.start=c.start,r.end=c.end,r.duration=void 0,j(r,e,n(r)))})};a(t.byId(s)?.data)}const gn=(t,e,n)=>n in t?t[n]:e?.[n];function pr(t,e){if(gn(t,e,"type")==="summary"){t.unscheduled=!1;return}t.unscheduled=!gn(t,e,"start")}function yr(t,e,n){"type"in t||(t.type=e.type),!t.start&&!(n&&"start"in t)&&(t.start=e.start),!t.end&&!t.duration&&(t.duration=e.duration),!("segments"in t)&&e.segments&&(t.segments=e.segments)}function j(t,e,n,s){s&&yr(t,s,e.unscheduledTasks),t.start&&mn(t,e,n,!1),e.unscheduledTasks&&pr(t,s),t.base_start&&mn(t,e,n,!0)}function mn(t,e,n,s){const{durationUnit:a}=e,o=a||"day",[r,i,d]=pn(s);t.type==="milestone"?(t[d]=0,t[i]=void 0):t[r]&&(t[d]?t[i]=hn(o,n)(t[r],t[d]):t[i]?t[d]=mr(o,n)(t[i],t[r]):(t[i]=hn(o,n)(t[r],1),t[d]=1))}function pn(t){return t?["base_start","base_end","base_duration"]:["start","end","duration"]}function yn(t,e,n){const[s,a,o]=pn(n);(e===o||e===s&&t.start)&&(e===o&&t[o]<1&&(t[o]=1),t[a]=null),e===a&&(t[o]=0,t[s]&&t[s]>=t[a]&&(t[a]=null,t[o]=1))}function kr(t,e,n,s){yn(t,s,!1),t.base_start&&yn(t,s,!0),j(t,e,n)}const Q=[],br=["add-task","update-task","move-task","delete-task","add-link","update-link","delete-link","add-assignment","update-assignment","delete-assignment"],_r={geometry:["tasks","cellHeight","baselines","unscheduledTasks","rollups","groupBy"]};class wr extends In{in;_router;_modules=new Map;_prevConfig={};_pendingGeometry=null;_resizeStart=null;_placeholderRow;constructor(e){super({writable:e,async:!1}),this._router=new $n(super.setState.bind(this),[{in:["tasks","start","end","scales","autoScale","markers","projectStart","projectEnd","baselines","progressLine","deadlines","criticalPath","schedule","unscheduledTasks"],out:["_start","_end"],exec:r=>{const{_end:i,_start:d,start:c,end:l,tasks:f,scales:h,autoScale:u,markers:g,projectStart:m,projectEnd:y,baselines:p,unscheduledTasks:b,progressLine:k,deadlines:w,criticalPath:_,schedule:v}=this.getState();if(this._pendingGeometry!=="meta")if(!c||!l||u){const S=X(h).unit,W=Ma(c,l,u,S,f);(W._end!==i||W._start!==d)&&this.setState(W,r)}else this.setState({_start:c,_end:l},r)}},{in:["_columns"],out:["_headerLength","_gridCollapseThreshold"],exec:r=>{const{_columns:i}=this.getState();let d=it;const c=i.find(l=>l.id==="add-task");c?.width&&(d=c.width),this.setState({_headerLength:Ke(i),_gridCollapseThreshold:d},r)}},{in:["displayMode"],out:["_displayPanels"],exec:r=>{const{displayMode:i,_compactMode:d,_displayPanels:c}=this.getState();this.setState({_displayPanels:d?Nt(i,c):i},r)}},{in:["_displayPanels","_columns","gridWidth"],out:["_columnsWidth"],exec:r=>{const{_columns:i,_displayPanels:d,gridWidth:c}=this.getState();if(!i?.length){this.setState({_columnsWidth:0},r);return}let l=0;d.includes("grid")?l=c:l=i?.find(f=>f.id==="add-task")?.width||it,l&&this.setState({_columnsWidth:l},r)}},{in:["start","end"],out:["cellWidth"],exec:r=>{const{_cellWidth:i,cellWidth:d}=this.getState();i!==d&&this.setState({cellWidth:i},r)}},{in:["_start","_end","cellWidth","scaleHeight","scales","lengthUnit","_weekStart","_headerLength"],out:["_scales"],exec:r=>{const i=this.getState();let{lengthUnit:d}=i;const{_start:c,_end:l,cellWidth:f,scaleHeight:h,scales:u,_weekStart:g,_headerLength:m}=i,y=X(u).unit;ba(y,d)||(d=y);const p=Wa(c,l,d,f,h,g,u,m);this.markGeometry("all"),this.setState({_scales:p},r)}},{in:["assignments"],out:["_assignments"],exec:r=>{const{assignments:i}=this.getState();this.setState({_assignments:this.indexAssignments(i)},r)}},{in:["_scales","scrollLeft","_chartWidth"],out:["xArea"],exec:r=>{const{_scales:i,scrollLeft:d,_chartWidth:c}=this.getState();if(!i||!c){this.setState({xArea:{from:0,to:0,start:0,end:0}},r);return}const l=i.rows[i.rows.length-1].cells;this.setState({xArea:un(d||0,c,l)},r)}},{in:["tasks","_assignments","groupBy","_scales"],out:["tree"],exec:r=>{this.getState();const{tasks:i,_scales:d}=this.getState(),c=this.getGrouping();if(c){if(!d)return;const l=c.buildTree();this.setState({tree:l});return}this.setState({tree:i},r)}},{in:["tree","_scales","_rollups","cellHeight","baselines","unscheduledTasks","deadlines","splitTasks","placeholderRow"],out:["_tasks"],exec:r=>{const{cellWidth:i,cellHeight:d,tree:c,_scales:l,baselines:f,splitTasks:h,unscheduledTasks:u,placeholderRow:g,_rollups:m,groupBy:y,_tasks:p,deadlines:b,tasks:k,durationUnit:w,schedule:_,criticalPath:v}=this.getState(),S=c.toArray();g&&S.push(this.getPlaceholderRow());const W={cellWidth:i,cellHeight:d,_scales:l,baselines:f,unscheduledTasks:u,_rollups:m,groupBy:y},T=this._pendingGeometry;if(this._pendingGeometry=null,(T==="meta"||T instanceof Set)&&p?.length===S.length&&S.every((D,G)=>p[G]?.id===D.id&&(D.$skip||typeof D.$x=="number"))){if(T instanceof Set)for(let D=0;D<S.length;D++)T.has(S[D].id)&&Ne(S[D],D,W);this.setState({_tasks:S},r);return}g&&(this.getPlaceholderRow(),this.getCalendar());const B=S.map((D,G)=>Ne(D,G,W));this.setState({_tasks:B},r)}},{in:["_tasks","links","cellHeight"],out:["_links"],exec:r=>{const{tree:i,links:d,cellHeight:c,criticalPath:l,_isFiltered:f}=this.getState(),h=d.map(u=>{const g=i.byId(u.source),m=i.byId(u.target);return!g||!m?null:Ba(u,g,m,c)}).toSorted((u,g)=>!u||!g?0:l?!!u.critical==!!g.critical?g.$pl-u.$pl:u.critical?1:-1:g.$pl-u.$pl).filter(u=>u&&f?i.isFilteredId(u.source)&&i.isFilteredId(u.target):u!==null);this.setState({_links:h},r)}},{in:["_links"],out:["_linksIndex"],exec:r=>{const{_links:i}=this.getState(),d=new Map;for(const c of i){if(!c.$p)continue;const l=Math.floor(c.$x1/2048),f=Math.floor(c.$x2/2048),h=Math.floor(c.$y1/2048),u=Math.floor(c.$y2/2048);for(let g=h;g<=u;g++)for(let m=l;m<=f;m++){const y=g*65536+m;let p=d.get(y);p||d.set(y,p=[]),p.push(c)}}this.setState({_linksIndex:d},r)}},{in:["_linksIndex","area","xArea","cellHeight"],out:["_visibleLinks"],exec:r=>{const{_linksIndex:i,area:d,xArea:c,cellHeight:l}=this.getState(),f=d.to??d.end*l,h=Math.floor(c.from/2048),u=Math.floor(c.to/2048),g=Math.floor(d.from/2048),m=Math.floor(f/2048);let y;if(h===u&&g===m)y=i.get(g*65536+h)??[];else{const b=new Set;for(let k=g;k<=m;k++)for(let w=h;w<=u;w++){const _=i.get(k*65536+w);if(_)for(const v of _)b.add(v)}y=Array.from(b)}const p=y.filter(b=>b.$y2>=d.from&&b.$y1<=f&&b.$x2>=c.from&&b.$x1<=c.to);this.setState({_visibleLinks:p},r)}},{in:["tasks","activeTask"],out:["_activeTask"],exec:r=>{const{activeTask:i,tasks:d}=this.getState(),c=d.byId(i);this.setState({_activeTask:c||null},r)}},{in:["tree","selected","placeholderRow"],out:["_selected"],exec:r=>{const{tree:i,selected:d,_isFiltered:c,placeholderRow:l}=this.getState(),f=d.map(h=>l&&U(h)?this.getPlaceholderRow():i.byId(h)).filter(h=>h?U(h.id)?!0:!c||i.isFilteredId(h.id):!1);this.setState({_selected:f},r)}},{in:["columns"],out:["_columns"],exec:r=>{const{columns:i}=this.getState();let d=i;this.setState({_columns:d},r)}}],{links:r=>new kt(At(r)),columns:r=>tr(r,()=>this.getState(),i=>this.getTaskCalendar(i))});const n=this.in=new Cn;br.forEach(r=>n.intercept(r,i=>{this.isRemote(i.eventSource)&&(i.skipProvider=!0)})),n.on("show-editor",r=>{this.setStateAsync({activeTask:r.id})}),n.on("select-task",({id:r,toggle:i,range:d,show:c=!0,focus:l,eventSource:f})=>{const{selected:h,_tasks:u,activeTask:g}=this.getState();let m=!1,y;if(h.length&&(i||d)){const b=[...h];if(d){const k=b[b.length-1],w=u.findIndex(T=>T.id===k),_=u.findIndex(T=>T.id===r),v=Math.min(w,_),S=Math.max(w,_)+1,W=u.slice(v,S).map(T=>T.id);w>_&&W.reverse(),W.forEach(T=>{b.includes(T)||b.push(T)})}else if(i){const k=b.findIndex(w=>w===r);k===-1?b.push(r):(m=!0,b.splice(k,1))}y=b}else y=[r];const p={selected:y};if(this.setState(p),y.length&&(l&&(c=l==="chart"?"xy":c||"y"),c)){const b=()=>{const k=y[y.length-1];this.scrollToTask(k,c),l&&this.setStateAsync({focusTask:{id:k,...l!=="chart"?{section:l}:{}}})};f==="add-task"?setTimeout(b,1):b()}!m&&g&&g!==r&&!U(r)&&n.exec("show-editor",{id:r})}),n.on("delete-link",({id:r})=>{const{links:i}=this.getState();i.remove(r),this.setStateAsync({links:i})}),n.on("update-link",r=>{const{links:i}=this.getState(),d=r.id,c=r.link;let l=r.link;i.update(d,l),l=i.byId(d),st(l,c),l.lag=Number(l.lag)||0,this.setStateAsync({links:i}),r.link=l}),n.on("add-link",r=>{const{link:i}=r,{links:d}=this.getState();!i.source||!i.target||(i.type||(i.type="e2s"),i.lag=Number(i.lag)||0,i.id=i.id||ee(),d.add(i),this.setStateAsync({links:d}),r.id=i.id,r.link=d.byId(i.id))});let s=null;const a=new Map;n.on("move-task",r=>{const{tasks:i,tree:d}=this.getState();let{mode:c,target:l}=r;const{id:f,inProgress:h}=r;if(this.isRemote(r.eventSource)){r.source=i.byId(f).parent,i.move(f,c,l),this.setStateAsync({tasks:i});return}const u=d.byId(f),g=this.getGrouping();if(typeof h>"u"?r.source=u.parent:r.source=s=s??u.parent,h===!1){d.update(u.id,{$reorder:!1}),a.forEach((m,y)=>{const p=i.byId(y);p&&(!F(p.start,m.start)||!F(p.end,m.end)||!!p.inactive!=!!m.inactive)&&n.exec("update-task",{id:y,task:{...p},eventSource:"move-task",joinUndo:!0,skipUndo:!0})}),a.clear(),this.setState({tasks:i}),s=null;return}if(l===f||d.contains(f,l)||g&&c!=="before"&&c!=="after"){r.skipProvider=!0;return}if(c==="up"||c==="down"){const m=i.getBranch(f);let y=i.getIndexById(f);if(c==="up"){const p=u.parent===0;if(y===0&&p){r.skipProvider=!0;return}y-=1,c="before"}else if(c==="down"){const p=y===m.length-1,b=u.parent===0;if(p&&b){r.skipProvider=!0;return}y+=1,c="after"}if(l=m[y]&&m[y].id||u.parent,l){const p=i.getBranch(l);let b=i.getIndexById(l),k=p[b];if(k.data){if(c==="before"){if(k.parent===u.parent){for(;k.data;)k.open||n.exec("open-task",{id:k.id,mode:!0}),k=k.data[k.data.length-1];l=k.id}}else if(c==="after"){let v;k.parent===u.parent?(v=k,k=k.data[0],l=k.id,c="before"):p.length-1!==b&&(v=k,b+=1,k=p[b],u.$level>k.$level&&k.data?(v=k,k=k.data[0],l=k.id,c="before"):l=k.id),v&&!v.open&&n.exec("open-task",{id:v.id,mode:!0})}}const w=i.getSummaryId(u.id);i.move(f,c,l);const _=i.getSummaryId(f);w!==_&&(w&&this.resetSummaryDates(w,"move-task"),_&&this.resetSummaryDates(_,"move-task"))}}else{const m=d.byId(l);let y=m,p=!1;for(;y.$level>u.$level;)y=d.byId(y.parent),y.id===f&&(p=!0);if(p)return;const b=!g&&d.getSummaryId(u.id);if(d.move(f,c,l),c==="child"){let k=m;for(;k.id!==0&&!k.open;)n.exec("open-task",{id:k.id,mode:!0}),k=i.byId(k.parent)}if(!g){const k=i.getSummaryId(f);if(b!==k){const w=h?a:null;b&&this.resetSummaryDates(b,"move-task",w),k&&this.resetSummaryDates(k,"move-task",w)}}}h?this.setState({tree:d}):this.setStateAsync({tasks:i}),r.target=l,r.mode=c}),n.on("drag-task",r=>{const i=this.getState(),{tree:d,_tasks:c,_selected:l,rollups:f,slack:h,inactiveTasks:u}=i,g=!!i.schedule?.auto,m=d.byId(r.id),{left:y,top:p,width:b,inProgress:k}=r,w={_tasks:c,_selected:l};if(typeof b<"u"&&(m.$w=b,Et(d,m,u,g)),typeof y<"u"){if(m.type==="summary"&&!at(m,i)){const _=y-m.$x;Be(m,_,!!f,g)}m.$x=y,Et(d,m,u,g)}typeof p<"u"&&(m.$y=p+4,m.$reorder=k),this.setState(w)});const o=new Set(["start","end","duration","type","inactive","base_start","base_end","base_duration","segments","rollup","calendar","deadline","constraint"]);n.on("update-task",r=>{const{id:i,segmentIndex:d,diff:c,eventSource:l}=r,f=this.isHistorySource(l),h=r.task;let{task:u}=r;const g=this.getState(),{tasks:m,_scales:y,durationUnit:p,splitTasks:b,_calendars:k,unscheduledTasks:w,inactiveTasks:_}=g,v={tasks:m},S=m.byId(i);if(this.isRemote(l)){m.update(i,u),st(m.byId(i),h),this.markGeometry(this.editedRows(i,u.type==="summary"||S.type==="summary")),this.setStateAsync(v),r.task=m.byId(i);return}const W=this.getTaskCalendar({...S,...u}),T={durationUnit:p,unscheduledTasks:w};if(l==="add-task"||l==="copy-task"||l==="move-task"||l==="update-task"||l==="delete-task"||l==="provide-data"||l==="schedule-tasks"){l==="schedule-tasks"||j(u,T,W,S),m.update(i,u),st(m.byId(i),h),r.task=m.byId(i);return}if(!(at(S,g)&&"manual"in u&&!u.manual&&(u.type??S.type)==="summary"||c||d>=0||"type"in u&&u.type!==S.type||Object.keys(u).some(P=>{if(!o.has(P)||P==="type")return!1;const A=u[P],yt=S[P];return!dt(A,yt)}))){m.update(i,u),st(m.byId(i),h);const P=m.byId(i),A=!this.getGrouping()&&typeof P.$x=="number";this.markGeometry(A?"meta":"all"),this.setStateAsync({tasks:m}),r.task=P;return}const B=y.lengthUnit;let D=I(B);const G=ft(p,W);c&&(u.start&&(u.start=D(u.start,c)),!d&&d!==0&&(u.start&&u.end?u.duration=S.duration:(u.start?u.end=S.end:(u.end=D(u.end,c),u.start=S.start,u.duration=G(u.end,u.start)),G(u.end,u.start)||(u.duration=1)))),u.type=u.type??S.type;const pt=u.type==="summary",vn=at({type:u.type,manual:"manual"in u?u.manual:S.manual},g),Mn=!!S.data?.length;if(_&&"inactive"in u&&(u.inactive,S.inactive),W&&u.start&&!f&&(u.start=It(u.start,c,W)),u.start&&u.end&&(!F(u.start,S.start)||!F(u.end,S.end))&&pt&&Mn&&!vn){let P=c||G(u.start,S.start);W&&(P=u.start>S.start?G(u.start,S.start):-G(S.start,u.start),D=va(W)),this.moveSummaryKids(S,(A,yt)=>{A=D(A,P);const Zt=k?this.getTaskCalendar(yt):W;return Zt?It(A,c,Zt):A},"update-task")}f||j(u,T,W,S),m.update(i,u),st(m.byId(i),h),pt&&this.deriveSummary(i);const Kt=m.getSummaryId(i);Kt&&this.resetSummaryDates(Kt,"update-task"),this.markGeometry(this.editedRows(i,pt||S.type==="summary")),this.setStateAsync(v),r.task=m.byId(i)}),n.on("add-task",r=>{const{tasks:i,_scales:d,unscheduledTasks:c,durationUnit:l,splitTasks:f,tree:h}=this.getState(),{mode:u,task:g,show:m,select:y=!0}=r,p=U(r.target)?void 0:r.target,b=this.getTaskCalendar(g);let k=-1,w,_;if(p?(_=i.byId(p),u==="child"?(w=_,g.parent=w.id):(_.parent!==null&&(w=i.byId(_.parent),g.parent=w.id),k=i.getIndexById(p),u==="after"&&(k+=1))):g.parent&&(w=i.byId(g.parent)),typeof r.index=="number"&&(!p||u==="child")){const T=i.byId(g.parent||0)?.data,B=T?T.length:0;k=r.index>=0&&r.index<B?r.index:-1}if(this.isRemote(r.eventSource)){const T=i.add(g,k);this.setStateAsync({tasks:i}),r.id=T.id,r.task=T;return}!((!r.eventSource||g.unscheduled)&&c)&&!g.start&&(w?.start?g.start=new Date(w.start.valueOf()):_?g.start=new Date(_.start.valueOf()):g.start=za({tasks:i,durationUnit:l,_scales:d},b),g.duration=g.duration||1),b&&g.start&&(g.start=It(g.start,1,b)),this.getState().baselines&&g.start&&(g.base_start=g.start,g.base_duration=g.duration),j(g,{durationUnit:l,unscheduledTasks:c},b);const v=i.add(g,k),S={tasks:i};if(m)for(;w&&w.id;)n.exec("open-task",{id:w.id,mode:!0}),w=h.byId(w.parent);r.id=v.id;const W=i.getSummaryId(v.id);W&&this.resetSummaryDates(W,"add-task"),this.setStateAsync(S),r.id=v.id,r.task=v,y?n.exec("select-task",{id:v.id,show:m,eventSource:"add-task"}):m&&this.scrollToTask(v.id,m),m&&r.eventSource==="placeholder"&&setTimeout(()=>{this.getState().placeholderRow&&this.scrollToTask(Ht,"y")},1)}),n.on("delete-task",r=>{const{id:i}=r,d=this.getState(),{tasks:c,links:l,selected:f}=d,h=c.byId(i);r.source=h.parent;const u=c.getSummaryId(i),g=[i];c.eachChild(p=>g.push(p.id),i),l.filter(p=>!(g.includes(p.source)||g.includes(p.target)));const m={tasks:c,links:l},y=d.groupBy?.field==="resource";(f.includes(i)||y)&&(m.selected=f.filter(p=>p!==i&&(!y||d.tree.byId(p)?.$id!==i))),c.remove(i),u&&!this.isRemote(r.eventSource)&&this.resetSummaryDates(u,"delete-task"),this.setStateAsync(m)}),n.on("indent-task",({id:r,mode:i})=>{const{tasks:d}=this.getState();if(i){const c=d.getBranch(r)[d.getIndexById(r)-1];c&&n.exec("move-task",{id:r,mode:"child",target:c.id})}else{const c=d.byId(r),l=d.byId(c.parent);l&&l.parent!==null&&n.exec("move-task",{id:r,mode:"after",target:c.parent})}}),n.on("copy-task",r=>{const{id:i,target:d,mode:c,eventSource:l}=r;if(l==="copy-task")return;const{tasks:f,links:h}=this.getState();if(f.contains(i,d)){r.skipProvider=!0;return}const u=f.getSummaryId(i),g=f.getSummaryId(d);let m=f.getIndexById(d);c==="before"&&(m-=1);const y=f.byId(i),p=f.copy(y,f.byId(d).parent,m+1);r.source=r.id,r.id=p[0][1],y.lazy&&(r.lazy=!0),u!==g&&g&&this.resetSummaryDates(g,"copy-task");let b=[];for(let k=1;k<p.length;k++){const[w,_]=p[k];h.forEach(v=>{if(v.source===w){const S={...v};delete S.target,b.push({...S,source:_})}else if(v.target===w){const S={...v};delete S.source,b.push({...S,target:_})}})}b=b.reduce((k,w)=>{const _=k.findIndex(v=>v.id===w.id);return _>-1?k[_]={...k[_],...w}:k.push(w),k},[]);for(let k=1;k<p.length;k++){const[w,_]=p[k],v=f.byId(_),S=f.byId(v.parent)?.data;n.exec("copy-task",{source:w,id:_,lazy:!!v.lazy,eventSource:"copy-task",joinUndo:!0,target:v.parent,mode:"child",index:S?.findIndex(W=>W.id===_),skipUndo:!0})}b.forEach(k=>{n.exec("add-link",{link:{...k,id:void 0},eventSource:"copy-task",joinUndo:!0,skipUndo:!0})}),this.setStateAsync({tasks:f})}),n.on("open-task",({id:r,mode:i})=>{const{tree:d}=this.getState(),c=d.byId(r);c.lazy?n.exec("request-data",{id:c.id}):(d.toArray().forEach(l=>l.$y=0),d.update(r,{open:i}),this.setState({tree:d}))}),n.on("scroll-chart",({left:r,top:i,date:d})=>{const{_chartWidth:c,_chartHeight:l,_tasks:f,cellHeight:h,_scales:u,cellWidth:g,_start:m,_weekStart:y}=this.getState();let p={};if(d){const b=u.diff(d,m,"hour");r=Math.round(b*g)}if(!isNaN(r)){if(typeof c<"u"&&!isNaN(u.width)){const b=u.width-c;r=$t(r,0,b)}p={scrollLeft:r,_scaleDate:He(r,{_scales:u,_start:m,_weekStart:y}),_zoomOffset:null}}if(!isNaN(i)){if(l!=null){const b=u.height+f.length*h-l;i=$t(i,0,b)}p.scrollTop=i}this.setState(p)}),n.on("render-data",r=>{this.setState({area:r})}),n.on("provide-data",r=>{const{tasks:i,links:d,assignments:c,durationUnit:l,splitTasks:f,unscheduledTasks:h,inactiveTasks:u}=this.getState(),g=i.byId(r.id);g.lazy?(g.lazy=!1,g.open=!0):g.data=[],i.parse(r.data.tasks,r.id),fn(i,{durationUnit:l,unscheduledTasks:h,inactiveTasks:u},b=>this.getTaskCalendar(b),r.id);const m=g.type==="summary"?g.id:i.getSummaryId(g.id);m&&this.resetSummaryDates(m,"provide-data");const y=(At(r.data.links)||[]).filter(b=>i.byId(b.source)&&i.byId(b.target)),p={tasks:i,links:new kt(d.map(b=>b).concat(y))};this.setStateAsync(p)}),n.on("zoom-scale",({dir:r,ratio:i,offset:d})=>{const c=this.getState(),{zoom:l,cellWidth:f,_cellWidth:h,scrollLeft:u}=c,g=(d||0)+u,m=He(g,c),y=r<0&&h||f;let p=Math.round(y*(1+r*(i??.15)));const{maxCellWidth:b,minCellWidth:k}=l.levels[l.level],w=r<0&&f>b;if(this.shouldExpandScale(p)){this.changeScale(l,r)&&this.setState({cellWidth:p,_cellWidth:p});return}if(p<k||p>b||w){if(!this.changeScale(l,r))if(p=Math.max(Math.min(p,b),k),p!==f)this.setState({cellWidth:p,_cellWidth:p});else return}else this.setState({cellWidth:p,_cellWidth:p});const{_scales:_,_start:v,cellWidth:S,_weekStart:W}=this.getState(),T=$(_.minUnit,v,W),B=_.diff(m,T,"hour");typeof d>"u"&&(d=S);let D=Math.round(B*S)-d;D<0&&(D=0),this.setState({scrollLeft:D,_scaleDate:m,_zoomOffset:d})}),n.on("sort-tasks",({key:r,order:i,add:d})=>{const c=this.getState(),{tasks:l,tree:f,_columns:h}=c;let u=c._sort;const g={key:r,order:i};let m=u?.length||0;m&&d?(u.forEach((y,p)=>{y.key===r&&(m=p)}),u[m]=g):u=[g],f.sort(u,h),this.setState({_sort:u,tree:f})}),n.on("filter-tasks",r=>{const{open:i,key:d,value:c}=r;let l=r.filter;const f=this.getState(),{tree:h,_columns:u}=f;let g=f.filterValues;d?g={...g,[d]:c}:Object.keys(r).length||(g={}),!l&&Object.values(g).some(m=>m||m===0)&&(l=Gn(g,u)),h.filterTree(l,i??!0),this.setState({tree:h,_isFiltered:!!l,filterValues:g})}),n.on("hotkey",({key:r,event:i,eventSource:d})=>{switch(r){case"arrowup":case"arrowdown":{const{selected:c,_tasks:l}=this.getState();i.preventDefault();const f=c.length;let h;if(r==="arrowup"?h=f?this.getPrevRow(c[f-1])?.id:l[l.length-1]?.id:h=f?this.getNextRow(c[f-1])?.id:l[0]?.id,h){const u=d==="chart"?"xy":!0,g=d;this.in.exec("select-task",{id:h,show:u,focus:g})}break}case"ctrl+c":{ot(this,"copy-task",null,null);break}case"ctrl+x":{ot(this,"cut-task",null,null);break}case"ctrl+v":{ot(this,"paste-task",null,null);break}case"ctrl+d":case"backspace":{i.preventDefault(),ot(this,"delete-task",null,null);break}case"ctrl+z":{this.in.exec("undo",{});break}case"ctrl+y":{this.in.exec("redo",{});break}}}),n.on("resize-chart",({width:r,height:i,scrollSize:d,ganttWidth:c})=>{if(c!=null){const h=this.getState();(c!==h._containerWidth||d!=null&&d!==h._scrollSize)&&this.syncLayout(c,d)}let l={};const f=this.getState();r>f._scales?.width&&(l=Ia(r,f)),this.setState({...l,_chartWidth:r,_chartHeight:i,_scrollSize:d})}),n.on("resize-grid",({width:r,section:i="grid",inProgress:d})=>{const c=i==="subGrid",l=this.getState();if(c&&!Bt(l.columns))return;const f=this._resizeStart??={panels:l._displayPanels??l.displayMode,gridWidth:l.gridWidth,subGridWidth:l.subGridWidth};d||(this._resizeStart=null);const h=l._containerWidth;if(h==null){this.setState(c?{subGridWidth:r}:{gridWidth:r});return}const u={...jt(l,h),...c?{subGridWidth:r}:{gridWidth:r},preferredGridWidth:f.gridWidth,preferredSubGridWidth:f.subGridWidth},g=c?d?hr:lr:d?ur:cr,{panels:m,...y}=g(f.panels,u);if(d){this.setState({...y,_displayPanels:m});return}this.setState(y),Ut(m,f.panels)?Ut(l._displayPanels,f.panels)||this.setState({_displayPanels:f.panels}):this.in.exec("set-display-mode",{mode:m})}),n.on("set-columns",({columns:r})=>{const i=this.getState().columns.map(d=>{const c=r.find(l=>l.id===d.id);return c?{...d,width:c.width,hidden:c.hidden,flexgrow:c.flexgrow}:d});tn(i),this.setState({columns:i})}),n.on("set-display-mode",({mode:r})=>{const i=this.getState();Bt(i.columns);let d=Lt(r);if(i._compactMode){this.setState({_displayPanels:Nt(d,i._displayPanels)});return}const c=i._containerWidth;c!=null&&(d=fr(i._displayPanels??i.displayMode,d,jt(i,c)));const l=!(i._displayPanels??i.displayMode).includes("grid")&&d.includes("grid");this.setState({displayMode:d,...l&&i.gridWidth<=on(i)?{gridWidth:Ft(i.columns)}:{}}),this.resyncLayout()})}init(e){const n={...e},s=this.getState(),a=!!s.area,o=a?{}:{scrollLeft:0,scrollTop:0,area:{from:0,start:0,end:0},xArea:{from:0,to:0,start:0,end:0},_isFiltered:!1,filterValues:{},groupBy:{field:null},tree:[],showConflicts:!1,_compactMode:!1,_containerWidth:null,_chartHeight:null};n.cellWidth&&(n._cellWidth=n.cellWidth),n.inclusiveEnd&&(n.durationUnit??"day")!=="day"&&(n.inclusiveEnd=!1);const r=n.columns??s.columns,i=r===!1?void 0:r;this.prepareLayoutConfig(n,s,i,a),n.unscheduledTasks=!1,n.inactiveTasks=!1,n.placeholderRow=!1,n.baselines=!1,n.markers=Q,n._markers=Q,n.undo=!1,n.schedule={},n.criticalPath=null,n.splitTasks=!1,n.summary={},n.rollups=!1,n._rollups={},n.slack=!1,n.resources=null,n._resources=[],n.assignments=[],n.calendar=null,n.calendars=[],n._calendar=null,n._calendars=new Map,n._composites=null,n.groupBy=null,n.wbs=null,n.progressLine=null,n.deadlines=!1,n.sCurve=null,n._sCurve=null,n._sCurvePoints=null,n.conflicts=Q,n.showConflicts=!1,n._conflicts=null;const d=this.changed(n,"tasks"),c=this.changed(n,"inclusiveEnd");this.resolveCalendars(n,s,d),this.changed(n,..._r.geometry)&&this.markGeometry("all");for(const l in n)l[0]!=="_"&&(this._prevConfig[l]=n[l]);if(d&&n.tasks){const l=new Nn(n.tasks),f={};fn(l,{durationUnit:n.durationUnit,splitTasks:n.splitTasks,unscheduledTasks:n.unscheduledTasks,inactiveTasks:n.inactiveTasks},h=>this.resolveTaskCalendar(h,f)),n.tasks=l}else n.tasks&&delete n.tasks;this.resetDatasetState(d),this._router.init({selected:Q,markers:Q,progressLine:!1,sCurve:!1,autoScale:!0,durationUnit:"day",inclusiveEnd:!1,highlightTime:null,focusTask:null,_sort:null,_resourceSort:null,conflicts:Q,...o,...n}),n.displayMode&&this.resyncLayout(),c&&!d&&this.getState()._isFiltered&&this.in.exec("filter-tasks",{open:!0})}isHistorySource(e){return e==="undo"||e==="redo"}isRemote(e){return e==="remote"}resetDatasetState(e,n,s){const a=this.getState();e&&(a._isFiltered&&(a.tree.filterTree(),this.setState({_isFiltered:!1,filterValues:{}})),a._sort&&this.setState({_sort:null}))}changed(e,...n){return n.some(s=>{const[a,o]=s.split(".");if(!(a in e))return!1;let r=this._prevConfig[a],i=e[a];return o&&(r=r?.[o],i=i?.[o]),r!==i&&!dt(r,i)})}prepareLayoutConfig(e,n,s,a){const o=s??nn({resources:e.resources,wbs:e.wbs});!a||this.changed(e,"displayMode")?e.displayMode=Lt(e.displayMode):n.displayMode?.includes("subGrid")?e.displayMode=Lt(n.displayMode):delete e.displayMode,a||(e.gridWidth??=Ft(o),e.subGridWidth??=0)}resyncLayout(){const{_containerWidth:e,_scrollSize:n}=this.getState();e!=null&&this.syncLayout(e,n)}syncLayout(e,n){const s=this.getState(),a=dr(s,{width:e,scrollSize:n}),o={_containerWidth:e};n!=null&&(o._scrollSize=n),a.compactMode!==s._compactMode&&(o._compactMode=a.compactMode),a.displayPanels&&(o._displayPanels=a.displayPanels),a.gridWidth!==s.gridWidth&&(o.gridWidth=a.gridWidth),a.subGridWidth!==s.subGridWidth&&(o.subGridWidth=a.subGridWidth),this.setState(o)}setState(e,n){return this._router.setState(e,n)}setStateAsync(e){this._router.setStateAsync(e)}editedRows(e,n){if(n)return"all";const s=new Set([e]),a=this.getState().tasks.getSummaryId(e,!0);return Array.isArray(a)?a.forEach(o=>s.add(o)):a!=null&&s.add(a),s}markGeometry(e){if(e==="all"){this._pendingGeometry="all";return}if(e==="meta"){this._pendingGeometry===null&&(this._pendingGeometry="meta");return}if(this._pendingGeometry!=="all")if(this._pendingGeometry instanceof Set)for(const n of e)this._pendingGeometry.add(n);else this._pendingGeometry=new Set(e)}getTask(e){const{tree:n}=this.getState();return n.byId(e)}getLinkValidator(){return()=>null}getResource(e){const{resources:n}=this.getState();return n?.byId(e)}getHistory(){return this.getState().undo?this._modules.get("historyManager"):null}getCalendar(e){const{_calendar:n,_calendars:s}=this.getState();return s?.get(e)??n??void 0}buildHighlightTime(){return(e,n)=>{const s=this.getCalendar();return s&&(n==="day"||n==="hour")&&!s.isWorkingDay(e)?"wx-weekend":""}}getTaskCalendar(e){const n=this.getState();if(!(!n._calendar&&!n._calendars?.size))return this.resolveTaskCalendar(e,n)}resolveTaskCalendar(e,n){const{_calendar:s,_calendars:a}=n;return(o=>a?.get(o)??s??void 0)(e?.calendar)}indexAssignments(e){return{byTask:{},byResource:{}}}resolveCalendars(e,n,s){}getResourceCalendar(e){return this.getCalendar(e?.calendar)}getGrouping(){return this.getState().groupBy?.field?this._modules.get("groupManager"):null}serialize(e){const n=e?.data||"tasks";if(n==="calendars"){const{_calendars:a}=this.getState();return[...a.entries()].map(([o,r])=>({...r?.serialize?.()||{},...r?.css?{css:r.css}:{},id:o}))}const s=this.getState()[n];if(s){if(s instanceof ne)return s.serialize();if(s instanceof kt)return s.map(a=>a)}return null}getTaskResources(e){const{_assignments:n,resources:s}=this.getState();if(!s||!n)return[];const a=n.byTask[e];return a?a.map(o=>{const r=s.byId(o.resource),i={...o};return delete i.resource,delete i.task,r?{...i,...r,assignmentId:o.id}:null}).filter(Boolean):[]}getResourceTasks(e){const{_assignments:n,tasks:s}=this.getState();if(!n)return[];const a=n.byResource[e];return a?a.map(o=>s.byId(o.task)||null).filter(Boolean):[]}changeScale(e,n){const s=e.level+n,a=e.levels[s];if(a){const{cellWidth:o,scales:r,_scales:i}=this.getState(),d=Da(e,n,s,a,i.lengthUnit,r,o);return d._cellWidth=d.cellWidth,this.setState(d),!0}return!1}shouldExpandScale(e){const{start:n,end:s,_chartWidth:a,_scales:o,cellWidth:r}=this.getState();return n&&s&&a&&o?.width&&r?o.width/r*e<a:!1}isScheduled(e){return this.getState().unscheduledTasks?e.some(n=>!n.unscheduled||n.data&&this.isScheduled(n.data)):!0}resetSummaryDates(e,n,s){if(this.deriveSummary(e,n,s)){const a=this.getState().tasks.getSummaryId(e);a&&this.resetSummaryDates(a,n,s)}}deriveSummary(e,n,s){const{tasks:a,durationUnit:o,splitTasks:r,unscheduledTasks:i,inactiveTasks:d,schedule:c}=this.getState(),l=a.byId(e),f=l.data;if(l.type!=="summary"||!f?.length)return!1;const h=at(l,{schedule:c})&&!!(l.start&&l.end),u=Ot({...l,start:void 0,end:void 0,duration:void 0},i,d),g=!h&&!!u.start&&this.isScheduled(f)&&(!F(l.start,u.start)||!F(l.end,u.end)),m=!!u.inactive!=!!l.inactive;return!g&&!m?!1:(g||(u.start=l.start,u.end=l.end,u.duration=l.duration),n?(s&&!s.has(e)&&s.set(e,{start:l.start,end:l.end,inactive:l.inactive}),this.in.exec("update-task",{id:e,task:u,eventSource:n,joinUndo:!0,skipUndo:!0,...s?{inProgress:!0,skipProvider:!0}:{}})):(j(u,{durationUnit:o,unscheduledTasks:i},this.getTaskCalendar(u)),a.update(e,u)),!0)}moveSummaryKids(e,n,s){const{unscheduledTasks:a,schedule:o}=this.getState();e.data.forEach(r=>{o?.auto&&r.manual||(a&&r.unscheduled||this.in.exec("update-task",{id:r.id,task:{start:n(r.start,r)},eventSource:s,joinUndo:!0,skipUndo:!0}),r.data?.length&&(this.moveSummaryKids(r,n,s),r.type==="summary"&&this.deriveSummary(r.id,s)))})}getPlaceholderRow(){return this._placeholderRow||(this._placeholderRow=ja()),this._placeholderRow}getNextRow(e){const n=this.getState()._tasks,s=n.findIndex(a=>a.id===e);return n[s+1]}getPrevRow(e){const n=this.getState()._tasks,s=n.findIndex(a=>a.id===e);return n[s-1]}scrollToTask(e,n){const{_chartWidth:s,_chartHeight:a,scrollLeft:o,scrollTop:r,cellWidth:i,cellHeight:d,_tasks:c,_scrollSize:l}=this.getState(),f=c.findIndex(p=>p.id===e||p.$id===e);if(f<0)return;const h=c[f],u=h.$placeholder?h:this.getTask(h.id),g={};if(n?.toString().indexOf("x")!==-1){if(u.$x+u.$w/2<o)g.left=Math.max(u.$x-(i||0),0);else if(u.$x+u.$w/2>=s+o){const p=s<u.$w?i:u.$w;g.left=u.$x-s+p}}const m=f*d;let y=null;m<r?y=m:a!=null&&m+d>r+a&&(y=m-a+d+l),y!==null&&(g.top=Math.max(y,0)),this.in.exec("scroll-chart",g)}}function Sr(t,e,n,s){if(typeof document>"u")return"";const a=document.createElement("canvas");{const o=xr(a,t,e,1,n);vr(o,s,0,t,0,e)}return a.toDataURL()}function xr(t,e,n,s,a){t.setAttribute("width",(e*s).toString()),t.setAttribute("height",(n*s).toString());const o=t.getContext("2d");return o.translate(-.5,-.5),o.strokeStyle=a,o}function vr(t,e,n,s,a,o){t.beginPath(),t.moveTo(s,a),t.lineTo(s,o),e==="full"&&t.lineTo(n,o),t.stroke()}const Rt=[{id:"task",label:"Task"},{id:"summary",label:"Summary task"},{id:"milestone",label:"Milestone"}];function qt(t){return!!t&&!t.$group&&typeof t.$groupValue<"u"}function kn(t){return!!t?.$group}function Mr(t){let e=bn.map(a=>({...a}));const n=t?.taskTypes||Rt,s=e.find(a=>a.id==="convert-task");return s.data=[],n.forEach(a=>{(!t?.summary?.autoConvert||a.id!=="summary")&&s.data.push(s.dataFactory(a))}),e}function Xt(t){return t.map(e=>{switch(e.data&&Xt(e.data),e.id){case"add-task:before":case"move-task:up":e.isDisabled=(n,s)=>Tr(n,s)||qt(n)||kn(n);break;case"move-task:down":e.isDisabled=(n,s)=>Dr(n,s)||qt(n)||kn(n);break;case"indent-task:add":e.isDisabled=(n,s)=>Ir(n,s)===n.parent;break;case"indent-task:remove":e.isDisabled=n=>Wr(n);break}return e})}function Wr(t){return t.parent===0}function Tr(t,e){const{_tasks:n}=e;return n[0]?.id===t.id}function Dr(t,e){const{_tasks:n}=e;return(n[n.length-1]?.$placeholder?n[n.length-2]:n[n.length-1])?.id===t.id}function Ir(t,e){const{_tasks:n}=e,s=n.findIndex(a=>a.id===t.id);return n[s-1]?.id??t.parent}function $r(t){return t&&typeof t=="object"}function Cr(t){return!t.selected||t.selected.length<2}const Pr=t=>e=>e.type===t||t==="summary"&&qt(e),bn=Xt([{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"}]},{comp:"separator"},{id:"convert-task",text:"Convert to",icon:"wxi-swap-horizontal",dataFactory:t=>({id:`convert-task:${t.id}`,text:`${t.label}`,isDisabled:Pr(t.id)})},{id:"edit-task",text:"Edit",icon:"wxi-edit"},{comp:"separator"},{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"}]},{comp:"separator"},{id:"indent-task:add",text:"Indent",icon:"wxi-indent"},{id:"indent-task:remove",text:"Outdent",icon:"wxi-unindent"},{comp:"separator"},{id:"delete-task",icon:"wxi-delete",text:"Delete",subtext:"Ctrl+D / BS",isHidden:(t,e,n)=>Cr(e)&&$r(n)}]);function Er(t){return[..._n]}const _n=Xt([{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"}]);function wn(t){return t.type==="summary"}function Qt(t,e){return wn(t)&&!at(t,e)}function Vt(t){return t.type==="milestone"}function mt(t){return typeof t.parent>"u"}function Sn(t,e){return e.unscheduledTasks&&t.unscheduled}function Or(t){const e=xn.map(s=>({...s})),n=e.find(s=>s.key==="type");return n.options=t?.taskTypes||Rt,e}const xn=[{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",isHidden:t=>mt(t)},{key:"start",comp:"date",label:"Start date",config:{format:"%d-%m-%Y"},isHidden:(t,e)=>Qt(t,e)},{key:"end",comp:"date",label:"End date",config:{format:"%d-%m-%Y"},isHidden:(t,e)=>Qt(t,e)||Vt(t),isDisabled:(t,e)=>Sn(t,e)},{key:"duration",comp:"counter",label:"Duration",config:{min:1},isHidden:(t,e)=>Qt(t,e)||Vt(t),isDisabled:(t,e)=>Sn(t,e)},{key:"progress",comp:"slider",label:"Progress",config:{min:1,max:100},isHidden:t=>Vt(t)||mt(t)},{key:"links",comp:"links",label:"",batch:"links",isHidden:t=>mt(t)}];function Jt(t,e){return!t||!Array.isArray(t)?t:t.filter(e).map(n=>n.items&&Array.isArray(n.items)?{...n,items:Jt(n.items,e)}:{...n})}const Gr=[{items:[{comp:"icon",icon:"wxi-close",id:"close"},{comp:"spacer"},{comp:"button",type:"danger",text:"Delete",id:"delete"},{comp:"button",type:"primary",text:"Save",id:"save"}]},{id:"tabs",comp:"tabs",css:"wx-toolbar-tabs",options:[{id:"general",label:"General"},{id:"links",label:"Links"}]}];function Ar(t){let e=Gr.map(s=>({...s}));t?.autoSave!==!1&&(e=Jt(e,s=>s.id!=="save"));const n=e.find(s=>s.id==="tabs");return n?.options&&(n.options=[...n.options]),t?.resources&&n?.options.push({id:"resources",label:"Resources",isHidden:s=>wn(s)||mt(s)}),t?.splitTasks&&n?.options.push({id:"segments",label:"Segments",isHidden:s=>!s.segments?.length}),e}function Hr(t,e){return 0}function zr(t,e){return null}const Fr=[{id:"snet",label:"Start no earlier than"},{id:"snlt",label:"Start no later than"},{id:"fnet",label:"Finish no earlier than"},{id:"fnlt",label:"Finish no later than"},{id:"mso",label:"Must start on"},{id:"mfo",label:"Must finish on"}];function Br(t,e){return[]}function Lr(t,e,n){return""}function Nr(t,e,n){return[]}function Yr(t,e,n){return[]}function Ur(t,e){return null}function jr(t){return null}export{wr as DataStore,Ht as PLACEHOLDER_ROW_ID,Ca as calcScaleCellDate,un as calculateArea,jr as createCalendar,en as defaultColumns,Fr as defaultConstraintTypes,xn as defaultEditorItems,bn as defaultMenuOptions,Rt as defaultTaskTypes,_n as defaultToolbarButtons,Aa as extendDragOptions,Jt as filterEditorButtons,De as format,Ae as formatDay,Qa as fromInclusiveTask,I as getAdder,Je as getDateEditorButtons,nn as getDefaultColumns,Ft as getDefaultGridWidth,ft as getDiffer,Ar as getEditorButtons,Or as getEditorItems,Ke as getHeaderLength,Br as getHistogramBars,Lr as getHistogramCapacityPath,Mr as getMenuOptions,Ua as getPlaceholderTask,er as getResourceColumns,Yr as getResourceHistogramColumns,Nr as getResourceLoadColumns,Hr as getSegmentProgress,Er as getToolbarButtons,$ as getUnitStart,Sr as grid,ot as handleAction,ln as isHandledAction,U as isPlaceholder,Ga as isSegmentMoveAllowed,At as normalizeLinks,nr as normalizeResourceColumns,Ta as normalizeZoom,Ya as placeLink,kr as prepareEditTask,xa as registerScaleUnit,Ur as resolveResourceHistogramBar,zr as resolveSCurvePoint,Ha as setTaskResources,qa as toInclusiveTask,ar as toggleChartSubGrid,sr as toggleGridChart};