diff --git a/.obsidian/graph.json b/.obsidian/graph.json index 1ef7166..9c4d3f8 100755 --- a/.obsidian/graph.json +++ b/.obsidian/graph.json @@ -8,7 +8,7 @@ "collapse-color-groups": false, "colorGroups": [ { - "query": "tag:Praktikum", + "query": "file:Tasks", "color": { "a": 1, "rgb": 14701138 diff --git a/.obsidian/plugins/obsidian-git/main.js b/.obsidian/plugins/obsidian-git/main.js index 5b1b9f2..f8e601d 100755 --- a/.obsidian/plugins/obsidian-git/main.js +++ b/.obsidian/plugins/obsidian-git/main.js @@ -33093,122 +33093,15 @@ var ObsidianGitSettingsTab = class extends import_obsidian8.PluginSettingTab { With all commits, cut-copy-paste-ing text inbetween multiple commits will be detected.
It uses git-blame and - for matches (at least ${GIT_LINE_AUTHORING_MOVEMENT_DETECTION_MINIMAL_LENGTH} characters) within the same (or all) commit(s), the originating commit's information is shown.`; - new import_obsidian8.Setting(this.containerEl).setName("Show commit hash").addToggle((tgl) => { - tgl.setValue(this.settings.lineAuthor.showCommitHash); - tgl.onChange( - async (value) => this.lineAuthorSettingHandler("showCommitHash", value) - ); - }); - new import_obsidian8.Setting(this.containerEl).setName("Author name display").setDesc("If and how the author is displayed").addDropdown((dropdown) => { - const options = { - hide: "Hide", - initials: "Initials (default)", - "first name": "First name", - "last name": "Last name", - full: "Full name" - }; - dropdown.addOptions(options); - dropdown.setValue(this.settings.lineAuthor.authorDisplay); - dropdown.onChange( - async (value) => this.lineAuthorSettingHandler("authorDisplay", value) - ); - }); - new import_obsidian8.Setting(this.containerEl).setName("Authoring date display").setDesc( - "If and how the date and time of authoring the line is displayed" - ).addDropdown((dropdown) => { - const options = { - hide: "Hide", - date: "Date (default)", - datetime: "Date and time", - "natural language": "Natural language", - custom: "Custom" - }; - dropdown.addOptions(options); - dropdown.setValue( - this.settings.lineAuthor.dateTimeFormatOptions - ); - dropdown.onChange( - async (value) => { - this.lineAuthorSettingHandler( - "dateTimeFormatOptions", - value - ); - this.display(); - } - ); - }); - if (this.settings.lineAuthor.dateTimeFormatOptions === "custom") { - const dateTimeFormatCustomStringSetting = new import_obsidian8.Setting( - this.containerEl - ); - dateTimeFormatCustomStringSetting.setName("Custom authoring date format").addText((cb) => { - cb.setValue( - this.settings.lineAuthor.dateTimeFormatCustomString - ); - cb.setPlaceholder("YYYY-MM-DD HH:mm"); - cb.onChange((value) => { - this.lineAuthorSettingHandler( - "dateTimeFormatCustomString", - value - ); - dateTimeFormatCustomStringSetting.descEl.innerHTML = this.previewCustomDateTimeDescriptionHtml( - value - ); - }); - }); - dateTimeFormatCustomStringSetting.descEl.innerHTML = this.previewCustomDateTimeDescriptionHtml( - this.settings.lineAuthor.dateTimeFormatCustomString - ); - } - new import_obsidian8.Setting(this.containerEl).setName("Authoring date display timezone").addDropdown((dropdown) => { - const options = { - "viewer-local": "My local (default)", - "author-local": "Author's local", - utc0000: "UTC+0000/Z" - }; - dropdown.addOptions(options); - dropdown.setValue( - this.settings.lineAuthor.dateTimeTimezone - ); - dropdown.onChange( - async (value) => this.lineAuthorSettingHandler("dateTimeTimezone", value) - ); - }).descEl.innerHTML = ` + for matches (at least ${dd} characters) within the same (or all) commit(s), the originating commit's information is shown.`,new z.Setting(this.containerEl).setName("Show commit hash").addToggle(a=>{a.setValue(this.settings.lineAuthor.showCommitHash),a.onChange(s=>this.lineAuthorSettingHandler("showCommitHash",s))}),new z.Setting(this.containerEl).setName("Author name display").setDesc("If and how the author is displayed").addDropdown(a=>{let s={hide:"Hide",initials:"Initials (default)","first name":"First name","last name":"Last name",full:"Full name"};a.addOptions(s),a.setValue(this.settings.lineAuthor.authorDisplay),a.onChange(async o=>this.lineAuthorSettingHandler("authorDisplay",o))}),new z.Setting(this.containerEl).setName("Authoring date display").setDesc("If and how the date and time of authoring the line is displayed").addDropdown(a=>{let s={hide:"Hide",date:"Date (default)",datetime:"Date and time","natural language":"Natural language",custom:"Custom"};a.addOptions(s),a.setValue(this.settings.lineAuthor.dateTimeFormatOptions),a.onChange(async o=>{await this.lineAuthorSettingHandler("dateTimeFormatOptions",o),this.refreshDisplayWithDelay()})}),this.settings.lineAuthor.dateTimeFormatOptions==="custom"){let a=new z.Setting(this.containerEl);a.setName("Custom authoring date format").addText(s=>{s.setValue(this.settings.lineAuthor.dateTimeFormatCustomString),s.setPlaceholder("YYYY-MM-DD HH:mm"),s.onChange(async o=>{await this.lineAuthorSettingHandler("dateTimeFormatCustomString",o),a.descEl.innerHTML=this.previewCustomDateTimeDescriptionHtml(o)})}),a.descEl.innerHTML=this.previewCustomDateTimeDescriptionHtml(this.settings.lineAuthor.dateTimeFormatCustomString)}new z.Setting(this.containerEl).setName("Authoring date display timezone").addDropdown(a=>{let s={"viewer-local":"My local (default)","author-local":"Author's local",utc0000:"UTC+0000/Z"};a.addOptions(s),a.setValue(this.settings.lineAuthor.dateTimeTimezone),a.onChange(async o=>this.lineAuthorSettingHandler("dateTimeTimezone",o))}).descEl.innerHTML=` The time-zone in which the authoring date should be shown. Either your local time-zone (default), the author's time-zone during commit creation or UTC\xB100:00. - `; - const oldestAgeSetting = new import_obsidian8.Setting(this.containerEl).setName( - "Oldest age in coloring" - ); - oldestAgeSetting.descEl.innerHTML = this.previewOldestAgeDescriptionHtml( - this.settings.lineAuthor.coloringMaxAge - )[0]; - oldestAgeSetting.addText((text2) => { - text2.setPlaceholder("1y"); - text2.setValue(this.settings.lineAuthor.coloringMaxAge); - text2.onChange((value) => { - const [preview, valid] = this.previewOldestAgeDescriptionHtml(value); - oldestAgeSetting.descEl.innerHTML = preview; - if (valid) { - this.lineAuthorSettingHandler("coloringMaxAge", value); - this.refreshColorSettingsName("oldest"); - } - }); - }); - this.createColorSetting("newest"); - this.createColorSetting("oldest"); - new import_obsidian8.Setting(this.containerEl).setName("Text color").addText((field) => { - field.setValue(this.settings.lineAuthor.textColorCss); - field.onChange((value) => { - this.lineAuthorSettingHandler("textColorCss", value); - }); - }).descEl.innerHTML = ` + `;let i=new z.Setting(this.containerEl).setName("Oldest age in coloring");i.descEl.innerHTML=this.previewOldestAgeDescriptionHtml(this.settings.lineAuthor.coloringMaxAge)[0],i.addText(a=>{a.setPlaceholder("1y"),a.setValue(this.settings.lineAuthor.coloringMaxAge),a.onChange(async s=>{let[o,l]=this.previewOldestAgeDescriptionHtml(s);i.descEl.innerHTML=o,l&&(await this.lineAuthorSettingHandler("coloringMaxAge",s),this.refreshColorSettingsName("oldest"))})}),this.createColorSetting("newest"),this.createColorSetting("oldest"),new z.Setting(this.containerEl).setName("Text color").addText(a=>{a.setValue(this.settings.lineAuthor.textColorCss),a.onChange(async s=>{await this.lineAuthorSettingHandler("textColorCss",s)})}).descEl.innerHTML=` The CSS color of the gutter text.
- - It is higly recommended to use + + It is highly recommended to use CSS variables defined by themes @@ -33219,13 +33112,7 @@ var ObsidianGitSettingsTab = class extends import_obsidian8.PluginSettingTab { See: List of available CSS variables in Obsidian - `; - new import_obsidian8.Setting(this.containerEl).setName("Ignore whitespace and newlines in changes").addToggle((tgl) => { - tgl.setValue(this.settings.lineAuthor.ignoreWhitespace); - tgl.onChange( - (value) => this.lineAuthorSettingHandler("ignoreWhitespace", value) - ); - }).descEl.innerHTML = ` + `,new z.Setting(this.containerEl).setName("Ignore whitespace and newlines in changes").addToggle(a=>{a.setValue(this.settings.lineAuthor.ignoreWhitespace),a.onChange(s=>this.lineAuthorSettingHandler("ignoreWhitespace",s))}).descEl.innerHTML=` Whitespace and newlines are interpreted as part of the document and in changes by default (hence not ignored). @@ -33236,12011 +33123,182 @@ var ObsidianGitSettingsTab = class extends import_obsidian8.PluginSettingTab { If you don't care about purely-whitespace changes (e.g. list nesting / quote indentation changes), then activating this will provide more meaningful change detection. - `; - } - } - createColorSetting(which) { - const setting = new import_obsidian8.Setting(this.containerEl).setName("").addText((text2) => { - const color = pickColor(which, this.settings.lineAuthor); - const defaultColor = pickColor( - which, - DEFAULT_SETTINGS.lineAuthor - ); - text2.setPlaceholder(rgbToString(defaultColor)); - text2.setValue(rgbToString(color)); - text2.onChange((colorNew) => { - const rgb = convertToRgb(colorNew); - if (rgb !== void 0) { - const key2 = which === "newest" ? "colorNew" : "colorOld"; - this.lineAuthorSettingHandler(key2, rgb); - } - this.refreshColorSettingsDesc(which, rgb); - }); - }); - this.lineAuthorColorSettings.set(which, setting); - this.refreshColorSettingsName(which); - this.refreshColorSettingsDesc( - which, - pickColor(which, this.settings.lineAuthor) - ); - } - refreshColorSettingsName(which) { - const settingsDom = this.lineAuthorColorSettings.get(which); - if (settingsDom) { - const whichDescriber = which === "oldest" ? `oldest (${this.settings.lineAuthor.coloringMaxAge} or older)` : "newest"; - settingsDom.nameEl.innerText = `Color for ${whichDescriber} commits`; - } - } - refreshColorSettingsDesc(which, rgb) { - const settingsDom = this.lineAuthorColorSettings.get(which); - if (settingsDom) { - settingsDom.descEl.innerHTML = this.colorSettingPreviewDescHtml( - which, - this.settings.lineAuthor, - rgb !== void 0 - ); - } - } - colorSettingPreviewDescHtml(which, laSettings, colorIsValid) { - const rgbStr = colorIsValid ? previewColor(which, laSettings) : `rgba(127,127,127,0.3)`; - const today = import_obsidian8.moment.unix(import_obsidian8.moment.now() / 1e3).format("YYYY-MM-DD"); - const text2 = colorIsValid ? `abcdef Author Name ${today}` : "invalid color"; - const preview = `
{let a=Rv(r,this.settings.lineAuthor),s=Rv(r,Xe.lineAuthor);i.setPlaceholder(mv(s)),i.setValue(mv(a)),i.onChange(async o=>{let l=n3(o);if(l!==void 0){let c=r==="newest"?"colorNew":"colorOld";await this.lineAuthorSettingHandler(c,l)}this.refreshColorSettingsDesc(r,l)})});this.lineAuthorColorSettings.set(r,n),this.refreshColorSettingsName(r),this.refreshColorSettingsDesc(r,Rv(r,this.settings.lineAuthor))}refreshColorSettingsName(r){let n=this.lineAuthorColorSettings.get(r);if(n){let i=r==="oldest"?`oldest (${this.settings.lineAuthor.coloringMaxAge} or older)`:"newest";n.nameEl.innerText=`Color for ${i} commits`}}refreshColorSettingsDesc(r,n){let i=this.lineAuthorColorSettings.get(r);i&&(i.descEl.innerHTML=this.colorSettingPreviewDescHtml(r,this.settings.lineAuthor,n!==void 0))}colorSettingPreviewDescHtml(r,n,i){let a=i?Mv(r,n):"rgba(127,127,127,0.3)",s=z.moment.unix(z.moment.now()/1e3).format("YYYY-MM-DD"),o=i?`abcdef Author Name ${s}`:"invalid color";return`Supports 'rgb(r,g,b)', 'hsl(h,s,l)', hex (#) and + named colors (e.g. 'black', 'purple'). Color preview: ${`
${text2}
`; - return `Supports 'rgb(r,g,b)', 'hsl(h,s,l)', hex (#) and - named colors (e.g. 'black', 'purple'). Color preview: ${preview}`; - } - previewCustomDateTimeDescriptionHtml(dateTimeFormatCustomString) { - const formattedDateTime = (0, import_obsidian8.moment)().format(dateTimeFormatCustomString); - return `
Format string to display the authoring date.
Currently: ${formattedDateTime}`; - } - previewOldestAgeDescriptionHtml(coloringMaxAge) { - const duration = parseColoringMaxAgeDuration(coloringMaxAge); - const durationString = duration !== void 0 ? `${duration.asDays()} days` : "invalid!"; - return [ - `The oldest age in the line author coloring. Everything older will have the same color. -
Smallest valid age is "1d". Currently: ${durationString}`, - duration - ]; - } -}; -function pickColor(which, las) { - return which === "oldest" ? las.colorOld : las.colorNew; -} -function parseColoringMaxAgeDuration(durationString) { - const duration = import_obsidian8.moment.duration("P" + durationString.toUpperCase()); - return duration.isValid() && duration.asDays() && duration.asDays() >= 1 ? duration : void 0; -} - -// src/lineAuthor/model.ts -function lineAuthoringId(head, objHash, path2) { - if (head === void 0 || objHash === void 0 || path2 === void 0) { - return void 0; - } - return `head${head}-obj${objHash}-path${path2}`; -} -var LineAuthoringContainerType = import_state.Annotation.define(); -function newComputationResultAsTransaction(key2, la, state) { - return state.update({ - annotations: LineAuthoringContainerType.of({ - key: key2, - la, - lineOffsetsFromUnsavedChanges: /* @__PURE__ */ new Map() - }) - }); -} -function getLineAuthorAnnotation(tr) { - return tr.annotation(LineAuthoringContainerType); -} -var lineAuthorState = import_state.StateField.define({ - create: (_state) => void 0, - /** - * The state can be updated from either an annotated transaction containing - * the newest line authoring (for the saved document) - or from - * unsaved changes of the document as the user is actively typing in the editor. - * - * In the first case, we take the new line authoring and discard anything we had remembered - * from unsaved changes. In the second case, we use the unsaved changes in {@link enrichUnsavedChanges} to pre-compute information to immediately update the - * line author gutter without needing to wait until the document is saved and the - * line authoring is properly computed. - */ - update: (previous, transaction) => { - var _a2; - return (_a2 = getLineAuthorAnnotation(transaction)) != null ? _a2 : enrichUnsavedChanges(transaction, previous); - }, - // compare cache keys. - // equality rate is >= 95% :) - // hence avoids recomputation of views - compare: (l, r) => (l == null ? void 0 : l.key) === (r == null ? void 0 : r.key) -}); -function laStateDigest(laState) { - var _a2; - const digest = import_js_sha256.sha256.create(); - if (!laState) - return digest; - const { la, key: key2, lineOffsetsFromUnsavedChanges } = laState; - digest.update(la === "untracked" ? "t" : "f"); - digest.update(key2); - for (const [k, v] of (_a2 = lineOffsetsFromUnsavedChanges.entries()) != null ? _a2 : []) - digest.update([k, v]); - return digest; -} -var latestSettings = { - get: void 0, - save: void 0 -}; -function provideSettingsAccess(settingsGetter, settingsSetter) { - latestSettings.get = settingsGetter; - latestSettings.save = settingsSetter; -} -function maxAgeInDaysFromSettings(settings) { - var _a2, _b; - return (_b = (_a2 = parseColoringMaxAgeDuration(settings.coloringMaxAge)) == null ? void 0 : _a2.asDays()) != null ? _b : parseColoringMaxAgeDuration( - DEFAULT_SETTINGS.lineAuthor.coloringMaxAge - ).asDays(); -} -function enrichUnsavedChanges(tr, prev) { - if (!prev) - return void 0; - if (!tr.changes.empty) { - tr.changes.iterChanges((fromA, toA, fromB, toB) => { - var _a2; - const oldDoc = tr.startState.doc; - const { newDoc } = tr; - const beforeFrom = oldDoc.lineAt(fromA).number; - const beforeTo = oldDoc.lineAt(toA).number; - const afterFrom = newDoc.lineAt(fromB).number; - const afterTo = newDoc.lineAt(toB).number; - const beforeLen = beforeTo - beforeFrom + 1; - const afterLen = afterTo - afterFrom + 1; - for (let afterI = afterFrom; afterI <= afterTo; afterI++) { - let offset = (_a2 = prev.lineOffsetsFromUnsavedChanges.get(afterI)) != null ? _a2 : 0; - const isLastLine = afterTo === afterI; - const changeInNumberOfLines = afterLen - beforeLen; - if (isLastLine) - offset += changeInNumberOfLines; - prev.lineOffsetsFromUnsavedChanges.set(afterI, offset); - } - }); - } - return prev; -} - -// src/lineAuthor/control.ts -var LineAuthoringSubscriber = class { - // remember path to detect and adapt to renames - constructor(state) { - this.state = state; - this.subscribeMe(); - } - async notifyLineAuthoring(id, la) { - if (this.view === void 0) { - console.warn( - `Git: View is not defined for editor cache key. Unforeseen situation. id: ${id}` - ); - return; - } - const state = this.view.state; - const transaction = newComputationResultAsTransaction(id, la, state); - this.view.dispatch(transaction); - } - updateToNewState(state) { - const filepathChanged = this.lastSeenPath && this.filepath != this.lastSeenPath; - this.state = state; - if (filepathChanged) { - this.unsubscribeMe(this.lastSeenPath); - this.subscribeMe(); - } - return this; - } - removeIfStale() { - if (this.view.destroyed) { - this.unsubscribeMe(this.lastSeenPath); - } - } - subscribeMe() { - if (this.filepath === void 0) - return; - eventsPerFilePathSingleton.ifFilepathDefinedTransformSubscribers( - this.filepath, - (subs) => subs.add(this) - ); - this.lastSeenPath = this.filepath; - } - unsubscribeMe(oldFilepath) { - eventsPerFilePathSingleton.ifFilepathDefinedTransformSubscribers( - oldFilepath, - (subs) => subs.delete(this) - ); - } - get filepath() { - var _a2, _b; - return (_b = (_a2 = this.state.field(import_obsidian9.editorViewField)) == null ? void 0 : _a2.file) == null ? void 0 : _b.path; - } - get view() { - return this.state.field(import_obsidian9.editorEditorField); - } -}; -var subscribeNewEditor = import_state2.StateField.define({ - create: (state) => new LineAuthoringSubscriber(state), - update: (v, transaction) => v.updateToNewState(transaction.state), - compare: (a, b) => a === b -}); - -// src/lineAuthor/view/cache.ts -init_polyfill_buffer(); -function clearViewCache() { - longestRenderedGutter = void 0; - renderedAgeInDaysForAdaptiveInitialColoring = []; - ageIdx = 0; - gutterInstances.clear(); - gutterMarkersRangeSet.clear(); - attachedGutterElements.clear(); -} -var longestRenderedGutter = void 0; -var getLongestRenderedGutter = () => longestRenderedGutter; -function conditionallyUpdateLongestRenderedGutter(gutter2, text2) { - var _a2; - const length = text2.length; - if (length < ((_a2 = longestRenderedGutter == null ? void 0 : longestRenderedGutter.length) != null ? _a2 : 0)) - return; - longestRenderedGutter = { gutter: gutter2, length, text: text2 }; - const settings = latestSettings.get(); - if (length !== settings.gutterSpacingFallbackLength) { - settings.gutterSpacingFallbackLength = length; - latestSettings.save(settings); - } -} -var renderedAgeInDaysForAdaptiveInitialColoring = []; -var ADAPTIVE_INITIAL_COLORING_AGE_CACHE_SIZE = 15; -var ageIdx = 0; -function recordRenderedAgeInDays(age) { - renderedAgeInDaysForAdaptiveInitialColoring[ageIdx] = age; - ageIdx = (ageIdx + 1) % ADAPTIVE_INITIAL_COLORING_AGE_CACHE_SIZE; -} -function computeAdaptiveInitialColoringAgeInDays() { - return median(renderedAgeInDaysForAdaptiveInitialColoring); -} -var gutterInstances = /* @__PURE__ */ new Map(); -var gutterMarkersRangeSet = /* @__PURE__ */ new Map(); -var attachedGutterElements = /* @__PURE__ */ new Set(); - -// src/lineAuthor/view/view.ts -init_polyfill_buffer(); -var import_state3 = require("@codemirror/state"); -var import_view2 = require("@codemirror/view"); - -// src/lineAuthor/view/gutter/gutter.ts -init_polyfill_buffer(); -var import_view = require("@codemirror/view"); -var import_js_sha2562 = __toESM(require_sha256()); -var import_obsidian10 = require("obsidian"); - -// src/lineAuthor/view/contextMenu.ts -init_polyfill_buffer(); - -// src/lineAuthor/view/gutter/gutterElementSearch.ts -init_polyfill_buffer(); -var mouseXY = { x: -10, y: -10 }; -function prepareGutterSearchForContextMenuHandling() { - if (mouseXY.x === -10) { - window.addEventListener("mousedown", (e) => { - mouseXY.x = e.clientX; - mouseXY.y = e.clientY; - }); - } -} -function findGutterElementUnderMouse() { - for (const elt of attachedGutterElements) { - if (contains(elt, mouseXY)) - return elt; - } -} -function contains(elt, pt) { - const { x, y, width, height } = elt.getBoundingClientRect(); - return x <= pt.x && pt.x <= x + width && y <= pt.y && pt.y <= y + height; -} - -// src/pluginGlobalRef.ts -init_polyfill_buffer(); -var pluginRef = {}; - -// src/lineAuthor/view/contextMenu.ts -var COMMIT_ATTR = "data-commit"; -function handleContextMenu(menu, editor, _mdv) { - if (editor.hasFocus()) - return; - const gutterElement = findGutterElementUnderMouse(); - if (!gutterElement) - return; - const info = getCommitInfo(gutterElement); - if (!info) - return; - if (!info.isZeroCommit && !info.isWaitingGutter) { - addCopyHashMenuItem(info, menu); - } - addConfigurableLineAuthorSettings("showCommitHash", menu); - addConfigurableLineAuthorSettings("authorDisplay", menu); - addConfigurableLineAuthorSettings("dateTimeFormatOptions", menu); -} -function addCopyHashMenuItem(commit2, menu) { - menu.addItem( - (item) => item.setTitle("Copy commit hash").setIcon("copy").setSection("obs-git-line-author-copy").onClick((_e) => navigator.clipboard.writeText(commit2.hash)) - ); -} -function addConfigurableLineAuthorSettings(key2, menu) { - var _a2, _b; - let title; - let actionNewValue; - const settings = pluginRef.plugin.settings.lineAuthor; - const currentValue = settings[key2]; - const currentlyShown = typeof currentValue === "boolean" ? currentValue : currentValue !== "hide"; - const defaultValue = DEFAULT_SETTINGS.lineAuthor[key2]; - if (key2 === "showCommitHash") { - title = "Show commit hash"; - actionNewValue = !currentValue; - } else if (key2 === "authorDisplay") { - const showOption = (_a2 = settings.lastShownAuthorDisplay) != null ? _a2 : defaultValue; - title = "Show author " + (currentlyShown ? currentValue : showOption); - actionNewValue = currentlyShown ? "hide" : showOption; - } else if (key2 === "dateTimeFormatOptions") { - const showOption = (_b = settings.lastShownDateTimeFormatOptions) != null ? _b : defaultValue; - title = "Show " + (currentlyShown ? currentValue : showOption); - title += !title.contains("date") ? " date" : ""; - actionNewValue = currentlyShown ? "hide" : showOption; - } else { - impossibleBranch(key2); - } - menu.addItem( - (item) => item.setTitle(title).setSection("obs-git-line-author-configure").setChecked(currentlyShown).onClick( - (_e) => { - var _a3, _b2; - return (_b2 = (_a3 = pluginRef.plugin) == null ? void 0 : _a3.settingsTab) == null ? void 0 : _b2.lineAuthorSettingHandler( - key2, - actionNewValue - ); - } - ) - ); -} -function enrichCommitInfoForContextMenu(commit2, isWaitingGutter, elt) { - elt.setAttr( - COMMIT_ATTR, - JSON.stringify({ - hash: commit2.hash, - isZeroCommit: commit2.isZeroCommit, - isWaitingGutter - }) - ); -} -function getCommitInfo(elt) { - const commitInfoStr = elt.getAttr(COMMIT_ATTR); - return commitInfoStr ? JSON.parse(commitInfoStr) : void 0; -} - -// src/lineAuthor/view/gutter/coloring.ts -init_polyfill_buffer(); -function previewColor(which, settings) { - return which === "oldest" ? coloringBasedOnCommitAge(0, false, settings).color : coloringBasedOnCommitAge(void 0, true, settings).color; -} -function coloringBasedOnCommitAge(commitAuthorEpochSeonds, isZeroCommit, settings) { - const maxAgeInDays = maxAgeInDaysFromSettings(settings); - const epochSecondsNow = Date.now() / 1e3; - const authoringEpochSeconds = commitAuthorEpochSeonds != null ? commitAuthorEpochSeonds : 0; - const secondsSinceCommit = isZeroCommit ? 0 : epochSecondsNow - authoringEpochSeconds; - const daysSinceCommit = secondsSinceCommit / 60 / 60 / 24; - const x = Math.pow( - Math.clamp(daysSinceCommit / maxAgeInDays, 0, 1), - 1 / 2.3 - ); - const dark = isDarkMode(); - const color0 = settings.colorNew; - const color1 = settings.colorOld; - const scaling = dark ? 0.4 : 1; - const r = lin(color0.r, color1.r, x) * scaling; - const g = lin(color0.g, color1.g, x) * scaling; - const b = lin(color0.b, color1.b, x) * scaling; - const a = dark ? 0.75 : 0.25; - return { color: `rgba(${r},${g},${b},${a})`, daysSinceCommit }; -} -function lin(z0, z1, x) { - return z0 + (z1 - z0) * x; -} -function isDarkMode() { - const obsidian = window == null ? void 0 : window.app; - return (obsidian == null ? void 0 : obsidian.getTheme()) === "obsidian"; -} -function setTextColorCssBasedOnSetting(settings) { - document.body.style.setProperty( - "--obs-git-gutter-text", - settings.textColorCss - ); -} - -// src/lineAuthor/view/gutter/commitChoice.ts -init_polyfill_buffer(); -function chooseNewestCommit(lineAuthoring, startLine, endLine) { - let newest = void 0; - for (let line = startLine; line <= endLine; line++) { - const currentHash = lineAuthoring.hashPerLine[line]; - const currentCommit = lineAuthoring.commits.get(currentHash); - if (!newest || currentCommit.isZeroCommit || isNewerThan(currentCommit, newest)) { - newest = currentCommit; - } - } - return newest; -} -function isNewerThan(left, right) { - var _a2, _b, _c, _d; - const l = (_b = (_a2 = left.author) == null ? void 0 : _a2.epochSeconds) != null ? _b : 0; - const r = (_d = (_c = right.author) == null ? void 0 : _c.epochSeconds) != null ? _d : 0; - return l > r; -} - -// src/lineAuthor/view/gutter/gutter.ts -var VALUE_NOT_FOUND_FALLBACK = "-"; -var NEW_CHANGE_CHARACTER = "+"; -var NEW_CHANGE_NUMBER_OF_CHARACTERS = 3; -var DIFFERING_AUTHOR_COMMITTER_MARKER = "*"; -var NON_WHITESPACE_REGEXP = /\S/g; -var UNINTRUSIVE_CHARACTER_FOR_WAITING_RENDERING = "%"; -var TextGutter = class extends import_view.GutterMarker { - constructor(text2) { - super(); - this.text = text2; - } - eq(other) { - return this.text === (other == null ? void 0 : other.text); - } - toDOM() { - return document.createTextNode(this.text); - } - destroy(dom) { - if (!document.body.contains(dom)) - dom.remove(); - } -}; -var LineAuthoringGutter = class extends import_view.GutterMarker { - /** - * **This should only be called {@link lineAuthoringGutterMarker}!** - * - * We want to avoid creating the same instance multiple times for improved performance. - */ - constructor(lineAuthoring, startLine, endLine, key2, settings, options) { - super(); - this.lineAuthoring = lineAuthoring; - this.startLine = startLine; - this.endLine = endLine; - this.key = key2; - this.settings = settings; - this.options = options; - this.point = false; - this.elementClass = "obs-git-blame-gutter"; - } - // Equality used by CodeMirror for optimisations - eq(other) { - return this.key === (other == null ? void 0 : other.key) && this.startLine === (other == null ? void 0 : other.startLine) && this.endLine === (other == null ? void 0 : other.endLine) && (this == null ? void 0 : this.options) === (other == null ? void 0 : other.options); - } - /** - * Renders to a Html node. - * - * It choses the newest commit within the line-range, - * renders it, makes adjustments for fake-commits and finally warps - * it into HTML. - * - * The DOM is actually precomputed with {@link computeDom}, - * which provides a finaliser to run before the DOM is handed over to CodeMirror. - * This is done, because this method is called frequently. It is called, - * whenever a gutter gets into the viewport and needs to be rendered. - * - * The age in days is recorded via {@link recordRenderedAgeInDays} to enable adaptive coloring. - */ - toDOM() { - var _a2; - this.precomputedDomProvider = (_a2 = this.precomputedDomProvider) != null ? _a2 : this.computeDom(); - return this.precomputedDomProvider(); - } - destroy(dom) { - if (!document.body.contains(dom)) { - dom.remove(); - attachedGutterElements.delete(dom); - } - } - /** - * Prepares the DOM for this gutter. - */ - computeDom() { - const commit2 = chooseNewestCommit( - this.lineAuthoring, - this.startLine, - this.endLine - ); - let toBeRenderedText = commit2.isZeroCommit ? "" : this.renderNonZeroCommit(commit2); - const isTrueCommit = !commit2.isZeroCommit && this.options !== "waiting-for-result"; - if (isTrueCommit) { - conditionallyUpdateLongestRenderedGutter(this, toBeRenderedText); - } else { - toBeRenderedText = this.adaptTextForFakeCommit( - commit2, - toBeRenderedText, - this.options - ); - } - const domProvider = this.createHtmlNode( - commit2, - toBeRenderedText, - this.options === "waiting-for-result" - ); - return domProvider; - } - createHtmlNode(commit2, text2, isWaitingGutter) { - var _a2; - const templateElt = window.createDiv(); - templateElt.innerText = text2; - const { color, daysSinceCommit } = coloringBasedOnCommitAge( - (_a2 = commit2 == null ? void 0 : commit2.author) == null ? void 0 : _a2.epochSeconds, - commit2 == null ? void 0 : commit2.isZeroCommit, - this.settings - ); - templateElt.style.backgroundColor = color; - enrichCommitInfoForContextMenu(commit2, isWaitingGutter, templateElt); - function prepareForDomAttachment() { - const elt = templateElt.cloneNode(true); - attachedGutterElements.add(elt); - if (!isWaitingGutter) - recordRenderedAgeInDays(daysSinceCommit); - return elt; - } - return prepareForDomAttachment; - } - renderNonZeroCommit(commit2) { - const optionalShortHash = this.settings.showCommitHash ? this.renderHash(commit2) : ""; - const optionalAuthorName = this.settings.authorDisplay === "hide" ? "" : `${this.renderAuthorName( - commit2, - this.settings.authorDisplay - )}`; - const optionalAuthoringDate = this.settings.dateTimeFormatOptions === "hide" ? "" : `${this.renderAuthoringDate( - commit2, - this.settings.dateTimeFormatOptions, - this.settings.dateTimeFormatCustomString, - this.settings.dateTimeTimezone - )}`; - const parts = [ - optionalShortHash, - optionalAuthorName, - optionalAuthoringDate - ]; - return parts.filter((x) => x.length >= 1).join(" "); - } - renderHash(nonZeroCommit) { - return nonZeroCommit.hash.substring(0, 6); - } - renderAuthorName(nonZeroCommit, authorDisplay) { - var _a2, _b, _c, _d; - const name = (_b = (_a2 = nonZeroCommit == null ? void 0 : nonZeroCommit.author) == null ? void 0 : _a2.name) != null ? _b : ""; - const words = name.split(" ").filter((word) => word.length >= 1); - let rendered; - switch (authorDisplay) { - case "initials": - rendered = words.map((word) => word[0].toUpperCase()).join(""); - break; - case "first name": - rendered = (_c = words.first()) != null ? _c : VALUE_NOT_FOUND_FALLBACK; - break; - case "last name": - rendered = (_d = words.last()) != null ? _d : VALUE_NOT_FOUND_FALLBACK; - break; - case "full": - rendered = name; - break; - default: - return impossibleBranch(authorDisplay); - } - if (!strictDeepEqual(nonZeroCommit == null ? void 0 : nonZeroCommit.author, nonZeroCommit == null ? void 0 : nonZeroCommit.committer)) { - rendered = rendered + DIFFERING_AUTHOR_COMMITTER_MARKER; - } - return rendered; - } - renderAuthoringDate(nonZeroCommit, dateTimeFormatOptions, dateTimeFormatCustomString, dateTimeTimezone) { - var _a2; - const FALLBACK_COMMIT_DATE = "?"; - if (((_a2 = nonZeroCommit == null ? void 0 : nonZeroCommit.author) == null ? void 0 : _a2.epochSeconds) === void 0) - return FALLBACK_COMMIT_DATE; - let dateTimeFormatting; - switch (dateTimeFormatOptions) { - case "date": - dateTimeFormatting = DATE_FORMAT; - break; - case "datetime": - dateTimeFormatting = DATE_TIME_FORMAT_MINUTES; - break; - case "custom": - dateTimeFormatting = dateTimeFormatCustomString; - break; - case "natural language": - dateTimeFormatting = (time) => { - const diff3 = time.diff((0, import_obsidian10.moment)()); - const addFluentSuffix = true; - return import_obsidian10.moment.duration(diff3).humanize(addFluentSuffix); - }; - break; - default: - return impossibleBranch(dateTimeFormatOptions); - } - let authoringDate = import_obsidian10.moment.unix( - nonZeroCommit.author.epochSeconds - ); - switch (dateTimeTimezone) { - case "viewer-local": - break; - case "author-local": - authoringDate = authoringDate.utcOffset( - nonZeroCommit.author.tz - ); - dateTimeFormatting += " Z"; - break; - case "utc0000": - authoringDate = authoringDate.utc(); - dateTimeFormatting += "[Z]"; - break; - default: - return impossibleBranch(dateTimeTimezone); - } - if (typeof dateTimeFormatting === "string") { - return authoringDate.format(dateTimeFormatting); - } else { - return dateTimeFormatting(authoringDate); - } - } - adaptTextForFakeCommit(commit2, toBeRenderedText, options) { - var _a2, _b, _c, _d; - const original = (_b = (_a2 = getLongestRenderedGutter()) == null ? void 0 : _a2.text) != null ? _b : toBeRenderedText; - const fillCharacter = options !== "waiting-for-result" && commit2.isZeroCommit ? NEW_CHANGE_CHARACTER : UNINTRUSIVE_CHARACTER_FOR_WAITING_RENDERING; - toBeRenderedText = original.replace( - NON_WHITESPACE_REGEXP, - fillCharacter - ); - const desiredTextLength = (_d = (_c = latestSettings.get()) == null ? void 0 : _c.gutterSpacingFallbackLength) != null ? _d : toBeRenderedText.length; - toBeRenderedText = resizeToLength( - toBeRenderedText, - desiredTextLength, - fillCharacter - ); - if (options !== "waiting-for-result" && commit2.isZeroCommit) { - const numberOfLastCharactersToKeep = Math.min( - desiredTextLength, - NEW_CHANGE_NUMBER_OF_CHARACTERS - ); - toBeRenderedText = prefixOfLengthAsWhitespace( - toBeRenderedText, - desiredTextLength - numberOfLastCharactersToKeep - ); - } - return toBeRenderedText; - } -}; -function lineAuthoringGutterMarker(la, startLine, endLine, key2, settings, options) { - const digest = import_js_sha2562.sha256.create(); - digest.update(Object.values(settings).join(",")); - digest.update(`s${startLine}-e${endLine}-k${key2}-o${options}`); - const cacheKey = digest.hex(); - const cached = gutterInstances.get(cacheKey); - if (cached) - return cached; - const result = new LineAuthoringGutter( - la, - startLine, - endLine, - key2, - settings, - options - ); - gutterInstances.set(cacheKey, result); - return result; -} - -// src/lineAuthor/view/gutter/initial.ts -init_polyfill_buffer(); -var import_obsidian11 = require("obsidian"); -function initialSpacingGutter() { - var _a2, _b; - const length = (_b = (_a2 = latestSettings.get()) == null ? void 0 : _a2.gutterSpacingFallbackLength) != null ? _b : DEFAULT_SETTINGS.lineAuthor.gutterSpacingFallbackLength; - return new TextGutter(Array(length).fill("-").join("")); -} -function initialLineAuthoringGutter(settings) { - const { lineAuthoring, ageForInitialRender } = adaptiveInitialColoredWaitingLineAuthoring(settings); - return lineAuthoringGutterMarker( - lineAuthoring, - 1, - 1, - "initialGutter" + ageForInitialRender, - // use a age coloring based cache key - settings, - "waiting-for-result" - ); -} -function adaptiveInitialColoredWaitingLineAuthoring(settings) { - var _a2; - const ageForInitialRender = (_a2 = computeAdaptiveInitialColoringAgeInDays()) != null ? _a2 : maxAgeInDaysFromSettings(settings) * 0.25; - const slightlyOlderAgeForInitialRender = (0, import_obsidian11.moment)().add( - -ageForInitialRender, - "days" - ); - const dummyAuthor = { - name: "", - epochSeconds: momentToEpochSeconds(slightlyOlderAgeForInitialRender), - tz: "+0000" - }; - const dummyCommit = { - hash: "waiting-for-result", - author: dummyAuthor, - committer: dummyAuthor, - isZeroCommit: false - }; - return { - lineAuthoring: { - hashPerLine: [void 0, "waiting-for-result"], - commits: /* @__PURE__ */ new Map([["waiting-for-result", dummyCommit]]) - }, - ageForInitialRender - }; -} - -// src/lineAuthor/view/gutter/untrackedFile.ts -init_polyfill_buffer(); -function newUntrackedFileGutter(key2, settings) { - const dummyLineAuthoring = { - hashPerLine: [void 0, "000000"], - commits: /* @__PURE__ */ new Map([["000000", zeroCommit]]) - }; - return lineAuthoringGutterMarker(dummyLineAuthoring, 1, 1, key2, settings); -} - -// src/lineAuthor/view/view.ts -var UNDISPLAYED = new TextGutter(""); -var lineAuthorGutter = (0, import_view2.gutter)({ - class: "line-author-gutter-container", - markers(view) { - const lineAuthoring = view.state.field(lineAuthorState, false); - return lineAuthoringGutterMarkersRangeSet(view, lineAuthoring); - }, - lineMarkerChange(update2) { - const newLineAuthoringId = laStateDigest( - update2.state.field(lineAuthorState) - ); - const oldLineAuthoringId = laStateDigest( - update2.startState.field(lineAuthorState) - ); - return oldLineAuthoringId !== newLineAuthoringId; - }, - renderEmptyElements: true, - initialSpacer: (view) => { - temporaryWorkaroundGutterSpacingForRenderedLineAuthoring(view); - return initialSpacingGutter(); - }, - updateSpacer: (_sp, update2) => { - var _a2, _b; - temporaryWorkaroundGutterSpacingForRenderedLineAuthoring(update2.view); - return (_b = (_a2 = getLongestRenderedGutter()) == null ? void 0 : _a2.gutter) != null ? _b : initialSpacingGutter(); - } -}); -function lineAuthoringGutterMarkersRangeSet(view, optLA) { - const digest = laStateDigest(optLA); - const doc = view.state.doc; - const lineBlockEndPos = /* @__PURE__ */ new Map(); - for (let line = 1; line <= doc.lines; line++) { - const from = doc.line(line).from; - const to = view.lineBlockAt(from).to; - lineBlockEndPos.set(line, [from, to]); - digest.update([from, to, 0]); - } - const laSettings = latestSettings.get(); - digest.update("s" + Object.values(latestSettings).join(",")); - const cacheKey = digest.hex(); - const cached = gutterMarkersRangeSet.get(cacheKey); - if (cached) - return cached; - const { result, allowCache } = computeLineAuthoringGutterMarkersRangeSet( - doc, - lineBlockEndPos, - laSettings, - optLA - ); - if (allowCache) - gutterMarkersRangeSet.set(cacheKey, result); - return result; -} -function computeLineAuthoringGutterMarkersRangeSet(doc, blocksPerLine, settings, optLA) { - let allowCache = true; - const docLastLine = doc.lines; - const ranges = []; - function add2(from, to, gutter2) { - return ranges.push(gutter2.range(from, to)); - } - const lineFrom = computeLineMappingForUnsavedChanges(docLastLine, optLA); - const emptyDoc = doc.length === 0; - const lastLineIsEmpty = doc.iterLines(docLastLine, docLastLine + 1).next().value === ""; - for (let startLine = 1; startLine <= docLastLine; startLine++) { - const [from, to] = blocksPerLine.get(startLine); - const endLine = doc.lineAt(to).number; - if (emptyDoc) { - add2(from, to, UNDISPLAYED); - continue; - } - if (startLine === docLastLine && lastLineIsEmpty) { - add2(from, to, UNDISPLAYED); - continue; - } - if (optLA === void 0) { - add2(from, to, initialLineAuthoringGutter(settings)); - allowCache = false; - continue; - } - const { key: key2, la } = optLA; - if (la === "untracked") { - add2(from, to, newUntrackedFileGutter(la, settings)); - continue; - } - const lastAuthorLine = la.hashPerLine.length - 1; - const laStartLine = lineFrom[startLine]; - const laEndLine = lineFrom[endLine]; - if (laEndLine && laEndLine > lastAuthorLine) { - add2(from, to, UNDISPLAYED); - } - if (laStartLine !== void 0 && between(1, laStartLine, lastAuthorLine) && laEndLine !== void 0 && between(1, laEndLine, lastAuthorLine)) { - add2( - from, - to, - lineAuthoringGutterMarker( - la, - laStartLine, - laEndLine, - key2, - settings - ) - ); - continue; - } - if (lastAuthorLine < 1) { - add2(from, to, initialLineAuthoringGutter(settings)); - allowCache = false; - continue; - } - const start = Math.clamp(laStartLine != null ? laStartLine : startLine, 1, lastAuthorLine); - const end = Math.clamp(laEndLine != null ? laEndLine : endLine, 1, lastAuthorLine); - add2( - from, - to, - lineAuthoringGutterMarker( - la, - start, - end, - key2 + "computing", - settings, - "waiting-for-result" - ) - ); - } - return { result: import_state3.RangeSet.of( - ranges, - /* sort = */ - true - ), allowCache }; -} -function computeLineMappingForUnsavedChanges(docLastLine, optLA) { - if (!(optLA == null ? void 0 : optLA.lineOffsetsFromUnsavedChanges)) { - return Array.from(new Array(docLastLine + 1), (ln) => ln); - } - const lineFrom = [void 0]; - let cumulativeLineOffset = 0; - for (let ln = 1; ln <= docLastLine; ln++) { - const unsavedChanges = optLA.lineOffsetsFromUnsavedChanges.get(ln); - cumulativeLineOffset += unsavedChanges != null ? unsavedChanges : 0; - lineFrom[ln] = unsavedChanges === void 0 ? ln - cumulativeLineOffset : void 0; - } - return lineFrom; -} -function temporaryWorkaroundGutterSpacingForRenderedLineAuthoring(view) { - const guttersContainers = view.dom.querySelectorAll( - ".cm-gutters" - ); - guttersContainers.forEach((cont) => { - if (!(cont == null ? void 0 : cont.style)) - return; - if (!cont.style.marginLeft) { - cont.style.marginLeft = "unset"; - } - }); -} - -// src/lineAuthor/lineAuthorProvider.ts -var LineAuthorProvider = class { - constructor(plugin) { - this.plugin = plugin; - /** - * Saves all computed line authoring results. - * - * See {@link LineAuthoringId} - */ - this.lineAuthorings = /* @__PURE__ */ new Map(); - } - async trackChanged(file) { - this.trackChangedHelper(file).catch((reason) => { - console.warn("Git: Error in trackChanged." + reason); - return Promise.reject(reason); - }); - } - async trackChangedHelper(file) { - if (!file) - return; - if (file.path === void 0) { - console.warn( - "Git: Attempted to track change of undefined filepath. Unforeseen situation." - ); - return; - } - this.computeLineAuthorInfo(file.path); - } - destroy() { - this.lineAuthorings.clear(); - eventsPerFilePathSingleton.clear(); - clearViewCache(); - } - async computeLineAuthorInfo(filepath) { - const gitManager = this.plugin.lineAuthoringFeature.isAvailableOnCurrentPlatform().gitManager; - const headRevision = await gitManager.submoduleAwareHeadRevisonInContainingDirectory( - filepath - ); - const fileHash = await gitManager.hashObject(filepath); - const key2 = lineAuthoringId(headRevision, fileHash, filepath); - if (key2 === void 0) { - return; - } - if (this.lineAuthorings.has(key2)) { - } else { - const gitAuthorResult = await gitManager.blame( - filepath, - this.plugin.settings.lineAuthor.followMovement, - this.plugin.settings.lineAuthor.ignoreWhitespace - ); - this.lineAuthorings.set(key2, gitAuthorResult); - } - this.notifyComputationResultToSubscribers(filepath, key2); - } - notifyComputationResultToSubscribers(filepath, key2) { - eventsPerFilePathSingleton.ifFilepathDefinedTransformSubscribers( - filepath, - async (subs) => subs.forEach( - (sub) => sub.notifyLineAuthoring(key2, this.lineAuthorings.get(key2)) - ) - ); - } -}; -var enabledLineAuthorInfoExtensions = import_state4.Prec.high([ - subscribeNewEditor, - lineAuthorState, - lineAuthorGutter -]); - -// src/lineAuthor/lineAuthorIntegration.ts -var LineAuthoringFeature = class { - constructor(plg) { - this.plg = plg; - this.codeMirrorExtensions = []; - this.handleWorkspaceLeaf = (leaf) => { - const obsView = leaf == null ? void 0 : leaf.view; - const file = obsView == null ? void 0 : obsView.file; - if (!this.lineAuthorInfoProvider) { - console.warn( - "Git: undefined lineAuthorInfoProvider. Unexpected situation." - ); - return; - } - if (file === void 0 || (obsView == null ? void 0 : obsView.allowNoFile) === true) - return; - this.lineAuthorInfoProvider.trackChanged(file); - }; - } - // ========================= INIT and DE-INIT ========================== - onLoadPlugin() { - this.plg.registerEditorExtension(this.codeMirrorExtensions); - provideSettingsAccess( - () => this.plg.settings.lineAuthor, - (laSettings) => { - this.plg.settings.lineAuthor = laSettings; - this.plg.saveSettings(); - } - ); - } - conditionallyActivateBySettings() { - if (this.plg.settings.lineAuthor.show) { - this.activateFeature(); - } - } - activateFeature() { - try { - if (!this.isAvailableOnCurrentPlatform().available) - return; - setTextColorCssBasedOnSetting(this.plg.settings.lineAuthor); - this.lineAuthorInfoProvider = new LineAuthorProvider(this.plg); - this.createEventHandlers(); - this.activateCodeMirrorExtensions(); - console.log(this.plg.manifest.name + ": Enabled line authoring."); - } catch (e) { - console.warn("Git: Error while loading line authoring feature.", e); - this.deactivateFeature(); - } - } - /** - * Deactivates the feature. This function is very defensive, as it is also - * called to cleanup, if a critical error in the line authoring has occurred. - */ - deactivateFeature() { - var _a2; - this.destroyEventHandlers(); - this.deactivateCodeMirrorExtensions(); - (_a2 = this.lineAuthorInfoProvider) == null ? void 0 : _a2.destroy(); - this.lineAuthorInfoProvider = void 0; - console.log(this.plg.manifest.name + ": Disabled line authoring."); - } - isAvailableOnCurrentPlatform() { - return { - available: this.plg.useSimpleGit && import_obsidian12.Platform.isDesktopApp, - gitManager: this.plg.gitManager instanceof SimpleGit ? this.plg.gitManager : void 0 - }; - } - // ========================= REFRESH ========================== - refreshLineAuthorViews() { - if (this.plg.settings.lineAuthor.show) { - this.deactivateFeature(); - this.activateFeature(); - } - } - // ========================= CODEMIRROR EXTENSIONS ========================== - activateCodeMirrorExtensions() { - this.codeMirrorExtensions.push(enabledLineAuthorInfoExtensions); - this.plg.app.workspace.updateOptions(); - this.plg.app.workspace.iterateAllLeaves(this.handleWorkspaceLeaf); - } - deactivateCodeMirrorExtensions() { - for (const ext of this.codeMirrorExtensions) { - this.codeMirrorExtensions.remove(ext); - } - this.plg.app.workspace.updateOptions(); - } - // ========================= HANDLERS ========================== - createEventHandlers() { - this.gutterContextMenuEvent = this.createGutterContextMenuHandler(); - this.fileOpenEvent = this.createFileOpenEvent(); - this.workspaceLeafChangeEvent = this.createWorkspaceLeafChangeEvent(); - this.fileModificationEvent = this.createVaultFileModificationHandler(); - this.refreshOnCssChangeEvent = this.createCssRefreshHandler(); - this.fileRenameEvent = this.createFileRenameEvent(); - prepareGutterSearchForContextMenuHandling(); - this.plg.registerEvent(this.gutterContextMenuEvent); - this.plg.registerEvent(this.refreshOnCssChangeEvent); - this.plg.registerEvent(this.fileOpenEvent); - this.plg.registerEvent(this.workspaceLeafChangeEvent); - this.plg.registerEvent(this.fileModificationEvent); - this.plg.registerEvent(this.fileRenameEvent); - } - destroyEventHandlers() { - this.plg.app.workspace.offref(this.refreshOnCssChangeEvent); - this.plg.app.workspace.offref(this.fileOpenEvent); - this.plg.app.workspace.offref(this.workspaceLeafChangeEvent); - this.plg.app.workspace.offref(this.refreshOnCssChangeEvent); - this.plg.app.vault.offref(this.fileRenameEvent); - this.plg.app.workspace.offref(this.gutterContextMenuEvent); - } - createFileOpenEvent() { - return this.plg.app.workspace.on( - "file-open", - (file) => { - var _a2; - return (_a2 = this.lineAuthorInfoProvider) == null ? void 0 : _a2.trackChanged(file); - } - ); - } - createWorkspaceLeafChangeEvent() { - return this.plg.app.workspace.on( - "active-leaf-change", - this.handleWorkspaceLeaf - ); - } - createFileRenameEvent() { - return this.plg.app.vault.on( - "rename", - (file, _old) => { - var _a2; - return file instanceof import_obsidian12.TFile && ((_a2 = this.lineAuthorInfoProvider) == null ? void 0 : _a2.trackChanged(file)); - } - ); - } - createVaultFileModificationHandler() { - return this.plg.app.vault.on( - "modify", - (anyPath) => { - var _a2; - return anyPath instanceof import_obsidian12.TFile && ((_a2 = this.lineAuthorInfoProvider) == null ? void 0 : _a2.trackChanged(anyPath)); - } - ); - } - createCssRefreshHandler() { - return this.plg.app.workspace.on( - "css-change", - () => this.refreshLineAuthorViews() - ); - } - createGutterContextMenuHandler() { - return this.plg.app.workspace.on("editor-menu", handleContextMenu); - } -}; - -// src/promiseQueue.ts -init_polyfill_buffer(); -var PromiseQueue = class { - constructor() { - this.tasks = []; - } - addTask(task) { - this.tasks.push(task); - if (this.tasks.length === 1) { - this.handleTask(); - } - } - async handleTask() { - if (this.tasks.length > 0) { - this.tasks[0]().finally(() => { - this.tasks.shift(); - this.handleTask(); - }); - } - } -}; - -// src/statusBar.ts -init_polyfill_buffer(); -var import_obsidian13 = require("obsidian"); -var StatusBar = class { - constructor(statusBarEl, plugin) { - this.statusBarEl = statusBarEl; - this.plugin = plugin; - this.messages = []; - this.base = "obsidian-git-statusbar-"; - this.statusBarEl.setAttribute("data-tooltip-position", "top"); - addEventListener("git-refresh", this.refreshCommitTimestamp.bind(this)); - } - displayMessage(message, timeout) { - this.messages.push({ - message: `Git: ${message.slice(0, 100)}`, - timeout - }); - this.display(); - } - display() { - if (this.messages.length > 0 && !this.currentMessage) { - this.currentMessage = this.messages.shift(); - this.statusBarEl.addClass(this.base + "message"); - this.statusBarEl.ariaLabel = ""; - this.statusBarEl.setText(this.currentMessage.message); - this.lastMessageTimestamp = Date.now(); - } else if (this.currentMessage) { - const messageAge = Date.now() - this.lastMessageTimestamp; - if (messageAge >= this.currentMessage.timeout) { - this.currentMessage = null; - this.lastMessageTimestamp = null; - } - } else { - this.displayState(); - } - } - displayState() { - if (this.statusBarEl.getText().length > 3 || !this.statusBarEl.hasChildNodes()) { - this.statusBarEl.empty(); - this.iconEl = this.statusBarEl.createDiv(); - this.textEl = this.statusBarEl.createDiv(); - this.textEl.style.float = "right"; - this.textEl.style.marginLeft = "5px"; - this.iconEl.style.float = "left"; - } - switch (this.plugin.state) { - case 0 /* idle */: - this.displayFromNow(); - break; - case 1 /* status */: - this.statusBarEl.ariaLabel = "Checking repository status..."; - (0, import_obsidian13.setIcon)(this.iconEl, "refresh-cw"); - this.statusBarEl.addClass(this.base + "status"); - break; - case 3 /* add */: - this.statusBarEl.ariaLabel = "Adding files..."; - (0, import_obsidian13.setIcon)(this.iconEl, "refresh-w"); - this.statusBarEl.addClass(this.base + "add"); - break; - case 4 /* commit */: - this.statusBarEl.ariaLabel = "Committing changes..."; - (0, import_obsidian13.setIcon)(this.iconEl, "git-commit"); - this.statusBarEl.addClass(this.base + "commit"); - break; - case 5 /* push */: - this.statusBarEl.ariaLabel = "Pushing changes..."; - (0, import_obsidian13.setIcon)(this.iconEl, "upload"); - this.statusBarEl.addClass(this.base + "push"); - break; - case 2 /* pull */: - this.statusBarEl.ariaLabel = "Pulling changes..."; - (0, import_obsidian13.setIcon)(this.iconEl, "download"); - this.statusBarEl.addClass(this.base + "pull"); - break; - case 6 /* conflicted */: - this.statusBarEl.ariaLabel = "You have conflict files..."; - (0, import_obsidian13.setIcon)(this.iconEl, "alert-circle"); - this.statusBarEl.addClass(this.base + "conflict"); - break; - default: - this.statusBarEl.ariaLabel = "Failed on initialization!"; - (0, import_obsidian13.setIcon)(this.iconEl, "alert-triangle"); - this.statusBarEl.addClass(this.base + "failed-init"); - break; - } - } - displayFromNow() { - var _a2; - const timestamp = this.lastCommitTimestamp; - if (timestamp) { - const moment6 = window.moment; - const fromNow = moment6(timestamp).fromNow(); - this.statusBarEl.ariaLabel = `${this.plugin.offlineMode ? "Offline: " : ""}Last Commit: ${fromNow}`; - if ((_a2 = this.unPushedCommits) != null ? _a2 : 0 > 0) { - this.statusBarEl.ariaLabel += ` -(${this.unPushedCommits} unpushed commits)`; - } - } else { - this.statusBarEl.ariaLabel = this.plugin.offlineMode ? "Git is offline" : "Git is ready"; - } - if (this.plugin.offlineMode) { - (0, import_obsidian13.setIcon)(this.iconEl, "globe"); - } else { - (0, import_obsidian13.setIcon)(this.iconEl, "check"); - } - if (this.plugin.settings.changedFilesInStatusBar && this.plugin.cachedStatus) { - this.textEl.setText( - this.plugin.cachedStatus.changed.length.toString() - ); - } - this.statusBarEl.addClass(this.base + "idle"); - } - async refreshCommitTimestamp() { - this.lastCommitTimestamp = await this.plugin.gitManager.getLastCommitTime(); - this.unPushedCommits = await this.plugin.gitManager.getUnpushedCommits(); - } -}; - -// src/ui/modals/changedFilesModal.ts -init_polyfill_buffer(); -var import_obsidian14 = require("obsidian"); -var ChangedFilesModal = class extends import_obsidian14.FuzzySuggestModal { - constructor(plugin, changedFiles) { - super(plugin.app); - this.plugin = plugin; - this.changedFiles = changedFiles; - this.setPlaceholder( - "Not supported files will be opened by default app!" - ); - } - getItems() { - return this.changedFiles; - } - getItemText(item) { - if (item.index == "U" && item.working_dir == "U") { - return `Untracked | ${item.vault_path}`; - } - let working_dir = ""; - let index2 = ""; - if (item.working_dir != " ") - working_dir = `Working Dir: ${item.working_dir} `; - if (item.index != " ") - index2 = `Index: ${item.index}`; - return `${working_dir}${index2} | ${item.vault_path}`; - } - onChooseItem(item, _) { - if (this.plugin.app.metadataCache.getFirstLinkpathDest( - item.vault_path, - "" - ) == null) { - this.app.openWithDefaultApp(item.vault_path); - } else { - this.plugin.app.workspace.openLinkText(item.vault_path, "/"); - } - } -}; - -// src/ui/modals/customMessageModal.ts -init_polyfill_buffer(); -var import_obsidian15 = require("obsidian"); -var CustomMessageModal = class extends import_obsidian15.SuggestModal { - constructor(plugin, fromAutoBackup) { - super(plugin.app); - this.fromAutoBackup = fromAutoBackup; - this.resolve = null; - this.plugin = plugin; - this.setPlaceholder( - "Type your message and select optional the version with the added date." - ); - } - open() { - super.open(); - return new Promise((resolve) => { - this.resolve = resolve; - }); - } - onClose() { - if (this.resolve) - this.resolve(void 0); - } - selectSuggestion(value, evt) { - if (this.resolve) - this.resolve(value); - super.selectSuggestion(value, evt); - } - getSuggestions(query) { - const date = window.moment().format(this.plugin.settings.commitDateFormat); - if (query == "") - query = "..."; - return [query, `${date}: ${query}`, `${query}: ${date}`]; - } - renderSuggestion(value, el) { - el.innerText = value; - } - onChooseSuggestion(item, _) { - } -}; - -// src/openInGitHub.ts -init_polyfill_buffer(); -var import_obsidian16 = require("obsidian"); -async function openLineInGitHub(editor, file, manager) { - const data = await getData(manager); - if (data.result === "failure") { - new import_obsidian16.Notice(data.reason); - return; - } - const { isGitHub, branch: branch2, repo, user } = data; - if (isGitHub) { - const path2 = manager.getRelativeRepoPath(file.path); - const from = editor.getCursor("from").line + 1; - const to = editor.getCursor("to").line + 1; - if (from === to) { - window.open( - `https://github.com/${user}/${repo}/blob/${branch2}/${path2}?plain=1#L${from}` - ); - } else { - window.open( - `https://github.com/${user}/${repo}/blob/${branch2}/${path2}?plain=1#L${from}-L${to}` - ); - } - } else { - new import_obsidian16.Notice("It seems like you are not using GitHub"); - } -} -async function openHistoryInGitHub(file, manager) { - const data = await getData(manager); - if (data.result === "failure") { - new import_obsidian16.Notice(data.reason); - return; - } - const { isGitHub, branch: branch2, repo, user } = data; - const path2 = manager.getRelativeRepoPath(file.path); - if (isGitHub) { - window.open( - `https://github.com/${user}/${repo}/commits/${branch2}/${path2}` - ); - } else { - new import_obsidian16.Notice("It seems like you are not using GitHub"); - } -} -async function getData(manager) { - const branchInfo = await manager.branchInfo(); - const remoteBranch = branchInfo.tracking; - const branch2 = branchInfo.current; - if (remoteBranch == null) { - return { - result: "failure", - reason: "Remote branch is not configured" - }; - } - if (branch2 == null) { - return { - result: "failure", - reason: "Failed to get current branch name" - }; - } - const remote = remoteBranch.substring(0, remoteBranch.indexOf("/")); - const remoteUrl = await manager.getConfig( - `remote.${remote}.url` - ); - const [isGitHub, httpsUser, httpsRepo, sshUser, sshRepo] = remoteUrl.match( - /(?:^https:\/\/github\.com\/(.*)\/(.*)\.git$)|(?:^[a-zA-Z]+@github\.com:(.*)\/(.*)\.git$)/ - ); - return { - result: "success", - isGitHub: !!isGitHub, - repo: httpsRepo || sshRepo, - user: httpsUser || sshUser, - branch: branch2 - }; -} - -// src/setting/localStorageSettings.ts -init_polyfill_buffer(); -var LocalStorageSettings = class { - constructor(plugin) { - this.plugin = plugin; - this.prefix = this.plugin.manifest.id + ":"; - } - migrate() { - const keys = [ - "password", - "hostname", - "conflict", - "lastAutoPull", - "lastAutoBackup", - "lastAutoPush", - "gitPath", - "pluginDisabled" - ]; - for (const key2 of keys) { - const old = localStorage.getItem(this.prefix + key2); - if (app.loadLocalStorage(this.prefix + key2) == null && old != null) { - if (old != null) { - app.saveLocalStorage(this.prefix + key2, old); - localStorage.removeItem(this.prefix + key2); - } - } - } - } - getPassword() { - return app.loadLocalStorage(this.prefix + "password"); - } - setPassword(value) { - return app.saveLocalStorage(this.prefix + "password", value); - } - getUsername() { - return app.loadLocalStorage(this.prefix + "username"); - } - setUsername(value) { - return app.saveLocalStorage(this.prefix + "username", value); - } - getHostname() { - return app.loadLocalStorage(this.prefix + "hostname"); - } - setHostname(value) { - return app.saveLocalStorage(this.prefix + "hostname", value); - } - getConflict() { - return app.loadLocalStorage(this.prefix + "conflict") == "true"; - } - setConflict(value) { - return app.saveLocalStorage(this.prefix + "conflict", `${value}`); - } - getLastAutoPull() { - return app.loadLocalStorage(this.prefix + "lastAutoPull"); - } - setLastAutoPull(value) { - return app.saveLocalStorage(this.prefix + "lastAutoPull", value); - } - getLastAutoBackup() { - return app.loadLocalStorage(this.prefix + "lastAutoBackup"); - } - setLastAutoBackup(value) { - return app.saveLocalStorage(this.prefix + "lastAutoBackup", value); - } - getLastAutoPush() { - return app.loadLocalStorage(this.prefix + "lastAutoPush"); - } - setLastAutoPush(value) { - return app.saveLocalStorage(this.prefix + "lastAutoPush", value); - } - getGitPath() { - return app.loadLocalStorage(this.prefix + "gitPath"); - } - setGitPath(value) { - return app.saveLocalStorage(this.prefix + "gitPath", value); - } - getPATHPaths() { - var _a2, _b; - return (_b = (_a2 = app.loadLocalStorage(this.prefix + "PATHPaths")) == null ? void 0 : _a2.split(":")) != null ? _b : []; - } - setPATHPaths(value) { - return app.saveLocalStorage(this.prefix + "PATHPaths", value.join(":")); - } - getEnvVars() { - var _a2; - return JSON.parse( - (_a2 = app.loadLocalStorage(this.prefix + "envVars")) != null ? _a2 : "[]" - ); - } - setEnvVars(value) { - return app.saveLocalStorage( - this.prefix + "envVars", - JSON.stringify(value) - ); - } - getPluginDisabled() { - return app.loadLocalStorage(this.prefix + "pluginDisabled") == "true"; - } - setPluginDisabled(value) { - return app.saveLocalStorage(this.prefix + "pluginDisabled", `${value}`); - } -}; - -// src/ui/diff/diffView.ts -init_polyfill_buffer(); - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/diff2html.js -init_polyfill_buffer(); - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/diff-parser.js -init_polyfill_buffer(); - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/types.js -init_polyfill_buffer(); -var LineType; -(function(LineType2) { - LineType2["INSERT"] = "insert"; - LineType2["DELETE"] = "delete"; - LineType2["CONTEXT"] = "context"; -})(LineType || (LineType = {})); -var OutputFormatType = { - LINE_BY_LINE: "line-by-line", - SIDE_BY_SIDE: "side-by-side" -}; -var LineMatchingType = { - LINES: "lines", - WORDS: "words", - NONE: "none" -}; -var DiffStyleType = { - WORD: "word", - CHAR: "char" -}; -var ColorSchemeType; -(function(ColorSchemeType2) { - ColorSchemeType2["AUTO"] = "auto"; - ColorSchemeType2["DARK"] = "dark"; - ColorSchemeType2["LIGHT"] = "light"; -})(ColorSchemeType || (ColorSchemeType = {})); - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/utils.js -init_polyfill_buffer(); -var specials = [ - "-", - "[", - "]", - "/", - "{", - "}", - "(", - ")", - "*", - "+", - "?", - ".", - "\\", - "^", - "$", - "|" -]; -var regex = RegExp("[" + specials.join("\\") + "]", "g"); -function escapeForRegExp(str) { - return str.replace(regex, "\\$&"); -} -function unifyPath(path2) { - return path2 ? path2.replace(/\\/g, "/") : path2; -} -function hashCode(text2) { - let i, chr, len; - let hash2 = 0; - for (i = 0, len = text2.length; i < len; i++) { - chr = text2.charCodeAt(i); - hash2 = (hash2 << 5) - hash2 + chr; - hash2 |= 0; - } - return hash2; -} - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/diff-parser.js -function getExtension(filename, language) { - const filenameParts = filename.split("."); - return filenameParts.length > 1 ? filenameParts[filenameParts.length - 1] : language; -} -function startsWithAny(str, prefixes) { - return prefixes.reduce((startsWith, prefix) => startsWith || str.startsWith(prefix), false); -} -var baseDiffFilenamePrefixes = ["a/", "b/", "i/", "w/", "c/", "o/"]; -function getFilename(line, linePrefix, extraPrefix) { - const prefixes = extraPrefix !== void 0 ? [...baseDiffFilenamePrefixes, extraPrefix] : baseDiffFilenamePrefixes; - const FilenameRegExp = linePrefix ? new RegExp(`^${escapeForRegExp(linePrefix)} "?(.+?)"?$`) : new RegExp('^"?(.+?)"?$'); - const [, filename = ""] = FilenameRegExp.exec(line) || []; - const matchingPrefix = prefixes.find((p) => filename.indexOf(p) === 0); - const fnameWithoutPrefix = matchingPrefix ? filename.slice(matchingPrefix.length) : filename; - return fnameWithoutPrefix.replace(/\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [+-]\d{4}.*$/, ""); -} -function getSrcFilename(line, srcPrefix) { - return getFilename(line, "---", srcPrefix); -} -function getDstFilename(line, dstPrefix) { - return getFilename(line, "+++", dstPrefix); -} -function parse(diffInput, config = {}) { - const files = []; - let currentFile = null; - let currentBlock = null; - let oldLine = null; - let oldLine2 = null; - let newLine = null; - let possibleOldName = null; - let possibleNewName = null; - const oldFileNameHeader = "--- "; - const newFileNameHeader = "+++ "; - const hunkHeaderPrefix = "@@"; - const oldMode = /^old mode (\d{6})/; - const newMode = /^new mode (\d{6})/; - const deletedFileMode = /^deleted file mode (\d{6})/; - const newFileMode = /^new file mode (\d{6})/; - const copyFrom = /^copy from "?(.+)"?/; - const copyTo = /^copy to "?(.+)"?/; - const renameFrom = /^rename from "?(.+)"?/; - const renameTo = /^rename to "?(.+)"?/; - const similarityIndex = /^similarity index (\d+)%/; - const dissimilarityIndex = /^dissimilarity index (\d+)%/; - const index2 = /^index ([\da-z]+)\.\.([\da-z]+)\s*(\d{6})?/; - const binaryFiles = /^Binary files (.*) and (.*) differ/; - const binaryDiff = /^GIT binary patch/; - const combinedIndex = /^index ([\da-z]+),([\da-z]+)\.\.([\da-z]+)/; - const combinedMode = /^mode (\d{6}),(\d{6})\.\.(\d{6})/; - const combinedNewFile = /^new file mode (\d{6})/; - const combinedDeletedFile = /^deleted file mode (\d{6}),(\d{6})/; - const diffLines2 = diffInput.replace(/\\ No newline at end of file/g, "").replace(/\r\n?/g, "\n").split("\n"); - function saveBlock() { - if (currentBlock !== null && currentFile !== null) { - currentFile.blocks.push(currentBlock); - currentBlock = null; - } - } - function saveFile() { - if (currentFile !== null) { - if (!currentFile.oldName && possibleOldName !== null) { - currentFile.oldName = possibleOldName; - } - if (!currentFile.newName && possibleNewName !== null) { - currentFile.newName = possibleNewName; - } - if (currentFile.newName) { - files.push(currentFile); - currentFile = null; - } - } - possibleOldName = null; - possibleNewName = null; - } - function startFile() { - saveBlock(); - saveFile(); - currentFile = { - blocks: [], - deletedLines: 0, - addedLines: 0 - }; - } - function startBlock(line) { - saveBlock(); - let values; - if (currentFile !== null) { - if (values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line)) { - currentFile.isCombined = false; - oldLine = parseInt(values[1], 10); - newLine = parseInt(values[2], 10); - } else if (values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line)) { - currentFile.isCombined = true; - oldLine = parseInt(values[1], 10); - oldLine2 = parseInt(values[2], 10); - newLine = parseInt(values[3], 10); - } else { - if (line.startsWith(hunkHeaderPrefix)) { - console.error("Failed to parse lines, starting in 0!"); - } - oldLine = 0; - newLine = 0; - currentFile.isCombined = false; - } - } - currentBlock = { - lines: [], - oldStartLine: oldLine, - oldStartLine2: oldLine2, - newStartLine: newLine, - header: line - }; - } - function createLine(line) { - if (currentFile === null || currentBlock === null || oldLine === null || newLine === null) - return; - const currentLine = { - content: line - }; - const addedPrefixes = currentFile.isCombined ? ["+ ", " +", "++"] : ["+"]; - const deletedPrefixes = currentFile.isCombined ? ["- ", " -", "--"] : ["-"]; - if (startsWithAny(line, addedPrefixes)) { - currentFile.addedLines++; - currentLine.type = LineType.INSERT; - currentLine.oldNumber = void 0; - currentLine.newNumber = newLine++; - } else if (startsWithAny(line, deletedPrefixes)) { - currentFile.deletedLines++; - currentLine.type = LineType.DELETE; - currentLine.oldNumber = oldLine++; - currentLine.newNumber = void 0; - } else { - currentLine.type = LineType.CONTEXT; - currentLine.oldNumber = oldLine++; - currentLine.newNumber = newLine++; - } - currentBlock.lines.push(currentLine); - } - function existHunkHeader(line, lineIdx) { - let idx = lineIdx; - while (idx < diffLines2.length - 3) { - if (line.startsWith("diff")) { - return false; - } - if (diffLines2[idx].startsWith(oldFileNameHeader) && diffLines2[idx + 1].startsWith(newFileNameHeader) && diffLines2[idx + 2].startsWith(hunkHeaderPrefix)) { - return true; - } - idx++; - } - return false; - } - diffLines2.forEach((line, lineIndex) => { - if (!line || line.startsWith("*")) { - return; - } - let values; - const prevLine = diffLines2[lineIndex - 1]; - const nxtLine = diffLines2[lineIndex + 1]; - const afterNxtLine = diffLines2[lineIndex + 2]; - if (line.startsWith("diff --git") || line.startsWith("diff --combined")) { - startFile(); - const gitDiffStart = /^diff --git "?([a-ciow]\/.+)"? "?([a-ciow]\/.+)"?/; - if (values = gitDiffStart.exec(line)) { - possibleOldName = getFilename(values[1], void 0, config.dstPrefix); - possibleNewName = getFilename(values[2], void 0, config.srcPrefix); - } - if (currentFile === null) { - throw new Error("Where is my file !!!"); - } - currentFile.isGitDiff = true; - return; - } - if (line.startsWith("Binary files") && !(currentFile === null || currentFile === void 0 ? void 0 : currentFile.isGitDiff)) { - startFile(); - const unixDiffBinaryStart = /^Binary files "?([a-ciow]\/.+)"? and "?([a-ciow]\/.+)"? differ/; - if (values = unixDiffBinaryStart.exec(line)) { - possibleOldName = getFilename(values[1], void 0, config.dstPrefix); - possibleNewName = getFilename(values[2], void 0, config.srcPrefix); - } - if (currentFile === null) { - throw new Error("Where is my file !!!"); - } - currentFile.isBinary = true; - return; - } - if (!currentFile || !currentFile.isGitDiff && currentFile && line.startsWith(oldFileNameHeader) && nxtLine.startsWith(newFileNameHeader) && afterNxtLine.startsWith(hunkHeaderPrefix)) { - startFile(); - } - if (currentFile === null || currentFile === void 0 ? void 0 : currentFile.isTooBig) { - return; - } - if (currentFile && (typeof config.diffMaxChanges === "number" && currentFile.addedLines + currentFile.deletedLines > config.diffMaxChanges || typeof config.diffMaxLineLength === "number" && line.length > config.diffMaxLineLength)) { - currentFile.isTooBig = true; - currentFile.addedLines = 0; - currentFile.deletedLines = 0; - currentFile.blocks = []; - currentBlock = null; - const message = typeof config.diffTooBigMessage === "function" ? config.diffTooBigMessage(files.length) : "Diff too big to be displayed"; - startBlock(message); - return; - } - if (line.startsWith(oldFileNameHeader) && nxtLine.startsWith(newFileNameHeader) || line.startsWith(newFileNameHeader) && prevLine.startsWith(oldFileNameHeader)) { - if (currentFile && !currentFile.oldName && line.startsWith("--- ") && (values = getSrcFilename(line, config.srcPrefix))) { - currentFile.oldName = values; - currentFile.language = getExtension(currentFile.oldName, currentFile.language); - return; - } - if (currentFile && !currentFile.newName && line.startsWith("+++ ") && (values = getDstFilename(line, config.dstPrefix))) { - currentFile.newName = values; - currentFile.language = getExtension(currentFile.newName, currentFile.language); - return; - } - } - if (currentFile && (line.startsWith(hunkHeaderPrefix) || currentFile.isGitDiff && currentFile.oldName && currentFile.newName && !currentBlock)) { - startBlock(line); - return; - } - if (currentBlock && (line.startsWith("+") || line.startsWith("-") || line.startsWith(" "))) { - createLine(line); - return; - } - const doesNotExistHunkHeader = !existHunkHeader(line, lineIndex); - if (currentFile === null) { - throw new Error("Where is my file !!!"); - } - if (values = oldMode.exec(line)) { - currentFile.oldMode = values[1]; - } else if (values = newMode.exec(line)) { - currentFile.newMode = values[1]; - } else if (values = deletedFileMode.exec(line)) { - currentFile.deletedFileMode = values[1]; - currentFile.isDeleted = true; - } else if (values = newFileMode.exec(line)) { - currentFile.newFileMode = values[1]; - currentFile.isNew = true; - } else if (values = copyFrom.exec(line)) { - if (doesNotExistHunkHeader) { - currentFile.oldName = values[1]; - } - currentFile.isCopy = true; - } else if (values = copyTo.exec(line)) { - if (doesNotExistHunkHeader) { - currentFile.newName = values[1]; - } - currentFile.isCopy = true; - } else if (values = renameFrom.exec(line)) { - if (doesNotExistHunkHeader) { - currentFile.oldName = values[1]; - } - currentFile.isRename = true; - } else if (values = renameTo.exec(line)) { - if (doesNotExistHunkHeader) { - currentFile.newName = values[1]; - } - currentFile.isRename = true; - } else if (values = binaryFiles.exec(line)) { - currentFile.isBinary = true; - currentFile.oldName = getFilename(values[1], void 0, config.srcPrefix); - currentFile.newName = getFilename(values[2], void 0, config.dstPrefix); - startBlock("Binary file"); - } else if (binaryDiff.test(line)) { - currentFile.isBinary = true; - startBlock(line); - } else if (values = similarityIndex.exec(line)) { - currentFile.unchangedPercentage = parseInt(values[1], 10); - } else if (values = dissimilarityIndex.exec(line)) { - currentFile.changedPercentage = parseInt(values[1], 10); - } else if (values = index2.exec(line)) { - currentFile.checksumBefore = values[1]; - currentFile.checksumAfter = values[2]; - values[3] && (currentFile.mode = values[3]); - } else if (values = combinedIndex.exec(line)) { - currentFile.checksumBefore = [values[2], values[3]]; - currentFile.checksumAfter = values[1]; - } else if (values = combinedMode.exec(line)) { - currentFile.oldMode = [values[2], values[3]]; - currentFile.newMode = values[1]; - } else if (values = combinedNewFile.exec(line)) { - currentFile.newFileMode = values[1]; - currentFile.isNew = true; - } else if (values = combinedDeletedFile.exec(line)) { - currentFile.deletedFileMode = values[1]; - currentFile.isDeleted = true; - } - }); - saveBlock(); - saveFile(); - return files; -} - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/file-list-renderer.js -init_polyfill_buffer(); - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/render-utils.js -init_polyfill_buffer(); - -// node_modules/.pnpm/diff@5.1.0/node_modules/diff/lib/index.mjs -init_polyfill_buffer(); -function Diff2() { -} -Diff2.prototype = { - diff: function diff2(oldString, newString) { - var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; - var callback = options.callback; - if (typeof options === "function") { - callback = options; - options = {}; - } - this.options = options; - var self2 = this; - function done(value) { - if (callback) { - setTimeout(function() { - callback(void 0, value); - }, 0); - return true; - } else { - return value; - } - } - oldString = this.castInput(oldString); - newString = this.castInput(newString); - oldString = this.removeEmpty(this.tokenize(oldString)); - newString = this.removeEmpty(this.tokenize(newString)); - var newLen = newString.length, oldLen = oldString.length; - var editLength = 1; - var maxEditLength = newLen + oldLen; - if (options.maxEditLength) { - maxEditLength = Math.min(maxEditLength, options.maxEditLength); - } - var bestPath = [{ - newPos: -1, - components: [] - }]; - var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); - if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { - return done([{ - value: this.join(newString), - count: newString.length - }]); - } - function execEditLength() { - for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { - var basePath = void 0; - var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; - if (addPath) { - bestPath[diagonalPath - 1] = void 0; - } - var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; - if (!canAdd && !canRemove) { - bestPath[diagonalPath] = void 0; - continue; - } - if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { - basePath = clonePath(removePath); - self2.pushComponent(basePath.components, void 0, true); - } else { - basePath = addPath; - basePath.newPos++; - self2.pushComponent(basePath.components, true, void 0); - } - _oldPos = self2.extractCommon(basePath, newString, oldString, diagonalPath); - if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { - return done(buildValues2(self2, basePath.components, newString, oldString, self2.useLongestToken)); - } else { - bestPath[diagonalPath] = basePath; - } - } - editLength++; - } - if (callback) { - (function exec() { - setTimeout(function() { - if (editLength > maxEditLength) { - return callback(); - } - if (!execEditLength()) { - exec(); - } - }, 0); - })(); - } else { - while (editLength <= maxEditLength) { - var ret = execEditLength(); - if (ret) { - return ret; - } - } - } - }, - pushComponent: function pushComponent(components, added, removed) { - var last2 = components[components.length - 1]; - if (last2 && last2.added === added && last2.removed === removed) { - components[components.length - 1] = { - count: last2.count + 1, - added, - removed - }; - } else { - components.push({ - count: 1, - added, - removed - }); - } - }, - extractCommon: function extractCommon2(basePath, newString, oldString, diagonalPath) { - var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0; - while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { - newPos++; - oldPos++; - commonCount++; - } - if (commonCount) { - basePath.components.push({ - count: commonCount - }); - } - basePath.newPos = newPos; - return oldPos; - }, - equals: function equals2(left, right) { - if (this.options.comparator) { - return this.options.comparator(left, right); - } else { - return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); - } - }, - removeEmpty: function removeEmpty2(array) { - var ret = []; - for (var i = 0; i < array.length; i++) { - if (array[i]) { - ret.push(array[i]); - } - } - return ret; - }, - castInput: function castInput2(value) { - return value; - }, - tokenize: function tokenize2(value) { - return value.split(""); - }, - join: function join4(chars) { - return chars.join(""); - } -}; -function buildValues2(diff3, components, newString, oldString, useLongestToken) { - var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0; - for (; componentPos < componentLen; componentPos++) { - var component = components[componentPos]; - if (!component.removed) { - if (!component.added && useLongestToken) { - var value = newString.slice(newPos, newPos + component.count); - value = value.map(function(value2, i) { - var oldValue = oldString[oldPos + i]; - return oldValue.length > value2.length ? oldValue : value2; - }); - component.value = diff3.join(value); - } else { - component.value = diff3.join(newString.slice(newPos, newPos + component.count)); - } - newPos += component.count; - if (!component.added) { - oldPos += component.count; - } - } else { - component.value = diff3.join(oldString.slice(oldPos, oldPos + component.count)); - oldPos += component.count; - if (componentPos && components[componentPos - 1].added) { - var tmp = components[componentPos - 1]; - components[componentPos - 1] = components[componentPos]; - components[componentPos] = tmp; - } - } - } - var lastComponent = components[componentLen - 1]; - if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff3.equals("", lastComponent.value)) { - components[componentLen - 2].value += lastComponent.value; - components.pop(); - } - return components; -} -function clonePath(path2) { - return { - newPos: path2.newPos, - components: path2.components.slice(0) - }; -} -var characterDiff2 = new Diff2(); -function diffChars(oldStr, newStr, options) { - return characterDiff2.diff(oldStr, newStr, options); -} -var extendedWordChars2 = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; -var reWhitespace2 = /\S/; -var wordDiff2 = new Diff2(); -wordDiff2.equals = function(left, right) { - if (this.options.ignoreCase) { - left = left.toLowerCase(); - right = right.toLowerCase(); - } - return left === right || this.options.ignoreWhitespace && !reWhitespace2.test(left) && !reWhitespace2.test(right); -}; -wordDiff2.tokenize = function(value) { - var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); - for (var i = 0; i < tokens.length - 1; i++) { - if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars2.test(tokens[i]) && extendedWordChars2.test(tokens[i + 2])) { - tokens[i] += tokens[i + 2]; - tokens.splice(i + 1, 2); - i--; - } - } - return tokens; -}; -function diffWordsWithSpace(oldStr, newStr, options) { - return wordDiff2.diff(oldStr, newStr, options); -} -var lineDiff2 = new Diff2(); -lineDiff2.tokenize = function(value) { - var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/); - if (!linesAndNewlines[linesAndNewlines.length - 1]) { - linesAndNewlines.pop(); - } - for (var i = 0; i < linesAndNewlines.length; i++) { - var line = linesAndNewlines[i]; - if (i % 2 && !this.options.newlineIsToken) { - retLines[retLines.length - 1] += line; - } else { - if (this.options.ignoreWhitespace) { - line = line.trim(); - } - retLines.push(line); - } - } - return retLines; -}; -var sentenceDiff2 = new Diff2(); -sentenceDiff2.tokenize = function(value) { - return value.split(/(\S.+?[.!?])(?=\s+|$)/); -}; -var cssDiff2 = new Diff2(); -cssDiff2.tokenize = function(value) { - return value.split(/([{}:;,]|\s+)/); -}; -function _typeof2(obj) { - "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof2 = function(obj2) { - return typeof obj2; - }; - } else { - _typeof2 = function(obj2) { - return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; - }; - } - return _typeof2(obj); -} -var objectPrototypeToString2 = Object.prototype.toString; -var jsonDiff2 = new Diff2(); -jsonDiff2.useLongestToken = true; -jsonDiff2.tokenize = lineDiff2.tokenize; -jsonDiff2.castInput = function(value) { - var _this$options = this.options, undefinedReplacement = _this$options.undefinedReplacement, _this$options$stringi = _this$options.stringifyReplacer, stringifyReplacer = _this$options$stringi === void 0 ? function(k, v) { - return typeof v === "undefined" ? undefinedReplacement : v; - } : _this$options$stringi; - return typeof value === "string" ? value : JSON.stringify(canonicalize2(value, null, null, stringifyReplacer), stringifyReplacer, " "); -}; -jsonDiff2.equals = function(left, right) { - return Diff2.prototype.equals.call(jsonDiff2, left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1")); -}; -function canonicalize2(obj, stack, replacementStack, replacer, key2) { - stack = stack || []; - replacementStack = replacementStack || []; - if (replacer) { - obj = replacer(key2, obj); - } - var i; - for (i = 0; i < stack.length; i += 1) { - if (stack[i] === obj) { - return replacementStack[i]; - } - } - var canonicalizedObj; - if ("[object Array]" === objectPrototypeToString2.call(obj)) { - stack.push(obj); - canonicalizedObj = new Array(obj.length); - replacementStack.push(canonicalizedObj); - for (i = 0; i < obj.length; i += 1) { - canonicalizedObj[i] = canonicalize2(obj[i], stack, replacementStack, replacer, key2); - } - stack.pop(); - replacementStack.pop(); - return canonicalizedObj; - } - if (obj && obj.toJSON) { - obj = obj.toJSON(); - } - if (_typeof2(obj) === "object" && obj !== null) { - stack.push(obj); - canonicalizedObj = {}; - replacementStack.push(canonicalizedObj); - var sortedKeys = [], _key; - for (_key in obj) { - if (obj.hasOwnProperty(_key)) { - sortedKeys.push(_key); - } - } - sortedKeys.sort(); - for (i = 0; i < sortedKeys.length; i += 1) { - _key = sortedKeys[i]; - canonicalizedObj[_key] = canonicalize2(obj[_key], stack, replacementStack, replacer, _key); - } - stack.pop(); - replacementStack.pop(); - } else { - canonicalizedObj = obj; - } - return canonicalizedObj; -} -var arrayDiff2 = new Diff2(); -arrayDiff2.tokenize = function(value) { - return value.slice(); -}; -arrayDiff2.join = arrayDiff2.removeEmpty = function(value) { - return value; -}; - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/rematch.js -init_polyfill_buffer(); -function levenshtein(a, b) { - if (a.length === 0) { - return b.length; - } - if (b.length === 0) { - return a.length; - } - const matrix = []; - let i; - for (i = 0; i <= b.length; i++) { - matrix[i] = [i]; - } - let j; - for (j = 0; j <= a.length; j++) { - matrix[0][j] = j; - } - for (i = 1; i <= b.length; i++) { - for (j = 1; j <= a.length; j++) { - if (b.charAt(i - 1) === a.charAt(j - 1)) { - matrix[i][j] = matrix[i - 1][j - 1]; - } else { - matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1)); - } - } - } - return matrix[b.length][a.length]; -} -function newDistanceFn(str) { - return (x, y) => { - const xValue = str(x).trim(); - const yValue = str(y).trim(); - const lev = levenshtein(xValue, yValue); - return lev / (xValue.length + yValue.length); - }; -} -function newMatcherFn(distance2) { - function findBestMatch(a, b, cache = /* @__PURE__ */ new Map()) { - let bestMatchDist = Infinity; - let bestMatch; - for (let i = 0; i < a.length; ++i) { - for (let j = 0; j < b.length; ++j) { - const cacheKey = JSON.stringify([a[i], b[j]]); - let md; - if (!(cache.has(cacheKey) && (md = cache.get(cacheKey)))) { - md = distance2(a[i], b[j]); - cache.set(cacheKey, md); - } - if (md < bestMatchDist) { - bestMatchDist = md; - bestMatch = { indexA: i, indexB: j, score: bestMatchDist }; - } - } - } - return bestMatch; - } - function group(a, b, level = 0, cache = /* @__PURE__ */ new Map()) { - const bm = findBestMatch(a, b, cache); - if (!bm || a.length + b.length < 3) { - return [[a, b]]; - } - const a1 = a.slice(0, bm.indexA); - const b1 = b.slice(0, bm.indexB); - const aMatch = [a[bm.indexA]]; - const bMatch = [b[bm.indexB]]; - const tailA = bm.indexA + 1; - const tailB = bm.indexB + 1; - const a2 = a.slice(tailA); - const b2 = b.slice(tailB); - const group1 = group(a1, b1, level + 1, cache); - const groupMatch = group(aMatch, bMatch, level + 1, cache); - const group2 = group(a2, b2, level + 1, cache); - let result = groupMatch; - if (bm.indexA > 0 || bm.indexB > 0) { - result = group1.concat(result); - } - if (a.length > tailA || b.length > tailB) { - result = result.concat(group2); - } - return result; - } - return group; -} - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/render-utils.js -var CSSLineClass = { - INSERTS: "d2h-ins", - DELETES: "d2h-del", - CONTEXT: "d2h-cntx", - INFO: "d2h-info", - INSERT_CHANGES: "d2h-ins d2h-change", - DELETE_CHANGES: "d2h-del d2h-change" -}; -var defaultRenderConfig = { - matching: LineMatchingType.NONE, - matchWordsThreshold: 0.25, - maxLineLengthHighlight: 1e4, - diffStyle: DiffStyleType.WORD, - colorScheme: ColorSchemeType.LIGHT -}; -var separator = "/"; -var distance = newDistanceFn((change) => change.value); -var matcher = newMatcherFn(distance); -function isDevNullName(name) { - return name.indexOf("dev/null") !== -1; -} -function removeInsElements(line) { - return line.replace(/(]*>((.|\n)*?)<\/ins>)/g, ""); -} -function removeDelElements(line) { - return line.replace(/(]*>((.|\n)*?)<\/del>)/g, ""); -} -function toCSSClass(lineType) { - switch (lineType) { - case LineType.CONTEXT: - return CSSLineClass.CONTEXT; - case LineType.INSERT: - return CSSLineClass.INSERTS; - case LineType.DELETE: - return CSSLineClass.DELETES; - } -} -function colorSchemeToCss(colorScheme) { - switch (colorScheme) { - case ColorSchemeType.DARK: - return "d2h-dark-color-scheme"; - case ColorSchemeType.AUTO: - return "d2h-auto-color-scheme"; - case ColorSchemeType.LIGHT: - default: - return "d2h-light-color-scheme"; - } -} -function prefixLength(isCombined) { - return isCombined ? 2 : 1; -} -function escapeForHtml(str) { - return str.slice(0).replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/\//g, "/"); -} -function deconstructLine(line, isCombined, escape = true) { - const indexToSplit = prefixLength(isCombined); - return { - prefix: line.substring(0, indexToSplit), - content: escape ? escapeForHtml(line.substring(indexToSplit)) : line.substring(indexToSplit) - }; -} -function filenameDiff(file) { - const oldFilename = unifyPath(file.oldName); - const newFilename = unifyPath(file.newName); - if (oldFilename !== newFilename && !isDevNullName(oldFilename) && !isDevNullName(newFilename)) { - const prefixPaths = []; - const suffixPaths = []; - const oldFilenameParts = oldFilename.split(separator); - const newFilenameParts = newFilename.split(separator); - const oldFilenamePartsSize = oldFilenameParts.length; - const newFilenamePartsSize = newFilenameParts.length; - let i = 0; - let j = oldFilenamePartsSize - 1; - let k = newFilenamePartsSize - 1; - while (i < j && i < k) { - if (oldFilenameParts[i] === newFilenameParts[i]) { - prefixPaths.push(newFilenameParts[i]); - i += 1; - } else { - break; - } - } - while (j > i && k > i) { - if (oldFilenameParts[j] === newFilenameParts[k]) { - suffixPaths.unshift(newFilenameParts[k]); - j -= 1; - k -= 1; - } else { - break; - } - } - const finalPrefix = prefixPaths.join(separator); - const finalSuffix = suffixPaths.join(separator); - const oldRemainingPath = oldFilenameParts.slice(i, j + 1).join(separator); - const newRemainingPath = newFilenameParts.slice(i, k + 1).join(separator); - if (finalPrefix.length && finalSuffix.length) { - return finalPrefix + separator + "{" + oldRemainingPath + " \u2192 " + newRemainingPath + "}" + separator + finalSuffix; - } else if (finalPrefix.length) { - return finalPrefix + separator + "{" + oldRemainingPath + " \u2192 " + newRemainingPath + "}"; - } else if (finalSuffix.length) { - return "{" + oldRemainingPath + " \u2192 " + newRemainingPath + "}" + separator + finalSuffix; - } - return oldFilename + " \u2192 " + newFilename; - } else if (!isDevNullName(newFilename)) { - return newFilename; - } else { - return oldFilename; - } -} -function getHtmlId(file) { - return `d2h-${hashCode(filenameDiff(file)).toString().slice(-6)}`; -} -function getFileIcon(file) { - let templateName = "file-changed"; - if (file.isRename) { - templateName = "file-renamed"; - } else if (file.isCopy) { - templateName = "file-renamed"; - } else if (file.isNew) { - templateName = "file-added"; - } else if (file.isDeleted) { - templateName = "file-deleted"; - } else if (file.newName !== file.oldName) { - templateName = "file-renamed"; - } - return templateName; -} -function diffHighlight(diffLine1, diffLine2, isCombined, config = {}) { - const { matching, maxLineLengthHighlight, matchWordsThreshold, diffStyle } = Object.assign(Object.assign({}, defaultRenderConfig), config); - const line1 = deconstructLine(diffLine1, isCombined, false); - const line2 = deconstructLine(diffLine2, isCombined, false); - if (line1.content.length > maxLineLengthHighlight || line2.content.length > maxLineLengthHighlight) { - return { - oldLine: { - prefix: line1.prefix, - content: escapeForHtml(line1.content) - }, - newLine: { - prefix: line2.prefix, - content: escapeForHtml(line2.content) - } - }; - } - const diff3 = diffStyle === "char" ? diffChars(line1.content, line2.content) : diffWordsWithSpace(line1.content, line2.content); - const changedWords = []; - if (diffStyle === "word" && matching === "words") { - const removed = diff3.filter((element2) => element2.removed); - const added = diff3.filter((element2) => element2.added); - const chunks = matcher(added, removed); - chunks.forEach((chunk) => { - if (chunk[0].length === 1 && chunk[1].length === 1) { - const dist = distance(chunk[0][0], chunk[1][0]); - if (dist < matchWordsThreshold) { - changedWords.push(chunk[0][0]); - changedWords.push(chunk[1][0]); - } - } - }); - } - const highlightedLine = diff3.reduce((highlightedLine2, part) => { - const elemType = part.added ? "ins" : part.removed ? "del" : null; - const addClass = changedWords.indexOf(part) > -1 ? ' class="d2h-change"' : ""; - const escapedValue = escapeForHtml(part.value); - return elemType !== null ? `${highlightedLine2}<${elemType}${addClass}>${escapedValue}` : `${highlightedLine2}${escapedValue}`; - }, ""); - return { - oldLine: { - prefix: line1.prefix, - content: removeInsElements(highlightedLine) - }, - newLine: { - prefix: line2.prefix, - content: removeDelElements(highlightedLine) - } - }; -} - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/file-list-renderer.js -var baseTemplatesPath = "file-summary"; -var iconsBaseTemplatesPath = "icon"; -var defaultFileListRendererConfig = { - colorScheme: defaultRenderConfig.colorScheme -}; -var FileListRenderer = class { - constructor(hoganUtils, config = {}) { - this.hoganUtils = hoganUtils; - this.config = Object.assign(Object.assign({}, defaultFileListRendererConfig), config); - } - render(diffFiles) { - const files = diffFiles.map((file) => this.hoganUtils.render(baseTemplatesPath, "line", { - fileHtmlId: getHtmlId(file), - oldName: file.oldName, - newName: file.newName, - fileName: filenameDiff(file), - deletedLines: "-" + file.deletedLines, - addedLines: "+" + file.addedLines - }, { - fileIcon: this.hoganUtils.template(iconsBaseTemplatesPath, getFileIcon(file)) - })).join("\n"); - return this.hoganUtils.render(baseTemplatesPath, "wrapper", { - colorScheme: colorSchemeToCss(this.config.colorScheme), - filesNumber: diffFiles.length, - files - }); - } -}; - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/line-by-line-renderer.js -init_polyfill_buffer(); -var defaultLineByLineRendererConfig = Object.assign(Object.assign({}, defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 }); -var genericTemplatesPath = "generic"; -var baseTemplatesPath2 = "line-by-line"; -var iconsBaseTemplatesPath2 = "icon"; -var tagsBaseTemplatesPath = "tag"; -var LineByLineRenderer = class { - constructor(hoganUtils, config = {}) { - this.hoganUtils = hoganUtils; - this.config = Object.assign(Object.assign({}, defaultLineByLineRendererConfig), config); - } - render(diffFiles) { - const diffsHtml = diffFiles.map((file) => { - let diffs; - if (file.blocks.length) { - diffs = this.generateFileHtml(file); - } else { - diffs = this.generateEmptyDiff(); - } - return this.makeFileDiffHtml(file, diffs); - }).join("\n"); - return this.hoganUtils.render(genericTemplatesPath, "wrapper", { - colorScheme: colorSchemeToCss(this.config.colorScheme), - content: diffsHtml - }); - } - makeFileDiffHtml(file, diffs) { - if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0) - return ""; - const fileDiffTemplate = this.hoganUtils.template(baseTemplatesPath2, "file-diff"); - const filePathTemplate = this.hoganUtils.template(genericTemplatesPath, "file-path"); - const fileIconTemplate = this.hoganUtils.template(iconsBaseTemplatesPath2, "file"); - const fileTagTemplate = this.hoganUtils.template(tagsBaseTemplatesPath, getFileIcon(file)); - return fileDiffTemplate.render({ - file, - fileHtmlId: getHtmlId(file), - diffs, - filePath: filePathTemplate.render({ - fileDiffName: filenameDiff(file) - }, { - fileIcon: fileIconTemplate, - fileTag: fileTagTemplate - }) - }); - } - generateEmptyDiff() { - return this.hoganUtils.render(genericTemplatesPath, "empty-diff", { - contentClass: "d2h-code-line", - CSSLineClass - }); - } - generateFileHtml(file) { - const matcher2 = newMatcherFn(newDistanceFn((e) => deconstructLine(e.content, file.isCombined).content)); - return file.blocks.map((block) => { - let lines = this.hoganUtils.render(genericTemplatesPath, "block-header", { - CSSLineClass, - blockHeader: file.isTooBig ? block.header : escapeForHtml(block.header), - lineClass: "d2h-code-linenumber", - contentClass: "d2h-code-line" - }); - this.applyLineGroupping(block).forEach(([contextLines, oldLines, newLines]) => { - if (oldLines.length && newLines.length && !contextLines.length) { - this.applyRematchMatching(oldLines, newLines, matcher2).map(([oldLines2, newLines2]) => { - const { left, right } = this.processChangedLines(file, file.isCombined, oldLines2, newLines2); - lines += left; - lines += right; - }); - } else if (contextLines.length) { - contextLines.forEach((line) => { - const { prefix, content } = deconstructLine(line.content, file.isCombined); - lines += this.generateSingleLineHtml(file, { - type: CSSLineClass.CONTEXT, - prefix, - content, - oldNumber: line.oldNumber, - newNumber: line.newNumber - }); - }); - } else if (oldLines.length || newLines.length) { - const { left, right } = this.processChangedLines(file, file.isCombined, oldLines, newLines); - lines += left; - lines += right; - } else { - console.error("Unknown state reached while processing groups of lines", contextLines, oldLines, newLines); - } - }); - return lines; - }).join("\n"); - } - applyLineGroupping(block) { - const blockLinesGroups = []; - let oldLines = []; - let newLines = []; - for (let i = 0; i < block.lines.length; i++) { - const diffLine = block.lines[i]; - if (diffLine.type !== LineType.INSERT && newLines.length || diffLine.type === LineType.CONTEXT && oldLines.length > 0) { - blockLinesGroups.push([[], oldLines, newLines]); - oldLines = []; - newLines = []; - } - if (diffLine.type === LineType.CONTEXT) { - blockLinesGroups.push([[diffLine], [], []]); - } else if (diffLine.type === LineType.INSERT && oldLines.length === 0) { - blockLinesGroups.push([[], [], [diffLine]]); - } else if (diffLine.type === LineType.INSERT && oldLines.length > 0) { - newLines.push(diffLine); - } else if (diffLine.type === LineType.DELETE) { - oldLines.push(diffLine); - } - } - if (oldLines.length || newLines.length) { - blockLinesGroups.push([[], oldLines, newLines]); - oldLines = []; - newLines = []; - } - return blockLinesGroups; - } - applyRematchMatching(oldLines, newLines, matcher2) { - const comparisons = oldLines.length * newLines.length; - const maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map((elem) => elem.content.length))); - const doMatching = comparisons < this.config.matchingMaxComparisons && maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison && (this.config.matching === "lines" || this.config.matching === "words"); - return doMatching ? matcher2(oldLines, newLines) : [[oldLines, newLines]]; - } - processChangedLines(file, isCombined, oldLines, newLines) { - const fileHtml = { - right: "", - left: "" - }; - const maxLinesNumber = Math.max(oldLines.length, newLines.length); - for (let i = 0; i < maxLinesNumber; i++) { - const oldLine = oldLines[i]; - const newLine = newLines[i]; - const diff3 = oldLine !== void 0 && newLine !== void 0 ? diffHighlight(oldLine.content, newLine.content, isCombined, this.config) : void 0; - const preparedOldLine = oldLine !== void 0 && oldLine.oldNumber !== void 0 ? Object.assign(Object.assign({}, diff3 !== void 0 ? { - prefix: diff3.oldLine.prefix, - content: diff3.oldLine.content, - type: CSSLineClass.DELETE_CHANGES - } : Object.assign(Object.assign({}, deconstructLine(oldLine.content, isCombined)), { type: toCSSClass(oldLine.type) })), { oldNumber: oldLine.oldNumber, newNumber: oldLine.newNumber }) : void 0; - const preparedNewLine = newLine !== void 0 && newLine.newNumber !== void 0 ? Object.assign(Object.assign({}, diff3 !== void 0 ? { - prefix: diff3.newLine.prefix, - content: diff3.newLine.content, - type: CSSLineClass.INSERT_CHANGES - } : Object.assign(Object.assign({}, deconstructLine(newLine.content, isCombined)), { type: toCSSClass(newLine.type) })), { oldNumber: newLine.oldNumber, newNumber: newLine.newNumber }) : void 0; - const { left, right } = this.generateLineHtml(file, preparedOldLine, preparedNewLine); - fileHtml.left += left; - fileHtml.right += right; - } - return fileHtml; - } - generateLineHtml(file, oldLine, newLine) { - return { - left: this.generateSingleLineHtml(file, oldLine), - right: this.generateSingleLineHtml(file, newLine) - }; - } - generateSingleLineHtml(file, line) { - if (line === void 0) - return ""; - const lineNumberHtml = this.hoganUtils.render(baseTemplatesPath2, "numbers", { - oldNumber: line.oldNumber || "", - newNumber: line.newNumber || "" - }); - return this.hoganUtils.render(genericTemplatesPath, "line", { - type: line.type, - lineClass: "d2h-code-linenumber", - contentClass: "d2h-code-line", - prefix: line.prefix === " " ? " " : line.prefix, - content: line.content, - lineNumber: lineNumberHtml, - line, - file - }); - } -}; - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/side-by-side-renderer.js -init_polyfill_buffer(); -var defaultSideBySideRendererConfig = Object.assign(Object.assign({}, defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 }); -var genericTemplatesPath2 = "generic"; -var baseTemplatesPath3 = "side-by-side"; -var iconsBaseTemplatesPath3 = "icon"; -var tagsBaseTemplatesPath2 = "tag"; -var SideBySideRenderer = class { - constructor(hoganUtils, config = {}) { - this.hoganUtils = hoganUtils; - this.config = Object.assign(Object.assign({}, defaultSideBySideRendererConfig), config); - } - render(diffFiles) { - const diffsHtml = diffFiles.map((file) => { - let diffs; - if (file.blocks.length) { - diffs = this.generateFileHtml(file); - } else { - diffs = this.generateEmptyDiff(); - } - return this.makeFileDiffHtml(file, diffs); - }).join("\n"); - return this.hoganUtils.render(genericTemplatesPath2, "wrapper", { - colorScheme: colorSchemeToCss(this.config.colorScheme), - content: diffsHtml - }); - } - makeFileDiffHtml(file, diffs) { - if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0) - return ""; - const fileDiffTemplate = this.hoganUtils.template(baseTemplatesPath3, "file-diff"); - const filePathTemplate = this.hoganUtils.template(genericTemplatesPath2, "file-path"); - const fileIconTemplate = this.hoganUtils.template(iconsBaseTemplatesPath3, "file"); - const fileTagTemplate = this.hoganUtils.template(tagsBaseTemplatesPath2, getFileIcon(file)); - return fileDiffTemplate.render({ - file, - fileHtmlId: getHtmlId(file), - diffs, - filePath: filePathTemplate.render({ - fileDiffName: filenameDiff(file) - }, { - fileIcon: fileIconTemplate, - fileTag: fileTagTemplate - }) - }); - } - generateEmptyDiff() { - return { - right: "", - left: this.hoganUtils.render(genericTemplatesPath2, "empty-diff", { - contentClass: "d2h-code-side-line", - CSSLineClass - }) - }; - } - generateFileHtml(file) { - const matcher2 = newMatcherFn(newDistanceFn((e) => deconstructLine(e.content, file.isCombined).content)); - return file.blocks.map((block) => { - const fileHtml = { - left: this.makeHeaderHtml(block.header, file), - right: this.makeHeaderHtml("") - }; - this.applyLineGroupping(block).forEach(([contextLines, oldLines, newLines]) => { - if (oldLines.length && newLines.length && !contextLines.length) { - this.applyRematchMatching(oldLines, newLines, matcher2).map(([oldLines2, newLines2]) => { - const { left, right } = this.processChangedLines(file.isCombined, oldLines2, newLines2); - fileHtml.left += left; - fileHtml.right += right; - }); - } else if (contextLines.length) { - contextLines.forEach((line) => { - const { prefix, content } = deconstructLine(line.content, file.isCombined); - const { left, right } = this.generateLineHtml({ - type: CSSLineClass.CONTEXT, - prefix, - content, - number: line.oldNumber - }, { - type: CSSLineClass.CONTEXT, - prefix, - content, - number: line.newNumber - }); - fileHtml.left += left; - fileHtml.right += right; - }); - } else if (oldLines.length || newLines.length) { - const { left, right } = this.processChangedLines(file.isCombined, oldLines, newLines); - fileHtml.left += left; - fileHtml.right += right; - } else { - console.error("Unknown state reached while processing groups of lines", contextLines, oldLines, newLines); - } - }); - return fileHtml; - }).reduce((accomulated, html2) => { - return { left: accomulated.left + html2.left, right: accomulated.right + html2.right }; - }, { left: "", right: "" }); - } - applyLineGroupping(block) { - const blockLinesGroups = []; - let oldLines = []; - let newLines = []; - for (let i = 0; i < block.lines.length; i++) { - const diffLine = block.lines[i]; - if (diffLine.type !== LineType.INSERT && newLines.length || diffLine.type === LineType.CONTEXT && oldLines.length > 0) { - blockLinesGroups.push([[], oldLines, newLines]); - oldLines = []; - newLines = []; - } - if (diffLine.type === LineType.CONTEXT) { - blockLinesGroups.push([[diffLine], [], []]); - } else if (diffLine.type === LineType.INSERT && oldLines.length === 0) { - blockLinesGroups.push([[], [], [diffLine]]); - } else if (diffLine.type === LineType.INSERT && oldLines.length > 0) { - newLines.push(diffLine); - } else if (diffLine.type === LineType.DELETE) { - oldLines.push(diffLine); - } - } - if (oldLines.length || newLines.length) { - blockLinesGroups.push([[], oldLines, newLines]); - oldLines = []; - newLines = []; - } - return blockLinesGroups; - } - applyRematchMatching(oldLines, newLines, matcher2) { - const comparisons = oldLines.length * newLines.length; - const maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map((elem) => elem.content.length))); - const doMatching = comparisons < this.config.matchingMaxComparisons && maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison && (this.config.matching === "lines" || this.config.matching === "words"); - return doMatching ? matcher2(oldLines, newLines) : [[oldLines, newLines]]; - } - makeHeaderHtml(blockHeader, file) { - return this.hoganUtils.render(genericTemplatesPath2, "block-header", { - CSSLineClass, - blockHeader: (file === null || file === void 0 ? void 0 : file.isTooBig) ? blockHeader : escapeForHtml(blockHeader), - lineClass: "d2h-code-side-linenumber", - contentClass: "d2h-code-side-line" - }); - } - processChangedLines(isCombined, oldLines, newLines) { - const fileHtml = { - right: "", - left: "" - }; - const maxLinesNumber = Math.max(oldLines.length, newLines.length); - for (let i = 0; i < maxLinesNumber; i++) { - const oldLine = oldLines[i]; - const newLine = newLines[i]; - const diff3 = oldLine !== void 0 && newLine !== void 0 ? diffHighlight(oldLine.content, newLine.content, isCombined, this.config) : void 0; - const preparedOldLine = oldLine !== void 0 && oldLine.oldNumber !== void 0 ? Object.assign(Object.assign({}, diff3 !== void 0 ? { - prefix: diff3.oldLine.prefix, - content: diff3.oldLine.content, - type: CSSLineClass.DELETE_CHANGES - } : Object.assign(Object.assign({}, deconstructLine(oldLine.content, isCombined)), { type: toCSSClass(oldLine.type) })), { number: oldLine.oldNumber }) : void 0; - const preparedNewLine = newLine !== void 0 && newLine.newNumber !== void 0 ? Object.assign(Object.assign({}, diff3 !== void 0 ? { - prefix: diff3.newLine.prefix, - content: diff3.newLine.content, - type: CSSLineClass.INSERT_CHANGES - } : Object.assign(Object.assign({}, deconstructLine(newLine.content, isCombined)), { type: toCSSClass(newLine.type) })), { number: newLine.newNumber }) : void 0; - const { left, right } = this.generateLineHtml(preparedOldLine, preparedNewLine); - fileHtml.left += left; - fileHtml.right += right; - } - return fileHtml; - } - generateLineHtml(oldLine, newLine) { - return { - left: this.generateSingleHtml(oldLine), - right: this.generateSingleHtml(newLine) - }; - } - generateSingleHtml(line) { - const lineClass = "d2h-code-side-linenumber"; - const contentClass = "d2h-code-side-line"; - return this.hoganUtils.render(genericTemplatesPath2, "line", { - type: (line === null || line === void 0 ? void 0 : line.type) || `${CSSLineClass.CONTEXT} d2h-emptyplaceholder`, - lineClass: line !== void 0 ? lineClass : `${lineClass} d2h-code-side-emptyplaceholder`, - contentClass: line !== void 0 ? contentClass : `${contentClass} d2h-code-side-emptyplaceholder`, - prefix: (line === null || line === void 0 ? void 0 : line.prefix) === " " ? " " : line === null || line === void 0 ? void 0 : line.prefix, - content: line === null || line === void 0 ? void 0 : line.content, - lineNumber: line === null || line === void 0 ? void 0 : line.number - }); - } -}; - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/hoganjs-utils.js -init_polyfill_buffer(); -var Hogan3 = __toESM(require_hogan()); - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/diff2html-templates.js -init_polyfill_buffer(); -var Hogan2 = __toESM(require_hogan()); -var defaultTemplates = {}; -defaultTemplates["file-summary-line"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('
  • '); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(t.rp("'); - t.b(t.v(t.f("fileName", c, p, 0))); - t.b(""); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(' '); - t.b(t.v(t.f("addedLines", c, p, 0))); - t.b(""); - t.b("\n" + i); - t.b(' '); - t.b(t.v(t.f("deletedLines", c, p, 0))); - t.b(""); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b("
  • "); - return t.fl(); -}, partials: { "'); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b(' Files changed ('); - t.b(t.v(t.f("filesNumber", c, p, 0))); - t.b(")"); - t.b("\n" + i); - t.b(' hide'); - t.b("\n" + i); - t.b(' show'); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b('
      '); - t.b("\n" + i); - t.b(" "); - t.b(t.t(t.f("files", c, p, 0))); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["generic-block-header"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b(""); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b('
    '); - if (t.s(t.f("blockHeader", c, p, 1), c, p, 0, 156, 173, "{{ }}")) { - t.rs(c, p, function(c2, p2, t2) { - t2.b(t2.t(t2.f("blockHeader", c2, p2, 0))); - }); - c.pop(); - } - if (!t.s(t.f("blockHeader", c, p, 1), c, p, 1, 0, 0, "")) { - t.b(" "); - } - ; - t.b("
    "); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b(""); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["generic-empty-diff"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b(""); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b(" File without changes"); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b(""); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["generic-file-path"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b(''); - t.b("\n" + i); - t.b(t.rp("'); - t.b(t.v(t.f("fileDiffName", c, p, 0))); - t.b(""); - t.b("\n" + i); - t.b(t.rp(""); - t.b("\n" + i); - t.b('"); - return t.fl(); -}, partials: { ""); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(" "); - t.b(t.t(t.f("lineNumber", c, p, 0))); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - if (t.s(t.f("prefix", c, p, 1), c, p, 0, 162, 238, "{{ }}")) { - t.rs(c, p, function(c2, p2, t2) { - t2.b(' '); - t2.b(t2.t(t2.f("prefix", c2, p2, 0))); - t2.b(""); - t2.b("\n" + i); - }); - c.pop(); - } - if (!t.s(t.f("prefix", c, p, 1), c, p, 1, 0, 0, "")) { - t.b('  '); - t.b("\n" + i); - } - ; - if (t.s(t.f("content", c, p, 1), c, p, 0, 371, 445, "{{ }}")) { - t.rs(c, p, function(c2, p2, t2) { - t2.b(' '); - t2.b(t2.t(t2.f("content", c2, p2, 0))); - t2.b(""); - t2.b("\n" + i); - }); - c.pop(); - } - if (!t.s(t.f("content", c, p, 1), c, p, 1, 0, 0, "")) { - t.b('
    '); - t.b("\n" + i); - } - ; - t.b("
    "); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b(""); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["generic-wrapper"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('
    '); - t.b("\n" + i); - t.b(" "); - t.b(t.t(t.f("content", c, p, 0))); - t.b("\n" + i); - t.b("
    "); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["icon-file-added"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('"); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["icon-file-changed"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('"); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["icon-file-deleted"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('"); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["icon-file-renamed"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('"); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["icon-file"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('"); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["line-by-line-file-diff"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('
    '); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b(" "); - t.b(t.t(t.f("filePath", c, p, 0))); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(" "); - t.b(t.t(t.f("diffs", c, p, 0))); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["line-by-line-numbers"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('
    '); - t.b(t.v(t.f("oldNumber", c, p, 0))); - t.b("
    "); - t.b("\n" + i); - t.b('
    '); - t.b(t.v(t.f("newNumber", c, p, 0))); - t.b("
    "); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["side-by-side-file-diff"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('
    '); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b(" "); - t.b(t.t(t.f("filePath", c, p, 0))); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(" "); - t.b(t.t(t.d("diffs.left", c, p, 0))); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b('
    '); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(' '); - t.b("\n" + i); - t.b(" "); - t.b(t.t(t.d("diffs.right", c, p, 0))); - t.b("\n" + i); - t.b(" "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - t.b("\n" + i); - t.b("
    "); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["tag-file-added"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('ADDED'); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["tag-file-changed"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('CHANGED'); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["tag-file-deleted"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('DELETED'); - return t.fl(); -}, partials: {}, subs: {} }); -defaultTemplates["tag-file-renamed"] = new Hogan2.Template({ code: function(c, p, i) { - var t = this; - t.b(i = i || ""); - t.b('RENAMED'); - return t.fl(); -}, partials: {}, subs: {} }); - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/hoganjs-utils.js -var HoganJsUtils = class { - constructor({ compiledTemplates = {}, rawTemplates = {} }) { - const compiledRawTemplates = Object.entries(rawTemplates).reduce((previousTemplates, [name, templateString]) => { - const compiledTemplate = Hogan3.compile(templateString, { asString: false }); - return Object.assign(Object.assign({}, previousTemplates), { [name]: compiledTemplate }); - }, {}); - this.preCompiledTemplates = Object.assign(Object.assign(Object.assign({}, defaultTemplates), compiledTemplates), compiledRawTemplates); - } - static compile(templateString) { - return Hogan3.compile(templateString, { asString: false }); - } - render(namespace, view, params, partials, indent2) { - const templateKey = this.templateKey(namespace, view); - try { - const template = this.preCompiledTemplates[templateKey]; - return template.render(params, partials, indent2); - } catch (e) { - throw new Error(`Could not find template to render '${templateKey}'`); - } - } - template(namespace, view) { - return this.preCompiledTemplates[this.templateKey(namespace, view)]; - } - templateKey(namespace, view) { - return `${namespace}-${view}`; - } -}; - -// node_modules/.pnpm/diff2html@3.4.47/node_modules/diff2html/lib-esm/diff2html.js -var defaultDiff2HtmlConfig = Object.assign(Object.assign(Object.assign({}, defaultLineByLineRendererConfig), defaultSideBySideRendererConfig), { outputFormat: OutputFormatType.LINE_BY_LINE, drawFileList: true }); -function html(diffInput, configuration = {}) { - const config = Object.assign(Object.assign({}, defaultDiff2HtmlConfig), configuration); - const diffJson = typeof diffInput === "string" ? parse(diffInput, config) : diffInput; - const hoganUtils = new HoganJsUtils(config); - const { colorScheme } = config; - const fileListRendererConfig = { colorScheme }; - const fileList = config.drawFileList ? new FileListRenderer(hoganUtils, fileListRendererConfig).render(diffJson) : ""; - const diffOutput = config.outputFormat === "side-by-side" ? new SideBySideRenderer(hoganUtils, config).render(diffJson) : new LineByLineRenderer(hoganUtils, config).render(diffJson); - return fileList + diffOutput; -} - -// src/ui/diff/diffView.ts -var import_obsidian17 = require("obsidian"); -var DiffView = class extends import_obsidian17.ItemView { - constructor(leaf, plugin) { - super(leaf); - this.plugin = plugin; - this.gettingDiff = false; - this.gitRefreshBind = this.refresh.bind(this); - this.gitViewRefreshBind = this.refresh.bind(this); - this.parser = new DOMParser(); - this.navigation = true; - addEventListener("git-refresh", this.gitRefreshBind); - addEventListener("git-view-refresh", this.gitViewRefreshBind); - } - getViewType() { - return DIFF_VIEW_CONFIG.type; - } - getDisplayText() { - var _a2; - if (((_a2 = this.state) == null ? void 0 : _a2.file) != null) { - let fileName = this.state.file.split("/").last(); - if (fileName == null ? void 0 : fileName.endsWith(".md")) - fileName = fileName.slice(0, -3); - return DIFF_VIEW_CONFIG.name + ` (${fileName})`; - } - return DIFF_VIEW_CONFIG.name; - } - getIcon() { - return DIFF_VIEW_CONFIG.icon; - } - async setState(state, result) { - this.state = state; - if (import_obsidian17.Platform.isMobile) { - this.leaf.view.titleEl.textContent = this.getDisplayText(); - } - await this.refresh(); - } - getState() { - return this.state; - } - onClose() { - removeEventListener("git-refresh", this.gitRefreshBind); - removeEventListener("git-view-refresh", this.gitViewRefreshBind); - return super.onClose(); - } - onOpen() { - this.refresh(); - return super.onOpen(); - } - async refresh() { - var _a2; - if (((_a2 = this.state) == null ? void 0 : _a2.file) && !this.gettingDiff && this.plugin.gitManager) { - this.gettingDiff = true; - try { - let diff3 = await this.plugin.gitManager.getDiffString( - this.state.file, - this.state.staged, - this.state.hash - ); - this.contentEl.empty(); - if (!diff3) { - if (this.plugin.gitManager instanceof SimpleGit && await this.plugin.gitManager.isTracked( - this.state.file - )) { - diff3 = [ - `--- ${this.state.file}`, - `+++ ${this.state.file}`, - "" - ].join("\n"); - } else { - const content = await this.app.vault.adapter.read( - this.plugin.gitManager.getRelativeVaultPath( - this.state.file - ) - ); - const header = `--- /dev/null -+++ ${this.state.file} -@@ -0,0 +1,${content.split("\n").length} @@`; - diff3 = [ - ...header.split("\n"), - ...content.split("\n").map((line) => `+${line}`) - ].join("\n"); - } - } - const diffEl = this.parser.parseFromString(html(diff3), "text/html").querySelector(".d2h-file-diff"); - this.contentEl.append(diffEl); - } finally { - this.gettingDiff = false; - } - } - } -}; - -// src/ui/history/historyView.ts -init_polyfill_buffer(); -var import_obsidian21 = require("obsidian"); - -// src/ui/history/historyView.svelte -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/index.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/animations.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/utils.js -init_polyfill_buffer(); -function noop() { -} -var identity = (x) => x; -function run(fn) { - return fn(); -} -function blank_object() { - return /* @__PURE__ */ Object.create(null); -} -function run_all(fns) { - fns.forEach(run); -} -function is_function(thing) { - return typeof thing === "function"; -} -function safe_not_equal(a, b) { - return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function"; -} -function is_empty(obj) { - return Object.keys(obj).length === 0; -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/environment.js -init_polyfill_buffer(); -var is_client = typeof window !== "undefined"; -var now = is_client ? () => window.performance.now() : () => Date.now(); -var raf = is_client ? (cb) => requestAnimationFrame(cb) : noop; - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/loop.js -init_polyfill_buffer(); -var tasks = /* @__PURE__ */ new Set(); -function run_tasks(now2) { - tasks.forEach((task) => { - if (!task.c(now2)) { - tasks.delete(task); - task.f(); - } - }); - if (tasks.size !== 0) - raf(run_tasks); -} -function loop(callback) { - let task; - if (tasks.size === 0) - raf(run_tasks); - return { - promise: new Promise((fulfill) => { - tasks.add(task = { c: callback, f: fulfill }); - }), - abort() { - tasks.delete(task); - } - }; -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/style_manager.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/dom.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/globals.js -init_polyfill_buffer(); -var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : ( - // @ts-ignore Node typings have this - global -); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js -var ResizeObserverSingleton = class _ResizeObserverSingleton { - /** @param {ResizeObserverOptions} options */ - constructor(options) { - /** - * @private - * @readonly - * @type {WeakMap} - */ - __publicField(this, "_listeners", "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0); - /** - * @private - * @type {ResizeObserver} - */ - __publicField(this, "_observer"); - /** @type {ResizeObserverOptions} */ - __publicField(this, "options"); - this.options = options; - } - /** - * @param {Element} element - * @param {import('./private.js').Listener} listener - * @returns {() => void} - */ - observe(element2, listener) { - this._listeners.set(element2, listener); - this._getObserver().observe(element2, this.options); - return () => { - this._listeners.delete(element2); - this._observer.unobserve(element2); - }; - } - /** - * @private - */ - _getObserver() { - var _a2; - return (_a2 = this._observer) != null ? _a2 : this._observer = new ResizeObserver((entries) => { - var _a3; - for (const entry of entries) { - _ResizeObserverSingleton.entries.set(entry.target, entry); - (_a3 = this._listeners.get(entry.target)) == null ? void 0 : _a3(entry); - } - }); - } -}; -ResizeObserverSingleton.entries = "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0; - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/dom.js -var is_hydrating = false; -function start_hydrating() { - is_hydrating = true; -} -function end_hydrating() { - is_hydrating = false; -} -function append2(target, node) { - target.appendChild(node); -} -function append_styles(target, style_sheet_id, styles) { - const append_styles_to = get_root_for_style(target); - if (!append_styles_to.getElementById(style_sheet_id)) { - const style = element("style"); - style.id = style_sheet_id; - style.textContent = styles; - append_stylesheet(append_styles_to, style); - } -} -function get_root_for_style(node) { - if (!node) - return document; - const root2 = node.getRootNode ? node.getRootNode() : node.ownerDocument; - if (root2 && /** @type {ShadowRoot} */ - root2.host) { - return ( - /** @type {ShadowRoot} */ - root2 - ); - } - return node.ownerDocument; -} -function append_empty_stylesheet(node) { - const style_element = element("style"); - style_element.textContent = "/* empty */"; - append_stylesheet(get_root_for_style(node), style_element); - return style_element.sheet; -} -function append_stylesheet(node, style) { - append2( - /** @type {Document} */ - node.head || node, - style - ); - return style.sheet; -} -function insert(target, node, anchor) { - target.insertBefore(node, anchor || null); -} -function detach(node) { - if (node.parentNode) { - node.parentNode.removeChild(node); - } -} -function destroy_each(iterations, detaching) { - for (let i = 0; i < iterations.length; i += 1) { - if (iterations[i]) - iterations[i].d(detaching); - } -} -function element(name) { - return document.createElement(name); -} -function text(data) { - return document.createTextNode(data); -} -function space() { - return text(" "); -} -function empty() { - return text(""); -} -function listen(node, event, handler, options) { - node.addEventListener(event, handler, options); - return () => node.removeEventListener(event, handler, options); -} -function stop_propagation(fn) { - return function(event) { - event.stopPropagation(); - return fn.call(this, event); - }; -} -function attr(node, attribute, value) { - if (value == null) - node.removeAttribute(attribute); - else if (node.getAttribute(attribute) !== value) - node.setAttribute(attribute, value); -} -function children(element2) { - return Array.from(element2.childNodes); -} -function set_data(text2, data) { - data = "" + data; - if (text2.data === data) - return; - text2.data = /** @type {string} */ - data; -} -function set_input_value(input, value) { - input.value = value == null ? "" : value; -} -function set_style(node, key2, value, important) { - if (value == null) { - node.style.removeProperty(key2); - } else { - node.style.setProperty(key2, value, important ? "important" : ""); - } -} -function toggle_class(element2, name, toggle) { - element2.classList.toggle(name, !!toggle); -} -function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) { - return new CustomEvent(type, { detail, bubbles, cancelable }); -} -function get_custom_elements_slots(element2) { - const result = {}; - element2.childNodes.forEach( - /** @param {Element} node */ - (node) => { - result[node.slot || "default"] = true; - } - ); - return result; -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/style_manager.js -var managed_styles = /* @__PURE__ */ new Map(); -var active = 0; -function hash(str) { - let hash2 = 5381; - let i = str.length; - while (i--) - hash2 = (hash2 << 5) - hash2 ^ str.charCodeAt(i); - return hash2 >>> 0; -} -function create_style_information(doc, node) { - const info = { stylesheet: append_empty_stylesheet(node), rules: {} }; - managed_styles.set(doc, info); - return info; -} -function create_rule(node, a, b, duration, delay2, ease, fn, uid = 0) { - const step = 16.666 / duration; - let keyframes = "{\n"; - for (let p = 0; p <= 1; p += step) { - const t = a + (b - a) * ease(p); - keyframes += p * 100 + `%{${fn(t, 1 - t)}} -`; - } - const rule = keyframes + `100% {${fn(b, 1 - b)}} -}`; - const name = `__svelte_${hash(rule)}_${uid}`; - const doc = get_root_for_style(node); - const { stylesheet, rules } = managed_styles.get(doc) || create_style_information(doc, node); - if (!rules[name]) { - rules[name] = true; - stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length); - } - const animation = node.style.animation || ""; - node.style.animation = `${animation ? `${animation}, ` : ""}${name} ${duration}ms linear ${delay2}ms 1 both`; - active += 1; - return name; -} -function delete_rule(node, name) { - const previous = (node.style.animation || "").split(", "); - const next = previous.filter( - name ? (anim) => anim.indexOf(name) < 0 : (anim) => anim.indexOf("__svelte") === -1 - // remove all Svelte animations - ); - const deleted = previous.length - next.length; - if (deleted) { - node.style.animation = next.join(", "); - active -= deleted; - if (!active) - clear_rules(); - } -} -function clear_rules() { - raf(() => { - if (active) - return; - managed_styles.forEach((info) => { - const { ownerNode } = info.stylesheet; - if (ownerNode) - detach(ownerNode); - }); - managed_styles.clear(); - }); -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/await_block.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/transitions.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/scheduler.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/lifecycle.js -init_polyfill_buffer(); -var current_component; -function set_current_component(component) { - current_component = component; -} -function get_current_component() { - if (!current_component) - throw new Error("Function called outside component initialization"); - return current_component; -} -function onDestroy(fn) { - get_current_component().$$.on_destroy.push(fn); -} -function bubble(component, event) { - const callbacks = component.$$.callbacks[event.type]; - if (callbacks) { - callbacks.slice().forEach((fn) => fn.call(this, event)); - } -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/scheduler.js -var dirty_components = []; -var binding_callbacks = []; -var render_callbacks = []; -var flush_callbacks = []; -var resolved_promise = /* @__PURE__ */ Promise.resolve(); -var update_scheduled = false; -function schedule_update() { - if (!update_scheduled) { - update_scheduled = true; - resolved_promise.then(flush); - } -} -function add_render_callback(fn) { - render_callbacks.push(fn); -} -var seen_callbacks = /* @__PURE__ */ new Set(); -var flushidx = 0; -function flush() { - if (flushidx !== 0) { - return; - } - const saved_component = current_component; - do { - try { - while (flushidx < dirty_components.length) { - const component = dirty_components[flushidx]; - flushidx++; - set_current_component(component); - update(component.$$); - } - } catch (e) { - dirty_components.length = 0; - flushidx = 0; - throw e; - } - set_current_component(null); - dirty_components.length = 0; - flushidx = 0; - while (binding_callbacks.length) - binding_callbacks.pop()(); - for (let i = 0; i < render_callbacks.length; i += 1) { - const callback = render_callbacks[i]; - if (!seen_callbacks.has(callback)) { - seen_callbacks.add(callback); - callback(); - } - } - render_callbacks.length = 0; - } while (dirty_components.length); - while (flush_callbacks.length) { - flush_callbacks.pop()(); - } - update_scheduled = false; - seen_callbacks.clear(); - set_current_component(saved_component); -} -function update($$) { - if ($$.fragment !== null) { - $$.update(); - run_all($$.before_update); - const dirty = $$.dirty; - $$.dirty = [-1]; - $$.fragment && $$.fragment.p($$.ctx, dirty); - $$.after_update.forEach(add_render_callback); - } -} -function flush_render_callbacks(fns) { - const filtered = []; - const targets = []; - render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)); - targets.forEach((c) => c()); - render_callbacks = filtered; -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/transitions.js -var promise; -function wait() { - if (!promise) { - promise = Promise.resolve(); - promise.then(() => { - promise = null; - }); - } - return promise; -} -function dispatch(node, direction, kind) { - node.dispatchEvent(custom_event(`${direction ? "intro" : "outro"}${kind}`)); -} -var outroing = /* @__PURE__ */ new Set(); -var outros; -function group_outros() { - outros = { - r: 0, - c: [], - p: outros - // parent group - }; -} -function check_outros() { - if (!outros.r) { - run_all(outros.c); - } - outros = outros.p; -} -function transition_in(block, local) { - if (block && block.i) { - outroing.delete(block); - block.i(local); - } -} -function transition_out(block, local, detach2, callback) { - if (block && block.o) { - if (outroing.has(block)) - return; - outroing.add(block); - outros.c.push(() => { - outroing.delete(block); - if (callback) { - if (detach2) - block.d(1); - callback(); - } - }); - block.o(local); - } else if (callback) { - callback(); - } -} -var null_transition = { duration: 0 }; -function create_bidirectional_transition(node, fn, params, intro) { - const options = { direction: "both" }; - let config = fn(node, params, options); - let t = intro ? 0 : 1; - let running_program = null; - let pending_program = null; - let animation_name = null; - let original_inert_value; - function clear_animation() { - if (animation_name) - delete_rule(node, animation_name); - } - function init3(program, duration) { - const d = ( - /** @type {Program['d']} */ - program.b - t - ); - duration *= Math.abs(d); - return { - a: t, - b: program.b, - d, - duration, - start: program.start, - end: program.start + duration, - group: program.group - }; - } - function go(b) { - const { - delay: delay2 = 0, - duration = 300, - easing = identity, - tick: tick2 = noop, - css - } = config || null_transition; - const program = { - start: now() + delay2, - b - }; - if (!b) { - program.group = outros; - outros.r += 1; - } - if ("inert" in node) { - if (b) { - if (original_inert_value !== void 0) { - node.inert = original_inert_value; - } - } else { - original_inert_value = /** @type {HTMLElement} */ - node.inert; - node.inert = true; - } - } - if (running_program || pending_program) { - pending_program = program; - } else { - if (css) { - clear_animation(); - animation_name = create_rule(node, t, b, duration, delay2, easing, css); - } - if (b) - tick2(0, 1); - running_program = init3(program, duration); - add_render_callback(() => dispatch(node, b, "start")); - loop((now2) => { - if (pending_program && now2 > pending_program.start) { - running_program = init3(pending_program, duration); - pending_program = null; - dispatch(node, running_program.b, "start"); - if (css) { - clear_animation(); - animation_name = create_rule( - node, - t, - running_program.b, - running_program.duration, - 0, - easing, - config.css - ); - } - } - if (running_program) { - if (now2 >= running_program.end) { - tick2(t = running_program.b, 1 - t); - dispatch(node, running_program.b, "end"); - if (!pending_program) { - if (running_program.b) { - clear_animation(); - } else { - if (!--running_program.group.r) - run_all(running_program.group.c); - } - } - running_program = null; - } else if (now2 >= running_program.start) { - const p = now2 - running_program.start; - t = running_program.a + running_program.d * easing(p / running_program.duration); - tick2(t, 1 - t); - } - } - return !!(running_program || pending_program); - }); - } - } - return { - run(b) { - if (is_function(config)) { - wait().then(() => { - const opts = { direction: b ? "in" : "out" }; - config = config(opts); - go(b); - }); - } else { - go(b); - } - }, - end() { - clear_animation(); - running_program = pending_program = null; - } - }; -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/each.js -init_polyfill_buffer(); -function ensure_array_like(array_like_or_iterator) { - return (array_like_or_iterator == null ? void 0 : array_like_or_iterator.length) !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator); -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/spread.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/ssr.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/shared/boolean_attributes.js -init_polyfill_buffer(); -var _boolean_attributes = ( - /** @type {const} */ - [ - "allowfullscreen", - "allowpaymentrequest", - "async", - "autofocus", - "autoplay", - "checked", - "controls", - "default", - "defer", - "disabled", - "formnovalidate", - "hidden", - "inert", - "ismap", - "loop", - "multiple", - "muted", - "nomodule", - "novalidate", - "open", - "playsinline", - "readonly", - "required", - "reversed", - "selected" - ] -); -var boolean_attributes = /* @__PURE__ */ new Set([..._boolean_attributes]); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/shared/utils/names.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/Component.js -init_polyfill_buffer(); -function create_component(block) { - block && block.c(); -} -function mount_component(component, target, anchor) { - const { fragment, after_update } = component.$$; - fragment && fragment.m(target, anchor); - add_render_callback(() => { - const new_on_destroy = component.$$.on_mount.map(run).filter(is_function); - if (component.$$.on_destroy) { - component.$$.on_destroy.push(...new_on_destroy); - } else { - run_all(new_on_destroy); - } - component.$$.on_mount = []; - }); - after_update.forEach(add_render_callback); -} -function destroy_component(component, detaching) { - const $$ = component.$$; - if ($$.fragment !== null) { - flush_render_callbacks($$.after_update); - run_all($$.on_destroy); - $$.fragment && $$.fragment.d(detaching); - $$.on_destroy = $$.fragment = null; - $$.ctx = []; - } -} -function make_dirty(component, i) { - if (component.$$.dirty[0] === -1) { - dirty_components.push(component); - schedule_update(); - component.$$.dirty.fill(0); - } - component.$$.dirty[i / 31 | 0] |= 1 << i % 31; -} -function init2(component, options, instance10, create_fragment10, not_equal, props, append_styles2 = null, dirty = [-1]) { - const parent_component = current_component; - set_current_component(component); - const $$ = component.$$ = { - fragment: null, - ctx: [], - // state - props, - update: noop, - not_equal, - bound: blank_object(), - // lifecycle - on_mount: [], - on_destroy: [], - on_disconnect: [], - before_update: [], - after_update: [], - context: new Map(options.context || (parent_component ? parent_component.$$.context : [])), - // everything else - callbacks: blank_object(), - dirty, - skip_bound: false, - root: options.target || parent_component.$$.root - }; - append_styles2 && append_styles2($$.root); - let ready = false; - $$.ctx = instance10 ? instance10(component, options.props || {}, (i, ret, ...rest) => { - const value = rest.length ? rest[0] : ret; - if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { - if (!$$.skip_bound && $$.bound[i]) - $$.bound[i](value); - if (ready) - make_dirty(component, i); - } - return ret; - }) : []; - $$.update(); - ready = true; - run_all($$.before_update); - $$.fragment = create_fragment10 ? create_fragment10($$.ctx) : false; - if (options.target) { - if (options.hydrate) { - start_hydrating(); - const nodes = children(options.target); - $$.fragment && $$.fragment.l(nodes); - nodes.forEach(detach); - } else { - $$.fragment && $$.fragment.c(); - } - if (options.intro) - transition_in(component.$$.fragment); - mount_component(component, options.target, options.anchor); - end_hydrating(); - flush(); - } - set_current_component(parent_component); -} -var SvelteElement; -if (typeof HTMLElement === "function") { - SvelteElement = class extends HTMLElement { - constructor($$componentCtor, $$slots, use_shadow_dom) { - super(); - /** The Svelte component constructor */ - __publicField(this, "$$ctor"); - /** Slots */ - __publicField(this, "$$s"); - /** The Svelte component instance */ - __publicField(this, "$$c"); - /** Whether or not the custom element is connected */ - __publicField(this, "$$cn", false); - /** Component props data */ - __publicField(this, "$$d", {}); - /** `true` if currently in the process of reflecting component props back to attributes */ - __publicField(this, "$$r", false); - /** @type {Record} Props definition (name, reflected, type etc) */ - __publicField(this, "$$p_d", {}); - /** @type {Record} Event listeners */ - __publicField(this, "$$l", {}); - /** @type {Map} Event listener unsubscribe functions */ - __publicField(this, "$$l_u", /* @__PURE__ */ new Map()); - this.$$ctor = $$componentCtor; - this.$$s = $$slots; - if (use_shadow_dom) { - this.attachShadow({ mode: "open" }); - } - } - addEventListener(type, listener, options) { - this.$$l[type] = this.$$l[type] || []; - this.$$l[type].push(listener); - if (this.$$c) { - const unsub = this.$$c.$on(type, listener); - this.$$l_u.set(listener, unsub); - } - super.addEventListener(type, listener, options); - } - removeEventListener(type, listener, options) { - super.removeEventListener(type, listener, options); - if (this.$$c) { - const unsub = this.$$l_u.get(listener); - if (unsub) { - unsub(); - this.$$l_u.delete(listener); - } - } - } - async connectedCallback() { - this.$$cn = true; - if (!this.$$c) { - let create_slot = function(name) { - return () => { - let node; - const obj = { - c: function create() { - node = element("slot"); - if (name !== "default") { - attr(node, "name", name); - } - }, - /** - * @param {HTMLElement} target - * @param {HTMLElement} [anchor] - */ - m: function mount(target, anchor) { - insert(target, node, anchor); - }, - d: function destroy(detaching) { - if (detaching) { - detach(node); - } - } - }; - return obj; - }; - }; - await Promise.resolve(); - if (!this.$$cn) { - return; - } - const $$slots = {}; - const existing_slots = get_custom_elements_slots(this); - for (const name of this.$$s) { - if (name in existing_slots) { - $$slots[name] = [create_slot(name)]; - } - } - for (const attribute of this.attributes) { - const name = this.$$g_p(attribute.name); - if (!(name in this.$$d)) { - this.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, "toProp"); - } - } - for (const key2 in this.$$p_d) { - if (!(key2 in this.$$d) && this[key2] !== void 0) { - this.$$d[key2] = this[key2]; - delete this[key2]; - } - } - this.$$c = new this.$$ctor({ - target: this.shadowRoot || this, - props: { - ...this.$$d, - $$slots, - $$scope: { - ctx: [] - } - } - }); - const reflect_attributes = () => { - this.$$r = true; - for (const key2 in this.$$p_d) { - this.$$d[key2] = this.$$c.$$.ctx[this.$$c.$$.props[key2]]; - if (this.$$p_d[key2].reflect) { - const attribute_value = get_custom_element_value( - key2, - this.$$d[key2], - this.$$p_d, - "toAttribute" - ); - if (attribute_value == null) { - this.removeAttribute(this.$$p_d[key2].attribute || key2); - } else { - this.setAttribute(this.$$p_d[key2].attribute || key2, attribute_value); - } - } - } - this.$$r = false; - }; - this.$$c.$$.after_update.push(reflect_attributes); - reflect_attributes(); - for (const type in this.$$l) { - for (const listener of this.$$l[type]) { - const unsub = this.$$c.$on(type, listener); - this.$$l_u.set(listener, unsub); - } - } - this.$$l = {}; - } - } - // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte - // and setting attributes through setAttribute etc, this is helpful - attributeChangedCallback(attr2, _oldValue, newValue) { - var _a2; - if (this.$$r) - return; - attr2 = this.$$g_p(attr2); - this.$$d[attr2] = get_custom_element_value(attr2, newValue, this.$$p_d, "toProp"); - (_a2 = this.$$c) == null ? void 0 : _a2.$set({ [attr2]: this.$$d[attr2] }); - } - disconnectedCallback() { - this.$$cn = false; - Promise.resolve().then(() => { - if (!this.$$cn) { - this.$$c.$destroy(); - this.$$c = void 0; - } - }); - } - $$g_p(attribute_name) { - return Object.keys(this.$$p_d).find( - (key2) => this.$$p_d[key2].attribute === attribute_name || !this.$$p_d[key2].attribute && key2.toLowerCase() === attribute_name - ) || attribute_name; - } - }; -} -function get_custom_element_value(prop, value, props_definition, transform) { - var _a2; - const type = (_a2 = props_definition[prop]) == null ? void 0 : _a2.type; - value = type === "Boolean" && typeof value !== "boolean" ? value != null : value; - if (!transform || !props_definition[prop]) { - return value; - } else if (transform === "toAttribute") { - switch (type) { - case "Object": - case "Array": - return value == null ? null : JSON.stringify(value); - case "Boolean": - return value ? "" : null; - case "Number": - return value == null ? null : value; - default: - return value; - } - } else { - switch (type) { - case "Object": - case "Array": - return value && JSON.parse(value); - case "Boolean": - return value; - case "Number": - return value != null ? +value : value; - default: - return value; - } - } -} -var SvelteComponent = class { - constructor() { - /** - * ### PRIVATE API - * - * Do not use, may change at any time - * - * @type {any} - */ - __publicField(this, "$$"); - /** - * ### PRIVATE API - * - * Do not use, may change at any time - * - * @type {any} - */ - __publicField(this, "$$set"); - } - /** @returns {void} */ - $destroy() { - destroy_component(this, 1); - this.$destroy = noop; - } - /** - * @template {Extract} K - * @param {K} type - * @param {((e: Events[K]) => void) | null | undefined} callback - * @returns {() => void} - */ - $on(type, callback) { - if (!is_function(callback)) { - return noop; - } - const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []); - callbacks.push(callback); - return () => { - const index2 = callbacks.indexOf(callback); - if (index2 !== -1) - callbacks.splice(index2, 1); - }; - } - /** - * @param {Partial} props - * @returns {void} - */ - $set(props) { - if (this.$$set && !is_empty(props)) { - this.$$.skip_bound = true; - this.$$set(props); - this.$$.skip_bound = false; - } - } -}; - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/dev.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/shared/version.js -init_polyfill_buffer(); -var PUBLIC_VERSION = "4"; - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/internal/disclose-version/index.js -init_polyfill_buffer(); -if (typeof window !== "undefined") - (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION); - -// node_modules/.pnpm/tslib@2.6.2/node_modules/tslib/tslib.es6.mjs -init_polyfill_buffer(); -function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -// src/ui/history/historyView.svelte -var import_obsidian20 = require("obsidian"); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/index.js -init_polyfill_buffer(); - -// src/ui/history/components/logComponent.svelte -init_polyfill_buffer(); -var import_obsidian19 = require("obsidian"); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/transition/index.js -init_polyfill_buffer(); - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/easing/index.js -init_polyfill_buffer(); -function cubicOut(t) { - const f = t - 1; - return f * f * f + 1; -} - -// node_modules/.pnpm/svelte@4.2.10/node_modules/svelte/src/runtime/transition/index.js -function slide(node, { delay: delay2 = 0, duration = 400, easing = cubicOut, axis = "y" } = {}) { - const style = getComputedStyle(node); - const opacity = +style.opacity; - const primary_property = axis === "y" ? "height" : "width"; - const primary_property_value = parseFloat(style[primary_property]); - const secondary_properties = axis === "y" ? ["top", "bottom"] : ["left", "right"]; - const capitalized_secondary_properties = secondary_properties.map( - (e) => `${e[0].toUpperCase()}${e.slice(1)}` - ); - const padding_start_value = parseFloat(style[`padding${capitalized_secondary_properties[0]}`]); - const padding_end_value = parseFloat(style[`padding${capitalized_secondary_properties[1]}`]); - const margin_start_value = parseFloat(style[`margin${capitalized_secondary_properties[0]}`]); - const margin_end_value = parseFloat(style[`margin${capitalized_secondary_properties[1]}`]); - const border_width_start_value = parseFloat( - style[`border${capitalized_secondary_properties[0]}Width`] - ); - const border_width_end_value = parseFloat( - style[`border${capitalized_secondary_properties[1]}Width`] - ); - return { - delay: delay2, - duration, - easing, - css: (t) => `overflow: hidden;opacity: ${Math.min(t * 20, 1) * opacity};${primary_property}: ${t * primary_property_value}px;padding-${secondary_properties[0]}: ${t * padding_start_value}px;padding-${secondary_properties[1]}: ${t * padding_end_value}px;margin-${secondary_properties[0]}: ${t * margin_start_value}px;margin-${secondary_properties[1]}: ${t * margin_end_value}px;border-${secondary_properties[0]}-width: ${t * border_width_start_value}px;border-${secondary_properties[1]}-width: ${t * border_width_end_value}px;` - }; -} - -// src/ui/history/components/logFileComponent.svelte -init_polyfill_buffer(); -var import_obsidian18 = require("obsidian"); -function add_css(target) { - append_styles(target, "svelte-1wbh8tp", "main.svelte-1wbh8tp .nav-file-title.svelte-1wbh8tp{align-items:center}"); -} -function create_if_block(ctx) { - let div; - let mounted; - let dispose; - return { - c() { - div = element("div"); - attr(div, "data-icon", "go-to-file"); - attr(div, "aria-label", "Open File"); - attr(div, "class", "clickable-icon"); - }, - m(target, anchor) { - insert(target, div, anchor); - ctx[7](div); - if (!mounted) { - dispose = [ - listen(div, "auxclick", stop_propagation( - /*open*/ - ctx[4] - )), - listen(div, "click", stop_propagation( - /*open*/ - ctx[4] - )) - ]; - mounted = true; - } - }, - p: noop, - d(detaching) { - if (detaching) { - detach(div); - } - ctx[7](null); - mounted = false; - run_all(dispose); - } - }; -} -function create_fragment(ctx) { - let main; - let div3; - let div0; - let t0_value = getDisplayPath( - /*diff*/ - ctx[0].vault_path - ) + ""; - let t0; - let t1; - let div2; - let div1; - let show_if = ( - /*view*/ - ctx[1].app.vault.getAbstractFileByPath( - /*diff*/ - ctx[0].vault_path - ) - ); - let t2; - let span; - let t3_value = ( - /*diff*/ - ctx[0].status + "" - ); - let t3; - let span_data_type_value; - let div3_data_path_value; - let div3_aria_label_value; - let mounted; - let dispose; - let if_block = show_if && create_if_block(ctx); - return { - c() { - var _a2, _b; - main = element("main"); - div3 = element("div"); - div0 = element("div"); - t0 = text(t0_value); - t1 = space(); - div2 = element("div"); - div1 = element("div"); - if (if_block) - if_block.c(); - t2 = space(); - span = element("span"); - t3 = text(t3_value); - attr(div0, "class", "tree-item-inner nav-file-title-content"); - attr(div1, "class", "buttons"); - attr(span, "class", "type"); - attr(span, "data-type", span_data_type_value = /*diff*/ - ctx[0].status); - attr(div2, "class", "git-tools"); - attr(div3, "class", "tree-item-self is-clickable nav-file-title svelte-1wbh8tp"); - attr(div3, "data-path", div3_data_path_value = /*diff*/ - ctx[0].vault_path); - attr( - div3, - "data-tooltip-position", - /*side*/ - ctx[3] - ); - attr(div3, "aria-label", div3_aria_label_value = /*diff*/ - ctx[0].vault_path); - toggle_class( - div3, - "is-active", - /*view*/ - ((_a2 = ctx[1].plugin.lastDiffViewState) == null ? void 0 : _a2.file) == /*diff*/ - ctx[0].vault_path && /*view*/ - ((_b = ctx[1].plugin.lastDiffViewState) == null ? void 0 : _b.hash) - ); - attr(main, "class", "tree-item nav-file svelte-1wbh8tp"); - }, - m(target, anchor) { - insert(target, main, anchor); - append2(main, div3); - append2(div3, div0); - append2(div0, t0); - append2(div3, t1); - append2(div3, div2); - append2(div2, div1); - if (if_block) - if_block.m(div1, null); - append2(div2, t2); - append2(div2, span); - append2(span, t3); - if (!mounted) { - dispose = [ - listen(main, "click", stop_propagation( - /*showDiff*/ - ctx[5] - )), - listen(main, "auxclick", stop_propagation( - /*showDiff*/ - ctx[5] - )), - listen( - main, - "focus", - /*focus_handler*/ - ctx[6] - ) - ]; - mounted = true; - } - }, - p(ctx2, [dirty]) { - var _a2, _b; - if (dirty & /*diff*/ - 1 && t0_value !== (t0_value = getDisplayPath( - /*diff*/ - ctx2[0].vault_path - ) + "")) - set_data(t0, t0_value); - if (dirty & /*view, diff*/ - 3) - show_if = /*view*/ - ctx2[1].app.vault.getAbstractFileByPath( - /*diff*/ - ctx2[0].vault_path - ); - if (show_if) { - if (if_block) { - if_block.p(ctx2, dirty); - } else { - if_block = create_if_block(ctx2); - if_block.c(); - if_block.m(div1, null); - } - } else if (if_block) { - if_block.d(1); - if_block = null; - } - if (dirty & /*diff*/ - 1 && t3_value !== (t3_value = /*diff*/ - ctx2[0].status + "")) - set_data(t3, t3_value); - if (dirty & /*diff*/ - 1 && span_data_type_value !== (span_data_type_value = /*diff*/ - ctx2[0].status)) { - attr(span, "data-type", span_data_type_value); - } - if (dirty & /*diff*/ - 1 && div3_data_path_value !== (div3_data_path_value = /*diff*/ - ctx2[0].vault_path)) { - attr(div3, "data-path", div3_data_path_value); - } - if (dirty & /*side*/ - 8) { - attr( - div3, - "data-tooltip-position", - /*side*/ - ctx2[3] - ); - } - if (dirty & /*diff*/ - 1 && div3_aria_label_value !== (div3_aria_label_value = /*diff*/ - ctx2[0].vault_path)) { - attr(div3, "aria-label", div3_aria_label_value); - } - if (dirty & /*view, diff*/ - 3) { - toggle_class( - div3, - "is-active", - /*view*/ - ((_a2 = ctx2[1].plugin.lastDiffViewState) == null ? void 0 : _a2.file) == /*diff*/ - ctx2[0].vault_path && /*view*/ - ((_b = ctx2[1].plugin.lastDiffViewState) == null ? void 0 : _b.hash) - ); - } - }, - i: noop, - o: noop, - d(detaching) { - if (detaching) { - detach(main); - } - if (if_block) - if_block.d(); - mounted = false; - run_all(dispose); - } - }; -} -function instance($$self, $$props, $$invalidate) { - let side; - let { diff: diff3 } = $$props; - let { view } = $$props; - let buttons = []; - window.setTimeout(() => buttons.forEach((b) => (0, import_obsidian18.setIcon)(b, b.getAttr("data-icon"))), 0); - function open(event) { - var _a2; - const file = view.app.vault.getAbstractFileByPath(diff3.vault_path); - if (file instanceof import_obsidian18.TFile) { - (_a2 = getNewLeaf(event)) === null || _a2 === void 0 ? void 0 : _a2.openFile(file); - } - } - function showDiff(event) { - var _a2; - (_a2 = getNewLeaf(event)) === null || _a2 === void 0 ? void 0 : _a2.setViewState({ - type: DIFF_VIEW_CONFIG.type, - active: true, - state: { - file: diff3.path, - staged: false, - hash: diff3.hash - } - }); - } - function focus_handler(event) { - bubble.call(this, $$self, event); - } - function div_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[0] = $$value; - $$invalidate(2, buttons); - }); - } - $$self.$$set = ($$props2) => { - if ("diff" in $$props2) - $$invalidate(0, diff3 = $$props2.diff); - if ("view" in $$props2) - $$invalidate(1, view = $$props2.view); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty & /*view*/ - 2) { - $: - $$invalidate(3, side = view.leaf.getRoot().side == "left" ? "right" : "left"); - } - }; - return [diff3, view, buttons, side, open, showDiff, focus_handler, div_binding]; -} -var LogFileComponent = class extends SvelteComponent { - constructor(options) { - super(); - init2(this, options, instance, create_fragment, safe_not_equal, { diff: 0, view: 1 }, add_css); - } -}; -var logFileComponent_default = LogFileComponent; - -// src/ui/history/components/logTreeComponent.svelte -init_polyfill_buffer(); -function add_css2(target) { - append_styles(target, "svelte-1lnl15d", "main.svelte-1lnl15d .nav-folder-title-content.svelte-1lnl15d{display:flex;align-items:center}"); -} -function get_each_context(ctx, list, i) { - const child_ctx = ctx.slice(); - child_ctx[8] = list[i]; - return child_ctx; -} -function create_else_block(ctx) { - let div4; - let div3; - let div0; - let t0; - let div1; - let t1; - let div2; - let t2_value = ( - /*entity*/ - ctx[8].title + "" - ); - let t2; - let div3_aria_label_value; - let t3; - let t4; - let current; - let mounted; - let dispose; - function click_handler() { - return ( - /*click_handler*/ - ctx[7]( - /*entity*/ - ctx[8] - ) - ); - } - let if_block = !/*closed*/ - ctx[4][ - /*entity*/ - ctx[8].title - ] && create_if_block_1(ctx); - return { - c() { - div4 = element("div"); - div3 = element("div"); - div0 = element("div"); - t0 = space(); - div1 = element("div"); - div1.innerHTML = ``; - t1 = space(); - div2 = element("div"); - t2 = text(t2_value); - t3 = space(); - if (if_block) - if_block.c(); - t4 = space(); - attr(div0, "data-icon", "folder"); - set_style(div0, "padding-right", "5px"); - set_style(div0, "display", "flex"); - attr(div1, "class", "tree-item-icon nav-folder-collapse-indicator collapse-icon"); - toggle_class( - div1, - "is-collapsed", - /*closed*/ - ctx[4][ - /*entity*/ - ctx[8].title - ] - ); - attr(div2, "class", "tree-item-inner nav-folder-title-content svelte-1lnl15d"); - attr(div3, "class", "tree-item-self is-clickable nav-folder-title"); - attr( - div3, - "data-tooltip-position", - /*side*/ - ctx[5] - ); - attr(div3, "aria-label", div3_aria_label_value = /*entity*/ - ctx[8].vaultPath); - attr(div4, "class", "tree-item nav-folder"); - toggle_class( - div4, - "is-collapsed", - /*closed*/ - ctx[4][ - /*entity*/ - ctx[8].title - ] - ); - }, - m(target, anchor) { - insert(target, div4, anchor); - append2(div4, div3); - append2(div3, div0); - append2(div3, t0); - append2(div3, div1); - append2(div3, t1); - append2(div3, div2); - append2(div2, t2); - append2(div4, t3); - if (if_block) - if_block.m(div4, null); - append2(div4, t4); - current = true; - if (!mounted) { - dispose = listen(div3, "click", click_handler); - mounted = true; - } - }, - p(new_ctx, dirty) { - ctx = new_ctx; - if (!current || dirty & /*closed, hierarchy*/ - 17) { - toggle_class( - div1, - "is-collapsed", - /*closed*/ - ctx[4][ - /*entity*/ - ctx[8].title - ] - ); - } - if ((!current || dirty & /*hierarchy*/ - 1) && t2_value !== (t2_value = /*entity*/ - ctx[8].title + "")) - set_data(t2, t2_value); - if (!current || dirty & /*side*/ - 32) { - attr( - div3, - "data-tooltip-position", - /*side*/ - ctx[5] - ); - } - if (!current || dirty & /*hierarchy*/ - 1 && div3_aria_label_value !== (div3_aria_label_value = /*entity*/ - ctx[8].vaultPath)) { - attr(div3, "aria-label", div3_aria_label_value); - } - if (!/*closed*/ - ctx[4][ - /*entity*/ - ctx[8].title - ]) { - if (if_block) { - if_block.p(ctx, dirty); - if (dirty & /*closed, hierarchy*/ - 17) { - transition_in(if_block, 1); - } - } else { - if_block = create_if_block_1(ctx); - if_block.c(); - transition_in(if_block, 1); - if_block.m(div4, t4); - } - } else if (if_block) { - group_outros(); - transition_out(if_block, 1, 1, () => { - if_block = null; - }); - check_outros(); - } - if (!current || dirty & /*closed, hierarchy*/ - 17) { - toggle_class( - div4, - "is-collapsed", - /*closed*/ - ctx[4][ - /*entity*/ - ctx[8].title - ] - ); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - current = true; - }, - o(local) { - transition_out(if_block); - current = false; - }, - d(detaching) { - if (detaching) { - detach(div4); - } - if (if_block) - if_block.d(); - mounted = false; - dispose(); - } - }; -} -function create_if_block2(ctx) { - let div; - let logfilecomponent; - let t; - let current; - logfilecomponent = new logFileComponent_default({ - props: { - diff: ( - /*entity*/ - ctx[8].data - ), - view: ( - /*view*/ - ctx[2] - ) - } - }); - return { - c() { - div = element("div"); - create_component(logfilecomponent.$$.fragment); - t = space(); - }, - m(target, anchor) { - insert(target, div, anchor); - mount_component(logfilecomponent, div, null); - append2(div, t); - current = true; - }, - p(ctx2, dirty) { - const logfilecomponent_changes = {}; - if (dirty & /*hierarchy*/ - 1) - logfilecomponent_changes.diff = /*entity*/ - ctx2[8].data; - if (dirty & /*view*/ - 4) - logfilecomponent_changes.view = /*view*/ - ctx2[2]; - logfilecomponent.$set(logfilecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(logfilecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(logfilecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - if (detaching) { - detach(div); - } - destroy_component(logfilecomponent); - } - }; -} -function create_if_block_1(ctx) { - let div; - let logtreecomponent; - let div_transition; - let current; - logtreecomponent = new LogTreeComponent({ - props: { - hierarchy: ( - /*entity*/ - ctx[8] - ), - plugin: ( - /*plugin*/ - ctx[1] - ), - view: ( - /*view*/ - ctx[2] - ) - } - }); - return { - c() { - div = element("div"); - create_component(logtreecomponent.$$.fragment); - attr(div, "class", "tree-item-children nav-folder-children"); - }, - m(target, anchor) { - insert(target, div, anchor); - mount_component(logtreecomponent, div, null); - current = true; - }, - p(ctx2, dirty) { - const logtreecomponent_changes = {}; - if (dirty & /*hierarchy*/ - 1) - logtreecomponent_changes.hierarchy = /*entity*/ - ctx2[8]; - if (dirty & /*plugin*/ - 2) - logtreecomponent_changes.plugin = /*plugin*/ - ctx2[1]; - if (dirty & /*view*/ - 4) - logtreecomponent_changes.view = /*view*/ - ctx2[2]; - logtreecomponent.$set(logtreecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(logtreecomponent.$$.fragment, local); - if (local) { - add_render_callback(() => { - if (!current) - return; - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, true); - div_transition.run(1); - }); - } - current = true; - }, - o(local) { - transition_out(logtreecomponent.$$.fragment, local); - if (local) { - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, false); - div_transition.run(0); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(div); - } - destroy_component(logtreecomponent); - if (detaching && div_transition) - div_transition.end(); - } - }; -} -function create_each_block(ctx) { - let current_block_type_index; - let if_block; - let if_block_anchor; - let current; - const if_block_creators = [create_if_block2, create_else_block]; - const if_blocks = []; - function select_block_type(ctx2, dirty) { - if ( - /*entity*/ - ctx2[8].data - ) - return 0; - return 1; - } - current_block_type_index = select_block_type(ctx, -1); - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - return { - c() { - if_block.c(); - if_block_anchor = empty(); - }, - m(target, anchor) { - if_blocks[current_block_type_index].m(target, anchor); - insert(target, if_block_anchor, anchor); - current = true; - }, - p(ctx2, dirty) { - let previous_block_index = current_block_type_index; - current_block_type_index = select_block_type(ctx2, dirty); - if (current_block_type_index === previous_block_index) { - if_blocks[current_block_type_index].p(ctx2, dirty); - } else { - group_outros(); - transition_out(if_blocks[previous_block_index], 1, 1, () => { - if_blocks[previous_block_index] = null; - }); - check_outros(); - if_block = if_blocks[current_block_type_index]; - if (!if_block) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); - if_block.c(); - } else { - if_block.p(ctx2, dirty); - } - transition_in(if_block, 1); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - current = true; - }, - o(local) { - transition_out(if_block); - current = false; - }, - d(detaching) { - if (detaching) { - detach(if_block_anchor); - } - if_blocks[current_block_type_index].d(detaching); - } - }; -} -function create_fragment2(ctx) { - let main; - let current; - let each_value = ensure_array_like( - /*hierarchy*/ - ctx[0].children - ); - let each_blocks = []; - for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); - } - const out = (i) => transition_out(each_blocks[i], 1, 1, () => { - each_blocks[i] = null; - }); - return { - c() { - main = element("main"); - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - attr(main, "class", "svelte-1lnl15d"); - toggle_class( - main, - "topLevel", - /*topLevel*/ - ctx[3] - ); - }, - m(target, anchor) { - insert(target, main, anchor); - for (let i = 0; i < each_blocks.length; i += 1) { - if (each_blocks[i]) { - each_blocks[i].m(main, null); - } - } - current = true; - }, - p(ctx2, [dirty]) { - if (dirty & /*hierarchy, view, closed, plugin, side, fold*/ - 119) { - each_value = ensure_array_like( - /*hierarchy*/ - ctx2[0].children - ); - let i; - for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context(ctx2, each_value, i); - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - transition_in(each_blocks[i], 1); - } else { - each_blocks[i] = create_each_block(child_ctx); - each_blocks[i].c(); - transition_in(each_blocks[i], 1); - each_blocks[i].m(main, null); - } - } - group_outros(); - for (i = each_value.length; i < each_blocks.length; i += 1) { - out(i); - } - check_outros(); - } - if (!current || dirty & /*topLevel*/ - 8) { - toggle_class( - main, - "topLevel", - /*topLevel*/ - ctx2[3] - ); - } - }, - i(local) { - if (current) - return; - for (let i = 0; i < each_value.length; i += 1) { - transition_in(each_blocks[i]); - } - current = true; - }, - o(local) { - each_blocks = each_blocks.filter(Boolean); - for (let i = 0; i < each_blocks.length; i += 1) { - transition_out(each_blocks[i]); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(main); - } - destroy_each(each_blocks, detaching); - } - }; -} -function instance2($$self, $$props, $$invalidate) { - let side; - let { hierarchy } = $$props; - let { plugin } = $$props; - let { view } = $$props; - let { topLevel = false } = $$props; - const closed = {}; - function fold(item) { - $$invalidate(4, closed[item.title] = !closed[item.title], closed); - } - const click_handler = (entity) => fold(entity); - $$self.$$set = ($$props2) => { - if ("hierarchy" in $$props2) - $$invalidate(0, hierarchy = $$props2.hierarchy); - if ("plugin" in $$props2) - $$invalidate(1, plugin = $$props2.plugin); - if ("view" in $$props2) - $$invalidate(2, view = $$props2.view); - if ("topLevel" in $$props2) - $$invalidate(3, topLevel = $$props2.topLevel); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty & /*view*/ - 4) { - $: - $$invalidate(5, side = view.leaf.getRoot().side == "left" ? "right" : "left"); - } - }; - return [hierarchy, plugin, view, topLevel, closed, side, fold, click_handler]; -} -var LogTreeComponent = class extends SvelteComponent { - constructor(options) { - super(); - init2( - this, - options, - instance2, - create_fragment2, - safe_not_equal, - { - hierarchy: 0, - plugin: 1, - view: 2, - topLevel: 3 - }, - add_css2 - ); - } -}; -var logTreeComponent_default = LogTreeComponent; - -// src/ui/history/components/logComponent.svelte -function get_each_context2(ctx, list, i) { - const child_ctx = ctx.slice(); - child_ctx[9] = list[i]; - return child_ctx; -} -function create_if_block_4(ctx) { - let div; - let t_value = ( - /*log*/ - ctx[0].refs.join(", ") + "" - ); - let t; - return { - c() { - div = element("div"); - t = text(t_value); - attr(div, "class", "git-ref"); - }, - m(target, anchor) { - insert(target, div, anchor); - append2(div, t); - }, - p(ctx2, dirty) { - if (dirty & /*log*/ - 1 && t_value !== (t_value = /*log*/ - ctx2[0].refs.join(", ") + "")) - set_data(t, t_value); - }, - d(detaching) { - if (detaching) { - detach(div); - } - } - }; -} -function create_if_block_3(ctx) { - let div; - let t_value = ( - /*authorToString*/ - ctx[7]( - /*log*/ - ctx[0] - ) + "" - ); - let t; - return { - c() { - div = element("div"); - t = text(t_value); - attr(div, "class", "git-author"); - }, - m(target, anchor) { - insert(target, div, anchor); - append2(div, t); - }, - p(ctx2, dirty) { - if (dirty & /*log*/ - 1 && t_value !== (t_value = /*authorToString*/ - ctx2[7]( - /*log*/ - ctx2[0] - ) + "")) - set_data(t, t_value); - }, - d(detaching) { - if (detaching) { - detach(div); - } - } - }; -} -function create_if_block_2(ctx) { - let div; - let t_value = (0, import_obsidian19.moment)( - /*log*/ - ctx[0].date - ).format( - /*plugin*/ - ctx[3].settings.commitDateFormat - ) + ""; - let t; - return { - c() { - div = element("div"); - t = text(t_value); - attr(div, "class", "git-date"); - }, - m(target, anchor) { - insert(target, div, anchor); - append2(div, t); - }, - p(ctx2, dirty) { - if (dirty & /*log, plugin*/ - 9 && t_value !== (t_value = (0, import_obsidian19.moment)( - /*log*/ - ctx2[0].date - ).format( - /*plugin*/ - ctx2[3].settings.commitDateFormat - ) + "")) - set_data(t, t_value); - }, - d(detaching) { - if (detaching) { - detach(div); - } - } - }; -} -function create_if_block3(ctx) { - let div; - let current_block_type_index; - let if_block; - let div_transition; - let current; - const if_block_creators = [create_if_block_12, create_else_block2]; - const if_blocks = []; - function select_block_type(ctx2, dirty) { - if ( - /*showTree*/ - ctx2[2] - ) - return 0; - return 1; - } - current_block_type_index = select_block_type(ctx, -1); - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - return { - c() { - div = element("div"); - if_block.c(); - attr(div, "class", "tree-item-children nav-folder-children"); - }, - m(target, anchor) { - insert(target, div, anchor); - if_blocks[current_block_type_index].m(div, null); - current = true; - }, - p(ctx2, dirty) { - let previous_block_index = current_block_type_index; - current_block_type_index = select_block_type(ctx2, dirty); - if (current_block_type_index === previous_block_index) { - if_blocks[current_block_type_index].p(ctx2, dirty); - } else { - group_outros(); - transition_out(if_blocks[previous_block_index], 1, 1, () => { - if_blocks[previous_block_index] = null; - }); - check_outros(); - if_block = if_blocks[current_block_type_index]; - if (!if_block) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); - if_block.c(); - } else { - if_block.p(ctx2, dirty); - } - transition_in(if_block, 1); - if_block.m(div, null); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - if (local) { - add_render_callback(() => { - if (!current) - return; - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, true); - div_transition.run(1); - }); - } - current = true; - }, - o(local) { - transition_out(if_block); - if (local) { - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, false); - div_transition.run(0); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(div); - } - if_blocks[current_block_type_index].d(); - if (detaching && div_transition) - div_transition.end(); - } - }; -} -function create_else_block2(ctx) { - let each_1_anchor; - let current; - let each_value = ensure_array_like( - /*log*/ - ctx[0].diff.files - ); - let each_blocks = []; - for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block2(get_each_context2(ctx, each_value, i)); - } - const out = (i) => transition_out(each_blocks[i], 1, 1, () => { - each_blocks[i] = null; - }); - return { - c() { - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - each_1_anchor = empty(); - }, - m(target, anchor) { - for (let i = 0; i < each_blocks.length; i += 1) { - if (each_blocks[i]) { - each_blocks[i].m(target, anchor); - } - } - insert(target, each_1_anchor, anchor); - current = true; - }, - p(ctx2, dirty) { - if (dirty & /*view, log*/ - 3) { - each_value = ensure_array_like( - /*log*/ - ctx2[0].diff.files - ); - let i; - for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context2(ctx2, each_value, i); - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - transition_in(each_blocks[i], 1); - } else { - each_blocks[i] = create_each_block2(child_ctx); - each_blocks[i].c(); - transition_in(each_blocks[i], 1); - each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); - } - } - group_outros(); - for (i = each_value.length; i < each_blocks.length; i += 1) { - out(i); - } - check_outros(); - } - }, - i(local) { - if (current) - return; - for (let i = 0; i < each_value.length; i += 1) { - transition_in(each_blocks[i]); - } - current = true; - }, - o(local) { - each_blocks = each_blocks.filter(Boolean); - for (let i = 0; i < each_blocks.length; i += 1) { - transition_out(each_blocks[i]); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(each_1_anchor); - } - destroy_each(each_blocks, detaching); - } - }; -} -function create_if_block_12(ctx) { - let logtreecomponent; - let current; - logtreecomponent = new logTreeComponent_default({ - props: { - hierarchy: ( - /*logsHierarchy*/ - ctx[6] - ), - plugin: ( - /*plugin*/ - ctx[3] - ), - view: ( - /*view*/ - ctx[1] - ), - topLevel: true - } - }); - return { - c() { - create_component(logtreecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(logtreecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const logtreecomponent_changes = {}; - if (dirty & /*logsHierarchy*/ - 64) - logtreecomponent_changes.hierarchy = /*logsHierarchy*/ - ctx2[6]; - if (dirty & /*plugin*/ - 8) - logtreecomponent_changes.plugin = /*plugin*/ - ctx2[3]; - if (dirty & /*view*/ - 2) - logtreecomponent_changes.view = /*view*/ - ctx2[1]; - logtreecomponent.$set(logtreecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(logtreecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(logtreecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(logtreecomponent, detaching); - } - }; -} -function create_each_block2(ctx) { - let logfilecomponent; - let current; - logfilecomponent = new logFileComponent_default({ - props: { - view: ( - /*view*/ - ctx[1] - ), - diff: ( - /*file*/ - ctx[9] - ) - } - }); - return { - c() { - create_component(logfilecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(logfilecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const logfilecomponent_changes = {}; - if (dirty & /*view*/ - 2) - logfilecomponent_changes.view = /*view*/ - ctx2[1]; - if (dirty & /*log*/ - 1) - logfilecomponent_changes.diff = /*file*/ - ctx2[9]; - logfilecomponent.$set(logfilecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(logfilecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(logfilecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(logfilecomponent, detaching); - } - }; -} -function create_fragment3(ctx) { - var _a2; - let main; - let div4; - let div3; - let div0; - let t0; - let div2; - let t1; - let t2; - let t3; - let div1; - let t4_value = ( - /*log*/ - ctx[0].message + "" - ); - let t4; - let div3_aria_label_value; - let t5; - let current; - let mounted; - let dispose; - let if_block0 = ( - /*log*/ - ctx[0].refs.length > 0 && create_if_block_4(ctx) - ); - let if_block1 = ( - /*plugin*/ - ctx[3].settings.authorInHistoryView != "hide" && /*log*/ - ((_a2 = ctx[0].author) == null ? void 0 : _a2.name) && create_if_block_3(ctx) - ); - let if_block2 = ( - /*plugin*/ - ctx[3].settings.dateInHistoryView && create_if_block_2(ctx) - ); - let if_block3 = !/*isCollapsed*/ - ctx[4] && create_if_block3(ctx); - return { - c() { - var _a3; - main = element("main"); - div4 = element("div"); - div3 = element("div"); - div0 = element("div"); - div0.innerHTML = ``; - t0 = space(); - div2 = element("div"); - if (if_block0) - if_block0.c(); - t1 = space(); - if (if_block1) - if_block1.c(); - t2 = space(); - if (if_block2) - if_block2.c(); - t3 = space(); - div1 = element("div"); - t4 = text(t4_value); - t5 = space(); - if (if_block3) - if_block3.c(); - attr(div0, "class", "tree-item-icon nav-folder-collapse-indicator collapse-icon"); - toggle_class( - div0, - "is-collapsed", - /*isCollapsed*/ - ctx[4] - ); - attr(div1, "class", "tree-item-inner nav-folder-title-content"); - attr(div3, "class", "tree-item-self is-clickable nav-folder-title"); - attr(div3, "aria-label", div3_aria_label_value = `${/*log*/ - ctx[0].refs.length > 0 ? ( - /*log*/ - ctx[0].refs.join(", ") + "\n" - ) : ""}${/*log*/ - (_a3 = ctx[0].author) == null ? void 0 : _a3.name} -${(0, import_obsidian19.moment)( - /*log*/ - ctx[0].date - ).format( - /*plugin*/ - ctx[3].settings.commitDateFormat - )} -${/*log*/ - ctx[0].message}`); - attr( - div3, - "data-tooltip-position", - /*side*/ - ctx[5] - ); - attr(div4, "class", "tree-item nav-folder"); - toggle_class( - div4, - "is-collapsed", - /*isCollapsed*/ - ctx[4] - ); - }, - m(target, anchor) { - insert(target, main, anchor); - append2(main, div4); - append2(div4, div3); - append2(div3, div0); - append2(div3, t0); - append2(div3, div2); - if (if_block0) - if_block0.m(div2, null); - append2(div2, t1); - if (if_block1) - if_block1.m(div2, null); - append2(div2, t2); - if (if_block2) - if_block2.m(div2, null); - append2(div2, t3); - append2(div2, div1); - append2(div1, t4); - append2(div4, t5); - if (if_block3) - if_block3.m(div4, null); - current = true; - if (!mounted) { - dispose = listen( - div3, - "click", - /*click_handler*/ - ctx[8] - ); - mounted = true; - } - }, - p(ctx2, [dirty]) { - var _a3, _b; - if (!current || dirty & /*isCollapsed*/ - 16) { - toggle_class( - div0, - "is-collapsed", - /*isCollapsed*/ - ctx2[4] - ); - } - if ( - /*log*/ - ctx2[0].refs.length > 0 - ) { - if (if_block0) { - if_block0.p(ctx2, dirty); - } else { - if_block0 = create_if_block_4(ctx2); - if_block0.c(); - if_block0.m(div2, t1); - } - } else if (if_block0) { - if_block0.d(1); - if_block0 = null; - } - if ( - /*plugin*/ - ctx2[3].settings.authorInHistoryView != "hide" && /*log*/ - ((_a3 = ctx2[0].author) == null ? void 0 : _a3.name) - ) { - if (if_block1) { - if_block1.p(ctx2, dirty); - } else { - if_block1 = create_if_block_3(ctx2); - if_block1.c(); - if_block1.m(div2, t2); - } - } else if (if_block1) { - if_block1.d(1); - if_block1 = null; - } - if ( - /*plugin*/ - ctx2[3].settings.dateInHistoryView - ) { - if (if_block2) { - if_block2.p(ctx2, dirty); - } else { - if_block2 = create_if_block_2(ctx2); - if_block2.c(); - if_block2.m(div2, t3); - } - } else if (if_block2) { - if_block2.d(1); - if_block2 = null; - } - if ((!current || dirty & /*log*/ - 1) && t4_value !== (t4_value = /*log*/ - ctx2[0].message + "")) - set_data(t4, t4_value); - if (!current || dirty & /*log, plugin*/ - 9 && div3_aria_label_value !== (div3_aria_label_value = `${/*log*/ - ctx2[0].refs.length > 0 ? ( - /*log*/ - ctx2[0].refs.join(", ") + "\n" - ) : ""}${/*log*/ - (_b = ctx2[0].author) == null ? void 0 : _b.name} -${(0, import_obsidian19.moment)( - /*log*/ - ctx2[0].date - ).format( - /*plugin*/ - ctx2[3].settings.commitDateFormat - )} -${/*log*/ - ctx2[0].message}`)) { - attr(div3, "aria-label", div3_aria_label_value); - } - if (!current || dirty & /*side*/ - 32) { - attr( - div3, - "data-tooltip-position", - /*side*/ - ctx2[5] - ); - } - if (!/*isCollapsed*/ - ctx2[4]) { - if (if_block3) { - if_block3.p(ctx2, dirty); - if (dirty & /*isCollapsed*/ - 16) { - transition_in(if_block3, 1); - } - } else { - if_block3 = create_if_block3(ctx2); - if_block3.c(); - transition_in(if_block3, 1); - if_block3.m(div4, null); - } - } else if (if_block3) { - group_outros(); - transition_out(if_block3, 1, 1, () => { - if_block3 = null; - }); - check_outros(); - } - if (!current || dirty & /*isCollapsed*/ - 16) { - toggle_class( - div4, - "is-collapsed", - /*isCollapsed*/ - ctx2[4] - ); - } - }, - i(local) { - if (current) - return; - transition_in(if_block3); - current = true; - }, - o(local) { - transition_out(if_block3); - current = false; - }, - d(detaching) { - if (detaching) { - detach(main); - } - if (if_block0) - if_block0.d(); - if (if_block1) - if_block1.d(); - if (if_block2) - if_block2.d(); - if (if_block3) - if_block3.d(); - mounted = false; - dispose(); - } - }; -} -function instance3($$self, $$props, $$invalidate) { - let logsHierarchy; - let side; - let { log: log2 } = $$props; - let { view } = $$props; - let { showTree } = $$props; - let { plugin } = $$props; - let isCollapsed = true; - function authorToString(log3) { - const name = log3.author.name; - if (plugin.settings.authorInHistoryView == "full") { - return name; - } else if (plugin.settings.authorInHistoryView == "initials") { - const words = name.split(" ").filter((word) => word.length > 0); - return words.map((word) => word[0].toUpperCase()).join(""); - } - } - const click_handler = () => $$invalidate(4, isCollapsed = !isCollapsed); - $$self.$$set = ($$props2) => { - if ("log" in $$props2) - $$invalidate(0, log2 = $$props2.log); - if ("view" in $$props2) - $$invalidate(1, view = $$props2.view); - if ("showTree" in $$props2) - $$invalidate(2, showTree = $$props2.showTree); - if ("plugin" in $$props2) - $$invalidate(3, plugin = $$props2.plugin); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty & /*plugin, log*/ - 9) { - $: - $$invalidate(6, logsHierarchy = { - title: "", - path: "", - vaultPath: "", - children: plugin.gitManager.getTreeStructure(log2.diff.files) - }); - } - if ($$self.$$.dirty & /*view*/ - 2) { - $: - $$invalidate(5, side = view.leaf.getRoot().side == "left" ? "right" : "left"); - } - }; - return [ - log2, - view, - showTree, - plugin, - isCollapsed, - side, - logsHierarchy, - authorToString, - click_handler - ]; -} -var LogComponent = class extends SvelteComponent { - constructor(options) { - super(); - init2(this, options, instance3, create_fragment3, safe_not_equal, { log: 0, view: 1, showTree: 2, plugin: 3 }); - } -}; -var logComponent_default = LogComponent; - -// src/ui/history/historyView.svelte -function get_each_context3(ctx, list, i) { - const child_ctx = ctx.slice(); - child_ctx[11] = list[i]; - return child_ctx; -} -function create_if_block4(ctx) { - let div1; - let div0; - let current; - let each_value = ensure_array_like( - /*logs*/ - ctx[6] - ); - let each_blocks = []; - for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block3(get_each_context3(ctx, each_value, i)); - } - const out = (i) => transition_out(each_blocks[i], 1, 1, () => { - each_blocks[i] = null; - }); - return { - c() { - div1 = element("div"); - div0 = element("div"); - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - attr(div0, "class", "tree-item-children nav-folder-children"); - attr(div1, "class", "tree-item nav-folder mod-root"); - }, - m(target, anchor) { - insert(target, div1, anchor); - append2(div1, div0); - for (let i = 0; i < each_blocks.length; i += 1) { - if (each_blocks[i]) { - each_blocks[i].m(div0, null); - } - } - current = true; - }, - p(ctx2, dirty) { - if (dirty & /*view, showTree, logs, plugin*/ - 71) { - each_value = ensure_array_like( - /*logs*/ - ctx2[6] - ); - let i; - for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context3(ctx2, each_value, i); - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - transition_in(each_blocks[i], 1); - } else { - each_blocks[i] = create_each_block3(child_ctx); - each_blocks[i].c(); - transition_in(each_blocks[i], 1); - each_blocks[i].m(div0, null); - } - } - group_outros(); - for (i = each_value.length; i < each_blocks.length; i += 1) { - out(i); - } - check_outros(); - } - }, - i(local) { - if (current) - return; - for (let i = 0; i < each_value.length; i += 1) { - transition_in(each_blocks[i]); - } - current = true; - }, - o(local) { - each_blocks = each_blocks.filter(Boolean); - for (let i = 0; i < each_blocks.length; i += 1) { - transition_out(each_blocks[i]); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(div1); - } - destroy_each(each_blocks, detaching); - } - }; -} -function create_each_block3(ctx) { - let logcomponent; - let current; - logcomponent = new logComponent_default({ - props: { - view: ( - /*view*/ - ctx[1] - ), - showTree: ( - /*showTree*/ - ctx[2] - ), - log: ( - /*log*/ - ctx[11] - ), - plugin: ( - /*plugin*/ - ctx[0] - ) - } - }); - return { - c() { - create_component(logcomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(logcomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const logcomponent_changes = {}; - if (dirty & /*view*/ - 2) - logcomponent_changes.view = /*view*/ - ctx2[1]; - if (dirty & /*showTree*/ - 4) - logcomponent_changes.showTree = /*showTree*/ - ctx2[2]; - if (dirty & /*logs*/ - 64) - logcomponent_changes.log = /*log*/ - ctx2[11]; - if (dirty & /*plugin*/ - 1) - logcomponent_changes.plugin = /*plugin*/ - ctx2[0]; - logcomponent.$set(logcomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(logcomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(logcomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(logcomponent, detaching); - } - }; -} -function create_fragment4(ctx) { - let main; - let div3; - let div2; - let div0; - let t0; - let div1; - let t1; - let div4; - let current; - let mounted; - let dispose; - let if_block = ( - /*logs*/ - ctx[6] && create_if_block4(ctx) - ); - return { - c() { - main = element("main"); - div3 = element("div"); - div2 = element("div"); - div0 = element("div"); - t0 = space(); - div1 = element("div"); - t1 = space(); - div4 = element("div"); - if (if_block) - if_block.c(); - attr(div0, "id", "layoutChange"); - attr(div0, "class", "clickable-icon nav-action-button"); - attr(div0, "aria-label", "Change Layout"); - attr(div1, "id", "refresh"); - attr(div1, "class", "clickable-icon nav-action-button"); - attr(div1, "data-icon", "refresh-cw"); - attr(div1, "aria-label", "Refresh"); - set_style(div1, "margin", "1px"); - toggle_class( - div1, - "loading", - /*loading*/ - ctx[4] - ); - attr(div2, "class", "nav-buttons-container"); - attr(div3, "class", "nav-header"); - attr(div4, "class", "nav-files-container"); - set_style(div4, "position", "relative"); - }, - m(target, anchor) { - insert(target, main, anchor); - append2(main, div3); - append2(div3, div2); - append2(div2, div0); - ctx[7](div0); - append2(div2, t0); - append2(div2, div1); - ctx[9](div1); - append2(main, t1); - append2(main, div4); - if (if_block) - if_block.m(div4, null); - current = true; - if (!mounted) { - dispose = [ - listen( - div0, - "click", - /*click_handler*/ - ctx[8] - ), - listen(div1, "click", triggerRefresh) - ]; - mounted = true; - } - }, - p(ctx2, [dirty]) { - if (!current || dirty & /*loading*/ - 16) { - toggle_class( - div1, - "loading", - /*loading*/ - ctx2[4] - ); - } - if ( - /*logs*/ - ctx2[6] - ) { - if (if_block) { - if_block.p(ctx2, dirty); - if (dirty & /*logs*/ - 64) { - transition_in(if_block, 1); - } - } else { - if_block = create_if_block4(ctx2); - if_block.c(); - transition_in(if_block, 1); - if_block.m(div4, null); - } - } else if (if_block) { - group_outros(); - transition_out(if_block, 1, 1, () => { - if_block = null; - }); - check_outros(); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - current = true; - }, - o(local) { - transition_out(if_block); - current = false; - }, - d(detaching) { - if (detaching) { - detach(main); - } - ctx[7](null); - ctx[9](null); - if (if_block) - if_block.d(); - mounted = false; - run_all(dispose); - } - }; -} -function triggerRefresh() { - dispatchEvent(new CustomEvent("git-refresh")); -} -function instance4($$self, $$props, $$invalidate) { - let { plugin } = $$props; - let { view } = $$props; - let loading; - let buttons = []; - let logs; - let showTree = plugin.settings.treeStructure; - let layoutBtn; - addEventListener("git-view-refresh", refresh); - plugin.app.workspace.onLayoutReady(() => { - window.setTimeout( - () => { - buttons.forEach((btn) => (0, import_obsidian20.setIcon)(btn, btn.getAttr("data-icon"))); - (0, import_obsidian20.setIcon)(layoutBtn, showTree ? "list" : "folder"); - }, - 0 - ); - }); - onDestroy(() => { - removeEventListener("git-view-refresh", refresh); - }); - function refresh() { - return __awaiter(this, void 0, void 0, function* () { - $$invalidate(4, loading = true); - const isSimpleGit = plugin.gitManager instanceof SimpleGit; - $$invalidate(6, logs = yield plugin.gitManager.log(void 0, false, isSimpleGit ? 50 : 10)); - $$invalidate(4, loading = false); - }); - } - function div0_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - layoutBtn = $$value; - $$invalidate(3, layoutBtn); - }); - } - const click_handler = () => { - $$invalidate(2, showTree = !showTree); - $$invalidate(0, plugin.settings.treeStructure = showTree, plugin); - plugin.saveSettings(); - }; - function div1_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[6] = $$value; - $$invalidate(5, buttons); - }); - } - $$self.$$set = ($$props2) => { - if ("plugin" in $$props2) - $$invalidate(0, plugin = $$props2.plugin); - if ("view" in $$props2) - $$invalidate(1, view = $$props2.view); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty & /*layoutBtn, showTree*/ - 12) { - $: { - if (layoutBtn) { - layoutBtn.empty(); - (0, import_obsidian20.setIcon)(layoutBtn, showTree ? "list" : "folder"); - } - } - } - }; - return [ - plugin, - view, - showTree, - layoutBtn, - loading, - buttons, - logs, - div0_binding, - click_handler, - div1_binding - ]; -} -var HistoryView = class extends SvelteComponent { - constructor(options) { - super(); - init2(this, options, instance4, create_fragment4, safe_not_equal, { plugin: 0, view: 1 }); - } -}; -var historyView_default = HistoryView; - -// src/ui/history/historyView.ts -var HistoryView2 = class extends import_obsidian21.ItemView { - constructor(leaf, plugin) { - super(leaf); - this.plugin = plugin; - this.hoverPopover = null; - } - getViewType() { - return HISTORY_VIEW_CONFIG.type; - } - getDisplayText() { - return HISTORY_VIEW_CONFIG.name; - } - getIcon() { - return HISTORY_VIEW_CONFIG.icon; - } - onClose() { - return super.onClose(); - } - onOpen() { - this._view = new historyView_default({ - target: this.contentEl, - props: { - plugin: this.plugin, - view: this - } - }); - return super.onOpen(); - } -}; - -// src/ui/modals/branchModal.ts -init_polyfill_buffer(); -var import_obsidian22 = require("obsidian"); -var BranchModal = class extends import_obsidian22.FuzzySuggestModal { - constructor(branches) { - super(app); - this.branches = branches; - this.setPlaceholder("Select branch to checkout"); - } - getItems() { - return this.branches; - } - getItemText(item) { - return item; - } - onChooseItem(item, evt) { - this.resolve(item); - } - open() { - super.open(); - return new Promise((resolve) => { - this.resolve = resolve; - }); - } - async onClose() { - await new Promise((resolve) => setTimeout(resolve, 10)); - if (this.resolve) - this.resolve(void 0); - } -}; - -// src/ui/modals/ignoreModal.ts -init_polyfill_buffer(); -var import_obsidian23 = require("obsidian"); -var IgnoreModal = class extends import_obsidian23.Modal { - constructor(app2, content) { - super(app2); - this.content = content; - this.resolve = null; - } - open() { - super.open(); - return new Promise((resolve) => { - this.resolve = resolve; - }); - } - onOpen() { - const { contentEl, titleEl } = this; - titleEl.setText("Edit .gitignore"); - const div = contentEl.createDiv(); - const text2 = div.createEl("textarea", { - text: this.content, - cls: ["obsidian-git-textarea"], - attr: { rows: 10, cols: 30, wrap: "off" } - }); - div.createEl("button", { - cls: ["mod-cta", "obsidian-git-center-button"], - text: "Save" - }).addEventListener("click", async () => { - this.resolve(text2.value); - this.close(); - }); - } - onClose() { - const { contentEl } = this; - this.resolve(void 0); - contentEl.empty(); - } -}; - -// src/ui/sourceControl/sourceControl.ts -init_polyfill_buffer(); -var import_obsidian30 = require("obsidian"); - -// src/ui/sourceControl/sourceControl.svelte -init_polyfill_buffer(); -var import_obsidian29 = require("obsidian"); - -// src/ui/modals/discardModal.ts -init_polyfill_buffer(); -var import_obsidian24 = require("obsidian"); -var DiscardModal = class extends import_obsidian24.Modal { - constructor(app2, deletion, filename) { - super(app2); - this.deletion = deletion; - this.filename = filename; - this.resolve = null; - } - myOpen() { - this.open(); - return new Promise((resolve) => { - this.resolve = resolve; - }); - } - onOpen() { - const { contentEl, titleEl } = this; - titleEl.setText(`${this.deletion ? "Delete" : "Discard"} this file?`); - contentEl.createEl("p").setText( - `Do you really want to ${this.deletion ? "delete" : "discard the changes of"} "${this.filename}"` - ); - const div = contentEl.createDiv({ cls: "modal-button-container" }); - const discard = div.createEl("button", { - cls: "mod-warning", - text: this.deletion ? "Delete" : "Discard" - }); - discard.addEventListener("click", async () => { - if (this.resolve) - this.resolve(true); - this.close(); - }); - discard.addEventListener("keypress", async () => { - if (this.resolve) - this.resolve(true); - this.close(); - }); - const close = div.createEl("button", { - text: "Cancel" - }); - close.addEventListener("click", () => { - if (this.resolve) - this.resolve(false); - return this.close(); - }); - close.addEventListener("keypress", () => { - if (this.resolve) - this.resolve(false); - return this.close(); - }); - } - onClose() { - const { contentEl } = this; - contentEl.empty(); - } -}; - -// src/ui/sourceControl/components/fileComponent.svelte -init_polyfill_buffer(); -var import_obsidian26 = require("obsidian"); - -// node_modules/.pnpm/github.com+Vinzent03+obsidian-community-lib@e663de4f95c879b40613090da78ea599ff621d24_@codemir_xyncsguozhhawq25qkwtwp76my/node_modules/obsidian-community-lib/dist/index.js -init_polyfill_buffer(); - -// node_modules/.pnpm/github.com+Vinzent03+obsidian-community-lib@e663de4f95c879b40613090da78ea599ff621d24_@codemir_xyncsguozhhawq25qkwtwp76my/node_modules/obsidian-community-lib/dist/utils.js -init_polyfill_buffer(); -var feather = __toESM(require_feather()); -var import_obsidian25 = require("obsidian"); -function hoverPreview(event, view, to) { - const targetEl = event.target; - app.workspace.trigger("hover-link", { - event, - source: view.getViewType(), - hoverParent: view, - targetEl, - linktext: to - }); -} - -// src/ui/sourceControl/components/fileComponent.svelte -function add_css3(target) { - append_styles(target, "svelte-1wbh8tp", "main.svelte-1wbh8tp .nav-file-title.svelte-1wbh8tp{align-items:center}"); -} -function create_if_block5(ctx) { - let div; - let mounted; - let dispose; - return { - c() { - div = element("div"); - attr(div, "data-icon", "go-to-file"); - attr(div, "aria-label", "Open File"); - attr(div, "class", "clickable-icon"); - }, - m(target, anchor) { - insert(target, div, anchor); - ctx[11](div); - if (!mounted) { - dispose = [ - listen(div, "auxclick", stop_propagation( - /*open*/ - ctx[5] - )), - listen(div, "click", stop_propagation( - /*open*/ - ctx[5] - )) - ]; - mounted = true; - } - }, - p: noop, - d(detaching) { - if (detaching) { - detach(div); - } - ctx[11](null); - mounted = false; - run_all(dispose); - } - }; -} -function create_fragment5(ctx) { - let main; - let div6; - let div0; - let t0_value = getDisplayPath( - /*change*/ - ctx[0].vault_path - ) + ""; - let t0; - let t1; - let div5; - let div3; - let show_if = ( - /*view*/ - ctx[1].app.vault.getAbstractFileByPath( - /*change*/ - ctx[0].vault_path - ) - ); - let t2; - let div1; - let t3; - let div2; - let t4; - let div4; - let t5_value = ( - /*change*/ - ctx[0].working_dir + "" - ); - let t5; - let div4_data_type_value; - let div6_data_path_value; - let div6_aria_label_value; - let mounted; - let dispose; - let if_block = show_if && create_if_block5(ctx); - return { - c() { - var _a2, _b, _c; - main = element("main"); - div6 = element("div"); - div0 = element("div"); - t0 = text(t0_value); - t1 = space(); - div5 = element("div"); - div3 = element("div"); - if (if_block) - if_block.c(); - t2 = space(); - div1 = element("div"); - t3 = space(); - div2 = element("div"); - t4 = space(); - div4 = element("div"); - t5 = text(t5_value); - attr(div0, "class", "tree-item-inner nav-file-title-content"); - attr(div1, "data-icon", "undo"); - attr(div1, "aria-label", "Discard"); - attr(div1, "class", "clickable-icon"); - attr(div2, "data-icon", "plus"); - attr(div2, "aria-label", "Stage"); - attr(div2, "class", "clickable-icon"); - attr(div3, "class", "buttons"); - attr(div4, "class", "type"); - attr(div4, "data-type", div4_data_type_value = /*change*/ - ctx[0].working_dir); - attr(div5, "class", "git-tools"); - attr(div6, "class", "tree-item-self is-clickable nav-file-title svelte-1wbh8tp"); - attr(div6, "data-path", div6_data_path_value = /*change*/ - ctx[0].vault_path); - attr( - div6, - "data-tooltip-position", - /*side*/ - ctx[3] - ); - attr(div6, "aria-label", div6_aria_label_value = /*change*/ - ctx[0].vault_path); - toggle_class( - div6, - "is-active", - /*view*/ - ((_a2 = ctx[1].plugin.lastDiffViewState) == null ? void 0 : _a2.file) == /*change*/ - ctx[0].vault_path && !/*view*/ - ((_b = ctx[1].plugin.lastDiffViewState) == null ? void 0 : _b.hash) && !/*view*/ - ((_c = ctx[1].plugin.lastDiffViewState) == null ? void 0 : _c.staged) - ); - attr(main, "class", "tree-item nav-file svelte-1wbh8tp"); - }, - m(target, anchor) { - insert(target, main, anchor); - append2(main, div6); - append2(div6, div0); - append2(div0, t0); - append2(div6, t1); - append2(div6, div5); - append2(div5, div3); - if (if_block) - if_block.m(div3, null); - append2(div3, t2); - append2(div3, div1); - ctx[12](div1); - append2(div3, t3); - append2(div3, div2); - ctx[13](div2); - append2(div5, t4); - append2(div5, div4); - append2(div4, t5); - if (!mounted) { - dispose = [ - listen(div1, "click", stop_propagation( - /*discard*/ - ctx[8] - )), - listen(div2, "click", stop_propagation( - /*stage*/ - ctx[6] - )), - listen( - main, - "mouseover", - /*hover*/ - ctx[4] - ), - listen(main, "click", stop_propagation( - /*showDiff*/ - ctx[7] - )), - listen(main, "auxclick", stop_propagation( - /*showDiff*/ - ctx[7] - )), - listen( - main, - "focus", - /*focus_handler*/ - ctx[10] - ) - ]; - mounted = true; - } - }, - p(ctx2, [dirty]) { - var _a2, _b, _c; - if (dirty & /*change*/ - 1 && t0_value !== (t0_value = getDisplayPath( - /*change*/ - ctx2[0].vault_path - ) + "")) - set_data(t0, t0_value); - if (dirty & /*view, change*/ - 3) - show_if = /*view*/ - ctx2[1].app.vault.getAbstractFileByPath( - /*change*/ - ctx2[0].vault_path - ); - if (show_if) { - if (if_block) { - if_block.p(ctx2, dirty); - } else { - if_block = create_if_block5(ctx2); - if_block.c(); - if_block.m(div3, t2); - } - } else if (if_block) { - if_block.d(1); - if_block = null; - } - if (dirty & /*change*/ - 1 && t5_value !== (t5_value = /*change*/ - ctx2[0].working_dir + "")) - set_data(t5, t5_value); - if (dirty & /*change*/ - 1 && div4_data_type_value !== (div4_data_type_value = /*change*/ - ctx2[0].working_dir)) { - attr(div4, "data-type", div4_data_type_value); - } - if (dirty & /*change*/ - 1 && div6_data_path_value !== (div6_data_path_value = /*change*/ - ctx2[0].vault_path)) { - attr(div6, "data-path", div6_data_path_value); - } - if (dirty & /*side*/ - 8) { - attr( - div6, - "data-tooltip-position", - /*side*/ - ctx2[3] - ); - } - if (dirty & /*change*/ - 1 && div6_aria_label_value !== (div6_aria_label_value = /*change*/ - ctx2[0].vault_path)) { - attr(div6, "aria-label", div6_aria_label_value); - } - if (dirty & /*view, change*/ - 3) { - toggle_class( - div6, - "is-active", - /*view*/ - ((_a2 = ctx2[1].plugin.lastDiffViewState) == null ? void 0 : _a2.file) == /*change*/ - ctx2[0].vault_path && !/*view*/ - ((_b = ctx2[1].plugin.lastDiffViewState) == null ? void 0 : _b.hash) && !/*view*/ - ((_c = ctx2[1].plugin.lastDiffViewState) == null ? void 0 : _c.staged) - ); - } - }, - i: noop, - o: noop, - d(detaching) { - if (detaching) { - detach(main); - } - if (if_block) - if_block.d(); - ctx[12](null); - ctx[13](null); - mounted = false; - run_all(dispose); - } - }; -} -function instance5($$self, $$props, $$invalidate) { - let side; - let { change } = $$props; - let { view } = $$props; - let { manager } = $$props; - let buttons = []; - window.setTimeout(() => buttons.forEach((b) => (0, import_obsidian26.setIcon)(b, b.getAttr("data-icon"))), 0); - function hover(event) { - if (app.vault.getAbstractFileByPath(change.vault_path)) { - hoverPreview(event, view, change.vault_path); - } - } - function open(event) { - var _a2; - const file = view.app.vault.getAbstractFileByPath(change.vault_path); - console.log(event); - if (file instanceof import_obsidian26.TFile) { - (_a2 = getNewLeaf(event)) === null || _a2 === void 0 ? void 0 : _a2.openFile(file); - } - } - function stage() { - manager.stage(change.path, false).finally(() => { - dispatchEvent(new CustomEvent("git-refresh")); - }); - } - function showDiff(event) { - var _a2; - (_a2 = getNewLeaf(event)) === null || _a2 === void 0 ? void 0 : _a2.setViewState({ - type: DIFF_VIEW_CONFIG.type, - active: true, - state: { file: change.path, staged: false } - }); - } - function discard() { - const deleteFile = change.working_dir == "U"; - new DiscardModal(view.app, deleteFile, change.vault_path).myOpen().then((shouldDiscard) => { - if (shouldDiscard === true) { - if (deleteFile) { - view.app.vault.adapter.remove(change.vault_path).finally(() => { - dispatchEvent(new CustomEvent("git-refresh")); - }); - } else { - manager.discard(change.path).finally(() => { - dispatchEvent(new CustomEvent("git-refresh")); - }); - } - } - }); - } - function focus_handler(event) { - bubble.call(this, $$self, event); - } - function div_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[1] = $$value; - $$invalidate(2, buttons); - }); - } - function div1_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[0] = $$value; - $$invalidate(2, buttons); - }); - } - function div2_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[2] = $$value; - $$invalidate(2, buttons); - }); - } - $$self.$$set = ($$props2) => { - if ("change" in $$props2) - $$invalidate(0, change = $$props2.change); - if ("view" in $$props2) - $$invalidate(1, view = $$props2.view); - if ("manager" in $$props2) - $$invalidate(9, manager = $$props2.manager); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty & /*view*/ - 2) { - $: - $$invalidate(3, side = view.leaf.getRoot().side == "left" ? "right" : "left"); - } - }; - return [ - change, - view, - buttons, - side, - hover, - open, - stage, - showDiff, - discard, - manager, - focus_handler, - div_binding, - div1_binding, - div2_binding - ]; -} -var FileComponent = class extends SvelteComponent { - constructor(options) { - super(); - init2(this, options, instance5, create_fragment5, safe_not_equal, { change: 0, view: 1, manager: 9 }, add_css3); - } -}; -var fileComponent_default = FileComponent; - -// src/ui/sourceControl/components/pulledFileComponent.svelte -init_polyfill_buffer(); -var import_obsidian27 = require("obsidian"); -function add_css4(target) { - append_styles(target, "svelte-1wbh8tp", "main.svelte-1wbh8tp .nav-file-title.svelte-1wbh8tp{align-items:center}"); -} -function create_fragment6(ctx) { - let main; - let div2; - let div0; - let t0_value = getDisplayPath( - /*change*/ - ctx[0].vault_path - ) + ""; - let t0; - let t1; - let div1; - let span; - let t2_value = ( - /*change*/ - ctx[0].working_dir + "" - ); - let t2; - let span_data_type_value; - let div2_data_path_value; - let div2_aria_label_value; - let mounted; - let dispose; - return { - c() { - main = element("main"); - div2 = element("div"); - div0 = element("div"); - t0 = text(t0_value); - t1 = space(); - div1 = element("div"); - span = element("span"); - t2 = text(t2_value); - attr(div0, "class", "tree-item-inner nav-file-title-content"); - attr(span, "class", "type"); - attr(span, "data-type", span_data_type_value = /*change*/ - ctx[0].working_dir); - attr(div1, "class", "git-tools"); - attr(div2, "class", "tree-item-self is-clickable nav-file-title svelte-1wbh8tp"); - attr(div2, "data-path", div2_data_path_value = /*change*/ - ctx[0].vault_path); - attr( - div2, - "data-tooltip-position", - /*side*/ - ctx[1] - ); - attr(div2, "aria-label", div2_aria_label_value = /*change*/ - ctx[0].vault_path); - attr(main, "class", "tree-item nav-file svelte-1wbh8tp"); - }, - m(target, anchor) { - insert(target, main, anchor); - append2(main, div2); - append2(div2, div0); - append2(div0, t0); - append2(div2, t1); - append2(div2, div1); - append2(div1, span); - append2(span, t2); - if (!mounted) { - dispose = [ - listen( - main, - "mouseover", - /*hover*/ - ctx[2] - ), - listen(main, "click", stop_propagation( - /*open*/ - ctx[3] - )), - listen(main, "auxclick", stop_propagation( - /*open*/ - ctx[3] - )), - listen( - main, - "focus", - /*focus_handler*/ - ctx[5] - ) - ]; - mounted = true; - } - }, - p(ctx2, [dirty]) { - if (dirty & /*change*/ - 1 && t0_value !== (t0_value = getDisplayPath( - /*change*/ - ctx2[0].vault_path - ) + "")) - set_data(t0, t0_value); - if (dirty & /*change*/ - 1 && t2_value !== (t2_value = /*change*/ - ctx2[0].working_dir + "")) - set_data(t2, t2_value); - if (dirty & /*change*/ - 1 && span_data_type_value !== (span_data_type_value = /*change*/ - ctx2[0].working_dir)) { - attr(span, "data-type", span_data_type_value); - } - if (dirty & /*change*/ - 1 && div2_data_path_value !== (div2_data_path_value = /*change*/ - ctx2[0].vault_path)) { - attr(div2, "data-path", div2_data_path_value); - } - if (dirty & /*side*/ - 2) { - attr( - div2, - "data-tooltip-position", - /*side*/ - ctx2[1] - ); - } - if (dirty & /*change*/ - 1 && div2_aria_label_value !== (div2_aria_label_value = /*change*/ - ctx2[0].vault_path)) { - attr(div2, "aria-label", div2_aria_label_value); - } - }, - i: noop, - o: noop, - d(detaching) { - if (detaching) { - detach(main); - } - mounted = false; - run_all(dispose); - } - }; -} -function instance6($$self, $$props, $$invalidate) { - let side; - let { change } = $$props; - let { view } = $$props; - function hover(event) { - if (app.vault.getAbstractFileByPath(change.vault_path)) { - hoverPreview(event, view, change.vault_path); - } - } - function open(event) { - var _a2; - const file = view.app.vault.getAbstractFileByPath(change.vault_path); - if (file instanceof import_obsidian27.TFile) { - (_a2 = getNewLeaf(event)) === null || _a2 === void 0 ? void 0 : _a2.openFile(file); - } - } - function focus_handler(event) { - bubble.call(this, $$self, event); - } - $$self.$$set = ($$props2) => { - if ("change" in $$props2) - $$invalidate(0, change = $$props2.change); - if ("view" in $$props2) - $$invalidate(4, view = $$props2.view); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty & /*view*/ - 16) { - $: - $$invalidate(1, side = view.leaf.getRoot().side == "left" ? "right" : "left"); - } - }; - return [change, side, hover, open, view, focus_handler]; -} -var PulledFileComponent = class extends SvelteComponent { - constructor(options) { - super(); - init2(this, options, instance6, create_fragment6, safe_not_equal, { change: 0, view: 4 }, add_css4); - } -}; -var pulledFileComponent_default = PulledFileComponent; - -// src/ui/sourceControl/components/stagedFileComponent.svelte -init_polyfill_buffer(); -var import_obsidian28 = require("obsidian"); -function add_css5(target) { - append_styles(target, "svelte-1wbh8tp", "main.svelte-1wbh8tp .nav-file-title.svelte-1wbh8tp{align-items:center}"); -} -function create_if_block6(ctx) { - let div; - let mounted; - let dispose; - return { - c() { - div = element("div"); - attr(div, "data-icon", "go-to-file"); - attr(div, "aria-label", "Open File"); - attr(div, "class", "clickable-icon"); - }, - m(target, anchor) { - insert(target, div, anchor); - ctx[10](div); - if (!mounted) { - dispose = listen(div, "click", stop_propagation( - /*open*/ - ctx[5] - )); - mounted = true; - } - }, - p: noop, - d(detaching) { - if (detaching) { - detach(div); - } - ctx[10](null); - mounted = false; - dispose(); - } - }; -} -function create_fragment7(ctx) { - let main; - let div5; - let div0; - let t0_value = getDisplayPath( - /*change*/ - ctx[0].vault_path - ) + ""; - let t0; - let t1; - let div4; - let div2; - let show_if = ( - /*view*/ - ctx[1].app.vault.getAbstractFileByPath( - /*change*/ - ctx[0].vault_path - ) - ); - let t2; - let div1; - let t3; - let div3; - let t4_value = ( - /*change*/ - ctx[0].index + "" - ); - let t4; - let div3_data_type_value; - let div5_data_path_value; - let div5_aria_label_value; - let mounted; - let dispose; - let if_block = show_if && create_if_block6(ctx); - return { - c() { - var _a2, _b, _c; - main = element("main"); - div5 = element("div"); - div0 = element("div"); - t0 = text(t0_value); - t1 = space(); - div4 = element("div"); - div2 = element("div"); - if (if_block) - if_block.c(); - t2 = space(); - div1 = element("div"); - t3 = space(); - div3 = element("div"); - t4 = text(t4_value); - attr(div0, "class", "tree-item-inner nav-file-title-content"); - attr(div1, "data-icon", "minus"); - attr(div1, "aria-label", "Unstage"); - attr(div1, "class", "clickable-icon"); - attr(div2, "class", "buttons"); - attr(div3, "class", "type"); - attr(div3, "data-type", div3_data_type_value = /*change*/ - ctx[0].index); - attr(div4, "class", "git-tools"); - attr(div5, "class", "tree-item-self is-clickable nav-file-title svelte-1wbh8tp"); - attr(div5, "data-path", div5_data_path_value = /*change*/ - ctx[0].vault_path); - attr( - div5, - "data-tooltip-position", - /*side*/ - ctx[3] - ); - attr(div5, "aria-label", div5_aria_label_value = /*change*/ - ctx[0].vault_path); - toggle_class( - div5, - "is-active", - /*view*/ - ((_a2 = ctx[1].plugin.lastDiffViewState) == null ? void 0 : _a2.file) == /*change*/ - ctx[0].vault_path && !/*view*/ - ((_b = ctx[1].plugin.lastDiffViewState) == null ? void 0 : _b.hash) && /*view*/ - ((_c = ctx[1].plugin.lastDiffViewState) == null ? void 0 : _c.staged) - ); - attr(main, "class", "tree-item nav-file svelte-1wbh8tp"); - }, - m(target, anchor) { - insert(target, main, anchor); - append2(main, div5); - append2(div5, div0); - append2(div0, t0); - append2(div5, t1); - append2(div5, div4); - append2(div4, div2); - if (if_block) - if_block.m(div2, null); - append2(div2, t2); - append2(div2, div1); - ctx[11](div1); - append2(div4, t3); - append2(div4, div3); - append2(div3, t4); - if (!mounted) { - dispose = [ - listen(div1, "click", stop_propagation( - /*unstage*/ - ctx[7] - )), - listen( - main, - "mouseover", - /*hover*/ - ctx[4] - ), - listen( - main, - "focus", - /*focus_handler*/ - ctx[9] - ), - listen(main, "click", stop_propagation( - /*showDiff*/ - ctx[6] - )), - listen(main, "auxclick", stop_propagation( - /*showDiff*/ - ctx[6] - )) - ]; - mounted = true; - } - }, - p(ctx2, [dirty]) { - var _a2, _b, _c; - if (dirty & /*change*/ - 1 && t0_value !== (t0_value = getDisplayPath( - /*change*/ - ctx2[0].vault_path - ) + "")) - set_data(t0, t0_value); - if (dirty & /*view, change*/ - 3) - show_if = /*view*/ - ctx2[1].app.vault.getAbstractFileByPath( - /*change*/ - ctx2[0].vault_path - ); - if (show_if) { - if (if_block) { - if_block.p(ctx2, dirty); - } else { - if_block = create_if_block6(ctx2); - if_block.c(); - if_block.m(div2, t2); - } - } else if (if_block) { - if_block.d(1); - if_block = null; - } - if (dirty & /*change*/ - 1 && t4_value !== (t4_value = /*change*/ - ctx2[0].index + "")) - set_data(t4, t4_value); - if (dirty & /*change*/ - 1 && div3_data_type_value !== (div3_data_type_value = /*change*/ - ctx2[0].index)) { - attr(div3, "data-type", div3_data_type_value); - } - if (dirty & /*change*/ - 1 && div5_data_path_value !== (div5_data_path_value = /*change*/ - ctx2[0].vault_path)) { - attr(div5, "data-path", div5_data_path_value); - } - if (dirty & /*side*/ - 8) { - attr( - div5, - "data-tooltip-position", - /*side*/ - ctx2[3] - ); - } - if (dirty & /*change*/ - 1 && div5_aria_label_value !== (div5_aria_label_value = /*change*/ - ctx2[0].vault_path)) { - attr(div5, "aria-label", div5_aria_label_value); - } - if (dirty & /*view, change*/ - 3) { - toggle_class( - div5, - "is-active", - /*view*/ - ((_a2 = ctx2[1].plugin.lastDiffViewState) == null ? void 0 : _a2.file) == /*change*/ - ctx2[0].vault_path && !/*view*/ - ((_b = ctx2[1].plugin.lastDiffViewState) == null ? void 0 : _b.hash) && /*view*/ - ((_c = ctx2[1].plugin.lastDiffViewState) == null ? void 0 : _c.staged) - ); - } - }, - i: noop, - o: noop, - d(detaching) { - if (detaching) { - detach(main); - } - if (if_block) - if_block.d(); - ctx[11](null); - mounted = false; - run_all(dispose); - } - }; -} -function instance7($$self, $$props, $$invalidate) { - let side; - let { change } = $$props; - let { view } = $$props; - let { manager } = $$props; - let buttons = []; - window.setTimeout(() => buttons.forEach((b) => (0, import_obsidian28.setIcon)(b, b.getAttr("data-icon"))), 0); - function hover(event) { - if (app.vault.getAbstractFileByPath(change.vault_path)) { - hoverPreview(event, view, change.vault_path); - } - } - function open(event) { - var _a2; - const file = view.app.vault.getAbstractFileByPath(change.vault_path); - if (file instanceof import_obsidian28.TFile) { - (_a2 = getNewLeaf(event)) === null || _a2 === void 0 ? void 0 : _a2.openFile(file); - } - } - function showDiff(event) { - var _a2; - (_a2 = getNewLeaf(event)) === null || _a2 === void 0 ? void 0 : _a2.setViewState({ - type: DIFF_VIEW_CONFIG.type, - active: true, - state: { file: change.path, staged: true } - }); - } - function unstage() { - manager.unstage(change.path, false).finally(() => { - dispatchEvent(new CustomEvent("git-refresh")); - }); - } - function focus_handler(event) { - bubble.call(this, $$self, event); - } - function div_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[1] = $$value; - $$invalidate(2, buttons); - }); - } - function div1_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[0] = $$value; - $$invalidate(2, buttons); - }); - } - $$self.$$set = ($$props2) => { - if ("change" in $$props2) - $$invalidate(0, change = $$props2.change); - if ("view" in $$props2) - $$invalidate(1, view = $$props2.view); - if ("manager" in $$props2) - $$invalidate(8, manager = $$props2.manager); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty & /*view*/ - 2) { - $: - $$invalidate(3, side = view.leaf.getRoot().side == "left" ? "right" : "left"); - } - }; - return [ - change, - view, - buttons, - side, - hover, - open, - showDiff, - unstage, - manager, - focus_handler, - div_binding, - div1_binding - ]; -} -var StagedFileComponent = class extends SvelteComponent { - constructor(options) { - super(); - init2(this, options, instance7, create_fragment7, safe_not_equal, { change: 0, view: 1, manager: 8 }, add_css5); - } -}; -var stagedFileComponent_default = StagedFileComponent; - -// src/ui/sourceControl/components/treeComponent.svelte -init_polyfill_buffer(); -function add_css6(target) { - append_styles(target, "svelte-hup5mn", "main.svelte-hup5mn .nav-folder-title.svelte-hup5mn{align-items:center}"); -} -function get_each_context4(ctx, list, i) { - const child_ctx = ctx.slice(); - child_ctx[15] = list[i]; - return child_ctx; -} -function create_else_block3(ctx) { - let div7; - let div6; - let div0; - let t0; - let div1; - let t1; - let div2; - let t2_value = ( - /*entity*/ - ctx[15].title + "" - ); - let t2; - let t3; - let div5; - let div4; - let t4; - let div3; - let div6_aria_label_value; - let t5; - let t6; - let current; - let mounted; - let dispose; - function select_block_type_2(ctx2, dirty) { - if ( - /*fileType*/ - ctx2[3] == 0 /* staged */ - ) - return create_if_block_5; - return create_else_block_1; - } - let current_block_type = select_block_type_2(ctx, -1); - let if_block0 = current_block_type(ctx); - let if_block1 = !/*closed*/ - ctx[5][ - /*entity*/ - ctx[15].title - ] && create_if_block_42(ctx); - function click_handler_3() { - return ( - /*click_handler_3*/ - ctx[14]( - /*entity*/ - ctx[15] - ) - ); - } - return { - c() { - div7 = element("div"); - div6 = element("div"); - div0 = element("div"); - t0 = space(); - div1 = element("div"); - div1.innerHTML = ``; - t1 = space(); - div2 = element("div"); - t2 = text(t2_value); - t3 = space(); - div5 = element("div"); - div4 = element("div"); - if_block0.c(); - t4 = space(); - div3 = element("div"); - t5 = space(); - if (if_block1) - if_block1.c(); - t6 = space(); - attr(div0, "data-icon", "folder"); - set_style(div0, "padding-right", "5px"); - set_style(div0, "display", "flex"); - attr(div1, "class", "tree-item-icon nav-folder-collapse-indicator collapse-icon"); - toggle_class( - div1, - "is-collapsed", - /*closed*/ - ctx[5][ - /*entity*/ - ctx[15].title - ] - ); - attr(div2, "class", "tree-item-inner nav-folder-title-content"); - set_style(div3, "width", "11px"); - attr(div4, "class", "buttons"); - attr(div5, "class", "git-tools"); - attr(div6, "class", "tree-item-self is-clickable nav-folder-title svelte-hup5mn"); - attr( - div6, - "data-tooltip-position", - /*side*/ - ctx[6] - ); - attr(div6, "aria-label", div6_aria_label_value = /*entity*/ - ctx[15].vaultPath); - attr(div7, "class", "tree-item nav-folder"); - toggle_class( - div7, - "is-collapsed", - /*closed*/ - ctx[5][ - /*entity*/ - ctx[15].title - ] - ); - }, - m(target, anchor) { - insert(target, div7, anchor); - append2(div7, div6); - append2(div6, div0); - append2(div6, t0); - append2(div6, div1); - append2(div6, t1); - append2(div6, div2); - append2(div2, t2); - append2(div6, t3); - append2(div6, div5); - append2(div5, div4); - if_block0.m(div4, null); - append2(div4, t4); - append2(div4, div3); - append2(div7, t5); - if (if_block1) - if_block1.m(div7, null); - append2(div7, t6); - current = true; - if (!mounted) { - dispose = listen(div7, "click", stop_propagation(click_handler_3)); - mounted = true; - } - }, - p(new_ctx, dirty) { - ctx = new_ctx; - if (!current || dirty & /*closed, hierarchy*/ - 33) { - toggle_class( - div1, - "is-collapsed", - /*closed*/ - ctx[5][ - /*entity*/ - ctx[15].title - ] - ); - } - if ((!current || dirty & /*hierarchy*/ - 1) && t2_value !== (t2_value = /*entity*/ - ctx[15].title + "")) - set_data(t2, t2_value); - if (current_block_type === (current_block_type = select_block_type_2(ctx, dirty)) && if_block0) { - if_block0.p(ctx, dirty); - } else { - if_block0.d(1); - if_block0 = current_block_type(ctx); - if (if_block0) { - if_block0.c(); - if_block0.m(div4, t4); - } - } - if (!current || dirty & /*side*/ - 64) { - attr( - div6, - "data-tooltip-position", - /*side*/ - ctx[6] - ); - } - if (!current || dirty & /*hierarchy*/ - 1 && div6_aria_label_value !== (div6_aria_label_value = /*entity*/ - ctx[15].vaultPath)) { - attr(div6, "aria-label", div6_aria_label_value); - } - if (!/*closed*/ - ctx[5][ - /*entity*/ - ctx[15].title - ]) { - if (if_block1) { - if_block1.p(ctx, dirty); - if (dirty & /*closed, hierarchy*/ - 33) { - transition_in(if_block1, 1); - } - } else { - if_block1 = create_if_block_42(ctx); - if_block1.c(); - transition_in(if_block1, 1); - if_block1.m(div7, t6); - } - } else if (if_block1) { - group_outros(); - transition_out(if_block1, 1, 1, () => { - if_block1 = null; - }); - check_outros(); - } - if (!current || dirty & /*closed, hierarchy*/ - 33) { - toggle_class( - div7, - "is-collapsed", - /*closed*/ - ctx[5][ - /*entity*/ - ctx[15].title - ] - ); - } - }, - i(local) { - if (current) - return; - transition_in(if_block1); - current = true; - }, - o(local) { - transition_out(if_block1); - current = false; - }, - d(detaching) { - if (detaching) { - detach(div7); - } - if_block0.d(); - if (if_block1) - if_block1.d(); - mounted = false; - dispose(); - } - }; -} -function create_if_block7(ctx) { - let div; - let current_block_type_index; - let if_block; - let t; - let current; - const if_block_creators = [create_if_block_13, create_if_block_22, create_if_block_32]; - const if_blocks = []; - function select_block_type_1(ctx2, dirty) { - if ( - /*fileType*/ - ctx2[3] == 0 /* staged */ - ) - return 0; - if ( - /*fileType*/ - ctx2[3] == 1 /* changed */ - ) - return 1; - if ( - /*fileType*/ - ctx2[3] == 2 /* pulled */ - ) - return 2; - return -1; - } - if (~(current_block_type_index = select_block_type_1(ctx, -1))) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - } - return { - c() { - div = element("div"); - if (if_block) - if_block.c(); - t = space(); - }, - m(target, anchor) { - insert(target, div, anchor); - if (~current_block_type_index) { - if_blocks[current_block_type_index].m(div, null); - } - append2(div, t); - current = true; - }, - p(ctx2, dirty) { - let previous_block_index = current_block_type_index; - current_block_type_index = select_block_type_1(ctx2, dirty); - if (current_block_type_index === previous_block_index) { - if (~current_block_type_index) { - if_blocks[current_block_type_index].p(ctx2, dirty); - } - } else { - if (if_block) { - group_outros(); - transition_out(if_blocks[previous_block_index], 1, 1, () => { - if_blocks[previous_block_index] = null; - }); - check_outros(); - } - if (~current_block_type_index) { - if_block = if_blocks[current_block_type_index]; - if (!if_block) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); - if_block.c(); - } else { - if_block.p(ctx2, dirty); - } - transition_in(if_block, 1); - if_block.m(div, t); - } else { - if_block = null; - } - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - current = true; - }, - o(local) { - transition_out(if_block); - current = false; - }, - d(detaching) { - if (detaching) { - detach(div); - } - if (~current_block_type_index) { - if_blocks[current_block_type_index].d(); - } - } - }; -} -function create_else_block_1(ctx) { - let div0; - let t; - let div1; - let mounted; - let dispose; - function click_handler_1() { - return ( - /*click_handler_1*/ - ctx[12]( - /*entity*/ - ctx[15] - ) - ); - } - function click_handler_2() { - return ( - /*click_handler_2*/ - ctx[13]( - /*entity*/ - ctx[15] - ) - ); - } - return { - c() { - div0 = element("div"); - div0.innerHTML = ``; - t = space(); - div1 = element("div"); - div1.innerHTML = ``; - attr(div0, "data-icon", "undo"); - attr(div0, "aria-label", "Discard"); - attr(div0, "class", "clickable-icon"); - attr(div1, "data-icon", "plus"); - attr(div1, "aria-label", "Stage"); - attr(div1, "class", "clickable-icon"); - }, - m(target, anchor) { - insert(target, div0, anchor); - insert(target, t, anchor); - insert(target, div1, anchor); - if (!mounted) { - dispose = [ - listen(div0, "click", stop_propagation(click_handler_1)), - listen(div1, "click", stop_propagation(click_handler_2)) - ]; - mounted = true; - } - }, - p(new_ctx, dirty) { - ctx = new_ctx; - }, - d(detaching) { - if (detaching) { - detach(div0); - detach(t); - detach(div1); - } - mounted = false; - run_all(dispose); - } - }; -} -function create_if_block_5(ctx) { - let div; - let mounted; - let dispose; - function click_handler() { - return ( - /*click_handler*/ - ctx[11]( - /*entity*/ - ctx[15] - ) - ); - } - return { - c() { - div = element("div"); - div.innerHTML = ``; - attr(div, "data-icon", "minus"); - attr(div, "aria-label", "Unstage"); - attr(div, "class", "clickable-icon"); - }, - m(target, anchor) { - insert(target, div, anchor); - if (!mounted) { - dispose = listen(div, "click", stop_propagation(click_handler)); - mounted = true; - } - }, - p(new_ctx, dirty) { - ctx = new_ctx; - }, - d(detaching) { - if (detaching) { - detach(div); - } - mounted = false; - dispose(); - } - }; -} -function create_if_block_42(ctx) { - let div; - let treecomponent; - let div_transition; - let current; - treecomponent = new TreeComponent({ - props: { - hierarchy: ( - /*entity*/ - ctx[15] - ), - plugin: ( - /*plugin*/ - ctx[1] - ), - view: ( - /*view*/ - ctx[2] - ), - fileType: ( - /*fileType*/ - ctx[3] - ) - } - }); - return { - c() { - div = element("div"); - create_component(treecomponent.$$.fragment); - attr(div, "class", "tree-item-children nav-folder-children"); - }, - m(target, anchor) { - insert(target, div, anchor); - mount_component(treecomponent, div, null); - current = true; - }, - p(ctx2, dirty) { - const treecomponent_changes = {}; - if (dirty & /*hierarchy*/ - 1) - treecomponent_changes.hierarchy = /*entity*/ - ctx2[15]; - if (dirty & /*plugin*/ - 2) - treecomponent_changes.plugin = /*plugin*/ - ctx2[1]; - if (dirty & /*view*/ - 4) - treecomponent_changes.view = /*view*/ - ctx2[2]; - if (dirty & /*fileType*/ - 8) - treecomponent_changes.fileType = /*fileType*/ - ctx2[3]; - treecomponent.$set(treecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(treecomponent.$$.fragment, local); - if (local) { - add_render_callback(() => { - if (!current) - return; - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, true); - div_transition.run(1); - }); - } - current = true; - }, - o(local) { - transition_out(treecomponent.$$.fragment, local); - if (local) { - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, false); - div_transition.run(0); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(div); - } - destroy_component(treecomponent); - if (detaching && div_transition) - div_transition.end(); - } - }; -} -function create_if_block_32(ctx) { - let pulledfilecomponent; - let current; - pulledfilecomponent = new pulledFileComponent_default({ - props: { - change: ( - /*entity*/ - ctx[15].data - ), - view: ( - /*view*/ - ctx[2] - ) - } - }); - return { - c() { - create_component(pulledfilecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(pulledfilecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const pulledfilecomponent_changes = {}; - if (dirty & /*hierarchy*/ - 1) - pulledfilecomponent_changes.change = /*entity*/ - ctx2[15].data; - if (dirty & /*view*/ - 4) - pulledfilecomponent_changes.view = /*view*/ - ctx2[2]; - pulledfilecomponent.$set(pulledfilecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(pulledfilecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(pulledfilecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(pulledfilecomponent, detaching); - } - }; -} -function create_if_block_22(ctx) { - let filecomponent; - let current; - filecomponent = new fileComponent_default({ - props: { - change: ( - /*entity*/ - ctx[15].data - ), - manager: ( - /*plugin*/ - ctx[1].gitManager - ), - view: ( - /*view*/ - ctx[2] - ) - } - }); - return { - c() { - create_component(filecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(filecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const filecomponent_changes = {}; - if (dirty & /*hierarchy*/ - 1) - filecomponent_changes.change = /*entity*/ - ctx2[15].data; - if (dirty & /*plugin*/ - 2) - filecomponent_changes.manager = /*plugin*/ - ctx2[1].gitManager; - if (dirty & /*view*/ - 4) - filecomponent_changes.view = /*view*/ - ctx2[2]; - filecomponent.$set(filecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(filecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(filecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(filecomponent, detaching); - } - }; -} -function create_if_block_13(ctx) { - let stagedfilecomponent; - let current; - stagedfilecomponent = new stagedFileComponent_default({ - props: { - change: ( - /*entity*/ - ctx[15].data - ), - manager: ( - /*plugin*/ - ctx[1].gitManager - ), - view: ( - /*view*/ - ctx[2] - ) - } - }); - return { - c() { - create_component(stagedfilecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(stagedfilecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const stagedfilecomponent_changes = {}; - if (dirty & /*hierarchy*/ - 1) - stagedfilecomponent_changes.change = /*entity*/ - ctx2[15].data; - if (dirty & /*plugin*/ - 2) - stagedfilecomponent_changes.manager = /*plugin*/ - ctx2[1].gitManager; - if (dirty & /*view*/ - 4) - stagedfilecomponent_changes.view = /*view*/ - ctx2[2]; - stagedfilecomponent.$set(stagedfilecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(stagedfilecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(stagedfilecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(stagedfilecomponent, detaching); - } - }; -} -function create_each_block4(ctx) { - let current_block_type_index; - let if_block; - let if_block_anchor; - let current; - const if_block_creators = [create_if_block7, create_else_block3]; - const if_blocks = []; - function select_block_type(ctx2, dirty) { - if ( - /*entity*/ - ctx2[15].data - ) - return 0; - return 1; - } - current_block_type_index = select_block_type(ctx, -1); - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - return { - c() { - if_block.c(); - if_block_anchor = empty(); - }, - m(target, anchor) { - if_blocks[current_block_type_index].m(target, anchor); - insert(target, if_block_anchor, anchor); - current = true; - }, - p(ctx2, dirty) { - let previous_block_index = current_block_type_index; - current_block_type_index = select_block_type(ctx2, dirty); - if (current_block_type_index === previous_block_index) { - if_blocks[current_block_type_index].p(ctx2, dirty); - } else { - group_outros(); - transition_out(if_blocks[previous_block_index], 1, 1, () => { - if_blocks[previous_block_index] = null; - }); - check_outros(); - if_block = if_blocks[current_block_type_index]; - if (!if_block) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); - if_block.c(); - } else { - if_block.p(ctx2, dirty); - } - transition_in(if_block, 1); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - current = true; - }, - o(local) { - transition_out(if_block); - current = false; - }, - d(detaching) { - if (detaching) { - detach(if_block_anchor); - } - if_blocks[current_block_type_index].d(detaching); - } - }; -} -function create_fragment8(ctx) { - let main; - let current; - let each_value = ensure_array_like( - /*hierarchy*/ - ctx[0].children - ); - let each_blocks = []; - for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block4(get_each_context4(ctx, each_value, i)); - } - const out = (i) => transition_out(each_blocks[i], 1, 1, () => { - each_blocks[i] = null; - }); - return { - c() { - main = element("main"); - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - attr(main, "class", "svelte-hup5mn"); - toggle_class( - main, - "topLevel", - /*topLevel*/ - ctx[4] - ); - }, - m(target, anchor) { - insert(target, main, anchor); - for (let i = 0; i < each_blocks.length; i += 1) { - if (each_blocks[i]) { - each_blocks[i].m(main, null); - } - } - current = true; - }, - p(ctx2, [dirty]) { - if (dirty & /*hierarchy, plugin, view, fileType, closed, fold, side, unstage, stage, discard*/ - 2031) { - each_value = ensure_array_like( - /*hierarchy*/ - ctx2[0].children - ); - let i; - for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context4(ctx2, each_value, i); - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - transition_in(each_blocks[i], 1); - } else { - each_blocks[i] = create_each_block4(child_ctx); - each_blocks[i].c(); - transition_in(each_blocks[i], 1); - each_blocks[i].m(main, null); - } - } - group_outros(); - for (i = each_value.length; i < each_blocks.length; i += 1) { - out(i); - } - check_outros(); - } - if (!current || dirty & /*topLevel*/ - 16) { - toggle_class( - main, - "topLevel", - /*topLevel*/ - ctx2[4] - ); - } - }, - i(local) { - if (current) - return; - for (let i = 0; i < each_value.length; i += 1) { - transition_in(each_blocks[i]); - } - current = true; - }, - o(local) { - each_blocks = each_blocks.filter(Boolean); - for (let i = 0; i < each_blocks.length; i += 1) { - transition_out(each_blocks[i]); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(main); - } - destroy_each(each_blocks, detaching); - } - }; -} -function instance8($$self, $$props, $$invalidate) { - let side; - let { hierarchy } = $$props; - let { plugin } = $$props; - let { view } = $$props; - let { fileType } = $$props; - let { topLevel = false } = $$props; - const closed = {}; - function stage(path2) { - plugin.gitManager.stageAll({ dir: path2 }).finally(() => { - dispatchEvent(new CustomEvent("git-refresh")); - }); - } - function unstage(path2) { - plugin.gitManager.unstageAll({ dir: path2 }).finally(() => { - dispatchEvent(new CustomEvent("git-refresh")); - }); - } - function discard(item) { - new DiscardModal(view.app, false, item.vaultPath).myOpen().then((shouldDiscard) => { - if (shouldDiscard === true) { - plugin.gitManager.discardAll({ - dir: item.path, - status: plugin.cachedStatus - }).finally(() => { - dispatchEvent(new CustomEvent("git-refresh")); - }); - } - }); - } - function fold(item) { - $$invalidate(5, closed[item.title] = !closed[item.title], closed); - } - const click_handler = (entity) => unstage(entity.path); - const click_handler_1 = (entity) => discard(entity); - const click_handler_2 = (entity) => stage(entity.path); - const click_handler_3 = (entity) => fold(entity); - $$self.$$set = ($$props2) => { - if ("hierarchy" in $$props2) - $$invalidate(0, hierarchy = $$props2.hierarchy); - if ("plugin" in $$props2) - $$invalidate(1, plugin = $$props2.plugin); - if ("view" in $$props2) - $$invalidate(2, view = $$props2.view); - if ("fileType" in $$props2) - $$invalidate(3, fileType = $$props2.fileType); - if ("topLevel" in $$props2) - $$invalidate(4, topLevel = $$props2.topLevel); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty & /*view*/ - 4) { - $: - $$invalidate(6, side = view.leaf.getRoot().side == "left" ? "right" : "left"); - } - }; - return [ - hierarchy, - plugin, - view, - fileType, - topLevel, - closed, - side, - stage, - unstage, - discard, - fold, - click_handler, - click_handler_1, - click_handler_2, - click_handler_3 - ]; -} -var TreeComponent = class extends SvelteComponent { - constructor(options) { - super(); - init2( - this, - options, - instance8, - create_fragment8, - safe_not_equal, - { - hierarchy: 0, - plugin: 1, - view: 2, - fileType: 3, - topLevel: 4 - }, - add_css6 - ); - } -}; -var treeComponent_default = TreeComponent; - -// src/ui/sourceControl/sourceControl.svelte -function add_css7(target) { - append_styles(target, "svelte-11adhly", `.commit-msg-input.svelte-11adhly.svelte-11adhly{width:100%;overflow:hidden;resize:none;padding:7px 5px;background-color:var(--background-modifier-form-field)}.git-commit-msg.svelte-11adhly.svelte-11adhly{position:relative;padding:0;width:calc(100% - var(--size-4-8));margin:4px auto}main.svelte-11adhly .git-tools .files-count.svelte-11adhly{padding-left:var(--size-2-1);width:11px;display:flex;align-items:center;justify-content:center}.nav-folder-title.svelte-11adhly.svelte-11adhly{align-items:center}.git-commit-msg-clear-button.svelte-11adhly.svelte-11adhly{position:absolute;background:transparent;border-radius:50%;color:var(--search-clear-button-color);cursor:var(--cursor);top:-4px;right:2px;bottom:0px;line-height:0;height:var(--input-height);width:28px;margin:auto;padding:0 0;text-align:center;display:flex;justify-content:center;align-items:center;transition:color 0.15s ease-in-out}.git-commit-msg-clear-button.svelte-11adhly.svelte-11adhly:after{content:"";height:var(--search-clear-button-size);width:var(--search-clear-button-size);display:block;background-color:currentColor;mask-image:url("data:image/svg+xml,");mask-repeat:no-repeat;-webkit-mask-image:url("data:image/svg+xml,");-webkit-mask-repeat:no-repeat}`); -} -function get_each_context5(ctx, list, i) { - const child_ctx = ctx.slice(); - child_ctx[40] = list[i]; - return child_ctx; -} -function get_each_context_1(ctx, list, i) { - const child_ctx = ctx.slice(); - child_ctx[40] = list[i]; - return child_ctx; -} -function get_each_context_2(ctx, list, i) { - const child_ctx = ctx.slice(); - child_ctx[45] = list[i]; - return child_ctx; -} -function create_if_block_8(ctx) { - let div; - let div_aria_label_value; - let mounted; - let dispose; - return { - c() { - div = element("div"); - attr(div, "class", "git-commit-msg-clear-button svelte-11adhly"); - attr(div, "aria-label", div_aria_label_value = "Clear"); - }, - m(target, anchor) { - insert(target, div, anchor); - if (!mounted) { - dispose = listen( - div, - "click", - /*click_handler_1*/ - ctx[33] - ); - mounted = true; - } - }, - p: noop, - d(detaching) { - if (detaching) { - detach(div); - } - mounted = false; - dispose(); - } - }; -} -function create_if_block8(ctx) { - let div18; - let div17; - let div7; - let div6; - let div0; - let t0; - let div1; - let t2; - let div5; - let div3; - let div2; - let t3; - let div4; - let t4_value = ( - /*status*/ - ctx[6].staged.length + "" - ); - let t4; - let t5; - let t6; - let div16; - let div15; - let div8; - let t7; - let div9; - let t9; - let div14; - let div12; - let div10; - let t10; - let div11; - let t11; - let div13; - let t12_value = ( - /*status*/ - ctx[6].changed.length + "" - ); - let t12; - let t13; - let t14; - let current; - let mounted; - let dispose; - let if_block0 = ( - /*stagedOpen*/ - ctx[13] && create_if_block_6(ctx) - ); - let if_block1 = ( - /*changesOpen*/ - ctx[12] && create_if_block_43(ctx) - ); - let if_block2 = ( - /*lastPulledFiles*/ - ctx[7].length > 0 && create_if_block_14(ctx) - ); - return { - c() { - div18 = element("div"); - div17 = element("div"); - div7 = element("div"); - div6 = element("div"); - div0 = element("div"); - div0.innerHTML = ``; - t0 = space(); - div1 = element("div"); - div1.textContent = "Staged Changes"; - t2 = space(); - div5 = element("div"); - div3 = element("div"); - div2 = element("div"); - div2.innerHTML = ``; - t3 = space(); - div4 = element("div"); - t4 = text(t4_value); - t5 = space(); - if (if_block0) - if_block0.c(); - t6 = space(); - div16 = element("div"); - div15 = element("div"); - div8 = element("div"); - div8.innerHTML = ``; - t7 = space(); - div9 = element("div"); - div9.textContent = "Changes"; - t9 = space(); - div14 = element("div"); - div12 = element("div"); - div10 = element("div"); - div10.innerHTML = ``; - t10 = space(); - div11 = element("div"); - div11.innerHTML = ``; - t11 = space(); - div13 = element("div"); - t12 = text(t12_value); - t13 = space(); - if (if_block1) - if_block1.c(); - t14 = space(); - if (if_block2) - if_block2.c(); - attr(div0, "class", "tree-item-icon nav-folder-collapse-indicator collapse-icon"); - toggle_class(div0, "is-collapsed", !/*stagedOpen*/ - ctx[13]); - attr(div1, "class", "tree-item-inner nav-folder-title-content"); - attr(div2, "data-icon", "minus"); - attr(div2, "aria-label", "Unstage"); - attr(div2, "class", "clickable-icon"); - attr(div3, "class", "buttons"); - attr(div4, "class", "files-count svelte-11adhly"); - attr(div5, "class", "git-tools"); - attr(div6, "class", "tree-item-self is-clickable nav-folder-title svelte-11adhly"); - attr(div7, "class", "staged tree-item nav-folder"); - toggle_class(div7, "is-collapsed", !/*stagedOpen*/ - ctx[13]); - attr(div8, "class", "tree-item-icon nav-folder-collapse-indicator collapse-icon"); - toggle_class(div8, "is-collapsed", !/*changesOpen*/ - ctx[12]); - attr(div9, "class", "tree-item-inner nav-folder-title-content"); - attr(div10, "data-icon", "undo"); - attr(div10, "aria-label", "Discard"); - attr(div10, "class", "clickable-icon"); - attr(div11, "data-icon", "plus"); - attr(div11, "aria-label", "Stage"); - attr(div11, "class", "clickable-icon"); - attr(div12, "class", "buttons"); - attr(div13, "class", "files-count svelte-11adhly"); - attr(div14, "class", "git-tools"); - attr(div15, "class", "tree-item-self is-clickable nav-folder-title svelte-11adhly"); - attr(div16, "class", "changes tree-item nav-folder"); - toggle_class(div16, "is-collapsed", !/*changesOpen*/ - ctx[12]); - attr(div17, "class", "tree-item-children nav-folder-children"); - attr(div18, "class", "tree-item nav-folder mod-root"); - }, - m(target, anchor) { - insert(target, div18, anchor); - append2(div18, div17); - append2(div17, div7); - append2(div7, div6); - append2(div6, div0); - append2(div6, t0); - append2(div6, div1); - append2(div6, t2); - append2(div6, div5); - append2(div5, div3); - append2(div3, div2); - ctx[34](div2); - append2(div5, t3); - append2(div5, div4); - append2(div4, t4); - append2(div7, t5); - if (if_block0) - if_block0.m(div7, null); - append2(div17, t6); - append2(div17, div16); - append2(div16, div15); - append2(div15, div8); - append2(div15, t7); - append2(div15, div9); - append2(div15, t9); - append2(div15, div14); - append2(div14, div12); - append2(div12, div10); - append2(div12, t10); - append2(div12, div11); - ctx[36](div11); - append2(div14, t11); - append2(div14, div13); - append2(div13, t12); - append2(div16, t13); - if (if_block1) - if_block1.m(div16, null); - append2(div17, t14); - if (if_block2) - if_block2.m(div17, null); - current = true; - if (!mounted) { - dispose = [ - listen(div2, "click", stop_propagation( - /*unstageAll*/ - ctx[19] - )), - listen( - div6, - "click", - /*click_handler_2*/ - ctx[35] - ), - listen(div10, "click", stop_propagation( - /*discard*/ - ctx[22] - )), - listen(div11, "click", stop_propagation( - /*stageAll*/ - ctx[18] - )), - listen( - div15, - "click", - /*click_handler_3*/ - ctx[37] - ) - ]; - mounted = true; - } - }, - p(ctx2, dirty) { - if (!current || dirty[0] & /*stagedOpen*/ - 8192) { - toggle_class(div0, "is-collapsed", !/*stagedOpen*/ - ctx2[13]); - } - if ((!current || dirty[0] & /*status*/ - 64) && t4_value !== (t4_value = /*status*/ - ctx2[6].staged.length + "")) - set_data(t4, t4_value); - if ( - /*stagedOpen*/ - ctx2[13] - ) { - if (if_block0) { - if_block0.p(ctx2, dirty); - if (dirty[0] & /*stagedOpen*/ - 8192) { - transition_in(if_block0, 1); - } - } else { - if_block0 = create_if_block_6(ctx2); - if_block0.c(); - transition_in(if_block0, 1); - if_block0.m(div7, null); - } - } else if (if_block0) { - group_outros(); - transition_out(if_block0, 1, 1, () => { - if_block0 = null; - }); - check_outros(); - } - if (!current || dirty[0] & /*stagedOpen*/ - 8192) { - toggle_class(div7, "is-collapsed", !/*stagedOpen*/ - ctx2[13]); - } - if (!current || dirty[0] & /*changesOpen*/ - 4096) { - toggle_class(div8, "is-collapsed", !/*changesOpen*/ - ctx2[12]); - } - if ((!current || dirty[0] & /*status*/ - 64) && t12_value !== (t12_value = /*status*/ - ctx2[6].changed.length + "")) - set_data(t12, t12_value); - if ( - /*changesOpen*/ - ctx2[12] - ) { - if (if_block1) { - if_block1.p(ctx2, dirty); - if (dirty[0] & /*changesOpen*/ - 4096) { - transition_in(if_block1, 1); - } - } else { - if_block1 = create_if_block_43(ctx2); - if_block1.c(); - transition_in(if_block1, 1); - if_block1.m(div16, null); - } - } else if (if_block1) { - group_outros(); - transition_out(if_block1, 1, 1, () => { - if_block1 = null; - }); - check_outros(); - } - if (!current || dirty[0] & /*changesOpen*/ - 4096) { - toggle_class(div16, "is-collapsed", !/*changesOpen*/ - ctx2[12]); - } - if ( - /*lastPulledFiles*/ - ctx2[7].length > 0 - ) { - if (if_block2) { - if_block2.p(ctx2, dirty); - if (dirty[0] & /*lastPulledFiles*/ - 128) { - transition_in(if_block2, 1); - } - } else { - if_block2 = create_if_block_14(ctx2); - if_block2.c(); - transition_in(if_block2, 1); - if_block2.m(div17, null); - } - } else if (if_block2) { - group_outros(); - transition_out(if_block2, 1, 1, () => { - if_block2 = null; - }); - check_outros(); - } - }, - i(local) { - if (current) - return; - transition_in(if_block0); - transition_in(if_block1); - transition_in(if_block2); - current = true; - }, - o(local) { - transition_out(if_block0); - transition_out(if_block1); - transition_out(if_block2); - current = false; - }, - d(detaching) { - if (detaching) { - detach(div18); - } - ctx[34](null); - if (if_block0) - if_block0.d(); - ctx[36](null); - if (if_block1) - if_block1.d(); - if (if_block2) - if_block2.d(); - mounted = false; - run_all(dispose); - } - }; -} -function create_if_block_6(ctx) { - let div; - let current_block_type_index; - let if_block; - let div_transition; - let current; - const if_block_creators = [create_if_block_7, create_else_block_2]; - const if_blocks = []; - function select_block_type(ctx2, dirty) { - if ( - /*showTree*/ - ctx2[3] - ) - return 0; - return 1; - } - current_block_type_index = select_block_type(ctx, [-1, -1]); - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - return { - c() { - div = element("div"); - if_block.c(); - attr(div, "class", "tree-item-children nav-folder-children"); - }, - m(target, anchor) { - insert(target, div, anchor); - if_blocks[current_block_type_index].m(div, null); - current = true; - }, - p(ctx2, dirty) { - let previous_block_index = current_block_type_index; - current_block_type_index = select_block_type(ctx2, dirty); - if (current_block_type_index === previous_block_index) { - if_blocks[current_block_type_index].p(ctx2, dirty); - } else { - group_outros(); - transition_out(if_blocks[previous_block_index], 1, 1, () => { - if_blocks[previous_block_index] = null; - }); - check_outros(); - if_block = if_blocks[current_block_type_index]; - if (!if_block) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); - if_block.c(); - } else { - if_block.p(ctx2, dirty); - } - transition_in(if_block, 1); - if_block.m(div, null); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - if (local) { - add_render_callback(() => { - if (!current) - return; - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, true); - div_transition.run(1); - }); - } - current = true; - }, - o(local) { - transition_out(if_block); - if (local) { - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, false); - div_transition.run(0); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(div); - } - if_blocks[current_block_type_index].d(); - if (detaching && div_transition) - div_transition.end(); - } - }; -} -function create_else_block_2(ctx) { - let each_1_anchor; - let current; - let each_value_2 = ensure_array_like( - /*status*/ - ctx[6].staged - ); - let each_blocks = []; - for (let i = 0; i < each_value_2.length; i += 1) { - each_blocks[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i)); - } - const out = (i) => transition_out(each_blocks[i], 1, 1, () => { - each_blocks[i] = null; - }); - return { - c() { - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - each_1_anchor = empty(); - }, - m(target, anchor) { - for (let i = 0; i < each_blocks.length; i += 1) { - if (each_blocks[i]) { - each_blocks[i].m(target, anchor); - } - } - insert(target, each_1_anchor, anchor); - current = true; - }, - p(ctx2, dirty) { - if (dirty[0] & /*status, view, plugin*/ - 67) { - each_value_2 = ensure_array_like( - /*status*/ - ctx2[6].staged - ); - let i; - for (i = 0; i < each_value_2.length; i += 1) { - const child_ctx = get_each_context_2(ctx2, each_value_2, i); - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - transition_in(each_blocks[i], 1); - } else { - each_blocks[i] = create_each_block_2(child_ctx); - each_blocks[i].c(); - transition_in(each_blocks[i], 1); - each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); - } - } - group_outros(); - for (i = each_value_2.length; i < each_blocks.length; i += 1) { - out(i); - } - check_outros(); - } - }, - i(local) { - if (current) - return; - for (let i = 0; i < each_value_2.length; i += 1) { - transition_in(each_blocks[i]); - } - current = true; - }, - o(local) { - each_blocks = each_blocks.filter(Boolean); - for (let i = 0; i < each_blocks.length; i += 1) { - transition_out(each_blocks[i]); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(each_1_anchor); - } - destroy_each(each_blocks, detaching); - } - }; -} -function create_if_block_7(ctx) { - let treecomponent; - let current; - treecomponent = new treeComponent_default({ - props: { - hierarchy: ( - /*stagedHierarchy*/ - ctx[10] - ), - plugin: ( - /*plugin*/ - ctx[0] - ), - view: ( - /*view*/ - ctx[1] - ), - fileType: 0 /* staged */, - topLevel: true - } - }); - return { - c() { - create_component(treecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(treecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const treecomponent_changes = {}; - if (dirty[0] & /*stagedHierarchy*/ - 1024) - treecomponent_changes.hierarchy = /*stagedHierarchy*/ - ctx2[10]; - if (dirty[0] & /*plugin*/ - 1) - treecomponent_changes.plugin = /*plugin*/ - ctx2[0]; - if (dirty[0] & /*view*/ - 2) - treecomponent_changes.view = /*view*/ - ctx2[1]; - treecomponent.$set(treecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(treecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(treecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(treecomponent, detaching); - } - }; -} -function create_each_block_2(ctx) { - let stagedfilecomponent; - let current; - stagedfilecomponent = new stagedFileComponent_default({ - props: { - change: ( - /*stagedFile*/ - ctx[45] - ), - view: ( - /*view*/ - ctx[1] - ), - manager: ( - /*plugin*/ - ctx[0].gitManager - ) - } - }); - return { - c() { - create_component(stagedfilecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(stagedfilecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const stagedfilecomponent_changes = {}; - if (dirty[0] & /*status*/ - 64) - stagedfilecomponent_changes.change = /*stagedFile*/ - ctx2[45]; - if (dirty[0] & /*view*/ - 2) - stagedfilecomponent_changes.view = /*view*/ - ctx2[1]; - if (dirty[0] & /*plugin*/ - 1) - stagedfilecomponent_changes.manager = /*plugin*/ - ctx2[0].gitManager; - stagedfilecomponent.$set(stagedfilecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(stagedfilecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(stagedfilecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(stagedfilecomponent, detaching); - } - }; -} -function create_if_block_43(ctx) { - let div; - let current_block_type_index; - let if_block; - let div_transition; - let current; - const if_block_creators = [create_if_block_52, create_else_block_12]; - const if_blocks = []; - function select_block_type_1(ctx2, dirty) { - if ( - /*showTree*/ - ctx2[3] - ) - return 0; - return 1; - } - current_block_type_index = select_block_type_1(ctx, [-1, -1]); - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - return { - c() { - div = element("div"); - if_block.c(); - attr(div, "class", "tree-item-children nav-folder-children"); - }, - m(target, anchor) { - insert(target, div, anchor); - if_blocks[current_block_type_index].m(div, null); - current = true; - }, - p(ctx2, dirty) { - let previous_block_index = current_block_type_index; - current_block_type_index = select_block_type_1(ctx2, dirty); - if (current_block_type_index === previous_block_index) { - if_blocks[current_block_type_index].p(ctx2, dirty); - } else { - group_outros(); - transition_out(if_blocks[previous_block_index], 1, 1, () => { - if_blocks[previous_block_index] = null; - }); - check_outros(); - if_block = if_blocks[current_block_type_index]; - if (!if_block) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); - if_block.c(); - } else { - if_block.p(ctx2, dirty); - } - transition_in(if_block, 1); - if_block.m(div, null); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - if (local) { - add_render_callback(() => { - if (!current) - return; - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, true); - div_transition.run(1); - }); - } - current = true; - }, - o(local) { - transition_out(if_block); - if (local) { - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, false); - div_transition.run(0); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(div); - } - if_blocks[current_block_type_index].d(); - if (detaching && div_transition) - div_transition.end(); - } - }; -} -function create_else_block_12(ctx) { - let each_1_anchor; - let current; - let each_value_1 = ensure_array_like( - /*status*/ - ctx[6].changed - ); - let each_blocks = []; - for (let i = 0; i < each_value_1.length; i += 1) { - each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); - } - const out = (i) => transition_out(each_blocks[i], 1, 1, () => { - each_blocks[i] = null; - }); - return { - c() { - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - each_1_anchor = empty(); - }, - m(target, anchor) { - for (let i = 0; i < each_blocks.length; i += 1) { - if (each_blocks[i]) { - each_blocks[i].m(target, anchor); - } - } - insert(target, each_1_anchor, anchor); - current = true; - }, - p(ctx2, dirty) { - if (dirty[0] & /*status, view, plugin*/ - 67) { - each_value_1 = ensure_array_like( - /*status*/ - ctx2[6].changed - ); - let i; - for (i = 0; i < each_value_1.length; i += 1) { - const child_ctx = get_each_context_1(ctx2, each_value_1, i); - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - transition_in(each_blocks[i], 1); - } else { - each_blocks[i] = create_each_block_1(child_ctx); - each_blocks[i].c(); - transition_in(each_blocks[i], 1); - each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); - } - } - group_outros(); - for (i = each_value_1.length; i < each_blocks.length; i += 1) { - out(i); - } - check_outros(); - } - }, - i(local) { - if (current) - return; - for (let i = 0; i < each_value_1.length; i += 1) { - transition_in(each_blocks[i]); - } - current = true; - }, - o(local) { - each_blocks = each_blocks.filter(Boolean); - for (let i = 0; i < each_blocks.length; i += 1) { - transition_out(each_blocks[i]); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(each_1_anchor); - } - destroy_each(each_blocks, detaching); - } - }; -} -function create_if_block_52(ctx) { - let treecomponent; - let current; - treecomponent = new treeComponent_default({ - props: { - hierarchy: ( - /*changeHierarchy*/ - ctx[9] - ), - plugin: ( - /*plugin*/ - ctx[0] - ), - view: ( - /*view*/ - ctx[1] - ), - fileType: 1 /* changed */, - topLevel: true - } - }); - return { - c() { - create_component(treecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(treecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const treecomponent_changes = {}; - if (dirty[0] & /*changeHierarchy*/ - 512) - treecomponent_changes.hierarchy = /*changeHierarchy*/ - ctx2[9]; - if (dirty[0] & /*plugin*/ - 1) - treecomponent_changes.plugin = /*plugin*/ - ctx2[0]; - if (dirty[0] & /*view*/ - 2) - treecomponent_changes.view = /*view*/ - ctx2[1]; - treecomponent.$set(treecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(treecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(treecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(treecomponent, detaching); - } - }; -} -function create_each_block_1(ctx) { - let filecomponent; - let current; - filecomponent = new fileComponent_default({ - props: { - change: ( - /*change*/ - ctx[40] - ), - view: ( - /*view*/ - ctx[1] - ), - manager: ( - /*plugin*/ - ctx[0].gitManager - ) - } - }); - filecomponent.$on("git-refresh", triggerRefresh2); - return { - c() { - create_component(filecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(filecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const filecomponent_changes = {}; - if (dirty[0] & /*status*/ - 64) - filecomponent_changes.change = /*change*/ - ctx2[40]; - if (dirty[0] & /*view*/ - 2) - filecomponent_changes.view = /*view*/ - ctx2[1]; - if (dirty[0] & /*plugin*/ - 1) - filecomponent_changes.manager = /*plugin*/ - ctx2[0].gitManager; - filecomponent.$set(filecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(filecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(filecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(filecomponent, detaching); - } - }; -} -function create_if_block_14(ctx) { - let div3; - let div2; - let div0; - let t0; - let div1; - let t2; - let span; - let t3_value = ( - /*lastPulledFiles*/ - ctx[7].length + "" - ); - let t3; - let t4; - let current; - let mounted; - let dispose; - let if_block = ( - /*lastPulledFilesOpen*/ - ctx[14] && create_if_block_23(ctx) - ); - return { - c() { - div3 = element("div"); - div2 = element("div"); - div0 = element("div"); - div0.innerHTML = ``; - t0 = space(); - div1 = element("div"); - div1.textContent = "Recently Pulled Files"; - t2 = space(); - span = element("span"); - t3 = text(t3_value); - t4 = space(); - if (if_block) - if_block.c(); - attr(div0, "class", "tree-item-icon nav-folder-collapse-indicator collapse-icon"); - attr(div1, "class", "tree-item-inner nav-folder-title-content"); - attr(span, "class", "tree-item-flair"); - attr(div2, "class", "tree-item-self is-clickable nav-folder-title svelte-11adhly"); - attr(div3, "class", "pulled nav-folder"); - toggle_class(div3, "is-collapsed", !/*lastPulledFilesOpen*/ - ctx[14]); - }, - m(target, anchor) { - insert(target, div3, anchor); - append2(div3, div2); - append2(div2, div0); - append2(div2, t0); - append2(div2, div1); - append2(div2, t2); - append2(div2, span); - append2(span, t3); - append2(div3, t4); - if (if_block) - if_block.m(div3, null); - current = true; - if (!mounted) { - dispose = listen( - div2, - "click", - /*click_handler_4*/ - ctx[38] - ); - mounted = true; - } - }, - p(ctx2, dirty) { - if ((!current || dirty[0] & /*lastPulledFiles*/ - 128) && t3_value !== (t3_value = /*lastPulledFiles*/ - ctx2[7].length + "")) - set_data(t3, t3_value); - if ( - /*lastPulledFilesOpen*/ - ctx2[14] - ) { - if (if_block) { - if_block.p(ctx2, dirty); - if (dirty[0] & /*lastPulledFilesOpen*/ - 16384) { - transition_in(if_block, 1); - } - } else { - if_block = create_if_block_23(ctx2); - if_block.c(); - transition_in(if_block, 1); - if_block.m(div3, null); - } - } else if (if_block) { - group_outros(); - transition_out(if_block, 1, 1, () => { - if_block = null; - }); - check_outros(); - } - if (!current || dirty[0] & /*lastPulledFilesOpen*/ - 16384) { - toggle_class(div3, "is-collapsed", !/*lastPulledFilesOpen*/ - ctx2[14]); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - current = true; - }, - o(local) { - transition_out(if_block); - current = false; - }, - d(detaching) { - if (detaching) { - detach(div3); - } - if (if_block) - if_block.d(); - mounted = false; - dispose(); - } - }; -} -function create_if_block_23(ctx) { - let div; - let current_block_type_index; - let if_block; - let div_transition; - let current; - const if_block_creators = [create_if_block_33, create_else_block4]; - const if_blocks = []; - function select_block_type_2(ctx2, dirty) { - if ( - /*showTree*/ - ctx2[3] - ) - return 0; - return 1; - } - current_block_type_index = select_block_type_2(ctx, [-1, -1]); - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - return { - c() { - div = element("div"); - if_block.c(); - attr(div, "class", "tree-item-children nav-folder-children"); - }, - m(target, anchor) { - insert(target, div, anchor); - if_blocks[current_block_type_index].m(div, null); - current = true; - }, - p(ctx2, dirty) { - let previous_block_index = current_block_type_index; - current_block_type_index = select_block_type_2(ctx2, dirty); - if (current_block_type_index === previous_block_index) { - if_blocks[current_block_type_index].p(ctx2, dirty); - } else { - group_outros(); - transition_out(if_blocks[previous_block_index], 1, 1, () => { - if_blocks[previous_block_index] = null; - }); - check_outros(); - if_block = if_blocks[current_block_type_index]; - if (!if_block) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); - if_block.c(); - } else { - if_block.p(ctx2, dirty); - } - transition_in(if_block, 1); - if_block.m(div, null); - } - }, - i(local) { - if (current) - return; - transition_in(if_block); - if (local) { - add_render_callback(() => { - if (!current) - return; - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, true); - div_transition.run(1); - }); - } - current = true; - }, - o(local) { - transition_out(if_block); - if (local) { - if (!div_transition) - div_transition = create_bidirectional_transition(div, slide, { duration: 150 }, false); - div_transition.run(0); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(div); - } - if_blocks[current_block_type_index].d(); - if (detaching && div_transition) - div_transition.end(); - } - }; -} -function create_else_block4(ctx) { - let each_1_anchor; - let current; - let each_value = ensure_array_like( - /*lastPulledFiles*/ - ctx[7] - ); - let each_blocks = []; - for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block5(get_each_context5(ctx, each_value, i)); - } - const out = (i) => transition_out(each_blocks[i], 1, 1, () => { - each_blocks[i] = null; - }); - return { - c() { - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - each_1_anchor = empty(); - }, - m(target, anchor) { - for (let i = 0; i < each_blocks.length; i += 1) { - if (each_blocks[i]) { - each_blocks[i].m(target, anchor); - } - } - insert(target, each_1_anchor, anchor); - current = true; - }, - p(ctx2, dirty) { - if (dirty[0] & /*lastPulledFiles, view*/ - 130) { - each_value = ensure_array_like( - /*lastPulledFiles*/ - ctx2[7] - ); - let i; - for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context5(ctx2, each_value, i); - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - transition_in(each_blocks[i], 1); - } else { - each_blocks[i] = create_each_block5(child_ctx); - each_blocks[i].c(); - transition_in(each_blocks[i], 1); - each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); - } - } - group_outros(); - for (i = each_value.length; i < each_blocks.length; i += 1) { - out(i); - } - check_outros(); - } - }, - i(local) { - if (current) - return; - for (let i = 0; i < each_value.length; i += 1) { - transition_in(each_blocks[i]); - } - current = true; - }, - o(local) { - each_blocks = each_blocks.filter(Boolean); - for (let i = 0; i < each_blocks.length; i += 1) { - transition_out(each_blocks[i]); - } - current = false; - }, - d(detaching) { - if (detaching) { - detach(each_1_anchor); - } - destroy_each(each_blocks, detaching); - } - }; -} -function create_if_block_33(ctx) { - let treecomponent; - let current; - treecomponent = new treeComponent_default({ - props: { - hierarchy: ( - /*lastPulledFilesHierarchy*/ - ctx[11] - ), - plugin: ( - /*plugin*/ - ctx[0] - ), - view: ( - /*view*/ - ctx[1] - ), - fileType: 2 /* pulled */, - topLevel: true - } - }); - return { - c() { - create_component(treecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(treecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const treecomponent_changes = {}; - if (dirty[0] & /*lastPulledFilesHierarchy*/ - 2048) - treecomponent_changes.hierarchy = /*lastPulledFilesHierarchy*/ - ctx2[11]; - if (dirty[0] & /*plugin*/ - 1) - treecomponent_changes.plugin = /*plugin*/ - ctx2[0]; - if (dirty[0] & /*view*/ - 2) - treecomponent_changes.view = /*view*/ - ctx2[1]; - treecomponent.$set(treecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(treecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(treecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(treecomponent, detaching); - } - }; -} -function create_each_block5(ctx) { - let pulledfilecomponent; - let current; - pulledfilecomponent = new pulledFileComponent_default({ - props: { - change: ( - /*change*/ - ctx[40] - ), - view: ( - /*view*/ - ctx[1] - ) - } - }); - pulledfilecomponent.$on("git-refresh", triggerRefresh2); - return { - c() { - create_component(pulledfilecomponent.$$.fragment); - }, - m(target, anchor) { - mount_component(pulledfilecomponent, target, anchor); - current = true; - }, - p(ctx2, dirty) { - const pulledfilecomponent_changes = {}; - if (dirty[0] & /*lastPulledFiles*/ - 128) - pulledfilecomponent_changes.change = /*change*/ - ctx2[40]; - if (dirty[0] & /*view*/ - 2) - pulledfilecomponent_changes.view = /*view*/ - ctx2[1]; - pulledfilecomponent.$set(pulledfilecomponent_changes); - }, - i(local) { - if (current) - return; - transition_in(pulledfilecomponent.$$.fragment, local); - current = true; - }, - o(local) { - transition_out(pulledfilecomponent.$$.fragment, local); - current = false; - }, - d(detaching) { - destroy_component(pulledfilecomponent, detaching); - } - }; -} -function create_fragment9(ctx) { - let main; - let div9; - let div8; - let div0; - let t0; - let div1; - let t1; - let div2; - let t2; - let div3; - let t3; - let div4; - let t4; - let div5; - let t5; - let div6; - let t6; - let div7; - let t7; - let div10; - let textarea; - let t8; - let t9; - let div11; - let main_data_type_value; - let current; - let mounted; - let dispose; - let if_block0 = ( - /*commitMessage*/ - ctx[2] && create_if_block_8(ctx) - ); - let if_block1 = ( - /*status*/ - ctx[6] && /*stagedHierarchy*/ - ctx[10] && /*changeHierarchy*/ - ctx[9] && create_if_block8(ctx) - ); - return { - c() { - main = element("main"); - div9 = element("div"); - div8 = element("div"); - div0 = element("div"); - t0 = space(); - div1 = element("div"); - t1 = space(); - div2 = element("div"); - t2 = space(); - div3 = element("div"); - t3 = space(); - div4 = element("div"); - t4 = space(); - div5 = element("div"); - t5 = space(); - div6 = element("div"); - t6 = space(); - div7 = element("div"); - t7 = space(); - div10 = element("div"); - textarea = element("textarea"); - t8 = space(); - if (if_block0) - if_block0.c(); - t9 = space(); - div11 = element("div"); - if (if_block1) - if_block1.c(); - attr(div0, "id", "backup-btn"); - attr(div0, "data-icon", "arrow-up-circle"); - attr(div0, "class", "clickable-icon nav-action-button"); - attr(div0, "aria-label", "Backup"); - attr(div1, "id", "commit-btn"); - attr(div1, "data-icon", "check"); - attr(div1, "class", "clickable-icon nav-action-button"); - attr(div1, "aria-label", "Commit"); - attr(div2, "id", "stage-all"); - attr(div2, "class", "clickable-icon nav-action-button"); - attr(div2, "data-icon", "plus-circle"); - attr(div2, "aria-label", "Stage all"); - attr(div3, "id", "unstage-all"); - attr(div3, "class", "clickable-icon nav-action-button"); - attr(div3, "data-icon", "minus-circle"); - attr(div3, "aria-label", "Unstage all"); - attr(div4, "id", "push"); - attr(div4, "class", "clickable-icon nav-action-button"); - attr(div4, "data-icon", "upload"); - attr(div4, "aria-label", "Push"); - attr(div5, "id", "pull"); - attr(div5, "class", "clickable-icon nav-action-button"); - attr(div5, "data-icon", "download"); - attr(div5, "aria-label", "Pull"); - attr(div6, "id", "layoutChange"); - attr(div6, "class", "clickable-icon nav-action-button"); - attr(div6, "aria-label", "Change Layout"); - attr(div7, "id", "refresh"); - attr(div7, "class", "clickable-icon nav-action-button"); - attr(div7, "data-icon", "refresh-cw"); - attr(div7, "aria-label", "Refresh"); - set_style(div7, "margin", "1px"); - toggle_class( - div7, - "loading", - /*loading*/ - ctx[5] - ); - attr(div8, "class", "nav-buttons-container"); - attr(div9, "class", "nav-header"); - attr( - textarea, - "rows", - /*rows*/ - ctx[15] - ); - attr(textarea, "class", "commit-msg-input svelte-11adhly"); - attr(textarea, "spellcheck", "true"); - attr(textarea, "placeholder", "Commit Message"); - attr(div10, "class", "git-commit-msg svelte-11adhly"); - attr(div11, "class", "nav-files-container"); - set_style(div11, "position", "relative"); - attr(main, "data-type", main_data_type_value = SOURCE_CONTROL_VIEW_CONFIG.type); - attr(main, "class", "svelte-11adhly"); - }, - m(target, anchor) { - insert(target, main, anchor); - append2(main, div9); - append2(div9, div8); - append2(div8, div0); - ctx[23](div0); - append2(div8, t0); - append2(div8, div1); - ctx[24](div1); - append2(div8, t1); - append2(div8, div2); - ctx[25](div2); - append2(div8, t2); - append2(div8, div3); - ctx[26](div3); - append2(div8, t3); - append2(div8, div4); - ctx[27](div4); - append2(div8, t4); - append2(div8, div5); - ctx[28](div5); - append2(div8, t5); - append2(div8, div6); - ctx[29](div6); - append2(div8, t6); - append2(div8, div7); - ctx[31](div7); - append2(main, t7); - append2(main, div10); - append2(div10, textarea); - set_input_value( - textarea, - /*commitMessage*/ - ctx[2] - ); - append2(div10, t8); - if (if_block0) - if_block0.m(div10, null); - append2(main, t9); - append2(main, div11); - if (if_block1) - if_block1.m(div11, null); - current = true; - if (!mounted) { - dispose = [ - listen( - div0, - "click", - /*backup*/ - ctx[17] - ), - listen( - div1, - "click", - /*commit*/ - ctx[16] - ), - listen( - div2, - "click", - /*stageAll*/ - ctx[18] - ), - listen( - div3, - "click", - /*unstageAll*/ - ctx[19] - ), - listen( - div4, - "click", - /*push*/ - ctx[20] - ), - listen( - div5, - "click", - /*pull*/ - ctx[21] - ), - listen( - div6, - "click", - /*click_handler*/ - ctx[30] - ), - listen(div7, "click", triggerRefresh2), - listen( - textarea, - "input", - /*textarea_input_handler*/ - ctx[32] - ) - ]; - mounted = true; - } - }, - p(ctx2, dirty) { - if (!current || dirty[0] & /*loading*/ - 32) { - toggle_class( - div7, - "loading", - /*loading*/ - ctx2[5] - ); - } - if (!current || dirty[0] & /*rows*/ - 32768) { - attr( - textarea, - "rows", - /*rows*/ - ctx2[15] - ); - } - if (dirty[0] & /*commitMessage*/ - 4) { - set_input_value( - textarea, - /*commitMessage*/ - ctx2[2] - ); - } - if ( - /*commitMessage*/ - ctx2[2] - ) { - if (if_block0) { - if_block0.p(ctx2, dirty); - } else { - if_block0 = create_if_block_8(ctx2); - if_block0.c(); - if_block0.m(div10, null); - } - } else if (if_block0) { - if_block0.d(1); - if_block0 = null; - } - if ( - /*status*/ - ctx2[6] && /*stagedHierarchy*/ - ctx2[10] && /*changeHierarchy*/ - ctx2[9] - ) { - if (if_block1) { - if_block1.p(ctx2, dirty); - if (dirty[0] & /*status, stagedHierarchy, changeHierarchy*/ - 1600) { - transition_in(if_block1, 1); - } - } else { - if_block1 = create_if_block8(ctx2); - if_block1.c(); - transition_in(if_block1, 1); - if_block1.m(div11, null); - } - } else if (if_block1) { - group_outros(); - transition_out(if_block1, 1, 1, () => { - if_block1 = null; - }); - check_outros(); - } - }, - i(local) { - if (current) - return; - transition_in(if_block1); - current = true; - }, - o(local) { - transition_out(if_block1); - current = false; - }, - d(detaching) { - if (detaching) { - detach(main); - } - ctx[23](null); - ctx[24](null); - ctx[25](null); - ctx[26](null); - ctx[27](null); - ctx[28](null); - ctx[29](null); - ctx[31](null); - if (if_block0) - if_block0.d(); - if (if_block1) - if_block1.d(); - mounted = false; - run_all(dispose); - } - }; -} -function triggerRefresh2() { - dispatchEvent(new CustomEvent("git-refresh")); -} -function instance9($$self, $$props, $$invalidate) { - let rows; - let { plugin } = $$props; - let { view } = $$props; - let loading; - let status2; - let lastPulledFiles = []; - let commitMessage = plugin.settings.commitMessage; - let buttons = []; - let changeHierarchy; - let stagedHierarchy; - let lastPulledFilesHierarchy; - let changesOpen = true; - let stagedOpen = true; - let lastPulledFilesOpen = true; - let showTree = plugin.settings.treeStructure; - let layoutBtn; - addEventListener("git-view-refresh", refresh); - plugin.app.workspace.onLayoutReady(() => { - window.setTimeout( - () => { - buttons.forEach((btn) => (0, import_obsidian29.setIcon)(btn, btn.getAttr("data-icon"))); - (0, import_obsidian29.setIcon)(layoutBtn, showTree ? "list" : "folder"); - }, - 0 - ); - }); - onDestroy(() => { - removeEventListener("git-view-refresh", refresh); - }); - function commit2() { - return __awaiter(this, void 0, void 0, function* () { - $$invalidate(5, loading = true); - if (status2) { - if (yield plugin.hasTooBigFiles(status2.staged)) { - plugin.setState(0 /* idle */); - return false; - } - plugin.promiseQueue.addTask(() => plugin.gitManager.commit({ message: commitMessage }).then(() => { - if (commitMessage !== plugin.settings.commitMessage) { - $$invalidate(2, commitMessage = ""); - } - plugin.setUpAutoBackup(); - }).finally(triggerRefresh2)); - } - }); - } - function backup() { - return __awaiter(this, void 0, void 0, function* () { - $$invalidate(5, loading = true); - if (status2) { - plugin.promiseQueue.addTask(() => plugin.createBackup(false, false, commitMessage).then(() => { - if (commitMessage !== plugin.settings.commitMessage) { - $$invalidate(2, commitMessage = ""); - } - }).finally(triggerRefresh2)); - } - }); - } - function refresh() { - return __awaiter(this, void 0, void 0, function* () { - if (!plugin.gitReady) { - $$invalidate(6, status2 = void 0); - return; - } - const unPushedCommits = yield plugin.gitManager.getUnpushedCommits(); - buttons.forEach((btn) => { - var _a2, _b; - if (import_obsidian29.Platform.isMobile) { - btn.removeClass("button-border"); - if (btn.id == "push" && unPushedCommits > 0) { - btn.addClass("button-border"); - } - } else { - (_a2 = btn.firstElementChild) === null || _a2 === void 0 ? void 0 : _a2.removeAttribute("color"); - if (btn.id == "push" && unPushedCommits > 0) { - (_b = btn.firstElementChild) === null || _b === void 0 ? void 0 : _b.setAttr("color", "var(--text-accent)"); - } - } - }); - $$invalidate(6, status2 = plugin.cachedStatus); - if (plugin.lastPulledFiles && plugin.lastPulledFiles != lastPulledFiles) { - $$invalidate(7, lastPulledFiles = plugin.lastPulledFiles); - $$invalidate(11, lastPulledFilesHierarchy = { - title: "", - path: "", - vaultPath: "", - children: plugin.gitManager.getTreeStructure(lastPulledFiles) - }); - } - if (status2) { - const sort = (a, b) => { - return a.vault_path.split("/").last().localeCompare(getDisplayPath(b.vault_path)); - }; - status2.changed.sort(sort); - status2.staged.sort(sort); - if (status2.changed.length + status2.staged.length > 500) { - $$invalidate(6, status2 = void 0); - if (!plugin.loading) { - plugin.displayError("Too many changes to display"); - } - } else { - $$invalidate(9, changeHierarchy = { - title: "", - path: "", - vaultPath: "", - children: plugin.gitManager.getTreeStructure(status2.changed) - }); - $$invalidate(10, stagedHierarchy = { - title: "", - path: "", - vaultPath: "", - children: plugin.gitManager.getTreeStructure(status2.staged) - }); - } - } else { - $$invalidate(9, changeHierarchy = void 0); - $$invalidate(10, stagedHierarchy = void 0); - } - $$invalidate(5, loading = plugin.loading); - }); - } - function stageAll() { - $$invalidate(5, loading = true); - plugin.promiseQueue.addTask(() => plugin.gitManager.stageAll({ status: status2 }).finally(triggerRefresh2)); - } - function unstageAll() { - $$invalidate(5, loading = true); - plugin.promiseQueue.addTask(() => plugin.gitManager.unstageAll({ status: status2 }).finally(triggerRefresh2)); - } - function push2() { - $$invalidate(5, loading = true); - plugin.promiseQueue.addTask(() => plugin.push().finally(triggerRefresh2)); - } - function pull2() { - $$invalidate(5, loading = true); - plugin.promiseQueue.addTask(() => plugin.pullChangesFromRemote().finally(triggerRefresh2)); - } - function discard() { - new DiscardModal(view.app, false, plugin.gitManager.getRelativeVaultPath("/")).myOpen().then((shouldDiscard) => { - if (shouldDiscard === true) { - plugin.promiseQueue.addTask(() => plugin.gitManager.discardAll({ status: plugin.cachedStatus }).finally(() => { - dispatchEvent(new CustomEvent("git-refresh")); - })); - } - }); - } - function div0_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[5] = $$value; - $$invalidate(8, buttons); - }); - } - function div1_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[0] = $$value; - $$invalidate(8, buttons); - }); - } - function div2_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[1] = $$value; - $$invalidate(8, buttons); - }); - } - function div3_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[2] = $$value; - $$invalidate(8, buttons); - }); - } - function div4_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[3] = $$value; - $$invalidate(8, buttons); - }); - } - function div5_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[4] = $$value; - $$invalidate(8, buttons); - }); - } - function div6_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - layoutBtn = $$value; - $$invalidate(4, layoutBtn); - }); - } - const click_handler = () => { - $$invalidate(3, showTree = !showTree); - $$invalidate(0, plugin.settings.treeStructure = showTree, plugin); - plugin.saveSettings(); - }; - function div7_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[6] = $$value; - $$invalidate(8, buttons); - }); - } - function textarea_input_handler() { - commitMessage = this.value; - $$invalidate(2, commitMessage); - } - const click_handler_1 = () => $$invalidate(2, commitMessage = ""); - function div2_binding_1($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[8] = $$value; - $$invalidate(8, buttons); - }); - } - const click_handler_2 = () => $$invalidate(13, stagedOpen = !stagedOpen); - function div11_binding($$value) { - binding_callbacks[$$value ? "unshift" : "push"](() => { - buttons[9] = $$value; - $$invalidate(8, buttons); - }); - } - const click_handler_3 = () => $$invalidate(12, changesOpen = !changesOpen); - const click_handler_4 = () => $$invalidate(14, lastPulledFilesOpen = !lastPulledFilesOpen); - $$self.$$set = ($$props2) => { - if ("plugin" in $$props2) - $$invalidate(0, plugin = $$props2.plugin); - if ("view" in $$props2) - $$invalidate(1, view = $$props2.view); - }; - $$self.$$.update = () => { - if ($$self.$$.dirty[0] & /*layoutBtn, showTree*/ - 24) { - $: { - if (layoutBtn) { - layoutBtn.empty(); - (0, import_obsidian29.setIcon)(layoutBtn, showTree ? "list" : "folder"); - } - } - } - if ($$self.$$.dirty[0] & /*commitMessage*/ - 4) { - $: - $$invalidate(15, rows = (commitMessage.match(/\n/g) || []).length + 1 || 1); - } - }; - return [ - plugin, - view, - commitMessage, - showTree, - layoutBtn, - loading, - status2, - lastPulledFiles, - buttons, - changeHierarchy, - stagedHierarchy, - lastPulledFilesHierarchy, - changesOpen, - stagedOpen, - lastPulledFilesOpen, - rows, - commit2, - backup, - stageAll, - unstageAll, - push2, - pull2, - discard, - div0_binding, - div1_binding, - div2_binding, - div3_binding, - div4_binding, - div5_binding, - div6_binding, - click_handler, - div7_binding, - textarea_input_handler, - click_handler_1, - div2_binding_1, - click_handler_2, - div11_binding, - click_handler_3, - click_handler_4 - ]; -} -var SourceControl = class extends SvelteComponent { - constructor(options) { - super(); - init2(this, options, instance9, create_fragment9, safe_not_equal, { plugin: 0, view: 1 }, add_css7, [-1, -1]); - } -}; -var sourceControl_default = SourceControl; - -// src/ui/sourceControl/sourceControl.ts -var GitView = class extends import_obsidian30.ItemView { - constructor(leaf, plugin) { - super(leaf); - this.plugin = plugin; - this.hoverPopover = null; - } - getViewType() { - return SOURCE_CONTROL_VIEW_CONFIG.type; - } - getDisplayText() { - return SOURCE_CONTROL_VIEW_CONFIG.name; - } - getIcon() { - return SOURCE_CONTROL_VIEW_CONFIG.icon; - } - onClose() { - return super.onClose(); - } - onOpen() { - this._view = new sourceControl_default({ - target: this.contentEl, - props: { - plugin: this.plugin, - view: this - } - }); - return super.onOpen(); - } -}; - -// src/ui/statusBar/branchStatusBar.ts -init_polyfill_buffer(); -var BranchStatusBar = class { - constructor(statusBarEl, plugin) { - this.statusBarEl = statusBarEl; - this.plugin = plugin; - this.statusBarEl.addClass("mod-clickable"); - this.statusBarEl.onClickEvent((e) => { - this.plugin.switchBranch(); - }); - } - async display() { - if (this.plugin.gitReady) { - const branchInfo = await this.plugin.gitManager.branchInfo(); - if (branchInfo.current != void 0) { - this.statusBarEl.setText(branchInfo.current); - } else { - this.statusBarEl.empty(); - } - } else { - this.statusBarEl.empty(); - } - } -}; - -// src/main.ts -var ObsidianGit = class extends import_obsidian31.Plugin { - constructor() { - super(...arguments); - this.gitReady = false; - this.promiseQueue = new PromiseQueue(); - this.conflictOutputFile = "conflict-files-obsidian-git.md"; - this.offlineMode = false; - this.loading = false; - this.lineAuthoringFeature = new LineAuthoringFeature(this); - } - setState(state) { - var _a2; - this.state = state; - (_a2 = this.statusBar) == null ? void 0 : _a2.display(); - } - async updateCachedStatus() { - this.cachedStatus = await this.gitManager.status(); - return this.cachedStatus; - } - async refresh() { - const gitView = this.app.workspace.getLeavesOfType( - SOURCE_CONTROL_VIEW_CONFIG.type - ); - const historyView = this.app.workspace.getLeavesOfType( - HISTORY_VIEW_CONFIG.type - ); - if (this.settings.changedFilesInStatusBar || gitView.length > 0 || historyView.length > 0) { - this.loading = true; - dispatchEvent(new CustomEvent("git-view-refresh")); - await this.updateCachedStatus(); - this.loading = false; - dispatchEvent(new CustomEvent("git-view-refresh")); - } - } - async refreshUpdatedHead() { - this.lineAuthoringFeature.refreshLineAuthorViews(); - } - async onload() { - console.log("loading " + this.manifest.name + " plugin"); - pluginRef.plugin = this; - this.localStorage = new LocalStorageSettings(this); - this.localStorage.migrate(); - await this.loadSettings(); - this.migrateSettings(); - this.settingsTab = new ObsidianGitSettingsTab(this.app, this); - this.addSettingTab(this.settingsTab); - if (!this.localStorage.getPluginDisabled()) { - this.loadPlugin(); - } - } - async loadPlugin() { - addEventListener("git-refresh", this.refresh.bind(this)); - addEventListener("git-head-update", this.refreshUpdatedHead.bind(this)); - this.registerView(SOURCE_CONTROL_VIEW_CONFIG.type, (leaf) => { - return new GitView(leaf, this); - }); - this.registerView(HISTORY_VIEW_CONFIG.type, (leaf) => { - return new HistoryView2(leaf, this); - }); - this.registerView(DIFF_VIEW_CONFIG.type, (leaf) => { - return new DiffView(leaf, this); - }); - this.lineAuthoringFeature.onLoadPlugin(); - this.app.workspace.registerHoverLinkSource( - SOURCE_CONTROL_VIEW_CONFIG.type, - { - display: "Git View", - defaultMod: true - } - ); - this.setRefreshDebouncer(); - this.addCommand({ - id: "edit-gitignore", - name: "Edit .gitignore", - callback: async () => { - const path2 = this.gitManager.getRelativeVaultPath(".gitignore"); - if (!await this.app.vault.adapter.exists(path2)) { - this.app.vault.adapter.write(path2, ""); - } - const content = await this.app.vault.adapter.read(path2); - const modal = new IgnoreModal(this.app, content); - const res = await modal.open(); - if (res !== void 0) { - await this.app.vault.adapter.write(path2, res); - this.refresh(); - } - } - }); - this.addCommand({ - id: "open-git-view", - name: "Open source control view", - callback: async () => { - const leafs = this.app.workspace.getLeavesOfType( - SOURCE_CONTROL_VIEW_CONFIG.type - ); - let leaf; - if (leafs.length === 0) { - leaf = this.app.workspace.getRightLeaf(false); - await leaf.setViewState({ - type: SOURCE_CONTROL_VIEW_CONFIG.type - }); - } else { - leaf = leafs.first(); - } - this.app.workspace.revealLeaf(leaf); - dispatchEvent(new CustomEvent("git-refresh")); - } - }); - this.addCommand({ - id: "open-history-view", - name: "Open history view", - callback: async () => { - const leafs = this.app.workspace.getLeavesOfType( - HISTORY_VIEW_CONFIG.type - ); - let leaf; - if (leafs.length === 0) { - leaf = this.app.workspace.getRightLeaf(false); - await leaf.setViewState({ - type: HISTORY_VIEW_CONFIG.type - }); - } else { - leaf = leafs.first(); - } - this.app.workspace.revealLeaf(leaf); - dispatchEvent(new CustomEvent("git-refresh")); - } - }); - this.addCommand({ - id: "open-diff-view", - name: "Open diff view", - checkCallback: (checking) => { - var _a2; - const file = this.app.workspace.getActiveFile(); - if (checking) { - return file !== null; - } else { - (_a2 = getNewLeaf()) == null ? void 0 : _a2.setViewState({ - type: DIFF_VIEW_CONFIG.type, - active: true, - state: { - staged: false, - file: this.gitManager.getRelativeRepoPath( - file.path, - true - ) - } - }); - } - } - }); - this.addCommand({ - id: "view-file-on-github", - name: "Open file on GitHub", - editorCallback: (editor, { file }) => { - if (file) - return openLineInGitHub(editor, file, this.gitManager); - } - }); - this.addCommand({ - id: "view-history-on-github", - name: "Open file history on GitHub", - editorCallback: (_, { file }) => { - if (file) - return openHistoryInGitHub(file, this.gitManager); - } - }); - this.addCommand({ - id: "pull", - name: "Pull", - callback: () => this.promiseQueue.addTask(() => this.pullChangesFromRemote()) - }); - this.addCommand({ - id: "fetch", - name: "fetch", - callback: () => this.promiseQueue.addTask(() => this.fetch()) - }); - this.addCommand({ - id: "switch-to-remote-branch", - name: "Switch to remote branch", - callback: () => this.promiseQueue.addTask(() => this.switchRemoteBranch()) - }); - this.addCommand({ - id: "add-to-gitignore", - name: "Add file to gitignore", - checkCallback: (checking) => { - const file = this.app.workspace.getActiveFile(); - if (checking) { - return file !== null; - } else { - this.app.vault.adapter.append( - this.gitManager.getRelativeVaultPath(".gitignore"), - "\n" + this.gitManager.getRelativeRepoPath( - file.path, - true - ) - ).then(() => { - this.refresh(); - }); - } - } - }); - this.addCommand({ - id: "push", - name: "Create backup", - callback: () => this.promiseQueue.addTask(() => this.createBackup(false)) - }); - this.addCommand({ - id: "backup-and-close", - name: "Create backup and close", - callback: () => this.promiseQueue.addTask(async () => { - await this.createBackup(false); - window.close(); - }) - }); - this.addCommand({ - id: "commit-push-specified-message", - name: "Create backup with specific message", - callback: () => this.promiseQueue.addTask(() => this.createBackup(false, true)) - }); - this.addCommand({ - id: "commit", - name: "Commit all changes", - callback: () => this.promiseQueue.addTask( - () => this.commit({ fromAutoBackup: false }) - ) - }); - this.addCommand({ - id: "commit-specified-message", - name: "Commit all changes with specific message", - callback: () => this.promiseQueue.addTask( - () => this.commit({ - fromAutoBackup: false, - requestCustomMessage: true - }) - ) - }); - this.addCommand({ - id: "commit-staged", - name: "Commit staged", - callback: () => this.promiseQueue.addTask( - () => this.commit({ - fromAutoBackup: false, - requestCustomMessage: false, - onlyStaged: true - }) - ) - }); - if (import_obsidian31.Platform.isDesktopApp) { - this.addCommand({ - id: "commit-amend-staged-specified-message", - name: "Commit Amend", - callback: () => this.promiseQueue.addTask( - () => this.commit({ - fromAutoBackup: false, - requestCustomMessage: true, - onlyStaged: true, - amend: true - }) - ) - }); - } - this.addCommand({ - id: "commit-staged-specified-message", - name: "Commit staged with specific message", - callback: () => this.promiseQueue.addTask( - () => this.commit({ - fromAutoBackup: false, - requestCustomMessage: true, - onlyStaged: true - }) - ) - }); - this.addCommand({ - id: "push2", - name: "Push", - callback: () => this.promiseQueue.addTask(() => this.push()) - }); - this.addCommand({ - id: "stage-current-file", - name: "Stage current file", - checkCallback: (checking) => { - const file = this.app.workspace.getActiveFile(); - if (checking) { - return file !== null; - } else { - this.promiseQueue.addTask(() => this.stageFile(file)); - } - } - }); - this.addCommand({ - id: "unstage-current-file", - name: "Unstage current file", - checkCallback: (checking) => { - const file = this.app.workspace.getActiveFile(); - if (checking) { - return file !== null; - } else { - this.promiseQueue.addTask(() => this.unstageFile(file)); - } - } - }); - this.addCommand({ - id: "edit-remotes", - name: "Edit remotes", - callback: async () => this.editRemotes() - }); - this.addCommand({ - id: "remove-remote", - name: "Remove remote", - callback: async () => this.removeRemote() - }); - this.addCommand({ - id: "set-upstream-branch", - name: "Set upstream branch", - callback: async () => this.setUpsreamBranch() - }); - this.addCommand({ - id: "delete-repo", - name: "CAUTION: Delete repository", - callback: async () => { - const repoExists = await this.app.vault.adapter.exists( - `${this.settings.basePath}/.git` - ); - if (repoExists) { - const modal = new GeneralModal({ - options: ["NO", "YES"], - placeholder: "Do you really want to delete the repository (.git directory)? This action cannot be undone.", - onlySelection: true - }); - const shouldDelete = await modal.open() === "YES"; - if (shouldDelete) { - await this.app.vault.adapter.rmdir( - `${this.settings.basePath}/.git`, - true - ); - new import_obsidian31.Notice( - "Successfully deleted repository. Reloading plugin..." - ); - this.unloadPlugin(); - this.init(); - } - } else { - new import_obsidian31.Notice("No repository found"); - } - } - }); - this.addCommand({ - id: "init-repo", - name: "Initialize a new repo", - callback: async () => this.createNewRepo() - }); - this.addCommand({ - id: "clone-repo", - name: "Clone an existing remote repo", - callback: async () => this.cloneNewRepo() - }); - this.addCommand({ - id: "list-changed-files", - name: "List changed files", - callback: async () => { - if (!await this.isAllInitialized()) - return; - const status2 = await this.gitManager.status(); - console.log(status2); - this.setState(0 /* idle */); - if (status2.changed.length + status2.staged.length > 500) { - this.displayError("Too many changes to display"); - return; - } - new ChangedFilesModal(this, status2.all).open(); - } - }); - this.addCommand({ - id: "switch-branch", - name: "Switch branch", - callback: () => { - this.switchBranch(); - } - }); - this.addCommand({ - id: "create-branch", - name: "Create new branch", - callback: () => { - this.createBranch(); - } - }); - this.addCommand({ - id: "delete-branch", - name: "Delete branch", - callback: () => { - this.deleteBranch(); - } - }); - this.addCommand({ - id: "discard-all", - name: "CAUTION: Discard all changes", - callback: async () => { - if (!await this.isAllInitialized()) - return false; - const modal = new GeneralModal({ - options: ["NO", "YES"], - placeholder: "Do you want to discard all changes to tracked files? This action cannot be undone.", - onlySelection: true - }); - const shouldDiscardAll = await modal.open() === "YES"; - if (shouldDiscardAll) { - this.promiseQueue.addTask(() => this.discardAll()); - } - } - }); - this.addCommand({ - id: "toggle-line-author-info", - name: "Toggle line author information", - callback: () => { - var _a2; - return (_a2 = this.settingsTab) == null ? void 0 : _a2.configureLineAuthorShowStatus( - !this.settings.lineAuthor.show - ); - } - }); - this.registerEvent( - this.app.workspace.on("file-menu", (menu, file, source) => { - this.handleFileMenu(menu, file, source); - }) - ); - if (this.settings.showStatusBar) { - const statusBarEl = this.addStatusBarItem(); - this.statusBar = new StatusBar(statusBarEl, this); - this.registerInterval( - window.setInterval(() => { - var _a2; - return (_a2 = this.statusBar) == null ? void 0 : _a2.display(); - }, 1e3) - ); - } - if (import_obsidian31.Platform.isDesktop && this.settings.showBranchStatusBar) { - const branchStatusBarEl = this.addStatusBarItem(); - this.branchBar = new BranchStatusBar(branchStatusBarEl, this); - this.registerInterval( - window.setInterval(() => { - var _a2; - return (_a2 = this.branchBar) == null ? void 0 : _a2.display(); - }, 6e4) - ); - } - this.app.workspace.onLayoutReady(() => this.init()); - } - setRefreshDebouncer() { - var _a2; - (_a2 = this.debRefresh) == null ? void 0 : _a2.cancel(); - this.debRefresh = (0, import_obsidian31.debounce)( - () => { - if (this.settings.refreshSourceControl) { - this.refresh(); - } - }, - this.settings.refreshSourceControlTimer, - true - ); - } - async showNotices() { - const length = 1e4; - if (this.manifest.id === "obsidian-git" && import_obsidian31.Platform.isDesktopApp && !this.settings.showedMobileNotice) { - new import_obsidian31.Notice( - "Git is now available on mobile! Please read the plugin's README for more information.", - length - ); - this.settings.showedMobileNotice = true; - await this.saveSettings(); - } - if (this.manifest.id === "obsidian-git-isomorphic") { - new import_obsidian31.Notice( - "Git Mobile is now deprecated. Please uninstall it and install Git instead.", - length - ); - } - } - handleFileMenu(menu, file, source) { - if (!this.settings.showFileMenu) - return; - if (source !== "file-explorer-context-menu") { - return; - } - if (!file) { - return; - } - if (!this.gitReady) - return; - menu.addItem((item) => { - item.setTitle(`Git: Stage`).setIcon("plus-circle").setSection("action").onClick((_) => { - this.promiseQueue.addTask(async () => { - if (file instanceof import_obsidian31.TFile) { - await this.gitManager.stage(file.path, true); - } else { - await this.gitManager.stageAll({ - dir: this.gitManager.getRelativeRepoPath( - file.path, - true - ) - }); - } - this.displayMessage(`Staged ${file.path}`); - }); - }); - }); - menu.addItem((item) => { - item.setTitle(`Git: Unstage`).setIcon("minus-circle").setSection("action").onClick((_) => { - this.promiseQueue.addTask(async () => { - if (file instanceof import_obsidian31.TFile) { - await this.gitManager.unstage(file.path, true); - } else { - await this.gitManager.unstageAll({ - dir: this.gitManager.getRelativeRepoPath( - file.path, - true - ) - }); - } - this.displayMessage(`Unstaged ${file.path}`); - }); - }); - }); - } - async migrateSettings() { - if (this.settings.mergeOnPull != void 0) { - this.settings.syncMethod = this.settings.mergeOnPull ? "merge" : "rebase"; - this.settings.mergeOnPull = void 0; - await this.saveSettings(); - } - if (this.settings.autoCommitMessage === void 0) { - this.settings.autoCommitMessage = this.settings.commitMessage; - await this.saveSettings(); - } - if (this.settings.gitPath != void 0) { - this.localStorage.setGitPath(this.settings.gitPath); - this.settings.gitPath = void 0; - await this.saveSettings(); - } - if (this.settings.username != void 0) { - this.localStorage.setPassword(this.settings.username); - this.settings.username = void 0; - await this.saveSettings(); - } - } - unloadPlugin() { - this.gitReady = false; - dispatchEvent(new CustomEvent("git-refresh")); - this.lineAuthoringFeature.deactivateFeature(); - this.clearAutoPull(); - this.clearAutoPush(); - this.clearAutoBackup(); - removeEventListener("git-refresh", this.refresh.bind(this)); - removeEventListener( - "git-head-update", - this.refreshUpdatedHead.bind(this) - ); - this.app.workspace.offref(this.openEvent); - this.app.metadataCache.offref(this.modifyEvent); - this.app.metadataCache.offref(this.deleteEvent); - this.app.metadataCache.offref(this.createEvent); - this.app.metadataCache.offref(this.renameEvent); - this.debRefresh.cancel(); - } - async onunload() { - this.app.workspace.unregisterHoverLinkSource( - SOURCE_CONTROL_VIEW_CONFIG.type - ); - this.unloadPlugin(); - console.log("unloading " + this.manifest.name + " plugin"); - } - async loadSettings() { - let data = await this.loadData(); - if (data == void 0) { - data = { showedMobileNotice: true }; - } - this.settings = mergeSettingsByPriority(DEFAULT_SETTINGS, data); - } - async saveSettings() { - var _a2; - (_a2 = this.settingsTab) == null ? void 0 : _a2.beforeSaveSettings(); - await this.saveData(this.settings); - } - saveLastAuto(date, mode) { - if (mode === "backup") { - this.localStorage.setLastAutoBackup(date.toString()); - } else if (mode === "pull") { - this.localStorage.setLastAutoPull(date.toString()); - } else if (mode === "push") { - this.localStorage.setLastAutoPush(date.toString()); - } - } - loadLastAuto() { - var _a2, _b, _c; - return { - backup: new Date((_a2 = this.localStorage.getLastAutoBackup()) != null ? _a2 : ""), - pull: new Date((_b = this.localStorage.getLastAutoPull()) != null ? _b : ""), - push: new Date((_c = this.localStorage.getLastAutoPush()) != null ? _c : "") - }; - } - get useSimpleGit() { - return import_obsidian31.Platform.isDesktopApp; - } - async init() { - var _a2; - this.showNotices(); - try { - if (this.useSimpleGit) { - this.gitManager = new SimpleGit(this); - await this.gitManager.setGitInstance(); - } else { - this.gitManager = new IsomorphicGit(this); - } - const result = await this.gitManager.checkRequirements(); - switch (result) { - case "missing-git": - this.displayError("Cannot run git command"); - break; - case "missing-repo": - new import_obsidian31.Notice( - "Can't find a valid git repository. Please create one via the given command or clone an existing repo.", - 1e4 - ); - break; - case "valid": - this.gitReady = true; - this.setState(0 /* idle */); - this.openEvent = this.app.workspace.on( - "active-leaf-change", - (leaf) => this.handleViewActiveState(leaf) - ); - this.modifyEvent = this.app.vault.on("modify", () => { - this.debRefresh(); - }); - this.deleteEvent = this.app.vault.on("delete", () => { - this.debRefresh(); - }); - this.createEvent = this.app.vault.on("create", () => { - this.debRefresh(); - }); - this.renameEvent = this.app.vault.on("rename", () => { - this.debRefresh(); - }); - this.registerEvent(this.modifyEvent); - this.registerEvent(this.deleteEvent); - this.registerEvent(this.createEvent); - this.registerEvent(this.renameEvent); - (_a2 = this.branchBar) == null ? void 0 : _a2.display(); - this.lineAuthoringFeature.conditionallyActivateBySettings(); - dispatchEvent(new CustomEvent("git-refresh")); - if (this.settings.autoPullOnBoot) { - this.promiseQueue.addTask( - () => this.pullChangesFromRemote() - ); - } - this.setUpAutos(); - break; - default: - console.log( - "Something weird happened. The 'checkRequirements' result is " + result - ); - } - } catch (error) { - this.displayError(error); - console.error(error); - } - } - async createNewRepo() { - await this.gitManager.init(); - new import_obsidian31.Notice("Initialized new repo"); - await this.init(); - } - async cloneNewRepo() { - const modal = new GeneralModal({ placeholder: "Enter remote URL" }); - const url = await modal.open(); - if (url) { - const confirmOption = "Vault Root"; - let dir = await new GeneralModal({ - options: this.gitManager instanceof IsomorphicGit ? [confirmOption] : [], - placeholder: "Enter directory for clone. It needs to be empty or not existent.", - allowEmpty: this.gitManager instanceof IsomorphicGit - }).open(); - if (dir !== void 0) { - if (dir === confirmOption) { - dir = "."; - } - dir = (0, import_obsidian31.normalizePath)(dir); - if (dir === "/") { - dir = "."; - } - if (dir === ".") { - const modal2 = new GeneralModal({ - options: ["NO", "YES"], - placeholder: `Does your remote repo contain a ${app.vault.configDir} directory at the root?`, - onlySelection: true - }); - const containsConflictDir = await modal2.open(); - if (containsConflictDir === void 0) { - new import_obsidian31.Notice("Aborted clone"); - return; - } else if (containsConflictDir === "YES") { - const confirmOption2 = "DELETE ALL YOUR LOCAL CONFIG AND PLUGINS"; - const modal3 = new GeneralModal({ - options: ["Abort clone", confirmOption2], - placeholder: `To avoid conflicts, the local ${app.vault.configDir} directory needs to be deleted.`, - onlySelection: true - }); - const shouldDelete = await modal3.open() === confirmOption2; - if (shouldDelete) { - await this.app.vault.adapter.rmdir( - app.vault.configDir, - true - ); - } else { - new import_obsidian31.Notice("Aborted clone"); - return; - } - } - } - const depth = await new GeneralModal({ - placeholder: "Specify depth of clone. Leave empty for full clone.", - allowEmpty: true - }).open(); - let depthInt = void 0; - if (depth !== "") { - depthInt = parseInt(depth); - if (isNaN(depthInt)) { - new import_obsidian31.Notice("Invalid depth. Aborting clone."); - return; - } - } - new import_obsidian31.Notice(`Cloning new repo into "${dir}"`); - const oldBase = this.settings.basePath; - const customDir = dir && dir !== "."; - if (customDir) { - this.settings.basePath = dir; - } - try { - await this.gitManager.clone(url, dir, depthInt); - } catch (error) { - this.settings.basePath = oldBase; - this.saveSettings(); - throw error; - } - new import_obsidian31.Notice("Cloned new repo."); - new import_obsidian31.Notice("Please restart Obsidian"); - if (customDir) { - this.saveSettings(); - } - } - } - } - /** - * Retries to call `this.init()` if necessary, otherwise returns directly - * @returns true if `this.gitManager` is ready to be used, false if not. - */ - async isAllInitialized() { - if (!this.gitReady) { - await this.init(); - } - return this.gitReady; - } - ///Used for command - async pullChangesFromRemote() { - if (!await this.isAllInitialized()) - return; - const filesUpdated = await this.pull(); - this.setUpAutoBackup(); - if (filesUpdated === false) { - return; - } - if (!filesUpdated) { - this.displayMessage("Everything is up-to-date"); - } - if (this.gitManager instanceof SimpleGit) { - const status2 = await this.gitManager.status(); - if (status2.conflicted.length > 0) { - this.displayError( - `You have conflicts in ${status2.conflicted.length} ${status2.conflicted.length == 1 ? "file" : "files"}` - ); - this.handleConflict(status2.conflicted); - } - } - dispatchEvent(new CustomEvent("git-refresh")); - this.setState(0 /* idle */); - } - async createBackup(fromAutoBackup, requestCustomMessage = false, commitMessage) { - if (!await this.isAllInitialized()) - return; - if (this.settings.syncMethod == "reset" && this.settings.pullBeforePush) { - await this.pull(); - } - if (!await this.commit({ - fromAutoBackup, - requestCustomMessage, - commitMessage - })) - return; - if (!this.settings.disablePush) { - if (await this.gitManager.canPush()) { - if (this.settings.syncMethod != "reset" && this.settings.pullBeforePush) { - await this.pull(); - } - await this.push(); - } else { - this.displayMessage("No changes to push"); - } - } - this.setState(0 /* idle */); - } - // Returns true if commit was successfully - async commit({ - fromAutoBackup, - requestCustomMessage = false, - onlyStaged = false, - commitMessage, - amend = false - }) { - if (!await this.isAllInitialized()) - return false; - let hadConflict = this.localStorage.getConflict(); - let changedFiles; - let status2; - let unstagedFiles; - if (this.gitManager instanceof SimpleGit) { - this.mayDeleteConflictFile(); - status2 = await this.updateCachedStatus(); - if (status2.conflicted.length == 0) { - this.localStorage.setConflict(false); - hadConflict = false; - } - if (fromAutoBackup && status2.conflicted.length > 0) { - this.displayError( - `Did not commit, because you have conflicts in ${status2.conflicted.length} ${status2.conflicted.length == 1 ? "file" : "files"}. Please resolve them and commit per command.` - ); - this.handleConflict(status2.conflicted); - return false; - } - changedFiles = [...status2.changed, ...status2.staged]; - } else if (fromAutoBackup && hadConflict) { - this.setState(6 /* conflicted */); - this.displayError( - `Did not commit, because you have conflicts. Please resolve them and commit per command.` - ); - return false; - } else if (hadConflict) { - await this.mayDeleteConflictFile(); - status2 = await this.updateCachedStatus(); - changedFiles = [...status2.changed, ...status2.staged]; - } else { - if (onlyStaged) { - changedFiles = await this.gitManager.getStagedFiles(); - } else { - unstagedFiles = await this.gitManager.getUnstagedFiles(); - changedFiles = unstagedFiles.map(({ filepath }) => ({ - vault_path: this.gitManager.getRelativeVaultPath(filepath) - })); - } - } - if (await this.hasTooBigFiles(changedFiles)) { - this.setState(0 /* idle */); - return false; - } - if (changedFiles.length !== 0 || hadConflict) { - let cmtMessage = commitMessage != null ? commitMessage : commitMessage = fromAutoBackup ? this.settings.autoCommitMessage : this.settings.commitMessage; - if (fromAutoBackup && this.settings.customMessageOnAutoBackup || requestCustomMessage) { - if (!this.settings.disablePopups && fromAutoBackup) { - new import_obsidian31.Notice( - "Auto backup: Please enter a custom commit message. Leave empty to abort" - ); - } - const tempMessage = await new CustomMessageModal( - this, - true - ).open(); - if (tempMessage != void 0 && tempMessage != "" && tempMessage != "...") { - cmtMessage = tempMessage; - } else { - this.setState(0 /* idle */); - return false; - } - } - let committedFiles; - if (onlyStaged) { - committedFiles = await this.gitManager.commit({ - message: cmtMessage, - amend - }); - } else { - committedFiles = await this.gitManager.commitAll({ - message: cmtMessage, - status: status2, - unstagedFiles, - amend - }); - } - if (this.gitManager instanceof SimpleGit) { - if ((await this.updateCachedStatus()).conflicted.length == 0) { - this.localStorage.setConflict(false); - } - } - let roughly = false; - if (committedFiles === void 0) { - roughly = true; - committedFiles = changedFiles.length; - } - this.setUpAutoBackup(); - this.displayMessage( - `Committed${roughly ? " approx." : ""} ${committedFiles} ${committedFiles == 1 ? "file" : "files"}` - ); - } else { - this.displayMessage("No changes to commit"); - } - dispatchEvent(new CustomEvent("git-refresh")); - this.setState(0 /* idle */); - return true; - } - async hasTooBigFiles(files) { - const branchInfo = await this.gitManager.branchInfo(); - const remote = branchInfo.tracking ? splitRemoteBranch(branchInfo.tracking)[0] : null; - if (remote) { - const remoteUrl = await this.gitManager.getRemoteUrl(remote); - if (remoteUrl == null ? void 0 : remoteUrl.includes("github.com")) { - const tooBigFiles = files.filter((f) => { - const file = this.app.vault.getAbstractFileByPath( - f.vault_path - ); - if (file instanceof import_obsidian31.TFile) { - return file.stat.size >= 1e8; - } - return false; - }); - if (tooBigFiles.length > 0) { - this.displayError( - `Did not commit, because following files are too big: ${tooBigFiles.map( - (e) => e.vault_path - )}. Please remove them.` - ); - return true; - } - } - } - return false; - } - async push() { - if (!await this.isAllInitialized()) - return false; - if (!await this.remotesAreSet()) { - return false; - } - const hadConflict = this.localStorage.getConflict(); - if (this.gitManager instanceof SimpleGit) - await this.mayDeleteConflictFile(); - let status2; - if (this.gitManager instanceof SimpleGit && (status2 = await this.updateCachedStatus()).conflicted.length > 0) { - this.displayError( - `Cannot push. You have conflicts in ${status2.conflicted.length} ${status2.conflicted.length == 1 ? "file" : "files"}` - ); - this.handleConflict(status2.conflicted); - return false; - } else if (this.gitManager instanceof IsomorphicGit && hadConflict) { - this.displayError(`Cannot push. You have conflicts`); - this.setState(6 /* conflicted */); - return false; - } - console.log("Pushing...."); - const pushedFiles = await this.gitManager.push(); - if (pushedFiles !== void 0) { - console.log("Pushed!", pushedFiles); - if (pushedFiles > 0) { - this.displayMessage( - `Pushed ${pushedFiles} ${pushedFiles == 1 ? "file" : "files"} to remote` - ); - } else { - this.displayMessage(`No changes to push`); - } - } - this.offlineMode = false; - this.setState(0 /* idle */); - dispatchEvent(new CustomEvent("git-refresh")); - return true; - } - /** Used for internals - Returns whether the pull added a commit or not. - - See {@link pullChangesFromRemote} for the command version. */ - async pull() { - if (!await this.remotesAreSet()) { - return false; - } - const pulledFiles = await this.gitManager.pull() || []; - this.offlineMode = false; - if (pulledFiles.length > 0) { - this.displayMessage( - `Pulled ${pulledFiles.length} ${pulledFiles.length == 1 ? "file" : "files"} from remote` - ); - this.lastPulledFiles = pulledFiles; - } - return pulledFiles.length; - } - async fetch() { - if (!await this.remotesAreSet()) { - return; - } - await this.gitManager.fetch(); - this.displayMessage(`Fetched from remote`); - this.offlineMode = false; - dispatchEvent(new CustomEvent("git-refresh")); - } - async mayDeleteConflictFile() { - const file = this.app.vault.getAbstractFileByPath( - this.conflictOutputFile - ); - if (file) { - this.app.workspace.iterateAllLeaves((leaf) => { - var _a2; - if (leaf.view instanceof import_obsidian31.MarkdownView && ((_a2 = leaf.view.file) == null ? void 0 : _a2.path) == file.path) { - leaf.detach(); - } - }); - await this.app.vault.delete(file); - } - } - async stageFile(file) { - if (!await this.isAllInitialized()) - return false; - await this.gitManager.stage(file.path, true); - this.displayMessage(`Staged ${file.path}`); - dispatchEvent(new CustomEvent("git-refresh")); - this.setState(0 /* idle */); - return true; - } - async unstageFile(file) { - if (!await this.isAllInitialized()) - return false; - await this.gitManager.unstage(file.path, true); - this.displayMessage(`Unstaged ${file.path}`); - dispatchEvent(new CustomEvent("git-refresh")); - this.setState(0 /* idle */); - return true; - } - async switchBranch() { - var _a2; - if (!await this.isAllInitialized()) - return; - const branchInfo = await this.gitManager.branchInfo(); - const selectedBranch = await new BranchModal( - branchInfo.branches - ).open(); - if (selectedBranch != void 0) { - await this.gitManager.checkout(selectedBranch); - this.displayMessage(`Switched to ${selectedBranch}`); - (_a2 = this.branchBar) == null ? void 0 : _a2.display(); - return selectedBranch; - } - } - async switchRemoteBranch() { - var _a2; - if (!await this.isAllInitialized()) - return; - const selectedBranch = await this.selectRemoteBranch() || ""; - const [remote, branch2] = splitRemoteBranch(selectedBranch); - if (branch2 != void 0 && remote != void 0) { - await this.gitManager.checkout(branch2, remote); - this.displayMessage(`Switched to ${selectedBranch}`); - (_a2 = this.branchBar) == null ? void 0 : _a2.display(); - return selectedBranch; - } - } - async createBranch() { - var _a2; - if (!await this.isAllInitialized()) - return; - const newBranch = await new GeneralModal({ - placeholder: "Create new branch" - }).open(); - if (newBranch != void 0) { - await this.gitManager.createBranch(newBranch); - this.displayMessage(`Created new branch ${newBranch}`); - (_a2 = this.branchBar) == null ? void 0 : _a2.display(); - return newBranch; - } - } - async deleteBranch() { - var _a2; - if (!await this.isAllInitialized()) - return; - const branchInfo = await this.gitManager.branchInfo(); - if (branchInfo.current) - branchInfo.branches.remove(branchInfo.current); - const branch2 = await new GeneralModal({ - options: branchInfo.branches, - placeholder: "Delete branch", - onlySelection: true - }).open(); - if (branch2 != void 0) { - let force = false; - const merged = await this.gitManager.branchIsMerged(branch2); - if (!merged) { - const forceAnswer = await new GeneralModal({ - options: ["YES", "NO"], - placeholder: "This branch isn't merged into HEAD. Force delete?", - onlySelection: true - }).open(); - if (forceAnswer !== "YES") { - return; - } - force = forceAnswer === "YES"; - } - await this.gitManager.deleteBranch(branch2, force); - this.displayMessage(`Deleted branch ${branch2}`); - (_a2 = this.branchBar) == null ? void 0 : _a2.display(); - return branch2; - } - } - // Ensures that the upstream branch is set. - // If not, it will prompt the user to set it. - // - // An exception is when the user has submodules enabled. - // In this case, the upstream branch is not required, - // to allow pulling/pushing only the submodules and not the outer repo. - async remotesAreSet() { - if (this.settings.updateSubmodules) { - return true; - } - if (!(await this.gitManager.branchInfo()).tracking) { - new import_obsidian31.Notice("No upstream branch is set. Please select one."); - return await this.setUpsreamBranch(); - } - return true; - } - async setUpsreamBranch() { - const remoteBranch = await this.selectRemoteBranch(); - if (remoteBranch == void 0) { - this.displayError("Aborted. No upstream-branch is set!", 1e4); - this.setState(0 /* idle */); - return false; - } else { - await this.gitManager.updateUpstreamBranch(remoteBranch); - this.displayMessage(`Set upstream branch to ${remoteBranch}`); - this.setState(0 /* idle */); - return true; - } - } - async setUpAutoBackup() { - if (this.settings.setLastSaveToLastCommit) { - this.clearAutoBackup(); - const lastCommitDate = await this.gitManager.getLastCommitTime(); - if (lastCommitDate) { - this.localStorage.setLastAutoBackup(lastCommitDate.toString()); - } - } - if (!this.timeoutIDBackup && !this.onFileModifyEventRef) { - const lastAutos = this.loadLastAuto(); - if (this.settings.autoSaveInterval > 0) { - const now2 = /* @__PURE__ */ new Date(); - const diff3 = this.settings.autoSaveInterval - Math.round( - (now2.getTime() - lastAutos.backup.getTime()) / 1e3 / 60 - ); - this.startAutoBackup(diff3 <= 0 ? 0 : diff3); - } - } - } - async setUpAutos() { - this.setUpAutoBackup(); - const lastAutos = this.loadLastAuto(); - if (this.settings.differentIntervalCommitAndPush && this.settings.autoPushInterval > 0) { - const now2 = /* @__PURE__ */ new Date(); - const diff3 = this.settings.autoPushInterval - Math.round( - (now2.getTime() - lastAutos.push.getTime()) / 1e3 / 60 - ); - this.startAutoPush(diff3 <= 0 ? 0 : diff3); - } - if (this.settings.autoPullInterval > 0) { - const now2 = /* @__PURE__ */ new Date(); - const diff3 = this.settings.autoPullInterval - Math.round( - (now2.getTime() - lastAutos.pull.getTime()) / 1e3 / 60 - ); - this.startAutoPull(diff3 <= 0 ? 0 : diff3); - } - } - async discardAll() { - await this.gitManager.discardAll({ - status: this.cachedStatus - }); - new import_obsidian31.Notice( - "All local changes have been discarded. New files remain untouched." - ); - } - clearAutos() { - this.clearAutoBackup(); - this.clearAutoPush(); - this.clearAutoPull(); - } - startAutoBackup(minutes) { - let time = (minutes != null ? minutes : this.settings.autoSaveInterval) * 6e4; - if (this.settings.autoBackupAfterFileChange) { - if (minutes === 0) { - this.doAutoBackup(); - } else { - this.onFileModifyEventRef = this.app.vault.on( - "modify", - () => this.autoBackupDebouncer() - ); - this.autoBackupDebouncer = (0, import_obsidian31.debounce)( - () => this.doAutoBackup(), - time, - true - ); - } - } else { - if (time > 2147483647) - time = 2147483647; - this.timeoutIDBackup = window.setTimeout( - () => this.doAutoBackup(), - time - ); - } - } - // This is used for both auto backup and commit - doAutoBackup() { - this.promiseQueue.addTask(() => { - if (this.settings.differentIntervalCommitAndPush) { - return this.commit({ fromAutoBackup: true }); - } else { - return this.createBackup(true); - } - }); - this.saveLastAuto(/* @__PURE__ */ new Date(), "backup"); - this.saveSettings(); - this.startAutoBackup(); - } - startAutoPull(minutes) { - let time = (minutes != null ? minutes : this.settings.autoPullInterval) * 6e4; - if (time > 2147483647) - time = 2147483647; - this.timeoutIDPull = window.setTimeout(() => { - this.promiseQueue.addTask(() => this.pullChangesFromRemote()); - this.saveLastAuto(/* @__PURE__ */ new Date(), "pull"); - this.saveSettings(); - this.startAutoPull(); - }, time); - } - startAutoPush(minutes) { - let time = (minutes != null ? minutes : this.settings.autoPushInterval) * 6e4; - if (time > 2147483647) - time = 2147483647; - this.timeoutIDPush = window.setTimeout(() => { - this.promiseQueue.addTask(() => this.push()); - this.saveLastAuto(/* @__PURE__ */ new Date(), "push"); - this.saveSettings(); - this.startAutoPush(); - }, time); - } - clearAutoBackup() { - var _a2; - let wasActive = false; - if (this.timeoutIDBackup) { - window.clearTimeout(this.timeoutIDBackup); - this.timeoutIDBackup = void 0; - wasActive = true; - } - if (this.onFileModifyEventRef) { - (_a2 = this.autoBackupDebouncer) == null ? void 0 : _a2.cancel(); - this.app.vault.offref(this.onFileModifyEventRef); - this.onFileModifyEventRef = void 0; - wasActive = true; - } - return wasActive; - } - clearAutoPull() { - if (this.timeoutIDPull) { - window.clearTimeout(this.timeoutIDPull); - this.timeoutIDPull = void 0; - return true; - } - return false; - } - clearAutoPush() { - if (this.timeoutIDPush) { - window.clearTimeout(this.timeoutIDPush); - this.timeoutIDPush = void 0; - return true; - } - return false; - } - async handleConflict(conflicted) { - this.setState(6 /* conflicted */); - this.localStorage.setConflict(true); - let lines; - if (conflicted !== void 0) { - lines = [ - "# Conflicts", - "Please resolve them and commit them using the commands `Git: Commit all changes` followed by `Git: Push`", - "(This file will automatically be deleted before commit)", - "[[#Additional Instructions]] available below file list", - "", - ...conflicted.map((e) => { - const file = this.app.vault.getAbstractFileByPath(e); - if (file instanceof import_obsidian31.TFile) { - const link = this.app.metadataCache.fileToLinktext( - file, - "/" - ); - return `- [[${link}]]`; - } else { - return `- Not a file: ${e}`; - } - }), - ` + style="background-color: ${a}; width: 30ch;" + >${o}`}`}previewCustomDateTimeDescriptionHtml(r){let n=(0,z.moment)().format(r);return`Format string to display the authoring date.
    Currently: ${n}`}previewOldestAgeDescriptionHtml(r){let n=Zd(r);return[`The oldest age in the line author coloring. Everything older will have the same color. +
    Smallest valid age is "1d". Currently: ${n!==void 0?`${n.asDays()} days`:"invalid!"}`,n]}setNonDefaultValue({settingsProperty:r,text:n}){let i=this.plugin.settings[r];Xe[r]!==i&&(typeof i=="string"||typeof i=="number"||typeof i=="boolean"?n.setValue(String(i)):n.setValue(JSON.stringify(i)))}refreshDisplayWithDelay(r=80){setTimeout(()=>this.display(),r)}};function Rv(t,e){return t==="oldest"?e.colorOld:e.colorNew}function Zd(t){let e=z.moment.duration("P"+t.toUpperCase());return e.isValid()&&e.asDays()&&e.asDays()>=1?e:void 0}function C3(t,e,r){if(!(t===void 0||e===void 0||r===void 0))return`head${t}-obj${e}-path${r}`}var P3=Jd.StateEffect.define();function R3(t,e,r){return r.update({effects:P3.of({key:t,la:e,lineOffsetsFromUnsavedChanges:new Map})})}var Lo=Jd.StateField.define({create:t=>{},update:(t,e)=>{for(let r of e.effects)if(r.is(P3))return r.value;return oU(e,t)},compare:(t,e)=>(t==null?void 0:t.key)===(e==null?void 0:e.key)});function Qd(t){var a;let e=T3.sha256.create();if(!t)return e;let{la:r,key:n,lineOffsetsFromUnsavedChanges:i}=t;e.update(r==="untracked"?"t":"f"),e.update(n);for(let[s,o]of(a=i.entries())!=null?a:[])e.update([s,o]);return e}var Qr={get:void 0,save:void 0};function M3(t,e){Qr.get=t,Qr.save=e}function eh(t){var e,r;return(r=(e=Zd(t.coloringMaxAge))==null?void 0:e.asDays())!=null?r:Zd(Xe.lineAuthor.coloringMaxAge).asDays()}function oU(t,e){if(e)return t.changes.empty||t.changes.iterChanges((r,n,i,a)=>{var p;let s=t.startState.doc,{newDoc:o}=t,l=s.lineAt(r).number,c=s.lineAt(n).number,u=o.lineAt(i).number,f=o.lineAt(a).number,d=c-l+1,h=f-u+1;for(let g=u;g<=f;g++){let v=(p=e.lineOffsetsFromUnsavedChanges.get(g))!=null?p:0,y=f===g,b=h-d;y&&(v+=b),e.lineOffsetsFromUnsavedChanges.set(g,v)}}),e}var Ov=class{constructor(e){this.state=e;this.subscribeMe()}notifyLineAuthoring(e,r){if(this.view===void 0){console.warn(`Git: View is not defined for editor cache key. Unforeseen situation. id: ${e}`);return}let n=this.view.state,i=R3(e,r,n);this.view.dispatch(i)}updateToNewState(e){let r=this.lastSeenPath&&this.filepath!=this.lastSeenPath;return this.state=e,r&&(this.unsubscribeMe(this.lastSeenPath),this.subscribeMe()),this}removeIfStale(){this.view.destroyed&&this.unsubscribeMe(this.lastSeenPath)}subscribeMe(){this.filepath!==void 0&&(Do.ifFilepathDefinedTransformSubscribers(this.filepath,e=>e.add(this)),this.lastSeenPath=this.filepath)}unsubscribeMe(e){Do.ifFilepathDefinedTransformSubscribers(e,r=>r.delete(this))}get filepath(){var e,r;return(r=(e=this.state.field(th.editorInfoField))==null?void 0:e.file)==null?void 0:r.path}get view(){return this.state.field(th.editorEditorField)}},I3=O3.StateField.define({create:t=>new Ov(t),update:(t,e)=>t.updateToNewState(e.state),compare:(t,e)=>t===e});m();function F3(){jo=void 0,Iv=[],rh=0,ih.clear(),ah.clear(),No.clear()}var jo,nh=()=>jo;function $3(t,e){var i;let r=e.length;if(r<((i=jo==null?void 0:jo.length)!=null?i:0))return;jo={gutter:t,length:r,text:e};let n=Qr.get();r!==n.gutterSpacingFallbackLength&&(n.gutterSpacingFallbackLength=r,Qr.save(n))}var Iv=[],lU=15,rh=0;function D3(t){Iv[rh]=t,rh=(rh+1)%lU}function L3(){return a3(Iv)}var ih=new Map,ah=new Map,No=new Set;m();var K3=require("@codemirror/state"),Z3=require("@codemirror/view");m();var Lv=require("@codemirror/view"),q3=Ot(_v()),lh=require("obsidian");m();m();var sh={x:-10,y:-10};function j3(){sh.x===-10&&window.addEventListener("mousedown",t=>{sh.x=t.clientX,sh.y=t.clientY})}function N3(){for(let t of No)if(cU(t,sh))return t}function cU(t,e){let{x:r,y:n,width:i,height:a}=t.getBoundingClientRect();return r<=e.x&&e.x<=r+i&&n<=e.y&&e.y<=n+a}m();var Nc={};var B3="data-commit";function H3(t,e,r){if(e.hasFocus())return;let n=N3();if(!n)return;let i=fU(n);i&&(!i.isZeroCommit&&!i.isWaitingGutter&&uU(i,t),Fv("showCommitHash",t),Fv("authorDisplay",t),Fv("dateTimeFormatOptions",t))}function uU(t,e){e.addItem(r=>r.setTitle("Copy commit hash").setIcon("copy").setSection("obs-git-line-author-copy").onClick(n=>navigator.clipboard.writeText(t.hash)))}function Fv(t,e){var l,c;let r,n,i=Nc.plugin.settings.lineAuthor,a=i[t],s=typeof a=="boolean"?a:a!=="hide",o=Xe.lineAuthor[t];if(t==="showCommitHash")r="Show commit hash",n=a;else if(t==="authorDisplay"){let u=(l=i.lastShownAuthorDisplay)!=null?l:o;r="Show author "+(s?a:u),n=s?"hide":u}else if(t==="dateTimeFormatOptions"){let u=(c=i.lastShownDateTimeFormatOptions)!=null?c:o;r="Show "+(s?a:u),r+=r.contains("date")?"":" date",n=s?"hide":u}else pa(t);e.addItem(u=>u.setTitle(r).setSection("obs-git-line-author-configure").setChecked(s).onClick(f=>{var d,h;return(h=(d=Nc.plugin)==null?void 0:d.settingsTab)==null?void 0:h.lineAuthorSettingHandler(t,n)}))}function U3(t,e,r){r.setAttr(B3,JSON.stringify({hash:t.hash,isZeroCommit:t.isZeroCommit,isWaitingGutter:e}))}function fU(t){let e=t.getAttr(B3);return e?JSON.parse(e):void 0}m();function Mv(t,e){return t==="oldest"?oh(0,!1,e).color:oh(void 0,!0,e).color}function oh(t,e,r){let n=eh(r),i=Date.now()/1e3,a=t!=null?t:0,o=(e?0:i-a)/60/60/24,l=Math.pow(Math.clamp(o/n,0,1),1/2.3),c=dU(),u=r.colorNew,f=r.colorOld,d=c?.4:1,h=$v(u.r,f.r,l)*d,p=$v(u.g,f.g,l)*d,g=$v(u.b,f.b,l)*d;return{color:`rgba(${h},${p},${g},${c?.75:.25})`,daysSinceCommit:o}}function $v(t,e,r){return t+(e-t)*r}function dU(){var t;return((t=window.app)==null?void 0:t.getTheme())==="obsidian"}function G3(t){document.body.style.setProperty("--obs-git-gutter-text",t.textColorCss)}m();function z3(t,e,r){let n;for(let i=e;i<=r;i++){let a=t.hashPerLine[i],s=t.commits.get(a);(!n||s.isZeroCommit||hU(s,n))&&(n=s)}return n}function hU(t,e){var i,a,s,o;let r=(a=(i=t.author)==null?void 0:i.epochSeconds)!=null?a:0,n=(o=(s=e.author)==null?void 0:s.epochSeconds)!=null?o:0;return r>n}var V3="-",pU="+",mU=3,gU="*",vU=/\S/g,yU="%",Bo=class t extends Lv.GutterMarker{constructor(r){super();this.text=r}eq(r){return r instanceof t&&this.text===r.text}toDOM(){return document.createTextNode(this.text)}destroy(r){r&&(document.body.contains(r)||r.remove())}},Dv=class extends Lv.GutterMarker{constructor(r,n,i,a,s,o){super();this.lineAuthoring=r;this.startLine=n;this.endLine=i;this.key=a;this.settings=s;this.options=o;this.point=!1;this.elementClass="obs-git-blame-gutter"}eq(r){return this.key===(r==null?void 0:r.key)&&this.startLine===(r==null?void 0:r.startLine)&&this.endLine===(r==null?void 0:r.endLine)&&(this==null?void 0:this.options)===(r==null?void 0:r.options)}toDOM(){var r;return this.precomputedDomProvider=(r=this.precomputedDomProvider)!=null?r:this.computeDom(),this.precomputedDomProvider()}destroy(r){r&&(document.body.contains(r)||(No.delete(r),r.remove()))}computeDom(){let r=z3(this.lineAuthoring,this.startLine,this.endLine),n=r.isZeroCommit?"":this.renderNonZeroCommit(r);return!r.isZeroCommit&&this.options!=="waiting-for-result"?$3(this,n):n=this.adaptTextForFakeCommit(r,n,this.options),this.createHtmlNode(r,n,this.options==="waiting-for-result")}createHtmlNode(r,n,i){var c;let a=window.createDiv();a.innerText=n;let{color:s,daysSinceCommit:o}=oh((c=r==null?void 0:r.author)==null?void 0:c.epochSeconds,r==null?void 0:r.isZeroCommit,this.settings);a.style.backgroundColor=s,U3(r,i,a);function l(){let u=a.cloneNode(!0);return No.add(u),i||D3(o),u}return l}renderNonZeroCommit(r){let n=this.settings.showCommitHash?this.renderHash(r):"",i=this.settings.authorDisplay==="hide"?"":`${this.renderAuthorName(r,this.settings.authorDisplay)}`,a=this.settings.dateTimeFormatOptions==="hide"?"":`${this.renderAuthoringDate(r,this.settings.dateTimeFormatOptions,this.settings.dateTimeFormatCustomString,this.settings.dateTimeTimezone)}`;return[n,i,a].filter(o=>o.length>=1).join(" ")}renderHash(r){return r.hash.substring(0,6)}renderAuthorName(r,n){var o,l,c,u;let i=(l=(o=r==null?void 0:r.author)==null?void 0:o.name)!=null?l:"",a=i.split(" ").filter(f=>f.length>=1),s;switch(n){case"initials":s=a.map(f=>f[0].toUpperCase()).join("");break;case"first name":s=(c=a.first())!=null?c:V3;break;case"last name":s=(u=a.last())!=null?u:V3;break;case"full":s=i;break;default:return pa(n)}return s3(r==null?void 0:r.author,r==null?void 0:r.committer)||(s=s+gU),s}renderAuthoringDate(r,n,i,a){var c;let s="?";if(((c=r==null?void 0:r.author)==null?void 0:c.epochSeconds)===void 0)return s;let o;switch(n){case"date":o=fd;break;case"datetime":o=o0;break;case"custom":o=i;break;case"natural language":o=u=>{let f=u.diff((0,lh.moment)());return lh.moment.duration(f).humanize(!0)};break;default:return pa(n)}let l=lh.moment.unix(r.author.epochSeconds);switch(a){case"viewer-local":break;case"author-local":l=l.utcOffset(r.author.tz),typeof o=="string"&&(o+=" Z");break;case"utc0000":l=l.utc(),typeof o=="string"&&(o+="[Z]");break;default:return pa(a)}return typeof o=="string"?l.format(o):o(l)}adaptTextForFakeCommit(r,n,i){var l,c,u,f;let a=(c=(l=nh())==null?void 0:l.text)!=null?c:n,s=i!=="waiting-for-result"&&r.isZeroCommit?pU:yU;n=a.replace(vU,s);let o=(f=(u=Qr.get())==null?void 0:u.gutterSpacingFallbackLength)!=null?f:n.length;if(n=o3(n,o,s),i!=="waiting-for-result"&&r.isZeroCommit){let d=Math.min(o,mU);n=l3(n,o-d)}return n}};function ns(t,e,r,n,i,a){let s=q3.sha256.create();s.update(JSON.stringify(i)),s.update(`s${e}-e${r}-k${n}-o${a}`);let o=s.hex(),l=ih.get(o);if(l)return l;let c=new Dv(t,e,r,n,i,a);return ih.set(o,c),c}m();var W3=require("obsidian");function jv(){var e,r;let t=(r=(e=Qr.get())==null?void 0:e.gutterSpacingFallbackLength)!=null?r:Xe.lineAuthor.gutterSpacingFallbackLength;return new Bo(Array(t).fill("-").join(""))}function Nv(t){let{lineAuthoring:e,ageForInitialRender:r}=wU(t);return ns(e,1,1,"initialGutter"+r,t,"waiting-for-result")}function wU(t){var a;let e=(a=L3())!=null?a:eh(t)*.25,r=(0,W3.moment)().add(-e,"days"),n={name:"",epochSeconds:i3(r),tz:"+0000"},i={hash:"waiting-for-result",author:n,committer:n,isZeroCommit:!1};return{lineAuthoring:{hashPerLine:[void 0,"waiting-for-result"],commits:new Map([["waiting-for-result",i]])},ageForInitialRender:e}}m();function Y3(t,e){return ns({hashPerLine:[void 0,"000000"],commits:new Map([["000000",m3]])},1,1,t,e)}var Bv=new Bo(""),J3=(0,Z3.gutter)({class:"line-author-gutter-container",markers(t){let e=t.state.field(Lo,!1);return bU(t,e)},lineMarkerChange(t){let e=Qd(t.state.field(Lo));return Qd(t.startState.field(Lo))!==e},renderEmptyElements:!0,initialSpacer:t=>(X3(t),jv()),updateSpacer:(t,e)=>{var r,n;return X3(e.view),(n=(r=nh())==null?void 0:r.gutter)!=null?n:jv()}});function bU(t,e){let r=Qd(e),n=t.state.doc,i=new Map;for(let u=1;u<=n.lines;u++){let f=n.line(u).from,d=t.lineBlockAt(f).to;i.set(u,[f,d]),r.update([f,d,0])}let a=Qr.get();r.update("s"+Object.values(Qr).join(","));let s=r.hex(),o=ah.get(s);if(o)return o;let{result:l,allowCache:c}=_U(n,i,a,e);return c&&ah.set(s,l),l}function _U(t,e,r,n){let i=!0,a=t.lines,s=[];function o(f,d,h){return s.push(h.range(f,d))}let l=xU(a,n),c=t.length===0,u=t.iterLines(a,a+1).next().value==="";for(let f=1;f<=a;f++){let[d,h]=e.get(f),p=t.lineAt(h).number;if(c){o(d,h,Bv);continue}if(f===a&&u){o(d,h,Bv);continue}if(n===void 0){o(d,h,Nv(r)),i=!1;continue}let{key:g,la:v}=n;if(v==="untracked"){o(d,h,Y3(v,r));continue}let y=v.hashPerLine.length-1,b=l[f],E=l[p];if(E&&E>y&&o(d,h,Bv),b!==void 0&&gv(1,b,y)&&E!==void 0&&gv(1,E,y)){o(d,h,ns(v,b,E,g,r));continue}if(y<1){o(d,h,Nv(r)),i=!1;continue}let S=Math.clamp(b!=null?b:f,1,y),A=Math.clamp(E!=null?E:p,1,y);o(d,h,ns(v,S,A,g+"computing",r,"waiting-for-result"))}return{result:K3.RangeSet.of(s,!0),allowCache:i}}function xU(t,e){if(!(e!=null&&e.lineOffsetsFromUnsavedChanges))return Array.from(new Array(t+1),i=>i);let r=[void 0],n=0;for(let i=1;i<=t;i++){let a=e.lineOffsetsFromUnsavedChanges.get(i);n+=a!=null?a:0,r[i]=a===void 0?i-n:void 0}return r}function X3(t){t.dom.querySelectorAll(".cm-gutters").forEach(r=>{r!=null&&r.style&&(r.style.marginLeft||(r.style.marginLeft="unset"))})}var ch=class{constructor(e){this.plugin=e;this.lineAuthorings=new Map}async trackChanged(e){return this.trackChangedHelper(e).catch(r=>(console.warn("Git: Error in trackChanged."+r),Promise.reject(r)))}async trackChangedHelper(e){if(e){if(e.path===void 0){console.warn("Git: Attempted to track change of undefined filepath. Unforeseen situation.");return}return this.computeLineAuthorInfo(e.path)}}destroy(){this.lineAuthorings.clear(),Do.clear(),F3()}async computeLineAuthorInfo(e){let r=this.plugin.lineAuthoringFeature.isAvailableOnCurrentPlatform().gitManager,n=await r.submoduleAwareHeadRevisonInContainingDirectory(e),i=await r.hashObject(e),a=C3(n,i,e);if(a!==void 0){if(!this.lineAuthorings.has(a)){let s=await r.blame(e,this.plugin.settings.lineAuthor.followMovement,this.plugin.settings.lineAuthor.ignoreWhitespace);this.lineAuthorings.set(a,s)}this.notifyComputationResultToSubscribers(e,a)}}notifyComputationResultToSubscribers(e,r){Do.ifFilepathDefinedTransformSubscribers(e,n=>n.forEach(i=>i.notifyLineAuthoring(r,this.lineAuthorings.get(r))))}},eM=Q3.Prec.high([I3,Lo,J3]);var uh=class{constructor(e){this.plg=e;this.codeMirrorExtensions=[];this.handleWorkspaceLeaf=e=>{if(!this.lineAuthorInfoProvider){console.warn("Git: undefined lineAuthorInfoProvider. Unexpected situation.");return}let r=e==null?void 0:e.view;!(r instanceof is.MarkdownView)||r.file==null||(r==null?void 0:r.allowNoFile)===!0||this.lineAuthorInfoProvider.trackChanged(r.file).catch(console.error)}}onLoadPlugin(){this.plg.registerEditorExtension(this.codeMirrorExtensions),M3(()=>this.plg.settings.lineAuthor,e=>{this.plg.settings.lineAuthor=e,this.plg.saveSettings()})}conditionallyActivateBySettings(){this.plg.settings.lineAuthor.show&&this.activateFeature()}activateFeature(){try{if(!this.isAvailableOnCurrentPlatform().available)return;G3(this.plg.settings.lineAuthor),this.lineAuthorInfoProvider=new ch(this.plg),this.createEventHandlers(),this.activateCodeMirrorExtensions(),console.log(this.plg.manifest.name+": Enabled line authoring.")}catch(e){console.warn("Git: Error while loading line authoring feature.",e),this.deactivateFeature()}}deactivateFeature(){var e;this.destroyEventHandlers(),this.deactivateCodeMirrorExtensions(),(e=this.lineAuthorInfoProvider)==null||e.destroy(),this.lineAuthorInfoProvider=void 0,console.log(this.plg.manifest.name+": Disabled line authoring.")}isAvailableOnCurrentPlatform(){return{available:this.plg.useSimpleGit&&is.Platform.isDesktopApp,gitManager:this.plg.gitManager instanceof Ce?this.plg.gitManager:void 0}}refreshLineAuthorViews(){this.plg.settings.lineAuthor.show&&(this.deactivateFeature(),this.activateFeature())}activateCodeMirrorExtensions(){this.codeMirrorExtensions.push(eM),this.plg.app.workspace.updateOptions(),this.plg.app.workspace.iterateAllLeaves(this.handleWorkspaceLeaf)}deactivateCodeMirrorExtensions(){for(let e of this.codeMirrorExtensions)this.codeMirrorExtensions.remove(e);this.plg.app.workspace.updateOptions()}createEventHandlers(){this.gutterContextMenuEvent=this.createGutterContextMenuHandler(),this.fileOpenEvent=this.createFileOpenEvent(),this.workspaceLeafChangeEvent=this.createWorkspaceLeafChangeEvent(),this.fileModificationEvent=this.createVaultFileModificationHandler(),this.refreshOnCssChangeEvent=this.createCssRefreshHandler(),this.fileRenameEvent=this.createFileRenameEvent(),j3(),this.plg.registerEvent(this.gutterContextMenuEvent),this.plg.registerEvent(this.refreshOnCssChangeEvent),this.plg.registerEvent(this.fileOpenEvent),this.plg.registerEvent(this.workspaceLeafChangeEvent),this.plg.registerEvent(this.fileModificationEvent),this.plg.registerEvent(this.fileRenameEvent)}destroyEventHandlers(){this.plg.app.workspace.offref(this.refreshOnCssChangeEvent),this.plg.app.workspace.offref(this.fileOpenEvent),this.plg.app.workspace.offref(this.workspaceLeafChangeEvent),this.plg.app.workspace.offref(this.refreshOnCssChangeEvent),this.plg.app.vault.offref(this.fileRenameEvent),this.plg.app.workspace.offref(this.gutterContextMenuEvent)}createFileOpenEvent(){return this.plg.app.workspace.on("file-open",e=>{var r;return void((r=this.lineAuthorInfoProvider)==null?void 0:r.trackChanged(e).catch(console.error))})}createWorkspaceLeafChangeEvent(){return this.plg.app.workspace.on("active-leaf-change",this.handleWorkspaceLeaf)}createFileRenameEvent(){return this.plg.app.vault.on("rename",(e,r)=>{var n;return e instanceof is.TFile&&((n=this.lineAuthorInfoProvider)==null?void 0:n.trackChanged(e))})}createVaultFileModificationHandler(){return this.plg.app.vault.on("modify",e=>{var r;return e instanceof is.TFile&&((r=this.lineAuthorInfoProvider)==null?void 0:r.trackChanged(e))})}createCssRefreshHandler(){return this.plg.app.workspace.on("css-change",()=>this.refreshLineAuthorViews())}createGutterContextMenuHandler(){return this.plg.app.workspace.on("editor-menu",H3)}};m();var fh=class{constructor(e){this.plugin=e;this.tasks=[]}addTask(e,r){this.tasks.push({task:e,onFinished:r!=null?r:()=>{}}),this.tasks.length===1&&this.handleTask()}handleTask(){if(this.tasks.length>0){let e=this.tasks[0];e.task().then(r=>{e.onFinished(r),this.tasks.shift(),this.handleTask()},r=>{this.plugin.displayError(r),e.onFinished(void 0),this.tasks.shift(),this.handleTask()})}}clear(){this.tasks=[]}};m();var $r=require("obsidian");var dh=class{constructor(e,r){this.statusBarEl=e;this.plugin=r;this.messages=[];this.base="obsidian-git-statusbar-";this.statusBarEl.setAttribute("data-tooltip-position","top"),r.registerEvent(r.app.workspace.on("obsidian-git:refreshed",()=>{this.refreshCommitTimestamp().catch(console.error)}))}displayMessage(e,r){this.messages.push({message:`Git: ${e.slice(0,100)}`,timeout:r}),this.display()}display(){this.messages.length>0&&!this.currentMessage?(this.currentMessage=this.messages.shift(),this.statusBarEl.addClass(this.base+"message"),this.statusBarEl.ariaLabel="",this.statusBarEl.setText(this.currentMessage.message),this.lastMessageTimestamp=Date.now()):this.currentMessage?Date.now()-this.lastMessageTimestamp>=this.currentMessage.timeout&&(this.currentMessage=null,this.lastMessageTimestamp=null):this.displayState()}displayState(){switch((this.statusBarEl.getText().length>3||!this.statusBarEl.hasChildNodes())&&(this.statusBarEl.empty(),this.conflictEl=this.statusBarEl.createDiv(),this.conflictEl.setAttribute("data-tooltip-position","top"),this.conflictEl.style.float="left",this.pausedEl=this.statusBarEl.createDiv(),this.pausedEl.setAttribute("data-tooltip-position","top"),this.pausedEl.style.float="left",this.iconEl=this.statusBarEl.createDiv(),this.iconEl.style.float="left",this.textEl=this.statusBarEl.createDiv(),this.textEl.style.float="right",this.textEl.style.marginLeft="5px"),this.plugin.localStorage.getConflict()?((0,$r.setIcon)(this.conflictEl,"alert-circle"),this.conflictEl.ariaLabel="You have merge conflicts. Resolve them and commit afterwards.",this.conflictEl.style.marginRight="5px",this.conflictEl.addClass(this.base+"conflict")):(this.conflictEl.empty(),this.conflictEl.style.marginRight=""),this.plugin.localStorage.getPausedAutomatics()?((0,$r.setIcon)(this.pausedEl,"pause-circle"),this.pausedEl.ariaLabel="Automatic routines are currently paused.",this.pausedEl.style.marginRight="5px",this.pausedEl.addClass(this.base+"paused")):(this.pausedEl.empty(),this.pausedEl.style.marginRight=""),this.plugin.state.gitAction){case 0:this.displayFromNow();break;case 1:this.statusBarEl.ariaLabel="Checking repository status...",(0,$r.setIcon)(this.iconEl,"refresh-cw"),this.statusBarEl.addClass(this.base+"status");break;case 3:this.statusBarEl.ariaLabel="Adding files...",(0,$r.setIcon)(this.iconEl,"archive"),this.statusBarEl.addClass(this.base+"add");break;case 4:this.statusBarEl.ariaLabel="Committing changes...",(0,$r.setIcon)(this.iconEl,"git-commit"),this.statusBarEl.addClass(this.base+"commit");break;case 5:this.statusBarEl.ariaLabel="Pushing changes...",(0,$r.setIcon)(this.iconEl,"upload"),this.statusBarEl.addClass(this.base+"push");break;case 2:this.statusBarEl.ariaLabel="Pulling changes...",(0,$r.setIcon)(this.iconEl,"download"),this.statusBarEl.addClass(this.base+"pull");break;default:this.statusBarEl.ariaLabel="Failed on initialization!",(0,$r.setIcon)(this.iconEl,"alert-triangle"),this.statusBarEl.addClass(this.base+"failed-init");break}}displayFromNow(){var n;let e=this.lastCommitTimestamp,r=this.plugin.state.offlineMode;if(e){let i=(0,$r.moment)(e).fromNow();this.statusBarEl.ariaLabel=`${r?"Offline: ":""}Last Commit: ${i}`,(n=this.unPushedCommits)!=null&&n&&(this.statusBarEl.ariaLabel+=` +(${this.unPushedCommits} unpushed commits)`)}else this.statusBarEl.ariaLabel=r?"Git is offline":"Git is ready";r?(0,$r.setIcon)(this.iconEl,"globe"):(0,$r.setIcon)(this.iconEl,"check"),this.plugin.settings.changedFilesInStatusBar&&this.plugin.cachedStatus&&this.textEl.setText(this.plugin.cachedStatus.changed.length.toString()),this.statusBarEl.addClass(this.base+"idle")}async refreshCommitTimestamp(){this.lastCommitTimestamp=await this.plugin.gitManager.getLastCommitTime(),this.unPushedCommits=await this.plugin.gitManager.getUnpushedCommits()}remove(){this.statusBarEl.remove()}};m();var ph=require("obsidian"),hh=class extends ph.SuggestModal{constructor(r){super(r.app);this.plugin=r;this.resolve=null;this.setPlaceholder("Type your message and select optional the version with the added date.")}openAndGetResult(){return new Promise(r=>{this.resolve=r,this.open()})}onClose(){new Promise(r=>setTimeout(r,10)).then(()=>{this.resolve&&this.resolve(void 0)})}getSuggestions(r){let n=(0,ph.moment)().format(this.plugin.settings.commitDateFormat);return r==""&&(r="..."),[r,`${n}: ${r}`,`${r}: ${n}`]}renderSuggestion(r,n){n.innerText=r}onChooseSuggestion(r,n){this.resolve&&this.resolve(r)}};m();var tM=require("obsidian"),Bc=class{constructor(e){this.plugin=e}saveLastAuto(e,r){r==="backup"?this.plugin.localStorage.setLastAutoBackup(e.toString()):r==="pull"?this.plugin.localStorage.setLastAutoPull(e.toString()):r==="push"&&this.plugin.localStorage.setLastAutoPush(e.toString())}loadLastAuto(){var e,r,n;return{backup:new Date((e=this.plugin.localStorage.getLastAutoBackup())!=null?e:""),pull:new Date((r=this.plugin.localStorage.getLastAutoPull())!=null?r:""),push:new Date((n=this.plugin.localStorage.getLastAutoPush())!=null?n:"")}}async init(){await this.setUpAutoCommitAndSync();let e=this.loadLastAuto();if(this.plugin.settings.differentIntervalCommitAndPush&&this.plugin.settings.autoPushInterval>0){let r=this.diff(this.plugin.settings.autoPushInterval,e.push);this.startAutoPush(r)}if(this.plugin.settings.autoPullInterval>0){let r=this.diff(this.plugin.settings.autoPullInterval,e.pull);this.startAutoPull(r)}}unload(){this.clearAutoPull(),this.clearAutoPush(),this.clearAutoCommitAndSync()}reload(...e){this.plugin.localStorage.getPausedAutomatics()||(e.contains("commit")&&(this.clearAutoCommitAndSync(),this.plugin.settings.autoSaveInterval>0&&this.startAutoCommitAndSync(this.plugin.settings.autoSaveInterval)),e.contains("push")&&(this.clearAutoPush(),this.plugin.settings.differentIntervalCommitAndPush&&this.plugin.settings.autoPushInterval>0&&this.startAutoPush(this.plugin.settings.autoPushInterval)),e.contains("pull")&&(this.clearAutoPull(),this.plugin.settings.autoPullInterval>0&&this.startAutoPull(this.plugin.settings.autoPullInterval)))}async setUpAutoCommitAndSync(){if(this.plugin.settings.setLastSaveToLastCommit){this.clearAutoCommitAndSync();let e=await this.plugin.gitManager.getLastCommitTime();e&&this.saveLastAuto(e,"backup")}if(!this.timeoutIDCommitAndSync&&!this.plugin.autoCommitDebouncer){let e=this.loadLastAuto();if(this.plugin.settings.autoSaveInterval>0){let r=this.diff(this.plugin.settings.autoSaveInterval,e.backup);this.startAutoCommitAndSync(r)}}}startAutoCommitAndSync(e){let r=(e!=null?e:this.plugin.settings.autoSaveInterval)*6e4;this.plugin.settings.autoBackupAfterFileChange?e===0?this.doAutoCommitAndSync():this.plugin.autoCommitDebouncer=(0,tM.debounce)(()=>this.doAutoCommitAndSync(),r,!0):(r>2147483647&&(r=2147483647),this.timeoutIDCommitAndSync=window.setTimeout(()=>this.doAutoCommitAndSync(),r))}doAutoCommitAndSync(){this.plugin.promiseQueue.addTask(async()=>{if(this.plugin.settings.setLastSaveToLastCommit){let r=await this.plugin.gitManager.getLastCommitTime();if(r){this.saveLastAuto(r,"backup");let n=this.diff(this.plugin.settings.autoSaveInterval,r);if(n>0)return this.startAutoCommitAndSync(n),!1}}let e=this.plugin.settings.autoCommitOnlyStaged;return this.plugin.settings.differentIntervalCommitAndPush?await this.plugin.commit({fromAuto:!0,onlyStaged:e}):await this.plugin.commitAndSync({fromAutoBackup:!0,onlyStaged:e}),!0},e=>{e!==!1&&(this.saveLastAuto(new Date,"backup"),this.startAutoCommitAndSync())})}startAutoPull(e){let r=(e!=null?e:this.plugin.settings.autoPullInterval)*6e4;r>2147483647&&(r=2147483647),this.timeoutIDPull=window.setTimeout(()=>this.doAutoPull(),r)}doAutoPull(){this.plugin.promiseQueue.addTask(()=>this.plugin.pullChangesFromRemote(),()=>{this.saveLastAuto(new Date,"pull"),this.startAutoPull()})}startAutoPush(e){let r=(e!=null?e:this.plugin.settings.autoPushInterval)*6e4;r>2147483647&&(r=2147483647),this.timeoutIDPush=window.setTimeout(()=>this.doAutoPush(),r)}doAutoPush(){this.plugin.promiseQueue.addTask(()=>this.plugin.push(),()=>{this.saveLastAuto(new Date,"push"),this.startAutoPush()})}clearAutoCommitAndSync(){var r;let e=!1;return this.timeoutIDCommitAndSync&&(window.clearTimeout(this.timeoutIDCommitAndSync),this.timeoutIDCommitAndSync=void 0,e=!0),this.plugin.autoCommitDebouncer&&((r=this.plugin.autoCommitDebouncer)==null||r.cancel(),this.plugin.autoCommitDebouncer=void 0,e=!0),e}clearAutoPull(){return this.timeoutIDPull?(window.clearTimeout(this.timeoutIDPull),this.timeoutIDPull=void 0,!0):!1}clearAutoPush(){return this.timeoutIDPush?(window.clearTimeout(this.timeoutIDPush),this.timeoutIDPush=void 0,!0):!1}diff(e,r){let i=e-Math.round((new Date().getTime()-r.getTime())/1e3/60);return Math.max(0,i)}};m();var bn=require("obsidian");m();var Hc=require("obsidian");async function rM(t,e,r){let n=await iM(e,r);if(n.result==="failure"){new Hc.Notice(n.reason);return}let{isGitHub:i,branch:a,repo:s,user:o,filePath:l}=n;if(i){let c=t.getCursor("from").line+1,u=t.getCursor("to").line+1;c===u?window.open(`https://github.com/${o}/${s}/blob/${a}/${l}?plain=1#L${c}`):window.open(`https://github.com/${o}/${s}/blob/${a}/${l}?plain=1#L${c}-L${u}`)}else new Hc.Notice("It seems like you are not using GitHub")}async function nM(t,e){let r=await iM(t,e);if(r.result==="failure"){new Hc.Notice(r.reason);return}let{isGitHub:n,branch:i,repo:a,user:s,filePath:o}=r;n?window.open(`https://github.com/${s}/${a}/commits/${i}/${o}`):new Hc.Notice("It seems like you are not using GitHub")}async function iM(t,e){let r=await e.branchInfo(),n=r.tracking,i=r.current,a,s=e.getRelativeRepoPath(t.path);if(e instanceof Ce){let l=await e.getSubmoduleOfFile(e.getRelativeRepoPath(t.path));if(l){s=l.relativeFilepath;let c=await e.git.cwd({path:l.submodule,root:!1}).status();if(n=c.tracking||void 0,i=c.current||void 0,n){let u=n.substring(0,n.indexOf("/")),f=await e.git.cwd({path:l.submodule,root:!1}).getConfig(`remote.${u}.url`,"local");if(f.value!=null)a=f.value;else return{result:"failure",reason:"Failed to get remote url of submodule"}}}}if(n==null)return{result:"failure",reason:"Remote branch is not configured"};if(i==null)return{result:"failure",reason:"Failed to get current branch name"};if(a==null){let l=n.substring(0,n.indexOf("/"));if(a=await e.getConfig(`remote.${l}.url`),a==null)return{result:"failure",reason:"Failed to get remote url"}}let o=a.match(/(?:^https:\/\/github\.com\/(.+)\/(.+?)(?:\.git)?$)|(?:^[a-zA-Z]+@github\.com:(.+)\/(.+?)(?:\.git)?$)/);if(o==null)return{result:"failure",reason:"Could not parse remote url"};{let[l,c,u,f,d]=o;return{result:"success",isGitHub:!!l,repo:u||d,user:c||f,branch:i,filePath:s}}}m();var aM=require("obsidian"),mh=class extends aM.FuzzySuggestModal{constructor(e,r){super(e.app),this.plugin=e,this.changedFiles=r,this.setPlaceholder("Not supported files will be opened by default app!")}getItems(){return this.changedFiles}getItemText(e){if(e.index=="U"&&e.workingDir=="U")return`Untracked | ${e.vaultPath}`;let r="",n="";return e.workingDir!=" "&&(r=`Working Dir: ${e.workingDir} `),e.index!=" "&&(n=`Index: ${e.index}`),`${r}${n} | ${e.vaultPath}`}onChooseItem(e,r){this.plugin.app.metadataCache.getFirstLinkpathDest(e.vaultPath,"")==null?this.app.openWithDefaultApp(e.vaultPath):this.plugin.app.workspace.openLinkText(e.vaultPath,"/")}};m();var sM=require("obsidian"),gh=class extends sM.Modal{constructor(r,n){super(r);this.content=n;this.resolve=null}openAndGetReslt(){return new Promise(r=>{this.resolve=r,this.open()})}onOpen(){let{contentEl:r,titleEl:n}=this;n.setText("Edit .gitignore");let i=r.createDiv(),a=i.createEl("textarea",{text:this.content,cls:["obsidian-git-textarea"],attr:{rows:10,cols:30,wrap:"off"}});i.createEl("button",{cls:["mod-cta","obsidian-git-center-button"],text:"Save"}).addEventListener("click",()=>{this.resolve(a.value),this.close()})}onClose(){let{contentEl:r}=this;r.empty(),this.resolve&&this.resolve(void 0)}};function oM(t){let e=t.app;t.addCommand({id:"edit-gitignore",name:"Edit .gitignore",callback:async()=>{let r=t.gitManager.getRelativeVaultPath(".gitignore");await e.vault.adapter.exists(r)||await e.vault.adapter.write(r,"");let n=await e.vault.adapter.read(r),a=await new gh(e,n).openAndGetReslt();a!==void 0&&(await e.vault.adapter.write(r,a),await t.refresh())}}),t.addCommand({id:"open-git-view",name:"Open source control view",callback:async()=>{var i;let r=e.workspace.getLeavesOfType($t.type),n;r.length===0?(n=(i=e.workspace.getRightLeaf(!1))!=null?i:e.workspace.getLeaf(),await n.setViewState({type:$t.type})):n=r.first(),await e.workspace.revealLeaf(n),e.workspace.trigger("obsidian-git:refresh")}}),t.addCommand({id:"open-history-view",name:"Open history view",callback:async()=>{var i;let r=e.workspace.getLeavesOfType(Zr.type),n;r.length===0?(n=(i=e.workspace.getRightLeaf(!1))!=null?i:e.workspace.getLeaf(),await n.setViewState({type:Zr.type})):n=r.first(),await e.workspace.revealLeaf(n),e.workspace.trigger("obsidian-git:refresh")}}),t.addCommand({id:"open-diff-view",name:"Open diff view",checkCallback:r=>{let n=e.workspace.getActiveFile();if(r)return n!==null;{let i=t.gitManager.getRelativeRepoPath(n.path,!0);t.tools.openDiff({aFile:i,aRef:""})}}}),t.addCommand({id:"view-file-on-github",name:"Open file on GitHub",editorCallback:(r,{file:n})=>{if(n)return rM(r,n,t.gitManager)}}),t.addCommand({id:"view-history-on-github",name:"Open file history on GitHub",editorCallback:(r,{file:n})=>{if(n)return nM(n,t.gitManager)}}),t.addCommand({id:"pull",name:"Pull",callback:()=>t.promiseQueue.addTask(()=>t.pullChangesFromRemote())}),t.addCommand({id:"fetch",name:"Fetch",callback:()=>t.promiseQueue.addTask(()=>t.fetch())}),t.addCommand({id:"switch-to-remote-branch",name:"Switch to remote branch",callback:()=>t.promiseQueue.addTask(()=>t.switchRemoteBranch())}),t.addCommand({id:"add-to-gitignore",name:"Add file to .gitignore",checkCallback:r=>{let n=e.workspace.getActiveFile();if(r)return n!==null;t.addFileToGitignore(n.path,n instanceof bn.TFolder).catch(i=>t.displayError(i))}}),t.addCommand({id:"push",name:"Commit-and-sync",callback:()=>t.promiseQueue.addTask(()=>t.commitAndSync({fromAutoBackup:!1}))}),t.addCommand({id:"backup-and-close",name:"Commit-and-sync and then close Obsidian",callback:()=>t.promiseQueue.addTask(async()=>{await t.commitAndSync({fromAutoBackup:!1}),window.close()})}),t.addCommand({id:"commit-push-specified-message",name:"Commit-and-sync with specific message",callback:()=>t.promiseQueue.addTask(()=>t.commitAndSync({fromAutoBackup:!1,requestCustomMessage:!0}))}),t.addCommand({id:"commit",name:"Commit all changes",callback:()=>t.promiseQueue.addTask(()=>t.commit({fromAuto:!1}))}),t.addCommand({id:"commit-specified-message",name:"Commit all changes with specific message",callback:()=>t.promiseQueue.addTask(()=>t.commit({fromAuto:!1,requestCustomMessage:!0}))}),t.addCommand({id:"commit-smart",name:"Commit",callback:()=>t.promiseQueue.addTask(async()=>{let n=(await t.updateCachedStatus()).staged.length>0;return t.commit({fromAuto:!1,requestCustomMessage:!1,onlyStaged:n})})}),t.addCommand({id:"commit-staged",name:"Commit staged",checkCallback:function(r){if(r)return!1;t.promiseQueue.addTask(async()=>t.commit({fromAuto:!1,requestCustomMessage:!1}))}}),bn.Platform.isDesktopApp&&t.addCommand({id:"commit-amend-staged-specified-message",name:"Amend staged",callback:()=>t.promiseQueue.addTask(()=>t.commit({fromAuto:!1,requestCustomMessage:!0,onlyStaged:!0,amend:!0}))}),t.addCommand({id:"commit-smart-specified-message",name:"Commit with specific message",callback:()=>t.promiseQueue.addTask(async()=>{let n=(await t.updateCachedStatus()).staged.length>0;return t.commit({fromAuto:!1,requestCustomMessage:!0,onlyStaged:n})})}),t.addCommand({id:"commit-staged-specified-message",name:"Commit staged with specific message",checkCallback:function(r){return r?!1:t.promiseQueue.addTask(()=>t.commit({fromAuto:!1,requestCustomMessage:!0,onlyStaged:!0}))}}),t.addCommand({id:"push2",name:"Push",callback:()=>t.promiseQueue.addTask(()=>t.push())}),t.addCommand({id:"stage-current-file",name:"Stage current file",checkCallback:r=>{let n=e.workspace.getActiveFile();if(r)return n!==null;t.promiseQueue.addTask(()=>t.stageFile(n))}}),t.addCommand({id:"unstage-current-file",name:"Unstage current file",checkCallback:r=>{let n=e.workspace.getActiveFile();if(r)return n!==null;t.promiseQueue.addTask(()=>t.unstageFile(n))}}),t.addCommand({id:"edit-remotes",name:"Edit remotes",callback:()=>t.editRemotes().catch(r=>t.displayError(r))}),t.addCommand({id:"remove-remote",name:"Remove remote",callback:()=>t.removeRemote().catch(r=>t.displayError(r))}),t.addCommand({id:"set-upstream-branch",name:"Set upstream branch",callback:()=>t.setUpstreamBranch().catch(r=>t.displayError(r))}),t.addCommand({id:"delete-repo",name:"CAUTION: Delete repository",callback:async()=>{await e.vault.adapter.exists(`${t.settings.basePath}/.git`)?await new ze(t,{options:["NO","YES"],placeholder:"Do you really want to delete the repository (.git directory)? plugin action cannot be undone.",onlySelection:!0}).openAndGetResult()==="YES"&&(await e.vault.adapter.rmdir(`${t.settings.basePath}/.git`,!0),new bn.Notice("Successfully deleted repository. Reloading plugin..."),t.unloadPlugin(),await t.init({fromReload:!0})):new bn.Notice("No repository found")}}),t.addCommand({id:"init-repo",name:"Initialize a new repo",callback:()=>t.createNewRepo().catch(r=>t.displayError(r))}),t.addCommand({id:"clone-repo",name:"Clone an existing remote repo",callback:()=>t.cloneNewRepo().catch(r=>t.displayError(r))}),t.addCommand({id:"list-changed-files",name:"List changed files",callback:async()=>{if(await t.isAllInitialized())try{let r=await t.updateCachedStatus();if(r.changed.length+r.staged.length>500){t.displayError("Too many changes to display");return}new mh(t,r.all).open()}catch(r){t.displayError(r)}}}),t.addCommand({id:"switch-branch",name:"Switch branch",callback:()=>{t.switchBranch().catch(r=>t.displayError(r))}}),t.addCommand({id:"create-branch",name:"Create new branch",callback:()=>{t.createBranch().catch(r=>t.displayError(r))}}),t.addCommand({id:"delete-branch",name:"Delete branch",callback:()=>{t.deleteBranch().catch(r=>t.displayError(r))}}),t.addCommand({id:"discard-all",name:"CAUTION: Discard all changes",callback:async()=>{let r=await t.discardAll();switch(r){case"discard":new bn.Notice("Discarded all changes in tracked files.");break;case"delete":new bn.Notice("Discarded all files.");break;case!1:break;default:Ud(r)}}}),t.addCommand({id:"pause-automatic-routines",name:"Pause/Resume automatic routines",callback:()=>{let r=!t.localStorage.getPausedAutomatics();t.localStorage.setPausedAutomatics(r),r?(t.automaticsManager.unload(),new bn.Notice("Paused automatic routines.")):(t.automaticsManager.reload("commit","push","pull"),new bn.Notice("Resumed automatic routines."))}}),t.addCommand({id:"raw-command",name:"Raw command",checkCallback:r=>{let n=t.gitManager;if(r)return n instanceof Ce;t.tools.runRawCommand().catch(i=>t.displayError(i))}}),t.addCommand({id:"toggle-line-author-info",name:"Toggle line author information",callback:()=>{var r;return(r=t.settingsTab)==null?void 0:r.configureLineAuthorShowStatus(!t.settings.lineAuthor.show)}})}m();var vh=class{constructor(e){this.plugin=e;this.prefix=this.plugin.manifest.id+":",this.app=e.app}migrate(){let e=["password","hostname","conflict","lastAutoPull","lastAutoBackup","lastAutoPush","gitPath","pluginDisabled"];for(let r of e){let n=localStorage.getItem(this.prefix+r);this.app.loadLocalStorage(this.prefix+r)==null&&n!=null&&n!=null&&(this.app.saveLocalStorage(this.prefix+r,n),localStorage.removeItem(this.prefix+r))}}getPassword(){return this.app.loadLocalStorage(this.prefix+"password")}setPassword(e){return this.app.saveLocalStorage(this.prefix+"password",e)}getUsername(){return this.app.loadLocalStorage(this.prefix+"username")}setUsername(e){return this.app.saveLocalStorage(this.prefix+"username",e)}getHostname(){return this.app.loadLocalStorage(this.prefix+"hostname")}setHostname(e){return this.app.saveLocalStorage(this.prefix+"hostname",e)}getConflict(){return this.app.loadLocalStorage(this.prefix+"conflict")=="true"}setConflict(e){return this.app.saveLocalStorage(this.prefix+"conflict",`${e}`)}getLastAutoPull(){return this.app.loadLocalStorage(this.prefix+"lastAutoPull")}setLastAutoPull(e){return this.app.saveLocalStorage(this.prefix+"lastAutoPull",e)}getLastAutoBackup(){return this.app.loadLocalStorage(this.prefix+"lastAutoBackup")}setLastAutoBackup(e){return this.app.saveLocalStorage(this.prefix+"lastAutoBackup",e)}getLastAutoPush(){return this.app.loadLocalStorage(this.prefix+"lastAutoPush")}setLastAutoPush(e){return this.app.saveLocalStorage(this.prefix+"lastAutoPush",e)}getGitPath(){return this.app.loadLocalStorage(this.prefix+"gitPath")}setGitPath(e){return this.app.saveLocalStorage(this.prefix+"gitPath",e)}getPATHPaths(){var e,r;return(r=(e=this.app.loadLocalStorage(this.prefix+"PATHPaths"))==null?void 0:e.split(":"))!=null?r:[]}setPATHPaths(e){return this.app.saveLocalStorage(this.prefix+"PATHPaths",e.join(":"))}getEnvVars(){var e;return JSON.parse((e=this.app.loadLocalStorage(this.prefix+"envVars"))!=null?e:"[]")}setEnvVars(e){return this.app.saveLocalStorage(this.prefix+"envVars",JSON.stringify(e))}getPluginDisabled(){return this.app.loadLocalStorage(this.prefix+"pluginDisabled")=="true"}setPluginDisabled(e){return this.app.saveLocalStorage(this.prefix+"pluginDisabled",`${e}`)}getPausedAutomatics(){return this.app.loadLocalStorage(this.prefix+"pausedAutomatics")=="true"}setPausedAutomatics(e){return this.app.saveLocalStorage(this.prefix+"pausedAutomatics",`${e}`)}};m();var Ho=require("obsidian");var Uc=class{constructor(e){this.plugin=e}async hasTooBigFiles(e){let r=await this.plugin.gitManager.branchInfo(),n=r.tracking?ki(r.tracking)[0]:null;if(!n)return!1;let i=await this.plugin.gitManager.getRemoteUrl(n);if(i!=null&&i.includes("github.com")){let a=[],s=this.plugin.gitManager;for(let o of e){let l=this.plugin.app.vault.getAbstractFileByPath(o.vaultPath),c=!1;if(l instanceof Ho.TFile)l.stat.size>=1e8&&(c=!0);else{let u=await this.plugin.app.vault.adapter.stat(o.vaultPath);u&&u.size>=1e8&&(c=!0)}if(c){let u=!1;s instanceof Ce&&(u=await s.isFileTrackedByLFS(o.path)),u||a.push(o)}}if(a.length>0)return this.plugin.displayError(`Aborted commit, because the following files are too big: +- ${a.map(o=>o.vaultPath).join(` +- `)} +Please remove them or add to .gitignore.`),!0}return!1}async writeAndOpenFile(e){e!==void 0&&await this.plugin.app.vault.adapter.write(To,e);let r=!1;this.plugin.app.workspace.iterateAllLeaves(n=>{n.getDisplayText()!=""&&To.startsWith(n.getDisplayText())&&(r=!0)}),r||await this.plugin.app.workspace.openLinkText(To,"/",!0)}openDiff({aFile:e,bFile:r,aRef:n,bRef:i,event:a}){var l,c;let s=this.plugin.settings.diffStyle;Ho.Platform.isMobileApp&&(s="git_unified");let o={aFile:e,bFile:r!=null?r:e,aRef:n,bRef:i};s=="split"?(l=vn(this.plugin.app,a))==null||l.setViewState({type:ca.type,active:!0,state:o}):s=="git_unified"&&((c=vn(this.plugin.app,a))==null||c.setViewState({type:ua.type,active:!0,state:o}))}async runRawCommand(){let e=this.plugin.gitManager;if(!(e instanceof Ce))return;let n=await new ze(this.plugin,{placeholder:"push origin master",allowEmpty:!1}).openAndGetResult();n!==void 0&&this.plugin.promiseQueue.addTask(async()=>{let i=new Ho.Notice(`Running '${n}'...`,999999);try{let a=await e.rawCommand(n);a?(i.setMessage(a),window.setTimeout(()=>i.hide(),5e3)):i.hide()}catch(a){throw i.hide(),a}})}};m();m();m();m();var Ke;(function(t){t.INSERT="insert",t.DELETE="delete",t.CONTEXT="context"})(Ke||(Ke={}));var lM={LINE_BY_LINE:"line-by-line",SIDE_BY_SIDE:"side-by-side"},cM={LINES:"lines",WORDS:"words",NONE:"none"},uM={WORD:"word",CHAR:"char"},as;(function(t){t.AUTO="auto",t.DARK="dark",t.LIGHT="light"})(as||(as={}));m();var SU=["-","[","]","/","{","}","(",")","*","+","?",".","\\","^","$","|"],EU=RegExp("["+SU.join("\\")+"]","g");function fM(t){return t.replace(EU,"\\$&")}function Hv(t){return t&&t.replace(/\\/g,"/")}function dM(t){let e,r,n,i=0;for(e=0,n=t.length;e1?r[r.length-1]:e}function pM(t,e){return e.reduce((r,n)=>r||t.startsWith(n),!1)}var mM=["a/","b/","i/","w/","c/","o/"];function ga(t,e,r){let n=r!==void 0?[...mM,r]:mM,i=e?new RegExp(`^${fM(e)} "?(.+?)"?$`):new RegExp('^"?(.+?)"?$'),[,a=""]=i.exec(t)||[],s=n.find(l=>a.indexOf(l)===0);return(s?a.slice(s.length):a).replace(/\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [+-]\d{4}.*$/,"")}function AU(t,e){return ga(t,"---",e)}function kU(t,e){return ga(t,"+++",e)}function gM(t,e={}){let r=[],n=null,i=null,a=null,s=null,o=null,l=null,c=null,u="--- ",f="+++ ",d="@@",h=/^old mode (\d{6})/,p=/^new mode (\d{6})/,g=/^deleted file mode (\d{6})/,v=/^new file mode (\d{6})/,y=/^copy from "?(.+)"?/,b=/^copy to "?(.+)"?/,E=/^rename from "?(.+)"?/,S=/^rename to "?(.+)"?/,A=/^similarity index (\d+)%/,k=/^dissimilarity index (\d+)%/,w=/^index ([\da-z]+)\.\.([\da-z]+)\s*(\d{6})?/,x=/^Binary files (.*) and (.*) differ/,_=/^GIT binary patch/,T=/^index ([\da-z]+),([\da-z]+)\.\.([\da-z]+)/,C=/^mode (\d{6}),(\d{6})\.\.(\d{6})/,I=/^new file mode (\d{6})/,L=/^deleted file mode (\d{6}),(\d{6})/,$=t.replace(/\\ No newline at end of file/g,"").replace(/\r\n?/g,` +`).split(` +`);function J(){i!==null&&n!==null&&(n.blocks.push(i),i=null)}function de(){n!==null&&(!n.oldName&&l!==null&&(n.oldName=l),!n.newName&&c!==null&&(n.newName=c),n.newName&&(r.push(n),n=null)),l=null,c=null}function le(){J(),de(),n={blocks:[],deletedLines:0,addedLines:0}}function ce(N){J();let W;n!==null&&((W=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(N))?(n.isCombined=!1,a=parseInt(W[1],10),o=parseInt(W[2],10)):(W=/^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(N))?(n.isCombined=!0,a=parseInt(W[1],10),s=parseInt(W[2],10),o=parseInt(W[3],10)):(N.startsWith(d)&&console.error("Failed to parse lines, starting in 0!"),a=0,o=0,n.isCombined=!1)),i={lines:[],oldStartLine:a,oldStartLine2:s,newStartLine:o,header:N}}function Te(N){if(n===null||i===null||a===null||o===null)return;let W={content:N},B=n.isCombined?["+ "," +","++"]:["+"],$e=n.isCombined?["- "," -","--"]:["-"];pM(N,B)?(n.addedLines++,W.type=Ke.INSERT,W.oldNumber=void 0,W.newNumber=o++):pM(N,$e)?(n.deletedLines++,W.type=Ke.DELETE,W.oldNumber=a++,W.newNumber=void 0):(W.type=Ke.CONTEXT,W.oldNumber=a++,W.newNumber=o++),i.lines.push(W)}function ne(N,W){let B=W;for(;B<$.length-3;){if(N.startsWith("diff"))return!1;if($[B].startsWith(u)&&$[B+1].startsWith(f)&&$[B+2].startsWith(d))return!0;B++}return!1}return $.forEach((N,W)=>{if(!N||N.startsWith("*"))return;let B,$e=$[W-1],lr=$[W+1],Ut=$[W+2];if(N.startsWith("diff --git")||N.startsWith("diff --combined")){if(le(),(B=/^diff --git "?([a-ciow]\/.+)"? "?([a-ciow]\/.+)"?/.exec(N))&&(l=ga(B[1],void 0,e.dstPrefix),c=ga(B[2],void 0,e.srcPrefix)),n===null)throw new Error("Where is my file !!!");n.isGitDiff=!0;return}if(N.startsWith("Binary files")&&!(n!=null&&n.isGitDiff)){if(le(),(B=/^Binary files "?([a-ciow]\/.+)"? and "?([a-ciow]\/.+)"? differ/.exec(N))&&(l=ga(B[1],void 0,e.dstPrefix),c=ga(B[2],void 0,e.srcPrefix)),n===null)throw new Error("Where is my file !!!");n.isBinary=!0;return}if((!n||!n.isGitDiff&&n&&N.startsWith(u)&&lr.startsWith(f)&&Ut.startsWith(d))&&le(),n!=null&&n.isTooBig)return;if(n&&(typeof e.diffMaxChanges=="number"&&n.addedLines+n.deletedLines>e.diffMaxChanges||typeof e.diffMaxLineLength=="number"&&N.length>e.diffMaxLineLength)){n.isTooBig=!0,n.addedLines=0,n.deletedLines=0,n.blocks=[],i=null;let Oe=typeof e.diffTooBigMessage=="function"?e.diffTooBigMessage(r.length):"Diff too big to be displayed";ce(Oe);return}if(N.startsWith(u)&&lr.startsWith(f)||N.startsWith(f)&&$e.startsWith(u)){if(n&&!n.oldName&&N.startsWith("--- ")&&(B=AU(N,e.srcPrefix))){n.oldName=B,n.language=hM(n.oldName,n.language);return}if(n&&!n.newName&&N.startsWith("+++ ")&&(B=kU(N,e.dstPrefix))){n.newName=B,n.language=hM(n.newName,n.language);return}}if(n&&(N.startsWith(d)||n.isGitDiff&&n.oldName&&n.newName&&!i)){ce(N);return}if(i&&(N.startsWith("+")||N.startsWith("-")||N.startsWith(" "))){Te(N);return}let X=!ne(N,W);if(n===null)throw new Error("Where is my file !!!");(B=h.exec(N))?n.oldMode=B[1]:(B=p.exec(N))?n.newMode=B[1]:(B=g.exec(N))?(n.deletedFileMode=B[1],n.isDeleted=!0):(B=v.exec(N))?(n.newFileMode=B[1],n.isNew=!0):(B=y.exec(N))?(X&&(n.oldName=B[1]),n.isCopy=!0):(B=b.exec(N))?(X&&(n.newName=B[1]),n.isCopy=!0):(B=E.exec(N))?(X&&(n.oldName=B[1]),n.isRename=!0):(B=S.exec(N))?(X&&(n.newName=B[1]),n.isRename=!0):(B=x.exec(N))?(n.isBinary=!0,n.oldName=ga(B[1],void 0,e.srcPrefix),n.newName=ga(B[2],void 0,e.dstPrefix),ce("Binary file")):_.test(N)?(n.isBinary=!0,ce(N)):(B=A.exec(N))?n.unchangedPercentage=parseInt(B[1],10):(B=k.exec(N))?n.changedPercentage=parseInt(B[1],10):(B=w.exec(N))?(n.checksumBefore=B[1],n.checksumAfter=B[2],B[3]&&(n.mode=B[3])):(B=T.exec(N))?(n.checksumBefore=[B[2],B[3]],n.checksumAfter=B[1]):(B=C.exec(N))?(n.oldMode=[B[2],B[3]],n.newMode=B[1]):(B=I.exec(N))?(n.newFileMode=B[1],n.isNew=!0):(B=L.exec(N))&&(n.deletedFileMode=B[1],n.isDeleted=!0)}),J(),de(),r}m();m();m();function CU(t,e){if(t.length===0)return e.length;if(e.length===0)return t.length;let r=[],n;for(n=0;n<=e.length;n++)r[n]=[n];let i;for(i=0;i<=t.length;i++)r[0][i]=i;for(n=1;n<=e.length;n++)for(i=1;i<=t.length;i++)e.charAt(n-1)===t.charAt(i-1)?r[n][i]=r[n-1][i-1]:r[n][i]=Math.min(r[n-1][i-1]+1,Math.min(r[n][i-1]+1,r[n-1][i]+1));return r[e.length][t.length]}function Uo(t){return(e,r)=>{let n=t(e).trim(),i=t(r).trim();return CU(n,i)/(n.length+i.length)}}function Go(t){function e(n,i,a=new Map){let s=1/0,o;for(let l=0;l0||o.indexB>0)&&(E=v.concat(E)),(n.length>d||i.length>h)&&(E=E.concat(b)),E}return r}var Dt={INSERTS:"d2h-ins",DELETES:"d2h-del",CONTEXT:"d2h-cntx",INFO:"d2h-info",INSERT_CHANGES:"d2h-ins d2h-change",DELETE_CHANGES:"d2h-del d2h-change"},ss={matching:cM.NONE,matchWordsThreshold:.25,maxLineLengthHighlight:1e4,diffStyle:uM.WORD,colorScheme:as.LIGHT},Zn="/",vM=Uo(t=>t.value),PU=Go(vM);function Gv(t){return t.indexOf("dev/null")!==-1}function RU(t){return t.replace(/(]*>((.|\n)*?)<\/ins>)/g,"")}function MU(t){return t.replace(/(]*>((.|\n)*?)<\/del>)/g,"")}function zo(t){switch(t){case Ke.CONTEXT:return Dt.CONTEXT;case Ke.INSERT:return Dt.INSERTS;case Ke.DELETE:return Dt.DELETES}}function Vo(t){switch(t){case as.DARK:return"d2h-dark-color-scheme";case as.AUTO:return"d2h-auto-color-scheme";case as.LIGHT:default:return"d2h-light-color-scheme"}}function OU(t){return t?2:1}function va(t){return t.slice(0).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function en(t,e,r=!0){let n=OU(e);return{prefix:t.substring(0,n),content:r?va(t.substring(n)):t.substring(n)}}function os(t){let e=Hv(t.oldName),r=Hv(t.newName);if(e!==r&&!Gv(e)&&!Gv(r)){let n=[],i=[],a=e.split(Zn),s=r.split(Zn),o=a.length,l=s.length,c=0,u=o-1,f=l-1;for(;cc&&f>c&&a[u]===s[f];)i.unshift(s[f]),u-=1,f-=1;let d=n.join(Zn),h=i.join(Zn),p=a.slice(c,u+1).join(Zn),g=s.slice(c,f+1).join(Zn);return d.length&&h.length?d+Zn+"{"+p+" \u2192 "+g+"}"+Zn+h:d.length?d+Zn+"{"+p+" \u2192 "+g+"}":h.length?"{"+p+" \u2192 "+g+"}"+Zn+h:e+" \u2192 "+r}else return Gv(r)?e:r}function qo(t){return`d2h-${dM(os(t)).toString().slice(-6)}`}function Wo(t){let e="file-changed";return t.isRename||t.isCopy?e="file-renamed":t.isNew?e="file-added":t.isDeleted?e="file-deleted":t.newName!==t.oldName&&(e="file-renamed"),e}function wh(t,e,r,n={}){let{matching:i,maxLineLengthHighlight:a,matchWordsThreshold:s,diffStyle:o}=Object.assign(Object.assign({},ss),n),l=en(t,r,!1),c=en(e,r,!1);if(l.content.length>a||c.content.length>a)return{oldLine:{prefix:l.prefix,content:va(l.content)},newLine:{prefix:c.prefix,content:va(c.content)}};let u=o==="char"?E3(l.content,c.content):k3(l.content,c.content),f=[];if(o==="word"&&i==="words"){let h=u.filter(v=>v.removed),p=u.filter(v=>v.added);PU(p,h).forEach(v=>{v[0].length===1&&v[1].length===1&&vM(v[0][0],v[1][0]){let g=p.added?"ins":p.removed?"del":null,v=f.indexOf(p)>-1?' class="d2h-change"':"",y=va(p.value);return g!==null?`${h}<${g}${v}>${y}`:`${h}${y}`},"");return{oldLine:{prefix:l.prefix,content:RU(d)},newLine:{prefix:c.prefix,content:MU(d)}}}var yM="file-summary",IU="icon",FU={colorScheme:ss.colorScheme},bh=class{constructor(e,r={}){this.hoganUtils=e,this.config=Object.assign(Object.assign({},FU),r)}render(e){let r=e.map(n=>this.hoganUtils.render(yM,"line",{fileHtmlId:qo(n),oldName:n.oldName,newName:n.newName,fileName:os(n),deletedLines:"-"+n.deletedLines,addedLines:"+"+n.addedLines},{fileIcon:this.hoganUtils.template(IU,Wo(n))})).join(` +`);return this.hoganUtils.render(yM,"wrapper",{colorScheme:Vo(this.config.colorScheme),filesNumber:e.length,files:r})}};m();var Vv=Object.assign(Object.assign({},ss),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),Gc="generic",wM="line-by-line",$U="icon",DU="tag",zc=class{constructor(e,r={}){this.hoganUtils=e,this.config=Object.assign(Object.assign({},Vv),r)}render(e){let r=e.map(n=>{let i;return n.blocks.length?i=this.generateFileHtml(n):i=this.generateEmptyDiff(),this.makeFileDiffHtml(n,i)}).join(` +`);return this.hoganUtils.render(Gc,"wrapper",{colorScheme:Vo(this.config.colorScheme),content:r})}makeFileDiffHtml(e,r){if(this.config.renderNothingWhenEmpty&&Array.isArray(e.blocks)&&e.blocks.length===0)return"";let n=this.hoganUtils.template(wM,"file-diff"),i=this.hoganUtils.template(Gc,"file-path"),a=this.hoganUtils.template($U,"file"),s=this.hoganUtils.template(DU,Wo(e));return n.render({file:e,fileHtmlId:qo(e),diffs:r,filePath:i.render({fileDiffName:os(e)},{fileIcon:a,fileTag:s})})}generateEmptyDiff(){return this.hoganUtils.render(Gc,"empty-diff",{contentClass:"d2h-code-line",CSSLineClass:Dt})}generateFileHtml(e){let r=Go(Uo(n=>en(n.content,e.isCombined).content));return e.blocks.map(n=>{let i=this.hoganUtils.render(Gc,"block-header",{CSSLineClass:Dt,blockHeader:e.isTooBig?n.header:va(n.header),lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line"});return this.applyLineGroupping(n).forEach(([a,s,o])=>{if(s.length&&o.length&&!a.length)this.applyRematchMatching(s,o,r).map(([l,c])=>{let{left:u,right:f}=this.processChangedLines(e,e.isCombined,l,c);i+=u,i+=f});else if(a.length)a.forEach(l=>{let{prefix:c,content:u}=en(l.content,e.isCombined);i+=this.generateSingleLineHtml(e,{type:Dt.CONTEXT,prefix:c,content:u,oldNumber:l.oldNumber,newNumber:l.newNumber})});else if(s.length||o.length){let{left:l,right:c}=this.processChangedLines(e,e.isCombined,s,o);i+=l,i+=c}else console.error("Unknown state reached while processing groups of lines",a,s,o)}),i}).join(` +`)}applyLineGroupping(e){let r=[],n=[],i=[];for(let a=0;a0)&&(r.push([[],n,i]),n=[],i=[]),s.type===Ke.CONTEXT?r.push([[s],[],[]]):s.type===Ke.INSERT&&n.length===0?r.push([[],[],[s]]):s.type===Ke.INSERT&&n.length>0?i.push(s):s.type===Ke.DELETE&&n.push(s)}return(n.length||i.length)&&(r.push([[],n,i]),n=[],i=[]),r}applyRematchMatching(e,r,n){let i=e.length*r.length,a=yh(e.concat(r).map(o=>o.content.length));return i{let i;return n.blocks.length?i=this.generateFileHtml(n):i=this.generateEmptyDiff(),this.makeFileDiffHtml(n,i)}).join(` +`);return this.hoganUtils.render(Vc,"wrapper",{colorScheme:Vo(this.config.colorScheme),content:r})}makeFileDiffHtml(e,r){if(this.config.renderNothingWhenEmpty&&Array.isArray(e.blocks)&&e.blocks.length===0)return"";let n=this.hoganUtils.template(LU,"file-diff"),i=this.hoganUtils.template(Vc,"file-path"),a=this.hoganUtils.template(jU,"file"),s=this.hoganUtils.template(NU,Wo(e));return n.render({file:e,fileHtmlId:qo(e),diffs:r,filePath:i.render({fileDiffName:os(e)},{fileIcon:a,fileTag:s})})}generateEmptyDiff(){return{right:"",left:this.hoganUtils.render(Vc,"empty-diff",{contentClass:"d2h-code-side-line",CSSLineClass:Dt})}}generateFileHtml(e){let r=Go(Uo(n=>en(n.content,e.isCombined).content));return e.blocks.map(n=>{let i={left:this.makeHeaderHtml(n.header,e),right:this.makeHeaderHtml("")};return this.applyLineGroupping(n).forEach(([a,s,o])=>{if(s.length&&o.length&&!a.length)this.applyRematchMatching(s,o,r).map(([l,c])=>{let{left:u,right:f}=this.processChangedLines(e.isCombined,l,c);i.left+=u,i.right+=f});else if(a.length)a.forEach(l=>{let{prefix:c,content:u}=en(l.content,e.isCombined),{left:f,right:d}=this.generateLineHtml({type:Dt.CONTEXT,prefix:c,content:u,number:l.oldNumber},{type:Dt.CONTEXT,prefix:c,content:u,number:l.newNumber});i.left+=f,i.right+=d});else if(s.length||o.length){let{left:l,right:c}=this.processChangedLines(e.isCombined,s,o);i.left+=l,i.right+=c}else console.error("Unknown state reached while processing groups of lines",a,s,o)}),i}).reduce((n,i)=>({left:n.left+i.left,right:n.right+i.right}),{left:"",right:""})}applyLineGroupping(e){let r=[],n=[],i=[];for(let a=0;a0)&&(r.push([[],n,i]),n=[],i=[]),s.type===Ke.CONTEXT?r.push([[s],[],[]]):s.type===Ke.INSERT&&n.length===0?r.push([[],[],[s]]):s.type===Ke.INSERT&&n.length>0?i.push(s):s.type===Ke.DELETE&&n.push(s)}return(n.length||i.length)&&(r.push([[],n,i]),n=[],i=[]),r}applyRematchMatching(e,r,n){let i=e.length*r.length,a=yh(e.concat(r).map(o=>o.content.length));return i'),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(n.rp("'),n.b(n.v(n.f("fileName",t,e,0))),n.b(""),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(' '),n.b(n.v(n.f("addedLines",t,e,0))),n.b(""),n.b(` +`+r),n.b(' '),n.b(n.v(n.f("deletedLines",t,e,0))),n.b(""),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b(""),n.fl()},partials:{"'),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b(' Files changed ('),n.b(n.v(n.f("filesNumber",t,e,0))),n.b(")"),n.b(` +`+r),n.b(' hide'),n.b(` +`+r),n.b(' show'),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b('
      '),n.b(` +`+r),n.b(" "),n.b(n.t(n.f("files",t,e,0))),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b(""),n.fl()},partials:{},subs:{}});dt["generic-block-header"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b(""),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b('
    '),n.s(n.f("blockHeader",t,e,1),t,e,0,156,173,"{{ }}")&&(n.rs(t,e,function(i,a,s){s.b(s.t(s.f("blockHeader",i,a,0)))}),t.pop()),n.s(n.f("blockHeader",t,e,1),t,e,1,0,0,"")||n.b(" "),n.b("
    "),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b(""),n.fl()},partials:{},subs:{}});dt["generic-empty-diff"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b(""),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b(" File without changes"),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b(""),n.fl()},partials:{},subs:{}});dt["generic-file-path"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b(''),n.b(` +`+r),n.b(n.rp("'),n.b(n.v(n.f("fileDiffName",t,e,0))),n.b(""),n.b(` +`+r),n.b(n.rp(""),n.b(` +`+r),n.b('"),n.fl()},partials:{""),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(" "),n.b(n.t(n.f("lineNumber",t,e,0))),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.s(n.f("prefix",t,e,1),t,e,0,162,238,"{{ }}")&&(n.rs(t,e,function(i,a,s){s.b(' '),s.b(s.t(s.f("prefix",i,a,0))),s.b(""),s.b(` +`+r)}),t.pop()),n.s(n.f("prefix",t,e,1),t,e,1,0,0,"")||(n.b('  '),n.b(` +`+r)),n.s(n.f("content",t,e,1),t,e,0,371,445,"{{ }}")&&(n.rs(t,e,function(i,a,s){s.b(' '),s.b(s.t(s.f("content",i,a,0))),s.b(""),s.b(` +`+r)}),t.pop()),n.s(n.f("content",t,e,1),t,e,1,0,0,"")||(n.b('
    '),n.b(` +`+r)),n.b("
    "),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b(""),n.fl()},partials:{},subs:{}});dt["generic-wrapper"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('
    '),n.b(` +`+r),n.b(" "),n.b(n.t(n.f("content",t,e,0))),n.b(` +`+r),n.b("
    "),n.fl()},partials:{},subs:{}});dt["icon-file-added"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('"),n.fl()},partials:{},subs:{}});dt["icon-file-changed"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('"),n.fl()},partials:{},subs:{}});dt["icon-file-deleted"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('"),n.fl()},partials:{},subs:{}});dt["icon-file-renamed"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('"),n.fl()},partials:{},subs:{}});dt["icon-file"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('"),n.fl()},partials:{},subs:{}});dt["line-by-line-file-diff"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('
    '),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b(" "),n.b(n.t(n.f("filePath",t,e,0))),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(" "),n.b(n.t(n.f("diffs",t,e,0))),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.fl()},partials:{},subs:{}});dt["line-by-line-numbers"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('
    '),n.b(n.v(n.f("oldNumber",t,e,0))),n.b("
    "),n.b(` +`+r),n.b('
    '),n.b(n.v(n.f("newNumber",t,e,0))),n.b("
    "),n.fl()},partials:{},subs:{}});dt["side-by-side-file-diff"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('
    '),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b(" "),n.b(n.t(n.f("filePath",t,e,0))),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(" "),n.b(n.t(n.d("diffs.left",t,e,0))),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b('
    '),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(' '),n.b(` +`+r),n.b(" "),n.b(n.t(n.d("diffs.right",t,e,0))),n.b(` +`+r),n.b(" "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.b(` +`+r),n.b("
    "),n.fl()},partials:{},subs:{}});dt["tag-file-added"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('ADDED'),n.fl()},partials:{},subs:{}});dt["tag-file-changed"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('CHANGED'),n.fl()},partials:{},subs:{}});dt["tag-file-deleted"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('DELETED'),n.fl()},partials:{},subs:{}});dt["tag-file-renamed"]=new ht.Template({code:function(t,e,r){var n=this;return n.b(r=r||""),n.b('RENAMED'),n.fl()},partials:{},subs:{}});var Wc=class{constructor({compiledTemplates:e={},rawTemplates:r={}}){let n=Object.entries(r).reduce((i,[a,s])=>{let o=Kv.compile(s,{asString:!1});return Object.assign(Object.assign({},i),{[a]:o})},{});this.preCompiledTemplates=Object.assign(Object.assign(Object.assign({},dt),e),n)}static compile(e){return Kv.compile(e,{asString:!1})}render(e,r,n,i,a){let s=this.templateKey(e,r);try{return this.preCompiledTemplates[s].render(n,i,a)}catch(o){throw new Error(`Could not find template to render '${s}'`)}}template(e,r){return this.preCompiledTemplates[this.templateKey(e,r)]}templateKey(e,r){return`${e}-${r}`}};var HU=Object.assign(Object.assign(Object.assign({},Vv),qv),{outputFormat:lM.LINE_BY_LINE,drawFileList:!0});function SM(t,e={}){let r=Object.assign(Object.assign({},HU),e),n=typeof t=="string"?gM(t,r):t,i=new Wc(r),{colorScheme:a}=r,s={colorScheme:a},o=r.drawFileList?new bh(i,s).render(n):"",l=r.outputFormat==="side-by-side"?new qc(i,r).render(n):new zc(i,r).render(n);return o+l}var xh=require("obsidian");var ls=class extends xh.ItemView{constructor(r,n){super(r);this.plugin=n;this.gettingDiff=!1;this.parser=new DOMParser,this.navigation=!0,this.gitRefreshRef=this.app.workspace.on("obsidian-git:status-changed",()=>{this.refresh().catch(console.error)})}getViewType(){return ua.type}getDisplayText(){var r;if(((r=this.state)==null?void 0:r.bFile)!=null){let n=this.state.bFile.split("/").last();return n!=null&&n.endsWith(".md")&&(n=n.slice(0,-3)),`Diff: ${n}`}return ua.name}getIcon(){return ua.icon}async setState(r,n){this.state=r,xh.Platform.isMobile&&(this.leaf.view.titleEl.textContent=this.getDisplayText()),await this.refresh()}getState(){return this.state}onClose(){return this.app.workspace.offref(this.gitRefreshRef),this.app.workspace.offref(this.gitViewRefreshRef),super.onClose()}async onOpen(){return await this.refresh(),super.onOpen()}async refresh(){var r;if((r=this.state)!=null&&r.bFile&&!this.gettingDiff&&this.plugin.gitManager){this.gettingDiff=!0;try{let n=await this.plugin.gitManager.getDiffString(this.state.bFile,this.state.aRef=="HEAD",this.state.bRef);this.contentEl.empty();let i=this.plugin.gitManager.getRelativeVaultPath(this.state.bFile);if(!n){if(this.plugin.gitManager instanceof Ce&&await this.plugin.gitManager.isTracked(this.state.bFile))n=[`--- ${this.state.aFile}`,`+++ ${this.state.bFile}`,""].join(` +`);else if(await this.app.vault.adapter.exists(i)){let a=await this.app.vault.adapter.read(i);n=[...`--- /dev/null ++++ ${this.state.bFile} +@@ -0,0 +1,${a.split(` +`).length} @@`.split(` +`),...a.split(` +`).map(o=>`+${o}`)].join(` +`)}}if(n){let a=this.parser.parseFromString(SM(n),"text/html").querySelector(".d2h-file-diff");this.contentEl.append(a)}else{let a=this.contentEl.createDiv({cls:"obsidian-git-center"});a.createSpan({text:"\u26A0\uFE0F",attr:{style:"font-size: 2em"}}),a.createEl("br"),a.createSpan({text:"File not found: "+this.state.bFile})}}finally{this.gettingDiff=!1}}}};m();var Qo=require("obsidian");var el=require("@codemirror/commands");m();var Ie=require("@codemirror/view"),ke=require("@codemirror/state");m();var Zv="\u037C",EM=typeof Symbol=="undefined"?"__"+Zv:Symbol.for(Zv),Jv=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),AM=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},Sh=class{constructor(e,r){this.rules=[];let{finish:n}=r||{};function i(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function a(s,o,l,c){let u=[],f=/^@(\w+)\b/.exec(s[0]),d=f&&f[1]=="keyframes";if(f&&o==null)return l.push(s[0]+";");for(let h in o){let p=o[h];if(/&/.test(h))a(h.split(/,\s*/).map(g=>s.map(v=>g.replace(/&/,v))).reduce((g,v)=>g.concat(v)),p,l);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");a(i(h),p,u,d)}else p!=null&&u.push(h.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(u.length||d)&&l.push((n&&!f&&!c?s.map(n):s).join(", ")+" {"+u.join(" ")+"}")}for(let s in e)a(i(s),e[s],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=AM[EM]||1;return AM[EM]=e+1,Zv+e.toString(36)}static mount(e,r,n){let i=e[Jv],a=n&&n.nonce;i?a&&i.setNonce(a):i=new Qv(e,a),i.mount(Array.isArray(r)?r:[r],e)}},kM=new Map,Qv=class{constructor(e,r){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let a=kM.get(n);if(a)return e[Jv]=a;this.sheet=new i.CSSStyleSheet,kM.set(n,this)}else this.styleTag=n.createElement("style"),r&&this.styleTag.setAttribute("nonce",r);this.modules=[],e[Jv]=this}mount(e,r){let n=this.sheet,i=0,a=0;for(let s=0;s-1&&(this.modules.splice(l,1),a--,l=-1),l==-1){if(this.modules.splice(a++,0,o),n)for(let c=0;cc){let f=t.slice(e,r).indexOf(n.slice(i,a));if(f>-1)return[new pt(e,e+f,i,i),new pt(e+f+c,r,a,a)]}else if(c>l){let f=n.slice(i,a).indexOf(t.slice(e,r));if(f>-1)return[new pt(e,e,i,i+f),new pt(r,r,i+f+l,a)]}if(l==1||c==1)return[new pt(e,r,i,a)];let u=qM(t,e,r,n,i,a);if(u){let[f,d,h]=u;return us(t,e,f,n,i,d).concat(us(t,f+h,r,n,d+h,a))}return GU(t,e,r,n,i,a)}var Yc=1e9,Xc=0,s1=!1;function GU(t,e,r,n,i,a){let s=r-e,o=a-i;if(Yc<1e9&&Math.min(s,o)>Yc*16||Xc>0&&Date.now()>Xc)return Math.min(s,o)>Yc*64?[new pt(e,r,i,a)]:TM(t,e,r,n,i,a);let l=Math.ceil((s+o)/2);e1.reset(l),t1.reset(l);let c=(h,p)=>t.charCodeAt(e+h)==n.charCodeAt(i+p),u=(h,p)=>t.charCodeAt(r-h-1)==n.charCodeAt(a-p-1),f=(s-o)%2!=0?t1:null,d=f?null:e1;for(let h=0;hYc||Xc>0&&!(h&63)&&Date.now()>Xc)return TM(t,e,r,n,i,a);let p=e1.advance(h,s,o,l,f,!1,c)||t1.advance(h,s,o,l,d,!0,u);if(p)return zU(t,e,r,e+p[0],n,i,a,i+p[1])}return[new pt(e,r,i,a)]}var Ch=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let r=0;rr)this.end+=2;else if(f>n)this.start+=2;else if(a){let d=i+(r-n)-l;if(d>=0&&d=r-u)return[h,i+h-d]}else{let h=r-a.vec[d];if(u>=h)return[u,f]}}}return null}},e1=new Ch,t1=new Ch;function zU(t,e,r,n,i,a,s,o){let l=!1;return!Ko(t,n)&&++n==r&&(l=!0),!Ko(i,o)&&++o==s&&(l=!0),l?[new pt(e,r,a,s)]:us(t,e,n,i,a,o).concat(us(t,n,r,i,o,s))}function VM(t,e){let r=1,n=Math.min(t,e);for(;rr||u>a||t.slice(o,c)!=n.slice(l,u)){if(s==1)return o-e-(Ko(t,o)?0:1);s=s>>1}else{if(c==r||u==a)return c-e;o=c,l=u}}}function l1(t,e,r,n,i,a){if(e==r||i==a||t.charCodeAt(r-1)!=n.charCodeAt(a-1))return 0;let s=VM(r-e,a-i);for(let o=r,l=a;;){let c=o-s,u=l-s;if(c>1}else{if(c==e||u==i)return r-c;o=c,l=u}}}function r1(t,e,r,n,i,a,s,o){let l=n.slice(i,a),c=null;for(;;){if(c||s=r)break;let d=t.slice(u,f),h=-1;for(;(h=l.indexOf(d,h+1))!=-1;){let p=o1(t,f,r,n,i+h+d.length,a),g=l1(t,e,u,n,i,i+h),v=d.length+p+g;(!c||c[2]>1}}function qM(t,e,r,n,i,a){let s=r-e,o=a-i;if(si.fromA-e&&n.toB>i.fromB-e&&(t[r-1]=new pt(n.fromA,i.toA,n.fromB,i.toB),t.splice(r--,1))}}function VU(t,e,r){for(;;){WM(r,1);let n=!1;for(let i=0;i3||o>3){let l=i==t.length-1?e.length:t[i+1].fromA,c=a.fromA-n,u=l-a.toA,f=PM(e,a.fromA,c),d=CM(e,a.toA,u),h=a.fromA-f,p=d-a.toA;if((!s||!o)&&h&&p){let g=Math.max(s,o),[v,y,b]=s?[e,a.fromA,a.toA]:[r,a.fromB,a.toB];g>h&&e.slice(f,a.fromA)==v.slice(b-h,b)?(a=t[i]=new pt(f,f+s,a.fromB-h,a.toB-h),f=a.fromA,d=CM(e,a.toA,l-a.toA)):g>p&&e.slice(a.toA,d)==v.slice(y,y+p)&&(a=t[i]=new pt(d-s,d,a.fromB+p,a.toB+p),d=a.toA,f=PM(e,a.fromA,a.fromA-n)),h=a.fromA-f,p=d-a.toA}if(h||p)a=t[i]=new pt(a.fromA-h,a.toA+p,a.fromB-h,a.toB+p);else if(s){if(!o){let g=MM(e,a.fromA,a.toA),v,y=g<0?-1:RM(e,a.toA,a.fromA);g>-1&&(v=g-a.fromA)<=u&&e.slice(a.fromA,g)==e.slice(a.toA,a.toA+v)?a=t[i]=a.offset(v):y>-1&&(v=a.toA-y)<=c&&e.slice(a.fromA-v,a.fromA)==e.slice(y,a.toA)&&(a=t[i]=a.offset(-v))}}else{let g=MM(r,a.fromB,a.toB),v,y=g<0?-1:RM(r,a.toB,a.fromB);g>-1&&(v=g-a.fromB)<=u&&r.slice(a.fromB,g)==r.slice(a.toB,a.toB+v)?a=t[i]=a.offset(v):y>-1&&(v=a.toB-y)<=c&&r.slice(a.fromB-v,a.fromB)==r.slice(y,a.toB)&&(a=t[i]=a.offset(-v))}}n=a.toA}return WM(t,3),t}var cs;try{cs=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(t){}function YM(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function XM(t,e){if(e==t.length)return 0;let r=t.charCodeAt(e);return r<192?YM(r)?1:0:cs?!JM(r)||e==t.length-1?cs.test(String.fromCharCode(r))?1:0:cs.test(t.slice(e,e+2))?2:0:0}function KM(t,e){if(!e)return 0;let r=t.charCodeAt(e-1);return r<192?YM(r)?1:0:cs?!QM(r)||e==1?cs.test(String.fromCharCode(r))?1:0:cs.test(t.slice(e-2,e))?2:0:0}var ZM=8;function CM(t,e,r){if(e==t.length||!KM(t,e))return e;for(let n=e,i=e+r,a=0;ai)return n;n+=s}return e}function PM(t,e,r){if(!e||!XM(t,e))return e;for(let n=e,i=e-r,a=0;at>=55296&&t<=56319,QM=t=>t>=56320&&t<=57343;function Ko(t,e){return!e||e==t.length||!JM(t.charCodeAt(e-1))||!QM(t.charCodeAt(e))}function WU(t,e,r){var n;return Yc=((n=r==null?void 0:r.scanLimit)!==null&&n!==void 0?n:1e9)>>1,Xc=r!=null&&r.timeout?Date.now()+r.timeout:0,s1=!1,VU(t,e,us(t,0,t.length,e,0,e.length))}function eO(){return!s1}function tO(t,e,r){return qU(WU(t,e,r),t,e)}var Jn=ke.Facet.define({combine:t=>t[0]}),n1=ke.StateEffect.define(),YU=ke.Facet.define(),Zo=ke.StateField.define({create(t){return null},update(t,e){for(let r of e.effects)r.is(n1)&&(t=r.value);for(let r of e.state.facet(YU))t=r(t,e);return t}});var Xo=class t{constructor(e,r,n,i,a,s=!0){this.changes=e,this.fromA=r,this.toA=n,this.fromB=i,this.toB=a,this.precise=s}offset(e,r){return e||r?new t(this.changes,this.fromA+e,this.toA+e,this.fromB+r,this.toB+r,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,r,n){let i=tO(e.toString(),r.toString(),n);return rO(i,e,r,0,0,eO())}static updateA(e,r,n,i,a){return DM($M(e,i,!0,n.length),e,r,n,a)}static updateB(e,r,n,i,a){return DM($M(e,i,!1,r.length),e,r,n,a)}};function OM(t,e,r,n){let i=r.lineAt(t),a=n.lineAt(e);return i.to==t&&a.to==e&&tf+1&&v>d+1)break;h.push(p.offset(-c+n,-u+i)),[f,d]=IM(p.toA+n,p.toB+i,e,r),o++}s.push(new Xo(h,c,Math.max(c,f),u,Math.max(u,d),a))}return s}var Eh=1e3;function FM(t,e,r,n){let i=0,a=t.length;for(;;){if(i==a){let u=0,f=0;i&&({toA:u,toB:f}=t[i-1]);let d=e-(r?u:f);return[u+d,f+d]}let s=i+a>>1,o=t[s],[l,c]=r?[o.fromA,o.toA]:[o.fromB,o.toB];if(l>e)a=s;else if(c<=e)i=s+1;else return n?[o.fromA,o.fromB]:[o.toA,o.toB]}}function $M(t,e,r,n){let i=[];return e.iterChangedRanges((a,s,o,l)=>{let c=0,u=r?e.length:n,f=0,d=r?n:e.length;a>Eh&&([c,f]=FM(t,a-Eh,r,!0)),s=c?i[i.length-1]={fromA:p.fromA,fromB:p.fromB,toA:u,toB:d,diffA:p.diffA+g,diffB:p.diffB+v}:i.push({fromA:c,toA:u,fromB:f,toB:d,diffA:g,diffB:v})}),i}function DM(t,e,r,n,i){if(!t.length)return e;let a=[];for(let s=0,o=0,l=0,c=0;;s++){let u=s==t.length?null:t[s],f=u?u.fromA+o:r.length,d=u?u.fromB+l:n.length;for(;cf||v.toB+l>d)break;a.push(v.offset(o,l)),c++}if(!u)break;let h=u.toA+o+u.diffA,p=u.toB+l+u.diffB,g=tO(r.sliceString(f,h),n.sliceString(d,p),i);for(let v of rO(g,r,n,f,d,eO()))a.push(v);for(o+=u.diffA,l+=u.diffB;ch&&v.fromB+l>p)break;c++}}return a}var XU={scanLimit:500},nO=Ie.ViewPlugin.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=NM(t))}update(t){(t.docChanged||t.viewportChanged||KU(t.startState,t.state)||ZU(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=NM(t.view))}},{decorations:t=>t.deco}),Ah=ke.Prec.low((0,Ie.gutter)({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(nO))===null||e===void 0?void 0:e.gutter)||ke.RangeSet.empty}}));function KU(t,e){return t.field(Zo,!1)!=e.field(Zo,!1)}function ZU(t,e){return t.facet(Jn)!=e.facet(Jn)}var LM=Ie.Decoration.line({class:"cm-changedLine"}),JU=Ie.Decoration.mark({class:"cm-changedText"}),QU=Ie.Decoration.mark({tagName:"ins",class:"cm-insertedLine"}),eG=Ie.Decoration.mark({tagName:"del",class:"cm-deletedLine"}),jM=new class extends Ie.GutterMarker{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function tG(t,e,r,n,i,a){let s=r?t.fromA:t.fromB,o=r?t.toA:t.toB,l=0;if(s!=o){i.add(s,s,LM),i.add(s,o,r?eG:QU),a&&a.add(s,s,jM);for(let c=e.iterRange(s,o-1),u=s;!c.next().done;){if(c.lineBreak){u++,i.add(u,u,LM),a&&a.add(u,u,jM);continue}let f=u+c.value.length;if(n)for(;l=u)break;(s?f.toA:f.toB)>c&&(!a||!a(t.state,f,o,l))&&tG(f,t.state.doc,s,n,o,l)}return{deco:o.finish(),gutter:l&&l.finish()}}var Yo=class extends Ie.WidgetType{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Ph=ke.StateEffect.define({map:(t,e)=>t.map(e)}),Kc=ke.StateField.define({create:()=>Ie.Decoration.none,update:(t,e)=>{for(let r of e.effects)if(r.is(Ph))return r.value;return t.map(e.changes)},provide:t=>Ie.EditorView.decorations.from(t)}),kh=.01;function BM(t,e){if(t.size!=e.size)return!1;let r=t.iter(),n=e.iter();for(;r.value;){if(r.from!=n.from||Math.abs(r.value.spec.widget.height-n.value.spec.widget.height)>1)return!1;r.next(),n.next()}return!0}function rG(t,e,r){let n=new ke.RangeSetBuilder,i=new ke.RangeSetBuilder,a=t.state.field(Kc).iter(),s=e.state.field(Kc).iter(),o=0,l=0,c=0,u=0,f=t.viewport,d=e.viewport;for(let v=0;;v++){let y=vkh&&(u+=k,i.add(l,l,Ie.Decoration.widget({widget:new Yo(k),block:!0,side:-1})))}if(b>o+1e3&&of.from&&ld.from){let S=Math.min(f.from-o,d.from-l);o+=S,l+=S,v--}else if(y)o=y.toA,l=y.toB;else break;for(;a.value&&a.fromkh&&i.add(e.state.doc.length,e.state.doc.length,Ie.Decoration.widget({widget:new Yo(h),block:!0,side:1}));let p=n.finish(),g=i.finish();BM(p,t.state.field(Kc))||t.dispatch({effects:Ph.of(p)}),BM(g,e.state.field(Kc))||e.dispatch({effects:Ph.of(g)})}var i1=ke.StateEffect.define({map:(t,e)=>e.mapPos(t)}),a1=class extends Ie.WidgetType{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let r=document.createElement("div");return r.className="cm-collapsedLines",r.textContent=e.state.phrase("$ unchanged lines",this.lines),r.addEventListener("click",n=>{let i=e.posAtDOM(n.target);e.dispatch({effects:i1.of(i)});let{side:a,sibling:s}=e.state.facet(Jn);s&&s().dispatch({effects:i1.of(nG(i,e.state.field(Zo),a=="a"))})}),r}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}};function nG(t,e,r){let n=0,i=0;for(let a=0;;a++){let s=a=t)return i+(t-n);[n,i]=r?[s.toA,s.toB]:[s.toB,s.toA]}}var iG=ke.StateField.define({create(t){return Ie.Decoration.none},update(t,e){t=t.map(e.changes);for(let r of e.effects)r.is(i1)&&(t=t.update({filter:n=>n!=r.value}));return t},provide:t=>Ie.EditorView.decorations.from(t)});function HM({margin:t=3,minSize:e=4}){return iG.init(r=>aG(r,t,e))}function aG(t,e,r){let n=new ke.RangeSetBuilder,i=t.facet(Jn).side=="a",a=t.field(Zo),s=1;for(let o=0;;o++){let l=o=r&&n.add(t.doc.line(c).from,t.doc.line(u).to,Ie.Decoration.replace({widget:new a1(f),block:!0})),!l)break;s=t.doc.lineAt(Math.min(t.doc.length,i?l.toA:l.toB)).number}return n.finish()}var sG=Ie.EditorView.styleModule.of(new Sh({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),oG=Ie.EditorView.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"\u299A"',marginInlineEnd:"7px"},"&:after":{content:'"\u299A"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),UM=new ke.Compartment,Th=new ke.Compartment,Rh=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||XU;let r=[ke.Prec.low(nO),oG,sG,Kc,Ie.EditorView.updateListener.of(f=>{this.measuring<0&&(f.heightChanged||f.viewportChanged)&&!f.transactions.some(d=>d.effects.some(h=>h.is(Ph)))&&this.measure()})],n=[Jn.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(Ah);let i=ke.EditorState.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Ie.EditorView.editorAttributes.of({class:"cm-merge-a"}),Th.of(n),r]}),a=[Jn.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&a.push(Ah);let s=ke.EditorState.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Ie.EditorView.editorAttributes.of({class:"cm-merge-b"}),Th.of(a),r]});this.chunks=Xo.build(i.doc,s.doc,this.diffConf);let o=[Zo.init(()=>this.chunks),UM.of(e.collapseUnchanged?HM(e.collapseUnchanged):[])];i=i.update({effects:ke.StateEffect.appendConfig.of(o)}).state,s=s.update({effects:ke.StateEffect.appendConfig.of(o)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let l=e.orientation||"a-b",c=document.createElement("div");c.className="cm-mergeViewEditor";let u=document.createElement("div");u.className="cm-mergeViewEditor",this.editorDOM.appendChild(l=="a-b"?c:u),this.editorDOM.appendChild(l=="a-b"?u:c),this.a=new Ie.EditorView({state:i,parent:c,root:e.root,dispatchTransactions:f=>this.dispatch(f,this.a)}),this.b=new Ie.EditorView({state:s,parent:u,root:e.root,dispatchTransactions:f=>this.dispatch(f,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,r){if(e.some(n=>n.docChanged)){let n=e[e.length-1],i=e.reduce((s,o)=>s.compose(o.changes),ke.ChangeSet.empty(e[0].startState.doc.length));this.chunks=r==this.a?Xo.updateA(this.chunks,n.newDoc,this.b.state.doc,i,this.diffConf):Xo.updateB(this.chunks,this.a.state.doc,n.newDoc,i,this.diffConf),r.update([...e,n.state.update({effects:n1.of(this.chunks)})]);let a=r==this.a?this.b:this.a;a.update([a.state.update({effects:n1.of(this.chunks)})]),this.scheduleMeasure()}else r.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let a=e.orientation!="b-a";if(a!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let s=this.a.dom.parentNode,o=this.b.dom.parentNode;s.remove(),o.remove(),this.editorDOM.insertBefore(a?s:o,this.editorDOM.firstChild),this.editorDOM.appendChild(a?o:s),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let a=!!this.revertDOM,s=this.revertToA,o=this.renderRevert;"revertControls"in e&&(a=!!e.revertControls,s=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(a,s,o)}let r="highlightChanges"in e,n="gutter"in e,i="collapseUnchanged"in e;if(r||n||i){let a=[],s=[];if(r||n){let o=this.a.state.facet(Jn),l=n?e.gutter!==!1:o.markGutter,c=r?e.highlightChanges!==!1:o.highlightChanges;a.push(Th.reconfigure([Jn.of({side:"a",sibling:()=>this.b,highlightChanges:c,markGutter:l}),l?Ah:[]])),s.push(Th.reconfigure([Jn.of({side:"b",sibling:()=>this.a,highlightChanges:c,markGutter:l}),l?Ah:[]]))}if(i){let o=UM.reconfigure(e.collapseUnchanged?HM(e.collapseUnchanged):[]);a.push(o),s.push(o)}this.a.dispatch({effects:a}),this.b.dispatch({effects:s})}this.scheduleMeasure()}setupRevertControls(e,r,n){this.revertToA=r,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",i=>this.revertClicked(i)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){rG(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,r=e.firstChild,n=this.a.viewport,i=this.b.viewport;for(let a=0;an.to||s.fromB>i.to)break;if(s.fromA-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function GM(t){let e=t.nextSibling;return t.remove(),e}var Mh=require("@codemirror/search"),Jo=require("@codemirror/state"),tn=require("@codemirror/view");var fs=class extends Qo.ItemView{constructor(r,n){super(r);this.plugin=n;this.refreshing=!1;this.ignoreNextModification=!1;this.navigation=!0,this.registerEvent(this.app.workspace.on("obsidian-git:status-changed",()=>{this.mergeView?this.updateRefEditors().catch(console.error):this.createMergeView().catch(console.error)})),this.intervalRef=window.setInterval(()=>{this.mergeView&&this.updateRefEditors().catch(console.error)},30*1e3),this.registerEvent(this.app.vault.on("modify",i=>{this.state.bRef==null&&i.path===this.state.bFile&&(this.ignoreNextModification?this.ignoreNextModification=!1:this.updateModifiableEditor().catch(console.error))})),this.registerEvent(this.app.vault.on("delete",i=>{this.state.bRef==null&&i.path===this.state.bFile&&this.createMergeView().catch(console.error)})),this.registerEvent(this.app.vault.on("create",i=>{this.state.bRef==null&&i.path===this.state.bFile&&this.createMergeView().catch(console.error)})),this.registerEvent(this.app.vault.on("rename",(i,a)=>{this.state.bRef==null&&(i.path===this.state.bFile||a===this.state.bFile)&&this.createMergeView().catch(console.error)})),this.fileSaveDebouncer=(0,Qo.debounce)(i=>{let a=this.state.bFile;a&&(this.ignoreNextModification=!0,this.plugin.app.vault.adapter.write(this.plugin.gitManager.getRelativeVaultPath(a),i).catch(s=>this.plugin.displayError(s)))},1e3,!1)}getViewType(){return ca.type}getDisplayText(){var r;if(((r=this.state)==null?void 0:r.bFile)!=null){let n=this.state.bFile.split("/").last();return n!=null&&n.endsWith(".md")&&(n=n.slice(0,-3)),`Diff: ${n}`}return ca.name}getIcon(){return ca.icon}async setState(r,n){this.state=r,Qo.Platform.isMobile&&(this.leaf.view.titleEl.textContent=this.getDisplayText()),await super.setState(r,n),await this.createMergeView()}getState(){return this.state}onClose(){return window.clearInterval(this.intervalRef),super.onClose()}async onOpen(){return await this.createMergeView(),super.onOpen()}async gitShow(r,n){try{return await this.plugin.gitManager.show(r,n,!1)}catch(i){if(i instanceof wr&&(i.message.includes("does not exist")||i.message.includes("unknown revision or path")||i.message.includes("exists on disk, but not in")||i.message.includes("fatal: bad object")))return i.message.includes("fatal: bad object")&&this.plugin.displayError(i.message),"";throw i}}async bShouldBeEditable(){if(this.state.bRef!=null)return!1;let r=this.plugin.gitManager.getRelativeVaultPath(this.state.bFile);return await this.app.vault.adapter.exists(r)}async updateModifiableEditor(){if(!this.mergeView||this.refreshing)return;let r=this.mergeView.b;this.refreshing=!0;let n=await this.app.vault.adapter.read(this.state.bFile);if(n!=r.state.doc.toString()){let i=r.state.update({changes:{from:0,to:r.state.doc.length,insert:n},annotations:[Jo.Transaction.remote.of(!0)]});r.dispatch(i)}this.refreshing=!1}async updateRefEditors(){if(!this.mergeView||this.refreshing)return;let r=this.mergeView.a,n=this.mergeView.b;this.refreshing=!0;let i=await this.gitShow(this.state.aRef,this.state.aFile),a;if(this.state.bRef!=null&&(a=await this.gitShow(this.state.bRef,this.state.bFile)),i!=r.state.doc.toString()){let s=r.state.update({changes:{from:0,to:r.state.doc.length,insert:i}});r.dispatch(s)}if(a!=null&&a!=n.state.doc.toString()){let s=n.state.update({changes:{from:0,to:n.state.doc.length,insert:a}});n.dispatch(s)}this.refreshing=!1}async createMergeView(){var r,n,i;if((r=this.state)!=null&&r.aFile&&((n=this.state)!=null&&n.bFile)&&!this.refreshing&&this.plugin.gitManager){this.refreshing=!0,(i=this.mergeView)==null||i.destroy();let a=this.containerEl.children[1];a.empty(),this.contentEl.addClass("git-split-diff-view"),this.bIsEditable=await this.bShouldBeEditable();let s=await this.gitShow(this.state.aRef,this.state.aFile),o;if(this.state.bRef!=null)o=await this.gitShow(this.state.bRef,this.state.bFile);else{let p=this.plugin.gitManager.getRelativeVaultPath(this.state.bFile);await this.app.vault.adapter.exists(p)?o=await this.app.vault.adapter.read(p):o=""}let l=[(0,tn.lineNumbers)(),(0,Mh.highlightSelectionMatches)(),(0,tn.drawSelection)(),tn.keymap.of([...el.standardKeymap,el.indentWithTab]),(0,el.history)(),(0,Mh.search)(),tn.EditorView.lineWrapping],c=this,u=tn.ViewPlugin.define(p=>({update(g){if(g.docChanged&&!g.transactions.some(v=>v.annotation(Jo.Transaction.remote))){let v=p.state.doc.toString();c.fileSaveDebouncer(v)}}})),f={doc:s,extensions:[...l,tn.EditorView.editable.of(!1),Jo.EditorState.readOnly.of(!0)]},d=[...l];this.bIsEditable?d.push(u):d.push(tn.EditorView.editable.of(!1),Jo.EditorState.readOnly.of(!0));let h={doc:o,extensions:d};a.addClasses(["cm-s-obsidian","mod-cm6","markdown-source-view","cm-content"]),this.mergeView=new Rh({b:h,a:f,collapseUnchanged:{minSize:6,margin:4},diffConfig:{scanLimit:this.bIsEditable?1e3:1e4},parent:a}),this.refreshing=!1}}};m();var C5=require("obsidian");m();m();m();var iO="5";var aO,sO,oO;typeof window!="undefined"&&((oO=(sO=(aO=window.__svelte)!=null?aO:window.__svelte={}).v)!=null?oO:sO.v=new Set).add(iO);m();m();m();var tl="[",ya="[!",ds="]",Ci={};var qe=Symbol(),rn=Symbol("filename"),lO=Symbol("hmr"),cO="http://www.w3.org/1999/xhtml";m();m();m();m();var Oh=!0;m();var D=!1;m();var nn=Array.isArray,uO=Array.prototype.indexOf,Zc=Array.from,c1=Object.keys,qt=Object.defineProperty,_r=Object.getOwnPropertyDescriptor,u1=Object.getOwnPropertyDescriptors,f1=Object.prototype,fO=Array.prototype,rl=Object.getPrototypeOf,d1=Object.isExtensible;function h1(t){return typeof t=="function"}var ir=()=>{};function Jc(t){for(var e=0;e{t=n,e=i});return{promise:r,resolve:t,reject:e}}m();m();var xr=Symbol("$state"),Qc=Symbol("legacy props"),hO=Symbol(""),Ih=Symbol("proxy path"),nl=new class extends Error{constructor(){super(...arguments);vt(this,"name","StaleReactionError");vt(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var eu=3,an=8;m();m();function pO(){if(D){let t=new Error("await_outside_boundary\nCannot await outside a `` with a `pending` snippet\nhttps://svelte.dev/e/await_outside_boundary");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/await_outside_boundary")}function tu(t){if(D){let e=new Error(`lifecycle_outside_component +\`${t}(...)\` can only be used during component initialisation +https://svelte.dev/e/lifecycle_outside_component`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function mO(){if(D){let t=new Error("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/async_derived_orphan")}function p1(){if(D){let t=new Error("bind_invalid_checkbox_value\nUsing `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead\nhttps://svelte.dev/e/bind_invalid_checkbox_value");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/bind_invalid_checkbox_value")}function gO(){if(D){let t=new Error(`derived_references_self +A derived value cannot reference itself recursively +https://svelte.dev/e/derived_references_self`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/derived_references_self")}function vO(t){if(D){let e=new Error(`effect_in_teardown +\`${t}\` cannot be used inside an effect cleanup function +https://svelte.dev/e/effect_in_teardown`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_in_teardown")}function yO(){if(D){let t=new Error("effect_in_unowned_derived\nEffect cannot be created inside a `$derived` value that was not itself created inside an effect\nhttps://svelte.dev/e/effect_in_unowned_derived");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function wO(t){if(D){let e=new Error(`effect_orphan +\`${t}\` can only be used inside an effect (e.g. during component initialisation) +https://svelte.dev/e/effect_orphan`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_orphan")}function bO(){if(D){let t=new Error(`effect_update_depth_exceeded +Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state +https://svelte.dev/e/effect_update_depth_exceeded`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function _O(){if(D){let t=new Error("flush_sync_in_effect\nCannot use `flushSync` inside an effect\nhttps://svelte.dev/e/flush_sync_in_effect");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/flush_sync_in_effect")}function xO(){if(D){let t=new Error(`hydration_failed +Failed to hydrate the application +https://svelte.dev/e/hydration_failed`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/hydration_failed")}function SO(t){if(D){let e=new Error(`props_invalid_value +Cannot do \`bind:${t}={undefined}\` when \`${t}\` has a fallback value +https://svelte.dev/e/props_invalid_value`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/props_invalid_value")}function EO(t){if(D){let e=new Error(`rune_outside_svelte +The \`${t}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files +https://svelte.dev/e/rune_outside_svelte`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/rune_outside_svelte")}function AO(){if(D){let t=new Error("state_descriptors_fixed\nProperty descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.\nhttps://svelte.dev/e/state_descriptors_fixed");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function kO(){if(D){let t=new Error("state_prototype_fixed\nCannot set prototype of `$state` object\nhttps://svelte.dev/e/state_prototype_fixed");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/state_prototype_fixed")}function TO(){if(D){let t=new Error("state_unsafe_mutation\nUpdating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`\nhttps://svelte.dev/e/state_unsafe_mutation");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/state_unsafe_mutation")}m();m();m();var hs="font-weight: bold",ps="font-weight: normal";function CO(t){D?console.warn(`%c[svelte] await_reactivity_loss +%cDetected reactivity loss when reading \`${t}\`. This happens when state is read in an async function after an earlier \`await\` +https://svelte.dev/e/await_reactivity_loss`,hs,ps):console.warn("https://svelte.dev/e/await_reactivity_loss")}function PO(t,e){D?console.warn(`%c[svelte] await_waterfall +%cAn async derived, \`${t}\` (${e}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app +https://svelte.dev/e/await_waterfall`,hs,ps):console.warn("https://svelte.dev/e/await_waterfall")}function RO(t,e,r){D?console.warn(`%c[svelte] hydration_attribute_changed +%cThe \`${t}\` attribute on \`${e}\` changed its value between server and client renders. The client value, \`${r}\`, will be ignored in favour of the server value +https://svelte.dev/e/hydration_attribute_changed`,hs,ps):console.warn("https://svelte.dev/e/hydration_attribute_changed")}function ms(t){D?console.warn(`%c[svelte] hydration_mismatch +%c${t?`Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${t}`:"Hydration failed because the initial UI does not match what was rendered on the server"} +https://svelte.dev/e/hydration_mismatch`,hs,ps):console.warn("https://svelte.dev/e/hydration_mismatch")}function MO(){D?console.warn(`%c[svelte] lifecycle_double_unmount +%cTried to unmount a component that was not mounted +https://svelte.dev/e/lifecycle_double_unmount`,hs,ps):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function Fh(t){D?console.warn(`%c[svelte] state_proxy_equality_mismatch +%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${t}\` will produce unexpected results +https://svelte.dev/e/state_proxy_equality_mismatch`,hs,ps):console.warn("https://svelte.dev/e/state_proxy_equality_mismatch")}function OO(t){D?console.warn(`%c[svelte] transition_slide_display +%cThe \`slide\` transition does not work correctly for elements with \`display: ${t}\` +https://svelte.dev/e/transition_slide_display`,hs,ps):console.warn("https://svelte.dev/e/transition_slide_display")}var se=!1;function Yt(t){se=t}var ge;function et(t){if(t===null)throw ms(),Ci;return ge=t}function Xt(){return et(jt(ge))}function H(t){if(se){if(jt(ge)!==null)throw ms(),Ci;ge=t}}function il(t=1){if(se){for(var e=t,r=ge;e--;)r=jt(r);ge=r}}function gs(){for(var t=0,e=ge;;){if(e.nodeType===an){var r=e.data;if(r===ds){if(t===0)return e;t-=1}else(r===tl||r===ya)&&(t+=1)}var n=jt(e);e.remove(),e=n}}function $h(t){if(!t||t.nodeType!==an)throw ms(),Ci;return t.data}m();m();m();m();function Dh(t){return t===this.v}function Lh(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function jh(t){return!Lh(t,this.v)}m();var _n=!1,Pi=!1,Qn=!1;m();m();m();var ru=null;function ei(t){let e=Error(),r=e.stack;if(!r)return null;let n=r.split(` +`),i=[` +`];for(let a=0;a"}`,a=e.ctx;a!==null;)i+=` +${n}in ${(o=a.function)==null?void 0:o[rn].split("/").pop()}`,a=a.p;return{message:t.message+` +${i} +`,stack:(l=t.stack)==null?void 0:l.split(` +`).filter(c=>!c.includes("svelte/src/internal")).join(` +`)}}}function $O(t){let e=v1.get(t);e&&(qt(t,"message",{value:e.message}),qt(t,"stack",{value:e.stack}))}m();var au=[],w1=[];function DO(){var t=au;au=[],Jc(t)}function uG(){var t=w1;w1=[],Jc(t)}function Lr(t){au.length===0&&queueMicrotask(DO),au.push(t)}function LO(){au.length>0&&DO(),w1.length>0&&uG()}m();var ane=589952;function Uh(){for(var t=ee.b;t!==null&&!t.has_pending_snippet();)t=t.parent;return t===null&&pO(),t}m();m();var Ii=null;function S1(t){Ii=t}var ou=new Set;function vs(t){var e=2050,r=oe!==null&&oe.f&2?oe:null;ee===null||r!==null&&r.f&256?e|=256:ee.f|=524288;let n={ctx:ye,deps:null,effects:null,equals:Dh,f:e,fn:t,reactions:null,rv:0,v:qe,wv:0,parent:r!=null?r:ee,ac:null};return D&&Qn&&(n.created=ei("CreatedAt")),n}function E1(t,e){let r=ee;r===null&&mO();var n=r.b,i=void 0,a=jr(qe),s=null,o=!oe;return jO(()=>{var h;D&&(Ii=ee);try{var l=t()}catch(p){l=Promise.reject(p)}D&&(Ii=null);var c=()=>l;i=(h=s==null?void 0:s.then(c,c))!=null?h:Promise.resolve(l),s=i;var u=xe,f=n.pending;o&&(n.update_pending_count(1),f||u.increment());let d=(p,g=void 0)=>{s=null,Ii=null,f||u.activate(),g?g!==nl&&(a.f|=8388608,ri(a,g)):(a.f&8388608&&(a.f^=8388608),ri(a,p),D&&e!==void 0&&(ou.add(a),setTimeout(()=>{ou.has(a)&&(PO(a.label,e),ou.delete(a))}))),o&&(n.update_pending_count(-1),f||u.decrement()),Vh()};if(i.then(d,p=>d(null,p||"unknown")),u)return()=>{queueMicrotask(()=>u.neuter())}}),D&&(a.f|=4194304),new Promise(l=>{function c(u){function f(){u===i?l(a):c(i)}u.then(f,f)}c(i)})}function Ct(t){let e=vs(t);return qh(e),e}function ys(t){let e=vs(t);return e.equals=jh,e}function Gh(t){var e=t.effects;if(e!==null){t.effects=null;for(var r=0;rE1(l))).then(l=>{i==null||i.activate(),s();try{r([...t.map(n),...l])}catch(c){a.f&16384||al(c,a)}i==null||i.deactivate(),Vh()}).catch(l=>{o.error(l)})}function dG(){var t=ee,e=oe,r=ye;return function(){Nt(t),kt(e),ba(r),D&&S1(null)}}function Vh(){Nt(null),kt(null),ba(null),D&&S1(null)}var uu=new Set,xe=null,fu=null,_a=null,b1=new Set,Kh=[];function BO(){let t=Kh.shift();Kh.length>0&&queueMicrotask(BO),t()}var _s=[],Qh=null,k1=!1,Yh=!1,ol,ll,xa,du,hu,bs,cl,Sa,Ea,ul,pu,mu,An,HO,Xh,T1,Zh=class Zh{constructor(){yt(this,An);vt(this,"current",new Map);yt(this,ol,new Map);yt(this,ll,new Set);yt(this,xa,0);yt(this,du,null);yt(this,hu,!1);yt(this,bs,[]);yt(this,cl,[]);yt(this,Sa,[]);yt(this,Ea,[]);yt(this,ul,[]);yt(this,pu,[]);yt(this,mu,[]);vt(this,"skipped_effects",new Set)}process(e){var a;_s=[],fu=null;var r=null;if(uu.size>1){r=new Map,_a=new Map;for(let[s,o]of this.current)r.set(s,{v:s.v,wv:s.wv}),s.v=o;for(let s of uu)if(s!==this)for(let[o,l]of ue(s,ol))r.has(o)||(r.set(o,{v:o.v,wv:o.wv}),o.v=l)}for(let s of e)di(this,An,HO).call(this,s);if(ue(this,bs).length===0&&ue(this,xa)===0){di(this,An,T1).call(this);var n=ue(this,Sa),i=ue(this,Ea);It(this,Sa,[]),It(this,Ea,[]),It(this,ul,[]),fu=xe,xe=null,NO(n),NO(i),xe===null?xe=this:uu.delete(this),(a=ue(this,du))==null||a.resolve()}else di(this,An,Xh).call(this,ue(this,Sa)),di(this,An,Xh).call(this,ue(this,Ea)),di(this,An,Xh).call(this,ue(this,ul));if(r){for(let[s,{v:o,wv:l}]of r)s.wv<=l&&(s.v=o);_a=null}for(let s of ue(this,bs))$i(s);for(let s of ue(this,cl))$i(s);It(this,bs,[]),It(this,cl,[])}capture(e,r){ue(this,ol).has(e)||ue(this,ol).set(e,r),this.current.set(e,e.v)}activate(){xe=this}deactivate(){xe=null,fu=null;for(let e of b1)if(b1.delete(e),e(),xe!==null)break}neuter(){It(this,hu,!0)}flush(){_s.length>0?C1():di(this,An,T1).call(this),xe===this&&(ue(this,xa)===0&&uu.delete(this),this.deactivate())}increment(){It(this,xa,ue(this,xa)+1)}decrement(){if(It(this,xa,ue(this,xa)-1),ue(this,xa)===0){for(let e of ue(this,pu))mt(e,2048),ii(e);for(let e of ue(this,mu))mt(e,4096),ii(e);It(this,Sa,[]),It(this,Ea,[]),this.flush()}else this.deactivate()}add_callback(e){ue(this,ll).add(e)}settled(){var e;return((e=ue(this,du))!=null?e:It(this,du,dO())).promise}static ensure(){if(xe===null){let e=xe=new Zh;uu.add(xe),Yh||Zh.enqueue(()=>{xe===e&&e.flush()})}return xe}static enqueue(e){Kh.length===0&&queueMicrotask(BO),Kh.unshift(e)}};ol=new WeakMap,ll=new WeakMap,xa=new WeakMap,du=new WeakMap,hu=new WeakMap,bs=new WeakMap,cl=new WeakMap,Sa=new WeakMap,Ea=new WeakMap,ul=new WeakMap,pu=new WeakMap,mu=new WeakMap,An=new WeakSet,HO=function(e){var u;e.f^=1024;for(var r=e.first;r!==null;){var n=r.f,i=(n&96)!==0,a=i&&(n&1024)!==0,s=a||(n&8192)!==0||this.skipped_effects.has(r);if(!s&&r.fn!==null){if(i)r.f^=1024;else if(!(n&1024))if(n&4)ue(this,Ea).push(r);else if(_n&&n&8)ue(this,Sa).push(r);else if(n&4194304){var o=(u=r.b)!=null&&u.pending?ue(this,cl):ue(this,bs);o.push(r)}else Aa(r)&&(r.f&16&&ue(this,ul).push(r),$i(r));var l=r.first;if(l!==null){r=l;continue}}var c=r.parent;for(r=r.next;r===null&&c!==null;)r=c.next,c=c.parent}},Xh=function(e){for(let r of e)(r.f&2048?ue(this,pu):ue(this,mu)).push(r),mt(r,1024);e.length=0},T1=function(){if(!ue(this,hu))for(let e of ue(this,ll))e();ue(this,ll).clear()};var ti=Zh;function fl(t){_n&&ee!==null&&_O();var e=Yh;Yh=!0;try{var r;for(t&&(C1(),r=t());;){if(LO(),_s.length===0&&(xe==null||xe.flush(),_s.length===0))return Qh=null,r;C1()}}finally{Yh=e}}function C1(){var a;var t=xs;k1=!0;try{var e=0;for(P1(!0);_s.length>0;){var r=ti.ensure();if(e++>1e3){if(D){var n=new Map;for(let s of r.current.keys())for(let[o,l]of(a=s.updated)!=null?a:[]){var i=n.get(o);i||(i={error:l.error,count:0},n.set(o,i)),i.count+=l.count}for(let s of n.values())console.error(s.error)}hG()}r.process(_s),Di.clear()}}finally{k1=!1,P1(t),Qh=null}}function hG(){try{bO()}catch(t){D&&qt(t,"stack",{value:""}),al(t,Qh)}}function NO(t){var e=t.length;if(e!==0){for(var r=0;ri&&n.f&1048576)break}}for(;r0&&!O1&&I1()}return e}function I1(){O1=!1;let t=Array.from(ws);for(let e of t)e.f&1024&&mt(e,4096),Aa(e)&&$i(e);ws.clear()}function su(t){ie(t,t.v+1)}function GO(t,e){var r=t.reactions;if(r!==null)for(var n=on(),i=r.length,a=0;a{if(ka===s)return u();var f=oe,d=ka;kt(null),F1(s);var h=u();return kt(f),F1(d),h};n&&(r.set("length",Pe(t.length,a)),D&&(t=gG(t)));var l="";function c(u){l=u,sn(i,`${l} version`);for(let[f,d]of r)sn(d,Es(l,f))}return new Proxy(t,{defineProperty(u,f,d){(!("value"in d)||d.configurable===!1||d.enumerable===!1||d.writable===!1)&&AO();var h=r.get(f);return h===void 0?h=o(()=>{var p=Pe(d.value,a);return r.set(f,p),D&&typeof f=="string"&&sn(p,Es(l,f)),p}):ie(h,d.value,!0),!0},deleteProperty(u,f){var d=r.get(f);if(d===void 0){if(f in u){let h=o(()=>Pe(qe,a));r.set(f,h),su(i),D&&sn(h,Es(l,f))}}else ie(d,qe),su(i);return!0},get(u,f,d){var v;if(f===xr)return t;if(D&&f===Ih)return c;var h=r.get(f),p=f in u;if(h===void 0&&(!p||(v=_r(u,f))!=null&&v.writable)&&(h=o(()=>{var y=Ne(p?u[f]:qe),b=Pe(y,a);return D&&sn(b,Es(l,f)),b}),r.set(f,h)),h!==void 0){var g=R(h);return g===qe?void 0:g}return Reflect.get(u,f,d)},getOwnPropertyDescriptor(u,f){var d=Reflect.getOwnPropertyDescriptor(u,f);if(d&&"value"in d){var h=r.get(f);h&&(d.value=R(h))}else if(d===void 0){var p=r.get(f),g=p==null?void 0:p.v;if(p!==void 0&&g!==qe)return{enumerable:!0,configurable:!0,value:g,writable:!0}}return d},has(u,f){var g;if(f===xr)return!0;var d=r.get(f),h=d!==void 0&&d.v!==qe||Reflect.has(u,f);if(d!==void 0||ee!==null&&(!h||(g=_r(u,f))!=null&&g.writable)){d===void 0&&(d=o(()=>{var v=h?Ne(u[f]):qe,y=Pe(v,a);return D&&sn(y,Es(l,f)),y}),r.set(f,d));var p=R(d);if(p===qe)return!1}return h},set(u,f,d,h){var k;var p=r.get(f),g=f in u;if(n&&f==="length")for(var v=d;vPe(qe,a)),r.set(v+"",y),D&&sn(y,Es(l,v)))}if(p===void 0)(!g||(k=_r(u,f))!=null&&k.writable)&&(p=o(()=>Pe(void 0,a)),ie(p,Ne(d)),r.set(f,p),D&&sn(p,Es(l,f)));else{g=p.v!==qe;var b=o(()=>Ne(d));ie(p,b)}var E=Reflect.getOwnPropertyDescriptor(u,f);if(E!=null&&E.set&&E.set.call(h,d),!g){if(n&&typeof f=="string"){var S=r.get("length"),A=Number(f);Number.isInteger(A)&&A>=S.v&&ie(S,A+1)}su(i)}return!0},ownKeys(u){R(i);var f=Reflect.ownKeys(u).filter(p=>{var g=r.get(p);return g===void 0||g.v!==qe});for(var[d,h]of r)h.v!==qe&&!(d in u)&&f.push(d);return f},setPrototypeOf(){kO()}})}function Es(t,e){var r;return typeof e=="symbol"?`${t}[Symbol(${(r=e.description)!=null?r:""})]`:pG.test(e)?`${t}.${e}`:/^\d+$/.test(e)?`${t}[${e}]`:`${t}['${e}']`}function ep(t){try{if(t!==null&&typeof t=="object"&&xr in t)return t[xr]}catch(e){}return t}var mG=new Set(["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"]);function gG(t){return new Proxy(t,{get(e,r,n){var i=Reflect.get(e,r,n);return mG.has(r)?function(...a){UO();var s=i.apply(this,a);return I1(),s}:i}})}function VO(){let t=Array.prototype,e=Array.__svelte_cleanup;e&&e();let{indexOf:r,lastIndexOf:n,includes:i}=t;t.indexOf=function(a,s){let o=r.call(this,a,s);if(o===-1){for(let l=s!=null?s:0;l{t.indexOf=r,t.lastIndexOf=n,t.includes=i}}var $1,qO,iu,WO,YO;function tp(){if($1===void 0){$1=window,qO=document,iu=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,r=Text.prototype;WO=_r(e,"firstChild").get,YO=_r(e,"nextSibling").get,d1(t)&&(t.__click=void 0,t.__className=void 0,t.__attributes=null,t.__style=void 0,t.__e=void 0),d1(r)&&(r.__t=void 0),D&&(t.__svelte_meta=null,VO())}}function Bt(t=""){return document.createTextNode(t)}function Ht(t){return WO.call(t)}function jt(t){return YO.call(t)}function G(t,e){if(!se)return Ht(t);var r=Ht(ge);if(r===null)r=ge.appendChild(Bt());else if(e&&r.nodeType!==eu){var n=Bt();return r==null||r.before(n),et(n),n}return et(r),r}function kr(t,e){var i,a;if(!se){var r=Ht(t);return r instanceof Comment&&r.data===""?jt(r):r}if(e&&((i=ge)==null?void 0:i.nodeType)!==eu){var n=Bt();return(a=ge)==null||a.before(n),et(n),n}return ge}function te(t,e=1,r=!1){let n=se?ge:t;for(var i;e--;)i=n,n=jt(n);if(!se)return n;if(r&&(n==null?void 0:n.nodeType)!==eu){var a=Bt();return n===null?i==null||i.after(a):n.before(a),et(a),a}return et(n),n}function dl(t){t.textContent=""}function hl(){if(!_n)return!1;var t=ee.f;return(t&32768)!==0}function KO(t){ee===null&&oe===null&&wO(t),oe!==null&&oe.f&256&&ee===null&&yO(),Sn&&vO(t)}function vG(t,e){var r=e.last;r===null?e.last=e.first=t:(r.next=t,t.prev=r,e.last=t)}function si(t,e,r,n=!0){var l;var i=ee;if(D)for(;i!==null&&i.f&131072;)i=i.parent;i!==null&&i.f&8192&&(t|=8192);var a={ctx:ye,deps:null,nodes_start:null,nodes_end:null,f:t|2048,first:null,fn:e,last:null,next:null,parent:i,b:i&&i.b,prev:null,teardown:null,transitions:null,wv:0,ac:null};if(D&&(a.component_function=xn),r)try{$i(a),a.f|=32768}catch(c){throw At(a),c}else e!==null&&ii(a);var s=r&&a.deps===null&&a.first===null&&a.nodes_start===null&&a.teardown===null&&(a.f&524288)===0;if(!s&&n&&(i!==null&&vG(a,i),oe!==null&&oe.f&2&&!(t&64))){var o=oe;((l=o.effects)!=null?l:o.effects=[]).push(a)}return a}function Hr(t){let e=si(8,null,!1);return mt(e,1024),e.teardown=t,e}function Zt(t){var i;KO("$effect"),D&&qt(t,"name",{value:"$effect"});var e=ee.f,r=!oe&&(e&32)!==0&&(e&32768)===0;if(r){var n=ye;((i=n.e)!=null?i:n.e=[]).push(t)}else return g1(t)}function g1(t){return si(1048580,t,!1)}function L1(t){ti.ensure();let e=si(64,t,!0);return()=>{At(e)}}function ZO(t){ti.ensure();let e=si(64,t,!0);return(r={})=>new Promise(n=>{r.outro?ni(e,()=>{At(e),n(void 0)}):(At(e),n(void 0))})}function Tr(t){return si(4,t,!1)}function jO(t){return si(4718592,t,!0)}function Kt(t,e=0){return si(8|e,t,!0)}function Fe(t,e=[],r=[]){Wh(e,r,n=>{si(8,()=>t(...n.map(R)),!0)})}function Sr(t,e=0){var r=si(16|e,t,!0);return D&&(r.dev_stack=Mi),r}function Et(t,e=!0){return si(32,t,!0,e)}function j1(t){var e=t.teardown;if(e!==null){let r=Sn,n=oe;D1(!0),kt(null);try{e.call(null)}finally{D1(r),kt(n)}}}function N1(t,e=!1){var i;var r=t.first;for(t.first=t.last=null;r!==null;){(i=r.ac)==null||i.abort(nl);var n=r.next;r.f&64?r.parent=null:At(r,e),r=n}}function JO(t){for(var e=t.first;e!==null;){var r=e.next;e.f&32||At(e),e=r}}function At(t,e=!0){var r=!1;(e||t.f&262144)&&t.nodes_start!==null&&t.nodes_end!==null&&(QO(t.nodes_start,t.nodes_end),r=!0),N1(t,e&&!r),yu(t,0),mt(t,16384);var n=t.transitions;if(n!==null)for(let a of n)a.stop();j1(t);var i=t.parent;i!==null&&i.first!==null&&M1(t),D&&(t.component_function=null),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes_start=t.nodes_end=t.ac=null}function QO(t,e){for(;t!==null;){var r=t===e?null:jt(t);t.remove(),t=r}}function M1(t){var e=t.parent,r=t.prev,n=t.next;r!==null&&(r.next=n),n!==null&&(n.prev=r),e!==null&&(e.first===t&&(e.first=n),e.last===t&&(e.last=r))}function ni(t,e){var r=[];rp(t,r,!0),B1(r,()=>{At(t),e&&e()})}function B1(t,e){var r=t.length;if(r>0){var n=()=>--r||e();for(var i of t)i.out(n)}else e()}function rp(t,e,r){if(!(t.f&8192)){if(t.f^=8192,t.transitions!==null)for(let s of t.transitions)(s.is_global||r)&&e.push(s);for(var n=t.first;n!==null;){var i=n.next,a=(n.f&65536)!==0||(n.f&32)!==0;rp(n,e,a?r:!1),n=i}}}function As(t){e5(t,!0)}function e5(t,e){if(t.f&8192){t.f^=8192,t.f&1024||(mt(t,2048),ii(t));for(var r=t.first;r!==null;){var n=r.next,i=(r.f&65536)!==0||(r.f&32)!==0;e5(r,i?e:!1),r=n}if(t.transitions!==null)for(let a of t.transitions)(a.is_global||e)&&a.in()}}m();var t5=null;var xs=!1;function P1(t){xs=t}var Sn=!1;function D1(t){Sn=t}var oe=null,Er=!1;function kt(t){oe=t}var ee=null;function Nt(t){ee=t}var Ar=null;function qh(t){oe!==null&&(!_n||oe.f&2)&&(Ar===null?Ar=[t]:Ar.push(t))}var or=null,Ur=0,Br=null;function zO(t){Br=t}var r5=1,wu=0,ka=wu;function F1(t){ka=t}var Fi=!1;function cu(){return++r5}function Aa(t){var f,d;var e=t.f;if(e&2048)return!0;if(e&4096){var r=t.deps,n=(e&256)!==0;if(r!==null){var i,a,s=(e&512)!==0,o=n&&ee!==null&&!Fi,l=r.length;if((s||o)&&(ee===null||!(ee.f&16384))){var c=t,u=c.parent;for(i=0;it.wv)return!0}(!n||ee!==null&&!Fi)&&mt(t,1024)}return!1}function n5(t,e,r=!0){var n=t.reactions;if(n!==null&&!(!_n&&(Ar!=null&&Ar.includes(t))))for(var i=0;i0)for(d.length=Ur+or.length,h=0;h{Promise.resolve().then(()=>{var e;if(!t.defaultPrevented)for(let r of t.target.elements)(e=r.__on_r)==null||e.call(r)})},{capture:!0}))}function ks(t){var e=oe,r=ee;kt(null),Nt(null);try{return t()}finally{kt(e),Nt(r)}}function G1(t,e,r,n=r){t.addEventListener(e,()=>ks(r));let i=t.__on_r;i?t.__on_r=()=>{i(),n(!0)}:t.__on_r=()=>n(!0),U1()}var z1=new Set,ap=new Set;function s5(t,e,r,n={}){function i(a){if(n.capture||pl.call(e,a),!a.cancelBubble)return ks(()=>r==null?void 0:r.call(this,a))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?Lr(()=>{e.addEventListener(t,i,n)}):e.addEventListener(t,i,n),i}function Gr(t,e,r,n,i){var a={capture:n,passive:i},s=s5(t,e,r,a);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Hr(()=>{e.removeEventListener(t,s,a)})}function gt(t){for(var e=0;e{throw E});throw d}}finally{t.__root=e,delete t.currentTarget,kt(u),Nt(f)}}}m();var bG;function o5(){bG=void 0}m();m();function sp(t){var e=document.createElement("template");return e.innerHTML=t.replaceAll("",""),e.content}function oi(t,e){var r=ee;r.nodes_start===null&&(r.nodes_start=t,r.nodes_end=e)}function fe(t,e){var r=(e&1)!==0,n=(e&2)!==0,i,a=!t.startsWith("");return()=>{if(se)return oi(ge,null),ge;i===void 0&&(i=sp(a?t:""+t),r||(i=Ht(i)));var s=n||iu?document.importNode(i,!0):i.cloneNode(!0);if(r){var o=Ht(s),l=s.lastChild;oi(o,l)}else oi(s,s);return s}}function Li(){if(se)return oi(ge,null),ge;var t=document.createDocumentFragment(),e=document.createComment(""),r=Bt();return t.append(e,r),oi(e,r),t}function ae(t,e){if(se){ee.nodes_end=ge,Xt();return}t!==null&&t.before(e)}m();var EG=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected","webkitdirectory","defer","disablepictureinpicture","disableremoteplayback"];var Yae=[...EG,"formNoValidate","isMap","noModule","playsInline","readOnly","value","volume","defaultValue","defaultChecked","srcObject","noValidate","allowFullscreen","disablePictureInPicture","disableRemotePlayback"];var AG=["touchstart","touchmove"];function c5(t){return AG.includes(t)}var kG=["$state","$state.raw","$derived","$derived.by"],Xae=[...kG,"$state.snapshot","$props","$props.id","$bindable","$effect","$effect.pre","$effect.tracking","$effect.root","$effect.pending","$inspect","$inspect().with","$inspect.trace","$host"];var op=!0;function Be(t,e){var n;var r=e==null?"":typeof e=="object"?e+"":e;r!==((n=t.__t)!=null?n:t.__t=t.nodeValue)&&(t.__t=r,t.nodeValue=r+"")}function Ta(t,e){return u5(t,e)}function q1(t,e){var s;tp(),e.intro=(s=e.intro)!=null?s:!1;let r=e.target,n=se,i=ge;try{for(var a=Ht(r);a&&(a.nodeType!==an||a.data!==tl);)a=jt(a);if(!a)throw Ci;Yt(!0),et(a),Xt();let o=u5(t,{...e,anchor:a});if(ge===null||ge.nodeType!==an||ge.data!==ds)throw ms(),Ci;return Yt(!1),o}catch(o){if(o===Ci)return e.recover===!1&&xO(),tp(),dl(r),Yt(!1),Ta(t,e);throw o}finally{Yt(n),et(i),o5()}}var ml=new Map;function u5(t,{target:e,anchor:r,props:n={},events:i,context:a,intro:s=!0}){tp();var o=new Set,l=f=>{for(var d=0;d{var f=r!=null?r:e.appendChild(Bt());return Et(()=>{if(a){tt({});var d=ye;d.c=a}i&&(n.$$events=i),se&&oi(f,null),op=s,c=t(f,n)||{},op=!0,se&&(ee.nodes_end=ge),a&&rt()}),()=>{var p;for(var d of o){e.removeEventListener(d,pl);var h=ml.get(d);--h===0?(document.removeEventListener(d,pl),ml.delete(d)):ml.set(d,h)}ap.delete(l),f!==r&&((p=f.parentNode)==null||p.removeChild(f))}});return V1.set(c,u),c}var V1=new WeakMap;function ji(t,e){let r=V1.get(t);return r?(V1.delete(t),r(e)):(D&&MO(),Promise.resolve())}m();m();if(D){let t=function(e){if(!(e in globalThis)){let r;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(r!==void 0)return r;EO(e)},set:n=>{r=n}})}};t("$state"),t("$effect"),t("$derived"),t("$inspect"),t("$props"),t("$bindable")}function W1(t){ye===null&&tu("onMount"),Pi&&ye.l!==null?RG(ye).m.push(t):Zt(()=>{let e=Ue(t);if(typeof e=="function")return e})}function d5(t){ye===null&&tu("onDestroy"),W1(()=>()=>Ue(t))}function RG(t){var r;var e=t.l;return(r=e.u)!=null?r:e.u={a:[],b:[],m:[]}}m();m();var p5=new Map;function m5(t,e){var r=p5.get(t);r||(r=new Set,p5.set(t,r)),r.add(e)}m();m();m();m();m();m();m();m();m();function _e(t,e,r=!1){se&&Xt();var n=t,i=null,a=null,s=qe,o=r?65536:0,l=!1;let c=(h,p=!0)=>{l=!0,d(p,h)};var u=null;function f(){u!==null&&(u.lastChild.remove(),n.before(u),u=null);var h=s?i:a,p=s?a:i;h&&As(h),p&&ni(p,()=>{s?a=null:i=null})}let d=(h,p)=>{if(s===(s=h))return;let g=!1;if(se){let A=$h(n)===ya;!!s===A&&(n=gs(),et(n),Yt(!1),g=!0)}var v=hl(),y=n;if(v&&(u=document.createDocumentFragment(),u.append(y=Bt())),s?i!=null||(i=p&&Et(()=>p(y))):a!=null||(a=p&&Et(()=>p(y))),v){var b=xe,E=s?i:a,S=s?a:i;E&&b.skipped_effects.delete(E),S&&b.skipped_effects.add(S),b.add_callback(f)}else f();g&&Yt(!0)};Sr(()=>{l=!1,e(c),l||d(null,null)},o),se&&(n=ge)}m();m();m();var bu=null;function zr(t,e){return e}function $G(t,e,r){for(var n=t.items,i=[],a=e.length,s=0;s0&&i.length===0&&r!==null;if(o){var l=r.parentNode;dl(l),l.append(r),n.clear(),li(t,e[0].prev,e[a-1].next)}B1(i,()=>{for(var c=0;c{var y=r();return nn(y)?y:y==null?[]:Zc(y)}),p,g;function v(){DG(g,p,o,d,s,i,e,n,r),a!==null&&(p.length===0?u?As(u):u=Et(()=>a(s)):u!==null&&ni(u,()=>{u=null}))}Sr(()=>{var I;g!=null||(g=ee),p=R(h);var y=p.length;if(f&&y===0)return;f=y===0;let b=!1;if(se){var E=$h(s)===ya;E!==(y===0)&&(s=gs(),et(s),Yt(!1),b=!0)}if(se){for(var S=null,A,k=0;k0&&et(gs())}if(se)y===0&&a&&(u=Et(()=>a(s)));else if(hl()){var _=new Set,T=xe;for(k=0;k0){var le=s&4&&f===0?i:null;if(c){for(w=0;w{var B;if(y!==void 0)for(k of y)(B=k.a)==null||B.apply()}),t.first=r.first&&r.first.e,t.last=v&&v.e;for(var ce of n.values())At(ce.e);n.clear()}function v5(t,e,r,n){n&1&&ri(t.v,e),n&2?ri(t.i,r):t.i=r}function X1(t,e,r,n,i,a,s,o,l,c,u){var f=bu,d=(l&1)!==0,h=(l&16)===0,p=d?h?Ss(i,!1,!1):jr(i):i,g=l&2?jr(s):s;D&&d&&(p.trace=()=>{var b=typeof g=="number"?s:g.v;c()[b]});var v={i:g,v:p,k:a,a:null,e:null,prev:r,next:n};bu=v;try{if(t===null){var y=document.createDocumentFragment();y.append(t=Bt())}return v.e=Et(()=>o(t,p,g,c),se),v.e.prev=r&&r.e,v.e.next=n&&n.e,r===null?u||(e.first=v):(r.next=v,r.e.next=v.e),n!==null&&(n.prev=v,n.e.prev=v.e),v}finally{bu=f}}function Y1(t,e,r){for(var n=t.next?t.next.e.nodes_start:r,i=e?e.e.nodes_start:r,a=t.e.nodes_start;a!==null&&a!==n;){var s=jt(a);i.before(a),a=s}}function li(t,e,r){e===null?t.first=r:(e.next=r,e.e.next=r&&r.e),r!==null&&(r.prev=e,r.e.prev=e&&e.e)}m();m();m();m();m();function Tn(t,e){Tr(()=>{var i;var r=t.getRootNode(),n=r.host?r:(i=r.head)!=null?i:r.ownerDocument.head;if(!n.querySelector("#"+e.hash)){let a=document.createElement("style");a.id=e.hash,a.textContent=e.code,n.appendChild(a),D&&m5(e.hash,a)}})}m();m();m();m();m();m();var w5=[...` +\r\f\xA0\v\uFEFF`];function b5(t,e,r){var n=t==null?"":""+t;if(e&&(n=n?n+" "+e:e),r){for(var i in r)if(r[i])n=n?n+" "+i:i;else if(n.length)for(var a=i.length,s=0;(s=n.indexOf(i,s))>=0;){var o=s+a;(s===0||w5.includes(n[s-1]))&&(o===n.length||w5.includes(n[o]))?n=(s===0?"":n.substring(0,s))+n.substring(o+1):s=o}}return n===""?null:n}m();function ot(t,e,r,n,i,a){var s=t.__className;if(se||s!==r||s===void 0){var o=b5(r,n,a);(!se||o!==t.getAttribute("class"))&&(o==null?t.removeAttribute("class"):e?t.className=o:t.setAttribute("class",o)),t.__className=r}else if(a&&i!==a)for(var l in a){var c=!!a[l];(i==null||c!==!!i[l])&&t.classList.toggle(l,c)}return a}m();m();var zG=Symbol("class"),VG=Symbol("style"),qG=Symbol("is custom element"),WG=Symbol("is html");function ve(t,e,r,n){var i=YG(t);if(se&&(i[e]=t.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&t.nodeName==="LINK")){n||KG(t,e,r!=null?r:"");return}i[e]!==(i[e]=r)&&(e==="loading"&&(t[hO]=r),r==null?t.removeAttribute(e):typeof r!="string"&&XG(t).includes(e)?t[e]=r:t.setAttribute(e,r))}function YG(t){var e;return(e=t.__attributes)!=null?e:t.__attributes={[qG]:t.nodeName.includes("-"),[WG]:t.namespaceURI===cO}}var _5=new Map;function XG(t){var e=_5.get(t.nodeName);if(e)return e;_5.set(t.nodeName,e=[]);for(var r,n=t,i=Element.prototype;i!==n;){r=u1(n);for(var a in r)r[a].set&&e.push(a);n=rl(n)}return e}function KG(t,e,r){var n;D&&(e==="srcset"&&ZG(t,r)||K1((n=t.getAttribute(e))!=null?n:"",r)||RO(e,t.outerHTML.replace(t.innerHTML,t.innerHTML&&"..."),String(r)))}function K1(t,e){return t===e?!0:new URL(t,document.baseURI).href===new URL(e,document.baseURI).href}function x5(t){return t.split(",").map(e=>e.trim().split(" ").filter(Boolean))}function ZG(t,e){var r=x5(t.srcset),n=x5(e);return n.length===r.length&&n.every(([i,a],s)=>a===r[s][1]&&(K1(r[s][0],i)||K1(i,r[s][0])))}m();m();m();var JG=Oh?()=>performance.now():()=>Date.now(),Cn={tick:t=>(Oh?requestAnimationFrame:ir)(t),now:()=>JG(),tasks:new Set};function S5(){let t=Cn.now();Cn.tasks.forEach(e=>{e.c(t)||(Cn.tasks.delete(e),e.f())}),Cn.tasks.size!==0&&Cn.tick(S5)}function E5(t){let e;return Cn.tasks.size===0&&Cn.tick(S5),{promise:new Promise(r=>{Cn.tasks.add(e={c:t,f:r})}),abort(){Cn.tasks.delete(e)}}}function up(t,e){ks(()=>{t.dispatchEvent(new CustomEvent(e))})}function rz(t){if(t==="float")return"cssFloat";if(t==="offset")return"cssOffset";if(t.startsWith("--"))return t;let e=t.split("-");return e.length===1?e[0]:e[0]+e.slice(1).map(r=>r[0].toUpperCase()+r.slice(1)).join("")}function A5(t){let e={},r=t.split(";");for(let n of r){let[i,a]=n.split(":");if(!i||a===void 0)break;let s=rz(i.trim());e[s]=a.trim()}return e}var nz=t=>t;function Pn(t,e,r,n){var E;var i=(t&1)!==0,a=(t&2)!==0,s=i&&a,o=(t&4)!==0,l=s?"both":i?"in":"out",c,u=e.inert,f=e.style.overflow,d,h;function p(){return ks(()=>{var S;return c!=null?c:c=r()(e,(S=n==null?void 0:n())!=null?S:{},{direction:l})})}var g={is_global:o,in(){var S;if(e.inert=u,!i){h==null||h.abort(),(S=h==null?void 0:h.reset)==null||S.call(h);return}a||d==null||d.abort(),up(e,"introstart"),d=Z1(e,p(),h,1,()=>{up(e,"introend"),d==null||d.abort(),d=c=void 0,e.style.overflow=f})},out(S){if(!a){S==null||S(),c=void 0;return}e.inert=!0,up(e,"outrostart"),h=Z1(e,p(),d,0,()=>{up(e,"outroend"),S==null||S()})},stop:()=>{d==null||d.abort(),h==null||h.abort()}},v=ee;if(((E=v.transitions)!=null?E:v.transitions=[]).push(g),i&&op){var y=o;if(!y){for(var b=v.parent;b&&b.f&65536;)for(;(b=b.parent)&&!(b.f&16););y=!b||(b.f&32768)!==0}y&&Tr(()=>{Ue(()=>g.in())})}}function Z1(t,e,r,n,i){var a=n===1;if(h1(e)){var s,o=!1;return Lr(()=>{if(!o){var v=e({direction:a?"in":"out"});s=Z1(t,v,r,n,i)}}),{abort:()=>{o=!0,s==null||s.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(r==null||r.deactivate(),!(e!=null&&e.duration))return i(),{abort:ir,deactivate:ir,reset:ir,t:()=>n};let{delay:l=0,css:c,tick:u,easing:f=nz}=e;var d=[];if(a&&r===void 0&&(u&&u(0,1),c)){var h=A5(c(0,1));d.push(h,h)}var p=()=>1-n,g=t.animate(d,{duration:l,fill:"forwards"});return g.onfinish=()=>{var _;g.cancel();var v=(_=r==null?void 0:r.t())!=null?_:1-n;r==null||r.abort();var y=n-v,b=e.duration*Math.abs(y),E=[];if(b>0){var S=!1;if(c)for(var A=Math.ceil(b/16.666666666666668),k=0;k<=A;k+=1){var w=v+y*f(k/A),x=A5(c(w,1-w));E.push(x),S||(S=x.overflow==="hidden")}S&&(t.style.overflow="hidden"),p=()=>{var T=g.currentTime;return v+y*f(T/b)},u&&E5(()=>{if(g.playState!=="running")return!1;var T=p();return u(T,1-T),!0})}g=t.animate(E,{duration:b,fill:"forwards"}),g.onfinish=()=>{p=()=>n,u==null||u(n,1-n),i()}},{abort:()=>{g&&(g.cancel(),g.effect=null,g.onfinish=ir)},deactivate:()=>{i=ir},reset:()=>{n===0&&(u==null||u(1,0))},t:()=>p()}}m();m();function ey(t,e,r=e){var n=on(),i=new WeakSet;G1(t,"input",a=>{D&&t.type==="checkbox"&&p1();var s=a?t.defaultValue:t.value;if(s=J1(t)?Q1(s):s,r(s),xe!==null&&i.add(xe),n&&s!==(s=e())){var o=t.selectionStart,l=t.selectionEnd;t.value=s!=null?s:"",l!==null&&(t.selectionStart=o,t.selectionEnd=Math.min(l,t.value.length))}}),(se&&t.defaultValue!==t.value||Ue(e)==null&&t.value)&&(r(J1(t)?Q1(t.value):t.value),xe!==null&&i.add(xe)),Kt(()=>{var o;D&&t.type==="checkbox"&&p1();var a=e();if(t===document.activeElement){var s=(o=fu)!=null?o:xe;if(i.has(s))return}J1(t)&&a===Q1(t.value)||t.type==="date"&&!a&&!t.value||a!==t.value&&(t.value=a!=null?a:"")})}function J1(t){var e=t.type;return e==="number"||e==="range"}function Q1(t){return t===""?null:+t}m();m();m();m();m();function k5(t,e){return t===e||(t==null?void 0:t[xr])===e}function Ze(t={},e,r,n){return Tr(()=>{var i,a;return Kt(()=>{i=a,a=(n==null?void 0:n())||[],Ue(()=>{t!==r(...a)&&(e(t,...a),i&&k5(r(...i),t)&&e(null,...i))})}),()=>{Lr(()=>{a&&k5(r(...a),t)&&e(null,...a)})}}),t}m();m();m();m();m();m();m();m();m();var dp=!1,Wde=Symbol();function ry(t){var e=dp;try{return dp=!1,[t(),dp]}finally{dp=e}}function cn(t,e,r,n){var E,S;var i=!Pi||(r&2)!==0,a=(r&8)!==0,s=(r&16)!==0,o=n,l=!0,c=()=>(l&&(l=!1,o=s?Ue(n):n),o),u;if(a){var f=xr in t||Qc in t;u=(S=(E=_r(t,e))==null?void 0:E.set)!=null?S:f&&e in t?A=>t[e]=A:void 0}var d,h=!1;a?[d,h]=ry(()=>t[e]):d=t[e],d===void 0&&n!==void 0&&(d=c(),u&&(i&&SO(e),u(d)));var p;if(i?p=()=>{var A=t[e];return A===void 0?c():(l=!0,A)}:p=()=>{var A=t[e];return A!==void 0&&(o=void 0),A===void 0?o:A},i&&!(r&4))return p;if(u){var g=t.$$legacy;return function(A,k){return arguments.length>0?((!i||!k||g||h)&&u(k?p():A),A):p()}}var v=!1,y=(r&1?vs:ys)(()=>(v=!1,p()));D&&(y.label=e),a&&R(y);var b=ee;return function(A,k){if(arguments.length>0){let w=k?R(y):i&&a?Ne(A):A;return ie(y,w),v=!0,o!==void 0&&(o=w),A}return Sn&&v||b.f&16384?y.v:R(y)}}m();m();m();function T5(t){return new ny(t)}var Ni,un,ny=class{constructor(e){yt(this,Ni);yt(this,un);var a,s;var r=new Map,n=(o,l)=>{var c=Ss(l,!1,!1);return r.set(o,c),c};let i=new Proxy({...e.props||{},$$events:{}},{get(o,l){var c;return R((c=r.get(l))!=null?c:n(l,Reflect.get(o,l)))},has(o,l){var c;return l===Qc?!0:(R((c=r.get(l))!=null?c:n(l,Reflect.get(o,l))),Reflect.has(o,l))},set(o,l,c){var u;return ie((u=r.get(l))!=null?u:n(l,c),c),Reflect.set(o,l,c)}});It(this,un,(e.hydrate?q1:Ta)(e.component,{target:e.target,anchor:e.anchor,props:i,context:e.context,intro:(a=e.intro)!=null?a:!1,recover:e.recover})),!_n&&(!((s=e==null?void 0:e.props)!=null&&s.$$host)||e.sync===!1)&&fl(),It(this,Ni,i.$$events);for(let o of Object.keys(ue(this,un)))o==="$set"||o==="$destroy"||o==="$on"||qt(this,o,{get(){return ue(this,un)[o]},set(l){ue(this,un)[o]=l},enumerable:!0});ue(this,un).$set=o=>{Object.assign(i,o)},ue(this,un).$destroy=()=>{ji(ue(this,un))}}$set(e){ue(this,un).$set(e)}$on(e,r){ue(this,Ni)[e]=ue(this,Ni)[e]||[];let n=(...i)=>r.call(this,...i);return ue(this,Ni)[e].push(n),()=>{ue(this,Ni)[e]=ue(this,Ni)[e].filter(i=>i!==n)}}$destroy(){ue(this,un).$destroy()}};Ni=new WeakMap,un=new WeakMap;var vz;typeof HTMLElement=="function"&&(vz=class extends HTMLElement{constructor(e,r,n){super();vt(this,"$$ctor");vt(this,"$$s");vt(this,"$$c");vt(this,"$$cn",!1);vt(this,"$$d",{});vt(this,"$$r",!1);vt(this,"$$p_d",{});vt(this,"$$l",{});vt(this,"$$l_u",new Map);vt(this,"$$me");this.$$ctor=e,this.$$s=r,n&&this.attachShadow({mode:"open"})}addEventListener(e,r,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(r),this.$$c){let i=this.$$c.$on(e,r);this.$$l_u.set(r,i)}super.addEventListener(e,r,n)}removeEventListener(e,r,n){if(super.removeEventListener(e,r,n),this.$$c){let i=this.$$l_u.get(r);i&&(i(),this.$$l_u.delete(r))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(i){return a=>{let s=document.createElement("slot");i!=="default"&&(s.name=i),ae(a,s)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;let r={},n=yz(this);for(let i of this.$$s)i in n&&(i==="default"&&!this.$$d.children?(this.$$d.children=e(i),r.default=!0):r[i]=e(i));for(let i of this.attributes){let a=this.$$g_p(i.name);a in this.$$d||(this.$$d[a]=iy(a,i.value,this.$$p_d,"toProp"))}for(let i in this.$$p_d)!(i in this.$$d)&&this[i]!==void 0&&(this.$$d[i]=this[i],delete this[i]);this.$$c=T5({component:this.$$ctor,target:this.shadowRoot||this,props:{...this.$$d,$$slots:r,$$host:this}}),this.$$me=L1(()=>{Kt(()=>{var i;this.$$r=!0;for(let a of c1(this.$$c)){if(!((i=this.$$p_d[a])!=null&&i.reflect))continue;this.$$d[a]=this.$$c[a];let s=iy(a,this.$$d[a],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[a].attribute||a):this.setAttribute(this.$$p_d[a].attribute||a,s)}this.$$r=!1})});for(let i in this.$$l)for(let a of this.$$l[i]){let s=this.$$c.$on(i,a);this.$$l_u.set(a,s)}this.$$l={}}}attributeChangedCallback(e,r,n){var i;this.$$r||(e=this.$$g_p(e),this.$$d[e]=iy(e,n,this.$$p_d,"toProp"),(i=this.$$c)==null||i.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return c1(this.$$p_d).find(r=>this.$$p_d[r].attribute===e||!this.$$p_d[r].attribute&&r.toLowerCase()===e)||e}});function iy(t,e,r,n){var a;let i=(a=r[t])==null?void 0:a.type;if(e=i==="Boolean"&&typeof e!="boolean"?e!=null:e,!n||!r[t])return e;if(n==="toAttribute")switch(i){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e==null?null:e;default:return e}else switch(i){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function yz(t){let e={};return t.childNodes.forEach(r=>{e[r.slot||"default"]=!0}),e}m();m();function Ts(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(u){try{c(n.next(u))}catch(f){s(f)}}function l(u){try{c(n.throw(u))}catch(f){s(f)}}function c(u){u.done?a(u.value):i(u.value).then(o,l)}c((n=n.apply(t,e||[])).next())})}var ly=require("obsidian");m();var sy=require("obsidian");m();function wz(t){let e=t-1;return e*e*e+1}var ay=!1;function ui(t,{delay:e=0,duration:r=400,easing:n=wz,axis:i="y"}={}){let a=getComputedStyle(t);D&&!ay&&/(contents|inline|table)/.test(a.display)&&(ay=!0,Promise.resolve().then(()=>ay=!1),OO(a.display));let s=+a.opacity,o=i==="y"?"height":"width",l=parseFloat(a[o]),c=i==="y"?["top","bottom"]:["left","right"],u=c.map(y=>`${y[0].toUpperCase()}${y.slice(1)}`),f=parseFloat(a[`padding${u[0]}`]),d=parseFloat(a[`padding${u[1]}`]),h=parseFloat(a[`margin${u[0]}`]),p=parseFloat(a[`margin${u[1]}`]),g=parseFloat(a[`border${u[0]}Width`]),v=parseFloat(a[`border${u[1]}Width`]);return{delay:e,duration:r,easing:n,css:y=>`overflow: hidden;opacity: ${Math.min(y*20,1)*s};${o}: ${y*l}px;padding-${c[0]}: ${y*f}px;padding-${c[1]}: ${y*d}px;margin-${c[0]}: ${y*h}px;margin-${c[1]}: ${y*p}px;border-${c[0]}-width: ${y*g}px;border-${c[1]}-width: ${y*v}px;min-${o}: 0`}}m();var hp=require("obsidian");var bz=fe('
    '),_z=fe('
    '),xz={hash:"svelte-1wbh8tp",code:"main.svelte-1wbh8tp .nav-file-title:where(.svelte-1wbh8tp) {align-items:center;}"};function _u(t,e){tt(e,!0),Tn(t,xz);let r=Ne([]),n=Ct(()=>e.view.leaf.getRoot().side=="left"?"right":"left");Zt(()=>{for(let y of r)y&&(0,hp.setIcon)(y,y.getAttr("data-icon"))});function i(y){y.stopPropagation(),Io(e.diff.path)?a(y):s(y)}function a(y){var b;y.stopPropagation();let E=e.view.app.vault.getAbstractFileByPath(e.diff.vaultPath);E instanceof hp.TFile&&((b=vn(e.view.app,y))===null||b===void 0||b.openFile(E).catch(S=>e.view.plugin.displayError(S)))}function s(y){var b;e.view.plugin.tools.openDiff({event:y,aFile:(b=e.diff.fromPath)!==null&&b!==void 0?b:e.diff.path,aRef:`${e.diff.hash}^`,bFile:e.diff.path,bRef:e.diff.hash})}var o=_z();o.__click=i;var l=G(o),c=G(l),u=G(c,!0);H(c);var f=te(c,2),d=G(f),h=G(d);{var p=y=>{var b=bz();b.__click=a,Ze(b,E=>r[0]=E,()=>r==null?void 0:r[0]),Gr("auxclick",b,a),ae(y,b)};_e(h,y=>{Fo(e.diff.vaultPath,e.view.app)&&y(p)})}H(d);var g=te(d,2),v=G(g,!0);H(g),H(f),H(l),H(o),Fe(y=>{ve(l,"data-path",e.diff.vaultPath),ve(l,"data-tooltip-position",R(n)),ve(l,"aria-label",e.diff.vaultPath),Be(u,y),ve(g,"data-type",e.diff.status),Be(v,e.diff.status)},[()=>Kn(e.diff.vaultPath)]),Gr("auxclick",o,y=>{y.stopPropagation(),y.button==2?Xn(e.view.app,y,e.diff.vaultPath,e.view.leaf,"git-history"):i(y)}),ae(t,o),rt()}gt(["click"]);m();var Sz=fe("
    "),Ez=(t,e,r)=>e(t,R(r)),Az=fe(''),kz=fe('
    '),Tz=fe("
    "),Cz={hash:"svelte-1lnl15d",code:"main.svelte-1lnl15d .nav-folder-title-content:where(.svelte-1lnl15d) {display:flex;align-items:center;}"};function xu(t,e){tt(e,!0),Tn(t,Cz);let r=cn(e,"topLevel",3,!1),n=cn(e,"closed",15),i=Ct(()=>e.view.leaf.getRoot().side=="left"?"right":"left");function a(l,c){l.stopPropagation(),n(n()[c.path]=!n()[c.path],!0)}var s=Tz();let o;Vr(s,21,()=>e.hierarchy.children,zr,(l,c)=>{var u=Li(),f=kr(u);{var d=p=>{var g=Sz(),v=G(g);_u(v,{get diff(){return R(c).data},get view(){return e.view}}),H(g),ae(p,g)},h=p=>{var g=kz();let v;var y=G(g);y.__click=[Ez,a,c];var b=te(G(y),2);let E;var S=te(b,2),A=G(S,!0);H(S),H(y);var k=te(y,2);{var w=x=>{var _=Az(),T=G(_);xu(T,{get hierarchy(){return R(c)},get plugin(){return e.plugin},get view(){return e.view},get closed(){return n()},set closed(C){n(C)}}),H(_),Pn(3,_,()=>ui,()=>({duration:150})),ae(x,_)};_e(k,x=>{n()[R(c).path]||x(w)})}H(g),Fe((x,_)=>{v=ot(g,1,"tree-item nav-folder",null,v,x),ve(y,"data-tooltip-position",R(i)),ve(y,"aria-label",R(c).vaultPath),E=ot(b,1,"tree-item-icon nav-folder-collapse-indicator collapse-icon",null,E,_),Be(A,R(c).title)},[()=>({"is-collapsed":n()[R(c).path]}),()=>({"is-collapsed":n()[R(c).path]})]),ae(p,g)};_e(f,p=>{R(c).data?p(d):p(h,!1)})}ae(l,u)}),H(s),Fe(l=>o=ot(s,1,"svelte-1lnl15d",null,o,l),[()=>({topLevel:r()})]),ae(t,s),rt()}gt(["click"]);var Pz=(t,e)=>ie(e,!R(e)),Rz=fe('
    '),Mz=fe('
    '),Oz=fe('
    '),Iz=fe(''),Fz=fe('
    '),$z={hash:"svelte-45h",code:""};function oy(t,e){tt(e,!0),Tn(t,$z);let r=Ct(()=>({title:"",path:"",vaultPath:"",children:e.plugin.gitManager.getTreeStructure(e.log.diff.files)})),n=Ct(()=>e.view.leaf.getRoot().side=="left"?"right":"left"),i=Pe(!0),a=Pe(Ne({}));function s(x){let _=x.author.name;if(e.plugin.settings.authorInHistoryView=="full")return _;if(e.plugin.settings.authorInHistoryView=="initials")return _.split(" ").filter(C=>C.length>0).map(C=>C[0].toUpperCase()).join("")}var o=Fz(),l=G(o);let c;var u=G(l);u.__click=[Pz,i];var f=G(u);let d;var h=te(f,2),p=G(h);{var g=x=>{var _=Rz(),T=G(_,!0);H(_),Fe(C=>Be(T,C),[()=>e.log.refs.join(", ")]),ae(x,_)};_e(p,x=>{e.log.refs.length>0&&x(g)})}var v=te(p,2);{var y=x=>{var _=Mz(),T=G(_,!0);H(_),Fe(C=>Be(T,C),[()=>s(e.log)]),ae(x,_)};_e(v,x=>{var _;e.plugin.settings.authorInHistoryView!="hide"&&((_=e.log.author)!=null&&_.name)&&x(y)})}var b=te(v,2);{var E=x=>{var _=Oz(),T=G(_,!0);H(_),Fe(C=>Be(T,C),[()=>(0,sy.moment)(e.log.date).format(e.plugin.settings.commitDateFormat)]),ae(x,_)};_e(b,x=>{e.plugin.settings.dateInHistoryView&&x(E)})}var S=te(b,2),A=G(S,!0);H(S),H(h),H(u);var k=te(u,2);{var w=x=>{var _=Iz(),T=G(_);{var C=L=>{xu(L,{get hierarchy(){return R(r)},get plugin(){return e.plugin},get view(){return e.view},topLevel:!0,get closed(){return R(a)},set closed($){ie(a,$,!0)}})},I=L=>{var $=Li(),J=kr($);Vr(J,17,()=>e.log.diff.files,zr,(de,le)=>{_u(de,{get view(){return e.view},get diff(){return R(le)}})}),ae(L,$)};_e(T,L=>{e.showTree?L(C):L(I,!1)})}H(_),Pn(3,_,()=>ui,()=>({duration:150})),ae(x,_)};_e(k,x=>{R(i)||x(w)})}H(l),H(o),Fe((x,_,T)=>{c=ot(l,1,"tree-item nav-folder",null,c,x),ve(u,"aria-label",_),ve(u,"data-tooltip-position",R(n)),d=ot(f,1,"tree-item-icon nav-folder-collapse-indicator collapse-icon",null,d,T),Be(A,e.log.message)},[()=>({"is-collapsed":R(i)}),()=>{var x;return`${e.log.refs.length>0?e.log.refs.join(", ")+` +`:""}${(x=e.log.author)==null?void 0:x.name} +${(0,sy.moment)(e.log.date).format(e.plugin.settings.commitDateFormat)} +${e.log.message}`},()=>({"is-collapsed":R(i)})]),ae(t,o),rt()}gt(["click"]);function Dz(t,e){e().catch(console.error)}var Lz=(t,e,r,n)=>{ie(e,!R(e)),(0,ly.setIcon)(r[0],R(e)?"list":"folder"),n(n().settings.treeStructure=R(e),!0),n().saveSettings()},jz=fe(''),Nz=fe('
    '),Bz={hash:"svelte-45h",code:""};function cy(t,e){tt(e,!0),Tn(t,Bz);let r=cn(e,"plugin",15),n=Pe(!1),i=Ne([]),a=Pe(void 0),s=Pe(Ne(r().settings.treeStructure)),o,l;Zt(()=>{l&&l.empty()}),o=e.view.app.workspace.on("obsidian-git:head-change",()=>void c().catch(console.error)),Zt(()=>{i.forEach(S=>(0,ly.setIcon)(S,S.getAttr("data-icon")))}),d5(()=>{e.view.app.workspace.offref(o)}),W1(()=>{let S=new IntersectionObserver(k=>{k[0].isIntersecting&&!R(n)&&u().catch(console.error)}),A=document.querySelector("#sentinel");return A&&S.observe(A),()=>{S.disconnect()}}),c().catch(console.error);function c(){return Ts(this,void 0,void 0,function*(){var S;if(!r().gitReady){ie(a,void 0);return}ie(n,!0);let A=r().gitManager instanceof Ce,k;((S=R(a)===null||R(a)===void 0?void 0:R(a).length)!==null&&S!==void 0?S:0)==0?k=A?50:10:k=R(a).length,ie(a,yield r().gitManager.log(void 0,!1,k),!0),ie(n,!1)})}function u(){return Ts(this,void 0,void 0,function*(){var S;if(!r().gitReady||R(a)===void 0)return;ie(n,!0);let k=r().gitManager instanceof Ce?50:10,w=yield r().gitManager.log(void 0,!1,k,(S=R(a).last())===null||S===void 0?void 0:S.hash);R(a).push(...w.slice(1)),ie(n,!1)})}var f=Nz(),d=G(f),h=G(d),p=G(h);p.__click=[Lz,s,i,r],Ze(p,S=>i[0]=S,()=>i==null?void 0:i[0]);var g=te(p,2);let v;g.__click=[Dz,c],Ze(g,S=>i[1]=S,()=>i==null?void 0:i[1]),H(h),H(d);var y=te(d,2),b=G(y);{var E=S=>{var A=jz();Vr(A,21,()=>R(a),zr,(k,w)=>{oy(k,{get view(){return e.view},get showTree(){return R(s)},get log(){return R(w)},get plugin(){return r()}})}),H(A),ae(S,A)};_e(b,S=>{R(a)&&S(E)})}il(4),H(y),H(f),Fe(S=>{ve(p,"data-icon",R(s)?"list":"folder"),v=ot(g,1,"clickable-icon nav-action-button",null,v,S)},[()=>({loading:R(n)})]),ae(t,f),rt()}gt(["click"]);var Su=class extends C5.ItemView{constructor(e,r){super(e),this.plugin=r,this.hoverPopover=null}getViewType(){return Zr.type}getDisplayText(){return Zr.name}getIcon(){return Zr.icon}onClose(){return this._view&&ji(this._view),super.onClose()}reload(){this._view&&ji(this._view),this._view=Ta(cy,{target:this.contentEl,props:{plugin:this.plugin,view:this}})}onOpen(){return this.reload(),super.onOpen()}};m();var P5=require("obsidian"),pp=class extends P5.FuzzySuggestModal{constructor(r,n){super(r.app);this.branches=n;this.setPlaceholder("Select branch to checkout")}getItems(){return this.branches}getItemText(r){return r}onChooseItem(r,n){this.resolve(r)}openAndGetReslt(){return new Promise(r=>{this.resolve=r,this.open()})}onClose(){new Promise(r=>setTimeout(r,10)).then(()=>{this.resolve&&this.resolve(void 0)})}};m();var $5=require("obsidian");m();var Ms=require("obsidian");m();var Au=require("obsidian");m();m();var Hz=Ot(R5()),Ca=require("obsidian");function Cs(t,e,r){let n=t.target;app.workspace.trigger("hover-link",{event:t,source:e.getViewType(),hoverParent:e,targetEl:n,linktext:r})}m();var M5=require("obsidian");var gl=class extends M5.Modal{constructor({app:r,path:n,filesToDeleteCount:i,filesToDiscardCount:a}){super(r);this.resolve=null;this.path=n,this.deleteCount=i,this.discardCount=a}openAndGetResult(){return this.open(),new Promise(r=>{this.resolve=r})}onOpen(){let r=this.deleteCount+this.discardCount,{contentEl:n,titleEl:i}=this,a="";this.path!=""&&(r>1?a=`files in "${this.path}"`:a=`"${this.path}"`),i.setText(`${this.discardCount==0?"Delete":"Discard"} ${a}`),this.deleteCount>0&&n.createEl("p").setText(`Are you sure you want to DELETE the ${Ic(this.deleteCount,"untracked file")}? They are deleted according to your Obsidian trash settting.`),this.discardCount>0&&n.createEl("p").setText(`Are you sure you want to discard ALL changes in ${Ic(this.discardCount,"tracked file")}?`);let s=n.createDiv({cls:"modal-button-container"});if(this.deleteCount>0){let l=s.createEl("button",{cls:"mod-warning",text:`${this.discardCount>0?"Discard":"Delete"} all ${Ic(r,"file")}`});l.addEventListener("click",()=>{this.resolve&&this.resolve("delete"),this.close()}),l.addEventListener("keypress",()=>{this.resolve&&this.resolve("delete"),this.close()})}if(this.discardCount>0){let l=s.createEl("button",{cls:"mod-warning",text:`Discard all ${Ic(this.discardCount,"tracked file")}`});l.addEventListener("click",()=>{this.resolve&&this.resolve("discard"),this.close()}),l.addEventListener("keypress",()=>{this.resolve&&this.resolve("discard"),this.close()})}let o=s.createEl("button",{text:"Cancel"});o.addEventListener("click",()=>(this.resolve&&this.resolve(!1),this.close())),o.addEventListener("keypress",()=>(this.resolve&&this.resolve(!1),this.close()))}onClose(){let{contentEl:r}=this;r.empty()}};function Uz(t,e){e.view.app.vault.getAbstractFileByPath(e.change.vaultPath)&&Cs(t,e.view,e.change.vaultPath)}function Gz(t,e){t.stopPropagation(),e.manager.stage(e.change.path,!1).catch(r=>e.view.plugin.displayError(r)).finally(()=>{e.view.app.workspace.trigger("obsidian-git:refresh")})}function zz(t,e){t.stopPropagation();let r=e.change.workingDir=="U";new gl({app:e.view.app,filesToDeleteCount:r?1:0,filesToDiscardCount:r?0:1,path:e.change.vaultPath}).openAndGetResult().then(n=>Ts(this,void 0,void 0,function*(){if(n=="delete"){let i=e.view.app.vault.getAbstractFileByPath(e.change.vaultPath);i instanceof Au.TFile?yield e.view.app.fileManager.trashFile(i):yield e.view.app.vault.adapter.remove(e.change.vaultPath)}else n=="discard"&&(yield e.manager.discard(e.change.path).finally(()=>{e.view.app.workspace.trigger("obsidian-git:refresh")}));e.view.app.workspace.trigger("obsidian-git:refresh")}),n=>e.view.plugin.displayError(n))}var Vz=fe('
    '),qz=fe('
    ');function ku(t,e){tt(e,!0);let r=Ne([]),n=Ct(()=>e.view.leaf.getRoot().side=="left"?"right":"left");Zt(()=>{for(let E of r)E&&(0,Au.setIcon)(E,E.getAttr("data-icon"))});function i(E){E.stopPropagation(),Io(e.change.path)?a(E):s(E)}function a(E){var S;E.stopPropagation();let A=e.view.app.vault.getAbstractFileByPath(e.change.vaultPath);A instanceof Au.TFile&&((S=vn(e.view.app,E))===null||S===void 0||S.openFile(A).catch(k=>e.view.plugin.displayError(k)))}function s(E){E.stopPropagation(),e.view.plugin.tools.openDiff({aFile:e.change.path,aRef:"",event:E})}var o=qz();o.__mouseover=[Uz,e],o.__click=i;var l=G(o),c=G(l),u=G(c,!0);H(c);var f=te(c,2),d=G(f),h=G(d);{var p=E=>{var S=Vz();S.__click=a,Ze(S,A=>r[0]=A,()=>r==null?void 0:r[0]),Gr("auxclick",S,a),ae(E,S)};_e(h,E=>{Fo(e.change.vaultPath,e.view.app)&&E(p)})}var g=te(h,2);g.__click=[zz,e],Ze(g,E=>r[1]=E,()=>r==null?void 0:r[1]);var v=te(g,2);v.__click=[Gz,e],Ze(v,E=>r[2]=E,()=>r==null?void 0:r[2]),H(d);var y=te(d,2),b=G(y,!0);H(y),H(f),H(l),H(o),Fe(E=>{ve(l,"data-path",e.change.vaultPath),ve(l,"data-tooltip-position",R(n)),ve(l,"aria-label",e.change.vaultPath),Be(u,E),ve(y,"data-type",e.change.workingDir),Be(b,e.change.workingDir)},[()=>Kn(e.change.vaultPath)]),Gr("auxclick",o,E=>{E.stopPropagation(),E.button==2?Xn(e.view.app,E,e.change.vaultPath,e.view.leaf,"git-source-control"):i(E)}),ae(t,o),rt()}gt(["mouseover","click"]);m();var O5=require("obsidian");function Wz(t,e){e.view.app.vault.getAbstractFileByPath(e.change.vaultPath)&&Cs(t,e.view,e.change.vaultPath)}var Yz=fe('
    ');function Tu(t,e){tt(e,!0);let r=Ct(()=>e.view.leaf.getRoot().side=="left"?"right":"left");function n(f){var d;f.stopPropagation();let h=e.view.app.vault.getAbstractFileByPath(e.change.vaultPath);h instanceof O5.TFile&&((d=vn(e.view.app,f))===null||d===void 0||d.openFile(h).catch(p=>e.view.plugin.displayError(p)))}var i=Yz();i.__mouseover=[Wz,e],i.__click=n;var a=G(i),s=G(a),o=G(s,!0);H(s);var l=te(s,2),c=G(l),u=G(c,!0);H(c),H(l),H(a),H(i),Fe(f=>{ve(a,"data-path",e.change.vaultPath),ve(a,"data-tooltip-position",R(r)),ve(a,"aria-label",e.change.vaultPath),Be(o,f),ve(c,"data-type",e.change.workingDir),Be(u,e.change.workingDir)},[()=>Kn(e.change.vaultPath)]),Gr("auxclick",i,f=>{f.stopPropagation(),f.button==2?Xn(e.view.app,f,e.change.vaultPath,e.view.leaf,"git-source-control"):n(f)}),ae(t,i),rt()}gt(["mouseover","click"]);m();var mp=require("obsidian");function Xz(t,e){e.view.app.vault.getFileByPath(e.change.vaultPath)&&Cs(t,e.view,e.change.vaultPath)}function Kz(t,e){t.stopPropagation(),e.manager.unstage(e.change.path,!1).catch(r=>e.view.plugin.displayError(r)).finally(()=>{e.view.app.workspace.trigger("obsidian-git:refresh")})}var Zz=fe('
    '),Jz=fe('
    ');function Cu(t,e){tt(e,!0);let r=Ne([]),n=Ct(()=>e.view.leaf.getRoot().side=="left"?"right":"left");Zt(()=>{for(let b of r)b&&(0,mp.setIcon)(b,b.getAttr("data-icon"))});function i(b){b.stopPropagation(),Io(e.change.path)?a(b):s(b)}function a(b){var E;b.stopPropagation();let S=e.view.app.vault.getAbstractFileByPath(e.change.vaultPath);S instanceof mp.TFile&&((E=vn(e.view.app,b))===null||E===void 0||E.openFile(S).catch(A=>e.view.plugin.displayError(A)))}function s(b){var E;b.stopPropagation(),e.view.plugin.tools.openDiff({aFile:(E=e.change.from)!==null&&E!==void 0?E:e.change.path,bFile:e.change.path,aRef:"HEAD",bRef:"",event:b})}var o=Jz();o.__mouseover=[Xz,e],o.__click=i;var l=G(o),c=G(l),u=G(c,!0);H(c);var f=te(c,2),d=G(f),h=G(d);{var p=b=>{var E=Zz();E.__click=a,Ze(E,S=>r[0]=S,()=>r==null?void 0:r[0]),ae(b,E)};_e(h,b=>{Fo(e.change.vaultPath,e.view.app)&&b(p)})}var g=te(h,2);g.__click=[Kz,e],Ze(g,b=>r[1]=b,()=>r==null?void 0:r[1]),H(d);var v=te(d,2),y=G(v,!0);H(v),H(f),H(l),H(o),Fe(b=>{ve(l,"data-path",e.change.vaultPath),ve(l,"data-tooltip-position",R(n)),ve(l,"aria-label",e.change.vaultPath),Be(u,b),ve(v,"data-type",e.change.index),Be(y,e.change.index)},[()=>Kn(e.change.vaultPath)]),Gr("auxclick",o,b=>{b.stopPropagation(),b.button==2?Xn(e.view.app,b,e.change.vaultPath,e.view.leaf,"git-source-control"):i(b)}),ae(t,o),rt()}gt(["mouseover","click"]);m();m();var Qz=fe(''),eV=fe("
    ");function Ps(t,e){tt(e,!0);var r=eV(),n=G(r);{var i=a=>{var s=Qz(),o=G(s),l=G(o),c=G(l,!0);H(l),H(o),H(s),Fe(()=>{ve(o,"aria-label","And "+(e.files.length-500)+" more files"),Be(c,"And "+(e.files.length-500)+" more files")}),ae(a,s)};_e(n,a=>{e.files.length>500&&a(i)})}H(r),ae(t,r),rt()}var rV=fe("
    "),nV=(t,e,r)=>e(t,R(r)),iV=(t,e,r)=>e(t,R(r).path),aV=fe('
    '),sV=(t,e,r)=>e(t,R(r)),oV=(t,e,r)=>e(t,R(r).path),lV=fe('
    ',1),cV=fe(''),uV=fe('
    '),fV=fe("
    ");function Rs(t,e){tt(e,!0);var r,n;let i=cn(e,"topLevel",3,!1),a=cn(e,"closed",15);for(let g of e.hierarchy.children)((n=(r=g.children)===null||r===void 0?void 0:r.length)!==null&&n!==void 0?n:0)>100&&a(a()[g.title]=!0,!0);let s=Ct(()=>e.view.leaf.getRoot().side=="left"?"right":"left");function o(g,v){g.stopPropagation(),e.plugin.gitManager.stageAll({dir:v}).catch(y=>e.plugin.displayError(y)).finally(()=>{e.view.app.workspace.trigger("obsidian-git:refresh")})}function l(g,v){g.stopPropagation(),e.plugin.gitManager.unstageAll({dir:v}).catch(y=>e.plugin.displayError(y)).finally(()=>{e.view.app.workspace.trigger("obsidian-git:refresh")})}function c(g,v){g.stopPropagation(),e.plugin.discardAll(v.vaultPath)}function u(g,v){g.stopPropagation(),a(a()[v.path]=!a()[v.path],!0)}var f=fV();let d;var h=G(f);Vr(h,17,()=>Fc(e.hierarchy.children,500),zr,(g,v)=>{var y=Li(),b=kr(y);{var E=A=>{var k=rV(),w=G(k);{var x=T=>{Cu(T,{get change(){return R(v).data},get manager(){return e.plugin.gitManager},get view(){return e.view}})},_=T=>{var C=Li(),I=kr(C);{var L=J=>{ku(J,{get change(){return R(v).data},get manager(){return e.plugin.gitManager},get view(){return e.view}})},$=J=>{var de=Li(),le=kr(de);{var ce=Te=>{Tu(Te,{get change(){return R(v).data},get view(){return e.view}})};_e(le,Te=>{e.fileType==2&&Te(ce)},!0)}ae(J,de)};_e(I,J=>{e.fileType==1?J(L):J($,!1)},!0)}ae(T,C)};_e(w,T=>{e.fileType==0?T(x):T(_,!1)})}H(k),ae(A,k)},S=A=>{var k=uV();k.__click=[nV,u,v];let w;var x=G(k),_=te(G(x),2);let T;var C=te(_,2),I=G(C,!0);H(C);var L=te(C,2),$=G(L),J=G($);{var de=ne=>{var N=aV();N.__click=[iV,l,v],ae(ne,N)},le=ne=>{var N=lV(),W=kr(N);W.__click=[sV,c,v];var B=te(W,2);B.__click=[oV,o,v],ae(ne,N)};_e(J,ne=>{e.fileType==0?ne(de):ne(le,!1)})}il(2),H($),H(L),H(x);var ce=te(x,2);{var Te=ne=>{var N=cV(),W=G(N);Rs(W,{get hierarchy(){return R(v)},get plugin(){return e.plugin},get view(){return e.view},get fileType(){return e.fileType},get closed(){return a()},set closed(B){a(B)}}),H(N),Pn(3,N,()=>ui,()=>({duration:150})),ae(ne,N)};_e(ce,ne=>{a()[R(v).path]||ne(Te)})}H(k),Fe((ne,N)=>{w=ot(k,1,"tree-item nav-folder",null,w,ne),ve(x,"data-tooltip-position",R(s)),ve(x,"aria-label",R(v).vaultPath),T=ot(_,1,"tree-item-icon nav-folder-collapse-indicator collapse-icon",null,T,N),Be(I,R(v).title)},[()=>({"is-collapsed":a()[R(v).path]}),()=>({"is-collapsed":a()[R(v).path]})]),Gr("auxclick",k,ne=>Xn(e.view.app,ne,R(v).vaultPath,e.view.leaf,"git-source-control")),ae(A,k)};_e(b,A=>{R(v).data?A(E):A(S,!1)})}ae(g,y)});var p=te(h,2);Ps(p,{get files(){return e.hierarchy.children}}),H(f),Fe(g=>d=ot(f,1,"",null,d,g),[()=>({topLevel:i()})]),ae(t,f),rt()}gt(["click"]);function dV(t,e,r,n,i,a){if(ie(e,!0),R(r)){let s=R(r).staged.length>0;n().promiseQueue.addTask(()=>n().commit({fromAuto:!1,commitMessage:R(i),onlyStaged:s}).then(()=>ie(i,n().settings.commitMessage,!0)).finally(a))}}function I5(t,e,r,n,i){t.stopPropagation(),ie(e,!0),r().promiseQueue.addTask(()=>r().gitManager.stageAll({status:R(n)}).finally(i))}function F5(t,e,r,n,i){t.stopPropagation(),ie(e,!0),r().promiseQueue.addTask(()=>r().gitManager.unstageAll({status:R(n)}).finally(i))}function hV(t,e,r,n){ie(e,!0),r().promiseQueue.addTask(()=>r().push().finally(n))}function pV(t,e,r,n){ie(e,!0),r().promiseQueue.addTask(()=>r().pullChangesFromRemote().finally(n))}function mV(t,e){t.stopPropagation(),e().discardAll()}var gV=(t,e,r,n)=>{ie(e,!R(e)),(0,Ms.setIcon)(r[6],R(e)?"list":"folder"),n().settings.treeStructure=R(e),n().saveSettings()},vV=(t,e)=>ie(e,""),yV=fe('
    '),wV=(t,e)=>ie(e,!R(e)),bV=fe(" ",1),_V=fe(''),xV=(t,e)=>ie(e,!R(e)),SV=fe(" ",1),EV=fe(''),AV=(t,e)=>ie(e,!R(e)),kV=fe(" ",1),TV=fe(''),CV=fe('
    '),PV=fe(''),RV=fe('
    '),MV={hash:"svelte-11adhly",code:`.commit-msg-input.svelte-11adhly {width:100%;overflow:hidden;resize:none;padding:7px 5px;background-color:var(--background-modifier-form-field);}.git-commit-msg.svelte-11adhly {position:relative;padding:0;width:calc(100% - var(--size-4-8));margin:4px auto;}main.svelte-11adhly .git-tools:where(.svelte-11adhly) .files-count:where(.svelte-11adhly) {padding-left:var(--size-2-1);width:11px;display:flex;align-items:center;justify-content:center;}.nav-folder-title.svelte-11adhly {align-items:center;}.git-commit-msg-clear-button.svelte-11adhly {position:absolute;background:transparent;border-radius:50%;color:var(--search-clear-button-color);cursor:var(--cursor);top:-4px;right:2px;bottom:0px;line-height:0;height:var(--input-height);width:28px;margin:auto;padding:0 0;text-align:center;display:flex;justify-content:center;align-items:center;transition:color 0.15s ease-in-out;}.git-commit-msg-clear-button.svelte-11adhly:after {content:"";height:var(--search-clear-button-size);width:var(--search-clear-button-size);display:block;background-color:currentColor;mask-image:url("data:image/svg+xml,");mask-repeat:no-repeat;-webkit-mask-image:url("data:image/svg+xml,");-webkit-mask-repeat:no-repeat;}`};function fy(t,e){tt(e,!0),Tn(t,MV);let r=cn(e,"plugin",7),n=cn(e,"view",7),i=Pe(!1),a=Pe(void 0),s=Pe(Ne([])),o=Pe(Ne(r().settings.commitMessage)),l=Ne([]),c=Pe(void 0),u=Pe(void 0),f=Pe(void 0),d=Pe(!0),h=Pe(!0),p=Pe(!0),g=Pe(0),v=Pe(Ne({})),y=Pe(Ne({})),b=Pe(Ne({})),E=Pe(Ne(r().settings.treeStructure));n().registerEvent(n().app.workspace.on("obsidian-git:loading-status",()=>ie(i,!0))),n().registerEvent(n().app.workspace.on("obsidian-git:status-changed",()=>void A().catch(console.error))),n().plugin.cachedStatus==null?n().plugin.refresh().catch(console.error):A().catch(console.error),Zt(()=>{l.forEach(X=>(0,Ms.setIcon)(X,X.getAttr("data-icon")))}),Zt(()=>{l.forEach(X=>{var Oe,De;!X||X.id!="push"||(Ms.Platform.isMobile?(X.removeClass("button-border"),R(g)>0&&X.addClass("button-border")):((Oe=X.firstElementChild)===null||Oe===void 0||Oe.removeAttribute("color"),R(g)>0&&((De=X.firstElementChild)===null||De===void 0||De.setAttr("color","var(--text-accent)"))))})}),n().scope=new Ms.Scope(r().app.scope),n().scope.register(["Ctrl"],"Enter",X=>S());function S(){if(ie(i,!0),R(a)){let X=R(a).staged.length>0;r().promiseQueue.addTask(()=>r().commitAndSync({fromAutoBackup:!1,commitMessage:R(o),onlyStaged:X}).then(()=>{ie(o,r().settings.commitMessage,!0)}).finally(k))}}function A(){return Ts(this,void 0,void 0,function*(){if(!r().gitReady){ie(a,void 0);return}if(ie(g,yield r().gitManager.getUnpushedCommits(),!0),ie(a,r().cachedStatus,!0),ie(i,!1),r().lastPulledFiles&&r().lastPulledFiles!=R(s)&&(ie(s,r().lastPulledFiles,!0),ie(f,{title:"",path:"",vaultPath:"",children:r().gitManager.getTreeStructure(R(s))},!0)),R(a)){let X=(Oe,De)=>Oe.vaultPath.split("/").last().localeCompare(Kn(De.vaultPath));R(a).changed.sort(X),R(a).staged.sort(X),ie(c,{title:"",path:"",vaultPath:"",children:r().gitManager.getTreeStructure(R(a).changed)},!0),ie(u,{title:"",path:"",vaultPath:"",children:r().gitManager.getTreeStructure(R(a).staged)},!0)}else ie(c,void 0),ie(u,void 0)})}function k(){n().app.workspace.trigger("obsidian-git:refresh")}let w=Ct(()=>(R(o).match(/\n/g)||[]).length+1||1);var x=RV(),_=G(x),T=G(_),C=G(T);C.__click=S,Ze(C,X=>l[0]=X,()=>l==null?void 0:l[0]);var I=te(C,2);I.__click=[dV,i,a,r,o,k],Ze(I,X=>l[1]=X,()=>l==null?void 0:l[1]);var L=te(I,2);L.__click=[I5,i,r,a,k],Ze(L,X=>l[2]=X,()=>l==null?void 0:l[2]);var $=te(L,2);$.__click=[F5,i,r,a,k],Ze($,X=>l[3]=X,()=>l==null?void 0:l[3]);var J=te($,2);J.__click=[hV,i,r,k],Ze(J,X=>l[4]=X,()=>l==null?void 0:l[4]);var de=te(J,2);de.__click=[pV,i,r,k],Ze(de,X=>l[5]=X,()=>l==null?void 0:l[5]);var le=te(de,2);le.__click=[gV,E,l,r],Ze(le,X=>l[6]=X,()=>l==null?void 0:l[6]);var ce=te(le,2);let Te;ce.__click=k,Ze(ce,X=>l[7]=X,()=>l==null?void 0:l[7]),H(T),H(_);var ne=te(_,2),N=G(ne);H1(N);var W=te(N,2);{var B=X=>{var Oe=yV();Oe.__click=[vV,o],ve(Oe,"aria-label","Clear"),ae(X,Oe)};_e(W,X=>{R(o)&&X(B)})}H(ne);var $e=te(ne,2),lr=G($e);{var Ut=X=>{var Oe=PV(),De=G(Oe);let Pt;var Le=G(De);Le.__click=[wV,h];var U=G(Le);let Je;var j=te(U,4),Z=G(j),Se=G(Z);Se.__click=[F5,i,r,a,k],Ze(Se,Mt=>l[8]=Mt,()=>l==null?void 0:l[8]),H(Z);var We=te(Z,2),Rt=G(We,!0);H(We),H(j),H(Le);var vl=te(Le,2);{var j5=Mt=>{var Gt=_V(),Bi=G(Gt);{var Rn=Jt=>{Rs(Jt,{get hierarchy(){return R(u)},get plugin(){return r()},get view(){return n()},get fileType(){return 0},topLevel:!0,get closed(){return R(v)},set closed(fn){ie(v,fn,!0)}})},Os=Jt=>{var fn=bV(),Pa=kr(fn);Vr(Pa,17,()=>Fc(R(a).staged,500),zr,(Hi,yl)=>{Cu(Hi,{get change(){return R(yl)},get view(){return n()},get manager(){return r().gitManager}})});var fi=te(Pa,2);Ps(fi,{get files(){return R(a).staged}}),ae(Jt,fn)};_e(Bi,Jt=>{R(E)?Jt(Rn):Jt(Os,!1)})}H(Gt),Pn(3,Gt,()=>ui,()=>({duration:150})),ae(Mt,Gt)};_e(vl,Mt=>{R(h)&&Mt(j5)})}H(De);var Ru=te(De,2);let dy;var Mu=G(Ru);Mu.__click=[xV,d];var hy=G(Mu);let py;var my=te(hy,4),yp=G(my),gy=G(yp);gy.__click=[mV,r];var vy=te(gy,2);vy.__click=[I5,i,r,a,k],Ze(vy,Mt=>l[9]=Mt,()=>l==null?void 0:l[9]),H(yp);var yy=te(yp,2),N5=G(yy,!0);H(yy),H(my),H(Mu);var B5=te(Mu,2);{var H5=Mt=>{var Gt=EV(),Bi=G(Gt);{var Rn=Jt=>{Rs(Jt,{get hierarchy(){return R(c)},get plugin(){return r()},get view(){return n()},get fileType(){return 1},topLevel:!0,get closed(){return R(y)},set closed(fn){ie(y,fn,!0)}})},Os=Jt=>{var fn=SV(),Pa=kr(fn);Vr(Pa,17,()=>Fc(R(a).changed,500),zr,(Hi,yl)=>{ku(Hi,{get change(){return R(yl)},get view(){return n()},get manager(){return r().gitManager}})});var fi=te(Pa,2);Ps(fi,{get files(){return R(a).changed}}),ae(Jt,fn)};_e(Bi,Jt=>{R(E)?Jt(Rn):Jt(Os,!1)})}H(Gt),Pn(3,Gt,()=>ui,()=>({duration:150})),ae(Mt,Gt)};_e(B5,Mt=>{R(d)&&Mt(H5)})}H(Ru);var U5=te(Ru,2);{var G5=Mt=>{var Gt=CV();let Bi;var Rn=G(Gt);Rn.__click=[AV,p];var Os=te(G(Rn),4),Jt=G(Os,!0);H(Os),H(Rn);var fn=te(Rn,2);{var Pa=fi=>{var Hi=TV(),yl=G(Hi);{var z5=Is=>{Rs(Is,{get hierarchy(){return R(f)},get plugin(){return r()},get view(){return n()},get fileType(){return 2},topLevel:!0,get closed(){return R(b)},set closed(Ou){ie(b,Ou,!0)}})},V5=Is=>{var Ou=kV(),wy=kr(Ou);Vr(wy,17,()=>R(s),zr,(W5,Y5)=>{Tu(W5,{get change(){return R(Y5)},get view(){return n()}})});var q5=te(wy,2);Ps(q5,{get files(){return R(s)}}),ae(Is,Ou)};_e(yl,Is=>{R(E)?Is(z5):Is(V5,!1)})}H(Hi),Pn(3,Hi,()=>ui,()=>({duration:150})),ae(fi,Hi)};_e(fn,fi=>{R(p)&&fi(Pa)})}H(Gt),Fe(fi=>{Bi=ot(Gt,1,"pulled nav-folder",null,Bi,fi),Be(Jt,R(s).length)},[()=>({"is-collapsed":!R(p)})]),ae(Mt,Gt)};_e(U5,Mt=>{R(s).length>0&&R(f)&&Mt(G5)})}H(Oe),Fe((Mt,Gt,Bi,Rn)=>{Pt=ot(De,1,"staged tree-item nav-folder",null,Pt,Mt),Je=ot(U,1,"tree-item-icon nav-folder-collapse-indicator collapse-icon",null,Je,Gt),Be(Rt,R(a).staged.length),dy=ot(Ru,1,"changes tree-item nav-folder",null,dy,Bi),py=ot(hy,1,"tree-item-icon nav-folder-collapse-indicator collapse-icon",null,py,Rn),Be(N5,R(a).changed.length)},[()=>({"is-collapsed":!R(h)}),()=>({"is-collapsed":!R(h)}),()=>({"is-collapsed":!R(d)}),()=>({"is-collapsed":!R(d)})]),ae(X,Oe)};_e(lr,X=>{R(a)&&R(u)&&R(c)&&X(Ut)})}H($e),H(x),Fe(X=>{ve(x,"data-type",$t.type),ve(le,"data-icon",R(E)?"list":"folder"),Te=ot(ce,1,"clickable-icon nav-action-button",null,Te,X),ve(N,"rows",R(w))},[()=>({loading:R(i)})]),ey(N,()=>R(o),X=>ie(o,X)),ae(t,x),rt()}gt(["click"]);var Pu=class extends $5.ItemView{constructor(e,r){super(e),this.plugin=r,this.hoverPopover=null}getViewType(){return $t.type}getDisplayText(){return $t.name}getIcon(){return $t.icon}onClose(){return this._view&&ji(this._view),super.onClose()}reload(){this._view&&ji(this._view),this._view=Ta(fy,{target:this.contentEl,props:{plugin:this.plugin,view:this}})}onOpen(){return this.reload(),super.onOpen()}};m();var gp=class{constructor(e,r){this.statusBarEl=e;this.plugin=r;this.statusBarEl.addClass("mod-clickable"),this.statusBarEl.onClickEvent(n=>{this.plugin.switchBranch().catch(i=>r.displayError(i))})}async display(){if(this.plugin.gitReady){let e=await this.plugin.gitManager.branchInfo();e.current!=null?this.statusBarEl.setText(e.current):this.statusBarEl.empty()}else this.statusBarEl.empty()}remove(){this.statusBarEl.remove()}};var vp=class extends we.Plugin{constructor(){super(...arguments);this.automaticsManager=new Bc(this);this.tools=new Uc(this);this.localStorage=new vh(this);this.state={gitAction:0,offlineMode:!1};this.gitReady=!1;this.promiseQueue=new fh(this);this.intervalsToClear=[];this.lineAuthoringFeature=new uh(this)}setPluginState(r){var n;this.state=Object.assign(this.state,r),(n=this.statusBar)==null||n.display()}async updateCachedStatus(){var r,n;return this.app.workspace.trigger("obsidian-git:loading-status"),this.cachedStatus=await this.gitManager.status(),this.cachedStatus.conflicted.length>0?(this.localStorage.setConflict(!0),await((r=this.branchBar)==null?void 0:r.display())):(this.localStorage.setConflict(!1),await((n=this.branchBar)==null?void 0:n.display())),this.app.workspace.trigger("obsidian-git:status-changed",this.cachedStatus),this.cachedStatus}async refresh(){if(!this.gitReady)return;let r=this.app.workspace.getLeavesOfType($t.type),n=this.app.workspace.getLeavesOfType(Zr.type);(this.settings.changedFilesInStatusBar||r.some(i=>{var a;return!((a=i.isDeferred)!=null&&a)})||n.some(i=>{var a;return!((a=i.isDeferred)!=null&&a)}))&&await this.updateCachedStatus().catch(i=>this.displayError(i)),this.app.workspace.trigger("obsidian-git:refreshed")}refreshUpdatedHead(){this.lineAuthoringFeature.refreshLineAuthorViews()}async onload(){console.log("loading "+this.manifest.name+" plugin: v"+this.manifest.version),Nc.plugin=this,this.localStorage.migrate(),await this.loadSettings(),await this.migrateSettings(),this.settingsTab=new Kd(this.app,this),this.addSettingTab(this.settingsTab),this.localStorage.getPluginDisabled()||(this.registerStuff(),this.app.workspace.onLayoutReady(()=>this.init({fromReload:!1}).catch(r=>this.displayError(r))))}onExternalSettingsChange(){this.reloadSettings().catch(r=>this.displayError(r))}async reloadSettings(){let r=JSON.stringify(this.settings);await this.loadSettings();let n=JSON.stringify(this.settings);r!==n&&(this.log("Reloading settings"),this.unloadPlugin(),await this.init({fromReload:!0}),this.app.workspace.getLeavesOfType($t.type).forEach(i=>{var a;if(!((a=i.isDeferred)!=null&&a))return i.view.reload()}),this.app.workspace.getLeavesOfType(Zr.type).forEach(i=>{var a;if(!((a=i.isDeferred)!=null&&a))return i.view.reload()}))}registerStuff(){this.registerEvent(this.app.workspace.on("obsidian-git:refresh",()=>{this.refresh().catch(r=>this.displayError(r))})),this.registerEvent(this.app.workspace.on("obsidian-git:head-change",()=>{this.refreshUpdatedHead()})),this.registerEvent(this.app.workspace.on("file-menu",(r,n,i)=>{this.handleFileMenu(r,n,i,"file-manu")})),this.registerEvent(this.app.workspace.on("obsidian-git:menu",(r,n,i)=>{this.handleFileMenu(r,n,i,"obsidian-git:menu")})),this.registerEvent(this.app.workspace.on("active-leaf-change",r=>{this.onActiveLeafChange(r)})),this.registerEvent(this.app.vault.on("modify",()=>{var r;this.debRefresh(),(r=this.autoCommitDebouncer)==null||r.call(this)})),this.registerEvent(this.app.vault.on("delete",()=>{var r;this.debRefresh(),(r=this.autoCommitDebouncer)==null||r.call(this)})),this.registerEvent(this.app.vault.on("create",()=>{var r;this.debRefresh(),(r=this.autoCommitDebouncer)==null||r.call(this)})),this.registerEvent(this.app.vault.on("rename",()=>{var r;this.debRefresh(),(r=this.autoCommitDebouncer)==null||r.call(this)})),this.registerView($t.type,r=>new Pu(r,this)),this.registerView(Zr.type,r=>new Su(r,this)),this.registerView(ua.type,r=>new ls(r,this)),this.registerView(ca.type,r=>new fs(r,this)),this.addRibbonIcon("git-pull-request","Open Git source control",async()=>{var i;let r=this.app.workspace.getLeavesOfType($t.type),n;r.length===0?(n=(i=this.app.workspace.getRightLeaf(!1))!=null?i:this.app.workspace.getLeaf(),await n.setViewState({type:$t.type})):n=r.first(),await this.app.workspace.revealLeaf(n)}),this.registerHoverLinkSource($t.type,{display:"Git View",defaultMod:!0}),this.lineAuthoringFeature.onLoadPlugin(),this.setRefreshDebouncer(),oM(this)}setRefreshDebouncer(){var r;(r=this.debRefresh)==null||r.cancel(),this.debRefresh=(0,we.debounce)(()=>{this.settings.refreshSourceControl&&this.refresh().catch(console.error)},this.settings.refreshSourceControlTimer,!0)}async addFileToGitignore(r,n){let i=this.gitManager.getRelativeRepoPath(r,!0),a=u3({isFolder:n,gitRelativePath:i});return await this.app.vault.adapter.append(this.gitManager.getRelativeVaultPath(".gitignore"),` +`+a),this.refresh()}handleFileMenu(r,n,i,a){if(!this.gitReady||!this.settings.showFileMenu||!n)return;let s;if(typeof n=="string"?s=n:s=n.path,i=="file-explorer-context-menu"&&(r.addItem(o=>{o.setTitle("Git: Stage").setIcon("plus-circle").setSection("action").onClick(l=>{this.promiseQueue.addTask(async()=>{n instanceof we.TFile?await this.stageFile(n):(await this.gitManager.stageAll({dir:this.gitManager.getRelativeRepoPath(s,!0)}),this.app.workspace.trigger("obsidian-git:refresh"))})})}),r.addItem(o=>{o.setTitle("Git: Unstage").setIcon("minus-circle").setSection("action").onClick(l=>{this.promiseQueue.addTask(async()=>{n instanceof we.TFile?await this.unstageFile(n):(await this.gitManager.unstageAll({dir:this.gitManager.getRelativeRepoPath(s,!0)}),this.app.workspace.trigger("obsidian-git:refresh"))})})}),r.addItem(o=>{o.setTitle("Git: Add to .gitignore").setIcon("file-x").setSection("action").onClick(l=>{this.addFileToGitignore(s,n instanceof we.TFolder).catch(c=>this.displayError(c))})})),i=="git-source-control"){r.addItem(l=>{l.setTitle("Git: Add to .gitignore").setIcon("file-x").setSection("action").onClick(c=>{this.addFileToGitignore(s,n instanceof we.TFolder).catch(u=>this.displayError(u))})});let o=this.app.vault.adapter;a==="obsidian-git:menu"&&o instanceof we.FileSystemAdapter&&(r.addItem(l=>{l.setTitle("Open in default app").setIcon("arrow-up-right").setSection("action").onClick(c=>{this.app.openWithDefaultApp(s)})}),r.addItem(l=>{l.setTitle("Show in system explorer").setIcon("arrow-up-right").setSection("action").onClick(c=>{window.electron.shell.showItemInFolder(L5.join(o.getBasePath(),s))})}))}}async migrateSettings(){this.settings.mergeOnPull!=null&&(this.settings.syncMethod=this.settings.mergeOnPull?"merge":"rebase",this.settings.mergeOnPull=void 0,await this.saveSettings()),this.settings.autoCommitMessage===void 0&&(this.settings.autoCommitMessage=this.settings.commitMessage,await this.saveSettings()),this.settings.gitPath!=null&&(this.localStorage.setGitPath(this.settings.gitPath),this.settings.gitPath=void 0,await this.saveSettings()),this.settings.username!=null&&(this.localStorage.setPassword(this.settings.username),this.settings.username=void 0,await this.saveSettings())}unloadPlugin(){var r,n;this.gitReady=!1,this.lineAuthoringFeature.deactivateFeature(),this.automaticsManager.unload(),(r=this.branchBar)==null||r.remove(),(n=this.statusBar)==null||n.remove(),this.statusBar=void 0,this.branchBar=void 0,this.gitManager.unload(),this.promiseQueue.clear();for(let i of this.intervalsToClear)window.clearInterval(i);this.intervalsToClear=[],this.debRefresh.cancel()}onunload(){this.unloadPlugin(),console.log("unloading "+this.manifest.name+" plugin")}async loadSettings(){let r=await this.loadData();r==null&&(r={showedMobileNotice:!0}),this.settings=gT(Xe,r)}async saveSettings(){var r;(r=this.settingsTab)==null||r.beforeSaveSettings(),await this.saveData(this.settings)}get useSimpleGit(){return we.Platform.isDesktopApp}async init({fromReload:r=!1}){var n;if(this.settings.showStatusBar&&!this.statusBar){let i=this.addStatusBarItem();this.statusBar=new dh(i,this),this.intervalsToClear.push(window.setInterval(()=>{var a;return(a=this.statusBar)==null?void 0:a.display()},1e3))}try{this.useSimpleGit?(this.gitManager=new Ce(this),await this.gitManager.setGitInstance()):this.gitManager=new wn(this);let i=await this.gitManager.checkRequirements(),a=this.localStorage.getPausedAutomatics();switch(i){case"missing-git":this.displayError(`Cannot run git command. Trying to run: '${this.localStorage.getGitPath()||"git"}' .`);break;case"missing-repo":new we.Notice("Can't find a valid git repository. Please create one via the given command or clone an existing repo.",1e4);break;case"valid":if(this.gitReady=!0,this.setPluginState({gitAction:0}),we.Platform.isDesktop&&this.settings.showBranchStatusBar&&!this.branchBar){let s=this.addStatusBarItem();this.branchBar=new gp(s,this),this.intervalsToClear.push(window.setInterval(()=>{var o;return void((o=this.branchBar)==null?void 0:o.display().catch(console.error))},6e4))}await((n=this.branchBar)==null?void 0:n.display()),this.lineAuthoringFeature.conditionallyActivateBySettings(),this.app.workspace.trigger("obsidian-git:refresh"),this.app.workspace.trigger("obsidian-git:head-change"),!r&&this.settings.autoPullOnBoot&&!a&&this.promiseQueue.addTask(()=>this.pullChangesFromRemote()),a||await this.automaticsManager.init(),a&&new we.Notice("Automatic routines are currently paused.");break;default:this.log("Something weird happened. The 'checkRequirements' result is "+i)}}catch(i){this.displayError(i),console.error(i)}}async createNewRepo(){try{await this.gitManager.init(),new we.Notice("Initialized new repo"),await this.init({fromReload:!0})}catch(r){this.displayError(r)}}async cloneNewRepo(){let n=await new ze(this,{placeholder:"Enter remote URL"}).openAndGetResult();if(n){let i="Vault Root",a=await new ze(this,{options:this.gitManager instanceof wn?[i]:[],placeholder:"Enter directory for clone. It needs to be empty or not existent.",allowEmpty:this.gitManager instanceof wn}).openAndGetResult();if(a==null)return;if(a===i&&(a="."),a=(0,we.normalizePath)(a),a==="/"&&(a="."),a==="."){let f=await new ze(this,{options:["NO","YES"],placeholder:`Does your remote repo contain a ${this.app.vault.configDir} directory at the root?`,onlySelection:!0}).openAndGetResult();if(f===void 0){new we.Notice("Aborted clone");return}else if(f==="YES"){let d="DELETE ALL YOUR LOCAL CONFIG AND PLUGINS";if(await new ze(this,{options:["Abort clone",d],placeholder:`To avoid conflicts, the local ${this.app.vault.configDir} directory needs to be deleted.`,onlySelection:!0}).openAndGetResult()===d)await this.app.vault.adapter.rmdir(this.app.vault.configDir,!0);else{new we.Notice("Aborted clone");return}}}let s=await new ze(this,{placeholder:"Specify depth of clone. Leave empty for full clone.",allowEmpty:!0}).openAndGetResult(),o;if(s===void 0){new we.Notice("Aborted clone");return}if(s!==""&&(o=parseInt(s),isNaN(o))){new we.Notice("Invalid depth. Aborting clone.");return}new we.Notice(`Cloning new repo into "${a}"`);let l=this.settings.basePath,c=a&&a!==".";c&&(this.settings.basePath=a);try{await this.gitManager.clone(vv(n),a,o),new we.Notice("Cloned new repo."),new we.Notice("Please restart Obsidian"),c&&await this.saveSettings()}catch(u){this.displayError(u),this.settings.basePath=l,await this.saveSettings()}}}async isAllInitialized(){return this.gitReady||await this.init({fromReload:!0}),this.gitReady}async pullChangesFromRemote(){if(!await this.isAllInitialized())return;let r=await this.pull();if(r!==!1){if(r||this.displayMessage("Pull: Everything is up-to-date"),this.gitManager instanceof Ce){let n=await this.updateCachedStatus();n.conflicted.length>0&&(this.displayError(`You have conflicts in ${n.conflicted.length} ${n.conflicted.length==1?"file":"files"}`),await this.handleConflict(n.conflicted))}this.app.workspace.trigger("obsidian-git:refresh"),this.setPluginState({gitAction:0})}}async commitAndSync({fromAutoBackup:r,requestCustomMessage:n=!1,commitMessage:i,onlyStaged:a=!1}){!await this.isAllInitialized()||(this.settings.syncMethod=="reset"&&this.settings.pullBeforePush&&await this.pull(),!await this.commit({fromAuto:r,requestCustomMessage:n,commitMessage:i,onlyStaged:a}))||(this.settings.syncMethod!="reset"&&this.settings.pullBeforePush&&await this.pull(),this.settings.disablePush||(await this.remotesAreSet()&&await this.gitManager.canPush()?await this.push():this.displayMessage("No commits to push")),this.setPluginState({gitAction:0}))}async commit({fromAuto:r,requestCustomMessage:n=!1,onlyStaged:i=!1,commitMessage:a,amend:s=!1}){if(!await this.isAllInitialized())return!1;try{let o=this.localStorage.getConflict(),l,c=[],u=[];if(this.gitManager instanceof Ce){if(await this.mayDeleteConflictFile(),l=await this.updateCachedStatus(),l.conflicted.length==0&&(o=!1),r&&l.conflicted.length>0)return this.displayError(`Did not commit, because you have conflicts in ${l.conflicted.length} ${l.conflicted.length==1?"file":"files"}. Please resolve them and commit per command.`),await this.handleConflict(l.conflicted),!1;c=l.staged,u=l.changed}else{if(r&&o)return this.displayError("Did not commit, because you have conflicts. Please resolve them and commit per command."),!1;{o&&await this.mayDeleteConflictFile();let f=this.gitManager;i?c=await f.getStagedFiles():u=(await f.getUnstagedFiles()).map(({path:h,type:p})=>({vaultPath:this.gitManager.getRelativeVaultPath(h),path:h,type:p}))}}if(await this.tools.hasTooBigFiles(i?c:[...c,...u]))return this.setPluginState({gitAction:0}),!1;if(u.length+c.length!==0||o){let f=a!=null?a:a=r?this.settings.autoCommitMessage:this.settings.commitMessage;if(r&&this.settings.customMessageOnAutoBackup||n){!this.settings.disablePopups&&r&&new we.Notice("Auto backup: Please enter a custom commit message. Leave empty to abort");let p=await new hh(this).openAndGetResult();if(p!=null&&p!=""&&p!="...")f=p;else return this.setPluginState({gitAction:0}),!1}else if(this.gitManager instanceof Ce&&this.settings.commitMessageScript){let p=this.settings.commitMessageScript,g=this.localStorage.getHostname()||"",v=p.replace("{{hostname}}",g);v=v.replace("{{date}}",(0,we.moment)().format(this.settings.commitDateFormat));let y=await $c("sh",["-c",v],{cwd:this.gitManager.absoluteRepoPath});y.code!=0?this.displayError(y.stderr):y.stdout.trim().length==0?this.displayMessage("Stdout from commit message script is empty. Using default message."):f=y.stdout}let d;i?d=await this.gitManager.commit({message:f,amend:s}):d=await this.gitManager.commitAll({message:f,status:l,unstagedFiles:u,amend:s}),this.gitManager instanceof Ce&&await this.updateCachedStatus();let h=!1;d===void 0&&(h=!0,d=u.length+c.length||0),this.displayMessage(`Committed${h?" approx.":""} ${d} ${d==1?"file":"files"}`)}else this.displayMessage("No changes to commit");return this.app.workspace.trigger("obsidian-git:refresh"),!0}catch(o){return this.displayError(o),!1}}async push(){if(!await this.isAllInitialized()||!await this.remotesAreSet())return!1;let r=this.localStorage.getConflict();try{this.gitManager instanceof Ce&&await this.mayDeleteConflictFile();let n;if(this.gitManager instanceof Ce&&(n=await this.updateCachedStatus()).conflicted.length>0)return this.displayError(`Cannot push. You have conflicts in ${n.conflicted.length} ${n.conflicted.length==1?"file":"files"}`),await this.handleConflict(n.conflicted),!1;if(this.gitManager instanceof wn&&r)return this.displayError("Cannot push. You have conflicts"),!1;this.log("Pushing....");let i=await this.gitManager.push();return i!==void 0&&(i>0?this.displayMessage(`Pushed ${i} ${i==1?"file":"files"} to remote`):this.displayMessage("No commits to push")),this.setPluginState({offlineMode:!1}),this.app.workspace.trigger("obsidian-git:refresh"),!0}catch(n){return n instanceof Co?this.handleNoNetworkError(n):this.displayError(n),!1}}async pull(){if(!await this.remotesAreSet())return!1;try{this.log("Pulling....");let r=await this.gitManager.pull()||[];return this.setPluginState({offlineMode:!1}),r.length>0&&(this.displayMessage(`Pulled ${r.length} ${r.length==1?"file":"files"} from remote`),this.lastPulledFiles=r),r.length}catch(r){return this.displayError(r),!1}}async fetch(){if(await this.remotesAreSet())try{await this.gitManager.fetch(),this.displayMessage("Fetched from remote"),this.setPluginState({offlineMode:!1}),this.app.workspace.trigger("obsidian-git:refresh")}catch(r){this.displayError(r)}}async mayDeleteConflictFile(){let r=this.app.vault.getAbstractFileByPath(To);r&&(this.app.workspace.iterateAllLeaves(n=>{var i;n.view instanceof we.MarkdownView&&((i=n.view.file)==null?void 0:i.path)==r.path&&n.detach()}),await this.app.vault.delete(r))}async stageFile(r){return await this.isAllInitialized()?(await this.gitManager.stage(r.path,!0),this.app.workspace.trigger("obsidian-git:refresh"),this.setPluginState({gitAction:0}),!0):!1}async unstageFile(r){return await this.isAllInitialized()?(await this.gitManager.unstage(r.path,!0),this.app.workspace.trigger("obsidian-git:refresh"),this.setPluginState({gitAction:0}),!0):!1}async switchBranch(){var i;if(!await this.isAllInitialized())return;let r=await this.gitManager.branchInfo(),n=await new pp(this,r.branches).openAndGetReslt();if(n!=null)return await this.gitManager.checkout(n),this.displayMessage(`Switched to ${n}`),this.app.workspace.trigger("obsidian-git:refresh"),await((i=this.branchBar)==null?void 0:i.display()),n}async switchRemoteBranch(){var a;if(!await this.isAllInitialized())return;let r=await this.selectRemoteBranch()||"",[n,i]=ki(r);if(i!=null&&n!=null)return await this.gitManager.checkout(i,n),this.displayMessage(`Switched to ${r}`),await((a=this.branchBar)==null?void 0:a.display()),r}async createBranch(){var n;if(!await this.isAllInitialized())return;let r=await new ze(this,{placeholder:"Create new branch"}).openAndGetResult();if(r!=null)return await this.gitManager.createBranch(r),this.displayMessage(`Created new branch ${r}`),await((n=this.branchBar)==null?void 0:n.display()),r}async deleteBranch(){var i;if(!await this.isAllInitialized())return;let r=await this.gitManager.branchInfo();r.current&&r.branches.remove(r.current);let n=await new ze(this,{options:r.branches,placeholder:"Delete branch",onlySelection:!0}).openAndGetResult();if(n!=null){let a=!1;if(!await this.gitManager.branchIsMerged(n)){let o=await new ze(this,{options:["YES","NO"],placeholder:"This branch isn't merged into HEAD. Force delete?",onlySelection:!0}).openAndGetResult();if(o!=="YES")return;a=o==="YES"}return await this.gitManager.deleteBranch(n,a),this.displayMessage(`Deleted branch ${n}`),await((i=this.branchBar)==null?void 0:i.display()),n}}async remotesAreSet(){return this.settings.updateSubmodules||(await this.gitManager.branchInfo()).tracking?!0:(new we.Notice("No upstream branch is set. Please select one."),await this.setUpstreamBranch())}async setUpstreamBranch(){let r=await this.selectRemoteBranch();return r==null?(this.displayError("Aborted. No upstream-branch is set!",1e4),this.setPluginState({gitAction:0}),!1):(await this.gitManager.updateUpstreamBranch(r),this.displayMessage(`Set upstream branch to ${r}`),this.setPluginState({gitAction:0}),!0)}async discardAll(r){if(!await this.isAllInitialized())return!1;let n=await this.gitManager.status({path:r}),i=0,a=0;for(let o of n.changed)o.workingDir=="U"?i++:a++;if(i+a==0)return!1;let s=await new gl({app:this.app,filesToDeleteCount:i,filesToDiscardCount:a,path:r!=null?r:""}).openAndGetResult();switch(s){case!1:return s;case"discard":await this.gitManager.discardAll({dir:r,status:this.cachedStatus});break;case"delete":{await this.gitManager.discardAll({dir:r,status:this.cachedStatus});let o=await this.gitManager.getUntrackedPaths({path:r,status:this.cachedStatus});for(let l of o){let c=this.gitManager.getRelativeVaultPath(l),u=this.app.vault.getAbstractFileByPath(c);u?await this.app.fileManager.trashFile(u):l.endsWith("/")?await this.app.vault.adapter.rmdir(c,!0):await this.app.vault.adapter.remove(c)}break}default:Ud(s)}return this.app.workspace.trigger("obsidian-git:refresh"),s}async handleConflict(r){this.localStorage.setConflict(!0);let n;r!==void 0&&(n=["# Conflicts","Please resolve them and commit them using the commands `Git: Commit all changes` followed by `Git: Push`","(This file will automatically be deleted before commit)","[[#Additional Instructions]] available below file list","",...r.map(i=>{let a=this.app.vault.getAbstractFileByPath(i);return a instanceof we.TFile?`- [[${this.app.metadataCache.fileToLinktext(a,"/")}]]`:`- Not a file: ${i}`}),` # Additional Instructions I strongly recommend to use "Source mode" for viewing the conflicted files. For simple conflicts, in each file listed above replace every occurrence of the following text blocks with the desired text. \`\`\`diff -<<<<<<< HEAD - File changes in local repository -======= File changes in remote repository ->>>>>>> origin/main -\`\`\`` - ]; - } - this.writeAndOpenFile(lines == null ? void 0 : lines.join("\n")); - } - async editRemotes() { - if (!await this.isAllInitialized()) - return; - const remotes = await this.gitManager.getRemotes(); - const nameModal = new GeneralModal({ - options: remotes, - placeholder: "Select or create a new remote by typing its name and selecting it" - }); - const remoteName = await nameModal.open(); - if (remoteName) { - const oldUrl = await this.gitManager.getRemoteUrl(remoteName); - const urlModal = new GeneralModal({ initialValue: oldUrl }); - const remoteURL = await urlModal.open(); - if (remoteURL) { - await this.gitManager.setRemote(remoteName, remoteURL); - return remoteName; - } - } - } - async selectRemoteBranch() { - let remotes = await this.gitManager.getRemotes(); - let selectedRemote; - if (remotes.length === 0) { - selectedRemote = await this.editRemotes(); - if (selectedRemote == void 0) { - remotes = await this.gitManager.getRemotes(); - } - } - const nameModal = new GeneralModal({ - options: remotes, - placeholder: "Select or create a new remote by typing its name and selecting it" - }); - const remoteName = selectedRemote != null ? selectedRemote : await nameModal.open(); - if (remoteName) { - this.displayMessage("Fetching remote branches"); - await this.gitManager.fetch(remoteName); - const branches = await this.gitManager.getRemoteBranches(remoteName); - const branchModal = new GeneralModal({ - options: branches, - placeholder: "Select or create a new remote branch by typing its name and selecting it" - }); - return await branchModal.open(); - } - } - async removeRemote() { - if (!await this.isAllInitialized()) - return; - const remotes = await this.gitManager.getRemotes(); - const nameModal = new GeneralModal({ - options: remotes, - placeholder: "Select a remote" - }); - const remoteName = await nameModal.open(); - if (remoteName) { - this.gitManager.removeRemote(remoteName); - } - } - async writeAndOpenFile(text2) { - if (text2 !== void 0) { - await this.app.vault.adapter.write(this.conflictOutputFile, text2); - } - let fileIsAlreadyOpened = false; - this.app.workspace.iterateAllLeaves((leaf) => { - if (leaf.getDisplayText() != "" && this.conflictOutputFile.startsWith(leaf.getDisplayText())) { - fileIsAlreadyOpened = true; - } - }); - if (!fileIsAlreadyOpened) { - this.app.workspace.openLinkText(this.conflictOutputFile, "/", true); - } - } - handleViewActiveState(leaf) { - var _a2, _b; - if (!(leaf == null ? void 0 : leaf.view.getState().file)) - return; - const sourceControlLeaf = this.app.workspace.getLeavesOfType(SOURCE_CONTROL_VIEW_CONFIG.type).first(); - const historyLeaf = this.app.workspace.getLeavesOfType(HISTORY_VIEW_CONFIG.type).first(); - (_a2 = sourceControlLeaf == null ? void 0 : sourceControlLeaf.view.containerEl.querySelector(`div.nav-file-title.is-active`)) == null ? void 0 : _a2.removeClass("is-active"); - (_b = historyLeaf == null ? void 0 : historyLeaf.view.containerEl.querySelector(`div.nav-file-title.is-active`)) == null ? void 0 : _b.removeClass("is-active"); - if ((leaf == null ? void 0 : leaf.view) instanceof DiffView) { - const path2 = leaf.view.state.file; - this.lastDiffViewState = leaf.view.getState(); - let el; - if (sourceControlLeaf && leaf.view.state.staged) { - el = sourceControlLeaf.view.containerEl.querySelector( - `div.staged div.nav-file-title[data-path='${path2}']` - ); - } else if (sourceControlLeaf && leaf.view.state.staged === false && !leaf.view.state.hash) { - el = sourceControlLeaf.view.containerEl.querySelector( - `div.changes div.nav-file-title[data-path='${path2}']` - ); - } else if (historyLeaf && leaf.view.state.hash) { - el = historyLeaf.view.containerEl.querySelector( - `div.nav-file-title[data-path='${path2}']` - ); - } - el == null ? void 0 : el.addClass("is-active"); - } else { - this.lastDiffViewState = void 0; - } - } - // region: displaying / formatting messages - displayMessage(message, timeout = 4 * 1e3) { - var _a2; - (_a2 = this.statusBar) == null ? void 0 : _a2.displayMessage(message.toLowerCase(), timeout); - if (!this.settings.disablePopups) { - if (!this.settings.disablePopupsForNoChanges || !message.startsWith("No changes")) { - new import_obsidian31.Notice(message, 5 * 1e3); - } - } - this.log(message); - } - displayError(message, timeout = 10 * 1e3) { - var _a2; - if (message instanceof Errors.UserCanceledError) { - new import_obsidian31.Notice("Aborted"); - return; - } - message = message.toString(); - new import_obsidian31.Notice(message, timeout); - console.log(`git obsidian error: ${message}`); - (_a2 = this.statusBar) == null ? void 0 : _a2.displayMessage(message.toLowerCase(), timeout); - } - log(message) { - console.log(`${this.manifest.id}: ` + message); - } -}; +\`\`\``]),await this.tools.writeAndOpenFile(n==null?void 0:n.join(` +`))}async editRemotes(){if(!await this.isAllInitialized())return;let r=await this.gitManager.getRemotes(),i=await new ze(this,{options:r,placeholder:"Select or create a new remote by typing its name and selecting it"}).openAndGetResult();if(i){let a=await this.gitManager.getRemoteUrl(i),o=await new ze(this,{initialValue:a,placeholder:"Enter remote URL"}).openAndGetResult();if(o)return await this.gitManager.setRemote(i,vv(o)),i}}async selectRemoteBranch(){let r=await this.gitManager.getRemotes(),n;r.length===0&&(n=await this.editRemotes(),n==null&&(r=await this.gitManager.getRemotes()));let i=new ze(this,{options:r,placeholder:"Select or create a new remote by typing its name and selecting it"}),a=n!=null?n:await i.openAndGetResult();if(a){this.displayMessage("Fetching remote branches"),await this.gitManager.fetch(a);let s=await this.gitManager.getRemoteBranches(a),l=await new ze(this,{options:s,placeholder:"Select or create a new remote branch by typing its name and selecting it"}).openAndGetResult();return l==null?void 0:l.startsWith(a+"/")?l:`${a}/${l}`}}async removeRemote(){if(!await this.isAllInitialized())return;let r=await this.gitManager.getRemotes(),i=await new ze(this,{options:r,placeholder:"Select a remote"}).openAndGetResult();i&&await this.gitManager.removeRemote(i)}onActiveLeafChange(r){var s,o;let n=r==null?void 0:r.view;if(!(n!=null&&n.getState().file)&&!(n instanceof ls||n instanceof fs))return;let i=this.app.workspace.getLeavesOfType($t.type).first(),a=this.app.workspace.getLeavesOfType(Zr.type).first();if((s=i==null?void 0:i.view.containerEl.querySelector("div.tree-item-self.is-active"))==null||s.removeClass("is-active"),(o=a==null?void 0:a.view.containerEl.querySelector("div.tree-item-self.is-active"))==null||o.removeClass("is-active"),(r==null?void 0:r.view)instanceof ls||(r==null?void 0:r.view)instanceof fs){let l=r.view.state.bFile;this.lastDiffViewState=r.view.getState();let c;i&&r.view.state.aRef=="HEAD"?c=i.view.containerEl.querySelector(`div.staged div.tree-item-self[data-path='${l}']`):i&&r.view.state.aRef==""?c=i.view.containerEl.querySelector(`div.changes div.tree-item-self[data-path='${l}']`):a&&(c=a.view.containerEl.querySelector(`div.tree-item-self[data-path='${l}']`)),c==null||c.addClass("is-active")}else this.lastDiffViewState=void 0}handleNoNetworkError(r){this.state.offlineMode?this.log("Encountered network error, but already in offline mode"):this.displayError("Git: Going into offline mode. Future network errors will no longer be displayed.",2e3),this.setPluginState({gitAction:0,offlineMode:!0})}displayMessage(r,n=4*1e3){var i;(i=this.statusBar)==null||i.displayMessage(r.toLowerCase(),n),this.settings.disablePopups||(!this.settings.disablePopupsForNoChanges||!r.startsWith("No changes"))&&new we.Notice(r,5*1e3),this.log(r)}displayError(r,n=10*1e3){var a;if(r instanceof D5.Errors.UserCanceledError){new we.Notice("Aborted");return}let i;r instanceof Error?i=r:i=new Error(String(r)),this.setPluginState({gitAction:0}),this.settings.showErrorNotices&&new we.Notice(i.message,n),console.error(`${this.manifest.id}:`,i.stack),(a=this.statusBar)==null||a.displayMessage(i.message.toLowerCase(),n)}log(...r){console.log(`${this.manifest.id}:`,...r)}}; /*! Bundled license information: ieee754/index.js: @@ -45277,3 +33335,5 @@ feather-icons/dist/feather.js: http://jedwatson.github.io/classnames *) */ + +/* nosourcemap */ diff --git a/.obsidian/plugins/obsidian-git/manifest.json b/.obsidian/plugins/obsidian-git/manifest.json index 79dc19c..2f24b79 100755 --- a/.obsidian/plugins/obsidian-git/manifest.json +++ b/.obsidian/plugins/obsidian-git/manifest.json @@ -1,9 +1,10 @@ { + "author": "Vinzent", + "authorUrl": "https://github.com/Vinzent03", "id": "obsidian-git", "name": "Git", - "description": "Backup your vault with Git.", + "description": "Integrate Git version control with automatic backup and other advanced features.", "isDesktopOnly": false, "fundingUrl": "https://ko-fi.com/vinzent", - "js": "main.js", - "version": "2.24.1" + "version": "2.35.2" } diff --git a/.obsidian/plugins/obsidian-git/styles.css b/.obsidian/plugins/obsidian-git/styles.css index 226dbe9..83c543b 100755 --- a/.obsidian/plugins/obsidian-git/styles.css +++ b/.obsidian/plugins/obsidian-git/styles.css @@ -14,11 +14,19 @@ } .workspace-leaf-content[data-type="git-view"] .view-content { - padding: 0; + padding-left: 0; + padding-top: 0; + padding-right: 0; } .workspace-leaf-content[data-type="git-history-view"] .view-content { - padding: 0; + padding-left: 0; + padding-top: 0; + padding-right: 0; +} + +.loading { + overflow: hidden; } .loading > svg { @@ -39,6 +47,10 @@ margin-right: auto; } +.obsidian-git-disabled { + opacity: 0.5; +} + .obsidian-git-center-button { display: block; margin: 20px auto; @@ -51,6 +63,15 @@ .tooltip.mod-right { overflow-wrap: break-word; } + +/* Limits the scrollbar to the view body */ +.git-view { + display: flex; + flex-direction: column; + position: relative; + height: 100%; +} + .git-tools { display: flex; margin-left: auto; @@ -77,6 +98,25 @@ height: auto; } +.workspace-leaf-content[data-type="git-view"] .tree-item-self, +.workspace-leaf-content[data-type="git-history-view"] .tree-item-self { + align-items: center; +} + +.workspace-leaf-content[data-type="git-view"] + .tree-item-self:hover + .clickable-icon, +.workspace-leaf-content[data-type="git-history-view"] + .tree-item-self:hover + .clickable-icon { + color: var(--icon-color-hover); +} + +/* Highlight an item as active if it's diff is currently opened */ +.is-active .git-tools .buttons > * { + color: var(--nav-item-color-active); +} + .git-author { color: var(--text-accent); } @@ -549,3 +589,41 @@ padding: 0px 6px 0px 6px; white-space: pre; /* Keep spaces and do not collapse them. */ } + +@media (max-width: 800px) { + /* hide git blame gutter not to superpose text */ + .cm-gutterElement.obs-git-blame-gutter { + display: none; + } +} + +.git-unified-diff-view, +.git-split-diff-view .cm-deletedLine .cm-changedText { + background-color: #ee443330; +} + +.git-unified-diff-view, +.git-split-diff-view .cm-insertedLine .cm-changedText { + background-color: #22bb2230; +} + +.git-obscure-prompt[git-is-obscured="true"] #git-show-password:after { + -webkit-mask-image: url('data:image/svg+xml,'); +} + +.git-obscure-prompt[git-is-obscured="false"] #git-show-password:after { + -webkit-mask-image: url('data:image/svg+xml,'); +} + +/* Override styling of Codemirror merge view "collapsed lines" indicator */ +.git-split-diff-view .ͼ2 .cm-collapsedLines { + background: var(--interactive-normal); + border-radius: var(--radius-m); + color: var(--text-accent); + font-size: var(--font-small); + padding: var(--size-4-1) var(--size-4-1); +} +.git-split-diff-view .ͼ2 .cm-collapsedLines:hover { + background: var(--interactive-hover); + color: var(--text-accent-hover); +} diff --git a/.obsidian/plugins/obsidian-style-settings/main.js b/.obsidian/plugins/obsidian-style-settings/main.js new file mode 100644 index 0000000..3a82c68 --- /dev/null +++ b/.obsidian/plugins/obsidian-style-settings/main.js @@ -0,0 +1,165 @@ +/* +THIS IS A GENERATED/BUNDLED FILE BY ESBUILD +if you want to view the source, please visit the github repository of this plugin +*/ + +var al=Object.create;var Kt=Object.defineProperty;var sl=Object.getOwnPropertyDescriptor;var ol=Object.getOwnPropertyNames;var ll=Object.getPrototypeOf,cl=Object.prototype.hasOwnProperty;var Zr=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),ul=(e,n)=>{for(var t in n)Kt(e,t,{get:n[t],enumerable:!0})},Zn=(e,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of ol(n))!cl.call(e,i)&&i!==t&&Kt(e,i,{get:()=>n[i],enumerable:!(a=sl(n,i))||a.enumerable});return e};var Xt=(e,n,t)=>(t=e!=null?al(ll(e)):{},Zn(n||!e||!e.__esModule?Kt(t,"default",{value:e,enumerable:!0}):t,e)),fl=e=>Zn(Kt({},"__esModule",{value:!0}),e);var Jn=Zr((Jr,en)=>{(function(e,n){typeof Jr=="object"&&typeof en!="undefined"?en.exports=n():typeof define=="function"&&define.amd?define(n):e.chroma=n()})(Jr,function(){"use strict";for(var e=function(r,s,o){return s===void 0&&(s=0),o===void 0&&(o=1),ro?o:r},n=function(r){r._clipped=!1,r._unclipped=r.slice(0);for(var s=0;s<=3;s++)s<3?((r[s]<0||r[s]>255)&&(r._clipped=!0),r[s]=e(r[s],0,255)):s===3&&(r[s]=e(r[s],0,1));return r},t={},a=0,i=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];a=3?Array.prototype.slice.call(r):c(r[0])=="object"&&s?s.split("").filter(function(o){return r[0][o]!==void 0}).map(function(o){return r[0][o]}):r[0]},p=function(r){if(r.length<2)return null;var s=r.length-1;return c(r[s])=="string"?r[s].toLowerCase():null},w=Math.PI,S={clip_rgb:n,limit:e,type:c,unpack:f,last:p,PI:w,TWOPI:w*2,PITHIRD:w/3,DEG2RAD:w/180,RAD2DEG:180/w},E={format:{},autodetect:[]},B=S.last,Y=S.clip_rgb,K=S.type,Q=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var g=this;if(K(s[0])==="object"&&s[0].constructor&&s[0].constructor===this.constructor)return s[0];var b=B(s),y=!1;if(!b){y=!0,E.sorted||(E.autodetect=E.autodetect.sort(function(R,O){return O.p-R.p}),E.sorted=!0);for(var d=0,A=E.autodetect;d4?r[4]:1;return y===1?[0,0,0,d]:[o>=1?0:255*(1-o)*(1-y),g>=1?0:255*(1-g)*(1-y),b>=1?0:255*(1-b)*(1-y),d]},Pe=xe,Qe=S.unpack,ie=S.type;L.prototype.cmyk=function(){return qe(this._rgb)},F.cmyk=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["cmyk"])))},E.format.cmyk=Pe,E.autodetect.push({p:2,test:function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];if(r=Qe(r,"cmyk"),ie(r)==="array"&&r.length===4)return"cmyk"}});var Tt=S.unpack,Ve=S.last,V=function(r){return Math.round(r*100)/100},M=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=Tt(r,"hsla"),g=Ve(r)||"lsa";return o[0]=V(o[0]||0),o[1]=V(o[1]*100)+"%",o[2]=V(o[2]*100)+"%",g==="hsla"||o.length>3&&o[3]<1?(o[3]=o.length>3?o[3]:1,g="hsla"):o.length=3,g+"("+o.join(",")+")"},_=M,u=S.unpack,h=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];r=u(r,"rgba");var o=r[0],g=r[1],b=r[2];o/=255,g/=255,b/=255;var y=Math.min(o,g,b),d=Math.max(o,g,b),A=(d+y)/2,k,N;return d===y?(k=0,N=Number.NaN):k=A<.5?(d-y)/(d+y):(d-y)/(2-d-y),o==d?N=(g-b)/(d-y):g==d?N=2+(b-o)/(d-y):b==d&&(N=4+(o-g)/(d-y)),N*=60,N<0&&(N+=360),r.length>3&&r[3]!==void 0?[N,k,A,r[3]]:[N,k,A]},m=h,C=S.unpack,v=S.last,x=Math.round,T=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=C(r,"rgba"),g=v(r)||"rgb";return g.substr(0,3)=="hsl"?_(m(o),g):(o[0]=x(o[0]),o[1]=x(o[1]),o[2]=x(o[2]),(g==="rgba"||o.length>3&&o[3]<1)&&(o[3]=o.length>3?o[3]:1,g="rgba"),g+"("+o.slice(0,g==="rgb"?3:4).join(",")+")")},I=T,D=S.unpack,P=Math.round,G=function(){for(var r,s=[],o=arguments.length;o--;)s[o]=arguments[o];s=D(s,"hsl");var g=s[0],b=s[1],y=s[2],d,A,k;if(b===0)d=A=k=y*255;else{var N=[0,0,0],R=[0,0,0],O=y<.5?y*(1+b):y+b-y*b,j=2*y-O,H=g/360;N[0]=H+1/3,N[1]=H,N[2]=H-1/3;for(var X=0;X<3;X++)N[X]<0&&(N[X]+=1),N[X]>1&&(N[X]-=1),6*N[X]<1?R[X]=j+(O-j)*6*N[X]:2*N[X]<1?R[X]=O:3*N[X]<2?R[X]=j+(O-j)*(2/3-N[X])*6:R[X]=j;r=[P(R[0]*255),P(R[1]*255),P(R[2]*255)],d=r[0],A=r[1],k=r[2]}return s.length>3?[d,A,k,s[3]]:[d,A,k,1]},q=G,U=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,fe=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,le=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,Oe=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,ye=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,Se=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,ae=Math.round,Re=function(r){r=r.toLowerCase().trim();var s;if(E.format.named)try{return E.format.named(r)}catch(X){}if(s=r.match(U)){for(var o=s.slice(1,4),g=0;g<3;g++)o[g]=+o[g];return o[3]=1,o}if(s=r.match(fe)){for(var b=s.slice(1,5),y=0;y<4;y++)b[y]=+b[y];return b}if(s=r.match(le)){for(var d=s.slice(1,4),A=0;A<3;A++)d[A]=ae(d[A]*2.55);return d[3]=1,d}if(s=r.match(Oe)){for(var k=s.slice(1,5),N=0;N<3;N++)k[N]=ae(k[N]*2.55);return k[3]=+k[3],k}if(s=r.match(ye)){var R=s.slice(1,4);R[1]*=.01,R[2]*=.01;var O=q(R);return O[3]=1,O}if(s=r.match(Se)){var j=s.slice(1,4);j[1]*=.01,j[2]*=.01;var H=q(j);return H[3]=+s[4],H}};Re.test=function(r){return U.test(r)||fe.test(r)||le.test(r)||Oe.test(r)||ye.test(r)||Se.test(r)};var _e=Re,Ke=S.type;L.prototype.css=function(r){return I(this._rgb,r)},F.css=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["css"])))},E.format.css=_e,E.autodetect.push({p:5,test:function(r){for(var s=[],o=arguments.length-1;o-- >0;)s[o]=arguments[o+1];if(!s.length&&Ke(r)==="string"&&_e.test(r))return"css"}});var Le=S.unpack;E.format.gl=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=Le(r,"rgba");return o[0]*=255,o[1]*=255,o[2]*=255,o},F.gl=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["gl"])))},L.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var et=S.unpack,gt=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=et(r,"rgb"),g=o[0],b=o[1],y=o[2],d=Math.min(g,b,y),A=Math.max(g,b,y),k=A-d,N=k*100/255,R=d/(255-k)*100,O;return k===0?O=Number.NaN:(g===A&&(O=(b-y)/k),b===A&&(O=2+(y-g)/k),y===A&&(O=4+(g-b)/k),O*=60,O<0&&(O+=360)),[O,N,R]},tt=gt,Ar=S.unpack,kr=Math.floor,Tr=function(){for(var r,s,o,g,b,y,d=[],A=arguments.length;A--;)d[A]=arguments[A];d=Ar(d,"hcg");var k=d[0],N=d[1],R=d[2],O,j,H;R=R*255;var X=N*255;if(N===0)O=j=H=R;else{k===360&&(k=0),k>360&&(k-=360),k<0&&(k+=360),k/=60;var ee=kr(k),Z=k-ee,se=R*(1-N),ge=se+X*(1-Z),Me=se+X*Z,Ie=se+X;switch(ee){case 0:r=[Ie,Me,se],O=r[0],j=r[1],H=r[2];break;case 1:s=[ge,Ie,se],O=s[0],j=s[1],H=s[2];break;case 2:o=[se,Ie,Me],O=o[0],j=o[1],H=o[2];break;case 3:g=[se,ge,Ie],O=g[0],j=g[1],H=g[2];break;case 4:b=[Me,se,Ie],O=b[0],j=b[1],H=b[2];break;case 5:y=[Ie,se,ge],O=y[0],j=y[1],H=y[2];break}}return[O,j,H,d.length>3?d[3]:1]},Lr=Tr,Mr=S.unpack,Ir=S.type;L.prototype.hcg=function(){return tt(this._rgb)},F.hcg=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["hcg"])))},E.format.hcg=Lr,E.autodetect.push({p:1,test:function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];if(r=Mr(r,"hcg"),Ir(r)==="array"&&r.length===3)return"hcg"}});var jt=S.unpack,Lt=S.last,Gt=Math.round,ja=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=jt(r,"rgba"),g=o[0],b=o[1],y=o[2],d=o[3],A=Lt(r)||"auto";d===void 0&&(d=1),A==="auto"&&(A=d<1?"rgba":"rgb"),g=Gt(g),b=Gt(b),y=Gt(y);var k=g<<16|b<<8|y,N="000000"+k.toString(16);N=N.substr(N.length-6);var R="0"+Gt(d*255).toString(16);switch(R=R.substr(R.length-2),A.toLowerCase()){case"rgba":return"#"+N+R;case"argb":return"#"+R+N;default:return"#"+N}},An=ja,Ga=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Ya=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,Ua=function(r){if(r.match(Ga)){(r.length===4||r.length===7)&&(r=r.substr(1)),r.length===3&&(r=r.split(""),r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var s=parseInt(r,16),o=s>>16,g=s>>8&255,b=s&255;return[o,g,b,1]}if(r.match(Ya)){(r.length===5||r.length===9)&&(r=r.substr(1)),r.length===4&&(r=r.split(""),r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]);var y=parseInt(r,16),d=y>>24&255,A=y>>16&255,k=y>>8&255,N=Math.round((y&255)/255*100)/100;return[d,A,k,N]}throw new Error("unknown hex color: "+r)},kn=Ua,Wa=S.type;L.prototype.hex=function(r){return An(this._rgb,r)},F.hex=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["hex"])))},E.format.hex=kn,E.autodetect.push({p:4,test:function(r){for(var s=[],o=arguments.length-1;o-- >0;)s[o]=arguments[o+1];if(!s.length&&Wa(r)==="string"&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var qa=S.unpack,Tn=S.TWOPI,za=Math.min,Ka=Math.sqrt,Xa=Math.acos,Qa=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=qa(r,"rgb"),g=o[0],b=o[1],y=o[2];g/=255,b/=255,y/=255;var d,A=za(g,b,y),k=(g+b+y)/3,N=k>0?1-A/k:0;return N===0?d=NaN:(d=(g-b+(g-y))/2,d/=Ka((g-b)*(g-b)+(g-y)*(b-y)),d=Xa(d),y>b&&(d=Tn-d),d/=Tn),[d*360,N,k]},Za=Qa,Ja=S.unpack,Fr=S.limit,pt=S.TWOPI,Nr=S.PITHIRD,ht=Math.cos,es=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];r=Ja(r,"hsi");var o=r[0],g=r[1],b=r[2],y,d,A;return isNaN(o)&&(o=0),isNaN(g)&&(g=0),o>360&&(o-=360),o<0&&(o+=360),o/=360,o<1/3?(A=(1-g)/3,y=(1+g*ht(pt*o)/ht(Nr-pt*o))/3,d=1-(A+y)):o<2/3?(o-=1/3,y=(1-g)/3,d=(1+g*ht(pt*o)/ht(Nr-pt*o))/3,A=1-(y+d)):(o-=2/3,d=(1-g)/3,A=(1+g*ht(pt*o)/ht(Nr-pt*o))/3,y=1-(d+A)),y=Fr(b*y*3),d=Fr(b*d*3),A=Fr(b*A*3),[y*255,d*255,A*255,r.length>3?r[3]:1]},ts=es,rs=S.unpack,ns=S.type;L.prototype.hsi=function(){return Za(this._rgb)},F.hsi=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["hsi"])))},E.format.hsi=ts,E.autodetect.push({p:2,test:function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];if(r=rs(r,"hsi"),ns(r)==="array"&&r.length===3)return"hsi"}});var is=S.unpack,as=S.type;L.prototype.hsl=function(){return m(this._rgb)},F.hsl=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["hsl"])))},E.format.hsl=q,E.autodetect.push({p:2,test:function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];if(r=is(r,"hsl"),as(r)==="array"&&r.length===3)return"hsl"}});var ss=S.unpack,os=Math.min,ls=Math.max,cs=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];r=ss(r,"rgb");var o=r[0],g=r[1],b=r[2],y=os(o,g,b),d=ls(o,g,b),A=d-y,k,N,R;return R=d/255,d===0?(k=Number.NaN,N=0):(N=A/d,o===d&&(k=(g-b)/A),g===d&&(k=2+(b-o)/A),b===d&&(k=4+(o-g)/A),k*=60,k<0&&(k+=360)),[k,N,R]},us=cs,fs=S.unpack,gs=Math.floor,ps=function(){for(var r,s,o,g,b,y,d=[],A=arguments.length;A--;)d[A]=arguments[A];d=fs(d,"hsv");var k=d[0],N=d[1],R=d[2],O,j,H;if(R*=255,N===0)O=j=H=R;else{k===360&&(k=0),k>360&&(k-=360),k<0&&(k+=360),k/=60;var X=gs(k),ee=k-X,Z=R*(1-N),se=R*(1-N*ee),ge=R*(1-N*(1-ee));switch(X){case 0:r=[R,ge,Z],O=r[0],j=r[1],H=r[2];break;case 1:s=[se,R,Z],O=s[0],j=s[1],H=s[2];break;case 2:o=[Z,R,ge],O=o[0],j=o[1],H=o[2];break;case 3:g=[Z,se,R],O=g[0],j=g[1],H=g[2];break;case 4:b=[ge,Z,R],O=b[0],j=b[1],H=b[2];break;case 5:y=[R,Z,se],O=y[0],j=y[1],H=y[2];break}}return[O,j,H,d.length>3?d[3]:1]},hs=ps,ds=S.unpack,vs=S.type;L.prototype.hsv=function(){return us(this._rgb)},F.hsv=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["hsv"])))},E.format.hsv=hs,E.autodetect.push({p:2,test:function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];if(r=ds(r,"hsv"),vs(r)==="array"&&r.length===3)return"hsv"}});var Be={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},ms=S.unpack,Ln=Math.pow,bs=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=ms(r,"rgb"),g=o[0],b=o[1],y=o[2],d=ys(g,b,y),A=d[0],k=d[1],N=d[2],R=116*k-16;return[R<0?0:R,500*(A-k),200*(k-N)]},Or=function(r){return(r/=255)<=.04045?r/12.92:Ln((r+.055)/1.055,2.4)},Dr=function(r){return r>Be.t3?Ln(r,1/3):r/Be.t2+Be.t0},ys=function(r,s,o){r=Or(r),s=Or(s),o=Or(o);var g=Dr((.4124564*r+.3575761*s+.1804375*o)/Be.Xn),b=Dr((.2126729*r+.7151522*s+.072175*o)/Be.Yn),y=Dr((.0193339*r+.119192*s+.9503041*o)/Be.Zn);return[g,b,y]},Mn=bs,Ss=S.unpack,Cs=Math.pow,xs=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];r=Ss(r,"lab");var o=r[0],g=r[1],b=r[2],y,d,A,k,N,R;return d=(o+16)/116,y=isNaN(g)?d:d+g/500,A=isNaN(b)?d:d-b/200,d=Be.Yn*$r(d),y=Be.Xn*$r(y),A=Be.Zn*$r(A),k=Rr(3.2404542*y-1.5371385*d-.4985314*A),N=Rr(-.969266*y+1.8760108*d+.041556*A),R=Rr(.0556434*y-.2040259*d+1.0572252*A),[k,N,R,r.length>3?r[3]:1]},Rr=function(r){return 255*(r<=.00304?12.92*r:1.055*Cs(r,1/2.4)-.055)},$r=function(r){return r>Be.t1?r*r*r:Be.t2*(r-Be.t0)},In=xs,ws=S.unpack,Es=S.type;L.prototype.lab=function(){return Mn(this._rgb)},F.lab=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["lab"])))},E.format.lab=In,E.autodetect.push({p:2,test:function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];if(r=ws(r,"lab"),Es(r)==="array"&&r.length===3)return"lab"}});var _s=S.unpack,As=S.RAD2DEG,ks=Math.sqrt,Ts=Math.atan2,Ls=Math.round,Ms=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=_s(r,"lab"),g=o[0],b=o[1],y=o[2],d=ks(b*b+y*y),A=(Ts(y,b)*As+360)%360;return Ls(d*1e4)===0&&(A=Number.NaN),[g,d,A]},Is=Ms,Fs=S.unpack,Ns=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=Fs(r,"rgb"),g=o[0],b=o[1],y=o[2],d=Mn(g,b,y),A=d[0],k=d[1],N=d[2];return Is(A,k,N)},Fn=Ns,Os=S.unpack,Ds=S.DEG2RAD,Rs=Math.sin,$s=Math.cos,Ps=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=Os(r,"lch"),g=o[0],b=o[1],y=o[2];return isNaN(y)&&(y=0),y=y*Ds,[g,$s(y)*b,Rs(y)*b]},Vs=Ps,Bs=S.unpack,Hs=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];r=Bs(r,"lch");var o=r[0],g=r[1],b=r[2],y=Vs(o,g,b),d=y[0],A=y[1],k=y[2],N=In(d,A,k),R=N[0],O=N[1],j=N[2];return[R,O,j,r.length>3?r[3]:1]},Nn=Hs,js=S.unpack,Gs=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=js(r,"hcl").reverse();return Nn.apply(void 0,o)},Ys=Gs,Us=S.unpack,Ws=S.type;L.prototype.lch=function(){return Fn(this._rgb)},L.prototype.hcl=function(){return Fn(this._rgb).reverse()},F.lch=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["lch"])))},F.hcl=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["hcl"])))},E.format.lch=Nn,E.format.hcl=Ys,["lch","hcl"].forEach(function(r){return E.autodetect.push({p:2,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=Us(s,r),Ws(s)==="array"&&s.length===3)return r}})});var qs={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},dt=qs,zs=S.type;L.prototype.name=function(){for(var r=An(this._rgb,"rgb"),s=0,o=Object.keys(dt);s0;)s[o]=arguments[o+1];if(!s.length&&zs(r)==="string"&&dt[r.toLowerCase()])return"named"}});var Ks=S.unpack,Xs=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=Ks(r,"rgb"),g=o[0],b=o[1],y=o[2];return(g<<16)+(b<<8)+y},Qs=Xs,Zs=S.type,Js=function(r){if(Zs(r)=="number"&&r>=0&&r<=16777215){var s=r>>16,o=r>>8&255,g=r&255;return[s,o,g,1]}throw new Error("unknown num color: "+r)},eo=Js,to=S.type;L.prototype.num=function(){return Qs(this._rgb)},F.num=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["num"])))},E.format.num=eo,E.autodetect.push({p:5,test:function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];if(r.length===1&&to(r[0])==="number"&&r[0]>=0&&r[0]<=16777215)return"num"}});var On=S.unpack,Dn=S.type,Rn=Math.round;L.prototype.rgb=function(r){return r===void 0&&(r=!0),r===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Rn)},L.prototype.rgba=function(r){return r===void 0&&(r=!0),this._rgb.slice(0,4).map(function(s,o){return o<3?r===!1?s:Rn(s):s})},F.rgb=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["rgb"])))},E.format.rgb=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];var o=On(r,"rgba");return o[3]===void 0&&(o[3]=1),o},E.autodetect.push({p:3,test:function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];if(r=On(r,"rgba"),Dn(r)==="array"&&(r.length===3||r.length===4&&Dn(r[3])=="number"&&r[3]>=0&&r[3]<=1))return"rgb"}});var Yt=Math.log,ro=function(r){var s=r/100,o,g,b;return s<66?(o=255,g=-155.25485562709179-.44596950469579133*(g=s-2)+104.49216199393888*Yt(g),b=s<20?0:-254.76935184120902+.8274096064007395*(b=s-10)+115.67994401066147*Yt(b)):(o=351.97690566805693+.114206453784165*(o=s-55)-40.25366309332127*Yt(o),g=325.4494125711974+.07943456536662342*(g=s-50)-28.0852963507957*Yt(g),b=255),[o,g,b,1]},$n=ro,no=S.unpack,io=Math.round,ao=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];for(var o=no(r,"rgb"),g=o[0],b=o[2],y=1e3,d=4e4,A=.4,k;d-y>A;){k=(d+y)*.5;var N=$n(k);N[2]/N[0]>=b/g?d=k:y=k}return io(k)},so=ao;L.prototype.temp=L.prototype.kelvin=L.prototype.temperature=function(){return so(this._rgb)},F.temp=F.kelvin=F.temperature=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];return new(Function.prototype.bind.apply(L,[null].concat(r,["temp"])))},E.format.temp=E.format.kelvin=E.format.temperature=$n;var oo=S.type;L.prototype.alpha=function(r,s){return s===void 0&&(s=!1),r!==void 0&&oo(r)==="number"?s?(this._rgb[3]=r,this):new L([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},L.prototype.clipped=function(){return this._rgb._clipped||!1},L.prototype.darken=function(r){r===void 0&&(r=1);var s=this,o=s.lab();return o[0]-=Be.Kn*r,new L(o,"lab").alpha(s.alpha(),!0)},L.prototype.brighten=function(r){return r===void 0&&(r=1),this.darken(-r)},L.prototype.darker=L.prototype.darken,L.prototype.brighter=L.prototype.brighten,L.prototype.get=function(r){var s=r.split("."),o=s[0],g=s[1],b=this[o]();if(g){var y=o.indexOf(g);if(y>-1)return b[y];throw new Error("unknown channel "+g+" in mode "+o)}else return b};var lo=S.type,co=Math.pow,uo=1e-7,fo=20;L.prototype.luminance=function(r){if(r!==void 0&&lo(r)==="number"){if(r===0)return new L([0,0,0,this._rgb[3]],"rgb");if(r===1)return new L([255,255,255,this._rgb[3]],"rgb");var s=this.luminance(),o="rgb",g=fo,b=function(d,A){var k=d.interpolate(A,.5,o),N=k.luminance();return Math.abs(r-N)r?b(d,k):b(k,A)},y=(s>r?b(new L([0,0,0]),this):b(this,new L([255,255,255]))).rgb();return new L(y.concat([this._rgb[3]]))}return go.apply(void 0,this._rgb.slice(0,3))};var go=function(r,s,o){return r=Pr(r),s=Pr(s),o=Pr(o),.2126*r+.7152*s+.0722*o},Pr=function(r){return r/=255,r<=.03928?r/12.92:co((r+.055)/1.055,2.4)},He={},Pn=S.type,Vn=function(r,s,o){o===void 0&&(o=.5);for(var g=[],b=arguments.length-3;b-- >0;)g[b]=arguments[b+3];var y=g[0]||"lrgb";if(!He[y]&&!g.length&&(y=Object.keys(He)[0]),!He[y])throw new Error("interpolation mode "+y+" is not defined");return Pn(r)!=="object"&&(r=new L(r)),Pn(s)!=="object"&&(s=new L(s)),He[y](r,s,o).alpha(r.alpha()+o*(s.alpha()-r.alpha()))};L.prototype.mix=L.prototype.interpolate=function(r,s){s===void 0&&(s=.5);for(var o=[],g=arguments.length-2;g-- >0;)o[g]=arguments[g+2];return Vn.apply(void 0,[this,r,s].concat(o))},L.prototype.premultiply=function(r){r===void 0&&(r=!1);var s=this._rgb,o=s[3];return r?(this._rgb=[s[0]*o,s[1]*o,s[2]*o,o],this):new L([s[0]*o,s[1]*o,s[2]*o,o],"rgb")},L.prototype.saturate=function(r){r===void 0&&(r=1);var s=this,o=s.lch();return o[1]+=Be.Kn*r,o[1]<0&&(o[1]=0),new L(o,"lch").alpha(s.alpha(),!0)},L.prototype.desaturate=function(r){return r===void 0&&(r=1),this.saturate(-r)};var Bn=S.type;L.prototype.set=function(r,s,o){o===void 0&&(o=!1);var g=r.split("."),b=g[0],y=g[1],d=this[b]();if(y){var A=b.indexOf(y);if(A>-1){if(Bn(s)=="string")switch(s.charAt(0)){case"+":d[A]+=+s;break;case"-":d[A]+=+s;break;case"*":d[A]*=+s.substr(1);break;case"/":d[A]/=+s.substr(1);break;default:d[A]=+s}else if(Bn(s)==="number")d[A]=s;else throw new Error("unsupported value for Color.set");var k=new L(d,b);return o?(this._rgb=k._rgb,this):k}throw new Error("unknown channel "+y+" in mode "+b)}else return d};var po=function(r,s,o){var g=r._rgb,b=s._rgb;return new L(g[0]+o*(b[0]-g[0]),g[1]+o*(b[1]-g[1]),g[2]+o*(b[2]-g[2]),"rgb")};He.rgb=po;var Vr=Math.sqrt,vt=Math.pow,ho=function(r,s,o){var g=r._rgb,b=g[0],y=g[1],d=g[2],A=s._rgb,k=A[0],N=A[1],R=A[2];return new L(Vr(vt(b,2)*(1-o)+vt(k,2)*o),Vr(vt(y,2)*(1-o)+vt(N,2)*o),Vr(vt(d,2)*(1-o)+vt(R,2)*o),"rgb")};He.lrgb=ho;var vo=function(r,s,o){var g=r.lab(),b=s.lab();return new L(g[0]+o*(b[0]-g[0]),g[1]+o*(b[1]-g[1]),g[2]+o*(b[2]-g[2]),"lab")};He.lab=vo;var Mt=function(r,s,o,g){var b,y,d,A;g==="hsl"?(d=r.hsl(),A=s.hsl()):g==="hsv"?(d=r.hsv(),A=s.hsv()):g==="hcg"?(d=r.hcg(),A=s.hcg()):g==="hsi"?(d=r.hsi(),A=s.hsi()):(g==="lch"||g==="hcl")&&(g="hcl",d=r.hcl(),A=s.hcl());var k,N,R,O,j,H;g.substr(0,1)==="h"&&(b=d,k=b[0],R=b[1],j=b[2],y=A,N=y[0],O=y[1],H=y[2]);var X,ee,Z,se;return!isNaN(k)&&!isNaN(N)?(N>k&&N-k>180?se=N-(k+360):N180?se=N+360-k:se=N-k,ee=k+o*se):isNaN(k)?isNaN(N)?ee=Number.NaN:(ee=N,(j==1||j==0)&&g!="hsv"&&(X=O)):(ee=k,(H==1||H==0)&&g!="hsv"&&(X=R)),X===void 0&&(X=R+o*(O-R)),Z=j+o*(H-j),new L([ee,X,Z],g)},Hn=function(r,s,o){return Mt(r,s,o,"lch")};He.lch=Hn,He.hcl=Hn;var mo=function(r,s,o){var g=r.num(),b=s.num();return new L(g+o*(b-g),"num")};He.num=mo;var bo=function(r,s,o){return Mt(r,s,o,"hcg")};He.hcg=bo;var yo=function(r,s,o){return Mt(r,s,o,"hsi")};He.hsi=yo;var So=function(r,s,o){return Mt(r,s,o,"hsl")};He.hsl=So;var Co=function(r,s,o){return Mt(r,s,o,"hsv")};He.hsv=Co;var xo=S.clip_rgb,Br=Math.pow,Hr=Math.sqrt,jr=Math.PI,jn=Math.cos,Gn=Math.sin,wo=Math.atan2,Eo=function(r,s,o){s===void 0&&(s="lrgb"),o===void 0&&(o=null);var g=r.length;o||(o=Array.from(new Array(g)).map(function(){return 1}));var b=g/o.reduce(function(ee,Z){return ee+Z});if(o.forEach(function(ee,Z){o[Z]*=b}),r=r.map(function(ee){return new L(ee)}),s==="lrgb")return _o(r,o);for(var y=r.shift(),d=y.get(s),A=[],k=0,N=0,R=0;R=360;)X-=360;d[H]=X}else d[H]=d[H]/A[H];return j/=g,new L(d,s).alpha(j>.99999?1:j,!0)},_o=function(r,s){for(var o=r.length,g=[0,0,0,0],b=0;b.9999999&&(g[3]=1),new L(xo(g))},mt=S.type,Ao=Math.pow,Ut=function(r){var s="rgb",o=F("#ccc"),g=0,b=[0,1],y=[],d=[0,0],A=!1,k=[],N=!1,R=0,O=1,j=!1,H={},X=!0,ee=1,Z=function($){if($=$||["#fff","#000"],$&&mt($)==="string"&&F.brewer&&F.brewer[$.toLowerCase()]&&($=F.brewer[$.toLowerCase()]),mt($)==="array"){$.length===1&&($=[$[0],$[0]]),$=$.slice(0);for(var z=0;z<$.length;z++)$[z]=F($[z]);y.length=0;for(var te=0;te<$.length;te++)y.push(te/($.length-1))}return Ue(),k=$},se=function($){if(A!=null){for(var z=A.length-1,te=0;te=A[te];)te++;return te-1}return 0},ge=function($){return $},Me=function($){return $},Ie=function($,z){var te,J;if(z==null&&(z=!1),isNaN($)||$===null)return o;if(z)J=$;else if(A&&A.length>2){var je=se($);J=je/(A.length-2)}else O!==R?J=($-R)/(O-R):J=1;J=Me(J),z||(J=ge(J)),ee!==1&&(J=Ao(J,ee)),J=d[0]+J*(1-d[0]-d[1]),J=Math.min(1,Math.max(0,J));var be=Math.floor(J*1e4);if(X&&H[be])te=H[be];else{if(mt(k)==="array")for(var ce=0;ce=ue&&ce===y.length-1){te=k[ce];break}if(J>ue&&J2){var ce=$.map(function(we,pe){return pe/($.length-1)}),ue=$.map(function(we){return(we-R)/(O-R)});ue.every(function(we,pe){return ce[pe]===we})||(Me=function(we){if(we<=0||we>=1)return we;for(var pe=0;we>=ue[pe+1];)pe++;var it=(we-ue[pe])/(ue[pe+1]-ue[pe]),bt=ce[pe]+it*(ce[pe+1]-ce[pe]);return bt})}}return b=[R,O],ne},ne.mode=function($){return arguments.length?(s=$,Ue(),ne):s},ne.range=function($,z){return Z($,z),ne},ne.out=function($){return N=$,ne},ne.spread=function($){return arguments.length?(g=$,ne):g},ne.correctLightness=function($){return $==null&&($=!0),j=$,Ue(),j?ge=function(z){for(var te=Ie(0,!0).lab()[0],J=Ie(1,!0).lab()[0],je=te>J,be=Ie(z,!0).lab()[0],ce=te+(J-te)*z,ue=be-ce,we=0,pe=1,it=20;Math.abs(ue)>.01&&it-- >0;)(function(){return je&&(ue*=-1),ue<0?(we=z,z+=(pe-z)*.5):(pe=z,z+=(we-z)*.5),be=Ie(z,!0).lab()[0],ue=be-ce})();return z}:ge=function(z){return z},ne},ne.padding=function($){return $!=null?(mt($)==="number"&&($=[$,$]),d=$,ne):d},ne.colors=function($,z){arguments.length<2&&(z="hex");var te=[];if(arguments.length===0)te=k.slice(0);else if($===1)te=[ne(.5)];else if($>1){var J=b[0],je=b[1]-J;te=ko(0,$,!1).map(function(pe){return ne(J+pe/($-1)*je)})}else{r=[];var be=[];if(A&&A.length>2)for(var ce=1,ue=A.length,we=1<=ue;we?ceue;we?ce++:ce--)be.push((A[ce-1]+A[ce])*.5);else be=b;te=be.map(function(pe){return ne(pe)})}return F[z]&&(te=te.map(function(pe){return pe[z]()})),te},ne.cache=function($){return $!=null?(X=$,ne):X},ne.gamma=function($){return $!=null?(ee=$,ne):ee},ne.nodata=function($){return $!=null?(o=F($),ne):o},ne};function ko(r,s,o){for(var g=[],b=ry;b?d++:d--)g.push(d);return g}var Gr=function(r){var s,o,g,b,y,d,A;if(r=r.map(function(O){return new L(O)}),r.length===2)s=r.map(function(O){return O.lab()}),y=s[0],d=s[1],b=function(O){var j=[0,1,2].map(function(H){return y[H]+O*(d[H]-y[H])});return new L(j,"lab")};else if(r.length===3)o=r.map(function(O){return O.lab()}),y=o[0],d=o[1],A=o[2],b=function(O){var j=[0,1,2].map(function(H){return(1-O)*(1-O)*y[H]+2*(1-O)*O*d[H]+O*O*A[H]});return new L(j,"lab")};else if(r.length===4){var k;g=r.map(function(O){return O.lab()}),y=g[0],d=g[1],A=g[2],k=g[3],b=function(O){var j=[0,1,2].map(function(H){return(1-O)*(1-O)*(1-O)*y[H]+3*(1-O)*(1-O)*O*d[H]+3*(1-O)*O*O*A[H]+O*O*O*k[H]});return new L(j,"lab")}}else if(r.length===5){var N=Gr(r.slice(0,3)),R=Gr(r.slice(2,5));b=function(O){return O<.5?N(O*2):R((O-.5)*2)}}return b},To=function(r){var s=Gr(r);return s.scale=function(){return Ut(s)},s},ze=function(r,s,o){if(!ze[o])throw new Error("unknown blend mode "+o);return ze[o](r,s)},rt=function(r){return function(s,o){var g=F(o).rgb(),b=F(s).rgb();return F.rgb(r(g,b))}},nt=function(r){return function(s,o){var g=[];return g[0]=r(s[0],o[0]),g[1]=r(s[1],o[1]),g[2]=r(s[2],o[2]),g}},Lo=function(r){return r},Mo=function(r,s){return r*s/255},Io=function(r,s){return r>s?s:r},Fo=function(r,s){return r>s?r:s},No=function(r,s){return 255*(1-(1-r/255)*(1-s/255))},Oo=function(r,s){return s<128?2*r*s/255:255*(1-2*(1-r/255)*(1-s/255))},Do=function(r,s){return 255*(1-(1-s/255)/(r/255))},Ro=function(r,s){return r===255?255:(r=255*(s/255)/(1-r/255),r>255?255:r)};ze.normal=rt(nt(Lo)),ze.multiply=rt(nt(Mo)),ze.screen=rt(nt(No)),ze.overlay=rt(nt(Oo)),ze.darken=rt(nt(Io)),ze.lighten=rt(nt(Fo)),ze.dodge=rt(nt(Ro)),ze.burn=rt(nt(Do));for(var $o=ze,Yr=S.type,Po=S.clip_rgb,Vo=S.TWOPI,Bo=Math.pow,Ho=Math.sin,jo=Math.cos,Go=function(r,s,o,g,b){r===void 0&&(r=300),s===void 0&&(s=-1.5),o===void 0&&(o=1),g===void 0&&(g=1),b===void 0&&(b=[0,1]);var y=0,d;Yr(b)==="array"?d=b[1]-b[0]:(d=0,b=[b,b]);var A=function(k){var N=Vo*((r+120)/360+s*k),R=Bo(b[0]+d*k,g),O=y!==0?o[0]+k*y:o,j=O*R*(1-R)/2,H=jo(N),X=Ho(N),ee=R+j*(-.14861*H+1.78277*X),Z=R+j*(-.29227*H-.90649*X),se=R+j*(1.97294*H);return F(Po([ee*255,Z*255,se*255,1]))};return A.start=function(k){return k==null?r:(r=k,A)},A.rotations=function(k){return k==null?s:(s=k,A)},A.gamma=function(k){return k==null?g:(g=k,A)},A.hue=function(k){return k==null?o:(o=k,Yr(o)==="array"?(y=o[1]-o[0],y===0&&(o=o[1])):y=0,A)},A.lightness=function(k){return k==null?b:(Yr(k)==="array"?(b=k,d=k[1]-k[0]):(b=[k,k],d=0),A)},A.scale=function(){return F.scale(A)},A.hue(o),A},Yo="0123456789abcdef",Uo=Math.floor,Wo=Math.random,qo=function(){for(var r="#",s=0;s<6;s++)r+=Yo.charAt(Uo(Wo()*16));return new L(r,"hex")},Yn=Math.log,zo=Math.pow,Ko=Math.floor,Xo=Math.abs,Un=function(r,s){s===void 0&&(s=null);var o={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return c(r)==="object"&&(r=Object.values(r)),r.forEach(function(g){s&&c(g)==="object"&&(g=g[s]),g!=null&&!isNaN(g)&&(o.values.push(g),o.sum+=g,go.max&&(o.max=g),o.count+=1)}),o.domain=[o.min,o.max],o.limits=function(g,b){return Wn(o,g,b)},o},Wn=function(r,s,o){s===void 0&&(s="equal"),o===void 0&&(o=7),c(r)=="array"&&(r=Un(r));var g=r.min,b=r.max,y=r.values.sort(function(Xr,Qr){return Xr-Qr});if(o===1)return[g,b];var d=[];if(s.substr(0,1)==="c"&&(d.push(g),d.push(b)),s.substr(0,1)==="e"){d.push(g);for(var A=1;A 0");var k=Math.LOG10E*Yn(g),N=Math.LOG10E*Yn(b);d.push(g);for(var R=1;R200&&(Me=!1)}for(var It={},qr=0;qrg?(o+.05)/(g+.05):(g+.05)/(o+.05)},Wt=Math.sqrt,Zo=Math.atan2,zn=Math.abs,Kn=Math.cos,Ur=Math.PI,Jo=function(r,s,o,g){o===void 0&&(o=1),g===void 0&&(g=1),r=new L(r),s=new L(s);for(var b=Array.from(r.lab()),y=b[0],d=b[1],A=b[2],k=Array.from(s.lab()),N=k[0],R=k[1],O=k[2],j=Wt(d*d+A*A),H=Wt(R*R+O*O),X=y<16?.511:.040975*y/(1+.01765*y),ee=.0638*j/(1+.0131*j)+.638,Z=j<1e-6?0:Zo(A,d)*180/Ur;Z<0;)Z+=360;for(;Z>=360;)Z-=360;var se=Z>=164&&Z<=345?.56+zn(.2*Kn(Ur*(Z+168)/180)):.36+zn(.4*Kn(Ur*(Z+35)/180)),ge=j*j*j*j,Me=Wt(ge/(ge+1900)),Ie=ee*(Me*se+1-Me),Ue=y-N,ne=j-H,$=d-R,z=A-O,te=$*$+z*z-ne*ne,J=Ue/(o*X),je=ne/(g*ee),be=Ie;return Wt(J*J+je*je+te/(be*be))},el=function(r,s,o){o===void 0&&(o="lab"),r=new L(r),s=new L(s);var g=r.get(o),b=s.get(o),y=0;for(var d in g){var A=(g[d]||0)-(b[d]||0);y+=A*A}return Math.sqrt(y)},tl=function(){for(var r=[],s=arguments.length;s--;)r[s]=arguments[s];try{return new(Function.prototype.bind.apply(L,[null].concat(r))),!0}catch(o){return!1}},rl={cool:function(){return Ut([F.hsl(180,1,.9),F.hsl(250,.7,.4)])},hot:function(){return Ut(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")}},qt={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},Wr=0,Xn=Object.keys(qt);Wr{((e,n)=>{typeof define=="function"&&define.amd?define([],n):typeof er=="object"&&er.exports?er.exports=n():e.fuzzysort=n()})(_i,e=>{"use strict";var n=(V,M)=>{if(V=="farzher")return{target:"farzher was here (^-^*)/",score:0,_indexes:[0]};if(!V||!M)return ie;var _=w(V);Te(M)||(M=p(M));var u=_.bitflags;return(u&M._bitflags)!==u?ie:E(_,M)},t=(V,M,_)=>{if(V=="farzher")return[{target:"farzher was here (^-^*)/",score:0,_indexes:[0],obj:M?M[0]:ie}];if(!V)return _&&_.all?S(V,M,_):Qe;var u=w(V),h=u.bitflags,m=u.containsSpace,C=_&&_.threshold||Pe,v=_&&_.limit||xe,x=0,T=0,I=M.length;if(_&&_.key)for(var D=_.key,P=0;PVe.peek().score&&Ve.replaceTop(U))))}}else if(_&&_.keys)for(var fe=_.scoreFn||Ye,le=_.keys,Oe=le.length,P=0;PVe.peek().score&&Ve.replaceTop(ye))))}else for(var P=0;PVe.peek().score&&Ve.replaceTop(U))))}}if(x===0)return Qe;for(var Re=new Array(x),P=x-1;P>=0;--P)Re[P]=Ve.poll();return Re.total=x+T,Re},a=(V,M,_)=>{if(typeof M=="function")return i(V,M);if(V===ie)return ie;M===void 0&&(M=""),_===void 0&&(_="");var u="",h=0,m=!1,C=V.target,v=C.length,x=V._indexes;x=x.slice(0,x.len).sort((D,P)=>D-P);for(var T=0;T{if(T===ie)return ie;var _=T.target,u=_.length,h=T._indexes;h=h.slice(0,h.len).sort((P,G)=>P-G);for(var m="",C=0,v=0,x=!1,T=[],I=0;IV._indexes.slice(0,V._indexes.len).sort((M,_)=>M-_),c=V=>{typeof V!="string"&&(V="");var M=Y(V);return{target:V,_targetLower:M._lower,_targetLowerCodes:M.lowerCodes,_nextBeginningIndexes:ie,_bitflags:M.bitflags,score:ie,_indexes:[0],obj:ie}},f=V=>{typeof V!="string"&&(V=""),V=V.trim();var M=Y(V),_=[];if(M.containsSpace){var u=V.split(/\s+/);u=[...new Set(u)];for(var h=0;h{if(V.length>999)return c(V);var M=re.get(V);return M!==void 0||(M=c(V),re.set(V,M)),M},w=V=>{if(V.length>999)return f(V);var M=F.get(V);return M!==void 0||(M=f(V),F.set(V,M)),M},S=(V,M,_)=>{var u=[];u.total=M.length;var h=_&&_.limit||xe;if(_&&_.key)for(var m=0;m=h)return u}}else if(_&&_.keys)for(var m=0;m=0;--I){var v=qe(C,_.keys[I]);if(!v){T[I]=ie;continue}Te(v)||(v=p(v)),v.score=Pe,v._indexes.len=0,T[I]=v}if(T.obj=C,T.score=Pe,u.push(T),u.length>=h)return u}else for(var m=0;m=h))return u}return u},E=(V,M,_=!1)=>{if(_===!1&&V.containsSpace)return B(V,M);for(var u=V._lower,h=V.lowerCodes,m=h[0],C=M._targetLowerCodes,v=h.length,x=C.length,P=0,T=0,I=0;;){var D=m===C[T];if(D){if(oe[I++]=T,++P,P===v)break;m=h[P]}if(++T,T>=x)return ie}var P=0,G=!1,q=0,U=M._nextBeginningIndexes;U===ie&&(U=M._nextBeginningIndexes=Q(M.target));var fe=T=oe[0]===0?0:U[oe[0]-1],le=0;if(T!==x)for(;;)if(T>=x){if(P<=0||(++le,le>200))break;--P;var Oe=ke[--q];T=U[Oe]}else{var D=h[P]===C[T];if(D){if(ke[q++]=T,++P,P===v){G=!0;break}++T}else T=U[T]}var ye=M._targetLower.indexOf(u,oe[0]),Se=~ye;if(Se&&!G)for(var ae=0;ae24&&(Le*=(tt-24)*10)}Se&&(Le/=1+v*v*1),Re&&(Le/=1+v*v*1),Le-=x-v,M.score=Le;for(var ae=0;ae{for(var _=new Set,u=0,h=ie,m=0,C=V.spaceSearches,I=0;Iu)return T;h.score=u;var I=0;for(let D of _)h._indexes[I++]=D;return h._indexes.len=I,h},Y=V=>{for(var M=V.length,_=V.toLowerCase(),u=[],h=0,m=!1,C=0;C=97&&v<=122?v-97:v>=48&&v<=57?26:v<=127?30:31;h|=1<{for(var M=V.length,_=[],u=0,h=!1,m=!1,C=0;C=65&&v<=90,T=x||v>=97&&v<=122||v>=48&&v<=57,I=x&&!h||!m||!T;h=x,m=T,I&&(_[u++]=C)}return _},Q=V=>{for(var M=V.length,_=K(V),u=[],h=_[0],m=0,C=0;CC?u[C]=h:(h=_[++m],u[C]=h===void 0?M:h);return u},L=()=>{re.clear(),F.clear(),oe=[],ke=[]},re=new Map,F=new Map,oe=[],ke=[],Ye=V=>{for(var M=Pe,_=V.length,u=0;u<_;++u){var h=V[u];if(h!==ie){var m=h.score;m>M&&(M=m)}}return M===Pe?ie:M},qe=(V,M)=>{var _=V[M];if(_!==void 0)return _;var u=M;Array.isArray(M)||(u=M.split("."));for(var h=u.length,m=-1;V&&++mtypeof V=="object",xe=1/0,Pe=-xe,Qe=[];Qe.total=0;var ie=null,Tt=V=>{var M=[],_=0,u={},h=m=>{for(var C=0,v=M[C],x=1;x<_;){var T=x+1;C=x,T<_&&M[T].score>1]=M[C],x=1+(C<<1)}for(var I=C-1>>1;C>0&&v.score>1)M[C]=M[I];M[C]=v};return u.add=m=>{var C=_;M[_++]=m;for(var v=C-1>>1;C>0&&m.score>1)M[C]=M[v];M[C]=m},u.poll=m=>{if(_!==0){var C=M[0];return M[0]=M[--_],h(),C}},u.peek=m=>{if(_!==0)return M[0]},u.replaceTop=m=>{M[0]=m,h()},u},Ve=Tt();return{single:n,go:t,highlight:a,prepare:c,indexes:l,cleanup:L}})});var cn=Zr((ar,ln)=>{(function(e,n){typeof ar=="object"&&typeof ln=="object"?ln.exports=n():typeof define=="function"&&define.amd?define([],n):typeof ar=="object"?ar.Pickr=n():e.Pickr=n()})(self,function(){return(()=>{"use strict";var e={d:(_,u)=>{for(var h in u)e.o(u,h)&&!e.o(_,h)&&Object.defineProperty(_,h,{enumerable:!0,get:u[h]})},o:(_,u)=>Object.prototype.hasOwnProperty.call(_,u),r:_=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})}},n={};e.d(n,{default:()=>M});var t={};function a(_,u,h,m){let C=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};u instanceof HTMLCollection||u instanceof NodeList?u=Array.from(u):Array.isArray(u)||(u=[u]),Array.isArray(h)||(h=[h]);for(let v of u)for(let x of h)v[_](x,m,{capture:!1,...C});return Array.prototype.slice.call(arguments,1)}e.r(t),e.d(t,{adjustableInputNumbers:()=>S,createElementFromString:()=>c,createFromTemplate:()=>f,eventPath:()=>p,off:()=>l,on:()=>i,resolveElement:()=>w});let i=a.bind(null,"addEventListener"),l=a.bind(null,"removeEventListener");function c(_){let u=document.createElement("div");return u.innerHTML=_.trim(),u.firstElementChild}function f(_){let u=(m,C)=>{let v=m.getAttribute(C);return m.removeAttribute(C),v},h=function(m){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},v=u(m,":obj"),x=u(m,":ref"),T=v?C[v]={}:C;x&&(C[x]=m);for(let I of Array.from(m.children)){let D=u(I,":arr"),P=h(I,D?{}:T);D&&(T[D]||(T[D]=[])).push(Object.keys(P).length?P:I)}return C};return h(c(_))}function p(_){let u=_.path||_.composedPath&&_.composedPath();if(u)return u;let h=_.target.parentElement;for(u=[_.target,h];h=h.parentElement;)u.push(h);return u.push(document,window),u}function w(_){return _ instanceof Element?_:typeof _=="string"?_.split(/>>/g).reduce((u,h,m,C)=>(u=u.querySelector(h),m1&&arguments[1]!==void 0?arguments[1]:m=>m;function h(m){let C=[.001,.01,.1][Number(m.shiftKey||2*m.ctrlKey)]*(m.deltaY<0?1:-1),v=0,x=_.selectionStart;_.value=_.value.replace(/[\d.]+/g,(T,I)=>I<=x&&I+T.length>=x?(x=I,u(Number(T),C,v)):(v++,T)),_.focus(),_.setSelectionRange(x,x),m.preventDefault(),_.dispatchEvent(new Event("input"))}i(_,"focus",()=>i(window,"wheel",h,{passive:!1})),i(_,"blur",()=>l(window,"wheel",h))}let{min:E,max:B,floor:Y,round:K}=Math;function Q(_,u,h){u/=100,h/=100;let m=Y(_=_/360*6),C=_-m,v=h*(1-u),x=h*(1-C*u),T=h*(1-(1-C)*u),I=m%6;return[255*[h,x,v,v,T,h][I],255*[T,h,h,x,v,v][I],255*[v,v,T,h,h,x][I]]}function L(_,u,h){return Q(_,u,h).map(m=>K(m).toString(16).padStart(2,"0"))}function re(_,u,h){let m=Q(_,u,h),C=m[0]/255,v=m[1]/255,x=m[2]/255,T=E(1-C,1-v,1-x);return[100*(T===1?0:(1-C-T)/(1-T)),100*(T===1?0:(1-v-T)/(1-T)),100*(T===1?0:(1-x-T)/(1-T)),100*T]}function F(_,u,h){let m=(2-(u/=100))*(h/=100)/2;return m!==0&&(u=m===1?0:m<.5?u*h/(2*m):u*h/(2-2*m)),[_,100*u,100*m]}function oe(_,u,h){let m=E(_/=255,u/=255,h/=255),C=B(_,u,h),v=C-m,x,T;if(v===0)x=T=0;else{T=v/C;let I=((C-_)/6+v/2)/v,D=((C-u)/6+v/2)/v,P=((C-h)/6+v/2)/v;_===C?x=P-D:u===C?x=1/3+I-P:h===C&&(x=2/3+D-I),x<0?x+=1:x>1&&(x-=1)}return[360*x,100*T,100*C]}function ke(_,u,h,m){return u/=100,h/=100,[...oe(255*(1-E(1,(_/=100)*(1-(m/=100))+m)),255*(1-E(1,u*(1-m)+m)),255*(1-E(1,h*(1-m)+m)))]}function Ye(_,u,h){u/=100;let m=2*(u*=(h/=100)<.5?h:1-h)/(h+u)*100,C=100*(h+u);return[_,isNaN(m)?0:m,C]}function qe(_){return oe(..._.match(/.{2}/g).map(u=>parseInt(u,16)))}function Te(_){_=_.match(/^[a-zA-Z]+$/)?function(C){if(C.toLowerCase()==="black")return"#000";let v=document.createElement("canvas").getContext("2d");return v.fillStyle=C,v.fillStyle==="#000"?null:v.fillStyle}(_):_;let u={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},h=C=>C.map(v=>/^(|\d+)\.\d+|\d+$/.test(v)?Number(v):void 0),m;e:for(let C in u){if(!(m=u[C].exec(_)))continue;let v=x=>!!m[2]==(typeof x=="number");switch(C){case"cmyk":{let[,x,T,I,D]=h(m);if(x>100||T>100||I>100||D>100)break e;return{values:ke(x,T,I,D),type:C}}case"rgba":{let[,,,x,T,I,D]=h(m);if(x>255||T>255||I>255||D<0||D>1||!v(D))break e;return{values:[...oe(x,T,I),D],a:D,type:C}}case"hexa":{let[,x]=m;x.length!==4&&x.length!==3||(x=x.split("").map(D=>D+D).join(""));let T=x.substring(0,6),I=x.substring(6);return I=I?parseInt(I,16)/255:void 0,{values:[...qe(T),I],a:I,type:C}}case"hsla":{let[,,,x,T,I,D]=h(m);if(x>360||T>100||I>100||D<0||D>1||!v(D))break e;return{values:[...Ye(x,T,I),D],a:D,type:C}}case"hsva":{let[,,,x,T,I,D]=h(m);if(x>360||T>100||I>100||D<0||D>1||!v(D))break e;return{values:[x,T,I,D],a:D,type:C}}}}return{values:null,type:null}}function xe(){let _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,m=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1,C=(x,T)=>function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:-1;return T(~I?x.map(D=>Number(D.toFixed(I))):x)},v={h:_,s:u,v:h,a:m,toHSVA(){let x=[v.h,v.s,v.v,v.a];return x.toString=C(x,T=>`hsva(${T[0]}, ${T[1]}%, ${T[2]}%, ${v.a})`),x},toHSLA(){let x=[...F(v.h,v.s,v.v),v.a];return x.toString=C(x,T=>`hsla(${T[0]}, ${T[1]}%, ${T[2]}%, ${v.a})`),x},toRGBA(){let x=[...Q(v.h,v.s,v.v),v.a];return x.toString=C(x,T=>`rgba(${T[0]}, ${T[1]}, ${T[2]}, ${v.a})`),x},toCMYK(){let x=re(v.h,v.s,v.v);return x.toString=C(x,T=>`cmyk(${T[0]}%, ${T[1]}%, ${T[2]}%, ${T[3]}%)`),x},toHEXA(){let x=L(v.h,v.s,v.v),T=v.a>=1?"":Number((255*v.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return T&&x.push(T),x.toString=()=>`#${x.join("").toUpperCase()}`,x},clone:()=>xe(v.h,v.s,v.v,v.a)};return v}let Pe=_=>Math.max(Math.min(_,1),0);function Qe(_){let u={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},_),_keyboard(v){let{options:x}=u,{type:T,key:I}=v;if(document.activeElement===x.wrapper){let{lock:D}=u.options,P=I==="ArrowUp",G=I==="ArrowRight",q=I==="ArrowDown",U=I==="ArrowLeft";if(T==="keydown"&&(P||G||q||U)){let fe=0,le=0;D==="v"?fe=P||G?1:-1:D==="h"?fe=P||G?-1:1:(le=P?-1:q?1:0,fe=U?-1:G?1:0),u.update(Pe(u.cache.x+.01*fe),Pe(u.cache.y+.01*le)),v.preventDefault()}else I.startsWith("Arrow")&&(u.options.onstop(),v.preventDefault())}},_tapstart(v){i(document,["mouseup","touchend","touchcancel"],u._tapstop),i(document,["mousemove","touchmove"],u._tapmove),v.cancelable&&v.preventDefault(),u._tapmove(v)},_tapmove(v){let{options:x,cache:T}=u,{lock:I,element:D,wrapper:P}=x,G=P.getBoundingClientRect(),q=0,U=0;if(v){let Oe=v&&v.touches&&v.touches[0];q=v?(Oe||v).clientX:0,U=v?(Oe||v).clientY:0,qG.left+G.width&&(q=G.left+G.width),UG.top+G.height&&(U=G.top+G.height),q-=G.left,U-=G.top}else T&&(q=T.x*G.width,U=T.y*G.height);I!=="h"&&(D.style.left=`calc(${q/G.width*100}% - ${D.offsetWidth/2}px)`),I!=="v"&&(D.style.top=`calc(${U/G.height*100}% - ${D.offsetHeight/2}px)`),u.cache={x:q/G.width,y:U/G.height};let fe=Pe(q/G.width),le=Pe(U/G.height);switch(I){case"v":return x.onchange(fe);case"h":return x.onchange(le);default:return x.onchange(fe,le)}},_tapstop(){u.options.onstop(),l(document,["mouseup","touchend","touchcancel"],u._tapstop),l(document,["mousemove","touchmove"],u._tapmove)},trigger(){u._tapmove()},update(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,{left:T,top:I,width:D,height:P}=u.options.wrapper.getBoundingClientRect();u.options.lock==="h"&&(x=v),u._tapmove({clientX:T+D*v,clientY:I+P*x})},destroy(){let{options:v,_tapstart:x,_keyboard:T}=u;l(document,["keydown","keyup"],T),l([v.wrapper,v.element],"mousedown",x),l([v.wrapper,v.element],"touchstart",x,{passive:!1})}},{options:h,_tapstart:m,_keyboard:C}=u;return i([h.wrapper,h.element],"mousedown",m),i([h.wrapper,h.element],"touchstart",m,{passive:!1}),i(document,["keydown","keyup"],C),u}function ie(){let _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_=Object.assign({onchange:()=>0,className:"",elements:[]},_);let u=i(_.elements,"click",h=>{_.elements.forEach(m=>m.classList[h.target===m?"add":"remove"](_.className)),_.onchange(h),h.stopPropagation()});return{destroy:()=>l(...u)}}let Tt={variantFlipOrder:{start:"sme",middle:"mse",end:"ems"},positionFlipOrder:{top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},position:"bottom",margin:8},Ve=(_,u,h)=>{let{container:m,margin:C,position:v,variantFlipOrder:x,positionFlipOrder:T}={container:document.documentElement.getBoundingClientRect(),...Tt,...h},{left:I,top:D}=u.style;u.style.left="0",u.style.top="0";let P=_.getBoundingClientRect(),G=u.getBoundingClientRect(),q={t:P.top-G.height-C,b:P.bottom+C,r:P.right+C,l:P.left-G.width-C},U={vs:P.left,vm:P.left+P.width/2+-G.width/2,ve:P.left+P.width-G.width,hs:P.top,hm:P.bottom-P.height/2-G.height/2,he:P.bottom-G.height},[fe,le="middle"]=v.split("-"),Oe=T[fe],ye=x[le],{top:Se,left:ae,bottom:Re,right:_e}=m;for(let Ke of Oe){let Le=Ke==="t"||Ke==="b",et=q[Ke],[gt,tt]=Le?["top","left"]:["left","top"],[Ar,kr]=Le?[G.height,G.width]:[G.width,G.height],[Tr,Lr]=Le?[Re,_e]:[_e,Re],[Mr,Ir]=Le?[Se,ae]:[ae,Se];if(!(etTr))for(let jt of ye){let Lt=U[(Le?"v":"h")+jt];if(!(LtLr))return u.style[tt]=Lt-G[tt]+"px",u.style[gt]=et-G[gt]+"px",Ke+jt}}return u.style.left=I,u.style.top=D,null};function V(_,u,h){return u in _?Object.defineProperty(_,u,{value:h,enumerable:!0,configurable:!0,writable:!0}):_[u]=h,_}class M{constructor(u){V(this,"_initializingActive",!0),V(this,"_recalc",!0),V(this,"_nanopop",null),V(this,"_root",null),V(this,"_color",xe()),V(this,"_lastColor",xe()),V(this,"_swatchColors",[]),V(this,"_setupAnimationFrame",null),V(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=u=Object.assign({...M.DEFAULT_OPTIONS},u);let{swatches:h,components:m,theme:C,sliders:v,lockOpacity:x,padding:T}=u;["nano","monolith"].includes(C)&&!v&&(u.sliders="h"),m.interaction||(m.interaction={});let{preview:I,opacity:D,hue:P,palette:G}=m;m.opacity=!x&&D,m.palette=G||I||D||P,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),h&&h.length&&h.forEach(le=>this.addSwatch(le));let{button:q,app:U}=this._root;this._nanopop=((le,Oe,ye)=>{let Se=typeof le!="object"||le instanceof HTMLElement?{reference:le,popper:Oe,...ye}:le;return{update(){let ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Se,{reference:Re,popper:_e}=Object.assign(Se,ae);if(!_e||!Re)throw new Error("Popper- or reference-element missing.");return Ve(Re,_e,Se)}}})(q,U,{margin:T}),q.setAttribute("role","button"),q.setAttribute("aria-label",this._t("btn:toggle"));let fe=this;this._setupAnimationFrame=requestAnimationFrame(function le(){if(!U.offsetWidth)return fe._setupAnimationFrame=requestAnimationFrame(le);fe.setColor(u.default),fe._rePositioningPicker(),u.defaultRepresentation&&(fe._representation=u.defaultRepresentation,fe.setColorRepresentation(fe._representation)),u.showAlways&&fe.show(),fe._initializingActive=!1,fe._emit("init")})}_preBuild(){let{options:u}=this;for(let h of["el","container"])u[h]=w(u[h]);this._root=(h=>{let{components:m,useAsButton:C,inline:v,appClass:x,theme:T,lockOpacity:I}=h.options,D=U=>U?"":'style="display:none" hidden',P=U=>h._t(U),G=f(` +
    + + ${C?"":''} + +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    + + + + + + + + + + + +
    +
    +
    + `),q=G.interaction;return q.options.find(U=>!U.hidden&&!U.classList.add("active")),q.type=()=>q.options.find(U=>U.classList.contains("active")),G})(this),u.useAsButton&&(this._root.button=u.el),u.container.appendChild(this._root.root)}_finalBuild(){let u=this.options,h=this._root;if(u.container.removeChild(h.root),u.inline){let m=u.el.parentElement;u.el.nextSibling?m.insertBefore(h.app,u.el.nextSibling):m.appendChild(h.app)}else u.container.appendChild(h.app);u.useAsButton?u.inline&&u.el.remove():u.el.parentNode.replaceChild(h.root,u.el),u.disabled&&this.disable(),u.comparison||(h.button.style.transition="none",u.useAsButton||(h.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){let u=this,h=this.options.components,m=(u.options.sliders||"v").repeat(2),[C,v]=m.match(/^[vh]+$/g)?m:[],x=()=>this._color||(this._color=this._lastColor.clone()),T={palette:Qe({element:u._root.palette.picker,wrapper:u._root.palette.palette,onstop:()=>u._emit("changestop","slider",u),onchange(I,D){if(!h.palette)return;let P=x(),{_root:G,options:q}=u,{lastColor:U,currentColor:fe}=G.preview;u._recalc&&(P.s=100*I,P.v=100-100*D,P.v<0&&(P.v=0),u._updateOutput("slider"));let le=P.toRGBA().toString(0);this.element.style.background=le,this.wrapper.style.background=` + linear-gradient(to top, rgba(0, 0, 0, ${P.a}), transparent), + linear-gradient(to left, hsla(${P.h}, 100%, 50%, ${P.a}), rgba(255, 255, 255, ${P.a})) + `,q.comparison?q.useAsButton||u._lastColor||U.style.setProperty("--pcr-color",le):(G.button.style.setProperty("--pcr-color",le),G.button.classList.remove("clear"));let Oe=P.toHEXA().toString();for(let{el:ye,color:Se}of u._swatchColors)ye.classList[Oe===Se.toHEXA().toString()?"add":"remove"]("pcr-active");fe.style.setProperty("--pcr-color",le)}}),hue:Qe({lock:v==="v"?"h":"v",element:u._root.hue.picker,wrapper:u._root.hue.slider,onstop:()=>u._emit("changestop","slider",u),onchange(I){if(!h.hue||!h.palette)return;let D=x();u._recalc&&(D.h=360*I),this.element.style.backgroundColor=`hsl(${D.h}, 100%, 50%)`,T.palette.trigger()}}),opacity:Qe({lock:C==="v"?"h":"v",element:u._root.opacity.picker,wrapper:u._root.opacity.slider,onstop:()=>u._emit("changestop","slider",u),onchange(I){if(!h.opacity||!h.palette)return;let D=x();u._recalc&&(D.a=Math.round(100*I)/100),this.element.style.background=`rgba(0, 0, 0, ${D.a})`,T.palette.trigger()}}),selectable:ie({elements:u._root.interaction.options,className:"active",onchange(I){u._representation=I.target.getAttribute("data-type").toUpperCase(),u._recalc&&u._updateOutput("swatch")}})};this._components=T}_bindEvents(){let{_root:u,options:h}=this,m=[i(u.interaction.clear,"click",()=>this._clearColor()),i([u.interaction.cancel,u.preview.lastColor],"click",()=>{this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0),this._emit("cancel")}),i(u.interaction.save,"click",()=>{!this.applyColor()&&!h.showAlways&&this.hide()}),i(u.interaction.result,["keyup","input"],C=>{this.setColor(C.target.value,!0)&&!this._initializingActive&&(this._emit("change",this._color,"input",this),this._emit("changestop","input",this)),C.stopImmediatePropagation()}),i(u.interaction.result,["focus","blur"],C=>{this._recalc=C.type==="blur",this._recalc&&this._updateOutput(null)}),i([u.palette.palette,u.palette.picker,u.hue.slider,u.hue.picker,u.opacity.slider,u.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0,{passive:!0})];if(!h.showAlways){let C=h.closeWithKey;m.push(i(u.button,"click",()=>this.isOpen()?this.hide():this.show()),i(document,"keyup",v=>this.isOpen()&&(v.key===C||v.code===C)&&this.hide()),i(document,["touchstart","mousedown"],v=>{this.isOpen()&&!p(v).some(x=>x===u.app||x===u.button)&&this.hide()},{capture:!0}))}if(h.adjustableNumbers){let C={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};S(u.interaction.result,(v,x,T)=>{let I=C[this.getColorRepresentation().toLowerCase()];if(I){let D=I[T],P=v+(D>=100?1e3*x:x);return P<=0?0:Number((P{v.isOpen()&&(h.closeOnScroll&&v.hide(),C===null?(C=setTimeout(()=>C=null,100),requestAnimationFrame(function x(){v._rePositioningPicker(),C!==null&&requestAnimationFrame(x)})):(clearTimeout(C),C=setTimeout(()=>C=null,100)))},{capture:!0}))}this._eventBindings=m}_rePositioningPicker(){let{options:u}=this;if(!u.inline&&!this._nanopop.update({container:document.body.getBoundingClientRect(),position:u.position})){let h=this._root.app,m=h.getBoundingClientRect();h.style.top=(window.innerHeight-m.height)/2+"px",h.style.left=(window.innerWidth-m.width)/2+"px"}}_updateOutput(u){let{_root:h,_color:m,options:C}=this;if(h.interaction.type()){let v=`to${h.interaction.type().getAttribute("data-type")}`;h.interaction.result.value=typeof m[v]=="function"?m[v]().toString(C.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",m,u,this)}_clearColor(){let u=arguments.length>0&&arguments[0]!==void 0&&arguments[0],{_root:h,options:m}=this;m.useAsButton||h.button.style.setProperty("--pcr-color","rgba(0, 0, 0, 0.15)"),h.button.classList.add("clear"),m.showAlways||this.hide(),this._lastColor=null,this._initializingActive||u||(this._emit("save",null),this._emit("clear"))}_parseLocalColor(u){let{values:h,type:m,a:C}=Te(u),{lockOpacity:v}=this.options,x=C!==void 0&&C!==1;return h&&h.length===3&&(h[3]=void 0),{values:!h||v&&x?null:h,type:m}}_t(u){return this.options.i18n[u]||M.I18N_DEFAULTS[u]}_emit(u){for(var h=arguments.length,m=new Array(h>1?h-1:0),C=1;Cv(...m,this))}on(u,h){return this._eventListener[u].push(h),this}off(u,h){let m=this._eventListener[u]||[],C=m.indexOf(h);return~C&&m.splice(C,1),this}addSwatch(u){let{values:h}=this._parseLocalColor(u);if(h){let{_swatchColors:m,_root:C}=this,v=xe(...h),x=c(`