tiny-markdown-editor 0.2.32 → 0.2.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyMDE={})}(this,(function(e){"use strict";var t,n,r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={};function s(){if(n)return t;n=1;var e=function(e){return e&&e.Math===Math&&e};return t=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof r&&r)||e("object"==typeof t&&t)||function(){return this}()||Function("return this")()}var o,a,u,l,c,h,p,f,g={};function d(){return a?o:(a=1,o=function(e){try{return!!e()}catch(e){return!0}})}function m(){if(l)return u;l=1;var e=d();return u=!e((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}function y(){if(h)return c;h=1;var e=d();return c=!e((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))}function T(){if(f)return p;f=1;var e=y(),t=Function.prototype.call;return p=e?t.bind(t):function(){return t.apply(t,arguments)},p}var M,v,D,k,b,F,C,E,w,x,A,S,L,$,O,I,P,B,N,_,R,H,j,G,z,U,Z,q,W,V,K,X,Y,Q,J,ee,te,ne,re,ie,se,oe={};function ae(){return D?v:(D=1,v=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}})}function ue(){if(b)return k;b=1;var e=y(),t=Function.prototype,n=t.call,r=e&&t.bind.bind(n,n);return k=e?r:function(e){return function(){return n.apply(e,arguments)}},k}function le(){if(C)return F;C=1;var e=ue(),t=e({}.toString),n=e("".slice);return F=function(e){return n(t(e),8,-1)}}function ce(){return A?x:(A=1,x=function(e){return null==e})}function he(){if(L)return S;L=1;var e=ce(),t=TypeError;return S=function(n){if(e(n))throw new t("Can't call method on "+n);return n}}function pe(){if(O)return $;O=1;var e=function(){if(w)return E;w=1;var e=ue(),t=d(),n=le(),r=Object,i=e("".split);return E=t((function(){return!r("z").propertyIsEnumerable(0)}))?function(e){return"String"===n(e)?i(e,""):r(e)}:r}(),t=he();return $=function(n){return e(t(n))}}function fe(){if(P)return I;P=1;var e="object"==typeof document&&document.all;return I=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(e){return"function"==typeof e}}function ge(){if(N)return B;N=1;var e=fe();return B=function(t){return"object"==typeof t?null!==t:e(t)}}function de(){if(R)return _;R=1;var e=s(),t=fe();return _=function(n,r){return arguments.length<2?(i=e[n],t(i)?i:void 0):e[n]&&e[n][r];var i},_}function me(){if(j)return H;j=1;var e=ue();return H=e({}.isPrototypeOf)}function ye(){if(Z)return U;Z=1;var e,t,n=s(),r=function(){if(z)return G;z=1;var e=s().navigator,t=e&&e.userAgent;return G=t?String(t):""}(),i=n.process,o=n.Deno,a=i&&i.versions||o&&o.version,u=a&&a.v8;return u&&(t=(e=u.split("."))[0]>0&&e[0]<4?1:+(e[0]+e[1])),!t&&r&&(!(e=r.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=r.match(/Chrome\/(\d+)/))&&(t=+e[1]),U=t}function Te(){if(W)return q;W=1;var e=ye(),t=d(),n=s().String;return q=!!Object.getOwnPropertySymbols&&!t((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41}))}function Me(){if(K)return V;K=1;var e=Te();return V=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function ve(){if(Y)return X;Y=1;var e=de(),t=fe(),n=me(),r=Me(),i=Object;return X=r?function(e){return"symbol"==typeof e}:function(r){var s=e("Symbol");return t(s)&&n(s.prototype,i(r))}}function De(){if(J)return Q;J=1;var e=String;return Q=function(t){try{return e(t)}catch(e){return"Object"}}}function ke(){if(te)return ee;te=1;var e=fe(),t=De(),n=TypeError;return ee=function(r){if(e(r))return r;throw new n(t(r)+" is not a function")}}function be(){if(re)return ne;re=1;var e=ke(),t=ce();return ne=function(n,r){var i=n[r];return t(i)?void 0:e(i)}}function Fe(){if(se)return ie;se=1;var e=T(),t=fe(),n=ge(),r=TypeError;return ie=function(i,s){var o,a;if("string"===s&&t(o=i.toString)&&!n(a=e(o,i)))return a;if(t(o=i.valueOf)&&!n(a=e(o,i)))return a;if("string"!==s&&t(o=i.toString)&&!n(a=e(o,i)))return a;throw new r("Can't convert object to primitive value")}}var Ce,Ee,we,xe,Ae,Se,Le,$e,Oe,Ie,Pe,Be,Ne,_e,Re,He,je,Ge,ze,Ue,Ze,qe,We,Ve,Ke={exports:{}};function Xe(){return Ee?Ce:(Ee=1,Ce=!1)}function Ye(){if(xe)return we;xe=1;var e=s(),t=Object.defineProperty;return we=function(n,r){try{t(e,n,{value:r,configurable:!0,writable:!0})}catch(t){e[n]=r}return r}}function Qe(){if(Ae)return Ke.exports;Ae=1;var e=Xe(),t=s(),n=Ye(),r="__core-js_shared__",i=Ke.exports=t[r]||n(r,{});return(i.versions||(i.versions=[])).push({version:"3.42.0",mode:e?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.42.0/LICENSE",source:"https://github.com/zloirock/core-js"}),Ke.exports}function Je(){if(Le)return Se;Le=1;var e=Qe();return Se=function(t,n){return e[t]||(e[t]=n||{})}}function et(){if(Oe)return $e;Oe=1;var e=he(),t=Object;return $e=function(n){return t(e(n))}}function tt(){if(Pe)return Ie;Pe=1;var e=ue(),t=et(),n=e({}.hasOwnProperty);return Ie=Object.hasOwn||function(e,r){return n(t(e),r)}}function nt(){if(Ne)return Be;Ne=1;var e=ue(),t=0,n=Math.random(),r=e(1..toString);return Be=function(e){return"Symbol("+(void 0===e?"":e)+")_"+r(++t+n,36)}}function rt(){if(Re)return _e;Re=1;var e=s(),t=Je(),n=tt(),r=nt(),i=Te(),o=Me(),a=e.Symbol,u=t("wks"),l=o?a.for||a:a&&a.withoutSetter||r;return _e=function(e){return n(u,e)||(u[e]=i&&n(a,e)?a[e]:l("Symbol."+e)),u[e]}}function it(){if(je)return He;je=1;var e=T(),t=ge(),n=ve(),r=be(),i=Fe(),s=rt(),o=TypeError,a=s("toPrimitive");return He=function(s,u){if(!t(s)||n(s))return s;var l,c=r(s,a);if(c){if(void 0===u&&(u="default"),l=e(c,s,u),!t(l)||n(l))return l;throw new o("Can't convert object to primitive value")}return void 0===u&&(u="number"),i(s,u)}}function st(){if(ze)return Ge;ze=1;var e=it(),t=ve();return Ge=function(n){var r=e(n,"string");return t(r)?r:r+""}}function ot(){if(Ze)return Ue;Ze=1;var e=s(),t=ge(),n=e.document,r=t(n)&&t(n.createElement);return Ue=function(e){return r?n.createElement(e):{}}}function at(){if(We)return qe;We=1;var e=m(),t=d(),n=ot();return qe=!e&&!t((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))}function ut(){if(Ve)return g;Ve=1;var e=m(),t=T(),n=function(){if(M)return oe;M=1;var e={}.propertyIsEnumerable,t=Object.getOwnPropertyDescriptor,n=t&&!e.call({1:2},1);return oe.f=n?function(e){var n=t(this,e);return!!n&&n.enumerable}:e,oe}(),r=ae(),i=pe(),s=st(),o=tt(),a=at(),u=Object.getOwnPropertyDescriptor;return g.f=e?u:function(e,l){if(e=i(e),l=s(l),a)try{return u(e,l)}catch(e){}if(o(e,l))return r(!t(n.f,e,l),e[l])},g}var lt,ct,ht,pt,ft,gt,dt,mt={};function yt(){if(ct)return lt;ct=1;var e=m(),t=d();return lt=e&&t((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}function Tt(){if(pt)return ht;pt=1;var e=ge(),t=String,n=TypeError;return ht=function(r){if(e(r))return r;throw new n(t(r)+" is not an object")}}function Mt(){if(ft)return mt;ft=1;var e=m(),t=at(),n=yt(),r=Tt(),i=st(),s=TypeError,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,u="enumerable",l="configurable",c="writable";return mt.f=e?n?function(e,t,n){if(r(e),t=i(t),r(n),"function"==typeof e&&"prototype"===t&&"value"in n&&c in n&&!n[c]){var s=a(e,t);s&&s[c]&&(e[t]=n.value,n={configurable:l in n?n[l]:s[l],enumerable:u in n?n[u]:s[u],writable:!1})}return o(e,t,n)}:o:function(e,n,a){if(r(e),n=i(n),r(a),t)try{return o(e,n,a)}catch(e){}if("get"in a||"set"in a)throw new s("Accessors not supported");return"value"in a&&(e[n]=a.value),e},mt}function vt(){if(dt)return gt;dt=1;var e=m(),t=Mt(),n=ae();return gt=e?function(e,r,i){return t.f(e,r,n(1,i))}:function(e,t,n){return e[t]=n,e}}var Dt,kt,bt,Ft,Ct,Et,wt,xt,At,St,Lt,$t,Ot,It,Pt,Bt={exports:{}};function Nt(){if(kt)return Dt;kt=1;var e=m(),t=tt(),n=Function.prototype,r=e&&Object.getOwnPropertyDescriptor,i=t(n,"name"),s=i&&"something"===function(){}.name,o=i&&(!e||e&&r(n,"name").configurable);return Dt={EXISTS:i,PROPER:s,CONFIGURABLE:o}}function _t(){if(Ft)return bt;Ft=1;var e=ue(),t=fe(),n=Qe(),r=e(Function.toString);return t(n.inspectSource)||(n.inspectSource=function(e){return r(e)}),bt=n.inspectSource}function Rt(){if(xt)return wt;xt=1;var e=Je(),t=nt(),n=e("keys");return wt=function(e){return n[e]||(n[e]=t(e))}}function Ht(){return St?At:(St=1,At={})}function jt(){if($t)return Lt;$t=1;var e,t,n,r=function(){if(Et)return Ct;Et=1;var e=s(),t=fe(),n=e.WeakMap;return Ct=t(n)&&/native code/.test(String(n))}(),i=s(),o=ge(),a=vt(),u=tt(),l=Qe(),c=Rt(),h=Ht(),p="Object already initialized",f=i.TypeError,g=i.WeakMap;if(r||l.state){var d=l.state||(l.state=new g);d.get=d.get,d.has=d.has,d.set=d.set,e=function(e,t){if(d.has(e))throw new f(p);return t.facade=e,d.set(e,t),t},t=function(e){return d.get(e)||{}},n=function(e){return d.has(e)}}else{var m=c("state");h[m]=!0,e=function(e,t){if(u(e,m))throw new f(p);return t.facade=e,a(e,m,t),t},t=function(e){return u(e,m)?e[m]:{}},n=function(e){return u(e,m)}}return Lt={set:e,get:t,has:n,enforce:function(r){return n(r)?t(r):e(r,{})},getterFor:function(e){return function(n){var r;if(!o(n)||(r=t(n)).type!==e)throw new f("Incompatible receiver, "+e+" required");return r}}}}function Gt(){if(Ot)return Bt.exports;Ot=1;var e=ue(),t=d(),n=fe(),r=tt(),i=m(),s=Nt().CONFIGURABLE,o=_t(),a=jt(),u=a.enforce,l=a.get,c=String,h=Object.defineProperty,p=e("".slice),f=e("".replace),g=e([].join),y=i&&!t((function(){return 8!==h((function(){}),"length",{value:8}).length})),T=String(String).split("String"),M=Bt.exports=function(e,t,n){"Symbol("===p(c(t),0,7)&&(t="["+f(c(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!r(e,"name")||s&&e.name!==t)&&(i?h(e,"name",{value:t,configurable:!0}):e.name=t),y&&n&&r(n,"arity")&&e.length!==n.arity&&h(e,"length",{value:n.arity});try{n&&r(n,"constructor")&&n.constructor?i&&h(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var o=u(e);return r(o,"source")||(o.source=g(T,"string"==typeof t?t:"")),e};return Function.prototype.toString=M((function(){return n(this)&&l(this).source||o(this)}),"toString"),Bt.exports}function zt(){if(Pt)return It;Pt=1;var e=fe(),t=Mt(),n=Gt(),r=Ye();return It=function(i,s,o,a){a||(a={});var u=a.enumerable,l=void 0!==a.name?a.name:s;if(e(o)&&n(o,l,a),a.global)u?i[s]=o:r(s,o);else{try{a.unsafe?i[s]&&(u=!0):delete i[s]}catch(e){}u?i[s]=o:t.f(i,s,{value:o,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return i}}var Ut,Zt,qt,Wt,Vt,Kt,Xt,Yt,Qt,Jt,en,tn,nn,rn,sn,on,an,un={};function ln(){if(Wt)return qt;Wt=1;var e=function(){if(Zt)return Ut;Zt=1;var e=Math.ceil,t=Math.floor;return Ut=Math.trunc||function(n){var r=+n;return(r>0?t:e)(r)}}();return qt=function(t){var n=+t;return n!=n||0===n?0:e(n)}}function cn(){if(Kt)return Vt;Kt=1;var e=ln(),t=Math.max,n=Math.min;return Vt=function(r,i){var s=e(r);return s<0?t(s+i,0):n(s,i)}}function hn(){if(Yt)return Xt;Yt=1;var e=ln(),t=Math.min;return Xt=function(n){var r=e(n);return r>0?t(r,9007199254740991):0}}function pn(){if(Jt)return Qt;Jt=1;var e=hn();return Qt=function(t){return e(t.length)}}function fn(){if(rn)return nn;rn=1;var e=ue(),t=tt(),n=pe(),r=function(){if(tn)return en;tn=1;var e=pe(),t=cn(),n=pn(),r=function(r){return function(i,s,o){var a=e(i),u=n(a);if(0===u)return!r&&-1;var l,c=t(o,u);if(r&&s!=s){for(;u>c;)if((l=a[c++])!=l)return!0}else for(;u>c;c++)if((r||c in a)&&a[c]===s)return r||c||0;return!r&&-1}};return en={includes:r(!0),indexOf:r(!1)}}().indexOf,i=Ht(),s=e([].push);return nn=function(e,o){var a,u=n(e),l=0,c=[];for(a in u)!t(i,a)&&t(u,a)&&s(c,a);for(;o.length>l;)t(u,a=o[l++])&&(~r(c,a)||s(c,a));return c}}function gn(){return on?sn:(on=1,sn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}function dn(){if(an)return un;an=1;var e=fn(),t=gn().concat("length","prototype");return un.f=Object.getOwnPropertyNames||function(n){return e(n,t)},un}var mn,yn,Tn,Mn,vn,Dn,kn,bn,Fn,Cn,En,wn,xn,An,Sn,Ln,$n,On,In,Pn={};function Bn(){if(Tn)return yn;Tn=1;var e=de(),t=ue(),n=dn(),r=(mn||(mn=1,Pn.f=Object.getOwnPropertySymbols),Pn),i=Tt(),s=t([].concat);return yn=e("Reflect","ownKeys")||function(e){var t=n.f(i(e)),o=r.f;return o?s(t,o(e)):t}}function Nn(){if(vn)return Mn;vn=1;var e=tt(),t=Bn(),n=ut(),r=Mt();return Mn=function(i,s,o){for(var a=t(s),u=r.f,l=n.f,c=0;c<a.length;c++){var h=a[c];e(i,h)||o&&e(o,h)||u(i,h,l(s,h))}}}function _n(){if(kn)return Dn;kn=1;var e=d(),t=fe(),n=/#|\.prototype\./,r=function(n,r){var u=s[i(n)];return u===a||u!==o&&(t(r)?e(r):!!r)},i=r.normalize=function(e){return String(e).replace(n,".").toLowerCase()},s=r.data={},o=r.NATIVE="N",a=r.POLYFILL="P";return Dn=r}function Rn(){if(Fn)return bn;Fn=1;var e=s(),t=ut().f,n=vt(),r=zt(),i=Ye(),o=Nn(),a=_n();return bn=function(s,u){var l,c,h,p,f,g=s.target,d=s.global,m=s.stat;if(l=d?e:m?e[g]||i(g,{}):e[g]&&e[g].prototype)for(c in u){if(p=u[c],h=s.dontCallGetSet?(f=t(l,c))&&f.value:l[c],!a(d?c:g+(m?".":"#")+c,s.forced)&&void 0!==h){if(typeof p==typeof h)continue;o(p,h)}(s.sham||h&&h.sham)&&n(p,"sham",!0),r(l,c,p,s)}}}function Hn(){if(xn)return wn;xn=1;var e=function(){if(En)return Cn;En=1;var e={};return e[rt()("toStringTag")]="z",Cn="[object z]"===String(e)}(),t=fe(),n=le(),r=rt()("toStringTag"),i=Object,s="Arguments"===n(function(){return arguments}());return wn=e?n:function(e){var o,a,u;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(a=function(e,t){try{return e[t]}catch(e){}}(o=i(e),r))?a:s?n(o):"Object"===(u=n(o))&&t(o.callee)?"Arguments":u}}function jn(){if(Sn)return An;Sn=1;var e=Hn(),t=String;return An=function(n){if("Symbol"===e(n))throw new TypeError("Cannot convert a Symbol value to a string");return t(n)}}function Gn(){if($n)return Ln;$n=1;var e=Tt();return Ln=function(){var t=e(this),n="";return t.hasIndices&&(n+="d"),t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.dotAll&&(n+="s"),t.unicode&&(n+="u"),t.unicodeSets&&(n+="v"),t.sticky&&(n+="y"),n}}function zn(){if(In)return On;In=1;var e=d(),t=s().RegExp,n=e((function(){var e=t("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),r=n||e((function(){return!t("a","y").sticky})),i=n||e((function(){var e=t("^r","gy");return e.lastIndex=2,null!==e.exec("str")}));return On={BROKEN_CARET:i,MISSED_STICKY:r,UNSUPPORTED_Y:n}}var Un,Zn,qn,Wn,Vn,Kn,Xn,Yn,Qn,Jn,er,tr,nr,rr,ir={};function sr(){if(Zn)return Un;Zn=1;var e=fn(),t=gn();return Un=Object.keys||function(n){return e(n,t)}}function or(){if(Vn)return Wn;Vn=1;var e=de();return Wn=e("document","documentElement")}function ar(){if(Xn)return Kn;Xn=1;var e,t=Tt(),n=function(){if(qn)return ir;qn=1;var e=m(),t=yt(),n=Mt(),r=Tt(),i=pe(),s=sr();return ir.f=e&&!t?Object.defineProperties:function(e,t){r(e);for(var o,a=i(t),u=s(t),l=u.length,c=0;l>c;)n.f(e,o=u[c++],a[o]);return e},ir}(),r=gn(),i=Ht(),s=or(),o=ot(),a=Rt(),u="prototype",l="script",c=a("IE_PROTO"),h=function(){},p=function(e){return"<"+l+">"+e+"</"+l+">"},f=function(e){e.write(p("")),e.close();var t=e.parentWindow.Object;return e=null,t},g=function(){try{e=new ActiveXObject("htmlfile")}catch(e){}var t,n,i;g="undefined"!=typeof document?document.domain&&e?f(e):(n=o("iframe"),i="java"+l+":",n.style.display="none",s.appendChild(n),n.src=String(i),(t=n.contentWindow.document).open(),t.write(p("document.F=Object")),t.close(),t.F):f(e);for(var a=r.length;a--;)delete g[u][r[a]];return g()};return i[c]=!0,Kn=Object.create||function(e,r){var i;return null!==e?(h[u]=t(e),i=new h,h[u]=null,i[c]=e):i=g(),void 0===r?i:n.f(i,r)}}function ur(){if(Qn)return Yn;Qn=1;var e=d(),t=s().RegExp;return Yn=e((function(){var e=t(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)}))}function lr(){if(er)return Jn;er=1;var e=d(),t=s().RegExp;return Jn=e((function(){var e=t("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")}))}function cr(){if(nr)return tr;nr=1;var e,t,n=T(),r=ue(),i=jn(),s=Gn(),o=zn(),a=Je(),u=ar(),l=jt().get,c=ur(),h=lr(),p=a("native-string-replace",String.prototype.replace),f=RegExp.prototype.exec,g=f,d=r("".charAt),m=r("".indexOf),y=r("".replace),M=r("".slice),v=(t=/b*/g,n(f,e=/a/,"a"),n(f,t,"a"),0!==e.lastIndex||0!==t.lastIndex),D=o.BROKEN_CARET,k=void 0!==/()??/.exec("")[1];return(v||k||D||c||h)&&(g=function(e){var t,r,o,a,c,h,T,b=this,F=l(b),C=i(e),E=F.raw;if(E)return E.lastIndex=b.lastIndex,t=n(g,E,C),b.lastIndex=E.lastIndex,t;var w=F.groups,x=D&&b.sticky,A=n(s,b),S=b.source,L=0,$=C;if(x&&(A=y(A,"y",""),-1===m(A,"g")&&(A+="g"),$=M(C,b.lastIndex),b.lastIndex>0&&(!b.multiline||b.multiline&&"\n"!==d(C,b.lastIndex-1))&&(S="(?: "+S+")",$=" "+$,L++),r=new RegExp("^(?:"+S+")",A)),k&&(r=new RegExp("^"+S+"$(?!\\s)",A)),v&&(o=b.lastIndex),a=n(f,x?r:b,$),x?a?(a.input=M(a.input,L),a[0]=M(a[0],L),a.index=b.lastIndex,b.lastIndex+=a[0].length):b.lastIndex=0:v&&a&&(b.lastIndex=b.global?a.index+a[0].length:o),k&&a&&a.length>1&&n(p,a[0],r,(function(){for(c=1;c<arguments.length-2;c++)void 0===arguments[c]&&(a[c]=void 0)})),a&&w)for(a.groups=h=u(null),c=0;c<w.length;c++)h[(T=w[c])[0]]=a[T[1]];return a}),tr=g}function hr(){if(rr)return i;rr=1;var e=Rn(),t=cr();return e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t}),i}hr();var pr,fr,gr,dr,mr,yr,Tr,Mr,vr,Dr,kr,br,Fr,Cr={};function Er(){if(Mr)return Tr;Mr=1;var e=function(){if(yr)return mr;yr=1;var e=ue(),t=ln(),n=jn(),r=he(),i=e("".charAt),s=e("".charCodeAt),o=e("".slice),a=function(e){return function(a,u){var l,c,h=n(r(a)),p=t(u),f=h.length;return p<0||p>=f?e?"":void 0:(l=s(h,p))<55296||l>56319||p+1===f||(c=s(h,p+1))<56320||c>57343?e?i(h,p):l:e?o(h,p,p+2):c-56320+(l-55296<<10)+65536}};return mr={codeAt:a(!1),charAt:a(!0)}}().charAt;return Tr=function(t,n,r){return n+(r?e(t,n).length:1)}}function wr(){if(Dr)return vr;Dr=1;var e=ue(),t=et(),n=Math.floor,r=e("".charAt),i=e("".replace),s=e("".slice),o=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,a=/\$([$&'`]|\d{1,2})/g;return vr=function(e,u,l,c,h,p){var f=l+e.length,g=c.length,d=a;return void 0!==h&&(h=t(h),d=o),i(p,d,(function(t,i){var o;switch(r(i,0)){case"$":return"$";case"&":return e;case"`":return s(u,0,l);case"'":return s(u,f);case"<":o=h[s(i,1,-1)];break;default:var a=+i;if(0===a)return t;if(a>g){var p=n(a/10);return 0===p?t:p<=g?void 0===c[p-1]?r(i,1):c[p-1]+r(i,1):t}o=c[a-1]}return void 0===o?"":o}))}}!function(){if(Fr)return Cr;Fr=1;var e=function(){if(fr)return pr;fr=1;var e=y(),t=Function.prototype,n=t.apply,r=t.call;return pr="object"==typeof Reflect&&Reflect.apply||(e?r.bind(n):function(){return r.apply(n,arguments)}),pr}(),t=T(),n=ue(),r=function(){if(dr)return gr;dr=1,hr();var e=T(),t=zt(),n=cr(),r=d(),i=rt(),s=vt(),o=i("species"),a=RegExp.prototype;return gr=function(u,l,c,h){var p=i(u),f=!r((function(){var e={};return e[p]=function(){return 7},7!==""[u](e)})),g=f&&!r((function(){var e=!1,t=/a/;return"split"===u&&((t={}).constructor={},t.constructor[o]=function(){return t},t.flags="",t[p]=/./[p]),t.exec=function(){return e=!0,null},t[p](""),!e}));if(!f||!g||c){var d=/./[p],m=l(p,""[u],(function(t,r,i,s,o){var u=r.exec;return u===n||u===a.exec?f&&!o?{done:!0,value:e(d,r,i,s)}:{done:!0,value:e(t,i,r,s)}:{done:!1}}));t(String.prototype,u,m[0]),t(a,p,m[1])}h&&s(a[p],"sham",!0)}}(),i=d(),s=Tt(),o=fe(),a=ge(),u=ln(),l=hn(),c=jn(),h=he(),p=Er(),f=be(),g=wr(),m=function(){if(br)return kr;br=1;var e=T(),t=Tt(),n=fe(),r=le(),i=cr(),s=TypeError;return kr=function(o,a){var u=o.exec;if(n(u)){var l=e(u,o,a);return null!==l&&t(l),l}if("RegExp"===r(o))return e(i,o,a);throw new s("RegExp#exec called on incompatible receiver")}}(),M=rt()("replace"),v=Math.max,D=Math.min,k=n([].concat),b=n([].push),F=n("".indexOf),C=n("".slice),E="$0"==="a".replace(/./,"$0"),w=!!/./[M]&&""===/./[M]("a","$0");r("replace",(function(n,r,i){var d=w?"$":"$0";return[function(e,n){var i=h(this),s=a(e)?f(e,M):void 0;return s?t(s,e,i,n):t(r,c(i),e,n)},function(t,n){var a=s(this),h=c(t);if("string"==typeof n&&-1===F(n,d)&&-1===F(n,"$<")){var f=i(r,a,h,n);if(f.done)return f.value}var y=o(n);y||(n=c(n));var T,M=a.global;M&&(T=a.unicode,a.lastIndex=0);for(var E,w=[];null!==(E=m(a,h))&&(b(w,E),M);){""===c(E[0])&&(a.lastIndex=p(h,l(a.lastIndex),T))}for(var x,A="",S=0,L=0;L<w.length;L++){for(var $,O=c((E=w[L])[0]),I=v(D(u(E.index),h.length),0),P=[],B=1;B<E.length;B++)b(P,void 0===(x=E[B])?x:String(x));var N=E.groups;if(y){var _=k([O],P,I,h);void 0!==N&&b(_,N),$=c(e(n,void 0,_))}else $=g(O,h,I,P,N,n);I>=S&&(A+=C(h,S,I)+$,S=I+O.length)}return A+C(h,S)}]}),!!i((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!E||w)}();var xr,Ar,Sr,Lr,$r,Or,Ir,Pr={};function Br(){return Ar?xr:(Ar=1,xr="\t\n\v\f\r                 \u2028\u2029\ufeff")}!function(){if(Ir)return Pr;Ir=1;var e=Rn(),t=function(){if(Lr)return Sr;Lr=1;var e=ue(),t=he(),n=jn(),r=Br(),i=e("".replace),s=RegExp("^["+r+"]+"),o=RegExp("(^|[^"+r+"])["+r+"]+$"),a=function(e){return function(r){var a=n(t(r));return 1&e&&(a=i(a,s,"")),2&e&&(a=i(a,o,"$1")),a}};return Sr={start:a(1),end:a(2),trim:a(3)}}().trim,n=function(){if(Or)return $r;Or=1;var e=Nt().PROPER,t=d(),n=Br();return $r=function(r){return t((function(){return!!n[r]()||"​…᠎"!=="​…᠎"[r]()||e&&n[r].name!==r}))}}();e({target:"String",proto:!0,forced:n("trim")},{trim:function(){return t(this)}})}();var Nr,_r,Rr,Hr,jr,Gr,zr,Ur,Zr,qr,Wr,Vr,Kr,Xr,Yr,Qr,Jr,ei,ti,ni,ri,ii,si,oi,ai,ui,li,ci,hi,pi,fi,gi,di,mi={};function yi(){if(Gr)return jr;Gr=1;var e=rt(),t=ar(),n=Mt().f,r=e("unscopables"),i=Array.prototype;return void 0===i[r]&&n(i,r,{configurable:!0,value:t(null)}),jr=function(e){i[r][e]=!0}}function Ti(){return Ur?zr:(Ur=1,zr={})}function Mi(){if(Vr)return Wr;Vr=1;var e=tt(),t=fe(),n=et(),r=Rt(),i=function(){if(qr)return Zr;qr=1;var e=d();return Zr=!e((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))}(),s=r("IE_PROTO"),o=Object,a=o.prototype;return Wr=i?o.getPrototypeOf:function(r){var i=n(r);if(e(i,s))return i[s];var u=i.constructor;return t(u)&&i instanceof u?u.prototype:i instanceof o?a:null}}function vi(){if(Xr)return Kr;Xr=1;var e,t,n,r=d(),i=fe(),s=ge(),o=ar(),a=Mi(),u=zt(),l=rt(),c=Xe(),h=l("iterator"),p=!1;return[].keys&&("next"in(n=[].keys())?(t=a(a(n)))!==Object.prototype&&(e=t):p=!0),!s(e)||r((function(){var t={};return e[h].call(t)!==t}))?e={}:c&&(e=o(e)),i(e[h])||u(e,h,(function(){return this})),Kr={IteratorPrototype:e,BUGGY_SAFARI_ITERATORS:p}}function Di(){if(Qr)return Yr;Qr=1;var e=Mt().f,t=tt(),n=rt()("toStringTag");return Yr=function(r,i,s){r&&!s&&(r=r.prototype),r&&!t(r,n)&&e(r,n,{configurable:!0,value:i})}}function ki(){if(ii)return ri;ii=1;var e=ge();return ri=function(t){return e(t)||null===t}}function bi(){if(oi)return si;oi=1;var e=ki(),t=String,n=TypeError;return si=function(r){if(e(r))return r;throw new n("Can't set "+t(r)+" as a prototype")}}function Fi(){if(ui)return ai;ui=1;var e=function(){if(ni)return ti;ni=1;var e=ue(),t=ke();return ti=function(n,r,i){try{return e(t(Object.getOwnPropertyDescriptor(n,r)[i]))}catch(e){}}}(),t=ge(),n=he(),r=bi();return ai=Object.setPrototypeOf||("__proto__"in{}?function(){var i,s=!1,o={};try{(i=e(Object.prototype,"__proto__","set"))(o,[]),s=o instanceof Array}catch(e){}return function(e,o){return n(e),r(o),t(e)?(s?i(e,o):e.__proto__=o,e):e}}():void 0)}function Ci(){if(ci)return li;ci=1;var e=Rn(),t=T(),n=Xe(),r=Nt(),i=fe(),s=function(){if(ei)return Jr;ei=1;var e=vi().IteratorPrototype,t=ar(),n=ae(),r=Di(),i=Ti(),s=function(){return this};return Jr=function(o,a,u,l){var c=a+" Iterator";return o.prototype=t(e,{next:n(+!l,u)}),r(o,c,!1,!0),i[c]=s,o}}(),o=Mi(),a=Fi(),u=Di(),l=vt(),c=zt(),h=rt(),p=Ti(),f=vi(),g=r.PROPER,d=r.CONFIGURABLE,m=f.IteratorPrototype,y=f.BUGGY_SAFARI_ITERATORS,M=h("iterator"),v="keys",D="values",k="entries",b=function(){return this};return li=function(r,h,f,T,F,C,E){s(f,h,T);var w,x,A,S=function(e){if(e===F&&P)return P;if(!y&&e&&e in O)return O[e];switch(e){case v:case D:case k:return function(){return new f(this,e)}}return function(){return new f(this)}},L=h+" Iterator",$=!1,O=r.prototype,I=O[M]||O["@@iterator"]||F&&O[F],P=!y&&I||S(F),B="Array"===h&&O.entries||I;if(B&&(w=o(B.call(new r)))!==Object.prototype&&w.next&&(n||o(w)===m||(a?a(w,m):i(w[M])||c(w,M,b)),u(w,L,!0,!0),n&&(p[L]=b)),g&&F===D&&I&&I.name!==D&&(!n&&d?l(O,"name",D):($=!0,P=function(){return t(I,this)})),F)if(x={values:S(D),keys:C?P:S(v),entries:S(k)},E)for(A in x)(y||$||!(A in O))&&c(O,A,x[A]);else e({target:h,proto:!0,forced:y||$},x);return n&&!E||O[M]===P||c(O,M,P,{name:F}),p[h]=P,x}}function Ei(){return pi?hi:(pi=1,hi=function(e,t){return{value:e,done:t}})}function wi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xi(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ai(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Si(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ai(Object(n),!0).forEach((function(t){xi(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ai(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Li(e,t){return Li=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Li(e,t)}function $i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,s,o,a=[],u=!0,l=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(u=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return wi(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wi(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oi(){Oi=function(e,t){return new n(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function n(e,r,i){var s=RegExp(e,r);return t.set(s,i||t.get(e)),Li(s,n.prototype)}function r(e,n){var r=t.get(n);return Object.keys(r).reduce((function(t,n){var i=r[n];if("number"==typeof i)t[n]=e[i];else{for(var s=0;void 0===e[i[s]]&&s+1<i.length;)s++;t[n]=e[i[s]]}return t}),Object.create(null))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Li(e,t)}(n,RegExp),n.prototype.exec=function(t){var n=e.exec.call(this,t);if(n){n.groups=r(n,this);var i=n.indices;i&&(i.groups=r(i,this))}return n},n.prototype[Symbol.replace]=function(n,i){if("string"==typeof i){var s=t.get(this);return e[Symbol.replace].call(this,n,i.replace(/\$<([^>]+)(>|$)/g,(function(e,t,n){if(""===n)return e;var r=s[t];return Array.isArray(r)?"$"+r.join("$"):"number"==typeof r?"$"+r:""})))}if("function"==typeof i){var o=this;return e[Symbol.replace].call(this,n,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(r(e,o)),i.apply(this,e)}))}return e[Symbol.replace].call(this,n,i)},Oi.apply(this,arguments)}!function(){if(di)return mi;di=1;var e=s(),t=_r?Nr:(_r=1,Nr={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}),n=function(){if(Hr)return Rr;Hr=1;var e=ot()("span").classList,t=e&&e.constructor&&e.constructor.prototype;return Rr=t===Object.prototype?void 0:t}(),r=function(){if(gi)return fi;gi=1;var e=pe(),t=yi(),n=Ti(),r=jt(),i=Mt().f,s=Ci(),o=Ei(),a=Xe(),u=m(),l="Array Iterator",c=r.set,h=r.getterFor(l);fi=s(Array,"Array",(function(t,n){c(this,{type:l,target:e(t),index:0,kind:n})}),(function(){var e=h(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,o(void 0,!0);switch(e.kind){case"keys":return o(n,!1);case"values":return o(t[n],!1)}return o([n,t[n]],!1)}),"values");var p=n.Arguments=n.Array;if(t("keys"),t("values"),t("entries"),!a&&u&&"values"!==p.name)try{i(p,"name",{value:"values"})}catch(e){}return fi}(),i=vt(),o=Di(),a=rt()("iterator"),u=r.values,l=function(e,n){if(e){if(e[a]!==u)try{i(e,a,u)}catch(t){e[a]=u}if(o(e,n,!0),t[n])for(var s in r)if(e[s]!==r[s])try{i(e,s,r[s])}catch(t){e[s]=r[s]}}};for(var c in t)l(e[c]&&e[c].prototype,c);l(n,"DOMTokenList")}();var Ii,Pi,Bi,Ni,_i,Ri,Hi,ji,Gi,zi,Ui,Zi,qi,Wi={};function Vi(){if(Pi)return Ii;Pi=1;var e=fe(),t=ge(),n=Fi();return Ii=function(r,i,s){var o,a;return n&&e(o=i.constructor)&&o!==s&&t(a=o.prototype)&&a!==s.prototype&&n(r,a),r}}function Ki(){if(ji)return Hi;ji=1;var e=Mt().f;return Hi=function(t,n,r){r in t||e(t,r,{configurable:!0,get:function(){return n[r]},set:function(e){n[r]=e}})}}function Xi(){if(zi)return Gi;zi=1;var e=Gt(),t=Mt();return Gi=function(n,r,i){return i.get&&e(i.get,r,{getter:!0}),i.set&&e(i.set,r,{setter:!0}),t.f(n,r,i)}}function Yi(){if(Zi)return Ui;Zi=1;var e=de(),t=Xi(),n=rt(),r=m(),i=n("species");return Ui=function(n){var s=e(n);r&&s&&!s[i]&&t(s,i,{configurable:!0,get:function(){return this}})}}!function(){if(qi)return Wi;qi=1;var e=m(),t=s(),n=ue(),r=_n(),i=Vi(),o=vt(),a=ar(),u=dn().f,l=me(),c=function(){if(Ni)return Bi;Ni=1;var e=ge(),t=le(),n=rt()("match");return Bi=function(r){var i;return e(r)&&(void 0!==(i=r[n])?!!i:"RegExp"===t(r))}}(),h=jn(),p=function(){if(Ri)return _i;Ri=1;var e=T(),t=tt(),n=me(),r=Gn(),i=RegExp.prototype;return _i=function(s){var o=s.flags;return void 0!==o||"flags"in i||t(s,"flags")||!n(i,s)?o:e(r,s)}}(),f=zn(),g=Ki(),y=zt(),M=d(),v=tt(),D=jt().enforce,k=Yi(),b=rt(),F=ur(),C=lr(),E=b("match"),w=t.RegExp,x=w.prototype,A=t.SyntaxError,S=n(x.exec),L=n("".charAt),$=n("".replace),O=n("".indexOf),I=n("".slice),P=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,B=/a/g,N=/a/g,_=new w(B)!==B,R=f.MISSED_STICKY,H=f.UNSUPPORTED_Y,j=e&&(!_||R||F||C||M((function(){return N[E]=!1,w(B)!==B||w(N)===N||"/a/i"!==String(w(B,"i"))})));if(r("RegExp",j)){for(var G=function(e,t){var n,r,s,u,f,g,d=l(x,this),m=c(e),y=void 0===t,T=[],M=e;if(!d&&m&&y&&e.constructor===G)return e;if((m||l(x,e))&&(e=e.source,y&&(t=p(M))),e=void 0===e?"":h(e),t=void 0===t?"":h(t),M=e,F&&"dotAll"in B&&(r=!!t&&O(t,"s")>-1)&&(t=$(t,/s/g,"")),n=t,R&&"sticky"in B&&(s=!!t&&O(t,"y")>-1)&&H&&(t=$(t,/y/g,"")),C&&(u=function(e){for(var t,n=e.length,r=0,i="",s=[],o=a(null),u=!1,l=!1,c=0,h="";r<=n;r++){if("\\"===(t=L(e,r)))t+=L(e,++r);else if("]"===t)u=!1;else if(!u)switch(!0){case"["===t:u=!0;break;case"("===t:if(i+=t,"?:"===I(e,r+1,r+3))continue;S(P,I(e,r+1))&&(r+=2,l=!0),c++;continue;case">"===t&&l:if(""===h||v(o,h))throw new A("Invalid capture group name");o[h]=!0,s[s.length]=[h,c],l=!1,h="";continue}l?h+=t:i+=t}return[i,s]}(e),e=u[0],T=u[1]),f=i(w(e,t),d?this:x,G),(r||s||T.length)&&(g=D(f),r&&(g.dotAll=!0,g.raw=G(function(e){for(var t,n=e.length,r=0,i="",s=!1;r<=n;r++)"\\"!==(t=L(e,r))?s||"."!==t?("["===t?s=!0:"]"===t&&(s=!1),i+=t):i+="[\\s\\S]":i+=t+L(e,++r);return i}(e),n)),s&&(g.sticky=!0),T.length&&(g.groups=T)),e!==M)try{o(f,"source",""===M?"(?:)":M)}catch(e){}return f},z=u(w),U=0;z.length>U;)g(G,w,z[U++]);x.constructor=G,G.prototype=x,y(t,"RegExp",G,{constructor:!0})}k("RegExp")}();var Qi,Ji={};!function(){if(Qi)return Ji;Qi=1;var e=s(),t=m(),n=Xi(),r=Gn(),i=d(),o=e.RegExp,a=o.prototype;t&&i((function(){var e=!0;try{o(".","d")}catch(t){e=!1}var t={},n="",r=e?"dgimsy":"gimsy",i=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},s={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var u in e&&(s.hasIndices="d"),s)i(u,s[u]);return Object.getOwnPropertyDescriptor(a,"flags").get.call(t)!==r||n!==r}))&&n(a,"flags",{configurable:!0,get:r})}();const es={ASCIIPunctuation:/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/,NotTriggerChar:/[^`_*[\]()<>!~\n]/,Scheme:/[A-Za-z][A-Za-z0-9+.-]{1,31}/,Email:/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/,HTMLOpenTag:/<HTMLTagName(?:HTMLAttribute)*\s*\/?>/,HTMLCloseTag:/<\/HTMLTagName\s*>/,HTMLTagName:/[A-Za-z][A-Za-z0-9-]*/,HTMLComment:/<!--(?:[^>-]|(?:[^>-](?:[^-]|-[^-])*[^-]))-->/,HTMLPI:/<\?(?:|.|(?:[^?]|\?[^>])*)\?>/,HTMLDeclaration:/<![A-Z]+\s[^>]*>/,HTMLCDATA:/<!\[CDATA\[.*?\]\]>/,HTMLAttribute:/\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:HTMLAttValue)?/,HTMLAttValue:/\s*=\s*(?:(?:'[^']*')|(?:"[^"]*")|(?:[^\s"'=<>`]+))/,KnownTag:/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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul/},ts=new RegExp(/^(?:[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\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-\u2E42\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]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B])/),ns=new RegExp(/(?:[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\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-\u2E42\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]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B])$/),rs={macPlatform:/Mac|iPod|iPhone|iPad/,lineSplit:/(?:\r\n|\r|\n)/,replacementPlaceholder:/(\${1,2})([0-9])/g,inlineContentPlaceholder:/\$\$([0-9])/,inlineReplacementPlaceholder:/\$([1-9])/g,blankContent:/^\s*$/,leadingWhitespace:/^\s/,trailingWhitespace:/\s$/,leadingWhitespaceRun:/^\s+/,surroundingWhitespace:Oi(/^(\s*).*\S(\s*)$/,{leading:1,trailing:2}),taskListItem:/^(\[)([ xX])(\])(\s|$)([\s\S]*)$/,orderedListNumber:/\d{1,9}/,inlineTagName:/^<\s*([a-zA-Z][a-zA-Z0-9]*)/,changeEvent:/^(?:change|input)$/i,selectionEvent:/^(?:selection|selectionchange)$/i,dropEvent:/^(?:drop)$/i,autolinkPrecedingChar:/[\s*_~(]/,emphasisDelimiter:/(^\*+)|(^_+)/,strikethroughDelimiter:/^~~/,autolinkScheme:/^(?:https?|ftp):\/\//i,autolinkWww:/^www\./i,autolinkDomain:/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)+/,autolinkPath:/^[^\s<]*/,autolinkProtocol:/^(?:mailto|xmpp):/i,autolinkXmpp:/^xmpp:/i,autolinkXmppResource:/^\/[a-zA-Z0-9@.\-_]+/,autolinkEmail:/^[a-zA-Z0-9.\-_+]+@[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)+/,emailTrailingChar:/[-_]$/,emailTld:/\.[a-zA-Z0-9]+$/,linkClosingBracket:/^\]/,openingAngle:/^</,closingAngle:/^>/,titleQuote:/^["']/,openingParen:/^\(/,closingParen:/^\)/,endsWithOpenAngle:/<$/,containsOpenAngle:/</,anyChar:/^./},is={TMH1:{regexp:/^( {0,3}#\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH1">$1</span>$$2<span class="TMMark TMMark_TMH1">$3</span>'},TMH2:{regexp:/^( {0,3}##\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH2">$1</span>$$2<span class="TMMark TMMark_TMH2">$3</span>'},TMH3:{regexp:/^( {0,3}###\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH3">$1</span>$$2<span class="TMMark TMMark_TMH3">$3</span>'},TMH4:{regexp:/^( {0,3}####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH4">$1</span>$$2<span class="TMMark TMMark_TMH4">$3</span>'},TMH5:{regexp:/^( {0,3}#####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH5">$1</span>$$2<span class="TMMark TMMark_TMH5">$3</span>'},TMH6:{regexp:/^( {0,3}######\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH6">$1</span>$$2<span class="TMMark TMMark_TMH6">$3</span>'},TMBlockquote:{regexp:/^( {0,3}>[ ]?)(.*)$/,replacement:'<span class="TMMark TMMark_TMBlockquote">$1</span>$$2'},TMCodeFenceBacktickOpen:{regexp:Oi(/^( {0,3}(````*)\s*)([^`]*?)(\s*)$/,{seq:2}),replacement:'<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span><span class="TMInfoString">$3</span>$4'},TMCodeFenceTildeOpen:{regexp:Oi(/^( {0,3}(~~~~*)\s*)(.*?)(\s*)$/,{seq:2}),replacement:'<span class="TMMark TMMark_TMCodeFenceTilde">$1</span><span class="TMInfoString">$3</span>$4'},TMCodeFenceBacktickClose:{regexp:Oi(/^( {0,3}(````*))(\s*)$/,{seq:2}),replacement:'<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span>$3'},TMCodeFenceTildeClose:{regexp:Oi(/^( {0,3}(~~~~*))(\s*)$/,{seq:2}),replacement:'<span class="TMMark TMMark_TMCodeFenceTilde">$1</span>$3'},TMBlankLine:{regexp:/^([ \t]*)$/,replacement:"$0"},TMSetextH1Marker:{regexp:/^ {0,3}=+\s*$/,replacement:'<span class="TMMark TMMark_TMSetextH1Marker">$0</span>'},TMSetextH2Marker:{regexp:/^ {0,3}-+\s*$/,replacement:'<span class="TMMark TMMark_TMSetextH1Marker">$0</span>'},TMHR:{regexp:/^( {0,3}(\*[ \t]*\*[ \t]*\*[ \t*]*)|(-[ \t]*-[ \t]*-[ \t-]*)|(_[ \t]*_[ \t]*_[ \t_]*))$/,replacement:'<span class="TMMark TMMark_TMHR">$0</span>'},TMUL:{regexp:/^( {0,3}[+*-] {1,4})(.*)$/,replacement:'<span class="TMMark TMMark_TMUL">$1</span>$$2'},TMOL:{regexp:/^( {0,3}\d{1,9}[.)] {1,4})(.*)$/,replacement:'<span class="TMMark TMMark_TMOL">$1</span>$$2'},TMIndentedCode:{regexp:/^( {4}|\t)(.*)$/,replacement:'<span class="TMMark TMMark_TMIndentedCode">$1</span>$2'},TMLinkReferenceDefinition:{regexp:/^( {0,3}\[\s*)([^\s\]](?:[^\]]|\\\])*?)(\s*\]:\s*)((?:[^\s<>]+)|(?:<(?:[^<>\\]|\\.)*>))?(\s*)((?:\((?:[^()\\]|\\.)*\))|(?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*'))?(\s*)$/,replacement:'<span class="TMMark TMMark_TMLinkReferenceDefinition">$1</span><span class="TMLinkLabel TMLinkLabel_Definition">$2</span><span class="TMMark TMMark_TMLinkReferenceDefinition">$3</span><span class="TMLinkDestination">$4</span>$5<span class="TMLinkTitle">$6</span>$7',labelPlaceholder:2}},ss=[{start:/^ {0,3}<(?:script|pre|style)(?:\s|>|$)/i,end:/(?:<\/script>|<\/pre>|<\/style>)/i,paraInterrupt:!0},{start:/^ {0,3}<!--/,end:/-->/,paraInterrupt:!0},{start:/^ {0,3}<\?/,end:/\?>/,paraInterrupt:!0},{start:/^ {0,3}<![A-Z]/,end:/>/,paraInterrupt:!0},{start:/^ {0,3}<!\[CDATA\[/,end:/\]\]>/,paraInterrupt:!0},{start:/^ {0,3}(?:<|<\/)(?:KnownTag)(?:\s|>|\/>|$)/i,end:!1,paraInterrupt:!0},{start:/^ {0,3}(?:HTMLOpenTag|HTMLCloseTag)\s*$/,end:!1,paraInterrupt:!1}],os={escape:{regexp:/^\\(ASCIIPunctuation)/,replacement:'<span class="TMMark TMMark_TMEscape">\\</span>$1'},code:{regexp:/^(`+)((?:[^`])|(?:[^`].*?[^`]))(\1)/,replacement:'<span class="TMMark TMMark_TMCode">$1</span><code class="TMCode">$2</code><span class="TMMark TMMark_TMCode">$3</span>'},autolink:{regexp:/^<((?:Scheme:[^\s<>]*)|(?:Email))>/,replacement:'<span class="TMMark TMMark_TMAutolink">&lt;</span><span class="TMAutolink">$1</span><span class="TMMark TMMark_TMAutolink">&gt;</span>'},html:{regexp:/^((?:HTMLOpenTag)|(?:HTMLCloseTag)|(?:HTMLComment)|(?:HTMLPI)|(?:HTMLDeclaration)|(?:HTMLCDATA))/,replacement:'<span class="TMHTML">$1</span>'},linkOpen:{regexp:/^\[/,replacement:""},imageOpen:{regexp:/^!\[/,replacement:""},linkLabel:{regexp:/^(\[\s*)([^\]]*?)(\s*\])/,replacement:"",labelPlaceholder:2},default:{regexp:/^(.|(?:NotTriggerChar+))/,replacement:"$1"}},as=new RegExp(Object.keys(es).join("|")),us=[...Object.keys(os)];for(let e of us){let t=os[e].regexp.source;for(;t.match(as);)t=t.replace(as,(e=>es[e].source));os[e].regexp=new RegExp(t,os[e].regexp.flags)}for(let e of ss){let t=e.start.source;for(;t.match(as);)t=t.replace(as,(e=>es[e].source));e.start=new RegExp(t,e.start.flags)}function ls(e){return(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const cs={bold:{type:"inline",className:"TMStrong",set:{pre:"**",post:"**"},unset:{prePattern:/(?:\*\*|__)$/,postPattern:/^(?:\*\*|__)/}},italic:{type:"inline",className:"TMEm",set:{pre:"*",post:"*"},unset:{prePattern:/(?:\*|_)$/,postPattern:/^(?:\*|_)/}},code:{type:"inline",className:"TMCode",set:{pre:"`",post:"`"},unset:{prePattern:/`+$/,postPattern:/^`+/}},strikethrough:{type:"inline",className:"TMStrikethrough",set:{pre:"~~",post:"~~"},unset:{prePattern:/~~$/,postPattern:/^~~/}},h1:{type:"line",className:"TMH1",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"# $2"},unset:{pattern:/^( {0,3}#\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h2:{type:"line",className:"TMH2",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"## $2"},unset:{pattern:/^( {0,3}##\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h3:{type:"line",className:"TMH3",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"### $2"},unset:{pattern:/^( {0,3}###\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h4:{type:"line",className:"TMH4",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"#### $2"},unset:{pattern:/^( {0,3}####\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h5:{type:"line",className:"TMH5",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"##### $2"},unset:{pattern:/^( {0,3}#####\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h6:{type:"line",className:"TMH6",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"###### $2"},unset:{pattern:/^( {0,3}######\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},ul:{type:"line",className:"TMUL",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"- $2"},unset:{pattern:/^( {0,3}[+*-] {1,4})(.*)$/,replacement:"$2"}},ol:{type:"line",className:"TMOL",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"$#. $2"},unset:{pattern:/^( {0,3}\d{1,9}[.)] {1,4})(.*)$/,replacement:"$2"}},blockquote:{type:"line",className:"TMBlockquote",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"> $2"},unset:{pattern:/^( {0,3}>[ ]?)(.*)$/,replacement:"$2"}}};e.Editor=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t;this.e=null,this.textarea=null,this.lines=[],this.lineElements=[],this.lineTypes=[],this.lineCaptures=[],this.lineReplacements=[],this.linkLabels=[],this.lineDirty=[],this.lastCommandState=null,this.customInlineGrammar={},this.mergedInlineGrammar=os,this.hasFocus=!0,this.lastSelection=null,this.listeners={change:[],selection:[],drop:[]},this.undoStack=[],this.redoStack=[],this.isRestoringHistory=!1,this.maxHistory=100,this.e=null,this.textarea=null,this.lines=[],this.lineElements=[],this.lineTypes=[],this.lineCaptures=[],this.lineReplacements=[],this.linkLabels=[],this.lineDirty=[],this.lastCommandState=null,this.hasFocus=!0,this.lastSelection=null,this.customInlineGrammar=e.customInlineGrammar||{},this.mergedInlineGrammar=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Si({},os);for(const r of Object.entries(e)){var n=$i(r,2);const e=n[0],i=n[1];{const n=Si({},i);let r=i.regexp.source;const s=new RegExp(Object.keys(es).join("|"));for(;r.match(s);)r=r.replace(s,(e=>es[e].source));n.regexp=new RegExp(r,i.regexp.flags),t[e]=n}}return t}(this.customInlineGrammar),this.listeners={change:[],selection:[],drop:[]};let n=null;"string"==typeof e.element?n=document.getElementById(e.element):e.element&&(n=e.element),"string"==typeof e.textarea?this.textarea=document.getElementById(e.textarea):e.textarea&&(this.textarea=e.textarea),this.textarea&&(n||(n=this.textarea)),n||(n=document.getElementsByTagName("body")[0]),n&&"TEXTAREA"===n.tagName&&(this.textarea=n,n=this.textarea.parentNode),this.textarea&&(this.textarea.style.display="none"),this.placeholder=void 0!==e.placeholder?e.placeholder:(null===(t=this.textarea)||void 0===t?void 0:t.placeholder)||void 0,this.undoStack=[],this.redoStack=[],this.isRestoringHistory=!1,this.maxHistory=100,this.createEditorElement(n,e),this.setContent("string"==typeof e.content?e.content:this.textarea?this.textarea.value:"# Hello TinyMDE!\nEdit **here**"),this.e.addEventListener("keydown",(e=>this.handleUndoRedoKey(e)))}get canUndo(){return this.undoStack.length>=2}get canRedo(){return this.redoStack.length>0}pushHistory(){this.isRestoringHistory||(this.pushCurrentState(),this.redoStack=[])}pushCurrentState(){this.undoStack.push({content:this.getContent(),selection:this.getSelection(),anchor:this.getSelection(!0)}),this.undoStack.length>this.maxHistory&&this.undoStack.shift()}undo(){if(this.undoStack.length<2)return;this.isRestoringHistory=!0,this.pushCurrentState();const e=this.undoStack.pop();this.redoStack.push(e);const t=this.undoStack[this.undoStack.length-1];this.setContent(t.content),t.selection&&this.setSelection(t.selection,t.anchor),this.undoStack.pop(),this.isRestoringHistory=!1}redo(){if(!this.redoStack.length)return;this.isRestoringHistory=!0,this.pushCurrentState();const e=this.redoStack.pop();this.setContent(e.content),e.selection&&this.setSelection(e.selection,e.anchor),this.isRestoringHistory=!1}handleUndoRedoKey(e){(rs.macPlatform.test(navigator.platform)?e.metaKey:e.ctrlKey)&&!e.altKey&&("z"===e.key||"Z"===e.key?(e.shiftKey?this.redo():this.undo(),e.preventDefault()):"y"!==e.key&&"Y"!==e.key||(this.redo(),e.preventDefault()))}createEditorElement(e,t){t&&void 0!==t.editor?"string"==typeof t.editor?this.e=document.getElementById(t.editor):this.e=t.editor:this.e=document.createElement("div"),this.e.classList.add("TinyMDE"),this.e.contentEditable="true",this.e.style.whiteSpace="pre-wrap",this.e.style.webkitUserModify="read-write-plaintext-only",this.placeholder&&this.e.setAttribute("data-placeholder",this.placeholder),void 0===t.editor&&(this.textarea&&this.textarea.parentNode===e&&this.textarea.nextSibling?e.insertBefore(this.e,this.textarea.nextSibling):e.appendChild(this.e)),this.e.addEventListener("input",(e=>this.handleInputEvent(e))),this.e.addEventListener("beforeinput",(e=>this.handleBeforeInputEvent(e))),this.e.addEventListener("compositionend",(e=>this.handleInputEvent(e))),document.addEventListener("selectionchange",(e=>{this.hasFocus&&this.handleSelectionChangeEvent(e)})),this.e.addEventListener("blur",(()=>this.hasFocus=!1)),this.e.addEventListener("focus",(()=>this.hasFocus=!0)),this.e.addEventListener("paste",(e=>this.handlePaste(e))),this.e.addEventListener("drop",(e=>this.handleDrop(e))),this.e.addEventListener("click",(e=>this.handleClick(e))),this.lineElements=this.e.childNodes}setContent(e){for(;this.e.firstChild;)this.e.removeChild(this.e.firstChild);this.lines=e.split(rs.lineSplit),this.lineDirty=[];for(let e=0;e<this.lines.length;e++){let e=document.createElement("div");this.e.appendChild(e),this.lineDirty.push(!0)}this.lineTypes=new Array(this.lines.length),this.updateFormatting(),this.updatePlaceholder(),this.fireChange(),this.isRestoringHistory||this.pushHistory()}getContent(){return this.lines.join("\n")}updatePlaceholder(){this.placeholder&&this.e&&(""===this.getContent()?this.e.classList.add("TinyMDE_empty"):this.e.classList.remove("TinyMDE_empty"))}updateFormatting(){this.updateLineTypes(),this.updateLinkLabels(),this.applyLineTypes()}updateLinkLabels(){this.linkLabels=[];for(let e=0;e<this.lines.length;e++)"TMLinkReferenceDefinition"===this.lineTypes[e]&&this.linkLabels.push(this.lineCaptures[e][is.TMLinkReferenceDefinition.labelPlaceholder])}replace(e,t){return e.replace(rs.replacementPlaceholder,((e,n,r)=>"$"===n?ls(t[parseInt(r)]):'<span class="TMInlineFormatted">'.concat(this.processInlineStyles(t[parseInt(r)]),"</span>")))}applyLineTypes(){let e=0;for(;e<this.lines.length;)if(this.isInlineGroupLeader(e)){const t=this.lineTypes[e];let n=e;for(;n+1<this.lines.length&&this.isInlineContinuation(n+1,t);)n++;this.applyInlineGroup(e,n),e=n+1}else this.applyLine(e),e++}isInlineGroupLeader(e){const t=this.lineTypes[e];return"TMPara"===t||"TMUL"===t||"TMOL"===t||"TMBlockquote"===t&&!this.isBlankBlockquoteContent(e)}isInlineContinuation(e,t){const n=this.lineTypes[e];return"TMPara"===n||"TMBlockquote"===n&&"TMBlockquote"===t&&!this.isBlankBlockquoteContent(e)}isBlankBlockquoteContent(e){const t=this.lineCaptures[e],n=t&&void 0!==t[2]?t[2]:"";return rs.blankContent.test(n)}applyLine(e){const t=this.lineElements[e];if(this.lineDirty[e]){let n=this.replace(this.lineReplacements[e],this.lineCaptures[e]);t.className=this.lineTypes[e],t.removeAttribute("style"),t.innerHTML=""===n?"<br />":n,delete t.dataset.mlSig}t.dataset.lineNum=e.toString()}applyInlineGroup(e,t){const n=[];let r="".concat(t-e);for(let i=e;i<=t;i++){const e=this.inlineContentIndex(this.lineReplacements[i]);n.push(void 0!==this.lineCaptures[i][e]?this.lineCaptures[i][e]:""),r+="".concat(this.lineTypes[i],"").concat(this.lineReplacements[i],"").concat(JSON.stringify(this.lineCaptures[i]))}const i="".concat(this.hashString(r));let s=!1;for(let n=e;n<=t;n++)if(this.lineDirty[n]||this.lineElements[n].dataset.mlSig!==i){s=!0;break}if(s){const r=this.splitInlineHTMLByLine(this.processInlineStyles(n.join("\n")));for(let n=e;n<=t;n++){const t=this.lineElements[n],s=r[n-e]||"",o=this.replaceWithInline(this.lineReplacements[n],this.lineCaptures[n],s);t.className=this.lineTypes[n],t.removeAttribute("style"),t.innerHTML=""===o?"<br />":o,t.dataset.mlSig=i}}for(let n=e;n<=t;n++)this.lineElements[n].dataset.lineNum=n.toString()}inlineContentIndex(e){const t=rs.inlineContentPlaceholder.exec(e);return t?parseInt(t[1]):0}replaceWithInline(e,t,n){return e.replace(rs.replacementPlaceholder,((e,r,i)=>"$"===r?ls(t[parseInt(i)]):'<span class="TMInlineFormatted">'.concat(n,"</span>")))}splitInlineHTMLByLine(e){const t=[],n=[];let r="",i=0;for(;i<e.length;){const s=e[i];if("\n"===s){for(let e=n.length-1;e>=0;e--)r+="</".concat(this.inlineTagName(n[e]),">");t.push(r),r=n.join(""),i++}else if("<"===s){const t=e.indexOf(">",i);if(t<0){r+=e.substr(i);break}const s=e.substring(i,t+1);r+=s,"/"===s[1]?n.pop():"/"!==s[s.length-2]&&n.push(s),i=t+1}else r+=s,i++}return t.push(r),t}inlineTagName(e){const t=rs.inlineTagName.exec(e);return t?t[1]:"span"}hashString(e){let t=5381;for(let n=0;n<e.length;n++)t=((t<<5)+t^e.charCodeAt(n))>>>0;return t}updateLineTypes(){let e=!1,t=0,n=!1;for(let r=0;r<this.lines.length;r++){let i="TMPara",s=[this.lines[r]],o="$$0";if("TMCodeFenceBacktickOpen"===e){let n=is.TMCodeFenceBacktickClose.regexp.exec(this.lines[r]);n&&n.groups.seq.length>=t?(i="TMCodeFenceBacktickClose",o=is.TMCodeFenceBacktickClose.replacement,s=n,e=!1):(i="TMFencedCodeBacktick",o='<span class="TMFencedCode">$0<br /></span>',s=[this.lines[r]])}else if("TMCodeFenceTildeOpen"===e){let n=is.TMCodeFenceTildeClose.regexp.exec(this.lines[r]);n&&n.groups.seq.length>=t?(i="TMCodeFenceTildeClose",o=is.TMCodeFenceTildeClose.replacement,s=n,e=!1):(i="TMFencedCodeTilde",o='<span class="TMFencedCode">$0<br /></span>',s=[this.lines[r]])}if("TMPara"===i&&!1===n)for(let e of ss)if(this.lines[r].match(e.start)&&(e.paraInterrupt||0===r||"TMPara"!==this.lineTypes[r-1]&&"TMUL"!==this.lineTypes[r-1]&&"TMOL"!==this.lineTypes[r-1]&&"TMBlockquote"!==this.lineTypes[r-1])){n=e;break}if(!1!==n&&(i="TMHTMLBlock",o='<span class="TMHTMLContent">$0<br /></span>',s=[this.lines[r]],n.end?this.lines[r].match(n.end)&&(n=!1):(r===this.lines.length-1||this.lines[r+1].match(is.TMBlankLine.regexp))&&(n=!1)),"TMPara"===i)for(let e in is)if(is[e].regexp){let t=is[e].regexp.exec(this.lines[r]);if(t){i=e,o=is[e].replacement,s=t;break}}if("TMCodeFenceBacktickOpen"!==i&&"TMCodeFenceTildeOpen"!==i||(e=i,t=s.groups.seq.length),"TMIndentedCode"!==i&&"TMLinkReferenceDefinition"!==i||!(r>0)||"TMPara"!==this.lineTypes[r-1]&&"TMUL"!==this.lineTypes[r-1]&&"TMOL"!==this.lineTypes[r-1]&&"TMBlockquote"!==this.lineTypes[r-1]||(i="TMPara",s=[this.lines[r]],o="$$0"),"TMSetextH2Marker"===i){let e=is.TMUL.regexp.exec(this.lines[r]);e&&(i="TMUL",o=is.TMUL.replacement,s=e)}if("TMSetextH1Marker"===i||"TMSetextH2Marker"===i)if(0===r||"TMPara"!==this.lineTypes[r-1]){let e=is.TMHR.regexp.exec(this.lines[r]);e?(i="TMHR",s=e,o=is.TMHR.replacement):(i="TMPara",s=[this.lines[r]],o="$$0")}else{let e=r-1;const t="TMSetextH1Marker"===i?"TMSetextH1":"TMSetextH2";do{this.lineTypes[e]!==t&&(this.lineTypes[e]=t,this.lineDirty[e]=!0),this.lineReplacements[e]="$$0",this.lineCaptures[e]=[this.lines[e]],e--}while(e>=0&&"TMPara"===this.lineTypes[e])}if("TMUL"===i||"TMOL"===i){const e=void 0!==s[2]?s[2]:"",t=rs.taskListItem.exec(e);if(t){const e="TMUL"===i?"TMMark_TMUL":"TMMark_TMOL",n=" "!==t[2]?"TMCheckbox TMCheckbox_checked":"TMCheckbox TMCheckbox_unchecked";s=[s[0],s[1],t[1],t[2],t[3],t[4],t[5]],o='<span class="TMMark '.concat(e,'">$1</span>')+'<span class="TMMark TMMark_TMTask">$2</span>'+'<span class="'.concat(n,'">$3</span>')+'<span class="TMMark TMMark_TMTask">$4</span><span class="TMMark TMMark_TMTask">$5</span>$$6'}}this.lineTypes[r]!==i&&(this.lineTypes[r]=i,this.lineDirty[r]=!0),this.lineReplacements[r]=o,this.lineCaptures[r]=s}}getSelection(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var t,n;const r=window.getSelection();let i=e?r.anchorNode:r.focusNode;if(!i)return null;let s=e?r.anchorOffset:r.focusOffset;if(i===this.e)return s<this.lines.length?{row:s,col:0}:{row:s-1,col:this.lines[s-1].length};let o=this.computeColumn(i,s);if(null===o)return null;let a=i;for(;a.parentElement!==this.e;)a=a.parentElement;let u=0;if(a.previousSibling){const e=null===(t=a.dataset)||void 0===t?void 0:t.lineNum,r=null===(n=a.previousSibling.dataset)||void 0===n?void 0:n.lineNum;if(e&&r){const t=parseInt(e);if(t===parseInt(r)+1)u=t;else for(;a.previousSibling;)u++,a=a.previousSibling}}return{row:u,col:o}}setSelection(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e)return;let n=this.computeNodeAndOffset(e.row,e.col,!!t&&(t.row===e.row&&t.col>e.col)),r=n.node,i=n.offset,s=null,o=null;if(t&&(t.row!==e.row||t.col!==e.col)){let n=this.computeNodeAndOffset(t.row,t.col,e.row===t.row&&e.col>t.col);s=n.node,o=n.offset}window.getSelection().setBaseAndExtent(r,i,s||r,s?o:i)}restoreLastSelection(){return!(!this.lastSelection||!this.lastSelection.focus)&&(this.setSelection(this.lastSelection.focus,this.lastSelection.anchor),!0)}paste(e){let t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;r||(r=this.getSelection(!0)),i||(i=this.getSelection(!1)),i||(i={row:this.lines.length-1,col:this.lines[this.lines.length-1].length}),r||(r=i),r.row<i.row||r.row===i.row&&r.col<=i.col?(t=r,n=i):(t=i,n=r);let s=e.split(rs.lineSplit),o=this.lines[t.row].substr(0,t.col),a=this.lines[n.row].substr(n.col);s[0]=o.concat(s[0]);let u=s[s.length-1].length;s[s.length-1]=s[s.length-1].concat(a),this.spliceLines(t.row,1+n.row-t.row,s),i.row=t.row+s.length-1,i.col=u,this.updateFormatting(),this.setSelection(i),this.fireChange()}wrapSelection(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(n||(n=this.getSelection(!1)),r||(r=this.getSelection(!0)),!n||!r||n.row!==r.row)return;this.isRestoringHistory||this.pushHistory(),this.lineDirty[n.row]=!0;const i=n.col<r.col?n.col:r.col,s=n.col<r.col?r.col:n.col,o=this.lines[n.row].substr(0,i).concat(e),a=s===i?"":this.lines[n.row].substr(i,s-i),u=t.concat(this.lines[n.row].substr(s));this.lines[n.row]=o.concat(a,u),r.col=o.length,n.col=r.col+a.length,this.updateFormatting(),this.setSelection(n,r),this.fireChange()}addEventListener(e,t){e.match(rs.changeEvent)&&this.listeners.change.push(t),e.match(rs.selectionEvent)&&this.listeners.selection.push(t),e.match(rs.dropEvent)&&this.listeners.drop.push(t)}fireChange(){if(this.updatePlaceholder(),!this.textarea&&!this.listeners.change.length)return;const e=this.getContent();this.textarea&&(this.textarea.value=e);for(let t of this.listeners.change)t({content:e,linesDirty:[...this.lineDirty]})}handleBeforeInputEvent(e){const t=e;if("deleteContentBackward"===t.inputType||"deleteContentForward"===t.inputType){const n=this.getSelection(),r=this.getSelection(!0);if(!n||!r)return;const i="deleteContentBackward"===t.inputType;if(n.row===r.row&&n.col===r.col){if(i&&0===n.col&&n.row>0){e.preventDefault(),this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();const t=this.lines[n.row-1].length;return this.lines[n.row-1]=this.lines[n.row-1]+this.lines[n.row],this.lineDirty[n.row-1]=!0,this.spliceLines(n.row,1),this.updateFormatting(),this.setSelection({row:n.row-1,col:t}),void this.fireChange()}if(!i&&n.col===this.lines[n.row].length&&n.row<this.lines.length-1){e.preventDefault(),this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();const t=this.lines[n.row].length;return this.lines[n.row]=this.lines[n.row]+this.lines[n.row+1],this.lineDirty[n.row]=!0,this.spliceLines(n.row+1,1),this.updateFormatting(),this.setSelection({row:n.row,col:t}),void this.fireChange()}}return}if("insertParagraph"!==t.inputType&&"insertLineBreak"!==t.inputType)return;this.isRestoringHistory||this.pushHistory(),e.preventDefault(),this.clearDirtyFlag();const n=this.getSelection(),r=this.getSelection(!0);if(n&&r){if(n.row!==r.row){const e=n.row<r.row?n:r,t=n.row<r.row?r:n;this.lines[e.row]=this.lines[e.row].substring(0,e.col),this.lines[t.row]=this.lines[t.row].substring(t.col),this.spliceLines(e.row+1,t.row-e.row-1),n.row=e.row+1,n.col=0}else{let e=!1;switch(this.lineTypes[n.row]){case"TMUL":e="TMUL";break;case"TMOL":e="TMOL";break;case"TMIndentedCode":e="TMIndentedCode"}const t=this.lines[n.row].substring(0,n.col<=r.col?n.col:r.col),i=this.lines[n.row].substring(n.col<=r.col?r.col:n.col);if(this.spliceLines(n.row,1,[t,i]),n.row+=1,n.col=0,e){let t=is[e].regexp.exec(this.lines[n.row-1]);t&&(t[2]?("TMOL"===e&&(t[1]=t[1].replace(rs.orderedListNumber,(e=>(parseInt(e)+1).toString()))),this.lines[n.row]="".concat(t[1]).concat(this.lines[n.row]),this.lineDirty[n.row]=!0,n.col=t[1].length):(this.lines[n.row-1]="",this.lineDirty[n.row-1]=!0))}}this.updateFormatting(),this.setSelection(n),n&&n.row<this.lineElements.length&&this.lineElements[n.row].scrollIntoView({block:"nearest",inline:"nearest"}),this.fireChange()}}handleInputEvent(e){const t=e;if("insertCompositionText"===t.inputType)return;this.isRestoringHistory||this.pushHistory();let n=this.getSelection();("insertParagraph"!==t.inputType&&"insertLineBreak"!==t.inputType||!n)&&(this.e.firstChild?this.fixNodeHierarchy():this.e.innerHTML='<div class="TMBlankLine"><br></div>',this.updateLineContentsAndFormatting(),n&&this.setSelection(n),this.fireChange())}handleSelectionChangeEvent(e){this.fireSelection()}handlePaste(e){this.isRestoringHistory||this.pushHistory(),e.preventDefault();let t=e.clipboardData.getData("text/plain");this.paste(t)}handleDrop(e){e.preventDefault(),this.fireDrop(e.dataTransfer)}handleClick(e){const t=e.target,n=t&&t.closest?t.closest(".TMCheckbox"):null;if(!n)return;let r=n;for(;r&&r.parentNode!==this.e;)r=r.parentNode;if(!r||void 0===r.dataset.lineNum)return;const i=parseInt(r.dataset.lineNum,10);if(isNaN(i)||i<0||i>=this.lines.length)return;const s=this.computeColumn(n,0);if(null===s)return;const o=this.lines[i].charAt(s);if(" "!==o&&"x"!==o&&"X"!==o)return;e.preventDefault(),this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();const a=" "===o?"x":" ";this.lines[i]=this.lines[i].substr(0,s)+a+this.lines[i].substr(s+1),this.lineDirty[i]=!0,this.updateFormatting(),this.fireChange()}processInlineStyles(e){let t="",n=[],r=0,i=e;e:for(;i;){if(10===i.charCodeAt(0)){t+="\n",i=i.substr(1),r+=1;continue e}for(let e of["escape","code","autolink","html"])if(this.mergedInlineGrammar[e]){let n=this.mergedInlineGrammar[e].regexp.exec(i);if(n){i=i.substr(n[0].length),r+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(rs.inlineReplacementPlaceholder,((e,t)=>ls(n[t])));continue e}}for(let e in this.customInlineGrammar)if("escape"!==e&&"code"!==e&&"autolink"!==e&&"html"!==e&&"linkOpen"!==e&&"imageOpen"!==e&&"linkLabel"!==e&&"default"!==e){let n=this.mergedInlineGrammar[e].regexp.exec(i);if(n){i=i.substr(n[0].length),r+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(rs.inlineReplacementPlaceholder,((e,t)=>ls(n[t])));continue e}}const s=r>0?e[r-1]:"";if(""===s||rs.autolinkPrecedingChar.test(s)){let e=this.parseAutolinkExtension(i);if(e){t="".concat(t).concat(e.output),i=i.substr(e.charCount),r+=e.charCount;continue e}}let o=i.match(this.mergedInlineGrammar.linkOpen.regexp),a=i.match(this.mergedInlineGrammar.imageOpen.regexp);if(a||o){let e=this.parseLinkOrImage(i,!!a);if(e){t="".concat(t).concat(e.output),i=i.substr(e.charCount),r+=e.charCount;continue e}}let u=rs.emphasisDelimiter.exec(i);if(u){let s=u[0].length;const o=u[0],a=u[0][0];i=i.substr(u[0].length);const l=r>0?e.substr(0,r):" ",c=r+u[0].length<e.length?i:" ",h=c.match(ts),p=l.match(ns),f=c.match(rs.leadingWhitespace),g=l.match(rs.trailingWhitespace);let d=!(f||h&&!g&&!p),m=!(g||p&&!f&&!h);if("_"===a&&d&&m&&(d=!!p,m=!!h),m){let e=n.length-1;for(;s&&e>=0;)if(n[e].delimiter===a){for(;e<n.length-1;){const e=n.pop();t="".concat(e.output).concat(e.delimString.substr(0,e.count)).concat(t)}if(s>=2&&n[e].count>=2?(t='<span class="TMMark">'.concat(a).concat(a,'</span><strong class="TMStrong">').concat(t,'</strong><span class="TMMark">').concat(a).concat(a,"</span>"),s-=2,n[e].count-=2):(t='<span class="TMMark">'.concat(a,'</span><em class="TMEm">').concat(t,'</em><span class="TMMark">').concat(a,"</span>"),s-=1,n[e].count-=1),0===n[e].count){let r=n.pop();t="".concat(r.output).concat(t),e--}}else e--}s&&d&&(n.push({delimiter:a,delimString:o,count:s,output:t}),t="",s=0),s&&(t="".concat(t).concat(o.substr(0,s))),r+=u[0].length}else if(u=rs.strikethroughDelimiter.exec(i),u){let e=!1,s=n.length-1;for(;!e&&s>=0;)if("~"===n[s].delimiter){for(;s<n.length-1;){const e=n.pop();t="".concat(e.output).concat(e.delimString.substr(0,e.count)).concat(t)}t='<span class="TMMark">~~</span><del class="TMStrikethrough">'.concat(t,'</del><span class="TMMark">~~</span>');let r=n.pop();t="".concat(r.output).concat(t),e=!0}else s--;e||(n.push({delimiter:"~",delimString:"~~",count:2,output:t}),t=""),r+=u[0].length,i=i.substr(u[0].length)}else{if(u=this.mergedInlineGrammar.default.regexp.exec(i),!u)throw"Infinite loop!";i=i.substr(u[0].length),r+=u[0].length,t+=this.mergedInlineGrammar.default.replacement.replace(rs.inlineReplacementPlaceholder,((e,t)=>ls(u[t])))}}for(;n.length;){const e=n.pop();t="".concat(e.output).concat(e.delimString.substr(0,e.count)).concat(t)}return t}computeColumn(e,t){let n,r=e;for(;r&&r.parentNode!==this.e;)r=r.parentNode;if(null===r)return null;for(e.nodeType===Node.TEXT_NODE||0===t?(n=t,r=e):t>0?(r=e.childNodes[t-1],n=r.textContent.length):(n=0,r=e);r.parentNode!==this.e;)r.previousSibling?(r=r.previousSibling,n+=r.textContent.length):r=r.parentNode;return n}computeNodeAndOffset(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e>=this.lineElements.length&&(e=this.lineElements.length-1,t=this.lines[e].length),t>this.lines[e].length&&(t=this.lines[e].length);const r=this.lineElements[e];let i=r.firstChild,s=!1,o={node:r.firstChild?r.firstChild:r,offset:0};for(;i!==r;){if(!s&&i.nodeType===Node.TEXT_NODE)if(i.nodeValue.length>=t){if(!n||i.nodeValue.length!==t)return{node:i,offset:t};o={node:i,offset:t},t=0}else t-=i.nodeValue.length;!s&&i.firstChild?i=i.firstChild:i.nextSibling?(s=!1,i=i.nextSibling):(s=!0,i=i.parentNode)}return o}updateLineContentsAndFormatting(){this.clearDirtyFlag(),this.updateLineContents(),this.updateFormatting()}clearDirtyFlag(){this.lineDirty=new Array(this.lines.length);for(let e=0;e<this.lineDirty.length;e++)this.lineDirty[e]=!1}updateLineContents(){let e=this.e.childElementCount-this.lines.length;if(e){let t=0;for(;t<=this.lines.length&&t<=this.lineElements.length&&this.lineElements[t]&&this.lines[t]===this.lineElements[t].textContent&&this.lineTypes[t]===this.lineElements[t].className;)t++;let n=-1;for(;-n<this.lines.length&&-n<this.lineElements.length&&this.lines[this.lines.length+n]===this.lineElements[this.lineElements.length+n].textContent&&this.lineTypes[this.lines.length+n]===this.lineElements[this.lineElements.length+n].className;)n--;let r=this.lines.length+n+1-t;r<-e&&(r=-e),r<0&&(r=0);let i=[];for(let n=0;n<r+e;n++)i.push(this.lineElements[t+n].textContent||"");this.spliceLines(t,r,i,!1)}else for(let e=0;e<this.lineElements.length;e++){let t=this.lineElements[e],n=t.textContent||"";this.lines[e]===n&&this.lineTypes[e]===t.className||(this.lines[e]=n,this.lineTypes[e]=t.className,this.lineDirty[e]=!0)}}spliceLines(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(r)for(let n=0;n<t;n++)this.e.removeChild(this.e.childNodes[e]);let i=[],s=[];for(let t=0;t<n.length;t++)i.push(""),s.push(!0),r&&(this.e.childNodes[e]?this.e.insertBefore(document.createElement("div"),this.e.childNodes[e]):this.e.appendChild(document.createElement("div")));this.lines.splice(e,t,...n),this.lineTypes.splice(e,t,...i),this.lineDirty.splice(e,t,...s)}fixNodeHierarchy(){const e=Array.from(this.e.childNodes),t=function(e){const t=e.parentElement,n=e.nextSibling;t.removeChild(e);for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];i.forEach((e=>n?t.insertBefore(e,n):t.appendChild(e)))};e.forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE||"DIV"!==e.tagName){const n=document.createElement("div");t(e,n),n.appendChild(e)}else if(0===e.childNodes.length)e.appendChild(document.createElement("br"));else{const n=Array.from(e.childNodes);if(n.some((e=>e.nodeType===Node.ELEMENT_NODE&&"DIV"===e.tagName)))return t(e,...n)}}))}parseAutolinkExtension(e){const t=this.matchExtendedAutolink(e);return!!t&&{output:'<span class="TMAutolink">'.concat(ls(t),"</span>"),charCount:t.length}}matchExtendedAutolink(e){const t=rs.autolinkScheme.exec(e),n=rs.autolinkWww.test(e);if(t||n){const n=t?t[0].length:0,r=e.substr(n),i=rs.autolinkDomain.exec(r);if(i&&this.isValidAutolinkDomain(i[0])){const t=rs.autolinkPath.exec(r.substr(i[0].length)),s=e.substr(0,n+i[0].length+(t?t[0].length:0)),o=this.trimAutolinkTrailing(s);if(o.length>=n+i[0].length)return o}}const r=rs.autolinkProtocol.exec(e);if(r){const t=this.matchAutolinkEmail(e.substr(r[0].length));if(t){let n="";if(rs.autolinkXmpp.test(e)){const i=rs.autolinkXmppResource.exec(e.substr(r[0].length+t.length));i&&(n=i[0])}return r[0]+t+n}}const i=this.matchAutolinkEmail(e);return i||!1}isValidAutolinkDomain(e){const t=e.split(".");return!(t.length<2)&&!t.slice(-2).some((e=>e.indexOf("_")>=0))}matchAutolinkEmail(e){const t=rs.autolinkEmail.exec(e);if(!t)return!1;let n=t[0];for(;n.length&&rs.emailTrailingChar.test(n);)n=n.substr(0,n.length-1);return!!rs.emailTld.test(n)&&n}trimAutolinkTrailing(e){let t=e.length,n=!0;for(;n&&t>0;){n=!1;const r=e[t-1];if("?!.,:*_~".indexOf(r)>=0)t--,n=!0;else if(")"===r){let r=0,i=0;for(let n=0;n<t;n++)"("===e[n]?r++:")"===e[n]&&i++;i>r&&(t--,n=!0)}}return e.substr(0,t)}parseLinkOrImage(e,t){let n=t?2:1,r=e.substr(0,n),i=t?"TMImage":"TMLink",s=n,o=1,a=!1,u=!1,l=[],c=[];e:for(;s<e.length&&!1===a;){let r=e.substr(s);for(let e of["escape","code","autolink","html"]){let t=this.mergedInlineGrammar[e].regexp.exec(r);if(t){s+=t[0].length;continue e}}if(r.match(this.mergedInlineGrammar.imageOpen.regexp))o++,s+=2;else if(r.match(this.mergedInlineGrammar.linkOpen.regexp)){if(o++,!t&&this.parseLinkOrImage(r,!1))return!1;s+=1}else r.match(rs.linkClosingBracket)&&(o--,0===o)?(a=e.substr(n,s-n),s++):s++}if(!1===a)return!1;let h=s<e.length?e.substr(s,1):"";if("["===h){let t=e.substr(s),n=this.mergedInlineGrammar.linkLabel.regexp.exec(t);if(!n)return!1;s+=n[0].length,l.push(n[1],n[2],n[3]),u=n[this.mergedInlineGrammar.linkLabel.labelPlaceholder]?n[this.mergedInlineGrammar.linkLabel.labelPlaceholder]:a.trim()}else if("("!==h)u=a.trim();else{s++;let t=1;for(;s<e.length&&t>0;){let n=e.substr(s),r=rs.leadingWhitespaceRun.exec(n);if(r){switch(c.length){case 0:case 1:c.push(r[0]);break;case 2:if(c[0].match(rs.containsOpenAngle))c[1]=c[1].concat(r[0]);else{if(1!==t)return!1;c.push(""),c.push(r[0])}break;case 3:c.push(r[0]);break;case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(r[0]);break;case 7:c[6]=c[6].concat(r[0]);break;default:return!1}s+=r[0].length}else if(r=this.mergedInlineGrammar.escape.regexp.exec(n),r){switch(c.length){case 0:c.push("");case 1:c.push(r[0]);break;case 2:c[1]=c[1].concat(r[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(r[0]);break;default:return!1}s+=r[0].length}else if(c.length<2&&n.match(rs.openingAngle))0===c.length&&c.push(""),c[0]=c[0].concat("<"),s++;else if(1!==c.length&&2!==c.length||!n.match(rs.closingAngle))if(r=rs.titleQuote.exec(n),!r||0!==c.length&&1!==c.length&&4!==c.length)if(!r||5!==c.length&&6!==c.length||c[4]!==r[0])if(n.match(rs.openingParen)){switch(c.length){case 0:c.push("");case 1:c.push("");case 2:c[1]=c[1].concat("("),c[0].match(rs.endsWithOpenAngle)||t++;break;case 3:c.push("");case 4:c.push("(");break;case 5:c.push("");case 6:if("("===c[4])return!1;c[5]=c[5].concat("(");break;default:return!1}s++}else if(n.match(rs.closingParen)){if(c.length<=2){for(;c.length<2;)c.push("");c[0].match(rs.endsWithOpenAngle)||t--,t>0&&(c[1]=c[1].concat(")"))}else 5===c.length||6===c.length?"("===c[4]?(5===c.length&&c.push(""),c.push(")")):5===c.length?c.push(")"):c[5]=c[5].concat(")"):t--;if(0===t)for(;c.length<7;)c.push("");s++}else{if(r=rs.anyChar.exec(n),!r)throw"Infinite loop";switch(c.length){case 0:c.push("");case 1:c.push(r[0]);break;case 2:c[1]=c[1].concat(r[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(r[0]);break;default:return!1}s+=r[0].length}else 5===c.length&&c.push(""),c.push(r[0]),s++;else{for(;c.length<4;)c.push("");c.push(r[0]),s++}else 1===c.length&&c.push(""),c.push(">"),s++}if(t>0)return!1}if(!1!==u){let e=!1;for(let t of this.linkLabels)if(t===u){e=!0;break}let t=e?"TMLinkLabel TMLinkLabel_Valid":"TMLinkLabel TMLinkLabel_Invalid",n='<span class="TMMark TMMark_'.concat(i,'">').concat(r,'</span><span class="').concat(i," ").concat(l.length<3||!l[1]?t:"",'">').concat(this.processInlineStyles(a),'</span><span class="TMMark TMMark_').concat(i,'">]</span>');return l.length>=3&&(n=n.concat('<span class="TMMark TMMark_'.concat(i,'">').concat(l[0],"</span>"),'<span class="'.concat(t,'">').concat(l[1],"</span>"),'<span class="TMMark TMMark_'.concat(i,'">').concat(l[2],"</span>"))),{output:n,charCount:s}}if(c.length>0){for(;c.length<7;)c.push("");return{output:'<span class="TMMark TMMark_'.concat(i,'">').concat(r,'</span><span class="').concat(i,'">').concat(this.processInlineStyles(a),'</span><span class="TMMark TMMark_').concat(i,'">](').concat(ls(c[0]),'</span><span class="').concat(i,'Destination">').concat(ls(c[1]),'</span><span class="TMMark TMMark_').concat(i,'">').concat(ls(c[2])).concat(ls(c[3])).concat(ls(c[4]),'</span><span class="').concat(i,'Title">').concat(ls(c[5]),'</span><span class="TMMark TMMark_').concat(i,'">').concat(ls(c[6]),")</span>"),charCount:s}}return!1}computeCommonAncestor(e,t){if(!e||!t)return null;if(e===t)return e;const n=e=>{let t=[];for(;e;)t.unshift(e),e=e.parentNode;return t},r=n(e),i=n(t);if(r[0]!==i[0])return null;let s;for(s=0;r[s]===i[s];s++);return r[s-1]}computeEnclosingMarkupNode(e,t,n){let r=null;if(!e)return null;if(t){if(e.row!==t.row)return null;const n=window.getSelection();if(!n)return null;r=this.computeCommonAncestor(n.focusNode,n.anchorNode)}else{const e=window.getSelection();if(!e||!e.focusNode)return null;r=e.focusNode}if(!r)return null;for(;r!==this.e;){if(r.classList&&r.classList.contains(n))return r;r=r.parentNode}return null}getCommandState(){let e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i={};if(n||(n=this.getSelection(!1)),r||(r=this.getSelection(!0)),!n){for(let e in cs)i[e]=null;return i}r||(r=n),r.row<n.row||r.row===n.row&&r.col<n.col?(e=r,t=n):(e=n,t=r),t.row>e.row&&0===t.col&&(t.row--,t.col=this.lines[t.row].length);for(let s in cs)if("inline"===cs[s].type&&(n&&n.row===r.row&&this.isInlineFormattingAllowed()?i[s]=!!this.computeEnclosingMarkupNode(n,r,cs[s].className)||n.col===r.col&&!!this.lines[n.row].substr(0,n.col).match(cs[s].unset.prePattern)&&!!this.lines[n.row].substr(n.col).match(cs[s].unset.postPattern):i[s]=null),"line"===cs[s].type)if(n){let n=this.lineTypes[e.row]===cs[s].className;for(let r=e.row;r<=t.row;r++)if(this.lineTypes[r]===cs[s].className!==n){n=null;break}i[s]=n}else i[s]=null;return i}setCommandState(e,t){if(this.isRestoringHistory||this.pushHistory(),"inline"===cs[e].type){let t=this.getSelection(!0),n=this.getSelection(!1);if(t||(t=n),!t)return;if(t.row!==n.row)return;if(!this.isInlineFormattingAllowed())return;let r=this.computeEnclosingMarkupNode(n,t,cs[e].className);if(this.clearDirtyFlag(),r){this.lineDirty[n.row]=!0;const i=this.computeColumn(r,0),s=r.textContent.length,o=this.lines[n.row].substr(0,i).replace(cs[e].unset.prePattern,""),a=this.lines[n.row].substr(i,s),u=this.lines[n.row].substr(i+s).replace(cs[e].unset.postPattern,"");this.lines[n.row]=o.concat(a,u),t.col=o.length,n.col=t.col+s,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else if(n.col===t.col&&this.lines[n.row].substr(0,n.col).match(cs[e].unset.prePattern)&&this.lines[n.row].substr(n.col).match(cs[e].unset.postPattern)){this.lineDirty[n.row]=!0;const r=this.lines[n.row].substr(0,n.col).replace(cs[e].unset.prePattern,""),i=this.lines[n.row].substr(n.col).replace(cs[e].unset.postPattern,"");this.lines[n.row]=r.concat(i),n.col=t.col=r.length,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else{let r=n.col<t.col?{startCol:n.col,endCol:t.col}:{startCol:t.col,endCol:n.col},i=r.startCol,s=r.endCol,o=this.lines[n.row].substr(i,s-i).match(rs.surroundingWhitespace);o&&(i+=o.groups.leading.length,s-=o.groups.trailing.length),n.col=i,t.col=s,this.wrapSelection(cs[e].set.pre,cs[e].set.post,n,t)}}else if("line"===cs[e].type){let n=this.getSelection(!0),r=this.getSelection(!1);if(n||(n=r),!r)return;this.clearDirtyFlag();let i=n.row>r.row?r:n,s=n.row>r.row?n:r;s.row>i.row&&0===s.col&&s.row--;for(let n=i.row;n<=s.row;n++)t&&this.lineTypes[n]!==cs[e].className&&(this.lines[n]=this.lines[n].replace(cs[e].set.pattern,cs[e].set.replacement.replace("$#",(n-i.row+1).toString())),this.lineDirty[n]=!0),t||this.lineTypes[n]!==cs[e].className||(this.lines[n]=this.lines[n].replace(cs[e].unset.pattern,cs[e].unset.replacement),this.lineDirty[n]=!0);this.updateFormatting(),this.setSelection({row:s.row,col:this.lines[s.row].length},{row:i.row,col:0}),this.fireChange()}}listItemMarker(e){const t=is.TMUL.regexp.exec(e);if(t)return t[1];const n=is.TMOL.regexp.exec(e);return n?n[1]:null}isTaskListItem(e){if(e<0||e>=this.lines.length)return!1;const t=this.lineTypes[e];if("TMUL"!==t&&"TMOL"!==t)return!1;const n=this.listItemMarker(this.lines[e]);return null!==n&&rs.taskListItem.test(this.lines[e].substr(n.length))}addTaskCheckbox(e){const t=this.listItemMarker(e);if(null!==t){const n=e.substr(t.length);return rs.taskListItem.test(n)?e:"".concat(t,"[ ] ").concat(n)}return e.replace(cs.ul.set.pattern,"- [ ] $2")}removeTaskCheckbox(e){const t=this.listItemMarker(e);if(null===t)return e;const n=rs.taskListItem.exec(e.substr(t.length));return n?"".concat(t).concat(n[5]):e}toggleTaskList(){let e=this.getSelection(!0),t=this.getSelection(!1);if(e||(e=t),!t)return;let n=e.row>t.row?t:e,r=e.row>t.row?e:t;r.row>n.row&&0===r.col&&r.row--;let i=!0;for(let e=n.row;e<=r.row;e++)if(!this.isTaskListItem(e)){i=!1;break}this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();for(let e=n.row;e<=r.row;e++){const t=i?this.removeTaskCheckbox(this.lines[e]):this.addTaskCheckbox(this.lines[e]);t!==this.lines[e]&&(this.lines[e]=t,this.lineDirty[e]=!0)}this.updateFormatting(),this.setSelection({row:r.row,col:this.lines[r.row].length},{row:n.row,col:0}),this.fireChange()}isInlineFormattingAllowed(){const e=window.getSelection();if(!e||!e.focusNode||!e.anchorNode)return!1;if(e.isCollapsed&&3===e.focusNode.nodeType&&e.focusOffset===e.focusNode.nodeValue.length){let t;for(t=e.focusNode;t&&null===t.nextSibling;t=t.parentNode);if(t&&t.nextSibling&&t.nextSibling.classList&&t.nextSibling.classList.contains("TMInlineFormatted"))return!0}let t=this.computeCommonAncestor(e.focusNode,e.anchorNode);if(!t)return!1;for(;t&&t!==this.e;){if(t.classList&&(t.classList.contains("TMInlineFormatted")||t.classList.contains("TMBlankLine")))return!0;t=t.parentNode}return!1}toggleCommandState(e){this.lastCommandState||(this.lastCommandState=this.getCommandState()),this.setCommandState(e,!this.lastCommandState[e])}fireDrop(e){for(let t of this.listeners.drop)t({dataTransfer:e})}fireSelection(){let e=this.getSelection(!1),t=this.getSelection(!0);if(this.lastSelection={focus:e,anchor:t},this.listeners.selection&&this.listeners.selection.length){let n=this.getCommandState(e,t);this.lastCommandState?Object.assign(this.lastCommandState,n):this.lastCommandState=Object.assign({},n);for(let n of this.listeners.selection)n({focus:e,anchor:t,commandState:this.lastCommandState})}}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyMDE={})}(this,(function(e){"use strict";var t,n,s,i,r,l,a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o={};function u(){if(n)return t;n=1;var e=function(e){return e&&e.Math===Math&&e};return t=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof a&&a)||e("object"==typeof t&&t)||function(){return this}()||Function("return this")()}function c(){return i?s:(i=1,s=function(e){try{return!!e()}catch(e){return!0}})}function h(){if(l)return r;l=1;var e=c();return r=!e((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}var p,f,d,g,m,T,M,D,F,k,y,C,E,b,$,w,A={exports:{}};function x(){if(f)return p;f=1;var e=c();return p=!e((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))}function S(){if(g)return d;g=1;var e=x(),t=Function.prototype,n=t.call,s=e&&t.bind.bind(n,n);return d=e?s:function(e){return function(){return n.apply(e,arguments)}},d}function v(){if(T)return m;T=1;var e="object"==typeof document&&document.all;return m=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(e){return"function"==typeof e}}function L(){return D?M:(D=1,M=function(e){return null==e})}function B(){if(k)return F;k=1;var e=L(),t=TypeError;return F=function(n){if(e(n))throw new t("Can't call method on "+n);return n}}function I(){if(C)return y;C=1;var e=B(),t=Object;return y=function(n){return t(e(n))}}function N(){if(b)return E;b=1;var e=S(),t=I(),n=e({}.hasOwnProperty);return E=Object.hasOwn||function(e,s){return n(t(e),s)}}var H,O,_,P,R,j,G,z,Z,U,q,W={exports:{}};function V(){if(P)return _;P=1;var e=u(),t=Object.defineProperty;return _=function(n,s){try{t(e,n,{value:s,configurable:!0,writable:!0})}catch(t){e[n]=s}return s}}function X(){if(R)return W.exports;R=1;var e=O?H:(O=1,H=!1),t=u(),n=V(),s="__core-js_shared__",i=W.exports=t[s]||n(s,{});return(i.versions||(i.versions=[])).push({version:"3.42.0",mode:e?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.42.0/LICENSE",source:"https://github.com/zloirock/core-js"}),W.exports}function K(){if(G)return j;G=1;var e=S(),t=v(),n=X(),s=e(Function.toString);return t(n.inspectSource)||(n.inspectSource=function(e){return s(e)}),j=n.inspectSource}function Q(){if(q)return U;q=1;var e=v();return U=function(t){return"object"==typeof t?null!==t:e(t)}}var J,Y,ee,te,ne,se,ie,re,le,ae,oe,ue,ce,he,pe,fe,de,ge,me,Te,Me,De,Fe,ke,ye,Ce,Ee,be,$e,we,Ae,xe,Se,ve,Le,Be,Ie,Ne,He,Oe,_e,Pe,Re,je,Ge,ze,Ze,Ue,qe,We,Ve,Xe,Ke,Qe,Je,Ye,et,tt,nt,st={};function it(){if(te)return ee;te=1;var e=h(),t=c(),n=function(){if(Y)return J;Y=1;var e=u(),t=Q(),n=e.document,s=t(n)&&t(n.createElement);return J=function(e){return s?n.createElement(e):{}}}();return ee=!e&&!t((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))}function rt(){if(re)return ie;re=1;var e=Q(),t=String,n=TypeError;return ie=function(s){if(e(s))return s;throw new n(t(s)+" is not an object")}}function lt(){if(ae)return le;ae=1;var e=x(),t=Function.prototype.call;return le=e?t.bind(t):function(){return t.apply(t,arguments)},le}function at(){if(ue)return oe;ue=1;var e=u(),t=v();return oe=function(n,s){return arguments.length<2?(i=e[n],t(i)?i:void 0):e[n]&&e[n][s];var i},oe}function ot(){if(ge)return de;ge=1;var e,t,n=u(),s=function(){if(fe)return pe;fe=1;var e=u().navigator,t=e&&e.userAgent;return pe=t?String(t):""}(),i=n.process,r=n.Deno,l=i&&i.versions||r&&r.version,a=l&&l.v8;return a&&(t=(e=a.split("."))[0]>0&&e[0]<4?1:+(e[0]+e[1])),!t&&s&&(!(e=s.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=s.match(/Chrome\/(\d+)/))&&(t=+e[1]),de=t}function ut(){if(Te)return me;Te=1;var e=ot(),t=c(),n=u().String;return me=!!Object.getOwnPropertySymbols&&!t((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41}))}function ct(){if(De)return Me;De=1;var e=ut();return Me=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function ht(){if(ke)return Fe;ke=1;var e=at(),t=v(),n=function(){if(he)return ce;he=1;var e=S();return ce=e({}.isPrototypeOf)}(),s=ct(),i=Object;return Fe=s?function(e){return"symbol"==typeof e}:function(s){var r=e("Symbol");return t(r)&&n(r.prototype,i(s))}}function pt(){if(Ce)return ye;Ce=1;var e=String;return ye=function(t){try{return e(t)}catch(e){return"Object"}}}function ft(){if(be)return Ee;be=1;var e=v(),t=pt(),n=TypeError;return Ee=function(s){if(e(s))return s;throw new n(t(s)+" is not a function")}}function dt(){if(we)return $e;we=1;var e=ft(),t=L();return $e=function(n,s){var i=n[s];return t(i)?void 0:e(i)}}function gt(){if(xe)return Ae;xe=1;var e=lt(),t=v(),n=Q(),s=TypeError;return Ae=function(i,r){var l,a;if("string"===r&&t(l=i.toString)&&!n(a=e(l,i)))return a;if(t(l=i.valueOf)&&!n(a=e(l,i)))return a;if("string"!==r&&t(l=i.toString)&&!n(a=e(l,i)))return a;throw new s("Can't convert object to primitive value")}}function mt(){if(ve)return Se;ve=1;var e=X();return Se=function(t,n){return e[t]||(e[t]=n||{})}}function Tt(){if(Be)return Le;Be=1;var e=S(),t=0,n=Math.random(),s=e(1..toString);return Le=function(e){return"Symbol("+(void 0===e?"":e)+")_"+s(++t+n,36)}}function Mt(){if(Ne)return Ie;Ne=1;var e=u(),t=mt(),n=N(),s=Tt(),i=ut(),r=ct(),l=e.Symbol,a=t("wks"),o=r?l.for||l:l&&l.withoutSetter||s;return Ie=function(e){return n(a,e)||(a[e]=i&&n(l,e)?l[e]:o("Symbol."+e)),a[e]}}function Dt(){if(Oe)return He;Oe=1;var e=lt(),t=Q(),n=ht(),s=dt(),i=gt(),r=Mt(),l=TypeError,a=r("toPrimitive");return He=function(r,o){if(!t(r)||n(r))return r;var u,c=s(r,a);if(c){if(void 0===o&&(o="default"),u=e(c,r,o),!t(u)||n(u))return u;throw new l("Can't convert object to primitive value")}return void 0===o&&(o="number"),i(r,o)}}function Ft(){if(Pe)return _e;Pe=1;var e=Dt(),t=ht();return _e=function(n){var s=e(n,"string");return t(s)?s:s+""}}function kt(){if(Re)return st;Re=1;var e=h(),t=it(),n=function(){if(se)return ne;se=1;var e=h(),t=c();return ne=e&&t((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}(),s=rt(),i=Ft(),r=TypeError,l=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o="enumerable",u="configurable",p="writable";return st.f=e?n?function(e,t,n){if(s(e),t=i(t),s(n),"function"==typeof e&&"prototype"===t&&"value"in n&&p in n&&!n[p]){var r=a(e,t);r&&r[p]&&(e[t]=n.value,n={configurable:u in n?n[u]:r[u],enumerable:o in n?n[o]:r[o],writable:!1})}return l(e,t,n)}:l:function(e,n,a){if(s(e),n=i(n),s(a),t)try{return l(e,n,a)}catch(e){}if("get"in a||"set"in a)throw new r("Accessors not supported");return"value"in a&&(e[n]=a.value),e},st}function yt(){return Ge?je:(Ge=1,je=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}})}function Ct(){if(Ze)return ze;Ze=1;var e=h(),t=kt(),n=yt();return ze=e?function(e,s,i){return t.f(e,s,n(1,i))}:function(e,t,n){return e[t]=n,e}}function Et(){if(qe)return Ue;qe=1;var e=mt(),t=Tt(),n=e("keys");return Ue=function(e){return n[e]||(n[e]=t(e))}}function bt(){return Ve?We:(Ve=1,We={})}function $t(){if(Ke)return Xe;Ke=1;var e,t,n,s=function(){if(Z)return z;Z=1;var e=u(),t=v(),n=e.WeakMap;return z=t(n)&&/native code/.test(String(n))}(),i=u(),r=Q(),l=Ct(),a=N(),o=X(),c=Et(),h=bt(),p="Object already initialized",f=i.TypeError,d=i.WeakMap;if(s||o.state){var g=o.state||(o.state=new d);g.get=g.get,g.has=g.has,g.set=g.set,e=function(e,t){if(g.has(e))throw new f(p);return t.facade=e,g.set(e,t),t},t=function(e){return g.get(e)||{}},n=function(e){return g.has(e)}}else{var m=c("state");h[m]=!0,e=function(e,t){if(a(e,m))throw new f(p);return t.facade=e,l(e,m,t),t},t=function(e){return a(e,m)?e[m]:{}},n=function(e){return a(e,m)}}return Xe={set:e,get:t,has:n,enforce:function(s){return n(s)?t(s):e(s,{})},getterFor:function(e){return function(n){var s;if(!r(n)||(s=t(n)).type!==e)throw new f("Incompatible receiver, "+e+" required");return s}}}}function wt(){if(Qe)return A.exports;Qe=1;var e=S(),t=c(),n=v(),s=N(),i=h(),r=function(){if(w)return $;w=1;var e=h(),t=N(),n=Function.prototype,s=e&&Object.getOwnPropertyDescriptor,i=t(n,"name"),r=i&&"something"===function(){}.name,l=i&&(!e||e&&s(n,"name").configurable);return $={EXISTS:i,PROPER:r,CONFIGURABLE:l}}().CONFIGURABLE,l=K(),a=$t(),o=a.enforce,u=a.get,p=String,f=Object.defineProperty,d=e("".slice),g=e("".replace),m=e([].join),T=i&&!t((function(){return 8!==f((function(){}),"length",{value:8}).length})),M=String(String).split("String"),D=A.exports=function(e,t,n){"Symbol("===d(p(t),0,7)&&(t="["+g(p(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!s(e,"name")||r&&e.name!==t)&&(i?f(e,"name",{value:t,configurable:!0}):e.name=t),T&&n&&s(n,"arity")&&e.length!==n.arity&&f(e,"length",{value:n.arity});try{n&&s(n,"constructor")&&n.constructor?i&&f(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var l=o(e);return s(l,"source")||(l.source=m(M,"string"==typeof t?t:"")),e};return Function.prototype.toString=D((function(){return n(this)&&u(this).source||l(this)}),"toString"),A.exports}function At(){if(Ye)return Je;Ye=1;var e=wt(),t=kt();return Je=function(n,s,i){return i.get&&e(i.get,s,{getter:!0}),i.set&&e(i.set,s,{setter:!0}),t.f(n,s,i)}}!function(){if(nt)return o;nt=1;var e=u(),t=h(),n=At(),s=function(){if(tt)return et;tt=1;var e=rt();return et=function(){var t=e(this),n="";return t.hasIndices&&(n+="d"),t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.dotAll&&(n+="s"),t.unicode&&(n+="u"),t.unicodeSets&&(n+="v"),t.sticky&&(n+="y"),n}}(),i=c(),r=e.RegExp,l=r.prototype;t&&i((function(){var e=!0;try{r(".","d")}catch(t){e=!1}var t={},n="",s=e?"dgimsy":"gimsy",i=function(e,s){Object.defineProperty(t,e,{get:function(){return n+=s,!0}})},a={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var o in e&&(a.hasIndices="d"),a)i(o,a[o]);return Object.getOwnPropertyDescriptor(l,"flags").get.call(t)!==s||n!==s}))&&n(l,"flags",{configurable:!0,get:s})}();const xt={ASCIIPunctuation:/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/,NotTriggerChar:/[^`_*[\]()<>!~\n]/,Scheme:/[A-Za-z][A-Za-z0-9+.-]{1,31}/,Email:/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/,HTMLOpenTag:/<HTMLTagName(?:HTMLAttribute)*\s*\/?>/,HTMLCloseTag:/<\/HTMLTagName\s*>/,HTMLTagName:/[A-Za-z][A-Za-z0-9-]*/,HTMLComment:/<!--(?:[^>-]|(?:[^>-](?:[^-]|-[^-])*[^-]))-->/,HTMLPI:/<\?(?:|.|(?:[^?]|\?[^>])*)\?>/,HTMLDeclaration:/<![A-Z]+\s[^>]*>/,HTMLCDATA:/<!\[CDATA\[.*?\]\]>/,HTMLAttribute:/\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:HTMLAttValue)?/,HTMLAttValue:/\s*=\s*(?:(?:'[^']*')|(?:"[^"]*")|(?:[^\s"'=<>`]+))/,KnownTag:/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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul/},St=new RegExp(/^(?:[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\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-\u2E42\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]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B])/),vt=new RegExp(/(?:[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\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-\u2E42\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]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B])$/),Lt={macPlatform:/Mac|iPod|iPhone|iPad/,lineSplit:/(?:\r\n|\r|\n)/,replacementPlaceholder:/(\${1,2})([0-9])/g,inlineContentPlaceholder:/\$\$([0-9])/,inlineReplacementPlaceholder:/\$([1-9])/g,blankContent:/^\s*$/,leadingWhitespace:/^\s/,trailingWhitespace:/\s$/,leadingWhitespaceRun:/^\s+/,surroundingWhitespace:/^(?<leading>\s*).*\S(?<trailing>\s*)$/,taskListItem:/^(\[)([ xX])(\])(\s|$)([\s\S]*)$/,orderedListNumber:/\d{1,9}/,inlineTagName:/^<\s*([a-zA-Z][a-zA-Z0-9]*)/,changeEvent:/^(?:change|input)$/i,selectionEvent:/^(?:selection|selectionchange)$/i,dropEvent:/^(?:drop)$/i,autolinkPrecedingChar:/[\s*_~(]/,emphasisDelimiter:/(^\*+)|(^_+)/,strikethroughDelimiter:/^~~/,autolinkScheme:/^(?:https?|ftp):\/\//i,autolinkWww:/^www\./i,autolinkDomain:/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)+/,autolinkPath:/^[^\s<]*/,autolinkProtocol:/^(?:mailto|xmpp):/i,autolinkXmpp:/^xmpp:/i,autolinkXmppResource:/^\/[a-zA-Z0-9@.\-_]+/,autolinkEmail:/^[a-zA-Z0-9.\-_+]+@[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)+/,emailTrailingChar:/[-_]$/,emailTld:/\.[a-zA-Z0-9]+$/,linkClosingBracket:/^\]/,openingAngle:/^</,closingAngle:/^>/,titleQuote:/^["']/,openingParen:/^\(/,closingParen:/^\)/,endsWithOpenAngle:/<$/,containsOpenAngle:/</,anyChar:/^./},Bt={TMH1:{regexp:/^( {0,3}#\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH1">$1</span>$$2<span class="TMMark TMMark_TMH1">$3</span>'},TMH2:{regexp:/^( {0,3}##\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH2">$1</span>$$2<span class="TMMark TMMark_TMH2">$3</span>'},TMH3:{regexp:/^( {0,3}###\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH3">$1</span>$$2<span class="TMMark TMMark_TMH3">$3</span>'},TMH4:{regexp:/^( {0,3}####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH4">$1</span>$$2<span class="TMMark TMMark_TMH4">$3</span>'},TMH5:{regexp:/^( {0,3}#####\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH5">$1</span>$$2<span class="TMMark TMMark_TMH5">$3</span>'},TMH6:{regexp:/^( {0,3}######\s)(.*?)((?:\s+#+\s*)?)$/,replacement:'<span class="TMMark TMMark_TMH6">$1</span>$$2<span class="TMMark TMMark_TMH6">$3</span>'},TMBlockquote:{regexp:/^( {0,3}>[ ]?)(.*)$/,replacement:'<span class="TMMark TMMark_TMBlockquote">$1</span>$$2'},TMCodeFenceBacktickOpen:{regexp:/^( {0,3}(?<seq>````*)\s*)([^`]*?)(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span><span class="TMInfoString">$3</span>$4'},TMCodeFenceTildeOpen:{regexp:/^( {0,3}(?<seq>~~~~*)\s*)(.*?)(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceTilde">$1</span><span class="TMInfoString">$3</span>$4'},TMCodeFenceBacktickClose:{regexp:/^( {0,3}(?<seq>````*))(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span>$3'},TMCodeFenceTildeClose:{regexp:/^( {0,3}(?<seq>~~~~*))(\s*)$/,replacement:'<span class="TMMark TMMark_TMCodeFenceTilde">$1</span>$3'},TMBlankLine:{regexp:/^([ \t]*)$/,replacement:"$0"},TMSetextH1Marker:{regexp:/^ {0,3}=+\s*$/,replacement:'<span class="TMMark TMMark_TMSetextH1Marker">$0</span>'},TMSetextH2Marker:{regexp:/^ {0,3}-+\s*$/,replacement:'<span class="TMMark TMMark_TMSetextH1Marker">$0</span>'},TMHR:{regexp:/^( {0,3}(\*[ \t]*\*[ \t]*\*[ \t*]*)|(-[ \t]*-[ \t]*-[ \t-]*)|(_[ \t]*_[ \t]*_[ \t_]*))$/,replacement:'<span class="TMMark TMMark_TMHR">$0</span>'},TMUL:{regexp:/^( {0,3}[+*-] {1,4})(.*)$/,replacement:'<span class="TMMark TMMark_TMUL">$1</span>$$2'},TMOL:{regexp:/^( {0,3}\d{1,9}[.)] {1,4})(.*)$/,replacement:'<span class="TMMark TMMark_TMOL">$1</span>$$2'},TMIndentedCode:{regexp:/^( {4}|\t)(.*)$/,replacement:'<span class="TMMark TMMark_TMIndentedCode">$1</span>$2'},TMLinkReferenceDefinition:{regexp:/^( {0,3}\[\s*)([^\s\]](?:[^\]]|\\\])*?)(\s*\]:\s*)((?:[^\s<>]+)|(?:<(?:[^<>\\]|\\.)*>))?(\s*)((?:\((?:[^()\\]|\\.)*\))|(?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*'))?(\s*)$/,replacement:'<span class="TMMark TMMark_TMLinkReferenceDefinition">$1</span><span class="TMLinkLabel TMLinkLabel_Definition">$2</span><span class="TMMark TMMark_TMLinkReferenceDefinition">$3</span><span class="TMLinkDestination">$4</span>$5<span class="TMLinkTitle">$6</span>$7',labelPlaceholder:2}},It=[{start:/^ {0,3}<(?:script|pre|style)(?:\s|>|$)/i,end:/(?:<\/script>|<\/pre>|<\/style>)/i,paraInterrupt:!0},{start:/^ {0,3}<!--/,end:/-->/,paraInterrupt:!0},{start:/^ {0,3}<\?/,end:/\?>/,paraInterrupt:!0},{start:/^ {0,3}<![A-Z]/,end:/>/,paraInterrupt:!0},{start:/^ {0,3}<!\[CDATA\[/,end:/\]\]>/,paraInterrupt:!0},{start:/^ {0,3}(?:<|<\/)(?:KnownTag)(?:\s|>|\/>|$)/i,end:!1,paraInterrupt:!0},{start:/^ {0,3}(?:HTMLOpenTag|HTMLCloseTag)\s*$/,end:!1,paraInterrupt:!1}],Nt={escape:{regexp:/^\\(ASCIIPunctuation)/,replacement:'<span class="TMMark TMMark_TMEscape">\\</span>$1'},code:{regexp:/^(`+)((?:[^`])|(?:[^`].*?[^`]))(\1)/,replacement:'<span class="TMMark TMMark_TMCode">$1</span><code class="TMCode">$2</code><span class="TMMark TMMark_TMCode">$3</span>'},autolink:{regexp:/^<((?:Scheme:[^\s<>]*)|(?:Email))>/,replacement:'<span class="TMMark TMMark_TMAutolink">&lt;</span><span class="TMAutolink">$1</span><span class="TMMark TMMark_TMAutolink">&gt;</span>'},html:{regexp:/^((?:HTMLOpenTag)|(?:HTMLCloseTag)|(?:HTMLComment)|(?:HTMLPI)|(?:HTMLDeclaration)|(?:HTMLCDATA))/,replacement:'<span class="TMHTML">$1</span>'},linkOpen:{regexp:/^\[/,replacement:""},imageOpen:{regexp:/^!\[/,replacement:""},linkLabel:{regexp:/^(\[\s*)([^\]]*?)(\s*\])/,replacement:"",labelPlaceholder:2},default:{regexp:/^(.|(?:NotTriggerChar+))/,replacement:"$1"}},Ht=new RegExp(Object.keys(xt).join("|")),Ot=[...Object.keys(Nt)];for(let e of Ot){let t=Nt[e].regexp.source;for(;t.match(Ht);)t=t.replace(Ht,(e=>xt[e].source));Nt[e].regexp=new RegExp(t,Nt[e].regexp.flags)}for(let e of It){let t=e.start.source;for(;t.match(Ht);)t=t.replace(Ht,(e=>xt[e].source));e.start=new RegExp(t,e.start.flags)}function _t(e){return(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const Pt={bold:{type:"inline",className:"TMStrong",set:{pre:"**",post:"**"},unset:{prePattern:/(?:\*\*|__)$/,postPattern:/^(?:\*\*|__)/}},italic:{type:"inline",className:"TMEm",set:{pre:"*",post:"*"},unset:{prePattern:/(?:\*|_)$/,postPattern:/^(?:\*|_)/}},code:{type:"inline",className:"TMCode",set:{pre:"`",post:"`"},unset:{prePattern:/`+$/,postPattern:/^`+/}},strikethrough:{type:"inline",className:"TMStrikethrough",set:{pre:"~~",post:"~~"},unset:{prePattern:/~~$/,postPattern:/^~~/}},h1:{type:"line",className:"TMH1",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"# $2"},unset:{pattern:/^( {0,3}#\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h2:{type:"line",className:"TMH2",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"## $2"},unset:{pattern:/^( {0,3}##\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h3:{type:"line",className:"TMH3",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"### $2"},unset:{pattern:/^( {0,3}###\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h4:{type:"line",className:"TMH4",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"#### $2"},unset:{pattern:/^( {0,3}####\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h5:{type:"line",className:"TMH5",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"##### $2"},unset:{pattern:/^( {0,3}#####\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},h6:{type:"line",className:"TMH6",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"###### $2"},unset:{pattern:/^( {0,3}######\s+)(.*?)((?:\s+#+\s*)?)$/,replacement:"$2"}},ul:{type:"line",className:"TMUL",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"- $2"},unset:{pattern:/^( {0,3}[+*-] {1,4})(.*)$/,replacement:"$2"}},ol:{type:"line",className:"TMOL",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"$#. $2"},unset:{pattern:/^( {0,3}\d{1,9}[.)] {1,4})(.*)$/,replacement:"$2"}},blockquote:{type:"line",className:"TMBlockquote",set:{pattern:/^( {0,3}(?:(?:#+|[0-9]{1,9}[).]|[>\-*+])\s+)?)(.*)$/,replacement:"> $2"},unset:{pattern:/^( {0,3}>[ ]?)(.*)$/,replacement:"$2"}}};e.Editor=class{constructor(e={}){var t;this.e=null,this.textarea=null,this.lines=[],this.lineElements=[],this.lineTypes=[],this.lineCaptures=[],this.lineReplacements=[],this.linkLabels=[],this.lineDirty=[],this.lastCommandState=null,this.customInlineGrammar={},this.mergedInlineGrammar=Nt,this.hasFocus=!0,this.lastSelection=null,this.cleanupFns=[],this.ownsElement=!1,this.elementOriginalStyle=null,this.textareaOriginalDisplay=null,this.destroyed=!1,this.listeners={change:[],selection:[],drop:[]},this.undoStack=[],this.redoStack=[],this.isRestoringHistory=!1,this.maxHistory=100,this.e=null,this.textarea=null,this.lines=[],this.lineElements=[],this.lineTypes=[],this.lineCaptures=[],this.lineReplacements=[],this.linkLabels=[],this.lineDirty=[],this.lastCommandState=null,this.hasFocus=!0,this.lastSelection=null,this.customInlineGrammar=e.customInlineGrammar||{},this.mergedInlineGrammar=function(e={}){const t={...Nt};for(const[n,s]of Object.entries(e)){const e={...s};let i=s.regexp.source;const r=new RegExp(Object.keys(xt).join("|"));for(;i.match(r);)i=i.replace(r,(e=>xt[e].source));e.regexp=new RegExp(i,s.regexp.flags),t[n]=e}return t}(this.customInlineGrammar),this.listeners={change:[],selection:[],drop:[]};let n=null;"string"==typeof e.element?n=document.getElementById(e.element):e.element&&(n=e.element),"string"==typeof e.textarea?this.textarea=document.getElementById(e.textarea):e.textarea&&(this.textarea=e.textarea),this.textarea&&(n||(n=this.textarea)),n||(n=document.getElementsByTagName("body")[0]),n&&"TEXTAREA"===n.tagName&&(this.textarea=n,n=this.textarea.parentNode),this.textarea&&(this.textareaOriginalDisplay=this.textarea.style.display,this.textarea.style.display="none"),this.placeholder=void 0!==e.placeholder?e.placeholder:(null===(t=this.textarea)||void 0===t?void 0:t.placeholder)||void 0,this.undoStack=[],this.redoStack=[],this.isRestoringHistory=!1,this.maxHistory=100,this.createEditorElement(n,e),this.setContent("string"==typeof e.content?e.content:this.textarea?this.textarea.value:"# Hello TinyMDE!\nEdit **here**"),this.addListener(this.e,"keydown",(e=>this.handleUndoRedoKey(e)))}get canUndo(){return this.undoStack.length>=2}get canRedo(){return this.redoStack.length>0}pushHistory(){this.isRestoringHistory||(this.pushCurrentState(),this.redoStack=[])}pushCurrentState(){this.undoStack.push({content:this.getContent(),selection:this.getSelection(),anchor:this.getSelection(!0)}),this.undoStack.length>this.maxHistory&&this.undoStack.shift()}undo(){if(this.undoStack.length<2)return;this.isRestoringHistory=!0,this.pushCurrentState();const e=this.undoStack.pop();this.redoStack.push(e);const t=this.undoStack[this.undoStack.length-1];this.setContent(t.content),t.selection&&this.setSelection(t.selection,t.anchor),this.undoStack.pop(),this.isRestoringHistory=!1}redo(){if(!this.redoStack.length)return;this.isRestoringHistory=!0,this.pushCurrentState();const e=this.redoStack.pop();this.setContent(e.content),e.selection&&this.setSelection(e.selection,e.anchor),this.isRestoringHistory=!1}handleUndoRedoKey(e){(Lt.macPlatform.test(navigator.platform)?e.metaKey:e.ctrlKey)&&!e.altKey&&("z"===e.key||"Z"===e.key?(e.shiftKey?this.redo():this.undo(),e.preventDefault()):"y"!==e.key&&"Y"!==e.key||(this.redo(),e.preventDefault()))}createEditorElement(e,t){t&&void 0!==t.editor?"string"==typeof t.editor?this.e=document.getElementById(t.editor):this.e=t.editor:(this.e=document.createElement("div"),this.ownsElement=!0),this.ownsElement||(this.elementOriginalStyle=this.e.getAttribute("style")),this.e.classList.add("TinyMDE"),this.e.contentEditable="true",this.e.style.whiteSpace="pre-wrap",this.e.style.webkitUserModify="read-write-plaintext-only",this.placeholder&&this.e.setAttribute("data-placeholder",this.placeholder),void 0===t.editor&&(this.textarea&&this.textarea.parentNode===e&&this.textarea.nextSibling?e.insertBefore(this.e,this.textarea.nextSibling):e.appendChild(this.e)),this.addListener(this.e,"input",(e=>this.handleInputEvent(e))),this.addListener(this.e,"beforeinput",(e=>this.handleBeforeInputEvent(e))),this.addListener(this.e,"compositionend",(e=>this.handleInputEvent(e))),this.addListener(document,"selectionchange",(e=>{this.hasFocus&&this.handleSelectionChangeEvent(e)})),this.addListener(this.e,"blur",(()=>this.hasFocus=!1)),this.addListener(this.e,"focus",(()=>this.hasFocus=!0)),this.addListener(this.e,"paste",(e=>this.handlePaste(e))),this.addListener(this.e,"drop",(e=>this.handleDrop(e))),this.addListener(this.e,"click",(e=>this.handleClick(e))),this.lineElements=this.e.childNodes}setContent(e){for(;this.e.firstChild;)this.e.removeChild(this.e.firstChild);this.lines=e.split(Lt.lineSplit),this.lineDirty=[];for(let e=0;e<this.lines.length;e++){let e=document.createElement("div");this.e.appendChild(e),this.lineDirty.push(!0)}this.lineTypes=new Array(this.lines.length),this.updateFormatting(),this.updatePlaceholder(),this.fireChange(),this.isRestoringHistory||this.pushHistory()}getContent(){return this.lines.join("\n")}updatePlaceholder(){this.placeholder&&this.e&&(""===this.getContent()?this.e.classList.add("TinyMDE_empty"):this.e.classList.remove("TinyMDE_empty"))}updateFormatting(){this.updateLineTypes(),this.updateLinkLabels(),this.applyLineTypes()}updateLinkLabels(){this.linkLabels=[];for(let e=0;e<this.lines.length;e++)"TMLinkReferenceDefinition"===this.lineTypes[e]&&this.linkLabels.push(this.lineCaptures[e][Bt.TMLinkReferenceDefinition.labelPlaceholder])}replace(e,t){return e.replace(Lt.replacementPlaceholder,((e,n,s)=>"$"===n?_t(t[parseInt(s)]):`<span class="TMInlineFormatted">${this.processInlineStyles(t[parseInt(s)])}</span>`))}applyLineTypes(){let e=0;for(;e<this.lines.length;)if(this.isInlineGroupLeader(e)){const t=this.lineTypes[e];let n=e;for(;n+1<this.lines.length&&this.isInlineContinuation(n+1,t);)n++;this.applyInlineGroup(e,n),e=n+1}else this.applyLine(e),e++}isInlineGroupLeader(e){const t=this.lineTypes[e];return"TMPara"===t||"TMUL"===t||"TMOL"===t||"TMBlockquote"===t&&!this.isBlankBlockquoteContent(e)}isInlineContinuation(e,t){const n=this.lineTypes[e];return"TMPara"===n||"TMBlockquote"===n&&"TMBlockquote"===t&&!this.isBlankBlockquoteContent(e)}isBlankBlockquoteContent(e){const t=this.lineCaptures[e],n=t&&void 0!==t[2]?t[2]:"";return Lt.blankContent.test(n)}applyLine(e){const t=this.lineElements[e];if(this.lineDirty[e]){let n=this.replace(this.lineReplacements[e],this.lineCaptures[e]);t.className=this.lineTypes[e],t.removeAttribute("style"),t.innerHTML=""===n?"<br />":n,delete t.dataset.mlSig}t.dataset.lineNum=e.toString()}applyInlineGroup(e,t){const n=[];let s=""+(t-e);for(let i=e;i<=t;i++){const e=this.inlineContentIndex(this.lineReplacements[i]);n.push(void 0!==this.lineCaptures[i][e]?this.lineCaptures[i][e]:""),s+=`${this.lineTypes[i]}${this.lineReplacements[i]}${JSON.stringify(this.lineCaptures[i])}`}const i=`${this.hashString(s)}`;let r=!1;for(let n=e;n<=t;n++)if(this.lineDirty[n]||this.lineElements[n].dataset.mlSig!==i){r=!0;break}if(r){const s=this.splitInlineHTMLByLine(this.processInlineStyles(n.join("\n")));for(let n=e;n<=t;n++){const t=this.lineElements[n],r=s[n-e]||"",l=this.replaceWithInline(this.lineReplacements[n],this.lineCaptures[n],r);t.className=this.lineTypes[n],t.removeAttribute("style"),t.innerHTML=""===l?"<br />":l,t.dataset.mlSig=i}}for(let n=e;n<=t;n++)this.lineElements[n].dataset.lineNum=n.toString()}inlineContentIndex(e){const t=Lt.inlineContentPlaceholder.exec(e);return t?parseInt(t[1]):0}replaceWithInline(e,t,n){return e.replace(Lt.replacementPlaceholder,((e,s,i)=>"$"===s?_t(t[parseInt(i)]):`<span class="TMInlineFormatted">${n}</span>`))}splitInlineHTMLByLine(e){const t=[],n=[];let s="",i=0;for(;i<e.length;){const r=e[i];if("\n"===r){for(let e=n.length-1;e>=0;e--)s+=`</${this.inlineTagName(n[e])}>`;t.push(s),s=n.join(""),i++}else if("<"===r){const t=e.indexOf(">",i);if(t<0){s+=e.substr(i);break}const r=e.substring(i,t+1);s+=r,"/"===r[1]?n.pop():"/"!==r[r.length-2]&&n.push(r),i=t+1}else s+=r,i++}return t.push(s),t}inlineTagName(e){const t=Lt.inlineTagName.exec(e);return t?t[1]:"span"}hashString(e){let t=5381;for(let n=0;n<e.length;n++)t=((t<<5)+t^e.charCodeAt(n))>>>0;return t}updateLineTypes(){let e=!1,t=0,n=!1;for(let s=0;s<this.lines.length;s++){let i="TMPara",r=[this.lines[s]],l="$$0";if("TMCodeFenceBacktickOpen"===e){let n=Bt.TMCodeFenceBacktickClose.regexp.exec(this.lines[s]);n&&n.groups.seq.length>=t?(i="TMCodeFenceBacktickClose",l=Bt.TMCodeFenceBacktickClose.replacement,r=n,e=!1):(i="TMFencedCodeBacktick",l='<span class="TMFencedCode">$0<br /></span>',r=[this.lines[s]])}else if("TMCodeFenceTildeOpen"===e){let n=Bt.TMCodeFenceTildeClose.regexp.exec(this.lines[s]);n&&n.groups.seq.length>=t?(i="TMCodeFenceTildeClose",l=Bt.TMCodeFenceTildeClose.replacement,r=n,e=!1):(i="TMFencedCodeTilde",l='<span class="TMFencedCode">$0<br /></span>',r=[this.lines[s]])}if("TMPara"===i&&!1===n)for(let e of It)if(this.lines[s].match(e.start)&&(e.paraInterrupt||0===s||"TMPara"!==this.lineTypes[s-1]&&"TMUL"!==this.lineTypes[s-1]&&"TMOL"!==this.lineTypes[s-1]&&"TMBlockquote"!==this.lineTypes[s-1])){n=e;break}if(!1!==n&&(i="TMHTMLBlock",l='<span class="TMHTMLContent">$0<br /></span>',r=[this.lines[s]],n.end?this.lines[s].match(n.end)&&(n=!1):(s===this.lines.length-1||this.lines[s+1].match(Bt.TMBlankLine.regexp))&&(n=!1)),"TMPara"===i)for(let e in Bt)if(Bt[e].regexp){let t=Bt[e].regexp.exec(this.lines[s]);if(t){i=e,l=Bt[e].replacement,r=t;break}}if("TMCodeFenceBacktickOpen"!==i&&"TMCodeFenceTildeOpen"!==i||(e=i,t=r.groups.seq.length),"TMIndentedCode"!==i&&"TMLinkReferenceDefinition"!==i||!(s>0)||"TMPara"!==this.lineTypes[s-1]&&"TMUL"!==this.lineTypes[s-1]&&"TMOL"!==this.lineTypes[s-1]&&"TMBlockquote"!==this.lineTypes[s-1]||(i="TMPara",r=[this.lines[s]],l="$$0"),"TMSetextH2Marker"===i){let e=Bt.TMUL.regexp.exec(this.lines[s]);e&&(i="TMUL",l=Bt.TMUL.replacement,r=e)}if("TMSetextH1Marker"===i||"TMSetextH2Marker"===i)if(0===s||"TMPara"!==this.lineTypes[s-1]){let e=Bt.TMHR.regexp.exec(this.lines[s]);e?(i="TMHR",r=e,l=Bt.TMHR.replacement):(i="TMPara",r=[this.lines[s]],l="$$0")}else{let e=s-1;const t="TMSetextH1Marker"===i?"TMSetextH1":"TMSetextH2";do{this.lineTypes[e]!==t&&(this.lineTypes[e]=t,this.lineDirty[e]=!0),this.lineReplacements[e]="$$0",this.lineCaptures[e]=[this.lines[e]],e--}while(e>=0&&"TMPara"===this.lineTypes[e])}if("TMUL"===i||"TMOL"===i){const e=void 0!==r[2]?r[2]:"",t=Lt.taskListItem.exec(e);if(t){const e="TMUL"===i?"TMMark_TMUL":"TMMark_TMOL",n=" "!==t[2]?"TMCheckbox TMCheckbox_checked":"TMCheckbox TMCheckbox_unchecked";r=[r[0],r[1],t[1],t[2],t[3],t[4],t[5]],l=`<span class="TMMark ${e}">$1</span><span class="TMMark TMMark_TMTask">$2</span><span class="${n}">$3</span><span class="TMMark TMMark_TMTask">$4</span><span class="TMMark TMMark_TMTask">$5</span>$$6`}}this.lineTypes[s]!==i&&(this.lineTypes[s]=i,this.lineDirty[s]=!0),this.lineReplacements[s]=l,this.lineCaptures[s]=r}}getSelection(e=!1){var t,n;const s=window.getSelection();let i=e?s.anchorNode:s.focusNode;if(!i)return null;let r=e?s.anchorOffset:s.focusOffset;if(i===this.e)return r<this.lines.length?{row:r,col:0}:{row:r-1,col:this.lines[r-1].length};let l=this.computeColumn(i,r);if(null===l)return null;let a=i;for(;a.parentElement!==this.e;)a=a.parentElement;let o=0;if(a.previousSibling){const e=null===(t=a.dataset)||void 0===t?void 0:t.lineNum,s=null===(n=a.previousSibling.dataset)||void 0===n?void 0:n.lineNum;if(e&&s){const t=parseInt(e);if(t===parseInt(s)+1)o=t;else for(;a.previousSibling;)o++,a=a.previousSibling}}return{row:o,col:l}}setSelection(e,t=null){if(!e)return;let{node:n,offset:s}=this.computeNodeAndOffset(e.row,e.col,!!t&&(t.row===e.row&&t.col>e.col)),i=null,r=null;if(t&&(t.row!==e.row||t.col!==e.col)){let{node:n,offset:s}=this.computeNodeAndOffset(t.row,t.col,e.row===t.row&&e.col>t.col);i=n,r=s}window.getSelection().setBaseAndExtent(n,s,i||n,i?r:s)}restoreLastSelection(){return!(!this.lastSelection||!this.lastSelection.focus)&&(this.setSelection(this.lastSelection.focus,this.lastSelection.anchor),!0)}paste(e,t=null,n=null){let s,i;t||(t=this.getSelection(!0)),n||(n=this.getSelection(!1)),n||(n={row:this.lines.length-1,col:this.lines[this.lines.length-1].length}),t||(t=n),t.row<n.row||t.row===n.row&&t.col<=n.col?(s=t,i=n):(s=n,i=t);let r=e.split(Lt.lineSplit),l=this.lines[s.row].substr(0,s.col),a=this.lines[i.row].substr(i.col);r[0]=l.concat(r[0]);let o=r[r.length-1].length;r[r.length-1]=r[r.length-1].concat(a),this.spliceLines(s.row,1+i.row-s.row,r),n.row=s.row+r.length-1,n.col=o,this.updateFormatting(),this.setSelection(n),this.fireChange()}wrapSelection(e,t,n=null,s=null){if(n||(n=this.getSelection(!1)),s||(s=this.getSelection(!0)),!n||!s||n.row!==s.row)return;this.isRestoringHistory||this.pushHistory(),this.lineDirty[n.row]=!0;const i=n.col<s.col?n.col:s.col,r=n.col<s.col?s.col:n.col,l=this.lines[n.row].substr(0,i).concat(e),a=r===i?"":this.lines[n.row].substr(i,r-i),o=t.concat(this.lines[n.row].substr(r));this.lines[n.row]=l.concat(a,o),s.col=l.length,n.col=s.col+a.length,this.updateFormatting(),this.setSelection(n,s),this.fireChange()}addEventListener(e,t){e.match(Lt.changeEvent)&&this.listeners.change.push(t),e.match(Lt.selectionEvent)&&this.listeners.selection.push(t),e.match(Lt.dropEvent)&&this.listeners.drop.push(t)}removeEventListener(e,t){e.match(Lt.changeEvent)&&(this.listeners.change=this.listeners.change.filter((e=>e!==t))),e.match(Lt.selectionEvent)&&(this.listeners.selection=this.listeners.selection.filter((e=>e!==t))),e.match(Lt.dropEvent)&&(this.listeners.drop=this.listeners.drop.filter((e=>e!==t)))}addListener(e,t,n){e.addEventListener(t,n),this.cleanupFns.push((()=>e.removeEventListener(t,n)))}destroy(){var e;if(!this.destroyed){this.destroyed=!0;for(const e of this.cleanupFns)e();if(this.cleanupFns=[],this.e)if(this.ownsElement)this.e.parentNode&&this.e.parentNode.removeChild(this.e);else{for(this.e.classList.remove("TinyMDE","TinyMDE_empty"),this.e.removeAttribute("contenteditable"),this.e.removeAttribute("data-placeholder");this.e.firstChild;)this.e.removeChild(this.e.firstChild);this.elementOriginalStyle?this.e.setAttribute("style",this.elementOriginalStyle):this.e.removeAttribute("style")}this.textarea&&(this.textarea.style.display=null!==(e=this.textareaOriginalDisplay)&&void 0!==e?e:""),this.listeners={change:[],selection:[],drop:[]},this.e=null,this.textarea=null}}fireChange(){if(this.updatePlaceholder(),!this.textarea&&!this.listeners.change.length)return;const e=this.getContent();this.textarea&&(this.textarea.value=e);for(let t of this.listeners.change)t({content:e,linesDirty:[...this.lineDirty]})}handleBeforeInputEvent(e){const t=e;if("deleteContentBackward"===t.inputType||"deleteContentForward"===t.inputType){const n=this.getSelection(),s=this.getSelection(!0);if(!n||!s)return;const i="deleteContentBackward"===t.inputType;if(n.row===s.row&&n.col===s.col){if(i&&0===n.col&&n.row>0){e.preventDefault(),this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();const t=this.lines[n.row-1].length;return this.lines[n.row-1]=this.lines[n.row-1]+this.lines[n.row],this.lineDirty[n.row-1]=!0,this.spliceLines(n.row,1),this.updateFormatting(),this.setSelection({row:n.row-1,col:t}),void this.fireChange()}if(!i&&n.col===this.lines[n.row].length&&n.row<this.lines.length-1){e.preventDefault(),this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();const t=this.lines[n.row].length;return this.lines[n.row]=this.lines[n.row]+this.lines[n.row+1],this.lineDirty[n.row]=!0,this.spliceLines(n.row+1,1),this.updateFormatting(),this.setSelection({row:n.row,col:t}),void this.fireChange()}}return}if("insertParagraph"!==t.inputType&&"insertLineBreak"!==t.inputType)return;this.isRestoringHistory||this.pushHistory(),e.preventDefault(),this.clearDirtyFlag();const n=this.getSelection(),s=this.getSelection(!0);if(n&&s){if(n.row!==s.row){const e=n.row<s.row?n:s,t=n.row<s.row?s:n;this.lines[e.row]=this.lines[e.row].substring(0,e.col),this.lines[t.row]=this.lines[t.row].substring(t.col),this.spliceLines(e.row+1,t.row-e.row-1),n.row=e.row+1,n.col=0}else{let e=!1;switch(this.lineTypes[n.row]){case"TMUL":e="TMUL";break;case"TMOL":e="TMOL";break;case"TMIndentedCode":e="TMIndentedCode"}const t=this.lines[n.row].substring(0,n.col<=s.col?n.col:s.col),i=this.lines[n.row].substring(n.col<=s.col?s.col:n.col);if(this.spliceLines(n.row,1,[t,i]),n.row+=1,n.col=0,e){let t=Bt[e].regexp.exec(this.lines[n.row-1]);t&&(t[2]?("TMOL"===e&&(t[1]=t[1].replace(Lt.orderedListNumber,(e=>(parseInt(e)+1).toString()))),this.lines[n.row]=`${t[1]}${this.lines[n.row]}`,this.lineDirty[n.row]=!0,n.col=t[1].length):(this.lines[n.row-1]="",this.lineDirty[n.row-1]=!0))}}this.updateFormatting(),this.setSelection(n),n&&n.row<this.lineElements.length&&this.lineElements[n.row].scrollIntoView({block:"nearest",inline:"nearest"}),this.fireChange()}}handleInputEvent(e){const t=e;if("insertCompositionText"===t.inputType)return;this.isRestoringHistory||this.pushHistory();let n=this.getSelection();("insertParagraph"!==t.inputType&&"insertLineBreak"!==t.inputType||!n)&&(this.e.firstChild?this.fixNodeHierarchy():this.e.innerHTML='<div class="TMBlankLine"><br></div>',this.updateLineContentsAndFormatting(),n&&this.setSelection(n),this.fireChange())}handleSelectionChangeEvent(e){this.fireSelection()}handlePaste(e){this.isRestoringHistory||this.pushHistory(),e.preventDefault();let t=e.clipboardData.getData("text/plain");this.paste(t)}handleDrop(e){e.preventDefault(),this.fireDrop(e.dataTransfer)}handleClick(e){const t=e.target,n=t&&t.closest?t.closest(".TMCheckbox"):null;if(!n)return;let s=n;for(;s&&s.parentNode!==this.e;)s=s.parentNode;if(!s||void 0===s.dataset.lineNum)return;const i=parseInt(s.dataset.lineNum,10);if(isNaN(i)||i<0||i>=this.lines.length)return;const r=this.computeColumn(n,0);if(null===r)return;const l=this.lines[i].charAt(r);if(" "!==l&&"x"!==l&&"X"!==l)return;e.preventDefault(),this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();const a=" "===l?"x":" ";this.lines[i]=this.lines[i].substr(0,r)+a+this.lines[i].substr(r+1),this.lineDirty[i]=!0,this.updateFormatting(),this.fireChange()}processInlineStyles(e){let t="",n=[],s=0,i=e;e:for(;i;){if(10===i.charCodeAt(0)){t+="\n",i=i.substr(1),s+=1;continue e}for(let e of["escape","code","autolink","html"])if(this.mergedInlineGrammar[e]){let n=this.mergedInlineGrammar[e].regexp.exec(i);if(n){i=i.substr(n[0].length),s+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(Lt.inlineReplacementPlaceholder,((e,t)=>_t(n[t])));continue e}}for(let e in this.customInlineGrammar)if("escape"!==e&&"code"!==e&&"autolink"!==e&&"html"!==e&&"linkOpen"!==e&&"imageOpen"!==e&&"linkLabel"!==e&&"default"!==e){let n=this.mergedInlineGrammar[e].regexp.exec(i);if(n){i=i.substr(n[0].length),s+=n[0].length,t+=this.mergedInlineGrammar[e].replacement.replace(Lt.inlineReplacementPlaceholder,((e,t)=>_t(n[t])));continue e}}const r=s>0?e[s-1]:"";if(""===r||Lt.autolinkPrecedingChar.test(r)){let e=this.parseAutolinkExtension(i);if(e){t=`${t}${e.output}`,i=i.substr(e.charCount),s+=e.charCount;continue e}}let l=i.match(this.mergedInlineGrammar.linkOpen.regexp),a=i.match(this.mergedInlineGrammar.imageOpen.regexp);if(a||l){let e=this.parseLinkOrImage(i,!!a);if(e){t=`${t}${e.output}`,i=i.substr(e.charCount),s+=e.charCount;continue e}}let o=Lt.emphasisDelimiter.exec(i);if(o){let r=o[0].length;const l=o[0],a=o[0][0];i=i.substr(o[0].length);const u=s>0?e.substr(0,s):" ",c=s+o[0].length<e.length?i:" ",h=c.match(St),p=u.match(vt),f=c.match(Lt.leadingWhitespace),d=u.match(Lt.trailingWhitespace);let g=!(f||h&&!d&&!p),m=!(d||p&&!f&&!h);if("_"===a&&g&&m&&(g=!!p,m=!!h),m){let e=n.length-1;for(;r&&e>=0;)if(n[e].delimiter===a){for(;e<n.length-1;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}if(r>=2&&n[e].count>=2?(t=`<span class="TMMark">${a}${a}</span><strong class="TMStrong">${t}</strong><span class="TMMark">${a}${a}</span>`,r-=2,n[e].count-=2):(t=`<span class="TMMark">${a}</span><em class="TMEm">${t}</em><span class="TMMark">${a}</span>`,r-=1,n[e].count-=1),0===n[e].count){t=`${n.pop().output}${t}`,e--}}else e--}r&&g&&(n.push({delimiter:a,delimString:l,count:r,output:t}),t="",r=0),r&&(t=`${t}${l.substr(0,r)}`),s+=o[0].length}else if(o=Lt.strikethroughDelimiter.exec(i),o){let e=!1,r=n.length-1;for(;!e&&r>=0;)if("~"===n[r].delimiter){for(;r<n.length-1;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}t=`<span class="TMMark">~~</span><del class="TMStrikethrough">${t}</del><span class="TMMark">~~</span>`,t=`${n.pop().output}${t}`,e=!0}else r--;e||(n.push({delimiter:"~",delimString:"~~",count:2,output:t}),t=""),s+=o[0].length,i=i.substr(o[0].length)}else{if(o=this.mergedInlineGrammar.default.regexp.exec(i),!o)throw"Infinite loop!";i=i.substr(o[0].length),s+=o[0].length,t+=this.mergedInlineGrammar.default.replacement.replace(Lt.inlineReplacementPlaceholder,((e,t)=>_t(o[t])))}}for(;n.length;){const e=n.pop();t=`${e.output}${e.delimString.substr(0,e.count)}${t}`}return t}computeColumn(e,t){let n,s=e;for(;s&&s.parentNode!==this.e;)s=s.parentNode;if(null===s)return null;for(e.nodeType===Node.TEXT_NODE||0===t?(n=t,s=e):t>0?(s=e.childNodes[t-1],n=s.textContent.length):(n=0,s=e);s.parentNode!==this.e;)s.previousSibling?(s=s.previousSibling,n+=s.textContent.length):s=s.parentNode;return n}computeNodeAndOffset(e,t,n=!1){e>=this.lineElements.length&&(e=this.lineElements.length-1,t=this.lines[e].length),t>this.lines[e].length&&(t=this.lines[e].length);const s=this.lineElements[e];let i=s.firstChild,r=!1,l={node:s.firstChild?s.firstChild:s,offset:0};for(;i!==s;){if(!r&&i.nodeType===Node.TEXT_NODE)if(i.nodeValue.length>=t){if(!n||i.nodeValue.length!==t)return{node:i,offset:t};l={node:i,offset:t},t=0}else t-=i.nodeValue.length;!r&&i.firstChild?i=i.firstChild:i.nextSibling?(r=!1,i=i.nextSibling):(r=!0,i=i.parentNode)}return l}updateLineContentsAndFormatting(){this.clearDirtyFlag(),this.updateLineContents(),this.updateFormatting()}clearDirtyFlag(){this.lineDirty=new Array(this.lines.length);for(let e=0;e<this.lineDirty.length;e++)this.lineDirty[e]=!1}updateLineContents(){let e=this.e.childElementCount-this.lines.length;if(e){let t=0;for(;t<=this.lines.length&&t<=this.lineElements.length&&this.lineElements[t]&&this.lines[t]===this.lineElements[t].textContent&&this.lineTypes[t]===this.lineElements[t].className;)t++;let n=-1;for(;-n<this.lines.length&&-n<this.lineElements.length&&this.lines[this.lines.length+n]===this.lineElements[this.lineElements.length+n].textContent&&this.lineTypes[this.lines.length+n]===this.lineElements[this.lineElements.length+n].className;)n--;let s=this.lines.length+n+1-t;s<-e&&(s=-e),s<0&&(s=0);let i=[];for(let n=0;n<s+e;n++)i.push(this.lineElements[t+n].textContent||"");this.spliceLines(t,s,i,!1)}else for(let e=0;e<this.lineElements.length;e++){let t=this.lineElements[e],n=t.textContent||"";this.lines[e]===n&&this.lineTypes[e]===t.className||(this.lines[e]=n,this.lineTypes[e]=t.className,this.lineDirty[e]=!0)}}spliceLines(e,t=0,n=[],s=!0){if(s)for(let n=0;n<t;n++)this.e.removeChild(this.e.childNodes[e]);let i=[],r=[];for(let t=0;t<n.length;t++)i.push(""),r.push(!0),s&&(this.e.childNodes[e]?this.e.insertBefore(document.createElement("div"),this.e.childNodes[e]):this.e.appendChild(document.createElement("div")));this.lines.splice(e,t,...n),this.lineTypes.splice(e,t,...i),this.lineDirty.splice(e,t,...r)}fixNodeHierarchy(){const e=Array.from(this.e.childNodes),t=(e,...t)=>{const n=e.parentElement,s=e.nextSibling;n.removeChild(e),t.forEach((e=>s?n.insertBefore(e,s):n.appendChild(e)))};e.forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE||"DIV"!==e.tagName){const n=document.createElement("div");t(e,n),n.appendChild(e)}else if(0===e.childNodes.length)e.appendChild(document.createElement("br"));else{const n=Array.from(e.childNodes);if(n.some((e=>e.nodeType===Node.ELEMENT_NODE&&"DIV"===e.tagName)))return t(e,...n)}}))}parseAutolinkExtension(e){const t=this.matchExtendedAutolink(e);return!!t&&{output:`<span class="TMAutolink">${_t(t)}</span>`,charCount:t.length}}matchExtendedAutolink(e){const t=Lt.autolinkScheme.exec(e),n=Lt.autolinkWww.test(e);if(t||n){const n=t?t[0].length:0,s=e.substr(n),i=Lt.autolinkDomain.exec(s);if(i&&this.isValidAutolinkDomain(i[0])){const t=Lt.autolinkPath.exec(s.substr(i[0].length)),r=e.substr(0,n+i[0].length+(t?t[0].length:0)),l=this.trimAutolinkTrailing(r);if(l.length>=n+i[0].length)return l}}const s=Lt.autolinkProtocol.exec(e);if(s){const t=this.matchAutolinkEmail(e.substr(s[0].length));if(t){let n="";if(Lt.autolinkXmpp.test(e)){const i=Lt.autolinkXmppResource.exec(e.substr(s[0].length+t.length));i&&(n=i[0])}return s[0]+t+n}}const i=this.matchAutolinkEmail(e);return i||!1}isValidAutolinkDomain(e){const t=e.split(".");return!(t.length<2)&&!t.slice(-2).some((e=>e.indexOf("_")>=0))}matchAutolinkEmail(e){const t=Lt.autolinkEmail.exec(e);if(!t)return!1;let n=t[0];for(;n.length&&Lt.emailTrailingChar.test(n);)n=n.substr(0,n.length-1);return!!Lt.emailTld.test(n)&&n}trimAutolinkTrailing(e){let t=e.length,n=!0;for(;n&&t>0;){n=!1;const s=e[t-1];if("?!.,:*_~".indexOf(s)>=0)t--,n=!0;else if(")"===s){let s=0,i=0;for(let n=0;n<t;n++)"("===e[n]?s++:")"===e[n]&&i++;i>s&&(t--,n=!0)}}return e.substr(0,t)}parseLinkOrImage(e,t){let n=t?2:1,s=e.substr(0,n),i=t?"TMImage":"TMLink",r=n,l=1,a=!1,o=!1,u=[],c=[];e:for(;r<e.length&&!1===a;){let s=e.substr(r);for(let e of["escape","code","autolink","html"]){let t=this.mergedInlineGrammar[e].regexp.exec(s);if(t){r+=t[0].length;continue e}}if(s.match(this.mergedInlineGrammar.imageOpen.regexp))l++,r+=2;else if(s.match(this.mergedInlineGrammar.linkOpen.regexp)){if(l++,!t&&this.parseLinkOrImage(s,!1))return!1;r+=1}else s.match(Lt.linkClosingBracket)&&(l--,0===l)?(a=e.substr(n,r-n),r++):r++}if(!1===a)return!1;let h=r<e.length?e.substr(r,1):"";if("["===h){let t=e.substr(r),n=this.mergedInlineGrammar.linkLabel.regexp.exec(t);if(!n)return!1;r+=n[0].length,u.push(n[1],n[2],n[3]),o=n[this.mergedInlineGrammar.linkLabel.labelPlaceholder]?n[this.mergedInlineGrammar.linkLabel.labelPlaceholder]:a.trim()}else if("("!==h)o=a.trim();else{r++;let t=1;for(;r<e.length&&t>0;){let n=e.substr(r),s=Lt.leadingWhitespaceRun.exec(n);if(s){switch(c.length){case 0:case 1:c.push(s[0]);break;case 2:if(c[0].match(Lt.containsOpenAngle))c[1]=c[1].concat(s[0]);else{if(1!==t)return!1;c.push(""),c.push(s[0])}break;case 3:c.push(s[0]);break;case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;case 7:c[6]=c[6].concat(s[0]);break;default:return!1}r+=s[0].length}else if(s=this.mergedInlineGrammar.escape.regexp.exec(n),s){switch(c.length){case 0:c.push("");case 1:c.push(s[0]);break;case 2:c[1]=c[1].concat(s[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;default:return!1}r+=s[0].length}else if(c.length<2&&n.match(Lt.openingAngle))0===c.length&&c.push(""),c[0]=c[0].concat("<"),r++;else if(1!==c.length&&2!==c.length||!n.match(Lt.closingAngle))if(s=Lt.titleQuote.exec(n),!s||0!==c.length&&1!==c.length&&4!==c.length)if(!s||5!==c.length&&6!==c.length||c[4]!==s[0])if(n.match(Lt.openingParen)){switch(c.length){case 0:c.push("");case 1:c.push("");case 2:c[1]=c[1].concat("("),c[0].match(Lt.endsWithOpenAngle)||t++;break;case 3:c.push("");case 4:c.push("(");break;case 5:c.push("");case 6:if("("===c[4])return!1;c[5]=c[5].concat("(");break;default:return!1}r++}else if(n.match(Lt.closingParen)){if(c.length<=2){for(;c.length<2;)c.push("");c[0].match(Lt.endsWithOpenAngle)||t--,t>0&&(c[1]=c[1].concat(")"))}else 5===c.length||6===c.length?"("===c[4]?(5===c.length&&c.push(""),c.push(")")):5===c.length?c.push(")"):c[5]=c[5].concat(")"):t--;if(0===t)for(;c.length<7;)c.push("");r++}else{if(s=Lt.anyChar.exec(n),!s)throw"Infinite loop";switch(c.length){case 0:c.push("");case 1:c.push(s[0]);break;case 2:c[1]=c[1].concat(s[0]);break;case 3:case 4:return!1;case 5:c.push("");case 6:c[5]=c[5].concat(s[0]);break;default:return!1}r+=s[0].length}else 5===c.length&&c.push(""),c.push(s[0]),r++;else{for(;c.length<4;)c.push("");c.push(s[0]),r++}else 1===c.length&&c.push(""),c.push(">"),r++}if(t>0)return!1}if(!1!==o){let e=!1;for(let t of this.linkLabels)if(t===o){e=!0;break}let t=e?"TMLinkLabel TMLinkLabel_Valid":"TMLinkLabel TMLinkLabel_Invalid",n=`<span class="TMMark TMMark_${i}">${s}</span><span class="${i} ${u.length<3||!u[1]?t:""}">${this.processInlineStyles(a)}</span><span class="TMMark TMMark_${i}">]</span>`;return u.length>=3&&(n=n.concat(`<span class="TMMark TMMark_${i}">${u[0]}</span>`,`<span class="${t}">${u[1]}</span>`,`<span class="TMMark TMMark_${i}">${u[2]}</span>`)),{output:n,charCount:r}}if(c.length>0){for(;c.length<7;)c.push("");return{output:`<span class="TMMark TMMark_${i}">${s}</span><span class="${i}">${this.processInlineStyles(a)}</span><span class="TMMark TMMark_${i}">](${_t(c[0])}</span><span class="${i}Destination">${_t(c[1])}</span><span class="TMMark TMMark_${i}">${_t(c[2])}${_t(c[3])}${_t(c[4])}</span><span class="${i}Title">${_t(c[5])}</span><span class="TMMark TMMark_${i}">${_t(c[6])})</span>`,charCount:r}}return!1}computeCommonAncestor(e,t){if(!e||!t)return null;if(e===t)return e;const n=e=>{let t=[];for(;e;)t.unshift(e),e=e.parentNode;return t},s=n(e),i=n(t);if(s[0]!==i[0])return null;let r;for(r=0;s[r]===i[r];r++);return s[r-1]}computeEnclosingMarkupNode(e,t,n){let s=null;if(!e)return null;if(t){if(e.row!==t.row)return null;const n=window.getSelection();if(!n)return null;s=this.computeCommonAncestor(n.focusNode,n.anchorNode)}else{const e=window.getSelection();if(!e||!e.focusNode)return null;s=e.focusNode}if(!s)return null;for(;s!==this.e;){if(s.classList&&s.classList.contains(n))return s;s=s.parentNode}return null}getCommandState(e=null,t=null){let n,s,i={};if(e||(e=this.getSelection(!1)),t||(t=this.getSelection(!0)),!e){for(let e in Pt)i[e]=null;return i}t||(t=e),t.row<e.row||t.row===e.row&&t.col<e.col?(n=t,s=e):(n=e,s=t),s.row>n.row&&0===s.col&&(s.row--,s.col=this.lines[s.row].length);for(let r in Pt)if("inline"===Pt[r].type&&(e&&e.row===t.row&&this.isInlineFormattingAllowed()?i[r]=!!this.computeEnclosingMarkupNode(e,t,Pt[r].className)||e.col===t.col&&!!this.lines[e.row].substr(0,e.col).match(Pt[r].unset.prePattern)&&!!this.lines[e.row].substr(e.col).match(Pt[r].unset.postPattern):i[r]=null),"line"===Pt[r].type)if(e){let e=this.lineTypes[n.row]===Pt[r].className;for(let t=n.row;t<=s.row;t++)if(this.lineTypes[t]===Pt[r].className!==e){e=null;break}i[r]=e}else i[r]=null;return i}setCommandState(e,t){if(this.isRestoringHistory||this.pushHistory(),"inline"===Pt[e].type){let t=this.getSelection(!0),n=this.getSelection(!1);if(t||(t=n),!t)return;if(t.row!==n.row)return;if(!this.isInlineFormattingAllowed())return;let s=this.computeEnclosingMarkupNode(n,t,Pt[e].className);if(this.clearDirtyFlag(),s){this.lineDirty[n.row]=!0;const i=this.computeColumn(s,0),r=s.textContent.length,l=this.lines[n.row].substr(0,i).replace(Pt[e].unset.prePattern,""),a=this.lines[n.row].substr(i,r),o=this.lines[n.row].substr(i+r).replace(Pt[e].unset.postPattern,"");this.lines[n.row]=l.concat(a,o),t.col=l.length,n.col=t.col+r,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else if(n.col===t.col&&this.lines[n.row].substr(0,n.col).match(Pt[e].unset.prePattern)&&this.lines[n.row].substr(n.col).match(Pt[e].unset.postPattern)){this.lineDirty[n.row]=!0;const s=this.lines[n.row].substr(0,n.col).replace(Pt[e].unset.prePattern,""),i=this.lines[n.row].substr(n.col).replace(Pt[e].unset.postPattern,"");this.lines[n.row]=s.concat(i),n.col=t.col=s.length,this.updateFormatting(),this.setSelection(n,t),this.fireChange()}else{let{startCol:s,endCol:i}=n.col<t.col?{startCol:n.col,endCol:t.col}:{startCol:t.col,endCol:n.col},r=this.lines[n.row].substr(s,i-s).match(Lt.surroundingWhitespace);r&&(s+=r.groups.leading.length,i-=r.groups.trailing.length),n.col=s,t.col=i,this.wrapSelection(Pt[e].set.pre,Pt[e].set.post,n,t)}}else if("line"===Pt[e].type){let n=this.getSelection(!0),s=this.getSelection(!1);if(n||(n=s),!s)return;this.clearDirtyFlag();let i=n.row>s.row?s:n,r=n.row>s.row?n:s;r.row>i.row&&0===r.col&&r.row--;for(let n=i.row;n<=r.row;n++)t&&this.lineTypes[n]!==Pt[e].className&&(this.lines[n]=this.lines[n].replace(Pt[e].set.pattern,Pt[e].set.replacement.replace("$#",(n-i.row+1).toString())),this.lineDirty[n]=!0),t||this.lineTypes[n]!==Pt[e].className||(this.lines[n]=this.lines[n].replace(Pt[e].unset.pattern,Pt[e].unset.replacement),this.lineDirty[n]=!0);this.updateFormatting(),this.setSelection({row:r.row,col:this.lines[r.row].length},{row:i.row,col:0}),this.fireChange()}}listItemMarker(e){const t=Bt.TMUL.regexp.exec(e);if(t)return t[1];const n=Bt.TMOL.regexp.exec(e);return n?n[1]:null}isTaskListItem(e){if(e<0||e>=this.lines.length)return!1;const t=this.lineTypes[e];if("TMUL"!==t&&"TMOL"!==t)return!1;const n=this.listItemMarker(this.lines[e]);return null!==n&&Lt.taskListItem.test(this.lines[e].substr(n.length))}addTaskCheckbox(e){const t=this.listItemMarker(e);if(null!==t){const n=e.substr(t.length);return Lt.taskListItem.test(n)?e:`${t}[ ] ${n}`}return e.replace(Pt.ul.set.pattern,"- [ ] $2")}removeTaskCheckbox(e){const t=this.listItemMarker(e);if(null===t)return e;const n=Lt.taskListItem.exec(e.substr(t.length));return n?`${t}${n[5]}`:e}toggleTaskList(){let e=this.getSelection(!0),t=this.getSelection(!1);if(e||(e=t),!t)return;let n=e.row>t.row?t:e,s=e.row>t.row?e:t;s.row>n.row&&0===s.col&&s.row--;let i=!0;for(let e=n.row;e<=s.row;e++)if(!this.isTaskListItem(e)){i=!1;break}this.isRestoringHistory||this.pushHistory(),this.clearDirtyFlag();for(let e=n.row;e<=s.row;e++){const t=i?this.removeTaskCheckbox(this.lines[e]):this.addTaskCheckbox(this.lines[e]);t!==this.lines[e]&&(this.lines[e]=t,this.lineDirty[e]=!0)}this.updateFormatting(),this.setSelection({row:s.row,col:this.lines[s.row].length},{row:n.row,col:0}),this.fireChange()}isInlineFormattingAllowed(){const e=window.getSelection();if(!e||!e.focusNode||!e.anchorNode)return!1;if(e.isCollapsed&&3===e.focusNode.nodeType&&e.focusOffset===e.focusNode.nodeValue.length){let t;for(t=e.focusNode;t&&null===t.nextSibling;t=t.parentNode);if(t&&t.nextSibling&&t.nextSibling.classList&&t.nextSibling.classList.contains("TMInlineFormatted"))return!0}let t=this.computeCommonAncestor(e.focusNode,e.anchorNode);if(!t)return!1;for(;t&&t!==this.e;){if(t.classList&&(t.classList.contains("TMInlineFormatted")||t.classList.contains("TMBlankLine")))return!0;t=t.parentNode}return!1}toggleCommandState(e){this.lastCommandState||(this.lastCommandState=this.getCommandState()),this.setCommandState(e,!this.lastCommandState[e])}fireDrop(e){for(let t of this.listeners.drop)t({dataTransfer:e})}fireSelection(){let e=this.getSelection(!1),t=this.getSelection(!0);if(this.lastSelection={focus:e,anchor:t},this.listeners.selection&&this.listeners.selection.length){let n=this.getCommandState(e,t);this.lastCommandState?Object.assign(this.lastCommandState,n):this.lastCommandState=Object.assign({},n);for(let n of this.listeners.selection)n({focus:e,anchor:t,commandState:this.lastCommandState})}}}}));
package/lib/TinyMDE.d.ts CHANGED
@@ -46,6 +46,11 @@ export declare class Editor {
46
46
  private hasFocus;
47
47
  private lastSelection;
48
48
  private placeholder;
49
+ private cleanupFns;
50
+ private ownsElement;
51
+ private elementOriginalStyle;
52
+ private textareaOriginalDisplay;
53
+ private destroyed;
49
54
  listeners: {
50
55
  change: EventHandler<ChangeEvent>[];
51
56
  selection: EventHandler<SelectionEvent>[];
@@ -113,6 +118,18 @@ export declare class Editor {
113
118
  paste(text: string, anchor?: Position | null, focus?: Position | null): void;
114
119
  wrapSelection(pre: string, post: string, focus?: Position | null, anchor?: Position | null): void;
115
120
  addEventListener<T extends EventType>(type: T, listener: T extends 'change' ? EventHandler<ChangeEvent> : T extends 'selection' ? EventHandler<SelectionEvent> : T extends 'drop' ? EventHandler<DropEvent> : never): void;
121
+ removeEventListener<T extends EventType>(type: T, listener: T extends 'change' ? EventHandler<ChangeEvent> : T extends 'selection' ? EventHandler<SelectionEvent> : T extends 'drop' ? EventHandler<DropEvent> : never): void;
122
+ private addListener;
123
+ /**
124
+ * Removes all DOM/document listeners registered by this instance (including the
125
+ * `document`-level selectionchange listener, which would otherwise keep the whole editor
126
+ * alive for as long as the page lives). An editor element TinyMDE created itself is removed
127
+ * from the DOM; one passed in by the caller is left in place, emptied and restored to the
128
+ * classes, attributes and inline styles it had before. A linked textarea is shown again.
129
+ * Does not destroy a CommandBar attached to this editor; destroy that separately.
130
+ * Safe to call multiple times.
131
+ */
132
+ destroy(): void;
116
133
  private fireChange;
117
134
  /**
118
135
  * beforeinput handler, exclusively to handle insertParagraph,
package/lib/TinyMDE.js CHANGED
@@ -19,6 +19,11 @@ class Editor {
19
19
  this.mergedInlineGrammar = grammar_1.inlineGrammar;
20
20
  this.hasFocus = true;
21
21
  this.lastSelection = null;
22
+ this.cleanupFns = [];
23
+ this.ownsElement = false;
24
+ this.elementOriginalStyle = null;
25
+ this.textareaOriginalDisplay = null;
26
+ this.destroyed = false;
22
27
  this.listeners = {
23
28
  change: [],
24
29
  selection: [],
@@ -72,6 +77,7 @@ class Editor {
72
77
  element = this.textarea.parentNode;
73
78
  }
74
79
  if (this.textarea) {
80
+ this.textareaOriginalDisplay = this.textarea.style.display;
75
81
  this.textarea.style.display = "none";
76
82
  }
77
83
  this.placeholder = props.placeholder !== undefined
@@ -87,7 +93,7 @@ class Editor {
87
93
  : this.textarea
88
94
  ? this.textarea.value
89
95
  : "# Hello TinyMDE!\nEdit **here**");
90
- this.e.addEventListener("keydown", (e) => this.handleUndoRedoKey(e));
96
+ this.addListener(this.e, "keydown", (e) => this.handleUndoRedoKey(e));
91
97
  }
92
98
  get canUndo() {
93
99
  return this.undoStack.length >= 2;
@@ -165,6 +171,10 @@ class Editor {
165
171
  }
166
172
  else {
167
173
  this.e = document.createElement("div");
174
+ this.ownsElement = true;
175
+ }
176
+ if (!this.ownsElement) {
177
+ this.elementOriginalStyle = this.e.getAttribute("style");
168
178
  }
169
179
  this.e.classList.add("TinyMDE");
170
180
  this.e.contentEditable = "true";
@@ -183,19 +193,19 @@ class Editor {
183
193
  element.appendChild(this.e);
184
194
  }
185
195
  }
186
- this.e.addEventListener("input", (e) => this.handleInputEvent(e));
187
- this.e.addEventListener("beforeinput", (e) => this.handleBeforeInputEvent(e));
188
- this.e.addEventListener("compositionend", (e) => this.handleInputEvent(e));
189
- document.addEventListener("selectionchange", (e) => {
196
+ this.addListener(this.e, "input", (e) => this.handleInputEvent(e));
197
+ this.addListener(this.e, "beforeinput", (e) => this.handleBeforeInputEvent(e));
198
+ this.addListener(this.e, "compositionend", (e) => this.handleInputEvent(e));
199
+ this.addListener(document, "selectionchange", (e) => {
190
200
  if (this.hasFocus) {
191
201
  this.handleSelectionChangeEvent(e);
192
202
  }
193
203
  });
194
- this.e.addEventListener("blur", () => this.hasFocus = false);
195
- this.e.addEventListener("focus", () => this.hasFocus = true);
196
- this.e.addEventListener("paste", (e) => this.handlePaste(e));
197
- this.e.addEventListener("drop", (e) => this.handleDrop(e));
198
- this.e.addEventListener("click", (e) => this.handleClick(e));
204
+ this.addListener(this.e, "blur", () => this.hasFocus = false);
205
+ this.addListener(this.e, "focus", () => this.hasFocus = true);
206
+ this.addListener(this.e, "paste", (e) => this.handlePaste(e));
207
+ this.addListener(this.e, "drop", (e) => this.handleDrop(e));
208
+ this.addListener(this.e, "click", (e) => this.handleClick(e));
199
209
  this.lineElements = this.e.childNodes;
200
210
  }
201
211
  setContent(content) {
@@ -757,6 +767,66 @@ class Editor {
757
767
  this.listeners.drop.push(listener);
758
768
  }
759
769
  }
770
+ removeEventListener(type, listener) {
771
+ if (type.match(grammar_1.editorRegExp.changeEvent)) {
772
+ this.listeners.change = this.listeners.change.filter((l) => l !== listener);
773
+ }
774
+ if (type.match(grammar_1.editorRegExp.selectionEvent)) {
775
+ this.listeners.selection = this.listeners.selection.filter((l) => l !== listener);
776
+ }
777
+ if (type.match(grammar_1.editorRegExp.dropEvent)) {
778
+ this.listeners.drop = this.listeners.drop.filter((l) => l !== listener);
779
+ }
780
+ }
781
+ addListener(target, type, handler) {
782
+ target.addEventListener(type, handler);
783
+ this.cleanupFns.push(() => target.removeEventListener(type, handler));
784
+ }
785
+ /**
786
+ * Removes all DOM/document listeners registered by this instance (including the
787
+ * `document`-level selectionchange listener, which would otherwise keep the whole editor
788
+ * alive for as long as the page lives). An editor element TinyMDE created itself is removed
789
+ * from the DOM; one passed in by the caller is left in place, emptied and restored to the
790
+ * classes, attributes and inline styles it had before. A linked textarea is shown again.
791
+ * Does not destroy a CommandBar attached to this editor; destroy that separately.
792
+ * Safe to call multiple times.
793
+ */
794
+ destroy() {
795
+ var _a;
796
+ if (this.destroyed)
797
+ return;
798
+ this.destroyed = true;
799
+ for (const cleanup of this.cleanupFns)
800
+ cleanup();
801
+ this.cleanupFns = [];
802
+ if (this.e) {
803
+ if (this.ownsElement) {
804
+ if (this.e.parentNode)
805
+ this.e.parentNode.removeChild(this.e);
806
+ }
807
+ else {
808
+ this.e.classList.remove("TinyMDE", "TinyMDE_empty");
809
+ this.e.removeAttribute("contenteditable");
810
+ this.e.removeAttribute("data-placeholder");
811
+ while (this.e.firstChild)
812
+ this.e.removeChild(this.e.firstChild);
813
+ // WebKit reflects an absent style attribute as "" rather than null, so treat
814
+ // both the same and drop the attribute instead of leaving an empty one behind.
815
+ if (this.elementOriginalStyle) {
816
+ this.e.setAttribute("style", this.elementOriginalStyle);
817
+ }
818
+ else {
819
+ this.e.removeAttribute("style");
820
+ }
821
+ }
822
+ }
823
+ if (this.textarea) {
824
+ this.textarea.style.display = (_a = this.textareaOriginalDisplay) !== null && _a !== void 0 ? _a : "";
825
+ }
826
+ this.listeners = { change: [], selection: [], drop: [] };
827
+ this.e = null;
828
+ this.textarea = null;
829
+ }
760
830
  fireChange() {
761
831
  this.updatePlaceholder();
762
832
  if (!this.textarea && !this.listeners.change.length)
@@ -25,11 +25,21 @@ export declare class CommandBar {
25
25
  buttons: Record<string, HTMLDivElement>;
26
26
  state: Record<string, boolean | null>;
27
27
  private hotkeys;
28
+ private cleanupFns;
29
+ private detachEditor;
30
+ private destroyed;
28
31
  constructor(props: CommandBarProps);
29
32
  private createCommandBarElement;
30
33
  private handleClick;
31
34
  setEditor(editor: Editor): void;
32
35
  private handleSelection;
33
36
  private handleKeydown;
37
+ private addListener;
38
+ /**
39
+ * Removes all listeners registered by this instance, including the document-level keydown
40
+ * listener and the selection listener on its editor, and detaches the command bar element.
41
+ * Safe to call multiple times.
42
+ */
43
+ destroy(): void;
34
44
  }
35
45
  export default CommandBar;