'use strict';

var obsidian = require('obsidian');

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

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());
    });
}

class Hider extends obsidian.Plugin {
    constructor() {
        super(...arguments);
        // refresh function for when we change settings
        this.refresh = () => {
            // re-load the style
            this.updateStyle();
        };
        // update the styles (at the start, or as the result of a settings change)
        this.updateStyle = () => {
            document.body.classList.toggle('hider-ribbon', this.settings.hideRibbon);
            document.body.classList.toggle('hider-status', this.settings.hideStatus);
            document.body.classList.toggle('hider-tabs', this.settings.hideTabs);
            document.body.classList.toggle('hider-scroll', this.settings.hideScroll);
            document.body.classList.toggle('hider-sidebar-buttons', this.settings.hideSidebarButtons);
            document.body.classList.toggle('hider-tooltips', this.settings.hideTooltips);
            document.body.classList.toggle('hider-search-suggestions', this.settings.hideSearchSuggestions);
            document.body.classList.toggle('hider-file-nav-header', this.settings.hideFileNavButtons);
            document.body.classList.toggle('hider-search-counts', this.settings.hideSearchCounts);
            document.body.classList.toggle('hider-instructions', this.settings.hideInstructions);
            document.body.classList.toggle('hider-meta', this.settings.hidePropertiesReading);
            document.body.classList.toggle('hider-vault', this.settings.hideVault);
        };
    }
    onload() {
        return __awaiter(this, void 0, void 0, function* () {
            // load settings
            yield this.loadSettings();
            // add the settings tab
            this.addSettingTab(new HiderSettingTab(this.app, this));
            // add the toggle on/off command
            this.addCommand({
                id: 'toggle-tab-containers',
                name: 'Toggle tab bar',
                callback: () => {
                    this.settings.hideTabs = !this.settings.hideTabs;
                    this.saveData(this.settings);
                    this.refresh();
                }
            });
            this.addCommand({
                id: 'toggle-app-ribbon',
                name: 'Toggle app ribbon',
                callback: () => {
                    this.settings.hideRibbon = !this.settings.hideRibbon;
                    this.saveData(this.settings);
                    this.refresh();
                }
            });
            this.addCommand({
                id: 'toggle-hider-status',
                name: 'Toggle status bar',
                callback: () => {
                    this.settings.hideStatus = !this.settings.hideStatus;
                    this.saveData(this.settings);
                    this.refresh();
                }
            });
            this.refresh();
        });
    }
    onunload() {
        console.log('Unloading Hider plugin');
    }
    loadSettings() {
        return __awaiter(this, void 0, void 0, function* () {
            this.settings = Object.assign(DEFAULT_SETTINGS, yield this.loadData());
        });
    }
    saveSettings() {
        return __awaiter(this, void 0, void 0, function* () {
            yield this.saveData(this.settings);
        });
    }
}
const DEFAULT_SETTINGS = {
    hideRibbon: false,
    hideStatus: false,
    hideTabs: false,
    hideScroll: false,
    hideSidebarButtons: false,
    hideTooltips: false,
    hideFileNavButtons: false,
    hideSearchSuggestions: false,
    hideSearchCounts: false,
    hideInstructions: false,
    hidePropertiesReading: false,
    hideVault: false
};
class HiderSettingTab extends obsidian.PluginSettingTab {
    constructor(app, plugin) {
        super(app, plugin);
        this.plugin = plugin;
    }
    display() {
        let { containerEl } = this;
        containerEl.empty();
        new obsidian.Setting(containerEl)
            .setName('Hide app ribbon')
            .setDesc('Hides the Obsidian menu. Warning: to open Settings you will need use the hotkey (default is CMD + ,)')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideRibbon)
            .onChange((value) => {
            this.plugin.settings.hideRibbon = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide tab bar')
            .setDesc('Hides the tab container at the top of the window')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideTabs)
            .onChange((value) => {
            this.plugin.settings.hideTabs = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide status bar')
            .setDesc('Hides word count, character count and backlink count')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideStatus)
            .onChange((value) => {
            this.plugin.settings.hideStatus = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide vault name')
            .setDesc('Hides the root folder name')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideVault)
            .onChange((value) => {
            this.plugin.settings.hideVault = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide scroll bars')
            .setDesc('Hides all scroll bars')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideScroll)
            .onChange((value) => {
            this.plugin.settings.hideScroll = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide sidebar toggle buttons')
            .setDesc('Hides both sidebar buttons')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideSidebarButtons)
            .onChange((value) => {
            this.plugin.settings.hideSidebarButtons = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide tooltips')
            .setDesc('Hides all tooltips')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideTooltips)
            .onChange((value) => {
            this.plugin.settings.hideTooltips = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide file explorer buttons')
            .setDesc('Hides buttons at the top of file explorer (new file, new folder, etc)')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideFileNavButtons)
            .onChange((value) => {
            this.plugin.settings.hideFileNavButtons = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide instructions')
            .setDesc('Hides instructional tips in modals')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideInstructions)
            .onChange((value) => {
            this.plugin.settings.hideInstructions = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide search suggestions')
            .setDesc('Hides suggestions in search pane')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideSearchSuggestions)
            .onChange((value) => {
            this.plugin.settings.hideSearchSuggestions = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide count of search term matches')
            .setDesc('Hides the number of matches within each search result')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hideSearchCounts)
            .onChange((value) => {
            this.plugin.settings.hideSearchCounts = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
        new obsidian.Setting(containerEl)
            .setName('Hide properties in Reading view')
            .setDesc('Hides the properties section in Reading view')
            .addToggle(toggle => toggle.setValue(this.plugin.settings.hidePropertiesReading)
            .onChange((value) => {
            this.plugin.settings.hidePropertiesReading = value;
            this.plugin.saveData(this.plugin.settings);
            this.plugin.refresh();
        }));
    }
}

module.exports = Hider;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 39380 characters]
