Absolue-Necessite/.obsidian/plugins/homepage/main.js
2023-10-27 09:49:33 +02:00

3 lines
53 KiB
JavaScript

"use strict";var tn=Object.create;var et=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var nn=Object.getOwnPropertyNames;var rn=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty;var sn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ln=(t,e)=>{for(var o in e)et(t,o,{get:e[o],enumerable:!0})},to=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nn(e))!an.call(t,i)&&i!==o&&et(t,i,{get:()=>e[i],enumerable:!(n=on(e,i))||n.enumerable});return t};var pn=(t,e,o)=>(o=t!=null?tn(rn(t)):{},to(e||!t||!t.__esModule?et(o,"default",{value:t,enumerable:!0}):o,t)),cn=t=>to(et({},"__esModule",{value:!0}),t);var xo=sn(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});var T=require("obsidian"),yt="YYYY-MM-DD",bt="gggg-[W]ww",so="YYYY-MM",lo="YYYY-[Q]Q",po="YYYY";function Ce(t){let e=window.app.plugins.getPlugin("periodic-notes");return e&&e.settings?.[t]?.enabled}function Fe(){try{let{internalPlugins:t,plugins:e}=window.app;if(Ce("daily")){let{format:r,folder:a,template:l}=e.getPlugin("periodic-notes")?.settings?.daily||{};return{format:r||yt,folder:a?.trim()||"",template:l?.trim()||""}}let{folder:o,format:n,template:i}=t.getPluginById("daily-notes")?.instance?.options||{};return{format:n||yt,folder:o?.trim()||"",template:i?.trim()||""}}catch(t){console.info("No custom daily note settings found!",t)}}function He(){try{let t=window.app.plugins,e=t.getPlugin("calendar")?.options,o=t.getPlugin("periodic-notes")?.settings?.weekly;if(Ce("weekly"))return{format:o.format||bt,folder:o.folder?.trim()||"",template:o.template?.trim()||""};let n=e||{};return{format:n.weeklyNoteFormat||bt,folder:n.weeklyNoteFolder?.trim()||"",template:n.weeklyNoteTemplate?.trim()||""}}catch(t){console.info("No custom weekly note settings found!",t)}}function Re(){let t=window.app.plugins;try{let e=Ce("monthly")&&t.getPlugin("periodic-notes")?.settings?.monthly||{};return{format:e.format||so,folder:e.folder?.trim()||"",template:e.template?.trim()||""}}catch(e){console.info("No custom monthly note settings found!",e)}}function Ve(){let t=window.app.plugins;try{let e=Ce("quarterly")&&t.getPlugin("periodic-notes")?.settings?.quarterly||{};return{format:e.format||lo,folder:e.folder?.trim()||"",template:e.template?.trim()||""}}catch(e){console.info("No custom quarterly note settings found!",e)}}function Ie(){let t=window.app.plugins;try{let e=Ce("yearly")&&t.getPlugin("periodic-notes")?.settings?.yearly||{};return{format:e.format||po,folder:e.folder?.trim()||"",template:e.template?.trim()||""}}catch(e){console.info("No custom yearly note settings found!",e)}}function co(...t){let e=[];for(let n=0,i=t.length;n<i;n++)e=e.concat(t[n].split("/"));let o=[];for(let n=0,i=e.length;n<i;n++){let r=e[n];!r||r==="."||o.push(r)}return e[0]===""&&o.unshift(""),o.join("/")}function dn(t){let e=t.substring(t.lastIndexOf("/")+1);return e.lastIndexOf(".")!=-1&&(e=e.substring(0,e.lastIndexOf("."))),e}async function un(t){let e=t.replace(/\\/g,"/").split("/");if(e.pop(),e.length){let o=co(...e);window.app.vault.getAbstractFileByPath(o)||await window.app.vault.createFolder(o)}}async function We(t,e){e.endsWith(".md")||(e+=".md");let o=T.normalizePath(co(t,e));return await un(o),o}async function Ee(t){let{metadataCache:e,vault:o}=window.app,n=T.normalizePath(t);if(n==="/")return Promise.resolve(["",null]);try{let i=e.getFirstLinkpathDest(n,""),r=await o.cachedRead(i),a=window.app.foldManager.load(i);return[r,a]}catch(i){return console.error(`Failed to read the daily note template '${n}'`,i),new T.Notice("Failed to read the daily note template"),["",null]}}function Q(t,e="day"){let o=t.clone().startOf(e).format();return`${e}-${o}`}function uo(t){return t.replace(/\[[^\]]*\]/g,"")}function mn(t,e){if(e==="week"){let o=uo(t);return/w{1,2}/i.test(o)&&(/M{1,4}/.test(o)||/D{1,4}/.test(o))}return!1}function Ne(t,e){return mo(t.basename,e)}function fn(t,e){return mo(dn(t),e)}function mo(t,e){let n={day:Fe,week:He,month:Re,quarter:Ve,year:Ie}[e]().format.split("/").pop(),i=window.moment(t,n,!0);if(!i.isValid())return null;if(mn(n,e)&&e==="week"){let r=uo(n);if(/w{1,2}/i.test(r))return window.moment(t,n.replace(/M{1,4}/g,"").replace(/D{1,4}/g,""),!1)}return i}var xt=class extends Error{};async function fo(t){let e=window.app,{vault:o}=e,n=window.moment,{template:i,format:r,folder:a}=Fe(),[l,s]=await Ee(i),c=t.format(r),p=await We(a,c);try{let m=await o.create(p,l.replace(/{{\s*date\s*}}/gi,c).replace(/{{\s*time\s*}}/gi,n().format("HH:mm")).replace(/{{\s*title\s*}}/gi,c).replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(v,d,w,f,u,g)=>{let P=n(),E=t.clone().set({hour:P.get("hour"),minute:P.get("minute"),second:P.get("second")});return w&&E.add(parseInt(f,10),u),g?E.format(g.substring(1).trim()):E.format(r)}).replace(/{{\s*yesterday\s*}}/gi,t.clone().subtract(1,"day").format(r)).replace(/{{\s*tomorrow\s*}}/gi,t.clone().add(1,"d").format(r)));return e.foldManager.save(m,s),m}catch(m){console.error(`Failed to create file: '${p}'`,m),new T.Notice("Unable to create new file.")}}function gn(t,e){return e[Q(t,"day")]??null}function hn(){let{vault:t}=window.app,{folder:e}=Fe(),o=t.getAbstractFileByPath(T.normalizePath(e));if(!o)throw new xt("Failed to find daily notes folder");let n={};return T.Vault.recurseChildren(o,i=>{if(i instanceof T.TFile){let r=Ne(i,"day");if(r){let a=Q(r,"day");n[a]=i}}}),n}var Pt=class extends Error{};function vn(){let{moment:t}=window,e=t.localeData()._week.dow,o=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];for(;e;)o.push(o.shift()),e--;return o}function wn(t){return vn().indexOf(t.toLowerCase())}async function go(t){let{vault:e}=window.app,{template:o,format:n,folder:i}=He(),[r,a]=await Ee(o),l=t.format(n),s=await We(i,l);try{let c=await e.create(s,r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,m,v,d,w,f)=>{let u=window.moment(),g=t.clone().set({hour:u.get("hour"),minute:u.get("minute"),second:u.get("second")});return v&&g.add(parseInt(d,10),w),f?g.format(f.substring(1).trim()):g.format(n)}).replace(/{{\s*title\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi,(p,m,v)=>{let d=wn(m);return t.weekday(d).format(v.trim())}));return window.app.foldManager.save(c,a),c}catch(c){console.error(`Failed to create file: '${s}'`,c),new T.Notice("Unable to create new file.")}}function yn(t,e){return e[Q(t,"week")]??null}function bn(){let t={};if(!vo())return t;let{vault:e}=window.app,{folder:o}=He(),n=e.getAbstractFileByPath(T.normalizePath(o));if(!n)throw new Pt("Failed to find weekly notes folder");return T.Vault.recurseChildren(n,i=>{if(i instanceof T.TFile){let r=Ne(i,"week");if(r){let a=Q(r,"week");t[a]=i}}}),t}var Et=class extends Error{};async function ho(t){let{vault:e}=window.app,{template:o,format:n,folder:i}=Re(),[r,a]=await Ee(o),l=t.format(n),s=await We(i,l);try{let c=await e.create(s,r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,m,v,d,w,f)=>{let u=window.moment(),g=t.clone().set({hour:u.get("hour"),minute:u.get("minute"),second:u.get("second")});return v&&g.add(parseInt(d,10),w),f?g.format(f.substring(1).trim()):g.format(n)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(c,a),c}catch(c){console.error(`Failed to create file: '${s}'`,c),new T.Notice("Unable to create new file.")}}function xn(t,e){return e[Q(t,"month")]??null}function Pn(){let t={};if(!wo())return t;let{vault:e}=window.app,{folder:o}=Re(),n=e.getAbstractFileByPath(T.normalizePath(o));if(!n)throw new Et("Failed to find monthly notes folder");return T.Vault.recurseChildren(n,i=>{if(i instanceof T.TFile){let r=Ne(i,"month");if(r){let a=Q(r,"month");t[a]=i}}}),t}var Nt=class extends Error{};async function En(t){let{vault:e}=window.app,{template:o,format:n,folder:i}=Ve(),[r,a]=await Ee(o),l=t.format(n),s=await We(i,l);try{let c=await e.create(s,r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,m,v,d,w,f)=>{let u=window.moment(),g=t.clone().set({hour:u.get("hour"),minute:u.get("minute"),second:u.get("second")});return v&&g.add(parseInt(d,10),w),f?g.format(f.substring(1).trim()):g.format(n)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(c,a),c}catch(c){console.error(`Failed to create file: '${s}'`,c),new T.Notice("Unable to create new file.")}}function Nn(t,e){return e[Q(t,"quarter")]??null}function On(){let t={};if(!yo())return t;let{vault:e}=window.app,{folder:o}=Ve(),n=e.getAbstractFileByPath(T.normalizePath(o));if(!n)throw new Nt("Failed to find quarterly notes folder");return T.Vault.recurseChildren(n,i=>{if(i instanceof T.TFile){let r=Ne(i,"quarter");if(r){let a=Q(r,"quarter");t[a]=i}}}),t}var Ot=class extends Error{};async function Dn(t){let{vault:e}=window.app,{template:o,format:n,folder:i}=Ie(),[r,a]=await Ee(o),l=t.format(n),s=await We(i,l);try{let c=await e.create(s,r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,m,v,d,w,f)=>{let u=window.moment(),g=t.clone().set({hour:u.get("hour"),minute:u.get("minute"),second:u.get("second")});return v&&g.add(parseInt(d,10),w),f?g.format(f.substring(1).trim()):g.format(n)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(c,a),c}catch(c){console.error(`Failed to create file: '${s}'`,c),new T.Notice("Unable to create new file.")}}function Sn(t,e){return e[Q(t,"year")]??null}function Tn(){let t={};if(!bo())return t;let{vault:e}=window.app,{folder:o}=Ie(),n=e.getAbstractFileByPath(T.normalizePath(o));if(!n)throw new Ot("Failed to find yearly notes folder");return T.Vault.recurseChildren(n,i=>{if(i instanceof T.TFile){let r=Ne(i,"year");if(r){let a=Q(r,"year");t[a]=i}}}),t}function kn(){let{app:t}=window,e=t.internalPlugins.plugins["daily-notes"];if(e&&e.enabled)return!0;let o=t.plugins.getPlugin("periodic-notes");return o&&o.settings?.daily?.enabled}function vo(){let{app:t}=window;if(t.plugins.getPlugin("calendar"))return!0;let e=t.plugins.getPlugin("periodic-notes");return e&&e.settings?.weekly?.enabled}function wo(){let{app:t}=window,e=t.plugins.getPlugin("periodic-notes");return e&&e.settings?.monthly?.enabled}function yo(){let{app:t}=window,e=t.plugins.getPlugin("periodic-notes");return e&&e.settings?.quarterly?.enabled}function bo(){let{app:t}=window,e=t.plugins.getPlugin("periodic-notes");return e&&e.settings?.yearly?.enabled}function Mn(t){let e={day:Fe,week:He,month:Re,quarter:Ve,year:Ie}[t];return e()}function An(t,e){return{day:fo,month:ho,week:go}[t](e)}h.DEFAULT_DAILY_NOTE_FORMAT=yt;h.DEFAULT_MONTHLY_NOTE_FORMAT=so;h.DEFAULT_QUARTERLY_NOTE_FORMAT=lo;h.DEFAULT_WEEKLY_NOTE_FORMAT=bt;h.DEFAULT_YEARLY_NOTE_FORMAT=po;h.appHasDailyNotesPluginLoaded=kn;h.appHasMonthlyNotesPluginLoaded=wo;h.appHasQuarterlyNotesPluginLoaded=yo;h.appHasWeeklyNotesPluginLoaded=vo;h.appHasYearlyNotesPluginLoaded=bo;h.createDailyNote=fo;h.createMonthlyNote=ho;h.createPeriodicNote=An;h.createQuarterlyNote=En;h.createWeeklyNote=go;h.createYearlyNote=Dn;h.getAllDailyNotes=hn;h.getAllMonthlyNotes=Pn;h.getAllQuarterlyNotes=On;h.getAllWeeklyNotes=bn;h.getAllYearlyNotes=Tn;h.getDailyNote=gn;h.getDailyNoteSettings=Fe;h.getDateFromFile=Ne;h.getDateFromPath=fn;h.getDateUID=Q;h.getMonthlyNote=xn;h.getMonthlyNoteSettings=Re;h.getPeriodicNoteSettings=Mn;h.getQuarterlyNote=Nn;h.getQuarterlyNoteSettings=Ve;h.getTemplateInfo=Ee;h.getWeeklyNote=yn;h.getWeeklyNoteSettings=He;h.getYearlyNote=Sn;h.getYearlyNoteSettings=Ie});var mi={};ln(mi,{default:()=>ft});module.exports=cn(mi);var se=require("obsidian");var Y=require("obsidian");var Po=require("obsidian");var oo=require("obsidian");function ee(t){return t?t.extension=="md"?t.path.slice(0,-3):t.path:""}function no(t){return t.split("/").slice(-1)[0].contains(".")?t:`${t}.md`}function io(t,e){return(t%e+e)%e}function ro(t){let e=t.vault.getFiles().filter(o=>["md","canvas"].contains(o.extension));if(e.length){let o=Math.floor(Math.random()*e.length);return ee(e[o])}}function ao(t){return t.workspace.getActiveViewOfType(oo.View)?.getViewType()=="empty"}var O=pn(xo()),Dt={["Daily Note"]:{noun:"day",adjective:"daily",create:O.createDailyNote,get:O.getDailyNote,getAll:O.getAllDailyNotes},["Weekly Note"]:{noun:"week",adjective:"weekly",create:O.createWeeklyNote,get:O.getWeeklyNote,getAll:O.getAllWeeklyNotes},["Monthly Note"]:{noun:"month",adjective:"monthly",create:O.createMonthlyNote,get:O.getMonthlyNote,getAll:O.getAllMonthlyNotes},["Yearly Note"]:{noun:"year",adjective:"yearly",create:O.createYearlyNote,get:O.getYearlyNote,getAll:O.getAllYearlyNotes}},St=["Daily Note","Weekly Note","Monthly Note","Yearly Note"];async function Eo(t,e){let o=e.communityPlugins["periodic-notes"],n=Dt[t],i=(0,Po.moment)().startOf(n.noun),r;if(Oo(o)){let a=n.getAll();Object.keys(a).length?r=n.get(i,a)||await n.create(i):r=await n.create(i)}else o.cache.initialize(),r=o.getPeriodicNote(n.noun,i)||await o.createPeriodicNote(n.noun,i);return ee(r)}function No(t,e){if(t=="Daily Note"&&e.internalPlugins["daily-notes"]?.enabled)return!0;let o=e.communityPlugins["periodic-notes"];if(!o)return!1;if(Oo(o)){let n=Dt[t].adjective;return e.communityPlugins["periodic-notes"].settings[n]?.enabled}else{let n=Dt[t].noun;return e.communityPlugins["periodic-notes"]?.calendarSetManager?.getActiveSet()[n]?.enabled}}function tt(t){let e=t.internalPlugins["daily-notes"];return e?.enabled&&e?.instance.options.autorun}function Oo(t){return(t?.manifest.version||"0").startsWith("0")}var Do=["markdown","canvas","kanban"],me="Main Homepage",ot="Mobile Homepage",nt=(n=>(n.ReplaceAll="Replace all open notes",n.ReplaceLast="Replace last note",n.Retain="Keep open notes",n))(nt||{}),Tt=(i=>(i.Default="Default view",i.Reading="Reading view",i.Source="Editing view (Source)",i.LivePreview="Editing view (Live Preview)",i))(Tt||{}),_e=(p=>(p.File="File",p.Workspace="Workspace",p.Random="Random file",p.Graph="Graph view",p.None="Nothing",p.DailyNote="Daily Note",p.WeeklyNote="Weekly Note",p.MonthlyNote="Monthly Note",p.YearlyNote="Yearly Note",p.MomentDate="Date-dependent file",p))(_e||{}),Be=class{constructor(e,o){this.lastView=void 0;this.openedViews=new WeakMap;this.name=e,this.plugin=o,this.app=o.app,this.data=o.settings.homepages[e],this.data.commands||(this.data.commands=[],this.save()),this.data?.hasRibbonIcon==!1&&this.app.workspace.onLayoutReady(async()=>{let n=this.app.workspace.leftRibbon;n.items.find(i=>i.id==="homepage:Open homepage").hidden=!0,n.onChange(!0),delete this.data.hasRibbonIcon,this.save()})}async open(e=!1){if(this.plugin.hasRequiredPlugin(this.data.kind)){if(this.data.kind==="Workspace")await this.launchWorkspace();else if(this.data.kind!=="Nothing"){let o=this.plugin.loaded?this.data.manualOpenMode:this.data.openMode;e&&(o="Keep open notes"),await this.launchLeaf(o)}}else{new Y.Notice("Homepage cannot be opened due to plugin unavailablity.");return}if(this.data.commands)for(let o of this.data.commands)this.app.commands.executeCommandById(o)}async launchWorkspace(){let e=this.plugin.internalPlugins.workspaces?.instance;if(!(this.data.value in e.workspaces)){new Y.Notice(`Cannot find the workspace "${this.data.value}" to use as the homepage.`);return}e.loadWorkspace(this.data.value)}async launchLeaf(e){let o;if(this.computedValue=await this.computeValue(),this.plugin.executing=!0,!(tt(this.plugin)&&!this.plugin.loaded)){if(e!=="Replace all open notes"){let n=this.getOpened();if(n.length>0){this.app.workspace.setActiveLeaf(n[0]),await this.configure(n[0]);return}else e=="Keep open notes"&&ao(this.app)&&(e="Replace last note")}e!=="Keep open notes"&&this.app.workspace.getActiveViewOfType(Y.View)?.leaf.setPinned(!1),e==="Replace all open notes"&&(Do.forEach(n=>this.app.workspace.detachLeavesOfType(n)),await Promise.resolve()),this.data.kind==="Graph view"?o=await this.launchGraph(e):o=await this.launchNote(e),o&&await this.configure(o)}}async launchGraph(e){if(e==="Keep open notes"){let o=this.app.workspace.getLeaf("tab");this.app.workspace.setActiveLeaf(o)}return this.app.commands.executeCommandById("graph:open"),this.app.workspace.getActiveViewOfType(Y.View)?.leaf}async launchNote(e){let o=this.app.metadataCache.getFirstLinkpathDest(this.computedValue,"/");if(!o){if(!this.data.autoCreate){new Y.Notice(`Homepage "${this.computedValue}" does not exist.`);return}o=await this.app.vault.create(no(this.computedValue),"")}let n=this.app.workspace.getLeaf(e=="Keep open notes");return await n.openFile(o),this.app.workspace.setActiveLeaf(n),n}async configure(e){this.plugin.executing=!1;let o=e.view;if(!(o instanceof Y.MarkdownView)){this.data.pin&&o.leaf.setPinned(!0);return}let n=o.getState();if(this.data.revertView&&(this.lastView=new WeakRef(o)),this.data.autoScroll){let i=o.editor.lineCount();n.mode=="preview"?o.previewMode.applyScroll(i-4):(o.editor.setCursor(i),o.editor.focus())}if(this.data.pin&&o.leaf.setPinned(!0),this.data.view!="Default view"){switch(this.data.view){case"Editing view (Live Preview)":case"Editing view (Source)":n.mode="source",n.source=this.data.view!="Editing view (Live Preview)";break;case"Reading view":n.mode="preview";break}await o.leaf.setViewState({type:"markdown",state:n}),this.plugin.loaded&&this.data.refreshDataview&&this.plugin.communityPlugins.dataview?.index.touch()}}getOpened(){return this.data.kind=="Graph view"?this.app.workspace.getLeavesOfType("graph"):Do.flatMap(o=>this.app.workspace.getLeavesOfType(o)).filter(o=>ee(o.view.file)==this.computedValue)}async computeValue(){let e=this.data.value;switch(this.data.kind){case"Date-dependent file":e=(0,Y.moment)().format(this.data.value);break;case"Random file":let o=ro(this.app);o&&(e=o);break;case"Daily Note":case"Weekly Note":case"Monthly Note":case"Yearly Note":e=await Eo(this.data.kind,this.plugin);break}return e}async save(){this.plugin.settings.homepages[this.name]=this.data,await this.plugin.saveSettings()}async revertView(){if(this.lastView==null||this.data.view=="Default view")return;let e=this.lastView.deref();if(!e||ee(e.file)==this.computedValue)return;let o=e.getState(),n=this.app.vault.config,i=n.defaultViewMode||"source",r=n.livePreview!==void 0?!n.livePreview:!1;e.leaf.getViewState().type=="markdown"&&(i!=o.mode||r!=o.source)&&(o.mode=i,o.source=r,await e.leaf.setViewState({type:"markdown",state:o,active:!0})),this.lastView=void 0}async openWhenEmpty(){if(!this.plugin.loaded||this.plugin.executing)return;let e=this.app.workspace.getActiveViewOfType(Y.View)?.leaf;e?.getViewState().type!=="empty"||e?.parentSplit.children.length!=1||await this.open(!0)}async apply(){let e=this.app.workspace.getActiveViewOfType(Y.FileView);if(!e)return;let o=ee(e.file);this.openedViews.get(e)!==o&&(this.openedViews.set(e,o),o===await this.computeValue()&&this.plugin.loaded&&!this.plugin.executing&&await this.configure(e.leaf))}};var W=require("obsidian");var Me=require("obsidian");var Ko=require("obsidian");var k="top",H="bottom",A="right",M="left",it="auto",re=[k,H,A,M],te="start",fe="end",So="clippingParents",rt="viewport",Oe="popper",To="reference",kt=re.reduce(function(t,e){return t.concat([e+"-"+te,e+"-"+fe])},[]),at=[].concat(re,[it]).reduce(function(t,e){return t.concat([e,e+"-"+te,e+"-"+fe])},[]),Ln="beforeRead",Cn="read",Fn="afterRead",Hn="beforeMain",Rn="main",Vn="afterMain",In="beforeWrite",Wn="write",_n="afterWrite",ko=[Ln,Cn,Fn,Hn,Rn,Vn,In,Wn,_n];function V(t){return t?(t.nodeName||"").toLowerCase():null}function D(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function q(t){var e=D(t).Element;return t instanceof e||t instanceof Element}function R(t){var e=D(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function De(t){if(typeof ShadowRoot>"u")return!1;var e=D(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Bn(t){var e=t.state;Object.keys(e.elements).forEach(function(o){var n=e.styles[o]||{},i=e.attributes[o]||{},r=e.elements[o];!R(r)||!V(r)||(Object.assign(r.style,n),Object.keys(i).forEach(function(a){var l=i[a];l===!1?r.removeAttribute(a):r.setAttribute(a,l===!0?"":l)}))})}function jn(t){var e=t.state,o={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,o.popper),e.styles=o,e.elements.arrow&&Object.assign(e.elements.arrow.style,o.arrow),function(){Object.keys(e.elements).forEach(function(n){var i=e.elements[n],r=e.attributes[n]||{},a=Object.keys(e.styles.hasOwnProperty(n)?e.styles[n]:o[n]),l=a.reduce(function(s,c){return s[c]="",s},{});!R(i)||!V(i)||(Object.assign(i.style,l),Object.keys(r).forEach(function(s){i.removeAttribute(s)}))})}}var Mo={name:"applyStyles",enabled:!0,phase:"write",fn:Bn,effect:jn,requires:["computeStyles"]};function I(t){return t.split("-")[0]}var X=Math.max,ge=Math.min,oe=Math.round;function Se(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function je(){return!/^((?!chrome|android).)*safari/i.test(Se())}function z(t,e,o){e===void 0&&(e=!1),o===void 0&&(o=!1);var n=t.getBoundingClientRect(),i=1,r=1;e&&R(t)&&(i=t.offsetWidth>0&&oe(n.width)/t.offsetWidth||1,r=t.offsetHeight>0&&oe(n.height)/t.offsetHeight||1);var a=q(t)?D(t):window,l=a.visualViewport,s=!je()&&o,c=(n.left+(s&&l?l.offsetLeft:0))/i,p=(n.top+(s&&l?l.offsetTop:0))/r,m=n.width/i,v=n.height/r;return{width:m,height:v,top:p,right:c+m,bottom:p+v,left:c,x:c,y:p}}function he(t){var e=z(t),o=t.offsetWidth,n=t.offsetHeight;return Math.abs(e.width-o)<=1&&(o=e.width),Math.abs(e.height-n)<=1&&(n=e.height),{x:t.offsetLeft,y:t.offsetTop,width:o,height:n}}function Ye(t,e){var o=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(o&&De(o)){var n=e;do{if(n&&t.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}function j(t){return D(t).getComputedStyle(t)}function Mt(t){return["table","td","th"].indexOf(V(t))>=0}function _(t){return((q(t)?t.ownerDocument:t.document)||window.document).documentElement}function ne(t){return V(t)==="html"?t:t.assignedSlot||t.parentNode||(De(t)?t.host:null)||_(t)}function Ao(t){return!R(t)||j(t).position==="fixed"?null:t.offsetParent}function Yn(t){var e=/firefox/i.test(Se()),o=/Trident/i.test(Se());if(o&&R(t)){var n=j(t);if(n.position==="fixed")return null}var i=ne(t);for(De(i)&&(i=i.host);R(i)&&["html","body"].indexOf(V(i))<0;){var r=j(i);if(r.transform!=="none"||r.perspective!=="none"||r.contain==="paint"||["transform","perspective"].indexOf(r.willChange)!==-1||e&&r.willChange==="filter"||e&&r.filter&&r.filter!=="none")return i;i=i.parentNode}return null}function J(t){for(var e=D(t),o=Ao(t);o&&Mt(o)&&j(o).position==="static";)o=Ao(o);return o&&(V(o)==="html"||V(o)==="body"&&j(o).position==="static")?e:o||Yn(t)||e}function ve(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function we(t,e,o){return X(t,ge(e,o))}function Lo(t,e,o){var n=we(t,e,o);return n>o?o:n}function $e(){return{top:0,right:0,bottom:0,left:0}}function Ue(t){return Object.assign({},$e(),t)}function qe(t,e){return e.reduce(function(o,n){return o[n]=t,o},{})}var $n=function(e,o){return e=typeof e=="function"?e(Object.assign({},o.rects,{placement:o.placement})):e,Ue(typeof e!="number"?e:qe(e,re))};function Un(t){var e,o=t.state,n=t.name,i=t.options,r=o.elements.arrow,a=o.modifiersData.popperOffsets,l=I(o.placement),s=ve(l),c=[M,A].indexOf(l)>=0,p=c?"height":"width";if(!(!r||!a)){var m=$n(i.padding,o),v=he(r),d=s==="y"?k:M,w=s==="y"?H:A,f=o.rects.reference[p]+o.rects.reference[s]-a[s]-o.rects.popper[p],u=a[s]-o.rects.reference[s],g=J(r),P=g?s==="y"?g.clientHeight||0:g.clientWidth||0:0,E=f/2-u/2,y=m[d],b=P-v[p]-m[w],x=P/2-v[p]/2+E,S=we(y,x,b),L=s;o.modifiersData[n]=(e={},e[L]=S,e.centerOffset=S-x,e)}}function qn(t){var e=t.state,o=t.options,n=o.element,i=n===void 0?"[data-popper-arrow]":n;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||Ye(e.elements.popper,i)&&(e.elements.arrow=i))}var Co={name:"arrow",enabled:!0,phase:"main",fn:Un,effect:qn,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function K(t){return t.split("-")[1]}var zn={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Kn(t,e){var o=t.x,n=t.y,i=e.devicePixelRatio||1;return{x:oe(o*i)/i||0,y:oe(n*i)/i||0}}function Fo(t){var e,o=t.popper,n=t.popperRect,i=t.placement,r=t.variation,a=t.offsets,l=t.position,s=t.gpuAcceleration,c=t.adaptive,p=t.roundOffsets,m=t.isFixed,v=a.x,d=v===void 0?0:v,w=a.y,f=w===void 0?0:w,u=typeof p=="function"?p({x:d,y:f}):{x:d,y:f};d=u.x,f=u.y;var g=a.hasOwnProperty("x"),P=a.hasOwnProperty("y"),E=M,y=k,b=window;if(c){var x=J(o),S="clientHeight",L="clientWidth";if(x===D(o)&&(x=_(o),j(x).position!=="static"&&l==="absolute"&&(S="scrollHeight",L="scrollWidth")),x=x,i===k||(i===M||i===A)&&r===fe){y=H;var C=m&&x===b&&b.visualViewport?b.visualViewport.height:x[S];f-=C-n.height,f*=s?1:-1}if(i===M||(i===k||i===H)&&r===fe){E=A;var F=m&&x===b&&b.visualViewport?b.visualViewport.width:x[L];d-=F-n.width,d*=s?1:-1}}var N=Object.assign({position:l},c&&zn),$=p===!0?Kn({x:d,y:f},D(o)):{x:d,y:f};if(d=$.x,f=$.y,s){var B;return Object.assign({},N,(B={},B[y]=P?"0":"",B[E]=g?"0":"",B.transform=(b.devicePixelRatio||1)<=1?"translate("+d+"px, "+f+"px)":"translate3d("+d+"px, "+f+"px, 0)",B))}return Object.assign({},N,(e={},e[y]=P?f+"px":"",e[E]=g?d+"px":"",e.transform="",e))}function Gn(t){var e=t.state,o=t.options,n=o.gpuAcceleration,i=n===void 0?!0:n,r=o.adaptive,a=r===void 0?!0:r,l=o.roundOffsets,s=l===void 0?!0:l;if(!1)var c;var p={placement:I(e.placement),variation:K(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Fo(Object.assign({},p,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:s})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Fo(Object.assign({},p,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:s})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}var Ho={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Gn,data:{}};var st={passive:!0};function Qn(t){var e=t.state,o=t.instance,n=t.options,i=n.scroll,r=i===void 0?!0:i,a=n.resize,l=a===void 0?!0:a,s=D(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return r&&c.forEach(function(p){p.addEventListener("scroll",o.update,st)}),l&&s.addEventListener("resize",o.update,st),function(){r&&c.forEach(function(p){p.removeEventListener("scroll",o.update,st)}),l&&s.removeEventListener("resize",o.update,st)}}var Ro={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Qn,data:{}};var Xn={left:"right",right:"left",bottom:"top",top:"bottom"};function Te(t){return t.replace(/left|right|bottom|top/g,function(e){return Xn[e]})}var Jn={start:"end",end:"start"};function lt(t){return t.replace(/start|end/g,function(e){return Jn[e]})}function ye(t){var e=D(t),o=e.pageXOffset,n=e.pageYOffset;return{scrollLeft:o,scrollTop:n}}function be(t){return z(_(t)).left+ye(t).scrollLeft}function At(t,e){var o=D(t),n=_(t),i=o.visualViewport,r=n.clientWidth,a=n.clientHeight,l=0,s=0;if(i){r=i.width,a=i.height;var c=je();(c||!c&&e==="fixed")&&(l=i.offsetLeft,s=i.offsetTop)}return{width:r,height:a,x:l+be(t),y:s}}function Lt(t){var e,o=_(t),n=ye(t),i=(e=t.ownerDocument)==null?void 0:e.body,r=X(o.scrollWidth,o.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),a=X(o.scrollHeight,o.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),l=-n.scrollLeft+be(t),s=-n.scrollTop;return j(i||o).direction==="rtl"&&(l+=X(o.clientWidth,i?i.clientWidth:0)-r),{width:r,height:a,x:l,y:s}}function xe(t){var e=j(t),o=e.overflow,n=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(o+i+n)}function pt(t){return["html","body","#document"].indexOf(V(t))>=0?t.ownerDocument.body:R(t)&&xe(t)?t:pt(ne(t))}function ae(t,e){var o;e===void 0&&(e=[]);var n=pt(t),i=n===((o=t.ownerDocument)==null?void 0:o.body),r=D(n),a=i?[r].concat(r.visualViewport||[],xe(n)?n:[]):n,l=e.concat(a);return i?l:l.concat(ae(ne(a)))}function ke(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Zn(t,e){var o=z(t,!1,e==="fixed");return o.top=o.top+t.clientTop,o.left=o.left+t.clientLeft,o.bottom=o.top+t.clientHeight,o.right=o.left+t.clientWidth,o.width=t.clientWidth,o.height=t.clientHeight,o.x=o.left,o.y=o.top,o}function Vo(t,e,o){return e===rt?ke(At(t,o)):q(e)?Zn(e,o):ke(Lt(_(t)))}function ei(t){var e=ae(ne(t)),o=["absolute","fixed"].indexOf(j(t).position)>=0,n=o&&R(t)?J(t):t;return q(n)?e.filter(function(i){return q(i)&&Ye(i,n)&&V(i)!=="body"}):[]}function Ct(t,e,o,n){var i=e==="clippingParents"?ei(t):[].concat(e),r=[].concat(i,[o]),a=r[0],l=r.reduce(function(s,c){var p=Vo(t,c,n);return s.top=X(p.top,s.top),s.right=ge(p.right,s.right),s.bottom=ge(p.bottom,s.bottom),s.left=X(p.left,s.left),s},Vo(t,a,n));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function ze(t){var e=t.reference,o=t.element,n=t.placement,i=n?I(n):null,r=n?K(n):null,a=e.x+e.width/2-o.width/2,l=e.y+e.height/2-o.height/2,s;switch(i){case k:s={x:a,y:e.y-o.height};break;case H:s={x:a,y:e.y+e.height};break;case A:s={x:e.x+e.width,y:l};break;case M:s={x:e.x-o.width,y:l};break;default:s={x:e.x,y:e.y}}var c=i?ve(i):null;if(c!=null){var p=c==="y"?"height":"width";switch(r){case te:s[c]=s[c]-(e[p]/2-o[p]/2);break;case fe:s[c]=s[c]+(e[p]/2-o[p]/2);break;default:}}return s}function Z(t,e){e===void 0&&(e={});var o=e,n=o.placement,i=n===void 0?t.placement:n,r=o.strategy,a=r===void 0?t.strategy:r,l=o.boundary,s=l===void 0?So:l,c=o.rootBoundary,p=c===void 0?rt:c,m=o.elementContext,v=m===void 0?Oe:m,d=o.altBoundary,w=d===void 0?!1:d,f=o.padding,u=f===void 0?0:f,g=Ue(typeof u!="number"?u:qe(u,re)),P=v===Oe?To:Oe,E=t.rects.popper,y=t.elements[w?P:v],b=Ct(q(y)?y:y.contextElement||_(t.elements.popper),s,p,a),x=z(t.elements.reference),S=ze({reference:x,element:E,strategy:"absolute",placement:i}),L=ke(Object.assign({},E,S)),C=v===Oe?L:x,F={top:b.top-C.top+g.top,bottom:C.bottom-b.bottom+g.bottom,left:b.left-C.left+g.left,right:C.right-b.right+g.right},N=t.modifiersData.offset;if(v===Oe&&N){var $=N[i];Object.keys(F).forEach(function(B){var le=[A,H].indexOf(B)>=0?1:-1,pe=[k,H].indexOf(B)>=0?"y":"x";F[B]+=$[pe]*le})}return F}function Ft(t,e){e===void 0&&(e={});var o=e,n=o.placement,i=o.boundary,r=o.rootBoundary,a=o.padding,l=o.flipVariations,s=o.allowedAutoPlacements,c=s===void 0?at:s,p=K(n),m=p?l?kt:kt.filter(function(w){return K(w)===p}):re,v=m.filter(function(w){return c.indexOf(w)>=0});v.length===0&&(v=m);var d=v.reduce(function(w,f){return w[f]=Z(t,{placement:f,boundary:i,rootBoundary:r,padding:a})[I(f)],w},{});return Object.keys(d).sort(function(w,f){return d[w]-d[f]})}function ti(t){if(I(t)===it)return[];var e=Te(t);return[lt(t),e,lt(e)]}function oi(t){var e=t.state,o=t.options,n=t.name;if(!e.modifiersData[n]._skip){for(var i=o.mainAxis,r=i===void 0?!0:i,a=o.altAxis,l=a===void 0?!0:a,s=o.fallbackPlacements,c=o.padding,p=o.boundary,m=o.rootBoundary,v=o.altBoundary,d=o.flipVariations,w=d===void 0?!0:d,f=o.allowedAutoPlacements,u=e.options.placement,g=I(u),P=g===u,E=s||(P||!w?[Te(u)]:ti(u)),y=[u].concat(E).reduce(function(Pe,ie){return Pe.concat(I(ie)===it?Ft(e,{placement:ie,boundary:p,rootBoundary:m,padding:c,flipVariations:w,allowedAutoPlacements:f}):ie)},[]),b=e.rects.reference,x=e.rects.popper,S=new Map,L=!0,C=y[0],F=0;F<y.length;F++){var N=y[F],$=I(N),B=K(N)===te,le=[k,H].indexOf($)>=0,pe=le?"width":"height",U=Z(e,{placement:N,boundary:p,rootBoundary:m,altBoundary:v,padding:c}),G=le?B?A:M:B?H:k;b[pe]>x[pe]&&(G=Te(G));var Ge=Te(G),ce=[];if(r&&ce.push(U[$]<=0),l&&ce.push(U[G]<=0,U[Ge]<=0),ce.every(function(Pe){return Pe})){C=N,L=!1;break}S.set(N,ce)}if(L)for(var Qe=w?3:1,gt=function(ie){var Le=y.find(function(Je){var de=S.get(Je);if(de)return de.slice(0,ie).every(function(ht){return ht})});if(Le)return C=Le,"break"},Ae=Qe;Ae>0;Ae--){var Xe=gt(Ae);if(Xe==="break")break}e.placement!==C&&(e.modifiersData[n]._skip=!0,e.placement=C,e.reset=!0)}}var Io={name:"flip",enabled:!0,phase:"main",fn:oi,requiresIfExists:["offset"],data:{_skip:!1}};function Wo(t,e,o){return o===void 0&&(o={x:0,y:0}),{top:t.top-e.height-o.y,right:t.right-e.width+o.x,bottom:t.bottom-e.height+o.y,left:t.left-e.width-o.x}}function _o(t){return[k,A,H,M].some(function(e){return t[e]>=0})}function ni(t){var e=t.state,o=t.name,n=e.rects.reference,i=e.rects.popper,r=e.modifiersData.preventOverflow,a=Z(e,{elementContext:"reference"}),l=Z(e,{altBoundary:!0}),s=Wo(a,n),c=Wo(l,i,r),p=_o(s),m=_o(c);e.modifiersData[o]={referenceClippingOffsets:s,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:m},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":m})}var Bo={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:ni};function ii(t,e,o){var n=I(t),i=[M,k].indexOf(n)>=0?-1:1,r=typeof o=="function"?o(Object.assign({},e,{placement:t})):o,a=r[0],l=r[1];return a=a||0,l=(l||0)*i,[M,A].indexOf(n)>=0?{x:l,y:a}:{x:a,y:l}}function ri(t){var e=t.state,o=t.options,n=t.name,i=o.offset,r=i===void 0?[0,0]:i,a=at.reduce(function(p,m){return p[m]=ii(m,e.rects,r),p},{}),l=a[e.placement],s=l.x,c=l.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=s,e.modifiersData.popperOffsets.y+=c),e.modifiersData[n]=a}var jo={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:ri};function ai(t){var e=t.state,o=t.name;e.modifiersData[o]=ze({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}var Yo={name:"popperOffsets",enabled:!0,phase:"read",fn:ai,data:{}};function Ht(t){return t==="x"?"y":"x"}function si(t){var e=t.state,o=t.options,n=t.name,i=o.mainAxis,r=i===void 0?!0:i,a=o.altAxis,l=a===void 0?!1:a,s=o.boundary,c=o.rootBoundary,p=o.altBoundary,m=o.padding,v=o.tether,d=v===void 0?!0:v,w=o.tetherOffset,f=w===void 0?0:w,u=Z(e,{boundary:s,rootBoundary:c,padding:m,altBoundary:p}),g=I(e.placement),P=K(e.placement),E=!P,y=ve(g),b=Ht(y),x=e.modifiersData.popperOffsets,S=e.rects.reference,L=e.rects.popper,C=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,F=typeof C=="number"?{mainAxis:C,altAxis:C}:Object.assign({mainAxis:0,altAxis:0},C),N=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,$={x:0,y:0};if(x){if(r){var B,le=y==="y"?k:M,pe=y==="y"?H:A,U=y==="y"?"height":"width",G=x[y],Ge=G+u[le],ce=G-u[pe],Qe=d?-L[U]/2:0,gt=P===te?S[U]:L[U],Ae=P===te?-L[U]:-S[U],Xe=e.elements.arrow,Pe=d&&Xe?he(Xe):{width:0,height:0},ie=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:$e(),Le=ie[le],Je=ie[pe],de=we(0,S[U],Pe[U]),ht=E?S[U]/2-Qe-de-Le-F.mainAxis:gt-de-Le-F.mainAxis,Go=E?-S[U]/2+Qe+de+Je+F.mainAxis:Ae+de+Je+F.mainAxis,vt=e.elements.arrow&&J(e.elements.arrow),Qo=vt?y==="y"?vt.clientTop||0:vt.clientLeft||0:0,qt=(B=N?.[y])!=null?B:0,Xo=G+ht-qt-Qo,Jo=G+Go-qt,zt=we(d?ge(Ge,Xo):Ge,G,d?X(ce,Jo):ce);x[y]=zt,$[y]=zt-G}if(l){var Kt,Zo=y==="x"?k:M,en=y==="x"?H:A,ue=x[b],Ze=b==="y"?"height":"width",Gt=ue+u[Zo],Qt=ue-u[en],wt=[k,M].indexOf(g)!==-1,Xt=(Kt=N?.[b])!=null?Kt:0,Jt=wt?Gt:ue-S[Ze]-L[Ze]-Xt+F.altAxis,Zt=wt?ue+S[Ze]+L[Ze]-Xt-F.altAxis:Qt,eo=d&&wt?Lo(Jt,ue,Zt):we(d?Jt:Gt,ue,d?Zt:Qt);x[b]=eo,$[b]=eo-ue}e.modifiersData[n]=$}}var $o={name:"preventOverflow",enabled:!0,phase:"main",fn:si,requiresIfExists:["offset"]};function Rt(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Vt(t){return t===D(t)||!R(t)?ye(t):Rt(t)}function li(t){var e=t.getBoundingClientRect(),o=oe(e.width)/t.offsetWidth||1,n=oe(e.height)/t.offsetHeight||1;return o!==1||n!==1}function It(t,e,o){o===void 0&&(o=!1);var n=R(e),i=R(e)&&li(e),r=_(e),a=z(t,i,o),l={scrollLeft:0,scrollTop:0},s={x:0,y:0};return(n||!n&&!o)&&((V(e)!=="body"||xe(r))&&(l=Vt(e)),R(e)?(s=z(e,!0),s.x+=e.clientLeft,s.y+=e.clientTop):r&&(s.x=be(r))),{x:a.left+l.scrollLeft-s.x,y:a.top+l.scrollTop-s.y,width:a.width,height:a.height}}function pi(t){var e=new Map,o=new Set,n=[];t.forEach(function(r){e.set(r.name,r)});function i(r){o.add(r.name);var a=[].concat(r.requires||[],r.requiresIfExists||[]);a.forEach(function(l){if(!o.has(l)){var s=e.get(l);s&&i(s)}}),n.push(r)}return t.forEach(function(r){o.has(r.name)||i(r)}),n}function Wt(t){var e=pi(t);return ko.reduce(function(o,n){return o.concat(e.filter(function(i){return i.phase===n}))},[])}function _t(t){var e;return function(){return e||(e=new Promise(function(o){Promise.resolve().then(function(){e=void 0,o(t())})})),e}}function Bt(t){var e=t.reduce(function(o,n){var i=o[n.name];return o[n.name]=i?Object.assign({},i,n,{options:Object.assign({},i.options,n.options),data:Object.assign({},i.data,n.data)}):n,o},{});return Object.keys(e).map(function(o){return e[o]})}var Uo={placement:"bottom",modifiers:[],strategy:"absolute"};function qo(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];return!e.some(function(n){return!(n&&typeof n.getBoundingClientRect=="function")})}function zo(t){t===void 0&&(t={});var e=t,o=e.defaultModifiers,n=o===void 0?[]:o,i=e.defaultOptions,r=i===void 0?Uo:i;return function(l,s,c){c===void 0&&(c=r);var p={placement:"bottom",orderedModifiers:[],options:Object.assign({},Uo,r),modifiersData:{},elements:{reference:l,popper:s},attributes:{},styles:{}},m=[],v=!1,d={state:p,setOptions:function(g){var P=typeof g=="function"?g(p.options):g;f(),p.options=Object.assign({},r,p.options,P),p.scrollParents={reference:q(l)?ae(l):l.contextElement?ae(l.contextElement):[],popper:ae(s)};var E=Wt(Bt([].concat(n,p.options.modifiers)));if(p.orderedModifiers=E.filter(function(N){return N.enabled}),!1){var y;if(getBasePlacement(p.options.placement)===auto)var b;var x,S,L,C,F}return w(),d.update()},forceUpdate:function(){if(!v){var g=p.elements,P=g.reference,E=g.popper;if(qo(P,E)){p.rects={reference:It(P,J(E),p.options.strategy==="fixed"),popper:he(E)},p.reset=!1,p.placement=p.options.placement,p.orderedModifiers.forEach(function(N){return p.modifiersData[N.name]=Object.assign({},N.data)});for(var y=0,b=0;b<p.orderedModifiers.length;b++){if(p.reset===!0){p.reset=!1,b=-1;continue}var x=p.orderedModifiers[b],S=x.fn,L=x.options,C=L===void 0?{}:L,F=x.name;typeof S=="function"&&(p=S({state:p,options:C,name:F,instance:d})||p)}}}},update:_t(function(){return new Promise(function(u){d.forceUpdate(),u(p)})}),destroy:function(){f(),v=!0}};if(!qo(l,s))return d;d.setOptions(c).then(function(u){!v&&c.onFirstUpdate&&c.onFirstUpdate(u)});function w(){p.orderedModifiers.forEach(function(u){var g=u.name,P=u.options,E=P===void 0?{}:P,y=u.effect;if(typeof y=="function"){var b=y({state:p,name:g,instance:d,options:E}),x=function(){};m.push(b||x)}})}function f(){m.forEach(function(u){return u()}),m=[]}return d}}var ci=[Ro,Yo,Ho,Mo,jo,Io,$o,Co,Bo],jt=zo({defaultModifiers:ci});var Yt=class{constructor(e,o,n){this.owner=e,this.containerEl=o,o.on("click",".suggestion-item",this.onSuggestionClick.bind(this)),o.on("mousemove",".suggestion-item",this.onSuggestionMouseover.bind(this)),n.register([],"ArrowUp",i=>{if(!i.isComposing)return this.setSelectedItem(this.selectedItem-1,!0),!1}),n.register([],"ArrowDown",i=>{if(!i.isComposing)return this.setSelectedItem(this.selectedItem+1,!0),!1}),n.register([],"Enter",i=>{if(!i.isComposing)return this.useSelectedItem(i),!1})}onSuggestionClick(e,o){e.preventDefault();let n=this.suggestions.indexOf(o);this.setSelectedItem(n,!1),this.useSelectedItem(e)}onSuggestionMouseover(e,o){let n=this.suggestions.indexOf(o);this.setSelectedItem(n,!1)}setSuggestions(e){this.containerEl.empty();let o=[];e.forEach(n=>{let i=this.containerEl.createDiv("suggestion-item");this.owner.renderSuggestion(n,i),o.push(i)}),this.values=e,this.suggestions=o,this.setSelectedItem(0,!1)}useSelectedItem(e){let o=this.values[this.selectedItem];o&&this.owner.selectSuggestion(o,e)}setSelectedItem(e,o){let n=io(e,this.suggestions.length),i=this.suggestions[this.selectedItem],r=this.suggestions[n];i?.removeClass("is-selected"),r?.addClass("is-selected"),this.selectedItem=n,o&&r.scrollIntoView(!1)}},Ke=class{constructor(e,o){this.app=e,this.inputEl=o,this.scope=new Ko.Scope,this.suggestEl=createDiv("suggestion-container");let n=this.suggestEl.createDiv("suggestion");this.suggest=new Yt(this,n,this.scope),this.scope.register([],"Escape",this.close.bind(this)),this.inputEl.addEventListener("input",this.onInputChanged.bind(this)),this.inputEl.addEventListener("focus",this.onInputChanged.bind(this)),this.inputEl.addEventListener("blur",this.close.bind(this)),this.suggestEl.on("mousedown",".suggestion-container",i=>{i.preventDefault()})}onInputChanged(){let e=this.inputEl.value,o=this.getSuggestions(e);o.length>0&&(this.suggest.setSuggestions(o),this.open(this.app.dom.appContainerEl,this.inputEl))}open(e,o){this.app.keymap.pushScope(this.scope),e.appendChild(this.suggestEl),this.popper=jt(o,this.suggestEl,{placement:"bottom-start",modifiers:[{name:"sameWidth",enabled:!0,fn:({state:n,instance:i})=>{let r=`${n.rects.reference.width+100}px`;n.styles.popper.width!==r&&(n.styles.popper.width=r,i.update())},phase:"beforeWrite",requires:["computeStyles"]}]})}close(){this.app.keymap.popScope(this.scope),this.suggest.setSuggestions([]),this.popper&&this.popper.destroy(),this.suggestEl.detach()}};var ct=class extends Ke{getSuggestions(e){let o=this.app.vault.getAllLoadedFiles(),n=[],i=e.toLowerCase();return o.forEach(r=>{r instanceof Me.TFile&&["md","canvas"].contains(r.extension)&&r.path.toLowerCase().contains(i)&&n.push(r)}),n}renderSuggestion(e,o){e.extension=="md"?o.setText(ee(e)):(o.setText(e.path.slice(0,-7)),o.insertAdjacentHTML("beforeend",'<div class="nav-file-tag" style="display:inline-block;vertical-align:middle">canvas</div>'))}selectSuggestion(e){this.inputEl.value=ee(e),this.inputEl.trigger("input"),this.close()}},dt=class extends Ke{getSuggestions(e){let o=Object.keys(this.app.internalPlugins.plugins.workspaces?.instance.workspaces),n=e.toLowerCase();return o.filter(i=>i.toLowerCase().contains(n))}renderSuggestion(e,o){o.setText(e)}selectSuggestion(e){this.inputEl.value=e,this.inputEl.trigger("input"),this.close()}},ut=class extends Me.FuzzySuggestModal{constructor(o){super(o.plugin.app);this.homepage=o.plugin.homepage,this.tab=o}getItems(){return Object.values(this.app.commands.commands)}getItemText(o){return o.name}onChooseItem(o){if(o.id==="homepage:open-homepage"){new Me.Notice("Really?");return}else this.homepage.data.commands||(this.homepage.data.commands=[]);this.homepage.data.commands.push(o.id),this.homepage.save(),this.tab.updateCommandBox()}};var Ut={version:3,homepages:{[me]:{value:"Home",kind:"File",openOnStartup:!0,openMode:"Replace all open notes",manualOpenMode:"Keep open notes",view:"Default view",revertView:!0,openWhenEmpty:!1,refreshDataview:!1,autoCreate:!0,autoScroll:!1,pin:!1,commands:[],alwaysApply:!1}},separateMobile:!1},$t=Ut.homepages[me],di=["Random file","Graph view","Nothing",...St],mt=class extends W.PluginSettingTab{constructor(o,n){super(o,n);this.plugin=n,this.settings=n.settings}sanitiseNote(o){return o===null||o.match(/^\s*$/)!==null?null:(0,W.normalizePath)(o)}display(){let o=this.plugin.homepage.data.kind=="Workspace",n=this.plugin.homepage.data.kind,i=tt(this.plugin),r=!1,a=document.createElement("article"),l=o?dt:ct;this.containerEl.empty(),this.elements={},a.id="nv-desc";let s=new W.Setting(this.containerEl).setName("Homepage").addDropdown(async c=>{for(let p of Object.values(_e)){if(!this.plugin.hasRequiredPlugin(p))if(p==this.plugin.homepage.data.kind)r=!0;else continue;let m=p;p=="Date-dependent file"&&(m="Moment (legacy)"),c.addOption(p,m)}c.setValue(this.plugin.homepage.data.kind),c.onChange(async p=>{this.plugin.homepage.data.kind=p,await this.plugin.homepage.save(),this.display()})});switch(s.settingEl.id="nv-main-setting",s.settingEl.append(a),n){case"File":a.innerHTML="Enter a note or canvas to use.";break;case"Workspace":a.innerHTML="Enter an Obsidian workspace to use.";break;case"Graph view":a.innerHTML="Your graph view will be used.";break;case"Nothing":a.innerHTML="Nothing will occur by default. Any commands added will still take effect.";break;case"Date-dependent file":a.innerHTML=`<span class="mod-warning">This type is deprecated and will eventually be removed. Use Daily/Weekly/Monthly/Yearly Note instead, which works natively with Daily and Periodic Notes.</span><br>
Enter a note or canvas to use based on <a href="https://momentjs.com/docs/#/displaying/format/" target="_blank" rel="noopener">Moment date formatting</a>.<small> Surround words in <code>[brackets]</code> to include them unmodified.
<br> Currently, your specification will produce: </small>`;break;case"Random file":a.innerHTML="A random note or canvas from your Obsidian folder will be selected.";break;case"Daily Note":a.innerHTML="Your Daily Note or Periodic Daily Note will be used.";break;case"Weekly Note":case"Monthly Note":case"Yearly Note":a.innerHTML=`Your Periodic ${this.plugin.homepage.data.kind} will be used.`;break}if(r&&a.createDiv({text:"The plugin required for this homepage type isn't available.",attr:{class:"mod-warning"}}),n=="Date-dependent file"){let c=a.lastChild.createEl("b",{attr:{class:"u-pop"}});s.addMomentFormat(p=>p.setDefaultFormat("YYYY-MM-DD").setValue(this.plugin.homepage.data.value).onChange(async m=>{this.plugin.homepage.data.value=m,await this.plugin.homepage.save()}).setSampleEl(c))}else di.includes(n)?s.addText(c=>{c.setDisabled(!0)}):s.addText(c=>{new l(this.app,c.inputEl),c.setPlaceholder($t.value),c.setValue($t.value==this.plugin.homepage.data.value?"":this.plugin.homepage.data.value),c.onChange(async p=>{this.plugin.homepage.data.value=this.sanitiseNote(p)||$t.value,await this.plugin.homepage.save()})});this.addToggle("Open on startup","When launching Obsidian, open the homepage.","openOnStartup",c=>this.display()),i&&(this.elements.openOnStartup.descEl.createDiv({text:`This setting has been disabled, as it isn't compatible with Daily Notes' "Open daily note on startup" functionality. To use it, disable the Daily Notes setting.`,attr:{class:"mod-warning"}}),this.disableSetting("openOnStartup")),this.addToggle("Open when empty","When there are no tabs open, open the homepage.","openWhenEmpty"),this.addToggle("Use when opening normally","Use homepage settings when opening it normally, such as from a link or the file browser.","alwaysApply"),new W.Setting(this.containerEl).setName("Separate mobile homepage").setDesc("For mobile devices, store the homepage and its settings separately.").addToggle(c=>c.setValue(this.plugin.settings.separateMobile).onChange(async p=>{this.plugin.settings.separateMobile=p,this.plugin.homepage=this.plugin.getHomepage(),await this.plugin.saveSettings(),this.display()})),this.addHeading("Commands","commandsHeading"),this.containerEl.createDiv({cls:"nv-command-desc setting-item-description",text:"Select commands that will be executed when opening the homepage."}),this.commandBox=this.containerEl.createDiv({cls:"nv-command-box"}),this.updateCommandBox(),this.addHeading("Vault environment","vaultHeading"),this.addDropdown("Opening method","Determine how extant tabs and views are affected on startup.","openMode",nt),this.addDropdown("Manual opening method","Determine how extant tabs and views are affected when opening with commands or the ribbon button.","manualOpenMode",nt),this.addToggle("Auto-create","If the homepage doesn't exist, create a note with the specified name.","autoCreate"),this.addToggle("Pin","Pin the homepage when opening.","pin"),this.addHeading("Opened view","paneHeading"),this.addDropdown("Homepage view","Choose what view to open the homepage in.","view",Tt),this.addToggle("Revert view on close","When navigating away from the homepage, restore the default view.","revertView"),this.addToggle("Auto-scroll","When opening the homepage, scroll to the bottom and focus on the last line.","autoScroll"),"dataview"in this.plugin.communityPlugins&&(this.addToggle("Refresh Dataview","Always attempt to reload Dataview views when opening the homepage.","refreshDataview"),this.elements.refreshDataview.descEl.createDiv({text:"Requires Dataview auto-refresh to be enabled.",attr:{class:"mod-warning"}})),W.Platform.isMobile||new W.ButtonComponent(this.containerEl).setButtonText("Copy debug info").setClass("nv-debug-button").onClick(async()=>await this.copyDebugInfo()),(o||n==="Nothing")&&this.disableSettings("openWhenEmpty","alwaysApply","vaultHeading","openMode","manualOpenMode","autoCreate","pin"),(o||["Nothing","Graph view"].includes(n))&&this.disableSettings("paneHeading","view","revertView","autoScroll","refreshDataview"),(!this.plugin.homepage.data.openOnStartup||i)&&this.disableSetting("openMode"),St.includes(this.plugin.homepage.data.kind)&&this.disableSetting("autoCreate")}disableSetting(o){this.elements[o]?.settingEl.setAttribute("nv-greyed","")}disableSettings(...o){o.forEach(n=>this.disableSetting(n))}addHeading(o,n){let i=new W.Setting(this.containerEl).setHeading().setName(o);this.elements[n]=i}addDropdown(o,n,i,r,a){let l=new W.Setting(this.containerEl).setName(o).setDesc(n).addDropdown(async s=>{for(let c of Object.values(r))s.addOption(c,c);s.setValue(this.plugin.homepage.data[i]),s.onChange(async c=>{this.plugin.homepage.data[i]=c,await this.plugin.homepage.save(),a&&a(c)})});this.elements[i]=l}addToggle(o,n,i,r){let a=new W.Setting(this.containerEl).setName(o).setDesc(n).addToggle(l=>l.setValue(this.plugin.homepage.data[i]).onChange(async s=>{this.plugin.homepage.data[i]=s,await this.plugin.homepage.save(),r&&r(s)}));this.elements[i]=a}updateCommandBox(){this.commandBox.innerHTML="";for(let[o,n]of this.plugin.homepage.data.commands.entries()){let i=this.app.commands.findCommand(n);if(!i)continue;let r=this.commandBox.createDiv({cls:"nv-command-pill",text:i.name});new W.ButtonComponent(r).setIcon("trash-2").setClass("clickable-icon").onClick(()=>{this.plugin.homepage.data.commands.splice(o,1),this.plugin.homepage.save(),this.updateCommandBox()})}new W.ButtonComponent(this.commandBox).setClass("nv-command-add-button").setButtonText("Add...").onClick(()=>{new ut(this).open()})}async copyDebugInfo(){let o=this.app.vault.config,n={...this.settings,_defaultViewMode:o.defaultViewMode||"default",_livePreview:o.livePreview!==void 0?o.livePreview:"default",_focusNewTab:o.focusNewTab!==void 0?o.focusNewTab:"default",_plugins:Object.keys(this.plugin.communityPlugins),_internalPlugins:Object.values(this.plugin.internalPlugins).flatMap(i=>i.enabled?[i.instance.id]:[]),_obsidianVersion:window.electron.ipcRenderer.sendSync("version")};await navigator.clipboard.writeText(JSON.stringify(n)),new W.Notice("Copied homepage debug information to clipboard")}};var ui='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5"><path d="M10.025 21H6v-7H3v-1.5L12 3l9 9.5V14h-3v7h-4v-7h-3.975v7Z" style="fill:none;stroke:currentColor;stroke-width:2px"/></svg>',ft=class extends se.Plugin{constructor(){super(...arguments);this.loaded=!1;this.executing=!1;this.onLayoutChange=async()=>{this.homepage.data.revertView&&await this.homepage.revertView(),this.homepage.data.openWhenEmpty&&await this.homepage.openWhenEmpty(),this.homepage.data.alwaysApply&&await this.homepage.apply()}}async onload(){let o=document.body.querySelector(".progress-bar")!==null;this.settings=await this.loadSettings(),this.internalPlugins=this.app.internalPlugins.plugins,this.communityPlugins=this.app.plugins.plugins,this.homepage=this.getHomepage(),this.app.workspace.onLayoutReady(async()=>{let n=this.communityPlugins["new-tab-default-page"],i=this.homepage.data.openOnStartup&&o&&!this.hasUrlParams();n&&(n._checkForNewTab=n.checkForNewTab,n.checkForNewTab=async r=>{if(!(this&&this.executing))return await n._checkForNewTab(r)}),i&&await this.homepage.open(),this.loaded=!0}),(0,se.addIcon)("homepage",ui),this.addRibbonIcon("homepage","Open homepage",n=>this.homepage.open(n.button==1||n.button==2||se.Keymap.isModifier(n,"Mod"))).setAttribute("id","nv-homepage-icon"),this.registerEvent(this.app.workspace.on("layout-change",this.onLayoutChange)),this.addSettingTab(new mt(this.app,this)),this.addCommand({id:"open-homepage",name:"Open homepage",callback:()=>this.homepage.open()}),console.log(`Homepage: ${this.homepage.data.value} (method: ${this.homepage.data.openMode}, view: ${this.homepage.data.view}, kind: ${this.homepage.data.kind})`)}async onunload(){this.app.workspace.off("layout-change",this.onLayoutChange);let o=this.communityPlugins["new-tab-default-page"];o&&(o.checkForNewTab=o._checkForNewTab)}getHomepage(){return this.settings.separateMobile&&se.Platform.isMobile?(ot in this.settings.homepages||(this.settings.homepages[ot]={...this.settings.homepages[me]}),new Be(ot,this)):new Be(me,this)}async loadSettings(){let o=await this.loadData();if(!o||o.version!==2)return Object.assign({},Ut,o);{let n={version:3,homepages:{},separateMobile:!1},i=o;return o.workspaceEnabled?(i.value=i.workspace,i.kind="Workspace"):o.useMoment?(i.value=i.momentFormat,i.kind="Date-dependent file"):(i.value=i.defaultNote,i.kind="File"),i.commands=[],delete i.workspace,delete i.momentFormat,delete i.defaultNote,delete i.useMoment,delete i.workspaceEnabled,n.homepages[me]=i,n}}async saveSettings(){await this.saveData(this.settings)}hasUrlParams(){let o=window.OBS_ACT;return o&&["open","advanced-uri"].includes(o?.action)&&("file"in o||"filepath"in o||"workspace"in o)}hasRequiredPlugin(o){switch(o){case"Workspace":return this.internalPlugins.workspaces?.enabled;case"Graph view":return this.internalPlugins.graph?.enabled;case"Daily Note":case"Weekly Note":case"Monthly Note":case"Yearly Note":return No(o,this);default:return!0}}};