varoe=Object.defineProperty;varve=Object.getOwnPropertyDescriptor;varCe=Object.getOwnPropertyNames;varTe=Object.prototype.hasOwnProperty;varFe=(w,t)=>{for(vareint)oe(w,e,{get:t[e],enumerable:!0})},xe=(w,t,e,n)=>{if(t&&typeoft=="object"||typeoft=="function")for(letiofCe(t))!Te.call(w,i)&&i!==e&&oe(w,i,{get:()=>t[i],enumerable:!(n=ve(t,i))||n.enumerable});returnw};varSe=w=>xe(oe({},"__esModule",{value:!0}),w);varMe={};Fe(Me,{default:()=>re});module.exports=Se(Me);varbe=require("obsidian");varA=require("obsidian");varZ=class{constructor(){this.values=newMap}put(t,e){this.values.set(t,e)}get(t,e){varn;return(n=this.values.get(t))!=null?n:e}getFirst(t,e){for(letn=0;n<t.length;n++){leti=t[n];if(this.containsKey(i))returnthis.get(i,e)}returne}containsKey(t){returnthis.values.has(t)}getKeys(){returnArray.from(this.values.keys())}removeKey(t){returnthis.values.delete(t)}clear(){this.values.clear()}};varae=require("obsidian"),B=class{staticgetFilePathWithNewExtension(t,e){return(0,ae.normalizePath)(t.parent.path+"/"+t.basename+"."+e)}staticgetFilePathExcludingExtension(t){return(0,ae.normalizePath)(t.parent.path+"/"+t.basename)}};varu=class{staticsetActive(t){u.isActive=t,u.isActive||this.clear()}staticsetAutoExpire(t){u.baseMinutesToExpire=t!=null?t:0,u.updateExpiryTime()}staticsetLevel(t){u.level!=t&&(u.allLevels.contains(t)&&(u.level=t),u.level=u.LevelFilename,this.clear())}staticupdateExpiryTime(){u.baseMinutesToExpire==0||u.baseMinutesToExpire==null?u.expiryTime=null:u.expiryTime=Date.now()+u.baseMinutesToExpire*1e3*60}staticputByFile(t,e){if(!u.isActive)return;letn=u.getFileCacheKey(e);this.cache.put(n,t),u.updateExpiryTime()}staticgetByFile(t){if(!u.isActive)returnu.blankPasswordAndHint;this.clearIfExpired(),u.updateExpiryTime();lete=u.getFileCacheKey(t);returnthis.cache.get(e,u.blankPasswordAndHint)}staticputByPath(t,e){if(!u.isActive)return;letn=u.getPathCacheKey(e);this.cache.put(n,t),u.updateExpiryTime()}staticgetByPath(t){if(!u.isActive)returnu.blankPasswordAndHint;this.clearIfExpired(),u.updateExpiryTime();lete=u.getPathCacheKey(t);returnthis.cache.get(e,u.blankPasswordAndHint)}staticgetPathCacheKey(t){lete=t.split("/").slice(0,-1).join("/");switch(u.level){caseu.LevelParentPath:returne;default:returnt}}staticgetFileCacheKey(t){switch(u.level){caseu.LevelParentPath:returnt.parent.path;default:returnB.getFilePathExcludingExtension(t)}}staticclearIfExpired(){u.expiryTime!=null&&(Date.now()<u.expiryTime||this.clear())}staticclearForFile(t){lete=u.getFileCacheKey(t);this.cache.removeKey(e)}staticclearForPath(t){lete=u.getPathCacheKey(t);this.cache.removeKey(e)}staticclear(){this.cache.clear()}},g=u;g.isActive=!0,g.blankPasswordAndHint={password:"",hint:""},g.cache=newZ,g.baseMinutesToExpire=0,g.expiryTime=null,g.LevelFilename="filename",g.LevelParentPath="parentPath",g.allLevels=[u.LevelFilename,u.LevelParentPath],g.level=u.LevelFilename;varW=classextendsA.PluginSettingTab{constructor(e,n,i,s){super(e,n);this.plugin=n,this.settings=i,this.features=s}display(){let{containerEl:e}=this;e.empty(),e.createEl("h1",{text:"Settings for Meld Encrypt"}),newA.Setting(e).setHeading().setName("Common Settings"),newA.Setting(e).setName("Confirm password?").setDesc("Confirm password when encrypting. (Recommended)").addToggle(r=>{r.setValue(this.settings.confirmPassword).onChange(asynco=>{this.settings.confirmPassword=o,awaitthis.plugin.saveSettings()})});letn=()=>{if(!this.settings.rememberPassword){i.settingEl.hide(),s.settingEl.hide();return}i.settingEl.show(),s.settingEl.show();letr=this.settings.rememberPasswordTimeout,o=`For ${r} minutes`;r==0&&(o="Until Obsidian is closed"),i.setName(`Remember Password (${o})`)};newA.Setting(e).setName("Remember password?").setDesc("Remember the last used passwords when encrypting or decrypting. Passwords are remembered until they timeout or Obsidian is closed").addToggle(r=>{r.setValue(this.settings.rememberPassword).onChange(asynco=>{this.settings.rememberPassword=o,awaitthis.plugin.saveSettings(),g.setActive(this.sett
`).slice(e,n+1).join(`
`)}static findFirstMarker(t,e,n=0){let i=null,s=null;return t.forEach(r=>{let o=e.indexOf(r,n);o!=-1&&(i==null||o<i)&&(i=o,s=r)}),s==null||i==null?null:{marker:s,position:i}}};var D=require("obsidian");var y=require("obsidian");var K=class{static get showInlineTitle(){var t;return(t=app.vault.getConfig("showInlineTitle"))!=null?t:!0}static get readableLineLength(){var t;return(t=app.vault.getConfig("readableLineLength"))!=null?t:!0}};var ie=class{constructor(t,e,n){this.version="1.0";this.version=t,this.hint=e,this.encodedData=n}},fe=class{static async encode(t,e,n){let s=await C.BuildDefault().encryptToBase64(n,t);return new ie(fe.DEFAULT_VERSION,e,s)}static async decrypt(t,e){return t.encodedData==""?"":await C.BuildFromFileDataOrThrow(t).decryptFromBase64(t.encodedData,e)}},S=fe;S.DEFAULT_VERSION="2.0";var I=class{static encode(t){return JSON.stringify(t,null,2)}static decode(t){return t===""?new ie(S.DEFAULT_VERSION,"",""):JSON.parse(t)}};var k="encrypted";var q="meld-encrypted-file-content-view",se=class extends y.TextFileView{constructor(e,n){var i;super(e);this.iconReadingView="book-open";this.iconSourceView="code";this.iconToggleEditView="edit";this.iconLockFile="lock";this.iconChangePassword="key";this.currentView=0;this.encryptionPassword="";this.hint="";this.currentEditorSourceText="";this.settings=n,this.defaultEditNoteView=(i=n.defaultView)!=null?i:"Source",this.currentEditNoteMode=this.defaultEditNoteView,this.elActionEditView=this.addAction(this.iconSourceView,"Source",()=>this.actionToggleEditMode()),this.elActionReadingView=this.addAction(this.iconReadingView,"Reading",()=>this.actionToggleEditMode()),this.elActionIconLockNote=this.addAction(this.iconLockFile,"Lock",()=>this.actionLockFile()),this.elActionChangePassword=this.addAction(this.iconChangePassword,"Change Password",()=>this.actionChangePassword()),this.elActionEditView.hide(),this.elActionReadingView.hide(),this.elActionIconLockNote.hide(),this.elActionChangePassword.hide(),this.containerEl.classList.add("meld-encrypt-encrypted-note-view"),this.contentEl.classList.add("meld-encrypt-encrypted-note-view-content")}actionToggleEditMode(){this.currentView==2&&(this.currentEditNoteMode=="Reading"?this.currentEditNoteMode="Source":this.currentEditNoteMode=="Source"&&(this.currentEditNoteMode="Reading"),this.refreshView(2))}actionLockFile(){this.encryptionPassword="",g.clearForFile(this.file),this.refreshView(1)}actionChangePassword(){this.refreshView(3)}onPaneMenu(e,n){n=="tab-header"&&this.currentView==2&&(e.addItem(i=>{i.setSection("action").setIcon(this.iconToggleEditView).setTitle("Toggle Editing/Reading").onClick(()=>this.actionToggleEditMode())}),e.addItem(i=>{i.setSection("action").setIcon(this.iconLockFile).setTitle("Lock").onClick(()=>this.actionLockFile())}),e.addItem(i=>{i.setSection("action").setIcon(this.iconChangePassword).setTitle("Change Password").onClick(()=>this.actionChangePassword())})),super.onPaneMenu(e,n)}addHeader(e,n){var i;e.createDiv({text:`\u{1F510}${n}\u{1F510}`,cls:"encrypted-note-message"}),K.showInlineTitle&&e.createDiv({text:(i=this.file)==null?void 0:i.basename,cls:"inline-title"})}validatePassword(e){return""}validateConfirm(e,n){return e===n?"":"Password doesn't match"}addNewNoteView(e){this.addHeader(e,"This note will be encrypted");let n=this.addUserInputContainer(e);new y.Setting(n).setDesc("Please provide a password and hint to start editing this note.");let i=async(l,c,p)=>{let m=this.validatePassword(l),V=this.validateConfirm(l,c);h.setDesc(m),f.setDesc(V),m.length===0&&V.length===0&&(this.encryptionPassword=l,this.hint=p,K.showInlineTitle||(this.currentEditorSourceText=`#${this.file.basename}