"use strict";varCt=Object.create;varL=Object.defineProperty;var_t=Object.getOwnPropertyDescriptor;varTt=Object.getOwnPropertyNames;varDt=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;varFt=(p,n)=>{for(vartinn)L(p,t,{get:n[t],enumerable:!0})},pt=(p,n,t,e)=>{if(n&&typeofn=="object"||typeofn=="function")for(letsofTt(n))!St.call(p,s)&&s!==t&&L(p,s,{get:()=>n[s],enumerable:!(e=_t(n,s))||e.enumerable});returnp};varx=(p,n,t)=>(t=p!=null?Ct(Dt(p)):{},pt(n||!p||!p.__esModule?L(t,"default",{value:p,enumerable:!0}):t,p)),Mt=p=>pt(L({},"__esModule",{value:!0}),p);varHt={};Ft(Ht,{default:()=>K});module.exports=Mt(Ht);vary=require("obsidian"),b=x(require("path")),at=x(require("fs"));varX={pythonPath:"python",enablePlugins:!1,pluginArgs:[],docintelEndpoint:"",outputPath:"",imageExtractionEnabled:!1,imageSubfolderTemplate:"{filename}-images",enableBatchProgress:!0,enableContextMenu:!0,enableRecursiveConversion:!1,outputFilenameTemplate:"{filename}",enableDragDrop:!0,enableAutoFrontmatter:!1,autoTags:"",conversionHistory:[]};varM=x(require("fs"));varQ=require("child_process"),k=x(require("path")),Z=".venv",ct=["3.14","3.13","3.12","3.11","3.10","3.9"];functionut(p){letn=process.env.HOME||process.env.USERPROFILE||"",t=process.platform==="win32",e=t?";":":",s=[];t||s.push("/opt/homebrew/bin","/usr/local/bin"),n&&(s.push(k.join(n,".local","bin")),t||s.push(k.join(n,".pyenv","shims")));leta=process.env.PATH||"",o=[...s,a].filter(Boolean),l=newSet,r=o.filter(i=>l.has(i)?!1:(l.add(i),!0));return{...process.env,PYTHONUTF8:"1",PATH:r.join(e),...p}}functionIt(p){returnprocess.platform==="win32"?k.join(p,Z,"Scripts","python.exe"):k.join(p,Z,"bin","python")}function$t(p,n){lett=p.trim(),e=[];t&&e.push(t),e.push(It(n));lets=process.env.HOME||process.env.USERPROFILE||"",a=process.platform==="win32",o=[];if(process.env.PIPX_HOME&&o.push(process.env.PIPX_HOME),s)if(o.push(k.join(s,".local","pipx")),a){letr=process.env.LOCALAPPDATA||k.join(s,"AppData","Local");o.push(k.join(r,"pipx"))}elseprocess.platform==="darwin"?o.push(k.join(s,"Library","Application Support","pipx")):o.push(k.join(s,".local","share","pipx"));for(letrofo)a?e.push(k.join(r,"venvs","markitdown","Scripts","python.exe")):e.push(k.join(r,"venvs","markitdown","bin","python"));if(a){t==="python"?e.push("python3"):t==="python3"?e.push("python"):e.push("python","python3");letr=process.env.LOCALAPPDATA||"";if(r){for(letiof["314","313","312","311","310","39"])e.push(`${r}\\Programs\\Python\\Python${i}\\python.exe`);e.push(`${r}\\Microsoft\\WindowsApps\\python3.exe`)}}else{t==="python"?e.push("python3"):t==="python3"?e.push("python"):e.push("python3","python"),e.push("/opt/homebrew/bin/python3"),e.push("/usr/local/bin/python3");for(letrofct)e.push(`/opt/homebrew/bin/python${r}`),e.push(`/usr/local/bin/python${r}`),e.push(`/opt/homebrew/opt/python@${r}/bin/python3`),e.push(`/usr/local/opt/python@${r}/bin/python3`);for(letrofct)e.push(`/Library/Frameworks/Python.framework/Versions/${r}/bin/python3`);e.push("/usr/bin/python3")}letl=newSet;returne.filter(r=>!r||l.has(r)?!1:(l.add(r),!0))}functionO(p,n,t,e){returnnewPromise((s,a)=>{leto=(0,Q.spawn)(p,[n,...t],{shell:!1,env:ut(e),stdio:["ignore","pipe","pipe"]}),l="",r="";o.stdout.on("data",i=>{l+=i.toString()}),o.stderr.on("data",i=>{r+=i.toString()}),o.on("error",i=>{a(i)}),o.on("close",i=>{s({stdout:l.trim(),stderr:r.trim(),exitCode:i??1})})})}functionA(p,n){returnk.join(n,"python",p)}asyncfunctiontt(p,n){lett={pythonInstalled:!1,pythonVersion:null,markitdownInstalled:!1,markitdownVersion:null},e=[],s=p.trim();if(!s)returne.push({path:p||"(empty)",error:"Path is empty or whitespace-only"}),{status:t,resolvedPythonPath:p,triedPaths:e};leta=A("check_install.py",n),o=$t(s,n),l=null;for(letrofo)try{leti=awaitO(r,a,["--check","all"]);if(i.exitCode===0&&i.stdout){letc=JSON.parse(i.stdout),u={pythonInstalled:!0,pythonVersion:c.python_version??null,markitdownInstalled:!1,markitdownVersion:null};if(c.packages?.markitdown&&(u.markitdownInstalled=c.packages.markitdown.installed,u.mar
`);i=d.pop()??"";for(let m of d)m.trim()&&(c=m.trim(),e?.(m.trim()))}),r.stderr.on("data",u=>{let d=u.toString().split(`
---`,3);if(n===-1)return null;let t=p.substring(4,n).trim(),e=n+4,s=p.substring(e);return{yaml:t,body:s}}function Lt(p,n){let t=new Set;for(let a of p.split(`
`)),new C.Notice(r)}}onClose(){this.contentEl.empty()}};var _=require("obsidian"),Pt=x(require("path"));var q=class extends _.Modal{constructor(n,t){super(n),this.plugin=t}onOpen(){let{contentEl:n}=this;n.addClass("markitdown-modal"),n.createEl("h2",{text:"Convert URL to Markdown"}),n.createEl("p",{text:"Enter a URL to convert (e.g. YouTube):"});let e=n.createDiv("markitdown-url-input-container").createEl("input",{attr:{type:"url",placeholder:"https://www.youtube.com/watch?v=..."}});e.style.width="100%";let a=n.createDiv("markitdown-button-container").createEl("button",{text:"Convert",cls:"mod-cta"});a.addEventListener("click",async()=>{let o=e.value.trim();if(!o){new _.Notice("Please enter a URL");return}if(!o.startsWith("http://")&&!o.startsWith("https://")){new _.Notice("URL must start with http:// or https://");return}a.disabled=!0,a.setText("Converting...");try{let l=P(this.app);if(!l){new _.Notice("Could not determine vault path. This plugin requires a local vault."),a.disabled=!1,a.setText("Convert");return}let r=E(l,this.plugin.settings.outputPath),i=this.deriveFilename(o),c=Pt.join(r,`${i}.md`),u=this.plugin.buildConversionOptions(c),d=await this.plugin.converter.convertUrl(o,c,u);d.success?(new _.Notice("URL converted successfully"),this.close(),await this.plugin.openConvertedFile(c,l)):(new _.Notice(`Conversionfailed:${d.error}`),a.disabled=!1,a.setText("Convert"))}catch(l){let r=l instanceof Error?l.message:String(l);new _.Notice(`Error:${r}`),a.disabled=!1,a.setText("Convert")}})}deriveFilename(n){try{let t=new URL(n);if(t.hostname==="www.youtube.com"||t.hostname==="youtube.com"||t.hostname==="m.youtube.com"){let s=t.searchParams.get("v");if(s)return`youtube-${s}`}if(t.hostname==="youtu.be"){let s=t.pathname.slice(1);if(s)return`youtube-${s}`}return`${t.hostname}${t.pathname}`.replace(/[^a-zA-Z0-9._-]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"")||"url-conversion"}catch{return`url-${Date.now()}`}}onClose(){this.contentEl.empty()}};var J=require("obsidian"),z=class extends J.Modal{constructor(n,t){super(n),this.plugin=t}onOpen(){let{contentEl:n}=this;n.addClass("markitdown-modal"),n.createEl("h2",{text:"Conversion history"});let t=this.plugin.settings.conversionHistory;if(t.length===0){n.createEl("p",{text:"No conversions have been recorded yet.",cls:"markitdown-history-empty"});return}let e=n.createDiv("markitdown-history-list");for(let o of t)this.renderEntry(e,o);n.createDiv("markitdown-button-container").createEl("button",{text:"Clear history",cls:"markitdown-history-clear-btn"}).addEventListener("click",async()=>{this.plugin.settings.conversionHistory=[],await this.plugin.saveSettings(),new J.Notice("Conversion history cleared"),this.close()})}renderEntry(n,t){let e=n.createDiv("markitdown-history-entry"),s=e.createDiv("markitdown-history-entry-header"),a=new Date(t.timestamp);s.createSpan({text:a.toLocaleString(),cls:"markitdown-history-timestamp"});let o=t.success?"markitdown-history-badge-success":"markitdown-history-badge-fail";s.createSpan({text:t.success?"Success":"Failed",cls:`markitdown-history-badge${o}`});let l=t.inputFile.split("/").pop()?.split("\\").pop()??t.inputFile;e.createDiv({text:l,cls:"markitdown-history-filename"});let r=[];t.processingTimeMs!==void 0&&r.push(`${t.processingTimeMs}ms`),t.imagesExtracted!==void 0&&t.imagesExtracted>0&&r.push(`${t.imagesExtracted}image${t.imagesExtracted!==1?"s":""}extracted`),r.length>0&&e.createDiv({text:r.join(" \xB7 "),cls:"markitdown-history-details"}),!t.success&&t.error&&e.createDiv({text:t.error,cls:"markitdown-history-error"})}onClose(){this.contentEl.empty()}};var G=require("obsidian"),F=class extends G.Modal{constructor(n,t){super(n),this.plugin=t}onOpen(){let{contentEl:n}=this;if(n.addClass("markitdown-modal"),n.createEl("h2",{text:"Markitdown setup"}),!this.plugin.dependencyStatus.pythonInstalled){this.showPythonNotFound(n);return}if(this.plugin.dependencyStatus.markitdownInstalled){this.showAlreadyInstalled(n);return}this.showInstallPrompt(n)}showPythonNotFound(n){n.createEl("p",{text:"Python is not installed or not found at the c