diff --git a/main.js b/main.js index 617a987..7c98a2c 100644 --- a/main.js +++ b/main.js @@ -10781,7 +10781,10 @@ var tooltipPlugin = import_view.ViewPlugin.fromClass( return tv.getCoords ? tv.getCoords(t4.pos) : this.view.coordsAtPos(t4.pos); }), size: this.manager.tooltipViews.map( - ({ dom }) => dom.getBoundingClientRect() + ({ dom }) => { + const size = dom.getBoundingClientRect(); + return size; + } ), space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view) }; @@ -10817,12 +10820,41 @@ var tooltipPlugin = import_view.ViewPlugin.fromClass( if (r3.left < right && r3.right > left && r3.top < top + height && r3.bottom > top) top = above ? r3.top - height - 2 - arrowHeight : r3.bottom + arrowHeight + 2; } + const computeFrameOffset = (win, rect) => { + const { top: top2, right: right2, bottom, left: left2, width: width2, height: height2, x: x5, y: y5 } = rect; + const dims = { top: top2, right: right2, bottom, left: left2 }; + if (typeof dims === "undefined") { + const dims2 = { top: 0, left: 0 }; + } + const frames = win.parent.document.getElementsByTagName("iframe"); + let frame; + let found = false; + for (let i5 = 0, len = frames.length; i5 < len; i5++) { + frame = frames[i5]; + if (frame.contentWindow == win) { + found = true; + break; + } + } + if (found) { + const rect2 = frame.getBoundingClientRect(); + dims.left += rect2.left; + dims.top += rect2.top; + if (win !== top2) { + computeFrameOffset(win.parent, rect2); + } + } else { + return { top: 0, left: 0 }; + } + return dims; + }; + const viewCoords = computeFrameOffset(this.view.dom.ownerDocument.defaultView, editor); if (this.position == "absolute") { - dom.style.top = top - measured.parent.top + "px"; - dom.style.left = left - measured.parent.left + "px"; + dom.style.top = viewCoords.top + top - measured.parent.top + "px"; + dom.style.left = viewCoords.left + left - measured.parent.left + "px"; } else { - dom.style.top = top + "px"; - dom.style.left = left + "px"; + dom.style.top = viewCoords.top + top + "px"; + dom.style.left = viewCoords.left + left + "px"; } if (arrow) arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`; @@ -12228,18 +12260,21 @@ var T4 = class { reloadSpaces: "Reload Spaces", loadBackupSpace: "Restore Spaces from Backup", backupSpace: "Backup Space", - blink: "Flow Search", + blink: "Blink", openFileContext: "Open Context Explorer", + convertFolderNote: "Convert to Folder Note", revealFile: "Reveal File in Spaces", toggleBacklinks: "Toggle Backlinks", collapseAllFolders: "Collapse All Folders", - addFileSpace: "Add File to Space" + addFileSpace: "Add File to Space", + removeFileSpace: "Remove File from Space" }, menu: { fileMetadata: "File Metadata", fileMetadataDescription: "This note only", openFilePane: "Open in a new pane", rename: "Rename", + changeToFolderNote: "Convert to Folder Note", moveFile: "Move file to...", duplicate: "Make a copy", edit: "Edit", @@ -12324,9 +12359,10 @@ var T4 = class { addTag: "Add Tag", tag: "Tag", syncFields: "Sync Properties", + convertTable: "Convert to Markdown", cutTable: "Cut Table", deleteTable: "Delete Table", - blink: "Flow Search", + blink: "Blink", addFile: "Add File", merge: "Merge", saveView: "Save View", @@ -12346,7 +12382,9 @@ var T4 = class { anyOf: "is any of", noneOf: "is none of", checked: "is checked", - unchecked: "is unchecked" + unchecked: "is unchecked", + isEmpty: "is empty", + isNotEmpty: "is not empty" }, sortTypes: { alphaAsc: "A to Z", @@ -12482,6 +12520,10 @@ var T4 = class { sectionAppearance: "Appearance", sectionContext: "Context", sectionSync: "Sync and Backup", + inlineStickerMenu: { + name: "Inline Stickers", + desc: "Add inline stickers by typing :" + }, defaultDateFormat: { name: "Default Date Format", desc: "Set the default date format (ISO 8601)" @@ -12989,17 +13031,26 @@ var markIconSet = { // src/components/FlowEditor/FlowEditorHover.tsx var FlowEditorHover = (props2) => { - return props2.type == "file" ? /* @__PURE__ */ Cn.createElement(Cn.Fragment, null, props2.toggle && /* @__PURE__ */ Cn.createElement("div", { + return /* @__PURE__ */ Cn.createElement("div", { + className: "mk-flowblock-menu" + }, props2.type == "file" ? /* @__PURE__ */ Cn.createElement(Cn.Fragment, null, props2.toggle && /* @__PURE__ */ Cn.createElement("div", { "aria-label": i18n_default.buttons.toggleFlow, onClick: props2.toggleFlow, className: `mk-hover-button ${props2.toggleState ? "mk-toggle-on" : ""}`, - dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-flow-hover"] } + dangerouslySetInnerHTML: { + __html: uiIconSet["mk-ui-flow-hover"] + } }), /* @__PURE__ */ Cn.createElement("div", { "aria-label": i18n_default.buttons.openLink, onClick: props2.openLink, className: "mk-hover-button", dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-open-link"] } })) : /* @__PURE__ */ Cn.createElement(Cn.Fragment, null, /* @__PURE__ */ Cn.createElement("div", { + "aria-label": i18n_default.buttons.convertTable, + onClick: props2.convertTable, + className: "mk-icon-xsmall mk-hover-button", + dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-sync"] } + }), /* @__PURE__ */ Cn.createElement("div", { "aria-label": i18n_default.buttons.cutTable, onClick: props2.cutTable, className: "mk-icon-xsmall mk-hover-button", @@ -13009,7 +13060,7 @@ var FlowEditorHover = (props2) => { onClick: props2.deleteTable, className: "mk-icon-xsmall mk-hover-button", dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-close"] } - })); + })), " "); }; // src/types/types.ts @@ -13033,44 +13084,44 @@ var eventTypes = { // src/dispatch/flowDispatch.ts var createFlowEditorInElement = (id2, el, type, file, ref, from, to) => { - let evt = new CustomEvent(eventTypes.spawnPortal, { + const evt = new CustomEvent(eventTypes.spawnPortal, { detail: { id: id2, el, file, from, to, ref, type } }); activeWindow.dispatchEvent(evt); }; var loadFlowEditorByDOM = (el, view, id2) => { - let evt = new CustomEvent(eventTypes.loadPortal, { + const evt = new CustomEvent(eventTypes.loadPortal, { detail: { id: id2, el, view } }); activeWindow.dispatchEvent(evt); }; var focusFlowEditor = (id2, top) => { - let evt = new CustomEvent(eventTypes.focusPortal, { + const evt = new CustomEvent(eventTypes.focusPortal, { detail: { id: id2, parent: false, top } }); activeWindow.dispatchEvent(evt); }; var focusFlowEditorParent = (id2, top) => { - let evt = new CustomEvent(eventTypes.focusPortal, { + const evt = new CustomEvent(eventTypes.focusPortal, { detail: { id: id2, parent: true, top } }); activeWindow.dispatchEvent(evt); }; var openFileFlowEditor = (file, source) => { - let evt = new CustomEvent(eventTypes.openFilePortal, { + const evt = new CustomEvent(eventTypes.openFilePortal, { detail: { file, source } }); activeWindow.dispatchEvent(evt); }; -// src/utils/tree.ts -var import_obsidian38 = require("obsidian"); - -// src/components/ContextView/ContextView.tsx -var import_obsidian34 = require("obsidian"); +// src/cm-extensions/flowEditor/flowEditor.tsx +var import_obsidian39 = require("obsidian"); // src/utils/array.ts -var insert = (arr, index, newItem) => [ +var insert = (arr, index, newItem) => index <= 0 ? [ + newItem, + ...arr +] : [ ...arr.slice(0, index), newItem, ...arr.slice(index) @@ -13110,8 +13161,8 @@ var serializeSQLValues = (value) => value.join(", "); var serializeSQLStatements = (value) => value.join("; "); var serializeSQLFieldNames = (value) => value.join(","); -// src/utils/metadata/tags.ts -var import_obsidian2 = require("obsidian"); +// src/components/ContextView/ContextView.tsx +var import_obsidian35 = require("obsidian"); // src/utils/strings.ts var stickerFromString = (sticker) => { @@ -13177,1412 +13228,2158 @@ var contextDisplayName = (context) => { var folderNotePathFromAFile = (settings, aFile) => !aFile ? null : settings.folderNoteInsideFolder ? `${aFile.path}/${aFile.name}.md` : aFile.parent == "/" ? `${aFile.name}.md` : `${aFile.parent}/${aFile.name}.md`; var folderPathFromFolderNoteFile = (settings, aFile) => !aFile ? null : settings.folderNoteInsideFolder ? aFile.parent : aFile.parent == "/" ? aFile.name : `${aFile.parent}/${aFile.name}`; -// src/utils/sanitize.ts -var sanitizeTableName = (name) => { - return name == null ? void 0 : name.replace(/[^a-z0-9+]+/gi, ""); -}; -var sanitizeColumnName = (name) => { - if ((name == null ? void 0 : name.charAt(0)) == "_") { - return sanitizeColumnName(name.substring(1)); - } - return name == null ? void 0 : name.replace(/"/g, ``); -}; -var sanitizeSQLStatement = (name) => { - return name == null ? void 0 : name.replace(/'/g, `''`); -}; - -// src/types/context.ts -var FilePropertyName = "File"; - -// src/utils/contexts/parsers.ts -var parsePropString = (str) => { - var _a2; - const [p1, p22] = (_a2 = str == null ? void 0 : str.match(/(\\.|[^.])+/g)) != null ? _a2 : []; - if (p22) - return { - field: p1, - property: p22 - }; - return { field: "File", property: p1 }; -}; - -// src/schemas/mdb.ts -var fieldTypeForType = (type) => fieldTypes.find((t4) => type == t4.type) || fieldTypes.find((t4) => type == t4.multiType); -var fieldTypes = [ - { - type: "unknown", - label: "", - restricted: true - }, - { - type: "preview", - label: i18n_default.properties.preview.label, - restricted: true - }, - { - type: "text", - label: i18n_default.properties.text.label, - metadata: true, - icon: "mk-make-h3" - }, - { - type: "number", - label: i18n_default.properties.number.label, - metadata: true, - icon: "mk-make-tag" - }, - { - type: "boolean", - label: i18n_default.properties.boolean.label, - metadata: true, - icon: "mk-make-todo" - }, - { - type: "date", - label: i18n_default.properties.date.label, - metadata: true, - icon: "mk-make-date" - }, - { - type: "option", - label: i18n_default.properties.option.label, - multi: true, - multiType: "option-multi", - icon: "mk-make-list" - }, - { - type: "file", - label: i18n_default.properties.file.label, - restricted: true, - icon: "mk-make-h3" - }, - { - type: "fileprop", - label: i18n_default.properties.fileProperty.label - }, - { - type: "link", - label: i18n_default.properties.link.label, - multi: true, - multiType: "link-multi", - metadata: true, - icon: "mk-make-note" - }, - { - type: "context", - label: i18n_default.properties.context.label, - multi: true, - multiType: "context-multi", - icon: "mk-make-note" - }, - { - type: "object", - label: i18n_default.properties.context.label, - restricted: true, - metadata: true - }, - { - type: "image", - label: i18n_default.properties.image.label, - multi: true, - multiType: "image-multi", - metadata: true, - icon: "mk-make-image" - } -]; -var defaultValueForPropertyType = (name, value, type) => { - if (type == "preview") { - return "https://images.unsplash.com/photo-1675789652575-0a5d2425b6c2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80"; +// src/components/ui/modals/imageModal.tsx +var import_obsidian = require("obsidian"); +var imageModal = class extends import_obsidian.FuzzySuggestModal { + constructor(plugin, app2, selectImage) { + super(app2); + this.plugin = plugin; + this.selectImage = selectImage; + this.resultContainerEl.toggleClass("mk-image-modal", true); + this.inputEl.focus(); + this.inputEl.placeholder = "Select an image or paste a URL"; + this.emptyStateText = "No Images Found"; + this.limit = 30; } - if (type == "fileprop") { - const { field, property } = parsePropString(value); - if (property == "ctime" || property == "mtime") - return (Date.now() - 60).toString(); - return value; + renderSuggestion(item, el) { + var oImg = el.createEl("img"); + const file = getAbstractFileAtPath(app, item.item); + oImg.setAttribute( + "src", + file ? app.vault.getResourcePath(file) : item.item + ); + oImg.setAttribute("height", "100px"); + oImg.setAttribute("width", "100px"); + el.appendChild(oImg); } - if (type == "file") { - return "Note Name"; + getItemText(item) { + return item; } - if (type == "date") { - return "2020-04-21"; + getSuggestions(query) { + let allImages = []; + if (query.match(urlRegex)) + allImages.push(query); + allImages.push( + ...getAllAbstractFilesInVault(this.plugin, app).filter( + (f4) => f4 instanceof import_obsidian.TFile && ["png", "jpg", "jpeg"].contains(f4.extension) + ).map((f4) => f4.path) + ); + return allImages.filter((f4) => f4.contains(query)).map((f4, i4) => ({ + item: f4, + match: { + score: i4, + matches: [] + } + })); } - if (type == "number") { - return "123"; + getItems() { + let allImages = []; + allImages.push( + ...getAllAbstractFilesInVault(this.plugin, app).filter( + (f4) => f4 instanceof import_obsidian.TFile && ["png", "jpg", "jpeg"].contains(f4.extension) + ).map((f4) => f4.path) + ); + return allImages; } - if (type == "boolean") { - return "true"; + onChooseItem(item, evt) { + this.selectImage(item); } - if (type == "link") { - return "[[Select Note]]"; +}; + +// src/hooks/useLongPress.tsx +function isMouseEvent(e4) { + return e4 && "screenX" in e4; +} + +// src/components/FileContextView/NoteBannerView.tsx +var import_obsidian4 = require("obsidian"); + +// src/types/space.ts +var FMBannerKey = "banner"; +var FMStickerKey = "sticker"; +var FMColorKey = "color"; +var FMMetadataKeys = [FMBannerKey, FMStickerKey, FMColorKey]; + +// node_modules/date-fns/esm/_lib/toInteger/index.js +function toInteger(dirtyNumber) { + if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) { + return NaN; } - if (type == "option") { - return "one, two"; + var number = Number(dirtyNumber); + if (isNaN(number)) { + return number; } - if (type == "text") { - return name; + return number < 0 ? Math.ceil(number) : Math.floor(number); +} + +// node_modules/date-fns/esm/_lib/requiredArgs/index.js +function requiredArgs(required, args) { + if (args.length < required) { + throw new TypeError(required + " argument" + (required > 1 ? "s" : "") + " required, but only " + args.length + " present"); } - if (type == "image") { - return "https://images.unsplash.com/photo-1675789652575-0a5d2425b6c2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80"; +} + +// node_modules/date-fns/esm/toDate/index.js +function _typeof(obj) { + "@babel/helpers - typeof"; + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function _typeof5(obj2) { + return typeof obj2; + }; + } else { + _typeof = function _typeof5(obj2) { + return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; + }; } - return ""; -}; -var defaultFileDBSchema = { - id: "files", - name: "Files", - type: "db", - primary: "true" -}; -var defaultFileListSchema = { - id: "filesView", - name: "Files", - type: "list", - def: "files" -}; -var defaultFileTableSchema = { - id: "filesView", - name: "Files", - type: "table", - def: "files" -}; -var defaultFolderSchema = { - uniques: [], - cols: ["id", "name", "type", "def", "predicate", "primary"], - rows: [defaultFileDBSchema, defaultFileListSchema] -}; -var defaultTagSchema = { - uniques: [], - cols: ["id", "name", "type", "def", "predicate", "primary"], - rows: [defaultFileDBSchema, defaultFileTableSchema] -}; -var fieldSchema = { - uniques: ["name,schemaId"], - cols: [ - "name", - "schemaId", - "type", - "value", - "attrs", - "hidden", - "unique", - "primary" - ] -}; -var defaultFolderFields = { - ...fieldSchema, - rows: [ - { - name: i18n_default.properties.preview.label, - schemaId: "files", - type: "preview", - hidden: "", - unique: "", - attrs: "", - value: "", - primary: "" - }, - { - name: FilePropertyName, - schemaId: "files", - type: "file", - primary: "true", - hidden: "", - unique: "", - attrs: "", - value: "" - }, - { - name: i18n_default.properties.fileProperty.createdTime, - schemaId: "files", - type: "fileprop", - value: "File.ctime", - hidden: "", - unique: "", - attrs: "", - primary: "" + return _typeof(obj); +} +function toDate(argument) { + requiredArgs(1, arguments); + var argStr = Object.prototype.toString.call(argument); + if (argument instanceof Date || _typeof(argument) === "object" && argStr === "[object Date]") { + return new Date(argument.getTime()); + } else if (typeof argument === "number" || argStr === "[object Number]") { + return new Date(argument); + } else { + if ((typeof argument === "string" || argStr === "[object String]") && typeof console !== "undefined") { + console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"); + console.warn(new Error().stack); } - ] -}; -var defaultFieldsForContext = (context) => { - if (context.type == "tag") { - return defaultTagFields; - } else if (context.type == "folder") { - return defaultFolderFields; - } - return defaultFolderFields; -}; -var defaultTableFields = [ - { - name: i18n_default.properties.defaultField, - schemaId: "", - type: "text" + return new Date(NaN); } -]; -var defaultTagFields = { - ...fieldSchema, - rows: [ - { - name: FilePropertyName, - schemaId: "files", - type: "file", - primary: "true", - hidden: "", - unique: "", - attrs: "", - value: "" - } - ] -}; -var defaultMDBTableForContext = (context) => { - if (context.type == "tag") { - return defaultTagMDBTable; - } else if (context.type == "folder") { - return defaultFolderMDBTable; +} + +// node_modules/date-fns/esm/addDays/index.js +function addDays(dirtyDate, dirtyAmount) { + requiredArgs(2, arguments); + var date = toDate(dirtyDate); + var amount = toInteger(dirtyAmount); + if (isNaN(amount)) { + return new Date(NaN); } - return defaultFolderMDBTable; -}; -var defaultFolderMDBTable = { - schema: defaultFileDBSchema, - cols: defaultFolderFields.rows, - rows: [] -}; -var defaultQueryMDBTable = { - schema: defaultFileDBSchema, - cols: defaultFolderFields.rows, - rows: [] -}; -var defaultTagMDBTable = { - schema: defaultFileDBSchema, - cols: defaultTagFields.rows, - rows: [] -}; -var fieldsToTable = (fields, schemas) => { - return fields.filter((s5) => schemas.find((g4) => g4.id == s5.schemaId && g4.type == "db")).reduce((p3, c4) => { - return { - ...p3, - ...p3[c4.schemaId] ? { - [c4.schemaId]: { - uniques: c4.unique == "true" ? [...p3[c4.schemaId].uniques, c4.name] : p3[c4.schemaId].uniques, - cols: [...p3[c4.schemaId].cols, c4.name], - rows: [] - } - } : { - [c4.schemaId]: { - uniques: c4.unique == "true" ? [c4.name] : [], - cols: [c4.name], - rows: [] - } - } - }; - }, {}); -}; -var defaultTablesForContext = (context) => { - if (context.type == "tag") { - return defaultTagTables; - } else if (context.type == "folder") { - return defaultFolderTables; + if (!amount) { + return date; } - return defaultFolderTables; -}; -var defaultFolderTables = { - m_schema: defaultFolderSchema, - m_fields: defaultFolderFields, - ...fieldsToTable( - defaultFolderFields.rows, - defaultFolderSchema.rows - ) -}; -var defaultTagTables = { - m_schema: defaultTagSchema, - m_fields: defaultTagFields, - ...fieldsToTable( - defaultTagFields.rows, - defaultTagSchema.rows - ) -}; + date.setDate(date.getDate() + amount); + return date; +} -// src/utils/db/db.ts -var import_obsidian = require("obsidian"); -var getDBFile = async (path, isRemote) => { - if (isRemote) { - return fetch(path).then((res) => res.arrayBuffer()); +// node_modules/date-fns/esm/addMonths/index.js +function addMonths(dirtyDate, dirtyAmount) { + requiredArgs(2, arguments); + var date = toDate(dirtyDate); + var amount = toInteger(dirtyAmount); + if (isNaN(amount)) { + return new Date(NaN); } - if (!await app.vault.adapter.exists((0, import_obsidian.normalizePath)(path))) { - return null; + if (!amount) { + return date; } - const file = await app.vault.adapter.readBinary( - (0, import_obsidian.normalizePath)(path) - ); - return file; -}; -var getDB = async (sqlJS, path, isRemote) => { - const buf = await getDBFile(path, isRemote); - if (buf) { - return new sqlJS.Database(new Uint8Array(buf)); + var dayOfMonth = date.getDate(); + var endOfDesiredMonth = new Date(date.getTime()); + endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0); + var daysInMonth = endOfDesiredMonth.getDate(); + if (dayOfMonth >= daysInMonth) { + return endOfDesiredMonth; + } else { + date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth); + return date; } - return new sqlJS.Database(); -}; -var saveDBFile = async (path, binary) => { - const file = app.vault.adapter.writeBinary( - (0, import_obsidian.normalizePath)(path), - binary - ); - return file; -}; -var dbResultsToDBTables = (res) => { - return res.reduce( - (p3, c4, i4) => [ - ...p3, - { - cols: c4.columns, - rows: c4 ? c4.values.map( - (r3) => c4.columns.reduce( - (prev, curr, index) => ({ ...prev, [curr]: r3[index] }), - {} - ) - ) : [] - } - ], - [] - ); -}; -var selectDB = (db, table, condition, fields) => { - const fieldsStr = fields != null ? fields : "*"; - const sqlstr = condition ? `SELECT ${fieldsStr} FROM "${table}" WHERE ${condition};` : `SELECT ${fieldsStr} FROM ${table};`; - let tables; - try { - tables = dbResultsToDBTables(db.exec(sqlstr)); - } catch (e4) { - return null; - } - if (tables.length == 1) - return tables[0]; - return null; -}; -var deleteFromDB = (db, table, condition) => { - const sqlstr = `DELETE FROM "${table}" WHERE ${condition};`; - try { - db.exec(sqlstr); - } catch (e4) { - console.log(e4); - } -}; -var dropTable = (db, table) => { - const sqlstr = `DROP TABLE IF EXISTS "${table}";`; - try { - db.exec(sqlstr); - } catch (e4) { - console.log(e4); - } -}; -var replaceDB = (db, tables) => { - const sqlstr = serializeSQLStatements(Object.keys(tables).map((t4) => { - const tableFields = tables[t4].cols; - const fieldQuery = serializeSQLFieldNames(uniq(tableFields).map((f4) => `'${sanitizeSQLStatement(f4)}' char`)); - const rowsQuery = tables[t4].rows.reduce((prev, curr) => { - return `${prev} REPLACE INTO "${t4}" VALUES (${serializeSQLValues(tableFields.map((c4) => { - var _a2; - return `'${(_a2 = sanitizeSQLStatement(curr == null ? void 0 : curr[c4])) != null ? _a2 : ""}'`; - }))});`; - }, ""); - const idxQuery = tables[t4].uniques.filter((f4) => f4).reduce((p3, c4) => { - return `${p3} CREATE UNIQUE INDEX IF NOT EXISTS idx_${t4}_${c4.replace( - /,/g, - "_" - )} ON ${t4}(${c4});`; - }, ""); - const insertQuery = `CREATE TABLE IF NOT EXISTS "${t4}" (${fieldQuery}); ${idxQuery} BEGIN TRANSACTION; ${rowsQuery} COMMIT;`; - return `DROP INDEX IF EXISTS idx_${t4}__id; DROP TABLE IF EXISTS "${t4}"; ${fieldQuery.length > 0 ? insertQuery : ""}`; - })); - try { - db.exec(sqlstr); - } catch (e4) { - console.log(e4); - } -}; -var saveDBToPath = async (plugin, path, tables) => { - const sqlJS = await plugin.sqlJS(); - let db = await getDB(sqlJS, path); - if (!db) { - db.close(); - return false; - } - replaceDB(db, tables); - await saveDBFile(path, db.export().buffer); - db.close(); - return true; -}; +} -// src/utils/json.ts -var safelyParseJSON = (json) => { - var parsed; - try { - parsed = JSON.parse(json); - } catch (e4) { - } - return parsed; -}; +// node_modules/date-fns/esm/addMilliseconds/index.js +function addMilliseconds(dirtyDate, dirtyAmount) { + requiredArgs(2, arguments); + var timestamp = toDate(dirtyDate).getTime(); + var amount = toInteger(dirtyAmount); + return new Date(timestamp + amount); +} -// src/utils/parser.tsx -var parseSortStrat = (str) => { - const [a5, b4] = str.split("_"); - return [a5, b4 == "asc"]; -}; -var parseMultiString = (str) => { - var _a2; - return (_a2 = str == null ? void 0 : str.match(/(\\.|[^,])+/g)) != null ? _a2 : []; -}; -var parseLinkString = (string) => { - if (!string) - return ""; - const match2 = /\[\[(.*?)\]\]/g.exec(string); - const stringValue = (match2 == null ? void 0 : match2.length) > 1 ? match2[1].substring(0, indexOfCharElseEOS("|", match2[1])) : string; - if (stringValue) - return stringValue; - return string; -}; -var parseLinkDisplayString = (string) => { - return filePathToString(parseLinkString(string)); -}; -var parseContextDefString = (str) => { - var _a2; - if (!str || str.length == 0) - return []; - if (str.charAt(0) == "#") { - return str.split("&").map((f4) => ({ - type: "tag", - value: f4 - })); - } - return (_a2 = safelyParseJSON(str)) != null ? _a2 : []; -}; -var parseSpace = (spaceRow) => { - return { - ...spaceRow, - def: parseSpaceDefString(spaceRow.def) - }; -}; -var parseSpaceDefString = (str) => { - var _a2; - if (!str || str.length == 0) - return { type: "focus", folder: "", filters: [] }; - if (str.charAt(0) != "{") { - return { - folder: str, - type: "focus", - filters: [ - { - type: "any", - trueFalse: true, - filters: [ - { - type: "filemeta", - fType: "string", - field: "folder", - fn: "equals", - value: str - } - ] - } - ] - }; - } - return (_a2 = safelyParseJSON(str)) != null ? _a2 : []; -}; +// node_modules/date-fns/esm/_lib/defaultOptions/index.js +var defaultOptions = {}; +function getDefaultOptions() { + return defaultOptions; +} -// src/utils/contexts/mdb.ts -var dbTableToMDBTable = (table, schema, fields) => { - var _a2; - return { - schema, - cols: fields, - rows: (_a2 = table == null ? void 0 : table.rows) != null ? _a2 : [] - }; -}; -var updateFieldsToSchema = (fields, context) => { - const defaultFields = defaultFieldsForContext(context); - return [ - ...fields, - ...defaultFields.rows.filter( - (f4) => !fields.some((g4) => g4.name == f4.name && g4.schemaId == f4.schemaId) - ) - ]; -}; -var getMDBTable = async (plugin, context, table) => { - if (!context) - return null; - const sqlJS = await plugin.sqlJS(); - const buf = await getDBFile(context.dbPath, context.isRemote); - if (!buf) { - return null; +// node_modules/date-fns/esm/startOfWeek/index.js +function startOfWeek(dirtyDate, options) { + var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; + requiredArgs(1, arguments); + var defaultOptions3 = getDefaultOptions(); + var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError("weekStartsOn must be between 0 and 6 inclusively"); } - const db = new sqlJS.Database(new Uint8Array(buf)); - await sanitizeTableSchema(plugin, db, context); - let fieldsTables; - let schema; - try { - fieldsTables = dbResultsToDBTables( - db.exec(`SELECT * FROM m_fields WHERE schemaId = '${table}'`) - ); - schema = dbResultsToDBTables( - db.exec(`SELECT * FROM m_schema WHERE id = '${table}'`) - )[0].rows[0]; - } catch (e4) { - db.close(); - return null; + var date = toDate(dirtyDate); + var day = date.getDay(); + var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; + date.setDate(date.getDate() - diff); + date.setHours(0, 0, 0, 0); + return date; +} + +// node_modules/date-fns/esm/startOfISOWeek/index.js +function startOfISOWeek(dirtyDate) { + requiredArgs(1, arguments); + return startOfWeek(dirtyDate, { + weekStartsOn: 1 + }); +} + +// node_modules/date-fns/esm/getISOWeekYear/index.js +function getISOWeekYear(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var year = date.getFullYear(); + var fourthOfJanuaryOfNextYear = new Date(0); + fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); + fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); + var startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); + var fourthOfJanuaryOfThisYear = new Date(0); + fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); + fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); + var startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); + if (date.getTime() >= startOfNextYear.getTime()) { + return year + 1; + } else if (date.getTime() >= startOfThisYear.getTime()) { + return year; + } else { + return year - 1; } - if (fieldsTables.length == 0) { - db.close(); - return { - schema, - cols: [], - rows: [] +} + +// node_modules/date-fns/esm/startOfISOWeekYear/index.js +function startOfISOWeekYear(dirtyDate) { + requiredArgs(1, arguments); + var year = getISOWeekYear(dirtyDate); + var fourthOfJanuary = new Date(0); + fourthOfJanuary.setFullYear(year, 0, 4); + fourthOfJanuary.setHours(0, 0, 0, 0); + var date = startOfISOWeek(fourthOfJanuary); + return date; +} + +// node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js +function getTimezoneOffsetInMilliseconds(date) { + var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds())); + utcDate.setUTCFullYear(date.getFullYear()); + return date.getTime() - utcDate.getTime(); +} + +// node_modules/date-fns/esm/startOfDay/index.js +function startOfDay(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + date.setHours(0, 0, 0, 0); + return date; +} + +// node_modules/date-fns/esm/differenceInCalendarDays/index.js +var MILLISECONDS_IN_DAY = 864e5; +function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) { + requiredArgs(2, arguments); + var startOfDayLeft = startOfDay(dirtyDateLeft); + var startOfDayRight = startOfDay(dirtyDateRight); + var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft); + var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight); + return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY); +} + +// node_modules/date-fns/esm/addWeeks/index.js +function addWeeks(dirtyDate, dirtyAmount) { + requiredArgs(2, arguments); + var amount = toInteger(dirtyAmount); + var days = amount * 7; + return addDays(dirtyDate, days); +} + +// node_modules/date-fns/esm/addYears/index.js +function addYears(dirtyDate, dirtyAmount) { + requiredArgs(2, arguments); + var amount = toInteger(dirtyAmount); + return addMonths(dirtyDate, amount * 12); +} + +// node_modules/date-fns/esm/max/index.js +function _typeof2(obj) { + "@babel/helpers - typeof"; + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof2 = function _typeof5(obj2) { + return typeof obj2; + }; + } else { + _typeof2 = function _typeof5(obj2) { + return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; }; } - const fields = fieldsTables[0].rows.filter( - (f4) => f4.name.length > 0 - ); - const dbTable = dbResultsToDBTables( - db.exec( - `SELECT ${serializeSQLFieldNames( - fields.reduce((p3, c4) => [...p3, `"${c4.name}"`], []) - )} FROM "${table}"` - ) - ); - db.close(); - return dbTableToMDBTable( - dbTable[0], - schema, - schema.primary ? updateFieldsToSchema(fields, context) : fields - ); -}; -var deleteMDBTable = async (plugin, context, table) => { - if (context.readOnly) - return false; - const sqlJS = await plugin.sqlJS(); - const buf = await getDBFile(context.dbPath, context.isRemote); - if (!buf) { - return false; - } - const db = new sqlJS.Database(new Uint8Array(buf)); - deleteFromDB(db, "m_schema", `id = '${sanitizeSQLStatement(table)}'`); - deleteFromDB(db, "m_schema", `def = '${sanitizeSQLStatement(table)}'`); - deleteFromDB(db, "m_fields", `schemaId = '${sanitizeSQLStatement(table)}'`); - dropTable(db, table); - await saveDBFile(context.dbPath, db.export().buffer); - db.close(); - return true; -}; -var getMDBTableSchemas = async (plugin, context) => { - const sqlJS = await plugin.sqlJS(); - const buf = await getDBFile(context.dbPath, context.isRemote); - if (!buf) { - return null; + return _typeof2(obj); +} +function max(dirtyDatesArray) { + requiredArgs(1, arguments); + var datesArray; + if (dirtyDatesArray && typeof dirtyDatesArray.forEach === "function") { + datesArray = dirtyDatesArray; + } else if (_typeof2(dirtyDatesArray) === "object" && dirtyDatesArray !== null) { + datesArray = Array.prototype.slice.call(dirtyDatesArray); + } else { + return new Date(NaN); } - const db = new sqlJS.Database(new Uint8Array(buf)); - await sanitizeTableSchema(plugin, db, context); - const tables = db.exec(`SELECT * FROM m_schema`); - db.close(); - return tables[0].values.map((f4) => { - const [id2, name, type, def, predicate, primary] = f4; - return { id: id2, name, type, def, predicate, primary }; + var result; + datesArray.forEach(function(dirtyDate) { + var currentDate = toDate(dirtyDate); + if (result === void 0 || result < currentDate || isNaN(Number(currentDate))) { + result = currentDate; + } }); -}; -var saveMDBToPath = async (plugin, context, mdb) => { - var _a2, _b2; - if (context.readOnly) - return; - const sqlJS = await plugin.sqlJS(); - const buf = await getDBFile(context.dbPath, context.isRemote); - if (!buf) { - return null; + return result || new Date(NaN); +} + +// node_modules/date-fns/esm/min/index.js +function _typeof3(obj) { + "@babel/helpers - typeof"; + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof3 = function _typeof5(obj2) { + return typeof obj2; + }; + } else { + _typeof3 = function _typeof5(obj2) { + return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; + }; } - const db = new sqlJS.Database(new Uint8Array(buf)); - const fieldsTables = dbResultsToDBTables( - db.exec(`SELECT * FROM m_fields WHERE schemaId != '${mdb.schema.id}'`) - ); - const tables = { - m_fields: { - uniques: fieldSchema.uniques, - cols: fieldSchema.cols, - rows: [...(_b2 = (_a2 = fieldsTables[0]) == null ? void 0 : _a2.rows) != null ? _b2 : [], ...mdb.cols] - }, - [mdb.schema.id]: { - uniques: [], - cols: mdb.cols.map((c4) => c4.name), - rows: mdb.rows + return _typeof3(obj); +} +function min(dirtyDatesArray) { + requiredArgs(1, arguments); + var datesArray; + if (dirtyDatesArray && typeof dirtyDatesArray.forEach === "function") { + datesArray = dirtyDatesArray; + } else if (_typeof3(dirtyDatesArray) === "object" && dirtyDatesArray !== null) { + datesArray = Array.prototype.slice.call(dirtyDatesArray); + } else { + return new Date(NaN); + } + var result; + datesArray.forEach(function(dirtyDate) { + var currentDate = toDate(dirtyDate); + if (result === void 0 || result > currentDate || isNaN(currentDate.getDate())) { + result = currentDate; } - }; - db.close(); - return saveDBToPath(plugin, context.dbPath, tables); -}; -var optionValuesForColumn = (column, table) => { - var _a2; - return uniq( - (_a2 = table == null ? void 0 : table.rows.reduce((p3, c4) => { - return [...p3, ...parseMultiString(c4[column])]; - }, [])) != null ? _a2 : [] - ); -}; -var createDefaultDB = async (plugin, context) => { - const sqlJS = await plugin.sqlJS(); - const table = defaultTablesForContext(context); - return saveDBToPath(plugin, context.dbPath, table); -}; -var sanitizeTableSchema = async (plugin, db, context) => { - const sqlJS = await plugin.sqlJS(); - const tableRes = db.exec( - `SELECT name FROM sqlite_master WHERE type='table';` - ); - if (!tableRes[0] || !tableRes[0].values.some((f4) => f4[0] == "m_schema") || !tableRes[0].values.some((f4) => f4[0] == "m_fields") || !tableRes[0].values.some((f4) => f4[0] == "files")) { - await createDefaultDB(plugin, context); + }); + return result || new Date(NaN); +} + +// node_modules/date-fns/esm/compareAsc/index.js +function compareAsc(dirtyDateLeft, dirtyDateRight) { + requiredArgs(2, arguments); + var dateLeft = toDate(dirtyDateLeft); + var dateRight = toDate(dirtyDateRight); + var diff = dateLeft.getTime() - dateRight.getTime(); + if (diff < 0) { + return -1; + } else if (diff > 0) { + return 1; + } else { + return diff; } -}; -var createNewRow = (mdb, row, index) => { - if (index) { - return { - ...mdb, - rows: insert(mdb.rows, index, row) +} + +// node_modules/date-fns/esm/isSameDay/index.js +function isSameDay(dirtyDateLeft, dirtyDateRight) { + requiredArgs(2, arguments); + var dateLeftStartOfDay = startOfDay(dirtyDateLeft); + var dateRightStartOfDay = startOfDay(dirtyDateRight); + return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime(); +} + +// node_modules/date-fns/esm/isDate/index.js +function _typeof4(obj) { + "@babel/helpers - typeof"; + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof4 = function _typeof5(obj2) { + return typeof obj2; + }; + } else { + _typeof4 = function _typeof5(obj2) { + return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; }; } - return { - ...mdb, - rows: [...mdb.rows, row] - }; -}; -var deleteTagContext = async (plugin, tag) => { - const context = tagContextFromTag(plugin, tag); - if (getAbstractFileAtPath(app, context.dbPath)) { - await deleteFile(plugin, getAbstractFileAtPath(app, context.dbPath)); + return _typeof4(obj); +} +function isDate(value) { + requiredArgs(1, arguments); + return value instanceof Date || _typeof4(value) === "object" && Object.prototype.toString.call(value) === "[object Date]"; +} + +// node_modules/date-fns/esm/isValid/index.js +function isValid(dirtyDate) { + requiredArgs(1, arguments); + if (!isDate(dirtyDate) && typeof dirtyDate !== "number") { + return false; } - app.workspace.iterateLeaves((leaf) => { - if (leaf.view.getViewType() == CONTEXT_VIEW_TYPE && leaf.view.getState().contextPath == tag) { - leaf.setViewState({ type: "empty" }); - } - }, app.workspace["rootSplit"]); - plugin.index.deleteTag(tag); -}; -var deleteSpaceContext = async (plugin, space) => { - const context = spaceContextFromSpace(plugin, spaceContextPathFromName(space)); - if (getAbstractFileAtPath(app, context.dbPath)) { - await deleteFile(plugin, getAbstractFileAtPath(app, context.dbPath)); + var date = toDate(dirtyDate); + return !isNaN(Number(date)); +} + +// node_modules/date-fns/esm/differenceInCalendarMonths/index.js +function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) { + requiredArgs(2, arguments); + var dateLeft = toDate(dirtyDateLeft); + var dateRight = toDate(dirtyDateRight); + var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear(); + var monthDiff = dateLeft.getMonth() - dateRight.getMonth(); + return yearDiff * 12 + monthDiff; +} + +// node_modules/date-fns/esm/differenceInCalendarWeeks/index.js +var MILLISECONDS_IN_WEEK = 6048e5; +function differenceInCalendarWeeks(dirtyDateLeft, dirtyDateRight, options) { + requiredArgs(2, arguments); + var startOfWeekLeft = startOfWeek(dirtyDateLeft, options); + var startOfWeekRight = startOfWeek(dirtyDateRight, options); + var timestampLeft = startOfWeekLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfWeekLeft); + var timestampRight = startOfWeekRight.getTime() - getTimezoneOffsetInMilliseconds(startOfWeekRight); + return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_WEEK); +} + +// node_modules/date-fns/esm/differenceInMilliseconds/index.js +function differenceInMilliseconds(dateLeft, dateRight) { + requiredArgs(2, arguments); + return toDate(dateLeft).getTime() - toDate(dateRight).getTime(); +} + +// node_modules/date-fns/esm/_lib/roundingMethods/index.js +var roundingMap = { + ceil: Math.ceil, + round: Math.round, + floor: Math.floor, + trunc: function trunc(value) { + return value < 0 ? Math.ceil(value) : Math.floor(value); } - app.workspace.iterateLeaves((leaf) => { - if (leaf.view.getViewType() == CONTEXT_VIEW_TYPE && leaf.view.getState().contextPath == context.contextPath) { - leaf.setViewState({ type: "empty" }); - } - }, app.workspace["rootSplit"]); }; -var connectContext = async (plugin, tag, source) => { -}; -var renameSpaceContextFile = async (plugin, space, newSpace) => { - const context = spaceContextFromSpace(plugin, spaceContextPathFromName(space)); - if (getAbstractFileAtPath(app, context.dbPath)) { - const newSpaceDBPath = newSpace + ".mdb"; - if (!getAbstractFileAtPath( - app, - getAbstractFileAtPath(app, context.dbPath).parent.path + "/" + newSpaceDBPath - )) { - await renameFile( - plugin, - getAbstractFileAtPath(app, context.dbPath), - newSpaceDBPath - ); - } else { - await deleteFile(plugin, getAbstractFileAtPath(app, context.dbPath)); - } - } - app.workspace.iterateLeaves((leaf) => { - if (leaf.view.getViewType() == CONTEXT_VIEW_TYPE && leaf.view.getState().contextPath == context.contextPath) { - leaf.setViewState({ - type: CONTEXT_VIEW_TYPE, - state: { contextPath: spaceContextPathFromName(newSpace) } - }); +var defaultRoundingMethod = "trunc"; +function getRoundingMethod(method) { + return method ? roundingMap[method] : roundingMap[defaultRoundingMethod]; +} + +// node_modules/date-fns/esm/endOfDay/index.js +function endOfDay(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + date.setHours(23, 59, 59, 999); + return date; +} + +// node_modules/date-fns/esm/endOfMonth/index.js +function endOfMonth(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var month = date.getMonth(); + date.setFullYear(date.getFullYear(), month + 1, 0); + date.setHours(23, 59, 59, 999); + return date; +} + +// node_modules/date-fns/esm/isLastDayOfMonth/index.js +function isLastDayOfMonth(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + return endOfDay(date).getTime() === endOfMonth(date).getTime(); +} + +// node_modules/date-fns/esm/differenceInMonths/index.js +function differenceInMonths(dirtyDateLeft, dirtyDateRight) { + requiredArgs(2, arguments); + var dateLeft = toDate(dirtyDateLeft); + var dateRight = toDate(dirtyDateRight); + var sign = compareAsc(dateLeft, dateRight); + var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight)); + var result; + if (difference < 1) { + result = 0; + } else { + if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) { + dateLeft.setDate(30); } - }, app.workspace["rootSplit"]); -}; -var renameTagContextFile = async (plugin, tag, newTag) => { - const context = tagContextFromTag(plugin, tag); - if (getAbstractFileAtPath(app, context.dbPath)) { - const newTagDBPath = tagToTagPath(newTag) + ".mdb"; - if (!getAbstractFileAtPath( - app, - getAbstractFileAtPath(app, context.dbPath).parent.path + "/" + tagToTagPath(newTag) + ".mdb" - )) { - await renameFile( - plugin, - getAbstractFileAtPath(app, context.dbPath), - tagToTagPath(newTag) + ".mdb" - ); - } else { - await deleteFile(plugin, getAbstractFileAtPath(app, context.dbPath)); + dateLeft.setMonth(dateLeft.getMonth() - sign * difference); + var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign; + if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) { + isLastMonthNotFull = false; } + result = sign * (difference - Number(isLastMonthNotFull)); } - plugin.index.renameTag(tag, newTag); - app.workspace.iterateLeaves((leaf) => { - if (leaf.view.getViewType() == CONTEXT_VIEW_TYPE && leaf.view.getState().contextPath == tag) { - leaf.setViewState({ - type: CONTEXT_VIEW_TYPE, - state: { contextPath: newTag } - }); - } - }, app.workspace["rootSplit"]); -}; + return result === 0 ? 0 : result; +} -// src/utils/metadata/tags.ts -var tagKeys = ["tag", "tags", "Tag", "Tags"]; -var tagToTagPath = (tag) => { - if (!tag) - return null; - let string = tag; - if (string.charAt(0) != "#") - string = "#" + string; - return string.replace(/\//g, "+"); -}; -var tagPathToTag = (string) => { - return filePathToString(string).replace(/\+/g, "/"); -}; -var loadTags = (plugin) => { - var _a2; - const folder = plugin.settings.tagContextFolder == "" ? app.vault.getRoot() : getAbstractFileAtPath( - app, - getFolderPathFromString(plugin.settings.tagContextFolder) - ); - return uniq([ - ...Object.keys(app.metadataCache.getTags()), - ...(_a2 = folder == null ? void 0 : folder.children.filter( - (f4) => f4 instanceof import_obsidian2.TFile && f4.extension == "mdb" && f4.name.charAt(0) == "#" - ).map((f4) => tagPathToTag(f4.name))) != null ? _a2 : [] - ]); -}; -var tagExists = (currentCache, findTag) => { - let currentTags = []; - if ((0, import_obsidian2.getAllTags)(currentCache)) { - currentTags = (0, import_obsidian2.getAllTags)(currentCache); +// node_modules/date-fns/esm/differenceInSeconds/index.js +function differenceInSeconds(dateLeft, dateRight, options) { + requiredArgs(2, arguments); + var diff = differenceInMilliseconds(dateLeft, dateRight) / 1e3; + return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff); +} + +// node_modules/date-fns/esm/startOfMonth/index.js +function startOfMonth(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + date.setDate(1); + date.setHours(0, 0, 0, 0); + return date; +} + +// node_modules/date-fns/esm/startOfYear/index.js +function startOfYear(dirtyDate) { + requiredArgs(1, arguments); + var cleanDate = toDate(dirtyDate); + var date = new Date(0); + date.setFullYear(cleanDate.getFullYear(), 0, 1); + date.setHours(0, 0, 0, 0); + return date; +} + +// node_modules/date-fns/esm/endOfWeek/index.js +function endOfWeek(dirtyDate, options) { + var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; + requiredArgs(1, arguments); + var defaultOptions3 = getDefaultOptions(); + var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError("weekStartsOn must be between 0 and 6 inclusively"); } - return currentTags.find((tag) => tag.toLowerCase() == findTag.toLowerCase()) ? true : false; -}; -var getAllFilesForTag = (tag) => { - let tagsCache = []; - (() => { - app.vault.getMarkdownFiles().forEach((tfile) => { - let currentCache; - if (app.metadataCache.getFileCache(tfile) !== null) { - currentCache = app.metadataCache.getFileCache(tfile); - } - let relativePath = tfile.path; - const hasTag = tagExists(currentCache, tag); - if (hasTag) { - tagsCache.push(relativePath); - } - }); - })(); - return tagsCache; -}; -var addTagToNote = (tag, tFile) => { - const newTag = validateName(tag); - editTagInFrontmatter("", newTag, tFile); -}; -var positionsForTag = (tag, file) => { - const currentCache = app.metadataCache.getFileCache(file); - if (currentCache.tags) { - const positions = currentCache.tags.filter((f4) => f4.tag == tag).map((f4) => f4.position).sort((a5, b4) => { - if (a5.start.offset < b4.start.offset) { - return -1; - } - if (a5.start.offset > b4.start.offset) { - return 1; - } - return 0; - }); - return positions; + var date = toDate(dirtyDate); + var day = date.getDay(); + var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn); + date.setDate(date.getDate() + diff); + date.setHours(23, 59, 59, 999); + return date; +} + +// node_modules/date-fns/esm/endOfISOWeek/index.js +function endOfISOWeek(dirtyDate) { + requiredArgs(1, arguments); + return endOfWeek(dirtyDate, { + weekStartsOn: 1 + }); +} + +// node_modules/date-fns/esm/subMilliseconds/index.js +function subMilliseconds(dirtyDate, dirtyAmount) { + requiredArgs(2, arguments); + var amount = toInteger(dirtyAmount); + return addMilliseconds(dirtyDate, -amount); +} + +// node_modules/date-fns/esm/_lib/getUTCDayOfYear/index.js +var MILLISECONDS_IN_DAY2 = 864e5; +function getUTCDayOfYear(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var timestamp = date.getTime(); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + var startOfYearTimestamp = date.getTime(); + var difference = timestamp - startOfYearTimestamp; + return Math.floor(difference / MILLISECONDS_IN_DAY2) + 1; +} + +// node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js +function startOfUTCISOWeek(dirtyDate) { + requiredArgs(1, arguments); + var weekStartsOn = 1; + var date = toDate(dirtyDate); + var day = date.getUTCDay(); + var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; + date.setUTCDate(date.getUTCDate() - diff); + date.setUTCHours(0, 0, 0, 0); + return date; +} + +// node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js +function getUTCISOWeekYear(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var year = date.getUTCFullYear(); + var fourthOfJanuaryOfNextYear = new Date(0); + fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4); + fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0); + var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear); + var fourthOfJanuaryOfThisYear = new Date(0); + fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4); + fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0); + var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear); + if (date.getTime() >= startOfNextYear.getTime()) { + return year + 1; + } else if (date.getTime() >= startOfThisYear.getTime()) { + return year; + } else { + return year - 1; } - return []; -}; -var removeTagFromFile = (tag, file) => { - const pos = positionsForTag(tag, file); - removeTagInFrontmatter(tag, file); - editTagInFileBody(tag, "", pos, file); -}; -var validateName = (tag) => { - return tag; -}; -var deleteTag = async (plugin, tag, subTags) => { - const files = getAllFilesForTag(tag).map((f4) => getAbstractFileAtPath(app, f4)).filter((f4) => f4 instanceof import_obsidian2.TFile); - files.forEach((file) => removeTagFromFile(tag, file)); - deleteTagContext(plugin, tag); - if (subTags) { - const tags = getAllSubtags(plugin, tag); - tags.forEach((tag2) => deleteTag(plugin, tag2, subTags)); +} + +// node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js +function startOfUTCISOWeekYear(dirtyDate) { + requiredArgs(1, arguments); + var year = getUTCISOWeekYear(dirtyDate); + var fourthOfJanuary = new Date(0); + fourthOfJanuary.setUTCFullYear(year, 0, 4); + fourthOfJanuary.setUTCHours(0, 0, 0, 0); + var date = startOfUTCISOWeek(fourthOfJanuary); + return date; +} + +// node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js +var MILLISECONDS_IN_WEEK2 = 6048e5; +function getUTCISOWeek(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); + return Math.round(diff / MILLISECONDS_IN_WEEK2) + 1; +} + +// node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js +function startOfUTCWeek(dirtyDate, options) { + var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; + requiredArgs(1, arguments); + var defaultOptions3 = getDefaultOptions(); + var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError("weekStartsOn must be between 0 and 6 inclusively"); } -}; -var tagsFromDefString = (defStr) => parseContextDefString(defStr).filter((f4) => f4.type == "tag" && f4.value.length > 0).map((f4) => f4.value); -var updateTagsForDefString = (defStr, tags) => JSON.stringify([...parseContextDefString(defStr).filter((f4) => f4.type != "tag"), ...tags.map((f4) => ({ type: "tag", value: f4 }))]); -var addTag = async (plugin, tag) => { - const context = tagContextFromTag(plugin, tag); - await createDefaultDB(plugin, context); -}; -var renameTag = async (plugin, tag, toTag) => { - const tags = getAllSubtags(plugin, tag); - const newTag = validateName(toTag); - const files = getAllFilesForTag(tag); - for (const file of files) { - const tFile = getAbstractFileAtPath(app, file); - if (tFile instanceof import_obsidian2.TFile) { - const positions = positionsForTag(tag, tFile); - if (positions.length > 0) { - await editTagInFileBody(tag, newTag, positions, tFile); - } else { - await editTagInFrontmatter(tag, newTag, tFile); - } - } + var date = toDate(dirtyDate); + var day = date.getUTCDay(); + var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; + date.setUTCDate(date.getUTCDate() - diff); + date.setUTCHours(0, 0, 0, 0); + return date; +} + +// node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js +function getUTCWeekYear(dirtyDate, options) { + var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var year = date.getUTCFullYear(); + var defaultOptions3 = getDefaultOptions(); + var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); + if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { + throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively"); } - await renameTagContextFile(plugin, tag, toTag); - for (const subtag of tags) { - await renameTag(plugin, subtag, subtag.replace(tag, newTag)); + var firstWeekOfNextYear = new Date(0); + firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate); + firstWeekOfNextYear.setUTCHours(0, 0, 0, 0); + var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options); + var firstWeekOfThisYear = new Date(0); + firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate); + firstWeekOfThisYear.setUTCHours(0, 0, 0, 0); + var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options); + if (date.getTime() >= startOfNextYear.getTime()) { + return year + 1; + } else if (date.getTime() >= startOfThisYear.getTime()) { + return year; + } else { + return year - 1; + } +} + +// node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js +function startOfUTCWeekYear(dirtyDate, options) { + var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; + requiredArgs(1, arguments); + var defaultOptions3 = getDefaultOptions(); + var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); + var year = getUTCWeekYear(dirtyDate, options); + var firstWeek = new Date(0); + firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate); + firstWeek.setUTCHours(0, 0, 0, 0); + var date = startOfUTCWeek(firstWeek, options); + return date; +} + +// node_modules/date-fns/esm/_lib/getUTCWeek/index.js +var MILLISECONDS_IN_WEEK3 = 6048e5; +function getUTCWeek(dirtyDate, options) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); + return Math.round(diff / MILLISECONDS_IN_WEEK3) + 1; +} + +// node_modules/date-fns/esm/_lib/addLeadingZeros/index.js +function addLeadingZeros(number, targetLength) { + var sign = number < 0 ? "-" : ""; + var output = Math.abs(number).toString(); + while (output.length < targetLength) { + output = "0" + output; + } + return sign + output; +} + +// node_modules/date-fns/esm/_lib/format/lightFormatters/index.js +var formatters = { + y: function y3(date, token) { + var signedYear = date.getUTCFullYear(); + var year = signedYear > 0 ? signedYear : 1 - signedYear; + return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); + }, + M: function M3(date, token) { + var month = date.getUTCMonth(); + return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); + }, + d: function d3(date, token) { + return addLeadingZeros(date.getUTCDate(), token.length); + }, + a: function a3(date, token) { + var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? "pm" : "am"; + switch (token) { + case "a": + case "aa": + return dayPeriodEnumValue.toUpperCase(); + case "aaa": + return dayPeriodEnumValue; + case "aaaaa": + return dayPeriodEnumValue[0]; + case "aaaa": + default: + return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; + } + }, + h: function h3(date, token) { + return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length); + }, + H: function H3(date, token) { + return addLeadingZeros(date.getUTCHours(), token.length); + }, + m: function m3(date, token) { + return addLeadingZeros(date.getUTCMinutes(), token.length); + }, + s: function s3(date, token) { + return addLeadingZeros(date.getUTCSeconds(), token.length); + }, + S: function S2(date, token) { + var numberOfDigits = token.length; + var milliseconds = date.getUTCMilliseconds(); + var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3)); + return addLeadingZeros(fractionalSeconds, token.length); } }; -var getAllSubtags = (plugin, tag) => { - const tags = loadTags(plugin); - return tags.filter((f4) => f4.startsWith(tag) && f4 != tag); +var lightFormatters_default = formatters; + +// node_modules/date-fns/esm/_lib/format/formatters/index.js +var dayPeriodEnum = { + am: "am", + pm: "pm", + midnight: "midnight", + noon: "noon", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night" }; -var removeTagInFrontmatter = async (oldTag, file) => { - var _a2; - let fm; - if (app.metadataCache.getFileCache(file) !== null) { - fm = (_a2 = app.metadataCache.getFileCache(file)) == null ? void 0 : _a2.frontmatter; - } - if (fm && app.fileManager.processFrontMatter) { - const processKey = (value) => { - if (Array.isArray(value)) { - return value.filter((f4) => stringFromTag(oldTag) != f4); - } else if (typeof value === "string") { - return serializeMultiDisplayString( - value.replace(/\s/g, "").split(",").filter((f4) => stringFromTag(oldTag) != f4) - ); - } - return value; - }; - const editKeys = tagKeys.filter((f4) => { - let tags = []; - if (Array.isArray(fm[f4])) { - tags = fm[f4]; - } else if (typeof fm[f4] === "string") { - tags = fm[f4].replace(/\s/g, "").split(","); - } - if (tags.find((g4) => g4 == stringFromTag(oldTag))) - return true; - return false; - }); - editKeys.forEach((tag) => { - app.fileManager.processFrontMatter(file, (frontmatter) => { - frontmatter[tag] = processKey(fm[tag]); +var formatters2 = { + G: function G2(date, token, localize2) { + var era = date.getUTCFullYear() > 0 ? 1 : 0; + switch (token) { + case "G": + case "GG": + case "GGG": + return localize2.era(era, { + width: "abbreviated" + }); + case "GGGGG": + return localize2.era(era, { + width: "narrow" + }); + case "GGGG": + default: + return localize2.era(era, { + width: "wide" + }); + } + }, + y: function y4(date, token, localize2) { + if (token === "yo") { + var signedYear = date.getUTCFullYear(); + var year = signedYear > 0 ? signedYear : 1 - signedYear; + return localize2.ordinalNumber(year, { + unit: "year" }); - }); - } -}; -var editTagInFrontmatter = async (oldTag, newTag, file) => { - var _a2; - let fm; - if (app.metadataCache.getFileCache(file) !== null) { - fm = (_a2 = app.metadataCache.getFileCache(file)) == null ? void 0 : _a2.frontmatter; - } - const addTag2 = (value) => { - if (Array.isArray(value)) { - return uniq([...value, stringFromTag(newTag)]).filter((f4) => (f4 == null ? void 0 : f4.length) > 0); - } else if (typeof value === "string") { - return serializeMultiDisplayString(uniq([ - ...value.replace(/\s/g, "").split(","), - stringFromTag(newTag) - ]).filter((f4) => (f4 == null ? void 0 : f4.length) > 0)); } - return stringFromTag(newTag); - }; - if (app.fileManager.processFrontMatter) { - if (fm) { - const processKey = (value) => { - if (Array.isArray(value)) { - return uniq( - value.map( - (f4) => stringFromTag(oldTag) == f4 ? stringFromTag(newTag) : f4 - ) - ); - } else if (typeof value === "string") { - return serializeMultiDisplayString(uniq( - value.replace(/\s/g, "").split(",").map( - (f4) => stringFromTag(oldTag) == f4 ? stringFromTag(newTag) : f4 - ) - )); - } - return value; - }; - const editKeys = tagKeys.filter((f4) => { - let tags = []; - if (Array.isArray(fm[f4])) { - tags = fm[f4]; - } else if (typeof fm[f4] === "string") { - tags = fm[f4].replace(/\s/g, "").split(","); - } - if (tags.find((g4) => g4 == stringFromTag(oldTag))) - return true; - return false; + return lightFormatters_default.y(date, token); + }, + Y: function Y2(date, token, localize2, options) { + var signedWeekYear = getUTCWeekYear(date, options); + var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; + if (token === "YY") { + var twoDigitYear = weekYear % 100; + return addLeadingZeros(twoDigitYear, 2); + } + if (token === "Yo") { + return localize2.ordinalNumber(weekYear, { + unit: "year" }); - if (editKeys.length > 0) { - editKeys.forEach((key2) => { - app.fileManager.processFrontMatter(file, (frontmatter) => { - frontmatter[key2] = processKey(fm[key2]); - }); + } + return addLeadingZeros(weekYear, token.length); + }, + R: function R2(date, token) { + var isoWeekYear = getUTCISOWeekYear(date); + return addLeadingZeros(isoWeekYear, token.length); + }, + u: function u3(date, token) { + var year = date.getUTCFullYear(); + return addLeadingZeros(year, token.length); + }, + Q: function Q2(date, token, localize2) { + var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); + switch (token) { + case "Q": + return String(quarter); + case "QQ": + return addLeadingZeros(quarter, 2); + case "Qo": + return localize2.ordinalNumber(quarter, { + unit: "quarter" }); - } else { - app.fileManager.processFrontMatter(file, (frontmatter) => { - frontmatter["tag"] = addTag2(fm["tag"]); + case "QQQ": + return localize2.quarter(quarter, { + width: "abbreviated", + context: "formatting" }); - } - } else { - app.fileManager.processFrontMatter(file, (frontmatter) => { - frontmatter["tag"] = stringFromTag(newTag); + case "QQQQQ": + return localize2.quarter(quarter, { + width: "narrow", + context: "formatting" + }); + case "QQQQ": + default: + return localize2.quarter(quarter, { + width: "wide", + context: "formatting" + }); + } + }, + q: function q4(date, token, localize2) { + var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); + switch (token) { + case "q": + return String(quarter); + case "qq": + return addLeadingZeros(quarter, 2); + case "qo": + return localize2.ordinalNumber(quarter, { + unit: "quarter" + }); + case "qqq": + return localize2.quarter(quarter, { + width: "abbreviated", + context: "standalone" + }); + case "qqqqq": + return localize2.quarter(quarter, { + width: "narrow", + context: "standalone" + }); + case "qqqq": + default: + return localize2.quarter(quarter, { + width: "wide", + context: "standalone" + }); + } + }, + M: function M4(date, token, localize2) { + var month = date.getUTCMonth(); + switch (token) { + case "M": + case "MM": + return lightFormatters_default.M(date, token); + case "Mo": + return localize2.ordinalNumber(month + 1, { + unit: "month" + }); + case "MMM": + return localize2.month(month, { + width: "abbreviated", + context: "formatting" + }); + case "MMMMM": + return localize2.month(month, { + width: "narrow", + context: "formatting" + }); + case "MMMM": + default: + return localize2.month(month, { + width: "wide", + context: "formatting" + }); + } + }, + L: function L3(date, token, localize2) { + var month = date.getUTCMonth(); + switch (token) { + case "L": + return String(month + 1); + case "LL": + return addLeadingZeros(month + 1, 2); + case "Lo": + return localize2.ordinalNumber(month + 1, { + unit: "month" + }); + case "LLL": + return localize2.month(month, { + width: "abbreviated", + context: "standalone" + }); + case "LLLLL": + return localize2.month(month, { + width: "narrow", + context: "standalone" + }); + case "LLLL": + default: + return localize2.month(month, { + width: "wide", + context: "standalone" + }); + } + }, + w: function w4(date, token, localize2, options) { + var week = getUTCWeek(date, options); + if (token === "wo") { + return localize2.ordinalNumber(week, { + unit: "week" }); } - } -}; -var editTagInFileBody = async (oldTag, newTag, positions, file) => { - const offsetOffset = newTag.length - oldTag.length; - if (positions.length == 0) - return false; - const original = await app.vault.read(file); - let text2 = original; - let offset = 0; - for (const { start, end } of positions) { - let startOff = start.offset + offset; - let endOff = end.offset + offset; - if (text2.slice(startOff, endOff) !== oldTag) { - return false; + return addLeadingZeros(week, token.length); + }, + I: function I3(date, token, localize2) { + var isoWeek = getUTCISOWeek(date); + if (token === "Io") { + return localize2.ordinalNumber(isoWeek, { + unit: "week" + }); } - text2 = text2.slice(0, startOff) + newTag + text2.slice(startOff + oldTag.length); - offset += offsetOffset; - } - if (text2 !== original) { - await app.vault.modify(file, text2); - return true; - } -}; -var allTagsForFile = (file) => { - var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j; - let rt = []; - if (file instanceof import_obsidian2.TFile) { - const fCache = app.metadataCache.getCache(file.path); - if (fCache && fCache.tags) - rt.push(...(_b2 = (_a2 = fCache.tags) == null ? void 0 : _a2.map((f4) => f4.tag)) != null ? _b2 : []); - if (fCache && ((_c2 = fCache.frontmatter) == null ? void 0 : _c2.tags)) - rt.push( - ...(typeof ((_d2 = fCache.frontmatter) == null ? void 0 : _d2.tags) === "string" ? parseMultiString(fCache.frontmatter.tags.replace(/ /g, "")) : Array.isArray((_e2 = fCache.frontmatter) == null ? void 0 : _e2.tags) ? (_f = fCache.frontmatter) == null ? void 0 : _f.tags : []).filter((f4) => typeof f4 === "string").map((f4) => "#" + f4) - ); - if (fCache && ((_g = fCache.frontmatter) == null ? void 0 : _g.tag)) - rt.push( - ...(typeof ((_h = fCache.frontmatter) == null ? void 0 : _h.tag) === "string" ? parseMultiString(fCache.frontmatter.tag.replace(/ /g, "")) : Array.isArray((_i = fCache.frontmatter) == null ? void 0 : _i.tag) ? (_j = fCache.frontmatter) == null ? void 0 : _j.tag : []).filter((f4) => typeof f4 === "string").map((f4) => "#" + f4) - ); - } - return uniq(rt); -}; - -// src/utils/path.ts -var import_obsidian3 = require("obsidian"); -var openPath = (plugin, _path) => { - const { type, path } = _path; - if (type == "file" || type == "folder") { - const afile = getAbstractFileAtPath(app, path); - if (afile) { - openAFile(afile, plugin, false); + return addLeadingZeros(isoWeek, token.length); + }, + d: function d4(date, token, localize2) { + if (token === "do") { + return localize2.ordinalNumber(date.getUTCDate(), { + unit: "date" + }); + } + return lightFormatters_default.d(date, token); + }, + D: function D3(date, token, localize2) { + var dayOfYear = getUTCDayOfYear(date); + if (token === "Do") { + return localize2.ordinalNumber(dayOfYear, { + unit: "dayOfYear" + }); + } + return addLeadingZeros(dayOfYear, token.length); + }, + E: function E3(date, token, localize2) { + var dayOfWeek = date.getUTCDay(); + switch (token) { + case "E": + case "EE": + case "EEE": + return localize2.day(dayOfWeek, { + width: "abbreviated", + context: "formatting" + }); + case "EEEEE": + return localize2.day(dayOfWeek, { + width: "narrow", + context: "formatting" + }); + case "EEEEEE": + return localize2.day(dayOfWeek, { + width: "short", + context: "formatting" + }); + case "EEEE": + default: + return localize2.day(dayOfWeek, { + width: "wide", + context: "formatting" + }); + } + }, + e: function e3(date, token, localize2, options) { + var dayOfWeek = date.getUTCDay(); + var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; + switch (token) { + case "e": + return String(localDayOfWeek); + case "ee": + return addLeadingZeros(localDayOfWeek, 2); + case "eo": + return localize2.ordinalNumber(localDayOfWeek, { + unit: "day" + }); + case "eee": + return localize2.day(dayOfWeek, { + width: "abbreviated", + context: "formatting" + }); + case "eeeee": + return localize2.day(dayOfWeek, { + width: "narrow", + context: "formatting" + }); + case "eeeeee": + return localize2.day(dayOfWeek, { + width: "short", + context: "formatting" + }); + case "eeee": + default: + return localize2.day(dayOfWeek, { + width: "wide", + context: "formatting" + }); + } + }, + c: function c3(date, token, localize2, options) { + var dayOfWeek = date.getUTCDay(); + var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; + switch (token) { + case "c": + return String(localDayOfWeek); + case "cc": + return addLeadingZeros(localDayOfWeek, token.length); + case "co": + return localize2.ordinalNumber(localDayOfWeek, { + unit: "day" + }); + case "ccc": + return localize2.day(dayOfWeek, { + width: "abbreviated", + context: "standalone" + }); + case "ccccc": + return localize2.day(dayOfWeek, { + width: "narrow", + context: "standalone" + }); + case "cccccc": + return localize2.day(dayOfWeek, { + width: "short", + context: "standalone" + }); + case "cccc": + default: + return localize2.day(dayOfWeek, { + width: "wide", + context: "standalone" + }); + } + }, + i: function i3(date, token, localize2) { + var dayOfWeek = date.getUTCDay(); + var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; + switch (token) { + case "i": + return String(isoDayOfWeek); + case "ii": + return addLeadingZeros(isoDayOfWeek, token.length); + case "io": + return localize2.ordinalNumber(isoDayOfWeek, { + unit: "day" + }); + case "iii": + return localize2.day(dayOfWeek, { + width: "abbreviated", + context: "formatting" + }); + case "iiiii": + return localize2.day(dayOfWeek, { + width: "narrow", + context: "formatting" + }); + case "iiiiii": + return localize2.day(dayOfWeek, { + width: "short", + context: "formatting" + }); + case "iiii": + default: + return localize2.day(dayOfWeek, { + width: "wide", + context: "formatting" + }); + } + }, + a: function a4(date, token, localize2) { + var hours = date.getUTCHours(); + var dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; + switch (token) { + case "a": + case "aa": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }); + case "aaa": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }).toLowerCase(); + case "aaaaa": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting" + }); + case "aaaa": + default: + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting" + }); + } + }, + b: function b3(date, token, localize2) { + var hours = date.getUTCHours(); + var dayPeriodEnumValue; + if (hours === 12) { + dayPeriodEnumValue = dayPeriodEnum.noon; + } else if (hours === 0) { + dayPeriodEnumValue = dayPeriodEnum.midnight; } else { - if (type == "file") - createNewMarkdownFile( - plugin, - defaultNoteFolder(plugin, null), - path - ); + dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; } - return; - } - if (type == "tag") { - openTagContext(path, plugin, false); - return; - } - if (type == "url") { - openURL(path); - return; + switch (token) { + case "b": + case "bb": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }); + case "bbb": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }).toLowerCase(); + case "bbbbb": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting" + }); + case "bbbb": + default: + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting" + }); + } + }, + B: function B4(date, token, localize2) { + var hours = date.getUTCHours(); + var dayPeriodEnumValue; + if (hours >= 17) { + dayPeriodEnumValue = dayPeriodEnum.evening; + } else if (hours >= 12) { + dayPeriodEnumValue = dayPeriodEnum.afternoon; + } else if (hours >= 4) { + dayPeriodEnumValue = dayPeriodEnum.morning; + } else { + dayPeriodEnumValue = dayPeriodEnum.night; + } + switch (token) { + case "B": + case "BB": + case "BBB": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "abbreviated", + context: "formatting" + }); + case "BBBBB": + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "narrow", + context: "formatting" + }); + case "BBBB": + default: + return localize2.dayPeriod(dayPeriodEnumValue, { + width: "wide", + context: "formatting" + }); + } + }, + h: function h4(date, token, localize2) { + if (token === "ho") { + var hours = date.getUTCHours() % 12; + if (hours === 0) + hours = 12; + return localize2.ordinalNumber(hours, { + unit: "hour" + }); + } + return lightFormatters_default.h(date, token); + }, + H: function H4(date, token, localize2) { + if (token === "Ho") { + return localize2.ordinalNumber(date.getUTCHours(), { + unit: "hour" + }); + } + return lightFormatters_default.H(date, token); + }, + K: function K2(date, token, localize2) { + var hours = date.getUTCHours() % 12; + if (token === "Ko") { + return localize2.ordinalNumber(hours, { + unit: "hour" + }); + } + return addLeadingZeros(hours, token.length); + }, + k: function k4(date, token, localize2) { + var hours = date.getUTCHours(); + if (hours === 0) + hours = 24; + if (token === "ko") { + return localize2.ordinalNumber(hours, { + unit: "hour" + }); + } + return addLeadingZeros(hours, token.length); + }, + m: function m4(date, token, localize2) { + if (token === "mo") { + return localize2.ordinalNumber(date.getUTCMinutes(), { + unit: "minute" + }); + } + return lightFormatters_default.m(date, token); + }, + s: function s4(date, token, localize2) { + if (token === "so") { + return localize2.ordinalNumber(date.getUTCSeconds(), { + unit: "second" + }); + } + return lightFormatters_default.s(date, token); + }, + S: function S3(date, token) { + return lightFormatters_default.S(date, token); + }, + X: function X2(date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timezoneOffset = originalDate.getTimezoneOffset(); + if (timezoneOffset === 0) { + return "Z"; + } + switch (token) { + case "X": + return formatTimezoneWithOptionalMinutes(timezoneOffset); + case "XXXX": + case "XX": + return formatTimezone(timezoneOffset); + case "XXXXX": + case "XXX": + default: + return formatTimezone(timezoneOffset, ":"); + } + }, + x: function x4(date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timezoneOffset = originalDate.getTimezoneOffset(); + switch (token) { + case "x": + return formatTimezoneWithOptionalMinutes(timezoneOffset); + case "xxxx": + case "xx": + return formatTimezone(timezoneOffset); + case "xxxxx": + case "xxx": + default: + return formatTimezone(timezoneOffset, ":"); + } + }, + O: function O3(date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timezoneOffset = originalDate.getTimezoneOffset(); + switch (token) { + case "O": + case "OO": + case "OOO": + return "GMT" + formatTimezoneShort(timezoneOffset, ":"); + case "OOOO": + default: + return "GMT" + formatTimezone(timezoneOffset, ":"); + } + }, + z: function z4(date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timezoneOffset = originalDate.getTimezoneOffset(); + switch (token) { + case "z": + case "zz": + case "zzz": + return "GMT" + formatTimezoneShort(timezoneOffset, ":"); + case "zzzz": + default: + return "GMT" + formatTimezone(timezoneOffset, ":"); + } + }, + t: function t3(date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timestamp = Math.floor(originalDate.getTime() / 1e3); + return addLeadingZeros(timestamp, token.length); + }, + T: function T5(date, token, _localize, options) { + var originalDate = options._originalDate || date; + var timestamp = originalDate.getTime(); + return addLeadingZeros(timestamp, token.length); } }; -var pathByString = (plugin, path, source) => { - const [str, alias] = path.split("|"); - const refIndex = str.lastIndexOf("#"); - const [link2, ref] = refIndex > 0 ? [str.substring(0, refIndex), str.substring(refIndex + 1)] : [str, void 0]; - const type = pathTypeByString(link2, source); - return { - fullPath: path, - path: link2, - type, - alias, - ref - }; -}; -var pathTypeByString = (file, source) => { - if (file.charAt(0) == "#") { - return "tag"; - } - if (file.slice(-2) == "//") { - return "space"; - } - if (file.charAt(file.length - 1) == "/") { - return "folder"; - } - let portalFile; - if (source) { - portalFile = app.metadataCache.getFirstLinkpathDest(file, source); - } else { - portalFile = app.vault.getAbstractFileByPath(file); +function formatTimezoneShort(offset, dirtyDelimiter) { + var sign = offset > 0 ? "-" : "+"; + var absOffset = Math.abs(offset); + var hours = Math.floor(absOffset / 60); + var minutes = absOffset % 60; + if (minutes === 0) { + return sign + String(hours); } - if (portalFile instanceof import_obsidian3.TFolder) { - return "folder"; + var delimiter = dirtyDelimiter || ""; + return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); +} +function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) { + if (offset % 60 === 0) { + var sign = offset > 0 ? "-" : "+"; + return sign + addLeadingZeros(Math.abs(offset) / 60, 2); } - if (portalFile instanceof import_obsidian3.TFile) { - return "file"; + return formatTimezone(offset, dirtyDelimiter); +} +function formatTimezone(offset, dirtyDelimiter) { + var delimiter = dirtyDelimiter || ""; + var sign = offset > 0 ? "-" : "+"; + var absOffset = Math.abs(offset); + var hours = addLeadingZeros(Math.floor(absOffset / 60), 2); + var minutes = addLeadingZeros(absOffset % 60, 2); + return sign + hours + delimiter + minutes; +} +var formatters_default = formatters2; + +// node_modules/date-fns/esm/_lib/format/longFormatters/index.js +var dateLongFormatter = function dateLongFormatter2(pattern, formatLong2) { + switch (pattern) { + case "P": + return formatLong2.date({ + width: "short" + }); + case "PP": + return formatLong2.date({ + width: "medium" + }); + case "PPP": + return formatLong2.date({ + width: "long" + }); + case "PPPP": + default: + return formatLong2.date({ + width: "full" + }); } - if (file.match(urlRegex)) - return "url"; - return "unknown"; }; - -// src/utils/contexts/contexts.ts -var contextEmbedStringFromContext = (context, schema) => { - if (context.type == "folder") { - if (context.contextPath == "/") - return `![![/#^${schema}]]`; - return `![![${context.contextPath}/#^${schema}]]`; +var timeLongFormatter = function timeLongFormatter2(pattern, formatLong2) { + switch (pattern) { + case "p": + return formatLong2.time({ + width: "short" + }); + case "pp": + return formatLong2.time({ + width: "medium" + }); + case "ppp": + return formatLong2.time({ + width: "long" + }); + case "pppp": + default: + return formatLong2.time({ + width: "full" + }); } - return `![![${context.contextPath}#^${schema}]]`; }; -var spaceContextFromSpace = (plugin, space, readOnly) => { - return { - type: "space", - sticker: "", - banner: "", - contextPath: space, - isRemote: false, - readOnly, - dbPath: getFolderPathFromString(plugin.settings.tagContextFolder) + "/" + spaceNameFromContextPath(space) + ".mdb" - }; +var dateTimeLongFormatter = function dateTimeLongFormatter2(pattern, formatLong2) { + var matchResult = pattern.match(/(P+)(p+)?/) || []; + var datePattern = matchResult[1]; + var timePattern = matchResult[2]; + if (!timePattern) { + return dateLongFormatter(pattern, formatLong2); + } + var dateTimeFormat; + switch (datePattern) { + case "P": + dateTimeFormat = formatLong2.dateTime({ + width: "short" + }); + break; + case "PP": + dateTimeFormat = formatLong2.dateTime({ + width: "medium" + }); + break; + case "PPP": + dateTimeFormat = formatLong2.dateTime({ + width: "long" + }); + break; + case "PPPP": + default: + dateTimeFormat = formatLong2.dateTime({ + width: "full" + }); + break; + } + return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); }; -var tagContextFromTag = (plugin, tag, readOnly) => { - return { - type: "tag", - sticker: "", - banner: "", - contextPath: tag, - isRemote: false, - readOnly, - dbPath: getFolderPathFromString(plugin.settings.tagContextFolder) + "/" + tagToTagPath(tag) + ".mdb" - }; +var longFormatters = { + p: timeLongFormatter, + P: dateTimeLongFormatter }; -var mdbContextByDBPath = (plugin, dbPath) => { - if (dbPath.match(urlRegex)) { - return remoteContextFromURL(plugin, dbPath); +var longFormatters_default = longFormatters; + +// node_modules/date-fns/esm/_lib/protectedTokens/index.js +var protectedDayOfYearTokens = ["D", "DD"]; +var protectedWeekYearTokens = ["YY", "YYYY"]; +function isProtectedDayOfYearToken(token) { + return protectedDayOfYearTokens.indexOf(token) !== -1; +} +function isProtectedWeekYearToken(token) { + return protectedWeekYearTokens.indexOf(token) !== -1; +} +function throwProtectedError(token, format2, input) { + if (token === "YYYY") { + throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); + } else if (token === "YY") { + throw new RangeError("Use `yy` instead of `YY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); + } else if (token === "D") { + throw new RangeError("Use `d` instead of `D` (in `".concat(format2, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); + } else if (token === "DD") { + throw new RangeError("Use `dd` instead of `DD` (in `".concat(format2, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); } - if (dbPath.startsWith(plugin.settings.tagContextFolder)) { - const contextPath = filePathToString(dbPath); - if (contextPath.charAt(0) == "#") - return tagContextFromTag(plugin, tagPathToTag(dbPath)); - return spaceContextFromSpace(plugin, spaceContextPathFromName(contextPath)); +} + +// node_modules/date-fns/esm/locale/en-US/_lib/formatDistance/index.js +var formatDistanceLocale = { + lessThanXSeconds: { + one: "less than a second", + other: "less than {{count}} seconds" + }, + xSeconds: { + one: "1 second", + other: "{{count}} seconds" + }, + halfAMinute: "half a minute", + lessThanXMinutes: { + one: "less than a minute", + other: "less than {{count}} minutes" + }, + xMinutes: { + one: "1 minute", + other: "{{count}} minutes" + }, + aboutXHours: { + one: "about 1 hour", + other: "about {{count}} hours" + }, + xHours: { + one: "1 hour", + other: "{{count}} hours" + }, + xDays: { + one: "1 day", + other: "{{count}} days" + }, + aboutXWeeks: { + one: "about 1 week", + other: "about {{count}} weeks" + }, + xWeeks: { + one: "1 week", + other: "{{count}} weeks" + }, + aboutXMonths: { + one: "about 1 month", + other: "about {{count}} months" + }, + xMonths: { + one: "1 month", + other: "{{count}} months" + }, + aboutXYears: { + one: "about 1 year", + other: "about {{count}} years" + }, + xYears: { + one: "1 year", + other: "{{count}} years" + }, + overXYears: { + one: "over 1 year", + other: "over {{count}} years" + }, + almostXYears: { + one: "almost 1 year", + other: "almost {{count}} years" } - return dbPath.endsWith((plugin == null ? void 0 : plugin.settings.folderContextFile) + ".mdb") ? folderContextFromFolder(plugin, getFolderFromPath(app, dbPath).path) : null; -}; -var remoteContextFromURL = (plugin, url) => { - return { - type: "unknown", - sticker: "", - banner: "", - contextPath: url, - isRemote: true, - readOnly: true, - dbPath: url - }; }; -var mdbContextByPath = (plugin, contextPath) => { - if (!contextPath) - return; - if (contextPath.match(urlRegex)) { - return remoteContextFromURL(plugin, contextPath); +var formatDistance = function formatDistance2(token, count2, options) { + var result; + var tokenValue = formatDistanceLocale[token]; + if (typeof tokenValue === "string") { + result = tokenValue; + } else if (count2 === 1) { + result = tokenValue.one; + } else { + result = tokenValue.other.replace("{{count}}", count2.toString()); } - const viewType = pathTypeByString(contextPath); - if (viewType == "space") { - return spaceContextFromSpace(plugin, contextPath); - } else if (viewType == "folder") { - return folderContextFromFolder(plugin, removeTrailingSlashFromFolder(contextPath)); - } else if (viewType == "tag") { - return tagContextFromTag(plugin, contextPath); + if (options !== null && options !== void 0 && options.addSuffix) { + if (options.comparison && options.comparison > 0) { + return "in " + result; + } else { + return result + " ago"; + } } - return null; + return result; }; -var folderContextFromFolder = (plugin, folder, readOnly) => { - return { - type: "folder", - sticker: "", - banner: "", - contextPath: folder, - isRemote: false, - readOnly, - dbPath: (folder == "/" ? "" : folder + "/") + plugin.settings.folderContextFile + ".mdb" +var formatDistance_default = formatDistance; + +// node_modules/date-fns/esm/locale/_lib/buildFormatLongFn/index.js +function buildFormatLongFn(args) { + return function() { + var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + var width = options.width ? String(options.width) : args.defaultWidth; + var format2 = args.formats[width] || args.formats[args.defaultWidth]; + return format2; }; +} + +// node_modules/date-fns/esm/locale/en-US/_lib/formatLong/index.js +var dateFormats = { + full: "EEEE, MMMM do, y", + long: "MMMM do, y", + medium: "MMM d, y", + short: "MM/dd/yyyy" }; -var linkContextRow = (plugin, row, fields) => { - return { - ...row, - ...fields.filter((f4) => f4.type == "fileprop").reduce((p3, c4) => { - const { field, property } = parsePropString(c4.value); - const col = fields.find((f4) => f4.name == field); - if (!col || !property) { - return p3; - } - if (col.type == "file" || col.type == "link") { - return { - ...p3, - [c4.name]: appendFilesMetaData(plugin, property, row[col.name]) - }; - } - if (col.type.includes("context")) { - const context = col.value; - const contextCache = plugin.index.contextsCache.get(context); - if (contextCache) { - return { - ...p3, - [c4.name]: linkContextProp( - property, - row[col.name], - contextCache.rows - ) - }; - } - } - return p3; - }, {}) - }; +var timeFormats = { + full: "h:mm:ss a zzzz", + long: "h:mm:ss a z", + medium: "h:mm:ss a", + short: "h:mm a" }; -var linkContextProp = (propType, rows, contextTableRows) => { - const contextRows = contextTableRows.filter( - (f4) => parseMultiString(rows).contains(f4.File) - ); - return serializeMultiString(uniq(contextRows.map((f4) => f4[propType]).filter((f4) => f4))); +var dateTimeFormats = { + full: "{{date}} 'at' {{time}}", + long: "{{date}} 'at' {{time}}", + medium: "{{date}}, {{time}}", + short: "{{date}}, {{time}}" +}; +var formatLong = { + date: buildFormatLongFn({ + formats: dateFormats, + defaultWidth: "full" + }), + time: buildFormatLongFn({ + formats: timeFormats, + defaultWidth: "full" + }), + dateTime: buildFormatLongFn({ + formats: dateTimeFormats, + defaultWidth: "full" + }) }; +var formatLong_default = formatLong; -// src/components/ui/modals/imageModal.tsx -var import_obsidian4 = require("obsidian"); -var imageModal = class extends import_obsidian4.FuzzySuggestModal { - constructor(plugin, app2, selectImage) { - super(app2); - this.plugin = plugin; - this.selectImage = selectImage; - this.resultContainerEl.toggleClass("mk-image-modal", true); - this.inputEl.focus(); - this.inputEl.placeholder = "Select an image or paste a URL"; - this.emptyStateText = "No Images Found"; - this.limit = 30; - } - renderSuggestion(item, el) { - var oImg = el.createEl("img"); - const file = getAbstractFileAtPath(app, item.item); - oImg.setAttribute( - "src", - file ? app.vault.getResourcePath(file) : item.item - ); - oImg.setAttribute("height", "100px"); - oImg.setAttribute("width", "100px"); - el.appendChild(oImg); - } - getItemText(item) { - return item; - } - getSuggestions(query) { - let allImages = []; - if (query.match(urlRegex)) - allImages.push(query); - allImages.push( - ...getAllAbstractFilesInVault(this.plugin, app).filter( - (f4) => f4 instanceof import_obsidian4.TFile && ["png", "jpg", "jpeg"].contains(f4.extension) - ).map((f4) => f4.path) - ); - return allImages.filter((f4) => f4.contains(query)).map((f4, i4) => ({ - item: f4, - match: { - score: i4, - matches: [] - } - })); - } - getItems() { - let allImages = []; - allImages.push( - ...getAllAbstractFilesInVault(this.plugin, app).filter( - (f4) => f4 instanceof import_obsidian4.TFile && ["png", "jpg", "jpeg"].contains(f4.extension) - ).map((f4) => f4.path) - ); - return allImages; - } - onChooseItem(item, evt) { - this.selectImage(item); - } +// node_modules/date-fns/esm/locale/en-US/_lib/formatRelative/index.js +var formatRelativeLocale = { + lastWeek: "'last' eeee 'at' p", + yesterday: "'yesterday at' p", + today: "'today at' p", + tomorrow: "'tomorrow at' p", + nextWeek: "eeee 'at' p", + other: "P" +}; +var formatRelative = function formatRelative2(token, _date, _baseDate, _options) { + return formatRelativeLocale[token]; }; +var formatRelative_default = formatRelative; -// src/hooks/useLongPress.tsx -function isMouseEvent(e4) { - return e4 && "screenX" in e4; +// node_modules/date-fns/esm/locale/_lib/buildLocalizeFn/index.js +function buildLocalizeFn(args) { + return function(dirtyIndex, options) { + var context = options !== null && options !== void 0 && options.context ? String(options.context) : "standalone"; + var valuesArray; + if (context === "formatting" && args.formattingValues) { + var defaultWidth = args.defaultFormattingWidth || args.defaultWidth; + var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth; + valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; + } else { + var _defaultWidth = args.defaultWidth; + var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth; + valuesArray = args.values[_width] || args.values[_defaultWidth]; + } + var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; + return valuesArray[index]; + }; } -// src/components/FileContextView/NoteBannerView.tsx -var import_obsidian7 = require("obsidian"); - -// src/types/space.ts -var FMBannerKey = "banner"; -var FMStickerKey = "sticker"; -var FMColorKey = "color"; -var FMMetadataKeys = [FMBannerKey, FMStickerKey, FMColorKey]; - -// node_modules/date-fns/esm/_lib/toInteger/index.js -function toInteger(dirtyNumber) { - if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) { - return NaN; +// node_modules/date-fns/esm/locale/en-US/_lib/localize/index.js +var eraValues = { + narrow: ["B", "A"], + abbreviated: ["BC", "AD"], + wide: ["Before Christ", "Anno Domini"] +}; +var quarterValues = { + narrow: ["1", "2", "3", "4"], + abbreviated: ["Q1", "Q2", "Q3", "Q4"], + wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] +}; +var monthValues = { + narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], + abbreviated: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], + wide: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] +}; +var dayValues = { + narrow: ["S", "M", "T", "W", "T", "F", "S"], + short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], + abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + wide: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] +}; +var dayPeriodValues = { + narrow: { + am: "a", + pm: "p", + midnight: "mi", + noon: "n", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night" + }, + abbreviated: { + am: "AM", + pm: "PM", + midnight: "midnight", + noon: "noon", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night" + }, + wide: { + am: "a.m.", + pm: "p.m.", + midnight: "midnight", + noon: "noon", + morning: "morning", + afternoon: "afternoon", + evening: "evening", + night: "night" } - var number = Number(dirtyNumber); - if (isNaN(number)) { - return number; +}; +var formattingDayPeriodValues = { + narrow: { + am: "a", + pm: "p", + midnight: "mi", + noon: "n", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night" + }, + abbreviated: { + am: "AM", + pm: "PM", + midnight: "midnight", + noon: "noon", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night" + }, + wide: { + am: "a.m.", + pm: "p.m.", + midnight: "midnight", + noon: "noon", + morning: "in the morning", + afternoon: "in the afternoon", + evening: "in the evening", + night: "at night" } - return number < 0 ? Math.ceil(number) : Math.floor(number); -} - -// node_modules/date-fns/esm/_lib/requiredArgs/index.js -function requiredArgs(required, args) { - if (args.length < required) { - throw new TypeError(required + " argument" + (required > 1 ? "s" : "") + " required, but only " + args.length + " present"); +}; +var ordinalNumber = function ordinalNumber2(dirtyNumber, _options) { + var number = Number(dirtyNumber); + var rem100 = number % 100; + if (rem100 > 20 || rem100 < 10) { + switch (rem100 % 10) { + case 1: + return number + "st"; + case 2: + return number + "nd"; + case 3: + return number + "rd"; + } } -} + return number + "th"; +}; +var localize = { + ordinalNumber, + era: buildLocalizeFn({ + values: eraValues, + defaultWidth: "wide" + }), + quarter: buildLocalizeFn({ + values: quarterValues, + defaultWidth: "wide", + argumentCallback: function argumentCallback(quarter) { + return quarter - 1; + } + }), + month: buildLocalizeFn({ + values: monthValues, + defaultWidth: "wide" + }), + day: buildLocalizeFn({ + values: dayValues, + defaultWidth: "wide" + }), + dayPeriod: buildLocalizeFn({ + values: dayPeriodValues, + defaultWidth: "wide", + formattingValues: formattingDayPeriodValues, + defaultFormattingWidth: "wide" + }) +}; +var localize_default = localize; -// node_modules/date-fns/esm/toDate/index.js -function _typeof(obj) { - "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function _typeof5(obj2) { - return typeof obj2; - }; - } else { - _typeof = function _typeof5(obj2) { - return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; +// node_modules/date-fns/esm/locale/_lib/buildMatchFn/index.js +function buildMatchFn(args) { + return function(string) { + var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + var width = options.width; + var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; + var matchResult = string.match(matchPattern); + if (!matchResult) { + return null; + } + var matchedString = matchResult[0]; + var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; + var key2 = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function(pattern) { + return pattern.test(matchedString); + }) : findKey(parsePatterns, function(pattern) { + return pattern.test(matchedString); + }); + var value; + value = args.valueCallback ? args.valueCallback(key2) : key2; + value = options.valueCallback ? options.valueCallback(value) : value; + var rest = string.slice(matchedString.length); + return { + value, + rest }; + }; +} +function findKey(object, predicate) { + for (var key2 in object) { + if (object.hasOwnProperty(key2) && predicate(object[key2])) { + return key2; + } } - return _typeof(obj); + return void 0; } -function toDate(argument) { - requiredArgs(1, arguments); - var argStr = Object.prototype.toString.call(argument); - if (argument instanceof Date || _typeof(argument) === "object" && argStr === "[object Date]") { - return new Date(argument.getTime()); - } else if (typeof argument === "number" || argStr === "[object Number]") { - return new Date(argument); - } else { - if ((typeof argument === "string" || argStr === "[object String]") && typeof console !== "undefined") { - console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"); - console.warn(new Error().stack); +function findIndex(array, predicate) { + for (var key2 = 0; key2 < array.length; key2++) { + if (predicate(array[key2])) { + return key2; } - return new Date(NaN); } + return void 0; } -// node_modules/date-fns/esm/addDays/index.js -function addDays(dirtyDate, dirtyAmount) { - requiredArgs(2, arguments); - var date = toDate(dirtyDate); - var amount = toInteger(dirtyAmount); - if (isNaN(amount)) { - return new Date(NaN); - } - if (!amount) { - return date; - } - date.setDate(date.getDate() + amount); - return date; +// node_modules/date-fns/esm/locale/_lib/buildMatchPatternFn/index.js +function buildMatchPatternFn(args) { + return function(string) { + var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + var matchResult = string.match(args.matchPattern); + if (!matchResult) + return null; + var matchedString = matchResult[0]; + var parseResult = string.match(args.parsePattern); + if (!parseResult) + return null; + var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; + value = options.valueCallback ? options.valueCallback(value) : value; + var rest = string.slice(matchedString.length); + return { + value, + rest + }; + }; } -// node_modules/date-fns/esm/addMonths/index.js -function addMonths(dirtyDate, dirtyAmount) { - requiredArgs(2, arguments); - var date = toDate(dirtyDate); - var amount = toInteger(dirtyAmount); - if (isNaN(amount)) { - return new Date(NaN); - } - if (!amount) { - return date; +// node_modules/date-fns/esm/locale/en-US/_lib/match/index.js +var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; +var parseOrdinalNumberPattern = /\d+/i; +var matchEraPatterns = { + narrow: /^(b|a)/i, + abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, + wide: /^(before christ|before common era|anno domini|common era)/i +}; +var parseEraPatterns = { + any: [/^b/i, /^(a|c)/i] +}; +var matchQuarterPatterns = { + narrow: /^[1234]/i, + abbreviated: /^q[1234]/i, + wide: /^[1234](th|st|nd|rd)? quarter/i +}; +var parseQuarterPatterns = { + any: [/1/i, /2/i, /3/i, /4/i] +}; +var matchMonthPatterns = { + narrow: /^[jfmasond]/i, + abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, + wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i +}; +var parseMonthPatterns = { + narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i], + any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i] +}; +var matchDayPatterns = { + narrow: /^[smtwf]/i, + short: /^(su|mo|tu|we|th|fr|sa)/i, + abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, + wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i +}; +var parseDayPatterns = { + narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], + any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] +}; +var matchDayPeriodPatterns = { + narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, + any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i +}; +var parseDayPeriodPatterns = { + any: { + am: /^a/i, + pm: /^p/i, + midnight: /^mi/i, + noon: /^no/i, + morning: /morning/i, + afternoon: /afternoon/i, + evening: /evening/i, + night: /night/i } - var dayOfMonth = date.getDate(); - var endOfDesiredMonth = new Date(date.getTime()); - endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0); - var daysInMonth = endOfDesiredMonth.getDate(); - if (dayOfMonth >= daysInMonth) { - return endOfDesiredMonth; - } else { - date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth); - return date; +}; +var match = { + ordinalNumber: buildMatchPatternFn({ + matchPattern: matchOrdinalNumberPattern, + parsePattern: parseOrdinalNumberPattern, + valueCallback: function valueCallback(value) { + return parseInt(value, 10); + } + }), + era: buildMatchFn({ + matchPatterns: matchEraPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseEraPatterns, + defaultParseWidth: "any" + }), + quarter: buildMatchFn({ + matchPatterns: matchQuarterPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseQuarterPatterns, + defaultParseWidth: "any", + valueCallback: function valueCallback2(index) { + return index + 1; + } + }), + month: buildMatchFn({ + matchPatterns: matchMonthPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseMonthPatterns, + defaultParseWidth: "any" + }), + day: buildMatchFn({ + matchPatterns: matchDayPatterns, + defaultMatchWidth: "wide", + parsePatterns: parseDayPatterns, + defaultParseWidth: "any" + }), + dayPeriod: buildMatchFn({ + matchPatterns: matchDayPeriodPatterns, + defaultMatchWidth: "any", + parsePatterns: parseDayPeriodPatterns, + defaultParseWidth: "any" + }) +}; +var match_default = match; + +// node_modules/date-fns/esm/locale/en-US/index.js +var locale = { + code: "en-US", + formatDistance: formatDistance_default, + formatLong: formatLong_default, + formatRelative: formatRelative_default, + localize: localize_default, + match: match_default, + options: { + weekStartsOn: 0, + firstWeekContainsDate: 1 } -} +}; +var en_US_default = locale; -// node_modules/date-fns/esm/addMilliseconds/index.js -function addMilliseconds(dirtyDate, dirtyAmount) { +// node_modules/date-fns/esm/_lib/defaultLocale/index.js +var defaultLocale_default = en_US_default; + +// node_modules/date-fns/esm/format/index.js +var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; +var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; +var escapedStringRegExp = /^'([^]*?)'?$/; +var doubleQuoteRegExp = /''/g; +var unescapedLatinCharacterRegExp = /[a-zA-Z]/; +function format(dirtyDate, dirtyFormatStr, options) { + var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4; requiredArgs(2, arguments); - var timestamp = toDate(dirtyDate).getTime(); - var amount = toInteger(dirtyAmount); - return new Date(timestamp + amount); + var formatStr = String(dirtyFormatStr); + var defaultOptions3 = getDefaultOptions(); + var locale2 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions3.locale) !== null && _ref !== void 0 ? _ref : defaultLocale_default; + var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions3.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); + if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { + throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively"); + } + var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions3.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions3.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError("weekStartsOn must be between 0 and 6 inclusively"); + } + if (!locale2.localize) { + throw new RangeError("locale must contain localize property"); + } + if (!locale2.formatLong) { + throw new RangeError("locale must contain formatLong property"); + } + var originalDate = toDate(dirtyDate); + if (!isValid(originalDate)) { + throw new RangeError("Invalid time value"); + } + var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate); + var utcDate = subMilliseconds(originalDate, timezoneOffset); + var formatterOptions = { + firstWeekContainsDate, + weekStartsOn, + locale: locale2, + _originalDate: originalDate + }; + var result = formatStr.match(longFormattingTokensRegExp).map(function(substring) { + var firstCharacter = substring[0]; + if (firstCharacter === "p" || firstCharacter === "P") { + var longFormatter = longFormatters_default[firstCharacter]; + return longFormatter(substring, locale2.formatLong); + } + return substring; + }).join("").match(formattingTokensRegExp).map(function(substring) { + if (substring === "''") { + return "'"; + } + var firstCharacter = substring[0]; + if (firstCharacter === "'") { + return cleanEscapedString(substring); + } + var formatter = formatters_default[firstCharacter]; + if (formatter) { + if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) { + throwProtectedError(substring, dirtyFormatStr, String(dirtyDate)); + } + if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) { + throwProtectedError(substring, dirtyFormatStr, String(dirtyDate)); + } + return formatter(utcDate, substring, locale2.localize, formatterOptions); + } + if (firstCharacter.match(unescapedLatinCharacterRegExp)) { + throw new RangeError("Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"); + } + return substring; + }).join(""); + return result; +} +function cleanEscapedString(input) { + var matched = input.match(escapedStringRegExp); + if (!matched) { + return input; + } + return matched[1].replace(doubleQuoteRegExp, "'"); } -// node_modules/date-fns/esm/_lib/defaultOptions/index.js -var defaultOptions = {}; -function getDefaultOptions() { - return defaultOptions; +// node_modules/date-fns/esm/_lib/assign/index.js +function assign(target, object) { + if (target == null) { + throw new TypeError("assign requires that input parameter not be null or undefined"); + } + for (var property in object) { + if (Object.prototype.hasOwnProperty.call(object, property)) { + ; + target[property] = object[property]; + } + } + return target; } -// node_modules/date-fns/esm/startOfWeek/index.js -function startOfWeek(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - requiredArgs(1, arguments); +// node_modules/date-fns/esm/_lib/cloneObject/index.js +function cloneObject(object) { + return assign({}, object); +} + +// node_modules/date-fns/esm/formatDistance/index.js +var MINUTES_IN_DAY = 1440; +var MINUTES_IN_ALMOST_TWO_DAYS = 2520; +var MINUTES_IN_MONTH = 43200; +var MINUTES_IN_TWO_MONTHS = 86400; +function formatDistance3(dirtyDate, dirtyBaseDate, options) { + var _ref, _options$locale; + requiredArgs(2, arguments); var defaultOptions3 = getDefaultOptions(); - var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); - if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { - throw new RangeError("weekStartsOn must be between 0 and 6 inclusively"); + var locale2 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions3.locale) !== null && _ref !== void 0 ? _ref : defaultLocale_default; + if (!locale2.formatDistance) { + throw new RangeError("locale must contain formatDistance property"); + } + var comparison = compareAsc(dirtyDate, dirtyBaseDate); + if (isNaN(comparison)) { + throw new RangeError("Invalid time value"); + } + var localizeOptions = assign(cloneObject(options), { + addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix), + comparison + }); + var dateLeft; + var dateRight; + if (comparison > 0) { + dateLeft = toDate(dirtyBaseDate); + dateRight = toDate(dirtyDate); + } else { + dateLeft = toDate(dirtyDate); + dateRight = toDate(dirtyBaseDate); + } + var seconds = differenceInSeconds(dateRight, dateLeft); + var offsetInSeconds = (getTimezoneOffsetInMilliseconds(dateRight) - getTimezoneOffsetInMilliseconds(dateLeft)) / 1e3; + var minutes = Math.round((seconds - offsetInSeconds) / 60); + var months; + if (minutes < 2) { + if (options !== null && options !== void 0 && options.includeSeconds) { + if (seconds < 5) { + return locale2.formatDistance("lessThanXSeconds", 5, localizeOptions); + } else if (seconds < 10) { + return locale2.formatDistance("lessThanXSeconds", 10, localizeOptions); + } else if (seconds < 20) { + return locale2.formatDistance("lessThanXSeconds", 20, localizeOptions); + } else if (seconds < 40) { + return locale2.formatDistance("halfAMinute", 0, localizeOptions); + } else if (seconds < 60) { + return locale2.formatDistance("lessThanXMinutes", 1, localizeOptions); + } else { + return locale2.formatDistance("xMinutes", 1, localizeOptions); + } + } else { + if (minutes === 0) { + return locale2.formatDistance("lessThanXMinutes", 1, localizeOptions); + } else { + return locale2.formatDistance("xMinutes", minutes, localizeOptions); + } + } + } else if (minutes < 45) { + return locale2.formatDistance("xMinutes", minutes, localizeOptions); + } else if (minutes < 90) { + return locale2.formatDistance("aboutXHours", 1, localizeOptions); + } else if (minutes < MINUTES_IN_DAY) { + var hours = Math.round(minutes / 60); + return locale2.formatDistance("aboutXHours", hours, localizeOptions); + } else if (minutes < MINUTES_IN_ALMOST_TWO_DAYS) { + return locale2.formatDistance("xDays", 1, localizeOptions); + } else if (minutes < MINUTES_IN_MONTH) { + var days = Math.round(minutes / MINUTES_IN_DAY); + return locale2.formatDistance("xDays", days, localizeOptions); + } else if (minutes < MINUTES_IN_TWO_MONTHS) { + months = Math.round(minutes / MINUTES_IN_MONTH); + return locale2.formatDistance("aboutXMonths", months, localizeOptions); + } + months = differenceInMonths(dateRight, dateLeft); + if (months < 12) { + var nearestMonth = Math.round(minutes / MINUTES_IN_MONTH); + return locale2.formatDistance("xMonths", nearestMonth, localizeOptions); + } else { + var monthsSinceStartOfYear = months % 12; + var years = Math.floor(months / 12); + if (monthsSinceStartOfYear < 3) { + return locale2.formatDistance("aboutXYears", years, localizeOptions); + } else if (monthsSinceStartOfYear < 9) { + return locale2.formatDistance("overXYears", years, localizeOptions); + } else { + return locale2.formatDistance("almostXYears", years + 1, localizeOptions); + } } +} + +// node_modules/date-fns/esm/getDaysInMonth/index.js +function getDaysInMonth(dirtyDate) { + requiredArgs(1, arguments); var date = toDate(dirtyDate); - var day = date.getDay(); - var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; - date.setDate(date.getDate() - diff); - date.setHours(0, 0, 0, 0); - return date; + var year = date.getFullYear(); + var monthIndex = date.getMonth(); + var lastDayOfMonth2 = new Date(0); + lastDayOfMonth2.setFullYear(year, monthIndex + 1, 0); + lastDayOfMonth2.setHours(0, 0, 0, 0); + return lastDayOfMonth2.getDate(); } -// node_modules/date-fns/esm/startOfISOWeek/index.js -function startOfISOWeek(dirtyDate) { +// node_modules/date-fns/esm/getISOWeek/index.js +var MILLISECONDS_IN_WEEK4 = 6048e5; +function getISOWeek(dirtyDate) { requiredArgs(1, arguments); - return startOfWeek(dirtyDate, { - weekStartsOn: 1 - }); + var date = toDate(dirtyDate); + var diff = startOfISOWeek(date).getTime() - startOfISOWeekYear(date).getTime(); + return Math.round(diff / MILLISECONDS_IN_WEEK4) + 1; } -// node_modules/date-fns/esm/getISOWeekYear/index.js -function getISOWeekYear(dirtyDate) { +// node_modules/date-fns/esm/getTime/index.js +function getTime(dirtyDate) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var timestamp = date.getTime(); + return timestamp; +} + +// node_modules/date-fns/esm/getUnixTime/index.js +function getUnixTime(dirtyDate) { + requiredArgs(1, arguments); + return Math.floor(getTime(dirtyDate) / 1e3); +} + +// node_modules/date-fns/esm/getWeekYear/index.js +function getWeekYear(dirtyDate, options) { + var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; requiredArgs(1, arguments); var date = toDate(dirtyDate); var year = date.getFullYear(); - var fourthOfJanuaryOfNextYear = new Date(0); - fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); - fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); - var startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); - var fourthOfJanuaryOfThisYear = new Date(0); - fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); - fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); - var startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); + var defaultOptions3 = getDefaultOptions(); + var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); + if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { + throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively"); + } + var firstWeekOfNextYear = new Date(0); + firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); + firstWeekOfNextYear.setHours(0, 0, 0, 0); + var startOfNextYear = startOfWeek(firstWeekOfNextYear, options); + var firstWeekOfThisYear = new Date(0); + firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); + firstWeekOfThisYear.setHours(0, 0, 0, 0); + var startOfThisYear = startOfWeek(firstWeekOfThisYear, options); if (date.getTime() >= startOfNextYear.getTime()) { return year + 1; } else if (date.getTime() >= startOfThisYear.getTime()) { @@ -14592,2543 +15389,679 @@ function getISOWeekYear(dirtyDate) { } } -// node_modules/date-fns/esm/startOfISOWeekYear/index.js -function startOfISOWeekYear(dirtyDate) { +// node_modules/date-fns/esm/startOfWeekYear/index.js +function startOfWeekYear(dirtyDate, options) { + var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; requiredArgs(1, arguments); - var year = getISOWeekYear(dirtyDate); - var fourthOfJanuary = new Date(0); - fourthOfJanuary.setFullYear(year, 0, 4); - fourthOfJanuary.setHours(0, 0, 0, 0); - var date = startOfISOWeek(fourthOfJanuary); + var defaultOptions3 = getDefaultOptions(); + var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); + var year = getWeekYear(dirtyDate, options); + var firstWeek = new Date(0); + firstWeek.setFullYear(year, 0, firstWeekContainsDate); + firstWeek.setHours(0, 0, 0, 0); + var date = startOfWeek(firstWeek, options); return date; } -// node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js -function getTimezoneOffsetInMilliseconds(date) { - var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds())); - utcDate.setUTCFullYear(date.getFullYear()); - return date.getTime() - utcDate.getTime(); +// node_modules/date-fns/esm/getWeek/index.js +var MILLISECONDS_IN_WEEK5 = 6048e5; +function getWeek(dirtyDate, options) { + requiredArgs(1, arguments); + var date = toDate(dirtyDate); + var diff = startOfWeek(date, options).getTime() - startOfWeekYear(date, options).getTime(); + return Math.round(diff / MILLISECONDS_IN_WEEK5) + 1; } -// node_modules/date-fns/esm/startOfDay/index.js -function startOfDay(dirtyDate) { +// node_modules/date-fns/esm/lastDayOfMonth/index.js +function lastDayOfMonth(dirtyDate) { requiredArgs(1, arguments); var date = toDate(dirtyDate); + var month = date.getMonth(); + date.setFullYear(date.getFullYear(), month + 1, 0); date.setHours(0, 0, 0, 0); return date; } -// node_modules/date-fns/esm/differenceInCalendarDays/index.js -var MILLISECONDS_IN_DAY = 864e5; -function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) { - requiredArgs(2, arguments); - var startOfDayLeft = startOfDay(dirtyDateLeft); - var startOfDayRight = startOfDay(dirtyDateRight); - var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft); - var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight); - return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY); +// node_modules/date-fns/esm/getWeeksInMonth/index.js +function getWeeksInMonth(date, options) { + requiredArgs(1, arguments); + return differenceInCalendarWeeks(lastDayOfMonth(date), startOfMonth(date), options) + 1; } -// node_modules/date-fns/esm/addWeeks/index.js -function addWeeks(dirtyDate, dirtyAmount) { +// node_modules/date-fns/esm/isAfter/index.js +function isAfter(dirtyDate, dirtyDateToCompare) { requiredArgs(2, arguments); - var amount = toInteger(dirtyAmount); - var days = amount * 7; - return addDays(dirtyDate, days); + var date = toDate(dirtyDate); + var dateToCompare = toDate(dirtyDateToCompare); + return date.getTime() > dateToCompare.getTime(); } -// node_modules/date-fns/esm/addYears/index.js -function addYears(dirtyDate, dirtyAmount) { +// node_modules/date-fns/esm/isBefore/index.js +function isBefore(dirtyDate, dirtyDateToCompare) { requiredArgs(2, arguments); - var amount = toInteger(dirtyAmount); - return addMonths(dirtyDate, amount * 12); -} - -// node_modules/date-fns/esm/max/index.js -function _typeof2(obj) { - "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof2 = function _typeof5(obj2) { - return typeof obj2; - }; - } else { - _typeof2 = function _typeof5(obj2) { - return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; - }; - } - return _typeof2(obj); -} -function max(dirtyDatesArray) { - requiredArgs(1, arguments); - var datesArray; - if (dirtyDatesArray && typeof dirtyDatesArray.forEach === "function") { - datesArray = dirtyDatesArray; - } else if (_typeof2(dirtyDatesArray) === "object" && dirtyDatesArray !== null) { - datesArray = Array.prototype.slice.call(dirtyDatesArray); - } else { - return new Date(NaN); - } - var result; - datesArray.forEach(function(dirtyDate) { - var currentDate = toDate(dirtyDate); - if (result === void 0 || result < currentDate || isNaN(Number(currentDate))) { - result = currentDate; - } - }); - return result || new Date(NaN); -} - -// node_modules/date-fns/esm/min/index.js -function _typeof3(obj) { - "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof3 = function _typeof5(obj2) { - return typeof obj2; - }; - } else { - _typeof3 = function _typeof5(obj2) { - return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; - }; - } - return _typeof3(obj); -} -function min(dirtyDatesArray) { - requiredArgs(1, arguments); - var datesArray; - if (dirtyDatesArray && typeof dirtyDatesArray.forEach === "function") { - datesArray = dirtyDatesArray; - } else if (_typeof3(dirtyDatesArray) === "object" && dirtyDatesArray !== null) { - datesArray = Array.prototype.slice.call(dirtyDatesArray); - } else { - return new Date(NaN); - } - var result; - datesArray.forEach(function(dirtyDate) { - var currentDate = toDate(dirtyDate); - if (result === void 0 || result > currentDate || isNaN(currentDate.getDate())) { - result = currentDate; - } - }); - return result || new Date(NaN); + var date = toDate(dirtyDate); + var dateToCompare = toDate(dirtyDateToCompare); + return date.getTime() < dateToCompare.getTime(); } -// node_modules/date-fns/esm/compareAsc/index.js -function compareAsc(dirtyDateLeft, dirtyDateRight) { +// node_modules/date-fns/esm/isSameMonth/index.js +function isSameMonth(dirtyDateLeft, dirtyDateRight) { requiredArgs(2, arguments); var dateLeft = toDate(dirtyDateLeft); var dateRight = toDate(dirtyDateRight); - var diff = dateLeft.getTime() - dateRight.getTime(); - if (diff < 0) { - return -1; - } else if (diff > 0) { - return 1; - } else { - return diff; - } -} - -// node_modules/date-fns/esm/isSameDay/index.js -function isSameDay(dirtyDateLeft, dirtyDateRight) { - requiredArgs(2, arguments); - var dateLeftStartOfDay = startOfDay(dirtyDateLeft); - var dateRightStartOfDay = startOfDay(dirtyDateRight); - return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime(); -} - -// node_modules/date-fns/esm/isDate/index.js -function _typeof4(obj) { - "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof4 = function _typeof5(obj2) { - return typeof obj2; - }; - } else { - _typeof4 = function _typeof5(obj2) { - return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; - }; - } - return _typeof4(obj); -} -function isDate(value) { - requiredArgs(1, arguments); - return value instanceof Date || _typeof4(value) === "object" && Object.prototype.toString.call(value) === "[object Date]"; -} - -// node_modules/date-fns/esm/isValid/index.js -function isValid(dirtyDate) { - requiredArgs(1, arguments); - if (!isDate(dirtyDate) && typeof dirtyDate !== "number") { - return false; - } - var date = toDate(dirtyDate); - return !isNaN(Number(date)); + return dateLeft.getFullYear() === dateRight.getFullYear() && dateLeft.getMonth() === dateRight.getMonth(); } -// node_modules/date-fns/esm/differenceInCalendarMonths/index.js -function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) { +// node_modules/date-fns/esm/isSameYear/index.js +function isSameYear(dirtyDateLeft, dirtyDateRight) { requiredArgs(2, arguments); var dateLeft = toDate(dirtyDateLeft); var dateRight = toDate(dirtyDateRight); - var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear(); - var monthDiff = dateLeft.getMonth() - dateRight.getMonth(); - return yearDiff * 12 + monthDiff; + return dateLeft.getFullYear() === dateRight.getFullYear(); } -// node_modules/date-fns/esm/differenceInCalendarWeeks/index.js -var MILLISECONDS_IN_WEEK = 6048e5; -function differenceInCalendarWeeks(dirtyDateLeft, dirtyDateRight, options) { +// node_modules/date-fns/esm/subDays/index.js +function subDays(dirtyDate, dirtyAmount) { requiredArgs(2, arguments); - var startOfWeekLeft = startOfWeek(dirtyDateLeft, options); - var startOfWeekRight = startOfWeek(dirtyDateRight, options); - var timestampLeft = startOfWeekLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfWeekLeft); - var timestampRight = startOfWeekRight.getTime() - getTimezoneOffsetInMilliseconds(startOfWeekRight); - return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_WEEK); + var amount = toInteger(dirtyAmount); + return addDays(dirtyDate, -amount); } -// node_modules/date-fns/esm/differenceInMilliseconds/index.js -function differenceInMilliseconds(dateLeft, dateRight) { +// node_modules/date-fns/esm/setMonth/index.js +function setMonth(dirtyDate, dirtyMonth) { requiredArgs(2, arguments); - return toDate(dateLeft).getTime() - toDate(dateRight).getTime(); -} - -// node_modules/date-fns/esm/_lib/roundingMethods/index.js -var roundingMap = { - ceil: Math.ceil, - round: Math.round, - floor: Math.floor, - trunc: function trunc(value) { - return value < 0 ? Math.ceil(value) : Math.floor(value); - } -}; -var defaultRoundingMethod = "trunc"; -function getRoundingMethod(method) { - return method ? roundingMap[method] : roundingMap[defaultRoundingMethod]; + var date = toDate(dirtyDate); + var month = toInteger(dirtyMonth); + var year = date.getFullYear(); + var day = date.getDate(); + var dateWithDesiredMonth = new Date(0); + dateWithDesiredMonth.setFullYear(year, month, 15); + dateWithDesiredMonth.setHours(0, 0, 0, 0); + var daysInMonth = getDaysInMonth(dateWithDesiredMonth); + date.setMonth(month, Math.min(day, daysInMonth)); + return date; } -// node_modules/date-fns/esm/endOfDay/index.js -function endOfDay(dirtyDate) { - requiredArgs(1, arguments); +// node_modules/date-fns/esm/setYear/index.js +function setYear(dirtyDate, dirtyYear) { + requiredArgs(2, arguments); var date = toDate(dirtyDate); - date.setHours(23, 59, 59, 999); + var year = toInteger(dirtyYear); + if (isNaN(date.getTime())) { + return new Date(NaN); + } + date.setFullYear(year); return date; } -// node_modules/date-fns/esm/endOfMonth/index.js -function endOfMonth(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var month = date.getMonth(); - date.setFullYear(date.getFullYear(), month + 1, 0); - date.setHours(23, 59, 59, 999); - return date; -} - -// node_modules/date-fns/esm/isLastDayOfMonth/index.js -function isLastDayOfMonth(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - return endOfDay(date).getTime() === endOfMonth(date).getTime(); -} +// src/utils/metadata/frontmatter/fm.ts +var import_lodash = __toESM(require_lodash()); +var import_obsidian3 = require("obsidian"); -// node_modules/date-fns/esm/differenceInMonths/index.js -function differenceInMonths(dirtyDateLeft, dirtyDateRight) { - requiredArgs(2, arguments); - var dateLeft = toDate(dirtyDateLeft); - var dateRight = toDate(dirtyDateRight); - var sign = compareAsc(dateLeft, dateRight); - var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight)); - var result; - if (difference < 1) { - result = 0; - } else { - if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) { - dateLeft.setDate(30); - } - dateLeft.setMonth(dateLeft.getMonth() - sign * difference); - var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign; - if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) { - isLastMonthNotFull = false; - } - result = sign * (difference - Number(isLastMonthNotFull)); +// src/utils/json.ts +var safelyParseJSON = (json) => { + var parsed; + try { + parsed = JSON.parse(json); + } catch (e4) { } - return result === 0 ? 0 : result; -} - -// node_modules/date-fns/esm/differenceInSeconds/index.js -function differenceInSeconds(dateLeft, dateRight, options) { - requiredArgs(2, arguments); - var diff = differenceInMilliseconds(dateLeft, dateRight) / 1e3; - return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff); -} - -// node_modules/date-fns/esm/startOfMonth/index.js -function startOfMonth(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - date.setDate(1); - date.setHours(0, 0, 0, 0); - return date; -} - -// node_modules/date-fns/esm/startOfYear/index.js -function startOfYear(dirtyDate) { - requiredArgs(1, arguments); - var cleanDate = toDate(dirtyDate); - var date = new Date(0); - date.setFullYear(cleanDate.getFullYear(), 0, 1); - date.setHours(0, 0, 0, 0); - return date; -} + return parsed; +}; -// node_modules/date-fns/esm/endOfWeek/index.js -function endOfWeek(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - requiredArgs(1, arguments); - var defaultOptions3 = getDefaultOptions(); - var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); - if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { - throw new RangeError("weekStartsOn must be between 0 and 6 inclusively"); +// src/utils/parser.tsx +var parseSortStrat = (str) => { + const [a5, b4] = str.split("_"); + return [a5, b4 == "asc"]; +}; +var parseMultiString = (str) => { + var _a2; + return (_a2 = str == null ? void 0 : str.match(/(\\.|[^,])+/g)) != null ? _a2 : []; +}; +var parseLinkString = (string) => { + if (!string) + return ""; + const match2 = /\[\[(.*?)\]\]/g.exec(string); + const stringValue = (match2 == null ? void 0 : match2.length) > 1 ? match2[1].substring(0, indexOfCharElseEOS("|", match2[1])) : string; + if (stringValue) + return stringValue; + return string; +}; +var parseLinkDisplayString = (string) => { + return filePathToString(parseLinkString(string)); +}; +var parseContextDefString = (str) => { + var _a2; + if (!str || str.length == 0) + return []; + if (str.charAt(0) == "#") { + return str.split("&").map((f4) => ({ + type: "tag", + value: f4 + })); } - var date = toDate(dirtyDate); - var day = date.getDay(); - var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn); - date.setDate(date.getDate() + diff); - date.setHours(23, 59, 59, 999); - return date; -} - -// node_modules/date-fns/esm/endOfISOWeek/index.js -function endOfISOWeek(dirtyDate) { - requiredArgs(1, arguments); - return endOfWeek(dirtyDate, { - weekStartsOn: 1 - }); -} - -// node_modules/date-fns/esm/subMilliseconds/index.js -function subMilliseconds(dirtyDate, dirtyAmount) { - requiredArgs(2, arguments); - var amount = toInteger(dirtyAmount); - return addMilliseconds(dirtyDate, -amount); -} - -// node_modules/date-fns/esm/_lib/getUTCDayOfYear/index.js -var MILLISECONDS_IN_DAY2 = 864e5; -function getUTCDayOfYear(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var timestamp = date.getTime(); - date.setUTCMonth(0, 1); - date.setUTCHours(0, 0, 0, 0); - var startOfYearTimestamp = date.getTime(); - var difference = timestamp - startOfYearTimestamp; - return Math.floor(difference / MILLISECONDS_IN_DAY2) + 1; -} - -// node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js -function startOfUTCISOWeek(dirtyDate) { - requiredArgs(1, arguments); - var weekStartsOn = 1; - var date = toDate(dirtyDate); - var day = date.getUTCDay(); - var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; - date.setUTCDate(date.getUTCDate() - diff); - date.setUTCHours(0, 0, 0, 0); - return date; -} + return (_a2 = safelyParseJSON(str)) != null ? _a2 : []; +}; +var parseSpace = (spaceRow) => { + return { + ...spaceRow, + def: parseSpaceDefString(spaceRow.def) + }; +}; +var parseSpaceDefString = (str) => { + var _a2; + if (!str || str.length == 0) + return { type: "focus", folder: "", filters: [] }; + if (str.charAt(0) != "{") { + return { + folder: str, + type: "focus", + filters: [ + { + type: "any", + trueFalse: true, + filters: [ + { + type: "filemeta", + fType: "string", + field: "folder", + fn: "equals", + value: str + } + ] + } + ] + }; + } + return (_a2 = safelyParseJSON(str)) != null ? _a2 : []; +}; -// node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js -function getUTCISOWeekYear(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var year = date.getUTCFullYear(); - var fourthOfJanuaryOfNextYear = new Date(0); - fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4); - fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0); - var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear); - var fourthOfJanuaryOfThisYear = new Date(0); - fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4); - fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0); - var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear); - if (date.getTime() >= startOfNextYear.getTime()) { - return year + 1; - } else if (date.getTime() >= startOfThisYear.getTime()) { - return year; +// src/utils/metadata/dv.ts +var import_obsidian2 = require("obsidian"); +var LocationWrapper = { + fullLine: { start: "", end: "" }, + brackets: { start: "[", end: "]" }, + parenthesis: { start: "(", end: ")" } +}; +var fieldComponents = [ + "inQuote", + "inList", + "startStyle", + "attribute", + "endStyle", + "beforeSeparatorSpacer", + "afterSeparatorSpacer", + "values" +]; +var genericFieldRegex = "(?>(\\s+)?)?(?- )?(?[_\\*~`]*)(?[0-9\\w\\p{Letter}\\p{Emoji_Presentation}][-0-9\\w\\p{Letter}\\p{Emoji_Presentation}\\s]*)(?[_\\*~`]*)(?\\s*)"; +var inlineFieldRegex = (attribute) => `(?>(\\s+)?)?(?- )?(?[_\\*~\`]*)(?${attribute})(?[_\\*~\`]*)(?\\s*)::(?\\s*)`; +var fullLineRegex = new RegExp( + `^${genericFieldRegex}::\\s*(?.*)?`, + "u" +); +var inSentenceRegexBrackets = new RegExp( + `\\[${genericFieldRegex}::\\s*(?[^\\]]+)?\\]`, + "gu" +); +var inSentenceRegexPar = new RegExp( + `\\(${genericFieldRegex}::\\s*(?[^\\)]+)?\\)`, + "gu" +); +var encodeLink = (value) => { + return value ? value.replace(/\[\[/g, "\u{1F54C}\u{1F527}").replace(/\]\]/g, "\u{1F413}\u{1F400}") : value; +}; +var decodeLink = (value) => { + return value ? value.replace(/🕌🔧/gu, "[[").replace(/🐓🐀/gu, "]]") : value; +}; +var matchInlineFields = (regex, line, attribute, input, location = "fullLine") => { + const sR = line.matchAll(regex); + let next = sR.next(); + const newFields = []; + while (!next.done) { + const match2 = next.value; + if (match2.groups && Object.keys(match2.groups).every((j4) => fieldComponents.includes(j4))) { + const { + inList, + inQuote, + startStyle, + endStyle, + beforeSeparatorSpacer, + afterSeparatorSpacer, + values + } = match2.groups; + const inputArray = input ? input.replace(/(\,\s+)/g, ",").split(",") : [""]; + const newValue = inputArray.length == 1 ? inputArray[0] : `${serializeMultiDisplayString(inputArray)}`; + const start = LocationWrapper[location].start; + const end = LocationWrapper[location].end; + newFields.push({ + oldField: match2[0], + newField: `${inQuote || ""}${start}${inList || ""}${startStyle}${attribute}${endStyle}${beforeSeparatorSpacer}::${afterSeparatorSpacer}${newValue}${end}` + }); + } + next = sR.next(); + } + return newFields; +}; +async function replaceValues(plugin, fileOrFilePath, attribute, input, previousItemsCount = 0) { + var _a2, _b2; + let file; + if (fileOrFilePath instanceof import_obsidian2.TFile) { + file = fileOrFilePath; } else { - return year - 1; + const _file = plugin.app.vault.getAbstractFileByPath(fileOrFilePath); + if (_file instanceof import_obsidian2.TFile && _file.extension == "md") { + file = _file; + } else { + throw Error("path doesn't correspond to a proper file"); + } + } + const content = (await plugin.app.vault.read(file)).split("\n"); + const frontmatter = (_a2 = plugin.app.metadataCache.getFileCache(file)) == null ? void 0 : _a2.frontmatter; + const skippedLines = []; + const { + position: { start, end } + } = frontmatter ? frontmatter : { position: { start: void 0, end: void 0 } }; + const newContent = content.map((line, i4) => { + const encodedInput = encodeLink(input); + let encodedLine = encodeLink(line); + const fullLineRegex2 = new RegExp( + `^${inlineFieldRegex(attribute)}(?[^\\]]*)`, + "u" + ); + const fR = encodedLine.match(fullLineRegex2); + if ((fR == null ? void 0 : fR.groups) && Object.keys(fR.groups).every((j4) => fieldComponents.includes(j4))) { + const { + inList, + inQuote, + startStyle, + endStyle, + beforeSeparatorSpacer, + afterSeparatorSpacer, + values + } = fR.groups; + const inputArray = input ? input.replace(/(\,\s+)/g, ",").split(",").sort() : []; + let newValue; + let hiddenValue = ""; + newValue = inputArray.length == 1 ? inputArray[0] : `${serializeMultiDisplayString(inputArray)}`; + return `${inQuote || ""}${inList || ""}${startStyle}${attribute}${endStyle}${beforeSeparatorSpacer}::${afterSeparatorSpacer}${hiddenValue + newValue}`; + } else { + const newFields = []; + const inSentenceRegexBrackets2 = new RegExp( + `\\[${inlineFieldRegex(attribute)}(?[^\\]]+)?\\]`, + "gu" + ); + const inSentenceRegexPar2 = new RegExp( + `\\(${inlineFieldRegex(attribute)}(?[^\\)]+)?\\)`, + "gu" + ); + newFields.push( + ...matchInlineFields( + inSentenceRegexBrackets2, + encodedLine, + attribute, + encodedInput, + "brackets" /* brackets */ + ) + ); + newFields.push( + ...matchInlineFields( + inSentenceRegexPar2, + encodedLine, + attribute, + encodedInput, + "parenthesis" /* parenthesis */ + ) + ); + newFields.forEach((field) => { + const fieldRegex = new RegExp( + field.oldField.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), + "u" + ); + encodedLine = encodedLine.replace(fieldRegex, field.newField); + }); + return decodeLink(encodedLine); + } + }); + await plugin.app.vault.modify( + file, + newContent.filter((line, i4) => !skippedLines.includes(i4)).join("\n") + ); + const editor = (_b2 = plugin.app.workspace.getActiveViewOfType(import_obsidian2.MarkdownView)) == null ? void 0 : _b2.editor; + if (editor) { + const lineNumber = editor.getCursor().line; + editor.setCursor({ + line: editor.getCursor().line, + ch: editor.getLine(lineNumber).length + }); } } -// node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js -function startOfUTCISOWeekYear(dirtyDate) { - requiredArgs(1, arguments); - var year = getUTCISOWeekYear(dirtyDate); - var fourthOfJanuary = new Date(0); - fourthOfJanuary.setUTCFullYear(year, 0, 4); - fourthOfJanuary.setUTCHours(0, 0, 0, 0); - var date = startOfUTCISOWeek(fourthOfJanuary); - return date; -} +// src/utils/metadata/frontmatter/detectYAMLType.ts +var detectYAMLType = (value, key2) => { + if (typeof value === "string") { + if (/\/\/(\S+?(?:jpe?g|png|gif|svg))/gi.test(value) || value.includes("unsplash")) { + return "image"; + } + if (/^\d{4}-\d{2}-\d{2}$/.test(value)) { + return "date"; + } + if (key2 == "tag" || key2 == "tags") { + return "tag"; + } + if (/\[\[.*?\]\]/.test(value)) { + return "link"; + } + } else if (typeof value === "number") { + return "number"; + } else if (typeof value === "boolean") { + return "boolean"; + } else if (!value) { + return "unknown"; + } else if (Array.isArray(value) || typeof value === "string" && value.indexOf(",") > -1) { + let arrayValue = Array.isArray(value) ? value : []; + if (typeof value === "string" && value.indexOf(",") > -1) { + arrayValue = parseMultiString(value); + } + if (key2 == "tag" || key2 == "tags") { + return "tag-multi"; + } + if (arrayValue.length == 1 && Array.isArray(arrayValue[0]) && arrayValue[0].length == 1 && typeof arrayValue[0][0] === "string") { + return "link"; + } + const types = uniq(arrayValue.map((f4) => detectYAMLType(f4, key2))); + if (types.length == 1 && types[0] == "link") { + return "link-multi"; + } + return "option-multi"; + } else if (value.isLuxonDateTime) { + return "date"; + } else if (value.isLuxonDuration) { + return "duration"; + } else if (value.type == "file") { + return "link"; + } else if (typeof value === "object" && !Array.isArray(value) && value !== null) { + return "object"; + } + return "text"; +}; -// node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js -var MILLISECONDS_IN_WEEK2 = 6048e5; -function getUTCISOWeek(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); - return Math.round(diff / MILLISECONDS_IN_WEEK2) + 1; -} +// src/utils/metadata/frontmatter/frontMatterKeys.ts +var frontMatterKeys = (fm) => { + return Object.keys(fm != null ? fm : {}).filter((f4) => f4 != "position").filter((f4) => f4 != "tag" && f4 != "tags"); +}; -// node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js -function startOfUTCWeek(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - requiredArgs(1, arguments); - var defaultOptions3 = getDefaultOptions(); - var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); - if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { - throw new RangeError("weekStartsOn must be between 0 and 6 inclusively"); +// src/utils/metadata/frontmatter/yamlTypeToMDBType.ts +var yamlTypeToMDBType = (YAMLtype) => { + switch (YAMLtype) { + case "duration": + return "text"; + break; + case "unknown": + return "text"; + break; } - var date = toDate(dirtyDate); - var day = date.getUTCDay(); - var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; - date.setUTCDate(date.getUTCDate() - diff); - date.setUTCHours(0, 0, 0, 0); - return date; -} + return YAMLtype; +}; -// node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js -function getUTCWeekYear(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var year = date.getUTCFullYear(); - var defaultOptions3 = getDefaultOptions(); - var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); - if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { - throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively"); +// src/utils/metadata/frontmatter/fm.ts +var saveContextToFile = (file, cols, context, plugin) => { + if (app.fileManager.processFrontMatter) { + app.fileManager.processFrontMatter(file, (frontmatter) => { + Object.keys(context).filter( + (f4) => cols.find((c4) => c4.name == f4) && cols.find((c4) => c4.name == f4).hidden != "true" && !cols.find((c4) => c4.name == f4).type.contains("file") && context[f4] + ).forEach((f4) => { + const col = cols.find((c4) => c4.name == f4); + frontmatter[f4] = valueForFrontmatter(col.type, context[f4]); + frontmatter[f4] = valueForFrontmatter(col.type, context[f4]); + }); + }); } - var firstWeekOfNextYear = new Date(0); - firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate); - firstWeekOfNextYear.setUTCHours(0, 0, 0, 0); - var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options); - var firstWeekOfThisYear = new Date(0); - firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate); - firstWeekOfThisYear.setUTCHours(0, 0, 0, 0); - var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options); - if (date.getTime() >= startOfNextYear.getTime()) { - return year + 1; - } else if (date.getTime() >= startOfThisYear.getTime()) { - return year; - } else { - return year - 1; +}; +var frontMatterForFile = (file) => { + let currentCache; + if (file instanceof import_obsidian3.TFile && app.metadataCache.getFileCache(file) !== null) { + currentCache = app.metadataCache.getFileCache(file); } -} - -// node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js -function startOfUTCWeekYear(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - requiredArgs(1, arguments); - var defaultOptions3 = getDefaultOptions(); - var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); - var year = getUTCWeekYear(dirtyDate, options); - var firstWeek = new Date(0); - firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate); - firstWeek.setUTCHours(0, 0, 0, 0); - var date = startOfUTCWeek(firstWeek, options); - return date; -} - -// node_modules/date-fns/esm/_lib/getUTCWeek/index.js -var MILLISECONDS_IN_WEEK3 = 6048e5; -function getUTCWeek(dirtyDate, options) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); - return Math.round(diff / MILLISECONDS_IN_WEEK3) + 1; -} - -// node_modules/date-fns/esm/_lib/addLeadingZeros/index.js -function addLeadingZeros(number, targetLength) { - var sign = number < 0 ? "-" : ""; - var output = Math.abs(number).toString(); - while (output.length < targetLength) { - output = "0" + output; + return currentCache == null ? void 0 : currentCache.frontmatter; +}; +var mergeTableData = (mdb, yamlmdb, types) => { + return { + ...mdb, + cols: [ + ...mdb.cols, + ...yamlmdb.cols.filter( + (f4) => !mdb.cols.find((g4) => g4.name.toLowerCase() == f4.toLowerCase()) + ).map((f4) => ({ + name: f4, + schemaId: mdb.schema.id, + type: yamlTypeToMDBType(types[f4]) + })) + ].filter(onlyUniquePropCaseInsensitive("name")), + rows: mdb.rows.map((r3) => { + const fmRow = yamlmdb.rows.find((f4) => f4.File == r3.File); + if (fmRow) { + return { + ...r3, + ...fmRow + }; + } + return r3; + }) + }; +}; +var guestimateTypes = (_files, plugin, dv) => { + const typesArray = _files.map((f4) => getAbstractFileAtPath(app, f4)).filter((f4) => f4).map((k5) => { + const fm = dv && plugin.dataViewAPI() ? plugin.dataViewAPI().page(k5.path) : frontMatterForFile(k5); + const fmKeys = dv ? Object.keys(fm != null ? fm : {}).filter( + (f4, i4, self2) => !self2.find( + (g4, j4) => g4.toLowerCase().replace(/\s/g, "-") == f4.toLowerCase().replace(/\s/g, "-") && i4 > j4 + ) ? true : false + ).filter((f4) => f4 != "file") : frontMatterKeys(fm); + return fmKeys.reduce( + (pk, ck) => ({ ...pk, [ck]: detectYAMLType(fm[ck], ck) }), + {} + ); + }); + const types = typesArray.reduce( + (p3, c4) => { + const newSet = Object.keys(c4).reduce( + (pk, ck) => { + var _a2; + return { ...pk, [ck]: [...(_a2 = p3 == null ? void 0 : p3[ck]) != null ? _a2 : [], c4[ck]] }; + }, + { ...p3 } + ); + return newSet; + }, + {} + ); + const guessType = (ts) => { + return import_lodash.default.head((0, import_lodash.default)(ts).countBy().entries().maxBy(import_lodash.default.last)); + }; + const guessedTypes = Object.keys(types).reduce((p3, c4) => { + return { ...p3, [c4]: guessType(types[c4]) }; + }, {}); + return guessedTypes; +}; +var valueForFrontmatter = (type, value) => { + if (type == "number") { + return parseFloat(value); + } else if (type == "boolean") { + return value == "true"; + } else if (type.contains("multi")) { + return parseMultiString(value).map( + (f4) => valueForFrontmatter(type.replace("-multi", ""), f4) + ); + } else if (type.contains("link") || type.contains("context")) { + return `[[${value}]]`; } - return sign + output; -} - -// node_modules/date-fns/esm/_lib/format/lightFormatters/index.js -var formatters = { - y: function y3(date, token) { - var signedYear = date.getUTCFullYear(); - var year = signedYear > 0 ? signedYear : 1 - signedYear; - return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); - }, - M: function M3(date, token) { - var month = date.getUTCMonth(); - return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); - }, - d: function d3(date, token) { - return addLeadingZeros(date.getUTCDate(), token.length); - }, - a: function a3(date, token) { - var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? "pm" : "am"; - switch (token) { - case "a": - case "aa": - return dayPeriodEnumValue.toUpperCase(); - case "aaa": - return dayPeriodEnumValue; - case "aaaaa": - return dayPeriodEnumValue[0]; - case "aaaa": - default: - return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; + return value; +}; +var valueForDataview = (type, value) => { + if (type.contains("link") || type.contains("context")) { + return `[[${value}]]`; + } + return value; +}; +var renameFrontmatterKey = (plugin, path, key2, name) => { + const afile = getAbstractFileAtPath(app, path); + if (afile && afile instanceof import_obsidian3.TFile) { + if (app.fileManager.processFrontMatter) { + app.fileManager.processFrontMatter(afile, (frontmatter) => { + if (key2 in frontmatter) { + frontmatter[name] = frontmatter[key2]; + delete frontmatter[key2]; + } + }); } - }, - h: function h3(date, token) { - return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length); - }, - H: function H3(date, token) { - return addLeadingZeros(date.getUTCHours(), token.length); - }, - m: function m3(date, token) { - return addLeadingZeros(date.getUTCMinutes(), token.length); - }, - s: function s3(date, token) { - return addLeadingZeros(date.getUTCSeconds(), token.length); - }, - S: function S2(date, token) { - var numberOfDigits = token.length; - var milliseconds = date.getUTCMilliseconds(); - var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3)); - return addLeadingZeros(fractionalSeconds, token.length); } }; -var lightFormatters_default = formatters; - -// node_modules/date-fns/esm/_lib/format/formatters/index.js -var dayPeriodEnum = { - am: "am", - pm: "pm", - midnight: "midnight", - noon: "noon", - morning: "morning", - afternoon: "afternoon", - evening: "evening", - night: "night" +var defaultValueForType = (value, type) => { + if (type == "date") { + return format(Date.now(), "yyyy-MM-dd"); + } + if (type == "number") { + return 0; + } + if (type == "boolean") { + return true; + } + if (type == "link") { + return "[[Select Note]]"; + } + if (type == "option") { + return "one, two"; + } + if (type == "text") { + return " "; + } + if (type == "image") { + return "https://images.unsplash.com/photo-1675789652575-0a5d2425b6c2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80"; + } }; -var formatters2 = { - G: function G2(date, token, localize2) { - var era = date.getUTCFullYear() > 0 ? 1 : 0; - switch (token) { - case "G": - case "GG": - case "GGG": - return localize2.era(era, { - width: "abbreviated" - }); - case "GGGGG": - return localize2.era(era, { - width: "narrow" - }); - case "GGGG": - default: - return localize2.era(era, { - width: "wide" - }); - } - }, - y: function y4(date, token, localize2) { - if (token === "yo") { - var signedYear = date.getUTCFullYear(); - var year = signedYear > 0 ? signedYear : 1 - signedYear; - return localize2.ordinalNumber(year, { - unit: "year" +var changeFrontmatterType = (plugin, path, key2, type) => { + const afile = getAbstractFileAtPath(app, path); + if (afile && afile instanceof import_obsidian3.TFile) { + if (app.fileManager.processFrontMatter) { + app.fileManager.processFrontMatter(afile, (frontmatter) => { + if (key2 in frontmatter) { + frontmatter[key2] = defaultValueForType(frontmatter[key2], type); + } }); } - return lightFormatters_default.y(date, token); - }, - Y: function Y2(date, token, localize2, options) { - var signedWeekYear = getUTCWeekYear(date, options); - var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; - if (token === "YY") { - var twoDigitYear = weekYear % 100; - return addLeadingZeros(twoDigitYear, 2); - } - if (token === "Yo") { - return localize2.ordinalNumber(weekYear, { - unit: "year" + } +}; +var deleteFrontmatterValue = (plugin, path, key2) => { + const afile = getAbstractFileAtPath(app, path); + if (afile && afile instanceof import_obsidian3.TFile) { + if (app.fileManager.processFrontMatter) { + app.fileManager.processFrontMatter(afile, (frontmatter) => { + if (plugin.dataViewAPI()) { + if (plugin.dataViewAPI().page(path)[key2] && !frontmatter[key2]) { + replaceValues(plugin, path, key2, ""); + } else { + if (key2 in frontmatter) { + delete frontmatter[key2]; + } + } + } else { + if (key2 in frontmatter) { + delete frontmatter[key2]; + } + } }); } - return addLeadingZeros(weekYear, token.length); - }, - R: function R2(date, token) { - var isoWeekYear = getUTCISOWeekYear(date); - return addLeadingZeros(isoWeekYear, token.length); - }, - u: function u3(date, token) { - var year = date.getUTCFullYear(); - return addLeadingZeros(year, token.length); - }, - Q: function Q2(date, token, localize2) { - var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); - switch (token) { - case "Q": - return String(quarter); - case "QQ": - return addLeadingZeros(quarter, 2); - case "Qo": - return localize2.ordinalNumber(quarter, { - unit: "quarter" - }); - case "QQQ": - return localize2.quarter(quarter, { - width: "abbreviated", - context: "formatting" - }); - case "QQQQQ": - return localize2.quarter(quarter, { - width: "narrow", - context: "formatting" - }); - case "QQQQ": - default: - return localize2.quarter(quarter, { - width: "wide", - context: "formatting" - }); - } - }, - q: function q4(date, token, localize2) { - var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); - switch (token) { - case "q": - return String(quarter); - case "qq": - return addLeadingZeros(quarter, 2); - case "qo": - return localize2.ordinalNumber(quarter, { - unit: "quarter" - }); - case "qqq": - return localize2.quarter(quarter, { - width: "abbreviated", - context: "standalone" - }); - case "qqqqq": - return localize2.quarter(quarter, { - width: "narrow", - context: "standalone" - }); - case "qqqq": - default: - return localize2.quarter(quarter, { - width: "wide", - context: "standalone" - }); - } - }, - M: function M4(date, token, localize2) { - var month = date.getUTCMonth(); - switch (token) { - case "M": - case "MM": - return lightFormatters_default.M(date, token); - case "Mo": - return localize2.ordinalNumber(month + 1, { - unit: "month" - }); - case "MMM": - return localize2.month(month, { - width: "abbreviated", - context: "formatting" - }); - case "MMMMM": - return localize2.month(month, { - width: "narrow", - context: "formatting" - }); - case "MMMM": - default: - return localize2.month(month, { - width: "wide", - context: "formatting" - }); + } +}; +var saveFrontmatterValue = (plugin, path, key2, value, type, forceSave) => { + let afile = getAbstractFileAtPath(app, path); + const fileCache = plugin.index.filesIndex.get(path); + if (afile && fileCache) { + if (fileCache.isFolder && fileCache.folderNote) { + afile = getAbstractFileAtPath(app, fileCache.folderNote.folderNotePath); } - }, - L: function L3(date, token, localize2) { - var month = date.getUTCMonth(); - switch (token) { - case "L": - return String(month + 1); - case "LL": - return addLeadingZeros(month + 1, 2); - case "Lo": - return localize2.ordinalNumber(month + 1, { - unit: "month" - }); - case "LLL": - return localize2.month(month, { - width: "abbreviated", - context: "standalone" - }); - case "LLLLL": - return localize2.month(month, { - width: "narrow", - context: "standalone" - }); - case "LLLL": - default: - return localize2.month(month, { - width: "wide", - context: "standalone" + if (afile instanceof import_obsidian3.TFile) { + if (app.fileManager.processFrontMatter) { + app.fileManager.processFrontMatter(afile, (frontmatter) => { + var _a2; + if (plugin.dataViewAPI()) { + if (((_a2 = plugin.dataViewAPI().page(afile.path)) == null ? void 0 : _a2[key2]) && !frontmatter[key2]) { + replaceValues(plugin, afile.path, key2, valueForDataview(type, value)); + } else { + if (key2 in frontmatter || forceSave) { + frontmatter[key2] = valueForFrontmatter(type, value); + } + } + } else { + if (key2 in frontmatter || forceSave) { + frontmatter[key2] = valueForFrontmatter(type, value); + } + } }); + } } - }, - w: function w4(date, token, localize2, options) { - var week = getUTCWeek(date, options); - if (token === "wo") { - return localize2.ordinalNumber(week, { - unit: "week" - }); + } +}; + +// src/components/FileContextView/NoteBannerView.tsx +var NoteBannerView = (props2) => { + const [banner, setBanner] = h2(null); + p2(() => { + var _a2; + if (props2.link) { + const newBanner = (_a2 = getAbstractFileAtPath(app, props2.link)) != null ? _a2 : props2.link; + setBanner(newBanner); + } else { + setBanner(null); } - return addLeadingZeros(week, token.length); - }, - I: function I3(date, token, localize2) { - var isoWeek = getUTCISOWeek(date); - if (token === "Io") { - return localize2.ordinalNumber(isoWeek, { - unit: "week" + }, [props2.link]); + const triggerBannerContextMenu = (e4) => { + if (!props2.file) + return; + e4.preventDefault(); + const fileMenu = new import_obsidian4.Menu(); + fileMenu.addSeparator(); + fileMenu.addItem((menuItem) => { + menuItem.setTitle(i18n_default.buttons.changeBanner); + menuItem.setIcon("lucide-image"); + menuItem.onClick((ev) => { + let vaultChangeModal = new imageModal( + props2.plugin, + props2.plugin.app, + (image) => saveFrontmatterValue( + props2.plugin, + props2.file.path, + FMBannerKey, + image, + "image", + true + ) + ); + vaultChangeModal.open(); }); - } - return addLeadingZeros(isoWeek, token.length); - }, - d: function d4(date, token, localize2) { - if (token === "do") { - return localize2.ordinalNumber(date.getUTCDate(), { - unit: "date" + }); + fileMenu.addItem((menuItem) => { + menuItem.setTitle(i18n_default.buttons.removeBanner); + menuItem.setIcon("lucide-file-minus"); + menuItem.onClick((ev) => { + deleteFrontmatterValue(props2.plugin, props2.file.path, FMBannerKey); }); - } - return lightFormatters_default.d(date, token); - }, - D: function D3(date, token, localize2) { - var dayOfYear = getUTCDayOfYear(date); - if (token === "Do") { - return localize2.ordinalNumber(dayOfYear, { - unit: "dayOfYear" + }); + if (isMouseEvent(e4)) { + fileMenu.showAtPosition({ x: e4.pageX, y: e4.pageY }); + } else { + fileMenu.showAtPosition({ + x: e4.nativeEvent.locationX, + y: e4.nativeEvent.locationY }); } - return addLeadingZeros(dayOfYear, token.length); - }, - E: function E3(date, token, localize2) { - var dayOfWeek = date.getUTCDay(); - switch (token) { - case "E": - case "EE": - case "EEE": - return localize2.day(dayOfWeek, { - width: "abbreviated", - context: "formatting" - }); - case "EEEEE": - return localize2.day(dayOfWeek, { - width: "narrow", - context: "formatting" - }); - case "EEEEEE": - return localize2.day(dayOfWeek, { - width: "short", - context: "formatting" - }); - case "EEEE": - default: - return localize2.day(dayOfWeek, { - width: "wide", - context: "formatting" - }); - } - }, - e: function e3(date, token, localize2, options) { - var dayOfWeek = date.getUTCDay(); - var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; - switch (token) { - case "e": - return String(localDayOfWeek); - case "ee": - return addLeadingZeros(localDayOfWeek, 2); - case "eo": - return localize2.ordinalNumber(localDayOfWeek, { - unit: "day" - }); - case "eee": - return localize2.day(dayOfWeek, { - width: "abbreviated", - context: "formatting" - }); - case "eeeee": - return localize2.day(dayOfWeek, { - width: "narrow", - context: "formatting" - }); - case "eeeeee": - return localize2.day(dayOfWeek, { - width: "short", - context: "formatting" - }); - case "eeee": - default: - return localize2.day(dayOfWeek, { - width: "wide", - context: "formatting" - }); - } - }, - c: function c3(date, token, localize2, options) { - var dayOfWeek = date.getUTCDay(); - var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; - switch (token) { - case "c": - return String(localDayOfWeek); - case "cc": - return addLeadingZeros(localDayOfWeek, token.length); - case "co": - return localize2.ordinalNumber(localDayOfWeek, { - unit: "day" - }); - case "ccc": - return localize2.day(dayOfWeek, { - width: "abbreviated", - context: "standalone" - }); - case "ccccc": - return localize2.day(dayOfWeek, { - width: "narrow", - context: "standalone" - }); - case "cccccc": - return localize2.day(dayOfWeek, { - width: "short", - context: "standalone" - }); - case "cccc": - default: - return localize2.day(dayOfWeek, { - width: "wide", - context: "standalone" - }); - } - }, - i: function i3(date, token, localize2) { - var dayOfWeek = date.getUTCDay(); - var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; - switch (token) { - case "i": - return String(isoDayOfWeek); - case "ii": - return addLeadingZeros(isoDayOfWeek, token.length); - case "io": - return localize2.ordinalNumber(isoDayOfWeek, { - unit: "day" - }); - case "iii": - return localize2.day(dayOfWeek, { - width: "abbreviated", - context: "formatting" - }); - case "iiiii": - return localize2.day(dayOfWeek, { - width: "narrow", - context: "formatting" - }); - case "iiiiii": - return localize2.day(dayOfWeek, { - width: "short", - context: "formatting" - }); - case "iiii": - default: - return localize2.day(dayOfWeek, { - width: "wide", - context: "formatting" - }); - } - }, - a: function a4(date, token, localize2) { - var hours = date.getUTCHours(); - var dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; - switch (token) { - case "a": - case "aa": - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "abbreviated", - context: "formatting" - }); - case "aaa": - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "abbreviated", - context: "formatting" - }).toLowerCase(); - case "aaaaa": - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "narrow", - context: "formatting" - }); - case "aaaa": - default: - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "wide", - context: "formatting" - }); - } - }, - b: function b3(date, token, localize2) { - var hours = date.getUTCHours(); - var dayPeriodEnumValue; - if (hours === 12) { - dayPeriodEnumValue = dayPeriodEnum.noon; - } else if (hours === 0) { - dayPeriodEnumValue = dayPeriodEnum.midnight; - } else { - dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; - } - switch (token) { - case "b": - case "bb": - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "abbreviated", - context: "formatting" - }); - case "bbb": - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "abbreviated", - context: "formatting" - }).toLowerCase(); - case "bbbbb": - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "narrow", - context: "formatting" - }); - case "bbbb": - default: - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "wide", - context: "formatting" - }); - } - }, - B: function B4(date, token, localize2) { - var hours = date.getUTCHours(); - var dayPeriodEnumValue; - if (hours >= 17) { - dayPeriodEnumValue = dayPeriodEnum.evening; - } else if (hours >= 12) { - dayPeriodEnumValue = dayPeriodEnum.afternoon; - } else if (hours >= 4) { - dayPeriodEnumValue = dayPeriodEnum.morning; - } else { - dayPeriodEnumValue = dayPeriodEnum.night; - } - switch (token) { - case "B": - case "BB": - case "BBB": - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "abbreviated", - context: "formatting" - }); - case "BBBBB": - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "narrow", - context: "formatting" - }); - case "BBBB": - default: - return localize2.dayPeriod(dayPeriodEnumValue, { - width: "wide", - context: "formatting" - }); - } - }, - h: function h4(date, token, localize2) { - if (token === "ho") { - var hours = date.getUTCHours() % 12; - if (hours === 0) - hours = 12; - return localize2.ordinalNumber(hours, { - unit: "hour" - }); - } - return lightFormatters_default.h(date, token); - }, - H: function H4(date, token, localize2) { - if (token === "Ho") { - return localize2.ordinalNumber(date.getUTCHours(), { - unit: "hour" - }); - } - return lightFormatters_default.H(date, token); - }, - K: function K2(date, token, localize2) { - var hours = date.getUTCHours() % 12; - if (token === "Ko") { - return localize2.ordinalNumber(hours, { - unit: "hour" - }); - } - return addLeadingZeros(hours, token.length); - }, - k: function k4(date, token, localize2) { - var hours = date.getUTCHours(); - if (hours === 0) - hours = 24; - if (token === "ko") { - return localize2.ordinalNumber(hours, { - unit: "hour" - }); - } - return addLeadingZeros(hours, token.length); - }, - m: function m4(date, token, localize2) { - if (token === "mo") { - return localize2.ordinalNumber(date.getUTCMinutes(), { - unit: "minute" - }); - } - return lightFormatters_default.m(date, token); - }, - s: function s4(date, token, localize2) { - if (token === "so") { - return localize2.ordinalNumber(date.getUTCSeconds(), { - unit: "second" - }); - } - return lightFormatters_default.s(date, token); - }, - S: function S3(date, token) { - return lightFormatters_default.S(date, token); - }, - X: function X2(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timezoneOffset = originalDate.getTimezoneOffset(); - if (timezoneOffset === 0) { - return "Z"; - } - switch (token) { - case "X": - return formatTimezoneWithOptionalMinutes(timezoneOffset); - case "XXXX": - case "XX": - return formatTimezone(timezoneOffset); - case "XXXXX": - case "XXX": - default: - return formatTimezone(timezoneOffset, ":"); - } - }, - x: function x4(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timezoneOffset = originalDate.getTimezoneOffset(); - switch (token) { - case "x": - return formatTimezoneWithOptionalMinutes(timezoneOffset); - case "xxxx": - case "xx": - return formatTimezone(timezoneOffset); - case "xxxxx": - case "xxx": - default: - return formatTimezone(timezoneOffset, ":"); - } - }, - O: function O3(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timezoneOffset = originalDate.getTimezoneOffset(); - switch (token) { - case "O": - case "OO": - case "OOO": - return "GMT" + formatTimezoneShort(timezoneOffset, ":"); - case "OOOO": - default: - return "GMT" + formatTimezone(timezoneOffset, ":"); - } - }, - z: function z4(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timezoneOffset = originalDate.getTimezoneOffset(); - switch (token) { - case "z": - case "zz": - case "zzz": - return "GMT" + formatTimezoneShort(timezoneOffset, ":"); - case "zzzz": - default: - return "GMT" + formatTimezone(timezoneOffset, ":"); - } - }, - t: function t3(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timestamp = Math.floor(originalDate.getTime() / 1e3); - return addLeadingZeros(timestamp, token.length); - }, - T: function T5(date, token, _localize, options) { - var originalDate = options._originalDate || date; - var timestamp = originalDate.getTime(); - return addLeadingZeros(timestamp, token.length); - } -}; -function formatTimezoneShort(offset, dirtyDelimiter) { - var sign = offset > 0 ? "-" : "+"; - var absOffset = Math.abs(offset); - var hours = Math.floor(absOffset / 60); - var minutes = absOffset % 60; - if (minutes === 0) { - return sign + String(hours); - } - var delimiter = dirtyDelimiter || ""; - return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); -} -function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) { - if (offset % 60 === 0) { - var sign = offset > 0 ? "-" : "+"; - return sign + addLeadingZeros(Math.abs(offset) / 60, 2); - } - return formatTimezone(offset, dirtyDelimiter); -} -function formatTimezone(offset, dirtyDelimiter) { - var delimiter = dirtyDelimiter || ""; - var sign = offset > 0 ? "-" : "+"; - var absOffset = Math.abs(offset); - var hours = addLeadingZeros(Math.floor(absOffset / 60), 2); - var minutes = addLeadingZeros(absOffset % 60, 2); - return sign + hours + delimiter + minutes; -} -var formatters_default = formatters2; - -// node_modules/date-fns/esm/_lib/format/longFormatters/index.js -var dateLongFormatter = function dateLongFormatter2(pattern, formatLong2) { - switch (pattern) { - case "P": - return formatLong2.date({ - width: "short" - }); - case "PP": - return formatLong2.date({ - width: "medium" - }); - case "PPP": - return formatLong2.date({ - width: "long" - }); - case "PPPP": - default: - return formatLong2.date({ - width: "full" - }); - } -}; -var timeLongFormatter = function timeLongFormatter2(pattern, formatLong2) { - switch (pattern) { - case "p": - return formatLong2.time({ - width: "short" - }); - case "pp": - return formatLong2.time({ - width: "medium" - }); - case "ppp": - return formatLong2.time({ - width: "long" - }); - case "pppp": - default: - return formatLong2.time({ - width: "full" - }); - } -}; -var dateTimeLongFormatter = function dateTimeLongFormatter2(pattern, formatLong2) { - var matchResult = pattern.match(/(P+)(p+)?/) || []; - var datePattern = matchResult[1]; - var timePattern = matchResult[2]; - if (!timePattern) { - return dateLongFormatter(pattern, formatLong2); - } - var dateTimeFormat; - switch (datePattern) { - case "P": - dateTimeFormat = formatLong2.dateTime({ - width: "short" - }); - break; - case "PP": - dateTimeFormat = formatLong2.dateTime({ - width: "medium" - }); - break; - case "PPP": - dateTimeFormat = formatLong2.dateTime({ - width: "long" - }); - break; - case "PPPP": - default: - dateTimeFormat = formatLong2.dateTime({ - width: "full" - }); - break; - } - return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); -}; -var longFormatters = { - p: timeLongFormatter, - P: dateTimeLongFormatter -}; -var longFormatters_default = longFormatters; - -// node_modules/date-fns/esm/_lib/protectedTokens/index.js -var protectedDayOfYearTokens = ["D", "DD"]; -var protectedWeekYearTokens = ["YY", "YYYY"]; -function isProtectedDayOfYearToken(token) { - return protectedDayOfYearTokens.indexOf(token) !== -1; -} -function isProtectedWeekYearToken(token) { - return protectedWeekYearTokens.indexOf(token) !== -1; -} -function throwProtectedError(token, format2, input) { - if (token === "YYYY") { - throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); - } else if (token === "YY") { - throw new RangeError("Use `yy` instead of `YY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); - } else if (token === "D") { - throw new RangeError("Use `d` instead of `D` (in `".concat(format2, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); - } else if (token === "DD") { - throw new RangeError("Use `dd` instead of `DD` (in `".concat(format2, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md")); - } -} - -// node_modules/date-fns/esm/locale/en-US/_lib/formatDistance/index.js -var formatDistanceLocale = { - lessThanXSeconds: { - one: "less than a second", - other: "less than {{count}} seconds" - }, - xSeconds: { - one: "1 second", - other: "{{count}} seconds" - }, - halfAMinute: "half a minute", - lessThanXMinutes: { - one: "less than a minute", - other: "less than {{count}} minutes" - }, - xMinutes: { - one: "1 minute", - other: "{{count}} minutes" - }, - aboutXHours: { - one: "about 1 hour", - other: "about {{count}} hours" - }, - xHours: { - one: "1 hour", - other: "{{count}} hours" - }, - xDays: { - one: "1 day", - other: "{{count}} days" - }, - aboutXWeeks: { - one: "about 1 week", - other: "about {{count}} weeks" - }, - xWeeks: { - one: "1 week", - other: "{{count}} weeks" - }, - aboutXMonths: { - one: "about 1 month", - other: "about {{count}} months" - }, - xMonths: { - one: "1 month", - other: "{{count}} months" - }, - aboutXYears: { - one: "about 1 year", - other: "about {{count}} years" - }, - xYears: { - one: "1 year", - other: "{{count}} years" - }, - overXYears: { - one: "over 1 year", - other: "over {{count}} years" - }, - almostXYears: { - one: "almost 1 year", - other: "almost {{count}} years" - } -}; -var formatDistance = function formatDistance2(token, count2, options) { - var result; - var tokenValue = formatDistanceLocale[token]; - if (typeof tokenValue === "string") { - result = tokenValue; - } else if (count2 === 1) { - result = tokenValue.one; - } else { - result = tokenValue.other.replace("{{count}}", count2.toString()); - } - if (options !== null && options !== void 0 && options.addSuffix) { - if (options.comparison && options.comparison > 0) { - return "in " + result; - } else { - return result + " ago"; - } - } - return result; -}; -var formatDistance_default = formatDistance; - -// node_modules/date-fns/esm/locale/_lib/buildFormatLongFn/index.js -function buildFormatLongFn(args) { - return function() { - var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - var width = options.width ? String(options.width) : args.defaultWidth; - var format2 = args.formats[width] || args.formats[args.defaultWidth]; - return format2; - }; -} - -// node_modules/date-fns/esm/locale/en-US/_lib/formatLong/index.js -var dateFormats = { - full: "EEEE, MMMM do, y", - long: "MMMM do, y", - medium: "MMM d, y", - short: "MM/dd/yyyy" -}; -var timeFormats = { - full: "h:mm:ss a zzzz", - long: "h:mm:ss a z", - medium: "h:mm:ss a", - short: "h:mm a" -}; -var dateTimeFormats = { - full: "{{date}} 'at' {{time}}", - long: "{{date}} 'at' {{time}}", - medium: "{{date}}, {{time}}", - short: "{{date}}, {{time}}" -}; -var formatLong = { - date: buildFormatLongFn({ - formats: dateFormats, - defaultWidth: "full" - }), - time: buildFormatLongFn({ - formats: timeFormats, - defaultWidth: "full" - }), - dateTime: buildFormatLongFn({ - formats: dateTimeFormats, - defaultWidth: "full" - }) -}; -var formatLong_default = formatLong; - -// node_modules/date-fns/esm/locale/en-US/_lib/formatRelative/index.js -var formatRelativeLocale = { - lastWeek: "'last' eeee 'at' p", - yesterday: "'yesterday at' p", - today: "'today at' p", - tomorrow: "'tomorrow at' p", - nextWeek: "eeee 'at' p", - other: "P" -}; -var formatRelative = function formatRelative2(token, _date, _baseDate, _options) { - return formatRelativeLocale[token]; -}; -var formatRelative_default = formatRelative; - -// node_modules/date-fns/esm/locale/_lib/buildLocalizeFn/index.js -function buildLocalizeFn(args) { - return function(dirtyIndex, options) { - var context = options !== null && options !== void 0 && options.context ? String(options.context) : "standalone"; - var valuesArray; - if (context === "formatting" && args.formattingValues) { - var defaultWidth = args.defaultFormattingWidth || args.defaultWidth; - var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth; - valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; - } else { - var _defaultWidth = args.defaultWidth; - var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth; - valuesArray = args.values[_width] || args.values[_defaultWidth]; - } - var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; - return valuesArray[index]; - }; -} - -// node_modules/date-fns/esm/locale/en-US/_lib/localize/index.js -var eraValues = { - narrow: ["B", "A"], - abbreviated: ["BC", "AD"], - wide: ["Before Christ", "Anno Domini"] -}; -var quarterValues = { - narrow: ["1", "2", "3", "4"], - abbreviated: ["Q1", "Q2", "Q3", "Q4"], - wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] -}; -var monthValues = { - narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], - abbreviated: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], - wide: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] -}; -var dayValues = { - narrow: ["S", "M", "T", "W", "T", "F", "S"], - short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], - abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], - wide: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] -}; -var dayPeriodValues = { - narrow: { - am: "a", - pm: "p", - midnight: "mi", - noon: "n", - morning: "morning", - afternoon: "afternoon", - evening: "evening", - night: "night" - }, - abbreviated: { - am: "AM", - pm: "PM", - midnight: "midnight", - noon: "noon", - morning: "morning", - afternoon: "afternoon", - evening: "evening", - night: "night" - }, - wide: { - am: "a.m.", - pm: "p.m.", - midnight: "midnight", - noon: "noon", - morning: "morning", - afternoon: "afternoon", - evening: "evening", - night: "night" - } -}; -var formattingDayPeriodValues = { - narrow: { - am: "a", - pm: "p", - midnight: "mi", - noon: "n", - morning: "in the morning", - afternoon: "in the afternoon", - evening: "in the evening", - night: "at night" - }, - abbreviated: { - am: "AM", - pm: "PM", - midnight: "midnight", - noon: "noon", - morning: "in the morning", - afternoon: "in the afternoon", - evening: "in the evening", - night: "at night" - }, - wide: { - am: "a.m.", - pm: "p.m.", - midnight: "midnight", - noon: "noon", - morning: "in the morning", - afternoon: "in the afternoon", - evening: "in the evening", - night: "at night" - } -}; -var ordinalNumber = function ordinalNumber2(dirtyNumber, _options) { - var number = Number(dirtyNumber); - var rem100 = number % 100; - if (rem100 > 20 || rem100 < 10) { - switch (rem100 % 10) { - case 1: - return number + "st"; - case 2: - return number + "nd"; - case 3: - return number + "rd"; - } - } - return number + "th"; -}; -var localize = { - ordinalNumber, - era: buildLocalizeFn({ - values: eraValues, - defaultWidth: "wide" - }), - quarter: buildLocalizeFn({ - values: quarterValues, - defaultWidth: "wide", - argumentCallback: function argumentCallback(quarter) { - return quarter - 1; - } - }), - month: buildLocalizeFn({ - values: monthValues, - defaultWidth: "wide" - }), - day: buildLocalizeFn({ - values: dayValues, - defaultWidth: "wide" - }), - dayPeriod: buildLocalizeFn({ - values: dayPeriodValues, - defaultWidth: "wide", - formattingValues: formattingDayPeriodValues, - defaultFormattingWidth: "wide" - }) -}; -var localize_default = localize; - -// node_modules/date-fns/esm/locale/_lib/buildMatchFn/index.js -function buildMatchFn(args) { - return function(string) { - var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - var width = options.width; - var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; - var matchResult = string.match(matchPattern); - if (!matchResult) { - return null; - } - var matchedString = matchResult[0]; - var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; - var key2 = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function(pattern) { - return pattern.test(matchedString); - }) : findKey(parsePatterns, function(pattern) { - return pattern.test(matchedString); - }); - var value; - value = args.valueCallback ? args.valueCallback(key2) : key2; - value = options.valueCallback ? options.valueCallback(value) : value; - var rest = string.slice(matchedString.length); - return { - value, - rest - }; - }; -} -function findKey(object, predicate) { - for (var key2 in object) { - if (object.hasOwnProperty(key2) && predicate(object[key2])) { - return key2; - } - } - return void 0; -} -function findIndex(array, predicate) { - for (var key2 = 0; key2 < array.length; key2++) { - if (predicate(array[key2])) { - return key2; - } - } - return void 0; -} - -// node_modules/date-fns/esm/locale/_lib/buildMatchPatternFn/index.js -function buildMatchPatternFn(args) { - return function(string) { - var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - var matchResult = string.match(args.matchPattern); - if (!matchResult) - return null; - var matchedString = matchResult[0]; - var parseResult = string.match(args.parsePattern); - if (!parseResult) - return null; - var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; - value = options.valueCallback ? options.valueCallback(value) : value; - var rest = string.slice(matchedString.length); - return { - value, - rest - }; - }; -} - -// node_modules/date-fns/esm/locale/en-US/_lib/match/index.js -var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; -var parseOrdinalNumberPattern = /\d+/i; -var matchEraPatterns = { - narrow: /^(b|a)/i, - abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, - wide: /^(before christ|before common era|anno domini|common era)/i -}; -var parseEraPatterns = { - any: [/^b/i, /^(a|c)/i] -}; -var matchQuarterPatterns = { - narrow: /^[1234]/i, - abbreviated: /^q[1234]/i, - wide: /^[1234](th|st|nd|rd)? quarter/i -}; -var parseQuarterPatterns = { - any: [/1/i, /2/i, /3/i, /4/i] -}; -var matchMonthPatterns = { - narrow: /^[jfmasond]/i, - abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, - wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i -}; -var parseMonthPatterns = { - narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i], - any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i] -}; -var matchDayPatterns = { - narrow: /^[smtwf]/i, - short: /^(su|mo|tu|we|th|fr|sa)/i, - abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, - wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i -}; -var parseDayPatterns = { - narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], - any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] -}; -var matchDayPeriodPatterns = { - narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, - any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i -}; -var parseDayPeriodPatterns = { - any: { - am: /^a/i, - pm: /^p/i, - midnight: /^mi/i, - noon: /^no/i, - morning: /morning/i, - afternoon: /afternoon/i, - evening: /evening/i, - night: /night/i - } -}; -var match = { - ordinalNumber: buildMatchPatternFn({ - matchPattern: matchOrdinalNumberPattern, - parsePattern: parseOrdinalNumberPattern, - valueCallback: function valueCallback(value) { - return parseInt(value, 10); - } - }), - era: buildMatchFn({ - matchPatterns: matchEraPatterns, - defaultMatchWidth: "wide", - parsePatterns: parseEraPatterns, - defaultParseWidth: "any" - }), - quarter: buildMatchFn({ - matchPatterns: matchQuarterPatterns, - defaultMatchWidth: "wide", - parsePatterns: parseQuarterPatterns, - defaultParseWidth: "any", - valueCallback: function valueCallback2(index) { - return index + 1; - } - }), - month: buildMatchFn({ - matchPatterns: matchMonthPatterns, - defaultMatchWidth: "wide", - parsePatterns: parseMonthPatterns, - defaultParseWidth: "any" - }), - day: buildMatchFn({ - matchPatterns: matchDayPatterns, - defaultMatchWidth: "wide", - parsePatterns: parseDayPatterns, - defaultParseWidth: "any" - }), - dayPeriod: buildMatchFn({ - matchPatterns: matchDayPeriodPatterns, - defaultMatchWidth: "any", - parsePatterns: parseDayPeriodPatterns, - defaultParseWidth: "any" - }) -}; -var match_default = match; - -// node_modules/date-fns/esm/locale/en-US/index.js -var locale = { - code: "en-US", - formatDistance: formatDistance_default, - formatLong: formatLong_default, - formatRelative: formatRelative_default, - localize: localize_default, - match: match_default, - options: { - weekStartsOn: 0, - firstWeekContainsDate: 1 - } -}; -var en_US_default = locale; - -// node_modules/date-fns/esm/_lib/defaultLocale/index.js -var defaultLocale_default = en_US_default; - -// node_modules/date-fns/esm/format/index.js -var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; -var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; -var escapedStringRegExp = /^'([^]*?)'?$/; -var doubleQuoteRegExp = /''/g; -var unescapedLatinCharacterRegExp = /[a-zA-Z]/; -function format(dirtyDate, dirtyFormatStr, options) { - var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4; - requiredArgs(2, arguments); - var formatStr = String(dirtyFormatStr); - var defaultOptions3 = getDefaultOptions(); - var locale2 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions3.locale) !== null && _ref !== void 0 ? _ref : defaultLocale_default; - var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions3.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); - if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { - throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively"); - } - var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions3.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions3.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); - if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { - throw new RangeError("weekStartsOn must be between 0 and 6 inclusively"); - } - if (!locale2.localize) { - throw new RangeError("locale must contain localize property"); - } - if (!locale2.formatLong) { - throw new RangeError("locale must contain formatLong property"); - } - var originalDate = toDate(dirtyDate); - if (!isValid(originalDate)) { - throw new RangeError("Invalid time value"); - } - var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate); - var utcDate = subMilliseconds(originalDate, timezoneOffset); - var formatterOptions = { - firstWeekContainsDate, - weekStartsOn, - locale: locale2, - _originalDate: originalDate - }; - var result = formatStr.match(longFormattingTokensRegExp).map(function(substring) { - var firstCharacter = substring[0]; - if (firstCharacter === "p" || firstCharacter === "P") { - var longFormatter = longFormatters_default[firstCharacter]; - return longFormatter(substring, locale2.formatLong); - } - return substring; - }).join("").match(formattingTokensRegExp).map(function(substring) { - if (substring === "''") { - return "'"; - } - var firstCharacter = substring[0]; - if (firstCharacter === "'") { - return cleanEscapedString(substring); - } - var formatter = formatters_default[firstCharacter]; - if (formatter) { - if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) { - throwProtectedError(substring, dirtyFormatStr, String(dirtyDate)); - } - if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) { - throwProtectedError(substring, dirtyFormatStr, String(dirtyDate)); - } - return formatter(utcDate, substring, locale2.localize, formatterOptions); - } - if (firstCharacter.match(unescapedLatinCharacterRegExp)) { - throw new RangeError("Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"); - } - return substring; - }).join(""); - return result; -} -function cleanEscapedString(input) { - var matched = input.match(escapedStringRegExp); - if (!matched) { - return input; - } - return matched[1].replace(doubleQuoteRegExp, "'"); -} - -// node_modules/date-fns/esm/_lib/assign/index.js -function assign(target, object) { - if (target == null) { - throw new TypeError("assign requires that input parameter not be null or undefined"); - } - for (var property in object) { - if (Object.prototype.hasOwnProperty.call(object, property)) { - ; - target[property] = object[property]; - } - } - return target; -} - -// node_modules/date-fns/esm/_lib/cloneObject/index.js -function cloneObject(object) { - return assign({}, object); -} - -// node_modules/date-fns/esm/formatDistance/index.js -var MINUTES_IN_DAY = 1440; -var MINUTES_IN_ALMOST_TWO_DAYS = 2520; -var MINUTES_IN_MONTH = 43200; -var MINUTES_IN_TWO_MONTHS = 86400; -function formatDistance3(dirtyDate, dirtyBaseDate, options) { - var _ref, _options$locale; - requiredArgs(2, arguments); - var defaultOptions3 = getDefaultOptions(); - var locale2 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions3.locale) !== null && _ref !== void 0 ? _ref : defaultLocale_default; - if (!locale2.formatDistance) { - throw new RangeError("locale must contain formatDistance property"); - } - var comparison = compareAsc(dirtyDate, dirtyBaseDate); - if (isNaN(comparison)) { - throw new RangeError("Invalid time value"); - } - var localizeOptions = assign(cloneObject(options), { - addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix), - comparison - }); - var dateLeft; - var dateRight; - if (comparison > 0) { - dateLeft = toDate(dirtyBaseDate); - dateRight = toDate(dirtyDate); - } else { - dateLeft = toDate(dirtyDate); - dateRight = toDate(dirtyBaseDate); - } - var seconds = differenceInSeconds(dateRight, dateLeft); - var offsetInSeconds = (getTimezoneOffsetInMilliseconds(dateRight) - getTimezoneOffsetInMilliseconds(dateLeft)) / 1e3; - var minutes = Math.round((seconds - offsetInSeconds) / 60); - var months; - if (minutes < 2) { - if (options !== null && options !== void 0 && options.includeSeconds) { - if (seconds < 5) { - return locale2.formatDistance("lessThanXSeconds", 5, localizeOptions); - } else if (seconds < 10) { - return locale2.formatDistance("lessThanXSeconds", 10, localizeOptions); - } else if (seconds < 20) { - return locale2.formatDistance("lessThanXSeconds", 20, localizeOptions); - } else if (seconds < 40) { - return locale2.formatDistance("halfAMinute", 0, localizeOptions); - } else if (seconds < 60) { - return locale2.formatDistance("lessThanXMinutes", 1, localizeOptions); - } else { - return locale2.formatDistance("xMinutes", 1, localizeOptions); - } - } else { - if (minutes === 0) { - return locale2.formatDistance("lessThanXMinutes", 1, localizeOptions); - } else { - return locale2.formatDistance("xMinutes", minutes, localizeOptions); - } - } - } else if (minutes < 45) { - return locale2.formatDistance("xMinutes", minutes, localizeOptions); - } else if (minutes < 90) { - return locale2.formatDistance("aboutXHours", 1, localizeOptions); - } else if (minutes < MINUTES_IN_DAY) { - var hours = Math.round(minutes / 60); - return locale2.formatDistance("aboutXHours", hours, localizeOptions); - } else if (minutes < MINUTES_IN_ALMOST_TWO_DAYS) { - return locale2.formatDistance("xDays", 1, localizeOptions); - } else if (minutes < MINUTES_IN_MONTH) { - var days = Math.round(minutes / MINUTES_IN_DAY); - return locale2.formatDistance("xDays", days, localizeOptions); - } else if (minutes < MINUTES_IN_TWO_MONTHS) { - months = Math.round(minutes / MINUTES_IN_MONTH); - return locale2.formatDistance("aboutXMonths", months, localizeOptions); - } - months = differenceInMonths(dateRight, dateLeft); - if (months < 12) { - var nearestMonth = Math.round(minutes / MINUTES_IN_MONTH); - return locale2.formatDistance("xMonths", nearestMonth, localizeOptions); - } else { - var monthsSinceStartOfYear = months % 12; - var years = Math.floor(months / 12); - if (monthsSinceStartOfYear < 3) { - return locale2.formatDistance("aboutXYears", years, localizeOptions); - } else if (monthsSinceStartOfYear < 9) { - return locale2.formatDistance("overXYears", years, localizeOptions); - } else { - return locale2.formatDistance("almostXYears", years + 1, localizeOptions); - } - } -} - -// node_modules/date-fns/esm/getDaysInMonth/index.js -function getDaysInMonth(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var year = date.getFullYear(); - var monthIndex = date.getMonth(); - var lastDayOfMonth2 = new Date(0); - lastDayOfMonth2.setFullYear(year, monthIndex + 1, 0); - lastDayOfMonth2.setHours(0, 0, 0, 0); - return lastDayOfMonth2.getDate(); -} - -// node_modules/date-fns/esm/getISOWeek/index.js -var MILLISECONDS_IN_WEEK4 = 6048e5; -function getISOWeek(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var diff = startOfISOWeek(date).getTime() - startOfISOWeekYear(date).getTime(); - return Math.round(diff / MILLISECONDS_IN_WEEK4) + 1; -} - -// node_modules/date-fns/esm/getTime/index.js -function getTime(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var timestamp = date.getTime(); - return timestamp; -} - -// node_modules/date-fns/esm/getUnixTime/index.js -function getUnixTime(dirtyDate) { - requiredArgs(1, arguments); - return Math.floor(getTime(dirtyDate) / 1e3); -} - -// node_modules/date-fns/esm/getWeekYear/index.js -function getWeekYear(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var year = date.getFullYear(); - var defaultOptions3 = getDefaultOptions(); - var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); - if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { - throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively"); - } - var firstWeekOfNextYear = new Date(0); - firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); - firstWeekOfNextYear.setHours(0, 0, 0, 0); - var startOfNextYear = startOfWeek(firstWeekOfNextYear, options); - var firstWeekOfThisYear = new Date(0); - firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); - firstWeekOfThisYear.setHours(0, 0, 0, 0); - var startOfThisYear = startOfWeek(firstWeekOfThisYear, options); - if (date.getTime() >= startOfNextYear.getTime()) { - return year + 1; - } else if (date.getTime() >= startOfThisYear.getTime()) { - return year; - } else { - return year - 1; - } -} - -// node_modules/date-fns/esm/startOfWeekYear/index.js -function startOfWeekYear(dirtyDate, options) { - var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2; - requiredArgs(1, arguments); - var defaultOptions3 = getDefaultOptions(); - var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions3.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions3.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); - var year = getWeekYear(dirtyDate, options); - var firstWeek = new Date(0); - firstWeek.setFullYear(year, 0, firstWeekContainsDate); - firstWeek.setHours(0, 0, 0, 0); - var date = startOfWeek(firstWeek, options); - return date; -} - -// node_modules/date-fns/esm/getWeek/index.js -var MILLISECONDS_IN_WEEK5 = 6048e5; -function getWeek(dirtyDate, options) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var diff = startOfWeek(date, options).getTime() - startOfWeekYear(date, options).getTime(); - return Math.round(diff / MILLISECONDS_IN_WEEK5) + 1; -} - -// node_modules/date-fns/esm/lastDayOfMonth/index.js -function lastDayOfMonth(dirtyDate) { - requiredArgs(1, arguments); - var date = toDate(dirtyDate); - var month = date.getMonth(); - date.setFullYear(date.getFullYear(), month + 1, 0); - date.setHours(0, 0, 0, 0); - return date; -} - -// node_modules/date-fns/esm/getWeeksInMonth/index.js -function getWeeksInMonth(date, options) { - requiredArgs(1, arguments); - return differenceInCalendarWeeks(lastDayOfMonth(date), startOfMonth(date), options) + 1; -} - -// node_modules/date-fns/esm/isAfter/index.js -function isAfter(dirtyDate, dirtyDateToCompare) { - requiredArgs(2, arguments); - var date = toDate(dirtyDate); - var dateToCompare = toDate(dirtyDateToCompare); - return date.getTime() > dateToCompare.getTime(); -} - -// node_modules/date-fns/esm/isBefore/index.js -function isBefore(dirtyDate, dirtyDateToCompare) { - requiredArgs(2, arguments); - var date = toDate(dirtyDate); - var dateToCompare = toDate(dirtyDateToCompare); - return date.getTime() < dateToCompare.getTime(); -} - -// node_modules/date-fns/esm/isSameMonth/index.js -function isSameMonth(dirtyDateLeft, dirtyDateRight) { - requiredArgs(2, arguments); - var dateLeft = toDate(dirtyDateLeft); - var dateRight = toDate(dirtyDateRight); - return dateLeft.getFullYear() === dateRight.getFullYear() && dateLeft.getMonth() === dateRight.getMonth(); -} - -// node_modules/date-fns/esm/isSameYear/index.js -function isSameYear(dirtyDateLeft, dirtyDateRight) { - requiredArgs(2, arguments); - var dateLeft = toDate(dirtyDateLeft); - var dateRight = toDate(dirtyDateRight); - return dateLeft.getFullYear() === dateRight.getFullYear(); -} - -// node_modules/date-fns/esm/subDays/index.js -function subDays(dirtyDate, dirtyAmount) { - requiredArgs(2, arguments); - var amount = toInteger(dirtyAmount); - return addDays(dirtyDate, -amount); -} - -// node_modules/date-fns/esm/setMonth/index.js -function setMonth(dirtyDate, dirtyMonth) { - requiredArgs(2, arguments); - var date = toDate(dirtyDate); - var month = toInteger(dirtyMonth); - var year = date.getFullYear(); - var day = date.getDate(); - var dateWithDesiredMonth = new Date(0); - dateWithDesiredMonth.setFullYear(year, month, 15); - dateWithDesiredMonth.setHours(0, 0, 0, 0); - var daysInMonth = getDaysInMonth(dateWithDesiredMonth); - date.setMonth(month, Math.min(day, daysInMonth)); - return date; -} - -// node_modules/date-fns/esm/setYear/index.js -function setYear(dirtyDate, dirtyYear) { - requiredArgs(2, arguments); - var date = toDate(dirtyDate); - var year = toInteger(dirtyYear); - if (isNaN(date.getTime())) { - return new Date(NaN); - } - date.setFullYear(year); - return date; -} - -// src/utils/metadata/frontmatter/fm.ts -var import_lodash = __toESM(require_lodash()); -var import_obsidian6 = require("obsidian"); - -// src/utils/metadata/dv.ts -var import_obsidian5 = require("obsidian"); -var LocationWrapper = { - fullLine: { start: "", end: "" }, - brackets: { start: "[", end: "]" }, - parenthesis: { start: "(", end: ")" } -}; -var fieldComponents = [ - "inQuote", - "inList", - "startStyle", - "attribute", - "endStyle", - "beforeSeparatorSpacer", - "afterSeparatorSpacer", - "values" -]; -var genericFieldRegex = "(?>(\\s+)?)?(?- )?(?[_\\*~`]*)(?[0-9\\w\\p{Letter}\\p{Emoji_Presentation}][-0-9\\w\\p{Letter}\\p{Emoji_Presentation}\\s]*)(?[_\\*~`]*)(?\\s*)"; -var inlineFieldRegex = (attribute) => `(?>(\\s+)?)?(?- )?(?[_\\*~\`]*)(?${attribute})(?[_\\*~\`]*)(?\\s*)::(?\\s*)`; -var fullLineRegex = new RegExp( - `^${genericFieldRegex}::\\s*(?.*)?`, - "u" -); -var inSentenceRegexBrackets = new RegExp( - `\\[${genericFieldRegex}::\\s*(?[^\\]]+)?\\]`, - "gu" -); -var inSentenceRegexPar = new RegExp( - `\\(${genericFieldRegex}::\\s*(?[^\\)]+)?\\)`, - "gu" -); -var encodeLink = (value) => { - return value ? value.replace(/\[\[/g, "\u{1F54C}\u{1F527}").replace(/\]\]/g, "\u{1F413}\u{1F400}") : value; -}; -var decodeLink = (value) => { - return value ? value.replace(/🕌🔧/gu, "[[").replace(/🐓🐀/gu, "]]") : value; -}; -var matchInlineFields = (regex, line, attribute, input, location = "fullLine") => { - const sR = line.matchAll(regex); - let next = sR.next(); - const newFields = []; - while (!next.done) { - const match2 = next.value; - if (match2.groups && Object.keys(match2.groups).every((j4) => fieldComponents.includes(j4))) { - const { - inList, - inQuote, - startStyle, - endStyle, - beforeSeparatorSpacer, - afterSeparatorSpacer, - values - } = match2.groups; - const inputArray = input ? input.replace(/(\,\s+)/g, ",").split(",") : [""]; - const newValue = inputArray.length == 1 ? inputArray[0] : `${serializeMultiDisplayString(inputArray)}`; - const start = LocationWrapper[location].start; - const end = LocationWrapper[location].end; - newFields.push({ - oldField: match2[0], - newField: `${inQuote || ""}${start}${inList || ""}${startStyle}${attribute}${endStyle}${beforeSeparatorSpacer}::${afterSeparatorSpacer}${newValue}${end}` - }); - } - next = sR.next(); - } - return newFields; -}; -async function replaceValues(plugin, fileOrFilePath, attribute, input, previousItemsCount = 0) { - var _a2, _b2; - let file; - if (fileOrFilePath instanceof import_obsidian5.TFile) { - file = fileOrFilePath; - } else { - const _file = plugin.app.vault.getAbstractFileByPath(fileOrFilePath); - if (_file instanceof import_obsidian5.TFile && _file.extension == "md") { - file = _file; - } else { - throw Error("path doesn't correspond to a proper file"); - } - } - const content = (await plugin.app.vault.read(file)).split("\n"); - const frontmatter = (_a2 = plugin.app.metadataCache.getFileCache(file)) == null ? void 0 : _a2.frontmatter; - const skippedLines = []; - const { - position: { start, end } - } = frontmatter ? frontmatter : { position: { start: void 0, end: void 0 } }; - const newContent = content.map((line, i4) => { - const encodedInput = encodeLink(input); - let encodedLine = encodeLink(line); - const fullLineRegex2 = new RegExp( - `^${inlineFieldRegex(attribute)}(?[^\\]]*)`, - "u" - ); - const fR = encodedLine.match(fullLineRegex2); - if ((fR == null ? void 0 : fR.groups) && Object.keys(fR.groups).every((j4) => fieldComponents.includes(j4))) { - const { - inList, - inQuote, - startStyle, - endStyle, - beforeSeparatorSpacer, - afterSeparatorSpacer, - values - } = fR.groups; - const inputArray = input ? input.replace(/(\,\s+)/g, ",").split(",").sort() : []; - let newValue; - let hiddenValue = ""; - newValue = inputArray.length == 1 ? inputArray[0] : `${serializeMultiDisplayString(inputArray)}`; - return `${inQuote || ""}${inList || ""}${startStyle}${attribute}${endStyle}${beforeSeparatorSpacer}::${afterSeparatorSpacer}${hiddenValue + newValue}`; - } else { - const newFields = []; - const inSentenceRegexBrackets2 = new RegExp( - `\\[${inlineFieldRegex(attribute)}(?[^\\]]+)?\\]`, - "gu" - ); - const inSentenceRegexPar2 = new RegExp( - `\\(${inlineFieldRegex(attribute)}(?[^\\)]+)?\\)`, - "gu" - ); - newFields.push( - ...matchInlineFields( - inSentenceRegexBrackets2, - encodedLine, - attribute, - encodedInput, - "brackets" /* brackets */ - ) - ); - newFields.push( - ...matchInlineFields( - inSentenceRegexPar2, - encodedLine, - attribute, - encodedInput, - "parenthesis" /* parenthesis */ - ) - ); - newFields.forEach((field) => { - const fieldRegex = new RegExp( - field.oldField.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), - "u" - ); - encodedLine = encodedLine.replace(fieldRegex, field.newField); - }); - return decodeLink(encodedLine); - } - }); - await plugin.app.vault.modify( - file, - newContent.filter((line, i4) => !skippedLines.includes(i4)).join("\n") - ); - const editor = (_b2 = plugin.app.workspace.getActiveViewOfType(import_obsidian5.MarkdownView)) == null ? void 0 : _b2.editor; - if (editor) { - const lineNumber = editor.getCursor().line; - editor.setCursor({ - line: editor.getCursor().line, - ch: editor.getLine(lineNumber).length - }); - } -} - -// src/utils/metadata/frontmatter/detectYAMLType.ts -var detectYAMLType = (value, key2) => { - if (typeof value === "string") { - if (/\/\/(\S+?(?:jpe?g|png|gif|svg))/gi.test(value) || value.includes("unsplash")) { - return "image"; - } - if (/^\d{4}-\d{2}-\d{2}$/.test(value)) { - return "date"; - } - if (key2 == "tag" || key2 == "tags") { - return "tag"; - } - if (/\[\[.*?\]\]/.test(value)) { - return "link"; - } - } else if (typeof value === "number") { - return "number"; - } else if (typeof value === "boolean") { - return "boolean"; - } else if (!value) { - return "unknown"; - } else if (Array.isArray(value) || typeof value === "string" && value.indexOf(",") > -1) { - let arrayValue = Array.isArray(value) ? value : []; - if (typeof value === "string" && value.indexOf(",") > -1) { - arrayValue = parseMultiString(value); - } - if (key2 == "tag" || key2 == "tags") { - return "tag-multi"; - } - if (arrayValue.length == 1 && Array.isArray(arrayValue[0]) && arrayValue[0].length == 1 && typeof arrayValue[0][0] === "string") { - return "link"; - } - const types = uniq(arrayValue.map((f4) => detectYAMLType(f4, key2))); - if (types.length == 1 && types[0] == "link") { - return "link-multi"; - } - return "option-multi"; - } else if (value.isLuxonDateTime) { - return "date"; - } else if (value.isLuxonDuration) { - return "duration"; - } else if (value.type == "file") { - return "link"; - } else if (typeof value === "object" && !Array.isArray(value) && value !== null) { - return "object"; - } - return "text"; -}; - -// src/utils/metadata/frontmatter/frontMatterKeys.ts -var frontMatterKeys = (fm) => { - return Object.keys(fm != null ? fm : {}).filter((f4) => f4 != "position").filter((f4) => f4 != "tag" && f4 != "tags"); -}; - -// src/utils/metadata/frontmatter/yamlTypeToMDBType.ts -var yamlTypeToMDBType = (YAMLtype) => { - switch (YAMLtype) { - case "duration": - return "text"; - break; - case "unknown": - return "text"; - break; - } - return YAMLtype; -}; - -// src/utils/metadata/frontmatter/fm.ts -var saveContextToFile = (file, cols, context, plugin) => { - if (app.fileManager.processFrontMatter) { - app.fileManager.processFrontMatter(file, (frontmatter) => { - Object.keys(context).filter( - (f4) => cols.find((c4) => c4.name == f4) && cols.find((c4) => c4.name == f4).hidden != "true" && !cols.find((c4) => c4.name == f4).type.contains("file") && context[f4] - ).forEach((f4) => { - const col = cols.find((c4) => c4.name == f4); - frontmatter[f4] = valueForFrontmatter(col.type, context[f4]); - frontmatter[f4] = valueForFrontmatter(col.type, context[f4]); - }); - }); - } -}; -var frontMatterForFile = (file) => { - let currentCache; - if (file instanceof import_obsidian6.TFile && app.metadataCache.getFileCache(file) !== null) { - currentCache = app.metadataCache.getFileCache(file); - } - return currentCache == null ? void 0 : currentCache.frontmatter; -}; -var mergeTableData = (mdb, yamlmdb, types) => { - return { - ...mdb, - cols: [ - ...mdb.cols, - ...yamlmdb.cols.filter( - (f4) => !mdb.cols.find((g4) => g4.name.toLowerCase() == f4.toLowerCase()) - ).map((f4) => ({ - name: f4, - schemaId: mdb.schema.id, - type: yamlTypeToMDBType(types[f4]) - })) - ].filter(onlyUniquePropCaseInsensitive("name")), - rows: mdb.rows.map((r3) => { - const fmRow = yamlmdb.rows.find((f4) => f4.File == r3.File); - if (fmRow) { - return { - ...r3, - ...fmRow - }; - } - return r3; - }) - }; -}; -var guestimateTypes = (_files, plugin, dv) => { - const typesArray = _files.map((f4) => getAbstractFileAtPath(app, f4)).filter((f4) => f4).map((k5) => { - const fm = dv && plugin.dataViewAPI() ? plugin.dataViewAPI().page(k5.path) : frontMatterForFile(k5); - const fmKeys = dv ? Object.keys(fm != null ? fm : {}).filter( - (f4, i4, self2) => !self2.find( - (g4, j4) => g4.toLowerCase().replace(/\s/g, "-") == f4.toLowerCase().replace(/\s/g, "-") && i4 > j4 - ) ? true : false - ).filter((f4) => f4 != "file") : frontMatterKeys(fm); - return fmKeys.reduce( - (pk, ck) => ({ ...pk, [ck]: detectYAMLType(fm[ck], ck) }), - {} - ); - }); - const types = typesArray.reduce( - (p3, c4) => { - const newSet = Object.keys(c4).reduce( - (pk, ck) => { - var _a2; - return { ...pk, [ck]: [...(_a2 = p3 == null ? void 0 : p3[ck]) != null ? _a2 : [], c4[ck]] }; - }, - { ...p3 } - ); - return newSet; - }, - {} - ); - const guessType = (ts) => { - return import_lodash.default.head((0, import_lodash.default)(ts).countBy().entries().maxBy(import_lodash.default.last)); - }; - const guessedTypes = Object.keys(types).reduce((p3, c4) => { - return { ...p3, [c4]: guessType(types[c4]) }; - }, {}); - return guessedTypes; -}; -var valueForFrontmatter = (type, value) => { - if (type == "number") { - return parseFloat(value); - } else if (type == "boolean") { - return value == "true"; - } else if (type.contains("multi")) { - return parseMultiString(value).map( - (f4) => valueForFrontmatter(type.replace("-multi", ""), f4) - ); - } else if (type.contains("link") || type.contains("context")) { - return `[[${value}]]`; - } - return value; -}; -var valueForDataview = (type, value) => { - if (type.contains("link") || type.contains("context")) { - return `[[${value}]]`; - } - return value; -}; -var renameFrontmatterKey = (plugin, path, key2, name) => { - const afile = getAbstractFileAtPath(app, path); - if (afile && afile instanceof import_obsidian6.TFile) { - if (app.fileManager.processFrontMatter) { - app.fileManager.processFrontMatter(afile, (frontmatter) => { - if (key2 in frontmatter) { - frontmatter[name] = frontmatter[key2]; - delete frontmatter[key2]; - } - }); - } - } -}; -var defaultValueForType = (value, type) => { - if (type == "date") { - return format(Date.now(), "yyyy-MM-dd"); - } - if (type == "number") { - return 0; - } - if (type == "boolean") { - return true; - } - if (type == "link") { - return "[[Select Note]]"; - } - if (type == "option") { - return "one, two"; - } - if (type == "text") { - return " "; - } - if (type == "image") { - return "https://images.unsplash.com/photo-1675789652575-0a5d2425b6c2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80"; - } -}; -var changeFrontmatterType = (plugin, path, key2, type) => { - const afile = getAbstractFileAtPath(app, path); - if (afile && afile instanceof import_obsidian6.TFile) { - if (app.fileManager.processFrontMatter) { - app.fileManager.processFrontMatter(afile, (frontmatter) => { - if (key2 in frontmatter) { - frontmatter[key2] = defaultValueForType(frontmatter[key2], type); - } - }); - } - } -}; -var deleteFrontmatterValue = (plugin, path, key2) => { - const afile = getAbstractFileAtPath(app, path); - if (afile && afile instanceof import_obsidian6.TFile) { - if (app.fileManager.processFrontMatter) { - app.fileManager.processFrontMatter(afile, (frontmatter) => { - if (plugin.dataViewAPI()) { - if (plugin.dataViewAPI().page(path)[key2] && !frontmatter[key2]) { - replaceValues(plugin, path, key2, ""); - } else { - if (key2 in frontmatter) { - delete frontmatter[key2]; - } - } - } else { - if (key2 in frontmatter) { - delete frontmatter[key2]; - } - } - }); - } - } -}; -var saveFrontmatterValue = (plugin, path, key2, value, type, forceSave) => { - let afile = getAbstractFileAtPath(app, path); - const fileCache = plugin.index.files.get(path); - if (afile && fileCache) { - if (fileCache.isFolder && fileCache.folderNote) { - afile = getAbstractFileAtPath(app, fileCache.folderNote.folderNotePath); - } - if (afile instanceof import_obsidian6.TFile) { - if (app.fileManager.processFrontMatter) { - app.fileManager.processFrontMatter(afile, (frontmatter) => { - var _a2; - if (plugin.dataViewAPI()) { - if (((_a2 = plugin.dataViewAPI().page(afile.path)) == null ? void 0 : _a2[key2]) && !frontmatter[key2]) { - replaceValues(plugin, afile.path, key2, valueForDataview(type, value)); - } else { - if (key2 in frontmatter || forceSave) { - frontmatter[key2] = valueForFrontmatter(type, value); - } - } - } else { - if (key2 in frontmatter || forceSave) { - frontmatter[key2] = valueForFrontmatter(type, value); - } - } - }); - } - } - } -}; - -// src/components/FileContextView/NoteBannerView.tsx -var NoteBannerView = (props2) => { - const [banner, setBanner] = h2(null); - p2(() => { - var _a2; - if (props2.link) { - const newBanner = (_a2 = getAbstractFileAtPath(app, props2.link)) != null ? _a2 : props2.link; - setBanner(newBanner); - } else { - setBanner(null); - } - }, [props2.link]); - const triggerBannerContextMenu = (e4) => { - if (!props2.file) - return; - e4.preventDefault(); - const fileMenu = new import_obsidian7.Menu(); - fileMenu.addSeparator(); - fileMenu.addItem((menuItem) => { - menuItem.setTitle(i18n_default.buttons.changeBanner); - menuItem.setIcon("lucide-image"); - menuItem.onClick((ev) => { - let vaultChangeModal = new imageModal( - props2.plugin, - props2.plugin.app, - (image) => saveFrontmatterValue( - props2.plugin, - props2.file.path, - FMBannerKey, - image, - "image", - true - ) - ); - vaultChangeModal.open(); - }); - }); - fileMenu.addItem((menuItem) => { - menuItem.setTitle(i18n_default.buttons.removeBanner); - menuItem.setIcon("lucide-file-minus"); - menuItem.onClick((ev) => { - deleteFrontmatterValue(props2.plugin, props2.file.path, FMBannerKey); - }); - }); - if (isMouseEvent(e4)) { - fileMenu.showAtPosition({ x: e4.pageX, y: e4.pageY }); - } else { - fileMenu.showAtPosition({ - x: e4.nativeEvent.locationX, - y: e4.nativeEvent.locationY - }); - } - return false; - }; - return /* @__PURE__ */ Cn.createElement("div", { - className: `mk-note-header`, - onContextMenu: triggerBannerContextMenu - }, banner && /* @__PURE__ */ Cn.createElement("img", { - src: banner instanceof import_obsidian7.TFile ? app.vault.getResourcePath(banner) : banner - })); + return false; + }; + return /* @__PURE__ */ Cn.createElement("div", { + className: `mk-note-header`, + onContextMenu: triggerBannerContextMenu + }, banner && /* @__PURE__ */ Cn.createElement("img", { + src: banner instanceof import_obsidian4.TFile ? app.vault.getResourcePath(banner) : banner + })); }; // src/components/StickerMenu/emojis/default.ts @@ -22342,629 +21275,1662 @@ var emojis = { { n: ["flag-gq", "equatorial guinea flag"], u: "1f1ec-1f1f6" }, { n: ["flag-gr", "greece flag"], u: "1f1ec-1f1f7" }, { - n: ["flag-gs", "south georgia & south sandwich islands flag"], - u: "1f1ec-1f1f8" + n: ["flag-gs", "south georgia & south sandwich islands flag"], + u: "1f1ec-1f1f8" + }, + { n: ["flag-gt", "guatemala flag"], u: "1f1ec-1f1f9" }, + { n: ["flag-gu", "guam flag"], u: "1f1ec-1f1fa" }, + { n: ["flag-gw", "guinea-bissau flag"], u: "1f1ec-1f1fc" }, + { n: ["flag-gy", "guyana flag"], u: "1f1ec-1f1fe" }, + { n: ["flag-hk", "hong kong sar china flag"], u: "1f1ed-1f1f0" }, + { n: ["flag-hm", "heard & mcdonald islands flag"], u: "1f1ed-1f1f2" }, + { n: ["flag-hn", "honduras flag"], u: "1f1ed-1f1f3" }, + { n: ["flag-hr", "croatia flag"], u: "1f1ed-1f1f7" }, + { n: ["flag-ht", "haiti flag"], u: "1f1ed-1f1f9" }, + { n: ["flag-hu", "hungary flag"], u: "1f1ed-1f1fa" }, + { n: ["flag-ic", "canary islands flag"], u: "1f1ee-1f1e8" }, + { n: ["flag-id", "indonesia flag"], u: "1f1ee-1f1e9" }, + { n: ["flag-ie", "ireland flag"], u: "1f1ee-1f1ea" }, + { n: ["flag-il", "israel flag"], u: "1f1ee-1f1f1" }, + { n: ["flag-im", "isle of man flag"], u: "1f1ee-1f1f2" }, + { n: ["flag-in", "india flag"], u: "1f1ee-1f1f3" }, + { n: ["flag-io", "british indian ocean territory flag"], u: "1f1ee-1f1f4" }, + { n: ["flag-iq", "iraq flag"], u: "1f1ee-1f1f6" }, + { n: ["flag-ir", "iran flag"], u: "1f1ee-1f1f7" }, + { n: ["flag-is", "iceland flag"], u: "1f1ee-1f1f8" }, + { n: ["it", "flag-it", "italy flag"], u: "1f1ee-1f1f9" }, + { n: ["flag-je", "jersey flag"], u: "1f1ef-1f1ea" }, + { n: ["flag-jm", "jamaica flag"], u: "1f1ef-1f1f2" }, + { n: ["flag-jo", "jordan flag"], u: "1f1ef-1f1f4" }, + { n: ["jp", "flag-jp", "japan flag"], u: "1f1ef-1f1f5" }, + { n: ["flag-ke", "kenya flag"], u: "1f1f0-1f1ea" }, + { n: ["flag-kg", "kyrgyzstan flag"], u: "1f1f0-1f1ec" }, + { n: ["flag-kh", "cambodia flag"], u: "1f1f0-1f1ed" }, + { n: ["flag-ki", "kiribati flag"], u: "1f1f0-1f1ee" }, + { n: ["flag-km", "comoros flag"], u: "1f1f0-1f1f2" }, + { n: ["flag-kn", "st. kitts & nevis flag"], u: "1f1f0-1f1f3" }, + { n: ["flag-kp", "north korea flag"], u: "1f1f0-1f1f5" }, + { n: ["kr", "flag-kr", "south korea flag"], u: "1f1f0-1f1f7" }, + { n: ["flag-kw", "kuwait flag"], u: "1f1f0-1f1fc" }, + { n: ["flag-ky", "cayman islands flag"], u: "1f1f0-1f1fe" }, + { n: ["flag-kz", "kazakhstan flag"], u: "1f1f0-1f1ff" }, + { n: ["flag-la", "laos flag"], u: "1f1f1-1f1e6" }, + { n: ["flag-lb", "lebanon flag"], u: "1f1f1-1f1e7" }, + { n: ["flag-lc", "st. lucia flag"], u: "1f1f1-1f1e8" }, + { n: ["flag-li", "liechtenstein flag"], u: "1f1f1-1f1ee" }, + { n: ["flag-lk", "sri lanka flag"], u: "1f1f1-1f1f0" }, + { n: ["flag-lr", "liberia flag"], u: "1f1f1-1f1f7" }, + { n: ["flag-ls", "lesotho flag"], u: "1f1f1-1f1f8" }, + { n: ["flag-lt", "lithuania flag"], u: "1f1f1-1f1f9" }, + { n: ["flag-lu", "luxembourg flag"], u: "1f1f1-1f1fa" }, + { n: ["flag-lv", "latvia flag"], u: "1f1f1-1f1fb" }, + { n: ["flag-ly", "libya flag"], u: "1f1f1-1f1fe" }, + { n: ["flag-ma", "morocco flag"], u: "1f1f2-1f1e6" }, + { n: ["flag-mc", "monaco flag"], u: "1f1f2-1f1e8" }, + { n: ["flag-md", "moldova flag"], u: "1f1f2-1f1e9" }, + { n: ["flag-me", "montenegro flag"], u: "1f1f2-1f1ea" }, + { n: ["flag-mf", "st. martin flag"], u: "1f1f2-1f1eb" }, + { n: ["flag-mg", "madagascar flag"], u: "1f1f2-1f1ec" }, + { n: ["flag-mh", "marshall islands flag"], u: "1f1f2-1f1ed" }, + { n: ["flag-mk", "north macedonia flag"], u: "1f1f2-1f1f0" }, + { n: ["flag-ml", "mali flag"], u: "1f1f2-1f1f1" }, + { n: ["flag-mm", "myanmar (burma) flag"], u: "1f1f2-1f1f2" }, + { n: ["flag-mn", "mongolia flag"], u: "1f1f2-1f1f3" }, + { n: ["flag-mo", "macao sar china flag"], u: "1f1f2-1f1f4" }, + { n: ["flag-mp", "northern mariana islands flag"], u: "1f1f2-1f1f5" }, + { n: ["flag-mq", "martinique flag"], u: "1f1f2-1f1f6" }, + { n: ["flag-mr", "mauritania flag"], u: "1f1f2-1f1f7" }, + { n: ["flag-ms", "montserrat flag"], u: "1f1f2-1f1f8" }, + { n: ["flag-mt", "malta flag"], u: "1f1f2-1f1f9" }, + { n: ["flag-mu", "mauritius flag"], u: "1f1f2-1f1fa" }, + { n: ["flag-mv", "maldives flag"], u: "1f1f2-1f1fb" }, + { n: ["flag-mw", "malawi flag"], u: "1f1f2-1f1fc" }, + { n: ["flag-mx", "mexico flag"], u: "1f1f2-1f1fd" }, + { n: ["flag-my", "malaysia flag"], u: "1f1f2-1f1fe" }, + { n: ["flag-mz", "mozambique flag"], u: "1f1f2-1f1ff" }, + { n: ["flag-na", "namibia flag"], u: "1f1f3-1f1e6" }, + { n: ["flag-nc", "new caledonia flag"], u: "1f1f3-1f1e8" }, + { n: ["flag-ne", "niger flag"], u: "1f1f3-1f1ea" }, + { n: ["flag-nf", "norfolk island flag"], u: "1f1f3-1f1eb" }, + { n: ["flag-ng", "nigeria flag"], u: "1f1f3-1f1ec" }, + { n: ["flag-ni", "nicaragua flag"], u: "1f1f3-1f1ee" }, + { n: ["flag-nl", "netherlands flag"], u: "1f1f3-1f1f1" }, + { n: ["flag-no", "norway flag"], u: "1f1f3-1f1f4" }, + { n: ["flag-np", "nepal flag"], u: "1f1f3-1f1f5" }, + { n: ["flag-nr", "nauru flag"], u: "1f1f3-1f1f7" }, + { n: ["flag-nu", "niue flag"], u: "1f1f3-1f1fa" }, + { n: ["flag-nz", "new zealand flag"], u: "1f1f3-1f1ff" }, + { n: ["flag-om", "oman flag"], u: "1f1f4-1f1f2" }, + { n: ["flag-pa", "panama flag"], u: "1f1f5-1f1e6" }, + { n: ["flag-pe", "peru flag"], u: "1f1f5-1f1ea" }, + { n: ["flag-pf", "french polynesia flag"], u: "1f1f5-1f1eb" }, + { n: ["flag-pg", "papua new guinea flag"], u: "1f1f5-1f1ec" }, + { n: ["flag-ph", "philippines flag"], u: "1f1f5-1f1ed" }, + { n: ["flag-pk", "pakistan flag"], u: "1f1f5-1f1f0" }, + { n: ["flag-pl", "poland flag"], u: "1f1f5-1f1f1" }, + { n: ["flag-pm", "st. pierre & miquelon flag"], u: "1f1f5-1f1f2" }, + { n: ["flag-pn", "pitcairn islands flag"], u: "1f1f5-1f1f3" }, + { n: ["flag-pr", "puerto rico flag"], u: "1f1f5-1f1f7" }, + { n: ["flag-ps", "palestinian territories flag"], u: "1f1f5-1f1f8" }, + { n: ["flag-pt", "portugal flag"], u: "1f1f5-1f1f9" }, + { n: ["flag-pw", "palau flag"], u: "1f1f5-1f1fc" }, + { n: ["flag-py", "paraguay flag"], u: "1f1f5-1f1fe" }, + { n: ["flag-qa", "qatar flag"], u: "1f1f6-1f1e6" }, + { n: ["flag-re", "r\xE9union flag"], u: "1f1f7-1f1ea" }, + { n: ["flag-ro", "romania flag"], u: "1f1f7-1f1f4" }, + { n: ["flag-rs", "serbia flag"], u: "1f1f7-1f1f8" }, + { n: ["ru", "flag-ru", "russia flag"], u: "1f1f7-1f1fa" }, + { n: ["flag-rw", "rwanda flag"], u: "1f1f7-1f1fc" }, + { n: ["flag-sa", "saudi arabia flag"], u: "1f1f8-1f1e6" }, + { n: ["flag-sb", "solomon islands flag"], u: "1f1f8-1f1e7" }, + { n: ["flag-sc", "seychelles flag"], u: "1f1f8-1f1e8" }, + { n: ["flag-sd", "sudan flag"], u: "1f1f8-1f1e9" }, + { n: ["flag-se", "sweden flag"], u: "1f1f8-1f1ea" }, + { n: ["flag-sg", "singapore flag"], u: "1f1f8-1f1ec" }, + { n: ["flag-sh", "st. helena flag"], u: "1f1f8-1f1ed" }, + { n: ["flag-si", "slovenia flag"], u: "1f1f8-1f1ee" }, + { n: ["flag-sj", "svalbard & jan mayen flag"], u: "1f1f8-1f1ef" }, + { n: ["flag-sk", "slovakia flag"], u: "1f1f8-1f1f0" }, + { n: ["flag-sl", "sierra leone flag"], u: "1f1f8-1f1f1" }, + { n: ["flag-sm", "san marino flag"], u: "1f1f8-1f1f2" }, + { n: ["flag-sn", "senegal flag"], u: "1f1f8-1f1f3" }, + { n: ["flag-so", "somalia flag"], u: "1f1f8-1f1f4" }, + { n: ["flag-sr", "suriname flag"], u: "1f1f8-1f1f7" }, + { n: ["flag-ss", "south sudan flag"], u: "1f1f8-1f1f8" }, + { n: ["flag-st", "s\xE3o tom\xE9 & pr\xEDncipe flag"], u: "1f1f8-1f1f9" }, + { n: ["flag-sv", "el salvador flag"], u: "1f1f8-1f1fb" }, + { n: ["flag-sx", "sint maarten flag"], u: "1f1f8-1f1fd" }, + { n: ["flag-sy", "syria flag"], u: "1f1f8-1f1fe" }, + { n: ["flag-sz", "eswatini flag"], u: "1f1f8-1f1ff" }, + { n: ["flag-ta", "tristan da cunha flag"], u: "1f1f9-1f1e6" }, + { n: ["flag-tc", "turks & caicos islands flag"], u: "1f1f9-1f1e8" }, + { n: ["flag-td", "chad flag"], u: "1f1f9-1f1e9" }, + { n: ["flag-tf", "french southern territories flag"], u: "1f1f9-1f1eb" }, + { n: ["flag-tg", "togo flag"], u: "1f1f9-1f1ec" }, + { n: ["flag-th", "thailand flag"], u: "1f1f9-1f1ed" }, + { n: ["flag-tj", "tajikistan flag"], u: "1f1f9-1f1ef" }, + { n: ["flag-tk", "tokelau flag"], u: "1f1f9-1f1f0" }, + { n: ["flag-tl", "timor-leste flag"], u: "1f1f9-1f1f1" }, + { n: ["flag-tm", "turkmenistan flag"], u: "1f1f9-1f1f2" }, + { n: ["flag-tn", "tunisia flag"], u: "1f1f9-1f1f3" }, + { n: ["flag-to", "tonga flag"], u: "1f1f9-1f1f4" }, + { n: ["flag-tr", "turkey flag"], u: "1f1f9-1f1f7" }, + { n: ["flag-tt", "trinidad & tobago flag"], u: "1f1f9-1f1f9" }, + { n: ["flag-tv", "tuvalu flag"], u: "1f1f9-1f1fb" }, + { n: ["flag-tw", "taiwan flag"], u: "1f1f9-1f1fc" }, + { n: ["flag-tz", "tanzania flag"], u: "1f1f9-1f1ff" }, + { n: ["flag-ua", "ukraine flag"], u: "1f1fa-1f1e6" }, + { n: ["flag-ug", "uganda flag"], u: "1f1fa-1f1ec" }, + { n: ["flag-um", "u.s. outlying islands flag"], u: "1f1fa-1f1f2" }, + { n: ["flag-un", "united nations flag"], u: "1f1fa-1f1f3" }, + { n: ["us", "flag-us", "united states flag"], u: "1f1fa-1f1f8" }, + { n: ["flag-uy", "uruguay flag"], u: "1f1fa-1f1fe" }, + { n: ["flag-uz", "uzbekistan flag"], u: "1f1fa-1f1ff" }, + { n: ["flag-va", "vatican city flag"], u: "1f1fb-1f1e6" }, + { n: ["flag-vc", "st. vincent & grenadines flag"], u: "1f1fb-1f1e8" }, + { n: ["flag-ve", "venezuela flag"], u: "1f1fb-1f1ea" }, + { n: ["flag-vg", "british virgin islands flag"], u: "1f1fb-1f1ec" }, + { n: ["flag-vi", "u.s. virgin islands flag"], u: "1f1fb-1f1ee" }, + { n: ["flag-vn", "vietnam flag"], u: "1f1fb-1f1f3" }, + { n: ["flag-vu", "vanuatu flag"], u: "1f1fb-1f1fa" }, + { n: ["flag-wf", "wallis & futuna flag"], u: "1f1fc-1f1eb" }, + { n: ["flag-ws", "samoa flag"], u: "1f1fc-1f1f8" }, + { n: ["flag-xk", "kosovo flag"], u: "1f1fd-1f1f0" }, + { n: ["flag-ye", "yemen flag"], u: "1f1fe-1f1ea" }, + { n: ["flag-yt", "mayotte flag"], u: "1f1fe-1f1f9" }, + { n: ["flag-za", "south africa flag"], u: "1f1ff-1f1e6" }, + { n: ["flag-zm", "zambia flag"], u: "1f1ff-1f1f2" }, + { n: ["flag-zw", "zimbabwe flag"], u: "1f1ff-1f1fc" }, + { + n: ["england flag", "flag-england"], + u: "1f3f4-e0067-e0062-e0065-e006e-e0067-e007f" + }, + { + n: ["scotland flag", "flag-scotland"], + u: "1f3f4-e0067-e0062-e0073-e0063-e0074-e007f" + }, + { + n: ["wales flag", "flag-wales"], + u: "1f3f4-e0067-e0062-e0077-e006c-e0073-e007f" + } + ] +}; + +// src/components/ui/modals/stickerModal.tsx +var import_obsidian5 = require("obsidian"); +var stickerModal = class extends import_obsidian5.FuzzySuggestModal { + constructor(app2, setIcon) { + super(app2); + this.setIcon = setIcon; + this.resultContainerEl.toggleClass("mk-sticker-modal", true); + this.inputEl.focus(); + this.emptyStateText = i18n_default.labels.findStickers; + this.limit = 0; + } + renderSuggestion(item, el) { + el.innerHTML = stickerFromString(item.item.unicode); + el.setAttr("aria-label", item.item.label); + } + getItemText(item) { + return item.label + item.desc; + } + getItems() { + const allEmojis = Object.keys(emojis).reduce( + (p3, c4) => [ + ...p3, + ...emojis[c4].map((e4) => ({ + label: e4.n[0], + desc: e4.n[1], + variants: e4.v, + unicode: e4.u + })) + ], + [] + ); + return allEmojis; + } + onChooseItem(item, evt) { + this.setIcon(item.unicode); + } +}; + +// src/components/FileSticker/FileSticker.tsx +var import_obsidian11 = require("obsidian"); + +// src/components/ui/modals/vaultChangeModals.ts +var import_obsidian6 = require("obsidian"); +var VaultChangeModal = class extends import_obsidian6.Modal { + constructor(plugin, file, action, space) { + super(plugin.app); + this.file = file; + this.action = action; + this.plugin = plugin; + this.space = space; + } + onOpen() { + const { contentEl } = this; + const myModal = this; + let headerText; + if (this.action === "rename") { + headerText = i18n_default.labels.rename; + } else if (this.action === "create folder") { + headerText = i18n_default.labels.createFolder; + } else if (this.action === "create note") { + headerText = i18n_default.labels.createNote; + } + const headerEl = contentEl.createEl("div", { text: headerText }); + headerEl.addClass("modal-title"); + const inputEl = contentEl.createEl("input"); + inputEl.style.cssText = "width: 100%; height: 2.5em; margin-bottom: 15px;"; + if (this.action === "rename") { + if (this.file instanceof import_obsidian6.TFolder) { + inputEl.value = this.file.name; + } else { + inputEl.value = this.file.name.substring( + 0, + indexOfCharElseEOS(".", this.file.name) + ); + } + } + inputEl.focus(); + let changeButtonText; + if (this.action === "rename") { + changeButtonText = i18n_default.buttons.rename; + } else if (this.action === "create folder") { + changeButtonText = i18n_default.buttons.createFolder; + } else if (this.action === "create note") { + changeButtonText = i18n_default.buttons.createNote; + } + const changeButton = contentEl.createEl("button", { + text: changeButtonText + }); + const cancelButton = contentEl.createEl("button", { + text: i18n_default.buttons.cancel + }); + cancelButton.style.cssText = "float: right;"; + cancelButton.addEventListener("click", () => { + myModal.close(); + }); + const onClickAction = async () => { + let newName = inputEl.value; + if (this.action === "rename") { + if (this.file instanceof import_obsidian6.TFile) { + newName = this.file.name.lastIndexOf(".") == -1 ? newName : newName + this.file.name.substring(this.file.name.lastIndexOf(".")); + } + renameFile(this.plugin, this.file, newName); + } else if (this.action === "create folder") { + const path = !this.file || this.file.path == "/" ? newName : this.file.path + "/" + newName; + if (getAbstractFileAtPath(app, path)) { + new import_obsidian6.Notice(i18n_default.notice.folderExists); + return; + } + this.app.vault.createFolder(path); + if (this.space != "/") + addPathsToSpace(this.plugin, this.space, [path]); + } + myModal.close(); + }; + changeButton.addEventListener("click", onClickAction); + inputEl.addEventListener("keydown", (e4) => { + if (e4.key === "Enter") + onClickAction(); + }); + } + onClose() { + const { contentEl } = this; + contentEl.empty(); + } +}; +var MoveSuggestionModal = class extends import_obsidian6.FuzzySuggestModal { + constructor(app2, files) { + super(app2); + this.files = files; + } + getItemText(item) { + return item.path; + } + getItems() { + return getAllFoldersInVault(this.app); + } + onChooseItem(item, evt) { + this.files.forEach((f4) => { + const file = getAbstractFileAtPath(app, f4); + if (file) { + this.app.vault.rename(file, item.path + "/" + file.name); + } + }); + } +}; +var AddToSpaceModal = class extends import_obsidian6.FuzzySuggestModal { + constructor(plugin, files) { + super(app); + this.plugin = plugin; + this.files = files; + } + getItemText(space) { + return space.name; + } + getItems() { + return this.plugin.index.allSpaces().filter((f4) => f4.def.type == "focus"); + } + onChooseItem(space, evt) { + this.files.forEach((f4) => { + var _a2; + const file = this.plugin.index.filesIndex.get(f4); + if (file) { + if (((_a2 = space.def.folder) == null ? void 0 : _a2.length) > 0) { + moveAFileToNewParentAtIndex(this.plugin, file, space.def.folder, 0); + } else { + insertSpaceItemAtIndex(this.plugin, space.name, file.path, 0); + } + } + }); + } +}; +var RemoveFromSpaceModal = class extends import_obsidian6.FuzzySuggestModal { + constructor(plugin, file) { + super(app); + this.plugin = plugin; + this.file = this.plugin.index.filesIndex.get(file); + } + getItemText(space) { + return space.name; + } + getItems() { + return this.file ? this.plugin.index.allSpaces().filter((f4) => { + var _a2; + return f4.def.type == "focus" && !(((_a2 = f4.def.folder) == null ? void 0 : _a2.length) > 0) && this.file.spaces.includes(f4.name); + }) : []; + } + onChooseItem(space, evt) { + removePathsFromSpace(this.plugin, space.name, [this.file.path]); + } +}; + +// src/superstate/spacesStore/spaces.ts +var import_lodash3 = __toESM(require_lodash()); +var import_obsidian10 = require("obsidian"); + +// src/schemas/spaces.ts +var vaultSchema = { + uniques: ["path"], + cols: ["path", "parent", "created", "sticker", "color", "folder", "rank"], + rows: [] +}; +var spaceSchema = { + uniques: ["name"], + cols: ["name", "sticker", "color", "pinned", "sort", "def", "rank"], + rows: [] +}; +var spaceItemsSchema = { + uniques: [], + cols: ["space", "path", "rank"], + rows: [] +}; + +// src/superstate/cacheParsers.ts +var import_lodash2 = __toESM(require_lodash()); + +// src/utils/metadata/frontmatter/parseFrontMatter.ts +var parseFrontMatter = (field, value) => { + const YAMLtype = detectYAMLType(value, field); + switch (YAMLtype) { + case "object": + return JSON.stringify(value); + break; + case "number": + return value.toString(); + break; + case "boolean": + return value ? "true" : "false"; + break; + case "date": + return value; + break; + case "duration": + return serializeMultiDisplayString(Object.keys(value.values).reduce( + (p3, c4) => [ + ...p3, + ...value.values[c4] > 0 ? [value.values[c4] + " " + c4] : [] + ], + [] + )); + break; + case "option-multi": + case "link-multi": + if (typeof value === "string") { + return value; + } + return serializeMultiString( + value.map((v3) => { + if (!v3) { + return ""; + } + if (typeof v3 === "string") { + return v3; + } + if (v3.path) { + return v3.path; + } + if (Array.isArray(value) && v3.length == 1 && Array.isArray(v3[0]) && v3[0].length == 1 && typeof v3[0][0] === "string") { + return v3[0][0]; + } + return JSON.stringify(v3); + }) + ); + break; + case "link": + { + if (Array.isArray(value) && value.length == 1 && Array.isArray(value[0]) && value[0].length == 1 && typeof value[0][0] === "string") { + return value[0][0]; + } else if (typeof value === "string") { + return value; + } + return value.path; + } + break; + case "text": + case "tag": + case "image": + return value; + break; + } + return ""; +}; + +// src/utils/contexts/predicate/filter.ts +var stringEqual = (value, filterValue) => { + return value == filterValue; +}; +var empty = (value, filterValue) => { + return (value != null ? value : "").length == 0; +}; +var stringCompare = (value, filterValue) => { + return (value != null ? value : "").toLowerCase().includes((filterValue != null ? filterValue : "").toLowerCase()); +}; +var greaterThan = (value, filterValue) => { + return parseFloat(value) > parseFloat(filterValue); +}; +var lessThan = (value, filterValue) => { + return parseInt(value) > parseInt(filterValue); +}; +var listIncludes = (value, filterValue) => { + const valueList = value ? parseMultiString(value) : []; + const strings = filterValue ? parseMultiString(filterValue) : []; + return strings.some((f4) => valueList.some((g4) => g4 == f4)); +}; +var filterReturnForCol = (col, filter, row) => { + if (!col) + return true; + const filterType = filterFnTypes[filter == null ? void 0 : filter.fn]; + let result = true; + if (filterType && filterType.fn) { + result = filterType.fn(row[filter.field], filter.value); + } + return result; +}; + +// src/utils/contexts/predicate/filterFns/filterFnTypes.ts +var filterFnTypes = { + isNotEmpty: { + type: ["text", "file", "link", "link-multi", "fileprop", "image"], + fn: (v3, f4) => !empty(v3, ""), + valueType: "none" + }, + isEmpty: { + type: ["text", "file", "link", "link-multi", "fileprop", "image"], + fn: (v3, f4) => empty(v3, ""), + valueType: "none" + }, + include: { + fn: (v3, f4) => stringCompare(v3, f4), + type: ["text", "file", "link", "link-multi", "fileprop", "image"], + valueType: "text" + }, + notInclude: { + type: ["text", "file", "link", "link-multi", "fileprop", "image"], + fn: (v3, f4) => !stringCompare(v3, f4), + valueType: "text" + }, + is: { + type: ["text", "file", "link", "context", "fileprop"], + fn: stringEqual, + valueType: "text" + }, + isNot: { + type: ["text", "file", "link", "context", "fileprop"], + fn: (v3, f4) => !stringEqual(v3, f4), + valueType: "text" + }, + equal: { + type: ["number"], + fn: stringEqual, + valueType: "number" + }, + isGreatThan: { + type: ["number"], + fn: greaterThan, + valueType: "number" + }, + isLessThan: { + type: ["number"], + fn: lessThan, + valueType: "number" + }, + isLessThanOrEqual: { + type: ["number"], + fn: (v3, f4) => !greaterThan(v3, f4), + valueType: "number" + }, + isGreatThanOrEqual: { + type: ["number"], + fn: (v3, f4) => !lessThan(v3, f4), + valueType: "number" + }, + dateBefore: { + type: ["date", "fileprop"], + fn: lessThan, + valueType: "date" + }, + dateAfter: { + type: ["date", "fileprop"], + fn: greaterThan, + valueType: "date" + }, + isAnyInList: { + type: ["option", "context", "option-multi", "context-multi", "tags-multi", "tags"], + fn: listIncludes, + valueType: "list" + }, + isNoneInList: { + type: ["option", "context", "option-multi", "context-multi", "tags-multi", "tags"], + fn: (v3, f4) => !listIncludes(v3, f4), + valueType: "list" + }, + isTrue: { + type: ["boolean"], + fn: (v3, f4) => v3 == "true", + valueType: "none" + }, + isFalse: { + type: ["boolean"], + fn: (v3, f4) => v3 != "true", + valueType: "none" + } +}; + +// src/superstate/cacheParsers.ts +var fileMetadataToVaultItem = (cache) => { + var _a2, _b2; + return { + path: cache.path, + parent: cache.parent, + color: cache.color, + created: (_b2 = (_a2 = cache.ctime) == null ? void 0 : _a2.toString()) != null ? _b2 : "", + sticker: cache.sticker, + folder: cache.isFolder ? "true" : "false", + rank: cache.rank + }; +}; +var parseSpaceCache = (space, spaceItems) => { + return { + name: space.name, + space, + spaceItems + }; +}; + +// src/utils/sanitize.ts +var sanitizeTableName = (name) => { + return name == null ? void 0 : name.replace(/[^a-z0-9+]+/gi, ""); +}; +var sanitizeColumnName = (name) => { + if ((name == null ? void 0 : name.charAt(0)) == "_") { + return sanitizeColumnName(name.substring(1)); + } + return name == null ? void 0 : name.replace(/"/g, ``); +}; +var sanitizeSQLStatement = (name) => { + return name == null ? void 0 : name.replace(/'/g, `''`); +}; + +// src/utils/tree.ts +var import_obsidian7 = require("obsidian"); +var nodeIsAncestorOfTarget = (node, target) => { + var _a2; + if (!node.item || !node.item.isFolder) + return false; + return (_a2 = target.item) == null ? void 0 : _a2.path.contains(node.item.path + "/"); +}; +var excludeVaultItemPredicate = (settings) => (f4, index, folder) => !(f4.folder != "true" && settings.hiddenExtensions.find( + (e4) => fileExtensionForFile(f4.path) == e4 +)) && !settings.hiddenFiles.find((e4) => e4 == f4.path) && (!settings.enableFolderNote || !settings.folderNoteInsideFolder && !folder.some((g4) => g4.path + ".md" == f4.path) || settings.folderNoteInsideFolder && !(f4.parent + "/" + folderPathToString(f4.parent) + ".md" == f4.path)); +var excludeFilePredicate = (plugin) => (f4, index, folder) => !(f4 instanceof import_obsidian7.TFile && plugin.settings.hiddenExtensions.find((e4) => f4.extension == e4)) && !plugin.settings.hiddenFiles.find((e4) => e4 == f4.path) && (!plugin.settings.enableFolderNote || !plugin.settings.folderNoteInsideFolder && !folder.some((g4) => g4.path + ".md" == f4.path) || plugin.settings.folderNoteInsideFolder && !(f4.parent.path + "/" + f4.parent.name + ".md" == f4.path)); +var folderChildren = (plugin, f4, exclusionList) => { + var _a2, _b2; + return (_b2 = (_a2 = f4 == null ? void 0 : f4.children) == null ? void 0 : _a2.filter(excludeFilePredicate(plugin))) != null ? _b2 : []; +}; +var compareByField = (field, dir) => (_a2, _b2) => { + const a5 = dir ? _a2 : _b2; + const b4 = dir ? _b2 : _a2; + if (a5[field] < b4[field]) { + return -1; + } + if (a5[field] > b4[field]) { + return 1; + } + return 0; +}; +var compareByFieldCaseInsensitive = (field, dir) => (_a2, _b2) => { + const a5 = dir ? _a2 : _b2; + const b4 = dir ? _b2 : _a2; + if (a5[field].toLowerCase() < b4[field].toLowerCase()) { + return -1; + } + if (a5[field].toLowerCase() > b4[field].toLowerCase()) { + return 1; + } + return 0; +}; +var internalPluginLoaded = (pluginName, app2) => { + var _a2; + return (_a2 = app2.internalPlugins.plugins[pluginName]) == null ? void 0 : _a2._loaded; +}; +function selectElementContents(el) { + if (!el) + return; + var range = document.createRange(); + range.selectNodeContents(el); + var sel = window.getSelection(); + sel.removeAllRanges(); + sel.addRange(range); +} + +// src/types/context.ts +var FilePropertyName = "File"; + +// src/utils/contexts/parsers.ts +var parsePropString = (str) => { + var _a2; + const [p1, p22] = (_a2 = str == null ? void 0 : str.match(/(\\.|[^.])+/g)) != null ? _a2 : []; + if (p22) + return { + field: p1, + property: p22 + }; + return { field: "File", property: p1 }; +}; + +// src/schemas/mdb.ts +var fieldTypeForType = (type) => fieldTypes.find((t4) => type == t4.type) || fieldTypes.find((t4) => type == t4.multiType); +var fieldTypes = [ + { + type: "unknown", + label: "", + restricted: true + }, + { + type: "preview", + label: i18n_default.properties.preview.label, + restricted: true + }, + { + type: "text", + label: i18n_default.properties.text.label, + metadata: true, + icon: "mk-make-h3" + }, + { + type: "number", + label: i18n_default.properties.number.label, + metadata: true, + icon: "mk-make-tag" + }, + { + type: "boolean", + label: i18n_default.properties.boolean.label, + metadata: true, + icon: "mk-make-todo" + }, + { + type: "date", + label: i18n_default.properties.date.label, + metadata: true, + icon: "mk-make-date" + }, + { + type: "option", + label: i18n_default.properties.option.label, + multi: true, + multiType: "option-multi", + icon: "mk-make-list" + }, + { + type: "file", + label: i18n_default.properties.file.label, + restricted: true, + icon: "mk-make-h3" + }, + { + type: "fileprop", + label: i18n_default.properties.fileProperty.label + }, + { + type: "link", + label: i18n_default.properties.link.label, + multi: true, + multiType: "link-multi", + metadata: true, + icon: "mk-make-note" + }, + { + type: "context", + label: i18n_default.properties.context.label, + multi: true, + multiType: "context-multi", + icon: "mk-make-note" + }, + { + type: "object", + label: i18n_default.properties.context.label, + restricted: true, + metadata: true + }, + { + type: "image", + label: i18n_default.properties.image.label, + multi: true, + multiType: "image-multi", + metadata: true, + icon: "mk-make-image" + } +]; +var defaultValueForPropertyType = (name, value, type) => { + if (type == "preview") { + return "https://images.unsplash.com/photo-1675789652575-0a5d2425b6c2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80"; + } + if (type == "fileprop") { + const { field, property } = parsePropString(value); + if (property == "ctime" || property == "mtime") + return (Date.now() - 60).toString(); + return value; + } + if (type == "file") { + return "Note Name"; + } + if (type == "date") { + return "2020-04-21"; + } + if (type == "number") { + return "123"; + } + if (type == "boolean") { + return "true"; + } + if (type == "link") { + return "[[Select Note]]"; + } + if (type == "option") { + return "one, two"; + } + if (type == "text") { + return name; + } + if (type == "image") { + return "https://images.unsplash.com/photo-1675789652575-0a5d2425b6c2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80"; + } + return ""; +}; +var defaultFileDBSchema = { + id: "files", + name: "Files", + type: "db", + primary: "true" +}; +var defaultFileListSchema = { + id: "filesView", + name: "Files", + type: "list", + def: "files" +}; +var defaultFileTableSchema = { + id: "filesView", + name: "Files", + type: "table", + def: "files" +}; +var defaultFolderSchema = { + uniques: [], + cols: ["id", "name", "type", "def", "predicate", "primary"], + rows: [defaultFileDBSchema, defaultFileListSchema] +}; +var defaultTagSchema = { + uniques: [], + cols: ["id", "name", "type", "def", "predicate", "primary"], + rows: [defaultFileDBSchema, defaultFileTableSchema] +}; +var fieldSchema = { + uniques: ["name,schemaId"], + cols: [ + "name", + "schemaId", + "type", + "value", + "attrs", + "hidden", + "unique", + "primary" + ] +}; +var defaultFolderFields = { + ...fieldSchema, + rows: [ + { + name: i18n_default.properties.preview.label, + schemaId: "files", + type: "preview", + hidden: "", + unique: "", + attrs: "", + value: "", + primary: "" }, - { n: ["flag-gt", "guatemala flag"], u: "1f1ec-1f1f9" }, - { n: ["flag-gu", "guam flag"], u: "1f1ec-1f1fa" }, - { n: ["flag-gw", "guinea-bissau flag"], u: "1f1ec-1f1fc" }, - { n: ["flag-gy", "guyana flag"], u: "1f1ec-1f1fe" }, - { n: ["flag-hk", "hong kong sar china flag"], u: "1f1ed-1f1f0" }, - { n: ["flag-hm", "heard & mcdonald islands flag"], u: "1f1ed-1f1f2" }, - { n: ["flag-hn", "honduras flag"], u: "1f1ed-1f1f3" }, - { n: ["flag-hr", "croatia flag"], u: "1f1ed-1f1f7" }, - { n: ["flag-ht", "haiti flag"], u: "1f1ed-1f1f9" }, - { n: ["flag-hu", "hungary flag"], u: "1f1ed-1f1fa" }, - { n: ["flag-ic", "canary islands flag"], u: "1f1ee-1f1e8" }, - { n: ["flag-id", "indonesia flag"], u: "1f1ee-1f1e9" }, - { n: ["flag-ie", "ireland flag"], u: "1f1ee-1f1ea" }, - { n: ["flag-il", "israel flag"], u: "1f1ee-1f1f1" }, - { n: ["flag-im", "isle of man flag"], u: "1f1ee-1f1f2" }, - { n: ["flag-in", "india flag"], u: "1f1ee-1f1f3" }, - { n: ["flag-io", "british indian ocean territory flag"], u: "1f1ee-1f1f4" }, - { n: ["flag-iq", "iraq flag"], u: "1f1ee-1f1f6" }, - { n: ["flag-ir", "iran flag"], u: "1f1ee-1f1f7" }, - { n: ["flag-is", "iceland flag"], u: "1f1ee-1f1f8" }, - { n: ["it", "flag-it", "italy flag"], u: "1f1ee-1f1f9" }, - { n: ["flag-je", "jersey flag"], u: "1f1ef-1f1ea" }, - { n: ["flag-jm", "jamaica flag"], u: "1f1ef-1f1f2" }, - { n: ["flag-jo", "jordan flag"], u: "1f1ef-1f1f4" }, - { n: ["jp", "flag-jp", "japan flag"], u: "1f1ef-1f1f5" }, - { n: ["flag-ke", "kenya flag"], u: "1f1f0-1f1ea" }, - { n: ["flag-kg", "kyrgyzstan flag"], u: "1f1f0-1f1ec" }, - { n: ["flag-kh", "cambodia flag"], u: "1f1f0-1f1ed" }, - { n: ["flag-ki", "kiribati flag"], u: "1f1f0-1f1ee" }, - { n: ["flag-km", "comoros flag"], u: "1f1f0-1f1f2" }, - { n: ["flag-kn", "st. kitts & nevis flag"], u: "1f1f0-1f1f3" }, - { n: ["flag-kp", "north korea flag"], u: "1f1f0-1f1f5" }, - { n: ["kr", "flag-kr", "south korea flag"], u: "1f1f0-1f1f7" }, - { n: ["flag-kw", "kuwait flag"], u: "1f1f0-1f1fc" }, - { n: ["flag-ky", "cayman islands flag"], u: "1f1f0-1f1fe" }, - { n: ["flag-kz", "kazakhstan flag"], u: "1f1f0-1f1ff" }, - { n: ["flag-la", "laos flag"], u: "1f1f1-1f1e6" }, - { n: ["flag-lb", "lebanon flag"], u: "1f1f1-1f1e7" }, - { n: ["flag-lc", "st. lucia flag"], u: "1f1f1-1f1e8" }, - { n: ["flag-li", "liechtenstein flag"], u: "1f1f1-1f1ee" }, - { n: ["flag-lk", "sri lanka flag"], u: "1f1f1-1f1f0" }, - { n: ["flag-lr", "liberia flag"], u: "1f1f1-1f1f7" }, - { n: ["flag-ls", "lesotho flag"], u: "1f1f1-1f1f8" }, - { n: ["flag-lt", "lithuania flag"], u: "1f1f1-1f1f9" }, - { n: ["flag-lu", "luxembourg flag"], u: "1f1f1-1f1fa" }, - { n: ["flag-lv", "latvia flag"], u: "1f1f1-1f1fb" }, - { n: ["flag-ly", "libya flag"], u: "1f1f1-1f1fe" }, - { n: ["flag-ma", "morocco flag"], u: "1f1f2-1f1e6" }, - { n: ["flag-mc", "monaco flag"], u: "1f1f2-1f1e8" }, - { n: ["flag-md", "moldova flag"], u: "1f1f2-1f1e9" }, - { n: ["flag-me", "montenegro flag"], u: "1f1f2-1f1ea" }, - { n: ["flag-mf", "st. martin flag"], u: "1f1f2-1f1eb" }, - { n: ["flag-mg", "madagascar flag"], u: "1f1f2-1f1ec" }, - { n: ["flag-mh", "marshall islands flag"], u: "1f1f2-1f1ed" }, - { n: ["flag-mk", "north macedonia flag"], u: "1f1f2-1f1f0" }, - { n: ["flag-ml", "mali flag"], u: "1f1f2-1f1f1" }, - { n: ["flag-mm", "myanmar (burma) flag"], u: "1f1f2-1f1f2" }, - { n: ["flag-mn", "mongolia flag"], u: "1f1f2-1f1f3" }, - { n: ["flag-mo", "macao sar china flag"], u: "1f1f2-1f1f4" }, - { n: ["flag-mp", "northern mariana islands flag"], u: "1f1f2-1f1f5" }, - { n: ["flag-mq", "martinique flag"], u: "1f1f2-1f1f6" }, - { n: ["flag-mr", "mauritania flag"], u: "1f1f2-1f1f7" }, - { n: ["flag-ms", "montserrat flag"], u: "1f1f2-1f1f8" }, - { n: ["flag-mt", "malta flag"], u: "1f1f2-1f1f9" }, - { n: ["flag-mu", "mauritius flag"], u: "1f1f2-1f1fa" }, - { n: ["flag-mv", "maldives flag"], u: "1f1f2-1f1fb" }, - { n: ["flag-mw", "malawi flag"], u: "1f1f2-1f1fc" }, - { n: ["flag-mx", "mexico flag"], u: "1f1f2-1f1fd" }, - { n: ["flag-my", "malaysia flag"], u: "1f1f2-1f1fe" }, - { n: ["flag-mz", "mozambique flag"], u: "1f1f2-1f1ff" }, - { n: ["flag-na", "namibia flag"], u: "1f1f3-1f1e6" }, - { n: ["flag-nc", "new caledonia flag"], u: "1f1f3-1f1e8" }, - { n: ["flag-ne", "niger flag"], u: "1f1f3-1f1ea" }, - { n: ["flag-nf", "norfolk island flag"], u: "1f1f3-1f1eb" }, - { n: ["flag-ng", "nigeria flag"], u: "1f1f3-1f1ec" }, - { n: ["flag-ni", "nicaragua flag"], u: "1f1f3-1f1ee" }, - { n: ["flag-nl", "netherlands flag"], u: "1f1f3-1f1f1" }, - { n: ["flag-no", "norway flag"], u: "1f1f3-1f1f4" }, - { n: ["flag-np", "nepal flag"], u: "1f1f3-1f1f5" }, - { n: ["flag-nr", "nauru flag"], u: "1f1f3-1f1f7" }, - { n: ["flag-nu", "niue flag"], u: "1f1f3-1f1fa" }, - { n: ["flag-nz", "new zealand flag"], u: "1f1f3-1f1ff" }, - { n: ["flag-om", "oman flag"], u: "1f1f4-1f1f2" }, - { n: ["flag-pa", "panama flag"], u: "1f1f5-1f1e6" }, - { n: ["flag-pe", "peru flag"], u: "1f1f5-1f1ea" }, - { n: ["flag-pf", "french polynesia flag"], u: "1f1f5-1f1eb" }, - { n: ["flag-pg", "papua new guinea flag"], u: "1f1f5-1f1ec" }, - { n: ["flag-ph", "philippines flag"], u: "1f1f5-1f1ed" }, - { n: ["flag-pk", "pakistan flag"], u: "1f1f5-1f1f0" }, - { n: ["flag-pl", "poland flag"], u: "1f1f5-1f1f1" }, - { n: ["flag-pm", "st. pierre & miquelon flag"], u: "1f1f5-1f1f2" }, - { n: ["flag-pn", "pitcairn islands flag"], u: "1f1f5-1f1f3" }, - { n: ["flag-pr", "puerto rico flag"], u: "1f1f5-1f1f7" }, - { n: ["flag-ps", "palestinian territories flag"], u: "1f1f5-1f1f8" }, - { n: ["flag-pt", "portugal flag"], u: "1f1f5-1f1f9" }, - { n: ["flag-pw", "palau flag"], u: "1f1f5-1f1fc" }, - { n: ["flag-py", "paraguay flag"], u: "1f1f5-1f1fe" }, - { n: ["flag-qa", "qatar flag"], u: "1f1f6-1f1e6" }, - { n: ["flag-re", "r\xE9union flag"], u: "1f1f7-1f1ea" }, - { n: ["flag-ro", "romania flag"], u: "1f1f7-1f1f4" }, - { n: ["flag-rs", "serbia flag"], u: "1f1f7-1f1f8" }, - { n: ["ru", "flag-ru", "russia flag"], u: "1f1f7-1f1fa" }, - { n: ["flag-rw", "rwanda flag"], u: "1f1f7-1f1fc" }, - { n: ["flag-sa", "saudi arabia flag"], u: "1f1f8-1f1e6" }, - { n: ["flag-sb", "solomon islands flag"], u: "1f1f8-1f1e7" }, - { n: ["flag-sc", "seychelles flag"], u: "1f1f8-1f1e8" }, - { n: ["flag-sd", "sudan flag"], u: "1f1f8-1f1e9" }, - { n: ["flag-se", "sweden flag"], u: "1f1f8-1f1ea" }, - { n: ["flag-sg", "singapore flag"], u: "1f1f8-1f1ec" }, - { n: ["flag-sh", "st. helena flag"], u: "1f1f8-1f1ed" }, - { n: ["flag-si", "slovenia flag"], u: "1f1f8-1f1ee" }, - { n: ["flag-sj", "svalbard & jan mayen flag"], u: "1f1f8-1f1ef" }, - { n: ["flag-sk", "slovakia flag"], u: "1f1f8-1f1f0" }, - { n: ["flag-sl", "sierra leone flag"], u: "1f1f8-1f1f1" }, - { n: ["flag-sm", "san marino flag"], u: "1f1f8-1f1f2" }, - { n: ["flag-sn", "senegal flag"], u: "1f1f8-1f1f3" }, - { n: ["flag-so", "somalia flag"], u: "1f1f8-1f1f4" }, - { n: ["flag-sr", "suriname flag"], u: "1f1f8-1f1f7" }, - { n: ["flag-ss", "south sudan flag"], u: "1f1f8-1f1f8" }, - { n: ["flag-st", "s\xE3o tom\xE9 & pr\xEDncipe flag"], u: "1f1f8-1f1f9" }, - { n: ["flag-sv", "el salvador flag"], u: "1f1f8-1f1fb" }, - { n: ["flag-sx", "sint maarten flag"], u: "1f1f8-1f1fd" }, - { n: ["flag-sy", "syria flag"], u: "1f1f8-1f1fe" }, - { n: ["flag-sz", "eswatini flag"], u: "1f1f8-1f1ff" }, - { n: ["flag-ta", "tristan da cunha flag"], u: "1f1f9-1f1e6" }, - { n: ["flag-tc", "turks & caicos islands flag"], u: "1f1f9-1f1e8" }, - { n: ["flag-td", "chad flag"], u: "1f1f9-1f1e9" }, - { n: ["flag-tf", "french southern territories flag"], u: "1f1f9-1f1eb" }, - { n: ["flag-tg", "togo flag"], u: "1f1f9-1f1ec" }, - { n: ["flag-th", "thailand flag"], u: "1f1f9-1f1ed" }, - { n: ["flag-tj", "tajikistan flag"], u: "1f1f9-1f1ef" }, - { n: ["flag-tk", "tokelau flag"], u: "1f1f9-1f1f0" }, - { n: ["flag-tl", "timor-leste flag"], u: "1f1f9-1f1f1" }, - { n: ["flag-tm", "turkmenistan flag"], u: "1f1f9-1f1f2" }, - { n: ["flag-tn", "tunisia flag"], u: "1f1f9-1f1f3" }, - { n: ["flag-to", "tonga flag"], u: "1f1f9-1f1f4" }, - { n: ["flag-tr", "turkey flag"], u: "1f1f9-1f1f7" }, - { n: ["flag-tt", "trinidad & tobago flag"], u: "1f1f9-1f1f9" }, - { n: ["flag-tv", "tuvalu flag"], u: "1f1f9-1f1fb" }, - { n: ["flag-tw", "taiwan flag"], u: "1f1f9-1f1fc" }, - { n: ["flag-tz", "tanzania flag"], u: "1f1f9-1f1ff" }, - { n: ["flag-ua", "ukraine flag"], u: "1f1fa-1f1e6" }, - { n: ["flag-ug", "uganda flag"], u: "1f1fa-1f1ec" }, - { n: ["flag-um", "u.s. outlying islands flag"], u: "1f1fa-1f1f2" }, - { n: ["flag-un", "united nations flag"], u: "1f1fa-1f1f3" }, - { n: ["us", "flag-us", "united states flag"], u: "1f1fa-1f1f8" }, - { n: ["flag-uy", "uruguay flag"], u: "1f1fa-1f1fe" }, - { n: ["flag-uz", "uzbekistan flag"], u: "1f1fa-1f1ff" }, - { n: ["flag-va", "vatican city flag"], u: "1f1fb-1f1e6" }, - { n: ["flag-vc", "st. vincent & grenadines flag"], u: "1f1fb-1f1e8" }, - { n: ["flag-ve", "venezuela flag"], u: "1f1fb-1f1ea" }, - { n: ["flag-vg", "british virgin islands flag"], u: "1f1fb-1f1ec" }, - { n: ["flag-vi", "u.s. virgin islands flag"], u: "1f1fb-1f1ee" }, - { n: ["flag-vn", "vietnam flag"], u: "1f1fb-1f1f3" }, - { n: ["flag-vu", "vanuatu flag"], u: "1f1fb-1f1fa" }, - { n: ["flag-wf", "wallis & futuna flag"], u: "1f1fc-1f1eb" }, - { n: ["flag-ws", "samoa flag"], u: "1f1fc-1f1f8" }, - { n: ["flag-xk", "kosovo flag"], u: "1f1fd-1f1f0" }, - { n: ["flag-ye", "yemen flag"], u: "1f1fe-1f1ea" }, - { n: ["flag-yt", "mayotte flag"], u: "1f1fe-1f1f9" }, - { n: ["flag-za", "south africa flag"], u: "1f1ff-1f1e6" }, - { n: ["flag-zm", "zambia flag"], u: "1f1ff-1f1f2" }, - { n: ["flag-zw", "zimbabwe flag"], u: "1f1ff-1f1fc" }, { - n: ["england flag", "flag-england"], - u: "1f3f4-e0067-e0062-e0065-e006e-e0067-e007f" + name: FilePropertyName, + schemaId: "files", + type: "file", + primary: "true", + hidden: "", + unique: "", + attrs: "", + value: "" }, { - n: ["scotland flag", "flag-scotland"], - u: "1f3f4-e0067-e0062-e0073-e0063-e0074-e007f" - }, + name: i18n_default.properties.fileProperty.createdTime, + schemaId: "files", + type: "fileprop", + value: "File.ctime", + hidden: "", + unique: "", + attrs: "", + primary: "" + } + ] +}; +var defaultFieldsForContext = (context) => { + if (context.type == "tag") { + return defaultTagFields; + } else if (context.type == "folder") { + return defaultFolderFields; + } + return defaultFolderFields; +}; +var defaultTableFields = [ + { + name: i18n_default.properties.defaultField, + schemaId: "", + type: "text" + } +]; +var defaultTagFields = { + ...fieldSchema, + rows: [ { - n: ["wales flag", "flag-wales"], - u: "1f3f4-e0067-e0062-e0077-e006c-e0073-e007f" + name: FilePropertyName, + schemaId: "files", + type: "file", + primary: "true", + hidden: "", + unique: "", + attrs: "", + value: "" } ] }; +var defaultMDBTableForContext = (context) => { + if (context.type == "tag") { + return defaultTagMDBTable; + } else if (context.type == "folder") { + return defaultFolderMDBTable; + } + return defaultFolderMDBTable; +}; +var defaultFolderMDBTable = { + schema: defaultFileDBSchema, + cols: defaultFolderFields.rows, + rows: [] +}; +var defaultQueryMDBTable = { + schema: defaultFileDBSchema, + cols: defaultFolderFields.rows, + rows: [] +}; +var defaultTagMDBTable = { + schema: defaultFileDBSchema, + cols: defaultTagFields.rows, + rows: [] +}; +var fieldsToTable = (fields, schemas) => { + return fields.filter((s5) => schemas.find((g4) => g4.id == s5.schemaId && g4.type == "db")).reduce((p3, c4) => { + return { + ...p3, + ...p3[c4.schemaId] ? { + [c4.schemaId]: { + uniques: c4.unique == "true" ? [...p3[c4.schemaId].uniques, c4.name] : p3[c4.schemaId].uniques, + cols: [...p3[c4.schemaId].cols, c4.name], + rows: [] + } + } : { + [c4.schemaId]: { + uniques: c4.unique == "true" ? [c4.name] : [], + cols: [c4.name], + rows: [] + } + } + }; + }, {}); +}; +var defaultTablesForContext = (context) => { + if (context.type == "tag") { + return defaultTagTables; + } else if (context.type == "folder") { + return defaultFolderTables; + } + return defaultFolderTables; +}; +var defaultFolderTables = { + m_schema: defaultFolderSchema, + m_fields: defaultFolderFields, + ...fieldsToTable( + defaultFolderFields.rows, + defaultFolderSchema.rows + ) +}; +var defaultTagTables = { + m_schema: defaultTagSchema, + m_fields: defaultTagFields, + ...fieldsToTable( + defaultTagFields.rows, + defaultTagSchema.rows + ) +}; -// src/components/ui/modals/stickerModal.tsx +// src/utils/db/db.ts var import_obsidian8 = require("obsidian"); -var stickerModal = class extends import_obsidian8.FuzzySuggestModal { - constructor(app2, setIcon) { - super(app2); - this.setIcon = setIcon; - this.resultContainerEl.toggleClass("mk-sticker-modal", true); - this.inputEl.focus(); - this.emptyStateText = i18n_default.labels.findStickers; - this.limit = 0; +var getDBFile = async (path, isRemote) => { + if (isRemote) { + return fetch(path).then((res) => res.arrayBuffer()); } - renderSuggestion(item, el) { - el.innerHTML = stickerFromString(item.item.unicode); - el.setAttr("aria-label", item.item.label); + if (!await app.vault.adapter.exists((0, import_obsidian8.normalizePath)(path))) { + return null; } - getItemText(item) { - return item.label + item.desc; + const file = await app.vault.adapter.readBinary( + (0, import_obsidian8.normalizePath)(path) + ); + return file; +}; +var getDB = async (sqlJS, path, isRemote) => { + const buf = await getDBFile(path, isRemote); + if (buf) { + return new sqlJS.Database(new Uint8Array(buf)); } - getItems() { - const allEmojis = Object.keys(emojis).reduce( - (p3, c4) => [ - ...p3, - ...emojis[c4].map((e4) => ({ - label: e4.n[0], - desc: e4.n[1], - variants: e4.v, - unicode: e4.u - })) - ], - [] - ); - return allEmojis; + return new sqlJS.Database(); +}; +var saveDBFile = async (path, binary) => { + const file = app.vault.adapter.writeBinary( + (0, import_obsidian8.normalizePath)(path), + binary + ); + return file; +}; +var dbResultsToDBTables = (res) => { + return res.reduce( + (p3, c4, i4) => [ + ...p3, + { + cols: c4.columns, + rows: c4 ? c4.values.map( + (r3) => c4.columns.reduce( + (prev, curr, index) => ({ ...prev, [curr]: r3[index] }), + {} + ) + ) : [] + } + ], + [] + ); +}; +var selectDB = (db, table, condition, fields) => { + const fieldsStr = fields != null ? fields : "*"; + const sqlstr = condition ? `SELECT ${fieldsStr} FROM "${table}" WHERE ${condition};` : `SELECT ${fieldsStr} FROM ${table};`; + let tables; + try { + tables = dbResultsToDBTables(db.exec(sqlstr)); + } catch (e4) { + return null; } - onChooseItem(item, evt) { - this.setIcon(item.unicode); + if (tables.length == 1) + return tables[0]; + return null; +}; +var deleteFromDB = (db, table, condition) => { + const sqlstr = `DELETE FROM "${table}" WHERE ${condition};`; + try { + db.exec(sqlstr); + } catch (e4) { + console.log(e4); } }; +var dropTable = (db, table) => { + const sqlstr = `DROP TABLE IF EXISTS "${table}";`; + try { + db.exec(sqlstr); + } catch (e4) { + console.log(e4); + } +}; +var replaceDB = (db, tables) => { + const sqlstr = serializeSQLStatements(Object.keys(tables).map((t4) => { + const tableFields = tables[t4].cols; + const fieldQuery = serializeSQLFieldNames(uniq(tableFields).map((f4) => `'${sanitizeSQLStatement(f4)}' char`)); + const rowsQuery = tables[t4].rows.reduce((prev, curr) => { + return `${prev} REPLACE INTO "${t4}" VALUES (${serializeSQLValues(tableFields.map((c4) => { + var _a2; + return `'${(_a2 = sanitizeSQLStatement(curr == null ? void 0 : curr[c4])) != null ? _a2 : ""}'`; + }))});`; + }, ""); + const idxQuery = tables[t4].uniques.filter((f4) => f4).reduce((p3, c4) => { + return `${p3} CREATE UNIQUE INDEX IF NOT EXISTS idx_${t4}_${c4.replace( + /,/g, + "_" + )} ON ${t4}(${c4});`; + }, ""); + const insertQuery = `CREATE TABLE IF NOT EXISTS "${t4}" (${fieldQuery}); ${idxQuery} BEGIN TRANSACTION; ${rowsQuery} COMMIT;`; + return `DROP INDEX IF EXISTS idx_${t4}__id; DROP TABLE IF EXISTS "${t4}"; ${fieldQuery.length > 0 ? insertQuery : ""}`; + })); + try { + db.exec(sqlstr); + } catch (e4) { + console.log(e4); + } +}; +var saveDBToPath = async (plugin, path, tables) => { + const sqlJS = await plugin.sqlJS(); + let db = await getDB(sqlJS, path); + if (!db) { + db.close(); + return false; + } + replaceDB(db, tables); + await saveDBFile(path, db.export().buffer); + db.close(); + return true; +}; -// src/components/FileSticker/FileSticker.tsx -var import_obsidian11 = require("obsidian"); - -// src/components/ui/modals/vaultChangeModals.ts +// src/utils/metadata/tags.ts var import_obsidian9 = require("obsidian"); -var VaultChangeModal = class extends import_obsidian9.Modal { - constructor(plugin, file, action, space) { - super(plugin.app); - this.file = file; - this.action = action; - this.plugin = plugin; - this.space = space; +var tagKeys = ["tag", "tags", "Tag", "Tags"]; +var tagToTagPath = (tag) => { + if (!tag) + return null; + let string = tag; + if (string.charAt(0) != "#") + string = "#" + string; + return string.replace(/\//g, "+"); +}; +var tagPathToTag = (string) => { + return filePathToString(string).replace(/\+/g, "/"); +}; +var loadTags = (plugin) => { + var _a2; + const folder = plugin.settings.tagContextFolder == "" ? app.vault.getRoot() : getAbstractFileAtPath( + app, + getFolderPathFromString(plugin.settings.tagContextFolder) + ); + return uniq([ + ...Object.keys(app.metadataCache.getTags()), + ...(_a2 = folder == null ? void 0 : folder.children.filter( + (f4) => f4 instanceof import_obsidian9.TFile && f4.extension == "mdb" && f4.name.charAt(0) == "#" + ).map((f4) => tagPathToTag(f4.name))) != null ? _a2 : [] + ]); +}; +var tagExists = (currentCache, findTag) => { + let currentTags = []; + if ((0, import_obsidian9.getAllTags)(currentCache)) { + currentTags = (0, import_obsidian9.getAllTags)(currentCache); } - onOpen() { - let { contentEl } = this; - let myModal = this; - let headerText; - if (this.action === "rename") { - headerText = i18n_default.labels.rename; - } else if (this.action === "create folder") { - headerText = i18n_default.labels.createFolder; - } else if (this.action === "create note") { - headerText = i18n_default.labels.createNote; - } - const headerEl = contentEl.createEl("div", { text: headerText }); - headerEl.addClass("modal-title"); - const inputEl = contentEl.createEl("input"); - inputEl.style.cssText = "width: 100%; height: 2.5em; margin-bottom: 15px;"; - if (this.action === "rename") { - inputEl.value = this.file.name.substring( - 0, - indexOfCharElseEOS(".", this.file.name) - ); - } - inputEl.focus(); - let changeButtonText; - if (this.action === "rename") { - changeButtonText = i18n_default.buttons.rename; - } else if (this.action === "create folder") { - changeButtonText = i18n_default.buttons.createFolder; - } else if (this.action === "create note") { - changeButtonText = i18n_default.buttons.createNote; - } - const changeButton = contentEl.createEl("button", { - text: changeButtonText - }); - const cancelButton = contentEl.createEl("button", { - text: i18n_default.buttons.cancel - }); - cancelButton.style.cssText = "float: right;"; - cancelButton.addEventListener("click", () => { - myModal.close(); + return currentTags.find((tag) => tag.toLowerCase() == findTag.toLowerCase()) ? true : false; +}; +var getAllFilesForTag = (tag) => { + let tagsCache = []; + (() => { + app.vault.getMarkdownFiles().forEach((tfile) => { + let currentCache; + if (app.metadataCache.getFileCache(tfile) !== null) { + currentCache = app.metadataCache.getFileCache(tfile); + } + let relativePath = tfile.path; + const hasTag = tagExists(currentCache, tag); + if (hasTag) { + tagsCache.push(relativePath); + } }); - const onClickAction = async () => { - let newName = inputEl.value; - if (this.action === "rename") { - newName = this.file.name.lastIndexOf(".") == -1 ? newName : newName + this.file.name.substring(this.file.name.lastIndexOf(".")); - renameFile(this.plugin, this.file, newName); - } else if (this.action === "create folder") { - const path = !this.file || this.file.path == "/" ? newName : this.file.path + "/" + newName; - if (getAbstractFileAtPath(app, path)) { - new import_obsidian9.Notice(i18n_default.notice.folderExists); - return; - } - this.app.vault.createFolder(path); - if (this.space != "/") - addPathsToSpace(this.plugin, this.space, [path]); + })(); + return tagsCache; +}; +var addTagToNote = (tag, tFile) => { + const newTag = validateName(tag); + editTagInFrontmatter("", newTag, tFile); +}; +var positionsForTag = (tag, file) => { + const currentCache = app.metadataCache.getFileCache(file); + if (currentCache.tags) { + const positions = currentCache.tags.filter((f4) => f4.tag == tag).map((f4) => f4.position).sort((a5, b4) => { + if (a5.start.offset < b4.start.offset) { + return -1; } - myModal.close(); - }; - changeButton.addEventListener("click", onClickAction); - inputEl.addEventListener("keydown", (e4) => { - if (e4.key === "Enter") - onClickAction(); + if (a5.start.offset > b4.start.offset) { + return 1; + } + return 0; }); + return positions; } - onClose() { - let { contentEl } = this; - contentEl.empty(); + return []; +}; +var removeTagFromFile = (tag, file) => { + const pos = positionsForTag(tag, file); + removeTagInFrontmatter(tag, file); + editTagInFileBody(tag, "", pos, file); +}; +var validateName = (tag) => { + return tag; +}; +var deleteTag = async (plugin, tag, subTags) => { + const files = getAllFilesForTag(tag).map((f4) => getAbstractFileAtPath(app, f4)).filter((f4) => f4 instanceof import_obsidian9.TFile); + files.forEach((file) => removeTagFromFile(tag, file)); + deleteTagContext(plugin, tag); + if (subTags) { + const tags = getAllSubtags(plugin, tag); + tags.forEach((tag2) => deleteTag(plugin, tag2, subTags)); } }; -var MoveSuggestionModal = class extends import_obsidian9.FuzzySuggestModal { - constructor(app2, files) { - super(app2); - this.files = files; +var tagsFromDefString = (defStr) => parseContextDefString(defStr).filter((f4) => f4.type == "tag" && f4.value.length > 0).map((f4) => f4.value); +var updateTagsForDefString = (defStr, tags) => JSON.stringify([...parseContextDefString(defStr).filter((f4) => f4.type != "tag"), ...tags.map((f4) => ({ type: "tag", value: f4 }))]); +var addTag = async (plugin, tag) => { + const context = tagContextFromTag(plugin, tag); + await createDefaultDB(plugin, context); +}; +var renameTag = async (plugin, tag, toTag) => { + const tags = getAllSubtags(plugin, tag); + const newTag = validateName(toTag); + const files = getAllFilesForTag(tag); + for (const file of files) { + const tFile = getAbstractFileAtPath(app, file); + if (tFile instanceof import_obsidian9.TFile) { + const positions = positionsForTag(tag, tFile); + if (positions.length > 0) { + await editTagInFileBody(tag, newTag, positions, tFile); + } else { + await editTagInFrontmatter(tag, newTag, tFile); + } + } } - getItemText(item) { - return item.path; + await renameTagContextFile(plugin, tag, toTag); + for (const subtag of tags) { + await renameTag(plugin, subtag, subtag.replace(tag, newTag)); } - getItems() { - return getAllFoldersInVault(this.app); +}; +var getAllSubtags = (plugin, tag) => { + const tags = loadTags(plugin); + return tags.filter((f4) => f4.startsWith(tag) && f4 != tag); +}; +var removeTagInFrontmatter = async (oldTag, file) => { + var _a2; + let fm; + if (app.metadataCache.getFileCache(file) !== null) { + fm = (_a2 = app.metadataCache.getFileCache(file)) == null ? void 0 : _a2.frontmatter; } - onChooseItem(item, evt) { - this.files.forEach((f4) => { - const file = getAbstractFileAtPath(app, f4); - if (file) { - this.app.vault.rename(file, item.path + "/" + file.name); + if (fm && app.fileManager.processFrontMatter) { + const processKey = (value) => { + if (Array.isArray(value)) { + return value.filter((f4) => stringFromTag(oldTag) != f4); + } else if (typeof value === "string") { + return serializeMultiDisplayString( + value.replace(/\s/g, "").split(",").filter((f4) => stringFromTag(oldTag) != f4) + ); } + return value; + }; + const editKeys = tagKeys.filter((f4) => { + let tags = []; + if (Array.isArray(fm[f4])) { + tags = fm[f4]; + } else if (typeof fm[f4] === "string") { + tags = fm[f4].replace(/\s/g, "").split(","); + } + if (tags.find((g4) => g4 == stringFromTag(oldTag))) + return true; + return false; + }); + editKeys.forEach((tag) => { + app.fileManager.processFrontMatter(file, (frontmatter) => { + frontmatter[tag] = processKey(fm[tag]); + }); }); } }; -function getAllFoldersInVault(app2) { - let folders = []; - let rootFolder = app2.vault.getRoot(); - folders.push(rootFolder); - function recursiveFx(folder) { - for (let child of folder.children) { - if (child instanceof import_obsidian9.TFolder) { - let childFolder = child; - folders.push(childFolder); - if (childFolder.children) - recursiveFx(childFolder); - } - } - } - recursiveFx(rootFolder); - return folders; -} -var AddToSpaceModal = class extends import_obsidian9.FuzzySuggestModal { - constructor(plugin, files) { - super(app); - this.plugin = plugin; - this.files = files; - } - getItemText(space) { - return space.name; - } - getItems() { - return this.plugin.index.allSpaces().filter((f4) => f4.def.type == "focus"); +var editTagInFrontmatter = async (oldTag, newTag, file) => { + var _a2; + let fm; + if (app.metadataCache.getFileCache(file) !== null) { + fm = (_a2 = app.metadataCache.getFileCache(file)) == null ? void 0 : _a2.frontmatter; } - onChooseItem(space, evt) { - this.files.forEach((f4) => { - var _a2; - const file = this.plugin.index.files.get(f4); - if (file) { - if (((_a2 = space.def.folder) == null ? void 0 : _a2.length) > 0) { - moveAFileToNewParentAtIndex(this.plugin, file, space.def.folder, 0); - } else { - insertSpaceItemAtIndex(this.plugin, space.name, file.path, 0); + const addTag2 = (value) => { + if (Array.isArray(value)) { + return uniq([...value, stringFromTag(newTag)]).filter((f4) => (f4 == null ? void 0 : f4.length) > 0); + } else if (typeof value === "string") { + return serializeMultiDisplayString(uniq([ + ...value.replace(/\s/g, "").split(","), + stringFromTag(newTag) + ]).filter((f4) => (f4 == null ? void 0 : f4.length) > 0)); + } + return stringFromTag(newTag); + }; + if (app.fileManager.processFrontMatter) { + if (fm) { + const processKey = (value) => { + if (Array.isArray(value)) { + return uniq( + value.map( + (f4) => stringFromTag(oldTag) == f4 ? stringFromTag(newTag) : f4 + ) + ); + } else if (typeof value === "string") { + return serializeMultiDisplayString(uniq( + value.replace(/\s/g, "").split(",").map( + (f4) => stringFromTag(oldTag) == f4 ? stringFromTag(newTag) : f4 + ) + )); + } + return value; + }; + const editKeys = tagKeys.filter((f4) => { + let tags = []; + if (Array.isArray(fm[f4])) { + tags = fm[f4]; + } else if (typeof fm[f4] === "string") { + tags = fm[f4].replace(/\s/g, "").split(","); } + if (tags.find((g4) => g4 == stringFromTag(oldTag))) + return true; + return false; + }); + if (editKeys.length > 0) { + editKeys.forEach((key2) => { + app.fileManager.processFrontMatter(file, (frontmatter) => { + frontmatter[key2] = processKey(fm[key2]); + }); + }); + } else { + app.fileManager.processFrontMatter(file, (frontmatter) => { + frontmatter["tag"] = addTag2(fm["tag"]); + }); } - }); + } else { + app.fileManager.processFrontMatter(file, (frontmatter) => { + frontmatter["tag"] = stringFromTag(newTag); + }); + } } }; -var RemoveFromSpaceModal = class extends import_obsidian9.FuzzySuggestModal { - constructor(plugin, file) { - super(app); - this.plugin = plugin; - this.file = this.plugin.index.files.get(file); - } - getItemText(space) { - return space.name; +var editTagInFileBody = async (oldTag, newTag, positions, file) => { + const offsetOffset = newTag.length - oldTag.length; + if (positions.length == 0) + return false; + const original = await app.vault.read(file); + let text2 = original; + let offset = 0; + for (const { start, end } of positions) { + let startOff = start.offset + offset; + let endOff = end.offset + offset; + if (text2.slice(startOff, endOff) !== oldTag) { + return false; + } + text2 = text2.slice(0, startOff) + newTag + text2.slice(startOff + oldTag.length); + offset += offsetOffset; } - getItems() { - return this.file ? this.plugin.index.allSpaces().filter((f4) => { - var _a2; - return f4.def.type == "focus" && !(((_a2 = f4.def.folder) == null ? void 0 : _a2.length) > 0) && this.file.spaces.includes(f4.name); - }) : []; + if (text2 !== original) { + await app.vault.modify(file, text2); + return true; } - onChooseItem(space, evt) { - removePathsFromSpace(this.plugin, space.name, [this.file.path]); +}; +var allTagsForFile = (file) => { + var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j; + let rt = []; + if (file instanceof import_obsidian9.TFile) { + const fCache = app.metadataCache.getCache(file.path); + if (fCache && fCache.tags) + rt.push(...(_b2 = (_a2 = fCache.tags) == null ? void 0 : _a2.map((f4) => f4.tag)) != null ? _b2 : []); + if (fCache && ((_c2 = fCache.frontmatter) == null ? void 0 : _c2.tags)) + rt.push( + ...(typeof ((_d2 = fCache.frontmatter) == null ? void 0 : _d2.tags) === "string" ? parseMultiString(fCache.frontmatter.tags.replace(/ /g, "")) : Array.isArray((_e2 = fCache.frontmatter) == null ? void 0 : _e2.tags) ? (_f = fCache.frontmatter) == null ? void 0 : _f.tags : []).filter((f4) => typeof f4 === "string").map((f4) => "#" + f4) + ); + if (fCache && ((_g = fCache.frontmatter) == null ? void 0 : _g.tag)) + rt.push( + ...(typeof ((_h = fCache.frontmatter) == null ? void 0 : _h.tag) === "string" ? parseMultiString(fCache.frontmatter.tag.replace(/ /g, "")) : Array.isArray((_i = fCache.frontmatter) == null ? void 0 : _i.tag) ? (_j = fCache.frontmatter) == null ? void 0 : _j.tag : []).filter((f4) => typeof f4 === "string").map((f4) => "#" + f4) + ); } + return uniq(rt); }; -// src/utils/spaces/spaces.ts -var import_lodash3 = __toESM(require_lodash()); -var import_obsidian10 = require("obsidian"); - -// src/schemas/spaces.ts -var vaultSchema = { - uniques: ["path"], - cols: ["path", "parent", "created", "sticker", "color", "folder", "rank"], - rows: [] +// src/utils/contexts/mdb.ts +var dbTableToMDBTable = (table, schema, fields) => { + var _a2; + return { + schema, + cols: fields, + rows: (_a2 = table == null ? void 0 : table.rows) != null ? _a2 : [] + }; }; -var spaceSchema = { - uniques: ["name"], - cols: ["name", "sticker", "color", "pinned", "sort", "def", "rank"], - rows: [] +var updateFieldsToSchema = (fields, context) => { + const defaultFields = defaultFieldsForContext(context); + return [ + ...fields, + ...defaultFields.rows.filter( + (f4) => !fields.some((g4) => g4.name == f4.name && g4.schemaId == f4.schemaId) + ) + ]; }; -var spaceItemsSchema = { - uniques: [], - cols: ["space", "path", "rank"], - rows: [] +var getMDBTable = async (plugin, context, table) => { + if (!context) + return null; + const sqlJS = await plugin.sqlJS(); + const buf = await getDBFile(context.dbPath, context.isRemote); + if (!buf) { + return null; + } + const db = new sqlJS.Database(new Uint8Array(buf)); + await sanitizeTableSchema(plugin, db, context); + let fieldsTables; + let schema; + try { + fieldsTables = dbResultsToDBTables( + db.exec(`SELECT * FROM m_fields WHERE schemaId = '${table}'`) + ); + schema = dbResultsToDBTables( + db.exec(`SELECT * FROM m_schema WHERE id = '${table}'`) + )[0].rows[0]; + } catch (e4) { + db.close(); + return null; + } + if (fieldsTables.length == 0) { + db.close(); + return { + schema, + cols: [], + rows: [] + }; + } + const fields = fieldsTables[0].rows.filter( + (f4) => f4.name.length > 0 + ); + const dbTable = dbResultsToDBTables( + db.exec( + `SELECT ${serializeSQLFieldNames( + fields.reduce((p3, c4) => [...p3, `"${c4.name}"`], []) + )} FROM "${table}"` + ) + ); + db.close(); + return dbTableToMDBTable( + dbTable[0], + schema, + schema.primary ? updateFieldsToSchema(fields, context) : fields + ); }; - -// src/superstate/cacheParsers.ts -var import_lodash2 = __toESM(require_lodash()); - -// src/utils/metadata/frontmatter/parseFrontMatter.ts -var parseFrontMatter = (field, value) => { - const YAMLtype = detectYAMLType(value, field); - switch (YAMLtype) { - case "object": - return JSON.stringify(value); - break; - case "number": - return value.toString(); - break; - case "boolean": - return value ? "true" : "false"; - break; - case "date": - return value; - break; - case "duration": - return serializeMultiDisplayString(Object.keys(value.values).reduce( - (p3, c4) => [ - ...p3, - ...value.values[c4] > 0 ? [value.values[c4] + " " + c4] : [] - ], - [] - )); - break; - case "option-multi": - case "link-multi": - if (typeof value === "string") { - return value; - } - return serializeMultiString( - value.map((v3) => { - if (!v3) { - return ""; - } - if (typeof v3 === "string") { - return v3; - } - if (v3.path) { - return v3.path; - } - if (Array.isArray(value) && v3.length == 1 && Array.isArray(v3[0]) && v3[0].length == 1 && typeof v3[0][0] === "string") { - return v3[0][0]; - } - return JSON.stringify(v3); - }) - ); - break; - case "link": - { - if (Array.isArray(value) && value.length == 1 && Array.isArray(value[0]) && value[0].length == 1 && typeof value[0][0] === "string") { - return value[0][0]; - } else if (typeof value === "string") { - return value; - } - return value.path; - } - break; - case "text": - case "tag": - case "image": - return value; - break; +var deleteMDBTable = async (plugin, context, table) => { + if (context.readOnly) + return false; + const sqlJS = await plugin.sqlJS(); + const buf = await getDBFile(context.dbPath, context.isRemote); + if (!buf) { + return false; + } + const db = new sqlJS.Database(new Uint8Array(buf)); + deleteFromDB(db, "m_schema", `id = '${sanitizeSQLStatement(table)}'`); + deleteFromDB(db, "m_schema", `def = '${sanitizeSQLStatement(table)}'`); + deleteFromDB(db, "m_fields", `schemaId = '${sanitizeSQLStatement(table)}'`); + dropTable(db, table); + await saveDBFile(context.dbPath, db.export().buffer); + db.close(); + return true; +}; +var getMDBTableSchemas = async (plugin, context) => { + const sqlJS = await plugin.sqlJS(); + const buf = await getDBFile(context.dbPath, context.isRemote); + if (!buf) { + return null; } - return ""; + const db = new sqlJS.Database(new Uint8Array(buf)); + await sanitizeTableSchema(plugin, db, context); + const tables = db.exec(`SELECT * FROM m_schema`); + db.close(); + return tables[0].values.map((f4) => { + const [id2, name, type, def, predicate, primary] = f4; + return { id: id2, name, type, def, predicate, primary }; + }); }; - -// src/utils/contexts/predicate/filter.ts -var stringEqual = (value, filterValue) => { - return value == filterValue; +var saveMDBToPath = async (plugin, context, mdb) => { + var _a2, _b2; + if (context.readOnly) + return; + const sqlJS = await plugin.sqlJS(); + const buf = await getDBFile(context.dbPath, context.isRemote); + if (!buf) { + return null; + } + const db = new sqlJS.Database(new Uint8Array(buf)); + const fieldsTables = dbResultsToDBTables( + db.exec(`SELECT * FROM m_fields WHERE schemaId != '${mdb.schema.id}'`) + ); + const tables = { + m_fields: { + uniques: fieldSchema.uniques, + cols: fieldSchema.cols, + rows: [...(_b2 = (_a2 = fieldsTables[0]) == null ? void 0 : _a2.rows) != null ? _b2 : [], ...mdb.cols] + }, + [mdb.schema.id]: { + uniques: [], + cols: mdb.cols.map((c4) => c4.name), + rows: mdb.rows + } + }; + db.close(); + return saveDBToPath(plugin, context.dbPath, tables); }; -var empty = (value, filterValue) => { - return (value != null ? value : "").length == 0; +var optionValuesForColumn = (column, table) => { + var _a2; + return uniq( + (_a2 = table == null ? void 0 : table.rows.reduce((p3, c4) => { + return [...p3, ...parseMultiString(c4[column])]; + }, [])) != null ? _a2 : [] + ); }; -var stringCompare = (value, filterValue) => { - return (value != null ? value : "").toLowerCase().includes((filterValue != null ? filterValue : "").toLowerCase()); +var defaultTableDataForContext = (plugin, contextInfo) => { + var _a2, _b2; + let files; + if (contextInfo.type == "folder") { + files = folderChildren( + plugin, + getAbstractFileAtPath( + plugin.app, + contextInfo.contextPath + ) + ); + return { + ...defaultMDBTableForContext(contextInfo), + rows: files.map((f4) => ({ File: f4.path })) + }; + } else if (contextInfo.type == "tag") { + files = getAllFilesForTag(contextInfo.contextPath).map((f4) => getAbstractFileAtPath(app, f4)).filter((f4) => f4); + return { + ...defaultMDBTableForContext(contextInfo), + rows: files.map((f4) => ({ File: f4.path })) + }; + } else if (contextInfo.type == "space") { + files = [ + ...(_b2 = (_a2 = plugin.index.spacesMap) == null ? void 0 : _a2.getInverse( + contextInfo.contextPath.substring( + 0, + contextInfo.contextPath.length - 2 + ) + )) != null ? _b2 : [] + ].map((f4) => getAbstractFileAtPath(app, f4)).filter((f4) => f4); + return { + ...defaultMDBTableForContext(contextInfo), + rows: files.map((f4) => ({ File: f4.path })) + }; + } + return null; }; -var greaterThan = (value, filterValue) => { - return parseFloat(value) > parseFloat(filterValue); +var createDefaultDB = async (plugin, context) => { + var _a2; + const table = defaultTableDataForContext(plugin, context); + if (table) { + const defaultFields = defaultFieldsForContext(context); + const defaultTable = defaultTablesForContext(context); + const dbField = { + ...defaultTable, + m_fields: { + uniques: defaultFields.uniques, + cols: defaultFields.cols, + rows: [...(_a2 = defaultFields.rows) != null ? _a2 : [], ...table.cols] + }, + [table.schema.id]: { + uniques: table.cols.filter((c4) => c4.unique == "true").map((c4) => c4.name), + cols: table.cols.map((c4) => c4.name), + rows: table.rows + } + }; + const result = await saveDBToPath(plugin, context.dbPath, dbField); + if (result) { + await plugin.index.reloadContext(context); + table.rows.map((f4) => getAbstractFileAtPath(app, f4.File)).forEach((f4) => f4 && plugin.index.reloadFile(f4, true)); + return true; + } + return false; + } + return false; }; -var lessThan = (value, filterValue) => { - return parseInt(value) > parseInt(filterValue); +var sanitizeTableSchema = async (plugin, db, context) => { + const sqlJS = await plugin.sqlJS(); + const tableRes = db.exec( + `SELECT name FROM sqlite_master WHERE type='table';` + ); + if (!tableRes[0] || !tableRes[0].values.some((f4) => f4[0] == "m_schema") || !tableRes[0].values.some((f4) => f4[0] == "m_fields") || !tableRes[0].values.some((f4) => f4[0] == "files")) { + await createDefaultDB(plugin, context); + } }; -var listIncludes = (value, filterValue) => { - const valueList = value ? parseMultiString(value) : []; - const strings = filterValue ? parseMultiString(filterValue) : []; - return strings.some((f4) => valueList.some((g4) => g4 == f4)); +var createNewRow = (mdb, row, index) => { + if (index) { + return { + ...mdb, + rows: insert(mdb.rows, index, row) + }; + } + return { + ...mdb, + rows: [...mdb.rows, row] + }; }; -var filterReturnForCol = (col, filter, row) => { - if (!col) - return true; - const filterType = filterFnTypes[filter == null ? void 0 : filter.fn]; - let result = true; - if (filterType && filterType.fn) { - result = filterType.fn(row[filter.field], filter.value); +var deleteTagContext = async (plugin, tag) => { + const context = tagContextFromTag(plugin, tag); + if (getAbstractFileAtPath(app, context.dbPath)) { + await deleteFile(plugin, getAbstractFileAtPath(app, context.dbPath)); } - return result; + app.workspace.iterateLeaves((leaf) => { + if (leaf.view.getViewType() == CONTEXT_VIEW_TYPE && leaf.view.getState().contextPath == tag) { + leaf.setViewState({ type: "empty" }); + } + }, app.workspace["rootSplit"]); + plugin.index.deleteTag(tag); }; - -// src/utils/contexts/predicate/filterFns/filterFnTypes.ts -var filterFnTypes = { - isNotEmpty: { - type: ["text", "file", "link", "link-multi", "fileprop", "image"], - fn: (v3, f4) => !empty(v3, ""), - valueType: "none" - }, - isEmpty: { - type: ["text", "file", "link", "link-multi", "fileprop", "image"], - fn: (v3, f4) => empty(v3, ""), - valueType: "none" - }, - include: { - fn: (v3, f4) => stringCompare(v3, f4), - type: ["text", "file", "link", "link-multi", "fileprop", "image"], - valueType: "text" - }, - notInclude: { - type: ["text", "file", "link", "link-multi", "fileprop", "image"], - fn: (v3, f4) => !stringCompare(v3, f4), - valueType: "text" - }, - is: { - type: ["text", "file", "link", "context", "fileprop"], - fn: stringEqual, - valueType: "text" - }, - isNot: { - type: ["text", "file", "link", "context", "fileprop"], - fn: (v3, f4) => !stringEqual(v3, f4), - valueType: "text" - }, - equal: { - type: ["number"], - fn: stringEqual, - valueType: "number" - }, - isGreatThan: { - type: ["number"], - fn: greaterThan, - valueType: "number" - }, - isLessThan: { - type: ["number"], - fn: lessThan, - valueType: "number" - }, - isLessThanOrEqual: { - type: ["number"], - fn: (v3, f4) => !greaterThan(v3, f4), - valueType: "number" - }, - isGreatThanOrEqual: { - type: ["number"], - fn: (v3, f4) => !lessThan(v3, f4), - valueType: "number" - }, - dateBefore: { - type: ["date", "fileprop"], - fn: lessThan, - valueType: "date" - }, - dateAfter: { - type: ["date", "fileprop"], - fn: greaterThan, - valueType: "date" - }, - isAnyInList: { - type: ["option", "context", "option-multi", "context-multi", "tags-multi", "tags"], - fn: listIncludes, - valueType: "list" - }, - isNoneInList: { - type: ["option", "context", "option-multi", "context-multi", "tags-multi", "tags"], - fn: (v3, f4) => !listIncludes(v3, f4), - valueType: "list" - }, - isTrue: { - type: ["boolean"], - fn: (v3, f4) => v3 == "true", - valueType: "none" - }, - isFalse: { - type: ["boolean"], - fn: (v3, f4) => v3 != "true", - valueType: "none" +var deleteSpaceContext = async (plugin, space) => { + const context = spaceContextFromSpace(plugin, spaceContextPathFromName(space)); + if (getAbstractFileAtPath(app, context.dbPath)) { + await deleteFile(plugin, getAbstractFileAtPath(app, context.dbPath)); } + app.workspace.iterateLeaves((leaf) => { + if (leaf.view.getViewType() == CONTEXT_VIEW_TYPE && leaf.view.getState().contextPath == context.contextPath) { + leaf.setViewState({ type: "empty" }); + } + }, app.workspace["rootSplit"]); }; - -// src/superstate/cacheParsers.ts -var fileMetadataToVaultItem = (cache) => { - var _a2, _b2; - return { - path: cache.path, - parent: cache.parent, - color: cache.color, - created: (_b2 = (_a2 = cache.ctime) == null ? void 0 : _a2.toString()) != null ? _b2 : "", - sticker: cache.sticker, - folder: cache.isFolder ? "true" : "false", - rank: cache.rank - }; +var connectContext = async (plugin, tag, source) => { }; -var parseSpaceCache = (space, spaceItems) => { - return { - name: space.name, - space, - spaceItems - }; +var renameSpaceContextFile = async (plugin, space, newSpace) => { + const context = spaceContextFromSpace(plugin, spaceContextPathFromName(space)); + if (getAbstractFileAtPath(app, context.dbPath)) { + const newSpaceDBPath = newSpace + ".mdb"; + if (!getAbstractFileAtPath( + app, + getAbstractFileAtPath(app, context.dbPath).parent.path + "/" + newSpaceDBPath + )) { + await renameFile( + plugin, + getAbstractFileAtPath(app, context.dbPath), + newSpaceDBPath + ); + } else { + await deleteFile(plugin, getAbstractFileAtPath(app, context.dbPath)); + } + } + app.workspace.iterateLeaves((leaf) => { + if (leaf.view.getViewType() == CONTEXT_VIEW_TYPE && leaf.view.getState().contextPath == context.contextPath) { + leaf.setViewState({ + type: CONTEXT_VIEW_TYPE, + state: { contextPath: spaceContextPathFromName(newSpace) } + }); + } + }, app.workspace["rootSplit"]); +}; +var renameTagContextFile = async (plugin, tag, newTag) => { + const context = tagContextFromTag(plugin, tag); + if (getAbstractFileAtPath(app, context.dbPath)) { + const newTagDBPath = tagToTagPath(newTag) + ".mdb"; + if (!getAbstractFileAtPath( + app, + getAbstractFileAtPath(app, context.dbPath).parent.path + "/" + tagToTagPath(newTag) + ".mdb" + )) { + await renameFile( + plugin, + getAbstractFileAtPath(app, context.dbPath), + tagToTagPath(newTag) + ".mdb" + ); + } else { + await deleteFile(plugin, getAbstractFileAtPath(app, context.dbPath)); + } + } + plugin.index.renameTag(tag, newTag); + app.workspace.iterateLeaves((leaf) => { + if (leaf.view.getViewType() == CONTEXT_VIEW_TYPE && leaf.view.getState().contextPath == tag) { + leaf.setViewState({ + type: CONTEXT_VIEW_TYPE, + state: { contextPath: newTag } + }); + } + }, app.workspace["rootSplit"]); }; -// src/utils/spaces/spaces.ts +// src/superstate/spacesStore/spaces.ts var rebuildIndex = async (plugin, save) => { var _a2, _b2; console.time("Make.md Vault Index"); - const newTables = indexCurrentFileTree((_a2 = plugin.index.vaultDBCache) != null ? _a2 : [], (_b2 = plugin.index.spacesItemsDBCache) != null ? _b2 : []); + const newTables = indexCurrentFileTree(plugin, (_a2 = plugin.index.vaultDBCache) != null ? _a2 : [], (_b2 = plugin.index.spacesItemsDBCache) != null ? _b2 : []); if (save && (!import_lodash3.default.isEqual(newTables.vault.rows, plugin.index.vaultDBCache) || !import_lodash3.default.isEqual(newTables.spaceItems.rows, plugin.index.spacesItemsDBCache))) { - plugin.index.saveSpacesDB(newTables, save); + plugin.index.saveSpacesDatabaseToDisk(newTables, save); } plugin.index.initialize(); console.timeEnd("Make.md Vault Index"); @@ -23056,7 +23022,7 @@ var vaultItemForPath = (plugin, path) => { var saveFileSticker = (plugin, path, sticker) => { if (plugin.settings.spacesEnabled) { const newVaultDB = plugin.index.vaultDBCache.map((f4) => f4.path == path ? { ...f4, sticker } : f4); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultDB } }); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultDB } }); } saveFrontmatterValue( plugin, @@ -23071,14 +23037,14 @@ var saveFileSticker = (plugin, path, sticker) => { var saveFolderSort = (plugin, path, sort) => { if (plugin.settings.spacesEnabled) { const newVaultDB = plugin.index.vaultDBCache.map((f4) => f4.path == path ? { ...f4, folder: sort } : f4); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultDB } }); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultDB } }); plugin.index.reloadFile(getAbstractFileAtPath(app, path)).then((f4) => plugin.index.broadcast("vault")); } }; var saveFileColor = (plugin, path, color) => { if (plugin.settings.spacesEnabled) { const newVaultDB = plugin.index.vaultDBCache.map((f4) => f4.path == path ? { ...f4, color } : f4); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultDB } }); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultDB } }); } saveFrontmatterValue( plugin, @@ -23092,7 +23058,7 @@ var saveFileColor = (plugin, path, color) => { }; var saveSpaceSticker = (plugin, name, sticker) => { const newSpaceDB = plugin.index.spacesDBCache.map((f4) => f4.name == name ? { ...f4, sticker } : f4); - plugin.index.saveSpacesDB({ spaces: { ...spaceSchema, rows: newSpaceDB } }); + plugin.index.saveSpacesDatabaseToDisk({ spaces: { ...spaceSchema, rows: newSpaceDB } }); plugin.index.reloadSpace(name); }; var updateFileRank = async (plugin, item, rank) => { @@ -23113,8 +23079,8 @@ var updateFileRank = async (plugin, item, rank) => { } return f4; }); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultDB } }); - const promises = newItems.map((f4) => plugin.index.files.set(f4.path, { ...plugin.index.files.get(f4.path), rank: f4.rank })); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultDB } }); + const promises = newItems.map((f4) => plugin.index.reloadFile(getAbstractFileAtPath(app, f4.path))); await Promise.all(promises); plugin.index.broadcast("space"); }; @@ -23138,7 +23104,7 @@ var moveAFileToNewParentAtIndex = async (plugin, item, newParent, index) => { )) != null ? _a2 : [], index, newItem - ).map((f4, index2) => ({ ...f4, rank: index2.toString() })); + ).map((f4, i4) => ({ ...f4, rank: i4.toString() })); const newVaultTable = [...plugin.index.vaultDBCache, newItem].filter((f4) => f4.path != item.path).map((f4) => { const newItem2 = rows.find((g4) => g4.path == f4.path); if (newItem2) { @@ -23146,10 +23112,10 @@ var moveAFileToNewParentAtIndex = async (plugin, item, newParent, index) => { } return f4; }); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultTable } }); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultTable } }); const afile = getAbstractFileAtPath(app, item.path); await moveFile(getAbstractFileAtPath(app, newParent), afile); - const promises = rows.map((f4) => plugin.index.files.set(f4.path, { ...plugin.index.files.get(f4.path), rank: f4.rank })); + const promises = rows.map((f4) => plugin.index.reloadFile(getAbstractFileAtPath(app, f4.path))); await Promise.all(promises); plugin.index.broadcast("space"); }; @@ -23182,12 +23148,12 @@ var insertSpaceAtIndex = (plugin, newSpace, rank) => { } return f4; }); - plugin.index.saveSpacesDB({ spaces: { ...spaceSchema, rows: newSpaceRows } }); + plugin.index.saveSpacesDatabaseToDisk({ spaces: { ...spaceSchema, rows: newSpaceRows } }); plugin.index.initializeSpaces().then((f4) => plugin.index.initalizeFiles()); }; var insertSpaceItemAtIndex = async (plugin, spaceName, path, rank) => { var _a2; - const space = (_a2 = plugin.index.spacesCache.get(spaceName)) == null ? void 0 : _a2.space; + const space = (_a2 = plugin.index.spacesIndex.get(spaceName)) == null ? void 0 : _a2.space; if (!space) return; const newSpace = { @@ -23227,7 +23193,7 @@ var insertSpaceItemAtIndex = async (plugin, spaceName, path, rank) => { } return f4; }); - plugin.index.saveSpacesDB({ spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); await plugin.index.reloadSpace(space.name); const promises = newSpaceItemsRows.map((f4) => plugin.index.reloadFile(getAbstractFileAtPath(app, f4.path))); await Promise.all(promises); @@ -23236,7 +23202,7 @@ var insertSpaceItemAtIndex = async (plugin, spaceName, path, rank) => { var saveSpace = (plugin, space, newSpace) => { const newSpaceRows = plugin.index.spacesDBCache.map((f4) => f4.name == space ? serializeSpace(newSpace) : f4); const newSpaceItemsRows = plugin.index.spacesItemsDBCache.map((f4) => f4.space == space ? { ...f4, space: newSpace.name } : f4); - plugin.index.saveSpacesDB({ spaces: { ...spaceSchema, rows: newSpaceRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ spaces: { ...spaceSchema, rows: newSpaceRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); plugin.settings.expandedSpaces = plugin.settings.expandedSpaces.map( (f4) => f4 == space ? newSpace.name : f4 ); @@ -23251,13 +23217,13 @@ var saveSpace = (plugin, space, newSpace) => { var removeSpace = (plugin, space) => { const newSpaceRows = plugin.index.spacesDBCache.filter((f4) => f4.name != space); const newSpaceItemsRows = plugin.index.spacesItemsDBCache.filter((f4) => f4.space != space); - plugin.index.saveSpacesDB({ spaces: { ...spaceSchema, rows: newSpaceRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ spaces: { ...spaceSchema, rows: newSpaceRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); deleteSpaceContext(plugin, space); plugin.index.deleteSpace(space); }; var updateSpaceSort = (plugin, spaceName, sort) => { var _a2; - const space = (_a2 = plugin.index.spacesCache.get(spaceName)) == null ? void 0 : _a2.space; + const space = (_a2 = plugin.index.spacesIndex.get(spaceName)) == null ? void 0 : _a2.space; if (space) saveSpace(plugin, spaceName, { ...space, @@ -23266,7 +23232,7 @@ var updateSpaceSort = (plugin, spaceName, sort) => { }; var toggleSpacePin = (plugin, spaceName, type) => { var _a2; - const space = (_a2 = plugin.index.spacesCache.get(spaceName)) == null ? void 0 : _a2.space; + const space = (_a2 = plugin.index.spacesIndex.get(spaceName)) == null ? void 0 : _a2.space; if (space) saveSpace(plugin, spaceName, { ...space, @@ -23275,7 +23241,7 @@ var toggleSpacePin = (plugin, spaceName, type) => { }; var addPathsToSpace = async (plugin, space, paths) => { const newSpaceItemsRows = [...plugin.index.spacesItemsDBCache, ...paths.map((p3) => ({ space, path: p3 }))]; - plugin.index.saveSpacesDB({ spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); await plugin.index.reloadSpace(space); const promises = paths.map((f4) => plugin.index.reloadFile(getAbstractFileAtPath(app, f4))); await Promise.all(promises); @@ -23283,7 +23249,7 @@ var addPathsToSpace = async (plugin, space, paths) => { }; var removePathsFromSpace = async (plugin, space, paths) => { const newSpaceItemsRows = plugin.index.spacesItemsDBCache.filter((f4) => !(f4.space == space && paths.includes(f4.path))); - plugin.index.saveSpacesDB({ spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); await plugin.index.reloadSpace(space); const promises = paths.map((f4) => plugin.index.reloadFile(getAbstractFileAtPath(app, f4))); await Promise.all(promises); @@ -23306,13 +23272,13 @@ var retrieveFolders = async (plugin, paths) => { const retrievedFolders = {}; paths.forEach((folder) => { const files = []; - for (const k5 of plugin.index.files.values()) { + for (const k5 of plugin.index.filesIndex.values()) { if (k5.parent == folder) files.push(k5); } retrievedFolders[folder] = files.filter( excludeVaultItemPredicate(plugin.settings) - ).map((f4) => plugin.index.files.get(f4.path)).filter((f4) => f4); + ).map((f4) => plugin.index.filesIndex.get(f4.path)).filter((f4) => f4); }); return retrievedFolders; }; @@ -23333,17 +23299,15 @@ var initiateDB = (db) => { spaceItems: spaceItemsSchema }); }; -var indexCurrentFileTree = (vaultDB, spaceItemsDB) => { - const treeItems = []; - import_obsidian10.Vault.recurseChildren(app.vault.getRoot(), (file) => { +var indexCurrentFileTree = (plugin, vaultDB, spaceItemsDB) => { + const treeItems = getAllAbstractFilesInVault(plugin, app).map((file) => { var _a2; - if (file.path != "/") - treeItems.push({ - path: file.path, - parent: (_a2 = file.parent) == null ? void 0 : _a2.path, - created: file instanceof import_obsidian10.TFile ? file.stat.ctime.toString() : void 0, - folder: file instanceof import_obsidian10.TFolder ? "true" : "false" - }); + return { + path: file.path, + parent: (_a2 = file.parent) == null ? void 0 : _a2.path, + created: file instanceof import_obsidian10.TFile ? file.stat.ctime.toString() : void 0, + folder: file instanceof import_obsidian10.TFolder ? "true" : "false" + }; }); const currentPaths = vaultDB; const deleteRows = currentPaths.filter( @@ -23377,27 +23341,6 @@ var indexCurrentFileTree = (vaultDB, spaceItemsDB) => { } }; }; -var newFolderInVault = (plugin, activeFile2) => { - const vaultChangeModal = new VaultChangeModal( - plugin, - plugin.app.vault.getRoot(), - "create folder", - "/" - ); - vaultChangeModal.open(); -}; -var newFileInVault = async (plugin, activeFile2, canvas) => { - let newFile; - if (canvas) { - newFile = await createNewCanvasFile(plugin, plugin.app.vault.getRoot(), ""); - } else { - newFile = await createNewMarkdownFile( - plugin, - plugin.app.vault.getRoot(), - "" - ); - } -}; var newFolderInSpace = (plugin, space, activeFile2) => { const vaultChangeModal = new VaultChangeModal( plugin, @@ -23749,7 +23692,7 @@ var atomicSelect = import_state4.EditorState.transactionFilter.of( ); // src/components/ContextView/EmbedContextView.tsx -var import_obsidian30 = require("obsidian"); +var import_obsidian31 = require("obsidian"); // node_modules/@dnd-kit/utilities/dist/utilities.esm.js function useCombinedRefs() { @@ -28074,7 +28017,7 @@ function matchExact(string) { // src/components/ContextView/MDBContext.tsx var import_lodash4 = __toESM(require_lodash()); -var import_obsidian12 = require("obsidian"); +var import_obsidian13 = require("obsidian"); // src/utils/contexts/predicate/sort.ts var simpleSort = (a5, b4) => { @@ -28165,6 +28108,73 @@ var sortReturnForCol = (col, sort, row, row2) => { return 0; }; +// src/utils/path.ts +var import_obsidian12 = require("obsidian"); +var openPath = (plugin, _path) => { + const { type, path } = _path; + if (type == "file" || type == "folder") { + const afile = getAbstractFileAtPath(app, path); + if (afile) { + openAFile(afile, plugin, false); + } else { + if (type == "file") + createNewMarkdownFile( + plugin, + defaultNoteFolder(plugin, null), + path + ); + } + return; + } + if (type == "tag") { + openTagContext(path, plugin, false); + return; + } + if (type == "url") { + openURL(path); + return; + } +}; +var pathByString = (path, source) => { + const [str, alias] = path.split("|"); + const refIndex = str.lastIndexOf("#"); + const [link, ref] = refIndex > 0 ? [str.substring(0, refIndex), str.substring(refIndex + 1)] : [str, void 0]; + const type = pathTypeByString(link, source); + return { + fullPath: path, + path: link, + type, + alias, + ref + }; +}; +var pathTypeByString = (file, source) => { + if (file.charAt(0) == "#") { + return "tag"; + } + if (file.slice(-2) == "//") { + return "space"; + } + if (file.charAt(file.length - 1) == "/") { + return "folder"; + } + let portalFile; + if (source) { + portalFile = app.metadataCache.getFirstLinkpathDest(file, source); + } else { + portalFile = app.vault.getAbstractFileByPath(file); + } + if (portalFile instanceof import_obsidian12.TFolder) { + return "folder"; + } + if (portalFile instanceof import_obsidian12.TFile) { + return "file"; + } + if (file.match(urlRegex)) + return "url"; + return "unknown"; +}; + // src/utils/contexts/predicate/predicate.tsx var defaultPredicateFnForType = (type, types) => { const fnType = Object.keys(types).find( @@ -28633,9 +28643,11 @@ var MDBProvider = (props2) => { }); } else { if (props2.schema) { - saveDB2(defaultMDBTableForContext(contextInfo)).then((f4) => { - setSchemaTable((prev) => defaultSchema); - }); + saveDB2(defaultTableDataForContext(props2.plugin, contextInfo)).then( + (f4) => { + setSchemaTable((prev) => defaultSchema); + } + ); } else { setSchemaTable((prev) => defaultSchema); setDBSchema((prev) => defaultFileDBSchema); @@ -28674,7 +28686,12 @@ var MDBProvider = (props2) => { return; } if ((evt.detail.type == "space" || evt.detail.type == "vault") && !dbFileExists) { - loadDefaultTableData(); + const defaultTable = defaultTableDataForContext( + props2.plugin, + contextInfo + ); + if (defaultTable) + setTableData(defaultTable); } else if (evt.detail.type == "vault") { refreshMDB(contextInfo.contextPath); } @@ -28732,13 +28749,13 @@ var MDBProvider = (props2) => { await saveDBToPath(props2.plugin, contextInfo.dbPath, dbField).then( (f4) => { setDBFileExists(true); - f4 ? setTableData(newTable) : new import_obsidian12.Notice("DB ERROR"); + f4 ? setTableData(newTable) : new import_obsidian13.Notice("DB ERROR"); } ); } else { await saveMDBToPath(props2.plugin, contextInfo, newTable).then((f4) => { setDBFileExists(true); - f4 ? setTableData(newTable) : new import_obsidian12.Notice("DB ERROR"); + f4 ? setTableData(newTable) : new import_obsidian13.Notice("DB ERROR"); }); } }; @@ -28764,7 +28781,12 @@ var MDBProvider = (props2) => { getMDBData(); } } else { - loadDefaultTableData(); + const defaultTable = defaultTableDataForContext( + props2.plugin, + contextInfo + ); + if (defaultTable) + setTableData(defaultTable); } } }, [dbSchema]); @@ -28787,7 +28809,7 @@ var MDBProvider = (props2) => { detail: { selection: path, path: { - ...pathByString(props2.plugin, contextInfo.contextPath), + ...pathByString(contextInfo.contextPath), ref: schema == null ? void 0 : schema.id } } @@ -28797,7 +28819,7 @@ var MDBProvider = (props2) => { let evt = new CustomEvent(eventTypes.activePathChange, { detail: { path: { - ...pathByString(props2.plugin, contextInfo.contextPath), + ...pathByString(contextInfo.contextPath), ref: schema == null ? void 0 : schema.id }, selection: null @@ -28806,42 +28828,6 @@ var MDBProvider = (props2) => { window.dispatchEvent(evt); } }; - const loadDefaultTableData = () => { - var _a3, _b2; - let files; - if (contextInfo.type == "folder") { - files = folderChildren( - props2.plugin, - getAbstractFileAtPath( - props2.plugin.app, - contextInfo.contextPath - ) - ); - setTableData({ - ...defaultMDBTableForContext(contextInfo), - rows: files.map((f4) => ({ File: f4.path })) - }); - } else if (contextInfo.type == "tag") { - files = getAllFilesForTag(contextInfo.contextPath).map((f4) => getAbstractFileAtPath(app, f4)).filter((f4) => f4); - setTableData({ - ...defaultMDBTableForContext(contextInfo), - rows: files.map((f4) => ({ File: f4.path })) - }); - } else if (contextInfo.type == "space") { - files = [ - ...(_b2 = (_a3 = props2.plugin.index.spaces) == null ? void 0 : _a3.getInverse( - contextInfo.contextPath.substring( - 0, - contextInfo.contextPath.length - 2 - ) - )) != null ? _b2 : [] - ].map((f4) => getAbstractFileAtPath(app, f4)).filter((f4) => f4); - setTableData({ - ...defaultMDBTableForContext(contextInfo), - rows: files.map((f4) => ({ File: f4.path })) - }); - } - }; const getContextTags = async (_tableData) => { const contextFields = _tableData.cols.filter((f4) => f4.type.contains("context")).map((f4) => f4.value).filter((f4) => !tagContexts.some((g4) => g4 == f4)); for (let c4 of contextFields) { @@ -28977,7 +28963,7 @@ var MDBProvider = (props2) => { mdbtable = contextTable[table]; } if (column.name == "") { - new import_obsidian12.Notice(i18n_default.notice.noPropertyName); + new import_obsidian13.Notice(i18n_default.notice.noPropertyName); return false; } if (!oldColumn && mdbtable.cols.find( @@ -28985,7 +28971,7 @@ var MDBProvider = (props2) => { ) || oldColumn && oldColumn.name != column.name && mdbtable.cols.find( (f4) => f4.name.toLowerCase() == column.name.toLowerCase() )) { - new import_obsidian12.Notice(i18n_default.notice.duplicatePropertyName); + new import_obsidian13.Notice(i18n_default.notice.duplicatePropertyName); return false; } const oldFieldIndex = oldColumn ? mdbtable.cols.findIndex((f4) => f4.name == oldColumn.name) : -1; @@ -31910,7 +31896,7 @@ function useReactTable(options) { // src/dispatch/mdb.ts var import_lodash5 = __toESM(require_lodash()); -var import_obsidian13 = require("obsidian"); +var import_obsidian14 = require("obsidian"); // src/utils/contexts/file.ts var renameRowForFile = (folder, filePath, toFilePath) => { @@ -31939,25 +31925,25 @@ var removeRowsForFile = (folder, filePaths) => { }; // src/utils/contexts/links.ts -var valueContainsLink = (link2, value) => { - return parseMultiString(value).some((f4) => link2 == parseLinkString(f4)); +var valueContainsLink = (link, value) => { + return parseMultiString(value).some((f4) => link == parseLinkString(f4)); }; -var replaceLinkInValue = (link2, newLink, value) => { - return serializeMultiString(parseMultiString(value).map((f4) => parseLinkString(f4) == link2 ? newLink : link2)); +var replaceLinkInValue = (link, newLink, value) => { + return serializeMultiString(parseMultiString(value).map((f4) => parseLinkString(f4) == link ? newLink : link)); }; -var removeLinkInValue = (link2, value) => { - return serializeMultiString(parseMultiString(value).filter((f4) => f4 != link2)); +var removeLinkInValue = (link, value) => { + return serializeMultiString(parseMultiString(value).filter((f4) => f4 != link)); }; var linkColumns = (cols) => { return cols.filter((f4) => f4.type.startsWith("link") || f4.type.startsWith("context")); }; -var removeLinksInRow = (plugin, row, link2, cols) => { +var removeLinksInRow = (plugin, row, link, cols) => { if (cols.length == 0) { return row; } const deltaRow = cols.reduce((p3, c4) => { - if (valueContainsLink(link2, row[c4.name])) { - const newValue = removeLinkInValue(link2, row[c4.name]); + if (valueContainsLink(link, row[c4.name])) { + const newValue = removeLinkInValue(link, row[c4.name]); saveFrontmatterValue( plugin, row.File, @@ -31972,13 +31958,13 @@ var removeLinksInRow = (plugin, row, link2, cols) => { }, {}); return { ...row, ...deltaRow }; }; -var renameLinksInRow = (plugin, row, link2, newLink, cols) => { +var renameLinksInRow = (plugin, row, link, newLink, cols) => { if (cols.length == 0) { return row; } const deltaRow = cols.reduce((p3, c4) => { - if (valueContainsLink(link2, row[c4.name])) { - const newValue = replaceLinkInValue(link2, newLink, row[c4.name]); + if (valueContainsLink(link, row[c4.name])) { + const newValue = replaceLinkInValue(link, newLink, row[c4.name]); saveFrontmatterValue( plugin, row.File, @@ -32081,7 +32067,7 @@ var saveDB = async (plugin, context, newTable) => { }; var insertColumns = (table, column) => { if (table.cols.find((f4) => f4.name == column.name)) { - new import_obsidian13.Notice(i18n_default.notice.duplicatePropertyName); + new import_obsidian14.Notice(i18n_default.notice.duplicatePropertyName); return; } return { @@ -32105,7 +32091,7 @@ var insertRowsIfUnique = (folder, rows) => { }; var saveContextToFrontmatter = (file, cols, context, plugin) => { const afile = getAbstractFileAtPath(app, file); - if (afile && afile instanceof import_obsidian13.TFile) + if (afile && afile instanceof import_obsidian14.TFile) saveContextToFile(afile, cols, context, plugin); }; var initiateContextIfNotExists = async (plugin, tag) => { @@ -32116,27 +32102,29 @@ var initiateContextIfNotExists = async (plugin, tag) => { return createDefaultDB(plugin, context); }; var updateContextValue = async (plugin, context, file, field, value) => { - const tagFileExists = getAbstractFileAtPath(app, context.dbPath); + let tagFileExists = abstractFileAtPathExists(app, context.dbPath); if (!tagFileExists) { - await createDefaultDB(plugin, context); + tagFileExists = await createDefaultDB(plugin, context); } - await getMDBTable(plugin, context, "files").then( - (tagDB) => { - const newMDB = updateValue(tagDB, FilePropertyName, file, field, value); - return saveDB(plugin, context, newMDB).then((f4) => newMDB); - } - ); + if (tagFileExists) + await getMDBTable(plugin, context, "files").then( + (tagDB) => { + const newMDB = updateValue(tagDB, FilePropertyName, file, field, value); + return saveDB(plugin, context, newMDB).then((f4) => newMDB); + } + ); }; var insertContextColumn = async (plugin, context, field) => { - const tagFileExists = getAbstractFileAtPath(app, context.dbPath); + let tagFileExists = abstractFileAtPathExists(app, context.dbPath); if (!tagFileExists) { - await createDefaultDB(plugin, context); + tagFileExists = await createDefaultDB(plugin, context); } - await getMDBTable(plugin, context, "files").then((tagDB) => { - const newDB = insertColumns(tagDB, field); - saveDB(plugin, context, newDB).then((f4) => newDB); - return newDB; - }); + if (tagFileExists) + await getMDBTable(plugin, context, "files").then((tagDB) => { + const newDB = insertColumns(tagDB, field); + saveDB(plugin, context, newDB).then((f4) => newDB); + return newDB; + }).then((f4) => plugin.index.reloadContext(context)); }; var insertContextItems = async (plugin, newPaths, t4) => { const saveNewContextRows = async (tag, context2) => { @@ -32144,17 +32132,18 @@ var insertContextItems = async (plugin, newPaths, t4) => { await saveDB(plugin, context2, insertRowsIfUnique(tag, newRow)); }; const context = tagContextFromTag(plugin, t4); - const tagFileExists = getAbstractFileAtPath(app, context.dbPath); + let tagFileExists = abstractFileAtPathExists(app, context.dbPath); if (!tagFileExists) { - await createDefaultDB(plugin, context); + tagFileExists = await createDefaultDB(plugin, context); } - await getMDBTable(plugin, context, "files").then( - (tagDB) => saveNewContextRows(tagDB, context) - ); + if (tagFileExists) + await getMDBTable(plugin, context, "files").then( + (tagDB) => saveNewContextRows(tagDB, context) + ); }; var fileToFM = (afile, cols, plugin) => { let file = afile; - if (afile instanceof import_obsidian13.TFolder) { + if (afile instanceof import_obsidian14.TFolder) { file = getAbstractFileAtPath(app, folderNotePathFromAFile(plugin.settings, tFileToAFile(afile))); } if (!file) @@ -32332,7 +32321,7 @@ var removeFilesInContext = async (plugin, paths, context) => { }; // src/components/ui/menus/menuItems.tsx -var import_obsidian14 = require("obsidian"); +var import_obsidian15 = require("obsidian"); // src/components/ui/menus/selectMenu/SelectMenuComponent.tsx var import_lodash6 = __toESM(require_lodash()); @@ -32911,7 +32900,7 @@ var inputMenuItem = (menuItem, value, setValue) => { return menuItem; }; var showSelectMenu = (point, optionProps) => { - const menu = new import_obsidian14.Menu(); + const menu = new import_obsidian15.Menu(); menu.dom.toggleClass("mk-menu", true); menu.setUseNativeMenu(false); const frag = document.createDocumentFragment(); @@ -33193,7 +33182,7 @@ var ContextCell = (props2) => { }; // src/components/ui/menus/datePickerMenu.tsx -var import_obsidian15 = require("obsidian"); +var import_obsidian16 = require("obsidian"); // node_modules/react-day-picker/dist/index.esm.js var __assign2 = function() { @@ -34775,7 +34764,7 @@ function DayPicker(props2) { // src/components/ui/menus/datePickerMenu.tsx var showDatePickerMenu = (point, value, setValue, format2) => { - const menu = new import_obsidian15.Menu(); + const menu = new import_obsidian16.Menu(); menu.dom.toggleClass("mk-menu", true); menu.setUseNativeMenu(false); const frag = document.createDocumentFragment(); @@ -34828,7 +34817,7 @@ var showDatePickerMenu = (point, value, setValue, format2) => { // src/utils/date.ts var formatDate = (plugin, date, dateFormat) => { - var dateString; + let dateString; try { dateString = format( date, @@ -34907,7 +34896,7 @@ var DateCell = (props2) => { }; // src/components/ContextView/ContextBuilder/BuilderMetadataFields.tsx -var import_obsidian16 = require("obsidian"); +var import_obsidian17 = require("obsidian"); var allMetadataForFiles = (plugin, files) => { return files.reduce((p3, c4) => { const fm = frontMatterForFile(c4); @@ -34941,7 +34930,7 @@ var metadatTypeFilterPredicate = (value, index, self2) => { var SyncMetadataComponent = (props2) => { const cols = allMetadataForFiles( props2.plugin, - props2.files.filter((f4) => f4 instanceof import_obsidian16.TFile) + props2.files.filter((f4) => f4 instanceof import_obsidian17.TFile) ).filter( (f4) => props2.columns ? !props2.columns.some((g4) => g4.name == f4.name) : true ); @@ -34959,7 +34948,7 @@ var SyncMetadataComponent = (props2) => { }; // src/components/Spaces/SpaceEditor.tsx -var import_obsidian24 = require("obsidian"); +var import_obsidian25 = require("obsidian"); // src/types/metadata.ts var fileProps = { @@ -35041,8 +35030,8 @@ var fileMeta = { // src/utils/contexts/predicate/filterFns/filterFnLabels.ts var filterFnLabels = { - isEmpty: "is empty", - isNotEmpty: "is not empty", + isEmpty: i18n_default.filterTypes.isEmpty, + isNotEmpty: i18n_default.filterTypes.isNotEmpty, include: i18n_default.filterTypes.contains, notInclude: i18n_default.filterTypes.notContains, is: i18n_default.filterTypes.is, @@ -35061,7 +35050,7 @@ var filterFnLabels = { }; // src/components/ui/menus/newPropertyMenu.tsx -var import_obsidian17 = require("obsidian"); +var import_obsidian18 = require("obsidian"); var NewPropertyMenuComponent = (props2) => { const [fieldName, setFieldName] = h2(""); const [fieldSource, setFieldSource] = h2( @@ -35148,7 +35137,7 @@ var NewPropertyMenuComponent = (props2) => { }; const saveField = () => { if (fieldName.length == 0) { - new import_obsidian17.Notice(i18n_default.notice.noPropertyName); + new import_obsidian18.Notice(i18n_default.notice.noPropertyName); return; } props2.saveField(fieldSource, { @@ -35215,7 +35204,7 @@ var NewPropertyMenuComponent = (props2) => { }, /* @__PURE__ */ Cn.createElement("span", null, "Cancel"))); }; var showNewPropertyMenu = (plugin, position, tags, fields, saveField, schemaId, contextPath, fileMetadata) => { - const menu = new import_obsidian17.Menu(); + const menu = new import_obsidian18.Menu(); menu.setUseNativeMenu(false); const frag = document.createDocumentFragment(); const div = frag.createDiv(); @@ -35421,7 +35410,7 @@ var ColumnHeader = (props2) => { }; // src/components/ui/menus/propertyMenu.tsx -var import_obsidian18 = require("obsidian"); +var import_obsidian19 = require("obsidian"); var PropertyValueComponent = (props2) => { const selectContext = (e4) => { var _a2; @@ -35437,7 +35426,7 @@ var PropertyValueComponent = (props2) => { }; const selectFileProp = (e4) => { var _a2; - const properties2 = (_a2 = props2.plugin.index.contextsCache.get(props2.contextPath)) == null ? void 0 : _a2.cols.filter( + const properties2 = (_a2 = props2.plugin.index.contextsIndex.get(props2.contextPath)) == null ? void 0 : _a2.cols.filter( (f4) => f4.type == "file" || f4.type == "link" || f4.type == "context" ).reduce((p3, c4) => { var _a3, _b2; @@ -35446,7 +35435,7 @@ var PropertyValueComponent = (props2) => { ...c4.type == "file" || c4.type == "link" ? filePropTypes.map((f4) => ({ name: c4.name + "." + f4.name, value: c4.name + "." + f4.value - })) : (_b2 = (_a3 = props2.plugin.index.contextsCache.get(c4.value)) == null ? void 0 : _a3.cols.filter((f4) => f4.hidden != "true").map((f4) => ({ + })) : (_b2 = (_a3 = props2.plugin.index.contextsIndex.get(c4.value)) == null ? void 0 : _a3.cols.filter((f4) => f4.hidden != "true").map((f4) => ({ name: c4.name + "." + f4.name, value: c4.name + "." + f4.name }))) != null ? _b2 : [] @@ -35575,7 +35564,7 @@ var PropertyMenuComponent = (props2) => { })); }; var showPropertyMenu = (plugin, position, editable, options, field, fields, contextPath, saveField, saveContext, hide, deleteColumn, sortColumn, hidden) => { - const menu = new import_obsidian18.Menu(); + const menu = new import_obsidian19.Menu(); menu.setUseNativeMenu(false); if (editable) { menu.addItem((menuItem) => { @@ -35669,12 +35658,12 @@ var showPropertyMenu = (plugin, position, editable, options, field, fields, cont var import_classnames = __toESM(require_classnames()); // src/components/ContextView/TagsView/TagsView.tsx -var import_obsidian19 = require("obsidian"); +var import_obsidian20 = require("obsidian"); var TagsView = (props2) => { const showTagMenu = (e4, tag) => { e4.stopPropagation(); e4.preventDefault(); - const menu = new import_obsidian19.Menu(); + const menu = new import_obsidian20.Menu(); menu.addItem((menuItem) => { menuItem.setIcon("hash"); menuItem.setTitle(i18n_default.menu.openTag); @@ -36217,8 +36206,8 @@ var ContextBuilderView = (props2) => { }; // src/components/ui/modals/contextEditorModal.tsx -var import_obsidian20 = require("obsidian"); -var ContextEditorModal = class extends import_obsidian20.Modal { +var import_obsidian21 = require("obsidian"); +var ContextEditorModal = class extends import_obsidian21.Modal { constructor(plugin, context, view) { super(plugin.app); this.context = context; @@ -36250,8 +36239,8 @@ var ContextEditorModal = class extends import_obsidian20.Modal { }; // src/components/ui/modals/mergeColumnModal.ts -var import_obsidian21 = require("obsidian"); -var MergeColumnModal = class extends import_obsidian21.Modal { +var import_obsidian22 = require("obsidian"); +var MergeColumnModal = class extends import_obsidian22.Modal { constructor(columns, mergeColumn) { super(app); this.columns = columns; @@ -36306,8 +36295,8 @@ var MergeColumnModal = class extends import_obsidian21.Modal { }; // src/components/ui/modals/saveViewModal.ts -var import_obsidian22 = require("obsidian"); -var SaveViewModal = class extends import_obsidian22.Modal { +var import_obsidian23 = require("obsidian"); +var SaveViewModal = class extends import_obsidian23.Modal { constructor(schema, saveSchema, action) { super(app); this.schema = schema; @@ -36374,7 +36363,7 @@ var SaveViewModal = class extends import_obsidian22.Modal { }; // src/components/ContextView/FilterBar/FilterBar.tsx -var import_obsidian23 = require("obsidian"); +var import_obsidian24 = require("obsidian"); // src/components/ContextView/FilterBar/SearchBar.tsx var SearchBar = (props2) => { @@ -36483,7 +36472,7 @@ var FilterBar = (props2) => { }); }; const viewContextMenu = (e4, _schema) => { - const fileMenu = new import_obsidian23.Menu(); + const fileMenu = new import_obsidian24.Menu(); fileMenu.addSeparator(); fileMenu.addItem((menuItem) => { menuItem.setTitle("Copy Embed Link"); @@ -36520,7 +36509,7 @@ var FilterBar = (props2) => { } }; const showFilterMenu = (e4) => { - const menu = new import_obsidian23.Menu(); + const menu = new import_obsidian24.Menu(); menu.addItem((item) => { item.setTitle(i18n_default.menu.tableView); item.setIcon("table-2"); @@ -36542,13 +36531,15 @@ var FilterBar = (props2) => { saveViewType("list"); }); }); - menu.addItem((item) => { - item.setTitle(i18n_default.menu.flowView); - item.setIcon("infinity"); - item.onClick(() => { - saveViewType("flow"); + if (dbSchema == null ? void 0 : dbSchema.primary) { + menu.addItem((item) => { + item.setTitle(i18n_default.menu.flowView); + item.setIcon("infinity"); + item.onClick(() => { + saveViewType("flow"); + }); }); - }); + } menu.addSeparator(); menu.addItem((item) => { item.setTitle(i18n_default.menu.groupBy); @@ -36818,7 +36809,7 @@ var FilterBar = (props2) => { ); }; const showAddMenu = (e4) => { - const fileMenu = new import_obsidian23.Menu(); + const fileMenu = new import_obsidian24.Menu(); const folder = getAbstractFileAtPath( app, contextInfo.contextPath @@ -36861,7 +36852,7 @@ var FilterBar = (props2) => { return false; }; const showFMMenu2 = (e4) => { - const menu = new import_obsidian23.Menu(); + const menu = new import_obsidian24.Menu(); menu.addItem((menuItem) => { menuItem.setIcon("log-in"); menuItem.setTitle(i18n_default.menu.mergeProperties); @@ -36931,7 +36922,7 @@ var FilterBar = (props2) => { case "text": case "number": { - const menu = new import_obsidian23.Menu(); + const menu = new import_obsidian24.Menu(); menu.setUseNativeMenu(false); const saveFilterValue = (value) => { const newFilter = { @@ -37059,7 +37050,7 @@ var FilterBar = (props2) => { dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-view-options"] } - }), /* @__PURE__ */ Cn.createElement("button", { + }), (dbSchema == null ? void 0 : dbSchema.primary) && /* @__PURE__ */ Cn.createElement("button", { onClick: (e4) => showColsMenu(e4), dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-build"] } }), contextInfo.type == "folder" && (dbSchema == null ? void 0 : dbSchema.id) == "files" && /* @__PURE__ */ Cn.createElement("button", { @@ -37121,7 +37112,7 @@ var FilterValueSpan = (props2) => { // src/components/Spaces/SpaceEditor.tsx var SpaceEditor = k3( (props2, ref) => { - var _a2; + var _a2, _b2; const [def, setDef] = h2( (_a2 = props2.def) != null ? _a2 : { type: "smart", @@ -37138,7 +37129,7 @@ var SpaceEditor = k3( case "text": case "number": { - const menu = new import_obsidian24.Menu(); + const menu = new import_obsidian25.Menu(); menu.setUseNativeMenu(false); menu.addItem((menuItem) => { inputMenuItem( @@ -37464,7 +37455,7 @@ var SpaceEditor = k3( ); const frontmatter = allMetadataForFiles( props2.plugin, - allFiles.map((f5) => getAbstractFileAtPath(app, f5.path)).filter((f5) => f5 instanceof import_obsidian24.TFile) + allFiles.map((f5) => getAbstractFileAtPath(app, f5.path)).filter((f5) => f5 instanceof import_obsidian25.TFile) ); const fmTypes = guestimateTypes( allFiles.map((f5) => f5.path), @@ -37502,7 +37493,9 @@ var SpaceEditor = k3( p2(() => { ref.current = def; }, [def]); - return /* @__PURE__ */ Cn.createElement("div", null, def.type == "smart" ? /* @__PURE__ */ Cn.createElement("div", { + return /* @__PURE__ */ Cn.createElement("div", { + className: "mk-space-settings" + }, def.type == "smart" ? /* @__PURE__ */ Cn.createElement("div", { className: "mk-query" }, def.filters.length == 0 ? /* @__PURE__ */ Cn.createElement(DefFilterGroup, { selectGroupType, @@ -37513,6 +37506,7 @@ var SpaceEditor = k3( i: 0, removeDefGroup }) : def.filters.map((f4, i4) => /* @__PURE__ */ Cn.createElement(DefFilterGroup, { + key: i4, group: f4, selectGroupType, addDefGroup, @@ -37521,6 +37515,7 @@ var SpaceEditor = k3( i: i4, removeDefGroup }, f4.filters.map((filter, k5) => /* @__PURE__ */ Cn.createElement(DefFilter, { + key: k5, filter, i: i4, k: k5, @@ -37529,9 +37524,45 @@ var SpaceEditor = k3( selectFilterValue, addDefFilter, removeDefFilter - }))))) : /* @__PURE__ */ Cn.createElement(Cn.Fragment, null)); + }))))) : /* @__PURE__ */ Cn.createElement("div", { + className: "setting-item mod-toggle" + }, /* @__PURE__ */ Cn.createElement("div", { + className: "setting-item-info" + }, /* @__PURE__ */ Cn.createElement("div", { + className: "setting-item-name" + }, "Sync to Folder"), /* @__PURE__ */ Cn.createElement("div", { + className: "setting-item-description" + }, "Select a folder to sync this space with all notes from a folder", /* @__PURE__ */ Cn.createElement("br", null), "Note: Existing items in the space will be removed from the space.")), /* @__PURE__ */ Cn.createElement("div", { + className: "setting-item-control" + }, /* @__PURE__ */ Cn.createElement("button", { + onClick: (e4) => { + const offset = e4.target.getBoundingClientRect(); + showSelectMenu( + { x: offset.left, y: offset.top + 30 }, + { + multi: false, + editable: false, + value: [], + options: [ + { name: "None", value: "" }, + ...getAllFoldersInVault(app).map((f4) => ({ + name: getFolderName(f4.path, app), + description: f4.path, + value: f4.path + })) + ], + saveOptions: (_9, values) => { + setDef((prev) => ({ ...prev, folder: values[0] })); + }, + searchable: true + } + ); + } + }, ((_b2 = def.folder) == null ? void 0 : _b2.length) > 0 ? getFolderName(def.folder, app) : "None")))); } ); +SpaceEditor.displayName = "SpaceEditor"; +var SpaceEditor_default = SpaceEditor; var DefFilter = (props2) => { var _a2; const { @@ -37617,8 +37648,8 @@ var DefFilterGroup = (props2) => { }; // src/components/ui/modals/editSpaceModal.tsx -var import_obsidian25 = require("obsidian"); -var EditSpaceModal = class extends import_obsidian25.Modal { +var import_obsidian26 = require("obsidian"); +var EditSpaceModal = class extends import_obsidian26.Modal { constructor(plugin, space, action) { super(plugin.app); this.space = space; @@ -37626,8 +37657,7 @@ var EditSpaceModal = class extends import_obsidian25.Modal { this.plugin = plugin; } onOpen() { - let { contentEl } = this; - let myModal = this; + const { contentEl } = this; let headerText; if (this.action === "rename") { if (this.space.def.type == "smart") { @@ -37655,7 +37685,7 @@ var EditSpaceModal = class extends import_obsidian25.Modal { const root = createRoot(queryEl); this.ref = Cn.createRef(); root.render( - /* @__PURE__ */ Cn.createElement(SpaceEditor, { + /* @__PURE__ */ Cn.createElement(SpaceEditor_default, { plugin: this.plugin, def: this.space.def, ref: this.ref @@ -37675,16 +37705,16 @@ var EditSpaceModal = class extends import_obsidian25.Modal { }); cancelButton.style.cssText = "float: right;"; cancelButton.addEventListener("click", () => { - myModal.close(); + this.close(); }); const onClickAction = async () => { - let newName = inputEl.value.replace(/\//g, ""); + const newName = inputEl.value.replace(/\//g, ""); if (newName.length == 0) { - new import_obsidian25.Notice(i18n_default.notice.newSpaceName); + new import_obsidian26.Notice(i18n_default.notice.newSpaceName); return; } - if (this.plugin.index.spacesCache.has(newName) && newName != this.space.name) { - new import_obsidian25.Notice(i18n_default.notice.duplicateSpaceName); + if (this.plugin.index.spacesIndex.has(newName) && newName != this.space.name) { + new import_obsidian26.Notice(i18n_default.notice.duplicateSpaceName); return; } if (this.action === "rename") { @@ -37700,7 +37730,7 @@ var EditSpaceModal = class extends import_obsidian25.Modal { 0 ); } - myModal.close(); + this.close(); }; changeButton.addEventListener("click", onClickAction); inputEl.addEventListener("keydown", (e4) => { @@ -37709,13 +37739,13 @@ var EditSpaceModal = class extends import_obsidian25.Modal { }); } onClose() { - let { contentEl } = this; + const { contentEl } = this; contentEl.empty(); } }; // src/components/ui/menus/fileMenu.tsx -var import_obsidian26 = require("obsidian"); +var import_obsidian27 = require("obsidian"); // src/utils/color.ts var colors = [ @@ -37732,7 +37762,7 @@ var colors = [ // src/components/ui/menus/fileMenu.tsx var triggerSectionAddMenu = (plugin, e4) => { - const fileMenu = new import_obsidian26.Menu(); + const fileMenu = new import_obsidian27.Menu(); fileMenu.addItem((menuItem) => { menuItem.setIcon("plus"); menuItem.setTitle(i18n_default.buttons.createSection); @@ -37784,7 +37814,7 @@ var triggerSectionAddMenu = (plugin, e4) => { var triggerSectionMenu = (plugin, space, spaces2, e4, activeFile2) => { if (!space) return; - const fileMenu = new import_obsidian26.Menu(); + const fileMenu = new import_obsidian27.Menu(); const spaceName = space.name; fileMenu.addItem((menuItem) => { menuItem.setIcon("edit"); @@ -37873,7 +37903,7 @@ var triggerSectionMenu = (plugin, space, spaces2, e4, activeFile2) => { menuItem.setTitle(i18n_default.menu.sortBy); menuItem.setIcon("sort-desc"); menuItem.onClick((ev) => { - const sortMenu = new import_obsidian26.Menu(); + const sortMenu = new import_obsidian27.Menu(); if (space.def.type == "focus") { sortMenu.addItem((menuItem2) => { const sortOption = ["rank", true]; @@ -37961,7 +37991,7 @@ var triggerMultiFileMenu = (plugin, selectedFiles2, e4) => { const files = selectedFiles2.map((s5) => s5.item.path); const spaces2 = plugin.index.allSpaces(); const spaceItems = retrieveSpaceItems(plugin, spaces2); - const fileMenu = new import_obsidian26.Menu(); + const fileMenu = new import_obsidian27.Menu(); fileMenu.addSeparator(); fileMenu.addItem((menuItem) => { menuItem.setIcon("plus"); @@ -38052,8 +38082,8 @@ var triggerMultiFileMenu = (plugin, selectedFiles2, e4) => { var triggerFileMenu = (plugin, file, isFolder, e4, source = "file-explorer") => { const spaces2 = plugin.index.allSpaces(); const spaceItems = retrieveSpaceItems(plugin, spaces2); - const cache = plugin.index.files.get(file.path); - const fileMenu = new import_obsidian26.Menu(); + const cache = plugin.index.filesIndex.get(file.path); + const fileMenu = new import_obsidian27.Menu(); if (isFolder) { fileMenu.addSeparator(); fileMenu.addItem((menuItem) => { @@ -38124,7 +38154,7 @@ var triggerFileMenu = (plugin, file, isFolder, e4, source = "file-explorer") => menuItem.setTitle(i18n_default.menu.sortBy); menuItem.setIcon("sort-desc"); menuItem.onClick((ev) => { - const sortMenu = new import_obsidian26.Menu(); + const sortMenu = new import_obsidian27.Menu(); sortMenu.addItem((menuItem2) => { menuItem2.setTitle(i18n_default.menu.customSort); menuItem2.setChecked(cache.folderSort == ""); @@ -38250,6 +38280,16 @@ var triggerFileMenu = (plugin, file, isFolder, e4, source = "file-explorer") => } }); }); + if (!isFolder) { + fileMenu.addItem((menuItem) => { + menuItem.setTitle(i18n_default.menu.changeToFolderNote); + menuItem.setIcon("file-plus-2"); + menuItem.onClick((ev) => { + if (file instanceof import_obsidian27.TFile) + noteToFolderNote(plugin, file, true); + }); + }); + } fileMenu.addItem((menuItem) => { menuItem.setIcon("go-to-file"); menuItem.setTitle(i18n_default.menu.openFilePane); @@ -38293,14 +38333,14 @@ var triggerFileMenu = (plugin, file, isFolder, e4, source = "file-explorer") => }; // src/components/ContextView/DataTypeView/FileCell.tsx -var import_obsidian27 = require("obsidian"); +var import_obsidian28 = require("obsidian"); var FileCell = (props2) => { const fileOrCleanPath = (f4) => { if (!f4) return { path: "" }; - const fileCache = props2.plugin.index.files.get(f4); + const fileCache = props2.plugin.index.filesIndex.get(f4); return fileCache ? { path: f4, fileCache } : { path: f4 }; }; const value = F2( @@ -38325,7 +38365,7 @@ var FileCell = (props2) => { if (!ref.current) return; if (fileExists((_a2 = ref.current) == null ? void 0 : _a2.value)) { - new import_obsidian27.Notice(i18n_default.notice.fileExists); + new import_obsidian28.Notice(i18n_default.notice.fileExists); } else { props2.saveValue(ref.current.value); props2.setEditMode(null); @@ -38338,7 +38378,7 @@ var FileCell = (props2) => { return; } if (fileExists(path)) { - new import_obsidian27.Notice(i18n_default.notice.fileExists); + new import_obsidian28.Notice(i18n_default.notice.fileExists); } else { await createNewMarkdownFile( props2.plugin, @@ -38571,7 +38611,7 @@ var TextCell = (props2) => { // src/components/ContextView/TableView/TableView.tsx var import_lodash7 = __toESM(require_lodash()); -var import_obsidian28 = require("obsidian"); +var import_obsidian29 = require("obsidian"); // src/components/ContextView/DataTypeView/ImageCell.tsx var ImageCell = (props2) => { @@ -39178,7 +39218,7 @@ var TableView = (props2) => { }; const showContextMenu = (e4, index) => { e4.preventDefault(); - const menu = new import_obsidian28.Menu(); + const menu = new import_obsidian29.Menu(); menu.addItem((item) => { item.setIcon("trash"); item.setTitle(i18n_default.menu.deleteRow); @@ -39433,7 +39473,7 @@ var PreviewCell = (props2) => { return getAbstractFileAtPath(app, previewImage); }, [previewImage]); const loadIcon = () => { - setVaultItem(props2.plugin.index.files.get(props2.file)); + setVaultItem(props2.plugin.index.filesIndex.get(props2.file)); }; p2(() => { loadIcon(); @@ -39639,15 +39679,11 @@ var FlowView = (props2) => { const ref = _2(null); const loadFile = async () => { const div = ref.current; - const { - path: link2, - ref: refStr, - type - } = pathByString(props2.plugin, props2.path); + const { path: link, ref: refStr, type } = pathByString(props2.path); const portalType = type == "tag" || type == "folder" ? "context" : "doc"; await spawnLeafFromFile( props2.plugin, - link2, + link, div, portalType, refStr, @@ -40319,11 +40355,11 @@ function useMountStatus() { } // src/components/ContextView/FlowListView/FlowListView.tsx -var import_obsidian29 = require("obsidian"); +var import_obsidian30 = require("obsidian"); var FlowListView = (props2) => { const { filteredData: data } = q2(MDBContext); const flowItems = F2(() => { - return data.map((f4) => getAbstractFileAtPath(app, f4.File)).filter((f4) => f4 instanceof import_obsidian29.TFile && f4.extension == "md"); + return data.map((f4) => getAbstractFileAtPath(app, f4.File)).filter((f4) => f4 instanceof import_obsidian30.TFile && f4.extension == "md"); }, [data]); return /* @__PURE__ */ Cn.createElement("div", { className: "mk-flow-container" @@ -40352,18 +40388,18 @@ var ContextListView = (props2) => { // src/components/ContextView/EmbedContextViewComponent.tsx var EmbedContextViewComponent = (props2) => { const context = mdbContextByPath(props2.plugin, props2.path); - return /* @__PURE__ */ Cn.createElement(MDBProvider, { + return /* @__PURE__ */ Cn.createElement(Cn.Fragment, null, context && /* @__PURE__ */ Cn.createElement(MDBProvider, { plugin: props2.plugin, context, schema: props2.schema - }, context && /* @__PURE__ */ Cn.createElement(ContextListView, { + }, /* @__PURE__ */ Cn.createElement("div", null, /* @__PURE__ */ Cn.createElement(ContextListView, { plugin: props2.plugin - })); + })))); }; // src/components/ContextView/EmbedContextView.tsx var EMBED_CONTEXT_VIEW_TYPE = "make-inline-context"; -var EmbedContextView = class extends import_obsidian30.ItemView { +var EmbedContextView = class extends import_obsidian31.ItemView { constructor(leaf, plugin) { super(leaf); this.navigation = true; @@ -40419,27 +40455,27 @@ var EmbedContextView = class extends import_obsidian30.ItemView { }; // src/components/FlowEditor/FlowEditor.tsx -var import_obsidian31 = require("obsidian"); +var import_obsidian32 = require("obsidian"); var popovers = /* @__PURE__ */ new WeakMap(); var mouseCoords = { x: 0, y: 0 }; function nosuper(base) { const derived = function() { - return Object.setPrototypeOf(new import_obsidian31.Component(), new.target.prototype); + return Object.setPrototypeOf(new import_obsidian32.Component(), new.target.prototype); }; derived.prototype = base.prototype; return Object.setPrototypeOf(derived, base); } var _a, _b, _c, _d, _e; -var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { +var FlowEditor = class extends nosuper(import_obsidian32.HoverPopover) { constructor(parent, targetEl, plugin, waitTime, onShowCallback) { super(); this.targetEl = targetEl; this.plugin = plugin; this.onShowCallback = onShowCallback; - this.abortController = this.addChild(new import_obsidian31.Component()); + this.abortController = this.addChild(new import_obsidian32.Component()); this.detaching = false; this.opening = false; - this.rootSplit = new import_obsidian31.WorkspaceSplit( + this.rootSplit = new import_obsidian32.WorkspaceSplit( window.app.workspace, "vertical" ); @@ -40457,13 +40493,14 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { this.onTarget = true; this.parent = parent; this.waitTime = waitTime; - this.state = import_obsidian31.PopoverState.Showing; + this.state = import_obsidian32.PopoverState.Showing; const { hoverEl } = this; this.abortController.load(); this.timer = window.setTimeout(this.show.bind(this), waitTime); this.setActive = this._setActive.bind(this); if (hoverEl) { hoverEl.addEventListener("mousedown", this.setActive); + hoverEl.addEventListener("mousedown", (e4) => e4.stopPropagation()); } popovers.set(this.hoverEl, this); this.hoverEl.addClass("hover-editor"); @@ -40547,7 +40584,7 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { this.registerEvent( app.workspace.on("layout-change", () => { this.rootSplit.children.forEach((item, index) => { - if (item instanceof import_obsidian31.WorkspaceTabs) { + if (item instanceof import_obsidian32.WorkspaceTabs) { this.rootSplit.replaceChild(index, item.children[0]); } }); @@ -40561,7 +40598,7 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { }, this.rootSplit); return leaves; } - onShow() { + async onShow() { var _a2, _b2; const closeDelay = 600; setTimeout(() => this.waitTime = closeDelay, closeDelay); @@ -40578,27 +40615,28 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { if (this.parent) { this.parent.flowEditor = this; } + await ((_b2 = this.onShowCallback) == null ? void 0 : _b2.call(this, this)); + this.onShowCallback = void 0; const viewHeaderEl = this.hoverEl.querySelector(".view-header"); viewHeaderEl == null ? void 0 : viewHeaderEl.remove(); const sizer = this.hoverEl.querySelector(".workspace-leaf"); - this.hoverEl.appendChild(sizer); + if (sizer) + this.hoverEl.appendChild(sizer); const inlineTitle = this.hoverEl.querySelector(".inline-title"); inlineTitle == null ? void 0 : inlineTitle.remove(); - (_b2 = this.onShowCallback) == null ? void 0 : _b2.call(this); - this.onShowCallback = void 0; } transition() { if (this.shouldShow()) { - if (this.state === import_obsidian31.PopoverState.Hiding) { - this.state = import_obsidian31.PopoverState.Shown; + if (this.state === import_obsidian32.PopoverState.Hiding) { + this.state = import_obsidian32.PopoverState.Shown; clearTimeout(this.timer); } } else { - if (this.state === import_obsidian31.PopoverState.Showing) { + if (this.state === import_obsidian32.PopoverState.Showing) { this.hide(); } else { - if (this.state === import_obsidian31.PopoverState.Shown) { - this.state = import_obsidian31.PopoverState.Hiding; + if (this.state === import_obsidian32.PopoverState.Shown) { + this.state = import_obsidian32.PopoverState.Hiding; this.timer = window.setTimeout(() => { if (this.shouldShow()) { this.transition(); @@ -40622,13 +40660,13 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { }); } shouldShowSelf() { - return !this.detaching && !!(this.onTarget || this.state == import_obsidian31.PopoverState.Shown || this.document.querySelector( + return !this.detaching && !!(this.onTarget || this.state == import_obsidian32.PopoverState.Shown || this.document.querySelector( `body>.modal-container, body > #he${this.id} ~ .menu, body > #he${this.id} ~ .suggestion-container` )); } show() { if (!this.targetEl || this.document.body.contains(this.targetEl)) { - this.state = import_obsidian31.PopoverState.Shown; + this.state = import_obsidian32.PopoverState.Shown; this.timer = 0; this.shownPos = mouseCoords; this.targetEl.replaceChildren(this.hoverEl); @@ -40670,7 +40708,7 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { nativeHide() { var _a2; const { hoverEl, targetEl } = this; - this.state = import_obsidian31.PopoverState.Hidden; + this.state = import_obsidian32.PopoverState.Hidden; hoverEl.detach(); if (targetEl) { const parent = targetEl.matchParent(".mk-hover-popover"); @@ -40681,13 +40719,30 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { this.unload(); } resolveLink(linkText, sourcePath) { - const link2 = (0, import_obsidian31.parseLinktext)(linkText); - const tFile = link2 ? this.plugin.app.metadataCache.getFirstLinkpathDest( - link2.path, + const link = (0, import_obsidian32.parseLinktext)(linkText); + const tFile = link ? this.plugin.app.metadataCache.getFirstLinkpathDest( + link.path, sourcePath != null ? sourcePath : "" ) : null; return tFile; } + async openContext(file, openState, useLeaf) { + if (this.detaching) + return; + const leaf = useLeaf != null ? useLeaf : this.attachLeaf(); + this.opening = true; + try { + await leaf.openFile(file, openState); + } catch (e4) { + console.error(e4); + } finally { + this.opening = false; + if (this.detaching) + this.hide(); + } + this.plugin.app.workspace.setActiveLeaf(leaf); + return leaf; + } async openFile(file, openState, useLeaf) { if (this.detaching) return; @@ -40712,10 +40767,10 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { eState }; } - buildEphemeralState(file, link2) { + buildEphemeralState(file, link) { const cache = this.plugin.app.metadataCache.getFileCache(file); - const subpath = cache ? (0, import_obsidian31.resolveSubpath)(cache, (link2 == null ? void 0 : link2.subpath) || "") : void 0; - const eState = { subpath: link2 == null ? void 0 : link2.subpath }; + const subpath = cache ? (0, import_obsidian32.resolveSubpath)(cache, (link == null ? void 0 : link.subpath) || "") : void 0; + const eState = { subpath: link == null ? void 0 : link.subpath }; if (subpath) { eState.line = subpath.start.line; eState.startLoc = subpath.start; @@ -40726,7 +40781,7 @@ var FlowEditor = class extends nosuper(import_obsidian31.HoverPopover) { }; // src/utils/flow/flowEditor.ts -var import_obsidian32 = require("obsidian"); +var import_obsidian33 = require("obsidian"); var parseOutReferences = (ostr) => { const str = ostr.split("|")[0]; const refIndex = str.lastIndexOf("#"); @@ -40824,7 +40879,7 @@ var loadFlowEditor = (cm, flowEditorInfo2, source, make) => { const dom = cm.dom.querySelector( "#mk-flow-" + flowEditorInfo2.id ); - const { path, type, ref } = pathByString(make, flowEditorInfo2.link, source); + const { path, type, ref } = pathByString(flowEditorInfo2.link, source); if (dom) { if (type == "folder" || type == "tag" || type == "space") { const context = mdbContextByPath( @@ -40860,7 +40915,7 @@ var loadFlowEditor = (cm, flowEditorInfo2, source, make) => { ); } } else { - if (aFile instanceof import_obsidian32.TFolder) { + if (aFile instanceof import_obsidian33.TFolder) { if (!dom.hasAttribute("ready")) { dom.setAttribute("ready", ""); createFlowEditorInElement( @@ -40878,7 +40933,7 @@ var loadFlowEditor = (cm, flowEditorInfo2, source, make) => { const createFile = async (e4) => { e4.stopPropagation(); e4.stopImmediatePropagation(); - await app.fileManager.createNewMarkdownFile(app.vault.getRoot(), link); + await app.fileManager.createNewMarkdownFile(app.vault.getRoot(), path); loadFlowEditor(cm, flowEditorInfo2, source, make); }; createDiv.setText(`"${path}" ` + i18n_default.labels.noFile); @@ -40954,79 +41009,86 @@ var focusPortal = async (plugin, evt) => { }; var openFileFromPortal = (plugin, evt) => { const { file: fullLink, source } = evt.detail; - const [link2, ref] = parseOutReferences(fullLink); - const file = getFileFromString(link2, source); + const [link, ref] = parseOutReferences(fullLink); + const file = getFileFromString(link, source); openAFile(file, plugin, false); }; -var spawnLeafFromFile = async (plugin, file, el, type, ref, from, to) => { - var _a2; +var spawnLeafFromFile = async (plugin, file, el, type, ref, from, to, onLeafAttachCallback) => { if (type == "context") { - const newLeaf2 = spawnPortal(plugin, el); - newLeaf2.setViewState({ - type: EMBED_CONTEXT_VIEW_TYPE, - state: { contextPath: file, ref } + spawnPortal(plugin, el, null, async (editor) => { + const newLeaf = editor.attachLeaf(); + await newLeaf.setViewState({ + type: EMBED_CONTEXT_VIEW_TYPE, + state: { contextPath: file, ref } + }); + if (onLeafAttachCallback) + onLeafAttachCallback(newLeaf); }); - return newLeaf2; } - let portalFile = plugin.app.vault.getAbstractFileByPath(file); + const portalFile = plugin.app.vault.getAbstractFileByPath(file); if (!portalFile || !Object.keys(app.embedRegistry.embedByExtension).some( (f4) => f4 == portalFile.extension )) - return; - const newLeaf = spawnPortal(plugin, el, portalFile.name); - await newLeaf.openFile(portalFile, { active: false }); - if (newLeaf.view.setMode) - newLeaf.view.setMode(newLeaf.view.editMode); - if (from && to) { - (_a2 = newLeaf.view.editor) == null ? void 0 : _a2.cm.dispatch({ - annotations: [editableRange.of([from, to])] + return null; + spawnPortal(plugin, el, portalFile.name, async (editor) => { + return editor.openFile(portalFile, { active: false }).then((newLeaf) => { + var _a2; + if (newLeaf.view.setMode) + newLeaf.view.setMode(newLeaf.view.editMode); + if (from && to) { + (_a2 = newLeaf.view.editor) == null ? void 0 : _a2.cm.dispatch({ + annotations: [editableRange.of([from, to])] + }); + if (onLeafAttachCallback) + onLeafAttachCallback(newLeaf); + } }); - } - return newLeaf; + }); }; var spawnNewPortal = async (plugin, evt) => { - var _a2, _b2, _c2; const { file, el, ref, from, to, type } = evt.detail; - const newLeaf = await spawnLeafFromFile(plugin, file, el, type, ref); - if (!((_a2 = newLeaf == null ? void 0 : newLeaf.view) == null ? void 0 : _a2.editor)) { - return; - } - const view = (_b2 = newLeaf.view.editor) == null ? void 0 : _b2.cm; - view.dispatch({ - annotations: [ - portalTypeAnnotation.of(evt.detail.type), - flowIDAnnotation.of(evt.detail.id) - ] - }); - view.dom.addEventListener("keydown", (e4) => { - if (e4.key == "ArrowUp") { - if (e4.metaKey == true) { - view.dispatch({ - annotations: arrowKeyAnnotation.of(3) - }); - } else { - view.dispatch({ - annotations: arrowKeyAnnotation.of(1) - }); - } + spawnLeafFromFile(plugin, file, el, type, ref, null, null, (newLeaf) => { + var _a2, _b2, _c2; + if (!((_a2 = newLeaf == null ? void 0 : newLeaf.view) == null ? void 0 : _a2.editor)) { + return; } - if (e4.key == "ArrowDown") { - if (e4.metaKey == true) { - view.dispatch({ - annotations: arrowKeyAnnotation.of(4) - }); - } else { - view.dispatch({ - annotations: arrowKeyAnnotation.of(2) - }); + const view = (_b2 = newLeaf.view.editor) == null ? void 0 : _b2.cm; + view.dispatch({ + annotations: [ + portalTypeAnnotation.of(evt.detail.type), + flowIDAnnotation.of(evt.detail.id) + ] + }); + view.dom.addEventListener("keydown", (e4) => { + if (e4.key == "ArrowUp") { + if (e4.metaKey == true) { + view.dispatch({ + annotations: arrowKeyAnnotation.of(3) + }); + } else { + view.dispatch({ + annotations: arrowKeyAnnotation.of(1) + }); + } + } + if (e4.key == "ArrowDown") { + if (e4.metaKey == true) { + view.dispatch({ + annotations: arrowKeyAnnotation.of(4) + }); + } else { + view.dispatch({ + annotations: arrowKeyAnnotation.of(2) + }); + } } + }); + if (from && to) { + (_c2 = newLeaf.view.editor) == null ? void 0 : _c2.cm.dispatch({ + annotations: [editableRange.of([from, to])] + }); } }); - if (from && to) { - (_c2 = newLeaf.view.editor) == null ? void 0 : _c2.cm.dispatch({ - annotations: [editableRange.of([from, to])] - }); - } }; var spawnPortal = (plugin, initiatingEl, fileName, onShowCallback) => { const parent = plugin.app.workspace.activeLeaf; @@ -41044,11 +41106,10 @@ var spawnPortal = (plugin, initiatingEl, fileName, onShowCallback) => { 0, fileName.lastIndexOf(".") ); - return hoverPopover.attachLeaf(); }; // src/components/ContextView/FilterBar/TableSelector.tsx -var import_obsidian33 = require("obsidian"); +var import_obsidian34 = require("obsidian"); var TableSelector = (props2) => { const { folderNoteOpen, viewFolderNote } = props2; const { @@ -41113,7 +41174,7 @@ var TableSelector = (props2) => { ); }; const viewContextMenu = (e4, _schema) => { - const fileMenu = new import_obsidian33.Menu(); + const fileMenu = new import_obsidian34.Menu(); fileMenu.addSeparator(); fileMenu.addItem((menuItem) => { menuItem.setTitle("Rename Table"); @@ -41160,13 +41221,16 @@ var TableSelector = (props2) => { var ContextViewComponent = (props2) => { var _a2, _b2; const context = props2.context; - const contextCache = props2.plugin.index.contextsCache.get( + const contextCache = props2.plugin.index.contextsIndex.get( context.contextPath ); const [folderCache, setFolderCache] = h2(null); + const [currentFlowNotePath, setCurrentFlowNotePath] = h2(null); const refreshCache = () => { if (props2.context.type == "folder") { - setFolderCache(props2.plugin.index.files.get(props2.context.contextPath)); + setFolderCache( + props2.plugin.index.filesIndex.get(props2.context.contextPath) + ); return; } setFolderCache(null); @@ -41177,34 +41241,33 @@ var ContextViewComponent = (props2) => { props2.plugin.settings.folderNoteDefaultView && props2.plugin.settings.enableFolderNote ); const loadFile = async () => { - var _a3, _b3; if (!folderCache) return; const folderNotePath = folderNotePathFromAFile( props2.plugin.settings, folderCache ); - let newLeaf; const folderNote = getAbstractFileAtPath(app, folderNotePath); - if (folderNote) { - const div = ref.current; - newLeaf = spawnPortal(props2.plugin, div); - await newLeaf.openFile(folderNote); - } else { - const div = ref.current; - const newFile = await app.fileManager.createNewMarkdownFile( - app.vault.getRoot(), - folderNotePath - ); - newLeaf = spawnPortal(props2.plugin, div); - await newLeaf.openFile(newFile); - } - if (!((_a3 = newLeaf == null ? void 0 : newLeaf.view) == null ? void 0 : _a3.editor)) { - return; - } - const view = (_b3 = newLeaf.view.editor) == null ? void 0 : _b3.cm; - view.dispatch({ - annotations: [portalTypeAnnotation.of("foldernote")] + const div = ref.current; + spawnPortal(props2.plugin, div, folderCache.name, async (editor) => { + var _a3, _b3; + let leaf; + if (folderNote) { + leaf = await editor.openFile(folderNote); + } else { + const newFile = await app.fileManager.createNewMarkdownFile( + app.vault.getRoot(), + folderNotePath + ); + leaf = await editor.openFile(newFile); + } + if (!((_a3 = leaf == null ? void 0 : leaf.view) == null ? void 0 : _a3.editor)) { + return; + } + const view = (_b3 = leaf.view.editor) == null ? void 0 : _b3.cm; + view.dispatch({ + annotations: [portalTypeAnnotation.of("foldernote")] + }); }); }; const cacheChanged = (evt) => { @@ -41239,7 +41302,7 @@ var ContextViewComponent = (props2) => { plugin: props2.plugin, link: folderCache.banner }), /* @__PURE__ */ Cn.createElement("div", { - className: "mk-folder-outter mk-header" + className: "mk-folder-outer mk-header" }, /* @__PURE__ */ Cn.createElement("div", { className: "mk-folder-header" }, folderCache && /* @__PURE__ */ Cn.createElement("div", { @@ -41271,7 +41334,7 @@ var ContextViewComponent = (props2) => { }), /* @__PURE__ */ Cn.createElement(ContextListView, { plugin: props2.plugin })), flowOpen && /* @__PURE__ */ Cn.createElement("div", { - className: "mk-folder-outter" + className: "mk-folder-outer" }, /* @__PURE__ */ Cn.createElement("div", { className: "mk-flowspace-editor mk-foldernote", ref @@ -41293,7 +41356,7 @@ var ContextViewComponent = (props2) => { // src/components/ContextView/ContextView.tsx var CONTEXT_VIEW_TYPE = "make-folder-view"; -var ContextView = class extends import_obsidian34.ItemView { +var ContextView = class extends import_obsidian35.ItemView { constructor(leaf, plugin, viewType) { super(leaf); this.navigation = true; @@ -41353,16 +41416,16 @@ var ContextView = class extends import_obsidian34.ItemView { }; // src/components/FileView/FileView.tsx -var import_obsidian36 = require("obsidian"); +var import_obsidian37 = require("obsidian"); // src/components/FileView/FileLinkViewComponent.tsx -var import_obsidian35 = require("obsidian"); +var import_obsidian36 = require("obsidian"); var FileLinkViewComponent = (props2) => { const ref = _2(null); const [markdown, setMarkdown] = h2(""); p2(() => { if (ref.current) - import_obsidian35.MarkdownRenderer.renderMarkdown(markdown, ref.current, props2.path, null); + import_obsidian36.MarkdownRenderer.renderMarkdown(markdown, ref.current, props2.path, null); }, [markdown]); p2(() => { fetch(props2.path).then((res) => res.text()).then((f4) => setMarkdown(f4)); @@ -41377,7 +41440,7 @@ var FileLinkViewComponent = (props2) => { // src/components/FileView/FileView.tsx var FILE_VIEW_TYPE = "make-file-view"; -var FileLinkView = class extends import_obsidian36.ItemView { +var FileLinkView = class extends import_obsidian37.ItemView { constructor(leaf, plugin, viewType) { super(leaf); this.navigation = true; @@ -41434,12 +41497,12 @@ var FileLinkView = class extends import_obsidian36.ItemView { }; // src/utils/file.ts -var import_obsidian37 = require("obsidian"); +var import_obsidian38 = require("obsidian"); var tFileToAFile = (file) => { var _a2, _b2; if (!file) return null; - if (file instanceof import_obsidian37.TFile && file.stat) { + if (file instanceof import_obsidian38.TFile && file.stat) { return { isFolder: false, name: file.basename, @@ -41462,12 +41525,12 @@ var defaultNoteFolder = (plugin, activeFile2) => { }; var defaultConfigFile = async (app2) => { return await app2.vault.adapter.read( - (0, import_obsidian37.normalizePath)(app2.vault.configDir + "/app.json") + (0, import_obsidian38.normalizePath)(app2.vault.configDir + "/app.json") ); }; var fileExtensionForFile = (path) => path == null ? void 0 : path.split(".").pop(); var appendFilesMetaData = (plugin, propType, filesString) => { - const files = parseMultiString(filesString).map((f4) => plugin.index.files.get(f4)).filter((f4) => f4); + const files = parseMultiString(filesString).map((f4) => plugin.index.filesIndex.get(f4)).filter((f4) => f4); return serializeMultiString(files.map((f4) => appendFileMetaData(propType, f4))); }; var appendFileMetaData = (propType, file) => { @@ -41501,17 +41564,18 @@ var moveFile = async (folder, file) => { }; var renameFile = async (plugin, file, newName) => { const afile = tFileToAFile(file); - const folderNotePath = folderNotePathFromAFile(plugin.settings, afile); - const folderNote = getAbstractFileAtPath(app, folderNotePath); await app.fileManager.renameFile( file, file.parent.path == "/" ? newName : file.parent.path + "/" + newName ); - if (afile.isFolder && folderNote) { - await app.fileManager.renameFile( - folderNote, - folderNotePathFromAFile(plugin.settings, tFileToAFile(file)) - ); + if (afile.isFolder && plugin.settings.enableFolderNote) { + const folderNotePath = folderNotePathFromAFile(plugin.settings, afile); + const folderNote = getAbstractFileAtPath(app, folderNotePath); + if (folderNote) + await app.fileManager.renameFile( + folderNote, + folderNotePathFromAFile(plugin.settings, tFileToAFile(file)) + ); } }; function getAllAbstractFilesInVault(plugin, app2) { @@ -41519,7 +41583,7 @@ function getAllAbstractFilesInVault(plugin, app2) { const rootFolder = app2.vault.getRoot(); function recursiveFx(folder) { for (const child of folderChildren(plugin, folder)) { - if (child instanceof import_obsidian37.TFolder) { + if (child instanceof import_obsidian38.TFolder) { const childFolder = child; if (childFolder.children) recursiveFx(childFolder); @@ -41537,7 +41601,7 @@ var getFolderFromPath = (app2, path) => { const afile = getAbstractFileAtPath(app2, removeTrailingSlashFromFolder(path)); if (!afile) return null; - return afile instanceof import_obsidian37.TFolder ? afile : afile.parent; + return afile instanceof import_obsidian38.TFolder ? afile : afile.parent; }; var getFolderPathFromString = (file) => { var _a2; @@ -41566,6 +41630,14 @@ var deleteFile = (plugin, file) => { return plugin.app.vault.trash(file, false); } }; +var getFolderName = (folderPath, app2) => { + if (folderPath === "/") + return app2.vault.getName(); + const index = folderPath.lastIndexOf("/"); + if (index !== -1) + return folderPath.substring(index + 1); + return folderPath; +}; var openFile = async (file, plugin, newLeaf) => { openAFile(getAbstractFileAtPath(plugin.app, file.path), plugin, newLeaf); }; @@ -41584,7 +41656,7 @@ var openSpace = async (spaceName, plugin, newLeaf) => { app.workspace.leftSplit.collapse(); } const evt = new CustomEvent(eventTypes.activePathChange, { - detail: { path: pathByString(plugin, spaceContextPathFromName(spaceName)) } + detail: { path: pathByString(spaceContextPathFromName(spaceName)) } }); window.dispatchEvent(evt); }; @@ -41611,14 +41683,31 @@ var openURL = async (url) => { app.workspace.leftSplit.collapse(); } }; +function getAllFoldersInVault(app2) { + const folders = []; + const rootFolder = app2.vault.getRoot(); + folders.push(rootFolder); + function recursiveFx(folder) { + for (const child of folder.children) { + if (child instanceof import_obsidian38.TFolder) { + const childFolder = child; + folders.push(childFolder); + if (childFolder.children) + recursiveFx(childFolder); + } + } + } + recursiveFx(rootFolder); + return folders; +} var openAFile = async (file, plugin, newLeaf) => { - if (file instanceof import_obsidian37.TFolder) { + if (file instanceof import_obsidian38.TFolder) { openTFolder(file, plugin, newLeaf); - } else if (file instanceof import_obsidian37.TFile) { + } else if (file instanceof import_obsidian38.TFile) { openTFile(file, plugin, newLeaf); } let evt = new CustomEvent(eventTypes.activePathChange, { - detail: { path: pathByString(plugin, file.path) } + detail: { path: pathByString(file.path) } }); window.dispatchEvent(evt); }; @@ -41651,8 +41740,8 @@ var openTagContext = async (tag, plugin, newLeaf) => { if (platformIsMobile()) { app.workspace.leftSplit.collapse(); } - let evt = new CustomEvent(eventTypes.activePathChange, { - detail: { path: pathByString(plugin, tag) } + const evt = new CustomEvent(eventTypes.activePathChange, { + detail: { path: pathByString(tag) } }); window.dispatchEvent(evt); }; @@ -41680,8 +41769,8 @@ var createNewCanvasFile = async (plugin, folder, newFileName, dontOpen) => { return newFile; } await openAFile(newFile, plugin, false); - let evt = new CustomEvent(eventTypes.activePathChange, { - detail: { path: pathByString(plugin, newFile.path) } + const evt = new CustomEvent(eventTypes.activePathChange, { + detail: { path: pathByString(newFile.path) } }); window.dispatchEvent(evt); return newFile; @@ -41704,14 +41793,14 @@ var createNewMarkdownFile = async (plugin, folder, newFileName, content, dontOpe titleEl.focus(); selectElementContents(titleEl); } - let evt = new CustomEvent(eventTypes.activePathChange, { - detail: { path: pathByString(plugin, newFile.path) } + const evt = new CustomEvent(eventTypes.activePathChange, { + detail: { path: pathByString(newFile.path) } }); window.dispatchEvent(evt); return newFile; }; var platformIsMobile = () => { - return import_obsidian37.Platform.isMobile; + return import_obsidian38.Platform.isMobile; }; var newFileInFolder = async (plugin, data, dontOpen) => { await createNewMarkdownFile( @@ -41722,6 +41811,25 @@ var newFileInFolder = async (plugin, data, dontOpen) => { dontOpen ); }; +var noteToFolderNote = async (plugin, file, open) => { + const folderPath = fileNameToString(file.path); + const folder = getAbstractFileAtPath(app, folderPath); + if (folder && folder instanceof import_obsidian38.TFolder) { + if (open) { + openTFolder(folder, plugin, false); + } + return; + } + await app.vault.createFolder(folderPath); + plugin.index.filesIndex.delete(file.path); + const newFolderNotePath = folderNotePathFromAFile(plugin.settings, tFileToAFile(getAbstractFileAtPath(app, folderPath))); + if (newFolderNotePath != file.path) { + await app.vault.rename(file, newFolderNotePath); + } + if (open) { + openTFolder(getAbstractFileAtPath(app, folderPath), plugin, false); + } +}; var folderNoteCache = (plugin, file) => { if (!file.extension || file.extension.length == 0) { const folderNotePath = folderNotePathFromAFile(plugin.settings, file); @@ -41733,7 +41841,7 @@ var folderNoteCache = (plugin, file) => { } } else if (file.extension == "md") { const folderPath = getAbstractFileAtPath(app, folderPathFromFolderNoteFile(plugin.settings, file)); - if (folderPath instanceof import_obsidian37.TFolder && folderPath.name == file.name) { + if (folderPath instanceof import_obsidian38.TFolder && folderPath.name == file.name) { return { folderNotePath: file.path, folderPath: folderPath.path @@ -41743,54 +41851,141 @@ var folderNoteCache = (plugin, file) => { return null; }; -// src/utils/tree.ts -var nodeIsAncestorOfTarget = (node, target) => { - var _a2, _b2, _c2; - if (!((_a2 = node.item) == null ? void 0 : _a2.isFolder)) - return false; - return (_c2 = target.item) == null ? void 0 : _c2.path.contains(((_b2 = node.item) == null ? void 0 : _b2.path) + "/"); +// src/utils/contexts/contexts.ts +var contextEmbedStringFromContext = (context, schema) => { + if (context.type == "folder") { + if (context.contextPath == "/") + return `![![/#^${schema}]]`; + return `![![${context.contextPath}/#^${schema}]]`; + } + return `![![${context.contextPath}#^${schema}]]`; }; -var excludeVaultItemPredicate = (settings) => (f4, index, folder) => !(f4.folder != "true" && settings.hiddenExtensions.find( - (e4) => fileExtensionForFile(f4.path) == e4 -)) && !settings.hiddenFiles.find((e4) => e4 == f4.path) && (!settings.enableFolderNote || !settings.folderNoteInsideFolder && !folder.some((g4) => g4.path + ".md" == f4.path) || settings.folderNoteInsideFolder && !(f4.parent + "/" + folderPathToString(f4.parent) + ".md" == f4.path)); -var excludeFilePredicate = (plugin) => (f4, index, folder) => !(f4 instanceof import_obsidian38.TFile && plugin.settings.hiddenExtensions.find((e4) => f4.extension == e4)) && !plugin.settings.hiddenFiles.find((e4) => e4 == f4.path) && (!plugin.settings.enableFolderNote || !plugin.settings.folderNoteInsideFolder && !folder.some((g4) => g4.path + ".md" == f4.path) || plugin.settings.folderNoteInsideFolder && !(f4.parent.path + "/" + f4.parent.name + ".md" == f4.path)); -var folderChildren = (plugin, f4, exclusionList) => { - var _a2, _b2; - return (_b2 = (_a2 = f4 == null ? void 0 : f4.children) == null ? void 0 : _a2.filter(excludeFilePredicate(plugin))) != null ? _b2 : []; +var spaceContextFromSpace = (plugin, space, readOnly) => { + return { + type: "space", + sticker: "", + banner: "", + contextPath: space, + isRemote: false, + readOnly, + dbPath: getFolderPathFromString(plugin.settings.tagContextFolder) + "/" + spaceNameFromContextPath(space) + ".mdb" + }; }; -var compareByField = (field, dir) => (_a2, _b2) => { - const a5 = dir ? _a2 : _b2; - const b4 = dir ? _b2 : _a2; - if (a5[field] < b4[field]) { - return -1; +var tagContextFromTag = (plugin, tag, readOnly) => { + return { + type: "tag", + sticker: "", + banner: "", + contextPath: tag, + isRemote: false, + readOnly, + dbPath: getFolderPathFromString(plugin.settings.tagContextFolder) + "/" + tagToTagPath(tag) + ".mdb" + }; +}; +var mdbContextByDBPath = (plugin, dbPath) => { + if (dbPath.match(urlRegex)) { + return remoteContextFromURL(plugin, dbPath); } - if (a5[field] > b4[field]) { - return 1; + if (dbPath.startsWith(plugin.settings.tagContextFolder)) { + const contextPath = filePathToString(dbPath); + if (contextPath.charAt(0) == "#") + return tagContextFromTag(plugin, tagPathToTag(dbPath)); + return spaceContextFromSpace(plugin, spaceContextPathFromName(contextPath)); } - return 0; + return dbPath.endsWith((plugin == null ? void 0 : plugin.settings.folderContextFile) + ".mdb") ? folderContextFromFolder(plugin, getFolderFromPath(app, dbPath).path) : null; }; -var compareByFieldCaseInsensitive = (field, dir) => (_a2, _b2) => { - const a5 = dir ? _a2 : _b2; - const b4 = dir ? _b2 : _a2; - if (a5[field].toLowerCase() < b4[field].toLowerCase()) { - return -1; +var remoteContextFromURL = (plugin, url) => { + return { + type: "unknown", + sticker: "", + banner: "", + contextPath: url, + isRemote: true, + readOnly: true, + dbPath: url + }; +}; +var mdbContextByPath = (plugin, contextPath) => { + if (!contextPath) + return; + if (contextPath.match(urlRegex)) { + return remoteContextFromURL(plugin, contextPath); } - if (a5[field].toLowerCase() > b4[field].toLowerCase()) { - return 1; + const viewType = pathTypeByString(contextPath); + if (viewType == "space") { + return spaceContextFromSpace(plugin, contextPath); + } else if (viewType == "folder") { + return folderContextFromFolder(plugin, removeTrailingSlashFromFolder(contextPath)); + } else if (viewType == "tag") { + return tagContextFromTag(plugin, contextPath); } - return 0; + return null; }; -var internalPluginLoaded = (pluginName, app2) => { - var _a2; - return (_a2 = app2.internalPlugins.plugins[pluginName]) == null ? void 0 : _a2._loaded; +var folderContextFromFolder = (plugin, folder, readOnly) => { + return { + type: "folder", + sticker: "", + banner: "", + contextPath: folder, + isRemote: false, + readOnly, + dbPath: (folder == "/" ? "" : folder + "/") + plugin.settings.folderContextFile + ".mdb" + }; +}; +var linkContextRow = (plugin, row, fields) => { + return { + ...row, + ...fields.filter((f4) => f4.type == "fileprop").reduce((p3, c4) => { + const { field, property } = parsePropString(c4.value); + const col = fields.find((f4) => f4.name == field); + if (!col || !property) { + return p3; + } + if (col.type == "file" || col.type == "link") { + return { + ...p3, + [c4.name]: appendFilesMetaData(plugin, property, row[col.name]) + }; + } + if (col.type.includes("context")) { + const context = col.value; + const contextCache = plugin.index.contextsIndex.get(context); + if (contextCache) { + return { + ...p3, + [c4.name]: linkContextProp( + property, + row[col.name], + contextCache.rows + ) + }; + } + } + return p3; + }, {}) + }; +}; +var linkContextProp = (propType, rows, contextTableRows) => { + const contextRows = contextTableRows.filter( + (f4) => parseMultiString(rows).contains(f4.File) + ); + return serializeMultiString(uniq(contextRows.map((f4) => f4[propType]).filter((f4) => f4))); +}; + +// src/utils/contexts/mdtable.ts +var createTable2 = (object, columns) => { + const columnNames = columns.map((f4) => f4.name); + const base = "|"; + let outputString = base + columnNames.join(base) + "|\n"; + columns.forEach((f4) => { + outputString += base + "----"; + }); + outputString += base + "\n"; + object.forEach((row) => { + outputString += columnNames.map((c4) => base + row[c4]).join("") + "|\n"; + }); + return outputString; }; -function selectElementContents(el) { - var range = document.createRange(); - range.selectNodeContents(el); - var sel = window.getSelection(); - sel.removeAllRanges(); - sel.addRange(range); -} // src/cm-extensions/flowEditor/flowEditor.tsx var toggleFlowEditor = import_state6.Annotation.define(); @@ -41904,12 +42099,12 @@ var flowEditorInfo = import_state6.StateField.define({ return news; }; for (let match2 of str.matchAll(/(?:!\[!\[|!!\[\[)([^\]]+)\]\]/g)) { - const link2 = match2[1]; - const existingLinks = previous.filter((f4) => f4.link == link2); - const offset = usedContainers.filter((f4) => f4 == link2).length; + const link = match2[1]; + const existingLinks = previous.filter((f4) => f4.link == link); + const offset = usedContainers.filter((f4) => f4 == link).length; const existingInfo = existingLinks[offset]; const id2 = existingInfo ? existingInfo.id : genId(); - usedContainers.push(link2); + usedContainers.push(link); const info = { id: id2, link: match2[1], @@ -41924,12 +42119,12 @@ var flowEditorInfo = import_state6.StateField.define({ } for (let match2 of str.matchAll(/\[\[([^\]]+)\]\]/g)) { if (str.charAt(match2.index - 1) != "!") { - const link2 = match2[1]; - const existingLinks = previous.filter((f4) => f4.link == link2); - const offset = usedContainers.filter((f4) => f4 == link2).length; + const link = match2[1]; + const existingLinks = previous.filter((f4) => f4.link == link); + const offset = usedContainers.filter((f4) => f4 == link).length; const existingInfo = existingLinks[offset]; const id2 = existingInfo ? existingInfo.id : genId(); - usedContainers.push(link2); + usedContainers.push(link); const info = { id: id2, link: match2[1], @@ -41942,12 +42137,12 @@ var flowEditorInfo = import_state6.StateField.define({ }; newValues.push(info); } else if (str.charAt(match2.index - 2) != "!") { - const link2 = match2[1]; - const existingLinks = previous.filter((f4) => f4.link == link2); - const offset = usedContainers.filter((f4) => f4 == link2).length; + const link = match2[1]; + const existingLinks = previous.filter((f4) => f4.link == link); + const offset = usedContainers.filter((f4) => f4 == link).length; const existingInfo = existingLinks[offset]; const id2 = existingInfo ? existingInfo.id : genId(); - usedContainers.push(link2); + usedContainers.push(link); const info = { id: id2, link: match2[1], @@ -41965,7 +42160,7 @@ var flowEditorInfo = import_state6.StateField.define({ return newValues; } }); -var flowEditorRangeset = (state) => { +var flowEditorRangeset = (state, plugin) => { let builder = new import_state6.RangeSetBuilder(); const infoFields = state.field(flowEditorInfo); for (let info of infoFields) { @@ -41974,7 +42169,7 @@ var flowEditorRangeset = (state) => { if (expandedState == 2) { if (embedType == 1) { if (!(state.selection.main.from == from - 4 && state.selection.main.to == to + 2 || state.selection.main.from >= from - 3 && state.selection.main.to <= to + 1)) { - builder.add(from - 4, from - 3, flowEditorSelector(info)); + builder.add(from - 4, from - 3, flowEditorSelector(info, plugin)); if (lineFix) { builder.add(from - 3, to + 2, flowEditorWidgetDecoration(info)); } else { @@ -41989,12 +42184,12 @@ var flowEditorRangeset = (state) => { const dec = builder.finish(); return dec; }; -var flowEditorField = import_state6.StateField.define({ +var flowEditorField = (plugin) => import_state6.StateField.define({ create(state) { - return flowEditorRangeset(state); + return flowEditorRangeset(state, plugin); }, update(value, tr) { - return flowEditorRangeset(tr.state); + return flowEditorRangeset(tr.state, plugin); }, provide: (f4) => import_view4.EditorView.decorations.from(f4) }); @@ -42021,10 +42216,11 @@ var FlowEditorWidget = class extends import_view4.WidgetType { } }; var FlowEditorSelector = class extends import_view4.WidgetType { - constructor(info) { + constructor(info, plugin) { super(); this.info = info; this.flowInfo = info; + this.plugin = plugin; } eq(other) { return false; @@ -42033,38 +42229,60 @@ var FlowEditorSelector = class extends import_view4.WidgetType { const div = document.createElement("div"); div.toggleClass("mk-floweditor-selector", true); const reactEl = createRoot(div); - const type = this.info.link.contains("/#^") ? "table" : "file"; - reactEl.render( - /* @__PURE__ */ Cn.createElement(FlowEditorHover, { - toggle: true, - type, - toggleState: true, - cutTable: () => { - navigator.clipboard.writeText(`![![${this.info.link}]]`); - view.dispatch({ - changes: { from: this.info.from - 4, to: this.info.to + 2 } - }); - }, - deleteTable: () => { - view.dispatch({ - changes: { from: this.info.from - 4, to: this.info.to + 2 } - }); - }, - toggleFlow: () => { - view.dispatch({ - changes: { from: this.info.from - 4, to: this.info.from - 3 } - }); - }, - openLink: () => { - openFileFlowEditor(this.flowInfo.link, "/"); - } - }) - ); + if (this.info.link && view.state.field(import_obsidian39.editorInfoField)) { + const infoField = view.state.field(import_obsidian39.editorInfoField); + const file = infoField.file; + const path = pathByString(this.info.link, file.path); + reactEl.render( + /* @__PURE__ */ Cn.createElement(FlowEditorHover, { + toggle: true, + path: path.path, + type: path.type, + toggleState: true, + convertTable: () => { + const context = mdbContextByPath(this.plugin, path.path); + getMDBTable( + this.plugin, + context, + path.ref.substring(1, path.ref.length) + ).then((mdbTable) => { + const markdown = createTable2(mdbTable.rows, mdbTable.cols); + view.dispatch({ + changes: { + from: this.info.from - 4, + to: this.info.to + 2, + insert: markdown + } + }); + }); + }, + cutTable: () => { + navigator.clipboard.writeText(`![![${this.info.link}]]`); + view.dispatch({ + changes: { from: this.info.from - 4, to: this.info.to + 2 } + }); + }, + deleteTable: () => { + view.dispatch({ + changes: { from: this.info.from - 4, to: this.info.to + 2 } + }); + }, + toggleFlow: () => { + view.dispatch({ + changes: { from: this.info.from - 4, to: this.info.from - 3 } + }); + }, + openLink: () => { + openFileFlowEditor(this.flowInfo.link, "/"); + } + }) + ); + } return div; } }; -var flowEditorSelector = (info) => import_view4.Decoration.replace({ - widget: new FlowEditorSelector(info), +var flowEditorSelector = (info, plugin) => import_view4.Decoration.replace({ + widget: new FlowEditorSelector(info, plugin), inclusive: true, block: false }); @@ -42625,12 +42843,12 @@ var BacklinkItem = (props2) => { p2(() => { var _a2, _b2; const fCache = app.metadataCache.getCache(props2.path); - const link2 = [...(_a2 = fCache.links) != null ? _a2 : [], ...(_b2 = fCache.embeds) != null ? _b2 : []].find( + const link = [...(_a2 = fCache.links) != null ? _a2 : [], ...(_b2 = fCache.embeds) != null ? _b2 : []].find( (f4) => props2.source.includes(f4.displayText) ); - if (link2) { + if (link) { const block2 = fCache.sections.find( - (f4) => f4.position.start.offset <= link2.position.start.offset && f4.position.end.offset >= link2.position.end.offset + (f4) => f4.position.start.offset <= link.position.start.offset && f4.position.end.offset >= link.position.end.offset ); setBlock([ Math.max(1, block2.position.start.line), @@ -42723,7 +42941,7 @@ var Backlinks = (props2) => { }; // src/components/FileContextView/InlineFileContextView.tsx -var import_obsidian41 = require("obsidian"); +var import_obsidian42 = require("obsidian"); // src/components/FileContextView/FileContextList.tsx var FileContextList = (props2) => { @@ -42881,9 +43099,9 @@ var FileContextList = (props2) => { }; // src/components/ui/menus/fmMenu.tsx -var import_obsidian39 = require("obsidian"); +var import_obsidian40 = require("obsidian"); var showFMMenu = (plugin, position, property, deleteProperty, syncProperty, renameProperty, changeType) => { - const menu = new import_obsidian39.Menu(); + const menu = new import_obsidian40.Menu(); menu.setUseNativeMenu(false); menu.addItem((menuItem) => { var _a2; @@ -42923,8 +43141,8 @@ var showFMMenu = (plugin, position, property, deleteProperty, syncProperty, rena }; // src/components/ui/modals/moveMetadataModal.tsx -var import_obsidian40 = require("obsidian"); -var MovePropertyModal = class extends import_obsidian40.Modal { +var import_obsidian41 = require("obsidian"); +var MovePropertyModal = class extends import_obsidian41.Modal { constructor(plugin, syncProperty, property, file) { super(plugin.app); this.plugin = plugin; @@ -43020,10 +43238,10 @@ var FrontmatterView = (props2) => { const [cols, setCols] = h2([]); const refreshData = async () => { var _a2; - const fileContexts = (_a2 = props2.plugin.index.contexts.get(path)) != null ? _a2 : /* @__PURE__ */ new Set(); + const fileContexts = (_a2 = props2.plugin.index.contextsMap.get(path)) != null ? _a2 : /* @__PURE__ */ new Set(); const columns = [...fileContexts].map((f4) => { var _a3, _b2; - return (_b2 = (_a3 = props2.plugin.index.contextsCache.get(f4)) == null ? void 0 : _a3.cols) != null ? _b2 : []; + return (_b2 = (_a3 = props2.plugin.index.contextsIndex.get(f4)) == null ? void 0 : _a3.cols) != null ? _b2 : []; }).reduce((p3, c4) => [...p3, ...c4], []); const newCols = []; const newValues = {}; @@ -43203,9 +43421,9 @@ var InlineFileContextView = (props2) => { const getFileCache = (file2) => { if (!file2 || file2.path == "/") return null; - const cache = props2.plugin.index.files.get(file2.path); + const cache = props2.plugin.index.filesIndex.get(file2.path); if (!cache) { - return props2.plugin.index.files.get( + return props2.plugin.index.filesIndex.get( folderPathFromFolderNoteFile(props2.plugin.settings, tFileToAFile(file2)) ); } @@ -43222,18 +43440,18 @@ var InlineFileContextView = (props2) => { } return fileCache.path; }, [fileCache]); - const showHeader = props2.showHeader && (fileCache == null ? void 0 : fileCache.folderNote) == null; + const showHeader = props2.showHeader; const [collapsed, setCollapsed] = h2( !showHeader ? false : !props2.plugin.settings.inlineContextExpanded ); const tags = (_b2 = fileCache == null ? void 0 : fileCache.tags) != null ? _b2 : []; const contexts = F2(() => { var _a3; - return ((_a3 = fileCache == null ? void 0 : fileCache.contexts) != null ? _a3 : []).map((f4) => props2.plugin.index.contextsCache.get(f4)).filter((f4) => f4).map((f4) => f4.info); + return ((_a3 = fileCache == null ? void 0 : fileCache.contexts) != null ? _a3 : []).map((f4) => props2.plugin.index.contextsIndex.get(f4)).filter((f4) => f4).map((f4) => f4.info); }, [fileCache]); const banner = fileCache == null ? void 0 : fileCache.banner; p2(() => { - props2.plugin.settings.inlineBacklinksExpanded = !collapsed; + props2.plugin.settings.inlineContextExpanded = !collapsed; props2.plugin.saveSettings(); }, [collapsed]); const fileNameRef = _2(null); @@ -43248,6 +43466,9 @@ var InlineFileContextView = (props2) => { if (evt.detail.type == "file" && evt.detail.name == file.path) { refreshFile(); } + if (evt.detail.type == "context" && contexts.some((f4) => f4.contextPath == evt.detail.name)) { + refreshFile(); + } }; p2(() => { window.addEventListener(eventTypes.spacesChange, cacheChanged); @@ -43289,11 +43510,11 @@ var InlineFileContextView = (props2) => { ); }; const addTag2 = (tag) => { - if (file instanceof import_obsidian41.TFile && file.extension == "md") + if (file instanceof import_obsidian42.TFile && file.extension == "md") addTagToNote(tag, file); }; const removeTag = (tag) => { - if (file instanceof import_obsidian41.TFile && file.extension == "md") + if (file instanceof import_obsidian42.TFile && file.extension == "md") removeTagFromFile(tag, file); }; const saveField = (source, field) => { @@ -43311,7 +43532,7 @@ var InlineFileContextView = (props2) => { if (source == "") { insertContextColumn( props2.plugin, - props2.plugin.index.contextsCache.get(fileCache.parent).info, + mdbContextByPath(props2.plugin, fileCache.parent), field ); return; @@ -43336,7 +43557,7 @@ var InlineFileContextView = (props2) => { ); }; const onBlur = (e4) => { - const newValue = e4.target.innerText; + const newValue = e4.target.innerHTML; if (newValue != fileNameToString(file.name)) { renameFile(props2.plugin, file, newValue + ".md"); } @@ -43348,7 +43569,7 @@ var InlineFileContextView = (props2) => { e4.stopPropagation(); }; const onKeyDown = (e4) => { - var _a3; + var _a3, _b3; e4.stopPropagation(); if (e4.key == "a" && e4.metaKey) { e4.preventDefault(); @@ -43364,8 +43585,9 @@ var InlineFileContextView = (props2) => { e4.preventDefault(); } if (e4.key == "Escape") { - fileNameRef.current.innerText = fileNameToString(file.name); e4.target.blur(); + (_b3 = props2.editorView) == null ? void 0 : _b3.focus(); + e4.preventDefault(); } }; y2(() => { @@ -43388,7 +43610,7 @@ var InlineFileContextView = (props2) => { (_a4 = fileNameRef.current) == null ? void 0 : _a4.removeEventListener("paste", pasteEvent); }; }, [fileNameRef]); - return /* @__PURE__ */ Cn.createElement(Cn.Fragment, null, showHeader && /* @__PURE__ */ Cn.createElement(NoteBannerView, { + return /* @__PURE__ */ Cn.createElement(Cn.Fragment, null, props2.showBanner && /* @__PURE__ */ Cn.createElement(NoteBannerView, { plugin: props2.plugin, link: banner, file: props2.file @@ -43397,7 +43619,7 @@ var InlineFileContextView = (props2) => { }, /* @__PURE__ */ Cn.createElement("div", { className: `mk-spacer`, style: { - "--header-height": showHeader && banner ? ((platformIsMobile() ? 1 : 0) * 26 + 138 + (!props2.plugin.settings.spacesStickers || props2.plugin.settings.inlineContextNameLayout == "horizontal" ? 1 : 0) * 50).toString() + "px" : 0 + "--header-height": props2.showBanner && banner ? ((platformIsMobile() ? 1 : 0) * 26 + 138 + (!props2.plugin.settings.spacesStickers || props2.plugin.settings.inlineContextNameLayout == "horizontal" ? 1 : 0) * 50).toString() + "px" : 0 }, onContextMenu: (e4) => e4.preventDefault() }), /* @__PURE__ */ Cn.createElement("div", { @@ -43413,8 +43635,11 @@ var InlineFileContextView = (props2) => { onDrop: (e4) => e4.preventDefault(), onKeyDown, onKeyPress, - onKeyUp - }, fileNameToString(file.name))), /* @__PURE__ */ Cn.createElement("div", { + onKeyUp, + dangerouslySetInnerHTML: { + __html: fileNameToString(file.name) + } + })), /* @__PURE__ */ Cn.createElement("div", { className: `mk-collapse mk-icon-xsmall mk-file-context-collapse ${collapsed ? "mk-collapsed" : ""}`, dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-collapse"] @@ -43435,7 +43660,7 @@ var InlineFileContextView = (props2) => { }, /* @__PURE__ */ Cn.createElement("div", { className: "mk-icon-xsmall", dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-tags"] } - }), platformIsMobile() ? "Tag" : "Add Tag"), props2.showHeader ? /* @__PURE__ */ Cn.createElement("button", { + }), platformIsMobile() ? "Tag" : "Add Tag"), props2.showBanner || props2.isFolderNote ? /* @__PURE__ */ Cn.createElement("button", { onClick: (e4) => changeCover(e4) }, /* @__PURE__ */ Cn.createElement("div", { className: "mk-icon-xsmall", @@ -43457,7 +43682,7 @@ var InlineFileContextView = (props2) => { metadataPath: metadataFilePath, folder: folderPath, tags, - excludeKeys: showHeader || (fileCache == null ? void 0 : fileCache.folderNote) ? FMMetadataKeys : [], + excludeKeys: showHeader || props2.isFolderNote ? FMMetadataKeys : [], editable: props2.editable }), contexts.map((context, i4) => /* @__PURE__ */ Cn.createElement(MDBProvider, { key: i4, @@ -43474,7 +43699,7 @@ var InlineFileContextView = (props2) => { }; // src/cm-extensions/inlineContext/inlineContext.tsx -var import_obsidian42 = require("obsidian"); +var import_obsidian43 = require("obsidian"); var InlineContextWidget = class extends import_view7.WidgetType { constructor(plugin, file, contentEl) { super(); @@ -43496,12 +43721,15 @@ var InlineContextWidget = class extends import_view7.WidgetType { container.toggleClass("cm-line", true); const anchor = createRoot(container); const flowType = view.state.field(flowTypeStateField, false); + const isFolderNote2 = flowType == "foldernote"; anchor.render( /* @__PURE__ */ Cn.createElement(Cn.Fragment, null, /* @__PURE__ */ Cn.createElement(InlineFileContextView, { plugin: this.plugin, file: this.file, editorView: view, - showHeader: true, + showHeader: !isFolderNote2, + showBanner: !isFolderNote2, + isFolderNote: isFolderNote2, editable: true })) ); @@ -43564,9 +43792,9 @@ var StatefulDecorationSet = class { var _a2; if (!show) return import_view7.Decoration.none; - if (!state.field(import_obsidian42.editorInfoField)) + if (!state.field(import_obsidian43.editorInfoField)) return null; - const infoField = state.field(import_obsidian42.editorInfoField); + const infoField = state.field(import_obsidian43.editorInfoField); if (!((_a2 = infoField.editor) == null ? void 0 : _a2.cm)) return null; const file = infoField.file; @@ -43626,7 +43854,7 @@ var frontmatterHider = (plugin) => import_state10.StateField.define({ } } }); - const livePreview = tr.state.field(import_obsidian42.editorLivePreviewField); + const livePreview = tr.state.field(import_obsidian43.editorLivePreviewField); if (fmEnd > 0 && fmEnd < tr.state.doc.length && plugin.settings.hideFrontmatter && livePreview) { builder.add( fmStart, @@ -43646,10 +43874,10 @@ var headerViewPlugin = (plugin) => import_view7.ViewPlugin.fromClass( this.flowTypeState = view.state.field(flowTypeStateField, false); if (this.flowTypeState == "doc" || this.flowTypeState == "foldernote" || !this.flowTypeState) this.statefulDecorationsSet.updateAsyncDecorations(view.state, true); - this.livePreview = view.state.field(import_obsidian42.editorLivePreviewField, false); + this.livePreview = view.state.field(import_obsidian43.editorLivePreviewField, false); } showHeader(view) { - if ((view.state.field(flowTypeStateField, false) == "doc" || view.state.field(flowTypeStateField, false) == "foldernote" || view.state.field(flowTypeStateField, false) == null) && view.state.field(import_obsidian42.editorLivePreviewField, false)) { + if ((view.state.field(flowTypeStateField, false) == "doc" || view.state.field(flowTypeStateField, false) == "foldernote" || view.state.field(flowTypeStateField, false) == null) && view.state.field(import_obsidian43.editorLivePreviewField, false)) { if (!this.headerEnabled) { this.statefulDecorationsSet.updateAsyncDecorations( view.state, @@ -43664,10 +43892,10 @@ var headerViewPlugin = (plugin) => import_view7.ViewPlugin.fromClass( } update(update) { var _a2, _b2; - const infoField = update.state.field(import_obsidian42.editorInfoField, false); - if (update.docChanged || update.state.field(flowTypeStateField, false) != this.flowTypeState || this.filePath != ((_a2 = infoField.file) == null ? void 0 : _a2.path) || this.livePreview != update.state.field(import_obsidian42.editorLivePreviewField, false)) { + const infoField = update.state.field(import_obsidian43.editorInfoField, false); + if (update.docChanged || update.state.field(flowTypeStateField, false) != this.flowTypeState || this.filePath != ((_a2 = infoField.file) == null ? void 0 : _a2.path) || this.livePreview != update.state.field(import_obsidian43.editorLivePreviewField, false)) { this.filePath = (_b2 = infoField.file) == null ? void 0 : _b2.path; - this.livePreview = update.state.field(import_obsidian42.editorLivePreviewField, false); + this.livePreview = update.state.field(import_obsidian43.editorLivePreviewField, false); this.flowTypeState = update.state.field(flowTypeStateField, false); this.showHeader(update.view); } @@ -43725,7 +43953,7 @@ var cmExtensions = (plugin, mobile) => { flowTypeStateField, editBlockExtensions(), preloadFlowEditor, - flowEditorField, + flowEditorField(plugin), flowEditorInfo, flowIDStateField, flowViewUpdates @@ -43741,7 +43969,7 @@ var cmExtensions = (plugin, mobile) => { }; // src/components/MakeMenu/MakeMenu.tsx -var import_obsidian43 = require("obsidian"); +var import_obsidian44 = require("obsidian"); // src/components/MakeMenu/commands/default.ts var default_default2 = [ @@ -43846,7 +44074,7 @@ function resolveCommands(plugin) { } // src/components/MakeMenu/MakeMenu.tsx -var MakeMenu = class extends import_obsidian43.EditorSuggest { +var MakeMenu = class extends import_obsidian44.EditorSuggest { constructor(app2, plugin) { super(app2); this.inCmd = false; @@ -43901,7 +44129,7 @@ var MakeMenu = class extends import_obsidian43.EditorSuggest { if (cmd.label === i18n_default.commandsSuggest.noResult) return; if (cmd.value == "table") { - this.plugin.createTable(this.file.parent.path).then((f4) => { + this.plugin.createInlineTable(this.file.parent.path).then((f4) => { this.context.editor.replaceRange( contextEmbedStringFromContext( folderContextFromFolder(this.plugin, this.file.parent.path), @@ -43939,8 +44167,8 @@ var MakeMenu = class extends import_obsidian43.EditorSuggest { }; // src/components/StickerMenu/StickerMenu.tsx -var import_obsidian44 = require("obsidian"); -var StickerMenu = class extends import_obsidian44.EditorSuggest { +var import_obsidian45 = require("obsidian"); +var StickerMenu = class extends import_obsidian45.EditorSuggest { constructor(app2, plugin) { super(app2); this.inCmd = false; @@ -44037,12 +44265,12 @@ var replaceAllTables = (plugin, el, ctx) => { for (let match2 of element.textContent.matchAll( /(?:!\[!\[|!!\[\[)([^\]]+)\]\]/g )) { - const link2 = match2[1]; + const link = match2[1]; const reactEl = createRoot(element.parentElement); reactEl.render( /* @__PURE__ */ Cn.createElement(FlowView, { plugin, - path: link2, + path: link, load: true }) ); @@ -44093,48 +44321,45 @@ var replaceAllEmbed = (el, ctx) => { /* @__PURE__ */ Cn.createElement(FlowEditorHover, { toggle: true, type: "file", + path: ctx.sourcePath, toggleState: false, toggleFlow: (e4) => { const cm = getCMFromElement(dom); const pos = cm == null ? void 0 : cm.posAtDOM(dom); if (!cm) return; - iterateTreeInSelection( - { from: pos - 3, to: pos + 4 }, - cm.state, - { - enter: (node) => { - if (node.name.contains("hmd-internal-link")) { - if (cm.state.sliceDoc(node.from - 4, node.from - 3) != "!") { - if (cm.state.sliceDoc(node.to + 2, node.to + 3) != cm.state.lineBreak) { - cm.dispatch({ - changes: [ - { - from: node.from - 3, - to: node.from - 3, - insert: "!" - }, - { - from: node.to + 2, - to: node.to + 2, - insert: cm.state.lineBreak - } - ] - }); - } else { - cm.dispatch({ - changes: { + iterateTreeInSelection({ from: pos - 3, to: pos + 4 }, cm.state, { + enter: (node) => { + if (node.name.contains("hmd-internal-link")) { + if (cm.state.sliceDoc(node.from - 4, node.from - 3) != "!") { + if (cm.state.sliceDoc(node.to + 2, node.to + 3) != cm.state.lineBreak) { + cm.dispatch({ + changes: [ + { from: node.from - 3, to: node.from - 3, insert: "!" + }, + { + from: node.to + 2, + to: node.to + 2, + insert: cm.state.lineBreak } - }); - } + ] + }); + } else { + cm.dispatch({ + changes: { + from: node.from - 3, + to: node.from - 3, + insert: "!" + } + }); } } } } - ); + }); e4.stopPropagation(); }, openLink: (e4) => { @@ -49244,8 +49469,8 @@ var Recoil_index_34 = Recoil_index.setBatcher; var Recoil_index_35 = Recoil_index.snapshot_UNSTABLE; // src/components/ui/modals/hiddenFilesModal.tsx -var import_obsidian45 = require("obsidian"); -var HiddenItemsModal = class extends import_obsidian45.Modal { +var import_obsidian46 = require("obsidian"); +var HiddenItemsModal = class extends import_obsidian46.Modal { constructor(plugin) { super(plugin.app); this.plugin = plugin; @@ -49384,7 +49609,7 @@ var HiddenFiles = (props2) => { }; // src/components/Spaces/MainMenu.tsx -var import_obsidian46 = require("obsidian"); +var import_obsidian47 = require("obsidian"); // src/recoil/pluginState.ts var activeFile = Recoil_index_4({ @@ -49446,7 +49671,7 @@ var MainMenu = (props2) => { const activeSpace = spaces2.find((f4) => f4.name == activeViewSpace2); const ref = _2(); const toggleSections = (collapse) => { - const newSections = collapse ? [] : ["/", ...spaces2.map((f4) => f4.name)]; + const newSections = collapse ? [] : spaces2.map((f4) => f4.name); plugin.settings.expandedSpaces = newSections; plugin.saveSettings(); }; @@ -49481,7 +49706,7 @@ var MainMenu = (props2) => { }; const showMenu = (e4) => { const { spaceActive, leafs } = refreshLeafs(); - const menu = new import_obsidian46.Menu(); + const menu = new import_obsidian47.Menu(); !spaceActive && menu.addItem((menuItem) => { menuItem.setIcon("lucide-arrow-left"); menuItem.setTitle(i18n_default.menu.backToSpace); @@ -49566,7 +49791,7 @@ var MainMenu = (props2) => { menuItem.setIcon("sync"); menuItem.setTitle("Reload Spaces"); menuItem.onClick((ev) => { - plugin.index.loadSpacesDB(); + plugin.index.loadSpacesDatabaseFromDisk(); }); }); menu.addItem((menuItem) => { @@ -50039,7 +50264,6 @@ var import_classnames7 = __toESM(require_classnames()); // src/components/Spaces/TreeView/SectionView.tsx var import_classnames6 = __toESM(require_classnames()); -var import_obsidian47 = require("obsidian"); var SectionItem = k3( ({ childCount, @@ -50062,9 +50286,9 @@ var SectionItem = k3( }, ref) => { var _a2, _b2; const [activeFile2, setActiveFile] = Recoil_index_14(activeFile); - const space = (_a2 = plugin.index.spacesCache.get(data.space)) == null ? void 0 : _a2.space; + const space = (_a2 = plugin.index.spacesIndex.get(data.space)) == null ? void 0 : _a2.space; const triggerMenu = (e4) => { - data.space == "/" ? triggerVaultMenu(e4) : triggerSectionMenu( + triggerSectionMenu( plugin, space, [...plugin.index.allSpaces()], @@ -50072,138 +50296,6 @@ var SectionItem = k3( activeFile2 ); }; - const triggerVaultMenu = (e4) => { - const fileMenu = new import_obsidian47.Menu(); - fileMenu.addItem((menuItem) => { - menuItem.setIcon("edit"); - menuItem.setTitle(i18n_default.buttons.createNote); - menuItem.onClick((ev) => { - newFileInSpace(plugin, space, activeFile2); - }); - }); - fileMenu.addItem((menuItem) => { - menuItem.setIcon("layout-dashboard"); - menuItem.setTitle(i18n_default.buttons.createCanvas); - menuItem.onClick((ev) => { - newFileInVault(plugin, activeFile2, true); - }); - }); - fileMenu.addItem((menuItem) => { - menuItem.setIcon("folder-plus"); - menuItem.setTitle(i18n_default.buttons.createFolder); - menuItem.onClick((ev) => { - newFolderInVault(plugin, activeFile2); - }); - }); - fileMenu.addSeparator(); - fileMenu.addItem((menuItem) => { - menuItem.setTitle(i18n_default.menu.collapseAll); - menuItem.setIcon("lucide-chevrons-down-up"); - menuItem.onClick((ev) => { - plugin.settings.expandedFolders = { - ...plugin.settings.expandedFolders, - "/": [] - }; - plugin.saveSettings(); - }); - }); - fileMenu.addSeparator(); - fileMenu.addItem((menuItem) => { - menuItem.setTitle(i18n_default.menu.sortBy); - menuItem.setIcon("sort-desc"); - menuItem.onClick((ev) => { - const sortMenu = new import_obsidian47.Menu(); - sortMenu.addItem((menuItem2) => { - menuItem2.setTitle(i18n_default.menu.customSort); - menuItem2.setChecked(plugin.settings.vaultSort[0] == "rank"); - menuItem2.onClick((ev2) => { - plugin.settings.vaultSort = ["rank", true]; - plugin.saveSettings(); - }); - }); - sortMenu.addSeparator(); - sortMenu.addItem((menuItem2) => { - menuItem2.setTitle(i18n_default.menu.fileNameSortAlphaAsc); - menuItem2.setChecked( - plugin.settings.vaultSort[0] == "path" && plugin.settings.vaultSort[1] == true - ); - menuItem2.onClick((ev2) => { - plugin.settings.vaultSort = ["path", true]; - plugin.saveSettings(); - }); - }); - sortMenu.addItem((menuItem2) => { - menuItem2.setTitle(i18n_default.menu.fileNameSortAlphaDesc); - menuItem2.setChecked( - plugin.settings.vaultSort[0] == "path" && plugin.settings.vaultSort[1] == false - ); - menuItem2.onClick((ev2) => { - plugin.settings.vaultSort = ["path", false]; - plugin.saveSettings(); - }); - }); - sortMenu.addSeparator(); - sortMenu.addItem((menuItem2) => { - menuItem2.setTitle(i18n_default.menu.createdTimeSortAsc); - menuItem2.setChecked( - plugin.settings.vaultSort[0] == "ctime" && plugin.settings.vaultSort[1] == false - ); - menuItem2.onClick((ev2) => { - plugin.settings.vaultSort = ["ctime", false]; - plugin.saveSettings(); - }); - }); - sortMenu.addItem((menuItem2) => { - menuItem2.setTitle(i18n_default.menu.createdTimeSortDesc); - menuItem2.setChecked( - plugin.settings.vaultSort[0] == "ctime" && plugin.settings.vaultSort[1] == true - ); - menuItem2.onClick((ev2) => { - plugin.settings.vaultSort = ["ctime", true]; - plugin.saveSettings(); - }); - }); - sortMenu.addItem((menuItem2) => { - menuItem2.setTitle(i18n_default.menu.modifiedTimeSortAsc); - menuItem2.setChecked( - plugin.settings.vaultSort[0] == "mtime" && plugin.settings.vaultSort[1] == false - ); - menuItem2.onClick((ev2) => { - plugin.settings.vaultSort = ["mtime", false]; - plugin.saveSettings(); - }); - }); - sortMenu.addItem((menuItem2) => { - menuItem2.setTitle(i18n_default.menu.modifiedTimeSortDesc); - menuItem2.setChecked( - plugin.settings.vaultSort[0] == "mtime" && plugin.settings.vaultSort[1] == true - ); - menuItem2.onClick((ev2) => { - plugin.settings.vaultSort = ["mtime", true]; - plugin.saveSettings(); - }); - }); - const offset = e4.target.getBoundingClientRect(); - if (isMouseEvent(e4)) { - sortMenu.showAtPosition({ x: offset.left, y: offset.top + 30 }); - } else { - sortMenu.showAtPosition({ - x: e4.nativeEvent.locationX, - y: e4.nativeEvent.locationY - }); - } - }); - }); - if (isMouseEvent(e4)) { - fileMenu.showAtPosition({ x: e4.pageX, y: e4.pageY }); - } else { - fileMenu.showAtPosition({ - x: e4.nativeEvent.locationX, - y: e4.nativeEvent.locationY - }); - } - return false; - }; return /* @__PURE__ */ Cn.createElement(Cn.Fragment, null, /* @__PURE__ */ Cn.createElement("div", { className: (0, import_classnames6.default)( "mk-tree-wrapper", @@ -50237,7 +50329,7 @@ var SectionItem = k3( "nav-folder-title", active && "is-selected" ), - "data-path": data.id == "/" ? plugin.app.vault.getName() : data.space, + "data-path": data.space, ref, ...handleProps }, /* @__PURE__ */ Cn.createElement("div", { @@ -50249,7 +50341,7 @@ var SectionItem = k3( onClick: () => { if (!space) return; - let vaultChangeModal = new stickerModal( + const vaultChangeModal = new stickerModal( plugin.app, (emoji) => saveSpaceIcon(plugin, space.name, emoji) ); @@ -50258,7 +50350,7 @@ var SectionItem = k3( })), /* @__PURE__ */ Cn.createElement("div", { className: "mk-tree-text", onClick: (e4) => space ? openSpace(space.name, plugin, false) : {} - }, data.id == "/" ? plugin.app.vault.getName() : data.space), /* @__PURE__ */ Cn.createElement("div", { + }, data.space), /* @__PURE__ */ Cn.createElement("div", { className: "mk-folder-buttons" }, /* @__PURE__ */ Cn.createElement("button", { "aria-label": i18n_default.buttons.moreOptions, @@ -50269,10 +50361,10 @@ var SectionItem = k3( dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-options"] } - }), data.space == "/" || ((_b2 = space == null ? void 0 : space.def) == null ? void 0 : _b2.type) == "focus" ? /* @__PURE__ */ Cn.createElement("button", { + }), ((_b2 = space == null ? void 0 : space.def) == null ? void 0 : _b2.type) == "focus" ? /* @__PURE__ */ Cn.createElement("button", { "aria-label": i18n_default.buttons.newNote, onClick: () => { - data.space == "/" ? newFileInVault(plugin, activeFile2) : newFileInSpace(plugin, space, activeFile2); + newFileInSpace(plugin, space, activeFile2); }, dangerouslySetInnerHTML: { __html: uiIconSet["mk-ui-plus"] @@ -50359,6 +50451,7 @@ var TreeItem = k3( indicator, collapsed, selected, + highlighted, onCollapse, onSelectRange, wrapperRef, @@ -50387,7 +50480,7 @@ var TreeItem = k3( plugin, e4.ctrlKey || e4.metaKey ); - setActiveFile(pathByString(plugin, file.item.path)); + setActiveFile(pathByString(file.item.path)); setSelectedFiles([file]); } } else { @@ -50396,7 +50489,7 @@ var TreeItem = k3( plugin, e4.ctrlKey || e4.metaKey ); - setActiveFile(pathByString(plugin, file.item.path)); + setActiveFile(pathByString(file.item.path)); setSelectedFiles([file]); } }; @@ -50457,7 +50550,7 @@ var TreeItem = k3( }; const updateFileCache = (evt) => { if (evt.detail.type == "file" && evt.detail.name == data.item.path) - setFileCache(plugin.index.files.get(data.item.path)); + setFileCache(plugin.index.filesIndex.get(data.item.path)); }; p2(() => { window.addEventListener(eventTypes.spacesChange, updateFileCache); @@ -50520,7 +50613,8 @@ var TreeItem = k3( fileCache.isFolder ? "nav-folder-title" : "nav-file-title", fileCache.folderNote ? "mk-folder-is-folder-note" : "", active ? "is-active" : "", - selected ? "is-selected" : "" + selected ? "is-selected" : "", + highlighted ? "is-highlighted" : "" ), ref, style: { @@ -50582,10 +50676,7 @@ function useForceUpdate() { return () => setValue((value2) => value2 + 1); } -// src/components/Spaces/TreeView/FileExplorerVirtualized.tsx -var import_obsidian49 = require("obsidian"); - -// src/utils/ui/dnd.ts +// src/utils/dnd/dragFile.ts function getMaxDepth({ previousItem }) { var _a2; if (previousItem) { @@ -50611,10 +50702,9 @@ function getProjection(items, activeItem, overItemIndex, previousItem, nextItem, if (overIsSection) { return { depth: 0, - maxDepth: 0, - minDepth: 0, overId: previousItem.id, - parentId: null + parentId: null, + sortable: true }; } return null; @@ -50622,11 +50712,6 @@ function getProjection(items, activeItem, overItemIndex, previousItem, nextItem, if (nodeIsAncestorOfTarget(activeItem, previousItem)) { return null; } - if (activeItem.space != previousItem.space) { - if (previousItem.space == "/") { - return null; - } - } const projectedDepth = dragDepth; const maxDepth = getMaxDepth({ previousItem @@ -50643,20 +50728,20 @@ function getProjection(items, activeItem, overItemIndex, previousItem, nextItem, return null; } } + const parentId = getParentId(); return { depth, - maxDepth, - minDepth, overId: previousItem.id, - parentId: getParentId() + parentId, + sortable: previousItem.sortable }; function getParentId() { var _a2; if (depth === 0) { - return previousItem.space == "/" ? "/" : previousItem.space + "//"; + return previousItem.space + "//"; } if (!previousItem) { - return "/"; + return null; } if (depth === previousItem.depth || depth > previousItem.depth && !previousItem.item.isFolder) { return previousItem.parentId; @@ -50669,6 +50754,97 @@ function getProjection(items, activeItem, overItemIndex, previousItem, nextItem, } } +// src/utils/dnd/dropFile.ts +var import_obsidian49 = require("obsidian"); +var dropFileInTree = async (plugin, active, over, projected, flattenedTree, activeSpaces) => { + var _a2, _b2, _c2, _d2, _e2, _f, _g, _h; + if (projected) { + const clonedItems = flattenedTree; + const overIndex = clonedItems.findIndex(({ id: id2 }) => id2 === over.id); + const overItem = clonedItems[overIndex]; + const activeIndex = clonedItems.findIndex(({ id: id2 }) => id2 === active.id); + const activeItem = clonedItems[activeIndex]; + const activeIsSection = activeItem.parentId == null; + const overIsSection = overItem.parentId == null; + const overSpace = activeSpaces.find( + (f4) => f4.name == overItem.space + ); + const activeSpace = activeSpaces.find( + (f4) => f4.name == activeItem.space + ); + const overIsFolderSpace = ((_b2 = (_a2 = overSpace == null ? void 0 : overSpace.def) == null ? void 0 : _a2.folder) == null ? void 0 : _b2.length) > 0; + const overIsSmartSpace = ((_c2 = overSpace == null ? void 0 : overSpace.def) == null ? void 0 : _c2.type) == "smart"; + const activeIsFolderSpace = ((_e2 = (_d2 = activeSpace == null ? void 0 : activeSpace.def) == null ? void 0 : _d2.folder) == null ? void 0 : _e2.length) > 0; + const activeIsSmartSpace = ((_f = activeSpace == null ? void 0 : activeSpace.def) == null ? void 0 : _f.type) == "smart"; + const { depth, overId, parentId } = projected; + const parentItem = clonedItems.find(({ id: id2 }) => id2 === parentId); + const parentIsSpace = (parentItem == null ? void 0 : parentItem.item) ? false : true; + const newRank = (_h = (_g = overItem.item) == null ? void 0 : _g.rank) != null ? _h : "-1"; + if (activeIsSection) { + if (overIsSection) { + const activeSpace2 = activeSpaces.find( + (f4) => f4.name == activeItem.space + ); + insertSpaceAtIndex( + plugin, + activeSpace2, + overSpace ? parseInt(overSpace.rank) : activeSpaces.length + ); + } + return; + } + let newParent = activeItem.item.parent; + if (parentIsSpace) { + if (overIsSmartSpace) { + return; + } + if (overIsFolderSpace) { + newParent = overSpace.def.folder; + } else { + insertSpaceItemAtIndex( + plugin, + overItem.space, + activeItem.item.path, + parseInt(newRank) + ); + return; + } + } else { + newParent = parentItem.item.isFolder ? parentItem.item.path : parentItem.item.parent; + } + const newPath = newParent == "/" ? activeItem.file.name : `${newParent}/${activeItem.file.name}`; + if (newPath == activeItem.item.path) { + if (!activeIsFolderSpace && activeItem.depth == 1) { + removePathsFromSpace(plugin, activeItem.space, [ + activeItem.item.path + ]); + } + if (activeItem.parentId == overItem.id) { + updateFileRank(plugin, activeItem.item, -1); + return; + } else { + updateFileRank(plugin, activeItem.item, parseInt(newRank)); + return; + } + } else { + if (plugin.app.vault.getAbstractFileByPath(newPath)) { + new import_obsidian49.Notice(i18n_default.notice.duplicateFile); + return; + } + removePathsFromSpace(plugin, activeItem.space, [ + activeItem.item.path + ]); + moveAFileToNewParentAtIndex( + plugin, + activeItem.item, + newParent, + parseInt(newRank) + ); + return; + } + } +}; + // src/components/Spaces/TreeView/FileExplorerVirtualized.tsx var VirtualizedList = Cn.memo(function VirtualizedList2(props2) { const { @@ -50729,11 +50905,12 @@ var VirtualizedList = Cn.memo(function VirtualizedList2(props2) { depth: flattenedTree[virtualRow.index].depth, childCount: flattenedTree[virtualRow.index].childrenCount, indentationWidth, - indicator: (projected == null ? void 0 : projected.overId) == flattenedTree[virtualRow.index].id ? flattenedTree[virtualRow.index].parentId == null && projected.parentId == null ? { state: 1 /* Top */, depth: projected.depth } : { state: 2 /* Bottom */, depth: projected.depth } : null, + indicator: (projected == null ? void 0 : projected.sortable) && (projected == null ? void 0 : projected.overId) == flattenedTree[virtualRow.index].id ? flattenedTree[virtualRow.index].parentId == null && projected.parentId == null ? { state: 1 /* Top */, depth: projected.depth } : { state: 2 /* Bottom */, depth: projected.depth } : null, plugin, style: {}, onSelectRange: selectRange2, active: (activeFile2 == null ? void 0 : activeFile2.path) == (flattenedTree[virtualRow.index].item ? flattenedTree[virtualRow.index].item.path : flattenedTree[virtualRow.index].space + "//"), + highlighted: projected && !projected.sortable && (projected.parentId == flattenedTree[virtualRow.index].parentId || projected.parentId == flattenedTree[virtualRow.index].id), selected: selectedFiles2.some( (g4) => g4.id == flattenedTree[virtualRow.index].id ), @@ -50751,9 +50928,6 @@ var FileExplorerComponent = (props2) => { ); const [activeFile2, setActiveFile] = Recoil_index_14(activeFile); const [spaces2, setSpaces] = h2([]); - const [vaultSort, setVaultSort] = h2( - plugin.settings.vaultSort.length == 2 ? plugin.settings.vaultSort : ["rank", true] - ); const [selectedFiles2, setSelectedFiles] = Recoil_index_14( selectedFiles ); @@ -50776,21 +50950,22 @@ var FileExplorerComponent = (props2) => { tree.push(spaceToTreeNode(space, spaceCollapsed, true)); if (!spaceCollapsed) ((_b2 = vaultItems[space.name + "/"]) != null ? _b2 : []).sort(folderSortFn(spaceSort[0], spaceSort[1])).forEach((item) => { - var _a3, _b3; + var _a3, _b3, _c2; const itemCollapsed = !((_a3 = expandedFolders2[space.name]) == null ? void 0 : _a3.includes( item.path )); const items = []; if (!itemCollapsed) { + const [sortStrat, dir] = ((_b3 = item.folderSort) == null ? void 0 : _b3.length) > 0 ? parseSortStrat(item.folderSort) : spaceSort; items.push( ...flattenedTreeFromVaultItems( item.path, space.name, vaultItems, - (_b3 = expandedFolders2[space.name]) != null ? _b3 : [], + (_c2 = expandedFolders2[space.name]) != null ? _c2 : [], 2, - spaceSort[0], - spaceSort[1] + sortStrat, + dir ) ); } @@ -50813,45 +50988,15 @@ var FileExplorerComponent = (props2) => { return tree; }; const flattenedTree = F2(() => { - var _a2; const tree = []; activeSpaces.forEach((space) => { tree.push(...treeForSpace(space)); }); - if (!props2.activeSpace) { - const vaultCollapsed = !expandedSpaces.includes("/"); - const items = []; - if (!vaultCollapsed) - items.push( - ...flattenedTreeFromVaultItems( - "/", - "/", - vaultItems, - (_a2 = expandedFolders2["/"]) != null ? _a2 : [], - 1, - vaultSort[0], - vaultSort[1] - ) - ); - items.splice(0, 0, { - id: "/", - parentId: null, - depth: 0, - index: 0, - space: "/", - path: "/", - item: null, - collapsed: vaultCollapsed, - sortable: vaultSort[0] == "rank", - childrenCount: items.length - }); - tree.push(...items); - } if (nextTreeScrollPath.current) { const index = tree.findIndex( (f4) => { - var _a3; - return ((_a3 = f4.item) == null ? void 0 : _a3.path) == nextTreeScrollPath.current; + var _a2; + return ((_a2 = f4.item) == null ? void 0 : _a2.path) == nextTreeScrollPath.current; } ); if (index != -1) { @@ -50865,7 +51010,6 @@ var FileExplorerComponent = (props2) => { activeSpaces, expandedSpaces, expandedFolders2, - vaultSort, props2.activeSpace ]); p2(() => { @@ -50891,7 +51035,6 @@ var FileExplorerComponent = (props2) => { }; }, []); const revealFile = (path) => { - var _a2, _b2; if (!path || path.type != "file" && path.type != "folder") return; const file = getAbstractFileAtPath(app, path.path); @@ -50900,34 +51043,27 @@ var FileExplorerComponent = (props2) => { (p3, c4, index) => [...p3, index == 0 ? c4 : `${p3[index]}/${c4}`], ["/"] ).slice(0, -1); - const newOpenFolders = [ - ...(_b2 = (_a2 = expandedFolders2["/"]) == null ? void 0 : _a2.filter((f4) => !openPaths.find((g4) => g4 == f4))) != null ? _b2 : [], - ...openPaths - ]; - plugin.settings.expandedFolders = { - ...expandedFolders2, - "/": newOpenFolders - }; + plugin.settings.expandedFolders = expandedFolders2; nextTreeScrollPath.current = file.path; plugin.saveSettings(); }; const handleRevealFileEvent = (evt) => { if (evt.detail) - revealFile(pathByString(plugin, evt.detail.file.path)); + revealFile(pathByString(evt.detail.file.path)); }; const retrieveData = async (folders) => { setSpaces(plugin.index.allSpaces()); - const spaceItems = plugin.index.spaces; + const spaceItems = plugin.index.spacesMap; setVaultItems((g4) => ({ ...g4, - ...[...plugin.index.spacesCache.keys()].reduce( + ...[...plugin.index.spacesIndex.keys()].reduce( (p3, c4) => { var _a2; return { ...p3, [c4 + "/"]: [...(_a2 = spaceItems.getInverse(c4)) != null ? _a2 : []].map((f4) => { var _a3; - const fileCache = plugin.index.files.get(f4); + const fileCache = plugin.index.filesIndex.get(f4); return { ...fileCache, rank: (_a3 = fileCache == null ? void 0 : fileCache.spaceRanks) == null ? void 0 : _a3[c4] }; }).filter((f4) => f4) }; @@ -50941,8 +51077,6 @@ var FileExplorerComponent = (props2) => { }; const flatFolders = F2(() => { const allFolders = []; - if (expandedSpaces.includes("/")) - allFolders.push("/"); expandedSpaces.forEach((space) => { var _a2; allFolders.push(...(_a2 = expandedFolders2[space]) != null ? _a2 : []); @@ -50967,7 +51101,6 @@ var FileExplorerComponent = (props2) => { setActiveFile(path); }; const settingsChanged = () => { - setVaultSort(plugin.settings.vaultSort); setExpandedFolders(plugin.settings.expandedFolders); setExpandedSpaces(plugin.settings.expandedSpaces); }; @@ -51036,8 +51169,6 @@ var FileExplorerComponent = (props2) => { active: { id: activeId2 } } = event; const activeItem2 = flattenedTree.find(({ id: id2 }) => id2 === activeId2); - if (activeItem2.parentId == null && activeItem2.space == "/") - return; setActiveId(activeId2); setOverId(activeId2); if (activeItem2) { @@ -51060,156 +51191,15 @@ var FileExplorerComponent = (props2) => { } function handleDragEnd({ active, over }) { resetState(); - moveFile2(active, over); - } - const moveFile2 = async (active, over) => { - var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2; - if (projected) { - const clonedItems = flattenedTree; - const overIndex2 = clonedItems.findIndex(({ id: id2 }) => id2 === over.id); - const overItem2 = clonedItems[overIndex2]; - const activeIndex = clonedItems.findIndex(({ id: id2 }) => id2 === active.id); - const activeTreeItem = clonedItems[activeIndex]; - const activeIsSection = activeTreeItem.parentId == null; - const overIsSection = overItem2.parentId == null; - const overSpace = activeSpaces.find( - (f4) => f4.name == overItem2.space - ); - if (activeIsSection) { - if (overIsSection) { - const activeSpace = activeSpaces.find( - (f4) => f4.name == activeTreeItem.space - ); - insertSpaceAtIndex( - plugin, - activeSpace, - overSpace ? parseInt(overSpace.rank) : spaces2.length - ); - return; - } - } - const { depth, overId: overId2, parentId } = projected; - const parentItem = clonedItems.find(({ id: id2 }) => id2 === parentId); - if (overItem2.space != activeItem.space || overItem2.space != "/") { - if (parentId != activeTreeItem.parentId) { - const newParent = (parentItem == null ? void 0 : parentItem.item) ? parentItem.item.isFolder ? parentItem.item.path : parentItem.item.parent : "/"; - const newRank = (_b2 = (_a2 = overItem2.item) == null ? void 0 : _a2.rank) != null ? _b2 : "-1"; - const newPath = newParent == "/" ? activeItem.file.name : `${newParent}/${activeItem.file.name}`; - if (newPath == activeItem.item.path) { - removePathsFromSpace(plugin, activeItem.space, [ - activeTreeItem.item.path - ]); - if (!(((_d2 = (_c2 = overSpace == null ? void 0 : overSpace.def) == null ? void 0 : _c2.folder) == null ? void 0 : _d2.length) > 0) && !(parentItem == null ? void 0 : parentItem.item)) { - insertSpaceItemAtIndex( - plugin, - overItem2.space, - activeItem.item.path, - parseInt(newRank) - ); - } - return; - } else { - if (plugin.app.vault.getAbstractFileByPath(newPath)) { - new import_obsidian49.Notice(i18n_default.notice.duplicateFile); - return; - } - } - removePathsFromSpace(plugin, activeItem.space, [ - activeTreeItem.item.path - ]); - if (!(((_f = (_e2 = overSpace == null ? void 0 : overSpace.def) == null ? void 0 : _e2.folder) == null ? void 0 : _f.length) > 0) && !(parentItem == null ? void 0 : parentItem.item)) { - insertSpaceItemAtIndex( - plugin, - overItem2.space, - activeItem.item.path, - parseInt(newRank) - ); - } - moveAFileToNewParentAtIndex( - plugin, - activeTreeItem.item, - newParent, - parseInt(newRank) - ); - return; - } - if (overItem2.space == activeItem.space && overItem2.space != "/") { - const newRank = (_h = (_g = overItem2.item) == null ? void 0 : _g.rank) != null ? _h : "-1"; - if (activeTreeItem.parentId == overItem2.space + "//" && (overIsSection || parentId == overItem2.space + "//")) { - insertSpaceItemAtIndex( - plugin, - overItem2.space, - activeItem.item.path, - parseInt(newRank) - ); - return; - } - if (activeTreeItem.parentId == overItem2.id) { - updateFileRank(plugin, activeTreeItem.item, -1); - return; - } - updateFileRank(plugin, activeTreeItem.item, parseInt(newRank)); - return; - } - if (overItem2.space == "/") { - return; - } - if (parentId != overItem2.space + "//" && parentId != null) { - return; - } - if (activeItem.space != overItem2.space && ((_j = (_i = overSpace == null ? void 0 : overSpace.def) == null ? void 0 : _i.folder) == null ? void 0 : _j.length) > 0) { - moveAFileToNewParentAtIndex( - plugin, - activeTreeItem.item, - (_k = overSpace.def) == null ? void 0 : _k.folder, - parseInt(overItem2.item.rank) - ); - if (activeItem.space != "/") { - removePathsFromSpace(plugin, activeItem.space, [ - activeTreeItem.item.path - ]); - } - } else { - insertSpaceItemAtIndex( - plugin, - overItem2.space, - activeItem.item.path, - parseInt((_l = overItem2.item) == null ? void 0 : _l.rank) - ); - } - return; - } - if (parentId != activeTreeItem.parentId) { - if (overIsSection && activeTreeItem.parentId == "///") { - updateFileRank(plugin, activeTreeItem.item, -1); - return; - } - const newParent = (parentItem == null ? void 0 : parentItem.item) ? parentItem.item.isFolder ? parentItem.item.path : parentItem.item.parent : "/"; - const newRank = (_n2 = (_m = overItem2.item) == null ? void 0 : _m.rank) != null ? _n2 : "-1"; - const newPath = newParent == "/" ? activeItem.file.name : `${newParent}/${activeItem.file.name}`; - if (plugin.app.vault.getAbstractFileByPath(newPath)) { - new import_obsidian49.Notice(i18n_default.notice.duplicateFile); - return; - } - moveAFileToNewParentAtIndex( - plugin, - activeTreeItem.item, - newParent, - parseInt(newRank) - ); - } else { - if (activeTreeItem.parentId == overItem2.id) { - updateFileRank(plugin, activeTreeItem.item, -1); - return; - } - updateFileRank( - plugin, - activeTreeItem.item, - parseInt(overItem2.item.rank) - ); - } - } - }; + dropFileInTree( + plugin, + active, + over, + projected, + flattenedTree, + activeSpaces + ); + } const adjustTranslate = ({ transform }) => { return { ...transform, @@ -51288,6 +51278,7 @@ var FileExplorerComponent = (props2) => { disabled: false, plugin, selected: false, + highlighted: false, active: false, clone: true, childCount: 0, @@ -51795,13 +51786,13 @@ var DEFAULT_SETTINGS = { fileIcons: [], cachedSpaces: [], menuTriggerChar: "/", + inlineStickerMenu: true, emojiTriggerChar: ":", folderContextFile: "context", tagContextFolder: "Context", hiddenFiles: ["Context"], lineNumbers: false, hiddenExtensions: ["mdb"], - vaultSort: ["rank", true], newFileLocation: "root", newFileFolderPath: "", inlineBacklinks: false, @@ -51816,7 +51807,8 @@ var DEFAULT_SETTINGS = { spacesAutoBackup: true, spacesAutoBackupInterval: 10, spacesAutoBackupLast: 0, - spacesUseAlias: false + spacesUseAlias: false, + precreateVaultSpace: false }; var MakeMDPluginSettingsTab = class extends import_obsidian53.PluginSettingTab { constructor(app2, plugin) { @@ -51827,7 +51819,7 @@ var MakeMDPluginSettingsTab = class extends import_obsidian53.PluginSettingTab { this.display(); } display() { - let { containerEl } = this; + const { containerEl } = this; containerEl.empty(); containerEl.createEl("h1", { text: i18n_default.settings.sectionSidebar }); new import_obsidian53.Setting(containerEl).setName(i18n_default.settings.spaces.name).setDesc(i18n_default.settings.spaces.desc).addToggle( @@ -51844,7 +51836,7 @@ var MakeMDPluginSettingsTab = class extends import_obsidian53.PluginSettingTab { ); if (this.plugin.settings.spacesEnabled) { containerEl.createEl("h3", { text: i18n_default.settings.sectionAppearance }); - let spaceAppearances = containerEl.createEl("div"); + const spaceAppearances = containerEl.createEl("div"); new import_obsidian53.Setting(spaceAppearances).setName(i18n_default.settings.sidebarTabs.name).setDesc(i18n_default.settings.sidebarTabs.desc).addToggle( (toggle) => toggle.setValue(this.plugin.settings.sidebarTabs).onChange((value) => { this.plugin.settings.sidebarTabs = value; @@ -52141,6 +52133,13 @@ var MakeMDPluginSettingsTab = class extends import_obsidian53.PluginSettingTab { this.plugin.reloadExtensions(false); }) ); + new import_obsidian53.Setting(containerEl).setName(i18n_default.settings.inlineStickerMenu.name).setDesc(i18n_default.settings.inlineStickerMenu.desc).addToggle( + (toggle) => toggle.setValue(this.plugin.settings.inlineStickerMenu).onChange(async (value) => { + this.plugin.settings.inlineStickerMenu = value; + await this.plugin.saveSettings(); + this.plugin.reloadExtensions(false); + }) + ); new import_obsidian53.Setting(containerEl).setName(i18n_default.settings.inlineStylerColor.name).setDesc(i18n_default.settings.inlineStylerColor.desc).addToggle( (toggle) => toggle.setValue(this.plugin.settings.inlineStylerColors).onChange((value) => { this.plugin.settings.inlineStylerColors = value; @@ -52201,7 +52200,7 @@ var BlinkComponent = Cn.forwardRef( const selectItem = (item) => { if (!item) return; - openPath(props2.plugin, pathByString(props2.plugin, item)); + openPath(props2.plugin, pathByString(item)); }; const optionProps = { multi: false, @@ -52229,6 +52228,8 @@ var BlinkComponent = Cn.forwardRef( })); } ); +BlinkComponent.displayName = "BlinkComponent"; +var BlinkComponent_default = BlinkComponent; // src/components/Blink/Blink.tsx var Blink = class extends import_obsidian54.Modal { @@ -52254,7 +52255,7 @@ var Blink = class extends import_obsidian54.Modal { } this.root = createRoot(this.modalEl); this.root.render( - /* @__PURE__ */ Cn.createElement(BlinkComponent, { + /* @__PURE__ */ Cn.createElement(BlinkComponent_default, { ref: this.ref, plugin, hide: () => this.close() @@ -52377,7 +52378,7 @@ var FileContextView = (props2) => { if (!selectedPath) return null; if (selectedPath.type == "folder" || selectedPath.type == "space" || selectedPath.type == "tag") { - return (_a2 = props2.plugin.index.contextsCache.get(selectedPath.path)) == null ? void 0 : _a2.info; + return (_a2 = props2.plugin.index.contextsIndex.get(selectedPath.path)) == null ? void 0 : _a2.info; } else { return null; } @@ -52396,7 +52397,7 @@ var FileContextView = (props2) => { const changeSelectedFile = (evt) => { const path = evt.detail.path; if (evt.detail.selection) { - setSelectedPath(pathByString(props2.plugin, evt.detail.selection)); + setSelectedPath(pathByString(evt.detail.selection)); } else { setSelectedPath(path); } @@ -52418,12 +52419,14 @@ var FileContextView = (props2) => { }, file && /* @__PURE__ */ Cn.createElement(InlineFileContextView, { plugin: props2.plugin, file, - showHeader: false, + showHeader: true, + showBanner: false, editable: true }), selectedRow && /* @__PURE__ */ Cn.createElement(InlineFileContextView, { plugin: props2.plugin, file: selectedRow, - showHeader: false, + showHeader: true, + showBanner: false, editable: true }), file && /* @__PURE__ */ Cn.createElement(Backlinks, { plugin: props2.plugin, @@ -52465,7 +52468,7 @@ var dispatchSpaceDatabaseFileChanged = (type, action, name, newName) => { var onFileCreated = async (plugin, newPath, folder) => { var _a2; const parent = (_a2 = getAbstractFileAtPath(app, newPath).parent) == null ? void 0 : _a2.path; - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: [...plugin.index.vaultDBCache, { + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: [...plugin.index.vaultDBCache, { path: newPath, parent, created: Math.trunc(Date.now() / 1e3).toString(), @@ -52476,7 +52479,7 @@ var onFileCreated = async (plugin, newPath, folder) => { var onFileDeleted = (plugin, oldPath) => { const newVaultRows = plugin.index.vaultDBCache.filter((f4) => f4.path != oldPath); const newSpaceItemsRows = plugin.index.spacesItemsDBCache.filter((f4) => f4.path != oldPath); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); plugin.index.deleteFile(oldPath); }; var onFileChanged = (plugin, oldPath, newPath) => { @@ -52490,7 +52493,7 @@ var onFileChanged = (plugin, oldPath, newPath) => { ...f4, path: newPath } : f4); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); plugin.index.renameFile(oldPath, newPath); }; var onFolderChanged = (plugin, oldPath, newPath) => { @@ -52512,15 +52515,20 @@ var onFolderChanged = (plugin, oldPath, newPath) => { ...f4, path: f4.path.replace(oldPath, newPath) } : f4); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); plugin.index.renameFile(oldPath, newPath); + if (plugin.settings.enableFolderNote && !plugin.settings.folderNoteInsideFolder) { + const file = getAbstractFileAtPath(app, oldPath + ".md"); + if (file) + renameFile(plugin, file, newPath + ".md"); + } allChildren.forEach((f4) => plugin.index.renameFile(f4.path, f4.path.replace(oldPath, newPath))); }; var onFolderDeleted = (plugin, oldPath) => { const allChildren = retrieveAllRecursiveChildren(plugin.index.vaultDBCache, plugin.settings, oldPath); const newVaultRows = plugin.index.vaultDBCache.filter((f4) => f4.path != oldPath && !f4.parent.startsWith(oldPath)); const newSpaceItemsRows = plugin.index.vaultDBCache.filter((f4) => f4.path != oldPath && !f4.parent.startsWith(oldPath)); - plugin.index.saveSpacesDB({ vault: { ...vaultSchema, rows: newVaultRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); + plugin.index.saveSpacesDatabaseToDisk({ vault: { ...vaultSchema, rows: newVaultRows }, spaceItems: { ...spaceItemsSchema, rows: newSpaceItemsRows } }); allChildren.forEach((f4) => plugin.index.deleteFile(f4.path)); plugin.index.deleteFile(oldPath); }; @@ -52691,6 +52699,9 @@ var LocalStorageCache = class { async storeFile(path, data) { await this.persister.setItem(this.fileKey(path), data); } + async removeFile(path) { + await this.persister.removeItem(this.fileKey(path)); + } async synchronize(existing) { let keys = new Set(await this.allFiles()); for (let exist of existing) @@ -52725,7 +52736,7 @@ function inlineWorker(scriptText) { // src/superstate/workers/entry.worker.ts function Worker2() { - return inlineWorker('var $_=Object.create;var Ji=Object.defineProperty,z_=Object.defineProperties,k_=Object.getOwnPropertyDescriptor,Y_=Object.getOwnPropertyDescriptors,Z_=Object.getOwnPropertyNames,Uo=Object.getOwnPropertySymbols,J_=Object.getPrototypeOf,Go=Object.prototype.hasOwnProperty,X_=Object.prototype.propertyIsEnumerable;var No=(i,p,y)=>p in i?Ji(i,p,{enumerable:!0,configurable:!0,writable:!0,value:y}):i[p]=y,Pt=(i,p)=>{for(var y in p||(p={}))Go.call(p,y)&&No(i,y,p[y]);if(Uo)for(var y of Uo(p))X_.call(p,y)&&No(i,y,p[y]);return i},Bt=(i,p)=>z_(i,Y_(p));var Q_=(i,p)=>()=>(p||i((p={exports:{}}).exports,p),p.exports);var V_=(i,p,y,A)=>{if(p&&typeof p=="object"||typeof p=="function")for(let m of Z_(p))!Go.call(i,m)&&m!==y&&Ji(i,m,{get:()=>p[m],enumerable:!(A=k_(p,m))||A.enumerable});return i};var j_=(i,p,y)=>(y=i!=null?$_(J_(i)):{},V_(p||!i||!i.__esModule?Ji(y,"default",{value:i,enumerable:!0}):y,i));var qo=Q_((Vt,Se)=>{(function(){var i,p="4.17.21",y=200,A="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",m="Expected a function",E="Invalid `variable` option passed into `_.template`",Q="__lodash_hash_undefined__",rn=500,un="__lodash_placeholder__",K=1,An=2,an=4,ln=1,Sn=2,Y=1,z=2,X=4,cn=8,En=16,V=32,jn=64,On=128,pt=256,qn=512,Fr=30,Fe="...",Wt=800,Ct=16,ne=1,Mr=2,Me=3,Jn=1/0,Kn=9007199254740991,Ie=17976931348623157e292,Tt=0/0,Cn=4294967295,Re=Cn-1,Le=Cn>>>1,pn=[["ary",On],["bind",Y],["bindKey",z],["curry",cn],["curryRight",En],["flip",qn],["partial",V],["partialRight",jn],["rearg",pt]],hn="[object Arguments]",gn="[object Array]",ht="[object AsyncFunction]",te="[object Boolean]",ee="[object Date]",fs="[object DOMException]",Ee="[object Error]",Oe="[object Function]",uu="[object GeneratorFunction]",Hn="[object Map]",re="[object Number]",os="[object Null]",nt="[object Object]",fu="[object Promise]",ss="[object Proxy]",ie="[object RegExp]",$n="[object Set]",ue="[object String]",be="[object Symbol]",as="[object Undefined]",fe="[object WeakMap]",ls="[object WeakSet]",oe="[object ArrayBuffer]",Ut="[object DataView]",Ir="[object Float32Array]",Rr="[object Float64Array]",Lr="[object Int8Array]",Er="[object Int16Array]",Or="[object Int32Array]",br="[object Uint8Array]",Dr="[object Uint8ClampedArray]",Pr="[object Uint16Array]",Br="[object Uint32Array]",cs=/\\b__p \\+= \'\';/g,ps=/\\b(__p \\+=) \'\' \\+/g,hs=/(__e\\(.*?\\)|\\b__t\\)) \\+\\n\'\';/g,ou=/&(?:amp|lt|gt|quot|#39);/g,su=/[&<>"\']/g,gs=RegExp(ou.source),_s=RegExp(su.source),ds=/<%-([\\s\\S]+?)%>/g,vs=/<%([\\s\\S]+?)%>/g,au=/<%=([\\s\\S]+?)%>/g,xs=/\\.|\\[(?:[^[\\]]*|(["\'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,ys=/^\\w*$/,ms=/[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g,Wr=/[\\\\^$.*+?()[\\]{}|]/g,ws=RegExp(Wr.source),Ur=/^\\s+/,As=/\\s/,Ss=/\\{(?:\\n\\/\\* \\[wrapped with .+\\] \\*\\/)?\\n?/,Cs=/\\{\\n\\/\\* \\[wrapped with (.+)\\] \\*/,Ts=/,? & /,Fs=/[^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]+/g,Ms=/[()=,{}\\[\\]\\/\\s]/,Is=/\\\\(\\\\)?/g,Rs=/\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g,lu=/\\w*$/,Ls=/^[-+]0x[0-9a-f]+$/i,Es=/^0b[01]+$/i,Os=/^\\[object .+?Constructor\\]$/,bs=/^0o[0-7]+$/i,Ds=/^(?:0|[1-9]\\d*)$/,Ps=/[\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\xff\\u0100-\\u017f]/g,De=/($^)/,Bs=/[\'\\n\\r\\u2028\\u2029\\\\]/g,Pe="\\\\ud800-\\\\udfff",Ws="\\\\u0300-\\\\u036f",Us="\\\\ufe20-\\\\ufe2f",Ns="\\\\u20d0-\\\\u20ff",cu=Ws+Us+Ns,pu="\\\\u2700-\\\\u27bf",hu="a-z\\\\xdf-\\\\xf6\\\\xf8-\\\\xff",Gs="\\\\xac\\\\xb1\\\\xd7\\\\xf7",qs="\\\\x00-\\\\x2f\\\\x3a-\\\\x40\\\\x5b-\\\\x60\\\\x7b-\\\\xbf",Ks="\\\\u2000-\\\\u206f",Hs=" \\\\t\\\\x0b\\\\f\\\\xa0\\\\ufeff\\\\n\\\\r\\\\u2028\\\\u2029\\\\u1680\\\\u180e\\\\u2000\\\\u2001\\\\u2002\\\\u2003\\\\u2004\\\\u2005\\\\u2006\\\\u2007\\\\u2008\\\\u2009\\\\u200a\\\\u202f\\\\u205f\\\\u3000",gu="A-Z\\\\xc0-\\\\xd6\\\\xd8-\\\\xde",_u="\\\\ufe0e\\\\ufe0f",du=Gs+qs+Ks+Hs,Nr="[\'\\u2019]",$s="["+Pe+"]",vu="["+du+"]",Be="["+cu+"]",xu="\\\\d+",zs="["+pu+"]",yu="["+hu+"]",mu="[^"+Pe+du+xu+pu+hu+gu+"]",Gr="\\\\ud83c[\\\\udffb-\\\\udfff]",ks="(?:"+Be+"|"+Gr+")",wu="[^"+Pe+"]",qr="(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}",Kr="[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]",Nt="["+gu+"]",Au="\\\\u200d",Su="(?:"+yu+"|"+mu+")",Ys="(?:"+Nt+"|"+mu+")",Cu="(?:"+Nr+"(?:d|ll|m|re|s|t|ve))?",Tu="(?:"+Nr+"(?:D|LL|M|RE|S|T|VE))?",Fu=ks+"?",Mu="["+_u+"]?",Zs="(?:"+Au+"(?:"+[wu,qr,Kr].join("|")+")"+Mu+Fu+")*",Js="\\\\d*(?:1st|2nd|3rd|(?![123])\\\\dth)(?=\\\\b|[A-Z_])",Xs="\\\\d*(?:1ST|2ND|3RD|(?![123])\\\\dTH)(?=\\\\b|[a-z_])",Iu=Mu+Fu+Zs,Qs="(?:"+[zs,qr,Kr].join("|")+")"+Iu,Vs="(?:"+[wu+Be+"?",Be,qr,Kr,$s].join("|")+")",js=RegExp(Nr,"g"),na=RegExp(Be,"g"),Hr=RegExp(Gr+"(?="+Gr+")|"+Vs+Iu,"g"),ta=RegExp([Nt+"?"+yu+"+"+Cu+"(?="+[vu,Nt,"$"].join("|")+")",Ys+"+"+Tu+"(?="+[vu,Nt+Su,"$"].join("|")+")",Nt+"?"+Su+"+"+Cu,Nt+"+"+Tu,Xs,Js,xu,Qs].join("|"),"g"),ea=RegExp("["+Au+Pe+cu+_u+"]"),ra=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ia=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ua=-1,q={};q[Ir]=q[Rr]=q[Lr]=q[Er]=q[Or]=q[br]=q[Dr]=q[Pr]=q[Br]=!0,q[hn]=q[gn]=q[oe]=q[te]=q[Ut]=q[ee]=q[Ee]=q[Oe]=q[Hn]=q[re]=q[nt]=q[ie]=q[$n]=q[ue]=q[fe]=!1;var G={};G[hn]=G[gn]=G[oe]=G[Ut]=G[te]=G[ee]=G[Ir]=G[Rr]=G[Lr]=G[Er]=G[Or]=G[Hn]=G[re]=G[nt]=G[ie]=G[$n]=G[ue]=G[be]=G[br]=G[Dr]=G[Pr]=G[Br]=!0,G[Ee]=G[Oe]=G[fe]=!1;var fa={\\u00C0:"A",\\u00C1:"A",\\u00C2:"A",\\u00C3:"A",\\u00C4:"A",\\u00C5:"A",\\u00E0:"a",\\u00E1:"a",\\u00E2:"a",\\u00E3:"a",\\u00E4:"a",\\u00E5:"a",\\u00C7:"C",\\u00E7:"c",\\u00D0:"D",\\u00F0:"d",\\u00C8:"E",\\u00C9:"E",\\u00CA:"E",\\u00CB:"E",\\u00E8:"e",\\u00E9:"e",\\u00EA:"e",\\u00EB:"e",\\u00CC:"I",\\u00CD:"I",\\u00CE:"I",\\u00CF:"I",\\u00EC:"i",\\u00ED:"i",\\u00EE:"i",\\u00EF:"i",\\u00D1:"N",\\u00F1:"n",\\u00D2:"O",\\u00D3:"O",\\u00D4:"O",\\u00D5:"O",\\u00D6:"O",\\u00D8:"O",\\u00F2:"o",\\u00F3:"o",\\u00F4:"o",\\u00F5:"o",\\u00F6:"o",\\u00F8:"o",\\u00D9:"U",\\u00DA:"U",\\u00DB:"U",\\u00DC:"U",\\u00F9:"u",\\u00FA:"u",\\u00FB:"u",\\u00FC:"u",\\u00DD:"Y",\\u00FD:"y",\\u00FF:"y",\\u00C6:"Ae",\\u00E6:"ae",\\u00DE:"Th",\\u00FE:"th",\\u00DF:"ss",\\u0100:"A",\\u0102:"A",\\u0104:"A",\\u0101:"a",\\u0103:"a",\\u0105:"a",\\u0106:"C",\\u0108:"C",\\u010A:"C",\\u010C:"C",\\u0107:"c",\\u0109:"c",\\u010B:"c",\\u010D:"c",\\u010E:"D",\\u0110:"D",\\u010F:"d",\\u0111:"d",\\u0112:"E",\\u0114:"E",\\u0116:"E",\\u0118:"E",\\u011A:"E",\\u0113:"e",\\u0115:"e",\\u0117:"e",\\u0119:"e",\\u011B:"e",\\u011C:"G",\\u011E:"G",\\u0120:"G",\\u0122:"G",\\u011D:"g",\\u011F:"g",\\u0121:"g",\\u0123:"g",\\u0124:"H",\\u0126:"H",\\u0125:"h",\\u0127:"h",\\u0128:"I",\\u012A:"I",\\u012C:"I",\\u012E:"I",\\u0130:"I",\\u0129:"i",\\u012B:"i",\\u012D:"i",\\u012F:"i",\\u0131:"i",\\u0134:"J",\\u0135:"j",\\u0136:"K",\\u0137:"k",\\u0138:"k",\\u0139:"L",\\u013B:"L",\\u013D:"L",\\u013F:"L",\\u0141:"L",\\u013A:"l",\\u013C:"l",\\u013E:"l",\\u0140:"l",\\u0142:"l",\\u0143:"N",\\u0145:"N",\\u0147:"N",\\u014A:"N",\\u0144:"n",\\u0146:"n",\\u0148:"n",\\u014B:"n",\\u014C:"O",\\u014E:"O",\\u0150:"O",\\u014D:"o",\\u014F:"o",\\u0151:"o",\\u0154:"R",\\u0156:"R",\\u0158:"R",\\u0155:"r",\\u0157:"r",\\u0159:"r",\\u015A:"S",\\u015C:"S",\\u015E:"S",\\u0160:"S",\\u015B:"s",\\u015D:"s",\\u015F:"s",\\u0161:"s",\\u0162:"T",\\u0164:"T",\\u0166:"T",\\u0163:"t",\\u0165:"t",\\u0167:"t",\\u0168:"U",\\u016A:"U",\\u016C:"U",\\u016E:"U",\\u0170:"U",\\u0172:"U",\\u0169:"u",\\u016B:"u",\\u016D:"u",\\u016F:"u",\\u0171:"u",\\u0173:"u",\\u0174:"W",\\u0175:"w",\\u0176:"Y",\\u0177:"y",\\u0178:"Y",\\u0179:"Z",\\u017B:"Z",\\u017D:"Z",\\u017A:"z",\\u017C:"z",\\u017E:"z",\\u0132:"IJ",\\u0133:"ij",\\u0152:"Oe",\\u0153:"oe",\\u0149:"\'n",\\u017F:"s"},oa={"&":"&","<":"<",">":">",\'"\':""","\'":"'"},sa={"&":"&","<":"<",">":">",""":\'"\',"'":"\'"},aa={"\\\\":"\\\\","\'":"\'","\\n":"n","\\r":"r","\\u2028":"u2028","\\u2029":"u2029"},la=parseFloat,ca=parseInt,Ru=typeof global=="object"&&global&&global.Object===Object&&global,pa=typeof self=="object"&&self&&self.Object===Object&&self,tn=Ru||pa||Function("return this")(),$r=typeof Vt=="object"&&Vt&&!Vt.nodeType&&Vt,Ft=$r&&typeof Se=="object"&&Se&&!Se.nodeType&&Se,Lu=Ft&&Ft.exports===$r,zr=Lu&&Ru.process,bn=function(){try{var l=Ft&&Ft.require&&Ft.require("util").types;return l||zr&&zr.binding&&zr.binding("util")}catch(g){}}(),Eu=bn&&bn.isArrayBuffer,Ou=bn&&bn.isDate,bu=bn&&bn.isMap,Du=bn&&bn.isRegExp,Pu=bn&&bn.isSet,Bu=bn&&bn.isTypedArray;function Tn(l,g,h){switch(h.length){case 0:return l.call(g);case 1:return l.call(g,h[0]);case 2:return l.call(g,h[0],h[1]);case 3:return l.call(g,h[0],h[1],h[2])}return l.apply(g,h)}function ha(l,g,h,w){for(var M=-1,B=l==null?0:l.length;++M-1}function kr(l,g,h){for(var w=-1,M=l==null?0:l.length;++w-1;);return h}function $u(l,g){for(var h=l.length;h--&&Gt(g,l[h],0)>-1;);return h}function Aa(l,g){for(var h=l.length,w=0;h--;)l[h]===g&&++w;return w}var Sa=Xr(fa),Ca=Xr(oa);function Ta(l){return"\\\\"+aa[l]}function Fa(l,g){return l==null?i:l[g]}function qt(l){return ea.test(l)}function Ma(l){return ra.test(l)}function Ia(l){for(var g,h=[];!(g=l.next()).done;)h.push(g.value);return h}function ni(l){var g=-1,h=Array(l.size);return l.forEach(function(w,M){h[++g]=[M,w]}),h}function zu(l,g){return function(h){return l(g(h))}}function dt(l,g){for(var h=-1,w=l.length,M=0,B=[];++h-1}function _l(n,t){var e=this.__data__,r=nr(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}tt.prototype.clear=cl,tt.prototype.delete=pl,tt.prototype.get=hl,tt.prototype.has=gl,tt.prototype.set=_l;function et(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t=t?n:t)),n}function Wn(n,t,e,r,u,o){var s,a=t&K,c=t&An,_=t&an;if(e&&(s=u?e(n,r,u,o):e(n)),s!==i)return s;if(!$(n))return n;var d=I(n);if(d){if(s=yc(n),!a)return xn(n,s)}else{var v=sn(n),x=v==Oe||v==uu;if(St(n))return If(n,a);if(v==nt||v==hn||x&&!u){if(s=c||x?{}:Yf(n),!a)return c?sc(n,El(s,n)):oc(n,rf(s,n))}else{if(!G[v])return u?n:{};s=mc(n,v,a)}}o||(o=new kn);var S=o.get(n);if(S)return S;o.set(n,s),So(n)?n.forEach(function(F){s.add(Wn(F,t,e,F,n,o))}):wo(n)&&n.forEach(function(F,b){s.set(b,Wn(F,t,e,b,n,o))});var T=_?c?Fi:Ti:c?mn:en,L=d?i:T(n);return Dn(L||n,function(F,b){L&&(b=F,F=n[b]),ge(s,b,Wn(F,t,e,b,n,o))}),s}function Ol(n){var t=en(n);return function(e){return uf(e,n,t)}}function uf(n,t,e){var r=e.length;if(n==null)return!r;for(n=N(n);r--;){var u=e[r],o=t[u],s=n[u];if(s===i&&!(u in n)||!o(s))return!1}return!0}function ff(n,t,e){if(typeof n!="function")throw new Pn(m);return we(function(){n.apply(i,e)},t)}function _e(n,t,e,r){var u=-1,o=We,s=!0,a=n.length,c=[],_=t.length;if(!a)return c;e&&(t=H(t,Fn(e))),r?(o=kr,s=!1):t.length>=y&&(o=se,s=!1,t=new Rt(t));n:for(;++uu?0:u+e),r=r===i||r>u?u:R(r),r<0&&(r+=u),r=e>r?0:To(r);e0&&e(a)?t>1?fn(a,t-1,e,r,u):_t(u,a):r||(u[u.length]=a)}return u}var oi=Df(),af=Df(!0);function Xn(n,t){return n&&oi(n,t,en)}function si(n,t){return n&&af(n,t,en)}function er(n,t){return gt(t,function(e){return ot(n[e])})}function Et(n,t){t=wt(t,n);for(var e=0,r=t.length;n!=null&&et}function Pl(n,t){return n!=null&&U.call(n,t)}function Bl(n,t){return n!=null&&t in N(n)}function Wl(n,t,e){return n>=on(t,e)&&n=120&&d.length>=120)?new Rt(s&&d):i}d=n[0];var v=-1,x=a[0];n:for(;++v-1;)a!==n&&Ye.call(a,c,1),Ye.call(n,c,1);return n}function mf(n,t){for(var e=n?t.length:0,r=e-1;e--;){var u=t[e];if(e==r||u!==o){var o=u;ft(u)?Ye.call(n,u,1):xi(n,u)}}return n}function _i(n,t){return n+Xe(ju()*(t-n+1))}function Xl(n,t,e,r){for(var u=-1,o=nn(Je((t-n)/(e||1)),0),s=h(o);o--;)s[r?o:++u]=n,n+=e;return s}function di(n,t){var e="";if(!n||t<1||t>Kn)return e;do t%2&&(e+=n),t=Xe(t/2),t&&(n+=n);while(t);return e}function O(n,t){return bi(Xf(n,t,wn),n+"")}function Ql(n){return ef(Qt(n))}function Vl(n,t){var e=Qt(n);return hr(e,Lt(t,0,e.length))}function xe(n,t,e,r){if(!$(n))return n;t=wt(t,n);for(var u=-1,o=t.length,s=o-1,a=n;a!=null&&++uu?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=h(u);++r>>1,s=n[o];s!==null&&!In(s)&&(e?s<=t:s=y){var _=t?null:pc(n);if(_)return Ne(_);s=!1,u=se,c=new Rt}else c=t?[]:a;n:for(;++r=r?n:Un(n,t,e)}var Mf=Ha||function(n){return tn.clearTimeout(n)};function If(n,t){if(t)return n.slice();var e=n.length,r=Zu?Zu(e):new n.constructor(e);return n.copy(r),r}function Ai(n){var t=new n.constructor(n.byteLength);return new ze(t).set(new ze(n)),t}function rc(n,t){var e=t?Ai(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}function ic(n){var t=new n.constructor(n.source,lu.exec(n));return t.lastIndex=n.lastIndex,t}function uc(n){return he?N(he.call(n)):{}}function Rf(n,t){var e=t?Ai(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}function Lf(n,t){if(n!==t){var e=n!==i,r=n===null,u=n===n,o=In(n),s=t!==i,a=t===null,c=t===t,_=In(t);if(!a&&!_&&!o&&n>t||o&&s&&c&&!a&&!_||r&&s&&c||!e&&c||!u)return 1;if(!r&&!o&&!_&&n=a)return c;var _=e[r];return c*(_=="desc"?-1:1)}}return n.index-t.index}function Ef(n,t,e,r){for(var u=-1,o=n.length,s=e.length,a=-1,c=t.length,_=nn(o-s,0),d=h(c+_),v=!r;++a1?e[u-1]:i,s=u>2?e[2]:i;for(o=n.length>3&&typeof o=="function"?(u--,o):i,s&&dn(e[0],e[1],s)&&(o=u<3?i:o,u=1),t=N(t);++r-1?u[o?t[s]:s]:i}}function Wf(n){return ut(function(t){var e=t.length,r=e,u=Bn.prototype.thru;for(n&&t.reverse();r--;){var o=t[r];if(typeof o!="function")throw new Pn(m);if(u&&!s&&cr(o)=="wrapper")var s=new Bn([],!0)}for(r=s?r:e;++r1&&P.reverse(),d&&ca))return!1;var _=o.get(n),d=o.get(t);if(_&&d)return _==t&&d==n;var v=-1,x=!0,S=e&Sn?new Rt:i;for(o.set(n,t),o.set(t,n);++v1?"& ":"")+t[r],t=t.join(e>2?", ":" "),n.replace(Ss,`{\n/* [wrapped with `+t+`] */\n`)}function Ac(n){return I(n)||Dt(n)||!!(Qu&&n&&n[Qu])}function ft(n,t){var e=typeof n;return t=t==null?Kn:t,!!t&&(e=="number"||e!="symbol"&&Ds.test(n))&&n>-1&&n%1==0&&n0){if(++t>=Wt)return arguments[0]}else t=0;return n.apply(i,arguments)}}function hr(n,t){var e=-1,r=n.length,u=r-1;for(t=t===i?r:t;++e1?n[t-1]:i;return e=typeof e=="function"?(n.pop(),e):i,so(n,e)});function ao(n){var t=f(n);return t.__chain__=!0,t}function bp(n,t){return t(n),n}function gr(n,t){return t(n)}var Dp=ut(function(n){var t=n.length,e=t?n[0]:0,r=this.__wrapped__,u=function(o){return fi(o,n)};return t>1||this.__actions__.length||!(r instanceof D)||!ft(e)?this.thru(u):(r=r.slice(e,+e+(t?1:0)),r.__actions__.push({func:gr,args:[u],thisArg:i}),new Bn(r,this.__chain__).thru(function(o){return t&&!o.length&&o.push(i),o}))});function Pp(){return ao(this)}function Bp(){return new Bn(this.value(),this.__chain__)}function Wp(){this.__values__===i&&(this.__values__=Co(this.value()));var n=this.__index__>=this.__values__.length,t=n?i:this.__values__[this.__index__++];return{done:n,value:t}}function Up(){return this}function Np(n){for(var t,e=this;e instanceof je;){var r=eo(e);r.__index__=0,r.__values__=i,t?u.__wrapped__=r:t=r;var u=r;e=e.__wrapped__}return u.__wrapped__=n,t}function Gp(){var n=this.__wrapped__;if(n instanceof D){var t=n;return this.__actions__.length&&(t=new D(this)),t=t.reverse(),t.__actions__.push({func:gr,args:[Di],thisArg:i}),new Bn(t,this.__chain__)}return this.thru(Di)}function qp(){return Tf(this.__wrapped__,this.__actions__)}var Kp=fr(function(n,t,e){U.call(n,e)?++n[e]:rt(n,e,1)});function Hp(n,t,e){var r=I(n)?Wu:bl;return e&&dn(n,t,e)&&(t=i),r(n,C(t,3))}function $p(n,t){var e=I(n)?gt:sf;return e(n,C(t,3))}var zp=Bf(ro),kp=Bf(io);function Yp(n,t){return fn(_r(n,t),1)}function Zp(n,t){return fn(_r(n,t),Jn)}function Jp(n,t,e){return e=e===i?1:R(e),fn(_r(n,t),e)}function lo(n,t){var e=I(n)?Dn:yt;return e(n,C(t,3))}function co(n,t){var e=I(n)?ga:of;return e(n,C(t,3))}var Xp=fr(function(n,t,e){U.call(n,e)?n[e].push(t):rt(n,e,[t])});function Qp(n,t,e,r){n=yn(n)?n:Qt(n),e=e&&!r?R(e):0;var u=n.length;return e<0&&(e=nn(u+e,0)),mr(n)?e<=u&&n.indexOf(t,e)>-1:!!u&&Gt(n,t,e)>-1}var Vp=O(function(n,t,e){var r=-1,u=typeof t=="function",o=yn(n)?h(n.length):[];return yt(n,function(s){o[++r]=u?Tn(t,s,e):de(s,t,e)}),o}),jp=fr(function(n,t,e){rt(n,e,t)});function _r(n,t){var e=I(n)?H:gf;return e(n,C(t,3))}function nh(n,t,e,r){return n==null?[]:(I(t)||(t=t==null?[]:[t]),e=r?i:e,I(e)||(e=e==null?[]:[e]),xf(n,t,e))}var th=fr(function(n,t,e){n[e?0:1].push(t)},function(){return[[],[]]});function eh(n,t,e){var r=I(n)?Yr:qu,u=arguments.length<3;return r(n,C(t,4),e,u,yt)}function rh(n,t,e){var r=I(n)?_a:qu,u=arguments.length<3;return r(n,C(t,4),e,u,of)}function ih(n,t){var e=I(n)?gt:sf;return e(n,xr(C(t,3)))}function uh(n){var t=I(n)?ef:Ql;return t(n)}function fh(n,t,e){(e?dn(n,t,e):t===i)?t=1:t=R(t);var r=I(n)?Il:Vl;return r(n,t)}function oh(n){var t=I(n)?Rl:nc;return t(n)}function sh(n){if(n==null)return 0;if(yn(n))return mr(n)?Kt(n):n.length;var t=sn(n);return t==Hn||t==$n?n.size:pi(n).length}function ah(n,t,e){var r=I(n)?Zr:tc;return e&&dn(n,t,e)&&(t=i),r(n,C(t,3))}var lh=O(function(n,t){if(n==null)return[];var e=t.length;return e>1&&dn(n,t[0],t[1])?t=[]:e>2&&dn(t[0],t[1],t[2])&&(t=[t[0]]),xf(n,fn(t,1),[])}),dr=$a||function(){return tn.Date.now()};function ch(n,t){if(typeof t!="function")throw new Pn(m);return n=R(n),function(){if(--n<1)return t.apply(this,arguments)}}function po(n,t,e){return t=e?i:t,t=n&&t==null?n.length:t,it(n,On,i,i,i,i,t)}function ho(n,t){var e;if(typeof t!="function")throw new Pn(m);return n=R(n),function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=i),e}}var Bi=O(function(n,t,e){var r=Y;if(e.length){var u=dt(e,Jt(Bi));r|=V}return it(n,r,t,e,u)}),go=O(function(n,t,e){var r=Y|z;if(e.length){var u=dt(e,Jt(go));r|=V}return it(t,r,n,e,u)});function _o(n,t,e){t=e?i:t;var r=it(n,cn,i,i,i,i,i,t);return r.placeholder=_o.placeholder,r}function vo(n,t,e){t=e?i:t;var r=it(n,En,i,i,i,i,i,t);return r.placeholder=vo.placeholder,r}function xo(n,t,e){var r,u,o,s,a,c,_=0,d=!1,v=!1,x=!0;if(typeof n!="function")throw new Pn(m);t=Gn(t)||0,$(e)&&(d=!!e.leading,v="maxWait"in e,o=v?nn(Gn(e.maxWait)||0,t):o,x="trailing"in e?!!e.trailing:x);function S(J){var Zn=r,at=u;return r=u=i,_=J,s=n.apply(at,Zn),s}function T(J){return _=J,a=we(b,t),d?S(J):s}function L(J){var Zn=J-c,at=J-_,Wo=t-Zn;return v?on(Wo,o-at):Wo}function F(J){var Zn=J-c,at=J-_;return c===i||Zn>=t||Zn<0||v&&at>=o}function b(){var J=dr();if(F(J))return P(J);a=we(b,L(J))}function P(J){return a=i,x&&r?S(J):(r=u=i,s)}function Rn(){a!==i&&Mf(a),_=0,r=c=u=a=i}function vn(){return a===i?s:P(dr())}function Ln(){var J=dr(),Zn=F(J);if(r=arguments,u=this,c=J,Zn){if(a===i)return T(c);if(v)return Mf(a),a=we(b,t),S(c)}return a===i&&(a=we(b,t)),s}return Ln.cancel=Rn,Ln.flush=vn,Ln}var ph=O(function(n,t){return ff(n,1,t)}),hh=O(function(n,t,e){return ff(n,Gn(t)||0,e)});function gh(n){return it(n,qn)}function vr(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new Pn(m);var e=function(){var r=arguments,u=t?t.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var s=n.apply(this,r);return e.cache=o.set(u,s)||o,s};return e.cache=new(vr.Cache||et),e}vr.Cache=et;function xr(n){if(typeof n!="function")throw new Pn(m);return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function _h(n){return ho(2,n)}var dh=ec(function(n,t){t=t.length==1&&I(t[0])?H(t[0],Fn(C())):H(fn(t,1),Fn(C()));var e=t.length;return O(function(r){for(var u=-1,o=on(r.length,e);++u=t}),Dt=cf(function(){return arguments}())?cf:function(n){return k(n)&&U.call(n,"callee")&&!Xu.call(n,"callee")},I=h.isArray,Eh=Eu?Fn(Eu):Nl;function yn(n){return n!=null&&yr(n.length)&&!ot(n)}function Z(n){return k(n)&&yn(n)}function Oh(n){return n===!0||n===!1||k(n)&&_n(n)==te}var St=ka||Zi,bh=Ou?Fn(Ou):Gl;function Dh(n){return k(n)&&n.nodeType===1&&!Ae(n)}function Ph(n){if(n==null)return!0;if(yn(n)&&(I(n)||typeof n=="string"||typeof n.splice=="function"||St(n)||Xt(n)||Dt(n)))return!n.length;var t=sn(n);if(t==Hn||t==$n)return!n.size;if(me(n))return!pi(n).length;for(var e in n)if(U.call(n,e))return!1;return!0}function Bh(n,t){return ve(n,t)}function Wh(n,t,e){e=typeof e=="function"?e:i;var r=e?e(n,t):i;return r===i?ve(n,t,i,e):!!r}function Ui(n){if(!k(n))return!1;var t=_n(n);return t==Ee||t==fs||typeof n.message=="string"&&typeof n.name=="string"&&!Ae(n)}function Uh(n){return typeof n=="number"&&Vu(n)}function ot(n){if(!$(n))return!1;var t=_n(n);return t==Oe||t==uu||t==ht||t==ss}function mo(n){return typeof n=="number"&&n==R(n)}function yr(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Kn}function $(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function k(n){return n!=null&&typeof n=="object"}var wo=bu?Fn(bu):Kl;function Nh(n,t){return n===t||ci(n,t,Ii(t))}function Gh(n,t,e){return e=typeof e=="function"?e:i,ci(n,t,Ii(t),e)}function qh(n){return Ao(n)&&n!=+n}function Kh(n){if(Tc(n))throw new M(A);return pf(n)}function Hh(n){return n===null}function $h(n){return n==null}function Ao(n){return typeof n=="number"||k(n)&&_n(n)==re}function Ae(n){if(!k(n)||_n(n)!=nt)return!1;var t=ke(n);if(t===null)return!0;var e=U.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Ke.call(e)==Ga}var Ni=Du?Fn(Du):Hl;function zh(n){return mo(n)&&n>=-Kn&&n<=Kn}var So=Pu?Fn(Pu):$l;function mr(n){return typeof n=="string"||!I(n)&&k(n)&&_n(n)==ue}function In(n){return typeof n=="symbol"||k(n)&&_n(n)==be}var Xt=Bu?Fn(Bu):zl;function kh(n){return n===i}function Yh(n){return k(n)&&sn(n)==fe}function Zh(n){return k(n)&&_n(n)==ls}var Jh=lr(hi),Xh=lr(function(n,t){return n<=t});function Co(n){if(!n)return[];if(yn(n))return mr(n)?zn(n):xn(n);if(ae&&n[ae])return Ia(n[ae]());var t=sn(n),e=t==Hn?ni:t==$n?Ne:Qt;return e(n)}function st(n){if(!n)return n===0?n:0;if(n=Gn(n),n===Jn||n===-Jn){var t=n<0?-1:1;return t*Ie}return n===n?n:0}function R(n){var t=st(n),e=t%1;return t===t?e?t-e:t:0}function To(n){return n?Lt(R(n),0,Cn):0}function Gn(n){if(typeof n=="number")return n;if(In(n))return Tt;if($(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=$(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=Ku(n);var e=Es.test(n);return e||bs.test(n)?ca(n.slice(2),e?2:8):Ls.test(n)?Tt:+n}function Fo(n){return Qn(n,mn(n))}function Qh(n){return n?Lt(R(n),-Kn,Kn):n===0?n:0}function W(n){return n==null?"":Mn(n)}var Vh=Yt(function(n,t){if(me(t)||yn(t)){Qn(t,en(t),n);return}for(var e in t)U.call(t,e)&&ge(n,e,t[e])}),Mo=Yt(function(n,t){Qn(t,mn(t),n)}),wr=Yt(function(n,t,e,r){Qn(t,mn(t),n,r)}),jh=Yt(function(n,t,e,r){Qn(t,en(t),n,r)}),ng=ut(fi);function tg(n,t){var e=kt(n);return t==null?e:rf(e,t)}var eg=O(function(n,t){n=N(n);var e=-1,r=t.length,u=r>2?t[2]:i;for(u&&dn(t[0],t[1],u)&&(r=1);++e1),o}),Qn(n,Fi(n),e),r&&(e=Wn(e,K|An|an,hc));for(var u=t.length;u--;)xi(e,t[u]);return e});function mg(n,t){return Ro(n,xr(C(t)))}var wg=ut(function(n,t){return n==null?{}:Zl(n,t)});function Ro(n,t){if(n==null)return{};var e=H(Fi(n),function(r){return[r]});return t=C(t),yf(n,e,function(r,u){return t(r,u[0])})}function Ag(n,t,e){t=wt(t,n);var r=-1,u=t.length;for(u||(u=1,n=i);++rt){var r=n;n=t,t=r}if(e||n%1||t%1){var u=ju();return on(n+u*(t-n+la("1e-"+((u+"").length-1))),t)}return _i(n,t)}var bg=Zt(function(n,t,e){return t=t.toLowerCase(),n+(e?Oo(t):t)});function Oo(n){return Ki(W(n).toLowerCase())}function bo(n){return n=W(n),n&&n.replace(Ps,Sa).replace(na,"")}function Dg(n,t,e){n=W(n),t=Mn(t);var r=n.length;e=e===i?r:Lt(R(e),0,r);var u=e;return e-=t.length,e>=0&&n.slice(e,u)==t}function Pg(n){return n=W(n),n&&_s.test(n)?n.replace(su,Ca):n}function Bg(n){return n=W(n),n&&ws.test(n)?n.replace(Wr,"\\\\$&"):n}var Wg=Zt(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()}),Ug=Zt(function(n,t,e){return n+(e?" ":"")+t.toLowerCase()}),Ng=Pf("toLowerCase");function Gg(n,t,e){n=W(n),t=R(t);var r=t?Kt(n):0;if(!t||r>=t)return n;var u=(t-r)/2;return ar(Xe(u),e)+n+ar(Je(u),e)}function qg(n,t,e){n=W(n),t=R(t);var r=t?Kt(n):0;return t&&r>>0,e?(n=W(n),n&&(typeof t=="string"||t!=null&&!Ni(t))&&(t=Mn(t),!t&&qt(n))?At(zn(n),0,e):n.split(t,e)):[]}var Zg=Zt(function(n,t,e){return n+(e?" ":"")+Ki(t)});function Jg(n,t,e){return n=W(n),e=e==null?0:Lt(R(e),0,n.length),t=Mn(t),n.slice(e,e+t.length)==t}function Xg(n,t,e){var r=f.templateSettings;e&&dn(n,t,e)&&(t=i),n=W(n),t=wr({},t,r,Kf);var u=wr({},t.imports,r.imports,Kf),o=en(u),s=jr(u,o),a,c,_=0,d=t.interpolate||De,v="__p += \'",x=ti((t.escape||De).source+"|"+d.source+"|"+(d===au?Rs:De).source+"|"+(t.evaluate||De).source+"|$","g"),S="//# sourceURL="+(U.call(t,"sourceURL")?(t.sourceURL+"").replace(/\\s/g," "):"lodash.templateSources["+ ++ua+"]")+`\n`;n.replace(x,function(F,b,P,Rn,vn,Ln){return P||(P=Rn),v+=n.slice(_,Ln).replace(Bs,Ta),b&&(a=!0,v+=`\' +\n__e(`+b+`) +\n\'`),vn&&(c=!0,v+=`\';\n`+vn+`;\n__p += \'`),P&&(v+=`\' +\n((__t = (`+P+`)) == null ? \'\' : __t) +\n\'`),_=Ln+F.length,F}),v+=`\';\n`;var T=U.call(t,"variable")&&t.variable;if(!T)v=`with (obj) {\n`+v+`\n}\n`;else if(Ms.test(T))throw new M(E);v=(c?v.replace(cs,""):v).replace(ps,"$1").replace(hs,"$1;"),v="function("+(T||"obj")+`) {\n`+(T?"":`obj || (obj = {});\n`)+"var __t, __p = \'\'"+(a?", __e = _.escape":"")+(c?`, __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, \'\') }\n`:`;\n`)+v+`return __p\n}`;var L=Po(function(){return B(o,S+"return "+v).apply(i,s)});if(L.source=v,Ui(L))throw L;return L}function Qg(n){return W(n).toLowerCase()}function Vg(n){return W(n).toUpperCase()}function jg(n,t,e){if(n=W(n),n&&(e||t===i))return Ku(n);if(!n||!(t=Mn(t)))return n;var r=zn(n),u=zn(t),o=Hu(r,u),s=$u(r,u)+1;return At(r,o,s).join("")}function n_(n,t,e){if(n=W(n),n&&(e||t===i))return n.slice(0,ku(n)+1);if(!n||!(t=Mn(t)))return n;var r=zn(n),u=$u(r,zn(t))+1;return At(r,0,u).join("")}function t_(n,t,e){if(n=W(n),n&&(e||t===i))return n.replace(Ur,"");if(!n||!(t=Mn(t)))return n;var r=zn(n),u=Hu(r,zn(t));return At(r,u).join("")}function e_(n,t){var e=Fr,r=Fe;if($(t)){var u="separator"in t?t.separator:u;e="length"in t?R(t.length):e,r="omission"in t?Mn(t.omission):r}n=W(n);var o=n.length;if(qt(n)){var s=zn(n);o=s.length}if(e>=o)return n;var a=e-Kt(r);if(a<1)return r;var c=s?At(s,0,a).join(""):n.slice(0,a);if(u===i)return c+r;if(s&&(a+=c.length-a),Ni(u)){if(n.slice(a).search(u)){var _,d=c;for(u.global||(u=ti(u.source,W(lu.exec(u))+"g")),u.lastIndex=0;_=u.exec(d);)var v=_.index;c=c.slice(0,v===i?a:v)}}else if(n.indexOf(Mn(u),a)!=a){var x=c.lastIndexOf(u);x>-1&&(c=c.slice(0,x))}return c+r}function r_(n){return n=W(n),n&&gs.test(n)?n.replace(ou,Oa):n}var i_=Zt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Ki=Pf("toUpperCase");function Do(n,t,e){return n=W(n),t=e?i:t,t===i?Ma(n)?Pa(n):xa(n):n.match(t)||[]}var Po=O(function(n,t){try{return Tn(n,i,t)}catch(e){return Ui(e)?e:new M(e)}}),u_=ut(function(n,t){return Dn(t,function(e){e=Vn(e),rt(n,e,Bi(n[e],n))}),n});function f_(n){var t=n==null?0:n.length,e=C();return n=t?H(n,function(r){if(typeof r[1]!="function")throw new Pn(m);return[e(r[0]),r[1]]}):[],O(function(r){for(var u=-1;++uKn)return[];var e=Cn,r=on(n,Cn);t=C(t),n-=Cn;for(var u=Vr(r,t);++e0||t<0)?new D(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=R(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},D.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},D.prototype.toArray=function(){return this.take(Cn)},Xn(D.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),u=f[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);!u||(f.prototype[t]=function(){var s=this.__wrapped__,a=r?[1]:arguments,c=s instanceof D,_=a[0],d=c||I(s),v=function(b){var P=u.apply(f,_t([b],a));return r&&x?P[0]:P};d&&e&&typeof _=="function"&&_.length!=1&&(c=d=!1);var x=this.__chain__,S=!!this.__actions__.length,T=o&&!x,L=c&&!S;if(!o&&d){s=L?s:new D(this);var F=n.apply(s,a);return F.__actions__.push({func:gr,args:[v],thisArg:i}),new Bn(F,x)}return T&&L?n.apply(this,a):(F=this.thru(v),T?r?F.value()[0]:F.value():F)})}),Dn(["pop","push","shift","sort","splice","unshift"],function(n){var t=Ge[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);f.prototype[n]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(I(o)?o:[],u)}return this[e](function(s){return t.apply(I(s)?s:[],u)})}}),Xn(D.prototype,function(n,t){var e=f[t];if(e){var r=e.name+"";U.call(zt,r)||(zt[r]=[]),zt[r].push({name:t,func:e})}}),zt[or(i,z).name]=[{name:"wrapper",func:i}],D.prototype.clone=rl,D.prototype.reverse=il,D.prototype.value=ul,f.prototype.at=Dp,f.prototype.chain=Pp,f.prototype.commit=Bp,f.prototype.next=Wp,f.prototype.plant=Np,f.prototype.reverse=Gp,f.prototype.toJSON=f.prototype.valueOf=f.prototype.value=qp,f.prototype.first=f.prototype.head,ae&&(f.prototype[ae]=Up),f},vt=Ba();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(tn._=vt,define(function(){return vt})):Ft?((Ft.exports=vt)._=vt,$r._=vt):tn._=vt}).call(Vt)});var iu=j_(qo());var Ko="banner",Xi="alias",Qi="sticker",Vi="color";var lt=i=>[...new Set(i)],Ho=i=>[...new Map(i.map(p=>[p.toLowerCase(),p])).values()];var $o=i=>{var p;try{p=JSON.parse(i)}catch(y){}return p};var ko=(i,p)=>p.indexOf(i)>0?p.indexOf(i):p.length,n0=i=>i.substring(0,i.length-2),ji=i=>i.replace(/\\//g,"+")+"//";var t0=i=>i.charAt(0)=="#"?i.substring(1,i.length):i;var e0=i=>i.charAt(0)=="/"?i.substring(1):i;var zo=i=>e0(i.substring(i.lastIndexOf("/")))||i,nu=i=>i?(i==null?void 0:i.type)=="folder"?zo(i.contextPath):(i==null?void 0:i.type)=="tag"?t0(i.contextPath):(i==null?void 0:i.type)=="space"?n0(i.contextPath):i.isRemote?zo(i.contextPath):i.contextPath:"";var ct=i=>{var p;return(p=i==null?void 0:i.match(/(\\\\.|[^,])+/g))!=null?p:[]},Yo=i=>{if(!i)return"";let p=/\\[\\[(.*?)\\]\\]/g.exec(i),y=(p==null?void 0:p.length)>1?p[1].substring(0,ko("|",p[1])):i;return y||i};var Zo=i=>{var p;return!i||i.length==0?[]:i.charAt(0)=="#"?i.split("&").map(y=>({type:"tag",value:y})):(p=$o(i))!=null?p:[]};var Ce=(i,p)=>{if(typeof i=="string"){if(/\\/\\/(\\S+?(?:jpe?g|png|gif|svg))/gi.test(i)||i.includes("unsplash"))return"image";if(/^\\d{4}-\\d{2}-\\d{2}$/.test(i))return"date";if(p=="tag"||p=="tags")return"tag";if(/\\[\\[.*?\\]\\]/.test(i))return"link"}else{if(typeof i=="number")return"number";if(typeof i=="boolean")return"boolean";if(i)if(Array.isArray(i)||typeof i=="string"&&i.indexOf(",")>-1){let y=Array.isArray(i)?i:[];if(typeof i=="string"&&i.indexOf(",")>-1&&(y=ct(i)),p=="tag"||p=="tags")return"tag-multi";if(y.length==1&&Array.isArray(y[0])&&y[0].length==1&&typeof y[0][0]=="string")return"link";let A=lt(y.map(m=>Ce(m,p)));return A.length==1&&A[0]=="link"?"link-multi":"option-multi"}else{if(i.isLuxonDateTime)return"date";if(i.isLuxonDuration)return"duration";if(i.type=="file")return"link";if(typeof i=="object"&&!Array.isArray(i)&&i!==null)return"object"}else return"unknown"}return"text"};var Jo=i=>Object.keys(i!=null?i:{}).filter(p=>p!="position").filter(p=>p!="tag"&&p!="tags");var jt=i=>i.join(","),Xo=i=>i.join(", ");var Ar=(i,p)=>{switch(Ce(p,i)){case"object":return JSON.stringify(p);case"number":return p.toString();case"boolean":return p?"true":"false";case"date":return p;case"duration":return Xo(Object.keys(p.values).reduce((A,m)=>[...A,...p.values[m]>0?[p.values[m]+" "+m]:[]],[]));case"option-multi":case"link-multi":return typeof p=="string"?p:jt(p.map(A=>A?typeof A=="string"?A:A.path?A.path:Array.isArray(p)&&A.length==1&&Array.isArray(A[0])&&A[0].length==1&&typeof A[0][0]=="string"?A[0][0]:JSON.stringify(A):""));case"link":return Array.isArray(p)&&p.length==1&&Array.isArray(p[0])&&p[0].length==1&&typeof p[0][0]=="string"?p[0][0]:typeof p=="string"?p:p.path;case"text":case"tag":case"image":return p}return""};var Qo=i=>{switch(i){case"duration":return"text";case"unknown":return"text"}return i};var Sr=(i,p)=>i==p,tu=(i,p)=>(i!=null?i:"").length==0,eu=(i,p)=>(i!=null?i:"").toLowerCase().includes((p!=null?p:"").toLowerCase()),Cr=(i,p)=>parseFloat(i)>parseFloat(p),Tr=(i,p)=>parseInt(i)>parseInt(p),ru=(i,p)=>{let y=i?ct(i):[];return(p?ct(p):[]).some(m=>y.some(E=>E==m))};var Te={isNotEmpty:{type:["text","file","link","link-multi","fileprop","image"],fn:(i,p)=>!tu(i,""),valueType:"none"},isEmpty:{type:["text","file","link","link-multi","fileprop","image"],fn:(i,p)=>tu(i,""),valueType:"none"},include:{fn:(i,p)=>eu(i,p),type:["text","file","link","link-multi","fileprop","image"],valueType:"text"},notInclude:{type:["text","file","link","link-multi","fileprop","image"],fn:(i,p)=>!eu(i,p),valueType:"text"},is:{type:["text","file","link","context","fileprop"],fn:Sr,valueType:"text"},isNot:{type:["text","file","link","context","fileprop"],fn:(i,p)=>!Sr(i,p),valueType:"text"},equal:{type:["number"],fn:Sr,valueType:"number"},isGreatThan:{type:["number"],fn:Cr,valueType:"number"},isLessThan:{type:["number"],fn:Tr,valueType:"number"},isLessThanOrEqual:{type:["number"],fn:(i,p)=>!Cr(i,p),valueType:"number"},isGreatThanOrEqual:{type:["number"],fn:(i,p)=>!Tr(i,p),valueType:"number"},dateBefore:{type:["date","fileprop"],fn:Tr,valueType:"date"},dateAfter:{type:["date","fileprop"],fn:Cr,valueType:"date"},isAnyInList:{type:["option","context","option-multi","context-multi","tags-multi","tags"],fn:ru,valueType:"list"},isNoneInList:{type:["option","context","option-multi","context-multi","tags-multi","tags"],fn:(i,p)=>!ru(i,p),valueType:"list"},isTrue:{type:["boolean"],fn:(i,p)=>i=="true",valueType:"none"},isFalse:{type:["boolean"],fn:(i,p)=>i!="true",valueType:"none"}};var r0=(i,p)=>p.reduce((A,m)=>{let[E,Q]=A,rn=m.type=="fileprop"?ns(Q,m):m.type=="filemeta"?jo(Q,m):m.type=="frontmatter"?Vo(Q,m):[],un=Q.filter(K=>!rn.includes(K));return[[...E,...rn],un]},[[],i])[0],i0=(i,p)=>p.reduce((y,A)=>A.type=="fileprop"?ns(y,A):A.type=="filemeta"?jo(y,A):A.type=="frontmatter"?Vo(y,A):[],i),Vo=(i,p)=>i.filter(y=>{let A=y.frontmatter;if(!A||!A[p.field])return!1;let m=Te[p.fn],E=!0;return m&&(E=m.fn(Ar(p.field,A[p.field]),p.value)),E}),jo=(i,p)=>i.filter(y=>{let A="";p.field=="outlinks"?A=jt(y.outlinks):p.field=="inlinks"?A=jt(y.inlinks):p.field=="tags"&&(A=jt(y.tags));let m=Te[p.fn],E=!0;return m&&(E=m.fn(A,p.value)),E}),ns=(i,p)=>i.filter(y=>{if(["path","sticker","color","isFolder","extension","ctime","mtime","size","parent"].includes(p.field)){let m=Te[p.fn],E=!0;return m&&(E=m.fn(y[p.field],p.value)),E}return!0}),ts=(i,p)=>i.filters.reduce((m,E)=>m&&(E.type=="any"?r0([p],E.filters).length>0:i0([p],E.filters).length>0),!0);var es=(i,p,y)=>{var An,an,ln,Sn,Y,z;if(!p)return{changed:!1,cache:{path:i.dbPath,info:i,name:nu(i),sticker:"",banner:"",cols:[],files:[],rows:[],def:[],defContexts:[],outlinks:[],contexts:[]}};let A=(an=(An=p.cols)==null?void 0:An.filter(X=>X.type.startsWith("context")))!=null?an:[],m=(Sn=(ln=p.cols)==null?void 0:ln.filter(X=>X.type.startsWith("link")))!=null?Sn:[],E=lt(A.map(X=>X.value)),Q=lt(p.rows.reduce((X,cn)=>lt([...X,...[...A,...m].flatMap(En=>ct(cn[En.name]).map(V=>Yo(V)))]),[])),rn=Zo(p.schema.def),un={path:i.dbPath,info:i,name:nu(i),sticker:"",banner:"",cols:p.cols,files:(Y=p.rows.map(X=>X.File))!=null?Y:[],rows:(z=p.rows)!=null?z:[],defContexts:rn.filter(X=>X.type=="tag").map(X=>X.value),def:rn,contexts:E,outlinks:Q},K=!0;return y&&iu.default.isEqual(un,y)&&(K=!0),{changed:K,cache:un}},u0=i=>{var y,A,m,E,Q,rn,un,K,An,an,ln,Sn,Y;let p=[];return i&&i.tags&&p.push(...(A=(y=i.tags)==null?void 0:y.map(z=>z.tag))!=null?A:[]),i&&((m=i.frontmatter)==null?void 0:m.tags)&&p.push(...(typeof((E=i.frontmatter)==null?void 0:E.tags)=="string"?ct(i.frontmatter.tags.replace(/ /g,"")):Array.isArray((Q=i.frontmatter)==null?void 0:Q.tags)?(un=(rn=i.frontmatter)==null?void 0:rn.tags)!=null?un:[]:[]).filter(z=>typeof z=="string").map(z=>"#"+z)),i&&((K=i.frontmatter)==null?void 0:K.tag)&&p.push(...(typeof((An=i.frontmatter)==null?void 0:An.tag)=="string"?ct(i.frontmatter.tag.replace(/ /g,"")):Array.isArray((an=i.frontmatter)==null?void 0:an.tag)?(Sn=(ln=i.frontmatter)==null?void 0:ln.tag)!=null?Sn:[]:[]).filter(z=>typeof z=="string").map(z=>"#"+z)),(Y=lt(p))!=null?Y:[]};var f0=(i,p,y,A)=>{let m=[];return m.push(...p.filter(E=>y.has(E))),i.parent!="/"&&m.push(i.parent),A.forEach(E=>{y.has(ji(E))&&m.push(ji(E))}),m},rs=(i,p,y,A,m,E,Q,rn,un)=>{var Kn,Ie,Tt,Cn,Re,Le;let K={path:i.path,name:i.name};i.stat&&(K.ctime=i.stat.ctime,K.mtime=i.stat.mtime,K.size=i.stat.size,K.extension=i.extension);let An=[],an=u0(E);if(y.has(i.parent))for(let pn of y.get(i.parent).def)pn.type=="tag"&&An.push(pn.value);An.push(...an);let ln=i.name,Sn=(Kn=m==null?void 0:m.sticker)!=null?Kn:"",Y=(Ie=m==null?void 0:m.color)!=null?Ie:"",z=(Tt=m==null?void 0:m.rank)!=null?Tt:"",X=(Cn=m==null?void 0:m.folder)!=null?Cn:"";X=="true"&&(X="");let cn=i.parent,En=i.isFolder,V={},jn={},On=[],pt=[],qn=E==null?void 0:E.frontmatter;E!=null&&E.links&&pt.push(...E.links.map(pn=>pn.link));let Fr=rn&&En?rn.folderNotePath:i.path;for(let pn of Object.keys(Q))Fr in Q[pn]&&On.push(pn);let Fe="";if(qn){let hn=Ho(Jo(qn)).reduce((gn,ht)=>Bt(Pt({},gn),{[ht]:{name:ht,type:Qo(Ce(qn[ht],ht))}}),{});Object.keys(hn).forEach(gn=>{V[gn]=Ar(gn,qn[gn]),jn[gn]=hn[gn].type}),Fe=(Re=V[Ko])!=null?Re:"",V[Qi]&&(Sn=qn[Qi]),V[Vi]&&(Y=qn[Vi]),V[Xi]&&p.spacesUseAlias&&(ln=qn[Xi])}let Wt=Bt(Pt({},K),{name:ln,tags:lt(An),fileTags:an,folderNote:rn,sticker:Sn,color:Y,rank:z,parent:cn,banner:Fe,isFolder:En,folderSort:X,frontmatter:V,frontmatterTypes:jn,inlinks:On,outlinks:pt}),Ct=[],ne={};for(let[pn,hn]of A)if(hn.space.def.type=="smart")ts(hn.space.def,Wt)&&Ct.push(pn);else if(((Le=hn.space.def.folder)==null?void 0:Le.length)>0)hn.space.def.folder==cn&&Ct.push(pn);else{let gn=hn.spaceItems.find(ht=>ht.path==Wt.path);gn&&(Ct.push(pn),ne[pn]=gn.rank)}let Mr=f0(i,An,y,Ct),Me=rn&&!En?Bt(Pt({},Wt),{spaces:[],contexts:[]}):Bt(Pt({},Wt),{spaces:Ct,contexts:lt(Mr),spaceRanks:ne}),Jn=!0;return un&&iu.default.isEqual(Me,un)&&(Jn=!1),{changed:Jn,cache:Me}};function is(i){let{file:p,settings:y,contextsCache:A,spacesCache:m,vaultItem:E,metadataCache:Q,resolvedLinks:rn,folderNote:un,oldMetadata:K}=i;return rs(p,y,A,m,E,Q,rn,un,K)}function us(i){let{context:p,mdbTable:y,oldCache:A}=i;return es(p,y,A)}var o0=self;o0.onmessage=async i=>{let{payload:p,job:y}=i.data,A;y.type=="file"?A=is(p):y.type=="context"&&(A=us(p));try{postMessage({job:y,result:A})}catch(m){console.log(m),postMessage({job:y,result:{$error:`Failed to index ${y.type} ${y.path}: ${m}`}})}};\n/**\n * @license\n * Lodash \n * Copyright OpenJS Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n'); + return inlineWorker('var $_=Object.create;var Ji=Object.defineProperty,z_=Object.defineProperties,k_=Object.getOwnPropertyDescriptor,Y_=Object.getOwnPropertyDescriptors,Z_=Object.getOwnPropertyNames,Uo=Object.getOwnPropertySymbols,J_=Object.getPrototypeOf,Go=Object.prototype.hasOwnProperty,X_=Object.prototype.propertyIsEnumerable;var No=(i,p,y)=>p in i?Ji(i,p,{enumerable:!0,configurable:!0,writable:!0,value:y}):i[p]=y,Pt=(i,p)=>{for(var y in p||(p={}))Go.call(p,y)&&No(i,y,p[y]);if(Uo)for(var y of Uo(p))X_.call(p,y)&&No(i,y,p[y]);return i},Bt=(i,p)=>z_(i,Y_(p));var Q_=(i,p)=>()=>(p||i((p={exports:{}}).exports,p),p.exports);var V_=(i,p,y,A)=>{if(p&&typeof p=="object"||typeof p=="function")for(let m of Z_(p))!Go.call(i,m)&&m!==y&&Ji(i,m,{get:()=>p[m],enumerable:!(A=k_(p,m))||A.enumerable});return i};var j_=(i,p,y)=>(y=i!=null?$_(J_(i)):{},V_(p||!i||!i.__esModule?Ji(y,"default",{value:i,enumerable:!0}):y,i));var qo=Q_((jt,Se)=>{(function(){var i,p="4.17.21",y=200,A="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",m="Expected a function",E="Invalid `variable` option passed into `_.template`",Q="__lodash_hash_undefined__",rn=500,un="__lodash_placeholder__",K=1,An=2,ln=4,cn=1,Sn=2,Y=1,$=2,X=4,pn=8,En=16,V=32,jn=64,On=128,pt=256,qn=512,Fr=30,Fe="...",Wt=800,Ct=16,Ut=1,Mr=2,Me=3,Jn=1/0,Kn=9007199254740991,Ie=17976931348623157e292,Tt=0/0,Cn=4294967295,Re=Cn-1,Le=Cn>>>1,on=[["ary",On],["bind",Y],["bindKey",$],["curry",pn],["curryRight",En],["flip",qn],["partial",V],["partialRight",jn],["rearg",pt]],hn="[object Arguments]",gn="[object Array]",ht="[object AsyncFunction]",te="[object Boolean]",ee="[object Date]",fs="[object DOMException]",Ee="[object Error]",Oe="[object Function]",uu="[object GeneratorFunction]",Hn="[object Map]",re="[object Number]",os="[object Null]",nt="[object Object]",fu="[object Promise]",ss="[object Proxy]",ie="[object RegExp]",$n="[object Set]",ue="[object String]",be="[object Symbol]",as="[object Undefined]",fe="[object WeakMap]",ls="[object WeakSet]",oe="[object ArrayBuffer]",Nt="[object DataView]",Ir="[object Float32Array]",Rr="[object Float64Array]",Lr="[object Int8Array]",Er="[object Int16Array]",Or="[object Int32Array]",br="[object Uint8Array]",Dr="[object Uint8ClampedArray]",Pr="[object Uint16Array]",Br="[object Uint32Array]",cs=/\\b__p \\+= \'\';/g,ps=/\\b(__p \\+=) \'\' \\+/g,hs=/(__e\\(.*?\\)|\\b__t\\)) \\+\\n\'\';/g,ou=/&(?:amp|lt|gt|quot|#39);/g,su=/[&<>"\']/g,gs=RegExp(ou.source),_s=RegExp(su.source),ds=/<%-([\\s\\S]+?)%>/g,vs=/<%([\\s\\S]+?)%>/g,au=/<%=([\\s\\S]+?)%>/g,xs=/\\.|\\[(?:[^[\\]]*|(["\'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,ys=/^\\w*$/,ms=/[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g,Wr=/[\\\\^$.*+?()[\\]{}|]/g,ws=RegExp(Wr.source),Ur=/^\\s+/,As=/\\s/,Ss=/\\{(?:\\n\\/\\* \\[wrapped with .+\\] \\*\\/)?\\n?/,Cs=/\\{\\n\\/\\* \\[wrapped with (.+)\\] \\*/,Ts=/,? & /,Fs=/[^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]+/g,Ms=/[()=,{}\\[\\]\\/\\s]/,Is=/\\\\(\\\\)?/g,Rs=/\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g,lu=/\\w*$/,Ls=/^[-+]0x[0-9a-f]+$/i,Es=/^0b[01]+$/i,Os=/^\\[object .+?Constructor\\]$/,bs=/^0o[0-7]+$/i,Ds=/^(?:0|[1-9]\\d*)$/,Ps=/[\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\xff\\u0100-\\u017f]/g,De=/($^)/,Bs=/[\'\\n\\r\\u2028\\u2029\\\\]/g,Pe="\\\\ud800-\\\\udfff",Ws="\\\\u0300-\\\\u036f",Us="\\\\ufe20-\\\\ufe2f",Ns="\\\\u20d0-\\\\u20ff",cu=Ws+Us+Ns,pu="\\\\u2700-\\\\u27bf",hu="a-z\\\\xdf-\\\\xf6\\\\xf8-\\\\xff",Gs="\\\\xac\\\\xb1\\\\xd7\\\\xf7",qs="\\\\x00-\\\\x2f\\\\x3a-\\\\x40\\\\x5b-\\\\x60\\\\x7b-\\\\xbf",Ks="\\\\u2000-\\\\u206f",Hs=" \\\\t\\\\x0b\\\\f\\\\xa0\\\\ufeff\\\\n\\\\r\\\\u2028\\\\u2029\\\\u1680\\\\u180e\\\\u2000\\\\u2001\\\\u2002\\\\u2003\\\\u2004\\\\u2005\\\\u2006\\\\u2007\\\\u2008\\\\u2009\\\\u200a\\\\u202f\\\\u205f\\\\u3000",gu="A-Z\\\\xc0-\\\\xd6\\\\xd8-\\\\xde",_u="\\\\ufe0e\\\\ufe0f",du=Gs+qs+Ks+Hs,Nr="[\'\\u2019]",$s="["+Pe+"]",vu="["+du+"]",Be="["+cu+"]",xu="\\\\d+",zs="["+pu+"]",yu="["+hu+"]",mu="[^"+Pe+du+xu+pu+hu+gu+"]",Gr="\\\\ud83c[\\\\udffb-\\\\udfff]",ks="(?:"+Be+"|"+Gr+")",wu="[^"+Pe+"]",qr="(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}",Kr="[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]",Gt="["+gu+"]",Au="\\\\u200d",Su="(?:"+yu+"|"+mu+")",Ys="(?:"+Gt+"|"+mu+")",Cu="(?:"+Nr+"(?:d|ll|m|re|s|t|ve))?",Tu="(?:"+Nr+"(?:D|LL|M|RE|S|T|VE))?",Fu=ks+"?",Mu="["+_u+"]?",Zs="(?:"+Au+"(?:"+[wu,qr,Kr].join("|")+")"+Mu+Fu+")*",Js="\\\\d*(?:1st|2nd|3rd|(?![123])\\\\dth)(?=\\\\b|[A-Z_])",Xs="\\\\d*(?:1ST|2ND|3RD|(?![123])\\\\dTH)(?=\\\\b|[a-z_])",Iu=Mu+Fu+Zs,Qs="(?:"+[zs,qr,Kr].join("|")+")"+Iu,Vs="(?:"+[wu+Be+"?",Be,qr,Kr,$s].join("|")+")",js=RegExp(Nr,"g"),na=RegExp(Be,"g"),Hr=RegExp(Gr+"(?="+Gr+")|"+Vs+Iu,"g"),ta=RegExp([Gt+"?"+yu+"+"+Cu+"(?="+[vu,Gt,"$"].join("|")+")",Ys+"+"+Tu+"(?="+[vu,Gt+Su,"$"].join("|")+")",Gt+"?"+Su+"+"+Cu,Gt+"+"+Tu,Xs,Js,xu,Qs].join("|"),"g"),ea=RegExp("["+Au+Pe+cu+_u+"]"),ra=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ia=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ua=-1,q={};q[Ir]=q[Rr]=q[Lr]=q[Er]=q[Or]=q[br]=q[Dr]=q[Pr]=q[Br]=!0,q[hn]=q[gn]=q[oe]=q[te]=q[Nt]=q[ee]=q[Ee]=q[Oe]=q[Hn]=q[re]=q[nt]=q[ie]=q[$n]=q[ue]=q[fe]=!1;var G={};G[hn]=G[gn]=G[oe]=G[Nt]=G[te]=G[ee]=G[Ir]=G[Rr]=G[Lr]=G[Er]=G[Or]=G[Hn]=G[re]=G[nt]=G[ie]=G[$n]=G[ue]=G[be]=G[br]=G[Dr]=G[Pr]=G[Br]=!0,G[Ee]=G[Oe]=G[fe]=!1;var fa={\\u00C0:"A",\\u00C1:"A",\\u00C2:"A",\\u00C3:"A",\\u00C4:"A",\\u00C5:"A",\\u00E0:"a",\\u00E1:"a",\\u00E2:"a",\\u00E3:"a",\\u00E4:"a",\\u00E5:"a",\\u00C7:"C",\\u00E7:"c",\\u00D0:"D",\\u00F0:"d",\\u00C8:"E",\\u00C9:"E",\\u00CA:"E",\\u00CB:"E",\\u00E8:"e",\\u00E9:"e",\\u00EA:"e",\\u00EB:"e",\\u00CC:"I",\\u00CD:"I",\\u00CE:"I",\\u00CF:"I",\\u00EC:"i",\\u00ED:"i",\\u00EE:"i",\\u00EF:"i",\\u00D1:"N",\\u00F1:"n",\\u00D2:"O",\\u00D3:"O",\\u00D4:"O",\\u00D5:"O",\\u00D6:"O",\\u00D8:"O",\\u00F2:"o",\\u00F3:"o",\\u00F4:"o",\\u00F5:"o",\\u00F6:"o",\\u00F8:"o",\\u00D9:"U",\\u00DA:"U",\\u00DB:"U",\\u00DC:"U",\\u00F9:"u",\\u00FA:"u",\\u00FB:"u",\\u00FC:"u",\\u00DD:"Y",\\u00FD:"y",\\u00FF:"y",\\u00C6:"Ae",\\u00E6:"ae",\\u00DE:"Th",\\u00FE:"th",\\u00DF:"ss",\\u0100:"A",\\u0102:"A",\\u0104:"A",\\u0101:"a",\\u0103:"a",\\u0105:"a",\\u0106:"C",\\u0108:"C",\\u010A:"C",\\u010C:"C",\\u0107:"c",\\u0109:"c",\\u010B:"c",\\u010D:"c",\\u010E:"D",\\u0110:"D",\\u010F:"d",\\u0111:"d",\\u0112:"E",\\u0114:"E",\\u0116:"E",\\u0118:"E",\\u011A:"E",\\u0113:"e",\\u0115:"e",\\u0117:"e",\\u0119:"e",\\u011B:"e",\\u011C:"G",\\u011E:"G",\\u0120:"G",\\u0122:"G",\\u011D:"g",\\u011F:"g",\\u0121:"g",\\u0123:"g",\\u0124:"H",\\u0126:"H",\\u0125:"h",\\u0127:"h",\\u0128:"I",\\u012A:"I",\\u012C:"I",\\u012E:"I",\\u0130:"I",\\u0129:"i",\\u012B:"i",\\u012D:"i",\\u012F:"i",\\u0131:"i",\\u0134:"J",\\u0135:"j",\\u0136:"K",\\u0137:"k",\\u0138:"k",\\u0139:"L",\\u013B:"L",\\u013D:"L",\\u013F:"L",\\u0141:"L",\\u013A:"l",\\u013C:"l",\\u013E:"l",\\u0140:"l",\\u0142:"l",\\u0143:"N",\\u0145:"N",\\u0147:"N",\\u014A:"N",\\u0144:"n",\\u0146:"n",\\u0148:"n",\\u014B:"n",\\u014C:"O",\\u014E:"O",\\u0150:"O",\\u014D:"o",\\u014F:"o",\\u0151:"o",\\u0154:"R",\\u0156:"R",\\u0158:"R",\\u0155:"r",\\u0157:"r",\\u0159:"r",\\u015A:"S",\\u015C:"S",\\u015E:"S",\\u0160:"S",\\u015B:"s",\\u015D:"s",\\u015F:"s",\\u0161:"s",\\u0162:"T",\\u0164:"T",\\u0166:"T",\\u0163:"t",\\u0165:"t",\\u0167:"t",\\u0168:"U",\\u016A:"U",\\u016C:"U",\\u016E:"U",\\u0170:"U",\\u0172:"U",\\u0169:"u",\\u016B:"u",\\u016D:"u",\\u016F:"u",\\u0171:"u",\\u0173:"u",\\u0174:"W",\\u0175:"w",\\u0176:"Y",\\u0177:"y",\\u0178:"Y",\\u0179:"Z",\\u017B:"Z",\\u017D:"Z",\\u017A:"z",\\u017C:"z",\\u017E:"z",\\u0132:"IJ",\\u0133:"ij",\\u0152:"Oe",\\u0153:"oe",\\u0149:"\'n",\\u017F:"s"},oa={"&":"&","<":"<",">":">",\'"\':""","\'":"'"},sa={"&":"&","<":"<",">":">",""":\'"\',"'":"\'"},aa={"\\\\":"\\\\","\'":"\'","\\n":"n","\\r":"r","\\u2028":"u2028","\\u2029":"u2029"},la=parseFloat,ca=parseInt,Ru=typeof global=="object"&&global&&global.Object===Object&&global,pa=typeof self=="object"&&self&&self.Object===Object&&self,tn=Ru||pa||Function("return this")(),$r=typeof jt=="object"&&jt&&!jt.nodeType&&jt,Ft=$r&&typeof Se=="object"&&Se&&!Se.nodeType&&Se,Lu=Ft&&Ft.exports===$r,zr=Lu&&Ru.process,bn=function(){try{var l=Ft&&Ft.require&&Ft.require("util").types;return l||zr&&zr.binding&&zr.binding("util")}catch(g){}}(),Eu=bn&&bn.isArrayBuffer,Ou=bn&&bn.isDate,bu=bn&&bn.isMap,Du=bn&&bn.isRegExp,Pu=bn&&bn.isSet,Bu=bn&&bn.isTypedArray;function Tn(l,g,h){switch(h.length){case 0:return l.call(g);case 1:return l.call(g,h[0]);case 2:return l.call(g,h[0],h[1]);case 3:return l.call(g,h[0],h[1],h[2])}return l.apply(g,h)}function ha(l,g,h,w){for(var M=-1,B=l==null?0:l.length;++M-1}function kr(l,g,h){for(var w=-1,M=l==null?0:l.length;++w-1;);return h}function $u(l,g){for(var h=l.length;h--&&qt(g,l[h],0)>-1;);return h}function Aa(l,g){for(var h=l.length,w=0;h--;)l[h]===g&&++w;return w}var Sa=Xr(fa),Ca=Xr(oa);function Ta(l){return"\\\\"+aa[l]}function Fa(l,g){return l==null?i:l[g]}function Kt(l){return ea.test(l)}function Ma(l){return ra.test(l)}function Ia(l){for(var g,h=[];!(g=l.next()).done;)h.push(g.value);return h}function ni(l){var g=-1,h=Array(l.size);return l.forEach(function(w,M){h[++g]=[M,w]}),h}function zu(l,g){return function(h){return l(g(h))}}function dt(l,g){for(var h=-1,w=l.length,M=0,B=[];++h-1}function _l(n,t){var e=this.__data__,r=nr(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}tt.prototype.clear=cl,tt.prototype.delete=pl,tt.prototype.get=hl,tt.prototype.has=gl,tt.prototype.set=_l;function et(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t=t?n:t)),n}function Wn(n,t,e,r,u,o){var s,a=t&K,c=t&An,_=t&ln;if(e&&(s=u?e(n,r,u,o):e(n)),s!==i)return s;if(!z(n))return n;var d=I(n);if(d){if(s=yc(n),!a)return xn(n,s)}else{var v=an(n),x=v==Oe||v==uu;if(St(n))return If(n,a);if(v==nt||v==hn||x&&!u){if(s=c||x?{}:Yf(n),!a)return c?sc(n,El(s,n)):oc(n,rf(s,n))}else{if(!G[v])return u?n:{};s=mc(n,v,a)}}o||(o=new kn);var S=o.get(n);if(S)return S;o.set(n,s),So(n)?n.forEach(function(F){s.add(Wn(F,t,e,F,n,o))}):wo(n)&&n.forEach(function(F,b){s.set(b,Wn(F,t,e,b,n,o))});var T=_?c?Fi:Ti:c?mn:en,L=d?i:T(n);return Dn(L||n,function(F,b){L&&(b=F,F=n[b]),ge(s,b,Wn(F,t,e,b,n,o))}),s}function Ol(n){var t=en(n);return function(e){return uf(e,n,t)}}function uf(n,t,e){var r=e.length;if(n==null)return!r;for(n=N(n);r--;){var u=e[r],o=t[u],s=n[u];if(s===i&&!(u in n)||!o(s))return!1}return!0}function ff(n,t,e){if(typeof n!="function")throw new Pn(m);return we(function(){n.apply(i,e)},t)}function _e(n,t,e,r){var u=-1,o=We,s=!0,a=n.length,c=[],_=t.length;if(!a)return c;e&&(t=H(t,Fn(e))),r?(o=kr,s=!1):t.length>=y&&(o=se,s=!1,t=new Rt(t));n:for(;++uu?0:u+e),r=r===i||r>u?u:R(r),r<0&&(r+=u),r=e>r?0:To(r);e0&&e(a)?t>1?fn(a,t-1,e,r,u):_t(u,a):r||(u[u.length]=a)}return u}var oi=Df(),af=Df(!0);function Xn(n,t){return n&&oi(n,t,en)}function si(n,t){return n&&af(n,t,en)}function er(n,t){return gt(t,function(e){return ot(n[e])})}function Et(n,t){t=wt(t,n);for(var e=0,r=t.length;n!=null&&et}function Pl(n,t){return n!=null&&U.call(n,t)}function Bl(n,t){return n!=null&&t in N(n)}function Wl(n,t,e){return n>=sn(t,e)&&n=120&&d.length>=120)?new Rt(s&&d):i}d=n[0];var v=-1,x=a[0];n:for(;++v-1;)a!==n&&Ye.call(a,c,1),Ye.call(n,c,1);return n}function mf(n,t){for(var e=n?t.length:0,r=e-1;e--;){var u=t[e];if(e==r||u!==o){var o=u;ft(u)?Ye.call(n,u,1):xi(n,u)}}return n}function _i(n,t){return n+Xe(ju()*(t-n+1))}function Xl(n,t,e,r){for(var u=-1,o=nn(Je((t-n)/(e||1)),0),s=h(o);o--;)s[r?o:++u]=n,n+=e;return s}function di(n,t){var e="";if(!n||t<1||t>Kn)return e;do t%2&&(e+=n),t=Xe(t/2),t&&(n+=n);while(t);return e}function O(n,t){return bi(Xf(n,t,wn),n+"")}function Ql(n){return ef(Vt(n))}function Vl(n,t){var e=Vt(n);return hr(e,Lt(t,0,e.length))}function xe(n,t,e,r){if(!z(n))return n;t=wt(t,n);for(var u=-1,o=t.length,s=o-1,a=n;a!=null&&++uu?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=h(u);++r>>1,s=n[o];s!==null&&!In(s)&&(e?s<=t:s=y){var _=t?null:pc(n);if(_)return Ne(_);s=!1,u=se,c=new Rt}else c=t?[]:a;n:for(;++r=r?n:Un(n,t,e)}var Mf=Ha||function(n){return tn.clearTimeout(n)};function If(n,t){if(t)return n.slice();var e=n.length,r=Zu?Zu(e):new n.constructor(e);return n.copy(r),r}function Ai(n){var t=new n.constructor(n.byteLength);return new ze(t).set(new ze(n)),t}function rc(n,t){var e=t?Ai(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}function ic(n){var t=new n.constructor(n.source,lu.exec(n));return t.lastIndex=n.lastIndex,t}function uc(n){return he?N(he.call(n)):{}}function Rf(n,t){var e=t?Ai(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}function Lf(n,t){if(n!==t){var e=n!==i,r=n===null,u=n===n,o=In(n),s=t!==i,a=t===null,c=t===t,_=In(t);if(!a&&!_&&!o&&n>t||o&&s&&c&&!a&&!_||r&&s&&c||!e&&c||!u)return 1;if(!r&&!o&&!_&&n=a)return c;var _=e[r];return c*(_=="desc"?-1:1)}}return n.index-t.index}function Ef(n,t,e,r){for(var u=-1,o=n.length,s=e.length,a=-1,c=t.length,_=nn(o-s,0),d=h(c+_),v=!r;++a1?e[u-1]:i,s=u>2?e[2]:i;for(o=n.length>3&&typeof o=="function"?(u--,o):i,s&&dn(e[0],e[1],s)&&(o=u<3?i:o,u=1),t=N(t);++r-1?u[o?t[s]:s]:i}}function Wf(n){return ut(function(t){var e=t.length,r=e,u=Bn.prototype.thru;for(n&&t.reverse();r--;){var o=t[r];if(typeof o!="function")throw new Pn(m);if(u&&!s&&cr(o)=="wrapper")var s=new Bn([],!0)}for(r=s?r:e;++r1&&P.reverse(),d&&ca))return!1;var _=o.get(n),d=o.get(t);if(_&&d)return _==t&&d==n;var v=-1,x=!0,S=e&Sn?new Rt:i;for(o.set(n,t),o.set(t,n);++v1?"& ":"")+t[r],t=t.join(e>2?", ":" "),n.replace(Ss,`{\n/* [wrapped with `+t+`] */\n`)}function Ac(n){return I(n)||Dt(n)||!!(Qu&&n&&n[Qu])}function ft(n,t){var e=typeof n;return t=t==null?Kn:t,!!t&&(e=="number"||e!="symbol"&&Ds.test(n))&&n>-1&&n%1==0&&n0){if(++t>=Wt)return arguments[0]}else t=0;return n.apply(i,arguments)}}function hr(n,t){var e=-1,r=n.length,u=r-1;for(t=t===i?r:t;++e1?n[t-1]:i;return e=typeof e=="function"?(n.pop(),e):i,so(n,e)});function ao(n){var t=f(n);return t.__chain__=!0,t}function bp(n,t){return t(n),n}function gr(n,t){return t(n)}var Dp=ut(function(n){var t=n.length,e=t?n[0]:0,r=this.__wrapped__,u=function(o){return fi(o,n)};return t>1||this.__actions__.length||!(r instanceof D)||!ft(e)?this.thru(u):(r=r.slice(e,+e+(t?1:0)),r.__actions__.push({func:gr,args:[u],thisArg:i}),new Bn(r,this.__chain__).thru(function(o){return t&&!o.length&&o.push(i),o}))});function Pp(){return ao(this)}function Bp(){return new Bn(this.value(),this.__chain__)}function Wp(){this.__values__===i&&(this.__values__=Co(this.value()));var n=this.__index__>=this.__values__.length,t=n?i:this.__values__[this.__index__++];return{done:n,value:t}}function Up(){return this}function Np(n){for(var t,e=this;e instanceof je;){var r=eo(e);r.__index__=0,r.__values__=i,t?u.__wrapped__=r:t=r;var u=r;e=e.__wrapped__}return u.__wrapped__=n,t}function Gp(){var n=this.__wrapped__;if(n instanceof D){var t=n;return this.__actions__.length&&(t=new D(this)),t=t.reverse(),t.__actions__.push({func:gr,args:[Di],thisArg:i}),new Bn(t,this.__chain__)}return this.thru(Di)}function qp(){return Tf(this.__wrapped__,this.__actions__)}var Kp=fr(function(n,t,e){U.call(n,e)?++n[e]:rt(n,e,1)});function Hp(n,t,e){var r=I(n)?Wu:bl;return e&&dn(n,t,e)&&(t=i),r(n,C(t,3))}function $p(n,t){var e=I(n)?gt:sf;return e(n,C(t,3))}var zp=Bf(ro),kp=Bf(io);function Yp(n,t){return fn(_r(n,t),1)}function Zp(n,t){return fn(_r(n,t),Jn)}function Jp(n,t,e){return e=e===i?1:R(e),fn(_r(n,t),e)}function lo(n,t){var e=I(n)?Dn:yt;return e(n,C(t,3))}function co(n,t){var e=I(n)?ga:of;return e(n,C(t,3))}var Xp=fr(function(n,t,e){U.call(n,e)?n[e].push(t):rt(n,e,[t])});function Qp(n,t,e,r){n=yn(n)?n:Vt(n),e=e&&!r?R(e):0;var u=n.length;return e<0&&(e=nn(u+e,0)),mr(n)?e<=u&&n.indexOf(t,e)>-1:!!u&&qt(n,t,e)>-1}var Vp=O(function(n,t,e){var r=-1,u=typeof t=="function",o=yn(n)?h(n.length):[];return yt(n,function(s){o[++r]=u?Tn(t,s,e):de(s,t,e)}),o}),jp=fr(function(n,t,e){rt(n,e,t)});function _r(n,t){var e=I(n)?H:gf;return e(n,C(t,3))}function nh(n,t,e,r){return n==null?[]:(I(t)||(t=t==null?[]:[t]),e=r?i:e,I(e)||(e=e==null?[]:[e]),xf(n,t,e))}var th=fr(function(n,t,e){n[e?0:1].push(t)},function(){return[[],[]]});function eh(n,t,e){var r=I(n)?Yr:qu,u=arguments.length<3;return r(n,C(t,4),e,u,yt)}function rh(n,t,e){var r=I(n)?_a:qu,u=arguments.length<3;return r(n,C(t,4),e,u,of)}function ih(n,t){var e=I(n)?gt:sf;return e(n,xr(C(t,3)))}function uh(n){var t=I(n)?ef:Ql;return t(n)}function fh(n,t,e){(e?dn(n,t,e):t===i)?t=1:t=R(t);var r=I(n)?Il:Vl;return r(n,t)}function oh(n){var t=I(n)?Rl:nc;return t(n)}function sh(n){if(n==null)return 0;if(yn(n))return mr(n)?Ht(n):n.length;var t=an(n);return t==Hn||t==$n?n.size:pi(n).length}function ah(n,t,e){var r=I(n)?Zr:tc;return e&&dn(n,t,e)&&(t=i),r(n,C(t,3))}var lh=O(function(n,t){if(n==null)return[];var e=t.length;return e>1&&dn(n,t[0],t[1])?t=[]:e>2&&dn(t[0],t[1],t[2])&&(t=[t[0]]),xf(n,fn(t,1),[])}),dr=$a||function(){return tn.Date.now()};function ch(n,t){if(typeof t!="function")throw new Pn(m);return n=R(n),function(){if(--n<1)return t.apply(this,arguments)}}function po(n,t,e){return t=e?i:t,t=n&&t==null?n.length:t,it(n,On,i,i,i,i,t)}function ho(n,t){var e;if(typeof t!="function")throw new Pn(m);return n=R(n),function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=i),e}}var Bi=O(function(n,t,e){var r=Y;if(e.length){var u=dt(e,Xt(Bi));r|=V}return it(n,r,t,e,u)}),go=O(function(n,t,e){var r=Y|$;if(e.length){var u=dt(e,Xt(go));r|=V}return it(t,r,n,e,u)});function _o(n,t,e){t=e?i:t;var r=it(n,pn,i,i,i,i,i,t);return r.placeholder=_o.placeholder,r}function vo(n,t,e){t=e?i:t;var r=it(n,En,i,i,i,i,i,t);return r.placeholder=vo.placeholder,r}function xo(n,t,e){var r,u,o,s,a,c,_=0,d=!1,v=!1,x=!0;if(typeof n!="function")throw new Pn(m);t=Gn(t)||0,z(e)&&(d=!!e.leading,v="maxWait"in e,o=v?nn(Gn(e.maxWait)||0,t):o,x="trailing"in e?!!e.trailing:x);function S(J){var Zn=r,at=u;return r=u=i,_=J,s=n.apply(at,Zn),s}function T(J){return _=J,a=we(b,t),d?S(J):s}function L(J){var Zn=J-c,at=J-_,Wo=t-Zn;return v?sn(Wo,o-at):Wo}function F(J){var Zn=J-c,at=J-_;return c===i||Zn>=t||Zn<0||v&&at>=o}function b(){var J=dr();if(F(J))return P(J);a=we(b,L(J))}function P(J){return a=i,x&&r?S(J):(r=u=i,s)}function Rn(){a!==i&&Mf(a),_=0,r=c=u=a=i}function vn(){return a===i?s:P(dr())}function Ln(){var J=dr(),Zn=F(J);if(r=arguments,u=this,c=J,Zn){if(a===i)return T(c);if(v)return Mf(a),a=we(b,t),S(c)}return a===i&&(a=we(b,t)),s}return Ln.cancel=Rn,Ln.flush=vn,Ln}var ph=O(function(n,t){return ff(n,1,t)}),hh=O(function(n,t,e){return ff(n,Gn(t)||0,e)});function gh(n){return it(n,qn)}function vr(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new Pn(m);var e=function(){var r=arguments,u=t?t.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var s=n.apply(this,r);return e.cache=o.set(u,s)||o,s};return e.cache=new(vr.Cache||et),e}vr.Cache=et;function xr(n){if(typeof n!="function")throw new Pn(m);return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function _h(n){return ho(2,n)}var dh=ec(function(n,t){t=t.length==1&&I(t[0])?H(t[0],Fn(C())):H(fn(t,1),Fn(C()));var e=t.length;return O(function(r){for(var u=-1,o=sn(r.length,e);++u=t}),Dt=cf(function(){return arguments}())?cf:function(n){return k(n)&&U.call(n,"callee")&&!Xu.call(n,"callee")},I=h.isArray,Eh=Eu?Fn(Eu):Nl;function yn(n){return n!=null&&yr(n.length)&&!ot(n)}function Z(n){return k(n)&&yn(n)}function Oh(n){return n===!0||n===!1||k(n)&&_n(n)==te}var St=ka||Zi,bh=Ou?Fn(Ou):Gl;function Dh(n){return k(n)&&n.nodeType===1&&!Ae(n)}function Ph(n){if(n==null)return!0;if(yn(n)&&(I(n)||typeof n=="string"||typeof n.splice=="function"||St(n)||Qt(n)||Dt(n)))return!n.length;var t=an(n);if(t==Hn||t==$n)return!n.size;if(me(n))return!pi(n).length;for(var e in n)if(U.call(n,e))return!1;return!0}function Bh(n,t){return ve(n,t)}function Wh(n,t,e){e=typeof e=="function"?e:i;var r=e?e(n,t):i;return r===i?ve(n,t,i,e):!!r}function Ui(n){if(!k(n))return!1;var t=_n(n);return t==Ee||t==fs||typeof n.message=="string"&&typeof n.name=="string"&&!Ae(n)}function Uh(n){return typeof n=="number"&&Vu(n)}function ot(n){if(!z(n))return!1;var t=_n(n);return t==Oe||t==uu||t==ht||t==ss}function mo(n){return typeof n=="number"&&n==R(n)}function yr(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Kn}function z(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function k(n){return n!=null&&typeof n=="object"}var wo=bu?Fn(bu):Kl;function Nh(n,t){return n===t||ci(n,t,Ii(t))}function Gh(n,t,e){return e=typeof e=="function"?e:i,ci(n,t,Ii(t),e)}function qh(n){return Ao(n)&&n!=+n}function Kh(n){if(Tc(n))throw new M(A);return pf(n)}function Hh(n){return n===null}function $h(n){return n==null}function Ao(n){return typeof n=="number"||k(n)&&_n(n)==re}function Ae(n){if(!k(n)||_n(n)!=nt)return!1;var t=ke(n);if(t===null)return!0;var e=U.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Ke.call(e)==Ga}var Ni=Du?Fn(Du):Hl;function zh(n){return mo(n)&&n>=-Kn&&n<=Kn}var So=Pu?Fn(Pu):$l;function mr(n){return typeof n=="string"||!I(n)&&k(n)&&_n(n)==ue}function In(n){return typeof n=="symbol"||k(n)&&_n(n)==be}var Qt=Bu?Fn(Bu):zl;function kh(n){return n===i}function Yh(n){return k(n)&&an(n)==fe}function Zh(n){return k(n)&&_n(n)==ls}var Jh=lr(hi),Xh=lr(function(n,t){return n<=t});function Co(n){if(!n)return[];if(yn(n))return mr(n)?zn(n):xn(n);if(ae&&n[ae])return Ia(n[ae]());var t=an(n),e=t==Hn?ni:t==$n?Ne:Vt;return e(n)}function st(n){if(!n)return n===0?n:0;if(n=Gn(n),n===Jn||n===-Jn){var t=n<0?-1:1;return t*Ie}return n===n?n:0}function R(n){var t=st(n),e=t%1;return t===t?e?t-e:t:0}function To(n){return n?Lt(R(n),0,Cn):0}function Gn(n){if(typeof n=="number")return n;if(In(n))return Tt;if(z(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=z(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=Ku(n);var e=Es.test(n);return e||bs.test(n)?ca(n.slice(2),e?2:8):Ls.test(n)?Tt:+n}function Fo(n){return Qn(n,mn(n))}function Qh(n){return n?Lt(R(n),-Kn,Kn):n===0?n:0}function W(n){return n==null?"":Mn(n)}var Vh=Zt(function(n,t){if(me(t)||yn(t)){Qn(t,en(t),n);return}for(var e in t)U.call(t,e)&&ge(n,e,t[e])}),Mo=Zt(function(n,t){Qn(t,mn(t),n)}),wr=Zt(function(n,t,e,r){Qn(t,mn(t),n,r)}),jh=Zt(function(n,t,e,r){Qn(t,en(t),n,r)}),ng=ut(fi);function tg(n,t){var e=Yt(n);return t==null?e:rf(e,t)}var eg=O(function(n,t){n=N(n);var e=-1,r=t.length,u=r>2?t[2]:i;for(u&&dn(t[0],t[1],u)&&(r=1);++e1),o}),Qn(n,Fi(n),e),r&&(e=Wn(e,K|An|ln,hc));for(var u=t.length;u--;)xi(e,t[u]);return e});function mg(n,t){return Ro(n,xr(C(t)))}var wg=ut(function(n,t){return n==null?{}:Zl(n,t)});function Ro(n,t){if(n==null)return{};var e=H(Fi(n),function(r){return[r]});return t=C(t),yf(n,e,function(r,u){return t(r,u[0])})}function Ag(n,t,e){t=wt(t,n);var r=-1,u=t.length;for(u||(u=1,n=i);++rt){var r=n;n=t,t=r}if(e||n%1||t%1){var u=ju();return sn(n+u*(t-n+la("1e-"+((u+"").length-1))),t)}return _i(n,t)}var bg=Jt(function(n,t,e){return t=t.toLowerCase(),n+(e?Oo(t):t)});function Oo(n){return Ki(W(n).toLowerCase())}function bo(n){return n=W(n),n&&n.replace(Ps,Sa).replace(na,"")}function Dg(n,t,e){n=W(n),t=Mn(t);var r=n.length;e=e===i?r:Lt(R(e),0,r);var u=e;return e-=t.length,e>=0&&n.slice(e,u)==t}function Pg(n){return n=W(n),n&&_s.test(n)?n.replace(su,Ca):n}function Bg(n){return n=W(n),n&&ws.test(n)?n.replace(Wr,"\\\\$&"):n}var Wg=Jt(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()}),Ug=Jt(function(n,t,e){return n+(e?" ":"")+t.toLowerCase()}),Ng=Pf("toLowerCase");function Gg(n,t,e){n=W(n),t=R(t);var r=t?Ht(n):0;if(!t||r>=t)return n;var u=(t-r)/2;return ar(Xe(u),e)+n+ar(Je(u),e)}function qg(n,t,e){n=W(n),t=R(t);var r=t?Ht(n):0;return t&&r>>0,e?(n=W(n),n&&(typeof t=="string"||t!=null&&!Ni(t))&&(t=Mn(t),!t&&Kt(n))?At(zn(n),0,e):n.split(t,e)):[]}var Zg=Jt(function(n,t,e){return n+(e?" ":"")+Ki(t)});function Jg(n,t,e){return n=W(n),e=e==null?0:Lt(R(e),0,n.length),t=Mn(t),n.slice(e,e+t.length)==t}function Xg(n,t,e){var r=f.templateSettings;e&&dn(n,t,e)&&(t=i),n=W(n),t=wr({},t,r,Kf);var u=wr({},t.imports,r.imports,Kf),o=en(u),s=jr(u,o),a,c,_=0,d=t.interpolate||De,v="__p += \'",x=ti((t.escape||De).source+"|"+d.source+"|"+(d===au?Rs:De).source+"|"+(t.evaluate||De).source+"|$","g"),S="//# sourceURL="+(U.call(t,"sourceURL")?(t.sourceURL+"").replace(/\\s/g," "):"lodash.templateSources["+ ++ua+"]")+`\n`;n.replace(x,function(F,b,P,Rn,vn,Ln){return P||(P=Rn),v+=n.slice(_,Ln).replace(Bs,Ta),b&&(a=!0,v+=`\' +\n__e(`+b+`) +\n\'`),vn&&(c=!0,v+=`\';\n`+vn+`;\n__p += \'`),P&&(v+=`\' +\n((__t = (`+P+`)) == null ? \'\' : __t) +\n\'`),_=Ln+F.length,F}),v+=`\';\n`;var T=U.call(t,"variable")&&t.variable;if(!T)v=`with (obj) {\n`+v+`\n}\n`;else if(Ms.test(T))throw new M(E);v=(c?v.replace(cs,""):v).replace(ps,"$1").replace(hs,"$1;"),v="function("+(T||"obj")+`) {\n`+(T?"":`obj || (obj = {});\n`)+"var __t, __p = \'\'"+(a?", __e = _.escape":"")+(c?`, __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, \'\') }\n`:`;\n`)+v+`return __p\n}`;var L=Po(function(){return B(o,S+"return "+v).apply(i,s)});if(L.source=v,Ui(L))throw L;return L}function Qg(n){return W(n).toLowerCase()}function Vg(n){return W(n).toUpperCase()}function jg(n,t,e){if(n=W(n),n&&(e||t===i))return Ku(n);if(!n||!(t=Mn(t)))return n;var r=zn(n),u=zn(t),o=Hu(r,u),s=$u(r,u)+1;return At(r,o,s).join("")}function n_(n,t,e){if(n=W(n),n&&(e||t===i))return n.slice(0,ku(n)+1);if(!n||!(t=Mn(t)))return n;var r=zn(n),u=$u(r,zn(t))+1;return At(r,0,u).join("")}function t_(n,t,e){if(n=W(n),n&&(e||t===i))return n.replace(Ur,"");if(!n||!(t=Mn(t)))return n;var r=zn(n),u=Hu(r,zn(t));return At(r,u).join("")}function e_(n,t){var e=Fr,r=Fe;if(z(t)){var u="separator"in t?t.separator:u;e="length"in t?R(t.length):e,r="omission"in t?Mn(t.omission):r}n=W(n);var o=n.length;if(Kt(n)){var s=zn(n);o=s.length}if(e>=o)return n;var a=e-Ht(r);if(a<1)return r;var c=s?At(s,0,a).join(""):n.slice(0,a);if(u===i)return c+r;if(s&&(a+=c.length-a),Ni(u)){if(n.slice(a).search(u)){var _,d=c;for(u.global||(u=ti(u.source,W(lu.exec(u))+"g")),u.lastIndex=0;_=u.exec(d);)var v=_.index;c=c.slice(0,v===i?a:v)}}else if(n.indexOf(Mn(u),a)!=a){var x=c.lastIndexOf(u);x>-1&&(c=c.slice(0,x))}return c+r}function r_(n){return n=W(n),n&&gs.test(n)?n.replace(ou,Oa):n}var i_=Jt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Ki=Pf("toUpperCase");function Do(n,t,e){return n=W(n),t=e?i:t,t===i?Ma(n)?Pa(n):xa(n):n.match(t)||[]}var Po=O(function(n,t){try{return Tn(n,i,t)}catch(e){return Ui(e)?e:new M(e)}}),u_=ut(function(n,t){return Dn(t,function(e){e=Vn(e),rt(n,e,Bi(n[e],n))}),n});function f_(n){var t=n==null?0:n.length,e=C();return n=t?H(n,function(r){if(typeof r[1]!="function")throw new Pn(m);return[e(r[0]),r[1]]}):[],O(function(r){for(var u=-1;++uKn)return[];var e=Cn,r=sn(n,Cn);t=C(t),n-=Cn;for(var u=Vr(r,t);++e0||t<0)?new D(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=R(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},D.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},D.prototype.toArray=function(){return this.take(Cn)},Xn(D.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),u=f[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);!u||(f.prototype[t]=function(){var s=this.__wrapped__,a=r?[1]:arguments,c=s instanceof D,_=a[0],d=c||I(s),v=function(b){var P=u.apply(f,_t([b],a));return r&&x?P[0]:P};d&&e&&typeof _=="function"&&_.length!=1&&(c=d=!1);var x=this.__chain__,S=!!this.__actions__.length,T=o&&!x,L=c&&!S;if(!o&&d){s=L?s:new D(this);var F=n.apply(s,a);return F.__actions__.push({func:gr,args:[v],thisArg:i}),new Bn(F,x)}return T&&L?n.apply(this,a):(F=this.thru(v),T?r?F.value()[0]:F.value():F)})}),Dn(["pop","push","shift","sort","splice","unshift"],function(n){var t=Ge[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);f.prototype[n]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(I(o)?o:[],u)}return this[e](function(s){return t.apply(I(s)?s:[],u)})}}),Xn(D.prototype,function(n,t){var e=f[t];if(e){var r=e.name+"";U.call(kt,r)||(kt[r]=[]),kt[r].push({name:t,func:e})}}),kt[or(i,$).name]=[{name:"wrapper",func:i}],D.prototype.clone=rl,D.prototype.reverse=il,D.prototype.value=ul,f.prototype.at=Dp,f.prototype.chain=Pp,f.prototype.commit=Bp,f.prototype.next=Wp,f.prototype.plant=Np,f.prototype.reverse=Gp,f.prototype.toJSON=f.prototype.valueOf=f.prototype.value=qp,f.prototype.first=f.prototype.head,ae&&(f.prototype[ae]=Up),f},vt=Ba();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(tn._=vt,define(function(){return vt})):Ft?((Ft.exports=vt)._=vt,$r._=vt):tn._=vt}).call(jt)});var iu=j_(qo());var Ko="banner",Xi="alias",Qi="sticker",Vi="color";var lt=i=>[...new Set(i)],Ho=i=>[...new Map(i.map(p=>[p.toLowerCase(),p])).values()];var $o=i=>{var p;try{p=JSON.parse(i)}catch(y){}return p};var ko=(i,p)=>p.indexOf(i)>0?p.indexOf(i):p.length,n0=i=>i.substring(0,i.length-2),ji=i=>i.replace(/\\//g,"+")+"//";var t0=i=>i.charAt(0)=="#"?i.substring(1,i.length):i;var e0=i=>i.charAt(0)=="/"?i.substring(1):i;var zo=i=>e0(i.substring(i.lastIndexOf("/")))||i,nu=i=>i?(i==null?void 0:i.type)=="folder"?zo(i.contextPath):(i==null?void 0:i.type)=="tag"?t0(i.contextPath):(i==null?void 0:i.type)=="space"?n0(i.contextPath):i.isRemote?zo(i.contextPath):i.contextPath:"";var ct=i=>{var p;return(p=i==null?void 0:i.match(/(\\\\.|[^,])+/g))!=null?p:[]},Yo=i=>{if(!i)return"";let p=/\\[\\[(.*?)\\]\\]/g.exec(i),y=(p==null?void 0:p.length)>1?p[1].substring(0,ko("|",p[1])):i;return y||i};var Zo=i=>{var p;return!i||i.length==0?[]:i.charAt(0)=="#"?i.split("&").map(y=>({type:"tag",value:y})):(p=$o(i))!=null?p:[]};var Ce=(i,p)=>{if(typeof i=="string"){if(/\\/\\/(\\S+?(?:jpe?g|png|gif|svg))/gi.test(i)||i.includes("unsplash"))return"image";if(/^\\d{4}-\\d{2}-\\d{2}$/.test(i))return"date";if(p=="tag"||p=="tags")return"tag";if(/\\[\\[.*?\\]\\]/.test(i))return"link"}else{if(typeof i=="number")return"number";if(typeof i=="boolean")return"boolean";if(i)if(Array.isArray(i)||typeof i=="string"&&i.indexOf(",")>-1){let y=Array.isArray(i)?i:[];if(typeof i=="string"&&i.indexOf(",")>-1&&(y=ct(i)),p=="tag"||p=="tags")return"tag-multi";if(y.length==1&&Array.isArray(y[0])&&y[0].length==1&&typeof y[0][0]=="string")return"link";let A=lt(y.map(m=>Ce(m,p)));return A.length==1&&A[0]=="link"?"link-multi":"option-multi"}else{if(i.isLuxonDateTime)return"date";if(i.isLuxonDuration)return"duration";if(i.type=="file")return"link";if(typeof i=="object"&&!Array.isArray(i)&&i!==null)return"object"}else return"unknown"}return"text"};var Jo=i=>Object.keys(i!=null?i:{}).filter(p=>p!="position").filter(p=>p!="tag"&&p!="tags");var ne=i=>i.join(","),Xo=i=>i.join(", ");var Ar=(i,p)=>{switch(Ce(p,i)){case"object":return JSON.stringify(p);case"number":return p.toString();case"boolean":return p?"true":"false";case"date":return p;case"duration":return Xo(Object.keys(p.values).reduce((A,m)=>[...A,...p.values[m]>0?[p.values[m]+" "+m]:[]],[]));case"option-multi":case"link-multi":return typeof p=="string"?p:ne(p.map(A=>A?typeof A=="string"?A:A.path?A.path:Array.isArray(p)&&A.length==1&&Array.isArray(A[0])&&A[0].length==1&&typeof A[0][0]=="string"?A[0][0]:JSON.stringify(A):""));case"link":return Array.isArray(p)&&p.length==1&&Array.isArray(p[0])&&p[0].length==1&&typeof p[0][0]=="string"?p[0][0]:typeof p=="string"?p:p.path;case"text":case"tag":case"image":return p}return""};var Qo=i=>{switch(i){case"duration":return"text";case"unknown":return"text"}return i};var Sr=(i,p)=>i==p,tu=(i,p)=>(i!=null?i:"").length==0,eu=(i,p)=>(i!=null?i:"").toLowerCase().includes((p!=null?p:"").toLowerCase()),Cr=(i,p)=>parseFloat(i)>parseFloat(p),Tr=(i,p)=>parseInt(i)>parseInt(p),ru=(i,p)=>{let y=i?ct(i):[];return(p?ct(p):[]).some(m=>y.some(E=>E==m))};var Te={isNotEmpty:{type:["text","file","link","link-multi","fileprop","image"],fn:(i,p)=>!tu(i,""),valueType:"none"},isEmpty:{type:["text","file","link","link-multi","fileprop","image"],fn:(i,p)=>tu(i,""),valueType:"none"},include:{fn:(i,p)=>eu(i,p),type:["text","file","link","link-multi","fileprop","image"],valueType:"text"},notInclude:{type:["text","file","link","link-multi","fileprop","image"],fn:(i,p)=>!eu(i,p),valueType:"text"},is:{type:["text","file","link","context","fileprop"],fn:Sr,valueType:"text"},isNot:{type:["text","file","link","context","fileprop"],fn:(i,p)=>!Sr(i,p),valueType:"text"},equal:{type:["number"],fn:Sr,valueType:"number"},isGreatThan:{type:["number"],fn:Cr,valueType:"number"},isLessThan:{type:["number"],fn:Tr,valueType:"number"},isLessThanOrEqual:{type:["number"],fn:(i,p)=>!Cr(i,p),valueType:"number"},isGreatThanOrEqual:{type:["number"],fn:(i,p)=>!Tr(i,p),valueType:"number"},dateBefore:{type:["date","fileprop"],fn:Tr,valueType:"date"},dateAfter:{type:["date","fileprop"],fn:Cr,valueType:"date"},isAnyInList:{type:["option","context","option-multi","context-multi","tags-multi","tags"],fn:ru,valueType:"list"},isNoneInList:{type:["option","context","option-multi","context-multi","tags-multi","tags"],fn:(i,p)=>!ru(i,p),valueType:"list"},isTrue:{type:["boolean"],fn:(i,p)=>i=="true",valueType:"none"},isFalse:{type:["boolean"],fn:(i,p)=>i!="true",valueType:"none"}};var r0=(i,p)=>p.reduce((A,m)=>{let[E,Q]=A,rn=m.type=="fileprop"?ns(Q,m):m.type=="filemeta"?jo(Q,m):m.type=="frontmatter"?Vo(Q,m):[],un=Q.filter(K=>!rn.includes(K));return[[...E,...rn],un]},[[],i])[0],i0=(i,p)=>p.reduce((y,A)=>A.type=="fileprop"?ns(y,A):A.type=="filemeta"?jo(y,A):A.type=="frontmatter"?Vo(y,A):[],i),Vo=(i,p)=>i.filter(y=>{let A=y.frontmatter;if(!A||!A[p.field])return!1;let m=Te[p.fn],E=!0;return m&&(E=m.fn(Ar(p.field,A[p.field]),p.value)),E}),jo=(i,p)=>i.filter(y=>{let A="";p.field=="outlinks"?A=ne(y.outlinks):p.field=="inlinks"?A=ne(y.inlinks):p.field=="tags"&&(A=ne(y.tags));let m=Te[p.fn],E=!0;return m&&(E=m.fn(A,p.value)),E}),ns=(i,p)=>i.filter(y=>{if(["path","sticker","color","isFolder","extension","ctime","mtime","size","parent"].includes(p.field)){let m=Te[p.fn],E=!0;return m&&(E=m.fn(y[p.field],p.value)),E}return!0}),ts=(i,p)=>i.filters.reduce((m,E)=>m&&(E.type=="any"?r0([p],E.filters).length>0:i0([p],E.filters).length>0),!0);var es=(i,p,y)=>{var An,ln,cn,Sn,Y,$;if(!p)return{changed:!1,cache:{path:i.dbPath,info:i,name:nu(i),sticker:"",banner:"",cols:[],files:[],rows:[],def:[],defContexts:[],outlinks:[],contexts:[]}};let A=(ln=(An=p.cols)==null?void 0:An.filter(X=>X.type.startsWith("context")))!=null?ln:[],m=(Sn=(cn=p.cols)==null?void 0:cn.filter(X=>X.type.startsWith("link")))!=null?Sn:[],E=lt(A.map(X=>X.value)),Q=lt(p.rows.reduce((X,pn)=>lt([...X,...[...A,...m].flatMap(En=>ct(pn[En.name]).map(V=>Yo(V)))]),[])),rn=Zo(p.schema.def),un={path:i.dbPath,info:i,name:nu(i),sticker:"",banner:"",cols:p.cols,files:(Y=p.rows.map(X=>X.File))!=null?Y:[],rows:($=p.rows)!=null?$:[],defContexts:rn.filter(X=>X.type=="tag").map(X=>X.value),def:rn,contexts:E,outlinks:Q},K=!0;return y&&iu.default.isEqual(un,y)&&(K=!0),{changed:K,cache:un}},u0=i=>{var y,A,m,E,Q,rn,un,K,An,ln,cn,Sn,Y;let p=[];return i&&i.tags&&p.push(...(A=(y=i.tags)==null?void 0:y.map($=>$.tag))!=null?A:[]),i&&((m=i.frontmatter)==null?void 0:m.tags)&&p.push(...(typeof((E=i.frontmatter)==null?void 0:E.tags)=="string"?ct(i.frontmatter.tags.replace(/ /g,"")):Array.isArray((Q=i.frontmatter)==null?void 0:Q.tags)?(un=(rn=i.frontmatter)==null?void 0:rn.tags)!=null?un:[]:[]).filter($=>typeof $=="string").map($=>"#"+$)),i&&((K=i.frontmatter)==null?void 0:K.tag)&&p.push(...(typeof((An=i.frontmatter)==null?void 0:An.tag)=="string"?ct(i.frontmatter.tag.replace(/ /g,"")):Array.isArray((ln=i.frontmatter)==null?void 0:ln.tag)?(Sn=(cn=i.frontmatter)==null?void 0:cn.tag)!=null?Sn:[]:[]).filter($=>typeof $=="string").map($=>"#"+$)),(Y=lt(p))!=null?Y:[]};var f0=(i,p,y,A)=>{let m=[];return m.push(...p.filter(E=>y.has(E))),i.parent!="/"&&m.push(i.parent),A.forEach(E=>{y.has(ji(E))&&m.push(ji(E))}),m},rs=(i,p,y,A,m,E,Q,rn,un)=>{var Kn,Ie,Tt,Cn,Re,Le;let K={path:i.path,name:i.name};i.stat&&(K.ctime=i.stat.ctime,K.mtime=i.stat.mtime,K.size=i.stat.size,K.extension=i.extension);let An=[],ln=u0(E);if(y.has(i.parent))for(let on of y.get(i.parent).def)on.type=="tag"&&An.push(on.value);An.push(...ln);let cn=i.name,Sn=(Kn=m==null?void 0:m.sticker)!=null?Kn:"",Y=(Ie=m==null?void 0:m.color)!=null?Ie:"",$=(Tt=m==null?void 0:m.rank)!=null?Tt:"",X=(Cn=m==null?void 0:m.folder)!=null?Cn:"";X=="true"&&(X="");let pn=i.parent,En=i.isFolder,V={},jn={},On=[],pt=[],qn=E==null?void 0:E.frontmatter;E!=null&&E.links&&pt.push(...E.links.map(on=>on.link));let Fr=rn&&En?rn.folderNotePath:i.path;for(let on of Object.keys(Q))Fr in Q[on]&&On.push(on);let Fe="";if(qn){let hn=Ho(Jo(qn)).reduce((gn,ht)=>Bt(Pt({},gn),{[ht]:{name:ht,type:Qo(Ce(qn[ht],ht))}}),{});Object.keys(hn).forEach(gn=>{V[gn]=Ar(gn,qn[gn]),jn[gn]=hn[gn].type}),Fe=(Re=V[Ko])!=null?Re:"",V[Qi]&&(Sn=qn[Qi]),V[Vi]&&(Y=qn[Vi]),V[Xi]&&p.spacesUseAlias&&(cn=qn[Xi])}let Wt=Bt(Pt({},K),{name:cn,tags:lt(An),fileTags:ln,folderNote:rn,sticker:Sn,color:Y,rank:$,parent:pn,banner:Fe,isFolder:En,folderSort:X,frontmatter:V,frontmatterTypes:jn,inlinks:On,outlinks:pt}),Ct=[],Ut={};for(let[on,hn]of A)if(hn.space.def.type=="smart")ts(hn.space.def,Wt)&&Ct.push(on);else if(((Le=hn.space.def.folder)==null?void 0:Le.length)>0)hn.space.def.folder==pn&&(Ct.push(on),Ut[on]=$);else{let gn=hn.spaceItems.find(ht=>ht.path==Wt.path);gn&&(Ct.push(on),Ut[on]=gn.rank)}let Mr=f0(i,An,y,Ct),Me=rn&&!En?Bt(Pt({},Wt),{spaces:[],contexts:[]}):Bt(Pt({},Wt),{spaces:Ct,contexts:lt(Mr),spaceRanks:Ut}),Jn=!0;return un&&iu.default.isEqual(Me,un)&&(Jn=!1),{changed:Jn,cache:Me}};function is(i){let{file:p,settings:y,contextsCache:A,spacesCache:m,vaultItem:E,metadataCache:Q,resolvedLinks:rn,folderNote:un,oldMetadata:K}=i;return rs(p,y,A,m,E,Q,rn,un,K)}function us(i){let{context:p,mdbTable:y,oldCache:A}=i;return es(p,y,A)}var o0=self;o0.onmessage=async i=>{let{payload:p,job:y}=i.data,A;y.type=="file"?A=is(p):y.type=="context"&&(A=us(p));try{postMessage({job:y,result:A})}catch(m){console.log(m),postMessage({job:y,result:{$error:`Failed to index ${y.type} ${y.path}: ${m}`}})}};\n/**\n * @license\n * Lodash \n * Copyright OpenJS Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n'); } // src/superstate/workers/manager.ts @@ -52797,13 +52808,13 @@ var Manager = class extends import_obsidian58.Component { payload: { file, settings: this.cache.plugin.settings, - contextsCache: this.cache.contextsCache, - spacesCache: this.cache.spacesCache, + contextsCache: this.cache.contextsIndex, + spacesCache: this.cache.spacesIndex, vaultItem: vaultItemForPath(this.cache.plugin, job.path), metadataCache: app.metadataCache.getCache(metadataPath), resolvedLinks: app.metadataCache.resolvedLinks, folderNote, - oldMetadata: this.cache.files.get(job.path) + oldMetadata: this.cache.filesIndex.get(job.path) } }); this.busy[workerId] = true; @@ -52819,7 +52830,7 @@ var Manager = class extends import_obsidian58.Component { payload: { context, mdbTable, - oldCache: this.cache.contextsCache.get(job.path) + oldCache: this.cache.contextsIndex.get(job.path) } }); this.busy[workerId] = true; @@ -52881,7 +52892,7 @@ var Superstate = class extends import_obsidian59.Component { this.app = app2; this.indexVersion = indexVersion; this.onChange = onChange; - this.persistSpacesDB = (0, import_lodash9.debounce)( + this.debounceSaveSpaceDatabase = (0, import_lodash9.debounce)( (tables) => { saveDBToPath(this.plugin, this.plugin.spacesDBPath, tables).then((f4) => { this.updateSpaceLastUpdated(); @@ -52896,12 +52907,13 @@ var Superstate = class extends import_obsidian59.Component { this.initialized = false; this.plugin = plugin; this.metadataCache = app2.metadataCache; - this.files = /* @__PURE__ */ new Map(); - this.spacesCache = /* @__PURE__ */ new Map(); - this.spaces = new IndexMap(); - this.tags = new IndexMap(); - this.contextsCache = /* @__PURE__ */ new Map(); - this.contexts = new IndexMap(); + this.filesIndex = /* @__PURE__ */ new Map(); + this.spacesIndex = /* @__PURE__ */ new Map(); + this.contextsIndex = /* @__PURE__ */ new Map(); + this.spacesMap = new IndexMap(); + this.linksMap = new IndexMap(); + this.tagsMap = new IndexMap(); + this.contextsMap = new IndexMap(); this.contextStoreQueue = Promise.resolve(); this.vaultDBCache = []; this.spacesItemsDBCache = []; @@ -52913,11 +52925,15 @@ var Superstate = class extends import_obsidian59.Component { static create(app2, indexVersion, onChange, plugin) { return new Superstate(app2, indexVersion, onChange, plugin); } + async initializeIndex() { + await this.loadFromCache(); + this.loadSpacesDatabaseFromDisk(); + } addToContextStoreQueue(operation) { this.contextStoreQueue = this.contextStoreQueue.then(operation).catch(() => { }); } - async resolveSync() { + async resolveSpacesDatabaseSync() { if (this.plugin.settings.spacesSyncLastUpdated.length > 0) { const waitIfSpacesFileStillSyncing = async (timeout) => { var _a2; @@ -52930,7 +52946,7 @@ var Superstate = class extends import_obsidian59.Component { } return true; }; - let resolverFile = getAbstractFileAtPath(app, this.plugin.settings.spacesSyncLastUpdated); + const resolverFile = getAbstractFileAtPath(app, this.plugin.settings.spacesSyncLastUpdated); if (!resolverFile) { await this.updateSpaceLastUpdated(); } else { @@ -52948,14 +52964,10 @@ var Superstate = class extends import_obsidian59.Component { } } } - async initializeIndex() { - await this.loadFromCache(); - this.loadSpacesDB(); - } - async loadSpacesDB() { + async loadSpacesDatabaseFromDisk() { var _a2, _b2, _c2, _d2, _e2, _f; if (this.plugin.settings.spacesEnabled) { - await this.resolveSync(); + await this.resolveSpacesDatabaseSync(); const db = await getDB(await this.plugin.sqlJS(), this.plugin.spacesDBPath); const tables = dbResultsToDBTables( db.exec( @@ -52974,6 +52986,19 @@ var Superstate = class extends import_obsidian59.Component { this.spacesItemsDBCache = (_d2 = (_c2 = selectDB(db, "spaceItems")) == null ? void 0 : _c2.rows) != null ? _d2 : []; this.spacesDBCache = (_f = (_e2 = selectDB(db, "spaces")) == null ? void 0 : _e2.rows) != null ? _f : []; db.close(); + if (!this.plugin.settings.precreateVaultSpace) { + insertSpaceAtIndex( + this.plugin, + { + name: this.plugin.app.vault.getName(), + pinned: "home", + def: { type: "focus", folder: "/", filters: [] } + }, + this.spacesDBCache.length + ); + this.plugin.settings.precreateVaultSpace = true; + this.plugin.saveSettings(); + } } rebuildIndex(this.plugin, true); } @@ -52982,7 +53007,7 @@ var Superstate = class extends import_obsidian59.Component { return app.vault.adapter.stat(this.plugin.spacesDBPath).then((f4) => { if (f4) { this.plugin.spacesDBLastModify = f4.mtime; - let resolverFile = getAbstractFileAtPath(app, this.plugin.settings.spacesSyncLastUpdated); + const resolverFile = getAbstractFileAtPath(app, this.plugin.settings.spacesSyncLastUpdated); if (!resolverFile) { return app.vault.create(this.plugin.settings.spacesSyncLastUpdated, f4.mtime.toString()).then((f5) => { }); @@ -52992,7 +53017,7 @@ var Superstate = class extends import_obsidian59.Component { }); } } - async saveSpacesDB(tables, save = true) { + async saveSpacesDatabaseToDisk(tables, save = true) { if (tables.vault) this.vaultDBCache = tables.vault.rows; if (tables.spaceItems) @@ -53000,7 +53025,7 @@ var Superstate = class extends import_obsidian59.Component { if (tables.spaces) this.spacesDBCache = tables.spaces.rows; if (save && this.plugin.settings.spacesEnabled && this.syncStatus == 0) { - this.persistSpacesDB(tables); + this.debounceSaveSpaceDatabase(tables); } } async initialize() { @@ -53014,24 +53039,24 @@ var Superstate = class extends import_obsidian59.Component { console.log(`Make.md Superstate: ${Date.now() - start} ms`); } async initializeSpaces() { - this.spacesCache = /* @__PURE__ */ new Map(); - let promises = this.spacesDBCache.map((f4) => this.reloadSpace(f4.name)); + this.spacesIndex = /* @__PURE__ */ new Map(); + const promises = this.spacesDBCache.map((f4) => this.reloadSpace(f4.name)); await Promise.all(promises); } async initializeContexts() { const allContexts = loadContexts(this.plugin, this.allSpaces()); - let promises = allContexts.map((l3) => this.reloadContext(l3)); + const promises = allContexts.map((l3) => this.reloadContext(l3)); await Promise.all(promises); } async cleanContexts() { - this.contextsCache.forEach((context) => { - const contextFiles = [...this.contexts.getInverse(context.info.contextPath)]; + this.contextsIndex.forEach((context) => { + const contextFiles = [...this.contextsMap.getInverse(context.info.contextPath)]; const removeFiles = context.files.filter((f4) => !contextFiles.includes(f4)); if (removeFiles.length > 0) this.addToContextStoreQueue(() => removeFilesInContext(this.plugin, removeFiles, context.info).then((f4) => this.reloadContext(context.info))); }); - this.spacesCache.forEach((space) => { - const removeFiles = [...this.spaces.getInverse(space.name)]; + this.spacesIndex.forEach((space) => { + const removeFiles = [...this.spacesMap.getInverse(space.name)]; }); } async loadFromCache() { @@ -53039,7 +53064,7 @@ var Superstate = class extends import_obsidian59.Component { const cacheSpacePromises = allSpaces.map((s5) => this.persister.loadFile(s5 + "//").then((serializedSpace) => { const space = safelyParseJSON(serializedSpace); if (space) { - this.spacesCache.set(s5, space); + this.spacesIndex.set(s5, space); this.broadcast("space", "change", s5); } })); @@ -53049,10 +53074,10 @@ var Superstate = class extends import_obsidian59.Component { if (!f4) return; const cache = parseFileCache(f4); - this.files.set(file.path, cache); - this.tags.set(file.path, new Set(cache.tags)); - this.contexts.set(file.path, new Set(cache.contexts)); - this.spaces.set(file.path, new Set(cache.spaces)); + this.filesIndex.set(file.path, cache); + this.tagsMap.set(file.path, new Set(cache.tags)); + this.contextsMap.set(file.path, new Set(cache.contexts)); + this.spacesMap.set(file.path, new Set(cache.spaces)); this.broadcast("file", "change", file.path); this.fileReloaded(file.path); })); @@ -53066,18 +53091,18 @@ var Superstate = class extends import_obsidian59.Component { this.broadcast("vault"); } async renameTag(tag, newTag) { - const contextCache = this.contextsCache.get(tag); - const existingContext = this.contextsCache.get(newTag); + const contextCache = this.contextsIndex.get(tag); + const existingContext = this.contextsIndex.get(newTag); if (existingContext) { await this.reloadContext(existingContext.info); - this.tags.getInverse(tag).forEach((file) => this.renameTagInFile(tag, newTag, getAbstractFileAtPath(app, file))); + this.tagsMap.getInverse(tag).forEach((file) => this.renameTagInFile(tag, newTag, getAbstractFileAtPath(app, file))); } else { - this.contextsCache.set(newTag, contextCache); - this.contextsCache.delete(tag); - this.tags.getInverse(tag).forEach((file) => this.renameTagInFile(tag, newTag, getAbstractFileAtPath(app, file))); + this.contextsIndex.set(newTag, contextCache); + this.contextsIndex.delete(tag); + this.tagsMap.getInverse(tag).forEach((file) => this.renameTagInFile(tag, newTag, getAbstractFileAtPath(app, file))); } let allContextsWithTag = []; - for (let [contextPath, contextCache2] of this.contextsCache) { + for (let [contextPath, contextCache2] of this.contextsIndex) { if (contextCache2.contexts.includes(tag) || contextCache2.defContexts.includes(tag)) { allContextsWithTag.push(contextCache2.info); } @@ -53086,8 +53111,8 @@ var Superstate = class extends import_obsidian59.Component { } renameTagInFile(tag, newTag, file) { let oldMetadata; - if (this.files.has(file.path)) { - oldMetadata = this.files.get(file.path); + if (this.filesIndex.has(file.path)) { + oldMetadata = this.filesIndex.get(file.path); } if (oldMetadata) { const newMetadata = { @@ -53096,9 +53121,9 @@ var Superstate = class extends import_obsidian59.Component { fileTags: oldMetadata.fileTags.map((f4) => f4 == tag ? newTag : f4), contexts: oldMetadata.contexts.map((f4) => f4 == tag ? newTag : f4) }; - this.files.set(file.path, newMetadata); - this.tags.set(file.path, new Set(newMetadata.tags)); - this.contexts.set(file.path, new Set(newMetadata.contexts)); + this.filesIndex.set(file.path, newMetadata); + this.tagsMap.set(file.path, new Set(newMetadata.tags)); + this.contextsMap.set(file.path, new Set(newMetadata.contexts)); } else { this.reloadFile(file); } @@ -53106,13 +53131,13 @@ var Superstate = class extends import_obsidian59.Component { this.broadcast("file", "change", file.path); } deleteTag(tag) { - const contextCache = this.contextsCache.get(tag); - this.contextsCache.delete(tag); - this.tags.getInverse(tag).forEach((file) => { + const contextCache = this.contextsIndex.get(tag); + this.contextsIndex.delete(tag); + this.tagsMap.getInverse(tag).forEach((file) => { this.deleteTagInFile(tag, getAbstractFileAtPath(app, file)); }); let allContextsWithTag = []; - for (let [contextPath, contextCache2] of this.contextsCache) { + for (let [contextPath, contextCache2] of this.contextsIndex) { if (contextCache2.contexts.includes(tag) || contextCache2.defContexts.includes(tag)) { allContextsWithTag.push(contextCache2.info); } @@ -53121,8 +53146,8 @@ var Superstate = class extends import_obsidian59.Component { } deleteTagInFile(tag, file) { let oldMetadata; - if (this.files.has(file.path)) { - oldMetadata = this.files.get(file.path); + if (this.filesIndex.has(file.path)) { + oldMetadata = this.filesIndex.get(file.path); } if (oldMetadata) { const newMetadata = { @@ -53131,9 +53156,9 @@ var Superstate = class extends import_obsidian59.Component { fileTags: oldMetadata.fileTags.filter((f4) => f4 != tag), contexts: oldMetadata.contexts.filter((f4) => f4 != tag) }; - this.files.set(file.path, newMetadata); - this.tags.set(file.path, new Set(newMetadata.tags)); - this.contexts.set(file.path, new Set(newMetadata.contexts)); + this.filesIndex.set(file.path, newMetadata); + this.tagsMap.set(file.path, new Set(newMetadata.tags)); + this.contextsMap.set(file.path, new Set(newMetadata.contexts)); } else { this.reloadFile(file); } @@ -53141,18 +53166,18 @@ var Superstate = class extends import_obsidian59.Component { this.broadcast("file", "change", file.path); } metadataChange(file) { - let fileCache = this.files.get(file.path); + let fileCache = this.filesIndex.get(file.path); let afile = file; if (!fileCache) { const folderNotePath = folderPathFromFolderNoteFile(this.plugin.settings, tFileToAFile(file)); - fileCache = this.files.get(folderNotePath); + fileCache = this.filesIndex.get(folderNotePath); if (fileCache) afile = getAbstractFileAtPath(app, fileCache.path); } if (fileCache) { const allContextsWithFile = fileCache.contexts.map((f4) => { var _a2; - return (_a2 = this.contextsCache.get(f4)) == null ? void 0 : _a2.info; + return (_a2 = this.contextsIndex.get(f4)) == null ? void 0 : _a2.info; }).filter((f4) => f4); this.addToContextStoreQueue(() => onMetadataChange(this.plugin, afile, allContextsWithFile)); this.reloadFile(afile); @@ -53162,77 +53187,77 @@ var Superstate = class extends import_obsidian59.Component { var _a2, _b2; const oldParentPath = getParentPathFromString(oldPath); const newParentPath = getParentPathFromString(newPath); - let newContextPath = newPath; + let newFilePath = newPath; const newTFile = getAbstractFileAtPath(app, newPath); - const oldFileCache = this.files.get(oldPath); + const oldFileCache = this.filesIndex.get(oldPath); if (!oldFileCache) { - this.spaces.rename(oldPath, newPath); - this.spaces.get(newPath).forEach((f4) => this.reloadSpace(f4)); + this.spacesMap.rename(oldPath, newPath); + this.spacesMap.get(newPath).forEach((f4) => this.reloadSpace(f4)); this.reloadFile(newTFile).then((f4) => this.broadcast("space")); return; } - const fileCache = { ...this.files.get(oldPath), path: newPath, parent: newParentPath }; - this.files.set(newPath, fileCache); - this.files.delete(oldPath); + const fileCache = { ...this.filesIndex.get(oldPath), path: newPath, parent: newParentPath }; + this.filesIndex.set(newPath, fileCache); + this.filesIndex.delete(oldPath); if (this.plugin.settings.enableFolderNote) { if (isFolderNote(this.plugin.settings, tFileToAFile(getAbstractFileAtPath(app, newPath)))) { - newContextPath = folderPathFromFolderNoteFile(this.plugin.settings, tFileToAFile(getAbstractFileAtPath(app, newPath))); - this.files.delete(newPath); + newFilePath = folderPathFromFolderNoteFile(this.plugin.settings, tFileToAFile(getAbstractFileAtPath(app, newPath))); + this.filesIndex.delete(newPath); } } - this.spaces.rename(oldPath, newContextPath); + this.spacesMap.rename(oldPath, newFilePath); const allContextsWithFile = ((_a2 = oldFileCache.contexts) != null ? _a2 : []).map((f4) => { var _a3; - return (_a3 = this.contextsCache.get(f4)) == null ? void 0 : _a3.info; + return (_a3 = this.contextsIndex.get(f4)) == null ? void 0 : _a3.info; }).filter((f4) => f4); if (oldParentPath != newParentPath) { - const newFolderPath = getFolderPathFromString(newContextPath); - const newFolderContext = this.contextsCache.get(newFolderPath); + const newFolderPath = getFolderPathFromString(newFilePath); + const newFolderContext = this.contextsIndex.get(newFolderPath); const newTags = uniq([...oldFileCache.fileTags, ...(_b2 = newFolderContext == null ? void 0 : newFolderContext.contexts) != null ? _b2 : []]); const sameContexts = allContextsWithFile.filter((f4) => newTags.includes(f4)); if (sameContexts.length > 0) - this.addToContextStoreQueue(() => renameFileInContexts(this.plugin, oldPath, newContextPath, sameContexts).then((f4) => sameContexts.forEach((c4) => this.reloadContext(c4)))); + this.addToContextStoreQueue(() => renameFileInContexts(this.plugin, oldPath, newFilePath, sameContexts).then((f4) => sameContexts.forEach((c4) => this.reloadContext(c4)))); const newContexts = newTags.filter((f4) => !sameContexts.includes(f4)).map((f4) => { var _a3; - return (_a3 = this.contextsCache.get(f4)) == null ? void 0 : _a3.info; + return (_a3 = this.contextsIndex.get(f4)) == null ? void 0 : _a3.info; }); if (newContexts.length > 0) - this.addToContextStoreQueue(() => addFileInContexts(this.plugin, newContextPath, newContexts).then((f4) => newContexts.forEach((c4) => this.reloadContext(c4)))); + this.addToContextStoreQueue(() => addFileInContexts(this.plugin, newFilePath, newContexts).then((f4) => newContexts.forEach((c4) => this.reloadContext(c4)))); const removedContexts = allContextsWithFile.filter((f4) => !sameContexts.includes(f4)); if (removedContexts.length > 0) this.addToContextStoreQueue(() => removeFileInContexts(this.plugin, oldPath, removedContexts).then((f4) => removedContexts.forEach((c4) => this.reloadContext(c4)))); } else { - this.addToContextStoreQueue(() => renameFileInContexts(this.plugin, oldPath, newContextPath, allContextsWithFile).then((f4) => { + this.addToContextStoreQueue(() => renameFileInContexts(this.plugin, oldPath, newFilePath, allContextsWithFile).then((f4) => { allContextsWithFile.forEach((c4) => this.reloadContext(c4)); })); } let allContextsWithLink = []; - for (let [contextPath, contextCache] of this.contextsCache) { + for (let [contextPath, contextCache] of this.contextsIndex) { if (contextCache.outlinks.includes(oldPath)) { allContextsWithLink.push(contextCache.info); } } - this.spaces.get(newContextPath).forEach((f4) => this.reloadSpace(f4)); - this.reloadFile(getAbstractFileAtPath(app, newContextPath)).then((f4) => this.broadcast("space")); - this.addToContextStoreQueue(() => renameLinkInContexts(this.plugin, oldPath, newContextPath, allContextsWithLink).then((f4) => allContextsWithFile.forEach((c4) => this.reloadContext(c4)))); + this.spacesMap.get(newFilePath).forEach((f4) => this.reloadSpace(f4)); + this.reloadFile(getAbstractFileAtPath(app, newFilePath)).then((f4) => this.broadcast("space")); + this.addToContextStoreQueue(() => renameLinkInContexts(this.plugin, oldPath, newFilePath, allContextsWithLink).then((f4) => allContextsWithFile.forEach((c4) => this.reloadContext(c4)))); } async createFile(path) { await this.reloadFile(getAbstractFileAtPath(app, path)); this.broadcast("space"); } deleteFile(path) { - const fileCache = this.files.get(path); + const fileCache = this.filesIndex.get(path); if (!fileCache) return; - this.files.delete(path); - this.spaces.delete(path); + this.filesIndex.delete(path); + this.spacesMap.delete(path); const allContextsWithFile = fileCache.contexts.map((f4) => { var _a2; - return (_a2 = this.contextsCache.get(f4)) == null ? void 0 : _a2.info; + return (_a2 = this.contextsIndex.get(f4)) == null ? void 0 : _a2.info; }).filter((f4) => f4); this.addToContextStoreQueue(() => removeFileInContexts(this.plugin, path, allContextsWithFile).then((f4) => allContextsWithFile.forEach((c4) => this.reloadContext(c4)))); let allContextsWithLink = []; - for (let [contextPath, contextCache] of this.contextsCache) { + for (let [contextPath, contextCache] of this.contextsIndex) { if (contextCache.outlinks.includes(path)) { allContextsWithLink.push(contextCache.info); } @@ -53241,25 +53266,28 @@ var Superstate = class extends import_obsidian59.Component { this.broadcast("space"); } async renameSpace(oldSpace, newSpace) { - if (this.spacesCache.has(oldSpace)) { - this.spacesCache.delete(oldSpace); + if (this.spacesIndex.has(oldSpace)) { + this.spacesIndex.delete(oldSpace); await this.reloadSpace(newSpace); } - this.spaces.renameInverse(oldSpace, newSpace); + this.spacesMap.renameInverse(oldSpace, newSpace); this.broadcast("space", "rename", oldSpace); } deleteSpace(space) { - if (this.spacesCache.has(space)) { - this.spacesCache.delete(space); + if (this.spacesIndex.has(space)) { + this.spacesIndex.delete(space); } - this.spaces.deleteInverse(space); + this.spacesMap.deleteInverse(space); + this.persister.removeFile(space + "//"); + this.plugin.settings.cachedSpaces = this.allSpaces().map((f4) => f4.name); + this.plugin.saveSettings(); this.broadcast("space"); } async spacesSynced() { const incomingSpaceTime = parseInt(await app.vault.read(getAbstractFileAtPath(app, this.plugin.settings.spacesSyncLastUpdated))); const currentSpaceTime = this.plugin.spacesDBLastModify; if (incomingSpaceTime != currentSpaceTime) { - this.loadSpacesDB(); + this.loadSpacesDatabaseFromDisk(); } } async reloadContext(context) { @@ -53270,7 +53298,7 @@ var Superstate = class extends import_obsidian59.Component { if (!changed) { return false; } - this.contextsCache.set(context.contextPath, cache); + this.contextsIndex.set(context.contextPath, cache); this.broadcast("context", "change", context.contextPath); return true; }); @@ -53282,7 +53310,7 @@ var Superstate = class extends import_obsidian59.Component { this.broadcast("vault"); } allSpaces() { - return [...this.spacesCache.values()].filter((f4) => f4).map((f4) => f4.space).sort( + return [...this.spacesIndex.values()].filter((f4) => f4).map((f4) => f4.space).sort( (a5, b4) => { var _a2, _b2; return ((_a2 = a5.rank) != null ? _a2 : "").localeCompare((_b2 = b4.rank) != null ? _b2 : "", void 0, { numeric: true }); @@ -53312,7 +53340,9 @@ var Superstate = class extends import_obsidian59.Component { const backupPath = (0, import_obsidian59.normalizePath)( `${spaceBackupFolder}/Spaces ${format(Date.now(), "yyyy-MM-dd HH-mm")}.mdb` ); - if (await this.app.vault.adapter.exists(this.plugin.spacesDBPath) && await !this.app.vault.adapter.exists(backupPath)) + const dbPathExists = await this.app.vault.adapter.exists(this.plugin.spacesDBPath); + const backupPathExists = await this.app.vault.adapter.exists(backupPath); + if (dbPathExists && !backupPathExists) app.vault.adapter.copy(this.plugin.spacesDBPath, backupPath); } async loadSpaceDBFromBackup(fileName) { @@ -53325,7 +53355,7 @@ var Superstate = class extends import_obsidian59.Component { await app.vault.adapter.remove(this.plugin.spacesDBPath); await app.vault.adapter.copy(filePath, this.plugin.spacesDBPath); await this.updateSpaceLastUpdated(); - this.loadSpacesDB(); + this.loadSpacesDatabaseFromDisk(); } } reloadSpace(spaceName) { @@ -53334,7 +53364,7 @@ var Superstate = class extends import_obsidian59.Component { const space = parseSpace(spaceDB); const spaceItems = this.spacesItemsDBCache.filter((f4) => f4.space == spaceName); const cache = parseSpaceCache(space, spaceItems); - this.spacesCache.set(spaceName, cache); + this.spacesIndex.set(spaceName, cache); this.persister.storeFile(spaceName + "//", JSON.stringify(cache)); this.plugin.settings.cachedSpaces = this.allSpaces().map((f4) => f4.name); this.plugin.saveSettings(); @@ -53349,17 +53379,17 @@ var Superstate = class extends import_obsidian59.Component { if (!changed && !force) { return false; } - this.files.set(file.path, cache); - this.tags.set(file.path, new Set(cache.tags)); - this.contexts.set(file.path, new Set(cache.contexts)); - if (!import_lodash9.default.isEqual(cache.spaces, Array.from(this.spaces.get(file.path)))) { - this.spaces.set(file.path, new Set(cache.spaces)); + this.filesIndex.set(file.path, cache); + this.tagsMap.set(file.path, new Set(cache.tags)); + this.contextsMap.set(file.path, new Set(cache.contexts)); + if (!import_lodash9.default.isEqual(cache.spaces, Array.from(this.spacesMap.get(file.path)))) { + this.spacesMap.set(file.path, new Set(cache.spaces)); this.broadcast("space"); } if (force) { const allContextsWithFile = cache.contexts.map((f4) => { var _a2; - return (_a2 = this.contextsCache.get(f4)) == null ? void 0 : _a2.info; + return (_a2 = this.contextsIndex.get(f4)) == null ? void 0 : _a2.info; }).filter((f4) => f4); this.addToContextStoreQueue(() => onMetadataChange(this.plugin, file, allContextsWithFile)); } @@ -53370,15 +53400,15 @@ var Superstate = class extends import_obsidian59.Component { } async fileReloaded(path) { let metadata; - if (this.files.has(path)) { - metadata = this.files.get(path); + if (this.filesIndex.has(path)) { + metadata = this.filesIndex.get(path); } if (!metadata) { return false; } let missingContexts = []; let removedContexts = []; - this.contextsCache.forEach((contextCache) => { + this.contextsIndex.forEach((contextCache) => { if (metadata.contexts.includes(contextCache.info.contextPath) && !contextCache.files.includes(path)) { missingContexts.push(contextCache.info); } else if (contextCache.files.includes(path) && !metadata.contexts.includes(contextCache.info.contextPath)) { @@ -53495,6 +53525,7 @@ var ReadingModeHeader = (props2) => { plugin: props2.plugin, file: getAbstractFileAtPath(app, path), showHeader: true, + showBanner: true, editable: false })); }; @@ -53634,6 +53665,32 @@ var patchWorkspace = (plugin) => { return false; }; }, + setActiveLeaf(old) { + return function setActiveLeaf(leaf, params) { + if (leaf.view.getViewType() == "markdown") { + this.activeEditor = leaf.view; + if (leaf.view.file) { + this._["file-open"].forEach((cb) => { + var _a2, _b2; + if ((cb == null ? void 0 : cb.fn) && ((_b2 = (_a2 = cb.ctx) == null ? void 0 : _a2.leaf) == null ? void 0 : _b2.file)) { + const bound = cb.fn.bind(cb.ctx); + bound(leaf.view.file); + } + }); + } + } + old.call(this, leaf, params); + }; + }, + getActiveViewOfType(old) { + return function getActiveViewOfType(type) { + if (type.prototype.getViewType() == "markdown") { + if (this.activeEditor) + return this.activeEditor; + } + return old.call(this, type); + }; + }, getDropLocation(old) { return function getDropLocation(event) { for (const popover of FlowEditor.activePopovers()) { @@ -53662,7 +53719,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { this.dataViewAPI = () => (0, import_obsidian_dataview.getAPI)(); this.spacesDBLastModify = 0; this.debouncedRefresh = () => null; - this.createTable = async (path) => { + this.createInlineTable = async (path) => { const context = folderContextFromFolder(this, path); const schemas = await getMDBTableSchemas(this, context); if (schemas) @@ -53705,9 +53762,9 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { this.activeFileChange(); }; this.openFileTreeLeaf = async (showAfterAttach) => { - let leafs = this.app.workspace.getLeavesOfType(FILE_TREE_VIEW_TYPE); + const leafs = this.app.workspace.getLeavesOfType(FILE_TREE_VIEW_TYPE); if (leafs.length == 0) { - let leaf = this.app.workspace.getLeftLeaf(false); + const leaf = this.app.workspace.getLeftLeaf(false); await leaf.setViewState({ type: FILE_TREE_VIEW_TYPE }); if (showAfterAttach && !app.workspace.leftSplit.collapsed) this.app.workspace.revealLeaf(leaf); @@ -53721,25 +53778,25 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { replaceMobileMainMenu(this); }; this.detachFileTreeLeafs = () => { - let leafs = this.app.workspace.getLeavesOfType(FILE_TREE_VIEW_TYPE); - for (let leaf of leafs) { + const leafs = this.app.workspace.getLeavesOfType(FILE_TREE_VIEW_TYPE); + for (const leaf of leafs) { if (leaf.view instanceof FileTreeView) leaf.view.destroy(); leaf.detach(); } }; this.detachFileContextLeafs = () => { - let leafs = this.app.workspace.getLeavesOfType(FILE_CONTEXT_VIEW_TYPE); - for (let leaf of leafs) { + const leafs = this.app.workspace.getLeavesOfType(FILE_CONTEXT_VIEW_TYPE); + for (const leaf of leafs) { if (leaf.view instanceof FileContextLeafView) leaf.view.destroy(); leaf.detach(); } }; this.openFileContextLeaf = async (reveal) => { - let leafs = this.app.workspace.getLeavesOfType(FILE_CONTEXT_VIEW_TYPE); + const leafs = this.app.workspace.getLeavesOfType(FILE_CONTEXT_VIEW_TYPE); if (leafs.length == 0) { - let leaf = this.app.workspace.getRightLeaf(false); + const leaf = this.app.workspace.getRightLeaf(false); await leaf.setViewState({ type: FILE_CONTEXT_VIEW_TYPE }); this.app.workspace.revealLeaf(leaf); } else { @@ -53767,7 +53824,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { if (cm) { const value = cm.state.field(flowEditorInfo, false); const currPosition = cm.state.selection.main; - for (let flowEditor of value) { + for (const flowEditor of value) { if (flowEditor.from < currPosition.to && flowEditor.to > currPosition.from) { cm.dispatch({ annotations: toggleFlowEditor.of([flowEditor.id, 2]) @@ -53781,7 +53838,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { if (cm) { const value = cm.state.field(flowEditorInfo, false); const currPosition = cm.state.selection.main; - for (let flowEditor of value) { + for (const flowEditor of value) { if (flowEditor.from < currPosition.to && flowEditor.to > currPosition.from) { cm.dispatch({ annotations: toggleFlowEditor.of([flowEditor.id, 0]) @@ -53799,7 +53856,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { } } quickOpen() { - let quickOpenModal = new Blink(this.app, this); + const quickOpenModal = new Blink(this.app, this); quickOpenModal.open(); } toggleBold() { @@ -53875,6 +53932,17 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { app.workspace.on("active-leaf-change", () => this.activeFileChange()) ); } + convertFolderNote() { + const activeLeaf = app.workspace.activeLeaf; + if ((activeLeaf == null ? void 0 : activeLeaf.view.getViewType()) == "markdown") { + const view = app.workspace.getActiveViewOfType(import_obsidian62.MarkdownView); + if (view instanceof import_obsidian62.MarkdownView && view.file instanceof import_obsidian62.TFile) { + noteToFolderNote(this, view.file, true); + } + } else { + new import_obsidian62.Notice("The view is not a note"); + } + } getActiveFile() { let filePath = null; const activeLeaf = app.workspace.activeLeaf; @@ -53899,8 +53967,8 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { activeFileChange() { const path = this.getActiveFile(); if (path) { - let evt = new CustomEvent(eventTypes.activePathChange, { - detail: { path: pathByString(this, path) } + const evt = new CustomEvent(eventTypes.activePathChange, { + detail: { path: pathByString(path) } }); window.dispatchEvent(evt); } @@ -53911,9 +53979,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { id: "mk-collapse-folders", name: i18n_default.commandPalette.collapseAllFolders, callback: () => { - this.settings.expandedFolders = { - "/": [] - }; + this.settings.expandedFolders = {}; this.saveSettings(); } }); @@ -53922,7 +53988,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { name: i18n_default.commandPalette.revealFile, callback: () => { const file = getAbstractFileAtPath(app, this.getActiveFile()); - let evt = new CustomEvent(eventTypes.revealFile, { + const evt = new CustomEvent(eventTypes.revealFile, { detail: { file } }); window.dispatchEvent(evt); @@ -53932,7 +53998,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { id: "mk-spaces-add-file", name: i18n_default.commandPalette.addFileSpace, callback: () => { - let vaultChangeModal = new AddToSpaceModal(this, [ + const vaultChangeModal = new AddToSpaceModal(this, [ this.getActiveFile() ]); vaultChangeModal.open(); @@ -53940,9 +54006,9 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { }); this.addCommand({ id: "mk-spaces-remove-file", - name: i18n_default.commandPalette.addFileSpace, + name: i18n_default.commandPalette.removeFileSpace, callback: () => { - let vaultChangeModal = new RemoveFromSpaceModal( + const vaultChangeModal = new RemoveFromSpaceModal( this, this.getActiveFile() ); @@ -53952,7 +54018,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { this.addCommand({ id: "mk-spaces-reload", name: i18n_default.commandPalette.reloadSpaces, - callback: () => this.index.loadSpacesDB() + callback: () => this.index.loadSpacesDatabaseFromDisk() }); this.addCommand({ id: "mk-spaces-load-backup", @@ -53962,7 +54028,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { (0, import_obsidian62.normalizePath)(`${app.vault.configDir}/plugins/make-md/backups`) ).then( (f4) => { - let vaultChangeModal = new LoadSpaceBackupModal(this, f4.files.map((f5) => filePathToString(f5))); + const vaultChangeModal = new LoadSpaceBackupModal(this, f4.files.map((f5) => filePathToString(f5))); vaultChangeModal.open(); } ); @@ -53979,6 +54045,13 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { callback: () => this.openFileTreeLeaf(true) }); } + if (this.settings.enableFolderNote) { + this.addCommand({ + id: "mk-convert-folder-note", + name: i18n_default.commandPalette.convertFolderNote, + callback: () => this.convertFolderNote() + }); + } if (this.settings.contextEnabled) { this.addCommand({ id: "mk-open-file-context", @@ -53991,7 +54064,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { id: "mk-toggle-backlinks", name: i18n_default.commandPalette.toggleBacklinks, callback: () => { - let evt = new CustomEvent(eventTypes.toggleBacklinks); + const evt = new CustomEvent(eventTypes.toggleBacklinks); window.dispatchEvent(evt); } }); @@ -54021,30 +54094,6 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { callback: () => this.closeFlow() }); } - if (this.settings.makerMode) { - this.addCommand({ - id: "mk-toggle-bold", - name: i18n_default.commandPalette.toggleBold, - callback: () => this.toggleBold(), - hotkeys: [ - { - modifiers: ["Mod"], - key: "b" - } - ] - }); - this.addCommand({ - id: "mk-toggle-italics", - name: i18n_default.commandPalette.toggleItalics, - callback: () => this.toggleEm(), - hotkeys: [ - { - modifiers: ["Mod"], - key: "i" - } - ] - }); - } } loadContext() { if (this.settings.contextEnabled) { @@ -54183,7 +54232,7 @@ var MakeMDPlugin = class extends import_obsidian62.Plugin { async saveSettings(refresh = true) { await this.saveData(this.settings); if (refresh) { - let evt = new CustomEvent(eventTypes.settingsChanged, {}); + const evt = new CustomEvent(eventTypes.settingsChanged, {}); window.dispatchEvent(evt); } } diff --git a/manifest.json b/manifest.json index 3d03f4a..b67d5bd 100755 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "make-md", "name": "MAKE.md", - "version": "0.7.10", + "version": "0.7.11", "minAppVersion": "0.16.0", "description": "Make.md brings you features that supercharges Obsidian. Sort your files in custom order and add file icons using Spaces. Edit inline embeds with Flow Editor. And style your text and add new markdown blocks without writing markdown using Maker Mode.", "author": "MAKE.md", diff --git a/styles.css b/styles.css index 2ce82ae..ec35b67 100644 --- a/styles.css +++ b/styles.css @@ -19,7 +19,7 @@ max-width: var(--file-line-width); width: 100%; } -.mk-folder-outter { +.mk-folder-outer { padding: 0 var(--file-margins); width: 100%; } @@ -114,11 +114,12 @@ padding: 0px 12px; width: 100%; } -.mk-flowspace-editor .mk-floweditor { +.mk-flowspace-editor:not(.mk-foldernote) .mk-floweditor { padding: 12px 0px; } .mk-flowspace-editor.mk-foldernote { width: var(--file-line-width); + max-width: 100%; margin-left: auto; margin-right: auto; } @@ -731,6 +732,9 @@ body { background-color: unset !important; gap: 0; } +.mk-space-settings { + margin-bottom: 12px; +} .menu-item-title { display: flex; justify-content: space-between; @@ -1487,7 +1491,7 @@ body { min-height: 600px; height: calc(100vh - 100px); } -.mk-floweditor .cm-content { +div:not(.mk-flowspace-editor) > .mk-floweditor .cm-content { padding: 0 !important; } .markdown-source-view.mod-cm6 .cm-content > .internal-embed { @@ -1548,6 +1552,7 @@ body { .mk-flow-seamless .markdown-embed-title { display: none; } +.mk-foldernote > .mk-floweditor > .popover-content > .mk-flow-titlebar, .mk-flow-minimal .mk-flow-titlebar, .mk-flow-seamless .mk-flow-titlebar { display: none; @@ -1576,7 +1581,7 @@ body { .mk-flow-minimal .internal-embed.markdown-embed { padding: 8px; border-radius: 4px; - border: thin solid var(--color-base-20); + border: thin solid var(--divider-color); margin-top: 4px; } .mk-flow-seamless .internal-embed > .markdown-embed, @@ -1615,6 +1620,13 @@ body { .mk-floweditor-container { min-height: var(--flow-height); } +.mk-floweditor-container > .mk-floweditor { + border: thin solid transparent; +} +.mk-floweditor-container > .mk-floweditor:hover { + background: rgba(0, 0, 0, 0.04) !important; + border: thin solid var(--divider-color); +} .mk-flow-minimal .mk-floweditor-container > .mk-floweditor:hover { box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.06), @@ -1649,31 +1661,41 @@ body { .mk-flow-minimal .internal-embed.markdown-embed > .mk-floweditor-selector, .mk-flow-seamless .internal-embed > .markdown-embed > .mk-floweditor-selector, .mk-flow-seamless .internal-embed.markdown-embed > .mk-floweditor-selector { - top: -22px !important; - right: 4px; + top: 8px; + right: 8px; } .mk-flow-minimal .cm-line > .mk-floweditor-selector, .mk-flow-seamless .cm-line > .mk-floweditor-selector { - top: 3px !important; + top: 8px; + right: 8px; } .mk-floweditor-selector { position: absolute; - visibility: hidden; - top: 30px; - right: 5px; + right: 0px; + top: 8px; z-index: var(--layer-popover); - padding-right: 8px; - height: 30px; + visibility: hidden; + height: 32px; display: flex; - gap: 6px; } -.mk-hover-button { - padding: 4px 6px; - border-radius: 4px; - background: var(--background-primary); - border: thin solid var(--background-modifier-border-hover); +.mk-flowblock-menu { + border-radius: var(--radius-s); + display: flex; + font-size: var(--font-ui-smaller); + border: 1px solid var(--background-modifier-border); + background: var(--interactive-normal); + box-shadow: var(--input-shadow); } -.mk-hover-button:hover { +.mk-flowblock-menu .mk-hover-button { + padding: var(--size-4-2); + color: var(--text-muted); + border: none; + border-right: 1px solid var(--background-modifier-border); +} +.mk-flowblock-menu .mk-hover-button:last-child { + border-right: none; +} +.mk-flowblock-menu .mk-hover-button:hover { background: var(--background-secondary-alt); } .mk-floweditor > .workspace-leaf > .workspace-leaf-content > .view-content > .markdown-source-view.mod-cm6 > .cm-editor > .cm-scroller { @@ -1767,6 +1789,7 @@ mark { padding-inline-start: 0 !important; text-indent: 0 !important; } +.mk-folder-header .mk-file-icon-placeholder button, .mk-header .mk-file-context-component .mk-file-icon-placeholder button { background: var(--background-secondary); border-radius: 8px; @@ -2504,6 +2527,9 @@ body:not(.is-mobile) .mk-main-menu-button:hover { .workspace-leaf:not(.mod-active) .is-selected { background: var(--nav-item-background-active) !important; } +.workspace-leaf.mod-active .is-highlighted { + background: var(--nav-item-background-active) !important; +} .is-phone .mk-inline-button { width: unset !important; }