Files
my-vault/.obsidian/plugins/quickadd/main.js
T

423 lines
1.2 MiB
JavaScript
Raw Normal View History

2026-01-05 19:25:56 +08:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var D4=Object.create;var zh=Object.defineProperty;var F4=Object.getOwnPropertyDescriptor;var P4=Object.getOwnPropertyNames;var M4=Object.getPrototypeOf,$4=Object.prototype.hasOwnProperty;var U$=r=>{throw TypeError(r)};var O4=(r,e,t)=>e in r?zh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var E=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var R4=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},fw=(r,e)=>{for(var t in e)zh(r,t,{get:e[t],enumerable:!0})},H$=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of P4(e))!$4.call(r,i)&&i!==t&&zh(r,i,{get:()=>e[i],enumerable:!(n=F4(e,i))||n.enumerable});return r};var z$=(r,e,t)=>(t=r!=null?D4(M4(r)):{},H$(e||!r||!r.__esModule?zh(t,"default",{value:r,enumerable:!0}):t,r)),N4=r=>H$(zh({},"__esModule",{value:!0}),r);var he=(r,e,t)=>O4(r,typeof e!="symbol"?e+"":e,t),m_=(r,e,t)=>e.has(r)||U$("Cannot "+t);var V=(r,e,t)=>(m_(r,e,"read from private field"),t?t.call(r):e.get(r)),rt=(r,e,t)=>e.has(r)?U$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),Ge=(r,e,t,n)=>(m_(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),lt=(r,e,t)=>(m_(r,e,"access private method"),t);var $R,OR,RR=E(()=>{$R=r=>{let e,t=new Set,n=(c,u)=>{let d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){let p=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(f=>f(e,p))}},i=()=>e,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(t.add(c),()=>t.delete(c))},l=e=r(n,i,a);return a},OR=(r=>r?$R(r):$R)});function Eg(r){if(r.kind)return r.kind;let e=(r.name??"").toLowerCase(),t=s8(r.endpoint),n=i=>t===i||t.endsWith(`.${i}`);return e==="anthropic"||n("api.anthropic.com")?"anthropic":e==="gemini"||n("generativelanguage.googleapis.com")?"gemini":"openai"}function s8(r){let e=(r??"").trim();if(!e)return"";for(let t of[e,`https://${e}`])try{return new URL(t).hostname.toLowerCase()}catch{}return""}function a8(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function nC(r,e){let t=a8(r),n=new Set(e.map(o=>o.id).filter(o=>!!o)),i=t;for(let o=2;n.has(i);o++)i=`${t}-${o}`;return i}function iC(r){let e=!1,t=new Set;for(let n of r){if(n.id&&!t.has(n.id)){t.add(n.id);continue}n.id=nC(n.id??n.name,r),t.add(n.id),e=!0}return e}function pc(r,e){return e&&e.name===r?e:void 0}function oC(r){return Tg[r].map(e=>({...e}))}var Tg,NR,l8,c8,sC,ro=E(()=>{Tg={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 Sg(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 aC(r){return Sg(r).map(([e,t])=>`${e}=${t}`).join(", ")}var Kp,td=E(()=>{Kp={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 lC,wA=E(()=>{ro();td();lC={choices:[],inputPrompt:"single-line",persistInputPromptDrafts:!0,useSelectionAsCaptureValue:!0,namePastedImagesAfterNoteTitle:!1,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:Kp,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:sC,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 Ve(r){if(typeof structuredClone=="function")try{return structuredClone(r)}catch{}return fc(r,new Map)}function fc(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(fc(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(fc(o,e),fc(s,e));return i}if(r instanceof Set){let i=new Set;e.set(r,i);for(let o of r.values())i.add(fc(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(fc(r.buffer,e),r.byteOffset,r.byteLength);return e.set(r,a),a}let i=r,o=fc(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:fc(o,e),writable:!0,enumerable:!0,configurable:!0});return n}var Jr=E(()=>{});var X,dt=E(()=>{RR();wA();Jr();X=(()=>{let r=OR((i,o)=>({...Ve(lC)})),{getState:e,setState:t,subscribe:n}=r;return{getState:e,replaceState:i=>t(i,!0),setState:t,subscribe:n}})()});var rd,_g,I,Ie=E(()=>{rd=class rd{register(e){return rd.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;rd.loggers.forEach(o=>o.logError(t,n,i))}logWarning(e){let t=e instanceof Error?e.message:e,n=e in
`)?`${r}${e}`:`${r}
${e}`}async function PN(r,e,t,n){let i=t.destination;if(i?.type!=="specifiedFile")return!1;let o=$g(r,i);if(!o)throw new Error(`Append link target file not found or is not a Markdown file: ${i.path}`);let s=CC(r,e,{sourcePath:o.path,linkType:"link"}),a;return await r.vault.process(o,l=>{let c=D8(l,s);return a={filePath:o.path,before:l,after:c,edits:[{from:l.length,to:l.length,text:c.slice(l.length)}]},c}),a&&n?.(a),!0}async function F8(r){let e=window.navigator?.clipboard;if(!e?.writeText)return I.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{return await e.writeText(r),!0}catch(t){return I.logMessage(`QuickAdd: Could not copy link to clipboard: ${t instanceof Error?t.message:String(t)}`),!1}}async function MN(r){let e=I8(r);return await F8(e)?(new Mg.Notice(`Copied link to '${r.basename}' to clipboard.`,FN),!0):(new Mg.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,FN),!1)}var Mg,FN,Og=E(()=>{Mg=require("obsidian");Ie();wc();FN=4e3});function io(r){if(r.nodeType===Node.DOCUMENT_NODE)return r;let e=r.ownerDocument;if(!e)throw new Error("Unable to resolve owner document for DOM node.");return e}function Rg(r){let e=io(r).defaultView;if(!e)throw new Error("Unable to resolve owner window for DOM node.");return e}function er(r,e){return io(r).win.createEl(e)}function Ng(r,e){return io(r).createTextNode(e)}var bs=E(()=>{});function xC(r){for(let e of r.workspace.getLeavesOfType("markdown")){let t=e.view;if(!(!t.containerEl||!t.file||t.file.extension!=="md"))try{let n=io(t.containerEl).activeElement;if(!n||!t.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(P8))continue;let o=n.closest(".metadata-property")?.getAttribute("data-property-key");if(!o)continue;return{file:t.file,key:o}}catch{continue}}return null}function M8(r,e,t){let n=NN(r,e),i=r[n];if(Array.isArray(i)){i.push(t);return}if(i==null||i===""){r[n]=t;return}if(typeof i=="string"){r[n]=`${i} ${t}`;return}throw new Error(`Cannot append link to frontmatter property '${n}' because it contains a ${typeof i} value.`)}function RN(r,e,t,n=ud){let i=NN(r,e),o=r[i];if(Array.isArray(o)){o.push(t);return}if(o===null||o===""){r[i]=[t];return}if(o===void 0){if(n==="error")throw new Error(`Cannot append link to frontmatter property '${i}' because it does not exist.`);r[i]=[t];return}if(typeof o=="object")throw new Error(`Cannot append link to frontmatter property '${i}' because it contains an object value.`);if(n!=="alwaysAppend")throw new Error(`Cannot append link to frontmatter property '${i}' because it is not a list and the link-handling mode is '${$N[n]}'. Choose '${$N.alwaysAppend}' to convert it into a list and append.`);r[i]=[o,t]}function NN(r,e){if(e=e.trim(),!e)throw new Error("Cannot append link to an empty frontmatter property key.");let t=ON(e),n=Object.keys(r).filter(i=>ON(i)===t);if(n.length>1)throw new Error(`Cannot append link to frontmatter property '${e}' because the note has multiple properties that normalize to that key.`);return n[0]??e}function ON(r){return r.trim().toLowerCase()}async function LN(r,e,t){let n=r.fileManager.generateMarkdownLink(t,e.file.path);try{return await r.fileManager.processFrontMatter(e.file,i=>{M8(i,e.key,n)}),!0}catch(i){return I.logError(`QuickAdd: created the file but could not append the link to frontmatter property '${e.key}' in '${e.file.path}': ${i instanceof Error?i.message:String(i)}`),!1}}var $N,P8,Lg=E(()=>{Ie();wc();bs();$N={alwaysAppend:"Create or convert",createProperty:"Create if missing",error:"Require list"},P8=['input[type="number"]','input[type="date"]','input[type="datetime-local"]','input[type="time"]','input[type="month"]','input[type="checkbox"]'].join(", ")});function VN(r,e,t,n){let i=No(e,t);return i?NA(r,i.editor,n):null}function NA(r,e,t){if(r.cursor.kind==="none")return null;let n=r.content.replace(/\r\n?/g,`
`),i=r.content.slice(0,r.cursor.value).replace(/\r\n?/g,`
`).length,o=d=>e.posToOffset(d),s=e.getCursor(),a;if(t==="currentLine")a=e.listSelections().map(({anchor:d,head:p})=>({from:o(d)<=o(p)?d:p,to:o(d)<=o(p)?p:d,text:n,cursor:i}));else if(t==="newLineAbove"||t==="newLineBelow"){let d=t==="newLineAbove";a=[{from:{line:s.line,ch:d?0:e.getLine(s.line).length},text:d?n+`
`:`
`+n,cursor:i+(d?0:1)}]}else return null;let l=[],c=[],u=0;a.sort((d,p)=>o(d.from)-o(p.from));for(let d of a)l.push(o(d.from)+u+d.cursor),c.push(o(d.from)+u+d.text.length-(t==="newLineAbove"?1:0)),u+=d.text.length-(o(d.to??d.from)-o(d.from));return e.transaction({changes:a.map(({from:d,to:p,text:f})=>({from:d,to:p,text:f}))}),e.setSelections(c.map(d=>({anchor:e.offsetToPos(d)}))),{offsets:l,content:e.getValue()}}function No(r,e){let t=xn(r);return t?.file?.path===e.path?t:null}function LA(r,e){try{let t=xn(e);return t?(t.editor.replaceSelection(r),!0):(I.logError(`unable to append '${r}' to current line.`),!1)}catch{return I.logError(`unable to append '${r}' to current line.`),!1}}function VA(r,e,t){try{let n=xn(t);if(!n)return I.logError(`unable to insert '${r}' on new line ${e}.`),!1;let i=n.editor,s=i.getCursor().line,a=r.split(`
`),l=a.length,c=a[l-1]?.length??0;if(e==="above")i.replaceRange(r+`
`,{line:s,ch:0}),i.setCursor({line:s+l-1,ch:c});else{let u=i.getLine(s);i.replaceRange(`
`+r,{line:s,ch:u.length}),i.setCursor({line:s+l,ch:c})}return!0}catch{return I.logError(`unable to insert '${r}' on new line ${e}.`),!1}}function BA(r,e){return VA(r,"above",e)}function qA(r,e){return VA(r,"below",e)}function $8(r,e,t,n,i){let o=c=>r.posToOffset(c),s=e.map(c=>{let[u,d]=o(c.anchor)<=o(c.head)?[c.anchor,c.head]:[c.head,c.anchor];return{from:u,to:d,text:n(r.getRange(u,d))}}).sort((c,u)=>o(c.from)-o(u.from)),a=s.map(({from:c,to:u,text:d})=>t==="replaceSelection"?{from:c,to:u,text:d}:{from:u,text:d}),l=[];if(t==="replaceSelection"){let c=0;for(let{from:u,to:d,text:p}of s)l.push(o(u)+c+p.length),c+=p.length-(o(d)-o(u))}i(a,()=>r.transaction({changes:a})),t==="replaceSelection"&&r.setSelections(l.map(c=>({anchor:r.offsetToPos(c)})))}async function BN(r,e,t="replaceSelection",n={}){let{requireActiveView:i=!0,frontmatterProperty:o,frontmatterHandling:s=ud,textForSelection:a,onEditorTextMutation:l}=n,c=r.workspace.getActiveViewOfType(EC.MarkdownView);if(!c){let g="Cannot append link because no active Markdown view is available.";if(i)throw new Error(g);I.logMessage(g);return}if(t==="inFrontmatter"){let g=c.file;if(!g)throw new Error("Cannot append link because the active Markdown view has no file.");await r.fileManager.processFrontMatter(g,v=>{RN(v,o??"",e,s)});return}let u=c.editor;if(!u){let g="Cannot append link because the active Markdown view has no editor.";if(i)throw new Error(g);I.logMessage(g);return}let d=(g,v)=>{if(!l){v();return}let y=u.getValue(),b=g.map(x=>({from:u.posToOffset(x.from),to:u.posToOffset(x.to??x.from),text:x.text}));v(),l({filePath:c.file?.path??null,before:y,after:u.getValue(),edits:b})},p=u.listSelections().map(g=>({anchor:{...g.anchor},head:{...g.head}}));if(a&&p.length>0&&(t==="replaceSelection"||t==="afterSelection")){$8(u,p,t,a,d);return}if(t==="replaceSelection"){let g=p.map(({anchor:v,head:y})=>({from:u.posToOffset(v)<=u.posToOffset(y)?v:y,to:u.posToOffset(v)<=u.posToOffset(y)?y:v,text:e}));d(g,()=>u.replaceSelection(e));return}let f=({line:g,ch:v})=>u.posToOffset({line:g,ch:v}),m=p.sort((g,v)=>f(v.head)-f(g.head));for(let g of m){let v=f(g.anchor)>f(g.head)?g.anchor:g.head;switch(t){case"afterSelection":{d([{from:v,text:e}],()=>u.replaceRange(e,v));break}case"endOfLine":case"newLine":{let y=u.getLine(v.line).length,b=t==="newLine"&&y>0?`
`:"",x={line:v.line,ch:y};d([{from:x,text:b+e}],()=>u.replaceRange(b+e,x));break}}}}async function TC(r,e,t,n){if(!t?.enabled)return!1;let i=bc(t),o=r.workspace.getActiveViewOfType(EC.MarkdownView),s=i.placement!=="inFrontmatter";if(!o||!o.file||s&&!o.editor){if(t.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let a=o.file.path,l=CC(r,e,{sourcePath:a,linkType:i.linkType,placement:i.placement}),c=i.displayText==="selection"?u=>CC(r,e,{sourcePath:a,linkType:i.linkType,placement:i.placement,alias:u}):void 0;return await BN(r,l,i.placement,{requireActiveView:!1,frontmatterProperty:i.frontmatterProperty,frontmatterHandling:i.frontmatterHandling,textForSelection:c,onEditorTextMutation:n}),!0}function UA(r,e,t,n){return Vg(r,e,[t],n)}function Vg(r,e,t,n){try{if(e.extension!=="md"||!t.length||t.some(c=>!Number.isSafeInteger(c)||c<0||c>n.length))return!1;let i=r.workspace.getActiveViewOfType(EC.MarkdownView);if(!i||i.file?.path!==e.path||i.getMode()==="preview")return!1;let o=i.editor;if(!o)return!1;let s=o.getValue(),a=t;if(s!==n){if(s!==n.replace(/\r\n?/g,`
`))return!1;a=t.map(c=>n.slice(0,c).replace(/\r\n?/g,`
`).length)}a.length===1?o.setCursor(o.offsetToPos(a[0])):o.setSelections(a.map(c=>({anchor:o.offsetToPos(c)})));let l=i.containerEl?.ownerDocument;return l&&l.activeElement===l.body&&o.focus(),!0}catch{return I.logMessage(`Unable to place cursor after capture in '${e.path}'.`),!1}}var EC,Bg=E(()=>{EC=require("obsidian");ys();Ie();wc();Og();Lg()});function kC(r){return Nt.test(r)||cr.test(r)||wn.test(r)}function Vn(r,e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let n=kC(t)?t:`${t}.md`,i=r.vault.getAbstractFileByPath(n);return i instanceof qN.TFile?i:null}function ri(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 HA(r,e){return e.length===0?!0:e.some(t=>r===t||r.startsWith(`${t}/`))}var qN,qg=E(()=>{qN=require("obsidian");Xe()});function HN(r){if(!r)return!1;let e=r,t=e.getViewState?.();return!!e.pinned||!!t?.pinned||!!t?.state?.pinned}function Ug(r){let e=r.workspace;return(e.rootSplit?e.getMostRecentLeaf?.(e.rootSplit):null)??e.getMostRecentLeaf?.()??null}function O8(r){let e=[];return r.workspace.iterateRootLeaves(t=>{e.includes(t)||e.push(t)}),e}function UN(r){return r.parent?.id??r.parent??null}function R8(r,e){let t=UN(e),n=r.filter(s=>s===e||HN(s)?!1:t===null||UN(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 N8(r){return r instanceof Jp.TFile?!0:typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"&&"extension"in r&&typeof r.extension=="string"}function L8(r,e,t,n){if(n&&(e==="tab"||e==="reuse")&&HN(n))return R8(O8(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 Hg(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(!N8(c)){let f=typeof e=="string"?e:e.path;throw new Error(`File not found: ${f}`)}let u=l??Ug(r),d=s?null:r.workspace.activeLeaf,p=L8(r,n,i,u);if(!p)throw new Error("Could not obtain a workspace leaf.");if(d&&r.workspace.activeLeaf!==d&&r.workspace.setActiveLeaf(d,{focus:!1}),s?await p.openFile(c):await p.openFile(c,{active:!1}),o&&o!=="default"&&!(typeof o=="object"&&o.mode==="default")){let f=p.getViewState(),m={...f.state??{}};o==="preview"||typeof o=="object"&&o.mode==="preview"?(m.mode="preview",delete m.source):o==="source"?(m.mode="source",m.source=!0):o==="live"||o==="live-preview"?(m.mode="source",m.source=!1):typeof o=="object"&&o.mode==="source"&&(m.mode="source",m.source=o.source),await p.setViewState({...f,...!s&&{active:!1},state:{...m,...a}})}return s&&r.workspace.setActiveLeaf(p,{focus:!0}),p}function zA(r){return(0,Jp.normalizePath)(r).replace(/\/{2,}/g,"/").replace(/^\/+/,"")}function zN(r,e){return zA(r)===zA(e)}function WA(r,e,t=!0){let n;return r.workspace.iterateRootLeaves(i=>{if(n&&n===r.workspace.activeLeaf)return;let o=i.view;if(o instanceof Jp.FileView&&o.file&&(o.file===e||zN(e.path,o.file.path))){n=i;return}}),n!==void 0?(t&&r.workspace.setActiveLeaf(n,{focus:!0}),n):null}var Jp,WN=E(()=>{Jp=require("obsidian")});function ll(r){let e=0,t=0,n=!1,i=0,o=0,s=0;for(;e<=r.length;){let a=r.indexOf(`
`,e),l=a===-1?r.length:a,c=r.slice(e,l).replace(/\r$/,""),u=a===-1?r.length+1:a+1,d=V8.exec(c);if(n){if(d&&d[1].length>=i&&d[2].trim().length===0)return jN(r.slice(o,e),s)}else if(d){let p=d[2].trim().split(/\s+/)[0]?.toLowerCase();(p==="js"||p==="javascript")&&(n=!0,i=d[1].length,o=u,s=t+1)}if(e=u,t++,a===-1)break}return n?jN(r.slice(o),s):{code:null,error:B8}}function jN(r,e){return r.trim().length===0?{code:"",error:q8}:{code:`
`.repeat(e)+r}}var V8,B8,q8,zg=E(()=>{V8=/^ {0,3}(`{3,})(.*)$/,B8="No ```js (or ```javascript) code block found in the note.",q8="The ```js code block is empty."});function GN(r){return r instanceof SC}function H8(r){return r.charCodeAt(0)===65279?r.slice(1):r}function z8(r){return H8(r).trimStart().slice(0,U8).toLowerCase()}function W8(r){return/^<(?:!doctype\s+html|html\b|head\b|body\b|script\b|meta\b|title\b|div\b)/.test(z8(r))}function jA(r,e){let t=new SC(r);throw e.reportLoadErrors!==!1&&Ze(t),t}function j8(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.`}function G8(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.`}function Y8(r,e){let t=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.`}function K8(r){return YN(r)?(r instanceof Error?r.message:String(r)).match(/Cannot find module ['"]([^'"]+)['"]/)?.[1]:void 0}function YN(r){return!r||typeof r!="object"?!1:r.code==="MODULE_NOT_FOUND"?!0:(r instanceof Error?r.message:String(r)).includes("Cannot find module")}function Q8(r){return r!==null&&typeof r=="object"}function X8(r){return typeof r.entry=="function"?!0:Object.entries(r).some(([e,t])=>e!=="settings"&&e!=="quickadd"&&typeof t=="function")}function Z8(r){return typeof r=="function"?!0:Q8(r)?X8(r):!1}function dd(r){let e=r.split("::").map(t=>t.trim()).filter(Boolean);return{basename:e[0],memberAccess:e.slice(1)}}function AC(r){let e=r.path??r.id;if(e===void 0)return;let{memberAccess:t}=dd(r.name??"");return t&&t.length>0?`${e}::${t.join("::")}`:e}async function Lo(r,e,t={}){let n=e.vault.getAbstractFileByPath(r.path);if(!n){I.logError(`failed to load file ${r.path}.`);return}if(n instanceof _C.TFile){let i=m=>window.require&&window.require(m),o={},s={exports:o},a=await e.vault.read(n),l=a;if(Nt.test(n.path)){let{code:m,error:g}=ll(a);if(m===null||m.length===0){t.reportLoadErrors!==!1&&new _C.Notice(`QuickAdd: ${g} (${r.path})`);return}l=m}W8(l)&&jA(j8(r.path),t);try{new Function("require","module","exports",l)(i,s,o)}catch(m){throw YN(m)&&jA(Y8(r.path,K8(m)),t),m}let c=o.default||s.exports;if(!c)return;let u=c,d=!!o.default,{memberAccess:p}=dd(r.name),f=!!(p&&p.length>0);if(p&&p.length>0){let m;for(;m=p.shift();)u=u[m]}return d&&!f&&!Z8(u)&&jA(G8(r.path),t),u}}var _C,U8,SC,IC=E(()=>{_C=require("obsidian");Xe();Ie();zg();xt();U8=1024,SC=class extends Error{constructor(e){super(e),this.name="UserScriptLoadError"}}});function ef(r){if(r==null||typeof r!="string"&&typeof r!="number"&&typeof r!="boolean")return"";let e=String(r).trim();return e.startsWith("#")?e.substring(1).trim():e}function Wg(r){return r==null?[]:(Array.isArray(r)?r:typeof r=="string"?r.split(/,|\s+/):[r]).map(ef).filter(Boolean)}var GA=E(()=>{});var xi,pd=E(()=>{GA();xi=class{static filterFiles(e,t,n){let i=this.applyInclusionFilters(e,t,n);return this.applyExclusionFilters(i,t,n)}static applyInclusionFilters(e,t,n){let i=e,o=this.getIncludeFolders(t);return o.length>0&&(i=i.filter(s=>o.some(a=>this.matchesFolder(s,a)))),t.tags&&t.tags.length>0&&(i=i.filter(s=>this.matchesTags(s,t.tags??[],n,"all"))),i}static applyExclusionFilters(e,t,n){return e.filter(i=>!(t.excludeFolders?.length&&t.excludeFolders.some(o=>this.matchesFolder(i,o)))&&!(t.excludeTags?.length&&this.matchesTags(i,t.excludeTags,n,"any"))&&!(t.excludeFiles?.length&&t.excludeFiles.some(o=>this.matchesFile(i,o))))}static getIncludeFolders(e){let t=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...new Set(t.map(n=>this.normalizePath(n)).filter(Boolean))]}static matchesFolder(e,t){let n=this.normalizePath(t),
`,e-1)+1,l=r.indexOf(`
`,Math.max(e,t)),c=l===-1?r.length:l,u=r.slice(a,e),d=r.slice(t,c),p=(u.match(/^\s*/)||[""])[0],f=r[e-1]==='"'&&r[t]==='"'||r[e-1]==="'"&&r[t]==="'",m=u.replace(/["']$/,""),v=d.replace(/^["']/,"").replace(/\s+#.*$/,"").trim().length===0,y=/:\s*$/.test(m)&&v,b=/^\s*-\s*$/.test(m)&&v;return{isInYaml:!0,isQuoted:f,lineStart:a,lineEnd:c,baseIndent:p,isKeyValuePosition:y,isListItemPosition:b}}var HI=E(()=>{});function N1(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(aQ,e=>`\\x${e.charCodeAt(0).toString(16).padStart(2,"0")}`)}function mv(r){return`"${N1(r)}"`}function zI(r,e,t){let n=fv(r,e,t,pv(r));return!n.isInYaml||!n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}function Ed(r,e,t,n){return zI(r,e,t)?r[e-1]==='"'?N1(n):n.replace(/'/g,"''"):n}function WI(r,e,t){let n=fv(r,e,t,pv(r));return!n.isInYaml||n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}var aQ,rx=E(()=>{HI();aQ=new RegExp("[\0-\x7F]","g")});function nx(r,e,t){let n=r.trim().toLowerCase();if(lQ.has(n))return n;t?.(`QuickAdd: Unsupported multi-select format "${r}" in "${e}". Supported formats: auto, inline, spaced, yaml, markdown.`)}function cQ(r,e){let t=r.lastIndexOf(`
`,e-1)+1;return r.slice(t,e).match(/^\s*/)?.[0]??""}function uQ(r){return`- ${r.replace(/\r\n?|\n/g,`
`)}`}function L1(r){let{input:e,matchStart:t,values:n,format:i}=r,o=n.map(s=>String(s));switch(i){case"auto":return;case"inline":return o.join(",");case"spaced":return o.join(", ");case"yaml":return`[${o.map(mv).join(", ")}]`;case"markdown":{if(o.length===0)return"";let s=cQ(e,t);return o.map(uQ).join(`
${s}`)}default:return i}}var lQ,ix=E(()=>{rx();lQ=new Set(["auto","inline","spaced","yaml","markdown"])});function sx(r,e){return r.length<=e?r:`${r.slice(0,e)}\u2026`}function pQ(r){let e=r.map(t=>`"${t}"`);return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function V1(r,e){let t=sx(r,32),n=`{{FIELD:${sx(e,48)}}}`,i=dQ.get(r);if(i)return`Unknown FIELD filter "${t}" - ${i}. Ignored in ${n}.`;let o=O1(r,ox);return o.length>0?`Unknown FIELD filter "${t}" - did you mean ${pQ(o)}? Ignored in ${n}.`:`Unknown FIELD filter "${t}" in ${n} was ignored. Supported filters: ${ox.join(", ")}.`}function fQ(r,e){let t=sx(r,32);return`FIELD filter "${t}" needs a value - write "${t}:value". Ignored in {{FIELD:${sx(e,48)}}}.`}function mQ(r,e,t){(t.warn??wf)(V1(r,e))}var ox,dQ,oi,hl=E(()=>{dv();xc();R1();ix();ox=["folder","tag","inline","inline-code-blocks","exclude-folder","exclude-tag","exclude-file","default","default-from","default-empty","default-always","case-sensitive","multi","format"],dQ=new Map([["case-insensitive",'matching is already case-insensitive; use "case-sensitive:true" to match exactly']]);oi=class{static parse(e,t){let n=qo(e).map(c=>c.trim()),i=n[0],o={},s=!1,a="auto",l=!1;for(let c=1;c<n.length;c++){let u=n[c];if(u.toLowerCase()==="multi"){s=!0;continue}let d=Uo(u);if(!d){let m=u.toLowerCase();t?.warnUnknown&&m&&(t.warn??wf)(ox.includes(m)?fQ(m,e):V1(m,e));continue}let p=d.key,f=d.value;if(!ox.includes(p)){t?.warnUnknown&&mQ(p,e,t);continue}switch(p){case"multi":s=Cc(f);break;case"format":l=!0,a=nx(f,`{{FIELD:${e}}}`,t?.warn)??"auto";break;case"folder":o.folders??(o.folders=[]),o.folders.push(f),o.folder||(o.folder=f);break;case"tag":{o.tags??(o.tags=[]);let m=f.startsWith("#")?f.substring(1):f;o.tags.push(m);break}case"inline":o.inline=f.toLowerCase()==="true";break;case"inline-code-blocks":o.inlineCodeBlocks??(o.inlineCodeBlocks=[]),o.inlineCodeBlocks.push(...f.split(",").map(m=>m.trim().toLowerCase()).filter(m=>m.length>0));break;case"default":o.defaultValue=f;break;case"default-from":o.defaultFrom=f.toLowerCase();break;case"default-empty":o.defaultEmpty=f.toLowerCase()==="true";break;case"default-always":o.defaultAlways=f.toLowerCase()==="true";break;case"case-sensitive":o.caseSensitive=f.toLowerCase()==="true";break;case"exclude-folder":o.excludeFolders??(o.excludeFolders=[]),o.excludeFolders.push(f);break;case"exclude-tag":{o.excludeTags??(o.excludeTags=[]);let m=f.startsWith("#")?f.substring(1):f;o.excludeTags.push(m);break}case"exclude-file":o.excludeFiles??(o.excludeFiles=[]),o.excludeFiles.push(f);break}}return!s&&l&&(t?.warn?.(`QuickAdd: |format: needs |multi in "{{FIELD:${e}}}"; ignoring.`),a="auto"),{fieldName:i,filters:o,...s?{multiSelect:s}:{},...a!=="auto"?{multiFormat:a}:{}}}}});function jI(r){return r.replace(/^\/+|\/+$/g,"")}function hv(r,e=t=>t){return JSON.stringify([...r].map(e).sort())}function B1(r,e){let t=[`folder=${jI(r)}`];return e.folders?.length&&t.push(`folders=${hv(e.folders,jI)}`),e.tags?.length&&t.push(`tags=${hv(e.tags)}`),e.excludeFolders?.length&&t.push(`xfolder=${hv(e.excludeFolders,jI)}`),e.excludeTags?.length&&t.push(`xtag=${hv(e.excludeTags)}`),e.excludeFiles?.length&&t.push(`xfile=${hv(e.excludeFiles)}`),t.join("|")}function gQ(r){let{folderPath:e,mode:t,label:n,optional:i,allowCustomInput:o,multiSelect:s,filter:a}=r,l=[B1(e,a),`mode=${t}`];return n&&l.push(`label=${n}`),i&&l.push("optional"),o&&l.push("custom"),s&&l.push("multi"),l.join("|")}function ax(r,e){if(!r)return null;let t=qo(r),n=(t.shift()??"").trim();if(!n)return null;let i=t,o=ws(i,"optional");i=o.remaining;let s=o.found,a=ws(i,"custom");i=a.remaining;let l=a.found,c=ws(i,"multi");i=c.remaining;let u=c.found,d="name",p=[];for(let w of i){let T=w.trim().toLowerCase();if(hQ.has(T)){d=T;continue}p.push(w)}let f,m;for(let w of p){let T=Uo(w);T&&(T.key==="label"&&T.value?f=T.value:T.key==="name"&&T.value&&(m=T.value))}let g=oi.parse(r,{warn:e?.warn}),v=u||(g.multiSelect??!1),y=g.multiFormat??"auto",b={folder:n,tags:g.filters.tags,excludeFolders:g.filters.excludeFolders,excludeTags:g.filt
`:" ");try{return $Q(e,T),T}catch(C){return I.logError(`Failed to insert image link: ${C instanceof Error?C.message:String(C)}`),new Cv.Notice("QuickAdd: saved the image but could not insert its link."),""}}async function g(y){let b=new Date,x=FQ(y);if(x.length===0)return I.logMessage("QuickAdd: image ingest skipped (no-images)."),"";if(i)return new Cv.Notice("QuickAdd: an image is still being saved \u2014 drop again in a moment."),I.logMessage("QuickAdd: image ingest skipped (busy)."),"";let w="";return i=(async()=>{w=await m(x,b)})().finally(()=>{i=null}),await i,w.length>0&&I.logMessage(`QuickAdd: ingested ${x.length} image(s) into the active prompt.`),w}e.addEventListener("paste",u),e.addEventListener("dragenter",d),e.addEventListener("dragover",d),e.addEventListener("dragleave",p),e.addEventListener("drop",f),e.addEventListener("compositionstart",a),e.addEventListener("compositionend",l);let v={isBusy:()=>i!==null,whenIdle:()=>i??Promise.resolve(),ingestFiles:g,detach:()=>{o=!0,p(),e.removeEventListener("paste",u),e.removeEventListener("dragenter",d),e.removeEventListener("dragover",d),e.removeEventListener("dragleave",p),e.removeEventListener("drop",f),e.removeEventListener("compositionstart",a),e.removeEventListener("compositionend",l);let y=px.findIndex(b=>b.handle===v);y>=0&&px.splice(y,1)}};return px.push({handle:v,inputEl:e}),v}async function Q1(r){let e=AQ();if(!e)return I.logMessage("QuickAdd: image ingest skipped (no-active-prompt)."),{ok:!1,reason:"no-active-prompt"};if(e.handle.isBusy())return I.logMessage("QuickAdd: image ingest skipped (busy)."),{ok:!1,reason:"busy"};let t=await e.handle.ingestFiles(r);return t.length===0?{ok:!1,reason:"no-images"}:{ok:!0,inserted:t}}function j1(r,e,t){switch(r){case"paste":{if(e.getData("text/plain").length>0)return{kind:"stand-down"};let n=G1(e).map(i=>({origin:"bytes",...i,naming:{kind:"paste-name"}}));return n.length>0?{kind:"take",images:n}:{kind:"stand-down"}}case"drop":{let n=IQ(e,t);if(n.length>0)return{kind:"take",images:n};let i=G1(e).map(o=>({origin:"bytes",...o,naming:X1(o)}));return i.length>0?{kind:"take",images:i}:{kind:"stand-down"}}default:return fx(r)}}function IQ(r,e){let t=[];for(let n of r.getData("text/plain").split(/\r?\n/u)){let i=n.trim();if(i.length===0||i.toLowerCase().startsWith("file://")||Dr(i))continue;let o=e.vault.getAbstractFileByPath(i);DQ(o)&&t.push({origin:"vault",file:o})}return t}function DQ(r){return r!==null&&"extension"in r&&typeof r.extension=="string"&&H1(r.extension)}function G1(r){let e=[],t=0;for(let o of Array.from(r.items??[])){if(o.kind!=="file"||(t++,!vl(o.type)))continue;let s=o.getAsFile();s&&e.push({file:s,mimeType:o.type})}if(t>0&&e.length===t)return e;if(e.length===0){let o=[];for(let s of Array.from(r.files??[]))vl(s.type)&&o.push({file:s,mimeType:s.type});return o}let n=[...e],i=new Set(e.map(({file:o,mimeType:s})=>`${o.name}\0${o.size}\0${s}\0${o.lastModified}`));for(let o of Array.from(r.files??[])){if(!vl(o.type))continue;let s=`${o.name}\0${o.size}\0${o.type}\0${o.lastModified}`;i.has(s)||(i.add(s),n.push({file:o,mimeType:o.type}))}return n}function FQ(r){return r.flatMap(e=>{if(!vl(e.type))return[];let t={file:e,mimeType:e.type};return[{origin:"bytes",...t,naming:X1(t)}]})}function X1(r){let e=W1(r.file.name);return e===null?{kind:"clipboard-stamp"}:{kind:"original-stem",stem:e}}function PQ(r,e,t){switch(r.naming.kind){case"clipboard-stamp":return z1(r.mimeType,e);case"paste-name":return lx({extension:gl[r.mimeType],sourcePath:t,now:e,nameAfterNoteTitle:X.getState().namePastedImagesAfterNoteTitle});case"original-stem":return`${r.naming.stem}.${gl[r.mimeType]}`;default:return fx(r.naming)}}function Y1(r){return Array.from(r.types??[]).some(e=>e==="Files"||vl(e))}function fx(r){throw new Error(`Unexpected image intake value: ${String(r)}`)}function MQ(r){let e=K1.then(r,r);return K1=e.catch(()=>{}),e}function $Q(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.dispatchEve
`)?r.replace(/\r?\n/g,`
`):r.includes("\\n")?r.replace(/\\n/g,`
`):r}function sX(r){if(!r)return!1;let e=r.toLowerCase();return e==="list"||e==="tags"||e==="multitext"}function m2(r,e){let t=r.trim();if(!t)return;let n=oX(t),i=e?.propertyType??ca(e?.app,e?.propertyKey),o=sX(i),a=o||i===null,c=n.split(/\n/).map(u=>u.trim()).filter(u=>u.length>0);if(a&&c.length>0&&c.every(u=>/^-\s+/.test(u)))return c.map(u=>u.replace(/^-[\s]*/,"").trim());if(n.startsWith("[")&&n.endsWith("]")||n.startsWith("{")&&n.endsWith("}")){if(i&&!o&&i!=="list")return;try{return JSON.parse(n)}catch{}}if(n.includes(",")&&a){let u=iX(n);if(u.length>1)return u}}var f2,h2=E(()=>{_f();f2={"[":"]","(":")","{":"}","<":">"}});function Af(r){if(typeof r=="string"&&r.startsWith("@date:")){let e=r.substring(6),t=new Date(e);if(!Number.isNaN(t.getTime()))return t}return r}function iD(r){return typeof r!="string"&&(Array.isArray(r)||typeof r=="object"&&r!==null||typeof r=="number"||typeof r=="boolean"||r===null)}function g2(r){return Array.isArray(r)||typeof r=="object"&&r!==null}function v2(r){if(iD(r))return Array.isArray(r)?"[]":r===null?"null":typeof r=="object"?"{}":String(r)}var If=E(()=>{});var y2,co,Sv=E(()=>{HI();h2();If();_f();y2="\0",co=class{constructor(e){this.app=e;this.map=new Map;this.propertyTypeCache=new Map}maybeCollect(e){let{input:t,matchStart:n,matchEnd:i,rawValue:o,fallbackKey:s,collectionActive:a,heuristicEnabled:l}=e;if(!a)return;let c=pv(t),u=fv(t,n,i,c);if(!u.isInYaml)return;let d=t.slice(u.lineStart,u.lineEnd),p=d.trim(),f=d.match(/^\s*([^:]+):/),m=f?f[1].trim():s,g=/^-\s*['"]?\{\{(?:VALUE|FIELD|FILE):[^}]+\}\}['"]?\s*$/i,v=null;if(u.isKeyValuePosition?v=[m]:g.test(p)&&(v=this.findListParentPath(t,u.lineStart,u.baseIndent??"")),!v||v.length===0)return;let y=v[v.length-1],b=o;if(l&&typeof o=="string"){let w=m2(o,this.buildParseOptions(y));w!==void 0&&(b=w)}if(!iD(b)||Array.isArray(b)&&b.length===0||!l&&!g2(b))return;let x=v.join(y2);return this.map.set(x,b),b}drain(){let e=new Map(this.map);return this.map.clear(),e}merge(e){for(let[t,n]of e)this.map.set(t,n)}buildParseOptions(e){return{propertyKey:e,propertyType:this.resolvePropertyType(e),app:this.app}}findListParentPath(e,t,n){let i=t-1,o=[],s=n.length;for(;i>=0;){let a=e.lastIndexOf(`
`,i),l=a===-1?0:a+1,c=e.slice(l,i+1),u=c.trim();if(u.length===0){i=l-2;continue}if(u==="---"||u==="...")break;if(u.startsWith("-")){i=l-2;continue}let d=c.match(/^(\s*)([^:\n]+):/);if(d){let f=(d[1]??"").length;if(f<s&&(o.unshift(d[2].trim()),s=f,s===0))break}i=l-2}return o.length>0?o:null}resolvePropertyType(e){if(!this.app)return null;if(this.propertyTypeCache.has(e))return this.propertyTypeCache.get(e)??null;let t=ca(this.app,e);return this.propertyTypeCache.set(e,t),t}};co.PATH_SEPARATOR=y2});function b2(r){if(!r)return null;let e=r.trim().toLowerCase();switch(e){case"kebab":case"snake":case"camel":case"pascal":case"title":case"lower":case"upper":case"slug":return e;default:return null}}function _x(r){return b2(r)!==null}function oD(r){if(!r)return r;let e=r.toLowerCase();return e.slice(0,1).toUpperCase()+e.slice(1)}function sD(r){return/\p{L}/u.test(r)?/\p{Lu}/u.test(r)&&!/\p{Ll}/u.test(r):!1}function kx(r){return/\p{Lu}/u.test(r)&&/\p{Ll}/u.test(r)}function aX(r){return/^\p{Ll}/u.test(r)&&kx(r)}function lX(r){if(!r)return[];{let t=r.match(/^([\p{Ll}][\p{Lu}]{2,})([\p{N}]+)?$/u);if(t){let n=[t[1]];return t[2]&&n.push(t[2]),n}}if(/^[\p{Ll}][\p{Lu}][\p{Ll}]+(?:[\p{Lu}][\p{Ll}]+)*$/u.test(r))return[r];let e=r;return e=e.replace(/([\p{Lu}])([\p{Lu}][\p{Ll}])/gu,"$1 $2"),e=e.replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2"),e=e.replace(/([\p{L}])([\p{N}])/gu,"$1 $2"),e=e.replace(/([\p{N}])([\p{L}])/gu,"$1 $2"),e.trim().split(/\s+/u).map(t=>t.trim()).filter(Boolean)}function cX(r){return r.split(/[^\p{L}\p{N}\p{M}]+/gu).filter(Boolean).flatMap(lX).filter(Boolean)}function _v(r,e){let t=b2(e);if(!t)return r;if(t==="lower")return r.toLowerCase();if(t==="upper")return r.toUpperCase();let n=cX(r);if(n.length===0)return"";switch(t){case"kebab":return n.map(i=>i.toLowerCase()).join("-");case"snake":return n.map(i=>i.toLowerCase()).join("_");case"camel":{let[i,...o]=n,s=i?aX(i)?i:i.toLowerCase():"",a=o.map(l=>sD(l)||kx(l)?l:oD(l));return[s,...a].join("")}case"pascal":return n.map(i=>sD(i)||kx(i)?i:oD(i)).join("");case"title":return n.map(i=>sD(i)||kx(i)?i:oD(i)).join(" ");case"slug":{let i=n.map(o=>o.toLowerCase()).join("-");return kd(i)?`${i}-`:i}default:return r}}var Sx,Ax=E(()=>{wv();Sx=["kebab","snake","camel","pascal","title","lower","upper","slug"]});function Ix(r){let e=r.trim();return e&&(/^\[\[.*\]\]$/.test(e)?e:`[[${e}]]`)}var aD=E(()=>{});function lD(r){let{remaining:e,found:t}=ws(r,"optional"),{remaining:n,found:i}=ws(e,"trim");return{remaining:n,optional:t,trim:i}}function cD(r,e,t,n,i){let o=r.map(d=>{let p=d.trim();return{raw:p,option:Uo(p)}}),s=t?dX:w2,a=o.some(({option:d})=>d?.key==="type"&&["number","slider"].includes(d.value.toLowerCase())),l=d=>s.has(d)||a&&uX.has(d);if(!o.some(({raw:d,option:p})=>p&&l(p.key)||e&&["custom","multi"].includes(d.toLowerCase())))return{defaultValue:r.join("|").trim(),allowCustomInput:!1,usesOptions:!1};let u={defaultValue:"",allowCustomInput:!1,usesOptions:!0,multiSelect:!1};for(let{raw:d,option:p}of o){if(e&&d.toLowerCase()==="custom"){u.allowCustomInput=!0;continue}if(e&&d.toLowerCase()==="multi"){u.multiSelect=!0;continue}if(!p||!l(p.key))continue;let{key:f,value:m}=p;switch(f){case"label":m&&(u.label=m);break;case"case":m&&(u.caseStyle=m);break;case"default":u.defaultValue=m;break;case"custom":u.allowCustomInput=Cc(m);break;case"type":m&&(u.inputTypeOverride=m);break;case"min":u.minRaw=m;break;case"max":u.maxRaw=m;break;case"step":u.stepRaw=m;break;case"text":u.displayValuesRaw=m;break;case"optional":u.optionalExplicit=Cc(m);break;case"trim":u.trimExplicit=Cc(m);break;case"multi":u.multiSelect=!0,u.multiEmit=m.trim().toLowerCase()==="linklist"?"linklist":"text";break;case"format":u.multiFormat=nx(m,n,i);break;case"name":m?u.name=m:i(`QuickAdd: empty |name: ignored in "${n}"; provide a variable name, e.g. {{VALUE:a,b|name:category}}.`);break;default:break}}return u}var uX,w2,dX,C2=E(()=>{xc();ix();uX=new Set(["min","max","step"]),w2=new Set(["label","default","custom","type","case","text","optional","trim","multi","format"]),dX=new Set([...w2,"name"])});function Df(r){if(r===voi
`)}if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return String(r);throw new Error("{{PROPERTY}} only expands text, finite numbers, checkboxes, and lists of text.")}function G2(r){return j2.map(e=>({key:e,present:r.has(e),value:r.get(e)}))}function Y2(r,e){for(let t of e)t.present?r.set(t.key,t.value):r.delete(t.key)}function K2(r,e,t){for(let i of j2)if(!(!r.has(i)||r.get(i)===void 0))throw new Error(`Property Capture cannot seed '${i}' because that variable is already set. Rename your {{VALUE:${i}}} prompt (or other writer of this key) so it does not collide with the property snapshot.`);let n;t!=null&&(n=SX(t,e)),r.set("propertyKey",e),r.set("propertyValue",n),r.set("list",Array.isArray(n)?[...n]:[])}function SX(r,e){if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return r;if(Array.isArray(r)&&r.every(t=>typeof t=="string"))return[...r];throw new Error(`Property '${e}' supports text, finite numbers, checkboxes, and lists of text only.`)}function Mv(r,e){if(Object.prototype.hasOwnProperty.call(r,e))return e;let t=Object.keys(r).filter(n=>n.trim().toLowerCase()===e.trim().toLowerCase());if(t.length>1)throw new Error(`Property '${e}' matches multiple properties in the target note.`);return t[0]??e}function Q2(r){return r.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!=="")}function X2(r){return typeof r=="string"?Q2(r).length===0:Array.isArray(r)&&r.length===0}function U2(r,e){if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return r;if(Array.isArray(r)&&r.every(t=>typeof t=="string"))return[...r];throw new Error(`Property '${e}' supports text, finite numbers, checkboxes, and lists of text only.`)}function _X(r,e){if(r===null&&["tags","aliases","cssclasses"].includes(e.toLowerCase()))return"list";if(r===null)return null;switch(r.toLowerCase()){case"text":return"text";case"number":return"number";case"checkbox":case"boolean":return"checkbox";case"list":case"multitext":case"tags":case"aliases":return"list";case"date":return"date";case"datetime":return"datetime";default:throw new Error(`Property '${e}' has unsupported type '${r}'.`)}}function Mx(r){return Array.isArray(r)?"list":typeof r=="boolean"?"checkbox":typeof r=="number"?"number":"text"}function AX(r,e,t){let n=Mx(r);if(e==="date"||e==="datetime"){if(typeof r=="string"&&(r===""||(e==="date"?/^\d{4}-\d{2}-\d{2}$/:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?$/).test(r)&&Number.isFinite(Date.parse(r))&&new Date(r.slice(0,10)).toISOString().slice(0,10)===r.slice(0,10)))return}else if(n===e)return;throw new Error(`Property '${t}' requires ${e}; the capture is ${n}. Use a matching typed VALUE token or value.`)}function Z2(r){let{frontmatter:e,config:t}=r,n=Mv(e,r.key),i=Object.prototype.hasOwnProperty.call(e,n);if(!i&&!t.createIfMissing)throw new Error(`Property '${n}' is missing. Enable 'Create property if missing' to add it.`);let o=i?e[n]:void 0,s=U2(r.value,n),a=o==null?null:U2(o,n),l=_X(r.registeredType,n)??(a===null?null:Mx(a)),c=typeof s=="string"?Q2(s):null;if(t.action==="addToList"){if(a!==null&&!Array.isArray(a))throw new Error(`Property '${n}' is ${Mx(a)}. 'Add to list' requires a list.`);if(l!==null&&l!=="list")throw new Error(`Property '${n}' is ${l}. 'Add to list' requires a list.`);let d=c??s;if(!Array.isArray(d))throw new Error(`Property '${n}' requires text or a list of text to add.`);return d.length===0?a??[]:r.compose?[...new Set(d)]:[...new Set([...a??[],...d])]}if(l==="list"&&a!==null&&!Array.isArray(a))throw new Error(`Property '${n}' contains ${Mx(a)}. Set a list only after correcting the existing property to a list.`);if(l===null&&c!==null&&c.length>1)throw new Error(`Property '${n}' has no type yet, so ${c.length} lines could be one text value or a list. Use 'Add to list' to write them as list items, or set the property's type in Obsidian first - Text keeps the lines as one value.`);let u=l==="list"?c??s:s;return l!==null&&AX(u,l,n),Array.isArray(u)?[...new Set(u)]:u}function J2(r){let e=(0,Fd.getFrontMatterInfo)(r);if
${(0,Fd.stringifyYaml)(e)}---
${n}`}var Fd,j2,wD=E(()=>{Fd=require("obsidian");Xe();j2=["propertyKey","propertyValue","list"]});var tV,$x,Lc,Pd=E(()=>{hD();gD();gD();bD();R2();tV=require("obsidian");Xe();lo();V2();Ie();rx();hl();q2();wD();hD();bD();$x=10,Lc=class extends Fx{constructor(){super(...arguments);this.linkToCurrentFileBehavior="required";this.targetFolderPath=null;this.propertyTokenExpanded=!1}runClocks(){return this.clocks}setTemplateInclusionState(t){this.templateInclusion=t}replaceDateInString(t){return F2(t,{clocks:()=>this.runClocks(),applyCase:(n,i,o)=>this.applyCaseOption(n,i,o)})}replaceTimeInString(t){return P2(t,{clocks:()=>this.runClocks(),applyCase:(n,i,o)=>this.applyCaseOption(n,i,o)})}async replaceSelectedInString(t){if(!SA.test(t))return t;let n=await this.getSelectedText(),i=new RegExp(SA.source,"gi");return t.replace(i,()=>n)}async replaceClipboardInString(t){if(!_A.test(t))return t;let n=await this.getClipboardContent(),i=new RegExp(_A.source,"gi");return t.replace(i,()=>n)}async replaceLinkToCurrentFileInString(t){if(!EA.test(t))return t;let n=this.getCurrentFileLink();if(!n){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");I.logMessage("Skipping {{LINKCURRENT}} replacement because no active file is available.")}let i=new RegExp(EA.source,"gi");return t.replace(i,()=>n??"")}replaceLinkToCurrentSectionInString(t){if(!TA.test(t))return t;let n=this.getCurrentFileLinkToSection();if(!n){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");I.logMessage("Skipping {{LINKSECTION}} replacement because no active file is available.")}let i=new RegExp(TA.source,"gi");return t.replace(i,()=>n??"")}replaceCurrentFileLinksInString(t){return this.replaceCurrentFileTokensInString(t,{links:!0})}replaceCurrentFileTokensInString(t,n){return O2(t,n,{LINKCURRENT:()=>this.getCurrentFileLink(),LINKSECTION:()=>this.getCurrentFileLinkToSection(),FILENAMECURRENT:()=>this.getCurrentFileName(),FOLDER:()=>this.targetFolderPath??"",FOLDERCURRENT:()=>this.getCurrentFolderPath(),TITLE:()=>this.getVariableValue("title")},this.linkToCurrentFileBehavior)}async replaceCurrentFileNameInString(t){return this.replaceCurrentFileTokensInString(t,{fileName:!0})}setLinkToCurrentFileBehavior(t){this.linkToCurrentFileBehavior=t}setTargetFolderPath(t){if(t==null){this.targetFolderPath=null;return}let n=t.trim();this.targetFolderPath=n==="/"?"":n.replace(/^\/+/,"").replace(/\/+$/,"")}replaceTargetFolderInString(t){return this.replaceCurrentFileTokensInString(t,{folder:!0})}getCurrentFileLinkToSection(){return null}getCurrentFolderPath(){return null}async replaceFieldVarInString(t){let n=new RegExp(cC.source,"gi"),i="",o=0,s;for(;(s=n.exec(t))!==null;){i+=t.slice(o,s.index);let a=s[1]+(s[2]||"");if(a){let l=this.getFieldVariableKey(a),c=oi.parse(a,{warnUnknown:!0,warn:this.warnSink});this.hasConcreteVariable(l)||this.variables.set(l,await this.suggestForField(a,c));let u=this.hasConcreteVariable(l)?this.variables.get(l):this.getVariableValue(l);(!c.multiFormat||c.multiFormat==="auto")&&this.retainSingleTokenValue(t,s.index,s.index+s[0].length,u);let d;Array.isArray(u)?d=this.renderCollectedOrArrayValue({input:t,matchStart:s.index,matchEnd:s.index+s[0].length,rawValue:u,fallbackKey:c.fieldName,heuristicEnabled:!1,multiFormat:c.multiFormat??"auto"})??u.join(","):d=Ed(t,s.index,s.index+s[0].length,String(u??"")),i+=d}else i+=s[0];o=n.lastIndex}return i+t.slice(o)}getFieldVariableKey(t){return`${sd}${t}`}async replaceFileInString(t){let n=new RegExp(uC.source,"gi"),i="",o=0,s;for(;(s=n.exec(t))!==null;){i+=t.slice(o,s.index);let a=ax(s[1]??"",{warn:this.warnSink});if(!a){i+=s[0],o=n.lastIndex;continue}let l=a.variableKey;this.hasConcreteVariable(l)||this.variables.set(l,await this.suggestForFile(a));let c=L2(this.variables.get(l),a.mode,u=>this.getFileLinkForStoredValue(u));if(Array.isArray(c)){let u=this.renderCollectedOrArrayValue({input:t,matchStart:s.index,matchEnd:s.index+s[0].lengt
`,i++):s=="\\"?(n+="\\",i++):n+="\\":n+=o}return n}expandLinebreakEscapesOutsideTokens(t){let n=Dd(t),i="",o=0,s=0;for(;o<t.length;){for(;s<n.length&&n[s].end<=o;)s++;let a=n[s];if(a&&a.start===o){i+=t.slice(a.start,a.end),o=a.end;continue}if(t[o]==="{"&&t[o+1]==="{"){let u=t.indexOf("}}",o+2),d=!1;if(u!==-1){let p=u+2;for(let f=s;f<n.length;f++){let m=n[f];if(m.start>=p)break;if(p<m.end&&p>m.start){d=!0;break}}}if(u!==-1&&!d){i+=t.slice(o,u+2),o=u+2;continue}}let l=t[o],c=t[o+1];l==="\\"?c==="n"?(i+=`
`,o+=2):c==="\\"?(i+="\\",o+=2):(i+="\\",o+=1):(i+=l,o+=1)}return i}replaceRandomInString(t){let n=t;for(;AA.test(n);){let i=AA.exec(n);if(!i||!i[1])continue;let o=parseInt(i[1]);if(o<=0||o>100)throw new Error(`Random string length must be between 1 and 100. Got: ${o}`);let s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a="";for(let l=0;l<o;l++)a+=s.charAt(Math.floor(Math.random()*s.length));n=n.replace(i[0],a)}return n}replaceTitleInString(t){return this.replaceCurrentFileTokensInString(t,{title:!0})}consumePropertyTokenExpanded(){let t=this.propertyTokenExpanded;return this.propertyTokenExpanded=!1,t}replacePropertyInString(t){if(!Ag.test(t))return t;if(this.promptScope!=="propertyValue")throw new Error("{{PROPERTY}} can only be used in a property Capture format.");this.propertyTokenExpanded=!0;let n=this.variables.get("propertyValue");/^{{PROPERTY}}$/i.test(t.trim())&&t.trim()===t&&this.retainSingleTokenValue(t,0,t.length,n===void 0?"":n);let i=W2(n);return t.replace(new RegExp(Ag.source,"gi"),()=>i)}}});function nV(r){return r<=31||r===127||r===8232||r===8233}function PX(r){let e="",t=0;for(;t<r.length;){let n=t;for(;n<r.length&&r.charCodeAt(n)===32;)n++;if(n<r.length&&nV(r.charCodeAt(n))){for(;n<r.length&&nV(r.charCodeAt(n));)n++;for(;n<r.length&&r.charCodeAt(n)===32;)n++;e+=" ",t=n;continue}e+=r.slice(t,Math.min(n+1,r.length)),t=n+1}return e}function iV(r,e){let t=r.length;for(;t>0&&e.includes(r[t-1]);)t--;return r.slice(0,t)}function Md(r){return MX.filter(e=>r.includes(e))}function sV(r){return`A file or folder name cannot contain ${cV(r)}, so this choice would fail at run time. ${lV}`}function aV(r,e){return`Cannot create "${e}": a file or folder name cannot contain ${cV(r)}. ${lV}`}function cV(r){return r.map(e=>`"${e}"`).join(", ")}function Wn(r,e="File path"){let{path:t,problems:n}=dV(r,e);if(n.length>0)throw new Error(n[0]);return t}function uV(r,e="File path"){return dV(r,e)}function dV(r,e){let t=[],n=r.replace(/\\/g,"/").split("/");return{path:n.map((o,s)=>o.length===0&&s!==0&&s!==n.length-1?(t.push(`${e} contains an empty path segment after formatting.`),o):$X(o,e,t)).join("/"),problems:t}}function $X(r,e,t){if(r.length===0)return r;let n=DX.test(r),i=FX.test(r),o=PX(r);n&&(o=o.replace(/^ /u,"")),i&&(o=o.replace(/ $/u,""));let s=iV(o," ");return s==="."||s===".."?(t.push(`${e} cannot contain "." or ".." path segments.`),s):(o=iV(o,". "),o||t.push(`${e} contains an empty path segment after formatting.`),o)}var oV,DX,FX,MX,lV,da=E(()=>{oV="\0-\x7F\u2028\u2029",DX=new RegExp(`^ *[${oV}]`,"u"),FX=new RegExp(`[${oV}] *$`,"u");MX=[":"];lV="Check your own text and tokens like {{TIME}}, which is HH:mm."});function Bc(r,e){let t=r,n=new RegExp(dC.source,"gi"),i=0;for(;n.test(t)&&!(++i>5);)t=t.replace(n,(o,s)=>{let a=String(s??"").trim();if(!a)return o;let l=e?.[a];return typeof l=="string"?l:""});return t}var $v=E(()=>{Xe()});var gt,Qt,po,Cl=E(()=>{(function(r){r[r.AM=0]="AM",r[r.PM=1]="PM"})(gt||(gt={}));(function(r){r[r.SUNDAY=0]="SUNDAY",r[r.MONDAY=1]="MONDAY",r[r.TUESDAY=2]="TUESDAY",r[r.WEDNESDAY=3]="WEDNESDAY",r[r.THURSDAY=4]="THURSDAY",r[r.FRIDAY=5]="FRIDAY",r[r.SATURDAY=6]="SATURDAY"})(Qt||(Qt={}));(function(r){r[r.JANUARY=1]="JANUARY",r[r.FEBRUARY=2]="FEBRUARY",r[r.MARCH=3]="MARCH",r[r.APRIL=4]="APRIL",r[r.MAY=5]="MAY",r[r.JUNE=6]="JUNE",r[r.JULY=7]="JULY",r[r.AUGUST=8]="AUGUST",r[r.SEPTEMBER=9]="SEPTEMBER",r[r.OCTOBER=10]="OCTOBER",r[r.NOVEMBER=11]="NOVEMBER",r[r.DECEMBER=12]="DECEMBER"})(po||(po={}))});function Fs(r,e){r.assign("day",e.getDate()),r.assign("month",e.getMonth()+1),r.assign("year",e.getFullYear())}function Bx(r,e){r.assign("hour",e.getHours()),r.assign("minute",e.getMinutes()),r.assign("second",e.getSeconds()),r.assign("millisecond",e.getMilliseconds()),r.assign("meridiem",e.getHours()<12?gt.AM:gt.PM)}function xl(r,e){r.imply("day",e.getDate()),r.imply("month",e.getMonth()+1),r.imply("year",e.getFullYear())}function Ov(r,e){r.imply("hour",e.getHours()),r.imply("minute",e.getMinutes()),r.imply("second",e.getSeconds()),r.imply("millisecond",e.getMilliseconds()),r.imply
2026-01-05 19:25:56 +08:00
tags: ${JSON.stringify(Array.from(this._tags).sort())},
knownValues: ${JSON.stringify(this.knownValues)},
impliedValues: ${JSON.stringify(this.impliedValues)}},
reference: ${JSON.stringify(this.reference)}]`}date(){let e=this.get("timezoneOffset")??this.reference.timezoneOffset;if(e==null)return this.dateWithoutTimezoneAdjustment();let t=new Date(Date.UTC(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond")));return t.setUTCFullYear(this.get("year")),new Date(t.getTime()-e*6e4)}addTag(e){return this._tags.add(e),this}addTags(e){for(let t of e)this._tags.add(t);return this}tags(){return new Set(this._tags)}dateWithoutTimezoneAdjustment(){let e=new Date(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond"));return e.setFullYear(this.get("year")),e}},Tl=class r{constructor(e,t,n,i,o){he(this,"refDate");he(this,"index");he(this,"text");he(this,"reference");he(this,"start");he(this,"end");this.reference=e,this.refDate=e.instant,this.index=t,this.text=n,this.start=i||new Tt(e),this.end=o}clone(){let e=new r(this.reference,this.index,this.text);return e.start=this.start?this.start.clone():null,e.end=this.end?this.end.clone():null,e}date(){return this.start.date()}addTag(e){return this.start.addTag(e),this.end&&this.end.addTag(e),this}addTags(e){return this.start.addTags(e),this.end&&this.end.addTags(e),this}tags(){let e=new Set(this.start.tags());if(this.end)for(let t of this.end.tags())e.add(t);return e}toString(){let e=Array.from(this.tags()).sort();return`[ParsingResult {index: ${this.index}, text: '${this.text}', tags: ${JSON.stringify(e)} ...}]`}}});function xD(r,e,t="\\s{0,5},?\\s{0,5}"){let n=e.replace(/\((?!\?)/g,"(?:");return`${r}${n}(?:${t}${n}){0,10}`}function BX(r){let e;return r instanceof Array?e=[...r]:r instanceof Map?e=Array.from(r.keys()):e=Object.keys(r),e}function an(r){return`(?:${BX(r).sort((t,n)=>n.length-t.length).join("|").replace(/\./g,"\\.")})`}var kl=E(()=>{});function Ux(r){return r<100&&(r>50?r=r+1900:r=r+2e3),r}function zc(r,e,t){let n=new Date(r);n.setMonth(t-1),n.setDate(e);let i=_n(n,{year:1}),o=_n(n,{year:-1});return Math.abs(i.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())?n=i:Math.abs(o.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())&&(n=o),n.getFullYear()}var Vf=E(()=>{El()});function qX(r){let e=r.toLowerCase();return ED[e]!==void 0?ED[e]:e==="a"||e==="an"||e=="the"?1:e.match(/few/)?3:e.match(/half/)?.5:e.match(/couple/)?2:e.match(/several/)?7:parseFloat(e)}function qf(r){let e=r.toLowerCase();return TD[e]!==void 0?TD[e]:(e=e.replace(/(?:st|nd|rd|th)$/i,""),parseInt(e))}function fa(r){if(/BE/i.test(r))return r=r.replace(/BE/i,""),parseInt(r)-543;if(/BCE?/i.test(r))return r=r.replace(/BCE?/i,""),-parseInt(r);if(/(AD|CE)/i.test(r))return r=r.replace(/(AD|CE)/i,""),parseInt(r);let e=parseInt(r);return Ux(e)}function Yo(r){let e={},t=r,n=vV.exec(t);for(;n;)HX(e,n),t=t.substring(n[0].length).trim(),n=vV.exec(t);return Object.keys(e).length==0?null:e}function HX(r,e){if(e[0].match(/^[a-zA-Z]+$/))return;let t=qX(e[1]),n=Rv[e[2].toLowerCase()];r[n]=t}var Hx,kD,ki,ED,TD,yV,Rv,bV,Bf,Wc,wV,vV,UX,CV,Sl,jc,Fr=E(()=>{kl();Vf();Hx={sunday:0,sun:0,"sun.":0,monday:1,mon:1,"mon.":1,tuesday:2,tue:2,"tue.":2,wednesday:3,wed:3,"wed.":3,thursday:4,thurs:4,"thurs.":4,thur:4,"thur.":4,thu:4,"thu.":4,friday:5,fri:5,"fri.":5,saturday:6,sat:6,"sat.":6},kD={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},ki={...kD,jan:1,"jan.":1,feb:2,"feb.":2,mar:3,"mar.":3,apr:4,"apr.":4,jun:6,"jun.":6,jul:7,"jul.":7,aug:8,"aug.":8,sep:9,"sep.":9,sept:9,"sept.":9,oct:10,"oct.":10,nov:11,"nov.":11,dec:12,"dec.":12},ED={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},TD={first:1,second:2,third:3,fourth:4,fifth:5,sixth:6,seventh:7,eighth:8,ninth:9,tenth:10,eleventh:11,twelfth:12,thirteenth:13,fourteenth:14,fifteenth:15,sixteenth:16,seventeenth:17,eighteenth:18,nineteenth:19,twentieth:20,"twenty first":21,"twenty-first":21,"twenty second":22,"twenty-second":22,"twenty third":23,"twenty-third":23,"twen
`,t+2);t=o===-1?r.length:o+1;continue}if(n==="/"&&i==="*"){let o=r.indexOf("*/",t+2);t=o===-1?r.length:o+2;continue}return t}return t}function Uy(r,e){let t=r[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let n="";for(let i=e+1;i<r.length;i++){let o=r[i];if(o==="\\"){let s=r[i+1];if(s===void 0)return null;n+=s,i+=1;continue}if(o===t)return{value:n,end:i+1};n+=o}return null}function tU(r,e){let t=/^[A-Za-z_$][\w$]*/.exec(r.slice(e));return t?{value:t[0],end:e+t[0].length}:null}function NE(r,e,t,n){let i=0;for(let o=e;o<r.length;o++){let s=r[o],a=r[o+1];if(s==='"'||s==="'"||s==="`"){let l=Uy(r,o);if(!l)return-1;o=l.end-1;continue}if(s==="/"&&a==="/"){let l=r.indexOf(`
`,o+2);o=l===-1?r.length:l;continue}if(s==="/"&&a==="*"){let l=r.indexOf("*/",o+2);if(l===-1)return-1;o=l+1;continue}if(s===t){i+=1;continue}if(s===n&&(i-=1,i===0))return o}return-1}function rU(r){let e=new Map,t=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(["'`])/g,n;for(;(n=t.exec(r))!==null;){let i=Uy(r,t.lastIndex-1);i&&(e.set(n[1],i.value),t.lastIndex=i.end)}return e}function BJ(r){let e=[],t=rU(r),n=0;for(;n<r.length;){n=Os(r,n);let i=r[n];if(i==='"'||i==="'"||i==="`"){let a=Uy(r,n);n=a?a.end:n+1;continue}let o=kF(r,n,t);if(!o){n+=1;continue}if(n=Os(r,o.end),r[n]!==":"){n=o.end;continue}if(n=Os(r,n+1),o.name!=="options"||r[n]!=="{")continue;let s=NE(r,n,"{","}");if(s===-1)break;e.push({start:n+1,end:s}),n=s+1}return e}function kF(r,e,t){if(r[e]==='"'||r[e]==="'"||r[e]==="`"){let i=Uy(r,e);return i?{name:i.value,end:i.end}:null}if(r[e]==="["){let i=Os(r,e+1),o=tU(r,i),s=NE(r,e,"[","]");if(s===-1)return null;let a=o?Os(r,o.end):i;return{name:o&&a===s?t.get(o.value)??null:null,end:s+1}}let n=tU(r,e);return n?{name:n.value,end:n.end}:null}function qJ(r){let e=new Map,t=0;for(;t<r.length;){if(t=Os(r,t),r[t]===","){t+=1;continue}if(t>=r.length)break;let n=kF(r,t,new Map);if(!n?.name){t+=1;continue}if(t=Os(r,n.end),r[t]!==":"){t+=1;continue}if(t=Os(r,t+1),r[t]==='"'||r[t]==="'"||r[t]==="`"){let o=Uy(r,t);if(!o)break;e.set(n.name,o.value),t=o.end;continue}if(r.slice(t,t+4)==="true"){e.set(n.name,!0),t+=4;continue}if(r.slice(t,t+5)==="false"){e.set(n.name,!1),t+=5;continue}let i=r[t];if(i==="{"||i==="["){let o=NE(r,t,i,i==="{"?"}":"]");if(o===-1)break;t=o+1;continue}for(;t<r.length&&r[t]!==",";)t+=1}return e}function UJ(r){let e=qJ(r),t=e.get("type"),n=e.get("secret");return t==="secret"||(t==="text"||t==="input")&&n===!0}function Hy(r,e){let t=e&&VJ.test(e)?ll(r).code??"":r,n=new Set,i=!1,o=rU(t);for(let{start:s,end:a}of BJ(t)){let l=s;for(;l<a;){if(l=Os(t,l),t[l]===","){l+=1;continue}if(l>=a)break;let c=kF(t,l,o);if(!c){l+=1;continue}if(l=Os(t,c.end),t[l]!==":"){l+=1;continue}if(l=Os(t,l+1),t[l]!=="{"){l+=1;continue}let u=NE(t,l,"{","}");if(u===-1||u>a)break;let d=t.slice(l+1,u);UJ(d)&&(i=!0,c.name&&n.add(c.name)),l=u+1}}return{names:n,foundSecretOptions:i}}var VJ,nU=E(()=>{zg();VJ=/\.md$/i});function qr(r){return typeof r=="object"&&r!==null}function iu(r){return qr(r)&&!Array.isArray(r)}function HJ(r){return iu(r)?!1:Array.isArray(r)?r.length>0:sr(r)}function Er(r){return iu(r)?r.commands:HJ(r)?r:void 0}function Ht(r){return Array.isArray(r)?r:[]}function bm(r){return Array.isArray(r)?r:[]}function zy(r){return Array.isArray(r)}function SF(r){let e=Ht(r),t=new Set,n=!1,i=[];for(let o of e){if(Array.isArray(o)){let l=SF(o);for(let c of l.commands){let u=c.id;if(typeof u=="string"&&u!==""&&!t.has(u)){t.add(u),i.push(c);continue}let d={...c,id:Kt()};t.add(d.id),i.push(d)}n=!0;continue}if(!qr(o)){n=!0;continue}let s=o.id;if(typeof s=="string"&&s!==""&&!t.has(s)){t.add(s),i.push(o);continue}let a={...o,id:Kt()};t.add(a.id),i.push(a),n=!0}return n?{commands:i,changed:n}:{commands:e,changed:!1}}function iU(r){oU(r,new Set)}function oU(r,e){qr(r)&&(e.has(r)||(e.add(r),iu(r)&&(r.id=Kt()),LE(Er(r),e)))}function LE(r,e){if(zy(r))for(let t of r){if(Array.isArray(t)){LE(t,e);continue}if(!qr(t)||e.has(t))continue;e.add(t),t.id=Kt();let n=t;LE(n.thenCommands,e),LE(n.elseCommands,e),sU(n.choice,e)}}function sU(r,e){if(!qr(r)||e.has(r))return;e.add(r);let t=r;if(t.id=Kt(),t.type==="Macro"&&oU(t.macro,e),t.type==="Multi"&&Array.isArray(t.choices))for(let n of t.choices)sU(n,e)}var un=E(()=>{sv();Ss();sv()});function Cm(r){return r!==null&&typeof r=="object"}function HE(r){return r?.secretStorage}function BE(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"setting"}function WJ(r){let e=5381;for(let t=0;t<r.length;t+=1)e=e*33^r.charCodeAt(t);return(e>>>0).toString(36).slice(0,zJ)}function lU(r,e){return r.length<=e?r:r.slice(0,e).replace(/-+$/g,"")||"setting"}function uU(r,e){let t=e?.id;return typeof t=="string"&&t.trim().length>0?t:r}function _F(r,e,t){let i=(t?[VE,r,e,t]:[VE,r,e]).join("-");if(i.length<
> `)}}var XP=E(()=>{});var ye,Yn=E(()=>{Ni();ye=class extends yt{}});var Xt,Zo=E(()=>{ZF();Xt=class r extends Nm{static Suggest(e,t,n,i,o,s){let a=new r(e,t,n,o,s);return i&&a.setPlaceholder(i),a.promise}constructor(e,t,n,i,o){super(e,t,n,i,o),this.warnIfEmptyDisplay(),this.open()}}});function $n(r,e){if(!r)throw new Error(typeof e=="function"?e():e)}var Jm=E(()=>{});function eh(r){return ZP.filter(e=>typeof r[e]=="number")}function ok(r){let e={...r};for(let t of ZP)delete e[t];return e}function JP(r,e){return r.supportsTemperature===!1&&eh(e).length>0?ok(e):e}function vz(r,e){return e.length===0?!1:Mne.some(t=>t.test(r))}function e0(r){let e=r.map(t=>Pne[t]);return e.length<=1?e.join(""):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`}function db(r,e){let t={};return typeof e.temperature=="number"&&(t.temperature=e.temperature),typeof e.top_p=="number"&&(t[r==="gemini"?"topP":"top_p"]=e.top_p),t}var ZP,Pne,ik,Mne,sk=E(()=>{ZP=["temperature","top_p","frequency_penalty","presence_penalty"],Pne={temperature:"Temperature",top_p:"Top P",frequency_penalty:"Frequency penalty",presence_penalty:"Presence penalty"};ik=ZP.join("|"),Mne=[new RegExp(`unsupported (?:parameter|value)[^.]{0,40}['\`"]?(?:${ik})['\`"]?`,"i"),new RegExp(`['\`"]?(?:${ik})['\`"]?[^.]{0,40}(?:is deprecated|is not supported|not supported|does not support)`,"i"),new RegExp(`unrecognized request argument[^.]{0,40}(?:${ik})`,"i"),new RegExp(`(?:${ik})[^.]{0,40}extra inputs are not permitted`,"i")]});function t0(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void 0}}function r0(r){let e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=Date.now();return Jo.push({...r,modelOptions:{...r.modelOptions??{}},id:e,createdAt:t,status:"pending"}),bz(),e}function pb(r,e){let t=Jo.find(n=>n.id===r);t&&(t.status=e.status,t.durationMs=e.durationMs,t.usage=e.usage,t.errorMessage=e.errorMessage,bz())}function yz(r=10){Number.isFinite(r)||(r=10);let e=Math.floor(r);return e<=0?[]:Jo.slice(-e).map(t0).reverse()}function bz(){if(Jo.length<=25)return;let r=Jo.length-25;for(;r>0;){let e=Jo.findIndex(t=>t.status!=="pending");if(e===-1)break;Jo.splice(e,1),r-=1}}function wz(r){let e=Jo.find(t=>t.id===r);return e?t0(e):null}function Cz(){let r=Jo[Jo.length-1];return r?t0(r):null}function xz(){Jo.splice(0,Jo.length)}var Jo,n0=E(()=>{Jo=[]});function ak(r){let e=r.workspace.activeEditor?.editor?.getCursor(),t=r.workspace.activeEditor?.editor?.listSelections();return()=>{e&&r.workspace.activeEditor?.editor?.setCursor(e),t&&r.workspace.activeEditor?.editor?.setSelections(t)}}var i0=E(()=>{});function fb(r){let e=Array.isArray(r)?r:{...r},t=e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")||e.properties!==void 0;if(e.properties){let n={};for(let[i,o]of Object.entries(e.properties))n[i]=fb(o);e.properties=n}return e.items&&!Array.isArray(e.items)&&(e.items=fb(e.items)),t&&(e.additionalProperties=!1,e.required=e.properties?Object.keys(e.properties):[]),e}function $ne(r){let e=[];for(let t of r)if(t.role==="system")e.push({role:"system",content:t.content});else if(t.role==="user")e.push({role:"user",content:t.content});else if(t.role==="assistant"){let n={role:"assistant",content:t.content??""};t.toolCalls&&t.toolCalls.length>0&&(n.tool_calls=t.toolCalls.map(i=>({id:i.id,type:"function",function:{name:i.name,arguments:i.rawArgs??JSON.stringify(i.args??{})}}))),e.push(n)}else for(let n of t.results)e.push({role:"tool",tool_call_id:n.toolCallId,content:n.isError?`ERROR: ${n.content}`:n.content});return e}function One(r){return r.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.strict?fb(e.parameters):e.parameters,...e.strict?{strict:!0}:{}}}))}function Rne(r){return typeof r=="string"?r:{type:"function",function:{name:r.name}}}function Lne(r,e){let t={model:r,...e.modelParams??{},messages:$ne(e.messages)};return e.tools&&e.tools.length>0&&(t.tools=One(e.tools),e.toolChoice&&(t.tool_choice=Rne(e.toolChoice)),e.disableParallel&&(t.parallel_tool_calls=!1)),e.maxOutpu
2026-01-05 19:25:56 +08:00
`)),Object.assign(o,db("anthropic",e.modelParams??{})),e.tools&&e.tools.length>0&&(o.tools=e.tools.map(s=>({name:s.name,description:s.description,input_schema:s.parameters})),e.toolChoice?o.tool_choice=Une(e.toolChoice,e.disableParallel):e.disableParallel&&(o.tool_choice={type:"auto",disable_parallel_tool_use:!0})),e.responseFormat?.schema&&(o.output_config={format:{type:"json_schema",schema:fb(e.responseFormat.schema)}}),o}function Une(r,e){let t=e?{disable_parallel_tool_use:!0}:{};return typeof r=="string"?r==="required"?{type:"any",...t}:r==="none"?{type:"none"}:{type:"auto",...t}:{type:"tool",name:r.name,...t}}function Hne(r){let e=r.content??[],t=e.filter(a=>a.type==="tool_use").map(a=>({id:a.id??"",name:a.name??"",args:a.input??{}})),n=String(r.stop_reason??""),i=r.usage??{},o=i.input_tokens??0,s=i.output_tokens??0;return{content:e.filter(a=>a.type==="text").map(a=>a.text??"").join(""),toolCalls:t,normalizedStopReason:n==="tool_use"||t.length>0?"tool_calls":n==="max_tokens"?"length":n==="end_turn"||n==="stop_sequence"?"stop":"other",rawStopReason:n,usage:{promptTokens:o,completionTokens:s,totalTokens:o+s}}}function zne(r,e){let t=[],n=[];for(let s of e.messages)if(s.role==="system")s.content&&t.push(s.content);else if(s.role==="user")n.push({role:"user",parts:[{text:s.content}]});else if(s.role==="assistant")if(Array.isArray(s.providerRaw))n.push({role:"model",parts:s.providerRaw});else{let a=[];s.content&&a.push({text:s.content});for(let l of s.toolCalls??[])a.push({functionCall:{name:l.name,args:l.args??{}}});n.push({role:"model",parts:a})}else n.push({role:"user",parts:s.results.map(a=>({functionResponse:{name:a.name,response:a.isError?{error:a.content}:{result:a.content}}}))});let i={contents:n};t.length>0&&(i.systemInstruction={role:"system",parts:[{text:t.join(`
2026-01-05 19:25:56 +08:00
`)}]}),e.tools&&e.tools.length>0&&(i.tools=[{functionDeclarations:e.tools.map(s=>({name:s.name,description:s.description,parameters:s.parameters}))}],e.toolChoice&&(i.toolConfig=Wne(e.toolChoice)));let o=db("gemini",e.modelParams??{});return e.maxOutputTokens!==void 0&&(o.maxOutputTokens=e.maxOutputTokens),e.responseFormat?.schema&&(o.responseMimeType="application/json",o.responseSchema=e.responseFormat.schema),Object.keys(o).length>0&&(i.generationConfig=o),i}function Wne(r){return typeof r=="string"?{functionCallingConfig:{mode:r==="required"?"ANY":r==="none"?"NONE":"AUTO"}}:{functionCallingConfig:{mode:"ANY",allowedFunctionNames:[r.name]}}}function jne(r){let e=r.candidates?.[0]??{},n=(e.content??{}).parts??[],i=n.filter(a=>a.functionCall).map((a,l)=>({id:a.functionCall?.id??`gemini-call-${l}`,name:a.functionCall?.name??"",args:a.functionCall?.args??{}})),o=String(e.finishReason??""),s=r.usageMetadata??{};return{content:n.filter(a=>typeof a.text=="string").map(a=>a.text??"").join(""),toolCalls:i,normalizedStopReason:i.length>0?"tool_calls":o==="MAX_TOKENS"?"length":o==="STOP"?"stop":"other",rawStopReason:o,usage:{promptTokens:s.promptTokenCount??0,completionTokens:s.candidatesTokenCount??0,totalTokens:s.totalTokenCount??0},providerRaw:n}}function o0(r,e,t,n=8192){switch(r){case"anthropic":return qne(e,t,n);case"gemini":return zne(e,t);default:return Lne(e,t)}}function Tz(r,e){switch(r){case"anthropic":return Hne(e);case"gemini":return jne(e);default:return Vne(e)}}var Nne,kz=E(()=>{sk();Nne=/^(?:o[1-9]|gpt-(?:[5-9]|\d\d))/i});async function mb({kind:r,apiKey:e,provider:t,model:n,body:i,afterRequest:o}){let s={"Content-Type":"application/json"},a;switch(r){case"anthropic":a="/v1/messages",s["x-api-key"]=e,s["anthropic-version"]="2023-06-01";break;case"gemini":a=`/v1beta/models/${encodeURIComponent(n.name)}:generateContent`,s["x-goog-api-key"]=e;break;default:a="/chat/completions",s.Authorization=`Bearer ${e}`}let l=(0,Sz.requestUrl)({url:t.endpoint+a,method:"POST",headers:s,body:JSON.stringify(i),throw:!1});o?.();let c=await l;if(c.status>=400)throw ET(t.name,c);return c.json}function Gne(r){return{id:r.id,model:r.model,content:r.choices[0].message.content,usage:{promptTokens:r.usage.prompt_tokens,completionTokens:r.usage.completion_tokens,totalTokens:r.usage.total_tokens},stopReason:r.choices[0].finish_reason,stopSequence:null,created:r.created}}function Yne(r){return{id:r.id,model:r.model,content:r.content.filter(e=>e.type==="text").map(e=>e.text??"").join(""),usage:{promptTokens:r.usage.input_tokens,completionTokens:r.usage.output_tokens,totalTokens:r.usage.input_tokens+r.usage.output_tokens},stopReason:r.stop_reason,stopSequence:r.stop_sequence,created:Date.now()}}function hb(r){if(typeof r.maxOutputTokens=="number"&&Number.isFinite(r.maxOutputTokens)&&r.maxOutputTokens>0)return Math.floor(r.maxOutputTokens);let e=4096;return Number.isFinite(r.maxTokens)&&r.maxTokens>0?Math.min(e,r.maxTokens):e}function Kne(r,e,t,n,i){if(r!=="anthropic"&&r!=="gemini")return{model:e.name,...n,messages:[{role:"system",content:t},{role:"user",content:i}]};let o=db(r,n);return r==="anthropic"?{model:e.name,max_tokens:hb(e),messages:[{role:"user",content:i}],...t&&t.trim().length>0?{system:t}:{},...o}:{contents:[{role:"user",parts:[{text:i}]}],...t&&t.trim().length>0?{systemInstruction:{role:"system",parts:[{text:t}]}}:{},...Object.keys(o).length?{generationConfig:o}:{}}}async function _z({kind:r,systemPrompt:e,params:t,prompt:n,...i}){let o=Kne(r,i.model,e,t,n),s={...i,kind:r,body:o};switch(r){case"anthropic":return Yne(await mb(s));case"gemini":return Qne(await mb(s));default:return Gne(await mb(s))}}function Qne(r){let e=r.candidates?.[0],n=(e?.content?.parts??[]).map(i=>typeof i.text=="string"?i.text:"").join("");return{id:`${Date.now()}`,model:r.modelVersion??"gemini",content:n,usage:{promptTokens:r.usageMetadata?.promptTokenCount??0,completionTokens:r.usageMetadata?.candidatesTokenCount??0,totalTokens:r.usageMetadata?.totalTokenCount??0},stopReason:e?.finishReason??"",stopSequence:null,created:Date.now()}}var Sz,s0=E(()=>{Sz=requ
${e}`:""}`});function Zne(){return Array.from(new Set([l0,...["kebab","snake","camel","pascal","title","lower","upper","slug"].map(r=>_v(l0,r))])).filter(Boolean)}function Mz(r){if(r.length<=1)return null;let e=Math.floor(r.length/2),t=[`
`,`
`,". "," "],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 p=d+a.length;if(p<=0||p>=r.length)continue;let f=Math.abs(p-e);f<i&&(i=f,n=p)}}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 Jne(r){let e=new RegExp(od.source,"gi"),t;for(;(t=e.exec(r))!==null;)if(t[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}function eie(r){return Oo.test(r)||hc.test(r)||dC.test(r)||tl.test(r)}function tie(r){return Pz.some(e=>r.includes(e))}function rie(r){return Pz.slice().sort((e,t)=>t.length-e.length).reduce((e,t)=>e.split(t).join(" "),r)}function $z(r){if(r>dk)throw new Error(`QuickAdd would split this chunked AI request into more than ${dk} prompts, which exceeds the safety limit. Increase the chunk size, use a larger chunk separator, or reduce the input text.`)}function nie(r,e,t){let n=Math.max(1,Math.floor(e)),i=[r],o=0;for(;i.length>0;){let s=i.pop(),l=Ui(s)<=n?null:Mz(s);if(!l){t.push(s),o+=1,$z(o);continue}i.push(l[1],l[0])}}function iie(r){let e=r.flags.replace(/[gy]/g,"");return new RegExp(r.source+"|",e).exec("").length-1}function sie(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(iie(e)>0||oie.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 aie(r,e,t,n){let i=[];if(r.forEach((l,c)=>{let u=[];nie(l,t,u),u.forEach((d,p)=>{i.push({text:d,joiner:p===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=Ui(l.text)+Math.max(1,Ui(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 lie(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 c0(r,e,t){if(X.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=Kd(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 p=e.chunkSeparator||/\n/g,{chunks:f,separators:m}=sie(u,p),g=await t(c,{chunk:l0});if(!(Jne(c)||eie(c)&&tie(g)))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,b=hU(y),x=rie(g),w=Ui(l)+Ui(x);if(w>=y)throw new Error(`The estimated prompt overhead (${w} tokens) exceeds the model's entire context window (${y} tokens). Shorten the system prompt or prompt template, or use a model with a larger context window.`);let{budget:T,clamped:C}=lie(b-w,e.maxChunkTokens);C&&I.logMessage(`[ChunkedPrompt] Requested max chunk tokens (${e.maxChunkTokens}) exceeds this model's estimated input budget; using ${T} estimated tokens per chunk instead.`);let S=e.shouldMerge??!0,A=aie(f,m,T,S);$z(A.length);let D=gb(r,i,o,s,l,d),P=["prompting",`${A.length} prompts being sent.`];n.setMessage(P[0],P[1]);let U=new uk(5,1e3*30),K=!1,W=0,ee=Promise.resolve(),me=G=>{let ie=ee.then(()=>{if(K)throw new Error("Chunked prompt stopped after an earlier failure.");return t(c,{chunk:G})});return ee=ie.then(()=>{},()=>{}),ie},O=async(G,ie=0)=>{if(K)throw new Error("Chunked prompt stopped after an earlier failure.");let xe;try{xe=await me(G)}catch(ue){throw K=!0,ue}try{return[(await U.add(()=>{if(K)throw new Error("Chunked prompt stopped after an earlier failure.");if(W+=1,W>dk)throw new Error(`Chunked AI request exceeded the safety limit of ${dk} provider requests.`);return D(xe)})).content]}catch(ue){let be=Mz(G);if(ie>=Xne||!be||!YU(ue))throw K=!0,ue;
`,e-1)+1,a=r.slice(o,t).split(`
`),l=a.length-1,c=0,u=a.map((d,p)=>p===l&&d===""?d:(c+=i.length,i+d));return{regionStart:o,regionEnd:t,replacement:u.join(`
`),selectionStart:e+i.length,selectionEnd:t+c}}function die(r,e){r.setSelectionRange(e.regionStart,e.regionEnd);let t=r.ownerDocument,n=!1;try{n=typeof t.execCommand=="function"&&t.execCommand("insertText",!1,e.replacement)}catch{n=!1}if(!n){let i=r.value;r.value=i.slice(0,e.regionStart)+e.replacement+i.slice(e.regionEnd),r.setSelectionRange(e.selectionStart,e.selectionEnd),r.dispatchEvent(new Event("input",{bubbles:!0}));return}r.setSelectionRange(e.selectionStart,e.selectionEnd)}function Vz(r,e={}){let t=i=>{if(i.key!=="Tab"||i.shiftKey||i.ctrlKey||i.metaKey||i.altKey||i.isComposing||i.defaultPrevented)return;i.preventDefault();let o=r.selectionStart??r.value.length,s=r.selectionEnd??o;die(r,uie(r.value,o,s,e))};r.addEventListener("keydown",t);let n=!1;return()=>{n||(n=!0,r.removeEventListener("keydown",t))}}var Bz=E(()=>{});var qz,cu,d0=E(()=>{qz=require("obsidian");nD();Bz();cu=class r extends xf{static Prompt(e,t,n,i,o,s){return new r(e,t,n,i,void 0,o,s).waitForClose}static PromptWithContext(e,t,n,i,o,s,a){return new r(e,t,n,i,o,s,a).waitForClose}getPromptKind(){return"multi"}createInputField(e,t,n){let i=new qz.TextAreaComponent(e);return i.inputEl.classList.add("wideInputPromptInputEl"),i.inputEl.setAttribute("dir","auto"),this.disposeIndent=Vz(i.inputEl),this.configureInput(i,t,n)}shouldSubmit(e){return(e.ctrlKey||e.metaKey)&&e.key==="Enter"}disposeInput(){this.disposeIndent?.()}}});var vb,Uz=E(()=>{Ds();uo();vb=class r extends ar{supportsPeek(){return!1}static Prompt(e,t,n,i,o,s){return new r(e,t,n,i,void 0,o,s).waitForClose}static PromptWithContext(e,t,n,i,o,s,a){return new r(e,t,n,i,o,s,a).waitForClose}createInputField(e,t,n){let i=super.createInputField(e,t,n);i.inputEl.type="number",i.inputEl.inputMode="decimal";let o=this.options?.numeric;return o?.min!==void 0&&(i.inputEl.min=String(o.min)),o?.max!==void 0&&(i.inputEl.max=String(o.max)),i.inputEl.setAttr("step",o?.step!==void 0?String(o.step):"any"),i}transformInputOnSubmit(e){return this.options?.numeric?e===""&&this.isOptionalPrompt?"":Go(e,this.options.numeric):e}}});var p0,yb,Hz=E(()=>{Ds();uo();p0={min:0,max:100,step:1},yb=class r extends ar{supportsPeek(){return!1}static Prompt(e,t,n,i,o,s){return new r(e,t,n,i,void 0,o,s).waitForClose}static PromptWithContext(e,t,n,i,o,s,a){return new r(e,t,n,i,o,s,a).waitForClose}createInputField(e,t,n){let i=this.options?.slider??p0,o=this.isOptionalPrompt&&!n,s=Ff(n,i);this.sliderEl=e.createEl("input"),this.sliderEl.type="range",this.sliderEl.min=String(i.min),this.sliderEl.max=String(i.max),this.sliderEl.step=String(i.step),this.sliderEl.value=s,this.sliderEl.setCssStyles({width:"100%"});let a=super.createInputField(e,void 0,s);return this.numberEl=a.inputEl,this.numberEl.type="number",this.numberEl.inputMode="decimal",this.numberEl.min=String(i.min),this.numberEl.max=String(i.max),this.numberEl.step=String(i.step),o&&(this.numberEl.value=""),this.sliderEl.addEventListener("input",()=>this.syncFromSlider()),this.numberEl.addEventListener("input",()=>this.syncFromNumber()),a}syncFromSlider(){!this.sliderEl||!this.numberEl||(this.numberEl.value=this.sliderEl.value,this.onInputChanged(this.sliderEl.value))}syncFromNumber(){if(!this.sliderEl||!this.numberEl)return;let e=this.numberEl.value;if(e===""&&this.isOptionalPrompt){this.onInputChanged("");return}let t=Go(e,this.options?.slider??p0);t!==""&&(this.sliderEl.value=t),this.onInputChanged(e)}transformInputOnSubmit(e){return e===""&&this.isOptionalPrompt?"":Ff(e,this.options?.slider??p0)}}});var Qd,f0=E(()=>{d0();Ds();Uz();Hz();_s();Qd=class{factory(e){return e==="multiline"?cu:e==="number"?vb:e==="slider"?yb:on().settings.inputPrompt==="multi-line"?cu:ar}}});function zz(r){return r.normalize("NFKD").toLowerCase()}var pie,Xd,m0=E(()=>{pie=0;Xd=class{constructor(e,t){this.options=t;this.instanceId=++pie;this.indexedItems=[];this.renderedRows=[];this.query="";this.rootEl=e.createDiv({cls:"qa-searchable-multi-select"});let n=this.rootEl.createDiv({cls:"search-input-container qa-searchable-multi-select__search-container"});this.searchInputEl=n.createEl("input",{cls:"q
`||k.charAt(de)==="\r"&&k.charAt(de+1)!==`
`)&&(se++,oe===0&&(oe=de+1)),de--}var $e=J+se,vt=R-oe;return q[R]={line:$e,lineStart:oe},{offset:R,line:$e+1,column:vt+1}}function K(k){if(!w(k))throw new Error("not a parser: "+k)}function W(k,R){return typeof k=="string"?k.charAt(R):k[R]}function ee(k){if(typeof k!="number")throw new Error("not a number: "+k)}function me(k){if(typeof k!="function")throw new Error("not a function: "+k)}function O(k){if(typeof k!="string")throw new Error("not a string: "+k)}var H=2,ce=3,te=8,z=5*te,G=4*te,ie=" ";function xe(k,R){return new Array(R+1).join(k)}function ue(k,R,q){var J=R-k.length;return J<=0?k:xe(q,J)+k}function be(k,R,q,J){return{from:k-R>0?k-R:0,to:k+q>J?J:k+q}}function Ke(k,R){var q,J,se,oe,de,$e=R.index,vt=$e.offset,nr=1;if(vt===k.length)return"Got the end of the input";if(C(k)){var lr=vt-vt%te,Wr=vt-lr,Wt=be(lr,z,G+te,k.length),Xn=c(function(ir){return c(function(La){return ue(La.toString(16),2,"0")},ir)},(function(ir,La){var Xl=ir.length,Va=[],Ys=0;if(Xl<=La)return[ir.slice()];for(var Ba=0;Ba<Xl;Ba++)Va[Ys]||Va.push([]),Va[Ys].push(ir[Ba]),(Ba+1)%La==0&&Ys++;return Va})(k.slice(Wt.from,Wt.to).toJSON().data,te));oe=(function(ir){return ir.from===0&&ir.to===1?{from:ir.from,to:ir.to}:{from:ir.from/te,to:Math.floor(ir.to/te)}})(Wt),J=lr/te,q=3*Wr,Wr>=4&&(q+=1),nr=2,se=c(function(ir){return ir.length<=4?ir.join(" "):ir.slice(0,4).join(" ")+" "+ir.slice(4).join(" ")},Xn),(de=(8*(oe.to>0?oe.to-1:oe.to)).toString(16).length)<2&&(de=2)}else{var Gs=k.split(/\r\n|[\n\r\u2028\u2029]/);q=$e.column-1,J=$e.line-1,oe=be(J,H,ce,Gs.length),se=Gs.slice(oe.from,oe.to),de=oe.to.toString().length}var Hh=J-oe.from;return C(k)&&(de=(8*(oe.to>0?oe.to-1:oe.to)).toString(16).length)<2&&(de=2),l(function(ir,La,Xl){var Va,Ys=Xl===Hh,Ba=Ys?"> ":ie;return Va=C(k)?ue((8*(oe.from+Xl)).toString(16),de,"0"):ue((oe.from+Xl+1).toString(),de," "),[].concat(ir,[Ba+Va+" | "+La],Ys?[ie+xe(" ",de)+" | "+ue("",q," ")+xe("^",nr)]:[])},[],se).join(`
`)}function Oe(k,R){return[`
`,"-- PARSING FAILED "+xe("-",50),`
`,Ke(k,R),`
`,(q=R.expected,q.length===1?`Expected:
`+q[0]:`Expected one of the following:
`+q.join(", ")),`
`].join("");var q}function Ee(k){return k.flags!==void 0?k.flags:[k.global?"g":"",k.ignoreCase?"i":"",k.multiline?"m":"",k.unicode?"u":"",k.sticky?"y":""].join("")}function He(){for(var k=[].slice.call(arguments),R=k.length,q=0;q<R;q+=1)K(k[q]);return o(function(J,se){for(var oe,de=new Array(R),$e=0;$e<R;$e+=1){if(!(oe=D(k[$e]._(J,se),oe)).status)return oe;de[$e]=oe.value,se=oe.index}return D(S(se,de),oe)})}function Le(){var k=[].slice.call(arguments);if(k.length===0)throw new Error("seqMap needs at least one argument");var R=k.pop();return me(R),He.apply(null,k).map(function(q){return R.apply(null,q)})}function At(){var k=[].slice.call(arguments),R=k.length;if(R===0)return Je("zero alternates");for(var q=0;q<R;q+=1)K(k[q]);return o(function(J,se){for(var oe,de=0;de<k.length;de+=1)if((oe=D(k[de]._(J,se),oe)).status)return oe;return oe})}function mr(k,R){return zr(k,R).or(Fe([]))}function zr(k,R){return K(k),K(R),Le(k,R.then(k).many(),function(q,J){return[q].concat(J)})}function ge(k){O(k);var R="'"+k+"'";return o(function(q,J){var se=J+k.length,oe=q.slice(J,se);return oe===k?S(se,oe):A(J,R)})}function ve(k,R){(function(se){if(!(se instanceof RegExp))throw new Error("not a regexp: "+se);for(var oe=Ee(se),de=0;de<oe.length;de++){var $e=oe.charAt(de);if($e!=="i"&&$e!=="m"&&$e!=="u"&&$e!=="s")throw new Error('unsupported regexp flag "'+$e+'": '+se)}})(k),arguments.length>=2?ee(R):R=0;var q=(function(se){return RegExp("^(?:"+se.source+")",Ee(se))})(k),J=""+k;return o(function(se,oe){var de=q.exec(se.slice(oe));if(de){if(0<=R&&R<=de.length){var $e=de[0],vt=de[R];return S(oe+$e.length,vt)}return A(oe,"valid match group (0 to "+de.length+") in "+J)}return A(oe,J)})}function Fe(k){return o(function(R,q){return S(q,k)})}function Je(k){return o(function(R,q){return A(q,k)})}function mt(k){if(w(k))return o(function(R,q){var J=k._(R,q);return J.index=q,J.value="",J});if(typeof k=="string")return mt(ge(k));if(k instanceof RegExp)return mt(ve(k));throw new Error("not a string, regexp, or parser: "+k)}function Ft(k){return K(k),o(function(R,q){var J=k._(R,q),se=R.slice(q,J.index);return J.status?A(q,'not "'+se+'"'):S(q,null)})}function Qe(k){return me(k),o(function(R,q){var J=W(R,q);return q<R.length&&k(J)?S(q+1,J):A(q,"a character/byte matching "+k)})}function zt(k,R){arguments.length<2&&(R=k,k=void 0);var q=o(function(J,se){return q._=R()._,q._(J,se)});return k?q.desc(k):q}function rr(){return Je("fantasy-land/empty")}s.parse=function(k){if(typeof k!="string"&&!C(k))throw new Error(".parse must be called with a string or Buffer as its argument");var R,q=this.skip(De)._(k,0);return R=q.status?{status:!0,value:q.value}:{status:!1,index:U(k,q.furthest),expected:q.expected},delete P[k],R},s.tryParse=function(k){var R=this.parse(k);if(R.status)return R.value;var q=Oe(k,R),J=new Error(q);throw J.type="ParsimmonError",J.result=R,J},s.assert=function(k,R){return this.chain(function(q){return k(q)?Fe(q):Je(R)})},s.or=function(k){return At(this,k)},s.trim=function(k){return this.wrap(k,k)},s.wrap=function(k,R){return Le(k,this,R,function(q,J){return J})},s.thru=function(k){return k(this)},s.then=function(k){return K(k),He(this,k).map(function(R){return R[1]})},s.many=function(){var k=this;return o(function(R,q){for(var J=[],se=void 0;;){if(!(se=D(k._(R,q),se)).status)return D(S(q,J),se);if(q===se.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");q=se.index,J.push(se.value)}})},s.tieWith=function(k){return O(k),this.map(function(R){if((function(se){if(!T(se))throw new Error("not an array: "+se)})(R),R.length){O(R[0]);for(var q=R[0],J=1;J<R.length;J++)O(R[J]),q+=k+R[J];return q}return""})},s.tie=function(){return this.tieWith("")},s.times=function(k,R){var q=this;return arguments.length<2&&(R=k),ee(k),ee(R),o(function(J,se){for(var oe=[],de=void 0,$e=void 0,vt=0;vt<k;vt+=1){if($e=D(de=q._(J,se),$e),!de.status)return $e;se=de.index,oe.push(de.value)}for(;vt<R&&($e=D(de=q._(J,se),$e),de.status);vt+=1)se=de.index,oe.push(de.value);return D(S(se,oe)
`),Iu=ge(`\r
`),we=At(Iu,xp,Cp).desc("newline"),qe=At(we,De);o.all=Z,o.alt=At,o.any=di,o.cr=Cp,o.createLanguage=function(k){var R={};for(var q in k)({}).hasOwnProperty.call(k,q)&&(function(J){R[J]=zt(function(){return k[J](R)})})(q);return R},o.crlf=Iu,o.custom=function(k){return o(k(S,A))},o.digit=Pt,o.digits=It,o.empty=rr,o.end=qe,o.eof=De,o.fail=Je,o.formatError=Oe,o.index=Qn,o.isParser=w,o.lazy=zt,o.letter=pi,o.letters=Di,o.lf=xp,o.lookahead=mt,o.makeFailure=A,o.makeSuccess=S,o.newline=we,o.noneOf=function(k){return Qe(function(R){return k.indexOf(R)<0}).desc("none of '"+k+"'")},o.notFollowedBy=Ft,o.of=Fe,o.oneOf=function(k){for(var R=k.split(""),q=0;q<R.length;q++)R[q]="'"+R[q]+"'";return Qe(function(J){return k.indexOf(J)>=0}).desc(R)},o.optWhitespace=Au,o.Parser=o,o.range=function(k,R){return Qe(function(q){return k<=q&&q<=R}).desc(k+"-"+R)},o.regex=ve,o.regexp=ve,o.sepBy=mr,o.sepBy1=zr,o.seq=He,o.seqMap=Le,o.seqObj=function(){for(var k,R={},q=0,J=(k=arguments,Array.prototype.slice.call(k)),se=J.length,oe=0;oe<se;oe+=1){var de=J[oe];if(!w(de)){if(T(de)&&de.length===2&&typeof de[0]=="string"&&w(de[1])){var $e=de[0];if(Object.prototype.hasOwnProperty.call(R,$e))throw new Error("seqObj: duplicate key "+$e);R[$e]=!0,q++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(q===0)throw new Error("seqObj expects at least one named parser, found zero");return o(function(vt,nr){for(var lr,Wr={},Wt=0;Wt<se;Wt+=1){var Xn,Gs;if(T(J[Wt])?(Xn=J[Wt][0],Gs=J[Wt][1]):(Xn=null,Gs=J[Wt]),!(lr=D(Gs._(vt,nr),lr)).status)return lr;Xn&&(Wr[Xn]=lr.value),nr=lr.index}return D(S(nr,Wr),lr)})},o.string=ge,o.succeed=Fe,o.takeWhile=function(k){return me(k),o(function(R,q){for(var J=q;J<R.length&&k(W(R,J));)J++;return S(J,R.slice(q,J))})},o.test=Qe,o.whitespace=wp,o["fantasy-land/empty"]=rr,o["fantasy-land/of"]=Fe,o.Binary={bitSeq:f,bitSeqObj:function(k){p();var R={},q=0,J=c(function(oe){if(T(oe)){var de=oe;if(de.length!==2)throw new Error("["+de.join(", ")+"] should be length 2, got length "+de.length);if(O(de[0]),ee(de[1]),Object.prototype.hasOwnProperty.call(R,de[0]))throw new Error("duplicate key in bitSeqObj: "+de[0]);return R[de[0]]=!0,q++,de}return ee(oe),[null,oe]},k);if(q<1)throw new Error("bitSeqObj expects at least one named pair, got ["+k.join(", ")+"]");var se=c(function(oe){return oe[0]},J);return f(c(function(oe){return oe[1]},J)).map(function(oe){return l(function(de,$e){return $e[0]!==null&&(de[$e[0]]=$e[1]),de},{},c(function(de,$e){return[de,oe[$e]]},se))})},byte:function(k){if(p(),ee(k),k>255)throw new Error("Value specified to byte constructor ("+k+"=0x"+k.toString(16)+") is larger in value than a single byte.");var R=(k>15?"0x":"0x0")+k.toString(16);return o(function(q,J){var se=W(q,J);return se===k?S(J+1,se):A(J,R)})},buffer:function(k){return m("buffer",k).map(function(R){return Buffer.from(R)})},encodedString:function(k,R){return m("string",R).map(function(q){return q.toString(k)})},uintBE:v,uint8BE:v(1),uint16BE:v(2),uint32BE:v(4),uintLE:y,uint8LE:y(1),uint16LE:y(2),uint32LE:y(4),intBE:b,int8BE:b(1),int16BE:b(2),int32BE:b(4),intLE:x,int8LE:x(1),int16LE:x(2),int32LE:x(4),floatBE:m("floatBE",4).map(function(k){return k.readFloatBE(0)}),floatLE:m("floatLE",4).map(function(k){return k.readFloatLE(0)}),doubleBE:m("doubleBE",8).map(function(k){return k.readDoubleBE(0)}),doubleLE:m("doubleLE",8).map(function(k){return k.readDoubleLE(0)})},t.exports=o}])})})(Ik,Ik.exports);var $=Ik.exports,tM=()=>/[#*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
`)[0];let n=t.substring(2).trim();return $.makeSuccess(e+t.length,n)}),namedField:r=>$.alt(r.explicitNamedField,mse(Ws.field).map(([e,t])=>Fk.named(hse(t),e))),sortField:r=>$.seqMap(Ws.field.skip($.optWhitespace),$.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 _W(()=>({type:e,fields:[],showId:!0}),$.seqMap($.regexp(/WITHOUT\s+ID/i).skip($.optWhitespace).atMost(1),$.sepBy(r.namedField,$.string(",").trim($.optWhitespace)),(t,n)=>({type:e,fields:n,showId:t.length==0})));case"list":return _W(()=>({type:e,format:void 0,showId:!0}),$.seqMap($.regexp(/WITHOUT\s+ID/i).skip($.optWhitespace).atMost(1),Ws.field.atMost(1),(t,n)=>({type:e,format:n.length==1?n[0]:void 0,showId:t.length==0})));case"task":return $.succeed({type:e});case"calendar":return $.whitespace.then($.seqMap(r.namedField,t=>({type:e,showId:!0,field:t})));default:return $.fail(`Unrecognized query type '${e}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:r=>$.seqMap($.regexp(/FROM/i),$.whitespace,Ws.source,(e,t,n)=>n),whereClause:r=>$.seqMap($.regexp(/WHERE/i),$.whitespace,Ws.field,(e,t,n)=>({type:"where",clause:n})).desc("WHERE <expression>"),sortByClause:r=>$.seqMap($.regexp(/SORT/i),$.whitespace,r.sortField.sepBy1($.string(",").trim($.optWhitespace)),(e,t,n)=>({type:"sort",fields:n})).desc("SORT field [ASC/DESC]"),limitClause:r=>$.seqMap($.regexp(/LIMIT/i),$.whitespace,Ws.field,(e,t,n)=>({type:"limit",amount:n})).desc("LIMIT <value>"),flattenClause:r=>$.seqMap($.regexp(/FLATTEN/i).skip($.whitespace),r.namedField,(e,t)=>({type:"flatten",field:t})).desc("FLATTEN <value> [AS <name>]"),groupByClause:r=>$.seqMap($.regexp(/GROUP BY/i).skip($.whitespace),r.namedField,(e,t)=>({type:"group",field:t})).desc("GROUP BY <value> [AS <name>]"),clause:r=>$.alt(r.fromClause,r.whereClause,r.sortByClause,r.limitClause,r.groupByClause,r.flattenClause),query:r=>$.seqMap(r.headerClause.trim(_0),r.fromClause.trim(_0).atMost(1),r.clause.trim(_0).many(),(e,t,n)=>({header:e,source:t.length==0?Ta.folder(""):t[0],operations:n,settings:eM}))}),_0=$.alt($.whitespace,_3.comment).many().map(r=>r.join("")),gse=r=>r?r.plugins.plugins.dataview?.api:window.DataviewAPI,vse=r=>r.plugins.enabledPlugins.has("dataview");ka.DATE_SHORTHANDS=j0;ka.DURATION_TYPES=W0;ka.EXPRESSION=Ws;ka.KEYWORDS=G0;ka.QUERY_LANGUAGE=_3;ka.getAPI=gse;ka.isPluginEnabled=vse;ka.parseField=fse});function Rk(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 rM=E(()=>{});function Nk(r){return r.replace(/[\\"]/g,"\\$&")}function yse(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function I3(r){return Nk(yse(r))}function D3(r){return typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"}var nM,Fb,F3=E(()=>{nM=z$(A3());Ie();rM();Fb=class{static getDataviewAPI(e){let t=(0,nM.getAPI)(e);return t||(I.logMessage("Dataview plugin is not installed or enabled"),null)}static async getFieldValues(e,t){return this.queryFieldValues(e,t)}static async getFieldValuesWithFilter(e,t,n={}){return this.queryFieldValues(e,t,n)}static async queryFieldValues(e,t,n){let i=new Set,o=this.getDataviewAPI(e);if(!o)return i;try{let a=`field("${Nk(t)}")`,l=[a],c=(n?.folders?.length?n.folders:n?.folder?[n.folder]:[]).map(g=>g.replace(/^\/+|\/+$/g,"")).filter(Boolean);if(c.length>0){let g=c.map(v=>`regexmatch("^${I3(v)}/", file.path)`);l.push(`(${g.join(" OR ")})`)}n?.tags?.length&&n.tags.forEach(g=>{let v=g.startsWith("#")?g:`#${g}`;l.push(`contains(file.tags, "${Nk(v)}")`)}),n?.excludeFolders?.length&&n.excludeFolders.forEach(g=>{let v=g.replace(/^\/+|\/+$/g,"");l.push(`!regexmatch("^${I3(v)}/", file.path)`)}),n?.excludeTags?.length&&n.excludeTags.forEach(g=>{let v=g.starts
`),o=[],s=null;for(let a of i){if(!s){let l=this.matchFenceOpen(a);l?s={...l,lines:[a]}:o.push(a);continue}if(this.matchFenceClose(a,s.length)){let l=s.info.trim().split(/\s+/)[0]?.toLowerCase();if(n.size>0&&l!==void 0&&l.length>0&&n.has(l))for(let u=1;u<s.lines.length;u++)o.push(s.lines[u]);s=null}else s.lines.push(a)}if(s)for(let a of s.lines)o.push(a);return o.join(`
`)}static matchFenceOpen(e){let t=this.FENCE_OPEN_REGEX.exec(this.stripTrailingCarriage(e));return t?{length:t[1].length,info:t[2]}:null}static matchFenceClose(e,t){let n=this.FENCE_CLOSE_REGEX.exec(this.stripTrailingCarriage(e));return n!==null&&n[1].length>=t}static stripTrailingCarriage(e){return e.endsWith("\r")?e.slice(0,-1):e}static getFieldValues(e,t,n){return this.parseInlineFields(e,n).get(t)||new Set}};Bl.INLINE_FIELD_REGEX=/(?:^|[\n\r])(?![ \t]*[-*+][ \t]+\[[ xX]\])([^:\n\r]+?)::[ \t]*(.*)$/gmu,Bl.FRONTMATTER_REGEX=/^---\r?\n[\s\S]*?\r?\n---\r?\n/,Bl.INLINE_CODE_SPAN_REGEX=/`[^`]*`/g,Bl.FENCE_OPEN_REGEX=/^[ \t]*(`{3,})([^`]*)$/,Bl.FENCE_CLOSE_REGEX=/^[ \t]*(`{3,})[ \t]*$/;fh=Bl});function sM(r){let e=[];return r.folder&&e.push(`folder:${r.folder}`),r.folders?.length&&e.push(`folders:${r.folders.join(",")}`),r.tags&&e.push(`tags:${r.tags.join(",")}`),r.inline&&e.push("inline:true"),r.inlineCodeBlocks?.length&&e.push(`inline-code-blocks:${r.inlineCodeBlocks.join(",")}`),r.caseSensitive&&e.push("case-sensitive:true"),r.excludeFolders&&e.push(`exclude-folders:${r.excludeFolders.join(",")}`),r.excludeTags&&e.push(`exclude-tags:${r.excludeTags.join(",")}`),r.excludeFiles&&e.push(`exclude-files:${r.excludeFiles.join(",")}`),r.defaultValue&&e.push(`default:${r.defaultValue}`),r.defaultEmpty&&e.push("default-empty:true"),r.defaultAlways&&e.push("default-always:true"),e.join("|")}async function M3(r,e,t){return(await aM(r,e,t)).values}async function aM(r,e,t){let n=await bse(r,e,t),i=Sa.processValues(n,t);return{values:i.values,hasDefaultValue:i.hasDefaultValue}}async function bse(r,e,t){let n=Vl.getInstance(),i=sM(t),o=n.get(e,i);if(o)return o;let s=n.getRevision(),a=await lM(r,e,t);return n.setIfRevision(e,a,i,s),a}async function lM(r,e,t){let n=e.trim().toLowerCase();if(n==="tags"||n==="tag"){let i=await wse(r,t);if(i.size>0)return i}try{if(!t.inline&&Fb.isAvailable(r)){let i=await Fb.getFieldValuesWithFilter(r,e,t);if(i.size>0)return i}}catch{}return await Ese(r,e,t)}async function wse(r,e){if(!(!!e.folder||!!e.folders?.length||!!e.tags?.length||!!e.excludeFolders?.length||!!e.excludeTags?.length||!!e.excludeFiles?.length)){let n=Cse(r);if(n.size>0)return n}return await xse(r,e)}function Cse(r){let e=new Set;try{let t=r.metadataCache.getTags?.();if(!t)return e;for(let n of Object.keys(t)){let o=(n.startsWith("#")?n.substring(1):n).trim();o&&e.add(o)}}catch{}return e}function Pb(r,e){if(e!=null)for(let t of Array.isArray(e)?e:[e]){let n=String(t).trim();n&&r.add(n)}}async function $3(r,e,t){let n=new Set,i=xi.filterFiles(r.vault.getMarkdownFiles(),e,o=>r.metadataCache.getFileCache(o));for(let o=0;o<i.length;o+=50){let s=await Promise.all(i.slice(o,o+50).map(async a=>{let l=new Set;try{await t(a,l)}catch{}return l}));for(let a of s)for(let l of a)n.add(l)}return n}async function xse(r,e){return $3(r,e,(t,n)=>{let i=r.metadataCache.getFileCache(t);Pb(n,i?.frontmatter?.tags),Pb(n,i?.frontmatter?.tag);for(let o of i?.tags??[]){let s=String(o.tag??"").trim().replace(/^#/,"");s&&n.add(s)}})}async function Ese(r,e,t){return $3(r,t,async(n,i)=>{let o=r.metadataCache.getFileCache(n)?.frontmatter?.[e];if(Array.isArray(o)?o.forEach(s=>Pb(i,[s])):typeof o!="object"&&Pb(i,o),t.inline){let s=await r.vault.read(n);Pb(i,[...fh.getFieldValues(s,e,{includeCodeBlocks:t.inlineCodeBlocks})])}})}var Bk=E(()=>{F3();pd();Lk();iM();oM()});function Tse(r,e){let t=e.trim();if(!t||!r)return null;let n=r[t];if(n===void 0){let i=t.toLowerCase(),o=Object.keys(r).find(s=>s.toLowerCase()===i);o!==void 0&&(n=r[o])}if(n==null)return null;if(Array.isArray(n)){let i=[];for(let o of n){let s=O3(o);s!==null&&i.push(s)}return i.length>0?i:null}return O3(n)}function qk(r,e,t){if(!e||e.extension!=="md")return null;let n=r.metadataCache.getFileCache(e)?.frontmatter;return Tse(n,t)}function O3(r){if(r==null)return null;let e=typeof r;if(e==="string"||e==="number"||e==="boolean"){let t=String(r).trim();return t.length>0?t:null}return null}var cM=E(()=>{});async function R3({app:r,executor:e,getSourcePath:t},n){let i=e?.promptProvider;try{let{fieldName:o,filter
Suggested values for ${o}: ${v.slice(0,3).join(", ")}`)}return i?await i.inputPrompt(`Enter value for ${o}`,g):await ar.PromptWithContext(r,`Enter value for ${o}`,g,void 0,t()??void 0,void 0,{allowPeek:!0})}return i?String(await i.suggester(d,d,m,!0)):await Mr.Suggest(r,d,d,{placeholder:m})}catch(o){throw ot(o)?new at("Input cancelled by user"):o}}async function N3({app:r,executor:e,getSourcePath:t},n){let i=e?.promptProvider;try{let o=xi.filterFiles(r.vault.getMarkdownFiles(),n.filter,u=>r.metadataCache.getFileCache(u)),s=n.label??`Select a file from ${n.folderPath}`;if(o.length===0){let u=`No markdown files found in "${n.folderPath}". Type a value or leave empty.`,d=i?await i.inputPrompt(s,u):await ar.Prompt(r,s,u,void 0,void 0,{optional:n.optional||void 0,allowPeek:!0});return n.multiSelect?d?[`${As}${d}`]:[]:d?`${As}${d}`:""}let a=$c(o,u=>r.metadataCache.getFileCache(u)),l=o.map(u=>`${Pc}${u.path}`);if(n.multiSelect)return(i?await i.suggesterMulti(a,l,{placeholder:s,allowCustomInput:n.allowCustomInput}):await du.Suggest(r,a,l,{placeholder:s,allowCustomValue:n.allowCustomInput,...n.optional?{skippable:!0}:{}})).map(d=>l.includes(d)?d:`${As}${d}`);if(i){let u=String(await i.suggester(a,l,s,n.allowCustomInput));return u?l.includes(u)?u:`${As}${u}`:""}if(n.allowCustomInput){let u=new Set(o.map(f=>f.basename.toLowerCase())),d=new Set(a.map(f=>f.toLowerCase())),p=await Mr.Suggest(r,a,l,{placeholder:s,valueExists:f=>u.has(f.toLowerCase())||d.has(f.toLowerCase()),...n.optional?{skippable:!0}:{}});return p?l.includes(p)?p:`${As}${p}`:""}return await Xt.Suggest(r,a,l,s,void 0,n.optional?{skippable:!0}:void 0)??""}catch(o){throw ot(o)?new at("Input cancelled by user"):o}}var L3=E(()=>{Ds();Ol();h0();Zo();hl();pd();Bk();iM();cM();lo();ur();xt();Ie()});function _se(r){return`\\begin{${r}}
\u261A
\\end{${r}}\u261A`}var kse,Sse,V3,uM=E(()=>{kse=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|","^{\u261A}\u261A","[\u261A]\u261A","\\above","\\abovewithdelims","\\acute","\\aleph","\\alpha","\\amalg","\\And","\\angle","\\approx","\\approxeq","\\arccos","\\arcsin","\\arctan","\\arg","\\array","\\arrowvert","\\Arrowvert","\\ast","\\asymp","\\atop","\\atopwithdelims","\\backepsilon","\\backprime","\\backsim","\\backsimeq","\\backslash","\\bar","\\barwedge","\\Bbb","\\Bbbk","\\because","\\begin","\\beta","\\beth","\\between","\\bf","\\Bigg","\\bigg","\\Big","\\big","\\Biggl","\\Biggm","\\Biggr","\\biggl","\\biggm","\\biggr","\\Bigl","\\Bigm","\\Bigl","\\bigl","\\bigm","\\bigr","\\bigcap","\\bigcirc","\\bigcup","\\bigodot","\\bigoplus","\\bigotimes","\\bigsqcup","\\bigstar","\\bigtriangledown","\\bigtriangleup","\\biguplus","\\bigvee","\\bigwedge","\\binom","\\blacklozenge","\\blacksquare","\\blacktriangle","\\blacktriangledown","\\blacktriangleleft","\\blacktriangleright","\\bmod","\\boldsymbol","\\bot","\\bowtie","\\Box","\\boxdot","\\boxed","\\boxminus","\\boxplus","\\boxtimes","\\brace","\\bracevert","\\brack","\\breve","\\bullet","\\Bumpeq","\\bumpeq","\\cal","\\cancel","\\Cap","\\cap","\\cases","\\cdot","\\cdotp","\\cdots","\\centerdot","\\cfrac{\u261A}{\u261A}\u261A","\\check","\\checkmark","\\chi","\\choose","\\circ","\\circeq","\\circlearrowleft","\\circlearrowright","\\circledast","\\circledcirc","\\circleddash","\\circledR","\\circledS","\\class","\\clubsuit","\\colon","\\color","\\complement","\\cong","\\coprod","\\cos","\\cosh","\\cot","\\coth","\\cr","\\csc","\\cssId","\\Cup","\\cup","\\curlyeqprec","\\curlyeqsucc","\\curlyvee","\\curlywedge","\\curvearrowleft","\\curvearrowright","\\dagger","\\ddagger","\\daleth","\\dashleftarrow","\\dashrightarrow","\\dashv","\\dbinom","\\dot","\\ddot","\\dddot","\\ddddot","\\ddots","\\DeclareMathOperator","\\def","\\deg","\\Delta","\\delta","\\det","\\dfrac{\u261A}{\u261A}\u261A","\\diagdown","\\diagup","\\Diamond","\\diamond","\\diamondsuit","\\digamma","\\dim","\\displaylines","\\displaystyle","\\div","\\divideontimes","\\Doteq","\\doteq","\\dotplus","\\dots","\\dotsb","\\dotsc","\\dotsi","\\dotsm","\\dotso","\\doublebarwedge","\\doublecap","\\doublecup","\\downarrow","\\Downarrow","\\downdownarrows","\\downharpoonleft","\\downharpoonright","\\ell","\\emptyset","\\end","\\enspace","\\epsilon","\\eqalign","\\eqalignno","\\eqcirc","\\eqsim","\\eqslantgtr","\\eqslantless","\\equiv","\\eta","\\eth","\\exists","\\exp","\\fallingdotseq","\\fbox","\\Finv","\\flat","\\forall","\\frac{\u261A}{\u261A}\u261A","\\frak","\\frown","\\Game","\\Gamma","\\gamma","\\gcd","\\ge","\\geq","\\geqq","\\geqslant","\\genfrac","\\gets","\\gg","\\ggg","\\gggtr","\\gimel","\\gtrapprox","\\gnapprox","\\gneq","\\gneqq","\\gvertneqq","\\gtrsim","\\gnsim","\\grave","\\gt","\\gtrdot","\\gtreqless","\\gtreqqless","\\gtrless","\\hat","\\hbar","\\hbox","\\hdashline","\\hline","\\heartsuit","\\hfil","\\hfill","\\hom","\\hookleftarrow","\\hookrightarrow","\\hphantom","\\href","\\hskip","\\hslash","\\hspace","\\Huge","\\huge","\\iddots","\\idotsint","\\iff","\\iiiint","\\iiint","\\iint","\\int","\\intop","\\Im","\\imath","\\impliedby","\\implies","\\in","\\inf","\\infty","\\injlim","\\intercal","\\iota","\\it","\\jmath","\\Join","\\kappa","\\ker","\\kern","\\Lambda","\\lambda","\\land","\\langle","\\LARGE","\\Large","\\large","\\LaTeX","\\lbrace","\\lbrack","\\lceil","\\ldotp","\\ldots","\\le","\\leq","\\leqq","\\leqslant","\\leadsto","\\left","\\leftarrow","\\Leftarrow","\\leftarrowtail","\\leftharpoondown","\\leftharpoonup","\\leftleftarrows","\\leftrightarrow","\\Leftrightarrow","\\leftrightarrows","\\leftrightharpoons","\\leftrightsquigarrow","\\leftroot","\\leftthreetimes","\\leqalignno","\\lessapprox","\\lessdot","\\lesseqgtr","\\lesseqqgtr","\\lessgtr","\\lesssim","\\lfloor","\\lg","\\lgroup","\\lhd","\\lim","\\liminf","\\limits","\\limsup","\\ll","\\llap","\\llcorner","\\lrcorner","\\Lleftarrow","\\lll","\\llless","\\lmoustache","\\ln","\\lnapprox","\\lneq","\\lneqq","\\lnot",
`)&&!Rse.test(e)?`
`:"",s=i.length>0&&!e.endsWith(`
`)?`
`:"",a=n.length+o.length,l=a+e.length;return{content:`${n}${o}${e}${s}${i}`,insertedStartOffset:a,insertedEndOffset:l}}function Z3(r,e){return op(r,e).content}var X3,Q3,Rse,wu=E(()=>{X3=require("obsidian"),Q3=/^[^\S\r\n]*\r?\n/,Rse=/^\r?\n/});function Rb(r){let e=ql(r),t=/\{\{CURSOR\}\}/i.exec(r.slice(e));return{content:zn(r),offsets:t?[zn(r.slice(0,e)).length+t.index]:[]}}function hM(r,e){if(r.content===e)return r;let t=ql(r.content),n=ql(e);return r.offsets.some(i=>i<t)||r.content.slice(t)!==e.slice(n)?null:{content:e,offsets:r.offsets.map(i=>i+n-t)}}var gM=E(()=>{wl();wu()});var Nb,mh,vM=E(()=>{Nb=require("obsidian");Xe();Ie();ht();la();mh=class{constructor(e){this.app=e}async createFolder(e){await this.app.vault.adapter.exists(e)||await this.app.vault.createFolder(e)}stripLeadingSlash(e){return e.replace(/^\/+/,"")}normalizeMarkdownFilePath(e,t){let n=this.stripLeadingSlash(e),i=n?`${n}/`:"",o=this.stripLeadingSlash(t).replace(Nt,"");return`${i}${o}.md`}async fileExists(e){return await this.app.vault.adapter.exists(e)}getFileByPath(e){let t=this.app.vault.getAbstractFileByPath(e);if(!t)throw I.logError(`${e} not found`),new Error(`${e} not found`);if(t instanceof Nb.TFolder)throw I.logError(`${e} found but it's a folder`),new Error(`${e} found but it's a folder`);if(!(t instanceof Nb.TFile))throw new Error(`${e} is not a file`);return t}async createFileWithInput(e,t,n={}){if(Dr(e))throw new Error(`Refusing to create a file outside the vault: "${e}".`);let i=e.match(/(.*)[/\\]/),o="";i&&(o=i[1]);let s=this.app.vault.getAbstractFileByPath(o);(!s||!(s instanceof Nb.TFolder))&&await this.createFolder(o);let a=()=>this.app.vault.create(e,t);return n.suppressTemplaterOnCreate&&e.toLowerCase().endsWith(".md")?await OA(this.app,e,a):await a()}}});async function wo(r,e){try{return r.promptProvider?await e.remote(r.promptProvider):r.interactive===!1?await e.headless():await e.app()}catch(t){throw ot(t)?new at("Input cancelled by user"):t}}var sp=E(()=>{ur();xt()});async function Co(r,e){let t=e.items.map((s,a)=>`${Lse}${a}`),n=await r.suggester(e.items.map(s=>s.title),t,e.placeholder,e.allowCustomInput??!1),i=n==null?"":String(n),o=t.indexOf(i);if(o!==-1)return e.items[o].value;if(i==="")throw new at("Input cancelled by user");if(e.allowCustomInput)return i;throw new Error(`A reply to ${e.what} has to be one of the offered options, and "${i.slice(0,60)}" is not. Reply with the item's \`value\` token exactly as it was sent, or \`{"cancelled": true}\` to dismiss it.`)}var Lse,ap=E(()=>{ur();Lse="\0qa-eng:"});function yM(r){let e=r.map(n=>n||"/");return`Folder must be under: ${e.length>3?`${e.slice(0,3).join(", ")}...`:e.join(", ")}`}var Wk,Vse,Aa,jk,J3=E(()=>{Wk=require("obsidian");vM();Zo();Ol();wv();Ni();Yn();sp();ap();Vse=3,Aa=class extends Error{constructor(e){super(e),this.name="InvalidFolderPathError"}},jk=class extends mh{async getOrCreateFolder(e,t){let n=this.buildFolderSelectionContext(e,{...t,topItems:e.length>0?[]:t.topItems??[]});if(!this.shouldPromptForFolder(n))return await this.handleSingleSelection(n);let i=this.buildFolderSelectionContext(e,t),o=await this.promptUntilAllowed(i,t.executor);return o.isEmpty?"":o.resolved}buildFolderSelectionContext(e,t){let n=t.allowCreate??!1,i=t.allowedRoots?.map(s=>this.normalizeFolderPath(s))??[];return{...this.buildFolderSuggestions(e,t.topItems??[],i.length>0?i:void 0),allowCreate:n,allowedRoots:i,placeholder:t.placeholder}}shouldPromptForFolder(e){return e.items.length>1||e.allowCreate&&e.items.length===0}async promptForFolder(e,t){let n=e.placeholder??"Choose a folder or type to create one";return String(await wo(t,{remote:i=>Co(i,{items:e.items.map((o,s)=>({value:o,title:e.displayItems[s]??o})),placeholder:n,allowCustomInput:e.allowCreate,what:"the folder chooser"}),headless:()=>{throw new ye("This choice needs to ask which folder to create the note in, but this run is non-interactive. Configure a single target folder, or re-run with the ui flag.")},app:()=>e.allowCreate?Mr.Suggest(this.app,e.displayItems,e.items,{placeholder:n,renderItem:(i,o)=>{this.renderFolderSugges
${a}`:`${a}
${s}`;return await this.app.vault.modify(t,l),t}catch(o){if(EM(o))throw o;return this.noteTemplateFileFailure(o,"Could not append to file with template"),Ze(o,"Could not append to file with template"),null}}async getTemplateContent(t){let n=Vn(this.app,t);if(!n)throw new Error(`Template file not found at path "${t}".`);return await this.app.vault.cachedRead(n)}}});var rj={};fw(rj,{SingleTemplateEngine:()=>vh});var vh,TM=E(()=>{Kk();Ie();Cu();vh=class extends xu{constructor(t,n,i,o,s){super(t,n,o,s);this.templatePath=i;this.promptScope="noteBody";this.preserveCursorMarkers=!1}setPreserveCursorMarkers(t){this.preserveCursorMarkers=t}setPromptScope(t){this.promptScope=t}setDestinationPath(t){this.formatter.setTitle(Ia(t)),this.formatter.setTargetFolderPath(Ai(t))}async run(){let t=await this.resolveTemplateSourcePath(this.templatePath),n=await this.getTemplateContent(t);return n||I.logError(`Template ${t} not found.`),n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope(this.promptScope,n,()=>this.preserveCursorMarkers?this.formatter.formatTemplateContent(n):this.formatter.formatFileContent(n))),n}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}}});var nj={};fw(nj,{SingleInlineScriptEngine:()=>kM});var kM,ij=E(()=>{Ob();kM=class extends _a{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 oj,ji,lp=E(()=>{wl();Qz();L3();$v();oj=require("obsidian");Xe();Zo();f0();U3();Ld();hl();lo();uo();Bk();ys();Pd();Sf();j3();ur();Yn();xt();ji=class extends Lc{constructor(t,n,i,o){super(t);this.app=t;this.plugin=n;this.choiceExecutor=i;this.contentValuePromptsAcceptImagePaste=!1;this.preserveTemplateCursorMarkers=!1;this.skipPropertyExpansion=!1;this.dateParser=o||Qo,i&&(this.variables=i?.variables)}runClocks(){return this.choiceExecutor?.clocks??this.clocks}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),this.formatScalarTokens(n)}async formatScalarTokens(t){let n=t;return 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),this.skipPropertyExpansion||(n=this.replacePropertyInString(n)),this.promptScope==="captureText"||this.promptScope==="noteBody"&&this.preserveTemplateCursorMarkers?n:zn(n)}async replaceGlobalVarInString(t){return Bc(t,this.plugin?.settings?.globalVariables)}async formatFileName(t,n="generic"){if(Ro.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(Ro.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 formatPropertyName(t){return await this.withPromptScope("propertyName",t,async()=>this.replaceCurrentFileTokensInString(await this.format(t),{links:!0,fileName:!0,folder:!0,activeFolder:"content",title:!0}))}async formatPropertyValue(t){let n=await this.preserveSingleTokenValue(t,()=>this.withPromptScope("propertyValue",t,async()=>{this.skipPropertyExpansion=!0;let i;try{i=await this.format(t)}finally{this.skipPropertyExpansion=!1}return i=this.replaceCurrentFileTokensInString(i,{links:!0,fileName:!0,folder:!0,activeFolder:"content",title:!0}),this.replacePropertyInString(i)}));return typeof n=="string"?zn(n):Array.isArray(n)?n.map(i=>typeof i=="str
${e}`;return{content:n,insertedStartOffset:r.length+1,insertedEndOffset:n.length}}return op(r,`${e}
`)}function zse(r){return r==null||r===""||Array.isArray(r)&&r.length===0}function uj(r){return typeof r=="string"?r.length>0?[r]:[]:!Array.isArray(r)||!r.every(e=>typeof e=="string")?null:r}function dj(r,e){let t=uj(r),n=uj(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 Xk,Bb,yh,Zk=E(()=>{Xk=require("obsidian");Ie();ht();Gk();Jm();Sv();If();Cu();wu();Bg();gM();Kk();da();_f();Bb=[{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's frontmatter, or at the very top."},{id:"bottom",label:"Append to bottom",description:"Adds the template content to the end of the note."},{id:"replace",label:"Replace note content",description:"Replaces the entire note content with the template."}];yh=class extends xu{constructor(t,n,i,o,s,a,l){super(t,n,a);this.targetFile=i;this.templatePath=o;this.mode=s;this.cursorView=null;this.resolvedTemplatePath=l??null}placeCursor(t){this.mode==="cursor"&&No(this.app,t)!==this.cursorView||super.placeCursor(t)}async run(){await this.apply()}async getResolvedTemplatePath(){return this.resolvedTemplatePath===null&&(this.resolvedTemplatePath=await this.resolveTemplateSourcePath(this.templatePath)),this.resolvedTemplatePath}async apply(){switch(this.cursorPlacement=null,$n(this.templatePath,"Cannot apply template: no template path given."),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=Wn(a,"File name"),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}=cj(n),a=this.cursorPlacement;return(s.trim().length>0||a)&&await this.app.vault.process(this.targetFile,l=>{let c=Hse(l,s,t);if(a&&c.insertedStartOffset!==null){let u=c.insertedStartOffset-(n.length-s.length);this.cursorPlacement={content:c.content,offsets:a.offsets.map(d=>u+d)}}return c.content}),await this.mergeFrontmatterProperties(o,i),await this.rebaseCursorAfterFileChanges(this.targetFile),this.targetFile}async insertTemplateAtCursor(){let t=No(this.app,this.targetFile);$n(t,"Cannot insert at cursor: the note is not open in the active editor."),this.cursorView=t;let n=t.editor,{formatted:i,templatePropertyVars:o}=await this.formatTemplateForTargetFile();$n(t.file===this.targetFile&&t.editor===n&&this.app.workspace.getLeavesOfType("markdown").some(c=>c.view===t),"Cannot insert at cursor: the original editor was closed or changed notes.");let{frontmatterYaml:s,body:a}=cj(i),l=this.cursorPlacement?.offsets[0];return l!==void 0?this.cursorPlacement=NA({content:a,cursor:{kind:"offset",value:l-(i.length-a.length),source:"marker"}},n,"currentLine"):a.trim().length>0&&n.replaceSelection(a),this.cursorPlacement&&s&&await t.save(),await this.mergeFrontmatterProperties(s,o),s&&await this.rebaseCursorAfterFileChanges(this.targetFile),this.targetFile}async format
> `);this.choiceExecutor.variables.set(n,t),this.choiceExecutor.variables.set(`${n}-quoted`,i)}assertAssignableName(e){xS(e)}}});function ZM(r){return(r??"").trim().replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+|\/+$/g,"").normalize("NFC")}function JM(r,e){return e.some(t=>r===t||r.startsWith(`${t}/`))}function pp(r,e){let t=(e??[]).map(n=>ZM(n)).filter(n=>n.length>0);return t.length===0?!0:r?JM(r.normalize("NFC"),t):!1}var TS=E(()=>{});function fp(r,e={}){let t=(r??"").trim();if(!t)throw new ns("Path is empty.");let n=t.replace(/\\/g,"/").normalize("NFC");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new ns(`Refusing to write to an absolute path outside the vault: "${n}".`);let i=n.replace(/\/+/g,"/").replace(/^\/+|\/+$/g,""),o=i.split("/").filter(a=>a.length>0);if(o.length===0)throw new ns("Path is empty after normalization.");for(let a of o){if(a==="."||a==="..")throw new ns(`Refusing path with a traversal segment ("${a}"): "${i}".`);if(a.startsWith("."))throw new ns(`Refusing to write into a dot/config path segment ("${a}"): "${i}".`);Hae(a,i)}let s=(e.allowedRoots??[]).map(a=>ZM(a)).filter(a=>a.length>0);if(s.length>0&&!JM(i,s))throw new ns(`Path "${i}" is not under an allowed root (${s.join(", ")}).`);return i}function Hae(r,e){if(vv.test(r))throw new ns(`Path segment "${r}" contains control characters: "${e}".`);if(yv.test(r))throw new ns(`Path segment "${r}" contains an illegal character (\\ : * ? " < > |): "${e}".`);if(bv.test(r))throw new ns(`Path segment "${r}" cannot end with a space or a period: "${e}".`);let t=r.split(".")[0]??"";if(t&&kd(t))throw new ns(`Path segment "${r}" is a reserved device name: "${e}".`)}var ns,dG=E(()=>{wv();TS();ns=class extends Error{constructor(e){super(e),this.name="UnsafeVaultPathError"}}});function Ph(r,e){let t=Object.entries(r),n=new Set(t.map(([o])=>o));if(pG(e.only,n,"only"),pG(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 Jb(r){return{...r,__qaTool:!0}}function pG(r,e,t){if(!r)return;let n=r.filter(i=>!e.has(i));n.length!==0&&I.logWarning(`AI tools: ${t} listed unknown tool name(s) ${n.map(i=>`"${i}"`).join(", ")}. Valid names: ${[...e].join(", ")}.`)}var kS=E(()=>{Ie()});function bG(r,e={}){let t=e.allowedRoots,n={read_note:mp({description:"Read a note's full markdown content by vault path.",inputSchema:hp({path:is("Vault path to the note, e.g. Notes/Foo.md")},["path"]),readOnly:!0,execute:async({path:i})=>{let o=fp(String(i),{allowedRoots:t}),s=r.vault.getAbstractFileByPath(o);if(!(s instanceof t$.TFile))return{found:!1,path:o};let a=await r.vault.cachedRead(s);return{found:!0,path:o,content:a.length>fG?a.slice(0,fG)+`
\u2026[truncated]`:a}}}),list_notes:mp({description:"List markdown notes, optionally within a folder.",inputSchema:hp({folder:is("Folder to list (omit for the whole vault)."),limit:mG("Max results (default 100, capped at 200).")},[]),readOnly:!0,execute:async({folder:i,limit:o})=>{let s=i?fp(String(i),{allowedRoots:t}):"",a=vG(gG(o,zae),1,Wae),l=Bo(r,s).filter(c=>pp(c.path,t));return{total:l.length,notes:l.slice(0,a).map(c=>({path:c.path,basename:c.basename}))}}}),search_notes:mp({description:"Search notes by name and/or content. Returns matching paths with a short snippet.",inputSchema:hp({query:is("Text to search for."),in:hG(["name","content","both"],"Where to search (default both)."),limit:mG("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=vG(gG(s,jae),1,Gae),u=r.vault.getMarkdownFiles().filter(m=>pp(m.path,t)),d=[],p=0,f=!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(p>=Yae){f=!0;continue}p++;let v=await r.vault.cachedRead(m),y=v.toLowerCase().indexOf(a);y>=0&&d.push({path:m.path,snippet:Qae(v,y)})}}return{results:d,scannedFiles:p,truncated:d.length>=c||f}}}),get_property_values:mp({description:"List the distinct values a frontmatter property takes across the vault (e.g. existing tags or statuses).",inputSchema:hp({field:is("Frontmatter property name."),folder:is("Optional folder scope.")},["field"]),readOnly:!0,execute:async({field:i,folder:o})=>{let s=o?fp(String(o),{allowedRoots:t}):"",a=(o?Bo(r,s):r.vault.getMarkdownFiles()).filter(c=>pp(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 p of Array.isArray(d)?d:[d])if(typeof p!="object"){let f=String(p).trim();f&&l.add(f)}}}return{field:String(i),values:[...l].sort().slice(0,200)}}}),create_note:mp({description:"Create a new markdown note. Fails if the path already exists.",inputSchema:hp({path:is("Vault path for the new note."),content:is("Initial markdown content.")},["path"]),needsApproval:!0,execute:async({path:i,content:o})=>{let s=fp(e$(String(i)),{allowedRoots:t});return await Km(r,s),await Kae(r,s),{created:!0,path:(await r.vault.create(s,String(o??""))).path}}}),append_to_note:mp({description:"Append text to an existing note (frontmatter-aware for top inserts).",inputSchema:hp({path:is("Vault path to the existing note."),content:is("Markdown to append."),position:hG(["top","bottom"],"Where to add it (default bottom).")},["path","content"]),needsApproval:!0,execute:async({path:i,content:o,position:s})=>{let a=fp(e$(String(i)),{allowedRoots:t}),l=yG(r,a);await Km(r,a);let c=await r.vault.read(l),u=String(o),d=s==="top"?Z3(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:mp({description:"Insert markdown under an existing heading (matched exactly). Errors if the heading is not found.",inputSchema:hp({path:is("Vault path to the existing note."),heading:is("Exact heading text (without the # markers)."),content:is("Markdown to insert under the heading.")},["path","heading","content"]),needsApproval:!0,execute:async({path:i,heading:o,content:s})=>{let a=fp(e$(String(i)),{allowedRoots:t}),l=yG(r,a);await Km(r,a);let c=r.metadataCache.getFileCache(l)?.headings??[],u=c.find(f=>f.heading===String(o));if(!u)throw new Error(`Heading "${o}" not found in ${a}`);let d=await r.vault.read(l),p=Xae(d,u.position.start.line,u.level,String(s),c);return await r.vault.modify(l,p),{inserted:!0,path:a,heading:String(o)}}})};return Ph(n,e)}function mp(r){return{...r,__qaTool:!0}}function hp(r,e){return{type:"object",properties:r,required:e}}function is(r){return{type:"string",description:r}}function mG(r){return{type:"integer",description:r}}function hG(r,e){return{type:"string",enum:r,description:e}}function gG(r,e){let t=Number(r);return Number.isFinite(t)?Math.floor(t):e}function vG(r,e,t){return Math.max(e,Math.min(t,r))}function e$(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 yG(r,e){let t=r.vault.getAbstractFileByPath(e);if(!(t instanceof t$.TFile))throw new Error(`Note not found: ${e}`);return t}async function Kae(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 Qae(r,e){let t=Math.max(0,e-40);return r.slice(t,e+80).replace(/\s+/g," ").trim()}function Xae(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(`
`)?n:n+`
`,l=o.slice(0,s),c=o.slice(s);for(;l.length>e+1&&l[l.length-1].trim()==="";)l.pop();return[...l,a.replace(/\n$/,""),...c].join(`
`)}var t$,fG,zae,Wae,jae,Gae,Yae,wG=E(()=>{t$=require("obsidian");ht();wu();TS();dG();TP();kS();fG=16e3,zae=100,Wae=200,jae=25,Gae=50,Yae=400});function xG(r,e={}){let t=e.allowedRoots,n=()=>{let s=r.workspace.getActiveFile();return!(s instanceof SS.TFile)||s.extension!=="md"?null:pp(s.path,t)?s:null},i=()=>{let s=r.workspace.getActiveViewOfType(SS.MarkdownView);return s&&pp(s.file?.path,t)?s:null},o={get_active_note:Jb({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>CG?a.slice(0,CG)+`
\u2026[truncated]`:a}}}}),get_selection:Jb({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 Ph(o,e)}var SS,CG,EG=E(()=>{SS=require("obsidian");TS();kS();CG=16e3});function TG(r={}){let e={get_date:Jb({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:aa({format:t!=null?String(t):void 0,offset:n!=null?Number(n):void 0})})})};return Ph(e,r)}var kG=E(()=>{ht();kS()});function _G(r,e,t,n){async function i(s,a){let l=X.getState();if(l.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let{model:c,provider:u}=jy(s),d=await Ca(r,u);return a?.assignToVariable&&xS(a.assignToVariable),{model:c,provider:u,apiKey:d,modelOptions:a?.modelOptions??{},outputVariableName:a?.assignToVariable||a?.variableName||"output",showAssistantMessages:a?.showAssistantMessages??!0,systemPrompt:a?.systemPrompt??l.ai.defaultSystemPrompt}}function o(s,a,l){if(!s)return Ze(new Error("AI Assistant returned null"),l),{};if(a?.shouldAssignVariables||a?.assignToVariable)for(let[c,u]of Object.entries(s))t.variables.set(c,u);return s}return{prompt:async(s,a,l)=>{let c=await Lz(r,{...await i(a,l),prompt:s},(u,d)=>n(u,d,!1));return o(c,l,"AI Prompt error")},chunkedPrompt:async(s,a,l,c,u)=>{let d=await c0(r,{...await i(l,c),text:s,promptTemplate:a,chunkSeparator:c?.chunkSeparator??/\n/,resultJoiner:c?.chunkJoiner??`
`,shouldMerge:c?.shouldMerge??!0,maxChunkTokens:c?.maxChunkTokens},(p,f)=>n(p,{...u,...f},!1));return o(d,c,"Chunked AI Prompt error")},getModels:()=>bU(),getMaxTokens:s=>jy(s).model.maxTokens,estimateTokens(s){return Ui(s)},countTokens(s,a){return SG||(SG=!0,I.logMessage("quickAddApi.ai.countTokens is deprecated and now returns a provider-agnostic estimate (the model argument is ignored). Use estimateTokens(text) instead.")),Ui(s)},getRequestLogs(s=10){return yz(s)},getRequestLogById(s){return wz(s)},getLastRequestLog(){return Cz()},clearRequestLogs(){xz()},agent:s=>new ES(r,e,t,s),tool:s=>({...s,__qaTool:!0}),stepCountIs:s=>({stepNumber:a})=>a>=s,hasToolCall:s=>({toolCallNames:a})=>a.includes(s),tools:{vault:s=>bG(r,s),workspace:s=>xG(r,s),system:s=>TG(s)}}}var SG,AG=E(()=>{u0();Tm();Yd();Wy();uG();QM();wG();EG();kG();dt();xt();Ie();SG=!1});function IG(r){return{getFieldValues:async(e,t)=>{let n=t?.includeInlineCodeBlocks?.map(a=>a.trim().toLowerCase()).filter(a=>a.length>0),i={folder:t?.folder,folders:t?.folders,tags:t?.tags,inline:t?.includeInline??!1,inlineCodeBlocks:n},o=r.vault.getMarkdownFiles();o=xi.filterFiles(o,i,a=>r.metadataCache.getFileCache(a));let s=new Set;for(let a of o){let c=r.metadataCache.getFileCache(a)?.frontmatter?.[e];if(c!=null){if(Array.isArray(c))c.forEach(u=>{if(u==null||typeof u=="object")return;let d=String(u).trim();d&&s.add(d)});else if(typeof c!="object"){let u=String(c).trim();u&&s.add(u)}}if(i.inline)try{let u=await r.vault.read(a);fh.getFieldValues(u,e,{includeCodeBlocks:n}).forEach(p=>s.add(p))}catch{}}return Array.from(s).sort()},clearCache:e=>{Vl.getInstance().clear(e)}}}var DG=E(()=>{Lk();pd();oM()});function FG(r){return Array.from(r.entries())}function PG(r,e){r.clear();for(let[t,n]of e)r.set(t,n)}var ci,Mh,r$=E(()=>{lp();SM();Zk();ys();xh();xt();ht();_M();rG();AG();DG();ci=class ci{static GetApi(e,t,n){let i=async(o,s,a=!0)=>{let l=a?FG(n.variables):null;s&&Object.keys(s).forEach(u=>{n.variables.set(u,s[u])});let c=await new ji(e,t,n).formatFileContent(o);return a&&l&&PG(n.variables,l),c};return{requestInputs:o=>tG(e,n,o),inputPrompt:(o,s,a,l)=>{let c=n?.promptProvider;return c?c.inputPrompt(o,s,a):ci.inputPrompt(e,o,s,a,l)},datePrompt:(o,s)=>{let a=n?.promptProvider;return a?a.datePrompt(o,s):ci.datePrompt(e,o,s)},wideInputPrompt:(o,s,a,l)=>{let c=n?.promptProvider;return c?c.wideInputPrompt(o,s,a):ci.wideInputPrompt(e,o,s,a,l)},yesNoPrompt:(o,s)=>{let a=n?.promptProvider;return a?a.yesNoPrompt(o,s):ci.yesNoPrompt(e,o,s)},infoDialog:(o,s)=>{let a=n?.promptProvider;return a?a.infoDialog(o,s):ci.infoDialog(e,o,s)},suggester:(o,s,a,l=!1,c)=>{let u=n?.promptProvider;return u?u.suggester(o,s,a,l):ci.suggester(e,o,s,a,l,c)},checkboxPrompt:(o,s,a)=>{let l=n?.promptProvider;return l?l.checkboxPrompt(o,s,a):ci.checkboxPrompt(e,o,s,a)},executeChoice:async(o,s,a)=>{let l;try{l=t.getChoiceByName(o)}catch{l=void 0}if(!l){Ze(new Error(`Choice named '${o}' not found`),"API executeChoice error");return}if(!Ch(n,a?.date)){Ze(new Error(`Could not parse date origin '${String(a?.date)}'`),"API executeChoice error");return}s&&Object.keys(s).forEach(u=>{n.variables.set(u,s[u])}),await n.execute(l);let c=n.consumeAbortSignal?.();if(n.variables.clear(),c)throw c},applyTemplateToActiveFile:async(o,s)=>{if(!o)throw new Error("applyTemplateToActiveFile requires a template path.");if(!wh(o))throw new Error("applyTemplateToActiveFile only supports markdown templates. Canvas and base templates cannot be applied to a markdown note.");if(s?.mode!==void 0&&!pj(s.mode))throw new Error(`Invalid mode '${String(s.mode)}'. Valid modes: ${Bb.map(l=>l.id).join(", ")}.`);let a=FG(n.variables);try{return await qb(e,t,{templatePath:o,mode:s?.mode,choiceExecutor:n})}finally{PG(n.variables,a)}},format:i,ai:_G(e,t,n,i),utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async o=>await navigator.clipboard.writeText(o),getSelection:()=>sl(e),getSelectedText:()=>{let o=xn(e);return o?o.editor.somethingSelected()?o.editor.getSelection():(Ze(new Error("No text selected"),"Could not get selected t
`)}var ew=E(()=>{});async function LG(r,e){return r.mode==="script"?await e.evaluateScriptCondition(r):Zae(r,e.variables)}function Zae(r,e){let t=r.variableName?.trim();if(!t)return I.logWarning("Conditional command skipped: No variable name configured."),!1;if(!(t in e))return I.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(Nc(r.operator)){let i=I2(r);return i===void 0?(I.logWarning(`Conditional command: Operator '${r.operator}' requires a comparison value.`),!1):r.operator==="contains"?NG(n,i,r):r.operator==="notContains"?!NG(n,i,r):Jae(n,i,r)}return!1}function NG(r,e,t){if(r==null)return!1;if(typeof e=="string"&&e.length===0)return I.logWarning("Conditional command: 'contains' operator requires a non-empty comparison value."),!1;if(Array.isArray(r))return r.map(o=>mD(o,t.valueType)).some(o=>o===e);if(typeof r=="string")return r.includes(ua(e));if(typeof r=="number"&&typeof e=="number")return r===e;let n=ua(r),i=ua(e);return typeof n=="string"&&n.includes(i)}function Jae(r,e,t){let n=mD(r,t.valueType);switch(t.operator){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return _S(n,e,(i,o)=>i<o);case"lessThanOrEqual":return _S(n,e,(i,o)=>i<=o);case"greaterThan":return _S(n,e,(i,o)=>i>o);case"greaterThanOrEqual":return _S(n,e,(i,o)=>i>=o);default:return!1}}function _S(r,e,t){let n=Number(r),i=Number(e);return Number.isNaN(n)||Number.isNaN(i)?(I.logWarning("Conditional command numeric comparison failed: non-numeric value encountered."),!1):t(n,i)}var VG=E(()=>{Ie();Id()});function BG(r,e=void 0){return r==="horizontal"?"horizontal":r==="vertical"?"vertical":e}function Tu(r,e,t){return t?{location:r,direction:t,focus:e,mode:"default"}:{location:r,focus:e,mode:"default"}}function qG(r){let e=r.focus??!0;if(r.location)switch(r.location){case"reuse":return Tu("reuse",e);case"tab":return Tu("tab",e);case"split":return Tu("split",e,BG(r.direction,"vertical"));case"window":return Tu("window",e);case"left-sidebar":return Tu("left-sidebar",e);case"right-sidebar":return Tu("right-sidebar",e);default:break}let t=r.openInNewTab??!1,n=BG(r.direction);return t?Tu("split",e,n??"vertical"):Tu("reuse",e)}var UG=E(()=>{eT()});function HG(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 zG=E(()=>{});function WG(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"?tle.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 jG(r){return`${r.scriptPath}::${r.exportName??"default"}`}var ele,GG,tle,_a,Ob=E(()=>{lj();Qk();ele=z$(require("obsidian"));Ie();xt();vr();r$();OG();i$();_s();ht();ho();qF();BF();UF();HF();zF();WF();jF();GF();YF();KF();ew();lp();ht();GG=require("obsidian");Ni();VG();$b();UG();zG();un();Ah();uS();Dh();tle=new Map([["InfiniteAIAssistant",'QuickAdd has removed the "Infinite AI Assistant" 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 user script.']]);_a=class extends $h{constructor(t,n,i,o,s,a,l,c=null){super(t);this.originLeaf=c;this.conditionalScriptCache=new Map;this.choice=i,this.plugin=n,this.macro=i?.macro,this.choiceExecutor=o,this.preloadedUserScripts=a??n
%cDetected reactivity loss when reading \`${r}\`. This happens when state is read in an async function after an earlier \`await\`
https://svelte.dev/e/await_reactivity_loss`,Ha,za):console.warn("https://svelte.dev/e/await_reactivity_loss")}function X$(r,e){Q?console.warn(`%c[svelte] await_waterfall
%cAn async derived, \`${r}\` (${e}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
https://svelte.dev/e/await_waterfall`,Ha,za):console.warn("https://svelte.dev/e/await_waterfall")}function Z$(){Q?console.warn(`%c[svelte] derived_inert
%cReading a derived belonging to a now-destroyed effect may result in stale values
https://svelte.dev/e/derived_inert`,Ha,za):console.warn("https://svelte.dev/e/derived_inert")}function J$(r,e,t){Q?console.warn(`%c[svelte] hydration_attribute_changed
%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
https://svelte.dev/e/hydration_attribute_changed`,Ha,za):console.warn("https://svelte.dev/e/hydration_attribute_changed")}function Fu(r){Q?console.warn(`%c[svelte] hydration_mismatch
%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"}
https://svelte.dev/e/hydration_mismatch`,Ha,za):console.warn("https://svelte.dev/e/hydration_mismatch")}function eO(){Q?console.warn(`%c[svelte] lifecycle_double_unmount
%cTried to unmount a component that was not mounted
https://svelte.dev/e/lifecycle_double_unmount`,Ha,za):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function tO(){Q?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",Ha,za):console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function Tw(r){Q?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
https://svelte.dev/e/state_proxy_equality_mismatch`,Ha,za):console.warn("https://svelte.dev/e/state_proxy_equality_mismatch")}function rO(){Q?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",Ha,za):console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}var Me=!1;function jr(r){Me=r}var Ye;function Vt(r){if(r===null)throw Fu(),qa;return Ye=r}function fn(){return Vt(Nn(Ye))}function N(r){if(Me){if(Nn(Ye)!==null)throw Fu(),qa;Ye=r}}function Gr(r=1){if(Me){for(var e=r,t=Ye;e--;)t=Nn(t);Ye=t}}function Ks(r=!0){for(var e=0,t=Ye;;){if(t.nodeType===Gi){var n=t.data;if(n==="]"){if(e===0)return t;e-=1}else(n==="["||n==="[!"||n[0]==="["&&!isNaN(Number(n.slice(1))))&&(e+=1)}var i=Nn(t);r&&t.remove(),t=i}}function Qh(r){if(!r||r.nodeType!==Gi)throw Fu(),qa;return r.data}function kw(r){return r===this.v}function Sw(r,e){return r!=r?e==e:r!==e||r!==null&&typeof r=="object"||typeof r=="function"}function _w(r){return!Sw(r,this.v)}function nO(r){if(Q){let e=new Error(`invariant_violation
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="Svelte error",e}else throw new Error("https://svelte.dev/e/invariant_violation")}function Aw(r){if(Q){let e=new Error(`lifecycle_outside_component
\`${r}(...)\` can only be used during component initialisation
https://svelte.dev/e/lifecycle_outside_component`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function oO(){if(Q){let r=new Error("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/async_derived_orphan")}function b_(){if(Q){let r=new Error("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");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/bind_invalid_checkbox_value")}function sO(){if(Q){let r=new Error(`derived_references_self
A derived value cannot reference itself recursively
https://svelte.dev/e/derived_references_self`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/derived_references_self")}function w_(r,e,t){if(Q){let n=new Error(`each_key_duplicate
${t?`Keyed each block has duplicate key \`${t}\` at indexes ${r} and ${e}`:`Keyed each block has duplicate key at indexes ${r} and ${e}`}
https://svelte.dev/e/each_key_duplicate`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_duplicate")}function aO(r,e,t){if(Q){let n=new Error(`each_key_volatile
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
https://svelte.dev/e/each_key_volatile`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_volatile")}function lO(r){if(Q){let e=new Error(`effect_in_teardown
\`${r}\` cannot be used inside an effect cleanup function
https://svelte.dev/e/effect_in_teardown`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_in_teardown")}function cO(){if(Q){let r=new Error("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");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function uO(r){if(Q){let e=new Error(`effect_orphan
\`${r}\` can only be used inside an effect (e.g. during component initialisation)
https://svelte.dev/e/effect_orphan`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_orphan")}function dO(){if(Q){let r=new Error(`effect_update_depth_exceeded
Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
https://svelte.dev/e/effect_update_depth_exceeded`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function pO(){if(Q){let r=new Error(`hydration_failed
Failed to hydrate the application
https://svelte.dev/e/hydration_failed`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/hydration_failed")}function fO(){if(Q){let r=new Error("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");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/invalid_snippet")}function mO(r){if(Q){let e=new Error(`props_invalid_value
Cannot do \`bind:${r}={undefined}\` when \`${r}\` has a fallback value
https://svelte.dev/e/props_invalid_value`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/props_invalid_value")}function hO(r){if(Q){let e=new Error(`rune_outside_svelte
The \`${r}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files
https://svelte.dev/e/rune_outside_svelte`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/rune_outside_svelte")}function gO(){if(Q){let r=new Error("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");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function vO(){if(Q){let r=new Error("state_prototype_fixed\nCannot set prototype of `$state` object\nhttps://svelte.dev/e/state_prototype_fixed");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_prototype_fixed")}function yO(){if(Q){let r=new Error("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");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function bO(){if(Q){let r=new Error("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");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}var Ar=!1,Wa=!1,ss=!1;var V4="font-weight: bold",B4="font-weight: normal";function C_(r){Q?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"}
https://svelte.dev/e/state_snapshot_uncloneable`,V4,B4):console.warn("https://svelte.dev/e/state_snapshot_uncloneable")}var q4=[];function Pu(r,e=!1,t=!1){if(Q&&!e){let n=[],i=Xh(r,new Map,"",n,null,t);if(n.length===1&&n[0]==="")C_();else if(n.length>0){let o=n.length>10?n.slice(0,7):n.slice(0,10),s=n.length-o.length,a=o.map(l=>`- <value>${l}`).join(`
`);s>0&&(a+=`
- ...and ${s} more`),C_(a)}return i}return Xh(r,new Map,"",q4,null,t)}function Xh(r,e,t,n,i=null,o=!1){if(typeof r=="object"&&r!==null){var s=e.get(r);if(s!==void 0)return s;if(r instanceof Map)return new Map(r);if(r instanceof Set)return new Set(r);if(ko(r)){var a=Array(r.length);e.set(r,a),i!==null&&e.set(i,a);for(var l=0;l<r.length;l+=1){var c=r[l];l in r&&(a[l]=Xh(c,e,Q?`${t}[${l}]`:t,n,null,o))}return a}if(ec(r)===vw){a={},e.set(r,a),i!==null&&e.set(i,a);for(var u of Object.keys(r))a[u]=Xh(r[u],e,Q?`${t}.${u}`:t,n,null,o);return a}if(r instanceof Date)return r.getTime(),structuredClone(r);if(typeof r.toJSON=="function"&&!o)return Xh(r.toJSON(),e,Q?`${t}.toJSON()`:t,n,r)}if(r instanceof EventTarget)return r;try{return structuredClone(r)}catch{return Q&&n.push(t),r}}var Zh=null;function Zn(r,e){return r.label=e,Iw(r.v,e),r}function Iw(r,e){return r?.[Cw]?.(e),r}function as(r){let e=new Error,t=U4();return t.length===0?null:(t.unshift(`
`),pn(e,"stack",{value:t.join(`
`)}),pn(e,"name",{value:r}),e)}function U4(){let r=Error.stackTraceLimit;Error.stackTraceLimit=1/0;let e=new Error().stack;if(Error.stackTraceLimit=r,!e)return[];let t=e.split(`
`),n=[];for(let i=0;i<t.length;i++){let o=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)}}return n}function CO(r,e){if(!Q)throw new Error("invariant(...) was not guarded by if (DEV)");r||nO(e)}var ct=null;function ja(r){ct=r}var Qs=null;function Sp(r){Qs=r}var ls=null;function Dw(r){ls=r}function pe(r,e=!1,t){ct={p:ct,i:!1,c:null,e:null,s:r,x:null,r:Pe,l:Wa&&!e?{s:null,u:null,$:[]}:null},Q&&(ct.function=t,ls=t)}function fe(r){var e=ct,t=e.e;if(t!==null){e.e=null;for(var n of t)x_(n)}return r!==void 0&&(e.x=r),e.i=!0,ct=e.p,Q&&(ls=ct?.function??null),Jh(r)}function Jh(r={}){return pn(r,ww,{value:!0}),r}function cs(){return!Wa||ct!==null&&ct.l===null}var Mu=[];function xO(){var r=Mu;Mu=[],yw(r)}function yr(r){if(Mu.length===0&&!$u){var e=Mu;queueMicrotask(()=>{e===Mu&&xO()})}Mu.push(r)}function EO(){for(;Mu.length>0;)xO()}var H4=-7169;function Bt(r,e){r.f=r.f&H4|e}function _p(r){(r.f&512)!==0||r.deps===null?Bt(r,1024):Bt(r,4096)}function TO(r){if(r!==null)for(let e of r)(e.f&2)===0||(e.f&65536)===0||(e.f^=65536,TO(e.deps))}function Fw(r,e,t){(r.f&2048)!==0?e.add(r):(r.f&4096)!==0&&t.add(r),TO(r.deps),Bt(r,1024)}var kO=!1,Pw=!1;function E_(r){var e=Pw;try{return Pw=!1,[r(),Pw]}finally{Pw=e}}function Nu(r){Me&&gn(r)!==null&&Ip(r)}var SO=!1;function Mw(){SO||(SO=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{if(!r.defaultPrevented)for(let e of r.target.elements)e[tc]?.()})},{capture:!0}))}function Ao(r){var e=ze,t=Pe;Qr(null),Xr(null);try{return r()}finally{Qr(e),Xr(t)}}function $w(r,e,t,n=t){r.addEventListener(e,()=>Ao(t));let i=r[tc];i?r[tc]=()=>{i(),n(!0)}:r[tc]=()=>n(!0),Mw()}function Ow(r,e,t,n){let i=cs()?nc:Lu;var o=r.filter(f=>!f.settled),s=e.map(i);if(Q&&s.forEach((f,m)=>{f.label=e[m].toString().replace("() => ","").replaceAll("$.eager(() => ","$state.eager(").replace(/\$\.get\((.+?)\)/g,(g,v)=>v)}),t.length===0&&o.length===0){n(s);return}var a=Pe,l=_O(),c=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(f=>f.promise)):null;function u(f){if((a.f&16384)===0){l();try{n([...s,...f])}catch(m){Mi(m,a)}Dp()}}var d=T_();if(t.length===0){c.then(()=>u([])).finally(d);return}function p(){Promise.all(t.map(f=>S_(f))).then(u).catch(f=>Mi(f,a)).finally(d)}c?c.then(()=>{l(),p(),Dp()}):p()}function _O(){var r=Pe,e=ze,t=ct,n=Ne;if(Q)var i=Qs;return function(s=!0){Xr(r),Qr(e),ja(t),s&&(r.f&16384)===0&&(n?.activate(),n?.apply()),Q&&(k_(null),Sp(i))}}var W4=!1;function Dp(r=!0){W4=!1,Xr(null),Qr(null),ja(null),r&&Ne?.deactivate(),Q&&(k_(null),Sp(null))}function T_(){var r=Pe,e=r.b,t=Ne,n=!!e?.is_rendered();return e?.update_pending_count(1,t),t.increment(n,r),()=>{e?.update_pending_count(-1,t),t.decrement(n,r)}}var $i=null;function k_(r){$i=r}var tg=new Set;function nc(r){var e=2050;Pe!==null&&(Pe.f|=524288);let t={ctx:ct,deps:null,effects:null,equals:kw,f:e,fn:r,reactions:null,rv:0,v:jt,wv:0,parent:Pe,ac:null};return Q&&ss&&(t.created=as("created at")),t}var Fp=Symbol("obsolete");function S_(r,e,t){let n=Pe;n===null&&oO();var i=void 0,o=ti(jt);Q&&(o.label=e??r.toString());var s=!ze,a=new Set;return DO(()=>{var l=Pe;Q&&($i={effect:l,effect_deps:new Set,warned:!1});var c=bw();i=c.promise;try{Promise.resolve(r()).then(c.resolve,f=>{f!==Ua&&c.reject(f)}).finally(Dp)}catch(f){c.reject(f),Dp()}if(Q){if($i){if(l.deps!==null)for(let f=0;f<fi;f+=1)$i.effect_deps.add(l.deps[f]);if(vn!==null)for(let f=0;f<vn.length;f+=1)$i.effect_deps.add(vn[f])}$i=null}var u=Ne;if(s){if((l.f&32768)!==0)var d=T_();if(n.b?.is_rendered())u.async_deriveds.get(l)?.reject(Fp);else for(let f of a.values())f.reject(Fp);a.add(c),u.async_deriveds.set(l,c)}let p=(f,m=void 0)=>{Q&&($i=null),d?.(),a.delete(c),m!==Fp&&(u.activate(),m?(o.f|=8388608,ds(o,m)):((o.f&8388608)!==0&&(o.f^=8388608),Q&&t!==void 0&&!o.equals(f)&&(tg.add(o),setTimeout(()=>{tg.has(o)&&(l.f&16384)===0&&(X$(o.label,t),tg.delete(o))})),ds(o,f)),u.deactivate())};c.promise.then(p,f=>p(null,f||"unknown"))}),hn(()=>{for(let l of a)l.reject(Fp)}),Q&&(o.f|=
${n}in ${e.fn?.name||"<unknown>"}`,o=e.ctx;o!==null;)i+=`
${n}in ${o.function?.[To].split("/").pop()}`,o=o.p;return{message:r.message+`
${i}
`,stack:r.stack?.split(`
`).filter(s=>!s.includes("svelte/src/internal")).join(`
`)}}}function YO(r){let e=q_.get(r);e&&(pn(r,"message",{value:e.message}),pn(r,"stack",{value:e.stack}))}function QO(r){Pe===null&&(ze===null&&uO(r),cO()),Yi&&lO(r)}function rY(r,e){var t=e.last;t===null?e.last=e.first=r:(t.next=r,r.prev=t,e.last=r)}function ea(r,e){var t=Pe;if(Q)for(;t!==null&&(t.f&131072)!==0;)t=t.parent;t!==null&&(t.f&8192)!==0&&(r|=8192);var n={ctx:ct,deps:null,nodes:null,f:r|2048|512,first:null,fn:e,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};Q&&(n.component_function=ls),Ne?.register_created_effect(n);var i=n;if((r&4)!==0)qu!==null?qu.push(n):Ki.ensure().schedule(n);else if(e!==null){try{Zs(n)}catch(s){throw br(n),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&524288)===0&&(i=i.first,(r&16)!==0&&(r&65536)!==0&&i!==null&&(i.f|=65536))}if(i!==null&&(i.parent=t,t!==null&&rY(i,t),ze!==null&&(ze.f&2)!==0&&(r&64)===0)){var o=ze;(o.effects??(o.effects=[])).push(i)}return n}function rc(){return ze!==null&&!hi}function hn(r){let e=ea(8,null);return Bt(e,1024),e.teardown=r,e}function Yt(r){QO("$effect"),Q&&pn(r,"name",{value:"$effect"});var e=Pe.f,t=!ze&&(e&32)!==0&&ct!==null&&!ct.i;if(t){var n=ct;(n.e??(n.e=[])).push(r)}else return x_(r)}function x_(r){return ea(1048580,r)}function z_(r){Ki.ensure();let e=ea(524352,r);return()=>{br(e)}}function XO(r){Ki.ensure();let e=ea(524352,r);return(t={})=>new Promise(n=>{t.outro?ta(e,()=>{br(e),n(void 0)}):(br(e),n(void 0))})}function $r(r){return ea(4,r)}function DO(r){return ea(4718592,r)}function bn(r,e=0){return ea(8|e,r)}function re(r,e=[],t=[],n=[]){Ow(n,e,t,i=>{ea(8,()=>{r(...i.map(h))})})}function gi(r,e=0){var t=ea(16|e,r);return Q&&(t.dev_stack=Qs),t}function Zr(r){return ea(524320,r)}function W_(r){var e=r.teardown;if(e!==null){let t=Yi,n=ze;U_(!0),Qr(null);try{e.call(null)}catch(i){Mi(i,r.parent)}finally{U_(t),Qr(n)}}}function ng(r,e=!1){var t=r.first;for(r.first=r.last=null;t!==null;){let i=t.ac;i!==null&&Ao(()=>{i.abort(Ua)});var n=t.next;(t.f&64)!==0?t.parent=null:br(t,e),t=n}}function ZO(r){for(var e=r.first;e!==null;){var t=e.next;(e.f&32)===0&&br(e),e=t}}function br(r,e=!0){var t=!1;(e||(r.f&262144)!==0)&&r.nodes!==null&&r.nodes.end!==null&&(JO(r.nodes.start,r.nodes.end),t=!0),r.f|=33554432,ng(r,e&&!t),Bu(r,0);var n=r.nodes&&r.nodes.t;if(n!==null)for(let o of n)o.stop();W_(r),r.f^=33554432,r.f|=16384;var i=r.parent;i!==null&&i.first!==null&&R_(r),Q&&(r.component_function=null),r.next=r.prev=r.teardown=r.ctx=r.deps=r.fn=r.nodes=r.ac=r.b=null}function JO(r,e){for(;r!==null;){var t=r===e?null:Nn(r);r.remove(),r=t}}function R_(r){var e=r.parent,t=r.prev,n=r.next;t!==null&&(t.next=n),n!==null&&(n.prev=t),e!==null&&(e.first===r&&(e.first=n),e.last===r&&(e.last=t))}function ta(r,e,t=!0){var n=[];r.f|=256,eR(r,n,!0);var i=()=>{t&&br(r),e&&e()},o=n.length;if(o>0){var s=()=>--o||i();for(var a of n)a.out(s)}else i()}function eR(r,e,t){if((r.f&8192)===0){r.f^=8192;var n=r.nodes&&r.nodes.t;if(n!==null)for(let a of n)(a.is_global||t)&&e.push(a);for(var i=r.first;i!==null;){var o=i.next;if((i.f&64)===0){var s=(i.f&65536)!==0||(i.f&32)!==0&&(r.f&16)!==0;eR(i,e,s?t:!1)}i=o}}}function Hp(r){r.f&=-257,tR(r,!0)}function tR(r,e){if((r.f&256)===0&&(r.f&8192)!==0){r.f^=8192,(r.f&1024)===0&&(Bt(r,2048),Ki.ensure().schedule(r));for(var t=r.first;t!==null;){var n=t.next,i=(t.f&65536)!==0||(t.f&32)!==0;tR(t,i?e:!1),t=n}var o=r.nodes&&r.nodes.t;if(o!==null)for(let s of o)(s.is_global||e)&&s.in()}}function zp(r,e){if(r.nodes)for(var t=r.nodes.start,n=r.nodes.end;t!==null;){var i=t===n?null:Nn(t);e.append(t),t=i}}var rR=null;var Ww=!1,Yi=!1;function U_(r){Yi=r}var ze=null,hi=!1;function Qr(r){ze=r}var Pe=null;function Xr(r){Pe=r}var Fo=null;function Lw(r){ze!==null&&(!Ar||(ze.f&2)!==0)&&(Fo??(Fo=new Set)).add(r)}var vn=null,fi=0,Qi=null;function UO(r){Qi=r}var iR=1,Gu=0,sc=Gu;function V_(r){sc=r}function Pp(){return++iR}function oc(r){var e=r.f;if((e&2048)!==0)return!0;if(e&2&&(r.f&=-65537),(e&4096)!==0){for(var t=r.deps,n=t.length,i=0;i<n;i++){var o=t[i];if(oc(o)&&A_(o),o.wv>r.wv)return!0}(e&512)!==0&&yn===null&&Bt(r,10
`).some(a=>a.startsWith("https://svelte.dev/e/")))throw s;return s!==qa&&console.warn("Failed to hydrate: ",s),e.recover===!1&&pO(),Hw(),Ip(t),jr(!1),Zu(r,e)}finally{jr(n),Vt(i)}}var Zw=new Map;function gR(r,{target:e,anchor:t,props:n={},events:i,context:o,intro:s=!0,transformError:a}){Hw();var l=void 0,c=XO(()=>{var u=t??e.appendChild(wr());hg(u,{pending:()=>{}},f=>{pe({});var m=ct;if(o&&(m.c=o),i&&(n.$$events=i),Me&&Xi(f,null),rA=s,l=r(f,n)||Jh(),rA=!0,Me&&(Pe.nodes.end=Ye,Ye===null||Ye.nodeType!==Gi||Ye.data!=="]"))throw Fu(),qa;fe()},a);var d=new Set,p=f=>{for(var m=0;m<f.length;m++){var g=f[m];if(!d.has(g)){d.add(g);var v=uR(g);for(let x of[e,document]){var y=Zw.get(x);y===void 0&&(y=new Map,Zw.set(x,y));var b=y.get(g);b===void 0?(x.addEventListener(g,Kw,{passive:v}),y.set(g,1)):y.set(g,b+1)}}}};return p(Ep(Y_)),Yw.add(p),()=>{for(var f of d)for(let v of[e,document]){var m=Zw.get(v),g=m.get(f);--g==0?(v.removeEventListener(f,Kw),m.delete(f),m.size===0&&Zw.delete(v)):m.set(f,g)}Yw.delete(p),u!==t&&u.parentNode?.removeChild(u)}});return nA.set(l,c),l}var nA=new WeakMap;function jp(r,e){let t=nA.get(r);return t?(nA.delete(r),t(e)):(Q&&eO(),Promise.resolve())}var ms,oa,to,Ju,gg,vg,Jw,hs=class{constructor(e,t=!0){he(this,"anchor");rt(this,ms,new Map);rt(this,oa,new Map);rt(this,to,new Map);rt(this,Ju,new Set);rt(this,gg,!0);rt(this,vg,e=>{if(V(this,ms).has(e)){var t=V(this,ms).get(e),n=V(this,oa).get(t);if(n)Hp(n),V(this,Ju).delete(t);else{var i=V(this,to).get(t);i&&(Hp(i.effect),V(this,oa).set(t,i.effect),V(this,to).delete(t),Q&&(i.fragment.lastChild[y_]=this.anchor),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),n=i.effect)}for(let[o,s]of V(this,ms)){if(V(this,ms).delete(o),o===e)break;let a=V(this,to).get(s);a&&(br(a.effect),V(this,to).delete(s))}for(let[o,s]of V(this,oa)){if(o===t||V(this,Ju).has(o))continue;let a=()=>{if(Array.from(V(this,ms).values()).includes(o)){var c=document.createDocumentFragment();zp(s,c),c.append(wr()),V(this,to).set(o,{effect:s,fragment:c})}else br(s);V(this,Ju).delete(o),V(this,oa).delete(o)};V(this,gg)||!n?(V(this,Ju).add(o),ta(s,a,!1)):a()}}});rt(this,Jw,e=>{V(this,ms).delete(e);let t=Array.from(V(this,ms).values());for(let[n,i]of V(this,to))t.includes(n)||(br(i.effect),V(this,to).delete(n))});this.anchor=e,Ge(this,gg,t)}ensure(e,t){var n=Ne,i=zw();if(t&&!V(this,oa).has(e)&&!V(this,to).has(e))if(i){var o=document.createDocumentFragment(),s=wr();o.append(s),V(this,to).set(e,{effect:Zr(()=>t(s)),fragment:o})}else V(this,oa).set(e,Zr(()=>t(this.anchor)));if(V(this,ms).set(n,e),i){for(let[a,l]of V(this,oa))a===e?n.unskip_effect(l):n.skip_effect(l);for(let[a,l]of V(this,to))a===e?n.unskip_effect(l.effect):n.skip_effect(l.effect);n.oncommit(V(this,vg)),n.ondiscard(V(this,Jw))}else Me&&(this.anchor=Ye),V(this,vg).call(this,n)}};ms=new WeakMap,oa=new WeakMap,to=new WeakMap,Ju=new WeakMap,gg=new WeakMap,vg=new WeakMap,Jw=new WeakMap;function yg(r,e,...t){var n=new hs(r);gi(()=>{let i=e()??null;Q&&i==null&&fO(),n.ensure(i,i&&(o=>i(o,...t)))},65536)}if(Q){let r=function(e){if(!(e in globalThis)){let t;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(t!==void 0)return t;hO(e)},set:n=>{t=n}})}};r("$state"),r("$effect"),r("$derived"),r("$inspect"),r("$props"),r("$bindable")}function eC(r){ct===null&&Aw("onMount"),Wa&&ct.l!==null?gY(ct).m.push(r):Yt(()=>{let e=kt(r);if(typeof e=="function")return e})}function gY(r){var e=r.l;return e.u??(e.u={a:[],b:[],m:[]})}var bR=new Map;function wR(r,e){var t=bR.get(r);t||(t=new Set,bR.set(r,t)),t.add(e)}function Y(r,e,t=!1){var n;Me&&(n=Ye,fn());var i=new hs(r),o=t?65536:0;function s(a,l){if(Me){var c=Qh(n);if(a!==parseInt(c.substring(1))){var u=Ks();Vt(u),i.anchor=u,jr(!1),i.ensure(a,l),jr(!0);return}}i.ensure(a,l)}gi(()=>{var a=!1;e((l,c=0)=>{a=!0,s(c,l)}),a||s(-1,null)},o)}var wY=Symbol("NaN");function bg(r,e,t){Me&&fn();var n=new hs(r),i=!cs();gi(()=>{var o=e();o!==o&&(o=wY),i&&o!==null&&typeof o=="object"&&(o={}),n.ensure(o,t)})}function xg(r,e){return e}function kY(r,e,t){for(var n=[],i=e.length,o,s=e.length,a=0;a<i;a++){let d=e
\r\f\xA0\v\uFEFF`];function AR(r,e,t){var n=r==null?"":""+r;if(e&&(n=n?n+" "+e:e),t){for(var i of Object.keys(t))if(t[i])n=n?n+" "+i:i;else if(n.length)for(var o=i.length,s=0;(s=n.indexOf(i,s))>=0;){var a=s+o;(s===0||SR.includes(n[s-1]))&&(a===n.length||SR.includes(n[a]))?n=(s===0?"":n.substring(0,s))+n.substring(a+1):s=a}}return n===""?null:n}function _R(r,e=!1){var t=e?" !important;":";",n="";for(var i of Object.keys(r)){var o=r[i];o!=null&&o!==""&&(n+=" "+i+": "+o+t)}return n}function aA(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function IR(r,e){if(e){var t="",n,i;if(Array.isArray(e)?(n=e[0],i=e[1]):n=e,r){r=String(r).replaceAll(/\/\*.*?\*\//g,"").trim();var o=!1,s=0,a=!1,l=[];n&&l.push(...Object.keys(n).map(aA)),i&&l.push(...Object.keys(i).map(aA));var c=0,u=-1;let g=r.length;for(var d=0;d<g;d++){var p=r[d];if(a?p==="/"&&r[d-1]==="*"&&(a=!1):o?o===p&&(o=!1):p==="/"&&r[d+1]==="*"?a=!0:p==='"'||p==="'"?o=p:p==="("?s++:p===")"&&s--,!a&&o===!1&&s===0){if(p===":"&&u===-1)u=d;else if(p===";"||d===g-1){if(u!==-1){var f=aA(r.substring(c,u).trim());if(!l.includes(f)){p!==";"&&d++;var m=r.substring(c,d).trim();t+=" "+m+";"}}c=d+1,u=-1}}}}return n&&(t+=_R(n)),i&&(t+=_R(i,!0)),t=t.trim(),t===""?null:t}return r==null?null:String(r)}function it(r,e,t,n,i,o){var s=r[jh];if(Me||s!==t||s===void 0){var a=AR(t,n,o);(!Me||a!==r.getAttribute("class"))&&(a==null?r.removeAttribute("class"):e?r.className=a:r.setAttribute("class",a)),r[jh]=t}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&r.classList.toggle(l,c)}return o}function lA(r,e={},t,n){for(var i in t){var o=t[i];e[i]!==o&&(t[i]==null?r.style.removeProperty(i):r.style.setProperty(i,o,n))}}function Gp(r,e,t,n){var i=r[Gh];if(Me||i!==e){var o=IR(e,n);(!Me||o!==r.getAttribute("style"))&&(o==null?r.removeAttribute("style"):r.style.cssText=o),r[Gh]=e}else n&&(Array.isArray(n)?(lA(r,t?.[0],n[0]),lA(r,t?.[1],n[1],"important")):lA(r,t,n));return n}function cA(r,e){e?r.hasAttribute("selected")||r.setAttribute("selected",""):r.removeAttribute("selected")}function $Y(r,e){var t=r.__defaultValue,n=r.multiple,i=n?t??[]:null;if(!(n&&!ko(i))){var o=r.selectedIndex,s=e&&n?new Set(r.selectedOptions):null;for(var a of r.options){var l=Yp(a);cA(a,n?i.includes(l):Uw(l,t))}if(e)if(s!==null)for(a of r.options){var c=s.has(a);a.selected!==c&&(a.selected=c)}else r.selectedIndex!==o&&(r.selectedIndex=o)}}function uc(r,e,t=!1){if(r.multiple){if(e==null)return;if(!ko(e))return tO();for(var n of r.options)n.selected=e.includes(Yp(n));return}for(n of r.options){var i=Yp(n);if(Uw(i,e)){n.selected=!0;return}}(!t||e!==void 0)&&(r.selectedIndex=-1)}function dc(r){var e=new MutationObserver(t=>{t.every(OY)||("__defaultValue"in r&&$Y(r,!1),"__value"in r&&uc(r,r.__value))});e.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),hn(()=>{e.disconnect()})}function uA(r,e,t=e){var n=new WeakSet,i=!0;$w(r,"change",o=>{var s=o?"[selected]":":checked",a;if(r.multiple)a=[].map.call(r.querySelectorAll(s),Yp);else{var l=r.querySelector(s)??r.querySelector("option:not([disabled])");a=l&&Yp(l)}t(a),r.__value=a,Ne!==null&&n.add(Ne)}),$r(()=>{var o=e();if(r===document.activeElement){var s=Ar?Xs:Ne;if(n.has(s))return}if(uc(r,o,i),i&&o===void 0){var a=r.querySelector(":checked");a!==null&&(o=Yp(a),t(o))}r.__value=o,i=!1})}function Yp(r){return"__value"in r?r.__value:r.value}function OY(r){if(r.target.closest("selectedcontent")!==null)return!0;if(r.type==="childList"){var e=[...r.addedNodes,...r.removedNodes];return e.length>0&&e.every(t=>t.nodeName==="SELECTEDCONTENT")}return!1}var VY=Symbol("is custom element"),BY=Symbol("is html"),qY=Ew?"link":"LINK";var UY=Ew?"progress":"PROGRESS";function Rt(r){if(Me){var e=!1,t=()=>{if(!e){if(e=!0,r.hasAttribute("value")){var n=r.value;ke(r,"value",null),r.value=n}if(r.hasAttribute("checked")){var i=r.checked;ke(r,"checked",null),r.checked=i}}};r[tc]=t,yr(t),Mw()}}function bi(r,e){var t=pA(r);t.value===(t.value=e??void 0)||r.value===e&&(e!==0||r.nodeName!==UY)||(r.value=e??"")}function ed(r,e){var t=pA(r);t.checked!==(t.checked=e??void 0)&&(r
`).map(b=>b.trim()).filter(b=>b.length>0),g=DA(m[0]??"(empty text card)",90),v=[`${m.length} line${m.length===1?"":"s"}`];c&&v.push(c);let y=v.join(" \xB7 ");return{id:a.id,type:l,title:g,subtitle:y,searchText:`${a.id} ${g} ${y}`.toLowerCase(),capturable:!0,capturableReason:""}}if(l==="file"){let f=u8(a.file),m=Nt.test(f),g=m?"":"Canvas file cards must link to markdown files (.md).",v=DA(f.split("/").pop()??f,90),y=[DA(f,120)];c&&y.push(c),m||y.push("Not capturable in this version");let b=y.join(" \xB7 ");return{id:a.id,type:l,title:v,subtitle:b,searchText:`${a.id} ${v} ${b}`.toLowerCase(),capturable:m,capturableReason:g}}let d=`Unsupported node (${typeof a.type=="string"&&a.type.length>0?a.type:"unknown"})`,p=c||"Type is not currently capturable";return{id:a.id,type:l,title:d,subtitle:p,searchText:`${a.id} ${d} ${p}`.toLowerCase(),capturable:!1,capturableReason:"This Canvas node type is not capturable."}}),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[]}}ht();Kg();ks();rn();bt();Xe();var Q5=["noteContent","propertyValue","captureTarget","fileName","lineTarget"],X5=["captureTarget","fileName"],Un=Q5,o1=3;function Be(r,e,t=r.endsWith(":}}")?2:0){return{insert:r,description:e,caretOffset:t}}var Z5=[{regex:KR,contexts:Un,suggestion:Be("{{VALUE}}","Asks you for text when the choice runs")},{regex:QR,contexts:Un,suggestion:Be("{{VALUE:}}","Asks once and reuses the answer by name, or lists options to pick from"),expansions:()=>[Be("{{VALUE:title}}",'Asks once, then reuses the answer as "title"'),Be("{{VALUE:option1,option2,option3}}","Asks you to pick one of these options"),Be("{{VALUE:option1,option2,option3|custom}}","Same, but you can also type your own"),Be("{{VALUE:title|label:Note title}}","Words the prompt yourself"),Be("{{VALUE:option1,option2|label:Pick one}}","A list with your own prompt text"),Be("{{VALUE:title|label:Note title|default:Untitled}}","Opens the prompt with an answer already filled in"),Be("{{VALUE:<items>|text:<display items>}}","Shows one label in the list and inserts another"),Be("{{VALUE:option1,option2|name:category}}","Names the pick, so {{VALUE:category}} reuses it"),Be("{{VALUE:title|case:kebab}}","Reshapes the answer; type |case: for every style"),Be("{{VALUE:title|trim}}","Trims whitespace off the answer"),Be("{{VALUE:title|optional}}","Lets the prompt be skipped, leaving it empty")]},{regex:YR,contexts:Un,suggestion:Be("{{NAME}}","Another name for {{VALUE}}; they do the same thing")},{regex:XR,contexts:Un,suggestion:Be("{{VDATE:}}",'Asks you for a date; "tomorrow" works'),expansions:()=>[Be("{{VDATE:date,YYYY-MM-DD}}",'Asks for a date, reused by name as "date"'),Be("{{VDATE:date,YYYY-MM-DD|today}}","Same, with today filled in"),Be("{{VDATE:dueDate,YYYY-MM-DD|next monday}}","Same, starting at next Monday"),Be("{{VDATE:dueDate,YYYY-MM-DD|optional}}","Same, but skippable"),Be("{{VDATE:date,dddd, MMMM Do, YYYY|case:lower}}","Lowercases the picked date after formatting")]},{regex:nN,contexts:Un,suggestion:Be("{{FIELD:}}","Suggests values a property already has in your vault, like {{FIELD:project}}")},{regex:lN,contexts:["noteContent","propertyValue"],suggestion:Be("{{PROPERTY}}","Inserts the property's current value (property Captures only)")},{regex:cN,contexts:["noteContent"],suggestion:Be("{{CURSOR}}","Places the cursor here (Capture and Template bodies)")},{regex:rN,contexts:Un,suggestion:Be("{{FILE:}}","Picks a note from a folder"),expansions:({context:r})=>{let e=[Be("{{FILE:<folder>}}","Picks a note from that folder and inserts its name")];return X5.includes(r)||e.push(Be("{{FILE:<folder>|link}}","Same, but inserts a link to the note"),Be("{{FILE:<folder>|path}}","Same, but inserts its full path"),Be("{{FILE:<folder>|optional}}","Same, but skippable")),e.push(Be("{{FILE:<folder>|custom}}","Same, but you can also type a name that is not there yet")),e}},{regex:sN,contexts:Un,suggestion:Be("{{MVALUE}}","Asks you for a math formula (LaTeX), with a live preview")},{regex:jR,contexts:Un,suggestion:Be("{{DAT
/* 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 St(r,e){pe(e,!0),We(r,aK);let t=ne(e,"checked",15),n=ne(e,"disabled",3,!1),i=ne(e,"ariaLabel",3,void 0),o=ne(e,"onchange",3,void 0),s=F(()=>t()??!1);function a(){n()||(t(!h(s)),o()?.(t()))}function l(p){(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),a())}var c=sK();let u;var d=B(c);Rt(d),N(c),re(()=>{u=it(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),ed(d,h(s))}),Ae("click",c,a),Ae("keydown",c,l),M(r,c),fe()}nt(["click","keydown"]);var lK=L("<option> </option>"),cK=L('<select class="dropdown"></select>');function ft(r,e){pe(e,!0);let t=ne(e,"value",15,""),n=ne(e,"disabled",3,!1),i=ne(e,"ariaLabel",3,void 0),o=ne(e,"onchange",3,void 0);var s=cK();Ot(s,21,()=>e.options,a=>a.value,(a,l)=>{var c=lK(),u=le(c,!0),d={};re(()=>{ae(u,h(l).label),d!==(d=h(l).value)&&(c.value=(c.__value=d)??"")}),M(a,c)}),N(s),dc(s),re(()=>{s.disabled=n(),ke(s,"aria-label",i())}),Ae("change",s,()=>o()?.(t())),uA(s,t),M(r,s),fe()}nt(["change"]);var l1=require("obsidian"),uK=L('<span class="quickadd-icon svelte-1fiwm9k"></span>'),dK={hash:"svelte-1fiwm9k",code:".quickadd-icon.svelte-1fiwm9k {display:inline-flex;align-items:center;}.quickadd-icon.svelte-1fiwm9k svg {display:inline-block;vertical-align:middle;}"};function Et(r,e){pe(e,!0),We(r,dK);let t=ne(e,"size",3,16),n=Ce(void 0);Yt(()=>{if(!h(n)||!e.iconId)return;(0,l1.setIcon)(h(n),e.iconId);let o=h(n).querySelector("svg");o&&(o.setAttribute("width",`${t()}`),o.setAttribute("height",`${t()}`))});var i=uK();Ci(i,o=>j(n,o),()=>h(n)),M(r,i),fe()}Ds();Ie();xt();function Ef(r){return r==="Multi"?"folder":"choice"}function u2(r){return r==="Multi"?"Folder":"Choice"}function VQ(r){return`${u2(r)} name`}async function wx(r,e,t){try{let i=(await ar.Prompt(r,VQ(t),void 0,e)).trim();return!i||i===e?null:i}catch(n){return ot(n)||I.logError(nl(n,"Could not rename")),null}}var BQ=L('<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 kv(r,e){pe(e,!0);let t=ne(e,"name",15);async function n(){let u=await wx(e.app,t());u&&t(u)}var i=BQ(),o=B(i),s=B(o),a=le(s,!0),l=_(s,2),c=B(l);Et(c,{iconId:"pencil",size:16}),N(l),N(o),N(i),re(()=>{ke(o,"aria-label",`Rename ${t()}`),ae(a,t())}),Ae("click",o,n),M(r,i),fe()}nt(["click"]);ks();rn();var si=class extends xr{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=>kn(s))}getSuggestions(t){let n=Ac(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=iv(t),o=iv(this.getCurrentQuery());t.toLowerCase().endsWith(".md")&&o.toLowerCase().startsWith(`${i.toLowerCase()}.`)&&(o=i),this.renderMatch(n,i,o)}getCurrentQuery(){return this.inputEl.value}};function qQ(r){return r?Array.isArray(r)?r:[r]:[]}function Sd(r,e){let t=qQ(e(r));return{destroy(){t.forEach(n=>n.destroy())}}}var UQ=L("<textarea></textarea>"),HQ=L('<input type="text"/>'),zQ=L('<!> <div aria-live="polite"> </div>',1);function sn(r,e){pe(e,!0);let t=ne(e,"value",15,""),n=ne(e,"placeholder",3,void 0),i=ne(e,"inputKind",3,"text"),o=ne(e,"required",3,!1),s=ne(e,"requiredMessage",3,"This field is required"),a=ne(e,"disabled",3,!1),l=ne(e,"validator",3,void 0),c=ne(e,"trim",3,!0),u=ne(e,"suggestions",3,void 0),d=ne(e,"maxSuggestions",3,1/0),p=ne(e,"makeSuggesters",19,()=>[]),f=ne(e,"app",3,void 0),m=ne(e,"id",3,void 0),g=ne(e,"ariaLabel",3,void 0),v=ne(e,"onChange",3,void 0),y=Ce(!1),b=Ce(""),x=Ce("neutral"),w=0,T=!1,C=`qa-hint-${Math.random().toString(36).slice(2)}`,S=te=>c()?te
text is inserted under it. Use the toggles below to control placement within that
section.</div>`),GB=L("<!> <!>",1),O9=L(`<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>`),YB=L("<!> <!> <!>",1),R9=L(`<div class="setting-item-description">No sorting: newest-first prepends the new section above existing ones;
oldest-first appends it below.</div>`),N9=L(`<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>`),L9=L(`<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),V9=L("<!> <!> <!> <!> <!>",1);function WD(r,e){pe(e,!0);let t=ne(e,"insertAfter",15);t().inline===void 0&&t(t().inline=!1,!0),t().replaceExisting===void 0&&t(t().replaceExisting=!1,!0),t().promptHeading===void 0&&t(t().promptHeading=!1,!0),t().insertAtEnd===void 0&&t(t().insertAtEnd=!1,!0),t().considerSubsections===void 0&&t(t().considerSubsections=!1,!0),t().blankLineAfterMatchMode||t(t().blankLineAfterMatchMode="auto",!0),t().createIfNotFound||t(t().createIfNotFound=!1,!0),t().createIfNotFoundLocation||t(t().createIfNotFoundLocation=no,!0);let n=[O=>new Sn(e.app,O,e.plugin,"lineTarget")],i=[{value:"auto",label:"Auto (headings only)"},{value:"skip",label:"Always skip"},{value:"none",label:"Never skip"}],o=F(()=>t().inline?[{value:no,label:"Top"},{value:nd,label:"Bottom"},{value:id,label:"Cursor"}]:[{value:no,label:"Top"},{value:nd,label:"Bottom"},{value:id,label:"Cursor"},{value:vs,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=Ce(!!t().orderBy),u=F(()=>t().createIfNotFoundLocation===vs),d=F(()=>t().createIfNotFound&&h(u)),p=F(()=>new jf(e.app,e.plugin)),f=Ce(!1);Yt(()=>{let O=t().after??"",H=h(p);if(!t().inline||O===""){j(f,!1);return}let ce=!1;return H.format(O).then(te=>{ce||j(f,/[\n\r]/.test(te),!0)}).catch(()=>{ce||j(f,!1)}),()=>{ce=!0}});let m=F(()=>t().orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"}),g=F(()=>/\{\{V?DATE\b/i.test(t().after??"")),v=F(()=>h(d)&&t().orderBy?.by==="insertion"&&h(g)&&!zD(t().after??""));Yt(()=>{if(!h(d))return;let O=zD(t().after??"");if(!t().orderBy){t(t().orderBy={by:O?"date":"insertion",direction:"desc",dateFormat:O,unparseable:"bottom"},!0);return}!h(c)&&(t().orderBy.by==="insertion"||t().orderBy.by==="date")&&(t(t().orderBy.by=O?"date":"insertion",!0),t(t().orderBy.dateFormat=O,!0))});function y(O){t(t().createIfNotFoundLocation=O,!0),O===vs?t(t().inline=!1,!0):(t(t().orderBy=void 0,!0),j(c,!1))}function b(O){j(c,!0),t().orderBy&&t(t().orderBy.by=O,!0)}function x(O){t().promptHeading||O&&!t().after.startsWith("#")&&(t(t().considerSubsections=!1,!0),new KB.Notice("Consider subsections requires the target to be a heading (starts with #)"))}function w(O){O&&(t(t().inline=!1,!0),t(t().replaceExisting=!1,!0))}var T=V9(),C=Te(T);Se(C,{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:H=>{St(H,{onchange:w,get checked(){return t().promptHeading},set checked(ce){t(t().promptHeading=ce,!0)}})},$$slots:{control:!0}});var S=_(C,2);{var A=O=>{var H=$9();M(O,H)},D=O=>{var H=YB(),ce=Te(H);Ti(ce,{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:(xe,ue=Ct)=>{var be=GB(),Ke=Te(be);sn(Ke,{get id(){return ue()},placeholder:"Insert after",required:!0,requiredMessage:"Insert after text is required",get makeSuggesters(){return n},get value(){return t().after},set value(Ee){t(t().after=Ee,!0)}});var Oe=_(Ke,2);fo(Oe,{get value(){return t().after},formatterKind:"lineTarget",get app(){return e.app},get plugin(){return e.plugin}}),M(xe,be)},$$slots:{default:!0}});var te=_(ce,2);{let ie=ue=>{St(ue,{get disabled(){return h(u)},get checked(){return t().inline},set checked(be){t(t().inline=be,!0)}})},xe=F(()=>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).");Se(te,{name:"Inline insertion",get desc(){return h
for Canvas card capture. Use top, bottom, insert-after, or insert-before
placement.</div>`),U9=L("<!> <!> <!> <!> <!>",1);function KD(r,e){pe(e,!0);let t=ne(e,"choice",15),n=F(()=>!!t().captureToActiveFile),i=F(()=>t().propertyCapture?"property":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=F(()=>[{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"},{value:"property",label:"Property"}]);function s(b){if(b==="property"){t().propertyCapture??t(t().propertyCapture={property:{kind:"named",format:""},action:"set",createIfMissing:!0},!0);return}if(delete t().propertyCapture,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),b==="top"){h(n)||t(t().prepend=!1,!0);return}if(b==="activeTop"){h(n)&&t(t().activeFileWritePosition="top",!0);return}if(b==="bottom"){h(n)?t(t().activeFileWritePosition="bottom",!0):t(t().prepend=!0,!0);return}if(b==="newLineAbove"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="above",!0);return}if(b==="newLineBelow"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="below",!0);return}if(b==="before"){t(t().insertBefore.enabled=!0,!0);return}t(t().insertAfter.enabled=!0,!0)}let a=F(()=>{if(t().propertyCapture)return!1;let b=typeof t().captureTo=="string"&&gc(t().captureTo),x=e.app.workspace.getActiveViewOfType(QB.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)?!x:!b))});var l=U9(),c=Te(l);{let b=w=>{ft(w,{get value(){return h(i)},get options(){return h(o)},onchange:s})},x=F(()=>h(n)?"Where to place the capture in the current file.":"Where to place the capture in the target file.");Se(c,{name:"Write position",get desc(){return h(x)},control:b,$$slots:{control:!0}})}var u=_(c,2);{var d=b=>{YD(b,{get app(){return e.app},get plugin(){return e.plugin},get config(){return t().propertyCapture},set config(x){t(t().propertyCapture=x,!0)}})};Y(u,b=>{t().propertyCapture&&b(d)})}var p=_(u,2);{var f=b=>{WD(b,{get app(){return e.app},get plugin(){return e.plugin},get insertAfter(){return t().insertAfter},set insertAfter(x){t(t().insertAfter=x,!0)}})};Y(p,b=>{!t().propertyCapture&&t().insertAfter.enabled&&b(f)})}var m=_(p,2);{var g=b=>{GD(b,{get app(){return e.app},get plugin(){return e.plugin},get insertBefore(){return t().insertBefore},set insertBefore(x){t(t().insertBefore=x,!0)}})};Y(m,b=>{!t().propertyCapture&&t().insertBefore?.enabled&&b(g)})}var v=_(m,2);{var y=b=>{var x=q9();M(b,x)};Y(v,b=>{h(a)&&b(y)})}M(r,l),fe()}var H9=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","ali
was changed by the error. Include the message below if you report this.</p> <!></div>`),Q9={hash:"svelte-bhgeqn",code:".qaMountFailed.svelte-bhgeqn {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;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:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaMountFailedDetail.svelte-bhgeqn {margin:10px 0 0;padding:8px 10px;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 XD(r,e){We(r,Q9);let t=ne(e,"detail",3,"");var n=K9(),i=B(n),o=B(i);Et(o,{iconId:"alert-triangle",size:16});var s=_(o,2),a=le(s);N(i);var l=_(i,4);{var c=u=>{var d=Y9(),p=le(d,!0);re(()=>ae(p,t())),M(u,d)};Y(l,u=>{t()&&u(c)})}N(n),re(()=>ae(a,`QuickAdd couldn't display ${e.what??""}`)),M(r,n)}var X9="this part of QuickAdd";function Li(r,e,t,n={}){let i=new Set(r.childNodes),o;try{o=Zu(e,{target:r,props:t})}catch(a){return Z9(r,i,nl(a),n)}let s=!1;return{ok:!0,destroy(){s||(s=!0,jp(o))}}}function Z9(r,e,t,n){let i=n.what??X9;for(let l of Array.from(r.childNodes))e.has(l)||l.remove();Ze(t,`Couldn't display ${i}`);let o=r.createDiv({cls:"qa-mount-failed-host"}),s=null;try{s=Zu(n.fallbackComponent??XD,{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&&jp(s),o.remove())}}}function gE(r,e){if(r.containerEl.addClass("qa-choice-builder"),r.modalEl.querySelector(".qa-builder-footer"))return;let t=r.modalEl.createDiv({cls:"qa-builder-footer"});t.createSpan({cls:"qa-builder-footer-note",text:`Changes to this ${e} are saved automatically`}),t.createEl("button",{type:"button",cls:"mod-cta",text:"Done"}).addEventListener("click",()=>r.close())}var Jf=class extends JB.Modal{constructor(t){super(t);this.svelteElements=[];this.waitForClose=new Promise(n=>{this.resolvePromise=n}),this.containerEl.addClass("quickAddModal"),gE(this,"choice"),this.open()}mountForm(t,n,i){let o=Li(this.contentEl,t,n,{what:i});return this.svelteElements.push(o),o.ok?n:void 0}destroySvelteElements(){this.svelteElements.forEach(t=>t.destroy()),this.svelteElements=[]}getResultChoice(){return this.choice}onClose(){super.onClose(),this.destroySvelteElements(),this.resolvePromise(Xc(this.getResultChoice()))}};var em=class extends Jf{constructor(t,n,i){super(t);this.plugin=i;this.choice=n,this.normalizeChoice(),this.display()}normalizeChoice(){this.choice.insertBefore||(this.choice.insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:no}),this.choice.activeFileWritePosition||(this.choice.activeFileWritePosition="cursor"),this.choice.createFileIfItDoesntExist||(this.choice.createFileIfItDoesntExist={enabled:!1,createWithTemplate:!1,template:""}),!this.choice.captureToActiveFile&&!gc(this.choice.captureTo)&&(this.choice.captureToCanvasNodeId=""),this.choice.openFile&&(this.choice.fileOpening=Cn(this.choice.fileOpening))}display(){this.containerEl.addClass("captureChoiceBuilder"),this.formProps=this.mountForm(QD,ZB({choice:this.choice,app:this.app,plugin:this.plugin}),"this capture choice's settings")}getResultChoice(){return this.formProps?.choice??this.choice}};Dl();Ie();ht();Kg();ks();var bE=class extends xr{constructor(t,n,i,o){super(t,n);this.app=t;this.inputEl=n;this.suggestItems=i;this.currentItems=o}updateCurrentItems(t){this.currentItems=t}getSuggestions(t){return this.suggestItems.filter(n=>n.contains(t))}selectSuggestion(t){this.inputEl.value=t,this.inputEl.trigger("input"),this.close()}renderSuggestion(t,n){t&&n.setText(t)}};var jq=require("obsidian");function dq(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOw
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pZ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ud(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=uF(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(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,a;return{s:function(){t=t.call(r)},n:function(){var l=t.next();return o=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!o&&t.return!=null&&t.return()}finally{if(s)throw a}}}}var fZ="finalize",mZ="consider";function lm(r,e,t){r.dispatchEvent(new CustomEvent(fZ,{detail:{items:e,info:t}}))}function ru(r,e,t){r.dispatchEvent(new CustomEvent(mZ,{detail:{items:e,info:t}}))}var DE="draggedEntered",Ly="draggedLeft",FE="draggedOverIndex",dF="draggedLeftDocument",EE={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function hZ(r,e,t){r.dispatchEvent(new CustomEvent(DE,{detail:{indexObj:e,draggedEl:t}}))}function gZ(r,e,t){r.dispatchEvent(new CustomEvent(Ly,{detail:{draggedEl:e,type:EE.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function vZ(r,e){r.dispatchEvent(new CustomEvent(Ly,{detail:{draggedEl:e,type:EE.OUTSIDE_OF_ANY}}))}function yZ(r,e,t){r.dispatchEvent(new CustomEvent(FE,{detail:{indexObj:e,draggedEl:t}}))}function bZ(r){window.dispatchEvent(new CustomEvent(dF,{detail:{draggedEl:r}}))}var jn={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:DE,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:FE,DRAGGED_LEFT:Ly,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},Fn={POINTER:"pointer",KEYBOARD:"keyboard"},wZ={space:[" "],enter:["Enter"],space_or_enter:[" ","Enter"]},Eq="space_or_enter",CZ={space:"space-bar",enter:"enter",space_or_enter:"space-bar or enter"},dm="isDndShadowItem",PE="data-is-dnd-shadow-item-internal",xZ="data-is-dnd-shadow-item-hint",Vy="id:dnd-shadow-placeholder-0000",EZ="dnd-action-dragged-el",gr="id",rF=0;function Tq(){rF++}function kq(){if(rF===0)throw new Error("Bug! trying to decrement when there are no dropzones");rF--}var pF=typeof window>"u",st=function(){};function nF(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t,n=e?_Z(r):r.getBoundingClientRect(),i=getComputedStyle(r),o=i.transform;if(o){var s,a,l,c;if(o.startsWith("matrix3d("))t=o.slice(9,-1).split(/, /),s=+t[0],a=+t[5],l=+t[12],c=+t[13];else if(o.startsWith("matrix("))t=o.slice(7,-1).split(/, /),s=+t[0],a=+t[3],l=+t[4],c=+t[5];else return n;var u=i.transformOrigin,d=n.left-l-(1-s)*parseFloat(u),p=n.top-c-(1-a)*parseFloat(u.slice(u.indexOf(" ")+1)),f=s?n.width/s:r.offsetWidth,m=a?n.height/a:r.offsetHeight;return{x:d,y:p,width:f,height:m,top:p,right:d+f,bottom:p+m,left:d}}else return n}function iF(r){var e=nF(r);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function TZ(r){var e=r.getBoundingClientRect();return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function Sq(r){return{x:(r.left+r.right)/2,y:(r.top+r.bottom)/2}}function kZ(r,e){return Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2))}function $y(r,e){return r.y<=e.bottom&&r.y>=e.top&&r.x>=e.left&&r.x<=e.right}function _q(r){return Sq(TZ(r))}function pq(r,e){var t=_q(e);return kZ(r,t)}function SZ(r){var e=r.ownerDocument,t=e.defaultView||window,n=r.getBoundingClientRect(),i=n.top+t.scrollY,o=n.left+t.scrollX;return n.right+t.scrollX<0||o>e.documentElement.scrollWidth||n.bottom+t.scrollY<0||i>e.documentElement.scrollHeight}function _Z(r){for(var e=r.getBoundingClientRect(),t={top:e.top,bottom:e.bottom,left:e.left,right:e.right},n=!1,i=!1,o=r.parentElement;o&&o!==document.body;){var s=window.getComputedStyle(o),a=s.overflowY,l=s.overflowX,c=a==="scroll"||a==="auto",u=l==="scroll"||l==="auto";if(c||u){var d=o.getBoundingClientRect();if(c){var p=Math.max(t.top,d.top),f=Math.min(t.bottom,d.bottom);(p!==t.top||f!==t.bottom)&&(n=!0),t.top=p,t.bottom=f}if(u){var m=Math.max(t.left,d.left),g=Math.min(t.right,d.right);(m!==t.left||g!==t.right)&&(i=!0),t.left=m,t.right=g}}o=o.parentElement}return n||i?{top:t.top,bottom:t.bottom,left:t.left,right:t.right,width:Math.max(0,t.right-t.left),height:M
file's folder (or you'll be prompted to pick one if no file is open).</div>`),FJ=L('<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),PJ=L("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1);function wF(r,e){pe(e,!0);let t=ne(e,"choice",15),n=F(()=>e.plugin.getTemplateFiles().map(ge=>ge.path)),i=F(()=>Il(Vo(e.app)));function o(ge){let ve=ge.trim();return ve?cl(ve)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:Vn(e.app,ve)!==null||"Template not found":!0}let s=[ge=>new Sn(e.app,ge,e.plugin,"fileName")],a=F(()=>yF(t(),t().fileNameFormat.enabled?t().fileNameFormat.format:Or)),l=F(()=>h(a)?"Show matching notes and unresolved links in the note-title prompt.":"Only available when the file name prompt is the default note title: no custom format, {{VALUE}}, or {{NAME}}."),c=F(()=>Gq(t().folder)),u=F(()=>Qq[h(c)]),d=F(()=>h(c)==="specified"&&t().folder.folders.length===0);function p(ge){t(t().folder=Yq(t().folder,ge),!0)}let f=Ce(""),m;function g(ge){return m=new bE(e.app,ge,h(i),t().folder.folders),m}Yt(()=>{m?.updateCurrentItems(t().folder.folders)});function v(){let ge=h(f).trim();if(ge){if(t().folder.folders.some(ve=>ve===ge)){I.logWarning("cannot add same folder twice.");return}t().folder.folders.push(ge),j(f,"")}}function y(ge){ge.key==="Enter"&&v()}let b=F(()=>sq(t().fileExistsBehavior)),x=F(()=>h(b)!=="prompt"&&h(b)!=="keep"),w=F(()=>nq(h(b)==="update"?"update":"create")),T=F(()=>t().fileExistsBehavior.kind==="apply"?t().fileExistsBehavior.mode:h(w)[0].id);function C(ge){t(t().fileExistsBehavior=aq(ge,t().fileExistsBehavior),!0)}function S(ge){t(t().fileExistsBehavior={kind:"apply",mode:ge},!0)}var A=PJ(),D=Te(A);kv(D,{get app(){return e.app},get name(){return t().name},set name(ge){t(t().name=ge,!0)}});var P=_(D,2);Se(P,{name:"Template",heading:!0});var U=_(P,2);Ti(U,{name:"Template path",desc:"Path to the template this choice creates notes from.",children:(ve,Fe=Ct)=>{sn(ve,{get id(){return Fe()},get value(){return t().templatePath},placeholder:"Template path",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,validator:o,onChange:Je=>t(t().templatePath=Je.trim(),!0)})},$$slots:{default:!0}});var K=_(U,2);Ti(K,{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:Fe=>{St(Fe,{get checked(){return t().fileNameFormat.enabled},set checked(Je){t(t().fileNameFormat.enabled=Je,!0)}})},children:(Fe,Je=Ct)=>{var mt=IJ(),Ft=Te(mt);sn(Ft,{get id(){return Je()},placeholder:"File name format",get makeSuggesters(){return s},get value(){return t().fileNameFormat.format},set value(rr){t(t().fileNameFormat.format=rr,!0)}});var Qe=_(Ft,2);Vd(Qe,{get value(){return t().fileNameFormat.format}});var zt=_(Qe,2);{let rr=F(()=>RE(t().folder));fo(zt,{get value(){return t().fileNameFormat.format},formatterKind:"fileName",get targetFolderPath(){return h(rr)},get app(){return e.app},get plugin(){return e.plugin}})}M(Fe,mt)},$$slots:{control:!0,default:!0}});var W=_(K,2);Se(W,{name:"Location",heading:!0});var ee=_(W,2);Se(ee,{name:"New note location",get desc(){return h(u)},control:ve=>{ft(ve,{get value(){return h(c)},get options(){return Kq},ariaLabel:"New note location",onchange:p})},$$slots:{control:!0}});var me=_(ee,2);{var O=ge=>{var ve=FJ(),Fe=Te(ve),Je=B(Fe),mt=B(Je);vF(mt,{get folders(){return t().folder.folders},onChange:Z=>t(t().folder.folders=Z,!0)}),N(Je);var Ft=_(Je,2),Qe=B(Ft);Rt(Qe),$r(()=>wi(Qe,()=>h(f),Z=>j(f,Z))),Jt(Qe,(Z,De)=>Sd?.(Z,De),()=>g);var zt=_(Qe,2);N(Ft),N(Fe);var rr=_(Fe,2);{var Qn=Z=>{var De=DJ();M(Z,De)};Y(rr,Z=>{h(d)&&Z(Qn)})}var di=_(rr,2);Se(di,{name:"Include subfolders",desc:"Get prompted to choose from both the selected folders and their subfolders when creating the note.",control:De=>{St(
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>`),Cee={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;}"};function JF(r,e){We(r,Cee);var t=wee(),n=B(t),i=B(n);Et(i,{iconId:"alert-triangle",size:16});var o=_(i,2),s=le(o);N(n),Gr(4),N(t),re(()=>ae(s,`QuickAdd couldn't read ${e.what??""}`)),M(r,t)}var Lm=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=sr(e.commands),this.commandsRef=SF(e.commands).commands,this.choices=e.choices,this.onCommandsChange=e.onCommandsChange,this.conditionalHandlers=e.conditionalHandlers,this.loadObsidianCommands(),this.loadScriptCandidates()}render(e){return this.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){let t=e.createDiv("commandList");this.unreadableCardHandle=Li(t,JF,{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=>{let t=this.app.commands.commands[e];this.obsidianCommands.push(new Gy(t.name,t.id))})}loadScriptCandidates(){this.scriptCandidates=sT(this.app)}renderCommandList(e){let t=e.createDiv("commandList");return this.commandListProps=SU({app:this.app,plugin:this.plugin,commands:this.commandsRef,deleteCommand:async n=>{let i=this.commandsRef.find(a=>a.id===n);if(!i)throw I.logError("command not found"),new Error("command not found");if(!await Si.Prompt(this.app,"Are you sure you wish to delete this command?",`If you click yes, you will delete '${i.name}'.`))return;if(!await jE(this.app,i)){new Hi.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=Li(t,VF,this.commandListProps,{what:"this macro's commands"}),this.commandListHandle.ok}renderCommandBar(e){let t=e.createDiv("quickCommandContainer");this.addChoiceButton(t,"Capture",Rm),this.addChoiceButton(t,"Template",ou),this.addCommandButton(t,"file-search","Add open file command",()=>new cT),this.addCommandButton(t,"clock","Add wait command",()=>new nT(100)),this.addCommandButton(t,"git-branch","Add conditional command",()=>new uT),X.getState().disableOnlineFeatures||this.addCommandButton(t,"bot","Add AI Assistant command",()=>new lT)}renderAddObsidianCommandSetting(e){let t,n=()=>{let i=t.getValue(),o=this.obsidianCommands.find(a=>a.name===i);if(!o){I.logError(`Could not find Obsidian command with name "${i}"`);return}let s=new Gy(o.name,o.commandId);s.generateId(),this.addCommand(s),t.setValue("")};new Hi.Setting(e).setName("Obsidian command").setDesc("Add an Obsidian command").addText(i=>{t=this.configureSuggestedInput(i,"Obsidian command",this.obsidianCommands.map(o=>o.name),n)}).addButton(i=>i.setCta().s
/* The chevron sits tighter to the label than the leading plus. */.qaNewChoiceBtn.svelte-a7rp4h svg: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
nested folders. */.qaAddChoiceControls.compact.svelte-a7rp4h {gap:1rem;}.qaAddChoiceControls.compact.svelte-a7rp4h button:where(.svelte-a7rp4h) {font-size:var(--font-ui-smaller);padding:2px 0;gap:0.25em;background:transparent;border:none;box-shadow:none;color:var(--text-muted);}.qaAddChoiceControls.compact.svelte-a7rp4h button:where(.svelte-a7rp4h):hover {color:var(--text-accent);text-decoration:underline;}
/* 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-a7rp4h button: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). */
@media (max-width: 800px) {.qaAddChoiceControls.svelte-a7rp4h:not(.compact):not(.fill) {flex-direction:column;align-items:stretch;}
}`};function zm(r,e){pe(e,!0),We(r,tte);let t=ne(e,"targetFolderId",3,void 0),n=ne(e,"targetFolderName",3,void 0),i=ne(e,"compact",3,!1),o=ne(e,"fill",3,!1),s=Ce(!1);function a(P){let U=new oH.Menu;for(let W of nH)U.addItem(ee=>ee.setTitle(`${W.label} \u2014 ${W.description}`).setIcon(W.iconId).onClick(me=>{let O=me.altKey===!0;e.onAddChoice(DT(W.type),W.type,t(),O)}));j(s,!0),U.onHide(()=>{j(s,!1)});let K=P.target?.closest("button");if(K){let W=K.getBoundingClientRect();U.showAtPosition({x:W.left,y:W.bottom+4})}else U.showAtMouseEvent(P)}function l(){e.onAddChoice(DT("Multi"),"Multi",t(),!0)}let c=F(()=>i()?"Add choice":"New choice"),u=F(()=>i()?"Add folder":"New folder"),d=F(()=>n()?`Add choice to ${n()}`:h(c)),p=F(()=>n()?`Add folder to ${n()}`:h(u));var f=ete();let m;var g=B(f),v=B(g);Et(v,{iconId:"folder-plus",size:14});var y=_(v,2),b=le(y,!0);N(g);var x=_(g,2);let w;var T=B(x);Et(T,{iconId:"plus",size:14});var C=_(T,2),S=le(C,!0),A=_(C,2);{var D=P=>{Et(P,{iconId:"chevron-down",size:12})};Y(A,P=>{i()||P(D)})}N(x),N(f),re(()=>{m=it(f,1,"qaAddChoiceControls svelte-a7rp4h",null,m,{compact:i(),fill:o()&&!i()}),ke(g,"aria-label",h(p)),ke(g,"title",i()?h(p):void 0),ae(b,h(u)),w=it(x,1,"qaNewChoiceBtn svelte-a7rp4h",null,w,{"mod-cta":!i()}),ke(x,"aria-expanded",h(s)),ke(x,"aria-label",h(d)),ke(x,"title",i()?h(d):void 0),ae(S,h(c))}),Ae("click",g,l),Ae("click",x,a),M(r,f),fe()}nt(["click"]);var rte=L('<div class="rightButtonsContainer svelte-1es4f02"><!> <!> <!> <!> <!> <!></div>'),nte={hash:"svelte-1es4f02",code:`.rightButtonsContainer.svelte-1es4f02 {display:flex;align-items:center;
/* Icons carry their own 3px padding inside the choice rows (24px hit
boxes), so a tight gap keeps the cluster compact without touching. */gap:2px;flex:0 0 auto;}`};function tb(r,e){pe(e,!0),We(r,nte);let t=ne(e,"showConfigureButton",3,!0),n=ne(e,"showDuplicateButton",3,!0),i=ne(e,"commandEnabled",3,!1),o=ne(e,"choiceName",3,"");var s=rte(),a=B(s);{var l=v=>{{let y=F(()=>`Configure${o()?" "+o():""}`);Lt(v,{iconId:"settings",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onConfigureChoice}})}};Y(a,v=>{t()&&v(l)})}var c=_(a,2);{var u=v=>{{let y=F(()=>`Duplicate${o()?" "+o():""}`);Lt(v,{iconId:"copy",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDuplicateChoice}})}};Y(c,v=>{n()&&v(u)})}var d=_(c,2);{let v=F(()=>`Delete${o()?" "+o():""}`);Lt(d,{iconId:"trash-2",get label(){return h(v)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDeleteChoice}})}var p=_(d,2);{var f=v=>{{let y=F(()=>`More options${o()?" for "+o():""}`);Lt(v,{iconId:"more-vertical",ariaHasPopup:"menu",get label(){return h(y)},onclick:b=>e.onOpenMenu?.(b.currentTarget)})}};Y(p,v=>{e.onOpenMenu&&v(f)})}var m=_(p,2);{let v=F(()=>`Command palette${o()?": "+o():""}`);Lt(m,{iconId:"zap",get ariaPressed(){return i()},get label(){return h(v)},extraClass:"qa-row-secondary-action",get onclick(){return e.onToggleCommand}})}var g=_(m,2);{let v=F(()=>`Reorder${o()?" "+o():""}`);cn(g,{get label(){return h(v)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.onDragHandleDown},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}N(s),M(r,s),fe()}var $T=require("obsidian");var sH=require("obsidian");bt();var uP="quickadd:move-to-root";function ite(r,e){let t=Lr(e);if(t.some(i=>Ue(i)&&i.id===r.id))return!1;let n=i=>{for(let o of i){if(!Ue(o))continue;let s=et(o);if(s.some(a=>a?.id===r.id)||n(s))return!0}return!1};return n(t)}function ote(r,e){let t=[],n=Array.isArray(e)?e:[],i=(o,s=[])=>{for(let a of o){if(!Ue(a))continue;let l=a.name??"";if(a.type==="Multi"){let c=[...s,l];ste(r,a)||t.push({id:a.id,path:c.join(" / ")}),i(et(a),[...s,l])}}};return i(n,[]),t}function ste(r,e){if(e.type!=="Multi"||r.id===e.id||jo(e))return!0;if(r.type==="Multi"){let t=new Set,n=i=>{Ue(i)&&(t.add(i.id),et(i).forEach(n))};if(et(r).forEach(n),t.has(e.id))return!0}return!1}function aH(r,e,t,n){let i=new sH.Menu;i.addItem(s=>s.setTitle(e.command?"Disable in command palette":"Enable in command palette").setIcon("zap").onClick(n.onToggle)).addItem(s=>s.setTitle("Rename").setIcon("pencil").onClick(n.onRename)).addItem(s=>s.setTitle("Configure").setIcon("settings").onClick(n.onConfigure)).addItem(s=>s.setTitle("Duplicate").setIcon("copy").onClick(n.onDuplicate)).addItem(s=>s.setTitle("Delete").setIcon("trash-2").onClick(n.onDelete)).addSeparator(),ite(e,t)&&i.addItem(s=>s.setTitle("Move to: (root)").setIcon("folder-up").onClick(()=>n.onMove(uP)));let o=ote(e,t);return o.length===0?i.addItem(s=>s.setTitle("Move to: (no folders)").setDisabled(!0).setIcon("folder")):o.forEach(s=>i.addItem(a=>a.setTitle(`Move to: ${s.path}`).setIcon("folder-open").onClick(()=>n.onMove(s.id)))),i}function FT(r,e,t,n,i){e.preventDefault(),aH(r,t,n,i).showAtMouseEvent(e)}function PT(r,e,t,n,i){let o=e.getBoundingClientRect();aH(r,t,n,i).showAtPosition({x:o.left,y:o.bottom})}var lH=require("obsidian");function MT(r,e,t,n){e.replaceChildren(),lH.MarkdownRenderer.render(n,r,e,"/",t)}bt();var ate=L('<div class="choiceListItem"><span class="qaChoiceRowIcon" aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></div>'),lte={hash:"svelte-1aljzaf",code:""};function dP(r,e){pe(e,!0),We(r,lte);let t=!0,n=Ce(void 0),i=new $T.Component;Yt(()=>{h(n)&&MT(e.choice.name,h(n),i,e.app)}),Yt(()=>()=>i.unload());let o=()=>({onRename:()=>e.actions.onRenameChoice(e.choice),onToggle:()=>e.actions.onToggleCommand(e.choice),onConfigure:()=>e.actions.onConfigureChoice(e.choice),onDuplicate:()=>e.actions.onDuplicateChoice(e.choice),onDelete:()=>e.actions.onDeleteChoice(e.choice),onMove:f=>e.actions.onMoveChoice(e.choice,f)});function s(f){FT(e.app,f,e.choice,e.
in <code class="svelte-1jxjn06">data.json</code>.</p>`),dte=L('<div class="nestedAddRow svelte-1jxjn06"><!></div>'),pte=L("<!> <!>",1),fte=L('<div class="nestedChoiceList svelte-1jxjn06"><!></div>'),mte=L('<div><div class="multiChoiceListItem"><button type="button" class="multiChoiceListItemName svelte-1jxjn06"><span aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></button> <!></div> <!></div>'),hte={hash:"svelte-1jxjn06",code:`
/* Row surface (min-height, padding, radius, hover, rhythm) is shared with
leaf rows and lives in styles.css \u2014 see "Choice list rows". Only the
folder-specific pieces stay here. */
/* Base icon = chevron-down (expanded); collapsed rotates to point RIGHT,
matching Obsidian's own collapse grammar (file explorer, outline). */.multiChoiceCollapseIcon.svelte-1jxjn06 {transition:transform 150ms ease;}.multiChoiceCollapseIcon.is-collapsed.svelte-1jxjn06 {transform:rotate(-90deg);}
@media (prefers-reduced-motion: reduce) {.multiChoiceCollapseIcon.svelte-1jxjn06 {transition:none;}
}
/* 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:1 1 auto;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:0 1 auto;}
/* 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:6px 8px 8px;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.4;}.qaUnreadableFolder.svelte-1jxjn06 code:where(.svelte-1jxjn06) {font-size:inherit;}.qaFolderCount.svelte-1jxjn06 {flex:0 0 auto;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:2px solid var(--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
child rows' padding, one tight step (4px) below the last child. */.nestedAddRow.svelte-1jxjn06 {margin:2px 0 4px 0;padding:0 8px;}`};function pP(r,e){pe(e,!0),We(r,hte);let t=ne(e,"choice",7),n=ne(e,"forceDragDisabled",3,!1),i=F(()=>et(t())),o=F(()=>jo(t())),s=!0,a=Ce(void 0),l=new OT.Component;Yt(()=>{h(a)&&MT(t().name,h(a),l,e.app)}),Yt(()=>()=>l.unload());let c=()=>({onRename:()=>e.actions.onRenameChoice(t()),onToggle:()=>e.actions.onToggleCommand(t()),onConfigure:()=>e.actions.onConfigureChoice(t()),onDuplicate:()=>e.actions.onDuplicateChoice(t()),onDelete:()=>e.actions.onDeleteChoice(t()),onMove:P=>e.actions.onMoveChoice(t(),P)});function u(P){FT(e.app,P,t(),e.roots,c())}function d(P){PT(e.app,P,t(),e.roots,c())}let p={...kt(()=>e.actions),onReorderChoices:P=>{t().choices=P,e.actions.onCommitFolder(t().id,P)}};function f(){n()||e.actions.onToggleCollapsed(t())}var m=mte(),g=B(m),v=B(g),y=B(v);let b;var x=B(y);Et(x,{iconId:"chevron-down",size:16}),N(y);var w=_(y,2);Ci(w,P=>j(a,P),()=>h(a));var T=_(w,2);{var C=P=>{var U=cte(),K=le(U,!0);re(()=>ae(K,h(i).length)),M(P,U)};Y(T,P=>{t().collapsed&&h(i).length>0&&P(C)})}N(v),Jt(v,P=>OE?.(P));var S=_(v,2);tb(S,{get onDragHandleDown(){return e.startDrag},onDeleteChoice:()=>e.actions.onDeleteChoice(t()),onConfigureChoice:()=>e.actions.onConfigureChoice(t()),onToggleCommand:()=>e.actions.onToggleCommand(t()),onDuplicateChoice:()=>e.actions.onDuplicateChoice(t()),onOpenMenu:d,get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown},showConfigureButton:s,get dragDisabled(){return e.dragDisabled},get choiceName(){return t().name},get commandEnabled(){return t().command},showDuplicateButton:!0}),N(g);var A=_(g,2);{var D=P=>{var U=or(),K=Te(U);{var W=ee=>{var me=fte(),O=B(me);{var H=te=>{var z=ute();M(te,z)},ce=te=>{var z=pte(),G=Te(z);{let ue=F(()=>h(i).length===0),be=F(()=>e.rootReorder??e.actions.onReorderChoices);Wm(G,{get app(){return e.app},get roots(){return e.roots},get choices(){return h(i)},nested:!0,get isEmptyFolder(){return h(ue)},get forceDragDisabled(){return n()},get rootReorder(){return h(be)},get actions(){return p}})}var ie=_(G,2);{var xe=ue=>{var be=dte(),Ke=B(be);zm(Ke,{compact:!0,get targetFolderId(){return t().id},get targetFolderName(){return t().name},get onAddChoice(){return e.actions.onAddChoice}}),N(be),M(ue,be)};Y(ie,ue=>{n()||ue(xe)})}M(te,z)};Y(O,te=>{h(o)?te(H):te(ce,-1)})}N(me),M(ee,me)};Y(K,ee=>{t().collapsed||ee(W)})}M(P,U)};Y(A,P=>{(!e.collapseId||e.collapseId&&t().id!==e.collapseId)&&P(D)})}N(m),re(()=>{ke(g,"data-choice-id",t().id),ke(v,"aria-expanded",!t().collapsed),ke(v,"aria-label",`Toggle ${t().name}`),b=it(y,1,"qaChoiceRowIcon multiChoiceCollapseIcon svelte-1jxjn06",null,b,{"is-collapsed":t().collapsed})}),Ae("contextmenu",g,u),Ae("click",g,P=>{OT.Platform.isMobile||P.target.closest("button, a")||f()}),Ae("click",v,f),M(r,m),fe()}nt(["contextmenu","click"]);function cH(r){let e=r-1;return e*e*e+1}function uH(r,{from:e,to:t},n={}){var{delay:i=0,duration:o=C=>Math.sqrt(C)*120,easing:s=cH}=n,a=getComputedStyle(r),l=a.transform==="none"?"":a.transform,[c,u]=a.transformOrigin.split(" ").map(parseFloat);c/=r.clientWidth,u/=r.clientHeight;var d=gte(r),p=r.clientWidth/t.width/d,f=r.clientHeight/t.height/d,m=e.left+e.width*c,g=e.top+e.height*u,v=t.left+t.width*c,y=t.top+t.height*u,b=(m-v)*p,x=(g-y)*f,w=e.width/t.width,T=e.height/t.height;return{delay:i,duration:typeof o=="function"?o(Math.sqrt(b*b+x*x)):o,easing:s,css:(C,S)=>{var A=S*b,D=S*x,P=C+S*w,U=C+S*T;return`transform: ${l} translate(${A}px, ${D}px) scale(${P}, ${U});`}}}function gte(r){if("currentCSSZoom"in r)return r.currentCSSZoom;for(var e=r,t=1;e!==null;)t*=+getComputedStyle(e).zoom,e=e.parentElement;return t}var dH=require("obsidian");bt();var vte=L("<div><!></div>"),yte=L("<div></div>"),bte={hash:"svelte-2ry05y",code:`.choiceList.svelte-2ry05y {width:auto;}
/* 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-color 120ms ease;}
/* 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:-4px 0 -4px -6px;border-radius:var(--radius-m);border:2px dashed transparent;pointer-events:none;transition:border-color 120ms ease;}.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;}
@media (prefers-reduced-motion: reduce) {.choiceList.qa-nested.svelte-2ry05y,
.choiceList.qa-nested.svelte-2ry05y::before {transition:none;}
}`};function Wm(r,e){pe(e,!0),We(r,bte);let t=ne(e,"choices",31,()=>ut([])),n=ne(e,"forceDragDisabled",3,!1),i=ne(e,"isEmptyFolder",3,!1),o=ne(e,"nested",3,!1),s=F(()=>{let T=new Set;return Lr(t()).filter(C=>{if(!Ue(C))return!1;let S=C.id;return typeof S!="string"||S===""||T.has(S)?!1:(T.add(S),!0)})}),a=F(()=>e.rootReorder??e.actions.onReorderChoices),l=0,c=dH.Platform.isMobile,u=Ce(""),d=gm(),p=F(()=>n()||!c&&!d.armed),f=Ce(void 0),m=null;function g(T){if(n())return;d.markStarted();let C=T.detail.items;m=fm(C,T.detail.info.id)??m,j(u,T.detail.info.id,!0),t(qi(C))}function v(T){if(n())return;j(u,"");let C=qi(T.detail.items),S=T.detail.info.id;T.detail.info.trigger===jn.DROPPED_INTO_ANOTHER?C=C.filter(A=>A.id!==S):m?.item.id===S&&!C.some(A=>A.id===S)&&(C=[...C],C.splice(Math.min(m.index,C.length),0,m.item)),m=null,t(C),d.reset(),e.actions.onReorderChoices(t())}let y=()=>{n()||d.startDrag()};function b(T,C){if(n())return;let S=document.activeElement?.getAttribute("aria-label"),A=qi(h(s)),D=mm(A,T.id,C);if(!D)return;let P=D.findIndex(U=>U.id===T.id);t(D),e.actions.onReorderChoices(t()),Hd(`Moved ${T.name} to position ${P+1} of ${D.length}`),S&&vm(h(f),S)}var x=yte();let w;Ot(x,29,()=>qi(h(s)),T=>T.id,(T,C)=>{var S=vte(),A=B(S);{var D=U=>{{let K=F(()=>e.roots??t()),W=F(()=>n()?void 0:()=>b(h(C),-1)),ee=F(()=>n()?void 0:()=>b(h(C),1));dP(U,{get app(){return e.app},get roots(){return h(K)},get dragDisabled(){return h(p)},startDrag:y,get actions(){return e.actions},get choice(){return h(C)},get onMoveUp(){return h(W)},get onMoveDown(){return h(ee)}})}},P=U=>{{let K=F(()=>e.roots??t()),W=F(()=>n()?void 0:()=>b(h(C),-1)),ee=F(()=>n()?void 0:()=>b(h(C),1));pP(U,{get app(){return e.app},get roots(){return h(K)},get dragDisabled(){return h(p)},startDrag:y,get actions(){return e.actions},get collapseId(){return h(u)},get forceDragDisabled(){return n()},get rootReorder(){return h(a)},get choice(){return h(C)},get onMoveUp(){return h(W)},get onMoveDown(){return h(ee)}})}};Y(A,U=>{h(C).type!=="Multi"?U(D):U(P,-1)})}N(S),sA(S,()=>uH,()=>({duration:l})),M(T,S)}),N(x),Ci(x,T=>j(f,T),()=>h(f)),Jt(x,(T,C)=>pm?.(T,C),()=>hm({items:h(s),dragDisabled:h(p),flipDurationMs:l,dropTargetClasses:o()?["qa-folder-droptarget"]:[]})),re(()=>w=it(x,1,"choiceList svelte-2ry05y",null,w,{"qa-nested":o(),"qa-folder-empty":i(),"qa-empty":h(s).length===0})),Po("consider",x,g),Po("finalize",x,v),M(r,x),fe()}var wte=L('<pre class="qaChoicesUnavailableDetail svelte-1fs8ikt"> </pre>'),Cte=L(`<div class="qaChoicesUnavailable svelte-1fs8ikt"><div class="qaChoicesUnavailableHead svelte-1fs8ikt"><!> <span class="qaChoicesUnavailableTitle svelte-1fs8ikt"> </span></div> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">Something in this vault's QuickAdd settings could not be read. Your choices
have not been changed or deleted, and QuickAdd will not overwrite them.</p> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">They are stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this vault. Make a
copy of that file before editing it.</p> <!></div>`),xte={hash:"svelte-1fs8ikt",code:".qaChoicesUnavailable.svelte-1fs8ikt {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaChoicesUnavailableHead.svelte-1fs8ikt {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaChoicesUnavailableTitle.svelte-1fs8ikt {font-weight:var(--font-semibold);color:var(--text-normal);}.qaChoicesUnavailableBody.svelte-1fs8ikt {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaChoicesUnavailableDetail.svelte-1fs8ikt {margin:10px 0 0;padding:8px 10px;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 jm(r,e){We(r,xte);let t=ne(e,"what",3,"your choices"),n=ne(e,"detail",3,"");var i=Cte(),o=B(i),s=B(o);Et(s,{iconId:"alert-triangle",size:16});var a=_(s,2),l=le(a);N(o);var c=_(o,6);{var u=d=>{var p=wte(),f=le(p,!0);re(()=>ae(f,n())),M(d,p)};Y(c,d=>{n()&&d(u)})}N(i),re(()=>ae(l,`QuickAdd couldn't display ${t()??""}`)),M(r,i)}xt();var gH=require("obsidian");Ie();xt();var mH=require("obsidian");bt();Ie();bt();var fP=new WeakMap;function pH(r){let e=fP.get(r);if(e)return e;let t=i1(r);return fP.set(r,t),t}function fH(r){return fP.has(r)}function mP(r,e){if(!Array.isArray(r))return r;let t=fH(r),{choices:n,repaired:i}=pH(r);if(t)return n;for(let{choice:o}of i)if(o.command)try{e.enableCommand(o)}catch(s){I.logError(`Could not register a command for the repaired choice "${o.name}": ${s instanceof Error?s.message:String(s)}`)}return n}function hH(r,e){let t=e.trim();if(!t)return r;let n=(0,mH.prepareFuzzySearch)(t),i=o=>{if(!Ue(o))return null;let s=!!n(o.name??"");if(o.type!=="Multi")return s?o:null;let a=et(o).map(l=>i(l)).filter(l=>l!==null);return s||a.length>0?{...o,collapsed:!1,choices:a}:null};return r.map(o=>i(o)).filter(o=>o!==null)}function hP(r){return Ue(r)?r.command?!0:et(r).some(hP):!1}function rb(r,e){if(!Ue(r))return r;if(r.id===e.id)return{...r,...e};if(ml(r)){let t=et(r).map(i=>rb(i,e));return{...r,choices:t}}return r}function vH(r){function e(){r.saveChoices(Xc(r.choices))}async function t(g,v,y,b=!1){let x=iH(v,r.choices),w=rP(v,x);if(r.choices=UU(r.choices,w,y),!y&&r.filterQuery.trim().length>0&&(r.filterQuery=""),e(),v==="Multi")await a(w);else if(!b)try{await s(w)}catch(T){I.logError(`Failed to configure the new choice: ${T instanceof Error?T.message:String(T)}`),e()}await n(w.id)}async function n(g){await ac();try{document.querySelector(`[data-choice-id="${g}"]`)?.scrollIntoView({block:"nearest"})}catch{}}function i(g){return Qy(r.choices,g.id)??g}async function o(g){let v=i(g);await NU(v,r.app)&&(r.choices=Xy(r.choices,g.id).updated,r.commandRegistry.disableCommand(v,{recursive:!0}),e())}async function s(g){let v=i(g),y=await LU(v,r.app,r.plugin);y&&(r.choices=r.choices.map(b=>rb(b,y)),r.commandRegistry.updateCommand(v,y),e())}async function a(g){if(!g)return;let v=await wx(r.app,g.name,g.type);if(!v)return;let y=i(g),b={...y,name:v};r.choices=r.choices.map(x=>rb(x,b)),r.commandRegistry.updateCommand(y,b),e()}function l(g){let v=VU(i(g));r.choices=r.choices.map(y=>rb(y,v)),v.command?r.commandRegistry.enableCommand(v):r.commandRegistry.disableCommand(v),e()}async function c(g){let v=await OU(i(g),r.app);r.choices=oP(r.choices,g.id,v)??[...r.choices,v],hP(v)&&r.commandRegistry.enableCommand(v),e(),new gH.Notice(`Duplicated "${g.name}".`),await n(v.id)}function u(g,v){r.choices=v===uP?qU(r.choices,g.id):BU(r.choices,g.id,v),e()}function d(g){r.choices=g,e()}function p(g,v){r.choices=HU(r.choices,g,v),e()}function f(g){r.choices=aP(r.choices,g.id,!g.collapsed),e()}function m(g,v){return(y,...b)=>{let x=Ef(y?.type),w=y?.name?`the ${x} \u201C${y.name}\u201D`:`that ${x}`;ld(`Couldn't ${g} ${w}`,v)(y,...b)}}return{onDeleteChoice:m("delete",o),onConfigureChoice:m("open the settings for",s),onToggleComman
text, or run a macro. Group them with folders. <a class="quickadd-docs-link" target="_blank" rel="noopener noreferrer">Learn more</a></p> <div class="choiceEmptyActions svelte-1r4uuo1"><!></div></div>`),Tte=L('<button class="search-input-clear-button qaFilterClearButton svelte-1r4uuo1" aria-label="Clear filter"></button>'),kte=L('<div class="choiceFilterEmpty svelte-1r4uuo1">No choices match your filter.</div>'),Ste=L('<button type="button" class="qaAIAssistantBtn clickable-icon svelte-1r4uuo1" aria-label="Configure AI Assistant" title="Configure AI Assistant"><!></button>'),_te=L('<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),Ate=L("<div><!></div>"),Ite={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:0 0 auto;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.5rem 1rem;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:12px 8px 16px;}`};function gP(r,e){pe(e,!0),We(r,Ite);let t=ne(e,"choices",31,()=>ut([])),n=Ce(""),i=F(()=>!Array.isArray(t())),o=F(()=>`The "choices" value in data.json is ${t()===null?"null":`of type "${typeof t()}"`}, but QuickAdd expects a list.`),s=yH.Platform.isMobile,a=Ce(ut(X.getState().disableOnlineFeatures)),l=new yT(kt(()=>e.plugin));t(mP(t(),l)),Yt(()=>{let g=X.subscribe(v=>{t(mP(v.choices,l)),j(a,v.disableOnlineFeatures,!0)});return()=>g()});let c=vH({get app(){return e.app},get plugin(){return e.plugin},get choices(){return t()},set choices(g){t(g)},get filterQuery(){return h(n)},set filterQuery(g){j(n,g,!0)},commandRegistry:l,saveChoices:g=>e.saveChoices(g)}),u=ld("Couldn't open the AI assistant settings",async()=>{let g=await new IT(e.app,X.getState().ai).waitForClose;g&&X.setState(v=>({...v,ai:g}))});var d=Ate(),p=B(d);{var f=g=>{jm(g,{get detail(){return h(o)}})},m=g=>{var v=or(),y=Te(v);hg(y,{onerror:x=>I.logError(`QuickAdd could not render the choice list: ${x instanceof Error?x.message:String(x)}`),failed:(x,w=Ct)=>{{let T=F(()=>w()instanceof Error?w().message:String(w()));jm(x,{get detail(){return h(T)}})}}},x=>{var w=or(),T=Te(w);{var C=D=>{var P=Ete(),U=B(P);Et(U,{iconId:"folder-plus",size:28});var K=_(U,4),W=_(B(K));N(K);var ee=_(K,2),me=B(ee);zm(me,{get onAddChoice(){return c.onAddChoice}}),N(ee),N(P),re(()=>ke(W,"href",Ms.gettingStarted)),M(D,P)},S=F(()=>t().length===0&&h(n).trim().length===0),A=D=>{var P=_te(),U=Te(P),K=B(U),W=B(K);Rt(W),ke(W,"spellcheck",!1);var ee=_(W,2);{var me=ue=>{var be=Tte();Ae("click",be,()=>j(n,"")),M(ue,be)};Y(ee,ue=>{h(n)&&ue(me)})}N(K),N(U);var O=_(U,2);{var H=ue=>{Wm(ue,{get app(){return e.app},get roots(){return t()},get actions(){return c},get choices(){return t()},set choices(be){t(be)}})},ce=F(()=>h(n).trim().length===0),te=ue=>{let be=F(()=>hH(t(),h(n)));var Ke=or(),Oe=Te(Ke);{var Ee=Le=>{var At=kte();M(Le,At)},He=Le=>{Wm(Le,{get app(){return e.app},get roots(){return t()},get choices(){return h(be)},forceDragDisabled:!0,get actions(){return c}})};Y(Oe,Le=>{h(be).length===0?Le(Ee):Le(He,-1)})}M(ue,Ke)};Y(O,ue=>{h(ce)?ue(H):ue(te,-1)})}var z=_(O,2),G=B(z);{var ie=ue=>{var be=Ste(),Ke=B(be);Et(Ke,{iconId:"sparkles",size:16}),N(be),Ae("click",be,u),M(ue,be)};Y(G,ue=>{h(a)||ue(ie)})}var xe=_(G,2);zm(xe,{get onAddChoice(){return c.onAddChoice},get fill(){return s}}),N(z),Ae("keydown",W,ue=>{ue.key==="Escape"&&h(n)&&(j(n,""),ue.stopPropagation())}),wi(W,()=>h(n),ue=>j(n,ue)),M(D,P)};Y(T,D=>{h(S)?D(C):D(A,-1)})}M(x,w)}),M(g,v)};Y(p,g=>{h(i)?g(f):g(m,-1)})}N(d),M(r,d),fe()}nt(["keydown","click"]);dt();var Dte=L('<div class="qa-gv__empty svelte-hx6w4t">No global variables yet.</div>'),Fte=L('<div class="qa-gv__row qa-gv__row--head svelte-hx6w4t"><div class="qa-gv__cell qa-gv__name">Name</div> <div class="qa-gv__cell qa-gv__value">Value</div> <div class="qa-gv__cell qa-gv__ops svelte-hx6w4t">Actions</div></div>'),Pte=L('<div class="qa-gv__row svelte-hx6w4t"><div class="qa-gv__cell qa-gv__name svelte-hx6w4t"><input type="text" placeholder="Name" class="svelte-hx6w4t"/></div> <div class="qa-gv__cell qa-gv__value svelte-hx6w4t"><textarea rows="2" placeholder="Snippet value (supports QuickAdd tokens)" class="svelte-hx6w4t"></textarea></div> <div class="qa-gv__cell qa-gv__ops svelte-hx6w4t"><button class="qa-gv__btn danger svelte-hx6w4t" title="Delete">Delete</button></div></div>'),Mte=L('<div class="qa-gv svelte-hx6w4t"><div class="qa-gv__desc svelte-hx6w4t">Define reusable snippets referenced as <code>&#123;&#123;GLOBAL_VAR:&lt;name&gt;&#125;&#125;</code>. Snippets support other QuickAdd tokens and expand before VALUE/VDATE/etc.</div> <div class="qa-gv__table svelte-hx6w4t"><!> <!></div> <div class="qa-gv__actions svelte-hx6w4t"><button class="mod-cta">Add variable</but
/* Keeps "Add variable" right-aligned now that it is the row's only child. */.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:6px 0;}.qa-gv__table.svelte-hx6w4t {display:grid;gap:8px;}.qa-gv__row.svelte-hx6w4t {display:grid;grid-template-columns:180px 1fr 140px;gap:8px;align-items:start;}.qa-gv__row--head.svelte-hx6w4t {font-weight:600;color:var(--text-muted);}.qa-gv__cell.svelte-hx6w4t input[type="text"]:where(.svelte-hx6w4t) {width:100%;}.qa-gv__cell.svelte-hx6w4t textarea: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:4px 8px;}.qa-gv__btn.danger.svelte-hx6w4t {color:var(--text-error);}
@media (max-width: 900px) {.qa-gv__row.svelte-hx6w4t {grid-template-columns:1fr;}.qa-gv__row--head.svelte-hx6w4t {display:none;}
}`};function vP(r,e){pe(e,!0),We(r,$te);let t=Ce(ut([]));function n(w,T){if(!T.has(w))return w;let C=1;for(;T.has(`${w}${C}`);)C++;return`${w}${C}`}function i(){let T=X.getState().globalVariables||{};j(t,Object.keys(T).map(C=>({name:C,value:T[C]??""})),!0)}let o=!1;function s(){let w=h(t).map(A=>A.name.trim()),T=w.some(A=>!A),C=new Set(w).size!==w.length;if(T||C)return;let S={};for(let A of h(t))S[A.name.trim()]=A.value??"";o=!0;try{X.setState({globalVariables:S})}finally{o=!1}}function a(){let w=new Set(h(t).map(C=>C.name)),T=n("NewVar",w);j(t,[...h(t),{name:T,value:""}],!0),s()}function l(w){j(t,h(t).filter((T,C)=>C!==w),!0),s()}function c(w){return new Sn(e.app,w,e.plugin),{destroy(){}}}let u;function d(w){u!==void 0&&window.clearTimeout(u),u=window.setTimeout(()=>{s()},200)}Yt(()=>{let w=X.subscribe(()=>{o||i()});return i(),()=>{u!==void 0&&window.clearTimeout(u),w()}});var p=Mte(),f=_(B(p),2),m=B(f);{var g=w=>{var T=Dte();M(w,T)},v=w=>{var T=Fte();M(w,T)};Y(m,w=>{h(t).length===0?w(g):w(v,-1)})}var y=_(m,2);Ot(y,17,()=>h(t),xg,(w,T,C)=>{var S=Pte(),A=B(S),D=B(A);Rt(D),Jt(D,ee=>c?.(ee)),$r(()=>wi(D,()=>h(T).name,ee=>h(T).name=ee)),N(A);var P=_(A,2),U=B(P);Nu(U),Jt(U,ee=>c?.(ee)),$r(()=>wi(U,()=>h(T).value,ee=>h(T).value=ee)),N(P);var K=_(P,2),W=le(K);N(S),Ae("input",D,()=>{d(h(T))}),Ae("input",U,()=>d(h(T))),Ae("click",W,()=>l(h(t).indexOf(h(T)))),M(w,S)}),N(f);var b=_(f,2),x=le(b);N(p),Ae("click",x,a),M(r,p),fe()}nt(["input","click"]);dt();ht();var LH=require("obsidian");bt();un();vr();var Ote=new Set;function bH(r){return r.type==="Multi"}function wH(r){return r.type==="Macro"}function Rte(r){return r.type==="Template"}function Nte(r){return r.type==="Capture"}function yP(r,e,t){return r?e.has(r.id)?t.has(r.id):!0:!1}function Lte(r,e,t,n){switch(r.type){case"Choice":{let i=r;if(!t.has(i.choiceId))return!0;let o=e.get(i.choiceId);return o&&yP(o.choice,e,t)&&n(o.choice),!0}case"NestedChoice":{let i=r;return i.choice&&yP(i.choice,e,t)&&n(i.choice),!0}default:return!1}}function Vte(r){let e=new Map,t=(n,i,o)=>{for(let s of n){if(!Ue(s))continue;let a=[...o,s.name];e.set(s.id,{choice:s,parentId:i,path:a}),bH(s)&&Array.isArray(s.choices)&&t(s.choices,s.id,a)}};return t(Lr(r),null,[]),e}function CH(r){let e=new Set;for(let t of et(r))Ue(t)&&e.add(t.id);return wH(r)&&bP(r.macro?.commands,e),e}function bP(r,e){for(let t of Ht(r))if(qr(t))switch(t.type){case"Choice":{let n=t;n.choiceId&&e.add(n.choiceId);break}case"Conditional":{let n=t;bP(n.thenCommands,e),bP(n.elseCommands,e);break}case"NestedChoice":{let i=t.choice;if(!i)break;let o=CH(i);for(let s of o)e.add(s);break}default:break}}function RT(r,e,t){let n=Vte(r),i=new Set,o=new Set,s=t?.excludedChoiceIds??Ote,a=e.filter(c=>!s.has(c)),l=[];for(;a.length>0;){let c=a.shift();if(i.has(c))continue;if(s.has(c)){i.add(c);continue}let u=n.get(c);if(!u){o.add(c);continue}i.add(c),l.push(c);let d=CH(u.choice);for(let p of d){if(!n.has(p)){o.add(p);continue}s.has(p)||a.push(p)}}return{catalog:n,choiceIds:l,missingChoiceIds:Array.from(o)}}function xH(r,e,t,n){let i=new Set(e),o=new Set,s=l=>{!l||!yP(l,r,i)||o.has(l.id)||(o.add(l.id),t(l),bH(l)&&Array.isArray(l.choices)&&l.choices.forEach(s),wH(l)&&a(l.macro?.commands))},a=l=>{for(let c of Ht(l))if(qr(c)&&!Lte(c,r,i,s)&&(n(c),c.type==="Conditional")){let u=c;a(u.thenCommands),a(u.elseCommands)}};for(let l of e){let c=r.get(l);c&&s(c.choice)}}function NT(r,e){let t=new Set,n=new Set;return xH(r,e,()=>{},i=>{if(i.type==="UserScript"){let o=i;o.path&&t.add(o.path)}else if(i.type==="Conditional"){let{condition:o}=i;o.mode==="script"&&o.scriptPath&&n.add(o.scriptPath)}}),{userScriptPaths:t,conditionalScriptPaths:n}}function LT(r,e){let t=new Set,n=new Set;return xH(r,e,i=>{if(Rte(i)&&i.templatePath&&t.add(i.templatePath),Nte(i)){let o=i.createFileIfItDoesntExist;o?.enabled&&o.createWithTemplate&&o.template&&n.add(o.template)}},()=>{}),{templatePaths:t,captureTemplatePaths:n}}function EH(r,e){let t=e.trim().toLowerCase();return t?r.filter(n=>`${n.path.join(" ")} ${n.choice.type}`.toLowerCase().includes(t)):r}function TH(r,e){let t=[];fo
/* Neutral surface with an amber-tinted border (these are warnings, not
critical danger): ranked, not a blanket-red fill \u2014 matches the import
modal's CapabilityBanner treatment. */.warning.svelte-llmxn2 {border:1px solid var(--qa-sev-warning-border);background:var(--background-secondary);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;color:var(--text-normal);}.warning.svelte-llmxn2 ul:where(.svelte-llmxn2) {margin:0.25rem 0 0 1rem;padding:0;}.assetKind.svelte-llmxn2 {color:var(--text-muted);}.actions.svelte-llmxn2 {display:flex;flex-direction:column;gap:1rem;}.actionGroup.svelte-llmxn2 {display:flex;flex-direction:column;gap:0.5rem;}.saveRow.svelte-llmxn2 {display:flex;gap:0.5rem;}.saveRow.svelte-llmxn2 input:where(.svelte-llmxn2) {flex:1;}.footer.svelte-llmxn2 {display:flex;justify-content:flex-end;gap:0.5rem;margin-top:0.5rem;}.footer.svelte-llmxn2 button.secondary:where(.svelte-llmxn2) {background:transparent;}
@media (max-width: 600px) {.exportPackageModal.svelte-llmxn2 {max-height:90vh;padding-bottom:0.5rem;}.controls.svelte-llmxn2 {flex-direction:column;align-items:stretch;gap:0.5rem;}.controlButtons.svelte-llmxn2 {width:100%;flex-direction:column;gap:0.5rem;align-items:stretch;}.controlButtons.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.choiceList.svelte-llmxn2 {min-height:160px;max-height:40vh;}.summaryGrid.svelte-llmxn2 {grid-template-columns:1fr;}.actions.svelte-llmxn2 {gap:0.75rem;}.actionGroup.svelte-llmxn2 {align-items:stretch;}.actionGroup.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.saveRow.svelte-llmxn2 {flex-direction:column;}.saveRow.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.footer.svelte-llmxn2 {flex-direction:column-reverse;align-items:stretch;}.footer.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}
}`};function wP(r,e){pe(e,!0),We(r,rre);let t={"user-script":"User script","conditional-script":"Conditional script",template:"Template file","capture-template":"Capture template"},n=Ce(""),i=Ce(ut(new Set)),o=Ce(ut(new Set)),s=Ce(ut($H())),a=Ce(null),l=Ce(null),c=F(()=>av(e.allChoices)),u=F(()=>EH(h(c),h(n))),d=F(()=>TH(h(c),h(i))),p=F(()=>kH(e.allChoices,h(d),h(o))),f=F(()=>new Map(h(c).map(we=>[we.id,we.path.join(" / ")])));function m(we){return we.type==="Multi"}function g(we){let qe=[];for(let k of et(we))Ue(k)&&qe.push(k.id,...g(k));return qe}function v(we,qe){let k=[we.id,...g(we)],R=new Set(h(i)),q=new Set(h(o));for(let J of k)qe?(R.add(J),q.delete(J)):(R.delete(J),q.add(J));j(i,R,!0),(!qe||h(o).size>0)&&j(o,q,!0)}function y(we){let qe=h(c).find(R=>R.id===we);if(!qe)return;let k=h(i).has(we);v(qe.choice,!k),j(a,null)}function b(){for(let we of h(u))v(we.choice,!0);j(a,null)}function x(){j(i,new Set,!0),j(o,new Set,!0),j(a,null)}function w(we){let{missingChoiceIds:qe,missingAssets:k}=we;return qe.length===0&&k.length===0?null:{missingChoices:qe,missingAssets:k}}async function T(){if(h(d).length===0)return new Bs.Notice("Select at least one choice to export."),null;try{let we=await OH(e.app,{choices:e.allChoices,rootChoiceIds:h(d),excludedChoiceIds:Array.from(h(o)),quickAddVersion:e.plugin.manifest.version});return j(a,w(we),!0),we}catch(we){return console.error(we),j(a,null),new Bs.Notice(`Export failed: ${we?.message??String(we)}`),null}}async function C(){if(!h(l)){j(l,"copy");try{let we=await T();if(!we)return;let qe=JSON.stringify(we.pkg,null,2);await A(qe),new Bs.Notice(`Copied package (${we.pkg.choices.length} choice${we.pkg.choices.length===1?"":"s"}) to clipboard.`),h(a)?new Bs.Notice("Package copied with warnings. Review details below."):e.close()}catch(we){console.error(we),new Bs.Notice(`Copy failed: ${we?.message??String(we)}`)}finally{j(l,null)}}}async function S(){if(h(l))return;let we=h(s).trim();if(!we){new Bs.Notice("Enter a file path before saving.");return}j(l,"save");try{let qe=await T();if(!qe)return;let{overwritten:k}=await NH(e.app,qe.pkg,we),R=qe.pkg.choices.length,q=`${R} choice${R===1?"":"s"}`;new Bs.Notice(k?`Overwrote package (${q}) at '${we}'.`:`Saved package (${q}) to '${we}'.`),h(a)?new Bs.Notice("Package saved with warnings. Review details below."):e.close()}catch(qe){let k=qe?.message??String(qe);if(k.startsWith("Save cancelled:")){new Bs.Notice("Save cancelled.");return}console.error(qe),new Bs.Notice(`Save failed: ${k}`)}finally{j(l,null)}}async function A(we){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(we);return}let qe=document.body.createEl("textarea");qe.value=we,qe.setAttribute("readonly","true"),qe.style.position="fixed",qe.style.opacity="0",qe.focus(),qe.select();let k=document.execCommand("copy");if(document.body.removeChild(qe),!k)throw new Error("Clipboard copy is not supported in this environment.")}var D=tre(),P=_(B(D),2),U=B(P);Rt(U),ke(U,"spellcheck",!1);var K=_(U,2),W=B(K),ee=_(W,2);N(K),N(P);var me=_(P,2),O=B(me);{var H=we=>{var qe=jte();M(we,qe)},ce=we=>{var qe=Kte();Ot(qe,21,()=>h(u),k=>k.id,(k,R)=>{var q=Yte(),J=B(q),se=B(J);Rt(se);var oe=_(se,2),de=le(oe,!0),$e=_(oe,2);{var vt=Wr=>{var Wt=Gte(),Xn=le(Wt,!0);re(Gs=>ae(Xn,Gs),[()=>h(R).path.slice(0,-1).join(" \u203A ")]),M(Wr,Wt)};Y($e,Wr=>{h(R).path.length>1&&Wr(vt)})}var nr=_($e,2),lr=le(nr,!0);N(J),N(q),re((Wr,Wt)=>{Gp(q,`padding-left: ${h(R).depth*16}px`),ed(se,Wr),ae(de,Wt),ae(lr,h(R).choice.type)},[()=>h(i).has(h(R).id),()=>h(R).path.at(-1)]),Ae("change",se,()=>y(h(R).id)),M(k,q)}),N(qe),M(we,qe)};Y(O,we=>{h(u).length===0?we(H):we(ce,-1)})}N(me);var te=_(me,2),z=_(B(te),2),G=B(z),ie=B(G),xe=le(ie,!0);Gr(2),N(G);var ue=_(G,2),be=B(ue),Ke=le(be,!0);Gr(2),N(ue);var Oe=_(ue,2),Ee=B(Oe),He=le(Ee,!0);Gr(2),N(Oe);var Le=_(Oe,2),At=B(Le),mr=le(At,!0);Gr(2),N(Le);var zr=_(Le,2),ge=B(zr),ve=le(ge,!0);Gr(2),N(zr),N(z);var Fe=_(z,2);{var Je=we=>{var qe=Qte(),k=_(B(qe),2),R=le(k);N(qe),re(q=>ae(R,`The following choice IDs were referenced but not found:
${q??""}`),[()=>h(p).missingChoiceIds.join(", ")]),M(we,qe)};Y(Fe,we=>{h(p).missingChoiceIds.length>0&&we(Je)})}N(te);var mt=_(te,2);{var Ft=we=>{var qe=ere(),k=_(B(qe),2);{var R=se=>{var oe=Xte(),de=le(oe);re($e=>ae(de,`Missing choices:
${$e??""}`),[()=>h(a).missingChoices.map($e=>h(f).get($e)??$e).join(", ")]),M(se,oe)};Y(k,se=>{h(a).missingChoices.length>0&&se(R)})}var q=_(k,2);{var J=se=>{var oe=Jte(),de=_(B(oe),2);Ot(de,21,()=>h(a).missingAssets,$e=>$e.path,($e,vt)=>{var nr=Zte(),lr=B(nr),Wr=_(lr),Wt=le(Wr);N(nr),re(()=>{ae(lr,`${h(vt).path??""} `),ae(Wt,`(${t[h(vt).kind]??""})`)}),M($e,nr)}),N(de),N(oe),M(se,oe)};Y(q,se=>{h(a).missingAssets.length>0&&se(J)})}N(qe),M(we,qe)};Y(mt,we=>{h(a)&&we(Ft)})}var Qe=_(mt,2),zt=B(Qe),rr=B(zt),Qn=B(rr);{var di=we=>{var qe=ra("Copying\u2026");M(we,qe)},Z=we=>{var qe=ra("Copy JSON");M(we,qe)};Y(Qn,we=>{h(l)==="copy"?we(di):we(Z,-1)})}N(rr),N(zt);var De=_(zt,2),Pt=B(De),It=_(B(Pt),2),pi=B(It);Rt(pi);var Di=_(pi,2),Au=B(Di);{var wp=we=>{var qe=ra("Saving\u2026");M(we,qe)},Cp=we=>{var qe=ra("Save to file");M(we,qe)};Y(Au,we=>{h(l)==="save"?we(wp):we(Cp,-1)})}N(Di),N(It),N(Pt),N(De),N(Qe);var xp=_(Qe,2),Iu=le(xp);N(D),re(()=>{ae(xe,h(p).rootCount),ae(Ke,h(p).totalChoices),ae(He,h(p).dependencyCount),ae(mr,h(p).userScripts+h(p).conditionalScripts),ae(ve,h(p).templateFiles+h(p).captureTemplates),rr.disabled=h(l)!==null,Di.disabled=h(l)!==null,Iu.disabled=h(l)!==null}),wi(U,()=>h(n),we=>j(n,we)),Ae("click",W,b),Ae("click",ee,x),Ae("click",rr,C),wi(pi,()=>h(s),we=>j(s,we)),Ae("click",Di,S),Ae("click",Iu,function(...we){e.close?.apply(this,we)}),M(r,D),fe()}nt(["click","change"]);var HT=class extends LH.Modal{constructor(t,n,i){super(t);this.plugin=n;this.choices=i;this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageExportModal"),this.handle=Li(this.contentEl,wP,{app:this.app,plugin:this.plugin,allChoices:this.choices,close:()=>this.close()},{what:"the package exporter"})}onClose(){this.handle?.destroy(),this.handle=null}};var uz=require("obsidian");var ab=require("obsidian");dt();ht();var LP=require("obsidian");Ss();vr();vr();bt();un();function nre(r){return r.type==="Multi"}function ire(r){return r.type==="Macro"}function CP(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),nre(r))if(Array.isArray(r.choices))for(let n of r.choices)CP(n,e,t);else sr(r.choices)&&e.onUnreadable?.();ire(r)&&zT(Er(r.macro),e,t)}}}function zT(r,e,t){if(!Array.isArray(r)){sr(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))&&(zT(i.thenCommands,e,t),zT(i.elseCommands,e,t));let s=n,a=n.type==="NestedChoice"||s.choice&&typeof s.choice=="object"?s.choice:void 0;a&&CP(a,e,t)}}function xP(r,e){let t=new Set;if(Array.isArray(r.choices))for(let i of r.choices)CP(i,e,t);else e.onUnreadable?.();let n=r.macros;if(Array.isArray(n))for(let i of n)zT(Er(i),e,t);else sr(n)&&e.onUnreadable?.()}function Gm(r){let e=!1;return xP(r,{onUnreadable:()=>{e=!0}}),e}function Ym(r,e){xP(r.settings,{onChoice:e})}function WT(r,e){xP(r,{onCommand:e})}function ore(r){return r.type==="AIAssistant"}function jT(r,e,t){let n=0;return WT({choices:r},i=>{if(!ore(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}Ie();bt();Jr();la();TP();Ss();vr();bt();un();Ml();function GT(r,e,t,n){let i=r.id,o=e.get(i)??i;r.id=o;let s=o!==i;if(r.type==="Macro"){let a=r;s&&iu(a.macro)&&(a.macro.id=Kt()),kP(Er(a.macro),e,t,s,n)}if(r.type==="Multi"){let a=r;Array.isArray(a.choices)&&(a.choices=a.choices.filter(l=>Ue(l)&&t.has(l.id)).map(l=>GT(l,e,t,n)))}return r}function kP(r,e,t,n,i){for(let o of Ht(r))if(qr(o))switch(fU(o,i),n&&(o.id=Kt()),o.type){case"Choice":{let s=o,a=e.get(s.choiceId);a&&(s.choiceId=a);break}case"Conditional":{let s=o;kP(s.thenCommands,e,t,n,i),kP(s.elseCommands,e,t,n,i);break}case"NestedChoice":{let s=o;s.choice&&t.has(s.choice.id)&&(s.choice=GT(s.ch
`?(n>e&&(e=n),n=0,t++):n++;n>e&&(e=n);let i=r.length/t;return e>1e3||i>250}function QT(r,e){let t=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{let n=au(t.content),i=n.length>qH,o=i?n.slice(0,qH):n;return{found:!0,text:o,truncated:i,sizeBytes:xre(n),looksMinified:Ere(o)}}catch(n){return{found:!0,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:n instanceof Error?n.message:String(n)}}}function WH(r){return r.summary.hasCritical}function jH(r,e){return r.criticalScriptPaths.every(t=>e.has(t))}var GH=require("obsidian");un();vr();bt();function ib(r){let e;try{e=JSON.parse(r)}catch(o){throw new Error(`Package content is not valid JSON: ${o?.message??o}`)}if(!PH(e))throw new Error("Content is not a valid QuickAdd package.");if(e.schemaVersion>1)throw new Error(`Package schema version ${e.schemaVersion} is newer than this plugin supports (${1}).`);let t=Tre(e.assets);if(t!==null)throw new Error(`Package contains duplicate asset path "${t}". Each asset must have a unique path.`);let n=kre(e.choices);if(n!==null)throw new Error(`Package contains conflicting definitions for choice "${n}". Each choice id must describe the same choice everywhere it appears.`);let i=Sre(e.choices);if(i!==null)throw new Error(`Package choice "${i}" names a parent that does not list it as a child. Each parented choice must appear inside its parent.`);return e}function Tre(r){let e=new Set;for(let t of r){let n=(0,GH.normalizePath)(t.originalPath??"");if(e.has(n))return t.originalPath;e.add(n)}return null}function kre(r){let e=new Map,t=null,n=i=>{if(t!==null||!i||typeof i!="object")return;let o=i.id;if(typeof o=="string"){let s=NP(i),a=e.get(o);if(a===void 0)e.set(o,s);else if(a!==s){t=o;return}}if(i.type==="Multi"){let s=i;if(Array.isArray(s.choices))for(let a of s.choices)n(a)}i.type==="Macro"&&RP(Ht(Er(i.macro)),n)};for(let i of r){if(t!==null)break;n(i?.choice)}return t}function RP(r,e){if(Array.isArray(r)){for(let t of r)if(t){if(t.type==="NestedChoice")e(t.choice);else if(t.type==="Conditional"){let n=t;RP(n.thenCommands,e),RP(n.elseCommands,e)}}}}function NP(r){if(r===null||typeof r!="object"){let n=JSON.stringify(r);return n===void 0?"\0undefined":n}if(Array.isArray(r))return`[${r.map(NP).join(",")}]`;let e=r;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${NP(e[n])}`).join(",")}}`}function Sre(r){let e=new Map(r.map(t=>[t.choice.id,t]));for(let t of r){let n=t.parentChoiceId;if(n===null)continue;let i=e.get(n);if(!i)continue;let o=i.choice;if(!et(o).some(a=>a?.id===t.choice.id))return t.choice.id}return null}async function YH(r,e){if(Dr(e))throw new Error(`Refusing to read a package outside the vault: "${e}".`);let t=(0,LP.normalizePath)(e.trim());if(!t)throw new Error("Package path cannot be empty.");if(!await r.vault.adapter.exists(t))throw new Error(`Package file not found: ${t}`);let i=await r.vault.adapter.read(t);return{pkg:ib(i),path:t}}async function KH(r,e,t){let n=new Map(nn(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(let s of t.assets){let a=Dr(s.originalPath)?!1:await r.vault.adapter.exists(s.originalPath);o.push({originalPath:s.originalPath,exists:a,kind:s.kind})}return{choiceConflicts:i,assetConflicts:o}}async function XT(r,e,t){let n=new Set([...t.assets.map(a=>a.originalPath),...HH(t)]),i=new Set;await Promise.all(Array.from(n,async a=>{a&&(Dr(a)||await XH(r,a)&&i.add(a))}));let o=zH(e,t,i),{summary:s}=o;return I.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}function _re(r){let t=(r??"").trim();if(!t)throw new Error("Package asset has an empty destination path.");let n=
/* 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
(~8:1) beats white-on-amber (~2.9:1). Fallback #ff8c00 matches styles.css
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 sb(r,e){pe(e,!0),We(r,Dre);let t=F(()=>Qm(e.flag)),n=F(()=>FP(e.flag)),i=F(()=>PP(e.flag));var o=Ire();let s;var a=le(o,!0);Jt(o,(l,c)=>ob?.(l,c),()=>h(i)),re(()=>{s=it(o,1,"qa-import-tag svelte-5jkd35",null,s,{critical:h(t)==="critical",warning:h(t)==="warning",info:h(t)==="info"}),ae(a,h(n))}),M(r,o),fe()}var Fre=L('<span class="qa-import-banner-detail svelte-tb9yz"> </span>'),Pre=L('<li><span class="qa-import-banner-tag svelte-tb9yz"><!></span><span class="qa-import-banner-title svelte-tb9yz"> </span> <!></li>'),Mre=L('<p class="qa-import-banner-note svelte-tb9yz">Takes effect after you reload the plugin or restart Obsidian.</p>'),$re=L('<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>'),Ore={hash:"svelte-tb9yz",code:`.qa-import-banner.svelte-tb9yz {background:var(--background-secondary);border:1px solid var(--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-tb9yz h3: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-tb9yz li:where(.svelte-tb9yz) {display:block;padding:0.4rem 0.5rem;border-radius:var(--radius-s, 4px);}.qa-import-banner-tag.svelte-tb9yz {display:inline-block;vertical-align:middle;margin:0 0.4rem 0.15rem 0;}
/* 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-tb9yz li.sev-critical:where(.svelte-tb9yz) {background:var(--qa-sev-critical-wash);}.qa-import-banner-rows.svelte-tb9yz li.sev-warning:where(.svelte-tb9yz) {background:var(--qa-sev-warning-wash);}.qa-import-banner-rows.svelte-tb9yz li.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 VP(r,e){pe(e,!0),We(r,Ore);let t=F(()=>e.preview.summary.runsOnStartup||e.preview.summary.registersCommandCount>0);var n=$re();let i;var o=B(n),s=B(o),a=B(s);Et(a,{iconId:"alert-triangle",size:17}),N(s),Gr(2),N(o);var l=_(o,2);Ot(l,21,()=>e.preview.capabilityRows,d=>d.flag+d.detail,(d,p)=>{var f=Pre();let m;var g=B(f),v=B(g);sb(v,{get flag(){return h(p).flag}}),N(g);var y=_(g),b=le(y,!0),x=_(y,2);{var w=T=>{var C=Fre(),S=le(C,!0);re(()=>ae(S,h(p).detail)),M(T,C)};Y(x,T=>{h(p).detail&&T(w)})}N(f),re(()=>{m=it(f,1,"svelte-tb9yz",null,m,{"sev-critical":h(p).severity==="critical","sev-warning":h(p).severity==="warning","sev-info":h(p).severity==="info"}),ae(b,h(p).title)}),M(d,f)}),N(l);var c=_(l,2);{var u=d=>{var p=Mre();M(d,p)};Y(c,d=>{h(t)&&d(u)})}N(n),re(()=>i=it(n,1,"qa-import-banner svelte-tb9yz",null,i,{critical:e.preview.summary.hasCritical})),M(r,n),fe()}var Rre=L('<span class="qa-import-file-exec svelte-lmqem5">Executable</span>'),Nre=L('<span class="qa-import-file-reviewed svelte-lmqem5"><!> Reviewed</span>'),Lre=L('<span class="qa-import-file-orphan svelte-lmqem5">Unused</span>'),Vre=L("<option>Overwrite</option>"),Bre=L(`<p class="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>`),qre=L('<p class="qa-import-file-error svelte-lmqem5"> </p>'),Ure=L(`<p class="qa-import-file-warn svelte-lmqem5">Minified: cannot be visually reviewed. Import
only if you trust the source.</p>`),Hre=L('<p class="qa-import-file-warn svelte-lmqem5"> </p>'),zre=L('<!> <pre class="qa-import-file-code svelte-lmqem5" tabindex="0" role="region"> </pre> <!>',1),Wre=L('<div class="qa-import-file-preview svelte-lmqem5"><!></div>'),jre=L('<div><div class="qa-import-file-head svelte-lmqem5"><!> <span> </span> <span class="qa-import-file-arrow svelte-lmqem5" aria-hidden="true">\u2192</span> <span class="qa-import-file-dest svelte-lmqem5"> </span></div> <div class="qa-import-file-badges svelte-lmqem5"><!> <!> <!> <span class="qa-import-file-size svelte-lmqem5"> </span></div> <div class="qa-import-file-fields svelte-lmqem5"><label class="qa-import-file-field svelte-lmqem5"><span class="qa-import-file-field-name svelte-lmqem5">Destination</span> <input type="text" placeholder="vault/path/to/file" class="svelte-lmqem5"/></label> <label class="qa-import-file-field svelte-lmqem5"><span class="qa-import-file-field-name svelte-lmqem5">Action</span> <select class="dropdown svelte-lmqem5"><option>Write</option><!><option>Skip</option></select></label></div> <!> <button type="button" class="qa-import-file-toggle svelte-lmqem5"><span><!></span> <span> </span></button> <div><div class="qa-import-file-preview-inner svelte-lmqem5"><!></div></div></div>'),Gre={hash:"svelte-lmqem5",code:`.qa-import-file.svelte-lmqem5 {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;display:flex;flex-direction:column;gap:0.5rem;background:var(--background-secondary);}.qa-import-file.overwrite.svelte-lmqem5 {border-color:var(--qa-sev-critical-border);}.qa-import-file-head.svelte-lmqem5 {display:flex;align-items:center;gap:0.4rem;flex-wrap:wrap;}.qa-import-file-status.svelte-lmqem5 {font-size:0.78rem;font-weight:700;letter-spacing:0.01em;color:var(--text-muted);}.qa-import-file-status.overwrite.svelte-lmqem5 {color:var(--text-error);}.qa-import-file-arrow.svelte-lmqem5 {color:var(--text-muted);}.qa-import-file-dest.svelte-lmqem5 {font-family:var(--font-monospace);font-size:0.85rem;overflow-wrap:anywhere;}.qa-import-file-badges.svelte-lmqem5 {display:flex;flex-wrap:wrap;gap:0.35rem;align-items:center;}.qa-import-file-orphan.svelte-lmqem5 {display:inline-flex;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;background:var(--background-modifier-hover);
/* --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.05rem 0.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:1 1 auto;min-width:0;color:var(--text-normal);}.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5) {flex:0 1 300px;min-width:0;}.qa-import-file-field.svelte-lmqem5 select:where(.svelte-lmqem5) {flex:0 0 auto;}
/* The native Obsidian input/dropdown focus box-shadow handles focus; no
custom outline (which would read as non-native). */.qa-import-file-field.svelte-lmqem5 input: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.1rem 0.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:2px solid var(--interactive-accent);outline-offset:1px;}.qa-import-file-chevron.svelte-lmqem5 {display:inline-flex;transition:transform 180ms ease;}.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-rows 200ms ease;}.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.4rem 0.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.5rem 0.6rem;border-radius:var(--radius-s, 4px);background:var(--background-modifier-form-field);border:1px solid var(--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:2px solid var(--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-lmqem5 input:where(.svelte-lmqem5),
.qa-import-file-field.svelte-lmqem5 select:where(.svelte-lmqem5) {flex:1 1 100%;}.qa-import-file-size.svelte-lmqem5 {margin-left:0;}
}.is-mobile .qa-import-file-toggle.svelte-lmqem5 {min-height:36px;padding:0.4rem 0.3rem;}
@media (prefers-reduced-motion: reduce) {.qa-import-file-chevron.svelte-lmqem5,
.qa-import-file-preview-wrap.svelte-lmqem5 {transition:none;}
}`};function BP(r,e){pe(e,!0),We(r,Gre);let t=ne(e,"reviewed",3,!1),n=Ce(!1),i=F(()=>h(n)?QT(e.pkg,e.file.originalPath):null),o=F(()=>`qa-file-preview-${e.file.originalPath.replace(/[^a-zA-Z0-9_-]/g,"-")}`);function s(ve){return ve<1024?`${ve} B`:ve<1024*1024?`${(ve/1024).toFixed(1)} KB`:`${(ve/(1024*1024)).toFixed(1)} MB`}function a(){j(n,!h(n)),h(n)&&e.file.requiresReview&&e.onReviewed(e.file.originalPath)}function l(ve){e.onPathInput(ve.currentTarget.value)}function c(ve){e.onModeChange(ve.currentTarget.value)}var u=jre();let d;var p=B(u),f=B(p);{let ve=F(()=>e.destinationExists?"file-warning":"file-plus");Et(f,{get iconId(){return h(ve)},size:16})}var m=_(f,2);let g;var v=le(m,!0),y=_(m,4),b=le(y,!0);N(p);var x=_(p,2),w=B(x);{var T=ve=>{var Fe=Rre();Jt(Fe,(Je,mt)=>ob?.(Je,mt),()=>"Runs as code when its choice runs. It can read, change, or delete files in your vault and access the network."),M(ve,Fe)};Y(w,ve=>{e.file.executable&&ve(T)})}var C=_(w,2);{var S=ve=>{var Fe=Nre(),Je=B(Fe);Et(Je,{iconId:"check",size:12}),Gr(),N(Fe),M(ve,Fe)};Y(C,ve=>{t()&&e.mode!=="skip"&&e.file.requiresReview&&ve(S)})}var A=_(C,2);{var D=ve=>{var Fe=Lre();Jt(Fe,(Je,mt)=>ob?.(Je,mt),()=>"Bundled in this package but not referenced by any choice."),M(ve,Fe)};Y(A,ve=>{e.file.orphan&&ve(D)})}var P=_(A,2),U=le(P,!0);N(x);var K=_(x,2),W=B(K),ee=_(B(W),2);Rt(ee),N(W);var me=_(W,2),O=_(B(me),2),H=B(O);H.value=H.__value="write";var ce=_(H);{var te=ve=>{var Fe=Vre();Fe.value=Fe.__value="overwrite",M(ve,Fe)};Y(ce,ve=>{e.destinationExists&&ve(te)})}var z=_(ce);z.value=z.__value="skip",N(O);var G;dc(O),N(me),N(K);var ie=_(K,2);{var xe=ve=>{var Fe=Bre();M(ve,Fe)};Y(ie,ve=>{e.file.requiresReview&&e.mode==="skip"&&ve(xe)})}var ue=_(ie,2),be=B(ue);let Ke;var Oe=B(be);Et(Oe,{iconId:"chevron-right",size:14}),N(be);var Ee=_(be,2),He=le(Ee,!0);N(ue);var Le=_(ue,2);let At;var mr=B(Le),zr=B(mr);{var ge=ve=>{var Fe=Wre(),Je=B(Fe);{var mt=Qe=>{var zt=qre(),rr=le(zt);re(()=>ae(rr,`Preview unavailable: ${h(i).error??""}`)),M(Qe,zt)},Ft=Qe=>{var zt=zre(),rr=Te(zt);{var Qn=It=>{var pi=Ure();M(It,pi)};Y(rr,It=>{h(i).looksMinified&&It(Qn)})}var di=_(rr,2),Z=le(di,!0),De=_(di,2);{var Pt=It=>{var pi=Hre(),Di=le(pi);re(()=>ae(Di,`Preview truncated. The full ${e.file.executable?"script will run":"file will be imported"}.`)),M(It,pi)};Y(De,It=>{h(i).truncated&&It(Pt)})}re(()=>{ke(di,"aria-label",`Contents of ${e.file.originalPath??""}`),ae(Z,h(i).text)}),M(Qe,zt)};Y(Je,Qe=>{h(i).error?Qe(mt):Qe(Ft,-1)})}N(Fe),M(ve,Fe)};Y(zr,ve=>{h(i)&&ve(ge)})}N(mr),N(Le),N(u),re(ve=>{d=it(u,1,"qa-import-file svelte-lmqem5",null,d,{overwrite:e.destinationExists}),g=it(m,1,"qa-import-file-status svelte-lmqem5",null,g,{overwrite:e.destinationExists}),ae(v,e.destinationExists?"Will overwrite":"New file"),ae(b,e.destinationPath),ae(U,ve),bi(ee,e.destinationPath),ee.disabled=e.mode==="skip",G!==(G=e.mode)&&(O.value=(O.__value=G)??"",uc(O,G)),ke(ue,"aria-expanded",h(n)),ke(ue,"aria-controls",h(o)),Ke=it(be,1,"qa-import-file-chevron svelte-lmqem5",null,Ke,{open:h(n)}),ae(He,h(n)?"Hide contents":"View contents"),At=it(Le,1,"qa-import-file-preview-wrap svelte-lmqem5",null,At,{open:h(n)}),ke(Le,"id",h(o))},[()=>s(e.file.sizeBytes)]),Ae("input",ee,l),Ae("change",O,c),Ae("click",ue,a),M(r,u),fe()}nt(["input","change","click"]);var Yre=L('<p id="qa-import-ack-hint" class="ackGate-hint svelte-1n28r6s"> </p>'),Kre=L('<section><label class="ackGate-label svelte-1n28r6s"><input id="qa-import-ack-checkbox" type="checkbox" class="svelte-1n28r6s"/> <span> </span></label> <!></section>'),Qre={hash:"svelte-1n28r6s",code:".ackGate.svelte-1n28r6s {display:flex;flex-direction:column;gap:0.4rem;padding:0.75rem;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);background:var(--background-secondary);}.ackGate.critical.svelte-1n28r6s {border-color:var(--qa-sev-critical-border);}.ackGate-label.svelte-1n28r6s {display:flex;align-items:flex-start;gap:0.5rem;font-weight:600;cursor:pointer;}.ackGate-label.svelte-1n28r6s:has(input:where(.svelte-1n28r6s):disabled) {cursor:not-allowed;opacity
script${h(i)===1?"":"s"} above to enable this.`)),M(g,v)};Y(f,g=>{h(i)>0&&!e.fullyReviewed&&g(m)})}N(a),re(()=>{l=it(a,1,"ackGate svelte-1n28r6s",null,l,{critical:h(n)}),ed(u,t()),u.disabled=!e.fullyReviewed,ke(u,"aria-describedby",h(i)>0&&!e.fullyReviewed?"qa-import-ack-hint":void 0),ae(p,h(s))}),Ae("change",u,g=>t(g.currentTarget.checked)),M(r,a),fe()}nt(["change"]);var UP=require("obsidian");la();function ZH(r,e){return r==="skip"?r:e&&r==="write"?"overwrite":!e&&r==="overwrite"?"write":r}function HP(r,e){return!e&&r==="overwrite"?"import":r}function JH(r,e,t){let n=e(r),i=r.exists||t(n);return{mode:i?"overwrite":"write",destinationPath:n,destinationExists:i}}function ez(r,e){let t=e(r);return{mode:t?"overwrite":"write",destinationPath:r,destinationExists:t}}function tz(r,e,t){let n=new Map;for(let i of r)n.set(i.originalPath,JH(i,e,t));return n}function rz(r,e,t,n){return r.get(e.originalPath)??JH(e,t,n)}function nz(r){let e=new Map;for(let t of r)e.set(t.choiceId,t.exists?"overwrite":"import");return e}function iz(r,e,t){let n=new Map(r);return n.set(e,t),n}function oz(r,e,t,n){let i=r.get(e)??ez(e,n),o=new Map(r);return o.set(e,{...i,mode:t}),o}function sz(r,e,t,n){let i=r.get(e)??ez(e,n),o=t.trim(),s=o||e,a=o||t,l=n(s),c=new Map(r);return c.set(e,{...i,mode:ZH(i.mode,l),destinationPath:a,destinationExists:l}),{decisions:c,effectivePath:s}}function az(r,e,t){let n=r.get(e);if(!n||n.destinationExists===t)return r;let i=new Map(r);return i.set(e,{...n,destinationExists:t,mode:ZH(n.mode,t)}),i}function lz(r,e){return r.map(t=>({choiceId:t.choiceId,mode:HP(e.get(t.choiceId)??"import",t.exists)}))}function cz(r,e,t){return r.map(n=>{let i=e.get(n.originalPath),o=i?.destinationPath?.trim()||n.originalPath,s=i?.destinationExists??(n.exists||t(o)),a=i?.mode??(s?"overwrite":"write");return{originalPath:n.originalPath,destinationPath:o,mode:a}})}var JT=class{constructor(e){this.app=e;this.tokens=new Map}optimistic(e){let t=e.trim();return!t||Dr(t)?!1:!!this.app.vault.getAbstractFileByPath((0,UP.normalizePath)(t))}async resolve(e){let t=e.trim();if(!t||Dr(t))return!1;try{return await this.app.vault.adapter.exists((0,UP.normalizePath)(t))}catch{return!1}}schedule(e,t,n){let i=(this.tokens.get(e)??0)+1;this.tokens.set(e,i),this.resolve(t).then(o=>{this.tokens.get(e)===i&&n(o)})}};var Xre=L('<span class="macroCommandType svelte-1qj0pve"> </span>'),Zre=L("<code> </code>"),Jre=L('<span class="macroCommandSummary svelte-1qj0pve"> </span>'),ene=L('<li class="svelte-1qj0pve"><span class="macroCommandName svelte-1qj0pve"> </span> <!> <!></li>'),tne=L('<ul class="macroCommands svelte-1qj0pve"></ul>'),rne={hash:"svelte-1qj0pve",code:".macroCommands.svelte-1qj0pve {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}.macroCommands.svelte-1qj0pve li:where(.svelte-1qj0pve) {display:flex;flex-wrap:wrap;align-items:center;gap:0.4rem;font-size:var(--font-ui-smaller, 0.85rem);}.macroCommandName.svelte-1qj0pve {font-weight:500;}.macroCommandType.svelte-1qj0pve {color:var(--text-muted);font-size:0.72rem;}.macroCommandSummary.svelte-1qj0pve {color:var(--text-muted);}"};function zP(r,e){We(r,rne);let t={UserScript:"User script",Conditional:"Conditional",NestedChoice:"Nested choice",Obsidian:"Obsidian command",Choice:"Choice",Wait:"Wait",EditorCommand:"Editor command",AIAssistant:"AI assistant",OpenFile:"Open file"};function n(o){return t[o]??o}var i=tne();Ot(i,21,()=>e.commands,xg,(o,s)=>{var a=ene(),l=B(a),c=le(l,!0),u=_(l,2);{var d=v=>{sb(v,{get flag(){return h(s).flag}})},p=v=>{var y=Xre(),b=le(y,!0);re(x=>ae(b,x),[()=>n(h(s).type)]),M(v,y)};Y(u,v=>{h(s).flag?v(d):v(p,-1)})}var f=_(u,2);{var m=v=>{var y=Zre(),b=le(y,!0);re(()=>ae(b,h(s).scriptPath)),M(v,y)},g=v=>{var y=Jre(),b=le(y,!0);re(()=>ae(b,h(s).summary)),M(v,y)};Y(f,v=>{h(s).scriptPath?v(m):h(s).summary&&v(g,1)})}N(a),re(()=>{Gp(a,`padding-left:${h(s).depth*1}rem`),ae(c,h(s).name)}),M(o,a)}),N(i),M(r,i)}var nne=L('<p class="svelte-s0203k">No choices found in this package.</p>'),ine=L('<div class="choiceExists svelte-s0203k">already in vault</div>'),o
/* 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-s0203k {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-s0203k:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.macroToggle.svelte-s0203k:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.macroRow.svelte-s0203k td:where(.svelte-s0203k) {background:var(--background-primary-alt, var(--background-secondary));}.choicesSection.svelte-s0203k table:where(.svelte-s0203k) {width:100%;border-collapse:collapse;table-layout:fixed;}.choicesSection.svelte-s0203k col.colName:where(.svelte-s0203k) {width:52%;}.choicesSection.svelte-s0203k col.colLocation:where(.svelte-s0203k) {width:26%;}.choicesSection.svelte-s0203k col.colAction:where(.svelte-s0203k) {width:22%;}.choicesSection.svelte-s0203k th:where(.svelte-s0203k),
.choicesSection.svelte-s0203k td:where(.svelte-s0203k) {padding:0.5rem;border-bottom:1px solid var(--background-modifier-border);text-align:left;word-break:break-word;overflow-wrap:anywhere;white-space:normal;vertical-align:top;}.choicesSection.svelte-s0203k th:where(.svelte-s0203k) {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);font-weight:600;}.choiceExists.svelte-s0203k {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);margin-top:0.1rem;}.choicesSection.svelte-s0203k tbody:where(.svelte-s0203k) tr:where(.svelte-s0203k):not(.macroRow):hover td:where(.svelte-s0203k) {background:var(--background-modifier-hover);}.choicesSection.svelte-s0203k select:where(.svelte-s0203k) {max-width:100%;}
/* Narrow viewports (mobile): a 3-column table can't breathe, so each row
becomes a stacked card with the column name as an inline label. */
@media (max-width: 500px) {.choicesSection.svelte-s0203k thead:where(.svelte-s0203k) {display:none;}.choicesSection.svelte-s0203k table:where(.svelte-s0203k),
.choicesSection.svelte-s0203k tbody:where(.svelte-s0203k),
.choicesSection.svelte-s0203k tr:where(.svelte-s0203k),
.choicesSection.svelte-s0203k td:where(.svelte-s0203k) {display:block;width:100%;}.choicesSection.svelte-s0203k tbody:where(.svelte-s0203k) tr:where(.svelte-s0203k):not(.macroRow) {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.5rem 0.6rem;margin-bottom:0.5rem;}.choicesSection.svelte-s0203k td:where(.svelte-s0203k) {border-bottom:none;padding:0.15rem 0;}.choicesSection.svelte-s0203k td[data-label="Location"]:where(.svelte-s0203k)::before,
.choicesSection.svelte-s0203k td[data-label="Action"]:where(.svelte-s0203k)::before {content:attr(data-label) ": ";font-weight:600;color:var(--text-muted);}.choicesSection.svelte-s0203k td[data-label="Action"]:where(.svelte-s0203k) {display:flex;align-items:center;gap:0.4rem;margin-top:0.25rem;}.choicesSection.svelte-s0203k td[data-label="Action"]:where(.svelte-s0203k) select:where(.svelte-s0203k) {flex:1;}.macroRow.svelte-s0203k td:where(.svelte-s0203k) {padding:0.25rem 0;}
}.is-mobile .macroToggle.svelte-s0203k {min-height:36px;padding:0.4rem 0.3rem;}`};function WP(r,e){pe(e,!0),We(r,dne);function t(a){return!a||a.length===0?"Root":a.slice(0,-1).join(" \u203A ")||"Root"}var n=une(),i=_(B(n),2);{var o=a=>{var l=nne();M(a,l)},s=a=>{var l=cne(),c=_(B(l),2);Ot(c,21,()=>e.conflicts,u=>u.choiceId,(u,d)=>{let p=F(()=>HP(e.choiceDecisions.get(h(d).choiceId)??"import",h(d).exists)),f=F(()=>e.previewChoiceById.get(h(d).choiceId)),m=F(()=>(h(f)?.commands?.length??0)>0);var g=lne(),v=Te(g),y=B(v),b=B(y),x=le(b,!0),w=_(b,2);{var T=G=>{var ie=ine();M(G,ie)};Y(w,G=>{h(d).exists&&G(T)})}var C=_(w,2);{var S=G=>{var ie=one(),xe=le(ie,!0);re((ue,be)=>{ke(ie,"aria-expanded",ue),ae(xe,be)},[()=>e.expandedMacros.has(h(d).choiceId),()=>e.expandedMacros.has(h(d).choiceId)?"Hide macro":"Show macro"]),Ae("click",ie,()=>e.toggleMacro(h(d).choiceId)),M(G,ie)};Y(C,G=>{h(m)&&G(S)})}N(y);var A=_(y),D=le(A,!0),P=_(A),U=B(P),K=B(U);K.value=K.__value="import";var W=_(K);{var ee=G=>{var ie=sne();ie.value=ie.__value="overwrite",M(G,ie)};Y(W,G=>{h(d).exists&&G(ee)})}var me=_(W);me.value=me.__value="duplicate";var O=_(me);O.value=O.__value="skip",N(U);var H;dc(U),N(P),N(v);var ce=_(v,2);{var te=G=>{var ie=ane(),xe=B(ie),ue=B(xe);{let be=F(()=>h(f)?.commands??[]);zP(ue,{get commands(){return h(be)}})}N(xe),N(ie),M(G,ie)},z=F(()=>h(m)&&e.expandedMacros.has(h(d).choiceId));Y(ce,G=>{h(z)&&G(te)})}re(G=>{ae(x,h(d).name),ae(D,G),H!==(H=h(p))&&(U.value=(U.__value=H)??"",uc(U,H))},[()=>t(h(d).pathHint)]),Ae("change",U,G=>e.onChoiceModeChange(h(d).choiceId,G)),M(u,g)}),N(c),N(l),M(a,l)};Y(i,a=>{e.conflicts.length===0?a(o):a(s,-1)})}N(n),M(r,n),fe()}nt(["click","change"]);var pne=L('<li><code> </code> <span class="warnLoc svelte-111ahcq"> </span></li>'),fne=L('<div class="warnItem svelte-111ahcq"><h4 class="svelte-111ahcq">Missing files</h4> <ul class="svelte-111ahcq"></ul></div>'),mne=L(`<li class="svelte-111ahcq"><code> </code>: bundled but not
used by any choice</li>`),hne=L('<div class="warnItem svelte-111ahcq"><h4 class="svelte-111ahcq">Unreferenced files</h4> <ul class="svelte-111ahcq"></ul></div>'),gne=L('<section class="warningsBand svelte-111ahcq"><!> <!></section>'),vne={hash:"svelte-111ahcq",code:`.warningsBand.svelte-111ahcq {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-111ahcq h4:where(.svelte-111ahcq) {margin:0;font-size:var(--font-ui-small, 0.9rem);}.warnItem.svelte-111ahcq ul:where(.svelte-111ahcq) {margin:0.25rem 0 0;padding-left:1rem;}.warnItem.svelte-111ahcq li:where(.svelte-111ahcq) {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-111ahcq li.script:where(.svelte-111ahcq) {padding:0.25rem 0.4rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-critical-wash);}.warnLoc.svelte-111ahcq {color:var(--text-muted);font-size:var(--font-ui-smaller, 0.8rem);}`};function jP(r,e){pe(e,!0),We(r,vne);var t=or(),n=Te(t);{var i=o=>{var s=gne(),a=B(s);{var l=d=>{var p=fne(),f=_(B(p),2);Ot(f,21,()=>e.preview.missingReferences,m=>m.path,(m,g)=>{var v=pne();let y;var b=B(v),x=le(b,!0),w=_(b),T=_(w),C=le(T,!0);N(v),re(()=>{y=it(v,1,"svelte-111ahcq",null,y,{script:h(g).asScript}),ae(x,h(g).path),ae(w,`:
${h(g).asScript?"not bundled, so it runs from whatever file exists at that path after import":"not bundled and not in your vault"} `),ae(C,h(g).breadcrumb)}),M(m,v)}),N(f),N(p),M(d,p)};Y(a,d=>{e.preview.missingReferences.length>0&&d(l)})}var c=_(a,2);{var u=d=>{var p=hne(),f=_(B(p),2);Ot(f,20,()=>e.preview.orphanAssets,m=>m,(m,g)=>{var v=mne(),y=B(v),b=le(y,!0);Gr(),N(v),re(()=>ae(b,g)),M(m,v)}),N(f),N(p),M(d,p)};Y(c,d=>{e.preview.orphanAssets.length>0&&d(u)})}N(s),M(o,s)};Y(n,o=>{e.preview&&(e.preview.missingReferences.length>0||e.preview.orphanAssets.length>0)&&o(i)})}M(r,t),fe()}var yne=L('<div class="errorMessage svelte-1nd6fqb"> </div>'),bne=L('<div class="info svelte-1nd6fqb">Analyzing package\u2026</div>'),wne=L('<p class="svelte-1nd6fqb">No files bundled with this package.</p>'),Cne=L('<h4> </h4> <div class="fileRows svelte-1nd6fqb"></div>',1),xne=L('<section class="filesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Files</h3> <!></section> <!>',1),Ene=L('<section class="summary svelte-1nd6fqb"><!> <span class="svelte-1nd6fqb"> </span></section>'),Tne=L('<section class="packageMeta svelte-1nd6fqb"><span class="svelte-1nd6fqb"><span class="metaLabel svelte-1nd6fqb">Version</span> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"><span class="metaLabel svelte-1nd6fqb">Created</span> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"> </span></section> <!> <!> <!> <!>',1),kne=L('<div class="importPackageModal svelte-1nd6fqb"><header class="svelte-1nd6fqb"><h2 class="svelte-1nd6fqb">Import QuickAdd package</h2> <p class="svelte-1nd6fqb">Review what this package adds and runs before importing.</p></header> <section class="pasteSection svelte-1nd6fqb"><label class="svelte-1nd6fqb"><span class="svelte-1nd6fqb">Paste package JSON</span> <textarea placeholder="Paste the contents of a .quickadd.json package here" rows="8" class="svelte-1nd6fqb"></textarea></label> <!></section> <!> <!> <section class="footer svelte-1nd6fqb"><button type="button" class="secondary svelte-1nd6fqb">Cancel</button> <button type="button" class="primary svelte-1nd6fqb"><!></button></section></div>'),Sne={hash:"svelte-1nd6fqb",code:`.importPackageModal.svelte-1nd6fqb {display:flex;flex-direction:column;gap:1rem;width:min(720px, 100%);max-height:80vh;overflow-y:auto;
/* 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
leave dead space. */.packageMeta.svelte-1nd6fqb {display:flex;flex-wrap:wrap;align-items:baseline;gap:0.3rem 0.6rem;padding:0.55rem 0.75rem;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);width:100%;font-size:var(--font-ui-small, 0.9rem);overflow-wrap:anywhere;}.metaLabel.svelte-1nd6fqb {color:var(--text-muted);}.metaSep.svelte-1nd6fqb {color:var(--text-faint);}.filesSection.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.75rem;}.filesGroupHeading.svelte-1nd6fqb {margin:0;font-size:var(--font-ui-small, 0.9rem);font-weight:600;color:var(--text-muted);}.filesGroupHeading.overwrite.svelte-1nd6fqb {color:var(--text-error);}.fileRows.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.5rem;}.summary.svelte-1nd6fqb {display:flex;align-items:center;gap:0.5rem;padding:0.55rem 0.7rem;border-radius:var(--radius-m, 8px);border:1px solid var(--qa-sev-success-border);background:var(--qa-sev-success-wash);color:var(--text-normal);}.summary.svelte-1nd6fqb .quickadd-icon {color:var(--text-success, var(--color-green, #0aa344));flex-shrink:0;}.footer.svelte-1nd6fqb {display:flex;justify-content:flex-end;gap:0.5rem;margin-top:0.5rem;}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb) {background:var(--interactive-accent);color:var(--text-on-accent);}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):hover:not(:disabled) {background:var(--interactive-accent-hover);}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):active:not(:disabled),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):active:not(:disabled) {transform:translateY(1px);}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb) {background:transparent;}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):hover:not(:disabled) {background:var(--background-modifier-hover);}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}
/* Accent background needs a light outline to stay visible. */.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--text-on-accent);outline-offset:-4px;}
@media (prefers-reduced-motion: reduce) {.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb) {transition:none;}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):active:not(:disabled),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):active:not(:disabled) {transform:none;}
}`};function GP(r,e){pe(e,!0),We(r,Sne);let t;function n(){return t??(t=new JT(e.app))}let i=Ce(null),o=Ce(null),s=Ce(null),a=Ce(!1),l=Ce(ut(new Set)),c=Ce(ut(new Set)),u=Ce(null),d=Ce(!1),p=Ce(null),f=Ce(ut(new Map)),m=Ce(ut(new Map)),g=Ce(""),v=Ce(!1),y=Ce(0),b=Ce(!1),x=F(()=>h(s)?WH(h(s)):!1),w=F(()=>h(s)?jH(h(s),h(l)):!0),T=F(()=>new Map((h(s)?.choices??[]).map(Z=>[Z.choiceId,Z]))),C=F(()=>new Map((h(s)?.files??[]).map(Z=>[Z.originalPath,Z]))),S=F(()=>!!(h(s)&&(h(s).summary.hasCritical||h(s).summary.hasWarning))),A=F(()=>!!(h(i)&&h(o))&&!h(v)&&(!h(x)||h(a)&&h(w))),D=F(()=>{let Z=h(p);if(!Z)return"";let De=[];Z.added&&De.push(`${Z.added} choice${Z.added===1?"":"s"} added`),Z.overwritten&&De.push(`${Z.overwritten} overwritten`),Z.assetsWritten&&De.push(`${Z.assetsWritten} file${Z.assetsWritten===1?"":"s"} written`);let Pt=Z.skipped+Z.assetsSkipped;return Pt&&De.push(`${Pt} skipped`),De.length?`Imported: ${De.join(", ")}.`:"Nothing was imported."});function P(Z){if(h(l).has(Z))return;let De=new Set(h(l));De.add(Z),j(l,De,!0)}function U(Z){let De=new Set(h(c));De.has(Z)?De.delete(Z):De.add(Z),j(c,De,!0)}let K=Z=>n().optimistic(Z),W=F(()=>(h(o)?.assetConflicts??[]).map(Z=>({conflict:Z,state:rz(h(m),Z,O,K),file:h(C).get(Z.originalPath)}))),ee=F(()=>h(W).filter(Z=>!Z.state.destinationExists)),me=F(()=>h(W).filter(Z=>Z.state.destinationExists));function O(Z){let[De]=ri(X.getState().templateFolderPaths),Pt=Z.kind==="template"||Z.kind==="capture-template";if(De&&Pt){let It=Z.originalPath.split("/").pop()??Z.originalPath;return`${De}/${It}`}return Z.originalPath}function H(Z,De){n().schedule(Z,De,Pt=>{j(m,az(h(m),Z,Pt),!0)})}function ce(){if(!h(o)){j(f,new Map,!0),j(m,new Map,!0);return}j(f,nz(h(o).choiceConflicts),!0),j(m,tz(h(o).assetConflicts,O,K),!0);for(let Z of h(o).assetConflicts){let De=h(m).get(Z.originalPath);De&&H(Z.originalPath,De.destinationPath)}}function te(Z,De){j(f,iz(h(f),Z,De),!0)}function z(Z,De){j(m,oz(h(m),Z,De,K),!0)}function G(Z,De){let{decisions:Pt,effectivePath:It}=sz(h(m),Z.originalPath,De,K);j(m,Pt,!0),H(Z.originalPath,It)}function ie(Z,De){let It=De.currentTarget.value;te(Z,It)}function xe(){j(s,null),j(a,!1),j(l,new Set,!0),j(c,new Set,!0)}async function ue(Z){let De=Z.trim(),Pt=L_(y);if(j(p,null),j(b,!1),!De){j(i,null),j(o,null),j(f,new Map,!0),j(m,new Map,!0),xe(),j(u,null);return}j(v,!0);try{let It=ib(De),pi=X.getState().choices,Di=await KH(e.app,pi,It),Au=await XT(e.app,pi,It);if(Pt!==h(y))return;j(i,{pkg:It,path:"[pasted]"},!0),j(o,Di,!0),xe(),j(s,Au,!0),j(u,null),ce()}catch(It){if(Pt!==h(y))return;j(u,It?.message??String(It),!0),j(i,null),j(o,null),j(f,new Map,!0),j(m,new Map,!0),xe()}finally{Pt===h(y)&&j(v,!1)}}function be(Z){let De=Z.currentTarget.value;j(g,De,!0),ue(De)}async function Ke(){if(h(b)){new ab.Notice("This package has already been imported.");return}if(!h(i)||!h(o)){new ab.Notice("Load a package before importing.");return}j(d,!0),j(p,null);try{let Z=await QH({app:e.app,existingChoices:X.getState().choices,aiProviders:X.getState().ai.providers,pkg:h(i).pkg,choiceDecisions:lz(h(o).choiceConflicts,h(f)),assetDecisions:cz(h(o).assetConflicts,h(m),K)});X.setState(De=>({...De,choices:Z.updatedChoices})),j(p,{added:Z.addedChoiceIds.length,overwritten:Z.overwrittenChoiceIds.length,skipped:Z.skippedChoiceIds.length,assetsWritten:Z.writtenAssets.length,assetsSkipped:Z.skippedAssets.length},!0),j(b,!0),new ab.Notice(`Imported ${Z.addedChoiceIds.length+Z.overwrittenChoiceIds.length} choice${Z.addedChoiceIds.length+Z.overwrittenChoiceIds.length===1?"":"s"} successfully.`)}catch(Z){console.error(Z),new ab.Notice(`Import failed: ${Z?.message??Z}`)}finally{j(d,!1)}}var Oe=kne(),Ee=_(B(Oe),2),He=B(Ee),Le=_(B(He),2);Nu(Le),N(He);var At=_(He,2);{var mr=Z=>{var De=yne(),Pt=le(De,!0);re(()=>ae(Pt,h(u))),M(Z,De)},zr=Z=>{var De=bne();M(Z,De)};Y(At,Z=>{h(u)?Z(mr):h(v)&&Z(zr,1)})}N(Ee);var ge=_(Ee,2);{var ve=Z=>{var De=Tne(),Pt=Te(De),It=B(Pt),pi=_(B(It));N(It);var Di=_(It,4),Au=_(B(Di));N(Di);var wp=_(Di,4),Cp=le(wp),xp=_(wp,4),Iu=le(xp);N(Pt);var we=_(Pt,2);{var qe=oe=>{VP(oe,{get preview(){return
2026-01-31 08:25:19 +08:00
tm = tomorrow
yd = yesterday`).setValue(bA(X.getState().dateAliases)).onChange(o=>{X.setState({dateAliases:VR(o)})}),i.inputEl.addClass("qa-date-alias-input")}),t.addButton(i=>{i.setButtonText("Reset to defaults").onClick(()=>{X.setState({dateAliases:Kp}),n?.setValue(bA(Kp))}),i.buttonEl.addClass("qa-date-alias-reset")})}renderTemplateFolderPaths(t){t.settingEl.addClass("qa-template-folders-setting");let n=t.controlEl.createDiv("qa-template-folders"),i=n.createDiv("qa-template-folder-list"),o=()=>ri(X.getState().templateFolderPaths),s=f=>{X.setState({templateFolderPaths:f})},a=()=>{i.empty();let f=o();if(f.length===0){i.createDiv({cls:"qa-template-folder-empty",text:"No folders added yet."});return}for(let m of f){let g=i.createDiv("qa-template-folder-row");g.createSpan({cls:"qa-template-folder-name",text:m,attr:{title:m}}),new lu.ExtraButtonComponent(g).setIcon("trash-2").setTooltip(`Remove ${m}`).onClick(()=>{s(o().filter(v=>v!==m)),a()})}},l=n.createDiv("qa-template-folder-input-row"),c=new lu.TextComponent(l);c.setPlaceholder("templates/"),c.inputEl.addClass("qa-template-folder-input");let u=new si(this.app,c.inputEl,Il(Vo(this.app)).filter(f=>f!=="/")),d=()=>{let[f]=ri([c.inputEl.value]);if(c.inputEl.value="",!f)return;let m=o();m.includes(f)||(s([...m,f]),a())},p=f=>{f.key==="Enter"&&(f.preventDefault(),d())};return c.inputEl.addEventListener("keydown",p),new lu.ButtonComponent(l).setCta().setButtonText("Add").onClick(()=>d()),a(),()=>{c.inputEl.removeEventListener("keydown",p),u.destroy()}}renderDevInfo(t){let n=t.settingEl.createDiv();n.addClass("qa-dev-info"),dz(n,{branch:null,commit:null,dirty:null})}};wA();Ie();mC();var Xm=class{formatOutputString(e){return`QuickAdd: (${e.level}) ${e.message}`}getQuickAddError(e,t,n,i){return{message:e,level:t,time:Date.now(),stack:n,originalError:i}}};xt();var lb=class extends Xm{constructor(){super(...arguments);this.ErrorLog=[]}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);this.addMessageToErrorLog(o);let s=i||new Error(t);console.error(this.formatOutputString(o),s)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);this.addMessageToErrorLog(o);let s=i||new Error(t);console.warn(this.formatOutputString(o),s)}logMessage(t,n,i){let o=this.getQuickAddError(t,"LOG",n,i);this.addMessageToErrorLog(o)}addMessageToErrorLog(t){this.ErrorLog.push(t),this.ErrorLog.length>PA&&(this.ErrorLog=this.ErrorLog.slice(-PA))}clearErrorLog(){this.ErrorLog=[]}};var QP=require("obsidian");mC();var nk=class extends Xm{constructor(t){super();this.plugin=t}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);new QP.Notice(this.formatOutputString(o),15e3)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);new QP.Notice(this.formatOutputString(o))}logMessage(t,n,i){}};Ie();xt();xt();var fz=1e4,mz=50,_ne=/plugin:([^\s:)]+)/;function Ane(r){let e=r.stack??"",t=`${r.name}: ${r.message}`;return(e.startsWith(t)?e.slice(t.length):e).split(`
`)}function Ine(r){for(let e of Ane(r)){let t=_ne.exec(e);if(t)return{pluginId:t[1],frame:e.trim()}}return null}function Dne(r,e){return`${r.name}@${e}`}function hz(r,e=Date.now){let t=r.manifest.id,n=new Map;r.registerDomEvent(window,"unhandledrejection",i=>{let o=i.reason,s=o instanceof Error?Ine(o):null;if(s?.pluginId!==t)return;if(ot(o)){i.preventDefault();return}let a=o,l=Dne(a,s.frame),c=e(),u=n.get(l);if(n.set(l,c),!(u!==void 0&&c-u<fz)){if(n.size>=mz){for(let[d,p]of n)c-p>=fz&&n.delete(d);if(n.size>=mz){let d=n.keys().next();!d.done&&d.value!==l&&n.delete(d.value)}}Ze(a,"A QuickAdd action failed")&&i.preventDefault()}})}var gz=require("obsidian");Ie();function Fne(r,e){try{let t=r.setting;return!t?.open||!t?.openTabById?(I.logMessage("QuickAdd: Obsidian internal settings API is unavailable."),!1):(t.open(),t.openTabById(e),!0)}catch(t){return I.logMessage(`QuickAdd: Failed to open plugin settings automatically: ${t}`),!1}}function Zm(r,e,t){let n=Fne(r,e);return!n&&t?.notice!==!1&&new gz.Notice("QuickAdd: Unable to open settings automatically. Open Settings \u2192 QuickAdd manually."),n}Ob();bt();xt();var AS=class{constructor(e,t,n,i){this.app=e;this.plugin=t;this.choices=n;this.choiceExecutor=i}async run(){let e=nn(this.choices).filter(t=>t.type==="Macro"&&t.runOnStartup);for(let t of e)try{await new _a(this.app,this.plugin,t,this.choiceExecutor,new Map).run()}catch(n){Ze(n,`Startup macro '${t.name}' failed`)}}};var _6=require("obsidian");Ie();wc();ht();Og();Lg();function IS(r,e){return!e.enabled||e.destination.type!=="specifiedFile"||$g(r,e.destination)?null:`Append link target file not found or is not a Markdown file: ${e.destination.path}`}async function DS(r,e,t,n,i){t.enabled&&(t.destination?.type==="specifiedFile"?await PN(r,e,t,i):n&&!al(t.placement)?await LN(r,n,e):i?await TC(r,e,t,i):await TC(r,e,t))}async function FS(r){try{await MN(r)}catch(e){I.logWarning(`Could not copy link to clipboard for '${r.path}': ${e instanceof Error?e.message:String(e)}`)}}async function gp({app:r,file:e,opening:t,originLeaf:n,forceFocus:i}){let o=Cn(t),s=i??o.focus??!0;return WA(r,e,s)||await Hg(r,e,{...o,...i===void 0?{}:{focus:i},originLeaf:n}),s}var Rh=require("obsidian");Jm();Xe();Zo();Ie();Dl();var $S=require("obsidian");ur();Dl();Sh();var YG=require("obsidian");lo();rn();function PS(r,e,t){let n=e.lastIndexOf("/"),i=n>=0?e.slice(0,n):"",o=iv(n>=0?e.slice(n+1):e),s=t?.vault.getAbstractFileByPath(e),a=t&&s instanceof YG.TFile?GI([s],d=>t.metadataCache.getFileCache(d))[0]:null,l=a?.primary??o,c=a?.secondary??i;r.addClass("mod-complex");let u=r.createDiv({cls:"suggestion-content"});u.createDiv({cls:"suggestion-title",text:l}),c&&u.createDiv({cls:"suggestion-note",text:c})}var MS=class extends $S.FuzzySuggestModal{constructor(t,n,i){super(t);this.settled=!1;this.rows=i.map(o=>({kind:"candidate",candidate:o})),this.action=Zc(n.existingNoteAction),this.promise=new Promise((o,s)=>{this.resolvePromise=o,this.rejectPromise=s}).then(o=>o.kind==="candidate"?Wb(o.candidate.item):Pa(o.title)),this.setPlaceholder(`Search notes or create ${n.name}`),this.open()}getItems(){return this.rows}getItemText(t){return t.kind==="candidate"?t.candidate.display:t.title}getSuggestions(t){let n=t.trim(),i=xo(n),o=a=>a.kind==="candidate"&&a.candidate.exactKeys.includes(i),s=super.getSuggestions(n).sort((a,l)=>Number(o(l.item))-Number(o(a.item)));return n&&!this.rows.some(o)&&s.unshift({item:{kind:"create",title:n},match:{score:Number.NEGATIVE_INFINITY,matches:[]}}),s}renderSuggestion({item:t},n){if(t.kind==="candidate"&&t.candidate.renderPath){let o=t.candidate;PS(n,t.candidate.renderPath),this.action!=="Open"&&n.querySelector(".suggestion-title")?.prepend(`${this.action}: `),o.renderAlias&&n.querySelector(".suggestion-content")?.createDiv({cls:"suggestion-note",text:`Alias: ${o.renderAlias}`});return}n.addClass("mod-complex");let i=n.createDiv({cls:"suggestion-content"});i.createDiv({cls:"suggestion-title",text:t.kind==="create"?`Create new note: ${t.title}`:t.candidate.unresolvedTitle??t.candidate.title}),t.kind==="create"?(0,$S.setIcon)(n.cre
2026-01-05 19:25:56 +08:00
`)}}).join(`
`)}}var ZG=r=>r.join(""),rle=r=>r.split(/\b/),nle=XG("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",ZG),ile={splitFunction:rle,joinFunction:ZG,conflictFunction:nle};function u$(r,e,t,n={}){n=Object.assign({},ile,n);let[i,o,s]=[r,e,t].map(c=>n.splitFunction.call(n,c)),a=nw.merge(i,o,s);return iw.collateMerge(a,n.joinFunction,n.conflictFunction)}var JG=u$;Xe();function e6(r,e){return r.line===e.line}function Gl(r){let e=[];return r.forEach((t,n)=>{let i=t.match(/^(#+)[\s]+(.*)$/);i&&e.push({level:i[1].length,text:i[2],line:n})}),e}function Yl(r,e,t=!1){let n=Gl(r),i=n.find(c=>c.line===e),o=!!i;if(!o&&t)throw new Error(`Target line ${e} is not a heading, but we are trying to find the end of its section.`);if(!o&&!t){let c=t6(r,e,u=>u.trim()==="");return c!==null&&c>e?c-1:e}let s=r.length-1,a=ole(i,n,r,t),l=lle(r,a,c=>c.trim()!=="");if(l!==null){if(l<e)return e;let c=r[l+1].trim()==="";return l+1===s&&!c?a:l===0?l+1:l}return a}function ole(r,e,t,n){let i=e.findIndex(u=>e6(u,r)),o=i===e.length-1,s=t.length-1;if(o)return s;let[a,l]=sle(r,e);if(l&&a===e.length)return s;if(l&&n)return e[a].line-1;if(l&&!n)return e[i+1].line;if(!n&&!l){let u=ale(r.line,e);return u===null?s:u}return s}function sle(r,e){let t=e.findIndex(i=>e6(i,r)),n=t6(e,t,i=>i.level<=r.level);return n===null?[-1,!1]:[n,!0]}function ale(r,e){let t=e.find(n=>n.line>r);return t?t.line:null}function lle(r,e,t){for(let n=e-1;n>=0;n--)if(t(r[n]))return n;return null}function t6(r,e,t){for(let n=e+1;n<r.length;n++)if(t(r[n]))return n;return null}wl();ew();wu();var cle="\u200B";function ow(r){let e=r.slice(),t=!1,n="",i=0;for(let o=0;o<r.length;o++){let s=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${cle}$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)}return e}function r6(r){return(r.match(/^#+\s+(.*)$/)?.[1]??"").trim()}function ule(r){let e=r.match(/^\[?v?(\d+)\.(\d+)\.(\d+)(?:[-+\]].*)?$/i)??r.match(/^\[?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/i);if(!e)return{value:0,parsed:!1};let t=n=>Math.min(Number(n??"0"),999999);return{value:t(e[1])*1e12+t(e[2])*1e6+t(e[3]),parsed:!0}}function n6(r,e,t){switch(e.by){case"lexical":return{value:r.toLocaleLowerCase(),parsed:!0};case"numeric":{let n=r.match(/^-?\d+(?:\.\d+)?/);return n?{value:Number(n[0]),parsed:!0}:{value:0,parsed:!1}}case"date":{let n=t?t(r,e.dateFormat||void 0,!1):null;return n&&n.isValid()?{value:n.valueOf(),parsed:!0}:{value:0,parsed:!1}}case"semver":return ule(r);default:return{value:0,parsed:!0}}}function dle(r,e){if(typeof r.value=="string"&&typeof e.value=="string")return r.value<e.value?-1:r.value>e.value?1:0;let t=r.value,n=e.value;return t<n?-1:t>n?1:0}function i6(r,e,t,n,i,o=0){let s=ow(r),a=Gl(s).filter(p=>p.line>=o),l=a.filter(p=>p.level===t),c=n6(r6(e),n,i);if(l.length===0){let p=a.filter(f=>f.level<t).pop();return p?{mode:"after",line:Yl(s,p.line,!0)}:{mode:"bodyStart"}}let u=()=>{let p=l[l.length-1];return{mode:"after",line:Yl(s,p.line,!0)}};if(n.by==="insertion")return n.direction==="desc"?{mode:"before",line:l[0].line}:u();if(!c.parsed)return u();let d=n.unparseable??"bottom";for(let p of l){let f=n6(r6(s[p.line]),n,i),m;if(!f.parsed)m=d==="bottom";else{let g=dle(c,f);m=n.direction==="desc"?g>0:g<0}if(m)return{mode:"before",line:p.line}}return u()}wu();function d$(r){let e=r.split(`
`);for(;e.length>1&&e[e.length-1].trim()==="";)e.pop();return e}function p$(r){return r.length===0||r.length===1&&r[0].trim()===""}function f$(r,e){if(e.length<=1){let t=ple(r,e[0]??"");return{start:t,end:t}}return fle(r,e)}function ple(r,e){let t=e.trimEnd(),n=-1;for(let i=0;i<r.length;i++){let o=r[i].trimStart();if(o===t)return i;if(o.startsWith(t)){let a=o.slice(t.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i);continue}let s=o.indexOf(t);if(s!==-1){let a=o.slice(s+t.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i)}}return n}function fle(r,e){let t=e.length,n=e.map(i=>o6(i));for(let i=0;i+t<=r.length;i++){let o=!0;for(let s=0;s<t;s++)if(o6(r[i+s])!==n[s]){o=!1;break}if(o)return{start:i,end:i+t-1}}return{start:-1,end:-1}}function o6(r){return r.trimEnd()}function US(r,e,t){return r?Gl([e[t]??""]).length>0:!1}function mle(r,e){return r==="skip"?!0:r==="none"?!1:hle(e)}function hle(r){return/^\s{0,3}#{1,6}\s+\S/.test(r)}function HS(r,e,t,n){if(e<0)return e;let i=r[e]??"";if(!mle(n,i))return e;let s=t.endsWith(`
`)?Math.max(r.length-1,0):r.length,a=e;for(let l=e+1;l<s;l++){if(r[l].trim().length===0){a=l;continue}break}return a}function sw(r,e,t,n){if(e<0)return e;let i=e,o=e+1;for(;o<r.length&&r[o].trim().length===0;)i=o,o++;return i===e||o!==r.length||!n.endsWith(`
`)?e:t.endsWith(`
`)?Math.max(e,i-1):i}function s6(r){return r.includes(`
`)||r.includes("\r")}function a6(r,e){let t=r.indexOf(`
`,e);return t===-1?r.length:t>0&&r[t-1]==="\r"?t-1:t}function m$(r){let e=ql(r);return e>0?r.slice(0,e).split(`
`).length-1:0}function l6(r,e){let t=m$(e),n=r.map((i,o)=>o<t?"":i);return ow(n).map(i=>i.replace(/\r$/,""))}function zS(r,e,t,n,i=r.length){let o=e.split(`
`),s=o.slice(0,t+1).join(`
`),a=o.slice(t+1).join(`
`),c=(o[t+1]??"").trim(),u=e.endsWith(`
`)&&t+1===o.length-1,d=t+1<o.length&&!u&&c==="",p=n&&r.endsWith(`
`)&&d?r.slice(0,-1):r,f=!p.endsWith(`
`)&&c!==""?`
`:"";return{content:`${s}
${p}${f}${a}`,insertedEndOffset:s.length+1+Math.min(i,p.length)}}function c6(r,e,t,n=r.length){let i=e.length>0&&!r.endsWith(`
`)?`
`:"",o=Math.max(0,Math.min(n,r.length));if(t<=0)return{content:`${r}${i}${e}`,insertedEndOffset:o};let s=e.split(`
`),a=s.slice(0,t).join(`
`),l=s.slice(t).join(`
`);return{content:`${a}
${r}${i}${l}`,insertedEndOffset:a.length+1+o}}function u6(r,e,t,n,i){let o=n,s=o.includes(`\r
`)?`\r
`:`
`,a=e.mode==="before"?e.line:e.line+1,l=0;for(let x=0;x<a&&x<r.length;x++)l+=r[x].length+1;l>o.length&&(l=o.length);let c=o.slice(0,l),u=o.slice(l),d=a>0?(r[a-1]??"").replace(/\r$/,""):"",p=a<r.length?(r[a]??"").replace(/\r$/,""):"",f=t.split(`
`).map(x=>x.replace(/\r$/,""));f.length>1&&f[f.length-1]===""&&f.pop();let m=[];a>0&&d.trim()!==""&&m.push(""),m.push(...f),a<r.length&&p.trim()!==""&&m.push("");let g=m.join(s),v=c.length>0&&!/\n$/.test(c)?s:"",y=u.length>0||/\n$/.test(o)?s:"",b=c.length+v.length;return{content:`${c}${v}${g}${y}${u}`,insertedEndOffset:b+(i===void 0?g.length:(a>0&&d.trim()!==""?s.length:0)+Math.min(t.slice(0,i).split(`
`).map(x=>x.replace(/\r$/,"")).join(s).length,f.join(s).length))}}function p6({capture:r,targetString:e,fileContent:t,insertAfter:n,task:i}){let o=r.content,s=n?.orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"},a=e.split(/\r?\n/,1)[0],l=Gl([a])[0]?.level??0,c=bl(r,`${e}
`),u=()=>{let w=op(t,c.content);return Oc(c,w.content,w.insertedStartOffset===null||c.cursor.kind==="none"?null:w.insertedStartOffset+c.cursor.value)};if(l===0)return u();let d=Eu(t),p=d.map(w=>w.replace(/\r$/,"")),f=m$(t),m=ow(p),g=a.replace(/\r$/,"").trimEnd(),v=m.findIndex((w,T)=>T>=f&&w.trimEnd()===g);if(v!==-1){let w=n?.insertAtEnd?sw(m,Yl(m,v,US(!!n?.considerSubsections,m,v))??m.length-1,t,o):HS(m,v,t,n?.blankLineAfterMatchMode??"auto"),T=zS(o,t,w,i,r.cursor.kind==="offset"?r.cursor.value:void 0);return Oc(r,T.content,T.insertedEndOffset)}let y=typeof window<"u"?window.moment:void 0,b=i6(p,a,l,s,y,f);if(b.mode==="bodyStart")return u();let x=u6(d,b,c.content,t,c.cursor.kind==="offset"&&c.cursor.source==="marker"?c.cursor.value:void 0);return Oc(c,x.content,x.insertedEndOffset)}ys();ew();Xe();ht();Yn();wl();lp();wu();Cu();dx();var gle=/^[ \t\r\n\f\v]*$/;function vle(r){return gle.test(r)}var WS=class extends ji{constructor(){super(...arguments);this.file=null;this.fileContent="";this.sourcePath=null;this.useSelectionAsCaptureValue=!0;this.clipboardImageFallbackEnabled=!1;this.createdClipboardAttachmentPaths=[];this.templaterProcessed=!1;this.insertAfterTargetOverride=null;this.lastResolvedInsertAfterHeading=null;this.linebreaksProcessed=!1}setDestinationFile(t){this.file=t,this.sourcePath=t.path,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(Ai(t.path)),this.setPromptRunContext({destination:t.path,destinationKind:"file"})}setDestinationSourcePath(t){this.sourcePath=t,this.file=null,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(Ai(t)),this.setPromptRunContext({destination:t,destinationKind:"file"})}setUseSelectionAsCaptureValue(t){this.useSelectionAsCaptureValue=t}setInsertAfterTargetOverride(t){this.insertAfterTargetOverride=t}getResolvedInsertAfterHeading(){return this.lastResolvedInsertAfterHeading}consumeCreatedClipboardAttachmentPaths(){let t=this.createdClipboardAttachmentPaths;return this.createdClipboardAttachmentPaths=[],t}shouldUseSelectionForValue(){return this.useSelectionAsCaptureValue}async getSelectedTextForValue(){let t=await this.getSelectedText();return t.trim().length>0?t:""}getLinkSourcePath(){return this.sourcePath??this.file?.path??null}async getClipboardContent(){let t=await super.getClipboardContent();return t.length>0||!this.clipboardImageFallbackEnabled?t:this.clipboardAttachmentLink!==void 0?this.clipboardAttachmentLink??"":(this.clipboardAttachmentLink=await this.saveClipboardImageAsAttachment(),this.clipboardAttachmentLink??"")}async withClipboardImageFallback(t){let n=this.clipboardImageFallbackEnabled;this.clipboardImageFallbackEnabled=!0;try{return await t()}finally{this.clipboardImageFallbackEnabled=n}}async saveClipboardImageAsAttachment(){let t=navigator.clipboard;if(typeof t?.read!="function")return null;let n,i;try{if(n=await this.getFirstClipboardImageItem(t),!n)return null;i=await(await n.clipboardItem.getType(n.mimeType)).arrayBuffer()}catch{return null}let o=this.getLinkSourcePath()??"",s=await cx(this.app,i,n.mimeType,o);return this.createdClipboardAttachmentPaths.push(s.path),ux(this.app,s,o)}async getFirstClipboardImageItem(t){let n=await t.read();for(let i of n){let o=i.types.find(s=>gl[s]!==void 0);if(o)return{clipboardItem:i,mimeType:o}}return null}getCurrentFileLink(){let t=this.app.workspace.getActiveFile();if(!t)return null;let n=this.sourcePath??this.file?.path??"";return this.app.fileManager.generateMarkdownLink(t,n)}async formatContentWithFile(t,n,i,o){if(this.choice=n,this.file=o,this.fileContent=i,!n||!o||i===null)return{content:t,captureContent:t,cursor:{kind:"none"}};this.setTargetFolderPath(Ai(o.path));let s=n.insertAfter.enabled||!!n.insertBefore?.enabled||n.prepend||!n.captureToActiveFile||n.activeFileWritePosition==="top"||n.activeFileWritePosition==="bottom";return await this.formatCapture(t,s)}async formatContent(t,n){return this.choice=n,n?await this.formatFileContent(t):t}async formatFileContent(t,n=!0){return(await this.formatCapture(t,n)).content}async formatCapture(t,n){let i=await this.withClipboardImageFallback(async()=
`)&&!n.startsWith(`
`),s=!this.choice.task||o?`
`:"";return bl(t,this.fileContent+s)}return this.choice.insertAfter.enabled?this.insertAfterHandler(t):this.choice.insertBefore?.enabled?this.insertBeforeHandler(t):this.insertAtNoteBodyStartTracking(t)}async formatContentOnly(t){let n=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));return vle(n)?this.fileContent:n}async expandTemplateLinebreaksOnce(t){return this.linebreaksProcessed?t:(this.linebreaksProcessed=!0,this.expandFormatTemplateEscapes(t))}async expandFormatTemplateEscapes(t){let n=await this.replaceGlobalVarInString(t);return this.expandLinebreakEscapesOutsideTokens(n)}async insertAfterHandler(t){let n=t.content,i=this.insertAfterTargetOverride;if(this.choice.insertAfter?.inline&&i===null){let f=await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));return await this.insertAfterInlineHandler(t,f)}let o=i??await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));if(i===null){let f=o.split(`
`,1)[0];this.lastResolvedInsertAfterHeading=/^#+\s+\S/.test(f)?f.trim():null}let s=d$(o);if(p$(s))throw new ye("Insert-after target is empty after formatting.");let a=Eu(this.fileContent),l=this.isOrderedCreate()?l6(a,this.fileContent):a,{start:c,end:u}=f$(l,s);if(c===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(t,o);throw new ye(`Insert-after target not found: '${o}'.`)}let p;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let f=Yl(a,c,this.considerSubsectionsForAnchor(a,c)),m=Math.max(f??a.length-1,u);p=sw(a,m,this.fileContent,n)}else{let f=this.choice.insertAfter?.blankLineAfterMatchMode??"auto";p=HS(a,u,this.fileContent,f)}return this.insertTextAfterPositionInBody(t,this.fileContent,p)}async insertBeforeHandler(t){let n=this.choice.insertBefore;if(!n)throw new ye("Insert-before settings are missing.");let i=await this.formatLocationString(await this.expandFormatTemplateEscapes(n.before)),o=d$(i);if(p$(o))throw new ye("Insert-before target is empty after formatting.");let s=Eu(this.fileContent),{start:a}=f$(s,o);if(a===-1){if(n.createIfNotFound)return await this.createInsertBeforeIfNotFound(t,i);throw new ye(`Insert-before target not found: '${i}'.`)}return this.insertTextBeforePositionInBody(t,this.fileContent,a)}async insertAfterInlineHandler(t,n){if(s6(n))throw new ye("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 ye(`Inline insert-after target not found: '${n}'.`)}let o=i+n.length,s=this.choice.insertAfter?.replaceExisting?a6(this.fileContent,o):o;return bl(t,this.fileContent.slice(0,o),this.fileContent.slice(s))}async createInsertAfterIfNotFound(t,n){let i=this.choice.insertAfter;if(i?.createIfNotFoundLocation===vs)return this.createInsertAfterOrdered(t,n);let o=bl(t,`${n}
`);return this.createMissingTarget({payload:o,location:i?.createIfNotFoundLocation,rawTarget:i.after,insertAtCursor:s=>{let a=s;if(i?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let l=Eu(this.fileContent),c=Yl(l,s,this.considerSubsectionsForAnchor(l,s));a=sw(l,c??l.length-1,this.fileContent,o.content)}return this.insertTextAfterPositionInBody(o,this.fileContent,a)}})}isOrderedCreate(){return!!this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation===vs}considerSubsectionsForAnchor(t,n){return US(!!this.choice.insertAfter?.considerSubsections,t,n)}createInsertAfterOrdered(t,n){return p6({capture:t,targetString:n,fileContent:this.fileContent,insertAfter:this.choice.insertAfter,task:!!this.choice.task})}async createInsertBeforeIfNotFound(t,n){let i=this.choice.insertBefore;if(!i)throw new ye("Insert-before settings are missing.");let o=bl(t,"",`${t.content.endsWith(`
`)||t.content.length===0?"":`
`}${n}`);return this.createMissingTarget({payload:o,location:i.createIfNotFoundLocation,rawTarget:i.before,insertAtCursor:s=>this.insertTextBeforePositionInBody(o,this.fileContent,s)})}async createInlineInsertAfterIfNotFound(t,n){let i=bl(t,n);return this.createMissingTarget({payload:i,location:this.choice.insertAfter?.createIfNotFoundLocation,rawTarget:this.choice.insertAfter.after,insertAtCursor:o=>this.insertTextAfterPositionInBody(i,this.fileContent,o)})}createMissingTarget({payload:t,location:n,rawTarget:i,insertAtCursor:o}){switch(n){case no:return this.insertAtNoteBodyStartTracking(t);case nd:return bl(t,`${this.fileContent}
`);case id:{let s=xn(this.app);if(!s)throw new ye(`Unable to insert line '${i}' at cursor position: no active markdown editor.`);try{return o(s.editor.getCursor().line)}catch{throw new ye(`Unable to insert line '${i}' at cursor position.`)}}default:throw new ye(`Unknown createIfNotFoundLocation: ${n}`)}}insertAtNoteBodyStartTracking(t){let n=op(this.fileContent,t.content);return Oc(t,n.content,n.insertedStartOffset===null||t.cursor.kind==="none"?null:n.insertedStartOffset+t.cursor.value)}insertTextAfterPositionInBody(t,n,i){let o=zS(t.content,n,i,!!this.choice.task,t.cursor.kind==="offset"?t.cursor.value:void 0);return Oc(t,o.content,o.insertedEndOffset)}insertTextBeforePositionInBody(t,n,i){let o=c6(t.content,n,i,t.cursor.kind==="offset"?t.cursor.value:void 0);return Oc(t,o.content,o.insertedEndOffset)}};ew();Ie();wD();_f();Sv();If();VM();wc();ht();xt();sp();ap();bf();Cu();var h6=require("obsidian");i$();Xe();ht();Ol();Jm();HM();da();la();Cu();sp();ap();Yn();RM();NM();var f6=require("obsidian");Xe();Yn();fE();pE();da();function m6(r,e){let t=r.trim().replace(/^\/+/,"");if(t==="")return{kind:"vault"};let n=Zf(t);if(n){if(!n.field)throw new ye("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=Xf(t);if(i){if(i.multiSelect)throw new ye("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=Wn(t,"Capture target file path");if(wn.test(o))throw new ye(`Capture to '.base' files is not supported (${o}). Use a Template choice instead.`);let s=o.endsWith("/"),a=o.replace(/\/+$/,"");if(s)return{kind:"folder",folder:a};if(Nt.test(o)||cr.test(o))return{kind:"file",path:o};let l=e.normalizeMarkdownFilePath("",a),u=e.getAbstractFileByPath(l)instanceof f6.TFile;return e.isFolder(a)&&!u?{kind:"folder",folder:a}:{kind:"file",path:o}}var jS=class extends $h{async getFormattedPathToCaptureTo(e){if(e){let s=this.app.workspace.getActiveFile();return $n(s,"Cannot capture to active file - no active file."),s.path}let t=this.getPreselectedCaptureTargetPath();if(t!==void 0){let s=fS({isFolder:a=>tf(this.app,a),markdownFileExists:a=>this.app.vault.getAbstractFileByPath(pS(a))instanceof h6.TFile},this.choice.captureTo??"",!1);if(s){let a=this.confinePreselectedToScope(s,t);if(a!==null)return this.normalizeCaptureFilePath(a)}}let n=this.choice.captureTo,i=await this.formatter.formatFileName(n,"captureTarget"),o=this.resolveCaptureTarget(i);switch(o.kind){case"vault":return this.selectFileInFolder("",!0);case"filter":return this.selectFileWithFilter(o.filter);case"property":return this.selectFileWithProperty(o.field,o.value,o.filter);case"folder":return this.selectFileInFolder(o.folder,!1);case"file":return this.normalizeCaptureFilePath(o.path)}}getPreselectedCaptureTargetPath(){return Nj(this.choiceExecutor?.variables,this.choice.id)}confinePreselectedToScope(e,t){let n=this.stripLeadingSlash(t);if(e.kind==="folder")return e.folderPathSlash&&!n.startsWith(e.folderPathSlash)?`${e.folderPathSlash}${n}`:n;if(this.resolveScopeFiles(e).some(a=>a.path===n))return n;if(!(this.choice.createFileIfItDoesntExist?.enabled??!1))return null;let s=new Set(this.app.vault.getMarkdownFiles().map(a=>a.basename.toLowerCase()));return this.captureTargetAlreadyExists(n,s)?null:n}resolveScopeFiles(e){return dS(this.app,e)}resolveCaptureTarget(e){return m6(e,{getAbstractFileByPath:t=>this.app.vault.getAbstractFileByPath(t),isFolder:t=>tf(this.app,t),normalizeMarkdownFilePath:(t,n)=>this.normalizeMarkdownFilePath(t,n)})}captureTargetExists(e,t){let n=t.startsWith(e)?t:`${e}${t}`,i;try{i=Wn(n,"Capture target file path")}catch{return!1}let o=[i];return/\.(md|canvas)$/i.test(i)||o.push(`${i}.md`,`${i}.canvas`),o.some(s=>!!this.app.vault.getAbstractFileByPath(s))}async selectFileInFolder(e,t){let n=e.endsWith("/")||t?e:`${e}/`,i=Bo(this.app,n),o=this.choice.createFileIfItDoesntExist?.enabled??!1;$n(o||i.length>0,`Folder ${n} is empty.`);let s=await this.chooseCaptureTar
`),t}async onFileExists(t,n,i=!1){let o=this.getFileByPath(t);if(!o)throw new Error("File not found");this.formatter.setTitle(o.basename),this.formatter.setDestinationFile(o);let s=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let a=await this.app.vault.read(o);if(/{{CURSOR}}/i.test(s)&&Tf(s).cursor.kind==="none")return{file:o,newFileContent:a,captureContent:"",priorContent:a,cursor:{kind:"none"},markerOnly:!0};if(i)return{file:o,newFileContent:a,captureContent:s,priorContent:a,cursor:{kind:"none"}};let l=await this.collectIfFrontmatter(()=>this.formatter.formatContentWithFile(s,this.choice,a,o));if(this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars()),l.markerOnly)return{file:o,newFileContent:a,captureContent:l.captureContent,priorContent:a,cursor:l.cursor,markerOnly:!0};let c=await this.app.vault.read(o),u=l.content,d=!0;if(c!==a){let p=JG(c,a,l.content);$n(p.isSuccess(),()=>`The file ${t} has been modified since the last read.
2026-01-05 19:25:56 +08:00
QuickAdd could not merge the versions two without conflicts, and will not modify the file.
This is in order to prevent data loss.`),u=p.joinedResults(),d=!1}return{file:o,newFileContent:u,captureContent:l.captureContent,priorContent:c,cursor:l.cursor,cursorPlacementSafe:d}}async onCreateFileIfItDoesntExist(t,n,i){Vb(t);let o=Ia(t);this.formatter.setTitle(o),this.formatter.setDestinationSourcePath(t);let s=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n));if(this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars()),/{{CURSOR}}/i.test(s)&&Tf(s).cursor.kind==="none")return null;let a="";if(this.choice.createFileIfItDoesntExist.createWithTemplate){let d=new vh(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);i?.enabled&&!i.requireActiveFile&&d.setLinkToCurrentFileBehavior("optional"),d.setTargetFolderPath(Ai(t)),d.setPromptRunContext({draftScopeId:`${this.choice.id}#${this.choice.createFileIfItDoesntExist.template}`,choiceName:this.choice.name,destination:t,destinationKind:"file"}),a=await d.run();let p=d.getAndClearTemplatePropertyVars();I.logMessage(`CaptureChoiceEngine: Collected ${p.size} template property variables`),p.size>0&&I.logMessage(`Variables: ${Array.from(p.keys()).join(", ")}`),this.templatePropertyVars=p}let l=await this.createFileWithInput(t,a,{suppressTemplaterOnCreate:this.choice.createFileIfItDoesntExist.createWithTemplate});this.choice.createFileIfItDoesntExist.createWithTemplate&&this.templatePropertyVars&&hh(l,this.templatePropertyVars)&&await gh(this.app,l,this.templatePropertyVars),this.choice.createFileIfItDoesntExist.createWithTemplate&&a?await yc(this.app,l):Xp(this.app)&&await bC(this.app,l);let c=await this.app.vault.read(l),u=await this.collectIfFrontmatter(()=>this.formatter.formatContentWithFile(s,this.choice,c,l));return this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars()),{file:l,newFileContent:u.content,captureContent:u.captureContent,priorContent:c,cursor:u.cursor,cursorPlacementSafe:!0,markerOnly:u.markerOnly}}collectIfFrontmatter(t){return this.suppressFrontmatterCollection?t():this.formatter.withTemplatePropertyCollection(t)}mergeCapturePropertyVars(t){if(!(!t||t.size===0)){for(let[n,i]of t)this.capturePropertyVars.set(n,i);I.logMessage(`CaptureChoiceEngine: Accumulated ${this.capturePropertyVars.size} structured capture variables`)}}async applyCapturePropertyVars(t){return this.capturePropertyVars.size===0?!1:hh(t,this.capturePropertyVars)?(I.logMessage(`CaptureChoiceEngine: Post-processing front matter with ${this.capturePropertyVars.size} capture variables`),await gh(this.app,t,this.capturePropertyVars),this.capturePropertyVars.clear(),!0):(this.capturePropertyVars.clear(),!1)}};Ob();var Eo=require("obsidian");rn();xt();ur();dt();bt();Lg();var v$=require("obsidian");Xe();Zo();ht();xt();function T6(r){let e=r.split("/").pop()??r,t=e.lastIndexOf(".");return t>0?e.slice(0,t):e}function y$(r){let e=new ou(T6(r));return e.id=`folder-template:${r}`,e.templatePath=r,e.openFile=!0,e.fileNameFormat={enabled:!0,format:Or},e.discoverExistingNotesBeforeCreate=!0,e}function b$(r){return ri(r.settings.templateFolderPaths).length>0}function Dle(r,e){let t=r.lastIndexOf("/"),n=t===-1?"":r.slice(0,t),i=e.createDiv({cls:"suggestion-content"});i.createDiv({cls:"suggestion-title",text:T6(r)}),n&&(e.classList.add("mod-complex"),i.createDiv({cls:"suggestion-note",text:n}))}async function Fle(r,e){let n=[...e].sort((i,o)=>i.path.localeCompare(o.path)).map(i=>i.path);try{return await Xt.Suggest(r,n,n,"New note from template",(i,o)=>Dle(i,o))}catch(i){if(ot(i))return null;throw i}}async function YS(r,e,t){try{let n=t.templatePath?.trim()||void 0;if(!n){if(!b$(e)){new v$.Notice("QuickAdd: Set a template folder in Settings \u2192 QuickAdd \u2192 Templates & properties to use \u201CNew note from template\u201D.",8e3),Zm(r,e.manifest.id,{notice:!1});return}let i=e.getTemplateFiles();if(i.length===0){new v$.Notice("QuickAdd: No template files found in your configured template folder(s).");return}let o=await Fle(r,i);if(!o)return;n=o}await t.choiceExecutor.execute(y$(n))}catch(n){if(ot(n))re
2026-01-05 19:25:56 +08:00
${o}
2026-01-05 19:25:56 +08:00
QuickAdd will now revert to backup.`),r.settings=n,X.replaceState(Ve(r.settings))}}r.saveSettings()}var Y6=pce;dt();var Na=require("obsidian");Ie();async function fce(r,e,t){let n=await(0,Na.requestUrl)({url:`https://api.github.com/repos/${r}/${e}/releases`,throw:!1}),i=n.json;if(n.status>=400||!Array.isArray(i)){let a=typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:"Unknown error";throw new Error(`Failed to fetch releases: ${a}`)}let o=i,s=o.findIndex(a=>a.tag_name===t);if(s===-1)throw new Error(`Could not find release with tag ${t}`);return o.slice(0,s).filter(a=>!a.draft&&!a.prerelease)}var T$=/^https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+$/,K6=/^\[!\[[^\]]*\]\(([^)\s"]+)\)\]\((https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+)\)$/,mce=/^<!--\s*poster:\s*(https:\/\/[^\s"'>]+)\s*-->$/;function hce(r,e){let t=e?` poster="${e}"`:"";return`<video controls preload="metadata" playsinline style="width: 100%; border-radius: 8px;" src="${r}"${t}></video>`}function gce(r){let e=r.split(`
`),t=new Set;for(let s of e){let a=s.trim();T$.test(a)&&t.add(a)}let n=new Map;for(let s of e){let a=s.trim().match(K6);a&&t.has(a[2])&&n.set(a[2],a[1])}let i=new Set;for(let s=0;s<e.length;s++)if(T$.test(e[s].trim()))for(let a of[1,-1]){let l=s+a;for(;l>=0&&l<e.length&&e[l].trim()==="";)l+=a;let c=l>=0&&l<e.length?e[l].trim().match(mce):null;if(c){n.set(e[s].trim(),c[1]),i.add(l);break}}let o=[];for(let s=0;s<e.length;s++){let a=e[s],l=a.trim();if(i.has(s))continue;let c=l.match(K6);if(!(c&&t.has(c[2]))){if(T$.test(l)){o.push(hce(l,n.get(l)));continue}o.push(a)}}return o.join(`
`)}function vce(r,e=1){let t=r.split(`
`);for(let n=0;n<t.length;n++)t[n].startsWith("#")&&(t[n]="#".repeat(e)+t[n]);return t.join(`
`)}var t_=class extends Na.Modal{constructor(t,n){super(t);this.markdownComponent=new Na.Component;this.isClosed=!1;this.previousVersion=n,this.releaseNotesPromise=fce("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=>{I.logError(`Failed to fetch release notes: ${i}`)})}onOpen(){let{contentEl:t}=this;t.empty(),t.createEl("h1",{text:"Fetching release notes..."}),this.addCloseFooter()}addCloseFooter(){let t=this.contentEl.createDiv("quickadd-update-modal-footer");new Na.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");let n=`### 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=>gce(d.body??"")).join(`
2026-01-05 19:25:56 +08:00
---
`),l=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,u=`${n}
${i}
${o}
2026-01-05 19:25:56 +08:00
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.
${l}
2026-01-05 19:25:56 +08:00
---
${vce(a)}`;this.markdownComponent.load(),Na.MarkdownRenderer.render(this.app,u,s,this.app.vault.getRoot().path,this.markdownComponent),this.addCloseFooter()}};Lk();Jr();Jr();function ui(r,e){if(Object.is(r,e))return!0;if(r===null||e===null)return r===e;if(typeof r!=typeof e)return!1;if(Array.isArray(r)||Array.isArray(e))return!Array.isArray(r)||!Array.isArray(e)||r.length!==e.length?!1:r.every((t,n)=>ui(t,e[n]));if(typeof r=="object"&&typeof e=="object"){let t=r,n=e,i=Object.keys(t),o=Object.keys(n);return i.length!==o.length?!1:i.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&ui(t[s],n[s]))}return!1}function ku(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)&&Object.getPrototypeOf(r)===Object.prototype}function yce(r){return ku(r)&&typeof r.name=="string"&&Array.isArray(r.models)}function bce(r){return ku(r)&&typeof r.name=="string"&&typeof r.maxTokens=="number"&&!Array.isArray(r.models)}function wce(r){if(typeof r.id=="string"&&r.id.trim().length>0)return`id:${r.id.trim().toLowerCase()}`;let e=String(r.name??"").trim().toLowerCase(),t=String(r.endpoint??"").trim().toLowerCase().replace(/\/+$/,"");return`name:${e}\0${t}`}function Cce(r){return String(r.name??"").trim().toLowerCase()}function Q6(r,e){let t=new Map;for(let n of r){if(!ku(n))continue;let i=e(n);!i||i==="id:"||i==="name:\0"||t.has(i)||t.set(i,n)}return t}function xce(r,e,t,n,i){let o=Q6(r??[],n),s=Q6(t,n),a=[],l=new Set;for(let c of e){if(!ku(c)){a.push(Ve(c));continue}let u=n(c);if(l.has(u))continue;l.add(u);let d=o.get(u),p=s.get(u);if(!s.has(u)){(!o.has(u)||!ui(c,d))&&a.push(Ve(c));continue}a.push(qh(d,c,p,i))}for(let c of t){if(!ku(c))continue;let u=n(c);l.has(u)||(l.add(u),o.has(u)||a.push(Ve(c)))}return a}function qh(r,e,t,n=[]){if(ui(e,t))return Ve(e);if(ui(e,r))return Ve(t);if(ui(t,r))return Ve(e);if(ku(r)&&ku(e)&&ku(t)){let a=new Set([...Object.keys(r),...Object.keys(e),...Object.keys(t)]),l={};for(let c of a)l[c]=qh(r[c],e[c],t[c],[...n,c]);return l}let i=Array.isArray(r)?r:void 0,o=Array.isArray(e)?e:void 0,s=Array.isArray(t)?t:void 0;if(o&&s){let a=n[n.length-1],l=[...o,...s,...i??[]],c=a==="providers"&&l.every(yce)?wce:a==="models"&&l.every(bce)?Cce:void 0;if(c)return xce(i,o,s,c,n)}return Ve(e)}function Ece(r,e){return!ui(r,e)}function Tce(r,e,t){return r==null||t==null?{toWrite:e,didMerge:!1}:Ece(r,t)?{toWrite:qh(r,e,t),didMerge:!0}:{toWrite:e,didMerge:!1}}function X6(r){let e=r.local,{toWrite:t,didMerge:n}=Tce(r.base,e,r.disk);ui(r.currentStore,e)||(t=qh(e,r.currentStore,t),e=r.currentStore,n=!0);let i=n&&ui(r.currentStore,e)&&!ui(t,r.currentStore);return{toWrite:t,didMerge:n,local:e,shouldReplaceStore:i}}function Z6(r,e,t){return!ui(r,e)&&ui(e,t)}function k$(r){if(r===!0||r==="true")return!0;if(r===!1||r==="false")return!1}function J6(r,e){if(e.cancelled!==void 0&&typeof e.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)return null;if(r==="confirm"){let t=e.value;if(k$(t)===void 0)return`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${S$(t)}.`}return null}function S$(r){return r===void 0?"no value":r===null?"null":typeof r=="string"?JSON.stringify(r.slice(0,40)):typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?"an array":typeof r}ur();Yn();var kce=25e3,Sce=6e4,_ce=3e4,Ace=75e3,Ice=32;function Dce(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}function Fce(r){if(r.origin||r.referer)return!1;let e=(r.host??"").split(":")[0];return e==="127.0.0.1"||e==="localhost"}function Pce(r){try{let e=window.require;return e?e(r):null}catch{return null}}function r_(){let r=window.crypto;if(r?.randomUUID)return r.randomUUID();if(r?.getRandomValues){let e=r.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}throw new Error("Interactive prompts require a secure random source (crypto), which is unavailable here.")}var n
2026-01-05 19:25:56 +08:00
/* nosourcemap */