vark7=Object.create;vartv=Object.defineProperty;varS7=Object.getOwnPropertyDescriptor;varD7=Object.getOwnPropertyNames;varI7=Object.getPrototypeOf,P7=Object.prototype.hasOwnProperty;varLN=r=>{throwTypeError(r)};varF7=(r,e,t)=>einr?tv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;varb=(r,e,t)=>()=>{if(t)throwt[0];try{returnr&&(e=r(r=0)),e}catch(n){throwt=[n],n}};varM7=(r,e)=>()=>{try{returne||r((e={exports:{}}).exports,e),e.exports}catch(t){throwe=0,t}},Zr=(r,e)=>{for(vartine)tv(r,t,{get:e[t],enumerable:!0})},BN=(r,e,t,n)=>{if(e&&typeofe=="object"||typeofe=="function")for(letiofD7(e))!P7.call(r,i)&&i!==t&&tv(r,i,{get:()=>e[i],enumerable:!(n=S7(e,i))||n.enumerable});returnr};varUN=(r,e,t)=>(t=r!=null?k7(I7(r)):{},BN(e||!r||!r.__esModule?tv(t,"default",{value:r,enumerable:!0}):t,r)),R7=r=>BN(tv({},"__esModule",{value:!0}),r);varle=(r,e,t)=>F7(r,typeofe!="symbol"?e+"":e,t),nI=(r,e,t)=>e.has(r)||LN("Cannot "+t);varH=(r,e,t)=>(nI(r,e,"read from private field"),t?t.call(r):e.get(r)),it=(r,e,t)=>e.has(r)?LN("Cannot add the same private member more than once"):einstanceofWeakSet?e.add(r):e.set(r,t),et=(r,e,t,n)=>(nI(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),xt=(r,e,t)=>(nI(r,e,"access private method"),t);varP2,F2,M2=b(()=>{P2=r=>{lete,t=newSet,n=(c,u)=>{letd=typeofc=="function"?c(e):c;if(!Object.is(d,e)){letf=e;e=u??(typeofd!="object"||d===null)?d:Object.assign({},e,d),t.forEach(p=>p(e,f))}},i=()=>e,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(t.add(c),()=>t.delete(c))},l=e=r(n,i,a);returna},F2=(r=>r?P2(r):P2)});functionRv(r){if(r.kind)returnr.kind;lete=(r.name??"").toLowerCase(),t=JX(r.endpoint),n=i=>t===i||t.endsWith(`.${i}`);returne==="anthropic"||n("api.anthropic.com")?"anthropic":e==="gemini"||n("generativelanguage.googleapis.com")?"gemini":"openai"}functionJX(r){lete=(r??"").trim();if(!e)return"";for(lettof[e,`https://${e}`])try{returnnewURL(t).hostname.toLowerCase()}catch{}return""}functioneQ(r){returnr.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}functiondT(r,e){lett=eQ(r),n=newSet(e.map(o=>o.id).filter(o=>!!o)),i=t;for(leto=2;n.has(i);o++)i=`${t}-${o}`;returni}functionpT(r){lete=!1,t=newSet;for(letnofr){if(n.id&&!t.has(n.id)){t.add(n.id);continue}n.id=dT(n.id??n.name,r),t.add(n.id),e=!0}returne}functionmu(r,e){returne&&e.name===r?e:void0}functionfT(r){return$v[r].map(e=>({...e}))}var$v,R2,tQ,rQ,mT,es=b(()=>{$v={openai:[{name:"gpt-5.5",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4-mini",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4-nano",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-4.1",maxTokens:1047576,maxOutputTokens:32768,supportsTemperature:!0},{name:"gpt-4.1-mini",maxTokens:1047576,maxOutputTokens:32768,supportsTemperature:!0},{name:"gpt-4o",maxTokens:128e3,maxOutputTokens:16384,supportsTemperature:!0},{name:"gpt-4o-mini",maxTokens:128e3,maxOutputTokens:16384,supportsTemperature:!0},{name:"o3",maxTokens:2e5,maxOutputTokens:1e5,supportsTemperature:!1},{name:"o4-mini",maxTokens:2e5,maxOutputTokens:1e5,supportsTemperature:!1}],google:[{name:"gemini-3.5-flash",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3.1-pro-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3.1-flash-lite",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3-pro-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3-flash-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-pro",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-flash",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-flash-lite",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0}],anthropic:[{name:"claude-fable-5",maxTokens:1e6,maxO
`)}function Nv(r){let e=Object.entries(r);if(e.length===0)return[];let n=["t","tm","yd"].map(s=>{let a=r[s];return a?[s,a]:null}).filter(s=>s!==null),i=new Set(n.map(([s])=>s)),o=e.filter(([s])=>!i.has(s)).sort((s,a)=>{let l=s[0].length-a[0].length;return l!==0?l:s[0].localeCompare(a[0])});return[...n,...o]}function hT(r){return Nv(r).map(([e,t])=>`${e}=${t}`).join(", ")}var Kf,Wd=b(()=>{Kf={t:"today",tm:"tomorrow",yd:"yesterday",nw:"next week",nm:"next month",ny:"next year",lw:"last week",lm:"last month",ly:"last year"}});var gT,a0=b(()=>{es();Wd();gT={choices:[],inputPrompt:"single-line",persistInputPromptDrafts:!0,useSelectionAsCaptureValue:!0,searchNestedChoices:!0,templateFolderLauncherRow:"bottom",devMode:!1,templateFolderPaths:[],announceUpdates:"major",version:"0.0.0",globalVariables:{},onePageInputEnabled:!1,disableOnlineFeatures:!0,enableUriCallbacks:!1,enableRibbonIcon:!1,showCaptureNotification:!0,showInputCancellationNotification:!1,enableTemplatePropertyTypes:!1,dateAliases:Kf,ai:{defaultModel:"Ask me",defaultSystemPrompt:'As an AI assistant within Obsidian, your primary goal is to help users manage their ideas and knowledge more effectively. Format your responses using Markdown syntax. Please use the [[Obsidian]] link format. You can write aliases for the links by writing [[Obsidian|the alias after the pipe symbol]]. To use mathematical notation, use LaTeX syntax. LaTeX syntax for larger equations should be on separate lines, surrounded with double dollar signs ($$). You can also inline math expressions by wrapping it in $ symbols. For example, use $$w_{ij}^{\\text{new}}:=w_{ij}^{\\text{current}}+\\eta\\cdot\\delta_j\\cdot x_{ij}$$ on a separate line, but you can write "($\\eta$ = learning rate, $\\delta_j$ = error term, $x_{ij}$ = input)" inline.',promptTemplatesFolderPath:"",showAssistant:!0,providers:mT,confirmToolCalls:"destructive"},migrations:{migrateToMacroIDFromEmbeddedMacro:!0,useQuickAddTemplateFolder:!1,incrementFileNameSettingMoveToDefaultBehavior:!1,consolidateFileExistsBehavior:!1,repairTemplateFileExistsBehavior:!1,mutualExclusionInsertAfterAndWriteToBottomOfFile:!1,setVersionAfterUpdateModalRelease:!1,addDefaultAIProviders:!1,removeMacroIndirection:!1,migrateFileOpeningSettings:!1,backfillFileOpeningDefaults:!1,setProviderModelDiscoveryMode:!1,migrateProviderApiKeysToSecretStorage:!1,migrateToMultipleTemplateFolders:!1,refreshStaleDefaultModelSeeds:!1,pinAiModelRefs:!1}}});function ht(r){if(typeof structuredClone=="function")try{return structuredClone(r)}catch{}return hu(r,new Map)}function hu(r,e){if(r===null||typeof r!="object")return r;if(e.has(r))return e.get(r);if(r instanceof Date){let i=new Date(r.getTime());return e.set(r,i),i}if(Array.isArray(r)){let i=[];e.set(r,i);for(let o of r)i.push(hu(o,e));return i}if(r instanceof Map){let i=new Map;e.set(r,i);for(let[o,s]of r.entries())i.set(hu(o,e),hu(s,e));return i}if(r instanceof Set){let i=new Set;e.set(r,i);for(let o of r.values())i.add(hu(o,e));return i}if(r instanceof RegExp){let i=new RegExp(r.source,r.flags);return i.lastIndex=r.lastIndex,e.set(r,i),i}if(r instanceof ArrayBuffer){let i=r.slice(0);return e.set(r,i),i}if(ArrayBuffer.isView(r)){if(r instanceof DataView){let a=new DataView(hu(r.buffer,e),r.byteOffset,r.byteLength);return e.set(r,a),a}let i=r,o=hu(i.buffer,e),s=new i.constructor(o,i.byteOffset,i.length);return e.set(r,s),s}let t=Object.getPrototypeOf(r),n=Object.create(t);e.set(r,n);for(let[i,o]of Object.entries(r))Object.defineProperty(n,i,{value:hu(o,e),writable:!0,enumerable:!0,configurable:!0});return n}var vi=b(()=>{});var ce,It=b(()=>{M2();a0();vi();ce=(()=>{let r=F2((i,o)=>({...ht(gT)})),{getState:e,setState:t,subscribe:n}=r;return{getState:e,replaceState:i=>t(i,!0),setState:t,subscribe:n}})()});var zd,Lv,F,Me=b(()=>{zd=class zd{register(e){return zd.loggers.push(e),this}logError(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=e instanceof Error?e:void 0;zd.loggers.forEach(o=>o.logError(t,n,i))}logWarning(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=
`)?`${r}${e}`:`${r}
${e}`}asyncfunctionkT(r,e,t){letn=t.destination;if(n?.type!=="specifiedFile")return!1;leti=zv(r,n);if(!i)thrownewError(`Append link target file not found or is not a Markdown file: ${n.path}`);leto=AT(r,e,{sourcePath:i.path,linkType:"link"});returnawaitr.vault.process(i,s=>PQ(s,o)),!0}asyncfunctionFQ(r){lete=window.navigator?.clipboard;if(!e?.writeText)returnF.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{returnawaite.writeText(r),!0}catch(t){returnF.logMessage(`QuickAdd: Could not copy link to clipboard: ${tinstanceofError?t.message:String(t)}`),!1}}asyncfunctionST(r){lete=IQ(r);returnawaitFQ(e)?(newWv.Notice(`Copied link to '${r.basename}' to clipboard.`,EB),!0):(newWv.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,EB),!1)}varWv,EB,Hv=b(()=>{Wv=require("obsidian");Me();Jd();EB=4e3});functionts(r){if(r.nodeType===Node.DOCUMENT_NODE)returnr;lete=r.ownerDocument;if(!e)thrownewError("Unable to resolve owner document for DOM node.");returne}functionep(r){lete=ts(r).defaultView;if(!e)thrownewError("Unable to resolve owner window for DOM node.");returne}functionzr(r,e){returnts(r).createElement(e)}functionjv(r,e){returnts(r).createTextNode(e)}varfc=b(()=>{});functionDT(r){for(leteofr.workspace.getLeavesOfType("markdown")){lett=e.view;if(!(!t.containerEl||!t.file||t.file.extension!=="md"))try{letn=ts(t.containerEl).activeElement;if(!n||!t.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(MQ))continue;leto=n.closest(".metadata-property")?.getAttribute("data-property-key");if(!o)continue;return{file:t.file,key:o}}catch{continue}}returnnull}functionRQ(r,e,t){letn=e.trim();if(!n)thrownewError("Cannot append link to an empty frontmatter property key.");leti=kB(r,n),o=r[i];if(Array.isArray(o)){o.push(t);return}if(o==null||o===""){r[i]=t;return}if(typeofo=="string"){r[i]=`${o}${t}`;return}thrownewError(`Cannot append link to frontmatter property '${i}' because it contains a ${typeofo} value.`)}functionAB(r,e,t,n=Qd){leti=e.trim();if(!i)thrownewError("Cannot append link to an empty frontmatter property key.");leto=kB(r,i),s=r[o];if(Array.isArray(s)){s.push(t);return}if(s===null||s===""){r[o]=[t];return}if(s===void0){if(n==="error")thrownewError(`Cannot append link to frontmatter property '${o}' because it does not exist.`);r[o]=[t];return}if(typeofs=="object")thrownewError(`Cannot append link to frontmatter property '${o}' because it contains an object value.`);if(n!=="alwaysAppend")thrownewError(`Cannot append link to frontmatter property '${o}' because it is not a list and the link-handling mode is '${TB[n]}'. Choose '${TB.alwaysAppend}' to convert it into a list and append.`);r[o]=[s,t]}functionkB(r,e){lett=_B(e),n=Object.keys(r).filter(i=>_B(i)===t);if(n.length>1)thrownewError(`Cannot append link to frontmatter property '${e}' because the note has multiple properties that normalize to that key.`);returnn[0]??e}function_B(r){returnr.trim().toLowerCase()}asyncfunctionIT(r,e,t){letn=r.fileManager.generateMarkdownLink(t,e.file.path);try{returnawaitr.fileManager.processFrontMatter(e.file,i=>{RQ(i,e.key,n)}),!0}catch(i){returnF.logError(`QuickAdd: created the file but could not append the link to frontmatter property '${e.key}' in '${e.file.path}': ${iinstanceofError?i.message:String(i)}`),!1}}varTB,MQ,nm=b(()=>{Me();Jd();fc();TB={alwaysAppend:"Create or convert",createProperty:"Create if missing",error:"Require list"},MQ=['input[type="number"]','input[type="date"]','input[type="datetime-local"]','input[type="time"]','input[type="month"]','input[type="checkbox"]'].join(", ")});functionGv(r,e){lett=On(r);returnt?.file?.path===e.path?t:null}functionk0(r,e){try{lett=On(e);returnt?(t.editor.replaceSelection(r),!0):(F.logError(`unable to append '${r}' to current line.`),!1)}catch{returnF.logError(`unable to append '${r}' to current line.`),!1}}functionS0(r,e,t){try{letn=On(t);if(!n)returnF.logError(`unable to insert '${r}' on new line ${e}.`),!1;leti=n.editor,s=
`+r,{line:s,ch:u.length}),i.setCursor({line:s+l,ch:c})}return!0}catch{return F.logError(`unabletoinsert'${r}'onnewline${e}.`),!1}}function D0(r,e){return S0(r,"above",e)}function I0(r,e){return S0(r,"below",e)}function $Q(r,e,t,n){let i=l=>r.posToOffset(l),o=e.map(l=>{let[c,u]=i(l.anchor)<=i(l.head)?[l.anchor,l.head]:[l.head,l.anchor];return{from:c,to:u,text:n(r.getRange(c,u))}}).sort((l,c)=>i(l.from)-i(c.from)),s=o.map(({from:l,to:c,text:u})=>t==="replaceSelection"?{from:l,to:c,text:u}:{from:c,text:u}),a=[];if(t==="replaceSelection"){let l=0;for(let{from:c,to:u,text:d}of o)a.push(i(c)+l+d.length),l+=d.length-(i(u)-i(c))}r.transaction({changes:s}),t==="replaceSelection"&&r.setSelections(a.map(l=>({anchor:r.offsetToPos(l)})))}async function SB(r,e,t="replaceSelection",n={}){let{requireActiveView:i=!0,frontmatterProperty:o,frontmatterHandling:s=Qd,textForSelection:a}=n,l=r.workspace.getActiveViewOfType(PT.MarkdownView);if(!l){let p="Cannot append link because no active Markdown view is available.";if(i)throw new Error(p);F.logMessage(p);return}if(t==="inFrontmatter"){let p=l.file;if(!p)throw new Error("Cannot append link because the active Markdown view has no file.");await r.fileManager.processFrontMatter(p,m=>{AB(m,o??"",e,s)});return}let c=l.editor;if(!c){let p="Cannot append link because the active Markdown view has no editor.";if(i)throw new Error(p);F.logMessage(p);return}let u=c.listSelections().map(p=>({anchor:{...p.anchor},head:{...p.head}}));if(a&&u.length>0&&(t==="replaceSelection"||t==="afterSelection")){$Q(c,u,t,a);return}if(t==="replaceSelection"){c.replaceSelection(e);return}let d=({line:p,ch:m})=>c.posToOffset({line:p,ch:m}),f=u.sort((p,m)=>d(m.head)-d(p.head));for(let p of f){let m=d(p.anchor)>d(p.head)?p.anchor:p.head;switch(t){case"afterSelection":{c.replaceRange(e,m);break}case"endOfLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length};c.replaceRange(e,g);break}case"newLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length},w=v.length===0?"":`
`;c.replaceRange(w+e,g);break}}}}async function tp(r,e,t){if(!t?.enabled)return!1;let n=xu(t),i=r.workspace.getActiveViewOfType(PT.MarkdownView),o=n.placement!=="inFrontmatter";if(!i||!i.file||o&&!i.editor){if(t.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let s=i.file.path,a=AT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement}),l=n.displayText==="selection"?c=>AT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement,alias:c}):void 0;return await SB(r,a,n.placement,{requireActiveView:!1,frontmatterProperty:n.frontmatterProperty,frontmatterHandling:n.frontmatterHandling,textForSelection:l}),!0}function P0(r,e,t,n){try{if(e.extension!=="md"||!Number.isSafeInteger(t)||t<0||t>n.length)return!1;let i=r.workspace.getActiveViewOfType(PT.MarkdownView);if(!i||i.file?.path!==e.path||i.getMode()==="preview")return!1;let o=i.editor;return!o||o.getValue()!==n?!1:(o.setCursor(o.offsetToPos(t)),!0)}catch{return F.logMessage(`Unabletoplacecursoraftercapturein'${e.path}'.`),!1}}var PT,DB=b(()=>{PT=require("obsidian");Cu();Me();Jd();Hv();nm()});function FT(r){return ir.test(r)||qr.test(r)||Vi.test(r)}function po(r,e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let n=FT(t)?t:`${t}.md`,i=r.vault.getAbstractFileByPath(n);return i instanceof IB.TFile?i:null}function Wi(r){if(!Array.isArray(r))return[];let e=new Set,t=[];for(let n of r){if(typeof n!="string")continue;let i=n.trim().replace(/^\/+/,"").replace(/\/+$/,"");!i||e.has(i)||(e.add(i),t.push(i))}return t}function F0(r,e){return e.length===0?!0:e.some(t=>r===t||r.startsWith(`${t}/`))}var IB,MT=b(()=>{IB=require("obsidian");Tt()});function FB(r){if(!r)return!1;let e=r,t=e.getViewState?.();return!!e.pinned||!!t?.pinned||!!t?.state?.pinned}function Yv(r){let e=r.workspace;return(e.rootSplit?e.getMostRecentLeaf?.(e.rootSplit):null)??e.getMostRecentLeaf?.()??null}function OQ(r){let e=[];return r.workspace.iterateRootLeaves(t=>{e.includes(t)||e.push(t)}),e}function PB(r){return r.parent?.id??r.parent??null}function NQ(r,e){let t=PB(e),n=r.filter(s=>s===e||FB(s)?!1:t===null||PB(s)!==t);if(n.length===0)return null;let i=r.indexOf(e);return(i===-1?r:[...r.slice(i+1),...r.slice(0,i)]).find(s=>n.includes(s))??n[0]}function LQ(r){return r instanceof im.TFile?!0:typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"&&"extension"in r&&typeof r.extension=="string"}function BQ(r,e,t,n){if(n&&(e==="tab"||e==="reuse")&&FB(n))return NQ(OQ(r),n)??r.workspace.getLeaf("tab");switch(e){case"reuse":return r.workspace.getLeaf(!1);case"tab":return r.workspace.getLeaf("tab");case"split":return r.workspace.getLeaf("split",t);case"window":return r.workspace.getLeaf("window");case"left-sidebar":return r.workspace.getLeftLeaf(!0);case"right-sidebar":return r.workspace.getRightLeaf(!0);default:return r.workspace.getLeaf("tab")}}async function mc(r,e,t={}){let{location:n="tab",direction:i="vertical",mode:o,focus:s=!0,eState:a,originLeaf:l}=t,c=typeof e=="string"?r.vault.getAbstractFileByPath(e):e;if(!LQ(c)){let f=typeof e=="string"?e:e.path;throw new Error(`Filenotfound:${f}`)}let u=l??Yv(r),d=BQ(r,n,i,u);if(!d)throw new Error("Could not obtain a workspace leaf.");if(await d.openFile(c),o&&o!=="default"&&!(typeof o=="object"&&o.mode==="default")){let f=d.getViewState(),p={...f.state??{}};o==="preview"||typeof o=="object"&&o.mode==="preview"?(p.mode="preview",delete p.source):o==="source"?(p.mode="source",p.source=!0):o==="live"||o==="live-preview"?(p.mode="source",p.source=!1):typeof o=="object"&&o.mode==="source"&&(p.mode="source",p.source=o.source),await d.setViewState({...f,state:{...p,...a}})}return s&&r.workspace.setActiveLeaf(d,{focus:!0}),d}function M0(r){return(0,im.normalizePath)(r).replace(/\/{2,}/g,"/").replace(/^\/+/,"")}function MB(r,e){return M0(r)===M0(e)}function rp(r,e,t=!0){let n;return r.workspace.iterateRootLeaves(i=>{let o=i.view;if(o instanceof im.FileView&&o.file&&(o.file===e||MB(e.path,o.file.path))){n=i;return}}),n!==void 0?(t&&r.workspace.setActiveLeaf(n,{focus:!0}),n):null}var im,R
`.repeat(e)+r}}varUQ,VQ,qQ,Kv=b(()=>{UQ=/^ {0,3}(`{3,})(.*)$/,VQ="No ```js (or ```javascript) code block found in the note.",qQ="The ```js code block is empty."});functionOB(r){returnrinstanceofRT}functionzQ(r){returnr.charCodeAt(0)===65279?r.slice(1):r}functionHQ(r){returnzQ(r).trimStart().slice(0,WQ).toLowerCase()}functionjQ(r){return/^<(?:!doctype\s+html|html\b|head\b|body\b|script\b|meta\b|title\b|div\b)/.test(HQ(r))}functionR0(r,e){lett=newRT(r);throwe.reportLoadErrors!==!1&<(t),t}functionGQ(r){return`QuickAdd could not load ${r}. This file looks like a saved webpage, not a JavaScript file. Open the script on GitHub, use the Raw button, then download the .js file and select that file in QuickAdd.`}functionYQ(r){return`QuickAdd loaded ${r}, but its default export is not a function. Change it to module.exports = async (params) => { ... } or exports.default = async (params) => { ... }. If you meant to export several functions, use module.exports = { run } and select Script::run.`}functionKQ(r,e){lett=e?`the required module "${e}"`:"a required module";return`QuickAdd could not load ${r} because it could not find ${t}. Check that the required file or package exists, and that the capitalization in require(...) matches the file name exactly.`}functionXQ(r){returnNB(r)?(rinstanceofError?r.message:String(r)).match(/Cannot find module ['"]([^'"]+)['"]/)?.[1]:void0}functionNB(r){return!r||typeofr!="object"?!1:r.code==="MODULE_NOT_FOUND"?!0:(rinstanceofError?r.message:String(r)).includes("Cannot find module")}functionQQ(r){returnr!==null&&typeofr=="object"}functionZQ(r){returntypeofr.entry=="function"?!0:Object.entries(r).some(([e,t])=>e!=="settings"&&e!=="quickadd"&&typeoft=="function")}functionJQ(r){returntypeofr=="function"?!0:QQ(r)?ZQ(r):!1}functionnp(r){lete=r.split("::").map(t=>t.trim()).filter(Boolean);return{basename:e[0],memberAccess:e.slice(1)}}functionOT(r){lete=r.path??r.id;if(e===void0)return;let{memberAccess:t}=np(r.name??"");returnt&&t.length>0?`${e}::${t.join("::")}`:e}asyncfunctionAa(r,e,t={}){letn=e.vault.getAbstractFileByPath(r.path);if(!n){F.logError(`failed to load file ${r.path}.`);return}if(ninstanceof$T.TFile){leti=m=>window.require&&window.require(m),o={},s={exports:o},a=awaite.vault.read(n),l=a;if(ir.test(n.path)){let{code:m,error:v}=hc(a);if(m===null||m.length===0){t.reportLoadErrors!==!1&&new$T.Notice(`QuickAdd: ${v} (${r.path})`);return}l=m}jQ(l)&&R0(GQ(r.path),t);try{newFunction("require","module","exports",l)(i,s,o)}catch(m){throwNB(m)&&R0(KQ(r.path,XQ(m)),t),m}letc=o.default||s.exports;if(!c)return;letu=c,d=!!o.default,{memberAccess:f}=np(r.name),p=!!(f&&f.length>0);if(f&&f.length>0){letm;for(;m=f.shift();)u=u[m]}returnd&&!p&&!JQ(u)&&R0(YQ(r.path),t),u}}var$T,WQ,RT,NT=b(()=>{$T=require("obsidian");Tt();Me();Kv();Cr();WQ=1024,RT=classextendsError{constructor(e){super(e),this.name="UserScriptLoadError"}}});functiongc(r){if(r==null||typeofr!="string"&&typeofr!="number"&&typeofr!="boolean")return"";lete=String(r).trim();returne.startsWith("#")?e.substring(1).trim():e}functionEu(r){returnr==null?[]:(Array.isArray(r)?r:typeofr=="string"?r.split(/,|\s+/):[r]).map(gc).filter(Boolean)}varLT=b(()=>{});varzi,ip=b(()=>{LT();zi=class{staticfilterFiles(e,t,n){leti=e;returni=this.applyInclusionFilters(i,t,n),i=this.applyExclusionFilters(i,t,n),i}staticapplyInclusionFilters(e,t,n){leti=!1,o=e,s=this.getIncludeFolders(t);returns.length>0&&(i=!0,o=o.filter(a=>s.some(l=>this.matchesFolder(a,l)))),t.tags&&t.tags.length>0&&(i=!0,o=o.filter(a=>this.matchesAllTags(a,t.tags??[],n))),i?o:e}staticapplyExclusionFilters(e,t,n){returne.filter(i=>!(t.excludeFolders&&t.excludeFolders.length>0&&t.excludeFolders.some(o=>this.matchesFolder(i,o))||t.excludeTags&&t.excludeTags.length>0&&this.matchesAnyTag(i,t.excludeTags,n)||t.excludeFiles&&t.excludeFiles.length>0&&t.excludeFiles.some(o=>this.matchesFile(i,o))))}staticgetIncludeFolders(e){lett=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...newSet(t.map(n=>this.normalizePath(n)).filter
`:" "))}catch(m){F.logError(`Failedtoinsertpastedimagelink:${minstanceofError?m.message:String(m)}`),new m_.Notice("QuickAdd: saved the pasted image but could not insert its link.")}}return e.addEventListener("paste",c),e.addEventListener("compositionstart",a),e.addEventListener("compositionend",l),{isBusy:()=>i!==null,whenIdle:()=>i??Promise.resolve(),detach:()=>{o=!0,e.removeEventListener("paste",c),e.removeEventListener("compositionstart",a),e.removeEventListener("compositionend",l)}}}function ree(r){let e=mV.then(r,r);return mV=e.catch(()=>{}),e}function hV(r){return Object.hasOwn(dy,r)}function nee(r){let e=[];for(let t of Array.from(r.items??[])){if(t.kind!=="file"||!hV(t.type))continue;let n=t.getAsFile();n&&e.push({file:n,mimeType:t.type})}if(e.length>0)return e;for(let t of Array.from(r.files??[]))hV(t.type)&&e.push({file:t,mimeType:t.type});return e}function iee(r,e){r.focus();let t=!1;try{t=r.ownerDocument.execCommand("insertText",!1,e)}catch{t=!1}if(t)return;let n=r.selectionStart??r.value.length,i=r.selectionEnd??n;r.setRangeText(e,n,i,"end"),r.dispatchEvent(new Event("input",{bubbles:!0}))}var m_,mV,h_=b(()=>{m_=require("obsidian");Me();MP();mV=Promise.resolve()});function RP(r){return!r.isComposing&&r.key==="Enter"&&r.shiftKey&&(r.ctrlKey||r.metaKey)}var km,Sr,zs=b(()=>{km=require("obsidian");SP();DP();IP();PP();FP();h_();Wr();Sr=class r extends km.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.isOptionalPrompt&&RP(t)){t.preventDefault(),this.skip();return}!t.isComposing&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new _m({kind:"single",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.display(),this.open(),this.fileSuggester=new xm(t,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Em(t,this.inputComponent.inputEl)}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,d_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}get isOptionalPrompt(){return this.options?.optional===!0}createInputField(t,n,i){let o=new km.TextComponent(t);return o.inputEl.setCssStyles({width:"100%"}),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.options?.imagePaste&&(this.imagePasteHandle=Am(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new km.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}createButtonBar(t){let n=t.createDiv();if(this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let i=this.createButton(n,"Skip",this.skipClickCallback);i.setTooltip("Leave this field empty"),i.buttonEl.setAttribute("aria-label","Skip and leave empty")}n.setCssStyles({display:"flex",flexDirection:"row-reverse",justifyContent:"flex-start",marg
${e}`:""}`});function NO(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void 0}}function MO(r){let e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=Date.now();return ea.push({...r,modelOptions:{...r.modelOptions??{}},id:e,createdAt:t,status:"pending"}),B4(),e}function Ix(r,e){let t=ea.find(n=>n.id===r);t&&(t.status=e.status,t.durationMs=e.durationMs,t.usage=e.usage,t.errorMessage=e.errorMessage,B4())}function L4(r=10){Number.isFinite(r)||(r=10);let e=Math.floor(r);return e<=0?[]:ea.slice(-e).map(NO).reverse()}function B4(){if(ea.length<=O4)return;let r=ea.length-O4;for(;r>0;){let e=ea.findIndex(t=>t.status!=="pending");if(e===-1)break;ea.splice(e,1),r-=1}}function U4(r){let e=ea.find(t=>t.id===r);return e?NO(e):null}function V4(){let r=ea[ea.length-1];return r?NO(r):null}function q4(){ea.splice(0,ea.length)}async function tme(r,e,t){if(typeof r!="function")throw new TypeError("Callback must be a function.");if(!(e instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");if(typeof t!="number"||t<=0)throw new TypeError("Interval must be a positive number.");let n=!1;for(e.then(()=>{n=!0},()=>{n=!0});!n;)r(),await sleep(t)}function rme(r){return r instanceof Error?r:new Error(String(r))}async function nme(r,e,t,n=!0,i){let o;if(e.enable)o=t.find(c=>c.path.endsWith(e.name));else{let c=t.map(u=>u.basename);if(i)o=await i.suggester(c,t,"Select a prompt template");else if(n)o=await Nr.Suggest(r,c,t);else throw new Ee("This AI command asks which prompt template to use, but this run is non-interactive. Enable a specific prompt template in the command, or re-run with the ui flag.")}Mi(o,"Prompt template does not exist");let s=o.path,a=r.vault.getAbstractFileByPath(s);Mi(a instanceof N4.TFile,`${s}isnotafile`);let l=await r.vault.cachedRead(a);return[o.basename,l]}async function W4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,promptTemplate:l,systemPrompt:c,promptTemplateFolder:u}=e,d=rs(r,u),[f,p]=await nme(r,l,d,e.interactive??!0,e.promptProvider);n.setMessage("waiting","QuickAdd is formatting the prompt template.");let m=await t(p),v=["prompting",`Usingprompttemplate"${f}".`];n.setMessage(v[0],v[1]);let y=SS(r,i,o,s,c,e.modelOptions)(m),x=(await LO(y,100,E=>{n.setMessage(v[0],`${v[1]}(${(E/1e3).toFixed(2)}s)`)},E=>{n.setMessage("finished",`Took${(E/1e3).toFixed(2)}s.`)})).content,C=("> "+x).replace(/\n/g,`
>`),_={[a]:x,[`${a}-quoted`]:C};return window.setTimeout(()=>n.hide(),5e3),_}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),Dt(i)?new St("Input cancelled by user"):i}}async function LO(r,e,t,n){let i=Date.now();return await tme(()=>t(Date.now()-i),r,e),n(Date.now()-i),await r}async function z4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,prompt:c,modelOptions:u}=e;n.setMessage("waiting","QuickAdd is formatting the prompt template.");let d=await t(c),f=["prompting","Using custom prompt."];n.setMessage(f[0],f[1]);let m=SS(r,i,o,s,l,u)(d),g=(await LO(m,100,x=>{n.setMessage(f[0],`${f[1]}(${(x/1e3).toFixed(2)}s)`)},x=>{n.setMessage("finished",`Took${(x/1e3).toFixed(2)}s.`)})).content,y=("> "+g).replace(/\n/g,`
`,". "," "],n=-1,i=Number.POSITIVE_INFINITY;for(let a of t){let l=r.lastIndexOf(a,e),c=r.indexOf(a,e),u=[l,c].filter(d=>d>0);for(let d of u){let f=d+a.length;if(f<=0||f>=r.length)continue;let p=Math.abs(f-e);p<i&&(i=p,n=f)}}if(n>0&&n<r.length)return[r.slice(0,n),r.slice(n)];let o=e,s=r.charCodeAt(o);return s>=56320&&s<=57343&&(o+=1),o<=0||o>=r.length?null:[r.slice(0,o),r.slice(o)]}function sme(r){let e=new RegExp(Hd.source,"gi"),t;for(;(t=e.exec(r))!==null;)if(t[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}function ame(r){return Rs.test(r)||vu.test(r)||pl.test(r)||dc.test(r)}function lme(r){return H4.some(e=>r.includes(e))}function cme(r){return H4.slice().sort((e,t)=>t.length-e.length).reduce((e,t)=>e.split(t).join(" "),r)}function G4(r){if(r>IS)throw new Error(`QuickAddwouldsplitthischunkedAIrequestintomorethan${IS}prompts,whichexceedsthesafetylimit.Increasethechunksize,usealargerchunkseparator,orreducetheinputtext.`)}function ume(r,e,t){let n=Math.max(1,Math.floor(e)),i=[r],o=0;for(;i.length>0;){let s=i.pop(),l=Uo(s)<=n?null:j4(s);if(!l){t.push(s),o+=1,G4(o);continue}i.push(l[1],l[0])}}function dme(r){let e=r.flags.replace(/[gy]/g,"");return new RegExp(r.source+"|",e).exec("").length-1}function fme(r,e){if(typeof e=="string"){let s=r.split(e);return{chunks:s,separators:new Array(Math.max(0,s.length-1)).fill(e)}}if(dme(e)>0||pme.test(e.source))return{chunks:r.split(e),separators:null};let t=new RegExp(`(${e.source})`,e.flags),n=r.split(t),i=[],o=[];for(let s=0;s<n.length;s++)s%2===0?i.push(n[s]):o.push(n[s]);return{chunks:i,separators:o}}function mme(r,e,t,n){let i=[];if(r.forEach((l,c)=>{let u=[];ume(l,t,u),u.forEach((d,f)=>{i.push({text:d,joiner:f===0&&c>0?e?.[c-1]??"":""})})}),!n)return i.map(l=>l.text);let o=[],s="",a=0;for(let l of i){let c=Uo(l.text)+Math.max(1,Uo(l.joiner));s!==""&&a+c>=t&&(o.push(s),s="",a=0),s+=s===""?l.text:l.joiner+l.text,a+=c}return s!==""&&o.push(s),o}function hme(r,e){let t=Math.max(1,Math.floor(r));if(e!==void 0&&Number.isFinite(e)&&e>0){let n=Math.floor(e);return{budget:Math.min(t,n),clamped:n>t}}return{budget:t,clamped:!1}}async function Y4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,promptTemplate:c,text:u,modelOptions:d}=e;n.setMessage("chunking","Creating prompt chunks with text and prompt template");let f=e.chunkSeparator||/\n/g,{chunks:p,separators:m}=fme(u,f),v=await t(c,{chunk:OO});if(!(sme(c)||ame(c)&&lme(v)))throw new Error("The chunked prompt template does not reference the chunk text. Add {{VALUE:chunk}} to your prompt template so each chunk is inserted.");let y=o.maxTokens,w=$G(y),x=cme(v),C=Uo(l)+Uo(x);if(C>=y)throw new Error(`Theestimatedpromptoverhead(${C}tokens)exceedsthemodel's entire context window (${y} tokens). Shorten the system prompt or prompt template, or use a model with a larger context window.`);let{budget:_,clamped:E}=hme(w-C,e.maxChunkTokens);E&&F.logMessage(`[ChunkedPrompt] Requested max chunk tokens (${e.maxChunkTokens}) exceeds this model'sestimatedinputbudget;using${_}estimatedtokensperchunkinstead.`);let D=e.shouldMerge??!0,P=mme(p,m,_,D);G4(P.length);let V=SS(r,i,o,s,l,d),j=["prompting",`${P.length}promptsbeingsent.`];n.setMessage(j[0],j[1]);let oe=new $O(5,1e3*30),se=!1,M=0,U=Promise.resolve(),q=ge=>{let be=U.then(()=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");return t(c,{chunk:ge})});return U=be.then(()=>{},()=>{}),be},B=async(ge,be=0)=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");let xe;try{xe=await q(ge)}catch(Ue){throw se=!0,Ue}try{return[(await oe.add(()=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");if(M+=1,M>IS)throw new Error(`ChunkedAIrequestexceededthesafetylimitof${IS}providerrequests.`);return V(xe)})).content]}catch(Ue){let $t=j4(ge);if(be>=ime||!$t||!mY(Ue))throw
> `),pe={[a]:X,[`${a}-quoted`]:ae};returnwindow.setTimeout(()=>n.hide(),5e3),pe}catch(i){thrown.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}varN4,O4,ea,$O,ime,IS,OO,H4,pme,DS=b(()=>{N4=require("obsidian");Wr();Co();Wc();It();qt();Sx();Cr();FO();Cx();RO();px();Me();Tt();O_();O4=25,ea=[];$O=class{constructor(e,t){this.maxRequests=e;this.intervalMs=t;this.queue=[];this.startTimes=[]}add(e){returnnewPromise((t,n)=>{this.queue.push(async()=>{try{t(awaite())}catch(i){n(rme(i))}}),this.schedule()})}schedule(){if(this.queue.length===0)return;lete=Date.now();if(this.startTimes=this.startTimes.filter(i=>e-i<this.intervalMs),this.startTimes.length>=this.maxRequests){leti=this.startTimes[0],o=Math.max(0,this.intervalMs-(e-i));window.setTimeout(()=>this.schedule(),o+1);return}lett=this.queue.shift();if(!t)return;this.startTimes.push(e);letn=t();window.setTimeout(()=>this.schedule(),this.intervalMs),this.schedule()}},ime=12,IS=500,OO="quickadd_chunk_probe_123456789";H4=ome();pme=/(?:^|[^\\])(?:\\\\)*\\[1-9]/});functionK4(r){returnr.normalize("NFKD").toLowerCase()}vargme,Qp,BO=b(()=>{gme=0;Qp=class{constructor(e,t){this.options=t;this.instanceId=++gme;this.indexedItems=[];this.renderedRows=[];this.query="";this.rootEl=document.createElement("div"),this.rootEl.className="qa-searchable-multi-select";letn=document.createElement("div");n.className="search-input-container qa-searchable-multi-select__search-container",this.searchInputEl=document.createElement("input"),this.searchInputEl.className="qa-searchable-multi-select__search",this.searchInputEl.type="search",this.searchInputEl.name=`qa-multi-select-search-${this.instanceId}`,this.searchInputEl.placeholder=t.searchPlaceholder??"Search options...",this.searchInputEl.setAttribute("aria-label",this.searchInputEl.placeholder),this.searchInputEl.setAttribute("autocomplete","off"),this.searchInputEl.setAttribute("spellcheck","false"),n.appendChild(this.searchInputEl),this.summaryEl=document.createElement("div"),this.summaryEl.className="qa-searchable-multi-select__summary",this.summaryEl.setAttribute("aria-live","polite"),this.listEl=document.createElement("div"),this.listEl.className="qa-searchable-multi-select__list",this.listEl.setAttribute("role","group"),this.listEl.setAttribute("aria-label","Options"),this.rootEl.append(n,this.summaryEl,this.listEl),e.appendChild(this.rootEl),this.searchInputEl.addEventListener("input",()=>{this.query=this.searchInputEl.value,this.renderList()}),this.searchInputEl.addEventListener("keydown",i=>{if(i.key==="ArrowDown"){i.preventDefault(),this.renderedRows[0]?.input.focus();return}if(i.key==="ArrowUp"){i.preventDefault(),this.renderedRows.at(-1)?.input.focus();return}i.key==="Escape"&&this.query&&(i.preventDefault(),i.stopPropagation(),this.query="",this.searchInputEl.value="",this.renderList())}),this.setItems(t.items)}setItems(e){this.indexedItems=e.map((t,n)=>({item:t,index:n,searchableText:K4(`${t.label}${t.searchText??""}`)})),this.searchInputEl.disabled=e.length===0,this.renderList()}focusSearchOnOpen(){document.body.classList.contains("is-mobile")||this.searchInputEl.focus()}refreshSelection(){for(let{item:e,input:t}ofthis.renderedRows)t.checked=this.options.isSelected(e),t.closest("label")?.classList.toggle("is-selected",t.checked);this.updateSummary()}getMatchingItems(){lete=K4(this.query.trim()).split(/\s+/).filter(Boolean);returne.length===0?this.indexedItems:this.indexedItems.filter(({searchableText:t})=>e.every(n=>t.includes(n)))}getVisibleItems(e){if(e.length<=200)returne;lett=[],n=[];for(letiofe)(this.options.isSelected(i.item)?t:n).push(i);return[...t,...n].slice(0,200)}renderList(){this.listEl.replaceChildren(),this.renderedRows=[];lete=this.getMatchingItems(),t=this.getVisibleItems(e);if(t.length===0){letn=document.createElement("div");n.className="qa-searchable-multi-select__empty",n.setAttribute("role","status"),n.textContent=this.indexedItems.length?`No options match \u201C${this.query.trim()}\u201D`:this.options.emptyText??"No options available",this.listEl.appendChild(n)}for(letno
`].join("");var N}function Ne(T){return T.flags!==void 0?T.flags:[T.global?"g":"",T.ignoreCase?"i":"",T.multiline?"m":"",T.unicode?"u":"",T.sticky?"y":""].join("")}function Ke(){for(var T=[].slice.call(arguments),k=T.length,N=0;N<k;N+=1)se(T[N]);return o(function(K,J){for(var ue,ve=new Array(k),Ve=0;Ve<k;Ve+=1){if(!(ue=V(T[Ve]._(K,J),ue)).status)return ue;ve[Ve]=ue.value,J=ue.index}return V(D(J,ve),ue)})}function Qe(){var T=[].slice.call(arguments);if(T.length===0)throw new Error("seqMap needs at least one argument");var k=T.pop();return q(k),Ke.apply(null,T).map(function(N){return k.apply(null,N)})}function ye(){var T=[].slice.call(arguments),k=T.length;if(k===0)return ut("zero alternates");for(var N=0;N<k;N+=1)se(T[N]);return o(function(K,J){for(var ue,ve=0;ve<T.length;ve+=1)if((ue=V(T[ve]._(K,J),ue)).status)return ue;return ue})}function We(T,k){return mt(T,k).or(Be([]))}function mt(T,k){return se(T),se(k),Qe(T,k.then(T).many(),function(N,K){return[N].concat(K)})}function He(T){B(T);var k="'"+T+"'";return o(function(N,K){var J=K+T.length,ue=N.slice(K,J);return ue===T?D(J,ue):P(K,k)})}function _e(T,k){(function(J){if(!(J instanceof RegExp))throw new Error("not a regexp: "+J);for(var ue=Ne(J),ve=0;ve<ue.length;ve++){var Ve=ue.charAt(ve);if(Ve!=="i"&&Ve!=="m"&&Ve!=="u"&&Ve!=="s")throw new Error('unsupported regexp flag "'+Ve+'": '+J)}})(T),arguments.length>=2?U(k):k=0;var N=(function(J){return RegExp("^(?:"+J.source+")",Ne(J))})(T),K=""+T;return o(function(J,ue){var ve=N.exec(J.slice(ue));if(ve){if(0<=k&&k<=ve.length){var Ve=ve[0],vt=ve[k];return D(ue+Ve.length,vt)}return P(ue,"valid match group (0 to "+ve.length+") in "+K)}return P(ue,K)})}function Be(T){return o(function(k,N){return D(N,T)})}function ut(T){return o(function(k,N){return P(N,T)})}function or(T){if(C(T))return o(function(k,N){var K=T._(k,N);return K.index=N,K.value="",K});if(typeof T=="string")return or(He(T));if(T instanceof RegExp)return or(_e(T));throw new Error("not a string, regexp, or parser: "+T)}function yr(T){return se(T),o(function(k,N){var K=T._(k,N),J=k.slice(N,K.index);return K.status?P(N,'not "'+J+'"'):D(N,null)})}function Pt(T){return q(T),o(function(k,N){var K=M(k,N);return N<k.length&&T(K)?D(N+1,K):P(N,"a character/byte matching "+T)})}function Ar(T,k){arguments.length<2&&(k=T,T=void 0);var N=o(function(K,J){return N._=k()._,N._(K,J)});return T?N.desc(T):N}function ur(){return ut("fantasy-land/empty")}s.parse=function(T){if(typeof T!="string"&&!E(T))throw new Error(".parse must be called with a string or Buffer as its argument");var k,N=this.skip(xo)._(T,0);return k=N.status?{status:!0,value:N.value}:{status:!1,index:oe(T,N.furthest),expected:N.expected},delete j[T],k},s.tryParse=function(T){var k=this.parse(T);if(k.status)return k.value;var N=$t(T,k),K=new Error(N);throw K.type="ParsimmonError",K.result=k,K},s.assert=function(T,k){return this.chain(function(N){return T(N)?Be(N):ut(k)})},s.or=function(T){return ye(this,T)},s.trim=function(T){return this.wrap(T,T)},s.wrap=function(T,k){return Qe(T,this,k,function(N,K){return K})},s.thru=function(T){return T(this)},s.then=function(T){return se(T),Ke(this,T).map(function(k){return k[1]})},s.many=function(){var T=this;return o(function(k,N){for(var K=[],J=void 0;;){if(!(J=V(T._(k,N),J)).status)return V(D(N,K),J);if(N===J.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");N=J.index,K.push(J.value)}})},s.tieWith=function(T){return B(T),this.map(function(k){if((function(J){if(!_(J))throw new Error("not an array: "+J)})(k),k.length){B(k[0]);for(var N=k[0],K=1;K<k.length;K++)B(k[K]),N+=T+k[K];return N}return""})},s.tie=function(){return this.tieWith("")},s.times=function(T,k){var N=this;return arguments.length<2&&(k=T),U(T),U(k),o(function(K,J){for(var ue=[],ve=void 0,Ve=void 0,vt=0;vt<T;vt+=1){if(Ve=V(ve=N._(K,J),Ve),!ve.status)return Ve;J=ve.index,ue.push(ve.value)}for(;vt<k&&(Ve=V(ve=N._(K,J),Ve),ve.status);vt+=1)J=ve.index,ue.push(ve.value);return V(D(J,ue),Ve)})},s.result=function(T){return t
`),Ka=He(`\r
`),Xa=ye(Ka,Ho,Tn).desc("newline"),Jc=ye(Xa,xo);o.all=Hn,o.alt=ye,o.any=Ft,o.cr=Tn,o.createLanguage=function(T){vark={};for(varNinT)({}).hasOwnProperty.call(T,N)&&(function(K){k[K]=Ar(function(){returnT[K](k)})})(N);returnk},o.crlf=Ka,o.custom=function(T){returno(T(D,P))},o.digit=xs,o.digits=jn,o.empty=ur,o.end=Jc,o.eof=xo,o.fail=ut,o.formatError=$t,o.index=dt,o.isParser=C,o.lazy=Ar,o.letter=re,o.letters=Ie,o.lf=Ho,o.lookahead=or,o.makeFailure=P,o.makeSuccess=D,o.newline=Xa,o.noneOf=function(T){returnPt(function(k){returnT.indexOf(k)<0}).desc("none of '"+T+"'")},o.notFollowedBy=yr,o.of=Be,o.oneOf=function(T){for(vark=T.split(""),N=0;N<k.length;N++)k[N]="'"+k[N]+"'";returnPt(function(K){returnT.indexOf(K)>=0}).desc(k)},o.optWhitespace=dr,o.Parser=o,o.range=function(T,k){returnPt(function(N){returnT<=N&&N<=k}).desc(T+"-"+k)},o.regex=_e,o.regexp=_e,o.sepBy=We,o.sepBy1=mt,o.seq=Ke,o.seqMap=Qe,o.seqObj=function(){for(varT,k={},N=0,K=(T=arguments,Array.prototype.slice.call(T)),J=K.length,ue=0;ue<J;ue+=1){varve=K[ue];if(!C(ve)){if(_(ve)&&ve.length===2&&typeofve[0]=="string"&&C(ve[1])){varVe=ve[0];if(Object.prototype.hasOwnProperty.call(k,Ve))thrownewError("seqObj: duplicate key "+Ve);k[Ve]=!0,N++;continue}thrownewError("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(N===0)thrownewError("seqObj expects at least one named parser, found zero");returno(function(vt,Pr){for(varjt,$i={},yt=0;yt<J;yt+=1){varpr,kr;if(_(K[yt])?(pr=K[yt][0],kr=K[yt][1]):(pr=null,kr=K[yt]),!(jt=V(kr._(vt,Pr),jt)).status)returnjt;pr&&($i[pr]=jt.value),Pr=jt.index}returnV(D(Pr,$i),jt)})},o.string=He,o.succeed=Be,o.takeWhile=function(T){returnq(T),o(function(k,N){for(varK=N;K<k.length&&T(M(k,K));)K++;returnD(K,k.slice(N,K))})},o.test=Pt,o.whitespace=br,o["fantasy-land/empty"]=ur,o["fantasy-land/of"]=Be,o.Binary={bitSeq:p,bitSeqObj:function(T){f();vark={},N=0,K=c(function(ue){if(_(ue)){varve=ue;if(ve.length!==2)thrownewError("["+ve.join(", ")+"] should be length 2, got length "+ve.length);if(B(ve[0]),U(ve[1]),Object.prototype.hasOwnProperty.call(k,ve[0]))thrownewError("duplicate key in bitSeqObj: "+ve[0]);returnk[ve[0]]=!0,N++,ve}returnU(ue),[null,ue]},T);if(N<1)thrownewError("bitSeqObj expects at least one named pair, got ["+T.join(", ")+"]");varJ=c(function(ue){returnue[0]},K);returnp(c(function(ue){returnue[1]},K)).map(function(ue){returnl(function(ve,Ve){returnVe[0]!==null&&(ve[Ve[0]]=Ve[1]),ve},{},c(function(ve,Ve){return[ve,ue[Ve]]},J))})},byte:function(T){if(f(),U(T),T>255)thrownewError("Value specified to byte constructor ("+T+"=0x"+T.toString(16)+") is larger in value than a single byte.");vark=(T>15?"0x":"0x0")+T.toString(16);returno(function(N,K){varJ=M(N,K);returnJ===T?D(K+1,J):P(K,k)})},buffer:function(T){returnm("buffer",T).map(function(k){returnBuffer.from(k)})},encodedString:function(T,k){returnm("string",k).map(function(N){returnN.toString(T)})},uintBE:g,uint8BE:g(1),uint16BE:g(2),uint32BE:g(4),uintLE:y,uint8LE:y(1),uint16LE:y(2),uint32LE:y(4),intBE:w,int8BE:w(1),int16BE:w(2),int32BE:w(4),intLE:x,int8LE:x(1),int16LE:x(2),int32LE:x(4),floatBE:m("floatBE",4).map(function(T){returnT.readFloatBE(0)}),floatLE:m("floatLE",4).map(function(T){returnT.readFloatLE(0)}),doubleBE:m("doubleBE",8).map(function(T){returnT.readDoubleBE(0)}),doubleLE:m("doubleLE",8).map(function(T){returnT.readDoubleLE(0)})},t.exports=o}])})})(KS,KS.exports);varR=KS.exports,I1=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u293
`)[0];let n=t.substring(2).trim();return R.makeSuccess(e+t.length,n)}),namedField:r=>R.alt(r.explicitNamedField,Age(ja.field).map(([e,t])=>QS.named(kge(t),e))),sortField:r=>R.seqMap(ja.field.skip(R.optWhitespace),R.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1),(e,t)=>{let n=t.length==0?"ascending":t[0].toLowerCase();return n=="desc"&&(n="descending"),n=="asc"&&(n="ascending"),{field:e,direction:n}}),headerClause:r=>r.queryType.chain(e=>{switch(e){case"table":return L5(()=>({type:e,fields:[],showId:!0}),R.seqMap(R.regexp(/WITHOUT\s+ID/i).skip(R.optWhitespace).atMost(1),R.sepBy(r.namedField,R.string(",").trim(R.optWhitespace)),(t,n)=>({type:e,fields:n,showId:t.length==0})));case"list":return L5(()=>({type:e,format:void 0,showId:!0}),R.seqMap(R.regexp(/WITHOUT\s+ID/i).skip(R.optWhitespace).atMost(1),ja.field.atMost(1),(t,n)=>({type:e,format:n.length==1?n[0]:void 0,showId:t.length==0})));case"task":return R.succeed({type:e});case"calendar":return R.whitespace.then(R.seqMap(r.namedField,t=>({type:e,showId:!0,field:t})));default:return R.fail(`Unrecognizedquerytype'${e}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:r=>R.seqMap(R.regexp(/FROM/i),R.whitespace,ja.source,(e,t,n)=>n),whereClause:r=>R.seqMap(R.regexp(/WHERE/i),R.whitespace,ja.field,(e,t,n)=>({type:"where",clause:n})).desc("WHERE <expression>"),sortByClause:r=>R.seqMap(R.regexp(/SORT/i),R.whitespace,r.sortField.sepBy1(R.string(",").trim(R.optWhitespace)),(e,t,n)=>({type:"sort",fields:n})).desc("SORT field [ASC/DESC]"),limitClause:r=>R.seqMap(R.regexp(/LIMIT/i),R.whitespace,ja.field,(e,t,n)=>({type:"limit",amount:n})).desc("LIMIT <value>"),flattenClause:r=>R.seqMap(R.regexp(/FLATTEN/i).skip(R.whitespace),r.namedField,(e,t)=>({type:"flatten",field:t})).desc("FLATTEN <value> [AS <name>]"),groupByClause:r=>R.seqMap(R.regexp(/GROUP BY/i).skip(R.whitespace),r.namedField,(e,t)=>({type:"group",field:t})).desc("GROUP BY <value> [AS <name>]"),clause:r=>R.alt(r.fromClause,r.whereClause,r.sortByClause,r.limitClause,r.groupByClause,r.flattenClause),query:r=>R.seqMap(r.headerClause.trim(r1),r.fromClause.trim(r1).atMost(1),r.clause.trim(r1).many(),(e,t,n)=>({header:e,source:t.length==0?Bl.folder(""):t[0],operations:n,settings:D1}))}),r1=R.alt(R.whitespace,L8.comment).many().map(r=>r.join("")),Sge=r=>r?r.plugins.plugins.dataview?.api:window.DataviewAPI,Dge=r=>r.plugins.enabledPlugins.has("dataview");Ul.DATE_SHORTHANDS=C1;Ul.DURATION_TYPES=w1;Ul.EXPRESSION=ja;Ul.KEYWORDS=x1;Ul.QUERY_LANGUAGE=L8;Ul.getAPI=Sge;Ul.isPluginEnabled=Dge;Ul.parseField=_ge});function Gx(r){if(!r.includes(",")){let o=r.trim();return o?[o]:[]}let e=[],t="",n=!1;for(let o=0;o<r.length;o++){let s=r[o],a=r[o+1];if(s==="["&&a==="["){n=!0,t+=s;continue}if(s==="]"&&a==="]"){n=!1,t+=s;continue}if(s===","&&!n){let l=t.trim();l&&e.push(l),t="";continue}t+=s}let i=t.trim();return i&&e.push(i),e}var P1=b(()=>{});function Yx(r){return r.replace(/[\\"]/g,"\\$&")}function Ige(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U8(r){return Yx(Ige(r))}function rD(r){return typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"}var F1,Kx,V8=b(()=>{F1=UN(B8());Me();P1();Kx=class{static getDataviewAPI(e){let t=(0,F1.getAPI)(e);return t||(F.logMessage("Dataview plugin is not installed or enabled"),null)}static async getFieldValues(e,t){let n=new Set,i=this.getDataviewAPI(e);if(!i)return n;try{let s=`field("${Yx(t)}")`,a=`TABLE${s}WHERE${s}`,l=await i.query(a);if(l.successful&&l.value.values)for(let c of l.value.values){let u=c[1];Array.isArray(u)?u.forEach(d=>{d&&typeof d=="string"?n.add(d.trim()):rD(d)?n.add(d.path):d&&typeof d!="object"&&n.add(String(d).trim())}):rD(u)?n.add(u.path):u&&typeof u=="string"?Gx(u).forEach(d=>n.add(d)):u&&typeof u!="object"&&n.add(String(u).trim())}}catch(o){F.logError(new Error(`FailedtoqueryDataviewforfield${t}:${o}`))}return n}static async getFieldValuesWithFilter(e,t,n={}){let i=new Set,o=this.getDataviewAPI(e);if(!o)return i;try{let a=`field("${Yx(t)}")`,l=[a],c=(n.folders?.length?n.folders:n.folder?[n.folder]:[]).map(v=>v.replace(/^\/+|\/+$/g,
${a}`;return await this.app.vault.modify(t,c),t}catch(o){if(z1(o))throw o;return this.noteTemplateFileFailure(o,"Could not append to file with template"),lt(o,"Could not append to file with template"),null}}async getTemplateContent(t){let n=po(this.app,t);if(!n)throw new Error(`Templatefilenotfoundatpath"${t}".`);return await this.app.vault.cachedRead(n)}}});var e9={};Zr(e9,{SingleTemplateEngine:()=>tE});var tE,H1=b(()=>{uD();Me();tE=class extends hd{constructor(t,n,i,o,s){super(t,n,o,s);this.templatePath=i;this.promptScope="noteBody"}setPromptScope(t){this.promptScope=t}async run(){let t=await this.resolveTemplateSourcePath(this.templatePath),n=await this.getTemplateContent(t);return n||F.logError(`Template${t}notfound.`),n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope(this.promptScope,n,()=>this.formatter.formatFileContent(n))),n}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}}});var t9={};Zr(t9,{SingleInlineScriptEngine:()=>j1});var j1,r9=b(()=>{Zx();j1=class extends ql{constructor(e,t,n,i){super(e,t,null,n,i)}async runAndGetOutput(e){let t=Object.getPrototypeOf(async function(){}).constructor;return await new t(e).bind(this.params,this).call()}}});var n9,ws,Lg=b(()=>{n9=require("obsidian");zs();nd();X4();WO();Tt();Wc();n5();a5();uh();Ru();ip();Hs();vl();$1();M1();O1();Cu();Me();$m();vy();K8();Wr();Co();Cr();ws=class extends yl{constructor(t,n,i,o){super(t);this.app=t;this.plugin=n;this.choiceExecutor=i;this.contentValuePromptsAcceptImagePaste=!1;this.dateParser=o||El,i&&(this.variables=i?.variables)}async format(t){let n=t;return n=await this.replaceInlineJavascriptInString(n),n=await this.replaceMacrosInString(n),n=await this.replaceTemplateInString(n),n=await this.replaceGlobalVarInString(n),n=this.replaceDateInString(n),n=this.replaceTimeInString(n),n=await this.replaceValueInString(n),n=await this.replaceSelectedInString(n),n=await this.replaceClipboardInString(n),n=await this.replaceDateVariableInString(n),n=await this.replaceVariableInString(n),n=await this.replaceFieldVarInString(n),n=await this.replaceFileInString(n),n=await this.replaceMathValueInString(n),n=this.replaceRandomInString(n),n}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(pl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}async formatFileName(t,n="generic"){if($s.test(t))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");let i=await this.withPromptScope(n,t,()=>this.format(t));if($s.test(i))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");return i=this.replaceCurrentFileTokensInString(i,{fileName:!0,folder:!0,activeFolder:"path"}),i}async formatFileContent(t){let n=t,i=this.contentValuePromptsAcceptImagePaste;this.contentValuePromptsAcceptImagePaste=!x_(this.promptScope);try{n=await this.format(n)}finally{this.contentValuePromptsAcceptImagePaste=i}return n=this.replaceCurrentFileTokensInString(n,{links:!0,fileName:!0,folder:!0,activeFolder:"content",title:!0}),n}async formatFolderPath(t){if($s.test(t))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");let n=await this.withPromptScope("folder",t,()=>this.format(t));if($s.test(n))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");return this.replaceCurrentFileTokensInString(n,{folder:!0,activeFolder:"path"}).replace(/^\/+/,"")}async formatTemplateFilePath(t){if($s.test(t))throw new Error("{{title}} cannot be used in a template path \u2014 the title is derived from the created file, not the source template.");let n=t;if(n=await this.replaceGlobalVarInString(n),$s.tes
Suggested values for ${i}: ${v.slice(0,3).join(", ")}`)}returnn?awaitn.inputPrompt(`Enter value for ${i}`,m):awaitSr.PromptWithContext(this.app,`Enter value for ${i}`,m,void0,this.getLinkSourcePath()??void0)}returnn?String(awaitn.suggester(u,u,p,!0)):awaitan.Suggest(this.app,u,u,{placeholder:p})}catch(i){throwDt(i)?newSt("Input cancelled by user"):i}}generateCacheKey(t){returniD(t)}asyncsuggestForFile(t){this.assertInteractivePrompt(`{{FILE}} (pick a file from ${t.folderPath})`);letn=this.choiceExecutor?.promptProvider;try{leti=zi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,c=>this.app.metadataCache.getFileCache(c)),o=t.label??`Select a file from ${t.folderPath}`;if(i.length===0){letc=`No markdown files found in "${t.folderPath}". Type a value or leave empty.`,u=n?awaitn.inputPrompt(o,c):awaitSr.Prompt(this.app,o,c,void0,void0,t.optional?{optional:!0}:void0);returnt.multiSelect?u?[`${as}${u}`]:[]:u?`${as}${u}`:""}lets=Tc(i,c=>this.app.metadataCache.getFileCache(c)),a=i.map(c=>`${gl}${c.path}`);if(t.multiSelect)return(n?awaitn.suggesterMulti(s,a,{placeholder:o,allowCustomInput:t.allowCustomInput}):awaitZp.Suggest(this.app,s,a,{placeholder:o,allowCustomValue:t.allowCustomInput,...t.optional?{skippable:!0}:{}})).map(u=>a.includes(u)?u:`${as}${u}`);if(n){letc=String(awaitn.suggester(s,a,o,t.allowCustomInput));returnc?a.includes(c)?c:`${as}${c}`:""}if(t.allowCustomInput){letc=newSet(i.map(f=>f.basename.toLowerCase())),u=newSet(s.map(f=>f.toLowerCase())),d=awaitan.Suggest(this.app,s,a,{placeholder:o,valueExists:f=>c.has(f.toLowerCase())||u.has(f.toLowerCase()),...t.optional?{skippable:!0}:{}});returnd?a.includes(d)?d:`${as}${d}`:""}returnawaitNr.Suggest(this.app,s,a,o,void0,t.optional?{skippable:!0}:void0)??""}catch(i){throwDt(i)?newSt("Input cancelled by user"):i}}asyncgetMacroValue(t,n){let{SingleMacroEngine:i}=awaitPromise.resolve().then(()=>(Z8(),Q8)),o=newi(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),s=awaito.runAndGetOutput(t,n)??"";returno.getVariables().forEach((a,l)=>{this.variables.set(l,a)}),s}asyncgetTemplateContent(t){let{SingleTemplateEngine:n}=awaitPromise.resolve().then(()=>(H1(),e9));this.templateInclusion??(this.templateInclusion={visited:newSet,depth:0});leti={visited:this.templateInclusion.visited,depth:this.templateInclusion.depth+1},o=newn(this.app,this.plugin,t,this.choiceExecutor,i);o.setTargetFolderPath(this.targetFolderPath),this.promptScope!=="generic"&&o.setPromptScope(this.promptScope),this.promptRunContext&&o.setPromptRunContext({...this.promptRunContext,draftScopeId:`${this.promptRunContext.draftScopeId??""}#${t}`});lets=awaito.run();returnthis.mergeTemplatePropertyVars(o.getAndClearTemplatePropertyVars()),s}asyncgetSelectedText(){lett=On(this.app);returnt?t.editor.getSelection():""}asyncgetClipboardContent(){try{returnawaitnavigator.clipboard.readText()}catch{return""}}isTemplatePropertyTypesEnabled(){returnthis.plugin.settings.enableTemplatePropertyTypes}asyncreplaceInlineJavascriptInString(t){letn=t;for(;dc.test(n);){leti=dc.exec(n);if(!i)break;leto=i.at(1)?.trim();if(o){let{SingleInlineScriptEngine:s}=awaitPromise.resolve().then(()=>(r9(),t9)),a=news(this.app,this.plugin,this.choiceExecutor,this.variables),l=awaita.runAndGetOutput(o);for(letuina.params.variables)this.variables.set(u,a.params.variables[u]);letc="";typeofl=="string"?c=l:(typeofl=="number"||typeofl=="boolean"||Array.isArray(l))&&(c=this.renderCollectedOrArrayValue({input:n,matchStart:i.index,matchEnd:i.index+i[0].length,rawValue:l,fallbackKey:"inlineScript",heuristicEnabled:this.isTemplatePropertyTypesEnabled()})??String(l)),n=this.replacer(n,dc,c)}elsen=this.replacer(n,dc,"")}returnn}asynccollectValuesManually(t,n){returnawaitoD(this.app,t,n)}}});functionlf(r){returnnewTextEncoder().encode(r).length}functionjge(r){lete=0;for(lettofr){if(t.role==="tool"){for(letnoft.results)e+=lf(n.content);continue}if(e+=lf(t.content),t.role==="assistant"&&t.toolCalls){for(letnoft.toolCalls)if(typeofn
`:"",a=n.length+o.length,l=a+e.length;return{content:`${n}${o}${e}${s}${i}`,insertedStartOffset:a,insertedEndOffset:l}}function gD(r,e){return Q1(r,e).content}var f9,p9,ave,oE=b(()=>{f9=require("obsidian"),p9=/^[^\S\r\n]*\r?\n/,ave=/^\r?\n/});function Z1(r){return(r??"").trim().replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+|\/+$/g,"").normalize("NFC")}function J1(r,e){return e.some(t=>r===t||r.startsWith(`${t}/`))}function uf(r,e){let t=(e??[]).map(n=>Z1(n)).filter(n=>n.length>0);return t.length===0?!0:r?J1(r.normalize("NFC"),t):!1}var vD=b(()=>{});function df(r,e={}){let t=(r??"").trim();if(!t)throw new sa("Path is empty.");let n=t.replace(/\\/g,"/").normalize("NFC");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new sa(`Refusingtowritetoanabsolutepathoutsidethevault:"${n}".`);let i=n.replace(/\/+/g,"/").replace(/^\/+|\/+$/g,""),o=i.split("/").filter(a=>a.length>0);if(o.length===0)throw new sa("Path is empty after normalization.");for(let a of o){if(a==="."||a==="..")throw new sa(`Refusingpathwithatraversalsegment("${a}"):"${i}".`);if(a.startsWith("."))throw new sa(`Refusingtowriteintoadot/configpathsegment("${a}"):"${i}".`);cve(a,i)}let s=(e.allowedRoots??[]).map(a=>Z1(a)).filter(a=>a.length>0);if(s.length>0&&!J1(i,s))throw new sa(`Path"${i}"isnotunderanallowedroot(${s.join(", ")}).`);return i}function cve(r,e){if(I_.test(r))throw new sa(`Pathsegment"${r}"containscontrolcharacters:"${e}".`);if(P_.test(r))throw new sa(`Pathsegment"${r}"containsanillegalcharacter(\\:*?" < > |): "${e}".`);if(F_.test(r))throw new sa(`Path segment "${r}" cannot end with a space or a period: "${e}".`);let t=r.split(".")[0]??"";if(t&&Pm(t))throw new sa(`Path segment "${r}" is a reserved device name: "${e}".`)}var sa,m9=b(()=>{M_();vD();sa=class extends Error{constructor(e){super(e),this.name="UnsafeVaultPathError"}}});function Bg(r,e){let t=Object.entries(r),n=new Set(t.map(([o])=>o));if(h9(e.only,n,"only"),h9(e.exclude,n,"exclude"),e.only){let o=new Set(e.only);t=t.filter(([s])=>o.has(s))}if(e.exclude){let o=new Set(e.exclude);t=t.filter(([s])=>!o.has(s))}let i=e.prefix??"";return Object.fromEntries(t.map(([o,s])=>[i+o,s]))}function sE(r){return{...r,__qaTool:!0}}function h9(r,e,t){if(!r)return;let n=r.filter(i=>!e.has(i));n.length!==0&&F.logWarning(`AI tools: ${t} listed unknown tool name(s) ${n.map(i=>`"${i}"`).join(",")}. Valid names: ${[...e].join(",")}.`)}var yD=b(()=>{Me()});function x9(r,e={}){let t=e.allowedRoots,n={read_note:pf({description:"Readanote's full markdown content by vault path.",inputSchema:ff({path:aa("Vault path to the note, e.g. Notes/Foo.md")},["path"]),readOnly:!0,execute:async({path:i})=>{let o=df(String(i),{allowedRoots:t}),s=r.vault.getAbstractFileByPath(o);if(!(s instanceof tN.TFile))return{found:!1,path:o};let a=await r.vault.cachedRead(s);return{found:!0,path:o,content:a.length>g9?a.slice(0,g9)+`
\u2026[truncated]`:a}}}),list_notes:pf({description:"List markdown notes, optionally within a folder.",inputSchema:ff({folder:aa("Folder to list (omit for the whole vault)."),limit:v9("Max results (default 100, capped at 200).")},[]),readOnly:!0,execute:async({folder:i,limit:o})=>{let s=i?df(String(i),{allowedRoots:t}):"",a=w9(b9(o,uve),1,dve),l=rs(r,s).filter(c=>uf(c.path,t));return{total:l.length,notes:l.slice(0,a).map(c=>({path:c.path,basename:c.basename}))}}}),search_notes:pf({description:"Search notes by name and/or content. Returns matching paths with a short snippet.",inputSchema:ff({query:aa("Text to search for."),in:y9(["name","content","both"],"Where to search (default both)."),limit:v9("Max results (default 25, capped at 50).")},["query"]),readOnly:!0,execute:async({query:i,in:o,limit:s})=>{let a=String(i).toLowerCase(),l=o??"both",c=w9(b9(s,pve),1,fve),u=r.vault.getMarkdownFiles().filter(m=>uf(m.path,t)),d=[],f=0,p=!1;for(let m of u){if(d.length>=c)break;if(l!=="content"&&m.basename.toLowerCase().includes(a)){d.push({path:m.path});continue}if(l!=="name"){if(f>=mve){p=!0;continue}f++;let g=await r.vault.cachedRead(m),y=g.toLowerCase().indexOf(a);y>=0&&d.push({path:m.path,snippet:gve(g,y)})}}return{results:d,scannedFiles:f,truncated:d.length>=c||p}}}),get_property_values:pf({description:"List the distinct values a frontmatter property takes across the vault (e.g. existing tags or statuses).",inputSchema:ff({field:aa("Frontmatter property name."),folder:aa("Optional folder scope.")},["field"]),readOnly:!0,execute:async({field:i,folder:o})=>{let s=o?df(String(o),{allowedRoots:t}):"",a=(o?rs(r,s):r.vault.getMarkdownFiles()).filter(c=>uf(c.path,t)),l=new Set;for(let c of a){let d=r.metadataCache.getFileCache(c)?.frontmatter?.[String(i)];if(d!=null){for(let f of Array.isArray(d)?d:[d])if(typeof f!="object"){let p=String(f).trim();p&&l.add(p)}}}return{field:String(i),values:[...l].sort().slice(0,200)}}}),create_note:pf({description:"Create a new markdown note. Fails if the path already exists.",inputSchema:ff({path:aa("Vault path for the new note."),content:aa("Initial markdown content.")},["path"]),needsApproval:!0,execute:async({path:i,content:o})=>{let s=df(eN(String(i)),{allowedRoots:t});return await lg(r,s),await hve(r,s),{created:!0,path:(await r.vault.create(s,String(o??""))).path}}}),append_to_note:pf({description:"Append text to an existing note (frontmatter-aware for top inserts).",inputSchema:ff({path:aa("Vault path to the existing note."),content:aa("Markdown to append."),position:y9(["top","bottom"],"Where to add it (default bottom).")},["path","content"]),needsApproval:!0,execute:async({path:i,content:o,position:s})=>{let a=df(eN(String(i)),{allowedRoots:t}),l=C9(r,a);await lg(r,a);let c=await r.vault.read(l),u=String(o),d=s==="top"?gD(c,u.endsWith(`
`)?u:u+`
`):`${c}${c.endsWith(`
`)||c.length===0?"":`
`}${u}`;return await r.vault.modify(l,d),{appended:!0,path:a}}}),insert_under_heading:pf({description:"Insert markdown under an existing heading (matched exactly). Errors if the heading is not found.",inputSchema:ff({path:aa("Vault path to the existing note."),heading:aa("Exact heading text (without the # markers)."),content:aa("Markdown to insert under the heading.")},["path","heading","content"]),needsApproval:!0,execute:async({path:i,heading:o,content:s})=>{let a=df(eN(String(i)),{allowedRoots:t}),l=C9(r,a);await lg(r,a);let c=r.metadataCache.getFileCache(l)?.headings??[],u=c.find(p=>p.heading===String(o));if(!u)throw new Error(`Heading "${o}" not found in ${a}`);let d=await r.vault.read(l),f=vve(d,u.position.start.line,u.level,String(s),c);return await r.vault.modify(l,f),{inserted:!0,path:a,heading:String(o)}}})};return Bg(n,e)}function pf(r){return{...r,__qaTool:!0}}function ff(r,e){return{type:"object",properties:r,required:e}}function aa(r){return{type:"string",description:r}}function v9(r){return{type:"integer",description:r}}function y9(r,e){return{type:"string",enum:r,description:e}}function b9(r,e){let t=Number(r);return Number.isFinite(t)?Math.floor(t):e}function w9(r,e,t){return Math.max(e,Math.min(t,r))}function eN(r){if(/\.md$/i.test(r))return r;if(/\.[a-z0-9]+$/i.test(r))throw new Error(`This tool only operates on markdown notes (.md); refused path: "${r}".`);return`${r}.md`}function C9(r,e){let t=r.vault.getAbstractFileByPath(e);if(!(t instanceof tN.TFile))throw new Error(`Note not found: ${e}`);return t}async function hve(r,e){let t=e.lastIndexOf("/");if(t<=0)return;let n=e.slice(0,t);if(!r.vault.getAbstractFileByPath(n))try{await r.vault.createFolder(n)}catch{}}function gve(r,e){let t=Math.max(0,e-40);return r.slice(t,e+80).replace(/\s+/g," ").trim()}function vve(r,e,t,n,i){let o=r.split(`
`),s=o.length;for(let u of i)if(u.position.start.line>e&&u.level<=t){s=u.position.start.line;break}let a=n.endsWith(`
`)}var tN,g9,uve,dve,pve,fve,mve,E9=b(()=>{tN=require("obsidian");qt();oE();vD();m9();sO();yD();g9=16e3,uve=100,dve=200,pve=25,fve=50,mve=400});function _9(r,e={}){let t=e.allowedRoots,n=()=>{let s=r.workspace.getActiveFile();return!(s instanceof bD.TFile)||s.extension!=="md"?null:uf(s.path,t)?s:null},i=()=>{let s=r.workspace.getActiveViewOfType(bD.MarkdownView);return s&&uf(s.file?.path,t)?s:null},o={get_active_note:sE({description:"Get the currently active note (path, basename, and content). Returns active:null if there is none.",inputSchema:{type:"object",properties:{}},readOnly:!0,execute:async()=>{let s=n();if(!s)return{active:null};let a=await r.vault.cachedRead(s);return{active:{path:s.path,basename:s.basename,content:a.length>T9?a.slice(0,T9)+`
\u2026[truncated]`:a}}}}),get_selection:sE({description:"Get the text currently selected in the active editor (empty string if none).",inputSchema:{type:"object",properties:{}},readOnly:!0,execute:async()=>({selection:i()?.editor?.getSelection()??""})})};return Bg(o,e)}var bD,T9,A9=b(()=>{bD=require("obsidian");vD();yD();T9=16e3});function k9(r={}){let e={get_date:sE({description:"Get the current date/time. Optionally pass a moment.js format and a day offset.",inputSchema:{type:"object",properties:{format:{type:"string",description:"moment.js format, e.g. YYYY-MM-DD"},offset:{type:"integer",description:"Day offset from today (e.g. 1 = tomorrow)."}}},readOnly:!0,execute:async({format:t,offset:n})=>({date:Bs({format:t!=null?String(t):void 0,offset:n!=null?Number(n):void 0})})})};return Bg(e,r)}var S9=b(()=>{qt();yD()});var aE,Ug,D9=b(()=>{aE=require("obsidian");Wr();BO();Ug=class r extends aE.Modal{constructor(t,n,i=[],o){super(t);this.items=n;this.selectedItems=i;this.header=o;this._selectedItems=[...i],this.promise=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.display(),this.open(),this.picker.focusSearchOnOpen()}static Open(t,n,i,o){return new r(t,n,i,o).promise}display(){this.contentEl.empty(),this.containerEl.addClass("quickAddModal","qaSearchableMultiSelectModal","checkboxPrompt"),this.header&&(this.titleEl.textContent=this.header),this.addSearchableOptions(),this.addSubmitButton()}onClose(){super.onClose(),this.resolved||this.rejectPromise(tn())}addSearchableOptions(){this.picker=new Qp(this.contentEl,{items:this.items.map(t=>({key:t,value:t,label:t})),isSelected:({value:t})=>this._selectedItems.includes(t),onToggle:({value:t},n)=>{if(n){this._selectedItems.includes(t)||this._selectedItems.push(t);return}this._selectedItems=this._selectedItems.filter(i=>i!==t)},getSelectedCount:()=>new Set(this._selectedItems).size})}addSubmitButton(){let t=this.contentEl.createDiv("submitButtonContainer");new aE.ButtonComponent(t).setButtonText("Submit").setCta().onClick(()=>{this.resolved=!0,this.resolvePromise(this._selectedItems),this.close()}),new aE.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.close()})}}});var wD,lE,I9=b(()=>{wD=require("obsidian"),lE=class r extends wD.Modal{constructor(t,n,i){super(t);this.header=n;this.text=i;this.waitForClose=new Promise(o=>{this.resolvePromise=o}),this.open(),this.display()}static Show(t,n,i){return new r(t,n,i).waitForClose}display(){this.contentEl.empty(),this.titleEl.textContent=this.header,String.isString(this.text)?this.contentEl.createEl("p",{text:this.text}):Array.isArray(this.text)&&this.text.forEach(i=>this.contentEl.createEl("p",{text:i}));let t=this.contentEl.createDiv(),n=new wD.ButtonComponent(t).setButtonText("OK").onClick(()=>this.close());Object.assign(t.style,{display:"flex",justifyContent:"flex-end"}),n.buttonEl.focus()}onClose(){super.onClose(),this.resolvePromise()}}});var CD,P9=b(()=>{Ru();$1();fl();CD=class extends mn{constructor(t,n,i){super(t,n);this.cachedValues=null;this.fieldInput=i;let o=Yi.parse(i);this.fieldName=o.fieldName,this.filters=o.filters}async getSuggestions(t){this.cachedValues||(this.cachedValues=await W8(this.app,this.fieldName,this.filters));let n=(t||"").toLowerCase();return n?this.cachedValues.filter(i=>i.toLowerCase().includes(n)).slice(0,200):this.cachedValues.slice(0,200)}renderSuggestion(t,n){this.renderMatch(n,t,this.getCurrentQuery())}selectSuggestion(t){this.inputEl.value=t;let n=new Event("input",{bubbles:!0});n.fromCompletion=!0,this.inputEl.dispatchEvent(n),this.close()}}});var F9,rN,xD,M9=b(()=>{F9=require("obsidian");fl();rN=200,xD=class extends mn{constructor(t,n,i,o,s,a,l){super(t,n);this.getOptions=i;this.isSelected=o;this.onSelect=s;this.multiSelect=a;this.allowCustomInput=l;a&&n.setAttribute("aria-multiselectable","true")}getSuggestions(t){let n=t.trim(),i=this.getOptions().filter(u=>!this.isSelected(u.value));if(!n)return i.slice(0,rN);let o=(0,F9.prepareFuzzySearch)(n),s=i.map(u=>({option:u,match:o(`${u.label} ${u.path}`)})).filter(u=>u.match!==null).sort((u,d)=>d.match.score-u.match.
${e}`:gD(r,`${e}
`)}function bve(r){return r==null||r===""||Array.isArray(r)&&r.length===0}function U9(r){return typeof r=="string"?r.length>0?[r]:[]:!Array.isArray(r)||!r.every(e=>typeof e=="string")?null:r}function V9(r,e){let t=U9(r),n=U9(e);if(t===null||n===null)return;let i=[],o=new Set(t);for(let s of n)s.length===0||o.has(s)||(o.add(s),i.push(s));if(i.length!==0)return[...t,...i]}var _D,cE,qg,AD=b(()=>{_D=require("obsidian");Me();qt();aD();Sx();D_();by();Rg();oE();uD();Tl();A_();cE=[{id:"cursor",label:"Insert at cursor",description:"Inserts the template at the cursor position in the editor."},{id:"top",label:"Insert at top",description:"Inserts the template below the note'sfrontmatter,orattheverytop."},{id:"bottom",label:"Appendtobottom",description:"Addsthetemplatecontenttotheendofthenote."},{id:"replace",label:"Replacenotecontent",description:"Replacestheentirenotecontentwiththetemplate."}];qg=class extends hd{constructor(t,n,i,o,s,a,l){super(t,n,a);this.targetFile=i;this.templatePath=o;this.mode=s;this.resolvedTemplatePath=l??null}async run(){await this.apply()}async getResolvedTemplatePath(){return this.resolvedTemplatePath===null&&(this.resolvedTemplatePath=await this.resolveTemplateSourcePath(this.templatePath)),this.resolvedTemplatePath}async apply(){switch(Mi(this.templatePath,"Cannotapplytemplate:notemplatepathgiven."),this.mode){case"replace":return await this.overwriteFileWithTemplate(this.targetFile,await this.getResolvedTemplatePath());case"top":case"bottom":return await this.insertTemplateIntoFile(this.mode);case"cursor":return await this.insertTemplateAtCursor()}}async computeChoiceTargetPath(t){let n=t.folder,i;if(this.formatter.setTargetFolderPath(null),n?.enabled){if(n.chooseWhenCreatingNote)return null;if(n.createInSameFolderAsActiveFile)i=this.targetFile.parent?.path??"";else{if(n.chooseFromSubfolders)return null;if(n.folders.length===1)i=await this.formatter.formatFolderPath(n.folders[0]);else return null}}else i=this.targetFile.parent?.path??"";i==="/"&&(i="");let o=this.targetFile.basename,s=!1;if(t.fileNameFormat?.enabled&&t.fileNameFormat.format){this.formatter.setTargetFolderPath(i);let a=await this.formatter.formatFileName(t.fileNameFormat.format,"generic"),l=ai(a,"Filename"),c=this.stripDuplicateFolderPrefix(l,i);o=c.fileName,s=this.shouldTreatFormattedNameAsVaultRelativePath(l,c.strippedPrefix,n?.enabled??!1)}return o.slice(o.lastIndexOf("/")+1).trim()?this.normalizeTemplateFilePath(s?"":i,o,await this.getResolvedTemplatePath()):null}async insertTemplateIntoFile(t){let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=B9(n);return s.trim().length>0&&await this.app.vault.process(this.targetFile,a=>yve(a,s,t)),await this.mergeFrontmatterProperties(o,i),this.targetFile}async insertTemplateAtCursor(){let t=Gv(this.app,this.targetFile);Mi(t,"Cannotinsertatcursor:thenoteisnotopenintheactiveeditor.");let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=B9(n);return s.trim().length>0&&t.editor.replaceSelection(s),await this.mergeFrontmatterProperties(o,i),this.targetFile}async formatTemplateForTargetFile(){let t=await this.getTemplateContent(await this.getResolvedTemplatePath());this.formatter.setTitle(this.targetFile.basename),this.formatter.setTargetFolderPath(Wo(this.targetFile.path));let n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",t,()=>this.formatter.formatFileContent(t))),i=this.formatter.getAndClearTemplatePropertyVars();return this.targetFile.extension==="md"&&(n=await pc(this.app,n,this.targetFile)),{formatted:n,templatePropertyVars:i}}async mergeFrontmatterProperties(t,n){if(!t||this.targetFile.extension!=="md")return;let i;try{i=(0,_D.parseYaml)(t)}catch(o){F.logWarning(`Could not parse template frontmatter for merging: ${o}`);return}if(!(!i||typeof i!="object"||Array.isArray(i))){if(n&&n.size>0)for(let[o,s]of n){let a=o.includes(Fa.PATH_SEPARATOR)?o.split(Fa.PATH_SEPARATOR):[o];q1(i,a,k_(s))
`)}var kD=b(()=>{});async function X9(r,e){return r.mode==="script"?await e.evaluateScriptCondition(r):Sve(r,e.variables)}function Sve(r,e){let t=r.variableName?.trim();if(!t)return F.logWarning("Conditionalcommandskipped:Novariablenameconfigured."),!1;if(!(t in e))return F.logWarning(`Conditional command skipped: Variable '${t}' is not defined.`),!1;let n=e[t];switch(r.operator){case"isTruthy":return!!n;case"isFalsy":return!n}if(Ou(r.operator)){let i=YV(r);return i===void 0?(F.logWarning(`Conditional command: Operator '${r.operator}' requires a comparison value.`),!1):r.operator==="contains"?K9(n,i,r):r.operator==="notContains"?!K9(n,i,r):Dve(n,i,r)}return!1}function K9(r,e,t){if(r==null)return!1;if(typeof e=="string"&&e.length===0)return F.logWarning("Conditionalcommand:'contains'operatorrequiresanon-emptycomparisonvalue."),!1;if(Array.isArray(r))return r.map(o=>QP(o,t.valueType)).some(o=>o===e);if(typeof r=="string")return r.includes($u(e));if(typeof r=="number"&&typeof e=="number")return r===e;let n=$u(r),i=$u(e);return typeof n=="string"&&n.includes(i)}function Dve(r,e,t){let n=QP(r,t.valueType);switch(t.operator){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return SD(n,e,(i,o)=>i<o);case"lessThanOrEqual":return SD(n,e,(i,o)=>i<=o);case"greaterThan":return SD(n,e,(i,o)=>i>o);case"greaterThanOrEqual":return SD(n,e,(i,o)=>i>=o);default:return!1}}function SD(r,e,t){let n=Number(r),i=Number(e);return Number.isNaN(n)||Number.isNaN(i)?(F.logWarning("Conditionalcommandnumericcomparisonfailed:non-numericvalueencountered."),!1):t(n,i)}var Q9=b(()=>{Me();Rm()});function Z9(r,e=void 0){return r==="horizontal"?"horizontal":r==="vertical"?"vertical":e}function gd(r,e,t){return t?{location:r,direction:t,focus:e,mode:"default"}:{location:r,focus:e,mode:"default"}}function J9(r){let e=r.focus??!0;if(r.location)switch(r.location){case"reuse":return gd("reuse",e);case"tab":return gd("tab",e);case"split":return gd("split",e,Z9(r.direction,"vertical"));case"window":return gd("window",e);case"left-sidebar":return gd("left-sidebar",e);case"right-sidebar":return gd("right-sidebar",e);default:break}let t=r.openInNewTab??!1,n=Z9(r.direction);return t?gd("split",e,n??"vertical"):gd("reuse",e)}var eK=b(()=>{Ck()});function tK(r){let e={hasOwnProperty:t=>r.has(t)};return new Proxy(e,{get(t,n){if(n==="hasOwnProperty")return e.hasOwnProperty;if(typeof n=="string")return r.get(n)},set(t,n,i){return typeof n!="string"||r.set(n,i),!0},deleteProperty(t,n){return typeof n!="string"||r.delete(n),!0},has(t,n){return typeof n=="string"&&r.has(n)},ownKeys(){return Array.from(r.keys())},getOwnPropertyDescriptor(t,n){if(n==="hasOwnProperty")return{value:e.hasOwnProperty,writable:!0,configurable:!0,enumerable:!1};if(!(typeof n!="string"||!r.has(n)))return{value:r.get(n),writable:!0,configurable:!0,enumerable:!0}}})}var rK=b(()=>{});function sK(r){return r!==null&&typeof r=="object"}function Pve(r){return typeof r=="function"}function aK(r){return sK(r)}function Fve(r){if(!aK(r))return;let{settings:e}=r;return sK(e)?e:void 0}function nK(r,e="command"){if(typeof r!="string"||!r.trim())return`the saved entry has no ${e} type, so QuickAdd cannot tell what it was meant to do. It is in .obsidian/plugins/quickadd/data.json.`;let t=e==="command"?Mve.get(r):void 0;return t||`QuickAdd does not recognise the ${e} type '${r}'. It can come from a newer version of QuickAdd, an imported package, or a hand-edited .obsidian/plugins/quickadd/data.json.`}function iK(r){return`${r.scriptPath}::${r.exportName??"default"}`}var Ive,oK,Mve,ql,Zx=b(()=>{Ive=UN(require("obsidian"));Me();Cr();Yr();oN();sN();Wc();$g();Og();hl();qt();gs();k$();A$();S$();D$();I$();P$();F$();M$();R$();$$();kD();DS();Xp();It();Lg();Nh();es();qt();oK=require("obsidian");Os();Wr();Co();hk();NT();Uc();Q9();Qx();eK();rK();Ii();Mve=new Map([["InfiniteAIAssistant",'QuickAdd has removed the "InfiniteAIAssistant" command type - no released version could ever run one. Delete the step from the macro. For chunked AI prompts, use quickAddApi.ai.chunkedPrompt() in a use
An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app \u2014 please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${r}"
https://svelte.dev/e/invariant_violation`);throw e.name="Svelteerror",e}else throw new Error("https://svelte.dev/e/invariant_violation")}function FE(r){if(te){let e=new Error(`lifecycle_outside_component
\`${r}(...)\` can only be used during component initialisation
https://svelte.dev/e/lifecycle_outside_component`);throwe.name="Svelte error",e}elsethrownewError("https://svelte.dev/e/lifecycle_outside_component")}functionYN(){if(te){letr=newError("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/async_derived_orphan")}functionlI(){if(te){letr=newError("bind_invalid_checkbox_value\nUsing `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead\nhttps://svelte.dev/e/bind_invalid_checkbox_value");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/bind_invalid_checkbox_value")}functionKN(){if(te){letr=newError(`derived_references_self
A derived value cannot reference itself recursively
Keyed each block has key that is not idempotent \u2014 the key for item at index ${r} was \`${e}\` but is now \`${t}\`. Keys must be the same each time for a given item
\`${r}\` cannot be used inside an effect cleanup function
https://svelte.dev/e/effect_in_teardown`);throwe.name="Svelte error",e}elsethrownewError("https://svelte.dev/e/effect_in_teardown")}functionZN(){if(te){letr=newError("effect_in_unowned_derived\nEffect cannot be created inside a `$derived` value that was not itself created inside an effect\nhttps://svelte.dev/e/effect_in_unowned_derived");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/effect_in_unowned_derived")}functionJN(r){if(te){lete=newError(`effect_orphan
\`${r}\` can only be used inside an effect (e.g. during component initialisation)
https://svelte.dev/e/hydration_failed`);throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/hydration_failed")}functionrL(){if(te){letr=newError("invalid_snippet\nCould not `{@render}` snippet due to the expression being `null` or `undefined`. Consider using optional chaining `{@render snippet?.()}`\nhttps://svelte.dev/e/invalid_snippet");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/invalid_snippet")}functionnL(r){if(te){lete=newError(`props_invalid_value
Cannot do \`bind:${r}={undefined}\` when \`${r}\` has a fallback value
The \`${r}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files
https://svelte.dev/e/rune_outside_svelte`);throwe.name="Svelte error",e}elsethrownewError("https://svelte.dev/e/rune_outside_svelte")}functionoL(){if(te){letr=newError("state_descriptors_fixed\nProperty descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.\nhttps://svelte.dev/e/state_descriptors_fixed");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/state_descriptors_fixed")}functionsL(){if(te){letr=newError("state_prototype_fixed\nCannot set prototype of `$state` object\nhttps://svelte.dev/e/state_prototype_fixed");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/state_prototype_fixed")}functionaL(){if(te){letr=newError("state_unsafe_mutation\nUpdating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`\nhttps://svelte.dev/e/state_unsafe_mutation");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/state_unsafe_mutation")}functionlL(){if(te){letr=newError("svelte_boundary_reset_onerror\nA `<svelte:boundary>` `reset` function cannot be called while an error is still being handled\nhttps://svelte.dev/e/svelte_boundary_reset_onerror");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/svelte_boundary_reset_onerror")}varZa="font-weight: bold",Ja="font-weight: normal";functioncL(r){te?console.warn(`%c[svelte] await_reactivity_loss
%cDetected reactivity loss when reading \`${r}\`. This happens when state is read in an async function after an earlier \`await\`
%cAn async derived, \`${r}\` (${e}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
%cThe \`${r}\` attribute on \`${e}\` changed its value between server and client renders. The client value, \`${t}\`, will be ignored in favour of the server value
%c${r?`Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${r}`:"Hydration failed because the initial UI does not match what was rendered on the server"}
%cTried to unmount a component that was not mounted
https://svelte.dev/e/lifecycle_double_unmount`,Za,Ja):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}functionmL(){te?console.warn("%c[svelte] select_multiple_invalid_value\n%cThe `value` property of a `<select multiple>` element should be an array, but it received a non-array value. The selection will be kept as is.\nhttps://svelte.dev/e/select_multiple_invalid_value",Za,Ja):console.warn("https://svelte.dev/e/select_multiple_invalid_value")}functionME(r){te?console.warn(`%c[svelte] state_proxy_equality_mismatch
%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${r}\` will produce unexpected results
%cTried to unmount a state proxy, rather than a component
https://svelte.dev/e/state_proxy_unmount`,Za,Ja):console.warn("https://svelte.dev/e/state_proxy_unmount")}functiongL(){te?console.warn("%c[svelte] svelte_boundary_reset_noop\n%cA `<svelte:boundary>` `reset` function only resets the boundary the first time it is called\nhttps://svelte.dev/e/svelte_boundary_reset_noop",Za,Ja):console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}varRe=!1;functionDn(r){Re=r}varZe;functiontr(r){if(r===null)throwCd(),Gl;returnZe=r}functionYn(){returntr(hi(Ze))}functionS(r){if(Re){if(hi(Ze)!==null)throwCd(),Gl;Ze=r}}functionIn(r=1){if(Re){for(vare=r,t=Ze;e--;)t=hi(t);Ze=t}}functionel(r=!0){for(vare=0,t=Ze;;){if(t.nodeType===jo){varn=t.data;if(n==="]"){if(e===0)returnt;e-=1}else(n==="["||n==="[!"||n[0]==="["&&!isNaN(Number(n.slice(1))))&&(e+=1)}vari=hi(t);r&&t.remove(),t=i}}functionav(r){if(!r||r.nodeType!==jo)throwCd(),Gl;returnr.data}functionRE(r){returnr===this.v}function$E(r,e){returnr!=r?e==e:r!==e||r!==null&&typeofr=="object"||typeofr=="function"}functionOE(r){return!$E(r,this.v)}varJr=!1,Kl=!1,pa=!1;varO7="font-weight: bold",N7="font-weight: normal";functionuI(r){te?console.warn(`%c[svelte] state_snapshot_uncloneable
%c${r?`The following properties cannot be cloned with \`$state.snapshot\` \u2014 the return value contains the originals:
${r}`:"Value cannot be cloned with `$state.snapshot` \u2014 the original value was returned"}
`),n=[];for(leti=0;i<t.length;i++){leto=t[i],s=o.replaceAll("\\","/");if(o.trim()!=="Error"){if(o.includes("validate_each_keys"))return[];s.includes("svelte/src/internal")||s.includes("node_modules/.vite")||n.push(o)}}returnn}functionyL(r,e){if(!te)thrownewError("invariant(...) was not guarded by if (DEV)");r||jN(e)}var_t=null;functionXl(r){_t=r}vartl=null;functionAf(r){tl=r}varha=null;functionLE(r){ha=r}functionwe(r,e=!1,t){_t={p:_t,i:!1,c:null,e:null,s:r,x:null,r:Fe,l:Kl&&!e?{s:null,u:null,$:[]}:null},te&&(_t.function=t,ha=t)}functionCe(r){vare=_t,t=e.e;if(t!==null){e.e=null;for(varnoft)dI(n)}returnr!==void0&&(e.x=r),e.i=!0,_t=e.p,te&&(ha=_t?.function??null),r??{}}functionga(){return!Kl||_t!==null&&_t.l===null}varxd=[];functionbL(){varr=xd;xd=[],kE(r)}functionBr(r){if(xd.length===0&&!Ed){vare=xd;queueMicrotask(()=>{e===xd&&bL()})}xd.push(r)}functionwL(){for(;xd.length>0;)bL()}varpI=newWeakMap;functionBE(r){vare=Fe;if(e===null)returnje.f|=8388608,r;if(te&&rinstanceofError&&!pI.has(r)&&pI.set(r,U7(r,e)),(e.f&32768)===0&&(e.f&4)===0)throwte&&!e.parent&&rinstanceofError&&CL(r),r;ya(r,e)}functionya(r,e){if(!(e!==null&&(e.f&16384)!==0)){for(;e!==null;){if((e.f&128)!==0){if((e.f&32768)===0)throwr;try{e.b.error(r);return}catch(t){r=t}}e=e.parent}throwte&&rinstanceofError&&CL(r),r}}functionU7(r,e){lett=Ao(r,"message");if(!(t&&!t.configurable)){for(varn=dv?" ":" ",i=`
was changed by the error. Include the message below if you report this.</p> <!></div>`),dQ={hash:"svelte-bhgeqn",code:".qaMountFailed.svelte-bhgeqn{border:1pxsolidvar(--background-modifier-border);border-radius:var(--radius-m);padding:12px14px;margin:4px08px;background:var(--background-secondary);}.qaMountFailedHead.svelte-bhgeqn{display:flex;align-items:center;gap:8px;color:var(--text-warning,var(--text-normal));}.qaMountFailedTitle.svelte-bhgeqn{font-weight:var(--font-semibold);color:var(--text-normal);}.qaMountFailedBody.svelte-bhgeqn{margin:8px00;color:var(--text-muted);font-size:var(--font-ui-small,13px);max-width:68ch;}.qaMountFailedDetail.svelte-bhgeqn{margin:10px00;padding:8px10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller,12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function y0(r,e){ot(r,dQ);let t=he(e,"detail",3,"");var n=uQ(),i=I(n),o=I(i);Rt(o,{iconId:"alert-triangle",size:16});var s=A(o,2),a=I(s);S(s),S(i);var l=A(i,4);{var c=u=>{var d=cQ(),f=I(d,!0);S(d),de(()=>me(f,t())),$(u,d)};ne(l,u=>{t()&&u(c)})}S(n),de(()=>me(a,`QuickAdd couldn't display ${e.what??""}`)),$(r,n)}var pQ="thispartofQuickAdd";function qi(r,e,t,n={}){let i=new Set(r.childNodes),o;try{o=Bd(e,{target:r,props:t})}catch(a){return fQ(r,i,Yd(a),n)}let s=!1;return{ok:!0,destroy(){s||(s=!0,Gf(o))}}}function fQ(r,e,t,n){let i=n.what??pQ;for(let l of Array.from(r.childNodes))e.has(l)||l.remove();lt(t,`Couldn't display ${i}`);let o=r.ownerDocument.createElement("div");o.className="qa-mount-failed-host",r.appendChild(o);let s=null;try{s=Bd(n.fallbackComponent??y0,{target:o,props:{what:i,detail:t.message}})}catch{o.textContent=`QuickAdd couldn't display ${i}.`}let a=!1;return{ok:!1,destroy(){a||(a=!0,s&&Gf(s),o.remove())}}}var mB=require("obsidian");Tt();function tm(r){return r.trim().replace(/^\/+/,"")}function bu(r){return r.trim().toLowerCase().endsWith(".canvas")}function w0(r,e){let t=tm(e);if(!t||t.includes("{{"))return null;let n=r.vault.getAbstractFileByPath(t);return!n||!(n instanceof mB.TFile)||n.extension!=="canvas"?null:n}function hB(r,e){let n=r.workspace.getMostRecentLeaf?.()?.view;if(!n||n.getViewType?.()!=="canvas")return null;let i=tm(e),o=tm(n.file?.path??r.workspace.getActiveFile()?.path??"");if(!i||i!==o)return null;let s=n.canvas?.selection?Array.from(n.canvas.selection):[];if(s.length!==1)return null;let a=s[0]?.id;return typeof a=="string"&&a.length>0?a:null}function mQ(r){return typeof r=="string"?r:r&&typeof r=="object"&&"path"in r&&typeof r.path=="string"?r.path:"(missingfilepath)"}function hQ(r){return typeof r.x!="number"||typeof r.y!="number"||typeof r.width!="number"||typeof r.height!="number"?"":`${Math.round(r.x)},${Math.round(r.y)} \xB7 ${Math.round(r.width)}x${Math.round(r.height)}`}function b0(r,e){return r.length<=e?r:r.slice(0,e-1)+"\u2026"}async function gB(r,e){try{let t=await r.vault.cachedRead(e),n=JSON.parse(t);if(!n||typeof n!="object")return[];let i=n.nodes;if(!Array.isArray(i))return[];let o=i.filter(a=>!!a&&typeof a=="object"&&typeof a.id=="string").map(a=>{let l=a.type==="text"?"text":a.type==="file"?"file":"other",c=hQ(a);if(l==="text"){let m=(typeof a.text=="string"?a.text:"").split(`
`).map(w=>w.trim()).filter(w=>w.length>0),v=b0(m[0]??"(emptytextcard)",90),g=[`${m.length} line${m.length===1?"":"s"}`];c&&g.push(c);let y=g.join("\xB7");return{id:a.id,type:l,title:v,subtitle:y,searchText:`${a.id} ${v} ${y}`.toLowerCase(),capturable:!0,capturableReason:""}}if(l==="file"){let p=mQ(a.file),m=ir.test(p),v=m?"":"Canvasfilecardsmustlinktomarkdownfiles(.md).",g=b0(p.split("/").pop()??p,90),y=[b0(p,120)];c&&y.push(c),m||y.push("Notcapturableinthisversion");let w=y.join("\xB7");return{id:a.id,type:l,title:g,subtitle:w,searchText:`${a.id} ${g} ${w}`.toLowerCase(),capturable:m,capturableReason:v}}let d=`Unsupported node (${typeof a.type=="string"&&a.type.length>0?a.type:"unknown"})`,f=c||"Typeisnotcurrentlycapturable";return{id:a.id,type:l,title:d,subtitle:f,searchText:`${a.id} ${d} ${f}`.toLowerCase(),capturable:!1,capturableReason:"ThisCanvasnodetypeisnotcapturable."}}),s={text:0,file:1,other:2};return o.sort((a,l)=>{let c=s[a.type]-s[l.type];return c!==0?c:a.title.localeCompare(l.title)})}catch{return[]}}qt();function _u(r){return/\{\{[^}]*\}\}/.test(r)}fl();Fo();Wt();Tt();var YZ=["noteContent","captureTarget","fileName","lineTarget"],KZ=["captureTarget","fileName"],wi=YZ,jU=3;function Je(r,e,t=r.endsWith(":}}")?2:0){return{insert:r,description:e,caretOffset:t}}var XZ=[{regex:W2,contexts:wi,suggestion:Je("{{VALUE}}","Asksyoufortextwhenthechoiceruns")},{regex:z2,contexts:wi,suggestion:Je("{{VALUE:}}","Asksonceandreusestheanswerbyname,orlistsoptionstopickfrom"),expansions:()=>[Je("{{VALUE:title}}",'Asks once, then reuses the answer as "title"'),Je("{{VALUE:option1,option2,option3}}","Asksyoutopickoneoftheseoptions"),Je("{{VALUE:option1,option2,option3|custom}}","Same,butyoucanalsotypeyourown"),Je("{{VALUE:title|label:Notetitle}}","Wordsthepromptyourself"),Je("{{VALUE:option1,option2|label:Pickone}}","Alistwithyourownprompttext"),Je("{{VALUE:title|label:Notetitle|default:Untitled}}","Opensthepromptwithanansweralreadyfilledin"),Je("{{VALUE:<items>|text:<displayitems>}}","Showsonelabelinthelistandinsertsanother"),Je("{{VALUE:option1,option2|name:category}}","Namesthepick,so{{VALUE:category}}reusesit"),Je("{{VALUE:title|case:kebab}}","Reshapestheanswer;type|case:foreverystyle"),Je("{{VALUE:title|trim}}","Trimswhitespaceofftheanswer"),Je("{{VALUE:title|optional}}","Letsthepromptbeskipped,leavingitempty")]},{regex:q2,contexts:wi,suggestion:Je("{{NAME}}","Anothernamefor{{VALUE}};theydothesamething")},{regex:H2,contexts:wi,suggestion:Je("{{VDATE:}}",'Asks you for a date; "tomorrow" works'),expansions:()=>[Je("{{VDATE:date,YYYY-MM-DD}}",'Asks for a date, reused by name as "date"'),Je("{{VDATE:date,YYYY-MM-DD|today}}","Same,withtodayfilledin"),Je("{{VDATE:dueDate,YYYY-MM-DD|nextmonday}}","Same,startingatnextMonday"),Je("{{VDATE:dueDate,YYYY-MM-DD|optional}}","Same,butskippable")]},{regex:Q2,contexts:wi,suggestion:Je("{{FIELD:}}","Suggestsvaluesapropertyalreadyhasinyourvault,like{{FIELD:project}}")},{regex:X2,contexts:wi,suggestion:Je("{{FILE:}}","Picksanotefromafolder"),expansions:({context:r})=>{let e=[Je("{{FILE:<folder>}}","Picksanotefromthatfolderandinsertsitsname")];return KZ.includes(r)||e.push(Je("{{FILE:<folder>|link}}","Same,butinsertsalinktothenote"),Je("{{FILE:<folder>|path}}","Same,butinsertsitsfullpath"),Je("{{FILE:<folder>|optional}}","Same,butskippable")),e.push(Je("{{FILE:<folder>|custom}}","Same,butyoucanalsotypeanamethatisnotthereyet")),e}},{regex:eB,contexts:wi,suggestion:Je("{{MVALUE}}","Asksyouforamathformula(LaTeX),withalivepreview")},{regex:U2,contexts:wi,suggestion:Je("{{DATE}}","Today's date, as YYYY-MM-DD")},{regex:V2,contexts:wi,suggestion:Je("{{DATE:}}","Today'sdateinaformatyouchoose,like{{DATE:MMMMDo}}"),expansions:({formatDate:r})=>[...["YYYY-MM-DD","MMMMDo,YYYY","dddDMMM","gggg-[W]ww"].map(e=>Je(`{{DATE:${e}}}`,r(e))),Je("{{DATE+7}}","Sevendaysfromtoday"),Je("{{DATE:YYYY-MM-DD|startof
/* Let clicks fall through to the container so a single handler owns toggling. */.checkbox-container.svelte-1bigjf0>input:where(.svelte-1bigjf0){pointer-events:none;}`};function lr(r,e){we(e,!0),ot(r,iJ);let t=he(e,"checked",15),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0),s=O(()=>t()??!1);function a(){n()||(t(!h(s)),o()?.(t()))}function l(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a())}var c=nJ();let u;var d=I(c);gr(d),S(c),de(()=>{u=wt(c,1,"checkbox-container svelte-1bigjf0",null,u,{"is-enabled":h(s),"is-disabled":n()}),ke(c,"aria-checked",h(s)),ke(c,"aria-label",i()),ke(c,"tabindex",n()?-1:0),qd(d,h(s))}),De("click",c,a),De("keydown",c,l),$(r,c),Ce()}Et(["click","keydown"]);var oJ=z("<option> </option>"),sJ=z('<select class="dropdown"></select>');function Jt(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0);var s=sJ();ar(s,21,()=>e.options,a=>a.value,(a,l)=>{var c=oJ(),u=I(c,!0);S(c);var d={};de(()=>{me(u,h(l).label),d!==(d=h(l).value)&&(c.value=(c.__value=h(l).value)??"")}),$(a,c)}),S(s),de(()=>{s.disabled=n(),ke(s,"aria-label",i())}),De("change",s,()=>o()?.(t())),QI(s,t),$(r,s),Ce()}Et(["change"]);zs();Me();Cr();function Sm(r){return r==="Multi"?"folder":"choice"}function gV(r){return r==="Multi"?"Folder":"Choice"}function oee(r){return`${gV(r)}name`}async function g_(r,e,t){try{let i=(await Sr.Prompt(r,oee(t),void 0,e)).trim();return!i||i===e?null:i}catch(n){return Dt(n)||F.logError(Yd(n,"Could not rename")),null}}var see=z('<h2 class="choiceNameHeader"><button type="button" class="choiceNameHeaderButton qa-rename-title-button"><span class="choiceNameHeaderText"> </span> <span class="choiceNameHeaderIcon" aria-hidden="true"><!></span></button></h2>');function py(r,e){we(e,!0);let t=he(e,"name",15);async function n(){let u=await g_(e.app,t());u&&t(u)}var i=see(),o=I(i),s=I(o),a=I(s,!0);S(s);var l=A(s,2),c=I(l);Rt(c,{iconId:"pencil",size:16}),S(l),S(o),S(i),de(()=>{ke(o,"aria-label",`Rename${t()}`),me(a,t())}),De("click",o,n),$(r,i),Ce()}Et(["click"]);fl();Fo();var ni=class extends mn{constructor(t,n,i,o=1/0){super(t,n);this.app=t;this.inputEl=n;this.items=i;this.maxSuggestions=o;this.items=i.map(s=>fn(s))}getSuggestions(t){let n=Cc(t).toLowerCase(),i=this.items.filter(s=>s.toLowerCase().includes(n));return i.length===0&&this.close(),i.slice(0,this.maxSuggestions)}selectSuggestion(t){this.inputEl.value=t,this.inputEl.trigger("input"),this.close()}renderSuggestion(t,n){if(!t)return;let i=sy(t),o=sy(this.getCurrentQuery());t.toLowerCase().endsWith(".md")&&o.toLowerCase().startsWith(`${i.toLowerCase()}.`)&&(o=i),this.renderMatch(n,i,o)}getCurrentQuery(){return this.inputEl.value}};function aee(r){return r?Array.isArray(r)?r:[r]:[]}function hp(r,e){let t=aee(e(r));return{destroy(){t.forEach(n=>n.destroy())}}}var lee=z("<textarea></textarea>"),cee=z('<input type="text"/>'),uee=z('<!> <div aria-live="polite"> </div>',1);function Ci(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"placeholder",3,void 0),i=he(e,"inputKind",3,"text"),o=he(e,"required",3,!1),s=he(e,"requiredMessage",3,"This field is required"),a=he(e,"disabled",3,!1),l=he(e,"validator",3,void 0),c=he(e,"trim",3,!0),u=he(e,"suggestions",3,void 0),d=he(e,"maxSuggestions",3,1/0),f=he(e,"makeSuggesters",19,()=>[]),p=he(e,"app",3,void 0),m=he(e,"id",3,void 0),v=he(e,"ariaLabel",3,void 0),g=he(e,"onChange",3,void 0),y=Ae(!1),w=Ae(""),x=Ae("neutral"),C=0,_=!1,E=`qa-hint-${Math.random().toString(36).slice(2)}`,D=Y=>c()?Y.trim():Y;function P(Y,X=!1,ae="neutral"){Z(y,X,!0),Z(w,Y??"",!0),Z(x,X?"neutral":ae,!0)}async function V(Y){if(o()&&D(Y).length===0)return P(s(),!0),!1;if(!l())return P(void 0),!0;let X=++C,ae=await Promise.resolve(l()(Y));return X!==C||_?!0:typeof ae=="boolean"?(P(ae?void 0:"Invalid value",!ae),ae):typeof ae=="string"?(P(ae,!0),!1):(P(ae.message??(ae.valid?void 0:"Invalid value"),!ae.valid,ae.valid?ae.variant??"neutral":"neutral"),ae.valid)}function j(Y){let X=Y.currentTarget.value;t(X),g()?.(X)}hr(()=>{o();let Y=t();V(Y)}),hr((
text is inserted under it. Use the toggles below to control placement within that
section.</div>`),xj=z("<!> <!>",1),ele=z(`<div class="setting-item-description">Inline insertion needs a single-line target. The line break (\\n) can't be
matched on the same line \u2014 remove it, or turn off "Inline insertion".</div>`),Ej=z("<!> <!> <!>",1),tle=z(`<div class="setting-item-description">No sorting: newest-first prepends the new section above existing ones;
oldest-first appends it below.</div>`),rle=z(`<div class="setting-item-description">This heading uses a date token QuickAdd can't auto-read for sorting. Pick
"Date" and enter the format, or sections stay in insertion order.</div>`),nle=z(`<div class="setting-item-description">The "Insert after" heading is created at its sorted position among ALL
same-level headings in the note (it is not scoped to one parent section). It
does NOT re-sort headings you already have; only the new one is placed. Use
"Insert at end of section" above for newest-on-top vs. appended entries within
each section.</div> <!> <!> <!> <!> <!> <!>`,1),ile=z("<!> <!> <!> <!> <!>",1);functionFR(r,e){we(e,!0);lett=he(e,"insertAfter",15);t().inline===void0&&t(t().inline=!1,!0),t().replaceExisting===void0&&t(t().replaceExisting=!1,!0),t().promptHeading===void0&&t(t().promptHeading=!1,!0),t().insertAtEnd===void0&&t(t().insertAtEnd=!1,!0),t().considerSubsections===void0&&t(t().considerSubsections=!1,!0),t().blankLineAfterMatchMode||t(t().blankLineAfterMatchMode="auto",!0),t().createIfNotFound||t(t().createIfNotFound=!1,!0),t().createIfNotFoundLocation||t(t().createIfNotFoundLocation=uo,!0);letn=[B=>newHi(e.app,B,e.plugin,"lineTarget")],i=[{value:"auto",label:"Auto (headings only)"},{value:"skip",label:"Always skip"},{value:"none",label:"Never skip"}],o=O(()=>t().inline?[{value:uo,label:"Top"},{value:lc,label:"Bottom"},{value:cc,label:"Cursor"}]:[{value:uo,label:"Top"},{value:lc,label:"Bottom"},{value:cc,label:"Cursor"},{value:_a,label:"Ordered (place new section among siblings)"}]),s=[{value:"insertion",label:"Insertion order (no sorting)"},{value:"lexical",label:"Text (A\u2192Z)"},{value:"numeric",label:"Number"},{value:"date",label:"Date"},{value:"semver",label:"Version (semver)"}],a=[{value:"desc",label:"Newest / highest first"},{value:"asc",label:"Oldest / lowest first"}],l=[{value:"bottom",label:"Sort existing unparseable headings to bottom"},{value:"top",label:"Sort existing unparseable headings to top"}],c=Ae(!!t().orderBy),u=O(()=>t().createIfNotFoundLocation===_a),d=O(()=>t().createIfNotFound&&h(u)),f=O(()=>newfh(e.app,e.plugin)),p=Ae(!1);hr(()=>{letB=t().after??"",ie=h(f);if(!t().inline||B===""){Z(p,!1);return}letW=!1;returnie.format(B).then(Y=>{W||Z(p,/[\n\r]/.test(Y),!0)}).catch(()=>{W||Z(p,!1)}),()=>{W=!0}});letm=O(()=>t().orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"}),v=O(()=>/\{\{V?DATE\b/i.test(t().after??"")),g=O(()=>h(d)&&t().orderBy?.by==="insertion"&&h(v)&&!PR(t().after??""));hr(()=>{if(!h(d))return;letB=PR(t().after??"");if(!t().orderBy){t(t().orderBy={by:B?"date":"insertion",direction:"desc",dateFormat:B,unparseable:"bottom"},!0);return}!h(c)&&(t().orderBy.by==="insertion"||t().orderBy.by==="date")&&(t(t().orderBy.by=B?"date":"insertion",!0),t(t().orderBy.dateFormat=B,!0))});functiony(B){t(t().createIfNotFoundLocation=B,!0),B===_a?t(t().inline=!1,!0):(t(t().orderBy=void0,!0),Z(c,!1))}functionw(B){Z(c,!0),t().orderBy&&t(t().orderBy.by=B,!0)}functionx(B){t().promptHeading||B&&!t().after.startsWith("#")&&(t(t().considerSubsections=!1,!0),newTj.Notice("Consider subsections requires the target to be a heading (starts with #)"))}functionC(B){B&&(t(t().inline=!1,!0),t(t().replaceExisting=!1,!0))}var_=ile(),E=Pe(_);$e(E,{name:"Choose heading when capturing",desc:"Instead of typing a target line now, show a dropdown of the target note's headings when you run this capture and insert under the one you pick.",control:ie=>{lr(ie,{onchange:C,getchecked(){returnt().promptHeading},setchecked(W){t(t().promptHeading=W,!0)}})},$$slots:{control:!0}});varD=A(E,2);{varP=B=>{varie=Jae();$(B,ie)},V=B=>{varie=Ej(),W=Pe(ie);ss(W,{name:"Insert after",desc:"Insert capture after specified text. Accepts format syntax. Tip: use a heading (starts with #) to target a section. Blank line handling is configurable below.",children:(ge,be=Vt)=>{varxe=xj(),Ue=Pe(xe);Ci(Ue,{getid(){returnbe()},placeholder:"Insert after",required:!0,requiredMessage:"Insert after text is required",getmakeSuggesters(){returnn},getvalue(){returnt().after},setvalue(Ne){t(t().after=Ne,!0)}});var$t=A(Ue,2);hs($t,{getvalue(){returnt().after},formatterKind:"lineTarget",getapp(){returne.app},getplugin(){returne.plugin}}),$(ge,xe)},$$slots:{default:!0}});varY=A(W,2);{letpe=be=>{lr(be,{getdisabled(){returnh(u)},getchecked(){returnt().inline},setchecked(xe){t(t().inline=xe,!0)}})},ge=O(()=>h(u)?"Inline insertion can't be combined with ordered placement.":"Insert captured content on the same line, immediately after the matched text (no newline added).");$e(Y,{name:"Inline insertion",getdesc(){returnh(g
placement.</div>`),sle=z("<!> <!> <!> <!>",1);function $R(r,e){we(e,!0);let t=he(e,"choice",15),n=O(()=>!!t().captureToActiveFile),i=O(()=>t().insertAfter?.enabled?"after":t().insertBefore?.enabled?"before":t().newLineCapture?.enabled?t().newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":h(n)?t().activeFileWritePosition==="top"?"activeTop":t().activeFileWritePosition==="bottom"||t().prepend?"bottom":"top":t().prepend?"bottom":"top"),o=O(()=>[{value:"top",label:h(n)?"At cursor":"Top of file"},...h(n)?[{value:"activeTop",label:"Top of file (after frontmatter)"},{value:"newLineAbove",label:"New line above cursor"},{value:"newLineBelow",label:"New line below cursor"}]:[],{value:"after",label:"After line\u2026"},{value:"before",label:"Before line\u2026"},{value:"bottom",label:"Bottom of file"}]);function s(g){if(t(t().prepend=!1,!0),t(t().insertAfter.enabled=!1,!0),t(t().insertAfter.promptHeading=!1,!0),t(t().insertAfter.inline=!1,!0),t(t().insertAfter.replaceExisting=!1,!0),t().insertBefore||t(t().insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"},!0),t(t().insertBefore.enabled=!1,!0),t().newLineCapture||t(t().newLineCapture={enabled:!1,direction:"below"},!0),t(t().newLineCapture.enabled=!1,!0),t(t().activeFileWritePosition="cursor",!0),g==="top"){h(n)||t(t().prepend=!1,!0);return}if(g==="activeTop"){h(n)&&t(t().activeFileWritePosition="top",!0);return}if(g==="bottom"){h(n)?t(t().activeFileWritePosition="bottom",!0):t(t().prepend=!0,!0);return}if(g==="newLineAbove"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="above",!0);return}if(g==="newLineBelow"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="below",!0);return}if(g==="before"){t(t().insertBefore.enabled=!0,!0);return}t(t().insertAfter.enabled=!0,!0)}let a=O(()=>{let g=typeof t().captureTo=="string"&&bu(t().captureTo),y=e.app.workspace.getActiveViewOfType(_j.FileView)?.getViewType()==="canvas",w=h(n)&&!t().insertAfter.enabled&&!t().insertBefore?.enabled&&!t().newLineCapture?.enabled&&(t().activeFileWritePosition??"cursor")==="cursor"&&!t().prepend;return!(!(t().newLineCapture?.enabled||w)||(h(n)?!y:!g))});var l=sle(),c=Pe(l);{let g=w=>{Jt(w,{get value(){return h(i)},get options(){return h(o)},onchange:s})},y=O(()=>h(n)?"Where to place the capture in the current file.":"Where to place the capture in the target file.");$e(c,{name:"Write position",get desc(){return h(y)},control:g,$$slots:{control:!0}})}var u=A(c,2);{var d=g=>{FR(g,{get app(){return e.app},get plugin(){return e.plugin},get insertAfter(){return t().insertAfter},set insertAfter(y){t(t().insertAfter=y,!0)}})};ne(u,g=>{t().insertAfter.enabled&&g(d)})}var f=A(u,2);{var p=g=>{RR(g,{get app(){return e.app},get plugin(){return e.plugin},get insertBefore(){return t().insertBefore},set insertBefore(y){t(t().insertBefore=y,!0)}})};ne(f,g=>{t().insertBefore?.enabled&&g(p)})}var m=A(f,2);{var v=g=>{var y=ole();$(g,y)};ne(m,g=>{h(a)&&g(v)})}$(r,l),Ce()}var ale=new Set(["activity","airplay","alarm-check","alarm-clock-off","alarm-clock","alarm-minus","alarm-plus","album","alert-circle","alert-octagon","alert-triangle","align-center-horizontal","align-center-vertical","align-center","align-end-horizontal","align-end-vertical","align-horizontal-distribute-center","align-horizontal-distribute-end","align-horizontal-distribute-start","align-horizontal-justify-center","align-horizontal-justify-end","align-horizontal-justify-start","align-horizontal-space-around","align-horizontal-space-between","align-justify","align-left","align-right","align-start-horizontal","align-start-vertical","align-vertical-distribute-center","align-vertical-distribute-end","align-vertical-distribute-start","align-vertical-justify-center","align-vertical-justify-end","align-vertical-justify-start","align-vertical-space-around","align-vertical-space-between","anchor","aperture","archive","arrow-big-down","arrow-big-left","arrow-big-right","arrow-big-up","arrow-down-circle","arrow-down-left","arrow-down-right","arrow-down","arrow-left-circle","arrow-left-righ
}.quickAddCommandList.svelte-ee11ws{max-width:50%;margin:12pxauto;}`};function LR(r,e){we(e,!0),ot(r,wle);var t=ble();ar(t,20,()=>e.folders,n=>n,(n,i)=>{var o=yle(),s=I(o),a=I(s,!0);S(s);var l=A(s,2);{let c=O(()=>`Removefolder${i}`);er(l,{iconId:"trash-2",get label(){return h(c)},onclick:()=>e.deleteFolder(i)})}S(o),de(()=>me(a,i)),$(n,o)}),S(t),$(r,t),Ce()}function Bj(r){return r.enabled?r.chooseWhenCreatingNote?"prompt":r.createInSameFolderAsActiveFile?"active-file":"specified":"obsidian-default"}function Uj(r,e){switch(e){case"obsidian-default":return{...r,enabled:!1,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"specified":return{...r,enabled:!0,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"active-file":return{...r,enabled:!0,createInSameFolderAsActiveFile:!0,chooseWhenCreatingNote:!1};case"prompt":return{...r,enabled:!0,chooseWhenCreatingNote:!0,createInSameFolderAsActiveFile:!1}}}var Vj=[{value:"obsidian-default",label:"Obsidian default"},{value:"specified",label:"In a specific folder"},{value:"active-file",label:"Same folder as current file"},{value:"prompt",label:"Ask for folder each time"}],qj={"obsidian-default":"Use Obsidian's \u201CDefault location for new notes\u201D setting.",specified:"Create the note in the folder(s) below. With multiple folders, you'll be asked which one when the note is created.","active-file":"Create the note next to the currently active file (falls back to the vault root if no file is open).",prompt:"Choose any folder in the vault when the note is created."};Tt();Tt();function NA(r,e){if(!r.fileNameFormat?.enabled)return!0;let t=e.trim().toLowerCase();return t===Ms.toLowerCase()||t===N2.toLowerCase()}function BR(r,e){return r.discoverExistingNotesBeforeCreate===!0&&NA(r,e)}function UR(r,e,t){return!(!BR(r,e)||t!=null)}Tt();function LA(r){if(!r?.enabled||r.chooseWhenCreatingNote||r.chooseFromSubfolders||r.createInSameFolderAsActiveFile)return;let e=r.folders??[];if(e.length!==1)return;let t=e[0]?.trim();if(t&&!t.includes("{{")&&!dc.test(t))return t}var Cle=z("<!> <!> <!>",1),xle=z(`<divclass="qa-folder-mode-warning">Addatleastonefolder.Withnone,thenotefallsbacktotheactive
file's folder (or you'llbepromptedtopickoneifnofileisopen).</div>`),Ele=z('<div class="folderSelectionContainer"><div class="folderList"><!></div> <div class="folderInputContainer"><input type="text" class="qa-folder-path-input" placeholder="Folder path" aria-label="Folder path"/> <button type="button" class="mod-cta">Add</button></div></div> <!> <!>',1),Tle=z("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1);function VR(r,e){we(e,!0);let t=he(e,"choice",15),n=O(()=>e.plugin.getTemplateFiles().map(ye=>ye.path)),i=O(()=>Nc(Ns(e.app)));function o(ye){let We=ye.trim();return We?_u(We)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:po(e.app,We)!==null||"Template not found":!0}let s=[ye=>new Hi(e.app,ye,e.plugin,"fileName")],a=O(()=>NA(t(),t().fileNameFormat.enabled?t().fileNameFormat.format:Ms)),l=O(()=>h(a)?"For the default note-title prompt, show matching notes first. Choosing one opens it unchanged; choosing the create row continues with this template.":"Only available when the file name prompt is the default note title: no custom format, {{VALUE}}, or {{NAME}}."),c=O(()=>Bj(t().folder)),u=O(()=>qj[h(c)]),d=O(()=>h(c)==="specified"&&t().folder.folders.length===0);function f(ye){t(t().folder=Uj(t().folder,ye),!0)}let p=Ae(""),m;function v(ye){return m=new $A(e.app,ye,h(i),t().folder.folders),m}hr(()=>{m?.updateCurrentItems(t().folder.folders)});function g(){let ye=h(p).trim();if(ye){if(t().folder.folders.some(We=>We===ye)){F.logWarning("cannot add same folder twice.");return}t().folder.folders.push(ye),Z(p,"")}}function y(ye){t(t().folder.folders=t().folder.folders.filter(We=>We!==ye),!0)}function w(ye){ye.key==="Enter"&&g()}let x=O(()=>Rj(t().fileExistsBehavior)),C=O(()=>h(x)!=="prompt"&&h(x)!=="keep"),_=O(()=>Pj(h(x)==="update"?"update":"create")),E=O(()=>t().fileExistsBehavior.kind==="apply"?t().fileExistsBehavior.mode:h(_)[0].id);function D(ye){t(t().fileExistsBehavior=$j(ye,t().fileExistsBehavior),!0)}function P(ye){t(t().fileExistsBehavior={kind:"apply",mode:ye},!0)}var V=Tle(),j=Pe(V);py(j,{get app(){return e.app},get name(){return t().name},set name(ye){t(t().name=ye,!0)}});var oe=A(j,2);$e(oe,{name:"Template",heading:!0});var se=A(oe,2);ss(se,{name:"Template path",desc:"Path to the template this choice creates notes from.",children:(We,mt=Vt)=>{Ci(We,{get id(){return mt()},get value(){return t().templatePath},placeholder:"Template path",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,validator:o,onChange:He=>t(t().templatePath=He.trim(),!0)})},$$slots:{default:!0}});var M=A(se,2);ss(M,{name:"File name format",desc:"Set the file name format. When off, QuickAdd asks for the note title.",get bodyVisible(){return t().fileNameFormat.enabled},control:mt=>{lr(mt,{get checked(){return t().fileNameFormat.enabled},set checked(He){t(t().fileNameFormat.enabled=He,!0)}})},children:(mt,He=Vt)=>{var _e=Cle(),Be=Pe(_e);Ci(Be,{get id(){return He()},placeholder:"File name format",get makeSuggesters(){return s},get value(){return t().fileNameFormat.format},set value(yr){t(t().fileNameFormat.format=yr,!0)}});var ut=A(Be,2);qp(ut,{get value(){return t().fileNameFormat.format}});var or=A(ut,2);{let yr=O(()=>LA(t().folder));hs(or,{get value(){return t().fileNameFormat.format},formatterKind:"fileName",get targetFolderPath(){return h(yr)},get app(){return e.app},get plugin(){return e.plugin}})}$(mt,_e)},$$slots:{control:!0,default:!0}});var U=A(M,2);$e(U,{name:"Location",heading:!0});var q=A(U,2);$e(q,{name:"New note location",get desc(){return h(u)},control:We=>{Jt(We,{get value(){return h(c)},get options(){return Vj},ariaLabel:"New note location",onchange:f})},$$slots:{control:!0}});var B=A(q,2);{var ie=ye=>{var We=Ele(),mt=Pe(We),He=I(mt),_e=I(He);LR(_e,{get folders(){return t().folder.folders},deleteFolder:y}),S(He);var Be=A(He,2),ut=I(Be);gr(ut),cn(()=>co(ut,()=>h(p),ur=>Z(p,ur))),Fr(ut,(ur,dt)=>hp?.(ur,dt),()=>v);var or=A(ut,2);S(Be),S(mt);var yr=A(mt,2);{var Pt=ur=>{var dt=xle();$(ur,dt)};ne(yr,ur=>{h(d)&&ur(Pt)})}var Ar=A(yr,2);$e(Ar,{name:
Inordertobeiterable,non-arrayobjectsmusthavea[Symbol.iterator]()method.`)}function Rle(){throw new TypeError(`Invalidattempttodestructurenon-iterableinstance.
Inordertobeiterable,non-arrayobjectsmusthavea[Symbol.iterator]()method.`)}function Gp(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=e$(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var n=0,i=function(){};return{s:i,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalidattempttoiteratenon-iterableinstance.
or edited here. Nothing has been changed or deleted, and QuickAdd will not
overwrite it.</p> <p class="qaDataUnreadableBody svelte-ktqmtm">It's stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this
vault. Make a copy of that file before editing it.</p></div>`),Eue={hash:"svelte-ktqmtm",code:".qaDataUnreadable.svelte-ktqmtm {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaDataUnreadableHead.svelte-ktqmtm {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaDataUnreadableTitle.svelte-ktqmtm {font-weight:var(--font-semibold);color:var(--text-normal);}.qaDataUnreadableBody.svelte-ktqmtm {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}"};functionO$(r,e){ot(r,Eue);vart=xue(),n=I(t),i=I(n);Rt(i,{iconId:"alert-triangle",size:16});varo=A(i,2),s=I(o);S(o),S(n),In(4),S(t),de(()=>me(s,`QuickAdd couldn't read ${e.what??""}`)),$(r,t)}varQh=class{constructor(e){this.obsidianCommands=[];this.scriptCandidates=[];this.commandListHandle=null;this.commandListProps=null;this.containerEl=null;this.unreadableCardHandle=null;this.app=e.app,this.plugin=e.plugin,this.unreadable=Di(e.commands),this.commandsRef=d$(e.commands).commands,this.choices=e.choices,this.onCommandsChange=e.onCommandsChange,this.conditionalHandlers=e.conditionalHandlers,this.loadObsidianCommands(),this.loadScriptCandidates()}render(e){returnthis.destroy(),this.containerEl=e,e.empty(),e.addClass("quickAddCommandEditor"),this.unreadable?(this.renderUnreadableCard(e),!1):this.renderCommandList(e)?(this.renderCommandBar(e),this.renderAddObsidianCommandSetting(e),this.renderAddEditorCommandSetting(e),this.renderAddUserScriptSetting(e),this.renderAddChoiceSetting(e),!0):!1}renderUnreadableCard(e){lett=e.createDiv("commandList");this.unreadableCardHandle=qi(t,O$,{what:"this macro's commands"},{what:"this macro's commands"})}destroy(){this.commandListHandle?.destroy(),this.commandListHandle=null,this.commandListProps=null,this.unreadableCardHandle?.destroy(),this.unreadableCardHandle=null}loadObsidianCommands(){Object.keys(this.app.commands.commands).forEach(e=>{lett=this.app.commands.commands[e];this.obsidianCommands.push(newfx(t.name,t.id))})}loadScriptCandidates(){this.scriptCandidates=Ak(this.app)}renderCommandList(e){lett=e.createDiv("commandList");returnthis.commandListProps=HG({app:this.app,plugin:this.plugin,commands:this.commandsRef,deleteCommand:asyncn=>{leti=this.commandsRef.find(a=>a.id===n);if(!i)throwF.logError("command not found"),newError("command not found");if(!awaitXi.Prompt(this.app,"Are you sure you wish to delete this command?",`If you click yes, you will delete '${i.name}'.`))return;if(!awaitdx(this.app,i)){newFi.Notice("Could not clear user script secrets. Command was not deleted.");return}this.commandsRef=this.commandsRef.filter(a=>a.id!==n),this.emitCommandsChanged()},saveCommands:n=>{this.commandsRef=n,this.onCommandsChange?.(n)},onConfigureCondition:this.conditionalHandlers?.configureCondition,onEditThenBranch:this.conditionalHandlers?.editThenBranch,onEditElseBranch:this.conditionalHandlers?.editElseBranch}),this.commandListHandle=qi(t,T$,this.commandListProps,{what:"this macro's commands"}),this.commandListHandle.ok}renderCommandBar(e){lett=e.createDiv("quickCommandContainer");this.addChoiceButton(t,"Capture",Bh),this.addChoiceButton(t,"Template",rd),this.addOpenFileCommandButton(t),this.addWaitCommandButton(t),this.addConditionalCommandButton(t),ce.getState().disableOnlineFeatures||this.addAIAssistantCommandButton(t)}renderAddObsidianCommandSetting(e){lett,n=()=>{leti=t.getValue(),o=this.obsidianCommands.find(a=>a.name===i);if(!o){F.logError(`Could not find Obsidian command with name "${i}"`);return}lets=newfx(o.name,o.commandId);s.generateId(),this.addCommand(s),t.setValue("")};newFi.Setting(e).setName("Obsidian command").setDesc("Add an Obsidian command").addText(i=>{t=i,i.inputEl.addClass("qa-command-sequence-input"),i.setPlaceholder("Obsidian command"),newni(this.app,i.inputEl,this.obsidianCommands.map(o=>o.name)),i.inputEl.addEventListener("keypress",o=>{o.key==="Enter"&&n()})}).addButton(i=>i.setCta().setButtonText("Add").o
/* The chevron sits tighter to the label than the leading plus. */.qaNewChoiceBtn.svelte-a7rp4hsvg:last-child{margin-left:-0.1em;opacity:0.85;}
/* Per-folder ("compact") controls render as quiet, clickable text links \u2014 not
filled buttons \u2014 so they read as "add inside this folder" affordances and
don't compete with the global primary CTA, especially when repeated across
/* Mobile/touch: stretch so the two buttons fill the bar width instead of
cramming to the right. Driven by \`fill\` (Platform.isMobile from the bottom
bar) because viewport media queries don't fire under desktop mobile-emulation. */.qaAddChoiceControls.fill.svelte-a7rp4h{flex:1;}.qaAddChoiceControls.fill.svelte-a7rp4hbutton:where(.svelte-a7rp4h){flex:1;justify-content:center;}
/* Narrow desktop windows stack the non-compact controls. Filled controls (the
mobile bottom bar) are excluded so this can't override \`.fill\`'s side-by-side
50/50 layout on a phone-width viewport (Platform.isMobile + width <= 800px). */
/* Full-width collapse toggle: reset native <button> chrome while keeping
native keyboard activation + aria-expanded. It hosts the shared icon
column (the chevron), so the folder NAME lands on the exact leaf-name x
for free \u2014 same 8px column gap as the leaf rows. */.multiChoiceListItemName.svelte-1jxjn06{flex:11auto;min-width:0;align-self:stretch;display:flex;align-items:center;
/* Obsidian's base button centers flex content; the name must not rely
on a growing child to stay left (it stopped growing for the count). */justify-content:flex-start;gap:8px;background:transparent;border:none;box-shadow:none;padding:0;
/* Obsidian's base button rule sets height: var(--input-height) (30px),
which would make folder rows 4px taller than leaf rows \u2014 the exact
rhythm break this redesign removes. */height:auto;min-height:0;font:inherit;color:inherit;text-align:left;cursor:pointer;
/* Suppress double-tap-zoom + its click delay on touch \u2014 proper touch hygiene
for a tap target, and reduces the ghost-click the dedupe above also guards. */touch-action:manipulation;}
/* The count reads as part of the label ("Misc \xB7 12"), so the name must not
grow \u2014 it keeps its ellipsis via flex-shrink + the shared min-width: 0. */.multiChoiceListItemName.svelte-1jxjn06.choiceListItemName{flex:01auto;}
/* Same slot, weight and colour as the empty-folder hint in ChoiceList, so a
folder we cannot read reads as a variation of "empty" rather than an alarm. */.qaUnreadableFolder.svelte-1jxjn06{margin:0;padding:6px8px8px;color:var(--text-faint);font-size:var(--font-ui-smaller,12px);line-height:1.4;}.qaUnreadableFolder.svelte-1jxjn06code:where(.svelte-1jxjn06){font-size:inherit;}.qaFolderCount.svelte-1jxjn06{flex:00auto;color:var(--text-faint);font-size:var(--font-ui-smaller,12px);font-variant-numeric:tabular-nums;line-height:1;}.multiChoiceListItemName.svelte-1jxjn06:focus-visible{outline:2pxsolidvar(--interactive-accent);outline-offset:1px;border-radius:var(--radius-s,4px);}
/* Just the indent \u2014 the drop-into-folder ring is drawn on the ACTUAL dndzone
(.choiceList, in ChoiceList.svelte) so the highlighted area equals the
droppable area (WYSIWYG); it is NOT drawn on this wrapper, which extends past
the zone to the add-row/hint. The ::before is an indent GUIDE under the
parent's icon column (x = row padding 8px + half the 18px column, minus
half the line), clarifying what belongs to the open folder. */.nestedChoiceList.svelte-1jxjn06{position:relative;padding-left:26px;}.nestedChoiceList.svelte-1jxjn06::before{content:"";position:absolute;left:16px;top:3px;bottom:3px;width:1px;background:var(--background-modifier-border);pointer-events:none;}
/* The per-folder add-row reads as a ghost row of the folder: aligned to the
/* Root (non-nested) empty list keeps a little bottom breathing room. The only way to
render it empty is a zero-match filter \u2014 a truly empty tree shows the hero state. */.choiceList.qa-empty.svelte-2ry05y:not(.qa-nested){padding-bottom:0.5rem;}.choiceList.qa-nested.svelte-2ry05y{
/* Own the 2px name->first-row gap so the empty drop band sits the same distance
below the folder name as a populated folder's first row (collapses with the
row's own margin-top, so populated folders look identical). */margin-top:2px;position:relative;/* anchor the ring (::before) */border-radius:var(--radius-m);transition:background-color120msease;}
/* The drop ring is drawn a few px OUTSIDE the content as an absolutely-positioned
::before (adds no layout) \u2014 "synthetically" bigger than the rows so it doesn't
clamp straight against the choice names. The right edge stays at the content edge:
the settings pane is overflow-x:hidden, so extending the ring right would clip it. */.choiceList.qa-nested.svelte-2ry05y::before{content:"";position:absolute;inset:-4px0-4px-6px;border-radius:var(--radius-m);border:2pxdashedtransparent;pointer-events:none;transition:border-color120msease;}.choiceList.qa-nested.svelte-2ry05y.qa-folder-droptarget{background-color:var(--background-modifier-hover);}.choiceList.qa-nested.svelte-2ry05y.qa-folder-droptarget::before{border-color:var(--interactive-accent);}
/* Empty folder: a GENEROUS, STABLE drop target. The band is sized by the folder's
PERSISTED emptiness (qa-folder-empty), NOT the live \`choices\` length \u2014 so when a
dragged item is previewed into the zone (filling \`choices\`, toggling qa-empty off)
the band keeps its height instead of collapsing/expanding under the cursor (the
"jumps all over the place"). Only persisted-empty folders get it, so populated
folders never heave at drag start. */.choiceList.qa-nested.qa-folder-empty.svelte-2ry05y{min-height:3rem;display:flex;align-items:center;}
/* Hint shows only when the folder is persisted-empty AND nothing is previewed in it
(qa-empty = live \`choices\` empty), so it cleanly swaps out for the previewed row
without changing the band's size. */.choiceList.qa-nested.qa-folder-empty.qa-empty.svelte-2ry05y::after{content:"Empty \u2014 add a choice or drag one here.";color:var(--text-faint);font-size:var(--font-ui-smaller,12px);line-height:1.3;padding-left:8px;/* align with the child rows' own left padding */pointer-events:none;user-select:none;}
havenotbeenchangedordeleted,andQuickAddwillnotoverwritethem.</p> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">They are stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this vault. Make a
text,orrunamacro.Groupthemwithfolders.<aclass="quickadd-docs-link"target="_blank"rel="noopener noreferrer">Learnmore</a></p> <div class="choiceEmptyActions svelte-1r4uuo1"><!></div></div>`),Ade=z('<button class="search-input-clear-button qaFilterClearButton svelte-1r4uuo1" aria-label="Clear filter"></button>'),kde=z('<div class="choiceFilterEmpty svelte-1r4uuo1">No choices match your filter.</div>'),Sde=z('<button type="button" class="qaAIAssistantBtn clickable-icon svelte-1r4uuo1" aria-label="Configure AI Assistant" title="Configure AI Assistant"><!></button>'),Dde=z('<div class="choiceFilterBar svelte-1r4uuo1"><div class="search-input-container choiceFilterInput svelte-1r4uuo1"><input type="search" placeholder="Filter choices..." autocapitalize="off" autocorrect="off" enterkeyhint="search"/> <!></div></div> <!> <div class="choiceViewBottomBar svelte-1r4uuo1"><!> <!></div>',1),Ide=z("<div><!></div>"),Pde={hash:"svelte-1r4uuo1",code:`.choiceViewBottomBar.svelte-1r4uuo1 {display:flex;flex-direction:row;align-items:center;justify-content:flex-end; /* pack right; "New choice" (primary) is the terminal action */flex-wrap:wrap;gap:0.5rem;margin-top:0.75rem;}
/* AI Assistant as a quiet icon button (matches the per-row action icons),
leading the right cluster so the bar's width barely changes when AI/online
features toggle. */.qaAIAssistantBtn.svelte-1r4uuo1{flex:00auto;display:inline-flex;align-items:center;justify-content:center;color:var(--text-muted);}.qaAIAssistantBtn.svelte-1r4uuo1:hover{color:var(--text-normal);}.choiceEmptyState.svelte-1r4uuo1{display:flex;flex-direction:column;align-items:center;text-align:center;gap:0.5rem;padding:2.5rem1rem;color:var(--text-muted);}.choiceEmptyTitle.svelte-1r4uuo1{font-weight:var(--font-semibold);color:var(--text-normal);}.choiceEmptyBody.svelte-1r4uuo1{margin:0;max-width:42ch;}.choiceEmptyActions.svelte-1r4uuo1{margin-top:0.5rem;}.choiceFilterBar.svelte-1r4uuo1{margin-bottom:8px;}
/* The native container is inline-block by default in some contexts; span
the full row so the filter aligns with the list edges. */.choiceFilterInput.svelte-1r4uuo1{width:100%;}
/* Obsidian styles .search-input-clear-button (position, the \xD7 glyph, hover)
\u2014 we only reset the <button> chrome so that styling shows through. A real
<button> (Obsidian uses a div) keeps it keyboard-operable. */.qaFilterClearButton.svelte-1r4uuo1{background:transparent;border:none;box-shadow:none;padding:0;margin:0;cursor:var(--cursor,pointer);}.choiceFilterEmpty.svelte-1r4uuo1{color:var(--text-faint);font-size:var(--font-ui-small,13px);padding:12px8px16px;}`};function Q$(r,e){we(e,!0),ot(r,Pde);let t=he(e,"choices",31,()=>bt([])),n=Ae(""),i=O(()=>!Array.isArray(t())),o=O(()=>`The"choices"valueindata.jsonis${t()===null?"null":`of type "${typeoft()}"`},butQuickAddexpectsalist.`),s=og.Platform.isMobile,a=Ae(bt(ce.getState().disableOnlineFeatures)),l=new Uk(Ot(()=>e.plugin));function c(W){if(!Array.isArray(W))return W;let Y=PY(W),{choices:X,repaired:ae}=IY(W);if(Y)return X;for(let{choice:pe}of ae)if(pe.command)try{l.enableCommand(pe)}catch(ge){F.logError(`Couldnotregisteracommandfortherepairedchoice"${pe.name}":${geinstanceofError?ge.message:String(ge)}`)}return X}t(c(t())),hr(()=>{let W=ce.subscribe(Y=>{t(c(Y.choices)),Z(a,Y.disableOnlineFeatures,!0)});return()=>W()});function u(){e.saveChoices(yh(t()))}let d=W=>W.type==="Multi";function f(W,Y){let X=Y.trim();if(!X)return W;let ae=(0,og.prepareFuzzySearch)(X),pe=ge=>{if(!Ye(ge))return null;let be=!!ae(ge.name??"");if(!d(ge))return be?ge:null;let xe=st(ge).map(Ue=>pe(Ue)).filter(Boolean);return be||xe.length>0?{...ge,collapsed:!1,choices:xe}:null};return W.map(ge=>pe(ge)).filter(Boolean)}async function p(W,Y,X,ae=!1){let pe=TY(Y,t()),ge=B$(Y,pe);if(t(sY(t(),ge,X)),!X&&h(n).trim().length>0&&Z(n,""),Y==="Multi")u(),await C(ge),await m(ge.id);else if(ae)u(),await m(ge.id);else{u();try{await w(ge)}catch(be){F.logError(`Failedtoconfigurethenewchoice:${beinstanceofError?be.message:String(be)}`),u()}await m(ge.id)}}async function m(W){await jf();try{document.querySelector(`[data-choice-id="${W}"]`)?.scrollIntoView({block:"nearest"})}catch{}}function v(W){return gx(t(),W.id)??W}function g(W){return Ye(W)?W.command?!0:st(W).some(g):!1}async function y(W){let Y=v(W);await tY(Y,e.app)&&(t(vx(t(),W.id).updated),l.disableCommand(Y,{recursive:!0}),u())}async function w(W){let Y=v(W),X=await rY(Y,e.app,e.plugin);X&&(t(t().map(ae=>x(ae,X))),l.updateCommand(Y,X),u())}function x(W,Y){if(!Ye(W))return W;if(W.id===Y.id)return{...W,...Y};if(xc(W)){let X=st(W).map(pe=>x(pe,Y));return{...W,choices:X}}return W}async function C(W){if(!W)return;let Y=await g_(e.app,W.name,W.type);if(!Y)return;let X=v(W),ae={...X,name:Y};t(t().map(pe=>x(pe,ae))),l.updateCommand(X,ae),u()}function _(W){let Y=nY(v(W));t(t().map(X=>x(X,Y))),Y.command?l.enableCommand(Y):l.disableCommand(Y),u()}async function E(W){let Y=await JG(v(W),e.app);t(q$(t(),W.id,Y)??[...t(),Y]),g(Y)&&l.enableCommand(Y),u(),new og.Notice(`Duplicated"${W.name}".`),await m(Y.id)}function D(W,Y){t(Y===H$?oY(t(),W.id):iY(t(),W.id,Y)),u()}function P(W){t(W),u()}function V(W,Y){t(aY(t(),W,Y)),u()}function j(W){t(z$(t(),W.id,!W.collapsed)),u()}function oe(W,Y){return(X,...ae)=>{let pe=Sm(X?.type),ge=X?.name?`the${pe}\u201C${X.name}\u201D`:`that${pe}`;em(`Couldn't ${W} ${ge}`,Y)(X,...ae)}}let se={onDeleteChoice:oe("delete",y),onConfigureChoice:oe("open the settings for",w),onToggleCommand:oe("update the command palette entry for",_),onDuplicateChoice:oe("duplicate",E),onRenameChoice:oe("rename",C),onMoveChoice:oe("move",D),onToggleCollapsed:oe("open or close",j),onReorderChoices:em("Couldn'tsavetheneworder",P),onCommitFolder:em("Couldn't save that folder'scontents",V),onAddChoice:(W,Y,X,ae)=>em(`Couldn't add that ${Sm(Y)}`,p)(W,Y,X,ae)},M=em("Couldn't open the AI assistant settings",async()=>{let W=await new Qk(e.app,ce.getState().ai).waitForClose;W&&ce.setState(Y=>({...Y,ai:W}))});var U=Ide(),q=I(U);{var B=W=>{ig(W,{get detail(){return h(o)}})},ie=W=>{var Y=un(),X=Pe(Y);hv(X,{onerror:pe=>F.logError(`QuickAdd could not render the choice list: ${pe instanceof Error?pe.message:String(pe)}`),failed:(pe,ge=Vt)=>{{let be=O(()=>ge()instanceof Error?ge().message:String(ge()));ig(pe,{get detail(){return h(be)}})}}},pe=>{var ge=un(),be=Pe(ge);{var xe=Ne=>{var
/* Keeps "Add variable" right-aligned now that it is the row'sonlychild.*/.qa-gv__actions.svelte-hx6w4t {display:flex;justify-content:flex-end;}.qa-gv__desc.svelte-hx6w4t {color:var(--text-muted);font-size:12px;}
/* Mirrors .qa-template-folder-empty, the sibling list's empty state. */.qa-gv__empty.svelte-hx6w4t{color:var(--text-muted);font-size:var(--font-ui-smaller);padding:6px0;}.qa-gv__table.svelte-hx6w4t{display:grid;gap:8px;}.qa-gv__row.svelte-hx6w4t{display:grid;grid-template-columns:180px1fr140px;gap:8px;align-items:start;}.qa-gv__row--head.svelte-hx6w4t{font-weight:600;color:var(--text-muted);}.qa-gv__cell.svelte-hx6w4tinput[type="text"]:where(.svelte-hx6w4t){width:100%;}.qa-gv__cell.svelte-hx6w4ttextarea:where(.svelte-hx6w4t){width:100%;resize:vertical;}.qa-gv__ops.svelte-hx6w4t{display:flex;gap:6px;align-items:center;}.qa-gv__btn.svelte-hx6w4t{padding:4px8px;}.qa-gv__btn.danger.svelte-hx6w4t{color:var(--text-error);}
}`};functionrO(r,e){we(e,!0),ot(r,ipe);lett={"user-script":"User script","conditional-script":"Conditional script",template:"Template file","capture-template":"Capture template"},n=Ae(""),i=Ae(bt(newSet)),o=Ae(bt(newSet)),s=Ae(bt(qY())),a=Ae(null),l=Ae(null),c=O(()=>ly(e.allChoices)),u=O(()=>v(h(c),h(n))),d=O(()=>_(h(c),h(i))),f=O(()=>E(e.allChoices,h(d),h(o))),p=O(()=>newMap(h(c).map(k=>[k.id,k.path.join(" / ")])));functionm(k){returnk.type==="Multi"}functionv(k,N){letK=N.trim().toLowerCase();returnK?k.filter(J=>`${J.path.join(" ")}${J.choice.type}`.toLowerCase().includes(K)):k}functiong(k){letN=[];for(letKofst(k))Ye(K)&&N.push(K.id,...g(K));returnN}functiony(k,N){letK=[k.id,...g(k)];if(N){letJ=newSet(h(i));for(letueofK)J.add(ue);if(Z(i,J,!0),h(o).size>0){letue=newSet(h(o));for(letveofK)ue.delete(ve);Z(o,ue,!0)}}else{letJ=newSet(h(i));for(letveofK)J.delete(ve);Z(i,J,!0);letue=newSet(h(o));for(letveofK)ue.add(ve);Z(o,ue,!0)}}functionw(k){letN=h(c).find(J=>J.id===k);if(!N)return;letK=h(i).has(k);y(N.choice,!K),Z(a,null)}functionx(){for(letkofh(u))y(k.choice,!0);Z(a,null)}functionC(){Z(i,newSet,!0),Z(o,newSet,!0),Z(a,null)}function_(k,N){letK=[];for(letJofk)N.has(J.id)&&(!J.parentId||!N.has(J.parentId))&&K.push(J.id);returnK}functionE(k,N,K){if(N.length===0)return{rootCount:0,totalChoices:0,dependencyCount:0,missingChoiceIds:[],userScripts:0,conditionalScripts:0,templateFiles:0,captureTemplates:0};letJ=nS(k,N,{excludedChoiceIds:K}),ue=iS(J.catalog,J.choiceIds),ve=oS(J.catalog,J.choiceIds);return{rootCount:N.length,totalChoices:J.choiceIds.length,dependencyCount:Math.max(J.choiceIds.length-N.length,0),missingChoiceIds:J.missingChoiceIds,userScripts:ue.userScriptPaths.size,conditionalScripts:ue.conditionalScriptPaths.size,templateFiles:ve.templatePaths.size,captureTemplates:ve.captureTemplatePaths.size}}functionD(k){let{missingChoiceIds:N,missingAssets:K}=k;returnN.length===0&&K.length===0?null:{missingChoices:N,missingAssets:K}}asyncfunctionP(){if(h(d).length===0)returnnewqa.Notice("Select at least one choice to export."),null;try{letk=awaitWY(e.app,{choices:e.allChoices,rootChoiceIds:h(d),excludedChoiceIds:Array.from(h(o)),quickAddVersion:e.plugin.manifest.version});returnZ(a,D(k),!0),k}catch(k){returnconsole.error(k),Z(a,null),newqa.Notice(`Export failed: ${k?.message??String(k)}`),null}}asyncfunctionV(){if(!h(l)){Z(l,"copy");try{letk=awaitP();if(!k)return;letN=JSON.stringify(k.pkg,null,2);awaitoe(N),newqa.Notice(`Copied package (${k.pkg.choices.length} choice${k.pkg.choices.length===1?"":"s"}) to clipboard.`),h(a)?newqa.Notice("Package copied with warnings. Review details below."):e.close()}catch(k){console.error(k),newqa.Notice(`Copy failed: ${k?.message??String(k)}`)}finally{Z(l,null)}}}asyncfunctionj(){if(h(l))return;letk=h(s).trim();if(!k){newqa.Notice("Enter a file path before saving.");return}Z(l,"save");try{letN=awaitP();if(!N)return;let{overwritten:K}=awaitHY(e.app,N.pkg,k),J=N.pkg.choices.length,ue=`${J} choice${J===1?"":"s"}`;newqa.Notice(K?`Overwrote package (${ue}) at '${k}'.`:`Saved package (${ue}) to '${k}'.`),h(a)?newqa.Notice("Package saved with warnings. Review details below."):e.close()}catch(N){letK=N?.message??String(N);if(K.startsWith("Save cancelled:")){newqa.Notice("Save cancelled.");return}console.error(N),newqa.Notice(`Save failed: ${K}`)}finally{Z(l,null)}}asyncfunctionoe(k){if(navigator.clipboard?.writeText){awaitnavigator.clipboard.writeText(k);return}letN=document.createElement("textarea");N.value=k,N.setAttribute("readonly","true"),N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.focus(),N.select();letK=document.execCommand("copy");if(document.body.removeChild(N),!K)thrownewError("Clipboard copy is not supported in this environment.")}varse=npe(),M=A(I(se),2),U=I(M);gr(U),ke(U,"spellcheck",!1);varq=A(U,2),B=I(q),ie=A(B,2);S(q),S(M);varW=A(M,2),Y=I(W);{varX=k=>{varN=Yde();$(k,N)},ae=k=>{varN=Qde();ar(N,21,()=>h(u),K=>K.id,(K,J)=>{varue=Xde(),ve=I(ue),Ve=I(ve);gr(
${jt??""}`),[()=>h(a).missingChoices.map(jt=>h(p).get(jt)??jt).join(", ")]),$(Ve,vt)};ne(K,Ve=>{h(a).missingChoices.length>0&&Ve(J)})}var ue=A(K,2);{var ve=Ve=>{var vt=tpe(),Pr=A(I(vt),2);ar(Pr,21,()=>h(a).missingAssets,jt=>jt.path,(jt,$i)=>{var yt=epe(),pr=I(yt),kr=A(pr),Gn=I(kr);S(kr),S(yt),de(()=>{me(pr,`${h($i).path??""}`),me(Gn,`(${t[h($i).kind]??""})`)}),$(jt,yt)}),S(Pr),S(vt),$(Ve,vt)};ne(ue,Ve=>{h(a).missingAssets.length>0&&Ve(ve)})}S(N),$(k,N)};ne(Ar,k=>{h(a)&&k(ur)})}var dt=A(Ar,2),Ft=I(dt),Hn=I(Ft),xo=I(Hn);{var xs=k=>{var N=cl("Copying\u2026");$(k,N)},jn=k=>{var N=cl("Copy JSON");$(k,N)};ne(xo,k=>{h(l)==="copy"?k(xs):k(jn,-1)})}S(Hn),S(Ft);var re=A(Ft,2),Ie=I(re),dr=A(I(Ie),2),br=I(dr);gr(br);var Tn=A(br,2),Ho=I(Tn);{var Ka=k=>{var N=cl("Saving\u2026");$(k,N)},Xa=k=>{var N=cl("Save to file");$(k,N)};ne(Ho,k=>{h(l)==="save"?k(Ka):k(Xa,-1)})}S(Tn),S(dr),S(Ie),S(re),S(dt);var Jc=A(dt,2),T=I(Jc);S(Jc),S(se),de(()=>{me(Ue,h(f).rootCount),me(Ke,h(f).totalChoices),me(We,h(f).dependencyCount),me(_e,h(f).userScripts+h(f).conditionalScripts),me(or,h(f).templateFiles+h(f).captureTemplates),Hn.disabled=h(l)!==null,Tn.disabled=h(l)!==null,T.disabled=h(l)!==null}),co(U,()=>h(n),k=>Z(n,k)),De("click",B,x),De("click",ie,C),De("click",Hn,V),co(br,()=>h(s),k=>Z(s,k)),De("click",Tn,j),De("click",T,function(...k){e.close?.apply(this,k)}),$(r,se),Ce()}Et(["click","change"]);var cS=class extends jY.Modal{constructor(t,n,i){super(t);this.plugin=n;this.choices=i;this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageExportModal"),this.handle=qi(this.contentEl,rO,{app:this.app,plugin:this.plugin,allChoices:this.choices,close:()=>this.close()},{what:"the package exporter"})}onClose(){this.handle?.destroy(),this.handle=null}};var x4=require("obsidian");var Ax=require("obsidian");It();qt();var gS=require("obsidian");ml();Wt();Ii();Yr();Yr();Yr();Wt();Ii();function ope(r){return r.type==="Multi"}function spe(r){return r.type==="Macro"}function nO(r,e,t){if(!(!r||typeof r!="object")){if(Array.isArray(r)){e.onUnreadable?.();return}if(!t.has(r)){if(t.add(r),e.onChoice?.(r),ope(r))if(Array.isArray(r.choices))for(let n of r.choices)nO(n,e,t);else t_(r.choices)&&e.onUnreadable?.();spe(r)&&uS(Wn(r.macro),e,t)}}}function uS(r,e,t){if(!Array.isArray(r)){Di(r)&&e.onUnreadable?.();return}for(let n of r){if(!n||typeof n!="object")continue;if(Array.isArray(n)){e.onUnreadable?.();continue}e.onCommand?.(n);let i=n;(n.type==="Conditional"||Array.isArray(i.thenCommands)||Array.isArray(i.elseCommands))&&(uS(i.thenCommands,e,t),uS(i.elseCommands,e,t));let s=n,a=n.type==="NestedChoice"||s.choice&&typeof s.choice=="object"?s.choice:void 0;a&&nO(a,e,t)}}function iO(r,e){let t=new Set;if(Array.isArray(r.choices))for(let i of r.choices)nO(i,e,t);else e.onUnreadable?.();let n=r.macros;if(Array.isArray(n))for(let i of n)uS(Wn(i),e,t);else Di(n)&&e.onUnreadable?.()}function sg(r){let e=!1;return iO(r,{onUnreadable:()=>{e=!0}}),e}function ag(r,e){iO(r.settings,{onChoice:e})}function dS(r,e){iO(r,{onCommand:e})}function ape(r){return r.type==="AIAssistant"}function pS(r,e,t){let n=0;return dS({choices:r},i=>{if(!ape(i)||i.modelRef&&i.modelRef.name===i.model&&e.find(l=>l.id===i.modelRef?.providerId)?.models.some(l=>l.name===i.model)||!i.model||i.model==="Ask me")return;let o=e.find(a=>a.models.some(l=>l.name===i.model));if(!o?.id)return;let s={providerId:o.id,name:i.model};i.modelRef=s,n++,t?.(i,s)}),n}Me();vi();sO();Ec();Uc();Yr();Wt();Ii();Kv();Tt();var lO={"user-script":{severity:"critical",label:"SCRIPT",description:"Runs custom JavaScript with full access to your vault and the network."},"conditional-script":{severity:"critical",label:"CONDITIONAL",description:"Runs custom JavaScript to decide which branch executes."},"bundled-script":{severity:"critical",label:"SCRIPT FILE",description:"Bundles a file that will be written to your vault and can be run as code."},"run-on-startup":{severity:"critical",label:"STARTUP",description:"Runs automatically every time Obsidian starts."},"mislabeled-executable":{severity:"critical",label:"EXECUTABLE"
`?(n>e&&(e=n),n=0,t++):n++;n>e&&(e=n);leti=r.length/t;returne>1e3||i>250}functionhS(r,e){lett=r.assets.find(n=>n.originalPath===e);if(!t)return{found:!1,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:"File is not bundled in this package."};try{letn=qc(t.content),i=n.length>YY,o=i?n.slice(0,YY):n;return{found:!0,text:o,truncated:i,sizeBytes:Tpe(n),looksMinified:_pe(o)}}catch(n){return{found:!0,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:ninstanceofError?n.message:String(n)}}}functiont4(r){returnr.summary.hasCritical}functionr4(r,e){returnr.criticalScriptPaths.every(t=>e.has(t))}asyncfunctionn4(r,e){if(Un(e))thrownewError(`Refusing to read a package outside the vault: "${e}".`);lett=(0,gS.normalizePath)(e.trim());if(!t)thrownewError("Package path cannot be empty.");if(!awaitr.vault.adapter.exists(t))thrownewError(`Package file not found: ${t}`);leti=awaitr.vault.adapter.read(t);return{pkg:mO(i),path:t}}functionmO(r){lete;try{e=JSON.parse(r)}catch(o){thrownewError(`Package content is not valid JSON: ${o?.message??o}`)}if(!$Y(e))thrownewError("Content is not a valid QuickAdd package.");if(e.schemaVersion>1)thrownewError(`Package schema version ${e.schemaVersion} is newer than this plugin supports (${1}).`);lett=Ape(e.assets);if(t!==null)thrownewError(`Package contains duplicate asset path "${t}". Each asset must have a unique path.`);letn=kpe(e.choices);if(n!==null)thrownewError(`Package contains conflicting definitions for choice "${n}". Each choice id must describe the same choice everywhere it appears.`);leti=Spe(e.choices);if(i!==null)thrownewError(`Package choice "${i}" names a parent that does not list it as a child. Each parented choice must appear inside its parent.`);returne}functionApe(r){lete=newSet;for(lettofr){letn=(0,gS.normalizePath)(t.originalPath??"");if(e.has(n))returnt.originalPath;e.add(n)}returnnull}functionkpe(r){lete=newMap,t=null,n=i=>{if(t!==null||!i||typeofi!="object")return;leto=i.id;if(typeofo=="string"){lets=dO(i),a=e.get(o);if(a===void0)e.set(o,s);elseif(a!==s){t=o;return}}if(i.type==="Multi"){lets=i;if(Array.isArray(s.choices))for(letaofs.choices)n(a)}i.type==="Macro"&&uO(i.macro?.commands,n)};for(letiofr){if(t!==null)break;n(i?.choice)}returnt}functionuO(r,e){if(Array.isArray(r)){for(lettofr)if(t){if(t.type==="NestedChoice")e(t.choice);elseif(t.type==="Conditional"){letn=t;uO(n.thenCommands,e),uO(n.elseCommands,e)}}}}functiondO(r){if(r===null||typeofr!="object"){letn=JSON.stringify(r);returnn===void0?"\0undefined":n}if(Array.isArray(r))return`[${r.map(dO).join(",")}]`;lete=r;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${dO(e[n])}`).join(",")}}`}functionSpe(r){lete=newMap(r.map(t=>[t.choice.id,t]));for(lettofr){letn=t.parentChoiceId;if(n===null)continue;leti=e.get(n);if(!i)continue;leto=i.choice;if(!st(o).some(a=>a?.id===t.choice.id))returnt.choice.id}returnnull}asyncfunctioni4(r,e,t){letn=newMap(Bn(e).map(s=>[s.id,s])),i=t.choices.map(s=>({choiceId:s.choice.id,name:s.choice.name,parentChoiceId:s.parentChoiceId,pathHint:s.pathHint??[],exists:n.has(s.choice.id)})),o=[];for(letsoft.assets){leta=Un(s.originalPath)?!1:awaitr.vault.adapter.exists(s.originalPath);o.push({originalPath:s.originalPath,exists:a,kind:s.kind})}return{choiceConflicts:i,assetConflicts:o}}asyncfunctionvS(r,e,t){letn=newSet([...t.assets.map(a=>a.originalPath),...JY(t)]),i=newSet;awaitPromise.all(Array.from(n,asynca=>{a&&(Un(a)||awaits4(r,a)&&i.add(a))}));leto=e4(e,t,i),{summary:s}=o;returnF.logMessage(`QuickAdd import preview: choices=${o.choiceCount} files=${o.fileCount} scripts=${s.scriptCount} runOnStartup=${s.runsOnStartup} registersCommands=${s.registersCommandCount} overwritesChoices=${s.overwritesChoices} overwritesFiles=${s.overwritesFiles} missing=${s.missingCount} critical=${s.criticalCount} warning=${s.warningCount}`),o}functionDpe(r){lett=(r??"").trim();if(!t)thrownewError("Package asset has an empty destination path.");letn=t.replace(/\\/g,"/");if(n.startsWith("/"
/* Critical: darkened red so white text clears WCAG AA (~5:1) at this size,
where Obsidian's stock --color-red (#e93147) lands at ~3.5:1. */.qa-import-tag.critical.svelte-5jkd35{background:var(--qa-sev-critical-pill);color:#fff;}
/* Warning: amber is medium-luminance in both themes, so near-black text
and clears AA (~5.9:1) with #1a1a1a. */.qa-import-tag.warning.svelte-5jkd35{background:var(--color-orange,#ff8c00);color:#1a1a1a;}.qa-import-tag.info.svelte-5jkd35{background:var(--background-modifier-border);color:var(--text-normal);}`};function _x(r,e){we(e,!0),ot(r,Rpe);let t=O(()=>fS(e.flag)),n=O(()=>KY(e.flag)),i=O(()=>XY(e.flag));var o=Mpe();let s;var a=I(o,!0);S(o),Fr(o,(l,c)=>Tx?.(l,c),()=>h(i)),de(()=>{s=wt(o,1,"qa-import-tag svelte-5jkd35",null,s,{critical:h(t)==="critical",warning:h(t)==="warning",info:h(t)==="info"}),me(a,h(n))}),$(r,o),Ce()}var $pe=z('<span class="qa-import-banner-detail svelte-tb9yz"> </span>'),Ope=z('<li><span class="qa-import-banner-tag svelte-tb9yz"><!></span><span class="qa-import-banner-title svelte-tb9yz"> </span> <!></li>'),Npe=z('<p class="qa-import-banner-note svelte-tb9yz">Takes effect after you reload the plugin or restart Obsidian.</p>'),Lpe=z('<section aria-label="What this package can do"><div class="qa-import-banner-head svelte-tb9yz"><span class="qa-import-banner-icon svelte-tb9yz"><!></span> <h3 class="svelte-tb9yz">What this package can do</h3></div> <ul class="qa-import-banner-rows svelte-tb9yz"></ul> <!></section>'),Bpe={hash:"svelte-tb9yz",code:`.qa-import-banner.svelte-tb9yz{background:var(--background-secondary);border:1pxsolidvar(--background-modifier-border);border-radius:var(--radius-m,8px);padding:0.85rem;display:flex;flex-direction:column;gap:0.5rem;}
/* Critical packages get a red-tinted hairline + red icon, not a blanket-red
fill: severity stays ranked and all text keeps its contrast on the neutral
surface. (A solid colored side-stripe would be the banned pattern.) */.qa-import-banner.critical.svelte-tb9yz{border-color:var(--qa-sev-critical-border);}.qa-import-banner-head.svelte-tb9yz{display:flex;align-items:center;gap:0.5rem;}.qa-import-banner-icon.svelte-tb9yz{display:inline-flex;color:var(--text-warning,var(--text-muted));}.qa-import-banner.critical.svelte-tb9yz.qa-import-banner-icon:where(.svelte-tb9yz){color:var(--text-error);}.qa-import-banner-head.svelte-tb9yzh3:where(.svelte-tb9yz){margin:0;font-size:1rem;}.qa-import-banner-rows.svelte-tb9yz{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}
/* The pill is an inline lead-in to the sentence (not a fixed left column),
so long titles wrap full-width under it instead of leaving a dead column
of whitespace beside a one-line pill. */.qa-import-banner-rows.svelte-tb9yzli:where(.svelte-tb9yz){display:block;padding:0.4rem0.5rem;border-radius:var(--radius-s,4px);}.qa-import-banner-tag.svelte-tb9yz{display:inline-block;vertical-align:middle;margin:00.4rem0.15rem0;}
/* Faint per-row severity wash so critical rows read hottest while warnings
recede, without saturating the whole banner. Composited over the banner
surface (not transparent) so the tint is a solid, predictable colour. */.qa-import-banner-rows.svelte-tb9yzli.sev-critical:where(.svelte-tb9yz){background:var(--qa-sev-critical-wash);}.qa-import-banner-rows.svelte-tb9yzli.sev-warning:where(.svelte-tb9yz){background:var(--qa-sev-warning-wash);}.qa-import-banner-rows.svelte-tb9yzli.sev-info:where(.svelte-tb9yz){background:var(--qa-sev-info-wash);}.qa-import-banner-title.svelte-tb9yz{line-height:1.4;}.qa-import-banner-detail.svelte-tb9yz{display:block;margin-top:0.15rem;font-size:var(--font-ui-smaller,0.8rem);color:var(--text-muted);overflow-wrap:anywhere;}.qa-import-banner-note.svelte-tb9yz{margin:0;font-size:var(--font-ui-smaller,0.8rem);color:var(--text-muted);}`};function vO(r,e){we(e,!0),ot(r,Bpe);let t=O(()=>e.preview.summary.runsOnStartup||e.preview.summary.registersCommandCount>0);var n=Lpe();let i;var o=I(n),s=I(o),a=I(s);Rt(a,{iconId:"alert-triangle",size:17}),S(s),In(2),S(o);var l=A(o,2);ar(l,21,()=>e.preview.capabilityRows,d=>d.flag+d.detail,(d,f)=>{var p=Ope();let m;var v=I(p),g=I(v);_x(g,{get flag(){return h(f).flag}}),S(v);var y=A(v),w=I(y,!0);S(y);var x=A(y,2);{var C=_=>{var E=$pe(),D=I(E,!0);S(E),de(()=>me(D,h(f).detail)),$(_,E)};ne(x,_=>{h(f).detail&&_(C)})}S(p),de(()=>{m=wt(p,1,"svelte-tb9yz",null,m,{"sev-critical":h(f).severity==="critical","sev-warning":h(f).severity==="warning","sev-info":h(f).severity==="info"}),me(w,h(f).title)}),$(d,p)}),S(l);var c=A(l,2);{var u=d=>{var f=Npe();$(d,f)};ne(c,d=>{h(t)&&d(u)})}S(n),de(()=>i=wt(n,1,"qa-import-banner svelte-tb9yz",null,i,{critical:e.preview.summary.hasCritical})),$(r,n),Ce()}var Upe=z('<span class="qa-import-file-exec svelte-lmqem5">Executable</span>'),Vpe=z('<span class="qa-import-file-reviewed svelte-lmqem5"><!> Reviewed</span>'),qpe=z('<span class="qa-import-file-orphan svelte-lmqem5">Unused</span>'),Wpe=z("<option>Overwrite</option>"),zpe=z(`<pclass="qa-import-file-skip-warn svelte-lmqem5"role="note">Won't be written. Any choice that uses this script will run whatever
file already exists at this path after import, not the contents you
reviewed.</p>`),Hpe=z('<pclass="qa-import-file-error svelte-lmqem5"></p>'),jpe=z(`<p class="qa-import-file-warn svelte-lmqem5">Minified: cannot be visually reviewed. Import
/* --text-normal (not --text-muted) so the badge clears AA on the hover
surface in dark themes too. */color:var(--text-normal);cursor:help;}.qa-import-file-exec.svelte-lmqem5{display:inline-flex;padding:0.05rem0.4rem;border-radius:var(--radius-s,4px);font-size:0.7rem;font-weight:700;letter-spacing:0.02em;text-transform:uppercase;background:var(--qa-sev-critical-pill);color:#fff;cursor:help;}.qa-import-file-reviewed.svelte-lmqem5{display:inline-flex;align-items:center;gap:0.15rem;font-size:0.72rem;color:var(--text-success,var(--color-green,#0aa344));}.qa-import-file-size.svelte-lmqem5{font-size:0.72rem;color:var(--text-faint);margin-left:auto;}
/* Obsidian Setting-row geometry: field name on the left at --text-normal,
control docked right at its native height \u2014 not a stacked label-above
form field (which read as non-native). */.qa-import-file-fields.svelte-lmqem5{display:flex;flex-direction:column;gap:0.4rem;}.qa-import-file-field.svelte-lmqem5{display:flex;align-items:center;gap:1rem;}.qa-import-file-field-name.svelte-lmqem5{flex:11auto;min-width:0;color:var(--text-normal);}.qa-import-file-field.svelte-lmqem5input:where(.svelte-lmqem5){flex:01300px;min-width:0;}.qa-import-file-field.svelte-lmqem5select:where(.svelte-lmqem5){flex:00auto;}
/* The native Obsidian input/dropdown focus box-shadow handles focus; no
custom outline (which would read as non-native). */.qa-import-file-field.svelte-lmqem5input:where(.svelte-lmqem5):disabled{opacity:0.5;cursor:not-allowed;}.qa-import-file-toggle.svelte-lmqem5{display:inline-flex;align-items:center;gap:0.3rem;align-self:flex-start;background:transparent;border:none;box-shadow:none;padding:0.1rem0.2rem;margin-left:-0.2rem;cursor:pointer;color:var(--text-accent);font-size:0.85rem;border-radius:var(--radius-s,4px);}.qa-import-file-toggle.svelte-lmqem5:hover{color:var(--interactive-accent-hover,var(--text-accent));text-decoration:underline;}.qa-import-file-toggle.svelte-lmqem5:focus-visible{outline:2pxsolidvar(--interactive-accent);outline-offset:1px;}.qa-import-file-chevron.svelte-lmqem5{display:inline-flex;transition:transform180msease;}.qa-import-file-chevron.open.svelte-lmqem5{transform:rotate(90deg);}.qa-import-file-preview-wrap.svelte-lmqem5{display:grid;grid-template-rows:0fr;transition:grid-template-rows200msease;}.qa-import-file-preview-wrap.open.svelte-lmqem5{grid-template-rows:1fr;}.qa-import-file-preview-inner.svelte-lmqem5{overflow:hidden;min-height:0;}.qa-import-file-preview.svelte-lmqem5{display:flex;flex-direction:column;gap:0.4rem;padding-top:0.2rem;}.qa-import-file-warn.svelte-lmqem5{margin:0;color:var(--text-warning,var(--text-muted));font-size:var(--font-ui-smaller,0.85rem);}.qa-import-file-skip-warn.svelte-lmqem5{margin:0;padding:0.4rem0.5rem;border-radius:var(--radius-s,4px);background:var(--qa-sev-warning-wash);color:var(--text-normal);font-size:var(--font-ui-smaller,0.85rem);line-height:1.4;}.qa-import-file-error.svelte-lmqem5{margin:0;color:var(--text-error);font-size:var(--font-ui-smaller,0.85rem);}.qa-import-file-code.svelte-lmqem5{margin:0;max-height:240px;overflow:auto;padding:0.5rem0.6rem;border-radius:var(--radius-s,4px);background:var(--background-modifier-form-field);border:1pxsolidvar(--background-modifier-border);font-family:var(--font-monospace);font-size:0.8rem;line-height:1.5;white-space:pre;tab-size:4;}.qa-import-file-code.svelte-lmqem5:focus-visible{outline:2pxsolidvar(--interactive-accent);outline-offset:1px;}
@media(max-width:600px){
/* Stack control under its name and let it use the full width on narrow
screens, where a right-docked control would be cramped. */.qa-import-file-field.svelte-lmqem5{flex-wrap:wrap;gap:0.25rem;}.qa-import-file-field.svelte-lmqem5input:where(.svelte-lmqem5),
/* overflow-x:hidden (paired with overflow-y:auto) clips child focus rings
at the flush left/right edges; the inline padding gives the ring room. */overflow-x:hidden;box-sizing:border-box;padding:2px 4px;}.importPackageModal.svelte-1nd6fqb :where(.svelte-1nd6fqb) {box-sizing:border-box;}.importPackageModal.svelte-1nd6fqb > section:where(.svelte-1nd6fqb) {max-width:100%;}.pasteSection.svelte-1nd6fqb label:where(.svelte-1nd6fqb) {display:flex;flex-direction:column;gap:0.5rem;}.pasteSection.svelte-1nd6fqb textarea:where(.svelte-1nd6fqb) {width:100%;font-family:var(--font-monospace);resize:vertical;}.errorMessage.svelte-1nd6fqb {color:var(--text-error);}.info.svelte-1nd6fqb {color:var(--text-muted);}
/* A single compact line that sizes to content and wraps naturally, instead
of a 4-equal-column grid where the date wraps to 3 lines and the rest
/* A plain inline text link, not a chrome button: neutralise Obsidian's
default button background/shadow on every state (!important to win over
the global button:hover / :focus rules that paint the grey box). */.macroToggle.svelte-1nd6fqb {display:inline-block;margin-top:0.35rem;padding:0;background:transparent !important;border:none;box-shadow:none !important;color:var(--text-accent);cursor:pointer;font-size:var(--font-ui-smaller, 0.8rem);border-radius:var(--radius-s, 4px);}.macroToggle.svelte-1nd6fqb:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.macroToggle.svelte-1nd6fqb:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {background:var(--background-primary-alt, var(--background-secondary));}.warningsBand.svelte-1nd6fqb {display:flex;flex-direction:column;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;gap:0.5rem;}.warnItem.svelte-1nd6fqb h4:where(.svelte-1nd6fqb) {margin:0;font-size:var(--font-ui-small, 0.9rem);}.warnItem.svelte-1nd6fqb ul:where(.svelte-1nd6fqb) {margin:0.25rem 0 0;padding-left:1rem;}.warnItem.svelte-1nd6fqb li:where(.svelte-1nd6fqb) {overflow-wrap:anywhere;}
/* A missing SCRIPT reference is an execution-hijack risk, not a broken
link: it runs from whatever exists at that path. Mark it as critical. */.warnItem.svelte-1nd6fqb li.script:where(.svelte-1nd6fqb) {padding:0.25rem 0.4rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-critical-wash);}.warnLoc.svelte-1nd6fqb {color:var(--text-muted);font-size:var(--font-ui-smaller, 0.8rem);}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb) {width:100%;border-collapse:collapse;table-layout:fixed;}.choicesSection.svelte-1nd6fqb col.colName:where(.svelte-1nd6fqb) {width:52%;}.choicesSection.svelte-1nd6fqb col.colLocation:where(.svelte-1nd6fqb) {width:26%;}.choicesSection.svelte-1nd6fqb col.colAction:where(.svelte-1nd6fqb) {width:22%;}.choicesSection.svelte-1nd6fqb th:where(.svelte-1nd6fqb),
}`};functionCO(r,e){we(e,!0),ot(r,Sfe);lett;functionn(){returnt??(t=newwS(e.app))}leti=Ae(null),o=Ae(null),s=Ae(null),a=Ae(!1),l=Ae(bt(newSet)),c=Ae(bt(newSet)),u=Ae(null),d=Ae(!1),f=Ae(null),p=Ae(bt(newMap)),m=Ae(bt(newMap)),v=Ae(""),g=Ae(!1),y=Ae(0),w=Ae(!1),x=O(()=>h(s)?t4(h(s)):!1),C=O(()=>h(s)?r4(h(s),h(l)):!0),_=O(()=>newMap((h(s)?.choices??[]).map(re=>[re.choiceId,re]))),E=O(()=>newMap((h(s)?.files??[]).map(re=>[re.originalPath,re]))),D=O(()=>!!(h(s)&&(h(s).summary.hasCritical||h(s).summary.hasWarning))),P=O(()=>!!(h(i)&&h(o))&&!h(g)&&(!h(x)||h(a)&&h(C))),V=O(()=>h(s)?.criticalScriptPaths.length??0),j=O(()=>h(s)?.missingReferences.some(re=>re.asScript)??!1),oe=O(()=>{letre=h(f);if(!re)return"";letIe=[];re.added&&Ie.push(`${re.added} choice${re.added===1?"":"s"} added`),re.overwritten&&Ie.push(`${re.overwritten} overwritten`),re.assetsWritten&&Ie.push(`${re.assetsWritten} file${re.assetsWritten===1?"":"s"} written`);letdr=re.skipped+re.assetsSkipped;returndr&&Ie.push(`${dr} skipped`),Ie.length?`Imported: ${Ie.join(", ")}.`:"Nothing was imported."}),se=O(()=>h(V)>0?h(j)?"I have reviewed each bundled script above and trust the source, including scripts that are not included and cannot be shown.":"I have reviewed each script above and trust the source.":h(j)?"This package runs scripts that are not included and cannot be reviewed. I trust the source.":"I understand this package can run code, and I trust the source.");functionM(re){if(h(l).has(re))return;letIe=newSet(h(l));Ie.add(re),Z(l,Ie,!0)}functionU(re){letIe=newSet(h(c));Ie.has(re)?Ie.delete(re):Ie.add(re),Z(c,Ie,!0)}letq=re=>n().optimistic(re),B=O(()=>(h(o)?.assetConflicts??[]).map(re=>({conflict:re,state:m4(h(m),re,Y,q),file:h(E).get(re.originalPath)}))),ie=O(()=>h(B).filter(re=>!re.state.destinationExists)),W=O(()=>h(B).filter(re=>re.state.destinationExists));functionY(re){let[Ie]=Wi(ce.getState().templateFolderPaths),dr=re.kind==="template"||re.kind==="capture-template";if(Ie&&dr){letbr=re.originalPath.split("/").pop()??re.originalPath;return`${Ie}/${br}`}returnre.originalPath}functionX(re,Ie){n().schedule(re,Ie,dr=>{Z(m,b4(h(m),re,dr),!0)})}functionae(){if(!h(o)){Z(p,newMap,!0),Z(m,newMap,!0);return}Z(p,h4(h(o).choiceConflicts),!0),Z(m,f4(h(o).assetConflicts,Y,q),!0);for(letreofh(o).assetConflicts){letIe=h(m).get(re.originalPath);Ie&&X(re.originalPath,Ie.destinationPath)}}functionpe(re,Ie){Z(p,g4(h(p),re,Ie),!0)}functionge(re,Ie){Z(m,v4(h(m),re,Ie,q),!0)}functionbe(re,Ie){let{decisions:dr,effectivePath:br}=y4(h(m),re.originalPath,Ie,q);Z(m,dr,!0),X(re.originalPath,br)}functionxe(re,Ie){letbr=Ie.currentTarget.value;pe(re,br)}functionUe(){Z(s,null),Z(a,!1),Z(l,newSet,!0),Z(c,newSet,!0)}asyncfunction$t(re){letIe=re.trim(),dr=MI(y);if(Z(f,null),Z(w,!1),!Ie){Z(i,null),Z(o,null),Z(p,newMap,!0),Z(m,newMap,!0),Ue(),Z(u,null);return}Z(g,!0);try{letbr=mO(Ie),Tn=ce.getState().choices,Ho=awaiti4(e.app,Tn,br),Ka=awaitvS(e.app,Tn,br);if(dr!==h(y))return;Z(i,{pkg:br,path:"[pasted]"},!0),Z(o,Ho,!0),Ue(),Z(s,Ka,!0),Z(u,null),ae()}catch(br){if(dr!==h(y))return;Z(u,br?.message??String(br),!0),Z(i,null),Z(o,null),Z(p,newMap,!0),Z(m,newMap,!0),Ue()}finally{dr===h(y)&&Z(g,!1)}}functionNe(re){letIe=re.currentTarget.value;Z(v,Ie,!0),$t(Ie)}functionKe(re){return!re||re.length===0?"Root":re.slice(0,-1).join(" \u203A ")||"Root"}asyncfunctionQe(){if(h(w)){newAx.Notice("This package has already been imported.");return}if(!h(i)||!h(o)){newAx.Notice("Load a package before importing.");return}Z(d,!0),Z(f,null);try{letre=awaito4({app:e.app,existingChoices:ce.getState().choices,aiProviders:ce.getState().ai.providers,pkg:h(i).pkg,choiceDecisions:w4(h(o).choiceConflicts,h(p)),assetDecisions:C4(h(o).assetConflicts,h(m),q)});ce.setState(Ie=>({...Ie,choices:re.updatedChoices})),Z(f,{added:re.addedChoiceIds.length,overwritten:re.overwrittenChoiceIds.length,skipped:re.skippedChoiceIds.length,assetsWritten:re.writtenAssets.length,assetsSkipped:re.skippedAssets.length},!0),Z(w,!0),newAx.Notice(`Imported ${re.addedChoiceIds.length+re.overw
${h(To).asScript?"not bundled, so it runs from whatever file exists at that path after import":"not bundled and not in your vault"} `),me(ru,h(To).breadcrumb)}),$(to,An)}),S(eo),S(Ji),$(pi,Ji)};ne(jl,pi=>{h(s).missingReferences.length>0&&pi(bd)})}varev=A(jl,2);{varxf=pi=>{varJi=wfe(),eo=A(I(Ji),2);ar(eo,20,()=>h(s).orphanAssets,to=>to,(to,To)=>{varAn=bfe(),Gt=I(An),ro=I(Gt,!0);S(Gt),In(),S(An),de(()=>me(ro,To)),$(to,An)}),S(eo),S(Ji),$(pi,Ji)};ne(ev,pi=>{h(s).orphanAssets.length>0&&pi(xf)})}S(_n),$(ln,_n)};ne(ua,ln=>{h(s)&&(h(s).missingReferences.length>0||h(s).orphanAssets.length>0)&&ln(Es)})}$(yt,pr)};ne(vt,yt=>{h(i)&&yt(Pr)})}varjt=A(vt,2);{var$i=yt=>{varpr=Efe(),kr=I(pr);Rt(kr,{iconId:"check-circle",size:16});varGn=A(kr,2),kt=I(Gn,!0);S(Gn),S(pr),de(()=>me(kt,h(oe))),$(yt,pr)};ne(jt,yt=>{h(f)&&yt($i)})}de(yt=>{me(Tn,` ${h(i).pkg.quickAddVersion??""}`),me(Ka,` ${yt??""}`),me(Jc,`${h(o).choiceConflicts.length??""} choice${h(o).choiceConflicts.length===1?"":"s"}`),me(k,`${h(i).pkg.assets.length??""} file${h(i).pkg.assets.length===1?"":"s"}`)},[()=>newDate(h(i).pkg.createdAt).toLocaleDateString()]),$(re,Ie)};ne(or,re=>{h(i)&&h(o)&&re(yr)})}varPt=A(or,2);{varAr=re=>{varIe=Afe();letdr;varbr=I(Ie),Tn=I(br);gr(Tn);varHo=A(Tn,2),Ka=I(Ho,!0);S(Ho),S(br);varXa=A(br,2);{varJc=T=>{vark=_fe(),N=I(k);S(k),de(()=>me(N,`Open \u201CView contents\u201D on each of the ${h(V)??""} executable
script${h(V)===1?"":"s"} above to enable this.`)),$(T,k)};ne(Xa,T=>{h(V)>0&&!h(C)&&T(Jc)})}S(Ie),de(()=>{dr=wt(Ie,1,"ackGate svelte-1nd6fqb",null,dr,{critical:h(s)?.summary.hasCritical}),qd(Tn,h(a)),Tn.disabled=!h(C),ke(Tn,"aria-describedby",h(V)>0&&!h(C)?"qa-import-ack-hint":void0),me(Ka,h(se))}),De("change",Tn,T=>Z(a,T.currentTarget.checked,!0)),$(re,Ie)};ne(Pt,re=>{h(i)&&h(x)&&!h(w)&&re(Ar)})}varur=A(Pt,2),dt=I(ur),Ft=A(dt,2),Hn=I(Ft);{varxo=re=>{varIe=cl("Importing\u2026");$(re,Ie)},xs=re=>{varIe=cl("Close");$(re,Ie)},jn=re=>{varIe=cl("Import package");$(re,Ie)};ne(Hn,re=>{h(d)?re(xo):h(w)?re(xs,1):re(jn,-1)})}S(Ft),S(ur),S(ye),de(()=>{dt.disabled=h(d),Ft.disabled=h(d)||!h(w)&&!h(P),ke(Ft,"title",!h(w)&&h(x)&&h(C)&&!h(a)?"Confirm the acknowledgement above to continue":void0)}),De("input",He,Ne),co(He,()=>h(v),re=>Z(v,re)),De("click",dt,function(...re){e.close?.apply(this,re)}),De("click",Ft,function(...re){(h(w)?e.close:Qe)?.apply(this,re)}),$(r,ye),Ce()}Et(["input","click","change"]);varCS=classextendsx4.Modal{constructor(t){super(t);this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageImportModal"),this.handle=qi(this.contentEl,CO,{app:this.app,close:()=>this.close()},{what:"the package importer"})}onClose(){this.handle?.destroy(),this.handle=null}};Tm();Wd();fc();functionxO(r,e,t,n){leti=zr(r,"div"),o=zr(r,"strong");returno.textContent=e,i.appendChild(o),i.appendChild(jv(r,` ${t}`)),n?.className&&i.classList.add(n.className),i.classList.add("qa-dev-info-row"),r.appendChild(i),i}functionE4(r,e){if(e.branch!==null&&xO(r,"Branch:",e.branch),e.commit!==null&&xO(r,"Commit:",e.commit),e.dirty!==null){lett=e.dirty?"Yes (uncommitted changes)":"No",n=e.dirty?"qa-dev-dirty-status":"qa-dev-clean-status";xO(r,"Uncommitted changes:",t,{className:n})}}Wt();varEO="Bundle or import QuickAdd automations as reusable packages.",xS=classextendsod.PluginSettingTab{constructor(t,n){super(t,n);this.choiceViewHandle=null;this.globalVariablesViewHandle=null;this.packagesUnsubscribe=null;this.plugin=n,this.icon="zap"}getControlValue(t){letn=ce.getState();returnt==="inputPrompt"?n.inputPrompt==="multi-line":n[t]}setControlValue(t,n){if(t==="inputPrompt"){ce.setState({inputPrompt:n?"multi-line":"single-line"});return}if(t==="persistInputPromptDrafts"){leti=!!n;ce.setState({persistInputPromptDrafts:i}),i||Gi.getInstance().clearAll();return}ce.setState({[t]:n})}getSettingDefinitions(){return[this.choicesAndPackagesGroup(),this.choicePickerGroup(),this.inputGroup(),this.templatesGroup(),this.notificationsGroup(),this.globalVariablesGroup(),this.aiAndOnlineGroup(),this.appearanceGroup()]}hide(){super.hide(),this.destroySettingViews()}destroySettingViews(){this.choiceViewHandle?.destroy(),this.choiceViewHandle=null,this.globalVariablesViewHandle?.destroy(),this.globalVariablesViewHandle=null,this.packagesUnsubscribe?.(),this.packagesUnsubscribe=null}choicesAndPackagesGroup(){return{type:"group",heading:"Choices & packages",extraButtons:[t=>t.setIcon("help-circle").setTooltip("QuickAdd documentation").onClick(()=>hj(Al.gettingStarted,t.extraSettingsEl))],items:[{name:"Choices",render:t=>this.renderChoicesView(t)},{name:"Packages",desc:EO,render:t=>this.renderPackages(t)}]}}choicePickerGroup(){return{type:"group",heading:"Choice picker",items:[{name:"Search nested choices",desc:"When searching in the choice picker, also match choices nested inside folders and show their path. Note that nested matches can outrank same-level ones. Disable to search only the open level.",control:{type:"toggle",key:"searchNestedChoices"}},{name:"\u201CNew note from template\u201D in the launcher",desc:"Add a row to Run QuickAdd that lists templates from your configured template folder, so you can create a note from a template without a dedicated Template choice. Only appears when a template folder is configured; the command palette entry works regardless.",control:{type:"dropdown",key:"templateFolderLauncherRow",defaultValue:"bottom",options:{bottom:"Show at the bottom (keeps your top choice first)",top:"Show at the top",of
`)}}varmK=r=>r.join(""),Kve=r=>r.split(/\b/),Xve=fK("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",mK),Qve={splitFunction:Kve,joinFunction:mK,conflictFunction:Xve};functionmN(r,e,t,n={}){n=Object.assign({},Qve,n);let[i,o,s]=[r,e,t].map(c=>n.splitFunction.call(n,c)),a=mE.merge(i,o,s);returnhE.collateMerge(a,n.joinFunction,n.conflictFunction)}varhK=mN;Tt();Cu();kD();Tt();qt();Co();Lg();functiongK(r,e){returnr.line===e.line}functionQc(r){lete=[];returnr.forEach((t,n)=>{leti=t.match(/^(#+)[\s]+(.*)$/);i&&e.push({level:i[1].length,text:i[2],line:n})}),e}functionvd(r,e,t=!1){letn=Qc(r),i=n.find(c=>c.line===e),o=!!i;if(!o&&t)thrownewError(`Target line ${e} is not a heading, but we are trying to find the end of its section.`);if(!o&&!t){letc=vK(r,e,u=>u.trim()==="");returnc!==null&&c>e?c-1:e}lets=r.length-1,a=Zve(i,n,r,t),l=tye(r,a,c=>c.trim()!=="");if(l!==null){if(l<e)returne;letc=r[l+1].trim()==="";returnl+1===s&&!c?a:l===0?l+1:l}returna}functionZve(r,e,t,n){leti=e.findIndex(u=>gK(u,r)),o=i===e.length-1,s=t.length-1;if(o)returns;let[a,l]=Jve(r,e);if(l&&a===e.length)returns;if(l&&n)returne[a].line-1;if(l&&!n)returne[i+1].line;if(!n&&!l){letu=eye(r.line,e);returnu===null?s:u}returns}functionJve(r,e){lett=e.findIndex(i=>gK(i,r)),n=vK(e,t,i=>i.level<=r.level);returnn===null?[-1,!1]:[n,!0]}functioneye(r,e){lett=e.find(n=>n.line>r);returnt?t.line:null}functiontye(r,e,t){for(letn=e-1;n>=0;n--)if(t(r[n]))returnn;returnnull}functionvK(r,e,t){for(letn=e+1;n<r.length;n++)if(t(r[n]))returnn;returnnull}varrye="\u200B";functiongE(r){lete=r.slice(),t=!1,n="",i=0;for(leto=0;o<r.length;o++){lets=r[o].match(/^(\s*)(`{3,}|~{3,})/);if(!t){s&&(t=!0,n=s[2][0],i=s[2].length);continue}e[o]=r[o].replace(/^(\s*)#+(\s)/,`$1${rye}$2`),s&&s[2][0]===n&&s[2].length>=i&&r[o].slice(s[1].length+s[2].length).trim()===""&&(t=!1,n="",i=0)}returne}functionyK(r){return(r.match(/^#+\s+(.*)$/)?.[1]??"").trim()}functionnye(r){lete=r.match(/^\[?v?(\d+)\.(\d+)\.(\d+)(?:[-+\]].*)?$/i)??r.match(/^\[?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/i);if(!e)return{value:0,parsed:!1};lett=n=>Math.min(Number(n??"0"),999999);return{value:t(e[1])*1e12+t(e[2])*1e6+t(e[3]),parsed:!0}}functionbK(r,e,t){switch(e.by){case"lexical":return{value:r.toLocaleLowerCase(),parsed:!0};case"numeric":{letn=r.match(/^-?\d+(?:\.\d+)?/);returnn?{value:Number(n[0]),parsed:!0}:{value:0,parsed:!1}}case"date":{letn=t?t(r,e.dateFormat||void0,!1):null;returnn&&n.isValid()?{value:n.valueOf(),parsed:!0}:{value:0,parsed:!1}}case"semver":returnnye(r);default:return{value:0,parsed:!0}}}functioniye(r,e){if(typeofr.value=="string"&&typeofe.value=="string")returnr.value<e.value?-1:r.value>e.value?1:0;lett=r.value,n=e.value;returnt<n?-1:t>n?1:0}functionwK(r,e,t,n,i,o=0){lets=gE(r),a=Qc(s).filter(f=>f.line>=o),l=a.filter(f=>f.level===t),c=bK(yK(e),n,i);if(l.length===0){letf=a.filter(p=>p.level<t).pop();returnf?{mode:"after",line:vd(s,f.line,!0)}:{mode:"bodyStart"}}letu=()=>{letf=l[l.length-1];return{mode:"after",line:vd(s,f.line,!0)}};if(n.by==="insertion")returnn.direction==="desc"?{mode:"before",line:l[0].line}:u();if(!c.parsed)returnu();letd=n.unparseable??"bottom";for(letfofl){letp=bK(yK(s[f.line]),n,i),m;if(!p.parsed)m=d==="bottom";else{letv=iye(c,p);m=n.direction==="desc"?v>0:v<0}if(m)return{mode:"before",line:f.line}}returnu()}oE();functionhN(r){lete=r.split(`
`,1)[0];this.lastResolvedInsertAfterHeading=/^#+\s+\S/.test(f)?f.trim():null}let o=hN(i);if(gN(o))throw new Ee("Insert-after target is empty after formatting.");let s=mf(this.fileContent),a=this.isOrderedCreate()?_K(s,this.fileContent):s,{start:l,end:c}=vN(a,o);if(l===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(t,i);throw new Ee(`Insert-aftertargetnotfound:'${i}'.`)}let d;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let f=vd(s,l,this.considerSubsectionsForAnchor(s,l)),p=Math.max(f??s.length-1,c);d=OD(s,p,this.fileContent,t)}else{let f=this.choice.insertAfter?.blankLineAfterMatchMode??"auto";d=yN(s,c,this.fileContent,f)}return this.insertTextAfterPositionInBody(t,this.fileContent,d)}async insertBeforeHandler(t){let n=this.choice.insertBefore;if(!n)throw new Ee("Insert-before settings are missing.");let i=await this.formatLocationString(await this.expandFormatTemplateEscapes(n.before)),o=hN(i);if(gN(o))throw new Ee("Insert-before target is empty after formatting.");let s=mf(this.fileContent),{start:a}=vN(s,o);if(a===-1){if(n.createIfNotFound)return await this.createInsertBeforeIfNotFound(t,i);throw new Ee(`Insert-beforetargetnotfound:'${i}'.`)}return this.insertTextBeforePositionInBody(t,this.fileContent,a)}async insertAfterInlineHandler(t,n){if(EK(n))throw new Ee("Inline insert-after target must be a single line \u2014 remove the line break (\\n) or turn off inline insertion.");let i=this.fileContent.indexOf(n);if(i===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInlineInsertAfterIfNotFound(t,n);throw new Ee(`Inlineinsert-aftertargetnotfound:'${n}'.`)}let o=i+n.length;if(this.setCaptureInsertionEndOffset(o+t.length),this.choice.insertAfter?.replaceExisting){let s=TK(this.fileContent,o);return this.fileContent.slice(0,o)+t+this.fileContent.slice(s)}return this.fileContent.slice(0,o)+t+this.fileContent.slice(o)}async createInsertAfterIfNotFound(t,n){let i=`${n}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===cc){let o=On(this.app);if(!o)throw new Ee(`Unabletoinsertline'${this.choice.insertAfter.after}'atcursorposition:noactivemarkdowneditor.`);try{let a=o.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let c=mf(this.fileContent),u=vd(c,a,this.considerSubsectionsForAnchor(c,a));a=OD(c,u??c.length-1,this.fileContent,i)}return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unabletoinsertline'${this.choice.insertAfter.after}'atcursorposition.`)}}if(this.choice.insertAfter?.createIfNotFoundLocation===_a)return this.createInsertAfterOrdered(t,n);throw new Ee(`UnknowncreateIfNotFoundLocation:${this.choice.insertAfter?.createIfNotFoundLocation}`)}isOrderedCreate(){return!!this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation===_a}considerSubsectionsForAnchor(t,n){return xK(!!this.choice.insertAfter?.considerSubsections,t,n)}createInsertAfterOrdered(t,n){let i=this.choice.insertAfter?.orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"},o=n.split(/\r?\n/,1)[0],s=Qc([o])[0]?.level??0,a=`${n}
${t}`;if(s===0)return this.insertAtNoteBodyStartTracking(a);let l=mf(this.fileContent),c=l.map(g=>g.replace(/\r$/,"")),u=bN(this.fileContent),d=gE(c),f=o.replace(/\r$/,"").trimEnd(),p=d.findIndex((g,y)=>y>=u&&g.trimEnd()===f);if(p!==-1){let g=this.choice.insertAfter?.insertAtEnd?OD(d,vd(d,p,this.considerSubsectionsForAnchor(d,p))??d.length-1,this.fileContent,t):yN(d,p,this.fileContent,this.choice.insertAfter?.blankLineAfterMatchMode??"auto");return this.insertTextAfterPositionInBody(t,this.fileContent,g)}let m=typeof window<"u"?window.moment:void 0,v=wK(c,o,s,i,m,u);return v.mode==="bodyStart"?this.insertAtNoteBodyStartTracking(a):this.spliceOrderedSection(l,v,a)}spliceOrderedSection(t,n,i){let{content:o,insertedEndOffset:s}=SK(t,n,i,this.fileContent);return this.setCaptureInsertionEndOffset(s),o}async createInsertBeforeIfNotFound(t,n){let i=this.choice.insertBefore;if(!i)throw new Ee("Insert-before settings are missing.");let o=t.endsWith(`
${o}`;if(i.createIfNotFoundLocation===cc){let s=On(this.app);if(!s)throw new Ee(`Unabletoinsertline'${i.before}'atcursorposition:noactivemarkdowneditor.`);try{let a=s.editor.getCursor();return this.insertTextBeforePositionInBody(o,this.fileContent,a.line,t.length)}catch{throw new Ee(`Unabletoinsertline'${i.before}'atcursorposition.`)}}throw new Ee(`UnknowncreateIfNotFoundLocation:${i.createIfNotFoundLocation}`)}async createInlineInsertAfterIfNotFound(t,n){let i=`${n}${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===uo)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===lc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===cc){let o=On(this.app);if(!o)throw new Ee(`Unabletoinsertline'${this.choice.insertAfter.after}'atcursorposition:noactivemarkdowneditor.`);try{let a=o.editor.getCursor().line;return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unabletoinsertline'${this.choice.insertAfter.after}'atcursorposition.`)}}throw new Ee(`UnknowncreateIfNotFoundLocation:${this.choice.insertAfter?.createIfNotFoundLocation}`)}insertAtNoteBodyStartTracking(t,n=t.length){let i=Q1(this.fileContent,t);if(i.insertedStartOffset===null)return this.setCaptureInsertionEndOffset(null),i.content;let o=Math.max(0,Math.min(n,t.length));return this.setCaptureInsertionEndOffset(i.insertedStartOffset+o),i.content}insertTextAfterPositionInBody(t,n,i){let{content:o,insertedEndOffset:s}=AK(t,n,i,!!this.choice.task);return this.setCaptureInsertionEndOffset(s),o}insertTextBeforePositionInBody(t,n,i,o=t.length){let{content:s,insertedEndOffset:a}=kK(t,n,i,o);return this.setCaptureInsertionEndOffset(a),s}};kD();Me();Jd();qt();Cr();$g();Og();var IK=require("obsidian");Tt();Co();Tl();function PK(r,e){let t=r.trim().replace(/^\/+/,"");if(t==="")return{kind:"vault"};let n=vh(t);if(n){if(!n.field)throw new Ee("Property capture target needs a field name, e.g. property:type=draft");return{kind:"property",field:n.field,value:n.value,filter:n.filter}}let i=gh(t);if(i){if(i.multiSelect)throw new Ee("Capture target filters select one destination file. Use {{FILE:...|multi}} in the capture format for multi-value metadata.");return{kind:"filter",filter:i.filter}}let o=ai(t,"Capture target file path");if(Vi.test(o))throw new Ee(`Captureto'.base'filesisnotsupported(${o}).UseaTemplatechoiceinstead.`);let s=o.endsWith("/"),a=o.replace(/\/+$/,"");if(s)return{kind:"folder",folder:a};if(ir.test(o)||qr.test(o))return{kind:"file",path:o};let l=e.normalizeMarkdownFilePath("",a),u=e.getAbstractFileByPath(l)instanceof IK.TFile;return e.isFolder(a)&&!u?{kind:"folder",folder:a}:{kind:"file",path:o}}Tt();function LD(r){return`${r.replace(/^\/+/,"").replace(ir,"")}.md`}function BD(r,e,t){if(t)return null;let n=(e??"").trim().replace(/^\/+/,"");if(_u(n))return null;let i=vh(n),o=!!i&&!!i.field,s=o?null:gh(n),a=!!s&&!s.multiSelect,l=!o&&!s&&n.startsWith("#"),c=n.endsWith("/"),u=!l&&!o&&!a&&!c&&(ir.test(n)||qr.test(n)||Vi.test(n)),d=n.replace(/\/+$/,""),f=!l&&!o&&!a&&!u&&(n===""||r.isFolder(d)&&!r.markdownFileExists(d)),p=!o&&!a&&c;if(o&&i)return{kind:"property",field:i.field,value:i.value,filter:i.filter};if(a&&s)return{kind:"filter",filter:s.filter};if(l)return{kind:"tag",tag:n};if(f||p){let m=d;return{kind:"folder",folderPathSlash:m===""?"":`${m}/`}}return null}Hv();Tl();Ec();Tm();nm();Rg();Hs();sN();aD();Co();lD();H1();function FK(r){let e=r.insertAfter.enabled||!!r.insertBefore?.enabled;return r.captureToActiveFile&&!e&&r.newLineCapture?.enabled?r.newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":r.captureToActiveFile&&!e?r.activeFileWritePosition==="top"?"activeFileTop":r.activeFileWritePosition==="bottom"||r.prepend?"append":"currentLine":r.insertAfter.enabled?"insertAfter":r.insertBefore?.enabled?"insertBefore":r.prepend?"prepend":"append"}Tt();Co();function wN(r){return r?.type==="text"?"text":r?.type==="file"||r?.file?"file":typeof r?.text=="string"?"text":"unsupported"}function dye(r,e){let t=e.id;if(!t)return null;let n=r.getData?.();return n?.nodes?.length?n.nodes.find(i=>i.id===t)??null:null}function MK(r,e){if(r==="text"){if(e==="currentLine")return"Canvas capture does not support 'At cursor' for text cards. Use top, bottom, insert-after, or insert-before placement.";if(e==="newLineAbove"||e==="newLineBelow")return"Canvas capture does not support 'New line above/below cursor' for text cards. Use top, bottom, insert-after, or insert-before placement."}return r==="file"&&(e==="currentLine"||e==="newLineAbove"||e==="newLineBelow")?"Canvas file cards do not support cursor-based capture modes. Use top, bottom, insert-after, or insert-before modes.":null}fun
`),t}asyncgetFormattedPathToCaptureTo(t){if(t){leta=this.app.workspace.getActiveFile();returnMi(a,"Cannot capture to active file - no active file."),a.path}letn=this.getPreselectedCaptureTargetPath();if(n!==void0){leta=BD({isFolder:l=>om(this.app,l),markdownFileExists:l=>this.app.vault.getAbstractFileByPath(LD(l))instanceofZc.TFile},this.choice.captureTo??"",!1);if(a){letl=this.confinePreselectedToScope(a,n);if(l!==null)returnthis.normalizeCaptureFilePath(l)}}leti=this.choice.captureTo,o=awaitthis.formatter.formatFileName(i,"captureTarget"),s=this.resolveCaptureTarget(o);switch(s.kind){case"vault":returnthis.selectFileInFolder("",!0);case"filter":returnthis.selectFileWithFilter(s.filter);case"property":returnthis.selectFileWithProperty(s.field,s.value,s.filter);case"folder":returnthis.selectFileInFolder(s.folder,!1);case"file":returnthis.normalizeCaptureFilePath(s.path)}}getPreselectedCaptureTargetPath(){lett=this.choiceExecutor?.variables?.get(Gd);returntypeoft=="string"&&t.length>0?t:void0}confinePreselectedToScope(t,n){leti=this.stripLeadingSlash(n);if(t.kind==="folder")returnt.folderPathSlash&&!i.startsWith(t.folderPathSlash)?`${t.folderPathSlash}${i}`:i;if(this.resolveScopeFiles(t).some(l=>l.path===i))returni;if(!(this.choice.createFileIfItDoesntExist?.enabled??!1))returnnull;leta=newSet(this.app.vault.getMarkdownFiles().map(l=>l.basename.toLowerCase()));returnthis.captureTargetAlreadyExists(i,a)?null:i}resolveScopeFiles(t){switch(t.kind){case"filter":returnsm(this.app,t.filter);case"property":returnam(this.app,t.field,t.value,t.filter);case"tag":returnXv(this.app,t.tag);case"folder":returnrs(this.app,t.folderPathSlash)}}resolveCaptureTarget(t){returnPK(t,{getAbstractFileByPath:n=>this.app.vault.getAbstractFileByPath(n),isFolder:n=>om(this.app,n),normalizeMarkdownFilePath:(n,i)=>this.normalizeMarkdownFilePath(n,i)})}captureTargetExists(t,n){leti=n.startsWith(t)?n:`${t}${n}`,o;try{o=ai(i,"Capture target file path")}catch{return!1}lets=[o];return/\.(md|canvas)$/i.test(o)||s.push(`${o}.md`,`${o}.canvas`),s.some(a=>!!this.app.vault.getAbstractFileByPath(a))}asyncselectFileInFolder(t,n){leti=t.endsWith("/")||n?t:`${t}/`,o=rs(this.app,i),s=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(s||o.length>0,`Folder ${i} is empty.`);leta=hf(o,gf(this.app)),l=a.map(v=>v.path),c=Tc(a,v=>this.app.metadataCache.getFileCache(v)),u=l.map((v,g)=>`${c[g]??v}${v}`),d=newSet(c.map(v=>v.toLowerCase())),f=s?"Choose a note or type to create one":void0,p=String(awaitia(this.choiceExecutor,{remote:v=>oa(v,{items:l.map((g,y)=>({value:g,title:c[y]??g})),placeholder:f,allowCustomInput:s,what:"the capture-target picker"}),headless:()=>{throwthis.assertInteractiveCaptureTarget(),newError("unreachable")},app:()=>an.Suggest(this.app,c,l,{placeholder:f,emptyStateText:s?"Type a note name to create it":void0,renderItem:(v,g)=>dE(g,v,this.app),searchItems:u,allowCustomValue:s,customValueLabel:v=>`Create new note: ${v}`,valueExists:v=>d.has(v.toLowerCase())||this.captureTargetExists(i,v)})}));Mi(!!p&&p.length>0,"No file selected for capture.");letm=p.startsWith(`${i}`)?p:`${i}${p}`;returnawaitthis.formatFilePath(m)}asyncselectFileWithFilter(t){letn=sm(this.app,t);returnthis.selectFileFromSet(n,"No files matched the capture target filters.")}asyncselectFileWithProperty(t,n,i){leto=am(this.app,t,n,i),s=n!==void0?`${t}=${n}`:t;returnthis.selectFileFromSet(o,`No notes with property ${s}.`)}captureTargetAlreadyExists(t,n){leti=t.trim();if(!i)return!1;leto;try{o=ai(i,"Capture target file path")}catch{return!1}lets=o.replace(/\.(md|canvas)$/i,"");if([o,`${s}.md`,`${s}.canvas`].some(c=>!!this.app.vault.getAbstractFileByPath(c)))return!0;letl=s.slice(s.lastIndexOf("/")+1);returnn.has(l.toLowerCase())}asyncselectFileFromSet(t,n){leti=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(i||t.length>0,n);leto=hf(t,gf(this.app)),s=o.map(m=>m.path),a=Tc(o,m=>this.app.metadataCache.getFileCache(m)),l=s.map((m,v)=>`${a[v]??m}${m}`),c=newSet(this.app.vault.getMarkdownFiles().map(m=>m.basename.toLowerCa
QuickAdd will now revert to backup.`),r.settings=n,ce.replaceState(ht(r.settings))}}r.saveSettings()}varp7=mbe;It();varHl=require("obsidian");Me();asyncfunctionhbe(r,e,t){letn=await(0,Hl.requestUrl)({url:`https://api.github.com/repos/${r}/${e}/releases`,throw:!1}),i=n.json;if(n.status>=400||!Array.isArray(i)){leta=typeofi=="object"&&i!==null&&"message"ini&&typeofi.message=="string"?i.message:"Unknown error";thrownewError(`Failed to fetch releases: ${a}`)}leto=i,s=o.findIndex(a=>a.tag_name===t);if(s===-1)thrownewError(`Could not find release with tag ${t}`);returno.slice(0,s).filter(a=>!a.draft&&!a.prerelease)}varIN=/^https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+$/,f7=/^\[!\[[^\]]*\]\(([^)\s"]+)\)\]\((https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+)\)$/,gbe=/^<!--\s*poster:\s*(https:\/\/[^\s"'>]+)\s*-->$/;functionvbe(r,e){lett=e?` poster="${e}"`:"";return`<video controls preload="metadata" playsinline style="width: 100%; border-radius: 8px;" src="${r}"${t}></video>`}functionybe(r){lete=r.split(`
`)}varYD=classextendsHl.Modal{constructor(t,n){super(t);this.markdownComponent=newHl.Component;this.isClosed=!1;this.previousVersion=n,this.releaseNotesPromise=hbe("chhoumann","quickadd",n),this.releaseNotesPromise.then(i=>{if(!this.isClosed){if(this.releases=i,this.releases.length===0){this.close();return}this.display()}}).catch(i=>{F.logError(`Failed to fetch release notes: ${i}`)})}onOpen(){let{contentEl:t}=this;t.empty(),t.createEl("h1",{text:"Fetching release notes..."}),this.addCloseFooter()}addCloseFooter(){lett=this.contentEl.createDiv("quickadd-update-modal-footer");newHl.ButtonComponent(t).setButtonText("Done").setCta().onClick(()=>this.close())}onClose(){let{contentEl:t}=this;this.isClosed=!0,this.markdownComponent.unload(),t.empty()}display(){let{contentEl:t}=this;t.empty(),t.classList.add("quickadd-update-modal-container");letn=`### New in QuickAdd v${this.releases[0].tag_name}
`,i="Thank you for using QuickAdd! If you like the plugin, please consider supporting me by buying me a coffee. With your sponsorship, I'll be able to contribute more to my existing projects, start new ones, and be more responsive to issues & feature requests.",o='<div class="quickadd-bmac-container"><a href="https://www.buymeacoffee.com/chhoumann" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 144px !important;" ></a></div>',s=t.createDiv("quickadd-update-modal"),a=this.releases.map(d=>ybe(d.body??"")).join(`
I'd love to get your feedback on QuickAdd! Please fill out this <a href="https://forms.gle/WRq1ewcKK8qmkqps6">feedback form</a> to let me know what you think.
${bbe(a)}`;this.markdownComponent.load(),Hl.MarkdownRenderer.render(this.app,u,s,this.app.vault.getRoot().path,this.markdownComponent),this.addCloseFooter()}};nD();Wr();Co();varwbe=25e3,Cbe=6e4,xbe=3e4,Ebe=75e3,Tbe=32;function_be(r,e){if(r.length!==e.length)return!1;lett=0;for(letn=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);returnt===0}functionAbe(r){if(r.origin||r.referer)return!1;lete=(r.host??"").split(":")[0];returne==="127.0.0.1"||e==="localhost"}functionkbe(r){try{lete=window.require;returne?e(r):null}catch{returnnull}}functionKD(){letr=window.crypto;if(r?.randomUUID)returnr.randomUUID();if(r?.getRandomValues){lete=r.getRandomValues(newUint8Array(16));returnArray.from(e,t=>t.toString(16).padStart(2,"0")).join("")}thrownewError("Interactive prompts require a secure random source (crypto), which is unavailable here.")}varXD="No pending prompt for that requestId",PN="The interactive client disconnected, so the run was ended.";functionSbe(r,e){if(e.cancelled!==void0&&typeofe.cancelled!="boolean")return`The "cancelled" flag must be the literal true (or omitted). A cancel that is not recognised would otherwise be answered on the user's behalf.`;if(e.cancelled===!0)returnnull;if(r==="confirm"){lett=e.value;if(!(t===!0||t===!1||t==="true"||t==="false"))return`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${Dbe(t)}.`}returnnull}functionDbe(r){returnr===void0?"no value":r===null?"null":typeofr=="string"?JSON.stringify(r.slice(0,40)):typeofr=="number"||typeofr=="boolean"?String(r):Array.isArray(r)?"an array":typeofr}varFN=class{constructor(){this.server=null;this.port=0;this.sessions=newMap;this.startPromise=null;this.generation=0}asyncensureStarted(){if(this.server)returnthis.port;if(this.startPromise)returnthis.startPromise;lete=kbe("http");if(!e)thrownewError("Interactive prompts require desktop Obsidian (Node http is unavailable).");lett=this.generation;returnthis.startPromise=newPromise((n,i)=>{leto=e.createServer((s,a)=>{this.handle(s,a)});o.on("error",s=>{this.generation===t&&(this.startPromise=null),i(s)}),o.listen(0,"127.0.0.1",()=>{if(this.generation!==t){o.close(),i(newError("Interactive server stopped during startup."));return}lets=o.address();this.port=typeofs=="object"&&s?s.port:0,this.server=o,n(this.port)})}),this.startPromise}createSession(){if(this.sessions.size>=Tbe)thrownewError("Too many active interactive sessions.");lete=KD(),t=KD()+KD(),n={id:e,token:t,queue:[],waiter:null,waiterTimer:null,pending:newMap,finished:!1,aborted:!1,cleanupTimer:null,attached:!1,attachTimer:null,pollWatchdog:null};returnn.attachTimer=window.setTimeout(()=>{!n.attached&&!n.finished&&this.finish(n.id,{kind:"error",error:"No client attached to the interactive session."})},xbe),this.sessions.set(e,n),{id:e,token:t}}emitPrompt(e,t){letn=this.sessions.get(e);if(!n)returnPromise.reject(newError("Unknown session"));if(n.finished)returnPromise.reject(newEe(PN));if(n.aborted)returnPromise.reject(newSt(yu));leti=KD();returnnewPromise((o,s)=>{n.pending.set(i,{resolve:o,reject:s,promptType:t.type}),this.push(n,{kind:"prompt",requestId:i,prompt:t})})}finish(e,t){letn=this.sessions.get(e);if(!(!n||n.finished)){n.finished=!0,n.attachTimer&&(window.clearTimeout(n.attachTimer),n.attachTimer=null),n.pollWatchdog&&(window.clearTimeout(n.pollWatchdog),n.pollWatchdog=null);for(let[,i]ofn.pending)i.reject(newEe(PN));n.pending.clear(),this.push(n,t),n.cleanupTimer=window.setTimeout(()=>this.destroySession(n),Cbe)}}abortSession(e){lett=this.sessions.get(e);if(!t||t.finished)returnnull;t.aborted=!0;letn=[...t.pending.values()];t.pending.clear();for(letiofn)i.reject(newSt(yu));returnt.queue=t.queue.filter(i=>i.kind!=="prompt"),n.length}stop(){this.generation++;for(leteofthis.sessions.values()){e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.cleanupTimer&&window.clearTimeout(e.cleanupTimer),e.attachTimer&&window.clearTimeout(e.attachTimer),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog);for(let[,t]ofe.pending)t