Month
The leap day will be added to this month.
`,o=W(),l=B("div"),s=B("select");for(let N=0;Nt[15].call(s)),D(l,"class","setting-item-control"),D(r,"class","setting-item"),D(e,"class","fantasy-calendar-nested-settings"),D(y,"class","buttons svelte-n1tx0h")},m(N,F){R(N,e,F),te(n,e,null),C(e,a),C(e,r),C(r,i),C(r,o),C(r,l),C(l,s);for(let j=0;j{let T=new xs(c,u.interval.length>0,x);T.onClose=()=>{!T.saved||!T.condition.interval||(x?u.interval.splice(u.interval.indexOf(x),1,T.condition):u.interval.push(T.condition),n(0,u))},T.open()},v=x=>{let T=[`${x.interval}`];return x.exclusive&&T.push("(Exclusive)"),x.ignore&&T.push(" - Ignoring Offset"),T.join(" ")},h=x=>{new Cr.ExtraButtonComponent(x).setIcon("pencil")},y=x=>{new Cr.ExtraButtonComponent(x).setIcon("trash")},p=x=>{new Cr.ButtonComponent(x).setButtonText("Cancel").setCta()},S=x=>n(0,u.name=x.detail,u);function _(){u.timespan=mn(this),n(0,u)}let A=x=>n(0,u.intercalary=!u.intercalary,u),L=()=>n(0,u.numbered=!u.numbered,u);function k(){u.after=mn(this),n(0,u)}let E=x=>n(0,u.offset=x.detail,u),w=()=>m(),N=x=>m(x),F=x=>n(0,u.interval=u.interval.filter(T=>T!=x),u),j=()=>s("cancel");return t.$$set=x=>{"app"in x&&n(11,c=x.app),"leapDay"in x&&n(0,u=x.leapDay),"calendar"in x&&n(12,d=x.calendar)},t.$$.update=()=>{if(t.$$.dirty[0]&1){e:n(4,a=u.intercalary)}if(t.$$.dirty[0]&4096){e:n(1,r=d.static.months)}if(t.$$.dirty[0]&3){e:n(13,i=r[u.timespan])}if(t.$$.dirty[0]&8192){e:n(3,o=i.length?[...Array(i.length).keys()].map(x=>x+1):[])}if(t.$$.dirty[0]&1){e:n(2,l=u.interval.sort((x,T)=>x.interval-T.interval))}},[u,r,l,o,a,s,m,v,h,y,p,c,d,i,S,_,A,L,k,E,w,N,F,j]}var _f=class extends de{constructor(e){super();he(this,e,T1,F1,le,{app:11,leapDay:0,calendar:12},k1,[-1,-1])}},Cf=_f;function S1(t){let e,n,a,r,i,o;return e=new kn({props:{type:"number",name:"Interval",desc:"How often the condition applies.",value:t[0].interval,warn:!t[0].interval}}),e.$on("blur",t[2]),a=new Ot({props:{disabled:!t[1],name:"Exclusive",desc:"If true, the leap day will not apply when the year meets the condition.\\n\\nRequires the leap day to have at least one non-exclusive condition.",value:t[0].exclusive}}),a.$on("click",t[3]),i=new Ot({props:{name:"Ignore Offset",desc:"The condition will ignore the leap day's offset when checking to apply.",value:t[0].ignore}}),i.$on("click",t[4]),{c(){ne(e.$$.fragment),n=W(),ne(a.$$.fragment),r=W(),ne(i.$$.fragment)},m(l,s){te(e,l,s),R(l,n,s),te(a,l,s),R(l,r,s),te(i,l,s),o=!0},p(l,[s]){let c={};s&1&&(c.value=l[0].interval),s&1&&(c.warn=!l[0].interval),e.$set(c);let u={};s&2&&(u.disabled=!l[1]),s&1&&(u.value=l[0].exclusive),a.$set(u);let d={};s&1&&(d.value=l[0].ignore),i.$set(d)},i(l){o||(P(e.$$.fragment,l),P(a.$$.fragment,l),P(i.$$.fragment,l),o=!0)},o(l){G(e.$$.fragment,l),G(a.$$.fragment,l),G(i.$$.fragment,l),o=!1},d(l){J(e,l),l&&q(n),J(a,l),l&&q(r),J(i,l)}}}function B1(t,e,n){let{canBeExclusive:a}=e,{condition:r}=e,i=s=>n(0,r.interval=s.detail,r),o=()=>a?n(0,r.exclusive=!r.exclusive,r):null,l=()=>n(0,r.ignore=!r.ignore,r);return t.$$set=s=>{"canBeExclusive"in s&&n(1,a=s.canBeExclusive),"condition"in s&&n(0,r=s.condition)},[r,a,i,o,l]}var Ef=class extends de{constructor(e){super();he(this,e,B1,S1,le,{canBeExclusive:1,condition:0})}},Af=Ef;var Fs=class extends lt{constructor(e,n,a){super(e);this.calendar=n;this.saved=!0;this.leapday={id:Ze(6),name:"Leap Day",interval:[],intercalary:!1,timespan:0,offset:0,type:"leapday"};a&&(this.leapday=(0,kf.default)(a),this.editing=!0),this.containerEl.addClasses(["fantasy-calendar-create-leapday"])}async display(){this.titleEl.setText(this.editing?"Edit Leap Day":"New Leap Day"),new Cf({target:this.contentEl,props:{leapDay:this.leapday,calendar:this.calendar,app:this.app}}).$on("cancel",()=>{this.saved=!1,this.close()})}async onOpen(){await this.display()}},xs=class extends lt{constructor(e,n,a){super(e);this.app=e;this.canBeExclusive=n;this.saved=!0;this.editing=!1;this.condition={interval:null,exclusive:!1,ignore:!1};a&&(this.condition={...a},this.editing=!0)}onOpen(){this.containerEl.addClasses(["fantasy-calendar-nested-settings"]),this.contentEl.empty(),this.titleEl.setText("Leap Day Condition"),new Af({target:this.contentEl,props:{canBeExclusive:this.canBeExclusive,condition:this.condition}}),this.buttonsEl=this.contentEl.createDiv("fantasy-context-buttons setting-item"),new Va.ButtonComponent(this.buttonsEl).setCta().setButtonText("Cancel").onClick(()=>{this.saved=!1,this.close()})}old(){new Va.Setting(this.contentEl).setName("Interval").setDesc("How often the condition applies.").addText(e=>{e.inputEl.setAttr("type","number"),e.setValue(`${this.condition.interval}`).onChange(n=>{isNaN(Number(n))||(this.condition.interval=Number(n))})}),new Va.Setting(this.contentEl).setName("Exclusive").setDesc(`If true, the leap day will not apply when the year meets the condition.
Requires the leap day to have at least one non-exclusive condition.`).addToggle(e=>e.setDisabled(!this.canBeExclusive).setValue(this.condition.exclusive).onChange(n=>this.condition.exclusive=n)),new Va.Setting(this.contentEl).setName("Ignore Offset").setDesc("The condition will ignore the leap day's offset when checking to apply.").addToggle(e=>e.setValue(this.condition.ignore).onChange(n=>this.condition.ignore=n))}};function xf(t,e,n){let a=t.slice();return a[11]=e[n],a}function N1(t){let e,n,a=t[0],r=[];for(let o=0;oG(r[o],1,1,()=>{r[o]=null});return{c(){e=B("div");for(let o=0;o{s[v]=null}),_e(),r=s[a],r?r.p(u,d):(r=s[a]=l[a](u),r.c()),P(r,1),r.m(i.parentNode,i))},i(u){o||(P(e.$$.fragment,u),P(r),o=!0)},o(u){G(e.$$.fragment,u),G(r),o=!1},d(u){J(e,u),u&&q(n),s[a].d(u),u&&q(i)}}}function O1(t){let e,n;return e=new ct({props:{name:"Leap Days",open:!1,desc:`${t[0].length} leap day${t[0].length!=1?"s":""}`,$$slots:{default:[I1]},$$scope:{ctx:t}}}),{c(){ne(e.$$.fragment)},m(a,r){te(e,a,r),n=!0},p(a,[r]){let i={};r&1&&(i.desc=`${a[0].length} leap day${a[0].length!=1?"s":""}`),r&16387&&(i.$$scope={dirty:r,ctx:a}),e.$set(i)},i(a){n||(P(e.$$.fragment,a),n=!0)},o(a){G(e.$$.fragment,a),n=!1},d(a){J(e,a)}}}function q1(t,e,n){let a,r,i,{plugin:o}=e,l=Ne("store");Fe(t,l,h=>n(10,a=h));let{leapDayStore:s,leapDayDisabled:c}=l;Fe(t,s,h=>n(0,r=h)),Fe(t,c,h=>n(1,i=h));let u=h=>{let y=new Fs(o.app,a,h);y.onClose=()=>{!y.saved||!y.leapday.interval.length||!y.leapday.name||(y.editing?s.update(h.id,{...y.leapday}):s.add({...y.leapday}))},y.open()},d=()=>u(),m=h=>u(h),v=h=>s.delete(h.id);return t.$$set=h=>{"plugin"in h&&n(6,o=h.plugin)},[r,i,l,s,c,u,o,d,m,v]}var Tf=class extends de{constructor(e){super();he(this,e,q1,O1,le,{plugin:6})}},Sf=Tf;var Nf=Ee(require("obsidian"));var R1=Ee(Nn());var Bf=Ee(require("obsidian"));var yA=Ee(require("obsidian"));function L1(t,e=ia){let n=pn(e),{subscribe:a,set:r,update:i}=n,o=et(n,T=>T.static),l=et(n,T=>T.current),{subscribe:s}=o,c=T=>i(I=>(I.static=T,I)),u=et(o,T=>T.months),d=et(o,T=>T.weekdays),m=et(o,T=>T.years),v=et(o,T=>T.useCustomYears),h=et(o,T=>T.moons),y=et(o,T=>T.displayMoons),p=et(o,T=>T.leapDays),S=et(n,T=>T.events),_=et(n,T=>T.categories),A=et(o,T=>T.months?.length&&T.months?.every(I=>I.name?.length)&&T.months?.every(I=>I.length>0)),L=et(o,T=>T.weekdays?.length&&T.weekdays?.every(I=>I.name?.length)&&T.firstWeekDay<(T.weekdays?.length??1/0)),k=et(o,T=>!T.useCustomYears||T.useCustomYears&&T.years?.length&&T.years.every(I=>I.name?.length)),E=et(n,T=>T.name?.length),w=et([n,l],([T,I])=>Da(I.day,T)),N=et([n,l],([T,I])=>_a(I.month,T)),F=et([n,l],([T,I])=>Ca(I.year,T)),j=et([w,N,F],([T,I,U])=>T&&I&&U),x=et([j,E,A,L,k],([T,I,U,$,ee])=>T&&I&&U&&$&&ee);return{subscribe:a,set:r,update:i,currentStore:{subscribe:l.subscribe,set:T=>{i(I=>(I.current={...T},I))},update:T=>i(I=>(I.current={...T},I))},valid:x,validDate:j,validDay:w,validMonth:N,validMonths:A,validWeekdays:L,validYear:F,validYears:k,validName:E,setProperty(T,I){return i(U=>(U[T]=I,U))},setCurrentDate:T=>i(I=>(I.current={...T},I)),staticStore:{subscribe:s,set:c,setProperty(T,I){return i(U=>(U.static[T]=I,U))}},weekdayStore:{subscribe:d.subscribe,add:()=>i(T=>(T.static.weekdays.push({type:"day",name:null,id:Ze(6)}),T)),update:(T,I)=>i(U=>(U.static.weekdays.splice(U.static.weekdays.findIndex($=>$.id==T),1,I),U)),delete:T=>i(I=>(I.static.weekdays=I.static.weekdays.filter(U=>U.id!=T),I)),set:T=>i(I=>(I.static.weekdays=[...T],I))},monthStore:{subscribe:u.subscribe,add:()=>i(T=>(T.static.months.push({type:"month",name:null,length:null,id:Ze(6)}),T)),update:(T,I)=>i(U=>(U.static.months.splice(U.static.months.findIndex($=>$.id==T),1,I),U)),delete:T=>i(I=>(I.static.months=I.static.months.filter(U=>U.id!=T),I)),set:T=>i(I=>(I.static.months=[...T],I))},yearStore:{customYears:v,subscribe:m.subscribe,add:()=>i(T=>(T.static.years.push({type:"year",name:null,id:Ze(6)}),T)),update:(T,I)=>i(U=>(U.static.years.splice(U.static.years.findIndex($=>$.id==T),1,I),U)),delete:T=>i(I=>(I.static.years=I.static.years.filter(U=>U.id!=T),I)),set:T=>i(I=>(I.static.years=[...T],I))},eventStore:{subscribe:S.subscribe,sortedStore:et(S,T=>T.sort((I,U)=>I.date.year!=U.date.year?I.date.year-U.date.year:I.date.month!=U.date.month?I.date.month-U.date.month:I.date.day-U.date.day)),set:T=>i(I=>(I.events=[...T],I)),add:T=>i(I=>(I.events.push({...T}),I)),update:(T,I)=>i(U=>{let $=U.events.findIndex(ee=>ee.id===T);return U.events.splice($,1,{...I}),U}),delete:T=>i(I=>(I.events=I.events.filter(U=>U.id!==T),I))},categoryStore:{subscribe:_.subscribe,set:T=>i(I=>(I.categories=[...T],I)),add:T=>i(I=>(I.categories.push({...T}),I)),update:(T,I)=>i(U=>{let $=U.categories.findIndex(ee=>ee.id===T);return U.categories.splice($,1,{...I}),U}),delete:T=>i(I=>(I.categories=I.categories.filter(U=>U.id!==T),I))},displayMoons:{subscribe:y.subscribe,set:T=>{i(I=>(I.static.displayMoons=T,I))}},moonStore:{subscribe:h.subscribe,set:T=>i(I=>(I.static.moons=[...T],I)),add:T=>i(I=>(I.static.moons.push({...T}),I)),update:(T,I)=>i(U=>{let $=U.static.moons.findIndex(ee=>ee.id===T);return U.static.moons.splice($,1,{...I}),U}),delete:T=>i(I=>(I.static.moons=I.static.moons.filter(U=>U.id!==T),I))},leapDayDisabled:et(u,T=>T.filter(I=>I.name?.length).length==0),leapDayStore:{subscribe:p.subscribe,set:T=>i(I=>(I.static.leapDays=[...T],I)),add:T=>i(I=>(I.static.leapDays.push({...T}),I)),update:(T,I)=>i(U=>{let $=U.static.leapDays.findIndex(ee=>ee.id===T);return U.static.leapDays.splice($,1,{...I}),U}),delete:T=>i(I=>(I.static.leapDays=I.static.leapDays.filter(U=>U.id!==T),I))}}}var Mf=L1;function P1(t){be(t,"svelte-190iu8i","body:not(.is-mobile) .fantasy-calendar-creator.svelte-190iu8i.svelte-190iu8i{position:absolute;top:var(--top, 0);height:100%}body:not(.is-mobile) .fantasy-calendar-creator-inner.svelte-190iu8i.svelte-190iu8i{position:absolute;top:0;left:-2px;bottom:0;overflow:auto;display:grid;grid-template-rows:auto 1fr}.fantasy-calendar-creator.svelte-190iu8i.svelte-190iu8i,.fantasy-calendar-creator.svelte-190iu8i .fantasy-calendar-creator-inner.svelte-190iu8i,.fantasy-calendar-creator.svelte-190iu8i .fantasy-creator-app.svelte-190iu8i{background-color:var(--creator-background-color)}body.is-mobile .fantasy-calendar-creator.svelte-190iu8i.svelte-190iu8i,body.is-mobile .fantasy-calendar-creator.svelte-190iu8i .fantasy-creator-app.svelte-190iu8i{padding:0px 10px;width:100%}.fantasy-creator-app.svelte-190iu8i.svelte-190iu8i{overflow:auto;height:100%}.fantasy-calendar-creator-header.svelte-190iu8i.svelte-190iu8i{margin:0}.top-nav.svelte-190iu8i.svelte-190iu8i{position:sticky;top:0;padding:10px 0px;background-color:inherit;z-index:3}.icons.svelte-190iu8i.svelte-190iu8i{display:flex;justify-content:space-between}.icons.svelte-190iu8i .left.svelte-190iu8i{display:flex;align-items:center}.check.svelte-190iu8i.svelte-190iu8i{display:flex;gap:0.25rem;align-items:center}.additional.svelte-190iu8i.svelte-190iu8i{color:var(--text-faint)}.save.svelte-190iu8i.svelte-190iu8i{color:var(--text-error)}.save.can-save.svelte-190iu8i.svelte-190iu8i{color:var(--interactive-success)}.additional.can-save.svelte-190iu8i.svelte-190iu8i{color:var(--text-normal)}.back.svelte-190iu8i.svelte-190iu8i{width:min-content}.back.svelte-190iu8i .clickable-icon{margin-left:0}")}function Of(t){let e,n,a,r,i,o,l,s,c,u,d,m,v,h,y,p,S,_,A,L,k,E,w,N,F,j,x,T,I,U,$,ee,Z,K,ve,xe,Ae,Oe,He,st,je;function wt(Te,tt){return Te[8]?V1:j1}let Nt=wt(t,-1),Je=Nt(t);return L=new Sc({props:{plugin:t[1]}}),E=new wd({}),N=new xd({}),j=new Rd({props:{app:t[1].app}}),T=new jo({}),U=new Qd({props:{plugin:t[1]}}),ee=new af({}),K=new ff({props:{plugin:t[1]}}),xe=new Sf({props:{plugin:t[1]}}),{c(){e=B("div"),n=B("div"),a=B("div"),r=B("div"),i=B("div"),s=W(),c=B("div"),Je.c(),u=W(),d=B("div"),v=W(),h=B("h3"),h.textContent="Calendar Creator",y=W(),p=B("div"),S=B("div"),A=W(),ne(L.$$.fragment),k=W(),ne(E.$$.fragment),w=W(),ne(N.$$.fragment),F=W(),ne(j.$$.fragment),x=W(),ne(T.$$.fragment),I=W(),ne(U.$$.fragment),$=W(),ne(ee.$$.fragment),Z=W(),ne(K.$$.fragment),ve=W(),ne(xe.$$.fragment),D(i,"class","back svelte-190iu8i"),D(i,"aria-label",o=t[8]?"Save and exit":"Exit without saving"),D(c,"class","check svelte-190iu8i"),D(r,"class","left svelte-190iu8i"),D(d,"class","cancel"),D(a,"class","icons svelte-190iu8i"),D(h,"class","fantasy-calendar-creator-header svelte-190iu8i"),D(n,"class","top-nav svelte-190iu8i"),D(p,"class","fantasy-creator-app svelte-190iu8i"),D(e,"class","inherit fantasy-calendar-creator-inner svelte-190iu8i"),D(e,"style",Ae=t[9]?"":`width: ${t[0]+4}px;`)},m(Te,tt){R(Te,e,tt),C(e,n),C(n,a),C(a,r),C(r,i),C(r,s),C(r,c),Je.m(c,null),C(a,u),C(a,d),C(n,v),C(n,h),C(e,y),C(e,p),C(p,S),C(p,A),te(L,p,null),C(p,k),te(E,p,null),C(p,w),te(N,p,null),C(p,F),te(j,p,null),C(p,x),te(T,p,null),C(p,I),te(U,p,null),C(p,$),te(ee,p,null),C(p,Z),te(K,p,null),C(p,ve),te(xe,p,null),He=!0,st||(je=[ue(l=t[12].call(null,i)),re(i,"click",t[20]),ue(m=t[13].call(null,d)),re(d,"click",t[21]),ue(_=t[14].call(null,S)),re(e,"introend",t[22]),re(e,"outroend",t[23])],st=!0)},p(Te,tt){t=Te,(!He||tt&256&&o!==(o=t[8]?"Save and exit":"Exit without saving"))&&D(i,"aria-label",o),Nt===(Nt=wt(t,tt))&&Je?Je.p(t,tt):(Je.d(1),Je=Nt(t),Je&&(Je.c(),Je.m(c,null)));let Yt={};tt&2&&(Yt.plugin=t[1]),L.$set(Yt);let $t={};tt&2&&($t.app=t[1].app),j.$set($t);let Rt={};tt&2&&(Rt.plugin=t[1]),U.$set(Rt);let Ht={};tt&2&&(Ht.plugin=t[1]),K.$set(Ht);let wn={};tt&2&&(wn.plugin=t[1]),xe.$set(wn),(!He||tt&1&&Ae!==(Ae=t[9]?"":`width: ${t[0]+4}px;`))&&D(e,"style",Ae)},i(Te){He||(P(L.$$.fragment,Te),P(E.$$.fragment,Te),P(N.$$.fragment,Te),P(j.$$.fragment,Te),P(T.$$.fragment,Te),P(U.$$.fragment,Te),P(ee.$$.fragment,Te),P(K.$$.fragment,Te),P(xe.$$.fragment,Te),It(()=>{Oe||(Oe=Oo(e,t[18],{x:t[0]*1.5,opacity:1},!0)),Oe.run(1)}),He=!0)},o(Te){G(L.$$.fragment,Te),G(E.$$.fragment,Te),G(N.$$.fragment,Te),G(j.$$.fragment,Te),G(T.$$.fragment,Te),G(U.$$.fragment,Te),G(ee.$$.fragment,Te),G(K.$$.fragment,Te),G(xe.$$.fragment,Te),Oe||(Oe=Oo(e,t[18],{x:t[0]*1.5,opacity:1},!1)),Oe.run(0),He=!1},d(Te){Te&&q(e),Je.d(),J(L),J(E),J(N),J(j),J(T),J(U),J(ee),J(K),J(xe),Te&&Oe&&Oe.end(),st=!1,we(je)}}}function j1(t){let e,n,a,r,i,o;return{c(){e=B("div"),a=W(),r=B("span"),r.textContent=`Additional information is required before
saving`,D(e,"class","save svelte-190iu8i"),D(e,"aria-label",t[7]),D(r,"class","additional svelte-190iu8i")},m(l,s){R(l,e,s),R(l,a,s),R(l,r,s),i||(o=ue(n=t[17].call(null,e)),i=!0)},p(l,s){s&128&&D(e,"aria-label",l[7])},d(l){l&&q(e),l&&q(a),l&&q(r),i=!1,o()}}}function V1(t){let e,n,a,r,i,o;return{c(){e=B("div"),a=W(),r=B("span"),r.textContent="All good! Exit to save calendar",D(e,"class","save can-save svelte-190iu8i"),D(e,"aria-label",t[7]),D(r,"class","additional can-save svelte-190iu8i")},m(l,s){R(l,e,s),R(l,a,s),R(l,r,s),i||(o=ue(n=t[17].call(null,e)),i=!0)},p(l,s){s&128&&D(e,"aria-label",l[7])},d(l){l&&q(e),l&&q(a),l&&q(r),i=!1,o()}}}function H1(t){let e,n,a=t[5]&&Of(t);return{c(){e=B("div"),a&&a.c(),D(e,"class","fantasy-calendar-creator svelte-190iu8i"),at(e,"--creator-background-color",t[2]),at(e,"--top",t[3]+"px")},m(r,i){R(r,e,i),a&&a.m(e,null),n=!0},p(r,[i]){r[5]?a?(a.p(r,i),i&32&&P(a,1)):(a=Of(r),a.c(),P(a,1),a.m(e,null)):a&&(De(),G(a,1,1,()=>{a=null}),_e()),(!n||i&4)&&at(e,"--creator-background-color",r[2]),(!n||i&8)&&at(e,"--top",r[3]+"px")},i(r){n||(P(a),n=!0)},o(r){G(a),n=!1},d(r){r&&q(e),a&&a.d()}}}function W1(t,e,n){let a,r,i,o=Fn.Platform.isMobile,l=o;$n(()=>{n(5,l=!0)});let s=Ve(),{width:c}=e,{base:u}=e,{plugin:d}=e,{color:m=null}=e,{top:v}=e,h=Mf(d,u);Fe(t,h,x=>n(4,i=x)),Zn("store",h);let y=x=>{new Fn.ExtraButtonComponent(x).setIcon("left-arrow-with-tail")},p=x=>{new Fn.ExtraButtonComponent(x).setIcon("cross").setTooltip("Exit without saving")},S=x=>{let T=x.createDiv("fantasy-calendar-apply-preset");new Fn.Setting(T).setName("Apply Preset").setDesc("Apply a common fantasy calendar as a preset.").addButton(I=>{I.setCta().setButtonText("Choose Preset").onClick(()=>{let U=new qo(d.app);U.onClose=()=>{if(!!U.saved&&(nt(h,i=(0,If.default)(U.preset),i),i?.name=="Gregorian Calendar")){let $=new Date;h.setCurrentDate({year:$.getFullYear(),month:$.getMonth(),day:$.getDate()})}},U.open()})})},_=!1,{valid:A}=h;Fe(t,A,x=>n(8,r=x));let L=()=>{if(!r&&!d.data.exit.saving){let x=new bs(d);x.onClose=()=>{x.confirmed&&n(5,l=!1),o&&s("exit",{saved:_,calendar:i})},x.open()}else n(6,_=!0),n(5,l=!1)},k=x=>{r?(0,Fn.setIcon)(x,"checkmark"):gn(x)},E=(x,T)=>o?null:Su(x,T),w=()=>{L()},N=()=>n(5,l=!1),F=()=>s("flown"),j=()=>s("exit",{saved:_,calendar:i});return t.$$set=x=>{"width"in x&&n(0,c=x.width),"base"in x&&n(19,u=x.base),"plugin"in x&&n(1,d=x.plugin),"color"in x&&n(2,m=x.color),"top"in x&&n(3,v=x.top)},t.$$.update=()=>{if(t.$$.dirty&16){e:n(7,a=Nu(i))}},[c,d,m,v,i,l,_,a,r,o,s,h,y,p,S,A,L,k,E,u,w,N,F,j]}var qf=class extends de{constructor(e){super();he(this,e,W1,H1,le,{width:0,base:19,plugin:1,color:2,top:3},P1)}},Ts=qf;var Rf;(function(a){a.none="None",a.monthly="Monthly",a.yearly="Yearly"})(Rf||(Rf={}));(0,ze.addIcon)("fantasy-calendar-grip",' ');(0,ze.addIcon)("fantasy-calendar-warning",' ');var xi=class extends ze.PluginSettingTab{constructor(e){super(e.app,e);this.plugin=e}get data(){return this.plugin.data}async display(){this.containerEl.empty(),this.containerEl.createEl("h2",{text:"Fantasy Calendars"}),this.containerEl.addClass("fantasy-calendar-settings"),this.contentEl=this.containerEl.createDiv("fantasy-calendar-settings-content"),this.buildInfo(this.contentEl.createDiv("fantasy-calendar-nested-settings")),this.calendarsEl=this.contentEl.createEl("details",{cls:"fantasy-calendar-nested-settings",attr:{...this.data.settingsToggleState.calendars?{open:"open"}:{}}}),this.buildCalendars(),this.buildEvents(this.contentEl.createEl("details",{cls:"fantasy-calendar-nested-settings",attr:{...this.data.settingsToggleState.events?{open:"open"}:{}}})),this.buildAdvanced(this.contentEl.createEl("details",{cls:"fantasy-calendar-nested-settings",attr:{...this.data.settingsToggleState.advanced?{open:"open"}:{}}}))}buildInfo(e){e.empty(),new ze.Setting(e).setName(`Reset "Don't Ask Again" Prompts`).setDesc(`All confirmations set to "Don't Ask Again" will be reset.`).addButton(n=>{n.setIcon("reset").onClick(async()=>{this.plugin.data.exit={saving:!1,event:!1,calendar:!1},await this.plugin.saveSettings()})}),new ze.Setting(e).setName(createFragment(n=>{let a=n.createSpan("fantasy-calendar-warning");(0,ze.setIcon)(a.createSpan("fantasy-calendar-warning"),"fantasy-calendar-warning"),a.createSpan({text:"Default Config Directory"})})).setDesc(createFragment(n=>{n.createSpan({text:"Please back up your data before changing this setting. Hidden directories must be manually entered."}),n.createEl("br"),n.createSpan({text:"Current directory: "});let a=this.data.configDirectory??this.app.vault.configDir;n.createEl("code",{text:a})})).addText(async n=>{let a=this.app.vault.getAllLoadedFiles().filter(i=>i instanceof ze.TFolder);n.setPlaceholder(this.data.configDirectory??this.app.vault.configDir);let r=new dr(this.app,n,[...a]);r.onClose=async()=>{n.inputEl.value?await this.app.vault.adapter.exists(n.inputEl.value)||(this.data.configDirectory=n.inputEl.value,await this.plugin.saveSettings()):this.data.configDirectory=null},n.inputEl.onblur=async()=>{if(!n.inputEl.value)return;let i=await this.app.vault.adapter.exists(n.inputEl.value);this.data.configDirectory=n.inputEl.value,await this.plugin.saveSettings(),this.display()}}).addExtraButton(n=>{n.setTooltip("Reset to Default").setIcon("reset").onClick(async()=>{this.data.configDirectory=null,await this.plugin.saveSettings(),this.display()})})}buildCalendars(){this.calendarsEl.empty(),this.calendarsEl.ontoggle=()=>{this.data.settingsToggleState.calendars=this.calendarsEl.open};let e=this.calendarsEl.createEl("summary");new ze.Setting(e).setHeading().setName("Calendar Management"),e.createDiv("collapser").createDiv("handle"),new ze.Setting(this.calendarsEl).setName("Show Intercalary Months Separately").setDesc("Intercalary months will appear a distinct months in the calendar.").addToggle(n=>{n.setValue(this.data.showIntercalary).onChange(async a=>{this.data.showIntercalary=a,await this.plugin.saveCalendar()})}),new ze.Setting(this.calendarsEl).setName("Default Calendar").setDesc("Views will open to this calendar by default.").addDropdown(n=>{n.addOption("none","None");for(let a of this.data.calendars)n.addOption(a.id,a.name);n.setValue(this.plugin.data.defaultCalendar),n.onChange(async a=>{if(a==="none"){this.plugin.data.defaultCalendar=null,await this.plugin.saveSettings();return}this.plugin.data.defaultCalendar=a,await this.plugin.saveSettings(),this.plugin.watcher.start()})}),new ze.Setting(this.calendarsEl).setName("Import Calendar").setDesc(createFragment(n=>{n.createSpan({text:"Import calendar from "}),n.createEl("a",{href:"https://app.fantasy-calendar.com",text:"Fantasy Calendar",cls:"external-link"})})).addButton(n=>{let a=createEl("input",{attr:{type:"file",name:"merge",accept:".json",multiple:!0,style:"display: none;"}});a.onchange=async()=>{let{files:r}=a;if(!!r.length){try{let i=[];for(let l of Array.from(r))i.push(JSON.parse(await l.text()));let o=Hr.import(i);for(let l of o)await this.plugin.addNewCalendar(l);this.display()}catch(i){new ze.Notice(`There was an error while importing the calendar${r.length==1?"":"s"}.`),console.error(i)}a.value=null}},n.setButtonText("Choose Files"),n.buttonEl.addClass("calendar-file-upload"),n.buttonEl.appendChild(a),n.onClick(()=>a.click())}),new ze.Setting(this.calendarsEl).setName("Create New Calendar").addButton(n=>n.setTooltip("Launch Calendar Creator").setIcon("plus-with-circle").onClick(async()=>{let a=await this.launchCalendarCreator();a&&(await this.plugin.addNewCalendar(a),this.display())})),this.existingEl=this.calendarsEl.createDiv("existing-calendars"),this.showCalendars()}showCalendars(){if(this.existingEl.empty(),!this.data.calendars.length){this.existingEl.createSpan({text:"No calendars created! Create a calendar to see it here."});return}for(let e of this.data.calendars)new ze.Setting(this.existingEl).setName(e.name).setDesc(e.description??"").addExtraButton(n=>{n.setIcon("pencil").onClick(async()=>{let a=await this.launchCalendarCreator(e);a&&(this.plugin.addNewCalendar(a,e),await this.plugin.saveCalendar(),this.display())})}).addExtraButton(n=>{n.setIcon("trash").onClick(async()=>{!this.plugin.data.exit.calendar&&!await Td(this.plugin)||(this.plugin.data.calendars=this.plugin.data.calendars.filter(a=>a.id!=e.id),e.id==this.data.defaultCalendar&&(this.plugin.data.defaultCalendar=this.plugin.data.calendars[0]?.id,this.plugin.watcher.start()),await this.plugin.saveCalendar(),this.display())})})}buildEvents(e){e.empty(),e.ontoggle=()=>{this.data.settingsToggleState.events=e.open};let n=e.createEl("summary");new ze.Setting(n).setHeading().setName("Events"),n.createDiv("collapser").createDiv("handle"),new ze.Setting(e).setName("Add Events to Default Calendar").setDesc(createFragment(a=>{a.createSpan({text:"Add events found in notes to the default calendar if the "}),a.createEl("code",{text:"fc-calendar"}),a.createSpan({text:" frontmatter tag is not present."})})).addToggle(a=>{a.setValue(this.data.addToDefaultIfMissing).onChange(async r=>{this.data.addToDefaultIfMissing=r,await this.plugin.saveSettings(),this.plugin.watcher.start()})}),new ze.Setting(e).setName("Display Event Previews").setDesc("Use the core Note Preview plugin to display event notes when hovered.").addToggle(a=>{a.setValue(this.data.eventPreview).onChange(async r=>{this.data.eventPreview=r,await this.plugin.saveSettings()})}),new ze.Setting(e).setName("Write Event Data to Frontmatter").setDesc("This setting is temporarily disabled.").addToggle(a=>{a.setValue(!1).setDisabled(!0).onChange(async r=>{this.data.eventFrontmatter=r,await this.plugin.saveSettings()})}),new ze.Setting(e).setName("Parse Note Titles for Event Dates").setDesc("The plugin will parse note titles for event dates.").addToggle(a=>{a.setValue(this.data.parseDates).onChange(async r=>{this.data.parseDates=r,await this.plugin.saveSettings(),this.plugin.watcher.start()})}),new ze.Setting(e).setName("Date Format").setClass(this.data.dailyNotes?"daily-notes":"no-daily-notes").setDesc(createFragment(a=>{if(a.createSpan({text:"Event dates will be parsed using this format."}),a.createSpan({text:"Only the "}),a.createEl("code",{text:"Y"}),a.createSpan({text:", "}),a.createEl("code",{text:"M"}),a.createSpan({text:", and "}),a.createEl("code",{text:"D"}),a.createEl("a",{text:"tokens",href:"https://momentjs.com/docs/#/displaying/format/",cls:"external-link"}),a.createSpan({text:" are supported."}),["Y","M","D"].some(r=>!this.data.dateFormat.includes(r))){a.createEl("br");let r=a.createSpan({cls:"fantasy-calendar-warning date-format"});(0,ze.setIcon)(r.createSpan("fantasy-calendar-warning"),"fantasy-calendar-warning");let i=["Y","M","D"].filter(o=>!this.data.dateFormat.includes(o));r.createSpan({text:` Date format is missing: ${i.join(", ").replace(/, ([^,]*)$/," and $1")}`})}})).addText(a=>{a.setDisabled(this.data.dailyNotes).setValue(this.plugin.format).onChange(async r=>{this.data.dateFormat=r,await this.plugin.saveSettings()}),a.inputEl.onblur=()=>this.buildEvents(e)}).addExtraButton(a=>{if(!this.plugin.canUseDailyNotes){a.extraSettingsEl.detach();return}this.data.dailyNotes?a.setIcon("checkmark").setTooltip("Unlink from Daily Notes").onClick(()=>{this.data.dailyNotes=!1,this.buildEvents(e)}):a.setIcon("sync").setTooltip("Link with Daily Notes").onClick(()=>{this.data.dailyNotes=!0,this.buildEvents(e)})})}buildAdvanced(e){e.empty(),e.ontoggle=()=>{this.data.settingsToggleState.advanced=e.open};let n=e.createEl("summary");new ze.Setting(n).setHeading().setName("Advanced"),n.createDiv("collapser").createDiv("handle"),new ze.Setting(e).setName("Show Event Debug Messages").setDesc(createFragment(a=>{a.createSpan({text:"The plugin will show debug messages when events are added, deleted or updated by the file watcher."})})).addToggle(a=>{a.setValue(this.data.debug).onChange(async r=>{this.data.debug=r,await this.plugin.saveSettings()})})}launchCalendarCreator(e=ia){let n=(0,Ha.default)(e);if(ze.Platform.isMobile){let a=new Lf(this.plugin,n);return new Promise((r,i)=>{try{a.onClose=()=>{a.saved&&(e=(0,Ha.default)(a.calendar),r(e)),r()},a.open()}catch{i()}})}else return this.containerEl.addClass("fantasy-calendar-creator-open"),new Promise(a=>{let r=getComputedStyle(this.containerEl.closest(".modal")).backgroundColor,i=new Ts({target:this.containerEl,props:{base:n,plugin:this.plugin,width:this.contentEl.clientWidth,color:r,top:this.containerEl.scrollTop}}),o=new ResizeObserver(()=>{i.$set({width:this.contentEl.clientWidth})});o.observe(this.contentEl),i.$on("exit",l=>{this.containerEl.removeClass("fantasy-calendar-creator-open"),i.$destroy(),l.detail.saved&&(e=(0,Ha.default)(l.detail.calendar),o.disconnect(),a(e)),a()})})}},Lf=class extends lt{constructor(e,n){super(e.app);this.plugin=e;this.saved=!1;this.calendar=(0,Ha.default)(n)}onOpen(){this.contentEl.setAttr("style","background-color: inherit; padding-top: 0px;");let e=new Ts({target:this.contentEl,props:{base:this.calendar,plugin:this.plugin,width:this.contentEl.clientWidth,top:0}});e.$on("exit",n=>{n.detail.saved&&(this.calendar=(0,Ha.default)(n.detail.calendar),this.saved=!0),this.close(),e.$destroy()})}};var qe=Ee(require("obsidian"));var Er=Ee(require("obsidian"));var Pf=class{constructor(e,n,a){this.month=e;this.number=n;this.leapday=a;this.shouldUpdate=!1}get calendar(){return this.month.calendar}get date(){return{day:this.number,month:this.month.number,year:this.year}}get events(){return(!this._events||!this._events.length||this.shouldUpdate)&&(this._events=this.month.getEventsOnDay(this.date)),this._events}get longDate(){return{day:this.number,month:this.month.name,year:this.year}}get daysBefore(){return this.month.daysBefore+this.number-1-this.month.leapDays.filter(e=>e.numbered&&e.after!i.intercalary||i.intercalary&&i.numbered).length).keys()].map(i=>new Pf(this,i+1,this.leapDays.find(o=>o.after==i)))}get id(){return this.data.id}get index(){return this.calendar.data.months.indexOf(this.data)}get name(){return this.data.name}get length(){return this.days.length}get firstWeekday(){return this.calendar.data.overflow?this.days[0].weekday:0}get lastWeekday(){return this.days[this.days.length-1].weekday}get type(){return this.data.type}getEventsOnDay(e){return(!this.events||!this.events.length||this.shouldUpdate)&&(this.days.forEach(n=>n.shouldUpdate=!0),this.events=this.calendar.getEventsForMonth(this),this.shouldUpdate=!1),this.events.filter(n=>{if((!n.date.year||n.date.year==e.year)&&(!n.date.month||n.date.month==e.month)&&n.date.day==e.day)return!0;if(!n.end&&!n.formulas?.length)return!1;let a={...n.date},r={...n.end??{}};a.year||(a.year=r.year=this.year),a.month||(a.month=r.month=this.number);let i=Number(this.calendar.hash(e));if(Number(this.calendar.hash(a))<=i&&i<=Number(this.calendar.hash(r)??1/0))if(n.formulas?.length){let o=this.calendar.totalDaysBeforeYear(a.year)+this.calendar.daysBeforeMonth(a.month,a.year,!0)+a.day;return(this.calendar.totalDaysBeforeYear(e.year)+this.calendar.daysBeforeMonth(e.month,e.year,!0)+e.day-o)%n.formulas[0].number==0}else return!0;return!1})}getMoonsForDay(e){return(!this.moons||!this.moons.length||this.shouldUpdateMoons)&&(this.moons=this.calendar.getMoonsForMonth(this)),this.moons[e.day-1]}},Wa=class extends Er.Events{constructor(e,n){super();this.calendar=e;this.plugin=n;this._cache=new Map;this.displayed={year:null,month:null,day:null};this.viewing={year:null,month:null,day:null};this.displayed={...this.current},this.update(this.calendar),this.plugin.registerEvent(this.plugin.app.workspace.on("fantasy-calendars-event-update",a=>{if(!a.has(this.calendar.id))return;let r=a.get(this.calendar.id);for(let i of r)!this._cache.has(i)||this.refreshYear(i)}))}addEvent(e){let n=e.date.year,a=e.date.month;this.refreshMonth(a,n)}refreshMonth(e,n){!this._cache.has(n)||!this._cache.get(n).months.has(e)||(this._cache.get(n).shouldUpdate=!0,this._cache.get(n).months.forEach(a=>a.shouldUpdate=!0),(n==this.displayed.year&&e==this.displayed.month||n==this.viewing.year&&e==this.viewing.month)&&this.trigger("month-update"))}refreshYear(e){!this._cache.has(e)||(this._cache.get(e).shouldUpdate=!0,this._cache.get(e).months.forEach(n=>n.shouldUpdate=!0),(e==this.displayed.year||e==this.viewing.year)&&this.trigger("month-update"))}getDayForDate(e){return this.getMonth(e.month,e.year).days[e.day-1]}getEventsForMonth(e){let{year:n,number:a}=e;if(this._cache.has(n)||this._cache.set(n,{events:[],shouldUpdate:!0,months:new Map}),this._cache.get(n).shouldUpdate){let i=this.calendar.events.filter(o=>{let l={...o.date},s={...o.end};return l.year==n||l.year==null?!0:l.year>n||!s&&!o.formulas?.length&&l.year=n||o.formulas?.length))});this._cache.set(n,{months:this._cache.get(n).months,events:i,shouldUpdate:!1})}return this._cache.get(n).events.filter(i=>{let o={...i.date},l={...i.end};return o.month==null||(o.year==n||o.year==null)&&o.month==a?!0:o.year>n||o.year==n&&o.month>a||!l&&!i.formulas?.length&&(o.month!=a||o.year=n&&l.month>=a)))})}getNameForYear(e){if(!this.data.useCustomYears)return`${e}`;if(this.data.useCustomYears&&e-1>=0&&e<=this.data.years?.length)return this.data.years[e-1].name}get displayWeeks(){return this.calendar.displayWeeks}getMonthsForYear(e){return this._cache.has(e)||this._cache.set(e,{events:[],shouldUpdate:!0,months:new Map(this.data.months.map((n,a)=>[a,new Fi(n,a,e,this)]))}),this._cache.get(e).months.size!=this.data.months.length&&this._cache.set(e,{...this._cache.get(e),months:new Map(this.data.months.map((n,a)=>[a,new Fi(n,a,e,this)]))}),Array.from(this._cache.get(e).months.values())}hash(e){if(e.year==null||e.month==null||e.day==null)return null;let n=`${this.data.months.length}`.length,a=`${e.month}`.padStart(n,"0"),r=`${this.maxDays}`.length,i=`${e.day}`.padStart(r,"0");return`${e.year}${a}${i}`}update(e){this.calendar=e??this.calendar,this.maxDays=Math.max(...this.data.months.map(n=>n.length)),this.standardMonths=this.data.months.filter(n=>n.type!="intercalary"),this.calendar?.current||(this.calendar.current={day:null,month:null,year:null}),Ca(this.calendar?.current.year,this.calendar)||(this.calendar.current.year=1),_a(this.calendar?.current.month,this.calendar)||(this.calendar.current.month=0),Da(this.calendar?.current.day,this.calendar)||(this.calendar.current.day=1),this.trigger("month-update"),this.trigger("day-update")}get categories(){return this.calendar.categories}get data(){return this.calendar.static}get current(){return this.calendar.current}get leapdays(){return this.data.leapDays??[]}get currentDate(){return Kt(this.current,this.calendar)}get displayedDate(){return Kt(this.displayed,this.calendar)}get viewedDate(){return Kt(this.viewing,this.calendar)}reset(){this.displayed={...this.current},this.viewing={...this.current},this.trigger("month-update"),this.trigger("day-update")}setCurrentMonth(e){this.displayed.month=e,this.trigger("month-update")}goToNextDay(){let e=this.getDayForDate(this.viewing);this.viewing.day+=1,this.viewing.day>e.month.days.length&&(this.goToNext(),this.viewing.month=this.displayed.month,this.viewing.year=this.displayed.year,this.viewing.day=1),this.trigger("day-update")}goToNextCurrentDay(){this.current.day+=1;let e=this.getMonth(this.current.month,this.current.year);this.current.day>=e.days.length&&(this.current.day=1,this.current.month+=1,this.current.month>=this.data.months.length&&(this.current.month=0,this.current.year+=1)),this.trigger("day-update")}get nextMonthIndex(){return Mn(this.displayed.month+1,this.data.months.length)}get nextMonth(){return this.getMonth(this.displayed.month+1,this.displayed.year)}canGoToNextYear(e=this.displayed.year){return!this.data.useCustomYears||ethis.displayed.month){if(this.displayed.year==1){new Er.Notice("This is the earliest year.");return}this.goToPreviousYear()}this.setCurrentMonth(e)}goToPreviousDay(){this.viewing.day-=1,this.viewing.day<1&&(this.goToPrevious(),this.viewing.month=this.displayed.month,this.viewing.year=this.displayed.year,this.viewing.day=this.currentMonth.days.length),this.trigger("day-update")}goToPreviousYear(){this.displayed.year-=1,this.trigger("year-update")}get weekdays(){return this.data.weekdays}get currentMonth(){return this.getMonth(this.displayed.month,this.displayed.year)}testLeapDay(e,n){return e.interval.sort((a,r)=>a.interval-r.interval).some(({interval:a,exclusive:r},i,o)=>{if(r&&i==0)return(n-e.offset)%a!=0;if(!r)return o[i+1]&&o[i+1].exclusive?(n-e.offset)%a==0&&(n-e.offset)%o[i+1].interval!=0:(n-e.offset)%a==0})}leapDaysForYear(e){return this.leapdays.filter(n=>this.testLeapDay(n,e))}leapDaysForMonth(e,n=this.displayed.year){return this.leapdays.filter(a=>a.timespan!=e?!1:this.testLeapDay(a,n))}getMonth(e,n,a=0){let r=this.data.months,i=Mn(e,r.length);if(e<0&&(n-=1),n==0)return null;if(e>=r.length&&(n+=1),this._cache.has(n)){if(this._cache.get(n).months.has(i))return this._cache.get(n).months.get(i)}else this._cache.set(n,{events:[],shouldUpdate:!0,months:new Map});if(r[i].type=="intercalary"&&a!=0)return this.getMonth(e+a,n,a);let o=new Fi(r[i],i,n,this);return this._cache.get(n).months.set(i,o),this._cache.set(n,this._cache.get(n)),o}getPaddedDaysForMonth(e){let n=e.days,a=[],r=this.getMonth(e.index-1,this.displayed.year,-1);e.firstWeekday>0&&e.type=="month"&&(a=r!=null?r.days.slice(-e.firstWeekday):Array(e.firstWeekday).fill(null));let i=[],o=this.getMonth(e.index+1,this.displayed.year,1);return e.lastWeekdaye.type==="month").reduce((e,n)=>e+n.length,0)}daysBeforeMonth(e,n,a=!1){return!e||e==0?0:this.data.months.slice(0,e).filter(r=>a?!0:r.type=="month").map((r,i)=>{let o=this.leapDaysForMonth(i,n);return r.length+o.filter(l=>!l.intercalary).length}).reduce((r,i)=>r+i,0)}dayNumberForDate(e){return this.daysBeforeMonth(e.month,e.year,!0)+e.day}get firstWeekday(){return this.data.firstWeekDay}get leapDaysBefore(){return this.displayed.year==1?0:this.leapDaysBeforeYear(this.displayed.year-1)}leapDaysBeforeYear(e){if(e==1)return 0;let n=e-1,a=0;for(let{interval:r,offset:i}of this.leapdays.filter(o=>!o.intercalary)){let o=0;for(let l=0;l!d.exclusive).map(d=>Math.floor((n+(d.ignore?0:i))/d.interval)).reduce((d,m)=>d+m,0),u=Math.floor((n+(s.ignore?0:i))/s.interval);s.exclusive?(o-=u,o+=c):(o+=u,o-=c)}a+=o}return a}get totalDaysBefore(){return this.totalDaysBeforeYear(this.displayed.year)}totalDaysBeforeYear(e,n=!1){return e<1?0:Math.abs(e-1)*this.data.months.filter(a=>n||a.type=="month").reduce((a,r)=>a+r.length,0)+this.leapDaysBeforeYear(e)}firstDayOfYear(e=this.displayed.year){return this.data.overflow?e==1?this.firstWeekday:Mn(this.totalDaysBeforeYear(e)%this.data.weekdays.length+this.firstWeekday+(this.data.offset??0),this.data.weekdays.length):0}get moons(){return this.data.moons}getMoonsForMonth(e){let n=[];for(let a of e.days){let r=this.totalDaysBeforeYear(e.year,!0)+this.daysBeforeMonth(e.number,e.year,!0)+a.number-1,i=[];for(let o of this.moons){let{offset:l,cycle:s}=o,c=24,u=(r-l)/s,m=(u-Math.floor(u))*c%c,v=of[c];i.push([o,v[Mn(Math.round(m),v.length)]])}n.push(i)}return n}};var Ga=Ee(require("obsidian"));var Ti=Ee(require("obsidian"));function G1(t){be(t,"svelte-1e1nyi2",".flag.svelte-1e1nyi2.svelte-1e1nyi2{cursor:pointer;position:relative;padding-left:0.125rem;text-align:left;width:100%;background-color:var(--hex-alpha);border-left:2px solid var(--color)}.flag-content.svelte-1e1nyi2.svelte-1e1nyi2{display:flex;gap:0.25rem;align-items:flex-start;justify-content:space-between}.day-view.svelte-1e1nyi2 .flag-content.svelte-1e1nyi2{justify-content:space-between}.clamp.svelte-1e1nyi2.svelte-1e1nyi2{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:keep-all;overflow:hidden;text-overflow:ellipsis}.note.svelte-1e1nyi2.svelte-1e1nyi2{display:flex;align-self:center}.multi.svelte-1e1nyi2.svelte-1e1nyi2{flex-shrink:0;overflow:visible;width:unset}.multi.svelte-1e1nyi2 .clamp.svelte-1e1nyi2{-webkit-line-clamp:1;overflow:visible}.multi.start.svelte-1e1nyi2.svelte-1e1nyi2{margin-left:0}.multi.end.svelte-1e1nyi2.svelte-1e1nyi2{margin-right:0}.multi.first.svelte-1e1nyi2.svelte-1e1nyi2{overflow:visible;white-space:nowrap}.multi.svelte-1e1nyi2.svelte-1e1nyi2:not(.first){color:transparent;overflow:hidden}.multi.svelte-1e1nyi2.svelte-1e1nyi2:not(.start){border:0;margin-left:-6px}.multi.svelte-1e1nyi2.svelte-1e1nyi2:not(.end){margin-right:-6px}.start.svelte-1e1nyi2>.flag-content.svelte-1e1nyi2{justify-content:flex-start;gap:1em}")}function jf(t){let e,n,a,r;return{c(){e=B("div"),D(e,"class","note svelte-1e1nyi2")},m(i,o){R(i,e,o),a||(r=ue(n=t[9].call(null,e)),a=!0)},d(i){i&&q(e),a=!1,r()}}}function U1(t){let e,n,a,r=t[0].name+"",i,o,l,s,c,u=t[0].note&&jf(t);return{c(){e=B("div"),n=B("div"),a=B("span"),i=fe(r),o=W(),u&&u.c(),D(a,"class","svelte-1e1nyi2"),me(a,"clamp",!t[1]),me(a,"day-view",t[1]),D(n,"class","flag-content svelte-1e1nyi2"),D(e,"class","flag svelte-1e1nyi2"),D(e,"aria-label",l=t[1]?null:t[0].name),at(e,"--hex-alpha",t[6]+"40"),at(e,"--color",t[6]),me(e,"multi",t[4]),me(e,"start",t[2]),me(e,"end",t[3]),me(e,"first",t[5]),me(e,"day-view",t[1])},m(d,m){R(d,e,m),C(e,n),C(n,a),C(a,i),C(n,o),u&&u.m(n,null),s||(c=[re(e,"click",t[12]),re(e,"mouseover",t[13]),re(e,"focus",z1),re(e,"contextmenu",t[14])],s=!0)},p(d,[m]){m&1&&r!==(r=d[0].name+"")&&ge(i,r),m&2&&me(a,"clamp",!d[1]),m&2&&me(a,"day-view",d[1]),d[0].note?u||(u=jf(d),u.c(),u.m(n,null)):u&&(u.d(1),u=null),m&3&&l!==(l=d[1]?null:d[0].name)&&D(e,"aria-label",l),m&64&&at(e,"--hex-alpha",d[6]+"40"),m&64&&at(e,"--color",d[6]),m&16&&me(e,"multi",d[4]),m&4&&me(e,"start",d[2]),m&8&&me(e,"end",d[3]),m&32&&me(e,"first",d[5]),m&2&&me(e,"day-view",d[1])},i:Q,o:Q,d(d){d&&q(e),u&&u.d(),s=!1,we(c)}}}var z1=()=>{};function Y1(t,e,n){let a=Ve(),{event:r}=e,{date:i}=e,{dayView:o=!1}=e,l=!1,s=!1,c=!1,u=!1,{categories:d}=e,m=d.find(_=>_.id==r.category)?.color??Cs,v=Ti.Platform.isMacOS?"Meta":"Control",h=_=>{(0,Ti.setIcon)(_,"note-glyph")},y=_=>{_.stopPropagation(),a("event-click",{event:r,modifier:_.getModifierState(v)})},p=_=>a("event-mouseover",{target:_.target,event:r}),S=_=>{_.stopPropagation(),a("event-context",{evt:_,event:r})};return t.$$set=_=>{"event"in _&&n(0,r=_.event),"date"in _&&n(10,i=_.date),"dayView"in _&&n(1,o=_.dayView),"categories"in _&&n(11,d=_.categories)},t.$$.update=()=>{if(t.$$.dirty&1039){e:r.end!=null&&!o&&(n(4,l=!0),n(2,s=i.day===r.date.day&&(r.date.month==null||i.month==r.date.month)&&(r.date.year==null||i.year===r.date.year)),n(5,u=s||i.day==1),n(3,c=i.day===r.end.day&&(r.end.month==null||i.month==r.end.month)&&(r.end.year==null||i.year===r.end.year)),s&&c&&(n(4,l=!1),n(2,s=!1),n(3,c=!1)))}if(t.$$.dirty&2049){e:n(6,m=d.find(_=>_.id==r.category)?.color??Cs)}},[r,o,s,c,l,u,m,a,v,h,i,d,y,p,S]}var Vf=class extends de{constructor(e){super();he(this,e,Y1,U1,le,{event:0,date:10,dayView:1,categories:11},G1)}},Hf=Vf;function $1(t){be(t,"svelte-qnut28",".flags-container.svelte-qnut28{height:100%}.flag-container.svelte-qnut28{display:flex;flex-flow:column nowrap;gap:0.25rem}.overflow.svelte-qnut28{color:var(--text-muted);display:flex;justify-content:flex-end;width:100%}")}function Wf(t){let e,n,a,r;return{c(){e=B("div"),D(e,"class","flag-container svelte-qnut28")},m(i,o){R(i,e,o),a||(r=ue(n=t[2].call(null,e)),a=!0)},p:Q,d(i){i&&q(e),a=!1,r()}}}function Gf(t){let e,n,a;return{c(){e=B("span"),n=fe("+"),a=fe(t[1])},m(r,i){R(r,e,i),C(e,n),C(e,a)},p(r,i){i&2&&ge(a,r[1])},d(r){r&&q(e)}}}function Z1(t){let e,n=t[0],a,r,i=Wf(t),o=t[1]>0&&Gf(t);return{c(){e=B("div"),i.c(),a=W(),r=B("div"),o&&o.c(),D(r,"class","overflow svelte-qnut28"),D(e,"class","flags-container svelte-qnut28")},m(l,s){R(l,e,s),i.m(e,null),C(e,a),C(e,r),o&&o.m(r,null)},p(l,[s]){s&1&&le(n,n=l[0])?(i.d(1),i=Wf(l),i.c(),i.m(e,a)):i.p(l,s),l[1]>0?o?o.p(l,s):(o=Gf(l),o.c(),o.m(r,null)):o&&(o.d(1),o=null)},i:Q,o:Q,d(l){l&&q(e),i.d(l),o&&o.d()}}}function K1(t,e,n){let{events:a=[]}=e,{categories:r}=e,{dayView:i=!1}=e,{date:o}=e,{calendar:l}=e,s=0,c=Ve(),u,d=0,m=v=>{if(a.length){let h=v?.parentElement?.getBoundingClientRect()?.height;if(!i&&(h==null||Math.floor(h)==Math.floor(d)))return;d=h,u=v,v.empty(),n(1,s=0);let y=h;for(let p of a){let S=new Hf({target:v,props:{event:p,categories:r,dayView:i,date:o}});if(S.$on("event-click",_=>c("event-click",_.detail)),S.$on("event-mouseover",_=>c("event-mouseover",_.detail)),S.$on("event-context",_=>c("event-context",_.detail)),!i){if(y=h-v.getBoundingClientRect().height,y<0){v.lastElementChild.detach(),n(1,s=a.length-a.indexOf(p));break}else if(y==0){n(1,s=a.length-a.indexOf(p)-1);break}}}}};return l.on("view-resized",()=>{i||m(u)}),t.$$set=v=>{"events"in v&&n(0,a=v.events),"categories"in v&&n(3,r=v.categories),"dayView"in v&&n(4,i=v.dayView),"date"in v&&n(5,o=v.date),"calendar"in v&&n(6,l=v.calendar)},t.$$.update=()=>{if(t.$$.dirty&1){e:n(0,a=[...a])}},[a,s,m,r,i,o,l]}var Uf=class extends de{constructor(e){super();he(this,e,K1,Z1,le,{events:0,categories:3,dayView:4,date:5,calendar:6},$1)}},Si=Uf;function Q1(t){be(t,"svelte-1uhffao",".day-view.svelte-1uhffao{padding:5px 15px;display:flex;flex-flow:column nowrap;gap:0.5rem}.nav.svelte-1uhffao,.date.svelte-1uhffao{display:flex;justify-content:space-between;align-items:center}.left-nav.svelte-1uhffao{display:flex}.left-nav.svelte-1uhffao .clickable-icon{margin-right:0}.calendar-clickable.svelte-1uhffao{align-items:center;cursor:pointer;display:flex;justify-content:center}h3.svelte-1uhffao{margin:0}.day-view.svelte-1uhffao .flag-container > .flag{padding-left:0.5rem}.title-container.svelte-1uhffao{display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.day-number.svelte-1uhffao{font-size:small}")}function zf(t,e,n){let a=t.slice();return a[24]=e[n][0],a[25]=e[n][1],a}function Yf(t){let e,n,a,r;return{c(){e=B("div"),n=B("em"),a=fe("Day "),r=fe(t[8]),D(e,"class","day-number svelte-1uhffao")},m(i,o){R(i,e,o),C(e,n),C(n,a),C(n,r)},p(i,o){o&256&&ge(r,i[8])},d(i){i&&q(e)}}}function $f(t){let e,n,a=t[5],r=[];for(let o=0;oG(r[o],1,1,()=>{r[o]=null});return{c(){e=B("div");for(let o=0;o{ee=null}),_e());let ve={};K&8&&(ve.events=Z[3].events),K&128&&(ve.categories=Z[7]),K&4&&(ve.date=Z[2]),K&2&&(ve.calendar=Z[1]),x.$set(ve)},i(Z){T||(P(ee),P(x.$$.fragment,Z),T=!0)},o(Z){G(ee),G(x.$$.fragment,Z),T=!1},d(Z){Z&&q(e),$&&$.d(),ee&&ee.d(),J(x),I=!1,we(U)}}}function J1(t,e,n){let a,r,i,o,l,s,{displayDayNumber:c}=e,u=Ne("calendar"),d;u.subscribe(x=>{n(1,d=x)});let m;Ne("displayMoons").subscribe(x=>n(4,m=x)),d.on("day-update",()=>{n(2,r=d.viewing),n(6,a=d.viewedDate),n(3,i=d.getDayForDate(r)),n(5,l=i.moons)});let h=Ve(),y=x=>{new Ga.ExtraButtonComponent(x).setIcon("cross").setTooltip("Close")},p=x=>{new Ga.ExtraButtonComponent(x).setIcon("fantasy-calendar-reveal").setTooltip("Show on Calendar").onClick(()=>{n(1,d.displayed.year=d.viewing.year,d),d.setCurrentMonth(d.viewing.month)})},S=x=>{new Ga.ExtraButtonComponent(x).setIcon("plus-with-circle").setTooltip("New Event").onClick(()=>h("event",r))},_=x=>{new Ga.ExtraButtonComponent(x).setIcon("left-arrow")},A=x=>{new Ga.ExtraButtonComponent(x).setIcon("right-arrow")},L=()=>h("reveal"),k=()=>h("close"),E=()=>d.goToPreviousDay(),w=()=>d.goToNextDay();function N(x){ce.call(this,t,x)}function F(x){ce.call(this,t,x)}function j(x){ce.call(this,t,x)}return t.$$set=x=>{"displayDayNumber"in x&&n(0,c=x.displayDayNumber)},t.$$.update=()=>{if(t.$$.dirty&2){e:n(6,a=d.viewedDate)}if(t.$$.dirty&2){e:n(2,r=d.viewing)}if(t.$$.dirty&6){e:n(3,i=d.getDayForDate(r))}if(t.$$.dirty&6){e:n(8,o=d.dayNumberForDate(r))}if(t.$$.dirty&8){e:n(5,l=i.moons)}if(t.$$.dirty&2){e:n(7,s=d.categories)}},[c,d,r,i,m,l,a,s,o,h,y,p,S,_,A,L,k,E,w,N,F,j]}var Kf=class extends de{constructor(e){super();he(this,e,J1,X1,le,{displayDayNumber:0},Q1)}},Qf=Kf;function eb(t){be(t,"svelte-1gou5hh",".dot.svelte-1gou5hh{display:inline-block;min-height:6px;min-width:6px;height:6px;width:6px;margin:0 2px}.active.svelte-1gou5hh{color:var(--text-on-accent)}")}function tb(t){let e,n,a,r;return{c(){e=sn("svg"),n=sn("circle"),D(n,"stroke",a=t[2]??"currentColor"),D(n,"fill",r=t[2]??"currentColor"),D(n,"cx","3"),D(n,"cy","3"),D(n,"r","2"),D(e,"class","dot svelte-1gou5hh"),D(e,"viewBox","0 0 6 6"),D(e,"xmlns","http://www.w3.org/2000/svg"),me(e,"filled",t[0]),me(e,"active",t[1])},m(i,o){R(i,e,o),C(e,n)},p(i,[o]){o&4&&a!==(a=i[2]??"currentColor")&&D(n,"stroke",a),o&4&&r!==(r=i[2]??"currentColor")&&D(n,"fill",r),o&1&&me(e,"filled",i[0]),o&2&&me(e,"active",i[1])},i:Q,o:Q,d(i){i&&q(e)}}}function nb(t,e,n){let{isFilled:a=!0}=e,{isActive:r=!1}=e,{color:i}=e;return t.$$set=o=>{"isFilled"in o&&n(0,a=o.isFilled),"isActive"in o&&n(1,r=o.isActive),"color"in o&&n(2,i=o.color)},[a,r,i]}var Xf=class extends de{constructor(e){super();he(this,e,nb,tb,le,{isFilled:0,isActive:1,color:2},eb)}},Jf=Xf;function ab(t){be(t,"svelte-1w3ytba",".dots-container.svelte-1w3ytba{width:100%}.dot-container.svelte-1w3ytba{display:flex;flex-flow:row nowrap;width:fit-content;margin:auto;line-height:6px;min-height:6px}.centered.svelte-1w3ytba{justify-content:center;align-items:center}.overflow.svelte-1w3ytba{color:var(--text-muted);font-size:xx-small;display:flex;justify-content:flex-end;width:100%;line-height:1.25}")}function eh(t){let e,n,a,r;return{c(){e=B("div"),D(e,"class","dot-container centered svelte-1w3ytba")},m(i,o){R(i,e,o),a||(r=ue(n=t[2].call(null,e)),a=!0)},p:Q,d(i){i&&q(e),a=!1,r()}}}function th(t){let e,n,a;return{c(){e=B("span"),n=fe("+"),a=fe(t[1])},m(r,i){R(r,e,i),C(e,n),C(e,a)},p(r,i){i&2&&ge(a,r[1])},d(r){r&&q(e)}}}function rb(t){let e,n=t[0],a,r,i=eh(t),o=t[1]>0&&th(t);return{c(){e=B("div"),i.c(),a=W(),r=B("div"),o&&o.c(),D(r,"class","overflow svelte-1w3ytba"),D(e,"class","dots-container svelte-1w3ytba")},m(l,s){R(l,e,s),i.m(e,null),C(e,a),C(e,r),o&&o.m(r,null)},p(l,[s]){s&1&&le(n,n=l[0])?(i.d(1),i=eh(l),i.c(),i.m(e,a)):i.p(l,s),l[1]>0?o?o.p(l,s):(o=th(l),o.c(),o.m(r,null)):o&&(o.d(1),o=null)},i:Q,o:Q,d(l){l&&q(e),i.d(l),o&&o.d()}}}function ib(t,e,n){let{events:a=[]}=e,{categories:r}=e,{calendar:i}=e,o=0,l,s=0,c=d=>{if(l=d,a.length){let m=d.parentElement?.getBoundingClientRect()?.width;if(!m||Math.floor(m)==Math.floor(s))return;s=m;let v=m;d.empty(),n(1,o=0);for(let h of a)if(new Jf({target:d,props:{color:u(h)}}),v=m-d.getBoundingClientRect().width,v<0){d.lastElementChild.detach(),n(1,o=a.length-a.indexOf(h));break}else if(v==0){n(1,o=a.length-a.indexOf(h)-1);break}}};i.on("view-resized",()=>{!l||c(l)});let u=d=>r.find(m=>m.id==d.category)?.color;return t.$$set=d=>{"events"in d&&n(0,a=d.events),"categories"in d&&n(3,r=d.categories),"calendar"in d&&n(4,i=d.calendar)},[a,o,c,r,i]}var nh=class extends de{constructor(e){super();he(this,e,ib,rb,le,{events:0,categories:3,calendar:4},ab)}},ah=nh;function ob(t){be(t,"svelte-3pptg2",".day.svelte-3pptg2{background-color:transparent;border:2px solid transparent;border-radius:4px;color:var(--color-text-day);cursor:pointer;font-size:0.8em;height:100%;padding:2px;position:relative;text-align:center;vertical-align:baseline;overflow:visible;display:flex;flex-flow:column nowrap}.active.svelte-3pptg2{background-color:var(--background-secondary)}.viewing.svelte-3pptg2{border:2px solid var(--background-modifier-border)}.adjacent-month.svelte-3pptg2{opacity:0.25}")}function rh(t,e,n){let a=t.slice();return a[20]=e[n][0],a[21]=e[n][1],a}function sb(t){let e,n;return e=new ah({props:{events:t[4],categories:t[9],calendar:t[0].calendar}}),{c(){ne(e.$$.fragment)},m(a,r){te(e,a,r),n=!0},p(a,r){let i={};r&16&&(i.events=a[4]),r&512&&(i.categories=a[9]),r&1&&(i.calendar=a[0].calendar),e.$set(i)},i(a){n||(P(e.$$.fragment,a),n=!0)},o(a){G(e.$$.fragment,a),n=!1},d(a){J(e,a)}}}function lb(t){let e,n,a,r=t[5]&&t[10]&&t[10].length&&ih(t);return n=new Si({props:{events:t[4],categories:t[9],date:t[8],calendar:t[0].calendar}}),n.$on("event-click",t[12]),n.$on("event-mouseover",t[13]),n.$on("event-context",t[14]),{c(){r&&r.c(),e=W(),ne(n.$$.fragment)},m(i,o){r&&r.m(i,o),R(i,e,o),te(n,i,o),a=!0},p(i,o){i[5]&&i[10]&&i[10].length?r?(r.p(i,o),o&1056&&P(r,1)):(r=ih(i),r.c(),P(r,1),r.m(e.parentNode,e)):r&&(De(),G(r,1,1,()=>{r=null}),_e());let l={};o&16&&(l.events=i[4]),o&512&&(l.categories=i[9]),o&256&&(l.date=i[8]),o&1&&(l.calendar=i[0].calendar),n.$set(l)},i(i){a||(P(r),P(n.$$.fragment,i),a=!0)},o(i){G(r),G(n.$$.fragment,i),a=!1},d(i){r&&r.d(i),i&&q(e),J(n,i)}}}function ih(t){let e,n,a=t[10],r=[];for(let o=0;oG(r[o],1,1,()=>{r[o]=null});return{c(){e=B("div");for(let o=0;o{h[_]=null}),_e(),l=h[o],l?l.p(p,S):(l=h[o]=v[o](p),l.c()),P(l,1),l.m(e,null)),(!u||S&2&&s!==(s=""+(xo(p[1]?"adjacent-month fantasy-adjacent-month":"")+" svelte-3pptg2")))&&D(e,"class",s),(!u||S&20&&c!==(c=!p[2]&&p[4].length?`${p[4].length} event${p[4].length==1?"":"s"}`:void 0))&&D(e,"aria-label",c),S&2&&me(e,"day",!0),S&2&&me(e,"fantasy-day",!0),S&130&&me(e,"active",p[7]&&!p[1]),S&74&&me(e,"viewing",p[3]&&p[6]&&!p[1])},i(p){u||(P(l),u=!0)},o(p){G(l),u=!1},d(p){p&&q(e),h[o].d(),d=!1,we(m)}}}function cb(t,e,n){let a,r,i,o,l,s=Ve(),{day:c}=e,{adjacent:u}=e,{fullView:d}=e,m=[],v;Ne("dayView").subscribe(w=>n(3,v=w));let y;Ne("displayMoons").subscribe(w=>n(5,y=w)),c.calendar.on("month-update",()=>{n(7,o=c.isCurrentDay),n(6,l=c.isDisplaying),n(4,m=c.events)}),c.calendar.on("day-update",()=>{n(7,o=c.isCurrentDay),n(6,l=c.isDisplaying)});function S(w){ce.call(this,t,w)}function _(w){ce.call(this,t,w)}function A(w){ce.call(this,t,w)}let L=()=>s("day-click",c),k=()=>s("day-doubleclick",c),E=w=>s("day-context-menu",{day:c,evt:w});return t.$$set=w=>{"day"in w&&n(0,c=w.day),"adjacent"in w&&n(1,u=w.adjacent),"fullView"in w&&n(2,d=w.fullView)},t.$$.update=()=>{if(t.$$.dirty&3){e:u||n(4,m=c.events)}if(t.$$.dirty&1){e:n(10,a=c.moons)}if(t.$$.dirty&1){e:n(9,r=c.calendar.categories)}if(t.$$.dirty&1){e:n(8,i=c.date)}if(t.$$.dirty&1){e:n(7,o=c.isCurrentDay)}if(t.$$.dirty&1){e:n(6,l=c.isDisplaying)}if(t.$$.dirty&8){e:n(3,v)}},[c,u,d,v,m,y,l,o,i,r,a,s,S,_,A,L,k,E]}var sh=class extends de{constructor(e){super();he(this,e,cb,ub,le,{day:0,adjacent:1,fullView:2},ob)}},Ar=sh;function db(t){be(t,"svelte-1cfzxxk",`.fantasy-month.svelte-1cfzxxk.svelte-1cfzxxk{display:grid;grid-template-columns:repeat(
var(--calendar-columns),
var(--column-widths)
);grid-auto-rows:var(--calendar-rows)}.intercalary.svelte-1cfzxxk.svelte-1cfzxxk{display:grid;grid-template-columns:1fr;grid-template-rows:auto auto;border-top:1px solid var(--background-modifier-border);border-bottom:1px solid var(--background-modifier-border);border-radius:0;align-items:center}.intercalary.svelte-1cfzxxk span.month.svelte-1cfzxxk{text-align:center}.intercalary.svelte-1cfzxxk .fantasy-month.svelte-1cfzxxk{grid-template-columns:unset;grid-auto-columns:var(--column-widths);align-items:center;justify-content:center}.leapday-container.svelte-1cfzxxk.svelte-1cfzxxk{grid-column:span var(--calendar-columns);display:flex;justify-content:center;align-items:center;border-top:1px solid var(--background-modifier-border);border-bottom:1px solid var(--background-modifier-border);color:var(--text-accent)}.full-view.svelte-1cfzxxk.svelte-1cfzxxk{height:100%;margin-bottom:0.5rem}.month.svelte-1cfzxxk.svelte-1cfzxxk{padding:0.25rem}.month-name.svelte-1cfzxxk.svelte-1cfzxxk{margin:0}.month.svelte-1cfzxxk .fantasy-day.day{padding:0px}`)}function lh(t,e,n){let a=t.slice();return a[24]=e[n],a}function uh(t,e,n){let a=t.slice();return a[24]=e[n],a}function ch(t,e,n){let a=t.slice();return a[29]=e[n],a}function dh(t,e,n){let a=t.slice();return a[29]=e[n],a}function fh(t,e,n){let a=t.slice();return a[24]=e[n],a}function hh(t){let e,n=t[1].name+"",a;return{c(){e=B("h3"),a=fe(n),D(e,"class","month-name svelte-1cfzxxk")},m(r,i){R(r,e,i),C(e,a)},p(r,i){i[0]&2&&n!==(n=r[1].name+"")&&ge(a,n)},d(r){r&&q(e)}}}function mh(t){let e,n=t[1].name+"",a;return{c(){e=B("span"),a=fe(n),D(e,"class","month svelte-1cfzxxk")},m(r,i){R(r,e,i),C(e,a)},p(r,i){i[0]&2&&n!==(n=r[1].name+"")&&ge(a,n)},d(r){r&&q(e)}}}function fb(t){let e;return{c(){e=B("div")},m(n,a){R(n,e,a)},p:Q,i:Q,o:Q,d(n){n&&q(e)}}}function hb(t){let e,n;return e=new Ar({props:{day:t[24],adjacent:!0,fullView:t[3]}}),{c(){ne(e.$$.fragment)},m(a,r){te(e,a,r),n=!0},p(a,r){let i={};r[0]&512&&(i.day=a[24]),r[0]&8&&(i.fullView=a[3]),e.$set(i)},i(a){n||(P(e.$$.fragment,a),n=!0)},o(a){G(e.$$.fragment,a),n=!1},d(a){J(e,a)}}}function ph(t){let e,n,a,r,i=[hb,fb],o=[];function l(s,c){return s[6]&&s[24]!=null?0:1}return e=l(t,[-1,-1]),n=o[e]=i[e](t),{c(){n.c(),a=Ue()},m(s,c){o[e].m(s,c),R(s,a,c),r=!0},p(s,c){let u=e;e=l(s,c),e===u?o[e].p(s,c):(De(),G(o[u],1,1,()=>{o[u]=null}),_e(),n=o[e],n?n.p(s,c):(n=o[e]=i[e](s),n.c()),P(n,1),n.m(a.parentNode,a))},i(s){r||(P(n),r=!0)},o(s){G(n),r=!1},d(s){o[e].d(s),s&&q(a)}}}function gh(t){let e,n,a,r,i,o,l,s=t[10](t[24]).next,c=[];for(let y=0;y{d[S]=null}),_e(),r=d[a],r?r.p(y,p):(r=d[a]=u[a](y),r.c()),P(r,1),r.m(n,null)),p[0]&256){v=y[10](y[24]).prev;let _;for(_=0;_{r=null}),_e()),o[24].leapday?.numbered?i&&(De(),G(i,1,1,()=>{i=null}),_e()):i?(i.p(o,l),l[0]&256&&P(i,1)):(i=bh(o),i.c(),P(i,1),i.m(n.parentNode,n))},i(o){a||(P(r),P(i),a=!0)},o(o){G(r),G(i),a=!1},d(o){r&&r.d(o),o&&q(e),i&&i.d(o),o&&q(n)}}}function gb(t){let e;return{c(){e=B("div")},m(n,a){R(n,e,a)},p:Q,i:Q,o:Q,d(n){n&&q(e)}}}function yb(t){let e,n;return e=new Ar({props:{day:t[24],adjacent:!0,fullView:t[3]}}),{c(){ne(e.$$.fragment)},m(a,r){te(e,a,r),n=!0},p(a,r){let i={};r[0]&128&&(i.day=a[24]),r[0]&8&&(i.fullView=a[3]),e.$set(i)},i(a){n||(P(e.$$.fragment,a),n=!0)},o(a){G(e.$$.fragment,a),n=!1},d(a){J(e,a)}}}function Dh(t){let e,n,a,r,i=[yb,gb],o=[];function l(s,c){return s[6]?0:1}return e=l(t,[-1,-1]),n=o[e]=i[e](t),{c(){n.c(),a=Ue()},m(s,c){o[e].m(s,c),R(s,a,c),r=!0},p(s,c){let u=e;e=l(s,c),e===u?o[e].p(s,c):(De(),G(o[u],1,1,()=>{o[u]=null}),_e(),n=o[e],n?n.p(s,c):(n=o[e]=i[e](s),n.c()),P(n,1),n.m(a.parentNode,a))},i(s){r||(P(n),r=!0)},o(s){G(n),r=!1},d(s){o[e].d(s),s&&q(a)}}}function _h(t){let e,n,a,r,i=t[9],o=[];for(let h=0;hG(o[h],1,1,()=>{o[h]=null}),s=t[8],c=[];for(let h=0;hG(c[h],1,1,()=>{c[h]=null}),d=t[7],m=[];for(let h=0;hG(m[h],1,1,()=>{m[h]=null});return{c(){e=B("div");for(let h=0;h{let T=x.weekday,I=x.calendar.weekdays.length-T,U=[];I!=0&&(U=[...Array(I).keys()]);let $=[];return T!=0&&($=[...Array(T).keys()]),{next:U,prev:$}};function y(x){ce.call(this,t,x)}function p(x){ce.call(this,t,x)}function S(x){ce.call(this,t,x)}function _(x){ce.call(this,t,x)}function A(x){ce.call(this,t,x)}function L(x){ce.call(this,t,x)}function k(x){ce.call(this,t,x)}function E(x){ce.call(this,t,x)}function w(x){ce.call(this,t,x)}function N(x){ce.call(this,t,x)}function F(x){ce.call(this,t,x)}function j(x){ce.call(this,t,x)}return t.$$set=x=>{"yearView"in x&&n(0,l=x.yearView),"month"in x&&n(1,s=x.month),"columns"in x&&n(2,c=x.columns),"fullView"in x&&n(3,u=x.fullView),"weeks"in x&&n(4,d=x.weeks),"intercalary"in x&&n(5,m=x.intercalary),"showPad"in x&&n(6,v=x.showPad)},t.$$.update=()=>{if(t.$$.dirty[0]&2){e:n(11,a=s.calendar.getPaddedDaysForMonth(s))}if(t.$$.dirty[0]&2048){e:n(9,r=a.previous)}if(t.$$.dirty[0]&2){e:n(8,i=s.days)}if(t.$$.dirty[0]&2048){e:n(7,o=a.next)}},[l,s,c,u,d,m,v,o,i,r,h,a,y,p,S,_,A,L,k,E,w,N,F,j]}var Ch=class extends de{constructor(e){super();he(this,e,bb,vb,le,{yearView:0,month:1,columns:2,fullView:3,weeks:4,intercalary:5,showPad:6},db,[-1,-1])}},Vn=Ch;var Bi=Ee(require("obsidian"));function wb(t){be(t,"svelte-131055d",".fantasy-nav.nav.nav.svelte-131055d{padding:10px 0px;margin:0;display:flex;flex-flow:row nowrap;justify-content:space-between;align-items:stretch}.container.svelte-131055d{display:flex;align-items:center}.fantasy-title.svelte-131055d{margin:0;line-height:1.25}.fantasy-right-nav.svelte-131055d{display:flex;justify-content:center;align-items:flex-start}.calendar-clickable.svelte-131055d{align-items:center;cursor:pointer;display:flex;justify-content:center}.title-container.svelte-131055d{display:flex;flex-flow:column nowrap;align-items:flex-start}")}function Db(t){let e,n,a,r,i,o,l,s,c,u,d,m,v,h,y,p,S,_,A,L,k,E,w,N,F,j;return{c(){e=B("div"),n=B("div"),a=B("h3"),r=B("span"),i=fe(t[0]),o=W(),l=B("span"),s=fe(t[1]),c=W(),u=B("div"),d=B("div"),m=B("div"),h=W(),y=B("div"),p=B("span"),p.textContent="Today",_=W(),A=B("div"),E=W(),w=B("div"),D(r,"class","fantasy-month month"),D(l,"class","fantasy-year year"),D(a,"class","fantasy-title title svelte-131055d"),D(n,"class","title-container svelte-131055d"),D(m,"class","arrow calendar-clickable svelte-131055d"),D(m,"aria-label",t[4]),D(y,"class","reset-button calendar-clickable svelte-131055d"),D(y,"aria-label",S="Today is "+t[2]),D(A,"class","arrow right calendar-clickable svelte-131055d"),D(A,"aria-label",L=t[3].name),D(w,"class","calendar-clickable svelte-131055d"),D(w,"aria-label","Calendar Settings"),D(d,"class","container svelte-131055d"),D(u,"class","right-nav fantasy-right-nav svelte-131055d"),D(e,"class","fantasy-nav nav svelte-131055d")},m(x,T){R(x,e,T),C(e,n),C(n,a),C(a,r),C(r,i),C(a,o),C(a,l),C(l,s),C(e,c),C(e,u),C(u,d),C(d,m),C(d,h),C(d,y),C(y,p),C(d,_),C(d,A),C(d,E),C(d,w),F||(j=[ue(v=t[6].call(null,m)),re(m,"click",t[10]),re(y,"click",t[11]),ue(k=t[7].call(null,A)),re(A,"click",t[12]),ue(N=t[8].call(null,w)),re(w,"click",t[13])],F=!0)},p(x,[T]){T&1&&ge(i,x[0]),T&2&&ge(s,x[1]),T&16&&D(m,"aria-label",x[4]),T&4&&S!==(S="Today is "+x[2])&&D(y,"aria-label",S),T&8&&L!==(L=x[3].name)&&D(A,"aria-label",L)},i:Q,o:Q,d(x){x&&q(e),F=!1,we(j)}}}function _b(t,e,n){let a,r=Ve(),{month:i}=e,{year:o}=e,{current:l}=e,s=Ne("calendar"),c;s.subscribe(A=>{c=A});let u=c.getPreviousMonth(),d=c.getNextMonth();c.on("month-update",()=>{n(9,u=c.getPreviousMonth()),n(3,d=c.getNextMonth())});let m=A=>{new Bi.ExtraButtonComponent(A).setIcon("left-arrow")},v=A=>{new Bi.ExtraButtonComponent(A).setIcon("right-arrow")},h=A=>{new Bi.ExtraButtonComponent(A).setIcon("gear")},y=()=>r("previous"),p=()=>r("reset"),S=A=>r("next"),_=A=>r("settings",A);return t.$$set=A=>{"month"in A&&n(0,i=A.month),"year"in A&&n(1,o=A.year),"current"in A&&n(2,l=A.current)},t.$$.update=()=>{if(t.$$.dirty&512){e:n(4,a=u?.name??"No Previous Month")}},[i,o,l,d,a,r,m,v,h,u,y,p,S,_]}var Eh=class extends de{constructor(e){super();he(this,e,_b,Db,le,{month:0,year:1,current:2},wb)}},Ah=Eh;var Ni=Ee(require("obsidian"));function Cb(t){be(t,"svelte-i3pajt","#calendar-container .fantasy-nav.nav.nav.svelte-i3pajt{padding:0;margin:0;display:flex;flex-flow:row nowrap;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:2}.fantasy-year-nav.svelte-i3pajt{display:flex;align-items:center;margin-right:auto}.container.svelte-i3pajt{display:flex;align-items:center}.fantasy-title.svelte-i3pajt{margin:0}.fantasy-right-nav.svelte-i3pajt{display:flex;justify-content:center;align-items:flex-start}.calendar-clickable.svelte-i3pajt{align-items:center;cursor:pointer;display:flex;justify-content:center}")}function kh(t){let e,n,a,r;return{c(){e=B("div"),D(e,"class","arrow calendar-clickable svelte-i3pajt"),D(e,"aria-label","Previous Year")},m(i,o){R(i,e,o),a||(r=[ue(n=t[4].call(null,e)),re(e,"click",t[7])],a=!0)},p:Q,d(i){i&&q(e),a=!1,we(r)}}}function xh(t){let e,n,a,r;return{c(){e=B("div"),D(e,"class","arrow right calendar-clickable svelte-i3pajt"),D(e,"aria-label","Next Year")},m(i,o){R(i,e,o),a||(r=[ue(n=t[5].call(null,e)),re(e,"click",t[9])],a=!0)},p:Q,d(i){i&&q(e),a=!1,we(r)}}}function Eb(t){let e,n,a,r,i,o,l,s,c,u,d,m,v,h,y,p,S,_,A=t[1]&&kh(t),L=t[1]&&xh(t);return{c(){e=B("div"),n=B("div"),a=B("h2"),r=B("span"),i=fe(t[0]),o=W(),l=B("div"),s=B("div"),A&&A.c(),c=W(),u=B("div"),d=B("span"),d.textContent="Today",v=W(),L&&L.c(),h=W(),y=B("div"),D(r,"class","fantasy-year"),D(a,"class","fantasy-title svelte-i3pajt"),D(n,"class","fantasy-year-nav svelte-i3pajt"),D(u,"class","reset-button calendar-clickable svelte-i3pajt"),D(u,"aria-label",m="Today is "+t[2]),D(y,"class","calendar-clickable svelte-i3pajt"),D(y,"aria-label","Calendar Settings"),D(s,"class","container svelte-i3pajt"),D(l,"class","right-nav fantasy-right-nav svelte-i3pajt"),D(e,"class","fantasy-nav nav svelte-i3pajt")},m(k,E){R(k,e,E),C(e,n),C(n,a),C(a,r),C(r,i),C(e,o),C(e,l),C(l,s),A&&A.m(s,null),C(s,c),C(s,u),C(u,d),C(s,v),L&&L.m(s,null),C(s,h),C(s,y),S||(_=[re(u,"click",t[8]),ue(p=t[6].call(null,y)),re(y,"click",t[10])],S=!0)},p(k,[E]){E&1&&ge(i,k[0]),k[1]?A?A.p(k,E):(A=kh(k),A.c(),A.m(s,c)):A&&(A.d(1),A=null),E&4&&m!==(m="Today is "+k[2])&&D(u,"aria-label",m),k[1]?L?L.p(k,E):(L=xh(k),L.c(),L.m(s,h)):L&&(L.d(1),L=null)},i:Q,o:Q,d(k){k&&q(e),A&&A.d(),L&&L.d(),S=!1,we(_)}}}function Ab(t,e,n){let a=Ve(),{year:r}=e,{arrows:i=!1}=e,{current:o}=e,l=h=>{new Ni.ExtraButtonComponent(h).setIcon("left-arrow")},s=h=>{new Ni.ExtraButtonComponent(h).setIcon("right-arrow")},c=h=>{new Ni.ExtraButtonComponent(h).setIcon("gear")},u=()=>a("previous"),d=()=>a("reset"),m=h=>a("next"),v=h=>a("settings",h);return t.$$set=h=>{"year"in h&&n(0,r=h.year),"arrows"in h&&n(1,i=h.arrows),"current"in h&&n(2,o=h.current)},[r,i,o,a,l,s,c,u,d,m,v]}var Fh=class extends de{constructor(e){super();he(this,e,Ab,Eb,le,{year:0,arrows:1,current:2},Cb)}},Mi=Fh;function kb(t){be(t,"svelte-15hvixf",".year-view.svelte-15hvixf{height:100%;position:relative;display:flex;flex-direction:column}.year.svelte-15hvixf{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;overflow:auto;flex:1}.year.svelte-15hvixf:not(.full-view){grid-template-columns:1fr}")}function xb(t){let e,n,a,r,i,o,l;return n=new Mi({props:{year:t[3],current:t[0]}}),n.$on("next",t[9]),n.$on("previous",t[10]),n.$on("reset",t[11]),n.$on("settings",t[12]),{c(){e=B("div"),ne(n.$$.fragment),a=W(),r=B("div"),D(r,"class","year svelte-15hvixf"),me(r,"full-view",t[1]),D(e,"class","year-view svelte-15hvixf")},m(s,c){R(s,e,c),te(n,e,null),C(e,a),C(e,r),t[13](r),i=!0,o||(l=re(r,"scroll",t[5],{once:!0}),o=!0)},p(s,[c]){let u={};c&8&&(u.year=s[3]),c&1&&(u.current=s[0]),n.$set(u),c&2&&me(r,"full-view",s[1])},i(s){i||(P(n.$$.fragment,s),i=!0)},o(s){G(n.$$.fragment,s),i=!1},d(s){s&&q(e),J(n),t[13](null),o=!1,l()}}}function Fb(t,e,n){let a,r=Ve(),{current:i}=e,{year:o}=e,{columns:l}=e,{fullView:s}=e,c,u,d,m=Ne("calendar"),v;m.subscribe(K=>{n(8,v=K)});let h=[],y=Ne("dayView"),p=Ne("displayMoons"),S=new IntersectionObserver((K,ve)=>{ve===S&&(!K.length||!K[0].isIntersecting||(S.disconnect(),!(!v.canGoToNextYear(d.year)&&d.number===v.data.months.length-1)&&(L(),j(h.shift()),_())))},{root:c,rootMargin:"0px",threshold:.25}),_=()=>{let K=c.children[c.children.length-2];!K||S.observe(K)},A=new IntersectionObserver((K,ve)=>{if(ve!==A||!K&&!K.length||K[0].isIntersecting)return;let xe=c.getBoundingClientRect();K[0].boundingClientRect.top{if(!(!v.canGoToNextYear(d.year)&&d.number===v.data.months.length-1)){if(d=v.getMonth(d.number+1,d.year),d.number===0&&!(c.lastElementChild instanceof HTMLHeadingElement)){let ve=c.createEl("h2",{text:v.getNameForYear(d.year),cls:"fantasy-title"});h.push(ve),A.disconnect(),A.observe(ve)}h.push(F(d,!1)),K&&(u=v.getMonth((u?.number??0)+1,u?.year??1)),E()}},k=new IntersectionObserver((K,ve)=>{ve===k&&(!K.length||!K[0].isIntersecting||(k.disconnect(),!!u&&(N(),j(h.pop()),E())))},{root:c,rootMargin:"0px",threshold:.25}),E=()=>{let K=c.children[1];!K||k.observe(K)},w=new IntersectionObserver((K,ve)=>{ve===w&&(!K&&!K.length||K[0].isIntersecting&&(n(6,o-=1),A.observe(K[0].target),w.disconnect()))},{root:c,rootMargin:"0px",threshold:0}),N=(K=!0)=>{if(u=v.getMonth(u.number-1,u.year),!!u){if(h.unshift(F(u,!0)),u.number===0&&!(c.firstElementChild instanceof HTMLHeadingElement)){let ve=createEl("h2",{text:v.getNameForYear(u.year),cls:"fantasy-title"});c.prepend(ve),h.unshift(ve),w.disconnect(),w.observe(ve)}K&&(d=v.getMonth(d.number-1,d.year)),_()}},F=(K,ve)=>{let xe=new Vn({target:c,anchor:ve?c.children[0]:null,props:{month:K,fullView:!1,yearView:!0,columns:l,weeks:v.weekdays.length,showPad:!1},context:new Map([["dayView",y],["displayMoons",p]])});return xe.$on("day-click",Ae=>r("day-click",Ae.detail)),xe.$on("day-doubleclick",Ae=>r("day-doubleclick",Ae.detail)),xe.$on("day-context-menu",Ae=>r("day-context-menu",Ae.detail)),xe.$on("event-mouseover",Ae=>r("event-mouseover",Ae.detail)),xe.$on("event-mouseover",Ae=>r("event-mouseover",Ae.detail)),xe},j=K=>{K instanceof HTMLHeadingElement?K.detach():K.$destroy()},x=async(K=!1)=>{for(let xe of h)j(xe);h.splice(0,h.length),c.empty(),await Kn(),n(6,o=v.current.year),u=v.getMonth(v.displayed.month-1,v.displayed.year),d=u;for(let xe=0;xe{k.disconnect(),S.disconnect(),w.disconnect(),A.disconnect()}),$n(x);let T=async()=>{await Kn(),k.observe(c.children[1]),S.observe(c.children[c.children.length-2])};function I(K){ce.call(this,t,K)}function U(K){ce.call(this,t,K)}let $=()=>x(!0);function ee(K){ce.call(this,t,K)}function Z(K){Aa[K?"unshift":"push"](()=>{c=K,n(2,c)})}return t.$$set=K=>{"current"in K&&n(0,i=K.current),"year"in K&&n(6,o=K.year),"columns"in K&&n(7,l=K.columns),"fullView"in K&&n(1,s=K.fullView)},t.$$.update=()=>{if(t.$$.dirty&320){e:n(3,a=v.getNameForYear(o))}},[i,s,c,a,x,T,o,l,v,I,U,$,ee,Z]}var Th=class extends de{constructor(e){super();he(this,e,Fb,xb,le,{current:0,year:6,columns:7,fullView:1},kb)}},Sh=Th;var Ss=Ee(require("obsidian"));function Tb(t){be(t,"svelte-ztrrn8",".year.svelte-ztrrn8{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;overflow:auto;flex:1}.year.svelte-ztrrn8:not(.full-view){grid-template-columns:1fr}")}function Bh(t,e,n){let a=t.slice();return a[8]=e[n],a}function Nh(t){let e,n;return e=new Vn({props:{month:t[8],fullView:!1,yearView:!0,columns:t[2],weeks:t[8].calendar.weekdays.length,showPad:!1}}),e.$on("day-click",t[3]),e.$on("day-doubleclick",t[4]),e.$on("day-context-menu",t[5]),e.$on("event-click",t[6]),e.$on("event-mouseover",t[7]),{c(){ne(e.$$.fragment)},m(a,r){te(e,a,r),n=!0},p(a,r){let i={};r&2&&(i.month=a[8]),r&4&&(i.columns=a[2]),r&2&&(i.weeks=a[8].calendar.weekdays.length),e.$set(i)},i(a){n||(P(e.$$.fragment,a),n=!0)},o(a){G(e.$$.fragment,a),n=!1},d(a){J(e,a)}}}function Sb(t){let e,n,a=t[1],r=[];for(let o=0;oG(r[o],1,1,()=>{r[o]=null});return{c(){e=B("div");for(let o=0;o{"fullView"in d&&n(0,a=d.fullView),"months"in d&&n(1,r=d.months),"columns"in d&&n(2,i=d.columns)},[a,r,i,o,l,s,c,u]}var Mh=class extends de{constructor(e){super();he(this,e,Bb,Sb,le,{fullView:0,months:1,columns:2},Tb)}},Ih=Mh;function Nb(t){be(t,"svelte-1xpvbi",".year-view.svelte-1xpvbi{height:100%;position:relative;display:flex;flex-direction:column}.year-container.svelte-1xpvbi{flex:1;overflow:auto}")}function Mb(t){let e,n,a,r,i;return n=new Mi({props:{year:t[2],current:t[0],arrows:!0}}),n.$on("next",t[9]),n.$on("previous",t[10]),n.$on("reset",t[11]),n.$on("settings",t[12]),{c(){e=B("div"),ne(n.$$.fragment),a=W(),r=B("div"),D(r,"class","year-container svelte-1xpvbi"),D(e,"class","year-view svelte-1xpvbi")},m(o,l){R(o,e,l),te(n,e,null),C(e,a),C(e,r),t[13](r),i=!0},p(o,[l]){let s={};l&4&&(s.year=o[2]),l&1&&(s.current=o[0]),n.$set(s)},i(o){i||(P(n.$$.fragment,o),i=!0)},o(o){G(n.$$.fragment,o),i=!1},d(o){o&&q(e),J(n),t[13](null)}}}function Ib(t,e,n){let a,r=Ve(),i=Ne("calendar"),o=Ne("dayView"),l=Ne("displayMoons"),s;i.subscribe(F=>{n(8,s=F)});let{year:c}=e,{current:u}=e,{columns:d}=e,m,v=(F,j=!1)=>{let x=s.getMonthsForYear(F),T=new Ih({target:m,anchor:j?m.children[0]:null,props:{months:x,fullView:!0,columns:d},context:new Map([["dayView",o],["displayMoons",l]])});return T.$on("day-click",I=>r("day-click",I.detail)),T.$on("day-doubleclick",I=>r("day-doubleclick",I.detail)),T.$on("day-context-menu",I=>r("day-context-menu",I.detail)),T.$on("event-mouseover",I=>r("event-mouseover",I.detail)),T.$on("event-mouseover",I=>r("event-mouseover",I.detail)),T},h=F=>{F instanceof HTMLHeadingElement?F.detach():F.$destroy()},y=[],p=()=>{if(!s.canGoToNextYear(c)){new Ss.Notice("This is the last year. Additional years can be created in settings.");return}n(6,c=c+1),A(c)},S=()=>{if(c===1){new Ss.Notice("This is the earliest year.");return}n(6,c=c-1),A(c)},_=()=>{n(6,c=s.current.year),A(c)},A=async F=>{y.forEach(j=>h(j)),m.empty(),await Kn(),F=F,y.push(v(F))};$n(()=>y.push(v(c)));let L=()=>p(),k=()=>S(),E=()=>_();function w(F){ce.call(this,t,F)}function N(F){Aa[F?"unshift":"push"](()=>{m=F,n(1,m)})}return t.$$set=F=>{"year"in F&&n(6,c=F.year),"current"in F&&n(0,u=F.current),"columns"in F&&n(7,d=F.columns)},t.$$.update=()=>{if(t.$$.dirty&320){e:n(2,a=s.getNameForYear(c))}},[u,m,a,p,S,_,c,d,s,L,k,E,w,N]}var Oh=class extends de{constructor(e){super();he(this,e,Ib,Mb,le,{year:6,current:0,columns:7},Nb)}},qh=Oh;function Ob(t){be(t,"svelte-li8ss6","#calendar-container.year-view.svelte-li8ss6.svelte-li8ss6{height:100%}#calendar-container.fantasy-calendar.full-view.svelte-li8ss6.svelte-li8ss6{width:100%;padding:0 0.5rem 0.5rem;height:100%;display:flex;flex-flow:column}.fantasy-calendar.full-view.svelte-li8ss6 .month-container.svelte-li8ss6{height:100%}.month-container.svelte-li8ss6.svelte-li8ss6{display:flex}.month-view.svelte-li8ss6.svelte-li8ss6{flex-grow:2}.weeks.svelte-li8ss6.svelte-li8ss6{display:grid;grid-template-rows:auto 1fr}.week-num-container.svelte-li8ss6.svelte-li8ss6{display:grid;grid-template-rows:repeat(var(--calendar-rows), auto);padding:0.25rem 0}.week-num.svelte-li8ss6.svelte-li8ss6{background-color:transparent;border:2px solid transparent;border-radius:4px;color:var(--color-text-day);cursor:pointer;font-size:0.8em;height:100%;padding:2px;position:relative;text-align:center;vertical-align:baseline;overflow:visible}.weekdays.svelte-li8ss6.svelte-li8ss6{display:grid;grid-template-columns:repeat(var(--calendar-columns), 1fr);grid-template-rows:auto;padding:0 0.25rem;gap:2px}.weekday.svelte-li8ss6.svelte-li8ss6{background-color:var(--color-background-heading);color:var(--color-text-heading);font-size:0.6em;letter-spacing:1px;padding:4px;text-transform:uppercase;text-align:center;border:2px solid transparent}hr.svelte-li8ss6.svelte-li8ss6{margin:1rem 0}.moon-container{display:flex;flex-flow:row wrap;align-items:center;justify-content:center}")}function Rh(t,e,n){let a=t.slice();return a[64]=e[n],a}function Lh(t,e,n){let a=t.slice();return a[67]=e[n],a}function qb(t){let e,n,a,r,i,o,l,s,c,u,d;e=new Ah({props:{month:t[6].name,year:t[11],current:t[3].currentDate}}),e.$on("next",t[34]),e.$on("previous",t[35]),e.$on("reset",t[36]),e.$on("settings",t[37]);let m=t[5]&&Ph(t),v=t[9]&&t[9].type=="intercalary"&&!t[14]&&Vh(t),h=t[6].type=="month"&&Hh(t);c=new Vn({props:{columns:t[13].length,weeks:t[7],month:t[6],fullView:t[1]}}),c.$on("day-click",t[44]),c.$on("day-doubleclick",t[45]),c.$on("day-context-menu",t[46]),c.$on("event-click",t[47]),c.$on("event-mouseover",t[48]),c.$on("event-context",t[49]);let y=t[10]&&t[10].type=="intercalary"&&!t[14]&&Gh(t);return{c(){ne(e.$$.fragment),n=W(),a=B("div"),r=B("div"),m&&m.c(),i=W(),o=B("div"),v&&v.c(),l=W(),h&&h.c(),s=W(),ne(c.$$.fragment),u=W(),y&&y.c(),D(r,"class","weeks svelte-li8ss6"),D(o,"class","month-view svelte-li8ss6"),D(a,"class","month-container svelte-li8ss6")},m(p,S){te(e,p,S),R(p,n,S),R(p,a,S),C(a,r),m&&m.m(r,null),C(a,i),C(a,o),v&&v.m(o,null),C(o,l),h&&h.m(o,null),C(o,s),te(c,o,null),C(o,u),y&&y.m(o,null),d=!0},p(p,S){let _={};S[0]&64&&(_.month=p[6].name),S[0]&2048&&(_.year=p[11]),S[0]&8&&(_.current=p[3].currentDate),e.$set(_),p[5]?m?m.p(p,S):(m=Ph(p),m.c(),m.m(r,null)):m&&(m.d(1),m=null),p[9]&&p[9].type=="intercalary"&&!p[14]?v?(v.p(p,S),S[0]&16896&&P(v,1)):(v=Vh(p),v.c(),P(v,1),v.m(o,l)):v&&(De(),G(v,1,1,()=>{v=null}),_e()),p[6].type=="month"?h?h.p(p,S):(h=Hh(p),h.c(),h.m(o,s)):h&&(h.d(1),h=null);let A={};S[0]&8192&&(A.columns=p[13].length),S[0]&128&&(A.weeks=p[7]),S[0]&64&&(A.month=p[6]),S[0]&2&&(A.fullView=p[1]),c.$set(A),p[10]&&p[10].type=="intercalary"&&!p[14]?y?(y.p(p,S),S[0]&17408&&P(y,1)):(y=Gh(p),y.c(),P(y,1),y.m(o,null)):y&&(De(),G(y,1,1,()=>{y=null}),_e())},i(p){d||(P(e.$$.fragment,p),P(v),P(c.$$.fragment,p),P(y),d=!0)},o(p){G(e.$$.fragment,p),G(v),G(c.$$.fragment,p),G(y),d=!1},d(p){J(e,p),p&&q(n),p&&q(a),m&&m.d(),v&&v.d(),h&&h.d(),J(c),y&&y.d()}}}function Rb(t){let e,n;return e=new qh({props:{year:t[12],columns:t[13].length,current:t[3].displayedDate}}),e.$on("next",t[25]),e.$on("previous",t[26]),e.$on("reset",t[27]),e.$on("settings",t[28]),e.$on("day-click",t[29]),e.$on("day-doubleclick",t[30]),e.$on("day-context-menu",t[31]),e.$on("event-click",t[32]),e.$on("event-mouseover",t[33]),{c(){ne(e.$$.fragment)},m(a,r){te(e,a,r),n=!0},p(a,r){let i={};r[0]&4096&&(i.year=a[12]),r[0]&8192&&(i.columns=a[13].length),r[0]&8&&(i.current=a[3].displayedDate),e.$set(i)},i(a){n||(P(e.$$.fragment,a),n=!0)},o(a){G(e.$$.fragment,a),n=!1},d(a){J(e,a)}}}function Lb(t){let e,n;return e=new Sh({props:{year:t[12],fullView:t[1],columns:t[13].length,current:t[3].displayedDate}}),e.$on("next",t[16]),e.$on("previous",t[17]),e.$on("reset",t[18]),e.$on("settings",t[19]),e.$on("day-click",t[20]),e.$on("day-doubleclick",t[21]),e.$on("day-context-menu",t[22]),e.$on("event-click",t[23]),e.$on("event-mouseover",t[24]),{c(){ne(e.$$.fragment)},m(a,r){te(e,a,r),n=!0},p(a,r){let i={};r[0]&4096&&(i.year=a[12]),r[0]&2&&(i.fullView=a[1]),r[0]&8192&&(i.columns=a[13].length),r[0]&8&&(i.current=a[3].displayedDate),e.$set(i)},i(a){n||(P(e.$$.fragment,a),n=!0)},o(a){G(e.$$.fragment,a),n=!1},d(a){J(e,a)}}}function Ph(t){let e,n,a,r=[...Array(t[7]).keys()],i=[];for(let o=0;o{s[v]=null}),_e(),a=s[n],a?a.p(d,m):(a=s[n]=l[n](d),a.c()),P(a,1),a.m(e,null)),(!o||m[0]&8)&&at(e,"--calendar-columns",d[3].weekdays.length),(!o||m[0]&8)&&at(e,"--column-widths",1/d[3].weekdays.length*100+"%"),(!o||m[0]&8)&&at(e,"--calendar-rows",d[3].weeksPerCurrentMonth),m[0]&2&&me(e,"full-view",d[1]),m[0]&4&&me(e,"year-view",d[2]),d[0]&&!d[1]?u?(u.p(d,m),m[0]&3&&P(u,1)):(u=Uh(d),u.c(),P(u,1),u.m(i.parentNode,i)):u&&(De(),G(u,1,1,()=>{u=null}),_e())},i(d){o||(P(a),P(u),o=!0)},o(d){G(a),G(u),o=!1},d(d){d&&q(e),s[n].d(),d&&q(r),u&&u.d(d),d&&q(i)}}}function jb(t,e,n){let a,r,i,o,l,s,c,u,d,{fullView:m=!1}=e,{dayView:v=!1}=e,{yearView:h=!1}=e,{calendar:y}=e,{moons:p}=e,{displayDayNumber:S}=e,{displayWeeks:_}=e,A=pn(v),L=pn(p),k=pn(y);Zn("dayView",A),Zn("displayMoons",L),Zn("calendar",k),y.on("month-update",()=>{n(12,i=y.displayed.year),n(11,o=y.getNameForYear(y.displayed.year)),n(6,l=y.currentMonth),n(10,s=y.nextMonth),n(9,c=y.previousMonth),n(7,d=y.weeksOfMonth(l)),n(8,u=y.weekNumbersOfMonth(l))});let E=()=>y.goToNextYear(),w=()=>y.goToPreviousYear();function N(ie){ce.call(this,t,ie)}function F(ie){ce.call(this,t,ie)}function j(ie){ce.call(this,t,ie)}function x(ie){ce.call(this,t,ie)}function T(ie){ce.call(this,t,ie)}function I(ie){ce.call(this,t,ie)}function U(ie){ce.call(this,t,ie)}let $=()=>y.goToNextYear(),ee=()=>y.goToPreviousYear();function Z(ie){ce.call(this,t,ie)}function K(ie){ce.call(this,t,ie)}function ve(ie){ce.call(this,t,ie)}function xe(ie){ce.call(this,t,ie)}function Ae(ie){ce.call(this,t,ie)}function Oe(ie){ce.call(this,t,ie)}function He(ie){ce.call(this,t,ie)}let st=()=>y.goToNext(),je=()=>y.goToPrevious();function wt(ie){ce.call(this,t,ie)}function Nt(ie){ce.call(this,t,ie)}function Je(ie){ce.call(this,t,ie)}function Te(ie){ce.call(this,t,ie)}function tt(ie){ce.call(this,t,ie)}function Yt(ie){ce.call(this,t,ie)}function $t(ie){ce.call(this,t,ie)}function Rt(ie){ce.call(this,t,ie)}function Ht(ie){ce.call(this,t,ie)}function wn(ie){ce.call(this,t,ie)}function Dn(ie){ce.call(this,t,ie)}function Gn(ie){ce.call(this,t,ie)}function ha(ie){ce.call(this,t,ie)}function ma(ie){ce.call(this,t,ie)}function Ii(ie){ce.call(this,t,ie)}function Oi(ie){ce.call(this,t,ie)}function qi(ie){ce.call(this,t,ie)}function Ri(ie){ce.call(this,t,ie)}function Li(ie){ce.call(this,t,ie)}function Pi(ie){ce.call(this,t,ie)}let ji=()=>n(0,v=!1);function Vi(ie){ce.call(this,t,ie)}function Hi(ie){ce.call(this,t,ie)}function Wi(ie){ce.call(this,t,ie)}function Gi(ie){ce.call(this,t,ie)}return t.$$set=ie=>{"fullView"in ie&&n(1,m=ie.fullView),"dayView"in ie&&n(0,v=ie.dayView),"yearView"in ie&&n(2,h=ie.yearView),"calendar"in ie&&n(3,y=ie.calendar),"moons"in ie&&n(15,p=ie.moons),"displayDayNumber"in ie&&n(4,S=ie.displayDayNumber),"displayWeeks"in ie&&n(5,_=ie.displayWeeks)},t.$$.update=()=>{if(t.$$.dirty[0]&4){e:h&&n(0,v=!1)}if(t.$$.dirty[0]&1){e:A.set(v)}if(t.$$.dirty[0]&32768){e:L.set(p)}if(t.$$.dirty[0]&8){e:k.set(y)}if(t.$$.dirty[0]&8){e:n(14,a=y.plugin.data.showIntercalary)}if(t.$$.dirty[0]&8){e:n(13,r=y.weekdays)}if(t.$$.dirty[0]&8){e:n(12,i=y.displayed.year)}if(t.$$.dirty[0]&8){e:n(11,o=y.getNameForYear(y.displayed.year))}if(t.$$.dirty[0]&8){e:n(6,l=y.currentMonth)}if(t.$$.dirty[0]&8){e:n(10,s=y.nextMonth)}if(t.$$.dirty[0]&8){e:n(9,c=y.previousMonth)}if(t.$$.dirty[0]&72){e:n(8,u=y.weekNumbersOfMonth(l))}if(t.$$.dirty[0]&72){e:n(7,d=y.weeksOfMonth(l))}},[v,m,h,y,S,_,l,d,u,c,s,o,i,r,a,p,E,w,N,F,j,x,T,I,U,$,ee,Z,K,ve,xe,Ae,Oe,He,st,je,wt,Nt,Je,Te,tt,Yt,$t,Rt,Ht,wn,Dn,Gn,ha,ma,Ii,Oi,qi,Ri,Li,Pi,ji,Vi,Hi,Wi,Gi]}var zh=class extends de{constructor(e){super();he(this,e,jb,Pb,le,{fullView:1,dayView:0,yearView:2,calendar:3,moons:15,displayDayNumber:4,displayWeeks:5},Ob,[-1,-1,-1])}},Yh=zh;var Xt="FANTASY_CALENDAR",fa="FANTASY_CALENDAR_FULL_VIEW";(0,qe.addIcon)(Xt,' ');(0,qe.addIcon)("fantasy-calendar-reveal",' ');var Hn=class extends qe.ItemView{constructor(e,n,a={}){super(n);this.plugin=e;this.leaf=n;this.options=a;this.updateMe=!0;this.yearView=!1;this.moons=!0;this.containerEl.addClass("fantasy-calendar-view"),this.contentEl.addClass("fantasy-calendar-view-content"),this.registerEvent(this.plugin.app.workspace.on("fantasy-calendars-updated",()=>{this.plugin.onSettingsLoad(()=>this.updateCalendars())})),this.registerEvent(this.plugin.app.workspace.on("layout-change",()=>{!this._app||this._app.$set({fullView:this.full,...this.full?{dayView:!1}:{}})}))}get root(){return this.leaf.getRoot()}get full(){return!("collapse"in this.root)}updateCalendars(){if(!this.updateMe){this.updateMe=!0;return}if(!this.plugin.data.calendars.length){this._app?.$destroy(),this.contentEl.empty(),this.noCalendarEl=this.contentEl.createDiv("fantasy-no-calendar"),this.noCalendarEl.createSpan({text:"No calendars created! Create a calendar to see it here."});return}let e=this.plugin.data.calendars.find(n=>n.id==this.calendar?.id)??this.plugin.defaultCalendar??this.plugin.data.calendars[0];this.helper&&this.helper.calendar.id==e.id?this.update(e):this.setCurrentCalendar(e)}update(e){this.calendar=e,this.helper.update(this.calendar),this.registerCalendarInterval(),this._app?this._app.$set({calendar:this.helper}):this.build()}async registerCalendarInterval(){if(this.interval&&(clearInterval(this.interval),this.interval=null),this.calendar.static.incrementDay){let e=new Date;this.calendar.date||(this.calendar.date=e.valueOf());let n=Eo(new Date(this.calendar.date),e);if(n>=1){for(let a=0;a{Eo(new Date,e)>=1&&(this.helper.goToNextCurrentDay(),this.helper.current,e=new Date,this.calendar.date=e.valueOf(),await this.saveCalendars())},60*1e3),this.registerInterval(this.interval)}}async saveCalendars(){this.updateMe=!1,await this.plugin.saveCalendar()}setCurrentCalendar(e){this.noCalendarEl?.detach(),this.calendar=e,this.moons=this.calendar.static.displayMoons,this.dayNumber=this.calendar.static.displayDayNumber,this.helper=new Wa(this.calendar,this.plugin),this.registerCalendarInterval(),this.build()}createEventForDay(e){let n=new Pa(this.plugin,this.calendar,null,e);n.onClose=async()=>{!n.saved||(this.calendar.events.push(n.event),this.helper.addEvent(n.event),await this.saveCalendars(),this._app.$set({calendar:this.helper}),this.triggerHelperEvent("day-update"))},n.open()}async onOpen(){this.plugin.onSettingsLoad(()=>this.updateCalendars())}build(){this.contentEl.empty(),this._app=new Yh({target:this.contentEl,props:{calendar:this.helper,fullView:this.full,yearView:this.yearView,moons:this.moons,displayWeeks:this.helper.displayWeeks,displayDayNumber:this.dayNumber}}),this._app.$on("day-click",e=>{let n=e.detail;n.events.length||this.createEventForDay(n.date)}),this._app.$on("day-doubleclick",e=>{let n=e.detail;!n.events.length||(this.helper.viewing.day=n.number,this.helper.viewing.month=n.month.number,this.helper.viewing.year=n.month.year,this.yearView=!1,this._app.$set({yearView:!1}),this._app.$set({dayView:!0}),this.triggerHelperEvent("day-update",!1))}),this._app.$on("day-context-menu",e=>{let{day:n,evt:a}=e.detail,r=new qe.Menu(this.app);r.setNoIcon(),this.full||r.addItem(i=>{i.setTitle("Open Day").onClick(()=>{this.openDay({day:n.number,month:this.helper.displayed.month,year:this.helper.displayed.year})})}),r.addItem(i=>{i.setTitle("Set as Today").onClick(async()=>{this.calendar.current=n.date,this.helper.current.day=n.number,this.triggerHelperEvent("day-update"),await this.saveCalendars()})}),r.addItem(i=>i.setTitle("New Event").onClick(()=>{this.createEventForDay(n.date)})),r.showAtMouseEvent(a)}),this._app.$on("settings",e=>{let n=e.detail,a=new qe.Menu(this.app);a.setNoIcon(),a.addItem(r=>{r.setTitle(`${this.calendar.displayWeeks?"Hide":"Show"} Weeks`).onClick(async()=>{this.calendar.displayWeeks=!this.calendar.displayWeeks,this.helper.update(this.calendar),this._app.$set({displayWeeks:this.calendar.displayWeeks}),await this.saveCalendars()})}),a.addItem(r=>{r.setTitle(`Open ${this.yearView?"Month":"Year"}`).onClick(()=>{this.yearView=!this.yearView,this._app.$set({yearView:this.yearView})})}),a.addItem(r=>{r.setTitle(this.moons?"Hide Moons":"Display Moons").onClick(()=>{this.toggleMoons()})}),a.addItem(r=>{r.setTitle(this.dayNumber?"Hide Day Number":"Display Day Number").onClick(async()=>{this.dayNumber=!this.dayNumber,this.calendar.static.displayDayNumber=this.dayNumber,this._app.$set({displayDayNumber:this.dayNumber}),await this.saveCalendars()})}),a.addItem(r=>{r.setTitle("View Day"),r.onClick(()=>{this.openDate()})}),a.addItem(r=>{r.setTitle("Switch Calendars"),r.setDisabled(this.plugin.data.calendars.length<=1),r.onClick(()=>{let i=new $h(this.plugin,this.calendar);i.onClose=()=>{!i.confirmed||this.setCurrentCalendar(i.calendar)},i.open()})}),a.showAtMouseEvent(n)}),this._app.$on("event-click",e=>{let{event:n,modifier:a}=e.detail;if(n.note){let r=[];this.app.workspace.iterateAllLeaves(i=>{i.view instanceof qe.MarkdownView&&i.view.file.basename===n.note&&r.push(i)}),r.length?this.app.workspace.setActiveLeaf(r[0]):this.app.workspace.openLinkText(n.note,"",this.full||a)}else new Kh(n,this.plugin).open()}),this._app.$on("event-mouseover",e=>{if(!this.plugin.data.eventPreview)return;let{target:n,event:a}=e.detail;a.note&&this.app.workspace.trigger("link-hover",this,n,a.note,"")}),this._app.$on("event-context",e=>{let{evt:n,event:a}=e.detail,r=new qe.Menu(this.app);r.setNoIcon(),a.note||r.addItem(i=>{i.setTitle("Create Note").onClick(async()=>{let o=this.app.workspace.getActiveFile()?.path,l=o?this.app.fileManager.getNewFileParent(o)?.parent??"/":"/",s=`${a.date.year}-${a.date.month+1}-${a.date.day}`,c;a.end&&(c=`${a.end.year}-${a.end.month+1}-${a.end.day}`);let u={"fc-calendar":this.calendar.name,"fc-date":s,...a.end?{"fc-end":c}:{},...a.category?{"fc-category":this.calendar.categories.find(m=>m.id==a.category)?.name}:{},"fc-display-name":a.name};a.note=(0,qe.normalizePath)(`${l}/${a.name}.md`);let d=this.app.vault.getAbstractFileByPath(a.note);if(d||(d=await this.app.vault.create(a.note,`---
${(0,qe.stringifyYaml)(u)}
---`)),await this.saveCalendars(),d instanceof qe.TFile){let v=this.app.workspace.getLeavesOfType("markdown").find(h=>{h.view instanceof qe.FileView&&h.view.file.path==a.note});v?this.app.workspace.setActiveLeaf(v):await this.app.workspace.getUnpinnedLeaf().openFile(d,{active:!0})}})}),r.addItem(i=>{i.setTitle("Edit Event").onClick(()=>{let o=new Pa(this.plugin,this.calendar,a);o.onClose=async()=>{if(!o.saved)return;let l=this.calendar.events.find(s=>s.id==a.id);this.calendar.events.splice(this.calendar.events.indexOf(l),1,o.event),this.helper.refreshMonth(o.event.date.month,o.event.date.year),(o.event.date.month!=l.date.month||o.event.date.year!=l.date.year)&&this.helper.refreshMonth(l.date.month,l.date.year),await this.saveCalendars(),this._app.$set({calendar:this.helper}),this.triggerHelperEvent("day-update")},o.open()})}),r.addItem(i=>{i.setTitle("Delete Event").onClick(async()=>{if(!this.plugin.data.exit.event&&!await Bd(this.plugin))return;let o=this.calendar.events.find(l=>l.id==a.id);this.calendar.events.splice(this.calendar.events.indexOf(o),1),this.helper.refreshMonth(o.date.month,o.date.year),await this.saveCalendars(),this._app.$set({calendar:this.helper}),this.triggerHelperEvent("day-update")})}),r.showAtMouseEvent(n)}),this._app.$on("event",e=>{let n=e.detail;this.createEventForDay(n)}),this._app.$on("reset",()=>{this.helper.reset(),this.yearView=!1,this._app.$set({yearView:!1}),this._app.$set({dayView:!0}),this.triggerHelperEvent("day-update",!1)})}openDay(e){this.helper.viewing.day=e.day,this.helper.viewing.month=e.month,this.helper.viewing.year=e.year,this.yearView=!1,this._app.$set({yearView:!1}),this._app.$set({dayView:!0}),this.triggerHelperEvent("day-update",!1)}openDate(){if(!this.helper||!this.calendar)return;let e=new Zh(this.plugin,this.calendar);e.onClose=async()=>{!e.confirmed||(e.setCurrent?(this.calendar.current={...e.date},this.setCurrentCalendar(this.calendar)):(this.helper.displayed={...e.date},this.helper.update(),this._app.$set({calendar:this.helper})),await this.saveCalendars())},e.open()}toggleMoons(){this.moons=!this.moons,this._app.$set({moons:this.moons})}async onClose(){}onResize(){this.triggerHelperEvent("view-resized",!1)}getViewType(){return Xt}getDisplayText(){return"Fantasy Calendar"}getIcon(){return Xt}triggerHelperEvent(e,n=!0){!this.helper||(this.helper.trigger(e),n&&(this.updateMe=!1,this.plugin.app.workspace.trigger("fantasy-calendars-updated")))}async onunload(){}},$h=class extends lt{constructor(e,n){super(e.app);this.plugin=e;this.calendar=n;this.confirmed=!1}async display(){this.contentEl.empty(),this.contentEl.createEl("h4",{text:"Switch Calendars"});let e=this.contentEl.createDiv("fantasy-calendar-dropdown");e.createEl("label",{text:"Choose a Calendar"}),new qe.DropdownComponent(e).onChange(r=>{this.calendar=this.plugin.data.calendars.find(i=>i.id==r)}).addOptions(Object.fromEntries(this.plugin.data.calendars.map(r=>[r.id,r.name]))).setValue(this.calendar?this.calendar.id:null);let a=this.contentEl.createDiv("fantasy-calendar-confirm-buttons");new qe.ButtonComponent(a).setButtonText("Switch").setCta().onClick(()=>{this.confirmed=!0,this.close()}),new qe.ButtonComponent(a).setButtonText("Cancel").onClick(()=>{this.close()})}onOpen(){this.display()}},Zh=class extends lt{constructor(e,n){super(e.app);this.plugin=e;this.calendar=n;this.confirmed=!1;this.setCurrent=!1;this.date={...this.calendar.current},this.tempCurrentDays=this.date.day}async display(){this.contentEl.empty(),this.contentEl.createEl("h4",{text:"View Day"}),this.dateFieldEl=this.contentEl.createDiv("fantasy-calendar-date-fields"),this.buildDateFields(),new qe.Setting(this.contentEl).setName("Set as Current Date").setDesc("Also set this date to today's date.").addToggle(n=>n.setValue(this.setCurrent).onChange(a=>{this.setCurrent=a}));let e=this.contentEl.createDiv("fantasy-calendar-confirm-buttons");new qe.ButtonComponent(e).setButtonText("Switch").setCta().onClick(()=>{this.confirmed=!0,this.date.day=this.tempCurrentDays,this.close()}),new qe.ButtonComponent(e).setButtonText("Cancel").onClick(()=>{this.close()})}buildDateFields(){this.dateFieldEl.empty(),this.tempCurrentDays!=null&&this.date.month!=null&&this.tempCurrentDays>this.calendar.static.months[this.date.month]?.length&&(this.tempCurrentDays=this.calendar.static.months[this.date.month]?.length);let e=this.dateFieldEl.createDiv("fantasy-calendar-date-field");e.createEl("label",{text:"Day"}),new qe.TextComponent(e).setPlaceholder("Day").setValue(`${this.tempCurrentDays}`).setDisabled(this.date.month==null).onChange(i=>{if(Number(i)<1||Number(i)>this.calendar.static.months[this.date.month]?.length){new qe.Notice(`The current day must be between 1 and ${this.calendar.static.months[this.date.month].length}`),this.tempCurrentDays=this.date.day,this.buildDateFields();return}this.tempCurrentDays=Number(i)}).inputEl.setAttr("type","number");let a=this.dateFieldEl.createDiv("fantasy-calendar-date-field");a.createEl("label",{text:"Month"}),new qe.DropdownComponent(a).addOptions(Object.fromEntries([["select","Select Month"],...this.calendar.static.months.map(i=>[i.name,i.name])])).setValue(this.date.month!=null?this.calendar.static.months[this.date.month].name:"select").onChange(i=>{i==="select"&&(this.date.month=null);let o=this.calendar.static.months.find(l=>l.name==i);this.date.month=this.calendar.static.months.indexOf(o),this.buildDateFields()});let r=this.dateFieldEl.createDiv("fantasy-calendar-date-field");if(r.createEl("label",{text:"Year"}),this.calendar.static.useCustomYears){let i=new qe.DropdownComponent(r);(this.calendar.static.years??[]).forEach(o=>{i.addOption(o.id,o.name)}),this.date.year>this.calendar.static.years?.length&&(this.date.year=this.calendar.static.years?this.calendar.static.years.length:null),i.setValue(this.calendar.static.years?.[this.date.year-1]?.id).onChange(o=>{this.date.year=this.calendar.static.years.findIndex(l=>l.id==o)+1})}else new qe.TextComponent(r).setPlaceholder("Year").setValue(`${this.date.year}`).onChange(o=>{this.date.year=Number(o)}).inputEl.setAttr("type","number")}onOpen(){this.display()}},Kh=class extends lt{constructor(e,n){super(n.app);this.event=e;this.plugin=n;this.containerEl.addClass("fantasy-calendar-view-event")}async display(){this.contentEl.empty(),this.contentEl.createEl("h4",{text:this.event.name}),await qe.MarkdownRenderer.renderMarkdown(this.event.description,this.contentEl,this.event.note,null)}async onOpen(){await this.display()}};var x9=Ee(require("fs")),Jt=Ee(require("obsidian"));function Bs(t){let e=new Blob([t],{type:"text/javascript"}),n=URL.createObjectURL(e),a=new Worker(n,{name:"Fantasy Calendar File Watcher"});return URL.revokeObjectURL(n),a}function Ns(){return Bs(`var te=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Re=te(Ae=>{Ae.entityMap={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"\\xC0",Aacute:"\\xC1",Acirc:"\\xC2",Atilde:"\\xC3",Auml:"\\xC4",Aring:"\\xC5",AElig:"\\xC6",Ccedil:"\\xC7",Egrave:"\\xC8",Eacute:"\\xC9",Ecirc:"\\xCA",Euml:"\\xCB",Igrave:"\\xCC",Iacute:"\\xCD",Icirc:"\\xCE",Iuml:"\\xCF",ETH:"\\xD0",Ntilde:"\\xD1",Ograve:"\\xD2",Oacute:"\\xD3",Ocirc:"\\xD4",Otilde:"\\xD5",Ouml:"\\xD6",Oslash:"\\xD8",Ugrave:"\\xD9",Uacute:"\\xDA",Ucirc:"\\xDB",Uuml:"\\xDC",Yacute:"\\xDD",THORN:"\\xDE",szlig:"\\xDF",agrave:"\\xE0",aacute:"\\xE1",acirc:"\\xE2",atilde:"\\xE3",auml:"\\xE4",aring:"\\xE5",aelig:"\\xE6",ccedil:"\\xE7",egrave:"\\xE8",eacute:"\\xE9",ecirc:"\\xEA",euml:"\\xEB",igrave:"\\xEC",iacute:"\\xED",icirc:"\\xEE",iuml:"\\xEF",eth:"\\xF0",ntilde:"\\xF1",ograve:"\\xF2",oacute:"\\xF3",ocirc:"\\xF4",otilde:"\\xF5",ouml:"\\xF6",oslash:"\\xF8",ugrave:"\\xF9",uacute:"\\xFA",ucirc:"\\xFB",uuml:"\\xFC",yacute:"\\xFD",thorn:"\\xFE",yuml:"\\xFF",nbsp:"\\xA0",iexcl:"\\xA1",cent:"\\xA2",pound:"\\xA3",curren:"\\xA4",yen:"\\xA5",brvbar:"\\xA6",sect:"\\xA7",uml:"\\xA8",copy:"\\xA9",ordf:"\\xAA",laquo:"\\xAB",not:"\\xAC",shy:"\\xAD\\xAD",reg:"\\xAE",macr:"\\xAF",deg:"\\xB0",plusmn:"\\xB1",sup2:"\\xB2",sup3:"\\xB3",acute:"\\xB4",micro:"\\xB5",para:"\\xB6",middot:"\\xB7",cedil:"\\xB8",sup1:"\\xB9",ordm:"\\xBA",raquo:"\\xBB",frac14:"\\xBC",frac12:"\\xBD",frac34:"\\xBE",iquest:"\\xBF",times:"\\xD7",divide:"\\xF7",forall:"\\u2200",part:"\\u2202",exist:"\\u2203",empty:"\\u2205",nabla:"\\u2207",isin:"\\u2208",notin:"\\u2209",ni:"\\u220B",prod:"\\u220F",sum:"\\u2211",minus:"\\u2212",lowast:"\\u2217",radic:"\\u221A",prop:"\\u221D",infin:"\\u221E",ang:"\\u2220",and:"\\u2227",or:"\\u2228",cap:"\\u2229",cup:"\\u222A",int:"\\u222B",there4:"\\u2234",sim:"\\u223C",cong:"\\u2245",asymp:"\\u2248",ne:"\\u2260",equiv:"\\u2261",le:"\\u2264",ge:"\\u2265",sub:"\\u2282",sup:"\\u2283",nsub:"\\u2284",sube:"\\u2286",supe:"\\u2287",oplus:"\\u2295",otimes:"\\u2297",perp:"\\u22A5",sdot:"\\u22C5",Alpha:"\\u0391",Beta:"\\u0392",Gamma:"\\u0393",Delta:"\\u0394",Epsilon:"\\u0395",Zeta:"\\u0396",Eta:"\\u0397",Theta:"\\u0398",Iota:"\\u0399",Kappa:"\\u039A",Lambda:"\\u039B",Mu:"\\u039C",Nu:"\\u039D",Xi:"\\u039E",Omicron:"\\u039F",Pi:"\\u03A0",Rho:"\\u03A1",Sigma:"\\u03A3",Tau:"\\u03A4",Upsilon:"\\u03A5",Phi:"\\u03A6",Chi:"\\u03A7",Psi:"\\u03A8",Omega:"\\u03A9",alpha:"\\u03B1",beta:"\\u03B2",gamma:"\\u03B3",delta:"\\u03B4",epsilon:"\\u03B5",zeta:"\\u03B6",eta:"\\u03B7",theta:"\\u03B8",iota:"\\u03B9",kappa:"\\u03BA",lambda:"\\u03BB",mu:"\\u03BC",nu:"\\u03BD",xi:"\\u03BE",omicron:"\\u03BF",pi:"\\u03C0",rho:"\\u03C1",sigmaf:"\\u03C2",sigma:"\\u03C3",tau:"\\u03C4",upsilon:"\\u03C5",phi:"\\u03C6",chi:"\\u03C7",psi:"\\u03C8",omega:"\\u03C9",thetasym:"\\u03D1",upsih:"\\u03D2",piv:"\\u03D6",OElig:"\\u0152",oelig:"\\u0153",Scaron:"\\u0160",scaron:"\\u0161",Yuml:"\\u0178",fnof:"\\u0192",circ:"\\u02C6",tilde:"\\u02DC",ensp:"\\u2002",emsp:"\\u2003",thinsp:"\\u2009",zwnj:"\\u200C",zwj:"\\u200D",lrm:"\\u200E",rlm:"\\u200F",ndash:"\\u2013",mdash:"\\u2014",lsquo:"\\u2018",rsquo:"\\u2019",sbquo:"\\u201A",ldquo:"\\u201C",rdquo:"\\u201D",bdquo:"\\u201E",dagger:"\\u2020",Dagger:"\\u2021",bull:"\\u2022",hellip:"\\u2026",permil:"\\u2030",prime:"\\u2032",Prime:"\\u2033",lsaquo:"\\u2039",rsaquo:"\\u203A",oline:"\\u203E",euro:"\\u20AC",trade:"\\u2122",larr:"\\u2190",uarr:"\\u2191",rarr:"\\u2192",darr:"\\u2193",harr:"\\u2194",crarr:"\\u21B5",lceil:"\\u2308",rceil:"\\u2309",lfloor:"\\u230A",rfloor:"\\u230B",loz:"\\u25CA",spades:"\\u2660",clubs:"\\u2663",hearts:"\\u2665",diams:"\\u2666"}});var Pe=te(me=>{var pe=/[A-Z_a-z\\xC0-\\xD6\\xD8-\\xF6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/,Oe=new RegExp("[\\\\-\\\\.0-9"+pe.source.slice(1,-1)+"\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040]"),Se=new RegExp("^"+pe.source+Oe.source+"*(?::"+pe.source+Oe.source+"*)?$"),j=0,S=1,F=2,G=3,U=4,L=5,Q=6,ne=7;function P(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,P)}P.prototype=new Error;P.prototype.name=P.name;function Me(){}Me.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),Ue(t,t={}),vt(e,t,n,r,this.errorHandler),r.endDocument()}};function vt(e,t,n,r,i){function s(E){if(E>65535){E-=65536;var x=55296+(E>>10),dt=56320+(E&1023);return String.fromCharCode(x,dt)}else return String.fromCharCode(E)}function a(E){var x=E.slice(1,-1);return x in n?n[x]:x.charAt(0)==="#"?s(parseInt(x.substr(1).replace("x","0x"))):(i.error("entity not found:"+E),E)}function o(E){if(E>g){var x=e.substring(g,E).replace(/?\\w+;/g,a);p&&c(g),r.characters(x,0,E-g),g=E}}function c(E,x){for(;E>=u&&(x=m.exec(e));)l=x.index,u=l+x[0].length,p.lineNumber++;p.columnNumber=E-l+1}for(var l=0,u=0,m=/.*(?:\\r\\n?|\\n)|.*$/g,p=r.locator,v=[{currentNSMap:t}],_={},g=0;;){try{var d=e.indexOf("<",g);if(d<0){if(!e.substr(g).match(/^\\s*$/)){var O=r.doc,z=O.createTextNode(e.substr(g));O.appendChild(z),r.currentElement=z}return}switch(d>g&&o(d),e.charAt(d+1)){case"/":var h=e.indexOf(">",d+3),f=e.substring(d+2,h),b=v.pop();h<0?(f=e.substring(d+2).replace(/[\\s<].*/,""),i.error("end tag name: "+f+" is not complete:"+b.tagName),h=d+1+f.length):f.match(/\\s)&&(f=f.replace(/[\\s<].*/,""),i.error("end tag name: "+f+" maybe not complete"),h=d+1+f.length);var _e=b.localNSMap,Ce=b.tagName==f,pt=Ce||b.tagName&&b.tagName.toLowerCase()==f.toLowerCase();if(pt){if(r.endElement(b.uri,b.localName,f),_e)for(var mt in _e)r.endPrefixMapping(mt);Ce||i.fatalError("end tag name: "+f+" is not match the current start tagName:"+b.tagName)}else v.push(b);h++;break;case"?":p&&c(d),h=Dt(e,d,r);break;case"!":p&&c(d),h=yt(e,d,r,i);break;default:p&&c(d);var C=new Le,ue=v[v.length-1].currentNSMap,h=gt(e,d,C,ue,a,i),xe=C.length;if(!C.closed&&Nt(e,h,C.tagName,_)&&(C.closed=!0,n.nbsp||i.warning("unclosed xml attribute")),p&&xe){for(var ht=$e(p,{}),le=0;leg?g=h:o(Math.max(d,g)+1)}}function $e(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function gt(e,t,n,r,i,s){function a(v,_,g){v in n.attributeNames&&s.fatalError("Attribute "+v+" redefined"),n.addValue(v,_,g)}for(var o,c,l=++t,u=j;;){var m=e.charAt(l);switch(m){case"=":if(u===S)o=e.slice(t,l),u=G;else if(u===F)u=G;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(u===G||u===S)if(u===S&&(s.warning('attribute value must after "="'),o=e.slice(t,l)),t=l+1,l=e.indexOf(m,t),l>0)c=e.slice(t,l).replace(/?\\w+;/g,i),a(o,c,t-1),u=L;else throw new Error("attribute value no end '"+m+"' match");else if(u==U)c=e.slice(t,l).replace(/?\\w+;/g,i),a(o,c,t),s.warning('attribute "'+o+'" missed start quot('+m+")!!"),t=l+1,u=L;else throw new Error('attribute value must after "="');break;case"/":switch(u){case j:n.setTagName(e.slice(t,l));case L:case Q:case ne:u=ne,n.closed=!0;case U:case S:case F:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),u==j&&n.setTagName(e.slice(t,l)),l;case">":switch(u){case j:n.setTagName(e.slice(t,l));case L:case Q:case ne:break;case U:case S:c=e.slice(t,l),c.slice(-1)==="/"&&(n.closed=!0,c=c.slice(0,-1));case F:u===F&&(c=o),u==U?(s.warning('attribute "'+c+'" missed quot(")!'),a(o,c.replace(/?\\w+;/g,i),t)):((r[""]!=="http://www.w3.org/1999/xhtml"||!c.match(/^(?:disabled|checked|selected)$/i))&&s.warning('attribute "'+c+'" missed value!! "'+c+'" instead!!'),a(c,c,t));break;case G:throw new Error("attribute value missed!!")}return l;case"\\x80":m=" ";default:if(m<=" ")switch(u){case j:n.setTagName(e.slice(t,l)),u=Q;break;case S:o=e.slice(t,l),u=F;break;case U:var c=e.slice(t,l).replace(/?\\w+;/g,i);s.warning('attribute "'+c+'" missed quot(")!!'),a(o,c,t);case L:u=Q;break}else switch(u){case F:var p=n.tagName;(r[""]!=="http://www.w3.org/1999/xhtml"||!o.match(/^(?:disabled|checked|selected)$/i))&&s.warning('attribute "'+o+'" missed value!! "'+o+'" instead2!!'),a(o,o,t),t=l,u=S;break;case L:s.warning('attribute space is required"'+o+'"!!');case Q:u=S,t=l;break;case G:u=U,t=l;break;case ne:throw new Error("elements closed character '/' and '>' must be connected to")}}l++}}function Fe(e,t,n){for(var r=e.tagName,i=null,s=e.length;s--;){var a=e[s],o=a.qName,c=a.value,p=o.indexOf(":");if(p>0)var l=a.prefix=o.slice(0,p),u=o.slice(p+1),m=l==="xmlns"&&u;else u=o,l=null,m=o==="xmlns"&&"";a.localName=u,m!==!1&&(i==null&&(i={},Ue(n,n={})),n[m]=i[m]=c,a.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(m,c))}for(var s=e.length;s--;){a=e[s];var l=a.prefix;l&&(l==="xml"&&(a.uri="http://www.w3.org/XML/1998/namespace"),l!=="xmlns"&&(a.uri=n[l||""]))}var p=r.indexOf(":");p>0?(l=e.prefix=r.slice(0,p),u=e.localName=r.slice(p+1)):(l=null,u=e.localName=r);var v=e.uri=n[l||""];if(t.startElement(v,u,r,e),e.closed){if(t.endElement(v,u,r),i)for(l in i)t.endPrefixMapping(l)}else return e.currentNSMap=n,e.localNSMap=i,!0}function Et(e,t,n,r,i){if(/^(?:script|textarea)$/i.test(n)){var s=e.indexOf(""+n+">",t),a=e.substring(t+1,s);if(/[&<]/.test(a))return/^script$/i.test(n)?(i.characters(a,0,a.length),s):(a=a.replace(/?\\w+;/g,r),i.characters(a,0,a.length),s)}return t+1}function Nt(e,t,n,r){var i=r[n];return i==null&&(i=e.lastIndexOf(""+n+">"),i",t+4);return s>t?(n.comment(e,t+4,s-t-4),s+3):(r.error("Unclosed comment"),-1)}else return-1;default:if(e.substr(t+3,6)=="CDATA["){var s=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,s-t-9),n.endCDATA(),s+3}var a=bt(e,t),o=a.length;if(o>1&&/!doctype/i.test(a[0][0])){var c=a[1][0],l=!1,u=!1;o>3&&(/^public$/i.test(a[2][0])?(l=a[3][0],u=o>4&&a[4][0]):/^system$/i.test(a[2][0])&&(u=a[3][0]));var m=a[o-1];return n.startDTD(c,l,u),n.endDTD(),m.index+m[0].length}}return-1}function Dt(e,t,n){var r=e.indexOf("?>",t);if(r){var i=e.substring(t,r).match(/^<\\?(\\S*)\\s*([\\s\\S]*?)\\s*$/);if(i){var s=i[0].length;return n.processingInstruction(i[1],i[2]),r+2}else return-1}return-1}function Le(){this.attributeNames={}}Le.prototype={setTagName:function(e){if(!Se.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,n){if(!Se.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}};function bt(e,t){var n,r=[],i=/'[^']+'|"[^"]+"|[^\\s<>\\/=]+=?|(\\/?\\s*>|<)/g;for(i.lastIndex=t,i.exec(e);n=i.exec(e);)if(r.push(n),n[1])return r}me.XMLReader=Me;me.ParseError=P});var we=te(J=>{function W(e,t){for(var n in e)t[n]=e[n]}function w(e,t){var n=e.prototype;if(!(n instanceof t)){let i=function(){};var r=i;i.prototype=t.prototype,i=new i,W(n,i),e.prototype=n=i}n.constructor!=e&&(typeof e!="function"&&console.error("unknow Class:"+e),n.constructor=e)}var wt="http://www.w3.org/1999/xhtml",T={},I=T.ELEMENT_NODE=1,k=T.ATTRIBUTE_NODE=2,re=T.TEXT_NODE=3,ke=T.CDATA_SECTION_NODE=4,Ve=T.ENTITY_REFERENCE_NODE=5,Tt=T.ENTITY_NODE=6,qe=T.PROCESSING_INSTRUCTION_NODE=7,Ye=T.COMMENT_NODE=8,Xe=T.DOCUMENT_NODE=9,ze=T.DOCUMENT_TYPE_NODE=10,R=T.DOCUMENT_FRAGMENT_NODE=11,_t=T.NOTATION_NODE=12,y={},N={},qt=y.INDEX_SIZE_ERR=(N[1]="Index size error",1),Yt=y.DOMSTRING_SIZE_ERR=(N[2]="DOMString size error",2),Ct=y.HIERARCHY_REQUEST_ERR=(N[3]="Hierarchy request error",3),Xt=y.WRONG_DOCUMENT_ERR=(N[4]="Wrong document",4),zt=y.INVALID_CHARACTER_ERR=(N[5]="Invalid character",5),jt=y.NO_DATA_ALLOWED_ERR=(N[6]="No data allowed",6),Gt=y.NO_MODIFICATION_ALLOWED_ERR=(N[7]="No modification allowed",7),xt=y.NOT_FOUND_ERR=(N[8]="Not found",8),Qt=y.NOT_SUPPORTED_ERR=(N[9]="Not supported",9),je=y.INUSE_ATTRIBUTE_ERR=(N[10]="Attribute in use",10),Wt=y.INVALID_STATE_ERR=(N[11]="Invalid state",11),Bt=y.SYNTAX_ERR=(N[12]="Syntax error",12),Zt=y.INVALID_MODIFICATION_ERR=(N[13]="Invalid modification",13),Kt=y.NAMESPACE_ERR=(N[14]="Invalid namespace",14),Jt=y.INVALID_ACCESS_ERR=(N[15]="Invalid access",15);function $(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,N[e]),this.message=N[e],Error.captureStackTrace&&Error.captureStackTrace(this,$);return n.code=e,t&&(this.message=this.message+": "+t),n}$.prototype=Error.prototype;W(y,$);function M(){}M.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r=0){for(var i=t.length-1;r0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n){for(var r in n)if(n[r]==e)return r}t=t.nodeType==k?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==k?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){var t=this.lookupPrefix(e);return t==null}};function Ze(e){return e=="<"&&"<"||e==">"&&">"||e=="&"&&"&"||e=='"'&&"""||""+e.charCodeAt()+";"}W(T,D);W(T,D.prototype);function B(e,t){if(t(e))return!0;if(e=e.firstChild)do if(B(e,t))return!0;while(e=e.nextSibling)}function Z(){}function It(e,t,n){e&&e._inc++;var r=n.namespaceURI;r=="http://www.w3.org/2000/xmlns/"&&(t._nsMap[n.prefix?n.localName:""]=n.value)}function Ke(e,t,n,r){e&&e._inc++;var i=n.namespaceURI;i=="http://www.w3.org/2000/xmlns/"&&delete t._nsMap[n.prefix?n.localName:""]}function de(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var i=t.firstChild,s=0;i;)r[s++]=i,i=i.nextSibling;r.length=s}}}function Je(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,de(e.ownerDocument,e),t}function He(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===R){var i=t.firstChild;if(i==null)return t;var s=t.lastChild}else i=s=t;var a=n?n.previousSibling:e.lastChild;i.previousSibling=a,s.nextSibling=n,a?a.nextSibling=i:e.firstChild=i,n==null?e.lastChild=s:n.previousSibling=s;do i.parentNode=e;while(i!==s&&(i=i.nextSibling));return de(e.ownerDocument||e,e),t.nodeType==R&&(t.firstChild=t.lastChild=null),t}function At(e,t){var n=t.parentNode;if(n){var r=e.lastChild;n.removeChild(t);var r=e.lastChild}var r=e.lastChild;return t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,de(e.ownerDocument,e,t),t}Z.prototype={nodeName:"#document",nodeType:Xe,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==R){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return this.documentElement==null&&e.nodeType==I&&(this.documentElement=e),He(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),Je(this,e)},importNode:function(e,t){return at(this,e,t)},getElementById:function(e){var t=null;return B(this.documentElement,function(n){if(n.nodeType==I&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\\\s)"+e+"(\\\\s|$)");return new V(this,function(n){var r=[];return B(n.documentElement,function(i){i!==n&&i.nodeType==I&&t.test(i.getAttribute("class"))&&r.push(i)}),r})},createElement:function(e){var t=new q;t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new M;var n=t.attributes=new ie;return n._ownerElement=t,t},createDocumentFragment:function(){var e=new se;return e.ownerDocument=this,e.childNodes=new M,e},createTextNode:function(e){var t=new ve;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new ge;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new Ee;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new De;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new ae;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new ye;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new q,r=t.split(":"),i=n.attributes=new ie;return n.childNodes=new M,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,r.length==2?(n.prefix=r[0],n.localName=r[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new ae,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,r.length==2?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}};w(Z,D);function q(){this._nsMap={}}q.prototype={nodeType:I,hasAttribute:function(e){return this.getAttributeNode(e)!=null},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===R?this.insertBefore(e,null):At(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return this.getAttributeNodeNS(e,t)!=null},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new V(this,function(t){var n=[];return B(t,function(r){r!==t&&r.nodeType==I&&(e==="*"||r.tagName==e)&&n.push(r)}),n})},getElementsByTagNameNS:function(e,t){return new V(this,function(n){var r=[];return B(n,function(i){i!==n&&i.nodeType===I&&(e==="*"||i.namespaceURI===e)&&(t==="*"||i.localName==t)&&r.push(i)}),r})}};Z.prototype.getElementsByTagName=q.prototype.getElementsByTagName;Z.prototype.getElementsByTagNameNS=q.prototype.getElementsByTagNameNS;w(q,D);function ae(){}ae.prototype.nodeType=k;w(ae,D);function K(){}K.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(N[Ct])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){var r=this.data.substring(0,e),i=this.data.substring(e+t);n=r+n+i,this.nodeValue=this.data=n,this.length=n.length}};w(K,D);function ve(){}ve.prototype={nodeName:"#text",nodeType:re,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}};w(ve,K);function ge(){}ge.prototype={nodeName:"#comment",nodeType:Ye};w(ge,K);function Ee(){}Ee.prototype={nodeName:"#cdata-section",nodeType:ke};w(Ee,K);function Ne(){}Ne.prototype.nodeType=ze;w(Ne,D);function et(){}et.prototype.nodeType=_t;w(et,D);function tt(){}tt.prototype.nodeType=Tt;w(tt,D);function ye(){}ye.prototype.nodeType=Ve;w(ye,D);function se(){}se.prototype.nodeName="#document-fragment";se.prototype.nodeType=R;w(se,D);function De(){}De.prototype.nodeType=qe;w(De,D);function nt(){}nt.prototype.serializeToString=function(e,t,n){return rt.call(e,t,n)};D.prototype.toString=rt;function rt(e,t){var n=[],r=this.nodeType==9&&this.documentElement||this,i=r.prefix,s=r.namespaceURI;if(s&&i==null){var i=r.lookupPrefix(s);if(i==null)var a=[{namespace:s,prefix:null}]}return Y(this,n,e,t,a),n.join("")}function it(e,t,n){var r=e.prefix||"",i=e.namespaceURI;if(!r&&!i||r==="xml"&&i==="http://www.w3.org/XML/1998/namespace"||i=="http://www.w3.org/2000/xmlns/")return!1;for(var s=n.length;s--;){var a=n[s];if(a.prefix==r)return a.namespace!=i}return!0}function Y(e,t,n,r,i){if(r)if(e=r(e),e){if(typeof e=="string"){t.push(e);return}}else return;switch(e.nodeType){case I:i||(i=[]);var s=i.length,a=e.attributes,o=a.length,c=e.firstChild,l=e.tagName;n=wt===e.namespaceURI||n,t.push("<",l);for(var u=0;u"),n&&/^script$/i.test(l))for(;c;)c.data?t.push(c.data):Y(c,t,n,r,i),c=c.nextSibling;else for(;c;)Y(c,t,n,r,i),c=c.nextSibling;t.push("",l,">")}else t.push("/>");return;case Xe:case R:for(var c=e.firstChild;c;)Y(c,t,n,r,i),c=c.nextSibling;return;case k:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,Ze),'"');case re:return t.push(e.data.replace(/[<&]/g,Ze).replace(/]]>/g,"]]>"));case ke:return t.push("");case Ye:return t.push("");case ze:var g=e.publicId,d=e.systemId;if(t.push("");else if(d&&d!=".")t.push(" SYSTEM ",d,">");else{var O=e.internalSubset;O&&t.push(" [",O,"]"),t.push(">")}return;case qe:return t.push("",e.target," ",e.data,"?>");case Ve:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function at(e,t,n){var r;switch(t.nodeType){case I:r=t.cloneNode(!1),r.ownerDocument=e;case R:break;case k:n=!0;break}if(r||(r=t.cloneNode(!1)),r.ownerDocument=e,r.parentNode=null,n)for(var i=t.firstChild;i;)r.appendChild(at(e,i,n)),i=i.nextSibling;return r}function be(e,t,n){var r=new t.constructor;for(var i in t){var s=t[i];typeof s!="object"&&s!=r[i]&&(r[i]=s)}switch(t.childNodes&&(r.childNodes=new M),r.ownerDocument=e,r.nodeType){case I:var a=t.attributes,o=r.attributes=new ie,c=a.length;o._ownerElement=r;for(var l=0;l{function ot(e){this.options=e||{locator:{}}}ot.prototype.parseFromString=function(e,t){var n=this.options,r=new St,i=n.domBuilder||new H,s=n.errorHandler,a=n.locator,o=n.xmlns||{},c=/\\/x?html?$/.test(t),l=c?Ot.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return a&&i.setDocumentLocator(a),r.errorHandler=Rt(s,i,a),r.domBuilder=n.domBuilder||i,c&&(o[""]="http://www.w3.org/1999/xhtml"),o.xml=o.xml||"http://www.w3.org/XML/1998/namespace",e&&typeof e=="string"?r.parse(e,o,l):r.errorHandler.error("invalid doc source"),i.doc};function Rt(e,t,n){if(!e){if(t instanceof H)return t;e=t}var r={},i=e instanceof Function;n=n||{};function s(a){var o=e[a];!o&&i&&(o=e.length==2?function(c){e(a,c)}:e),r[a]=o&&function(c){o("[xmldom "+a+"] "+c+Te(n))}||function(){}}return s("warning"),s("error"),s("fatalError"),r}function H(){this.cdata=!1}function X(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}H.prototype={startDocument:function(){this.doc=new $t().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var i=this.doc,s=i.createElementNS(e,n||t),a=r.length;oe(this,s),this.currentElement=s,this.locator&&X(this.locator,s);for(var o=0;o=t+n||t?new java.lang.String(e,t,n)+"":e}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\\w+/g,function(e){H.prototype[e]=function(){return null}});function oe(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}var Ot=Re(),lt=Pe(),St=lt.XMLReader,Mt=lt.ParseError,$t=ee.DOMImplementation=we().DOMImplementation;ee.XMLSerializer=we().XMLSerializer;ee.DOMParser=ot;ee.__DOMHandler=H});function ce(e,t){return(e%t+t)%t}function fe(e){return"ID_xyxyxyxyxyxy".replace(/[xy]/g,function(t){var n=Math.random()*16|0,r=t=="x"?n:n&3|8;return r.toString(16)})}var{DOMParser:Ft}=ct(),Ut=/(<(span|div).*?<\\/(span|div)>)/g,A=self,ft=class{constructor(){this.queue=[];this.parsing=!1;this.parseTitle=!1;A.addEventListener("message",t=>{if(t.data.type=="options"){let{defaultCalendar:n,addToDefaultIfMissing:r,format:i,parseTitle:s,debug:a}=t.data;this.addToDefaultIfMissing=r,this.defaultCalendar=n,this.format=i,this.parseTitle=s,this.debug=a,this.debug&&console.debug("Received options message")}}),A.addEventListener("message",t=>{if(t.data.type=="calendars"){let{calendars:n}=t.data;this.calendars=[...n],this.debug&&console.debug("Received calendars message")}}),A.addEventListener("message",t=>{t.data.type=="queue"&&(this.add(...t.data.paths),this.debug&&console.debug(\`Received queue message for \${t.data.paths.length} paths\`))})}add(...t){this.debug&&console.debug(\`Adding \${t.length} paths to queue\`),this.queue.push(...t),this.parsing||this.parse()}async parse(){for(this.parsing=!0;this.queue.length;){let t=this.queue.shift();this.debug&&console.debug(\`Parsing \${t} for calendar events (\${this.queue.length} to go)\`),await this.getFileData(t)}this.parsing=!1,this.debug&&console.info("Parsing complete"),A.postMessage({type:"save"})}async getFileData(t){let n=this;return new Promise(r=>{function i(s){if(s.data.type=="queue"){A.removeEventListener("message",i),r();return}if(s.data.type!="file"||s.data.path!=t)return;A.removeEventListener("message",i);let{data:a,cache:o,allTags:c,file:l}=s.data;n.parseFileForEvents(a,o,c,l),r()}setTimeout(()=>r(),500),A.addEventListener("message",i),A.postMessage({path:t,type:"get"})})}getDataFromFrontmatter(t){let n,r,i;return t&&"fc-ignore"in t?{}:(t&&(n=t==null?void 0:t["fc-calendar"],r=t==null?void 0:t["fc-category"],i=t==null?void 0:t["fc-display-name"]),this.addToDefaultIfMissing&&(!n||!n.length)&&(n=this.defaultCalendar),n=n==null?void 0:n.toLowerCase(),{calendar:this.calendars.find(a=>n==a.name.toLowerCase()),fcCategory:r,eventDisplayName:i})}removeEventsFromFile(t){for(let n of this.calendars)for(let r=0;rh.replace(/#/,"")).includes(o.timelineTag.replace(/#/,""))&&(u=this.parseTimelineEvents(o,t,i,c),s.push(...u));let m=this.parseFrontmatterEvents(o,c,a,i,l);if(s.push(...m),!s||!s.length){this.removeEventsFromFile(i.path);return}let p=0;for(let h of s){let f=o.events.find(b=>b.note==i.path&&(!h.timestamp||b.timestamp==h.timestamp));(f==null?void 0:f.date.day)==h.date.day&&(f==null?void 0:f.date.month)==h.date.month&&(f==null?void 0:f.date.year)==h.date.year&&((v=f==null?void 0:f.end)==null?void 0:v.day)==((_=h.end)==null?void 0:_.day)&&((g=f==null?void 0:f.end)==null?void 0:g.month)==((d=h.end)==null?void 0:d.month)&&((O=f==null?void 0:f.end)==null?void 0:O.year)==((z=h.end)==null?void 0:z.year)&&(f==null?void 0:f.category)==h.category&&(f==null?void 0:f.name)==h.name&&(!h.timestamp&&!(f==null?void 0:f.timestamp)||(f==null?void 0:f.timestamp)==h.timestamp)||(A.postMessage({type:"update",id:o.id,index:f?o.events.findIndex(b=>b.id==(f==null?void 0:f.id)):-1,event:h,original:f}),p++)}this.debug&&s.length>0&&console.info(\`\${p}/\${s.length} (\${m.length} from frontmatter, \${u.length} from timelines) event operations completed on \${o.name} for \${i.basename}\`)}parseFrontmatterEvents(t,n,r,i,s){let{date:a,end:o}=this.getDates(r,this.parseTitle?i.basename:"");if(!a)return[];if((a==null?void 0:a.month)&&typeof(a==null?void 0:a.month)=="string"){let u=t.static.months.find(m=>m.name==a.month);u?a.month=t.static.months.indexOf(u):a.month=null}else(a==null?void 0:a.month)&&typeof(a==null?void 0:a.month)=="number"&&(a.month=ce(a.month-1,t.static.months.length));if((o==null?void 0:o.month)&&typeof(o==null?void 0:o.month)=="string"){let u=t.static.months.find(m=>m.name==o.month);u?o.month=t.static.months.indexOf(u):o.month=null}else(o==null?void 0:o.month)&&typeof(o==null?void 0:o.month)=="number"&&(o.month=ce(o.month-1,t.static.months.length));let c=Number(\`\${a.year}\${a.month}\${a.day}00\`),l=t.categories.find(u=>(u==null?void 0:u.name)==n);return[{id:fe(6),name:s!=null?s:i.basename,note:i.path,date:a,end:o,category:l==null?void 0:l.id,description:"",auto:!0}]}parseTimelineEvents(t,n,r,i){var o;let s=[],a=new Ft;for(let c of n.matchAll(Ut)){let l=a.parseFromString(c[0],"text/html"),u={class:l.documentElement.getAttribute("class"),dataset:{date:l.documentElement.getAttribute("data-date"),title:l.documentElement.getAttribute("data-title"),class:l.documentElement.getAttribute("data-class"),end:l.documentElement.getAttribute("data-end")},content:l.documentElement.textContent};if(u.class!=="ob-timelines"||!u.dataset.date)continue;let m=Number(u.dataset.date[0]=="-"?+u.dataset.date.substring(1,u.dataset.date.length).split("-").join("")*-1:+u.dataset.date.split("-").join("")),p=u.dataset.date.split(/(?(d==null?void 0:d.name)==u.dataset.class);s.push({id:fe(6),name:(o=u.dataset.title)!=null?o:r.basename,note:r.path,date:v,end:_,timestamp:m,category:g==null?void 0:g.id,description:u.content,auto:!0})}return s}parseDate(t){var n;if(typeof t=="string"){if(!/\\d+[./-]\\d+[./-]\\d+/.test(t))return;try{let[r]=(n=t.match(/\\d+[./-]\\d+[./-]\\d+/))!=null?n:[];if(!r)return;let i=r.split(/[.\\-\\/]/).map(a=>Number(a)),s=[...new Set(this.format.replace(/[^\\w]/g,"").toUpperCase().split(""))];return{year:i[s.indexOf("Y")],month:i[s.indexOf("M")],day:i[s.indexOf("D")]}}catch(r){return}}else return t}getDates(t={},n){let r="fc-date"in t?"fc-date":"fc-start",i;t&&r in t&&(i=t[r]),i||(i=n);let s=this.parseDate(i),a="fc-end"in t?t["fc-end"]:null,o=this.parseDate(a);return{date:s,end:o}}};new ft;
`)}var Qh=class extends Jt.FuzzySuggestModal{constructor(e){super(e.app);this.plugin=e}getItems(){return this.plugin.data.calendars}getItemText(e){return e.name}onChooseItem(e,n){this.chosen=e,this.close()}},Ms=class extends Jt.Component{constructor(e){super();this.plugin=e;this.queue=new Set;this.tree=new Map;this.worker=new Ns}get calendars(){return this.plugin.data.calendars}get metadataCache(){return this.plugin.app.metadataCache}get vault(){return this.plugin.app.vault}onload(){this.plugin.addCommand({id:"rescan-events",name:"Rescan Events",callback:()=>{this.plugin.data.debug&&console.info("Beginning full rescan for calendar events"),this.start()}}),this.plugin.addCommand({id:"rescan-events-for-calendar",name:"Rescan Events for Calendar",callback:()=>{let e=new Qh(this.plugin);e.onClose=()=>{e.chosen&&(this.plugin.data.debug&&console.info("Beginning full rescan for calendar events for calendar "+e.chosen.name),this.start(e.chosen))},e.open()}}),this.worker.postMessage({type:"calendars",calendars:this.calendars}),this.registerEvent(this.plugin.app.workspace.on("fantasy-calendars-updated",()=>{this.worker.postMessage({type:"calendars",calendars:this.calendars})})),this.worker.postMessage({type:"options",parseTitle:this.plugin.data.parseDates,addToDefaultIfMissing:this.plugin.data.addToDefaultIfMissing,format:this.plugin.format,defaultCalendar:this.plugin.defaultCalendar?.name,debug:this.plugin.data.debug}),this.registerEvent(this.plugin.app.workspace.on("fantasy-calendar-settings-change",()=>{this.worker.postMessage({type:"options",parseTitle:this.plugin.data.parseDates,addToDefaultIfMissing:this.plugin.data.addToDefaultIfMissing,format:this.plugin.format,defaultCalendar:this.plugin.defaultCalendar?.name,debug:this.plugin.data.debug})})),this.registerEvent(this.metadataCache.on("changed",e=>{this.queue.has(e.path)||this.startParsing([e.path])})),this.registerEvent(this.vault.on("rename",async(e,n)=>{if(!!this.calendars.length&&e instanceof Jt.TFile){for(let a of this.calendars)a.events=a.events.filter(r=>r.note!=n);this.worker.postMessage({type:"calendars",calendars:this.calendars}),this.startParsing([e.path])}})),this.registerEvent(this.vault.on("delete",async e=>{if(e instanceof Jt.TFile){for(let n of this.calendars){let a=n.events.filter(r=>r.note===e.path);n.events=n.events.filter(r=>r.note!=e.path);for(let r of a)this.addToTree(n,r)}await this.plugin.saveCalendar(),this.plugin.app.workspace.trigger("fantasy-calendars-event-update",this.tree),this.tree=new Map}})),this.worker.addEventListener("message",async e=>{if(e.data.type=="get"){let{path:n}=e.data;this.queue.delete(n);let a=this.plugin.app.vault.getAbstractFileByPath(n);if(a instanceof Jt.TFile){let r=this.metadataCache.getFileCache(a),i=(0,Jt.getAllTags)(r),o=await this.vault.cachedRead(a);this.worker.postMessage({type:"file",path:n,cache:r,file:{path:a.path,basename:a.basename},allTags:i,data:o})}else if(a instanceof Jt.TFolder){let r=a.children.map(i=>i.path);this.startParsing(r)}}}),this.worker.addEventListener("message",async e=>{if(e.data.type=="update"){let{id:n,index:a,event:r,original:i}=e.data,o=this.calendars.find(l=>l.id==n);if(!o)return;a==-1?(this.plugin.data.debug&&console.debug(`Adding '${r.name}' to ${o.name}`),o.events.push(r)):(this.plugin.data.debug&&console.debug(`Updating '${r.name}' in calendar ${o.name}`),o.events.splice(a,a>=0?1:0,r)),this.addToTree(o,r),i&&this.addToTree(o,i)}}),this.worker.addEventListener("message",async e=>{if(e.data.type=="delete"){let{id:n,index:a,event:r}=e.data;if(!r)return;let i=this.calendars.find(o=>o.id==n);if(!i)return;this.plugin.data.debug&&console.debug(`Removing '${r.name}' from ${i.name}`),i.events=i.events.filter(o=>o.id!=r.id),this.addToTree(i,r)}}),this.worker.addEventListener("message",async e=>{e.data.type=="save"&&(this.plugin.data.debug&&console.debug("Received save event from file watcher"),this.plugin.app.workspace.trigger("fantasy-calendars-event-update",this.tree),this.tree=new Map,await this.plugin.saveCalendar())}),this.start()}start(e){let n=e?[e]:this.calendars;if(!n.length)return;let a=new Set;for(let r of n){if(!r||!r.autoParse)continue;let i=this.vault.getAbstractFileByPath(r.path);if(!(!i||!(i instanceof Jt.TFolder)))for(let o of i.children)a.add(o.path)}!a.size||(this.plugin.data.debug&&console.info(e?`Starting rescan for ${e.name} (${a.size})`:`Starting rescan for ${n.length} calendars (${a.size})`),this.startParsing([...a]))}addToTree(e,n){this.tree.has(e.id)||this.tree.set(e.id,new Set);let a=this.tree.get(e.id);if(!a.has(n.date.year)&&(a.add(n.date.year),n.end&&n.end.year!=n.date.year))for(let r=n.date.year+1;r<=n.end.year;r++)a.add(n.date.year)}startParsing(e){for(let n of e)this.queue.add(n);this.worker.postMessage({type:"queue",paths:e})}onunload(){this.worker.terminate(),this.worker=null}};var Is=Ee(require("obsidian"));var Os=class{constructor(e){this.plugin=e}getCalendars(){return this.plugin.data.calendars}getMoons(e,n){let a=n?this.plugin.data.calendars.find(({name:s})=>s==n):this.plugin.defaultCalendar??this.plugin.defaultCalendar,r=this.getHelper(a),i=e||r.current,o=r.getDayForDate(i),l=[];for(let[s,c]of o.moons){let u=createSpan();new jn({target:u,props:{moon:s,phase:c}}),l.push({icon:u,moon:s,phase:c})}return l}getDay(e,n=this.plugin.defaultCalendar){if(!e||typeof e!="object"||e.year==null||e.month==null||e.day==null){new Is.Notice("The Date parameter is required and must have the day, month and year.");return}typeof n=="string"&&(n=this.plugin.data.calendars.find(o=>o.name==n)??this.plugin.defaultCalendar);let a=this.getHelper(n),r;if(typeof e.month=="string"?r=a.data.months.findIndex(o=>o.name==e.month):r=e.month,isNaN(e.year)||isNaN(r)||r==-1||isNaN(e.day)){let o=[];isNaN(e.year)&&o.push("The year must be a number."),(isNaN(r)||r==-1)&&(typeof e.month=="string"?o.push(`Could not find ${e.month} in the Months list for ${a.calendar.name}`):o.push("The month must be a number or the name of a month in the list of months for the selected calendar.")),isNaN(e.day)&&o.push("The year must be a number."),new Is.Notice(`There was an issue with the provided date.
${o.join(`
`)}`);return}let i=a.getDayForDate({year:e.year,month:r,day:e.day});return{moons:i.moons,events:i.events,date:i.date,longDate:i.longDate,leapDay:i.leapday,weekday:i.weekday,displayDate:Kt(i.date,a.calendar)}}async addCategoryToCalendar(e,n=this.plugin.defaultCalendar){if(!e)throw new Error("Category is required.");if(!e.name||!e.color)throw new Error("A category requires a name and a color.");if(e.id||(e.id=Ze(6)),typeof n=="string"&&(n=this.plugin.data.calendars.find(a=>a.name==n)??this.plugin.defaultCalendar),!n||typeof n!="object"||!("categories"in n))throw new Error("Invalid calendar provided.");n.categories.push(e),await this.plugin.saveCalendar()}getHelper(e=this.plugin.defaultCalendar){return new Wa(e,this.plugin)}};var qs=Ee(Nn());var Xh=Wn.Platform.isMacOS?"Meta":"Control",ia={name:null,description:null,id:null,static:{incrementDay:!1,firstWeekDay:null,overflow:!0,weekdays:[],months:[],moons:[],displayMoons:!0,displayDayNumber:!1,leapDays:[],eras:[]},current:{year:null,month:null,day:null},events:[],categories:[],autoParse:!1,path:"/",supportTimelines:!1,syncTimelines:!0,timelineTag:"#timeline"},Jh={addToDefaultIfMissing:!0,calendars:[],configDirectory:null,currentCalendar:null,dailyNotes:!1,dateFormat:"YYYY-MM-DD",defaultCalendar:null,eventPreview:!1,exit:{saving:!1,event:!1,calendar:!1},eventFrontmatter:!1,parseDates:!1,settingsToggleState:{calendars:!1,events:!1,advanced:!0},showIntercalary:!1,version:{major:null,minor:null,patch:null},debug:!1},Rs=class extends Wn.Plugin{constructor(){super(...arguments);this.api=new Os(this);this.watcher=new Ms(this);this.save=(0,Wn.debounce)(async e=>{if(this.configDirectory)try{await this.app.vault.adapter.exists(this.configDirectory)||await this.app.vault.adapter.mkdir(this.configDirectory),await this.app.vault.adapter.write(this.configFilePath,JSON.stringify(e))}catch(n){console.error(n),new Wn.Notice("There was an error saving into the configured directory.")}await this.saveData(e)},200)}async addNewCalendar(e,n){let a=!n||e.name!=n?.name||e.autoParse&&!n?.autoParse||e.path!=n?.path;n==null?this.data.calendars.push(e):this.data.calendars.splice(this.data.calendars.indexOf(n),1,e),this.data.defaultCalendar||(this.data.defaultCalendar=e.id),a&&this.watcher.start(e),await this.saveCalendar()}get currentCalendar(){return this.data.calendars.find(e=>e.id==this.data.currentCalendar)}get canUseDailyNotes(){return this.dailyNotes._loaded}get dailyNotes(){return this.app.internalPlugins.getPluginById("daily-notes")}get canUseTimelines(){return this.app.plugins.getPlugin("obsidian-timelines")!=null}syncTimelines(e){return e.syncTimelines&&this.canUseTimelines}timelineTag(e){let n=e.timelineTag;return this.syncTimelines(e)&&(n=this.app.plugins.getPlugin("obsidian-timelines").settings.timelineTag),/^#/.test(n)||(n=`#${n}`),n??e.timelineTag??""}get format(){return(this.data.dailyNotes&&this.canUseDailyNotes?this.dailyNotes.instance.options.format:this.data.dateFormat)??"YYYY-MM-DD"}get defaultCalendar(){return this.data.calendars.find(e=>e.id==this.data.defaultCalendar)??this.data.calendars[0]}get view(){let e=this.app.workspace.getLeavesOfType(Xt),n=e.length?e[0]:null;if(n&&n.view&&n.view instanceof Hn)return n.view}get full(){let e=this.app.workspace.getLeavesOfType(fa),n=e.length?e[0]:null;if(n&&n.view&&n.view instanceof Hn)return n.view}async onload(){console.log("Loading Fantasy Calendars v"+this.manifest.version),(window.FantasyCalendarAPI=this.api)&&this.register(()=>delete window.FantasyCalendarAPI),this.registerView(Xt,e=>new Hn(this,e)),this.registerView(fa,e=>new Hn(this,e,{full:!0})),this.app.workspace.onLayoutReady(async()=>{await this.loadSettings(),this.watcher.load(),this.addCommands(),this.addSettingTab(new xi(this)),this.addCalendarView(!0)}),this.addRibbonIcon(Xt,"Open Large Fantasy Calendar",e=>{this.app.workspace.getLeaf(e.getModifierState(Xh)).setViewState({type:fa})})}async onunload(){console.log("Unloading Fantasy Calendars v"+this.manifest.version),this.app.workspace.getLeavesOfType(Xt).forEach(e=>e.detach()),this.app.workspace.getLeavesOfType(fa).forEach(e=>e.detach()),this.watcher.unload()}addCommands(){this.addCommand({id:"open-fantasy-calendar",name:"Open Fantasy Calendar",callback:()=>{this.addCalendarView()}}),this.addCommand({id:"open-big-fantasy-calendar",name:"Open Large Fantasy Calendar",callback:()=>{this.addFullCalendarView()}}),this.addCommand({id:"toggle-moons",name:"Toggle Moons",checkCallback:e=>{let n=this.app.workspace.getLeavesOfType(Xt);if(n&&n.length)return e||n[0].view.toggleMoons(),!0}}),this.addCommand({id:"view-date",name:"View Date",checkCallback:e=>{let n=this.app.workspace.getLeavesOfType(Xt);if(n&&n.length)return e||n[0].view.openDate(),!0}}),this.addCommand({id:"view-date",name:"View Note Event",checkCallback:e=>{let n=this.app.workspace.getLeavesOfType(Xt);if(n&&n.length&&n[0].view instanceof Hn){let a=this.app.workspace.getActiveFile();if(a){let r=n[0].view.calendar.events.find(i=>i.note==a.path);if(r)return e||n[0].view.openDay(r.date),!0}}}})}async addCalendarView(e=!1){e&&this.app.workspace.getLeavesOfType(Xt)?.length||(await this.app.workspace.getRightLeaf(!1).setViewState({type:Xt}),this.view&&this.app.workspace.revealLeaf(this.view.leaf))}async addFullCalendarView(e=!1){e&&this.app.workspace.getLeavesOfType(fa)?.length||(this.app.workspace.getLeaf(!1).setViewState({type:fa}),this.full&&this.app.workspace.revealLeaf(this.full.leaf))}async loadData(){return this.configDirectory&&await this.app.vault.adapter.exists(this.configFilePath)?JSON.parse(await this.app.vault.adapter.read(this.configFilePath)):await this.app.vault.adapter.exists(`${this.manifest.dir}/temp.json`)?JSON.parse(await this.app.vault.adapter.read(`${this.manifest.dir}/temp.json`)):await super.loadData()}async loadSettings(){if(this.data={...(0,qs.default)(Jh),...await this.loadData()},!this.data.defaultCalendar&&this.data.calendars.length&&(this.data.defaultCalendar=this.data.calendars[0].id),this.data.calendars.length&&!this.data.calendars.find(e=>e.id==this.data.defaultCalendar)&&(this.data.defaultCalendar=this.data.calendars[0].id),this.data.autoParse&&this.data.calendars.length){for(let e of this.data.calendars)e.autoParse=this.data.autoParse,e.path=this.data.path;delete this.data.autoParse,delete this.data.path}for(let e of this.data.calendars)e&&e.static&&e.static.eras&&e.static.eras.length&&e.static.eras.some(n=>!n.id)&&(e.static.eras=e.static.eras.map(n=>({...(0,qs.default)(n),id:n.id??Ze(6),restart:n.restart??!1,endsYear:n.endsYear??!1,event:n.event??!1})));this.data.eventFrontmatter=!1,await this.saveSettings(),this.settingsLoaded=!0,this.app.workspace.trigger("fantasy-calendars-settings-loaded")}onSettingsLoad(e){this.settingsLoaded?e():this.app.workspace.on("fantasy-calendars-settings-loaded",()=>e())}async saveCalendar(){await this.saveSettings(),this.app.workspace.trigger("fantasy-calendars-updated")}get configDirectory(){if(!(!this.data||!this.data.configDirectory))return`${this.data.configDirectory}/plugins/fantasy-calendar`}get configFilePath(){if(!!this.data.configDirectory)return`${this.configDirectory}/data.json`}async saveSettings(){await this.save(this.data),this.app.workspace.trigger("fantasy-calendar-settings-change")}async saveData(e,n=this.manifest.dir){try{await this.app.vault.adapter.write(`${n}/temp.json`,JSON.stringify(e,null,null)),await this.app.vault.adapter.exists(`${n}/data.json`)&&await this.app.vault.adapter.remove(`${n}/data.json`),await this.app.vault.adapter.copy(`${n}/temp.json`,`${n}/data.json`),await this.app.vault.adapter.remove(`${n}/temp.json`)}catch(a){console.log("\u{1F680} ~ file: main.ts:499 ~ e:",a),await super.saveData(e)}}};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/*! https://mths.be/he v1.2.0 by @mathias | MIT license */
/**
* chroma.js - JavaScript library for color conversions
*
* Copyright (c) 2011-2019, Gregor Aisch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name Gregor Aisch may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* -------------------------------------------------------
*
* chroma.js includes colors from colorbrewer2.org, which are released under
* the following license:
*
* Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
* and The Pennsylvania State University.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* ------------------------------------------------------
*
* Named colors are taken from X11 Color Names.
* http://www.w3.org/TR/css3-color/#svg-color
*
* @preserve
*/