/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var _i=Object.create;var xt=Object.defineProperty;var zi=Object.getOwnPropertyDescriptor;var Mi=Object.getOwnPropertyNames;var vi=Object.getPrototypeOf,Ni=Object.prototype.hasOwnProperty;var Vt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),$n=(e,t)=>{for(var n in t)xt(e,n,{get:t[n],enumerable:!0})},qn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Mi(t))!Ni.call(e,i)&&i!==n&&xt(e,i,{get:()=>t[i],enumerable:!(r=zi(t,i))||r.enumerable});return e};var yt=(e,t,n)=>(n=e!=null?_i(vi(e)):{},qn(t||!e||!e.__esModule?xt(n,"default",{value:e,enumerable:!0}):n,e)),Ui=e=>qn(xt({},"__esModule",{value:!0}),e);var Yn=Vt((as,$t)=>{(function(){var e;typeof $t!="undefined"?e=$t.exports=r:e=function(){return this||(0,eval)("this")}(),e.format=r,e.vsprintf=n,typeof console!="undefined"&&typeof console.log=="function"&&(e.printf=t);function t(){console.log(r.apply(null,arguments))}function n(i,u){return r.apply(null,[i].concat(u))}function r(i){for(var u=1,o=[].slice.call(arguments),s=0,p=i.length,a="",l,h=!1,f,c,F=!1,g,C=function(){return o[u++]},y=function(){for(var b="";/\d/.test(i[s]);)b+=i[s++],l=i[s];return b.length>0?parseInt(b):null};s{$r.exports=function(t){return t!=null&&t.constructor!=null&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}});var Gr=Vt((oh,Xr)=>{"use strict";var Lt=Object.prototype.hasOwnProperty,Zr=Object.prototype.toString,qr=Object.defineProperty,Hr=Object.getOwnPropertyDescriptor,Yr=function(t){return typeof Array.isArray=="function"?Array.isArray(t):Zr.call(t)==="[object Array]"},Qr=function(t){if(!t||Zr.call(t)!=="[object Object]")return!1;var n=Lt.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Lt.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i=="undefined"||Lt.call(t,i)},Wr=function(t,n){qr&&n.name==="__proto__"?qr(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},Kr=function(t,n){if(n==="__proto__")if(Lt.call(t,n)){if(Hr)return Hr(t,n).value}else return;return t[n]};Xr.exports=function e(){var t,n,r,i,u,o,s=arguments[0],p=1,a=arguments.length,l=!1;for(typeof s=="boolean"&&(l=s,s=arguments[1]||{},p=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});pMt,default:()=>vt});module.exports=Ui(Xo);var ue=require("obsidian");var N=require("obsidian");var je={children(e){return e.children},annotatetextnode(e,t){return e.type==="text"?{offset:{end:e.position.end.offset,start:e.position.start.offset},text:t.substring(e.position.start.offset,e.position.end.offset)}:null},interpretmarkup(e=""){return e}};function ji(e,t,n=je){let r=[];function i(u){let o=n.annotatetextnode(u,t);o!==null&&r.push(o);let s=n.children(u);s!==null&&Array.isArray(s)&&s.forEach(i)}return i(e),r}function Vi(e,t,n=je){let r=[],i={offset:{end:0,start:0}};for(let o of t){let s=e.substring(i.offset.end,o.offset.start);r.push({interpretAs:n.interpretmarkup(s),markup:s,offset:{end:o.offset.start,start:i.offset.end}}),r.push(o),i=o}let u=e.substring(i.offset.end,e.length);return r.push({interpretAs:n.interpretmarkup(u),markup:u,offset:{end:e.length,start:i.offset.end}}),{annotation:r}}function Hn(e,t,n=je){let r=ji(t,e,n);return Vi(e,r,n)}var Jo=ye(/[A-Za-z]/),es=ye(/[\dA-Za-z]/),ts=ye(/[#-'*+\--9=?A-Z^-~]/);var ns=ye(/\d/),rs=ye(/[\dA-Fa-f]/),is=ye(/[!-/:-@[-`{-~]/);function nt(e){return e!==null&&e<-2}function rt(e){return e===-2||e===-1||e===32}var us=ye(/\p{P}|\p{S}/u),os=ye(/\s/);function ye(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}var Qn=yt(Yn(),1),it=Object.assign(Le(Error),{eval:Le(EvalError),range:Le(RangeError),reference:Le(ReferenceError),syntax:Le(SyntaxError),type:Le(TypeError),uri:Le(URIError)});function Le(e){return t.displayName=e.displayName||e.name,t;function t(n,...r){let i=n&&(0,Qn.default)(n,...r);return new e(i)}}var Et={}.hasOwnProperty,Wn={yaml:"-",toml:"+"};function Ve(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:["yaml"];for(;++ni?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);u0?(Z(e,e.length,0,t),e):t}var Jn={}.hasOwnProperty;function er(e){let t={},n=-1;for(;++no))return;let w=t.events.length,L=w,B,q;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(B){q=t.events[L][1].end;break}B=!0}for(y(r),x=w;xA;){let R=n[T];t.containerState=R[1],R[0].exit.call(t,e)}n.length=A}function b(){i.write([null]),u=void 0,i=void 0,t.containerState._closeFlow=void 0}}function ru(e,t,n){return P(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var or=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;var re=Ae(/[A-Za-z]/),ee=Ae(/[\dA-Za-z]/),sr=Ae(/[#-'*+\--9=?A-Z^-~]/);function ar(e){return e!==null&&(e<32||e===127)}var ut=Ae(/\d/),lr=Ae(/[\dA-Fa-f]/),cr=Ae(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function W(e){return e!==null&&(e<0||e===32)}function M(e){return e===-2||e===-1||e===32}var pr=Ae(or),hr=Ae(/\s/);function Ae(e){return t;function t(n){return n!==null&&e.test(String.fromCharCode(n))}}function Gt(e){if(e===null||W(e)||hr(e))return 1;if(pr(e))return 2}function qe(e,t,n){let r=[],i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let h=Object.assign({},e[r][1].end),f=Object.assign({},e[n][1].start);fr(h,-p),fr(f,p),o={type:p>1?"strongSequence":"emphasisSequence",start:h,end:Object.assign({},e[r][1].end)},s={type:p>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[n][1].start),end:f},u={type:p>1?"strongText":"emphasisText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},i={type:p>1?"strong":"emphasis",start:Object.assign({},o.start),end:Object.assign({},s.end)},e[r][1].end=Object.assign({},o.start),e[n][1].start=Object.assign({},s.end),a=[],e[r][1].end.offset-e[r][1].start.offset&&(a=J(a,[["enter",e[r][1],t],["exit",e[r][1],t]])),a=J(a,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",u,t]]),a=J(a,qe(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),a=J(a,[["exit",u,t],["enter",s,t],["exit",s,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(l=2,a=J(a,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,Z(e,r-1,n-r+3,a),n=r+a.length-l-2;break}}for(n=-1;++n0&&M(x)?P(e,b,"linePrefix",u+1)(x):b(x)}function b(x){return x===null||D(x)?e.check(dr,g,T)(x):(e.enter("codeFlowValue"),A(x))}function A(x){return x===null||D(x)?(e.exit("codeFlowValue"),b(x)):(e.consume(x),A)}function T(x){return e.exit("codeFenced"),t(x)}function R(x,w,L){let B=0;return q;function q(I){return x.enter("lineEnding"),x.consume(I),x.exit("lineEnding"),V}function V(I){return x.enter("codeFencedFence"),M(I)?P(x,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):z(I)}function z(I){return I===s?(x.enter("codeFencedFenceSequence"),S(I)):L(I)}function S(I){return I===s?(B++,x.consume(I),S):B>=o?(x.exit("codeFencedFenceSequence"),M(I)?P(x,_,"whitespace")(I):_(I)):L(I)}function _(I){return I===null||D(I)?(x.exit("codeFencedFence"),w(I)):L(I)}}}function mu(e,t,n){let r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),u)}function u(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}var st={name:"codeIndented",tokenize:gu},du={tokenize:xu,partial:!0};function gu(e,t,n){let r=this;return i;function i(a){return e.enter("codeIndented"),P(e,u,"linePrefix",5)(a)}function u(a){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?o(a):n(a)}function o(a){return a===null?p(a):D(a)?e.attempt(du,o,p)(a):(e.enter("codeFlowValue"),s(a))}function s(a){return a===null||D(a)?(e.exit("codeFlowValue"),o(a)):(e.consume(a),s)}function p(a){return e.exit("codeIndented"),t(a)}}function xu(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):D(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):P(e,u,"linePrefix",5)(o)}function u(o){let s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):D(o)?i(o):n(o)}}var en={name:"codeText",tokenize:Fu,resolve:yu,previous:Eu};function yu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}var gr=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;var Ja=we(/[A-Za-z]/),el=we(/[\dA-Za-z]/),tl=we(/[#-'*+\--9=?A-Z^-~]/);function nn(e){return e!==null&&(e<32||e===127)}var nl=we(/\d/),rl=we(/[\dA-Fa-f]/),il=we(/[!-/:-@[-`{-~]/);function xr(e){return e!==null&&e<-2}function yr(e){return e!==null&&(e<0||e===32)}var ul=we(gr),ol=we(/\s/);function we(e){return t;function t(n){return n!==null&&e.test(String.fromCharCode(n))}}function St(e,t,n,r,i,u,o,s,p){let a=p||Number.POSITIVE_INFINITY,l=0;return h;function h(y){return y===60?(e.enter(r),e.enter(i),e.enter(u),e.consume(y),e.exit(u),f):y===null||y===32||y===41||nn(y)?n(y):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),g(y))}function f(y){return y===62?(e.enter(u),e.consume(y),e.exit(u),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),c(y))}function c(y){return y===62?(e.exit("chunkString"),e.exit(s),f(y)):y===null||y===60||xr(y)?n(y):(e.consume(y),y===92?F:c)}function F(y){return y===60||y===62||y===92?(e.consume(y),c):c(y)}function g(y){return!l&&(y===null||y===41||yr(y))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(y)):l999||c===null||c===91||c===93&&!p||c===94&&!s&&"_hiddenFootnoteSupport"in o.parser.constructs?n(c):c===93?(e.exit(u),e.enter(i),e.consume(c),e.exit(i),e.exit(r),t):rn(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),h(c))}function h(c){return c===null||c===91||c===93||rn(c)||s++>999?(e.exit("chunkString"),l(c)):(e.consume(c),p||(p=!Fr(c)),c===92?f:h)}function f(c){return c===91||c===92||c===93?(e.consume(c),s++,h):h(c)}}var Ar=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;var bl=be(/[A-Za-z]/),Sl=be(/[\dA-Za-z]/),Dl=be(/[#-'*+\--9=?A-Z^-~]/);var Tl=be(/\d/),Ol=be(/[\dA-Fa-f]/),Bl=be(/[!-/:-@[-`{-~]/);function un(e){return e!==null&&e<-2}var Pl=be(Ar),Ll=be(/\s/);function be(e){return t;function t(n){return n!==null&&e.test(String.fromCharCode(n))}}function Tt(e,t,n,r,i,u){let o;return s;function s(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,p):n(f)}function p(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(u),a(f))}function a(f){return f===o?(e.exit(u),p(o)):f===null?n(f):un(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),P(e,a,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(f))}function l(f){return f===o||f===null||un(f)?(e.exit("chunkString"),a(f)):(e.consume(f),f===92?h:l)}function h(f){return f===o||f===92?(e.consume(f),l):l(f)}}var Cr=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;var Nl=Se(/[A-Za-z]/),Ul=Se(/[\dA-Za-z]/),jl=Se(/[#-'*+\--9=?A-Z^-~]/);var Vl=Se(/\d/),$l=Se(/[\dA-Fa-f]/),ql=Se(/[!-/:-@[-`{-~]/);function wr(e){return e!==null&&e<-2}function kr(e){return e===-2||e===-1||e===32}var Hl=Se(Cr),Yl=Se(/\s/);function Se(e){return t;function t(n){return n!==null&&e.test(String.fromCharCode(n))}}function Ie(e,t){let n;return r;function r(i){return wr(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):kr(i)?P(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function de(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var on={name:"definition",tokenize:Du},Su={tokenize:Tu,partial:!0};function Du(e,t,n){let r=this,i;return u;function u(c){return e.enter("definition"),o(c)}function o(c){return Dt.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(c)}function s(c){return i=de(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),c===58?(e.enter("definitionMarker"),e.consume(c),e.exit("definitionMarker"),p):n(c)}function p(c){return W(c)?Ie(e,a)(c):a(c)}function a(c){return St(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(c)}function l(c){return e.attempt(Su,h,h)(c)}function h(c){return M(c)?P(e,f,"whitespace")(c):f(c)}function f(c){return c===null||D(c)?(e.exit("definition"),r.parser.defined.push(i),t(c)):n(c)}}function Tu(e,t,n){return r;function r(s){return W(s)?Ie(e,i)(s):n(s)}function i(s){return Tt(e,u,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function u(s){return M(s)?P(e,o,"whitespace")(s):o(s)}function o(s){return s===null||D(s)?t(s):n(s)}}var sn={name:"hardBreakEscape",tokenize:Ou};function Ou(e,t,n){return r;function r(u){return e.enter("hardBreakEscape"),e.consume(u),i}function i(u){return D(u)?(e.exit("hardBreakEscape"),t(u)):n(u)}}var an={name:"headingAtx",tokenize:Pu,resolve:Bu};function Bu(e,t){let n=e.length-2,r=3,i,u;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},u={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Z(e,r,n-r+1,[["enter",i,t],["enter",u,t],["exit",u,t],["exit",i,t]])),e}function Pu(e,t,n){let r=0;return i;function i(l){return e.enter("atxHeading"),u(l)}function u(l){return e.enter("atxHeadingSequence"),o(l)}function o(l){return l===35&&r++<6?(e.consume(l),o):l===null||W(l)?(e.exit("atxHeadingSequence"),s(l)):n(l)}function s(l){return l===35?(e.enter("atxHeadingSequence"),p(l)):l===null||D(l)?(e.exit("atxHeading"),t(l)):M(l)?P(e,s,"whitespace")(l):(e.enter("atxHeadingText"),a(l))}function p(l){return l===35?(e.consume(l),p):(e.exit("atxHeadingSequence"),s(l))}function a(l){return l===null||l===35||W(l)?(e.exit("atxHeadingText"),s(l)):(e.consume(l),a)}}var br=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ln=["pre","script","style","textarea"];var cn={name:"htmlFlow",tokenize:_u,resolveTo:Ru,concrete:!0},Lu={tokenize:Mu,partial:!0},Iu={tokenize:zu,partial:!0};function Ru(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function _u(e,t,n){let r=this,i,u,o,s,p;return a;function a(d){return l(d)}function l(d){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(d),h}function h(d){return d===33?(e.consume(d),f):d===47?(e.consume(d),u=!0,g):d===63?(e.consume(d),i=3,r.interrupt?t:m):re(d)?(e.consume(d),o=String.fromCharCode(d),C):n(d)}function f(d){return d===45?(e.consume(d),i=2,c):d===91?(e.consume(d),i=5,s=0,F):re(d)?(e.consume(d),i=4,r.interrupt?t:m):n(d)}function c(d){return d===45?(e.consume(d),r.interrupt?t:m):n(d)}function F(d){let ne="CDATA[";return d===ne.charCodeAt(s++)?(e.consume(d),s===ne.length?r.interrupt?t:z:F):n(d)}function g(d){return re(d)?(e.consume(d),o=String.fromCharCode(d),C):n(d)}function C(d){if(d===null||d===47||d===62||W(d)){let ne=d===47,Ne=o.toLowerCase();return!ne&&!u&&ln.includes(Ne)?(i=1,r.interrupt?t(d):z(d)):br.includes(o.toLowerCase())?(i=6,ne?(e.consume(d),y):r.interrupt?t(d):z(d)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(d):u?b(d):A(d))}return d===45||ee(d)?(e.consume(d),o+=String.fromCharCode(d),C):n(d)}function y(d){return d===62?(e.consume(d),r.interrupt?t:z):n(d)}function b(d){return M(d)?(e.consume(d),b):q(d)}function A(d){return d===47?(e.consume(d),q):d===58||d===95||re(d)?(e.consume(d),T):M(d)?(e.consume(d),A):q(d)}function T(d){return d===45||d===46||d===58||d===95||ee(d)?(e.consume(d),T):R(d)}function R(d){return d===61?(e.consume(d),x):M(d)?(e.consume(d),R):A(d)}function x(d){return d===null||d===60||d===61||d===62||d===96?n(d):d===34||d===39?(e.consume(d),p=d,w):M(d)?(e.consume(d),x):L(d)}function w(d){return d===p?(e.consume(d),p=null,B):d===null||D(d)?n(d):(e.consume(d),w)}function L(d){return d===null||d===34||d===39||d===47||d===60||d===61||d===62||d===96||W(d)?R(d):(e.consume(d),L)}function B(d){return d===47||d===62||M(d)?A(d):n(d)}function q(d){return d===62?(e.consume(d),V):n(d)}function V(d){return d===null||D(d)?z(d):M(d)?(e.consume(d),V):n(d)}function z(d){return d===45&&i===2?(e.consume(d),H):d===60&&i===1?(e.consume(d),Q):d===62&&i===4?(e.consume(d),oe):d===63&&i===3?(e.consume(d),m):d===93&&i===5?(e.consume(d),ce):D(d)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Lu,pe,S)(d)):d===null||D(d)?(e.exit("htmlFlowData"),S(d)):(e.consume(d),z)}function S(d){return e.check(Iu,_,pe)(d)}function _(d){return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),I}function I(d){return d===null||D(d)?S(d):(e.enter("htmlFlowData"),z(d))}function H(d){return d===45?(e.consume(d),m):z(d)}function Q(d){return d===47?(e.consume(d),o="",se):z(d)}function se(d){if(d===62){let ne=o.toLowerCase();return ln.includes(ne)?(e.consume(d),oe):z(d)}return re(d)&&o.length<8?(e.consume(d),o+=String.fromCharCode(d),se):z(d)}function ce(d){return d===93?(e.consume(d),m):z(d)}function m(d){return d===62?(e.consume(d),oe):d===45&&i===2?(e.consume(d),m):z(d)}function oe(d){return d===null||D(d)?(e.exit("htmlFlowData"),pe(d)):(e.consume(d),oe)}function pe(d){return e.exit("htmlFlow"),t(d)}}function zu(e,t,n){let r=this;return i;function i(o){return D(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),u):n(o)}function u(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Mu(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ce,t,n)}}var pn={name:"htmlText",tokenize:vu};function vu(e,t,n){let r=this,i,u,o;return s;function s(m){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(m),p}function p(m){return m===33?(e.consume(m),a):m===47?(e.consume(m),R):m===63?(e.consume(m),A):re(m)?(e.consume(m),L):n(m)}function a(m){return m===45?(e.consume(m),l):m===91?(e.consume(m),u=0,F):re(m)?(e.consume(m),b):n(m)}function l(m){return m===45?(e.consume(m),c):n(m)}function h(m){return m===null?n(m):m===45?(e.consume(m),f):D(m)?(o=h,Q(m)):(e.consume(m),h)}function f(m){return m===45?(e.consume(m),c):h(m)}function c(m){return m===62?H(m):m===45?f(m):h(m)}function F(m){let oe="CDATA[";return m===oe.charCodeAt(u++)?(e.consume(m),u===oe.length?g:F):n(m)}function g(m){return m===null?n(m):m===93?(e.consume(m),C):D(m)?(o=g,Q(m)):(e.consume(m),g)}function C(m){return m===93?(e.consume(m),y):g(m)}function y(m){return m===62?H(m):m===93?(e.consume(m),y):g(m)}function b(m){return m===null||m===62?H(m):D(m)?(o=b,Q(m)):(e.consume(m),b)}function A(m){return m===null?n(m):m===63?(e.consume(m),T):D(m)?(o=A,Q(m)):(e.consume(m),A)}function T(m){return m===62?H(m):A(m)}function R(m){return re(m)?(e.consume(m),x):n(m)}function x(m){return m===45||ee(m)?(e.consume(m),x):w(m)}function w(m){return D(m)?(o=w,Q(m)):M(m)?(e.consume(m),w):H(m)}function L(m){return m===45||ee(m)?(e.consume(m),L):m===47||m===62||W(m)?B(m):n(m)}function B(m){return m===47?(e.consume(m),H):m===58||m===95||re(m)?(e.consume(m),q):D(m)?(o=B,Q(m)):M(m)?(e.consume(m),B):H(m)}function q(m){return m===45||m===46||m===58||m===95||ee(m)?(e.consume(m),q):V(m)}function V(m){return m===61?(e.consume(m),z):D(m)?(o=V,Q(m)):M(m)?(e.consume(m),V):B(m)}function z(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,S):D(m)?(o=z,Q(m)):M(m)?(e.consume(m),z):(e.consume(m),_)}function S(m){return m===i?(e.consume(m),i=void 0,I):m===null?n(m):D(m)?(o=S,Q(m)):(e.consume(m),S)}function _(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||W(m)?B(m):(e.consume(m),_)}function I(m){return m===47||m===62||W(m)?B(m):n(m)}function H(m){return m===62?(e.consume(m),e.exit("htmlTextData"),e.exit("htmlText"),t):n(m)}function Q(m){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),se}function se(m){return M(m)?P(e,ce,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):ce(m)}function ce(m){return e.enter("htmlTextData"),o(m)}}var Re={name:"labelEnd",tokenize:qu,resolveTo:$u,resolveAll:Vu},Nu={tokenize:Hu},Uu={tokenize:Yu},ju={tokenize:Qu};function Vu(e){let t=-1;for(;++t=3&&(a===null||D(a))?(e.exit("thematicBreak"),t(a)):n(a)}function p(a){return a===i?(e.consume(a),r++,p):(e.exit("thematicBreakSequence"),M(a)?P(e,s,"whitespace")(a):s(a))}}var X={name:"list",tokenize:eo,continuation:{tokenize:to},exit:ro},Gu={tokenize:io,partial:!0},Ju={tokenize:no,partial:!0};function eo(e,t,n){let r=this,i=r.events[r.events.length-1],u=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(c){let F=r.containerState.type||(c===42||c===43||c===45?"listUnordered":"listOrdered");if(F==="listUnordered"?!r.containerState.marker||c===r.containerState.marker:ut(c)){if(r.containerState.type||(r.containerState.type=F,e.enter(F,{_container:!0})),F==="listUnordered")return e.enter("listItemPrefix"),c===42||c===45?e.check(_e,n,a)(c):a(c);if(!r.interrupt||c===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(c)}return n(c)}function p(c){return ut(c)&&++o<10?(e.consume(c),p):(!r.interrupt||o<2)&&(r.containerState.marker?c===r.containerState.marker:c===41||c===46)?(e.exit("listItemValue"),a(c)):n(c)}function a(c){return e.enter("listItemMarker"),e.consume(c),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||c,e.check(Ce,r.interrupt?n:l,e.attempt(Gu,f,h))}function l(c){return r.containerState.initialBlankLine=!0,u++,f(c)}function h(c){return M(c)?(e.enter("listItemPrefixWhitespace"),e.consume(c),e.exit("listItemPrefixWhitespace"),f):n(c)}function f(c){return r.containerState.size=u+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(c)}}function to(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Ce,i,u);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,P(e,t,"listItemIndent",r.containerState.size+1)(s)}function u(s){return r.containerState.furtherBlankLines||!M(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ju,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,P(e,e.attempt(X,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function no(e,t,n){let r=this;return P(e,i,"listItemIndent",r.containerState.size+1);function i(u){let o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(u):n(u)}}function ro(e){e.exit(this.containerState.type)}function io(e,t,n){let r=this;return P(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(u){let o=r.events[r.events.length-1];return!M(u)&&o&&o[1].type==="listItemPrefixWhitespace"?t(u):n(u)}}var Ot={name:"setextUnderline",tokenize:oo,resolveTo:uo};function uo(e,t){let n=e.length,r,i,u;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!u&&e[n][1].type==="definition"&&(u=n);let o={type:"setextHeading",start:Object.assign({},e[i][1].start),end:Object.assign({},e[e.length-1][1].end)};return e[i][1].type="setextHeadingText",u?(e.splice(i,0,["enter",o,t]),e.splice(u+1,0,["exit",e[r][1],t]),e[r][1].end=Object.assign({},e[u][1].end)):e[r][1]=o,e.push(["exit",o,t]),e}function oo(e,t,n){let r=this,i;return u;function u(a){let l=r.events.length,h;for(;l--;)if(r.events[l][1].type!=="lineEnding"&&r.events[l][1].type!=="linePrefix"&&r.events[l][1].type!=="content"){h=r.events[l][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=a,o(a)):n(a)}function o(a){return e.enter("setextHeadingLineSequence"),s(a)}function s(a){return a===i?(e.consume(a),s):(e.exit("setextHeadingLineSequence"),M(a)?P(e,p,"lineSuffix")(a):p(a))}function p(a){return a===null||D(a)?(e.exit("setextHeadingLine"),t(a)):n(a)}}var Sr={tokenize:so};function so(e){let t=this,n=e.attempt(Ce,r,e.attempt(this.parser.constructs.flowInitial,i,P(e,e.attempt(this.parser.constructs.flow,i,e.attempt(tn,i)),"linePrefix")));return n;function r(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),t.currentConstruct=void 0,n}}var Dr={resolveAll:Pr()},Tr=Br("string"),Or=Br("text");function Br(e){return{tokenize:t,resolveAll:Pr(e==="text"?ao:void 0)};function t(n){let r=this,i=this.parser.constructs[e],u=n.attempt(i,o,s);return o;function o(l){return a(l)?u(l):s(l)}function s(l){if(l===null){n.consume(l);return}return n.enter("data"),n.consume(l),p}function p(l){return a(l)?(n.exit("data"),u(l)):(n.consume(l),p)}function a(l){if(l===null)return!0;let h=i[l],f=-1;if(h)for(;++f-1){let s=o[0];typeof s=="string"?o[0]=s.slice(r):o.shift()}u>0&&o.push(e[i].slice(0,u))}return o}function co(e,t){let n=-1,r=[],i;for(;++nEo,contentInitial:()=>ho,disable:()=>Fo,document:()=>po,flow:()=>mo,flowInitial:()=>fo,insideSpan:()=>yo,string:()=>go,text:()=>xo});var po={42:X,43:X,45:X,48:X,49:X,50:X,51:X,52:X,53:X,54:X,55:X,56:X,57:X,62:At},ho={91:on},fo={[-2]:st,[-1]:st,32:st},mo={35:an,42:_e,45:[Ot,_e],60:cn,61:Ot,95:_e,96:kt,126:kt},go={38:wt,92:Ct},xo={[-5]:at,[-4]:at,[-3]:at,33:hn,38:wt,42:ot,60:[Jt,pn],91:fn,92:[sn,Ct],93:Re,95:ot,96:en},yo={null:[ot,Dr]},Eo={null:[42,95]},Fo={null:[]};function Ir(e){let n=er([mn,...(e||{}).extensions||[]]),r={defined:[],lazy:{},constructs:n,content:i(rr),document:i(ur),flow:i(Sr),string:i(Tr),text:i(Or)};return r;function i(u){return o;function o(s){return Lr(r,u,s)}}}var Rr=/[\0\t\n\r]/g;function _r(){let e=1,t="",n=!0,r;return i;function i(u,o,s){let p=[],a,l,h,f,c;for(u=t+u.toString(o),h=0,t="",n&&(u.charCodeAt(0)===65279&&h++,n=void 0);h13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCharCode(n)}var Ao=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Mr(e){return e.replace(Ao,Co)}function Co(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let i=n.charCodeAt(1),u=i===120||i===88;return Bt(n.slice(u?2:1),u?16:10)}return He(n)||e}function De(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?vr(e.position):"start"in e||"end"in e?vr(e):"line"in e||"column"in e?dn(e):""}function dn(e){return Nr(e&&e.line)+":"+Nr(e&&e.column)}function vr(e){return dn(e&&e.start)+"-"+dn(e&&e.end)}function Nr(e){return e&&typeof e=="number"?e:1}var jr={}.hasOwnProperty,gn=function(e,t,n){return typeof t!="string"&&(n=t,t=void 0),wo(n)(zr(Ir(n).document().write(_r()(e,t,!0))))};function wo(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(jn),autolinkProtocol:V,autolinkEmail:V,atxHeading:s(vn),blockQuote:s(Ue),characterEscape:V,characterReference:V,codeFenced:s(Pe),codeFencedFenceInfo:p,codeFencedFenceMeta:p,codeIndented:s(Pe,p),codeText:s(Ut,p),codeTextData:V,data:V,codeFlowValue:V,definition:s(Di),definitionDestinationString:p,definitionLabelString:p,definitionTitleString:p,emphasis:s(Ti),hardBreakEscape:s(Nn),hardBreakTrailing:s(Nn),htmlFlow:s(Un,p),htmlFlowData:V,htmlText:s(Un,p),htmlTextData:V,image:s(Oi),label:p,link:s(jn),listItem:s(Bi),listItemValue:F,listOrdered:s(Vn,c),listUnordered:s(Vn),paragraph:s(Pi),reference:Ne,referenceString:p,resourceDestinationString:p,resourceTitleString:p,setextHeading:s(vn),strong:s(Li),thematicBreak:s(Ri)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:he,autolinkProtocol:Je,blockQuote:l(),characterEscapeValue:z,characterReferenceMarkerHexadecimal:Ge,characterReferenceMarkerNumeric:Ge,characterReferenceValue:K,codeFenced:l(b),codeFencedFence:y,codeFencedFenceInfo:g,codeFencedFenceMeta:C,codeFlowValue:z,codeIndented:l(A),codeText:l(Q),codeTextData:z,data:z,definition:l(),definitionDestinationString:x,definitionLabelString:T,definitionTitleString:R,emphasis:l(),hardBreakEscape:l(_),hardBreakTrailing:l(_),htmlFlow:l(I),htmlFlowData:z,htmlText:l(H),htmlTextData:z,image:l(ce),label:oe,labelText:m,lineEnding:S,link:l(se),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Nt,resourceDestinationString:pe,resourceTitleString:d,resource:ne,setextHeading:l(q),setextHeadingLineSequence:B,setextHeadingText:L,strong:l(),thematicBreak:l()}};Vr(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(E){let k={type:"root",children:[]},O={stack:[k],tokenStack:[],config:t,enter:a,exit:h,buffer:p,resume:f,setData:u,getData:o},U=[],$=-1;for(;++$0){let ae=O.tokenStack[O.tokenStack.length-1];(ae[1]||Ur).call(O,void 0,ae[0])}for(k.position={start:Te(E.length>0?E[0][1].start:{line:1,column:1,offset:0}),end:Te(E.length>0?E[E.length-2][1].end:{line:1,column:1,offset:0})},$=-1;++${let r=this.data("settings");return gn(n,Object.assign({},r,e,{extensions:this.data("micromarkExtensions")||[],mdastExtensions:this.data("fromMarkdownExtensions")||[]}))}})}function xn(e){if(e)throw e}var si=yt(yn(),1),Sn=yt(Gr(),1);function lt(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function En(){let e=[],t={run:n,use:r};return t;function n(...i){let u=-1,o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);s(null,...i);function s(p,...a){let l=e[++u],h=-1;if(p){o(p);return}for(;++ho.length,p;s&&o.push(i);try{p=e.apply(this,o)}catch(a){let l=a;if(s&&n)throw l;return i(l)}s||(p&&p.then&&typeof p.then=="function"?p.then(u,i):p instanceof Error?i(p):u(p))}function i(o,...s){n||(n=!0,t(o,...s))}function u(o){i(null,o)}}var ri=yt(yn(),1);var G=class extends Error{constructor(t,n,r){let i=[null,null],u={start:{line:null,column:null},end:{line:null,column:null}};if(super(),typeof n=="string"&&(r=n,n=void 0),typeof r=="string"){let o=r.indexOf(":");o===-1?i[1]=r:(i[0]=r.slice(0,o),i[1]=r.slice(o+1))}n&&("type"in n||"position"in n?n.position&&(u=n.position):"start"in n||"end"in n?u=n:("line"in n||"column"in n)&&(u.start=n)),this.name=De(n)||"1:1",this.message=typeof t=="object"?t.message:t,this.stack="",typeof t=="object"&&t.stack&&(this.stack=t.stack),this.reason=this.message,this.fatal,this.line=u.start.line,this.column=u.start.column,this.position=u,this.source=i[0],this.ruleId=i[1],this.file,this.actual,this.expected,this.url,this.note}};G.prototype.file="";G.prototype.name="";G.prototype.reason="";G.prototype.message="";G.prototype.stack="";G.prototype.fatal=null;G.prototype.column=null;G.prototype.line=null;G.prototype.source=null;G.prototype.ruleId=null;G.prototype.position=null;var le={basename:bo,dirname:So,extname:Do,join:To,sep:"/"};function bo(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ct(e);let n=0,r=-1,i=e.length,u;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.charCodeAt(i)===47){if(u){n=i+1;break}}else r<0&&(u=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,s=t.length-1;for(;i--;)if(e.charCodeAt(i)===47){if(u){n=i+1;break}}else o<0&&(u=!0,o=i+1),s>-1&&(e.charCodeAt(i)===t.charCodeAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function So(e){if(ct(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.charCodeAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.charCodeAt(0)===47?"/":".":t===1&&e.charCodeAt(0)===47?"//":e.slice(0,t)}function Do(e){ct(e);let t=e.length,n=-1,r=0,i=-1,u=0,o;for(;t--;){let s=e.charCodeAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:u!==1&&(u=1):i>-1&&(u=-1)}return i<0||n<0||u===0||u===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function To(...e){let t=-1,n;for(;++t0&&e.charCodeAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Bo(e,t){let n="",r=0,i=-1,u=0,o=-1,s,p;for(;++o<=e.length;){if(o2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",r=0):(n=n.slice(0,p),r=n.length-1-n.lastIndexOf("/")),i=o,u=0;continue}}else if(n.length>0){n="",r=0,i=o,u=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,u=0}else s===46&&u>-1?u++:u=-1}return n}function ct(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var ei={cwd:Po};function Po(){return"/"}function Ye(e){return e!==null&&typeof e=="object"&&e.href&&e.origin}function ti(e){if(typeof e=="string")e=new URL(e);else if(!Ye(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Lo(e)}function Lo(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let t=e.pathname,n=-1;for(;++n{if(x||!w||!L)R(x);else{let B=u.stringify(w,L);B==null||(zo(B)?L.value=B:L.result=B),R(x,L)}});function R(x,w){x||!w?A(x):b?b(w):C(null,w)}}}function F(g){let C;u.freeze(),wn("processSync",u.Parser),kn("processSync",u.Compiler);let y=ht(g);return u.process(y,b),oi("processSync","process",C),y;function b(A){C=!0,xn(A)}}}function ii(e,t){return typeof e=="function"&&e.prototype&&(Ro(e.prototype)||t in e.prototype)}function Ro(e){let t;for(t in e)if(ai.call(e,t))return!0;return!1}function wn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `Parser`")}function kn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `Compiler`")}function bn(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ui(e){if(!lt(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function oi(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ht(e){return _o(e)?e:new pt(e)}function _o(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function zo(e){return typeof e=="string"||(0,si.default)(e)}var Tn={children(e){return je.children(e)},annotatetextnode(e,t){return je.annotatetextnode(e,t)},interpretmarkup(e=""){return` `.repeat((e.match(/\n/g)||[]).length)},remarkoptions:{}};function ci(e,t=Tn){let n=Dn().use(Pt,t.remarkoptions).use(Ft,["yaml","toml"]).parse(e);return Hn(e,n,t)}var zn=require("obsidian");var Bn=class{add(t,n,r){if(typeof arguments[0]!="string")for(let i in arguments[0])this.add(i,arguments[0][i],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(i){this[i]=this[i]||[],n&&this[i][r?"unshift":"push"](n)},this)}run(t,n){this[t]=this[t]||[],this[t].forEach(function(r){r.call(n&&n.context?n.context:n,n)})}},Pn=class{constructor(t){this.jsep=t,this.registered={}}register(){for(var t=arguments.length,n=new Array(t),r=0;r{if(typeof i!="object"||!i.name||!i.init)throw new Error("Invalid JSEP plugin format");this.registered[i.name]||(i.init(this.jsep),this.registered[i.name]=i)})}},te=class e{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,n,r){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=n,r?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,n){return e.literals[t]=n,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(n=>n.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(t){let n=new Error(t+" at character "+this.index);throw n.index=this.index,n.description=t,n}runHook(t,n){if(e.hooks[t]){let r={context:this,node:n};return e.hooks.run(t,r),r.node}return n}searchHook(t){if(e.hooks[t]){let n={context:this};return e.hooks[t].find(function(r){return r.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),n=t.length===1?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",n)}gobbleExpressions(t){let n=[],r,i;for(;this.index0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.lengthu.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;i.length>2&&l(i[i.length-2]);)s=i.pop(),n=i.pop().value,o=i.pop(),t={type:e.BINARY_EXP,operator:n,left:o,right:s},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+a),i.push(u,t)}for(p=i.length-1,t=i[p];p>1;)t={type:e.BINARY_EXP,operator:i[p-1].value,left:i[p-2],right:t},p-=2;return t}gobbleToken(){let t,n,r,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(n=this.expr.substr(this.index,e.max_unop_len),r=n.length;r>0;){if(e.unary_ops.hasOwnProperty(n)&&(!e.isIdentifierStart(this.code)||this.index+n.length=n.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(u===e.COMMA_CODE){if(this.index++,i++,i!==n.length){if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let o=n.length;o":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});te.max_unop_len=te.getMaxKeyLen(te.unary_ops);te.max_binop_len=te.getMaxKeyLen(te.binary_ops);var ge=e=>new te(e).parse(),No=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(te).filter(e=>!No.includes(e)&&ge[e]===void 0).forEach(e=>{ge[e]=te[e]});ge.Jsep=te;var Uo="ConditionalExpression",jo={name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let r=n.node,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let u=this.gobbleExpression();if(u||this.throwError("Expected expression"),n.node={type:Uo,test:r,consequent:i,alternate:u},r.operator&&e.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=r}}else this.throwError("Expected :")}})}};ge.plugins.register(jo);var pi=47,Vo=92,$o={name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(this.code===pi){let r=++this.index,i=!1;for(;this.index=97&&p<=122||p>=65&&p<=90||p>=48&&p<=57)o+=this.char;else break}let s;try{s=new RegExp(u,o)}catch(p){this.throwError(p.message)}return n.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?i=!0:i&&this.code===e.CBRACK_CODE&&(i=!1),this.index+=this.code===Vo?2:1}this.throwError("Unclosed Regex")}})}},On=43,qo=45,Qe={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[On,qo],assignmentPrecedence:.9,init(e){let t=[e.IDENTIFIER,e.MEMBER_EXP];Qe.assignmentOperators.forEach(r=>e.addBinaryOp(r,Qe.assignmentPrecedence,!0)),e.hooks.add("gobble-token",function(i){let u=this.code;Qe.updateOperators.some(o=>o===u&&o===this.expr.charCodeAt(this.index+1))&&(this.index+=2,i.node={type:"UpdateExpression",operator:u===On?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},(!i.node.argument||!t.includes(i.node.argument.type))&&this.throwError(`Unexpected ${i.node.operator}`))}),e.hooks.add("after-token",function(i){if(i.node){let u=this.code;Qe.updateOperators.some(o=>o===u&&o===this.expr.charCodeAt(this.index+1))&&(t.includes(i.node.type)||this.throwError(`Unexpected ${i.node.operator}`),this.index+=2,i.node={type:"UpdateExpression",operator:u===On?"++":"--",argument:i.node,prefix:!1})}}),e.hooks.add("after-expression",function(i){i.node&&n(i.node)});function n(r){Qe.assignmentOperators.has(r.operator)?(r.type="AssignmentExpression",n(r.left),n(r.right)):r.operator||Object.values(r).forEach(i=>{i&&typeof i=="object"&&n(i)})}}};ge.plugins.register($o,Qe);ge.addUnaryOp("typeof");ge.addLiteral("null",null);ge.addLiteral("undefined",void 0);var Ho=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),j={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return j.evalBinaryExpression(e,t);case"Compound":return j.evalCompound(e,t);case"ConditionalExpression":return j.evalConditionalExpression(e,t);case"Identifier":return j.evalIdentifier(e,t);case"Literal":return j.evalLiteral(e,t);case"MemberExpression":return j.evalMemberExpression(e,t);case"UnaryExpression":return j.evalUnaryExpression(e,t);case"ArrayExpression":return j.evalArrayExpression(e,t);case"CallExpression":return j.evalCallExpression(e,t);case"AssignmentExpression":return j.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression(e,t){return{"||":(r,i)=>r||i(),"&&":(r,i)=>r&&i(),"|":(r,i)=>r|i(),"^":(r,i)=>r^i(),"&":(r,i)=>r&i(),"==":(r,i)=>r==i(),"!=":(r,i)=>r!=i(),"===":(r,i)=>r===i(),"!==":(r,i)=>r!==i(),"<":(r,i)=>r":(r,i)=>r>i(),"<=":(r,i)=>r<=i(),">=":(r,i)=>r>=i(),"<<":(r,i)=>r<>":(r,i)=>r>>i(),">>>":(r,i)=>r>>>i(),"+":(r,i)=>r+i(),"-":(r,i)=>r-i(),"*":(r,i)=>r*i(),"/":(r,i)=>r/i(),"%":(r,i)=>r%i()}[e.operator](j.evalAst(e.left,t),()=>j.evalAst(e.right,t))},evalCompound(e,t){let n;for(let r=0;r-j.evalAst(r,t),"!":r=>!j.evalAst(r,t),"~":r=>~j.evalAst(r,t),"+":r=>+j.evalAst(r,t),typeof:r=>typeof j.evalAst(r,t)}[e.operator](e.argument)},evalArrayExpression(e,t){return e.elements.map(n=>j.evalAst(n,t))},evalCallExpression(e,t){let n=e.arguments.map(i=>j.evalAst(i,t));return j.evalAst(e.callee,t)(...n)},evalAssignmentExpression(e,t){if(e.left.type!=="Identifier")throw SyntaxError("Invalid left-hand side in assignment");let n=e.left.name,r=j.evalAst(e.right,t);return t[n]=r,t[n]}},Ln=class{constructor(t){this.code=t,this.ast=ge(this.code)}runInNewContext(t){let n=Object.assign(Object.create(null),t);return j.evalAst(this.ast,n)}};function Oe(e,t){return e=e.slice(),e.push(t),e}function In(e,t){return t=t.slice(),t.unshift(e),t}var Rn=class extends Error{constructor(t){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=t,this.name="NewError"}};function v(e,t,n,r,i){if(!(this instanceof v))try{return new v(e,t,n,r,i)}catch(o){if(!o.avoidNew)throw o;return o.value}typeof e=="string"&&(i=r,r=n,n=t,t=e,e=null);let u=e&&typeof e=="object";if(e=e||{},this.json=e.json||n,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=Object.hasOwn(e,"wrap")?e.wrap:!0,this.sandbox=e.sandbox||{},this.eval=e.eval===void 0?"safe":e.eval,this.ignoreEvalErrors=typeof e.ignoreEvalErrors=="undefined"?!1:e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||r||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){let o={path:u?e.path:t};u?"json"in e&&(o.json=e.json):o.json=n;let s=this.evaluate(o);if(!s||typeof s!="object")throw new Rn(s);return s}}v.prototype.evaluate=function(e,t,n,r){let i=this.parent,u=this.parentProperty,{flatten:o,wrap:s}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,n=n||this.callback,this.currOtherTypeCallback=r||this.otherTypeCallback,t=t||this.json,e=e||this.path,e&&typeof e=="object"&&!Array.isArray(e)){if(!e.path&&e.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,s=Object.hasOwn(e,"wrap")?e.wrap:s,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,n=Object.hasOwn(e,"callback")?e.callback:n,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=Object.hasOwn(e,"parent")?e.parent:i,u=Object.hasOwn(e,"parentProperty")?e.parentProperty:u,e=e.path}if(i=i||null,u=u||null,Array.isArray(e)&&(e=v.toPathString(e)),!e&&e!==""||!t)return;let p=v.toPathArray(e);p[0]==="$"&&p.length>1&&p.shift(),this._hasParentSelector=null;let a=this._trace(p,t,["$"],i,u,n).filter(function(l){return l&&!l.isParentSelector});return a.length?!s&&a.length===1&&!a[0].hasArrExpr?this._getPreferredOutput(a[0]):a.reduce((l,h)=>{let f=this._getPreferredOutput(h);return o&&Array.isArray(f)?l=l.concat(f):l.push(f),l},[]):s?[]:void 0};v.prototype._getPreferredOutput=function(e){let t=this.currResultType;switch(t){case"all":{let n=Array.isArray(e.path)?e.path:v.toPathArray(e.path);return e.pointer=v.toPointer(n),e.path=typeof e.path=="string"?e.path:v.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return v.toPathString(e[t]);case"pointer":return v.toPointer(e.path);default:throw new TypeError("Unknown result type")}};v.prototype._handleCallback=function(e,t,n){if(t){let r=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:v.toPathString(e.path),t(r,n,e)}};v.prototype._trace=function(e,t,n,r,i,u,o,s){let p;if(!e.length)return p={path:n,value:t,parent:r,parentProperty:i,hasArrExpr:o},this._handleCallback(p,u,"value"),p;let a=e[0],l=e.slice(1),h=[];function f(c){Array.isArray(c)?c.forEach(F=>{h.push(F)}):h.push(c)}if((typeof a!="string"||s)&&t&&Object.hasOwn(t,a))f(this._trace(l,t[a],Oe(n,a),t,a,u,o));else if(a==="*")this._walk(t,c=>{f(this._trace(l,t[c],Oe(n,c),t,c,u,!0,!0))});else if(a==="..")f(this._trace(l,t,n,r,i,u,o)),this._walk(t,c=>{typeof t[c]=="object"&&f(this._trace(e.slice(),t[c],Oe(n,c),t,c,u,!0))});else{if(a==="^")return this._hasParentSelector=!0,{path:n.slice(0,-1),expr:l,isParentSelector:!0};if(a==="~")return p={path:Oe(n,a),value:i,parent:r,parentProperty:null},this._handleCallback(p,u,"property"),p;if(a==="$")f(this._trace(l,t,n,null,null,u,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(a))f(this._slice(a,l,t,n,r,i,u));else if(a.indexOf("?(")===0){if(this.currEval===!1)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let c=a.replace(/^\?\((.*?)\)$/u,"$1"),F=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(c);F?this._walk(t,g=>{let C=[F[2]],y=F[1]?t[g][F[1]]:t[g];this._trace(C,y,n,r,i,u,!0).length>0&&f(this._trace(l,t[g],Oe(n,g),t,g,u,!0))}):this._walk(t,g=>{this._eval(c,t[g],g,n,r,i)&&f(this._trace(l,t[g],Oe(n,g),t,g,u,!0))})}else if(a[0]==="("){if(this.currEval===!1)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(In(this._eval(a,t,n.at(-1),n.slice(0,-1),r,i),l),t,n,r,i,u,o))}else if(a[0]==="@"){let c=!1,F=a.slice(1,-2);switch(F){case"scalar":(!t||!["object","function"].includes(typeof t))&&(c=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===F&&(c=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(c=!0);break;case"number":Number.isFinite(t)&&(c=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(c=!0);break;case"object":t&&typeof t===F&&(c=!0);break;case"array":Array.isArray(t)&&(c=!0);break;case"other":c=this.currOtherTypeCallback(t,n,r,i);break;case"null":t===null&&(c=!0);break;default:throw new TypeError("Unknown value type "+F)}if(c)return p={path:n,value:t,parent:r,parentProperty:i},this._handleCallback(p,u,"value"),p}else if(a[0]==="`"&&t&&Object.hasOwn(t,a.slice(1))){let c=a.slice(1);f(this._trace(l,t[c],Oe(n,c),t,c,u,o,!0))}else if(a.includes(",")){let c=a.split(",");for(let F of c)f(this._trace(In(F,l),t,n,r,i,u,!0))}else!s&&t&&Object.hasOwn(t,a)&&f(this._trace(l,t[a],Oe(n,a),t,a,u,o,!0))}if(this._hasParentSelector)for(let c=0;c{t(n)})};v.prototype._slice=function(e,t,n,r,i,u,o){if(!Array.isArray(n))return;let s=n.length,p=e.split(":"),a=p[2]&&Number.parseInt(p[2])||1,l=p[0]&&Number.parseInt(p[0])||0,h=p[1]&&Number.parseInt(p[1])||s;l=l<0?Math.max(0,l+s):Math.min(s,l),h=h<0?Math.max(0,h+s):Math.min(s,h);let f=[];for(let c=l;c{f.push(g)});return f};v.prototype._eval=function(e,t,n,r,i,u){this.currSandbox._$_parentProperty=u,this.currSandbox._$_parent=i,this.currSandbox._$_property=n,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;let o=e.includes("@path");o&&(this.currSandbox._$_path=v.toPathString(r.concat([n])));let s=this.currEval+"Script:"+e;if(!v.cache[s]){let p=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(p=p.replaceAll("@path","_$_path")),this.currEval==="safe"||this.currEval===!0||this.currEval===void 0)v.cache[s]=new this.safeVm.Script(p);else if(this.currEval==="native")v.cache[s]=new this.vm.Script(p);else if(typeof this.currEval=="function"&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){let a=this.currEval;v.cache[s]=new a(p)}else if(typeof this.currEval=="function")v.cache[s]={runInNewContext:a=>this.currEval(p,a)};else throw new TypeError(`Unknown "eval" property "${this.currEval}"`)}try{return v.cache[s].runInNewContext(this.currSandbox)}catch(p){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+p.message+": "+e)}};v.cache={};v.toPathString=function(e){let t=e,n=t.length,r="$";for(let i=1;itypeof t[a]=="function");let u=r.map(a=>t[a]);n=i.reduce((a,l)=>{let h=t[l].toString();return/function/u.test(h)||(h="function "+h),"var "+l+"="+h+";"+a},"")+n,!/(['"])use strict\1/u.test(n)&&!r.includes("arguments")&&(n="var arguments = undefined;"+n),n=n.replace(/;\s*$/u,"");let s=n.lastIndexOf(";"),p=s!==-1?n.slice(0,s+1)+" return "+n.slice(s+1):" return "+n;return new Function(...r,p)(...u)}};v.prototype.vm={Script:_n};var ie;(f=>{async function e(c,F,g,C){var L;let y=ci(g,{...Tn,interpretmarkup(B=""){var V,z;if(/^`[^`]+`$/.test(B))return B;let q=` `.repeat((z=(V=B.match(/\n/g))==null?void 0:V.length)!=null?z:0);return B.match(/^\s*(-|\d+\.) $/m)?q+"\u2022 ":q}}),b=JSON.stringify(y),A=(L=C!=null?C:c.staticLanguage)!=null?L:"auto",T={data:b,language:A,enabledOnly:"false",level:c.pickyMode?"picky":"default"};c.motherTongue&&(T.motherTongue=c.motherTongue),c.enabledCategories&&(T.enabledCategories=c.enabledCategories),c.disabledCategories&&(T.disabledCategories=c.disabledCategories),c.enabledRules&&(T.enabledRules=c.enabledRules),c.disabledRules&&(T.disabledRules=c.disabledRules),A=="auto"&&(T.preferredVariants=Object.values(c.languageVariety).join(",")),ze(c.serverUrl)!=="standard"&&c.apikey&&c.username&&(T.username=c.username,T.apiKey=c.apikey);let x=await p({url:`${c.serverUrl}/v2/check`,method:"POST",body:new URLSearchParams(T).toString(),headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}});if(x.json==null)throw new Error("Error processing response from LanguageTool.");return l("$.matches[*]",x.json).map(B=>{let q=a("$.offset@number()",B),V=q+a("$.length@number()",B);return{text:g.slice(q,V),from:F+q,to:F+V,title:a("$.shortMessage@string()",B),message:a("$.message@string()",B),replacements:l("$.replacements[*].value@string()",B),categoryId:a("$.rule.category.id@string()",B),ruleId:a("$.rule.id@string()",B)}})}f.check=e;async function t(c){let F=await(0,zn.requestUrl)({url:`${c}/v2/languages`}).json;if(F==null||!(F instanceof Array))throw new Error("Error processing response from LanguageTool.");return F}f.languages=t;async function n(c){if(c.username==null||c.apikey==null)throw Error("Syncing words is only supported for premium users");try{let F=(await p({url:h(`${c.serverUrl}/v2/words`,{username:c.username,apiKey:c.apikey,limit:"1000"}).href})).json;return l("$.words[*]@string()",F)}catch(F){throw new Error(`Requesting words failed ${F}`)}}f.words=n;async function r(c,F){if(c.username==null||c.apikey==null)throw Error("Syncing words is only supported for premium users");try{let g=(await p({url:h(`${c.serverUrl}/v2/words/add`,{username:c.username,apiKey:c.apikey,word:F}).href,method:"POST"})).json;return a("$.added@boolean()",g)}catch(g){throw new Error(`Adding words failed ${g}`)}}f.wordsAdd=r;async function i(c,F){if(c.username==null||c.apikey==null)throw Error("Syncing words is only supported for premium users");try{let g=(await p({url:h(`${c.serverUrl}/v2/words/delete`,{username:c.username,apiKey:c.apikey,word:F}).href,method:"POST"})).json;return a("$.deleted@boolean()",g)}catch(g){throw new Error(`Deleting words failed ${g}`)}}f.wordsDel=i;class u{constructor(){this.url="https://qb-grammar-en.languagetool.org/phrasal-paraphraser/subscribe"}async query(F,g){let C=F.slice(0,g.from).split(/\s+/).length,y=F.slice(g.from,g.to),b={message:{indices:[C],mode:0,phrases:[y],text:F},meta:{clientStatus:"string",product:"string",traceID:"string",userID:"string"},response_queue:"string"};try{let A=(await p({url:this.url,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})).json;return l("$.data.suggestions[*][*]@string()",A)}catch(A){throw new Error(`Requesting synonyms failed ${A}`)}}}class o{constructor(){this.url="https://synonyms.languagetool.org/synonyms/de"}async query(F,g){let C=F.slice(g.from,g.to).trim(),y=F.slice(0,g.from).split(/\s+/).join("+"),b=F.slice(g.to).split(/\s+/).join("+");try{let A=(await p({url:h(`${this.url}/${C}`,{before:y,after:b}).href,method:"GET"})).json;return l("$.synsets[*].terms[*].term@string()",A)}catch(A){throw new Error(`Requesting synonyms failed ${A}`)}}}f.SYNONYMS={en:new u,de:new o};async function p(c){let F;try{F=await(0,zn.requestUrl)({...c,throw:!1})}catch(g){throw new Error(`Request to LanguageTool failed: Please check your connection and server URL. ${g}`)}if(F.status===504||F.status===503)throw new Error("Request to LanguageTool timed out. Please try again later.");if(F.status!==200){let g=F.text;throw g.length>310&&(g=g.substring(0,300)+"..."),new Error(`Request to LanguageTool failed ${F.status}: ${g}`)}return F}function a(c,F){let g=v({path:c,json:F,wrap:!1,eval:!1});if(g==null)throw new Error("Error parsing response.");return g}function l(c,F){let g=v({path:c,json:F,wrap:!0,eval:!1});if(g==null||!(g instanceof Array))throw new Error("Error parsing response.");return g}function h(c,F){let g=new URL(c);return g.search=new URLSearchParams(F).toString(),g}})(ie||(ie={}));function It(e){switch(e){case"COLLOQUIALISMS":case"REDUNDANCY":case"STYLE":case"SYNONYMS":return"lt-style";case"TYPOS":return"lt-major"}return"lt-minor"}function We(e,t){let n=new Set(e);for(let r of t)n.delete(r);return n}function hi(e,t){let n=new Set(e);for(let r of t)n.add(r);return n}function fi(e,t){let n=new Set;for(let r of t)e.has(r)&&n.add(r);return n}function Ke(e,t){return e=e.toLowerCase(),t=t.toLowerCase(),e>t?1:en.code===t).filter(n=>n.longCode!==n.code),Object.fromEntries(e.map(n=>[n.longCode,n.name]))}var Rt=class extends N.PluginSettingTab{constructor(n,r){super(n,r);this.endpointListeners=[];this.languageListeners=[];this.languages=[];this.plugin=r}configureCheckDelay(n,r){let i=mt[r].minDelay;this.plugin.settings.autoCheckDelay=Math.clamp(this.plugin.settings.autoCheckDelay,i,mi),n.setLimits(i,mi,Qo)}async notifyEndpointChange(n){for(let r of this.endpointListeners)await r(n.serverUrl)}async configureLanguageVariants(n,r){var o;let i=this.plugin.settings.languageVariety,u=di(this.languages,r);i[r]=(o=i[r])!=null?o:Object.keys(u)[0],n.addOptions(u).setValue(i[r]).onChange(async s=>{i[r]=s,await this.plugin.saveSettings()}),this.languageListeners.push(async s=>{var a;for(;n.selectEl.options.length>0;)n.selectEl.remove(0);let p=di(s,r);i[r]=(a=i[r])!=null?a:Object.keys(p)[0],n.addOptions(p).setValue(i[r])})}async display(){let{containerEl:n}=this;n.empty();let r=this.plugin.settings;this.endpointListeners=[],this.endpointListeners.push(async a=>{let l=[];a&&(l=await ie.languages(a)),this.languages=l;for(let h of this.languageListeners)await h(l)}),this.endpointListeners.push(async a=>{await this.plugin.syncDictionary()}),this.languageListeners=[],new N.Setting(n).setName("Error logs").setDesc(`${this.plugin.logs.length} messages`).addButton(a=>{a.setButtonText("Copy to clipboard").onClick(async()=>{await window.navigator.clipboard.writeText(this.plugin.logs.join(` `)),new N.Notice("Logs copied to clipboard")})});let i=ze(r.serverUrl),u=null;new N.Setting(n).setName("Endpoint").setDesc("Choose the LanguageTool server url").then(a=>{a.controlEl.classList.add("lt-settings-grid");let l=null,h=null;a.addDropdown(f=>{l=f,f.addOptions({standard:"(Standard) api.languagetool.org",premium:"(Premium) api.languagetoolplus.com",custom:"Custom URL"}).setValue(i).onChange(async c=>{i=c,r.serverUrl=mt[i].url,h&&h.setValue(r.serverUrl).setDisabled(c!=="custom"),u&&this.configureCheckDelay(u,i),await this.notifyEndpointChange(r),await this.plugin.saveSettings()})}),a.addText(f=>{h=f,f.setPlaceholder("https://your-custom-url.com").setValue(r.serverUrl).setDisabled(i!=="custom").onChange(async c=>{r.serverUrl=c.replace(/\/v2\/check\/$/,"").replace(/\/$/,""),i=ze(r.serverUrl),i!=="custom"&&(l==null||l.setValue(i),h==null||h.setDisabled(!0)),await this.notifyEndpointChange(r),await this.plugin.saveSettings()})})}),new N.Setting(n).setName("API username").setDesc("Enter a username/mail for API access").addText(a=>a.setPlaceholder("peterlustig@example.com").setValue(r.username||"").onChange(async l=>{r.username=l.replace(/\s+/g,""),await this.plugin.saveSettings()})),new N.Setting(n).setName("API key").setDesc(createFragment(a=>{a.createEl("a",{text:"Click here for information about Premium Access",href:"https://github.com/wrenger/obsidian-languagetool#premium-accounts",attr:{target:"_blank"}})})).addText(a=>a.setValue(r.apikey||"").onChange(async l=>{r.apikey=l.replace(/\s+/g,""),r.apikey&&i!=="premium"&&new N.Notice("You have entered an API Key but you are not using the Premium Endpoint"),await this.plugin.saveSettings()})),new N.Setting(n).setName("Auto check text").setDesc("Check text as you type").addToggle(a=>{a.setValue(r.shouldAutoCheck).onChange(async l=>{r.shouldAutoCheck=l,await this.plugin.saveSettings()})}),new N.Setting(n).setName("Auto check delay (ms)").setDesc("Time to wait for autocheck after the last key press").addSlider(a=>{u=a,this.configureCheckDelay(a,i),a.setValue(r.autoCheckDelay).onChange(async l=>{r.autoCheckDelay=l,await this.plugin.saveSettings()}).setDynamicTooltip()});function o(a){if(a.appendText("Enables the context menu for synonyms fetched from"),a.createEl("br"),r.synonyms!=null){let l=ie.SYNONYMS[r.synonyms];if(!l){a.appendText(" (unknown API)");return}a.createEl("a",{text:l.url,href:l.url,attr:{target:"_blank"}})}else a.appendText("(none)")}let s=new N.Setting(n).setName("Find synonyms").setDesc(createFragment(o));s.addDropdown(a=>{var l;a.addOption("none","---");for(let h of Object.keys(ie.SYNONYMS))a.addOption(h,h);a.setValue((l=r.synonyms)!=null?l:"none").onChange(async h=>{r.synonyms=h!=="none"?h:void 0,await this.plugin.saveSettings(),s.setDesc(createFragment(o))})}),new N.Setting(n).setName("Language settings").setHeading(),new N.Setting(n).setName("Mother tongue").setDesc("Set mother tongue if you want to be warned about false friends when writing in other languages. This setting will also be used for automatic language detection.").addDropdown(a=>{this.languageListeners.push(async l=>{var h;for(;a.selectEl.options.length>0;)a.selectEl.remove(0);a.addOption("none","---").addOptions(Object.fromEntries(l.filter(f=>f.longCode==f.code).map(f=>[f.longCode,f.name]))).setValue((h=r.motherTongue)!=null?h:"none").onChange(async f=>{r.motherTongue=f!=="none"?f:void 0,await this.plugin.saveSettings()})})}),new N.Setting(n).setName("Static language").setDesc("Set a static language that will always be used (LanguageTool tries to auto detect the language, this is usually not necessary)").addDropdown(a=>{this.languageListeners.push(async l=>{var h;for(;a.selectEl.options.length>0;)a.selectEl.remove(0);a.addOption("auto","Auto Detect").addOptions(Object.fromEntries(l.map(f=>[f.longCode,f.name]))).setValue((h=r.staticLanguage)!=null?h:"auto").onChange(async f=>{r.staticLanguage=f!=="auto"?f:void 0,await this.plugin.saveSettings()})})}),new N.Setting(n).setName("Language varieties").setHeading().setDesc("Some languages have varieties depending on the country they are spoken in.");let p={en:"English",de:"German",pt:"Portuguese",ca:"Catalan"};for(let[a,l]of Object.entries(p))new N.Setting(n).setName(`Interpret ${l} as`).addDropdown(async h=>{this.configureLanguageVariants(h,a)});new N.Setting(n).setName("Spellcheck Dictionary").setHeading(),new N.Setting(n).setName("Ignored Words").setDesc("Words that should not be highlighted as spelling mistakes.").addButton(a=>{a.setIcon("settings").setTooltip("Edit dictionary").onClick(()=>{new Mn(this.app,this.plugin).open()})}),new N.Setting(n).setName("Sync with LanguageTool").setDesc("This is only supported for premium users.").addToggle(a=>{a.setDisabled(i!=="premium").setValue(r.syncDictionary).onChange(async l=>{r.syncDictionary=l,await this.plugin.syncDictionary()}),this.endpointListeners.push(async l=>{a.setDisabled(ze(l)!=="premium")})}),new N.Setting(n).setName("Rule categories").setHeading().setDesc(createFragment(a=>{a.appendText("The picky mode enables a lot of extra categories and rules. Additionally, you can enable or disable specific rules down below."),a.createEl("br"),a.createEl("a",{text:"Click here for a list of rules and categories",href:"https://community.languagetool.org/rule/list",attr:{target:"_blank"}})})),new N.Setting(n).setName("Picky mode").setDesc("Provides more style and tonality suggestions, detects long or complex sentences, recognizes colloquialism and redundancies, proactively suggests synonyms for commonly overused words").addToggle(a=>{a.setValue(r.pickyMode).onChange(async l=>{r.pickyMode=l,await this.plugin.saveSettings()})}),new N.Setting(n).setName("Enabled categories").setDesc("Comma-separated list of categories").addText(a=>{var l;return a.setPlaceholder("CATEGORY_1,CATEGORY_2").setValue((l=r.enabledCategories)!=null?l:"").onChange(async h=>{r.enabledCategories=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(n).setName("Disabled categories").setDesc("Comma-separated list of categories").addText(a=>{var l;return a.setPlaceholder("CATEGORY_1,CATEGORY_2").setValue((l=r.disabledCategories)!=null?l:"").onChange(async h=>{r.disabledCategories=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(n).setName("Enabled rules").setDesc("Comma-separated list of rules").addText(a=>{var l;return a.setPlaceholder("RULE_1,RULE_2").setValue((l=r.enabledRules)!=null?l:"").onChange(async h=>{r.enabledRules=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(n).setName("Disabled rules").setDesc("Comma-separated list of rules").addText(a=>{var l;return a.setPlaceholder("RULE_1,RULE_2").setValue((l=r.disabledRules)!=null?l:"").onChange(async h=>{r.disabledRules=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),await this.notifyEndpointChange(r)}},Mn=class extends N.Modal{constructor(t,n){super(t),this.setTitle("Spellcheck dictionary"),this.plugin=n,this.words=n.settings.dictionary}async onOpen(){this.words=this.plugin.settings.dictionary;let{contentEl:t}=this,n=s=>{s.replaceChildren(...this.words.map(p=>s.createDiv({cls:"multi-select-pill"},a=>{a.createDiv({cls:"multi-select-pill-content"},l=>l.createSpan({text:p})),a.createDiv({cls:"multi-select-pill-remove-button"},l=>{l.appendChild((0,N.getIcon)("x")),l.onClickEvent(()=>{this.words.remove(p),n(s)})})})))},r=null;t.createDiv({cls:"multi-select-container"},s=>{r=s,n(s)}),this.plugin.syncDictionary().then(s=>{s&&(this.words=this.plugin.settings.dictionary,r&&n(r))});let i="",u=null,o=()=>{i&&(this.words=[...new Set([...this.words,i])].sort(Ke),r&&n(r),u&&u.setValue(""),i="")};new N.Setting(t).setName("Add").addText(s=>{u=s.setValue(i).onChange(p=>i=p.trim()),s.inputEl.addEventListener("keypress",p=>{p.key==="Enter"&&o()})}).addExtraButton(s=>{s.setIcon("plus").setTooltip("Add").onClick(()=>{o()})})}async onClose(){this.contentEl.empty(),this.plugin.settings.dictionary=this.words,await this.plugin.syncDictionary()}};var ki=require("@codemirror/view");var xi=require("@codemirror/view");function yi(e){let t=-1,n=1/0,r=-1/0;return xi.EditorView.updateListener.of(i=>{if(!i.docChanged||!e.settings.shouldAutoCheck)return;i.changes.iterChangedRanges((o,s,p,a)=>{n=Math.min(n,p,a),r=Math.max(r,p,a)});let u=i.view;clearTimeout(t),t=window.setTimeout(()=>{e.runDetection(u,{from:n,to:r}).catch(o=>{console.error(o)}),n=1/0,r=-1/0},e.settings.autoCheckDelay)})}var Ai=require("@codemirror/view"),Ci=require("@codemirror/state");var gt=require("obsidian");var Ze=require("@codemirror/view"),Me=require("@codemirror/state"),Xe=require("@codemirror/language");var Wo=/(frontmatter|code|math|templater|blockid|hashtag|internal)/,_t=Me.StateEffect.define(),dt=Me.StateEffect.define(),ve=Me.StateEffect.define(),zt=Me.StateEffect.define();function Ei(e,t){return e.from<=t.from&&t.from<=e.to||e.from<=t.to&&t.to<=e.to||t.from<=e.from&&e.from<=t.to||t.from<=e.to&&e.to<=t.to}var Be=Me.StateField.define({create(){return Ze.Decoration.none},update(e,t){e=e.map(t.changes);let n=new Set,r={},i=null,u=s=>{if(r[s]==null){i||(i=(0,Xe.syntaxTree)(t.state));let p=i.resolveInner(s,1).type.prop(Xe.tokenClassNodeProp);r[s]=!(p&&Wo.test(p))}return r[s]},o=s=>{i||(i=(0,Xe.syntaxTree)(t.state));let p=i.resolve(t.newDoc.lineAt(s.from).from,1).type.prop(Xe.tokenClassNodeProp);return!(p!=null&&p.includes("table")&&s.ruleId==="WHITESPACE_RULE")};t.docChanged&&t.selection&&e.size&&(e=e.update({filter:(s,p)=>!Ei({from:s,to:p},t.selection.main)}));for(let s of t.effects)if(s.is(_t)){let p=s.value,a=`${p.from},${p.to}`;!n.has(a)&&u(p.from)&&u(p.to)&&o(p)&&(n.add(a),e=e.update({add:[Ze.Decoration.mark({class:`lt-underline ${It(p.categoryId)}`,underline:p}).range(p.from,p.to)]}))}else s.is(dt)?e=Ze.Decoration.none:s.is(ve)?e=e.update({filterFrom:s.value.from,filterTo:s.value.to,filter:(p,a)=>!Ei({from:p,to:a},s.value)}):s.is(zt)&&(e=e.update({filter:(p,a,l)=>!s.value(l.spec.underline)}));return e},provide:e=>Ze.EditorView.decorations.from(e)});function Ko(e,t,n){let r=n.replacements.slice(0,Mt),i=n.categoryId,u=n.ruleId;return createDiv({cls:["lt-predictions-container",It(i)]},o=>{n.title&&o.createSpan({cls:"lt-title"},p=>{p.createSpan({text:n.title})}),n.message&&o.createSpan({cls:"lt-message",text:n.message});let s=ve.of({...n});o.createDiv({cls:"lt-bottom"},p=>{r.length&&p.createDiv({cls:"lt-buttoncontainer"},a=>{for(let l of r)a.createEl("button",{text:l||"(delete)"},h=>{h.onclick=()=>{t.dispatch({changes:[{from:n.from,to:n.to,insert:l}],effects:[s]})}})}),p.createDiv({cls:"lt-info-container"},a=>{a.createEl("button",{cls:"lt-info-button clickable-icon"},l=>{(0,gt.setIcon)(l,"info"),l.onclick=()=>{let h=document.getElementsByClassName("lt-info-box").item(0);if(!h)throw Error("Programming error: failed to create popup.");h.hasClass("hidden")?h.removeClass("hidden"):h.addClass("hidden")}}),a.createDiv({cls:"lt-info-box hidden"},l=>{l.createDiv({cls:"lt-info",text:`Category:\xA0${i}`}),l.createDiv({cls:"lt-info",text:`Rule:\xA0${u}`})})})}),o.createDiv({cls:"lt-ignorecontainer"},p=>{p.createEl("button",{cls:"lt-ignore-btn"},a=>{i==="TYPOS"?((0,gt.setIcon)(a.createSpan(),"plus-with-circle"),a.createSpan({text:"Add to personal dictionary"}),a.onclick=async()=>{e.settings.dictionary.push(n.text),await e.syncDictionary(),t.dispatch({effects:[zt.of(l=>l.text===n.text)]})}):((0,gt.setIcon)(a.createSpan(),"cross"),a.createSpan({text:"Ignore suggestion"}),a.onclick=()=>{t.dispatch({effects:[s]})})}),i!=="TYPOS"&&i!=="SYNONYMS"&&p.createEl("button",{cls:"lt-ignore-btn"},a=>{(0,gt.setIcon)(a.createSpan(),"circle-off"),a.createSpan({text:"Disable rule"}),a.onclick=()=>{e.settings.disabledRules?e.settings.disabledRules+=","+u:e.settings.disabledRules=u,e.saveSettings(),t.dispatch({effects:[zt.of(l=>l.ruleId===u)]})}})})})}function Fi(e,t,n){let r=n.field(Be);if(r.size===0||n.selection.ranges.length>1)return[];let i=null;if(r.between(n.selection.main.from,n.selection.main.to,(u,o,s)=>{i={...s.spec.underline,from:u,to:o}}),i!=null){let{from:u,to:o}=i;if(e.length){let s=e[0];if(s.pos===u&&s.end===o)return e}return[{pos:u,end:o,above:!0,strictSide:!1,arrow:!1,create:s=>({dom:Ko(t,s,i)})}]}return[]}function wi(e){return Ci.StateField.define({create:t=>Fi([],e,t),update:(t,n)=>Fi(t,e,n.state),provide:t=>Ai.showTooltip.computeN([t],n=>n.field(t))})}function bi(e){return[(0,ki.tooltips)({position:"absolute",tooltipSpace:t=>t.dom.getBoundingClientRect()}),Be,wi(e),yi(e)]}var Si=require("@codemirror/language");var Mt=5,vt=class extends ue.Plugin{constructor(){super(...arguments);this.isLoading=!1;this.logs=[]}async onload(){await this.loadSettings(),this.settingTab=new Rt(this.app,this),this.addSettingTab(this.settingTab),this.app.workspace.onLayoutReady(()=>{this.statusBarText=this.addStatusBarItem(),this.setStatusBarReady(),this.registerDomEvent(this.statusBarText,"click",()=>this.handleStatusBarClick())}),this.registerEditorExtension(bi(this)),this.registerCommands(),this.registerMenuItems();let n=new Set(this.settings.dictionary.map(r=>r.trim()));n.delete(""),this.settings.dictionary=[...n].sort(Ke),this.syncDictionary(),await this.saveSettings()}onunload(){this.logs=[],this.isLoading=!1}registerCommands(){this.addCommand({id:"check",name:"Check text",editorCallback:(n,r)=>{let i=n.cm;this.runDetection(i).catch(u=>{console.error(u)})}}),this.addCommand({id:"toggle-auto-check",name:"Toggle automatic checking",callback:async()=>{this.settings.shouldAutoCheck=!this.settings.shouldAutoCheck,await this.saveSettings()}}),this.addCommand({id:"clear",name:"Clear suggestions",editorCallback:n=>{n.cm.dispatch({effects:[dt.of(null)]})}}),this.addCommand({id:"accept-all",name:"Accept all suggestions",editorCallback:n=>{let r=n.cm,i=[],u=[];r.state.field(Be).between(0,1/0,(o,s,p)=>{var a,l,h;(h=(l=(a=p.spec)==null?void 0:a.underline)==null?void 0:l.replacements)!=null&&h.length&&(i.push({from:o,to:s,insert:p.spec.underline.replacements[0]}),u.push(ve.of({from:o,to:s})))}),r.dispatch({changes:i,effects:u})}}),this.addCommand({id:"next",name:"Jump to next suggestion",editorCheckCallback:(n,r)=>{let i=r.cm,u=r.posToOffset(r.getCursor()),o=null;if(i.state.field(Be).between(u+1,1/0,(s,p)=>{(!o||o.from>s)&&(o={from:s,to:p})}),n)return o!=null;o!=null&&i.dispatch({selection:{anchor:o.from,head:o.to}})}});for(let n=1;n<=Mt;n++)this.addCommand(this.applySuggestionCommand(n));this.addCommand({id:"synonyms",name:"Show synonyms",editorCheckCallback:(n,r)=>this.showSynonyms(r,n)})}applySuggestionCommand(n){return{id:`accept-${n}`,name:`Accept suggestion ${n}`,editorCheckCallback(r,i){var c,F,g;let u=i.cm,o=i.posToOffset(i.getCursor()),s=[];u.state.field(Be).between(o,o,(C,y,b)=>{s.push({from:C,to:y,value:b})});let p=s.length===1&&((g=(F=(c=s[0].value.spec)==null?void 0:c.underline)==null?void 0:F.replacements)==null?void 0:g.length)>=n;if(r)return p;if(!p)return;let{from:a,to:l,value:h}=s[0],f={from:a,to:l,insert:h.spec.underline.replacements[n-1]};u.dispatch({changes:[f],effects:[ve.of({from:a,to:l})]})}}}registerMenuItems(){this.registerEvent(this.app.workspace.on("editor-menu",(n,r,i)=>{this.showSynonyms(r,!0)&&n.addItem(u=>{u.setTitle("Synonyms"),u.setIcon("square-stack"),u.onClick(()=>this.showSynonyms(r))})}))}showSynonyms(n,r=!1){if(!this.settings.synonyms||!(this.settings.synonyms in ie.SYNONYMS))return!1;let i=ie.SYNONYMS[this.settings.synonyms];if(!i)return!1;let u=n.cm,o=u.state.selection.main;if(o.empty)return!1;let s=u.state.sliceDoc(u.state.selection.main.from,u.state.selection.main.to);if(s.match(/[\s\.]/))return!1;if(r)return!0;let p=u.state.doc.lineAt(o.from),a=p.text.slice(0,o.from-p.from).lastIndexOf(".")+1,l=p.text.slice(a),h=l.trimStart(),f=p.from+a+l.length-h.length,c={from:o.from-f,to:o.to-f};h=h.trimEnd();let F=h.indexOf(".");return F!==-1&&(h=h.slice(0,F+1)),i.query(h,c).then(g=>u.dispatch({effects:[_t.of({text:s,from:o.from,to:o.to,title:"Synonyms",message:"",categoryId:"SYNONYMS",ruleId:"SYNONYMS",replacements:g})]})).catch(g=>{console.error(g),this.pushLogs(g),new ue.Notice(g.message,3e4)}),!0}setStatusBarReady(){this.isLoading=!1,this.statusBarText.empty(),this.statusBarText.createSpan({cls:"lt-status-bar-btn"},n=>{n.createSpan({cls:"lt-status-bar-check-icon",text:"Aa"})})}setStatusBarWorking(){this.isLoading||(this.isLoading=!0,this.statusBarText.empty(),this.statusBarText.createSpan({cls:["lt-status-bar-btn","lt-loading"]},n=>{(0,ue.setIcon)(n,"sync-small")}))}handleStatusBarClick(){var i;let n=(i=this.statusBarText.parentElement)==null?void 0:i.getBoundingClientRect(),r=this.statusBarText.getBoundingClientRect();new ue.Menu().addItem(u=>{u.setTitle("Check text"),u.setIcon("checkbox-glyph"),u.onClick(async()=>{let o=this.app.workspace.getActiveViewOfType(ue.MarkdownView);if(o&&o.getMode()==="source"){let s=o.editor.cm;await this.runDetection(s)}})}).addItem(u=>{u.setTitle(this.settings.shouldAutoCheck?"Disable automatic checking":"Enable automatic checking"),u.setIcon("uppercase-lowercase-a"),u.onClick(async()=>{this.settings.shouldAutoCheck=!this.settings.shouldAutoCheck,await this.saveSettings()})}).addItem(u=>{u.setTitle("Clear suggestions"),u.setIcon("reset"),u.onClick(()=>{let o=this.app.workspace.getActiveViewOfType(ue.MarkdownView);if(!o)return;o.editor.cm.dispatch({effects:[dt.of(null)]})})}).showAtPosition({x:r.right+5,y:((n==null?void 0:n.top)||0)-5})}async runDetection(n,r){var f;let i=this.app.workspace.getActiveFile(),u=i&&this.app.metadataCache.getFileCache(i),o=(f=u==null?void 0:u.frontmatter)==null?void 0:f.lt_language,s=n.state.selection.main;!r&&!s.empty&&(r={...s});let p=0,a="";if(r?(r=Zo(n,r),p=r.from,a=n.state.sliceDoc(r.from,r.to)):a=n.state.sliceDoc(0),!a.trim())return;let l;try{this.setStatusBarWorking(),l=await ie.check(this.settings,p,a,o)}catch(c){console.error(c),c instanceof Error&&(this.pushLogs(c),new ue.Notice(c.message,3e4));return}finally{this.setStatusBarReady()}let h=[];if(r?h.push(ve.of(r)):h.push(dt.of(null)),l){let c=this.settings.dictionary;for(let F of l)F.to>n.state.doc.length||F.categoryId==="TYPOS"&&c.includes(F.text)||h.push(_t.of(F))}h.length&&n.dispatch({effects:h})}async pushLogs(n){let r=`${new Date().toLocaleString()}: Error: '${n.message}' Settings: ${JSON.stringify({...this.settings,username:"REDACTED",apikey:"REDACTED"})} `;this.settings.username&&(r=r.replaceAll(this.settings.username,"<>")),this.settings.apikey&&(r=r.replaceAll(this.settings.apikey,"<>")),this.logs.push(r),this.logs.length>10&&this.logs.shift()}async loadSettings(){this.settings=Object.assign({},gi,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}async onExternalSettingsChange(){this.settingTab.notifyEndpointChange(this.settings)}async syncDictionary(){if(!this.settings.syncDictionary||ze(this.settings.serverUrl)!=="premium")return await this.saveSettings(),!1;try{let n=new Set(this.settings.remoteDictionary),r=new Set(this.settings.dictionary),i=new Set(await ie.words(this.settings)),u=We(n,r);u=fi(u,i);for(let h of u)await ie.wordsDel(this.settings,h);let o=We(n,i);i=We(i,u),r=We(r,o);let s=We(r,i);for(let h of s)await ie.wordsAdd(this.settings,h);let p=hi(i,r),l=new Set(this.settings.dictionary).size!==p.size;return this.settings.dictionary=[...p].sort(Ke),this.settings.remoteDictionary=[...p].sort(Ke),await this.saveSettings(),l}catch(n){this.pushLogs(n),new ue.Notice(n.message,3e4),console.error("Failed sync spellcheck with LanguageTool",n)}return await this.saveSettings(),!1}};function Zo(e,t){let n=null;if(t.from>0){n=(0,Si.syntaxTree)(e.state);let r=n.resolveInner(t.from,-1);r.type.name.startsWith("list-")?t.from=r.from:t.from=e.state.doc.lineAt(t.from).from}else t.from=0;return t.to * @license MIT *) */ /* nosourcemap */