/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ "use strict";var hs=Object.defineProperty;var mp=Object.getOwnPropertyDescriptor;var pp=Object.getOwnPropertyNames;var hp=Object.prototype.hasOwnProperty;var Iu=r=>{throw TypeError(r)};var gp=(r,e,t)=>e in r?hs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var bp=(r,e)=>{for(var t in e)hs(r,t,{get:e[t],enumerable:!0})},vp=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of pp(e))!hp.call(r,i)&&i!==t&&hs(r,i,{get:()=>e[i],enumerable:!(n=mp(e,i))||n.enumerable});return r};var yp=r=>vp(hs({},"__esModule",{value:!0}),r);var c=(r,e,t)=>gp(r,typeof e!="symbol"?e+"":e,t),fl=(r,e,t)=>e.has(r)||Iu("Cannot "+t);var h=(r,e,t)=>(fl(r,e,"read from private field"),t?t.call(r):e.get(r)),L=(r,e,t)=>e.has(r)?Iu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),Z=(r,e,t,n)=>(fl(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),U=(r,e,t)=>(fl(r,e,"access private method"),t);var _b={};bp(_b,{default:()=>ul});module.exports=yp(_b);var ho=class{constructor(e){c(this,"deps",e);c(this,"lastExpiredKeys",new Set)}startPeriodicTask(){let e=!0;this.periodicTask().finally(()=>{e=!1}),this.deps.registerInterval(window.setInterval(()=>{if(e){console.debug("Skip reminder interval task because task is already running.");return}e=!0,this.periodicTask().finally(()=>{e=!1})},this.deps.checkIntervalSec()*1e3))}async periodicTask(){if(this.deps.reloadUI(!1),this.deps.isScanned()||this.deps.reloadRemindersInAllFiles().then(()=>{this.deps.markScanned(),this.deps.saveData()}),this.deps.saveData(!1),this.deps.isPopupIntrusive()&&this.deps.isEditing())return;let e=this.deps.getExpiredReminders(),t=new Set(e.map(i=>i.key()));for(let i of t)if(!this.lastExpiredKeys.has(i)){this.deps.reloadUI(!0);break}if(this.lastExpiredKeys=t,!this.deps.isNotificationEnabled()||this.deps.isNotificationPaused())return;let n;for(let i of e)if(this.deps.isLayoutReady()){if(i.muteNotification)continue;if(n)for(;n.beingDisplayed;)await this.sleep(100);this.deps.showReminder(i),n=i}}async sleep(e){return new Promise(t=>window.setTimeout(t,e))}};function ml(r){let e=r.lastIndexOf("/");return(e===-1?r:r.slice(e+1)).replace(/\.md$/i,"")}function pl(r,e){let t=new Map;for(let o of r){let s=t.get(o.sequenceId);s===void 0?t.set(o.sequenceId,[o]):s.push(o)}let n=[],i=[];for(let o of t.values()){let s=o[o.length-1];if(s.event==="message_delete")continue;(s.atSeconds>e?n:i).push({sequenceId:s.sequenceId,atSeconds:s.atSeconds})}return{pending:n,delivered:i}}var go="obr-";function bo(r){return r.startsWith(go)}var Ip=16777619,_p=2166136261,Cp=2654435769;function _u(r,e){let t=e;for(let n=0;n>>0}var xp=` `;function Cu(r,e){return`${r}${xp}${e}`}function xu(r,e,t){let n=Cu(r,e),i=_u(n,_p).toString(36),o=_u(n,Cp).toString(36),s=`${go}${i}${o}`;return t===0?s:`${s}-${t}`}function hl(r){var i;let e=[...r].sort((o,s)=>o.file!==s.file?o.filed)continue;let K=p.get(x);m.set(K,{sequenceId:K,atSeconds:Math.floor(X/1e3),reminder:x})}let b=new Map;for(let x of t)b.set(x.sequenceId,x);let g=[];for(let x of m.values()){let X=b.get(x.sequenceId);(X===void 0||X.atSeconds!==x.atSeconds)&&g.push(x)}let v=[],I=new Set;function w(x){I.has(x)||(I.add(x),v.push({sequenceId:x}))}for(let x of t)bo(x.sequenceId)&&(m.has(x.sequenceId)||wu(x,f)&&w(x.sequenceId));for(let x of n)wu(x,f)&&w(x.sequenceId);return{publish:g,delete:v}}function wu(r,e){if(!bo(r.sequenceId))return!1;let t=e.get(r.sequenceId);return t===void 0||t!==r.atSeconds}function bl(r){return r.map(e=>e.sequenceId).filter(bo)}var Rp=/^[-_A-Za-z0-9]{1,64}$/;function ai(r){return Rp.test(r)}var li=class{constructor(e){c(this,"_value",e)}get value(){return this._value}},bn=class{constructor(e){c(this,"_value",e);c(this,"onChangeFunctions",[])}onChanged(e){this.onChangeFunctions.push(e)}get value(){return this._value}set value(e){let t=this._value;this._value=e,this.onChangeFunctions.forEach(n=>{n(t,e)})}};var Au=require("obsidian"),P=Au.moment;var G=class r{constructor(e,t){c(this,"time",e);c(this,"_hasTimePart",t)}static now(){return new r(P(),!0)}static parse(e){return e.length>10?new r(P(e,"YYYY-MM-DD HH:mm"),!0):new r(P(e,"YYYY-MM-DD"),!1)}static ofEpochMillis(e){return new r(P(e),!0)}static duration(e,t,n,i){return t.fixedTime(i).diff(e.fixedTime(i),n)}getTimeInMillis(e){return this.fixedTime(e).valueOf()}format(e,t){return this.fixedTime(t).format(e)}toYYYYMMMM(e){return this.fixedTime(e).format("YYYY, MMMM")}toYYYYMMDD(e){return this.fixedTime(e).format("YYYY-MM-DD")}add(e,t,n){return new r(this.fixedTime(n).clone().add(e,t),this._hasTimePart)}fixedTime(e){return this._hasTimePart?this.time:e===void 0?this.time:this.time.clone().add(e.minutes,"minutes")}get hasTimePart(){return this._hasTimePart}moment(){return this.time}isValid(){return this.time.isValid()}clone(e){let t=e==null?this._hasTimePart:e,n=this.time.clone();return new r(n,t)}toString(){return this._hasTimePart?this.format("YYYY-MM-DD HH:mm"):this.format("YYYY-MM-DD")}equals(e){return this._hasTimePart===e._hasTimePart&&this.time.isSame(e.time)}},gs=class r{constructor(e,t){c(this,"hour",e);c(this,"minute",t)}static parse(e){if(!e.match(/^\d{1,2}:\d{1,2}$/))throw new Error(`Unexpected format time(${e}). Time must be HH:mm.`);let t=e.split(":");if(t.length!==2)throw new Error(`Unexpected format time(${e}). time must be HH:mm.`);let n=parseInt(t[0]),i=parseInt(t[1]);if(n>23||n<0)throw new Error("hour must be 0~23");if(i>59||i<0)throw new Error("minute must be 0~59");return new r(n,i)}get minutes(){return this.hour*60+this.minute}toString(){let e=t=>t<10?"0"+t:""+t;return`${e(this.hour)}:${e(this.minute)}`}};function ci(r,e){return()=>new G(P(),!0).add(r,e)}function Ru(r){return ci(r,"minutes")}function vl(r){return ci(r,"hours")}function kp(r){return ci(r,"days")}function Fp(r){return ci(r,"weeks")}function Sp(r){return ci(r,"months")}function Ep(r){return ci(r,"years")}function Zn(r){return()=>{let e=P();return e.isoWeekday()<=r?new G(e.isoWeekday(r),!1):new G(e.add(1,"weeks").isoWeekday(r),!1)}}function yl(){return()=>new G(P().add(1,"days"),!1)}function ku(){return()=>new G(P().add(1,"weeks"),!1)}function Tp(){return()=>new G(P().add(1,"months"),!1)}function Gp(){return()=>new G(P().add(1,"years"),!1)}var ve=class{constructor(e,t){c(this,"label",e);c(this,"later",t)}};function Fu(r){return r.split(` `).map(e=>Bp(e.trim()))}function Bp(r){if(r=r.toLowerCase(),r.startsWith("in")){let e=r.split(" ");if(e.length!==3)throw new Error("Unsupported format. Should be 'In N (minutes|hours)'");let t=e[1]==="a"||e[1]==="an"?1:parseInt(e[1]);switch(e[2]){case"minute":case"minutes":{let n=t==1?"minute":"minutes";return new ve(`In ${t} ${n}`,Ru(t))}case"hour":case"hours":{let n=t==1?"hour":"hours";return new ve(`In ${t} ${n}`,vl(t))}case"day":case"days":{let n=t==1?"day":"days";return new ve(`In ${t} ${n}`,kp(t))}case"week":case"weeks":{let n=t==1?"week":"weeks";return new ve(`In ${t} ${n}`,Fp(t))}case"month":case"months":{let n=t==1?"month":"months";return new ve(`In ${t} ${n}`,Sp(t))}case"year":case"years":{let n=t==1?"year":"years";return new ve(`In ${t} ${n}`,Ep(t))}}}else if(r.startsWith("next")){let e=r.substring(5);switch(e){case"sunday":return new ve("Next Sunday",Zn(0));case"monday":return new ve("Next Monday",Zn(1));case"tuesday":return new ve("Next Tuesday",Zn(2));case"wednesday":return new ve("Next Wednesday",Zn(3));case"thursday":return new ve("Next Thursday",Zn(4));case"friday":return new ve("Next Friday",Zn(5));case"saturday":return new ve("Next Saturday",Zn(6));case"day":return new ve("Tomorrow",yl());case"week":return new ve("Next week",ku());case"month":return new ve("Next month",Tp());case"year":return new ve("Next year",Gp());default:throw new Error(`Unsupported weekday: ${e}`)}}else if(r==="tomorrow")return new ve("Tomorrow",yl());throw new Error(`Unsupported format: ${r}`)}var _l=[new ve("In 30 minutes",Ru(30)),new ve("In 1 hours",vl(1)),new ve("In 3 hours",vl(3)),new ve("Tomorrow",yl()),new ve("Next week",ku())],Il=class{constructor(){c(this,"dateFormat",new li("YYYY-MM-DD"));c(this,"dateTimeFormat",new li("YYYY-MM-DD HH:mm"));c(this,"strict",new li(!1))}setTimeFormat(e,t,n){this.dateFormat=e,this.dateTimeFormat=t,this.strict=n}parse(e){let t=this.doParse(e,!0);return t!=null?t:this.strict.value?null:this.doParse(e,!1)}doParse(e,t){let n=P(e,this.dateTimeFormat.value,t);if(n.isValid())return new G(n,!0);let i=P(e,this.dateFormat.value,t);return i.isValid()?new G(i,!1):null}toString(e){return e.hasTimePart?e.format(this.dateTimeFormat.value):e.format(this.dateFormat.value)}},xr=new Il;var Dp=1800*1e3,Np=10*1e3,Zp=200;function bs(r){let e=r.trim();return e.length===0?{}:{Authorization:`Bearer ${e}`}}function Eu(r){return r.trim().replace(/\/+$/,"")}function Tu(r,e){return`${r}/${encodeURIComponent(e)}/json?poll=1&sched=1`}function Gu(r,e,t){return`${r}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function vs(r){let e=r.text.trim().slice(0,Zp);return e.length===0?`status=${r.status}`:`status=${r.status} body=${e}`}function Bu(r){return r===401||r===403}var vo=class{constructor(e){c(this,"deps",e);c(this,"debounceTimer");c(this,"syncing",!1);c(this,"syncQueued",!1);c(this,"stopped",!1);c(this,"previousEnabled");c(this,"authFailureNotified",!1)}start(){this.previousEnabled=this.deps.isEnabled(),this.sync(),this.deps.registerInterval(window.setInterval(()=>{this.sync()},Dp))}stop(){this.stopped=!0,this.debounceTimer!==void 0&&(window.clearTimeout(this.debounceTimer),this.debounceTimer=void 0)}notifyRemindersChanged(){this.stopped||(this.debounceTimer!==void 0&&window.clearTimeout(this.debounceTimer),this.debounceTimer=window.setTimeout(()=>{this.debounceTimer=void 0,this.sync()},Np))}notifySettingsChanged(){this.stopped||(this.authFailureNotified=!1,this.checkEnabledTransition(),this.notifyRemindersChanged())}noteAuthFailure(e){!Bu(e)||this.authFailureNotified||(this.authFailureNotified=!0,this.deps.notify(`Reminder: the ntfy server rejected the request (${e}). Scheduled notifications are not being published. Check the ntfy access token in the plugin settings.`))}checkEnabledTransition(){let e=this.deps.isEnabled(),t=this.previousEnabled;this.previousEnabled=e,t===!0&&!e&&this.cleanupAfterDisable()}async cleanupAfterDisable(){let e=this.resolveServerAndTopic();if(e===void 0)return;let{serverUrl:t,topic:n}=e;try{let{pending:i}=await this.fetchServerState(t,n),o=bl(i);for(let s of o)await this.deleteScheduled(t,n,s)}catch(i){console.error("[ntfy] Failed to clean up scheduled notifications after disabling: %o",i)}}async sync(){if(this.syncing){this.syncQueued=!0;return}this.syncing=!0;try{await this.doSync()}finally{this.syncing=!1,this.syncQueued&&(this.syncQueued=!1,this.sync())}}async doSync(){if(!this.deps.isEnabled())return;let e=this.resolveServerAndTopic();if(e===void 0)return;let{serverUrl:t,topic:n}=e;try{let{pending:i,delivered:o}=await this.fetchServerState(t,n),s=gl({reminders:this.deps.reminders(),serverPending:i,serverDelivered:o,now:G.now(),defaultTime:this.deps.defaultTime()});for(let a of s.delete)await this.deleteScheduled(t,n,a.sequenceId);for(let a of s.publish)await this.publish(t,n,a)}catch(i){console.error("[ntfy] Failed to sync scheduled notifications: %o",i)}}resolveServerAndTopic(){let e=Eu(this.deps.serverUrl()),t=this.deps.topic().trim();if(!(e.length===0||!ai(t)))return{serverUrl:e,topic:t}}async fetchServerState(e,t){let n=await this.deps.request({url:Tu(e,t),method:"GET",headers:bs(this.deps.accessToken())});if(n.status>=400)throw this.noteAuthFailure(n.status),new Error(`ntfy: failed to fetch the topic's scheduled messages: ${vs(n)}`);let i=[];for(let s of n.text.split(` `)){let a=s.trim();if(a.length===0)continue;let l;try{l=JSON.parse(a)}catch(u){console.error("[ntfy] Failed to parse a poll response line: %o",u);continue}l.event!=="message"&&l.event!=="message_delete"||l.sequence_id===void 0||l.time===void 0||i.push({event:l.event,sequenceId:l.sequence_id,atSeconds:l.time})}let o=Math.floor(Date.now()/1e3);return pl(i,o)}async publish(e,t,n){let i=await this.deps.request({url:`${e}/`,method:"POST",headers:{...bs(this.deps.accessToken()),"Content-Type":"application/json","X-Sequence-ID":n.sequenceId},body:JSON.stringify({topic:t,title:n.reminder.title,message:ml(n.reminder.file),click:this.buildClickUrl(n.reminder),delay:String(n.atSeconds)})});i.status>=400&&(this.noteAuthFailure(i.status),console.error("[ntfy] Failed to publish a scheduled notification: %s",vs(i)))}async deleteScheduled(e,t,n){let i=await this.deps.request({url:Gu(e,t,n),method:"DELETE",headers:bs(this.deps.accessToken())});i.status>=400&&(this.noteAuthFailure(i.status),console.error("[ntfy] Failed to delete a scheduled notification: %s",vs(i)))}buildClickUrl(e){let t=e.file.replace(/\.md$/i,""),n=encodeURIComponent(this.deps.vaultName()),i=encodeURIComponent(t);return`obsidian://open?vault=${n}&file=${i}`}},Su=`${go}selftest`,Xp=1440*60;function Cl(r,e){let t=vs(e);return Bu(e.status)?`${r} was refused (${t}). Check the access token, and that it has read-write access to this topic.`:e.status===404?`${r} failed (${t}). Check the server URL.`:`${r} failed (${t}).`}async function Du(r,e){let t=Eu(e.serverUrl),n=e.topic.trim();if(t.length===0)return{ok:!1,message:"Set the ntfy server URL first."};if(n.length===0)return{ok:!1,message:"Set the ntfy topic first."};if(!ai(n))return{ok:!1,message:"The ntfy topic is not a valid topic name: use only letters, digits, dashes and underscores (1-64 characters)."};let i=bs(e.accessToken);try{let o=await r({url:Tu(t,n),method:"GET",headers:i});if(o.status>=400)return{ok:!1,message:Cl("Reading the topic",o)};let s=await r({url:`${t}/`,method:"POST",headers:{...i,"Content-Type":"application/json","X-Sequence-ID":Su},body:JSON.stringify({topic:n,title:"Reminder connection test",message:"Published by the Obsidian Reminder plugin to check the ntfy settings, and deleted again right away.",delay:String(Math.floor(Date.now()/1e3)+Xp)})});if(s.status>=400)return{ok:!1,message:Cl("Publishing a test message",s)};let a=await r({url:Gu(t,n,Su),method:"DELETE",headers:i});return a.status>=400?{ok:!1,message:`${Cl("Deleting the test message",a)} It stays scheduled until the next sync removes it.`}:{ok:!0,message:"Connected. Reading, publishing and deleting all succeeded."}}catch(o){return{ok:!1,message:`Could not reach ${t}: ${o instanceof Error?o.message:String(o)}`}}}var Yr=require("obsidian");var Jd=require("obsidian");var Nu=require("obsidian");function Zu(r,e){if(!e.reminders.getExpiredReminders(e.settings.reminderTime.value).some(i=>!i.muteNotification))return!1;if(r)return!0;let n=e.reminders.muteExpiredReminders(e.settings.reminderTime.value);return e.ui.reload(!0),e.data.save(!0),new Nu.Notice(`Muted ${n} reminder${n===1?"":"s"}`),!0}var xl=require("obsidian");var Xu=require("obsidian");var ys=class extends Xu.SuggestModal{constructor(t,n,i,o){super(t);c(this,"laters",n);c(this,"onSelect",i);c(this,"onCloseCallback",o);this.setPlaceholder("Pause reminder notifications for...")}getSuggestions(t){return this.laters.filter(n=>n.label.toLowerCase().includes(t.toLowerCase()))}renderSuggestion(t,n){n.createDiv({text:t.label})}onChooseSuggestion(t){this.onSelect(t)}onClose(){var t;(t=this.onCloseCallback)==null||t.call(this)}};function Up(r,e){let t=e.later();r.data.dndUntil.value=t,r.data.save(!0),r.ui.refreshDndStatusBar(),new xl.Notice(`Reminder notifications paused until ${t.format("YYYY-MM-DD HH:mm")}`)}function Is(r){r.data.dndUntil.value=null,r.data.save(!0),r.ui.refreshDndStatusBar(),new xl.Notice("Reminder notifications resumed")}function _s(r,e){new ys(r.app,r.settings.laters.value,t=>{Up(r,t)},e).open()}function Uu(r,e){return r||_s(e),!0}function ui(r,e){return r==null?!1:e.getTimeInMillis()e===this.check)}setChecked(e){this.check=e?"x":" "}getHeaderLength(){return this.prefix.length+this.check.length+this.suffix.length}clone(){return vn.parse(this.lineIndex,this.toMarkdown())}};c(vn,"regexp",/^(?((> ?)*)?\s*[-*+][ ]+\[)(?.)(?\]\s+)(?.*)$/),c(vn,"checkedStatuses",["x","-"]);var di=vn;function Lu(r){if(di.parse(0,r)!==null)return r;let e=/^(?(?:> ?)*\s*)(?.*)$/.exec(r),t=e.groups.lead,n=e.groups.rest;if(/^#{1,6}[ ]/.test(n)||/^\d+[.)][ ]/.test(n)||n.startsWith("|")||n.startsWith("```"))return null;let i=/^(?[-*+])[ ]+(?.*)$/.exec(n);if(i){let o=i.groups.marker,s=i.groups.content;return`${t}${o} [ ] ${s}`}return`${t}- [ ] ${n}`}var Cs=class Cs{constructor(e,t){c(this,"file",e);c(this,"lines",[]);c(this,"todos",[]);this.parse(t)}parse(e){this.lines=e.split(` `),this.todos=[];let t=null,n=0;this.lines.forEach((i,o)=>{let s=Cs.fenceRegexp.exec(i),a=s==null?void 0:s.groups.fence,l=s==null?void 0:s.groups.info;if(t===null){if(a!==void 0&&(a[0]!=="`"||!l.includes("`"))){t=a[0],n=a.length;return}}else{a!==void 0&&a[0]===t&&a.length>=n&&l.trim()===""&&(t=null);return}let u=di.parse(o,i);u&&this.todos.push(u)})}getTodos(){return this.todos}insertTodo(e,t){t.lineIndex=e,this.lines.splice(e,0,t.toMarkdown());let n=-1;for(let[i,o]of this.todos.entries())o.lineIndex>=e&&(n<0&&(n=i),o.lineIndex++);n<=0?this.todos.splice(0,0,t):this.todos.splice(n,0,t)}getTodo(e){let t=this.todos.find(n=>n.lineIndex===e);return t==null?null:t}applyChanges(){this.todos.forEach(e=>{this.lines[e.lineIndex]=e.toMarkdown()})}toMarkdown(){return this.applyChanges(),this.lines.join(` `)}};c(Cs,"fenceRegexp",/^\s*(?:> ?)*\s*(?`{3,}|~{3,})(?.*)$/);var Lr=Cs;var Mu=require("obsidian");var Xn=window.require?window.require("electron"):void 0;function xs(){new Mu.Notice('Cannot insert a reminder here. Reminders can only be added to task lines such as "- [ ] task".')}function ws(r){return(r==null?void 0:r.dom.closest(".kanban-plugin__item-input"))!=null}function As(r,e,t,n,i,o){let s=r.appendReminder(e,t,n);if(s!=null)return s;if(o)return Yu(r,e,t,n);if(!i)return null;let a=Lu(e);if(a==null)return null;let l=n==null?void 0:n+(a.length-e.length);return r.appendReminder(a,t,l)}async function Ou(r,e){return Xn&&(await Xn.remote.dialog.showMessageBox({type:"question",title:"Obsidian Reminder",message:r,detail:e,buttons:["OK","Cancel"],cancelId:1})).response===0?0:1}var fi=class r{constructor(e,t,n,i,o){c(this,"file",e);c(this,"title",t);c(this,"time",n);c(this,"rowNumber",i);c(this,"done",o);c(this,"muteNotification",!1);c(this,"beingDisplayed",!1)}key(){return this.file+this.title+this.time.toString()}isExpired(e,t){return this.time.getTimeInMillis(t)<=e}equals(e){return this.rowNumber===e.rowNumber&&this.title===e.title&&this.time.equals(e.time)&&this.file===e.file}getFileName(){return r.extractFileName(this.file)}static extractFileName(e){let t=e.split(/[/\\]/);return t[t.length-1].replace(/^(.*?)(\..+)?$/,"$1")}},Rs=class{constructor(e){c(this,"onChange",e);c(this,"fileToReminders",new Map);c(this,"reminders",[]);c(this,"reminderTime")}getExpiredReminders(e){let t=new Date().getTime(),n=[];for(let i=0;it.time.toYYYYMMDD()===e.toYYYYMMDD())}removeReminder(e){console.debug("Remove reminder: %o",e),this.reminders.remove(e);let t=this.fileToReminders.get(e.file);t&&(t.remove(e),t.length===0&&this.fileToReminders.delete(e.file)),this.onChange()}clear(){this.fileToReminders.clear(),this.reminders=[],this.onChange()}removeByFile(e){return this.fileToReminders.delete(e)?(this.sortReminders(),!0):!1}replaceFile(e,t){let n=this.fileToReminders.get(e);if(n){if(this.equals(n,t))return!1;let i=new Map;for(let o of n)i.set(o.key(),o.muteNotification);for(let o of t){let s=i.get(o.key());i.set(o.key(),o.muteNotification),s!==void 0&&(o.muteNotification=s)}}return this.fileToReminders.set(e,t),this.sortReminders(),!0}equals(e,t){if(e.length!==t.length)return!1;let n=[...e],i=[...t];return this.sort(n),this.sort(i),n.every((o,s)=>o.equals(i[s]))}sortReminders(){let e=[];for(let t of this.fileToReminders.values())e.push(...t);this.sort(e),this.reminders=e,this.onChange()}sort(e){e.sort((t,n)=>{var o,s;let i=t.time.getTimeInMillis((o=this.reminderTime)==null?void 0:o.value)-n.time.getTimeInMillis((s=this.reminderTime)==null?void 0:s.value);return i>0?1:i<0?-1:0})}},Pu=[{name:"US Style (12h)",format:{yearMonthFormat:"MMMM YYYY",monthDayFormat:"MM/DD",shortDateWithWeekdayFormat:"M/DD (ddd)",timeFormat:"h:mm A"}},{name:"US Style (24h)",format:{yearMonthFormat:"MMMM YYYY",monthDayFormat:"MM/DD",shortDateWithWeekdayFormat:"M/DD (ddd)",timeFormat:"HH:mm"}},{name:"EU Style (24h)",format:{yearMonthFormat:"MMMM YYYY",monthDayFormat:"DD/MM",shortDateWithWeekdayFormat:"D/MM (ddd)",timeFormat:"HH:mm"}},{name:"EU Style (12h)",format:{yearMonthFormat:"MMMM YYYY",monthDayFormat:"DD/MM",shortDateWithWeekdayFormat:"D/MM (ddd)",timeFormat:"h:mm A"}},{name:"JP Style (24h)",format:{yearMonthFormat:"YYYY\u5E74MM\u6708",monthDayFormat:"MM/DD",shortDateWithWeekdayFormat:"M\u6708D\u65E5 (ddd)",timeFormat:"HH:mm"}},{name:"JP Style (12h)",format:{yearMonthFormat:"YYYY\u5E74MM\u6708",monthDayFormat:"MM/DD",shortDateWithWeekdayFormat:"M\u6708D\u65E5 (ddd)",timeFormat:"h:mm A"}}];function $u(r,e,t,n){let i=G.duration(e,r,"days",t);if(i>30)return new yn(r.format(n.yearMonthFormat,t),o=>o.format(n.monthDayFormat,t));if(i>=7)return new yn("Over 1 week",o=>o.format(n.monthDayFormat,t));if(r.toYYYYMMDD(t)===e.toYYYYMMDD(t)){let o=new yn("Today",s=>s.format(n.timeFormat,t));return o.isToday=!0,o}return r.toYYYYMMDD(t)===e.add(1,"days",t).toYYYYMMDD()?new yn("Tomorrow",o=>o.format(n.timeFormat,t)):new yn(r.format(n.shortDateWithWeekdayFormat,t),o=>o.format(n.timeFormat,t))}var yn=class{constructor(e,t){c(this,"name",e);c(this,"timeToStringFunc",t);c(this,"isToday",!1);c(this,"isOverdue",!1)}timeToString(e){return this.timeToStringFunc(e)}};function Hu(r,e,t){let n=G.now(),i=n.getTimeInMillis(),o=[],s=[],a=[],l=$u(n,n,e,t);for(let u=0;u0||l.isToday)&&o.push(new Io(l,s)),s=[]),s.push(d),l=p}if(s.length>0&&o.push(new Io(l,s)),a.length>0){let u=new yn("Overdue",d=>d.toYYYYMMDD(e)===n.toYYYYMMDD(e)?d.format(t.timeFormat,e):d.format(t.monthDayFormat,e));u.isOverdue=!0,o.splice(0,0,new Io(u,a))}return o}var Io=class{constructor(e,t){c(this,"group",e);c(this,"reminders",t)}get name(){return this.group.name}get isOverdue(){return this.group.isOverdue}timeToString(e){return this.group.timeToString(e)}};var pt=class pt{constructor(e,t){c(this,"key",e);c(this,"defaultValue",t)}};c(pt,"now",new pt("now",G.now())),c(pt,"useCustomEmojiForTasksPlugin",new pt("useCustomEmojiForTasksPlugin",!1)),c(pt,"removeTagsForTasksPlugin",new pt("removeTagsForTasksPlugin",!1)),c(pt,"useReminderTimeFallbackForTasksPlugin",new pt("useReminderTimeFallbackForTasksPlugin",!1)),c(pt,"dataviewReminderFieldName",new pt("dataviewReminderFieldName","reminder")),c(pt,"linkDatesToDailyNotes",new pt("linkDatesToDailyNotes",!1)),c(pt,"strictDateFormat",new pt("strictDateFormat",!1));var _e=pt,_o=class{constructor(){c(this,"parameters",new Map)}setParameter(e,t){this.parameters.set(e.key,()=>t.value)}setParameterFunc(e,t){this.parameters.set(e.key,t)}setParameterValue(e,t){this.parameters.set(e.key,()=>t)}getParameter(e){let t=this.parameters.get(e.key);return t==null?e.defaultValue:t()}},In=class{constructor(){c(this,"config",new _o)}setConfig(e){this.config=e}parse(e){return e.getTodos().map(t=>{let n=this.parseValidReminder(t);if(n==null)return null;let i=n.getTitle();if(i==null)return null;let o=n.getTime();if(o==null)return null;let s=new fi(e.file,i,o,t.lineIndex,this.isDone(t,n)),a=n.computeSpan(),l=t.getHeaderLength();return{reminder:s,columnStart:a.start+l,columnEnd:a.end+l}}).filter(t=>t!=null)}async modify(e,t,n){let i=e.getTodo(t.rowNumber);if(i===null)return console.warn("Not a todo: reminder=%o",t),!1;let o=this.parseValidReminder(i);return o===null||!this.modifyReminder(e,i,o,n)?!1:(i.body=o.toMarkdown(),!0)}parseValidReminder(e){let t=this.parseReminder(e);return t===null||!this.isValidReminder(t)?null:t}isDone(e,t){return e.isChecked()}isValidReminder(e){return e.getTime()!==null}modifyReminder(e,t,n,i){if(i.rawTime!==void 0){if(!n.setRawTime(i.rawTime))return console.warn("The reminder doesn't support raw time: parsed=%o",n),!1}else i.time!==void 0&&n.setTime(i.time);return i.checked!==void 0&&t.setChecked(i.checked),!0}appendReminder(e,t,n){let i=di.parse(0,e);if(i==null)return null;let o=this.parseReminder(i),s=i.getHeaderLength();return n!=null&&(n-=s),o!=null?o.setTime(t,n):(o=this.newReminder(i.body,t,n),o.setTime(t)),i.body=o.toMarkdown(),{insertedLine:i.toMarkdown(),caretPosition:s+o.getEndOfTimeTextIndex()}}isStrictDateFormat(){return this.config.getParameter(_e.strictDateFormat)}},ks=class{constructor(){c(this,"config");c(this,"formats",[])}setConfig(e){this.config=e,this.syncConfig()}parse(e){let t=[];for(let n of this.formats){let i=n.parse(e);i!=null&&t.push(...i)}return t}async modify(e,t,n){for(let i of this.formats)if(await i.modify(e,t,n))return!0;return!1}resetFormat(e){this.formats=e,this.syncConfig()}syncConfig(){this.config!=null&&this.formats.forEach(e=>e.setConfig(this.config))}appendReminder(e,t){return this.formats[0]==null?null:this.formats[0].appendReminder(e,t)}};var Ju="(?[[(])(?
\\s*)(?[\\p{L}\\p{N}_-]+)::(?\\s*)(?[^[\\]()]*?)(?\\s*)(?[)\\]])";function Qp(r,e){return r==="["&&e==="]"?"bracket":r==="("&&e===")"?"paren":null}function ju(r){let e=new RegExp(Ju,"gu"),t=[],n;for(;(n=e.exec(r))!==null;){let i=n.groups,o=Qp(i.open,i.close);o!=null&&t.push({key:i.key,value:i.value,style:o,start:n.index,end:n.index+n[0].length})}return t}function zu(r,e,t){let n=r.slice(e.start,e.end),o=new RegExp(`^${Ju}$`,"u").exec(n);if(o==null)return r;let s=o.groups,a=s.open.length+s.pre.length+s.key.length+2+s.mid.length,l=s.value.length,u=n.slice(0,a)+t+n.slice(a+l);return r.slice(0,e.start)+u+r.slice(e.end)}function Ku(r,e,t,n="bracket"){let[i,o]=n==="bracket"?["[","]"]:["(",")"],s=`${i}${e}:: ${t}${o}`;if(r.length===0)return s;let a=/\s$/.test(r)?"":" ";return`${r}${a}${s}`}function wl(r,e){let t=e.start,n=e.end;return t>0&&r[t-1]===" "?t-=1:n0?"+":"")+String(this.n)+e),e},r.prototype.getJsWeekday=function(){return this.weekday===6?0:this.weekday+1},r})();var be=function(r){return r!=null},Ut=function(r){return typeof r=="number"},Al=function(r){return typeof r=="string"&&Co.includes(r)},rt=Array.isArray,nr=function(r,e){e===void 0&&(e=r),arguments.length===1&&(e=r,r=0);for(var t=[],n=r;n>0,n.length>e?String(n):(e=e-n.length,e>t.length&&(t+=ee(t,e/t.length)),t.slice(0,e)+String(n))}var ed=function(r,e,t){var n=r.split(e);return t?n.slice(0,t).concat([n.slice(t).join(e)]):n},ht=function(r,e){var t=r%e;return t*e<0?t+e:t},Fs=function(r,e){return{div:Math.floor(r/e),mod:ht(r,e)}},Qt=function(r){return!be(r)||r.length===0},Fe=function(r){return!Qt(r)},re=function(r,e){return Fe(r)&&r.indexOf(e)!==-1};var wr=function(r,e,t,n,i,o){return n===void 0&&(n=0),i===void 0&&(i=0),o===void 0&&(o=0),new Date(Date.UTC(r,e-1,t,n,i,o))},Wp=[31,28,31,30,31,30,31,31,30,31,30,31],rd=1e3*60*60*24,Ss=9999,nd=wr(1970,1,1),Vp=[6,0,1,2,3,4,5];var mi=function(r){return r%4===0&&r%100!==0||r%400===0},Rl=function(r){return r instanceof Date},Qn=function(r){return Rl(r)&&!isNaN(r.getTime())};var Yp=function(r,e){var t=r.getTime(),n=e.getTime(),i=t-n;return Math.round(i/rd)},xo=function(r){return Yp(r,nd)},Es=function(r){return new Date(nd.getTime()+r*rd)},Lp=function(r){var e=r.getUTCMonth();return e===1&&mi(r.getUTCFullYear())?29:Wp[e]},Mr=function(r){return Vp[r.getUTCDay()]},kl=function(r,e){var t=wr(r,e+1,1);return[Mr(t),Lp(t)]},Ts=function(r,e){return e=e||r,new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))},Gs=function(r){var e=new Date(r.getTime());return e},Fl=function(r){for(var e=[],t=0;tthis.maxDate;if(this.method==="between"){if(t)return!0;if(n)return!1}else if(this.method==="before"){if(n)return!1}else if(this.method==="after")return t?!0:(this.add(e),!1);return this.add(e)},r.prototype.add=function(e){return this._result.push(e),!0},r.prototype.getValue=function(){var e=this._result;switch(this.method){case"all":case"between":return e;default:return e.length?e[e.length-1]:null}},r.prototype.clone=function(){return new r(this.method,this.args)},r})(),$r=Mp;var Sl=function(r,e){return Sl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},Sl(r,e)};function hi(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Sl(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var nt=function(){return nt=Object.assign||function(e){for(var t,n=1,i=arguments.length;ne[0].length)&&(e=o,t=i)}if(e!=null&&(this.text=this.text.substr(e[0].length),this.text===""&&(this.done=!0)),e==null){this.done=!0,this.symbol=null,this.value=null;return}}while(t==="SKIP");return this.symbol=t,this.value=e,!0},r.prototype.accept=function(e){if(this.symbol===e){if(this.value){var t=this.value;return this.nextSymbol(),t}return this.nextSymbol(),!0}return!1},r.prototype.acceptNumber=function(){return this.accept("number")},r.prototype.expect=function(e){if(this.accept(e))return!0;throw new Error("expected "+e+" but found "+this.symbol)},r})();function Ao(r,e){e===void 0&&(e=Wn);var t={},n=new jp(e.tokens);if(!n.start(r))return null;return i(),t;function i(){n.expect("every");var f=n.acceptNumber();if(f&&(t.interval=parseInt(f[0],10)),n.isDone())throw new Error("Unexpected end");switch(n.symbol){case"day(s)":t.freq=F.DAILY,n.nextSymbol()&&(s(),p());break;case"weekday(s)":t.freq=F.WEEKLY,t.byweekday=[F.MO,F.TU,F.WE,F.TH,F.FR],n.nextSymbol(),s(),p();break;case"week(s)":t.freq=F.WEEKLY,n.nextSymbol()&&(o(),s(),p());break;case"hour(s)":t.freq=F.HOURLY,n.nextSymbol()&&(o(),p());break;case"minute(s)":t.freq=F.MINUTELY,n.nextSymbol()&&(o(),p());break;case"month(s)":t.freq=F.MONTHLY,n.nextSymbol()&&(o(),p());break;case"year(s)":t.freq=F.YEARLY,n.nextSymbol()&&(o(),p());break;case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":t.freq=F.WEEKLY;var m=n.symbol.substr(0,2).toUpperCase();if(t.byweekday=[F[m]],!n.nextSymbol())return;for(;n.accept("comma");){if(n.isDone())throw new Error("Unexpected end");var b=l();if(!b)throw new Error("Unexpected symbol "+n.symbol+", expected weekday");t.byweekday.push(F[b]),n.nextSymbol()}s(),d(),p();break;case"january":case"february":case"march":case"april":case"may":case"june":case"july":case"august":case"september":case"october":case"november":case"december":if(t.freq=F.YEARLY,t.bymonth=[a()],!n.nextSymbol())return;for(;n.accept("comma");){if(n.isDone())throw new Error("Unexpected end");var g=a();if(!g)throw new Error("Unexpected symbol "+n.symbol+", expected month");t.bymonth.push(g),n.nextSymbol()}o(),p();break;default:throw new Error("Unknown symbol")}}function o(){var f=n.accept("on"),m=n.accept("the");if(f||m)do{var b=u(),g=l(),v=a();if(b)g?(n.nextSymbol(),t.byweekday||(t.byweekday=[]),t.byweekday.push(F[g].nth(b))):(t.bymonthday||(t.bymonthday=[]),t.bymonthday.push(b),n.accept("day(s)"));else if(g)n.nextSymbol(),t.byweekday||(t.byweekday=[]),t.byweekday.push(F[g]);else if(n.symbol==="weekday(s)")n.nextSymbol(),t.byweekday||(t.byweekday=[F.MO,F.TU,F.WE,F.TH,F.FR]);else if(n.symbol==="week(s)"){n.nextSymbol();var I=n.acceptNumber();if(!I)throw new Error("Unexpected symbol "+n.symbol+", expected week number");for(t.byweekno=[parseInt(I[0],10)];n.accept("comma");){if(I=n.acceptNumber(),!I)throw new Error("Unexpected symbol "+n.symbol+"; expected monthday");t.byweekno.push(parseInt(I[0],10))}}else if(v)n.nextSymbol(),t.bymonth||(t.bymonth=[]),t.bymonth.push(v);else return}while(n.accept("comma")||n.accept("the")||n.accept("on"))}function s(){var f=n.accept("at");if(f)do{var m=n.acceptNumber();if(!m)throw new Error("Unexpected symbol "+n.symbol+", expected hour");for(t.byhour=[parseInt(m[0],10)];n.accept("comma");){if(m=n.acceptNumber(),!m)throw new Error("Unexpected symbol "+n.symbol+"; expected hour");t.byhour.push(parseInt(m[0],10))}}while(n.accept("comma")||n.accept("at"))}function a(){switch(n.symbol){case"january":return 1;case"february":return 2;case"march":return 3;case"april":return 4;case"may":return 5;case"june":return 6;case"july":return 7;case"august":return 8;case"september":return 9;case"october":return 10;case"november":return 11;case"december":return 12;default:return!1}}function l(){switch(n.symbol){case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":return n.symbol.substr(0,2).toUpperCase();default:return!1}}function u(){switch(n.symbol){case"last":return n.nextSymbol(),-1;case"first":return n.nextSymbol(),1;case"second":return n.nextSymbol(),n.accept("last")?-2:2;case"third":return n.nextSymbol(),n.accept("last")?-3:3;case"nth":var f=parseInt(n.value[1],10);if(f<-366||f>366)throw new Error("Nth out of range: "+f);return n.nextSymbol(),n.accept("last")?-f:f;default:return!1}}function d(){n.accept("on"),n.accept("the");var f=u();if(f)for(t.bymonthday=[f],n.nextSymbol();n.accept("comma");){if(f=u(),!f)throw new Error("Unexpected symbol "+n.symbol+"; expected monthday");t.bymonthday.push(f),n.nextSymbol()}}function p(){if(n.symbol==="until"){var f=Date.parse(n.text);if(!f)throw new Error("Cannot parse until date:"+n.text);t.until=new Date(f)}else n.accept("for")&&(t.count=parseInt(n.value[0],10),n.expect("number"))}}var j;(function(r){r[r.YEARLY=0]="YEARLY",r[r.MONTHLY=1]="MONTHLY",r[r.WEEKLY=2]="WEEKLY",r[r.DAILY=3]="DAILY",r[r.HOURLY=4]="HOURLY",r[r.MINUTELY=5]="MINUTELY",r[r.SECONDLY=6]="SECONDLY"})(j||(j={}));function Ro(r){return r12){var n=Math.floor(this.month/12),i=ht(this.month,12);this.month=i,this.year+=n,this.month===0&&(this.month=12,--this.year)}},e.prototype.addWeekly=function(t,n){n>this.getWeekday()?this.day+=-(this.getWeekday()+1+(6-n))+t*7:this.day+=-(this.getWeekday()-n)+t*7,this.fixDay()},e.prototype.addDaily=function(t){this.day+=t,this.fixDay()},e.prototype.addHours=function(t,n,i){for(n&&(this.hour+=Math.floor((23-this.hour)/t)*t);;){this.hour+=t;var o=Fs(this.hour,24),s=o.div,a=o.mod;if(s&&(this.hour=a,this.addDaily(s)),Qt(i)||re(i,this.hour))break}},e.prototype.addMinutes=function(t,n,i,o){for(n&&(this.minute+=Math.floor((1439-(this.hour*60+this.minute))/t)*t);;){this.minute+=t;var s=Fs(this.minute,60),a=s.div,l=s.mod;if(a&&(this.minute=l,this.addHours(a,!1,i)),(Qt(i)||re(i,this.hour))&&(Qt(o)||re(o,this.minute)))break}},e.prototype.addSeconds=function(t,n,i,o,s){for(n&&(this.second+=Math.floor((86399-(this.hour*3600+this.minute*60+this.second))/t)*t);;){this.second+=t;var a=Fs(this.second,60),l=a.div,u=a.mod;if(l&&(this.second=u,this.addMinutes(l,!1,i,o)),(Qt(i)||re(i,this.hour))&&(Qt(o)||re(o,this.minute))&&(Qt(s)||re(s,this.second)))break}},e.prototype.fixDay=function(){if(!(this.day<=28)){var t=kl(this.year,this.month-1)[1];if(!(this.day<=t))for(;this.day>t;){if(this.day-=t,++this.month,this.month===13&&(this.month=1,++this.year,this.year>Ss))return;t=kl(this.year,this.month-1)[1]}}},e.prototype.add=function(t,n){var i=t.freq,o=t.interval,s=t.wkst,a=t.byhour,l=t.byminute,u=t.bysecond;switch(i){case j.YEARLY:return this.addYears(o);case j.MONTHLY:return this.addMonths(o);case j.WEEKLY:return this.addWeekly(o,s);case j.DAILY:return this.addDaily(o);case j.HOURLY:return this.addHours(o,n,a);case j.MINUTELY:return this.addMinutes(o,n,a,l);case j.SECONDLY:return this.addSeconds(o,n,a,l,u)}},e})(bi);function Tl(r){for(var e=[],t=Object.keys(r),n=0,i=t;n=-366&&n<=366))throw new Error("bysetpos must be between 1 and 366, or between -366 and -1")}}if(!(e.byweekno||Fe(e.byweekno)||Fe(e.byyearday)||e.bymonthday||Fe(e.bymonthday)||be(e.byweekday)||be(e.byeaster)))switch(e.freq){case F.YEARLY:e.bymonth||(e.bymonth=e.dtstart.getUTCMonth()+1),e.bymonthday=e.dtstart.getUTCDate();break;case F.MONTHLY:e.bymonthday=e.dtstart.getUTCDate();break;case F.WEEKLY:e.byweekday=[Mr(e.dtstart)];break}if(be(e.bymonth)&&!rt(e.bymonth)&&(e.bymonth=[e.bymonth]),be(e.byyearday)&&!rt(e.byyearday)&&Ut(e.byyearday)&&(e.byyearday=[e.byyearday]),!be(e.bymonthday))e.bymonthday=[],e.bynmonthday=[];else if(rt(e.bymonthday)){for(var i=[],o=[],t=0;t0?i.push(n):n<0&&o.push(n)}e.bymonthday=i,e.bynmonthday=o}else e.bymonthday<0?(e.bynmonthday=[e.bymonthday],e.bymonthday=[]):(e.bynmonthday=[],e.bymonthday=[e.bymonthday]);if(be(e.byweekno)&&!rt(e.byweekno)&&(e.byweekno=[e.byweekno]),!be(e.byweekday))e.bynweekday=null;else if(Ut(e.byweekday))e.byweekday=[e.byweekday],e.bynweekday=null;else if(Al(e.byweekday))e.byweekday=[Ne.fromStr(e.byweekday).weekday],e.bynweekday=null;else if(e.byweekday instanceof Ne)!e.byweekday.n||e.freq>F.MONTHLY?(e.byweekday=[e.byweekday.weekday],e.bynweekday=null):(e.bynweekday=[[e.byweekday.weekday,e.byweekday.n]],e.byweekday=null);else{for(var s=[],a=[],t=0;tF.MONTHLY?s.push(l.weekday):a.push([l.weekday,l.n])}e.byweekday=Fe(s)?s:null,e.bynweekday=Fe(a)?a:null}return be(e.byhour)?Ut(e.byhour)&&(e.byhour=[e.byhour]):e.byhour=e.freq=4?(d=0,u=a.yearlen+ht(s-e.wkst,7)):u=n-d;for(var p=Math.floor(u/7),f=ht(u,7),m=Math.floor(p+f/4),b=0;b0&&g<=m){var v=void 0;g>1?(v=d+(g-1)*7,d!==l&&(v-=7-l)):v=d;for(var I=0;I<7&&(a.wnomask[v]=1,v++,a.wdaymask[v]!==e.wkst);I++);}}if(re(e.byweekno,1)){var v=d+m*7;if(d!==l&&(v-=7-l),v=4?(X=0,V=K+ht(x-e.wkst,7)):V=n-d,w=Math.floor(52+ht(V,7)/4)}if(re(e.byweekno,w))for(var v=0;vo)return Pr(r);if(w>=t){var x=Sd(w,e);if(!r.accept(x)||a&&(--a,!a))return Pr(r)}}else for(var I=m;Io)return Pr(r);if(w>=t){var x=Sd(w,e);if(!r.accept(x)||a&&(--a,!a))return Pr(r)}}}if(e.interval===0||(l.add(e,g),l.year>Ss))return Pr(r);Ro(n)||(d=u.gettimeset(n)(l.hour,l.minute,l.second,0)),u.rebuild(l.year,l.month)}}function lh(r,e,t){var n=t.bymonth,i=t.byweekno,o=t.byweekday,s=t.byeaster,a=t.bymonthday,l=t.bynmonthday,u=t.byyearday;return Fe(n)&&!re(n,r.mmask[e])||Fe(i)&&!r.wnomask[e]||Fe(o)&&!re(o,r.wdaymask[e])||Fe(r.nwdaymask)&&!r.nwdaymask[e]||s!==null&&!re(r.eastermask,e)||(Fe(a)||Fe(l))&&!re(a,r.mdaymask[e])&&!re(l,r.nmdaymask[e])||Fe(u)&&(e=r.yearlen&&!re(u,e+1-r.yearlen)&&!re(u,-r.nextyearlen+e-r.yearlen))}function Sd(r,e){return new Vn(r,e.tzid).rezonedDate()}function Pr(r){return r.getValue()}function ch(r,e,t,n,i){for(var o=!1,s=e;s=F.HOURLY&&Fe(i)&&!re(i,e.hour)||n>=F.MINUTELY&&Fe(o)&&!re(o,e.minute)||n>=F.SECONDLY&&Fe(s)&&!re(s,e.second)?[]:r.gettimeset(n)(e.hour,e.minute,e.second,e.millisecond)}var ir={MO:new Ne(0),TU:new Ne(1),WE:new Ne(2),TH:new Ne(3),FR:new Ne(4),SA:new Ne(5),SU:new Ne(6)},ko={freq:j.YEARLY,dtstart:null,interval:1,wkst:ir.MO,count:null,until:null,tzid:null,bysetpos:null,bymonth:null,bymonthday:null,bynmonthday:null,byyearday:null,byweekno:null,byweekday:null,bynweekday:null,byhour:null,byminute:null,bysecond:null,byeaster:null},fd=Object.keys(ko),F=(function(){function r(e,t){e===void 0&&(e={}),t===void 0&&(t=!1),this._cache=t?null:new hd,this.origOptions=Tl(e);var n=ud(e).parsedOptions;this.options=n}return r.parseText=function(e,t){return Ao(e,t)},r.fromText=function(e,t){return sd(e,t)},r.fromString=function(e){return new r(r.parseString(e)||void 0)},r.prototype._iter=function(e){return Bs(e,this.options)},r.prototype._cacheGet=function(e,t){return this._cache?this._cache._cacheGet(e,t):!1},r.prototype._cacheAdd=function(e,t,n){if(this._cache)return this._cache._cacheAdd(e,t,n)},r.prototype.all=function(e){if(e)return this._iter(new El("all",{},e));var t=this._cacheGet("all");return t===!1&&(t=this._iter(new $r("all",{})),this._cacheAdd("all",t)),t},r.prototype.between=function(e,t,n,i){if(n===void 0&&(n=!1),!Qn(e)||!Qn(t))throw new Error("Invalid date passed in to RRule.between");var o={before:t,after:e,inc:n};if(i)return this._iter(new El("between",o,i));var s=this._cacheGet("between",o);return s===!1&&(s=this._iter(new $r("between",o)),this._cacheAdd("between",s,o)),s},r.prototype.before=function(e,t){if(t===void 0&&(t=!1),!Qn(e))throw new Error("Invalid date passed in to RRule.before");var n={dt:e,inc:t},i=this._cacheGet("before",n);return i===!1&&(i=this._iter(new $r("before",n)),this._cacheAdd("before",i,n)),i},r.prototype.after=function(e,t){if(t===void 0&&(t=!1),!Qn(e))throw new Error("Invalid date passed in to RRule.after");var n={dt:e,inc:t},i=this._cacheGet("after",n);return i===!1&&(i=this._iter(new $r("after",n)),this._cacheAdd("after",i,n)),i},r.prototype.count=function(){return this.all().length},r.prototype.toString=function(){return Eo(this.origOptions)},r.prototype.toText=function(e,t,n){return ad(this,e,t,n)},r.prototype.isFullyConvertibleToText=function(){return ld(this)},r.prototype.clone=function(){return new r(this.origOptions)},r.FREQUENCIES=["YEARLY","MONTHLY","WEEKLY","DAILY","HOURLY","MINUTELY","SECONDLY"],r.YEARLY=j.YEARLY,r.MONTHLY=j.MONTHLY,r.WEEKLY=j.WEEKLY,r.DAILY=j.DAILY,r.HOURLY=j.HOURLY,r.MINUTELY=j.MINUTELY,r.SECONDLY=j.SECONDLY,r.MO=ir.MO,r.TU=ir.TU,r.WE=ir.WE,r.TH=ir.TH,r.FR=ir.FR,r.SA=ir.SA,r.SU=ir.SU,r.parseString=So,r.optionsToString=Eo,r})();function Ed(r,e,t,n,i,o){var s={},a=r.accept;function l(f,m){t.forEach(function(b){b.between(f,m,!0).forEach(function(g){s[Number(g)]=!0})})}i.forEach(function(f){var m=new Vn(f,o).rezonedDate();s[Number(m)]=!0}),r.accept=function(f){var m=Number(f);return isNaN(m)?a.call(this,f):!s[m]&&(l(new Date(m-1),new Date(m+1)),!s[m])?(s[m]=!0,a.call(this,f)):!0},r.method==="between"&&(l(r.args.after,r.args.before),r.accept=function(f){var m=Number(f);return s[m]?!0:(s[m]=!0,a.call(this,f))});for(var u=0;u1||i.length||o.length||s.length){var d=new Dl(u);return d.dtstart(a),d.tzid(l||void 0),n.forEach(function(f){d.rrule(new F(Bl(f,a,l),u))}),i.forEach(function(f){d.rdate(f)}),o.forEach(function(f){d.exrule(new F(Bl(f,a,l),u))}),s.forEach(function(f){d.exdate(f)}),e.compatible&&e.dtstart&&d.rdate(a),d}var p=n[0]||{};return new F(Bl(p,p.dtstart||e.dtstart||a,p.tzid||e.tzid||l),u)}function Ds(r,e){return e===void 0&&(e={}),fh(r,mh(e))}function Bl(r,e,t){return nt(nt({},r),{dtstart:e,tzid:t})}function mh(r){var e=[],t=Object.keys(r),n=Object.keys(Td);if(t.forEach(function(i){re(n,i)||e.push(i)}),e.length)throw new Error("Invalid options: "+e.join(", "));return nt(nt({},Td),r)}function ph(r){if(r.indexOf(":")===-1)return{name:"RRULE",value:r};var e=ed(r,":",1),t=e[0],n=e[1];return{name:t,value:n}}function hh(r){var e=ph(r),t=e.name,n=e.value,i=t.split(";");if(!i)throw new Error("empty property name");return{name:i[0].toUpperCase(),parms:i.slice(1),value:n}}function gh(r,e){if(e===void 0&&(e=!1),r=r&&r.trim(),!r)throw new Error("Invalid empty string");if(!e)return r.split(/\s/);for(var t=r.split(`
`),n=0;n0&&i[0]===" "?(t[n-1]+=i.slice(1),t.splice(n,1)):n+=1:t.splice(n,1)}return t}function bh(r){r.forEach(function(e){if(!/(VALUE=DATE(-TIME)?)|(TZID=)/.test(e))throw new Error("unsupported RDATE/EXDATE parm: "+e)})}function Gd(r,e){return bh(e),r.split(",").map(function(t){return wo(t)})}function Bd(r){var e=this;return function(t){if(t!==void 0&&(e["_".concat(r)]=t),e["_".concat(r)]!==void 0)return e["_".concat(r)];for(var n=0;nt.key.toLowerCase()===e)}firstField(e){var t;return(t=this.fieldsByKey(e)[0])!=null?t:null}hasReminderField(){return this.firstField(this.reminderFieldName)!=null}hasAnySourceField(){return this.hasReminderField()||this.firstField(Yn)!=null}reminderSourceField(){var e;return(e=this.firstField(this.reminderFieldName))!=null?e:this.firstField(Yn)}getTitle(){let e=new Set([..._h,this.reminderFieldName]),t=this.fields().filter(i=>e.has(i.key.toLowerCase())).sort((i,o)=>o.start-i.start),n=this.text;for(let i of t)n=wl(n,i);return n=n.trim(),this.removeTags&&(n=Ns(n)),n}getTime(){let e=this.reminderSourceField();return e==null?null:Nl(e.value)}setTime(e){var i;let t=this.reminderSourceField(),n=(i=t==null?void 0:t.key)!=null?i:Yn;this.setFieldValue(n,Xd(e))}setRawTime(e){var i;let t=this.reminderSourceField(),n=(i=t==null?void 0:t.key)!=null?i:Yn;return this.setFieldValue(n,e),!0}getDueDate(){let e=this.firstField(Yn);return e==null?null:Nl(e.value)}setDueDate(e){this.setFieldValue(Yn,Xd(e))}getRecurrence(){var t;let e=this.firstField(Ud);return(t=e==null?void 0:e.value)!=null?t:null}getDoneDate(){let e=this.firstField(Zs);return e==null?null:Nl(e.value)}setDoneDate(e){if(e==null){this.removeFieldByKey(Zs);return}let t=e instanceof G?e.format(Zl):e;this.setFieldValue(Zs,t)}getEndOfTimeTextIndex(){let e=this.reminderSourceField();return e!=null?e.end:this.toMarkdown().length}computeSpan(){let e=this.reminderSourceField();return e==null?{start:0,end:0}:{start:e.start,end:e.end}}toMarkdown(){return this.text}clone(){return r.parse(this.toMarkdown(),this.reminderFieldName,this.removeTags)}setFieldValue(e,t){let n=this.firstField(e);n!=null?this.text=zu(this.text,n,t):this.text=Ku(this.text,e,t,"bracket")}removeFieldByKey(e){let t=this.firstField(e);t!=null&&(this.text=wl(this.text,t))}},Qs=class Qs extends yi{parseReminder(e){let t=Xs.parse(e.body,this.reminderFieldName(),this.removeTagsEnabled());return t.hasAnySourceField()?t:null}reminderFieldName(){return this.config.getParameter(_e.dataviewReminderFieldName)}removeTagsEnabled(){return this.config.getParameter(_e.removeTagsForTasksPlugin)}usesSeparateReminderDate(e){return e.hasReminderField()}newReminder(e,t){let n=Xs.parse(e,this.reminderFieldName(),this.removeTagsEnabled());return n.setTime(t),n}};c(Qs,"instance",new Qs);var Us=Qs;var Rr=class Rr{constructor(e,t,n,i,o=null){c(this,"linkDatesToDailyNotes",e);c(this,"title1",t);c(this,"time",n);c(this,"title2",i);c(this,"recurrence",o)}static parse(e,t){t==null&&(t=!1);let n=Rr.regexp.exec(e);if(n==null)return null;let i=n.groups.title1,o=n.groups.time;if(o==null)return null;let s=n.groups.title2;t&&(o=o.replace("[[",""),o=o.replace("]]",""));let a=null,l=o.indexOf(Rr.recurrenceSymbol);if(l>=0){let u=o.substring(0,l).trim(),d=o.substring(l+Rr.recurrenceSymbol.length).trim();d!==""&&(o=u,a=d)}return new Rr(t,i,o,s,a)}getTitle(){return`${this.title1.trim()} ${this.title2.trim()}`.trim()}getTime(){return xr.parse(this.time)}setTime(e){this.time=xr.toString(e)}setRawTime(e){return this.time=e,!0}getEndOfTimeTextIndex(){return this.toMarkdown().length-this.title2.length}computeSpan(){let e=this.title1.length,t=this.computeGroupText();return{start:e,end:e+t.length}}toMarkdown(){return`${this.title1}${this.computeGroupText()}${this.title2}`}computeGroupText(){let e=this.recurrence!==null?`${this.time} ${Rr.recurrenceSymbol}${this.recurrence}`:this.time;return`(@${this.renderTimeText(e)})`}renderTimeText(e){if(!this.linkDatesToDailyNotes)return e;let t=xr.parse(this.time);if(!t)return e;let n=xr.toString(t.clone(!1));return e.replace(n,`[[${n}]]`)}clone(){return Rr.parse(this.toMarkdown(),this.linkDatesToDailyNotes)}};c(Rr,"regexp",/^(?.*?)\(@(?