/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
If you want to view the source, visit the plugin's github repository:
https://github.com/kometenstaub/customizable-page-header-buttons

This plugin is MIT-licensed:

	MIT License

	Copyright (c) 2021-2022 kometenstaub and contributors

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.


The commandSuggester, iconPicker, Obsidian icon names and the biggest part of the settings tab have been adapted from the Obsidian Customizable Sidebar Plugin (https://github.com/phibr0/obsidian-customizable-sidebar).
It is MIT-licensed:
	MIT License

	Copyright (c) 2021 Phillip

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.

The workspace monkey-patching uses code from monkey-around, which is ISC-licensed.
https://github.com/pjeby/monkey-around

*/

var J=Object.create;var S=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var j=n=>S(n,"__esModule",{value:!0});var ee=(n,i)=>{j(n);for(var e in i)S(n,e,{get:i[e],enumerable:!0})},te=(n,i,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of X(i))!Z.call(n,t)&&t!=="default"&&S(n,t,{get:()=>i[t],enumerable:!(e=Q(i,t))||e.enumerable});return n},C=n=>te(j(S(n!=null?J(Y(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);ee(exports,{default:()=>O});var r=C(require("obsidian"));function q(n,i){let e=Object.keys(i).map(t=>ie(n,t,i[t]));return e.length===1?e[0]:function(){e.forEach(t=>t())}}function ie(n,i,e){let t=n[i],l=n.hasOwnProperty(i),s=e(t);return t&&Object.setPrototypeOf(s,t),Object.setPrototypeOf(o,s),n[i]=o,u;function o(...c){return s===t&&n[i]===o&&u(),s.apply(this,c)}function u(){n[i]===o&&(l?n[i]=t:delete n[i]),s!==t&&(s=t,Object.setPrototypeOf(o,t||Function))}}var d=C(require("obsidian"));var V=C(require("obsidian"));var k=C(require("obsidian"));var x=C(require("obsidian"));var H=["add-note-glyph","any-key","audio-file","blocks","bold-glyph","box-glyph","bracket-glyph","broken-link","bullet-list-glyph","bullet-list","calendar-glyph","calendar-with-checkmark","check-in-circle","check-small","checkbox-glyph","checkmark","clock-glyph","clock","cloud","code-glyph","command-glyph","compress-glyph","create-new","cross-in-box","cross","crossed-star","dice-glyph","dice","document","documents","dot-network","double-down-arrow-glyph","double-up-arrow-glyph","down-arrow-with-tail","down-chevron-glyph","down-curly-arrow-glyph","duplicate-glyph","enlarge-glyph","enter","exit-fullscreen","expand-vertically","file-explorer-glyph","filled-pin","folder","forward-arrow","fullscreen","gear","github-glyph","go-to-file","graph-glyph","hashtag","heading-glyph","help","highlight-glyph","horizontal-split","image-file","image-glyph","import-glyph","indent-glyph","info","install","italic-glyph","keyboard-glyph","languages","left-arrow-with-tail","left-arrow","left-chevron-glyph","lines-of-text","link-glyph","link","links-coming-in","links-going-out","logo-crystal","magnifying-glass","merge-files-glyph","merge-files","microphone-filled","microphone","minus-with-circle","navigate-glyph","note-glyph","number-list-glyph","open-elsewhere-glyph","open-vault","pane-layout","paper-plane-glyph","paper-plane","paste-text","paste","paused","pdf-file","pencil","percent-sign-glyph","pin","play-audio-glyph","plus-minus-glyph","plus-with-circle","popup-open","presentation-glyph","presentation","price-tag-glyph","question-mark-glyph","quote-glyph","reading-glasses","redo-glyph","reset","restore-file-glyph","right-arrow-with-tail","right-arrow","right-chevron-glyph","right-triangle","run-command","scissors-glyph","scissors","search-glyph","search","select-all-text","sheets-in-box","split","stacked-levels","star-glyph","star-list","star","stop-audio-glyph","strikethrough-glyph","switch","sync-small","sync","tag-glyph","three-horizontal-bars","tomorrow-glyph","trash","two-blank-pages","undo-glyph","unindent-glyph","up-and-down-arrows","up-arrow-with-tail","up-chevron-glyph","up-curly-arrow-glyph","uppercase-lowercase-a","vault","vertical-split","vertical-three-dots","wand-glyph","wand","workspace-glyph","wrench-screwdriver-glyph","yesterday-glyph"],h="page-header-button",b="titlebar-button",M="titlebar-center",L=[b,h];function le(n){return n.includes(":")?n.split(":")[1].trim():n}function _(){let n=24;return x.Platform.isMobile?n=24:x.Platform.isDesktop&&(n=18),n}function E(n,i,e,t,l,s="a"){let o=le(n),u=l.concat([i]),c=createEl(s,{cls:u,attr:{"aria-label-position":"bottom","aria-label":o}});return(0,x.setIcon)(c,e,t),c}function I(n){for(let i=n.length;i>=0;i--)n[i]&&n[i].remove()}function R(n,i,e){let t=n.getElementsByClassName(`${e} ${h} ${i}`);t[0]&&t[0].remove()}function y(n){return n.getElementsByClassName("titlebar-text")[0]}function v(n){let i=n.getElementsByClassName("titlebar-text")[0];i&&i.detach()}function f(n,i){let e=i.getElementsByClassName(`${h} ${M}`)[0];if(e!==void 0){let t=e.parentElement;e.detach(),t&&t.insertBefore(n,t.children[0])}}function w(n){let e=D(n).getElementsByClassName(`${h} ${b}`);I(e)}function T(n){let i=createDiv({cls:[h,"titlebar-center"]}),e=n.getElementsByClassName("titlebar-inner")[0];return e&&e.insertBefore(i,e.children[0]),i}function $(){let n=[];app.workspace.iterateAllLeaves(i=>{n.push(i.view.containerEl)});for(let i=0;i<n.length;i++){let t=n[i].getElementsByClassName(h);t.length>0&&I(t)}}function z(n){let i=[];app.workspace.iterateAllLeaves(e=>{i.push(e.view.containerEl)});for(let e=0;e<i.length;e++){let t=i[e];R(t,n,"view-action")}}function W(n){g(n),p(n)}function g(n){let e=A(n).getElementsByClassName(h);e.length>0&&I(e)}function p(n){let e=P(n).getElementsByClassName(h);e.length>0&&I(e)}function F(n,i){let e=A(i);R(e,n,b)}function U(n,i){let e=P(i);R(e,n,b)}function G(n,i){let e=D(i);R(e,n,b)}function A(n){return n.getElementsByClassName("titlebar-button-container mod-left")[0]}function P(n){return n.getElementsByClassName("titlebar-button-container mod-right")[0]}function D(n){return n.getElementsByClassName(`${h} ${M}`)[0]}var m=class extends k.FuzzySuggestModal{constructor(i,e,t,l=-1){super(i.app);this.plugin=i,this.command=e,this.type=t,this.index=l,this.setPlaceholder("Please pick an icon")}cap(i){return i.split(" ").map(t=>t[0].toUpperCase()+t.substring(1)).join(" ")}getItems(){return this.plugin.iconList}getItemText(i){return this.cap(i.replace("lucide-","").replace(/-/gi," "))}renderSuggestion(i,e){e.addClass("CS-icon-container");let t=e.createDiv({cls:"CS-icon"});(0,k.setIcon)(t,i.item),super.renderSuggestion(i,e)}async onChooseItem(i){let{id:e,name:t}=this.command,{settings:l}=this.plugin,s=0;if(this.type==="page"){let o="both";this.index===-1?o="both":o=l.enabledButtons[this.index].showButtons;let u={id:e,icon:i,name:t,showButtons:o};this.index===-1?l.enabledButtons.push(u):(l.enabledButtons[this.index]=u,new k.Notice("This change will take effect for new panes only."))}else{let o={id:e,icon:i,name:t};if(this.index===-1)if(this.type==="title-left")l.titleLeft.push(o);else if(this.type==="title-right")l.titleRight.push(o);else{let u=l.titleCenter.length;u!==0&&(s=u),l.titleCenter.push(o)}else if(this.type==="title-left")l.titleLeft[this.index]=o;else if(this.type==="title-right")l.titleRight[this.index]=o;else{let u=l.titleCenter.length;u!==0&&(s=u),l.titleCenter[this.index]=o}}if(await this.plugin.saveSettings(),this.type==="title-left")for(let o=0;o<this.plugin.windows.length;o++)g(this.plugin.windows[o]),this.plugin.addLeftTitleBarButtons(this.plugin.windows[o]);else if(this.type==="title-right")for(let o=0;o<this.plugin.windows.length;o++)p(this.plugin.windows[o]),this.plugin.addRightTitleBarButtons(this.plugin.windows[o]);else if(s===0){this.plugin.titlebarText=[];for(let o=0;o<this.plugin.windows.length;o++){let u=this.plugin.windows[o];this.plugin.titlebarText.push(y(u)),v(u);let c=T(u);this.plugin.addCenterTitleBarButtons(u)}}else if(l.titleCenter.length===0)for(let o=0;o<this.plugin.windows.length;o++)f(this.plugin.titlebarText[o],this.plugin.windows[o]);else for(let o=0;o<this.plugin.windows.length;o++)w(this.plugin.windows[o]),this.plugin.addCenterTitleBarButtons(this.plugin.windows[o]);setTimeout(()=>{dispatchEvent(new Event("TopBar-addedCommand"))},100)}};var B=class extends V.FuzzySuggestModal{constructor(i,e){super(i.app);this.plugin=i,this.type=e}pushToSettings(i,e,t){t==="titleRight"||t==="titleLeft"||t==="titleCenter"?i[t].push({id:e.id,icon:e.icon,name:e.name}):i.enabledButtons.push({id:e.id,icon:e.icon,name:e.name,showButtons:"both"})}getItems(){return this.app.commands.listCommands()}getItemText(i){return i.name}async onChooseItem(i,e){let{settings:t}=this.plugin,l=0;if(i.icon!==void 0){if(this.type==="page")this.pushToSettings(t,i,"enabledSettings");else if(this.type==="title-left")this.pushToSettings(t,i,"titleLeft");else if(this.type==="title-right")this.pushToSettings(t,i,"titleRight");else{let s=this.plugin.settings.titleCenter.length;s!==0&&(l=s),this.pushToSettings(t,i,"titleCenter")}if(await this.plugin.saveSettings(),this.type==="title-left")for(let s=0;s<this.plugin.windows.length;s++)g(this.plugin.windows[s]),this.plugin.addLeftTitleBarButtons(this.plugin.windows[s]);else if(this.type==="title-right")for(let s=0;s<this.plugin.windows.length;s++)p(this.plugin.windows[s]),this.plugin.addRightTitleBarButtons(this.plugin.windows[s]);else if(this.type==="title-center")if(l===0){this.plugin.titlebarText=[];for(let s=0;s<this.plugin.windows.length;s++){let o=this.plugin.windows[s];this.plugin.titlebarText.push(y(o)),v(o);let u=T(o);this.plugin.addCenterTitleBarButtons(o)}}else if(this.plugin.settings.titleCenter.length===0)for(let s=0;s<this.plugin.windows.length;s++)f(this.plugin.titlebarText[s],this.plugin.windows[s]);else for(let s=0;s<this.plugin.windows.length;s++)w(this.plugin.windows[s]),this.plugin.addCenterTitleBarButtons(this.plugin.windows[s]);setTimeout(()=>{dispatchEvent(new Event("TopBar-addedCommand"))},100)}else new m(this.plugin,i,this.type).open()}};var N=class extends d.PluginSettingTab{constructor(i,e){super(i,e);this.plugin=e,this.plugin.listener=()=>{this.display()},this.containerEl.addClass("page-header-button"),addEventListener("TopBar-addedCommand",this.plugin.listener)}display(){let{containerEl:i}=this,{settings:e}=this.plugin;i.empty(),i.createEl("h3",{text:"Page Header Buttons"}),i.createEl("p",{text:"The buttons are added in the order in which they are shown here."}),new d.Setting(i).setName("Show buttons on desktop").setDesc("By default, the buttons will only be shown in Obsidian Mobile.").addToggle(t=>{t.setValue(e.desktop).onChange(async l=>{if(e.desktop=l,await this.plugin.saveSettings(),this.display(),!l){for(let s of e.enabledButtons)s.showButtons="mobile";await this.plugin.saveSettings()}})}),new d.Setting(i).setName("Add Button").setDesc("Add a new button left to the switch edit/preview mode toggle.").addButton(t=>{t.setButtonText("Add Command").onClick(()=>{new B(this.plugin,"page").open()})}),this.app.plugins.plugins["pane-relief"]&&new d.Setting(i).setName("Pane Relief count").setDesc("Enable to show the pane relief history count next to back/forward buttons.").addToggle(t=>{t.setValue(e.paneRelief).onChange(async l=>{e.paneRelief=l,await this.plugin.saveSettings()})}),new d.Setting(i).setName("Button spacing").setDesc("Set the spacing for Page Header buttons.").addButton(t=>{t.setButtonText("Click to go to the Style settings. Requires the Style settings plugin."),t.onClick(l=>this.app.setting.openTabById("obsidian-style-settings"))});for(let t=0;t<e.enabledButtons.length;t++){let l=e.enabledButtons[t],s=createDiv({cls:"CS-settings-icon"});(0,d.setIcon)(s,l.icon,24);let o=new d.Setting(i).setName(l.name);e.desktop&&o.addDropdown(u=>{u.addOption("both","Add button for both mobile and desktop.").addOption("mobile","Add button only for mobile.").addOption("desktop","Add button only for desktop.").setValue(l.showButtons).onChange(async c=>{l.showButtons=c,e.enabledButtons[t]=l,await this.plugin.saveSettings(),c==="desktop"&&d.Platform.isMobile?z(l.id):c==="mobile"&&d.Platform.isDesktop&&z(l.id)})}),t>0&&o.addExtraButton(u=>{u.setIcon("up-arrow-with-tail").setTooltip("Move button to the left").onClick(async()=>{e.enabledButtons[t]=e.enabledButtons[t-1],e.enabledButtons[t-1]=l,await this.plugin.saveSettings(),this.display()})}),t<e.enabledButtons.length-1&&o.addExtraButton(u=>{u.setIcon("down-arrow-with-tail").setTooltip("Move button to the right").onClick(async()=>{e.enabledButtons[t]=e.enabledButtons[t+1],e.enabledButtons[t+1]=l,await this.plugin.saveSettings(),this.display()})}),o.addExtraButton(u=>{u.setIcon("trash").setTooltip("Remove Command").onClick(async()=>{e.enabledButtons.remove(l),z(l.id),await this.plugin.saveSettings(),this.display()})}).addExtraButton(u=>{u.setIcon("gear").setTooltip("Edit Icon").onClick(()=>{let c=e.enabledButtons.findIndex(a=>a===l);new m(this.plugin,l,"page",c).open()})}),o.nameEl.prepend(s),o.nameEl.addClass("CS-flex")}if(d.Platform.isDesktopApp){i.createEl("br"),i.createEl("h3",{text:"Titlebar buttons"}),i.createEl("h4",{text:"Left titlebar"}),new d.Setting(i).setName("Add Button").setDesc("Add a new button right to the back/forward buttons.").addButton(t=>{t.setButtonText("Add Command").onClick(()=>{new B(this.plugin,"title-left").open()})});for(let t=0;t<e.titleLeft.length;t++){let l=e.titleLeft[t],s=createDiv({cls:"CS-settings-icon"});(0,d.setIcon)(s,l.icon,24);let o=new d.Setting(i).setName(l.name);t>0&&o.addExtraButton(u=>{u.setIcon("up-arrow-with-tail").setTooltip("Move button to the left").onClick(async()=>{e.titleLeft[t]=e.titleLeft[t-1],e.titleLeft[t-1]=l,await this.plugin.saveSettings();for(let c=0;c<this.plugin.windows.length;c++)g(this.plugin.windows[c]),this.plugin.addLeftTitleBarButtons(this.plugin.windows[c]);this.display()})}),t<e.titleLeft.length-1&&o.addExtraButton(u=>{u.setIcon("down-arrow-with-tail").setTooltip("Move button to the right").onClick(async()=>{e.titleLeft[t]=e.titleLeft[t+1],e.titleLeft[t+1]=l,await this.plugin.saveSettings();for(let c=0;c<this.plugin.windows.length;c++)g(this.plugin.windows[c]),this.plugin.addLeftTitleBarButtons(this.plugin.windows[c]);this.display()})}),o.addExtraButton(u=>{u.setIcon("trash").setTooltip("Remove Command").onClick(async()=>{e.titleLeft.remove(l),await this.plugin.saveSettings();for(let c=0;c<this.plugin.windows.length;c++)F(l.id,this.plugin.windows[c]);this.display()})}).addExtraButton(u=>{u.setIcon("gear").setTooltip("Edit Icon").onClick(()=>{let c=e.titleLeft.findIndex(a=>a===l);new m(this.plugin,l,"title-left",c).open();for(let a=0;a<this.plugin.windows.length;a++)g(this.plugin.windows[a]),this.plugin.addLeftTitleBarButtons(this.plugin.windows[a])})}),o.nameEl.prepend(s),o.nameEl.addClass("CS-flex")}i.createEl("h4",{text:"Right titlebar"}),new d.Setting(i).setName("Add Button").setDesc("Add a new button left to the minimize/maximize/close buttons.").addButton(t=>{t.setButtonText("Add Command").onClick(()=>{new B(this.plugin,"title-right").open()})});for(let t=0;t<e.titleRight.length;t++){let l=e.titleRight[t],s=createDiv({cls:"CS-settings-icon"});(0,d.setIcon)(s,l.icon,24);let o=new d.Setting(i).setName(l.name);t>0&&o.addExtraButton(u=>{u.setIcon("up-arrow-with-tail").setTooltip("Move button to the left").onClick(async()=>{e.titleRight[t]=e.titleRight[t-1],e.titleRight[t-1]=l,await this.plugin.saveSettings();for(let c=0;c<this.plugin.windows.length;c++)p(this.plugin.windows[c]),this.plugin.addRightTitleBarButtons(this.plugin.windows[c]);this.display()})}),t<e.titleRight.length-1&&o.addExtraButton(u=>{u.setIcon("down-arrow-with-tail").setTooltip("Move button to the right").onClick(async()=>{e.titleRight[t]=e.titleRight[t+1],e.titleRight[t+1]=l,await this.plugin.saveSettings();for(let c=0;c<this.plugin.windows.length;c++)p(this.plugin.windows[c]),this.plugin.addRightTitleBarButtons(this.plugin.windows[c]);this.display()})}),o.addExtraButton(u=>{u.setIcon("trash").setTooltip("Remove Command").onClick(async()=>{e.titleRight.remove(l),await this.plugin.saveSettings();for(let c=0;c<this.plugin.windows.length;c++)U(l.id,this.plugin.windows[c]);this.display()})}).addExtraButton(u=>{u.setIcon("gear").setTooltip("Edit Icon").onClick(()=>{let c=e.titleRight.findIndex(a=>a===l);new m(this.plugin,l,"title-right",c).open();for(let a=0;a<this.plugin.windows.length;a++)p(this.plugin.windows[a]),this.plugin.addRightTitleBarButtons(this.plugin.windows[a])})}),o.nameEl.prepend(s),o.nameEl.addClass("CS-flex")}i.createEl("h4",{text:"Center titlebar"}),new d.Setting(i).setName("Add Button").setDesc("Add a new button to the center titlebar.").addButton(t=>{t.setButtonText("Add Command").onClick(()=>{new B(this.plugin,"title-center").open()})});for(let t=0;t<e.titleCenter.length;t++){let l=e.titleCenter[t],s=createDiv({cls:"CS-settings-icon"});(0,d.setIcon)(s,l.icon,24);let o=new d.Setting(i).setName(l.name);t>0&&o.addExtraButton(u=>{u.setIcon("up-arrow-with-tail").setTooltip("Move button to the left").onClick(async()=>{e.titleCenter[t]=e.titleCenter[t-1],e.titleCenter[t-1]=l,await this.plugin.saveSettings();for(let c=0;c<this.plugin.windows.length;c++)w(this.plugin.windows[c]),this.plugin.addCenterTitleBarButtons(this.plugin.windows[c]);this.display()})}),t<e.titleCenter.length-1&&o.addExtraButton(u=>{u.setIcon("down-arrow-with-tail").setTooltip("Move button to the right").onClick(async()=>{e.titleCenter[t]=e.titleCenter[t+1],e.titleCenter[t+1]=l,await this.plugin.saveSettings();for(let c=0;c<this.plugin.windows.length;c++)w(this.plugin.windows[c]),this.plugin.addCenterTitleBarButtons(this.plugin.windows[c]);this.display()})}),o.addExtraButton(u=>{u.setIcon("trash").setTooltip("Remove Command").onClick(async()=>{if(e.titleCenter.remove(l),await this.plugin.saveSettings(),this.plugin.settings.titleCenter.length===0)for(let c=0;c<this.plugin.windows.length;c++)f(this.plugin.titlebarText[c],this.plugin.windows[c]);else for(let c=0;c<this.plugin.windows.length;c++)G(l.id,this.plugin.windows[c]);this.display()})}).addExtraButton(u=>{u.setIcon("gear").setTooltip("Edit Icon").onClick(()=>{let c=e.titleCenter.findIndex(a=>a===l);new m(this.plugin,l,"title-center",c).open()})}),o.nameEl.prepend(s),o.nameEl.addClass("CS-flex")}}}};var K=["lucide-activity","lucide-airplay","lucide-alarm-check","lucide-alarm-clock-off","lucide-alarm-clock","lucide-alarm-minus","lucide-alarm-plus","lucide-album","lucide-alert-circle","lucide-alert-octagon","lucide-alert-triangle","lucide-align-center-horizontal","lucide-align-center","lucide-align-center-vertical","lucide-align-end-horizontal","lucide-align-end-vertical","lucide-align-horizontal-distribute-center","lucide-align-horizontal-distribute-end","lucide-align-horizontal-distribute-start","lucide-align-horizontal-justify-center","lucide-align-horizontal-justify-end","lucide-align-horizontal-justify-start","lucide-align-horizontal-space-around","lucide-align-horizontal-space-between","lucide-align-justify","lucide-align-left","lucide-align-right","lucide-align-start-horizontal","lucide-align-start-vertical","lucide-align-vertical-distribute-center","lucide-align-vertical-distribute-end","lucide-align-vertical-distribute-start","lucide-align-vertical-justify-center","lucide-align-vertical-justify-end","lucide-align-vertical-justify-start","lucide-align-vertical-space-around","lucide-align-vertical-space-between","lucide-anchor","lucide-aperture","lucide-archive","lucide-arrow-big-down","lucide-arrow-big-left","lucide-arrow-big-right","lucide-arrow-big-up","lucide-arrow-down-circle","lucide-arrow-down-left","lucide-arrow-down-right","lucide-arrow-down","lucide-arrow-left-circle","lucide-arrow-left-right","lucide-arrow-left","lucide-arrow-right-circle","lucide-arrow-right","lucide-arrow-up-circle","lucide-arrow-up-left","lucide-arrow-up-right","lucide-arrow-up","lucide-asterisk","lucide-at-sign","lucide-award","lucide-axe","lucide-banknote","lucide-bar-chart-2","lucide-bar-chart","lucide-baseline","lucide-battery-charging","lucide-battery-full","lucide-battery-low","lucide-battery-medium","lucide-battery","lucide-beaker","lucide-bell-minus","lucide-bell-off","lucide-bell-plus","lucide-bell-ring","lucide-bell","lucide-bike","lucide-binary","lucide-bitcoin","lucide-bluetooth-connected","lucide-bluetooth-off","lucide-bluetooth-searching","lucide-bluetooth","lucide-bold","lucide-bookmark-minus","lucide-bookmark-plus","lucide-bookmark","lucide-book-open","lucide-book","lucide-bot","lucide-box-select","lucide-box","lucide-briefcase","lucide-brush","lucide-bug","lucide-building","lucide-bus","lucide-calculator","lucide-calendar","lucide-camera-off","lucide-camera","lucide-carrot","lucide-car","lucide-cast","lucide-check-circle-2","lucide-check-circle","lucide-check-square","lucide-check","lucide-chevron-down","lucide-chevron-first","lucide-chevron-last","lucide-chevron-left","lucide-chevron-right","lucide-chevrons-down","lucide-chevrons-down-up","lucide-chevrons-left","lucide-chevrons-right","lucide-chevrons-up-down","lucide-chevrons-up","lucide-chevron-up","lucide-chrome","lucide-circle-slashed","lucide-circle","lucide-clipboard-check","lucide-clipboard-copy","lucide-clipboard-list","lucide-clipboard","lucide-clipboard-x","lucide-clock-1","lucide-clock-2","lucide-clock-3","lucide-clock-4","lucide-clock-5","lucide-clock-6","lucide-clock-7","lucide-clock-8","lucide-clock-9","lucide-clock-10","lucide-clock-11","lucide-clock-12","lucide-clock","lucide-cloud-drizzle","lucide-cloud-fog","lucide-cloud-hail","lucide-cloud-lightning","lucide-cloud-moon","lucide-cloud-off","lucide-cloud-rain","lucide-cloud-rain-wind","lucide-cloud-snow","lucide-cloud-sun","lucide-cloud","lucide-cloudy","lucide-clover","lucide-code-2","lucide-codepen","lucide-codesandbox","lucide-code","lucide-coffee","lucide-coins","lucide-columns","lucide-command","lucide-compass","lucide-contact","lucide-contrast","lucide-cookie","lucide-copyleft","lucide-copyright","lucide-copy","lucide-corner-down-left","lucide-corner-down-right","lucide-corner-left-down","lucide-corner-left-up","lucide-corner-right-down","lucide-corner-right-up","lucide-corner-up-left","lucide-corner-up-right","lucide-cpu","lucide-credit-card","lucide-crop","lucide-crosshair","lucide-cross","lucide-crown","lucide-currency","lucide-database","lucide-delete","lucide-disc","lucide-divide-circle","lucide-divide-square","lucide-divide","lucide-dollar-sign","lucide-download-cloud","lucide-download","lucide-dribbble","lucide-droplets","lucide-droplet","lucide-drumstick","lucide-edit-2","lucide-edit-3","lucide-edit","lucide-egg","lucide-equal-not","lucide-equal","lucide-euro","lucide-expand","lucide-external-link","lucide-eye-off","lucide-eye","lucide-facebook","lucide-fast-forward","lucide-feather","lucide-figma","lucide-file-check-2","lucide-file-check","lucide-file-code","lucide-file-digit","lucide-file-input","lucide-file-minus-2","lucide-file-minus","lucide-file-output","lucide-file-plus-2","lucide-file-plus","lucide-file-search","lucide-files","lucide-file","lucide-file-text","lucide-file-x-2","lucide-file-x","lucide-film","lucide-filter","lucide-flag","lucide-flag-triangle-left","lucide-flag-triangle-right","lucide-flame","lucide-flashlight-off","lucide-flashlight","lucide-flask-conical","lucide-flask-round","lucide-folder-minus","lucide-folder-open","lucide-folder-plus","lucide-folder","lucide-form-input","lucide-forward","lucide-framer","lucide-frown","lucide-function-square","lucide-gamepad-2","lucide-gamepad","lucide-gauge","lucide-gavel","lucide-gem","lucide-ghost","lucide-gift","lucide-git-branch-plus","lucide-git-branch","lucide-git-commit","lucide-github","lucide-gitlab","lucide-git-merge","lucide-git-pull-request","lucide-glasses","lucide-globe-2","lucide-globe","lucide-grab","lucide-graduation-cap","lucide-grid","lucide-grip-horizontal","lucide-grip-vertical","lucide-hammer","lucide-hand-metal","lucide-hand","lucide-hard-drive","lucide-hard-hat","lucide-hash","lucide-haze","lucide-headphones","lucide-heart","lucide-help-circle","lucide-hexagon","lucide-highlighter","lucide-history","lucide-home","lucide-image-minus","lucide-image-off","lucide-image-plus","lucide-image","lucide-import","lucide-inbox","lucide-indent","lucide-indian-rupee","lucide-infinity","lucide-info","lucide-inspect","lucide-instagram","lucide-italic","lucide-japanese-yen","lucide-keyboard","lucide-key","lucide-landmark","lucide-languages","lucide-laptop-2","lucide-laptop","lucide-lasso-select","lucide-lasso","lucide-layers","lucide-layout-dashboard","lucide-layout-grid","lucide-layout-list","lucide-layout","lucide-layout-template","lucide-library","lucide-life-buoy","lucide-lightbulb-off","lucide-lightbulb","lucide-link-2-off","lucide-link-2","lucide-linkedin","lucide-link","lucide-list-checks","lucide-list-minus","lucide-list-ordered","lucide-list-plus","lucide-list","lucide-list-x","lucide-loader-2","lucide-loader","lucide-locate-fixed","lucide-locate-off","lucide-locate","lucide-lock","lucide-log-in","lucide-log-out","lucide-mail","lucide-map-pin","lucide-map","lucide-maximize-2","lucide-maximize","lucide-megaphone","lucide-meh","lucide-menu","lucide-message-circle","lucide-message-square","lucide-mic-off","lucide-mic","lucide-minimize-2","lucide-minimize","lucide-minus-circle","lucide-minus-square","lucide-minus","lucide-monitor-off","lucide-monitor-speaker","lucide-monitor","lucide-moon","lucide-more-horizontal","lucide-more-vertical","lucide-mountain-snow","lucide-mountain","lucide-mouse-pointer-2","lucide-mouse-pointer-click","lucide-mouse-pointer","lucide-move-diagonal-2","lucide-move-diagonal","lucide-move-horizontal","lucide-move","lucide-move-vertical","lucide-music","lucide-navigation-2","lucide-navigation","lucide-network","lucide-octagon","lucide-option","lucide-outdent","lucide-package-check","lucide-package-minus","lucide-package-plus","lucide-package-search","lucide-package","lucide-package-x","lucide-palette","lucide-palmtree","lucide-paperclip","lucide-pause-circle","lucide-pause-octagon","lucide-pause","lucide-pencil","lucide-pen-tool","lucide-percent","lucide-person-standing","lucide-phone-call","lucide-phone-forwarded","lucide-phone-incoming","lucide-phone-missed","lucide-phone-off","lucide-phone-outgoing","lucide-phone","lucide-pie-chart","lucide-piggy-bank","lucide-pin","lucide-pipette","lucide-plane","lucide-play-circle","lucide-play","lucide-plug-zap","lucide-plus-circle","lucide-plus-square","lucide-plus","lucide-pocket","lucide-podcast","lucide-pointer","lucide-pound-sterling","lucide-power-off","lucide-power","lucide-printer","lucide-qr-code","lucide-quote","lucide-radio-receiver","lucide-radio","lucide-redo","lucide-refresh-ccw","lucide-refresh-cw","lucide-regex","lucide-repeat-1","lucide-repeat","lucide-reply-all","lucide-reply","lucide-rewind","lucide-rocking-chair","lucide-rotate-ccw","lucide-rotate-cw","lucide-rss","lucide-ruler","lucide-russian-ruble","lucide-save","lucide-scale","lucide-scan-line","lucide-scan","lucide-scissors","lucide-screen-share-off","lucide-screen-share","lucide-search","lucide-send","lucide-separator-horizontal","lucide-separator-vertical","lucide-server-crash","lucide-server-off","lucide-server","lucide-settings-2","lucide-settings","lucide-share-2","lucide-share","lucide-sheet","lucide-shield-alert","lucide-shield-check","lucide-shield-close","lucide-shield-off","lucide-shield","lucide-shirt","lucide-shopping-bag","lucide-shopping-cart","lucide-shovel","lucide-shrink","lucide-shuffle","lucide-sidebar-close","lucide-sidebar-open","lucide-sidebar","lucide-sigma","lucide-signal-high","lucide-signal-low","lucide-signal-medium","lucide-signal","lucide-signal-zero","lucide-skip-back","lucide-skip-forward","lucide-skull","lucide-slack","lucide-slash","lucide-sliders","lucide-smartphone-charging","lucide-smartphone","lucide-smile","lucide-snowflake","lucide-sort-asc","lucide-sort-desc","lucide-speaker","lucide-sprout","lucide-square","lucide-star-half","lucide-star","lucide-stop-circle","lucide-stretch-horizontal","lucide-stretch-vertical","lucide-strikethrough","lucide-subscript","lucide-sunrise","lucide-sunset","lucide-sun","lucide-superscript","lucide-swiss-franc","lucide-switch-camera","lucide-table","lucide-tablet","lucide-tag","lucide-target","lucide-tent","lucide-terminal-square","lucide-terminal","lucide-text-cursor-input","lucide-text-cursor","lucide-thermometer-snowflake","lucide-thermometer-sun","lucide-thermometer","lucide-thumbs-down","lucide-thumbs-up","lucide-ticket","lucide-timer-off","lucide-timer-reset","lucide-timer","lucide-toggle-left","lucide-toggle-right","lucide-tornado","lucide-trash-2","lucide-trash","lucide-trello","lucide-trending-down","lucide-trending-up","lucide-triangle","lucide-truck","lucide-tv-2","lucide-tv","lucide-twitch","lucide-twitter","lucide-type","lucide-umbrella","lucide-underline","lucide-undo","lucide-unlink-2","lucide-unlink","lucide-unlock","lucide-upload-cloud","lucide-upload","lucide-user-check","lucide-user-minus","lucide-user-plus","lucide-users","lucide-user","lucide-user-x","lucide-verified","lucide-vibrate","lucide-video-off","lucide-video","lucide-view","lucide-voicemail","lucide-volume-1","lucide-volume-2","lucide-volume","lucide-volume-x","lucide-wallet","lucide-wand","lucide-watch","lucide-waves","lucide-webcam","lucide-wifi-off","lucide-wifi","lucide-wind","lucide-wrap-text","lucide-wrench","lucide-x-circle","lucide-x-octagon","lucide-x-square","lucide-x","lucide-youtube","lucide-zap-off","lucide-zap","lucide-zoom-in","lucide-zoom-out"];var ne={enabledButtons:[],desktop:!1,titleLeft:[],titleRight:[],titleCenter:[],paneRelief:!1},O=class extends r.Plugin{constructor(){super(...arguments);this.iconList=H.concat(K);this.titlebarText=[];this.windows=[]}addPageHeaderButton(i,e){let{id:t,icon:l,name:s}=e,o=_(),c=E(s,t,l,o,["view-action",h]);this.settings.paneRelief&&(t==="app:go-forward"||t==="app:go-back")&&c.addClass("pane-relief"),i.prepend(c),this.registerDomEvent(c,"mousedown",a=>{a.button===0&&setTimeout(()=>{this.app.commands.executeCommandById(t)},5)})}addLeftTitleBarButton(i,e){let{id:t,icon:l,name:s}=e,u=E(s,t,l,15,L,"div");i.append(u),this.registerDomEvent(u,"click",()=>{this.app.commands.executeCommandById(t)})}addRightTitleBarButton(i,e){let{id:t,icon:l,name:s}=e,u=E(s,t,l,15,L,"div");i.insertBefore(u,i.children[0]),this.registerDomEvent(u,"click",()=>{this.app.commands.executeCommandById(t)})}addCenterTitleBarButton(i,e){let{id:t,icon:l,name:s}=e,u=E(s,t,l,15,L,"div");i.append(u),this.registerDomEvent(u,"click",()=>{this.app.commands.executeCommandById(t)})}addLeftTitleBarButtons(i){if(this.settings.titleLeft.length>0){let e=A(i);for(let t of this.settings.titleLeft)this.addLeftTitleBarButton(e,t)}}addRightTitleBarButtons(i){if(this.settings.titleRight.length>0){let e=P(i);for(let t=this.settings.titleRight.length-1;t>=0;t--)this.addRightTitleBarButton(e,this.settings.titleRight[t])}}addCenterTitleBarButtons(i){if(this.settings.titleCenter.length>0){let e=D(i);for(let t of this.settings.titleCenter)this.addCenterTitleBarButton(e,t)}}initTitleBar(i){if(this.addLeftTitleBarButtons(i),this.addRightTitleBarButtons(i),this.settings.titleCenter.length>0){let e=y(i);if(!this.titlebarText.contains(e)){this.titlebarText.push(e),v(i);let t=T(i);this.addCenterTitleBarButtons(i)}}}async onload(){if(console.log("loading Customizable Page Header Plugin"),await this.loadSettings(),this.addSettingTab(new N(this.app,this)),this.app.workspace.onLayoutReady(()=>{var i;if(r.Platform.isDesktopApp){this.windows.push(document),this.initTitleBar(document);let{children:e}=this.app.workspace.floatingSplit;if(e.length+1!==this.windows.length){for(let t of e)if(t instanceof r.WorkspaceWindow){let l=(i=t.getContainer())==null?void 0:i.doc;l&&(this.windows.push(l),this.initTitleBar(l))}}}(r.Platform.isMobile||this.settings.desktop)&&this.addButtonsToAllLeaves()}),r.Platform.isMobile||this.settings.desktop){let i=this;this.register(q(r.Workspace.prototype,{changeLayout(e){return async function(l){await e.call(this,l),i.addButtonsToAllLeaves()}}})),this.registerEvent(this.app.workspace.on("layout-change",()=>{let e=app.workspace.getActiveViewOfType(r.View);!e||this.addButtonsToLeaf(e.leaf)})),this.registerEvent(this.app.workspace.on("window-open",(e,t)=>{var s;let l=(s=e.getContainer())==null?void 0:s.doc;l&&(this.windows.push(l),this.initTitleBar(l))}))}}addButtonsToAllLeaves(){app.workspace.iterateAllLeaves(i=>this.addButtonsToLeaf(i)),app.workspace.onLayoutChange()}addButtonsToLeaf(i){var l;let e=i==null?void 0:i.view.containerEl,t=e==null?void 0:e.getElementsByClassName("view-actions")[0];if(!!t)for(let s=this.settings.enabledButtons.length-1;s>=0;s--)(l=t.getElementsByClassName(`view-action page-header-button ${this.settings.enabledButtons[s].id}`)[0])==null||l.detach(),(this.settings.enabledButtons[s].showButtons==="both"||this.settings.enabledButtons[s].showButtons==="mobile"&&r.Platform.isMobile||this.settings.enabledButtons[s].showButtons==="desktop"&&r.Platform.isDesktop)&&this.addPageHeaderButton(t,this.settings.enabledButtons[s])}onunload(){console.log("unloading Customizable Page Header Plugin"),$();for(let i=0;i<this.windows.length;i++)W(this.windows[i]),f(this.titlebarText[i],this.windows[i]);globalThis.removeEventListener("TopBar-addedCommand",this.listener)}async loadSettings(){this.settings=Object.assign({},ne,await this.loadData())}async saveSettings(){await this.saveData(this.settings),app.workspace.onLayoutReady(()=>this.addButtonsToAllLeaves())}};
