/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var Qi=Object.create;var wt=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var Ki=Object.getOwnPropertyNames;var Ji=Object.getPrototypeOf,Xi=Object.prototype.hasOwnProperty;var Kt=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Kn=(e,n)=>{for(var t in n)wt(e,t,{get:n[t],enumerable:!0})},Jn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Ki(n))!Xi.call(e,i)&&i!==t&&wt(e,i,{get:()=>n[i],enumerable:!(r=Zi(n,i))||r.enumerable});return e};var Dt=(e,n,t)=>(t=e!=null?Qi(Ji(e)):{},Jn(n||!e||!e.__esModule?wt(t,"default",{value:e,enumerable:!0}):t,e)),Gi=e=>Jn(wt({},"__esModule",{value:!0}),e);var Gn=Kt((Ma,Jt)=>{(function(){var e;typeof Jt!="undefined"?e=Jt.exports=r:e=function(){return this||(0,eval)("this")}(),e.format=r,e.vsprintf=t,typeof console!="undefined"&&typeof console.log=="function"&&(e.printf=n);function n(){console.log(r.apply(null,arguments))}function t(i,u){return r.apply(null,[i].concat(u))}function r(i){for(var u=1,o=[].slice.call(arguments),a=0,c=i.length,l="",s,h=!1,f,p,b=!1,A,y=function(){return o[u++]},F=function(){for(var w="";/\d/.test(i[a]);)w+=i[a++],s=i[a];return w.length>0?parseInt(w):null};a{Xr.exports=function(n){return n!=null&&n.constructor!=null&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}});var ai=Kt((Qp,oi)=>{"use strict";var jt=Object.prototype.hasOwnProperty,ui=Object.prototype.toString,Gr=Object.defineProperty,ei=Object.getOwnPropertyDescriptor,ti=function(n){return typeof Array.isArray=="function"?Array.isArray(n):ui.call(n)==="[object Array]"},ni=function(n){if(!n||ui.call(n)!=="[object Object]")return!1;var t=jt.call(n,"constructor"),r=n.constructor&&n.constructor.prototype&&jt.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!t&&!r)return!1;var i;for(i in n);return typeof i=="undefined"||jt.call(n,i)},ri=function(n,t){Gr&&t.name==="__proto__"?Gr(n,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):n[t.name]=t.newValue},ii=function(n,t){if(t==="__proto__")if(jt.call(n,t)){if(ei)return ei(n,t).value}else return;return n[t]};oi.exports=function e(){var n,t,r,i,u,o,a=arguments[0],c=1,l=arguments.length,s=!1;for(typeof a=="boolean"&&(s=a,a=arguments[1]||{},c=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});c$t,default:()=>Wt,getElectronWindow:()=>wa});module.exports=Gi(Sa);var se=require("obsidian");var N=require("obsidian");var Ve={children(e){return e.children},annotatetextnode(e,n){return e.type==="text"?{offset:{end:e.position.end.offset,start:e.position.start.offset},text:n.substring(e.position.start.offset,e.position.end.offset)}:null},interpretmarkup(e=""){return e}};function eu(e,n,t=Ve){let r=[];function i(u){let o=t.annotatetextnode(u,n);o!==null&&r.push(o);let a=t.children(u);a!==null&&Array.isArray(a)&&a.forEach(i)}return i(e),r}function tu(e,n,t=Ve){let r=[],i={offset:{end:0,start:0}};for(let o of n){let a=e.substring(i.offset.end,o.offset.start);r.push({interpretAs:t.interpretmarkup(a),markup:a,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:t.interpretmarkup(u),markup:u,offset:{end:e.length,start:i.offset.end}}),{annotation:r}}function Xn(e,n,t=Ve){let r=eu(n,e,t);return tu(e,r,t)}var va=ye(/[A-Za-z]/),Ta=ye(/[\dA-Za-z]/),Oa=ye(/[#-'*+\--9=?A-Z^-~]/);var _a=ye(/\d/),Pa=ye(/[\dA-Fa-f]/),Ia=ye(/[!-/:-@[-`{-~]/);function at(e){return e!==null&&e<-2}function st(e){return e===-2||e===-1||e===32}var La=ye(/\p{P}|\p{S}/u),Ra=ye(/\s/);function ye(e){return n;function n(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var er=Dt(Gn(),1),lt=Object.assign(Ie(Error),{eval:Ie(EvalError),range:Ie(RangeError),reference:Ie(ReferenceError),syntax:Ie(SyntaxError),type:Ie(TypeError),uri:Ie(URIError)});function Ie(e){return n.displayName=e.displayName||e.name,n;function n(t,...r){let i=t&&(0,er.default)(t,...r);return new e(i)}}var St={}.hasOwnProperty,tr={yaml:"-",toml:"+"};function He(e){let n=[],t=-1,r=Array.isArray(e)?e:e?[e]:["yaml"];for(;++ti?0:i+n:n=n>i?i:n,t=t>0?t:0,r.length<1e4)o=Array.from(r),o.unshift(n,t),e.splice(...o);else for(t&&e.splice(n,t);u0?(Z(e,e.length,0,n),e):n}var or={}.hasOwnProperty;function ar(e){let n={},t=-1;for(;++to))return;let C=n.events.length,_=C,R,Y;for(;_--;)if(n.events[_][0]==="exit"&&n.events[_][1].type==="chunkFlow"){if(R){Y=n.events[_][1].end;break}R=!0}for(F(r),g=C;gE;){let T=t[S];n.containerState=T[1],T[0].exit.call(n,e)}t.length=E}function w(){i.write([null]),u=void 0,i=void 0,n.containerState._closeFlow=void 0}}function gu(e,n,t){return P(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var hr=/[!-\/:-@\[-`\{-~\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 qs=Ce(/[A-Za-z]/),$s=Ce(/[\dA-Za-z]/),Ws=Ce(/[#-'*+\--9=?A-Z^-~]/);var Ys=Ce(/\d/),Qs=Ce(/[\dA-Fa-f]/),Zs=Ce(/[!-/:-@[-`{-~]/);function mr(e){return e!==null&&(e<0||e===32)}var dr=Ce(hr),gr=Ce(/\s/);function Ce(e){return n;function n(t){return t!==null&&e.test(String.fromCharCode(t))}}function an(e){if(e===null||mr(e)||gr(e))return 1;if(dr(e))return 2}function $e(e,n,t){let r=[],i=-1;for(;++i1&&e[t][1].end.offset-e[t][1].start.offset>1?2:1;let h=Object.assign({},e[r][1].end),f=Object.assign({},e[t][1].start);Fr(h,-c),Fr(f,c),o={type:c>1?"strongSequence":"emphasisSequence",start:h,end:Object.assign({},e[r][1].end)},a={type:c>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[t][1].start),end:f},u={type:c>1?"strongText":"emphasisText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[t][1].start)},i={type:c>1?"strong":"emphasis",start:Object.assign({},o.start),end:Object.assign({},a.end)},e[r][1].end=Object.assign({},o.start),e[t][1].start=Object.assign({},a.end),l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=G(l,[["enter",e[r][1],n],["exit",e[r][1],n]])),l=G(l,[["enter",i,n],["enter",o,n],["exit",o,n],["enter",u,n]]),l=G(l,$e(n.parser.constructs.insideSpan.null,e.slice(r+1,t),n)),l=G(l,[["exit",u,n],["enter",a,n],["exit",a,n],["exit",i,n]]),e[t][1].end.offset-e[t][1].start.offset?(s=2,l=G(l,[["enter",e[t][1],n],["exit",e[t][1],n]])):s=0,Z(e,r-1,t-r+3,l),t=r+l.length-s-2;break}}for(t=-1;++t0&&z(g)?P(e,w,"linePrefix",u+1)(g):w(g)}function w(g){return g===null||v(g)?e.check(kr,A,S)(g):(e.enter("codeFlowValue"),E(g))}function E(g){return g===null||v(g)?(e.exit("codeFlowValue"),w(g)):(e.consume(g),E)}function S(g){return e.exit("codeFenced"),n(g)}function T(g,C,_){let R=0;return Y;function Y(I){return g.enter("lineEnding"),g.consume(I),g.exit("lineEnding"),H}function H(I){return g.enter("codeFencedFence"),z(I)?P(g,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):D(I)}function D(I){return I===a?(g.enter("codeFencedFenceSequence"),B(I)):_(I)}function B(I){return I===a?(R++,g.consume(I),B):R>=o?(g.exit("codeFencedFenceSequence"),z(I)?P(g,L,"whitespace")(I):L(I)):_(I)}function L(I){return I===null||v(I)?(g.exit("codeFencedFence"),C(I)):_(I)}}}function Su(e,n,t){let r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),u)}function u(o){return r.parser.lazy[r.now().line]?t(o):n(o)}}var pt={name:"codeIndented",tokenize:vu},Bu={tokenize:Tu,partial:!0};function vu(e,n,t){let r=this;return i;function i(l){return e.enter("codeIndented"),P(e,u,"linePrefix",5)(l)}function u(l){let s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?o(l):t(l)}function o(l){return l===null?c(l):v(l)?e.attempt(Bu,o,c)(l):(e.enter("codeFlowValue"),a(l))}function a(l){return l===null||v(l)?(e.exit("codeFlowValue"),o(l)):(e.consume(l),a)}function c(l){return e.exit("codeIndented"),n(l)}}function Tu(e,n,t){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?t(o):v(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):P(e,u,"linePrefix",5)(o)}function u(o){let a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(o):v(o)?i(o):t(o)}}var ln={name:"codeText",tokenize:Pu,resolve:Ou,previous:_u};function Ou(e){let n=e.length-4,t=3,r,i;if((e[t][1].type==="lineEnding"||e[t][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(r=t;++r=4?n(o):e.interrupt(r.parser.constructs.flow,t,n)(o)}}var wr=/[!-\/:-@\[-`\{-~\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 jl=we(/[A-Za-z]/),Ul=we(/[\dA-Za-z]/),Vl=we(/[#-'*+\--9=?A-Z^-~]/);function fn(e){return e!==null&&(e<32||e===127)}var Hl=we(/\d/),ql=we(/[\dA-Fa-f]/),$l=we(/[!-/:-@[-`{-~]/);function Dr(e){return e!==null&&e<-2}function Sr(e){return e!==null&&(e<0||e===32)}var Wl=we(wr),Yl=we(/\s/);function we(e){return n;function n(t){return t!==null&&e.test(String.fromCharCode(t))}}function It(e,n,t,r,i,u,o,a,c){let l=c||Number.POSITIVE_INFINITY,s=0;return h;function h(F){return F===60?(e.enter(r),e.enter(i),e.enter(u),e.consume(F),e.exit(u),f):F===null||F===32||F===41||fn(F)?t(F):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),A(F))}function f(F){return F===62?(e.enter(u),e.consume(F),e.exit(u),e.exit(i),e.exit(r),n):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(F))}function p(F){return F===62?(e.exit("chunkString"),e.exit(a),f(F)):F===null||F===60||Dr(F)?t(F):(e.consume(F),F===92?b:p)}function b(F){return F===60||F===62||F===92?(e.consume(F),p):p(F)}function A(F){return!s&&(F===null||F===41||Sr(F))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),n(F)):s999||p===null||p===91||p===93&&!c||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?t(p):p===93?(e.exit(u),e.enter(i),e.consume(p),e.exit(i),e.exit(r),n):pn(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),s):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||pn(p)||a++>999?(e.exit("chunkString"),s(p)):(e.consume(p),c||(c=!vr(p)),p===92?f:h)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,h):h(p)}}var Tr=/[!-\/:-@\[-`\{-~\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 pc=Se(/[A-Za-z]/),hc=Se(/[\dA-Za-z]/),mc=Se(/[#-'*+\--9=?A-Z^-~]/);var dc=Se(/\d/),gc=Se(/[\dA-Fa-f]/),Fc=Se(/[!-/:-@[-`{-~]/);function hn(e){return e!==null&&e<-2}var xc=Se(Tr),yc=Se(/\s/);function Se(e){return n;function n(t){return t!==null&&e.test(String.fromCharCode(t))}}function Rt(e,n,t,r,i,u){let o;return a;function a(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,c):t(f)}function c(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),n):(e.enter(u),l(f))}function l(f){return f===o?(e.exit(u),c(o)):f===null?t(f):hn(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),P(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),s(f))}function s(f){return f===o||f===null||hn(f)?(e.exit("chunkString"),l(f)):(e.consume(f),f===92?h:s)}function h(f){return f===o||f===92?(e.consume(f),s):s(f)}}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 Dc=Be(/[A-Za-z]/),Sc=Be(/[\dA-Za-z]/),Bc=Be(/[#-'*+\--9=?A-Z^-~]/);var vc=Be(/\d/),Tc=Be(/[\dA-Fa-f]/),Oc=Be(/[!-/:-@[-`{-~]/);function _r(e){return e!==null&&e<-2}function Pr(e){return e===-2||e===-1||e===32}var _c=Be(Or),Pc=Be(/\s/);function Be(e){return n;function n(t){return t!==null&&e.test(String.fromCharCode(t))}}function Le(e,n){let t;return r;function r(i){return _r(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t=!0,r):Pr(i)?P(e,r,t?"linePrefix":"lineSuffix")(i):n(i)}}function Fe(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var mn={name:"definition",tokenize:ju},Nu={tokenize:Uu,partial:!0};function ju(e,n,t){let r=this,i;return u;function u(p){return e.enter("definition"),o(p)}function o(p){return Lt.call(r,e,a,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Fe(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):t(p)}function c(p){return K(p)?Le(e,l)(p):l(p)}function l(p){return It(e,s,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function s(p){return e.attempt(Nu,h,h)(p)}function h(p){return z(p)?P(e,f,"whitespace")(p):f(p)}function f(p){return p===null||v(p)?(e.exit("definition"),r.parser.defined.push(i),n(p)):t(p)}}function Uu(e,n,t){return r;function r(a){return K(a)?Le(e,i)(a):t(a)}function i(a){return Rt(e,u,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function u(a){return z(a)?P(e,o,"whitespace")(a):o(a)}function o(a){return a===null||v(a)?n(a):t(a)}}var dn={name:"hardBreakEscape",tokenize:Vu};function Vu(e,n,t){return r;function r(u){return e.enter("hardBreakEscape"),e.consume(u),i}function i(u){return v(u)?(e.exit("hardBreakEscape"),n(u)):t(u)}}var gn={name:"headingAtx",tokenize:qu,resolve:Hu};function Hu(e,n){let t=e.length-2,r=3,i,u;return e[r][1].type==="whitespace"&&(r+=2),t-2>r&&e[t][1].type==="whitespace"&&(t-=2),e[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&e[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[t][1].end},u={type:"chunkText",start:e[r][1].start,end:e[t][1].end,contentType:"text"},Z(e,r,t-r+1,[["enter",i,n],["enter",u,n],["exit",u,n],["exit",i,n]])),e}function qu(e,n,t){let r=0;return i;function i(s){return e.enter("atxHeading"),u(s)}function u(s){return e.enter("atxHeadingSequence"),o(s)}function o(s){return s===35&&r++<6?(e.consume(s),o):s===null||K(s)?(e.exit("atxHeadingSequence"),a(s)):t(s)}function a(s){return s===35?(e.enter("atxHeadingSequence"),c(s)):s===null||v(s)?(e.exit("atxHeading"),n(s)):z(s)?P(e,a,"whitespace")(s):(e.enter("atxHeadingText"),l(s))}function c(s){return s===35?(e.consume(s),c):(e.exit("atxHeadingSequence"),a(s))}function l(s){return s===null||s===35||K(s)?(e.exit("atxHeadingText"),a(s)):(e.consume(s),l)}}var Ir=["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"],Fn=["pre","script","style","textarea"];var xn={name:"htmlFlow",tokenize:Qu,resolveTo:Yu,concrete:!0},$u={tokenize:Ku,partial:!0},Wu={tokenize:Zu,partial:!0};function Yu(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function Qu(e,n,t){let r=this,i,u,o,a,c;return l;function l(d){return s(d)}function s(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,A):d===63?(e.consume(d),i=3,r.interrupt?n:m):re(d)?(e.consume(d),o=String.fromCharCode(d),y):t(d)}function f(d){return d===45?(e.consume(d),i=2,p):d===91?(e.consume(d),i=5,a=0,b):re(d)?(e.consume(d),i=4,r.interrupt?n:m):t(d)}function p(d){return d===45?(e.consume(d),r.interrupt?n:m):t(d)}function b(d){let ne="CDATA[";return d===ne.charCodeAt(a++)?(e.consume(d),a===ne.length?r.interrupt?n:D:b):t(d)}function A(d){return re(d)?(e.consume(d),o=String.fromCharCode(d),y):t(d)}function y(d){if(d===null||d===47||d===62||K(d)){let ne=d===47,je=o.toLowerCase();return!ne&&!u&&Fn.includes(je)?(i=1,r.interrupt?n(d):D(d)):Ir.includes(o.toLowerCase())?(i=6,ne?(e.consume(d),F):r.interrupt?n(d):D(d)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(d):u?w(d):E(d))}return d===45||ee(d)?(e.consume(d),o+=String.fromCharCode(d),y):t(d)}function F(d){return d===62?(e.consume(d),r.interrupt?n:D):t(d)}function w(d){return z(d)?(e.consume(d),w):Y(d)}function E(d){return d===47?(e.consume(d),Y):d===58||d===95||re(d)?(e.consume(d),S):z(d)?(e.consume(d),E):Y(d)}function S(d){return d===45||d===46||d===58||d===95||ee(d)?(e.consume(d),S):T(d)}function T(d){return d===61?(e.consume(d),g):z(d)?(e.consume(d),T):E(d)}function g(d){return d===null||d===60||d===61||d===62||d===96?t(d):d===34||d===39?(e.consume(d),c=d,C):z(d)?(e.consume(d),g):_(d)}function C(d){return d===c?(e.consume(d),c=null,R):d===null||v(d)?t(d):(e.consume(d),C)}function _(d){return d===null||d===34||d===39||d===47||d===60||d===61||d===62||d===96||K(d)?T(d):(e.consume(d),_)}function R(d){return d===47||d===62||z(d)?E(d):t(d)}function Y(d){return d===62?(e.consume(d),H):t(d)}function H(d){return d===null||v(d)?D(d):z(d)?(e.consume(d),H):t(d)}function D(d){return d===45&&i===2?(e.consume(d),q):d===60&&i===1?(e.consume(d),W):d===62&&i===4?(e.consume(d),ue):d===63&&i===3?(e.consume(d),m):d===93&&i===5?(e.consume(d),pe):v(d)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check($u,he,B)(d)):d===null||v(d)?(e.exit("htmlFlowData"),B(d)):(e.consume(d),D)}function B(d){return e.check(Wu,L,he)(d)}function L(d){return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),I}function I(d){return d===null||v(d)?B(d):(e.enter("htmlFlowData"),D(d))}function q(d){return d===45?(e.consume(d),m):D(d)}function W(d){return d===47?(e.consume(d),o="",le):D(d)}function le(d){if(d===62){let ne=o.toLowerCase();return Fn.includes(ne)?(e.consume(d),ue):D(d)}return re(d)&&o.length<8?(e.consume(d),o+=String.fromCharCode(d),le):D(d)}function pe(d){return d===93?(e.consume(d),m):D(d)}function m(d){return d===62?(e.consume(d),ue):d===45&&i===2?(e.consume(d),m):D(d)}function ue(d){return d===null||v(d)?(e.exit("htmlFlowData"),he(d)):(e.consume(d),ue)}function he(d){return e.exit("htmlFlow"),n(d)}}function Zu(e,n,t){let r=this;return i;function i(o){return v(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),u):t(o)}function u(o){return r.parser.lazy[r.now().line]?t(o):n(o)}}function Ku(e,n,t){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ke,n,t)}}var yn={name:"htmlText",tokenize:Ju};function Ju(e,n,t){let r=this,i,u,o;return a;function a(m){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(m),c}function c(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),T):m===63?(e.consume(m),E):re(m)?(e.consume(m),_):t(m)}function l(m){return m===45?(e.consume(m),s):m===91?(e.consume(m),u=0,b):re(m)?(e.consume(m),w):t(m)}function s(m){return m===45?(e.consume(m),p):t(m)}function h(m){return m===null?t(m):m===45?(e.consume(m),f):v(m)?(o=h,W(m)):(e.consume(m),h)}function f(m){return m===45?(e.consume(m),p):h(m)}function p(m){return m===62?q(m):m===45?f(m):h(m)}function b(m){let ue="CDATA[";return m===ue.charCodeAt(u++)?(e.consume(m),u===ue.length?A:b):t(m)}function A(m){return m===null?t(m):m===93?(e.consume(m),y):v(m)?(o=A,W(m)):(e.consume(m),A)}function y(m){return m===93?(e.consume(m),F):A(m)}function F(m){return m===62?q(m):m===93?(e.consume(m),F):A(m)}function w(m){return m===null||m===62?q(m):v(m)?(o=w,W(m)):(e.consume(m),w)}function E(m){return m===null?t(m):m===63?(e.consume(m),S):v(m)?(o=E,W(m)):(e.consume(m),E)}function S(m){return m===62?q(m):E(m)}function T(m){return re(m)?(e.consume(m),g):t(m)}function g(m){return m===45||ee(m)?(e.consume(m),g):C(m)}function C(m){return v(m)?(o=C,W(m)):z(m)?(e.consume(m),C):q(m)}function _(m){return m===45||ee(m)?(e.consume(m),_):m===47||m===62||K(m)?R(m):t(m)}function R(m){return m===47?(e.consume(m),q):m===58||m===95||re(m)?(e.consume(m),Y):v(m)?(o=R,W(m)):z(m)?(e.consume(m),R):q(m)}function Y(m){return m===45||m===46||m===58||m===95||ee(m)?(e.consume(m),Y):H(m)}function H(m){return m===61?(e.consume(m),D):v(m)?(o=H,W(m)):z(m)?(e.consume(m),H):R(m)}function D(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(e.consume(m),i=m,B):v(m)?(o=D,W(m)):z(m)?(e.consume(m),D):(e.consume(m),L)}function B(m){return m===i?(e.consume(m),i=void 0,I):m===null?t(m):v(m)?(o=B,W(m)):(e.consume(m),B)}function L(m){return m===null||m===34||m===39||m===60||m===61||m===96?t(m):m===47||m===62||K(m)?R(m):(e.consume(m),L)}function I(m){return m===47||m===62||K(m)?R(m):t(m)}function q(m){return m===62?(e.consume(m),e.exit("htmlTextData"),e.exit("htmlText"),n):t(m)}function W(m){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),le}function le(m){return z(m)?P(e,pe,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):pe(m)}function pe(m){return e.enter("htmlTextData"),o(m)}}var Re={name:"labelEnd",tokenize:ro,resolveTo:no,resolveAll:to},Xu={tokenize:io},Gu={tokenize:uo},eo={tokenize:oo};function to(e){let n=-1;for(;++n=3&&(l===null||v(l))?(e.exit("thematicBreak"),n(l)):t(l)}function c(l){return l===i?(e.consume(l),r++,c):(e.exit("thematicBreakSequence"),z(l)?P(e,a,"whitespace")(l):a(l))}}var J={name:"list",tokenize:ho,continuation:{tokenize:mo},exit:Fo},fo={tokenize:xo,partial:!0},po={tokenize:go,partial:!0};function ho(e,n,t){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 a;function a(p){let b=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(b==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ft(p)){if(r.containerState.type||(r.containerState.type=b,e.enter(b,{_container:!0})),b==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(ze,t,l)(p):l(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return t(p)}function c(p){return ft(p)&&++o<10?(e.consume(p),c):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),l(p)):t(p)}function l(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(ke,r.interrupt?t:s,e.attempt(fo,f,h))}function s(p){return r.containerState.initialBlankLine=!0,u++,f(p)}function h(p){return z(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):t(p)}function f(p){return r.containerState.size=u+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(p)}}function mo(e,n,t){let r=this;return r.containerState._closeFlow=void 0,e.check(ke,i,u);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,P(e,n,"listItemIndent",r.containerState.size+1)(a)}function u(a){return r.containerState.furtherBlankLines||!z(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(po,n,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,P(e,e.attempt(J,n,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function go(e,n,t){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?n(u):t(u)}}function Fo(e){e.exit(this.containerState.type)}function xo(e,n,t){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!z(u)&&o&&o[1].type==="listItemPrefixWhitespace"?n(u):t(u)}}var zt={name:"setextUnderline",tokenize:Eo,resolveTo:yo};function yo(e,n){let t=e.length,r,i,u;for(;t--;)if(e[t][0]==="enter"){if(e[t][1].type==="content"){r=t;break}e[t][1].type==="paragraph"&&(i=t)}else e[t][1].type==="content"&&e.splice(t,1),!u&&e[t][1].type==="definition"&&(u=t);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,n]),e.splice(u+1,0,["exit",e[r][1],n]),e[r][1].end=Object.assign({},e[u][1].end)):e[r][1]=o,e.push(["exit",o,n]),e}function Eo(e,n,t){let r=this,i;return u;function u(l){let s=r.events.length,h;for(;s--;)if(r.events[s][1].type!=="lineEnding"&&r.events[s][1].type!=="linePrefix"&&r.events[s][1].type!=="content"){h=r.events[s][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=l,o(l)):t(l)}function o(l){return e.enter("setextHeadingLineSequence"),a(l)}function a(l){return l===i?(e.consume(l),a):(e.exit("setextHeadingLineSequence"),z(l)?P(e,c,"lineSuffix")(l):c(l))}function c(l){return l===null||v(l)?(e.exit("setextHeadingLine"),n(l)):t(l)}}var Lr={tokenize:Ao};function Ao(e){let n=this,t=e.attempt(ke,r,e.attempt(this.parser.constructs.flowInitial,i,P(e,e.attempt(this.parser.constructs.flow,i,e.attempt(cn,i)),"linePrefix")));return t;function r(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),n.currentConstruct=void 0,t}function i(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),n.currentConstruct=void 0,t}}var Rr={resolveAll:jr()},zr=Nr("string"),Mr=Nr("text");function Nr(e){return{tokenize:n,resolveAll:jr(e==="text"?Co:void 0)};function n(t){let r=this,i=this.parser.constructs[e],u=t.attempt(i,o,a);return o;function o(s){return l(s)?u(s):a(s)}function a(s){if(s===null){t.consume(s);return}return t.enter("data"),t.consume(s),c}function c(s){return l(s)?(t.exit("data"),u(s)):(t.consume(s),c)}function l(s){if(s===null)return!0;let h=i[s],f=-1;if(h)for(;++f-1){let a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}u>0&&o.push(e[i].slice(0,u))}return o}function ko(e,n){let t=-1,r=[],i;for(;++t_o,contentInitial:()=>Do,disable:()=>Po,document:()=>wo,flow:()=>Bo,flowInitial:()=>So,insideSpan:()=>Oo,string:()=>vo,text:()=>To});var wo={42:J,43:J,45:J,48:J,49:J,50:J,51:J,52:J,53:J,54:J,55:J,56:J,57:J,62:vt},Do={91:mn},So={[-2]:pt,[-1]:pt,32:pt},Bo={35:gn,42:ze,45:[zt,ze],60:xn,61:zt,95:ze,96:_t,126:_t},vo={38:Ot,92:Tt},To={[-5]:ht,[-4]:ht,[-3]:ht,33:En,38:Ot,42:ct,60:[sn,yn],91:An,92:[dn,Tt],93:Re,95:ct,96:ln},Oo={null:[ct,Rr]},_o={null:[42,95]},Po={null:[]};function Vr(e){let t=ar([Cn,...(e||{}).extensions||[]]),r={defined:[],lazy:{},constructs:t,content:i(cr),document:i(pr),flow:i(Lr),string:i(zr),text:i(Mr)};return r;function i(u){return o;function o(a){return Ur(r,u,a)}}}var Hr=/[\0\t\n\r]/g;function qr(){let e=1,n="",t=!0,r;return i;function i(u,o,a){let c=[],l,s,h,f,p;for(u=n+u.toString(o),h=0,n="",t&&(u.charCodeAt(0)===65279&&h++,t=void 0);h13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"\uFFFD":String.fromCharCode(t)}var Io=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Wr(e){return e.replace(Io,Lo)}function Lo(e,n,t){if(n)return n;if(t.charCodeAt(0)===35){let i=t.charCodeAt(1),u=i===120||i===88;return Mt(t.slice(u?2:1),u?16:10)}return We(t)||e}function ve(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Yr(e.position):"start"in e||"end"in e?Yr(e):"line"in e||"column"in e?bn(e):""}function bn(e){return Qr(e&&e.line)+":"+Qr(e&&e.column)}function Yr(e){return bn(e&&e.start)+"-"+bn(e&&e.end)}function Qr(e){return e&&typeof e=="number"?e:1}var Kr={}.hasOwnProperty,kn=function(e,n,t){return typeof n!="string"&&(t=n,n=void 0),Ro(t)($r(Vr(t).document().write(qr()(e,n,!0))))};function Ro(e){let n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Qn),autolinkProtocol:H,autolinkEmail:H,atxHeading:a($n),blockQuote:a(Ue),characterEscape:H,characterReference:H,codeFenced:a(Pe),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:a(Pe,c),codeText:a(Qt,c),codeTextData:H,data:H,codeFlowValue:H,definition:a(ji),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:a(Ui),hardBreakEscape:a(Wn),hardBreakTrailing:a(Wn),htmlFlow:a(Yn,c),htmlFlowData:H,htmlText:a(Yn,c),htmlTextData:H,image:a(Vi),label:c,link:a(Qn),listItem:a(Hi),listItemValue:b,listOrdered:a(Zn,p),listUnordered:a(Zn),paragraph:a(qi),reference:je,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:a($n),strong:a($i),thematicBreak:a(Yi)},exit:{atxHeading:s(),atxHeadingSequence:C,autolink:s(),autolinkEmail:me,autolinkProtocol:it,blockQuote:s(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:rt,characterReferenceMarkerNumeric:rt,characterReferenceValue:Q,codeFenced:s(w),codeFencedFence:F,codeFencedFenceInfo:A,codeFencedFenceMeta:y,codeFlowValue:D,codeIndented:s(E),codeText:s(W),codeTextData:D,data:D,definition:s(),definitionDestinationString:g,definitionLabelString:S,definitionTitleString:T,emphasis:s(),hardBreakEscape:s(L),hardBreakTrailing:s(L),htmlFlow:s(I),htmlFlowData:D,htmlText:s(q),htmlTextData:D,image:s(pe),label:ue,labelText:m,lineEnding:B,link:s(le),listItem:s(),listOrdered:s(),listUnordered:s(),paragraph:s(),referenceString:Yt,resourceDestinationString:he,resourceTitleString:d,resource:ne,setextHeading:s(Y),setextHeadingLineSequence:R,setextHeadingText:_,strong:s(),thematicBreak:s()}};Jr(n,(e||{}).mdastExtensions||[]);let t={};return r;function r(x){let k={type:"root",children:[]},O={stack:[k],tokenStack:[],config:n,enter:l,exit:h,buffer:c,resume:f,setData:u,getData:o},j=[],U=-1;for(;++U0){let ce=O.tokenStack[O.tokenStack.length-1];(ce[1]||Zr).call(O,void 0,ce[0])}for(k.position={start:Te(x.length>0?x[0][1].start:{line:1,column:1,offset:0}),end:Te(x.length>0?x[x.length-2][1].end:{line:1,column:1,offset:0})},U=-1;++U{let r=this.data("settings");return kn(t,Object.assign({},r,e,{extensions:this.data("micromarkExtensions")||[],mdastExtensions:this.data("fromMarkdownExtensions")||[]}))}})}function wn(e){if(e)throw e}var gi=Dt(Dn(),1),In=Dt(ai(),1);function mt(e){if(typeof e!="object"||e===null)return!1;let n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Sn(){let e=[],n={run:t,use:r};return n;function t(...i){let u=-1,o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(c,...l){let s=e[++u],h=-1;if(c){o(c);return}for(;++ho.length,c;a&&o.push(i);try{c=e.apply(this,o)}catch(l){let s=l;if(a&&t)throw s;return i(s)}a||(c&&c.then&&typeof c.then=="function"?c.then(u,i):c instanceof Error?i(c):u(c))}function i(o,...a){t||(t=!0,n(o,...a))}function u(o){i(null,o)}}var pi=Dt(Dn(),1);var X=class extends Error{constructor(n,t,r){let i=[null,null],u={start:{line:null,column:null},end:{line:null,column:null}};if(super(),typeof t=="string"&&(r=t,t=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))}t&&("type"in t||"position"in t?t.position&&(u=t.position):"start"in t||"end"in t?u=t:("line"in t||"column"in t)&&(u.start=t)),this.name=ve(t)||"1:1",this.message=typeof n=="object"?n.message:n,this.stack="",typeof n=="object"&&n.stack&&(this.stack=n.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}};X.prototype.file="";X.prototype.name="";X.prototype.reason="";X.prototype.message="";X.prototype.stack="";X.prototype.fatal=null;X.prototype.column=null;X.prototype.line=null;X.prototype.source=null;X.prototype.ruleId=null;X.prototype.position=null;var fe={basename:Mo,dirname:No,extname:jo,join:Uo,sep:"/"};function Mo(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');dt(e);let t=0,r=-1,i=e.length,u;if(n===void 0||n.length===0||n.length>e.length){for(;i--;)if(e.charCodeAt(i)===47){if(u){t=i+1;break}}else r<0&&(u=!0,r=i+1);return r<0?"":e.slice(t,r)}if(n===e)return"";let o=-1,a=n.length-1;for(;i--;)if(e.charCodeAt(i)===47){if(u){t=i+1;break}}else o<0&&(u=!0,o=i+1),a>-1&&(e.charCodeAt(i)===n.charCodeAt(a--)?a<0&&(r=i):(a=-1,r=o));return t===r?r=o:r<0&&(r=e.length),e.slice(t,r)}function No(e){if(dt(e),e.length===0)return".";let n=-1,t=e.length,r;for(;--t;)if(e.charCodeAt(t)===47){if(r){n=t;break}}else r||(r=!0);return n<0?e.charCodeAt(0)===47?"/":".":n===1&&e.charCodeAt(0)===47?"//":e.slice(0,n)}function jo(e){dt(e);let n=e.length,t=-1,r=0,i=-1,u=0,o;for(;n--;){let a=e.charCodeAt(n);if(a===47){if(o){r=n+1;break}continue}t<0&&(o=!0,t=n+1),a===46?i<0?i=n:u!==1&&(u=1):i>-1&&(u=-1)}return i<0||t<0||u===0||u===1&&i===t-1&&i===r+1?"":e.slice(i,t)}function Uo(...e){let n=-1,t;for(;++n0&&e.charCodeAt(e.length-1)===47&&(t+="/"),n?"/"+t:t}function Ho(e,n){let t="",r=0,i=-1,u=0,o=-1,a,c;for(;++o<=e.length;){if(o2){if(c=t.lastIndexOf("/"),c!==t.length-1){c<0?(t="",r=0):(t=t.slice(0,c),r=t.length-1-t.lastIndexOf("/")),i=o,u=0;continue}}else if(t.length>0){t="",r=0,i=o,u=0;continue}}n&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+e.slice(i+1,o):t=e.slice(i+1,o),r=o-i-1;i=o,u=0}else a===46&&u>-1?u++:u=-1}return t}function dt(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var li={cwd:qo};function qo(){return"/"}function Ye(e){return e!==null&&typeof e=="object"&&e.href&&e.origin}function ci(e){if(typeof e=="string")e=new URL(e);else if(!Ye(e)){let n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){let n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return $o(e)}function $o(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 n=e.pathname,t=-1;for(;++t{if(g||!C||!_)T(g);else{let R=u.stringify(C,_);R==null||(Zo(R)?_.value=R:_.result=R),T(g,_)}});function T(g,C){g||!C?E(g):w?w(C):y(null,C)}}}function b(A){let y;u.freeze(),On("processSync",u.Parser),_n("processSync",u.Compiler);let F=Ft(A);return u.process(F,w),di("processSync","process",y),F;function w(E){y=!0,wn(E)}}}function hi(e,n){return typeof e=="function"&&e.prototype&&(Yo(e.prototype)||n in e.prototype)}function Yo(e){let n;for(n in e)if(Fi.call(e,n))return!0;return!1}function On(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `Parser`")}function _n(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `Compiler`")}function Pn(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function mi(e){if(!mt(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function di(e,n,t){if(!t)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Ft(e){return Qo(e)?e:new gt(e)}function Qo(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Zo(e){return typeof e=="string"||(0,gi.default)(e)}var Rn={children(e){return Ve.children(e)},annotatetextnode(e,n){return Ve.annotatetextnode(e,n)},interpretmarkup(e=""){return` `.repeat((e.match(/\n/g)||[]).length)},remarkoptions:{}};function yi(e,n=Rn){let t=Ln().use(Nt,n.remarkoptions).use(Bt,["yaml","toml"]).parse(e);return Xn(e,t,n)}var _e=require("obsidian");function Jo(e,n,t){return n=xt(n),ia(e,Un()?Reflect.construct(n,t||[],xt(e).constructor):n.apply(e,t))}function bi(e,n,t){if(Un())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,n);var i=new(e.bind.apply(e,r));return t&&yt(i,t.prototype),i}function Un(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(n){}return(Un=function(){return!!e})()}function Ei(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),t.push.apply(t,r)}return t}function Xo(e){for(var n=1;ne.length)&&(n=e.length);for(var t=0,r=new Array(n);t=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var u=!0,o=!1,a;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return u=c.done,c},e:function(c){o=!0,a=c},f:function(){try{!u&&t.return!=null&&t.return()}finally{if(o)throw a}}}}var la=function(){function e(){Ke(this,e)}return Je(e,[{key:"add",value:function(t,r,i){if(typeof arguments[0]!="string")for(var u in arguments[0])this.add(u,arguments[0][u],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(o){this[o]=this[o]||[],r&&this[o][i?"unshift":"push"](r)},this)}},{key:"run",value:function(t,r){this[t]=this[t]||[],this[t].forEach(function(i){i.call(r&&r.context?r.context:r,r)})}}])}(),ca=function(){function e(n){Ke(this,e),this.jsep=n,this.registered={}}return Je(e,[{key:"register",value:function(){for(var t=this,r=arguments.length,i=new Array(r),u=0;u0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.lengthp.prec:i<=p.prec};u.length>2&&h(u[u.length-2]);)c=u.pop(),r=u.pop().value,a=u.pop(),t={type:e.BINARY_EXP,operator:r,left:a,right:c},u.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+s),u.push(o,t)}for(l=u.length-1,t=u[l];l>1;)t={type:e.BINARY_EXP,operator:u[l-1].value,left:u[l-2],right:t},l-=2;return t}},{key:"gobbleToken",value:function(){var t,r,i,u;if(this.gobbleSpaces(),u=this.searchHook("gobble-token"),u)return this.runHook("after-token",u);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)u=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)u=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),i=r.length;i>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(o===e.COMMA_CODE){if(this.index++,u++,u!==r.length){if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(var a=r.length;a=48&&t<=57}},{key:"binaryPrecedence",value:function(t){return e.binary_ops[t]||0}},{key:"isIdentifierStart",value:function(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))}},{key:"isIdentifierPart",value:function(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}}])}(),fa=new la;Object.assign(ae,{hooks:fa,plugins:new ca(ae),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops);ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops);var Ze=function(n){return new ae(n).parse()},pa=Object.getOwnPropertyNames(ae);pa.forEach(function(e){Ze[e]===void 0&&e!=="prototype"&&(Ze[e]=ae[e])});Ze.Jsep=ae;var ha="ConditionalExpression",ma={name:"ternary",init:function(n){n.hooks.add("after-expression",function(r){if(r.node&&this.code===n.QUMARK_CODE){this.index++;var i=r.node,u=this.gobbleExpression();if(u||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===n.COLON_CODE){this.index++;var o=this.gobbleExpression();if(o||this.throwError("Expected expression"),r.node={type:ha,test:i,consequent:u,alternate:o},i.operator&&n.binary_ops[i.operator]<=.9){for(var a=i;a.right.operator&&n.binary_ops[a.right.operator]<=.9;)a=a.right;r.node.test=a.right,a.right=r.node,r.node=i}}else this.throwError("Expected :")}})}};Ze.plugins.register(ma);var Ci=47,da=92,ga={name:"regex",init:function(n){n.hooks.add("gobble-token",function(r){if(this.code===Ci){for(var i=++this.index,u=!1;this.index=97&&c<=122||c>=65&&c<=90||c>=48&&c<=57)a+=this.char;else break}var l=void 0;try{l=new RegExp(o,a)}catch(s){this.throwError(s.message)}return r.node={type:n.LITERAL,value:l,raw:this.expr.slice(i-1,this.index)},r.node=this.gobbleTokenProperty(r.node),r.node}this.code===n.OBRACK_CODE?u=!0:u&&this.code===n.CBRACK_CODE&&(u=!1),this.index+=this.code===da?2:1}this.throwError("Unclosed Regex")}})}},zn=43,Fa=45,Qe={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[zn,Fa],assignmentPrecedence:.9,init:function(n){var t=[n.IDENTIFIER,n.MEMBER_EXP];Qe.assignmentOperators.forEach(function(i){return n.addBinaryOp(i,Qe.assignmentPrecedence,!0)}),n.hooks.add("gobble-token",function(u){var o=this,a=this.code;Qe.updateOperators.some(function(c){return c===a&&c===o.expr.charCodeAt(o.index+1)})&&(this.index+=2,u.node={type:"UpdateExpression",operator:a===zn?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},(!u.node.argument||!t.includes(u.node.argument.type))&&this.throwError("Unexpected ".concat(u.node.operator)))}),n.hooks.add("after-token",function(u){var o=this;if(u.node){var a=this.code;Qe.updateOperators.some(function(c){return c===a&&c===o.expr.charCodeAt(o.index+1)})&&(t.includes(u.node.type)||this.throwError("Unexpected ".concat(u.node.operator)),this.index+=2,u.node={type:"UpdateExpression",operator:a===zn?"++":"--",argument:u.node,prefix:!1})}}),n.hooks.add("after-expression",function(u){u.node&&r(u.node)});function r(i){Qe.assignmentOperators.has(i.operator)?(i.type="AssignmentExpression",r(i.left),r(i.right)):i.operator||Object.values(i).forEach(function(u){u&&oe(u)==="object"&&r(u)})}}},te=Object.prototype.hasOwnProperty;function Oe(e,n){return e=e.slice(),e.push(n),e}function jn(e,n){return n=n.slice(),n.unshift(e),n}var xa=function(e){function n(t){var r;return Ke(this,n),r=Jo(this,n,['JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)']),r.avoidNew=!0,r.value=t,r.name="NewError",r}return ta(n,e),Je(n)}(Mn(Error));function M(e,n,t,r,i){if(!(this instanceof M))try{return new M(e,n,t,r,i)}catch(c){if(!c.avoidNew)throw c;return c.value}typeof e=="string"&&(i=r,r=t,t=n,n=e,e=null);var u=e&&oe(e)==="object";if(e=e||{},this.json=e.json||t,this.path=e.path||n,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=te.call(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){var o={path:u?e.path:n};u?"json"in e&&(o.json=e.json):o.json=t;var a=this.evaluate(o);if(!a||oe(a)!=="object")throw new xa(a);return a}}M.prototype.evaluate=function(e,n,t,r){var i=this,u=this.parent,o=this.parentProperty,a=this.flatten,c=this.wrap;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,t=t||this.callback,this.currOtherTypeCallback=r||this.otherTypeCallback,n=n||this.json,e=e||this.path,e&&oe(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(!te.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');var l=e;n=l.json,a=te.call(e,"flatten")?e.flatten:a,this.currResultType=te.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=te.call(e,"sandbox")?e.sandbox:this.currSandbox,c=te.call(e,"wrap")?e.wrap:c,this.currEval=te.call(e,"eval")?e.eval:this.currEval,t=te.call(e,"callback")?e.callback:t,this.currOtherTypeCallback=te.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,u=te.call(e,"parent")?e.parent:u,o=te.call(e,"parentProperty")?e.parentProperty:o,e=e.path}if(u=u||null,o=o||null,Array.isArray(e)&&(e=M.toPathString(e)),!(!e&&e!==""||!n)){var s=M.toPathArray(e);s[0]==="$"&&s.length>1&&s.shift(),this._hasParentSelector=null;var h=this._trace(s,n,["$"],u,o,t).filter(function(f){return f&&!f.isParentSelector});return h.length?!c&&h.length===1&&!h[0].hasArrExpr?this._getPreferredOutput(h[0]):h.reduce(function(f,p){var b=i._getPreferredOutput(p);return a&&Array.isArray(b)?f=f.concat(b):f.push(b),f},[]):c?[]:void 0}};M.prototype._getPreferredOutput=function(e){var n=this.currResultType;switch(n){case"all":{var t=Array.isArray(e.path)?e.path:M.toPathArray(e.path);return e.pointer=M.toPointer(t),e.path=typeof e.path=="string"?e.path:M.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[n];case"path":return M.toPathString(e[n]);case"pointer":return M.toPointer(e.path);default:throw new TypeError("Unknown result type")}};M.prototype._handleCallback=function(e,n,t){if(n){var r=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:M.toPathString(e.path),n(r,t,e)}};M.prototype._trace=function(e,n,t,r,i,u,o,a){var c=this,l;if(!e.length)return l={path:t,value:n,parent:r,parentProperty:i,hasArrExpr:o},this._handleCallback(l,u,"value"),l;var s=e[0],h=e.slice(1),f=[];function p(D){Array.isArray(D)?D.forEach(function(B){f.push(B)}):f.push(D)}if((typeof s!="string"||a)&&n&&te.call(n,s))p(this._trace(h,n[s],Oe(t,s),n,s,u,o));else if(s==="*")this._walk(n,function(D){p(c._trace(h,n[D],Oe(t,D),n,D,u,!0,!0))});else if(s==="..")p(this._trace(h,n,t,r,i,u,o)),this._walk(n,function(D){oe(n[D])==="object"&&p(c._trace(e.slice(),n[D],Oe(t,D),n,D,u,!0))});else{if(s==="^")return this._hasParentSelector=!0,{path:t.slice(0,-1),expr:h,isParentSelector:!0};if(s==="~")return l={path:Oe(t,s),value:i,parent:r,parentProperty:null},this._handleCallback(l,u,"property"),l;if(s==="$")p(this._trace(h,n,t,null,null,u,o));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(s))p(this._slice(s,h,n,t,r,i,u));else if(s.indexOf("?(")===0){if(this.currEval===!1)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");var b=s.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),A=/@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])?((?:[\0->@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))(?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\)\])['\]]/g.exec(b);A?this._walk(n,function(D){var B=[A[2]],L=A[1]?n[D][A[1]]:n[D],I=c._trace(B,L,t,r,i,u,!0);I.length>0&&p(c._trace(h,n[D],Oe(t,D),n,D,u,!0))}):this._walk(n,function(D){c._eval(b,n[D],D,t,r,i)&&p(c._trace(h,n[D],Oe(t,D),n,D,u,!0))})}else if(s[0]==="("){if(this.currEval===!1)throw new Error("Eval [(expr)] prevented in JSONPath expression.");p(this._trace(jn(this._eval(s,n,t[t.length-1],t.slice(0,-1),r,i),h),n,t,r,i,u,o))}else if(s[0]==="@"){var y=!1,F=s.slice(1,-2);switch(F){case"scalar":(!n||!["object","function"].includes(oe(n)))&&(y=!0);break;case"boolean":case"string":case"undefined":case"function":oe(n)===F&&(y=!0);break;case"integer":Number.isFinite(n)&&!(n%1)&&(y=!0);break;case"number":Number.isFinite(n)&&(y=!0);break;case"nonFinite":typeof n=="number"&&!Number.isFinite(n)&&(y=!0);break;case"object":n&&oe(n)===F&&(y=!0);break;case"array":Array.isArray(n)&&(y=!0);break;case"other":y=this.currOtherTypeCallback(n,t,r,i);break;case"null":n===null&&(y=!0);break;default:throw new TypeError("Unknown value type "+F)}if(y)return l={path:t,value:n,parent:r,parentProperty:i},this._handleCallback(l,u,"value"),l}else if(s[0]==="`"&&n&&te.call(n,s.slice(1))){var w=s.slice(1);p(this._trace(h,n[w],Oe(t,w),n,w,u,o,!0))}else if(s.includes(",")){var E=s.split(","),S=sa(E),T;try{for(S.s();!(T=S.n()).done;){var g=T.value;p(this._trace(jn(g,h),n,t,r,i,u,!0))}}catch(D){S.e(D)}finally{S.f()}}else!a&&n&&te.call(n,s)&&p(this._trace(h,n[s],Oe(t,s),n,s,u,o,!0))}if(this._hasParentSelector)for(var C=0;C":function(u,o){return u>o()},"<=":function(u,o){return u<=o()},">=":function(u,o){return u>=o()},"<<":function(u,o){return u<>":function(u,o){return u>>o()},">>>":function(u,o){return u>>>o()},"+":function(u,o){return u+o()},"-":function(u,o){return u-o()},"*":function(u,o){return u*o()},"/":function(u,o){return u/o()},"%":function(u,o){return u%o()}}[n.operator](V.evalAst(n.left,t),function(){return V.evalAst(n.right,t)});return r},evalCompound:function(n,t){for(var r,i=0;i-1?r.slice(0,c+1)+" return "+r.slice(c+1):" return "+r;return bi(Function,i.concat([l])).apply(void 0,Vn(o))}}])}();M.prototype.vm={Script:Aa};M.prototype.safeVm={Script:Ea};var ie;(h=>{async function e(f,p,b){var E;let A=yi(b,{...Rn,interpretmarkup(S=""){var g,C;if(/^`[^`]+`$/.test(S))return S;let T=` `.repeat((C=(g=S.match(/\n/g))==null?void 0:g.length)!=null?C:0);return S.match(/^\s*(-|\d+\.) $/m)?T+"\u2022 ":T}}),y={data:JSON.stringify(A),language:(E=f.staticLanguage)!=null?E:"auto",enabledOnly:"false",level:f.pickyMode?"picky":"default"};f.motherTongue&&(y.motherTongue=f.motherTongue),f.enabledCategories&&(y.enabledCategories=f.enabledCategories),f.disabledCategories&&(y.disabledCategories=f.disabledCategories),f.enabledRules&&(y.enabledRules=f.enabledRules),f.disabledRules&&(y.disabledRules=f.disabledRules),f.staticLanguage==null&&(y.preferredVariants=Object.values(f.languageVariety).join(",")),f.apikey&&f.username&&(y.username=f.username,y.apiKey=f.apikey);let F;try{F=await(0,_e.requestUrl)({url:`${f.serverUrl}/v2/check`,method:"POST",body:new URLSearchParams(y).toString(),throw:!0,headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}})}catch(S){throw console.log(S),new Error(`Request to LanguageTool failed: Please check your connection and server URL. ${S}`)}if(F.json==null)throw new Error("Error processing response from LanguageTool.");return l("$.matches[*]",F.json).map(S=>{let T=c("$.offset@number()",S),g=T+c("$.length@number()",S);return{text:b.slice(T,g),from:p+T,to:p+g,title:c("$.shortMessage@string()",S),message:c("$.message@string()",S),replacements:l("$.replacements[*].value@string()",S),categoryId:c("$.rule.category.id@string()",S),ruleId:c("$.rule.id@string()",S)}})}h.check=e;async function n(f){let p=await(0,_e.requestUrl)({url:`${f}/v2/languages`}).json;if(p==null||!(p instanceof Array))throw new Error("Error processing response from LanguageTool.");return p}h.languages=n;async function t(f){if(f.username==null||f.apikey==null)throw Error("Syncing words is only supported for premium users");try{let p=await(0,_e.requestUrl)({url:s(`${f.serverUrl}/v2/words`,{username:f.username,apiKey:f.apikey,limit:"1000"}).href}).json;return l("$.words[*]@string()",p)}catch(p){throw new Error(`Requesting words failed ${p}`)}}h.words=t;async function r(f,p){if(f.username==null||f.apikey==null)throw Error("Syncing words is only supported for premium users");try{let b=await(0,_e.requestUrl)({url:s(`${f.serverUrl}/v2/words/add`,{username:f.username,apiKey:f.apikey,word:p}).href,method:"POST"}).json;return c("$.added@boolean()",b)}catch(b){throw new Error(`Adding words failed ${b}`)}}h.wordsAdd=r;async function i(f,p){if(f.username==null||f.apikey==null)throw Error("Syncing words is only supported for premium users");try{let b=await(0,_e.requestUrl)({url:s(`${f.serverUrl}/v2/words/delete`,{username:f.username,apiKey:f.apikey,word:p}).href,method:"POST"}).json;return c("$.deleted@boolean()",b)}catch(b){throw new Error(`Deleting words failed ${b}`)}}h.wordsDel=i;class u{constructor(){this.url="https://qb-grammar-en.languagetool.org/phrasal-paraphraser/subscribe"}async query(p,b){let A="$.data.suggestions[*][*]@string()",y=p.slice(0,b.from).split(/\s+/).length,F=p.slice(b.from,b.to),w={message:{indices:[y],mode:0,phrases:[F],text:p},meta:{clientStatus:"string",product:"string",traceID:"string",userID:"string"},response_queue:"string"},E;try{return E=await(0,_e.requestUrl)({url:this.url,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)}).json,l(A,E)}catch(S){throw new Error(`Requesting synonyms failed ${S}`)}}}class o{constructor(){this.url="https://synonyms.languagetool.org/synonyms/de"}async query(p,b){let A=p.slice(b.from,b.to).trim(),y=p.slice(0,b.from).split(/\s+/).join("+"),F=p.slice(b.to).split(/\s+/).join("+"),w;try{return w=await(0,_e.requestUrl)({url:s(`${this.url}/${A}`,{before:y,after:F}).href,method:"GET"}).json,l("$.synsets[*].terms[*].term@string()",w)}catch(E){throw new Error(`Requesting synonyms failed ${E}`)}}}h.SYNONYMS={en:new u,de:new o};function c(f,p){let b=M({path:f,json:p,wrap:!1,eval:!1});if(b==null)throw new Error("Error parsing response.");return b}function l(f,p){let b=M({path:f,json:p,wrap:!0,eval:!1});if(b==null||!(b instanceof Array))throw new Error("Error parsing response.");return b}function s(f,p){let b=new URL(f);return b.search=new URLSearchParams(p).toString(),b}})(ie||(ie={}));function Ut(e){switch(e){case"COLLOQUIALISMS":case"REDUNDANCY":case"STYLE":case"SYNONYMS":return"lt-style";case"TYPOS":return"lt-major"}return"lt-minor"}function Xe(e,n){let t=new Set(e);for(let r of n)t.delete(r);return t}function Hn(e,n){let t=new Set(e);for(let r of n)t.add(r);return t}function Di(e,n){let t=new Set;for(let r of n)e.has(r)&&t.add(r);return t}function Ge(e,n){return e=e.toLowerCase(),n=n.toLowerCase(),e>n?1:et.code===n).filter(t=>t.longCode!==t.code),Object.fromEntries(e.map(t=>[t.longCode,t.name]))}var Vt=class extends N.PluginSettingTab{constructor(t,r){super(t,r);this.endpointListeners=[];this.languageListeners=[];this.languages=[];this.plugin=r}configureCheckDelay(t,r){let i=Ct[r].minDelay;this.plugin.settings.autoCheckDelay=Math.clamp(this.plugin.settings.autoCheckDelay,i,Si),t.setLimits(i,Si,Ca)}async notifyEndpointChange(t){for(let r of this.endpointListeners)await r(t.serverUrl)}async configureLanguageVariants(t,r){var o;let i=this.plugin.settings.languageVariety,u=Bi(this.languages,r);i[r]=(o=i[r])!=null?o:Object.keys(u)[0],t.addOptions(u).setValue(i[r]).onChange(async a=>{i[r]=a,await this.plugin.saveSettings()}),this.languageListeners.push(async a=>{var l;for(;t.selectEl.options.length>0;)t.selectEl.remove(0);let c=Bi(a,r);i[r]=(l=i[r])!=null?l:Object.keys(c)[0],t.addOptions(c).setValue(i[r])})}async display(){let{containerEl:t}=this;t.empty();let r=this.plugin.settings;this.endpointListeners=[],this.endpointListeners.push(async l=>{let s=[];l&&(s=await ie.languages(l)),this.languages=s;for(let h of this.languageListeners)await h(s)}),this.endpointListeners.push(async l=>{await this.plugin.syncDictionary()}),this.languageListeners=[],new N.Setting(t).setName("Error logs").setDesc(`${this.plugin.logs.length} messages`).addButton(l=>{l.setButtonText("Copy to clipboard").onClick(async()=>{await window.navigator.clipboard.writeText(this.plugin.logs.join(` `)),new N.Notice("Logs copied to clipboard")})});let i=At(r.serverUrl),u=null;new N.Setting(t).setName("Endpoint").setDesc("Choose the LanguageTool server url").then(l=>{l.controlEl.classList.add("lt-settings-grid");let s=null,h=null;l.addDropdown(f=>{s=f,f.addOptions({standard:"(Standard) api.languagetool.org",premium:"(Premium) api.languagetoolplus.com",custom:"Custom URL"}).setValue(i).onChange(async p=>{i=p,r.serverUrl=Ct[i].url,h&&h.setValue(r.serverUrl).setDisabled(p!=="custom"),u&&this.configureCheckDelay(u,i),await this.notifyEndpointChange(r),await this.plugin.saveSettings()})}),l.addText(f=>{h=f,f.setPlaceholder("https://your-custom-url.com").setValue(r.serverUrl).setDisabled(i!=="custom").onChange(async p=>{r.serverUrl=p.replace(/\/v2\/check\/$/,"").replace(/\/$/,""),i=At(r.serverUrl),i!=="custom"&&(s==null||s.setValue(i),h==null||h.setDisabled(!0)),await this.notifyEndpointChange(r),await this.plugin.saveSettings()})})}),new N.Setting(t).setName("API username").setDesc("Enter a username/mail for API access").addText(l=>l.setPlaceholder("peterlustig@example.com").setValue(r.username||"").onChange(async s=>{r.username=s.replace(/\s+/g,""),await this.plugin.saveSettings()})),new N.Setting(t).setName("API key").setDesc(createFragment(l=>{l.createEl("a",{text:"Click here for information about Premium Access",href:"https://github.com/wrenger/obsidian-languagetool#premium-accounts",attr:{target:"_blank"}})})).addText(l=>l.setValue(r.apikey||"").onChange(async s=>{r.apikey=s.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(t).setName("Auto check text").setDesc("Check text as you type").addToggle(l=>{l.setValue(r.shouldAutoCheck).onChange(async s=>{r.shouldAutoCheck=s,await this.plugin.saveSettings()})}),new N.Setting(t).setName("Auto check delay (ms)").setDesc("Time to wait for autocheck after the last key press").addSlider(l=>{u=l,this.configureCheckDelay(l,i),l.setValue(r.autoCheckDelay).onChange(async s=>{r.autoCheckDelay=s,await this.plugin.saveSettings()}).setDynamicTooltip()});function o(l){if(l.appendText("Enables the context menu for synonyms fetched from"),l.createEl("br"),r.synonyms!=null){let s=ie.SYNONYMS[r.synonyms];if(!s){l.appendText(" (unknown API)");return}l.createEl("a",{text:s.url,href:s.url,attr:{target:"_blank"}})}else l.appendText("(none)")}let a=new N.Setting(t).setName("Find synonyms").setDesc(createFragment(o));a.addDropdown(l=>{var s;l.addOption("none","---");for(let h of Object.keys(ie.SYNONYMS))l.addOption(h,h);l.setValue((s=r.synonyms)!=null?s:"none").onChange(async h=>{r.synonyms=h!=="none"?h:void 0,await this.plugin.saveSettings(),a.setDesc(createFragment(o))})}),new N.Setting(t).setName("Language settings").setHeading(),new N.Setting(t).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(l=>{this.languageListeners.push(async s=>{var h;for(;l.selectEl.options.length>0;)l.selectEl.remove(0);l.addOption("none","---").addOptions(Object.fromEntries(s.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(t).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(l=>{this.languageListeners.push(async s=>{var h;for(;l.selectEl.options.length>0;)l.selectEl.remove(0);l.addOption("auto","Auto Detect").addOptions(Object.fromEntries(s.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(t).setName("Language varieties").setHeading().setDesc("Some languages have varieties depending on the country they are spoken in.");let c={en:"English",de:"German",pt:"Portuguese",ca:"Catalan"};for(let[l,s]of Object.entries(c))new N.Setting(t).setName(`Interpret ${s} as`).addDropdown(async h=>{this.configureLanguageVariants(h,l)});new N.Setting(t).setName("Spellcheck Dictionary").setHeading(),new N.Setting(t).setName("Ignored Words").setDesc("Words that should not be highlighted as spelling mistakes.").addButton(l=>{l.setIcon("settings").setTooltip("Edit dictionary").onClick(()=>{new qn(this.app,this.plugin).open()})}),new N.Setting(t).setName("Sync with LanguageTool").setDesc("This is only supported for premium users.").addToggle(l=>{l.setDisabled(i!=="premium").setValue(r.syncDictionary).onChange(async s=>{r.syncDictionary=s,await this.plugin.syncDictionary()}),this.endpointListeners.push(async s=>{l.setDisabled(At(s)!=="premium")})}),new N.Setting(t).setName("Rule categories").setHeading().setDesc(createFragment(l=>{l.appendText("The picky mode enables a lot of extra categories and rules. Additionally, you can enable or disable specific rules down below."),l.createEl("br"),l.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(t).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(l=>{l.setValue(r.pickyMode).onChange(async s=>{r.pickyMode=s,await this.plugin.saveSettings()})}),new N.Setting(t).setName("Enabled categories").setDesc("Comma-separated list of categories").addText(l=>{var s;return l.setPlaceholder("CATEGORY_1,CATEGORY_2").setValue((s=r.enabledCategories)!=null?s:"").onChange(async h=>{r.enabledCategories=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(t).setName("Disabled categories").setDesc("Comma-separated list of categories").addText(l=>{var s;return l.setPlaceholder("CATEGORY_1,CATEGORY_2").setValue((s=r.disabledCategories)!=null?s:"").onChange(async h=>{r.disabledCategories=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(t).setName("Enabled rules").setDesc("Comma-separated list of rules").addText(l=>{var s;return l.setPlaceholder("RULE_1,RULE_2").setValue((s=r.enabledRules)!=null?s:"").onChange(async h=>{r.enabledRules=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(t).setName("Disabled rules").setDesc("Comma-separated list of rules").addText(l=>{var s;return l.setPlaceholder("RULE_1,RULE_2").setValue((s=r.disabledRules)!=null?s:"").onChange(async h=>{r.disabledRules=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),await this.notifyEndpointChange(r)}},qn=class extends N.Modal{constructor(n,t){super(n),this.setTitle("Spellcheck dictionary"),this.plugin=t,this.words=t.settings.dictionary}async onOpen(){this.words=this.plugin.settings.dictionary;let{contentEl:n}=this,t=a=>{a.replaceChildren(...this.words.map(c=>a.createDiv({cls:"multi-select-pill"},l=>{l.createDiv({cls:"multi-select-pill-content"},s=>s.createSpan({text:c})),l.createDiv({cls:"multi-select-pill-remove-button"},s=>{s.appendChild((0,N.getIcon)("x")),s.onClickEvent(()=>{this.words.remove(c),t(a)})})})))},r=null;n.createDiv({cls:"multi-select-container"},a=>{r=a,t(a)}),this.plugin.syncDictionary().then(a=>{a&&(this.words=this.plugin.settings.dictionary,r&&t(r))});let i="",u=null,o=()=>{i&&(this.words=[...new Set([...this.words,i])].sort(Ge),r&&t(r),u&&u.setValue(""),i="")};new N.Setting(n).setName("Add").addText(a=>{u=a.setValue(i).onChange(c=>i=c.trim()),a.inputEl.addEventListener("keypress",c=>{c.key==="Enter"&&o()})}).addExtraButton(a=>{a.setIcon("plus").setTooltip("Add").onClick(()=>{o()})})}async onClose(){this.contentEl.empty(),this.plugin.settings.dictionary=this.words,await this.plugin.syncDictionary()}};var zi=require("@codemirror/view");var Ti=require("@codemirror/view");function Oi(e){let n=-1,t=1/0,r=-1/0;return Ti.EditorView.updateListener.of(i=>{if(!i.docChanged||!e.settings.shouldAutoCheck)return;i.changes.iterChangedRanges((o,a,c,l)=>{t=Math.min(t,c,l),r=Math.max(r,c,l)});let u=i.view;clearTimeout(n),n=window.setTimeout(()=>{e.runDetection(u,{from:t,to:r}).catch(o=>{console.error(o)}),t=1/0,r=-1/0},e.settings.autoCheckDelay)})}var Ii=require("@codemirror/view"),Li=require("@codemirror/state");var kt=require("obsidian");var et=require("@codemirror/view"),Me=require("@codemirror/state"),tt=require("@codemirror/language");var ba=/(frontmatter|code|math|templater|blockid|hashtag|internal)/,Ht=Me.StateEffect.define(),bt=Me.StateEffect.define(),nt=Me.StateEffect.define(),qt=Me.StateEffect.define();function _i(e,n){return e.from<=n.from&&n.from<=e.to||e.from<=n.to&&n.to<=e.to||n.from<=e.from&&e.from<=n.to||n.from<=e.to&&e.to<=n.to}var Ne=Me.StateField.define({create(){return et.Decoration.none},update(e,n){e=e.map(n.changes);let t=new Set,r={},i=null,u=a=>{if(r[a]==null){i||(i=(0,tt.syntaxTree)(n.state));let c=i.resolveInner(a,1).type.prop(tt.tokenClassNodeProp);r[a]=!(c&&ba.test(c))}return r[a]},o=a=>{i||(i=(0,tt.syntaxTree)(n.state));let c=i.resolve(n.newDoc.lineAt(a.from).from,1).type.prop(tt.tokenClassNodeProp);return!(c!=null&&c.includes("table")&&a.ruleId==="WHITESPACE_RULE")};n.docChanged&&n.selection&&e.size&&(e=e.update({filter:(a,c)=>!_i({from:a,to:c},n.selection.main)}));for(let a of n.effects)if(a.is(Ht)){let c=a.value,l=`${c.from},${c.to}`;!t.has(l)&&u(c.from)&&u(c.to)&&o(c)&&(t.add(l),e=e.update({add:[et.Decoration.mark({class:`lt-underline ${Ut(c.categoryId)}`,underline:c}).range(c.from,c.to)]}))}else a.is(bt)?e=et.Decoration.none:a.is(nt)?e=e.update({filterFrom:a.value.from,filterTo:a.value.to,filter:(c,l)=>!_i({from:c,to:l},a.value)}):a.is(qt)&&(e=e.update({filter:(c,l,s)=>!a.value(s.spec.underline)}));return e},provide:e=>et.EditorView.decorations.from(e)});function ka(e,n,t){let r=t.replacements.slice(0,$t),i=t.categoryId,u=t.ruleId;return createDiv({cls:["lt-predictions-container",Ut(i)]},o=>{t.title&&o.createSpan({cls:"lt-title"},c=>{c.createSpan({text:t.title})}),t.message&&o.createSpan({cls:"lt-message",text:t.message});let a=nt.of({...t});o.createDiv({cls:"lt-bottom"},c=>{r.length&&c.createDiv({cls:"lt-buttoncontainer"},l=>{for(let s of r)l.createEl("button",{text:s||"(delete)"},h=>{h.onclick=()=>{n.dispatch({changes:[{from:t.from,to:t.to,insert:s}],effects:[a]})}})}),c.createDiv({cls:"lt-info-container"},l=>{l.createEl("button",{cls:"lt-info-button clickable-icon"},s=>{(0,kt.setIcon)(s,"info"),s.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")}}),l.createDiv({cls:"lt-info-box hidden"},s=>{s.createDiv({cls:"lt-info",text:`Category:\xA0${i}`}),s.createDiv({cls:"lt-info",text:`Rule:\xA0${u}`})})})}),o.createDiv({cls:"lt-ignorecontainer"},c=>{c.createEl("button",{cls:"lt-ignore-btn"},l=>{i==="TYPOS"?((0,kt.setIcon)(l.createSpan(),"plus-with-circle"),l.createSpan({text:"Add to personal dictionary"}),l.onclick=async()=>{e.settings.dictionary.push(t.text),await e.syncDictionary(),n.dispatch({effects:[qt.of(s=>s.text===t.text)]})}):((0,kt.setIcon)(l.createSpan(),"cross"),l.createSpan({text:"Ignore suggestion"}),l.onclick=()=>{n.dispatch({effects:[a]})})}),i!=="TYPOS"&&i!=="SYNONYMS"&&c.createEl("button",{cls:"lt-ignore-btn"},l=>{(0,kt.setIcon)(l.createSpan(),"circle-off"),l.createSpan({text:"Disable rule"}),l.onclick=()=>{e.settings.disabledRules?e.settings.disabledRules+=","+u:e.settings.disabledRules=u,e.saveSettings(),n.dispatch({effects:[qt.of(s=>s.ruleId===u)]})}})})})}function Pi(e,n,t){let r=t.field(Ne);if(r.size===0||t.selection.ranges.length>1)return[];let i=null;if(r.between(t.selection.main.from,t.selection.main.to,(u,o,a)=>{i={...a.spec.underline,from:u,to:o}}),i!=null){let{from:u,to:o}=i;if(e.length){let a=e[0];if(a.pos===u&&a.end===o)return e}return[{pos:u,end:o,above:!0,strictSide:!1,arrow:!1,create:a=>({dom:ka(n,a,i)})}]}return[]}function Ri(e){return Li.StateField.define({create:n=>Pi([],e,n),update:(n,t)=>Pi(n,e,t.state),provide:n=>Ii.showTooltip.computeN([n],t=>t.field(n))})}function Mi(e){return[(0,zi.tooltips)({position:"absolute",tooltipSpace:n=>n.dom.getBoundingClientRect()}),Ne,Ri(e),Oi(e)]}var Ni=require("@codemirror/language");var $t=5;function wa(){if(window.electronWindow==null)throw Error("Electron not found!");return window.electronWindow}var Wt=class extends se.Plugin{constructor(){super(...arguments);this.isLoading=!1;this.logs=[]}async onload(){await this.loadSettings(),this.settingTab=new Vt(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(Mi(this)),this.registerCommands(),this.registerMenuItems();let t=new Set(this.settings.dictionary.map(r=>r.trim()));t.delete(""),this.settings.dictionary=[...t].sort(Ge),this.syncDictionary(),await this.saveSettings()}onunload(){this.logs=[],this.isLoading=!1}registerCommands(){this.addCommand({id:"check",name:"Check text",editorCallback:(t,r)=>{let i=t.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:t=>{t.cm.dispatch({effects:[bt.of(null)]})}}),this.addCommand({id:"next",name:"Jump to next suggestion",editorCheckCallback:(t,r)=>{let i=r.cm,u=r.posToOffset(r.getCursor()),o=null;if(i.state.field(Ne).between(u+1,1/0,(a,c)=>{(!o||o.from>a)&&(o={from:a,to:c})}),t)return o!=null;o!=null&&i.dispatch({selection:{anchor:o.from,head:o.to}})}});for(let t=1;t<=$t;t++)this.addCommand(this.applySuggestionCommand(t));this.addCommand({id:"synonyms",name:"Show synonyms",editorCheckCallback:(t,r)=>this.showSynonyms(r,t)})}applySuggestionCommand(t){return{id:`accept-${t}`,name:`Accept suggestion ${t}`,editorCheckCallback(r,i){var p,b,A;let u=i.cm,o=i.posToOffset(i.getCursor()),a=[];u.state.field(Ne).between(o,o,(y,F,w)=>{a.push({from:y,to:F,value:w})});let c=a.length===1&&((A=(b=(p=a[0].value.spec)==null?void 0:p.underline)==null?void 0:b.replacements)==null?void 0:A.length)>=t;if(r)return c;if(!c)return;let{from:l,to:s,value:h}=a[0],f={from:l,to:s,insert:h.spec.underline.replacements[t-1]};u.dispatch({changes:[f],effects:[nt.of({from:l,to:s})]})}}}registerMenuItems(){this.registerEvent(this.app.workspace.on("editor-menu",(t,r,i)=>{this.showSynonyms(r,!0)&&t.addItem(u=>{u.setTitle("Synonyms"),u.setIcon("square-stack"),u.onClick(()=>this.showSynonyms(r))})}))}showSynonyms(t,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=t.cm,o=u.state.selection.main;if(o.empty)return!1;let a=u.state.sliceDoc(u.state.selection.main.from,u.state.selection.main.to);if(a.match(/[\s\.]/))return!1;if(r)return!0;let c=u.state.doc.lineAt(o.from),l=c.text.slice(0,o.from-c.from).lastIndexOf(".")+1,s=c.text.slice(l),h=s.trimStart(),f=c.from+l+s.length-h.length,p={from:o.from-f,to:o.to-f};h=h.trimEnd();let b=h.indexOf(".");return b!==-1&&(h=h.slice(0,b+1)),i.query(h,p).then(A=>u.dispatch({effects:[Ht.of({text:a,from:o.from,to:o.to,title:"Synonyms",message:"",categoryId:"SYNONYMS",ruleId:"SYNONYMS",replacements:A})]})).catch(A=>{this.pushLogs(A),new se.Notice(A.message,5e3)}),!0}setStatusBarReady(){this.isLoading=!1,this.statusBarText.empty(),this.statusBarText.createSpan({cls:"lt-status-bar-btn"},t=>{t.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"]},t=>{(0,se.setIcon)(t,"sync-small")}))}handleStatusBarClick(){var i;let t=(i=this.statusBarText.parentElement)==null?void 0:i.getBoundingClientRect(),r=this.statusBarText.getBoundingClientRect();new se.Menu().addItem(u=>{u.setTitle("Check text"),u.setIcon("checkbox-glyph"),u.onClick(async()=>{let o=this.app.workspace.getActiveViewOfType(se.MarkdownView);if(o&&o.getMode()==="source")try{let a=o.editor.cm;await this.runDetection(a)}catch(a){console.error(a)}})}).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(se.MarkdownView);if(!o)return;o.editor.cm.dispatch({effects:[bt.of(null)]})})}).showAtPosition({x:r.right+5,y:((t==null?void 0:t.top)||0)-5})}async runDetection(t,r){let i=t.state.selection.main;!r&&!i.empty&&(r={...i});let u=0,o="";if(r?(r=Da(t,r),u=r.from,o=t.state.sliceDoc(r.from,r.to)):o=t.state.sliceDoc(0),!o.trim())return;let a;try{this.setStatusBarWorking(),a=await ie.check(this.settings,u,o)}catch(l){console.error(l),l instanceof Error&&(this.pushLogs(l),new se.Notice(l.message,5e3));return}finally{this.setStatusBarReady()}let c=[];if(r?c.push(nt.of(r)):c.push(bt.of(null)),a){let l=this.settings.dictionary;for(let s of a)s.to>t.state.doc.length||s.categoryId==="TYPOS"&&l.includes(s.text)||c.push(Ht.of(s))}c.length&&t.dispatch({effects:c})}async pushLogs(t){let r=`${new Date().toLocaleString()}: Error: '${t.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({},vi,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}async onExternalSettingsChange(){this.settingTab.notifyEndpointChange(this.settings)}async syncDictionary(){if(!this.settings.syncDictionary||At(this.settings.serverUrl)!=="premium")return await this.saveSettings(),!1;try{let t=new Set(this.settings.remoteDictionary),r=new Set(this.settings.dictionary),i=new Set(await ie.words(this.settings)),u=Xe(t,r);u=Di(u,i);for(let h of u)await ie.wordsDel(this.settings,h);let o=Xe(t,i);i=Xe(i,u),r=Xe(r,o);let a=Xe(r,i);for(let h of a)await ie.wordsAdd(this.settings,h);let c=Hn(i,r),l=new Set(this.settings.dictionary),s=l.size!==c.size;return Hn(l,c).size,c.size,this.settings.dictionary=[...c].sort(Ge),this.settings.remoteDictionary=[...c].sort(Ge),await this.saveSettings(),s}catch(t){this.pushLogs(t),console.error("Failed sync spellcheck with LanguageTool",t)}return await this.saveSettings(),!1}};function Da(e,n){let t=null;if(n.from>0){t=(0,Ni.syntaxTree)(e.state);let r=t.resolveInner(n.from,-1);r.type.name.startsWith("list-")?n.from=r.from:n.from=e.state.doc.lineAt(n.from).from}else n.from=0;return n.to * @license MIT *) */