@pod-os/elements 0.30.2-rc.a4eda69.0 → 0.30.2-rc.ca6f577.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +0,0 @@
1
- import{r as t,i as e,h as n}from"./p-97889672.js";import{o as r,j as i,k as s,l as o,S as l,h as u,t as a}from"./p-5a025614.js";import"./p-c066fd50.js";function f(t,e){return r(((n,r)=>{let s=0;n.subscribe(i(r,(n=>{r.next(t.call(e,n,s++))})))}))}function h(t,e,n){const l=o(t)||e||n?{next:t,error:e,complete:n}:t;return l?r(((t,e)=>{var n;(n=l.subscribe)===null||n===void 0?void 0:n.call(l);let r=true;t.subscribe(i(e,(t=>{var n;(n=l.next)===null||n===void 0?void 0:n.call(l,t);e.next(t)}),(()=>{var t;r=false;(t=l.complete)===null||t===void 0?void 0:t.call(l);e.complete()}),(t=>{var n;r=false;(n=l.error)===null||n===void 0?void 0:n.call(l,t);e.error(t)}),(()=>{var t,e;if(r){(t=l.unsubscribe)===null||t===void 0?void 0:t.call(l)}(e=l.finalize)===null||e===void 0?void 0:e.call(l)})))})):s}var c=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};var d={exports:{}};
2
- /*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */(function(t,e){(function(e,n){t.exports=n()})(c,(function(){const{entries:t,setPrototypeOf:e,isFrozen:n,getPrototypeOf:r,getOwnPropertyDescriptor:i}=Object;let{freeze:s,seal:o,create:l}=Object;let{apply:u,construct:a}=typeof Reflect!=="undefined"&&Reflect;if(!s){s=function t(e){return e}}if(!o){o=function t(e){return e}}if(!u){u=function t(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++){i[s-2]=arguments[s]}return e.apply(n,i)}}if(!a){a=function t(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++){r[i-1]=arguments[i]}return new e(...r)}}const f=S(Array.prototype.forEach);const h=S(Array.prototype.lastIndexOf);const c=S(Array.prototype.pop);const d=S(Array.prototype.push);const p=S(Array.prototype.splice);const m=S(String.prototype.toLowerCase);const g=S(String.prototype.toString);const w=S(String.prototype.match);const b=S(String.prototype.replace);const v=S(String.prototype.indexOf);const k=S(String.prototype.trim);const y=S(Object.prototype.hasOwnProperty);const x=S(RegExp.prototype.test);const M=T(TypeError);function S(t){return function(e){if(e instanceof RegExp){e.lastIndex=0}for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++){r[i-1]=arguments[i]}return u(t,e,r)}}function T(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++){n[r]=arguments[r]}return a(t,n)}}function E(t,r){let i=arguments.length>2&&arguments[2]!==undefined?arguments[2]:m;if(e){e(t,null)}let s=r.length;while(s--){let e=r[s];if(typeof e==="string"){const t=i(e);if(t!==e){if(!n(r)){r[s]=t}e=t}}t[e]=true}return t}function A(t){for(let e=0;e<t.length;e++){const n=y(t,e);if(!n){t[e]=null}}return t}function O(e){const n=l(null);for(const[r,i]of t(e)){const t=y(e,r);if(t){if(Array.isArray(i)){n[r]=A(i)}else if(i&&typeof i==="object"&&i.constructor===Object){n[r]=O(i)}else{n[r]=i}}}return n}function $(t,e){while(t!==null){const n=i(t,e);if(n){if(n.get){return S(n.get)}if(typeof n.value==="function"){return S(n.value)}}t=r(t)}function n(){return null}return n}const R=s(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]);const C=s(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]);const L=s(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]);const N=s(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]);const I=s(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]);const P=s(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]);const D=s(["#text"]);const H=s(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]);const _=s(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]);const j=s(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]);const z=s(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]);const B=o(/\{\{[\w\W]*|[\w\W]*\}\}/gm);const F=o(/<%[\w\W]*|[\w\W]*%>/gm);const U=o(/\$\{[\w\W]*/gm);const q=o(/^data-[\-\w.\u00B7-\uFFFF]+$/);const K=o(/^aria-[\-\w]+$/);const J=o(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);const W=o(/^(?:\w+script|data):/i);const V=o(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);const G=o(/^html$/i);const Z=o(/^[a-z][.\w]*(-[.\w]+)+$/i);var Y=Object.freeze({__proto__:null,ARIA_ATTR:K,ATTR_WHITESPACE:V,CUSTOM_ELEMENT:Z,DATA_ATTR:q,DOCTYPE_NAME:G,ERB_EXPR:F,IS_ALLOWED_URI:J,IS_SCRIPT_OR_DATA:W,MUSTACHE_EXPR:B,TMPLIT_EXPR:U});const X={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12};const Q=function t(){return typeof window==="undefined"?null:window};const tt=function t(e,n){if(typeof e!=="object"||typeof e.createPolicy!=="function"){return null}let r=null;const i="data-tt-policy-suffix";if(n&&n.hasAttribute(i)){r=n.getAttribute(i)}const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(t){return t},createScriptURL(t){return t}})}catch(t){console.warn("TrustedTypes policy "+s+" could not be created.");return null}};const et=function t(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function nt(){let e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:Q();const n=t=>nt(t);n.version="3.3.0";n.removed=[];if(!e||!e.document||e.document.nodeType!==X.document||!e.Element){n.isSupported=false;return n}let{document:r}=e;const i=r;const o=i.currentScript;const{DocumentFragment:u,HTMLTemplateElement:a,Node:S,Element:T,NodeFilter:A,NamedNodeMap:B=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:F,DOMParser:U,trustedTypes:q}=e;const K=T.prototype;const W=$(K,"cloneNode");const V=$(K,"remove");const Z=$(K,"nextSibling");const rt=$(K,"childNodes");const it=$(K,"parentNode");if(typeof a==="function"){const t=r.createElement("template");if(t.content&&t.content.ownerDocument){r=t.content.ownerDocument}}let st;let ot="";const{implementation:lt,createNodeIterator:ut,createDocumentFragment:at,getElementsByTagName:ft}=r;const{importNode:ht}=i;let ct=et();n.isSupported=typeof t==="function"&&typeof it==="function"&&lt&&lt.createHTMLDocument!==undefined;const{MUSTACHE_EXPR:dt,ERB_EXPR:pt,TMPLIT_EXPR:mt,DATA_ATTR:gt,ARIA_ATTR:wt,IS_SCRIPT_OR_DATA:bt,ATTR_WHITESPACE:vt,CUSTOM_ELEMENT:kt}=Y;let{IS_ALLOWED_URI:yt}=Y;let xt=null;const Mt=E({},[...R,...C,...L,...I,...D]);let St=null;const Tt=E({},[...H,..._,...j,...z]);let Et=Object.seal(l(null,{tagNameCheck:{writable:true,configurable:false,enumerable:true,value:null},attributeNameCheck:{writable:true,configurable:false,enumerable:true,value:null},allowCustomizedBuiltInElements:{writable:true,configurable:false,enumerable:true,value:false}}));let At=null;let Ot=null;const $t=Object.seal(l(null,{tagCheck:{writable:true,configurable:false,enumerable:true,value:null},attributeCheck:{writable:true,configurable:false,enumerable:true,value:null}}));let Rt=true;let Ct=true;let Lt=false;let Nt=true;let It=false;let Pt=true;let Dt=false;let Ht=false;let _t=false;let jt=false;let zt=false;let Bt=false;let Ft=true;let Ut=false;const qt="user-content-";let Kt=true;let Jt=false;let Wt={};let Vt=null;const Gt=E({},["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"]);let Zt=null;const Yt=E({},["audio","video","img","source","image","track"]);let Xt=null;const Qt=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]);const te="http://www.w3.org/1998/Math/MathML";const ee="http://www.w3.org/2000/svg";const ne="http://www.w3.org/1999/xhtml";let re=ne;let ie=false;let se=null;const oe=E({},[te,ee,ne],g);let le=E({},["mi","mo","mn","ms","mtext"]);let ue=E({},["annotation-xml"]);const ae=E({},["title","style","font","a","script"]);let fe=null;const he=["application/xhtml+xml","text/html"];const ce="text/html";let de=null;let pe=null;const me=r.createElement("form");const ge=function t(e){return e instanceof RegExp||e instanceof Function};const we=function t(){let e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(pe&&pe===e){return}if(!e||typeof e!=="object"){e={}}e=O(e);fe=he.indexOf(e.PARSER_MEDIA_TYPE)===-1?ce:e.PARSER_MEDIA_TYPE;de=fe==="application/xhtml+xml"?g:m;xt=y(e,"ALLOWED_TAGS")?E({},e.ALLOWED_TAGS,de):Mt;St=y(e,"ALLOWED_ATTR")?E({},e.ALLOWED_ATTR,de):Tt;se=y(e,"ALLOWED_NAMESPACES")?E({},e.ALLOWED_NAMESPACES,g):oe;Xt=y(e,"ADD_URI_SAFE_ATTR")?E(O(Qt),e.ADD_URI_SAFE_ATTR,de):Qt;Zt=y(e,"ADD_DATA_URI_TAGS")?E(O(Yt),e.ADD_DATA_URI_TAGS,de):Yt;Vt=y(e,"FORBID_CONTENTS")?E({},e.FORBID_CONTENTS,de):Gt;At=y(e,"FORBID_TAGS")?E({},e.FORBID_TAGS,de):O({});Ot=y(e,"FORBID_ATTR")?E({},e.FORBID_ATTR,de):O({});Wt=y(e,"USE_PROFILES")?e.USE_PROFILES:false;Rt=e.ALLOW_ARIA_ATTR!==false;Ct=e.ALLOW_DATA_ATTR!==false;Lt=e.ALLOW_UNKNOWN_PROTOCOLS||false;Nt=e.ALLOW_SELF_CLOSE_IN_ATTR!==false;It=e.SAFE_FOR_TEMPLATES||false;Pt=e.SAFE_FOR_XML!==false;Dt=e.WHOLE_DOCUMENT||false;jt=e.RETURN_DOM||false;zt=e.RETURN_DOM_FRAGMENT||false;Bt=e.RETURN_TRUSTED_TYPE||false;_t=e.FORCE_BODY||false;Ft=e.SANITIZE_DOM!==false;Ut=e.SANITIZE_NAMED_PROPS||false;Kt=e.KEEP_CONTENT!==false;Jt=e.IN_PLACE||false;yt=e.ALLOWED_URI_REGEXP||J;re=e.NAMESPACE||ne;le=e.MATHML_TEXT_INTEGRATION_POINTS||le;ue=e.HTML_INTEGRATION_POINTS||ue;Et=e.CUSTOM_ELEMENT_HANDLING||{};if(e.CUSTOM_ELEMENT_HANDLING&&ge(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)){Et.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck}if(e.CUSTOM_ELEMENT_HANDLING&&ge(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)){Et.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck}if(e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==="boolean"){Et.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements}if(It){Ct=false}if(zt){jt=true}if(Wt){xt=E({},D);St=[];if(Wt.html===true){E(xt,R);E(St,H)}if(Wt.svg===true){E(xt,C);E(St,_);E(St,z)}if(Wt.svgFilters===true){E(xt,L);E(St,_);E(St,z)}if(Wt.mathMl===true){E(xt,I);E(St,j);E(St,z)}}if(e.ADD_TAGS){if(typeof e.ADD_TAGS==="function"){$t.tagCheck=e.ADD_TAGS}else{if(xt===Mt){xt=O(xt)}E(xt,e.ADD_TAGS,de)}}if(e.ADD_ATTR){if(typeof e.ADD_ATTR==="function"){$t.attributeCheck=e.ADD_ATTR}else{if(St===Tt){St=O(St)}E(St,e.ADD_ATTR,de)}}if(e.ADD_URI_SAFE_ATTR){E(Xt,e.ADD_URI_SAFE_ATTR,de)}if(e.FORBID_CONTENTS){if(Vt===Gt){Vt=O(Vt)}E(Vt,e.FORBID_CONTENTS,de)}if(Kt){xt["#text"]=true}if(Dt){E(xt,["html","head","body"])}if(xt.table){E(xt,["tbody"]);delete At.tbody}if(e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=="function"){throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.')}if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=="function"){throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.')}st=e.TRUSTED_TYPES_POLICY;ot=st.createHTML("")}else{if(st===undefined){st=tt(q,o)}if(st!==null&&typeof ot==="string"){ot=st.createHTML("")}}if(s){s(e)}pe=e};const be=E({},[...C,...L,...N]);const ve=E({},[...I,...P]);const ke=function t(e){let n=it(e);if(!n||!n.tagName){n={namespaceURI:re,tagName:"template"}}const r=m(e.tagName);const i=m(n.tagName);if(!se[e.namespaceURI]){return false}if(e.namespaceURI===ee){if(n.namespaceURI===ne){return r==="svg"}if(n.namespaceURI===te){return r==="svg"&&(i==="annotation-xml"||le[i])}return Boolean(be[r])}if(e.namespaceURI===te){if(n.namespaceURI===ne){return r==="math"}if(n.namespaceURI===ee){return r==="math"&&ue[i]}return Boolean(ve[r])}if(e.namespaceURI===ne){if(n.namespaceURI===ee&&!ue[i]){return false}if(n.namespaceURI===te&&!le[i]){return false}return!ve[r]&&(ae[r]||!be[r])}if(fe==="application/xhtml+xml"&&se[e.namespaceURI]){return true}return false};const ye=function t(e){d(n.removed,{element:e});try{it(e).removeChild(e)}catch(t){V(e)}};const xe=function t(e,r){try{d(n.removed,{attribute:r.getAttributeNode(e),from:r})}catch(t){d(n.removed,{attribute:null,from:r})}r.removeAttribute(e);if(e==="is"){if(jt||zt){try{ye(r)}catch(t){}}else{try{r.setAttribute(e,"")}catch(t){}}}};const Me=function t(e){let n=null;let i=null;if(_t){e="<remove></remove>"+e}else{const t=w(e,/^[\r\n\t ]+/);i=t&&t[0]}if(fe==="application/xhtml+xml"&&re===ne){e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>"}const s=st?st.createHTML(e):e;if(re===ne){try{n=(new U).parseFromString(s,fe)}catch(t){}}if(!n||!n.documentElement){n=lt.createDocument(re,"template",null);try{n.documentElement.innerHTML=ie?ot:s}catch(t){}}const o=n.body||n.documentElement;if(e&&i){o.insertBefore(r.createTextNode(i),o.childNodes[0]||null)}if(re===ne){return ft.call(n,Dt?"html":"body")[0]}return Dt?n.documentElement:o};const Se=function t(e){return ut.call(e.ownerDocument||e,e,A.SHOW_ELEMENT|A.SHOW_COMMENT|A.SHOW_TEXT|A.SHOW_PROCESSING_INSTRUCTION|A.SHOW_CDATA_SECTION,null)};const Te=function t(e){return e instanceof F&&(typeof e.nodeName!=="string"||typeof e.textContent!=="string"||typeof e.removeChild!=="function"||!(e.attributes instanceof B)||typeof e.removeAttribute!=="function"||typeof e.setAttribute!=="function"||typeof e.namespaceURI!=="string"||typeof e.insertBefore!=="function"||typeof e.hasChildNodes!=="function")};const Ee=function t(e){return typeof S==="function"&&e instanceof S};function Ae(t,e,r){f(t,(t=>{t.call(n,e,r,pe)}))}const Oe=function t(e){let r=null;Ae(ct.beforeSanitizeElements,e,null);if(Te(e)){ye(e);return true}const i=de(e.nodeName);Ae(ct.uponSanitizeElement,e,{tagName:i,allowedTags:xt});if(Pt&&e.hasChildNodes()&&!Ee(e.firstElementChild)&&x(/<[/\w!]/g,e.innerHTML)&&x(/<[/\w!]/g,e.textContent)){ye(e);return true}if(e.nodeType===X.progressingInstruction){ye(e);return true}if(Pt&&e.nodeType===X.comment&&x(/<[/\w]/g,e.data)){ye(e);return true}if(!($t.tagCheck instanceof Function&&$t.tagCheck(i))&&(!xt[i]||At[i])){if(!At[i]&&Re(i)){if(Et.tagNameCheck instanceof RegExp&&x(Et.tagNameCheck,i)){return false}if(Et.tagNameCheck instanceof Function&&Et.tagNameCheck(i)){return false}}if(Kt&&!Vt[i]){const t=it(e)||e.parentNode;const n=rt(e)||e.childNodes;if(n&&t){const r=n.length;for(let i=r-1;i>=0;--i){const r=W(n[i],true);r.__removalCount=(e.__removalCount||0)+1;t.insertBefore(r,Z(e))}}}ye(e);return true}if(e instanceof T&&!ke(e)){ye(e);return true}if((i==="noscript"||i==="noembed"||i==="noframes")&&x(/<\/no(script|embed|frames)/i,e.innerHTML)){ye(e);return true}if(It&&e.nodeType===X.text){r=e.textContent;f([dt,pt,mt],(t=>{r=b(r,t," ")}));if(e.textContent!==r){d(n.removed,{element:e.cloneNode()});e.textContent=r}}Ae(ct.afterSanitizeElements,e,null);return false};const $e=function t(e,n,i){if(Ft&&(n==="id"||n==="name")&&(i in r||i in me)){return false}if(Ct&&!Ot[n]&&x(gt,n));else if(Rt&&x(wt,n));else if($t.attributeCheck instanceof Function&&$t.attributeCheck(n,e));else if(!St[n]||Ot[n]){if(Re(e)&&(Et.tagNameCheck instanceof RegExp&&x(Et.tagNameCheck,e)||Et.tagNameCheck instanceof Function&&Et.tagNameCheck(e))&&(Et.attributeNameCheck instanceof RegExp&&x(Et.attributeNameCheck,n)||Et.attributeNameCheck instanceof Function&&Et.attributeNameCheck(n,e))||n==="is"&&Et.allowCustomizedBuiltInElements&&(Et.tagNameCheck instanceof RegExp&&x(Et.tagNameCheck,i)||Et.tagNameCheck instanceof Function&&Et.tagNameCheck(i)));else{return false}}else if(Xt[n]);else if(x(yt,b(i,vt,"")));else if((n==="src"||n==="xlink:href"||n==="href")&&e!=="script"&&v(i,"data:")===0&&Zt[e]);else if(Lt&&!x(bt,b(i,vt,"")));else if(i){return false}else;return true};const Re=function t(e){return e!=="annotation-xml"&&w(e,kt)};const Ce=function t(e){Ae(ct.beforeSanitizeAttributes,e,null);const{attributes:r}=e;if(!r||Te(e)){return}const i={attrName:"",attrValue:"",keepAttr:true,allowedAttributes:St,forceKeepAttr:undefined};let s=r.length;while(s--){const t=r[s];const{name:o,namespaceURI:l,value:u}=t;const a=de(o);const h=u;let d=o==="value"?h:k(h);i.attrName=a;i.attrValue=d;i.keepAttr=true;i.forceKeepAttr=undefined;Ae(ct.uponSanitizeAttribute,e,i);d=i.attrValue;if(Ut&&(a==="id"||a==="name")){xe(o,e);d=qt+d}if(Pt&&x(/((--!?|])>)|<\/(style|title|textarea)/i,d)){xe(o,e);continue}if(a==="attributename"&&w(d,"href")){xe(o,e);continue}if(i.forceKeepAttr){continue}if(!i.keepAttr){xe(o,e);continue}if(!Nt&&x(/\/>/i,d)){xe(o,e);continue}if(It){f([dt,pt,mt],(t=>{d=b(d,t," ")}))}const p=de(e.nodeName);if(!$e(p,a,d)){xe(o,e);continue}if(st&&typeof q==="object"&&typeof q.getAttributeType==="function"){if(l);else{switch(q.getAttributeType(p,a)){case"TrustedHTML":{d=st.createHTML(d);break}case"TrustedScriptURL":{d=st.createScriptURL(d);break}}}}if(d!==h){try{if(l){e.setAttributeNS(l,o,d)}else{e.setAttribute(o,d)}if(Te(e)){ye(e)}else{c(n.removed)}}catch(t){xe(o,e)}}}Ae(ct.afterSanitizeAttributes,e,null)};const Le=function t(e){let n=null;const r=Se(e);Ae(ct.beforeSanitizeShadowDOM,e,null);while(n=r.nextNode()){Ae(ct.uponSanitizeShadowNode,n,null);Oe(n);Ce(n);if(n.content instanceof u){t(n.content)}}Ae(ct.afterSanitizeShadowDOM,e,null)};n.sanitize=function(t){let e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};let r=null;let s=null;let o=null;let l=null;ie=!t;if(ie){t="\x3c!--\x3e"}if(typeof t!=="string"&&!Ee(t)){if(typeof t.toString==="function"){t=t.toString();if(typeof t!=="string"){throw M("dirty is not a string, aborting")}}else{throw M("toString is not a function")}}if(!n.isSupported){return t}if(!Ht){we(e)}n.removed=[];if(typeof t==="string"){Jt=false}if(Jt){if(t.nodeName){const e=de(t.nodeName);if(!xt[e]||At[e]){throw M("root node is forbidden and cannot be sanitized in-place")}}}else if(t instanceof S){r=Me("\x3c!----\x3e");s=r.ownerDocument.importNode(t,true);if(s.nodeType===X.element&&s.nodeName==="BODY"){r=s}else if(s.nodeName==="HTML"){r=s}else{r.appendChild(s)}}else{if(!jt&&!It&&!Dt&&t.indexOf("<")===-1){return st&&Bt?st.createHTML(t):t}r=Me(t);if(!r){return jt?null:Bt?ot:""}}if(r&&_t){ye(r.firstChild)}const a=Se(Jt?t:r);while(o=a.nextNode()){Oe(o);Ce(o);if(o.content instanceof u){Le(o.content)}}if(Jt){return t}if(jt){if(zt){l=at.call(r.ownerDocument);while(r.firstChild){l.appendChild(r.firstChild)}}else{l=r}if(St.shadowroot||St.shadowrootmode){l=ht.call(i,l,true)}return l}let h=Dt?r.outerHTML:r.innerHTML;if(Dt&&xt["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&x(G,r.ownerDocument.doctype.name)){h="<!DOCTYPE "+r.ownerDocument.doctype.name+">\n"+h}if(It){f([dt,pt,mt],(t=>{h=b(h,t," ")}))}return st&&Bt?st.createHTML(h):h};n.setConfig=function(){let t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};we(t);Ht=true};n.clearConfig=function(){pe=null;Ht=false};n.isValidAttribute=function(t,e,n){if(!pe){we({})}const r=de(t);const i=de(e);return $e(r,i,n)};n.addHook=function(t,e){if(typeof e!=="function"){return}d(ct[t],e)};n.removeHook=function(t,e){if(e!==undefined){const n=h(ct[t],e);return n===-1?undefined:p(ct[t],n,1)[0]}return c(ct[t])};n.removeHooks=function(t){ct[t]=[]};n.removeAllHooks=function(){ct=et()};return n}var rt=nt();return rt}))})(d);const p=d.exports;function m(t){return{value:p.sanitize(t,{ADD_TAGS:["pos-rich-link","pos-image"],ADD_ATTR:["uri"]})}}function g(t){this.content=t}g.prototype={constructor:g,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?undefined:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this;var i=r.find(t),s=r.content.slice();if(i==-1){s.push(n||t,e)}else{s[i+1]=e;if(n)s[i]=n}return new g(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();n.splice(e,2);return new g(n)},addToStart:function(t,e){return new g([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();n.push(t,e);return new g(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice();var s=r.find(t);i.splice(s==-1?i.length:s,0,e,n);return new g(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){t=g.from(t);if(!t.size)return this;return new g(t.content.concat(this.subtract(t).content))},append:function(t){t=g.from(t);if(!t.size)return this;return new g(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=g.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};this.forEach((function(e,n){t[e]=n}));return t},get size(){return this.content.length>>1}};g.from=function(t){if(t instanceof g)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new g(e)};function w(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let t=0;i.text[t]==s.text[t];t++)n++;return n}if(i.content.size||s.content.size){let t=w(i.content,s.content,n+1);if(t!=null)return t}n+=i.nodeSize}}function b(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),u=o.nodeSize;if(o==l){n-=u;r-=u;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let t=0,e=Math.min(o.text.length,l.text.length);while(t<e&&o.text[o.text.length-t-1]==l.text[l.text.length-t-1]){t++;n--;r--}return{a:n,b:r}}if(o.content.size||l.content.size){let t=b(o.content,l.content,n-1,r-1);if(t)return t}n-=u;r-=u}}class v{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,r=0,i){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&n(l,r+o,i||null,s)!==false&&l.content.size){let i=o+1;l.nodesBetween(Math.max(0,t-i),Math.min(l.content.size,e-i),n,r+i)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let i="",s=true;this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):!o.isLeaf?"":r?typeof r==="function"?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"";if(o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&n){if(s)s=false;else i+=n}i+=u}),0);return i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),i=0;if(e.isText&&e.sameMarkup(n)){r[r.length-1]=e.withText(e.text+n.text);i=1}for(;i<t.content.length;i++)r.push(t.content[i]);return new v(r,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let n=[],r=0;if(e>t)for(let i=0,s=0;s<e;i++){let o=this.content[i],l=s+o.nodeSize;if(l>t){if(s<t||l>e){if(o.isText)o=o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s));else o=o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))}n.push(o);r+=o.nodeSize}s=l}return new v(n,r)}cutByIndex(t,e){if(t==e)return v.empty;if(t==0&&e==this.content.length)return this;return new v(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice();let i=this.size+e.nodeSize-n.nodeSize;r[t]=e;return new v(r,i)}addToStart(t){return new v([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new v(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e);n+=r.nodeSize}}findDiffStart(t,e=0){return w(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return b(this,t,e,n)}findIndex(t){if(t==0)return y(0,t);if(t==this.size)return y(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,n=0;;e++){let r=this.child(e),i=n+r.nodeSize;if(i>=t){if(i==t)return y(e+1,i);return y(e,n)}n=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return v.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new v(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return v.empty;let e,n=0;for(let r=0;r<t.length;r++){let i=t[r];n+=i.nodeSize;if(r&&i.isText&&t[r-1].sameMarkup(i)){if(!e)e=t.slice(0,r);e[e.length-1]=i.withText(e[e.length-1].text+i.text)}else if(e){e.push(i)}}return new v(e||t,n)}static from(t){if(!t)return v.empty;if(t instanceof v)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new v([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}v.empty=new v([],0);const k={index:0,offset:0};function y(t,e){k.index=t;k.offset=e;return k}function x(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let n=Array.isArray(t);if(Array.isArray(e)!=n)return false;if(n){if(t.length!=e.length)return false;for(let n=0;n<t.length;n++)if(!x(t[n],e[n]))return false}else{for(let n in t)if(!(n in e)||!x(t[n],e[n]))return false;for(let n in e)if(!(n in t))return false}return true}class M{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,n=false;for(let r=0;r<t.length;r++){let i=t[r];if(this.eq(i))return t;if(this.type.excludes(i.type)){if(!e)e=t.slice(0,r)}else if(i.type.excludes(this.type)){return t}else{if(!n&&i.type.rank>this.type.rank){if(!e)e=t.slice(0,r);e.push(this);n=true}if(e)e.push(i)}}if(!e)e=t.slice();if(!n)e.push(this);return e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return true;return false}eq(t){return this==t||this.type==t.type&&x(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=n.create(e.attrs);n.checkAttrs(r.attrs);return r}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return M.none;if(t instanceof M)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}M.none=[];class S extends Error{}class T{constructor(t,e,n){this.content=t;this.openStart=e;this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=A(this.content,t+this.openStart,e);return n&&new T(n,this.openStart,this.openEnd)}removeBetween(t,e){return new T(E(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};if(this.openStart>0)t.openStart=this.openStart;if(this.openEnd>0)t.openEnd=this.openEnd;return t}static fromJSON(t,e){if(!e)return T.empty;let n=e.openStart||0,r=e.openEnd||0;if(typeof n!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new T(v.fromJSON(t,e.content),n,r)}static maxOpen(t,e=true){let n=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)r++;return new T(t,n,r)}}T.empty=new T(v.empty,0,0);function E(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r);let{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(E(s.content,e-i-1,n-i-1)))}function A(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText){if(r&&!r.canReplace(i,i,n))return null;return t.cut(0,e).append(n).append(t.cut(e))}let l=A(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function O(t,e,n){if(n.openStart>t.depth)throw new S("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new S("Inconsistent open depths");return $(t,e,n,0)}function $(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=$(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(!n.content.size){return I(s,D(t,e,r))}else if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let r=t.parent,i=r.content;return I(r,i.cut(0,t.parentOffset).append(n.content).append(i.cut(e.parentOffset)))}else{let{start:i,end:o}=H(n,t);return I(s,P(t,i,o,e,r))}}function R(t,e){if(!e.type.compatibleContent(t.type))throw new S("Cannot join "+e.type.name+" onto "+t.type.name)}function C(t,e,n){let r=t.node(n);R(r,e.node(n));return r}function L(t,e){let n=e.length-1;if(n>=0&&t.isText&&t.sameMarkup(e[n]))e[n]=t.withText(e[n].text+t.text);else e.push(t)}function N(t,e,n,r){let i=(e||t).node(n);let s=0,o=e?e.index(n):i.childCount;if(t){s=t.index(n);if(t.depth>n){s++}else if(t.textOffset){L(t.nodeAfter,r);s++}}for(let t=s;t<o;t++)L(i.child(t),r);if(e&&e.depth==n&&e.textOffset)L(e.nodeBefore,r)}function I(t,e){t.type.checkContent(e);return t.copy(e)}function P(t,e,n,r,i){let s=t.depth>i&&C(t,e,i+1);let o=r.depth>i&&C(n,r,i+1);let l=[];N(null,t,i,l);if(s&&o&&e.index(i)==n.index(i)){R(s,o);L(I(s,P(t,e,n,r,i+1)),l)}else{if(s)L(I(s,D(t,e,i+1)),l);N(e,n,i,l);if(o)L(I(o,D(n,r,i+1)),l)}N(r,null,i,l);return new v(l)}function D(t,e,n){let r=[];N(null,t,n,r);if(t.depth>n){let i=C(t,e,n+1);L(I(i,D(t,e,n+1)),r)}N(e,null,n,r);return new v(r)}function H(t,e){let n=e.depth-t.openStart,r=e.node(n);let i=r.copy(t.content);for(let t=n-1;t>=0;t--)i=e.node(t).copy(v.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class _{constructor(t,e,n){this.pos=t;this.path=e;this.parentOffset=n;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[e*3],r=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)r+=n.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return M.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let t=n;n=r;r=t}let i=n.marks;for(var s=0;s<i.length;s++)if(i[s].type.spec.inclusive===false&&(!r||!i[s].isInSet(r.marks)))i=i[s--].removeFromSet(i);return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var i=0;i<n.length;i++)if(n[i].type.spec.inclusive===false&&(!r||!n[i].isInSet(r.marks)))n=n[i--].removeFromSet(n);return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new F(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[];let r=0,i=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(i);let o=i-s;n.push(e,t,r+s);if(!o)break;e=e.child(t);if(e.isText)break;i=o-1;r+=s+1}return new _(e,n,i)}static resolveCached(t,e){let n=B.get(t);if(n){for(let t=0;t<n.elts.length;t++){let r=n.elts[t];if(r.pos==e)return r}}else{B.set(t,n=new j)}let r=n.elts[n.i]=_.resolve(t,e);n.i=(n.i+1)%z;return r}}class j{constructor(){this.elts=[];this.i=0}}const z=12,B=new WeakMap;class F{constructor(t,e,n){this.$from=t;this.$to=e;this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const U=Object.create(null);class q{constructor(t,e,n,r=M.none){this.type=t;this.attrs=e;this.marks=r;this.content=n||v.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&x(this.attrs,e||t.defaultAttrs||U)&&M.sameSet(this.marks,n||M.none)}copy(t=null){if(t==this.content)return this;return new q(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new q(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){if(t==0&&e==this.content.size)return this;return this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=false){if(t==e)return T.empty;let r=this.resolve(t),i=this.resolve(e);let s=n?0:r.sharedDepth(e);let o=r.start(s),l=r.node(s);let u=l.content.cut(r.pos-o,i.pos-o);return new T(u,r.depth-s,i.depth-s)}replace(t,e,n){return O(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);e=e.maybeChild(n);if(!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return _.resolveCached(this,t)}resolveNoCache(t){return _.resolve(this,t)}rangeHasMark(t,e,n){let r=false;if(e>t)this.nodesBetween(t,e,(t=>{if(n.isInSet(t.marks))r=true;return!r}));return 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 t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return J(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=v.empty,r=0,i=n.childCount){let s=this.contentMatchAt(t).matchFragment(n,r,i);let o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return false;for(let t=r;t<i;t++)if(!this.type.allowsMarks(n.child(t).marks))return false;return true}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return false;let i=this.contentMatchAt(t).matchType(n);let s=i&&i.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);this.type.checkAttrs(this.attrs);let t=M.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs);t=n.addToSet(t)}if(!M.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}if(this.content.size)t.content=this.content.toJSON();if(this.marks.length)t.marks=this.marks.map((t=>t.toJSON()));return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=v.fromJSON(t,e.content);let i=t.nodeType(e.type).create(e.attrs,r,n);i.type.checkAttrs(i.attrs);return i}}q.prototype.text=undefined;class K extends q{constructor(t,e,n,r){super(t,e,null,r);if(!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return J(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new K(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new K(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){if(t==0&&e==this.text.length)return this;return this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();t.text=this.text;return t}}function J(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class W{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let n=new V(t,e);if(n.next==null)return W.empty;let r=G(n);if(n.next)n.err("Unexpected trailing text");let i=st(nt(r));ot(i,n);return i}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let i=e;r&&i<n;i++)r=r.matchType(t.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return true;return false}fillBefore(t,e=false,n=0){let r=[this];function i(s,o){let l=s.matchFragment(t,n);if(l&&(!e||l.validEnd))return v.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:n}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let t=i(n,o.concat(e));if(t)return t}}return null}return i(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];while(n.length){let r=n.shift(),i=r.match;if(i.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!r.type||o.validEnd)){n.push({match:s.contentMatch,type:s,via:r});e[s.name]=true}}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(n){t.push(n);for(let r=0;r<n.next.length;r++)if(t.indexOf(n.next[r].next)==-1)e(n.next[r].next)}e(this);return t.map(((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)r+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return r})).join("\n")}}W.empty=new W(true);class V{constructor(t,e){this.string=t;this.nodeTypes=e;this.inline=null;this.pos=0;this.tokens=t.split(/\s*(?=\b|\W|$)/);if(this.tokens[this.tokens.length-1]=="")this.tokens.pop();if(this.tokens[0]=="")this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||true)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function G(t){let e=[];do{e.push(Z(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Z(t){let e=[];do{e.push(Y(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Y(t){let e=et(t);for(;;){if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Q(t,e);else break}return e}function X(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function Q(t,e){let n=X(t),r=n;if(t.eat(",")){if(t.next!="}")r=X(t);else r=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:n,max:r,expr:e}}function tt(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let t in n){let r=n[t];if(r.isInGroup(e))i.push(r)}if(i.length==0)t.err("No node type or group '"+e+"' found");return i}function et(t){if(t.eat("(")){let e=G(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=tt(t,t.next).map((e=>{if(t.inline==null)t.inline=e.isInline;else if(t.inline!=e.isInline)t.err("Mixing inline and block content");return{type:"name",value:e}}));t.pos++;return e.length==1?e[0]:{type:"choice",exprs:e}}else{t.err("Unexpected token '"+t.next+"'")}}function nt(t){let e=[[]];i(s(t,0),n());return e;function n(){return e.push([])-1}function r(t,n,r){let i={term:r,to:n};e[t].push(i);return i}function i(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,n)=>t.concat(s(n,e))),[])}else if(t.type=="seq"){for(let r=0;;r++){let o=s(t.exprs[r],e);if(r==t.exprs.length-1)return o;i(o,e=n())}}else if(t.type=="star"){let o=n();r(e,o);i(s(t.expr,o),o);return[r(o)]}else if(t.type=="plus"){let o=n();i(s(t.expr,e),o);i(s(t.expr,o),o);return[r(o)]}else if(t.type=="opt"){return[r(e)].concat(s(t.expr,e))}else if(t.type=="range"){let o=e;for(let e=0;e<t.min;e++){let e=n();i(s(t.expr,o),e);o=e}if(t.max==-1){i(s(t.expr,o),o)}else{for(let e=t.min;e<t.max;e++){let e=n();r(o,e);i(s(t.expr,o),e);o=e}}return[r(o)]}else if(t.type=="name"){return[r(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function rt(t,e){return e-t}function it(t,e){let n=[];r(e);return n.sort(rt);function r(e){let i=t[e];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(e);for(let t=0;t<i.length;t++){let{term:e,to:s}=i[t];if(!e&&n.indexOf(s)==-1)r(s)}}}function st(t){let e=Object.create(null);return n(it(t,0));function n(r){let i=[];r.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<i.length;t++)if(i[t][0]==e)r=i[t][1];it(t,n).forEach((t=>{if(!r)i.push([e,r=[]]);if(r.indexOf(t)==-1)r.push(t)}))}))}));let s=e[r.join(",")]=new W(r.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let r=i[t][1].sort(rt);s.next.push({type:i[t][0],next:e[r.join(",")]||n(r)})}return s}}function ot(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:n,next:o}=t.next[e];s.push(n.name);if(i&&!(n.isText||n.hasRequiredAttrs()))i=false;if(r.indexOf(o)==-1)r.push(o)}if(i)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function lt(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function ut(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===undefined){let e=t[r];if(e.hasDefault)i=e.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function at(t,e,n,r){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in t){let r=t[n];if(r.validate)r.validate(e[n])}}function ft(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new dt(t,r,e[r]);return n}class ht{constructor(t,e,n){this.name=t;this.schema=e;this.spec=n;this.markSet=null;this.groups=n.group?n.group.split(" "):[];this.attrs=ft(t,n.attrs);this.defaultAttrs=lt(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(n.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==W.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return ut(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new q(this,this.computeAttrs(t),v.from(e),M.setFrom(n))}createChecked(t=null,e,n){e=v.from(e);this.checkContent(e);return new q(this,this.computeAttrs(t),e,M.setFrom(n))}createAndFill(t=null,e,n){t=this.computeAttrs(t);e=v.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e);let i=r&&r.fillBefore(v.empty,true);if(!i)return null;return new q(this,t,e.append(i),M.setFrom(n))}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return false;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return false;return true}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){at(this.attrs,t,"node")}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return true;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return false;return true}allowedMarks(t){if(this.markSet==null)return t;let e;for(let n=0;n<t.length;n++){if(!this.allowsMarkType(t[n].type)){if(!e)e=t.slice(0,n)}else if(e){e.push(t[n])}}return!e?t:e.length?e:M.none}static compile(t,e){let n=Object.create(null);t.forEach(((t,r)=>n[t]=new ht(t,e,r)));let r=e.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 t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}function ct(t,e,n){let r=n.split("|");return n=>{let i=n===null?"null":typeof n;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class dt{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default");this.default=n.default;this.validate=typeof n.validate=="string"?ct(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class pt{constructor(t,e,n,r){this.name=t;this.rank=e;this.schema=n;this.spec=r;this.attrs=ft(t,r.attrs);this.excluded=null;let i=lt(this.attrs);this.instance=i?new M(this,i):null}create(t=null){if(!t&&this.instance)return this.instance;return new M(this,ut(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;t.forEach(((t,i)=>n[t]=new pt(t,r++,e,i)));return n}removeFromSet(t){for(var e=0;e<t.length;e++)if(t[e].type==this){t=t.slice(0,e).concat(t.slice(e+1));e--}return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){at(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class mt{constructor(t){this.linebreakReplacement=null;this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=g.from(t.nodes),e.marks=g.from(t.marks||{}),this.nodes=ht.compile(this.spec.nodes,this);this.marks=pt.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",i=e.spec.marks;e.contentMatch=n[r]||(n[r]=W.parse(r,this.nodes));e.inlineContent=e.contentMatch.inlineContent;if(e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet=i=="_"?null:i?gt(this,i.split(" ")):i==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=n==null?[e]:n==""?[]:gt(this,n.split(" "))}this.nodeFromJSON=t=>q.fromJSON(this,t);this.markFromJSON=t=>M.fromJSON(this,t);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,n,r){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof ht))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new K(n,n.defaultAttrs,t,M.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function gt(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s){n.push(s)}else{for(let e in t.marks){let r=t.marks[e];if(i=="_"||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)n.push(o=r)}}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function wt(t){return t.tag!=null}function bt(t){return t.style!=null}class vt{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let n=this.matchedStyles=[];e.forEach((t=>{if(wt(t)){this.tags.push(t)}else if(bt(t)){let e=/[^=]*/.exec(t.style)[0];if(n.indexOf(e)<0)n.push(e);this.styles.push(t)}}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new Ot(this,e,false);n.addAll(t,M.none,e.from,e.to);return n.finish()}parseSlice(t,e={}){let n=new Ot(this,e,true);n.addAll(t,M.none,e.from,e.to);return T.maxOpen(n.finish())}matchTag(t,e,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Rt(t,n.tag)&&(n.namespace===undefined||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(e===false)continue;n.attrs=e||undefined}return n}}}matchStyle(t,e,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(s.indexOf(t)!=0||r.context&&!n.matchesContext(r.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(r.getAttrs){let t=r.getAttrs(e);if(t===false)continue;r.attrs=t||undefined}return r}}static schemaRules(t){let e=[];function n(t){let n=t.priority==null?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r],i=t.priority==null?50:t.priority;if(i<n)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;if(r)r.forEach((t=>{n(t=Ct(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;if(r)r.forEach((t=>{n(t=Ct(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new vt(t,vt.schemaRules(t)))}}const kt={address:true,article:true,aside:true,blockquote:true,canvas:true,dd:true,div:true,dl:true,fieldset:true,figcaption:true,figure:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,li:true,noscript:true,ol:true,output:true,p:true,pre:true,section:true,table:true,tfoot:true,ul:true};const yt={head:true,noscript:true,object:true,script:true,style:true,title:true};const xt={ol:true,ul:true};const Mt=1,St=2,Tt=4;function Et(t,e,n){if(e!=null)return(e?Mt:0)|(e==="full"?St:0);return t&&t.whitespace=="pre"?Mt|St:n&~Tt}class At{constructor(t,e,n,r,i,s){this.type=t;this.attrs=e;this.marks=n;this.solid=r;this.options=s;this.content=[];this.activeMarks=M.none;this.match=i||(s&Tt?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(v.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,n;if(n=e.findWrapping(t.type)){this.match=e;return n}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Mt)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let e=v.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(v.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!kt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Ot{constructor(t,e,n){this.parser=t;this.options=e;this.isOpen=n;this.open=0;this.localPreserveWS=false;let r=e.topNode,i;let s=Et(null,e.preserveWhitespace,0)|(n?Tt:0);if(r)i=new At(r.type,r.attrs,M.none,true,e.topMatch||r.type.contentMatch,s);else if(n)i=new At(null,null,M.none,true,null,s);else i=new At(t.schema.topNodeType,null,M.none,true,null,s);this.nodes=[i];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t,e){if(t.nodeType==3)this.addTextNode(t,e);else if(t.nodeType==1)this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue;let r=this.top,i=r.options&St?"full":this.localPreserveWS||(r.options&Mt)>0;if(i==="full"||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(!i){n=n.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let e=r.content[r.content.length-1];let i=t.previousSibling;if(!e||i&&i.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))n=n.slice(1)}}else if(i!=="full"){n=n.replace(/\r?\n|\r/g," ")}else{n=n.replace(/\r\n?/g,"\n")}if(n)this.insertNode(this.parser.schema.text(n),e,!/\S/.test(n));this.findInText(t)}else{this.findInside(t)}}addElement(t,e,n){let r=this.localPreserveWS,i=this.top;if(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))this.localPreserveWS=true;let s=t.nodeName.toLowerCase(),o;if(xt.hasOwnProperty(s)&&this.parser.normalizeLists)$t(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(o=this.parser.matchTag(t,this,n));t:if(l?l.ignore:yt.hasOwnProperty(s)){this.findInside(t);this.ignoreFallback(t,e)}else if(!l||l.skip||l.closeParent){if(l&&l.closeParent)this.open=Math.max(0,this.open-1);else if(l&&l.skip.nodeType)t=l.skip;let n,r=this.needsBlock;if(kt.hasOwnProperty(s)){if(i.content.length&&i.content[0].isInline&&this.open){this.open--;i=this.top}n=true;if(!i.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t,e);break t}let o=l&&l.skip?e:this.readStyles(t,e);if(o)this.addAll(t,o);if(n)this.sync(i);this.needsBlock=r}else{let n=this.readStyles(t,e);if(n)this.addElementByRule(t,l,n,l.consuming===false?o:undefined)}this.localPreserveWS=r}leafFallback(t,e){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"),e,true)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let r=this.parser.matchedStyles[t],i=n.getPropertyValue(r);if(i)for(let t=undefined;;){let n=this.parser.matchStyle(r,i,this,t);if(!n)break;if(n.ignore)return null;if(n.clearMark)e=e.filter((t=>!n.clearMark(t)));else e=e.concat(this.parser.schema.marks[n.mark].create(n.attrs));if(n.consuming===false)t=n;else break}}return e}addElementByRule(t,e,n,r){let i,s;if(e.node){s=this.parser.schema.nodes[e.node];if(!s.isLeaf){let t=this.enter(s,e.attrs||null,n,e.preserveWhitespace);if(t){i=true;n=t}}else if(!this.insertNode(s.create(e.attrs),n,t.nodeName=="BR")){this.leafFallback(t,n)}}else{let t=this.parser.schema.marks[e.mark];n=n.concat(t.create(e.attrs))}let o=this.top;if(s&&s.isLeaf){this.findInside(t)}else if(r){this.addElement(t,n,r)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,n,false)))}else{let r=t;if(typeof e.contentElement=="string")r=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")r=e.contentElement(t);else if(e.contentElement)r=e.contentElement;this.findAround(t,r,true);this.addAll(r,n);this.findAround(t,r,false)}if(i&&this.sync(o))this.open--}addAll(t,e,n,r){let i=n||0;for(let s=n?t.childNodes[n]:t.firstChild,o=r==null?null:t.childNodes[r];s!=o;s=s.nextSibling,++i){this.findAtPoint(t,i);this.addDOM(s,e)}this.findAtPoint(t,i)}findPlace(t,e,n){let r,i;for(let e=this.open,s=0;e>=0;e--){let o=this.nodes[e];let l=o.findWrapping(t);if(l&&(!r||r.length>l.length+s)){r=l;i=o;if(!l.length)break}if(o.solid){if(n)break;s+=2}}if(!r)return null;this.sync(i);for(let t=0;t<r.length;t++)e=this.enterInner(r[t],null,e,false);return e}insertNode(t,e,n){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)e=this.enterInner(t,null,e)}let r=this.findPlace(t,e,n);if(r){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let n=M.none;for(let i of r.concat(t.marks))if(e.type?e.type.allowsMarkType(i.type):Lt(i.type,t.type))n=i.addToSet(n);e.content.push(t.mark(n));return true}return false}enter(t,e,n,r){let i=this.findPlace(t.create(e),n,false);if(i)i=this.enterInner(t,e,n,true,r);return i}enterInner(t,e,n,r=false,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let o=Et(t,i,s.options);if(s.options&Tt&&s.content.length==0)o|=Tt;let l=M.none;n=n.filter((e=>{if(s.type?s.type.allowsMarkType(e.type):Lt(e.type,t)){l=e.addToSet(l);return false}return true}));this.nodes.push(new At(t,e,l,r,null,o));this.open++;return n}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t){this.open=e;return true}else if(this.localPreserveWS){this.nodes[e].options|=Mt}}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++){if(this.find[n].node==t&&this.find[n].offset==e)this.find[n].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,n){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].pos==null&&t.nodeType==1&&t.contains(this.find[r].node)){let t=e.compareDocumentPosition(this.find[r].node);if(t&(n?2:4))this.find[r].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].node==t)this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset)}}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/");let n=this.options.context;let r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type);let i=-(n?n.depth+1:0)+(r?0:1);let s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(l==""){if(t==e.length-1||t==0)continue;for(;o>=i;o--)if(s(t-1,o))return true;return false}else{let t=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return false;o--}}return true};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function $t(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&xt.hasOwnProperty(t)&&n){n.appendChild(e);e=n}else if(t=="li"){n=e}else if(t){n=null}}}function Rt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ct(t){let e={};for(let n in t)e[n]=t[n];return e}function Lt(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let n=0;n<t.edgeCount;n++){let{type:r,next:i}=t.edge(n);if(r==e)return true;if(s.indexOf(i)<0&&o(i))return true}};if(o(i.contentMatch))return true}}class Nt{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},n){if(!n)n=Pt(e).createDocumentFragment();let r=n,i=[];t.forEach((t=>{if(i.length||t.marks.length){let n=0,s=0;while(n<i.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(i[n][0])||e.type.spec.spanning===false)break;n++;s++}while(n<i.length)r=i.pop()[1];while(s<t.marks.length){let n=t.marks[s++];let o=this.serializeMark(n,t.isInline,e);if(o){i.push([n,r]);r.appendChild(o.dom);r=o.contentDOM||o.dom}}}r.appendChild(this.serializeNodeInner(t,e))}));return n}serializeNodeInner(t,e){let{dom:n,contentDOM:r}=jt(Pt(e),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let i=this.serializeMark(t.marks[r],t.isInline,e);if(i){(i.contentDOM||i.dom).appendChild(n);n=i.dom}}return n}serializeMark(t,e,n={}){let r=this.marks[t.type.name];return r&&jt(Pt(n),r(t,e),null,t.attrs)}static renderSpec(t,e,n=null,r){return jt(t,e,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Nt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=It(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return It(t.marks)}}function It(t){let e={};for(let n in t){let r=t[n].spec.toDOM;if(r)e[n]=r}return e}function Pt(t){return t.document||window.document}const Dt=new WeakMap;function Ht(t){let e=Dt.get(t);if(e===undefined)Dt.set(t,e=_t(t));return e}function _t(t){let e=null;function n(t){if(t&&typeof t=="object"){if(Array.isArray(t)){if(typeof t[0]=="string"){if(!e)e=[];e.push(t)}else{for(let e=0;e<t.length;e++)n(t[e])}}else{for(let e in t)n(t[e])}}}n(t);return e}function jt(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ht(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");if(o>0){n=i.slice(0,o);i=i.slice(o+1)}let l;let u=n?t.createElementNS(n,i):t.createElement(i);let a=e[1],f=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){f=2;for(let t in a)if(a[t]!=null){let e=t.indexOf(" ");if(e>0)u.setAttributeNS(t.slice(0,e),t.slice(e+1),a[t]);else if(t=="style"&&u.style)u.style.cssText=a[t];else u.setAttribute(t,a[t])}}for(let i=f;i<e.length;i++){let s=e[i];if(s===0){if(i<e.length-1||i>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:e,contentDOM:i}=jt(t,s,n,r);u.appendChild(e);if(i){if(l)throw new RangeError("Multiple content holes");l=i}}}return{dom:u,contentDOM:l}}const zt=65535;const Bt=Math.pow(2,16);function Ft(t,e){return t+e*Bt}function Ut(t){return t&zt}function qt(t){return(t-(t&zt))/Bt}const Kt=1,Jt=2,Wt=4,Vt=8;class Gt{constructor(t,e,n){this.pos=t;this.delInfo=e;this.recover=n}get deleted(){return(this.delInfo&Vt)>0}get deletedBefore(){return(this.delInfo&(Kt|Wt))>0}get deletedAfter(){return(this.delInfo&(Jt|Wt))>0}get deletedAcross(){return(this.delInfo&Wt)>0}}class Zt{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Zt.empty)return Zt.empty}recover(t){let e=0,n=Ut(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[n*3]+e+qt(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>t)break;let u=this.ranges[o+i],a=this.ranges[o+s],f=l+u;if(t<=f){let i=!u?e:t==l?-1:t==f?1:e;let s=l+r+(i<0?0:a);if(n)return s;let h=t==(e<0?l:f)?null:Ft(o/3,t-l);let c=t==l?Jt:t==f?Kt:Wt;if(e<0?t!=l:t!=f)c|=Vt;return new Gt(s,c,h)}r+=a-u}return n?t+r:new Gt(t+r,0,null)}touches(t,e){let n=0,r=Ut(e);let i=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?n:0);if(o>t)break;let l=this.ranges[e+i],u=o+l;if(t<=u&&e==r*3)return true;n+=this.ranges[e+s]-l}return false}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i);let u=this.ranges[r+e],a=this.ranges[r+n];t(o,o+u,l,l+a);i+=a-u}}invert(){return new Zt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Zt.empty:new Zt(t<0?[0,-t,0]:[0,0,t])}}Zt.empty=new Zt([]);class Yt{constructor(t,e,n=0,r=(t?t.length:0)){this.mirror=e;this.from=n;this.to=r;this._maps=t||[];this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new Yt(this._maps,this.mirror,t,e)}appendMap(t,e){if(!this.ownData){this._maps=this._maps.slice();this.mirror=this.mirror&&this.mirror.slice();this.ownData=true}this.to=this._maps.push(t);if(e!=null)this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,n=this._maps.length;e<t._maps.length;e++){let r=t.getMirror(e);this.appendMap(t._maps[e],r!=null&&r<e?n+r:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this._maps.length+t._maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t._maps[e].invert(),r!=null&&r>e?n-r-1:undefined)}}invert(){let t=new Yt;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let n=this.from;n<this.to;n++)t=this._maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n],s=i.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(n);if(e!=null&&e>n&&e<this.to){n=e;t=this._maps[e].recover(s.recover);continue}}r|=s.delInfo;t=s.pos}return n?t:new Gt(t,r,null)}}const Xt=Object.create(null);class Qt{getMap(){return Zt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Xt[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Xt)throw new RangeError("Duplicate use of step JSON ID "+t);Xt[t]=e;e.prototype.jsonID=t;return e}}class te{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new te(t,null)}static fail(t){return new te(null,t)}static fromReplace(t,e,n,r){try{return te.ok(t.replace(e,n,r))}catch(t){if(t instanceof S)return te.fail(t.message);throw t}}}function ee(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);if(s.content.size)s=s.copy(ee(s.content,e,s));if(s.isInline)s=e(s,n,i);r.push(s)}return v.fromArray(r)}class ne extends Qt{constructor(t,e,n){super();this.from=t;this.to=e;this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from);let r=n.node(n.sharedDepth(this.to));let i=new T(ee(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),r),e.openStart,e.openEnd);return te.fromReplace(t,this.from,this.to,i)}invert(){return new re(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);if(e.deleted&&n.deleted||e.pos>=n.pos)return null;return new ne(e.pos,n.pos,this.mark)}merge(t){if(t instanceof ne&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new ne(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ne(e.from,e.to,t.markFromJSON(e.mark))}}Qt.jsonID("addMark",ne);class re extends Qt{constructor(t,e,n){super();this.from=t;this.to=e;this.mark=n}apply(t){let e=t.slice(this.from,this.to);let n=new T(ee(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return te.fromReplace(t,this.from,this.to,n)}invert(){return new ne(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);if(e.deleted&&n.deleted||e.pos>=n.pos)return null;return new re(e.pos,n.pos,this.mark)}merge(t){if(t instanceof re&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new re(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new re(e.from,e.to,t.markFromJSON(e.mark))}}Qt.jsonID("removeMark",re);class ie extends Qt{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return te.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return te.fromReplace(t,this.pos,this.pos+1,new T(v.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new ie(this.pos,e.marks[n]);return new ie(this.pos,this.mark)}}return new se(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ie(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ie(e.pos,t.markFromJSON(e.mark))}}Qt.jsonID("addNodeMark",ie);class se extends Qt{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return te.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return te.fromReplace(t,this.pos,this.pos+1,new T(v.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new ie(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new se(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new se(e.pos,t.markFromJSON(e.mark))}}Qt.jsonID("removeNodeMark",se);class oe extends Qt{constructor(t,e,n,r=false){super();this.from=t;this.to=e;this.slice=n;this.structure=r}apply(t){if(this.structure&&ue(t,this.from,this.to))return te.fail("Structure replace would overwrite content");return te.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Zt([this.from,this.to-this.from,this.slice.size])}invert(t){return new oe(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);if(e.deletedAcross&&n.deletedAcross)return null;return new oe(e.pos,Math.max(e.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof oe)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?T.empty:new T(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new oe(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?T.empty:new T(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new oe(t.from,this.to,e,this.structure)}else{return null}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new oe(e.from,e.to,T.fromJSON(t,e.slice),!!e.structure)}}Qt.jsonID("replace",oe);class le extends Qt{constructor(t,e,n,r,i,s,o=false){super();this.from=t;this.to=e;this.gapFrom=n;this.gapTo=r;this.slice=i;this.insert=s;this.structure=o}apply(t){if(this.structure&&(ue(t,this.from,this.gapFrom)||ue(t,this.gapTo,this.to)))return te.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return te.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);if(!n)return te.fail("Content does not fit in gap");return te.fromReplace(t,this.from,this.to,n)}getMap(){return new Zt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new le(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);let r=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let i=this.to==this.gapTo?n.pos:t.map(this.gapTo,1);if(e.deletedAcross&&n.deletedAcross||r<e.pos||i>n.pos)return null;return new le(e.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new le(e.from,e.to,e.gapFrom,e.gapTo,T.fromJSON(t,e.slice),e.insert,!!e.structure)}}Qt.jsonID("replaceAround",le);function ue(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;while(i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount){s--;i--}if(i>0){let t=r.node(s).maybeChild(r.indexAfter(s));while(i>0){if(!t||t.isLeaf)return true;t=t.firstChild;i--}}return false}function ae(t,e,n,r){let i=[],s=[];let o,l;t.doc.nodesBetween(e,n,((t,u,a)=>{if(!t.isInline)return;let f=t.marks;if(!r.isInSet(f)&&a.type.allowsMarkType(r.type)){let a=Math.max(u,e),h=Math.min(u+t.nodeSize,n);let c=r.addToSet(f);for(let t=0;t<f.length;t++){if(!f[t].isInSet(c)){if(o&&o.to==a&&o.mark.eq(f[t]))o.to=h;else i.push(o=new re(a,h,f[t]))}}if(l&&l.to==a)l.to=h;else s.push(l=new ne(a,h,r))}}));i.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function fe(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,((t,o)=>{if(!t.isInline)return;s++;let l=null;if(r instanceof pt){let e=t.marks,n;while(n=r.isInSet(e)){(l||(l=[])).push(n);e=n.removeFromSet(e)}}else if(r){if(r.isInSet(t.marks))l=[r]}else{l=t.marks}if(l&&l.length){let r=Math.min(o+t.nodeSize,n);for(let t=0;t<l.length;t++){let n=l[t],u;for(let t=0;t<i.length;t++){let e=i[t];if(e.step==s-1&&n.eq(i[t].style))u=e}if(u){u.to=r;u.step=s}else{i.push({style:n,from:Math.max(o,e),to:r,step:s})}}}}));i.forEach((e=>t.step(new re(e.from,e.to,e.style))))}function he(t,e,n,r=n.contentMatch,i=true){let s=t.doc.nodeAt(e);let o=[],l=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),a=l+u.nodeSize;let f=r.matchType(u.type);if(!f){o.push(new oe(l,a,T.empty))}else{r=f;for(let e=0;e<u.marks.length;e++)if(!n.allowsMarkType(u.marks[e].type))t.step(new re(l,a,u.marks[e]));if(i&&u.isText&&n.whitespace!="pre"){let t,e=/\r?\n|\r/g,r;while(t=e.exec(u.text)){if(!r)r=new T(v.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0);o.push(new oe(l+t.index,l+t.index+t[0].length,r))}}}l=a}if(!r.validEnd){let e=r.fillBefore(v.empty,true);t.replace(l,l,new T(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function ce(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function de(t){let e=t.parent;let n=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let r=t.$from.node(e);let i=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&r.canReplace(i,s,n))return e;if(e==0||r.type.spec.isolating||!ce(r,i,s))break}return null}function pe(t,e,n){let{$from:r,$to:i,depth:s}=e;let o=r.before(s+1),l=i.after(s+1);let u=o,a=l;let f=v.empty,h=0;for(let t=s,e=false;t>n;t--)if(e||r.index(t)>0){e=true;f=v.from(r.node(t).copy(f));h++}else{u--}let c=v.empty,d=0;for(let t=s,e=false;t>n;t--)if(e||i.after(t+1)<i.end(t)){e=true;c=v.from(i.node(t).copy(c));d++}else{a++}t.step(new le(u,a,o,l,new T(f.append(c),h,d),f.size-h,true))}function me(t,e,n=null,r=t){let i=we(t,e);let s=i&&be(r,e);if(!s)return null;return i.map(ge).concat({type:e,attrs:n}).concat(s.map(ge))}function ge(t){return{type:t,attrs:null}}function we(t,e){let{parent:n,startIndex:r,endIndex:i}=t;let s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function be(t,e){let{parent:n,startIndex:r,endIndex:i}=t;let s=n.child(r);let o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=o.length?o[o.length-1]:e;let u=l.contentMatch;for(let t=r;u&&t<i;t++)u=u.matchType(n.child(t).type);if(!u||!u.validEnd)return null;return o}function ve(t,e,n){let r=v.empty;for(let t=n.length-1;t>=0;t--){if(r.size){let e=n[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(n[t].type.create(n[t].attrs,r))}let i=e.start,s=e.end;t.step(new le(i,s,i,s,new T(r,0,0),n.length,true))}function ke(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{let o=typeof i=="function"?i(e):i;if(e.isTextblock&&!e.hasMarkup(r,o)&&Me(t.doc,t.mapping.slice(s).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let t=r.whitespace=="pre",e=!!r.contentMatch.matchType(r.schema.linebreakReplacement);if(t&&!e)i=false;else if(!t&&e)i=true}if(i===false)xe(t,e,n,s);he(t,t.mapping.slice(s).map(n,1),r,undefined,i===null);let l=t.mapping.slice(s);let u=l.map(n,1),a=l.map(n+e.nodeSize,1);t.step(new le(u,a,u+1,a-1,new T(v.from(r.create(o,null,e.marks)),0,0),1,true));if(i===true)ye(t,e,n,s);return false}}))}function ye(t,e,n,r){e.forEach(((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;while(o=l.exec(i.text)){let i=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(i,i+1,e.type.schema.linebreakReplacement.create())}}}))}function xe(t,e,n,r){e.forEach(((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let i=t.mapping.slice(r).map(n+1+s);t.replaceWith(i,i+1,e.type.schema.text("\n"))}}))}function Me(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Se(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!n)n=s.type;let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new le(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new T(v.from(o),0,0),1,true))}function Te(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n;let o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return false;for(let t=i.depth-1,e=n-2;t>s;t--,e--){let n=i.node(t),s=i.index(t);if(n.type.spec.isolating)return false;let o=n.content.cutByIndex(s,n.childCount);let l=r&&r[e+1];if(l)o=o.replaceChild(0,l.type.create(l.attrs));let u=r&&r[e]||n;if(!n.canReplace(s+1,n.childCount)||!u.type.validContent(o))return false}let l=i.indexAfter(s);let u=r&&r[0];return i.node(s).canReplaceWith(l,l,u?u.type:i.node(s+1).type)}function Ee(t,e,n=1,r){let i=t.doc.resolve(e),s=v.empty,o=v.empty;for(let t=i.depth,e=i.depth-n,l=n-1;t>e;t--,l--){s=v.from(i.node(t).copy(s));let e=r&&r[l];o=v.from(e?e.type.create(e.attrs,o):i.node(t).copy(o))}t.step(new oe(e,e,new T(s.append(o),n,n),true))}function Ae(t,e){let n=t.resolve(e),r=n.index();return $e(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Oe(t,e){if(!e.content.size)t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount);let{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i);let o=s.type==r?t.type.schema.nodes.text:s.type;n=n.matchType(o);if(!n)return false;if(!t.type.allowsMarks(s.marks))return false}return n.validEnd}function $e(t,e){return!!(t&&e&&!t.isLeaf&&Oe(t,e))}function Re(t,e,n=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let i,s,o=r.index(t);if(t==r.depth){i=r.nodeBefore;s=r.nodeAfter}else if(n>0){i=r.node(t+1);o++;s=r.node(t).maybeChild(o)}else{i=r.node(t).maybeChild(o-1);s=r.node(t+1)}if(i&&!i.isTextblock&&$e(i,s)&&r.node(t).canReplace(o,o+1))return e;if(t==0)break;e=n<0?r.before(t):r.after(t)}}function Ce(t,e,n){let r=null;let{linebreakReplacement:i}=t.doc.type.schema;let s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let t=o.whitespace=="pre";let e=!!o.contentMatch.matchType(i);if(t&&!e)r=false;else if(!t&&e)r=true}let l=t.steps.length;if(r===false){let r=t.doc.resolve(e+n);xe(t,r.node(),r.before(),l)}if(o.inlineContent)he(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let u=t.mapping.slice(l),a=u.map(e-n);t.step(new oe(a,u.map(e+n,-1),T.empty,true));if(r===true){let e=t.doc.resolve(a);ye(t,e.node(),e.before(),t.steps.length)}return t}function Le(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,n))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,n))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}function Ne(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let t=0;t<n.openStart;t++)i=i.firstChild.content;for(let t=1;t<=(n.openStart==0&&n.size?2:1);t++){for(let e=r.depth;e>=0;e--){let n=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1;let s=r.index(e)+(n>0?1:0);let o=r.node(e),l=false;if(t==1){l=o.canReplace(s,s,i)}else{let t=o.contentMatchAt(s).findWrapping(i.firstChild.type);l=t&&o.canReplaceWith(s,s,t[0])}if(l)return n==0?r.pos:n<0?r.before(e+1):r.after(e+1)}}return null}function Ie(t,e,n=e,r=T.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);if(Pe(i,s,r))return new oe(e,n,r);return new De(i,s,r).fit()}function Pe(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class De{constructor(t,e,n){this.$from=t;this.$to=e;this.unplaced=n;this.frontier=[];this.placed=v.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=v.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let n=this.$from,r=this.close(t<0?this.$to:n.doc.resolve(t));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;while(s&&o&&i.childCount==1){i=i.firstChild.content;s--;o--}let l=new T(i,s,o);if(t>-1)return new le(n.pos,t,this.$to.pos,this.$to.end(),l,e);if(l.size||n.pos!=this.$to.pos)return new oe(n.pos,r.pos,l);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<t;n++){let i=e.firstChild;if(e.childCount>1)r=0;if(i.type.spec.isolating&&r<=n){t=n;break}e=i.content}for(let e=1;e<=2;e++){for(let n=e==1?t:this.unplaced.openStart;n>=0;n--){let t,r=null;if(n){r=je(this.unplaced.content,n-1).firstChild;t=r.content}else{t=this.unplaced.content}let i=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:o}=this.frontier[t],l,u=null;if(e==1&&(i?o.matchType(i.type)||(u=o.fillBefore(v.from(i),false)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:t,parent:r,inject:u};else if(e==2&&i&&(l=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:t,parent:r,wrap:l};if(r&&o.matchType(r.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced;let r=je(t,e);if(!r.childCount||r.firstChild.isLeaf)return false;this.unplaced=new T(t,e+1,Math.max(n,r.size+e>=t.size-n?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced;let r=je(t,e);if(r.childCount<=1&&e>0){let i=t.size-e<=e+r.size;this.unplaced=new T(He(t,e-1,1),e-1,i?e-1:n)}else{this.unplaced=new T(He(t,e,1),e,n)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:r,wrap:i}){while(this.depth>e)this.closeFrontierNode();if(i)for(let t=0;t<i.length;t++)this.openFrontierNode(i[t]);let s=this.unplaced,o=n?n.content:s.content;let l=s.openStart-t;let u=0,a=[];let{match:f,type:h}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)a.push(r.child(t));f=f.matchFragment(r)}let c=o.size+t-(s.content.size-s.openEnd);while(u<o.childCount){let t=o.child(u),e=f.matchType(t.type);if(!e)break;u++;if(u>1||l==0||t.content.size){f=e;a.push(ze(t.mark(h.allowedMarks(t.marks)),u==1?l:0,u==o.childCount?c:-1))}}let d=u==o.childCount;if(!d)c=-1;this.placed=_e(this.placed,e,v.from(a));this.frontier[e].match=f;if(d&&c<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=o;t<c;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!d?new T(He(s.content,t,u),s.openStart,s.openEnd):t==0?T.empty:new T(He(s.content,t-1,1),t-1,c<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!Be(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);while(n>1&&r==this.$to.end(--n))++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:r}=this.frontier[e];let i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=Be(t,e,r,n,i);if(!s)continue;for(let n=e-1;n>=0;n--){let{match:e,type:r}=this.frontier[n];let i=Be(t,n,r,e,true);if(!i||i.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=_e(this.placed,e.depth,e.fit);t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),r=e.type.contentMatch.fillBefore(e.content,true,t.index(n));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(t);this.placed=_e(this.placed,this.depth,v.from(t.create(e,n)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(v.empty,true);if(e.childCount)this.placed=_e(this.placed,this.frontier.length,e)}}function He(t,e,n){if(e==0)return t.cutByIndex(n,t.childCount);return t.replaceChild(0,t.firstChild.copy(He(t.firstChild.content,e-1,n)))}function _e(t,e,n){if(e==0)return t.append(n);return t.replaceChild(t.childCount-1,t.lastChild.copy(_e(t.lastChild.content,e-1,n)))}function je(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ze(t,e,n){if(e<=0)return t;let r=t.content;if(e>1)r=r.replaceChild(0,ze(r.firstChild,e-1,r.childCount==1?n-1:0));if(e>0){r=t.type.contentMatch.fillBefore(r).append(r);if(n<=0)r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(v.empty,true))}return t.copy(r)}function Be(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,true,o);return l&&!Fe(n,s.content,o)?l:null}function Fe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return true;return false}function Ue(t){return t.spec.defining||t.spec.definingForContent}function qe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(Pe(i,s,r))return t.step(new oe(e,n,r));let o=Ve(i,t.doc.resolve(n));if(o[o.length-1]==0)o.pop();let l=-(i.depth+1);o.unshift(l);for(let t=i.depth,e=i.pos-1;t>0;t--,e--){let n=i.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;if(o.indexOf(t)>-1)l=t;else if(i.before(t)==e)o.splice(1,0,-t)}let u=o.indexOf(l);let a=[],f=r.openStart;for(let t=r.content,e=0;;e++){let n=t.firstChild;a.push(n);if(e==r.openStart)break;t=n.content}for(let t=f-1;t>=0;t--){let e=a[t],n=Ue(e.type);if(n&&!e.sameMarkup(i.node(Math.abs(l)-1)))f=t;else if(n||!e.type.isTextblock)break}for(let e=r.openStart;e>=0;e--){let l=(e+f+1)%(r.openStart+1);let h=a[l];if(!h)continue;for(let e=0;e<o.length;e++){let a=o[(e+u)%o.length],f=true;if(a<0){f=false;a=-a}let c=i.node(a-1),d=i.index(a-1);if(c.canReplaceWith(d,d,h.type,h.marks))return t.replace(i.before(a),f?s.after(a):n,new T(Ke(r.content,0,r.openStart,l),l,r.openEnd))}}let h=t.steps.length;for(let l=o.length-1;l>=0;l--){t.replace(e,n,r);if(t.steps.length>h)break;let u=o[l];if(u<0)continue;e=i.before(u);n=s.after(u)}}function Ke(t,e,n,r,i){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Ke(i.content,e+1,n,r,i)))}if(e>r){let e=i.contentMatchAt(0);let n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(v.empty,true))}return t}function Je(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Le(t.doc,e,r.type);if(i!=null)e=n=i}t.replaceRange(e,n,new T(v.from(r),0,0))}function We(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);let s=Ve(r,i);for(let e=0;e<s.length;e++){let n=s[e],o=e==s.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return t.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return t.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++){if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n)}t.delete(e,n)}function Ve(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let r=t.start(i);if(r<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;if(r==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==r-1)n.push(i)}return n}class Ge extends Qt{constructor(t,e,n){super();this.pos=t;this.attr=e;this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return te.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return te.fromReplace(t,this.pos,this.pos+1,new T(v.from(r),0,e.isLeaf?0:1))}getMap(){return Zt.empty}invert(t){return new Ge(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ge(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ge(e.pos,e.attr,e.value)}}Qt.jsonID("attr",Ge);class Ze extends Qt{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let n in t.attrs)e[n]=t.attrs[n];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return te.ok(n)}getMap(){return Zt.empty}invert(t){return new Ze(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ze(e.attr,e.value)}}Qt.jsonID("docAttr",Ze);let Ye=class extends Error{};Ye=function t(e){let n=Error.call(this,e);n.__proto__=t.prototype;return n};Ye.prototype=Object.create(Error.prototype);Ye.prototype.constructor=Ye;Ye.prototype.name="TransformError";class Xe{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Yt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Ye(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);if(!e.failed)this.addStep(t,e.doc);return e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc);this.steps.push(t);this.mapping.appendMap(t.getMap());this.doc=e}replace(t,e=t,n=T.empty){let r=Ie(this.doc,t,e,n);if(r)this.step(r);return this}replaceWith(t,e,n){return this.replace(t,e,new T(v.from(n),0,0))}delete(t,e){return this.replace(t,e,T.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){qe(this,t,e,n);return this}replaceRangeWith(t,e,n){Je(this,t,e,n);return this}deleteRange(t,e){We(this,t,e);return this}lift(t,e){pe(this,t,e);return this}join(t,e=1){Ce(this,t,e);return this}wrap(t,e){ve(this,t,e);return this}setBlockType(t,e=t,n,r=null){ke(this,t,e,n,r);return this}setNodeMarkup(t,e,n=null,r){Se(this,t,e,n,r);return this}setNodeAttribute(t,e,n){this.step(new Ge(t,e,n));return this}setDocAttribute(t,e){this.step(new Ze(t,e));return this}addNodeMark(t,e){this.step(new ie(t,e));return this}removeNodeMark(t,e){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(e instanceof M){if(e.isInSet(n.marks))this.step(new se(t,e))}else{let r=n.marks,i,s=[];while(i=e.isInSet(r)){s.push(new se(t,i));r=i.removeFromSet(r)}for(let t=s.length-1;t>=0;t--)this.step(s[t])}return this}split(t,e=1,n){Ee(this,t,e,n);return this}addMark(t,e,n){ae(this,t,e,n);return this}removeMark(t,e,n){fe(this,t,e,n);return this}clearIncompatible(t,e,n){he(this,t,e,n);return this}}const Qe=Object.create(null);class tn{constructor(t,e,n){this.$anchor=t;this.$head=e;this.ranges=n||[new en(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return false;return true}content(){return this.$from.doc.slice(this.from,this.to,true)}replace(t,e=T.empty){let n=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++){r=n;n=n.lastChild}let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:u}=s[o],a=t.mapping.slice(i);t.replaceRange(a.map(l.pos),a.map(u.pos),o?T.empty:e);if(o==0)cn(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],l=t.mapping.slice(n);let u=l.map(s.pos),a=l.map(o.pos);if(i){t.deleteRange(u,a)}else{t.replaceRangeWith(u,a,e);cn(t,n,e.isInline?-1:1)}}}static findFrom(t,e,n=false){let r=t.parent.inlineContent?new sn(t):hn(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let r=t.depth-1;r>=0;r--){let i=e<0?hn(t.node(0),t.node(r),t.before(r+1),t.index(r),e,n):hn(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,n);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new an(t.node(0))}static atStart(t){return hn(t,t,0,0,1)||new an(t)}static atEnd(t){return hn(t,t,t.content.size,t.childCount,-1)||new an(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Qe[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Qe)throw new RangeError("Duplicate use of selection JSON ID "+t);Qe[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return sn.between(this.$anchor,this.$head).getBookmark()}}tn.prototype.visible=true;class en{constructor(t,e){this.$from=t;this.$to=e}}let nn=false;function rn(t){if(!nn&&!t.parent.inlineContent){nn=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class sn extends tn{constructor(t,e=t){rn(t);rn(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return tn.near(n);let r=t.resolve(e.map(this.anchor));return new sn(r.parent.inlineContent?r:n,n)}replace(t,e=T.empty){super.replace(t,e);if(e==T.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof sn&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new on(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new sn(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(t,e,n){let r=t.pos-e.pos;if(!n||r)n=r>=0?1:-1;if(!e.parent.inlineContent){let t=tn.findFrom(e,n,true)||tn.findFrom(e,-n,true);if(t)e=t.$head;else return tn.near(e,n)}if(!t.parent.inlineContent){if(r==0){t=e}else{t=(tn.findFrom(t,-n,true)||tn.findFrom(t,n,true)).$anchor;if(t.pos<e.pos!=r<0)t=e}}return new sn(t,e)}}tn.jsonID("text",sn);class on{constructor(t,e){this.anchor=t;this.head=e}map(t){return new on(t.map(this.anchor),t.map(this.head))}resolve(t){return sn.between(t.resolve(this.anchor),t.resolve(this.head))}}class ln extends tn{constructor(t){let e=t.nodeAfter;let n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n);this.node=e}map(t,e){let{deleted:n,pos:r}=e.mapResult(this.anchor);let i=t.resolve(r);if(n)return tn.near(i);return new ln(i)}content(){return new T(v.from(this.node),0,0)}eq(t){return t instanceof ln&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new un(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ln(t.resolve(e.anchor))}static create(t,e){return new ln(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}ln.prototype.visible=false;tn.jsonID("node",ln);class un{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new on(n,n):new un(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;if(n&&ln.isSelectable(n))return new ln(e);return tn.near(e)}}class an extends tn{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=T.empty){if(e==T.empty){t.delete(0,t.doc.content.size);let e=tn.atStart(t.doc);if(!e.eq(t.selection))t.setSelection(e)}else{super.replace(t,e)}}toJSON(){return{type:"all"}}static fromJSON(t){return new an(t)}map(t){return new an(t)}eq(t){return t instanceof an}getBookmark(){return fn}}tn.jsonID("all",an);const fn={map(){return this},resolve(t){return new an(t)}};function hn(t,e,n,r,i,s=false){if(e.inlineContent)return sn.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let r=e.child(o);if(!r.isAtom){let e=hn(t,r,n+i,i<0?r.childCount:0,i,s);if(e)return e}else if(!s&&ln.isSelectable(r)){return ln.create(t,n-(i<0?r.nodeSize:0))}n+=r.nodeSize*i}return null}function cn(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof oe||i instanceof le))return;let s=t.mapping.maps[r],o;s.forEach(((t,e,n,r)=>{if(o==null)o=r}));t.setSelection(tn.near(t.doc.resolve(o),n))}const dn=1,pn=2,mn=4;class gn extends Xe{constructor(t){super(t.doc);this.curSelectionFor=0;this.updated=0;this.meta=Object.create(null);this.time=Date.now();this.curSelection=t.selection;this.storedMarks=t.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length){this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor));this.curSelectionFor=this.steps.length}return this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");this.curSelection=t;this.curSelectionFor=this.steps.length;this.updated=(this.updated|dn)&~pn;this.storedMarks=null;return this}get selectionSet(){return(this.updated&dn)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=pn;return this}ensureMarks(t){if(!M.sameSet(this.storedMarks||this.selection.$from.marks(),t))this.setStoredMarks(t);return this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&pn)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~pn;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let n=this.selection;if(e)t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||M.none));n.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,n){let r=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(r.text(t),true)}else{if(n==null)n=e;n=n==null?e:n;if(!t)return this.deleteRange(e,n);let i=this.storedMarks;if(!i){let t=this.doc.resolve(e);i=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}this.replaceRangeWith(e,n,r.text(t,i));if(!this.selection.empty)this.setSelection(tn.near(this.selection.$to));return this}}setMeta(t,e){this.meta[typeof t=="string"?t:t.key]=e;return this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return false;return true}scrollIntoView(){this.updated|=mn;return this}get scrolledIntoView(){return(this.updated&mn)>0}}function wn(t,e){return!e||!t?t:t.bind(e)}class bn{constructor(t,e,n){this.name=t;this.init=wn(e.init,n);this.apply=wn(e.apply,n)}}const vn=[new bn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new bn("selection",{init(t,e){return t.selection||tn.atStart(e.doc)},apply(t){return t.selection}}),new bn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new bn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class kn{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=vn.slice();if(e)e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t);this.pluginsByKey[t.key]=t;if(t.spec.state)this.fields.push(new bn(t.key,t.spec.state,t))}))}}class yn{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),r=null;for(;;){let i=false;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=r?r[s].n:0,u=r?r[s].state:this;let a=l<e.length&&o.spec.appendTransaction.call(o,l?e.slice(l):e,u,n);if(a&&n.filterTransaction(a,s)){a.setMeta("appendedTransaction",t);if(!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:n,n:e.length}:{state:this,n:0})}e.push(a);n=n.applyInner(a);i=true}if(r)r[s]={state:n,n:e.length}}}if(!i)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new yn(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];e[i.name]=i.apply(t,this[i.name],this,e)}return e}get tr(){return new gn(this)}static create(t){let e=new kn(t.doc?t.doc.type.schema:t.schema,t.plugins);let n=new yn(e);for(let r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n}reconfigure(t){let e=new kn(this.schema,t.plugins);let n=e.fields,r=new yn(e);for(let e=0;e<n.length;e++){let i=n[e].name;r[i]=this.hasOwnProperty(i)?this[i]:n[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let n in t){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[n],i=r.spec.state;if(i&&i.toJSON)e[n]=i.toJSON.call(r,this[r.key])}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new kn(t.schema,t.plugins);let i=new yn(r);r.fields.forEach((r=>{if(r.name=="doc"){i.doc=q.fromJSON(t.schema,e.doc)}else if(r.name=="selection"){i.selection=tn.fromJSON(i.doc,e.selection)}else if(r.name=="storedMarks"){if(e.storedMarks)i.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(n)for(let s in n){let o=n[s],l=o.spec.state;if(o.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){i[r.name]=l.fromJSON.call(o,t,e[s],i);return}}i[r.name]=r.init(t,i)}}));return i}}function xn(t,e,n){for(let r in t){let i=t[r];if(i instanceof Function)i=i.bind(e);else if(r=="handleDOMEvents")i=xn(i,e,{});n[r]=i}return n}class Mn{constructor(t){this.spec=t;this.props={};if(t.props)xn(t.props,this,this.props);this.key=t.key?t.key.key:Tn("plugin")}getState(t){return t[this.key]}}const Sn=Object.create(null);function Tn(t){if(t in Sn)return t+"$"+ ++Sn[t];Sn[t]=0;return t+"$"}class En{constructor(t="key"){this.key=Tn(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const An=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function On(t,e){let{$cursor:n}=t.selection;if(!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0))return null;return n}const $n=(t,e,n)=>{let r=On(t,n);if(!r)return false;let i=Pn(r);if(!i){let n=r.blockRange(),i=n&&de(n);if(i==null)return false;if(e)e(t.tr.lift(n,i).scrollIntoView());return true}let s=i.nodeBefore;if(Qn(t,i,e,-1))return true;if(r.parent.content.size==0&&(Nn(s,"end")||ln.isSelectable(s))){for(let n=r.depth;;n--){let o=Ie(t.doc,r.before(n),r.after(n),T.empty);if(o&&o.slice.size<o.to-o.from){if(e){let n=t.tr.step(o);n.setSelection(Nn(s,"end")?tn.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):ln.create(n.doc,i.pos-s.nodeSize));e(n.scrollIntoView())}return true}if(n==1||r.node(n-1).childCount>1)break}}if(s.isAtom&&i.depth==r.depth-1){if(e)e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView());return true}return false};const Rn=(t,e,n)=>{let r=On(t,n);if(!r)return false;let i=Pn(r);return i?Ln(t,i,e):false};const Cn=(t,e,n)=>{let r=Dn(t,n);if(!r)return false;let i=jn(r);return i?Ln(t,i,e):false};function Ln(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return false;let t=i.lastChild;if(!t)return false;i=t}let o=e.nodeAfter,l=o,u=e.pos+1;for(;!l.isTextblock;u++){if(l.type.spec.isolating)return false;let t=l.firstChild;if(!t)return false;l=t}let a=Ie(t.doc,s,u,T.empty);if(!a||a.from!=s||a instanceof oe&&a.slice.size>=u-s)return false;if(n){let e=t.tr.step(a);e.setSelection(sn.create(e.doc,s));n(e.scrollIntoView())}return true}function Nn(t,e,n=false){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return true;if(n&&r.childCount!=1)return false}return false}const In=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return false;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return false;s=Pn(r)}let o=s&&s.nodeBefore;if(!o||!ln.isSelectable(o))return false;if(e)e(t.tr.setSelection(ln.create(t.doc,s.pos-o.nodeSize)).scrollIntoView());return true};function Pn(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Dn(t,e){let{$cursor:n}=t.selection;if(!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size))return null;return n}const Hn=(t,e,n)=>{let r=Dn(t,n);if(!r)return false;let i=jn(r);if(!i)return false;let s=i.nodeAfter;if(Qn(t,i,e,1))return true;if(r.parent.content.size==0&&(Nn(s,"start")||ln.isSelectable(s))){let n=Ie(t.doc,r.before(),r.after(),T.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Nn(s,"start")?tn.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):ln.create(r.doc,r.mapping.map(i.pos)));e(r.scrollIntoView())}return true}}if(s.isAtom&&i.depth==r.depth-1){if(e)e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView());return true}return false};const _n=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return false;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return false;s=jn(r)}let o=s&&s.nodeAfter;if(!o||!ln.isSelectable(o))return false;if(e)e(t.tr.setSelection(ln.create(t.doc,s.pos)).scrollIntoView());return true};function jn(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const zn=(t,e)=>{let n=t.selection,r=n instanceof ln,i;if(r){if(n.node.isTextblock||!Ae(t.doc,n.from))return false;i=n.from}else{i=Re(t.doc,n.from,-1);if(i==null)return false}if(e){let n=t.tr.join(i);if(r)n.setSelection(ln.create(n.doc,i-t.doc.resolve(i).nodeBefore.nodeSize));e(n.scrollIntoView())}return true};const Bn=(t,e)=>{let n=t.selection,r;if(n instanceof ln){if(n.node.isTextblock||!Ae(t.doc,n.to))return false;r=n.to}else{r=Re(t.doc,n.to,1);if(r==null)return false}if(e)e(t.tr.join(r).scrollIntoView());return true};const Fn=(t,e)=>{let{$from:n,$to:r}=t.selection;let i=n.blockRange(r),s=i&&de(i);if(s==null)return false;if(e)e(t.tr.lift(i,s).scrollIntoView());return true};const Un=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function qn(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Kn=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return false;let i=n.node(-1),s=n.indexAfter(-1),o=qn(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return false;if(e){let r=n.after(),i=t.tr.replaceWith(r,r,o.createAndFill());i.setSelection(tn.near(i.doc.resolve(r),1));e(i.scrollIntoView())}return true};const Jn=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof an||r.parent.inlineContent||i.parent.inlineContent)return false;let s=qn(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos;let o=t.tr.insert(n,s.createAndFill());o.setSelection(sn.create(o.doc,n+1));e(o.scrollIntoView())}return true};const Wn=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return false;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Te(t.doc,r)){if(e)e(t.tr.split(r).scrollIntoView());return true}}let r=n.blockRange(),i=r&&de(r);if(i==null)return false;if(e)e(t.tr.lift(r,i).scrollIntoView());return true};function Vn(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof ln&&e.selection.node.isBlock){if(!r.parentOffset||!Te(e.doc,r.pos))return false;if(n)n(e.tr.split(r.pos).scrollIntoView());return true}if(!r.depth)return false;let s=[];let o,l,u=false,a=false;for(let e=r.depth;;e--){let n=r.node(e);if(n.isBlock){u=r.end(e)==r.pos+(r.depth-e);a=r.start(e)==r.pos-(r.depth-e);l=qn(r.node(e-1).contentMatchAt(r.indexAfter(e-1)));let n=t&&t(i.parent,u,r);s.unshift(n||(u&&l?{type:l}:null));o=e;break}else{if(e==1)return false;s.unshift(null)}}let f=e.tr;if(e.selection instanceof sn||e.selection instanceof an)f.deleteSelection();let h=f.mapping.map(r.pos);let c=Te(f.doc,h,s.length,s);if(!c){s[0]=l?{type:l}:null;c=Te(f.doc,h,s.length,s)}if(!c)return false;f.split(h,s.length,s);if(!u&&a&&r.node(o).type!=l){let t=f.mapping.map(r.before(o)),e=f.doc.resolve(t);if(l&&r.node(o-1).canReplaceWith(e.index(),e.index()+1,l))f.setNodeMarkup(f.mapping.map(r.before(o)),l)}if(n)n(f.scrollIntoView());return true}}const Gn=Vn();const Zn=(t,e)=>{let{$from:n,to:r}=t.selection,i;let s=n.sharedDepth(r);if(s==0)return false;i=n.before(s);if(e)e(t.tr.setSelection(ln.create(t.doc,i)));return true};const Yn=(t,e)=>{if(e)e(t.tr.setSelection(new an(t.doc)));return true};function Xn(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();if(!r||!i||!r.type.compatibleContent(i.type))return false;if(!r.content.size&&e.parent.canReplace(s-1,s)){if(n)n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(i.isTextblock||Ae(t.doc,e.pos)))return false;if(n)n(t.tr.join(e.pos).scrollIntoView());return true}function Qn(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l;let u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&Xn(t,e,n))return true;let a=!u&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(n){let r=e.pos+s.nodeSize,l=v.empty;for(let t=o.length-1;t>=0;t--)l=v.from(o[t].create(null,l));l=v.from(i.copy(l));let u=t.tr.step(new le(e.pos-1,r,e.pos,r,new T(l,1,0),o.length,true));let a=u.doc.resolve(r+2*o.length);if(a.nodeAfter&&a.nodeAfter.type==i.type&&Ae(u.doc,a.pos))u.join(a.pos);n(u.scrollIntoView())}return true}let f=s.type.spec.isolating||r>0&&u?null:tn.findFrom(e,1);let h=f&&f.$from.blockRange(f.$to),c=h&&de(h);if(c!=null&&c>=e.depth){if(n)n(t.tr.lift(h,c).scrollIntoView());return true}if(a&&Nn(s,"start",true)&&Nn(i,"end")){let r=i,o=[];for(;;){o.push(r);if(r.isTextblock)break;r=r.lastChild}let l=s,u=1;for(;!l.isTextblock;l=l.firstChild)u++;if(r.canReplace(r.childCount,r.childCount,l.content)){if(n){let r=v.empty;for(let t=o.length-1;t>=0;t--)r=v.from(o[t].copy(r));let i=t.tr.step(new le(e.pos-o.length,e.pos+s.nodeSize,e.pos+u,e.pos+s.nodeSize-u,new T(r,o.length,0),0,true));n(i.scrollIntoView())}return true}}return false}function tr(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to;let s=i.depth;while(i.node(s).isInline){if(!s)return false;s--}if(!i.node(s).isTextblock)return false;if(n)n(e.tr.setSelection(sn.create(e.doc,t<0?i.start(s):i.end(s))));return true}}const er=tr(-1);const nr=tr(1);function rr(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection;let o=i.blockRange(s),l=o&&me(o,t,e);if(!l)return false;if(r)r(n.tr.wrap(o,l).scrollIntoView());return true}}function ir(t,e=null){return function(n,r){let i=false;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(s,o,((r,s)=>{if(i)return false;if(!r.isTextblock||r.hasMarkup(t,e))return;if(r.type==t){i=true}else{let e=n.doc.resolve(s),r=e.index();i=e.parent.canReplaceWith(r,r+1,t)}}))}if(!i)return false;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(s,o,t,e)}r(i.scrollIntoView())}return true}}function sr(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return true;return false}}let or=sr(An,$n,In);let lr=sr(An,Hn,_n);const ur={Enter:sr(Un,Jn,Wn,Gn),"Mod-Enter":Kn,Backspace:or,"Mod-Backspace":or,"Shift-Backspace":or,Delete:lr,"Mod-Delete":lr,"Mod-a":Yn};const ar={"Ctrl-h":ur["Backspace"],"Alt-Backspace":ur["Mod-Backspace"],"Ctrl-d":ur["Delete"],"Ctrl-Alt-Backspace":ur["Mod-Delete"],"Alt-Delete":ur["Mod-Delete"],"Alt-d":ur["Mod-Delete"],"Ctrl-a":er,"Ctrl-e":nr};for(let t in ur)ar[t]=ur[t];typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;function fr(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection;let o=i.blockRange(s);if(!o)return false;let l=r?n.tr:null;if(!hr(l,o,t,e))return false;if(r)r(l.scrollIntoView());return true}}function hr(t,e,n,r=null){let i=false,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return false;let t=o.resolve(e.start-2);s=new F(t,t,e.depth);if(e.endIndex<e.parent.childCount)e=new F(e.$from,o.resolve(e.$to.end(e.depth)),e.depth);i=true}let l=me(s,n,r,e);if(!l)return false;if(t)cr(t,e,l,i,n);return true}function cr(t,e,n,r,i){let s=v.empty;for(let t=n.length-1;t>=0;t--)s=v.from(n[t].type.create(n[t].attrs,s));t.step(new le(e.start-(r?2:0),e.end,e.start,e.end,new T(s,0,0),n.length,true));let o=0;for(let t=0;t<n.length;t++)if(n[t].type==i)o=t+1;let l=n.length-o;let u=e.start+n.length-(r?2:0),a=e.parent;for(let n=e.startIndex,r=e.endIndex,i=true;n<r;n++,i=false){if(!i&&Te(t.doc,u,l)){t.split(u,l);u+=2*l}u+=a.child(n).nodeSize}return t}function dr(t){return function(e,n){let{$from:r,$to:i}=e.selection;let s=r.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!n)return true;if(r.node(s.depth-1).type==t)return pr(e,n,t,s);else return mr(e,n,s)}}function pr(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);if(s<o){i.step(new le(s-1,o,s,o,new T(v.from(n.create(null,r.parent.copy())),1,0),1,true));r=new F(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth)}const l=de(r);if(l==null)return false;i.lift(r,l);let u=i.doc.resolve(i.mapping.map(s,-1)-1);if(Ae(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type)i.join(u.pos);e(i.scrollIntoView());return true}function mr(t,e,n){let r=t.tr,i=n.parent;for(let t=n.end,e=n.endIndex-1,s=n.startIndex;e>s;e--){t-=i.child(e).nodeSize;r.delete(t-1,t+1)}let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return false;let l=n.startIndex==0,u=n.endIndex==i.childCount;let a=s.node(-1),f=s.index(-1);if(!a.canReplace(f+(l?0:1),f+1,o.content.append(u?v.empty:v.from(i))))return false;let h=s.pos,c=h+o.nodeSize;r.step(new le(h-(l?1:0),c+(u?1:0),h+1,c-1,new T((l?v.empty:v.from(i.copy(v.empty))).append(u?v.empty:v.from(i.copy(v.empty))),l?0:1,u?0:1),l?0:1));e(r.scrollIntoView());return true}function gr(t){return function(e,n){let{$from:r,$to:i}=e.selection;let s=r.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let o=s.startIndex;if(o==0)return false;let l=s.parent,u=l.child(o-1);if(u.type!=t)return false;if(n){let r=u.lastChild&&u.lastChild.type==l.type;let i=v.from(r?t.create():null);let o=new T(v.from(t.create(null,v.from(l.type.create(null,i)))),r?3:1,0);let a=s.start,f=s.end;n(e.tr.step(new le(a-(r?3:1),f,a,f,o,1,true)).scrollIntoView())}return true}}const wr=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const br=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let vr=null;const kr=function(t,e,n){let r=vr||(vr=document.createRange());r.setEnd(t,n==null?t.nodeValue.length:n);r.setStart(t,e||0);return r};const yr=function(){vr=null};const xr=function(t,e,n,r){return n&&(Sr(t,e,n,r,-1)||Sr(t,e,n,r,1))};const Mr=/^(img|br|input|textarea|hr)$/i;function Sr(t,e,n,r,i){var s;for(;;){if(t==n&&e==r)return true;if(e==(i<0?0:Tr(t))){let n=t.parentNode;if(!n||n.nodeType!=1||$r(t)||Mr.test(t.nodeName)||t.contentEditable=="false")return false;e=wr(t)+(i<0?0:1);t=n}else if(t.nodeType==1){let n=t.childNodes[e+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable=="false"){if((s=n.pmViewDesc)===null||s===void 0?void 0:s.ignoreForSelection)e+=i;else return false}else{t=n;e=i<0?Tr(t):0}}else{return false}}}function Tr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Er(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1];e=Tr(t)}else if(t.parentNode&&!$r(t)){e=wr(t);t=t.parentNode}else{return null}}}function Ar(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e];e=0}else if(t.parentNode&&!$r(t)){e=wr(t)+1;t=t.parentNode}else{return null}}}function Or(t,e,n){for(let r=e==0,i=e==Tr(t);r||i;){if(t==n)return true;let e=wr(t);t=t.parentNode;if(!t)return false;r=r&&e==0;i=i&&e==Tr(t)}}function $r(t){let e;for(let n=t;n;n=n.parentNode)if(e=n.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Rr=function(t){return t.focusNode&&xr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Cr(t,e){let n=document.createEvent("Event");n.initEvent("keydown",true,true);n.keyCode=t;n.key=n.code=e;return n}function Lr(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function Nr(t,e,n){if(t.caretPositionFromPoint){try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Tr(r.offsetNode),r.offset)}}catch(t){}}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Tr(r.startContainer),r.startOffset)}}}const Ir=typeof navigator!="undefined"?navigator:null;const Pr=typeof document!="undefined"?document:null;const Dr=Ir&&Ir.userAgent||"";const Hr=/Edge\/(\d+)/.exec(Dr);const _r=/MSIE \d/.exec(Dr);const jr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dr);const zr=!!(_r||jr||Hr);const Br=_r?document.documentMode:jr?+jr[1]:Hr?+Hr[1]:0;const Fr=!zr&&/gecko\/(\d+)/i.test(Dr);Fr&&+(/Firefox\/(\d+)/.exec(Dr)||[0,0])[1];const Ur=!zr&&/Chrome\/(\d+)/.exec(Dr);const qr=!!Ur;const Kr=Ur?+Ur[1]:0;const Jr=!zr&&!!Ir&&/Apple Computer/.test(Ir.vendor);const Wr=Jr&&(/Mobile\/\w+/.test(Dr)||!!Ir&&Ir.maxTouchPoints>2);const Vr=Wr||(Ir?/Mac/.test(Ir.platform):false);const Gr=Ir?/Win/.test(Ir.platform):false;const Zr=/Android \d/.test(Dr);const Yr=!!Pr&&"webkitFontSmoothing"in Pr.documentElement.style;const Xr=Yr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Qr(t){let e=t.defaultView&&t.defaultView.visualViewport;if(e)return{left:0,right:e.width,top:0,bottom:e.height};return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function ti(t,e){return typeof t=="number"?t:t[e]}function ei(t){let e=t.getBoundingClientRect();let n=e.width/t.offsetWidth||1;let r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function ni(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let o=n||t.dom;;){if(!o)break;if(o.nodeType!=1){o=br(o);continue}let t=o;let n=t==s.body;let l=n?Qr(s):ei(t);let u=0,a=0;if(e.top<l.top+ti(r,"top"))a=-(l.top-e.top+ti(i,"top"));else if(e.bottom>l.bottom-ti(r,"bottom"))a=e.bottom-e.top>l.bottom-l.top?e.top+ti(i,"top")-l.top:e.bottom-l.bottom+ti(i,"bottom");if(e.left<l.left+ti(r,"left"))u=-(l.left-e.left+ti(i,"left"));else if(e.right>l.right-ti(r,"right"))u=e.right-l.right+ti(i,"right");if(u||a){if(n){s.defaultView.scrollBy(u,a)}else{let n=t.scrollLeft,r=t.scrollTop;if(a)t.scrollTop+=a;if(u)t.scrollLeft+=u;let i=t.scrollLeft-n,s=t.scrollTop-r;e={left:e.left-i,top:e.top-s,right:e.right-i,bottom:e.bottom-s}}}let f=n?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:br(o)}}function ri(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top);let r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let e=t.root.elementFromPoint(s,o);if(!e||e==t.dom||!t.dom.contains(e))continue;let l=e.getBoundingClientRect();if(l.top>=n-20){r=e;i=l.top;break}}return{refDOM:r,refTop:i,stack:ii(t.dom)}}function ii(t){let e=[],n=t.ownerDocument;for(let r=t;r;r=br(r)){e.push({dom:r,top:r.scrollTop,left:r.scrollLeft});if(t==n)break}return e}function si({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;oi(n,r==0?0:r-e)}function oi(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];if(r.scrollTop!=i+e)r.scrollTop=i+e;if(r.scrollLeft!=s)r.scrollLeft=s}}let li=null;function ui(t){if(t.setActive)return t.setActive();if(li)return t.focus(li);let e=ii(t);t.focus(li==null?{get preventScroll(){li={preventScroll:true};return true}}:undefined);if(!li){li=false;oi(e,0)}}function ai(t,e){let n,r=2e8,i,s=0;let o=e.top,l=e.top;let u,a;for(let f=t.firstChild,h=0;f;f=f.nextSibling,h++){let t;if(f.nodeType==1)t=f.getClientRects();else if(f.nodeType==3)t=kr(f).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=o&&d.bottom>=l){o=Math.max(d.bottom,o);l=Math.min(d.top,l);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<r){n=f;r=t;i=t&&n.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(f.nodeType==1&&t)s=h+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!u&&d.left<=e.left&&d.right>=e.left){u=f;a={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=h+1}}if(!n&&u){n=u;i=a;r=0}if(n&&n.nodeType==3)return fi(n,i);if(!n||r&&n.nodeType==1)return{node:t,offset:s};return ai(n,i)}function fi(t,e){let n=t.nodeValue.length;let r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1);r.setStart(t,i);let n=bi(r,1);if(n.top==n.bottom)continue;if(hi(e,n))return{node:t,offset:i+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}function hi(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ci(t,e){let n=t.parentNode;if(n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left)return n;return t}function di(t,e,n){let{node:r,offset:i}=ai(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function pi(t,e,n,r){let i=-1;for(let n=e,s=false;;){if(n==t.dom)break;let e=t.docView.nearestDesc(n,true),o;if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)&&((o=e.dom.getBoundingClientRect()).width||o.height)){if(e.node.isBlock&&e.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(e.dom.nodeName)){if(!s&&o.left>r.left||o.top>r.top)i=e.posBefore;else if(!s&&o.right<r.left||o.bottom<r.top)i=e.posAfter;s=true}if(!e.contentDOM&&i<0&&!e.node.isText){let t=e.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2;return t?e.posBefore:e.posAfter}}n=e.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function mi(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom){for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let n=t.childNodes[s];if(n.nodeType==1){let t=n.getClientRects();for(let r=0;r<t.length;r++){let i=t[r];if(hi(e,i))return mi(n,e,i)}}if((s=(s+1)%r)==i)break}}return t}function gi(t,e){let n=t.dom.ownerDocument,r,i=0;let s=Nr(n,e.left,e.top);if(s)({node:r,offset:i}=s);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top);let l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let n=t.dom.getBoundingClientRect();if(!hi(e,n))return null;o=mi(t.dom,e,n);if(!o)return null}if(Jr){for(let t=o;r&&t;t=br(t))if(t.draggable)r=undefined}o=ci(o,e);if(r){if(Fr&&r.nodeType==1){i=Math.min(i,r.childNodes.length);if(i<r.childNodes.length){let t=r.childNodes[i],n;if(t.nodeName=="IMG"&&(n=t.getBoundingClientRect()).right<=e.left&&n.bottom>e.top)i++}}let n;if(Yr&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable=="false"&&n.getBoundingClientRect().top>=e.top)i--;if(r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom)l=t.state.doc.content.size;else if(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")l=pi(t,r,i,e)}if(l==null)l=di(t,o,e);let u=t.docView.nearestDesc(o,true);return{pos:l,inside:u?u.posAtStart-u.border:-1}}function wi(t){return t.top<t.bottom||t.left<t.right}function bi(t,e){let n=t.getClientRects();if(n.length){let t=n[e<0?0:n.length-1];if(wi(t))return t}return Array.prototype.find.call(n,wi)||t.getBoundingClientRect()}const vi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ki(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1);let o=Yr||Fr;if(r.nodeType==3){if(o&&(vi.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let t=bi(kr(r,i,i),n);if(Fr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let e=bi(kr(r,i-1,i-1),-1);if(e.top==t.top){let n=bi(kr(r,i,i+1),-1);if(n.top!=t.top)return yi(n,n.left<e.left)}}return t}else{let t=i,e=i,s=n<0?1:-1;if(n<0&&!i){e++;s=-1}else if(n>=0&&i==r.nodeValue.length){t--;s=1}else if(n<0){t--}else{e++}return yi(bi(kr(r,t,e),s),s<0)}}let l=t.state.doc.resolve(e-(s||0));if(!l.parent.inlineContent){if(s==null&&i&&(n<0||i==Tr(r))){let t=r.childNodes[i-1];if(t.nodeType==1)return xi(t.getBoundingClientRect(),false)}if(s==null&&i<Tr(r)){let t=r.childNodes[i];if(t.nodeType==1)return xi(t.getBoundingClientRect(),true)}return xi(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Tr(r))){let t=r.childNodes[i-1];let e=t.nodeType==3?kr(t,Tr(t)-(o?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return yi(bi(e,1),false)}if(s==null&&i<Tr(r)){let t=r.childNodes[i];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?kr(t,0,o?0:1):t.nodeType==1?t:null;if(e)return yi(bi(e,-1),true)}return yi(bi(r.nodeType==3?kr(r):r,-n),n>=0)}function yi(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function xi(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Mi(t,e,n){let r=t.state,i=t.root.activeElement;if(r!=e)t.updateState(e);if(i!=t.dom)t.focus();try{return n()}finally{if(r!=e)t.updateState(r);if(i!=t.dom&&i)i.focus()}}function Si(t,e,n){let r=e.selection;let i=n=="up"?r.$from:r.$to;return Mi(t,e,(()=>{let{node:e}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let n=t.docView.nearestDesc(e,true);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let r=ki(t,i.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=kr(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let i=e[t];if(i.bottom>i.top+1&&(n=="up"?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return false}}return true}))}const Ti=/[\u0590-\u08ac]/;function Ei(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return false;let i=r.parentOffset,s=!i,o=i==r.parent.content.size;let l=t.domSelection();if(!l)return r.pos==r.start()||r.pos==r.end();if(!Ti.test(r.parent.textContent)||!l.modify)return n=="left"||n=="backward"?s:o;return Mi(t,e,(()=>{let{focusNode:e,focusOffset:i,anchorNode:s,anchorOffset:o}=t.domSelectionRange();let u=l.caretBidiLevel;l.modify("move",n,"character");let a=r.depth?t.docView.domAfterPos(r.before()):t.dom;let{focusNode:f,focusOffset:h}=t.domSelectionRange();let c=f&&!a.contains(f.nodeType==1?f:f.parentNode)||e==f&&i==h;try{l.collapse(s,o);if(e&&(e!=s||i!=o)&&l.extend)l.extend(e,i)}catch(t){}if(u!=null)l.caretBidiLevel=u;return c}))}let Ai=null;let Oi=null;let $i=false;function Ri(t,e,n){if(Ai==e&&Oi==n)return $i;Ai=e;Oi=n;return $i=n=="up"||n=="down"?Si(t,e,n):Ei(t,e,n)}const Ci=0,Li=1,Ni=2,Ii=3;class Pi{constructor(t,e,n,r){this.parent=t;this.children=e;this.dom=n;this.contentDOM=r;this.dirty=Ci;n.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,n){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let r=this.children[e];if(r==t)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(n<0){let n,r;if(t==this.contentDOM){n=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;n=t.previousSibling}while(n&&!((r=n.pmViewDesc)&&r.parent==this))n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(t==this.contentDOM){n=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;n=t.nextSibling}while(n&&!((r=n.pmViewDesc)&&r.parent==this))n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM){r=e>wr(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){r=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){r=false;break}if(e.previousSibling)break}if(r==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=true;break}if(e.nextSibling)break}}return(r==null?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let n=true,r=t;r;r=r.parentNode){let i=this.getDesc(r),s;if(i&&(!e||i.node)){if(n&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))n=false;else return i}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let r=t;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let r=this.children[e],i=n+r.size;if(n==t&&i!=n){while(!r.border&&r.children.length){for(let t=0;t<r.children.length;t++){let e=r.children[t];if(e.size){r=e;break}}}return r}if(t<i)return r.descAt(t-n-r.border);n=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,r=0;for(let e=0;n<this.children.length;n++){let i=this.children[n],s=e+i.size;if(s>t||i instanceof Fi){r=t-e;break}e=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(let t;n&&!(t=this.children[n-1]).size&&t instanceof Di&&t.side>=0;n--){}if(e<=0){let t,r=true;for(;;n--,r=false){t=n?this.children[n-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&r&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?wr(t.dom)+1:0}}else{let t,r=true;for(;;n++,r=false){t=n<this.children.length?this.children[n]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&r&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?wr(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],l=s+n.size;if(r==-1&&t<=l){let i=s+n.border;if(t>=i&&e<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,i);t=s;for(let e=o;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=wr(n.dom)+1;break}t-=n.size}if(r==-1)r=0}if(r>-1&&(l>e||o==this.children.length-1)){e=l;for(let t=o+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=wr(n.dom);break}e+=n.size}if(i==-1)i=this.contentDOM.childNodes.length;break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(e.nodeType!=1||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,r=false){let i=Math.min(t,e),s=Math.max(t,e);for(let o=0,l=0;o<this.children.length;o++){let u=this.children[o],a=l+u.size;if(i>l&&s<a)return u.setSelection(t-l-u.border,e-l-u.border,n,r);l=a}let o=this.domFromPos(t,t?-1:1);let l=e==t?o:this.domFromPos(e,e?-1:1);let u=n.root.getSelection();let a=n.domSelectionRange();let f=false;if((Fr||Jr)&&t==e){let{node:t,offset:e}=o;if(t.nodeType==3){f=!!(e&&t.nodeValue[e-1]=="\n");if(f&&e==t.nodeValue.length){for(let e=t,n;e;e=e.parentNode){if(n=e.nextSibling){if(n.nodeName=="BR")o=l={node:n.parentNode,offset:wr(n)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let n=t.childNodes[e-1];f=n&&(n.nodeName=="BR"||n.contentEditable=="false")}}if(Fr&&a.focusNode&&a.focusNode!=l.node&&a.focusNode.nodeType==1){let t=a.focusNode.childNodes[a.focusOffset];if(t&&t.contentEditable=="false")r=true}if(!(r||f&&Jr)&&xr(o.node,o.offset,a.anchorNode,a.anchorOffset)&&xr(l.node,l.offset,a.focusNode,a.focusOffset))return;let h=false;if((u.extend||t==e)&&!(f&&Fr)){u.collapse(o.node,o.offset);try{if(t!=e)u.extend(l.node,l.offset);h=true}catch(t){}}if(!h){if(t>e){let t=o;o=l;l=t}let n=document.createRange();n.setEnd(l.node,l.offset);n.setStart(o.node,o.offset);u.removeAllRanges();u.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?t<=s&&e>=n:t<s&&e>n){let r=n+i.border,o=s-i.border;if(t>=r&&e<=o){this.dirty=t==n||e==s?Ni:Li;if(t==r&&e==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM))i.dirty=Ii;else i.markDirty(t-r,e-r);return}else{i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ni:Ii}}n=s}this.dirty=Ni}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=t==1?Ni:Li;if(e.dirty<n)e.dirty=n}}get domAtom(){return false}get ignoreForCoords(){return false}get ignoreForSelection(){return false}isText(t){return false}}class Di extends Pi{constructor(t,e,n,r){let i,s=e.type.toDOM;if(typeof s=="function")s=s(n,(()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;i=this}matchesWidget(t){return this.dirty==Ci&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Hi extends Pi{constructor(t,e,n,r){super(t,[],e,null);this.textDOM=n;this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class _i extends Pi{constructor(t,e,n,r,i){super(t,[],n,r);this.mark=e;this.spec=i}static create(t,e,n,r){let i=r.nodeViews[e.type.name];let s=i&&i(e,r,n);if(!s||!s.dom)s=Nt.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs);return new _i(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){if(this.dirty&Ii||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Ii&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=Ci){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=Ci}}slice(t,e,n){let r=_i.create(this.parent,this.mark,true,n);let i=this.children,s=this.size;if(e<s)i=ss(i,e,s,n);if(t>0)i=ss(i,0,t,n);for(let t=0;t<i.length;t++)i[t].parent=r;r.children=i;return r}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class ji extends Pi{constructor(t,e,n,r,i,s,o,l,u){super(t,[],i,s);this.node=e;this.outerDeco=n;this.innerDeco=r;this.nodeDOM=o}static create(t,e,n,r,i,s){let o=i.nodeViews[e.type.name],l;let u=o&&o(e,i,(()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)}),n,r);let a=u&&u.dom,f=u&&u.contentDOM;if(e.isText){if(!a)a=document.createTextNode(e.text);else if(a.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!a){let t=Nt.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:a,contentDOM:f}=t)}if(!f&&!e.isText&&a.nodeName!="BR"){if(!a.hasAttribute("contenteditable"))a.contentEditable="false";if(e.type.spec.draggable)a.draggable=true}let h=a;a=Zi(a,n,e);if(u)return l=new Ui(t,e,n,r,a,f||null,h,u,i,s+1);else if(e.isText)return new Bi(t,e,n,r,a,h,i);else return new ji(t,e,n,r,a,f||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>v.empty}return t}matchesNode(t,e,n){return this.dirty==Ci&&t.eq(this.node)&&Yi(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,r=e;let i=t.composing?this.localCompositionInfo(t,e):null;let s=i&&i.pos>-1?i:null;let o=i&&i.pos<0;let l=new Qi(this,s&&s.node,t);ns(this.node,this.innerDeco,((e,i,s)=>{if(e.spec.marks)l.syncToMarks(e.spec.marks,n,t);else if(e.type.side>=0&&!s)l.syncToMarks(i==this.node.childCount?M.none:this.node.child(i).marks,n,t);l.placeWidget(e,t,r)}),((e,s,u,a)=>{l.syncToMarks(e.marks,n,t);let f;if(l.findNodeMatch(e,s,u,a));else if(o&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(f=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(e,s,u,f,t));else if(l.updateNextNode(e,s,u,t,a,r));else{l.addNode(e,s,u,t,r)}r+=e.nodeSize}));l.syncToMarks([],n,t);if(this.node.isTextblock)l.addTextblockHacks();l.destroyRest();if(l.changed||this.dirty==Ni){if(s)this.protectLocalComposition(t,s);qi(this.contentDOM,this.children,t);if(Wr)rs(this.dom)}}localCompositionInfo(t,e){let{from:n,to:r}=t.state.selection;if(!(t.state.selection instanceof sn)||n<e||r>e+this.node.content.size)return null;let i=t.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let t=i.nodeValue;let s=is(this.node.content,t,n-e,r-e);return s<0?null:{node:i,pos:s,text:t}}else{return{node:i,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:n,text:r}){if(this.getDesc(e))return;let i=e;for(;;i=i.parentNode){if(i.parentNode==this.contentDOM)break;while(i.previousSibling)i.parentNode.removeChild(i.previousSibling);while(i.nextSibling)i.parentNode.removeChild(i.nextSibling);if(i.pmViewDesc)i.pmViewDesc=undefined}let s=new Hi(this,i,e,r);t.input.compositionNodes.push(s);this.children=ss(this.children,n,n+r.length,t,s)}update(t,e,n,r){if(this.dirty==Ii||!t.sameMarkup(this.node))return false;this.updateInner(t,e,n,r);return true}updateInner(t,e,n,r){this.updateOuterDeco(e);this.node=t;this.innerDeco=n;if(this.contentDOM)this.updateChildren(r,this.posAtStart);this.dirty=Ci}updateOuterDeco(t){if(Yi(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let n=this.dom;this.dom=Vi(this.dom,this.nodeDOM,Wi(this.outerDeco,this.node,e),Wi(t,this.node,e));if(this.dom!=n){n.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.draggable=true}}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function zi(t,e,n,r,i){Zi(r,e,t);let s=new ji(undefined,t,e,n,r,r,r,i,0);if(s.contentDOM)s.updateChildren(i,0);return s}class Bi extends ji{constructor(t,e,n,r,i,s,o){super(t,e,n,r,i,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,n,r){if(this.dirty==Ii||this.dirty!=Ci&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=Ci||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(r.trackWrites==this.nodeDOM)r.trackWrites=null}this.node=t;this.dirty=Ci;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,n)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,n){let r=this.node.cut(t,e),i=document.createTextNode(r.text);return new Bi(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=Ii}get domAtom(){return false}isText(t){return this.node.text==t}}class Fi extends Pi{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==Ci&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ui extends ji{constructor(t,e,n,r,i,s,o,l,u,a){super(t,e,n,r,i,s,o,u,a);this.spec=l}update(t,e,n,r){if(this.dirty==Ii)return false;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,e,n);if(i)this.updateInner(t,e,n,r);return i}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,n,r)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,r)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function qi(t,e,n){let r=t.firstChild,i=false;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){while(l!=r){r=Xi(r);i=true}r=r.nextSibling}else{i=true;t.insertBefore(l,r)}if(o instanceof _i){let e=r?r.previousSibling:t.lastChild;qi(o.contentDOM,o.children,n);r=e?e.nextSibling:t.firstChild}}while(r){r=Xi(r);i=true}if(i&&n.trackWrites==t)n.trackWrites=null}const Ki=function(t){if(t)this.nodeName=t};Ki.prototype=Object.create(null);const Ji=[new Ki];function Wi(t,e,n){if(t.length==0)return Ji;let r=n?Ji[0]:new Ki,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(!o)continue;if(o.nodeName)i.push(r=new Ki(o.nodeName));for(let t in o){let s=o[t];if(s==null)continue;if(n&&i.length==1)i.push(r=new Ki(e.isInline?"span":"div"));if(t=="class")r.class=(r.class?r.class+" ":"")+s;else if(t=="style")r.style=(r.style?r.style+";":"")+s;else if(t!="nodeName")r[t]=s}}return i}function Vi(t,e,n,r){if(n==Ji&&r==Ji)return e;let i=e;for(let e=0;e<r.length;e++){let s=r[e],o=n[e];if(e){let e;if(o&&o.nodeName==s.nodeName&&i!=t&&(e=i.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){i=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(i);o=Ji[0];i=e}}Gi(i,o||Ji[0],s)}return i}function Gi(t,e,n){for(let r in e)if(r!="class"&&r!="style"&&r!="nodeName"&&!(r in n))t.removeAttribute(r);for(let r in n)if(r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r])t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[];let i=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)if(i.indexOf(r[e])==-1)t.classList.remove(r[e]);for(let e=0;e<i.length;e++)if(r.indexOf(i[e])==-1)t.classList.add(i[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;while(r=n.exec(e.style))t.style.removeProperty(r[1])}if(n.style)t.style.cssText+=n.style}}function Zi(t,e,n){return Vi(t,t,Ji,Wi(e,n,t.nodeType!=1))}function Yi(t,e){if(t.length!=e.length)return false;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return false;return true}function Xi(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class Qi{constructor(t,e,n){this.lock=e;this.view=n;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=ts(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let r=0,i=this.stack.length>>1;let s=Math.min(i,t.length);while(r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&t[r].type.spec.spanning!==false)r++;while(r<i){this.destroyRest();this.top.dirty=Ci;this.index=this.stack.pop();this.top=this.stack.pop();i--}while(i<t.length){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let n=this.top.children[e];if(n.matchesMark(t[i])&&!this.isLocked(n.dom)){r=e;break}}if(r>-1){if(r>this.index){this.changed=true;this.destroyBetween(this.index,r)}this.top=this.top.children[this.index]}else{let r=_i.create(this.top,t[i],e,n);this.top.children.splice(this.index,0,r);this.top=r;this.changed=true}this.index=0;i++}}findNodeMatch(t,e,n,r){let i=-1,s;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,n)){i=this.top.children.indexOf(s,this.index)}else{for(let r=this.index,s=Math.min(this.top.children.length,r+5);r<s;r++){let s=this.top.children[r];if(s.matchesNode(t,e,n)&&!this.preMatch.matched.has(s)){i=r;break}}}if(i<0)return false;this.destroyBetween(this.index,i);this.index++;return true}updateNodeAt(t,e,n,r,i){let s=this.top.children[r];if(s.dirty==Ii&&s.dom==s.contentDOM)s.dirty=Ni;if(!s.update(t,e,n,i))return false;this.destroyBetween(this.index,r);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,n,r,i,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof ji){let u=this.preMatch.matched.get(l);if(u!=null&&u!=i)return false;let a=l.dom,f;let h=this.isLocked(a)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&l.dirty!=Ii&&Yi(e,l.outerDeco));if(!h&&l.update(t,e,n,r)){this.destroyBetween(this.index,o);if(l.dom!=a)this.changed=true;this.index++;return true}else if(!h&&(f=this.recreateWrapper(l,t,e,n,r,s))){this.destroyBetween(this.index,o);this.top.children[this.index]=f;if(f.contentDOM){f.dirty=Ni;f.updateChildren(r,s+1);f.dirty=Ci}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,n,r,i,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!Yi(n,t.outerDeco)||!r.eq(t.innerDeco))return null;let o=ji.create(this.top,e,n,r,i,s);if(o.contentDOM){o.children=t.children;t.children=[];for(let t of o.children)t.parent=o}t.destroy();return o}addNode(t,e,n,r,i){let s=ji.create(this.top,t,e,n,r,i);if(s.contentDOM)s.updateChildren(r,i+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(t)&&(t==r.widget||!r.widget.type.toDOM.parentNode)){this.index++}else{let r=new Di(this.top,t,e,n);this.top.children.splice(this.index++,0,r);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof _i){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Bi)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((Jr||qr)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let n=document.createElement(t);if(t=="IMG"){n.className="ProseMirror-separator";n.alt=""}if(t=="BR")n.className="ProseMirror-trailingBreak";let r=new Fi(this.top,[],n,null);if(e!=this.top)e.children.push(r);else e.children.splice(this.index++,0,r);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function ts(t,e){let n=e,r=n.children.length;let i=t.childCount,s=new Map,o=[];t:while(i>0){let l;for(;;){if(r){let t=n.children[r-1];if(t instanceof _i){n=t;r=t.children.length}else{l=t;r--;break}}else if(n==e){break t}else{r=n.parent.children.indexOf(n);n=n.parent}}let u=l.node;if(!u)continue;if(u!=t.child(i-1))break;--i;s.set(l,i);o.push(l)}return{index:i,matched:s,matches:o.reverse()}}function es(t,e){return t.type.side-e.type.side}function ns(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let n=0;n<t.childCount;n++){let o=t.child(n);r(o,i,e.forChild(s,o),n);s+=o.nodeSize}return}let o=0,l=[],u=null;for(let a=0;;){let f,h;while(o<i.length&&i[o].to==s){let t=i[o++];if(t.widget){if(!f)f=t;else(h||(h=[f])).push(t)}}if(f){if(h){h.sort(es);for(let t=0;t<h.length;t++)n(h[t],a,!!u)}else{n(f,a,!!u)}}let c,d;if(u){d=-1;c=u;u=null}else if(a<t.childCount){d=a;c=t.child(a++)}else{break}for(let t=0;t<l.length;t++)if(l[t].to<=s)l.splice(t--,1);while(o<i.length&&i[o].from<=s&&i[o].to>s)l.push(i[o++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(o<i.length&&i[o].from<t)t=i[o].from;for(let e=0;e<l.length;e++)if(l[e].to<t)t=l[e].to;if(t<p){u=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(o<i.length&&i[o].to<p)o++}let m=c.isInline&&!c.isLeaf?l.filter((t=>!t.inline)):l.slice();r(c,m,e.forChild(s,c),d);s=p}}function rs(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important";window.getComputedStyle(t).listStyle;t.style.cssText=e}}function is(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;s+=o.nodeSize;if(!o.isText)continue;let u=o.text;while(i<t.childCount){let e=t.child(i++);s+=e.nodeSize;if(!e.isText)break;u+=e.text}if(s>=n){if(s>=r&&u.slice(r-e.length-l,r-l)==e)return r-e.length;let t=l<r?u.lastIndexOf(e,r-l-1):-1;if(t>=0&&t+e.length+l>=n)return l+t;if(n==r&&u.length>=r+e.length-l&&u.slice(r-l,r-l+e.length)==e)return r}}return-1}function ss(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],a=l,f=l+=u.size;if(a>=n||f<=e){s.push(u)}else{if(a<e)s.push(u.slice(0,e-a,r));if(i){s.push(i);i=undefined}if(f>n)s.push(u.slice(n-a,u.size,r))}}return s}function ls(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0;let o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),u,a;if(Rr(n)){u=o;while(i&&!i.node)i=i.parent;let t=i.node;if(i&&t.isAtom&&ln.isSelectable(t)&&i.parent&&!(t.isInline&&Or(n.focusNode,n.focusOffset,i.dom))){let t=i.posBefore;a=new ln(o==t?l:r.resolve(t))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let e=o,i=o;for(let r=0;r<n.rangeCount;r++){let s=n.getRangeAt(r);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1));i=Math.max(i,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[u,o]=i==t.state.selection.anchor?[i,e]:[e,i];l=r.resolve(o)}else{u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1)}if(u<0)return null}let f=r.resolve(u);if(!a){let n=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;a=bs(t,f,l,n)}return a}function us(t){return t.editable?t.hasFocus():ks(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function as(t,e=false){let n=t.state.selection;gs(t,n);if(!us(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&qr){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&xr(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){ms(t)}else{let{anchor:r,head:i}=n,s,o;if(fs&&!(n instanceof sn)){if(!n.$from.parent.inlineContent)s=hs(t,n.from);if(!n.empty&&!n.$from.parent.inlineContent)o=hs(t,n.to)}t.docView.setSelection(r,i,t,e);if(fs){if(s)ds(s);if(o)ds(o)}if(n.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)ps(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const fs=Jr||qr&&Kr<63;function hs(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0);let i=r<n.childNodes.length?n.childNodes[r]:null;let s=r?n.childNodes[r-1]:null;if(Jr&&i&&i.contentEditable=="false")return cs(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return cs(i);else if(s)return cs(s)}}function cs(t){t.contentEditable="true";if(Jr&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function ds(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function ps(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange();let r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(n.anchorNode!=r||n.anchorOffset!=i){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!us(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function ms(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";if(r)e.collapse(n.parentNode,wr(n)+1);else e.collapse(n,0);if(!r&&!t.state.selection.visible&&zr&&Br<=11){n.disabled=true;n.disabled=false}}function gs(t,e){if(e instanceof ln){let n=t.docView.descAt(e.from);if(n!=t.lastSelectedViewDesc){ws(t);if(n)n.selectNode();t.lastSelectedViewDesc=n}}else{ws(t)}}function ws(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function bs(t,e,n,r){return t.someProp("createSelectionBetween",(r=>r(t,e,n)))||sn.between(e,n,r)}function vs(t){if(t.editable&&!t.hasFocus())return false;return ks(t)}function ks(t){let e=t.domSelectionRange();if(!e.anchorNode)return false;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return false}}function ys(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let n=t.domSelectionRange();return xr(e.node,e.offset,n.anchorNode,n.anchorOffset)}function xs(t,e){let{$anchor:n,$head:r}=t.selection;let i=e>0?n.max(r):n.min(r);let s=!i.parent.inlineContent?i:i.depth?t.doc.resolve(e>0?i.after():i.before()):null;return s&&tn.findFrom(s,e)}function Ms(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function Ss(t,e,n){let r=t.state.selection;if(r instanceof sn){if(n.indexOf("s")>-1){let{$head:n}=r,i=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return false;let s=t.state.doc.resolve(n.pos+i.nodeSize*(e<0?-1:1));return Ms(t,new sn(r.$anchor,s))}else if(!r.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let n=xs(t.state,e);if(n&&n instanceof ln)return Ms(t,n);return false}else if(!(Vr&&n.indexOf("m")>-1)){let n=r.$head,i=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter,s;if(!i||i.isText)return false;let o=e<0?n.pos-i.nodeSize:n.pos;if(!(i.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM))return false;if(ln.isSelectable(i)){return Ms(t,new ln(e<0?t.state.doc.resolve(n.pos-i.nodeSize):n))}else if(Yr){return Ms(t,new sn(t.state.doc.resolve(e<0?o:o+i.nodeSize)))}else{return false}}}else if(r instanceof ln&&r.node.isInline){return Ms(t,new sn(e>0?r.$to:r.$from))}else{let n=xs(t.state,e);if(n)return Ms(t,n);return false}}function Ts(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Es(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function As(t,e){return e<0?Os(t):$s(t)}function Os(t){let e=t.domSelectionRange();let n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=false;if(Fr&&n.nodeType==1&&r<Ts(n)&&Es(n.childNodes[r],-1))o=true;for(;;){if(r>0){if(n.nodeType!=1){break}else{let t=n.childNodes[r-1];if(Es(t,-1)){i=n;s=--r}else if(t.nodeType==3){n=t;r=n.nodeValue.length}else break}}else if(Rs(n)){break}else{let e=n.previousSibling;while(e&&Es(e,-1)){i=n.parentNode;s=wr(e);e=e.previousSibling}if(!e){n=n.parentNode;if(n==t.dom)break;r=0}else{n=e;r=Ts(n)}}}if(o)Ns(t,n,r);else if(i)Ns(t,i,s)}function $s(t){let e=t.domSelectionRange();let n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Ts(n);let s,o;for(;;){if(r<i){if(n.nodeType!=1)break;let t=n.childNodes[r];if(Es(t,1)){s=n;o=++r}else break}else if(Rs(n)){break}else{let e=n.nextSibling;while(e&&Es(e,1)){s=e.parentNode;o=wr(e)+1;e=e.nextSibling}if(!e){n=n.parentNode;if(n==t.dom)break;r=i=0}else{n=e;r=0;i=Ts(n)}}}if(s)Ns(t,s,o)}function Rs(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Cs(t,e){while(t&&e==t.childNodes.length&&!$r(t)){e=wr(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n;e=0}}function Ls(t,e){while(t&&!e&&!$r(t)){e=wr(t);t=t.parentNode}while(t&&e){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n;e=t.childNodes.length}}function Ns(t,e,n){if(e.nodeType!=3){let t,r;if(r=Cs(e,n)){e=r;n=0}else if(t=Ls(e,n)){e=t;n=t.nodeValue.length}}let r=t.domSelection();if(!r)return;if(Rr(r)){let t=document.createRange();t.setEnd(e,n);t.setStart(e,n);r.removeAllRanges();r.addRange(t)}else if(r.extend){r.extend(e,n)}t.domObserver.setCurSelection();let{state:i}=t;setTimeout((()=>{if(t.state==i)as(t)}),50)}function Is(t,e){let n=t.state.doc.resolve(e);if(!(qr||Gr)&&n.parent.inlineContent){let r=t.coordsAtPos(e);if(e>n.start()){let n=t.coordsAtPos(e-1);let i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(e<n.end()){let n=t.coordsAtPos(e+1);let i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}let r=getComputedStyle(t.dom).direction;return r=="rtl"?"rtl":"ltr"}function Ps(t,e,n){let r=t.state.selection;if(r instanceof sn&&!r.empty||n.indexOf("s")>-1)return false;if(Vr&&n.indexOf("m")>-1)return false;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=xs(t.state,e);if(n&&n instanceof ln)return Ms(t,n)}if(!i.parent.inlineContent){let n=e<0?i:s;let o=r instanceof an?tn.near(n,e):tn.findFrom(n,e);return o?Ms(t,o):false}return false}function Ds(t,e){if(!(t.state.selection instanceof sn))return true;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return true;if(!i)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=t.state.tr;if(e<0)r.delete(n.pos-s.nodeSize,n.pos);else r.delete(n.pos,n.pos+s.nodeSize);t.dispatch(r);return true}return false}function Hs(t,e,n){t.domObserver.stop();e.contentEditable=n;t.domObserver.start()}function _s(t){if(!Jr||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Hs(t,n,"true");setTimeout((()=>Hs(t,n,"false")),20)}return false}function js(t){let e="";if(t.ctrlKey)e+="c";if(t.metaKey)e+="m";if(t.altKey)e+="a";if(t.shiftKey)e+="s";return e}function zs(t,e){let n=e.keyCode,r=js(e);if(n==8||Vr&&n==72&&r=="c"){return Ds(t,-1)||As(t,-1)}else if(n==46&&!e.shiftKey||Vr&&n==68&&r=="c"){return Ds(t,1)||As(t,1)}else if(n==13||n==27){return true}else if(n==37||Vr&&n==66&&r=="c"){let e=n==37?Is(t,t.state.selection.from)=="ltr"?-1:1:-1;return Ss(t,e,r)||As(t,e)}else if(n==39||Vr&&n==70&&r=="c"){let e=n==39?Is(t,t.state.selection.from)=="ltr"?1:-1:1;return Ss(t,e,r)||As(t,e)}else if(n==38||Vr&&n==80&&r=="c"){return Ps(t,-1,r)||As(t,-1)}else if(n==40||Vr&&n==78&&r=="c"){return _s(t)||Ps(t,1,r)||As(t,1)}else if(r==(Vr?"m":"c")&&(n==66||n==73||n==89||n==90)){return true}return false}function Bs(t,e){t.someProp("transformCopied",(n=>{e=n(e,t)}));let n=[],{content:r,openStart:i,openEnd:s}=e;while(i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1){i--;s--;let t=r.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);r=t.content}let o=t.someProp("clipboardSerializer")||Nt.fromSchema(t.state.schema);let l=Xs(),u=l.createElement("div");u.appendChild(o.serializeFragment(r,{document:l}));let a=u.firstChild,f,h=0;while(a&&a.nodeType==1&&(f=Zs[a.nodeName.toLowerCase()])){for(let t=f.length-1;t>=0;t--){let e=l.createElement(f[t]);while(u.firstChild)e.appendChild(u.firstChild);u.appendChild(e);h++}a=u.firstChild}if(a&&a.nodeType==1)a.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(n)}`);let c=t.someProp("clipboardTextSerializer",(n=>n(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:u,text:c,slice:e}}function Fs(t,e,n,r,i){let s=i.parent.type.spec.code;let o,l;if(!n&&!e)return null;let u=!!e&&(r||s||!n);if(u){t.someProp("transformPastedText",(n=>{e=n(e,s||r,t)}));if(s){l=new T(v.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0);t.someProp("transformPasted",(e=>{l=e(l,t,true)}));return l}let n=t.someProp("clipboardTextParser",(n=>n(e,i,r,t)));if(n){l=n}else{let n=i.marks();let{schema:r}=t.state,s=Nt.fromSchema(r);o=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=o.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(r.text(t,n)))}))}}else{t.someProp("transformPastedHTML",(e=>{n=e(n,t)}));o=eo(n);if(Yr)no(o)}let a=o&&o.querySelector("[data-pm-slice]");let f=a&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(a.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let t=+f[3];t>0;t--){let t=o.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;o=t}if(!l){let e=t.someProp("clipboardParser")||t.someProp("domParser")||vt.fromSchema(t.state.schema);l=e.parseSlice(o,{preserveWhitespace:!!(u||f),context:i,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!Us.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(f){l=ro(Gs(l,+f[1],+f[2]),f[4])}else{l=T.maxOpen(qs(l.content,i),true);if(l.openStart||l.openEnd){let t=0,e=0;for(let e=l.content.firstChild;t<l.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=l.content.lastChild;e<l.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}l=Gs(l,t,e)}}t.someProp("transformPasted",(e=>{l=e(l,t,u)}));return l}const Us=/^(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 qs(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r=e.node(n);let i=r.contentMatchAt(e.index(n));let s,o=[];t.forEach((t=>{if(!o)return;let e=i.findWrapping(t.type),n;if(!e)return o=null;if(n=o.length&&s.length&&Js(e,s,t,o[o.length-1],0)){o[o.length-1]=n}else{if(o.length)o[o.length-1]=Ws(o[o.length-1],s.length);let n=Ks(t,e);o.push(n);i=i.matchType(n.type);s=e}}));if(o)return v.from(o)}return t}function Ks(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,v.from(t));return t}function Js(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Js(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));let o=r.contentMatchAt(r.childCount);if(o.matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(v.from(Ks(n,t,i+1))))}}function Ws(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ws(t.lastChild,e-1));let r=t.contentMatchAt(t.childCount).fillBefore(v.empty,true);return t.copy(n.append(r))}function Vs(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;if(t.childCount>1)s=0;if(i<r-1)l=Vs(l,e,n,r,i+1,s);if(i>=n)l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(v.empty,true));return t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Gs(t,e,n){if(e<t.openStart)t=new T(Vs(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(n<t.openEnd)t=new T(Vs(t.content,1,n,t.openEnd,0,0),t.openStart,n);return t}const Zs={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ys=null;function Xs(){return Ys||(Ys=document.implementation.createHTMLDocument("title"))}let Qs=null;function to(t){let e=window.trustedTypes;if(!e)return t;if(!Qs)Qs=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t});return Qs.createHTML(t)}function eo(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let n=Xs().createElement("div");let r=/<([a-z][^>\s]+)/i.exec(t),i;if(i=r&&Zs[r[1].toLowerCase()])t=i.map((t=>"<"+t+">")).join("")+t+i.map((t=>"</"+t+">")).reverse().join("");n.innerHTML=to(t);if(i)for(let t=0;t<i.length;t++)n=n.querySelector(i[t])||n;return n}function no(t){let e=t.querySelectorAll(qr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];if(r.childNodes.length==1&&r.textContent==" "&&r.parentNode)r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function ro(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch(e){return t}let{content:i,openStart:s,openEnd:o}=t;for(let t=r.length-2;t>=0;t-=2){let e=n.nodes[r[t]];if(!e||e.hasRequiredAttrs())break;i=v.from(e.create(r[t+1],i));s++;o++}return new T(i,s,o)}const io={};const so={};const oo={touchstart:true,touchmove:true};class lo{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:"",button:0};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.lastChromeDelete=0;this.composing=false;this.compositionNode=null;this.composingTimeout=-1;this.compositionNodes=[];this.compositionEndedAt=-2e8;this.compositionID=1;this.compositionPendingChanges=0;this.domChangeCount=0;this.eventHandlers=Object.create(null);this.hideSelectionGuard=null}}function uo(t){for(let e in io){let n=io[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(po(t,e)&&!co(t,e)&&(t.editable||!(e.type in so)))n(t,e)},oo[e]?{passive:true}:undefined)}if(Jr)t.dom.addEventListener("input",(()=>null));ho(t)}function ao(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function fo(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout);clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function ho(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)if(!t.input.eventHandlers[n])t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>co(t,e))}))}function co(t,e){return t.someProp("handleDOMEvents",(n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:false}))}function po(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return false;return true}function mo(t,e){if(!co(t,e)&&io[e.type]&&(t.editable||!(e.type in so)))io[e.type](t,e)}so.keydown=(t,e)=>{let n=e;t.input.shiftKey=n.keyCode==16||n.shiftKey;if($o(t,n))return;t.input.lastKeyCode=n.keyCode;t.input.lastKeyCodeTime=Date.now();if(Zr&&qr&&n.keyCode==13)return;if(n.keyCode!=229)t.domObserver.forceFlush();if(Wr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,Cr(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,n)))||zs(t,n)){n.preventDefault()}else{ao(t,"key")}};so.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};so.keypress=(t,e)=>{let n=e;if($o(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Vr&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n)))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof sn)||!r.$from.sameParent(r.$to)){let e=String.fromCharCode(n.charCode);let i=()=>t.state.tr.insertText(e).scrollIntoView();if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(n=>n(t,r.$from.pos,r.$to.pos,e,i))))t.dispatch(i());n.preventDefault()}};function go(t){return{left:t.clientX,top:t.clientY}}function wo(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function bo(t,e,n,r,i){if(r==-1)return false;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--){if(t.someProp(e,(e=>r>s.depth?e(t,n,s.nodeAfter,s.before(r),i,true):e(t,n,s.node(r),s.before(r),i,false))))return true}return false}function vo(t,e,n){if(!t.focused)t.focus();if(t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);if(n=="pointer")r.setMeta("pointer",true);t.dispatch(r)}function ko(t,e){if(e==-1)return false;let n=t.state.doc.resolve(e),r=n.nodeAfter;if(r&&r.isAtom&&ln.isSelectable(r)){vo(t,new ln(n),"pointer");return true}return false}function yo(t,e){if(e==-1)return false;let n=t.state.selection,r,i;if(n instanceof ln)r=n.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(ln.isSelectable(e)){if(r&&n.$from.depth>0&&t>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos)i=s.before(n.$from.depth);else i=s.before(t);break}}if(i!=null){vo(t,ln.create(t.state.doc,i),"pointer");return true}else{return false}}function xo(t,e,n,r,i){return bo(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(n=>n(t,e,r)))||(i?yo(t,n):ko(t,n))}function Mo(t,e,n,r){return bo(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(n=>n(t,e,r)))}function So(t,e,n,r){return bo(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(n=>n(t,e,r)))||To(t,n,r)}function To(t,e,n){if(n.button!=0)return false;let r=t.state.doc;if(e==-1){if(r.inlineContent){vo(t,sn.create(r,0,r.content.size),"pointer");return true}return false}let i=r.resolve(e);for(let e=i.depth+1;e>0;e--){let n=e>i.depth?i.nodeAfter:i.node(e);let s=i.before(e);if(n.inlineContent)vo(t,sn.create(r,s+1,s+1+n.content.size),"pointer");else if(ln.isSelectable(n))vo(t,ln.create(r,s),"pointer");else continue;return true}}function Eo(t){return Po(t)}const Ao=Vr?"metaKey":"ctrlKey";io.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Eo(t);let i=Date.now(),s="singleClick";if(i-t.input.lastClick.time<500&&wo(n,t.input.lastClick)&&!n[Ao]&&t.input.lastClick.button==n.button){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let o=t.posAtCoords(go(n));if(!o)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new Oo(t,o,n,!!r)}else if((s=="doubleClick"?Mo:So)(t,o.pos,o.inside,n)){n.preventDefault()}else{ao(t,"pointer")}};class Oo{constructor(t,e,n,r){this.view=t;this.pos=e;this.event=n;this.flushed=r;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!n[Ao];this.allowDefault=n.shiftKey;let i,s;if(e.inside>-1){i=t.state.doc.nodeAt(e.inside);s=e.inside}else{let n=t.state.doc.resolve(e.pos);i=n.parent;s=n.depth?n.before():0}const o=r?null:n.target;const l=o?t.docView.nearestDesc(o,true):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:u}=t.state;if(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==false||u instanceof ln&&u.from<=s&&u.to>s)this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Fr&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.draggable=true;if(this.mightDrag.setUneditable)setTimeout((()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")}),20);this.view.domObserver.start()}t.root.addEventListener("mouseup",this.up=this.up.bind(this));t.root.addEventListener("mousemove",this.move=this.move.bind(this));ao(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up);this.view.root.removeEventListener("mousemove",this.move);if(this.mightDrag&&this.target){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout((()=>as(this.view)));this.view.input.mouseDown=null}up(t){this.done();if(!this.view.dom.contains(t.target))return;let e=this.pos;if(this.view.state.doc!=this.startDoc)e=this.view.posAtCoords(go(t));this.updateAllowDefault(t);if(this.allowDefault||!e){ao(this.view,"pointer")}else if(xo(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||Jr&&this.mightDrag&&!this.mightDrag.node.isAtom||qr&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)){vo(this.view,tn.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{ao(this.view,"pointer")}}move(t){this.updateAllowDefault(t);ao(this.view,"pointer");if(t.buttons==0)this.done()}updateAllowDefault(t){if(!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4))this.allowDefault=true}}io.touchstart=t=>{t.input.lastTouch=Date.now();Eo(t);ao(t,"pointer")};io.touchmove=t=>{t.input.lastTouch=Date.now();ao(t,"pointer")};io.contextmenu=t=>Eo(t);function $o(t,e){if(t.composing)return true;if(Jr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const Ro=Zr?5e3:-1;so.compositionstart=so.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof sn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||n.marks();Po(t,true);t.markCursor=null}else{Po(t,!e.selection.empty);if(Fr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,r=e.focusOffset;n&&n.nodeType==1&&r!=0;){let e=r<0?n.lastChild:n.childNodes[r-1];if(!e)break;if(e.nodeType==3){let n=t.domSelection();if(n)n.collapse(e,e.nodeValue.length);break}else{n=e;r=-1}}}}t.input.composing=true}Co(t,Ro)};so.compositionend=(t,e)=>{if(t.composing){t.input.composing=false;t.input.compositionEndedAt=e.timeStamp;t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0;t.input.compositionNode=null;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;Co(t,20)}};function Co(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>Po(t)),e)}function Lo(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=Io()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function No(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Er(e.focusNode,e.focusOffset);let r=Ar(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let e=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!e||!e.isText(r.nodeValue)){return r}else if(t.input.compositionNode==r){let t=n.pmViewDesc;if(!(!t||!t.isText(n.nodeValue)))return r}}return n||r}function Io(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function Po(t,e=false){if(Zr&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();Lo(t);if(e||t.docView&&t.docView.dirty){let n=ls(t),r=t.state.selection;if(n&&!n.eq(r))t.dispatch(t.state.tr.setSelection(n));else if((t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent)t.dispatch(t.state.tr.deleteSelection());else t.updateState(t.state);return true}return false}function Do(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e);n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e);t.dom.blur();r.removeAllRanges();r.addRange(i);setTimeout((()=>{if(n.parentNode)n.parentNode.removeChild(n);t.focus()}),50)}const Ho=zr&&Br<15||Wr&&Xr<604;io.copy=so.cut=(t,e)=>{let n=e;let r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=Ho?null:n.clipboardData;let o=r.content(),{dom:l,text:u}=Bs(t,o);if(s){n.preventDefault();s.clearData();s.setData("text/html",l.innerHTML);s.setData("text/plain",u)}else{Do(t,l)}if(i)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function _o(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function jo(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));if(!n)r.contentEditable="true";r.style.cssText="position: fixed; left: -10000px; top: 10px";r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(r.parentNode)r.parentNode.removeChild(r);if(n)zo(t,r.value,null,i,e);else zo(t,r.textContent,r.innerHTML,i,e)}),50)}function zo(t,e,n,r,i){let s=Fs(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,i,s||T.empty))))return true;if(!s)return false;let o=_o(s);let l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);t.dispatch(l.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Bo(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}so.paste=(t,e)=>{let n=e;if(t.composing&&!Zr)return;let r=Ho?null:n.clipboardData;let i=t.input.shiftKey&&t.input.lastKeyCode!=45;if(r&&zo(t,Bo(r),r.getData("text/html"),i,n))n.preventDefault();else jo(t,n)};class Fo{constructor(t,e,n){this.slice=t;this.move=e;this.node=n}}const Uo=Vr?"altKey":"ctrlKey";function qo(t,e){let n=t.someProp("dragCopies",(t=>!t(e)));return n!=null?n:!e[Uo]}io.dragstart=(t,e)=>{let n=e;let r=t.input.mouseDown;if(r)r.done();if(!n.dataTransfer)return;let i=t.state.selection;let s=i.empty?null:t.posAtCoords(go(n));let o;if(s&&s.pos>=i.from&&s.pos<=(i instanceof ln?i.to-1:i.to));else if(r&&r.mightDrag){o=ln.create(t.state.doc,r.mightDrag.pos)}else if(n.target&&n.target.nodeType==1){let e=t.docView.nearestDesc(n.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)o=ln.create(t.state.doc,e.posBefore)}let l=(o||t.state.selection).content();let{dom:u,text:a,slice:f}=Bs(t,l);if(!n.dataTransfer.files.length||!qr||Kr>120)n.dataTransfer.clearData();n.dataTransfer.setData(Ho?"Text":"text/html",u.innerHTML);n.dataTransfer.effectAllowed="copyMove";if(!Ho)n.dataTransfer.setData("text/plain",a);t.dragging=new Fo(f,qo(t,n),o)};io.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};so.dragover=so.dragenter=(t,e)=>e.preventDefault();so.drop=(t,e)=>{let n=e;let r=t.dragging;t.dragging=null;if(!n.dataTransfer)return;let i=t.posAtCoords(go(n));if(!i)return;let s=t.state.doc.resolve(i.pos);let o=r&&r.slice;if(o){t.someProp("transformPasted",(e=>{o=e(o,t,false)}))}else{o=Fs(t,Bo(n.dataTransfer),Ho?null:n.dataTransfer.getData("text/html"),false,s)}let l=!!(r&&qo(t,n));if(t.someProp("handleDrop",(e=>e(t,n,o||T.empty,l)))){n.preventDefault();return}if(!o)return;n.preventDefault();let u=o?Ne(t.state.doc,s.pos,o):s.pos;if(u==null)u=s.pos;let a=t.state.tr;if(l){let{node:t}=r;if(t)t.replace(a);else a.deleteSelection()}let f=a.mapping.map(u);let h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1;let c=a.doc;if(h)a.replaceRangeWith(f,f,o.content.firstChild);else a.replaceRange(f,f,o);if(a.doc.eq(c))return;let d=a.doc.resolve(f);if(h&&ln.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild)){a.setSelection(new ln(d))}else{let e=a.mapping.map(u);a.mapping.maps[a.mapping.maps.length-1].forEach(((t,n,r,i)=>e=i));a.setSelection(bs(t,d,a.doc.resolve(e)))}t.focus();t.dispatch(a.setMeta("uiEvent","drop"))};io.focus=t=>{t.input.lastFocus=Date.now();if(!t.focused){t.domObserver.stop();t.dom.classList.add("ProseMirror-focused");t.domObserver.start();t.focused=true;setTimeout((()=>{if(t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange()))as(t)}),20)}};io.blur=(t,e)=>{let n=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(n.relatedTarget&&t.dom.contains(n.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};io.beforeinput=(t,e)=>{let n=e;if(qr&&Zr&&n.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;t.dom.blur();t.focus();if(t.someProp("handleKeyDown",(e=>e(t,Cr(8,"Backspace")))))return;let{$cursor:n}=t.state.selection;if(n&&n.pos>0)t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in so)io[t]=so[t];function Ko(t,e){if(t==e)return true;for(let n in t)if(t[n]!==e[n])return false;for(let n in e)if(!(n in t))return false;return true}class Jo{constructor(t,e){this.toDOM=t;this.spec=e||Yo;this.side=this.spec.side||0}map(t,e,n,r){let{pos:i,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new Go(i-n,i-n,this)}valid(){return true}eq(t){return this==t||t instanceof Jo&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ko(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class Wo{constructor(t,e){this.attrs=t;this.spec=e||Yo}map(t,e,n,r){let i=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n;let s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new Go(i,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Wo&&Ko(this.attrs,t.attrs)&&Ko(this.spec,t.spec)}static is(t){return t.type instanceof Wo}destroy(){}}class Vo{constructor(t,e){this.attrs=t;this.spec=e||Yo}map(t,e,n,r){let i=t.mapResult(e.from+r,1);if(i.deleted)return null;let s=t.mapResult(e.to+r,-1);if(s.deleted||s.pos<=i.pos)return null;return new Go(i.pos-n,s.pos-n,this)}valid(t,e){let{index:n,offset:r}=t.content.findIndex(e.from),i;return r==e.from&&!(i=t.child(n)).isText&&r+i.nodeSize==e.to}eq(t){return this==t||t instanceof Vo&&Ko(this.attrs,t.attrs)&&Ko(this.spec,t.spec)}destroy(){}}class Go{constructor(t,e,n){this.from=t;this.to=e;this.type=n}copy(t,e){return new Go(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new Go(t,t,new Jo(e,n))}static inline(t,e,n,r){return new Go(t,e,new Wo(n,r))}static node(t,e,n,r){return new Go(t,e,new Vo(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Wo}get widget(){return this.type instanceof Jo}}const Zo=[],Yo={};class Xo{constructor(t,e){this.local=t.length?t:Zo;this.children=e.length?e:Zo}static create(t,e){return e.length?ol(e,t,0,Yo):Qo}find(t,e,n){let r=[];this.findInner(t==null?0:t,e==null?1e9:e,r,0,n);return r}findInner(t,e,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];if(o.from<=e&&o.to>=t&&(!i||i(o.spec)))n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,n,r+o,i)}}}map(t,e,n){if(this==Qo||t.maps.length==0)return this;return this.mapInner(t,e,0,0,n||Yo)}mapInner(t,e,n,r,i){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(t,n,r);if(l&&l.type.valid(e,l))(s||(s=[])).push(l);else if(i.onRemove)i.onRemove(this.local[o].spec)}if(this.children.length)return el(this.children,s||[],t,e,n,r,i);else return s?new Xo(s.sort(ll),Zo):Qo}add(t,e){if(!e.length)return this;if(this==Qo)return Xo.create(t,e);return this.addInner(t,e,0)}addInner(t,e,n){let r,i=0;t.forEach(((t,s)=>{let o=s+n,l;if(!(l=il(e,t,o)))return;if(!r)r=this.children.slice();while(i<r.length&&r[i]<s)i+=3;if(r[i]==s)r[i+2]=r[i+2].addInner(t,l,o+1);else r.splice(i,0,s,s+t.nodeSize,ol(l,t,o+1,Yo));i+=3}));let s=nl(i?sl(e):e,-n);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new Xo(s.length?this.local.concat(s).sort(ll):this.local,r||this.children)}remove(t){if(t.length==0||this==Qo)return this;return this.removeInner(t,0)}removeInner(t,e){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i;let s=n[r]+e,o=n[r+1]+e;for(let e=0,n;e<t.length;e++)if(n=t[e]){if(n.from>s&&n.to<o){t[e]=null;(i||(i=[])).push(n)}}if(!i)continue;if(n==this.children)n=this.children.slice();let l=n[r+2].removeInner(i,s+1);if(l!=Qo){n[r+2]=l}else{n.splice(r,3);r-=3}}if(r.length)for(let n=0,i;n<t.length;n++)if(i=t[n]){for(let t=0;t<r.length;t++)if(r[t].eq(i,e)){if(r==this.local)r=this.local.slice();r.splice(t--,1)}}if(n==this.children&&r==this.local)return this;return r.length||n.length?new Xo(r,n):Qo}forChild(t,e){if(this==Qo)return this;if(e.isLeaf)return Xo.empty;let n,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)n=this.children[e+2];break}let i=t+1,s=i+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>i&&e.type instanceof Wo){let t=Math.max(i,e.from)-i,n=Math.min(s,e.to)-i;if(t<n)(r||(r=[])).push(e.copy(t,n))}}if(r){let t=new Xo(r.sort(ll),Zo);return n?new tl([t,n]):t}return n||Qo}eq(t){if(this==t)return true;if(!(t instanceof Xo)||this.local.length!=t.local.length||this.children.length!=t.children.length)return false;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return false;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return false;return true}locals(t){return ul(this.localsInner(t))}localsInner(t){if(this==Qo)return Zo;if(t.inlineContent||!this.local.some(Wo.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof Wo))e.push(this.local[t])}return e}forEachSet(t){t(this)}}Xo.empty=new Xo([],[]);Xo.removeOverlap=ul;const Qo=Xo.empty;class tl{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,Yo)));return tl.from(n)}forChild(t,e){if(e.isLeaf)return Xo.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(t,e);if(i==Qo)continue;if(i instanceof tl)n=n.concat(i.members);else n.push(i)}return tl.from(n)}eq(t){if(!(t instanceof tl)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,n=true;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(t);if(!i.length)continue;if(!e){e=i}else{if(n){e=e.slice();n=false}for(let t=0;t<i.length;t++)e.push(i[t])}}return e?ul(n?e:e.sort(ll)):Zo}static from(t){switch(t.length){case 0:return Qo;case 1:return t[0];default:return new tl(t.every((t=>t instanceof Xo))?t:t.reduce(((t,e)=>t.concat(e instanceof Xo?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function el(t,e,n,r,i,s,o){let l=t.slice();for(let t=0,e=s;t<n.maps.length;t++){let r=0;n.maps[t].forEach(((t,n,i,s)=>{let o=s-i-(n-t);for(let i=0;i<l.length;i+=3){let s=l[i+1];if(s<0||t>s+e-r)continue;let u=l[i]+e-r;if(n>=u){l[i+1]=t<=u?-2:-1}else if(t>=e&&o){l[i]+=o;l[i+1]+=o}}r+=o}));e=n.maps[t].map(e,-1)}let u=false;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(l[e+1]==-2){u=true;l[e+1]=-1;continue}let a=n.map(t[e]+s),f=a-i;if(f<0||f>=r.content.size){u=true;continue}let h=n.map(t[e+1]+s,-1),c=h-i;let{index:d,offset:p}=r.content.findIndex(f);let m=r.maybeChild(d);if(m&&p==f&&p+m.nodeSize==c){let r=l[e+2].mapInner(n,m,a+1,t[e]+s+1,o);if(r!=Qo){l[e]=f;l[e+1]=c;l[e+2]=r}else{l[e+1]=-2;u=true}}else{u=true}}if(u){let u=rl(l,t,e,n,i,s,o);let a=ol(u,r,0,o);e=a.local;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){l.splice(t,3);t-=3}for(let t=0,e=0;t<a.children.length;t+=3){let n=a.children[t];while(e<l.length&&l[e]<n)e+=3;l.splice(e,0,a.children[t],a.children[t+1],a.children[t+2])}}return new Xo(e.sort(ll),l)}function nl(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Go(i.from+e,i.to+e,i.type))}return n}function rl(t,e,n,r,i,s,o){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(r,i,e);if(l)n.push(l);else if(o.onRemove)o.onRemove(t.local[s].spec)}for(let n=0;n<t.children.length;n+=3)l(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)if(t[n+1]==-1)l(t[n+2],e[n]+s+1);return n}function il(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>n&&s.to<r){(i||(i=[])).push(s);t[e]=null}}return i}function sl(t){let e=[];for(let n=0;n<t.length;n++)if(t[n]!=null)e.push(t[n]);return e}function ol(t,e,n,r){let i=[],s=false;e.forEach(((e,o)=>{let l=il(t,e,o+n);if(l){s=true;let t=ol(l,e,n+o+1,r);if(t!=Qo)i.push(o,o+e.nodeSize,t)}}));let o=nl(s?sl(t):t,-n).sort(ll);for(let t=0;t<o.length;t++)if(!o[t].type.valid(e,o[t])){if(r.onRemove)r.onRemove(o[t].spec);o.splice(t--,1)}return o.length||i.length?new Xo(o,i):Qo}function ll(t,e){return t.from-e.from||t.to-e.to}function ul(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){if(s.to!=r.to){if(e==t)e=t.slice();e[i]=s.copy(s.from,r.to);al(e,i+1,s.copy(r.to,s.to))}continue}else{if(s.from<r.to){if(e==t)e=t.slice();e[n]=r.copy(r.from,s.from);al(e,i,r.copy(s.from,r.to))}break}}}return e}function al(t,e,n){while(e<t.length&&ll(n,t[e])>0)e++;t.splice(e,0,n)}function fl(t){let e=[];t.someProp("decorations",(n=>{let r=n(t.state);if(r&&r!=Qo)e.push(r)}));if(t.cursorWrapper)e.push(Xo.create(t.state.doc,[t.cursorWrapper.deco]));return tl.from(e)}const hl={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const cl=zr&&Br<=11;class dl{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}set(t){this.anchorNode=t.anchorNode;this.anchorOffset=t.anchorOffset;this.focusNode=t.focusNode;this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class pl{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new dl;this.onCharData=null;this.suppressingSelectionUpdates=false;this.lastChangedTextNode=null;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(zr&&Br<=11&&t.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)))this.flushSoon();else this.flush()}));if(cl){this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue});this.flushSoon()}}this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1;this.flush()}),20)}forceFlush(){if(this.flushingSoon>-1){window.clearTimeout(this.flushingSoon);this.flushingSoon=-1;this.flush()}}start(){if(this.observer){this.observer.takeRecords();this.observer.observe(this.view.dom,hl)}if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}if(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=true;setTimeout((()=>this.suppressingSelectionUpdates=false),50)}onSelectionChange(){if(!vs(this.view))return;if(this.suppressingSelectionUpdates)return as(this.view);if(zr&&Br<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&xr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return true;let e=new Set,n;for(let n=t.focusNode;n;n=br(n))e.add(n);for(let r=t.anchorNode;r;r=br(r))if(e.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let n=t.domSelectionRange();let r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&vs(t)&&!this.ignoreSelectionChange(n);let i=-1,s=-1,o=false,l=[];if(t.editable){for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],l);if(n){i=i<0?n.from:Math.min(n.from,i);s=s<0?n.to:Math.max(n.to,s);if(n.typeOver)o=true}}}if(Fr&&l.length){let e=l.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,n]=e;if(t.parentNode&&t.parentNode.parentNode==n.parentNode)n.remove();else t.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;if(e&&e.nodeName=="LI"&&(!n||kl(t,n)!=e))r.remove()}}}let u=null;if(i<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Rr(n)&&(u=ls(t))&&u.eq(tn.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;as(t);this.currentSelection.set(n);t.scrollToSelection()}else if(i>-1||r){if(i>-1){t.docView.markDirty(i,s);wl(t)}this.handleDOMChange(i,s,o,l);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(n))as(t);this.currentSelection.set(n)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(n==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if(t.type=="childList"){for(let n=0;n<t.addedNodes.length;n++){let r=t.addedNodes[n];e.push(r);if(r.nodeType==3)this.lastChangedTextNode=r}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let r=t.previousSibling,i=t.nextSibling;if(zr&&Br<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:s}=t.addedNodes[e];if(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)r=n;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)i=s}}let s=r&&r.parentNode==t.target?wr(r)+1:0;let o=n.localPosFromDOM(t.target,s,-1);let l=i&&i.parentNode==t.target?wr(i):t.target.childNodes.length;let u=n.localPosFromDOM(t.target,l,1);return{from:o,to:u}}else if(t.type=="attributes"){return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}}else{this.lastChangedTextNode=t.target;return{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let ml=new WeakMap;let gl=false;function wl(t){if(ml.has(t))return;ml.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Fr;if(gl)return;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.");gl=true}}function bl(t,e){let n=e.startContainer,r=e.startOffset;let i=e.endContainer,s=e.endOffset;let o=t.domAtPos(t.state.selection.anchor);if(xr(o.node,o.offset,i,s))[n,r,i,s]=[i,s,n,r];return{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function vl(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return bl(t,n)}let n;function r(t){t.preventDefault();t.stopImmediatePropagation();n=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",r,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",r,true);return n?bl(t,n):null}function kl(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let e=t.docView.nearestDesc(n,true);if(e&&e.node.isBlock)return n}return null}function yl(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=t.docView.parseRange(e,n);let u=t.domSelectionRange();let a;let f=u.anchorNode;if(f&&t.dom.contains(f.nodeType==1?f:f.parentNode)){a=[{node:f,offset:u.anchorOffset}];if(!Rr(u))a.push({node:u.focusNode,offset:u.focusOffset})}if(qr&&t.input.lastKeyCode===8){for(let t=s;t>i;t--){let e=r.childNodes[t-1],n=e.pmViewDesc;if(e.nodeName=="BR"&&!n){s=t;break}if(!n||n.size)break}}let h=t.state.doc;let c=t.someProp("domParser")||vt.fromSchema(t.state.schema);let d=h.resolve(o);let p=null,m=c.parse(r,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:i,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:a,ruleFromNode:xl,context:d});if(a&&a[0].pos!=null){let t=a[0].pos,e=a[1]&&a[1].pos;if(e==null)e=t;p={anchor:t+o,head:e+o}}return{doc:m,sel:p,from:o,to:l}}function xl(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(Jr&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");t.appendChild(document.createElement("li"));return{skip:t}}else if(t.parentNode.lastChild==t||Jr&&/^(tr|table)$/i.test(t.parentNode.nodeName)){return{ignore:true}}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder")){return{ignore:true}}return null}const Ml=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Sl(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let n=ls(t,e);if(n&&!t.state.selection.eq(n)){if(qr&&Zr&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Cr(13,"Enter")))))return;let r=t.state.tr.setSelection(n);if(e=="pointer")r.setMeta("pointer",true);else if(e=="key")r.scrollIntoView();if(s)r.setMeta("composition",s);t.dispatch(r)}return}let o=t.state.doc.resolve(e);let l=o.sharedDepth(n);e=o.before(l+1);n=t.state.doc.resolve(n).after(l+1);let u=t.state.selection;let a=yl(t,e,n);let f=t.state.doc,h=f.slice(a.from,a.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=$l(h.content,a.doc.content,a.from,c,d);if(p)t.input.domChangeCount++;if((Wr&&t.input.lastIOSEnter>Date.now()-225||Zr)&&i.some((t=>t.nodeType==1&&!Ml.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,Cr(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(r&&u instanceof sn&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(a.sel&&a.sel.anchor!=a.sel.head)){p={start:u.from,endA:u.to,endB:u.to}}else{if(a.sel){let e=Tl(t,t.state.doc,a.sel);if(e&&!e.eq(t.state.selection)){let n=t.state.tr.setSelection(e);if(s)n.setMeta("composition",s);t.dispatch(n)}}return}}if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof sn){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=a.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=a.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(zr&&Br<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>a.from&&a.doc.textBetween(p.start-a.from-1,p.start-a.from+1)=="  "){p.start--;p.endA--;p.endB--}let m=a.doc.resolveNoCache(p.start-a.from);let g=a.doc.resolveNoCache(p.endB-a.from);let w=f.resolve(p.start);let b=m.sameParent(g)&&m.parent.inlineContent&&w.end()>=p.endA;if((Wr&&t.input.lastIOSEnter>Date.now()-225&&(!b||i.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<a.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(a.doc.textBetween(m.pos,g.pos,"","")))&&t.someProp("handleKeyDown",(e=>e(t,Cr(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Al(f,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",(e=>e(t,Cr(8,"Backspace"))))){if(Zr&&qr)t.domObserver.suppressSelectionUpdates();return}if(qr&&p.endB==p.start)t.input.lastChromeDelete=Date.now();if(Zr&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==p.endA){p.endB-=2;g=a.doc.resolveNoCache(p.endB-a.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Cr(13,"Enter"))}))}),20)}let v=p.start,k=p.endA;let y=e=>{let n=e||t.state.tr.replace(v,k,a.doc.slice(p.start-a.from,p.endB-a.from));if(a.sel){let e=Tl(t,n.doc,a.sel);if(e&&!(qr&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==v||e.head==n.mapping.map(k)-1)||zr&&e.empty&&e.head==v))n.setSelection(e)}if(s)n.setMeta("composition",s);return n.scrollIntoView()};let x;if(b){if(m.pos==g.pos){if(zr&&Br<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>as(t)),20)}let e=y(t.state.tr.delete(v,k));let n=f.resolve(p.start).marksAcross(f.resolve(p.endA));if(n)e.ensureMarks(n);t.dispatch(e)}else if(p.endA==p.endB&&(x=El(m.parent.content.cut(m.parentOffset,g.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start())))){let e=y(t.state.tr);if(x.type=="add")e.addMark(v,k,x.mark);else e.removeMark(v,k,x.mark);t.dispatch(e)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,g.parentOffset);let n=()=>y(t.state.tr.insertText(e,v,k));if(!t.someProp("handleTextInput",(r=>r(t,v,k,e,n))))t.dispatch(n())}}else{t.dispatch(y())}}function Tl(t,e,n){if(Math.max(n.anchor,n.head)>e.content.size)return null;return bs(t,e.resolve(n.anchor),e.resolve(n.head))}function El(t,e){let n=t.firstChild.marks,r=e.firstChild.marks;let i=n,s=r,o,l,u;for(let t=0;t<r.length;t++)i=r[t].removeFromSet(i);for(let t=0;t<n.length;t++)s=n[t].removeFromSet(s);if(i.length==1&&s.length==0){l=i[0];o="add";u=t=>t.mark(l.addToSet(t.marks))}else if(i.length==0&&s.length==1){l=s[0];o="remove";u=t=>t.mark(l.removeFromSet(t.marks))}else{return null}let a=[];for(let t=0;t<e.childCount;t++)a.push(u(e.child(t)));if(v.from(a).eq(t))return{mark:l,type:o}}function Al(t,e,n,r,i){if(n-e<=i.pos-r.pos||Ol(r,true,false)<i.pos)return false;let s=t.resolve(e);if(!r.parent.isTextblock){let t=s.nodeAfter;return t!=null&&n==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let o=t.resolve(Ol(s,true,true));if(!o.parent.isTextblock||o.pos>n||Ol(o,true,false)<n)return false;return r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Ol(t,e,n){let r=t.depth,i=e?t.end():t.pos;while(r>0&&(e||t.indexAfter(r)==t.node(r).childCount)){r--;i++;e=false}if(n){let e=t.node(r).maybeChild(t.indexAfter(r));while(e&&!e.isLeaf){e=e.firstChild;i++}}return i}function $l(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let t=Math.max(0,s-Math.min(o,l));r-=o+t-s}if(o<s&&t.size<e.size){let t=r<=s&&r>=o?s-r:0;s-=t;if(s&&s<e.size&&Rl(e.textBetween(s-1,s+1)))s+=t?1:-1;l=s+(l-o);o=s}else if(l<s){let e=r<=s&&r>=l?s-r:0;s-=e;if(s&&s<t.size&&Rl(t.textBetween(s-1,s+1)))s+=e?1:-1;o=s+(o-l);l=s}return{start:s,endA:o,endB:l}}function Rl(t){if(t.length!=2)return false;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Cl{constructor(t,e){this._root=null;this.focused=false;this.trackWrites=null;this.mounted=false;this.markCursor=null;this.cursorWrapper=null;this.lastSelectedViewDesc=undefined;this.input=new lo;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(_l);this.dispatch=this.dispatch.bind(this);this.dom=t&&t.mount||document.createElement("div");if(t){if(t.appendChild)t.appendChild(this.dom);else if(typeof t=="function")t(this.dom);else if(t.mount)this.mounted=true}this.editable=Il(this);Nl(this);this.nodeViews=Dl(this);this.docView=zi(this.state.doc,Ll(this),fl(this),this.dom,this);this.domObserver=new pl(this,((t,e,n,r)=>Sl(this,t,e,n,r)));this.domObserver.start();uo(this);this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){if(t.handleDOMEvents!=this._props.handleDOMEvents)ho(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(_l);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let r=this.state,i=false,s=false;if(t.storedMarks&&this.composing){Lo(this);s=true}this.state=t;let o=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Dl(this);if(Hl(t,this.nodeViews)){this.nodeViews=t;i=true}}if(o||e.handleDOMEvents!=this._props.handleDOMEvents){ho(this)}this.editable=Il(this);Nl(this);let l=fl(this),u=Ll(this);let a=r.plugins!=t.plugins&&!r.doc.eq(t.doc)?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve";let f=i||!this.docView.matchesNode(t.doc,u,l);if(f||!t.selection.eq(r.selection))s=true;let h=a=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ri(this);if(s){this.domObserver.stop();let e=f&&(zr||qr)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&Pl(r.selection,t.selection);if(f){let n=qr?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=No(this);if(i||!this.docView.update(t.doc,u,l,this)){this.docView.updateOuterDeco(u);this.docView.destroy();this.docView=zi(t.doc,u,l,this.dom,this)}if(n&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ys(this))){as(this,e)}else{gs(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(r);if(((n=this.dragging)===null||n===void 0?void 0:n.node)&&!r.doc.eq(t.doc))this.updateDraggedNode(this.dragging,r);if(a=="reset"){this.dom.scrollTop=0}else if(a=="to selection"){this.scrollToSelection()}else if(h){si(h)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode));else if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof ln){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)ni(this,e.getBoundingClientRect(),t)}else{ni(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];if(n.update)n.update(this,t)}}}updateDraggedNode(t,e){let n=t.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node){r=n.from}else{let t=n.from+(this.state.doc.content.size-e.doc.content.size);let i=t>0&&this.state.doc.nodeAt(t);if(i==n.node)r=t}this.dragging=new Fo(t.slice,t.move,r<0?undefined:ln.create(this.state.doc,r))}someProp(t,e){let n=this._props&&this._props[t],r;if(n!=null&&(r=e?e(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[t];if(i!=null&&(r=e?e(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let s=i[n].props[t];if(s!=null&&(r=e?e(s):s))return r}}hasFocus(){if(zr){let t=this.root.activeElement;if(t==this.dom)return true;if(!t||!this.dom.contains(t))return false;while(t&&this.dom!=t&&this.dom.contains(t)){if(t.contentEditable=="false")return false;t=t.parentElement}return true}return this.root.activeElement==this.dom}focus(){this.domObserver.stop();if(this.editable)ui(this.dom);as(this);this.domObserver.start()}get root(){let t=this._root;if(t==null)for(let t=this.dom.parentNode;t;t=t.parentNode){if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return t||document}updateRoot(){this._root=null}posAtCoords(t){return gi(this,t)}coordsAtPos(t,e=1){return ki(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let r=this.docView.posFromDOM(t,e,n);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return Ri(this,e||this.state,t)}pasteHTML(t,e){return zo(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return zo(this,t,null,true,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return Bs(this,t)}destroy(){if(!this.docView)return;fo(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],fl(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;yr()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return mo(this,t)}domSelectionRange(){let t=this.domSelection();if(!t)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return Jr&&this.root.nodeType===11&&Lr(this.dom.ownerDocument)==this.dom&&vl(this,t)||t}domSelection(){return this.root.getSelection()}}Cl.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))};function Ll(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(n=>{if(typeof n=="function")n=n(t.state);if(n)for(let t in n){if(t=="class")e.class+=" "+n[t];else if(t=="style")e.style=(e.style?e.style+";":"")+n[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(n[t])}}));if(!e.translate)e.translate="no";return[Go.node(0,t.state.doc.content.size,e)]}function Nl(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator";e.setAttribute("mark-placeholder","true");e.setAttribute("alt","");t.cursorWrapper={dom:e,deco:Go.widget(t.state.selection.from,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function Il(t){return!t.someProp("editable",(e=>e(t.state)===false))}function Pl(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Dl(t){let e=Object.create(null);function n(t){for(let n in t)if(!Object.prototype.hasOwnProperty.call(e,n))e[n]=t[n]}t.someProp("nodeViews",n);t.someProp("markViews",n);return e}function Hl(t,e){let n=0,r=0;for(let r in t){if(t[r]!=e[r])return true;n++}for(let t in e)r++;return n!=r}function _l(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var jl={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:"'"};var zl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var Bl=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var Fl=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ul=0;Ul<10;Ul++)jl[48+Ul]=jl[96+Ul]=String(Ul);for(var Ul=1;Ul<=24;Ul++)jl[Ul+111]="F"+Ul;for(var Ul=65;Ul<=90;Ul++){jl[Ul]=String.fromCharCode(Ul+32);zl[Ul]=String.fromCharCode(Ul)}for(var ql in jl)if(!zl.hasOwnProperty(ql))zl[ql]=jl[ql];function Kl(t){var e=Bl&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Fl&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var n=!e&&t.key||(t.shiftKey?zl:jl)[t.keyCode]||t.key||"Unidentified";if(n=="Esc")n="Escape";if(n=="Del")n="Delete";if(n=="Left")n="ArrowLeft";if(n=="Up")n="ArrowUp";if(n=="Right")n="ArrowRight";if(n=="Down")n="ArrowDown";return n}const Jl=typeof navigator!="undefined"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);const Wl=typeof navigator!="undefined"&&/Win/.test(navigator.platform);function Vl(t){let e=t.split(/-(?!$)/),n=e[e.length-1];if(n=="Space")n=" ";let r,i,s,o;for(let t=0;t<e.length-1;t++){let n=e[t];if(/^(cmd|meta|m)$/i.test(n))o=true;else if(/^a(lt)?$/i.test(n))r=true;else if(/^(c|ctrl|control)$/i.test(n))i=true;else if(/^s(hift)?$/i.test(n))s=true;else if(/^mod$/i.test(n)){if(Jl)o=true;else i=true}else throw new Error("Unrecognized modifier name: "+n)}if(r)n="Alt-"+n;if(i)n="Ctrl-"+n;if(o)n="Meta-"+n;if(s)n="Shift-"+n;return n}function Gl(t){let e=Object.create(null);for(let n in t)e[Vl(n)]=t[n];return e}function Zl(t,e,n=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(n&&e.shiftKey)t="Shift-"+t;return t}function Yl(t){return new Mn({props:{handleKeyDown:Xl(t)}})}function Xl(t){let e=Gl(t);return function(t,n){let r=Kl(n),i,s=e[Zl(r,n)];if(s&&s(t.state,t.dispatch,t))return true;if(r.length==1&&r!=" "){if(n.shiftKey){let i=e[Zl(r,n,false)];if(i&&i(t.state,t.dispatch,t))return true}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Wl&&n.ctrlKey&&n.altKey)&&(i=jl[n.keyCode])&&i!=r){let r=e[Zl(i,n)];if(r&&r(t.state,t.dispatch,t))return true}}return false}}var Ql=Object.defineProperty;var tu=(t,e)=>{for(var n in e)Ql(t,n,{get:e[n],enumerable:true})};function eu(t){const{state:e,transaction:n}=t;let{selection:r}=n;let{doc:i}=n;let{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){r=n.selection;i=n.doc;s=n.storedMarks;return n}}}var nu=class{constructor(t){this.editor=t.editor;this.rawCommands=this.editor.extensionManager.commands;this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this;const{view:r}=e;const{tr:i}=n;const s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map((([t,e])=>{const n=(...t)=>{const n=e(...t)(s);if(!i.getMeta("preventDispatch")&&!this.hasCustomState){r.dispatch(i)}return n};return[t,n]})))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=true){const{rawCommands:n,editor:r,state:i}=this;const{view:s}=r;const o=[];const l=!!t;const u=t||i.tr;const a=()=>{if(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState){s.dispatch(u)}return o.every((t=>t===true))};const f={...Object.fromEntries(Object.entries(n).map((([t,n])=>{const r=(...t)=>{const r=this.buildProps(u,e);const i=n(...t)(r);o.push(i);return f};return[t,r]}))),run:a};return f}createCan(t){const{rawCommands:e,state:n}=this;const r=false;const i=t||n.tr;const s=this.buildProps(i,r);const o=Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...s,dispatch:void 0})])));return{...o,chain:()=>this.createChain(i,r)}}buildProps(t,e=true){const{rawCommands:n,editor:r,state:i}=this;const{view:s}=r;const o={tr:t,editor:r,view:s,state:eu({state:i,transaction:t}),dispatch:e?()=>void 0:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(o)])))}};return o}};var ru={};tu(ru,{blur:()=>iu,clearContent:()=>su,clearNodes:()=>ou,command:()=>lu,createParagraphNear:()=>uu,cut:()=>au,deleteCurrentNode:()=>fu,deleteNode:()=>cu,deleteRange:()=>du,deleteSelection:()=>pu,enter:()=>mu,exitCode:()=>gu,extendMarkRange:()=>Mu,first:()=>Su,focus:()=>Ru,forEach:()=>Cu,insertContent:()=>Lu,insertContentAt:()=>_u,joinBackward:()=>Bu,joinDown:()=>zu,joinForward:()=>Fu,joinItemBackward:()=>Uu,joinItemForward:()=>qu,joinTextblockBackward:()=>Ku,joinTextblockForward:()=>Ju,joinUp:()=>ju,keyboardShortcut:()=>Gu,lift:()=>Yu,liftEmptyBlock:()=>Xu,liftListItem:()=>Qu,newlineInCode:()=>ta,resetAttributes:()=>ra,scrollIntoView:()=>ia,selectAll:()=>sa,selectNodeBackward:()=>oa,selectNodeForward:()=>la,selectParentNode:()=>ua,selectTextblockEnd:()=>aa,selectTextblockStart:()=>fa,setContent:()=>ca,setMark:()=>sf,setMeta:()=>of,setNode:()=>lf,setNodeSelection:()=>uf,setTextSelection:()=>af,sinkListItem:()=>ff,splitBlock:()=>cf,splitListItem:()=>df,toggleList:()=>gf,toggleMark:()=>wf,toggleNode:()=>bf,toggleWrap:()=>vf,undoInputRule:()=>kf,unsetAllMarks:()=>yf,unsetMark:()=>xf,updateAttributes:()=>Mf,wrapIn:()=>Sf,wrapInList:()=>Tf});var iu=()=>({editor:t,view:e})=>{requestAnimationFrame((()=>{var n;if(!t.isDestroyed){e.dom.blur();(n=window==null?void 0:window.getSelection())==null?void 0:n.removeAllRanges()}}));return true};var su=(t=true)=>({commands:e})=>e.setContent("",{emitUpdate:t});var ou=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e;const{ranges:i}=r;if(!n){return true}i.forEach((({$from:n,$to:r})=>{t.doc.nodesBetween(n.pos,r.pos,((t,n)=>{if(t.type.isText){return}const{doc:r,mapping:i}=e;const s=r.resolve(i.map(n));const o=r.resolve(i.map(n+t.nodeSize));const l=s.blockRange(o);if(!l){return}const u=de(l);if(t.type.isTextblock){const{defaultType:t}=s.parent.contentMatchAt(s.index());e.setNodeMarkup(l.start,t)}if(u||u===0){e.lift(l,u)}}))}));return true};var lu=t=>e=>t(e);var uu=()=>({state:t,dispatch:e})=>Jn(t,e);var au=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n;const s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);r.insert(o,s.content);r.setSelection(new sn(r.doc.resolve(Math.max(o-1,0))));return true};var fu=()=>({tr:t,dispatch:e})=>{const{selection:n}=t;const r=n.$anchor.node();if(r.content.size>0){return false}const i=t.selection.$anchor;for(let n=i.depth;n>0;n-=1){const s=i.node(n);if(s.type===r.type){if(e){const e=i.before(n);const r=i.after(n);t.delete(e,r).scrollIntoView()}return true}}return false};function hu(t,e){if(typeof t==="string"){if(!e.nodes[t]){throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`)}return e.nodes[t]}return t}var cu=t=>({tr:e,state:n,dispatch:r})=>{const i=hu(t,n.schema);const s=e.selection.$anchor;for(let t=s.depth;t>0;t-=1){const n=s.node(t);if(n.type===i){if(r){const n=s.before(t);const r=s.after(t);e.delete(n,r).scrollIntoView()}return true}}return false};var du=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;if(n){e.delete(r,i)}return true};var pu=()=>({state:t,dispatch:e})=>An(t,e);var mu=()=>({commands:t})=>t.keyboardShortcut("Enter");var gu=()=>({state:t,dispatch:e})=>Kn(t,e);function wu(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function bu(t,e,n={strict:true}){const r=Object.keys(e);if(!r.length){return true}return r.every((r=>{if(n.strict){return e[r]===t[r]}if(wu(e[r])){return e[r].test(t[r])}return e[r]===t[r]}))}function vu(t,e,n={}){return t.find((t=>t.type===e&&bu(Object.fromEntries(Object.keys(n).map((e=>[e,t.attrs[e]]))),n)))}function ku(t,e,n={}){return!!vu(t,e,n)}function yu(t,e,n){var r;if(!t||!e){return}let i=t.parent.childAfter(t.parentOffset);if(!i.node||!i.node.marks.some((t=>t.type===e))){i=t.parent.childBefore(t.parentOffset)}if(!i.node||!i.node.marks.some((t=>t.type===e))){return}n=n||((r=i.node.marks[0])==null?void 0:r.attrs);const s=vu([...i.node.marks],e,n);if(!s){return}let o=i.index;let l=t.start()+i.offset;let u=o+1;let a=l+i.node.nodeSize;while(o>0&&ku([...t.parent.child(o-1).marks],e,n)){o-=1;l-=t.parent.child(o).nodeSize}while(u<t.parent.childCount&&ku([...t.parent.child(u).marks],e,n)){a+=t.parent.child(u).nodeSize;u+=1}return{from:l,to:a}}function xu(t,e){if(typeof t==="string"){if(!e.marks[t]){throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`)}return e.marks[t]}return t}var Mu=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=xu(t,r.schema);const{doc:o,selection:l}=n;const{$from:u,from:a,to:f}=l;if(i){const t=yu(u,s,e);if(t&&t.from<=a&&t.to>=f){const e=sn.create(o,t.from,t.to);n.setSelection(e)}}return true};var Su=t=>e=>{const n=typeof t==="function"?t(e):t;for(let t=0;t<n.length;t+=1){if(n[t](e)){return true}}return false};function Tu(t){return t instanceof sn}function Eu(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Au(t,e=null){if(!e){return null}const n=tn.atStart(t);const r=tn.atEnd(t);if(e==="start"||e===true){return n}if(e==="end"){return r}const i=n.from;const s=r.to;if(e==="all"){return sn.create(t,Eu(0,i,s),Eu(t.content.size,i,s))}return sn.create(t,Eu(e,i,s),Eu(e,i,s))}function Ou(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function $u(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Ru=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:true,...e};const o=()=>{if($u()||Ou()){r.dom.focus()}requestAnimationFrame((()=>{if(!n.isDestroyed){r.focus();if(e==null?void 0:e.scrollIntoView){n.commands.scrollIntoView()}}}))};if(r.hasFocus()&&t===null||t===false){return true}if(s&&t===null&&!Tu(n.state.selection)){o();return true}const l=Au(i.doc,t)||n.state.selection;const u=n.state.selection.eq(l);if(s){if(!u){i.setSelection(l)}if(u&&i.storedMarks){i.setStoredMarks(i.storedMarks)}o()}return true};var Cu=(t,e)=>n=>t.every(((t,r)=>e(t,{...n,index:r})));var Lu=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e);var Nu=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)){t.removeChild(r)}else if(r.nodeType===1){Nu(r)}}return t};function Iu(t){if(typeof window==="undefined"){throw new Error("[tiptap error]: there is no window object available, so this function cannot be used")}const e=`<body>${t}</body>`;const n=(new window.DOMParser).parseFromString(e,"text/html").body;return Nu(n)}function Pu(t,e,n){if(t instanceof q||t instanceof v){return t}n={slice:true,parseOptions:{},...n};const r=typeof t==="object"&&t!==null;const i=typeof t==="string";if(r){try{const r=Array.isArray(t)&&t.length>0;if(r){return v.fromArray(t.map((t=>e.nodeFromJSON(t))))}const i=e.nodeFromJSON(t);if(n.errorOnInvalidContent){i.check()}return i}catch(r){if(n.errorOnInvalidContent){throw new Error("[tiptap error]: Invalid JSON content",{cause:r})}console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r);return Pu("",e,n)}}if(i){if(n.errorOnInvalidContent){let r=false;let i="";const s=new mt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>{r=true;i=typeof t==="string"?t:t.outerHTML;return null}}]}})});if(n.slice){vt.fromSchema(s).parseSlice(Iu(t),n.parseOptions)}else{vt.fromSchema(s).parse(Iu(t),n.parseOptions)}if(n.errorOnInvalidContent&&r){throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}}const r=vt.fromSchema(e);if(n.slice){return r.parseSlice(Iu(t),n.parseOptions).content}return r.parse(Iu(t),n.parseOptions)}return Pu("",e,n)}function Du(t,e,n){const r=t.steps.length-1;if(r<e){return}const i=t.steps[r];if(!(i instanceof oe||i instanceof le)){return}const s=t.mapping.maps[r];let o=0;s.forEach(((t,e,n,r)=>{if(o===0){o=r}}));t.setSelection(tn.near(t.doc.resolve(o),n))}var Hu=t=>!("type"in t);var _u=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:true,applyInputRules:false,applyPasteRules:false,...n};let i;const l=t=>{s.emit("contentError",{editor:s,error:t,disableCollaboration:()=>{if("collaboration"in s.storage&&typeof s.storage.collaboration==="object"&&s.storage.collaboration){s.storage.collaboration.isDisabled=true}}})};const u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError){try{Pu(e,s.schema,{parseOptions:u,errorOnInvalidContent:true})}catch(t){l(t)}}try{i=Pu(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(t){l(t);return false}let{from:a,to:f}=typeof t==="number"?{from:t,to:t}:{from:t.from,to:t.to};let h=true;let c=true;const d=Hu(i)?i:[i];d.forEach((t=>{t.check();h=h?t.isText&&t.marks.length===0:false;c=c?t.isBlock:false}));if(a===f&&c){const{parent:t}=r.doc.resolve(a);const e=t.isTextblock&&!t.type.spec.code&&!t.childCount;if(e){a-=1;f+=1}}let p;if(h){if(Array.isArray(e)){p=e.map((t=>t.text||"")).join("")}else if(e instanceof v){let t="";e.forEach((e=>{if(e.text){t+=e.text}}));p=t}else if(typeof e==="object"&&!!e&&!!e.text){p=e.text}else{p=e}r.insertText(p,a,f)}else{p=i;const t=r.doc.resolve(a);const e=t.node();const n=t.parentOffset===0;const s=e.isText||e.isTextblock;const o=e.content.size>0;if(n&&s&&o){a=Math.max(0,a-1)}r.replaceWith(a,f,p)}if(n.updateSelection){Du(r,r.steps.length-1,-1)}if(n.applyInputRules){r.setMeta("applyInputRules",{from:a,text:p})}if(n.applyPasteRules){r.setMeta("applyPasteRules",{from:a,text:p})}}return true};var ju=()=>({state:t,dispatch:e})=>zn(t,e);var zu=()=>({state:t,dispatch:e})=>Bn(t,e);var Bu=()=>({state:t,dispatch:e})=>$n(t,e);var Fu=()=>({state:t,dispatch:e})=>Hn(t,e);var Uu=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Re(t.doc,t.selection.$from.pos,-1);if(r===null||r===void 0){return false}n.join(r,2);if(e){e(n)}return true}catch{return false}};var qu=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Re(t.doc,t.selection.$from.pos,1);if(r===null||r===void 0){return false}n.join(r,2);if(e){e(n)}return true}catch{return false}};var Ku=()=>({state:t,dispatch:e})=>Rn(t,e);var Ju=()=>({state:t,dispatch:e})=>Cn(t,e);function Wu(){return typeof navigator!=="undefined"?/Mac/.test(navigator.platform):false}function Vu(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];if(n==="Space"){n=" "}let r;let i;let s;let o;for(let t=0;t<e.length-1;t+=1){const n=e[t];if(/^(cmd|meta|m)$/i.test(n)){o=true}else if(/^a(lt)?$/i.test(n)){r=true}else if(/^(c|ctrl|control)$/i.test(n)){i=true}else if(/^s(hift)?$/i.test(n)){s=true}else if(/^mod$/i.test(n)){if($u()||Wu()){o=true}else{i=true}}else{throw new Error(`Unrecognized modifier name: ${n}`)}}if(r){n=`Alt-${n}`}if(i){n=`Ctrl-${n}`}if(o){n=`Meta-${n}`}if(s){n=`Shift-${n}`}return n}var Gu=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=Vu(t).split(/-(?!$)/);const o=s.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t)));const l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:true,cancelable:true});const u=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,l)))}));u==null?void 0:u.steps.forEach((t=>{const e=t.map(r.mapping);if(e&&i){r.maybeStep(e)}}));return true};function Zu(t,e,n={}){const{from:r,to:i,empty:s}=t.selection;const o=e?hu(e,t.schema):null;const l=[];t.doc.nodesBetween(r,i,((t,e)=>{if(t.isText){return}const n=Math.max(r,e);const s=Math.min(i,e+t.nodeSize);l.push({node:t,from:n,to:s})}));const u=i-r;const a=l.filter((t=>{if(!o){return true}return o.name===t.node.type.name})).filter((t=>bu(t.node.attrs,n,{strict:false})));if(s){return!!a.length}const f=a.reduce(((t,e)=>t+e.to-e.from),0);return f>=u}var Yu=(t,e={})=>({state:n,dispatch:r})=>{const i=hu(t,n.schema);const s=Zu(n,i,e);if(!s){return false}return Fn(n,r)};var Xu=()=>({state:t,dispatch:e})=>Wn(t,e);var Qu=t=>({state:e,dispatch:n})=>{const r=hu(t,e.schema);return dr(r)(e,n)};var ta=()=>({state:t,dispatch:e})=>Un(t,e);function ea(t,e){if(e.nodes[t]){return"node"}if(e.marks[t]){return"mark"}return null}function na(t,e){const n=typeof e==="string"?[e]:e;return Object.keys(t).reduce(((e,r)=>{if(!n.includes(r)){e[r]=t[r]}return e}),{})}var ra=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null;let o=null;const l=ea(typeof t==="string"?t:t.name,r.schema);if(!l){return false}if(l==="node"){s=hu(t,r.schema)}if(l==="mark"){o=xu(t,r.schema)}if(i){n.selection.ranges.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{if(s&&s===t.type){n.setNodeMarkup(r,void 0,na(t.attrs,e))}if(o&&t.marks.length){t.marks.forEach((i=>{if(o===i.type){n.addMark(r,r+t.nodeSize,o.create(na(i.attrs,e)))}}))}}))}))}return true};var ia=()=>({tr:t,dispatch:e})=>{if(e){t.scrollIntoView()}return true};var sa=()=>({tr:t,dispatch:e})=>{if(e){const e=new an(t.doc);t.setSelection(e)}return true};var oa=()=>({state:t,dispatch:e})=>In(t,e);var la=()=>({state:t,dispatch:e})=>_n(t,e);var ua=()=>({state:t,dispatch:e})=>Zn(t,e);var aa=()=>({state:t,dispatch:e})=>nr(t,e);var fa=()=>({state:t,dispatch:e})=>er(t,e);function ha(t,e,n={},r={}){return Pu(t,e,{slice:false,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var ca=(t,{errorOnInvalidContent:e,emitUpdate:n=true,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:u}=s;if(r.preserveWhitespace!=="full"){const l=ha(t,i.schema,r,{errorOnInvalidContent:e!=null?e:i.options.enableContentCheck});if(o){s.replaceWith(0,u.content.size,l).setMeta("preventUpdate",!n)}return true}if(o){s.setMeta("preventUpdate",!n)}return l.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e!=null?e:i.options.enableContentCheck})};function da(t,e){const n=xu(e,t.schema);const{from:r,to:i,empty:s}=t.selection;const o=[];if(s){if(t.storedMarks){o.push(...t.storedMarks)}o.push(...t.selection.$head.marks())}else{t.doc.nodesBetween(r,i,(t=>{o.push(...t.marks)}))}const l=o.find((t=>t.type.name===n.name));if(!l){return{}}return{...l.attrs}}function pa(t,e){const n=new Xe(t);e.forEach((t=>{t.steps.forEach((t=>{n.step(t)}))}));return n}function ma(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs()){return n}}return null}function ga(t,e,n){const r=[];t.nodesBetween(e.from,e.to,((t,e)=>{if(n(t)){r.push({node:t,pos:e})}}));return r}function wa(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r)){return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}}function ba(t){return e=>wa(e.$from,t)}function va(t,e,n){if(t.config[e]===void 0&&t.parent){return va(t.parent,e,n)}if(typeof t.config[e]==="function"){const r=t.config[e].bind({...n,parent:t.parent?va(t.parent,e,n):null});return r}return t.config[e]}function ka(t){return t.map((t=>{const e={name:t.name,options:t.options,storage:t.storage};const n=va(t,"addExtensions",e);if(n){return[t,...ka(n())]}return t})).flat(10)}function ya(t,e){const n=Nt.fromSchema(e).serializeFragment(t);const r=document.implementation.createHTMLDocument();const i=r.createElement("div");i.appendChild(n);return i.innerHTML}function xa(t){return typeof t==="function"}function Ma(t,e=void 0,...n){if(xa(t)){if(e){return t.bind(e)(...n)}return t(...n)}return t}function Sa(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ta(t){const e=t.filter((t=>t.type==="extension"));const n=t.filter((t=>t.type==="node"));const r=t.filter((t=>t.type==="mark"));return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Ea(t){const e=[];const{nodeExtensions:n,markExtensions:r}=Ta(t);const i=[...n,...r];const s={default:null,validate:void 0,rendered:true,renderHTML:null,parseHTML:null,keepOnSplit:true,isRequired:false};t.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage,extensions:i};const r=va(t,"addGlobalAttributes",n);if(!r){return}const o=r();o.forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,r])=>{e.push({type:n,name:t,attribute:{...s,...r}})}))}))}))}));i.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage};const r=va(t,"addAttributes",n);if(!r){return}const i=r();Object.entries(i).forEach((([n,r])=>{const i={...s,...r};if(typeof(i==null?void 0:i.default)==="function"){i.default=i.default()}if((i==null?void 0:i.isRequired)&&(i==null?void 0:i.default)===void 0){delete i.default}e.push({type:t.name,name:n,attribute:i})}))}));return e}function Aa(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};Object.entries(e).forEach((([t,e])=>{const r=n[t];if(!r){n[t]=e;return}if(t==="class"){const r=e?String(e).split(" "):[];const i=n[t]?n[t].split(" "):[];const s=r.filter((t=>!i.includes(t)));n[t]=[...i,...s].join(" ")}else if(t==="style"){const r=e?e.split(";").map((t=>t.trim())).filter(Boolean):[];const i=n[t]?n[t].split(";").map((t=>t.trim())).filter(Boolean):[];const s=new Map;i.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));s.set(e,n)}));r.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));s.set(e,n)}));n[t]=Array.from(s.entries()).map((([t,e])=>`${t}: ${e}`)).join("; ")}else{n[t]=e}}));return n}),{})}function Oa(t,e){return e.filter((e=>e.type===t.type.name)).filter((t=>t.attribute.rendered)).map((e=>{if(!e.attribute.renderHTML){return{[e.name]:t.attrs[e.name]}}return e.attribute.renderHTML(t.attrs)||{}})).reduce(((t,e)=>Aa(t,e)),{})}function $a(t){if(typeof t!=="string"){return t}if(t.match(/^[+-]?(?:\d*\.)?\d+$/)){return Number(t)}if(t==="true"){return true}if(t==="false"){return false}return t}function Ra(t,e){if("style"in t){return t}return{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===false){return false}const i=e.reduce(((t,e)=>{const r=e.attribute.parseHTML?e.attribute.parseHTML(n):$a(n.getAttribute(e.name));if(r===null||r===void 0){return t}return{...t,[e.name]:r}}),{});return{...r,...i}}}}function Ca(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>{if(t==="attrs"&&Sa(e)){return false}return e!==null&&e!==void 0})))}function La(t,e){var n;const r=Ea(t);const{nodeExtensions:i,markExtensions:s}=Ta(t);const o=(n=i.find((t=>va(t,"topNode"))))==null?void 0:n.name;const l=Object.fromEntries(i.map((n=>{const i=r.filter((t=>t.type===n.name));const s={name:n.name,options:n.options,storage:n.storage,editor:e};const o=t.reduce(((t,e)=>{const r=va(e,"extendNodeSchema",s);return{...t,...r?r(n):{}}}),{});const l=Ca({...o,content:Ma(va(n,"content",s)),marks:Ma(va(n,"marks",s)),group:Ma(va(n,"group",s)),inline:Ma(va(n,"inline",s)),atom:Ma(va(n,"atom",s)),selectable:Ma(va(n,"selectable",s)),draggable:Ma(va(n,"draggable",s)),code:Ma(va(n,"code",s)),whitespace:Ma(va(n,"whitespace",s)),linebreakReplacement:Ma(va(n,"linebreakReplacement",s)),defining:Ma(va(n,"defining",s)),isolating:Ma(va(n,"isolating",s)),attrs:Object.fromEntries(i.map((t=>{var e,n;return[t.name,{default:(e=t==null?void 0:t.attribute)==null?void 0:e.default,validate:(n=t==null?void 0:t.attribute)==null?void 0:n.validate}]})))});const u=Ma(va(n,"parseHTML",s));if(u){l.parseDOM=u.map((t=>Ra(t,i)))}const a=va(n,"renderHTML",s);if(a){l.toDOM=t=>a({node:t,HTMLAttributes:Oa(t,i)})}const f=va(n,"renderText",s);if(f){l.toText=f}return[n.name,l]})));const u=Object.fromEntries(s.map((n=>{const i=r.filter((t=>t.type===n.name));const s={name:n.name,options:n.options,storage:n.storage,editor:e};const o=t.reduce(((t,e)=>{const r=va(e,"extendMarkSchema",s);return{...t,...r?r(n):{}}}),{});const l=Ca({...o,inclusive:Ma(va(n,"inclusive",s)),excludes:Ma(va(n,"excludes",s)),group:Ma(va(n,"group",s)),spanning:Ma(va(n,"spanning",s)),code:Ma(va(n,"code",s)),attrs:Object.fromEntries(i.map((t=>{var e,n;return[t.name,{default:(e=t==null?void 0:t.attribute)==null?void 0:e.default,validate:(n=t==null?void 0:t.attribute)==null?void 0:n.validate}]})))});const u=Ma(va(n,"parseHTML",s));if(u){l.parseDOM=u.map((t=>Ra(t,i)))}const a=va(n,"renderHTML",s);if(a){l.toDOM=t=>a({mark:t,HTMLAttributes:Oa(t,i)})}return[n.name,l]})));return new mt({topNode:o,nodes:l,marks:u})}function Na(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return Array.from(new Set(e))}function Ia(t){const e=100;return t.sort(((t,n)=>{const r=va(t,"priority")||e;const i=va(n,"priority")||e;if(r>i){return-1}if(r<i){return 1}return 0}))}function Pa(t){const e=Ia(ka(t));const n=Na(e.map((t=>t.name)));if(n.length){console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`)}return e}function Da(t,e,n){const{from:r,to:i}=e;const{blockSeparator:s="\n\n",textSerializers:o={}}=n||{};let l="";t.nodesBetween(r,i,((t,n,u,a)=>{var f;if(t.isBlock&&n>r){l+=s}const h=o==null?void 0:o[t.type.name];if(h){if(u){l+=h({node:t,pos:n,parent:u,index:a,range:e})}return false}if(t.isText){l+=(f=t==null?void 0:t.text)==null?void 0:f.slice(Math.max(r,n)-n,i-n)}}));return l}function Ha(t,e){const n={from:0,to:t.content.size};return Da(t,n,e)}function _a(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}function ja(t,e){const n=hu(e,t.schema);const{from:r,to:i}=t.selection;const s=[];t.doc.nodesBetween(r,i,(t=>{s.push(t)}));const o=s.reverse().find((t=>t.type.name===n.name));if(!o){return{}}return{...o.attrs}}function za(t,e){const n=ea(typeof e==="string"?e:e.name,t.schema);if(n==="node"){return ja(t,e)}if(n==="mark"){return da(t,e)}return{}}function Ba(t,e=JSON.stringify){const n={};return t.filter((t=>{const r=e(t);return Object.prototype.hasOwnProperty.call(n,r)?false:n[r]=true}))}function Fa(t){const e=Ba(t);return e.length===1?e:e.filter(((t,n)=>{const r=e.filter(((t,e)=>e!==n));return!r.some((e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))}))}function Ua(t){const{mapping:e,steps:n}=t;const r=[];e.maps.forEach(((t,i)=>{const s=[];if(!t.ranges.length){const{from:t,to:e}=n[i];if(t===void 0||e===void 0){return}s.push({from:t,to:e})}else{t.forEach(((t,e)=>{s.push({from:t,to:e})}))}s.forEach((({from:t,to:n})=>{const s=e.slice(i).map(t,-1);const o=e.slice(i).map(n);const l=e.invert().map(s,-1);const u=e.invert().map(o);r.push({oldRange:{from:l,to:u},newRange:{from:s,to:o}})}))}));return Fa(r)}function qa(t,e,n){const r=[];if(t===e){n.resolve(t).marks().forEach((e=>{const i=n.resolve(t);const s=yu(i,e.type);if(!s){return}r.push({mark:e,...s})}))}else{n.nodesBetween(t,e,((t,e)=>{if(!t||(t==null?void 0:t.nodeSize)===void 0){return}r.push(...t.marks.map((n=>({from:e,to:e+t.nodeSize,mark:n}))))}))}return r}var Ka=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r;let o=null;while(s>0&&o===null){const t=i.node(s);if((t==null?void 0:t.type.name)===e){o=t}else{s-=1}}return[o,s]};function Ja(t,e){return e.nodes[t]||e.marks[t]||null}function Wa(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=t.find((t=>t.type===e&&t.name===n));if(!r){return false}return r.attribute.keepOnSplit})))}var Va=(t,e=500)=>{let n="";const r=t.parentOffset;t.parent.nodesBetween(Math.max(0,r-e),r,((t,e,i,s)=>{var o,l;const u=((l=(o=t.type.spec).toText)==null?void 0:l.call(o,{node:t,pos:e,parent:i,index:s}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?u:u.slice(0,Math.max(0,r-e))}));return n};function Ga(t,e,n={}){const{empty:r,ranges:i}=t.selection;const s=e?xu(e,t.schema):null;if(r){return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>{if(!s){return true}return s.name===t.type.name})).find((t=>bu(t.attrs,n,{strict:false})))}let o=0;const l=[];i.forEach((({$from:e,$to:n})=>{const r=e.pos;const i=n.pos;t.doc.nodesBetween(r,i,((t,e)=>{if(!t.isText&&!t.marks.length){return}const n=Math.max(r,e);const s=Math.min(i,e+t.nodeSize);const u=s-n;o+=u;l.push(...t.marks.map((t=>({mark:t,from:n,to:s}))))}))}));if(o===0){return false}const u=l.filter((t=>{if(!s){return true}return s.name===t.mark.type.name})).filter((t=>bu(t.mark.attrs,n,{strict:false}))).reduce(((t,e)=>t+e.to-e.from),0);const a=l.filter((t=>{if(!s){return true}return t.mark.type!==s&&t.mark.type.excludes(s)})).reduce(((t,e)=>t+e.to-e.from),0);const f=u>0?u+a:u;return f>=o}function Za(t,e,n={}){if(!e){return Zu(t,null,n)||Ga(t,null,n)}const r=ea(e,t.schema);if(r==="node"){return Zu(t,e,n)}if(r==="mark"){return Ga(t,e,n)}return false}var Ya=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const n=ba((t=>t.type.name===e))(t.selection);if(!n){return false}const r=t.doc.resolve(n.pos+1);if(i.pos+1===r.end()){return true}return false}if(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos){return false}return true};var Xa=t=>{const{$from:e,$to:n}=t.selection;if(e.parentOffset>0||e.pos!==n.pos){return false}return true};function Qa(t,e){if(Array.isArray(e)){return e.some((e=>{const n=typeof e==="string"?e:e.name;return n===t.name}))}return e}function tf(t,e){const{nodeExtensions:n}=Ta(e);const r=n.find((e=>e.name===t));if(!r){return false}const i={name:r.name,options:r.options,storage:r.storage};const s=Ma(va(r,"group",i));if(typeof s!=="string"){return false}return s.split(" ").includes("list")}function ef(t,{checkChildren:e=true,ignoreWhitespace:n=false}={}){var r;if(n){if(t.type.name==="hardBreak"){return true}if(t.isText){return/^\s*$/m.test((r=t.text)!=null?r:"")}}if(t.isText){return!t.text}if(t.isAtom||t.isLeaf){return false}if(t.content.childCount===0){return true}if(e){let r=true;t.content.forEach((t=>{if(r===false){return}if(!ef(t,{ignoreWhitespace:n,checkChildren:e})){r=false}}));return r}return false}function nf(t){return t instanceof ln}function rf(t,e,n){var r;const{selection:i}=e;let s=null;if(Tu(i)){s=i.$cursor}if(s){const e=(r=t.storedMarks)!=null?r:s.marks();const i=s.parent.type.allowsMarkType(n);return i&&(!!n.isInSet(e)||!e.some((t=>t.type.excludes(n))))}const{ranges:o}=i;return o.some((({$from:e,$to:r})=>{let i=e.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):false;t.doc.nodesBetween(e.pos,r.pos,((t,e,r)=>{if(i){return false}if(t.isInline){const e=!r||r.type.allowsMarkType(n);const s=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));i=e&&s}return!i}));return i}))}var sf=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n;const{empty:o,ranges:l}=s;const u=xu(t,r.schema);if(i){if(o){const t=da(r,u);n.addStoredMark(u.create({...t,...e}))}else{l.forEach((t=>{const i=t.$from.pos;const s=t.$to.pos;r.doc.nodesBetween(i,s,((t,r)=>{const o=Math.max(r,i);const l=Math.min(r+t.nodeSize,s);const a=t.marks.find((t=>t.type===u));if(a){t.marks.forEach((t=>{if(u===t.type){n.addMark(o,l,u.create({...t.attrs,...e}))}}))}else{n.addMark(o,l,u.create(e))}}))}))}}return rf(r,n,u)};var of=(t,e)=>({tr:n})=>{n.setMeta(t,e);return true};var lf=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=hu(t,n.schema);let o;if(n.selection.$anchor.sameParent(n.selection.$head)){o=n.selection.$anchor.parent.attrs}if(!s.isTextblock){console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.');return false}return i().command((({commands:t})=>{const r=ir(s,{...o,...e})(n);if(r){return true}return t.clearNodes()})).command((({state:t})=>ir(s,{...o,...e})(t,r))).run()};var uf=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e;const r=Eu(t,0,n.content.size);const i=ln.create(n,r);e.setSelection(i)}return true};var af=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e;const{from:r,to:i}=typeof t==="number"?{from:t,to:t}:t;const s=sn.atStart(n).from;const o=sn.atEnd(n).to;const l=Eu(r,s,o);const u=Eu(i,s,o);const a=sn.create(n,l,u);e.setSelection(a)}return true};var ff=t=>({state:e,dispatch:n})=>{const r=hu(t,e.schema);return gr(r)(e,n)};function hf(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter((t=>e==null?void 0:e.includes(t.type.name)));t.tr.ensureMarks(r)}}var cf=({keepMarks:t=true}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e;const{$from:l,$to:u}=s;const a=i.extensionManager.attributes;const f=Wa(a,l.node().type.name,l.node().attrs);if(s instanceof ln&&s.node.isBlock){if(!l.parentOffset||!Te(o,l.pos)){return false}if(r){if(t){hf(n,i.extensionManager.splittableMarks)}e.split(l.pos).scrollIntoView()}return true}if(!l.parent.isBlock){return false}const h=u.parentOffset===u.parent.content.size;const c=l.depth===0?void 0:ma(l.node(-1).contentMatchAt(l.indexAfter(-1)));let d=h&&c?[{type:c,attrs:f}]:void 0;let p=Te(e.doc,e.mapping.map(l.pos),1,d);if(!d&&!p&&Te(e.doc,e.mapping.map(l.pos),1,c?[{type:c}]:void 0)){p=true;d=c?[{type:c,attrs:f}]:void 0}if(r){if(p){if(s instanceof sn){e.deleteSelection()}e.split(e.mapping.map(l.pos),1,d);if(c&&!h&&!l.parentOffset&&l.parent.type!==c){const t=e.mapping.map(l.before());const n=e.doc.resolve(t);if(l.node(-1).canReplaceWith(n.index(),n.index()+1,c)){e.setNodeMarkup(e.mapping.map(l.before()),c)}}}if(t){hf(n,i.extensionManager.splittableMarks)}e.scrollIntoView()}return p};var df=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=hu(t,r.schema);const{$from:u,$to:a}=r.selection;const f=r.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(a)){return false}const h=u.node(-1);if(h.type!==l){return false}const c=s.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==l||u.index(-2)!==u.node(-2).childCount-1){return false}if(i){let t=v.empty;const r=u.index(-1)?1:u.index(-2)?2:3;for(let e=u.depth-r;e>=u.depth-3;e-=1){t=v.from(u.node(e).copy(t))}const i=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3;const s={...Wa(c,u.node().type.name,u.node().attrs),...e};const a=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(s))||void 0;t=t.append(v.from(l.createAndFill(null,a)||void 0));const f=u.before(u.depth-(r-1));n.replace(f,u.after(-i),new T(t,4-r,0));let h=-1;n.doc.nodesBetween(f,n.doc.content.size,((t,e)=>{if(h>-1){return false}if(t.isTextblock&&t.content.size===0){h=e+1}}));if(h>-1){n.setSelection(sn.near(n.doc.resolve(h)))}n.scrollIntoView()}return true}const d=a.pos===u.end()?h.contentMatchAt(0).defaultType:null;const p={...Wa(c,h.type.name,h.attrs),...e};const m={...Wa(c,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,a.pos);const g=d?[{type:l,attrs:p},{type:d,attrs:m}]:[{type:l,attrs:p}];if(!Te(n.doc,u.pos,2)){return false}if(i){const{selection:t,storedMarks:e}=r;const{splittableMarks:o}=s.extensionManager;const l=e||t.$to.parentOffset&&t.$from.marks();n.split(u.pos,2,g).scrollIntoView();if(!l||!i){return true}const a=l.filter((t=>o.includes(t.type.name)));n.ensureMarks(a)}return true};var pf=(t,e)=>{const n=ba((t=>t.type===e))(t.selection);if(!n){return true}const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0){return true}const i=t.doc.nodeAt(r);const s=n.node.type===(i==null?void 0:i.type)&&Ae(t.doc,n.pos);if(!s){return true}t.join(n.pos);return true};var mf=(t,e)=>{const n=ba((t=>t.type===e))(t.selection);if(!n){return true}const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0){return true}const i=t.doc.nodeAt(r);const s=n.node.type===(i==null?void 0:i.type)&&Ae(t.doc,r);if(!s){return true}t.join(r);return true};var gf=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:u,commands:a,can:f})=>{const{extensions:h,splittableMarks:c}=i.extensionManager;const d=hu(t,o.schema);const p=hu(e,o.schema);const{selection:m,storedMarks:g}=o;const{$from:w,$to:b}=m;const v=w.blockRange(b);const k=g||m.$to.parentOffset&&m.$from.marks();if(!v){return false}const y=ba((t=>tf(t.type.name,h)))(m);if(v.depth>=1&&y&&v.depth-y.depth<=1){if(y.node.type===d){return a.liftListItem(p)}if(tf(y.node.type.name,h)&&d.validContent(y.node.content)&&l){return u().command((()=>{s.setNodeMarkup(y.pos,d);return true})).command((()=>pf(s,d))).command((()=>mf(s,d))).run()}}if(!n||!k||!l){return u().command((()=>{const t=f().wrapInList(d,r);if(t){return true}return a.clearNodes()})).wrapInList(d,r).command((()=>pf(s,d))).command((()=>mf(s,d))).run()}return u().command((()=>{const t=f().wrapInList(d,r);const e=k.filter((t=>c.includes(t.type.name)));s.ensureMarks(e);if(t){return true}return a.clearNodes()})).wrapInList(d,r).command((()=>pf(s,d))).command((()=>mf(s,d))).run()};var wf=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=false}=n;const o=xu(t,r.schema);const l=Ga(r,o,e);if(l){return i.unsetMark(o,{extendEmptyMarkRange:s})}return i.setMark(o,e)};var bf=(t,e,n={})=>({state:r,commands:i})=>{const s=hu(t,r.schema);const o=hu(e,r.schema);const l=Zu(r,s,n);let u;if(r.selection.$anchor.sameParent(r.selection.$head)){u=r.selection.$anchor.parent.attrs}if(l){return i.setNode(o,u)}return i.setNode(s,{...u,...n})};var vf=(t,e={})=>({state:n,commands:r})=>{const i=hu(t,n.schema);const s=Zu(n,i,e);if(s){return r.lift(i)}return r.wrapIn(i,e)};var kf=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const e=t.tr;const n=s.transform;for(let t=n.steps.length-1;t>=0;t-=1){e.step(n.steps[t].invert(n.docs[t]))}if(s.text){const n=e.doc.resolve(s.from).marks();e.replaceWith(s.from,s.to,t.schema.text(s.text,n))}else{e.delete(s.from,s.to)}}return true}}return false};var yf=()=>({tr:t,dispatch:e})=>{const{selection:n}=t;const{empty:r,ranges:i}=n;if(r){return true}if(e){i.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)}))}return true};var xf=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=false}=e;const{selection:l}=n;const u=xu(t,r.schema);const{$from:a,empty:f,ranges:h}=l;if(!i){return true}if(f&&o){let{from:t,to:e}=l;const r=(s=a.marks().find((t=>t.type===u)))==null?void 0:s.attrs;const i=yu(a,u,r);if(i){t=i.from;e=i.to}n.removeMark(t,e,u)}else{h.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,u)}))}n.removeStoredMark(u);return true};var Mf=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null;let o=null;const l=ea(typeof t==="string"?t:t.name,r.schema);if(!l){return false}if(l==="node"){s=hu(t,r.schema)}if(l==="mark"){o=xu(t,r.schema)}if(i){n.selection.ranges.forEach((t=>{const i=t.$from.pos;const l=t.$to.pos;let u;let a;let f;let h;if(n.selection.empty){r.doc.nodesBetween(i,l,((t,e)=>{if(s&&s===t.type){f=Math.max(e,i);h=Math.min(e+t.nodeSize,l);u=e;a=t}}))}else{r.doc.nodesBetween(i,l,((t,r)=>{if(r<i&&s&&s===t.type){f=Math.max(r,i);h=Math.min(r+t.nodeSize,l);u=r;a=t}if(r>=i&&r<=l){if(s&&s===t.type){n.setNodeMarkup(r,void 0,{...t.attrs,...e})}if(o&&t.marks.length){t.marks.forEach((s=>{if(o===s.type){const u=Math.max(r,i);const a=Math.min(r+t.nodeSize,l);n.addMark(u,a,o.create({...s.attrs,...e}))}}))}}}))}if(a){if(u!==void 0){n.setNodeMarkup(u,void 0,{...a.attrs,...e})}if(o&&a.marks.length){a.marks.forEach((t=>{if(o===t.type){n.addMark(f,h,o.create({...t.attrs,...e}))}}))}}}))}return true};var Sf=(t,e={})=>({state:n,dispatch:r})=>{const i=hu(t,n.schema);return rr(i,e)(n,r)};var Tf=(t,e={})=>({state:n,dispatch:r})=>{const i=hu(t,n.schema);return fr(i,e)(n,r)};var Ef=class{constructor(){this.callbacks={}}on(t,e){if(!this.callbacks[t]){this.callbacks[t]=[]}this.callbacks[t].push(e);return this}emit(t,...e){const n=this.callbacks[t];if(n){n.forEach((t=>t.apply(this,e)))}return this}off(t,e){const n=this.callbacks[t];if(n){if(e){this.callbacks[t]=n.filter((t=>t!==e))}else{delete this.callbacks[t]}}return this}once(t,e){const n=(...r)=>{this.off(t,n);e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};var Af=class{constructor(t){var e;this.find=t.find;this.handler=t.handler;this.undoable=(e=t.undoable)!=null?e:true}};var Of=(t,e)=>{if(wu(e)){return e.exec(t)}const n=e(t);if(!n){return null}const r=[n.text];r.index=n.index;r.input=t;r.data=n.data;if(n.replaceWith){if(!n.text.includes(n.replaceWith)){console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".')}r.push(n.replaceWith)}return r};function $f(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:l}=t;const{view:u}=n;if(u.composing){return false}const a=u.state.doc.resolve(r);if(a.parent.type.spec.code||!!((e=a.nodeBefore||a.nodeAfter)==null?void 0:e.marks.find((t=>t.type.spec.code)))){return false}let f=false;const h=Va(a)+s;o.forEach((t=>{if(f){return}const e=Of(h,t.find);if(!e){return}const o=u.state.tr;const a=eu({state:u.state,transaction:o});const c={from:r-(e[0].length-s.length),to:i};const{commands:d,chain:p,can:m}=new nu({editor:n,state:a});const g=t.handler({state:a,range:c,match:e,commands:d,chain:p,can:m});if(g===null||!o.steps.length){return}if(t.undoable){o.setMeta(l,{transform:o,from:r,to:i,text:s})}u.dispatch(o);f=true}));return f}function Rf(t){const{editor:e,rules:n}=t;const r=new Mn({state:{init(){return null},apply(t,i,s){const o=t.getMeta(r);if(o){return o}const l=t.getMeta("applyInputRules");const u=!!l;if(u){setTimeout((()=>{let{text:t}=l;if(typeof t==="string"){t=t}else{t=ya(v.from(t),s.schema)}const{from:i}=l;const o=i+t.length;$f({editor:e,from:i,to:o,text:t,rules:n,plugin:r})}))}return t.selectionSet||t.docChanged?null:i}},props:{handleTextInput(t,i,s,o){return $f({editor:e,from:i,to:s,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:t=>{setTimeout((()=>{const{$cursor:i}=t.state.selection;if(i){$f({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}}));return false}},handleKeyDown(t,i){if(i.key!=="Enter"){return false}const{$cursor:s}=t.state.selection;if(s){return $f({editor:e,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}return false}},isInputRules:true});return r}function Cf(t){return Object.prototype.toString.call(t).slice(8,-1)}function Lf(t){if(Cf(t)!=="Object"){return false}return t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Nf(t,e){const n={...t};if(Lf(t)&&Lf(e)){Object.keys(e).forEach((r=>{if(Lf(e[r])&&Lf(t[r])){n[r]=Nf(t[r],e[r])}else{n[r]=e[r]}}))}return n}var If=class{constructor(t={}){this.type="extendable";this.parent=null;this.child=null;this.name="";this.config={name:this.name};this.config={...this.config,...t};this.name=this.config.name}get options(){return{...Ma(va(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ma(va(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Nf(this.options,t)});e.name=this.name;e.parent=this.parent;return e}extend(t={}){const e=new this.constructor({...this.config,...t});e.parent=this;this.child=e;e.name="name"in t?t.name:e.parent.name;return e}};var Pf=class t extends If{constructor(){super(...arguments);this.type="mark"}static create(e={}){const n=typeof e==="function"?e():e;return new t(n)}static handleExit({editor:t,mark:e}){const{tr:n}=t.state;const r=t.state.selection.$from;const i=r.pos===r.end();if(i){const i=r.marks();const s=!!i.find((t=>(t==null?void 0:t.type.name)===e.name));if(!s){return false}const o=i.find((t=>(t==null?void 0:t.type.name)===e.name));if(o){n.removeStoredMark(o)}n.insertText(" ",r.pos);t.view.dispatch(n);return true}return false}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};function Df(t){return typeof t==="number"}var Hf=class{constructor(t){this.find=t.find;this.handler=t.handler}};var _f=(t,e,n)=>{if(wu(e)){return[...t.matchAll(e)]}const r=e(t,n);if(!r){return[]}return r.map((e=>{const n=[e.text];n.index=e.index;n.input=t;n.data=e.data;if(e.replaceWith){if(!e.text.includes(e.replaceWith)){console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".')}n.push(e.replaceWith)}return n}))};function jf(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t;const{commands:u,chain:a,can:f}=new nu({editor:e,state:n});const h=[];n.doc.nodesBetween(r,i,((t,e)=>{var c,d,p,m,g;if(((d=(c=t.type)==null?void 0:c.spec)==null?void 0:d.code)||!(t.isText||t.isTextblock||t.isInline)){return}const w=(g=(m=(p=t.content)==null?void 0:p.size)!=null?m:t.nodeSize)!=null?g:0;const b=Math.max(r,e);const v=Math.min(i,e+w);if(b>=v){return}const k=t.isText?t.text||"":t.textBetween(b-e,v-e,void 0,"");const y=_f(k,s.find,o);y.forEach((t=>{if(t.index===void 0){return}const e=b+t.index+1;const r=e+t[0].length;const i={from:n.tr.mapping.map(e),to:n.tr.mapping.map(r)};const c=s.handler({state:n,range:i,match:t,commands:u,chain:a,can:f,pasteEvent:o,dropEvent:l});h.push(c)}))}));const c=h.every((t=>t!==null));return c}var zf=null;var Bf=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});(e=n.clipboardData)==null?void 0:e.setData("text/html",t);return n};function Ff(t){const{editor:e,rules:n}=t;let r=null;let i=false;let s=false;let o=typeof ClipboardEvent!=="undefined"?new ClipboardEvent("paste"):null;let l;try{l=typeof DragEvent!=="undefined"?new DragEvent("drop"):null}catch{l=null}const u=({state:t,from:n,to:r,rule:i,pasteEvt:s})=>{const u=t.tr;const a=eu({state:t,transaction:u});const f=jf({editor:e,state:a,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:s,dropEvent:l});if(!f||!u.steps.length){return}try{l=typeof DragEvent!=="undefined"?new DragEvent("drop"):null}catch{l=null}o=typeof ClipboardEvent!=="undefined"?new ClipboardEvent("paste"):null;return u};const a=n.map((t=>new Mn({view(t){const n=n=>{var i;r=((i=t.dom.parentElement)==null?void 0:i.contains(n.target))?t.dom.parentElement:null;if(r){zf=e}};const i=()=>{if(zf){zf=null}};window.addEventListener("dragstart",n);window.addEventListener("dragend",i);return{destroy(){window.removeEventListener("dragstart",n);window.removeEventListener("dragend",i)}}},props:{handleDOMEvents:{drop:(t,e)=>{s=r===t.dom.parentElement;l=e;if(!s){const t=zf;if(t==null?void 0:t.isEditable){setTimeout((()=>{const e=t.state.selection;if(e){t.commands.deleteRange({from:e.from,to:e.to})}}),10)}}return false},paste:(t,e)=>{var n;const r=(n=e.clipboardData)==null?void 0:n.getData("text/html");o=e;i=!!(r==null?void 0:r.includes("data-pm-slice"));return false}}},appendTransaction:(e,n,r)=>{const l=e[0];const a=l.getMeta("uiEvent")==="paste"&&!i;const f=l.getMeta("uiEvent")==="drop"&&!s;const h=l.getMeta("applyPasteRules");const c=!!h;if(!a&&!f&&!c){return}if(c){let{text:e}=h;if(typeof e==="string"){e=e}else{e=ya(v.from(e),r.schema)}const{from:n}=h;const i=n+e.length;const s=Bf(e);return u({rule:t,state:r,from:n,to:{b:i},pasteEvt:s})}const d=n.doc.content.findDiffStart(r.doc.content);const p=n.doc.content.findDiffEnd(r.doc.content);if(!Df(d)||!p||d===p.b){return}return u({rule:t,state:r,from:d,to:p,pasteEvt:o})}})));return a}var Uf=class{constructor(t,e){this.splittableMarks=[];this.editor=e;this.baseExtensions=t;this.extensions=Pa(t);this.schema=La(this.extensions,e);this.setupExtensions()}get commands(){return this.extensions.reduce(((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ja(e.name,this.schema)};const r=va(e,"addCommands",n);if(!r){return t}return{...t,...r()}}),{})}get plugins(){const{editor:t}=this;const e=Ia([...this.extensions].reverse());const n=e.flatMap((e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Ja(e.name,this.schema)};const r=[];const i=va(e,"addKeyboardShortcuts",n);let s={};if(e.type==="mark"&&va(e,"exitable",n)){s.ArrowRight=()=>Pf.handleExit({editor:t,mark:e})}if(i){const e=Object.fromEntries(Object.entries(i()).map((([e,n])=>[e,()=>n({editor:t})])));s={...s,...e}}const o=Yl(s);r.push(o);const l=va(e,"addInputRules",n);if(Qa(e,t.options.enableInputRules)&&l){const e=l();if(e&&e.length){const n=Rf({editor:t,rules:e});const i=Array.isArray(n)?n:[n];r.push(...i)}}const u=va(e,"addPasteRules",n);if(Qa(e,t.options.enablePasteRules)&&u){const e=u();if(e&&e.length){const n=Ff({editor:t,rules:e});r.push(...n)}}const a=va(e,"addProseMirrorPlugins",n);if(a){const t=a();r.push(...t)}return r}));return n}get attributes(){return Ea(this.extensions)}get nodeViews(){const{editor:t}=this;const{nodeExtensions:e}=Ta(this.extensions);return Object.fromEntries(e.filter((t=>!!va(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name));const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:hu(e.name,this.schema)};const i=va(e,"addNodeView",r);if(!i){return[]}const s=(r,s,o,l,u)=>{const a=Oa(r,n);return i()({node:r,view:s,getPos:o,decorations:l,innerDecorations:u,editor:t,extension:e,HTMLAttributes:a})};return[e.name,s]})))}get markViews(){const{editor:t}=this;const{markExtensions:e}=Ta(this.extensions);return Object.fromEntries(e.filter((t=>!!va(t,"addMarkView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name));const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:xu(e.name,this.schema)};const i=va(e,"addMarkView",r);if(!i){return[]}const s=(r,s,o)=>{const l=Oa(r,n);return i()({mark:r,view:s,inline:o,editor:t,extension:e,HTMLAttributes:l,updateAttributes:e=>{yh(r,t,e)}})};return[e.name,s]})))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map((t=>[t.name,t.storage])));t.forEach((t=>{var e;const n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Ja(t.name,this.schema)};if(t.type==="mark"){const r=(e=Ma(va(t,"keepOnSplit",n)))!=null?e:true;if(r){this.splittableMarks.push(t.name)}}const r=va(t,"onBeforeCreate",n);const i=va(t,"onCreate",n);const s=va(t,"onUpdate",n);const o=va(t,"onSelectionUpdate",n);const l=va(t,"onTransaction",n);const u=va(t,"onFocus",n);const a=va(t,"onBlur",n);const f=va(t,"onDestroy",n);if(r){this.editor.on("beforeCreate",r)}if(i){this.editor.on("create",i)}if(s){this.editor.on("update",s)}if(o){this.editor.on("selectionUpdate",o)}if(l){this.editor.on("transaction",l)}if(u){this.editor.on("focus",u)}if(a){this.editor.on("blur",a)}if(f){this.editor.on("destroy",f)}}))}};Uf.resolve=Pa;Uf.sort=Ia;Uf.flatten=ka;var qf={};tu(qf,{ClipboardTextSerializer:()=>Jf,Commands:()=>Wf,Delete:()=>Vf,Drop:()=>Gf,Editable:()=>Zf,FocusEvents:()=>Xf,Keymap:()=>Qf,Paste:()=>th,Tabindex:()=>eh,focusEventsPluginKey:()=>Yf});var Kf=class t extends If{constructor(){super(...arguments);this.type="extension"}static create(e={}){const n=typeof e==="function"?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};var Jf=Kf.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Mn({key:new En("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this;const{state:e,schema:n}=t;const{doc:r,selection:i}=e;const{ranges:s}=i;const o=Math.min(...s.map((t=>t.$from.pos)));const l=Math.max(...s.map((t=>t.$to.pos)));const u=_a(n);const a={from:o,to:l};return Da(r,a,{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}});var Wf=Kf.create({name:"commands",addCommands(){return{...ru}}});var Vf=Kf.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var n,r,i,s;if((s=(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.filterTransaction)==null?void 0:i.call(r,t))!=null?s:t.getMeta("y-sync$")){return}const o=pa(t.before,[t,...e]);const l=Ua(o);l.forEach((e=>{if(o.mapping.mapResult(e.oldRange.from).deletedAfter&&o.mapping.mapResult(e.oldRange.to).deletedBefore){o.before.nodesBetween(e.oldRange.from,e.oldRange.to,((n,r)=>{const i=r+n.nodeSize-2;const s=e.oldRange.from<=r&&i<=e.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:i,newFrom:o.mapping.map(r),newTo:o.mapping.map(i),deletedRange:e.oldRange,newRange:e.newRange,partial:!s,editor:this.editor,transaction:t,combinedTransform:o})}))}}));const u=o.mapping;o.steps.forEach(((e,n)=>{var r,i;if(e instanceof re){const s=u.slice(n).map(e.from,-1);const l=u.slice(n).map(e.to);const a=u.invert().map(s,-1);const f=u.invert().map(l);const h=(r=o.doc.nodeAt(s-1))==null?void 0:r.marks.some((t=>t.eq(e.mark)));const c=(i=o.doc.nodeAt(l))==null?void 0:i.marks.some((t=>t.eq(e.mark)));this.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:a,to:f},newRange:{from:s,to:l},partial:Boolean(c||h),editor:this.editor,transaction:t,combinedTransform:o})}}))};if((i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)!=null?i:true){setTimeout(s,0)}else{s()}}});var Gf=Kf.create({name:"drop",addProseMirrorPlugins(){return[new Mn({key:new En("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}});var Zf=Kf.create({name:"editable",addProseMirrorPlugins(){return[new Mn({key:new En("editable"),props:{editable:()=>this.editor.options.editable}})]}});var Yf=new En("focusEvents");var Xf=Kf.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Mn({key:Yf,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=true;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",false);e.dispatch(r);return false},blur:(e,n)=>{t.isFocused=false;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",false);e.dispatch(r);return false}}}})]}});var Qf=Kf.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:r}=e;const{empty:i,$anchor:s}=n;const{pos:o,parent:l}=s;const u=s.parent.isTextblock&&o>0?e.doc.resolve(o-1):s;const a=u.parent.type.spec.isolating;const f=s.pos-s.parentOffset;const h=a&&u.parent.childCount===1?f===s.pos:tn.atStart(r).from===o;if(!i||!l.type.isTextblock||l.textContent.length||!h||h&&s.parent.type.name==="paragraph"){return false}return t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()]));const e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()]));const n=()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()]));const r={Enter:n,"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()};const i={...r};const s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};if($u()||Wu()){return s}return i},addProseMirrorPlugins(){return[new Mn({key:new En("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some((t=>t.getMeta("composition")))){return}const r=t.some((t=>t.docChanged))&&!e.doc.eq(n.doc);const i=t.some((t=>t.getMeta("preventClearDocument")));if(!r||i){return}const{empty:s,from:o,to:l}=e.selection;const u=tn.atStart(e.doc).from;const a=tn.atEnd(e.doc).to;const f=o===u&&l===a;if(s||!f){return}const h=ef(n.doc);if(!h){return}const c=n.tr;const d=eu({state:n,transaction:c});const{commands:p}=new nu({editor:this.editor,state:d});p.clearNodes();if(!c.steps.length){return}return c}})]}});var th=Kf.create({name:"paste",addProseMirrorPlugins(){return[new Mn({key:new En("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}});var eh=Kf.create({name:"tabindex",addProseMirrorPlugins(){return[new Mn({key:new En("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var nh=class t{constructor(t,e,n=false,r=null){this.currentNode=null;this.actualDepth=null;this.isBlock=n;this.resolvedPos=t;this.editor=e;this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!=null?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from;let n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}e=this.from+1;n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){if(this.isBlock){return this.pos}return this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){if(this.isBlock){return this.pos+this.size}return this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0){return null}const e=this.resolvedPos.start(this.resolvedPos.depth-1);const n=this.resolvedPos.doc.resolve(e);return new t(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));if(e.depth!==this.depth){e=this.resolvedPos.doc.resolve(this.from-3)}return new t(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));if(e.depth!==this.depth){e=this.resolvedPos.doc.resolve(this.to+3)}return new t(e,this.editor)}get children(){const e=[];this.node.content.forEach(((n,r)=>{const i=n.isBlock&&!n.isTextblock;const s=n.isAtom&&!n.isText;const o=this.pos+r+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2){return}const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth){return}const u=new t(l,this.editor,i,i?n:null);if(i){u.actualDepth=this.depth+1}e.push(new t(l,this.editor,i,i?n:null))}));return e}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null;let r=this.parent;while(r&&!n){if(r.node.type.name===t){if(Object.keys(e).length>0);else{n=r}}r=r.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,true)[0]||null}querySelectorAll(t,e={},n=false){let r=[];if(!this.children||this.children.length===0){return r}const i=Object.keys(e);this.children.forEach((s=>{if(n&&r.length>0){return}if(s.node.type.name===t){const t=i.every((t=>e[t]===s.node.attrs[t]));if(t){r.push(s)}}if(n&&r.length>0){return}r=r.concat(s.querySelectorAll(t,e,n))}));return r}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t});this.editor.view.dispatch(e)}};var rh=`.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}`;function ih(t,e,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null){return r}const i=document.createElement("style");if(e){i.setAttribute("nonce",e)}i.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,"");i.innerHTML=t;document.getElementsByTagName("head")[0].appendChild(i);return i}var sh=class extends Ef{constructor(t={}){super();this.css=null;this.editorView=null;this.isFocused=false;this.isInitialized=false;this.extensionStorage={};this.instanceId=Math.random().toString(36).slice(2,9);this.options={element:typeof document!=="undefined"?document.createElement("div"):null,content:"",injectCSS:true,injectNonce:void 0,extensions:[],autofocus:false,editable:true,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:true,enablePasteRules:true,enableCoreExtensions:true,enableContentCheck:false,emitContentError:false,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null};this.isCapturingTransaction=false;this.capturedTransaction=null;this.setOptions(t);this.createExtensionManager();this.createCommandManager();this.createSchema();this.on("beforeCreate",this.options.onBeforeCreate);this.emit("beforeCreate",{editor:this});this.on("mount",this.options.onMount);this.on("unmount",this.options.onUnmount);this.on("contentError",this.options.onContentError);this.on("create",this.options.onCreate);this.on("update",this.options.onUpdate);this.on("selectionUpdate",this.options.onSelectionUpdate);this.on("transaction",this.options.onTransaction);this.on("focus",this.options.onFocus);this.on("blur",this.options.onBlur);this.on("destroy",this.options.onDestroy);this.on("drop",(({event:t,slice:e,moved:n})=>this.options.onDrop(t,e,n)));this.on("paste",(({event:t,slice:e})=>this.options.onPaste(t,e)));this.on("delete",this.options.onDelete);const e=this.createDoc();const n=Au(e,this.options.autofocus);this.editorState=yn.create({doc:e,schema:this.schema,selection:n||void 0});if(this.options.element){this.mount(this.options.element)}}mount(t){if(typeof document==="undefined"){throw new Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`)}this.createView(t);this.emit("mount",{editor:this});if(this.css&&!document.head.contains(this.css)){document.head.appendChild(this.css)}window.setTimeout((()=>{if(this.isDestroyed){return}this.commands.focus(this.options.autofocus);this.emit("create",{editor:this});this.isInitialized=true}),0)}unmount(){if(this.editorView){const t=this.editorView.dom;if(t==null?void 0:t.editor){delete t.editor}this.editorView.destroy()}this.editorView=null;this.isInitialized=false;if(this.css){try{if(typeof this.css.remove==="function"){this.css.remove()}else if(this.css.parentNode){this.css.parentNode.removeChild(this.css)}}catch(t){console.warn("Failed to remove CSS element:",t)}}this.css=null;this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){if(this.options.injectCSS&&typeof document!=="undefined"){this.css=ih(rh,this.options.injectNonce)}}setOptions(t={}){this.options={...this.options,...t};if(!this.editorView||!this.state||this.isDestroyed){return}if(this.options.editorProps){this.view.setProps(this.options.editorProps)}this.view.updateState(this.state)}setEditable(t,e=true){this.setOptions({editable:t});if(e){this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){if(this.editorView){return this.editorView}return new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:false,dragging:null,editable:true,isDestroyed:false},{get:(t,e)=>{if(this.editorView){return this.editorView[e]}if(e==="state"){return this.editorState}if(e in t){return Reflect.get(t,e)}throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){if(this.editorView){this.editorState=this.view.state}return this.editorState}registerPlugin(t,e){const n=xa(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t];const r=this.state.reconfigure({plugins:n});this.view.updateState(r);return r}unregisterPlugin(t){if(this.isDestroyed){return void 0}const e=this.state.plugins;let n=e;[].concat(t).forEach((t=>{const e=typeof t==="string"?`${t}$`:t.key;n=n.filter((t=>!t.key.startsWith(e)))}));if(e.length===n.length){return void 0}const r=this.state.reconfigure({plugins:n});this.view.updateState(r);return r}createExtensionManager(){var t,e;const n=this.options.enableCoreExtensions?[Zf,Jf.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Wf,Xf,Qf,eh,Gf,th,Vf].filter((t=>{if(typeof this.options.enableCoreExtensions==="object"){return this.options.enableCoreExtensions[t.name]!==false}return true})):[];const r=[...n,...this.options.extensions].filter((t=>["extension","node","mark"].includes(t==null?void 0:t.type)));this.extensionManager=new Uf(r,this)}createCommandManager(){this.commandManager=new nu({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=ha(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)){throw e}this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{if("collaboration"in this.storage&&typeof this.storage.collaboration==="object"&&this.storage.collaboration){this.storage.collaboration.isDisabled=true}this.options.extensions=this.options.extensions.filter((t=>t.name!=="collaboration"));this.createExtensionManager()}});t=ha(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:false})}return t}createView(t){var e;this.editorView=new Cl(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n);this.prependClass();this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){if(this.view.isDestroyed){return}this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=true;t();this.isCapturingTransaction=false;const e=this.capturedTransaction;this.capturedTransaction=null;return e}dispatchTransaction(t){if(this.view.isDestroyed){return}if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach((t=>{var e;return(e=this.capturedTransaction)==null?void 0:e.step(t)}));return}const{state:e,transactions:n}=this.state.applyTransaction(t);const r=!this.state.selection.eq(e.selection);const i=n.includes(t);const s=this.state;this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e});if(!i){return}this.view.updateState(e);this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)});if(r){this.emit("selectionUpdate",{editor:this,transaction:t})}const o=n.findLast((t=>t.getMeta("focus")||t.getMeta("blur")));const l=o==null?void 0:o.getMeta("focus");const u=o==null?void 0:o.getMeta("blur");if(l){this.emit("focus",{editor:this,event:l.event,transaction:o})}if(u){this.emit("blur",{editor:this,event:u.event,transaction:o})}if(t.getMeta("preventUpdate")||!n.some((t=>t.docChanged))||s.doc.eq(e.doc)){return}this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return za(this.state,t)}isActive(t,e){const n=typeof t==="string"?t:null;const r=typeof t==="string"?e:t;return Za(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ya(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return Ha(this.state.doc,{blockSeparator:e,textSerializers:{..._a(this.schema),...n}})}get isEmpty(){return ef(this.state.doc)}destroy(){this.emit("destroy");this.unmount();this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:true}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new nh(e,this)}get $doc(){return this.$pos(0)}};function oh(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ma(t.getAttributes,void 0,r);if(i===false||i===null){return null}const{tr:s}=e;const o=r[r.length-1];const l=r[0];if(o){const r=l.search(/\S/);const u=n.from+l.indexOf(o);const a=u+o.length;const f=qa(n.from,n.to,e.doc).filter((e=>{const n=e.mark.type.excluded;return n.find((n=>n===t.type&&n!==e.mark.type))})).filter((t=>t.to>u));if(f.length){return null}if(a<n.to){s.delete(a,n.to)}if(u>n.from){s.delete(n.from+r,u)}const h=n.from+r+o.length;s.addMark(n.from+r,h,t.type.create(i||{}));s.removeStoredMark(t.type)}},undoable:t.undoable})}function lh(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ma(t.getAttributes,void 0,r)||{};const{tr:s}=e;const o=n.from;let l=n.to;const u=t.type.create(i);if(r[1]){const t=r[0].lastIndexOf(r[1]);let e=o+t;if(e>l){e=l}else{l=e+r[1].length}const n=r[0][r[0].length-1];s.insertText(n,o+r[0].length-1);s.replaceWith(e,l,u)}else if(r[0]){const e=t.type.isInline?o:o-1;s.insert(e,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function uh(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from);const s=Ma(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type)){return null}e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function ah(t){return new Af({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=Ma(t.getAttributes,void 0,r)||{};const o=e.tr.delete(n.from,n.to);const l=o.doc.resolve(n.from);const u=l.blockRange();const a=u&&me(u,t.type,s);if(!a){return null}o.wrap(u,a);if(t.keepMarks&&t.editor){const{selection:n,storedMarks:r}=e;const{splittableMarks:i}=t.editor.extensionManager;const s=r||n.$to.parentOffset&&n.$from.marks();if(s){const t=s.filter((t=>i.includes(t.type.name)));o.ensureMarks(t)}}if(t.keepAttributes){const e=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(e,s).run()}const f=o.doc.resolve(n.from-1).nodeBefore;if(f&&f.type===t.type&&Ae(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))){o.join(n.from-1)}},undoable:t.undoable})}function fh(t,e){const{selection:n}=t;const{$from:r}=n;if(n instanceof ln){const t=r.index();const n=r.parent;return n.canReplaceWith(t,t+1,e)}let i=r.depth;while(i>=0){const t=r.index(i);const n=r.node(i);const s=n.contentMatchAt(t);if(s.matchType(e)){return true}i-=1}return false}var hh={};tu(hh,{createAtomBlockMarkdownSpec:()=>ph,createBlockMarkdownSpec:()=>mh,createInlineMarkdownSpec:()=>bh,parseAttributes:()=>ch,parseIndentedBlocks:()=>vh,renderNestedMarkdownContent:()=>kh,serializeAttributes:()=>dh});function ch(t){if(!(t==null?void 0:t.trim())){return{}}const e={};const n=[];const r=t.replace(/["']([^"']*)["']/g,(t=>{n.push(t);return`__QUOTED_${n.length-1}__`}));const i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const t=i.map((t=>t.trim().slice(1)));e.class=t.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);if(s){e.id=s[1]}const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;const l=Array.from(r.matchAll(o));l.forEach((([,t,r])=>{var i;const s=parseInt(((i=r.match(/__QUOTED_(\d+)__/))==null?void 0:i[1])||"0",10);const o=n[s];if(o){e[t]=o.slice(1,-1)}}));const u=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();if(u){const t=u.split(/\s+/).filter(Boolean);t.forEach((t=>{if(t.match(/^[a-zA-Z][\w-]*$/)){e[t]=true}}))}return e}function dh(t){if(!t||Object.keys(t).length===0){return""}const e=[];if(t.class){const n=String(t.class).split(/\s+/).filter(Boolean);n.forEach((t=>e.push(`.${t}`)))}if(t.id){e.push(`#${t.id}`)}Object.entries(t).forEach((([t,n])=>{if(t==="class"||t==="id"){return}if(n===true){e.push(t)}else if(n!==false&&n!=null){e.push(`${t}="${String(n)}"`)}}));return e.join(" ")}function ph(t){const{nodeName:e,name:n,parseAttributes:r=ch,serializeAttributes:i=dh,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t;const u=n||e;const a=t=>{if(!l){return t}const e={};l.forEach((n=>{if(n in t){e[n]=t[n]}}));return e};return{parseMarkdown:(t,n)=>{const r={...s,...t.attributes};return n.createNode(e,r,[])},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${u}(?:\\s|$)`,"m");const r=(e=t.match(n))==null?void 0:e.index;return r!==void 0?r:-1},tokenize(t,n,i){const s=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`);const l=t.match(s);if(!l){return void 0}const a=l[1]||"";const f=r(a);const h=o.find((t=>!(t in f)));if(h){return void 0}return{type:e,raw:l[0],attributes:f}}},renderMarkdown:t=>{const e=a(t.attrs||{});const n=i(e);const r=n?` {${n}}`:"";return`:::${u}${r} :::`}}}function mh(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=ch,serializeAttributes:s=dh,defaultAttributes:o={},content:l="block",allowedAttributes:u}=t;const a=n||e;const f=t=>{if(!u){return t}const e={};u.forEach((n=>{if(n in t){e[n]=t[n]}}));return e};return{parseMarkdown:(t,n)=>{let i;if(r){const e=r(t);i=typeof e==="string"?[{type:"text",text:e}]:e}else if(l==="block"){i=n.parseChildren(t.tokens||[])}else{i=n.parseInline(t.tokens||[])}const s={...o,...t.attributes};return n.createNode(e,s,i)},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${a}`,"m");const r=(e=t.match(n))==null?void 0:e.index;return r!==void 0?r:-1},tokenize(t,n,r){var s;const o=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*\\n`);const u=t.match(o);if(!u){return void 0}const[f,h=""]=u;const c=i(h);let d=1;const p=f.length;let m="";const g=/^:::([\w-]*)(\s.*)?/gm;const w=t.slice(p);g.lastIndex=0;for(;;){const n=g.exec(w);if(n===null){break}const i=n.index;const o=n[1];if((s=n[2])==null?void 0:s.endsWith(":::")){continue}if(o){d+=1}else{d-=1;if(d===0){const s=w.slice(0,i);m=s.trim();const o=t.slice(0,p+i+n[0].length);let u=[];if(m){if(l==="block"){u=r.blockTokens(s);u.forEach((t=>{if(t.text&&(!t.tokens||t.tokens.length===0)){t.tokens=r.inlineTokens(t.text)}}));while(u.length>0){const t=u[u.length-1];if(t.type==="paragraph"&&(!t.text||t.text.trim()==="")){u.pop()}else{break}}}else{u=r.inlineTokens(m)}}return{type:e,raw:o,attributes:c,content:m,tokens:u}}}}return void 0}},renderMarkdown:(t,e)=>{const n=f(t.attrs||{});const r=s(n);const i=r?` {${r}}`:"";const o=e.renderChildren(t.content||[],"\n\n");return`:::${a}${i}\n\n${o}\n\n:::`}}}function gh(t){if(!t.trim()){return{}}const e={};const n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);while(r!==null){const[,i,s,o]=r;e[i]=s||o;r=n.exec(t)}return e}function wh(t){return Object.entries(t).filter((([,t])=>t!==void 0&&t!==null)).map((([t,e])=>`${t}="${e}"`)).join(" ")}function bh(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=gh,serializeAttributes:s=wh,defaultAttributes:o={},selfClosing:l=false,allowedAttributes:u}=t;const a=n||e;const f=t=>{if(!u){return t}const e={};u.forEach((n=>{if(n in t){e[n]=t[n]}}));return e};const h=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(t,n)=>{const i={...o,...t.attributes};if(l){return n.createNode(e,i)}const s=r?r(t):t.content||"";if(s){return n.createNode(e,i,[n.createTextNode(s)])}return n.createNode(e,i,[])},markdownTokenizer:{name:e,level:"inline",start(t){const e=l?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`);const n=t.match(e);const r=n==null?void 0:n.index;return r!==void 0?r:-1},tokenize(t,n,r){const s=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`);const o=t.match(s);if(!o){return void 0}let u="";let a="";if(l){const[,t]=o;a=t}else{const[,t,e]=o;a=t;u=e||""}const f=i(a.trim());return{type:e,raw:o[0],content:u.trim(),attributes:f}}},renderMarkdown:t=>{let e="";if(r){e=r(t)}else if(t.content&&t.content.length>0){e=t.content.filter((t=>t.type==="text")).map((t=>t.text)).join("")}const n=f(t.attrs||{});const i=s(n);const o=i?` ${i}`:"";if(l){return`[${a}${o}]`}return`[${a}${o}]${e}[/${a}]`}}}function vh(t,e,n){var r,i,s,o;const l=t.split("\n");const u=[];let a="";let f=0;const h=e.baseIndentSize||2;while(f<l.length){const t=l[f];const c=t.match(e.itemPattern);if(!c){if(u.length>0){break}else if(t.trim()===""){f+=1;continue}else{return void 0}}const d=e.extractItemData(c);const{indentLevel:p,mainContent:m}=d;a=`${a}${t}\n`;const g=[m];f+=1;while(f<l.length){const t=l[f];if(t.trim()===""){const e=l.slice(f+1).findIndex((t=>t.trim()!==""));if(e===-1){break}const n=l[f+1+e];const s=((i=(r=n.match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0;if(s>p){g.push(t);a=`${a}${t}\n`;f+=1;continue}else{break}}const e=((o=(s=t.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0;if(e>p){g.push(t);a=`${a}${t}\n`;f+=1}else{break}}let w;const b=g.slice(1);if(b.length>0){const t=b.map((t=>t.slice(p+h))).join("\n");if(t.trim()){if(e.customNestedParser){w=e.customNestedParser(t)}else{w=n.blockTokens(t)}}}const v=e.createToken(d,w);u.push(v)}if(u.length===0){return void 0}return{items:u,raw:a.trim()}}function kh(t,e,n,r){if(!t||!Array.isArray(t.content)){return""}const i=typeof n==="function"?n(r):n;const[s,...o]=t.content;const l=e.renderChildren([s]);const u=[`${i}${l}`];if(o&&o.length>0){o.forEach((t=>{const n=e.renderChildren([t]);if(n){const t=n.split("\n").map((t=>t?e.indent(t):"")).join("\n");u.push(t)}}))}return u.join("\n")}function yh(t,e,n={}){const{state:r}=e;const{doc:i,tr:s}=r;const o=t;i.descendants(((e,r)=>{const i=s.mapping.map(r);const l=s.mapping.map(r)+e.nodeSize;let u=null;e.marks.forEach((t=>{if(t!==o){return false}u=t}));if(!u){return}let a=false;Object.keys(n).forEach((t=>{if(n[t]!==u.attrs[t]){a=true}}));if(a){const e=t.type.create({...t.attrs,...n});s.removeMark(i,l,t.type);s.addMark(i,l,e)}}));if(s.docChanged){e.view.dispatch(s)}}var xh=class t extends If{constructor(){super(...arguments);this.type="node"}static create(e={}){const n=typeof e==="function"?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};function Mh(t){return new Hf({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=Ma(t.getAttributes,void 0,r,i);if(s===false||s===null){return null}const{tr:o}=e;const l=r[r.length-1];const u=r[0];let a=n.to;if(l){const r=u.search(/\S/);const i=n.from+u.indexOf(l);const f=i+l.length;const h=qa(n.from,n.to,e.doc).filter((e=>{const n=e.mark.type.excluded;return n.find((n=>n===t.type&&n!==e.mark.type))})).filter((t=>t.to>i));if(h.length){return null}if(f<n.to){o.delete(f,n.to)}if(i>n.from){o.delete(n.from+r,i)}a=n.from+r+l.length;o.addMark(n.from+r,a,t.type.create(s||{}));o.removeStoredMark(t.type)}}})}var Sh=(t,e)=>{if(t==="slot"){return 0}if(t instanceof Function){return t(e)}const{children:n,...r}=e!=null?e:{};if(t==="svg"){throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead")}return[t,r,n]};var Th=/^\s*>\s$/;var Eh=xh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:true,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Sh("blockquote",{...Aa(this.options.HTMLAttributes,t),children:Sh("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content){return""}const n=[];t.content.forEach((t=>{const r=e.renderChildren(t);const i=r.split("\n").map((t=>`> ${t}`)).join("\n");n.push(i)}));const r=n.flatMap((t=>[t,"> "]));return r.slice(0,-1).join("\n")},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[ah({find:Th,type:this.type})]}});var Ah=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;var Oh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;var $h=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;var Rh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;var Ch=Pf.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Sh("strong",{...Aa(this.options.HTMLAttributes,t),children:Sh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[oh({find:Ah,type:this.type}),oh({find:$h,type:this.type})]},addPasteRules(){return[Mh({find:Oh,type:this.type}),Mh({find:Rh,type:this.type})]}});var Lh=/(^|[^`])`([^`]+)`(?!`)$/;var Nh=/(^|[^`])`([^`]+)`(?!`)/g;var Ih=Pf.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:true,exitable:true,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>{if(!t.content){return""}return`\`${e.renderChildren(t.content)}\``},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[oh({find:Lh,type:this.type})]},addPasteRules(){return[Mh({find:Nh,type:this.type})]}});var Ph=4;var Dh=/^```([a-z]+)?[\s\n]$/;var Hh=/^~~~([a-z]+)?[\s\n]$/;var _h=xh.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:true,exitOnArrowDown:true,defaultLanguage:null,enableTabIndentation:false,tabSize:Ph,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:true,defining:true,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n){return null}const r=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]];const i=r.filter((t=>t.startsWith(n))).map((t=>t.replace(n,"")));const s=i[0];if(!s){return null}return s},rendered:false}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Aa(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;if(((n=t.raw)==null?void 0:n.startsWith("```"))===false&&t.codeBlockStyle!=="indented"){return[]}return e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";if(!t.content){r=`\`\`\`${i}\n\n\`\`\``}else{const n=[`\`\`\`${i}`,e.renderChildren(t.content),"```"];r=n.join("\n")}return r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection;const n=e.pos===1;if(!t||e.parent.type.name!==this.name){return false}if(n||!e.parent.textContent.length){return this.editor.commands.clearNodes()}return false},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation){return false}const n=(e=this.options.tabSize)!=null?e:Ph;const{state:r}=t;const{selection:i}=r;const{$from:s,empty:o}=i;if(s.parent.type!==this.type){return false}const l=" ".repeat(n);if(o){return t.commands.insertContent(l)}return t.commands.command((({tr:t})=>{const{from:e,to:n}=i;const s=r.doc.textBetween(e,n,"\n","\n");const o=s.split("\n");const u=o.map((t=>l+t)).join("\n");t.replaceWith(e,n,r.schema.text(u));return true}))},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation){return false}const n=(e=this.options.tabSize)!=null?e:Ph;const{state:r}=t;const{selection:i}=r;const{$from:s,empty:o}=i;if(s.parent.type!==this.type){return false}if(o){return t.commands.command((({tr:t})=>{var e;const{pos:i}=s;const o=s.start();const l=s.end();const u=r.doc.textBetween(o,l,"\n","\n");const a=u.split("\n");let f=0;let h=0;const c=i-o;for(let t=0;t<a.length;t+=1){if(h+a[t].length>=c){f=t;break}h+=a[t].length+1}const d=a[f];const p=((e=d.match(/^ */))==null?void 0:e[0])||"";const m=Math.min(p.length,n);if(m===0){return true}let g=o;for(let t=0;t<f;t+=1){g+=a[t].length+1}t.delete(g,g+m);const w=i-g;if(w<=m){t.setSelection(sn.create(t.doc,g))}return true}))}return t.commands.command((({tr:t})=>{const{from:e,to:s}=i;const o=r.doc.textBetween(e,s,"\n","\n");const l=o.split("\n");const u=l.map((t=>{var e;const r=((e=t.match(/^ */))==null?void 0:e[0])||"";const i=Math.min(r.length,n);return t.slice(i)})).join("\n");t.replaceWith(e,s,r.schema.text(u));return true}))},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter){return false}const{state:e}=t;const{selection:n}=e;const{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type){return false}const s=r.parentOffset===r.parent.nodeSize-2;const o=r.parent.textContent.endsWith("\n\n");if(!s||!o){return false}return t.chain().command((({tr:t})=>{t.delete(r.pos-2,r.pos);return true})).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown){return false}const{state:e}=t;const{selection:n,doc:r}=e;const{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type){return false}const o=i.parentOffset===i.parent.nodeSize-2;if(!o){return false}const l=i.after();if(l===void 0){return false}const u=r.nodeAt(l);if(u){return t.commands.command((({tr:t})=>{t.setSelection(tn.near(r.resolve(l)));return true}))}return t.commands.exitCode()}}},addInputRules(){return[uh({find:Dh,type:this.type,getAttributes:t=>({language:t[1]})}),uh({find:Hh,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Mn({key:new En("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData){return false}if(this.editor.isActive(this.type.name)){return false}const n=e.clipboardData.getData("text/plain");const r=e.clipboardData.getData("vscode-editor-data");const i=r?JSON.parse(r):void 0;const s=i==null?void 0:i.mode;if(!n||!s){return false}const{tr:o,schema:l}=t.state;const u=l.text(n.replace(/\r\n?/g,"\n"));o.replaceSelectionWith(this.type.create({language:s},u));if(o.selection.$from.parent.type!==this.type){o.setSelection(sn.near(o.doc.resolve(Math.max(0,o.selection.from-2))))}o.setMeta("paste",true);t.dispatch(o);return true}}})]}});var jh=xh.create({name:"doc",topNode:true,content:"block+",renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n\n")}});var zh=xh.create({name:"hardBreak",addOptions(){return{keepMarks:true,HTMLAttributes:{}}},inline:true,group:"inline",selectable:false,linebreakReplacement:true,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Aa(this.options.HTMLAttributes,t)]},renderText(){return"\n"},renderMarkdown:(t,e)=>e.indent(`\n`),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:i}=n;if(t.$from.parent.type.spec.isolating){return false}const{keepMarks:s}=this.options;const{splittableMarks:o}=r.extensionManager;const l=i||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&l&&s){const e=l.filter((t=>o.includes(t.type.name)));t.ensureMarks(e)}return true})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Bh=xh.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:true,addAttributes(){return{level:{default:1,rendered:false}}},parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){const n=this.options.levels.includes(t.attrs.level);const r=n?t.attrs.level:this.options.levels[0];return[`h${r}`,Aa(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.level)?parseInt(t.attrs.level,10):1;const i="#".repeat(r);if(!t.content){return""}return`${i} ${e.renderChildren(t.content)}`},addCommands(){return{setHeading:t=>({commands:e})=>{if(!this.options.levels.includes(t.level)){return false}return e.setNode(this.name,t)},toggleHeading:t=>({commands:e})=>{if(!this.options.levels.includes(t.level)){return false}return e.toggleNode(this.name,"paragraph",t)}}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,...{[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}})),{})},addInputRules(){return this.options.levels.map((t=>uh({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}});var Fh=xh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Aa(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!fh(e,e.schema.nodes[this.name])){return false}const{selection:n}=e;const{$to:r}=n;const i=t();if(nf(n)){i.insertContentAt(r.pos,{type:this.name})}else{i.insertContent({type:this.name})}return i.command((({state:t,tr:e,dispatch:n})=>{if(n){const{$to:n}=e.selection;const r=n.end();if(n.nodeAfter){if(n.nodeAfter.isTextblock){e.setSelection(sn.create(e.doc,n.pos+1))}else if(n.nodeAfter.isBlock){e.setSelection(ln.create(e.doc,n.pos))}else{e.setSelection(sn.create(e.doc,n.pos))}}else{const i=t.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType;const s=i==null?void 0:i.create();if(s){e.insert(r,s);e.setSelection(sn.create(e.doc,r+1))}}e.scrollIntoView()}return true})).run()}}},addInputRules(){return[lh({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Uh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/;var qh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g;var Kh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/;var Jh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;var Wh=Pf.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Aa(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[oh({find:Uh,type:this.type}),oh({find:Kh,type:this.type})]},addPasteRules(){return[Mh({find:qh,type:this.type}),Mh({find:Jh,type:this.type})]}});const Vh="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";const Gh="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2";const Zh="numeric";const Yh="ascii";const Xh="alpha";const Qh="asciinumeric";const tc="alphanumeric";const ec="domain";const nc="emoji";const rc="scheme";const ic="slashscheme";const sc="whitespace";function oc(t,e){if(!(t in e)){e[t]=[]}return e[t]}function lc(t,e,n){if(e[Zh]){e[Qh]=true;e[tc]=true}if(e[Yh]){e[Qh]=true;e[Xh]=true}if(e[Qh]){e[tc]=true}if(e[Xh]){e[tc]=true}if(e[tc]){e[ec]=true}if(e[nc]){e[ec]=true}for(const r in e){const e=oc(r,n);if(e.indexOf(t)<0){e.push(t)}}}function uc(t,e){const n={};for(const r in e){if(e[r].indexOf(t)>=0){n[r]=true}}return n}function ac(t=null){this.j={};this.jr=[];this.jd=null;this.t=t}ac.groups={};ac.prototype={accepts(){return!!this.t},go(t){const e=this;const n=e.j[t];if(n){return n}for(let n=0;n<e.jr.length;n++){const r=e.jr[n][0];const i=e.jr[n][1];if(i&&r.test(t)){return i}}return e.jd},has(t,e=false){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++){this.tt(t[i],e,n,r)}},tr(t,e,n,r){r=r||ac.groups;let i;if(e&&e.j){i=e}else{i=new ac(e);if(n&&r){lc(e,n,r)}}this.jr.push([t,i]);return i},ts(t,e,n,r){let i=this;const s=t.length;if(!s){return i}for(let e=0;e<s-1;e++){i=i.tt(t[e])}return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||ac.groups;const i=this;if(e&&e.j){i.j[t]=e;return e}const s=e;let o,l=i.go(t);if(l){o=new ac;Object.assign(o.j,l.j);o.jr.push.apply(o.jr,l.jr);o.jd=l.jd;o.t=l.t}else{o=new ac}if(s){if(r){if(o.t&&typeof o.t==="string"){const t=Object.assign(uc(o.t,r),n);lc(s,t,r)}else if(n){lc(s,n,r)}}o.t=s}i.j[t]=o;return o}};const fc=(t,e,n,r,i)=>t.ta(e,n,r,i);const hc=(t,e,n,r,i)=>t.tr(e,n,r,i);const cc=(t,e,n,r,i)=>t.ts(e,n,r,i);const dc=(t,e,n,r,i)=>t.tt(e,n,r,i);const pc="WORD";const mc="UWORD";const gc="ASCIINUMERICAL";const wc="ALPHANUMERICAL";const bc="LOCALHOST";const vc="TLD";const kc="UTLD";const yc="SCHEME";const xc="SLASH_SCHEME";const Mc="NUM";const Sc="WS";const Tc="NL";const Ec="OPENBRACE";const Ac="CLOSEBRACE";const Oc="OPENBRACKET";const $c="CLOSEBRACKET";const Rc="OPENPAREN";const Cc="CLOSEPAREN";const Lc="OPENANGLEBRACKET";const Nc="CLOSEANGLEBRACKET";const Ic="FULLWIDTHLEFTPAREN";const Pc="FULLWIDTHRIGHTPAREN";const Dc="LEFTCORNERBRACKET";const Hc="RIGHTCORNERBRACKET";const _c="LEFTWHITECORNERBRACKET";const jc="RIGHTWHITECORNERBRACKET";const zc="FULLWIDTHLESSTHAN";const Bc="FULLWIDTHGREATERTHAN";const Fc="AMPERSAND";const Uc="APOSTROPHE";const qc="ASTERISK";const Kc="AT";const Jc="BACKSLASH";const Wc="BACKTICK";const Vc="CARET";const Gc="COLON";const Zc="COMMA";const Yc="DOLLAR";const Xc="DOT";const Qc="EQUALS";const td="EXCLAMATION";const ed="HYPHEN";const nd="PERCENT";const rd="PIPE";const id="PLUS";const sd="POUND";const od="QUERY";const ld="QUOTE";const ud="FULLWIDTHMIDDLEDOT";const ad="SEMI";const fd="SLASH";const hd="TILDE";const cd="UNDERSCORE";const dd="EMOJI";const pd="SYM";var md=Object.freeze({__proto__:null,ALPHANUMERICAL:wc,AMPERSAND:Fc,APOSTROPHE:Uc,ASCIINUMERICAL:gc,ASTERISK:qc,AT:Kc,BACKSLASH:Jc,BACKTICK:Wc,CARET:Vc,CLOSEANGLEBRACKET:Nc,CLOSEBRACE:Ac,CLOSEBRACKET:$c,CLOSEPAREN:Cc,COLON:Gc,COMMA:Zc,DOLLAR:Yc,DOT:Xc,EMOJI:dd,EQUALS:Qc,EXCLAMATION:td,FULLWIDTHGREATERTHAN:Bc,FULLWIDTHLEFTPAREN:Ic,FULLWIDTHLESSTHAN:zc,FULLWIDTHMIDDLEDOT:ud,FULLWIDTHRIGHTPAREN:Pc,HYPHEN:ed,LEFTCORNERBRACKET:Dc,LEFTWHITECORNERBRACKET:_c,LOCALHOST:bc,NL:Tc,NUM:Mc,OPENANGLEBRACKET:Lc,OPENBRACE:Ec,OPENBRACKET:Oc,OPENPAREN:Rc,PERCENT:nd,PIPE:rd,PLUS:id,POUND:sd,QUERY:od,QUOTE:ld,RIGHTCORNERBRACKET:Hc,RIGHTWHITECORNERBRACKET:jc,SCHEME:yc,SEMI:ad,SLASH:fd,SLASH_SCHEME:xc,SYM:pd,TILDE:hd,TLD:vc,UNDERSCORE:cd,UTLD:kc,UWORD:mc,WORD:pc,WS:Sc});const gd=/[a-z]/;const wd=/\p{L}/u;const bd=/\p{Emoji}/u;const vd=/\d/;const kd=/\s/;const yd="\r";const xd="\n";const Md="️";const Sd="‍";const Td="";let Ed=null,Ad=null;function Od(t=[]){const e={};ac.groups=e;const n=new ac;if(Ed==null){Ed=Ld(Vh)}if(Ad==null){Ad=Ld(Gh)}dc(n,"'",Uc);dc(n,"{",Ec);dc(n,"}",Ac);dc(n,"[",Oc);dc(n,"]",$c);dc(n,"(",Rc);dc(n,")",Cc);dc(n,"<",Lc);dc(n,">",Nc);dc(n,"(",Ic);dc(n,")",Pc);dc(n,"「",Dc);dc(n,"」",Hc);dc(n,"『",_c);dc(n,"』",jc);dc(n,"<",zc);dc(n,">",Bc);dc(n,"&",Fc);dc(n,"*",qc);dc(n,"@",Kc);dc(n,"`",Wc);dc(n,"^",Vc);dc(n,":",Gc);dc(n,",",Zc);dc(n,"$",Yc);dc(n,".",Xc);dc(n,"=",Qc);dc(n,"!",td);dc(n,"-",ed);dc(n,"%",nd);dc(n,"|",rd);dc(n,"+",id);dc(n,"#",sd);dc(n,"?",od);dc(n,'"',ld);dc(n,"/",fd);dc(n,";",ad);dc(n,"~",hd);dc(n,"_",cd);dc(n,"\\",Jc);dc(n,"・",ud);const r=hc(n,vd,Mc,{[Zh]:true});hc(r,vd,r);const i=hc(r,gd,gc,{[Qh]:true});const s=hc(r,wd,wc,{[tc]:true});const o=hc(n,gd,pc,{[Yh]:true});hc(o,vd,i);hc(o,gd,o);hc(i,vd,i);hc(i,gd,i);const l=hc(n,wd,mc,{[Xh]:true});hc(l,gd);hc(l,vd,s);hc(l,wd,l);hc(s,vd,s);hc(s,gd);hc(s,wd,s);const u=dc(n,xd,Tc,{[sc]:true});const a=dc(n,yd,Sc,{[sc]:true});const f=hc(n,kd,Sc,{[sc]:true});dc(n,Td,f);dc(a,xd,u);dc(a,Td,f);hc(a,kd,f);dc(f,yd);dc(f,xd);hc(f,kd,f);dc(f,Td,f);const h=hc(n,bd,dd,{[nc]:true});dc(h,"#");hc(h,bd,h);dc(h,Md,h);const c=dc(h,Sd);dc(c,"#");hc(c,bd,h);const d=[[gd,o],[vd,i]];const p=[[gd,null],[wd,l],[vd,s]];for(let t=0;t<Ed.length;t++){Cd(n,Ed[t],vc,pc,d)}for(let t=0;t<Ad.length;t++){Cd(n,Ad[t],kc,mc,p)}lc(vc,{tld:true,ascii:true},e);lc(kc,{utld:true,alpha:true},e);Cd(n,"file",yc,pc,d);Cd(n,"mailto",yc,pc,d);Cd(n,"http",xc,pc,d);Cd(n,"https",xc,pc,d);Cd(n,"ftp",xc,pc,d);Cd(n,"ftps",xc,pc,d);lc(yc,{scheme:true,ascii:true},e);lc(xc,{slashscheme:true,ascii:true},e);t=t.sort(((t,e)=>t[0]>e[0]?1:-1));for(let e=0;e<t.length;e++){const r=t[e][0];const i=t[e][1];const s=i?{[rc]:true}:{[ic]:true};if(r.indexOf("-")>=0){s[ec]=true}else if(!gd.test(r)){s[Zh]=true}else if(vd.test(r)){s[Qh]=true}else{s[Yh]=true}cc(n,r,r,s)}cc(n,"localhost",bc,{ascii:true});n.jd=new ac(pd);return{start:n,tokens:Object.assign({groups:e},md)}}function $d(t,e){const n=Rd(e.replace(/[A-Z]/g,(t=>t.toLowerCase())));const r=n.length;const i=[];let s=0;let o=0;while(o<r){let l=t;let u=null;let a=0;let f=null;let h=-1;let c=-1;while(o<r&&(u=l.go(n[o]))){l=u;if(l.accepts()){h=0;c=0;f=l}else if(h>=0){h+=n[o].length;c++}a+=n[o].length;s+=n[o].length;o++}s-=h;o-=c;a-=h;i.push({t:f.t,v:e.slice(s-a,s),s:s-a,e:s})}return i}function Rd(t){const e=[];const n=t.length;let r=0;while(r<n){let i=t.charCodeAt(r);let s;let o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o);r+=o.length}return e}function Cd(t,e,n,r,i){let s;const o=e.length;for(let n=0;n<o-1;n++){const o=e[n];if(t.j[o]){s=t.j[o]}else{s=new ac(r);s.jr=i.slice();t.j[o]=s}t=s}s=new ac(n);s.jr=i.slice();t.j[e[o-1]]=s;return s}function Ld(t){const e=[];const n=[];let r=0;let i="0123456789";while(r<t.length){let s=0;while(i.indexOf(t[r+s])>=0){s++}if(s>0){e.push(n.join(""));for(let e=parseInt(t.substring(r,r+s),10);e>0;e--){n.pop()}r+=s}else{n.push(t[r]);r++}}return e}const Nd={defaultProtocol:"http",events:null,format:Pd,formatHref:Pd,nl2br:false,tagName:"a",target:null,rel:null,validate:true,truncate:Infinity,className:null,attributes:null,ignoreTags:[],render:null};function Id(t,e=null){let n=Object.assign({},Nd);if(t){n=Object.assign(n,t instanceof Id?t.o:t)}const r=n.ignoreTags;const i=[];for(let t=0;t<r.length;t++){i.push(r[t].toUpperCase())}this.o=n;if(e){this.defaultRender=e}this.ignoreTags=i}Id.prototype={o:Nd,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];if(!i){return i}if(typeof i==="object"){i=n.t in i?i[n.t]:Nd[t];if(typeof i==="function"&&r){i=i(e,n)}}else if(typeof i==="function"&&r){i=i(e,n.t,n)}return i},getObj(t,e,n){let r=this.o[t];if(typeof r==="function"&&e!=null){r=r(e,n.t,n)}return r},render(t){const e=t.render(this);const n=this.get("render",null,t)||this.defaultRender;return n(e,t.t,t)}};function Pd(t){return t}function Dd(t,e){this.t="token";this.v=t;this.tk=e}Dd.prototype={isLink:false,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString();const n=t.get("truncate",e,this);const r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Nd.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this;const n=this.toHref(t.get("defaultProtocol"));const r=t.get("formatHref",n,this);const i=t.get("tagName",n,e);const s=this.toFormattedString(t);const o={};const l=t.get("className",n,e);const u=t.get("target",n,e);const a=t.get("rel",n,e);const f=t.getObj("attributes",n,e);const h=t.getObj("events",n,e);o.href=r;if(l){o.class=l}if(u){o.target=u}if(a){o.rel=a}if(f){Object.assign(o,f)}return{tagName:i,attributes:o,content:s,eventListeners:h}}};function Hd(t,e){class n extends Dd{constructor(e,n){super(e,n);this.t=t}}for(const t in e){n.prototype[t]=e[t]}n.t=t;return n}const _d=Hd("email",{isLink:true,toHref(){return"mailto:"+this.toString()}});const jd=Hd("text");const zd=Hd("nl");const Bd=Hd("url",{isLink:true,toHref(t=Nd.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==bc&&t[1].t===Gc}});const Fd=t=>new ac(t);function Ud({groups:t}){const e=t.domain.concat([Fc,qc,Kc,Jc,Wc,Vc,Yc,Qc,ed,Mc,nd,rd,id,sd,fd,pd,hd,cd]);const n=[Uc,Gc,Zc,Xc,td,nd,od,ld,ad,Lc,Nc,Ec,Ac,$c,Oc,Rc,Cc,Ic,Pc,Dc,Hc,_c,jc,zc,Bc];const r=[Fc,Uc,qc,Jc,Wc,Vc,Yc,Qc,ed,Ec,Ac,nd,rd,id,sd,od,fd,pd,hd,cd];const i=Fd();const s=dc(i,hd);fc(s,r,s);fc(s,t.domain,s);const o=Fd(),l=Fd(),u=Fd();fc(i,t.domain,o);fc(i,t.scheme,l);fc(i,t.slashscheme,u);fc(o,r,s);fc(o,t.domain,o);const a=dc(o,Kc);dc(s,Kc,a);dc(l,Kc,a);dc(u,Kc,a);const f=dc(s,Xc);fc(f,r,s);fc(f,t.domain,s);const h=Fd();fc(a,t.domain,h);fc(h,t.domain,h);const c=dc(h,Xc);fc(c,t.domain,h);const d=Fd(_d);fc(c,t.tld,d);fc(c,t.utld,d);dc(a,bc,d);const p=dc(h,ed);dc(p,ed,p);fc(p,t.domain,h);fc(d,t.domain,h);dc(d,Xc,c);dc(d,ed,p);const m=dc(d,Gc);fc(m,t.numeric,_d);const g=dc(o,ed);const w=dc(o,Xc);dc(g,ed,g);fc(g,t.domain,o);fc(w,r,s);fc(w,t.domain,o);const b=Fd(Bd);fc(w,t.tld,b);fc(w,t.utld,b);fc(b,t.domain,o);fc(b,r,s);dc(b,Xc,w);dc(b,ed,g);dc(b,Kc,a);const v=dc(b,Gc);const k=Fd(Bd);fc(v,t.numeric,k);const y=Fd(Bd);const x=Fd();fc(y,e,y);fc(y,n,x);fc(x,e,y);fc(x,n,x);dc(b,fd,y);dc(k,fd,y);const M=dc(l,Gc);const S=dc(u,Gc);const T=dc(S,fd);const E=dc(T,fd);fc(l,t.domain,o);dc(l,Xc,w);dc(l,ed,g);fc(u,t.domain,o);dc(u,Xc,w);dc(u,ed,g);fc(M,t.domain,y);dc(M,fd,y);dc(M,od,y);fc(E,t.domain,y);fc(E,e,y);dc(E,fd,y);const A=[[Ec,Ac],[Oc,$c],[Rc,Cc],[Lc,Nc],[Ic,Pc],[Dc,Hc],[_c,jc],[zc,Bc]];for(let t=0;t<A.length;t++){const[r,i]=A[t];const s=dc(y,r);dc(x,r,s);dc(s,i,y);const o=Fd(Bd);fc(s,e,o);const l=Fd();fc(s,n);fc(o,e,o);fc(o,n,l);fc(l,e,o);fc(l,n,l);dc(o,i,y);dc(l,i,y)}dc(i,bc,b);dc(i,Tc,zd);return{start:i,tokens:md}}function qd(t,e,n){let r=n.length;let i=0;let s=[];let o=[];while(i<r){let l=t;let u=null;let a=null;let f=0;let h=null;let c=-1;while(i<r&&!(u=l.go(n[i].t))){o.push(n[i++])}while(i<r&&(a=u||l.go(n[i].t))){u=null;l=a;if(l.accepts()){c=0;h=l}else if(c>=0){c++}i++;f++}if(c<0){i-=f;if(i<r){o.push(n[i]);i++}}else{if(o.length>0){s.push(Kd(jd,e,o));o=[]}i-=c;f-=c;const t=h.t;const r=n.slice(i-f,i);s.push(Kd(t,e,r))}}if(o.length>0){s.push(Kd(jd,e,o))}return s}function Kd(t,e,n){const r=n[0].s;const i=n[n.length-1].e;const s=e.slice(r,i);return new t(s,n)}const Jd=typeof console!=="undefined"&&console&&console.warn||(()=>{});const Wd="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.";const Vd={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:false};function Gd(){ac.groups={};Vd.scanner=null;Vd.parser=null;Vd.tokenQueue=[];Vd.pluginQueue=[];Vd.customSchemes=[];Vd.initialized=false;return Vd}function Zd(t,e=false){if(Vd.initialized){Jd(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Wd}`)}if(!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t)){throw new Error(`linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat`)}Vd.customSchemes.push([t,e])}function Yd(){Vd.scanner=Od(Vd.customSchemes);for(let t=0;t<Vd.tokenQueue.length;t++){Vd.tokenQueue[t][1]({scanner:Vd.scanner})}Vd.parser=Ud(Vd.scanner.tokens);for(let t=0;t<Vd.pluginQueue.length;t++){Vd.pluginQueue[t][1]({scanner:Vd.scanner,parser:Vd.parser})}Vd.initialized=true;return Vd}function Xd(t){if(!Vd.initialized){Yd()}return qd(Vd.parser.start,t,$d(Vd.scanner.start,t))}Xd.scan=$d;function Qd(t,e=null,n=null){if(e&&typeof e==="object"){if(n){throw Error(`linkifyjs: Invalid link type ${e}; must be a string`)}n=e;e=null}const r=new Id(n);const i=Xd(t);const s=[];for(let t=0;t<i.length;t++){const n=i[t];if(n.isLink&&(!e||n.t===e)&&r.check(n)){s.push(n.toFormattedObject(r))}}return s}var tp="[\0-   ᠎ -\u2029  ]";var ep=new RegExp(tp);var np=new RegExp(`${tp}$`);var rp=new RegExp(tp,"g");function ip(t){if(t.length===1){return t[0].isLink}if(t.length===3&&t[1].isLink){return["()","[]"].includes(t[0].value+t[2].value)}return false}function sp(t){return new Mn({key:new En("autolink"),appendTransaction:(e,n,r)=>{const i=e.some((t=>t.docChanged))&&!n.doc.eq(r.doc);const s=e.some((t=>t.getMeta("preventAutolink")));if(!i||s){return}const{tr:o}=r;const l=pa(n.doc,[...e]);const u=Ua(l);u.forEach((({newRange:e})=>{const n=ga(r.doc,e,(t=>t.isTextblock));let i;let s;if(n.length>1){i=n[0];s=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0," ")}else if(n.length){const t=r.doc.textBetween(e.from,e.to," "," ");if(!np.test(t)){return}i=n[0];s=r.doc.textBetween(i.pos,e.to,void 0," ")}if(i&&s){const e=s.split(ep).filter(Boolean);if(e.length<=0){return false}const n=e[e.length-1];const l=i.pos+s.lastIndexOf(n);if(!n){return false}const u=Xd(n).map((e=>e.toObject(t.defaultProtocol)));if(!ip(u)){return false}u.filter((t=>t.isLink)).map((t=>({...t,from:l+t.start+1,to:l+t.end+1}))).filter((t=>{if(!r.schema.marks.code){return true}return!r.doc.rangeHasMark(t.from,t.to,r.schema.marks.code)})).filter((e=>t.validate(e.value))).filter((e=>t.shouldAutoLink(e.value))).forEach((e=>{if(qa(e.from,e.to,r.doc).some((e=>e.mark.type===t.type))){return}o.addMark(e.from,e.to,t.type.create({href:e.href}))}))}}));if(!o.steps.length){return}return o}})}function op(t){return new Mn({key:new En("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0){return false}if(!e.editable){return false}let o=null;if(r.target instanceof HTMLAnchorElement){o=r.target}else{let t=r.target;const e=[];while(t.nodeName!=="DIV"){e.push(t);t=t.parentNode}o=e.find((t=>t.nodeName==="A"))}if(!o){return false}const l=za(e.state,t.type.name);const u=(i=o==null?void 0:o.href)!=null?i:l.href;const a=(s=o==null?void 0:o.target)!=null?s:l.target;if(t.enableClickSelection){t.editor.commands.extendMarkRange(t.type.name)}if(o&&u){window.open(u,a);return true}return false}}})}function lp(t){return new Mn({key:new En("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t;const{state:s}=e;const{selection:o}=s;const{empty:l}=o;if(l){return false}let u="";r.content.forEach((t=>{u+=t.textContent}));const a=Qd(u,{defaultProtocol:t.defaultProtocol}).find((t=>t.isLink&&t.value===u));if(!u||!a||i!==void 0&&!i(a.href)){return false}return t.editor.commands.setMark(t.type,{href:a.href})}}})}function up(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];if(e){e.forEach((t=>{const e=typeof t==="string"?t:t.scheme;if(e){n.push(e)}}))}return!t||t.replace(rp,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var ap=Pf.create({name:"link",priority:1e3,keepOnSplit:false,exitable:true,onCreate(){if(this.options.validate&&!this.options.shouldAutoLink){this.options.shouldAutoLink=this.options.validate;console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")}this.options.protocols.forEach((t=>{if(typeof t==="string"){Zd(t);return}Zd(t.scheme,t.optionalSlashes)}))},onDestroy(){Gd()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:true,enableClickSelection:false,linkOnPaste:true,autolink:true,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!up(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");if(!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!up(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return null}}]},renderHTML({HTMLAttributes:t}){if(!this.options.isAllowedUri(t.href,{defaultValidate:t=>!!up(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return["a",Aa(this.options.HTMLAttributes,{...t,href:""}),0]}return["a",Aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";const i=e.renderChildren(t);return`[${i}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;if(!this.options.isAllowedUri(n,{defaultValidate:t=>!!up(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return e().setMark(this.name,t).setMeta("preventAutolink",true).run()},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};if(n&&!this.options.isAllowedUri(n,{defaultValidate:t=>!!up(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return e().toggleMark(this.name,t,{extendEmptyMarkRange:true}).setMeta("preventAutolink",true).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:true}).setMeta("preventAutolink",true).run()}},addPasteRules(){return[Mh({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options;const i=Qd(t).filter((t=>t.isLink&&this.options.isAllowedUri(t.value,{defaultValidate:t=>!!up(t,n),protocols:n,defaultProtocol:r})));if(i.length){i.forEach((t=>{if(!this.options.shouldAutoLink(t.value)){return}e.push({text:t.value,data:{href:t.href},index:t.start})}))}}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];const{protocols:e,defaultProtocol:n}=this.options;if(this.options.autolink){t.push(sp({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:t=>this.options.isAllowedUri(t,{defaultValidate:t=>!!up(t,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink}))}if(this.options.openOnClick===true){t.push(op({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection}))}if(this.options.linkOnPaste){t.push(lp({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink}))}return t}});var fp=ap;var hp=Object.defineProperty;var cp=(t,e)=>{for(var n in e)hp(t,n,{get:e[n],enumerable:true})};var dp="listItem";var pp="textStyle";var mp=/^\s*([-+*])\s$/;var gp=xh.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:false,keepAttributes:false}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||t.ordered){return[]}return{type:"bulletList",content:t.items?e.parseChildren(t.items):[]}},renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownOptions:{indentsContent:true},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>{if(this.options.keepAttributes){return e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(dp,this.editor.getAttributes(pp)).run()}return t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ah({find:mp,type:this.type});if(this.options.keepMarks||this.options.keepAttributes){t=ah({find:mp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(pp),editor:this.editor})}return[t]}});var wp=xh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:true,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item"){return[]}let n=[];if(t.tokens&&t.tokens.length>0){const r=t.tokens.some((t=>t.type==="paragraph"));if(r){n=e.parseChildren(t.tokens)}else{const r=t.tokens[0];if(r&&r.type==="text"&&r.tokens&&r.tokens.length>0){const i=e.parseInline(r.tokens);n=[{type:"paragraph",content:i}];if(t.tokens.length>1){const r=t.tokens.slice(1);const i=e.parseChildren(r);n.push(...i)}}else{n=e.parseChildren(t.tokens)}}}if(n.length===0){n=[{type:"paragraph",content:[]}]}return{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>kh(t,e,(t=>{if(t.parentType==="bulletList"){return"- "}if(t.parentType==="orderedList"){return`${t.index+1}. `}return"- "}),n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var bp={};cp(bp,{findListItemPos:()=>vp,getNextListDepth:()=>kp,handleBackspace:()=>Sp,handleDelete:()=>Ap,hasListBefore:()=>yp,hasListItemAfter:()=>Op,hasListItemBefore:()=>xp,listItemHasSubList:()=>Mp,nextListIsDeeper:()=>Tp,nextListIsHigher:()=>Ep});var vp=(t,e)=>{const{$from:n}=e.selection;const r=hu(t,e.schema);let i=null;let s=n.depth;let o=n.pos;let l=null;while(s>0&&l===null){i=n.node(s);if(i.type===r){l=s}else{s-=1;o-=1}}if(l===null){return null}return{$pos:e.doc.resolve(o),depth:l}};var kp=(t,e)=>{const n=vp(t,e);if(!n){return false}const[,r]=Ka(e,t,n.$pos.pos+4);return r};var yp=(t,e,n)=>{const{$anchor:r}=t.selection;const i=Math.max(0,r.pos-2);const s=t.doc.resolve(i).node();if(!s||!n.includes(s.type.name)){return false}return true};var xp=(t,e)=>{var n;const{$anchor:r}=e.selection;const i=e.doc.resolve(r.pos-2);if(i.index()===0){return false}if(((n=i.nodeBefore)==null?void 0:n.type.name)!==t){return false}return true};var Mp=(t,e,n)=>{if(!n){return false}const r=hu(t,e.schema);let i=false;n.descendants((t=>{if(t.type===r){i=true}}));return i};var Sp=(t,e,n)=>{if(t.commands.undoInputRule()){return true}if(t.state.selection.from!==t.state.selection.to){return false}if(!Zu(t.state,e)&&yp(t.state,e,n)){const{$anchor:n}=t.state.selection;const r=t.state.doc.resolve(n.before()-1);const i=[];r.node().descendants(((t,n)=>{if(t.type.name===e){i.push({node:t,pos:n})}}));const s=i.at(-1);if(!s){return false}const o=t.state.doc.resolve(r.start()+s.pos+1);return t.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!Zu(t.state,e)){return false}if(!Xa(t.state)){return false}const r=vp(e,t.state);if(!r){return false}const i=t.state.doc.resolve(r.$pos.pos-2);const s=i.node(r.depth);const o=Mp(e,t.state,s);if(xp(e,t.state)&&!o){return t.commands.joinItemBackward()}return t.chain().liftListItem(e).run()};var Tp=(t,e)=>{const n=kp(t,e);const r=vp(t,e);if(!r||!n){return false}if(n>r.depth){return true}return false};var Ep=(t,e)=>{const n=kp(t,e);const r=vp(t,e);if(!r||!n){return false}if(n<r.depth){return true}return false};var Ap=(t,e)=>{if(!Zu(t.state,e)){return false}if(!Ya(t.state,e)){return false}const{selection:n}=t.state;const{$from:r,$to:i}=n;if(!n.empty&&r.sameParent(i)){return false}if(Tp(e,t.state)){return t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run()}if(Ep(e,t.state)){return t.chain().joinForward().joinBackward().run()}return t.commands.joinItemForward()};var Op=(t,e)=>{var n;const{$anchor:r}=e.selection;const i=e.doc.resolve(r.pos-r.parentOffset-2);if(i.index()===i.parent.childCount-1){return false}if(((n=i.nodeAfter)==null?void 0:n.type.name)!==t){return false}return true};var $p=Kf.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:n})=>{if(t.state.schema.nodes[n]===void 0){return}if(Ap(t,n)){e=true}}));return e},"Mod-Delete":({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:n})=>{if(t.state.schema.nodes[n]===void 0){return}if(Ap(t,n)){e=true}}));return e},Backspace:({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:n,wrapperNames:r})=>{if(t.state.schema.nodes[n]===void 0){return}if(Sp(t,n,r)){e=true}}));return e},"Mod-Backspace":({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:n,wrapperNames:r})=>{if(t.state.schema.nodes[n]===void 0){return}if(Sp(t,n,r)){e=true}}));return e}}}});var Rp=/^(\s*)(\d+)\.\s+(.*)$/;var Cp=/^\s/;function Lp(t){const e=[];let n=0;let r=0;while(n<t.length){const i=t[n];const s=i.match(Rp);if(!s){break}const[,o,l,u]=s;const a=o.length;let f=u;let h=n+1;const c=[i];while(h<t.length){const e=t[h];const n=e.match(Rp);if(n){break}if(e.trim()===""){c.push(e);f+="\n";h+=1}else if(e.match(Cp)){c.push(e);f+=`\n${e.slice(a+2)}`;h+=1}else{break}}e.push({indent:a,number:parseInt(l,10),content:f.trim(),raw:c.join("\n")});r=h;n=h}return[e,r]}function Np(t,e,n){var r;const i=[];let s=0;while(s<t.length){const o=t[s];if(o.indent===e){const l=o.content.split("\n");const u=((r=l[0])==null?void 0:r.trim())||"";const a=[];if(u){a.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)})}const f=l.slice(1).join("\n").trim();if(f){const t=n.blockTokens(f);a.push(...t)}let h=s+1;const c=[];while(h<t.length&&t[h].indent>e){c.push(t[h]);h+=1}if(c.length>0){const t=Math.min(...c.map((t=>t.indent)));const e=Np(c,t,n);a.push({type:"list",ordered:true,start:c[0].number,items:e,raw:c.map((t=>t.raw)).join("\n")})}i.push({type:"list_item",raw:o.raw,tokens:a});s=h}else{s+=1}}return i}function Ip(t,e){return t.map((t=>{if(t.type!=="list_item"){return e.parseChildren([t])[0]}const n=[];if(t.tokens&&t.tokens.length>0){t.tokens.forEach((t=>{if(t.type==="paragraph"||t.type==="list"||t.type==="blockquote"||t.type==="code"){n.push(...e.parseChildren([t]))}else if(t.type==="text"&&t.tokens){const r=e.parseChildren([t]);n.push({type:"paragraph",content:r})}else{const r=e.parseChildren([t]);if(r.length>0){n.push(...r)}}}))}return{type:"listItem",content:n}}))}var Pp="listItem";var Dp="textStyle";var Hp=/^(\d+)\.\s$/;var _p=xh.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:false,keepAttributes:false}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Aa(this.options.HTMLAttributes,n),0]:["ol",Aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered){return[]}const n=t.start||1;const r=t.items?Ip(t.items,e):[];if(n!==1){return{type:"orderedList",attrs:{start:n},content:r}}return{type:"orderedList",content:r}},renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/);const n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split("\n");const[s,o]=Lp(i);if(s.length===0){return void 0}const l=Np(s,0,n);if(l.length===0){return void 0}const u=((r=s[0])==null?void 0:r.number)||1;return{type:"list",ordered:true,start:u,items:l,raw:i.slice(0,o).join("\n")}}},markdownOptions:{indentsContent:true},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>{if(this.options.keepAttributes){return e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Pp,this.editor.getAttributes(Dp)).run()}return t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ah({find:Hp,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});if(this.options.keepMarks||this.options.keepAttributes){t=ah({find:Hp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Dp)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})}return[t]}});var jp=/^\s*(\[([( |x])?\])\s$/;var zp=xh.create({name:"taskItem",addOptions(){return{nested:false,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:true,addAttributes(){return{checked:{default:false,keepOnSplit:false,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Aa(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0){n.push(e.createNode("paragraph",{},e.parseInline(t.tokens)))}else if(t.text){n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})]))}else{n.push(e.createNode("paragraph",{},[]))}if(t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||false},n)},renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.checked)?"x":" ";const i=`- [${r}] `;return kh(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};if(!this.options.nested){return t}return{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li");const s=document.createElement("label");const o=document.createElement("span");const l=document.createElement("input");const u=document.createElement("div");const a=t=>{var e,n;l.ariaLabel=((n=(e=this.options.a11y)==null?void 0:e.checkboxLabel)==null?void 0:n.call(e,t,l.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};a(t);s.contentEditable="false";l.type="checkbox";l.addEventListener("mousedown",(t=>t.preventDefault()));l.addEventListener("change",(e=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:i}=e.target;if(r.isEditable&&typeof n==="function"){r.chain().focus(void 0,{scrollIntoView:false}).command((({tr:t})=>{const e=n();if(typeof e!=="number"){return false}const r=t.doc.nodeAt(e);t.setNodeMarkup(e,void 0,{...r==null?void 0:r.attrs,checked:i});return true})).run()}if(!r.isEditable&&this.options.onReadOnlyChecked){if(!this.options.onReadOnlyChecked(t,i)){l.checked=!l.checked}}}));Object.entries(this.options.HTMLAttributes).forEach((([t,e])=>{i.setAttribute(t,e)}));i.dataset.checked=t.attrs.checked;l.checked=t.attrs.checked;s.append(l,o);i.append(s,u);Object.entries(e).forEach((([t,e])=>{i.setAttribute(t,e)}));return{dom:i,contentDOM:u,update:t=>{if(t.type!==this.type){return false}i.dataset.checked=t.attrs.checked;l.checked=t.attrs.checked;a(t);return true}}}},addInputRules(){return[ah({find:jp,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}});var Bp=xh.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Aa(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=t=>{const e=vh(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:t[3].toLowerCase()==="x"}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:r},n);if(e){return[{type:"taskList",raw:e.raw,items:e.items}]}return n.blockTokens(t)};const i=vh(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:t[3].toLowerCase()==="x"}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:r},n);if(!i){return void 0}return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:true},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Kf.create({name:"listKit",addExtensions(){const t=[];if(this.options.bulletList!==false){t.push(gp.configure(this.options.bulletList))}if(this.options.listItem!==false){t.push(wp.configure(this.options.listItem))}if(this.options.listKeymap!==false){t.push($p.configure(this.options.listKeymap))}if(this.options.orderedList!==false){t.push(_p.configure(this.options.orderedList))}if(this.options.taskItem!==false){t.push(zp.configure(this.options.taskItem))}if(this.options.taskList!==false){t.push(Bp.configure(this.options.taskList))}return t}});var Fp=xh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Aa(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image"){return e.parseChildren([n[0]])}return e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>{if(!t||!Array.isArray(t.content)){return""}return e.renderChildren(t.content)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Up=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/;var qp=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g;var Kp=Pf.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:false,getAttrs:t=>t.includes("line-through")?{}:false}]},renderHTML({HTMLAttributes:t}){return["s",Aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[oh({find:Up,type:this.type})]},addPasteRules(){return[Mh({find:qp,type:this.type})]}});var Jp=xh.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var Wp=Pf.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:false,getAttrs:t=>t.includes("underline")?{}:false}]},renderHTML({HTMLAttributes:t}){return["u",Aa(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/;const i=r.exec(t);if(!i){return void 0}const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Vp(t={}){return new Mn({view(e){return new Gp(e,t)}})}class Gp{constructor(t,e){var n;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(n=e.width)!==null&&n!==void 0?n:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let n=t=>{this[e](t)};t.dom.addEventListener(e,n);return{name:e,handler:n}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,n;let r=this.editorView.dom,i=r.getBoundingClientRect();let s=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(e){let e=t.nodeBefore,r=t.nodeAfter;if(e||r){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let i=t.getBoundingClientRect();let s=e?i.bottom:i.top;if(e&&r)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;let l=this.width/2*o;n={left:i.left,right:i.right,top:s-l,bottom:s+l}}}}if(!n){let t=this.editorView.coordsAtPos(this.cursorPos);let e=this.width/2*s;n={left:t.left-e,right:t.left+e,top:t.top,bottom:t.bottom}}let l=this.editorView.dom.offsetParent;if(!this.element){this.element=l.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let u,a;if(!l||l==document.body&&getComputedStyle(l).position=="static"){u=-pageXOffset;a=-pageYOffset}else{let t=l.getBoundingClientRect();let e=t.width/l.offsetWidth,n=t.height/l.offsetHeight;u=t.left-l.scrollLeft*e;a=t.top-l.scrollTop*n}this.element.style.left=(n.left-u)/s+"px";this.element.style.top=(n.top-a)/o+"px";this.element.style.width=(n.right-n.left)/s+"px";this.element.style.height=(n.bottom-n.top)/o+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let r=n&&n.type.spec.disableDropCursor;let i=typeof r=="function"?r(this.editorView,e,t):r;if(e&&!i){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Ne(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class Zp extends tn{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return Zp.valid(n)?new Zp(n):tn.near(n)}content(){return T.empty}eq(t){return t instanceof Zp&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Zp(t.resolve(e.pos))}getBookmark(){return new Yp(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!Xp(t)||!Qp(t))return false;let n=e.type.spec.allowGapCursor;if(n!=null)return n;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,n=false){t:for(;;){if(!n&&Zp.valid(t))return t;let r=t.pos,i=null;for(let n=t.depth;;n--){let s=t.node(n);if(e>0?t.indexAfter(n)<s.childCount:t.index(n)>0){i=s.child(e>0?t.indexAfter(n):t.index(n)-1);break}else if(n==0){return null}r+=e;let o=t.doc.resolve(r);if(Zp.valid(o))return o}for(;;){let s=e>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!ln.isSelectable(i)){t=t.doc.resolve(r+i.nodeSize*e);n=false;continue t}break}i=s;r+=e;let o=t.doc.resolve(r);if(Zp.valid(o))return o}return null}}}Zp.prototype.visible=false;Zp.findFrom=Zp.findGapCursorFrom;tn.jsonID("gapcursor",Zp);class Yp{constructor(t){this.pos=t}map(t){return new Yp(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Zp.valid(e)?new Zp(e):tn.near(e)}}function Xp(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return true;continue}for(let t=r.child(n-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Qp(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return true;continue}for(let t=r.child(n);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function tm(){return new Mn({props:{decorations:sm,createSelectionBetween(t,e,n){return e.pos==n.pos&&Zp.valid(n)?new Zp(n):null},handleClick:rm,handleKeyDown:em,handleDOMEvents:{beforeinput:im}}})}const em=Xl({ArrowLeft:nm("horiz",-1),ArrowRight:nm("horiz",1),ArrowUp:nm("vert",-1),ArrowDown:nm("vert",1)});function nm(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,r,i){let s=t.selection;let o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof sn){if(!i.endOfTextblock(n)||o.depth==0)return false;l=false;o=t.doc.resolve(e>0?o.after():o.before())}let u=Zp.findGapCursorFrom(o,e,l);if(!u)return false;if(r)r(t.tr.setSelection(new Zp(u)));return true}}function rm(t,e,n){if(!t||!t.editable)return false;let r=t.state.doc.resolve(e);if(!Zp.valid(r))return false;let i=t.posAtCoords({left:n.clientX,top:n.clientY});if(i&&i.inside>-1&&ln.isSelectable(t.state.doc.nodeAt(i.inside)))return false;t.dispatch(t.state.tr.setSelection(new Zp(r)));return true}function im(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Zp))return false;let{$from:n}=t.state.selection;let r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return false;let i=v.empty;for(let t=r.length-1;t>=0;t--)i=v.from(r[t].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new T(i,0,0));s.setSelection(sn.near(s.doc.resolve(n.pos+1)));t.dispatch(s);return false}function sm(t){if(!(t.selection instanceof Zp))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return Xo.create(t.doc,[Go.widget(t.selection.head,e,{key:"gapcursor"})])}var om=200;var lm=function t(){};lm.prototype.append=function t(e){if(!e.length){return this}e=lm.from(e);return!this.length&&e||e.length<om&&this.leafAppend(e)||this.length<om&&e.leafPrepend(this)||this.appendInner(e)};lm.prototype.prepend=function t(e){if(!e.length){return this}return lm.from(e).append(this)};lm.prototype.appendInner=function t(e){return new am(this,e)};lm.prototype.slice=function t(e,n){if(e===void 0)e=0;if(n===void 0)n=this.length;if(e>=n){return lm.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,n))};lm.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};lm.prototype.forEach=function t(e,n,r){if(n===void 0)n=0;if(r===void 0)r=this.length;if(n<=r){this.forEachInner(e,n,r,0)}else{this.forEachInvertedInner(e,n,r,0)}};lm.prototype.map=function t(e,n,r){if(n===void 0)n=0;if(r===void 0)r=this.length;var i=[];this.forEach((function(t,n){return i.push(e(t,n))}),n,r);return i};lm.from=function t(e){if(e instanceof lm){return e}return e&&e.length?new um(e):lm.empty};var um=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var n={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(n,r){if(n==0&&r==this.length){return this}return new e(this.values.slice(n,r))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,n,r,i){for(var s=n;s<r;s++){if(e(this.values[s],i+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,n,r,i){for(var s=n-1;s>=r;s--){if(e(this.values[s],i+s)===false){return false}}};e.prototype.leafAppend=function t(n){if(this.length+n.length<=om){return new e(this.values.concat(n.flatten()))}};e.prototype.leafPrepend=function t(n){if(this.length+n.length<=om){return new e(n.flatten().concat(this.values))}};n.length.get=function(){return this.values.length};n.depth.get=function(){return 0};Object.defineProperties(e.prototype,n);return e}(lm);lm.empty=new um([]);var am=function(t){function e(e,n){t.call(this);this.left=e;this.right=n;this.length=e.length+n.length;this.depth=Math.max(e.depth,n.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,n,r,i){var s=this.left.length;if(n<s&&this.left.forEachInner(e,n,Math.min(r,s),i)===false){return false}if(r>s&&this.right.forEachInner(e,Math.max(n-s,0),Math.min(this.length,r)-s,i+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,n,r,i){var s=this.left.length;if(n>s&&this.right.forEachInvertedInner(e,n-s,Math.max(r,s)-s,i+s)===false){return false}if(r<s&&this.left.forEachInvertedInner(e,Math.min(n,s),r,i)===false){return false}};e.prototype.sliceInner=function t(e,n){if(e==0&&n==this.length){return this}var r=this.left.length;if(n<=r){return this.left.slice(e,n)}if(e>=r){return this.right.slice(e-r,n-r)}return this.left.slice(e,r).append(this.right.slice(0,n-r))};e.prototype.leafAppend=function t(n){var r=this.right.leafAppend(n);if(r){return new e(this.left,r)}};e.prototype.leafPrepend=function t(n){var r=this.left.leafPrepend(n);if(r){return new e(r,this.right)}};e.prototype.appendInner=function t(n){if(this.left.depth>=Math.max(this.right.depth,n.depth)+1){return new e(this.left,new e(this.right,n))}return new e(this,n)};return e}(lm);const fm=500;class hm{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--){let t=this.items.get(n-1);if(t.selection){--n;break}}let r,i;if(e){r=this.remapping(n,this.items.length);i=r.maps.length}let s=t.tr;let o,l;let u=[],a=[];this.items.forEach(((t,e)=>{if(!t.step){if(!r){r=this.remapping(n,e+1);i=r.maps.length}i--;a.push(t);return}if(r){a.push(new dm(t.map));let e=t.step.map(r.slice(i)),n;if(e&&s.maybeStep(e).doc){n=s.mapping.maps[s.mapping.maps.length-1];u.push(new dm(n,undefined,undefined,u.length+a.length))}i--;if(n)r.appendMap(n,i)}else{s.maybeStep(t.step)}if(t.selection){o=r?t.selection.map(r.slice(i)):t.selection;l=new hm(this.items.slice(0,n).append(a.reverse().concat(u)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:l,transform:s,selection:o}}addTransform(t,e,n,r){let i=[],s=this.eventCount;let o=this.items,l=!r&&o.length?o.get(o.length-1):null;for(let n=0;n<t.steps.length;n++){let u=t.steps[n].invert(t.docs[n]);let a=new dm(t.mapping.maps[n],u,e),f;if(f=l&&l.merge(a)){a=f;if(n)i.pop();else o=o.slice(0,o.length-1)}i.push(a);if(e){s++;e=undefined}if(!r)l=a}let u=s-n.depth;if(u>mm){o=cm(o,u);s-=u}return new hm(o.append(i),s)}remapping(t,e){let n=new Yt;this.items.forEach(((e,r)=>{let i=e.mirrorOffset!=null&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:undefined;n.appendMap(e.map,i)}),t,e);return n}addMaps(t){if(this.eventCount==0)return this;return new hm(this.items.append(t.map((t=>new dm(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-e);let i=t.mapping;let s=t.steps.length;let o=this.eventCount;this.items.forEach((t=>{if(t.selection)o--}),r);let l=e;this.items.forEach((e=>{let r=i.getMirror(--l);if(r==null)return;s=Math.min(s,r);let u=i.maps[r];if(e.step){let s=t.steps[r].invert(t.docs[r]);let a=e.selection&&e.selection.map(i.slice(l+1,r));if(a)o++;n.push(new dm(u,s,a))}else{n.push(new dm(u))}}),r);let u=[];for(let t=e;t<s;t++)u.push(new dm(i.maps[t]));let a=this.items.slice(0,r).append(u).append(n);let f=new hm(a,o);if(f.emptyItemCount()>fm)f=f.compress(this.items.length-n.length);return f}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length;let r=[],i=0;this.items.forEach(((s,o)=>{if(o>=t){r.push(s);if(s.selection)i++}else if(s.step){let t=s.step.map(e.slice(n)),o=t&&t.getMap();n--;if(o)e.appendMap(o,n);if(t){let l=s.selection&&s.selection.map(e.slice(n));if(l)i++;let u=new dm(o.invert(),t,l),a,f=r.length-1;if(a=r.length&&r[f].merge(u))r[f]=a;else r.push(u)}}else if(s.map){n--}}),this.items.length,0);return new hm(lm.from(r.reverse()),i)}}hm.empty=new hm(lm.empty,0);function cm(t,e){let n;t.forEach(((t,r)=>{if(t.selection&&e--==0){n=r;return false}}));return t.slice(n)}class dm{constructor(t,e,n,r){this.map=t;this.step=e;this.selection=n;this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new dm(e.getMap().invert(),e,this.selection)}}}class pm{constructor(t,e,n,r,i){this.done=t;this.undone=e;this.prevRanges=n;this.prevTime=r;this.prevComposition=i}}const mm=20;function gm(t,e,n,r){let i=n.getMeta(Sm),s;if(i)return i.historyState;if(n.getMeta(Tm))t=new pm(t.done,t.undone,null,0,-1);let o=n.getMeta("appendedTransaction");if(n.steps.length==0){return t}else if(o&&o.getMeta(Sm)){if(o.getMeta(Sm).redo)return new pm(t.done.addTransform(n,undefined,r,Mm(e)),t.undone,bm(n.mapping.maps),t.prevTime,t.prevComposition);else return new pm(t.done,t.undone.addTransform(n,undefined,r,Mm(e)),null,t.prevTime,t.prevComposition)}else if(n.getMeta("addToHistory")!==false&&!(o&&o.getMeta("addToHistory")===false)){let i=n.getMeta("composition");let s=t.prevTime==0||!o&&t.prevComposition!=i&&(t.prevTime<(n.time||0)-r.newGroupDelay||!wm(n,t.prevRanges));let l=o?vm(t.prevRanges,n.mapping):bm(n.mapping.maps);return new pm(t.done.addTransform(n,s?e.selection.getBookmark():undefined,r,Mm(e)),hm.empty,l,n.time,i==null?t.prevComposition:i)}else if(s=n.getMeta("rebased")){return new pm(t.done.rebased(n,s),t.undone.rebased(n,s),vm(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}else{return new pm(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vm(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}}function wm(t,e){if(!e)return false;if(!t.docChanged)return true;let n=false;t.mapping.maps[0].forEach(((t,r)=>{for(let i=0;i<e.length;i+=2)if(t<=e[i+1]&&r>=e[i])n=true}));return n}function bm(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach(((t,n,r,i)=>e.push(r,i)));return e}function vm(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);if(i<=s)n.push(i,s)}return n}function km(t,e,n){let r=Mm(e);let i=Sm.get(e).spec.config;let s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc);let l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r);let u=new pm(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Sm,{redo:n,historyState:u})}let ym=false,xm=null;function Mm(t){let e=t.plugins;if(xm!=e){ym=false;xm=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){ym=true;break}}return ym}const Sm=new En("history");const Tm=new En("closeHistory");function Em(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new Mn({key:Sm,state:{init(){return new pm(hm.empty,hm.empty,null,0,-1)},apply(e,n,r){return gm(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType;let r=n=="historyUndo"?Om:n=="historyRedo"?$m:null;if(!r)return false;e.preventDefault();return r(t.state,t.dispatch)}}}})}function Am(t,e){return(n,r)=>{let i=Sm.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return false;if(r){let s=km(i,n,t);if(s)r(e?s.scrollIntoView():s)}return true}}const Om=Am(false,true);const $m=Am(true,true);Kf.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter((t=>t!=="")).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;const n=(t==null?void 0:t.mode)||this.options.mode;if(n==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize};this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;const n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=false;return[new Mn({key:new En("characterCount"),appendTransaction:(e,n,r)=>{if(t){return}const i=this.options.limit;if(i===null||i===void 0||i===0){t=true;return}const s=this.storage.characters({node:r.doc});if(s>i){const e=s-i;const n=0;const o=e;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const l=r.tr.deleteRange(n,o);t=true;return l}t=true},filterTransaction:(t,e)=>{const n=this.options.limit;if(!t.docChanged||n===0||n===null||n===void 0){return true}const r=this.storage.characters({node:e.doc});const i=this.storage.characters({node:t.doc});if(i<=n){return true}if(r>n&&i>n&&i<=r){return true}if(r>n&&i>n&&i>r){return false}const s=t.getMeta("paste");if(!s){return false}const o=t.selection.$head.pos;const l=i-n;const u=o-l;const a=o;t.deleteRange(u,a);const f=this.storage.characters({node:t.doc});if(f>n){return false}return true}})]}});var Rm=Kf.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Vp(this.options)]}});Kf.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Mn({key:new En("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor;const{anchor:i}=e;const s=[];if(!n||!r){return Xo.create(t,[])}let o=0;if(this.options.mode==="deepest"){t.descendants(((t,e)=>{if(t.isText){return}const n=i>=e&&i<=e+t.nodeSize-1;if(!n){return false}o+=1}))}let l=0;t.descendants(((t,e)=>{if(t.isText){return false}const n=i>=e&&i<=e+t.nodeSize-1;if(!n){return false}l+=1;const r=this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1;if(r){return this.options.mode==="deepest"}s.push(Go.node(e,e+t.nodeSize,{class:this.options.className}))}));return Xo.create(t,s)}}})]}});var Cm=Kf.create({name:"gapCursor",addProseMirrorPlugins(){return[tm()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ma(va(t,"allowGapCursor",n)))!=null?e:null}}});Kf.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:true,showOnlyCurrent:true,includeChildren:false}},addProseMirrorPlugins(){return[new Mn({key:new En("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable;const{anchor:r}=e;const i=[];if(!n){return null}const s=this.editor.isEmpty;t.descendants(((t,e)=>{const n=r>=e&&r<=e+t.nodeSize;const o=!t.isLeaf&&ef(t);if((n||!this.options.showOnlyCurrent)&&o){const r=[this.options.emptyNodeClass];if(s){r.push(this.options.emptyEditorClass)}const o=Go.node(e,e+t.nodeSize,{class:r.join(" "),"data-placeholder":typeof this.options.placeholder==="function"?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});i.push(o)}return this.options.includeChildren}));return Xo.create(t,i)}}})]}});Kf.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Mn({key:new En("selection"),props:{decorations(n){if(n.selection.empty||t.isFocused||!t.isEditable||nf(n.selection)||t.view.dragging){return null}return Xo.create(n.doc,[Go.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Lm({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var Nm=Kf.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new En(this.name);const n=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph";const r=Object.entries(this.editor.schema.nodes).map((([,t])=>t)).filter((t=>(this.options.notAfter||[]).concat(n).includes(t.name)));return[new Mn({key:e,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i;const u=e.getState(i);const a=s.content.size;const f=l.nodes[n];if(!u){return}return o.insert(a,f.create())},state:{init:(t,e)=>{const n=e.tr.doc.lastChild;return!Lm({node:n,types:r})},apply:(t,e)=>{if(!t.docChanged){return e}const n=t.doc.lastChild;return!Lm({node:n,types:r})}}})]}});var Im=Kf.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Om(t,e),redo:()=>({state:t,dispatch:e})=>$m(t,e)}},addProseMirrorPlugins(){return[Em(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});var Pm=Kf.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];if(this.options.bold!==false){i.push(Ch.configure(this.options.bold))}if(this.options.blockquote!==false){i.push(Eh.configure(this.options.blockquote))}if(this.options.bulletList!==false){i.push(gp.configure(this.options.bulletList))}if(this.options.code!==false){i.push(Ih.configure(this.options.code))}if(this.options.codeBlock!==false){i.push(_h.configure(this.options.codeBlock))}if(this.options.document!==false){i.push(jh.configure(this.options.document))}if(this.options.dropcursor!==false){i.push(Rm.configure(this.options.dropcursor))}if(this.options.gapcursor!==false){i.push(Cm.configure(this.options.gapcursor))}if(this.options.hardBreak!==false){i.push(zh.configure(this.options.hardBreak))}if(this.options.heading!==false){i.push(Bh.configure(this.options.heading))}if(this.options.undoRedo!==false){i.push(Im.configure(this.options.undoRedo))}if(this.options.horizontalRule!==false){i.push(Fh.configure(this.options.horizontalRule))}if(this.options.italic!==false){i.push(Wh.configure(this.options.italic))}if(this.options.listItem!==false){i.push(wp.configure(this.options.listItem))}if(this.options.listKeymap!==false){i.push($p.configure((t=this.options)==null?void 0:t.listKeymap))}if(this.options.link!==false){i.push(ap.configure((e=this.options)==null?void 0:e.link))}if(this.options.orderedList!==false){i.push(_p.configure(this.options.orderedList))}if(this.options.paragraph!==false){i.push(Fp.configure(this.options.paragraph))}if(this.options.strike!==false){i.push(Kp.configure(this.options.strike))}if(this.options.text!==false){i.push(Jp.configure(this.options.text))}if(this.options.underline!==false){i.push(Wp.configure((n=this.options)==null?void 0:n.underline))}if(this.options.trailingNode!==false){i.push(Nm.configure((r=this.options)==null?void 0:r.trailingNode))}return i}});var Dm=Pm;var Hm=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;var _m=xh.create({name:"image",addOptions(){return{inline:false,allowBase64:false,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:true,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Aa(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,s,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"";const u=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"";const a=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return a?`![${u}](${l} "${a}")`:`![${u}](${l})`},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[lh({find:Hm,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var jm=_m;const zm=t=>jm.extend({addNodeView(){return({HTMLAttributes:e})=>{const n=document.createElement("pos-image");const r=new URL(e.src,t);n.setAttribute("src",r.toString());let i=["alt","title"];for(const t of i){if(e[t]){n.setAttribute(t,e[t])}}return{dom:n,ignoreMutation:()=>true}}}});const Bm=t=>fp.extend({addMarkView(){return({HTMLAttributes:e})=>{const n=document.createElement("pos-rich-link");const r=new URL(e.href,t);n.setAttribute("uri",r.toString());return{dom:n,contentDOM:n,ignoreMutation:()=>true}}}});class Fm{constructor(t,e,n){this.modified=false;this.editingJustChanged=false;this.modifications=new l;this.editor=new sh({element:t,extensions:[Dm.configure({link:false}),zm(n),Bm(n)],content:e.value,editable:false});this.editor.on("update",(()=>{if(this.editingJustChanged){this.editingJustChanged=false;return}this.modified=true;this.modifications.next({content:this.editor.getHTML()})}))}onUpdate(t){this.editor.on("update",t)}isEditable(){return this.editor.isEditable}startEditing(){this.editingJustChanged=true;this.editor.setEditable(true);this.editor.commands.focus()}stopEditing(){this.editingJustChanged=true;this.editor.setEditable(false)}isModified(){return this.modified}getContent(){return this.editor.getHTML()}observeChanges(t=1e3){return this.modifications.pipe(u(t),h((()=>this.modified=false)))}}function Um(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n){if(n.hasOwnProperty(r))t[r]=n[r]}}return t}function qm(t,e){return Array(e+1).join(t)}function Km(t){return t.replace(/^\n*/,"")}function Jm(t){var e=t.length;while(e>0&&t[e-1]==="\n")e--;return t.substring(0,e)}var Wm=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function Vm(t){return eg(t,Wm)}var Gm=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function Zm(t){return eg(t,Gm)}function Ym(t){return ng(t,Gm)}var Xm=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function Qm(t){return eg(t,Xm)}function tg(t){return ng(t,Xm)}function eg(t,e){return e.indexOf(t.nodeName)>=0}function ng(t,e){return t.getElementsByTagName&&e.some((function(e){return t.getElementsByTagName(e).length}))}var rg={};rg.paragraph={filter:"p",replacement:function(t){return"\n\n"+t+"\n\n"}};rg.lineBreak={filter:"br",replacement:function(t,e,n){return n.br+"\n"}};rg.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(t,e,n){var r=Number(e.nodeName.charAt(1));if(n.headingStyle==="setext"&&r<3){var i=qm(r===1?"=":"-",t.length);return"\n\n"+t+"\n"+i+"\n\n"}else{return"\n\n"+qm("#",r)+" "+t+"\n\n"}}};rg.blockquote={filter:"blockquote",replacement:function(t){t=t.replace(/^\n+|\n+$/g,"");t=t.replace(/^/gm,"> ");return"\n\n"+t+"\n\n"}};rg.list={filter:["ul","ol"],replacement:function(t,e){var n=e.parentNode;if(n.nodeName==="LI"&&n.lastElementChild===e){return"\n"+t}else{return"\n\n"+t+"\n\n"}}};rg.listItem={filter:"li",replacement:function(t,e,n){var r=n.bulletListMarker+" ";var i=e.parentNode;if(i.nodeName==="OL"){var s=i.getAttribute("start");var o=Array.prototype.indexOf.call(i.children,e);r=(s?Number(s)+o:o+1)+". "}t=t.replace(/^\n+/,"").replace(/\n+$/,"\n").replace(/\n/gm,"\n"+" ".repeat(r.length));return r+t+(e.nextSibling&&!/\n$/.test(t)?"\n":"")}};rg.indentedCodeBlock={filter:function(t,e){return e.codeBlockStyle==="indented"&&t.nodeName==="PRE"&&t.firstChild&&t.firstChild.nodeName==="CODE"},replacement:function(t,e,n){return"\n\n "+e.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}};rg.fencedCodeBlock={filter:function(t,e){return e.codeBlockStyle==="fenced"&&t.nodeName==="PRE"&&t.firstChild&&t.firstChild.nodeName==="CODE"},replacement:function(t,e,n){var r=e.firstChild.getAttribute("class")||"";var i=(r.match(/language-(\S+)/)||[null,""])[1];var s=e.firstChild.textContent;var o=n.fence.charAt(0);var l=3;var u=new RegExp("^"+o+"{3,}","gm");var a;while(a=u.exec(s)){if(a[0].length>=l){l=a[0].length+1}}var f=qm(o,l);return"\n\n"+f+i+"\n"+s.replace(/\n$/,"")+"\n"+f+"\n\n"}};rg.horizontalRule={filter:"hr",replacement:function(t,e,n){return"\n\n"+n.hr+"\n\n"}};rg.inlineLink={filter:function(t,e){return e.linkStyle==="inlined"&&t.nodeName==="A"&&t.getAttribute("href")},replacement:function(t,e){var n=e.getAttribute("href");if(n)n=n.replace(/([()])/g,"\\$1");var r=ig(e.getAttribute("title"));if(r)r=' "'+r.replace(/"/g,'\\"')+'"';return"["+t+"]("+n+r+")"}};rg.referenceLink={filter:function(t,e){return e.linkStyle==="referenced"&&t.nodeName==="A"&&t.getAttribute("href")},replacement:function(t,e,n){var r=e.getAttribute("href");var i=ig(e.getAttribute("title"));if(i)i=' "'+i+'"';var s;var o;switch(n.linkReferenceStyle){case"collapsed":s="["+t+"][]";o="["+t+"]: "+r+i;break;case"shortcut":s="["+t+"]";o="["+t+"]: "+r+i;break;default:var l=this.references.length+1;s="["+t+"]["+l+"]";o="["+l+"]: "+r+i}this.references.push(o);return s},references:[],append:function(t){var e="";if(this.references.length){e="\n\n"+this.references.join("\n")+"\n\n";this.references=[]}return e}};rg.emphasis={filter:["em","i"],replacement:function(t,e,n){if(!t.trim())return"";return n.emDelimiter+t+n.emDelimiter}};rg.strong={filter:["strong","b"],replacement:function(t,e,n){if(!t.trim())return"";return n.strongDelimiter+t+n.strongDelimiter}};rg.code={filter:function(t){var e=t.previousSibling||t.nextSibling;var n=t.parentNode.nodeName==="PRE"&&!e;return t.nodeName==="CODE"&&!n},replacement:function(t){if(!t)return"";t=t.replace(/\r?\n|\r/g," ");var e=/^`|^ .*?[^ ].* $|`$/.test(t)?" ":"";var n="`";var r=t.match(/`+/gm)||[];while(r.indexOf(n)!==-1)n=n+"`";return n+e+t+e+n}};rg.image={filter:"img",replacement:function(t,e){var n=ig(e.getAttribute("alt"));var r=e.getAttribute("src")||"";var i=ig(e.getAttribute("title"));var s=i?' "'+i+'"':"";return r?"!["+n+"]"+"("+r+s+")":""}};function ig(t){return t?t.replace(/(\n+\s*)+/g,"\n"):""}function sg(t){this.options=t;this._keep=[];this._remove=[];this.blankRule={replacement:t.blankReplacement};this.keepReplacement=t.keepReplacement;this.defaultRule={replacement:t.defaultReplacement};this.array=[];for(var e in t.rules)this.array.push(t.rules[e])}sg.prototype={add:function(t,e){this.array.unshift(e)},keep:function(t){this._keep.unshift({filter:t,replacement:this.keepReplacement})},remove:function(t){this._remove.unshift({filter:t,replacement:function(){return""}})},forNode:function(t){if(t.isBlank)return this.blankRule;var e;if(e=og(this.array,t,this.options))return e;if(e=og(this._keep,t,this.options))return e;if(e=og(this._remove,t,this.options))return e;return this.defaultRule},forEach:function(t){for(var e=0;e<this.array.length;e++)t(this.array[e],e)}};function og(t,e,n){for(var r=0;r<t.length;r++){var i=t[r];if(lg(i,e,n))return i}return void 0}function lg(t,e,n){var r=t.filter;if(typeof r==="string"){if(r===e.nodeName.toLowerCase())return true}else if(Array.isArray(r)){if(r.indexOf(e.nodeName.toLowerCase())>-1)return true}else if(typeof r==="function"){if(r.call(t,e,n))return true}else{throw new TypeError("`filter` needs to be a string, array, or function")}}function ug(t){var e=t.element;var n=t.isBlock;var r=t.isVoid;var i=t.isPre||function(t){return t.nodeName==="PRE"};if(!e.firstChild||i(e))return;var s=null;var o=false;var l=null;var u=fg(l,e,i);while(u!==e){if(u.nodeType===3||u.nodeType===4){var a=u.data.replace(/[ \r\n\t]+/g," ");if((!s||/ $/.test(s.data))&&!o&&a[0]===" "){a=a.substr(1)}if(!a){u=ag(u);continue}u.data=a;s=u}else if(u.nodeType===1){if(n(u)||u.nodeName==="BR"){if(s){s.data=s.data.replace(/ $/,"")}s=null;o=false}else if(r(u)||i(u)){s=null;o=true}else if(s){o=false}}else{u=ag(u);continue}var f=fg(l,u,i);l=u;u=f}if(s){s.data=s.data.replace(/ $/,"");if(!s.data){ag(s)}}}function ag(t){var e=t.nextSibling||t.parentNode;t.parentNode.removeChild(t);return e}function fg(t,e,n){if(t&&t.parentNode===e||n(e)){return e.nextSibling||e.parentNode}return e.firstChild||e.nextSibling||e.parentNode}var hg=typeof window!=="undefined"?window:{};function cg(){var t=hg.DOMParser;var e=false;try{if((new t).parseFromString("","text/html")){e=true}}catch(t){}return e}function dg(){var t=function(){};{if(pg()){t.prototype.parseFromString=function(t){var e=new window.ActiveXObject("htmlfile");e.designMode="on";e.open();e.write(t);e.close();return e}}else{t.prototype.parseFromString=function(t){var e=document.implementation.createHTMLDocument("");e.open();e.write(t);e.close();return e}}}return t}function pg(){var t=false;try{document.implementation.createHTMLDocument("").open()}catch(e){if(hg.ActiveXObject)t=true}return t}var mg=cg()?hg.DOMParser:dg();function gg(t,e){var n;if(typeof t==="string"){var r=bg().parseFromString('<x-turndown id="turndown-root">'+t+"</x-turndown>","text/html");n=r.getElementById("turndown-root")}else{n=t.cloneNode(true)}ug({element:n,isBlock:Vm,isVoid:Zm,isPre:e.preformattedCode?vg:null});return n}var wg;function bg(){wg=wg||new mg;return wg}function vg(t){return t.nodeName==="PRE"||t.nodeName==="CODE"}function kg(t,e){t.isBlock=Vm(t);t.isCode=t.nodeName==="CODE"||t.parentNode.isCode;t.isBlank=yg(t);t.flankingWhitespace=xg(t,e);return t}function yg(t){return!Zm(t)&&!Qm(t)&&/^\s*$/i.test(t.textContent)&&!Ym(t)&&!tg(t)}function xg(t,e){if(t.isBlock||e.preformattedCode&&t.isCode){return{leading:"",trailing:""}}var n=Mg(t.textContent);if(n.leadingAscii&&Sg("left",t,e)){n.leading=n.leadingNonAscii}if(n.trailingAscii&&Sg("right",t,e)){n.trailing=n.trailingNonAscii}return{leading:n.leading,trailing:n.trailing}}function Mg(t){var e=t.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:e[1],leadingAscii:e[2],leadingNonAscii:e[3],trailing:e[4],trailingNonAscii:e[5],trailingAscii:e[6]}}function Sg(t,e,n){var r;var i;var s;if(t==="left"){r=e.previousSibling;i=/ $/}else{r=e.nextSibling;i=/^ /}if(r){if(r.nodeType===3){s=i.test(r.nodeValue)}else if(n.preformattedCode&&r.nodeName==="CODE"){s=false}else if(r.nodeType===1&&!Vm(r)){s=i.test(r.textContent)}}return s}var Tg=Array.prototype.reduce;var Eg=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function Ag(t){if(!(this instanceof Ag))return new Ag(t);var e={rules:rg,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:false,blankReplacement:function(t,e){return e.isBlock?"\n\n":""},keepReplacement:function(t,e){return e.isBlock?"\n\n"+e.outerHTML+"\n\n":e.outerHTML},defaultReplacement:function(t,e){return e.isBlock?"\n\n"+t+"\n\n":t}};this.options=Um({},e,t);this.rules=new sg(this.options)}Ag.prototype={turndown:function(t){if(!Lg(t)){throw new TypeError(t+" is not a string, or an element/document/fragment node.")}if(t==="")return"";var e=Og.call(this,new gg(t,this.options));return $g.call(this,e)},use:function(t){if(Array.isArray(t)){for(var e=0;e<t.length;e++)this.use(t[e])}else if(typeof t==="function"){t(this)}else{throw new TypeError("plugin must be a Function or an Array of Functions")}return this},addRule:function(t,e){this.rules.add(t,e);return this},keep:function(t){this.rules.keep(t);return this},remove:function(t){this.rules.remove(t);return this},escape:function(t){return Eg.reduce((function(t,e){return t.replace(e[0],e[1])}),t)}};function Og(t){var e=this;return Tg.call(t.childNodes,(function(t,n){n=new kg(n,e.options);var r="";if(n.nodeType===3){r=n.isCode?n.nodeValue:e.escape(n.nodeValue)}else if(n.nodeType===1){r=Rg.call(e,n)}return Cg(t,r)}),"")}function $g(t){var e=this;this.rules.forEach((function(n){if(typeof n.append==="function"){t=Cg(t,n.append(e.options))}}));return t.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function Rg(t){var e=this.rules.forNode(t);var n=Og.call(this,t);var r=t.flankingWhitespace;if(r.leading||r.trailing)n=n.trim();return r.leading+e.replacement(n,t,this.options)+r.trailing}function Cg(t,e){var n=Jm(t);var r=Km(e);var i=Math.max(t.length-n.length,e.length-r.length);var s="\n\n".substring(0,i);return n+s+r}function Lg(t){return t!=null&&(typeof t==="string"||t.nodeType&&(t.nodeType===1||t.nodeType===9||t.nodeType===11))}const Ng=new Ag({headingStyle:"atx",bulletListMarker:"-",codeBlockStyle:"fenced"});function Ig(t){return Ng.turndown(t)}var Pg={exports:{}};(function(t,e){(function(e,n){{t.exports=n()}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:c,(function(){var t={};var e=t;var n={exports:t};var r=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var n in e)r(t,n,{get:e[n],enumerable:!0})},u=(t,e,n,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of s(e))!o.call(t,u)&&u!==n&&r(t,u,{get:()=>e[u],enumerable:!(l=i(e,u))||l.enumerable});return t};var a=t=>u(r({},"__esModule",{value:!0}),t);var f={};l(f,{Hooks:()=>Pt,Lexer:()=>Ct,Marked:()=>Dt,Parser:()=>It,Renderer:()=>Lt,TextRenderer:()=>Nt,Tokenizer:()=>Rt,defaults:()=>c,getDefaults:()=>h,lexer:()=>Jt,marked:()=>_t,options:()=>jt,parse:()=>qt,parseInline:()=>Ut,parser:()=>Kt,setOptions:()=>zt,use:()=>Bt,walkTokens:()=>Ft});n.exports=a(f);function h(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var c=h();function d(t){c=t}var p={exec:()=>null};function m(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(t,e)=>{let i=typeof e=="string"?e:e.source;return i=i.replace(g.caret,"$1"),n=n.replace(t,i),r},getRegex:()=>new RegExp(n,e)};return r}var g={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},w=/^(?:[ \t]*(?:\n|$))+/,b=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,v=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,k=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,y=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,x=/(?:[*+-]|\d{1,9}[.)])/,M=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,S=m(M).replace(/bull/g,x).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),T=m(M).replace(/bull/g,x).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),E=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,A=/^[^\n]+/,O=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,$=m(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",O).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),R=m(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,x).getRegex(),C="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",L=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,N=m("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",L).replace("tag",C).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),I=m(E).replace("hr",k).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex(),P=m(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",I).getRegex(),D={blockquote:P,code:b,def:$,fences:v,heading:y,hr:k,html:N,lheading:S,list:R,newline:w,paragraph:I,table:p,text:A},H=m("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",k).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex(),_={...D,lheading:T,table:H,paragraph:m(E).replace("hr",k).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",H).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex()},j={...D,html:m(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",L).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:p,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:m(E).replace("hr",k).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",S).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},z=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,B=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,F=/^( {2,}|\\)\n(?!\s*$)/,U=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,q=/[\p{P}\p{S}]/u,K=/[\s\p{P}\p{S}]/u,J=/[^\s\p{P}\p{S}]/u,W=m(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,K).getRegex(),V=/(?!~)[\p{P}\p{S}]/u,G=/(?!~)[\s\p{P}\p{S}]/u,Z=/(?:[^\s\p{P}\p{S}]|~)/u,Y=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,X=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Q=m(X,"u").replace(/punct/g,q).getRegex(),tt=m(X,"u").replace(/punct/g,V).getRegex(),et="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",nt=m(et,"gu").replace(/notPunctSpace/g,J).replace(/punctSpace/g,K).replace(/punct/g,q).getRegex(),rt=m(et,"gu").replace(/notPunctSpace/g,Z).replace(/punctSpace/g,G).replace(/punct/g,V).getRegex(),it=m("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,J).replace(/punctSpace/g,K).replace(/punct/g,q).getRegex(),st=m(/\\(punct)/,"gu").replace(/punct/g,q).getRegex(),ot=m(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),lt=m(L).replace("(?:--\x3e|$)","--\x3e").getRegex(),ut=m("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",lt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),at=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,ft=m(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",at).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ht=m(/^!?\[(label)\]\[(ref)\]/).replace("label",at).replace("ref",O).getRegex(),ct=m(/^!?\[(ref)\](?:\[\])?/).replace("ref",O).getRegex(),dt=m("reflink|nolink(?!\\()","g").replace("reflink",ht).replace("nolink",ct).getRegex(),pt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,mt={_backpedal:p,anyPunctuation:st,autolink:ot,blockSkip:Y,br:F,code:B,del:p,emStrongLDelim:Q,emStrongRDelimAst:nt,emStrongRDelimUnd:it,escape:z,link:ft,nolink:ct,punctuation:W,reflink:ht,reflinkSearch:dt,tag:ut,text:U,url:p},gt={...mt,link:m(/^!?\[(label)\]\((.*?)\)/).replace("label",at).getRegex(),reflink:m(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",at).getRegex()},wt={...mt,emStrongRDelimAst:rt,emStrongLDelim:tt,url:m(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",pt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:m(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",pt).getRegex()},bt={...wt,br:m(F).replace("{2,}","*").getRegex(),text:m(wt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vt={normal:D,gfm:_,pedantic:j},kt={normal:mt,gfm:wt,breaks:bt,pedantic:gt};var yt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},xt=t=>yt[t];function Mt(t,e){if(e){if(g.escapeTest.test(t))return t.replace(g.escapeReplace,xt)}else if(g.escapeTestNoEncode.test(t))return t.replace(g.escapeReplaceNoEncode,xt);return t}function St(t){try{t=encodeURI(t).replace(g.percentDecode,"%")}catch{return null}return t}function Tt(t,e){let n=t.replace(g.findPipe,((t,e,n)=>{let r=!1,i=e;for(;--i>=0&&n[i]==="\\";)r=!r;return r?"|":" |"})),r=n.split(g.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(g.slashPipe,"|");return r}function Et(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r;){let s=t.charAt(r-i-1);if(s===e&&!n)i++;else if(s!==e&&n)i++;else break}return t.slice(0,r-i)}function At(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Ot(t,e,n,r,i){let s=e.href,o=e.title||null,l=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let u={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,u}function $t(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`\n`).map((t=>{let e=t.match(n.other.beginningSpace);if(e===null)return t;let[r]=e;return r.length>=i.length?t.slice(i.length):t})).join(`\n`)}var Rt=class{options;rules;lexer;constructor(t){this.options=t||c}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Et(t,`\n`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let t=e[0],n=$t(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let e=Et(t,"#");(this.options.pedantic||!e||this.rules.other.endingSpaceChar.test(e))&&(t=e.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Et(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let t=Et(e[0],`\n`).split(`\n`),n="",r="",i=[];for(;t.length>0;){let e=!1,s=[],o;for(o=0;o<t.length;o++)if(this.rules.other.blockquoteStart.test(t[o]))s.push(t[o]),e=!0;else if(!e)s.push(t[o]);else break;t=t.slice(o);let l=s.join(`\n`),u=l.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${l}`:l,r=r?`${r}\n${u}`:u;let a=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=a,t.length===0)break;let f=i.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let e=f,s=e.raw+`\n`+t.join(`\n`),o=this.blockquote(s);i[i.length-1]=o,n=n.substring(0,n.length-e.raw.length)+o.raw,r=r.substring(0,r.length-e.text.length)+o.text;break}else if(f?.type==="list"){let e=f,s=e.raw+`\n`+t.join(`\n`),o=this.list(s);i[i.length-1]=o,n=n.substring(0,n.length-f.raw.length)+o.raw,r=r.substring(0,r.length-e.raw.length)+o.raw,t=s.substring(i.at(-1).raw.length).split(`\n`);continue}}return{type:"blockquote",raw:n,tokens:i,text:r}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=!1;for(;t;){let n=!1,r="",l="";if(!(e=s.exec(t))||this.rules.block.hr.test(t))break;r=e[0],t=t.substring(r.length);let u=e[2].split(`\n`,1)[0].replace(this.rules.other.listReplaceTabs,(t=>" ".repeat(3*t.length))),a=t.split(`\n`,1)[0],f=!u.trim(),h=0;if(this.options.pedantic?(h=2,l=u.trimStart()):f?h=e[1].length+1:(h=e[2].search(this.rules.other.nonSpaceChar),h=h>4?1:h,l=u.slice(h),h+=e[1].length),f&&this.rules.other.blankLine.test(a)&&(r+=a+`\n`,t=t.substring(a.length+1),n=!0),!n){let e=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),i=this.rules.other.fencesBeginRegex(h),s=this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h);for(;t;){let c=t.split(`\n`,1)[0],d;if(a=c,this.options.pedantic?(a=a.replace(this.rules.other.listReplaceNesting," "),d=a):d=a.replace(this.rules.other.tabCharGlobal," "),i.test(a)||s.test(a)||o.test(a)||e.test(a)||n.test(a))break;if(d.search(this.rules.other.nonSpaceChar)>=h||!a.trim())l+=`\n`+d.slice(h);else{if(f||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(u)||s.test(u)||n.test(u))break;l+=`\n`+a}!f&&!a.trim()&&(f=!0),r+=c+`\n`,t=t.substring(c.length+1),u=d.slice(h)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let c=null,d;this.options.gfm&&(c=this.rules.other.listIsTask.exec(l),c&&(d=c[0]!=="[ ] ",l=l.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:r,task:!!c,checked:d,loose:!1,text:l,tokens:[]}),i.raw+=r}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let t=0;t<i.items.length;t++)if(this.lexer.state.top=!1,i.items[t].tokens=this.lexer.blockTokens(i.items[t].text,[]),!i.loose){let e=i.items[t].tokens.filter((t=>t.type==="space")),n=e.length>0&&e.some((t=>this.rules.other.anyLine.test(t.raw)));i.loose=n}if(i.loose)for(let t=0;t<i.items.length;t++)i.items[t].loose=!0;return i}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:n,title:r}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Tt(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`\n`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let t of r)this.rules.other.tableAlignRight.test(t)?s.align.push("right"):this.rules.other.tableAlignCenter.test(t)?s.align.push("center"):this.rules.other.tableAlignLeft.test(t)?s.align.push("left"):s.align.push(null);for(let t=0;t<n.length;t++)s.header.push({text:n[t],tokens:this.lexer.inline(n[t]),header:!0,align:s.align[t]});for(let t of i)s.rows.push(Tt(t,s.header.length).map(((t,e)=>({text:t,tokens:this.lexer.inline(t),header:!1,align:s.align[e]}))));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let t=e[1].charAt(e[1].length-1)===`\n`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let e=Et(t.slice(0,-1),"\\");if((t.length-e.length)%2===0)return}else{let t=At(e[2],"()");if(t===-2)return;if(t>-1){let n=(e[0].indexOf("!")===0?5:4)+e[1].length+t;e[2]=e[2].substring(0,t),e[0]=e[0].substring(0,n).trim(),e[3]=""}}let n=e[2],r="";if(this.options.pedantic){let t=this.rules.other.pedanticHrefTitle.exec(n);t&&(n=t[1],r=t[3])}else r=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?n=n.slice(1):n=n.slice(1,-1)),Ot(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let t=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[t.toLowerCase()];if(!r){let t=n[0].charAt(0);return{type:"text",raw:t,text:t}}return Ot(n,r,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let n=[...r[0]].length-1,i,s,o=n,l=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+n);(r=u.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(s=[...i].length,r[3]||r[4]){o+=s;continue}else if((r[5]||r[6])&&n%3&&!((n+s)%3)){l+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+l);let e=[...r[0]][0].length,u=t.slice(0,n+r.index+e+s);if(Math.min(n,s)%2){let t=u.slice(1,-1);return{type:"em",raw:u,text:t,tokens:this.lexer.inlineTokens(t)}}let a=u.slice(2,-2);return{type:"strong",raw:u,text:a,tokens:this.lexer.inlineTokens(a)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return n&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){let e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let t,n;return e[2]==="@"?(t=e[1],n="mailto:"+t):(t=e[1],n=t),{type:"link",raw:e[0],text:t,href:n,tokens:[{type:"text",raw:t,text:t}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let t,n;if(e[2]==="@")t=e[0],n="mailto:"+t;else{let r;do{r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??""}while(r!==e[0]);t=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:t,href:n,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}};var Ct=class t{tokens;options;state;tokenizer;inlineQueue;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||c,this.options.tokenizer=this.options.tokenizer||new Rt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:g,block:vt.normal,inline:kt.normal};this.options.pedantic?(e.block=vt.pedantic,e.inline=kt.pedantic):this.options.gfm&&(e.block=vt.gfm,this.options.breaks?e.inline=kt.breaks:e.inline=kt.gfm),this.tokenizer.rules=e}static get rules(){return{block:vt,inline:kt}}static lex(e,n){return new t(n).lex(e)}static lexInline(e,n){return new t(n).inlineTokens(e)}lex(t){t=t.replace(g.carriageReturn,`\n`),this.blockTokens(t,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],n=!1){for(this.options.pedantic&&(t=t.replace(g.tabCharGlobal," ").replace(g.spaceLine,""));t;){let r;if(this.options.extensions?.block?.some((n=>(r=n.call({lexer:this},t,e))?(t=t.substring(r.raw.length),e.push(r),!0):!1)))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let n=e.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`\n`:e.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let n=e.at(-1);n?.type==="paragraph"||n?.type==="text"?(n.raw+=(n.raw.endsWith(`\n`)?"":`\n`)+r.raw,n.text+=`\n`+r.text,this.inlineQueue.at(-1).src=n.text):e.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length);let n=e.at(-1);n?.type==="paragraph"||n?.type==="text"?(n.raw+=(n.raw.endsWith(`\n`)?"":`\n`)+r.raw,n.text+=`\n`+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},e.push(r));continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),e.push(r);continue}let i=t;if(this.options.extensions?.startBlock){let e=1/0,n=t.slice(1),r;this.options.extensions.startBlock.forEach((t=>{r=t.call({lexer:this},n),typeof r=="number"&&r>=0&&(e=Math.min(e,r))})),e<1/0&&e>=0&&(i=t.substring(0,e+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let s=e.at(-1);n&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`\n`)?"":`\n`)+r.raw,s.text+=`\n`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):e.push(r),n=i.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length);let n=e.at(-1);n?.type==="text"?(n.raw+=(n.raw.endsWith(`\n`)?"":`\n`)+r.raw,n.text+=`\n`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):e.push(r);continue}if(t){let e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}else throw new Error(e)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){let n=t,r=null;if(this.tokens.links){let t=Object.keys(this.tokens.links);if(t.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)t.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=!1,s="";for(;t;){i||(s=""),i=!1;let r;if(this.options.extensions?.inline?.some((n=>(r=n.call({lexer:this},t,e))?(t=t.substring(r.raw.length),e.push(r),!0):!1)))continue;if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length);let n=e.at(-1);r.type==="text"&&n?.type==="text"?(n.raw+=r.raw,n.text+=r.text):e.push(r);continue}if(r=this.tokenizer.emStrong(t,n,s)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),e.push(r);continue}if(r=this.tokenizer.autolink(t)){t=t.substring(r.raw.length),e.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t))){t=t.substring(r.raw.length),e.push(r);continue}let o=t;if(this.options.extensions?.startInline){let e=1/0,n=t.slice(1),r;this.options.extensions.startInline.forEach((t=>{r=t.call({lexer:this},n),typeof r=="number"&&r>=0&&(e=Math.min(e,r))})),e<1/0&&e>=0&&(o=t.substring(0,e+1))}if(r=this.tokenizer.inlineText(o)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(s=r.raw.slice(-1)),i=!0;let n=e.at(-1);n?.type==="text"?(n.raw+=r.raw,n.text+=r.text):e.push(r);continue}if(t){let e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}else throw new Error(e)}}return e}};var Lt=class{options;parser;constructor(t){this.options=t||c}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(g.notSpaceStart)?.[0],i=t.replace(g.endingNewline,"")+`\n`;return r?'<pre><code class="language-'+Mt(r)+'">'+(n?i:Mt(i,!0))+`</code></pre>\n`:"<pre><code>"+(n?i:Mt(i,!0))+`</code></pre>\n`}blockquote({tokens:t}){return`<blockquote>\n${this.parser.parse(t)}</blockquote>\n`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>\n`}hr(t){return`<hr>\n`}list(t){let e=t.ordered,n=t.start,r="";for(let e=0;e<t.items.length;e++){let n=t.items[e];r+=this.listitem(n)}let i=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>\n`+r+"</"+i+`>\n`}listitem(t){let e="";if(t.task){let n=this.checkbox({checked:!!t.checked});t.loose?t.tokens[0]?.type==="paragraph"?(t.tokens[0].text=n+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=n+" "+Mt(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):e+=n+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>\n`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>\n`}table(t){let e="",n="";for(let e=0;e<t.header.length;e++)n+=this.tablecell(t.header[e]);e+=this.tablerow({text:n});let r="";for(let e=0;e<t.rows.length;e++){let i=t.rows[e];n="";for(let t=0;t<i.length;t++)n+=this.tablecell(i[t]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>\n<thead>\n`+e+`</thead>\n`+r+`</table>\n`}tablerow({text:t}){return`<tr>\n${t}</tr>\n`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Mt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=St(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+Mt(e)+'"'),s+=">"+r+"</a>",s}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=St(t);if(i===null)return Mt(n);t=i;let s=`<img src="${t}" alt="${n}"`;return e&&(s+=` title="${Mt(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Mt(t.text)}};var Nt=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}};var It=class t{options;renderer;textRenderer;constructor(t){this.options=t||c,this.options.renderer=this.options.renderer||new Lt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Nt}static parse(e,n){return new t(n).parse(e)}static parseInline(e,n){return new t(n).parseInline(e)}parse(t,e=!0){let n="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let t=i,e=this.options.extensions.renderers[t.type].call({parser:this},t);if(e!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(t.type)){n+=e||"";continue}}let s=i;switch(s.type){case"space":{n+=this.renderer.space(s);continue}case"hr":{n+=this.renderer.hr(s);continue}case"heading":{n+=this.renderer.heading(s);continue}case"code":{n+=this.renderer.code(s);continue}case"table":{n+=this.renderer.table(s);continue}case"blockquote":{n+=this.renderer.blockquote(s);continue}case"list":{n+=this.renderer.list(s);continue}case"html":{n+=this.renderer.html(s);continue}case"def":{n+=this.renderer.def(s);continue}case"paragraph":{n+=this.renderer.paragraph(s);continue}case"text":{let i=s,o=this.renderer.text(i);for(;r+1<t.length&&t[r+1].type==="text";)i=t[++r],o+=`\n`+this.renderer.text(i);e?n+=this.renderer.paragraph({type:"paragraph",raw:o,text:o,tokens:[{type:"text",raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(t),"";throw new Error(t)}}}return n}parseInline(t,e=this.renderer){let n="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let t=this.options.extensions.renderers[i.type].call({parser:this},i);if(t!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=t||"";continue}}let s=i;switch(s.type){case"escape":{n+=e.text(s);break}case"html":{n+=e.html(s);break}case"link":{n+=e.link(s);break}case"image":{n+=e.image(s);break}case"strong":{n+=e.strong(s);break}case"em":{n+=e.em(s);break}case"codespan":{n+=e.codespan(s);break}case"br":{n+=e.br(s);break}case"del":{n+=e.del(s);break}case"text":{n+=e.text(s);break}default:{let t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(t),"";throw new Error(t)}}}return n}};var Pt=class{options;block;constructor(t){this.options=t||c}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?Ct.lex:Ct.lexInline}provideParser(){return this.block?It.parse:It.parseInline}};var Dt=class{defaults=h();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=It;Renderer=Lt;TextRenderer=Nt;Lexer=Ct;Tokenizer=Rt;Hooks=Pt;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let t=r;for(let r of t.header)n=n.concat(this.walkTokens(r.tokens,e));for(let r of t.rows)for(let t of r)n=n.concat(this.walkTokens(t.tokens,e));break}case"list":{let t=r;n=n.concat(this.walkTokens(t.items,e));break}default:{let t=r;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach((r=>{let i=t[r].flat(1/0);n=n.concat(this.walkTokens(i,e))})):t.tokens&&(n=n.concat(this.walkTokens(t.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach((t=>{let n={...t};if(n.async=this.defaults.async||n.async||!1,t.extensions&&(t.extensions.forEach((t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let n=e.renderers[t.name];n?e.renderers[t.name]=function(...e){let r=t.renderer.apply(this,e);return r===!1&&(r=n.apply(this,e)),r}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let n=e[t.level];n?n.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)})),n.extensions=e),t.renderer){let e=this.defaults.renderer||new Lt(this.defaults);for(let n in t.renderer){if(!(n in e))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,i=t.renderer[r],s=e[r];e[r]=(...t)=>{let n=i.apply(e,t);return n===!1&&(n=s.apply(e,t)),n||""}}n.renderer=e}if(t.tokenizer){let e=this.defaults.tokenizer||new Rt(this.defaults);for(let n in t.tokenizer){if(!(n in e))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,i=t.tokenizer[r],s=e[r];e[r]=(...t)=>{let n=i.apply(e,t);return n===!1&&(n=s.apply(e,t)),n}}n.tokenizer=e}if(t.hooks){let e=this.defaults.hooks||new Pt;for(let n in t.hooks){if(!(n in e))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,i=t.hooks[r],s=e[r];Pt.passThroughHooks.has(n)?e[r]=t=>{if(this.defaults.async&&Pt.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(e,t);return s.call(e,n)})();let r=i.call(e,t);return s.call(e,r)}:e[r]=(...t)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(e,t);return n===!1&&(n=await s.apply(e,t)),n})();let n=i.apply(e,t);return n===!1&&(n=s.apply(e,t)),n}}n.hooks=e}if(t.walkTokens){let e=this.defaults.walkTokens,r=t.walkTokens;n.walkTokens=function(t){let n=[];return n.push(r.call(this,t)),e&&(n=n.concat(e.call(this,t))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ct.lex(t,e??this.defaults)}parser(t,e){return It.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(e):e,r=await(i.hooks?await i.hooks.provideLexer():t?Ct.lex:Ct.lexInline)(n,i),s=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(s,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():t?It.parse:It.parseInline)(s,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let n=(i.hooks?i.hooks.provideLexer():t?Ct.lex:Ct.lexInline)(e,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():t?It.parse:It.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(t){return s(t)}}}onError(t,e){return n=>{if(n.message+=`\nPlease report this to https://github.com/markedjs/marked.`,t){let t="<p>An error occurred:</p><pre>"+Mt(n.message+"",!0)+"</pre>";return e?Promise.resolve(t):t}if(e)return Promise.reject(n);throw n}}};var Ht=new Dt;function _t(t,e){return Ht.parse(t,e)}_t.options=_t.setOptions=function(t){return Ht.setOptions(t),_t.defaults=Ht.defaults,d(_t.defaults),_t};_t.getDefaults=h;_t.defaults=c;_t.use=function(...t){return Ht.use(...t),_t.defaults=Ht.defaults,d(_t.defaults),_t};_t.walkTokens=function(t,e){return Ht.walkTokens(t,e)};_t.parseInline=Ht.parseInline;_t.Parser=It;_t.parser=It.parse;_t.Renderer=Lt;_t.TextRenderer=Nt;_t.Lexer=Ct;_t.lexer=Ct.lex;_t.Tokenizer=Rt;_t.Hooks=Pt;_t.parse=_t;var jt=_t.options,zt=_t.setOptions,Bt=_t.use,Ft=_t.walkTokens,Ut=_t.parseInline,qt=_t,Kt=It.parse,Jt=Ct.lex;if(e!=t)n.exports=t;return n.exports}))})(Pg);async function Dg(t){return await Pg.exports.marked(t)}const Hg=":host {\n article {\n padding: 0;\n &:focus-within {\n outline: var(--pos-input-focus-outline);\n }\n\n .tiptap {\n border: none;\n outline: none;\n }\n\n line-height: 1.5;\n pos-image {\n --max-width: 100%;\n }\n\n header {\n position: sticky;\n background-color: var(--pos-background-color);\n border-bottom: var(--size-px) solid var(--pos-border-color);\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n overflow: hidden;\n z-index: var(--layer-1);\n top: 0;\n padding: var(--size-1);\n flex-direction: row;\n justify-content: flex-end;\n button {\n background: var(--pos-primary-color);\n color: var(--pos-primary-text-color);\n outline: none;\n border: none;\n border-radius: var(--radius-xs);\n display: inline-flex;\n gap: var(--size-1);\n justify-content: center;\n align-items: center;\n height: var(--size-8);\n flex-shrink: 1;\n\n &:focus {\n outline: var(--pos-input-focus-outline);\n }\n\n &:hover {\n filter: brightness(110%);\n box-shadow: var(--shadow-md);\n }\n }\n .status {\n display: flex;\n align-content: center;\n align-items: center;\n gap: var(--size-1);\n font-size: var(--scale-00);\n\n &.pending {\n animation: pending-fade 1s ease forwards;\n }\n\n &.success {\n animation: success-flash 2s ease forwards;\n }\n\n &.error {\n animation: error-flash 2s ease infinite;\n }\n }\n }\n\n .content {\n padding: var(--size-4);\n\n pre {\n code {\n display: block;\n padding: var(--size-4);\n overflow-x: auto;\n background-color: var(--color-black);\n font-family: monospace;\n color: var(--color-white);\n line-height: 1.6;\n border-radius: var(--radius-lg);\n }\n }\n\n blockquote {\n border-left: var(--size-1) solid var(--pos-primary-color);\n margin-left: var(--size-4);\n padding-left: var(--size-4);\n }\n }\n }\n}\n\n@keyframes pending-fade {\n 0% {\n opacity: 0;\n color: var(--pos-subtle-text-color);\n }\n 100% {\n opacity: 1;\n color: var(--pos-primary-color);\n }\n}\n\n@keyframes success-flash {\n 0% {\n opacity: 0;\n color: var(--pos-subtle-text-color);\n }\n 50% {\n opacity: 1;\n color: var(--color-green-500);\n }\n 100% {\n opacity: 1;\n color: var(--pos-subtle-text-color);\n }\n}\n\n@keyframes error-flash {\n 0% {\n opacity: 0;\n }\n 50% {\n opacity: 1;\n color: var(--color-red-500);\n }\n 100% {\n opacity: 0;\n }\n}\n";const _g=Hg;const jg="article {\n padding: var(--size-2);\n display: flex;\n flex-direction: column;\n gap: var(--size-2);\n outline: var(--pos-border-solid);\n border-radius: var(--radius-sm);\n box-shadow: var(--shadow-md);\n background-color: var(--pos-card-background);\n\n header {\n display: flex;\n flex-direction: column;\n gap: var(--size-2);\n h1 {\n margin: 0;\n }\n }\n}\n";const zg=jg;const Bg=class{constructor(n){t(this,n);this.documentModified=e(this,"pod-os:document-modified",7);this.savingFailed=false;this.editable=false;this.isModified=false;this.isEditing=false;this.disconnected$=new l}async componentWillLoad(){const t=await this.file.blob().text();const e=await Dg(t);this.sanitizedHtml=m(e)}componentDidLoad(){this.editor=new Fm(this.editorEl,this.sanitizedHtml,this.file.url);this.editor.onUpdate((()=>{this.isModified=this.editor.isModified()}));this.editor.observeChanges().pipe(a(this.disconnected$),f((t=>Ig(t.content))),h((t=>{this.isModified=false;this.documentModified.emit({file:this.file,newContent:t})}))).subscribe()}disconnectedCallback(){this.disconnected$.next();this.disconnected$.unsubscribe()}async startEditing(){this.editor.startEditing();this.isEditing=true}async stopEditing(){this.editor.stopEditing();this.isEditing=false}render(){return n("article",{key:"755b556623643489ff7826e8a591b48ff72f9f65"},this.editable?n("header",null,this.isEditing?this.getStatus():null,this.isEditing?n("button",{onClick:()=>this.stopEditing()},n("sl-icon",{name:"eye"}),"View"):n("button",{onClick:()=>this.startEditing()},n("sl-icon",{name:"pencil-square"}),"Edit")):null,n("div",{key:"33cd49fa0e448263388034f1ae58a092fe374e63",class:"content",ref:t=>this.editorEl=t}))}getStatus(){if(this.isModified){return n(Fg,{status:"pending",message:"pending changes",icon:"clock-history"})}if(this.savingFailed){return n(Fg,{status:"error",message:"saving failed",icon:"x-octagon"})}return n(Fg,{status:"success",message:"all saved",icon:"check2-circle"})}};function Fg({status:t,icon:e,message:r}){return n("span",{class:{status:true,[t]:true},role:"status","aria-live":"polite","aria-labelledby":"status-message"},n("sl-icon",{name:e,"aria-hidden":"true"}),n("span",{id:"status-message"},r))}Bg.style=_g+zg;export{Bg as pos_markdown_document};
3
- //# sourceMappingURL=p-b479ffbe.entry.js.map