vart4=Object.create;varJ=Object.defineProperty;vars4=Object.getOwnPropertyDescriptor;varh4=Object.getOwnPropertyNames;varv4=Object.getPrototypeOf,m4=Object.prototype.hasOwnProperty;varF1=i=>J(i,"__esModule",{value:!0});varz4=(i,c)=>()=>(c||i((c={exports:{}}).exports,c),c.exports),p4=(i,c)=>{F1(i);for(varainc)J(i,a,{get:c[a],enumerable:!0})},d4=(i,c,a)=>{if(c&&typeofc=="object"||typeofc=="function")for(leteofh4(c))!m4.call(i,e)&&e!=="default"&&J(i,e,{get:()=>c[e],enumerable:!(a=s4(c,e))||a.enumerable});returni},S=i=>d4(F1(J(i!=null?t4(v4(i)):{},"default",i&&i.__esModule&&"default"ini?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);varX1=z4((LL,Q1)=>{"use strict";varh1=Object.defineProperty,H4=Object.getOwnPropertyDescriptor,V4=Object.getOwnPropertyNames,g4=Object.prototype.hasOwnProperty,L4=(i,c)=>{for(varainc)h1(i,a,{get:c[a],enumerable:!0})},x4=(i,c,a,e)=>{if(c&&typeofc=="object"||typeofc=="function")for(letnofV4(c))!g4.call(i,n)&&n!==a&&h1(i,n,{get:()=>c[n],enumerable:!(e=H4(c,n))||e.enumerable});returni},b4=i=>x4(h1({},"__esModule",{value:!0}),i),$1={};L4($1,{FileInputSuggest:()=>A4,FolderInputSuggest:()=>N4,FuzzyInputSuggest:()=>m1,createCollapsibleSection:()=>w4,setNodeIcon:()=>y4});Q1.exports=b4($1);varv1=require("obsidian"),m1=classextendsv1.AbstractInputSuggest{constructor(i,c,a){super(i,c.inputEl);this.items=a}getSuggestions(i){letc=(0,v1.prepareSimpleSearch)(i),a=[];for(leteofthis.items){letn=c(this.getItemText(e));n&&a.push({item:e,match:n})}returna}renderSuggestion(i,c){c.addClass("mod-complex");leta=c.createDiv({cls:"suggestion-content"});if(!i?.item){a.setText("No match found"),a.parentElement?.addClass("is-selected");return}this.renderTitle(a.createDiv("suggestion-title"),i),this.renderNote?.(a.createDiv("suggestion-note"),i),this.renderFlair?.(c.createDiv("suggestion-aux").createDiv("suggestion-flair"),i)}renderMatches(i,c,a,e){(0,v1.renderMatches)(i,c,a,e)}},Y1=require("obsidian"),N4=classextendsm1{getItemText(i){returni.path}renderNote(i,c){let{item:a,match:e}=c;(0,Y1.renderMatches)(i,a.path,e.matches)}renderTitle(i,c){let{item:a,match:e}=c;(0,Y1.renderMatches)(i,a.name,e.matches,a.path.length-a.name.length)}},K1=require("obsidian"),A4=classextendsm1{getItemText(i){returni.path}renderNote(i,c){let{item:a,match:e}=c;(0,K1.renderMatches)(i,a.path,e.matches)}renderTitle(i,c){let{item:a,match:e}=c;(0,K1.renderMatches)(i,a.name,e.matches,a.path.length-a.name.length)}},S4=require("obsidian");functiony4(i,c){i.addClass("has-node-icon"),(0,S4.setIcon)(i,c)}varJ1=require("obsidian");functionw4(i,c,a,e){letn=i.createEl("details",{cls:"javalent-nested-settings",attr:{...a??!0?{open:"open"}:{}}});n.ontoggle=async()=>{e&&e(n.open)};letl=n.createEl("summary");returnnewJ1.Setting(l).setHeading().setName(c),(0,J1.setIcon)(l.createDiv("handle"),"chevron-right"),n}});p4(exports,{default:()=>B1});vard=S(require("obsidian"));varq1=S(require("obsidian"));functionM4(i,c){for(leta=0;a<c.length;a++)if(i.startsWith(c[a]))returna;return!1}functionR1(i,c,a){lete=a.title??i[0].toUpperCase()+i.slice(1).toLowerCase(),n=["title:","collapse:","icon:","color:","metadata:"],l=["title","collapse","icon","color","metadata"],o=c.split(`
`],l=new Blob([this.plugin.calloutManager.generateCssString()],{type:"text/css"});createEl("a",{attr:{download:"custom_callouts.css",href:URL.createObjectURL(l)}}).click()}).setDisabled(!Object.keys(this.plugin.data.userAdmonitions).length)),new v.Setting(c).setName("Export Custom Types as JSON").setDesc("Choose custom types to export as a JSON file that you can then share with other users.").addButton(e=>e.setButtonText("Download All").setCta().onClick(()=>{let n=Object.values(this.plugin.data.userAdmonitions);this.download(n)})).addButton(e=>e.setButtonText("Select & Download").onClick(()=>{let n=new a1(this.plugin);n.onClose=()=>{if(!n.export)return;let l=Object.values(this.plugin.data.userAdmonitions);this.download(l.filter(o=>n.selectedAdmonitions.includes(o.type)))},n.open()})),new v.Setting(c).setName("Use CSS Snippet for Custom Callouts").setDesc("Instead of managing it internally, Admonitions will maintain a CSS snippet to enable your custom types for callouts.").addToggle(e=>e.setValue(this.plugin.data.useSnippet).onChange(n=>{this.plugin.data.useSnippet=n,this.plugin.saveSettings(),this.plugin.calloutManager.setUseSnippet()})),new v.Setting(c).setName(M("Add New")).setDesc("Add a new Admonition type. All custom Admonitions will also be usable as callouts.").addButton(e=>e.setTooltip(M("Add Additional")).setButtonText("+").onClick(async()=>{let l=new T(this.plugin);l.onClose=async()=>{if(l.saved){let o={type:l.type,color:l.color,icon:l.icon,command:!1,title:l.title,injectColor:l.injectColor,noTitle:l.noTitle,copy:l.copy};this.plugin.addAdmonition(o),this.plugin.calloutManager.addAdmonition(o),this.display()}},l.open()})),new v.Setting(c).setName("Import Admonition(s)").setDesc("Import admonitions from a JSON definition.").addButton(e=>{let n=createEl("input",{attr:{type:"file",name:"merge",accept:".json",multiple:!0,style:"display: none;"}});n.onchange=async()=>{let{files:l}=n;if(!!l.length){try{let o=[];for(let r of Array.from(l))o.push(JSON.parse(await r.text()));for(let r of o.flat()){if(typeof r!="object")continue;r.icon||(r.icon={name:"pencil-alt",type:"font-awesome"});let f=y.validateImport(this.plugin,r);if(f.success==!1){new v.Notice(createFragment(s=>{s.createSpan({text:`Therewasanissueimportingthe${r.type}admonition:`}),s.createEl("br"),s.createSpan({text:f.message})}));continue}f.messages?.length&&new v.Notice(createFragment(s=>{s.createSpan({text:`Therewasanissueimportingthe${r.type}admonition:`});for(let h of f.messages)s.createEl("br"),s.createSpan({text:h})})),await this.plugin.addAdmonition(r)}this.display()}catch(o){new v.Notice(`Therewasanerrorwhileimportingtheadmonition${l.length==1?"":"s"}.`),console.error(o)}n.value=null}},e.setButtonText("Choose Files"),e.buttonEl.appendChild(n),e.onClick(()=>n.click())}).addExtraButton(e=>e.setIcon("info").onClick(()=>{let n=new v.Modal(this.plugin.app);n.onOpen=()=>{n.contentEl.createSpan({text:"Import one or more admonition definitions as a JSON array. An admonition definition should look as follows at minimum:"}),n.contentEl.createEl("br");let l=new v.TextAreaComponent(n.contentEl.createDiv()).setDisabled(!0).setValue(JSON.stringify({type:"embed-affliction",color:"149, 214, 148",icon:{name:"head-side-cough",type:"font-awesome"}},null,4));l.inputEl.setAttribute("style",`height:${l.inputEl.scrollHeight}px;resize:none;`),n.contentEl.createEl("br"),n.contentEl.createSpan({text:"See the plugin ReadMe for more information."})},n.open()})),this.additionalEl=c.createDiv("additional"),this.buildTypes(),this.buildAdmonitions(this.containerEl.createEl("details",{cls:"admonitions-nested-settings",attr:{...this.plugin.data.open.admonitions?{open:!0}:{}}})),this.buildIcons(this.containerEl.createEl("details",{cls:"admonitions-nested-settings",attr:{...this.plugin.data.open.icons?{open:!0}:{}}})),this.buildOtherSyntaxes(this.containerEl.createEl("details",{cls:"admonitions-nested-settings",attr:{...this.plugin.data.open.other?{open:!0}:{}}})),this.buildAdvanced(this.containerEl.createEl("details",{cls:"admonitions-nested-settings",attr:{...th
>`)}`),this.converted++}returnc}buildAdvanced(c){c.empty(),c.ontoggle=()=>{this.plugin.data.open.advanced=c.open,this.plugin.saveSettings()};leta=c.createEl("summary");newv.Setting(a).setHeading().setName("Advanced Settings"),a.createDiv("collapser").createDiv("handle"),newv.Setting(c).setName(M("Markdown Syntax Highlighting")).setDesc(M("Use Obsidian's markdown syntax highlighter in admonition code blocks. This setting is experimental and could cause errors.")).addToggle(e=>{e.setValue(this.plugin.data.syntaxHighlight),e.onChange(asyncn=>{this.plugin.data.syntaxHighlight=n,n?this.plugin.turnOnSyntaxHighlighting():this.plugin.turnOffSyntaxHighlighting(),awaitthis.plugin.saveSettings()})})}buildTypes(){this.additionalEl.empty();for(letcofObject.values(this.plugin.data.userAdmonitions)){leta=newv.Setting(this.additionalEl),e=this.plugin.getAdmonitionElement(c.type,c.type[0].toUpperCase()+c.type.slice(1).toLowerCase(),c.icon,c.injectColor??this.plugin.data.injectColor?c.color:null);a.infoEl.replaceWith(e),c.command?a.addExtraButton(n=>{n.setIcon(X.toString()).setTooltip(M("Unregister Commands")).onClick(async()=>{this.plugin.unregisterCommandsFor(c),awaitthis.plugin.saveSettings(),this.display()})}):a.addExtraButton(n=>{n.setIcon(Q.toString()).setTooltip(M("Register Commands")).onClick(async()=>{this.plugin.registerCommandsFor(c),awaitthis.plugin.saveSettings(),this.display()})}),a.addExtraButton(n=>{n.setIcon("pencil").setTooltip(M("Edit")).onClick(()=>{letl=newT(this.plugin,c);l.onClose=async()=>{if(l.saved){leto=c.command,r={type:l.type,color:l.color,icon:l.icon,command:o,title:l.title,injectColor:l.injectColor,noTitle:l.noTitle,copy:l.copy};if(r.type!=c.type){this.plugin.unregisterType(c);letf=Object.entries(this.plugin.data.userAdmonitions);this.plugin.data.userAdmonitions=Object.fromEntries(f.map(([s,h])=>s==c.type?[r.type,r]:[s,h]))}elsethis.plugin.data.userAdmonitions[r.type]=r;this.plugin.registerType(r.type),this.plugin.calloutManager.addAdmonition(r),this.display()}},l.open()})}).addExtraButton(n=>{n.setIcon("trash").setTooltip(M("Delete")).onClick(()=>{this.plugin.removeAdmonition(c),this.display()})})}}},T=classextendsv.Modal{constructor(c,a){super(c.app);this.plugin=c;this.color="#7d7d7d";this.icon={};this.saved=!1;this.error=!1;this.injectColor=this.plugin.data.injectColor;this.noTitle=!1;this.editing=!1;a&&(this.editing=!0,this.color=a.color,this.icon=a.icon,this.type=a.type,this.originalType=a.type,this.title=a.title,this.injectColor=a.injectColor??this.injectColor,this.noTitle=a.noTitle??!1,this.copy=a.copy??this.plugin.data.copyButton)}setAdmonitionElement(c){this.admonitionPreviewParent.empty(),this.admonitionPreview=this.plugin.getAdmonitionElement(this.type,c[0].toUpperCase()+c.slice(1).toLowerCase(),this.icon,this.injectColor??this.plugin.data.injectColor?this.color:null),this.admonitionPreview.createDiv("callout-content admonition-content").createEl("p",{text:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla."}),this.admonitionPreviewParent.appendChild(this.admonitionPreview)}asyncdisplay(){this.containerEl.addClass("admonition-settings-modal"),this.titleEl.setText(`${this.editing?"Edit":"Add"} Admonition`);let{contentEl:c}=this;c.empty();leta=c.createDiv(),e=this.title??this.type??"...";this.admonitionPreviewParent=c.createDiv(),this.setAdmonitionElement(e[0].toUpperCase()+e.slice(1).toLowerCase());letn,l=newv.Setting(a).setName(M("Admonition Type")).addText(t=>{n=t,n.setValue(this.type).onChange(m=>{letz=y.validateType(m,this.plugin,this.originalType);if(z.success==!1){T.setValidationError(t.inputEl,z.message);return}T.removeValidationError(t.inputEl),this.type=m,this.title||this.setAdmonitionElement(this.type?.[0].toUpperCase()+this.type?.slice(1).toLowerCase())})});l.controlEl.addClass("admonition-type-setting"),l.descEl.createSpan({text:"This is used to create the admonition (e.g., "}),l.descEl.createEl("code",{text:"note"}),l.descEl.createSpan({text:" or "}),l.descEl.createEl("code",{text:"abstract"}),l.descEl.createSpan({text:")"}),new
`).replace(/^> /gm,"")).then(async()=>{new q.Notice("Callout content copied to clipboard.")})})}}if(l.noTitle&&!e.dataset.calloutFold&&o.querySelector(".callout-title-inner")?.textContent?.toLowerCase()===l.type.toLowerCase()&&o.addClass("no-title"),!l.noTitle&&this.plugin.data.autoCollapse&&!e.dataset.calloutFold&&this.setCollapsible(e),l.title&&o.textContent==n[0].toUpperCase()+n.slice(1).toLowerCase()){let s=o.querySelector(".callout-title-inner");s&&s.setText(l.title)}this.plugin.data.dropShadow&&e.addClass("drop-shadow")}setCollapsible(c){let a=c.querySelector(".callout-title"),e=c.querySelector(".callout-content");if(!e)return;c.addClass("is-collapsible"),this.plugin.data.defaultCollapseType=="closed"?(c.dataset.calloutFold="-",c.addClass("is-collapsed")):c.dataset.calloutFold="+";let n=a.createDiv("callout-fold");(0,q.setIcon)(n,"chevron-down");let l=c.hasClass("is-collapsed");if(this.getComputedHeights(e),l)for(let o of this.heights)e.style.setProperty(o,"0px");a.onclick=o=>{this.collapse(c,o)}}collapse(c,a){a?.preventDefault();let e=c.querySelector(".callout-content");function n(o){e.removeEventListener("transitionend",n),e.style.removeProperty("transition")}e.addEventListener("transitionend",n),e.style.setProperty("transition","all 100ms cubic-bezier(.02, .01, .47, 1)");let l=c.hasClass("is-collapsed");if(!a||a.button==0){let o=this.getComputedHeights(e);for(let r of this.heights)e.style.setProperty(r,l?o[r]:"0px");c.toggleClass("is-collapsed",!l)}}getComputedHeights(c){if(this.heightMap.has(c))return this.heightMap.get(c);let a=getComputedStyle(c),e={};for(let n of this.heights)e[n]=a.getPropertyValue(n);return this.heightMap.set(c,e),e}generateCssString(){let c=[`/* This snippet was auto-generated by the Admonitions plugin */
`);let o=e.getCursor();e.setCursor(o.line-2)}catch{new d.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}`,name:`Insert${c.type}`,editorCheckCallback:(a,e,n)=>{if(a)return c.command;if(c.command)try{e.getDoc().replaceSelection(`\`\`\`ad-${c.type}
`);let l=e.getCursor();e.setCursor(l.line-2)}catch{new d.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}-with-title`,name:`Insert${c.type}WithTitle`,editorCheckCallback:(a,e,n)=>{if(a)return c.command;if(c.command)try{let l=c.title??"";e.getDoc().replaceSelection(`\`\`\`ad-${c.type}
`);let o=e.getCursor();e.setCursor(o.line-3)}catch{new d.Notice("There was an issue inserting the admonition.")}}})}unregisterType(c){this.data.syntaxHighlight&&this.turnOffSyntaxHighlighting([c.type]),c.command&&this.unregisterCommandsFor(c),this.postprocessors.has(c.type)&&(d.MarkdownPreviewRenderer.unregisterPostProcessor(this.postprocessors.get(c.type)),d.MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(`ad-${c.type}`),this.postprocessors.delete(c.type))}async removeAdmonition(c){this.data.userAdmonitions[c.type]&&delete this.data.userAdmonitions[c.type],this.unregisterType(c),this.calloutManager.removeAdmonition(c),await this.saveSettings()}unregisterCommandsFor(c){c.command=!1,this.app.commands.findCommand(`obsidian-admonition:insert-${c.type}`)&&(delete this.app.commands.editorCommands[`obsidian-admonition:insert-${c.type}`],delete this.app.commands.editorCommands[`obsidian-admonition:insert-${c.type}-with-title`],delete this.app.commands.commands[`obsidian-admonition:insert-${c.type}`],delete this.app.commands.commands[`obsidian-admonition:insert-${c.type}-with-title`])}async saveSettings(){this.data.version=this.manifest.version,await this.saveData(this.data)}async loadSettings(){let c=await this.loadData();if(this.data=Object.assign({},dL,c),this.data.userAdmonitions){if(!this.data.version||Number(this.data.version.split(".")[0])<5)for(let a in this.data.userAdmonitions)Object.prototype.hasOwnProperty.call(this.data.userAdmonitions[a],"type")||(this.data.userAdmonitions[a]={...this.data.userAdmonitions[a],icon:{type:"font-awesome",name:this.data.userAdmonitions[a].icon}});(!this.data.version||Number(this.data.version.split(".")[0])<8)&&new d.Notice(createFragment(a=>{a.createSpan({text:"Admonitions: Obsidian now has native support for callouts! Check out the "}),a.createEl("a",{text:"Admonitions ReadMe",href:"obsidian://show-plugin?id=obsidian-admonition"}),a.createSpan({text:" for what that means for Admonitions going forward."})}),0)}if(!this.data.rpgDownloadedOnce&&this.data.userAdmonitions&&Object.values(this.data.userAdmonitions).some(a=>{if(a.icon.type=="rpg")return!0})&&!this.data.icons.includes("rpg"))try{await this.downloadIcon("rpg"),this.data.rpgDownloadedOnce=!0}catch{}await this.saveSettings()}turnOnSyntaxHighlighting(c=Object.keys(this.admonitions)){!this.data.syntaxHighlight||(c.forEach(a=>{if(this.data.syntaxHighlight){let[,e]=`${a}`.match(/^([\w+#-]*)[^\n`]*$/);window.CodeMirror.defineMode(`ad-${e}`,(n,l)=>window.CodeMirror.getMode({},"hypermd"))}}),this.app.workspace.onLayoutReady(()=>this.app.workspace.iterateCodeMirrors(a=>a.setOption("mode",a.getOption("mode")))))}turnOffSyntaxHighlighting(c=Object.keys(this.admonitions)){c.forEach(a=>{window.CodeMirror.modes.hasOwnProperty(`ad-${a}`)&&deletewindow.CodeMirror.modes[`ad-${a}`]}),this.app.workspace.onLayoutReady(()=>this.app.workspace.iterateCodeMirrors(a=>a.setOption("mode",a.getOption("mode"))))}asynconunload(){console.log("Obsidian Admonition unloaded"),this.postprocessors=null,this.turnOffSyntaxHighlighting()}};