A simple directory listing for ZDDC archives — and any directory.
- Pick how you want to browse:
-
+
A two-pane file browser for ZDDC archives — and any directory.
+
Online — when this page is served by zddc-server, the
listing for the current directory loads automatically.
Local — click Add Local Directory to pick any folder
on your computer (Chromium-based browsers).
-
Once loaded: click a folder to expand it, shift-click
- to expand its entire subtree (or collapse it again),
- click column headers to sort. Click any file to open it.
+
Once loaded: click folders to expand, click files to preview them in
+ the right pane. Markdown files open in a full editor with TOC.
+ Switch to Grid mode to bulk-rename ZDDC files
+ spreadsheet-style.
-
+
+
+
+
+
-
-
-
-
-
Name
-
Size
-
Type
-
Modified
-
-
-
-
+
+
+
+
+
+
+
+
+
+ No file selected
+
+
+
+
+
Click a file in the tree to preview it.
+
+
+
+
+
+
+
+ Grid view is loading…
+
@@ -1094,35 +1228,32 @@ body {
What is Browse?
-
Browse is a directory listing for ZDDC archives — and any directory. It works in two modes:
+
Browse is the ZDDC file experience. Two top-level modes:
-
Online
-
When the page is served by zddc-server, the listing for the current
- URL directory loads automatically. Breadcrumbs link to ancestor folders.
-
Local
-
Click Add Local Directory to pick any folder on your
- computer. Local mode requires a Chromium-based browser (File System
- Access API).
+
Browse mode
+
File tree on the left, preview on the right. Click a folder to
+ expand, click a file to preview. Markdown files open in a full editor;
+ PDF, image, ZIP, XLSX, DOCX, TIFF all render inline.
+
Grid mode
+
Spreadsheet view of the current subtree's files for bulk
+ ZDDC renaming. Edit cells directly, copy/paste with Excel,
+ save back to disk.
-
Tree navigation
+
Tree navigation (Browse mode)
Click a folder
-
Toggle expand/collapse on that folder.
-
Double-click a folder
-
Navigate into the folder — it becomes the new root of the
- view. Server mode loads the folder's URL; local mode re-roots
- onto that folder's handle.
+
Expand or collapse it inline.
Shift-click a folder
-
Recursive expand or collapse — applies to the whole subtree.
+
Recursive expand or collapse — the whole subtree.
Click a file
-
Open in the preview popup. Modifier-click (Ctrl/Cmd) or middle-click
- opens in a new tab.
+
Preview it in the right pane.
+
⤴ Pop out
+
Open the current preview in a separate window — useful for a second
+ monitor.
ZIP files
Behave as folders — click to inspect contents inline. JSZip is
bundled, so this works offline.
-
Column headers
-
Click to sort; click again to reverse.
Refresh
Re-fetches the current directory listing — works for both
local (re-enumerates the FS handle) and online (re-fetches the JSON).
@@ -2315,6 +2446,30 @@ X.B(E,Y);return E}return J}())
})(UTIF, pako);
})();
+/*!
+ * @toast-ui/editor
+ * @version 3.2.2 | Fri Feb 17 2023
+ * @author NHN Cloud FE Development Lab
+ * @license MIT
+ */
+!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.toastui=t():(e.toastui=e.toastui||{},e.toastui.Editor=t())}(self,(function(){return function(){var e={368:function(e){
+/*! @license DOMPurify 2.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.3/LICENSE */
+e.exports=function(){"use strict";function e(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1?n-1:0),o=1;o/gm),q=a(/^data-[\-\w.\u00B7-\uFFFF]/),V=a(/^aria-[\-\w]+$/),j=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),$=a(/^(?:\w+script|data):/i),_=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function W(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:J(),t=function(e){return K(e)};if(t.version="2.3.3",t.removed=[],!e||!e.document||9!==e.document.nodeType)return t.isSupported=!1,t;var n=e.document,r=e.document,o=e.DocumentFragment,i=e.HTMLTemplateElement,a=e.Node,l=e.Element,c=e.NodeFilter,u=e.NamedNodeMap,d=void 0===u?e.NamedNodeMap||e.MozNamedAttrMap:u,x=e.Text,C=e.Comment,Z=e.DOMParser,X=e.trustedTypes,Q=l.prototype,Y=S(Q,"cloneNode"),ee=S(Q,"nextSibling"),te=S(Q,"childNodes"),ne=S(Q,"parentNode");if("function"==typeof i){var re=r.createElement("template");re.content&&re.content.ownerDocument&&(r=re.content.ownerDocument)}var oe=G(X,n),ie=oe&&Fe?oe.createHTML(""):"",se=r,ae=se.implementation,le=se.createNodeIterator,ce=se.createDocumentFragment,ue=se.getElementsByTagName,de=n.importNode,pe={};try{pe=M(r).documentMode?r.documentMode:{}}catch(e){}var he={};t.isSupported="function"==typeof ne&&ae&&void 0!==ae.createHTMLDocument&&9!==pe;var fe=H,me=z,ge=q,ve=V,ye=$,be=_,we=j,ke=null,xe=T({},[].concat(W(E),W(N),W(O),W(A),W(I))),Ce=null,Te=T({},[].concat(W(R),W(P),W(B),W(F))),Me=null,Se=null,Ee=!0,Ne=!0,Oe=!1,De=!1,Ae=!1,Le=!1,Ie=!1,Re=!1,Pe=!1,Be=!0,Fe=!1,He=!0,ze=!0,qe=!1,Ve={},je=null,$e=T({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),_e=null,Ue=T({},["audio","video","img","source","image","track"]),We=null,Je=T({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ge="http://www.w3.org/1998/Math/MathML",Ke="http://www.w3.org/2000/svg",Ze="http://www.w3.org/1999/xhtml",Xe=Ze,Qe=!1,Ye=void 0,et=["application/xhtml+xml","text/html"],tt="text/html",nt=void 0,rt=null,ot=r.createElement("form"),it=function(e){rt&&rt===e||(e&&"object"===(void 0===e?"undefined":U(e))||(e={}),e=M(e),ke="ALLOWED_TAGS"in e?T({},e.ALLOWED_TAGS):xe,Ce="ALLOWED_ATTR"in e?T({},e.ALLOWED_ATTR):Te,We="ADD_URI_SAFE_ATTR"in e?T(M(Je),e.ADD_URI_SAFE_ATTR):Je,_e="ADD_DATA_URI_TAGS"in e?T(M(Ue),e.ADD_DATA_URI_TAGS):Ue,je="FORBID_CONTENTS"in e?T({},e.FORBID_CONTENTS):$e,Me="FORBID_TAGS"in e?T({},e.FORBID_TAGS):{},Se="FORBID_ATTR"in e?T({},e.FORBID_ATTR):{},Ve="USE_PROFILES"in e&&e.USE_PROFILES,Ee=!1!==e.ALLOW_ARIA_ATTR,Ne=!1!==e.ALLOW_DATA_ATTR,Oe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,De=e.SAFE_FOR_TEMPLATES||!1,Ae=e.WHOLE_DOCUMENT||!1,Re=e.RETURN_DOM||!1,Pe=e.RETURN_DOM_FRAGMENT||!1,Be=!1!==e.RETURN_DOM_IMPORT,Fe=e.RETURN_TRUSTED_TYPE||!1,Ie=e.FORCE_BODY||!1,He=!1!==e.SANITIZE_DOM,ze=!1!==e.KEEP_CONTENT,qe=e.IN_PLACE||!1,we=e.ALLOWED_URI_REGEXP||we,Xe=e.NAMESPACE||Ze,Ye=Ye=-1===et.indexOf(e.PARSER_MEDIA_TYPE)?tt:e.PARSER_MEDIA_TYPE,nt="application/xhtml+xml"===Ye?function(e){return e}:m,De&&(Ne=!1),Pe&&(Re=!0),Ve&&(ke=T({},[].concat(W(I))),Ce=[],!0===Ve.html&&(T(ke,E),T(Ce,R)),!0===Ve.svg&&(T(ke,N),T(Ce,P),T(Ce,F)),!0===Ve.svgFilters&&(T(ke,O),T(Ce,P),T(Ce,F)),!0===Ve.mathMl&&(T(ke,A),T(Ce,B),T(Ce,F))),e.ADD_TAGS&&(ke===xe&&(ke=M(ke)),T(ke,e.ADD_TAGS)),e.ADD_ATTR&&(Ce===Te&&(Ce=M(Ce)),T(Ce,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&T(We,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(je===$e&&(je=M(je)),T(je,e.FORBID_CONTENTS)),ze&&(ke["#text"]=!0),Ae&&T(ke,["html","head","body"]),ke.table&&(T(ke,["tbody"]),delete Me.tbody),s&&s(e),rt=e)},st=T({},["mi","mo","mn","ms","mtext"]),at=T({},["foreignobject","desc","title","annotation-xml"]),lt=T({},N);T(lt,O),T(lt,D);var ct=T({},A);T(ct,L);var ut=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:Ze,tagName:"template"});var n=m(e.tagName),r=m(t.tagName);if(e.namespaceURI===Ke)return t.namespaceURI===Ze?"svg"===n:t.namespaceURI===Ge?"svg"===n&&("annotation-xml"===r||st[r]):Boolean(lt[n]);if(e.namespaceURI===Ge)return t.namespaceURI===Ze?"math"===n:t.namespaceURI===Ke?"math"===n&&at[r]:Boolean(ct[n]);if(e.namespaceURI===Ze){if(t.namespaceURI===Ke&&!at[r])return!1;if(t.namespaceURI===Ge&&!st[r])return!1;var o=T({},["title","style","font","a","script"]);return!ct[n]&&(o[n]||!lt[n])}return!1},dt=function(e){f(t.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ie}catch(t){e.remove()}}},pt=function(e,n){try{f(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch(e){f(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),"is"===e&&!Ce[e])if(Re||Pe)try{dt(n)}catch(e){}else try{n.setAttribute(e,"")}catch(e){}},ht=function(e){var t=void 0,n=void 0;if(Ie)e=""+e;else{var o=g(e,/^[\r\n\t ]+/);n=o&&o[0]}"application/xhtml+xml"===Ye&&(e=''+e+"");var i=oe?oe.createHTML(e):e;if(Xe===Ze)try{t=(new Z).parseFromString(i,Ye)}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(Xe,"template",null);try{t.documentElement.innerHTML=Qe?"":i}catch(e){}}var s=t.body||t.documentElement;return e&&n&&s.insertBefore(r.createTextNode(n),s.childNodes[0]||null),Xe===Ze?ue.call(t,Ae?"html":"body")[0]:Ae?t.documentElement:s},ft=function(e){return le.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT,null,!1)},mt=function(e){return!(e instanceof x||e instanceof C||"string"==typeof e.nodeName&&"string"==typeof e.textContent&&"function"==typeof e.removeChild&&e.attributes instanceof d&&"function"==typeof e.removeAttribute&&"function"==typeof e.setAttribute&&"string"==typeof e.namespaceURI&&"function"==typeof e.insertBefore)},gt=function(e){return"object"===(void 0===a?"undefined":U(a))?e instanceof a:e&&"object"===(void 0===e?"undefined":U(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},vt=function(e,n,r){he[e]&&p(he[e],(function(e){e.call(t,n,r,rt)}))},yt=function(e){var n=void 0;if(vt("beforeSanitizeElements",e,null),mt(e))return dt(e),!0;if(g(e.nodeName,/[\u0080-\uFFFF]/))return dt(e),!0;var r=nt(e.nodeName);if(vt("uponSanitizeElement",e,{tagName:r,allowedTags:ke}),!gt(e.firstElementChild)&&(!gt(e.content)||!gt(e.content.firstElementChild))&&w(/<[/\w]/g,e.innerHTML)&&w(/<[/\w]/g,e.textContent))return dt(e),!0;if("select"===r&&w(/=0;--s)o.insertBefore(Y(i[s],!0),ee(e))}return dt(e),!0}return e instanceof l&&!ut(e)?(dt(e),!0):"noscript"!==r&&"noembed"!==r||!w(/<\/no(script|embed)/i,e.innerHTML)?(De&&3===e.nodeType&&(n=e.textContent,n=v(n,fe," "),n=v(n,me," "),e.textContent!==n&&(f(t.removed,{element:e.cloneNode()}),e.textContent=n)),vt("afterSanitizeElements",e,null),!1):(dt(e),!0)},bt=function(e,t,n){if(He&&("id"===t||"name"===t)&&(n in r||n in ot))return!1;if(Ne&&!Se[t]&&w(ge,t));else if(Ee&&w(ve,t));else{if(!Ce[t]||Se[t])return!1;if(We[t]);else if(w(we,v(n,be,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==y(n,"data:")||!_e[e])if(Oe&&!w(ye,v(n,be,"")));else if(n)return!1}return!0},wt=function(e){var n=void 0,r=void 0,o=void 0,i=void 0;vt("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ce};for(i=s.length;i--;){var l=n=s[i],c=l.name,u=l.namespaceURI;if(r=b(n.value),o=nt(c),a.attrName=o,a.attrValue=r,a.keepAttr=!0,a.forceKeepAttr=void 0,vt("uponSanitizeAttribute",e,a),r=a.attrValue,!a.forceKeepAttr&&(pt(c,e),a.keepAttr))if(w(/\/>/i,r))pt(c,e);else{De&&(r=v(r,fe," "),r=v(r,me," "));var d=nt(e.nodeName);if(bt(d,o,r))try{u?e.setAttributeNS(u,c,r):e.setAttribute(c,r),h(t.removed)}catch(e){}}}vt("afterSanitizeAttributes",e,null)}},kt=function e(t){var n=void 0,r=ft(t);for(vt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)vt("uponSanitizeShadowNode",n,null),yt(n)||(n.content instanceof o&&e(n.content),wt(n));vt("afterSanitizeShadowDOM",t,null)};return t.sanitize=function(r,i){var s=void 0,l=void 0,c=void 0,u=void 0,d=void 0;if((Qe=!r)&&(r="\x3c!--\x3e"),"string"!=typeof r&&!gt(r)){if("function"!=typeof r.toString)throw k("toString is not a function");if("string"!=typeof(r=r.toString()))throw k("dirty is not a string, aborting")}if(!t.isSupported){if("object"===U(e.toStaticHTML)||"function"==typeof e.toStaticHTML){if("string"==typeof r)return e.toStaticHTML(r);if(gt(r))return e.toStaticHTML(r.outerHTML)}return r}if(Le||it(i),t.removed=[],"string"==typeof r&&(qe=!1),qe);else if(r instanceof a)1===(l=(s=ht("\x3c!----\x3e")).ownerDocument.importNode(r,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?s=l:s.appendChild(l);else{if(!Re&&!De&&!Ae&&-1===r.indexOf("<"))return oe&&Fe?oe.createHTML(r):r;if(!(s=ht(r)))return Re?null:ie}s&&Ie&&dt(s.firstChild);for(var p=ft(qe?r:s);c=p.nextNode();)3===c.nodeType&&c===u||yt(c)||(c.content instanceof o&&kt(c.content),wt(c),u=c);if(u=null,qe)return r;if(Re){if(Pe)for(d=ce.call(s.ownerDocument);s.firstChild;)d.appendChild(s.firstChild);else d=s;return Be&&(d=de.call(n,d,!0)),d}var h=Ae?s.outerHTML:s.innerHTML;return De&&(h=v(h,fe," "),h=v(h,me," ")),oe&&Fe?oe.createHTML(h):h},t.setConfig=function(e){it(e),Le=!0},t.clearConfig=function(){rt=null,Le=!1},t.isValidAttribute=function(e,t,n){rt||it({});var r=nt(e),o=nt(t);return bt(r,o,n)},t.addHook=function(e,t){"function"==typeof t&&(he[e]=he[e]||[],f(he[e],t))},t.removeHook=function(e){he[e]&&h(he[e])},t.removeHooks=function(e){he[e]&&(he[e]=[])},t.removeAllHooks=function(){he={}},t}return K()}()},928:function(e,t,n){"use strict";var r=n(322);e.exports=function(e,t,n){var o,i;if(n=n||0,!r(t))return-1;if(Array.prototype.indexOf)return Array.prototype.indexOf.call(t,e,n);for(i=t.length,o=n;n>=0&&o-1)}},471:function(e,t,n){"use strict";var r=n(928),o=n(354),i=Element.prototype,s=i.matches||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||function(e){var t=this.document||this.ownerDocument;return r(this,o(t.querySelectorAll(e)))>-1};e.exports=function(e,t){return s.call(e,t)}},462:function(e,t,n){"use strict";var r=n(893),o=n(928),i=n(902),s=n(24);e.exports=function(e){var t,n,a=Array.prototype.slice.call(arguments,1),l=e.classList;l?r(a,(function(e){l.remove(e)})):(t=i(e).split(/\s+/),n=[],r(t,(function(e){o(e,a)<0&&n.push(e)})),s(e,n))}},969:function(e){"use strict";e.exports=function(e,t){var n,r,o,i,s=Object.prototype.hasOwnProperty;for(o=1,i=arguments.length;o6048e5}(s)||(window.localStorage.setItem(i,(new Date).getTime()),setTimeout((function(){"interactive"!==document.readyState&&"complete"!==document.readyState||o("https://www.google-analytics.com/collect",{v:1,t:"event",tid:t,cid:n,dp:n,dh:e,el:e,ec:"use"})}),1e3)))}},516:function(e){"use strict";e.exports=function(e,t){var n,r;return t=t||0,function(){r=Array.prototype.slice.call(arguments),window.clearTimeout(n),n=window.setTimeout((function(){e.apply(null,r)}),t)}}},423:function(e,t,n){"use strict";var r=n(516);e.exports=function(e,t){var n,o,i,s,a=!0,l=function(t){e.apply(null,t),n=null};function c(){if(s=Array.prototype.slice.call(arguments),a)return l(s),void(a=!1);i=Number(new Date),n=n||i,o(s),i-n>=t&&l(s)}return o=r(l,t=t||0),c.reset=function(){a=!0,n=null},c}},322:function(e){"use strict";e.exports=function(e){return e instanceof Array}},326:function(e){"use strict";e.exports=function(e){return"boolean"==typeof e||e instanceof Boolean}},65:function(e,t,n){"use strict";var r=n(929),o=n(934);e.exports=function(e){return!r(e)&&!o(e)}},404:function(e,t,n){"use strict";var r=n(790);e.exports=function(e){return!r(e)}},294:function(e){"use strict";e.exports=function(e){return e instanceof Function}},934:function(e){"use strict";e.exports=function(e){return null===e}},321:function(e){"use strict";e.exports=function(e){return"number"==typeof e||e instanceof Number}},73:function(e){"use strict";e.exports=function(e){return e===Object(e)}},758:function(e){"use strict";e.exports=function(e){return"string"==typeof e||e instanceof String}},790:function(e,t,n){"use strict";var r=n(65);e.exports=function(e){return r(e)&&!1!==e}},929:function(e){"use strict";e.exports=function(e){return void 0===e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var r={};return function(){"use strict";n.d(r,{default:function(){return vy}});
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+***************************************************************************** */
+var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var o=function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n>1}},a.from=function(e){if(e instanceof a)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new a(t)};var l=a;function c(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let e=0;o.text[e]==i.text[e];e++)n++;return n}if(o.content.size||i.content.size){let e=c(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function u(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=e.child(--o),a=t.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;ee&&!1!==n(a,r+s,o||null,i)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,e-o),Math.min(a.content.size,t-o),n,r+o)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,((s,a)=>{s.isText?(o+=s.text.slice(Math.max(e,a)-a,t-a),i=!n):s.isLeaf?(r?o+="function"==typeof r?r(s):r:s.type.spec.leafText&&(o+=s.type.spec.leafText(s)),i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);oe)for(let o=0,i=0;ie&&((it)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),r+=s.nodeSize),i=a}return new d(n,r)}cutByIndex(e,t){return e==t?d.empty:0==e&&t==this.content.length?this:new d(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new d(r,o)}addToStart(e){return new d([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new d(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=r+this.child(n).nodeSize;if(o>=e)return o==e||t>0?h(n+1,o):h(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return d.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new d(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return d.empty;let t,n=0;for(let r=0;rthis.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank)),t}}m.none=[];class g extends Error{}class v{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=b(this.content,e+this.openStart,t);return n&&new v(n,this.openStart,this.openEnd)}removeBetween(e,t){return new v(y(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return v.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new v(d.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new v(e,n,r)}}function y(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:a}=e.findIndex(n);if(o==t||i.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(y(i.content,t-o-1,n-o-1)))}function b(e,t,n,r){let{index:o,offset:i}=e.findIndex(t),s=e.maybeChild(o);if(i==t||s.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=b(s.content,t-i-1,n);return a&&e.replaceChild(o,s.copy(a))}function w(e,t,n){if(n.openStart>e.depth)throw new g("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new g("Inconsistent open depths");return k(e,t,n,0)}function k(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r=0;e--)r=t.node(e).copy(d.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return S(i,E(e,o,s,t,r))}{let r=e.parent,o=r.content;return S(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return S(i,N(e,t,r))}function x(e,t){if(!t.type.compatibleContent(e.type))throw new g("Cannot join "+t.type.name+" onto "+e.type.name)}function C(e,t,n){let r=e.node(n);return x(r,t.node(n)),r}function T(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function M(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(T(e.nodeAfter,r),i++));for(let e=i;eo&&C(e,t,o+1),s=r.depth>o&&C(n,r,o+1),a=[];return M(null,e,o,a),i&&s&&t.index(o)==n.index(o)?(x(i,s),T(S(i,E(e,t,n,r,o+1)),a)):(i&&T(S(i,N(e,t,o+1)),a),M(t,n,o,a),s&&T(S(s,N(n,r,o+1)),a)),M(r,null,o,a),new d(a)}function N(e,t,n){let r=[];if(M(null,e,n,r),e.depth>n){T(S(C(e,t,n+1),N(e,t,n+1)),r)}return M(t,null,n,r),new d(r)}v.empty=new v(d.empty,0,0);class O{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new I(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new O(t,n,o)}static resolveCached(e,t){for(let n=0;ne&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),F(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=d.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;ee.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=d.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}P.prototype.text=void 0;class B extends P{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):F(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new B(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new B(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function F(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class H{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new z(e,t);if(null==n.next)return H.empty;let r=q(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return n(W(e,0));function n(r){let o=[];r.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)}))}))}));let i=t[r.join(",")]=new H(r.indexOf(e.length-1)>-1);for(let e=0;ee.to=t))}function i(e,t){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(i(n,t))),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return r(t,s),o(i(e.expr,s),s),[r(s)]}if("plus"==e.type){let s=n();return o(i(e.expr,t),s),o(i(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;te.createAndFill())));for(let e=0;e=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n"+e.indexOf(t.next[n].next);return r})).join("\n")}}H.empty=new H(!0);class z{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function q(e){let t=[];do{t.push(V(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function V(e){let t=[];do{t.push(j(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function j(e){let t=function(e){if(e.eat("(")){let t=q(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.groups.indexOf(t)>-1&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=_(e,t)}return t}function $(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function _(e,t){let n=$(e),r=n;return e.eat(",")&&(r="}"!=e.next?$(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function U(e,t){return t-e}function W(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;tn[e]=new Z(e,t,r)));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class X{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Q{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=K(r.attrs),this.excluded=null;let o=J(this.attrs);this.instance=o?new m(this,o):null}create(e=null){return!e&&this.instance?this.instance:new m(this,G(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach(((e,o)=>n[e]=new Q(e,r++,t,o))),n}removeFromSet(e){for(var t=0;t-1}}class Y{constructor(e){this.cached=Object.create(null),this.spec={nodes:l.from(e.nodes),marks:l.from(e.marks||{}),topNode:e.topNode},this.nodes=Z.compile(this.spec.nodes,this),this.marks=Q.compile(this.spec.marks,this);let t=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let n=this.nodes[e],r=n.spec.content||"",o=n.spec.marks;n.contentMatch=t[r]||(t[r]=H.parse(r,this.nodes)),n.inlineContent=n.contentMatch.inlineContent,n.markSet="_"==o?null:o?ee(this,o.split(" ")):""!=o&&n.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:ee(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Z))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new B(n,n.defaultAttrs,e,m.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return P.fromJSON(this,e)}markFromJSON(e){return m.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function ee(e,t){let n=[];for(let r=0;r-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class te{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((e=>{e.tag?this.tags.push(e):e.style&&this.styles.push(e)})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new ae(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new ae(this,t,!0);return n.addAll(e,t.from,t.to),v.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r{n(e=ce(e)),e.mark=t}))}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach((e=>{n(e=ce(e)),e.node=t}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new te(e,te.schemaRules(e)))}}const ne={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},re={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},oe={ol:!0,ul:!0};function ie(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class se{constructor(e,t,n,r,o,i,s){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=m.none,this.stashMarks=[],this.match=i||(4&s?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(d.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=d.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(d.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;tthis.insertNode(e)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}r&&this.sync(s)&&this.open--,i&&this.removePendingMark(i,s)}addAll(e,t,n){let r=t||0;for(let o=t?e.childNodes[t]:e.firstChild,i=null==n?null:e.childNodes[n];o!=i;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o);this.findAtPoint(e,r)}findPlace(e){let t,n;for(let r=this.open;r>=0;r--){let o=this.nodes[r],i=o.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,n=o,!i.length))break;if(o.solid)break}if(!t)return!1;this.sync(n);for(let e=0;ethis.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=a&&-1==e.groups.indexOf(a))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}addPendingMark(e){let t=function(e,t){for(let n=0;n=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);let t=r.popFromStashMark(e);t&&r.type&&r.type.allowsMarkType(t.type)&&(r.activeMarks=t.addToSet(r.activeMarks))}if(r==t)break}}}function le(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ce(e){let t={};for(let n in e)t[n]=e[n];return t}function ue(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n{if(o.length||e.marks.length){let n=0,i=0;for(;n=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&de.renderSpec(he(n),r(e,t))}static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,o=t[0],i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let s=n?e.createElementNS(n,o):e.createElement(o),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let e in a)if(null!=a[e]){let t=e.indexOf(" ");t>0?s.setAttributeNS(e.slice(0,t),e.slice(t+1),a[e]):s.setAttribute(e,a[e])}}for(let o=l;ol)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{let{dom:t,contentDOM:o}=de.renderSpec(e,i,n);if(s.appendChild(t),o){if(r)throw new RangeError("Multiple content holes");r=o}}}return{dom:s,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new de(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=pe(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return pe(e.marks)}}function pe(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function he(e){return e.document||window.document}var fe=n(956),me=n.n(fe),ge=n(969),ve=n.n(ge),ye=n(522),be=n.n(ye),we=n(204),ke=n.n(we),xe=n(462),Ce=n.n(xe),Te=n(758),Me=n.n(Te),Se=n(321),Ee=n.n(Se),Ne=n(929),Oe=n.n(Ne),De=n(934),Ae=n.n(De),Le=n(391),Ie=n.n(Le),Re=(/Mac/.test(navigator.platform),/[\u0020]+/g),Pe=/[>(){}[\]+-.!#|]/g,Be=/<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>||<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g,Fe=/\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g,He=/[*_~`]/g,ze=/!\[.*\]\(.*\)/g,qe=/[[\]]/g,Ve=/(?:^|[^\\])\\(?!\\)/g,je=new RegExp('[&<>"]',"g");function $e(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";default:return e}}function _e(e){return je.test(e)?e.replace(je,$e):e}function Ue(e,t){return-1!==e.indexOf(t)}var We=["rel","target","hreflang","type"],Je={codeblock:/(^ {4}[^\n]+\n*)+/,thematicBreak:/^ *((\* *){3,}|(- *){3,} *|(_ *){3,}) */,atxHeading:/^(#{1,6}) +[\s\S]+/,seTextheading:/^([^\n]+)\n *(=|-){2,} */,blockquote:/^( *>[^\n]+.*)+/,list:/^ *(\*+|-+|\d+\.) [\s\S]+/,def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? */,link:/!?\[.*\]\(.*\)/,reflink:/!?\[.*\]\s*\[([^\]]*)\]/,verticalBar:/\u007C/,fencedCodeblock:/^((`|~){3,})/};function Ge(e){if(!e)return null;var t={};return We.forEach((function(n){Oe()(e[n])||(t[n]=e[n])})),t}function Ke(e,t){for(var n="",r=0;re[0]&&nt?[t,e]:[e,t]}const at=Math.pow(2,16);function lt(e,t){return e+t*at}function ct(e){return 65535&e}class ut{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class dt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&dt.empty)return dt.empty}recover(e){let t=0,n=ct(e);if(!this.inverted)for(let e=0;ee)break;let l=this.ranges[s+o],c=this.ranges[s+i],u=a+l;if(e<=u){let o=a+r+((l?e==a?-1:e==u?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?a:u)?null:lt(s/3,e-a),d=e==a?2:e==u?1:4;return(t<0?e!=a:e!=u)&&(d|=8),new ut(o,d,i)}r+=c-l}return n?e+r:new ut(e+r,0,null)}touches(e,t){let n=0,r=ct(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;te)break;let a=this.ranges[t+o];if(e<=s+a&&t==3*r)return!0;n+=this.ranges[t+i]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new pt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&te.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),r),t.openStart,t.openEnd);return mt.fromReplace(e,this.from,this.to,o)}invert(){return new yt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new vt(t.pos,n.pos,this.mark)}merge(e){return e instanceof vt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new vt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new vt(t.from,t.to,e.markFromJSON(t.mark))}}ft.jsonID("addMark",vt);class yt extends ft{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new v(gt(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return mt.fromReplace(e,this.from,this.to,n)}invert(){return new vt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new yt(t.pos,n.pos,this.mark)}merge(e){return e instanceof yt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new yt(t.from,t.to,e.markFromJSON(t.mark))}}ft.jsonID("removeMark",yt);class bt extends ft{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&kt(e,this.from,this.to)?mt.fail("Structure replace would overwrite content"):mt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new dt([this.from,this.to-this.from,this.slice.size])}invert(e){return new bt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new bt(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof bt)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?v.empty:new v(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new bt(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?v.empty:new v(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new bt(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new bt(t.from,t.to,v.fromJSON(e,t.slice),!!t.structure)}}ft.jsonID("replace",bt);class wt extends ft{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(kt(e,this.from,this.gapFrom)||kt(e,this.gapTo,this.to)))return mt.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return mt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?mt.fromReplace(e,this.from,this.to,n):mt.fail("Content does not fit in gap")}getMap(){return new dt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new wt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=e.map(this.gapFrom,-1),o=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||rn.pos?null:new wt(t.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new wt(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}}function kt(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function xt(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Ct(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(ni;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=r&&r[t]||n;if(a!=n&&(s=s.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function St(e,t){let n=e.resolve(t),r=n.index();return Et(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Et(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}function Nt(e,t,n=t,r=v.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Ot(o,i,r)?new bt(t,n,r):new Dt(o,i,r).fit()}function Ot(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}ft.jsonID("replaceAround",wt);class Dt{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=d.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=d.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let a=new v(o,i,s);return e>-1?new wt(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new bt(n.pos,r.pos,a):null}findFittable(){for(let e=1;e<=2;e++)for(let t=this.unplaced.openStart;t>=0;t--){let n,r=null;t?(r=It(this.unplaced.content,t-1).firstChild,n=r.content):n=this.unplaced.content;let o=n.firstChild;for(let n=this.depth;n>=0;n--){let i,{type:s,match:a}=this.frontier[n],l=null;if(1==e&&(o?a.matchType(o.type)||(l=a.fillBefore(d.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:t,frontierDepth:n,parent:r,inject:l};if(2==e&&o&&(i=a.findWrapping(o.type)))return{sliceDepth:t,frontierDepth:n,parent:r,wrap:i};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=It(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new v(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=It(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new v(At(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new v(At(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e1||0==a||e.content.size)&&(u=t,c.push(Rt(e.mark(p.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?h:-1)))}let f=l==s.childCount;f||(h=-1),this.placed=Lt(this.placed,t,d.from(c)),this.frontier[t].match=u,f&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t=0;n--){let{match:t,type:r}=this.frontier[n],o=Pt(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Lt(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Lt(this.placed,this.depth,d.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(d.empty,!0);e.childCount&&(this.placed=Lt(this.placed,this.frontier.length,e))}}function At(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(At(e.firstChild.content,t-1,n)))}function Lt(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Lt(e.lastChild.content,t-1,n)))}function It(e,t){for(let n=0;n1&&(r=r.replaceChild(0,Rt(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(d.empty,!0)))),e.copy(r)}function Pt(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(let r=n;rr){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(d.empty,!0))}return e}function Ht(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(ot.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}let zt=class extends Error{};zt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(zt.prototype=Object.create(Error.prototype)).constructor=zt,zt.prototype.name="TransformError";const qt=Object.create(null);class Vt{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new jt(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let o=t<0?Xt(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Xt(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Kt(e.node(0))}static atStart(e){return Xt(e,e,0,0,1)||new Kt(e)}static atEnd(e){return Xt(e,e,e.content.size,e.childCount,-1)||new Kt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=qt[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in qt)throw new RangeError("Duplicate use of selection JSON ID "+e);return qt[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Ut.between(this.$anchor,this.$head).getBookmark()}}Vt.prototype.visible=!0;class jt{constructor(e,t){this.$from=e,this.$to=t}}let $t=!1;function _t(e){$t||e.parent.inlineContent||($t=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Ut extends Vt{constructor(e,t=e){_t(e),_t(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return Vt.near(n);let r=e.resolve(t.map(this.anchor));return new Ut(r.parent.inlineContent?r:n,n)}replace(e,t=v.empty){if(super.replace(e,t),t==v.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Ut&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Wt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ut(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=Vt.findFrom(t,n,!0)||Vt.findFrom(t,-n,!0);if(!e)return Vt.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(Vt.findFrom(e,-n,!0)||Vt.findFrom(e,n,!0)).$anchor).posnew Kt(e)};function Xt(e,t,n,r,o,i=!1){if(t.inlineContent)return Ut.create(e,n);for(let s=r-(o>0?0:1);o>0?s=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&Jt.isSelectable(r))return Jt.create(e,n-(o<0?r.nodeSize:0))}else{let t=Xt(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function Qt(e,t,n){let r=e.steps.length-1;if(r{null==o&&(o=r)})),e.setSelection(Vt.near(e.doc.resolve(o),n)))}class Yt extends class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new pt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new zt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=v.empty){let r=Nt(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new v(d.from(n),0,0))}delete(e,t){return this.replace(e,t,v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Ot(o,i,r))return e.step(new bt(t,n,r));let s=Ht(o,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:o.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=c[e].type,n=Bt(t);if(n&&o.node(l).type!=t)u=e;else if(n||!t.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+u+1)%(r.openStart+1),d=c[a];if(d)for(let t=0;t=0&&(e.replace(t,n,r),!(e.steps.length>d));a--){let e=s[a];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i)return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),a=o.after(i+1),l=s,c=a,u=d.empty,p=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=d.from(r.node(e).copy(u)),p++):l--;let h=d.empty,f=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=d.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new wt(o,i,o,i,new v(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{if(t.isTextblock&&!t.hasMarkup(r,o)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){e.clearIncompatible(e.mapping.slice(i).map(n,1),r);let s=e.mapping.slice(i),a=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new wt(a,l,a+1,l-1,new v(d.from(r.create(o,null,t.marks)),0,0),1,!0)),!1}}))}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r=[]){return function(e,t,n,r,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new wt(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new v(d.from(s),0,0),1,!0))}(this,e,t,n,r),this}split(e,t=1,n){return function(e,t,n=1,r){let o=e.doc.resolve(t),i=d.empty,s=d.empty;for(let e=o.depth,t=o.depth-n,a=n-1;e>t;e--,a--){i=d.from(o.node(e).copy(i));let t=r&&r[a];s=d.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new bt(t,t,new v(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],a=[];e.doc.nodesBetween(t,n,((e,l,c)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),d=Math.min(l+e.nodeSize,n),p=r.addToSet(u);for(let e=0;ee.step(t))),a.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let o=[],i=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let a=null;if(r instanceof Q){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;ee.step(new yt(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return function(e,t,n,r=n.contentMatch){let o=e.doc.nodeAt(t),i=[],s=t+1;for(let t=0;t=0;t--)e.step(i[t])}(this,e,t,n),this}}{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return m.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||m.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(Vt.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function en(e,t){return t&&e?e.bind(t):e}class tn{constructor(e,t,n){this.name=e,this.init=en(t.init,n),this.apply=en(t.apply,n)}}const nn=[new tn("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new tn("selection",{init:(e,t)=>e.selection||Vt.atStart(t.doc),apply:e=>e.selection}),new tn("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new tn("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class rn{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=nn.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new tn(e.key,e.spec.state,e))}))}}class on{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new rn(e.schema,e.plugins),o=new on(r);return r.fields.forEach((r=>{if("doc"==r.name)o.doc=P.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=Vt.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=a.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}})),o}}function sn(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=sn(o,t,{})),n[r]=o}return n}class an{constructor(e){this.spec=e,this.props={},e.props&&sn(e.props,this,this.props),this.key=e.key?e.key.key:cn("plugin")}getState(e){return e[this.key]}}const ln=Object.create(null);function cn(e){return e in ln?e+"$"+ ++ln[e]:(ln[e]=0,e+"$")}class un{constructor(e="key"){this.key=cn(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const dn="undefined"!=typeof navigator?navigator:null,pn="undefined"!=typeof document?document:null,hn=dn&&dn.userAgent||"",fn=/Edge\/(\d+)/.exec(hn),mn=/MSIE \d/.exec(hn),gn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(hn),vn=!!(mn||gn||fn),yn=mn?document.documentMode:gn?+gn[1]:fn?+fn[1]:0,bn=!vn&&/gecko\/(\d+)/i.test(hn);bn&&(/Firefox\/(\d+)/.exec(hn)||[0,0])[1];const wn=!vn&&/Chrome\/(\d+)/.exec(hn),kn=!!wn,xn=wn?+wn[1]:0,Cn=!vn&&!!dn&&/Apple Computer/.test(dn.vendor),Tn=Cn&&(/Mobile\/\w+/.test(hn)||!!dn&&dn.maxTouchPoints>2),Mn=Tn||!!dn&&/Mac/.test(dn.platform),Sn=/Android \d/.test(hn),En=!!pn&&"webkitFontSmoothing"in pn.documentElement.style,Nn=En?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,On=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Dn=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let An=null;const Ln=function(e,t,n){let r=An||(An=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},In=function(e,t,n,r){return n&&(Pn(e,t,n,r,-1)||Pn(e,t,n,r,1))},Rn=/^(img|br|input|textarea|hr)$/i;function Pn(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Bn(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Fn(e)||Rn.test(e.nodeName)||"false"==e.contentEditable)return!1;t=On(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?Bn(e):0}}}function Bn(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Fn(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Hn=function(e){let t=e.isCollapsed;return t&&kn&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t};function zn(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function qn(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Vn(e,t){return"number"==typeof e?e:e[t]}function jn(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function $n(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;s=Dn(s)){if(1!=s.nodeType)continue;let e=s,n=e==i.body,a=n?qn(i):jn(e),l=0,c=0;if(t.topa.bottom-Vn(r,"bottom")&&(c=t.bottom-a.bottom+Vn(o,"bottom")),t.lefta.right-Vn(r,"right")&&(l=t.right-a.right+Vn(o,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}if(n)break}}function _n(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Dn(r));return t}function Un(e,t){for(let n=0;n=a){s=Math.max(d.bottom,s),a=Math.min(d.top,a);let e=d.left>t.left?d.left-t.left:d.right=(d.left+d.right)/2?1:0));continue}}!n&&(t.left>=d.right&&t.top>=d.top||t.left>=d.left&&t.top>=d.bottom)&&(i=c+1)}}return n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let o=0;o=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:e,offset:i}:Jn(n,r)}function Gn(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Kn(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&o++}n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?i=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(i=function(e,t,n,r){let o=-1;for(let n=t;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(t.node.isBlock&&t.parent){let e=t.dom.getBoundingClientRect();if(e.left>r.left||e.top>r.top)o=t.posBefore;else{if(!(e.right-1?o:e.docView.posFromDOM(t,n,1)}(e,n,o,t))}null==i&&(i=function(e,t,n){let{node:r,offset:o}=Jn(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:i,inside:a?a.posAtStart-a.border:-1}}function Xn(e,t){let n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}const Qn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Yn(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=En||bn;if(3==r.nodeType){if(!s||!Qn.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,er(Xn(Ln(r,e,t),i),i<0)}{let e=Xn(Ln(r,o,o),n);if(bn&&o&&/\s/.test(r.nodeValue[o-1])&&o=0)}if(null==i&&o&&(n<0||o==Bn(r))){let e=r.childNodes[o-1],t=3==e.nodeType?Ln(e,Bn(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return er(Xn(t,1),!1)}if(null==i&&o=0)}function er(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function tr(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function nr(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const rr=/[\u0590-\u08ac]/;let or=null,ir=null,sr=!1;function ar(e,t,n){return or==t&&ir==n?sr:(or=t,ir=n,sr="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return nr(e,t,(()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.dom;break}t=n.dom.parentNode}let r=Yn(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Ln(e,0,e.nodeValue.length).getClientRects()}for(let e=0;eo.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.domSelection();return rr.test(r.parent.textContent)&&a.modify?nr(e,t,(()=>{let t=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");let l=!(r.depth?e.docView.domAfterPos(r.before()):e.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(t),null!=s&&(a.caretBidiLevel=s),l})):"left"==n||"backward"==n?i:s}(e,t,n))}class lr{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tOn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te||n instanceof mr){o=e-t;break}t=i}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof cr&&n.side>=0;r--);if(t<=0){let e,n=!0;for(;e=r?this.children[r-1]:null,e&&e.dom.parentNode!=this.contentDOM;r--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?On(e.dom)+1:0}}{let e,n=!0;for(;e=r=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=On(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;ea&&it){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirtyo?o.parent?o.parent.posBeforeChild(o):void 0:r))),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class ur extends lr{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class dr extends lr{constructor(e,t,n,r){super(e,[],n,r),this.mark=t}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=de.renderSpec(document,t.type.spec.toDOM(t,n))),new dr(e,t,i.dom,i.contentDOM||i.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(o=Nr(o,0,e,n));for(let e=0;es?s.parent?s.parent.posBeforeChild(s):void 0:i),n,r),c=l&&l.dom,u=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else c||({dom:c,contentDOM:u}=de.renderSpec(document,t.type.spec.toDOM(t)));u||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Cr(c,n,t),l?s=new gr(e,t,n,r,c,u||null,d,l,o,i+1):t.isText?new fr(e,t,n,r,c,d,o):new pr(e,t,n,r,c,u||null,d,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>d.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Tr(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new Sr(this,i&&i.node);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;ni;)a.push(o[s++]);let p=i+u.nodeSize;if(u.isText){let e=p;s!e.inline)):a.slice(),t.forChild(i,u),d),i=p}}(this.node,this.innerDeco,((t,o,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&a.syncToMarks(o==this.node.childCount?m.none:this.node.child(o).marks,n,e),a.placeWidget(t,e,r)}),((t,i,l,c)=>{let u;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,i,l,c)||s&&e.state.selection.from>r&&e.state.selection.to-1&&a.updateNodeAt(t,i,l,u,e)||a.updateNextNode(t,i,l,e,c)||a.addNode(t,i,l,e,r),r+=t.nodeSize})),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),vr(this.contentDOM,this.children,e),Tn&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Ut)||nt+this.node.content.size)return null;let o=e.domSelection(),i=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];t=Bn(e=e.childNodes[t-1])}else{if(!(1==e.nodeType&&t=n){let e=a=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return o<0?null:{node:i,pos:o,text:e}}return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new ur(this,o,t,r);e.input.compositionNodes.push(i),this.children=Nr(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(Tr(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=kr(this.dom,this.nodeDOM,wr(this.outerDeco,this.node,t),wr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function hr(e,t,n,r,o){return Cr(r,t,e),new pr(void 0,e,t,n,r,r,r,o,0)}class fr extends pr{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new fr(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}}class mr extends lr{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class gr extends pr{constructor(e,t,n,r,o,i,s,a,l,c){super(e,t,n,r,o,i,s,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function vr(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof dr)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n>1,i=Math.min(o,e.length);for(;r-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=dr.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r=n||u<=t?i.push(l):(cn&&i.push(l.slice(n-c,l.size,r)))}return i}function Or(e,t=null){let n=e.domSelection(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(Hn(n)){for(a=c;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&Jt.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==Bn(e);r||o;){if(e==n)return!0;let t=On(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==Bn(e)}}(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;l=new Jt(s==e?c:r.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;a=r.resolve(t)}if(!l){l=Hr(e,a,c,"pointer"==t||e.state.selection.head{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{Dr(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Lr=Cn||kn&&xn<63;function Ir(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=rr(e,t,n)))||Ut.between(t,n,r)}function zr(e){return(!e.editable||e.root.activeElement==e.dom)&&qr(e)}function qr(e){let t=e.domSelection();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Vr(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&Vt.findFrom(i,t)}function jr(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function $r(e,t,n){let r=e.state.selection;if(!(r instanceof Ut)){if(r instanceof Jt&&r.node.isInline)return jr(e,new Ut(t>0?r.$to:r.$from));{let n=Vr(e.state,t);return!!n&&jr(e,n)}}if(!r.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){let n=Vr(e.state,t);return!!(n&&n instanceof Jt)&&jr(e,n)}if(!(Mn&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Jt.isSelectable(i)?jr(e,new Jt(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):!!En&&jr(e,new Ut(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function _r(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ur(e){let t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Wr(e){let t=e.domSelection(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(bn&&1==n.nodeType&&r<_r(n)&&Ur(n.childNodes[r])&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Ur(e))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Gr(n))break;{let t=n.previousSibling;for(;t&&Ur(t);)o=n.parentNode,i=On(t),t=t.previousSibling;if(t)n=t,r=_r(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Kr(e,t,n,r):o&&Kr(e,t,o,i)}function Jr(e){let t=e.domSelection(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=_r(n);for(;;)if(r{e.state==o&&Ar(e)}),50)}function Zr(e,t,n){let r=e.state.selection;if(r instanceof Ut&&!r.empty||n.indexOf("s")>-1)return!1;if(Mn&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Vr(e.state,t);if(n&&n instanceof Jt)return jr(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof Kt?Vt.near(n,t):Vt.findFrom(n,t);return!!s&&jr(e,s)}return!1}function Xr(e,t){if(!(e.state.selection instanceof Ut))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function Qr(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Yr(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||Mn&&72==n&&"c"==r?Xr(e,-1)||Wr(e):46==n||Mn&&68==n&&"c"==r?Xr(e,1)||Jr(e):13==n||27==n||(37==n||Mn&&66==n&&"c"==r?$r(e,-1,r)||Wr(e):39==n||Mn&&70==n&&"c"==r?$r(e,1,r)||Jr(e):38==n||Mn&&80==n&&"c"==r?Zr(e,-1,r)||Wr(e):40==n||Mn&&78==n&&"c"==r?function(e){if(!Cn||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelection();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Qr(e,n,"true"),setTimeout((()=>Qr(e,n,"false")),20)}return!1}(e)||Zr(e,1,r)||Jr(e):r==(Mn?"m":"c")&&(66==n||73==n||89==n||90==n))}function eo(e,t){let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||de.fromSchema(e.state.schema),a=uo(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,u=l.firstChild,d=0;for(;u&&1==u.nodeType&&(c=lo[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),d++}u=l.firstChild}return u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",(e=>e(t)))||t.content.textBetween(0,t.content.size,"\n\n")}}function to(e,t,n,r,o){let i,s,a=o.parent.type.spec.code;if(!n&&!t)return null;let l=t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",(e=>{t=e(t,a||r)})),a)return t?new v(d.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):v.empty;let n=e.someProp("clipboardTextParser",(e=>e(t,o,r)));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=de.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))}))}}else e.someProp("transformPastedHTML",(e=>{n=e(n)})),i=function(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=uo().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);(n=o&&lo[o[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>""+e+">")).reverse().join(""));if(r.innerHTML=e,n)for(let e=0;e0&&i.firstChild;e--)i=i.firstChild;if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||te.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!l&&!u),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||no.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(u)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;o=d.from(t.create(n[e+1],o)),i++,s++}return new v(o,i,s)}(ao(s,+u[1],+u[2]),u[4]);else if(s=v.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach((e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&oo(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=io(i[i.length-1],r.length));let t=ro(e,n);i.push(t),o=o.matchType(t.type),r=n}})),i)return d.from(i)}return e}(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=e(s)})),s}const no=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function ro(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,d.from(e));return e}function oo(e,t,n,r,o){if(o=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,e.childCount>1||i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(d.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function ao(e,t,n){return t{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>vo(e,t))}))}function vo(e,t){return e.someProp("handleDOMEvents",(n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function yo(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function bo(e){return{left:e.clientX,top:e.clientY}}function wo(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,(t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1))))return!0;return!1}function ko(e,t,n){e.focused||e.focus();let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function xo(e,t,n,r,o){return wo(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(n=>n(e,t,r)))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof Jt&&(n=o.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(Jt.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(ko(e,Jt.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Jt.isSelectable(r))&&(ko(e,new Jt(n),"pointer"),!0)}(e,n))}function Co(e,t,n,r){return wo(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(n=>n(e,t,r)))}function To(e,t,n,r){return wo(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(n=>n(e,t,r)))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(ko(e,Ut.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(t);for(let t=o.depth+1;t>0;t--){let n=t>o.depth?o.nodeAfter:o.node(t),i=o.before(t);if(n.inlineContent)ko(e,Ut.create(r,i+1,i+1+n.content.size),"pointer");else{if(!Jt.isSelectable(n))continue;ko(e,Jt.create(r,i),"pointer")}return!0}}(e,n,r)}function Mo(e){return Lo(e)}ho.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!No(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Sn||!kn||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!Tn||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||Yr(e,n)?n.preventDefault():mo(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,zn(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},ho.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ho.keypress=(e,t)=>{let n=t;if(No(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Mn&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof Ut&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode);e.someProp("handleTextInput",(n=>n(e,r.$from.pos,r.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const So=Mn?"metaKey":"ctrlKey";po.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Mo(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[So]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=e.posAtCoords(bo(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Eo(e,s,n,!!r)):("doubleClick"==i?Co:To)(e,s.pos,s.inside,n)?n.preventDefault():mo(e,"pointer"))};class Eo{constructor(e,t,n,r){let o,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[So],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a?a.dom:null;let{selection:l}=e.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof Jt&&l.from<=i&&l.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!bn||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),mo(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>Ar(this.view))),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(bo(e))),this.allowDefault||!t?mo(this.view,"pointer"):xo(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Cn&&this.mightDrag&&!this.mightDrag.node.isAtom||kn&&!(this.view.state.selection instanceof Ut)&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ko(this.view,Vt.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):mo(this.view,"pointer")}move(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0),mo(this.view,"pointer"),0==e.buttons&&this.done()}}function No(e,t){return!!e.composing||!!(Cn&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}po.touchdown=e=>{Mo(e),mo(e,"pointer")},po.contextmenu=e=>Mo(e);const Oo=Sn?5e3:-1;function Do(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>Lo(e)),t))}function Ao(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Lo(e,t=!1){if(!(Sn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ao(e),t||e.docView&&e.docView.dirty){let t=Or(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}ho.compositionstart=ho.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),Lo(e,!0),e.markCursor=null;else if(Lo(e),bn&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelection();for(let e=t.focusNode,n=t.focusOffset;e&&1==e.nodeType&&0!=n;){let r=n<0?e.lastChild:e.childNodes[n-1];if(!r)break;if(3==r.nodeType){t.collapse(r,r.nodeValue.length);break}e=r,n=-1}}e.input.composing=!0}Do(e,Oo)},ho.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,Do(e,20))};const Io=vn&&yn<15||Tn&&Nn<604;function Ro(e,t,n,r){let o=to(e,t,n,e.input.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,r,o||v.empty))))return!0;if(!o)return!1;let i=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),s=i?e.state.tr.replaceSelectionWith(i,e.input.shiftKey):e.state.tr.replaceSelection(o);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}po.copy=ho.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=Io?null:n.clipboardData,s=r.content(),{dom:a,text:l}=eo(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ho.paste=(e,t)=>{let n=t;if(e.composing&&!Sn)return;let r=Io?null:n.clipboardData;r&&Ro(e,r.getData("text/plain"),r.getData("text/html"),n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ro(e,r.value,null,t):Ro(e,r.textContent,r.innerHTML,t)}),50)}(e,n)};class Po{constructor(e,t){this.slice=e,this.move=t}}const Bo=Mn?"altKey":"ctrlKey";po.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=e.state.selection,i=o.empty?null:e.posAtCoords(bo(n));if(i&&i.pos>=o.from&&i.pos<=(o instanceof Jt?o.to-1:o.to));else if(r&&r.mightDrag)e.dispatch(e.state.tr.setSelection(Jt.create(e.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&e.dispatch(e.state.tr.setSelection(Jt.create(e.state.doc,t.posBefore)))}let s=e.state.selection.content(),{dom:a,text:l}=eo(e,s);n.dataTransfer.clearData(),n.dataTransfer.setData(Io?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Io||n.dataTransfer.setData("text/plain",l),e.dragging=new Po(s,!n[Bo])},po.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},ho.dragover=ho.dragenter=(e,t)=>t.preventDefault(),ho.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let o=e.posAtCoords(bo(n));if(!o)return;let i=e.state.doc.resolve(o.pos);if(!i)return;let s=r&&r.slice;s?e.someProp("transformPasted",(e=>{s=e(s)})):s=to(e,n.dataTransfer.getData(Io?"Text":"text/plain"),Io?null:n.dataTransfer.getData("text/html"),!1,i);let a=!(!r||n[Bo]);if(e.someProp("handleDrop",(t=>t(e,n,s||v.empty,a))))return void n.preventDefault();if(!s)return;n.preventDefault();let l=s?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);a=e&&s.canReplaceWith(i,i,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}(e.state.doc,i.pos,s):i.pos;null==l&&(l=i.pos);let c=e.state.tr;a&&c.deleteSelection();let u=c.mapping.map(l),d=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,p=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(p))return;let h=c.doc.resolve(u);if(d&&Jt.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Jt(h));else{let t=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,r,o)=>t=o)),c.setSelection(Hr(e,h,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},po.focus=e=>{e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelection())&&Ar(e)}),20))},po.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},po.beforeinput=(e,t)=>{if(kn&&Sn&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,zn(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in ho)po[e]=ho[e];function Fo(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Ho{constructor(e,t){this.toDOM=e,this.spec=t||$o,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new Vo(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Ho&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Fo(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class zo{constructor(e,t){this.attrs=e,this.spec=t||$o}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Vo(o,i,this)}valid(e,t){return t.from=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;ie){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==Uo||0==e.maps.length?this:this.mapInner(e,t,0,0,n||$o)}mapInner(e,t,n,r,o){let i;for(let s=0;s{for(let s=0;sc+i)continue;let u=a[s]+i;t>=u?a[s+1]=e<=u?-2:-1:n>=o&&(l=r-n-(t-e))&&(a[s]+=l,a[s+1]+=l)}};for(let e=0;e=r.content.size){c=!0;continue}let d=n.map(e[t+1]+i,-1)-o,{index:p,offset:h}=r.content.findIndex(u),f=r.maybeChild(p);if(f&&h==u&&h+f.nodeSize==d){let r=a[t+2].mapInner(n,f,l+1,e[t]+i+1,s);r!=Uo?(a[t]=u,a[t+1]=d,a[t+2]=r):(a[t+1]=-2,c=!0)}else c=!0}if(c){let l=function(e,t,n,r,o,i,s){function a(e,t){for(let i=0;i{let s,a=i+n;if(s=Go(t,e,a)){for(r||(r=this.children.slice());oi&&t.to=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;eo&&t.type instanceof zo){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;en.map(e,t,$o)));return Wo.from(n)}forChild(e,t){if(t.isLeaf)return _o.empty;let n=[];for(let r=0;rn&&t.to{let a=Go(e,t,s+n);if(a){i=!0;let e=Zo(a,t,n+s+1,r);e!=Uo&&o.push(s,s+t.nodeSize,e)}}));let s=Jo(i?Ko(e):e,-n).sort(Xo);for(let e=0;e0;)t++;e.splice(t,0,n)}function ei(e){let t=[];return e.someProp("decorations",(n=>{let r=n(e.state);r&&r!=Uo&&t.push(r)})),e.cursorWrapper&&t.push(_o.create(e.state.doc,[e.cursorWrapper.deco])),Wo.from(t)}const ti={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ni=vn&&yn<=11;class ri{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class oi{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ri,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),ni&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ti)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(zr(this.view)){if(this.suppressingSelectionUpdates)return Ar(this.view);if(vn&&yn<=11&&!this.view.state.selection.empty){let e=this.view.domSelection();if(e.focusNode&&In(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelection())}ignoreSelectionChange(e){if(0==e.rangeCount)return!0;let t=e.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(t);return n&&n.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}flush(){if(!this.view.docView||this.flushingSoon>-1)return;let e=this.observer?this.observer.takeRecords():[];this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);let t=this.view.domSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&zr(this.view)&&!this.ignoreSelectionChange(t),r=-1,o=-1,i=!1,s=[];if(this.view.editable)for(let t=0;t1){let e=s.filter((e=>"BR"==e.nodeName));if(2==e.length){let t=e[0],n=e[1];t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(e){if(ii)return;ii=!0,"normal"==getComputedStyle(e.dom).whiteSpace&&console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.")}(this.view)),this.handleDOMChange(r,o,i,s),this.view.docView&&this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(t)||Ar(this.view),this.currentSelection.set(t))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;nDate.now()-50?e.input.lastSelectionOrigin:null,n=Or(e,t);if(n&&!e.state.selection.eq(n)){let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),e.dispatch(r)}return}let i=e.state.doc.resolve(t),s=i.sharedDepth(n);t=i.before(s+1),n=e.state.doc.resolve(n).after(s+1);let a=e.state.selection,l=function(e,t,n){let r,{node:o,fromOffset:i,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelection(),u=c.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(r=[{node:u,offset:c.anchorOffset}],Hn(c)||r.push({node:c.focusNode,offset:c.focusOffset})),kn&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let d=e.state.doc,p=e.someProp("domParser")||te.fromSchema(e.state.schema),h=d.resolve(a),f=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:r,ruleFromNode:si,context:h});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n);if(kn&&e.cursorWrapper&&l.sel&&l.sel.anchor==e.cursorWrapper.deco.from&&l.sel.head==l.sel.anchor){let t=e.cursorWrapper.deco.type.toDOM.nextSibling,n=t&&t.nodeValue?t.nodeValue.length:1;l.sel={anchor:l.sel.anchor+n,head:l.sel.anchor+n}}let c,u,p=e.state.doc,h=p.slice(l.from,l.to);8===e.input.lastKeyCode&&Date.now()-100=s?i-r:0,a=i+(a-s),s=i}else if(a=a?i-r:0,s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}(h.content,l.doc.content,l.from,c,u);if((Tn&&e.input.lastIOSEnter>Date.now()-225||Sn)&&o.some((e=>"DIV"==e.nodeName||"P"==e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",(t=>t(e,zn(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&a instanceof Ut&&!a.empty&&a.$head.sameParent(a.$anchor))||e.composing||l.sel&&l.sel.anchor!=l.sel.head){if(l.sel){let t=li(e,e.state.doc,l.sel);t&&!t.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(t))}return}f={start:a.from,endA:a.to,endB:a.to}}e.input.domChangeCount++,e.state.selection.frome.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?f.start=e.state.selection.from:f.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),vn&&yn<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>l.from&&" "==l.doc.textBetween(f.start-l.from-1,f.start-l.from+1)&&(f.start--,f.endA--,f.endB--);let m,g=l.doc.resolveNoCache(f.start-l.from),v=l.doc.resolveNoCache(f.endB-l.from),y=p.resolve(f.start),b=g.sameParent(v)&&g.parent.inlineContent&&y.end()>=f.endA;if((Tn&&e.input.lastIOSEnter>Date.now()-225&&(!b||o.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!b&&g.post(e,zn(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,r,o){if(!r.parent.isTextblock||n-t<=o.pos-r.pos||ci(r,!0,!1)n||ci(s,!0,!1)t(e,zn(8,"Backspace")))))return void(Sn&&kn&&e.domObserver.suppressSelectionUpdates());kn&&Sn&&f.endB==f.start&&(e.input.lastAndroidDelete=Date.now()),Sn&&!b&&g.start()!=v.start()&&0==v.parentOffset&&g.depth==v.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==f.endA&&(f.endB-=2,v=l.doc.resolveNoCache(f.endB-l.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,zn(13,"Enter"))}))}),20));let w,k,x,C=f.start,T=f.endA;if(b)if(g.pos==v.pos)vn&&yn<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>Ar(e)),20)),w=e.state.tr.delete(C,T),k=p.resolve(f.start).marksAcross(p.resolve(f.endA));else if(f.endA==f.endB&&(x=function(e,t){let n,r,o,i=e.firstChild.marks,s=t.firstChild.marks,a=i,l=s;for(let e=0;ee.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;en(e,C,T,t))))return;w=e.state.tr.insertText(t,C,T)}if(w||(w=e.state.tr.replace(C,T,l.doc.slice(f.start-l.from,f.endB-l.from))),l.sel){let t=li(e,w.doc,l.sel);t&&!(kn&&Sn&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastAndroidDeletet.content.size?null:Hr(e,t.resolve(n.anchor),t.resolve(n.head))}function ci(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}class ui{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new fo,this.prevDirectPlugins=[],this.pluginViews=[],this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(mi),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=hi(this),pi(this),this.nodeViews=fi(this),this.docView=hr(this.state.doc,di(this),ei(this),this.dom,this),this.domObserver=new oi(this,((e,t,n,r)=>ai(this,e,t,n,r))),this.domObserver.start(),function(e){for(let t in po){let n=po[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!yo(e,t)||vo(e,t)||!e.editable&&t.type in ho||n(e,t)})}Cn&&e.dom.addEventListener("input",(()=>null)),go(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&go(this),this._props=e,e.plugins&&(e.plugins.forEach(mi),this.directPlugins=e.plugins),this.updateStateInner(e.state,!0)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this.state.plugins!=e.plugins)}updateStateInner(e,t){let n=this.state,r=!1,o=!1;if(e.storedMarks&&this.composing&&(Ao(this),o=!0),this.state=e,t){let e=fi(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,r=!0),go(this)}this.editable=hi(this),pi(this);let i=ei(this),s=di(this),a=t?"reset":e.scrollToSelection>n.scrollToSelection?"to selection":"preserve",l=r||!this.docView.matchesNode(e.doc,s,i);!l&&e.selection.eq(n.selection)||(o=!0);let c="preserve"==a&&o&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s=o-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:_n(e.dom)}}(this);if(o){this.domObserver.stop();let t=l&&(vn||kn)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(n.selection,e.selection);if(l){let n=kn?this.trackWrites=this.domSelection().focusNode:null;!r&&this.docView.update(e.doc,s,i,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=hr(e.doc,s,i,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelection())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelection();return In(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?Ar(this,t):(Br(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(n),"reset"==a)this.dom.scrollTop=0;else if("to selection"==a){let t=this.domSelection().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(e.selection instanceof Jt){let n=this.docView.domAfterPos(e.selection.from);1==n.nodeType&&$n(this,n.getBoundingClientRect(),t)}else $n(this,this.coordsAtPos(e.selection.head,1),t)}else c&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Un(n,0==r?0:r-t)}(c)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;te.ownerDocument.getSelection()),this._root=e;return e||document}posAtCoords(e){return Zn(this,e)}coordsAtPos(e,t=1){return Yn(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return ar(this,t||this.state,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ei(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){vo(e,t)||!po[t.type]||!e.editable&&t.type in ho||po[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelection(){return this.root.getSelection()}}function di(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e&&(t.class+=" "+n[e]),"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),[Vo.node(0,e.state.doc.content.size,t)]}function pi(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Vo.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function hi(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function fi(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function mi(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var gi=n(354),vi=n.n(gi),yi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"},bi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},wi="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),ki="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),xi="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),Ci="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ti="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Mi=wi&&(Ci||+wi[1]<57)||xi&&Ci,Si=0;Si<10;Si++)yi[48+Si]=yi[96+Si]=String(Si);for(Si=1;Si<=24;Si++)yi[Si+111]="F"+Si;for(Si=65;Si<=90;Si++)yi[Si]=String.fromCharCode(Si+32),bi[Si]=String.fromCharCode(Si);for(var Ei in yi)bi.hasOwnProperty(Ei)||(bi[Ei]=yi[Ei]);const Ni="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Oi(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e127)&&(r=yi[n.keyCode])&&r!=o){let o=t[Di(r,n,!0)];if(o&&o(e.state,e.dispatch,e))return!0}else if(i&&n.shiftKey){let r=t[Di(o,n,!0)];if(r&&r(e.state,e.dispatch,e))return!0}return!1}}const Ii=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Ri(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function Pi(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}const Bi=(e,t,n)=>{let{$cursor:r}=e.selection;if(!r||(n?!n.endOfTextblock("forward",e):r.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function zi(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=zi(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(Vt.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},Vi=(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof Jt&&e.selection.node.isBlock)return!(!n.parentOffset||!Mt(e.doc,n.pos))&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.parent.isBlock)return!1;if(t){let o=r.parentOffset==r.parent.content.size,i=e.tr;(e.selection instanceof Ut||e.selection instanceof Kt)&&i.deleteSelection();let s=0==n.depth?null:zi(n.node(-1).contentMatchAt(n.indexAfter(-1))),a=o&&s?[{type:s}]:void 0,l=Mt(i.doc,i.mapping.map(n.pos),1,a);if(a||l||!Mt(i.doc,i.mapping.map(n.pos),1,s?[{type:s}]:void 0)||(s&&(a=[{type:s}]),l=!0),l&&(i.split(i.mapping.map(n.pos),1,a),!o&&!n.parentOffset&&n.parent.type!=s)){let e=i.mapping.map(n.before()),t=i.doc.resolve(e);s&&n.node(-1).canReplaceWith(t.index(),t.index()+1,s)&&i.setNodeMarkup(i.mapping.map(n.before()),s)}t(i.scrollIntoView())}return!0},ji=(e,t)=>(t&&t(e.tr.setSelection(new Kt(e.doc))),!0);function $i(e,t,n){let r,o,i=t.nodeBefore,s=t.nodeAfter;if(i.type.spec.isolating||s.type.spec.isolating)return!1;if(function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!St(e.doc,t.pos)||(n&&n(e.tr.clearIncompatible(t.pos,r.type,r.contentMatchAt(r.childCount)).join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let a=t.parent.canReplace(t.index(),t.index()+1);if(a&&(r=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(r[0]||s.type).validEnd){if(n){let o=t.pos+s.nodeSize,a=d.empty;for(let e=r.length-1;e>=0;e--)a=d.from(r[e].create(null,a));a=d.from(i.copy(a));let l=e.tr.step(new wt(t.pos-1,o,t.pos,o,new v(a,1,0),r.length,!0)),c=o+2*r.length;St(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=Vt.findFrom(t,1),c=l&&l.$from.blockRange(l.$to),u=c&&Ct(c);if(null!=u&&u>=t.depth)return n&&n(e.tr.lift(c,u).scrollIntoView()),!0;if(a&&Ri(s,"start",!0)&&Ri(i,"end")){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let a=s,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,a.content)){if(n){let r=d.empty;for(let e=o.length-1;e>=0;e--)r=d.from(o[e].copy(r));n(e.tr.step(new wt(t.pos-o.length,t.pos+s.nodeSize,t.pos+l,t.pos+s.nodeSize-l,new v(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function _i(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(Ut.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const Ui=_i(-1),Wi=_i(1);function Ji(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=s&&function(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e{if(s)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)s=!0;else{let t=n.doc.resolve(o),r=t.index();s=t.parent.canReplaceWith(r,r+1,e)}})),!!s&&(r&&r(n.tr.setBlockType(o,i,e,t).scrollIntoView()),!0)}}function Ki(e,t=null){return function(n,r){let{empty:o,$cursor:i,ranges:s}=n.selection;if(o&&!i||!function(e,t,n){for(let r=0;r{if(s)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)})),s)return!0}return!1}(n.doc,s,e))return!1;if(r)if(i)e.isInSet(n.storedMarks||i.marks())?r(n.tr.removeStoredMark(e)):r(n.tr.addStoredMark(e.create(t)));else{let o=!1,i=n.tr;for(let t=0;!o&&t{let{$cursor:r}=e.selection;if(!r||(n?!n.endOfTextblock("backward",e):r.parentOffset>0))return!1;let o=Pi(r);if(!o){let n=r.blockRange(),o=n&&Ct(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(!i.type.spec.isolating&&$i(e,o,t))return!0;if(0==r.parent.content.size&&(Ri(i,"end")||Jt.isSelectable(i))){let n=Nt(e.doc,r.before(),r.after(),v.empty);if(n&&n.slice.size{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=Pi(r)}let s=i&&i.nodeBefore;return!(!s||!Jt.isSelectable(s))&&(t&&t(e.tr.setSelection(Jt.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)})),Qi=Zi(Ii,Bi,((e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof Kt||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=zi(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Mt(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Ct(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)}),Vi),"Mod-Enter":qi,Backspace:Xi,"Mod-Backspace":Xi,"Shift-Backspace":Xi,Delete:Qi,"Mod-Delete":Qi,"Mod-a":ji},es={"Ctrl-h":Yi.Backspace,"Alt-Backspace":Yi["Mod-Backspace"],"Ctrl-d":Yi.Delete,"Ctrl-Alt-Backspace":Yi["Mod-Delete"],"Alt-Delete":Yi["Mod-Delete"],"Alt-d":Yi["Mod-Delete"],"Ctrl-a":Ui,"Ctrl-e":Wi};for(let e in Yi)es[e]=Yi[e];const ts=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?es:Yi;class ns{constructor(e,t){var n;this.match=e,this.match=e,this.handler="string"==typeof t?(n=t,function(e,t,r,o){let i=n;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let n=(r+=e)-o;n>0&&(i=t[0].slice(e-n,e)+i,r=o)}return e.tr.insertText(i,r,o)}):t}}function rs({rules:e}){let t=new an({state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>is(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout((()=>{let{$cursor:r}=n.state.selection;r&&is(n,r.pos,r.pos,"",e,t)}))}}},isInputRules:!0});return t}function is(e,t,n,r,o,i){if(e.composing)return!1;let s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;let l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,null,"")+r;for(let a=0;a{let n=e.plugins;for(let r=0;r=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};new ns(/--$/,"—"),new ns(/\.\.\.$/,"…"),new ns(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new ns(/"$/,"”"),new ns(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new ns(/'$/,"’");var as=200,ls=function(){};ls.prototype.append=function(e){return e.length?(e=ls.from(e),!this.length&&e||e.length=t?ls.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ls.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ls.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ls.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},ls.from=function(e){return e instanceof ls?e:e&&e.length?new cs(e):ls.empty};var cs=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=as)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=as)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ls);ls.empty=new cs([]);var us=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return eo&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ls),ds=ls;class ps{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,a=e.tr,l=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new hs(e.map));let t,o=e.step.map(n.slice(r));o&&a.maybeStep(o).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new hs(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new ps(this.items.slice(0,o).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:a,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,a=!r&&s.length?s.get(s.length-1):null;for(let n=0;nms&&(s=function(e,t){let n;return e.forEach(((e,r)=>{if(e.selection&&0==t--)return n=r,!1})),e.slice(n)}(s,l),i-=l),new ps(s.append(o),i)}remapping(e,t){let n=new pt;return this.items.forEach(((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new ps(this.items.append(e.map((e=>new hs(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach((e=>{e.selection&&s--}),r);let a=t;this.items.forEach((t=>{let r=o.getMirror(--a);if(null==r)return;i=Math.min(i,r);let l=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(a+1,r));c&&s++,n.push(new hs(l,i,c))}else n.push(new hs(l))}),r);let l=[];for(let e=t;e500&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],o=0;return this.items.forEach(((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=i.selection&&i.selection.map(t.slice(n));a&&o++;let l,c=new hs(s.invert(),e,a),u=r.length-1;(l=r.length&&r[u].merge(c))?r[u]=l:r.push(c)}}else i.map&&n--}),this.items.length,0),new ps(ds.from(r.reverse()),o)}}ps.empty=new ps(ds.empty,0);class hs{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new hs(t.getMap().invert(),t,this.selection)}}}class fs{constructor(e,t,n,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r}}const ms=20;function gs(e){let t=[];return e.forEach(((e,n,r,o)=>t.push(r,o))),t}function vs(e,t){if(!e)return null;let n=[];for(let r=0;rnew fs(ps.empty,ps.empty,null,0),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(xs);if(i)return i.historyState;n.getMeta(Cs)&&(e=new fs(e.done,e.undone,null,0));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(xs))return s.getMeta(xs).redo?new fs(e.done.addTransform(n,void 0,r,ks(t)),e.undone,gs(n.mapping.maps[n.steps.length-1]),e.prevTime):new fs(e.done,e.undone.addTransform(n,void 0,r,ks(t)),null,e.prevTime);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new fs(e.done.rebased(n,o),e.undone.rebased(n,o),vs(e.prevRanges,n.mapping),e.prevTime):new fs(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),vs(e.prevRanges,n.mapping),e.prevTime);{let o=0==e.prevTime||!s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,r)=>{for(let o=0;o=t[o]&&(n=!0)})),n}(n,e.prevRanges)),i=s?vs(e.prevRanges,n.mapping):gs(n.mapping.maps[n.steps.length-1]);return new fs(e.done.addTransform(n,o?t.selection.getBookmark():void 0,r,ks(t)),ps.empty,i,n.time)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?Ms:"historyRedo"==n?Ss:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}const Ms=(e,t)=>{let n=xs.getState(e);return!(!n||0==n.done.eventCount)&&(t&&ys(n,e,t,!1),!0)},Ss=(e,t)=>{let n=xs.getState(e);return!(!n||0==n.undone.eventCount)&&(t&&ys(n,e,t,!0),!0)};function Es(e,t){var n=e.nodes.paragraph;return t?n.create(null,Me()(t)?e.text(t):t):n.createAndFill()}function Ns(e,t,n){return e.text(t,n)}function Os(e,t,n){void 0===n&&(n=t);var r=e.doc.content.size,o=r>0?r-1:1;return Ut.create(e.doc,Math.min(t,o),Math.min(n,o))}function Ds(e,t,n){var r=t.pos;return e.replaceWith(r,r,Es(n)),e.setSelection(Os(e,r+1))}function As(e){for(var t=e.state,n=e.from,r=e.startIndex,o=e.endIndex,i=e.createText,s=t.tr,a=t.doc,l=t.schema,c=r;c<=o;c+=1){var u=a.child(c),p=u.nodeSize,h=u.textContent,f=u.content,m=i(h),g=m?Ns(l,m):d.empty,v=s.mapping.map(n),y=v+f.size;s.replaceWith(v,y,g),n+=p}return s}function Ls(e,t,n,r){var o=n.length;e.split(t).delete(t-o,t).insert(e.mapping.map(t),r).setSelection(Os(e,e.mapping.map(t)-o))}function Is(e){return e.sourcepos[0][0]}function Rs(e){return e.sourcepos[1][0]}function Ps(e){return e.sourcepos[0][1]}function Bs(e){return e.sourcepos[1][1]}function Fs(e){var t=e.type;return"strike"===t||"strong"===t||"emph"===t||"code"===t||"link"===t||"image"===t}function Hs(e){return e&&("item"===e.type||"list"===e.type)}function zs(e){return Hs(e)&&"ordered"===e.listData.type}function qs(e){return Hs(e)&&"ordered"!==e.listData.type}function Vs(e){return e&&("tableCell"===e.type||"tableDelimCell"===e.type)}function js(e,t,n){for(void 0===n&&(n=!0),e=n?e:e.parent;e&&"document"!==e.type;){if(t(e))return e;e=e.parent}return null}function $s(e,t){return[e[0],e[1]+t]}function _s(e,t){return[e[0],t]}function Us(e){var t=e.firstChild.literal;switch(e.type){case"emph":return"*"+t+"*";case"strong":return"**"+t+"**";case"strike":return"~~"+t+"~~";case"code":return"`"+t+"`";case"link":case"image":var n=e,r=n.destination,o=n.title;return("link"===e.type?"":"!")+"["+t+"]("+r+(o?' "'+o+'"':"")+")";default:return null}}function Ws(e){switch(e.type){case"document":case"blockQuote":case"list":case"item":case"paragraph":case"heading":case"emph":case"strong":case"strike":case"link":case"image":case"table":case"tableHead":case"tableBody":case"tableRow":case"tableCell":case"tableDelimRow":case"customInline":return!0;default:return!1}}function Js(e){for(var t=[],n=e.walker(),r=null;r=n.next();){var o=r.node;"text"===o.type&&t.push(o.literal)}return t.join("")}var Gs=[],Ks={},Zs=/\$\$widget\d+\s/;function Xs(e){var t=e.search(Zs);if(-1!==t){var n=e.substring(t).replace(Zs,"").replace("$$","");e=e.substring(0,t),e+=Xs(n)}return e}function Qs(e,t){return"$$"+e+" "+t+"$$"}function Ys(e,t){var n=Ks[e],r=n.rule,o=n.toDOM,i=Xs(t).match(r);return i&&(t=i[0]),o(t)}function ea(){return Gs}function ta(e){(Gs=e).forEach((function(e,t){Ks["widget"+t]=e}))}function na(e,t,n,r){return e.concat(ra(t,n,r))}function ra(e,t,n){void 0===n&&(n=0);var r=[],o=(Gs[n]||{}).rule,i=n+1;if(e=Xs(e),o&&o.test(e)){for(var s=void 0;-1!==(s=e.search(o));){var a=e.substring(0,s);a&&(r=na(r,a,t,i));var l=(e=e.substring(s)).match(o)[0],c="widget"+n;r.push(t.nodes.widget.create({info:c},t.text(Qs(c,l)))),e=e.substring(l.length)}e&&(r=na(r,e,t,i))}else e&&(r=n`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)",fa="<("+pa+")("+ha+")*\\s*/?>",ma="(?:"+fa+"|([A-Za-z][A-Za-z0-9-]*)\\s*[>])",ga=new RegExp("^"+ma,"i"),va=/ /i,ya=/|/,ba="