Files
StudyDiary/.obsidian/plugins/quickadd/main.js
T

421 lines
1.2 MiB
JavaScript
Raw Normal View History

2026-07-23 20:36:13 +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
*/
2026-08-02 09:03:32 +08:00
var k7=Object.create;var tv=Object.defineProperty;var S7=Object.getOwnPropertyDescriptor;var D7=Object.getOwnPropertyNames;var I7=Object.getPrototypeOf,P7=Object.prototype.hasOwnProperty;var LN=r=>{throw TypeError(r)};var F7=(r,e,t)=>e in r?tv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var b=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var M7=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Zr=(r,e)=>{for(var t in e)tv(r,t,{get:e[t],enumerable:!0})},BN=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D7(e))!P7.call(r,i)&&i!==t&&tv(r,i,{get:()=>e[i],enumerable:!(n=S7(e,i))||n.enumerable});return r};var UN=(r,e,t)=>(t=r!=null?k7(I7(r)):{},BN(e||!r||!r.__esModule?tv(t,"default",{value:r,enumerable:!0}):t,r)),R7=r=>BN(tv({},"__esModule",{value:!0}),r);var le=(r,e,t)=>F7(r,typeof e!="symbol"?e+"":e,t),nI=(r,e,t)=>e.has(r)||LN("Cannot "+t);var H=(r,e,t)=>(nI(r,e,"read from private field"),t?t.call(r):e.get(r)),it=(r,e,t)=>e.has(r)?LN("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),et=(r,e,t,n)=>(nI(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),xt=(r,e,t)=>(nI(r,e,"access private method"),t);var P2,F2,M2=b(()=>{P2=r=>{let e,t=new Set,n=(c,u)=>{let d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){let f=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(p=>p(e,f))}},i=()=>e,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(t.add(c),()=>t.delete(c))},l=e=r(n,i,a);return a},F2=(r=>r?P2(r):P2)});function Rv(r){if(r.kind)return r.kind;let e=(r.name??"").toLowerCase(),t=JX(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 JX(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 eQ(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function dT(r,e){let t=eQ(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 pT(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=dT(n.id??n.name,r),t.add(n.id),e=!0}return e}function mu(r,e){return e&&e.name===r?e:void 0}function fT(r){return $v[r].map(e=>({...e}))}var $v,R2,tQ,rQ,mT,es=b(()=>{$v={openai:[{name:"gpt-5.5",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4-mini",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4-nano",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-4.1",maxTokens:1047576,maxOutputTokens:32768,supportsTemperature:!0},{name:"gpt-4.1-mini",maxTokens:1047576,maxOutputTokens:32768,supportsTemperature:!0},{name:"gpt-4o",maxTokens:128e3,maxOutputTokens:16384,supportsTemperature:!0},{name:"gpt-4o-mini",maxTokens:128e3,maxOutputTokens:16384,supportsTemperature:!0},{name:"o3",maxTokens:2e5,maxOutputTokens:1e5,supportsTemperature:!1},{name:"o4-mini",maxTokens:2e5,maxOutputTokens:1e5,supportsTemperature:!1}],google:[{name:"gemini-3.5-flash",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3.1-pro-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3.1-flash-lite",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3-pro-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3-flash-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-pro",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-flash",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-flash-lite",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0}],anthropic:[{name:"claude-fable-5",maxTokens:1e6,maxO
`)}function Nv(r){let e=Object.entries(r);if(e.length===0)return[];let n=["t","tm","yd"].map(s=>{let a=r[s];return a?[s,a]:null}).filter(s=>s!==null),i=new Set(n.map(([s])=>s)),o=e.filter(([s])=>!i.has(s)).sort((s,a)=>{let l=s[0].length-a[0].length;return l!==0?l:s[0].localeCompare(a[0])});return[...n,...o]}function hT(r){return Nv(r).map(([e,t])=>`${e}=${t}`).join(", ")}var Kf,Wd=b(()=>{Kf={t:"today",tm:"tomorrow",yd:"yesterday",nw:"next week",nm:"next month",ny:"next year",lw:"last week",lm:"last month",ly:"last year"}});var gT,a0=b(()=>{es();Wd();gT={choices:[],inputPrompt:"single-line",persistInputPromptDrafts:!0,useSelectionAsCaptureValue:!0,searchNestedChoices:!0,templateFolderLauncherRow:"bottom",devMode:!1,templateFolderPaths:[],announceUpdates:"major",version:"0.0.0",globalVariables:{},onePageInputEnabled:!1,disableOnlineFeatures:!0,enableUriCallbacks:!1,enableRibbonIcon:!1,showCaptureNotification:!0,showInputCancellationNotification:!1,enableTemplatePropertyTypes:!1,dateAliases:Kf,ai:{defaultModel:"Ask me",defaultSystemPrompt:'As an AI assistant within Obsidian, your primary goal is to help users manage their ideas and knowledge more effectively. Format your responses using Markdown syntax. Please use the [[Obsidian]] link format. You can write aliases for the links by writing [[Obsidian|the alias after the pipe symbol]]. To use mathematical notation, use LaTeX syntax. LaTeX syntax for larger equations should be on separate lines, surrounded with double dollar signs ($$). You can also inline math expressions by wrapping it in $ symbols. For example, use $$w_{ij}^{\\text{new}}:=w_{ij}^{\\text{current}}+\\eta\\cdot\\delta_j\\cdot x_{ij}$$ on a separate line, but you can write "($\\eta$ = learning rate, $\\delta_j$ = error term, $x_{ij}$ = input)" inline.',promptTemplatesFolderPath:"",showAssistant:!0,providers:mT,confirmToolCalls:"destructive"},migrations:{migrateToMacroIDFromEmbeddedMacro:!0,useQuickAddTemplateFolder:!1,incrementFileNameSettingMoveToDefaultBehavior:!1,consolidateFileExistsBehavior:!1,repairTemplateFileExistsBehavior:!1,mutualExclusionInsertAfterAndWriteToBottomOfFile:!1,setVersionAfterUpdateModalRelease:!1,addDefaultAIProviders:!1,removeMacroIndirection:!1,migrateFileOpeningSettings:!1,backfillFileOpeningDefaults:!1,setProviderModelDiscoveryMode:!1,migrateProviderApiKeysToSecretStorage:!1,migrateToMultipleTemplateFolders:!1,refreshStaleDefaultModelSeeds:!1,pinAiModelRefs:!1}}});function ht(r){if(typeof structuredClone=="function")try{return structuredClone(r)}catch{}return hu(r,new Map)}function hu(r,e){if(r===null||typeof r!="object")return r;if(e.has(r))return e.get(r);if(r instanceof Date){let i=new Date(r.getTime());return e.set(r,i),i}if(Array.isArray(r)){let i=[];e.set(r,i);for(let o of r)i.push(hu(o,e));return i}if(r instanceof Map){let i=new Map;e.set(r,i);for(let[o,s]of r.entries())i.set(hu(o,e),hu(s,e));return i}if(r instanceof Set){let i=new Set;e.set(r,i);for(let o of r.values())i.add(hu(o,e));return i}if(r instanceof RegExp){let i=new RegExp(r.source,r.flags);return i.lastIndex=r.lastIndex,e.set(r,i),i}if(r instanceof ArrayBuffer){let i=r.slice(0);return e.set(r,i),i}if(ArrayBuffer.isView(r)){if(r instanceof DataView){let a=new DataView(hu(r.buffer,e),r.byteOffset,r.byteLength);return e.set(r,a),a}let i=r,o=hu(i.buffer,e),s=new i.constructor(o,i.byteOffset,i.length);return e.set(r,s),s}let t=Object.getPrototypeOf(r),n=Object.create(t);e.set(r,n);for(let[i,o]of Object.entries(r))Object.defineProperty(n,i,{value:hu(o,e),writable:!0,enumerable:!0,configurable:!0});return n}var vi=b(()=>{});var ce,It=b(()=>{M2();a0();vi();ce=(()=>{let r=F2((i,o)=>({...ht(gT)})),{getState:e,setState:t,subscribe:n}=r;return{getState:e,replaceState:i=>t(i,!0),setState:t,subscribe:n}})()});var zd,Lv,F,Me=b(()=>{zd=class zd{register(e){return zd.loggers.push(e),this}logError(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=e instanceof Error?e:void 0;zd.loggers.forEach(o=>o.logError(t,n,i))}logWarning(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=
`)?`${r}${e}`:`${r}
${e}`}async function kT(r,e,t){let n=t.destination;if(n?.type!=="specifiedFile")return!1;let i=zv(r,n);if(!i)throw new Error(`Append link target file not found or is not a Markdown file: ${n.path}`);let o=AT(r,e,{sourcePath:i.path,linkType:"link"});return await r.vault.process(i,s=>PQ(s,o)),!0}async function FQ(r){let e=window.navigator?.clipboard;if(!e?.writeText)return F.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{return await e.writeText(r),!0}catch(t){return F.logMessage(`QuickAdd: Could not copy link to clipboard: ${t instanceof Error?t.message:String(t)}`),!1}}async function ST(r){let e=IQ(r);return await FQ(e)?(new Wv.Notice(`Copied link to '${r.basename}' to clipboard.`,EB),!0):(new Wv.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,EB),!1)}var Wv,EB,Hv=b(()=>{Wv=require("obsidian");Me();Jd();EB=4e3});function ts(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 ep(r){let e=ts(r).defaultView;if(!e)throw new Error("Unable to resolve owner window for DOM node.");return e}function zr(r,e){return ts(r).createElement(e)}function jv(r,e){return ts(r).createTextNode(e)}var fc=b(()=>{});function DT(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=ts(t.containerEl).activeElement;if(!n||!t.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(MQ))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 RQ(r,e,t){let n=e.trim();if(!n)throw new Error("Cannot append link to an empty frontmatter property key.");let i=kB(r,n),o=r[i];if(Array.isArray(o)){o.push(t);return}if(o==null||o===""){r[i]=t;return}if(typeof o=="string"){r[i]=`${o} ${t}`;return}throw new Error(`Cannot append link to frontmatter property '${i}' because it contains a ${typeof o} value.`)}function AB(r,e,t,n=Qd){let i=e.trim();if(!i)throw new Error("Cannot append link to an empty frontmatter property key.");let o=kB(r,i),s=r[o];if(Array.isArray(s)){s.push(t);return}if(s===null||s===""){r[o]=[t];return}if(s===void 0){if(n==="error")throw new Error(`Cannot append link to frontmatter property '${o}' because it does not exist.`);r[o]=[t];return}if(typeof s=="object")throw new Error(`Cannot append link to frontmatter property '${o}' because it contains an object value.`);if(n!=="alwaysAppend")throw new Error(`Cannot append link to frontmatter property '${o}' because it is not a list and the link-handling mode is '${TB[n]}'. Choose '${TB.alwaysAppend}' to convert it into a list and append.`);r[o]=[s,t]}function kB(r,e){let t=_B(e),n=Object.keys(r).filter(i=>_B(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 _B(r){return r.trim().toLowerCase()}async function IT(r,e,t){let n=r.fileManager.generateMarkdownLink(t,e.file.path);try{return await r.fileManager.processFrontMatter(e.file,i=>{RQ(i,e.key,n)}),!0}catch(i){return F.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 TB,MQ,nm=b(()=>{Me();Jd();fc();TB={alwaysAppend:"Create or convert",createProperty:"Create if missing",error:"Require list"},MQ=['input[type="number"]','input[type="date"]','input[type="datetime-local"]','input[type="time"]','input[type="month"]','input[type="checkbox"]'].join(", ")});function Gv(r,e){let t=On(r);return t?.file?.path===e.path?t:null}function k0(r,e){try{let t=On(e);return t?(t.editor.replaceSelection(r),!0):(F.logError(`unable to append '${r}' to current line.`),!1)}catch{return F.logError(`unable to append '${r}' to current line.`),!1}}function S0(r,e,t){try{let n=On(t);if(!n)return F.logError(`unable to insert '${r}' on new line ${e}.`),!1;let i=n.editor,s=
`),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 F.logError(`unable to insert '${r}' on new line ${e}.`),!1}}function D0(r,e){return S0(r,"above",e)}function I0(r,e){return S0(r,"below",e)}function $Q(r,e,t,n){let i=l=>r.posToOffset(l),o=e.map(l=>{let[c,u]=i(l.anchor)<=i(l.head)?[l.anchor,l.head]:[l.head,l.anchor];return{from:c,to:u,text:n(r.getRange(c,u))}}).sort((l,c)=>i(l.from)-i(c.from)),s=o.map(({from:l,to:c,text:u})=>t==="replaceSelection"?{from:l,to:c,text:u}:{from:c,text:u}),a=[];if(t==="replaceSelection"){let l=0;for(let{from:c,to:u,text:d}of o)a.push(i(c)+l+d.length),l+=d.length-(i(u)-i(c))}r.transaction({changes:s}),t==="replaceSelection"&&r.setSelections(a.map(l=>({anchor:r.offsetToPos(l)})))}async function SB(r,e,t="replaceSelection",n={}){let{requireActiveView:i=!0,frontmatterProperty:o,frontmatterHandling:s=Qd,textForSelection:a}=n,l=r.workspace.getActiveViewOfType(PT.MarkdownView);if(!l){let p="Cannot append link because no active Markdown view is available.";if(i)throw new Error(p);F.logMessage(p);return}if(t==="inFrontmatter"){let p=l.file;if(!p)throw new Error("Cannot append link because the active Markdown view has no file.");await r.fileManager.processFrontMatter(p,m=>{AB(m,o??"",e,s)});return}let c=l.editor;if(!c){let p="Cannot append link because the active Markdown view has no editor.";if(i)throw new Error(p);F.logMessage(p);return}let u=c.listSelections().map(p=>({anchor:{...p.anchor},head:{...p.head}}));if(a&&u.length>0&&(t==="replaceSelection"||t==="afterSelection")){$Q(c,u,t,a);return}if(t==="replaceSelection"){c.replaceSelection(e);return}let d=({line:p,ch:m})=>c.posToOffset({line:p,ch:m}),f=u.sort((p,m)=>d(m.head)-d(p.head));for(let p of f){let m=d(p.anchor)>d(p.head)?p.anchor:p.head;switch(t){case"afterSelection":{c.replaceRange(e,m);break}case"endOfLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length};c.replaceRange(e,g);break}case"newLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length},w=v.length===0?"":`
`;c.replaceRange(w+e,g);break}}}}async function tp(r,e,t){if(!t?.enabled)return!1;let n=xu(t),i=r.workspace.getActiveViewOfType(PT.MarkdownView),o=n.placement!=="inFrontmatter";if(!i||!i.file||o&&!i.editor){if(t.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let s=i.file.path,a=AT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement}),l=n.displayText==="selection"?c=>AT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement,alias:c}):void 0;return await SB(r,a,n.placement,{requireActiveView:!1,frontmatterProperty:n.frontmatterProperty,frontmatterHandling:n.frontmatterHandling,textForSelection:l}),!0}function P0(r,e,t,n){try{if(e.extension!=="md"||!Number.isSafeInteger(t)||t<0||t>n.length)return!1;let i=r.workspace.getActiveViewOfType(PT.MarkdownView);if(!i||i.file?.path!==e.path||i.getMode()==="preview")return!1;let o=i.editor;return!o||o.getValue()!==n?!1:(o.setCursor(o.offsetToPos(t)),!0)}catch{return F.logMessage(`Unable to place cursor after capture in '${e.path}'.`),!1}}var PT,DB=b(()=>{PT=require("obsidian");Cu();Me();Jd();Hv();nm()});function FT(r){return ir.test(r)||qr.test(r)||Vi.test(r)}function po(r,e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let n=FT(t)?t:`${t}.md`,i=r.vault.getAbstractFileByPath(n);return i instanceof IB.TFile?i:null}function Wi(r){if(!Array.isArray(r))return[];let e=new Set,t=[];for(let n of r){if(typeof n!="string")continue;let i=n.trim().replace(/^\/+/,"").replace(/\/+$/,"");!i||e.has(i)||(e.add(i),t.push(i))}return t}function F0(r,e){return e.length===0?!0:e.some(t=>r===t||r.startsWith(`${t}/`))}var IB,MT=b(()=>{IB=require("obsidian");Tt()});function FB(r){if(!r)return!1;let e=r,t=e.getViewState?.();return!!e.pinned||!!t?.pinned||!!t?.state?.pinned}function Yv(r){let e=r.workspace;return(e.rootSplit?e.getMostRecentLeaf?.(e.rootSplit):null)??e.getMostRecentLeaf?.()??null}function OQ(r){let e=[];return r.workspace.iterateRootLeaves(t=>{e.includes(t)||e.push(t)}),e}function PB(r){return r.parent?.id??r.parent??null}function NQ(r,e){let t=PB(e),n=r.filter(s=>s===e||FB(s)?!1:t===null||PB(s)!==t);if(n.length===0)return null;let i=r.indexOf(e);return(i===-1?r:[...r.slice(i+1),...r.slice(0,i)]).find(s=>n.includes(s))??n[0]}function LQ(r){return r instanceof im.TFile?!0:typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"&&"extension"in r&&typeof r.extension=="string"}function BQ(r,e,t,n){if(n&&(e==="tab"||e==="reuse")&&FB(n))return NQ(OQ(r),n)??r.workspace.getLeaf("tab");switch(e){case"reuse":return r.workspace.getLeaf(!1);case"tab":return r.workspace.getLeaf("tab");case"split":return r.workspace.getLeaf("split",t);case"window":return r.workspace.getLeaf("window");case"left-sidebar":return r.workspace.getLeftLeaf(!0);case"right-sidebar":return r.workspace.getRightLeaf(!0);default:return r.workspace.getLeaf("tab")}}async function mc(r,e,t={}){let{location:n="tab",direction:i="vertical",mode:o,focus:s=!0,eState:a,originLeaf:l}=t,c=typeof e=="string"?r.vault.getAbstractFileByPath(e):e;if(!LQ(c)){let f=typeof e=="string"?e:e.path;throw new Error(`File not found: ${f}`)}let u=l??Yv(r),d=BQ(r,n,i,u);if(!d)throw new Error("Could not obtain a workspace leaf.");if(await d.openFile(c),o&&o!=="default"&&!(typeof o=="object"&&o.mode==="default")){let f=d.getViewState(),p={...f.state??{}};o==="preview"||typeof o=="object"&&o.mode==="preview"?(p.mode="preview",delete p.source):o==="source"?(p.mode="source",p.source=!0):o==="live"||o==="live-preview"?(p.mode="source",p.source=!1):typeof o=="object"&&o.mode==="source"&&(p.mode="source",p.source=o.source),await d.setViewState({...f,state:{...p,...a}})}return s&&r.workspace.setActiveLeaf(d,{focus:!0}),d}function M0(r){return(0,im.normalizePath)(r).replace(/\/{2,}/g,"/").replace(/^\/+/,"")}function MB(r,e){return M0(r)===M0(e)}function rp(r,e,t=!0){let n;return r.workspace.iterateRootLeaves(i=>{let o=i.view;if(o instanceof im.FileView&&o.file&&(o.file===e||MB(e.path,o.file.path))){n=i;return}}),n!==void 0?(t&&r.workspace.setActiveLeaf(n,{focus:!0}),n):null}var im,R
`,e),l=a===-1?r.length:a,c=r.slice(e,l).replace(/\r$/,""),u=a===-1?r.length+1:a+1,d=UQ.exec(c);if(n){if(d&&d[1].length>=i&&d[2].trim().length===0)return $B(r.slice(o,e),s)}else if(d){let f=d[2].trim().split(/\s+/)[0]?.toLowerCase();(f==="js"||f==="javascript")&&(n=!0,i=d[1].length,o=u,s=t+1)}if(e=u,t++,a===-1)break}return n?$B(r.slice(o),s):{code:null,error:VQ}}function $B(r,e){return r.trim().length===0?{code:"",error:qQ}:{code:`
`.repeat(e)+r}}var UQ,VQ,qQ,Kv=b(()=>{UQ=/^ {0,3}(`{3,})(.*)$/,VQ="No ```js (or ```javascript) code block found in the note.",qQ="The ```js code block is empty."});function OB(r){return r instanceof RT}function zQ(r){return r.charCodeAt(0)===65279?r.slice(1):r}function HQ(r){return zQ(r).trimStart().slice(0,WQ).toLowerCase()}function jQ(r){return/^<(?:!doctype\s+html|html\b|head\b|body\b|script\b|meta\b|title\b|div\b)/.test(HQ(r))}function R0(r,e){let t=new RT(r);throw e.reportLoadErrors!==!1&&lt(t),t}function GQ(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 YQ(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 KQ(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 XQ(r){return NB(r)?(r instanceof Error?r.message:String(r)).match(/Cannot find module ['"]([^'"]+)['"]/)?.[1]:void 0}function NB(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 QQ(r){return r!==null&&typeof r=="object"}function ZQ(r){return typeof r.entry=="function"?!0:Object.entries(r).some(([e,t])=>e!=="settings"&&e!=="quickadd"&&typeof t=="function")}function JQ(r){return typeof r=="function"?!0:QQ(r)?ZQ(r):!1}function np(r){let e=r.split("::").map(t=>t.trim()).filter(Boolean);return{basename:e[0],memberAccess:e.slice(1)}}function OT(r){let e=r.path??r.id;if(e===void 0)return;let{memberAccess:t}=np(r.name??"");return t&&t.length>0?`${e}::${t.join("::")}`:e}async function Aa(r,e,t={}){let n=e.vault.getAbstractFileByPath(r.path);if(!n){F.logError(`failed to load file ${r.path}.`);return}if(n instanceof $T.TFile){let i=m=>window.require&&window.require(m),o={},s={exports:o},a=await e.vault.read(n),l=a;if(ir.test(n.path)){let{code:m,error:v}=hc(a);if(m===null||m.length===0){t.reportLoadErrors!==!1&&new $T.Notice(`QuickAdd: ${v} (${r.path})`);return}l=m}jQ(l)&&R0(GQ(r.path),t);try{new Function("require","module","exports",l)(i,s,o)}catch(m){throw NB(m)&&R0(KQ(r.path,XQ(m)),t),m}let c=o.default||s.exports;if(!c)return;let u=c,d=!!o.default,{memberAccess:f}=np(r.name),p=!!(f&&f.length>0);if(f&&f.length>0){let m;for(;m=f.shift();)u=u[m]}return d&&!p&&!JQ(u)&&R0(YQ(r.path),t),u}}var $T,WQ,RT,NT=b(()=>{$T=require("obsidian");Tt();Me();Kv();Cr();WQ=1024,RT=class extends Error{constructor(e){super(e),this.name="UserScriptLoadError"}}});function gc(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 Eu(r){return r==null?[]:(Array.isArray(r)?r:typeof r=="string"?r.split(/,|\s+/):[r]).map(gc).filter(Boolean)}var LT=b(()=>{});var zi,ip=b(()=>{LT();zi=class{static filterFiles(e,t,n){let i=e;return i=this.applyInclusionFilters(i,t,n),i=this.applyExclusionFilters(i,t,n),i}static applyInclusionFilters(e,t,n){let i=!1,o=e,s=this.getIncludeFolders(t);return s.length>0&&(i=!0,o=o.filter(a=>s.some(l=>this.matchesFolder(a,l)))),t.tags&&t.tags.length>0&&(i=!0,o=o.filter(a=>this.matchesAllTags(a,t.tags??[],n))),i?o:e}static applyExclusionFilters(e,t,n){return e.filter(i=>!(t.excludeFolders&&t.excludeFolders.length>0&&t.excludeFolders.some(o=>this.matchesFolder(i,o))||t.excludeTags&&t.excludeTags.length>0&&this.matchesAnyTag(i,t.excludeTags,n)||t.excludeFiles&&t.excludeFiles.length>0&&t.excludeFiles.some(o=>this.matchesFile(i,o))))}static getIncludeFolders(e){let t=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...new Set(t.map(n=>this.normalizePath(n)).filter
`:" "))}catch(m){F.logError(`Failed to insert pasted image link: ${m instanceof Error?m.message:String(m)}`),new m_.Notice("QuickAdd: saved the pasted image but could not insert its link.")}}return e.addEventListener("paste",c),e.addEventListener("compositionstart",a),e.addEventListener("compositionend",l),{isBusy:()=>i!==null,whenIdle:()=>i??Promise.resolve(),detach:()=>{o=!0,e.removeEventListener("paste",c),e.removeEventListener("compositionstart",a),e.removeEventListener("compositionend",l)}}}function ree(r){let e=mV.then(r,r);return mV=e.catch(()=>{}),e}function hV(r){return Object.hasOwn(dy,r)}function nee(r){let e=[];for(let t of Array.from(r.items??[])){if(t.kind!=="file"||!hV(t.type))continue;let n=t.getAsFile();n&&e.push({file:n,mimeType:t.type})}if(e.length>0)return e;for(let t of Array.from(r.files??[]))hV(t.type)&&e.push({file:t,mimeType:t.type});return e}function iee(r,e){r.focus();let t=!1;try{t=r.ownerDocument.execCommand("insertText",!1,e)}catch{t=!1}if(t)return;let n=r.selectionStart??r.value.length,i=r.selectionEnd??n;r.setRangeText(e,n,i,"end"),r.dispatchEvent(new Event("input",{bubbles:!0}))}var m_,mV,h_=b(()=>{m_=require("obsidian");Me();MP();mV=Promise.resolve()});function RP(r){return!r.isComposing&&r.key==="Enter"&&r.shiftKey&&(r.ctrlKey||r.metaKey)}var km,Sr,zs=b(()=>{km=require("obsidian");SP();DP();IP();PP();FP();h_();Wr();Sr=class r extends km.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.isOptionalPrompt&&RP(t)){t.preventDefault(),this.skip();return}!t.isComposing&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new _m({kind:"single",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.display(),this.open(),this.fileSuggester=new xm(t,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Em(t,this.inputComponent.inputEl)}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,d_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}get isOptionalPrompt(){return this.options?.optional===!0}createInputField(t,n,i){let o=new km.TextComponent(t);return o.inputEl.setCssStyles({width:"100%"}),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.options?.imagePaste&&(this.imagePasteHandle=Am(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new km.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}createButtonBar(t){let n=t.createDiv();if(this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let i=this.createButton(n,"Skip",this.skipClickCallback);i.setTooltip("Leave this field empty"),i.buttonEl.setAttribute("aria-label","Skip and leave empty")}n.setCssStyles({display:"flex",flexDirection:"row-reverse",justifyContent:"flex-start",marg
`,e-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),f=(u.match(/^\s*/)||[""])[0],p=r[e-1]==='"'&&r[t]==='"'||r[e-1]==="'"&&r[t]==="'",m=u.replace(/["']$/,""),g=d.replace(/^["']/,"").replace(/\s+#.*$/,"").trim().length===0,y=/:\s*$/.test(m)&&g,w=/^\s*-\s*$/.test(m)&&g;return{isInYaml:!0,isQuoted:p,lineStart:a,lineEnd:c,baseIndent:f,isKeyValuePosition:y,isListItemPosition:w}}var LP=b(()=>{});function yy(r,e){if(!r||!e)return null;let t=r,n=t.metadataTypeManager??t.metadataCache?.app?.metadataTypeManager;if(!n||typeof n.getTypeInfo!="function")return null;let i=n.getTypeInfo(e),o=i?.expected?.type??i?.inferred?.type;return typeof o=="string"?o:null}function Ree(r){return r!==null&&Fee.has(r.toLowerCase())}function SV(r,e){return Mee.has(e.toLowerCase())||Ree(yy(r,e))}var Fee,Mee,A_=b(()=>{Fee=new Set(["aliases","list","multitext","tags"]),Mee=new Set(["aliases","cssclasses","tags"])});function $ee(r,e=","){let t=[],n="",i=[],o=null;for(let a=0;a<r.length;a++){let l=r[a];if(o){if(n+=l,l===o){let c=0;for(let u=a-1;u>=0&&r[u]==="\\";u--)c++;c%2===0&&(o=null)}continue}if(l==='"'){o=l,n+=l;continue}if(l in DV){i.push(DV[l]),n+=l;continue}if(i.length>0){let c=i[i.length-1];l===c&&i.pop(),n+=l;continue}if(l===e){let c=n.trim();c.length>0&&t.push(c),n="";continue}n+=l}let s=n.trim();return s.length>0&&t.push(s),t}function Oee(r){return r.includes(`
`)?r.replace(/\r?\n/g,`
`):r.includes("\\n")?r.replace(/\\n/g,`
`):r}function Nee(r){if(!r)return!1;let e=r.toLowerCase();return e==="list"||e==="tags"||e==="multitext"}function IV(r,e){let t=r.trim();if(!t)return;let n=Oee(t),i=e?.propertyType??yy(e?.app,e?.propertyKey),o=Nee(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=$ee(n);if(u.length>1)return u}}var DV,PV=b(()=>{A_();DV={"[":"]","(":")","{":"}","<":">"}});function k_(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 BP(r){return typeof r!="string"&&(Array.isArray(r)||typeof r=="object"&&r!==null||typeof r=="number"||typeof r=="boolean"||r===null)}function FV(r){return Array.isArray(r)||typeof r=="object"&&r!==null}function S_(r){if(BP(r))return Array.isArray(r)?"[]":r===null?"null":typeof r=="object"?"{}":String(r)}var by=b(()=>{});var MV,Fa,D_=b(()=>{LP();PV();by();A_();MV="\0",Fa=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=T_(t),u=__(t,n,i,c);if(!u.isInYaml)return;let d=t.slice(u.lineStart,u.lineEnd),f=d.trim(),p=d.match(/^\s*([^:]+):/),m=p?p[1].trim():s,v=/^-\s*['"]?\{\{(?:VALUE|FIELD|FILE):[^}]+\}\}['"]?\s*$/i,g=null;if(u.isKeyValuePosition?g=[m]:v.test(f)&&(g=this.findListParentPath(t,u.lineStart,u.baseIndent??"")),!g||g.length===0)return;let y=g[g.length-1],w=o;if(l&&typeof o=="string"){let C=IV(o,this.buildParseOptions(y));C!==void 0&&(w=C)}if(!BP(w)||!l&&!FV(w))return;let x=g.join(MV);return this.map.set(x,w),w}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 p=(d[1]??"").length;if(p<s&&(o.unshift(d[2].trim()),s=p,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=yy(this.app,e);return this.propertyTypeCache.set(e,t),t}};Fa.PATH_SEPARATOR=MV});function Pm(r){return Lee.has(r.toUpperCase())}var I_,P_,F_,Lee,M_=b(()=>{I_=new RegExp("[\0-]","u"),P_=/[\\/:*?"<>|]/u,F_=/[. ]$/u,Lee=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"])});function RV(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 WP(r){return RV(r)!==null}function UP(r){if(!r)return r;let e=r.toLowerCase();return e.slice(0,1).toUpperCase()+e.slice(1)}function VP(r){return/\p{L}/u.test(r)?/\p{Lu}/u.test(r)&&!/\p{Ll}/u.test(r):!1}function R_(r){return/\p{Lu}/u.test(r)&&/\p{Ll}/u.test(r)}function Bee(r){return/^\p{Ll}/u.test(r)&&R_(r)}function Uee(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 Vee(r){return r.split(/[^\p{L}\p{N}\p{M}]+/gu).filter(Boolean).flatMap(Uee).filter(Boolean)}function $_(r,e){let t=RV(e);if(!t)return r;if(t==="lower")return r.toLowerCase();if(t==="upper")return r.toUpperCase();let n=Vee(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?Bee(i)?i:i.toLowerCase():"",a=o.map(l=>VP(l)||R_(l)?l:UP(l));return[s,...a].join("")}case"pascal":return n.map(i=>VP(i)||R_(i)?i:UP(i)).join("");case"title":return n.map(i=>VP(i)||R_(i)?i:UP(i)).join(" ");case"slug":{let i=n.map(o=>o.toLowerCase()).join("-");return Pm(i)?`${i}-`:i}default:return r}}var qP,O_=b(()=>{M_();qP=["kebab","snake","camel","pascal","title","lower","upper","slug"]});function zP(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}function HP(r,e,t){let n=__(r,e,t,T_(r));return!n.isInYaml||n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}var $V=b(()=>{LP()});function N_(r){let e=r.trim();return e&&(/^\[\[.*\]\]$/.test(e)?e:`[[${e}]]`)}var jP=b(()=>{});function zee(r,e,t){return t&&e?`${r}${GP}${e}`:r}function Cy(r){let e=r.indexOf(GP);return e===-1?r:r.slice(0,e)}function Hee(r,e){let t=e.toLowerCase(),n=null;for(let i of r.keys())if(i.toLowerCase()===t&&r.get(i)!==void 0){if(n)return null;n=i}return n}function U_(r,e){if(!e)return null;let t=[e],n=Cy(e);n!==e&&t.push(n);for(let i of t){if(r.has(i)&&r.get(i)!==void 0)return i;let o=Hee(r,i);if(o)return o}return null}function jee(r){let{remaining:e,found:t}=ka(r,"optional");return{remaining:e,optional:t}}function BV(r){let{remaining:e,optional:t}=jee(r),{remaining:n,found:i}=ka(e,"trim");return{remaining:n,optional:t,trim:i}}function Gee(r,e){let t=r.trim();if(!t)return!1;let n=fo(t);return n?(e?YP:B_).has(n.key):!1}function Yee(r,e){let t=e?YP:B_;return r.some(n=>{let i=fo(n.trim());if(!i||i.key!=="type"||!t.has("type"))return!1;let o=i.value.trim().toLowerCase();return o==="number"||o==="slider"})}function UV(r,e,t,n,i){if(r.length===0)return{defaultValue:"",allowCustomInput:!1,usesOptions:!1};let o=t?YP:B_,s=Yee(r,t),a=r.some(V=>Gee(V,t)||s&&OV.has(fo(V.trim())?.key??"")),l=e&&r.some(V=>V.trim().toLowerCase()==="
`,n++):o=="\\"?(t+="\\",n++):t+="\\":t+=i}return t}expandLinebreakEscapesOutsideTokens(e){let t=Ay(e),n="",i=0,o=0;for(;i<e.length;){for(;o<t.length&&t[o].end<=i;)o++;let s=t[o];if(s&&s.start===i){n+=e.slice(s.start,s.end),i=s.end;continue}if(e[i]==="{"&&e[i+1]==="{"){let c=e.indexOf("}}",i+2),u=!1;if(c!==-1){let d=c+2;for(let f=o;f<t.length;f++){let p=t[f];if(p.start>=d)break;if(d<p.end&&d>p.start){u=!0;break}}}if(c!==-1&&!u){n+=e.slice(i,c+2),i=c+2;continue}}let a=e[i],l=e[i+1];a==="\\"?l==="n"?(n+=`
`,i+=2):l==="\\"?(n+="\\",i+=2):(n+="\\",i+=1):(n+=a,i+=1)}return n}replaceRandomInString(e){let t=e;for(;m0.test(t);){let n=m0.exec(t);if(!n||!n[1])continue;let i=parseInt(n[1]);if(i<=0||i>100)throw new Error(`Random string length must be between 1 and 100. Got: ${i}`);let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s="";for(let a=0;a<i;a++)s+=o.charAt(Math.floor(Math.random()*o.length));t=t.replace(n[0],s)}return t}replaceTitleInString(e){return this.replaceCurrentFileTokensInString(e,{title:!0})}}});var G,Oe,ls,pt=b(()=>{(function(r){r[r.AM=0]="AM",r[r.PM=1]="PM"})(G||(G={}));(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"})(Oe||(Oe={}));(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"})(ls||(ls={}))});function nt(r,e){r.assign("day",e.getDate()),r.assign("month",e.getMonth()+1),r.assign("year",e.getFullYear())}function W_(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?G.AM:G.PM)}function _c(r,e){r.imply("day",e.getDate()),r.imply("month",e.getMonth()+1),r.imply("year",e.getFullYear())}function Lt(r,e){r.imply("hour",e.getHours()),r.imply("minute",e.getMinutes()),r.imply("second",e.getSeconds()),r.imply("millisecond",e.getMilliseconds()),r.imply("meridiem",e.getHours()<12?G.AM:G.PM)}var nn=b(()=>{pt()});function Lu(r,e,t,n,i=0){let o=0,s=0;for(;s<n;)o++,new Date(r,e-1,o).getDay()===t&&s++;return new Date(r,e-1,o,i)}function ZV(r,e,t,n=0){let i=t===0?7:t,o=new Date(r,e-1+1,1,12),s=o.getDay()===0?7:o.getDay(),a;return s===i?a=7:s<i?a=7+s-i:a=s-i,o.setDate(o.getDate()-a),new Date(r,e-1,o.getDate(),n)}function z_(r,e,t={}){if(r==null)return null;if(typeof r=="number")return r;let n=t[r]??ste[r];return n==null?null:typeof n=="number"?n:e==null?null:e>n.dstStart(e.getFullYear())&&!(e>n.dstEnd(e.getFullYear()))?n.timezoneOffsetDuringDst:n.timezoneOffsetNonDst}var ste,JP=b(()=>{pt();ste={ACDT:630,ACST:570,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,ALMT:360,AMST:-180,AMT:-240,ANAST:720,ANAT:720,AQTT:300,ART:-180,AST:-240,AWDT:540,AWST:480,AZOST:0,AZOT:-60,AZST:300,AZT:240,BNT:480,BOT:-240,BRST:-120,BRT:-180,BST:60,BTT:360,CAST:480,CAT:120,CCT:390,CDT:-300,CEST:120,CET:{timezoneOffsetDuringDst:120,timezoneOffsetNonDst:60,dstStart:r=>ZV(r,ls.MARCH,Oe.SUNDAY,2),dstEnd:r=>ZV(r,ls.OCTOBER,Oe.SUNDAY,3)},CHADT:825,CHAST:765,CKT:-600,CLST:-180,CLT:-240,COT:-300,CST:-360,CT:{timezoneOffsetDuringDst:-300,timezoneOffsetNonDst:-360,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},CVT:-60,CXT:420,ChST:600,DAVT:420,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEST:180,EET:120,EGST:0,EGT:-60,EST:-300,ET:{timezoneOffsetDuringDst:-240,timezoneOffsetNonDst:-300,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},FJST:780,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GMT:0,GST:240,GYT:-240,HAA:-180,HAC:-300,HADT:-540,HAE:-240,HAP:-420,HAR:-360,HAST:-600,HAT:-90,HAY:-480,HKT:480,HLV:-210,HNA:-240,HNC:-360,HNE:-300,HNP:-480,HNR:-420,HNT:-150,HNY:-540,HOVT:420,ICT:420,IDT:180,IOT:360,IRDT:270,IRKST:540,IRKT:540,IRST:210,IST:330,JST:540,KGT:360,KRAST:480,KRAT:480,KST:540,KUYT:240,LHDT:660,LHST:630,LINT:840,MAGST:720,MAGT:720,MART:-510,MAWT:300,MDT:-360,MESZ:120,MEZ:60,MHT:720,MMT:390,MSD:240,MSK:180,MST:-420,MT:{timezoneOffsetDuringDst:-360,timezoneOffsetNonDst:-420,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:690,NOVST:420,NOVT:360,NPT:345,NST:-150,NUT:-660,NZDT:780,NZST:720,OMSST:420,OMST:420,PDT:-420,PET:-300,PE
2026-07-23 20:36:13 +08:00
tags: ${JSON.stringify(Array.from(this._tags).sort())},
knownValues: ${JSON.stringify(this.knownValues)},
impliedValues: ${JSON.stringify(this.impliedValues)}},
2026-08-02 09:03:32 +08:00
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}},at=class r{constructor(e,t,n,i,o){le(this,"refDate");le(this,"index");le(this,"text");le(this,"reference");le(this,"start");le(this,"end");this.reference=e,this.refDate=e.instant,this.index=t,this.text=n,this.start=i||new Q(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 Er(r,e,t="\\s{0,5},?\\s{0,5}"){let n=e.replace(/\((?!\?)/g,"(?:");return`${r}${n}(?:${t}${n}){0,10}`}function ate(r){let e;return r instanceof Array?e=[...r]:r instanceof Map?e=Array.from(r.keys()):e=Object.keys(r),e}function ee(r){return`(?:${ate(r).sort((t,n)=>n.length-t.length).join("|").replace(/\./g,"\\.")})`}var ze=b(()=>{});function jr(r){return r<100&&(r>50?r=r+1900:r=r+2e3),r}function ft(r,e,t){let n=new Date(r);n.setMonth(t-1),n.setDate(e);let i=gt(n,{year:1}),o=gt(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 zt=b(()=>{Bt()});function lte(r){let e=r.toLowerCase();return eF[e]!==void 0?eF[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 Lm(r){let e=r.toLowerCase();return tF[e]!==void 0?tF[e]:(e=e.replace(/(?:st|nd|rd|th)$/i,""),parseInt(e))}function bl(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 jr(e)}function js(r){let e={},t=r,n=eq.exec(t);for(;n;)ute(e,n),t=t.substring(n[0].length).trim(),n=eq.exec(t);return Object.keys(e).length==0?null:e}function ute(r,e){if(e[0].match(/^[a-zA-Z]+$/))return;let t=lte(e[1]),n=Dy[e[2].toLowerCase()];r[n]=t}var H_,rF,ho,eF,tF,tq,Dy,rq,Nm,Bu,nq,eq,cte,iq,Ac,Uu,on=b(()=>{ze();zt();H_={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},rF={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},ho={...rF,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},eF={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},tF={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
`,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 ux(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 DG(r,e){let t=/^[A-Za-z_$][\w$]*/.exec(r.slice(e));return t?{value:t[0],end:e+t[0].length}:null}function cx(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=ux(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 FG(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=ux(r,t.lastIndex-1);i&&(e.set(n[1],i.value),t.lastIndex=i.end)}return e}function jce(r){let e=[],t=FG(r),n=0;for(;n<r.length;){n=Na(r,n);let i=r[n],o=r[n+1];if(i==='"'||i==="'"||i==="`"){let l=ux(r,n);n=l?l.end:n+1;continue}if(i==="/"&&o==="/"){let l=r.indexOf(`
`,n+2);n=l===-1?r.length:l+1;continue}if(i==="/"&&o==="*"){let l=r.indexOf("*/",n+2);n=l===-1?r.length:l+2;continue}let s=m$(r,n,t);if(!s){n+=1;continue}if(n=Na(r,s.end),r[n]!==":"){n=s.end;continue}if(n=Na(r,n+1),s.name!=="options"||r[n]!=="{")continue;let a=cx(r,n,"{","}");if(a===-1)break;e.push({start:n+1,end:a}),n=a+1}return e}function m$(r,e,t){if(r[e]==='"'||r[e]==="'"||r[e]==="`"){let i=ux(r,e);return i?{name:i.value,end:i.end}:null}if(r[e]==="["){let i=Na(r,e+1),o=DG(r,i),s=cx(r,e,"[","]");if(s===-1)return null;let a=o?Na(r,o.end):i;return{name:o&&a===s?t.get(o.value)??null:null,end:s+1}}let n=DG(r,e);return n?{name:n.value,end:n.end}:null}function Gce(r){let e=new Map,t=0;for(;t<r.length;){if(t=Na(r,t),r[t]===","){t+=1;continue}if(t>=r.length)break;let n=m$(r,t,new Map);if(!n?.name){t+=1;continue}if(t=Na(r,n.end),r[t]!==":"){t+=1;continue}if(t=Na(r,t+1),r[t]==='"'||r[t]==="'"||r[t]==="`"){let i=ux(r,t);if(!i)break;e.set(n.name,i.value),t=i.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}if(r[t]==="{"){let i=cx(r,t,"{","}");if(i===-1)break;t=i+1;continue}if(r[t]==="["){let i=cx(r,t,"[","]");if(i===-1)break;t=i+1;continue}for(;t<r.length&&r[t]!==",";)t+=1}return e}function Yce(r){let e=Gce(r),t=e.get("type"),n=e.get("secret");return t==="secret"||(t==="text"||t==="input")&&n===!0}function Ph(r,e){let t=e&&Wce.test(e)?hc(r).code??"":r,n=new Set,i=!1,o=FG(t);for(let{start:s,end:a}of jce(t)){let l=s;for(;l<a;){if(l=Na(t,l),t[l]===","){l+=1;continue}if(l>=a)break;let c=m$(t,l,o);if(!c){l+=1;continue}if(l=Na(t,c.end),t[l]!==":"){l+=1;continue}if(l=Na(t,l+1),t[l]!=="{"){l+=1;continue}let u=cx(t,l,"{","}");if(u===-1||u>a)break;let d=t.slice(l+1,u);Yce(d)&&(i=!0,c.name&&n.add(c.name)),l=u+1}}return{names:n,foundSecretOptions:i}}function Fh(r){return td(r)?r.type==="secret"||(r.type==="text"||r.type==="input")&&r.secret===!0:!1}function Ih(r){return td(r)&&r[IG]===!0&&typeof r.secretRef=="string"&&r.secretRef.trim().length>0}function ck(r){return{[IG]:!0,secretRef:r}}function Kce(r,e,t){let n=r.id?.trim()||r.path||r.name||"script";return p$(lk(n),lk(PG(e,t)))}function Xce(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>Fh(t)).map(([t])=>t):[]}function Qce(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>Fh(t)):[]}function Zce(r){return typeof r.id=="string"&&r.id.trim().length>0}async function h$(r,e){let t=pk(r);if(!t?.getSecret)return null;try{return await Promise.resolve(t.getSecret(e))}catch(n){return F.logWarning(`Failed to read user script SecretStorage entry "${e}": ${f$(n)}`),null}}async function Jce(r,e,t){let n=pk(r);if(!n?.setSecret)return!1;try{return await Promise.resolve(n.setSecret(e,t)),!0}catch(i){return F.logWarning(`Failed to write user script SecretStorage entry "${e}": ${f$(i)}`),!1}}async function eue(r,e,t,n,i){let o=e.id?.trim()||e.path||e.name||"script",s=lk(o),a=lk(PG(t,i)),l=p$(s,a),c=1;for(;;){let u=await h$(r,l);if(!u||u===n)return l;c+=1,l=p$(s,a,String(c))}}async function g$(r,e,t,n,i,o){if(n.length===0)return null;let s=i?.trim()||await eue(r,e,t,n,o);return await Jce(r,s,n)?s:null}async function v$(r,e){let t=e?.trim();if(!t)return!0;let n=pk(r);if(!n)return!0;let i=n.deleteSecret??n.removeSecret??n.delete;try{if(i)return await Promise.resolve(i.call(n,t)),!0;if(n.setSecret)return await Promise.resolve(n.setSecret(t,"")),!0}catch(o){F.logWarning(`Failed to clear user script SecretStorage entry "${t}": ${f$(o)}`)}return!1}async function fk(r,e,t){let n=e.settings??{},i={...n},o=new Set(Xce(t));for(let[s,a]of Object.entries(n)){if(Ih(a)){let l=await h$(r,a.secretRef);if(l){i[s]=l;continue}throw new Error(`Secret setting "${s}" for user script "${e.name}" is unavailable. Re-enter it on this device.`)}o.has(s)&&(i[s]=typeof a=="string"?a:"")}return i}async function Mh(r,e,t){let n=Qce(t);if(n.length===0)return!1;let i=pk(r);if(!i?.getSecret||!i?.setSecret)return n.some(([a])=>{let l=e.settings?.[a];return typeof l=="string"&&l.length>0})&&F.logWarning(`SecretStorage unavailable; leavi
2026-07-23 20:36:13 +08:00
2026-08-02 09:03:32 +08:00
`));let s=e.modelParams??{};return typeof s.temperature=="number"&&(o.temperature=s.temperature),typeof s.top_p=="number"&&(o.top_p=s.top_p),e.tools&&e.tools.length>0&&(o.tools=e.tools.map(a=>({name:a.name,description:a.description,input_schema:a.parameters})),e.toolChoice?o.tool_choice=zfe(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:Dx(e.responseFormat.schema)}}),o}function zfe(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 Hfe(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 jfe(r,e){let t=[],n=[];for(let a of e.messages)if(a.role==="system")a.content&&t.push(a.content);else if(a.role==="user")n.push({role:"user",parts:[{text:a.content}]});else if(a.role==="assistant")if(Array.isArray(a.providerRaw))n.push({role:"model",parts:a.providerRaw});else{let l=[];a.content&&l.push({text:a.content});for(let c of a.toolCalls??[])l.push({functionCall:{name:c.name,args:c.args??{}}});n.push({role:"model",parts:l})}else n.push({role:"user",parts:a.results.map(l=>({functionResponse:{name:l.name,response:l.isError?{error:l.content}:{result:l.content}}}))});let i={contents:n};t.length>0&&(i.systemInstruction={role:"system",parts:[{text:t.join(`
`)}]}),e.tools&&e.tools.length>0&&(i.tools=[{functionDeclarations:e.tools.map(a=>({name:a.name,description:a.description,parameters:a.parameters}))}],e.toolChoice&&(i.toolConfig=Gfe(e.toolChoice)));let o={},s=e.modelParams??{};return typeof s.temperature=="number"&&(o.temperature=s.temperature),typeof s.top_p=="number"&&(o.topP=s.top_p),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 Gfe(r){return typeof r=="string"?{functionCallingConfig:{mode:r==="required"?"ANY":r==="none"?"NONE":"AUTO"}}:{functionCallingConfig:{mode:"ANY",allowedFunctionNames:[r.name]}}}function Yfe(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 DO(r,e,t,n=8192){switch(r){case"anthropic":return Wfe(e,t,n);case"gemini":return jfe(e,t);default:return Ufe(e,t)}}function P4(r,e){switch(r){case"anthropic":return Hfe(e);case"gemini":return Yfe(e);default:return Vfe(e)}}var Bfe,F4=b(()=>{Bfe=/^(?:o[1-9]|gpt-(?:[5-9]|\d\d))/i});async function pg(r,e,t){let n=(0,Px.requestUrl)({...r,throw:!1});t&&t();let i=await n;if(i.status>=400)throw Hk(e,i);return i.json}function Kfe(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 Xfe(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()}}async function Qfe(r,e,t,n,i,o,s){return pg({url:`${t.endpoint}/chat/completions`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({model:e.name,...i,messages:[{role:"system",content:n},{role:"user",content:o}]})},t.name,s)}function IO(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}async function Zfe(r,e,t,n,i,o,s){let a={model:e.name,max_tokens:IO(e),messages:[{role:"user",content:o}]};return n&&n.trim().length>0&&(a.system=n),typeof i.temperature=="number"&&(a.temperature=i.temperature),typeof i.top_p=="number"&&(a.top_p=i.top_p),pg({url:`${t.endpoint}/v1/messages`,method:"POST",headers:{"Content-Type":"application/json","x-api-key":r,"anthropic-version":"2023-06-01"},body:JSON.stringify(a)},t.name,s)}async function Jfe(r,e,t,n,i,o,s){let a=`${t.endpoint}/v1beta/models/${encodeURIComponent(e.name)}:generateContent`,l={};typeof i.temperature=="number"&&(l.temperature=i.temperature),typeof i.top_p=="number"&&(l.topP=i.top_p);let c={contents:[{role:"user",parts:[{text:o}]}]};return n&&n.trim().length>0&&(c.systemInstruction={role:"system",parts:[{text:n}]}),Object.keys(l).length>0&&(c.generationConfig=l),pg({url:a,method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":r},body:JSON.stringify(c)},t.name,s)}function eme(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
${e}`:""}`});function NO(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void 0}}function MO(r){let e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=Date.now();return ea.push({...r,modelOptions:{...r.modelOptions??{}},id:e,createdAt:t,status:"pending"}),B4(),e}function Ix(r,e){let t=ea.find(n=>n.id===r);t&&(t.status=e.status,t.durationMs=e.durationMs,t.usage=e.usage,t.errorMessage=e.errorMessage,B4())}function L4(r=10){Number.isFinite(r)||(r=10);let e=Math.floor(r);return e<=0?[]:ea.slice(-e).map(NO).reverse()}function B4(){if(ea.length<=O4)return;let r=ea.length-O4;for(;r>0;){let e=ea.findIndex(t=>t.status!=="pending");if(e===-1)break;ea.splice(e,1),r-=1}}function U4(r){let e=ea.find(t=>t.id===r);return e?NO(e):null}function V4(){let r=ea[ea.length-1];return r?NO(r):null}function q4(){ea.splice(0,ea.length)}async function tme(r,e,t){if(typeof r!="function")throw new TypeError("Callback must be a function.");if(!(e instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");if(typeof t!="number"||t<=0)throw new TypeError("Interval must be a positive number.");let n=!1;for(e.then(()=>{n=!0},()=>{n=!0});!n;)r(),await sleep(t)}function rme(r){return r instanceof Error?r:new Error(String(r))}async function nme(r,e,t,n=!0,i){let o;if(e.enable)o=t.find(c=>c.path.endsWith(e.name));else{let c=t.map(u=>u.basename);if(i)o=await i.suggester(c,t,"Select a prompt template");else if(n)o=await Nr.Suggest(r,c,t);else throw new Ee("This AI command asks which prompt template to use, but this run is non-interactive. Enable a specific prompt template in the command, or re-run with the ui flag.")}Mi(o,"Prompt template does not exist");let s=o.path,a=r.vault.getAbstractFileByPath(s);Mi(a instanceof N4.TFile,`${s} is not a file`);let l=await r.vault.cachedRead(a);return[o.basename,l]}async function W4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,promptTemplate:l,systemPrompt:c,promptTemplateFolder:u}=e,d=rs(r,u),[f,p]=await nme(r,l,d,e.interactive??!0,e.promptProvider);n.setMessage("waiting","QuickAdd is formatting the prompt template.");let m=await t(p),v=["prompting",`Using prompt template "${f}".`];n.setMessage(v[0],v[1]);let y=SS(r,i,o,s,c,e.modelOptions)(m),x=(await LO(y,100,E=>{n.setMessage(v[0],`${v[1]} (${(E/1e3).toFixed(2)}s)`)},E=>{n.setMessage("finished",`Took ${(E/1e3).toFixed(2)}s.`)})).content,C=("> "+x).replace(/\n/g,`
> `),_={[a]:x,[`${a}-quoted`]:C};return window.setTimeout(()=>n.hide(),5e3),_}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),Dt(i)?new St("Input cancelled by user"):i}}async function LO(r,e,t,n){let i=Date.now();return await tme(()=>t(Date.now()-i),r,e),n(Date.now()-i),await r}async function z4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,prompt:c,modelOptions:u}=e;n.setMessage("waiting","QuickAdd is formatting the prompt template.");let d=await t(c),f=["prompting","Using custom prompt."];n.setMessage(f[0],f[1]);let m=SS(r,i,o,s,l,u)(d),g=(await LO(m,100,x=>{n.setMessage(f[0],`${f[1]} (${(x/1e3).toFixed(2)}s)`)},x=>{n.setMessage("finished",`Took ${(x/1e3).toFixed(2)}s.`)})).content,y=("> "+g).replace(/\n/g,`
> `),w={[a]:g,[`${a}-quoted`]:y};return window.setTimeout(()=>n.hide(),5e3),w}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}function ome(){return Array.from(new Set([OO,...["kebab","snake","camel","pascal","title","lower","upper","slug"].map(r=>$_(OO,r))])).filter(Boolean)}function j4(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 f=d+a.length;if(f<=0||f>=r.length)continue;let p=Math.abs(f-e);p<i&&(i=p,n=f)}}if(n>0&&n<r.length)return[r.slice(0,n),r.slice(n)];let o=e,s=r.charCodeAt(o);return s>=56320&&s<=57343&&(o+=1),o<=0||o>=r.length?null:[r.slice(0,o),r.slice(o)]}function sme(r){let e=new RegExp(Hd.source,"gi"),t;for(;(t=e.exec(r))!==null;)if(t[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}function ame(r){return Rs.test(r)||vu.test(r)||pl.test(r)||dc.test(r)}function lme(r){return H4.some(e=>r.includes(e))}function cme(r){return H4.slice().sort((e,t)=>t.length-e.length).reduce((e,t)=>e.split(t).join(" "),r)}function G4(r){if(r>IS)throw new Error(`QuickAdd would split this chunked AI request into more than ${IS} prompts, which exceeds the safety limit. Increase the chunk size, use a larger chunk separator, or reduce the input text.`)}function ume(r,e,t){let n=Math.max(1,Math.floor(e)),i=[r],o=0;for(;i.length>0;){let s=i.pop(),l=Uo(s)<=n?null:j4(s);if(!l){t.push(s),o+=1,G4(o);continue}i.push(l[1],l[0])}}function dme(r){let e=r.flags.replace(/[gy]/g,"");return new RegExp(r.source+"|",e).exec("").length-1}function fme(r,e){if(typeof e=="string"){let s=r.split(e);return{chunks:s,separators:new Array(Math.max(0,s.length-1)).fill(e)}}if(dme(e)>0||pme.test(e.source))return{chunks:r.split(e),separators:null};let t=new RegExp(`(${e.source})`,e.flags),n=r.split(t),i=[],o=[];for(let s=0;s<n.length;s++)s%2===0?i.push(n[s]):o.push(n[s]);return{chunks:i,separators:o}}function mme(r,e,t,n){let i=[];if(r.forEach((l,c)=>{let u=[];ume(l,t,u),u.forEach((d,f)=>{i.push({text:d,joiner:f===0&&c>0?e?.[c-1]??"":""})})}),!n)return i.map(l=>l.text);let o=[],s="",a=0;for(let l of i){let c=Uo(l.text)+Math.max(1,Uo(l.joiner));s!==""&&a+c>=t&&(o.push(s),s="",a=0),s+=s===""?l.text:l.joiner+l.text,a+=c}return s!==""&&o.push(s),o}function hme(r,e){let t=Math.max(1,Math.floor(r));if(e!==void 0&&Number.isFinite(e)&&e>0){let n=Math.floor(e);return{budget:Math.min(t,n),clamped:n>t}}return{budget:t,clamped:!1}}async function Y4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,promptTemplate:c,text:u,modelOptions:d}=e;n.setMessage("chunking","Creating prompt chunks with text and prompt template");let f=e.chunkSeparator||/\n/g,{chunks:p,separators:m}=fme(u,f),v=await t(c,{chunk:OO});if(!(sme(c)||ame(c)&&lme(v)))throw new Error("The chunked prompt template does not reference the chunk text. Add {{VALUE:chunk}} to your prompt template so each chunk is inserted.");let y=o.maxTokens,w=$G(y),x=cme(v),C=Uo(l)+Uo(x);if(C>=y)throw new Error(`The estimated prompt overhead (${C} 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:_,clamped:E}=hme(w-C,e.maxChunkTokens);E&&F.logMessage(`[ChunkedPrompt] Requested max chunk tokens (${e.maxChunkTokens}) exceeds this model's estimated input budget; using ${_} estimated tokens per chunk instead.`);let D=e.shouldMerge??!0,P=mme(p,m,_,D);G4(P.length);let V=SS(r,i,o,s,l,d),j=["prompting",`${P.length} prompts being sent.`];n.setMessage(j[0],j[1]);let oe=new $O(5,1e3*30),se=!1,M=0,U=Promise.resolve(),q=ge=>{let be=U.then(()=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");return t(c,{chunk:ge})});return U=be.then(()=>{},()=>{}),be},B=async(ge,be=0)=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");let xe;try{xe=await q(ge)}catch(Ue){throw se=!0,Ue}try{return[(await oe.add(()=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");if(M+=1,M>IS)throw new Error(`Chunked AI request exceeded the safety limit of ${IS} provider requests.`);return V(xe)})).content]}catch(Ue){let $t=j4(ge);if(be>=ime||!$t||!mY(Ue))throw
> `),pe={[a]:X,[`${a}-quoted`]:ae};return window.setTimeout(()=>n.hide(),5e3),pe}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}var N4,O4,ea,$O,ime,IS,OO,H4,pme,DS=b(()=>{N4=require("obsidian");Wr();Co();Wc();It();qt();Sx();Cr();FO();Cx();RO();px();Me();Tt();O_();O4=25,ea=[];$O=class{constructor(e,t){this.maxRequests=e;this.intervalMs=t;this.queue=[];this.startTimes=[]}add(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{t(await e())}catch(i){n(rme(i))}}),this.schedule()})}schedule(){if(this.queue.length===0)return;let e=Date.now();if(this.startTimes=this.startTimes.filter(i=>e-i<this.intervalMs),this.startTimes.length>=this.maxRequests){let i=this.startTimes[0],o=Math.max(0,this.intervalMs-(e-i));window.setTimeout(()=>this.schedule(),o+1);return}let t=this.queue.shift();if(!t)return;this.startTimes.push(e);let n=t();window.setTimeout(()=>this.schedule(),this.intervalMs),this.schedule()}},ime=12,IS=500,OO="quickadd_chunk_probe_123456789";H4=ome();pme=/(?:^|[^\\])(?:\\\\)*\\[1-9]/});function K4(r){return r.normalize("NFKD").toLowerCase()}var gme,Qp,BO=b(()=>{gme=0;Qp=class{constructor(e,t){this.options=t;this.instanceId=++gme;this.indexedItems=[];this.renderedRows=[];this.query="";this.rootEl=document.createElement("div"),this.rootEl.className="qa-searchable-multi-select";let n=document.createElement("div");n.className="search-input-container qa-searchable-multi-select__search-container",this.searchInputEl=document.createElement("input"),this.searchInputEl.className="qa-searchable-multi-select__search",this.searchInputEl.type="search",this.searchInputEl.name=`qa-multi-select-search-${this.instanceId}`,this.searchInputEl.placeholder=t.searchPlaceholder??"Search options...",this.searchInputEl.setAttribute("aria-label",this.searchInputEl.placeholder),this.searchInputEl.setAttribute("autocomplete","off"),this.searchInputEl.setAttribute("spellcheck","false"),n.appendChild(this.searchInputEl),this.summaryEl=document.createElement("div"),this.summaryEl.className="qa-searchable-multi-select__summary",this.summaryEl.setAttribute("aria-live","polite"),this.listEl=document.createElement("div"),this.listEl.className="qa-searchable-multi-select__list",this.listEl.setAttribute("role","group"),this.listEl.setAttribute("aria-label","Options"),this.rootEl.append(n,this.summaryEl,this.listEl),e.appendChild(this.rootEl),this.searchInputEl.addEventListener("input",()=>{this.query=this.searchInputEl.value,this.renderList()}),this.searchInputEl.addEventListener("keydown",i=>{if(i.key==="ArrowDown"){i.preventDefault(),this.renderedRows[0]?.input.focus();return}if(i.key==="ArrowUp"){i.preventDefault(),this.renderedRows.at(-1)?.input.focus();return}i.key==="Escape"&&this.query&&(i.preventDefault(),i.stopPropagation(),this.query="",this.searchInputEl.value="",this.renderList())}),this.setItems(t.items)}setItems(e){this.indexedItems=e.map((t,n)=>({item:t,index:n,searchableText:K4(`${t.label} ${t.searchText??""}`)})),this.searchInputEl.disabled=e.length===0,this.renderList()}focusSearchOnOpen(){document.body.classList.contains("is-mobile")||this.searchInputEl.focus()}refreshSelection(){for(let{item:e,input:t}of this.renderedRows)t.checked=this.options.isSelected(e),t.closest("label")?.classList.toggle("is-selected",t.checked);this.updateSummary()}getMatchingItems(){let e=K4(this.query.trim()).split(/\s+/).filter(Boolean);return e.length===0?this.indexedItems:this.indexedItems.filter(({searchableText:t})=>e.every(n=>t.includes(n)))}getVisibleItems(e){if(e.length<=200)return e;let t=[],n=[];for(let i of e)(this.options.isSelected(i.item)?t:n).push(i);return[...t,...n].slice(0,200)}renderList(){this.listEl.replaceChildren(),this.renderedRows=[];let e=this.getMatchingItems(),t=this.getVisibleItems(e);if(t.length===0){let n=document.createElement("div");n.className="qa-searchable-multi-select__empty",n.setAttribute("role","status"),n.textContent=this.indexedItems.length?`No options match \u201C${this.query.trim()}\u201D`:this.options.emptyText??"No options available",this.listEl.appendChild(n)}for(let n o
`,e-1)+1,a=r.slice(o,t).split(`
`),l=a.length-1,c=0,u=a.map((d,f)=>f===l&&d===""?d:(c+=i.length,i+d));return{regionStart:o,regionEnd:t,replacement:u.join(`
`),selectionStart:e+i.length,selectionEnd:t+c}}function Cme(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 J4(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;Cme(r,wme(r.value,o,s,e))};r.addEventListener("keydown",t);let n=!1;return()=>{n||(n=!0,r.removeEventListener("keydown",t))}}var e5=b(()=>{});var gg,ld,zO=b(()=>{gg=require("obsidian");SP();DP();IP();PP();FP();e5();zs();h_();Wr();ld=class r extends gg.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.isOptionalPrompt&&RP(t)){t.preventDefault(),this.skip();return}(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new _m({kind:"multi",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.display(),this.open(),this.fileSuggester=new xm(t,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Em(t,this.inputComponent.inputEl)}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaWideInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,d_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}createInputField(t,n,i){let o=new gg.TextAreaComponent(t);return o.inputEl.classList.add("wideInputPromptInputEl"),o.inputEl.setAttribute("dir","auto"),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.disposeIndent=J4(o.inputEl),this.options?.imagePaste&&(this.imagePasteHandle=Am(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new gg.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}get isOptionalPrompt(){return this.options?.optional===!0}createButtonBar(t){let n=t.createDiv();if(this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let i=this.createButton(n,"Skip",this.skipClickCallback);i.setTooltip("Leave this field empty"),i.buttonEl.setAttribute("aria-label","Skip and leave empty")}n.setCssStyles({display:"flex",flexDirection:"row-reverse",justifyContent:"flex-start",marginTop:"1rem",gap:"0.5rem"})}submit(){if(!(this.didSubmit||this.didClose)){if(this.imagePasteHandle?.isBusy()){this.imagePasteHandle.whenIdle().then(()=>this.submit());return}this.input=this.inputComponent?.inputEl?.value??this.input,this.didSubmit=!0,this.close()}}skip(){this.didSubmit||(this.input="",this.didSubmit=!0,this.close())}cancel(){this.
2026-07-23 20:36:13 +08:00
\u261A
2026-08-02 09:03:32 +08:00
\\end{${r}}\u261A`}var xme,Eme,i5,jO=b(()=>{xme=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|","^{\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",
`||T.charAt(ve)==="\r"&&T.charAt(ve+1)!==`
`)&&(J++,ue===0&&(ue=ve+1)),ve--}var Ve=K+J,vt=k-ue;return N[k]={line:Ve,lineStart:ue},{offset:k,line:Ve+1,column:vt+1}}function se(T){if(!C(T))throw new Error("not a parser: "+T)}function M(T,k){return typeof T=="string"?T.charAt(k):T[k]}function U(T){if(typeof T!="number")throw new Error("not a number: "+T)}function q(T){if(typeof T!="function")throw new Error("not a function: "+T)}function B(T){if(typeof T!="string")throw new Error("not a string: "+T)}var ie=2,W=3,Y=8,X=5*Y,ae=4*Y,pe=" ";function ge(T,k){return new Array(k+1).join(T)}function be(T,k,N){var K=k-T.length;return K<=0?T:ge(N,K)+T}function xe(T,k,N,K){return{from:T-k>0?T-k:0,to:T+N>K?K:T+N}}function Ue(T,k){var N,K,J,ue,ve,Ve=k.index,vt=Ve.offset,Pr=1;if(vt===T.length)return"Got the end of the input";if(E(T)){var jt=vt-vt%Y,$i=vt-jt,yt=xe(jt,X,ae+Y,T.length),pr=c(function(kt){return c(function(Eo){return be(Eo.toString(16),2,"0")},kt)},(function(kt,Eo){var ua=kt.length,Es=[],ln=0;if(ua<=Eo)return[kt.slice()];for(var _n=0;_n<ua;_n++)Es[ln]||Es.push([]),Es[ln].push(kt[_n]),(_n+1)%Eo==0&&ln++;return Es})(T.slice(yt.from,yt.to).toJSON().data,Y));ue=(function(kt){return kt.from===0&&kt.to===1?{from:kt.from,to:kt.to}:{from:kt.from/Y,to:Math.floor(kt.to/Y)}})(yt),K=jt/Y,N=3*$i,$i>=4&&(N+=1),Pr=2,J=c(function(kt){return kt.length<=4?kt.join(" "):kt.slice(0,4).join(" ")+" "+kt.slice(4).join(" ")},pr),(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2)}else{var kr=T.split(/\r\n|[\n\r\u2028\u2029]/);N=Ve.column-1,K=Ve.line-1,ue=xe(K,ie,W,kr.length),J=kr.slice(ue.from,ue.to),ve=ue.to.toString().length}var Gn=K-ue.from;return E(T)&&(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2),l(function(kt,Eo,ua){var Es,ln=ua===Gn,_n=ln?"> ":pe;return Es=E(T)?be((8*(ue.from+ua)).toString(16),ve,"0"):be((ue.from+ua+1).toString(),ve," "),[].concat(kt,[_n+Es+" | "+Eo],ln?[pe+ge(" ",ve)+" | "+be("",N," ")+ge("^",Pr)]:[])},[],J).join(`
`)}function $t(T,k){return[`
`,"-- PARSING FAILED "+ge("-",50),`
2026-07-23 20:36:13 +08:00
2026-08-02 09:03:32 +08:00
`,Ue(T,k),`
`,(N=k.expected,N.length===1?`Expected:
`+N[0]:`Expected one of the following:
`+N.join(", ")),`
`].join("");var N}function Ne(T){return T.flags!==void 0?T.flags:[T.global?"g":"",T.ignoreCase?"i":"",T.multiline?"m":"",T.unicode?"u":"",T.sticky?"y":""].join("")}function Ke(){for(var T=[].slice.call(arguments),k=T.length,N=0;N<k;N+=1)se(T[N]);return o(function(K,J){for(var ue,ve=new Array(k),Ve=0;Ve<k;Ve+=1){if(!(ue=V(T[Ve]._(K,J),ue)).status)return ue;ve[Ve]=ue.value,J=ue.index}return V(D(J,ve),ue)})}function Qe(){var T=[].slice.call(arguments);if(T.length===0)throw new Error("seqMap needs at least one argument");var k=T.pop();return q(k),Ke.apply(null,T).map(function(N){return k.apply(null,N)})}function ye(){var T=[].slice.call(arguments),k=T.length;if(k===0)return ut("zero alternates");for(var N=0;N<k;N+=1)se(T[N]);return o(function(K,J){for(var ue,ve=0;ve<T.length;ve+=1)if((ue=V(T[ve]._(K,J),ue)).status)return ue;return ue})}function We(T,k){return mt(T,k).or(Be([]))}function mt(T,k){return se(T),se(k),Qe(T,k.then(T).many(),function(N,K){return[N].concat(K)})}function He(T){B(T);var k="'"+T+"'";return o(function(N,K){var J=K+T.length,ue=N.slice(K,J);return ue===T?D(J,ue):P(K,k)})}function _e(T,k){(function(J){if(!(J instanceof RegExp))throw new Error("not a regexp: "+J);for(var ue=Ne(J),ve=0;ve<ue.length;ve++){var Ve=ue.charAt(ve);if(Ve!=="i"&&Ve!=="m"&&Ve!=="u"&&Ve!=="s")throw new Error('unsupported regexp flag "'+Ve+'": '+J)}})(T),arguments.length>=2?U(k):k=0;var N=(function(J){return RegExp("^(?:"+J.source+")",Ne(J))})(T),K=""+T;return o(function(J,ue){var ve=N.exec(J.slice(ue));if(ve){if(0<=k&&k<=ve.length){var Ve=ve[0],vt=ve[k];return D(ue+Ve.length,vt)}return P(ue,"valid match group (0 to "+ve.length+") in "+K)}return P(ue,K)})}function Be(T){return o(function(k,N){return D(N,T)})}function ut(T){return o(function(k,N){return P(N,T)})}function or(T){if(C(T))return o(function(k,N){var K=T._(k,N);return K.index=N,K.value="",K});if(typeof T=="string")return or(He(T));if(T instanceof RegExp)return or(_e(T));throw new Error("not a string, regexp, or parser: "+T)}function yr(T){return se(T),o(function(k,N){var K=T._(k,N),J=k.slice(N,K.index);return K.status?P(N,'not "'+J+'"'):D(N,null)})}function Pt(T){return q(T),o(function(k,N){var K=M(k,N);return N<k.length&&T(K)?D(N+1,K):P(N,"a character/byte matching "+T)})}function Ar(T,k){arguments.length<2&&(k=T,T=void 0);var N=o(function(K,J){return N._=k()._,N._(K,J)});return T?N.desc(T):N}function ur(){return ut("fantasy-land/empty")}s.parse=function(T){if(typeof T!="string"&&!E(T))throw new Error(".parse must be called with a string or Buffer as its argument");var k,N=this.skip(xo)._(T,0);return k=N.status?{status:!0,value:N.value}:{status:!1,index:oe(T,N.furthest),expected:N.expected},delete j[T],k},s.tryParse=function(T){var k=this.parse(T);if(k.status)return k.value;var N=$t(T,k),K=new Error(N);throw K.type="ParsimmonError",K.result=k,K},s.assert=function(T,k){return this.chain(function(N){return T(N)?Be(N):ut(k)})},s.or=function(T){return ye(this,T)},s.trim=function(T){return this.wrap(T,T)},s.wrap=function(T,k){return Qe(T,this,k,function(N,K){return K})},s.thru=function(T){return T(this)},s.then=function(T){return se(T),Ke(this,T).map(function(k){return k[1]})},s.many=function(){var T=this;return o(function(k,N){for(var K=[],J=void 0;;){if(!(J=V(T._(k,N),J)).status)return V(D(N,K),J);if(N===J.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");N=J.index,K.push(J.value)}})},s.tieWith=function(T){return B(T),this.map(function(k){if((function(J){if(!_(J))throw new Error("not an array: "+J)})(k),k.length){B(k[0]);for(var N=k[0],K=1;K<k.length;K++)B(k[K]),N+=T+k[K];return N}return""})},s.tie=function(){return this.tieWith("")},s.times=function(T,k){var N=this;return arguments.length<2&&(k=T),U(T),U(k),o(function(K,J){for(var ue=[],ve=void 0,Ve=void 0,vt=0;vt<T;vt+=1){if(Ve=V(ve=N._(K,J),Ve),!ve.status)return Ve;J=ve.index,ue.push(ve.value)}for(;vt<k&&(Ve=V(ve=N._(K,J),Ve),ve.status);vt+=1)J=ve.index,ue.push(ve.value);return V(D(J,ue),Ve)})},s.result=function(T){return t
`),Ka=He(`\r
`),Xa=ye(Ka,Ho,Tn).desc("newline"),Jc=ye(Xa,xo);o.all=Hn,o.alt=ye,o.any=Ft,o.cr=Tn,o.createLanguage=function(T){var k={};for(var N in T)({}).hasOwnProperty.call(T,N)&&(function(K){k[K]=Ar(function(){return T[K](k)})})(N);return k},o.crlf=Ka,o.custom=function(T){return o(T(D,P))},o.digit=xs,o.digits=jn,o.empty=ur,o.end=Jc,o.eof=xo,o.fail=ut,o.formatError=$t,o.index=dt,o.isParser=C,o.lazy=Ar,o.letter=re,o.letters=Ie,o.lf=Ho,o.lookahead=or,o.makeFailure=P,o.makeSuccess=D,o.newline=Xa,o.noneOf=function(T){return Pt(function(k){return T.indexOf(k)<0}).desc("none of '"+T+"'")},o.notFollowedBy=yr,o.of=Be,o.oneOf=function(T){for(var k=T.split(""),N=0;N<k.length;N++)k[N]="'"+k[N]+"'";return Pt(function(K){return T.indexOf(K)>=0}).desc(k)},o.optWhitespace=dr,o.Parser=o,o.range=function(T,k){return Pt(function(N){return T<=N&&N<=k}).desc(T+"-"+k)},o.regex=_e,o.regexp=_e,o.sepBy=We,o.sepBy1=mt,o.seq=Ke,o.seqMap=Qe,o.seqObj=function(){for(var T,k={},N=0,K=(T=arguments,Array.prototype.slice.call(T)),J=K.length,ue=0;ue<J;ue+=1){var ve=K[ue];if(!C(ve)){if(_(ve)&&ve.length===2&&typeof ve[0]=="string"&&C(ve[1])){var Ve=ve[0];if(Object.prototype.hasOwnProperty.call(k,Ve))throw new Error("seqObj: duplicate key "+Ve);k[Ve]=!0,N++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(N===0)throw new Error("seqObj expects at least one named parser, found zero");return o(function(vt,Pr){for(var jt,$i={},yt=0;yt<J;yt+=1){var pr,kr;if(_(K[yt])?(pr=K[yt][0],kr=K[yt][1]):(pr=null,kr=K[yt]),!(jt=V(kr._(vt,Pr),jt)).status)return jt;pr&&($i[pr]=jt.value),Pr=jt.index}return V(D(Pr,$i),jt)})},o.string=He,o.succeed=Be,o.takeWhile=function(T){return q(T),o(function(k,N){for(var K=N;K<k.length&&T(M(k,K));)K++;return D(K,k.slice(N,K))})},o.test=Pt,o.whitespace=br,o["fantasy-land/empty"]=ur,o["fantasy-land/of"]=Be,o.Binary={bitSeq:p,bitSeqObj:function(T){f();var k={},N=0,K=c(function(ue){if(_(ue)){var ve=ue;if(ve.length!==2)throw new Error("["+ve.join(", ")+"] should be length 2, got length "+ve.length);if(B(ve[0]),U(ve[1]),Object.prototype.hasOwnProperty.call(k,ve[0]))throw new Error("duplicate key in bitSeqObj: "+ve[0]);return k[ve[0]]=!0,N++,ve}return U(ue),[null,ue]},T);if(N<1)throw new Error("bitSeqObj expects at least one named pair, got ["+T.join(", ")+"]");var J=c(function(ue){return ue[0]},K);return p(c(function(ue){return ue[1]},K)).map(function(ue){return l(function(ve,Ve){return Ve[0]!==null&&(ve[Ve[0]]=Ve[1]),ve},{},c(function(ve,Ve){return[ve,ue[Ve]]},J))})},byte:function(T){if(f(),U(T),T>255)throw new Error("Value specified to byte constructor ("+T+"=0x"+T.toString(16)+") is larger in value than a single byte.");var k=(T>15?"0x":"0x0")+T.toString(16);return o(function(N,K){var J=M(N,K);return J===T?D(K+1,J):P(K,k)})},buffer:function(T){return m("buffer",T).map(function(k){return Buffer.from(k)})},encodedString:function(T,k){return m("string",k).map(function(N){return N.toString(T)})},uintBE:g,uint8BE:g(1),uint16BE:g(2),uint32BE:g(4),uintLE:y,uint8LE:y(1),uint16LE:y(2),uint32LE:y(4),intBE:w,int8BE:w(1),int16BE:w(2),int32BE:w(4),intLE:x,int8LE:x(1),int16LE:x(2),int32LE:x(4),floatBE:m("floatBE",4).map(function(T){return T.readFloatBE(0)}),floatLE:m("floatLE",4).map(function(T){return T.readFloatLE(0)}),doubleBE:m("doubleBE",8).map(function(T){return T.readDoubleBE(0)}),doubleLE:m("doubleLE",8).map(function(T){return T.readDoubleLE(0)})},t.exports=o}])})})(KS,KS.exports);var R=KS.exports,I1=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u293
`)[0];let n=t.substring(2).trim();return R.makeSuccess(e+t.length,n)}),namedField:r=>R.alt(r.explicitNamedField,Age(ja.field).map(([e,t])=>QS.named(kge(t),e))),sortField:r=>R.seqMap(ja.field.skip(R.optWhitespace),R.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1),(e,t)=>{let n=t.length==0?"ascending":t[0].toLowerCase();return n=="desc"&&(n="descending"),n=="asc"&&(n="ascending"),{field:e,direction:n}}),headerClause:r=>r.queryType.chain(e=>{switch(e){case"table":return L5(()=>({type:e,fields:[],showId:!0}),R.seqMap(R.regexp(/WITHOUT\s+ID/i).skip(R.optWhitespace).atMost(1),R.sepBy(r.namedField,R.string(",").trim(R.optWhitespace)),(t,n)=>({type:e,fields:n,showId:t.length==0})));case"list":return L5(()=>({type:e,format:void 0,showId:!0}),R.seqMap(R.regexp(/WITHOUT\s+ID/i).skip(R.optWhitespace).atMost(1),ja.field.atMost(1),(t,n)=>({type:e,format:n.length==1?n[0]:void 0,showId:t.length==0})));case"task":return R.succeed({type:e});case"calendar":return R.whitespace.then(R.seqMap(r.namedField,t=>({type:e,showId:!0,field:t})));default:return R.fail(`Unrecognized query type '${e}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:r=>R.seqMap(R.regexp(/FROM/i),R.whitespace,ja.source,(e,t,n)=>n),whereClause:r=>R.seqMap(R.regexp(/WHERE/i),R.whitespace,ja.field,(e,t,n)=>({type:"where",clause:n})).desc("WHERE <expression>"),sortByClause:r=>R.seqMap(R.regexp(/SORT/i),R.whitespace,r.sortField.sepBy1(R.string(",").trim(R.optWhitespace)),(e,t,n)=>({type:"sort",fields:n})).desc("SORT field [ASC/DESC]"),limitClause:r=>R.seqMap(R.regexp(/LIMIT/i),R.whitespace,ja.field,(e,t,n)=>({type:"limit",amount:n})).desc("LIMIT <value>"),flattenClause:r=>R.seqMap(R.regexp(/FLATTEN/i).skip(R.whitespace),r.namedField,(e,t)=>({type:"flatten",field:t})).desc("FLATTEN <value> [AS <name>]"),groupByClause:r=>R.seqMap(R.regexp(/GROUP BY/i).skip(R.whitespace),r.namedField,(e,t)=>({type:"group",field:t})).desc("GROUP BY <value> [AS <name>]"),clause:r=>R.alt(r.fromClause,r.whereClause,r.sortByClause,r.limitClause,r.groupByClause,r.flattenClause),query:r=>R.seqMap(r.headerClause.trim(r1),r.fromClause.trim(r1).atMost(1),r.clause.trim(r1).many(),(e,t,n)=>({header:e,source:t.length==0?Bl.folder(""):t[0],operations:n,settings:D1}))}),r1=R.alt(R.whitespace,L8.comment).many().map(r=>r.join("")),Sge=r=>r?r.plugins.plugins.dataview?.api:window.DataviewAPI,Dge=r=>r.plugins.enabledPlugins.has("dataview");Ul.DATE_SHORTHANDS=C1;Ul.DURATION_TYPES=w1;Ul.EXPRESSION=ja;Ul.KEYWORDS=x1;Ul.QUERY_LANGUAGE=L8;Ul.getAPI=Sge;Ul.isPluginEnabled=Dge;Ul.parseField=_ge});function Gx(r){if(!r.includes(",")){let o=r.trim();return o?[o]:[]}let e=[],t="",n=!1;for(let o=0;o<r.length;o++){let s=r[o],a=r[o+1];if(s==="["&&a==="["){n=!0,t+=s;continue}if(s==="]"&&a==="]"){n=!1,t+=s;continue}if(s===","&&!n){let l=t.trim();l&&e.push(l),t="";continue}t+=s}let i=t.trim();return i&&e.push(i),e}var P1=b(()=>{});function Yx(r){return r.replace(/[\\"]/g,"\\$&")}function Ige(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U8(r){return Yx(Ige(r))}function rD(r){return typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"}var F1,Kx,V8=b(()=>{F1=UN(B8());Me();P1();Kx=class{static getDataviewAPI(e){let t=(0,F1.getAPI)(e);return t||(F.logMessage("Dataview plugin is not installed or enabled"),null)}static async getFieldValues(e,t){let n=new Set,i=this.getDataviewAPI(e);if(!i)return n;try{let s=`field("${Yx(t)}")`,a=`TABLE ${s} WHERE ${s}`,l=await i.query(a);if(l.successful&&l.value.values)for(let c of l.value.values){let u=c[1];Array.isArray(u)?u.forEach(d=>{d&&typeof d=="string"?n.add(d.trim()):rD(d)?n.add(d.path):d&&typeof d!="object"&&n.add(String(d).trim())}):rD(u)?n.add(u.path):u&&typeof u=="string"?Gx(u).forEach(d=>n.add(d)):u&&typeof u!="object"&&n.add(String(u).trim())}}catch(o){F.logError(new Error(`Failed to query Dataview for field ${t}: ${o}`))}return n}static async getFieldValuesWithFilter(e,t,n={}){let i=new Set,o=this.getDataviewAPI(e);if(!o)return i;try{let a=`field("${Yx(t)}")`,l=[a],c=(n.folders?.length?n.folders:n.folder?[n.folder]:[]).map(v=>v.replace(/^\/+|\/+$/g,
`),o=[],s=!1,a=0,l="",c=[];for(let u of i){if(!s){let d=this.matchFenceOpen(u);d?(s=!0,a=d.length,l=d.info,c=[u]):o.push(u);continue}if(this.matchFenceClose(u,a)){let d=l.trim().split(/\s+/)[0]?.toLowerCase();if(n.size>0&&d!==void 0&&d.length>0&&n.has(d))for(let p=1;p<c.length;p++)o.push(c[p]);s=!1,c=[]}else c.push(u)}if(s)for(let u of c)o.push(u);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}};jc.INLINE_FIELD_REGEX=/(?:^|[\n\r])(?![ \t]*[-*+][ \t]+\[[ xX]\])([^:\n\r]+?)::[ \t]*(.*)$/gmu,jc.FRONTMATTER_REGEX=/^---\r?\n[\s\S]*?\r?\n---\r?\n/,jc.INLINE_CODE_SPAN_REGEX=/`[^`]*`/g,jc.FENCE_OPEN_REGEX=/^[ \t]*(`{3,})([^`]*)$/,jc.FENCE_CLOSE_REGEX=/^[ \t]*(`{3,})[ \t]*$/;Dg=jc});function iD(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 W8(r,e,t){let n=Vl.getInstance(),i=iD(t),o=n.get(e,i);return o||(o=await oD(r,e,t),n.set(e,o,i)),Ya.processValues(o,t).values}async function z8(r,e,t){let n=Vl.getInstance(),i=iD(t),o=n.get(e,i);o||(o=await oD(r,e,t),n.set(e,o,i));let s=Ya.processValues(o,t);return{values:s.values,hasDefaultValue:s.hasDefaultValue}}async function oD(r,e,t){let n=e.trim().toLowerCase();if(n==="tags"||n==="tag"){let i=await Pge(r,t);if(i.size>0)return i}try{if(!t.inline&&Kx.isAvailable(r)){let i=await Kx.getFieldValuesWithFilter(r,e,t);if(i.size>0)return i}}catch{}return await Rge(r,e,t)}async function Pge(r,e){if(!(!!e.folder||!!e.folders?.length||!!e.tags?.length||!!e.excludeFolders?.length||!!e.excludeTags?.length||!!e.excludeFiles?.length)){let n=Fge(r);if(n.size>0)return n}return await Mge(r,e)}function Fge(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}async function Mge(r,e){let t=new Set,n=r.vault.getMarkdownFiles();n=zi.filterFiles(n,e,o=>r.metadataCache.getFileCache(o));let i=50;for(let o=0;o<n.length;o+=i){let a=n.slice(o,o+i).map(async c=>{let u=new Set;try{let d=r.metadataCache.getFileCache(c),f=d?.frontmatter?.tags;if(f!=null){let m=Array.isArray(f)?f:[f];for(let v of m){let g=String(v).trim();g&&u.add(g)}}let p=d?.frontmatter?.tag;if(p!=null){let m=Array.isArray(p)?p:[p];for(let v of m){let g=String(v).trim();g&&u.add(g)}}if(d?.tags)for(let m of d.tags){let v=String(m.tag??"").trim(),g=v.startsWith("#")?v.substring(1):v;g&&u.add(g)}}catch{}return u}),l=await Promise.all(a);for(let c of l)for(let u of c)t.add(u)}return t}async function Rge(r,e,t){let n=new Set,i=r.vault.getMarkdownFiles();i=zi.filterFiles(i,t,s=>r.metadataCache.getFileCache(s));let o=50;for(let s=0;s<i.length;s+=o){let l=i.slice(s,s+o).map(async u=>{let d=new Set;try{let p=r.metadataCache.getFileCache(u)?.frontmatter?.[e];if(p!=null){if(Array.isArray(p))p.forEach(m=>{let v=String(m).trim();v&&d.add(v)});else if(typeof p!="object"){let m=String(p).trim();m&&d.add(m)}}if(t.inline)try{let m=await r.vault.read(u);Dg.getFieldValues(m,e,{includeCodeBlocks:t.inlineCodeBlocks}).forEach(g=>{let y=String(g).trim();y&&d.add(y)})}catch{}}catch{}return d}),c=await Promise.all(l);for(let u of c)for(let d of u)n.add(d)}return n}var $1=b(()=>{V8();ip();nD();M1();R1()});function $ge(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=H8(o);s!==null&&i.push(s)}return i.length>0?i
${l}`:`${l}
${a}`;return await this.app.vault.modify(t,c),t}catch(o){if(z1(o))throw o;return this.noteTemplateFileFailure(o,"Could not append to file with template"),lt(o,"Could not append to file with template"),null}}async getTemplateContent(t){let n=po(this.app,t);if(!n)throw new Error(`Template file not found at path "${t}".`);return await this.app.vault.cachedRead(n)}}});var e9={};Zr(e9,{SingleTemplateEngine:()=>tE});var tE,H1=b(()=>{uD();Me();tE=class extends hd{constructor(t,n,i,o,s){super(t,n,o,s);this.templatePath=i;this.promptScope="noteBody"}setPromptScope(t){this.promptScope=t}async run(){let t=await this.resolveTemplateSourcePath(this.templatePath),n=await this.getTemplateContent(t);return n||F.logError(`Template ${t} not found.`),n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope(this.promptScope,n,()=>this.formatter.formatFileContent(n))),n}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}}});var t9={};Zr(t9,{SingleInlineScriptEngine:()=>j1});var j1,r9=b(()=>{Zx();j1=class extends ql{constructor(e,t,n,i){super(e,t,null,n,i)}async runAndGetOutput(e){let t=Object.getPrototypeOf(async function(){}).constructor;return await new t(e).bind(this.params,this).call()}}});var n9,ws,Lg=b(()=>{n9=require("obsidian");zs();nd();X4();WO();Tt();Wc();n5();a5();uh();Ru();ip();Hs();vl();$1();M1();O1();Cu();Me();$m();vy();K8();Wr();Co();Cr();ws=class extends yl{constructor(t,n,i,o){super(t);this.app=t;this.plugin=n;this.choiceExecutor=i;this.contentValuePromptsAcceptImagePaste=!1;this.dateParser=o||El,i&&(this.variables=i?.variables)}async format(t){let n=t;return n=await this.replaceInlineJavascriptInString(n),n=await this.replaceMacrosInString(n),n=await this.replaceTemplateInString(n),n=await this.replaceGlobalVarInString(n),n=this.replaceDateInString(n),n=this.replaceTimeInString(n),n=await this.replaceValueInString(n),n=await this.replaceSelectedInString(n),n=await this.replaceClipboardInString(n),n=await this.replaceDateVariableInString(n),n=await this.replaceVariableInString(n),n=await this.replaceFieldVarInString(n),n=await this.replaceFileInString(n),n=await this.replaceMathValueInString(n),n=this.replaceRandomInString(n),n}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(pl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}async formatFileName(t,n="generic"){if($s.test(t))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");let i=await this.withPromptScope(n,t,()=>this.format(t));if($s.test(i))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");return i=this.replaceCurrentFileTokensInString(i,{fileName:!0,folder:!0,activeFolder:"path"}),i}async formatFileContent(t){let n=t,i=this.contentValuePromptsAcceptImagePaste;this.contentValuePromptsAcceptImagePaste=!x_(this.promptScope);try{n=await this.format(n)}finally{this.contentValuePromptsAcceptImagePaste=i}return n=this.replaceCurrentFileTokensInString(n,{links:!0,fileName:!0,folder:!0,activeFolder:"content",title:!0}),n}async formatFolderPath(t){if($s.test(t))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");let n=await this.withPromptScope("folder",t,()=>this.format(t));if($s.test(n))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");return this.replaceCurrentFileTokensInString(n,{folder:!0,activeFolder:"path"}).replace(/^\/+/,"")}async formatTemplateFilePath(t){if($s.test(t))throw new Error("{{title}} cannot be used in a template path \u2014 the title is derived from the created file, not the source template.");let n=t;if(n=await this.replaceGlobalVarInString(n),$s.tes
Suggested values for ${i}: ${v.slice(0,3).join(", ")}`)}return n?await n.inputPrompt(`Enter value for ${i}`,m):await Sr.PromptWithContext(this.app,`Enter value for ${i}`,m,void 0,this.getLinkSourcePath()??void 0)}return n?String(await n.suggester(u,u,p,!0)):await an.Suggest(this.app,u,u,{placeholder:p})}catch(i){throw Dt(i)?new St("Input cancelled by user"):i}}generateCacheKey(t){return iD(t)}async suggestForFile(t){this.assertInteractivePrompt(`{{FILE}} (pick a file from ${t.folderPath})`);let n=this.choiceExecutor?.promptProvider;try{let i=zi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,c=>this.app.metadataCache.getFileCache(c)),o=t.label??`Select a file from ${t.folderPath}`;if(i.length===0){let c=`No markdown files found in "${t.folderPath}". Type a value or leave empty.`,u=n?await n.inputPrompt(o,c):await Sr.Prompt(this.app,o,c,void 0,void 0,t.optional?{optional:!0}:void 0);return t.multiSelect?u?[`${as}${u}`]:[]:u?`${as}${u}`:""}let s=Tc(i,c=>this.app.metadataCache.getFileCache(c)),a=i.map(c=>`${gl}${c.path}`);if(t.multiSelect)return(n?await n.suggesterMulti(s,a,{placeholder:o,allowCustomInput:t.allowCustomInput}):await Zp.Suggest(this.app,s,a,{placeholder:o,allowCustomValue:t.allowCustomInput,...t.optional?{skippable:!0}:{}})).map(u=>a.includes(u)?u:`${as}${u}`);if(n){let c=String(await n.suggester(s,a,o,t.allowCustomInput));return c?a.includes(c)?c:`${as}${c}`:""}if(t.allowCustomInput){let c=new Set(i.map(f=>f.basename.toLowerCase())),u=new Set(s.map(f=>f.toLowerCase())),d=await an.Suggest(this.app,s,a,{placeholder:o,valueExists:f=>c.has(f.toLowerCase())||u.has(f.toLowerCase()),...t.optional?{skippable:!0}:{}});return d?a.includes(d)?d:`${as}${d}`:""}return await Nr.Suggest(this.app,s,a,o,void 0,t.optional?{skippable:!0}:void 0)??""}catch(i){throw Dt(i)?new St("Input cancelled by user"):i}}async getMacroValue(t,n){let{SingleMacroEngine:i}=await Promise.resolve().then(()=>(Z8(),Q8)),o=new i(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),s=await o.runAndGetOutput(t,n)??"";return o.getVariables().forEach((a,l)=>{this.variables.set(l,a)}),s}async getTemplateContent(t){let{SingleTemplateEngine:n}=await Promise.resolve().then(()=>(H1(),e9));this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0});let i={visited:this.templateInclusion.visited,depth:this.templateInclusion.depth+1},o=new n(this.app,this.plugin,t,this.choiceExecutor,i);o.setTargetFolderPath(this.targetFolderPath),this.promptScope!=="generic"&&o.setPromptScope(this.promptScope),this.promptRunContext&&o.setPromptRunContext({...this.promptRunContext,draftScopeId:`${this.promptRunContext.draftScopeId??""}#${t}`});let s=await o.run();return this.mergeTemplatePropertyVars(o.getAndClearTemplatePropertyVars()),s}async getSelectedText(){let t=On(this.app);return t?t.editor.getSelection():""}async getClipboardContent(){try{return await navigator.clipboard.readText()}catch{return""}}isTemplatePropertyTypesEnabled(){return this.plugin.settings.enableTemplatePropertyTypes}async replaceInlineJavascriptInString(t){let n=t;for(;dc.test(n);){let i=dc.exec(n);if(!i)break;let o=i.at(1)?.trim();if(o){let{SingleInlineScriptEngine:s}=await Promise.resolve().then(()=>(r9(),t9)),a=new s(this.app,this.plugin,this.choiceExecutor,this.variables),l=await a.runAndGetOutput(o);for(let u in a.params.variables)this.variables.set(u,a.params.variables[u]);let c="";typeof l=="string"?c=l:(typeof l=="number"||typeof l=="boolean"||Array.isArray(l))&&(c=this.renderCollectedOrArrayValue({input:n,matchStart:i.index,matchEnd:i.index+i[0].length,rawValue:l,fallbackKey:"inlineScript",heuristicEnabled:this.isTemplatePropertyTypesEnabled()})??String(l)),n=this.replacer(n,dc,c)}else n=this.replacer(n,dc,"")}return n}async collectValuesManually(t,n){return await oD(this.app,t,n)}}});function lf(r){return new TextEncoder().encode(r).length}function jge(r){let e=0;for(let t of r){if(t.role==="tool"){for(let n of t.results)e+=lf(n.content);continue}if(e+=lf(t.content),t.role==="assistant"&&t.toolCalls){for(let n of t.toolCalls)if(typeof n
> `);this.choiceExecutor.variables.set(n,t),this.choiceExecutor.variables.set(`${n}-quoted`,i)}assertAssignableName(e){nE(e)}}});function X1(r){let e=(0,f9.getFrontMatterInfo)(r);return e.exists?e.contentStart:0}function lve(r,e){let t=X1(r);if(t===0)return 0;if(p9.test(e))return t;let n=p9.exec(r.slice(t));return n?t+n[0].length:t}function Q1(r,e){if(e.length===0)return{content:r,insertedStartOffset:null,insertedEndOffset:null};let t=lve(r,e),n=r.slice(0,t),i=r.slice(t),o=n.length>0&&!n.endsWith(`
`)&&!ave.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 gD(r,e){return Q1(r,e).content}var f9,p9,ave,oE=b(()=>{f9=require("obsidian"),p9=/^[^\S\r\n]*\r?\n/,ave=/^\r?\n/});function Z1(r){return(r??"").trim().replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+|\/+$/g,"").normalize("NFC")}function J1(r,e){return e.some(t=>r===t||r.startsWith(`${t}/`))}function uf(r,e){let t=(e??[]).map(n=>Z1(n)).filter(n=>n.length>0);return t.length===0?!0:r?J1(r.normalize("NFC"),t):!1}var vD=b(()=>{});function df(r,e={}){let t=(r??"").trim();if(!t)throw new sa("Path is empty.");let n=t.replace(/\\/g,"/").normalize("NFC");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new sa(`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 sa("Path is empty after normalization.");for(let a of o){if(a==="."||a==="..")throw new sa(`Refusing path with a traversal segment ("${a}"): "${i}".`);if(a.startsWith("."))throw new sa(`Refusing to write into a dot/config path segment ("${a}"): "${i}".`);cve(a,i)}let s=(e.allowedRoots??[]).map(a=>Z1(a)).filter(a=>a.length>0);if(s.length>0&&!J1(i,s))throw new sa(`Path "${i}" is not under an allowed root (${s.join(", ")}).`);return i}function cve(r,e){if(I_.test(r))throw new sa(`Path segment "${r}" contains control characters: "${e}".`);if(P_.test(r))throw new sa(`Path segment "${r}" contains an illegal character (\\ : * ? " < > |): "${e}".`);if(F_.test(r))throw new sa(`Path segment "${r}" cannot end with a space or a period: "${e}".`);let t=r.split(".")[0]??"";if(t&&Pm(t))throw new sa(`Path segment "${r}" is a reserved device name: "${e}".`)}var sa,m9=b(()=>{M_();vD();sa=class extends Error{constructor(e){super(e),this.name="UnsafeVaultPathError"}}});function Bg(r,e){let t=Object.entries(r),n=new Set(t.map(([o])=>o));if(h9(e.only,n,"only"),h9(e.exclude,n,"exclude"),e.only){let o=new Set(e.only);t=t.filter(([s])=>o.has(s))}if(e.exclude){let o=new Set(e.exclude);t=t.filter(([s])=>!o.has(s))}let i=e.prefix??"";return Object.fromEntries(t.map(([o,s])=>[i+o,s]))}function sE(r){return{...r,__qaTool:!0}}function h9(r,e,t){if(!r)return;let n=r.filter(i=>!e.has(i));n.length!==0&&F.logWarning(`AI tools: ${t} listed unknown tool name(s) ${n.map(i=>`"${i}"`).join(", ")}. Valid names: ${[...e].join(", ")}.`)}var yD=b(()=>{Me()});function x9(r,e={}){let t=e.allowedRoots,n={read_note:pf({description:"Read a note's full markdown content by vault path.",inputSchema:ff({path:aa("Vault path to the note, e.g. Notes/Foo.md")},["path"]),readOnly:!0,execute:async({path:i})=>{let o=df(String(i),{allowedRoots:t}),s=r.vault.getAbstractFileByPath(o);if(!(s instanceof tN.TFile))return{found:!1,path:o};let a=await r.vault.cachedRead(s);return{found:!0,path:o,content:a.length>g9?a.slice(0,g9)+`
\u2026[truncated]`:a}}}),list_notes:pf({description:"List markdown notes, optionally within a folder.",inputSchema:ff({folder:aa("Folder to list (omit for the whole vault)."),limit:v9("Max results (default 100, capped at 200).")},[]),readOnly:!0,execute:async({folder:i,limit:o})=>{let s=i?df(String(i),{allowedRoots:t}):"",a=w9(b9(o,uve),1,dve),l=rs(r,s).filter(c=>uf(c.path,t));return{total:l.length,notes:l.slice(0,a).map(c=>({path:c.path,basename:c.basename}))}}}),search_notes:pf({description:"Search notes by name and/or content. Returns matching paths with a short snippet.",inputSchema:ff({query:aa("Text to search for."),in:y9(["name","content","both"],"Where to search (default both)."),limit:v9("Max results (default 25, capped at 50).")},["query"]),readOnly:!0,execute:async({query:i,in:o,limit:s})=>{let a=String(i).toLowerCase(),l=o??"both",c=w9(b9(s,pve),1,fve),u=r.vault.getMarkdownFiles().filter(m=>uf(m.path,t)),d=[],f=0,p=!1;for(let m of u){if(d.length>=c)break;if(l!=="content"&&m.basename.toLowerCase().includes(a)){d.push({path:m.path});continue}if(l!=="name"){if(f>=mve){p=!0;continue}f++;let g=await r.vault.cachedRead(m),y=g.toLowerCase().indexOf(a);y>=0&&d.push({path:m.path,snippet:gve(g,y)})}}return{results:d,scannedFiles:f,truncated:d.length>=c||p}}}),get_property_values:pf({description:"List the distinct values a frontmatter property takes across the vault (e.g. existing tags or statuses).",inputSchema:ff({field:aa("Frontmatter property name."),folder:aa("Optional folder scope.")},["field"]),readOnly:!0,execute:async({field:i,folder:o})=>{let s=o?df(String(o),{allowedRoots:t}):"",a=(o?rs(r,s):r.vault.getMarkdownFiles()).filter(c=>uf(c.path,t)),l=new Set;for(let c of a){let d=r.metadataCache.getFileCache(c)?.frontmatter?.[String(i)];if(d!=null){for(let f of Array.isArray(d)?d:[d])if(typeof f!="object"){let p=String(f).trim();p&&l.add(p)}}}return{field:String(i),values:[...l].sort().slice(0,200)}}}),create_note:pf({description:"Create a new markdown note. Fails if the path already exists.",inputSchema:ff({path:aa("Vault path for the new note."),content:aa("Initial markdown content.")},["path"]),needsApproval:!0,execute:async({path:i,content:o})=>{let s=df(eN(String(i)),{allowedRoots:t});return await lg(r,s),await hve(r,s),{created:!0,path:(await r.vault.create(s,String(o??""))).path}}}),append_to_note:pf({description:"Append text to an existing note (frontmatter-aware for top inserts).",inputSchema:ff({path:aa("Vault path to the existing note."),content:aa("Markdown to append."),position:y9(["top","bottom"],"Where to add it (default bottom).")},["path","content"]),needsApproval:!0,execute:async({path:i,content:o,position:s})=>{let a=df(eN(String(i)),{allowedRoots:t}),l=C9(r,a);await lg(r,a);let c=await r.vault.read(l),u=String(o),d=s==="top"?gD(c,u.endsWith(`
`)?u:u+`
`):`${c}${c.endsWith(`
`)||c.length===0?"":`
`}${u}`;return await r.vault.modify(l,d),{appended:!0,path:a}}}),insert_under_heading:pf({description:"Insert markdown under an existing heading (matched exactly). Errors if the heading is not found.",inputSchema:ff({path:aa("Vault path to the existing note."),heading:aa("Exact heading text (without the # markers)."),content:aa("Markdown to insert under the heading.")},["path","heading","content"]),needsApproval:!0,execute:async({path:i,heading:o,content:s})=>{let a=df(eN(String(i)),{allowedRoots:t}),l=C9(r,a);await lg(r,a);let c=r.metadataCache.getFileCache(l)?.headings??[],u=c.find(p=>p.heading===String(o));if(!u)throw new Error(`Heading "${o}" not found in ${a}`);let d=await r.vault.read(l),f=vve(d,u.position.start.line,u.level,String(s),c);return await r.vault.modify(l,f),{inserted:!0,path:a,heading:String(o)}}})};return Bg(n,e)}function pf(r){return{...r,__qaTool:!0}}function ff(r,e){return{type:"object",properties:r,required:e}}function aa(r){return{type:"string",description:r}}function v9(r){return{type:"integer",description:r}}function y9(r,e){return{type:"string",enum:r,description:e}}function b9(r,e){let t=Number(r);return Number.isFinite(t)?Math.floor(t):e}function w9(r,e,t){return Math.max(e,Math.min(t,r))}function eN(r){if(/\.md$/i.test(r))return r;if(/\.[a-z0-9]+$/i.test(r))throw new Error(`This tool only operates on markdown notes (.md); refused path: "${r}".`);return`${r}.md`}function C9(r,e){let t=r.vault.getAbstractFileByPath(e);if(!(t instanceof tN.TFile))throw new Error(`Note not found: ${e}`);return t}async function hve(r,e){let t=e.lastIndexOf("/");if(t<=0)return;let n=e.slice(0,t);if(!r.vault.getAbstractFileByPath(n))try{await r.vault.createFolder(n)}catch{}}function gve(r,e){let t=Math.max(0,e-40);return r.slice(t,e+80).replace(/\s+/g," ").trim()}function vve(r,e,t,n,i){let o=r.split(`
`),s=o.length;for(let u of i)if(u.position.start.line>e&&u.level<=t){s=u.position.start.line;break}let a=n.endsWith(`
`)?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 tN,g9,uve,dve,pve,fve,mve,E9=b(()=>{tN=require("obsidian");qt();oE();vD();m9();sO();yD();g9=16e3,uve=100,dve=200,pve=25,fve=50,mve=400});function _9(r,e={}){let t=e.allowedRoots,n=()=>{let s=r.workspace.getActiveFile();return!(s instanceof bD.TFile)||s.extension!=="md"?null:uf(s.path,t)?s:null},i=()=>{let s=r.workspace.getActiveViewOfType(bD.MarkdownView);return s&&uf(s.file?.path,t)?s:null},o={get_active_note:sE({description:"Get the currently active note (path, basename, and content). Returns active:null if there is none.",inputSchema:{type:"object",properties:{}},readOnly:!0,execute:async()=>{let s=n();if(!s)return{active:null};let a=await r.vault.cachedRead(s);return{active:{path:s.path,basename:s.basename,content:a.length>T9?a.slice(0,T9)+`
\u2026[truncated]`:a}}}}),get_selection:sE({description:"Get the text currently selected in the active editor (empty string if none).",inputSchema:{type:"object",properties:{}},readOnly:!0,execute:async()=>({selection:i()?.editor?.getSelection()??""})})};return Bg(o,e)}var bD,T9,A9=b(()=>{bD=require("obsidian");vD();yD();T9=16e3});function k9(r={}){let e={get_date:sE({description:"Get the current date/time. Optionally pass a moment.js format and a day offset.",inputSchema:{type:"object",properties:{format:{type:"string",description:"moment.js format, e.g. YYYY-MM-DD"},offset:{type:"integer",description:"Day offset from today (e.g. 1 = tomorrow)."}}},readOnly:!0,execute:async({format:t,offset:n})=>({date:Bs({format:t!=null?String(t):void 0,offset:n!=null?Number(n):void 0})})})};return Bg(e,r)}var S9=b(()=>{qt();yD()});var aE,Ug,D9=b(()=>{aE=require("obsidian");Wr();BO();Ug=class r extends aE.Modal{constructor(t,n,i=[],o){super(t);this.items=n;this.selectedItems=i;this.header=o;this._selectedItems=[...i],this.promise=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.display(),this.open(),this.picker.focusSearchOnOpen()}static Open(t,n,i,o){return new r(t,n,i,o).promise}display(){this.contentEl.empty(),this.containerEl.addClass("quickAddModal","qaSearchableMultiSelectModal","checkboxPrompt"),this.header&&(this.titleEl.textContent=this.header),this.addSearchableOptions(),this.addSubmitButton()}onClose(){super.onClose(),this.resolved||this.rejectPromise(tn())}addSearchableOptions(){this.picker=new Qp(this.contentEl,{items:this.items.map(t=>({key:t,value:t,label:t})),isSelected:({value:t})=>this._selectedItems.includes(t),onToggle:({value:t},n)=>{if(n){this._selectedItems.includes(t)||this._selectedItems.push(t);return}this._selectedItems=this._selectedItems.filter(i=>i!==t)},getSelectedCount:()=>new Set(this._selectedItems).size})}addSubmitButton(){let t=this.contentEl.createDiv("submitButtonContainer");new aE.ButtonComponent(t).setButtonText("Submit").setCta().onClick(()=>{this.resolved=!0,this.resolvePromise(this._selectedItems),this.close()}),new aE.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.close()})}}});var wD,lE,I9=b(()=>{wD=require("obsidian"),lE=class r extends wD.Modal{constructor(t,n,i){super(t);this.header=n;this.text=i;this.waitForClose=new Promise(o=>{this.resolvePromise=o}),this.open(),this.display()}static Show(t,n,i){return new r(t,n,i).waitForClose}display(){this.contentEl.empty(),this.titleEl.textContent=this.header,String.isString(this.text)?this.contentEl.createEl("p",{text:this.text}):Array.isArray(this.text)&&this.text.forEach(i=>this.contentEl.createEl("p",{text:i}));let t=this.contentEl.createDiv(),n=new wD.ButtonComponent(t).setButtonText("OK").onClick(()=>this.close());Object.assign(t.style,{display:"flex",justifyContent:"flex-end"}),n.buttonEl.focus()}onClose(){super.onClose(),this.resolvePromise()}}});var CD,P9=b(()=>{Ru();$1();fl();CD=class extends mn{constructor(t,n,i){super(t,n);this.cachedValues=null;this.fieldInput=i;let o=Yi.parse(i);this.fieldName=o.fieldName,this.filters=o.filters}async getSuggestions(t){this.cachedValues||(this.cachedValues=await W8(this.app,this.fieldName,this.filters));let n=(t||"").toLowerCase();return n?this.cachedValues.filter(i=>i.toLowerCase().includes(n)).slice(0,200):this.cachedValues.slice(0,200)}renderSuggestion(t,n){this.renderMatch(n,t,this.getCurrentQuery())}selectSuggestion(t){this.inputEl.value=t;let n=new Event("input",{bubbles:!0});n.fromCompletion=!0,this.inputEl.dispatchEvent(n),this.close()}}});var F9,rN,xD,M9=b(()=>{F9=require("obsidian");fl();rN=200,xD=class extends mn{constructor(t,n,i,o,s,a,l){super(t,n);this.getOptions=i;this.isSelected=o;this.onSelect=s;this.multiSelect=a;this.allowCustomInput=l;a&&n.setAttribute("aria-multiselectable","true")}getSuggestions(t){let n=t.trim(),i=this.getOptions().filter(u=>!this.isSelected(u.value));if(!n)return i.slice(0,rN);let o=(0,F9.prepareFuzzySearch)(n),s=i.map(u=>({option:u,match:o(`${u.label} ${u.path}`)})).filter(u=>u.match!==null).sort((u,d)=>d.match.score-u.match.
${e}`:gD(r,`${e}
`)}function bve(r){return r==null||r===""||Array.isArray(r)&&r.length===0}function U9(r){return typeof r=="string"?r.length>0?[r]:[]:!Array.isArray(r)||!r.every(e=>typeof e=="string")?null:r}function V9(r,e){let t=U9(r),n=U9(e);if(t===null||n===null)return;let i=[],o=new Set(t);for(let s of n)s.length===0||o.has(s)||(o.add(s),i.push(s));if(i.length!==0)return[...t,...i]}var _D,cE,qg,AD=b(()=>{_D=require("obsidian");Me();qt();aD();Sx();D_();by();Rg();oE();uD();Tl();A_();cE=[{id:"cursor",label:"Insert at cursor",description:"Inserts the template at the cursor position in the editor."},{id:"top",label:"Insert at top",description:"Inserts the template below the note'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."}];qg=class extends hd{constructor(t,n,i,o,s,a,l){super(t,n,a);this.targetFile=i;this.templatePath=o;this.mode=s;this.resolvedTemplatePath=l??null}async run(){await this.apply()}async getResolvedTemplatePath(){return this.resolvedTemplatePath===null&&(this.resolvedTemplatePath=await this.resolveTemplateSourcePath(this.templatePath)),this.resolvedTemplatePath}async apply(){switch(Mi(this.templatePath,"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=ai(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}=B9(n);return s.trim().length>0&&await this.app.vault.process(this.targetFile,a=>yve(a,s,t)),await this.mergeFrontmatterProperties(o,i),this.targetFile}async insertTemplateAtCursor(){let t=Gv(this.app,this.targetFile);Mi(t,"Cannot insert at cursor: the note is not open in the active editor.");let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=B9(n);return s.trim().length>0&&t.editor.replaceSelection(s),await this.mergeFrontmatterProperties(o,i),this.targetFile}async formatTemplateForTargetFile(){let t=await this.getTemplateContent(await this.getResolvedTemplatePath());this.formatter.setTitle(this.targetFile.basename),this.formatter.setTargetFolderPath(Wo(this.targetFile.path));let n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",t,()=>this.formatter.formatFileContent(t))),i=this.formatter.getAndClearTemplatePropertyVars();return this.targetFile.extension==="md"&&(n=await pc(this.app,n,this.targetFile)),{formatted:n,templatePropertyVars:i}}async mergeFrontmatterProperties(t,n){if(!t||this.targetFile.extension!=="md")return;let i;try{i=(0,_D.parseYaml)(t)}catch(o){F.logWarning(`Could not parse template frontmatter for merging: ${o}`);return}if(!(!i||typeof i!="object"||Array.isArray(i))){if(n&&n.size>0)for(let[o,s]of n){let a=o.includes(Fa.PATH_SEPARATOR)?o.split(Fa.PATH_SEPARATOR):[o];q1(i,a,k_(s))
`,shouldMerge:a?.shouldMerge??!0,maxChunkTokens:a?.maxChunkTokens},(g,y)=>{let w={...l,...y};return d(g,w,!1)});return v?((a?.shouldAssignVariables||a?.assignToVariable)&&Object.entries(v).forEach(([g,y])=>{n.variables.set(g,y)}),v):(lt(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>BG(),getMaxTokens:i=>Oh(i).model.maxTokens,estimateTokens(i){return Uo(i)},countTokens(i,o){return H9||(H9=!0,F.logMessage("quickAddApi.ai.countTokens is deprecated and now returns a provider-agnostic estimate (the model argument is ignored). Use estimateTokens(text) instead.")),Uo(i)},getRequestLogs(i=10){return L4(i)},getRequestLogById(i){return U4(i)},getLastRequestLog(){return V4()},clearRequestLogs(){q4()},agent:i=>new hD(e,t,n,i),tool:i=>({...i,__qaTool:!0}),stepCountIs:i=>({stepNumber:o})=>o>=i,hasToolCall:i=>({toolCallNames:o})=>o.includes(i),tools:{vault:i=>x9(e,i),workspace:i=>_9(e,i),system:i=>k9(i)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async i=>await navigator.clipboard.writeText(i),getSelection:()=>{let i=On(e);return i?i.editor.getSelection()??"":""},getSelectedText:()=>{let i=On(e);return i?i.editor.somethingSelected()?i.editor.getSelection():(lt(new Error("No text selected"),"Could not get selected text"),""):(lt(new Error("No active Markdown editor"),"Could not get selected text"),"")}},date:{now:(i,o)=>Bs({format:i,offset:o}),tomorrow:i=>Bs({format:i,offset:1}),yesterday:i=>Bs({format:i,offset:-1})},fieldSuggestions:{getFieldValues:async(i,o)=>{let s=o?.includeInlineCodeBlocks?.map(u=>u.trim().toLowerCase()).filter(u=>u.length>0),a={folder:o?.folder,folders:o?.folders,tags:o?.tags,inline:o?.includeInline??!1,inlineCodeBlocks:s},l=e.vault.getMarkdownFiles();l=TD.filterFiles(l,a,u=>e.metadataCache.getFileCache(u));let c=new Set;for(let u of l){let f=e.metadataCache.getFileCache(u)?.frontmatter?.[i];if(f!=null){if(Array.isArray(f))f.forEach(p=>{if(p==null||typeof p=="object")return;let m=String(p).trim();m&&c.add(m)});else if(typeof f!="object"){let p=String(f).trim();p&&c.add(p)}}if(a.inline)try{let p=await e.vault.read(u);Dg.getFieldValues(p,i,{includeCodeBlocks:s}).forEach(v=>c.add(v))}catch{}}return Array.from(c).sort()},clearCache:i=>{Vl.getInstance().clear(i)}}}}static async inputPrompt(e,t,n,i,o){try{return await Sr.Prompt(e,t,n,i,void 0,o)}catch(s){Yc(s)}}static async datePrompt(e,t,n){try{let i=await ef.Prompt(e,t,n?.placeholder,n?.defaultValue,n?.dateFormat);if(i&&i.startsWith("@date:")){let o=i.slice(6);return(n?.dateFormat?Nl(o,n.dateFormat):null)??o}return i}catch(i){Yc(i)}}static async wideInputPrompt(e,t,n,i,o){try{return await ld.Prompt(e,t,n,i,void 0,o)}catch(s){Yc(s)}}static async yesNoPrompt(e,t,n){let i;try{i=await Xi.Ask(e,t,n)}catch(o){Yc(o)}if(i===null)throw new St(yu);return i}static async infoDialog(e,t,n){try{return await lE.Show(e,t,n)}catch(i){Yc(i)}}static async suggester(e,t,n,i,o=!1,s){try{let a;return typeof t=="function"?a=n.map((l,c,u)=>fn(t(l,c,u))):a=t.map(l=>fn(l)),o?await an.Suggest(e,a,n,{...i?{placeholder:i}:{},...s?.renderItem?{renderItem:s.renderItem}:{}}):await Nr.Suggest(e,a,n,i,s?.renderItem)}catch(a){Yc(a)}}static async checkboxPrompt(e,t,n,i){try{return await(i===void 0?Ug.Open(e,t,n):Ug.Open(e,t,n,i))}catch(o){Yc(o)}}}});var jg,sN=b(()=>{L1();jg=class extends Ig{}});function Y9(r){return new Promise(e=>window.setTimeout(e,r))}function mf(r){return r.split(`
`)}var kD=b(()=>{});async function X9(r,e){return r.mode==="script"?await e.evaluateScriptCondition(r):Sve(r,e.variables)}function Sve(r,e){let t=r.variableName?.trim();if(!t)return F.logWarning("Conditional command skipped: No variable name configured."),!1;if(!(t in e))return F.logWarning(`Conditional command skipped: Variable '${t}' is not defined.`),!1;let n=e[t];switch(r.operator){case"isTruthy":return!!n;case"isFalsy":return!n}if(Ou(r.operator)){let i=YV(r);return i===void 0?(F.logWarning(`Conditional command: Operator '${r.operator}' requires a comparison value.`),!1):r.operator==="contains"?K9(n,i,r):r.operator==="notContains"?!K9(n,i,r):Dve(n,i,r)}return!1}function K9(r,e,t){if(r==null)return!1;if(typeof e=="string"&&e.length===0)return F.logWarning("Conditional command: 'contains' operator requires a non-empty comparison value."),!1;if(Array.isArray(r))return r.map(o=>QP(o,t.valueType)).some(o=>o===e);if(typeof r=="string")return r.includes($u(e));if(typeof r=="number"&&typeof e=="number")return r===e;let n=$u(r),i=$u(e);return typeof n=="string"&&n.includes(i)}function Dve(r,e,t){let n=QP(r,t.valueType);switch(t.operator){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return SD(n,e,(i,o)=>i<o);case"lessThanOrEqual":return SD(n,e,(i,o)=>i<=o);case"greaterThan":return SD(n,e,(i,o)=>i>o);case"greaterThanOrEqual":return SD(n,e,(i,o)=>i>=o);default:return!1}}function SD(r,e,t){let n=Number(r),i=Number(e);return Number.isNaN(n)||Number.isNaN(i)?(F.logWarning("Conditional command numeric comparison failed: non-numeric value encountered."),!1):t(n,i)}var Q9=b(()=>{Me();Rm()});function Z9(r,e=void 0){return r==="horizontal"?"horizontal":r==="vertical"?"vertical":e}function gd(r,e,t){return t?{location:r,direction:t,focus:e,mode:"default"}:{location:r,focus:e,mode:"default"}}function J9(r){let e=r.focus??!0;if(r.location)switch(r.location){case"reuse":return gd("reuse",e);case"tab":return gd("tab",e);case"split":return gd("split",e,Z9(r.direction,"vertical"));case"window":return gd("window",e);case"left-sidebar":return gd("left-sidebar",e);case"right-sidebar":return gd("right-sidebar",e);default:break}let t=r.openInNewTab??!1,n=Z9(r.direction);return t?gd("split",e,n??"vertical"):gd("reuse",e)}var eK=b(()=>{Ck()});function tK(r){let e={hasOwnProperty:t=>r.has(t)};return new Proxy(e,{get(t,n){if(n==="hasOwnProperty")return e.hasOwnProperty;if(typeof n=="string")return r.get(n)},set(t,n,i){return typeof n!="string"||r.set(n,i),!0},deleteProperty(t,n){return typeof n!="string"||r.delete(n),!0},has(t,n){return typeof n=="string"&&r.has(n)},ownKeys(){return Array.from(r.keys())},getOwnPropertyDescriptor(t,n){if(n==="hasOwnProperty")return{value:e.hasOwnProperty,writable:!0,configurable:!0,enumerable:!1};if(!(typeof n!="string"||!r.has(n)))return{value:r.get(n),writable:!0,configurable:!0,enumerable:!0}}})}var rK=b(()=>{});function sK(r){return r!==null&&typeof r=="object"}function Pve(r){return typeof r=="function"}function aK(r){return sK(r)}function Fve(r){if(!aK(r))return;let{settings:e}=r;return sK(e)?e:void 0}function nK(r,e="command"){if(typeof r!="string"||!r.trim())return`the saved entry has no ${e} type, so QuickAdd cannot tell what it was meant to do. It is in .obsidian/plugins/quickadd/data.json.`;let t=e==="command"?Mve.get(r):void 0;return t||`QuickAdd does not recognise the ${e} type '${r}'. It can come from a newer version of QuickAdd, an imported package, or a hand-edited .obsidian/plugins/quickadd/data.json.`}function iK(r){return`${r.scriptPath}::${r.exportName??"default"}`}var Ive,oK,Mve,ql,Zx=b(()=>{Ive=UN(require("obsidian"));Me();Cr();Yr();oN();sN();Wc();$g();Og();hl();qt();gs();k$();A$();S$();D$();I$();P$();F$();M$();R$();$$();kD();DS();Xp();It();Lg();Nh();es();qt();oK=require("obsidian");Os();Wr();Co();hk();NT();Uc();Q9();Qx();eK();rK();Ii();Mve=new Map([["InfiniteAIAssistant",'QuickAdd has removed the "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 use
An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app \u2014 please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${r}"
https://svelte.dev/e/invariant_violation`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/invariant_violation")}function FE(r){if(te){let e=new Error(`lifecycle_outside_component
\`${r}(...)\` can only be used during component initialisation
https://svelte.dev/e/lifecycle_outside_component`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function YN(){if(te){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 lI(){if(te){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 KN(){if(te){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 cI(r,e,t){if(te){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 XN(r,e,t){if(te){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 QN(r){if(te){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 ZN(){if(te){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 JN(r){if(te){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 eL(){if(te){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 tL(){if(te){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 rL(){if(te){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 nL(r){if(te){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 iL(r){if(te){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 oL(){if(te){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 sL(){if(te){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 aL(){if(te){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 lL(){if(te){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 Za="font-weight: bold",Ja="font-weight: normal";function cL(r){te?console.warn(`%c[svelte] await_reactivity_loss
%cDetected reactivity loss when reading \`${r}\`. This happens when state is read in an async function after an earlier \`await\`
https://svelte.dev/e/await_reactivity_loss`,Za,Ja):console.warn("https://svelte.dev/e/await_reactivity_loss")}function uL(r,e){te?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`,Za,Ja):console.warn("https://svelte.dev/e/await_waterfall")}function dL(){te?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`,Za,Ja):console.warn("https://svelte.dev/e/derived_inert")}function pL(r,e,t){te?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`,Za,Ja):console.warn("https://svelte.dev/e/hydration_attribute_changed")}function Cd(r){te?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`,Za,Ja):console.warn("https://svelte.dev/e/hydration_mismatch")}function fL(){te?console.warn(`%c[svelte] lifecycle_double_unmount
%cTried to unmount a component that was not mounted
https://svelte.dev/e/lifecycle_double_unmount`,Za,Ja):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function mL(){te?console.warn("%c[svelte] select_multiple_invalid_value\n%cThe `value` property of a `<select multiple>` element should be an array, but it received a non-array value. The selection will be kept as is.\nhttps://svelte.dev/e/select_multiple_invalid_value",Za,Ja):console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function ME(r){te?console.warn(`%c[svelte] state_proxy_equality_mismatch
%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${r}\` will produce unexpected results
https://svelte.dev/e/state_proxy_equality_mismatch`,Za,Ja):console.warn("https://svelte.dev/e/state_proxy_equality_mismatch")}function hL(){te?console.warn(`%c[svelte] state_proxy_unmount
%cTried to unmount a state proxy, rather than a component
https://svelte.dev/e/state_proxy_unmount`,Za,Ja):console.warn("https://svelte.dev/e/state_proxy_unmount")}function gL(){te?console.warn("%c[svelte] svelte_boundary_reset_noop\n%cA `<svelte:boundary>` `reset` function only resets the boundary the first time it is called\nhttps://svelte.dev/e/svelte_boundary_reset_noop",Za,Ja):console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}var Re=!1;function Dn(r){Re=r}var Ze;function tr(r){if(r===null)throw Cd(),Gl;return Ze=r}function Yn(){return tr(hi(Ze))}function S(r){if(Re){if(hi(Ze)!==null)throw Cd(),Gl;Ze=r}}function In(r=1){if(Re){for(var e=r,t=Ze;e--;)t=hi(t);Ze=t}}function el(r=!0){for(var e=0,t=Ze;;){if(t.nodeType===jo){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=hi(t);r&&t.remove(),t=i}}function av(r){if(!r||r.nodeType!==jo)throw Cd(),Gl;return r.data}function RE(r){return r===this.v}function $E(r,e){return r!=r?e==e:r!==e||r!==null&&typeof r=="object"||typeof r=="function"}function OE(r){return!$E(r,this.v)}var Jr=!1,Kl=!1,pa=!1;var O7="font-weight: bold",N7="font-weight: normal";function uI(r){te?console.warn(`%c[svelte] state_snapshot_uncloneable
%c${r?`The following properties cannot be cloned with \`$state.snapshot\` \u2014 the return value contains the originals:
${r}`:"Value cannot be cloned with `$state.snapshot` \u2014 the original value was returned"}
https://svelte.dev/e/state_snapshot_uncloneable`,O7,N7):console.warn("https://svelte.dev/e/state_snapshot_uncloneable")}var L7=[];function fa(r,e=!1,t=!1){if(te&&!e){let n=[],i=lv(r,new Map,"",n,null,t);if(n.length===1&&n[0]==="")uI();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`),uI(a)}return i}return lv(r,new Map,"",L7,null,t)}function lv(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(da(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]=lv(c,e,te?`${t}[${l}]`:t,n,null,o))}return a}if(iu(r)===AE){a={},e.set(r,a),i!==null&&e.set(i,a);for(var u of Object.keys(r))a[u]=lv(r[u],e,te?`${t}.${u}`:t,n,null,o);return a}if(r instanceof Date)return structuredClone(r);if(typeof r.toJSON=="function"&&!o)return lv(r.toJSON(),e,te?`${t}.toJSON()`:t,n,r)}if(r instanceof EventTarget)return r;try{return structuredClone(r)}catch{return te&&n.push(t),r}}var cv=null;function Ni(r,e){return r.label=e,NE(r.v,e),r}function NE(r,e){return r?.[DE]?.(e),r}function ma(r){let e=new Error,t=B7();return t.length===0?null:(t.unshift(`
`),Oi(e,"stack",{value:t.join(`
`)}),Oi(e,"name",{value:r}),e)}function B7(){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 yL(r,e){if(!te)throw new Error("invariant(...) was not guarded by if (DEV)");r||jN(e)}var _t=null;function Xl(r){_t=r}var tl=null;function Af(r){tl=r}var ha=null;function LE(r){ha=r}function we(r,e=!1,t){_t={p:_t,i:!1,c:null,e:null,s:r,x:null,r:Fe,l:Kl&&!e?{s:null,u:null,$:[]}:null},te&&(_t.function=t,ha=t)}function Ce(r){var e=_t,t=e.e;if(t!==null){e.e=null;for(var n of t)dI(n)}return r!==void 0&&(e.x=r),e.i=!0,_t=e.p,te&&(ha=_t?.function??null),r??{}}function ga(){return!Kl||_t!==null&&_t.l===null}var xd=[];function bL(){var r=xd;xd=[],kE(r)}function Br(r){if(xd.length===0&&!Ed){var e=xd;queueMicrotask(()=>{e===xd&&bL()})}xd.push(r)}function wL(){for(;xd.length>0;)bL()}var pI=new WeakMap;function BE(r){var e=Fe;if(e===null)return je.f|=8388608,r;if(te&&r instanceof Error&&!pI.has(r)&&pI.set(r,U7(r,e)),(e.f&32768)===0&&(e.f&4)===0)throw te&&!e.parent&&r instanceof Error&&CL(r),r;ya(r,e)}function ya(r,e){if(!(e!==null&&(e.f&16384)!==0)){for(;e!==null;){if((e.f&128)!==0){if((e.f&32768)===0)throw r;try{e.b.error(r);return}catch(t){r=t}}e=e.parent}throw te&&r instanceof Error&&CL(r),r}}function U7(r,e){let t=Ao(r,"message");if(!(t&&!t.configurable)){for(var n=dv?" ":" ",i=`
${n}in ${e.fn?.name||"<unknown>"}`,o=e.ctx;o!==null;)i+=`
${n}in ${o.function?.[Ts].split("/").pop()}`,o=o.p;return{message:r.message+`
${i}
`,stack:r.stack?.split(`
`).filter(s=>!s.includes("svelte/src/internal")).join(`
`)}}}function CL(r){let e=pI.get(r);e&&(Oi(r,"message",{value:e.message}),Oi(r,"stack",{value:e.stack}))}var V7=-7169;function rr(r,e){r.f=r.f&V7|e}function kf(r){(r.f&512)!==0||r.deps===null?rr(r,1024):rr(r,4096)}function xL(r){if(r!==null)for(let e of r)(e.f&2)===0||(e.f&65536)===0||(e.f^=65536,xL(e.deps))}function UE(r,e,t){(r.f&2048)!==0?e.add(r):(r.f&4096)!==0&&t.add(r),xL(r.deps),rr(r,1024)}var EL=!1,VE=!1;function fI(r){var e=VE;try{return VE=!1,[r(),VE]}finally{VE=e}}function Ad(r){Re&&gi(r)!==null&&Df(r)}var TL=!1;function qE(){TL||(TL=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{if(!r.defaultPrevented)for(let e of r.target.elements)e[ou]?.()})},{capture:!0}))}function ks(r){var e=je,t=Fe;Mn(null),Rn(null);try{return r()}finally{Mn(e),Rn(t)}}function WE(r,e,t,n=t){r.addEventListener(e,()=>ks(t));let i=r[ou];i?r[ou]=()=>{i(),n(!0)}:r[ou]=()=>n(!0),qE()}function _L(r){let e=0,t=Ui(0),n;return te&&Ni(t,"createSubscriber version"),()=>{su()&&(h(t),Qn(()=>(e===0&&(n=Ot(()=>r(()=>kd(t)))),e+=1,()=>{Br(()=>{e-=1,e===0&&(n?.(),n=void 0,kd(t))})})))}}var W7=589824;function hv(r,e,t,n){new mI(r,e,t,n)}var Go,pv,Ss,Sd,Do,Ds,io,Yo,Zl,Dd,au,If,fv,mv,rl,jE,sr,kL,SL,hI,DL,gI,zE,HE,vI,yI,mI=class{constructor(e,t,n,i){it(this,sr);le(this,"parent");le(this,"is_pending",!1);le(this,"transform_error");it(this,Go);it(this,pv,Re?Ze:null);it(this,Ss);it(this,Sd);it(this,Do);it(this,Ds,null);it(this,io,null);it(this,Yo,null);it(this,Zl,null);it(this,Dd,0);it(this,au,0);it(this,If,!1);it(this,fv,new Set);it(this,mv,new Set);it(this,rl,null);it(this,jE,_L(()=>(et(this,rl,Ui(H(this,Dd))),te&&Ni(H(this,rl),"$effect.pending()"),()=>{et(this,rl,null)})));et(this,Go,e),et(this,Ss,t),et(this,Sd,o=>{var s=Fe;s.b=this,s.f|=128,n(o)}),this.parent=Fe.b,this.transform_error=i??this.parent?.transform_error??(o=>o),et(this,Do,oo(()=>{if(Re){let o=H(this,pv);Yn();let s=o.data==="[!";if(o.data.startsWith("[?")){let l=JSON.parse(o.data.slice("[?".length));xt(this,sr,SL).call(this,l)}else s?xt(this,sr,DL).call(this):xt(this,sr,kL).call(this)}else xt(this,sr,gI).call(this)},W7)),Re&&et(this,Go,Ze)}defer_effect(e){UE(e,H(this,fv),H(this,mv))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!H(this,Ss).pending}update_pending_count(e,t){xt(this,sr,vI).call(this,e,t),et(this,Dd,H(this,Dd)+e),!(!H(this,rl)||H(this,If))&&(et(this,If,!0),Br(()=>{et(this,If,!1),H(this,rl)&&ba(H(this,rl),H(this,Dd))}))}get_effect_pending(){return H(this,jE).call(this),h(H(this,rl))}error(e){if(!H(this,Ss).onerror&&!H(this,Ss).failed)throw e;qe?.is_fork?(H(this,Ds)&&qe.skip_effect(H(this,Ds)),H(this,io)&&qe.skip_effect(H(this,io)),H(this,Yo)&&qe.skip_effect(H(this,Yo)),qe.oncommit(()=>{xt(this,sr,yI).call(this,e)})):xt(this,sr,yI).call(this,e)}};Go=new WeakMap,pv=new WeakMap,Ss=new WeakMap,Sd=new WeakMap,Do=new WeakMap,Ds=new WeakMap,io=new WeakMap,Yo=new WeakMap,Zl=new WeakMap,Dd=new WeakMap,au=new WeakMap,If=new WeakMap,fv=new WeakMap,mv=new WeakMap,rl=new WeakMap,jE=new WeakMap,sr=new WeakSet,kL=function(){try{et(this,Ds,$n(()=>H(this,Sd).call(this,H(this,Go))))}catch(e){this.error(e)}},SL=function(e){let t=H(this,Ss).failed,{reset:n,invoke_onerror:i}=xt(this,sr,hI).call(this,e);Br(i),t&&et(this,Yo,$n(()=>{t(H(this,Go),()=>e,()=>n)}))},hI=function(e){var t=!1,n=!1;let i=()=>{if(t){gL();return}t=!0,n&&lL(),H(this,Yo)!==null&&nl(H(this,Yo),()=>{et(this,Yo,null)}),xt(this,sr,HE).call(this,()=>{xt(this,sr,gI).call(this)})};return{reset:i,invoke_onerror:()=>{try{n=!0,H(this,Ss).onerror?.(e,i),n=!1}catch(s){ya(s,H(this,Do)&&H(this,Do).parent)}}}},DL=function(){let e=H(this,Ss).pending;e&&(this.is_pending=!0,et(this,io,$n(()=>e(H(this,Go)))),Br(()=>{var t=et(this,Zl,document.createDocumentFragment()),n=en();t.append(n),et(this,Ds,xt(this,sr,HE).call(this,()=>$n(()=>H(this,Sd).call(this,n)))),H(this,au)===0&&(H(this,Go).before(t),et(this,Zl,null),nl(H(this,io),()=>{et(this,io,null)}),xt(this,sr,zE).call(this,qe))}))},gI=function(){try{if(this.is_pending=this.has_pending_snippet(),et(this,au,0),et(this,D
`).some(a=>a.startsWith("https://svelte.dev/e/")))throw s;return s!==Gl&&console.warn("Failed to hydrate: ",s),e.recover===!1&&tL(),eT(),Df(t),Dn(!1),Bd(r,e)}finally{Dn(n),tr(i)}}var aT=new Map;function p2(r,{target:e,anchor:t,props:n={},events:i,context:o,intro:s=!0,transformError:a}){eT();var l=void 0,c=ZL(()=>{var u=t??e.appendChild(en());hv(u,{pending:()=>{}},p=>{we({});var m=_t;if(o&&(m.c=o),i&&(n.$$events=i),Re&&Zo(p,null),WI=s,l=r(p,n)||{},WI=!0,Re&&(Fe.nodes.end=Ze,Ze===null||Ze.nodeType!==jo||Ze.data!=="]"))throw Cd(),Gl;Ce()},a);var d=new Set,f=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!d.has(v)){d.add(v);var g=d2(v);for(let x of[e,document]){var y=aT.get(x);y===void 0&&(y=new Map,aT.set(x,y));var w=y.get(v);w===void 0?(x.addEventListener(v,sT,{passive:g}),y.set(v,1)):y.set(v,w+1)}}}};return f(Ef(UI)),oT.add(f),()=>{for(var p of d)for(let g of[e,document]){var m=aT.get(g),v=m.get(p);--v==0?(g.removeEventListener(p,sT),m.delete(p),m.size===0&&aT.delete(g)):m.set(p,v)}oT.delete(f),u!==t&&u.parentNode?.removeChild(u)}});return zI.set(l,c),l}var zI=new WeakMap;function Gf(r,e){let t=zI.get(r);return t?(zI.delete(r),t(e)):(te&&(Sn in r?hL():fL()),Promise.resolve())}var xa,ul,Jo,Ud,kv,Sv,lT,Ea=class{constructor(e,t=!0){le(this,"anchor");it(this,xa,new Map);it(this,ul,new Map);it(this,Jo,new Map);it(this,Ud,new Set);it(this,kv,!0);it(this,Sv,e=>{if(H(this,xa).has(e)){var t=H(this,xa).get(e),n=H(this,ul).get(t);if(n)Hf(n),H(this,Ud).delete(t);else{var i=H(this,Jo).get(t);i&&(Hf(i.effect),H(this,ul).set(t,i.effect),H(this,Jo).delete(t),te&&(i.fragment.lastChild[aI]=this.anchor),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),n=i.effect)}for(let[o,s]of H(this,xa)){if(H(this,xa).delete(o),o===e)break;let a=H(this,Jo).get(s);a&&(Vr(a.effect),H(this,Jo).delete(s))}for(let[o,s]of H(this,ul)){if(o===t||H(this,Ud).has(o))continue;let a=()=>{if(Array.from(H(this,xa).values()).includes(o)){var c=document.createDocumentFragment();Pf(s,c),c.append(en()),H(this,Jo).set(o,{effect:s,fragment:c})}else Vr(s);H(this,Ud).delete(o),H(this,ul).delete(o)};H(this,kv)||!n?(H(this,Ud).add(o),nl(s,a,!1)):a()}}});it(this,lT,e=>{H(this,xa).delete(e);let t=Array.from(H(this,xa).values());for(let[n,i]of H(this,Jo))t.includes(n)||(Vr(i.effect),H(this,Jo).delete(n))});this.anchor=e,et(this,kv,t)}ensure(e,t){var n=qe,i=tT();if(t&&!H(this,ul).has(e)&&!H(this,Jo).has(e))if(i){var o=document.createDocumentFragment(),s=en();o.append(s),H(this,Jo).set(e,{effect:$n(()=>t(s)),fragment:o})}else H(this,ul).set(e,$n(()=>t(this.anchor)));if(H(this,xa).set(n,e),i){for(let[a,l]of H(this,ul))a===e?n.unskip_effect(l):n.skip_effect(l);for(let[a,l]of H(this,Jo))a===e?n.unskip_effect(l.effect):n.skip_effect(l.effect);n.oncommit(H(this,Sv)),n.ondiscard(H(this,lT))}else Re&&(this.anchor=Ze),H(this,Sv).call(this,n)}};xa=new WeakMap,ul=new WeakMap,Jo=new WeakMap,Ud=new WeakMap,kv=new WeakMap,Sv=new WeakMap,lT=new WeakMap;function Dv(r,e,...t){var n=new Ea(r);oo(()=>{let i=e()??null;te&&i==null&&rL(),n.ensure(i,i&&(o=>i(o,...t)))},65536)}if(te){let r=function(e){if(!(e in globalThis)){let t;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(t!==void 0)return t;iL(e)},set:n=>{t=n}})}};r("$state"),r("$effect"),r("$derived"),r("$inspect"),r("$props"),r("$bindable")}function cT(r){_t===null&&FE("onMount"),Kl&&_t.l!==null?pX(_t).m.push(r):hr(()=>{let e=Ot(r);if(typeof e=="function")return e})}function pX(r){var e=r.l;return e.u??(e.u={a:[],b:[],m:[]})}var h2=new Map;function g2(r,e){var t=h2.get(r);t||(t=new Set,h2.set(r,t)),t.add(e)}function ne(r,e,t=!1){var n;Re&&(n=Ze,Yn());var i=new Ea(r),o=t?65536:0;function s(a,l){if(Re){var c=av(n);if(a!==parseInt(c.substring(1))){var u=el();tr(u),i.anchor=u,Dn(!1),i.ensure(a,l),Dn(!0);return}}i.ensure(a,l)}oo(()=>{var a=!1;e((l,c=0)=>{a=!0,s(c,l)}),a||s(-1,null)},o)}var gX=Symbol("NaN");function jI(r,e,t){Re&&Yn();var n=new Ea(r),i=!ga();oo(()=>{var o=e();o!==o&&(o=gX),i&&o!==null&&typeof o=="object"&&(o={}),n.ensure(o,t)})}function Fv(r,e){return e}function CX(r,e,t){for(var n=[],i=e.length,o,s=e.length,a=
\r\f\xA0\v\uFEFF`];function _2(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||E2.includes(n[s-1]))&&(a===n.length||E2.includes(n[a]))?n=(s===0?"":n.substring(0,s))+n.substring(a+1):s=a}}return n===""?null:n}function T2(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 KI(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function A2(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(/\s*\/\*.*?\*\/\s*/g,"").trim();var o=!1,s=0,a=!1,l=[];n&&l.push(...Object.keys(n).map(KI)),i&&l.push(...Object.keys(i).map(KI));var c=0,u=-1;let v=r.length;for(var d=0;d<v;d++){var f=r[d];if(a?f==="/"&&r[d-1]==="*"&&(a=!1):o?o===f&&(o=!1):f==="/"&&r[d+1]==="*"?a=!0:f==='"'||f==="'"?o=f:f==="("?s++:f===")"&&s--,!a&&o===!1&&s===0){if(f===":"&&u===-1)u=d;else if(f===";"||d===v-1){if(u!==-1){var p=KI(r.substring(c,u).trim());if(!l.includes(p)){f!==";"&&d++;var m=r.substring(c,d).trim();t+=" "+m+";"}}c=d+1,u=-1}}}}return n&&(t+=T2(n)),i&&(t+=T2(i,!0)),t=t.trim(),t===""?null:t}return r==null?null:String(r)}function wt(r,e,t,n,i,o){var s=r[nv];if(Re||s!==t||s===void 0){var a=_2(t,n,o);(!Re||a!==r.getAttribute("class"))&&(a==null?r.removeAttribute("class"):e?r.className=a:r.setAttribute("class",a)),r[nv]=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 XI(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 Yf(r,e,t,n){var i=r[iv];if(Re||i!==e){var o=A2(e,n);(!Re||o!==r.getAttribute("style"))&&(o==null?r.removeAttribute("style"):r.style.cssText=o),r[iv]=e}else n&&(Array.isArray(n)?(XI(r,t?.[0],n[0]),XI(r,t?.[1],n[1],"important")):XI(r,t,n));return n}function fu(r,e,t=!1){if(r.multiple){if(e==null)return;if(!da(e))return mL();for(var n of r.options)n.selected=e.includes(Mv(n));return}for(n of r.options){var i=Mv(n);if($I(i,e)){n.selected=!0;return}}(!t||e!==void 0)&&(r.selectedIndex=-1)}function Vd(r){var e=new MutationObserver(()=>{"__value"in r&&fu(r,r.__value)});e.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Xn(()=>{e.disconnect()})}function QI(r,e,t=e){var n=new WeakSet,i=!0;WE(r,"change",o=>{var s=o?"[selected]":":checked",a;if(r.multiple)a=[].map.call(r.querySelectorAll(s),Mv);else{var l=r.querySelector(s)??r.querySelector("option:not([disabled])");a=l&&Mv(l)}t(a),r.__value=a,qe!==null&&n.add(qe)}),cn(()=>{var o=e();if(r===document.activeElement){var s=Jr?il:qe;if(n.has(s))return}if(fu(r,o,i),i&&o===void 0){var a=r.querySelector(":checked");a!==null&&(o=Mv(a),t(o))}r.__value=o,i=!1}),Vd(r)}function Mv(r){return"__value"in r?r.__value:r.value}var FX=Symbol("is custom element"),MX=Symbol("is html"),RX=PE?"link":"LINK";var $X=PE?"progress":"PROGRESS";function gr(r){if(Re){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[ou]=t,Br(t),qE()}}function Ps(r,e){var t=JI(r);t.value===(t.value=e??void 0)||r.value===e&&(e!==0||r.nodeName!==$X)||(r.value=e??"")}function qd(r,e){var t=JI(r);t.checked!==(t.checked=e??void 0)&&(r.checked=e)}function ke(r,e,t,n){var i=JI(r);if(Re&&(i[e]=r.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&r.nodeName===RX)){n||NX(r,e,t??"");return}i[e]!==(i[e]=t)&&(e==="loading"&&(r[HN]=t),t==null?r.removeAttribute(e):typeof t!="string"&&OX(r).includes(e)?r[e]=t:r.setAttribute(e,t))}function JI(r){var e;return r[e=IE]??(r[e]={[FX]:r.nodeName.includes("-"),[MX]:r.namespaceURI===EE})}var k2=new Map;function OX(r){var e=r.getAttribute("is")||r.nodeName,t=k2.get(e);if(t)return t;k2.set(e,t=[]);for(var n,i=r,o=Element.prototype;o!==i;){n=_E(i);for(var s in n)n[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&t.push(s);i=iu(i)}return t}function NX(r,e,t){te&&(e==="sr
was changed by the error. Include the message below if you report this.</p> <!></div>`),dQ={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 y0(r,e){ot(r,dQ);let t=he(e,"detail",3,"");var n=uQ(),i=I(n),o=I(i);Rt(o,{iconId:"alert-triangle",size:16});var s=A(o,2),a=I(s);S(s),S(i);var l=A(i,4);{var c=u=>{var d=cQ(),f=I(d,!0);S(d),de(()=>me(f,t())),$(u,d)};ne(l,u=>{t()&&u(c)})}S(n),de(()=>me(a,`QuickAdd couldn't display ${e.what??""}`)),$(r,n)}var pQ="this part of QuickAdd";function qi(r,e,t,n={}){let i=new Set(r.childNodes),o;try{o=Bd(e,{target:r,props:t})}catch(a){return fQ(r,i,Yd(a),n)}let s=!1;return{ok:!0,destroy(){s||(s=!0,Gf(o))}}}function fQ(r,e,t,n){let i=n.what??pQ;for(let l of Array.from(r.childNodes))e.has(l)||l.remove();lt(t,`Couldn't display ${i}`);let o=r.ownerDocument.createElement("div");o.className="qa-mount-failed-host",r.appendChild(o);let s=null;try{s=Bd(n.fallbackComponent??y0,{target:o,props:{what:i,detail:t.message}})}catch{o.textContent=`QuickAdd couldn't display ${i}.`}let a=!1;return{ok:!1,destroy(){a||(a=!0,s&&Gf(s),o.remove())}}}var mB=require("obsidian");Tt();function tm(r){return r.trim().replace(/^\/+/,"")}function bu(r){return r.trim().toLowerCase().endsWith(".canvas")}function w0(r,e){let t=tm(e);if(!t||t.includes("{{"))return null;let n=r.vault.getAbstractFileByPath(t);return!n||!(n instanceof mB.TFile)||n.extension!=="canvas"?null:n}function hB(r,e){let n=r.workspace.getMostRecentLeaf?.()?.view;if(!n||n.getViewType?.()!=="canvas")return null;let i=tm(e),o=tm(n.file?.path??r.workspace.getActiveFile()?.path??"");if(!i||i!==o)return null;let s=n.canvas?.selection?Array.from(n.canvas.selection):[];if(s.length!==1)return null;let a=s[0]?.id;return typeof a=="string"&&a.length>0?a:null}function mQ(r){return typeof r=="string"?r:r&&typeof r=="object"&&"path"in r&&typeof r.path=="string"?r.path:"(missing file path)"}function hQ(r){return typeof r.x!="number"||typeof r.y!="number"||typeof r.width!="number"||typeof r.height!="number"?"":`${Math.round(r.x)},${Math.round(r.y)} \xB7 ${Math.round(r.width)}x${Math.round(r.height)}`}function b0(r,e){return r.length<=e?r:r.slice(0,e-1)+"\u2026"}async function gB(r,e){try{let t=await r.vault.cachedRead(e),n=JSON.parse(t);if(!n||typeof n!="object")return[];let i=n.nodes;if(!Array.isArray(i))return[];let o=i.filter(a=>!!a&&typeof a=="object"&&typeof a.id=="string").map(a=>{let l=a.type==="text"?"text":a.type==="file"?"file":"other",c=hQ(a);if(l==="text"){let m=(typeof a.text=="string"?a.text:"").split(`
`).map(w=>w.trim()).filter(w=>w.length>0),v=b0(m[0]??"(empty text card)",90),g=[`${m.length} line${m.length===1?"":"s"}`];c&&g.push(c);let y=g.join(" \xB7 ");return{id:a.id,type:l,title:v,subtitle:y,searchText:`${a.id} ${v} ${y}`.toLowerCase(),capturable:!0,capturableReason:""}}if(l==="file"){let p=mQ(a.file),m=ir.test(p),v=m?"":"Canvas file cards must link to markdown files (.md).",g=b0(p.split("/").pop()??p,90),y=[b0(p,120)];c&&y.push(c),m||y.push("Not capturable in this version");let w=y.join(" \xB7 ");return{id:a.id,type:l,title:g,subtitle:w,searchText:`${a.id} ${g} ${w}`.toLowerCase(),capturable:m,capturableReason:v}}let d=`Unsupported node (${typeof a.type=="string"&&a.type.length>0?a.type:"unknown"})`,f=c||"Type is not currently capturable";return{id:a.id,type:l,title:d,subtitle:f,searchText:`${a.id} ${d} ${f}`.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[]}}qt();function _u(r){return/\{\{[^}]*\}\}/.test(r)}fl();Fo();Wt();Tt();var YZ=["noteContent","captureTarget","fileName","lineTarget"],KZ=["captureTarget","fileName"],wi=YZ,jU=3;function Je(r,e,t=r.endsWith(":}}")?2:0){return{insert:r,description:e,caretOffset:t}}var XZ=[{regex:W2,contexts:wi,suggestion:Je("{{VALUE}}","Asks you for text when the choice runs")},{regex:z2,contexts:wi,suggestion:Je("{{VALUE:}}","Asks once and reuses the answer by name, or lists options to pick from"),expansions:()=>[Je("{{VALUE:title}}",'Asks once, then reuses the answer as "title"'),Je("{{VALUE:option1,option2,option3}}","Asks you to pick one of these options"),Je("{{VALUE:option1,option2,option3|custom}}","Same, but you can also type your own"),Je("{{VALUE:title|label:Note title}}","Words the prompt yourself"),Je("{{VALUE:option1,option2|label:Pick one}}","A list with your own prompt text"),Je("{{VALUE:title|label:Note title|default:Untitled}}","Opens the prompt with an answer already filled in"),Je("{{VALUE:<items>|text:<display items>}}","Shows one label in the list and inserts another"),Je("{{VALUE:option1,option2|name:category}}","Names the pick, so {{VALUE:category}} reuses it"),Je("{{VALUE:title|case:kebab}}","Reshapes the answer; type |case: for every style"),Je("{{VALUE:title|trim}}","Trims whitespace off the answer"),Je("{{VALUE:title|optional}}","Lets the prompt be skipped, leaving it empty")]},{regex:q2,contexts:wi,suggestion:Je("{{NAME}}","Another name for {{VALUE}}; they do the same thing")},{regex:H2,contexts:wi,suggestion:Je("{{VDATE:}}",'Asks you for a date; "tomorrow" works'),expansions:()=>[Je("{{VDATE:date,YYYY-MM-DD}}",'Asks for a date, reused by name as "date"'),Je("{{VDATE:date,YYYY-MM-DD|today}}","Same, with today filled in"),Je("{{VDATE:dueDate,YYYY-MM-DD|next monday}}","Same, starting at next Monday"),Je("{{VDATE:dueDate,YYYY-MM-DD|optional}}","Same, but skippable")]},{regex:Q2,contexts:wi,suggestion:Je("{{FIELD:}}","Suggests values a property already has in your vault, like {{FIELD:project}}")},{regex:X2,contexts:wi,suggestion:Je("{{FILE:}}","Picks a note from a folder"),expansions:({context:r})=>{let e=[Je("{{FILE:<folder>}}","Picks a note from that folder and inserts its name")];return KZ.includes(r)||e.push(Je("{{FILE:<folder>|link}}","Same, but inserts a link to the note"),Je("{{FILE:<folder>|path}}","Same, but inserts its full path"),Je("{{FILE:<folder>|optional}}","Same, but skippable")),e.push(Je("{{FILE:<folder>|custom}}","Same, but you can also type a name that is not there yet")),e}},{regex:eB,contexts:wi,suggestion:Je("{{MVALUE}}","Asks you for a math formula (LaTeX), with a live preview")},{regex:U2,contexts:wi,suggestion:Je("{{DATE}}","Today's date, as YYYY-MM-DD")},{regex:V2,contexts:wi,suggestion:Je("{{DATE:}}","Today's date in a format you choose, like {{DATE:MMMM Do}}"),expansions:({formatDate:r})=>[...["YYYY-MM-DD","MMMM Do, YYYY","ddd D MMM","gggg-[W]ww"].map(e=>Je(`{{DATE:${e}}}`,r(e))),Je("{{DATE+7}}","Seven days from today"),Je("{{DATE:YYYY-MM-DD|startof
/* Let clicks fall through to the container so a single handler owns toggling. */.checkbox-container.svelte-1bigjf0 > input:where(.svelte-1bigjf0) {pointer-events:none;}`};function lr(r,e){we(e,!0),ot(r,iJ);let t=he(e,"checked",15),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0),s=O(()=>t()??!1);function a(){n()||(t(!h(s)),o()?.(t()))}function l(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a())}var c=nJ();let u;var d=I(c);gr(d),S(c),de(()=>{u=wt(c,1,"checkbox-container svelte-1bigjf0",null,u,{"is-enabled":h(s),"is-disabled":n()}),ke(c,"aria-checked",h(s)),ke(c,"aria-label",i()),ke(c,"tabindex",n()?-1:0),qd(d,h(s))}),De("click",c,a),De("keydown",c,l),$(r,c),Ce()}Et(["click","keydown"]);var oJ=z("<option> </option>"),sJ=z('<select class="dropdown"></select>');function Jt(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0);var s=sJ();ar(s,21,()=>e.options,a=>a.value,(a,l)=>{var c=oJ(),u=I(c,!0);S(c);var d={};de(()=>{me(u,h(l).label),d!==(d=h(l).value)&&(c.value=(c.__value=h(l).value)??"")}),$(a,c)}),S(s),de(()=>{s.disabled=n(),ke(s,"aria-label",i())}),De("change",s,()=>o()?.(t())),QI(s,t),$(r,s),Ce()}Et(["change"]);zs();Me();Cr();function Sm(r){return r==="Multi"?"folder":"choice"}function gV(r){return r==="Multi"?"Folder":"Choice"}function oee(r){return`${gV(r)} name`}async function g_(r,e,t){try{let i=(await Sr.Prompt(r,oee(t),void 0,e)).trim();return!i||i===e?null:i}catch(n){return Dt(n)||F.logError(Yd(n,"Could not rename")),null}}var see=z('<h2 class="choiceNameHeader"><button type="button" class="choiceNameHeaderButton qa-rename-title-button"><span class="choiceNameHeaderText"> </span> <span class="choiceNameHeaderIcon" aria-hidden="true"><!></span></button></h2>');function py(r,e){we(e,!0);let t=he(e,"name",15);async function n(){let u=await g_(e.app,t());u&&t(u)}var i=see(),o=I(i),s=I(o),a=I(s,!0);S(s);var l=A(s,2),c=I(l);Rt(c,{iconId:"pencil",size:16}),S(l),S(o),S(i),de(()=>{ke(o,"aria-label",`Rename ${t()}`),me(a,t())}),De("click",o,n),$(r,i),Ce()}Et(["click"]);fl();Fo();var ni=class extends mn{constructor(t,n,i,o=1/0){super(t,n);this.app=t;this.inputEl=n;this.items=i;this.maxSuggestions=o;this.items=i.map(s=>fn(s))}getSuggestions(t){let n=Cc(t).toLowerCase(),i=this.items.filter(s=>s.toLowerCase().includes(n));return i.length===0&&this.close(),i.slice(0,this.maxSuggestions)}selectSuggestion(t){this.inputEl.value=t,this.inputEl.trigger("input"),this.close()}renderSuggestion(t,n){if(!t)return;let i=sy(t),o=sy(this.getCurrentQuery());t.toLowerCase().endsWith(".md")&&o.toLowerCase().startsWith(`${i.toLowerCase()}.`)&&(o=i),this.renderMatch(n,i,o)}getCurrentQuery(){return this.inputEl.value}};function aee(r){return r?Array.isArray(r)?r:[r]:[]}function hp(r,e){let t=aee(e(r));return{destroy(){t.forEach(n=>n.destroy())}}}var lee=z("<textarea></textarea>"),cee=z('<input type="text"/>'),uee=z('<!> <div aria-live="polite"> </div>',1);function Ci(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"placeholder",3,void 0),i=he(e,"inputKind",3,"text"),o=he(e,"required",3,!1),s=he(e,"requiredMessage",3,"This field is required"),a=he(e,"disabled",3,!1),l=he(e,"validator",3,void 0),c=he(e,"trim",3,!0),u=he(e,"suggestions",3,void 0),d=he(e,"maxSuggestions",3,1/0),f=he(e,"makeSuggesters",19,()=>[]),p=he(e,"app",3,void 0),m=he(e,"id",3,void 0),v=he(e,"ariaLabel",3,void 0),g=he(e,"onChange",3,void 0),y=Ae(!1),w=Ae(""),x=Ae("neutral"),C=0,_=!1,E=`qa-hint-${Math.random().toString(36).slice(2)}`,D=Y=>c()?Y.trim():Y;function P(Y,X=!1,ae="neutral"){Z(y,X,!0),Z(w,Y??"",!0),Z(x,X?"neutral":ae,!0)}async function V(Y){if(o()&&D(Y).length===0)return P(s(),!0),!1;if(!l())return P(void 0),!0;let X=++C,ae=await Promise.resolve(l()(Y));return X!==C||_?!0:typeof ae=="boolean"?(P(ae?void 0:"Invalid value",!ae),ae):typeof ae=="string"?(P(ae,!0),!1):(P(ae.message??(ae.valid?void 0:"Invalid value"),!ae.valid,ae.valid?ae.variant??"neutral":"neutral"),ae.valid)}function j(Y){let X=Y.currentTarget.value;t(X),g()?.(X)}hr(()=>{o();let Y=t();V(Y)}),hr((
text is inserted under it. Use the toggles below to control placement within that
section.</div>`),xj=z("<!> <!>",1),ele=z(`<div class="setting-item-description">Inline insertion needs a single-line target. The line break (\\n) can't be
matched on the same line \u2014 remove it, or turn off "Inline insertion".</div>`),Ej=z("<!> <!> <!>",1),tle=z(`<div class="setting-item-description">No sorting: newest-first prepends the new section above existing ones;
oldest-first appends it below.</div>`),rle=z(`<div class="setting-item-description">This heading uses a date token QuickAdd can't auto-read for sorting. Pick
"Date" and enter the format, or sections stay in insertion order.</div>`),nle=z(`<div class="setting-item-description">The "Insert after" heading is created at its sorted position among ALL
same-level headings in the note (it is not scoped to one parent section). It
does NOT re-sort headings you already have; only the new one is placed. Use
"Insert at end of section" above for newest-on-top vs. appended entries within
each section.</div> <!> <!> <!> <!> <!> <!>`,1),ile=z("<!> <!> <!> <!> <!>",1);function FR(r,e){we(e,!0);let t=he(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=uo,!0);let n=[B=>new Hi(e.app,B,e.plugin,"lineTarget")],i=[{value:"auto",label:"Auto (headings only)"},{value:"skip",label:"Always skip"},{value:"none",label:"Never skip"}],o=O(()=>t().inline?[{value:uo,label:"Top"},{value:lc,label:"Bottom"},{value:cc,label:"Cursor"}]:[{value:uo,label:"Top"},{value:lc,label:"Bottom"},{value:cc,label:"Cursor"},{value:_a,label:"Ordered (place new section among siblings)"}]),s=[{value:"insertion",label:"Insertion order (no sorting)"},{value:"lexical",label:"Text (A\u2192Z)"},{value:"numeric",label:"Number"},{value:"date",label:"Date"},{value:"semver",label:"Version (semver)"}],a=[{value:"desc",label:"Newest / highest first"},{value:"asc",label:"Oldest / lowest first"}],l=[{value:"bottom",label:"Sort existing unparseable headings to bottom"},{value:"top",label:"Sort existing unparseable headings to top"}],c=Ae(!!t().orderBy),u=O(()=>t().createIfNotFoundLocation===_a),d=O(()=>t().createIfNotFound&&h(u)),f=O(()=>new fh(e.app,e.plugin)),p=Ae(!1);hr(()=>{let B=t().after??"",ie=h(f);if(!t().inline||B===""){Z(p,!1);return}let W=!1;return ie.format(B).then(Y=>{W||Z(p,/[\n\r]/.test(Y),!0)}).catch(()=>{W||Z(p,!1)}),()=>{W=!0}});let m=O(()=>t().orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"}),v=O(()=>/\{\{V?DATE\b/i.test(t().after??"")),g=O(()=>h(d)&&t().orderBy?.by==="insertion"&&h(v)&&!PR(t().after??""));hr(()=>{if(!h(d))return;let B=PR(t().after??"");if(!t().orderBy){t(t().orderBy={by:B?"date":"insertion",direction:"desc",dateFormat:B,unparseable:"bottom"},!0);return}!h(c)&&(t().orderBy.by==="insertion"||t().orderBy.by==="date")&&(t(t().orderBy.by=B?"date":"insertion",!0),t(t().orderBy.dateFormat=B,!0))});function y(B){t(t().createIfNotFoundLocation=B,!0),B===_a?t(t().inline=!1,!0):(t(t().orderBy=void 0,!0),Z(c,!1))}function w(B){Z(c,!0),t().orderBy&&t(t().orderBy.by=B,!0)}function x(B){t().promptHeading||B&&!t().after.startsWith("#")&&(t(t().considerSubsections=!1,!0),new Tj.Notice("Consider subsections requires the target to be a heading (starts with #)"))}function C(B){B&&(t(t().inline=!1,!0),t(t().replaceExisting=!1,!0))}var _=ile(),E=Pe(_);$e(E,{name:"Choose heading when capturing",desc:"Instead of typing a target line now, show a dropdown of the target note's headings when you run this capture and insert under the one you pick.",control:ie=>{lr(ie,{onchange:C,get checked(){return t().promptHeading},set checked(W){t(t().promptHeading=W,!0)}})},$$slots:{control:!0}});var D=A(E,2);{var P=B=>{var ie=Jae();$(B,ie)},V=B=>{var ie=Ej(),W=Pe(ie);ss(W,{name:"Insert after",desc:"Insert capture after specified text. Accepts format syntax. Tip: use a heading (starts with #) to target a section. Blank line handling is configurable below.",children:(ge,be=Vt)=>{var xe=xj(),Ue=Pe(xe);Ci(Ue,{get id(){return be()},placeholder:"Insert after",required:!0,requiredMessage:"Insert after text is required",get makeSuggesters(){return n},get value(){return t().after},set value(Ne){t(t().after=Ne,!0)}});var $t=A(Ue,2);hs($t,{get value(){return t().after},formatterKind:"lineTarget",get app(){return e.app},get plugin(){return e.plugin}}),$(ge,xe)},$$slots:{default:!0}});var Y=A(W,2);{let pe=be=>{lr(be,{get disabled(){return h(u)},get checked(){return t().inline},set checked(xe){t(t().inline=xe,!0)}})},ge=O(()=>h(u)?"Inline insertion can't be combined with ordered placement.":"Insert captured content on the same line, immediately after the matched text (no newline added).");$e(Y,{name:"Inline insertion",get desc(){return h(g
for Canvas card capture. Use top, bottom, insert-after, or insert-before
placement.</div>`),sle=z("<!> <!> <!> <!>",1);function $R(r,e){we(e,!0);let t=he(e,"choice",15),n=O(()=>!!t().captureToActiveFile),i=O(()=>t().insertAfter?.enabled?"after":t().insertBefore?.enabled?"before":t().newLineCapture?.enabled?t().newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":h(n)?t().activeFileWritePosition==="top"?"activeTop":t().activeFileWritePosition==="bottom"||t().prepend?"bottom":"top":t().prepend?"bottom":"top"),o=O(()=>[{value:"top",label:h(n)?"At cursor":"Top of file"},...h(n)?[{value:"activeTop",label:"Top of file (after frontmatter)"},{value:"newLineAbove",label:"New line above cursor"},{value:"newLineBelow",label:"New line below cursor"}]:[],{value:"after",label:"After line\u2026"},{value:"before",label:"Before line\u2026"},{value:"bottom",label:"Bottom of file"}]);function s(g){if(t(t().prepend=!1,!0),t(t().insertAfter.enabled=!1,!0),t(t().insertAfter.promptHeading=!1,!0),t(t().insertAfter.inline=!1,!0),t(t().insertAfter.replaceExisting=!1,!0),t().insertBefore||t(t().insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"},!0),t(t().insertBefore.enabled=!1,!0),t().newLineCapture||t(t().newLineCapture={enabled:!1,direction:"below"},!0),t(t().newLineCapture.enabled=!1,!0),t(t().activeFileWritePosition="cursor",!0),g==="top"){h(n)||t(t().prepend=!1,!0);return}if(g==="activeTop"){h(n)&&t(t().activeFileWritePosition="top",!0);return}if(g==="bottom"){h(n)?t(t().activeFileWritePosition="bottom",!0):t(t().prepend=!0,!0);return}if(g==="newLineAbove"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="above",!0);return}if(g==="newLineBelow"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="below",!0);return}if(g==="before"){t(t().insertBefore.enabled=!0,!0);return}t(t().insertAfter.enabled=!0,!0)}let a=O(()=>{let g=typeof t().captureTo=="string"&&bu(t().captureTo),y=e.app.workspace.getActiveViewOfType(_j.FileView)?.getViewType()==="canvas",w=h(n)&&!t().insertAfter.enabled&&!t().insertBefore?.enabled&&!t().newLineCapture?.enabled&&(t().activeFileWritePosition??"cursor")==="cursor"&&!t().prepend;return!(!(t().newLineCapture?.enabled||w)||(h(n)?!y:!g))});var l=sle(),c=Pe(l);{let g=w=>{Jt(w,{get value(){return h(i)},get options(){return h(o)},onchange:s})},y=O(()=>h(n)?"Where to place the capture in the current file.":"Where to place the capture in the target file.");$e(c,{name:"Write position",get desc(){return h(y)},control:g,$$slots:{control:!0}})}var u=A(c,2);{var d=g=>{FR(g,{get app(){return e.app},get plugin(){return e.plugin},get insertAfter(){return t().insertAfter},set insertAfter(y){t(t().insertAfter=y,!0)}})};ne(u,g=>{t().insertAfter.enabled&&g(d)})}var f=A(u,2);{var p=g=>{RR(g,{get app(){return e.app},get plugin(){return e.plugin},get insertBefore(){return t().insertBefore},set insertBefore(y){t(t().insertBefore=y,!0)}})};ne(f,g=>{t().insertBefore?.enabled&&g(p)})}var m=A(f,2);{var v=g=>{var y=ole();$(g,y)};ne(m,g=>{h(a)&&g(v)})}$(r,l),Ce()}var ale=new Set(["activity","airplay","alarm-check","alarm-clock-off","alarm-clock","alarm-minus","alarm-plus","album","alert-circle","alert-octagon","alert-triangle","align-center-horizontal","align-center-vertical","align-center","align-end-horizontal","align-end-vertical","align-horizontal-distribute-center","align-horizontal-distribute-end","align-horizontal-distribute-start","align-horizontal-justify-center","align-horizontal-justify-end","align-horizontal-justify-start","align-horizontal-space-around","align-horizontal-space-between","align-justify","align-left","align-right","align-start-horizontal","align-start-vertical","align-vertical-distribute-center","align-vertical-distribute-end","align-vertical-distribute-start","align-vertical-justify-center","align-vertical-justify-end","align-vertical-justify-start","align-vertical-space-around","align-vertical-space-between","anchor","aperture","archive","arrow-big-down","arrow-big-left","arrow-big-right","arrow-big-up","arrow-down-circle","arrow-down-left","arrow-down-right","arrow-down","arrow-left-circle","arrow-left-righ
@media (min-width: 768px) {.quickAddFolderListGrid.svelte-ee11ws {display:grid;grid-template-columns:repeat(2, 1fr);column-gap:20px;}
}.quickAddCommandList.svelte-ee11ws {max-width:50%;margin:12px auto;}`};function LR(r,e){we(e,!0),ot(r,wle);var t=ble();ar(t,20,()=>e.folders,n=>n,(n,i)=>{var o=yle(),s=I(o),a=I(s,!0);S(s);var l=A(s,2);{let c=O(()=>`Remove folder ${i}`);er(l,{iconId:"trash-2",get label(){return h(c)},onclick:()=>e.deleteFolder(i)})}S(o),de(()=>me(a,i)),$(n,o)}),S(t),$(r,t),Ce()}function Bj(r){return r.enabled?r.chooseWhenCreatingNote?"prompt":r.createInSameFolderAsActiveFile?"active-file":"specified":"obsidian-default"}function Uj(r,e){switch(e){case"obsidian-default":return{...r,enabled:!1,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"specified":return{...r,enabled:!0,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"active-file":return{...r,enabled:!0,createInSameFolderAsActiveFile:!0,chooseWhenCreatingNote:!1};case"prompt":return{...r,enabled:!0,chooseWhenCreatingNote:!0,createInSameFolderAsActiveFile:!1}}}var Vj=[{value:"obsidian-default",label:"Obsidian default"},{value:"specified",label:"In a specific folder"},{value:"active-file",label:"Same folder as current file"},{value:"prompt",label:"Ask for folder each time"}],qj={"obsidian-default":"Use Obsidian's \u201CDefault location for new notes\u201D setting.",specified:"Create the note in the folder(s) below. With multiple folders, you'll be asked which one when the note is created.","active-file":"Create the note next to the currently active file (falls back to the vault root if no file is open).",prompt:"Choose any folder in the vault when the note is created."};Tt();Tt();function NA(r,e){if(!r.fileNameFormat?.enabled)return!0;let t=e.trim().toLowerCase();return t===Ms.toLowerCase()||t===N2.toLowerCase()}function BR(r,e){return r.discoverExistingNotesBeforeCreate===!0&&NA(r,e)}function UR(r,e,t){return!(!BR(r,e)||t!=null)}Tt();function LA(r){if(!r?.enabled||r.chooseWhenCreatingNote||r.chooseFromSubfolders||r.createInSameFolderAsActiveFile)return;let e=r.folders??[];if(e.length!==1)return;let t=e[0]?.trim();if(t&&!t.includes("{{")&&!dc.test(t))return t}var Cle=z("<!> <!> <!>",1),xle=z(`<div class="qa-folder-mode-warning">Add at least one folder. With none, the note falls back to the active
file's folder (or you'll be prompted to pick one if no file is open).</div>`),Ele=z('<div class="folderSelectionContainer"><div class="folderList"><!></div> <div class="folderInputContainer"><input type="text" class="qa-folder-path-input" placeholder="Folder path" aria-label="Folder path"/> <button type="button" class="mod-cta">Add</button></div></div> <!> <!>',1),Tle=z("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1);function VR(r,e){we(e,!0);let t=he(e,"choice",15),n=O(()=>e.plugin.getTemplateFiles().map(ye=>ye.path)),i=O(()=>Nc(Ns(e.app)));function o(ye){let We=ye.trim();return We?_u(We)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:po(e.app,We)!==null||"Template not found":!0}let s=[ye=>new Hi(e.app,ye,e.plugin,"fileName")],a=O(()=>NA(t(),t().fileNameFormat.enabled?t().fileNameFormat.format:Ms)),l=O(()=>h(a)?"For the default note-title prompt, show matching notes first. Choosing one opens it unchanged; choosing the create row continues with this template.":"Only available when the file name prompt is the default note title: no custom format, {{VALUE}}, or {{NAME}}."),c=O(()=>Bj(t().folder)),u=O(()=>qj[h(c)]),d=O(()=>h(c)==="specified"&&t().folder.folders.length===0);function f(ye){t(t().folder=Uj(t().folder,ye),!0)}let p=Ae(""),m;function v(ye){return m=new $A(e.app,ye,h(i),t().folder.folders),m}hr(()=>{m?.updateCurrentItems(t().folder.folders)});function g(){let ye=h(p).trim();if(ye){if(t().folder.folders.some(We=>We===ye)){F.logWarning("cannot add same folder twice.");return}t().folder.folders.push(ye),Z(p,"")}}function y(ye){t(t().folder.folders=t().folder.folders.filter(We=>We!==ye),!0)}function w(ye){ye.key==="Enter"&&g()}let x=O(()=>Rj(t().fileExistsBehavior)),C=O(()=>h(x)!=="prompt"&&h(x)!=="keep"),_=O(()=>Pj(h(x)==="update"?"update":"create")),E=O(()=>t().fileExistsBehavior.kind==="apply"?t().fileExistsBehavior.mode:h(_)[0].id);function D(ye){t(t().fileExistsBehavior=$j(ye,t().fileExistsBehavior),!0)}function P(ye){t(t().fileExistsBehavior={kind:"apply",mode:ye},!0)}var V=Tle(),j=Pe(V);py(j,{get app(){return e.app},get name(){return t().name},set name(ye){t(t().name=ye,!0)}});var oe=A(j,2);$e(oe,{name:"Template",heading:!0});var se=A(oe,2);ss(se,{name:"Template path",desc:"Path to the template this choice creates notes from.",children:(We,mt=Vt)=>{Ci(We,{get id(){return mt()},get value(){return t().templatePath},placeholder:"Template path",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,validator:o,onChange:He=>t(t().templatePath=He.trim(),!0)})},$$slots:{default:!0}});var M=A(se,2);ss(M,{name:"File name format",desc:"Set the file name format. When off, QuickAdd asks for the note title.",get bodyVisible(){return t().fileNameFormat.enabled},control:mt=>{lr(mt,{get checked(){return t().fileNameFormat.enabled},set checked(He){t(t().fileNameFormat.enabled=He,!0)}})},children:(mt,He=Vt)=>{var _e=Cle(),Be=Pe(_e);Ci(Be,{get id(){return He()},placeholder:"File name format",get makeSuggesters(){return s},get value(){return t().fileNameFormat.format},set value(yr){t(t().fileNameFormat.format=yr,!0)}});var ut=A(Be,2);qp(ut,{get value(){return t().fileNameFormat.format}});var or=A(ut,2);{let yr=O(()=>LA(t().folder));hs(or,{get value(){return t().fileNameFormat.format},formatterKind:"fileName",get targetFolderPath(){return h(yr)},get app(){return e.app},get plugin(){return e.plugin}})}$(mt,_e)},$$slots:{control:!0,default:!0}});var U=A(M,2);$e(U,{name:"Location",heading:!0});var q=A(U,2);$e(q,{name:"New note location",get desc(){return h(u)},control:We=>{Jt(We,{get value(){return h(c)},get options(){return Vj},ariaLabel:"New note location",onchange:f})},$$slots:{control:!0}});var B=A(q,2);{var ie=ye=>{var We=Ele(),mt=Pe(We),He=I(mt),_e=I(He);LR(_e,{get folders(){return t().folder.folders},deleteFolder:y}),S(He);var Be=A(He,2),ut=I(Be);gr(ut),cn(()=>co(ut,()=>h(p),ur=>Z(p,ur))),Fr(ut,(ur,dt)=>hp?.(ur,dt),()=>v);var or=A(ut,2);S(Be),S(mt);var yr=A(mt,2);{var Pt=ur=>{var dt=xle();$(ur,dt)};ne(yr,ur=>{h(d)&&ur(Pt)})}var Ar=A(yr,2);$e(Ar,{name:
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rle(){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 Gp(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=e$(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var n=0,i=function(){};return{s:i,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`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 $le="finalize",Ole="consider";function kh(r,e,t){r.dispatchEvent(new CustomEvent($le,{detail:{items:e,info:t}}))}function Ju(r,e,t){r.dispatchEvent(new CustomEvent(Ole,{detail:{items:e,info:t}}))}var XA="draggedEntered",sx="draggedLeft",QA="draggedOverIndex",t$="draggedLeftDocument",WA={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function Nle(r,e,t){r.dispatchEvent(new CustomEvent(XA,{detail:{indexObj:e,draggedEl:t}}))}function Lle(r,e,t){r.dispatchEvent(new CustomEvent(sx,{detail:{draggedEl:e,type:WA.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function Ble(r,e){r.dispatchEvent(new CustomEvent(sx,{detail:{draggedEl:e,type:WA.OUTSIDE_OF_ANY}}))}function Ule(r,e,t){r.dispatchEvent(new CustomEvent(QA,{detail:{indexObj:e,draggedEl:t}}))}function Vle(r){window.dispatchEvent(new CustomEvent(t$,{detail:{draggedEl:r}}))}var Ai={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:XA,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:QA,DRAGGED_LEFT:sx,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},Qi={POINTER:"pointer",KEYBOARD:"keyboard"},ZA="isDndShadowItem",JA="data-is-dnd-shadow-item-internal",qle="data-is-dnd-shadow-item-hint",ek="id:dnd-shadow-placeholder-0000",Wle="dnd-action-dragged-el",qn="id",HR=0;function rG(){HR++}function nG(){if(HR===0)throw new Error("Bug! trying to decrement when there are no dropzones");HR--}var r$=typeof window>"u",Ct=function(){};function jR(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t,n=e?jle(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.x-l-(1-s)*parseFloat(u),f=n.y-c-(1-a)*parseFloat(u.slice(u.indexOf(" ")+1)),p=s?n.width/s:r.offsetWidth,m=a?n.height/a:r.offsetHeight;return{x:d,y:f,width:p,height:m,top:f,right:d+p,bottom:f+m,left:d}}else return n}function GR(r){var e=jR(r);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function iG(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 oG(r){return{x:(r.left+r.right)/2,y:(r.top+r.bottom)/2}}function zle(r,e){return Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2))}function rx(r,e){return r.y<=e.bottom&&r.y>=e.top&&r.x>=e.left&&r.x<=e.right}function sG(r){return oG(iG(r))}function jj(r,e){var t=sG(e);return zle(r,t)}function Hle(r){var e=iG(r);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}function jle(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 f=Math.max(t.top,d.top),p=Math.min(t.bottom,d.bottom);(f!==t.top||p!==t.bottom)&&(n=!0),t.top=f,t.bottom=p}if(u){var m=Math.max(t.left,d.left),v=Math.min(t.right,d.right);(m!==t.left||v!==t.right)&&(i=!0),t.left=m,t.right=v}}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:Math.max(0,t.bottom-t.top)}:{top:e.top,bottom:e.bottom,left:e.left,right:e.right,width:Math.max(0,e.right-e.left),height:Math.max(0,e.bottom-e.top)}}var _h;function n$(){Ct(function(){return"resetting indexes cache"}),_h=new Map}n$();functio
or edited here. Nothing has been changed or deleted, and QuickAdd will not
overwrite it.</p> <p class="qaDataUnreadableBody svelte-ktqmtm">It's stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this
vault. Make a copy of that file before editing it.</p></div>`),Eue={hash:"svelte-ktqmtm",code:".qaDataUnreadable.svelte-ktqmtm {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaDataUnreadableHead.svelte-ktqmtm {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaDataUnreadableTitle.svelte-ktqmtm {font-weight:var(--font-semibold);color:var(--text-normal);}.qaDataUnreadableBody.svelte-ktqmtm {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}"};function O$(r,e){ot(r,Eue);var t=xue(),n=I(t),i=I(n);Rt(i,{iconId:"alert-triangle",size:16});var o=A(i,2),s=I(o);S(o),S(n),In(4),S(t),de(()=>me(s,`QuickAdd couldn't read ${e.what??""}`)),$(r,t)}var Qh=class{constructor(e){this.obsidianCommands=[];this.scriptCandidates=[];this.commandListHandle=null;this.commandListProps=null;this.containerEl=null;this.unreadableCardHandle=null;this.app=e.app,this.plugin=e.plugin,this.unreadable=Di(e.commands),this.commandsRef=d$(e.commands).commands,this.choices=e.choices,this.onCommandsChange=e.onCommandsChange,this.conditionalHandlers=e.conditionalHandlers,this.loadObsidianCommands(),this.loadScriptCandidates()}render(e){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=qi(t,O$,{what:"this macro's commands"},{what:"this macro's commands"})}destroy(){this.commandListHandle?.destroy(),this.commandListHandle=null,this.commandListProps=null,this.unreadableCardHandle?.destroy(),this.unreadableCardHandle=null}loadObsidianCommands(){Object.keys(this.app.commands.commands).forEach(e=>{let t=this.app.commands.commands[e];this.obsidianCommands.push(new fx(t.name,t.id))})}loadScriptCandidates(){this.scriptCandidates=Ak(this.app)}renderCommandList(e){let t=e.createDiv("commandList");return this.commandListProps=HG({app:this.app,plugin:this.plugin,commands:this.commandsRef,deleteCommand:async n=>{let i=this.commandsRef.find(a=>a.id===n);if(!i)throw F.logError("command not found"),new Error("command not found");if(!await Xi.Prompt(this.app,"Are you sure you wish to delete this command?",`If you click yes, you will delete '${i.name}'.`))return;if(!await dx(this.app,i)){new Fi.Notice("Could not clear user script secrets. Command was not deleted.");return}this.commandsRef=this.commandsRef.filter(a=>a.id!==n),this.emitCommandsChanged()},saveCommands:n=>{this.commandsRef=n,this.onCommandsChange?.(n)},onConfigureCondition:this.conditionalHandlers?.configureCondition,onEditThenBranch:this.conditionalHandlers?.editThenBranch,onEditElseBranch:this.conditionalHandlers?.editElseBranch}),this.commandListHandle=qi(t,T$,this.commandListProps,{what:"this macro's commands"}),this.commandListHandle.ok}renderCommandBar(e){let t=e.createDiv("quickCommandContainer");this.addChoiceButton(t,"Capture",Bh),this.addChoiceButton(t,"Template",rd),this.addOpenFileCommandButton(t),this.addWaitCommandButton(t),this.addConditionalCommandButton(t),ce.getState().disableOnlineFeatures||this.addAIAssistantCommandButton(t)}renderAddObsidianCommandSetting(e){let t,n=()=>{let i=t.getValue(),o=this.obsidianCommands.find(a=>a.name===i);if(!o){F.logError(`Could not find Obsidian command with name "${i}"`);return}let s=new fx(o.name,o.commandId);s.generateId(),this.addCommand(s),t.setValue("")};new Fi.Setting(e).setName("Obsidian command").setDesc("Add an Obsidian command").addText(i=>{t=i,i.inputEl.addClass("qa-command-sequence-input"),i.setPlaceholder("Obsidian command"),new ni(this.app,i.inputEl,this.obsidianCommands.map(o=>o.name)),i.inputEl.addEventListener("keypress",o=>{o.key==="Enter"&&n()})}).addButton(i=>i.setCta().setButtonText("Add").o
/* The chevron sits tighter to the label than the leading plus. */.qaNewChoiceBtn.svelte-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 rg(r,e){we(e,!0),ot(r,sde);let t=he(e,"targetFolderId",3,void 0),n=he(e,"targetFolderName",3,void 0),i=he(e,"compact",3,!1),o=he(e,"fill",3,!1),s=Ae(!1);function a(j){let oe=new _Y.Menu;for(let M of EY)oe.addItem(U=>U.setTitle(`${M.label} \u2014 ${M.description}`).setIcon(M.iconId).onClick(q=>{let B=q.altKey===!0;e.onAddChoice(Zk(M.type),M.type,t(),B)}));Z(s,!0),oe.onHide(()=>{Z(s,!1)});let se=j.target?.closest("button");if(se){let M=se.getBoundingClientRect();oe.showAtPosition({x:M.left,y:M.bottom+4})}else oe.showAtMouseEvent(j)}function l(){e.onAddChoice(Zk("Multi"),"Multi",t(),!0)}let c=O(()=>i()?"Add choice":"New choice"),u=O(()=>i()?"Add folder":"New folder"),d=O(()=>n()?`Add choice to ${n()}`:h(c)),f=O(()=>n()?`Add folder to ${n()}`:h(u));var p=ode();let m;var v=I(p),g=I(v);Rt(g,{iconId:"folder-plus",size:14});var y=A(g,2),w=I(y,!0);S(y),S(v);var x=A(v,2);let C;var _=I(x);Rt(_,{iconId:"plus",size:14});var E=A(_,2),D=I(E,!0);S(E);var P=A(E,2);{var V=j=>{Rt(j,{iconId:"chevron-down",size:12})};ne(P,j=>{i()||j(V)})}S(x),S(p),de(()=>{m=wt(p,1,"qaAddChoiceControls svelte-a7rp4h",null,m,{compact:i(),fill:o()&&!i()}),ke(v,"aria-label",h(f)),ke(v,"title",i()?h(f):void 0),me(w,h(u)),C=wt(x,1,"qaNewChoiceBtn svelte-a7rp4h",null,C,{"mod-cta":!i()}),ke(x,"aria-expanded",h(s)),ke(x,"aria-label",h(d)),ke(x,"title",i()?h(d):void 0),me(D,h(c))}),De("click",v,l),De("click",x,a),$(r,p),Ce()}Et(["click"]);var ade=z('<div class="rightButtonsContainer svelte-1es4f02"><!> <!> <!> <!> <!> <!></div>'),lde={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 xx(r,e){we(e,!0),ot(r,lde);let t=he(e,"showConfigureButton",3,!0),n=he(e,"showDuplicateButton",3,!0),i=he(e,"commandEnabled",3,!1),o=he(e,"choiceName",3,"");var s=ade(),a=I(s);{var l=g=>{{let y=O(()=>`Configure${o()?" "+o():""}`);er(g,{iconId:"settings",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onConfigureChoice}})}};ne(a,g=>{t()&&g(l)})}var c=A(a,2);{var u=g=>{{let y=O(()=>`Duplicate${o()?" "+o():""}`);er(g,{iconId:"copy",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDuplicateChoice}})}};ne(c,g=>{n()&&g(u)})}var d=A(c,2);{let g=O(()=>`Delete${o()?" "+o():""}`);er(d,{iconId:"trash-2",get label(){return h(g)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDeleteChoice}})}var f=A(d,2);{var p=g=>{{let y=O(()=>`More options${o()?" for "+o():""}`);er(g,{iconId:"more-vertical",ariaHasPopup:"menu",get label(){return h(y)},onclick:w=>e.onOpenMenu?.(w.currentTarget)})}};ne(f,g=>{e.onOpenMenu&&g(p)})}var m=A(f,2);{let g=O(()=>`Command palette${o()?": "+o():""}`);er(m,{iconId:"zap",get ariaPressed(){return i()},get label(){return h(g)},extraClass:"qa-row-secondary-action",get onclick(){return e.onToggleCommand}})}var v=A(m,2);{let g=O(()=>`Reorder${o()?" "+o():""}`);ki(v,{get label(){return h(g)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.onDragHandleDown},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(s),$(r,s),Ce()}var eS=require("obsidian");var AY=require("obsidian");function Jk(r,e,t,n){e.replaceChildren(),AY.MarkdownRenderer.render(n,r,e,"/",t)}Wt();var cde=z('<div class="choiceListItem"><span class="qaChoiceRowIcon" aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></div>'),ude={hash:"svelte-1aljzaf",code:""};function Y$(r,e){we(e,!0),ot(r,ude);let t=!0,n=Ae(void 0),i=new eS.Component;hr(()=>{h(n)&&Jk(e.choice.name,h(n),i,e.app)}),hr(()=>()=>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:p=>e.actions.onMoveChoice(e.choice,p)});function s(p){Vk(e.app,p,e.choice,e.roots,o())}function a(p){qk(e.app,p,e.choice,e.roots,o())}var l=cde(),c=I(l),u=I(c);{let p=O(()=>wm(e.choice));Rt(u,{get iconId(){return h(p)},size:15})}S(c);var d=A(c,2);sc(d,p=>Z(n,p),()=>h(n));var f=A(d,2);xx(f,{get onDragHandleDown(){return e.startDrag},onDeleteChoice:()=>e.actions.onDeleteChoice(e.choice),onConfigureChoice:()=>e.actions.onConfigureChoice(e.choice),onToggleCommand:()=>e.actions.onToggleCommand(e.choice),onDuplicateChoice:()=>e.actions.onDuplicateChoice(e.choice),onOpenMenu:a,get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown},get choiceName(){return e.choice.name},get commandEnabled(){return e.choice.command},showConfigureButton:t,get dragDisabled(){return e.dragDisabled},showDuplicateButton:!0}),S(l),de(()=>ke(l,"data-choice-id",e.choice.id)),De("contextmenu",l,s),De("dblclick",l,p=>{eS.Platform.isMobile||p.target.closest("button, a")||e.actions.onConfigureChoice(e.choice)}),$(r,l),Ce()}Et(["contextmenu","dblclick"]);var tS=require("obsidian");Wt();var dde=z('<span class="qaFolderCount svelte-1jxjn06" aria-hidden="true"> </span>'),pde=z(`<p class="qaUnreadableFolder svelte-1jxjn06">QuickAdd couldn't read this folder's contents. They're still
in <code class="svelte-1jxjn06">data.json</code>.</p>`),fde=z('<div class="nestedAddRow svelte-1jxjn06"><!></div>'),mde=z("<!> <!>",1),hde=z('<div class="nestedChoiceList svelte-1jxjn06"><!></div>'),gde=z('<div><div class="multiChoiceListItem"><button type="button" class="multiChoiceListItemName svelte-1jxjn06"><span aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></button> <!></div> <!></div>'),vde={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 K$(r,e){we(e,!0),ot(r,vde);let t=he(e,"choice",7),n=he(e,"forceDragDisabled",3,!1),i=O(()=>st(t())),o=O(()=>Ws(t())),s=!0,a=Ae(void 0),l=new tS.Component;hr(()=>{h(a)&&Jk(t().name,h(a),l,e.app)}),hr(()=>()=>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:j=>e.actions.onMoveChoice(t(),j)});function u(j){Vk(e.app,j,t(),e.roots,c())}function d(j){qk(e.app,j,t(),e.roots,c())}let f={...Ot(()=>e.actions),onReorderChoices:j=>{t().choices=j,e.actions.onCommitFolder(t().id,j)}};function p(){n()||e.actions.onToggleCollapsed(t())}var m=gde(),v=I(m),g=I(v),y=I(g);let w;var x=I(y);Rt(x,{iconId:"chevron-down",size:16}),S(y);var C=A(y,2);sc(C,j=>Z(a,j),()=>h(a));var _=A(C,2);{var E=j=>{var oe=dde(),se=I(oe,!0);S(oe),de(()=>me(se,h(i).length)),$(j,oe)};ne(_,j=>{t().collapsed&&h(i).length>0&&j(E)})}S(g),Fr(g,j=>OA?.(j));var D=A(g,2);xx(D,{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}),S(v);var P=A(v,2);{var V=j=>{var oe=un(),se=Pe(oe);{var M=U=>{var q=hde(),B=I(q);{var ie=Y=>{var X=pde();$(Y,X)},W=Y=>{var X=mde(),ae=Pe(X);{let be=O(()=>h(i).length===0),xe=O(()=>e.rootReorder??e.actions.onReorderChoices);ng(ae,{get app(){return e.app},get roots(){return e.roots},get choices(){return h(i)},nested:!0,get isEmptyFolder(){return h(be)},get forceDragDisabled(){return n()},get rootReorder(){return h(xe)},get actions(){return f}})}var pe=A(ae,2);{var ge=be=>{var xe=fde(),Ue=I(xe);rg(Ue,{compact:!0,get targetFolderId(){return t().id},get targetFolderName(){return t().name},get onAddChoice(){return e.actions.onAddChoice}}),S(xe),$(be,xe)};ne(pe,be=>{n()||be(ge)})}$(Y,X)};ne(B,Y=>{h(o)?Y(ie):Y(W,-1)})}S(q),$(U,q)};ne(se,U=>{t().collapsed||U(M)})}$(j,oe)};ne(P,j=>{(!e.collapseId||e.collapseId&&t().id!==e.collapseId)&&j(V)})}S(m),de(()=>{ke(v,"data-choice-id",t().id),ke(g,"aria-expanded",!t().collapsed),ke(g,"aria-label",`Toggle ${t().name}`),w=wt(y,1,"qaChoiceRowIcon multiChoiceCollapseIcon svelte-1jxjn06",null,w,{"is-collapsed":t().collapsed})}),De("contextmenu",v,u),De("click",v,j=>{tS.Platform.isMobile||j.target.closest("button, a")||p()}),De("click",g,p),$(r,m),Ce()}Et(["contextmenu","click"]);function kY(r){let e=r-1;return e*e*e+1}function SY(r,{from:e,to:t},n={}){var{delay:i=0,duration:o=E=>Math.sqrt(E)*120,easing:s=kY}=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=yde(r),f=r.clientWidth/t.width/d,p=r.clientHeight/t.height/d,m=e.left+e.width*c,v=e.top+e.height*u,g=t.left+t.width*c,y=t.top+t.height*u,w=(m-g)*f,x=(v-y)*p,C=e.width/t.width,_=e.height/t.height;return{delay:i,duration:typeof o=="function"?o(Math.sqrt(w*w+x*x)):o,easing:s,css:(E,D)=>{var P=D*w,V=D*x,j=E+D*C,oe=E+D*_;return`transform: ${l} translate(${P}px, ${V}px) scale(${j}, ${oe});`}}}function yde(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 DY=require("obsidian");Wt();var bde=z("<div><!></div>"),wde=z("<div></div>"),Cde={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 ng(r,e){we(e,!0),ot(r,Cde);let t=he(e,"choices",31,()=>bt([])),n=he(e,"forceDragDisabled",3,!1),i=he(e,"isEmptyFolder",3,!1),o=he(e,"nested",3,!1),s=O(()=>{let x=new Set;return hn(t()).filter(C=>{if(!Ye(C))return!1;let _=C.id;return typeof _!="string"||_===""||x.has(_)?!1:(x.add(_),!0)})}),a=O(()=>e.rootReorder??e.actions.onReorderChoices),l=0,c=DY.Platform.isMobile,u=Ae(""),d=ok(),f=O(()=>n()||!c&&!d.armed);function p(x){n()||(d.markStarted(),Z(u,x.detail.info.id,!0),t(Ml(x.detail.items)))}function m(x){if(n())return;Z(u,"");let C=Ml(x.detail.items);x.detail.info.trigger===Ai.DROPPED_INTO_ANOTHER&&(C=C.filter(_=>_.id!==x.detail.info.id)),t(C),d.reset(),e.actions.onReorderChoices(t())}let v=()=>{n()||d.startDrag()};function g(x,C){if(n())return;let _=Ml(h(s)),E=_.findIndex(j=>j.id===x.id);if(E===-1)return;let D=E+C;if(D<0||D>=_.length)return;let P=[..._],[V]=P.splice(E,1);P.splice(D,0,V),t(P),e.actions.onReorderChoices(t()),Fl(`Moved ${x.name} to position ${D+1} of ${_.length}`)}var y=wde();let w;ar(y,29,()=>Ml(h(s)),x=>x.id,(x,C)=>{var _=bde(),E=I(_);{var D=V=>{{let j=O(()=>e.roots??t()),oe=O(()=>n()?void 0:()=>g(h(C),-1)),se=O(()=>n()?void 0:()=>g(h(C),1));Y$(V,{get app(){return e.app},get roots(){return h(j)},get dragDisabled(){return h(f)},startDrag:v,get actions(){return e.actions},get choice(){return h(C)},get onMoveUp(){return h(oe)},get onMoveDown(){return h(se)}})}},P=V=>{{let j=O(()=>e.roots??t()),oe=O(()=>n()?void 0:()=>g(h(C),-1)),se=O(()=>n()?void 0:()=>g(h(C),1));K$(V,{get app(){return e.app},get roots(){return h(j)},get dragDisabled(){return h(f)},startDrag:v,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(oe)},get onMoveDown(){return h(se)}})}};ne(E,V=>{h(C).type!=="Multi"?V(D):V(P,-1)})}S(_),YI(_,()=>SY,()=>({duration:l})),$(x,_)}),S(y),Fr(y,(x,C)=>nk?.(x,C),()=>ik({items:h(s),dragDisabled:h(f),flipDurationMs:l,dropTargetClasses:o()?["qa-folder-droptarget"]:[]})),de(()=>w=wt(y,1,"choiceList svelte-2ry05y",null,w,{"qa-nested":o(),"qa-folder-empty":i(),"qa-empty":h(s).length===0})),oc("consider",y,p),oc("finalize",y,m),$(r,y),Ce()}var xde=z('<pre class="qaChoicesUnavailableDetail svelte-1fs8ikt"> </pre>'),Ede=z(`<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>`),Tde={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 ig(r,e){ot(r,Tde);let t=he(e,"what",3,"your choices"),n=he(e,"detail",3,"");var i=Ede(),o=I(i),s=I(o);Rt(s,{iconId:"alert-triangle",size:16});var a=A(s,2),l=I(a);S(a),S(o);var c=A(o,6);{var u=d=>{var f=xde(),p=I(f,!0);S(f),de(()=>me(p,n())),$(d,f)};ne(c,d=>{n()&&d(u)})}S(i),de(()=>me(l,`QuickAdd couldn't display ${t()??""}`)),$(r,i)}Wt();Wt();var X$=new WeakMap;function IY(r){let e=X$.get(r);if(e)return e;let t=HU(r);return X$.set(r,t),t}function PY(r){return X$.has(r)}Cr();var _de=z(`<div class="choiceEmptyState svelte-1r4uuo1"><!> <div class="choiceEmptyTitle svelte-1r4uuo1">No choices yet</div> <p class="choiceEmptyBody svelte-1r4uuo1">A choice is an action QuickAdd can run: create a note, capture
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>`),Ade=z('<button class="search-input-clear-button qaFilterClearButton svelte-1r4uuo1" aria-label="Clear filter"></button>'),kde=z('<div class="choiceFilterEmpty svelte-1r4uuo1">No choices match your filter.</div>'),Sde=z('<button type="button" class="qaAIAssistantBtn clickable-icon svelte-1r4uuo1" aria-label="Configure AI Assistant" title="Configure AI Assistant"><!></button>'),Dde=z('<div class="choiceFilterBar svelte-1r4uuo1"><div class="search-input-container choiceFilterInput svelte-1r4uuo1"><input type="search" placeholder="Filter choices..." autocapitalize="off" autocorrect="off" enterkeyhint="search"/> <!></div></div> <!> <div class="choiceViewBottomBar svelte-1r4uuo1"><!> <!></div>',1),Ide=z("<div><!></div>"),Pde={hash:"svelte-1r4uuo1",code:`.choiceViewBottomBar.svelte-1r4uuo1 {display:flex;flex-direction:row;align-items:center;justify-content:flex-end; /* pack right; "New choice" (primary) is the terminal action */flex-wrap:wrap;gap:0.5rem;margin-top:0.75rem;}
/* AI Assistant as a quiet icon button (matches the per-row action icons),
leading the right cluster so the bar's width barely changes when AI/online
features toggle. */.qaAIAssistantBtn.svelte-1r4uuo1 {flex: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 Q$(r,e){we(e,!0),ot(r,Pde);let t=he(e,"choices",31,()=>bt([])),n=Ae(""),i=O(()=>!Array.isArray(t())),o=O(()=>`The "choices" value in data.json is ${t()===null?"null":`of type "${typeof t()}"`}, but QuickAdd expects a list.`),s=og.Platform.isMobile,a=Ae(bt(ce.getState().disableOnlineFeatures)),l=new Uk(Ot(()=>e.plugin));function c(W){if(!Array.isArray(W))return W;let Y=PY(W),{choices:X,repaired:ae}=IY(W);if(Y)return X;for(let{choice:pe}of ae)if(pe.command)try{l.enableCommand(pe)}catch(ge){F.logError(`Could not register a command for the repaired choice "${pe.name}": ${ge instanceof Error?ge.message:String(ge)}`)}return X}t(c(t())),hr(()=>{let W=ce.subscribe(Y=>{t(c(Y.choices)),Z(a,Y.disableOnlineFeatures,!0)});return()=>W()});function u(){e.saveChoices(yh(t()))}let d=W=>W.type==="Multi";function f(W,Y){let X=Y.trim();if(!X)return W;let ae=(0,og.prepareFuzzySearch)(X),pe=ge=>{if(!Ye(ge))return null;let be=!!ae(ge.name??"");if(!d(ge))return be?ge:null;let xe=st(ge).map(Ue=>pe(Ue)).filter(Boolean);return be||xe.length>0?{...ge,collapsed:!1,choices:xe}:null};return W.map(ge=>pe(ge)).filter(Boolean)}async function p(W,Y,X,ae=!1){let pe=TY(Y,t()),ge=B$(Y,pe);if(t(sY(t(),ge,X)),!X&&h(n).trim().length>0&&Z(n,""),Y==="Multi")u(),await C(ge),await m(ge.id);else if(ae)u(),await m(ge.id);else{u();try{await w(ge)}catch(be){F.logError(`Failed to configure the new choice: ${be instanceof Error?be.message:String(be)}`),u()}await m(ge.id)}}async function m(W){await jf();try{document.querySelector(`[data-choice-id="${W}"]`)?.scrollIntoView({block:"nearest"})}catch{}}function v(W){return gx(t(),W.id)??W}function g(W){return Ye(W)?W.command?!0:st(W).some(g):!1}async function y(W){let Y=v(W);await tY(Y,e.app)&&(t(vx(t(),W.id).updated),l.disableCommand(Y,{recursive:!0}),u())}async function w(W){let Y=v(W),X=await rY(Y,e.app,e.plugin);X&&(t(t().map(ae=>x(ae,X))),l.updateCommand(Y,X),u())}function x(W,Y){if(!Ye(W))return W;if(W.id===Y.id)return{...W,...Y};if(xc(W)){let X=st(W).map(pe=>x(pe,Y));return{...W,choices:X}}return W}async function C(W){if(!W)return;let Y=await g_(e.app,W.name,W.type);if(!Y)return;let X=v(W),ae={...X,name:Y};t(t().map(pe=>x(pe,ae))),l.updateCommand(X,ae),u()}function _(W){let Y=nY(v(W));t(t().map(X=>x(X,Y))),Y.command?l.enableCommand(Y):l.disableCommand(Y),u()}async function E(W){let Y=await JG(v(W),e.app);t(q$(t(),W.id,Y)??[...t(),Y]),g(Y)&&l.enableCommand(Y),u(),new og.Notice(`Duplicated "${W.name}".`),await m(Y.id)}function D(W,Y){t(Y===H$?oY(t(),W.id):iY(t(),W.id,Y)),u()}function P(W){t(W),u()}function V(W,Y){t(aY(t(),W,Y)),u()}function j(W){t(z$(t(),W.id,!W.collapsed)),u()}function oe(W,Y){return(X,...ae)=>{let pe=Sm(X?.type),ge=X?.name?`the ${pe} \u201C${X.name}\u201D`:`that ${pe}`;em(`Couldn't ${W} ${ge}`,Y)(X,...ae)}}let se={onDeleteChoice:oe("delete",y),onConfigureChoice:oe("open the settings for",w),onToggleCommand:oe("update the command palette entry for",_),onDuplicateChoice:oe("duplicate",E),onRenameChoice:oe("rename",C),onMoveChoice:oe("move",D),onToggleCollapsed:oe("open or close",j),onReorderChoices:em("Couldn't save the new order",P),onCommitFolder:em("Couldn't save that folder's contents",V),onAddChoice:(W,Y,X,ae)=>em(`Couldn't add that ${Sm(Y)}`,p)(W,Y,X,ae)},M=em("Couldn't open the AI assistant settings",async()=>{let W=await new Qk(e.app,ce.getState().ai).waitForClose;W&&ce.setState(Y=>({...Y,ai:W}))});var U=Ide(),q=I(U);{var B=W=>{ig(W,{get detail(){return h(o)}})},ie=W=>{var Y=un(),X=Pe(Y);hv(X,{onerror:pe=>F.logError(`QuickAdd could not render the choice list: ${pe instanceof Error?pe.message:String(pe)}`),failed:(pe,ge=Vt)=>{{let be=O(()=>ge()instanceof Error?ge().message:String(ge()));ig(pe,{get detail(){return h(be)}})}}},pe=>{var ge=un(),be=Pe(ge);{var xe=Ne=>{var
/* Keeps "Add variable" right-aligned now that it is the row'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 Z$(r,e){we(e,!0),ot(r,Ode);let t=Ae(bt([]));function n(C,_){if(!_.has(C))return C;let E=1;for(;_.has(`${C}${E}`);)E++;return`${C}${E}`}function i(){let _=ce.getState().globalVariables||{};Z(t,Object.keys(_).map(E=>({name:E,value:_[E]??""})),!0)}let o=!1;function s(){let C=h(t).map(P=>P.name.trim()),_=C.some(P=>!P),E=new Set(C).size!==C.length;if(_||E)return;let D={};for(let P of h(t))D[P.name.trim()]=P.value??"";o=!0;try{ce.setState({globalVariables:D})}finally{o=!1}}function a(){let C=new Set(h(t).map(E=>E.name)),_=n("NewVar",C);Z(t,[...h(t),{name:_,value:""}],!0),s()}function l(C){Z(t,h(t).filter((_,E)=>E!==C),!0),s()}function c(C){return new Hi(e.app,C,e.plugin),{destroy(){}}}let u;function d(C){u!==void 0&&window.clearTimeout(u),u=window.setTimeout(()=>{s()},200)}hr(()=>{let C=ce.subscribe(()=>{o||i()});return i(),()=>{u!==void 0&&window.clearTimeout(u),C()}});var f=$de(),p=A(I(f),2),m=I(p);{var v=C=>{var _=Fde();$(C,_)},g=C=>{var _=Mde();$(C,_)};ne(m,C=>{h(t).length===0?C(v):C(g,-1)})}var y=A(m,2);ar(y,17,()=>h(t),Fv,(C,_,E)=>{var D=Rde(),P=I(D),V=I(P);gr(V),Fr(V,U=>c?.(U)),cn(()=>co(V,()=>h(_).name,U=>h(_).name=U)),S(P);var j=A(P,2),oe=I(j);Ad(oe),Fr(oe,U=>c?.(U)),cn(()=>co(oe,()=>h(_).value,U=>h(_).value=U)),S(j);var se=A(j,2),M=I(se);S(se),S(D),De("input",V,()=>{d(h(_))}),De("input",oe,()=>d(h(_))),De("click",M,()=>l(h(t).indexOf(h(_)))),$(C,D)}),S(p);var w=A(p,2),x=I(w);S(w),S(f),De("click",x,a),$(r,f),Ce()}Et(["input","click"]);It();qt();var jY=require("obsidian");var qa=require("obsidian");Wt();Ii();Yr();var Nde=new Set;function eO(r){return r.type==="Multi"}function tO(r){return r.type==="Macro"}function Lde(r){return r.type==="Template"}function Bde(r){return r.type==="Capture"}function rS(r,e,t){return r?e.has(r.id)?t.has(r.id):!0:!1}function FY(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&&rS(o.choice,e,t)&&n(o.choice),!0}case"NestedChoice":{let i=r;return i.choice&&rS(i.choice,e,t)&&n(i.choice),!0}default:return!1}}function Ude(r){let e=new Map,t=(n,i,o)=>{for(let s of n){if(!Ye(s))continue;let a=[...o,s.name];e.set(s.id,{choice:s,parentId:i,path:a}),eO(s)&&Array.isArray(s.choices)&&t(s.choices,s.id,a)}};return t(hn(r),null,[]),e}function MY(r){let e=new Set;for(let t of st(r))Ye(t)&&e.add(t.id);return tO(r)&&J$(r.macro?.commands,e),e}function J$(r,e){for(let t of Dr(r))if(Si(t))switch(t.type){case"Choice":{let n=t;n.choiceId&&e.add(n.choiceId);break}case"Conditional":{let n=t;J$(n.thenCommands,e),J$(n.elseCommands,e);break}case"NestedChoice":{let i=t.choice;if(!i)break;let o=MY(i);for(let s of o)e.add(s);break}default:break}}function nS(r,e,t){let n=Ude(r),i=new Set,o=new Set,s=t?.excludedChoiceIds??Nde,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=MY(u.choice);for(let f of d){if(!n.has(f)){o.add(f);continue}s.has(f)||a.push(f)}}return{catalog:n,choiceIds:l,missingChoiceIds:Array.from(o)}}function iS(r,e){let t=new Set(e),n=new Set,i=new Set,o=new Set,s=l=>{if(l&&rS(l,r,t)&&!n.has(l.id)){if(n.add(l.id),eO(l)&&Array.isArray(l.choices))for(let c of l.choices)s(c);tO(l)&&a(l.macro?.commands)}},a=l=>{for(let c of Dr(l))if(Si(c)&&!FY(c,r,t,s))switch(c.type){case"UserScript":{let u=c;u.path&&i.add(u.path);break}case"Conditional":{let u=c,d=u.condition;d.mode==="script"&&d.scriptPath&&o.add(d.scriptPath),a(u.thenCommands),a(u.elseCommands);break}default:break}};for(let l of e){let c=r.get(l);c&&s(c.choice)}return{userScriptPaths:i,conditionalScriptPaths:o}}function oS(r,e){let t=new Set(e),n=new Set,i=new Set,o=new Set,s=l=>{if(l&&rS(l,r,t)&&!n.has(l.id)){if(n.add(l.id),Lde(l)&&l.templatePath&&i.add(l.templatePath),Bde(l)&&l.createFileIfItDoesntExist?.enabled&&l.createFileIfItDoesntExist.createWithTemplate&&l.createFileIfItDoesntExist.template&&o.add(l.createFileIfItDoesntExist.template),eO(l)&&Array.isArray(l.choices))for(let c of l.choices)s(c);tO(l)&&a(l.macro?.commands)}},a=l=>{for(let c of Dr(l
/* 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 rO(r,e){we(e,!0),ot(r,ipe);let t={"user-script":"User script","conditional-script":"Conditional script",template:"Template file","capture-template":"Capture template"},n=Ae(""),i=Ae(bt(new Set)),o=Ae(bt(new Set)),s=Ae(bt(qY())),a=Ae(null),l=Ae(null),c=O(()=>ly(e.allChoices)),u=O(()=>v(h(c),h(n))),d=O(()=>_(h(c),h(i))),f=O(()=>E(e.allChoices,h(d),h(o))),p=O(()=>new Map(h(c).map(k=>[k.id,k.path.join(" / ")])));function m(k){return k.type==="Multi"}function v(k,N){let K=N.trim().toLowerCase();return K?k.filter(J=>`${J.path.join(" ")} ${J.choice.type}`.toLowerCase().includes(K)):k}function g(k){let N=[];for(let K of st(k))Ye(K)&&N.push(K.id,...g(K));return N}function y(k,N){let K=[k.id,...g(k)];if(N){let J=new Set(h(i));for(let ue of K)J.add(ue);if(Z(i,J,!0),h(o).size>0){let ue=new Set(h(o));for(let ve of K)ue.delete(ve);Z(o,ue,!0)}}else{let J=new Set(h(i));for(let ve of K)J.delete(ve);Z(i,J,!0);let ue=new Set(h(o));for(let ve of K)ue.add(ve);Z(o,ue,!0)}}function w(k){let N=h(c).find(J=>J.id===k);if(!N)return;let K=h(i).has(k);y(N.choice,!K),Z(a,null)}function x(){for(let k of h(u))y(k.choice,!0);Z(a,null)}function C(){Z(i,new Set,!0),Z(o,new Set,!0),Z(a,null)}function _(k,N){let K=[];for(let J of k)N.has(J.id)&&(!J.parentId||!N.has(J.parentId))&&K.push(J.id);return K}function E(k,N,K){if(N.length===0)return{rootCount:0,totalChoices:0,dependencyCount:0,missingChoiceIds:[],userScripts:0,conditionalScripts:0,templateFiles:0,captureTemplates:0};let J=nS(k,N,{excludedChoiceIds:K}),ue=iS(J.catalog,J.choiceIds),ve=oS(J.catalog,J.choiceIds);return{rootCount:N.length,totalChoices:J.choiceIds.length,dependencyCount:Math.max(J.choiceIds.length-N.length,0),missingChoiceIds:J.missingChoiceIds,userScripts:ue.userScriptPaths.size,conditionalScripts:ue.conditionalScriptPaths.size,templateFiles:ve.templatePaths.size,captureTemplates:ve.captureTemplatePaths.size}}function D(k){let{missingChoiceIds:N,missingAssets:K}=k;return N.length===0&&K.length===0?null:{missingChoices:N,missingAssets:K}}async function P(){if(h(d).length===0)return new qa.Notice("Select at least one choice to export."),null;try{let k=await WY(e.app,{choices:e.allChoices,rootChoiceIds:h(d),excludedChoiceIds:Array.from(h(o)),quickAddVersion:e.plugin.manifest.version});return Z(a,D(k),!0),k}catch(k){return console.error(k),Z(a,null),new qa.Notice(`Export failed: ${k?.message??String(k)}`),null}}async function V(){if(!h(l)){Z(l,"copy");try{let k=await P();if(!k)return;let N=JSON.stringify(k.pkg,null,2);await oe(N),new qa.Notice(`Copied package (${k.pkg.choices.length} choice${k.pkg.choices.length===1?"":"s"}) to clipboard.`),h(a)?new qa.Notice("Package copied with warnings. Review details below."):e.close()}catch(k){console.error(k),new qa.Notice(`Copy failed: ${k?.message??String(k)}`)}finally{Z(l,null)}}}async function j(){if(h(l))return;let k=h(s).trim();if(!k){new qa.Notice("Enter a file path before saving.");return}Z(l,"save");try{let N=await P();if(!N)return;let{overwritten:K}=await HY(e.app,N.pkg,k),J=N.pkg.choices.length,ue=`${J} choice${J===1?"":"s"}`;new qa.Notice(K?`Overwrote package (${ue}) at '${k}'.`:`Saved package (${ue}) to '${k}'.`),h(a)?new qa.Notice("Package saved with warnings. Review details below."):e.close()}catch(N){let K=N?.message??String(N);if(K.startsWith("Save cancelled:")){new qa.Notice("Save cancelled.");return}console.error(N),new qa.Notice(`Save failed: ${K}`)}finally{Z(l,null)}}async function oe(k){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(k);return}let N=document.createElement("textarea");N.value=k,N.setAttribute("readonly","true"),N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.focus(),N.select();let K=document.execCommand("copy");if(document.body.removeChild(N),!K)throw new Error("Clipboard copy is not supported in this environment.")}var se=npe(),M=A(I(se),2),U=I(M);gr(U),ke(U,"spellcheck",!1);var q=A(U,2),B=I(q),ie=A(B,2);S(q),S(M);var W=A(M,2),Y=I(W);{var X=k=>{var N=Yde();$(k,N)},ae=k=>{var N=Qde();ar(N,21,()=>h(u),K=>K.id,(K,J)=>{var ue=Xde(),ve=I(ue),Ve=I(ve);gr(
${ue??""}`),[()=>h(f).missingChoiceIds.join(", ")]),$(k,N)};ne(yr,k=>{h(f).missingChoiceIds.length>0&&k(Pt)})}S(pe);var Ar=A(pe,2);{var ur=k=>{var N=rpe(),K=A(I(N),2);{var J=Ve=>{var vt=Jde(),Pr=I(vt);S(vt),de(jt=>me(Pr,`Missing choices:
${jt??""}`),[()=>h(a).missingChoices.map(jt=>h(p).get(jt)??jt).join(", ")]),$(Ve,vt)};ne(K,Ve=>{h(a).missingChoices.length>0&&Ve(J)})}var ue=A(K,2);{var ve=Ve=>{var vt=tpe(),Pr=A(I(vt),2);ar(Pr,21,()=>h(a).missingAssets,jt=>jt.path,(jt,$i)=>{var yt=epe(),pr=I(yt),kr=A(pr),Gn=I(kr);S(kr),S(yt),de(()=>{me(pr,`${h($i).path??""} `),me(Gn,`(${t[h($i).kind]??""})`)}),$(jt,yt)}),S(Pr),S(vt),$(Ve,vt)};ne(ue,Ve=>{h(a).missingAssets.length>0&&Ve(ve)})}S(N),$(k,N)};ne(Ar,k=>{h(a)&&k(ur)})}var dt=A(Ar,2),Ft=I(dt),Hn=I(Ft),xo=I(Hn);{var xs=k=>{var N=cl("Copying\u2026");$(k,N)},jn=k=>{var N=cl("Copy JSON");$(k,N)};ne(xo,k=>{h(l)==="copy"?k(xs):k(jn,-1)})}S(Hn),S(Ft);var re=A(Ft,2),Ie=I(re),dr=A(I(Ie),2),br=I(dr);gr(br);var Tn=A(br,2),Ho=I(Tn);{var Ka=k=>{var N=cl("Saving\u2026");$(k,N)},Xa=k=>{var N=cl("Save to file");$(k,N)};ne(Ho,k=>{h(l)==="save"?k(Ka):k(Xa,-1)})}S(Tn),S(dr),S(Ie),S(re),S(dt);var Jc=A(dt,2),T=I(Jc);S(Jc),S(se),de(()=>{me(Ue,h(f).rootCount),me(Ke,h(f).totalChoices),me(We,h(f).dependencyCount),me(_e,h(f).userScripts+h(f).conditionalScripts),me(or,h(f).templateFiles+h(f).captureTemplates),Hn.disabled=h(l)!==null,Tn.disabled=h(l)!==null,T.disabled=h(l)!==null}),co(U,()=>h(n),k=>Z(n,k)),De("click",B,x),De("click",ie,C),De("click",Hn,V),co(br,()=>h(s),k=>Z(s,k)),De("click",Tn,j),De("click",T,function(...k){e.close?.apply(this,k)}),$(r,se),Ce()}Et(["click","change"]);var cS=class extends jY.Modal{constructor(t,n,i){super(t);this.plugin=n;this.choices=i;this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageExportModal"),this.handle=qi(this.contentEl,rO,{app:this.app,plugin:this.plugin,allChoices:this.choices,close:()=>this.close()},{what:"the package exporter"})}onClose(){this.handle?.destroy(),this.handle=null}};var x4=require("obsidian");var Ax=require("obsidian");It();qt();var gS=require("obsidian");ml();Wt();Ii();Yr();Yr();Yr();Wt();Ii();function ope(r){return r.type==="Multi"}function spe(r){return r.type==="Macro"}function nO(r,e,t){if(!(!r||typeof r!="object")){if(Array.isArray(r)){e.onUnreadable?.();return}if(!t.has(r)){if(t.add(r),e.onChoice?.(r),ope(r))if(Array.isArray(r.choices))for(let n of r.choices)nO(n,e,t);else t_(r.choices)&&e.onUnreadable?.();spe(r)&&uS(Wn(r.macro),e,t)}}}function uS(r,e,t){if(!Array.isArray(r)){Di(r)&&e.onUnreadable?.();return}for(let n of r){if(!n||typeof n!="object")continue;if(Array.isArray(n)){e.onUnreadable?.();continue}e.onCommand?.(n);let i=n;(n.type==="Conditional"||Array.isArray(i.thenCommands)||Array.isArray(i.elseCommands))&&(uS(i.thenCommands,e,t),uS(i.elseCommands,e,t));let s=n,a=n.type==="NestedChoice"||s.choice&&typeof s.choice=="object"?s.choice:void 0;a&&nO(a,e,t)}}function iO(r,e){let t=new Set;if(Array.isArray(r.choices))for(let i of r.choices)nO(i,e,t);else e.onUnreadable?.();let n=r.macros;if(Array.isArray(n))for(let i of n)uS(Wn(i),e,t);else Di(n)&&e.onUnreadable?.()}function sg(r){let e=!1;return iO(r,{onUnreadable:()=>{e=!0}}),e}function ag(r,e){iO(r.settings,{onChoice:e})}function dS(r,e){iO(r,{onCommand:e})}function ape(r){return r.type==="AIAssistant"}function pS(r,e,t){let n=0;return dS({choices:r},i=>{if(!ape(i)||i.modelRef&&i.modelRef.name===i.model&&e.find(l=>l.id===i.modelRef?.providerId)?.models.some(l=>l.name===i.model)||!i.model||i.model==="Ask me")return;let o=e.find(a=>a.models.some(l=>l.name===i.model));if(!o?.id)return;let s={providerId:o.id,name:i.model};i.modelRef=s,n++,t?.(i,s)}),n}Me();vi();sO();Ec();Uc();Yr();Wt();Ii();Kv();Tt();var lO={"user-script":{severity:"critical",label:"SCRIPT",description:"Runs custom JavaScript with full access to your vault and the network."},"conditional-script":{severity:"critical",label:"CONDITIONAL",description:"Runs custom JavaScript to decide which branch executes."},"bundled-script":{severity:"critical",label:"SCRIPT FILE",description:"Bundles a file that will be written to your vault and can be run as code."},"run-on-startup":{severity:"critical",label:"STARTUP",description:"Runs automatically every time Obsidian starts."},"mislabeled-executable":{severity:"critical",label:"EXECUTABLE"
`?(n>e&&(e=n),n=0,t++):n++;n>e&&(e=n);let i=r.length/t;return e>1e3||i>250}function hS(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=qc(t.content),i=n.length>YY,o=i?n.slice(0,YY):n;return{found:!0,text:o,truncated:i,sizeBytes:Tpe(n),looksMinified:_pe(o)}}catch(n){return{found:!0,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:n instanceof Error?n.message:String(n)}}}function t4(r){return r.summary.hasCritical}function r4(r,e){return r.criticalScriptPaths.every(t=>e.has(t))}async function n4(r,e){if(Un(e))throw new Error(`Refusing to read a package outside the vault: "${e}".`);let t=(0,gS.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:mO(i),path:t}}function mO(r){let e;try{e=JSON.parse(r)}catch(o){throw new Error(`Package content is not valid JSON: ${o?.message??o}`)}if(!$Y(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=Ape(e.assets);if(t!==null)throw new Error(`Package contains duplicate asset path "${t}". Each asset must have a unique path.`);let n=kpe(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=Spe(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 Ape(r){let e=new Set;for(let t of r){let n=(0,gS.normalizePath)(t.originalPath??"");if(e.has(n))return t.originalPath;e.add(n)}return null}function kpe(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=dO(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"&&uO(i.macro?.commands,n)};for(let i of r){if(t!==null)break;n(i?.choice)}return t}function uO(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;uO(n.thenCommands,e),uO(n.elseCommands,e)}}}}function dO(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(dO).join(",")}]`;let e=r;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${dO(e[n])}`).join(",")}}`}function Spe(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(!st(o).some(a=>a?.id===t.choice.id))return t.choice.id}return null}async function i4(r,e,t){let n=new Map(Bn(e).map(s=>[s.id,s])),i=t.choices.map(s=>({choiceId:s.choice.id,name:s.choice.name,parentChoiceId:s.parentChoiceId,pathHint:s.pathHint??[],exists:n.has(s.choice.id)})),o=[];for(let s of t.assets){let a=Un(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 vS(r,e,t){let n=new Set([...t.assets.map(a=>a.originalPath),...JY(t)]),i=new Set;await Promise.all(Array.from(n,async a=>{a&&(Un(a)||await s4(r,a)&&i.add(a))}));let o=e4(e,t,i),{summary:s}=o;return F.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 Dpe(r){let t=(r??"").trim();if(!t)throw new Error("Package asset has an empty destination path.");let n=t.replace(/\\/g,"/");if(n.startsWith("/"
/* Critical: darkened red so white text clears WCAG AA (~5:1) at this size,
where Obsidian's stock --color-red (#e93147) lands at ~3.5:1. */.qa-import-tag.critical.svelte-5jkd35 {background:var(--qa-sev-critical-pill);color:#fff;}
/* Warning: amber is medium-luminance in both themes, so near-black text
(~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 _x(r,e){we(e,!0),ot(r,Rpe);let t=O(()=>fS(e.flag)),n=O(()=>KY(e.flag)),i=O(()=>XY(e.flag));var o=Mpe();let s;var a=I(o,!0);S(o),Fr(o,(l,c)=>Tx?.(l,c),()=>h(i)),de(()=>{s=wt(o,1,"qa-import-tag svelte-5jkd35",null,s,{critical:h(t)==="critical",warning:h(t)==="warning",info:h(t)==="info"}),me(a,h(n))}),$(r,o),Ce()}var $pe=z('<span class="qa-import-banner-detail svelte-tb9yz"> </span>'),Ope=z('<li><span class="qa-import-banner-tag svelte-tb9yz"><!></span><span class="qa-import-banner-title svelte-tb9yz"> </span> <!></li>'),Npe=z('<p class="qa-import-banner-note svelte-tb9yz">Takes effect after you reload the plugin or restart Obsidian.</p>'),Lpe=z('<section aria-label="What this package can do"><div class="qa-import-banner-head svelte-tb9yz"><span class="qa-import-banner-icon svelte-tb9yz"><!></span> <h3 class="svelte-tb9yz">What this package can do</h3></div> <ul class="qa-import-banner-rows svelte-tb9yz"></ul> <!></section>'),Bpe={hash:"svelte-tb9yz",code:`.qa-import-banner.svelte-tb9yz {background:var(--background-secondary);border: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 vO(r,e){we(e,!0),ot(r,Bpe);let t=O(()=>e.preview.summary.runsOnStartup||e.preview.summary.registersCommandCount>0);var n=Lpe();let i;var o=I(n),s=I(o),a=I(s);Rt(a,{iconId:"alert-triangle",size:17}),S(s),In(2),S(o);var l=A(o,2);ar(l,21,()=>e.preview.capabilityRows,d=>d.flag+d.detail,(d,f)=>{var p=Ope();let m;var v=I(p),g=I(v);_x(g,{get flag(){return h(f).flag}}),S(v);var y=A(v),w=I(y,!0);S(y);var x=A(y,2);{var C=_=>{var E=$pe(),D=I(E,!0);S(E),de(()=>me(D,h(f).detail)),$(_,E)};ne(x,_=>{h(f).detail&&_(C)})}S(p),de(()=>{m=wt(p,1,"svelte-tb9yz",null,m,{"sev-critical":h(f).severity==="critical","sev-warning":h(f).severity==="warning","sev-info":h(f).severity==="info"}),me(w,h(f).title)}),$(d,p)}),S(l);var c=A(l,2);{var u=d=>{var f=Npe();$(d,f)};ne(c,d=>{h(t)&&d(u)})}S(n),de(()=>i=wt(n,1,"qa-import-banner svelte-tb9yz",null,i,{critical:e.preview.summary.hasCritical})),$(r,n),Ce()}var Upe=z('<span class="qa-import-file-exec svelte-lmqem5">Executable</span>'),Vpe=z('<span class="qa-import-file-reviewed svelte-lmqem5"><!> Reviewed</span>'),qpe=z('<span class="qa-import-file-orphan svelte-lmqem5">Unused</span>'),Wpe=z("<option>Overwrite</option>"),zpe=z(`<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>`),Hpe=z('<p class="qa-import-file-error svelte-lmqem5"> </p>'),jpe=z(`<p class="qa-import-file-warn svelte-lmqem5">Minified: cannot be visually reviewed. Import
only if you trust the source.</p>`),Gpe=z('<p class="qa-import-file-warn svelte-lmqem5"> </p>'),Ype=z('<!> <pre class="qa-import-file-code svelte-lmqem5" tabindex="0" role="region"> </pre> <!>',1),Kpe=z('<div class="qa-import-file-preview svelte-lmqem5"><!></div>'),Xpe=z('<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>'),Qpe={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 bS(r,e){we(e,!0),ot(r,Qpe);let t=he(e,"reviewed",3,!1),n=Ae(!1),i=O(()=>h(n)?hS(e.pkg,e.file.originalPath):null),o=O(()=>`qa-file-preview-${e.file.originalPath.replace(/[^a-zA-Z0-9_-]/g,"-")}`);function s(_e){return _e<1024?`${_e} B`:_e<1024*1024?`${(_e/1024).toFixed(1)} KB`:`${(_e/(1024*1024)).toFixed(1)} MB`}function a(){Z(n,!h(n)),h(n)&&e.file.requiresReview&&e.onReviewed(e.file.originalPath)}function l(_e){e.onPathInput(_e.currentTarget.value)}function c(_e){e.onModeChange(_e.currentTarget.value)}var u=Xpe();let d;var f=I(u),p=I(f);{let _e=O(()=>e.destinationExists?"file-warning":"file-plus");Rt(p,{get iconId(){return h(_e)},size:16})}var m=A(p,2);let v;var g=I(m,!0);S(m);var y=A(m,4),w=I(y,!0);S(y),S(f);var x=A(f,2),C=I(x);{var _=_e=>{var Be=Upe();Fr(Be,(ut,or)=>Tx?.(ut,or),()=>"Runs as code when its choice runs. It can read, change, or delete files in your vault and access the network."),$(_e,Be)};ne(C,_e=>{e.file.executable&&_e(_)})}var E=A(C,2);{var D=_e=>{var Be=Vpe(),ut=I(Be);Rt(ut,{iconId:"check",size:12}),In(),S(Be),$(_e,Be)};ne(E,_e=>{t()&&e.mode!=="skip"&&e.file.requiresReview&&_e(D)})}var P=A(E,2);{var V=_e=>{var Be=qpe();Fr(Be,(ut,or)=>Tx?.(ut,or),()=>"Bundled in this package but not referenced by any choice."),$(_e,Be)};ne(P,_e=>{e.file.orphan&&_e(V)})}var j=A(P,2),oe=I(j,!0);S(j),S(x);var se=A(x,2),M=I(se),U=A(I(M),2);gr(U),S(M);var q=A(M,2),B=A(I(q),2),ie=I(B);ie.value=ie.__value="write";var W=A(ie);{var Y=_e=>{var Be=Wpe();Be.value=Be.__value="overwrite",$(_e,Be)};ne(W,_e=>{e.destinationExists&&_e(Y)})}var X=A(W);X.value=X.__value="skip",S(B);var ae;Vd(B),S(q),S(se);var pe=A(se,2);{var ge=_e=>{var Be=zpe();$(_e,Be)};ne(pe,_e=>{e.file.requiresReview&&e.mode==="skip"&&_e(ge)})}var be=A(pe,2),xe=I(be);let Ue;var $t=I(xe);Rt($t,{iconId:"chevron-right",size:14}),S(xe);var Ne=A(xe,2),Ke=I(Ne,!0);S(Ne),S(be);var Qe=A(be,2);let ye;var We=I(Qe),mt=I(We);{var He=_e=>{var Be=Kpe(),ut=I(Be);{var or=Pt=>{var Ar=Hpe(),ur=I(Ar);S(Ar),de(()=>me(ur,`Preview unavailable: ${h(i).error??""}`)),$(Pt,Ar)},yr=Pt=>{var Ar=Ype(),ur=Pe(Ar);{var dt=jn=>{var re=jpe();$(jn,re)};ne(ur,jn=>{h(i).looksMinified&&jn(dt)})}var Ft=A(ur,2),Hn=I(Ft,!0);S(Ft);var xo=A(Ft,2);{var xs=jn=>{var re=Gpe(),Ie=I(re);S(re),de(()=>me(Ie,`Preview truncated. The full ${e.file.executable?"script will run":"file will be imported"}.`)),$(jn,re)};ne(xo,jn=>{h(i).truncated&&jn(xs)})}de(()=>{ke(Ft,"aria-label",`Contents of ${e.file.originalPath??""}`),me(Hn,h(i).text)}),$(Pt,Ar)};ne(ut,Pt=>{h(i).error?Pt(or):Pt(yr,-1)})}S(Be),$(_e,Be)};ne(mt,_e=>{h(i)&&_e(He)})}S(We),S(Qe),S(u),de(_e=>{d=wt(u,1,"qa-import-file svelte-lmqem5",null,d,{overwrite:e.destinationExists}),v=wt(m,1,"qa-import-file-status svelte-lmqem5",null,v,{overwrite:e.destinationExists}),me(g,e.destinationExists?"Will overwrite":"New file"),me(w,e.destinationPath),me(oe,_e),Ps(U,e.destinationPath),U.disabled=e.mode==="skip",ae!==(ae=e.mode)&&(B.value=(B.__value=e.mode)??"",fu(B,e.mode)),ke(be,"aria-expanded",h(n)),ke(be,"aria-controls",h(o)),Ue=wt(xe,1,"qa-import-file-chevron svelte-lmqem5",null,Ue,{open:h(n)}),me(Ke,h(n)?"Hide contents":"View contents"),ye=wt(Qe,1,"qa-import-file-preview-wrap svelte-lmqem5",null,ye,{open:h(n)}),ke(Qe,"id",h(o))},[()=>s(e.file.sizeBytes)]),De("input",U,l),De("change",B,c),De("click",be,a),$(r,u),Ce()}Et(["input","change","click"]);var Zpe=z('<span class="macroCommandType svelte-1qj0pve"> </span>'),Jpe=z("<code> </code>"),efe=z('<span class="macroCommandSummary svelte-1qj0pve"> </span>'),tfe=z('<li class="svelte-1qj0pve"><span class="macroCommandName svelte-1qj0pve"> </span> <!> <!></li>'),rfe=z('<ul class="macroCommands svelte-1qj0pve"></ul>'),nfe={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-mute
used by any choice</li>`),wfe=z('<div class="warnItem svelte-1nd6fqb"><h4 class="svelte-1nd6fqb">Unreferenced files</h4> <ul class="svelte-1nd6fqb"></ul></div>'),Cfe=z('<section class="warningsBand svelte-1nd6fqb"><!> <!></section>'),xfe=z('<section class="filesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Files</h3> <!></section> <!>',1),Efe=z('<section class="summary svelte-1nd6fqb"><!> <span class="svelte-1nd6fqb"> </span></section>'),Tfe=z('<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> <!> <section class="choicesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Choices</h3> <!></section> <!> <!>',1),_fe=z('<p id="qa-import-ack-hint" class="ackGate-hint svelte-1nd6fqb"> </p>'),Afe=z('<section><label class="ackGate-label svelte-1nd6fqb"><input id="qa-import-ack-checkbox" type="checkbox" class="svelte-1nd6fqb"/> <span class="svelte-1nd6fqb"> </span></label> <!></section>'),kfe=z('<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>'),Sfe={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);}.choicesSection.svelte-1nd6fqb,
.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;}.choiceName.svelte-1nd6fqb {font-weight:500;}
/* A plain inline text link, not a chrome button: neutralise Obsidian's
default button background/shadow on every state (!important to win over
the global button:hover / :focus rules that paint the grey box). */.macroToggle.svelte-1nd6fqb {display:inline-block;margin-top:0.35rem;padding:0;background:transparent !important;border:none;box-shadow:none !important;color:var(--text-accent);cursor:pointer;font-size:var(--font-ui-smaller, 0.8rem);border-radius:var(--radius-s, 4px);}.macroToggle.svelte-1nd6fqb:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.macroToggle.svelte-1nd6fqb:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {background:var(--background-primary-alt, var(--background-secondary));}.warningsBand.svelte-1nd6fqb {display:flex;flex-direction:column;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;gap:0.5rem;}.warnItem.svelte-1nd6fqb h4:where(.svelte-1nd6fqb) {margin:0;font-size:var(--font-ui-small, 0.9rem);}.warnItem.svelte-1nd6fqb ul:where(.svelte-1nd6fqb) {margin:0.25rem 0 0;padding-left:1rem;}.warnItem.svelte-1nd6fqb li:where(.svelte-1nd6fqb) {overflow-wrap:anywhere;}
/* A missing SCRIPT reference is an execution-hijack risk, not a broken
link: it runs from whatever exists at that path. Mark it as critical. */.warnItem.svelte-1nd6fqb li.script:where(.svelte-1nd6fqb) {padding:0.25rem 0.4rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-critical-wash);}.warnLoc.svelte-1nd6fqb {color:var(--text-muted);font-size:var(--font-ui-smaller, 0.8rem);}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb) {width:100%;border-collapse:collapse;table-layout:fixed;}.choicesSection.svelte-1nd6fqb col.colName:where(.svelte-1nd6fqb) {width:52%;}.choicesSection.svelte-1nd6fqb col.colLocation:where(.svelte-1nd6fqb) {width:26%;}.choicesSection.svelte-1nd6fqb col.colAction:where(.svelte-1nd6fqb) {width:22%;}.choicesSection.svelte-1nd6fqb th:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {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-1nd6fqb th:where(.svelte-1nd6fqb) {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);font-weight:600;}.choiceExists.svelte-1nd6fqb {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);margin-top:0.1rem;}.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb) tr:where(.svelte-1nd6fqb):not(.macroRow):hover td:where(.svelte-1nd6fqb) {background:var(--background-modifier-hover);}.choicesSection.svelte-1nd6fqb select:where(.svelte-1nd6fqb) {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-1nd6fqb thead:where(.svelte-1nd6fqb) {display:none;}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb tr:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {display:block;width:100%;}.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb) tr:where(.svelte-1nd6fqb):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-1nd6fqb td:where(.svelte-1nd6fqb) {border-bottom:none;padding:0.15rem 0;}.choicesSection.svelte-1nd6fqb td[data-label="Location"]:where(.svelte-1nd6fqb)::before,
.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb)::before {content:attr(data-label) ": ";font-weight:600;color:var(--text-muted);}.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb) {display:flex;align-items:center;gap:0.4rem;margin-top:0.25rem;}.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb) select:where(.svelte-1nd6fqb) {flex:1;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {padding:0.25rem 0;}
}.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;}.ackGate.svelte-1nd6fqb {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-1nd6fqb {border-color:var(--qa-sev-critical-border);}.ackGate-label.svelte-1nd6fqb {display:flex;align-items:flex-start;gap:0.5rem;font-weight:600;cursor:pointer;}.ackGate-label.svelte-1nd6fqb:has(input:where(.svelte-1nd6fqb):disabled) {cursor:not-allowed;opacity:0.6;}.ackGate-label.svelte-1nd6fqb input:where(.svelte-1nd6fqb) {margin-top:0.2rem;flex-shrink:0;}.ackGate-label.svelte-1nd6fqb input:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.ackGate-hint.svelte-1nd6fqb {margin:0;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);}.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;}.is-mobile .macroToggle.svelte-1nd6fqb {min-height:36px;padding:0.4rem 0.3rem;}
@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 CO(r,e){we(e,!0),ot(r,Sfe);let t;function n(){return t??(t=new wS(e.app))}let i=Ae(null),o=Ae(null),s=Ae(null),a=Ae(!1),l=Ae(bt(new Set)),c=Ae(bt(new Set)),u=Ae(null),d=Ae(!1),f=Ae(null),p=Ae(bt(new Map)),m=Ae(bt(new Map)),v=Ae(""),g=Ae(!1),y=Ae(0),w=Ae(!1),x=O(()=>h(s)?t4(h(s)):!1),C=O(()=>h(s)?r4(h(s),h(l)):!0),_=O(()=>new Map((h(s)?.choices??[]).map(re=>[re.choiceId,re]))),E=O(()=>new Map((h(s)?.files??[]).map(re=>[re.originalPath,re]))),D=O(()=>!!(h(s)&&(h(s).summary.hasCritical||h(s).summary.hasWarning))),P=O(()=>!!(h(i)&&h(o))&&!h(g)&&(!h(x)||h(a)&&h(C))),V=O(()=>h(s)?.criticalScriptPaths.length??0),j=O(()=>h(s)?.missingReferences.some(re=>re.asScript)??!1),oe=O(()=>{let re=h(f);if(!re)return"";let Ie=[];re.added&&Ie.push(`${re.added} choice${re.added===1?"":"s"} added`),re.overwritten&&Ie.push(`${re.overwritten} overwritten`),re.assetsWritten&&Ie.push(`${re.assetsWritten} file${re.assetsWritten===1?"":"s"} written`);let dr=re.skipped+re.assetsSkipped;return dr&&Ie.push(`${dr} skipped`),Ie.length?`Imported: ${Ie.join(", ")}.`:"Nothing was imported."}),se=O(()=>h(V)>0?h(j)?"I have reviewed each bundled script above and trust the source, including scripts that are not included and cannot be shown.":"I have reviewed each script above and trust the source.":h(j)?"This package runs scripts that are not included and cannot be reviewed. I trust the source.":"I understand this package can run code, and I trust the source.");function M(re){if(h(l).has(re))return;let Ie=new Set(h(l));Ie.add(re),Z(l,Ie,!0)}function U(re){let Ie=new Set(h(c));Ie.has(re)?Ie.delete(re):Ie.add(re),Z(c,Ie,!0)}let q=re=>n().optimistic(re),B=O(()=>(h(o)?.assetConflicts??[]).map(re=>({conflict:re,state:m4(h(m),re,Y,q),file:h(E).get(re.originalPath)}))),ie=O(()=>h(B).filter(re=>!re.state.destinationExists)),W=O(()=>h(B).filter(re=>re.state.destinationExists));function Y(re){let[Ie]=Wi(ce.getState().templateFolderPaths),dr=re.kind==="template"||re.kind==="capture-template";if(Ie&&dr){let br=re.originalPath.split("/").pop()??re.originalPath;return`${Ie}/${br}`}return re.originalPath}function X(re,Ie){n().schedule(re,Ie,dr=>{Z(m,b4(h(m),re,dr),!0)})}function ae(){if(!h(o)){Z(p,new Map,!0),Z(m,new Map,!0);return}Z(p,h4(h(o).choiceConflicts),!0),Z(m,f4(h(o).assetConflicts,Y,q),!0);for(let re of h(o).assetConflicts){let Ie=h(m).get(re.originalPath);Ie&&X(re.originalPath,Ie.destinationPath)}}function pe(re,Ie){Z(p,g4(h(p),re,Ie),!0)}function ge(re,Ie){Z(m,v4(h(m),re,Ie,q),!0)}function be(re,Ie){let{decisions:dr,effectivePath:br}=y4(h(m),re.originalPath,Ie,q);Z(m,dr,!0),X(re.originalPath,br)}function xe(re,Ie){let br=Ie.currentTarget.value;pe(re,br)}function Ue(){Z(s,null),Z(a,!1),Z(l,new Set,!0),Z(c,new Set,!0)}async function $t(re){let Ie=re.trim(),dr=MI(y);if(Z(f,null),Z(w,!1),!Ie){Z(i,null),Z(o,null),Z(p,new Map,!0),Z(m,new Map,!0),Ue(),Z(u,null);return}Z(g,!0);try{let br=mO(Ie),Tn=ce.getState().choices,Ho=await i4(e.app,Tn,br),Ka=await vS(e.app,Tn,br);if(dr!==h(y))return;Z(i,{pkg:br,path:"[pasted]"},!0),Z(o,Ho,!0),Ue(),Z(s,Ka,!0),Z(u,null),ae()}catch(br){if(dr!==h(y))return;Z(u,br?.message??String(br),!0),Z(i,null),Z(o,null),Z(p,new Map,!0),Z(m,new Map,!0),Ue()}finally{dr===h(y)&&Z(g,!1)}}function Ne(re){let Ie=re.currentTarget.value;Z(v,Ie,!0),$t(Ie)}function Ke(re){return!re||re.length===0?"Root":re.slice(0,-1).join(" \u203A ")||"Root"}async function Qe(){if(h(w)){new Ax.Notice("This package has already been imported.");return}if(!h(i)||!h(o)){new Ax.Notice("Load a package before importing.");return}Z(d,!0),Z(f,null);try{let re=await o4({app:e.app,existingChoices:ce.getState().choices,aiProviders:ce.getState().ai.providers,pkg:h(i).pkg,choiceDecisions:w4(h(o).choiceConflicts,h(p)),assetDecisions:C4(h(o).assetConflicts,h(m),q)});ce.setState(Ie=>({...Ie,choices:re.updatedChoices})),Z(f,{added:re.addedChoiceIds.length,overwritten:re.overwrittenChoiceIds.length,skipped:re.skippedChoiceIds.length,assetsWritten:re.writtenAssets.length,assetsSkipped:re.skippedAssets.length},!0),Z(w,!0),new Ax.Notice(`Imported ${re.addedChoiceIds.length+re.overw
${h(To).asScript?"not bundled, so it runs from whatever file exists at that path after import":"not bundled and not in your vault"} `),me(ru,h(To).breadcrumb)}),$(to,An)}),S(eo),S(Ji),$(pi,Ji)};ne(jl,pi=>{h(s).missingReferences.length>0&&pi(bd)})}var ev=A(jl,2);{var xf=pi=>{var Ji=wfe(),eo=A(I(Ji),2);ar(eo,20,()=>h(s).orphanAssets,to=>to,(to,To)=>{var An=bfe(),Gt=I(An),ro=I(Gt,!0);S(Gt),In(),S(An),de(()=>me(ro,To)),$(to,An)}),S(eo),S(Ji),$(pi,Ji)};ne(ev,pi=>{h(s).orphanAssets.length>0&&pi(xf)})}S(_n),$(ln,_n)};ne(ua,ln=>{h(s)&&(h(s).missingReferences.length>0||h(s).orphanAssets.length>0)&&ln(Es)})}$(yt,pr)};ne(vt,yt=>{h(i)&&yt(Pr)})}var jt=A(vt,2);{var $i=yt=>{var pr=Efe(),kr=I(pr);Rt(kr,{iconId:"check-circle",size:16});var Gn=A(kr,2),kt=I(Gn,!0);S(Gn),S(pr),de(()=>me(kt,h(oe))),$(yt,pr)};ne(jt,yt=>{h(f)&&yt($i)})}de(yt=>{me(Tn,` ${h(i).pkg.quickAddVersion??""}`),me(Ka,` ${yt??""}`),me(Jc,`${h(o).choiceConflicts.length??""} choice${h(o).choiceConflicts.length===1?"":"s"}`),me(k,`${h(i).pkg.assets.length??""} file${h(i).pkg.assets.length===1?"":"s"}`)},[()=>new Date(h(i).pkg.createdAt).toLocaleDateString()]),$(re,Ie)};ne(or,re=>{h(i)&&h(o)&&re(yr)})}var Pt=A(or,2);{var Ar=re=>{var Ie=Afe();let dr;var br=I(Ie),Tn=I(br);gr(Tn);var Ho=A(Tn,2),Ka=I(Ho,!0);S(Ho),S(br);var Xa=A(br,2);{var Jc=T=>{var k=_fe(),N=I(k);S(k),de(()=>me(N,`Open \u201CView contents\u201D on each of the ${h(V)??""} executable
script${h(V)===1?"":"s"} above to enable this.`)),$(T,k)};ne(Xa,T=>{h(V)>0&&!h(C)&&T(Jc)})}S(Ie),de(()=>{dr=wt(Ie,1,"ackGate svelte-1nd6fqb",null,dr,{critical:h(s)?.summary.hasCritical}),qd(Tn,h(a)),Tn.disabled=!h(C),ke(Tn,"aria-describedby",h(V)>0&&!h(C)?"qa-import-ack-hint":void 0),me(Ka,h(se))}),De("change",Tn,T=>Z(a,T.currentTarget.checked,!0)),$(re,Ie)};ne(Pt,re=>{h(i)&&h(x)&&!h(w)&&re(Ar)})}var ur=A(Pt,2),dt=I(ur),Ft=A(dt,2),Hn=I(Ft);{var xo=re=>{var Ie=cl("Importing\u2026");$(re,Ie)},xs=re=>{var Ie=cl("Close");$(re,Ie)},jn=re=>{var Ie=cl("Import package");$(re,Ie)};ne(Hn,re=>{h(d)?re(xo):h(w)?re(xs,1):re(jn,-1)})}S(Ft),S(ur),S(ye),de(()=>{dt.disabled=h(d),Ft.disabled=h(d)||!h(w)&&!h(P),ke(Ft,"title",!h(w)&&h(x)&&h(C)&&!h(a)?"Confirm the acknowledgement above to continue":void 0)}),De("input",He,Ne),co(He,()=>h(v),re=>Z(v,re)),De("click",dt,function(...re){e.close?.apply(this,re)}),De("click",Ft,function(...re){(h(w)?e.close:Qe)?.apply(this,re)}),$(r,ye),Ce()}Et(["input","click","change"]);var CS=class extends x4.Modal{constructor(t){super(t);this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageImportModal"),this.handle=qi(this.contentEl,CO,{app:this.app,close:()=>this.close()},{what:"the package importer"})}onClose(){this.handle?.destroy(),this.handle=null}};Tm();Wd();fc();function xO(r,e,t,n){let i=zr(r,"div"),o=zr(r,"strong");return o.textContent=e,i.appendChild(o),i.appendChild(jv(r,` ${t}`)),n?.className&&i.classList.add(n.className),i.classList.add("qa-dev-info-row"),r.appendChild(i),i}function E4(r,e){if(e.branch!==null&&xO(r,"Branch:",e.branch),e.commit!==null&&xO(r,"Commit:",e.commit),e.dirty!==null){let t=e.dirty?"Yes (uncommitted changes)":"No",n=e.dirty?"qa-dev-dirty-status":"qa-dev-clean-status";xO(r,"Uncommitted changes:",t,{className:n})}}Wt();var EO="Bundle or import QuickAdd automations as reusable packages.",xS=class extends od.PluginSettingTab{constructor(t,n){super(t,n);this.choiceViewHandle=null;this.globalVariablesViewHandle=null;this.packagesUnsubscribe=null;this.plugin=n,this.icon="zap"}getControlValue(t){let n=ce.getState();return t==="inputPrompt"?n.inputPrompt==="multi-line":n[t]}setControlValue(t,n){if(t==="inputPrompt"){ce.setState({inputPrompt:n?"multi-line":"single-line"});return}if(t==="persistInputPromptDrafts"){let i=!!n;ce.setState({persistInputPromptDrafts:i}),i||Gi.getInstance().clearAll();return}ce.setState({[t]:n})}getSettingDefinitions(){return[this.choicesAndPackagesGroup(),this.choicePickerGroup(),this.inputGroup(),this.templatesGroup(),this.notificationsGroup(),this.globalVariablesGroup(),this.aiAndOnlineGroup(),this.appearanceGroup()]}hide(){super.hide(),this.destroySettingViews()}destroySettingViews(){this.choiceViewHandle?.destroy(),this.choiceViewHandle=null,this.globalVariablesViewHandle?.destroy(),this.globalVariablesViewHandle=null,this.packagesUnsubscribe?.(),this.packagesUnsubscribe=null}choicesAndPackagesGroup(){return{type:"group",heading:"Choices & packages",extraButtons:[t=>t.setIcon("help-circle").setTooltip("QuickAdd documentation").onClick(()=>hj(Al.gettingStarted,t.extraSettingsEl))],items:[{name:"Choices",render:t=>this.renderChoicesView(t)},{name:"Packages",desc:EO,render:t=>this.renderPackages(t)}]}}choicePickerGroup(){return{type:"group",heading:"Choice picker",items:[{name:"Search nested choices",desc:"When searching in the choice picker, also match choices nested inside folders and show their path. Note that nested matches can outrank same-level ones. Disable to search only the open level.",control:{type:"toggle",key:"searchNestedChoices"}},{name:"\u201CNew note from template\u201D in the launcher",desc:"Add a row to Run QuickAdd that lists templates from your configured template folder, so you can create a note from a template without a dedicated Template choice. Only appears when a template folder is configured; the command palette entry works regardless.",control:{type:"dropdown",key:"templateFolderLauncherRow",defaultValue:"bottom",options:{bottom:"Show at the bottom (keeps your top choice first)",top:"Show at the top",of
2026-07-23 20:36:13 +08:00
tm = tomorrow
2026-08-02 09:03:32 +08:00
yd = yesterday`).setValue(s0(ce.getState().dateAliases)).onChange(o=>{ce.setState({dateAliases:O2(o)})}),i.inputEl.addClass("qa-date-alias-input")}),t.addButton(i=>{i.setButtonText("Reset to defaults").onClick(()=>{ce.setState({dateAliases:Kf}),n?.setValue(s0(Kf))}),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=()=>Wi(ce.getState().templateFolderPaths),s=p=>{ce.setState({templateFolderPaths:p})},a=()=>{i.empty();let p=o();if(p.length===0){i.createDiv({cls:"qa-template-folder-empty",text:"No folders added yet."});return}for(let m of p){let v=i.createDiv("qa-template-folder-row");v.createSpan({cls:"qa-template-folder-name",text:m,attr:{title:m}}),new od.ExtraButtonComponent(v).setIcon("trash-2").setTooltip(`Remove ${m}`).onClick(()=>{s(o().filter(g=>g!==m)),a()})}},l=n.createDiv("qa-template-folder-input-row"),c=new od.TextComponent(l);c.setPlaceholder("templates/"),c.inputEl.addClass("qa-template-folder-input");let u=new ni(this.app,c.inputEl,Nc(Ns(this.app)).filter(p=>p!=="/")),d=()=>{let[p]=Wi([c.inputEl.value]);if(c.inputEl.value="",!p)return;let m=o();m.includes(p)||(s([...m,p]),a())},f=p=>{p.key==="Enter"&&(p.preventDefault(),d())};return c.inputEl.addEventListener("keydown",f),new od.ButtonComponent(l).setCta().setButtonText("Add").onClick(()=>d()),a(),()=>{c.inputEl.removeEventListener("keydown",f),u.destroy()}}renderDevInfo(t){let n=t.settingEl.createDiv();n.addClass("qa-dev-info"),E4(n,{branch:null,commit:null,dirty:null})}};a0();Me();CT();var cg=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}}};Cr();var kx=class extends cg{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),i?console.log(this.formatOutputString(o),i):console.log(this.formatOutputString(o))}addMessageToErrorLog(t){this.ErrorLog.push(t),this.ErrorLog.length>v0&&(this.ErrorLog=this.ErrorLog.slice(-v0))}clearErrorLog(){this.ErrorLog=[]}};var TO=require("obsidian");CT();var ES=class extends cg{constructor(t){super();this.plugin=t}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);new TO.Notice(this.formatOutputString(o),15e3)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);new TO.Notice(this.formatOutputString(o))}logMessage(t,n,i){}};Me();Cr();Cr();var T4=1e4,_4=50,Dfe=/plugin:([^\s:)]+)/;function Ife(r){let e=r.stack??"",t=`${r.name}: ${r.message}`;return(e.startsWith(t)?e.slice(t.length):e).split(`
`)}function Pfe(r){for(let e of Ife(r)){let t=Dfe.exec(e);if(t)return{pluginId:t[1],frame:e.trim()}}return null}function Ffe(r,e){return`${r.name}@${e}`}function A4(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?Pfe(o):null;if(s?.pluginId!==t)return;if(Dt(o)){i.preventDefault();return}let a=o,l=Ffe(a,s.frame),c=e(),u=n.get(l);if(n.set(l,c),!(u!==void 0&&c-u<T4)){if(n.size>=_4){for(let[d,f]of n)c-f>=T4&&n.delete(d);if(n.size>=_4){let d=n.keys().next();!d.done&&d.value!==l&&n.delete(d.value)}}lt(a,"A QuickAdd action failed")&&i.preventDefault()}})}var k4=require("obsidian");Me();function Mfe(r,e){try{let t=r.setting;return!t?.open||!t?.openTabById?(F.logMessage("QuickAdd: Obsidian internal settings API is unavailable."),!1):(t.open(),t.openTabById(e),!0)}catch(t){return F.logMessage(`QuickAdd: Failed to open plugin settings automatically: ${t}`),!1}}function ug(r,e,t){let n=Mfe(r,e);return!n&&t?.notice!==!1&&new k4.Notice("QuickAdd: Unable to open settings automatically. Open Settings \u2192 QuickAdd manually."),n}Zx();Wt();Cr();var DD=class{constructor(e,t,n,i){this.app=e;this.plugin=t;this.choices=n;this.choiceExecutor=i}async run(){let e=Bn(this.choices).filter(t=>t.type==="Macro"&&t.runOnStartup);for(let t of e)try{await new ql(this.app,this.plugin,t,this.choiceExecutor,new Map).run()}catch(n){lt(n,`Startup macro '${t.name}' failed`)}}};var HK=require("obsidian");var Yg=require("obsidian");Sx();Tt();Wc();Me();var cK=require("obsidian");nd();$g();Og();Co();var lK=require("obsidian");Hs();Fo();function dE(r,e,t){let n=e.lastIndexOf("/"),i=n>=0?e.slice(0,n):"",o=sy(n>=0?e.slice(n+1):e),s=t?.vault.getAbstractFileByPath(e),a=t&&s instanceof lK.TFile?OP([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})}function hf(r,e={}){let{openedAtOf:t,recentRankOf:n,isExcluded:i}=e;return r.map(o=>({file:o,name:o.basename||o.path,excluded:i?.(o.path)??!1,openedAt:t?.(o.path),recentRank:n?.(o.path)})).sort((o,s)=>{if(o.excluded!==s.excluded)return o.excluded?1:-1;let a=o.openedAt!=null,l=s.openedAt!=null;if(a!==l)return a?-1:1;if(a&&l&&o.openedAt!==s.openedAt)return s.openedAt-o.openedAt;let c=o.recentRank??Number.POSITIVE_INFINITY,u=s.recentRank??Number.POSITIVE_INFINITY;return c!==u?c-u:o.name.localeCompare(s.name)}).map(o=>o.file)}AP();function gf(r){let e=r.workspace?.getLastOpenFiles?.(),t=Array.isArray(e)?e:[],n=new Map;t.forEach((s,a)=>{n.has(s)||n.set(s,a)});let i;try{i=Cm.getInstanceIfExists()}catch{i=void 0}let o=r.metadataCache;return{openedAtOf:s=>i?.getLastOpenedAt(s),recentRankOf:s=>n.get(s),isExcluded:s=>o?.isUserIgnored?.(s)??!1}}Cr();Wr();Tl();Ec();var aN="@quickadd-existing-note:",lN="@quickadd-unresolved-note:";function Rve(r){return`${aN}${r}`}function $ve(r){return`${lN}${r}`}function Ove(r){return r.startsWith(aN)}function Nve(r){return r.startsWith(lN)}function Lve(r){return r.slice(aN.length)}function Bve(r){return r.slice(lN.length)}function vf(r){return r.trim().replace(/\.md$/i,"").toLowerCase()}function uK(r){return r.trim().replace(/^\/+/,"")}function Uve(r){return r.trim().length>0&&!r.includes("{{")}function Vve(r){if(!Uve(r.templatePath))return new Set;let e=uK(r.templatePath),t=/\.md$/i.test(e)?e:`${e}.md`;return new Set([t.toLowerCase()])}function qve(r,e,t){let n=e.replace(/\.md$/i,"");r.add(vf(e)),r.add(vf(n)),r.add(vf(t))}function Wve(r,e){let t=r.metadataCache.getFileCache(e)?.frontmatter;if(!t)return[];let n=[];for(let[i,o]of Object.entries(t)){let s=i.toLowerCase();s!=="alias"&&s!=="aliases"||(typeof o=="string"?n.push(...o.split(",").map(a=>a.trim()).filter(Boolean)):Array.isArray(o)&&n.push(...o.filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean)))}return n}function zve(r){let n=((r.split("|")[0]?.trim()??"").split("#")[0]?.trim()??"").replace(/\.md$/i,"").trim();return!n||n==="/"||Un(n)?null:n}function Hve(r){
2026-07-23 20:36:13 +08:00
`)}}).join(`
2026-08-02 09:03:32 +08:00
`)}}var mK=r=>r.join(""),Kve=r=>r.split(/\b/),Xve=fK("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",mK),Qve={splitFunction:Kve,joinFunction:mK,conflictFunction:Xve};function mN(r,e,t,n={}){n=Object.assign({},Qve,n);let[i,o,s]=[r,e,t].map(c=>n.splitFunction.call(n,c)),a=mE.merge(i,o,s);return hE.collateMerge(a,n.joinFunction,n.conflictFunction)}var hK=mN;Tt();Cu();kD();Tt();qt();Co();Lg();function gK(r,e){return r.line===e.line}function Qc(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 vd(r,e,t=!1){let n=Qc(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=vK(r,e,u=>u.trim()==="");return c!==null&&c>e?c-1:e}let s=r.length-1,a=Zve(i,n,r,t),l=tye(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 Zve(r,e,t,n){let i=e.findIndex(u=>gK(u,r)),o=i===e.length-1,s=t.length-1;if(o)return s;let[a,l]=Jve(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=eye(r.line,e);return u===null?s:u}return s}function Jve(r,e){let t=e.findIndex(i=>gK(i,r)),n=vK(e,t,i=>i.level<=r.level);return n===null?[-1,!1]:[n,!0]}function eye(r,e){let t=e.find(n=>n.line>r);return t?t.line:null}function tye(r,e,t){for(let n=e-1;n>=0;n--)if(t(r[n]))return n;return null}function vK(r,e,t){for(let n=e+1;n<r.length;n++)if(t(r[n]))return n;return null}var rye="\u200B";function gE(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${rye}$2`),s&&s[2][0]===n&&s[2].length>=i&&r[o].slice(s[1].length+s[2].length).trim()===""&&(t=!1,n="",i=0)}return e}function yK(r){return(r.match(/^#+\s+(.*)$/)?.[1]??"").trim()}function nye(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 bK(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 nye(r);default:return{value:0,parsed:!0}}}function iye(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 wK(r,e,t,n,i,o=0){let s=gE(r),a=Qc(s).filter(f=>f.line>=o),l=a.filter(f=>f.level===t),c=bK(yK(e),n,i);if(l.length===0){let f=a.filter(p=>p.level<t).pop();return f?{mode:"after",line:vd(s,f.line,!0)}:{mode:"bodyStart"}}let u=()=>{let f=l[l.length-1];return{mode:"after",line:vd(s,f.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 f of l){let p=bK(yK(s[f.line]),n,i),m;if(!p.parsed)m=d==="bottom";else{let v=iye(c,p);m=n.direction==="desc"?v>0:v<0}if(m)return{mode:"before",line:f.line}}return u()}oE();function hN(r){let e=r.split(`
`);for(;e.length>1&&e[e.length-1].trim()==="";)e.pop();return e}function gN(r){return r.length===0||r.length===1&&r[0].trim()===""}function vN(r,e){if(e.length<=1){let t=oye(r,e[0]??"");return{start:t,end:t}}return sye(r,e)}function oye(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 sye(r,e){let t=e.length,n=e.map(i=>CK(i));for(let i=0;i+t<=r.length;i++){let o=!0;for(let s=0;s<t;s++)if(CK(r[i+s])!==n[s]){o=!1;break}if(o)return{start:i,end:i+t-1}}return{start:-1,end:-1}}function CK(r){return r.trimEnd()}function xK(r,e,t){return r?Qc([e[t]??""]).length>0:!1}function aye(r,e){return r==="skip"?!0:r==="none"?!1:lye(e)}function lye(r){return/^\s{0,3}#{1,6}\s+\S/.test(r)}function yN(r,e,t,n){if(e<0)return e;let i=r[e]??"";if(!aye(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 OD(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 EK(r){return r.includes(`
`)||r.includes("\r")}function TK(r,e){let t=r.indexOf(`
`,e);return t===-1?r.length:t>0&&r[t-1]==="\r"?t-1:t}function bN(r){let e=X1(r);return e>0?r.slice(0,e).split(`
`).length-1:0}function _K(r,e){let t=bN(e),n=r.map((i,o)=>o<t?"":i);return gE(n).map(i=>i.replace(/\r$/,""))}function AK(r,e,t,n){let i=e.split(`
`),o=i.slice(0,t+1).join(`
`),s=i.slice(t+1).join(`
`),l=(i[t+1]??"").trim(),c=e.endsWith(`
`)&&t+1===i.length-1,u=t+1<i.length&&!c&&l==="",d=n&&r.endsWith(`
`)&&u?r.slice(0,-1):r,f=!d.endsWith(`
`)&&l!==""?`
`:"";return{content:`${o}
${d}${f}${s}`,insertedEndOffset:o.length+1+d.length}}function kK(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 SK(r,e,t,n){let i=n,o=i.includes(`\r
`)?`\r
`:`
`,s=e.mode==="before"?e.line:e.line+1,a=0;for(let w=0;w<s&&w<r.length;w++)a+=r[w].length+1;a>i.length&&(a=i.length);let l=i.slice(0,a),c=i.slice(a),u=s>0?(r[s-1]??"").replace(/\r$/,""):"",d=s<r.length?(r[s]??"").replace(/\r$/,""):"",f=t.split(`
`).map(w=>w.replace(/\r$/,""));f.length>1&&f[f.length-1]===""&&f.pop();let p=[];s>0&&u.trim()!==""&&p.push(""),p.push(...f),s<r.length&&d.trim()!==""&&p.push("");let m=p.join(o),v=l.length>0&&!/\n$/.test(l)?o:"",g=c.length>0||/\n$/.test(i)?o:"",y=l.length+v.length;return{content:`${l}${v}${m}${g}${c}`,insertedEndOffset:y+m.length}}oE();Rg();MP();var uye=/^[ \t\r\n\f\v]*$/;function DK(r){return uye.test(r)}var ND=class extends ws{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;this.captureInsertionEndOffset=null}setDestinationFile(t){this.file=t,this.sourcePath=t.path,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(Wo(t.path)),this.setPromptRunContext({destination:t.path,destinationKind:"file"})}setDestinationSourcePath(t){this.sourcePath=t,this.file=null,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(Wo(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}getCaptureInsertionEndOffset(){return this.captureInsertionEndOffset}setCaptureInsertionEndOffset(t){this.captureInsertionEndOffset=typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null}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 p_(this.app,i,n.mimeType,o);return this.createdClipboardAttachmentPaths.push(s.path),f_(this.app,s,o)}async getFirstClipboardImageItem(t){let n=await t.read();for(let i of n){let o=i.types.find(s=>dy[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.setCaptureInsertionEndOffset(null),this.choice=n,this.file=o,this.fileContent=i,!n||!o||i===null)return t;this.setTargetFolderPath(Wo(o.path));let s=n.insertAfter.enabled||!!n.insertBefore?.enabled||n.prepend||!n.captureToActiveFile||n.activeFileWritePosition==="top"||n.activeFileWritePosition==="bottom";return await this.formatFileContent(t,s)}async formatContent(t,n){return this.choice=n,n?await this.formatFileContent(t):t}async formatFileContent(t,n=!0){let i=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));if(n&&this.file&&!this.templaterProcessed){let a=await pc(this.app,i,this.file);a&&(i=a),this.templaterProcessed=!0}if(DK(i))return this.fileContent;if(this.choice.prepend||this.choice.captureToActiveFile&&this.choice.activeFileWrite
`)&&!i.startsWith(`
`),c=a||l?`
`:"";return this.setCaptureInsertionEndOffset(this.fileContent.length+c.length+i.length),`${this.fileContent}${c}${i}`}return this.choice.insertAfter.enabled?await this.insertAfterHandler(i):this.choice.insertBefore?.enabled?await this.insertBeforeHandler(i):this.insertAtNoteBodyStartTracking(i)}async formatContentOnly(t){let n=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));return DK(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=this.insertAfterTargetOverride;if(this.choice.insertAfter?.inline&&n===null){let f=await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));return await this.insertAfterInlineHandler(t,f)}let i=n??await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));if(n===null){let f=i.split(`
`,1)[0];this.lastResolvedInsertAfterHeading=/^#+\s+\S/.test(f)?f.trim():null}let o=hN(i);if(gN(o))throw new Ee("Insert-after target is empty after formatting.");let s=mf(this.fileContent),a=this.isOrderedCreate()?_K(s,this.fileContent):s,{start:l,end:c}=vN(a,o);if(l===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(t,i);throw new Ee(`Insert-after target not found: '${i}'.`)}let d;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let f=vd(s,l,this.considerSubsectionsForAnchor(s,l)),p=Math.max(f??s.length-1,c);d=OD(s,p,this.fileContent,t)}else{let f=this.choice.insertAfter?.blankLineAfterMatchMode??"auto";d=yN(s,c,this.fileContent,f)}return this.insertTextAfterPositionInBody(t,this.fileContent,d)}async insertBeforeHandler(t){let n=this.choice.insertBefore;if(!n)throw new Ee("Insert-before settings are missing.");let i=await this.formatLocationString(await this.expandFormatTemplateEscapes(n.before)),o=hN(i);if(gN(o))throw new Ee("Insert-before target is empty after formatting.");let s=mf(this.fileContent),{start:a}=vN(s,o);if(a===-1){if(n.createIfNotFound)return await this.createInsertBeforeIfNotFound(t,i);throw new Ee(`Insert-before target not found: '${i}'.`)}return this.insertTextBeforePositionInBody(t,this.fileContent,a)}async insertAfterInlineHandler(t,n){if(EK(n))throw new Ee("Inline insert-after target must be a single line \u2014 remove the line break (\\n) or turn off inline insertion.");let i=this.fileContent.indexOf(n);if(i===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInlineInsertAfterIfNotFound(t,n);throw new Ee(`Inline insert-after target not found: '${n}'.`)}let o=i+n.length;if(this.setCaptureInsertionEndOffset(o+t.length),this.choice.insertAfter?.replaceExisting){let s=TK(this.fileContent,o);return this.fileContent.slice(0,o)+t+this.fileContent.slice(s)}return this.fileContent.slice(0,o)+t+this.fileContent.slice(o)}async createInsertAfterIfNotFound(t,n){let i=`${n}
${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===uo)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===lc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===cc){let o=On(this.app);if(!o)throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position: no active markdown editor.`);try{let a=o.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let c=mf(this.fileContent),u=vd(c,a,this.considerSubsectionsForAnchor(c,a));a=OD(c,u??c.length-1,this.fileContent,i)}return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position.`)}}if(this.choice.insertAfter?.createIfNotFoundLocation===_a)return this.createInsertAfterOrdered(t,n);throw new Ee(`Unknown createIfNotFoundLocation: ${this.choice.insertAfter?.createIfNotFoundLocation}`)}isOrderedCreate(){return!!this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation===_a}considerSubsectionsForAnchor(t,n){return xK(!!this.choice.insertAfter?.considerSubsections,t,n)}createInsertAfterOrdered(t,n){let i=this.choice.insertAfter?.orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"},o=n.split(/\r?\n/,1)[0],s=Qc([o])[0]?.level??0,a=`${n}
${t}`;if(s===0)return this.insertAtNoteBodyStartTracking(a);let l=mf(this.fileContent),c=l.map(g=>g.replace(/\r$/,"")),u=bN(this.fileContent),d=gE(c),f=o.replace(/\r$/,"").trimEnd(),p=d.findIndex((g,y)=>y>=u&&g.trimEnd()===f);if(p!==-1){let g=this.choice.insertAfter?.insertAtEnd?OD(d,vd(d,p,this.considerSubsectionsForAnchor(d,p))??d.length-1,this.fileContent,t):yN(d,p,this.fileContent,this.choice.insertAfter?.blankLineAfterMatchMode??"auto");return this.insertTextAfterPositionInBody(t,this.fileContent,g)}let m=typeof window<"u"?window.moment:void 0,v=wK(c,o,s,i,m,u);return v.mode==="bodyStart"?this.insertAtNoteBodyStartTracking(a):this.spliceOrderedSection(l,v,a)}spliceOrderedSection(t,n,i){let{content:o,insertedEndOffset:s}=SK(t,n,i,this.fileContent);return this.setCaptureInsertionEndOffset(s),o}async createInsertBeforeIfNotFound(t,n){let i=this.choice.insertBefore;if(!i)throw new Ee("Insert-before settings are missing.");let o=t.endsWith(`
`)||t.length===0?`${t}${n}`:`${t}
${n}`;if(i.createIfNotFoundLocation===uo)return this.insertAtNoteBodyStartTracking(o,t.length);if(i.createIfNotFoundLocation===lc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+t.length),`${this.fileContent}
${o}`;if(i.createIfNotFoundLocation===cc){let s=On(this.app);if(!s)throw new Ee(`Unable to insert line '${i.before}' at cursor position: no active markdown editor.`);try{let a=s.editor.getCursor();return this.insertTextBeforePositionInBody(o,this.fileContent,a.line,t.length)}catch{throw new Ee(`Unable to insert line '${i.before}' at cursor position.`)}}throw new Ee(`Unknown createIfNotFoundLocation: ${i.createIfNotFoundLocation}`)}async createInlineInsertAfterIfNotFound(t,n){let i=`${n}${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===uo)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===lc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===cc){let o=On(this.app);if(!o)throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position: no active markdown editor.`);try{let a=o.editor.getCursor().line;return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position.`)}}throw new Ee(`Unknown createIfNotFoundLocation: ${this.choice.insertAfter?.createIfNotFoundLocation}`)}insertAtNoteBodyStartTracking(t,n=t.length){let i=Q1(this.fileContent,t);if(i.insertedStartOffset===null)return this.setCaptureInsertionEndOffset(null),i.content;let o=Math.max(0,Math.min(n,t.length));return this.setCaptureInsertionEndOffset(i.insertedStartOffset+o),i.content}insertTextAfterPositionInBody(t,n,i){let{content:o,insertedEndOffset:s}=AK(t,n,i,!!this.choice.task);return this.setCaptureInsertionEndOffset(s),o}insertTextBeforePositionInBody(t,n,i,o=t.length){let{content:s,insertedEndOffset:a}=kK(t,n,i,o);return this.setCaptureInsertionEndOffset(a),s}};kD();Me();Jd();qt();Cr();$g();Og();var IK=require("obsidian");Tt();Co();Tl();function PK(r,e){let t=r.trim().replace(/^\/+/,"");if(t==="")return{kind:"vault"};let n=vh(t);if(n){if(!n.field)throw new Ee("Property capture target needs a field name, e.g. property:type=draft");return{kind:"property",field:n.field,value:n.value,filter:n.filter}}let i=gh(t);if(i){if(i.multiSelect)throw new Ee("Capture target filters select one destination file. Use {{FILE:...|multi}} in the capture format for multi-value metadata.");return{kind:"filter",filter:i.filter}}let o=ai(t,"Capture target file path");if(Vi.test(o))throw new Ee(`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(ir.test(o)||qr.test(o))return{kind:"file",path:o};let l=e.normalizeMarkdownFilePath("",a),u=e.getAbstractFileByPath(l)instanceof IK.TFile;return e.isFolder(a)&&!u?{kind:"folder",folder:a}:{kind:"file",path:o}}Tt();function LD(r){return`${r.replace(/^\/+/,"").replace(ir,"")}.md`}function BD(r,e,t){if(t)return null;let n=(e??"").trim().replace(/^\/+/,"");if(_u(n))return null;let i=vh(n),o=!!i&&!!i.field,s=o?null:gh(n),a=!!s&&!s.multiSelect,l=!o&&!s&&n.startsWith("#"),c=n.endsWith("/"),u=!l&&!o&&!a&&!c&&(ir.test(n)||qr.test(n)||Vi.test(n)),d=n.replace(/\/+$/,""),f=!l&&!o&&!a&&!u&&(n===""||r.isFolder(d)&&!r.markdownFileExists(d)),p=!o&&!a&&c;if(o&&i)return{kind:"property",field:i.field,value:i.value,filter:i.filter};if(a&&s)return{kind:"filter",filter:s.filter};if(l)return{kind:"tag",tag:n};if(f||p){let m=d;return{kind:"folder",folderPathSlash:m===""?"":`${m}/`}}return null}Hv();Tl();Ec();Tm();nm();Rg();Hs();sN();aD();Co();lD();H1();function FK(r){let e=r.insertAfter.enabled||!!r.insertBefore?.enabled;return r.captureToActiveFile&&!e&&r.newLineCapture?.enabled?r.newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":r.captureToActiveFile&&!e?r.activeFileWritePosition==="top"?"activeFileTop":r.activeFileWritePosition==="bottom"||r.prepend?"append":"currentLine":r.insertAfter.enabled?"insertAfter":r.insertBefore?.enabled?"insertBefore":r.prepend?"prepend":"append"}Tt();Co();function wN(r){return r?.type==="text"?"text":r?.type==="file"||r?.file?"file":typeof r?.text=="string"?"text":"unsupported"}function dye(r,e){let t=e.id;if(!t)return null;let n=r.getData?.();return n?.nodes?.length?n.nodes.find(i=>i.id===t)??null:null}function MK(r,e){if(r==="text"){if(e==="currentLine")return"Canvas capture does not support 'At cursor' for text cards. Use top, bottom, insert-after, or insert-before placement.";if(e==="newLineAbove"||e==="newLineBelow")return"Canvas capture does not support 'New line above/below cursor' for text cards. Use top, bottom, insert-after, or insert-before placement."}return r==="file"&&(e==="currentLine"||e==="newLineAbove"||e==="newLineBelow")?"Canvas file cards do not support cursor-based capture modes. Use top, bottom, insert-after, or insert-before modes.":null}fun
`),t}async getFormattedPathToCaptureTo(t){if(t){let a=this.app.workspace.getActiveFile();return Mi(a,"Cannot capture to active file - no active file."),a.path}let n=this.getPreselectedCaptureTargetPath();if(n!==void 0){let a=BD({isFolder:l=>om(this.app,l),markdownFileExists:l=>this.app.vault.getAbstractFileByPath(LD(l))instanceof Zc.TFile},this.choice.captureTo??"",!1);if(a){let l=this.confinePreselectedToScope(a,n);if(l!==null)return this.normalizeCaptureFilePath(l)}}let i=this.choice.captureTo,o=await this.formatter.formatFileName(i,"captureTarget"),s=this.resolveCaptureTarget(o);switch(s.kind){case"vault":return this.selectFileInFolder("",!0);case"filter":return this.selectFileWithFilter(s.filter);case"property":return this.selectFileWithProperty(s.field,s.value,s.filter);case"folder":return this.selectFileInFolder(s.folder,!1);case"file":return this.normalizeCaptureFilePath(s.path)}}getPreselectedCaptureTargetPath(){let t=this.choiceExecutor?.variables?.get(Gd);return typeof t=="string"&&t.length>0?t:void 0}confinePreselectedToScope(t,n){let i=this.stripLeadingSlash(n);if(t.kind==="folder")return t.folderPathSlash&&!i.startsWith(t.folderPathSlash)?`${t.folderPathSlash}${i}`:i;if(this.resolveScopeFiles(t).some(l=>l.path===i))return i;if(!(this.choice.createFileIfItDoesntExist?.enabled??!1))return null;let a=new Set(this.app.vault.getMarkdownFiles().map(l=>l.basename.toLowerCase()));return this.captureTargetAlreadyExists(i,a)?null:i}resolveScopeFiles(t){switch(t.kind){case"filter":return sm(this.app,t.filter);case"property":return am(this.app,t.field,t.value,t.filter);case"tag":return Xv(this.app,t.tag);case"folder":return rs(this.app,t.folderPathSlash)}}resolveCaptureTarget(t){return PK(t,{getAbstractFileByPath:n=>this.app.vault.getAbstractFileByPath(n),isFolder:n=>om(this.app,n),normalizeMarkdownFilePath:(n,i)=>this.normalizeMarkdownFilePath(n,i)})}captureTargetExists(t,n){let i=n.startsWith(t)?n:`${t}${n}`,o;try{o=ai(i,"Capture target file path")}catch{return!1}let s=[o];return/\.(md|canvas)$/i.test(o)||s.push(`${o}.md`,`${o}.canvas`),s.some(a=>!!this.app.vault.getAbstractFileByPath(a))}async selectFileInFolder(t,n){let i=t.endsWith("/")||n?t:`${t}/`,o=rs(this.app,i),s=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(s||o.length>0,`Folder ${i} is empty.`);let a=hf(o,gf(this.app)),l=a.map(v=>v.path),c=Tc(a,v=>this.app.metadataCache.getFileCache(v)),u=l.map((v,g)=>`${c[g]??v} ${v}`),d=new Set(c.map(v=>v.toLowerCase())),f=s?"Choose a note or type to create one":void 0,p=String(await ia(this.choiceExecutor,{remote:v=>oa(v,{items:l.map((g,y)=>({value:g,title:c[y]??g})),placeholder:f,allowCustomInput:s,what:"the capture-target picker"}),headless:()=>{throw this.assertInteractiveCaptureTarget(),new Error("unreachable")},app:()=>an.Suggest(this.app,c,l,{placeholder:f,emptyStateText:s?"Type a note name to create it":void 0,renderItem:(v,g)=>dE(g,v,this.app),searchItems:u,allowCustomValue:s,customValueLabel:v=>`Create new note: ${v}`,valueExists:v=>d.has(v.toLowerCase())||this.captureTargetExists(i,v)})}));Mi(!!p&&p.length>0,"No file selected for capture.");let m=p.startsWith(`${i}`)?p:`${i}${p}`;return await this.formatFilePath(m)}async selectFileWithFilter(t){let n=sm(this.app,t);return this.selectFileFromSet(n,"No files matched the capture target filters.")}async selectFileWithProperty(t,n,i){let o=am(this.app,t,n,i),s=n!==void 0?`${t}=${n}`:t;return this.selectFileFromSet(o,`No notes with property ${s}.`)}captureTargetAlreadyExists(t,n){let i=t.trim();if(!i)return!1;let o;try{o=ai(i,"Capture target file path")}catch{return!1}let s=o.replace(/\.(md|canvas)$/i,"");if([o,`${s}.md`,`${s}.canvas`].some(c=>!!this.app.vault.getAbstractFileByPath(c)))return!0;let l=s.slice(s.lastIndexOf("/")+1);return n.has(l.toLowerCase())}async selectFileFromSet(t,n){let i=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(i||t.length>0,n);let o=hf(t,gf(this.app)),s=o.map(m=>m.path),a=Tc(o,m=>this.app.metadataCache.getFileCache(m)),l=s.map((m,v)=>`${a[v]??m} ${m}`),c=new Set(this.app.vault.getMarkdownFiles().map(m=>m.basename.toLowerCa
2026-07-23 20:36:13 +08:00
QuickAdd could not merge the versions two without conflicts, and will not modify the file.
2026-08-02 09:03:32 +08:00
This is in order to prevent data loss.`),u=f.joinedResults(),d=!1}return{file:i,newFileContent:u,captureContent:o,priorContent:c,cursorEndOffset:l??void 0,cursorPlacementSafe:d}}async onCreateFileIfItDoesntExist(t,n,i){eE(t);let o=Mg(t);this.formatter.setTitle(o),this.formatter.setDestinationSourcePath(t);let s=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let a="";if(this.choice.createFileIfItDoesntExist.createWithTemplate){let f=new tE(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);i?.enabled&&!i.requireActiveFile&&f.setLinkToCurrentFileBehavior("optional"),f.setTargetFolderPath(Wo(t)),f.setPromptRunContext({draftScopeId:`${this.choice.id}#${this.choice.createFileIfItDoesntExist.template}`,choiceName:this.choice.name,destination:t,destinationKind:"file"}),a=await f.run();let p=f.getAndClearTemplatePropertyVars();F.logMessage(`CaptureChoiceEngine: Collected ${p.size} template property variables`),p.size>0&&F.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&&Pg(l,this.templatePropertyVars)&&await Fg(this.app,l,this.templatePropertyVars),this.choice.createFileIfItDoesntExist.createWithTemplate&&a?await Xd(this.app,l):qv(this.app)&&await T0(this.app,l);let c=await this.app.vault.read(l),u=await this.collectIfFrontmatter(()=>this.formatter.formatContentWithFile(s,this.choice,c,l));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let d=this.formatter.getCaptureInsertionEndOffset();return{file:l,newFileContent:u,captureContent:s,priorContent:c,cursorEndOffset:d??void 0,cursorPlacementSafe:!0}}async formatFilePath(t){let n=await this.formatter.formatFileName(t,"captureTarget");return this.normalizeCaptureFilePath(n)}normalizeCaptureFilePath(t){let n=ai(this.stripLeadingSlash(t),"Capture target file path");if(Vi.test(n))throw new Ee(`Capture to '.base' files is not supported (${n}). Use a Template choice instead.`);let i=this.normalizeCaptureFilePathExtension(n);if(!Mg(i).trim())throw new Ee(`Capture target file name is empty after formatting ('${i}'). Make sure the tokens in 'Capture to' produce a value.`);if(Un(i))throw new Ee(`Refusing to capture to a file outside the vault: "${i}".`);return i}normalizeCaptureFilePathExtension(t){let n=t.match(ir)?.[0];if(n)return`${ai(t.replace(ir,""),"Capture target file path")}${n}`;let i=t.match(qr)?.[0];return i?`${ai(t.replace(qr,""),"Capture target file path")}${i}`:this.normalizeMarkdownFilePath("",t)}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);F.logMessage(`CaptureChoiceEngine: Accumulated ${this.capturePropertyVars.size} structured capture variables`)}}async applyCapturePropertyVars(t){return this.capturePropertyVars.size===0?!1:Pg(t,this.capturePropertyVars)?(F.logMessage(`CaptureChoiceEngine: Post-processing front matter with ${this.capturePropertyVars.size} capture variables`),await Fg(this.app,t,this.capturePropertyVars),this.capturePropertyVars.clear(),!0):(this.capturePropertyVars.clear(),!1)}};Zx();var Cs=require("obsidian");Fo();Cr();Wr();It();Wt();nm();var xN=require("obsidian");Tt();Wc();qt();Cr();function BK(r){let e=r.split("/").pop()??r,t=e.lastIndexOf(".");return t>0?e.slice(0,t):e}function EN(r){let e=new rd(BK(r));return e.id=`folder-template:${r}`,e.templatePath=r,e.openFile=!0,e.fileNameFormat={enabled:!0,format:Ms},e.discoverExistingNotesBeforeCreate=!0,e}function TN(r){return Wi(r.settings.templateFolderPaths).length>0}function Cye(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
2026-07-23 20:36:13 +08:00
2026-08-02 09:03:32 +08:00
${o}
2026-07-23 20:36:13 +08:00
2026-08-02 09:03:32 +08:00
QuickAdd will now revert to backup.`),r.settings=n,ce.replaceState(ht(r.settings))}}r.saveSettings()}var p7=mbe;It();var Hl=require("obsidian");Me();async function hbe(r,e,t){let n=await(0,Hl.requestUrl)({url:`https://api.github.com/repos/${r}/${e}/releases`,throw:!1}),i=n.json;if(n.status>=400||!Array.isArray(i)){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 IN=/^https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+$/,f7=/^\[!\[[^\]]*\]\(([^)\s"]+)\)\]\((https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+)\)$/,gbe=/^<!--\s*poster:\s*(https:\/\/[^\s"'>]+)\s*-->$/;function vbe(r,e){let t=e?` poster="${e}"`:"";return`<video controls preload="metadata" playsinline style="width: 100%; border-radius: 8px;" src="${r}"${t}></video>`}function ybe(r){let e=r.split(`
`),t=new Set;for(let s of e){let a=s.trim();IN.test(a)&&t.add(a)}let n=new Map;for(let s of e){let a=s.trim().match(f7);a&&t.has(a[2])&&n.set(a[2],a[1])}let i=new Set;for(let s=0;s<e.length;s++)if(IN.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(gbe):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(f7);if(!(c&&t.has(c[2]))){if(IN.test(l)){o.push(vbe(l,n.get(l)));continue}o.push(a)}}return o.join(`
`)}function bbe(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 YD=class extends Hl.Modal{constructor(t,n){super(t);this.markdownComponent=new Hl.Component;this.isClosed=!1;this.previousVersion=n,this.releaseNotesPromise=hbe("chhoumann","quickadd",n),this.releaseNotesPromise.then(i=>{if(!this.isClosed){if(this.releases=i,this.releases.length===0){this.close();return}this.display()}}).catch(i=>{F.logError(`Failed to fetch release notes: ${i}`)})}onOpen(){let{contentEl:t}=this;t.empty(),t.createEl("h1",{text:"Fetching release notes..."}),this.addCloseFooter()}addCloseFooter(){let t=this.contentEl.createDiv("quickadd-update-modal-footer");new Hl.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=>ybe(d.body??"")).join(`
2026-07-23 20:36:13 +08:00
---
2026-08-02 09:03:32 +08:00
`),l=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,u=`${n}
${i}
${o}
2026-07-23 20:36:13 +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.
2026-08-02 09:03:32 +08:00
${l}
2026-07-23 20:36:13 +08:00
---
2026-08-02 09:03:32 +08:00
${bbe(a)}`;this.markdownComponent.load(),Hl.MarkdownRenderer.render(this.app,u,s,this.app.vault.getRoot().path,this.markdownComponent),this.addCloseFooter()}};nD();Wr();Co();var wbe=25e3,Cbe=6e4,xbe=3e4,Ebe=75e3,Tbe=32;function _be(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 Abe(r){if(r.origin||r.referer)return!1;let e=(r.host??"").split(":")[0];return e==="127.0.0.1"||e==="localhost"}function kbe(r){try{let e=window.require;return e?e(r):null}catch{return null}}function KD(){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 XD="No pending prompt for that requestId",PN="The interactive client disconnected, so the run was ended.";function Sbe(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(!(t===!0||t===!1||t==="true"||t==="false"))return`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${Dbe(t)}.`}return null}function Dbe(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}var FN=class{constructor(){this.server=null;this.port=0;this.sessions=new Map;this.startPromise=null;this.generation=0}async ensureStarted(){if(this.server)return this.port;if(this.startPromise)return this.startPromise;let e=kbe("http");if(!e)throw new Error("Interactive prompts require desktop Obsidian (Node http is unavailable).");let t=this.generation;return this.startPromise=new Promise((n,i)=>{let o=e.createServer((s,a)=>{this.handle(s,a)});o.on("error",s=>{this.generation===t&&(this.startPromise=null),i(s)}),o.listen(0,"127.0.0.1",()=>{if(this.generation!==t){o.close(),i(new Error("Interactive server stopped during startup."));return}let s=o.address();this.port=typeof s=="object"&&s?s.port:0,this.server=o,n(this.port)})}),this.startPromise}createSession(){if(this.sessions.size>=Tbe)throw new Error("Too many active interactive sessions.");let e=KD(),t=KD()+KD(),n={id:e,token:t,queue:[],waiter:null,waiterTimer:null,pending:new Map,finished:!1,aborted:!1,cleanupTimer:null,attached:!1,attachTimer:null,pollWatchdog:null};return n.attachTimer=window.setTimeout(()=>{!n.attached&&!n.finished&&this.finish(n.id,{kind:"error",error:"No client attached to the interactive session."})},xbe),this.sessions.set(e,n),{id:e,token:t}}emitPrompt(e,t){let n=this.sessions.get(e);if(!n)return Promise.reject(new Error("Unknown session"));if(n.finished)return Promise.reject(new Ee(PN));if(n.aborted)return Promise.reject(new St(yu));let i=KD();return new Promise((o,s)=>{n.pending.set(i,{resolve:o,reject:s,promptType:t.type}),this.push(n,{kind:"prompt",requestId:i,prompt:t})})}finish(e,t){let n=this.sessions.get(e);if(!(!n||n.finished)){n.finished=!0,n.attachTimer&&(window.clearTimeout(n.attachTimer),n.attachTimer=null),n.pollWatchdog&&(window.clearTimeout(n.pollWatchdog),n.pollWatchdog=null);for(let[,i]of n.pending)i.reject(new Ee(PN));n.pending.clear(),this.push(n,t),n.cleanupTimer=window.setTimeout(()=>this.destroySession(n),Cbe)}}abortSession(e){let t=this.sessions.get(e);if(!t||t.finished)return null;t.aborted=!0;let n=[...t.pending.values()];t.pending.clear();for(let i of n)i.reject(new St(yu));return t.queue=t.queue.filter(i=>i.kind!=="prompt"),n.length}stop(){this.generation++;for(let e of this.sessions.values()){e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.cleanupTimer&&window.clearTimeout(e.cleanupTimer),e.attachTimer&&window.clearTimeout(e.attachTimer),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog);for(let[,t]of e.pending)t
2026-07-23 20:36:13 +08:00
/* nosourcemap */