Files
BlueRoseNote/.obsidian/plugins/templater-obsidian/main.js

53 lines
314 KiB
JavaScript
Raw Normal View History

2025-08-02 12:09:34 +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-05-06 16:27:05 +08:00
var Gi=Object.create;var Lt=Object.defineProperty;var Ri=Object.getOwnPropertyDescriptor;var Vi=Object.getOwnPropertyNames;var zi=Object.getPrototypeOf,Ji=Object.prototype.hasOwnProperty;var Or=r=>Lt(r,"__esModule",{value:!0});var Wi=(r,e)=>{Or(r);for(var t in e)Lt(r,t,{get:e[t],enumerable:!0})},Qi=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vi(e))!Ji.call(r,n)&&n!=="default"&&Lt(r,n,{get:()=>e[n],enumerable:!(t=Ri(e,n))||t.enumerable});return r},U=r=>Qi(Or(Lt(r!=null?Gi(zi(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var qr=(()=>{for(var r=new Uint8Array(128),e=0;e<64;e++)r[e<26?e+65:e<52?e+71:e<62?e-4:e*4-205]=e;return t=>{for(var n=t.length,i=new Uint8Array((n-(t[n-1]=="=")-(t[n-2]=="="))*3/4|0),o=0,s=0;o<n;){var l=r[t.charCodeAt(o++)],u=r[t.charCodeAt(o++)],d=r[t.charCodeAt(o++)],h=r[t.charCodeAt(o++)];i[s++]=l<<2|u>>4,i[s++]=u<<4|d>>2,i[s++]=d<<6|h}return i}})();Wi(exports,{default:()=>wr});var _n=U(require("obsidian"));var P=U(require("obsidian"));var Lr=U(require("obsidian"));function z(r){let e=new Lr.Notice("",8e3),t=createFragment(n=>{n.createEl("b",{text:"Templater error"}),n.createSpan({text:":"}),n.createEl("br"),n.createSpan({text:r.message}),r instanceof T&&r.console_msg&&(n.createEl("br"),n.createSpan({text:"Check console for more information"}),console.error("Templater Error:",r.message,`
`,r.console_msg))});e.messageEl.appendChild(t)}var T=class extends Error{constructor(e,t){super(e);this.console_msg=t;this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}};async function se(r,e){try{return await r()}catch(t){return t instanceof T?z(t):z(new T(e,t instanceof Error?t.message:void 0)),null}}function ce(r,e){try{return r()}catch(t){return z(new T(e,t instanceof Error?t.message:void 0)),null}}var J=function(){function r(){}return r.explainIfInvalidTSDocTagName=function(e){if(e[0]!=="@")return'A TSDoc tag name must start with an "@" symbol';if(!r._tsdocTagNameRegExp.test(e))return"A TSDoc tag name must start with a letter and contain only letters and numbers"},r.validateTSDocTagName=function(e){var t=r.explainIfInvalidTSDocTagName(e);if(t)throw new Error(t)},r.explainIfInvalidLinkUrl=function(e){if(e.length===0)return"The URL cannot be empty";if(!r._urlSchemeRegExp.test(e))return'An @link URL must begin with a scheme comprised only of letters and numbers followed by "://". (For general URLs, use an HTML "<a>" tag instead.)';if(!r._urlSchemeAfterRegExp.test(e))return'An @link URL must have at least one character after "://"'},r.explainIfInvalidHtmlName=function(e){if(!r._htmlNameRegExp.test(e))return"An HTML name must be an ASCII letter followed by zero or more letters, digits, or hyphens"},r.validateHtmlName=function(e){var t=r.explainIfInvalidHtmlName(e);if(t)throw new Error(t)},r.explainIfInvalidPackageName=function(e){if(e.length===0)return"The package name cannot be an empty string";if(!r._validPackageNameRegExp.test(e))return"The package name ".concat(JSON.stringify(e)," is not a valid package name")},r.explainIfInvalidImportPath=function(e,t){if(e.length>0){if(e.indexOf("//")>=0)return'An import path must not contain "//"';if(e[e.length-1]==="/")return'An import path must not end with "/"';if(!t&&e[0]==="/")return'An import path must not start with "/" unless prefixed by a package name'}},r.isSystemSelector=function(e){return r._systemSelectors.has(e)},r.explainIfInvalidUnquotedIdentifier=function(e){if(e.length===0)return"The identifier cannot be an empty string";if(r._identifierBadCharRegExp.test(e))return"The identifier cannot non-word characters";if(r._identifierNumberStartRegExp.test(e))return"The identifier must not start with a number"},r.explainIfInvalidUnquotedMemberIdentifier=function(e){var t=r.explainIfInvalidUnquotedIdentifier(e);if(t!==void 0)return t;if(r.isSystemSelector(e))return'The identifier "'.concat(e,'" must be quoted because it is a TSDoc system selector name')},r._tsdocTagNameRegExp=/^@[a-z][a-z0-9]*$/i,r._urlSchemeRegExp=/^[a-z][a-z0-9]*\:\/\//i,r._urlSchemeAfterRegExp=/^[a-z][a-z0-9]*\:\/\/./i,r._htmlNameRegExp=/^[a-z]+[a-z0-9\-]*$/i,r._identifierBadCharRegExp=/[^a-z0-9_$]/i,r._identifierNumberStartRegExp=/^[0-9]/,r._validPackageNameRegExp=/^(?:@[a-z0-9\-_\.]+\/)?[a-z0-9\-_\.]+$/i,r._systemSelectors=new Set(["instance","static","constructor","class","enum","function","interface","namespace","type","variable"]),r}();var Cn=function(){function r(){this._docNodeDefinitionsByKind=new Map,this._docNodeDefinitionsByConstructor=new Map}return r.prototype.registerDocNodes=function(e,t){var n=J.explainIfInvalidPackageName(e);if(n)throw new Error("Invalid NPM package name: "+n);for(var i=0,o=t;i<o.length;i++){var s=o[i];if(!r._nodeKindRegExp.test(s.docNodeKind))throw new Error("The DocNode kind ".concat(JSON.stringify(s.docNodeKind)," is not a valid identifier.")+" It must start with an underscore or letter, and be comprised of letters, numbers, and underscores");var l=this._docNodeDefinitionsByKind.get(s.docNodeKind);if(l!==void 0)throw new Error('The DocNode kind "'.concat(s.docNodeKind,'" was already registered')+" by ".concat(l.packageName));if(l=this._docNodeDefinitionsByConstructor.get(s.constructor),l!==void 0)throw new Error("This DocNode constructor was already registered by ".concat(l.packageName)+" as ".concat(l.docNodeKind));var u={docNodeKind:s.docNodeKind,constructor:s.constructor,packageName:e,allowedChildKinds:new Set};
`:this.range.toString()},r}();var ro=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),x;(function(r){r.Spacing="Spacing",r.BlockTag="BlockTag",r.CodeSpan_OpeningDelimiter="CodeSpan_OpeningDelimiter",r.CodeSpan_Code="CodeSpan_Code",r.CodeSpan_ClosingDelimiter="CodeSpan_ClosingDelimiter",r.DeclarationReference_PackageName="DeclarationReference_PackageName",r.DeclarationReference_ImportPath="DeclarationReference_ImportPath",r.DeclarationReference_ImportHash="DeclarationReference_ImportHash",r.ErrorText="ErrorText",r.NonstandardText="NonstandardText",r.EscapedText="EscapedText",r.FencedCode_OpeningFence="FencedCode_OpeningFence",r.FencedCode_Language="FencedCode_Language",r.FencedCode_Code="FencedCode_Code",r.FencedCode_ClosingFence="FencedCode_ClosingFence",r.HtmlAttribute_Name="HtmlAttribute_Name",r.HtmlAttribute_Equals="HtmlAttribute_Equals",r.HtmlAttribute_Value="HtmlAttribute_Value",r.HtmlEndTag_OpeningDelimiter="HtmlEndTag_OpeningDelimiter",r.HtmlEndTag_Name="HtmlEndTag_Name",r.HtmlEndTag_ClosingDelimiter="HtmlEndTag_ClosingDelimiter",r.HtmlStartTag_OpeningDelimiter="HtmlStartTag_OpeningDelimiter",r.HtmlStartTag_Name="HtmlStartTag_Name",r.HtmlStartTag_ClosingDelimiter="HtmlStartTag_ClosingDelimiter",r.InlineTag_OpeningDelimiter="InlineTag_OpeningDelimiter",r.InlineTag_TagName="InlineTag_TagName",r.InlineTag_TagContent="InlineTag_TagContent",r.InlineTag_ClosingDelimiter="InlineTag_ClosingDelimiter",r.LinkTag_UrlDestination="LinkTag_UrlDestination",r.LinkTag_Pipe="LinkTag_Pipe",r.LinkTag_LinkText="LinkTag_LinkText",r.MemberIdentifier_LeftQuote="MemberIdentifier_LeftQuote",r.MemberIdentifier_Identifier="MemberIdentifier_Identifier",r.MemberIdentifier_RightQuote="MemberIdentifier_RightQuote",r.MemberReference_Dot="MemberReference_Dot",r.MemberReference_LeftParenthesis="MemberReference_LeftParenthesis",r.MemberReference_Colon="MemberReference_Colon",r.MemberReference_RightParenthesis="MemberReference_RightParenthesis",r.MemberSelector="MemberSelector",r.DocMemberSymbol_LeftBracket="DocMemberSymbol_LeftBracket",r.DocMemberSymbol_RightBracket="DocMemberSymbol_RightBracket",r.ParamBlock_ParameterName="ParamBlock_ParameterName",r.ParamBlock_Hyphen="ParamBlock_Hyphen",r.PlainText="PlainText",r.SoftBreak="SoftBreak"})(x||(x={}));var y=function(r){ro(e,r);function e(t){var n=r.call(this,t)||this;if(t.excerptKind===x.Spacing)for(var i=0,o=t.content.tokens;i<o.length;i++){var s=o[i];switch(s.kind){case p.Spacing:case p.Newline:case p.EndOfInput:break;default:throw new Error("The excerptKind=Spacing but the range contains a non-whitespace token")}}return n._excerptKind=t.excerptKind,n._content=t.content,n}return Object.defineProperty(e.prototype,"kind",{get:function(){return g.Excerpt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"excerptKind",{get:function(){return this._excerptKind},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"content",{get:function(){return this._content},enumerable:!1,configurable:!0}),e}(v);var io=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ht=function(r){io(e,r);function e(t){var n=r.call(this,t)||this;return J.validateTSDocTagName(t.tagName),n._tagName=t.tagName,n._tagNameWithUpperCase=t.tagName.toUpperCase(),v.isParsedParameters(t)
`,this._emitCommentFraming=!0,this._lineState=ee.Closed,this._previousLineHadContent=!1,this._hangingParagraph=!1}return r.prototype.renderComment=function(e,t){this._emitCommentFraming=!0,this._renderCompleteObject(e,t)},r.prototype.renderHtmlTag=function(e,t){this._emitCommentFraming=!1,this._renderCompleteObject(e,t)},r.prototype.renderDeclarationReference=function(e,t){this._emitCommentFraming=!1,this._renderCompleteObject(e,t)},r.prototype._renderCompleteObject=function(e,t){this._output=e,this._lineState=ee.Closed,this._previousLineHadContent=!1,this._hangingParagraph=!1,this._renderNode(t),this._writeEnd()},r.prototype._renderNode=function(e){var t=this;if(e!==void 0)switch(e.kind){case g.Block:var n=e;this._ensureLineSkipped(),this._renderNode(n.blockTag),n.blockTag.tagNameWithUpperCase===L.returns.tagNameWithUpperCase&&(this._writeContent(" "),this._hangingParagraph=!0),this._renderNode(n.content);break;case g.BlockTag:var i=e;this._lineState===ee.MiddleOfLine&&this._writeContent(" "),this._writeContent(i.tagName);break;case g.CodeSpan:var o=e;this._writeContent("`"),this._writeContent(o.code),this._writeContent("`");break;case g.Comment:var s=e;this._renderNodes(Bn(Bn(Bn([s.summarySection,s.remarksBlock,s.privateRemarks,s.deprecatedBlock,s.params,s.typeParams,s.returnsBlock],s.customBlocks,!0),s.seeBlocks,!0),[s.inheritDocTag],!1)),s.modifierTagSet.nodes.length>0&&(this._ensureLineSkipped(),this._renderNodes(s.modifierTagSet.nodes));break;case g.DeclarationReference:var l=e;this._writeContent(l.packageName),this._writeContent(l.importPath),(l.packageName!==void 0||l.importPath!==void 0)&&this._writeContent("#"),this._renderNodes(l.memberReferences);break;case g.ErrorText:var u=e;this._writeContent(u.text);break;case g.EscapedText:var d=e;this._writeContent(d.encodedText);break;case g.FencedCode:var h=e;this._ensureAtStartOfLine(),this._writeContent("```"),this._writeContent(h.language),this._writeNewline(),this._writeContent(h.code),this._writeContent("```"),this._writeNewline(),this._writeNewline();break;case g.HtmlAttribute:var j=e;this._writeContent(j.name),this._writeContent(j.spacingAfterName),this._writeContent("="),this._writeContent(j.spacingAfterEquals),this._writeContent(j.value),this._writeContent(j.spacingAfterValue);break;case g.HtmlEndTag:var E=e;this._writeContent("</"),this._writeContent(E.name),this._writeContent(">");break;case g.HtmlStartTag:var M=e;this._writeContent("<"),this._writeContent(M.name),this._writeContent(M.spacingAfterName);for(var I=M.spacingAfterName===void 0||M.spacingAfterName.length===0,K=0,D=M.htmlAttributes;K<D.length;K++){var R=D[K];I&&this._writeContent(" "),this._renderNode(R),I=R.spacingAfterValue===void 0||R.spacingAfterValue.length===0}this._writeContent(M.selfClosingTag?"/>":">");break;case g.InheritDocTag:var ie=e;this._renderInlineTag(ie,function(){ie.declarationReference&&(t._writeContent(" "),t._renderNode(ie.declarationReference))});break;case g.InlineTag:var oe=e;this._renderInlineTag(oe,function(){oe.tagContent.length>0&&(t._writeContent(" "),t._writeContent(oe.tagContent))});break;case g.LinkTag:var W=e;this._renderInlineTag(W,function(){(W.urlDestination!==void 0||W.codeDestination!==void 0)&&(W.urlDestination!==void 0?(t._writeContent(" "),t._writeContent(W.urlDestination)):W.codeDestination!==void 0&&(t._writeContent(" "),t._renderNode(W.codeDestination))),W.linkText!==void 0&&(t._writeContent(" "),t._writeContent("|"),t._writeContent(" "),t._writeContent(W.linkText))});break;case g.MemberIdentifier:var Ue=e;Ue.hasQuotes?(this._writeContent('"'),this._writeContent(Ue.identifier),this._writeContent('"')):this._writeContent(Ue.identifier);break;case g.MemberReference:var fe=e;fe.hasDot&&this._writeContent("."),fe.selector&&this._writeContent("("),fe.memberSymbol?this._renderNode(fe.memberSymbol):this._renderNode(fe.memberIdentifier),fe.selector&&(this._writeContent(":"),this._renderNode(fe.selector),this._writeContent(")"));break;case g.MemberSelector:var xn=e;this._writeContent(xn.selector);break;case g.MemberSymbol:var Pt=e;this._writeContent("["),this.
`?(++t,n=1):++n)}return{line:t,column:n}},r.prototype._validateBounds=function(){if(this.pos<0)throw new Error("TextRange.pos cannot be negative");if(this.end<0)throw new Error("TextRange.end cannot be negative");if(this.end<this.pos)throw new Error("TextRange.end cannot be smaller than TextRange.pos");if(this.pos>this.buffer.length)throw new Error("TextRange.pos cannot exceed the associated text buffer length");if(this.end>this.buffer.length)throw new Error("TextRange.end cannot exceed the associated text buffer length")},r.empty=new r("",0,0),r}();var bt=function(){function r(e){this.messageId=e.messageId,this.unformattedText=e.messageText,this.textRange=e.textRange,this.tokenSequence=e.tokenSequence,this.docNode=e.docNode,this._text=void 0}return r._formatMessageText=function(e,t){if(e||(e="An unknown error occurred"),t.pos!==0||t.end!==0){var n=t.getLocation(t.pos);if(n.line)return"(".concat(n.line,",").concat(n.column,"): ")+e}return e},Object.defineProperty(r.prototype,"text",{get:function(){return this._text===void 0&&(this._text=r._formatMessageText(this.unformattedText,this.textRange)),this._text},enumerable:!1,configurable:!0}),r.prototype.toString=function(){return this.text},r}();var On=function(){function r(){this._messages=[]}return Object.defineProperty(r.prototype,"messages",{get:function(){return this._messages},enumerable:!1,configurable:!0}),r.prototype.addMessage=function(e){this._messages.push(e)},r.prototype.addMessageForTextRange=function(e,t,n){this.addMessage(new bt({messageId:e,messageText:t,textRange:n}))},r.prototype.addMessageForTokenSequence=function(e,t,n,i){this.addMessage(new bt({messageId:e,messageText:t,textRange:n.getContainingTextRange(),tokenSequence:n,docNode:i}))},r.prototype.addMessageForDocErrorText=function(e){var t;e.textExcerpt?t=e.textExcerpt:t=e.errorLocation,this.addMessage(new bt({messageId:e.messageId,messageText:e.errorMessage,textRange:t.getContainingTextRange(),tokenSequence:t,docNode:e}))},r}();var qn=function(){function r(e,t){this.commentRange=ye.empty,this.lines=[],this.tokens=[],this.configuration=e,this.sourceRange=t,this.docComment=new Kt({configuration:this.configuration}),this.log=new On}return r}();var qe=function(){function r(e){this.parserContext=e.parserContext,this._startIndex=e.startIndex,this._endIndex=e.endIndex,this._validateBounds()}return r.createEmpty=function(e){return new r({parserContext:e,startIndex:0,endIndex:0})},Object.defineProperty(r.prototype,"startIndex",{get:function(){return this._startIndex},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"endIndex",{get:function(){return this._endIndex},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"tokens",{get:function(){return this.parserContext.tokens.slice(this._startIndex,this._endIndex)},enumerable:!1,configurable:!0}),r.prototype.getNewSequence=function(e,t){return new r({parserContext:this.parserContext,startIndex:e,endIndex:t})},r.prototype.getContainingTextRange=function(){return this.isEmpty()?ye.empty:this.parserContext.sourceRange.getNewRange(this.parserContext.tokens[this._startIndex].range.pos,this.parserContext.tokens[this._endIndex-1].range.end)},r.prototype.isEmpty=function(){return this._startIndex===this._endIndex},r.prototype.toString=function(){return this.tokens.map(function(e){return e.toString()}).join("")},r.prototype._validateBounds=function(){if(this.startIndex<0)throw new Error("TokenSequence.startIndex cannot be negative");if(this.endIndex<0)throw new Error("TokenSequence.endIndex cannot be negative");if(this.endIndex<this.startIndex)throw new Error("TokenSequence.endIndex cannot be smaller than TokenSequence.startIndex");if(this.startIndex>this.parserContext.tokens.length)throw new Error("TokenSequence.startIndex cannot exceed the associated token array");if(this.endIndex>this.parserContext.tokens.length)throw new Error("TokenSequence.endIndex cannot exceed the associated token array")},r}();var Q;(function(r){r[r.BeginComment1=0]="BeginComment1",r[r.BeginComment2=1]="BeginComment2",r[r.CollectingFirstLine=2]="CollectingFirstLine"
`?((d!==Q.CollectingFirstLine||l>s)&&h.push(t.getNewRange(s,l)),s=u,l=u,d=Q.AdvancingLine):j==="*"&&M==="/"?(l>s&&h.push(t.getNewRange(s,l)),s=0,l=0,++u,o=u,d=Q.Done):r._whitespaceCharacterRegExp.test(j)||(l=u);break;case Q.AdvancingLine:j==="*"?M==="/"?(s=0,l=0,++u,o=u,d=Q.Done):(M===" "&&++u,s=u,l=u,d=Q.CollectingLine):j===`
`?(h.push(t.getNewRange(E,E)),s=u):r._whitespaceCharacterRegExp.test(j)||(l=u,d=Q.CollectingLine);break}}return e.commentRange=t.getNewRange(i,o),e.lines=h,!0},r._whitespaceCharacterRegExp=/^\s$/,r}();var Et=function(){function r(){}return r.readTokens=function(e){r._ensureInitialized();for(var t=[],n=void 0,i=0,o=e;i<o.length;i++){var s=o[i];r._pushTokensForLine(t,s),n=s}return n?t.push(new ze(p.EndOfInput,n.getNewRange(n.end,n.end),n)):t.push(new ze(p.EndOfInput,ye.empty,ye.empty)),t},r.isPunctuation=function(e){return r._ensureInitialized(),r._punctuationTokens[e]||!1},r._pushTokensForLine=function(e,t){for(var n=t.buffer,i=t.end,o=t.pos,s=void 0,l=o;o<i;){var u=n.charCodeAt(o),d=r._charCodeMap[u];d===void 0&&(d=p.Other),s!==void 0&&d===s&&r._isMultiCharacterToken(s)||(s!==void 0&&e.push(new ze(s,t.getNewRange(l,o),t)),l=o,s=d),++o}s!==void 0&&e.push(new ze(s,t.getNewRange(l,o),t)),e.push(new ze(p.Newline,t.getNewRange(t.end,t.end),t))},r._isMultiCharacterToken=function(e){switch(e){case p.Spacing:case p.AsciiWord:case p.Other:return!0}return!1},r._ensureInitialized=function(){if(!r._charCodeMap){r._charCodeMap={},r._punctuationTokens={};for(var e=r._commonMarkPunctuationCharacters,t=0;t<e.length;++t){var n=e.charCodeAt(t);r._charCodeMap[n]=p.OtherPunctuation}for(var i={"\\":p.Backslash,"<":p.LessThan,">":p.GreaterThan,"=":p.Equals,"'":p.SingleQuote,'"':p.DoubleQuote,"/":p.Slash,"-":p.Hyphen,"@":p.AtSign,"{":p.LeftCurlyBracket,"}":p.RightCurlyBracket,"`":p.Backtick,".":p.Period,":":p.Colon,",":p.Comma,"[":p.LeftSquareBracket,"]":p.RightSquareBracket,"|":p.Pipe,"(":p.LeftParenthesis,")":p.RightParenthesis,"#":p.PoundSymbol,"+":p.Plus,$:p.DollarSign},o=0,s=Object.getOwnPropertyNames(i);o<s.length;o++){var l=s[o];r._charCodeMap[l.charCodeAt(0)]=i[l],r._punctuationTokens[i[l]]=!0}r._punctuationTokens[p.OtherPunctuation]=!0;for(var u=r._wordCharacters,t=0;t<u.length;++t){var n=u.charCodeAt(t);r._charCodeMap[n]=p.AsciiWord}r._charCodeMap[" ".charCodeAt(0)]=p.Spacing,r._charCodeMap[" ".charCodeAt(0)]=p.Spacing}},r._commonMarkPunctuationCharacters="!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~",r._wordCharacters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_",r}();var Ln=function(){function r(e,t){if(this._parserContext=e,this.tokens=e.tokens,t){if(t.parserContext!==this._parserContext)throw new Error("The embeddedTokenSequence must use the same parser context");this._readerStartIndex=t.startIndex,this._readerEndIndex=t.endIndex}else this._readerStartIndex=0,this._readerEndIndex=this.tokens.length;this._currentIndex=this._readerStartIndex,this._accumulatedStartIndex=this._readerStartIndex}return r.prototype.extractAccumulatedSequence=function(){if(this._accumulatedStartIndex===this._currentIndex)throw new Error("Parser assertion failed: The queue should not be empty when extractAccumulatedSequence() is called");var e=new qe({parserContext:this._parserContext,startIndex:this._accumulatedStartIndex,endIndex:this._currentIndex});return this._accumulatedStartIndex=this._currentIndex,e},r.prototype.isAccumulatedSequenceEmpty=function(){return this._accumulatedStartIndex===this._currentIndex},r.prototype.tryExtractAccumulatedSequence=function(){if(!this.isAccumulatedSequenceEmpty())return this.extractAccumulatedSequence()},r.prototype.assertAccumulatedSequenceIsEmpty=function(){if(!this.isAccumulatedSequenceEmpty()){var e=new qe({parserContext:this._parserContext,startIndex:this._accumulatedStartIndex,endIndex:this._currentIndex}),t=e.tokens.map(function(n){return n.toString()});throw new Error(`Parser assertion failed: The queue should be empty, but it contains:
`+JSON.stringify(t))}},r.prototype.peekToken=function(){return this.tokens[this._currentIndex]},r.prototype.peekTokenKind=function(){return this._currentIndex>=this._readerEndIndex?p.EndOfInput:this.tokens[this._currentIndex].kind},r.prototype.peekTokenAfterKind=function(){return this._currentIndex+1>=this._readerEndIndex?p.EndOfInput:this.tokens[this._currentIndex+1].kind},r.prototype.peekTokenAfterAfterKind=function(){return this._currentIndex+2>=this._readerEndIndex?p.EndOfInput:this.tokens[this._currentIndex+2].kind},r.prototype.readToken=function(){if(this._currentIndex>=this._readerEndIndex)throw new Error("Cannot read past end of stream");var e=this.tokens[this._currentIndex];if(e.kind===p.EndOfInput)throw new Error("The EndOfInput token cannot be read");return this._currentIndex++,e},r.prototype.peekPreviousTokenKind=function(){return this._currentIndex===0?p.EndOfInput:this.tokens[this._currentIndex-1].kind},r.prototype.createMarker=function(){return this._currentIndex},r.prototype.backtrackToMarker=function(e){if(e>this._currentIndex)throw new Error("The marker has expired");this._currentIndex=e,e<this._accumulatedStartIndex&&(this._accumulatedStartIndex=e)},r}();var an=function(){return an=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},an.apply(this,arguments)};function kt(r){return r!==void 0&&Object.hasOwnProperty.call(r,"failureMessage")}var Rr=function(){function r(e){this._parserContext=e,this._configuration=e.configuration,this._currentSection=e.docComment.summarySection}return r.prototype.parse=function(){for(var e=new Ln(this._parserContext),t=!1;!t;)switch(e.peekTokenKind()){case p.EndOfInput:t=!0;break;case p.Newline:this._pushAccumulatedPlainText(e),e.readToken(),this._pushNode(new Zt({parsed:!0,configuration:this._configuration,softBreakExcerpt:e.extractAccumulatedSequence()}));break;case p.Backslash:this._pushAccumulatedPlainText(e),this._pushNode(this._parseBackslashEscape(e));break;case p.AtSign:this._pushAccumulatedPlainText(e),this._parseAndPushBlock(e);break;case p.LeftCurlyBracket:{this._pushAccumulatedPlainText(e);var n=e.createMarker(),i=this._parseInlineTag(e),o=this._parserContext.docComment;if(i instanceof wt){var s=e.createMarker()-1;o.inheritDocTag===void 0?this._parserContext.docComment.inheritDocTag=i:this._pushNode(this._backtrackAndCreateErrorRange(e,n,s,w.ExtraInheritDocTag,"A doc comment cannot have more than one @inheritDoc tag"))}else this._pushNode(i);break}case p.RightCurlyBracket:this._pushAccumulatedPlainText(e),this._pushNode(this._createError(e,w.EscapeRightBrace,'The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag'));break;case p.LessThan:this._pushAccumulatedPlainText(e),e.peekTokenAfterKind()===p.Slash?this._pushNode(this._parseHtmlEndTag(e)):this._pushNode(this._parseHtmlStartTag(e));break;case p.GreaterThan:this._pushAccumulatedPlainText(e),this._pushNode(this._createError(e,w.EscapeGreaterThan,'The ">" character should be escaped using a backslash to avoid confusion with an HTML tag'));break;case p.Backtick:this._pushAccumulatedPlainText(e),e.peekTokenAfterKind()===p.Backtick&&e.peekTokenAfterAfterKind()===p.Backtick?this._pushNode(this._parseFencedCode(e)):this._pushNode(this._parseCodeSpan(e));break;default:e.readToken();break}this._pushAccumulatedPlainText(e),this._performValidationChecks()},r.prototype._performValidationChecks=function(){var e=this._parserContext.docComment;e.deprecatedBlock&&(on.hasAnyTextContent(e.deprecatedBlock)||this._parserContext.log.addMessageForTokenSequence(w.MissingDeprecationMessage,"The ".concat(e.deprecatedBlock.blockTag.tagName," block must include a deprecation message,")+" e.g. describing the recommended alternative",e.deprecatedBlock.blockTag.getTokenSequence(),e.deprecatedBlock)),e.inheritDocTag&&(e.remarksBlock&&this._parserContext.log.addMessageForTokenSequence(w.InheritDocIncompatibleTag,'A "'.concat(e.remarksBlock.blockTag.tagName,'" block must not be used, beca
`)).join(`
`)}catch{return console.error("Failed to parse summary section"),""}}function Do(r){if(!r)return"";try{let e=r.content.nodes[0]?.getChildNodes()[0];return e instanceof me?e.text.trim():""}catch{return""}}function Po(r){try{return r.blocks.map(n=>{let i=n.parameterName,o=n.content.getChildNodes()[0].getChildNodes().filter(s=>s instanceof me).map(s=>s.text).join(" ");return new Kn(i,o)})}catch{return[]}}function Pe(r,e,t){if(t<0||t===r.length)return;let n=r[e];r[e]=r[t],r[t]=n}function He(r){return r.workspace.activeEditor?.file??r.workspace.getActiveFile()}function sn(r){let e=r.lastIndexOf("/");return e!==-1?r.slice(0,e):""}function St(r){return r!==null&&typeof r=="object"}function Qr(r){let e=r.toString(),t=e.indexOf("(");return e.substring(t+1,e.indexOf(")")).replace(/ /g,"").split(",")}function Yn(r,e,t){let n=r.instanceOf(HTMLOListElement)?"li":"p",i=r.createEl(n),o=r.createEl("b",{text:e});return i.appendChild(o),i.appendChild(activeDocument.createTextNode(`: ${t}`)),i}function cn(r,e){if(Object.keys(e).length!==0){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))if(Object.prototype.hasOwnProperty.call(r,t)){let n=r[t],i=e[t];if(Array.isArray(n)||Array.isArray(i)){let o=Array.isArray(n)?n:[n],s=Array.isArray(i)?i:[i];r[t]=o.concat(s).unique()}else St(n)&&St(i)?cn(n,i):i!=null&&i!==""&&(r[t]=i)}else r[t]=e[t]}}function Ct(r){let e={},t=(0,re.getFrontMatterInfo)(r);return t.frontmatter&&(e=(0,re.parseYaml)(t.frontmatter)),{frontmatter:e,content:r.slice(t.contentStart)}}var ln=U(require("obsidian"));var he;(function(t){t[t.TemplateFiles=0]="TemplateFiles",t[t.ScriptFiles=1]="ScriptFiles"})(he||(he={}));var ct=class extends ln.AbstractInputSuggest{constructor(e,t,n){super(t.app,e);this.inputEl=e;this.plugin=t;this.mode=n}get_folder(e){switch(e){case 0:return this.plugin.settings.templates_folder;case 1:return this.plugin.settings.user_scripts_folder}}get_error_msg(e){switch(e){case 0:return"Templates folder doesn't exist";case 1:return"User Scripts folder doesn't exist"}}getSuggestions(e){let t=ce(()=>je(this.plugin.app,this.get_folder(this.mode)),this.get_error_msg(this.mode));if(!t)return[];let n=[],i=e.toLowerCase();return t.forEach(o=>{o instanceof ln.TFile&&o.extension==="md"&&o.path.toLowerCase().includes(i)&&n.push(o)}),n.slice(0,1e3)}renderSuggestion(e,t){t.setText(e.path)}selectSuggestion(e){this.setValue(e.path),this.inputEl.trigger("input"),this.close()}};var un=U(require("obsidian")),lt=class extends un.AbstractInputSuggest{constructor(e,t){super(e,t);this.inputEl=t}getSuggestions(e){let t=this.app.vault.getAllLoadedFiles(),n=[],i=e.toLowerCase();return t.forEach(o=>{o instanceof un.TFolder&&o.path.toLowerCase().includes(i)&&n.push(o)}),n.slice(0,1e3)}renderSuggestion(e,t){t.setText(e.path)}selectSuggestion(e){this.setValue(e.path),this.inputEl.trigger("input"),this.close()}};var Ne;(function(o){o[o.Off=0]="Off",o[o.RenderDescriptionParameterReturn=1]="RenderDescriptionParameterReturn",o[o.RenderDescriptionParameterList=2]="RenderDescriptionParameterList",o[o.RenderDescriptionReturn=3]="RenderDescriptionReturn",o[o.RenderDescriptionOnly=4]="RenderDescriptionOnly"})(Ne||(Ne={}));function Xr(r){return isBoolean(r)?r:[1,3].includes(r)}function Zr(r){return isBoolean(r)?r:[1,2].includes(r)}function ei(r){return isBoolean(r)?r:r!=0}var ti={command_timeout:5,templates_folder:"",templates_pairs:[["",""]],trigger_on_file_creation:!1,auto_jump_to_cursor:!1,enable_system_commands:!1,shell_path:"",user_scripts_folder:"",enable_folder_templates:!0,folder_templates:[{folder:"",template:""}],enable_file_templates:!1,file_templates:[{regex:".*",template:""}],syntax_highlighting:!0,syntax_highlighting_mobile:!1,enabled_templates_hotkeys:[""],startup_templates:[""],intellisense_render:Ne.RenderDescriptionParameterReturn,ignore_folders_on_creation:[{folder:""}]},Gn=class extends P.PluginSettingTab{constructor(e){super(e.app,e);this.plugin=e;this.icon="templater-icon"}display(){this.containerEl.empty(),this.add_template_folder_setting(),this.add_internal_functions_setting(),this.add_syntax_highlighting_settings(),
> \u2014 ${o}`}catch{return new T("Error generating daily quote"),"Error generating daily quote"}}}generate_random_picture(){return async(e,t,n=!1)=>{try{let i=await this.getRequest(`https://templater-unsplash-2.fly.dev/${t?"?q="+t:""}`).then(s=>s.json),o=i.full;if(e&&!n)if(e.includes("x")){let[s,l]=e.split("x");o=o.concat(`&w=${s}&h=${l}`)}else o=o.concat(`&w=${e}`);return n?`![photo by ${i.photog}(${i.photogUrl}) on Unsplash|${e}](${o})`:`![photo by ${i.photog}(${i.photogUrl}) on Unsplash](${o})`}catch{return new T("Error generating random picture"),"Error generating random picture"}}}generate_request(){return async(e,t)=>{try{let i=(await this.getRequest(e)).json;return t&&i?t.split(".").reduce((o,s)=>{if(Object.prototype.hasOwnProperty.call(o,s))return o[s];throw new Error(`Path ${t} not found in the JSON response`)},i):i}catch(n){throw console.error(n),new T("Error fetching and extracting value")}}}};var Wn=class extends ne{constructor(){super(...arguments);this.name="hooks";this.event_refs=[]}async create_static_templates(){this.static_functions.set("on_all_templates_executed",this.generate_on_all_templates_executed())}async create_dynamic_templates(){}async teardown(){this.event_refs.forEach(e=>{e.e.offref(e)}),this.event_refs=[]}generate_on_all_templates_executed(){return e=>{let t=this.plugin.app.workspace.on("templater:all-templates-executed",async()=>{await Le(1),e()});t&&this.event_refs.push(t)}}};var Qn=class extends ne{constructor(){super(...arguments);this.name="frontmatter"}async create_static_templates(){}async create_dynamic_templates(){let e=this.plugin.app.metadataCache.getFileCache(this.config.target_file);this.dynamic_functions=new Map(Object.entries(e?.frontmatter||{}))}async teardown(){}};var we=U(require("obsidian"));var Xn=class extends we.Modal{constructor(e,t,n,i){super(e);this.prompt_text=t;this.default_value=n;this.multi_line=i;this.submitted=!1}onOpen(){this.titleEl.setText(this.prompt_text),this.createForm()}onClose(){this.contentEl.empty(),this.submitted||this.reject(new T("Cancelled prompt"))}createForm(){let e=this.contentEl.createDiv();e.addClass("templater-prompt-div");let t;this.multi_line?t=new we.TextAreaComponent(e):t=new we.TextComponent(e);let n=this.contentEl.createDiv();n.addClass("templater-button-div");let i=new we.ButtonComponent(n);i.buttonEl.addClass("mod-cta"),i.setButtonText("Submit").onClick(o=>{this.resolveAndClose(o)}),this.value=this.default_value??"",t.inputEl.addClass("templater-prompt-input"),t.setPlaceholder("Type text here"),t.setValue(this.value),t.onChange(o=>this.value=o),t.inputEl.focus(),t.inputEl.addEventListener("keydown",o=>this.enterCallback(o))}enterCallback(e){e.isComposing||e.keyCode===229||(this.multi_line?we.Platform.isDesktop&&e.key==="Enter"&&!e.shiftKey&&this.resolveAndClose(e):e.key==="Enter"&&this.resolveAndClose(e))}resolveAndClose(e){this.submitted=!0,e.preventDefault(),this.resolve(this.value),this.close()}async openAndGetValue(e,t){this.resolve=e,this.reject=t,this.open()}};var ai=U(require("obsidian")),Zn=class extends ai.FuzzySuggestModal{constructor(e,t,n,i,o,s){super(e);this.text_items=t;this.items=n;this.default_value=s;this.submitted=!1;this.containerEl.addClass("templater-suggester-modal"),this.setPlaceholder(i),o&&(this.limit=o)}getItems(){return this.items}onOpen(){super.onOpen(),this.default_value!==void 0&&(this.inputEl.value=this.getItemText(this.default_value),this.inputEl.dispatchEvent(new InputEvent("input")))}onClose(){this.submitted||this.reject(new T("Cancelled prompt"))}selectSuggestion(e,t){this.submitted=!0,this.close(),this.onChooseSuggestion(e,t)}getItemText(e){return this.text_items instanceof Function?this.text_items(e):this.text_items[this.items.indexOf(e)]||"Undefined Text Item"}onChooseItem(e){this.resolve(e)}async openAndGetValue(e,t){this.resolve=e,this.reject=t,this.open()}};var le=U(require("obsidian")),er=class extends le.Modal{constructor(e,t,n,i,o,s){super(e);this.text_items=t;this.items=n;this.submitted=!1;this.selectedItems=[];this.setTitle(i),this.listEl=this.contentEl.createDiv("templater-multisugge
})`)(n,o,i)}catch(u){throw new T(`Failed to load user script at "${e.path}".`,u instanceof Error?u.message:String(u))}let l=i.default??o.exports;if(!l)throw new T(`Failed to load user script at "${e.path}". No exports detected.`);if(typeof l=="function")t.set(e.basename,l);else if(typeof l=="object"&&l!==null){if(!Object.values(l).every(d=>typeof d=="function"))throw new T(`Exported object in "${e.path}" must contain only functions.`);t.set(e.basename,l)}else throw new T(`Invalid export in "${e.path}". Must be a function or object of functions.`)}async generate_object(){let e=await this.generate_user_script_functions();return Object.fromEntries(e)}};var ar=class{constructor(e){this.plugin=e;this.user_system_functions=new ir(e),this.user_script_functions=new or(e)}async generate_object(e){let t={},n={};return this.plugin.settings.enable_system_commands&&(t=await this.user_system_functions.generate_object(e)),this.plugin.settings.user_scripts_folder&&(n=await this.user_script_functions.generate_object()),{...t,...n}}};var No=U(require("obsidian")),ve;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.USER_INTERNAL=1]="USER_INTERNAL"})(ve||(ve={}));var sr=class{constructor(e){this.plugin=e;this.internal_functions=new rr(this.plugin),this.user_functions=new ar(this.plugin)}async init(){await this.internal_functions.init()}async teardown(){await this.internal_functions.teardown()}additional_functions(){return{app:this.plugin.app,obsidian:No}}async generate_object(e,t=1){let n={},i=this.additional_functions(),o=await this.internal_functions.generate_object(e),s={};switch(Object.assign(n,i),t){case 0:Object.assign(n,o);break;case 1:s=await this.user_functions.generate_object(e),Object.assign(n,{...o,user:s});break}return n}};var Ko={},b,Ae=new Array(32).fill(void 0);Ae.push(void 0,null,!0,!1);function ue(r){return Ae[r]}var Dt=Ae.length;function Mo(r){r<36||(Ae[r]=Dt,Dt=r)}function cr(r){let e=ue(r);return Mo(r),e}var ci=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});ci.decode();var fn=new Uint8Array;function dn(){return fn.byteLength===0&&(fn=new Uint8Array(b.memory.buffer)),fn}function $e(r,e){return ci.decode(dn().subarray(r,r+e))}function Ke(r){Dt===Ae.length&&Ae.push(Ae.length+1);let e=Dt;return Dt=Ae[e],Ae[e]=r,e}var _e=0,gn=new TextEncoder("utf-8"),Fo=typeof gn.encodeInto=="function"?function(r,e){return gn.encodeInto(r,e)}:function(r,e){let t=gn.encode(r);return e.set(t),{read:r.length,written:t.length}};function Fe(r,e,t){if(t===void 0){let l=gn.encode(r),u=e(l.length);return dn().subarray(u,u+l.length).set(l),_e=l.length,u}let n=r.length,i=e(n),o=dn(),s=0;for(;s<n;s++){let l=r.charCodeAt(s);if(l>127)break;o[i+s]=l}if(s!==n){s!==0&&(r=r.slice(s)),i=t(i,n,n=s+r.length*3);let l=dn().subarray(i+s,i+n);s+=Fo(r,l).written}return _e=s,i}function Io(r){return r==null}var mn=new Int32Array;function pe(){return mn.byteLength===0&&(mn=new Int32Array(b.memory.buffer)),mn}function lr(r){let e=typeof r;if(e=="number"||e=="boolean"||r==null)return`${r}`;if(e=="string")return`"${r}"`;if(e=="symbol"){let i=r.description;return i==null?"Symbol":`Symbol(${i})`}if(e=="function"){let i=r.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(r)){let i=r.length,o="[";i>0&&(o+=lr(r[0]));for(let s=1;s<i;s++)o+=", "+lr(r[s]);return o+="]",o}let t=/\[object ([^\]]+)\]/.exec(toString.call(r)),n;if(t.length>1)n=t[1];else return toString.call(r);if(n=="Object")try{return"Object("+JSON.stringify(r)+")"}catch{return"Object"}return r instanceof Error?`${r.name}: ${r.message}
${r.stack}`:n}function Bo(r,e){if(!(r instanceof e))throw new Error(`expected instance of ${e.name}`);return r.ptr}var hn=32;function Oo(r){if(hn==1)throw new Error("out of js stack");return Ae[--hn]=r,hn}function ur(r,e){try{return r.apply(this,e)}catch(t){b.__wbindgen_exn_store(Ke(t))}}var Je=class{static __wrap(e){let t=Object.create(Je.prototype);return t.ptr=e,t}__destroy_into_raw(){let e=this.ptr;return this.ptr=0,e}free(){let e=this.__destroy_into_raw();b.__wbg_parserconfig_free(e)}get interpolate(){let e=b.__wbg_get_parserconfig_interpolate(this.ptr);return String.fromCodePoint(e)}set interpolate(e){b.__wbg_set_parserconfig_interpolate(this.ptr,e.codePointAt(0))}get execution(){let e=b.__wbg_get_parserconfig_execution(this.ptr);return String.fromCodePoint(e)}set execution(e){b.__wbg_set_parserconfig_execution(this.ptr,e.codePointAt(0))}get single_whitespace(){let e=b.__wbg_get_parserconfig_single_whitespace(this.ptr);return String.fromCodePoint(e)}set single_whitespace(e){b.__wbg_set_parserconfig_single_whitespace(this.ptr,e.codePointAt(0))}get multiple_whitespace(){let e=b.__wbg_get_parserconfig_multiple_whitespace(this.ptr);return String.fromCodePoint(e)}set multiple_whitespace(e){b.__wbg_set_parserconfig_multiple_whitespace(this.ptr,e.codePointAt(0))}constructor(e,t,n,i,o,s,l){let u=Fe(e,b.__wbindgen_malloc,b.__wbindgen_realloc),d=_e,h=Fe(t,b.__wbindgen_malloc,b.__wbindgen_realloc),j=_e,E=Fe(l,b.__wbindgen_malloc,b.__wbindgen_realloc),M=_e,I=b.parserconfig_new(u,d,h,j,n.codePointAt(0),i.codePointAt(0),o.codePointAt(0),s.codePointAt(0),E,M);return Je.__wrap(I)}get opening_tag(){try{let n=b.__wbindgen_add_to_stack_pointer(-16);b.parserconfig_opening_tag(n,this.ptr);var e=pe()[n/4+0],t=pe()[n/4+1];return $e(e,t)}finally{b.__wbindgen_add_to_stack_pointer(16),b.__wbindgen_free(e,t)}}set opening_tag(e){let t=Fe(e,b.__wbindgen_malloc,b.__wbindgen_realloc),n=_e;b.parserconfig_set_opening_tag(this.ptr,t,n)}get closing_tag(){try{let n=b.__wbindgen_add_to_stack_pointer(-16);b.parserconfig_closing_tag(n,this.ptr);var e=pe()[n/4+0],t=pe()[n/4+1];return $e(e,t)}finally{b.__wbindgen_add_to_stack_pointer(16),b.__wbindgen_free(e,t)}}set closing_tag(e){let t=Fe(e,b.__wbindgen_malloc,b.__wbindgen_realloc),n=_e;b.parserconfig_set_closing_tag(this.ptr,t,n)}get global_var(){try{let n=b.__wbindgen_add_to_stack_pointer(-16);b.parserconfig_global_var(n,this.ptr);var e=pe()[n/4+0],t=pe()[n/4+1];return $e(e,t)}finally{b.__wbindgen_add_to_stack_pointer(16),b.__wbindgen_free(e,t)}}set global_var(e){let t=Fe(e,b.__wbindgen_malloc,b.__wbindgen_realloc),n=_e;b.parserconfig_set_global_var(this.ptr,t,n)}},ft=class{static __wrap(e){let t=Object.create(ft.prototype);return t.ptr=e,t}__destroy_into_raw(){let e=this.ptr;return this.ptr=0,e}free(){let e=this.__destroy_into_raw();b.__wbg_renderer_free(e)}constructor(e){Bo(e,Je);var t=e.ptr;e.ptr=0;let n=b.renderer_new(t);return ft.__wrap(n)}render_content(e,t){try{let s=b.__wbindgen_add_to_stack_pointer(-16),l=Fe(e,b.__wbindgen_malloc,b.__wbindgen_realloc),u=_e;b.renderer_render_content(s,this.ptr,l,u,Oo(t));var n=pe()[s/4+0],i=pe()[s/4+1],o=pe()[s/4+2];if(o)throw cr(i);return cr(n)}finally{b.__wbindgen_add_to_stack_pointer(16),Ae[hn++]=void 0}}};async function qo(r,e){if(typeof Response=="function"&&r instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(n){if(r.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let t=await r.arrayBuffer();return await WebAssembly.instantiate(t,e)}else{let t=await WebAssembly.instantiate(r,e);return t instanceof WebAssembly.Instance?{instance:t,module:r}:t}}function Lo(){let r={};return r.wbg={},r.wbg.__wbindgen_object_drop_ref=function(e){cr(e)},r.wbg.__wbindgen_string_new=function(e,t){let n=$e(e,t);return Ke(n)},r.wbg.__wbindgen_string_get=function(e,t){let n=ue
${(0,G.stringifyYaml)(M)}---
`),j+=E+d,o.editor.setValue(j),o.editor.setSelection({line:0,ch:0},{line:0,ch:0}),await Le(100),await i.save()}else await this.plugin.app.vault.process(t,j=>{let E="",{content:M,frontmatter:I}=Ct(j);return cn(I,h),Object.keys(I).length>0&&(E+=`---
${(0,G.stringifyYaml)(I)}---
`),E+=M+d,u=E,E});this.plugin.app.workspace.trigger("templater:new-note-from-template",{file:t,content:u}),await this.plugin.editor_handler.jump_to_next_cursor_location(t,!0),await this.end_templater_task(n)}async overwrite_active_file_commands(){let e=this.plugin.app.workspace.activeEditor;if(!e||!e.file){z(new T("Active editor is null, can't overwrite content"));return}await this.overwrite_file_commands(e.file,!0)}async overwrite_file_commands(e,t=!1){let{path:n}=e;this.start_templater_task(n);let i=this.create_running_config(e,e,t?3:2),o=await se(async()=>this.read_and_parse_template(i),"Template parsing error, aborting.");if(o==null){await this.end_templater_task(n);return}await this.plugin.app.vault.modify(e,o),this.plugin.app.workspace.trigger("templater:overwrite-file",{file:e,content:o}),await this.plugin.editor_handler.jump_to_next_cursor_location(e,!0),await this.end_templater_task(n)}async process_dynamic_templates(e,t){let n=Jr(),i=activeDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT),o,s=!1,l;for(;o=i.nextNode();){let u=o.nodeValue;if(u!==null){let d=n.exec(u);if(d!==null){let h=this.plugin.app.metadataCache.getFirstLinkpathDest("",t.sourcePath);if(!h||!(h instanceof G.TFile))return;if(!s){s=!0;let j=this.create_running_config(h,h,4);l=await this.functions_generator.generate_object(j,ve.USER_INTERNAL),this.current_functions_object=l}}for(;d!=null;){let h=d[1]+d[2],j=await se(async()=>await this.parser.parse_commands(h,l),`Command Parsing error in dynamic command '${h}'`);if(j==null)return;let E=n.lastIndex-d[0].length,M=n.lastIndex;u=u.substring(0,E)+j+u.substring(M),n.lastIndex+=j.length-d[0].length,d=n.exec(u)}o.nodeValue=u}}}get_new_file_template_for_folder(e){let t=e;for(;t instanceof G.TFolder;){let n=t,i=this.plugin.settings.folder_templates.find(o=>o.folder==n.path);if(i&&i.template)return i.template;t=t.parent}}get_new_file_template_for_file(e){let t=this.plugin.settings.file_templates.find(n=>new RegExp(n.regex).test(e.path));if(t&&t.template)return t.template}static async on_file_creation(e,t,n){if(!(n instanceof G.TFile)||n.extension!=="md")return;let i=(0,G.normalizePath)(e.plugin.settings.templates_folder);if(n.path.includes(i)&&i!=="/")return;for(let u of e.plugin.settings.ignore_folders_on_creation){let d=(0,G.normalizePath)(u.folder);if(n.path.startsWith(d)&&d!=="")return}if(await Le(300),e.files_with_pending_templates.has(n.path))return;let o=await t.vault.read(n),s=(0,G.getFrontMatterInfo)(o),l=o.length-s.contentStart;if(l==0&&e.plugin.settings.enable_folder_templates){if(!(n.parent instanceof G.TFolder))return;let u=e.get_new_file_template_for_folder(n.parent);if(!u)return;let d=await se(async()=>De(t,u),`Couldn't find template ${u}`);if(d==null)return;await e.write_template_to_file(d,n)}else if(l==0&&e.plugin.settings.enable_file_templates){let u=e.get_new_file_template_for_file(n);if(!u)return;let d=await se(async()=>De(t,u),`Couldn't find template ${u}`);if(d==null)return;await e.write_template_to_file(d,n)}else{let u=1e5;n.stat.size<=u?await e.overwrite_file_commands(n):console.debug(`Templater skipped parsing ${n.path} because file size exceeds ${u}`)}}async execute_startup_scripts(){for(let e of this.plugin.settings.startup_templates){if(!e)continue;let t=ce(()=>De(this.plugin.app,e),`Couldn't find startup template "${e}"`);if(!t)continue;let{path:n}=t;this.start_templater_task(n);let i=this.create_running_config(t,t,5);await se(async()=>this.read_and_parse_template(i),"Startup Template parsing error, aborting."),await this.end_templater_task(n)}}};var gt=U(require("obsidian"));var An=class{constructor(e,t,n){this.plugin=e;this.templater=t;this.settings=n}async setup(){this.plugin.app.workspace.onLayoutReady(async()=>{if(this.settings.trigger_on_file_creation&&this.plugin.app.vault.getConfig("openBehavior")==="daily"){let t=this.plugin.app.internalPlugins.getEnabledPluginById("daily-notes");if(t){let{folder:n,format:i}=t.options,o=(0,gt.normalizePath)(`${n}/${(0,gt.moment)().format(i)}.md`),s=He(this.plugin.app);s?.path===o&&await dt.on_file_creation(this.templater,this.plugin.a
`,s+1))!==-1;i++,o=s);o+=1;let l=e.slice(o,t).length;return{line:i,ch:l}}get_cursor_matches_and_positions(e){let t=/<%\s*tp\.file\.cursor\((?<order>[0-9]*)\)\s*%>/g,n=[],i;for(;(i=t.exec(e))!==null;)n.push(i);if(n.length===0)return{};n.sort((h,j)=>Number(h.groups?.order||0)-Number(j.groups?.order||0));let o=n[0][0],s=n.filter(h=>h[0]===o),l=s[0][1]===""?[s[0]]:s,u=[],d=0;for(let h of l){let j=h.index-d;u.push(this.get_editor_position_from_index(e,j)),e=e.slice(0,j)+e.slice(j+h[0].length),d+=h[0].length}return{cursor_matches:l,positions:u}}};var mi=U(require("obsidian"));var Yo={app:{name:"app",description:"This module exposes the app instance. Prefer to use this over the global app instance."},user:{name:"user",description:"This module exposes custom made scripts, written by yourself within the script file folder location"},config:{name:"config",description:`This module exposes Templater's running configuration.
This is mostly useful when writing scripts requiring some context information.
`,functions:{template_file:{name:"template_file",description:"The `TFile` object representing the template file.",definition:"tp.config.template_file"},target_file:{name:"target_file",description:"The `TFile` object representing the target file where the template will be inserted.",definition:"tp.config.target_file"},run_mode:{name:"run_mode",description:"The `RunMode`, representing the way Templater was launched (Create new from template, Append to active file, ...).",definition:"tp.config.run_mode"},active_file:{name:"active_file",description:"The active file (if existing) when launching Templater.",definition:"tp.config.active_file?"}}},date:{name:"date",description:"This module contains every internal function related to dates.",functions:{now:{name:"now",description:"Retrieves the date.",definition:'tp.date.now(format: string = "YYYY-MM-DD", offset?: number | string, reference?: string, reference_format?: string)',args:[{name:"format",description:'The format for the date. Defaults to `"YYYY-MM-DD"`. Refer to the [Momentjs format reference](https://momentjs.com/docs/#/displaying/format/).'},{name:"offset",description:"Duration to offset the date from. If a number is provided, duration will be added to the date in days. You can also specify the offset as a string using the ISO 8601 format."},{name:"reference",description:"The date to use instead of today's date, e.g. set this to the note's title."},{name:"reference_format",description:"The format for the reference date. Refer to the [Momentjs format reference](https://momentjs.com/docs/#/displaying/format/)."}],examples:[{name:"Date now",example:"<% tp.date.now() %>"},{name:"Date now with format",example:'<% tp.date.now("Do MMMM YYYY") %>'},{name:"Last week",example:'<% tp.date.now("YYYY-MM-DD", -7) %>'},{name:"Next week",example:'<% tp.date.now("YYYY-MM-DD", 7) %>'},{name:"Last month",example:'<% tp.date.now("YYYY-MM-DD", "P-1M") %>'},{name:"Next year",example:'<% tp.date.now("YYYY-MM-DD", "P1Y") %>'},{name:"File's title date + 1 day (tomorrow)",example:'<% tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD") %>'},{name:"File's title date - 1 day (yesterday)",example:'<% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>'}]},tomorrow:{name:"tomorrow",description:"Retrieves tomorrow's date.",definition:'tp.date.tomorrow(format: string = "YYYY-MM-DD")',args:[{name:"format",description:'The format for the date. Defaults to `"YYYY-MM-DD"`. Refer to the [Momentjs format reference](https://momentjs.com/docs/#/displaying/format/).'}],examples:[{name:"Date tomorrow",example:"<% tp.date.tomorrow() %>"},{name:"Date tomorrow with format",example:'<% tp.date.tomorrow("Do MMMM YYYY") %>'}]},yesterday:{name:"yesterday",description:"Retrieves yesterday's date.",definition:'tp.date.yesterday(format: string = "YYYY-MM-DD")',args:[{name:"format",description:'The format for the date. Defaults to `"YYYY-MM-DD"`. Refer to the [Momentjs format reference](https://momentjs.com/docs/#/displaying/format/).'}],examples:[{name:"Date yesterday",example:"<% tp.date.yesterday() %>"},{name:"Date yesterday with format",example:'<% tp.date.yesterday("Do MMMM YYYY") %>'}]},weekday:{name:"weekday",description:"",definition:'tp.date.weekday(format: string = "YYYY-MM-DD", weekday: number, reference?: string, reference_format?: string)',args:[{name:"format",description:'The format for the date. Defaults to `"YYYY-MM-DD"`. Refer to the [Momentjs format reference](https://momentjs.com/docs/#/displaying/format/).'},{name:"weekday",description:"Week day number. If the locale assigns Monday as the first day of the week, `0` will be Monday, `-7` will be last week's day."},{name:"reference",description:"The reference date to use instead of today, e.g. set this to the note's title."},{name:"reference_format",description:"The format for the reference date. Refer to the [Momentjs format reference](https://momentjs.com/docs/#/displaying/format/)."}],examples:[{name:"This week's Monday",example:'<% tp.date.weekday("YYYY-MM-DD", 0) %>'},{name:"Next Monday",example:'<% tp.date.weekday("YYYY-MM-DD", 7)
You can navigate between the different cursors using the configured hotkey in Obsidian settings.
`,definition:"tp.file.cursor(order?: number)",args:[{name:"order",description:`The order of the different cursors jump, e.g. it will jump from 1 to 2 to 3, and so on.
If you specify multiple tp.file.cursor with the same order, the editor will switch to multi-cursor.
`}],examples:[{name:"File cursor",example:"<% tp.file.cursor() %>"},{name:"File multi-cursor",example:"<% tp.file.cursor(1) %>Content<% tp.file.cursor(1) %>"}]},cursor_append:{name:"cursor_append",description:"Appends some content after the active cursor in the file.",definition:"tp.file.cursor_append(content: string)",args:[{name:"content",description:"The content to append after the active cursor."}],examples:[{name:"File cursor append",example:'<% tp.file.cursor_append("Some text") %>'}]},exists:{name:"exists",description:"Check to see if a file exists by it's file path. The full path to the file, relative to the Vault and containing the extension, must be provided.",definition:"tp.file.exists(filepath: string)",args:[{name:"filepath",description:"The full file path of the file we want to check existence for."}],examples:[{name:"File existence",example:'<% await tp.file.exists("MyFolder/MyFile.md") %>'},{name:"File existence of current file",example:'<% await tp.file.exists(tp.file.folder(true) + "/" + tp.file.title + ".md") %>'}]},find_tfile:{name:"find_tfile",description:"Search for a file and returns its `TFile` instance.",definition:"tp.file.find_tfile(filename: string)",args:[{name:"filename",description:"The filename we want to search and resolve as a `TFile`."}],examples:[{name:"File find TFile",example:'<% tp.file.find_tfile("MyFile").basename %>'}]},folder:{name:"folder",description:"Retrieves the file's folder name.",definition:"tp.file.folder(absolute: boolean = false)",args:[{name:"absolute",description:"If set to `true`, returns the vault-absolute path of the folder. If `false`, only returns the basename of the folder (the last part). Defaults to `false`."}],examples:[{name:"File folder (Folder)",example:"<% tp.file.folder() %>"},{name:"File folder with vault-absolute path (Path/To/Folder)",example:"<% tp.file.folder(true) %>"}]},include:{name:"include",description:"Includes the file's link content. Templates in the included content will be resolved.",definition:"tp.file.include(include_link: string | TFile)",args:[{name:"include_link",description:'The link to the file to include, e.g. `"[[MyFile]]"`, or a TFile object. Also supports sections or blocks inclusions.'}],examples:[{name:"File include",example:'<% await tp.file.include("[[Template1]]") %>'},{name:"File include TFile",example:'<% await tp.file.include(tp.file.find_tfile("MyFile")) %>'},{name:"File include section",example:'<% await tp.file.include("[[MyFile#Section1]]") %>'},{name:"File include block",example:'<% await tp.file.include("[[MyFile#^block1]]") %>'}]},last_modified_date:{name:"last_modified_date",description:"Retrieves the file's last modification date.",definition:'tp.file.last_modified_date(format: string = "YYYY-MM-DD HH:mm")',args:[{name:"format",description:'The format for the date. Defaults to `"YYYY-MM-DD HH:mm"`. Refer to [format reference](https://momentjs.com/docs/#/displaying/format/).'}],examples:[{name:"File last modified date",example:"<% tp.file.last_modified_date() %>"},{name:"File last modified date with format",example:'<% tp.file.last_modified_date("dddd Do MMMM YYYY HH:mm") %>'}]},move:{name:"move",description:"Moves the file to the desired vault location.",definition:"tp.file.move(new_path: string, file_to_move?: TFile)",args:[{name:"new_path",description:'The new vault relative path of the file, without the file extension. Note: the new path needs to include the folder and the filename, e.g. `"/Notes/MyNote"`.'},{name:"file_to_move",description:"The file to move, defaults to the current file."}],examples:[{name:"File move",example:'<%* await tp.file.move("/A/B/" + tp.file.title) %>'},{name:"File move and rename",example:'<%* await tp.file.move("/A/B/NewTitle") %>'}]},path:{name:"path",description:"Retrieves the file's absolute path on the system.",definition:"tp.file.path(relative: boolean = false)",args:[{name:"relative",description:"If set to `true`, only retrieves the vault's relative path."}],examples:[{name:"File path",example:"<% tp.file.path() %>"},{name:"File relative path (relative to vault root)",exa
let value = await tp.system.prompt("Please enter a value");
%>
# <% value %>
selected value: <% value %>`}]},suggester:{name:"suggester",description:"Spawns a suggester prompt and returns the user's chosen item.",definition:'tp.system.suggester(text_items: string[] | ((item: T) => string), items: T[], throw_on_cancel: boolean = false, placeholder: string = "", limit?: number = undefined, default_value?: T = undefined)',args:[{name:"text_items",description:"Array of strings representing the text that will be displayed for each item in the suggester prompt. This can also be a function that maps an item to its text representation."},{name:"items",description:"Array containing the values of each item in the correct order."},{name:"throw_on_cancel",description:"Throws an error if the prompt is canceled, instead of returning a `null` value."},{name:"placeholder",description:"Placeholder string of the prompt."},{name:"limit",description:"Limit the number of items rendered at once (useful to improve performance when displaying large lists)."},{name:"default_value",description:"Default value to initialize the suggester with."}],examples:[{name:"Suggester",example:'<% await tp.system.suggester(["Happy", "Sad", "Confused"], ["Happy", "Sad", "Confused"]) %>'},{name:"Suggester with mapping function (same as above example)",example:'<% await tp.system.suggester((item) => item, ["Happy", "Sad", "Confused"]) %>'},{name:"Suggester for files",example:"[[<% (await tp.system.suggester((item) => item.basename, tp.app.vault.getMarkdownFiles())).basename %>]]"},{name:"Suggester for tags",example:'<% await tp.system.suggester(item => item, Object.keys(tp.app.metadataCache.getTags()).map(x => x.replace("#", ""))) %>'},{name:"Reuse value from suggester",example:`<%*
let selectedValue = await tp.system.suggester(["Happy", "Sad", "Confused"], ["Happy", "Sad", "Confused"]);
%>
# <% selectedValue %>
selected value: <% selectedValue %>`},{name:"Default value for the suggester",example:`<%*
let selectedValue = await tp.system.suggester(["Happy", "Sad", "Confused"], ["Happy", "Sad", "Confused"], false, "", undefined, "Confused");
%>
# <% selectedValue %>
selected value: <% selectedValue %>`}]},multi_suggester:{name:"multi_suggester",description:"Spawns a suggester prompt that supports selecting multiple items and returns the user's chosen items.",definition:'tp.system.multi_suggester(text_items: string[] | ((item: T) => string), items: T[], throw_on_cancel: boolean = false, title: string = "", limit?: number = undefined, default_values?: T[] = undefined)',args:[{name:"text_items",description:"Array of strings representing the text that will be displayed for each item in the suggester prompt. This can also be a function that maps an item to its text representation."},{name:"items",description:"Array containing the values of each item in the correct order."},{name:"throw_on_cancel",description:"Throws an error if the prompt is canceled, instead of returning a `null` value."},{name:"title",description:"Text placed at the top of the modal."},{name:"limit",description:"Limit the number of items rendered at once (useful to improve performance when displaying large lists)."},{name:"default_values",description:"Default values to initialize the suggester with."}],examples:[{name:"Multi-suggester",example:'<% await tp.system.multi_suggester(["Happy", "Sad", "Confused"], ["Happy", "Sad", "Confused"]) %>'},{name:"Multi-suggester with mapping function (same as above example)",example:'<% await tp.system.multi_suggester((item) => item, ["Happy", "Sad", "Confused"]) %>'},{name:"Multi-suggester for files",example:"<% (await tp.system.multi_suggester((item) => item.basename, tp.app.vault.getMarkdownFiles())).map(f => `[[${f.basename}]]`) %>"},{name:"Multi-suggester for tags",example:'<% await tp.system.multi_suggester(item => item, Object.keys(tp.app.metadataCache.getTags()).map(x => x.replace("#", ""))) %>'},{name:"Reuse value from multi-suggester",example:`<%*
let selectedValues = await tp.system.multi_suggester(["Happy", "Sad", "Confused"], ["Happy", "Sad", "Confused"]);
%>
# <% selectedValues %>
selected values: <% selectedValues %>`},{name:"Default value for the suggester",example:`<%*
let selectedValue = await tp.system.multi_suggester(["Happy", "Sad", "Confused"], ["Happy", "Sad", "Confused"], false, "", undefined, ["Happy", "Confused"]);
%>
# <% selectedValue %>
selected value: <% selectedValue %>`}]}}},web:{name:"web",description:"This modules contains every internal function related to the web (making web requests).",functions:{daily_quote:{name:"daily_quote",description:"Retrieves and parses the daily quote from `https://github.com/Zachatoo/quotes-database` as a callout.",definition:"tp.web.daily_quote()",examples:[{name:"Daily quote",example:"<% await tp.web.daily_quote() %>"}]},random_picture:{name:"random_picture",description:"Gets a random image from `https://unsplash.com/`.",definition:"tp.web.random_picture(size?: string, query?: string, include_size?: boolean)",args:[{name:"size",description:"Image size in the format `<width>x<height>`."},{name:"query",description:"Limits selection to photos matching a search term. Multiple search terms can be passed separated by a comma."},{name:"include_size",description:"Optional argument to include the specified size in the image link markdown. Defaults to false."}],examples:[{name:"Random picture",example:"<% await tp.web.random_picture() %>"},{name:"Random picture with size",example:'<% await tp.web.random_picture("200x200") %>'},{name:"Random picture with size and query",example:'<% await tp.web.random_picture("200x200", "landscape,water") %>'}]},request:{name:"request",description:"Makes a HTTP request to the specified URL. Optionally, you can specify a path to extract specific data from the response.",definition:"tp.web.request(url: string, path?: string)",args:[{name:"url",description:"The URL to which the HTTP request will be made."},{name:"path",description:"A path within the response JSON to extract specific data."}],examples:[{name:"Simple request",example:'<% await tp.web.request("https://jsonplaceholder.typicode.com/todos/1") %>'},{name:"Request with path",example:'<% await tp.web.request("https://jsonplaceholder.typicode.com/todos", "0.title") %>'}]}}}},di={tp:Yo};var Go=["app","config","date","file","frontmatter","hooks","obsidian","system","user","web"],Ro=new Set(Go);function mr(r){return typeof r=="string"&&Ro.has(r)}function gi(r){return!!(r.definition||r.returns||r.args)}var hr=class{constructor(e){this.plugin=e;this.documentation=di}get_all_modules_documentation(){let e=this.documentation.tp,t=Object.values(e);return(!this.plugin.settings||!this.plugin.settings.user_scripts_folder)&&(t=t.filter(n=>n.name!=="user")),t.map(n=>(n.queryKey=n.name,n))}async get_all_functions_documentation(e,t){if(e==="app")return this.get_app_functions_documentation(this.plugin.app,t);if(e==="user"){if(!this.plugin.settings||!this.plugin.settings.user_scripts_folder)return;let n=await se(async()=>{let i=je(this.plugin.app,this.plugin.settings.user_scripts_folder).filter(s=>s.extension=="js");return await Wr(this.plugin.app,i)},"User Scripts folder doesn't exist");return!n||n.length===0?void 0:n.reduce((i,o)=>o.extension!=="js"?i:[...i,{name:o.basename,queryKey:o.basename,definition:"",description:o.description,returns:o.returns,args:o.arguments.reduce((l,u)=>(l[u.name]={name:u.name,description:u.description},l),{}),example:""}],[])}if(!!this.documentation.tp[e].functions)return Object.values(this.documentation.tp[e].functions).map(n=>(n.queryKey=n.name,n))}get_app_functions_documentation(e,t){if(!St(e))return[];let n=t.split(".");if(n.length===0)return[];let i=e;for(let u=0;u<n.length-1;u++){let d=n[u];if(d in i){let h=i[d];if(!St(h))return[];i=h}}let o=["tp","app",...n.slice(0,n.length-1)].join("."),s=n.slice(0,n.length-1).join("."),l=[];for(let u in i){let d=`${o}.${u}`,h=s?`${s}.${u}`:u;l.push({name:u,queryKey:h,definition:typeof i[u]=="function"?`${d}(${Qr(i[u]).join(", ")})`:d,description:"",returns:"",example:""})}return l}get_module_documentation(e){return this.documentation.tp[e]}get_function_documentation(e,t){return this.documentation.tp[e].functions[t]}get_argument_documentation(e,t,n){let i=this.get_function_documentation(e,t);return!i||!i.args?null:i.args[n]}};var Ar=class extends mi.EditorSuggest{constructor(e){super(e.app);this.tp_keyword_regex=/tp\.(?<module>[a-z]*)?(?<fn_trigger>\.(?<fn>[a-zA-Z_.]*)?)?$/;this.module
/* nosourcemap */