histropediajs 1.4.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.
@@ -0,0 +1,5 @@
1
+ /*!
2
+ HistropediaJS v1.4.0 | Histropedia Ltd. (c) 2026 | https://js.histropedia.com
3
+ Use of this software is subject to our End User Licence Agreement: https://js.histropedia.com/licence.html
4
+ */
5
+ (function(O,z){typeof exports=="object"&&typeof module!="undefined"?module.exports=z():typeof define=="function"&&define.amd?define(z):(O=typeof globalThis!="undefined"?globalThis:O||self,O.Histropedia=z())})(this,(function(){"use strict";var Wo=Object.defineProperty,Yo=Object.defineProperties;var Zo=Object.getOwnPropertyDescriptors;var Gi=Object.getOwnPropertySymbols;var Vo=Object.prototype.hasOwnProperty,Uo=Object.prototype.propertyIsEnumerable;var qi=(O,z,B)=>z in O?Wo(O,z,{enumerable:!0,configurable:!0,writable:!0,value:B}):O[z]=B,ct=(O,z)=>{for(var B in z||(z={}))Vo.call(z,B)&&qi(O,B,z[B]);if(Gi)for(var B of Gi(z))Uo.call(z,B)&&qi(O,B,z[B]);return O},$i=(O,z)=>Yo(O,Zo(z));const O={linear:t=>t,swing:t=>.5-Math.cos(t*Math.PI)/2,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,easeInCubic:t=>t**3,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t**3:1+--t*(2*t)**2};function z({from:t=0,to:e=1,duration:i=400,easing:n=O.linear,onUpdate:o,onComplete:s,autoStart:r=!0}={}){let a=null,l=!1;function h(d){if(l)return;a===null&&(a=d);const g=Math.min(1,(d-a)/i),f=n(g),m=t+(e-t)*f;o==null||o(m,f),g<1?requestAnimationFrame(h):s==null||s()}function c(){l=!1,a=null,requestAnimationFrame(h)}return r&&c(),{stop(){l=!0},restart(){l=!1,c()}}}const B=0,st=1,Xi=2,K=0,J=1,rt=2,Oe=3,ke=4,Ee=5,ze=6,Ne=7,xe=8,Be=9,Fe=10,He=11,At=11,We=10,Ye=9,Ze=8,ae=7,le=6,Ve=3,Ue=1,ji={3:{label:" ka",value:1e3},6:{label:" Ma",value:1e6},9:{label:" Ga",value:1e9}},Ge=1,qe=2,$e=3,he=0,Xe=0,Vt=1,ce=[{region:1,zoom:{from:0,to:3.11},low:1,medium:2,high:3,all:25,step:{months:0,days:1}},{region:2,zoom:{from:3.11,to:6.22},low:1,medium:2,high:3,all:25,step:{months:0,days:2}},{region:3,zoom:{from:6.22,to:9.33},low:1,medium:2,high:3,all:25,step:{months:0,days:4}},{region:4,zoom:{from:9.33,to:12.44},low:1,medium:2,high:3,all:25,step:{months:0,days:8}},{region:5,zoom:{from:12.44,to:15.55},low:1,medium:2,high:3,all:25,step:{months:0,days:16}},{region:6,zoom:{from:15.55,to:18.66},low:1,medium:2,high:3,all:25,step:{months:0,days:32}},{region:7,zoom:{from:18.66,to:21.77},low:1,medium:2,high:3,all:25,step:{months:0,days:64}},{region:8,zoom:{from:21.77,to:24.88},low:1,medium:2,high:3,all:25,step:{months:0,days:128}},{region:9,zoom:{from:24.88,to:27.99},low:1,medium:2,high:3,all:25,step:{months:0,days:256}},{region:10,zoom:{from:27.99,to:31.1},low:1,medium:2,high:3,all:25,step:{months:0,days:512}},{region:11,zoom:{from:31.1,to:34.21},low:1,medium:2,high:3,all:25,step:{months:0,days:1024}},{region:12,zoom:{from:34.21,to:37.32},low:1,medium:2,high:3,all:25,step:{months:0,days:2048}},{region:13,zoom:{from:37.32,to:40.43},low:1,medium:2,high:3,all:25,step:{months:0,days:4096}},{region:14,zoom:{from:40.43,to:43.54},low:1,medium:2,high:3,all:25,step:{months:0,days:8192}},{region:15,zoom:{from:43.54,to:46.65},low:1,medium:2,high:3,all:25,step:{months:0,days:16384}},{region:16,zoom:{from:46.65,to:49.76},low:1,medium:2,high:3,all:25,step:{months:0,days:32768}},{region:17,zoom:{from:49.76,to:52.87},low:1,medium:2,high:3,all:25,step:{months:0,days:65536}},{region:18,zoom:{from:52.87,to:55.98},low:1,medium:2,high:3,all:25,step:{months:0,days:131072}},{region:19,zoom:{from:55.98,to:59.09},low:1,medium:2,high:3,all:25,step:{months:0,days:262144}},{region:20,zoom:{from:59.09,to:62.2},low:1,medium:2,high:3,all:25,step:{months:0,days:524288}},{region:21,zoom:{from:62.2,to:65.31},low:1,medium:2,high:3,all:25,step:{months:0,days:1048576}},{region:22,zoom:{from:65.31,to:68.42},low:1,medium:2,high:3,all:25,step:{months:0,days:2097152}},{region:23,zoom:{from:68.42,to:71.53},low:1,medium:2,high:3,all:25,step:{months:0,days:4194304}},{region:24,zoom:{from:71.53,to:74.64},low:1,medium:2,high:3,all:25,step:{months:0,days:8388608}},{region:25,zoom:{from:74.64,to:77.75},low:1,medium:2,high:3,all:25,step:{months:0,days:16777216}},{region:26,zoom:{from:77.75,to:80.86},low:1,medium:2,high:3,all:25,step:{months:0,days:33554432}},{region:27,zoom:{from:80.86,to:83.97},low:1,medium:2,high:3,all:25,step:{months:0,days:67108864}},{region:28,zoom:{from:83.97,to:87.08},low:1,medium:2,high:3,all:25,step:{months:0,days:134217728}},{region:29,zoom:{from:87.08,to:90.19},low:1,medium:2,high:3,all:25,step:{months:0,days:268435456}},{region:30,zoom:{from:90.19,to:93.3},low:1,medium:2,high:3,all:25,step:{months:0,days:536870912}},{region:31,zoom:{from:93.3,to:96.41},low:1,medium:2,high:3,all:25,step:{months:0,days:1073741824}},{region:32,zoom:{from:96.41,to:99.52},low:1,medium:2,high:3,all:25,step:{months:0,days:2147483648}},{region:33,zoom:{from:99.52,to:102.63},low:1,medium:2,high:3,all:25,step:{months:0,days:4294967296}},{region:34,zoom:{from:102.63,to:105.74},low:1,medium:2,high:3,all:25,step:{months:0,days:8589934592}},{region:35,zoom:{from:105.74,to:108.85},low:1,medium:2,high:3,all:25,step:{months:0,days:17179869184}},{region:36,zoom:{from:108.85,to:111.96},low:1,medium:2,high:3,all:25,step:{months:0,days:34359738368}},{region:37,zoom:{from:111.96,to:115.07},low:1,medium:2,high:3,all:25,step:{months:0,days:68719476736}},{region:38,zoom:{from:115.07,to:118.18},low:1,medium:2,high:3,all:25,step:{months:0,days:137438953472}},{region:39,zoom:{from:118.18,to:121.29},low:1,medium:2,high:3,all:25,step:{months:0,days:274877906944}},{region:40,zoom:{from:121.29,to:124.4},low:1,medium:2,high:3,all:25,step:{months:0,days:549755813888}}],Ki=Object.freeze(Object.defineProperty({__proto__:null,DENSITY_ALL:he,DENSITY_HIGH:$e,DENSITY_LOW:Ge,DENSITY_MEDIUM:qe,DENSITY_SETTINGS:ce,ERA_MARKER:Xi,MAJOR_MARKER:st,MINOR_MARKER:B,PRECISION_BILLION_YEARS:Ue,PRECISION_CENTURY:ae,PRECISION_DAY:At,PRECISION_DECADE:Ze,PRECISION_MILLENNIUM:le,PRECISION_MILLION_YEARS:Ve,PRECISION_MONTH:We,PRECISION_YEAR:Ye,RANGE_ALL:Xe,RANGE_SCREEN:Vt,YEAR_PREFIXES:ji,ZOOM_100_MILLION_YEARS:Fe,ZOOM_100_THOUSAND_YEARS:Ne,ZOOM_10_MILLION_YEARS:Be,ZOOM_10_THOUSAND_YEARS:ze,ZOOM_BILLION_YEARS:He,ZOOM_CENTURY:ke,ZOOM_DAY:K,ZOOM_DECADE:Oe,ZOOM_MILLENNIUM:Ee,ZOOM_MILLION_YEARS:xe,ZOOM_MONTH:J,ZOOM_YEAR:rt},Symbol.toStringTag,{value:"Module"}));class Ji{constructor(){this._enabled=!1,this._prefix="[Histropedia]";const e=typeof console!="undefined"?console:null;this._console=e,this._fns={log:e&&e.log?e.log.bind(e):()=>{},warn:e&&e.warn?e.warn.bind(e):()=>{},error:e&&e.error?e.error.bind(e):()=>{},info:e&&e.info?e.info.bind(e):()=>{},debug:e&&e.debug?e.debug.bind(e):e&&e.log?e.log.bind(e):()=>{},group:e&&e.group?e.group.bind(e):e&&e.log?e.log.bind(e):()=>{},groupCollapsed:e&&e.groupCollapsed?e.groupCollapsed.bind(e):e&&e.group?e.group.bind(e):e&&e.log?e.log.bind(e):()=>{},groupEnd:e&&e.groupEnd?e.groupEnd.bind(e):()=>{}}}setEnabled(e){this._enabled=!!e}isEnabled(){return!!this._enabled}setPrefix(e){this._prefix=String(e||"")}getPrefix(){return this._prefix}_withPrefixedArgs(e){if(!this._prefix)return e;if(e&&e.length>0&&typeof e[0]=="string"){const i=e.slice();return i[0]=`${this._prefix} ${i[0]}`,i}return[this._prefix,...e]}_log(e,i){if(!this._enabled)return;(this._fns[e]||this._fns.log)(...this._withPrefixedArgs(i))}log(...e){this._log("log",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}group(...e){this._enabled&&this._fns.group(...this._withPrefixedArgs(e))}groupCollapsed(...e){this._enabled&&this._fns.groupCollapsed(...this._withPrefixedArgs(e))}groupEnd(){this._enabled&&this._fns.groupEnd()}}const P=new Ji,Ut=[31,28,31,30,31,30,31,31,30,31,30,31],Qi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function y(t,e,i){if(typeof t=="object"){const n=t;this.year=n.year,this.month=n.month,this.day=je(n.year,n.month,n.day)}else this.year=t,this.month=e,this.day=je(t,e,i)}function je(t,e,i){return i>28?Math.min(i,It(t,e)):i}function It(t,e){return e===2&&(t%4===0&&t%100!==0||t%400===0)?29:Ut[e-1]}function Gt(t,e){return t=t.toString(),e=typeof e=="string"?e:",",t.length<=4?t:t.replace(/\B(?=(\d{3})+(?!\d))/g,e)}y.prototype.getDaysTo=function(t){return t.getDaysSinceYearZero()-this.getDaysSinceYearZero()},y.prototype.getMonthsTo=function(t){return this.getYearsTo(t)*12},y.prototype.getYearsTo=function(t){let e=t.year-this.year;return e+=(t.month-this.month)/12+(t.day-this.day)/365.2422,e},y.prototype.getLeapYearsSinceYearZero=function(){let t=this.year;return this.month<3&&t--,Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400)},y.prototype.getDaysSinceYearZero=function(){let e=this.year*365+this.day;for(let i=0;i<this.month-1;i++)e+=Ut[i];return e+=this.getLeapYearsSinceYearZero(),e},y.prototype.getDayOfYear=function(){if(isUndefined(this._dayOfYear)){this._dayOfYear=0;for(let t=1;t<this.month;t++)this._dayOfYear+=It(this.year,t);this._dayOfYear+=this.day}return this._dayOfYear},y.getByDayOfYear=function(t,e){const i=new y(t,1,1);let n=Ut[0];for(let o=0;o<e-1;o++)i.day++,i.day>n&&(i.day=1,i.month++,i.month>12&&(i.month=1,i.year++),n=i.month===2?It(i.year,i.month):Ut[i.month-1]);return i},y.prototype.getNextDay=function(){return this.addDays(1)},y.prototype.addDays=function(t){let e=this.day,i=this.month,n=this.year;for(let o=0;o<t;o++)e++,e>It(n,i)&&(e=1,i++,i>12&&(i=1,n++));return new y(n,i,e)},y.prototype.addMonths=function(t){let e=this.month,i=this.year;for(let n=0;n<t;n++)e++,e>12&&(e=1,i++);return new y(i,e,1)},y.prototype.getPreviousDay=function(){let t=this.day,e=this.month,i=this.year;return t--,t<1&&(e--,e<1&&(e=12,i--),t=It(i,e)),new y(i,e,t)},y.prototype.getNextMonth=function(){let t=this.month,e=this.year;return t++,t>12&&(t=1,e++),new y(e,t,1)},y.prototype.getPreviousMonth=function(){let t=this.month,e=this.year;return t--,t<1&&(t=12,e--),new y(e,t,1)},y.prototype.addYears=function(t){return new y(this.year+t,1,1)},y.prototype.format=function(t,e){e=e||{},t=t||"D MMM YYYY";const i=e.yearPrefix,n=typeof e.bceText=="string"?e.bceText:" ʙᴄᴇ",o=this.year<=0,s=this.year===0,r=e.thousandsSeparator;if(i&&!s){const a=i.value||1,l=i.label||"";let h;return o?h=Gt((-this.year+1)/a,r)+l+n:h=Gt(this.year/a,r)+l,h}return t.replace("YYYY",o?Gt(-this.year+1,r)+n:Gt(this.year,r)).replace("D",this.day).replace("MMM",Qi[this.month-1])},y.prototype.isSame=function(t){return t.year===this.year&&t.month===this.month&&t.day===this.day},y.prototype.toKeyString=function(){return`${this.year}|${this.month}|${this.day}`},y.prototype.isAfter=function(t){if(this.year>t.year)return!0;if(this.year===t.year){if(this.month>t.month)return!0;if(this.month===t.month)return this.day>t.day}return!1},y.prototype.isBetween=function(t,e){return this.isAfter(t)&&e.isAfter(this)},y.prototype.compare=function(t){return this.isSame(t)?0:this.isAfter(t)?1:-1},y.prototype.asFloat=function(){const t=this.month-1,e=this.day-1;return t===0&&e===0?this.year:Math.round((this.year+(t*31+e)/371)*100)/100},y.prototype.isInFuture=function(){const t=new Date,e=new y(t.getFullYear(),t.getMonth()+1,t.getDate());return this.isAfter(e)},y.prototype.convertToIso=function(){return this.year<0&&(this.year+=1),this},y.CreateAsStartOfPeriod=function(t,e){const i=t.year,n=t.month||1,o=t.day||1;return e=e||At,e===ae?i<0?new y(i,1,1):new y(i-99,1,1):e===le?i<0?new y(i,1,1):new y(i-999,1,1):new y(i,n,o)},y.CreateAsEndOfPeriod=function(t,e){const i=t.year,n=t.month||1,o=t.day||1;if(e=e||At,e===At)return new y(i,n,o);if(e===We)return new y(i,n,It(i,n));if(e===Ye)return new y(i,12,31);if(e===Ze)return new y(i+9,12,31);const s=i<=0;return e===ae?s?new y(i+99,12,31):new y(i,12,31):e===le?s?new y(i+999,12,31):new y(i,12,31):e===Ve?new y(i+999999,12,31):e===Ue?new y(i+999999999,12,31):(P.error("precision is not implemented"),new y(i,n,o))},y.now=function(){const t=new Date;return new y({year:t.getYear()+1900,month:t.getMonth()+1,day:t.getDate()})},y.fromString=function(t){const e=t.split("-");e[0]===""&&(e.shift(),e[0]=`-${e[0]}`);const n=parseInt(e[0]),o=parseInt(e[1])||1,s=parseInt(e[2])||1;return new y({year:parseInt(n),month:parseInt(o),day:parseInt(s)})};function ue(t,...e){return Object.assign(t,...e)}function I(t,...e){const i=s=>{if(s&&typeof s=="object"&&!Object.prototype.hasOwnProperty.call(s,"__proto__"))try{Object.defineProperty(s,"__proto__",{value:void 0,writable:!0,enumerable:!1,configurable:!0})}catch(r){}};i(t);const n=s=>s==="__proto__"||s==="constructor"||s==="prototype",o=s=>{if(s===null||typeof s!="object")return!1;const r=Object.getPrototypeOf(s);return r===Object.prototype||r===null};for(const s of e)if(!(!s||typeof s!="object"))for(const r of Object.keys(s)){if(n(r))continue;const a=s[r];if(Array.isArray(a)){t[r]=a.slice();continue}if(o(a)){const l=o(t[r])?t[r]:{};i(l),t[r]=I(l,a);continue}t[r]=a}return i(t),t}function ut(t,e){const i=t.split("."),n=i[i.length-1];let o={};o[n]=e;for(let s=i.length-2;s>=0;s--){const r=i[s],a=I({},o);o={},o[r]=a}return o}function Ke(t,e){const i=`_${e}`;t[i]=void 0,Object.defineProperty(t,e,{get(){const n=this[i];return typeof n=="function"?n(this):n},set(n){this[i]=n},enumerable:!0,configurable:!1})}function de(t){return typeof t=="undefined"}const tn={id:"i",title:"t",rank:"r",subtitle:"s","from.year":"fy","from.month":"fm","from.day":"fd","from.precision":"fp","to.year":"ty","to.month":"tm","to.day":"td","to.precision":"tp",isToPresent:"p",isStarred:"v","offset.left":"ol","offset.top":"ot",imageUrl:"m",lane:"ln",style:"st",activeStyle:"ast",hiddenByFilter:"h",hidePeriodLine:"hp"};function Je(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:t[tn[e]]}function Qe(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}function ti(t){return t.indexOf(".")>-1}function v(t,e){return ti(e)?Qe(t,e):Je(t,e)}function C(t,e){return ti(e)?!de(Qe(t,e)):!de(Je(t,e))}Ke(L.prototype,"hidePeriodLine"),Ke(L.prototype,"hiddenByFilter");function L(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.imageLoaded=!1,this.stacking=0,this.groupIndex=0,this.isActive=!1,this.isVisible=!1,this.isVisibleInLane=!0,this.isInRange=!1,this.isInView=!1,this.isVisibleInGroup=!1,this.isVisibleInRows=!0,this.isStarred=!1,this.isMouseOverStar=!1,this.isMouseover=!1,this.isDragging=!1,this.registeredPosition={left:0,top:0},this.position={left:0,top:0},this.dragStartOffset={left:0,top:0},this.indicator={fromX:0,toX:0},this.offset={left:0,top:0},this.finalOffset={left:0,top:0},this.isVisibleAfterFade=!1,this.opacity=0,this.fadeAnimation={finalOpacity:0,dummyElement:null},this.moveAnimation={finalOffset:{left:0,top:0},dummyElement:void 0},this.row=0,this.laneId=null,this.laneOrder=0,this.isFading=!1,this.isMoving=!1,this._cachedHeight=0,this._cachedWidth=0,this._sizeValid=!1,this._sizeCacheKey=null,this._layoutCaches=null,this._resolvedDefaultCardLayout=null,this._resolvedCardLayoutName=null}L.prototype.setupByReceivedData=function(t){this.owner._assignArticleToLane(this,this.owner._resolveLaneIdFromArticleData(t));const e=this.owner._getResolvedArticleOptions(this).defaultData,i=I({},e,t);C(t,"to")||delete i.to,this.data=I({},t),this.title=v(i,"title")||"",this.rank=v(i,"rank")||0,this.subtitle=v(i,"subtitle")||"",this._setupArticlePeriod(i),this.offset.left=this.finalOffset.left=this.moveAnimation.finalOffset.left=i.offsetLeft||0,this.offset.top=this.finalOffset.top=this.moveAnimation.finalOffset.top=i.offsetTop||0,this.isStarred=!!i.starred,this.cardLayout=v(i,"cardLayout")||null,this.initialiseStyles(i),this.hiddenByFilter=v(i,"hiddenByFilter"),this.hidePeriodLine=C(i,"hidePeriodLine")?v(i,"hidePeriodLine"):this.owner.options.article.periodLine.defaultHide,this.isDataLoaded=!0,this.isImageInfoLoaded=!1},L.prototype._setupArticlePeriod=function(t){const e=new y(parseInt(v(t,"from.year")),parseInt(v(t,"from.month")),parseInt(v(t,"from.day")));this.owner.getDmyFromInput(e);const i=parseInt(v(t,"from.precision")),n=v(t,"isToPresent"),o=n===!0||n===1;let s,r;o?s=y.now():C(t,"to")?(s=new y(parseInt(v(t,"to.year")),parseInt(v(t,"to.month")),parseInt(v(t,"to.day"))),this.owner.getDmyFromInput(s),r=parseInt(v(t,"to.precision"))):(s=e,r=i);const a=y.CreateAsStartOfPeriod(e,i),l=y.CreateAsEndOfPeriod(s,r);this.period={from:a,to:l.getNextDay(),isToPresent:o},this.period.years=this.period.to.asFloat()-this.period.from.asFloat()},L.prototype.setImage=function(){this.isImageInfoLoaded=!0,v(this.data,"imageUrl")?this.owner.enqueueImageLoad(this):(this._releaseImageResource(),this.image=null,this.imageLoaded=!1)},L.prototype._releaseImageResource=function(t={}){const e=typeof this._closeImage=="function"?this._closeImage:null;if(e){this._closeImage=null;try{e(t)}catch(i){}return}t.keepState||(this.image=null,this.imageLoaded=!1,this._loadedImageKey=null)},L.prototype.registerPosition=function(t){this.registeredPosition=this.position=t},L.prototype.overlaps=function(t){return t.period.from.isSame(this.period.from)&&t.period.to.isSame(this.period.to)||t.period.from.isBetween(this.period.from,this.period.to)||t.period.to.isBetween(this.period.from,this.period.to)||this.period.from.isBetween(t.period.from,t.period.to)||this.period.to.isBetween(t.period.from,t.period.to)},L.prototype.overlapsInclusiveWithDates=function(t,e){return!(this.period.from.isAfter(e)||t.isAfter(this.period.to))},L.prototype.overlapsInclusive=function(t){return this.overlapsInclusiveWithDates(t.period.from,t.period.to)},L.prototype.isInside=function(t){if(!this.isVisible)return!1;this._ensureSizeCache();const e=this.position.left,i=this.position.top,n=this._cachedWidth,o=this._cachedHeight;return t.left>=e&&t.left<=e+n&&t.top>=i&&t.top<=i+o},L.prototype.pointerEnter=function(t){this.isMouseover=!0,this.owner.trigger("article-pointerenter",this,t)},L.prototype.pointerLeave=function(t){this.isMouseover=!1,this.owner.trigger("article-pointerleave",this,t)},L.prototype.updateIsMouseOverStar=function(t){const e=this.getIconBox();if(!e)return!1;const i=this.isMouseOverStar;return this.isMouseOverStar=t.left>=e.left&&t.left<=e.left+e.width&&t.top>=e.top&&t.top<=e.top+e.height,this.isMouseOverStar!==i&&!this.owner.isAnimating&&this.owner.redraw(),this.isMouseOverStar},L.prototype.getCursor=function(t){const e=this.owner.options.style.cursor;return this.isDragging?e.article.dragging:(this.updateIsMouseOverStar(t),this.owner.options.article.draggable&&this.isActive?this.isMouseOverStar?e.clickable:e.article.hoverDraggable:e.clickable)},L.prototype.clicked=function(t){return this.updateIsMouseOverStar(t),this.isMouseOverStar?(this.isStarred=!this.isStarred,!0):!1},L.prototype.getStatusForSave=function(){const t={i:this.id};return this.offset.left!==0&&(t.l=this.offset.left),this.offset.top!==0&&(t.t=this.offset.top),this.isStarred&&(t.v=!0),t},L.prototype.headerOverlapsWith=function(t){const e=this.registeredPosition.left,i=t.registeredPosition.left,n=e+this.getWidth();return i+t.getWidth()>=e&&n>=i},L.prototype._getWidth=function(){return this._getCurrentStyle().width},L.prototype.getWidth=function(){return this._ensureSizeCache(),this._cachedWidth},L.prototype.getHeight=function(){return this._ensureSizeCache(),this._cachedHeight},L.prototype.setOption=function(t,e){let i=!1;if(typeof t=="string"){if(typeof e=="undefined")return v(this.data,t);t=ut(t,e)}I(this.data,t),C(t,"id")&&(this.id=t.id),C(t,"title")&&(this.title=t.title,this.titleLines=void 0),C(t,"subtitle")&&(this.subtitle=t.subtitle,this.summarisedSubtitle=void 0),(C(t,"from")||C(t,"to")||C(t,"isToPresent"))&&(this._setupArticlePeriod(this.data),i=!0),C(t,"imageUrl")&&this.setImage(),C(t,"rank")&&(this.rank=t.rank,i=!0),C(t,"starred")&&(this.isStarred=t.starred),C(t,"hiddenByFilter")&&(this.hiddenByFilter=t.hiddenByFilter),C(t,"hidePeriodLine")&&(this.hidePeriodLine=t.hidePeriodLine);const n=C(t,"lane");n&&(this.owner._assignArticleToLane(this,t.lane),this.initialiseStyles(this.data),this.invalidateCaches(),i=!0);const o=C(t,"style"),s=C(t,"activeStyle"),r=C(t,"hoverStyle");let a=!1;o?(this.initialiseStyles(this.data),this.invalidateCaches()):(r&&(I(this.hoverStyle,t.hoverStyle),this.activeHoverStyle=I({},this.hoverStyle,this.owner._getResolvedArticleOptions(this).defaultActiveStyle,this.data.activeStyle),a=!0),s&&(this.activeStyle=I(this.activeStyle,t.activeStyle),a||I(this.activeHoverStyle,t.activeStyle)),this.invalidateCaches()),C(t,"cardLayout")&&this.setCardLayout(t.cardLayout),n&&this.owner.updateArticlesGroupIndex(),i?this.owner.requestRedraw():this.owner.requestRedraw(this.redraw)},L.prototype.initialiseStyles=function(t=this.data){const e=this.owner._getResolvedArticleOptions(this),i=this.owner._resolveDefaultCardLayoutName(this),o=this.owner._getExplicitArticleCardLayout(this)||i;this._resolvedDefaultCardLayout=i,this._resolvedCardLayoutName=o;const s=e.layoutStyles[o]||{},r=I({},e.defaultStyle,s.style||{},v(t,"style")||{}),a=I({},e.defaultActiveStyle,s.activeStyle||{},v(t,"activeStyle")||{}),l=I({},e.defaultHoverStyle,s.hoverStyle||{},v(t,"hoverStyle")||{});this.style=r,this.activeStyle=I({},r,a),this.hoverStyle=I({},r,l),this.activeHoverStyle=I({},this.hoverStyle,a)},L.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return v(this.style,t);t=ut(t,e)}this.data.style=I(this.data.style||{},t),this.initialiseStyles(this.data),this.invalidateCaches(),this.owner.requestRedraw()},L.prototype.setHoverStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return v(this.activeStyle,t);t=ut(t,e)}this.data.hoverStyle=I(this.data.hoverStyle||{},t),I(this.hoverStyle,t),this.activeHoverStyle=I({},this.hoverStyle,this.owner._getResolvedArticleOptions(this).defaultActiveStyle,this.data.activeStyle),this.owner.requestRedraw()},L.prototype.setActiveStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return v(this.activeStyle,t);t=ut(t,e)}this.data.activeStyle=I(this.data.activeStyle||{},t),I(this.activeStyle,t),I(this.activeHoverStyle,t),this.owner.requestRedraw()},L.prototype.activated=function(){P.warn('DEPRECATION WARNING: article.activated() was deprecated in v1.3.0. Use timeline.select(article.id) and handle selection with options.on["article-select"] instead.'),this.owner.trigger("article-click",this)},L.prototype.updateVisibility=function(){const t=this.isVisibleAfterFade,e=this.isInRange&&this.isVisibleInLane&&this.isVisibleInGroup&&this.isVisibleInRows&&!this.isHiddenByFilter;if(!this.isVisibleInLane){this.setVisibility(!1);return}if(t!==e){if(e&&!this.isImageInfoLoaded&&this.setImage(),!this.owner.options.article.animation.fade.active){this.setVisibility(e);return}this.setVisibilityWithFade(e)}},L.prototype.setVisibility=function(t){var e,i,n,o;this.isFading&&((i=(e=this.fadeAnimation)==null?void 0:e.dummyElement)!=null&&i.stop)&&(this.fadeAnimation.dummyElement.stop(),this.isFading=!1,((o=(n=this.owner)==null?void 0:n.lastAnimatingArticle)==null?void 0:o.id)===this.id&&this.owner.lastAnimatingArticle.animationType==="fade"&&(this.owner.isAnimatingArticles=!1)),this.isVisible=t,this.isVisibleAfterFade=t,this.opacity=t?1:0,t||this._releaseImageResource({skipRedraw:!0})},L.prototype.setVisibilityWithFade=function(t){var h,c,d,g;const e=this;if(t===e.isVisibleAfterFade)return;e.isFading&&((c=(h=e.fadeAnimation)==null?void 0:h.dummyElement)!=null&&c.stop)&&e.fadeAnimation.dummyElement.stop(),e.isFading=!0,e.isVisibleAfterFade=t,e.fadeAnimation=e.fadeAnimation||{},e.fadeAnimation.finalOpacity=t,t&&(e.isVisible=!0),e.owner.notifyArticleAnimating("fade",e.id);const i=e.owner.options.article.animation.fade,n=(d=i.duration)!=null?d:400,o=(g=i.easing)!=null?g:"swing",s=O[o]||O.swing,r=e.opacity,l=z({from:r,to:t?1:0,duration:n,easing:s,onUpdate(f){e.opacity=f,e.owner.requestRedraw()},onComplete(){e.isFading=!1,t||(e.isVisible=!1,e._releaseImageResource({skipRedraw:!0}));const f=e.owner.lastAnimatingArticle;e.id===f.id&&f.animationType==="fade"&&(e.owner.isAnimatingArticles=!1),typeof i.complete=="function"&&i.complete.call(e)}});e.fadeAnimation.dummyElement=l},L.prototype.moveToOffset=function(t){this.finalOffset.top=this.offset.top=t.top||this.offset.top,this.finalOffset.left=this.offset.left=t.left||this.offset.left,this.position.top=this.registeredPosition.top+this.offset.top,this.position.left=this.registeredPosition.left+this.offset.left},L.prototype.moveTo=function(t){const e={left:t.left-this.registeredPosition.left,top:t.top-this.registeredPosition.top};this.moveToOffset(e)},L.prototype.moveToWithAnim=function(t){const e={left:t.left-this.registeredPosition.left,top:t.top-this.registeredPosition.top};this.moveToOffsetWithAnim(e)},L.prototype.moveToOffsetWithAnim=function(t){var g,f,m;const e=this,i=e.moveAnimation;if(t.top===i.finalOffset.top&&t.left===i.finalOffset.left)return;e.isMoving&&((g=i==null?void 0:i.dummyElement)!=null&&g.stop)&&i.dummyElement.stop(),i.finalOffset=this.finalOffset={left:t.left,top:t.top},e.isMoving=!0,e.owner.notifyArticleAnimating("move",e.id);const n=e.owner.options.article.animation.move,o=(f=n.duration)!=null?f:400,s=(m=n.easing)!=null?m:"swing",r=O[s]||O.swing,a=e.offset.top,l=e.offset.left,h=t.top-a,c=t.left-l,d=z({from:0,to:1,duration:o,easing:r,onUpdate(b){e.offset.top=a+h*b,e.offset.left=l+c*b,e.position.top=e.registeredPosition.top+e.offset.top,e.position.left=e.registeredPosition.left+e.offset.left,e.owner.requestRedraw()},onComplete(){e.offset.top=t.top,e.offset.left=t.left,e.position.top=e.registeredPosition.top+t.top,e.position.left=e.registeredPosition.left+t.left,e.isMoving=!1;const b=e.owner.lastAnimatingArticle;e.id===b.id&&b.animationType==="move"&&(e.owner.isAnimatingArticles=!1)}});i.dummyElement=d},L.prototype.draw=function(t){if(!this.isDataLoaded||isNaN(this.position.left))return;this._ensureSizeCache(),t.globalAlpha=this.opacity,this._getCurrentCardLayout().draw.call(this,t)},L.prototype._getCurrentStyle=function(){return this.isActive?this.isMouseover?this.activeHoverStyle:this.activeStyle:this.isMouseover?this.hoverStyle:this.style},L.prototype._getPeriodLineRenderGeometry=function(t){const i=this.owner._getResolvedArticleOptions(this).periodLine||{},o=(this.owner.options.article.periodLine||{}).position||"axis",s=Number.isFinite(i.baselineGap)?i.baselineGap:0,r=this.hidePeriodLine?0:i.spacing||0,a=this.hidePeriodLine?0:i.thickness||0,l=(r+a)*this.stacking;let h=t,c=this.owner.options.style.mainLine.size/2;if(o==="lane"&&this.owner._isLaneLayoutActive()){const g=this.owner.getLaneById(this.laneId);g&&g.geometry&&(h=Math.floor(g.geometry.bottom),c=0)}const d=h-s-l-c-a/2;return{position:o,baselineGap:s,spacing:r,thickness:a,anchorY:h,anchorOffset:c,y:d}},L.prototype.drawPeriodLinesAndConnectors=function(t,e){t.globalAlpha=this.opacity;const i=this._getCurrentStyle(),n=this._getPeriodLineRenderGeometry(e),o=n.y;if(!this.hidePeriodLine){const g=this.indicator.fromX,f=this.indicator.toX;if(t.beginPath(),t.lineWidth=n.thickness,t.moveTo(g,o),t.lineTo(f,o),this.period.isToPresent){const m=f-g,b=15,A=Math.max(1-b/m,.7),p=t.createLinearGradient(g,o,f,o);p.addColorStop(0,i.color),p.addColorStop(A,i.color),p.addColorStop(1,"rgba(255,255,255,0)"),t.strokeStyle=p}else t.strokeStyle=i.color;t.stroke()}if(!i.connectorLine.visible)return;const s=this._getCurrentCardLayout(),r=typeof s.getConnectorEnd=="function"?s.getConnectorEnd.call(this):{left:this.position.left+i.connectorLine.offsetX,top:this.position.top+this.getHeight()+i.connectorLine.offsetY},a=Math.max(0,this.indicator.fromX),l=o,h=r.left,c=r.top;t.strokeStyle=t.fillStyle=i.color,t.lineWidth=i.connectorLine.thickness,t.beginPath(),t.moveTo(a,l),t.lineTo(h,c),t.stroke();const d=Math.atan((c-l)/(h-a))+(h>=a?-90:90)*Math.PI/180;t.save(),t.beginPath(),t.translate(h,c),t.rotate(d),t.moveTo(-i.connectorLine.arrow.width,0),t.lineTo(i.connectorLine.arrow.width,0),t.lineTo(0,-i.connectorLine.arrow.height),t.closePath(),t.restore(),t.fill()},L.prototype.getIconBox=function(){return this._getCurrentCardLayout().getIconBox.call(this)},L.prototype.startDragging=function(t,e){this.isMoving&&this.moveAnimation.dummyElement.stop(),this.isDragging=!0,this.dragInitialPosition={left:this.position.left,top:this.position.top},this.lastDragPosition={left:this.position.left,top:this.position.top},this.dragStartOffset={left:t.left-this.position.left,top:t.top-this.position.top},this.owner.startAnimation(),this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag-start",this,e)},L.prototype.stopDragging=function(t){this.offset=this.finalOffset=this.moveAnimation.finalOffset={left:this.position.left-this.registeredPosition.left,top:this.position.top-this.registeredPosition.top},this.isDragging=!1,this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag-end",this,t)},L.prototype.dragging=function(t,e){const i={left:t.left-this.dragStartOffset.left,top:t.top-this.dragStartOffset.top},n=this.lastDragPosition||{left:this.position.left,top:this.position.top},o=this.dragInitialPosition||n,s=i.left-n.left,r=i.top-n.top,a=i.left-o.left,l=i.top-o.top;this.position=i,this.lastDragPosition=i,this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag",this,{dx:s,dy:r,totalDx:a,totalDy:l},e)},L.prototype._cacheBucket=function(){const t=this._getCurrentCardLayoutName();return this._layoutCaches||(this._layoutCaches=Object.create(null)),this._layoutCaches[t]||(this._layoutCaches[t]=Object.create(null))},L.prototype.memo=function(t,e){const i=this._cacheBucket();return t in i?i[t]:i[t]=e.call(this)},L.prototype._getSizeCacheKey=function(){var l,h;const t=typeof this._getCurrentStyle=="function"?this._getCurrentStyle():null,e=t&&t.image||{},i=t&&t.header||{},n=t&&t.subheader||{},o=t&&t.border||{},s=typeof this._getCurrentCardLayoutName=="function"?this._getCurrentCardLayoutName():"",r=this.imageLoaded&&this.image;return[s,t&&t.width,t&&t.height,i.height,n.height,o.width,(l=e.margin)!=null?l:0,e.shape||"",(h=e.maxHeight)!=null?h:"",t&&t.maxImageHeight!==void 0?t.maxImageHeight:"",r?this.image.width:"noimg",r?this.image.height:""].join("|")},L.prototype.updateCachedSize=function(){const t=this._getCurrentCardLayout();this._cachedWidth=t.getWidth.call(this),this._cachedHeight=t.getHeight.call(this),this.height=this._cachedHeight,this._sizeValid=!0,this._sizeCacheKey=this._getSizeCacheKey()},L.prototype._ensureSizeCache=function(){const t=this._getSizeCacheKey();(!this._sizeValid||t!==this._sizeCacheKey)&&this.updateCachedSize()},L.prototype.invalidateCaches=function(){if(this._sizeValid=!1,this._sizeCacheKey=null,this._layoutCaches){const t=this._layoutCaches;for(const e in t){const i=t[e];if(i)for(const n in i){const o=i[n];if(o&&typeof o.close=="function")try{o.close()}catch(s){}}}}this._layoutCaches=null},L.prototype._getCurrentCardLayoutName=function(){return this._resolvedCardLayoutName||this.cardLayout||this._resolvedDefaultCardLayout||this.owner._resolveArticleCardLayoutName(this)},L.prototype._getCurrentCardLayout=function(){return this.owner.getCardLayout(this._getCurrentCardLayoutName())},L.prototype.setCardLayout=function(t){if(!this.owner.getCardLayout(t))throw new Error(`Card layout "${t}" not found`);this.cardLayout=t,this._resolvedCardLayoutName=t,this.initialiseStyles(),this.invalidateCaches(),this.owner.requestRedraw(this.redraw)};function dt(t,e){const i=Number(t),n=Number(e);if(Number.isFinite(i)&&Number.isFinite(n))return i-n;const s=String(t),r=String(e);return s===r?0:s<r?-1:1}function en(t,e){const i=t.period.from.getDaysTo(t.period.to),n=e.period.from.getDaysTo(e.period.to);return i<n?1:i>n?-1:dt(t.id,e.id)}function nn(t,e){const i=t.period.years,n=e.period.years;return i<n?1:i>n?-1:dt(t.id,e.id)}function on(t,e){const i=t.isInView&&t.isVisible,n=e.isInView&&e.isVisible;return!i&&n?-1:i&&!n?1:t.position.top-e.position.top}function ei(t,e){const i=t.period.from,n=e.period.from;let o=i.compare(n);return o===0&&(o=dt(e.id,t.id)),o}function sn(t,e){const i=t.period.to;let o=e.period.to.compare(i);return o===0&&(o=dt(e.id,t.id)),o}function rn(t,e){const i=t.position.top,n=e.position.top;return i<n?-1:i>n?1:dt(e.id,t.id)}function fe(t,e){const i=t.laneOrder||0,n=e.laneOrder||0;if(i>n)return-1;if(i<n)return 1;const o=t.row,s=e.row;return o<s?1:o>s?-1:dt(e.id,t.id)}function ge(t,e){const i=t.rank,n=e.rank;return i<n?1:i>n?-1:dt(e.id,t.id)}function an(t,e){const i=t.effectiveRank,n=e.effectiveRank;return i<n?1:i>n?-1:dt(e.id,t.id)}function ln(t,e){const i=t.position.left,n=e.position.left;let o=i<n?1:i>n?-1:0;return o===0&&(o=t.position.top-e.position.top,o===0&&(o=t.period.from.compare(e.period.from),o===0&&(o=dt(t.id,e.id)))),o}const hn=Object.freeze(Object.defineProperty({__proto__:null,ARTICLE_DURATION_SORTER:en,ARTICLE_DURATION_YEARS_SORTER:nn,ARTICLE_EFFECTIVE_RANK_SORTER:an,ARTICLE_FROM_SORTER:ei,ARTICLE_IMAGE_QUEUE_SORTER:on,ARTICLE_POSITION_SORTER:ln,ARTICLE_RANK_SORTER:ge,ARTICLE_ROW_SORTER:fe,ARTICLE_TOP_SORTER:rn,ARTICLE_TO_SORTER:sn},Symbol.toStringTag,{value:"Module"})),cn=["defaultCardLayout","defaultStyle","defaultHoverStyle","defaultActiveStyle","layoutStyles"],un=["defaultData","density","distanceToBaseline","autoStacking.active","autoStacking.rowSpacing","autoStacking.fitToHeight","autoStacking.topGap","periodLine.baselineGap","periodLine.spacing","periodLine.thickness"];function ii(t,e){if(!t||typeof t!="object")return!1;for(let i=0;i<e.length;i++)if(C(t,e[i]))return!0;return!1}function kt(t){return typeof t=="number"&&Number.isFinite(t)}function me(t,e,i){return Math.min(Math.max(t,e),i)}function ni(t){const e=ii(t,cn);return{cacheChanged:e||ii(t,un),styleChanged:e}}function oi(t={},e={}){const i=t||{},n=e||{},o=i.autoStacking||{},s=n.autoStacking||{},r=i.periodLine||{},a=n.periodLine||{};return{defaultData:I({},i.defaultData||{},n.defaultData||{}),density:Object.prototype.hasOwnProperty.call(n,"density")?n.density:i.density,distanceToBaseline:I({},i.distanceToBaseline||{},n.distanceToBaseline||{}),defaultCardLayout:Object.prototype.hasOwnProperty.call(n,"defaultCardLayout")?n.defaultCardLayout:i.defaultCardLayout,defaultStyle:I({},i.defaultStyle||{},n.defaultStyle||{}),defaultHoverStyle:I({},i.defaultHoverStyle||{},n.defaultHoverStyle||{}),defaultActiveStyle:I({},i.defaultActiveStyle||{},n.defaultActiveStyle||{}),layoutStyles:I({},i.layoutStyles||{},n.layoutStyles||{}),autoStacking:{active:C(n,"autoStacking.active")?s.active:o.active,rowSpacing:C(n,"autoStacking.rowSpacing")?s.rowSpacing:o.rowSpacing,fitToHeight:C(n,"autoStacking.fitToHeight")?s.fitToHeight:o.fitToHeight,topGap:C(n,"autoStacking.topGap")?s.topGap:o.topGap},periodLine:{baselineGap:C(n,"periodLine.baselineGap")?a.baselineGap:r.baselineGap,spacing:C(n,"periodLine.spacing")?a.spacing:r.spacing,thickness:C(n,"periodLine.thickness")?a.thickness:r.thickness}}}function dn(t,e,i,n){var b;if(!t||t.active!==!0)return null;const o=t.lanesOnly!==!1;if(!i&&o)return null;const s=(b=t.byCardLayout)==null?void 0:b[n];if(!s)return null;const r=Math.max(0,kt(e)?e:0),a=Math.max(0,kt(s.ratio)?s.ratio:0),l=kt(s.min)?s.min:0,h=kt(s.max)?s.max:Number.POSITIVE_INFINITY,c=Math.max(0,Math.min(l,h)),d=Math.max(c,h),g=me(c,0,r),f=me(d,g,r),m=Math.round(r*a);return me(m,g,f)}function qt(t,e,i,n){const o=dn(t==null?void 0:t.responsive,e,i,n);return Number.isFinite(o)?o:kt(t==null?void 0:t.value)?t.value:0}const fn={from:{precision:At},to:{precision:At},rank:0,starred:!1,hidePeriodLine:!1,hiddenByFilter:!1},gn={width:150,color:"#e9e9e9",backgroundColor:"#fff",topRadius:3,maxImageHeight:400,image:{shape:"natural",margin:0,maxHeight:200,borderRadius:0},header:{height:50,text:{font:"normal 14px 'Segoe UI'",align:"left",baseline:"middle",margin:10,color:"#333",lineHeight:18,numberOfLines:2,offsetY:0}},subheader:{height:30,color:"#555",text:{font:"normal 11px 'Segoe UI'",color:"#eee",align:"left",baseline:"middle",margin:10,lineHeight:6,offsetY:0}},shadow:{x:0,y:0,amount:0,color:"#000"},border:{color:"#ddd",width:1},connectorLine:{visible:!0,offsetX:18,offsetY:-20,thickness:1,arrow:{width:16,height:45}},star:{width:16,margin:3}},mn={color:"#a6c6e2"},pn={color:"#337ab7",header:{text:{color:"#fff"}},subheader:{color:"#333"},shadow:{x:3,y:3,amount:5,color:"#333"},border:{width:2,color:"#2e6da4"},connectorLine:{thickness:2}},yn={heightWeight:1,header:{visible:!0,height:24,padding:{left:12,right:12}}},wn={header:{},body:{},title:{}},bn={width:1e3,height:500,verticalOffset:40,enableUserControl:!0,enableCursor:!0,canvas:{dpr:"auto",dprMode:"stable",maxDpr:3},zoom:{initial:34,minimum:0,maximum:123,wheelStep:.2,wheelSpeed:3,allowCtrlWheel:!1,wheelMode:"auto",discreteWheelAnimation:{active:!0,duration:250},proportionalGain:2,proportionalExponent:1.1,ratio:.8,unitSize:{initial:200,showMinorLabels:48,minimum:8}},initialDate:{year:1990,month:1,day:1},shiftBceDates:!1,draggingVicinity:!0,pan:{momentum:{active:!0,sampleWindow:100,minVelocity:.01,stopVelocity:.005,friction:.005,maxDuration:5600}},style:{mainLine:{visible:!0,position:"bottom",size:8,showDateIndicators:!0},draggingHighlight:{visible:!0,color:"rgba(237, 247, 255, 0.5)",area:{up:0,down:"edge"}},marker:{minor:{height:12,extend:!1,color:"#6097f2",futureColor:"#ccc"},major:{height:30,extend:!1,color:"#0c3a88",futureColor:"#ccc"}},dateLabel:{minor:{font:"normal 10px Calibri",color:"#333",futureColor:"#ccc",textAlign:"start",offset:{x:4,y:0},bceText:"",thousandsSeparator:",",yearPrefixes:{ka:{label:"ka",value:1e3,minDivision:1e3},Ma:{label:"Ma",value:1e6,minDivision:1e5},Ga:{label:"Ga",value:1e9,minDivision:1e8}}},major:{font:"normal 16px Calibri",color:"#000",futureColor:"#ccc",textAlign:"start",offset:{x:4,y:0},bceText:" ʙᴄᴇ",thousandsSeparator:",",yearPrefixes:{ka:{label:"ka",value:1e3,minDivision:1e5},Ma:{label:"Ma",value:1e6,minDivision:1e6},Ga:{label:"Ga",value:1e9,minDivision:1e9}}}},cursor:{timeline:{hover:"default",dragging:"e-resize"},clickable:"pointer",article:{hoverDraggable:"move",dragging:"move"}}},timeBand:{visible:!0,reserveSpace:!0,reserveSpacePixels:20,area:{up:0,down:"edge"},defaultStyle:{backgroundColor:"rgba(200, 200, 200, 0.25)",border:{color:"rgba(120, 120, 120, 0.25)",width:1},text:{font:"normal 16px Calibri",color:"#555",align:"left",baseline:"bottom",verticalAlign:"bottom",margin:4,offsetY:0}},data:[]},lane:{visible:!0,defaultId:"default",gap:0,topGap:0,axisGap:0,defaultLayout:I({},yn),defaultStyle:I({},wn),defaultClassName:"",defaultHeaderClassName:"",defaultBodyClassName:"",defaultTitleClassName:"",data:[]},image:{maxConcurrent:6,maxCacheBytes:64*1024*1024,requireCORS:!1,decodeMode:"auto",sanitizer:{allowedSchemes:["http","https","data","blob"]}},article:{density:he,rendering:{pixelSnap:"device"},draggable:!0,distanceToBaseline:{value:350,responsive:{active:!0,lanesOnly:!0,byCardLayout:{portrait:{ratio:.6,min:310,max:410},landscape:{ratio:.6,min:100,max:160}}}},collectOngoing:!1,autoStacking:{active:!0,rowSpacing:50,range:Xe,fitToHeight:!0,topGap:10},periodLine:{position:"lane",baselineGap:0,spacing:4,thickness:10,stacking:{sorter:ei,reverseOrder:!1}},animation:{fade:{active:!0,duration:1500,easing:"swing"},move:{active:!0,duration:1500,easing:"swing"}},star:{visible:!0},defaultData:ct({},fn),defaultCardLayout:"portrait",cardLayoutBreakpoints:[{maxHeight:320,layout:"landscape"}],defaultStyle:ct({},gn),defaultHoverStyle:ct({},mn),defaultActiveStyle:ct({},pn),layoutStyles:{}}};function _n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function si(t,e){P.warn(`DEPRECATION WARNING: ${t} is deprecated. Use ${e} instead.`)}function ri(t,e,i){(t==null?void 0:t.distanceToMainLine)!==void 0&&(si(`${i}.distanceToMainLine`,`${i}.distanceToBaseline.value`),e&&((!e.distanceToBaseline||typeof e.distanceToBaseline!="object")&&(e.distanceToBaseline={}),_n(e.distanceToBaseline,"value")||(e.distanceToBaseline.value=t.distanceToMainLine),delete e.distanceToMainLine))}function ai(t){if(typeof t!="string")return t;const e=t.replace(/(^article\.|\.article\.)distanceToMainLine$/,"$1distanceToBaseline.value");return e!==t&&si(t,e),e}function pe(t){var i;if(!t)return t;const e=I({},t);return((i=t.article)==null?void 0:i.distanceToMainLine)!==void 0&&(e.article||(e.article={}),ri(t.article,e.article,"lane.article")),e}function li(t){var n,o,s,r;if(!t)return t;const e=I({},t);if(((n=t.article)==null?void 0:n.distanceToMainLine)!==void 0&&(e.article||(e.article={}),ri(t.article,e.article,"article")),Array.isArray((o=t.lane)==null?void 0:o.data)){e.lane||(e.lane={}),e.lane.data=e.lane.data||[];for(let a=0;a<t.lane.data.length;a++)e.lane.data[a]=pe(t.lane.data[a])}if(((r=(s=t.article)==null?void 0:s.periodLine)==null?void 0:r.defaultHide)!==void 0&&(P.warn("DEPRECATION WARNING: article.periodLine.defaultHide is deprecated. Use article.defaultData.hidePeriodLine instead."),e.article||(e.article={}),e.article.defaultData||(e.article.defaultData={}),e.article.defaultData.hidePeriodLine=t.article.periodLine.defaultHide),["defaultStyle","defaultHoverStyle","defaultActiveStyle"].forEach(a=>{var l,h;((h=(l=t.article)==null?void 0:l[a])==null?void 0:h.maxImageHeight)!==void 0&&(P.warn(`DEPRECATION WARNING: article.${a}.maxImageHeight is deprecated. Use article.${a}.image.maxHeight instead.`),e.article||(e.article={}),e.article[a]||(e.article[a]={}),e.article[a].image||(e.article[a].image={}),e.article[a].image.maxHeight=t.article[a].maxImageHeight)}),t.onSave!==void 0&&(P.warn('DEPRECATION WARNING: onSave is deprecated. Use options.on["timeline-state-change"] instead.'),e.on||(e.on={}),!e.on["timeline-state-change"])){const a=t.onSave;typeof a=="function"&&(e.on["timeline-state-change"]=function(l){a.call(this,l)})}if(t.onArticleClick!==void 0&&(P.warn('DEPRECATION WARNING: onArticleClick is deprecated. Use options.on["article-click"] for click events, or options.on["article-select"] for selection by any means.'),e.on||(e.on={}),!e.on["article-click"])){const a=t.onArticleClick;typeof a=="function"&&(e.on["article-click"]=function(l,h){a.call(this,l)})}if(t.onArticleDoubleClick!==void 0&&(P.warn('DEPRECATION WARNING: onArticleDoubleClick is deprecated. Use options.on["article-dblclick"] instead.'),e.on||(e.on={}),!e.on["article-dblclick"])){const a=t.onArticleDoubleClick;typeof a=="function"&&(e.on["article-dblclick"]=function(l,h){a.call(this,l)})}if(t.onRedraw!==void 0){if(P.warn('DEPRECATION WARNING: onRedraw is deprecated. Use options.on["timeline-render-end"] instead.'),e.on||(e.on={}),!e.on["timeline-render-end"]){const a=t.onRedraw;typeof a=="function"&&(e.on["timeline-render-end"]=function(l){a.call(this,l)})}delete e.onRedraw}return e}const hi=I({},bn);function Et(t,e,...i){return typeof t=="function"?t.call(e,...i):t}function Z(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.isImplicit=!1,this.order=0,this.title="",this.className="",this.headerClassName="",this.bodyClassName="",this.titleClassName="",this.layout={},this.style={},this.articleOptions={},this.resolvedArticleOptions={},this._runtimeArticleOptions={},this.geometry=null,this.currentVisibility="visible"}Z.prototype.setupByReceivedData=function(t,{implicit:e=!1}={}){this.data=pe(t),this.isImplicit=!!e,this._resolveFromData(),this.isDataLoaded=!0},Z.prototype._resolveFromData=function(){var i,n;const t=this.owner&&this.owner.options?this.owner.options.lane||{}:{},e=this.data||{};this.title=v(e,"title")||"",this.className=v(e,"className")||"",this.headerClassName=v(e,"headerClassName")||"",this.bodyClassName=v(e,"bodyClassName")||"",this.titleClassName=v(e,"titleClassName")||"",this.layout=I({},t.defaultLayout||{},e.layout||{}),this.style=I({},t.defaultStyle||{},e.style||{}),this.articleOptions=I({},e.article||{}),this.resolvedArticleOptions=oi(((n=(i=this.owner)==null?void 0:i.options)==null?void 0:n.article)||{},this.articleOptions)},Z.prototype._applyOption=function(t,{suppressRedraw:e=!1,markExplicit:i=!1,suppressArticleRefresh:n=!1}={}){if(!t||typeof t!="object")return;t=pe(t);const o=this.id,s=C(t,"id")?t.id:o;if(s!==o){const a=this.owner.getLaneById(s);if(a&&a!==this)throw new Error(`Lane "${s}" already exists`)}I(this.data,t),i&&(this.isImplicit=!1),s!==o&&(this.id=s);const r=ni(v(t,"article"));return this._resolveFromData(),s!==o&&this.owner._handleLaneIdChange(this,o),r.styleChanged&&!n&&this.owner._refreshArticlesForLane(this,{refreshStyles:!0}),this.owner._handleLaneChange({requestRedraw:!e}),{articleImpact:r,idChanged:s!==o,laneId:this.id}},Z.prototype.setOption=function(t,e){if(typeof t=="string"){const i=ai(t);if(typeof e=="undefined")return v(this.data,i);t=ut(i,e)}this._applyOption(t)},Z.prototype.hide=function(){this.setOption("visibility","hidden")},Z.prototype.show=function(){this.setOption("visibility","visible")},Z.prototype.moveToIndex=function(t){return this.owner.moveLaneToIndex(this,t)},Z.prototype.moveBefore=function(t){return this.owner.moveLaneBefore(this,t)},Z.prototype.moveAfter=function(t){return this.owner.moveLaneAfter(this,t)},Z.prototype.moveUp=function(){return this.owner.moveLaneUp(this)},Z.prototype.moveDown=function(){return this.owner.moveLaneDown(this)},Z.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return v(this.style,t);t=ut(t,e)}this.data.style=I(this.data.style||{},t),this._resolveFromData(),this.owner._handleLaneChange({requestRedraw:!0,refreshOrder:!1})},Object.defineProperty(Z.prototype,"visibility",{get(){const t=this&&this.data?this.data.visibility:void 0;if(typeof t=="undefined")return"visible";const e=Et(t,this,this);return e==="visible"||e==="hidden"?e:(P.warn("Invalid Lane.visibility value; expected 'visible'|'hidden'. Defaulting to 'visible'",{laneId:this&&this.id,value:e}),"visible")},set(t){this.data||(this.data={}),this.data.visibility=t},enumerable:!0,configurable:!1});function ft(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.title="",this.style={},this.period={from:null,to:null,isToPresent:!1}}ft.prototype.setupByReceivedData=function(t){this.data=ct({},t),this.title=v(t,"title")||"",this.style=v(t,"style")||{},this._setupPeriod(t),this.isDataLoaded=!0},ft.prototype._setupPeriod=function(t){const e=new y(parseInt(v(t,"from.year")),parseInt(v(t,"from.month")),parseInt(v(t,"from.day")));this.owner.getDmyFromInput(e);const i=parseInt(v(t,"from.precision")),n=v(t,"isToPresent"),o=n===!0||n===1;let s,r;o?s=y.now():C(t,"to")?(s=new y(parseInt(v(t,"to.year")),parseInt(v(t,"to.month")),parseInt(v(t,"to.day"))),this.owner.getDmyFromInput(s),r=parseInt(v(t,"to.precision"))):(s=e,r=i);const a=y.CreateAsStartOfPeriod(e,i),l=y.CreateAsEndOfPeriod(s,r);this.period={from:a,to:l.getNextDay(),isToPresent:o}},ft.prototype.overlapsInclusiveWithDates=function(t,e){return!(this.period.from.isAfter(e)||t.isAfter(this.period.to))},ft.prototype.setOption=function(t,e){let i=!1;if(typeof t=="string"){if(typeof e=="undefined")return v(this.data,t);t=ut(t,e)}if(I(this.data,t),C(t,"id")&&(this.id=t.id),C(t,"title")&&(this.title=t.title),(C(t,"from")||C(t,"to")||C(t,"isToPresent"))&&(this._setupPeriod(this.data),i=!0),C(t,"style")){const n=this.owner.options.timeBand&&this.owner.options.timeBand.defaultStyle||{};this.style=I({},n,this.data.style||{})}i?this.owner.requestRedraw():this.owner.requestRedraw(this.owner.redraw)},ft.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return v(this.style,t);t=ut(t,e)}this.data.style=I(this.data.style||{},t);const i=this.owner.options.timeBand&&this.owner.options.timeBand.defaultStyle||{};this.style=I({},i,this.data.style||{}),this.owner.requestRedraw()},Object.defineProperty(ft.prototype,"visibility",{get(){const t=this&&this.data?this.data.visibility:void 0;if(typeof t=="undefined")return"visible";const e=Et(t,this,this);return e==="visible"||e==="hidden"?e:(P.warn("Invalid TimeBand.visibility value; expected 'visible'|'hidden'. Defaulting to 'visible'",{bandId:this&&this.id,value:e}),"visible")},set(t){this.data||(this.data={}),this.data.visibility=t},enumerable:!0,configurable:!1});function vn(t,e,i){if(i>=t.length){let n=i-t.length;for(;n--+1;)t.push(void 0)}return t.splice(i,0,t.splice(e,1)[0]),t}function Ln(t,e){if(t.length===0)return-1;let i=0,n=t[0][e];for(let o=1;o<t.length;o++)t[o][e]<n&&(n=t[o][e],i=o);return i}function ci(t,e,i){return t<e?e:t>i?i:t}class An{constructor(e){this.invalidateCb=e,this.seen=new Set,this.loading=new Set,this.loaded=new Set,typeof document!="undefined"&&document.fonts&&document.fonts.addEventListener&&document.fonts.addEventListener("loadingdone",i=>{for(const n of i.fontfaces)this._notifyFamily(n.family)})}use(e){!e||this.loading.has(e)||this.loaded.has(e)||(this.seen.add(e),typeof document!="undefined"&&document.fonts&&document.fonts.load&&(this.loading.add(e),document.fonts.load(e).then(()=>{this.loading.delete(e),this.loaded.add(e),this.invalidateCb(e)}).catch(i=>{P.warn("[FontWatcher] Font load failed:",e,i),this.loading.delete(e)})))}_notifyFamily(e){for(const i of this.seen)i.includes(e)&&(this.loading.delete(i),this.loaded.add(i),this.invalidateCb(i))}}const In=64*1024*1024,Cn=new Set(["square","circle"]),Sn=new Set(["auto","prefer-bitmap","bitmap","prefer-img","img"]);function bt(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function j(t){return Math.max(1,Math.floor(t||0))}class Tn{constructor(e={}){const{maxConcurrent:i=6,maxCacheBytes:n,requireCORS:o=!1,decodeMode:s="auto"}=e;this.maxConcurrent=Math.max(1,i|0),this.requireCORS=!!o;let r;typeof n=="number"?r=Number.isFinite(n)?Math.max(0,n):1/0:r=In,this.maxCacheBytes=r;let a=typeof s=="string"?s.toLowerCase():"auto";Sn.has(a)||(a="auto"),this.decodeMode=a,this.queue=[],this.active=0,this.cache=new Map,this.totalBytes=0,this.inflight=new Map}enqueue(e,i,n,o={}){if(!e||!i||typeof n!="function")return()=>{};const s=typeof o.shape=="string"?o.shape.toLowerCase():"natural",r={key:e,url:i,onReady:n,options:{targetW:bt(o.targetW)?o.targetW:null,targetH:bt(o.targetH)?o.targetH:null,shape:s,article:o.article||null},cancelled:!1,delivered:!1},a=this.cache.get(e);if(a){const h=this._acquire(a,r.options.article);r.delivered=!0;try{n(a.image,a.tainted,a.kind,a.close,h)}catch(c){throw h({keepState:!0,skipRedraw:!0}),c}return()=>{}}const l=this.inflight.get(e);return l?l.requests.push(r):r.options.article&&r.options.article.isInView?this.queue.unshift(r):this.queue.push(r),this._pump(),()=>this._cancel(r)}_cancel(e){var n;if(!e||e.cancelled||e.delivered)return;e.cancelled=!0;const i=this.inflight.get(e.key);if(i){const o=i.requests.indexOf(e);if(o!==-1&&i.requests.splice(o,1),i.requests.length===0)try{(n=i.controller)==null||n.abort()}catch(s){}}else{const o=this.queue.indexOf(e);o!==-1&&this.queue.splice(o,1)}}_pump(){if(!(this.active>=this.maxConcurrent))for(;this.active<this.maxConcurrent&&this.queue.length;){const e=this.queue.shift();if(!e||e.cancelled)continue;const i=e.options&&e.options.article;if(i&&i.isInRange===!1){e.cancelled=!0;try{i._pendingImageKey===e.key&&(i._pendingImageKey=null,typeof i._imageCancel=="function"&&(i._imageCancel=null))}catch(o){}continue}if(this.cache.has(e.key)){this._serveFromCache(e);continue}const n=this.inflight.get(e.key);if(n){n.requests.push(e);continue}this._startLoad(e)}}_serveFromCache(e){const i=this.cache.get(e.key);if(!i||e.cancelled)return;const n=this._acquire(i,e.options.article);e.delivered=!0;try{e.onReady(i.image,i.tainted,i.kind,i.close,n)}catch(o){throw n({keepState:!0,skipRedraw:!0}),o}}_startLoad(e){const i=typeof AbortController!="undefined"?new AbortController:null,n={requests:[e],controller:i};this.inflight.set(e.key,n),this.active++;const o=i?i.signal:void 0,s=this._loadResource(e,o);n.promise=s,s.then(r=>{if(!r)return;const a=this.cache.get(e.key);a&&this._evictEntry(e.key,a),r.key=e.key,r.refs=0,r.articles=new Set,r.lastUsed=this._now(),this.cache.set(e.key,r),this.totalBytes+=r.bytes||0;const l=n.requests.slice();for(const h of l){if(!h||h.cancelled)continue;const c=this._acquire(r,h.options.article);h.delivered=!0;try{h.onReady(r.image,r.tainted,r.kind,r.close,c)}catch(d){throw c({keepState:!0,skipRedraw:!0}),d}}this._trimCache()}).catch(()=>{}).finally(()=>{this.inflight.delete(e.key),this.active=Math.max(0,this.active-1),this._pump()})}_acquire(e,i){e.refs=(e.refs||0)+1,e.lastUsed=this._now(),i&&e.articles.add(i);let n=!1;const o=(s={})=>{n||(n=!0,this._releaseInternal(e.key,i,s))};return o._key=e.key,i&&(o._article=i),o}_releaseInternal(e,i,n={}){const o=this.cache.get(e);o&&(o.refs>0&&(o.refs-=1),o.lastUsed=this._now(),i&&o.articles instanceof Set&&o.articles.delete(i),this._dropArticleState(i,e,n),this._trimCache())}_dropArticleState(e,i,n){if(!e||!i)return;const o=!!n.keepState,s=!!n.skipRedraw;if(!o&&e._loadedImageKey===i){if(e.imageLoaded=!1,e.image=null,e._loadedImageKey=null,typeof e._cacheBucket=="function")try{const a=e._cacheBucket(),l=`imageRaster:${i}`;a&&Object.prototype.hasOwnProperty.call(a,l)&&delete a[l]}catch(a){}if(typeof e.updateCachedSize=="function")try{e.updateCachedSize()}catch(a){}const r=e.owner;if(!s&&r&&typeof r.requestRedraw=="function")try{r.requestRedraw()}catch(a){}}e._closeImage&&e._closeImage._key===i&&(e._closeImage=null)}_trimCache(){if(!Number.isFinite(this.maxCacheBytes)||this.totalBytes<=this.maxCacheBytes)return;const e=[];for(const[i,n]of this.cache.entries())n&&e.push({key:i,entry:n});e.sort((i,n)=>{const o=typeof i.entry.lastUsed=="number"?i.entry.lastUsed:0,s=typeof n.entry.lastUsed=="number"?n.entry.lastUsed:0;return o-s});for(const{key:i,entry:n}of e){if(this.totalBytes<=this.maxCacheBytes)break;n.refs>0||this._evictEntry(i,n)}}_evictEntry(e,i){if(this.cache.has(e)&&(this.cache.delete(e),this.totalBytes=Math.max(0,this.totalBytes-(i.bytes||0)),i&&typeof i.close=="function"))try{i.close()}catch(n){}}async _loadResource(e,i){if(!e||e.cancelled)return null;const n=this.decodeMode,o=typeof createImageBitmap=="function",s=async a=>{if(!o){if(a)throw new Error("ImageBitmap not supported");return null}try{return await this._loadViaFetch(e,i)}catch(l){if(a)throw l}try{return await this._loadViaImageElement(e,!0)}catch(l){if(a)throw l;return null}},r=async a=>{try{return await this._loadViaImageElement(e,!1)}catch(l){if(!a)throw l;return await s(!1)}};switch(n){case"bitmap":return await s(!0);case"prefer-bitmap":case"auto":{const a=await s(!1);return a||await r(!1)}case"prefer-img":{const a=await r(!0);return a||await s(!1)}case"img":return await r(!1);default:{const a=await s(!1);return a||await r(!1)}}}async _loadViaFetch(e,i){const n={signal:i,mode:"cors",credentials:this.requireCORS?"same-origin":"omit"},o=await fetch(e.url,n);if(!o.ok)throw new Error("image fetch failed");const s=await o.blob(),r=await createImageBitmap(s),a=this._computeTransform(e.options,r.width,r.height);let l=r;if(a.needsCrop||a.needsResize){const h=a.sw,c=a.sh,d={};a.resizeWidth&&(d.resizeWidth=a.resizeWidth),a.resizeHeight&&(d.resizeHeight=a.resizeHeight),l=await createImageBitmap(r,a.sx,a.sy,h,c,d);try{r.close()}catch(g){}}return this._buildEntryFromBitmap(l,!1)}async _loadViaImageElement(e,i){const n=await this._createImageElement(e.url),o=j(n.naturalWidth||n.width||0),s=j(n.naturalHeight||n.height||0),r=e.options.shape||"natural",a=this._computeTransform(e.options,o,s);if(!i&&r==="natural"&&(a.needsResize=!1,a.resizeWidth=null,a.resizeHeight=null),i&&typeof createImageBitmap=="function"){const l={};a.resizeWidth&&(l.resizeWidth=a.resizeWidth),a.resizeHeight&&(l.resizeHeight=a.resizeHeight);const h=await createImageBitmap(n,a.sx,a.sy,a.sw,a.sh,l);return this._buildEntryFromBitmap(h,!this.requireCORS)}if(a.needsCrop||a.needsResize){const l=this._drawToCanvas(n,a);return this._buildEntryFromCanvas(l,!this.requireCORS)}return{image:n,kind:"img",tainted:!this.requireCORS,close:()=>{},bytes:this._estimateBytes(o,s)}}_drawToCanvas(e,i){let n=i.resizeWidth!=null?i.resizeWidth:i.sw,o=i.resizeHeight!=null?i.resizeHeight:i.sh;if(i.resizeWidth!=null&&i.resizeHeight==null&&i.sw>0){const a=i.resizeWidth/i.sw;o=Math.max(1,Math.round(i.sh*a))}else if(i.resizeHeight!=null&&i.resizeWidth==null&&i.sh>0){const a=i.resizeHeight/i.sh;n=Math.max(1,Math.round(i.sw*a))}n=Math.max(1,Math.round(n)),o=Math.max(1,Math.round(o));const s=this._createCanvas(n,o),r=s.getContext&&s.getContext("2d");return r&&r.drawImage(e,i.sx,i.sy,i.sw,i.sh,0,0,n,o),s}_createCanvas(e,i){const n=j(e),o=j(i);if(typeof document!="undefined"&&typeof document.createElement=="function"){const s=document.createElement("canvas");return s.width=n,s.height=o,s}return typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(n,o):{width:n,height:o,getContext:()=>null}}_buildEntryFromBitmap(e,i){return{image:e,kind:"bitmap",tainted:i,close:()=>{try{e.close()}catch(o){}},bytes:this._estimateBytes(e.width,e.height)}}_buildEntryFromCanvas(e,i){return{image:e,kind:"canvas",tainted:i,close:()=>{if(typeof e.close=="function")try{e.close()}catch(o){}},bytes:this._estimateBytes(e.width,e.height)}}_computeTransform(e,i,n){const o={sx:0,sy:0,sw:j(i),sh:j(n),resizeWidth:null,resizeHeight:null,needsCrop:!1,needsResize:!1},s=e.shape||"natural";if(Cn.has(s)){o.sw!==o.sh&&(o.sw>o.sh?(o.sx=Math.floor((o.sw-o.sh)/2),o.sw=o.sh):(o.sy=Math.floor((o.sh-o.sw)/2),o.sh=o.sw),o.needsCrop=!0);const r=e.targetW||e.targetH;if(bt(r)){const a=j(r);o.resizeWidth=a,o.resizeHeight=a,o.needsResize=!0}}else{const r=e.targetW,a=e.targetH,l=o.sw,h=o.sh,c=d=>{if(!Number.isFinite(d)||d<=0)return;const g=j(l*d),f=j(h*d);g===l&&f===h||(o.resizeWidth=g,o.resizeHeight=f,o.needsResize=!0)};if(bt(r)&&bt(a)){const d=Math.min(r/l,a/h);c(d)}else bt(r)?c(r/l):bt(a)&&c(a/h)}return o.resizeWidth!=null&&o.resizeHeight==null?o.resizeHeight=j(o.sh):o.resizeHeight!=null&&o.resizeWidth==null&&(o.resizeWidth=j(o.sw)),o}_estimateBytes(e,i){return j(e)*j(i)*4}_now(){return typeof performance!="undefined"&&typeof performance.now=="function"?performance.now():Date.now()}_createImageElement(e){return new Promise((i,n)=>{const o=new Image;this.requireCORS&&(o.crossOrigin="anonymous"),o.decoding="async",o.fetchPriority="low",o.onload=()=>i(o),o.onerror=()=>n(new Error("image load error")),o.src=e,typeof o.decode=="function"&&o.decode().then(()=>i(o)).catch(()=>{})})}}class k{constructor(e,i){this.owner=e,this.zoomOptions=i,this.zoom=0,this.startToken=null,this.unit=K,this.unitSizeInPixels=100,this.unitLengthInYears=1,this.zoomChangedHandlers=[],this.yearPrefix={minor:!1,major:!1},this.unitLevels=[]}}k.prototype.getUnitSizeInPixelsForZoom=function(t){const e=this.zoomOptions.ratio,i=this.unitLevels[this.unit],n=i.zoomStart;return i.startUnitSize*Math.pow(e,t-n)},k.prototype.getChangePoint=function(t){return this.unitLevels[this.unit].zoomStart},k.prototype.getUnitFromZoom=function(t){const e=this.unitLevels;for(let i=e.length-1;i>=0;i--)if(t>=e[i].zoomStart)return i;throw new Error(`Zoom ${t} is out of range`)},k.prototype.getDateLabelFormatOptions=function(t){t=t===st?"major":"minor";const e=this.owner.options.style.dateLabel[t];return{thousandsSeparator:e.thousandsSeparator,bceText:e.bceText,yearPrefix:this.yearPrefix[t]}},k.prototype.createYearToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels};let i=t.year;const n=i===0;i<=0&&(i=-i+1);const o=this.unitLengthInYears,s=this.unitLevels[this.unit];return i%(o*10)===0||n?(e.label=t.format("YYYY",this.getDateLabelFormatOptions(st)),e.type=st):(e.type=B,this.zoom<s.zoomHideMinorLabels&&(e.label=t.format("YYYY",this.getDateLabelFormatOptions(B)))),e},k.prototype.createMonthToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels},i=this.unitLevels[J];return t.month===1?(e.label=t.format("YYYY",this.getDateLabelFormatOptions(st)),e.type=st):(e.type=B,this.zoom<i.zoomHideMinorLabels&&(e.label=t.format("MMM"))),e},k.prototype.createDayToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels},i=this.unitLevels[K];return t.day===1?(e.label=t.format("MMM YYYY",this.getDateLabelFormatOptions(st)),e.type=st):(e.type=B,this.zoom<i.zoomHideMinorLabels&&(e.label=t.format("D"))),e},k.prototype.addZoomChangedHandler=function(t,e){this.zoomChangedHandlers.push({callback:t,context:e||this})},k.prototype.notifyZoomChanged=function(){for(let t=0;t<this.zoomChangedHandlers.length;t++)this.zoomChangedHandlers[t].callback.call(this.zoomChangedHandlers[t].context)},k.prototype.setZoom=function(t){const e=this.zoom;let i=parseFloat(t.toFixed(4));i<this.zoomOptions.minimum&&(i=this.zoomOptions.minimum),i>this.zoomOptions.maximum&&(i=this.zoomOptions.maximum),this.zoom=i,this.unit=this.getUnitFromZoom(this.zoom),this.unitSizeInPixels=this.getUnitSizeInPixelsForZoom(this.zoom);let n=0;if(this.unit>=rt){const o=this.unit-rt;n=Math.pow(10,o)}if(this.unitLengthInYears=n,this.setCurrentYearPrefixes(),this.owner._isInitialized){const o=this.zoom-e;this.owner.trigger("zoom",{zoom:this.zoom,zoomDelta:o})}return this.owner._emitTimelineStateChange(),this.notifyZoomChanged(),this.zoom},k.prototype.getPixelsBetween=function(t,e){const i=this.unit;return i<=K?t.getDaysTo(e)*this.unitSizeInPixels:i===J?t.getMonthsTo(e)*this.unitSizeInPixels:t.getYearsTo(e)*this.unitSizeInPixels/this.unitLengthInYears},k.prototype.setStartToken=function(t){return this.startToken=t},k.prototype.setStartDate=function(t){let e=0;switch(t.year<0&&(e=1),this.unit){case K:return this.startToken=this.createDayToken(t),0;case J:return this.startToken=this.createMonthToken(new y(t.year,t.month,1)),this.unitSizeInPixels/30.44*(this.startToken.value.day-t.day);case rt:return this.startToken=this.createYearToken(new y(t.year,1,1)),this.unitSizeInPixels/365.2422*((this.startToken.value.month-t.month)*30.44+(this.startToken.value.day-t.day));default:{const i=this.unitLengthInYears;return this.startToken=this.createYearToken(new y(Math.floor(t.year/i)*i+e,1,1)),this.unitSizeInPixels/(365.2422*i)*((this.startToken.value.year-t.year)*365.2422+(this.startToken.value.month-t.month)*30.44+(this.startToken.value.day-t.day))}}},k.prototype.getStartTokenCloned=function(){switch(this.startToken.unit){case K:return this.createDayToken(this.startToken.value);case J:return this.createMonthToken(this.startToken.value);default:return this.createYearToken(this.startToken.value)}},k.prototype.getNext=function(t){switch(t.unit){case K:return this.createDayToken(t.value.getNextDay());case J:return this.createMonthToken(t.value.getNextMonth());case rt:return this.createYearToken(t.value.addYears(1));default:{const e=this.unitLengthInYears;return this.createYearToken(t.value.addYears(t.value.year===-(e-1)?e-1:e))}}},k.prototype.getPrevious=function(t){switch(t.unit){case K:return this.createDayToken(t.value.getPreviousDay());case J:return this.createMonthToken(t.value.getPreviousMonth());case rt:return this.createYearToken(t.value.addYears(-1));default:{const e=this.unitLengthInYears;return this.createYearToken(t.value.addYears(t.value.year===0?1-e:-e))}}},k.prototype.getPreviousNth=function(t,e){for(let i=0;i<e;i++)t=this.getPrevious(t);return t},k.prototype.zoomUnitToString=function(t){switch(t){case K:return"day";case J:return"month";case rt:return"year";case Oe:return"decade";case ke:return"century";case Ee:return"millennium";case ze:return"10 thousand years";case Ne:return"100 thousand years";case xe:return"million years";case Be:return"10 million years";case Fe:return"100 million years";case He:return"billion years";default:return"unknown"}},k.prototype.setUnitLevels=function(){this.unitLevels=[];const t=this.zoomOptions.unitSize.minimum,e=this.zoomOptions.unitSize.showMinorLabels,i=0,n=this.getZoomChangeByDistance(e,t),o=this.zoomOptions.unitSize.initial,s=this.getZoomChangeByDistance(o,t),r=i+s,a=r-n,l={startUnitSize:o,zoomStart:i,zoomHideMinorLabels:a,zoomEnd:r};this.unitLevels.push(l);const h=t*31,c=this.getZoomChangeByDistance(h,t),d=r+c,g=d-n;this.unitLevels.push({startUnitSize:h,zoomStart:r,zoomHideMinorLabels:g,zoomEnd:d});const f=t*12,m=this.getZoomChangeByDistance(f,t),b=d+m,A=b-n;this.unitLevels.push({startUnitSize:f,zoomStart:d,zoomHideMinorLabels:A,zoomEnd:b});let p,_,w=b,S,M;const F=8;for(let D=1;D<=F;D++)p=t*10,_=this.getZoomChangeByDistance(p,t),S=w+_,M=S-n,this.unitLevels.push({startUnitSize:p,zoomStart:w,zoomHideMinorLabels:M,zoomEnd:S}),w=S,D===F&&(this.zoomOptions.maximum=Math.min(this.zoomOptions.maximum,S))},k.prototype.getZoomChangeByDistance=function(t,e){const i=this.zoomOptions.ratio;return Math.log(e/t)/Math.log(i)},k.prototype.scaleDistanceByZoomChange=function(t,e){const i=this.zoomOptions.ratio;return t*Math.pow(i,e)},k.prototype.setCurrentYearPrefixes=function(){const t=["minor","major"];if(this.unit<rt){for(let n=0;n<t.length;n++)this.yearPrefix[t[n]]=!1;return}const e=this.owner.options.style.dateLabel,i={minor:this.unitLengthInYears,major:this.unitLengthInYears*10};for(let n=0;n<t.length;n++){const o=t[n],s=Object.values(e[o].yearPrefixes);this.yearPrefix[o]=!1,s.sort(function(r,a){return a.minDivision-r.minDivision});for(let r=0;r<s.length;r++){const a=s[r];if(a.minDivision<=i[o]){this.yearPrefix[o]={label:a.label,value:a.value};break}}}};const ui=["http","https","data","blob"];function Dn(t,e=ui){if(typeof t!="string")return!1;const i=t.trim(),n=i.toLowerCase();if(n.startsWith("data:"))return e.includes("data");if(n.startsWith("blob:"))return e.includes("blob");try{const o=new URL(i,typeof window!="undefined"?window.location.href:void 0);return e.includes(o.protocol.replace(":",""))}catch(o){return!1}}function Mn(t){return/^data:image\//i.test(t)}function Rn(t,e){if(!Array.isArray(e)||e.length===0)return!0;try{const i=new URL(t,typeof window!="undefined"?window.location.href:void 0),n=i.origin.toLowerCase(),o=i.hostname.toLowerCase();for(const s of e){if(typeof s!="string")continue;const r=s.trim().toLowerCase();if(r.includes("://")){try{const a=new URL(r).origin.toLowerCase();if(n===a)return!0}catch(a){}continue}if(r.startsWith("*.")&&(o===r.slice(2)||o.endsWith(`.${r.slice(2)}`))||r.startsWith(".")&&(o===r.slice(1)||o.endsWith(r))||o===r||o.endsWith(`.${r}`))return!0}return!1}catch(i){return!0}}function Pn(t,e={}){if(typeof t!="string")return null;const i=Array.isArray(e.allowedSchemes)&&e.allowedSchemes.length?e.allowedSchemes:ui;if(!Dn(t,i))return null;const n=t.trim().toLowerCase();return n.startsWith("data:")?Mn(n)?t:null:Rn(t,e.allowedOrigins)?t:null}function On(){const t=typeof globalThis!="undefined"&&globalThis.devicePixelRatio||1;return typeof t!="number"||!isFinite(t)||t<=0?1:t}function kn(t){const e=t&&t.dprMode==="native",i=On(),n=e?i:Math.ceil(i),o=t&&typeof t.dpr=="number"&&isFinite(t.dpr)&&t.dpr>0?t.dpr:n,s=t&&typeof t.maxDpr=="number"&&isFinite(t.maxDpr)&&t.maxDpr>0?t.maxDpr:4;return Math.min(s,Math.max(1,o))}function ye(t,e,i,n,o){const s=kn(o),r=Math.max(1,Math.round(e!=null?e:t.clientWidth||t.width||1)),a=Math.max(1,Math.round(i!=null?i:t.clientHeight||t.height||1));t.style&&(t.style.width!==`${r}px`&&(t.style.width=`${r}px`),t.style.height!==`${a}px`&&(t.style.height=`${a}px`));const l=r*s,h=a*s;t.width!==l&&(t.width=l),t.height!==h&&(t.height=h);const c=n||t.getContext&&t.getContext("2d")||null;return c&&typeof c.setTransform=="function"&&c.setTransform(s,0,0,s,0,0),t._dpr=s,s}function di(t,e){const i=t.canvas._dpr||1;t.shadowOffsetX=e.x*i,t.shadowOffsetY=e.y*i,t.shadowBlur=e.amount*i,t.shadowColor=e.color}function En(t){return t instanceof HTMLCanvasElement||t&&t.nodeName==="CANVAS"}function zn({width:t,height:e,className:i,style:n}={}){const o=document.createElement("canvas");return t!=null&&(o.width=t),e!=null&&(o.height=e),i&&(o.className=i),o.style.touchAction="none",n&&Object.assign(o.style,n),o}function fi(t,e){return t!=null&&t.append?t.append(e):t.appendChild(e),e}function Nn(t){const e=t.getBoundingClientRect();return{left:e.left,top:e.top}}function xn(){document.selection?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()}const Q=typeof window!="undefined"&&"onpointerdown"in window,Bn=750,gi=Q?{down:"pointerdown",move:"pointermove",up:"pointerup",cancel:"pointercancel",leave:"pointerleave"}:{down:"mousedown",move:"mousemove",up:"mouseup",cancel:"mouseleave",leave:"mouseleave"};function $t(t,e,i,n){const o=gi[e]||e;t.addEventListener(o,i,n),Q||(e==="down"&&t.addEventListener("touchstart",i,n),e==="move"&&t.addEventListener("touchmove",i,n),e==="up"&&(t.addEventListener("touchend",i,n),t.addEventListener("touchcancel",i,n)))}function Xt(t,e,i,n){const o=gi[e]||e;t.removeEventListener(o,i,n),Q||(e==="down"&&t.removeEventListener("touchstart",i,n),e==="move"&&t.removeEventListener("touchmove",i,n),e==="up"&&(t.removeEventListener("touchend",i,n),t.removeEventListener("touchcancel",i,n)))}function zt(t){if(t.touches&&t.touches[0]){const e=t.touches[0];return{x:e.clientX,y:e.clientY}}if(t.changedTouches&&t.changedTouches[0]){const e=t.changedTouches[0];return{x:e.clientX,y:e.clientY}}return{x:t.clientX,y:t.clientY}}class Fn{constructor(e,{onStart:i,onMove:n,onEnd:o}={}){this.target=e,this.onStart=i,this.onMove=n,this.onEnd=o,this.pointers=new Map,this.lastTouchTime=0,this._handleDown=this._handleDown.bind(this),this._handleMove=this._handleMove.bind(this),this._handleUp=this._handleUp.bind(this),$t(e,"down",this._handleDown),$t(window,"move",this._handleMove),$t(window,"up",this._handleUp),Q&&$t(window,"cancel",this._handleUp)}destroy(){Xt(this.target,"down",this._handleDown),Xt(window,"move",this._handleMove),Xt(window,"up",this._handleUp),Q&&Xt(window,"cancel",this._handleUp),this.pointers.clear()}_handleDown(e){if(!Q){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}Q?this._addOrUpdatePointer(e):e.touches?this._syncTouches(e):this.pointers.set("mouse",{id:"mouse",x:e.clientX,y:e.clientY,type:"mouse"}),this.onStart&&this.onStart(e,this)}_handleMove(e){if(!Q){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}if(Q)this.pointers.has(this._getPointerId(e))&&this._addOrUpdatePointer(e);else if(e.touches)this._syncTouches(e);else if(this.pointers.has("mouse")){const i=this.pointers.get("mouse");i.x=e.clientX,i.y=e.clientY}this.onMove&&this.onMove(e,this)}_handleUp(e){if(!Q){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}if(Q)this.pointers.delete(this._getPointerId(e));else if(e.changedTouches){for(const i of e.changedTouches)this.pointers.delete(i.identifier);(!e.touches||e.touches.length===0)&&this.pointers.delete("mouse")}else this.pointers.delete("mouse");this.onEnd&&this.onEnd(e,this)}_getPointerId(e){return e.pointerId!=null?e.pointerId:"mouse"}_isTouchEvent(e){return!!(e.touches||e.changedTouches)}_shouldIgnoreMouseEvent(e){return!this._isTouchEvent(e)&&Date.now()-this.lastTouchTime<Bn}_addOrUpdatePointer(e){this.pointers.set(this._getPointerId(e),{id:this._getPointerId(e),x:e.clientX,y:e.clientY,type:e.pointerType||"mouse"})}_syncTouches(e){this.pointers.clear();for(const i of e.touches)this.pointers.set(i.identifier,{id:i.identifier,x:i.clientX,y:i.clientY,type:"touch"})}get list(){return Array.from(this.pointers.values())}}function Hn(t){return t.list[0]||null}function mi(t){const e=t.list;return e.length===0?null:e.length===1?{x:e[0].x,y:e[0].y}:{x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2}}function pi(t){const e=t.list;if(e.length<2)return 0;const i=e[0].x-e[1].x,n=e[0].y-e[1].y;return Math.hypot(i,n)}function u(t,e){const i=li(e);this.options=I({},hi,i),En(t)?this.canvas=t:(this.canvas=zn(),fi(t,this.canvas)),this.canvas&&this.canvas.style&&(this.options.width!=null&&(this.canvas.style.width=`${this.options.width}px`),this.options.height!=null&&(this.canvas.style.height=`${this.options.height}px`)),this.canvasContext=this.canvas.getContext("2d"),this.canvasDpr=ye(this.canvas,this.options.width,this.options.height,this.canvasContext,this.options.canvas),this.fontWatcher=new An(l=>{this.forLoadedArticles(h=>h.invalidateCaches()),this.requestRedraw()});const n=this.canvasContext,o=n.measureText.bind(n);n.measureText=l=>(this.fontWatcher.use(n.font),o(l)),this.width=this.canvas.clientWidth||this.options.width,this.top=this.options.height-this._getEffectiveVerticalOffset(),this.repositionWindow=0,this.uniqueId=`tl${new Date().getTime()}`,this.title="My timeline",this.ownerId=void 0,this.cursor="default",this.mouseoverArticle=null,this.isDragging=!1,this.draggingArticle=null,this.dragStartX=0,this.isPanning=!1,this.isPinching=!1,this.isAnimating=!1,this.isAnimatingArticles=!1,this.isCustomAnimating=!1,this.animation={redrawFunction:!1,defaultRedrawFunction:this.repositionRedraw,dragRedrawFunction:this.defaultRedraw,pan:null,zoom:null},this.lastAnimatingArticle={id:null,endTime:0},this.topRow=0,this.loadingHttpRequests=[],this.articles=[],this.lanes=[],this.timeBands=[],this._runtimeArticleOptions={},this.redrawRequests={default:!1,reposition:!1},this._initialiseLaneHost(t),this.handlers={},this.options.on&&this.onMultiple(this.options.on),this._isInitialized=!1;const s=this.options.zoom,r=this.getDmyFromInput(new y(this.options.initialDate));this.timescaleManager=new k(this,s),this.timescaleManager.setUnitLevels(),this.timescaleManager.addZoomChangedHandler(this.zoomChanged,this),this.timescaleManager.setZoom(s.initial),this.timescaleManager.setStartDate(r),this.options.enableUserControl&&(this.enableZoomByWheel(),this.enableDragging()),this.groups={level:-1,periods:[]};const a=this.options.image||{};this.imageLoader=new Tn({maxConcurrent:a.maxConcurrent,maxCacheBytes:a.maxCacheBytes,requireCORS:a.requireCORS,decodeMode:a.decodeMode}),this.options.lane&&Array.isArray(this.options.lane.data)&&this.options.lane.data.length>0&&this.addLanes(this.options.lane.data),this.options.timeBand&&Array.isArray(this.options.timeBand.data)&&this.options.timeBand.data.length>0&&typeof this.addTimeBands=="function"&&this.addTimeBands(this.options.timeBand.data),this.requestRedraw(),this._isInitialized=!0}u.prototype.setTitle=function(t){this.title=t,this._emitTimelineStateChange()},u.prototype.getWidth=function(){return this.canvas.clientWidth||this.options.width},u.prototype.getCanvasDpr=function(){return this.canvasDpr||1},u.prototype.isInVicinity=function(t,e,i){if(e=Et(e,this,t,i),typeof e=="boolean")return e;const n=i||this.getRelativePosition(t);return n.top>this.top-e.up&&n.top<this.top+e.down},u.prototype.getPixel=function(t,e){let i;const n=t.toKeyString();if(e){if(i=e.tokens,Object.prototype.hasOwnProperty.call(i,n))return i[n]}else i={};const o=this.repositionWindow,s=this.timescaleManager.startToken;return i[n]=this.timescaleManager.getPixelsBetween(s.value,t)+o},u.prototype.getRelativePosition=function(t){const{x:e,y:i}=zt(t),n=this.canvas.getBoundingClientRect();return{left:e-n.left,top:i-n.top}},u.prototype.updateCursor=function(t){const e=this.cursor,i=this.cursor=this.getCursor(t);e!==i&&(this.canvas.style.cursor=i)},u.prototype.getCursor=function(t){const e=this.options.style.cursor;if(this.isDragging)return e.timeline.dragging;const i=this.getRelativePosition(t);return this.draggingArticle?this.draggingArticle.getCursor(i):!this.options.disableBranding&&(this._isInsideHistropediaJSLink(i)||this._isInsideTermsLink(i))?e.clickable:this.mouseoverArticle!==null?this.mouseoverArticle.getCursor(i):e.timeline.hover},u.prototype.onRedraw=function(t){P.warn('DEPRECATION WARNING: timeline.onRedraw(handler) is deprecated. Use timeline.on("timeline-render-end", handler) instead.'),typeof this.on=="function"&&this.on("timeline-render-end",t)},u.prototype.zoomChanged=function(){let t;this.currentDensitySetting&&(t=this.currentDensitySetting.region),this.updateCurrentDensitySetting(),t!==this.currentDensitySetting.region&&this.updateArticlesGroupIndex()},u.prototype.updateCurrentDensitySetting=function(){for(let t=0;t<ce.length;t++){const e=ce[t];if(this.timescaleManager.zoom>=e.zoom.from&&this.timescaleManager.zoom<e.zoom.to){this.currentDensitySetting=e;break}}},u.prototype.calculateEndToken=function(){const t=this.getWidth();let e=this.repositionWindow,n=this.timescaleManager.startToken,o;do o=n,n=this.timescaleManager.getNext(n),e+=n.length;while(e<t);return o},u.prototype.getDensityPick=function(t=this.options.article.density){switch(t){case Ge:return this.currentDensitySetting.low;case qe:return this.currentDensitySetting.medium;case $e:return this.currentDensitySetting.high;case he:return this.currentDensitySetting.all}P.error(`Unknown density selector:${val}`)},u.prototype.invoke=function(t,e,i){Object.prototype.hasOwnProperty.call(e,t)&&e[t].call(this,i)},u.prototype.forLoadedArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&t.call(this,i)}},u.prototype.forVisibleArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&i.isVisible&&t.call(this,i)}},u.prototype.forInRangeArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&(i.isInRange||i.isFading)&&t.call(this,i)}},u.prototype.enqueueImageLoad=function(t){let e=v(t.data,"imageUrl");if(!e){if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(l){}t.image=null,t.imageLoaded=!1,t._closeImage=null,t._loadedImageKey=null,t._pendingImageKey=null;return}const{sanitizer:i,customSanitizer:n}=this.options.image;if(typeof n=="function")try{e=n(e,i)}catch(l){e=null}else e=Pn(e,i);if(!e){if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(l){}t.image=null,t.imageLoaded=!1,t._closeImage=null,t._loadedImageKey=null,t._pendingImageKey=null;return}const o=this._getArticleImageTargetSpec(t),s=o&&Number.isFinite(o.dpr)&&o.dpr>0?Math.round(Math.max(1,o.dpr)*1e3)/1e3:1,r=`img:${e}:${o.layout}:${o.shape}:${o.targetW||0}x${o.targetH||0}@${s}`;if(t._loadedImageKey===r&&t.imageLoaded&&t.image||t._pendingImageKey===r&&typeof t._imageCancel=="function")return;if(t._pendingImageKey&&t._pendingImageKey!==r&&typeof t._imageCancel=="function"){try{t._imageCancel()}catch(l){}t._imageCancel=null}t.imageLoaded&&t.image||(t.imageLoaded=!1),t._pendingImageKey=r;const a=this.imageLoader.enqueue(r,e,(l,h,c,d,g)=>{if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(m){}let f=null;typeof g=="function"?f=g:typeof d=="function"&&(f=function(){try{d()}catch(m){}}),t.image=l,t.imageLoaded=!0,t._loadedImageKey=r,t._pendingImageKey=null,t._imageCancel=null,t._closeImage=f,t._closeImage&&t._closeImage._key==null&&typeof g=="function"&&(t._closeImage._key=r,t._closeImage._article=t),typeof t.updateCachedSize=="function"&&t.updateCachedSize(),this.requestRedraw(this.redraw)},{targetW:o.targetW,targetH:o.targetH,shape:o.shape,article:t});t._imageCancel=a},u.prototype._getArticleImageTargetSpec=function(t){const e=t._getCurrentCardLayoutName(),i=t._getCurrentStyle(),n=i&&i.image?i.image:{},o=n.shape||"square";let s=null,r=null;if(e==="landscape"){const g=n.margin||0,f=Math.max(1,(i.height||0)-g*2);s=f,r=f}else if(e==="portrait"){const g=n.margin||0,m=Math.max(1,(i.width||0)-0-g*2);o==="square"||o==="circle"?(s=m,r=m):s=m}else i&&typeof i.width=="number"&&(s=i.width);const a=typeof this.getCanvasDpr=="function"?this.getCanvasDpr():Number(this.canvasDpr),l=Number.isFinite(a)&&a>0?a:1,h=g=>typeof g!="number"||!Number.isFinite(g)||g<=0?null:Math.max(1,Math.round(g*l)),c=h(s),d=h(r);return{layout:e,targetW:c,targetH:d,shape:o,dpr:l}},u.prototype.setOption=function(t,e){if(typeof t=="string"){const l=ai(t),h=v(this.options,l);if(typeof e=="undefined")return h;t=ut(l,e)}t=li(t),I(this.options,t);const i=t.width||t.height;i&&this.setSize(this.options.width,this.options.height);const n=C(t,"canvas.dpr")||C(t,"canvas.dprMode")||C(t,"canvas.maxDpr");!i&&n&&(this.canvasDpr=ye(this.canvas,this.options.width,this.options.height,this.canvasContext,this.options.canvas)),typeof t.verticalOffset=="number"&&(this.top=this.options.height-this._getEffectiveVerticalOffset()),(C(t,"timeBand.visible")||C(t,"timeBand.reserveSpace")||C(t,"timeBand.reserveSpacePixels"))&&(this.top=this.options.height-this._getEffectiveVerticalOffset());const s=ni(v(t,"article"));if(C(t,"timeBand.defaultStyle")&&Array.isArray(this.timeBands)&&this.timeBands.length>0){const l=this.options.timeBand&&this.options.timeBand.defaultStyle?this.options.timeBand.defaultStyle:{};for(let h=0;h<this.timeBands.length;h++){const c=this.timeBands[h],d=c&&c.data&&c.data.style?c.data.style:{};c.style=I({},l,d)}}let a={styleLaneIds:new Set};if(C(t,"lane")){const l=v(t,"lane.data");Array.isArray(l)&&(a=this.addLanes(l,{suppressArticleRefresh:!0}))}if(C(t,"lane")||s.cacheChanged){const l=s.styleChanged?"all":a.styleLaneIds.size>0?a.styleLaneIds:null;this._refreshResolvedLanesFromOptions({articleStyleScope:l})}this.requestRedraw()},u.prototype.setSize=function(t,e){this.canvas&&this.canvas.style&&(typeof t=="number"&&(this.canvas.style.width=`${t}px`),typeof e=="number"&&(this.canvas.style.height=`${e}px`)),this.options.width=t,this.options.height=e,this.canvasDpr=ye(this.canvas,t,e,this.canvasContext,this.options.canvas),typeof this._syncLaneViewportSize=="function"&&this._syncLaneViewportSize(),this.width=this.canvas.clientWidth||t,this.top=e-this._getEffectiveVerticalOffset(),this.requestRedraw()},u.prototype._getEffectiveVerticalOffset=function(){const t=this.options.verticalOffset||0,e=this.options.timeBand||{},i=Array.isArray(this.timeBands)&&this.timeBands.length>0,o=!!e.reserveSpace&&e.visible&&i&&e.reserveSpacePixels||0;return t+o},u.prototype.generateDensitySettings=function(){const t=this.timescaleManager.zoomOptions.ratio;P.log(this.timescaleManager);const e=[],i=Math.round(Math.log(.5)/Math.log(t)*100)/100;for(let n=0;n<19;n++){const o={region:n+1,zoom:{from:n*i,to:(n+1)*i},low:1,medium:2,high:3,all:25,step:{months:0,days:Math.pow(2,n)}};e.push(o)}P.log(JSON.stringify(e))};function Wn(t,e){return`${t}::${e}`}u.prototype.updateArticlesGroupIndex=function(){this.forLoadedArticles(function(t){t.groupIndex=this.calculateGroupIndex(t.period.from)})},u.prototype.updateVisibleArticlesOfGroups=function(t){if(this._isLaneLayoutActive()){this.groups={};const o=this.options.article.autoStacking.range===Vt?1:20,s=this.calculateGroupIndex(t.tokens.start)-o,r=this.calculateGroupIndex(t.tokens.end)+o,a=this._getActiveLanesForLayout();this.forLoadedArticles(function(l){l.isVisibleInGroup=!1});for(let l=0;l<a.length;l++){const h=a[l];for(let c=s;c<=r;c++){const d=Wn(h.id,c);this.groups[d]=this.getArticlesInGroup(c,s,r,h.id).map(function(g){return g.isVisibleInGroup=!0,g.id})}}return}this.groups={};const e=this.options.article.autoStacking.range===Vt?1:20,i=this.calculateGroupIndex(t.tokens.start)-e,n=this.calculateGroupIndex(t.tokens.end)+e;this.forLoadedArticles(function(o){o.isVisibleInGroup=!1});for(let o=i;o<=n;o++)this.groups[o]=this.getArticlesInGroup(o,i,n).map(function(s){return s.isVisibleInGroup=!0,s.id})};const Yn=1e7,Zn=2e7;u.prototype.getArticlesInGroup=function(t,e,i,n){function o(c){let d=c.rank;return c.isActive?d+=Zn:c.isStarred&&(d+=Yn),d}const s=typeof n!="undefined"?this.getLaneById(n):null,r=s&&s.resolvedArticleOptions?s.resolvedArticleOptions.density:this.options.article.density,a=this.getDensityPick(r),l=[];let h=0;for(let c=0;c<this.articles.length;c++){const d=this.articles[c];if(!(!d.isDataLoaded||d.isHiddenByFilter||typeof n!="undefined"&&d.laneId!==n||!(ci(d.groupIndex,e,i)===t))){if(d.effectiveRank=o(d),l.length<a){l.push(d),d.effectiveRank<l[h].effectiveRank&&(h=l.length-1);continue}d.effectiveRank>l[h].effectiveRank&&(l[h]=d,h=Ln(l,"effectiveRank"))}}return l},u.prototype.calculateGroupIndex=function(t){if(this.timescaleManager.unit>=J&&this.currentDensitySetting.step.months!==0){const i=t.year*12+(t.month-1);return Math.floor(i/this.currentDensitySetting.step.months)}const e=t.year*372+(t.month-1)*31+t.day;return this.currentDensitySetting.step.days===0?Math.floor(e/(this.currentDensitySetting.step.months*30)):Math.floor(e/this.currentDensitySetting.step.days)},u.prototype.canBeVisibleInGroup=function(t,e,i){if(t.isActive)return!0;e=e||this.timescaleManager.startToken,i=i||this.calculateEndToken();const n=this.calculateGroupIndex(e.value)-1,o=this.calculateGroupIndex(i.value)+1,s=ci(t.groupIndex,n,o);return Object.prototype.hasOwnProperty.call(this.groups,s)?this.groups[s].indexOf(t.id)>=0:!1};const Vn=64;function Un({velocity:t,friction:e,minVelocity:i,maxDuration:n,maxFrameDelta:o=Vn,shouldStop:s,onUpdate:r,onComplete:a}={}){let l=t;const h=performance.now();let c=h,d=!1;if(!Number.isFinite(l)||!Number.isFinite(e)||e<=0||!Number.isFinite(i)||i<0||!Number.isFinite(n)||n<=0)return{stop(){}};function g(){d=!0}function f(){d||(d=!0,a==null||a())}function m(b){if(d)return;if(s!=null&&s()){g();return}if(b-h>=n||Math.abs(l)<i){f();return}const A=Math.min(Math.max(b-c,0),o);if(c=b,A>0){const p=Math.exp(-e*A),_=l*(1-p)/e;l*=p,_!==0&&(r==null||r(_,l))}requestAnimationFrame(m)}return requestAnimationFrame(m),{stop:g}}u.prototype._drawBranding=function(t){this._drawCopyrightLinks(t)};const jt=117,we=22,yi=0,wi=0,Kt=8,be=0,Ct=12,Gn="HistropediaJS",bi=75,qn="Terms",$n=33,Xn=10,jn=`${Gn} | ${qn}`;u.prototype._drawCopyrightLinks=function(t){t.beginPath(),t.fillStyle="rgba(255, 255, 255, 0.8)",t.fillRect(this.width-jt-yi-Kt*2,this.top-Math.floor(this.options.style.mainLine.size/2)-we-wi-be*2,jt+Kt*2,we+be*2),t.textAlign="left",t.textBaseline="middle",t.fillStyle="#000000",t.font=`normal ${Ct}px "Helvetica Neue", Helvetica, Arial, sans-serif`;const e=this._getBrandingTextCoords();t.fillText(jn,e.left,e.top,jt+Kt)},u.prototype._getBrandingTextCoords=function(){return{left:this.width-jt-yi-Kt,top:this.top-Math.floor(this.options.style.mainLine.size/2)-we-wi+Ct-be}},u.prototype._isInsideHistropediaJSLink=function(t){const e=this._getBrandingTextCoords();return _i(t,{left:e.left,top:e.top-Ct/2,width:bi,height:Ct})},u.prototype._isInsideTermsLink=function(t){const e=this._getBrandingTextCoords();return _i(t,{left:e.left+bi+Xn,top:e.top-Ct/2,width:$n,height:Ct})};function Kn(){const t=window.open("https://js.histropedia.com","_blank","noopener,noreferrer");t&&(t.opener=null)}function Jn(){const t=window.open("https://js.histropedia.com/licence.html","_blank","noopener,noreferrer");t&&(t.opener=null)}function _i(t,e){return t.left>=e.left&&t.left<=e.left+e.width&&t.top>=e.top&&t.top<=e.top+e.height}const _e=({startToken:t,offsetX:e=0,dx:i=0,totalDx:n=0}={})=>({startToken:t,offsetX:e,dx:i,totalDx:n}),ve=({centre:t=null,scale:e=0,zoom:i=0,distance:n=0,zoomDelta:o=0,dx:s=0,totalZoomDelta:r=0,pointers:a=[]}={})=>({centre:t,scale:e,zoom:i,distance:n,zoomDelta:o,dx:s,totalZoomDelta:r,pointers:a}),Qn=({centre:t=null,zoom:e=0,zoomDelta:i=0}={})=>({centre:t,zoom:e,zoomDelta:i}),to=({viewport:t}={})=>{var n,o;if(!t)return{viewport:{x:0,y:0}};const{x:e=(n=t.left)!=null?n:0,y:i=(o=t.top)!=null?o:0}=t;return{viewport:{x:e,y:i}}},vi=100,eo=.01,io=.005,no=.004,oo=1200;function St(t,e){return Number.isFinite(t)&&t>0?t:e}function so(t,e){if(!(t!=null&&t.canvas))return!1;const i=t.canvas.ownerDocument;if(!i||typeof i.elementFromPoint!="function")return!0;const{x:n,y:o}=zt(e),s=i.elementFromPoint(n,o);if(!s)return!1;const r=t._laneViewportElement||t.canvas;return r===s||r.contains(s)}u.prototype.enableDragging=function(){const e=this,i={relativePos:null,isDoubleClick:!1,isArticleClick:!1,isArticleDoubleClick:!1,isTermsClick:!1,isHjsClick:!1,article:null,lastClick:{time:0,targetType:null,articleId:null,relativePos:null}},n={initial:{distance:0,zoom:0},centre:{},scale:1,prevActualZoom:0},o=2,s=5,r=500;function a(p,_,w=o){return Math.abs(p.left-_.left)<=w&&Math.abs(p.top-_.top)<=w}function l(p){const _=Nn(e.canvas);return{x:p.x-_.left,y:p.y-_.top}}function h(){i.relativePos=null,i.isDoubleClick=!1,i.isArticleClick=!1,i.isArticleDoubleClick=!1,i.isTermsClick=!1,i.isHjsClick=!1,i.article=null}function c(){i.lastClick.time=0,i.lastClick.targetType=null,i.lastClick.articleId=null,i.lastClick.relativePos=null}function d(){return i.isHjsClick?"branding-hjs":i.isTermsClick?"branding-terms":i.isArticleClick&&i.article?"article":"timeline"}function g(p,_){const{lastClick:w}=i,S=d();return!w.time||p-w.time>=r||w.targetType!==S?!1:S==="article"?!!i.article&&w.articleId===i.article.id:S==="timeline"?!!w.relativePos&&a(w.relativePos,_,s):!1}function f(p){i.lastClick.time=Date.now(),i.lastClick.targetType=d(),i.lastClick.articleId=i.article?i.article.id:null,i.lastClick.relativePos=p?ct({},p):null}function m(p,_){if(xn(),_.list.length>=2){h(),c(),e.isPinching||(n.centre=l(mi(_)),n.initial.distance=pi(_),n.initial.zoom=e.timescaleManager.zoom,e.isPinching=!0,n.prevActualZoom=n.initial.zoom,e.startAnimation(),e.trigger("zoom-pinch-start",ve({centre:n.centre,scale:1,distance:n.initial.distance,zoom:n.initial.zoom,zoomDelta:0,totalZoomDelta:0,pointers:[..._.list]}),p));return}h();const w=i.relativePos=e.getRelativePosition(p);e.options.disableBranding||(i.isHjsClick=e._isInsideHistropediaJSLink(w),i.isTermsClick=e._isInsideTermsLink(w));let S=!1;if(!(i.isHjsClick||i.isTermsClick))for(let F=e.articles.length-1;F>=0;F--){const D=e.articles[F];if(D.isVisible&&D.isInside(w)){i.isArticleClick=!0,i.article=D,D.isActive&&e.options.article.draggable&&(S=!0);break}}const M=Date.now();if(i.isDoubleClick=g(M,w),i.isArticleDoubleClick=i.isArticleClick&&i.isDoubleClick,S){e.draggingArticle=i.article,i.article.startDragging(w,p);return}e.draggingArticle===null&&e.isInVicinity(p,e.options.draggingVicinity,w)&&e.startDragging(p)}function b(p,_){if(e.isPinching){const w=e.timescaleManager.zoomOptions.ratio,S=n.centre.x;n.centre=l(mi(_));const M=pi(_);n.scale=M/n.initial.distance;const F=Math.log(n.scale)/Math.log(w),D=n.initial.zoom+F,q=S-n.centre.x;e.setZoomByPivotPixel(D,n.centre.x,q);const x=e.timescaleManager.zoom,X=x-n.initial.zoom,H=x-n.prevActualZoom;n.prevActualZoom=x,e.trigger("zoom-pinch",ve({centre:n.centre,scale:n.scale,distance:M,zoom:x,pointers:[..._.list],dx:q,zoomDelta:H,totalZoomDelta:X}),p)}else if(e.isDragging)e.doDrag(p);else if(e.draggingArticle!==null){const w=e.getRelativePosition(p);e.draggingArticle.dragging(w,p)}else p.pointerType==="mouse"&&(e.updateMouseoverArticle(p),e.mouseoverArticle!==null&&e.trigger("article-pointermove",e.mouseoverArticle,p));e.options.enableCursor&&e.updateCursor(p)}function A(p,_){if(e.isPinching&&_.list.length<2){if(_.list.length===1){const et=Hn(_);e.dragStartX=et.x}const D=n.scale||1,q=e.timescaleManager.zoom,x=q-n.initial.zoom,X=q,H=(n.initial.distance||0)*D;e.isPinching=!1,h(),e.trigger("zoom-pinch-end",ve({centre:n.centre,scale:D,distance:H,zoom:X,zoomDelta:0,dx:0,totalZoomDelta:x,pointers:[..._.list]}),p);return}const w=e.getRelativePosition(p),S=p.type==="pointercancel"||p.type==="touchcancel";let M=!1;if(!S&&i.relativePos&&a(i.relativePos,w)){if(i.isHjsClick)Kn();else if(i.isTermsClick)Jn();else if(i.isArticleClick)e.select(i.article.id),i.article.clicked(i.relativePos),e.options.enableCursor&&(e.canvas.style.cursor=i.article.getCursor(w)),e.trigger("article-click",i.article,p),i.isArticleDoubleClick&&e.trigger("article-dblclick",i.article,p);else{const{left:D=0,top:q=0}=i.relativePos||{},x=to({viewport:{x:D,y:q}});e.trigger("timeline-click",x,p),i.isDoubleClick&&e.trigger("timeline-dblclick",x,p)}M=!0}M?f(i.relativePos):i.relativePos&&c(),h();const F=e.draggingArticle;F!==null?(F.stopDragging(p),e.draggingArticle=null):e.isDragging&&e.endDragging(p),e.redraw()}this._dragPointerTracker=new Fn(this.canvas,{onStart:m,onMove:b,onEnd:A})},u.prototype.startDragging=function(e){var n,o;(n=this.stopPanAnimation)==null||n.call(this),(o=this.stopZoomAnimation)==null||o.call(this),this.isDragging=!0;const i=zt(e);this.dragOrigin={left:i.x,top:i.y},this.dragStartX=i.x,this.dragStartY=i.y,this.dragMomentumSamples=[{time:Date.now(),x:i.x}],this.trigger("viewport-drag-start",_e({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow}),e)},u.prototype.endDragging=function(e){this.isDragging=!1;const i=zt(e),n=this.dragOrigin.left-i.x;this.trackDragMomentumSample(i.x),this.trigger("viewport-drag-end",_e({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow,totalDx:n}),e),this.startDragMomentum()},u.prototype.doDrag=function(e){var r;this.isPanning&&((r=this.stopPanAnimation)==null||r.call(this));const i=zt(e),n=this.dragStartX-i.x,o=this.dragOrigin.left-i.x,s=Math.abs(o);this.dragStartX=i.x,this.trackDragMomentumSample(i.x),this.isAnimating||this.startAnimation(),s>30&&(this.animation.dragRedrawFunction=this.defaultRedraw),this.updateFromByPixels(n),this.trigger("viewport-drag",_e({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow,dx:n,totalDx:o}),e)},u.prototype.trackDragMomentumSample=function(e){var a;const i=Date.now(),n=((a=this.options.pan)==null?void 0:a.momentum)||{},o=St(n.sampleWindow,vi),s=this.dragMomentumSamples||[],r=i-o;for(;s.length>0&&s[0].time<r;)s.shift();s.push({time:i,x:e}),this.dragMomentumSamples=s},u.prototype.startDragMomentum=function(){var b,A,p;const e=((b=this.options.pan)==null?void 0:b.momentum)||{};if(e.active!==!0){this.dragMomentumSamples=[];return}const i=St(e.sampleWindow,vi),n=Date.now()-i,o=(this.dragMomentumSamples||[]).filter(_=>_.time>=n);if(this.dragMomentumSamples=[],o.length<2||this.isPinching||this.draggingArticle!==null)return;const s=o[0],r=o[o.length-1],a=r.time-s.time;if(a<=0)return;const l=(s.x-r.x)/a,h=St(e.minVelocity,eo);if(Math.abs(l)<h)return;this.isPanning&&((A=this.animation.pan)!=null&&A.stop)&&this.animation.pan.stop(),(p=this.stopZoomAnimation)==null||p.call(this);const c=St(e.friction,no),d=St(e.stopVelocity,io),g=St(e.maxDuration,oo);if(!Number.isFinite(l)||!Number.isFinite(c))return;this.isPanning=!0,this.startAnimation();const f=this,m=Un({velocity:l,friction:c,minVelocity:d,maxDuration:g,shouldStop(){return f.isDragging||f.isPinching?(f.isPanning=!1,!0):!1},onUpdate(_){f.updateFromByPixels(_),f.requestRedraw()},onComplete(){f.isPanning=!1,f.animation.pan===m&&(f.animation.pan=null)}});this.animation.pan=m},u.prototype.updateFromByPixels=function(t){this.repositionWindow-=t;let e=this.timescaleManager.startToken,i=this.timescaleManager.getPrevious(e);for(;this.repositionWindow>=i.length;)this.repositionWindow-=i.length,e=i,i=this.timescaleManager.getPrevious(e);for(;-this.repositionWindow>=e.length;)this.repositionWindow+=e.length,e=this.timescaleManager.getNext(e);this.timescaleManager.setStartToken(e)},u.prototype.updateMouseoverArticle=function(t,e=this.articles){const i=this.mouseoverArticle;let n=null;if(so(this,t)){const o=this.getRelativePosition(t);for(let s=e.length-1;s>=0;s--){const r=e[s];if(r.isVisible&&r.isInside(o)){n=r;break}}}this.mouseoverArticle=n,i!==n&&(i!==null&&i.pointerLeave(t),n!==null&&n.pointerEnter(t),this.requestRedraw(this.redraw))},u.prototype.load=function(t){this.addArticles(t),this.updateCurrentDensitySetting(),this.updateArticlesGroupIndex(),this.requestRedraw()},u.prototype.addArticles=function(t,e,i){if(t.length===0){i&&i.call(this);return}const n=this.articles.map(function(s){return s.id}),o=[];for(let s=0;s<t.length;s++){const r=t[s];n.indexOf(v(r,"id"))===-1&&(o.push(r),this._createImplicitLane(this._resolveLaneIdFromArticleData(r)))}this._updateLaneLayout();for(let s=0;s<o.length;s++){const r=new L(this,v(o[s],"id"));this.articles.push(r),r.setupByReceivedData(o[s]),r.registerPosition(this.getOriginalPosition(r))}this._refreshLaneOrder(),this.updateIsActiveStatus(),i&&i.call(this)},u.prototype.getDmyFromInput=function(t){return this.options.shiftBceDates&&t.year<0&&(t.year+=1),t},u.prototype.getActiveArticle=function(){for(let t=this.articles.length-1;t>=0;t--)if(this.articles[t].isActive)return this.articles[t];return null},u.prototype.getArticleById=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];if(i.id===t)return i}},u.prototype.bringFront=function(t){const e=Li(this.articles,t);e>=0&&vn(this.articles,e,this.articles.length-1),this._emitTimelineStateChange()},u.prototype.select=function(t){this.bringFront(t);const e=this.getActiveArticle();this.updateIsActiveStatus();const i=this.getActiveArticle();i!==e&&i&&this.trigger("article-select",i)},u.prototype.activated=function(t){this.select(t.id)},u.prototype.updateIsActiveStatus=function(){for(let t=0;t<this.articles.length;t++)this.articles[t].isActive=!1;for(let t=this.articles.length-1;t>=0;t--)if(this.articles[t].isDataLoaded){this.articles[t].isActive=!0;return}},u.prototype.getVisibleArticlesClone=function(){const t=[];for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isVisible&&i.isDataLoaded&&t.push(i)}return t},u.prototype.hasArticle=function(t){let e;for(let i=0;i<this.articles.length;i++)this.articles[i].id===t&&(e=this.articles[i]);return!de(e)},u.prototype.reposition=function(t,e){if(t.isDragging)return;const i=this.getOriginalPosition(t,e);t.registeredPosition=i;const n=t.finalOffset;if(!this.options.article.animation.move.active){t.position={left:i.left+n.left,top:i.top+n.top},t.offset={left:n.left,top:n.top};return}t.moveAnimation.finalOffset.top!==n.top||t.moveAnimation.finalOffset.left!==n.left?t.moveToOffsetWithAnim(n,!0):t.position={left:i.left+t.offset.left,top:i.top+t.offset.top}},u.prototype.getOriginalPosition=function(t,e){let i=this.getPixel(t.period.from,e);if(this.options.article.collectOngoing){const s=this.getPixel(t.period.to,e),r=isNaN(i)||i<0,a=isNaN(s)||s>0;r&&a&&(i=0)}const n=t._getCurrentStyle(),o=this.getLaneById(t.laneId);return this._isLaneLayoutActive()&&o&&o.geometry?{left:i-n.connectorLine.offsetX,top:o.geometry.bodyContentBottom-this._getLaneDistanceToBaseline(o)}:{left:i-n.connectorLine.offsetX,top:this.top-this._getTimelineDistanceToBaseline()}},u.prototype.reorderArticles=function(t){const e=[];for(let o=0;o<t.length;o++){const s=Li(this.articles,t[o]);e.push(this.articles[s])}const i=this.getActiveArticle();this.articles=e,this.updateIsActiveStatus();const n=this.getActiveArticle();n!==i&&n&&this.trigger("article-select",n),this._emitTimelineStateChange()},u.prototype.getSortedByYearClone=function(){},u.prototype.removeArticleById=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];if(i.id===t){if(typeof i._imageCancel=="function")try{i._imageCancel()}catch(n){}if(typeof i._closeImage=="function")try{i._closeImage({skipRedraw:!0})}catch(n){}i._pendingImageKey=null,this.articles.splice(e,1);break}}},u.prototype.deleteCurrentArticle=function(){if(this.articles.length!==0){this.removeById(this.articles,this.getActiveArticle().id),this.requestRedraw();for(let t=this.articles.length-1;t>=0;t--){const e=this.articles[t];if(e.isVisible){this.select(e.id),this.requestRedraw();return}}}},u.prototype.pp=function(t){let e="";for(let i=0;i<this.articles.length;i++)e+=`${this.articles[i].title.split(" ")[0]},`;t=t||"",P.log(`${t}:${e}`)};function Li(t,e){return t.findIndex(i=>i.id===e)}ft.prototype.draw=function(t,e){t.globalAlpha=1;const i=e.left,n=e.right,o=e.top,s=e.height,r=Math.max(0,n-i);if(r<=0)return;const a=this.style||{};t.fillStyle=a.backgroundColor||"rgba(200,200,200,0.25)",t.fillRect(i,o,r,s);const l=a.border||null;l&&l.width&&(t.lineWidth=l.width,t.strokeStyle=l.color||"rgba(120,120,120,0.6)",t.strokeRect(i+.5,o+.5,r-1,s-1));const h=a.text||{},c=h.margin||6,d=Math.max(0,r-c*2);if(d>2){t.font=h.font||"500 12px Calibri",t.textAlign=h.align||"center",t.textBaseline=h.baseline||"middle",t.fillStyle=h.color||"#222";const g=this.title||"",f=t.measureText(g).width;let m=g;if(f>d){const _=t.measureText.bind(t);let w=0,S=g.length,M=0;const D=_("…").width,q=Math.max(0,d-D);for(;w<=S;){const x=Math.floor((w+S)/2),X=g.substring(0,x);_(X).width<=q?(M=x,w=x+1):S=x-1}m=M>0?`${g.substring(0,M)}…`:""}const b=h.align==="left"?i+c:h.align==="right"?n-c:Math.floor((i+n)/2);let A;switch(h.verticalAlign||"middle"){case"top":A=o+(h.margin||0);break;case"bottom":A=o+s-(h.margin||0);break;default:A=o+Math.floor(s/2);break}A+=h.offsetY||0,t.fillText(m,b,A)}};function Ai(t){t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor="transparent black"}function Ii(t,e,i,n,o,s){t.moveTo(e+s,i),t.lineTo(e+n-s,i),s>0&&t.quadraticCurveTo(e+n,i,e+n,i+s),t.lineTo(e+n,i+o),t.lineTo(e,i+o),t.lineTo(e,i+s),s>0&&t.quadraticCurveTo(e,i,e+s,i),s===0&&t.closePath()}function Jt(t,e,i,n,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.arcTo(e+n,i,e+n,i+s,s),t.lineTo(e+n,i+o-s),t.arcTo(e+n,i+o,e+n-s,i+o,s),t.lineTo(e+s,i+o),t.arcTo(e,i+o,e,i+o-s,s),t.lineTo(e,i+s),t.arcTo(e,i,e+s,i,s),t.closePath()}function Ci(t,e,i,n,o,s,r,a){t.beginPath();const l=Math.PI/n;for(let h=0;h<2*n;h++){const c=(h&1)===0?s:o,d=e+Math.cos(1+h*l)*c,g=i+Math.sin(1+h*l)*c;h===0?t.moveTo(d,g):t.lineTo(d,g)}t.closePath(),t.lineWidth=1,t.strokeStyle=a,t.fillStyle=r,t.stroke(),t.fill()}function Si(t,e,i,n,o){let s;switch(i){case"left":s=t+n;break;case"center":s=t+e/2;break;case"right":s=t+e-n;break;default:s=t+n}return typeof o=="function"?o(s):i==="center"?t+Math.floor(e/2):s}function Ti(t,e,i,n,o,s,r,a,l){const h=l/2;t.save(),t.beginPath(),t.arc(r+h,a+h,h,0,Math.PI*2,!1),t.closePath(),t.clip(),t.drawImage(e,i,n,o,s,r,a,l,l),t.restore()}function Qt(t,e,i){const n=t.split(" "),o=[];let s=n[0];for(let r=1;r<n.length;r++){const a=n[r];e.measureText(`${s} ${a}`).width<i?s+=` ${a}`:(o.push(s),s=a)}return o.push(s),o}function Le(t,e,i,n="…"){if(!t||typeof t.measureText!="function")throw new Error("Invalid canvas context provided");if(typeof e!="string"||e===""||typeof i!="number"||i<=0)return"";if(typeof n!="string"&&(n="…"),t.measureText(e).width<=i)return e;const s=t.measureText(n).width;if(s>=i)return"";const r=i-s;if(r<=0)return"";let a=0,l=e.length,h=0;for(;a<=l;){const c=Math.floor((a+l)/2),d=e.substring(0,c);t.measureText(d).width<=r?(h=c,a=c+1):l=c-1}return h===0?"":e.substring(0,h)+n}function te(t,e,i=null,n=null){if(!Array.isArray(t)||t.length===0)return t;if(typeof e!="number"||e<=0)return[];const o=t.length>e,s=o?t.slice(0,e):[...t];if(s.length>0){const r=s.length-1,a=s[r];if(i&&typeof n=="number"&&n>0)if(o){const l=Le(i,a,n);s[r]=l,l===a&&(s[r]=Le(i,`${a}…`,n,"…"))}else s[r]=Le(i,a,n);else o&&(s[r]+="...")}return s}const Di={up:0,down:0};function Mi(t,e={}){const{anchorY:i=0,canvasHeight:n=0,fallbackArea:o=Di}=e,s=Number.isFinite(i)?i:0,r=Number.isFinite(n)?n:0,a=typeof(o==null?void 0:o.up)=="number"&&Number.isFinite(o.up)?Math.max(0,o.up):0,l=typeof(o==null?void 0:o.down)=="number"&&Number.isFinite(o.down)?Math.max(0,o.down):0,h=t||o||Di,c=!!t,d=typeof h.up=="undefined"?c?0:a:h.up,g=typeof h.down=="undefined"?c?0:l:h.down,f=(A,p)=>{if(typeof p=="number")return Number.isFinite(p)?Math.max(0,p):0;const _=typeof p=="object"&&p!==null&&p.value==="edge";if(p==="edge"||_){const w=_?p.padding:0,S=typeof w=="number"&&Number.isFinite(w)?Math.max(0,w):0,M=A==="up"?Math.max(0,s):Math.max(0,r-s);return Math.max(0,M-S)}return 0},m=f("up",d),b=f("down",g);return{up:m,down:b,height:m+b}}u.prototype.defaultRedraw=function(){this.redraw({onArticlesInRangeIsReady:function(e){this.updateVisibleArticlesOfGroups(e),this.forInRangeArticles(function(n){this.reposition(n,e)}),this.stack(e)},onArticlesVisiblityIsReady:function(e){this.updateArticleLines()}})},u.prototype.repositionRedraw=function(){this.redraw({onArticlesInRangeIsReady:function(e){this.updateVisibleArticlesOfGroups(e),this.forInRangeArticles(function(n){this.reposition(n,e)})},onArticlesVisiblityIsReady:function(e){this.updateArticleLines()}})},u.prototype.redraw=function(t){if(this.redrawInProgress)return;this.redrawInProgress=!0;const e=this.topRow;t=t||{};const i=this.canvasContext,n=this.getWidth(),o=this.top;this.trigger("timeline-render-start",{canvasContext:i,top:o});const s={},r=this.getTokensAndMarkers(n),a=r.markers,l=r.tokens;s.tokens=l,this._updateLaneLayout(),this._refreshAdaptiveArticleRuntimeOptions(),this._syncLaneDom(),this.invoke("onMainRangeIsReady",t,s),this.forLoadedArticles(function(c){c.isInView=c.overlapsInclusiveWithDates(s.tokens.start,s.tokens.end),this.options.article.autoStacking.range===Vt?c.isInRange=c.isInView:c.isInRange=!0,c.isVisibleInLane=this._isArticleLaneVisible(c),c.isInRange&&(c.isHiddenByFilter=c.hiddenByFilter)}),this.invoke("onArticlesInRangeIsReady",t,s),this.forLoadedArticles(function(c){c.updateVisibility()}),this.forVisibleArticles(function(c){this.enqueueImageLoad(c)}),this.invoke("onArticlesVisiblityIsReady",t,s),this.forInRangeArticles(function(c){c.indicator={fromX:Math.max(-3,Math.round(this.getPixel(c.period.from,s))),toX:Math.min(this.options.width,Math.round(this.getPixel(c.period.to,s)))},c.indicator.toX-c.indicator.fromX<2&&(c.indicator.toX=c.indicator.fromX+2)}),!this._isLaneLayoutActive()&&this.options.article.autoStacking.fitToHeight&&e!==this.topRow&&this.fitToHeight(!0),this.render(i,o,n,a),this.redrawInProgress=!1,this.trigger("timeline-render-end",{canvasContext:i,drawCycleContext:s,top:o})},u.prototype.render=function(t,e,i,n){const o=this.options.style.mainLine.size>>1,s=this._getEffectiveVerticalOffset?this._getEffectiveVerticalOffset():this.options.verticalOffset;this.owner||t.clearRect(0,0,i,this.top+s),this.drawTimeBands(t,e,i),this.drawDraggingHighlight(t,e,i);const r=this.options.style.mainLine.position==="top"?-s:e;this.drawMainline(t,r,i,n),this.options.style.mainLine.showDateIndicators&&(t.beginPath(),this.forInRangeArticles(function(h){!h.isHiddenByFilter&&h.isInView&&(t.moveTo(h.indicator.fromX,e-o),t.lineTo(h.indicator.fromX,e+o))}),t.lineWidth=3,t.globalAlpha=.75,t.strokeStyle="#303030",t.stroke()),t.globalAlpha=1;for(let l=0;l<this.articles.length;l++){const h=this.articles[l];h.isDataLoaded&&h.isVisible&&!h.isActive&&h.drawPeriodLinesAndConnectors(t,e)}for(let l=0;l<this.articles.length;l++){const h=this.articles[l];h.isDataLoaded&&h.isVisible&&!h.isActive&&h.draw(t)}const a=this.getActiveArticle();a&&a.isVisible&&(a.drawPeriodLinesAndConnectors(t,e),a.draw(t)),this.options.disableBranding||(t.globalAlpha=1,this._drawBranding(t))},u.prototype.drawMainline=function(t,e,i,n){if(this.options.style.mainLine.visible){t.globalAlpha=1;const o=this.options.style.mainLine.size>>1,s=t.createLinearGradient(0,e-o,0,e+o);s.addColorStop(0,"#808080"),s.addColorStop(1,"#ccc"),t.beginPath(),t.lineWidth=this.options.style.mainLine.size,t.strokeStyle=t.fillStyle=s,t.moveTo(0,e),t.lineTo(i,e),t.stroke();for(const r in n)this.drawMarkersAndLabels(t,n[r],r,e+o)}},u.prototype.drawDraggingHighlight=function(t,e,i){if(!this.isDragging)return;const n=this.options.style.draggingHighlight||{};if(!n.visible)return;t.fillStyle=n.color;const o=this.top,s=this.options.height,r={up:0,down:60},{up:a,height:l}=Mi(n.area,{anchorY:o,canvasHeight:s,fallbackArea:r});l<=0||t.fillRect(0,o-a,i,l)},u.prototype.drawTimeBands=function(t,e,i){const n=this.options.timeBand||{};if(!n.visible||!this.timeBands||this.timeBands.length===0)return;const o={tokens:this.getTokensAndMarkers(i).tokens},s=this._getVisibleTimeBands(o);if(s.length===0)return;const r=this.top,a=this.options.height,l={up:0,down:40},{up:h,height:c}=Mi(n.area,{anchorY:r,canvasHeight:a,fallbackArea:l});if(c<=0)return;const d=r-h;t.save();for(let g=0;g<s.length;g++){const f=s[g];let m=Math.round(this.getPixel(f.period.from,o)),b=Math.round(this.getPixel(f.period.to,o));b<0||m>i||(m=Math.max(0,m),b=Math.min(i,b),!(b-m<=0)&&f.draw(t,{left:m,right:b,top:d,height:c}))}t.restore()},u.prototype.getTokensAndMarkers=function(t){const e={},i={};i[st]=[],i[B]=[];let n=this.repositionWindow,o=this.timescaleManager.startToken;e.start=o.value;let s=o;const r=9;o=this.timescaleManager.getPreviousNth(o,r),n-=o.length*r;do i[o.type].push(o),e[o.value.toKeyString()]=o.drawX=n,n+=o.length,s=o,o=this.timescaleManager.getNext(o);while(n<t+150);return e.end=s.value,{tokens:e,markers:i}},u.prototype.drawMarkersAndLabels=function(t,e,i,n){if(e.length===0)return;switch(i){case JSON.stringify(B):i="minor";break;case JSON.stringify(st):i="major";break;default:P.log("token type not recognised",i,B)}const o=this.options.style.marker[i],s=o.extend,r=this.options.style.mainLine.position==="top"?-1:1,a=o.height,l=!!e[0].label;let h=e[0].value.isInFuture(),c=!h,d,g;r===-1&&(n-=this.options.style.mainLine.size),l&&(d=this.options.style.dateLabel[i],t.font=d.font,t.textAlign=d.textAlign,t.textBaseline=r===1?"alphabetic":"top",g=n+a*r+d.offset.y),t.beginPath();for(let f=0;f<e.length;f++){const m=e[f];h=m.value.isInFuture(),c&&h&&(c=!1,t.strokeStyle=o.color,t.lineWidth=1,t.stroke(),t.beginPath());const b=Math.round(m.drawX);t.moveTo(b,n+a*r);const A=s?n+-1*r*this.top:n;if(t.lineTo(b,A),l&&m.label){const p=b+d.offset.x;t.fillStyle=h?d.futureColor:d.color,t.fillText(m.label,p,g)}}t.strokeStyle=h?o.futureColor:o.color,t.lineWidth=1,t.stroke()},u.prototype.loadTimeBands=function(t){this.addTimeBands(t),typeof this._getEffectiveVerticalOffset=="function"&&(this.top=this.options.height-this._getEffectiveVerticalOffset()),this.requestRedraw()},u.prototype.addTimeBands=function(t){if(!Array.isArray(t)||t.length===0)return;const e=this.timeBands.map(o=>o.id),i=t.filter(o=>e.indexOf(o.id)===-1),n=this.options.timeBand&&this.options.timeBand.defaultStyle||{};for(let o=0;o<i.length;o++){const s=i[o],r=new ft(this,s.id);r.setupByReceivedData(s),r.style=I({},n,s.style||{}),this.timeBands.push(r)}typeof this._getEffectiveVerticalOffset=="function"&&(this.top=this.options.height-this._getEffectiveVerticalOffset())},u.prototype._getVisibleTimeBands=function(t){if(!this.timeBands||this.timeBands.length===0)return[];const e=t.tokens.start,i=t.tokens.end;return this.timeBands.filter(n=>n.isDataLoaded&&n.visibility!=="hidden"&&n.overlapsInclusiveWithDates(e,i))};function Ae(t,e){return e&&e.resolvedArticleOptions?e.resolvedArticleOptions:oi(t.options.article||{})}u.prototype._getResolvedArticleOptions=function(t){const e=t&&t.laneId!=null?t.laneId:this._resolveLaneIdFromArticleData(t),i=this.getLaneById(e);return Ae(this,i)},u.prototype._getExplicitArticleCardLayout=function(t){if(!t)return null;if(typeof t.cardLayout=="string"&&t.cardLayout!=="")return t.cardLayout;const e=t.data||t,i=v(e,"cardLayout");return typeof i=="string"&&i!==""?i:null},u.prototype._getResolvedArticleTopGap=function(t=this.options.article||{}){const e=t.autoStacking||{};let i=Number(Et(e.topGap,this))||0;return this.options.style.mainLine.position==="top"&&(i-=this.options.verticalOffset),i},u.prototype._getTimelineArticleAvailableHeight=function(){return Math.max(0,this.top-this._getResolvedArticleTopGap())},u.prototype._getLaneArticleAvailableHeight=function(t){return!t||!t.geometry?0:Math.max(0,t.geometry.bodyContentBottom-t.geometry.bodyContentTop)},u.prototype._getAvailableHeightForArticle=function(t){const e=t&&t.laneId!=null?t.laneId:this._resolveLaneIdFromArticleData(t);return this._isLaneLayoutActive()?this._getLaneArticleAvailableHeight(this.getLaneById(e)):this._getTimelineArticleAvailableHeight()},u.prototype._resolveCardLayoutFromBreakpoints=function(t){var i;const e=Array.isArray((i=this.options.article)==null?void 0:i.cardLayoutBreakpoints)?this.options.article.cardLayoutBreakpoints:[];for(let n=0;n<e.length;n++){const o=e[n];if(!(!o||!Number.isFinite(o.maxHeight)||typeof o.layout!="string"||o.layout==="")&&t<=o.maxHeight)return o.layout}return null},u.prototype._resolveDefaultCardLayoutName=function(t){const e=this._getResolvedArticleOptions(t),i=this._resolveCardLayoutFromBreakpoints(this._getAvailableHeightForArticle(t));if(i)return i;const n=e.defaultCardLayout;return typeof n=="string"&&n!==""?n:"portrait"},u.prototype._resolveArticleCardLayoutName=function(t){return this._getExplicitArticleCardLayout(t)||this._resolveDefaultCardLayoutName(t)},u.prototype._getTimelineDistanceToBaseline=function(){var e,i;if(Number.isFinite((e=this._runtimeArticleOptions)==null?void 0:e.distanceToBaseline))return this._runtimeArticleOptions.distanceToBaseline;const t=this._resolveDefaultCardLayoutName();return qt((i=this.options.article)==null?void 0:i.distanceToBaseline,this._getTimelineArticleAvailableHeight(),!1,t)},u.prototype._getLaneAutoStackingOptions=function(t){return Ae(this,t).autoStacking||{}},u.prototype._getLaneDistanceToBaseline=function(t){var n;if(!this._isLaneLayoutActive())return this._getTimelineDistanceToBaseline();if(Number.isFinite((n=t==null?void 0:t._runtimeArticleOptions)==null?void 0:n.distanceToBaseline))return t._runtimeArticleOptions.distanceToBaseline;const e=Ae(this,t),i=this._resolveDefaultCardLayoutName({laneId:t==null?void 0:t.id});return qt(e.distanceToBaseline,this._getLaneArticleAvailableHeight(t),!0,i)},u.prototype._refreshAdaptiveArticleRuntimeOptions=function(){var n,o;const t=this._isLaneLayoutActive(),e=this._getTimelineArticleAvailableHeight(),i=this._resolveDefaultCardLayoutName();this._runtimeArticleOptions={availableHeight:e,defaultCardLayout:i,distanceToBaseline:qt((n=this.options.article)==null?void 0:n.distanceToBaseline,e,!1,i)};for(let s=0;s<this.lanes.length;s++){const r=this.lanes[s],a=t&&r.geometry?this._getLaneArticleAvailableHeight(r):0,l=(o=r==null?void 0:r.resolvedArticleOptions)==null?void 0:o.distanceToBaseline,h=this._resolveDefaultCardLayoutName({laneId:r==null?void 0:r.id});r._runtimeArticleOptions={availableHeight:a,defaultCardLayout:h,distanceToBaseline:qt(l,a,t,h)}}this.forLoadedArticles(s=>{const r=this._resolveDefaultCardLayoutName(s),a=this._resolveArticleCardLayoutName(s);if(s._resolvedCardLayoutName!==a){s.initialiseStyles(s.data),s.invalidateCaches();return}s._resolvedDefaultCardLayout=r,s._resolvedCardLayoutName=a})};function yt(...t){return t.filter(Boolean).join(" ")}function gt(t){return`${Math.round(t||0)}px`}function Ri(t,e){const i=e===t.length-1,n=e===0,o=["histropedia-lane",`histropedia-lane-index-${e}`];return i&&o.push("histropedia-lane-position-top"),n&&o.push("histropedia-lane-position-bottom"),!i&&!n&&o.push("histropedia-lane-position-middle"),o}function ro(t){switch(t){case"center":return"center";case"right":return"flex-end";default:return"flex-start"}}function wt(t,e){return C(t||{},e)?v(t,e):void 0}function Pi(t,e,i){return e?{visible:!1,rootClassName:yt(...Ri(t.lanes,i),t.options.lane.defaultClassName,e.className),zIndex:String(t.lanes.length-i),headerClassName:yt("histropedia-lane-header",t.options.lane.defaultHeaderClassName,e.headerClassName),bodyClassName:yt("histropedia-lane-body",t.options.lane.defaultBodyClassName,e.bodyClassName),titleClassName:yt("histropedia-lane-title",t.options.lane.defaultTitleClassName,e.titleClassName)}:{visible:!1}}function ao(t,e,i){var l,h;const n=e.geometry,o=e.style||{},s=wt(o,"title.textAlign"),r=wt(o,"body.borderWidth"),a=wt(o,"body.borderRadius");return{visible:!0,rootClassName:yt(...Ri(t.lanes,i),t.options.lane.defaultClassName,e.className),zIndex:String(t.lanes.length-i),headerClassName:yt("histropedia-lane-header",t.options.lane.defaultHeaderClassName,e.headerClassName),bodyClassName:yt("histropedia-lane-body",t.options.lane.defaultBodyClassName,e.bodyClassName),titleClassName:yt("histropedia-lane-title",t.options.lane.defaultTitleClassName,e.titleClassName),top:gt(n.top),height:gt(n.height),headerHeight:gt(n.headerHeight||0),headerDisplay:n.headerHeight>0?"":"none",headerBackgroundColor:wt(o,"header.backgroundColor"),bodyTop:gt(n.bodyTop-n.top),bodyBottom:gt(n.bottom-n.bodyBottom),bodyBackgroundColor:wt(o,"body.backgroundColor"),bodyBorderColor:wt(o,"body.borderColor"),bodyBorderWidth:typeof r=="undefined"?void 0:gt(r),bodyBorderStyle:typeof r=="undefined"?void 0:"solid",bodyBorderRadius:typeof a=="undefined"?void 0:gt(a),titleLeft:gt(((l=n.headerPadding)==null?void 0:l.left)||0),titleRight:gt(((h=n.headerPadding)==null?void 0:h.right)||0),titleJustifyContent:typeof s=="undefined"?void 0:ro(s),titleColor:wt(o,"title.color"),titleFont:wt(o,"title.font"),titleTextAlign:s,titleText:e.title||""}}function tt(t,e,i){t[e]=typeof i=="undefined"?"":i}function lo(t,e){const i=[];for(let n=t.lanes.length-1;n>=0;n--){const o=String(t.lanes[n].id),s=t._laneDomNodes.get(o);s&&i.push(s.root)}for(let n=0;n<i.length;n++)e.children[n]!==i[n]&&e.insertBefore(i[n],e.children[n]||null)}function Oi(t,e,i){if((!e||e.rootClassName!==i.rootClassName)&&(t.root.className=i.rootClassName),(!e||e.headerClassName!==i.headerClassName)&&(t.header.className=i.headerClassName),(!e||e.bodyClassName!==i.bodyClassName)&&(t.body.className=i.bodyClassName),(!e||e.titleClassName!==i.titleClassName)&&(t.title.className=i.titleClassName),(!e||e.zIndex!==i.zIndex)&&tt(t.root.style,"zIndex",i.zIndex),!(e&&e.visible===i.visible&&i.visible===!1)){if(!i.visible){t.root.style.display="none";return}(!e||e.visible!==!0)&&(t.root.style.display=""),(!e||e.top!==i.top)&&(t.root.style.top=i.top),(!e||e.height!==i.height)&&(t.root.style.height=i.height),(!e||e.headerHeight!==i.headerHeight)&&(t.header.style.height=i.headerHeight),(!e||e.headerDisplay!==i.headerDisplay)&&(t.header.style.display=i.headerDisplay),(!e||e.headerBackgroundColor!==i.headerBackgroundColor)&&tt(t.header.style,"backgroundColor",i.headerBackgroundColor),(!e||e.bodyTop!==i.bodyTop)&&(t.body.style.top=i.bodyTop),(!e||e.bodyBottom!==i.bodyBottom)&&(t.body.style.bottom=i.bodyBottom),(!e||e.bodyBackgroundColor!==i.bodyBackgroundColor)&&tt(t.body.style,"backgroundColor",i.bodyBackgroundColor),(!e||e.bodyBorderColor!==i.bodyBorderColor)&&tt(t.body.style,"borderColor",i.bodyBorderColor),(!e||e.bodyBorderWidth!==i.bodyBorderWidth)&&tt(t.body.style,"borderWidth",i.bodyBorderWidth),(!e||e.bodyBorderStyle!==i.bodyBorderStyle)&&tt(t.body.style,"borderStyle",i.bodyBorderStyle),(!e||e.bodyBorderRadius!==i.bodyBorderRadius)&&tt(t.body.style,"borderRadius",i.bodyBorderRadius),(!e||e.titleLeft!==i.titleLeft)&&(t.title.style.left=i.titleLeft),(!e||e.titleRight!==i.titleRight)&&(t.title.style.right=i.titleRight),(!e||e.titleJustifyContent!==i.titleJustifyContent)&&tt(t.title.style,"justifyContent",i.titleJustifyContent),(!e||e.titleColor!==i.titleColor)&&tt(t.title.style,"color",i.titleColor),(!e||e.titleFont!==i.titleFont)&&tt(t.title.style,"font",i.titleFont),(!e||e.titleTextAlign!==i.titleTextAlign)&&tt(t.title.style,"textAlign",i.titleTextAlign),(!e||e.titleText!==i.titleText)&&(t.title.textContent=i.titleText)}}u.prototype._initialiseLaneHost=function(t){if(this._laneHostElement=null,this._laneViewportElement=null,this._laneLayer=null,this._laneDomNodes=new Map,this._laneDomState=new Map,this._laneDomDirty=!0,this._laneLayerDisplay=null,this._hasExplicitLanes=!1,!(t&&t===this.canvas)&&t&&t.nodeName!=="CANVAS"){this._laneHostElement=t;return}const i=this.canvas?this.canvas.parentElement:null;i&&i.firstElementChild===this.canvas&&i.children.length===1&&(this._laneHostElement=i)},u.prototype._ensureLaneViewport=function(){if(!this._laneHostElement||!this.canvas)return null;if(this._laneViewportElement)return this._laneViewportElement;const t=this.canvas.parentElement;if(!t)return null;const e=document.createElement("div");return e.className="histropedia-viewport",e.style.display="block",e.style.position="relative",t.insertBefore(e,this.canvas),e.appendChild(this.canvas),this._laneViewportElement=e,this._syncLaneViewportSize(),e},u.prototype._syncLaneViewportSize=function(){if(!this._laneViewportElement||!this.canvas)return;const t=this.canvas.style&&this.canvas.style.width?this.canvas.style.width:"",e=this.canvas.style&&this.canvas.style.height?this.canvas.style.height:"";this._laneViewportElement.style.width=t,this._laneViewportElement.style.height=e},u.prototype._markLaneDomDirty=function(){this._laneDomDirty=!0},u.prototype._setLaneLayerDisplay=function(t){!this._laneLayer||this._laneLayerDisplay===t||(this._laneLayer.style.display=t,this._laneLayerDisplay=t)},u.prototype._isLaneChromeActive=function(){return this._isLaneLayoutActive()&&this.options.lane.visible!==!1},u.prototype._ensureLaneLayer=function(){const t=this._ensureLaneViewport();if(!t)return null;if(!this._laneLayer){const e=document.createElement("div");e.setAttribute("aria-hidden","true"),e.dataset.histropediaLaneLayer="true",e.style.position="absolute",e.style.inset="0",e.style.pointerEvents="none",e.style.zIndex="0",e.style.overflow="hidden";const i=typeof window!="undefined"&&window.getComputedStyle?window.getComputedStyle(this.canvas).position:this.canvas.style.position;(!i||i==="static")&&(this.canvas.style.position="relative"),this.canvas.style.zIndex="1",this.canvas.style.display||(this.canvas.style.display="block"),this.canvas.parentElement===t?t.insertBefore(e,this.canvas):fi(t,e),this._laneLayer=e}return this._laneLayer},u.prototype._syncLaneDom=function(){if(!this._isLaneChromeActive()){this._laneLayer&&this._setLaneLayerDisplay("none");return}const t=this._ensureLaneLayer();if(!t)return;this._setLaneLayerDisplay("");const e=this._laneDomDirty,i=new Set;for(let n=0;n<this.lanes.length;n++){const o=this.lanes[n],s=o.geometry,r=o.currentVisibility!=="hidden"&&s,a=String(o.id);let l=this._laneDomNodes.get(a);if(!l){const d=document.createElement("div"),g=document.createElement("div"),f=document.createElement("div"),m=document.createElement("div");d.dataset.histropediaLaneId=a,g.appendChild(f),d.appendChild(g),d.appendChild(m),t.appendChild(d),d.style.position="absolute",d.style.left="0",d.style.right="0",d.style.boxSizing="border-box",d.style.pointerEvents="none",g.style.position="absolute",g.style.left="0",g.style.right="0",g.style.top="0",g.style.boxSizing="border-box",g.style.pointerEvents="none",m.style.position="absolute",m.style.left="0",m.style.right="0",m.style.boxSizing="border-box",m.style.pointerEvents="none",f.style.position="absolute",f.style.top="0",f.style.bottom="0",f.style.display="flex",f.style.alignItems="center",f.style.boxSizing="border-box",f.style.pointerEvents="none",f.style.overflow="hidden",f.style.whiteSpace="nowrap",f.style.textOverflow="ellipsis",l={root:d,header:g,title:f,body:m},this._laneDomNodes.set(a,l)}i.add(a);const h=r?ao(this,o,n):Pi(this,o,n),c=this._laneDomState.get(a);Oi(l,c,h),this._laneDomState.set(a,h)}this._laneDomNodes.forEach((n,o)=>{if(!i.has(o)){const s=Pi(),r=this._laneDomState.get(o);Oi(n,r,s),this._laneDomState.set(o,s)}}),e&&lo(this,t),this._laneDomDirty=!1};function Nt(t,e){return t===e}function ho(t){const e=t&&t.layout?t.layout:{},i=Number.isFinite(e.height)?e.height:null,n=Number.isFinite(e.heightWeight)&&e.heightWeight>0?e.heightWeight:1;return{explicitHeight:i,heightWeight:n}}function ee(t){return Math.round(t||0)}function co(t,e){return e&&(t.cacheChanged=t.cacheChanged||!!e.cacheChanged,e.styleChanged&&e.laneId!=null&&t.styleLaneIds.add(String(e.laneId))),t}function ki(t,e){if(!Number.isFinite(t))throw new Error(`Lane index must be a finite number. Received: ${t}`);return e<=1?0:Math.min(Math.max(Math.trunc(t),0),e-1)}u.prototype._getDefaultLaneId=function(){const t=this.options&&this.options.lane?this.options.lane:{};return t.defaultId!=null?t.defaultId:"default"},u.prototype._isLaneLayoutActive=function(){if(!Array.isArray(this.lanes)||this.lanes.length===0)return!1;if(this.lanes.length!==1)return!0;const t=this.lanes[0];return!(t&&t.isImplicit&&Nt(t.id,this._getDefaultLaneId())&&!this._hasExplicitLanes)},u.prototype.getLaneById=function(t){for(let e=0;e<this.lanes.length;e++){const i=this.lanes[e];if(Nt(i.id,t))return i}},u.prototype._resolveLaneReference=function(t){if(t instanceof Z||t&&typeof t=="object"&&t.owner){if(t.owner===this){const e=this.lanes.indexOf(t);if(e>=0)return this.lanes[e]}throw new Error(`Lane "${t.id}" does not belong to this timeline`)}if(t!=null&&t!==""){const e=this.getLaneById(t);if(e)return e}throw new Error(`Lane "${t}" does not exist on this timeline`)},u.prototype._getLanePublicIndex=function(t){const e=this.lanes.indexOf(t);if(e<0)throw new Error(`Lane "${t&&t.id}" does not belong to this timeline`);return e},u.prototype._getInternalLaneIndexFromPublicIndex=function(t,e=this.lanes.length){return ki(t,e)},u.prototype._handleLaneChange=function({requestRedraw:t=!1,refreshOrder:e=!0}={}){e&&this._refreshLaneOrder(),this._markLaneDomDirty(),t&&this.requestRedraw()},u.prototype._createImplicitLane=function(t){const e=t!=null&&t!==""?t:this._getDefaultLaneId(),i=this.getLaneById(e);if(i)return i;const n=new Z(this,e);return n.setupByReceivedData({id:e},{implicit:!0}),this.lanes.push(n),this._handleLaneChange(),n},u.prototype._resolveLaneIdFromArticleData=function(t){const e=t?v(t,"lane"):void 0;return e!=null&&e!==""?e:this._getDefaultLaneId()},u.prototype._assignArticleToLane=function(t,e){const i=this._createImplicitLane(e);return t.laneId=i.id,t.laneOrder=i.order||0,i},u.prototype._refreshLaneOrder=function(){for(let t=0;t<this.lanes.length;t++)this.lanes[t].order=t;for(let t=0;t<this.articles.length;t++){const e=this.articles[t],i=this.getLaneById(e.laneId);e.laneOrder=i?i.order:0}this._hasExplicitLanes=this.lanes.some(t=>!t.isImplicit)},u.prototype._handleLaneIdChange=function(t,e){for(let i=0;i<this.articles.length;i++){const n=this.articles[i];Nt(n.laneId,e)&&(n.laneId=t.id,n.data&&v(n.data,"lane")!=null&&(n.data.lane=t.id))}this._markLaneDomDirty()},u.prototype._refreshArticlesForLane=function(t,{refreshStyles:e=!0}={}){if(e)for(let i=0;i<this.articles.length;i++){const n=this.articles[i];!n.isDataLoaded||!Nt(n.laneId,t.id)||(n.initialiseStyles(n.data),n.invalidateCaches())}},u.prototype._refreshAllLaneArticleStyles=function(){this.forLoadedArticles(t=>{t.initialiseStyles(t.data),t.invalidateCaches()})},u.prototype._refreshLaneArticleStylesByIds=function(t){!t||t.size===0||this.forLoadedArticles(e=>{t.has(String(e.laneId))&&(e.initialiseStyles(e.data),e.invalidateCaches())})},u.prototype._refreshResolvedLanesFromOptions=function({articleStyleScope:t=null}={}){for(let e=0;e<this.lanes.length;e++)this.lanes[e]._resolveFromData();this._handleLaneChange(),t==="all"?this._refreshAllLaneArticleStyles():t instanceof Set&&this._refreshLaneArticleStylesByIds(t)},u.prototype.loadLanes=function(t){this.addLanes(t),this.requestRedraw()},u.prototype.addLanes=function(t,{suppressArticleRefresh:e=!1}={}){var n,o;if(!Array.isArray(t)||t.length===0)return{cacheChanged:!1,styleLaneIds:new Set};const i={cacheChanged:!1,styleLaneIds:new Set};for(let s=0;s<t.length;s++){const r=t[s]||{},a=r.id!=null?r.id:this._getDefaultLaneId(),l=this.getLaneById(a);if(l){const c=l._applyOption(I({},r,{id:a}),{suppressRedraw:!0,markExplicit:!0,suppressArticleRefresh:e});co(i,{cacheChanged:(n=c==null?void 0:c.articleImpact)==null?void 0:n.cacheChanged,styleChanged:(o=c==null?void 0:c.articleImpact)==null?void 0:o.styleChanged,laneId:c==null?void 0:c.laneId});continue}const h=new Z(this,a);h.setupByReceivedData(I({},r,{id:a}),{implicit:!1}),this.lanes.push(h)}return this._handleLaneChange(),i},u.prototype.moveLaneToIndex=function(t,e){const i=this._resolveLaneReference(t),n=this._getLanePublicIndex(i),o=ki(e,this.lanes.length);if(n===o)return i;const s=this._getInternalLaneIndexFromPublicIndex(n),r=this._getInternalLaneIndexFromPublicIndex(o),a=this.lanes.splice(s,1)[0];return this.lanes.splice(r,0,a),this._handleLaneChange({requestRedraw:!0}),a},u.prototype.moveLaneBefore=function(t,e){const i=this._resolveLaneReference(t),n=this._resolveLaneReference(e);if(i===n)return i;const o=this._getLanePublicIndex(i),s=this._getLanePublicIndex(n),r=o<s?s-1:s;return this.moveLaneToIndex(i,r)},u.prototype.moveLaneAfter=function(t,e){const i=this._resolveLaneReference(t),n=this._resolveLaneReference(e);if(i===n)return i;const o=this._getLanePublicIndex(i),s=this._getLanePublicIndex(n),r=o<s?s:s+1;return this.moveLaneToIndex(i,r)},u.prototype.moveLaneUp=function(t){const e=this._resolveLaneReference(t);return this.moveLaneToIndex(e,e.order+1)},u.prototype.moveLaneDown=function(t){const e=this._resolveLaneReference(t);return this.moveLaneToIndex(e,e.order-1)},u.prototype.loadLaneArticles=function(t,e){const i=t!=null&&t!==""?t:this._getDefaultLaneId(),o=(Array.isArray(e)?e:[]).map(s=>{const r=I({},s),a=v(s,"lane");return a!=null&&a!==""&&!Nt(a,i)&&P.warn("loadLaneArticles overriding conflicting article.lane value",{articleId:v(s,"id"),from:a,to:i}),r.lane=i,r});this._createImplicitLane(i),this.load(o)},u.prototype._getActiveLanesForLayout=function(){if(!Array.isArray(this.lanes)||this.lanes.length===0)return[];const t=[];for(let e=0;e<this.lanes.length;e++){const i=this.lanes[e];i.currentVisibility=i.visibility,i.currentVisibility!=="hidden"?t.push(i):i.geometry=null}return t},u.prototype._updateLaneLayout=function(){var A,p,_;const t=this._getActiveLanesForLayout();if(!this._isLaneLayoutActive()||t.length===0){for(let w=0;w<this.lanes.length;w++)this.lanes[w].geometry=null;return}const e=this.options.lane||{},i=typeof e.gap=="number"?e.gap:0,n=typeof e.topGap=="number"?e.topGap:0,o=typeof e.axisGap=="number"?e.axisGap:0,s=this.top-this.options.style.mainLine.size/2-o,r=i*Math.max(t.length-1,0),a=s-n-r,l=t.map(w=>ho(w));let h=0,c=0;for(let w=0;w<l.length;w++){const S=l[w];S.explicitHeight!=null?h+=S.explicitHeight:c+=S.heightWeight}const d=Math.max(0,a-h),g=this.getWidth(),f=ee(s),m=c>0;let b=n;for(let w=t.length-1;w>=0;w--){const S=t[w],M=l[w],F=M.explicitHeight!=null?M.explicitHeight:c>0?d*M.heightWeight/c:0,D=ee(b),q=b+F,x=w===0&&m?f:ee(q),X=Math.max(0,x-D),H=D+X,et=((A=S.layout.header)==null?void 0:A.padding)||{},_t=((p=S.layout.header)==null?void 0:p.visible)!==!1&&typeof((_=S.layout.header)==null?void 0:_.height)=="number"?ee(S.layout.header.height):0,it=D+_t,vt=H;S.geometry={top:D,left:0,width:g,height:X,bottom:H,headerTop:D,headerHeight:_t,headerBottom:it,bodyTop:it,bodyBottom:vt,bodyLeft:0,bodyRight:g,bodyContentTop:it,bodyContentBottom:vt,bodyContentLeft:0,bodyContentRight:g,headerPadding:et},b=q+i}},u.prototype._isArticleLaneVisible=function(t){const e=this.getLaneById(t.laneId);return!e||!this._isLaneLayoutActive()?!0:e.currentVisibility!=="hidden"},u.prototype._getLaneRowSpacing=function(t,e){const i=this._getLaneAutoStackingOptions(t),n=Array.isArray(e)?e.length:e;if(!t||!i.fitToHeight||n<=1||!t.geometry)return i.rowSpacing;const o=Number(Et(i.topGap,this))||0,s=t.geometry.bodyContentBottom-this._getLaneDistanceToBaseline(t),r=t.geometry.bodyContentTop+o,a=Math.max(0,s-r);return Math.max(Math.round(a/(n-1)),1)},u.prototype.updateArticleLines=function(){const t=this,e=this.options.article.periodLine||{},i=this._isLaneLayoutActive()&&e.position==="lane";function n(l){const h=[];return t.forVisibleArticles(function(c){c.hidePeriodLine||(h.push(c),h[h.length-1].stacking=-1)}),h.sort(t.options.article.periodLine.stacking.sorter),t.options.article.periodLine.stacking.reverseOrder&&h.reverse(),h}function o(l,h){for(let c=0;c<h.length;c++)if(l.overlaps(h[c]))return!1;return!0}function s(l){let h=0;const c=[];let d;do{c[h]=[],d=!1;for(let g=0;g<l.length;g++){const f=l[g];f.stacking>=0||o(f,c[h])&&(c[h].push(f),f.stacking=h,d=!0)}h++}while(d)}const r=n(this.articles);if(!i){s(r);return}const a=new Map;for(let l=0;l<r.length;l++){const h=r[l],c=String(h.laneId),d=a.get(c)||[];d.push(h),a.set(c,d)}a.forEach(l=>{s(l)})},u.prototype.stack=function(t){if(this.articles.length===0||!this.options.article.autoStacking.active)return;function e(h){let c;const d=[],g=[];for(let f=0;f<h.length;f++){const m=h[f];m.isDataLoaded&&m.isInRange&&m.isVisibleInGroup&&!m.isHiddenByFilter&&(m.isActive?c=m:m.isStarred?d.push(m):g.push(m))}return d.sort(ge),g.sort(ge),[].concat(c||[],d,g)}function i(h,c){for(let d=0;d<h.length;d++){const g=h[d];if(c.headerOverlapsWith(g))return!1}return!0}function n(h,c){for(let d=0;d<h.length;d++)if(i(h[d],c))return d;return h.length}function o(h,c){const d=n(h,c);return d>=h.length&&(h[d]=[]),h[d].push(c),!0}const s=e(this.articles);if(this._isLaneLayoutActive()){const h=new Map;for(let d=0;d<s.length;d++){const g=s[d],f=this.getLaneById(g.laneId),m=this._getLaneAutoStackingOptions(f),b=String(g.laneId),A=h.get(b)||[];m.active===!1?(A[0]||(A[0]=[]),A[0].push(g),g.isVisibleInRows=!0):g.isVisibleInRows=o(A,g),h.set(b,A)}this.topRow=0,h.forEach((d,g)=>{const f=this.getLaneById(g),m=this._getLaneAutoStackingOptions(f),b=m.active===!1?0:this._getLaneRowSpacing(f,d);f&&(f.topRow=0);for(let A=0;A<d.length;A++)for(let p=0;p<d[A].length;p++){const _=d[A][p],w=m.active===!1;w||(_.finalOffset={left:0,top:A*-b}),_.row=w?0:A,f&&(f.topRow=Math.max(f.topRow,_.row)),_.isInView&&(this.topRow=Math.max(this.topRow,_.row)),w||this.reposition(_,t)}});const c=this.getActiveArticle();this.articles.sort(fe),c&&this.bringFront(c.id);return}const r=this.options.article.autoStacking.rowSpacing,a=[];for(let h=0;h<s.length;h++)s[h].isVisibleInRows=o(a,s[h]);this.topRow=0;for(let h=0;h<a.length;h++)for(let c=0;c<a[h].length;c++){const d=a[h][c];d.finalOffset={left:0,top:h*-r},d.row=h,d.isInView&&(this.topRow=Math.max(this.topRow,h)),this.reposition(d,t)}const l=this.getActiveArticle();this.articles.sort(fe),l&&this.bringFront(l.id)},u.prototype.notifyEventSpacingChanged=function(){this.requestRedraw(this.defaultRedraw)};const uo=.001,fo=1e3/60;function go(t,e="discrete"){let i=0;if("deltaY"in t&&typeof t.deltaY=="number"&&t.deltaY!==0?i=-t.deltaY:"wheelDelta"in t&&typeof t.wheelDelta=="number"&&t.wheelDelta!==0?i=t.wheelDelta:"detail"in t&&typeof t.detail=="number"&&t.detail!==0&&(i=-t.detail),e==="discrete")return i>0?1:-1;const n=i/120;return n===0?0:n}function mo(t){if(t.deltaMode===1)return!0;if(typeof t.deltaY=="number"){const e=Math.abs(t.deltaY);if(e>=100&&e%120===0)return!0}return"wheelDelta"in t&&typeof t.wheelDelta=="number"&&Math.abs(t.wheelDelta)%120===0}function po(t,e){const i=t.discreteWheelAnimation;return i!=null&&i.active?e:!1}function yo(t,e){return e&&Number.isFinite(t.animation.wheelZoomTarget)?t.animation.wheelZoomTarget:t.timescaleManager.zoom}function Ei(t,e){let i=e;return i>t.maximum&&(i=t.maximum),i<t.minimum&&(i=t.minimum),i}function wo(t,e){var n;const i=((n=t.discreteWheelAnimation)==null?void 0:n.duration)||250;return i<=0?1:1-Math.pow(.05,Math.max(e,0)/i)}function Ie(t){t.wheelZoomTarget=null,t.wheelZoomPivotPoint=null,t.wheelZoomPivotPixel=null,t.wheelZoomLastFrameTime=null,t.wheelZoomFrame=null}u.prototype.enableZoomByWheel=function(){this._wheelEnabled||(this._wheelEnabled=!0,this._wheelHandler=e=>{const{allowCtrlWheel:i=!1,wheelMode:n="auto"}=this.options.zoom||{};if(!i&&e.ctrlKey)return;const s=go(e,n==="discrete"?"discrete":"proportional");this.onWheel(e,s)},this.canvas.addEventListener("wheel",this._wheelHandler,{passive:!1}),this.canvas.addEventListener("DOMMouseScroll",this._wheelHandler,{passive:!1}))},u.prototype.disableZoomByWheel=function(){this._wheelEnabled&&(this.canvas.removeEventListener("wheel",this._wheelHandler),this.canvas.removeEventListener("DOMMouseScroll",this._wheelHandler),this._wheelEnabled=!1,this._wheelHandler=null)},u.prototype.onWheel=function(e,i){const{wheelSpeed:n,wheelStep:o,maximum:s,minimum:r,proportionalGain:a,proportionalExponent:l,wheelMode:h}=this.options.zoom,c=h!=="discrete",d=mo(e);if(c&&!d){const w=Math.sign(i)||1;let S=Math.abs(i);S>=1&&l&&l!==1&&(S=Math.pow(S,l)),S*=a,i=w*S}else c&&d&&(i=i>0?1:-1);const g=po(this.options.zoom,d);let f=yo(this,g)+-i*n*o;f=Ei({maximum:s,minimum:r},f);let m,b;if(e.target===this.canvas&&"offsetX"in e&&typeof e.offsetX=="number")m=e.offsetX,b=e.offsetY;else{const w=this.canvas.getBoundingClientRect();m=e.clientX-w.left,b=e.clientY-w.top}const A=this.timescaleManager.zoom;g?this.animateZoomByPivotPoint(f,this.getPivotPoint(m),m):(this.animation.wheelZoomFrame!=null&&cancelAnimationFrame(this.animation.wheelZoomFrame),Ie(this.animation),this.setZoomByPivotPixel(f,m));const p=this.timescaleManager.zoom,_=f-A;this.requestRedraw(),e.preventDefault(),this.trigger("zoom-wheel",Qn({centre:{x:m,y:b},zoom:g?f:p,zoomDelta:_}),e)},u.prototype.animateZoomByPivotPoint=function(e,i,n){var r,a;if((r=this.stopPanAnimation)==null||r.call(this),this.animation.wheelZoomFrame==null&&((a=this.animation.zoom)!=null&&a.stop)&&(this.animation.zoom.stop(),this.animation.zoom=null),this.animation.wheelZoomTarget=Ei(this.options.zoom,e),this.animation.wheelZoomPivotPoint=i,this.animation.wheelZoomPivotPixel=n,this.animation.wheelZoomFrame!=null)return;const o=this;function s(l){const h=o.animation.wheelZoomTarget;if(!Number.isFinite(h)){Ie(o.animation);return}const c=o.timescaleManager.zoom,d=h-c,g=o.animation.wheelZoomPivotPoint,f=o.animation.wheelZoomPivotPixel;if(Math.abs(d)<=uo){o.setZoomByPivotPoint(h,g,f),o.requestRedraw(o.repositionRedraw),Ie(o.animation);return}const m=o.animation.wheelZoomLastFrameTime,b=m==null?fo:l-m;o.animation.wheelZoomLastFrameTime=l;const A=wo(o.options.zoom,b),p=c+d*A;o.setZoomByPivotPoint(p,g,f),o.requestRedraw(o.repositionRedraw),o.animation.wheelZoomFrame=requestAnimationFrame(s)}this.animation.wheelZoomFrame=requestAnimationFrame(s)},u.prototype.setZoom=function(e,i,n=0){var r,a;(r=this.stopPanAnimation)==null||r.call(this),(a=this.stopZoomAnimation)==null||a.call(this);const o=i==null?this.width/2:i,s=n?Math.round(n):0;this.setZoomByPivotPixel(e,o,s),this.requestRedraw()},u.prototype.setZoomByPivotPixel=function(e,i,n=0){this.setZoomByPivotPoint(e,this.getPivotPoint(i),i,n)},u.prototype.setZoomByPivotPoint=function(e,i,n,o=0){this.timescaleManager.setZoom(e);const s=this.timescaleManager.setStartDate(i.date);this.repositionWindow=s-i.fraction,this.updateFromByPixels(-n+o)},u.prototype.getPivotPoint=function(e){let i=this.timescaleManager.getStartTokenCloned(),n=this.repositionWindow;n>=0&&(i=this.timescaleManager.getPrevious(i),n-=i.length);let o=i;for(;n<=e;)n+=i.length,o=i,i=this.timescaleManager.getNext(i);const s=o.unit,r=o.length;let a=e-(n-i.length);const l=o.value;let{year:h,month:c,day:d}=l;if(s===J)d=Math.floor(a/r*30.44)+1,a-=(d-1)*r/30.44,o.value=new y(h,c,d);else if(s!==K){const g=this.timescaleManager.unitLengthInYears;let f=Math.floor(a*365.2422*g/r)+1,m=0;f>365&&(m=Math.floor(f/365),f=f-365*m),a=0,o.value=y.getByDayOfYear(h+m,f)}return{date:o.value,fraction:a}},u.prototype.startAnimation=function(t){this.isAnimating||(this.isAnimating=!0,this.animation.redrawFunction=t,this.drawAnimationFrame())},u.prototype.stopAnimation=function(){this.isAnimating=!1,this.animation.dragRedrawFunction=this.repositionRedraw,this.animation.redrawFunction=!1},u.prototype.areAnimationsFinished=function(){return!(this.isDragging||this.isPanning||this.isPinching||this.draggingArticle!==null||this.isAnimatingArticles||this.isCustomAnimating)},u.prototype.drawAnimationFrame=function(){if(this.areAnimationsFinished())return this.stopAnimation();const t=this,e=this.getAnimationRedrawFunction();this.updateRedrawRequests(e),requestAnimationFrame(function(i){e.call(t),t.drawAnimationFrame()})},u.prototype.requestRedraw=function(t){t=t||this.defaultRedraw;const e=this;if(!this.isAnimating)return t.call(e);t===this.defaultRedraw&&(this.redrawRequests.default=!0),t===this.repositionRedraw&&(this.redrawRequests.reposition=!0)},u.prototype.updateRedrawRequests=function(t){t===this.defaultRedraw&&(this.redrawRequests.default=!1,this.redrawRequests.reposition=!1),t===this.repositionRedraw&&(this.redrawRequests.reposition=!1)},u.prototype.getAnimationRedrawFunction=function(){return this.isDragging?this.animation.dragRedrawFunction:this.isPanning||this.isPinching?this.defaultRedraw:this.redrawRequests.default?this.defaultRedraw:this.redrawRequests.reposition?this.repositionRedraw:this.animation.redrawFunction||this.animation.defaultRedrawFunction},u.prototype.stopPanAnimation=function(){var t;(t=this.animation.pan)!=null&&t.stop&&this.animation.pan.stop(),this.animation.pan=null,this.isPanning=!1},u.prototype.stopZoomAnimation=function(){var t;(t=this.animation.zoom)!=null&&t.stop&&this.animation.zoom.stop(),this.animation.zoom=null,this.animation.wheelZoomFrame!=null&&cancelAnimationFrame(this.animation.wheelZoomFrame),this.animation.wheelZoomTarget=null,this.animation.wheelZoomPivotPoint=null,this.animation.wheelZoomPivotPixel=null,this.animation.wheelZoomLastFrameTime=null,this.animation.wheelZoomFrame=null},u.prototype.switchToPositiveRepositionWindow=function(){if(this.repositionWindow<0){let t=this.timescaleManager.startToken;this.repositionWindow=t.length+this.repositionWindow,t=this.timescaleManager.getNext(t),this.timescaleManager.setStartToken(t)}},u.prototype.zoomToAnim=function(t,e){this.stopPanAnimation(),this.stopZoomAnimation();const i=this.timescaleManager.zoom,n=2e3,o=O.swing,s=this,r=z({from:i,to:t,duration:n,easing:o,onUpdate(a){s.setZoomByPivotPixel(a,s.width/2),s.requestRedraw()},onComplete(){typeof e=="function"&&e.call(s)}});this.animation.zoom=r},u.prototype.goToPixelAnim=function(t,e={}){var a;this.stopPanAnimation(),this.stopZoomAnimation(),this.isPanning=!0;const i=1e8;let n=!1;Math.abs(t)>i&&(t=Math.sign(t)*i,n=!0),this.startAnimation();let o=0;const s=this,r=z({from:0,to:t,duration:(a=e.duration)!=null?a:2e3,easing:O[e.easing]||O.swing,onUpdate(l){const h=l-o;o=l,s.updateFromByPixels(h),s.isPinching?(s.isPanning=!1,r.stop()):s.requestRedraw()},onComplete(){var l;n&&e.targetDmy&&s.setStartDate(e.targetDmy),s.isPanning=!1,(l=e.complete)==null||l.call(s)}});this.animation.pan=r},u.prototype.goToDateAnim=function(t,e={}){this.switchToPositiveRepositionWindow(),this.getDmyFromInput(t);const i=this.timescaleManager.startToken.value;let n=this.repositionWindow-this.timescaleManager.getPixelsBetween(t,i);e.offsetX&&(n-=e.offsetX),e.targetDmy=t,this.goToPixelAnim(n,e)},u.prototype.repositionWithAnim=function(t){const e=this.getOriginalPosition(t);t.registeredPosition=e;const i={left:e.left+t.dragFinishOffset.left,top:e.top+t.dragFinishOffset.top};t.moveToWithAnim(i)},u.prototype.notifyArticleAnimating=function(t,e){const i=new Date().getTime(),n=this.options.article.animation[t].duration,o=i+n;o>this.lastAnimatingArticle.endTime&&(this.lastAnimatingArticle.id=e,this.lastAnimatingArticle.endTime=o,this.lastAnimatingArticle.animationType=t),this.isAnimatingArticles=!0,this.startAnimation()},u.prototype.toggleAutoFit=function(){const t=this.options.article.autoStacking.fitToHeight=!this.options.article.autoStacking.fitToHeight;return t&&this.fitToHeight(!0),t},u.prototype.fitToHeight=function(t){if(this.topRow+1===1)return;const i=this.options.article.autoStacking.rowSpacing=this.getFitToHeightRowSpacing();return t&&this.requestRedraw(),i},u.prototype.getFitToHeightRowSpacing=function(){const t=this.top-this._getTimelineDistanceToBaseline(),e=this._getResolvedArticleTopGap(),i=this.topRow;if(i===0)return!1;const n=Math.abs(t-e);return Math.max(Math.round(n/i),1)},u.prototype.incrementRowSpacing=function(t,e){return this.options.article.rowSpacing=Math.max(this.options.article.rowSpacing+t,1),e&&this.requestRedraw(),this.options.article.rowSpacing};function zi(t=0){var e,i;return typeof t=="number"?{left:t,right:t}:{left:(e=t==null?void 0:t.left)!=null?e:0,right:(i=t==null?void 0:t.right)!=null?i:0}}function Tt(t){var e,i;if(!t||!Number.isFinite(t.year))throw new Error("fitDateRange requires start and end dates with a numeric year");return new y({year:t.year,month:(e=t.month)!=null?e:1,day:(i=t.day)!=null?i:1})}function xt(t){return new y(t===-1?1:t+1,1,1)}function bo(t,e){return e===12?xt(t):new y(t,e+1,1)}function Ni(t){const e=Tt(t),i=t.month!=null,n=t.day!=null;return i?n?{start:e,end:Tt(t)}:{start:e,end:bo(t.year,t.month)}:{start:e,end:xt(t.year)}}function xi(t,e){return Math.max(1,t.getWidth()-e.left-e.right)}function _o(t,e){var s,r;const i=(s=t.zoomOptions)==null?void 0:s.minimum,n=(r=t.zoomOptions)==null?void 0:r.maximum;let o=e;return Number.isFinite(i)&&o<i&&(o=i),Number.isFinite(n)&&o>n&&(o=n),o}function Bi(t,e){return Number.isFinite(e)?parseFloat(_o(t,e).toFixed(4)):e}function vo(t,e){const i=t.unitLevels;if(!Array.isArray(i)||i.length===0)return t.unit;for(let n=i.length-1;n>=0;n--)if(e>=i[n].zoomStart)return n;return t.unit}function Lo(t,e,i){var r,a;const n=(r=t.unitLevels)==null?void 0:r[e],o=(a=t.zoomOptions)==null?void 0:a.ratio;if(n&&Number.isFinite(n.startUnitSize)&&Number.isFinite(n.zoomStart)&&Number.isFinite(o)&&o>0)return n.startUnitSize*Math.pow(o,i-n.zoomStart);if(!Number.isFinite(t.unitSizeInPixels))return NaN;const s=i-t.zoom;return t.scaleDistanceByZoomChange?t.scaleDistanceByZoomChange(t.unitSizeInPixels,s):NaN}function Ao(t){return t>=rt?Math.pow(10,t-rt):0}function Io(t,e,i,n){const o=Bi(t,n),s=vo(t,o),r=Lo(t,s,o);return!Number.isFinite(r)||r<=0?NaN:s<=K?e.getDaysTo(i)*r:s===J?e.getMonthsTo(i)*r:e.getYearsTo(i)*r/Ao(s)}function Fi(t,e,i,n){const o=t.timescaleManager,s=o.getPixelsBetween(e,i);if(!Number.isFinite(s)||s<=0)return o.zoom;const r=xi(t,n),a=o.getZoomChangeByDistance(s,r);if(!Number.isFinite(a))return o.zoom;let l=o.zoom+a;for(let h=0;h<4;h++){const c=Io(o,e,i,l);if(!Number.isFinite(c)||c<=0)break;const d=o.getZoomChangeByDistance(c,r);if(!Number.isFinite(d)||(l+=d,Math.abs(d)<5e-5))break}return Bi(o,l)}function Co(t,e,i,n){return Fi(t,t.getDmyFromInput(Tt(e)),t.getDmyFromInput(Tt(i)),n)}function Hi(t){const e=t.timescaleManager,i=e.unitSizeInPixels;if(!Number.isFinite(i)||i<=0)return 0;if(e.unit==null||e.unit<=K)return i;if(e.unit===J)return i/30.44;const n=Number.isFinite(e.unitLengthInYears)&&e.unitLengthInYears>0?e.unitLengthInYears:1;return i/(365.2422*n)}function Wi(t,e,i,n=!1){const o=Math.floor(e),s=Ce(o),r=(e-o)*Hi(t),a=t.timescaleManager.setStartDate(s);t.repositionWindow=a-r,i&&t.updateFromByPixels(-i),t.requestRedraw(),n&&t._emitTimelineStateChange()}function So(t,e,i,n=!1){const o=at(e);Wi(t,o,i,n)}function To(t,e){const i=Hi(t);return i?at(e.date)+e.fraction/i:at(e.date)}function Yi(t,e){return To(t,t.getPivotPoint(e))}function at(t){return t.getDaysSinceYearZero()}function Ce(t){const e=Math.floor(t);let i=Math.floor(e/365.2422),n=at(new y(i,1,1)),o=at(xt(i));for(;n>e;)i-=1,n=at(new y(i,1,1)),o=at(xt(i));for(;o<=e;)i=i===-1?1:i+1,n=o,o=at(xt(i));return y.getByDayOfYear(i,e-n+1)}function Se(t,e,i){return t+(e-t)*i}function Do(t,e,i,n,o){return i<=e?o:Fi(t,Ce(e),Ce(i),n)}function Mo(t){var e,i,n,o,s;typeof t.stopPanAnimation=="function"?t.stopPanAnimation():(t.isPanning&&((i=(e=t.animation)==null?void 0:e.pan)!=null&&i.stop)&&t.animation.pan.stop(),t.isPanning=!1),typeof t.stopZoomAnimation=="function"?t.stopZoomAnimation():((o=(n=t.animation)==null?void 0:n.zoom)!=null&&o.stop&&t.animation.zoom.stop(),((s=t.animation)==null?void 0:s.wheelZoomFrame)!=null&&cancelAnimationFrame(t.animation.wheelZoomFrame),t.animation&&(t.animation.zoom=null,t.animation.wheelZoomTarget=null,t.animation.wheelZoomPivotPoint=null,t.animation.wheelZoomPivotPixel=null,t.animation.wheelZoomLastFrameTime=null,t.animation.wheelZoomFrame=null))}function Ro(t,e,i,n,o,s={}){var A;Mo(t),t.switchToPositiveRepositionWindow(),t.isPanning=!0,t.startAnimation();const r=t.timescaleManager.zoom,a=xi(t,o),l=Yi(t,o.left),h=Yi(t,o.left+a),c=t.getDmyFromInput(Tt(e)),d=t.getDmyFromInput(Tt(i)),g=at(c),f=at(d),m=h>l&&f>g,b=z({from:0,to:1,duration:(A=s.duration)!=null?A:2e3,easing:O[s.easing]||O.swing,onUpdate(p){if(t.isPinching){t.isPanning=!1,b.stop();return}const _=Se(l,g,p);let w=r;p>0&&(w=m?Do(t,_,Se(h,f,p),o,t.timescaleManager.zoom):Se(r,n,p)),w!==t.timescaleManager.zoom&&t.timescaleManager.setZoom(w),Wi(t,_,o.left)},onComplete(){n!==t.timescaleManager.zoom&&t.timescaleManager.setZoom(n),So(t,c,o.left,!0),t.isPanning=!1}});t.animation.pan=b}function Po(t,e){var a,l,h,c;const i=t.articles||[];let n=null,o=null,s=0,r=0;for(let d=0;d<i.length;d++){const g=i[d];if(!e(g)||!((a=g.period)!=null&&a.from))continue;const f=g.period.from;(!n||f.compare(n)<0)&&(n=f),(!o||f.compare(o)>0)&&(o=f);const m=g._getCurrentStyle(),b=(h=(l=m.connectorLine)==null?void 0:l.offsetX)!=null?h:0,A=(c=m.width)!=null?c:0;s=Math.max(s,b),r=Math.max(r,A-b)}return n?{earliest:n,latest:o,maxCardLeftOffset:s,maxCardRightOffset:r}:null}u.prototype.setStartDate=function(t,e){e=e||0,typeof t=="string"&&(t=y.fromString(t)),t=this.getDmyFromInput(t);const i=this.timescaleManager.setStartDate(t);this.repositionWindow=i,e&&this.updateFromByPixels(-e),this.requestRedraw(),this._emitTimelineStateChange()},u.prototype.getZoom=function(){return this.timescaleManager.zoom},u.prototype.setCentreDate=function(t,e){this.setStartDate(t,this.getWidth()/2+e)},u.prototype.fitDateRange=function(e,i,n={}){var c;const o=zi(n.padding);let s=Ni(e),r=Ni(i);s.start.compare(r.start)>0&&([s,r]=[r,s]);const a=s.start,l=r.end,h=Co(this,a,l,o);if((c=n.animation)!=null&&c.active){Ro(this,a,l,h,o,n.animation);return}h!==this.timescaleManager.zoom&&this.setZoom(h),this.setStartDate(a,o.left)},u.prototype.fitArticleRange=function(e,i={}){var n;return!((n=e==null?void 0:e.period)!=null&&n.from)||!e.period.to?!1:(this.fitDateRange(e.period.from,e.period.to,{padding:i.padding,animation:i.animation}),!0)},u.prototype.fitArticles=function(e={}){var r;const i=e.articleFilter||function(l){return!l.hiddenByFilter},n=Po(this,i);if(!n)return!1;const o=zi((r=e.padding)!=null?r:40),s={left:o.left+n.maxCardLeftOffset,right:o.right+n.maxCardRightOffset};return this.fitDateRange(n.earliest,n.latest,{padding:s,animation:e.animation}),!0},u.prototype.on=function(t,e){if(typeof t=="object")return this.onMultiple(t);this.handlers[t]||(this.handlers[t]=[]),this.handlers[t].push(e)},u.prototype.trigger=function(t,...e){if(!this.handlers[t])return;const i=this.handlers[t];for(let n=0;n<i.length;n++)i[n].call(this,...e)},u.prototype.onMultiple=function(t){for(const e in t)this.on(e,t[e])},u.prototype.off=function(t,e){if(typeof t=="object")return this.offMultiple(t);this.handlers[t]&&(this.handlers[t]=this.handlers[t].filter(i=>i!==e))},u.prototype.offMultiple=function(t){for(const e in t)this.off(e,t[e])};function ie(t){return Math.round(t)}function Oo(t,e=1){const i=typeof e=="number"&&isFinite(e)&&e>0?e:1;return Math.round(t*i)/i}function ko(t){return t}function Zi(t=1,e="device"){return e===!1||e==="none"?ko:e==="css"?ie:function(n){return Oo(n,t)}}function Eo(t,e,i){i||(i=ie);const n=e/2;return{left:i(t.left+n),top:i(t.top+n),width:i(t.width-e),height:i(t.height-e)}}function Te(t){var n,o,s,r,a,l;const e=((o=(n=t.owner)==null?void 0:n.getCanvasDpr)==null?void 0:o.call(n))||1,i=(l=(a=(r=(s=t.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.rendering)==null?void 0:l.pixelSnap;return Zi(e,i)}function De(t){const e=Te(t);return{top:e(t.position.top),left:e(t.position.left)}}const zo={name:"landscape",draw(t){var G,W,Y,$;if(!this.isDataLoaded||isNaN(this.position.left))return;const e=this._getCurrentStyle(),i=Te(this),n=De(this),o=n.top,s=n.left,r=e.width,a=e.height,l=e.backgroundColor||"#FFF",h=e.shadow,c=e.borderRadius||0;di(t,h),t.fillStyle=l,c>0?(Jt(t,s,o,r,a,c),t.fill()):t.fillRect(s,o,r,a),Ai(t);let d=s,g=r;if(this.imageLoaded){const T=e.image,E=T.margin,N=s+E,pt=o+E,ot=a-E*2;let Rt,Pt,Ot,se;this.image.width>this.image.height?(Rt=ie((this.image.width-this.image.height)/2),Pt=0,Ot=se=this.image.height):(Rt=0,Pt=0,Ot=se=this.image.width);const Ho=T.shape||"square",Vi=T.borderRadius||0,Ui=(Ht,Wt,Yt,re,Zt,Me,Re,Pe)=>{Vi>0?(t.save(),Jt(t,Zt,Me,Re,Pe,Vi),t.clip(),t.drawImage(this.image,Ht,Wt,Yt,re,Zt,Me,Re,Pe),t.restore()):t.drawImage(this.image,Ht,Wt,Yt,re,Zt,Me,Re,Pe)};switch(Ho){case"circle":{Ti(t,this.image,Rt,Pt,Ot,se,N,pt,ot);break}case"square":{Ui(Rt,Pt,Ot,se,N,pt,ot,ot);break}default:{const Ht=Math.min(ot/this.image.width,ot/this.image.height),Wt=i(this.image.width*Ht),Yt=i(this.image.height*Ht),re=i(N+(ot-Wt)/2),Zt=i(pt+(ot-Yt)/2);Ui(0,0,this.image.width,this.image.height,re,Zt,Wt,Yt);break}}d=s+ot+E,g=r-ot-E}const f=(($=(Y=(W=(G=this.owner)==null?void 0:G.options)==null?void 0:W.article)==null?void 0:Y.star)==null?void 0:$.visible)!==!1&&(this.isActive||this.isStarred);if(f){const T=e.star.width,E=e.star.margin,N=T+E;g=Math.max(0,g-N)}const m=e.header.text,b=m.margin,A=m.lineHeight,p=d+b,_=g-b*2,w=m.offsetY||0,S=this.title,M=m.numberOfLines,F=this.memo(`titleLines:${S}:${_}:${m.font}:${M}`,()=>{t.font=m.font;let T=Qt(S,t,_);return T.length>M&&(T=te(T,M,t,_)),T}),D=F.length,x=this.memo(`headerMetrics:${m.font}`,()=>(t.font=m.font,t.measureText("Hg"))).actualBoundingBoxAscent,X=`${this.subtitle}`,H=e.subheader.text,et=H.font,Dt=H.margin,_t=d+Dt,it=g-Dt*2,vt=H.offsetY||0,R=this.memo(`subtitle:${X}:${it}:${et}`,()=>{t.font=et;const T=Qt(X,t,it);return T.length>1?te(T,1,t,it)[0]:T[0]}),V=this.memo(`subheaderMetrics:${et}`,()=>(t.font=et,t.measureText("Hg"))),U=V.actualBoundingBoxAscent,mt=V.actualBoundingBoxDescent,Ft=D*A,nt=U+mt,lt=Ft+nt;let ht=i(o+(a-lt)/2)+x+w;t.font=m.font,t.fillStyle=m.color,t.textAlign=m.align,t.textBaseline=m.baseline;for(let T=0;T<F.length;T++)t.fillText(F[T],p,ht,_),ht+=A;ht+=vt,t.font=H.font,t.fillStyle=H.color,t.textAlign=H.align,t.textBaseline=H.baseline,t.fillText(R,_t,ht,it);const Mt=e.border;if(Mt.width>0&&(t.strokeStyle=Mt.color,t.lineWidth=Mt.width,c>0?(Jt(t,s,o,r,a,c),t.stroke()):t.strokeRect(s,o,r,a)),f){const T=this.getIconBox();let E,N;this.isStarred?this.isMouseOverStar?(E="#8A8A8A",N="#fff800"):(E="#a5a5a5",N="#fff800"):this.isMouseOverStar?(E="#8A8A8A",N="#dfdfdf"):(E="#a5a5a5",N="#ebebeb"),Ci(t,T.centreX,T.centreY,5,T.innerRadius,T.outerRadius,N,E)}},getWidth(){return this._getCurrentStyle().width},getHeight(){return this._getCurrentStyle().height},getConnectorEnd(){const t=this._getCurrentStyle(),e=De(this);return{left:e.left+t.connectorLine.offsetX,top:e.top+this.getHeight()+t.connectorLine.offsetY}},getIconBox(){var r,a,l,h;if(((h=(l=(a=(r=this.owner)==null?void 0:r.options)==null?void 0:a.article)==null?void 0:l.star)==null?void 0:h.visible)===!1)return!1;const t=this._getCurrentStyle(),e=Te(this),i=t.star.width,n={width:i,height:i},o=t.borderRadius||0,s=De(this);return n.left=e(s.left-o/4+this._getWidth()-n.width-t.star.margin),n.top=e(s.top+o/4+t.star.margin),n.centreX=e(n.left+n.width/2),n.centreY=e(n.top+n.height/2),n.outerRadius=e(n.width/2),n.innerRadius=e(n.outerRadius/2),n},defaultStyle:{width:220,height:70,borderRadius:4,image:{shape:"square",margin:4,borderRadius:4},header:{text:{color:"#333",baseline:"alphabetic"}},subheader:{text:{color:"#777",baseline:"alphabetic"}}},defaultHoverStyle:{border:{color:"#a6c6e2"}},defaultActiveStyle:{header:{text:{color:"#000"}},subheader:{text:{color:"#333"}}}};function Bt(t){var n,o,s,r,a,l;const e=((o=(n=t.owner)==null?void 0:n.getCanvasDpr)==null?void 0:o.call(n))||1,i=(l=(a=(r=(s=t.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.rendering)==null?void 0:l.pixelSnap;return Zi(e,i)}function ne(t){const e=Bt(t);return{top:e(t.position.top),left:e(t.position.left)}}const No={name:"portrait",draw(t){var x,X,H,et,Dt,_t,it,vt;const e=this._getCurrentStyle(),i=Bt(this),n=e.border.width,o=Math.max(n,((X=(x=this.hoverStyle)==null?void 0:x.border)==null?void 0:X.width)||0,((et=(H=this.activeStyle)==null?void 0:H.border)==null?void 0:et.width)||0),s=e.header.height,r=e.subheader.height,a=ne(this),l={top:a.top,left:a.left,width:i(this._getWidth()),height:i(this._cachedHeight)},h=i(l.top+n/2),d=i(h+s),g=d+r,f=Eo(l,o,i);e.shadow&&(di(t,e.shadow),t.fillStyle=e.backgroundColor,t.fillRect(l.left,l.top+e.topRadius,l.width,l.height-e.topRadius),Ai(t)),t.save(),t.beginPath(),Ii(t,l.left,l.top,l.width,l.height,e.topRadius),t.clip(),t.fillStyle=e.color,t.fillRect(l.left,l.top,l.width,i(s+n/2)),t.restore(),r!==0&&(t.fillStyle=e.subheader.color,t.fillRect(l.left,d,l.width,r),t.beginPath(),t.lineWidth=1,t.moveTo(f.left+5,d+1),t.lineTo(f.left+10,d-5),t.lineTo(f.left+15,d+1),t.closePath(),t.fill());const m=e.header.text.align;t.fillStyle=e.header.text.color,t.font=e.header.text.font,t.textAlign=m,t.textBaseline=e.header.text.baseline;const b=e.header.text.margin,A=e.header.text.lineHeight,p=f.width-b*2,_=e.header.text.numberOfLines,w=this.memo(`titleLines:${this.title}:${p}:${e.header.text.font}:${_}`,()=>{t.font=e.header.text.font;let R=Qt(this.title,t,p);return R.length>_&&(R=te(R,_,t,p)),this.titleLines=R,R}),S=Math.min(_,w.length),M=(S-1)*A,D=h+(s-M)/2,q=Si(f.left,f.width,m,b,i);for(let R=0;R<S;R++){const V=i(D+R*A);t.fillText(w[R],q,V,p)}if(e.subheader.height!==0){const R=e.subheader.text.align,V=e.subheader.text.margin,U=f.width-V*2;t.textAlign=R,t.textBaseline=e.subheader.text.baseline,t.fillStyle=e.subheader.text.color,t.font=e.subheader.text.font;const mt=`${this.subtitle}`,Ft=this.memo(`subtitle:${mt}:${U}:${e.subheader.text.font}`,()=>{t.font=e.subheader.text.font;const Lt=Qt(mt,t,U),ht=Lt.length>1?te(Lt,1,t,U)[0]:Lt[0];return this.summarisedSubtitle=ht,ht}),nt=Si(f.left,f.width,R,V,i),lt=i(d+r/2);t.fillText(Ft,nt,lt,U)}if(this.imageLoaded){const R=e.image,V=R.margin||0,U=i(l.left+V),mt=i(g+V),Ft=Math.max(0,l.width-V*2),nt=i(Ft);let lt;const Lt=R.shape||"square";switch(Lt){case"circle":case"square":lt=nt;break;default:const G=nt/this.image.width,W=this.image.height*G,Y=R.maxHeight||e.maxImageHeight||400;lt=Math.min(W,Y);break}lt=i(lt),t.fillStyle=e.backgroundColor,t.fillRect(U,mt,nt,lt);const ht=R.borderRadius||0,Mt=(G,W,Y,$,T,E,N,pt)=>{ht>0?(t.save(),Jt(t,T,E,N,pt,ht),t.clip(),t.drawImage(this.image,G,W,Y,$,T,E,N,pt),t.restore()):t.drawImage(this.image,G,W,Y,$,T,E,N,pt)};switch(Lt){case"circle":{let G,W,Y,$;this.image.width>this.image.height?(G=(this.image.width-this.image.height)/2,W=0,Y=$=this.image.height):(G=0,W=(this.image.height-this.image.width)/2,Y=$=this.image.width);const T=nt,E=U,N=mt;Ti(t,this.image,G,W,Y,$,E,N,T);break}case"square":{let G,W,Y,$;this.image.width>this.image.height?(G=(this.image.width-this.image.height)/2,W=0,Y=$=this.image.height):(G=0,W=(this.image.height-this.image.width)/2,Y=$=this.image.width);const T=nt;Mt(G,W,Y,$,U,mt,T,T);break}default:{const G=nt/this.image.width,W=this.image.height*G,Y=R.maxHeight||e.maxImageHeight||400,$=0;let T=0;const E=this.image.width;let N=this.image.height;const pt=nt,ot=lt,Rt=U,Pt=mt;if(W>Y){const Ot=Y/W;N=this.image.height*Ot,T=ie((this.image.height-N)/2)}Mt($,T,E,N,Rt,Pt,pt,ot);break}}}if(e.border.width>0&&(t.beginPath(),Ii(t,l.left,l.top,l.width,l.height,e.topRadius),t.lineWidth=e.border.width,t.strokeStyle=e.border.color,t.stroke()),((vt=(it=(_t=(Dt=this.owner)==null?void 0:Dt.options)==null?void 0:_t.article)==null?void 0:it.star)==null?void 0:vt.visible)!==!1&&(this.isActive||this.isStarred)){const R=xo(this);let V,U;this.isStarred?this.isMouseOverStar?(V="#8A8A8A",U="#fff800"):(V="#a5a5a5",U="#fff800"):this.isMouseOverStar?(V="#8A8A8A",U="#dfdfdf"):(V="#a5a5a5",U="#ebebeb"),Ci(t,R.centreX,R.centreY,5,R.innerRadius,R.outerRadius,U,V)}},getWidth(){return this._getCurrentStyle().width},getHeight(){const t=this._getCurrentStyle(),e=Bt(this);let i=0;if(this.imageLoaded){const o=t.image,s=o.margin||0,r=o.shape||"square",a=e(t.width-t.border.width/2-s*2);switch(r){case"circle":case"square":i=a+s*2;break;default:const l=a/this.image.width,h=this.image.height*l,c=t.image.maxHeight||t.maxImageHeight||400;i=Math.min(h,c)+s*2;break}}const n=e(t.header.height+t.subheader.height);return i+n+t.border.width},getConnectorEnd(){const t=this._getCurrentStyle(),e=ne(this);return{left:e.left+t.connectorLine.offsetX,top:e.top+this.getHeight()+t.connectorLine.offsetY}},getIconBox(){var s,r,a,l;if(((l=(a=(r=(s=this.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.star)==null?void 0:l.visible)===!1)return!1;const t=this._getCurrentStyle(),e=Bt(this),i=ne(this),n=t.star.width,o={width:n,height:n};return o.left=e(i.left-t.topRadius/4+this._getWidth()-o.width-t.star.margin),o.top=e(i.top+t.topRadius/4+t.star.margin),o}};function xo(t){const e=t._getCurrentStyle(),i=Bt(t),n=ne(t),o=e.star.width,s={width:o,height:o};return s.left=i(n.left-e.topRadius/4+t._getWidth()-s.width-e.star.margin),s.top=i(n.top+e.topRadius/4+e.star.margin),s.centreX=i(s.left+s.width/2),s.centreY=i(s.top+s.height/2),s.outerRadius=i(s.width/2),s.innerRadius=i(s.outerRadius/2),s}const oe=new Map;function Bo(t){return typeof t.getWidth!="function"&&(t.getWidth=function(){return this._getCurrentStyle().width}),typeof t.getHeight!="function"&&(t.getHeight=function(){return this._getCurrentStyle().height}),typeof t.getIconBox!="function"&&(t.getIconBox=function(){return!1}),t}function Fo(t){return t&&t.aliasOf?oe.get(t.aliasOf):t}return u.registerCardLayout=function(e){if(!e||typeof e!="object")throw new Error("Card layout definition must be an object");const{name:i,draw:n,aliasOf:o}=e;if(!i||typeof i!="string")throw new Error("Card layout must have a unique string 'name'");if(o){oe.set(i,{aliasOf:o});return}if(typeof n!="function")throw new Error(`Card layout "${i}" must implement draw(ctx)`);oe.set(i,Bo(ct({},e)));const{defaultStyle:s,defaultHoverStyle:r,defaultActiveStyle:a}=e,l=hi.article.layoutStyles[i]={};s&&(l.style=ue({},s)),r&&(l.hoverStyle=ue({},r)),a&&(l.activeStyle=ue({},a))},u.getCardLayout=function(e){const i=Fo(oe.get(e));return i||(P.warn(`Unknown card layout "${e}"`),null)},u.prototype._getCurrentCardLayoutName=function(){return this.options.article.defaultCardLayout},u.prototype.registerCardLayout=u.registerCardLayout,u.prototype.getCardLayout=u.getCardLayout,u.registerCardLayout(No),u.registerCardLayout(zo),u.registerCardLayout({name:"default",aliasOf:"portrait"}),u.prototype.getStatusForSave=function(){const t=this.timescaleManager.startToken.value,e=[];for(let i=0;i<this.articles.length;i++)e.push(this.articles[i].getStatusForSave());return JSON.stringify({t:this.title,o:this.ownerId,z:this.timescaleManager.zoom,fy:t.year,fm:t.month,fd:t.day,w:this.repositionWindow,a:e})},u.prototype._emitTimelineStateChange=function(){this&&this._isInitialized===!0&&this.trigger("timeline-state-change",this.getStatusForSave())},$i(ct(ct({Timeline:u,Article:L,Lane:Z,TimeBand:ft,Dmy:y},Ki),hn),{Logger:P,setDebug(t){P.setEnabled(!!t)},isDebugEnabled(){return P.isEnabled()},enableDebug(){P.setEnabled(!0)},disableDebug(){P.setEnabled(!1)}})}));