@tempots/beatui 0.78.2 → 0.80.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.
Files changed (95) hide show
  1. package/dist/{ar-D__6gR_P.js → ar-Bo_FZZi7.js} +2 -1
  2. package/dist/ar-DwHLVgKj.cjs +1 -0
  3. package/dist/auth/index.cjs.js +1 -1
  4. package/dist/auth/index.es.js +69 -69
  5. package/dist/beatui.css +127 -7
  6. package/dist/beatui.tailwind.css +127 -7
  7. package/dist/{de-DmKpCTuQ.js → de-CCqwOkqN.js} +3 -2
  8. package/dist/de-zI5mdV4M.cjs +1 -0
  9. package/dist/{deep-merge-Bsqkvp9-.js → deep-merge-1uN6CG6K.js} +2 -2
  10. package/dist/{deep-merge-cQgRrtGF.cjs → deep-merge-CBIkQM4E.cjs} +1 -1
  11. package/dist/{duration-input-DcZf0Dyd.js → duration-input-C9kpsw-t.js} +3 -3
  12. package/dist/{duration-input-Dt6riwzu.cjs → duration-input-DHWhQJnn.cjs} +1 -1
  13. package/dist/{es-BDZ5UJLS.js → es-BF02UrPL.js} +2 -1
  14. package/dist/es-Cw90CAbu.cjs +1 -0
  15. package/dist/fa-B4lssnzR.cjs +1 -0
  16. package/dist/{fa-CuPgy1cj.js → fa-DPQV4YB8.js} +2 -1
  17. package/dist/fr-1Kd6z1F-.cjs +1 -0
  18. package/dist/{fr-DmyMO3lB.js → fr-dmxPhwkD.js} +4 -3
  19. package/dist/{he-C3RHfs6R.js → he-BtQbrVt3.js} +2 -1
  20. package/dist/he-CJ3XnuPm.cjs +1 -0
  21. package/dist/hi-BpfnFKHp.cjs +1 -0
  22. package/dist/{hi-YnvrXBht.js → hi-D_Le4Yka.js} +10 -9
  23. package/dist/{index-mPVib4v9.js → index-CGEzILlC.js} +1 -1
  24. package/dist/{index-CdVc1Y2V.cjs → index-CfaWytS2.cjs} +1 -1
  25. package/dist/{index-BGwNJNop.cjs → index-K6u33-GC.cjs} +2 -2
  26. package/dist/{index-Dbu1ZPpw.js → index-YtW7SCWB.js} +3 -3
  27. package/dist/index.cjs.js +2 -2
  28. package/dist/index.es.js +15 -15
  29. package/dist/it-COCZ9NyB.cjs +1 -0
  30. package/dist/{it-CWLwlDXe.js → it-DyHjSuHN.js} +2 -1
  31. package/dist/ja--NdggLU9.cjs +1 -0
  32. package/dist/{ja-DthjgDtM.js → ja-X43lABza.js} +2 -1
  33. package/dist/json-schema/index.cjs.js +7 -7
  34. package/dist/json-schema/index.es.js +3403 -3380
  35. package/dist/json-structure/index.cjs.js +1 -1
  36. package/dist/json-structure/index.es.js +4 -4
  37. package/dist/{ko-joDK7ONT.js → ko-B9g9iw99.js} +2 -1
  38. package/dist/ko-BUvb0ggK.cjs +1 -0
  39. package/dist/{modal-oWbT46Rc.js → modal-CSHIhHvI.js} +2 -2
  40. package/dist/{modal-D3NQ6ZgO.cjs → modal-cc8Ehngz.cjs} +1 -1
  41. package/dist/monaco/index.cjs.js +2 -2
  42. package/dist/monaco/index.es.js +6 -8
  43. package/dist/nl-0S25Gsld.cjs +1 -0
  44. package/dist/{nl-DmoWeXUt.js → nl-Ew5jnSsT.js} +2 -1
  45. package/dist/{notice-C0Brmeyi.js → notice-C-964yaY.js} +2 -2
  46. package/dist/{notice-DYBLXglS.cjs → notice-C_BWqu2K.cjs} +1 -1
  47. package/dist/pl-B3k-K3S4.cjs +1 -0
  48. package/dist/{pl-8hl5VXnm.js → pl-C9f6UBSe.js} +2 -1
  49. package/dist/prosemirror/index.cjs.js +1 -1
  50. package/dist/prosemirror/index.es.js +1 -1
  51. package/dist/pt-CKoikRO5.cjs +1 -0
  52. package/dist/{pt-BfYK9Rl3.js → pt-DYtAvbrw.js} +2 -1
  53. package/dist/ru-COb7RSDt.cjs +1 -0
  54. package/dist/{ru-eA_dNkJz.js → ru-ZexN-b8V.js} +2 -1
  55. package/dist/{toolbar-DoRPrs-s.cjs → toolbar-D5FcnRju.cjs} +1 -1
  56. package/dist/{toolbar-CdY5huSG.js → toolbar-DNpBIoJo.js} +1 -1
  57. package/dist/{tr-CdqbnopM.js → tr-BDvn05-H.js} +4 -3
  58. package/dist/tr-tO_EH-Y2.cjs +1 -0
  59. package/dist/{translations-BEMKy6-W.js → translations-0tLX4x7M.js} +26 -25
  60. package/dist/{translations-CVfr2JXG.js → translations-CfWR4loD.js} +1 -1
  61. package/dist/{translations-D_Vu2mbd.cjs → translations-DwGC_94w.cjs} +1 -1
  62. package/dist/translations-WPN3ibDg.cjs +1 -0
  63. package/dist/types/beatui-i18n/default.d.ts +1 -0
  64. package/dist/types/beatui-i18n/locales/en.d.ts +1 -0
  65. package/dist/types/beatui-i18n/translations.d.ts +1 -0
  66. package/dist/ur-BbnYJ3HS.cjs +1 -0
  67. package/dist/{ur-D9sr_I1M.js → ur-DbEqQgS6.js} +2 -1
  68. package/dist/{use-form-pSErMD6z.cjs → use-form-D4JFOcjo.cjs} +1 -1
  69. package/dist/{use-form-DMiCxK26.js → use-form-D4rqJkvG.js} +1 -1
  70. package/dist/vi-ByBwvGQY.cjs +1 -0
  71. package/dist/{vi-0f97dtZb.js → vi-CpZUeuSj.js} +2 -1
  72. package/dist/{widget-customization-nxbAoCx5.js → widget-customization-BSjJz3_Y.js} +4 -4
  73. package/dist/{widget-customization-WNWmH_gX.cjs → widget-customization-CrFVrt4V.cjs} +1 -1
  74. package/dist/{zh-C7HcUKhE.js → zh-DJyhKO0I.js} +2 -1
  75. package/dist/zh-DnxK0ieB.cjs +1 -0
  76. package/package.json +6 -6
  77. package/dist/ar-DNoFBb9J.cjs +0 -1
  78. package/dist/de-AwUkK0rS.cjs +0 -1
  79. package/dist/es-D-d2AIlX.cjs +0 -1
  80. package/dist/fa-D7rRdG8c.cjs +0 -1
  81. package/dist/fr-0er_BWMt.cjs +0 -1
  82. package/dist/he-R2veUyP3.cjs +0 -1
  83. package/dist/hi-C9UP7NGG.cjs +0 -1
  84. package/dist/it-Cxt1_D4h.cjs +0 -1
  85. package/dist/ja-CpDovHPb.cjs +0 -1
  86. package/dist/ko-M_MCTNuN.cjs +0 -1
  87. package/dist/nl-DGhIOGxN.cjs +0 -1
  88. package/dist/pl-DocnXix_.cjs +0 -1
  89. package/dist/pt-DO2Zcuqv.cjs +0 -1
  90. package/dist/ru-D9KCOBqN.cjs +0 -1
  91. package/dist/tr-BBmQvRSa.cjs +0 -1
  92. package/dist/translations-eUtMHN9s.cjs +0 -1
  93. package/dist/ur-u5qjZsKM.cjs +0 -1
  94. package/dist/vi-_w5RE8el.cjs +0 -1
  95. package/dist/zh-6cQcHbf6.cjs +0 -1
@@ -1,9 +1,9 @@
1
- "use strict";const S=require("@tempots/dom"),It=require("./toolbar-DoRPrs-s.cjs"),Br=require("./translations-eUtMHN9s.cjs"),zo=require("./link-portal-_tiDFZqh.cjs"),vo=require("@tempots/ui"),Po=require("./theme-Dt6lCAvY.cjs");function V(t){this.content=t}V.prototype={constructor:V,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?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,u=r.find(t),i=r.content.slice();return u==-1?i.push(n||t,e):(i[u+1]=e,n&&(i[u]=n)),new V(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new V(n)},addToStart:function(t,e){return new V([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new V(n)},addBefore:function(t,e,n){var r=this.remove(e),u=r.content.slice(),i=r.find(t);return u.splice(i==-1?u.length:i,0,e,n),new V(u)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=V.from(t),t.size?new V(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=V.from(t),t.size?new V(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=V.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};V.from=function(t){if(t instanceof V)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new V(e)};function Ni(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let u=t.child(r),i=e.child(r);if(u==i){n+=u.nodeSize;continue}if(!u.sameMarkup(i))return n;if(u.isText&&u.text!=i.text){for(let s=0;u.text[s]==i.text[s];s++)n++;return n}if(u.content.size||i.content.size){let s=Ni(u.content,i.content,n+1);if(s!=null)return s}n+=u.nodeSize}}function Ii(t,e,n,r){for(let u=t.childCount,i=e.childCount;;){if(u==0||i==0)return u==i?null:{a:n,b:r};let s=t.child(--u),o=e.child(--i),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let a=0,c=Math.min(s.text.length,o.text.length);for(;a<c&&s.text[s.text.length-a-1]==o.text[o.text.length-a-1];)a++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let a=Ii(s.content,o.content,n-1,r-1);if(a)return a}n-=l,r-=l}}class x{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,u=0,i){for(let s=0,o=0;o<n;s++){let l=this.content[s],a=o+l.nodeSize;if(a>e&&r(l,u+o,i||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,u+c)}o=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,u){let i="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let a=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?u?typeof u=="function"?u(o):u:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&a||o.isTextblock)&&r&&(s?s=!1:i+=r),i+=a},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,u=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(u[u.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)u.push(e.content[i]);return new x(u,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],u=0;if(n>e)for(let i=0,s=0;s<n;i++){let o=this.content[i],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),u+=o.nodeSize),s=l}return new x(r,u)}cutByIndex(e,n){return e==n?x.empty:e==0&&n==this.content.length?this:new x(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let u=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return u[e]=n,new x(u,i)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}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(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let u=this.content[n];e(u,r,n),r+=u.nodeSize}}findDiffStart(e,n=0){return Ni(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ii(this,e,n,r)}findIndex(e){if(e==0)return en(0,e);if(e==this.size)return en(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let u=this.child(n),i=r+u.nodeSize;if(i>=e)return i==e?en(n+1,i):en(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return x.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let n,r=0;for(let u=0;u<e.length;u++){let i=e[u];r+=i.nodeSize,u&&i.isText&&e[u-1].sameMarkup(i)?(n||(n=e.slice(0,u)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new x(n||e,r)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const Pn={index:0,offset:0};function en(t,e){return Pn.index=t,Pn.offset=e,Pn}function dn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!dn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!dn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class T{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let u=0;u<e.length;u++){let i=e[u];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,u));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,u)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&dn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let u=r.create(n.attrs);return r.checkAttrs(u.attrs),u}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return T.none;if(e instanceof T)return[e];let n=e.slice();return n.sort((r,u)=>r.type.rank-u.type.rank),n}}T.none=[];class hn extends Error{}class D{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Bi(this.content,e+this.openStart,n);return r&&new D(r,this.openStart,this.openEnd)}removeBetween(e,n){return new D(Ri(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return D.empty;let r=n.openStart||0,u=n.openEnd||0;if(typeof r!="number"||typeof u!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new D(x.fromJSON(e,n.content),r,u)}static maxOpen(e,n=!0){let r=0,u=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)u++;return new D(e,r,u)}}D.empty=new D(x.empty,0,0);function Ri(t,e,n){let{index:r,offset:u}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(u==e||i.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Ri(i.content,e-u-1,n-u-1)))}function Bi(t,e,n,r){let{index:u,offset:i}=t.findIndex(e),s=t.maybeChild(u);if(i==e||s.isText)return r&&!r.canReplace(u,u,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Bi(s.content,e-i-1,n,s);return o&&t.replaceChild(u,s.copy(o))}function Lo(t,e,n){if(n.openStart>t.depth)throw new hn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new hn("Inconsistent open depths");return zi(t,e,n,0)}function zi(t,e,n,r){let u=t.index(r),i=t.node(r);if(u==e.index(r)&&r<t.depth-n.openStart){let s=zi(t,e,n,r+1);return i.copy(i.content.replaceChild(u,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Ye(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=qo(n,t);return Ye(i,Pi(t,s,o,e,r))}else return Ye(i,pn(t,e,r))}function vi(t,e){if(!e.type.compatibleContent(t.type))throw new hn("Cannot join "+e.type.name+" onto "+t.type.name)}function pr(t,e,n){let r=t.node(n);return vi(r,e.node(n)),r}function Ge(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function wt(t,e,n,r){let u=(e||t).node(n),i=0,s=e?e.index(n):u.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ge(t.nodeAfter,r),i++));for(let o=i;o<s;o++)Ge(u.child(o),r);e&&e.depth==n&&e.textOffset&&Ge(e.nodeBefore,r)}function Ye(t,e){return t.type.checkContent(e),t.copy(e)}function Pi(t,e,n,r,u){let i=t.depth>u&&pr(t,e,u+1),s=r.depth>u&&pr(n,r,u+1),o=[];return wt(null,t,u,o),i&&s&&e.index(u)==n.index(u)?(vi(i,s),Ge(Ye(i,Pi(t,e,n,r,u+1)),o)):(i&&Ge(Ye(i,pn(t,e,u+1)),o),wt(e,n,u,o),s&&Ge(Ye(s,pn(n,r,u+1)),o)),wt(r,null,u,o),new x(o)}function pn(t,e,n){let r=[];if(wt(null,t,n,r),t.depth>n){let u=pr(t,e,n+1);Ge(Ye(u,pn(t,e,n+1)),r)}return wt(e,null,n,r),new x(r)}function qo(t,e){let n=e.depth-t.openStart,u=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)u=e.node(i).copy(x.from(u));return{start:u.resolveNoCache(t.openStart+n),end:u.resolveNoCache(u.content.size-t.openEnd-n)}}class Rt{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],u=e.child(n);return r?e.child(n).cut(r):u}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],u=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)u+=r.child(i).nodeSize;return u}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return T.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),u=e.maybeChild(n);if(!r){let o=r;r=u,u=o}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!u||!i[s].isInSet(u.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,u=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!u||!r[i].isInSet(u.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Li(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],u=0,i=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(i),a=i-l;if(r.push(s,o,u+l),!a||(s=s.child(o),s.isText))break;i=a-1,u+=l+1}return new Rt(n,r,i)}static resolveCached(e,n){let r=lu.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else lu.set(e,r=new Vo);let u=r.elts[r.i]=Rt.resolve(e,n);return r.i=(r.i+1)%$o,u}}class Vo{constructor(){this.elts=[],this.i=0}}const $o=12,lu=new WeakMap;class Li{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}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 Wo=Object.create(null);class xe{constructor(e,n,r,u=T.none){this.type=e,this.attrs=n,this.marks=u,this.content=r||x.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,u=0){this.content.nodesBetween(e,n,r,u,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,u){return this.content.textBetween(e,n,r,u)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&dn(this.attrs,n||e.defaultAttrs||Wo)&&T.sameSet(this.marks,r||T.none)}copy(e=null){return e==this.content?this:new xe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new xe(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return D.empty;let u=this.resolve(e),i=this.resolve(n),s=r?0:u.sharedDepth(n),o=u.start(s),a=u.node(s).content.cut(u.pos-o,i.pos-o);return new D(a,u.depth-s,i.depth-s)}replace(e,n,r){return Lo(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:u}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(u==e||n.isText)return n;e-=u+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let u=this.content.child(n-1);return{node:u,index:n-1,offset:r-u.nodeSize}}resolve(e){return Rt.resolveCached(this,e)}resolveNoCache(e){return Rt.resolve(this,e)}rangeHasMark(e,n,r){let u=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(u=!0),!u)),u}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),qi(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=x.empty,u=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,u,i),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=u;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,u){if(u&&!this.type.allowsMarks(u))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=T.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!T.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let u=x.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,u,r);return i.type.checkAttrs(i.attrs),i}}xe.prototype.text=void 0;class mn extends xe{constructor(e,n,r,u){if(super(e,n,null,u),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):qi(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new mn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new mn(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function qi(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class tt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Ho(e,n);if(r.next==null)return tt.empty;let u=Vi(r);r.next&&r.err("Unexpected trailing text");let i=Yo(Go(u));return Xo(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let u=this;for(let i=n;u&&i<r;i++)u=u.matchType(e.child(i).type);return u}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let u=[this];function i(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return x.from(o.map(a=>a.createAndFill()));for(let a=0;a<s.next.length;a++){let{type:c,next:f}=s.next[a];if(!(c.isText||c.hasRequiredAttrs())&&u.indexOf(f)==-1){u.push(f);let p=i(f,o.concat(c));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let u=r.shift(),i=u.match;if(i.matchType(e)){let s=[];for(let o=u;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:o,next:l}=i.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!u.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:u}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let u=0;u<r.next.length;u++)e.indexOf(r.next[u].next)==-1&&n(r.next[u].next)}return n(this),e.map((r,u)=>{let i=u+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
1
+ "use strict";const S=require("@tempots/dom"),It=require("./toolbar-D5FcnRju.cjs"),Br=require("./translations-WPN3ibDg.cjs"),zo=require("./link-portal-_tiDFZqh.cjs"),vo=require("@tempots/ui"),Po=require("./theme-Dt6lCAvY.cjs");function V(t){this.content=t}V.prototype={constructor:V,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?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,u=r.find(t),i=r.content.slice();return u==-1?i.push(n||t,e):(i[u+1]=e,n&&(i[u]=n)),new V(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new V(n)},addToStart:function(t,e){return new V([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new V(n)},addBefore:function(t,e,n){var r=this.remove(e),u=r.content.slice(),i=r.find(t);return u.splice(i==-1?u.length:i,0,e,n),new V(u)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=V.from(t),t.size?new V(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=V.from(t),t.size?new V(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=V.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};V.from=function(t){if(t instanceof V)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new V(e)};function Ni(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let u=t.child(r),i=e.child(r);if(u==i){n+=u.nodeSize;continue}if(!u.sameMarkup(i))return n;if(u.isText&&u.text!=i.text){for(let s=0;u.text[s]==i.text[s];s++)n++;return n}if(u.content.size||i.content.size){let s=Ni(u.content,i.content,n+1);if(s!=null)return s}n+=u.nodeSize}}function Ii(t,e,n,r){for(let u=t.childCount,i=e.childCount;;){if(u==0||i==0)return u==i?null:{a:n,b:r};let s=t.child(--u),o=e.child(--i),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let a=0,c=Math.min(s.text.length,o.text.length);for(;a<c&&s.text[s.text.length-a-1]==o.text[o.text.length-a-1];)a++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let a=Ii(s.content,o.content,n-1,r-1);if(a)return a}n-=l,r-=l}}class x{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,u=0,i){for(let s=0,o=0;o<n;s++){let l=this.content[s],a=o+l.nodeSize;if(a>e&&r(l,u+o,i||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,u+c)}o=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,u){let i="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let a=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?u?typeof u=="function"?u(o):u:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&a||o.isTextblock)&&r&&(s?s=!1:i+=r),i+=a},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,u=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(u[u.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)u.push(e.content[i]);return new x(u,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],u=0;if(n>e)for(let i=0,s=0;s<n;i++){let o=this.content[i],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),u+=o.nodeSize),s=l}return new x(r,u)}cutByIndex(e,n){return e==n?x.empty:e==0&&n==this.content.length?this:new x(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let u=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return u[e]=n,new x(u,i)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}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(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let u=this.content[n];e(u,r,n),r+=u.nodeSize}}findDiffStart(e,n=0){return Ni(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ii(this,e,n,r)}findIndex(e){if(e==0)return en(0,e);if(e==this.size)return en(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let u=this.child(n),i=r+u.nodeSize;if(i>=e)return i==e?en(n+1,i):en(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return x.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let n,r=0;for(let u=0;u<e.length;u++){let i=e[u];r+=i.nodeSize,u&&i.isText&&e[u-1].sameMarkup(i)?(n||(n=e.slice(0,u)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new x(n||e,r)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const Pn={index:0,offset:0};function en(t,e){return Pn.index=t,Pn.offset=e,Pn}function dn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!dn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!dn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class T{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let u=0;u<e.length;u++){let i=e[u];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,u));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,u)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&dn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let u=r.create(n.attrs);return r.checkAttrs(u.attrs),u}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return T.none;if(e instanceof T)return[e];let n=e.slice();return n.sort((r,u)=>r.type.rank-u.type.rank),n}}T.none=[];class hn extends Error{}class D{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Bi(this.content,e+this.openStart,n);return r&&new D(r,this.openStart,this.openEnd)}removeBetween(e,n){return new D(Ri(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return D.empty;let r=n.openStart||0,u=n.openEnd||0;if(typeof r!="number"||typeof u!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new D(x.fromJSON(e,n.content),r,u)}static maxOpen(e,n=!0){let r=0,u=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)u++;return new D(e,r,u)}}D.empty=new D(x.empty,0,0);function Ri(t,e,n){let{index:r,offset:u}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(u==e||i.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Ri(i.content,e-u-1,n-u-1)))}function Bi(t,e,n,r){let{index:u,offset:i}=t.findIndex(e),s=t.maybeChild(u);if(i==e||s.isText)return r&&!r.canReplace(u,u,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Bi(s.content,e-i-1,n,s);return o&&t.replaceChild(u,s.copy(o))}function Lo(t,e,n){if(n.openStart>t.depth)throw new hn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new hn("Inconsistent open depths");return zi(t,e,n,0)}function zi(t,e,n,r){let u=t.index(r),i=t.node(r);if(u==e.index(r)&&r<t.depth-n.openStart){let s=zi(t,e,n,r+1);return i.copy(i.content.replaceChild(u,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Ye(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=qo(n,t);return Ye(i,Pi(t,s,o,e,r))}else return Ye(i,pn(t,e,r))}function vi(t,e){if(!e.type.compatibleContent(t.type))throw new hn("Cannot join "+e.type.name+" onto "+t.type.name)}function pr(t,e,n){let r=t.node(n);return vi(r,e.node(n)),r}function Ge(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function wt(t,e,n,r){let u=(e||t).node(n),i=0,s=e?e.index(n):u.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ge(t.nodeAfter,r),i++));for(let o=i;o<s;o++)Ge(u.child(o),r);e&&e.depth==n&&e.textOffset&&Ge(e.nodeBefore,r)}function Ye(t,e){return t.type.checkContent(e),t.copy(e)}function Pi(t,e,n,r,u){let i=t.depth>u&&pr(t,e,u+1),s=r.depth>u&&pr(n,r,u+1),o=[];return wt(null,t,u,o),i&&s&&e.index(u)==n.index(u)?(vi(i,s),Ge(Ye(i,Pi(t,e,n,r,u+1)),o)):(i&&Ge(Ye(i,pn(t,e,u+1)),o),wt(e,n,u,o),s&&Ge(Ye(s,pn(n,r,u+1)),o)),wt(r,null,u,o),new x(o)}function pn(t,e,n){let r=[];if(wt(null,t,n,r),t.depth>n){let u=pr(t,e,n+1);Ge(Ye(u,pn(t,e,n+1)),r)}return wt(e,null,n,r),new x(r)}function qo(t,e){let n=e.depth-t.openStart,u=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)u=e.node(i).copy(x.from(u));return{start:u.resolveNoCache(t.openStart+n),end:u.resolveNoCache(u.content.size-t.openEnd-n)}}class Rt{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],u=e.child(n);return r?e.child(n).cut(r):u}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],u=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)u+=r.child(i).nodeSize;return u}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return T.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),u=e.maybeChild(n);if(!r){let o=r;r=u,u=o}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!u||!i[s].isInSet(u.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,u=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!u||!r[i].isInSet(u.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Li(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],u=0,i=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(i),a=i-l;if(r.push(s,o,u+l),!a||(s=s.child(o),s.isText))break;i=a-1,u+=l+1}return new Rt(n,r,i)}static resolveCached(e,n){let r=lu.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else lu.set(e,r=new Vo);let u=r.elts[r.i]=Rt.resolve(e,n);return r.i=(r.i+1)%$o,u}}class Vo{constructor(){this.elts=[],this.i=0}}const $o=12,lu=new WeakMap;class Li{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}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 Wo=Object.create(null);class xe{constructor(e,n,r,u=T.none){this.type=e,this.attrs=n,this.marks=u,this.content=r||x.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,u=0){this.content.nodesBetween(e,n,r,u,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,u){return this.content.textBetween(e,n,r,u)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&dn(this.attrs,n||e.defaultAttrs||Wo)&&T.sameSet(this.marks,r||T.none)}copy(e=null){return e==this.content?this:new xe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new xe(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return D.empty;let u=this.resolve(e),i=this.resolve(n),s=r?0:u.sharedDepth(n),o=u.start(s),a=u.node(s).content.cut(u.pos-o,i.pos-o);return new D(a,u.depth-s,i.depth-s)}replace(e,n,r){return Lo(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:u}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(u==e||n.isText)return n;e-=u+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let u=this.content.child(n-1);return{node:u,index:n-1,offset:r-u.nodeSize}}resolve(e){return Rt.resolveCached(this,e)}resolveNoCache(e){return Rt.resolve(this,e)}rangeHasMark(e,n,r){let u=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(u=!0),!u)),u}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),qi(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=x.empty,u=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,u,i),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=u;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,u){if(u&&!this.type.allowsMarks(u))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=T.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!T.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let u=x.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,u,r);return i.type.checkAttrs(i.attrs),i}}xe.prototype.text=void 0;class mn extends xe{constructor(e,n,r,u){if(super(e,n,null,u),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):qi(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new mn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new mn(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function qi(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class tt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Ho(e,n);if(r.next==null)return tt.empty;let u=Vi(r);r.next&&r.err("Unexpected trailing text");let i=Yo(Go(u));return Xo(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let u=this;for(let i=n;u&&i<r;i++)u=u.matchType(e.child(i).type);return u}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let u=[this];function i(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return x.from(o.map(a=>a.createAndFill()));for(let a=0;a<s.next.length;a++){let{type:c,next:f}=s.next[a];if(!(c.isText||c.hasRequiredAttrs())&&u.indexOf(f)==-1){u.push(f);let p=i(f,o.concat(c));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let u=r.shift(),i=u.match;if(i.matchType(e)){let s=[];for(let o=u;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:o,next:l}=i.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!u.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:u}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let u=0;u<r.next.length;u++)e.indexOf(r.next[u].next)==-1&&n(r.next[u].next)}return n(this),e.map((r,u)=>{let i=u+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
2
2
  `)}}tt.empty=new tt(!0);class Ho{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Vi(t){let e=[];do e.push(Jo(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Jo(t){let e=[];do e.push(jo(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function jo(t){let e=Zo(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=Uo(t,e);else break;return e}function au(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Uo(t,e){let n=au(t),r=n;return t.eat(",")&&(t.next!="}"?r=au(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Ko(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let u=[];for(let i in n){let s=n[i];s.isInGroup(e)&&u.push(s)}return u.length==0&&t.err("No node type or group '"+e+"' found"),u}function Zo(t){if(t.eat("(")){let e=Vi(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Ko(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Go(t){let e=[[]];return u(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,l){let a={term:l,to:o};return e[s].push(a),a}function u(s,o){s.forEach(l=>l.to=o)}function i(s,o){if(s.type=="choice")return s.exprs.reduce((l,a)=>l.concat(i(a,o)),[]);if(s.type=="seq")for(let l=0;;l++){let a=i(s.exprs[l],o);if(l==s.exprs.length-1)return a;u(a,o=n())}else if(s.type=="star"){let l=n();return r(o,l),u(i(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return u(i(s.expr,o),l),u(i(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(o)].concat(i(s.expr,o));if(s.type=="range"){let l=o;for(let a=0;a<s.min;a++){let c=n();u(i(s.expr,l),c),l=c}if(s.max==-1)u(i(s.expr,l),l);else for(let a=s.min;a<s.max;a++){let c=n();r(l,c),u(i(s.expr,l),c),l=c}return[r(l)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function $i(t,e){return e-t}function cu(t,e){let n=[];return r(e),n.sort($i);function r(u){let i=t[u];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(u);for(let s=0;s<i.length;s++){let{term:o,to:l}=i[s];!o&&n.indexOf(l)==-1&&r(l)}}}function Yo(t){let e=Object.create(null);return n(cu(t,0));function n(r){let u=[];r.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let a;for(let c=0;c<u.length;c++)u[c][0]==o&&(a=u[c][1]);cu(t,l).forEach(c=>{a||u.push([o,a=[]]),a.indexOf(c)==-1&&a.push(c)})})});let i=e[r.join(",")]=new tt(r.indexOf(t.length-1)>-1);for(let s=0;s<u.length;s++){let o=u[s][1].sort($i);i.next.push({type:u[s][0],next:e[o.join(",")]||n(o)})}return i}}function Xo(t,e){for(let n=0,r=[t];n<r.length;n++){let u=r[n],i=!u.validEnd,s=[];for(let o=0;o<u.next.length;o++){let{type:l,next:a}=u.next[o];s.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(a)==-1&&r.push(a)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Wi(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 Hi(t,e){let n=Object.create(null);for(let r in t){let u=e&&e[r];if(u===void 0){let i=t[r];if(i.hasDefault)u=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=u}return n}function Ji(t,e,n,r){for(let u in e)if(!(u in t))throw new RangeError(`Unsupported attribute ${u} for ${n} of type ${u}`);for(let u in t){let i=t[u];i.validate&&i.validate(e[u])}}function ji(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new el(t,r,e[r]);return n}let fu=class Ui{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ji(e,r.attrs),this.defaultAttrs=Wi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==tt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Hi(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new xe(this,this.computeAttrs(e),x.from(n),T.setFrom(r))}createChecked(e=null,n,r){return n=x.from(n),this.checkContent(n),new xe(this,this.computeAttrs(e),n,T.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=x.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let u=this.contentMatch.matchFragment(n),i=u&&u.fillBefore(x.empty,!0);return i?new xe(this,e,n.append(i),T.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ji(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:T.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new Ui(i,n,s));let u=n.spec.topNode||"doc";if(!r[u])throw new RangeError("Schema is missing its top node type ('"+u+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Qo(t,e,n){let r=n.split("|");return u=>{let i=u===null?"null":typeof u;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class el{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Qo(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class An{constructor(e,n,r,u){this.name=e,this.rank=n,this.schema=r,this.spec=u,this.attrs=ji(e,u.attrs),this.excluded=null;let i=Wi(this.attrs);this.instance=i?new T(this,i):null}create(e=null){return!e&&this.instance?this.instance:new T(this,Hi(this.attrs,e))}static compile(e,n){let r=Object.create(null),u=0;return e.forEach((i,s)=>r[i]=new An(i,u++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Ji(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class zr{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let u in e)n[u]=e[u];n.nodes=V.from(e.nodes),n.marks=V.from(e.marks||{}),this.nodes=fu.compile(this.spec.nodes,this),this.marks=An.compile(this.spec.marks,this);let r=Object.create(null);for(let u in this.nodes){if(u in this.marks)throw new RangeError(u+" can not be both a node and a mark");let i=this.nodes[u],s=i.spec.content||"",o=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=tt.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=o=="_"?null:o?du(this,o.split(" ")):o==""||!i.inlineContent?[]:null}for(let u in this.marks){let i=this.marks[u],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:du(this,s.split(" "))}this.nodeFromJSON=u=>xe.fromJSON(this,u),this.markFromJSON=u=>T.fromJSON(this,u),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,u){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof fu){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,u)}text(e,n){let r=this.nodes.text;return new mn(r,r.defaultAttrs,e,T.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function du(t,e){let n=[];for(let r=0;r<e.length;r++){let u=e[r],i=t.marks[u],s=i;if(i)n.push(i);else for(let o in t.marks){let l=t.marks[o];(u=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(u)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function tl(t){return t.tag!=null}function nl(t){return t.style!=null}class Bt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(u=>{if(tl(u))this.tags.push(u);else if(nl(u)){let i=/[^=]*/.exec(u.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(u)}}),this.normalizeLists=!this.tags.some(u=>{if(!/^(ul|ol)\b/.test(u.tag)||!u.node)return!1;let i=e.nodes[u.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new pu(this,n,!1);return r.addAll(e,T.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new pu(this,n,!0);return r.addAll(e,T.none,n.from,n.to),D.maxOpen(r.finish())}matchTag(e,n,r){for(let u=r?this.tags.indexOf(r)+1:0;u<this.tags.length;u++){let i=this.tags[u];if(il(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,u){for(let i=u?this.styles.indexOf(u)+1:0;i<this.styles.length;i++){let s=this.styles[i],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(u){let i=u.priority==null?50:u.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<i)break}n.splice(s,0,u)}for(let u in e.marks){let i=e.marks[u].spec.parseDOM;i&&i.forEach(s=>{r(s=mu(s)),s.mark||s.ignore||s.clearMark||(s.mark=u)})}for(let u in e.nodes){let i=e.nodes[u].spec.parseDOM;i&&i.forEach(s=>{r(s=mu(s)),s.node||s.ignore||s.mark||(s.node=u)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Bt(e,Bt.schemaRules(e)))}}const Ki={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},rl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Zi={ol:!0,ul:!0},zt=1,mr=2,Tt=4;function hu(t,e,n){return e!=null?(e?zt:0)|(e==="full"?mr:0):t&&t.whitespace=="pre"?zt|mr:n&~Tt}class tn{constructor(e,n,r,u,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=u,this.options=s,this.content=[],this.activeMarks=T.none,this.match=i||(s&Tt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(x.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,u;return(u=r.findWrapping(e.type))?(this.match=r,u):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&zt)){let r=this.content[this.content.length-1],u;if(r&&r.isText&&(u=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==u[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-u[0].length))}}let n=x.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(x.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ki.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class pu{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let u=n.topNode,i,s=hu(null,n.preserveWhitespace,0)|(r?Tt:0);u?i=new tn(u.type,u.attrs,T.none,!0,n.topMatch||u.type.contentMatch,s):r?i=new tn(null,null,T.none,!0,null,s):i=new tn(e.schema.topNodeType,null,T.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,u=this.top,i=u.options&mr?"full":this.localPreserveWS||(u.options&zt)>0,{schema:s}=this.parser;if(i==="full"||u.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
3
3
  `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(s.text(o[l]),n,!/\S/.test(o[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=u.content[u.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let u=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;Zi.hasOwnProperty(s)&&this.parser.normalizeLists&&ul(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:rl.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let a,c=this.needsBlock;if(Ki.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),a=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),a&&this.sync(i),this.needsBlock=c}else{let a=this.readStyles(e,n);a&&this.addElementByRule(e,l,a,l.consuming===!1?o:void 0)}this.localPreserveWS=u}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let u=0;u<this.parser.matchedStyles.length;u++){let i=this.parser.matchedStyles[u],s=r.getPropertyValue(i);if(s)for(let o=void 0;;){let l=this.parser.matchStyle(i,s,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(a=>!l.clearMark(a)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,r,u){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(u)this.addElement(e,r,u);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(o)&&this.open--}addAll(e,n,r,u){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=u==null?null:e.childNodes[u];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let u,i;for(let s=this.open,o=0;s>=0;s--){let l=this.nodes[s],a=l.findWrapping(e);if(a&&(!u||u.length>a.length+o)&&(u=a,i=l,!a.length))break;if(l.solid){if(r)break;o+=2}}if(!u)return null;this.sync(i);for(let s=0;s<u.length;s++)n=this.enterInner(u[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let u=this.findPlace(e,n,r);if(u){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=T.none;for(let o of u.concat(e.marks))(i.type?i.type.allowsMarkType(o.type):gu(o.type,e.type))&&(s=o.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,u){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,u)),i}enterInner(e,n,r,u=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=hu(e,i,s.options);s.options&Tt&&s.content.length==0&&(o|=Tt);let l=T.none;return r=r.filter(a=>(s.type?s.type.allowsMarkType(a.type):gu(a.type,e))?(l=a.addToSet(l),!1):!0),this.nodes.push(new tn(e,n,l,u,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=zt)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let u=r.length-1;u>=0;u--)e+=r[u].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let u=0;u<this.find.length;u++)this.find[u].pos==null&&e.nodeType==1&&e.contains(this.find[u].node)&&n.compareDocumentPosition(this.find[u].node)&(r?2:4)&&(this.find[u].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,u=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(u?0:1),s=(o,l)=>{for(;o>=0;o--){let a=n[o];if(a==""){if(o==n.length-1||o==0)continue;for(;l>=i;l--)if(s(o-1,l))return!0;return!1}else{let c=l>0||l==0&&u?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!c||c.name!=a&&!c.isInGroup(a))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function ul(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Zi.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function il(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function mu(t){let e={};for(let n in t)e[n]=t[n];return e}function gu(t,e){let n=e.schema.nodes;for(let r in n){let u=n[r];if(!u.allowsMarkType(t))continue;let i=[],s=o=>{i.push(o);for(let l=0;l<o.edgeCount;l++){let{type:a,next:c}=o.edge(l);if(a==e||i.indexOf(c)<0&&s(c))return!0}};if(s(u.contentMatch))return!0}}class yt{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ln(n).createDocumentFragment());let u=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let o=0,l=0;for(;o<i.length&&l<s.marks.length;){let a=s.marks[l];if(!this.marks[a.type.name]){l++;continue}if(!a.eq(i[o][0])||a.type.spec.spanning===!1)break;o++,l++}for(;o<i.length;)u=i.pop()[1];for(;l<s.marks.length;){let a=s.marks[l++],c=this.serializeMark(a,s.isInline,n);c&&(i.push([a,u]),u.appendChild(c.dom),u=c.contentDOM||c.dom)}}u.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:u}=on(Ln(n),this.nodes[e.type.name](e),null,e.attrs);if(u){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,u)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let u=e.marks.length-1;u>=0;u--){let i=this.serializeMark(e.marks[u],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let u=this.marks[e.type.name];return u&&on(Ln(r),u(e,n),null,e.attrs)}static renderSpec(e,n,r=null,u){return on(e,n,r,u)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new yt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=bu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return bu(e.marks)}}function bu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ln(t){return t.document||window.document}const xu=new WeakMap;function sl(t){let e=xu.get(t);return e===void 0&&xu.set(t,e=ol(t)),e}function ol(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let u=0;u<r.length;u++)n(r[u]);else for(let u in r)n(r[u])}return n(t),e}function on(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 u=e[0],i;if(typeof u!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=sl(r))&&i.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 s=u.indexOf(" ");s>0&&(n=u.slice(0,s),u=u.slice(s+1));let o,l=n?t.createElementNS(n,u):t.createElement(u),a=e[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let f in a)if(a[f]!=null){let p=f.indexOf(" ");p>0?l.setAttributeNS(f.slice(0,p),f.slice(p+1),a[f]):f=="style"&&l.style?l.style.cssText=a[f]:l.setAttribute(f,a[f])}}for(let f=c;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:d}=on(t,p,n,r);if(l.appendChild(h),d){if(o)throw new RangeError("Multiple content holes");o=d}}}return{dom:l,contentDOM:o}}const Gi=65535,Yi=Math.pow(2,16);function ll(t,e){return t+e*Yi}function ku(t){return t&Gi}function al(t){return(t-(t&Gi))/Yi}const Xi=1,Qi=2,ln=4,es=8;class gr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&es)>0}get deletedBefore(){return(this.delInfo&(Xi|ln))>0}get deletedAfter(){return(this.delInfo&(Qi|ln))>0}get deletedAcross(){return(this.delInfo&ln)>0}}class ee{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ee.empty)return ee.empty}recover(e){let n=0,r=ku(e);if(!this.inverted)for(let u=0;u<r;u++)n+=this.ranges[u*3+2]-this.ranges[u*3+1];return this.ranges[r*3]+n+al(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let u=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?u:0);if(l>e)break;let a=this.ranges[o+i],c=this.ranges[o+s],f=l+a;if(e<=f){let p=a?e==l?-1:e==f?1:n:n,h=l+u+(p<0?0:c);if(r)return h;let d=e==(n<0?l:f)?null:ll(o/3,e-l),m=e==l?Qi:e==f?Xi:ln;return(n<0?e!=l:e!=f)&&(m|=es),new gr(h,m,d)}u+=c-a}return r?e+u:new gr(e+u,0,null)}touches(e,n){let r=0,u=ku(n),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>e)break;let a=this.ranges[o+i],c=l+a;if(e<=c&&o==u*3)return!0;r+=this.ranges[o+s]-a}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let u=0,i=0;u<this.ranges.length;u+=3){let s=this.ranges[u],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i),a=this.ranges[u+n],c=this.ranges[u+r];e(o,o+a,l,l+c),i+=c-a}}invert(){return new ee(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ee.empty:new ee(e<0?[0,-e,0]:[0,0,e])}}ee.empty=new ee([]);class vt{constructor(e,n,r=0,u=e?e.length:0){this.mirror=n,this.from=r,this.to=u,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new vt(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let u=e.getMirror(n);this.appendMap(e._maps[n],u!=null&&u<n?r+u:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let u=e.getMirror(n);this.appendMap(e._maps[n].invert(),u!=null&&u>n?r-u-1:void 0)}}invert(){let e=new vt;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let u=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],o=s.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(o.recover);continue}}u|=o.delInfo,e=o.pos}return r?e:new gr(e,u,null)}}const qn=Object.create(null);class U{getMap(){return ee.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=qn[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in qn)throw new RangeError("Duplicate use of step JSON ID "+e);return qn[e]=n,n.prototype.jsonID=e,n}}class B{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new B(e,null)}static fail(e){return new B(null,e)}static fromReplace(e,n,r,u){try{return B.ok(e.replace(n,r,u))}catch(i){if(i instanceof hn)return B.fail(i.message);throw i}}}function vr(t,e,n){let r=[];for(let u=0;u<t.childCount;u++){let i=t.child(u);i.content.size&&(i=i.copy(vr(i.content,e,i))),i.isInline&&(i=e(i,n,u)),r.push(i)}return x.fromArray(r)}class Be extends U{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),u=r.node(r.sharedDepth(this.to)),i=new D(vr(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),u),n.openStart,n.openEnd);return B.fromReplace(e,this.from,this.to,i)}invert(){return new me(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Be(n.pos,r.pos,this.mark)}merge(e){return e instanceof Be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Be(n.from,n.to,e.markFromJSON(n.mark))}}U.jsonID("addMark",Be);class me extends U{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new D(vr(n.content,u=>u.mark(this.mark.removeFromSet(u.marks)),e),n.openStart,n.openEnd);return B.fromReplace(e,this.from,this.to,r)}invert(){return new Be(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new me(n.pos,r.pos,this.mark)}merge(e){return e instanceof me&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new me(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new me(n.from,n.to,e.markFromJSON(n.mark))}}U.jsonID("removeMark",me);class ze extends U{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return B.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return B.fromReplace(e,this.pos,this.pos+1,new D(x.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let u=0;u<n.marks.length;u++)if(!n.marks[u].isInSet(r))return new ze(this.pos,n.marks[u]);return new ze(this.pos,this.mark)}}return new nt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ze(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ze(n.pos,e.markFromJSON(n.mark))}}U.jsonID("addNodeMark",ze);class nt extends U{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return B.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return B.fromReplace(e,this.pos,this.pos+1,new D(x.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ze(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new nt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new nt(n.pos,e.markFromJSON(n.mark))}}U.jsonID("removeNodeMark",nt);class j extends U{constructor(e,n,r,u=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=u}apply(e){return this.structure&&br(e,this.from,this.to)?B.fail("Structure replace would overwrite content"):B.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ee([this.from,this.to-this.from,this.slice.size])}invert(e){return new j(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new j(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof j)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?D.empty:new D(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new j(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?D.empty:new D(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new j(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new j(n.from,n.to,D.fromJSON(e,n.slice),!!n.structure)}}U.jsonID("replace",j);class G extends U{constructor(e,n,r,u,i,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=u,this.slice=i,this.insert=s,this.structure=o}apply(e){if(this.structure&&(br(e,this.from,this.gapFrom)||br(e,this.gapTo,this.to)))return B.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return B.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?B.fromReplace(e,this.from,this.to,r):B.fail("Content does not fit in gap")}getMap(){return new ee([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new G(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),u=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||u<n.pos||i>r.pos?null:new G(n.pos,r.pos,u,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new G(n.from,n.to,n.gapFrom,n.gapTo,D.fromJSON(e,n.slice),n.insert,!!n.structure)}}U.jsonID("replaceAround",G);function br(t,e,n){let r=t.resolve(e),u=n-e,i=r.depth;for(;u>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,u--;if(u>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;u>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,u--}}return!1}function cl(t,e,n,r){let u=[],i=[],s,o;t.doc.nodesBetween(e,n,(l,a,c)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let p=Math.max(a,e),h=Math.min(a+l.nodeSize,n),d=r.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(d)||(s&&s.to==p&&s.mark.eq(f[m])?s.to=h:u.push(s=new me(p,h,f[m])));o&&o.to==p?o.to=h:i.push(o=new Be(p,h,r))}}),u.forEach(l=>t.step(l)),i.forEach(l=>t.step(l))}function fl(t,e,n,r){let u=[],i=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;i++;let l=null;if(r instanceof An){let a=s.marks,c;for(;c=r.isInSet(a);)(l||(l=[])).push(c),a=c.removeFromSet(a)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let a=Math.min(o+s.nodeSize,n);for(let c=0;c<l.length;c++){let f=l[c],p;for(let h=0;h<u.length;h++){let d=u[h];d.step==i-1&&f.eq(u[h].style)&&(p=d)}p?(p.to=a,p.step=i):u.push({style:f,from:Math.max(o,e),to:a,step:i})}}}),u.forEach(s=>t.step(new me(s.from,s.to,s.style)))}function Pr(t,e,n,r=n.contentMatch,u=!0){let i=t.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<i.childCount;l++){let a=i.child(l),c=o+a.nodeSize,f=r.matchType(a.type);if(!f)s.push(new j(o,c,D.empty));else{r=f;for(let p=0;p<a.marks.length;p++)n.allowsMarkType(a.marks[p].type)||t.step(new me(o,c,a.marks[p]));if(u&&a.isText&&n.whitespace!="pre"){let p,h=/\r?\n|\r/g,d;for(;p=h.exec(a.text);)d||(d=new D(x.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),s.push(new j(o+p.index,o+p.index+p[0].length,d))}}o=c}if(!r.validEnd){let l=r.fillBefore(x.empty,!0);t.replace(o,o,new D(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function dl(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function jt(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,u=0,i=0;;--r){let s=t.$from.node(r),o=t.$from.index(r)+u,l=t.$to.indexAfter(r)-i;if(r<t.depth&&s.canReplace(o,l,n))return r;if(r==0||s.type.spec.isolating||!dl(s,o,l))break;o&&(u=1),l<s.childCount&&(i=1)}return null}function hl(t,e,n){let{$from:r,$to:u,depth:i}=e,s=r.before(i+1),o=u.after(i+1),l=s,a=o,c=x.empty,f=0;for(let d=i,m=!1;d>n;d--)m||r.index(d)>0?(m=!0,c=x.from(r.node(d).copy(c)),f++):l--;let p=x.empty,h=0;for(let d=i,m=!1;d>n;d--)m||u.after(d+1)<u.end(d)?(m=!0,p=x.from(u.node(d).copy(p)),h++):a++;t.step(new G(l,a,s,o,new D(c.append(p),f,h),c.size-f,!0))}function ts(t,e,n=null,r=t){let u=pl(t,e),i=u&&ml(r,e);return i?u.map(yu).concat({type:e,attrs:n}).concat(i.map(yu)):null}function yu(t){return{type:t,attrs:null}}function pl(t,e){let{parent:n,startIndex:r,endIndex:u}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,u,s)?i:null}function ml(t,e){let{parent:n,startIndex:r,endIndex:u}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let a=r;l&&a<u;a++)l=l.matchType(n.child(a).type);return!l||!l.validEnd?null:s}function gl(t,e,n){let r=x.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(n[s].type.create(n[s].attrs,r))}let u=e.start,i=e.end;t.step(new G(u,i,u,i,new D(r,0,0),n.length,!0))}function bl(t,e,n,r,u){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let l=typeof u=="function"?u(s):u;if(s.isTextblock&&!s.hasMarkup(r,l)&&xl(t.doc,t.mapping.slice(i).map(o),r)){let a=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",d=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!d?a=!1:!h&&d&&(a=!0)}a===!1&&rs(t,s,o,i),Pr(t,t.mapping.slice(i).map(o,1),r,void 0,a===null);let c=t.mapping.slice(i),f=c.map(o,1),p=c.map(o+s.nodeSize,1);return t.step(new G(f,p,f+1,p-1,new D(x.from(r.create(l,null,s.marks)),0,0),1,!0)),a===!0&&ns(t,s,o,i),!1}})}function ns(t,e,n,r){e.forEach((u,i)=>{if(u.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(u.text);){let l=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function rs(t,e,n,r){e.forEach((u,i)=>{if(u.type==u.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`
5
5
  `))}})}function xl(t,e,n){let r=t.resolve(e),u=r.index();return r.parent.canReplaceWith(u,u+1,n)}function kl(t,e,n,r,u){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,u||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new G(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new D(x.from(s),0,0),1,!0))}function Ot(t,e,n=1,r){let u=t.resolve(e),i=u.depth-n,s=r&&r[r.length-1]||u.parent;if(i<0||u.parent.type.spec.isolating||!u.parent.canReplace(u.index(),u.parent.childCount)||!s.type.validContent(u.parent.content.cutByIndex(u.index(),u.parent.childCount)))return!1;for(let a=u.depth-1,c=n-2;a>i;a--,c--){let f=u.node(a),p=u.index(a);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(p,f.childCount),d=r&&r[c+1];d&&(h=h.replaceChild(0,d.type.create(d.attrs)));let m=r&&r[c]||f;if(!f.canReplace(p+1,f.childCount)||!m.type.validContent(h))return!1}let o=u.indexAfter(i),l=r&&r[0];return u.node(i).canReplaceWith(o,o,l?l.type:u.node(i+1).type)}function yl(t,e,n=1,r){let u=t.doc.resolve(e),i=x.empty,s=x.empty;for(let o=u.depth,l=u.depth-n,a=n-1;o>l;o--,a--){i=x.from(u.node(o).copy(i));let c=r&&r[a];s=x.from(c?c.type.create(c.attrs,s):u.node(o).copy(s))}t.step(new j(e,e,new D(i.append(s),n,n),!0))}function Lr(t,e){let n=t.resolve(e),r=n.index();return Dl(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Cl(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let u=0;u<e.childCount;u++){let i=e.child(u),s=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function Dl(t,e){return!!(t&&e&&!t.isLeaf&&Cl(t,e))}function _l(t,e,n){let r=null,{linebreakReplacement:u}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(u&&s.inlineContent){let c=s.whitespace=="pre",f=!!s.contentMatch.matchType(u);c&&!f?r=!1:!c&&f&&(r=!0)}let o=t.steps.length;if(r===!1){let c=t.doc.resolve(e+n);rs(t,c.node(),c.before(),o)}s.inlineContent&&Pr(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let l=t.mapping.slice(o),a=l.map(e-n);if(t.step(new j(a,l.map(e+n,-1),D.empty,!0)),r===!0){let c=t.doc.resolve(a);ns(t,c.node(),c.before(),t.steps.length)}return t}function El(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 u=r.depth-1;u>=0;u--){let i=r.index(u);if(r.node(u).canReplaceWith(i,i,n))return r.before(u+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let u=r.depth-1;u>=0;u--){let i=r.indexAfter(u);if(r.node(u).canReplaceWith(i,i,n))return r.after(u+1);if(i<r.node(u).childCount)return null}return null}function Sl(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let u=n.content;for(let i=0;i<n.openStart;i++)u=u.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let s=r.depth;s>=0;s--){let o=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(o>0?1:0),a=r.node(s),c=!1;if(i==1)c=a.canReplace(l,l,u);else{let f=a.contentMatchAt(l).findWrapping(u.firstChild.type);c=f&&a.canReplaceWith(l,l,f[0])}if(c)return o==0?r.pos:o<0?r.before(s+1):r.after(s+1)}return null}function qr(t,e,n=e,r=D.empty){if(e==n&&!r.size)return null;let u=t.resolve(e),i=t.resolve(n);return us(u,i,r)?new j(e,n,r):new Al(u,i,r).fit()}function us(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Al{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let u=0;u<=e.depth;u++){let i=e.node(u);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(u))})}for(let u=e.depth;u>0;u--)this.placed=x.from(e.node(u).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,u=this.close(e<0?this.$to:r.doc.resolve(e));if(!u)return null;let i=this.placed,s=r.depth,o=u.depth;for(;s&&o&&i.childCount==1;)i=i.firstChild.content,s--,o--;let l=new D(i,s,o);return e>-1?new G(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new j(r.pos,u.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,u=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(u=0),i.type.spec.isolating&&u<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let u,i=null;r?(i=Vn(this.unplaced.content,r-1).firstChild,u=i.content):u=this.unplaced.content;let s=u.firstChild;for(let o=this.depth;o>=0;o--){let{type:l,match:a}=this.frontier[o],c,f=null;if(n==1&&(s?a.matchType(s.type)||(f=a.fillBefore(x.from(s),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:o,parent:i,inject:f};if(n==2&&s&&(c=a.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:o,parent:i,wrap:c};if(i&&a.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,u=Vn(e,n);return!u.childCount||u.firstChild.isLeaf?!1:(this.unplaced=new D(e,n+1,Math.max(r,u.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,u=Vn(e,n);if(u.childCount<=1&&n>0){let i=e.size-n<=n+u.size;this.unplaced=new D(St(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new D(St(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:u,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,o=r?r.content:s.content,l=s.openStart-e,a=0,c=[],{match:f,type:p}=this.frontier[n];if(u){for(let m=0;m<u.childCount;m++)c.push(u.child(m));f=f.matchFragment(u)}let h=o.size+e-(s.content.size-s.openEnd);for(;a<o.childCount;){let m=o.child(a),g=f.matchType(m.type);if(!g)break;a++,(a>1||l==0||m.content.size)&&(f=g,c.push(is(m.mark(p.allowedMarks(m.marks)),a==1?l:0,a==o.childCount?h:-1)))}let d=a==o.childCount;d||(h=-1),this.placed=At(this.placed,n,x.from(c)),this.frontier[n].match=f,d&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=o;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=d?e==0?D.empty:new D(St(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new D(St(s.content,e,a),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!$n(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,u=this.$to.after(r);for(;r>1&&u==this.$to.end(--r);)++u;return u}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:u}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=$n(e,n,u,r,i);if(s){for(let o=n-1;o>=0;o--){let{match:l,type:a}=this.frontier[o],c=$n(e,o,a,l,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=At(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let u=e.node(r),i=u.type.contentMatch.fillBefore(u.content,!0,e.index(r));this.openFrontierNode(u.type,u.attrs,i)}return e}openFrontierNode(e,n=null,r){let u=this.frontier[this.depth];u.match=u.match.matchType(e),this.placed=At(this.placed,this.depth,x.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(x.empty,!0);n.childCount&&(this.placed=At(this.placed,this.frontier.length,n))}}function St(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(St(t.firstChild.content,e-1,n)))}function At(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(At(t.lastChild.content,e-1,n)))}function Vn(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function is(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,is(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(x.empty,!0)))),t.copy(r)}function $n(t,e,n,r,u){let i=t.node(e),s=u?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let o=r.fillBefore(i.content,!0,s);return o&&!Ml(n,i.content,s)?o:null}function Ml(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function wl(t){return t.spec.defining||t.spec.definingForContent}function Tl(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let u=t.doc.resolve(e),i=t.doc.resolve(n);if(us(u,i,r))return t.step(new j(e,n,r));let s=ls(u,i);s[s.length-1]==0&&s.pop();let o=-(u.depth+1);s.unshift(o);for(let p=u.depth,h=u.pos-1;p>0;p--,h--){let d=u.node(p).type.spec;if(d.defining||d.definingAsContext||d.isolating)break;s.indexOf(p)>-1?o=p:u.before(p)==h&&s.splice(1,0,-p)}let l=s.indexOf(o),a=[],c=r.openStart;for(let p=r.content,h=0;;h++){let d=p.firstChild;if(a.push(d),h==r.openStart)break;p=d.content}for(let p=c-1;p>=0;p--){let h=a[p],d=wl(h.type);if(d&&!h.sameMarkup(u.node(Math.abs(o)-1)))c=p;else if(d||!h.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let h=(p+c+1)%(r.openStart+1),d=a[h];if(d)for(let m=0;m<s.length;m++){let g=s[(m+l)%s.length],b=!0;g<0&&(b=!1,g=-g);let k=u.node(g-1),y=u.index(g-1);if(k.canReplaceWith(y,y,d.type,d.marks))return t.replace(u.before(g),b?i.after(g):n,new D(ss(r.content,0,r.openStart,h),h,r.openEnd))}}let f=t.steps.length;for(let p=s.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>f));p--){let h=s[p];h<0||(e=u.before(h),n=i.after(h))}}function ss(t,e,n,r,u){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(ss(i.content,e+1,n,r,i)))}if(e>r){let i=u.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(x.empty,!0))}return t}function Ol(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let u=El(t.doc,e,r.type);u!=null&&(e=n=u)}t.replaceRange(e,n,new D(x.from(r),0,0))}function Fl(t,e,n){let r=t.doc.resolve(e),u=t.doc.resolve(n),i=ls(r,u);for(let s=0;s<i.length;s++){let o=i[s],l=s==i.length-1;if(l&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),u.end(o));if(o>0&&(l||r.node(o-1).canReplace(r.index(o-1),u.indexAfter(o-1))))return t.delete(r.before(o),u.after(o))}for(let s=1;s<=r.depth&&s<=u.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&u.end(s)-n!=u.depth-s&&r.start(s-1)==u.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),u.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function ls(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let u=r;u>=0;u--){let i=t.start(u);if(i<t.pos-(t.depth-u)||e.end(u)>e.pos+(e.depth-u)||t.node(u).type.spec.isolating||e.node(u).type.spec.isolating)break;(i==e.start(u)||u==t.depth&&u==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&u&&e.start(u-1)==i-1)&&n.push(u)}return n}class ft extends U{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return B.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let u=n.type.create(r,null,n.marks);return B.fromReplace(e,this.pos,this.pos+1,new D(x.from(u),0,n.isLeaf?0:1))}getMap(){return ee.empty}invert(e){return new ft(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ft(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ft(n.pos,n.attr,n.value)}}U.jsonID("attr",ft);class Pt extends U{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let u in e.attrs)n[u]=e.attrs[u];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return B.ok(r)}getMap(){return ee.empty}invert(e){return new Pt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Pt(n.attr,n.value)}}U.jsonID("docAttr",Pt);let pt=class extends Error{};pt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};pt.prototype=Object.create(Error.prototype);pt.prototype.constructor=pt;pt.prototype.name="TransformError";class Nl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new vt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new pt(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=D.empty){let u=qr(this.doc,e,n,r);return u&&this.step(u),this}replaceWith(e,n,r){return this.replace(e,n,new D(x.from(r),0,0))}delete(e,n){return this.replace(e,n,D.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Tl(this,e,n,r),this}replaceRangeWith(e,n,r){return Ol(this,e,n,r),this}deleteRange(e,n){return Fl(this,e,n),this}lift(e,n){return hl(this,e,n),this}join(e,n=1){return _l(this,e,n),this}wrap(e,n){return gl(this,e,n),this}setBlockType(e,n=e,r,u=null){return bl(this,e,n,r,u),this}setNodeMarkup(e,n,r=null,u){return kl(this,e,n,r,u),this}setNodeAttribute(e,n,r){return this.step(new ft(e,n,r)),this}setDocAttribute(e,n){return this.step(new Pt(e,n)),this}addNodeMark(e,n){return this.step(new ze(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof T)n.isInSet(r.marks)&&this.step(new nt(e,n));else{let u=r.marks,i,s=[];for(;i=n.isInSet(u);)s.push(new nt(e,i)),u=i.removeFromSet(u);for(let o=s.length-1;o>=0;o--)this.step(s[o])}return this}split(e,n=1,r){return yl(this,e,n,r),this}addMark(e,n,r){return cl(this,e,n,r),this}removeMark(e,n,r){return fl(this,e,n,r),this}clearIncompatible(e,n,r){return Pr(this,e,n,r),this}}const Wn=Object.create(null);class O{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Il(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=D.empty){let r=n.content.lastChild,u=null;for(let o=0;o<n.openEnd;o++)u=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:a}=s[o],c=e.mapping.slice(i);e.replaceRange(c.map(l.pos),c.map(a.pos),o?D.empty:n),o==0&&_u(e,i,(r?r.isInline:u&&u.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,u=this.ranges;for(let i=0;i<u.length;i++){let{$from:s,$to:o}=u[i],l=e.mapping.slice(r),a=l.map(s.pos),c=l.map(o.pos);i?e.deleteRange(a,c):(e.replaceRangeWith(a,c,n),_u(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let u=e.parent.inlineContent?new F(e):at(e.node(0),e.parent,e.pos,e.index(),n,r);if(u)return u;for(let i=e.depth-1;i>=0;i--){let s=n<0?at(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):at(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new te(e.node(0))}static atStart(e){return at(e,e,0,0,1)||new te(e)}static atEnd(e){return at(e,e,e.content.size,e.childCount,-1)||new te(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Wn[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Wn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Wn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}}O.prototype.visible=!0;class Il{constructor(e,n){this.$from=e,this.$to=n}}let Cu=!1;function Du(t){!Cu&&!t.parent.inlineContent&&(Cu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class F extends O{constructor(e,n=e){Du(e),Du(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return O.near(r);let u=e.resolve(n.map(this.anchor));return new F(u.parent.inlineContent?u:r,r)}replace(e,n=D.empty){if(super.replace(e,n),n==D.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof F&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Mn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new F(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let u=e.resolve(n);return new this(u,r==n?u:e.resolve(r))}static between(e,n,r){let u=e.pos-n.pos;if((!r||u)&&(r=u>=0?1:-1),!n.parent.inlineContent){let i=O.findFrom(n,r,!0)||O.findFrom(n,-r,!0);if(i)n=i.$head;else return O.near(n,r)}return e.parent.inlineContent||(u==0?e=n:(e=(O.findFrom(e,-r,!0)||O.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=u<0&&(e=n))),new F(e,n)}}O.jsonID("text",F);class Mn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Mn(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}}class A extends O{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:u}=n.mapResult(this.anchor),i=e.resolve(u);return r?O.near(i):new A(i)}content(){return new D(x.from(this.node),0,0)}eq(e){return e instanceof A&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Vr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new A(e.resolve(n.anchor))}static create(e,n){return new A(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}A.prototype.visible=!1;O.jsonID("node",A);class Vr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Mn(r,r):new Vr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&A.isSelectable(r)?new A(n):O.near(n)}}class te extends O{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=D.empty){if(n==D.empty){e.delete(0,e.doc.content.size);let r=O.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new te(e)}map(e){return new te(e)}eq(e){return e instanceof te}getBookmark(){return Rl}}O.jsonID("all",te);const Rl={map(){return this},resolve(t){return new te(t)}};function at(t,e,n,r,u,i=!1){if(e.inlineContent)return F.create(t,n);for(let s=r-(u>0?0:1);u>0?s<e.childCount:s>=0;s+=u){let o=e.child(s);if(o.isAtom){if(!i&&A.isSelectable(o))return A.create(t,n-(u<0?o.nodeSize:0))}else{let l=at(t,o,n+u,u<0?o.childCount:0,u,i);if(l)return l}n+=o.nodeSize*u}return null}function _u(t,e,n){let r=t.steps.length-1;if(r<e)return;let u=t.steps[r];if(!(u instanceof j||u instanceof G))return;let i=t.mapping.maps[r],s;i.forEach((o,l,a,c)=>{s==null&&(s=c)}),t.setSelection(O.near(t.doc.resolve(s),n))}const Eu=1,nn=2,Su=4;class Bl extends Nl{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Eu)&~nn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Eu)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=nn,this}ensureMarks(e){return T.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&nn)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~nn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||T.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let u=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(u.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,u.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(O.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Su,this}get scrolledIntoView(){return(this.updated&Su)>0}}function Au(t,e){return!e||!t?t:t.bind(e)}class Mt{constructor(e,n,r){this.name=e,this.init=Au(n.init,r),this.apply=Au(n.apply,r)}}const zl=[new Mt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Mt("selection",{init(t,e){return t.selection||O.atStart(e.doc)},apply(t){return t.selection}}),new Mt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Mt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Hn{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=zl.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Mt(r.key,r.spec.state,r))})}}class Ue{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let u=this.config.plugins[r];if(u.spec.filterTransaction&&!u.spec.filterTransaction.call(u,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),u=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=u?u[s].n:0,a=u?u[s].state:this,c=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,a,r);if(c&&r.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",e),!u){u=[];for(let f=0;f<this.config.plugins.length;f++)u.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(c),r=r.applyInner(c),i=!0}u&&(u[s]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Ue(this.config),r=this.config.fields;for(let u=0;u<r.length;u++){let i=r[u];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new Bl(this)}static create(e){let n=new Hn(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ue(n);for(let u=0;u<n.fields.length;u++)r[n.fields[u].name]=n.fields[u].init(e,r);return r}reconfigure(e){let n=new Hn(this.schema,e.plugins),r=n.fields,u=new Ue(n);for(let i=0;i<r.length;i++){let s=r[i].name;u[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,u)}return u}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let u=e[r],i=u.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(u,this[u.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let u=new Hn(e.schema,e.plugins),i=new Ue(u);return u.fields.forEach(s=>{if(s.name=="doc")i.doc=xe.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=O.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let l=r[o],a=l.spec.state;if(l.key==s.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){i[s.name]=a.fromJSON.call(l,e,n[o],i);return}}i[s.name]=s.init(e,i)}}),i}}function as(t,e,n){for(let r in t){let u=t[r];u instanceof Function?u=u.bind(e):r=="handleDOMEvents"&&(u=as(u,e,{})),n[r]=u}return n}class $r{constructor(e){this.spec=e,this.props={},e.props&&as(e.props,this,this.props),this.key=e.key?e.key.key:cs("plugin")}getState(e){return e[this.key]}}const Jn=Object.create(null);function cs(t){return t in Jn?t+"$"+ ++Jn[t]:(Jn[t]=0,t+"$")}class fs{constructor(e="key"){this.key=cs(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ds=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function vl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Pl=(t,e,n)=>{let r=vl(t,n);if(!r)return!1;let u=hs(r);if(!u){let s=r.blockRange(),o=s&&jt(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let i=u.nodeBefore;if(ms(t,u,e,-1))return!0;if(r.parent.content.size==0&&(mt(i,"end")||A.isSelectable(i)))for(let s=r.depth;;s--){let o=qr(t.doc,r.before(s),r.after(s),D.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(mt(i,"end")?O.findFrom(l.doc.resolve(l.mapping.map(u.pos,-1)),-1):A.create(l.doc,u.pos-i.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&u.depth==r.depth-1?(e&&e(t.tr.delete(u.pos-i.nodeSize,u.pos).scrollIntoView()),!0):!1};function mt(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Ll=(t,e,n)=>{let{$head:r,empty:u}=t.selection,i=r;if(!u)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=hs(r)}let s=i&&i.nodeBefore;return!s||!A.isSelectable(s)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function hs(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 ql(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Vl=(t,e,n)=>{let r=ql(t,n);if(!r)return!1;let u=ps(r);if(!u)return!1;let i=u.nodeAfter;if(ms(t,u,e,1))return!0;if(r.parent.content.size==0&&(mt(i,"start")||A.isSelectable(i))){let s=qr(t.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size<s.to-s.from){if(e){let o=t.tr.step(s);o.setSelection(mt(i,"start")?O.findFrom(o.doc.resolve(o.mapping.map(u.pos)),1):A.create(o.doc,o.mapping.map(u.pos))),e(o.scrollIntoView())}return!0}}return i.isAtom&&u.depth==r.depth-1?(e&&e(t.tr.delete(u.pos,u.pos+i.nodeSize).scrollIntoView()),!0):!1},$l=(t,e,n)=>{let{$head:r,empty:u}=t.selection,i=r;if(!u)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=ps(r)}let s=i&&i.nodeAfter;return!s||!A.isSelectable(s)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,i.pos)).scrollIntoView()),!0)};function ps(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 Wl=(t,e)=>{let{$from:n,$to:r}=t.selection,u=n.blockRange(r),i=u&&jt(u);return i==null?!1:(e&&e(t.tr.lift(u,i).scrollIntoView()),!0)},Hl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
6
- `).scrollIntoView()),!0)};function Wr(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 Jl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let u=n.node(-1),i=n.indexAfter(-1),s=Wr(u.contentMatchAt(i));if(!s||!u.canReplaceWith(i,i,s))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,s.createAndFill());l.setSelection(O.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},jl=(t,e)=>{let n=t.selection,{$from:r,$to:u}=n;if(n instanceof te||r.parent.inlineContent||u.parent.inlineContent)return!1;let i=Wr(u.parent.contentMatchAt(u.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&u.index()<u.parent.childCount?r:u).pos,o=t.tr.insert(s,i.createAndFill());o.setSelection(F.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},Ul=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ot(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),u=r&&jt(r);return u==null?!1:(e&&e(t.tr.lift(r,u).scrollIntoView()),!0)};function Kl(t){return(e,n)=>{let{$from:r,$to:u}=e.selection;if(e.selection instanceof A&&e.selection.node.isBlock)return!r.parentOffset||!Ot(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,o,l=!1,a=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),a=r.start(h)==r.pos-(r.depth-h),o=Wr(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(l&&o?{type:o}:null),s=h;break}else{if(h==1)return!1;i.unshift(null)}let c=e.tr;(e.selection instanceof F||e.selection instanceof te)&&c.deleteSelection();let f=c.mapping.map(r.pos),p=Ot(c.doc,f,i.length,i);if(p||(i[0]=o?{type:o}:null,p=Ot(c.doc,f,i.length,i)),!p)return!1;if(c.split(f,i.length,i),!l&&a&&r.node(s).type!=o){let h=c.mapping.map(r.before(s)),d=c.doc.resolve(h);o&&r.node(s-1).canReplaceWith(d.index(),d.index()+1,o)&&c.setNodeMarkup(c.mapping.map(r.before(s)),o)}return n&&n(c.scrollIntoView()),!0}}const Zl=Kl(),Gl=(t,e)=>(e&&e(t.tr.setSelection(new te(t.doc))),!0);function Yl(t,e,n){let r=e.nodeBefore,u=e.nodeAfter,i=e.index();return!r||!u||!r.type.compatibleContent(u.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(u.isTextblock||Lr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ms(t,e,n,r){let u=e.nodeBefore,i=e.nodeAfter,s,o,l=u.type.spec.isolating||i.type.spec.isolating;if(!l&&Yl(t,e,n))return!0;let a=!l&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(s=(o=u.contentMatchAt(u.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,d=x.empty;for(let b=s.length-1;b>=0;b--)d=x.from(s[b].create(null,d));d=x.from(u.copy(d));let m=t.tr.step(new G(e.pos-1,h,e.pos,h,new D(d,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==u.type&&Lr(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let c=i.type.spec.isolating||r>0&&l?null:O.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),p=f&&jt(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(a&&mt(i,"start",!0)&&mt(u,"end")){let h=u,d=[];for(;d.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let b=x.empty;for(let y=d.length-1;y>=0;y--)b=x.from(d[y].copy(b));let k=t.tr.step(new G(e.pos-d.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new D(b,d.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function gs(t){return function(e,n){let r=e.selection,u=t<0?r.$from:r.$to,i=u.depth;for(;u.node(i).isInline;){if(!i)return!1;i--}return u.node(i).isTextblock?(n&&n(e.tr.setSelection(F.create(e.doc,t<0?u.start(i):u.end(i)))),!0):!1}}const Xl=gs(-1),Ql=gs(1);function ea(t,e=null){return function(n,r){let{$from:u,$to:i}=n.selection,s=u.blockRange(i),o=s&&ts(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function xr(t,e=null){return function(n,r){let u=!1;for(let i=0;i<n.selection.ranges.length&&!u;i++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[i];n.doc.nodesBetween(s,o,(l,a)=>{if(u)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)u=!0;else{let c=n.doc.resolve(a),f=c.index();u=c.parent.canReplaceWith(f,f+1,t)}})}if(!u)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];i.setBlockType(o,l,t,e)}r(i.scrollIntoView())}return!0}}function ta(t,e,n,r){for(let u=0;u<e.length;u++){let{$from:i,$to:s}=e[u],o=i.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(i.pos,s.pos,(l,a)=>{if(o)return!1;o=l.inlineContent&&l.type.allowsMarkType(n)}),o)return!0}return!1}function an(t,e=null,n){return function(r,u){let{empty:i,$cursor:s,ranges:o}=r.selection;if(i&&!s||!ta(r.doc,o,t))return!1;if(u)if(s)t.isInSet(r.storedMarks||s.marks())?u(r.tr.removeStoredMark(t)):u(r.tr.addStoredMark(t.create(e)));else{let l,a=r.tr;l=!o.some(c=>r.doc.rangeHasMark(c.$from.pos,c.$to.pos,t));for(let c=0;c<o.length;c++){let{$from:f,$to:p}=o[c];if(!l)a.removeMark(f.pos,p.pos,t);else{let h=f.pos,d=p.pos,m=f.nodeAfter,g=p.nodeBefore,b=m&&m.isText?/^\s*/.exec(m.text)[0].length:0,k=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;h+b<d&&(h+=b,d-=k),a.addMark(h,d,t.create(e))}}u(a.scrollIntoView())}return!0}}function Hr(...t){return function(e,n,r){for(let u=0;u<t.length;u++)if(t[u](e,n,r))return!0;return!1}}let jn=Hr(ds,Pl,Ll),Mu=Hr(ds,Vl,$l);const Se={Enter:Hr(Hl,jl,Ul,Zl),"Mod-Enter":Jl,Backspace:jn,"Mod-Backspace":jn,"Shift-Backspace":jn,Delete:Mu,"Mod-Delete":Mu,"Mod-a":Gl},bs={"Ctrl-h":Se.Backspace,"Alt-Backspace":Se["Mod-Backspace"],"Ctrl-d":Se.Delete,"Ctrl-Alt-Backspace":Se["Mod-Delete"],"Alt-Delete":Se["Mod-Delete"],"Alt-d":Se["Mod-Delete"],"Ctrl-a":Xl,"Ctrl-e":Ql};for(let t in Se)bs[t]=Se[t];const na=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,ra=na?bs:Se;function xs(t,e){return ks(t,e)!=null}function ks(t,e){const{from:n,$from:r,to:u,empty:i}=t.selection;if(!e)return null;if(i){if(t.storedMarks){const c=t.storedMarks.find(f=>f.type.name===e.name);if(c!=null)return c}const l=r.marks().find(c=>c.type.name===e.name);if(l!=null)return l;const a=r.nodeAfter;if(a&&a.marks){const c=a.marks.find(f=>f.type.name===e.name);if(c!=null)return c}return null}let s=null;return t.doc.nodesBetween(n,u,o=>{if(s!=null)return!1;if(o.marks){const l=o.marks.find(a=>a.type.name===e.name);if(l!=null)return s=l,!1}}),s}function cn(t,e,n){return t.map(()=>{const r=e.value,u=r.state.schema.marks[n];return xs(r.state,u)})}function ua(t,e,n){const{$from:r}=t.selection;for(let i=r.depth;i>0;i--){const s=r.node(i);if(s.type.name===e.name)return n!=null?Object.keys(n).every(o=>s.attrs[o]===n[o]):!0}const u=t.doc.nodeAt(r.pos);return u&&u.type.name===e.name?n!=null?Object.keys(n).every(i=>u.attrs[i]===n[i]):!0:!1}function Dt(t,e,n,r){return t.map(()=>{const u=e.value,i=u.state.schema.nodes[n];return i?ua(u.state,i,r):!1})}function he({active:t,display:e,onClick:n,disabled:r,label:u,icon:i,size:s}){return S.When(e,()=>It.ToolbarButton({onClick:n,disabled:r,variant:t.map(o=>o?"filled":"light"),size:s},S.attr.title(u),Br.Icon({icon:i,size:s})))}function ia(t,e){const n=t.state.schema.marks.link;if(n==null)return;const{from:r,to:u}=t.state.selection,i=t.state.tr.addMark(r,u,n.create({href:e,title:null}));t.dispatch(i),t.focus()}function ys(t){const{state:e}=t,{$from:n,$to:r}=e.selection;if(!Cs(e))return null;let u=n.pos,i=r.pos;const s=e.doc;for(;u>0&&s.resolve(u-1).nodeAfter?.marks?.some(a=>a.type.name==="link");)u--;for(;i<s.content.size&&s.resolve(i).nodeAfter?.marks?.some(a=>a.type.name==="link");)i++;return{start:u,end:i}}function sa(t,e){const n=t.state.schema.marks.link;if(n==null)return;const r=ys(t);if(r==null)return;const{start:u,end:i}=r,s=t.state.tr.removeMark(u,i,n).addMark(u,i,n.create({href:e,title:null}));t.dispatch(s)}function oa(t){const e=t.state.schema.marks.link;if(e==null)return;const n=ys(t);if(n==null)return;const{start:r,end:u}=n,i=t.state.tr.removeMark(r,u,e);t.dispatch(i),t.focus()}function Cs(t){return xs(t,t.schema.marks.link)}function la({stateUpdate:t,view:e,isReadOnly:n,label:r,linkUrlPlaceholder:u,size:i}){const s=S.prop(null);s.on(l=>{l!=null&&sa(e.value,l)});const o=t.on(()=>{const l=ks(e.value.state,e.value.state.schema.marks.link);l!=null?s.set(l.attrs.href??""):s.set(null)});return S.Fragment(S.OnDispose(o),It.ToolbarGroup(he({display:S.signal(!0),active:cn(t,e,"link"),disabled:n,label:r,icon:"mdi:link-variant",size:i,onClick:()=>{const l=e.value.state;Cs(l)?(oa(e.value),s.set(null)):(ia(e.value,""),s.set(""))}}),S.Ensure(s,l=>Br.TextInput({value:l,autofocus:!0,onInput:s.set,placeholder:u,size:i}))),S.Ensure(s,l=>It.ToolbarButton({disabled:l.map(a=>a.trim()===""),variant:"text",onClick:()=>{const a=s.value;a&&window.open(a,"_blank")},size:i},"go")))}function rn({display:t},...e){return S.When(S.computedOf(...t)((...n)=>n.some(Boolean)),()=>It.ToolbarGroup(...e))}function Ds({view:t,stateUpdate:e,features:n,readOnly:r=S.signal(!1),size:u="sm"}){return S.Ensure(t,i=>S.Use(Br.BeatUII18n,s=>{const o=s.$.prosemirror,l=i;return It.Toolbar(rn({display:[n.$.bold,n.$.italic,n.$.code]},he({active:cn(e,l,"strong"),display:n.$.bold,onClick:()=>Un(l.value,"strong"),disabled:r,label:o.$.bold,icon:"mdi:format-bold",size:u}),he({active:cn(e,l,"em"),display:n.$.italic,onClick:()=>Un(l.value,"em"),disabled:r,label:o.$.italic,icon:"mdi:format-italic",size:u}),he({active:cn(e,l,"code"),display:n.$.code,onClick:()=>Un(l.value,"code"),disabled:r,label:o.$.code,icon:"mdi:code-tags",size:u})),rn({display:[n.$.headings]},S.Repeat(n.$.headerLevels.map(a=>Math.min(Math.max(a,1),6)),({counter:a})=>he({active:Dt(e,l,"heading",{level:a}),display:n.$.headings,onClick:()=>aa(l.value,a),disabled:r,label:o.map(c=>c.heading(a)),icon:`mdi:format-header-${a}`,size:u}))),rn({display:[n.$.bulletList,n.$.orderedList]},he({active:Dt(e,l,"bullet_list"),display:n.$.bulletList,onClick:()=>wu(l.value,"bullet_list"),disabled:r,label:o.$.bulletList,icon:"mdi:format-list-bulleted",size:u}),he({active:Dt(e,l,"ordered_list"),display:n.$.orderedList,onClick:()=>wu(l.value,"ordered_list"),disabled:r,label:o.$.orderedList,icon:"mdi:format-list-numbered",size:u})),rn({display:[n.$.blockquote,n.$.codeBlock,n.$.horizontalRule]},he({active:Dt(e,l,"blockquote"),display:n.$.blockquote,onClick:()=>ca(l.value),disabled:r,label:o.$.blockquote,icon:"mdi:format-quote-close",size:u}),he({active:Dt(e,l,"code_block"),display:n.$.codeBlock,onClick:()=>fa(l.value),disabled:r,label:o.$.codeBlock,icon:"mdi:code-braces",size:u}),he({active:S.signal(!1),display:n.$.horizontalRule,onClick:()=>da(l.value),disabled:r,label:o.$.horizontalRule,icon:"mdi:minus",size:u})),S.When(n.$.links,()=>la({stateUpdate:e,view:l,isReadOnly:r,label:o.$.link,linkUrlPlaceholder:o.$.linkUrlPlaceholder,size:u})))}))}function Un(t,e){const n=t.state.schema.marks[e];n!=null&&(an(n)(t.state,t.dispatch),t.focus())}function aa(t,e){const n=t.state.schema.nodes.heading;n!=null&&(xr(n,{level:e})(t.state,t.dispatch),t.focus())}async function wu(t,e){const{wrapInList:n,liftListItem:r}=await Promise.resolve().then(()=>require("./index-CdVc1Y2V.cjs")),u=t.state.schema.nodes[e],i=t.state.schema.nodes.list_item;if(u==null||i==null)return;const{state:s}=t,{$from:o}=s.selection;let l=null;for(let a=o.depth;a>0;a--){const c=o.node(a);if(c.type.name==="bullet_list"||c.type.name==="ordered_list"){l=c.type.name;break}}l===e?r(i)(s,t.dispatch):l!=null?r(i)(t.state,t.dispatch)&&n(u)(t.state,t.dispatch):n(u)(s,t.dispatch),t.focus()}function ca(t){const e=t.state.schema.nodes.blockquote;if(e==null)return;const{state:n}=t,{$from:r}=n.selection;let u=!1;for(let i=r.depth;i>0;i--)if(r.node(i).type.name==="blockquote"){u=!0;break}u?Wl(n,t.dispatch):ea(e)(n,t.dispatch),t.focus()}function fa(t){const e=t.state.schema.nodes.code_block,n=t.state.schema.nodes.paragraph;if(e==null||n==null)return;const{state:r}=t,{$from:u}=r.selection;let i=!1;for(let s=u.depth;s>0;s--)if(u.node(s).type.name==="code_block"){i=!0;break}i?xr(n)(r,t.dispatch):xr(e)(r,t.dispatch),t.focus()}function da(t){const e=t.state.schema.nodes.horizontal_rule;if(e!=null){const n=t.state.tr.replaceSelectionWith(e.create());t.dispatch(n),t.focus()}}const $=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},gt=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let kr=null;const Ee=function(t,e,n){let r=kr||(kr=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},ha=function(){kr=null},rt=function(t,e,n,r){return n&&(Tu(t,e,n,r,-1)||Tu(t,e,n,r,1))},pa=/^(img|br|input|textarea|hr)$/i;function Tu(t,e,n,r,u){for(var i;;){if(t==n&&e==r)return!0;if(e==(u<0?0:ie(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Ut(t)||pa.test(t.nodeName)||t.contentEditable=="false")return!1;e=$(t)+(u<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(u<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=u;else return!1;else t=s,e=u<0?ie(t):0}else return!1}}function ie(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ma(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=ie(t)}else if(t.parentNode&&!Ut(t))e=$(t),t=t.parentNode;else return null}}function ga(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&&!Ut(t))e=$(t)+1,t=t.parentNode;else return null}}function ba(t,e,n){for(let r=e==0,u=e==ie(t);r||u;){if(t==n)return!0;let i=$(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,u=u&&i==ie(t)}}function Ut(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const wn=function(t){return t.focusNode&&rt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function je(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function xa(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ka(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ie(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ie(r.startContainer),r.startOffset)}}}const ke=typeof navigator<"u"?navigator:null,Ou=typeof document<"u"?document:null,He=ke&&ke.userAgent||"",yr=/Edge\/(\d+)/.exec(He),_s=/MSIE \d/.exec(He),Cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(He),Y=!!(_s||Cr||yr),Le=_s?document.documentMode:Cr?+Cr[1]:yr?+yr[1]:0,se=!Y&&/gecko\/(\d+)/i.test(He);se&&+(/Firefox\/(\d+)/.exec(He)||[0,0])[1];const Dr=!Y&&/Chrome\/(\d+)/.exec(He),L=!!Dr,Es=Dr?+Dr[1]:0,H=!Y&&!!ke&&/Apple Computer/.test(ke.vendor),bt=H&&(/Mobile\/\w+/.test(He)||!!ke&&ke.maxTouchPoints>2),ue=bt||(ke?/Mac/.test(ke.platform):!1),Ss=ke?/Win/.test(ke.platform):!1,Ae=/Android \d/.test(He),Kt=!!Ou&&"webkitFontSmoothing"in Ou.documentElement.style,ya=Kt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ca(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function _e(t,e){return typeof t=="number"?t:t[e]}function Da(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,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 Fu(t,e,n){let r=t.someProp("scrollThreshold")||0,u=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=gt(s);continue}let o=s,l=o==i.body,a=l?Ca(i):Da(o),c=0,f=0;if(e.top<a.top+_e(r,"top")?f=-(a.top-e.top+_e(u,"top")):e.bottom>a.bottom-_e(r,"bottom")&&(f=e.bottom-e.top>a.bottom-a.top?e.top+_e(u,"top")-a.top:e.bottom-a.bottom+_e(u,"bottom")),e.left<a.left+_e(r,"left")?c=-(a.left-e.left+_e(u,"left")):e.right>a.right-_e(r,"right")&&(c=e.right-a.right+_e(u,"right")),c||f)if(l)i.defaultView.scrollBy(c,f);else{let h=o.scrollLeft,d=o.scrollTop;f&&(o.scrollTop+=f),c&&(o.scrollLeft+=c);let m=o.scrollLeft-h,g=o.scrollTop-d;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let p=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(p))break;s=p=="absolute"?s.offsetParent:gt(s)}}function _a(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,u;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(i,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){r=o,u=l.top;break}}return{refDOM:r,refTop:u,stack:As(t.dom)}}function As(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=gt(r));return e}function Ea({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Ms(n,r==0?0:r-e)}function Ms(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:u,left:i}=t[n];r.scrollTop!=u+e&&(r.scrollTop=u+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let st=null;function Sa(t){if(t.setActive)return t.setActive();if(st)return t.focus(st);let e=As(t);t.focus(st==null?{get preventScroll(){return st={preventScroll:!0},!0}}:void 0),st||(st=!1,Ms(e,0))}function ws(t,e){let n,r=2e8,u,i=0,s=e.top,o=e.top,l,a;for(let c=t.firstChild,f=0;c;c=c.nextSibling,f++){let p;if(c.nodeType==1)p=c.getClientRects();else if(c.nodeType==3)p=Ee(c).getClientRects();else continue;for(let h=0;h<p.length;h++){let d=p[h];if(d.top<=s&&d.bottom>=o){s=Math.max(d.bottom,s),o=Math.min(d.top,o);let m=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(m<r){n=c,r=m,u=m&&n.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e,c.nodeType==1&&m&&(i=f+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!l&&d.left<=e.left&&d.right>=e.left&&(l=c,a={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(i=f+1)}}return!n&&l&&(n=l,u=a,r=0),n&&n.nodeType==3?Aa(n,u):!n||r&&n.nodeType==1?{node:t,offset:i}:ws(n,u)}function Aa(t,e){let n=t.nodeValue.length,r=document.createRange(),u;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=Te(r,1);if(s.top!=s.bottom&&Jr(e,s)){u={node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),u||{node:t,offset:0}}function Jr(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ma(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function wa(t,e,n){let{node:r,offset:u}=ws(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,u,i)}function Ta(t,e,n,r){let u=-1;for(let i=e,s=!1;i!=t.dom;){let o=t.docView.nearestDesc(i,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?u=o.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(u=o.posAfter),s=!0),!o.contentDOM&&u<0&&!o.node.isText))return(o.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;i=o.dom.parentNode}return u>-1?u:t.docView.posFromDOM(e,n,-1)}function Ts(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let u=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=u;;){let s=t.childNodes[i];if(s.nodeType==1){let o=s.getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(Jr(e,a))return Ts(s,e,a)}}if((i=(i+1)%r)==u)break}return t}function Oa(t,e){let n=t.dom.ownerDocument,r,u=0,i=ka(n,e.left,e.top);i&&({node:r,offset:u}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let a=t.dom.getBoundingClientRect();if(!Jr(e,a)||(s=Ts(t.dom,e,a),!s))return null}if(H)for(let a=s;r&&a;a=gt(a))a.draggable&&(r=void 0);if(s=Ma(s,e),r){if(se&&r.nodeType==1&&(u=Math.min(u,r.childNodes.length),u<r.childNodes.length)){let c=r.childNodes[u],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&u++}let a;Kt&&u&&r.nodeType==1&&(a=r.childNodes[u-1]).nodeType==1&&a.contentEditable=="false"&&a.getBoundingClientRect().top>=e.top&&u--,r==t.dom&&u==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(u==0||r.nodeType!=1||r.childNodes[u-1].nodeName!="BR")&&(o=Ta(t,r,u,e))}o==null&&(o=wa(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function Nu(t){return t.top<t.bottom||t.left<t.right}function Te(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Nu(r))return r}return Array.prototype.find.call(n,Nu)||t.getBoundingClientRect()}const Fa=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Os(t,e,n){let{node:r,offset:u,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Kt||se;if(r.nodeType==3)if(s&&(Fa.test(r.nodeValue)||(n<0?!u:u==r.nodeValue.length))){let l=Te(Ee(r,u,u),n);if(se&&u&&/\s/.test(r.nodeValue[u-1])&&u<r.nodeValue.length){let a=Te(Ee(r,u-1,u-1),-1);if(a.top==l.top){let c=Te(Ee(r,u,u+1),-1);if(c.top!=l.top)return _t(c,c.left<a.left)}}return l}else{let l=u,a=u,c=n<0?1:-1;return n<0&&!u?(a++,c=-1):n>=0&&u==r.nodeValue.length?(l--,c=1):n<0?l--:a++,_t(Te(Ee(r,l,a),c),c<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&u&&(n<0||u==ie(r))){let l=r.childNodes[u-1];if(l.nodeType==1)return Kn(l.getBoundingClientRect(),!1)}if(i==null&&u<ie(r)){let l=r.childNodes[u];if(l.nodeType==1)return Kn(l.getBoundingClientRect(),!0)}return Kn(r.getBoundingClientRect(),n>=0)}if(i==null&&u&&(n<0||u==ie(r))){let l=r.childNodes[u-1],a=l.nodeType==3?Ee(l,ie(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(a)return _t(Te(a,1),!1)}if(i==null&&u<ie(r)){let l=r.childNodes[u];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let a=l?l.nodeType==3?Ee(l,0,s?0:1):l.nodeType==1?l:null:null;if(a)return _t(Te(a,-1),!0)}return _t(Te(r.nodeType==3?Ee(r):r,-n),n>=0)}function _t(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 Kn(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 Fs(t,e,n){let r=t.state,u=t.root.activeElement;r!=e&&t.updateState(e),u!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),u!=t.dom&&u&&u.focus()}}function Na(t,e,n){let r=e.selection,u=n=="up"?r.$from:r.$to;return Fs(t,e,()=>{let{node:i}=t.docView.domFromPos(u.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(i,!0);if(!o)break;if(o.node.isBlock){i=o.contentDOM||o.dom;break}i=o.dom.parentNode}let s=Os(t,u.pos,1);for(let o=i.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=Ee(o,0,o.nodeValue.length).getClientRects();else continue;for(let a=0;a<l.length;a++){let c=l[a];if(c.bottom>c.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const Ia=/[\u0590-\u08ac]/;function Ra(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let u=r.parentOffset,i=!u,s=u==r.parent.content.size,o=t.domSelection();return o?!Ia.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?i:s:Fs(t,e,()=>{let{focusNode:l,focusOffset:a,anchorNode:c,anchorOffset:f}=t.domSelectionRange(),p=o.caretBidiLevel;o.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:d,focusOffset:m}=t.domSelectionRange(),g=d&&!h.contains(d.nodeType==1?d:d.parentNode)||l==d&&a==m;try{o.collapse(c,f),l&&(l!=c||a!=f)&&o.extend&&o.extend(l,a)}catch{}return p!=null&&(o.caretBidiLevel=p),g}):r.pos==r.start()||r.pos==r.end()}let Iu=null,Ru=null,Bu=!1;function Ba(t,e,n){return Iu==e&&Ru==n?Bu:(Iu=e,Ru=n,Bu=n=="up"||n=="down"?Na(t,e,n):Ra(t,e,n))}const oe=0,zu=1,Ke=2,ye=3;class Zt{constructor(e,n,r,u){this.parent=e,this.children=n,this.dom=r,this.contentDOM=u,this.dirty=oe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let u=this.children[n];if(u==e)return r;r+=u.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(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let u;if(e==this.dom&&this.contentDOM)u=n>$(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))u=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){u=!1;break}if(i.previousSibling)break}if(u==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){u=!0;break}if(i.nextSibling)break}}return u??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,u=e;u;u=u.parentNode){let i=this.getDesc(u),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let u=e;u;u=u.parentNode){let i=this.getDesc(u);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let u=this.children[n],i=r+u.size;if(r==e&&i!=r){for(;!u.border&&u.children.length;)for(let s=0;s<u.children.length;s++){let o=u.children[s];if(o.size){u=o;break}}return u}if(e<i)return u.descAt(e-r-u.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,u=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(o>e||s instanceof Is){u=e-i;break}i=o}if(u)return this.children[r].domFromPos(u-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Ns&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?$(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?$(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let u=-1,i=-1;for(let s=r,o=0;;o++){let l=this.children[o],a=s+l.size;if(u==-1&&e<=a){let c=s+l.border;if(e>=c&&n<=a-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,c);e=s;for(let f=o;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){u=$(p.dom)+1;break}e-=p.size}u==-1&&(u=0)}if(u>-1&&(a>n||o==this.children.length-1)){n=a;for(let c=o+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=$(f.dom);break}n+=f.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:n,fromOffset:u,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,u=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let h=0,d=0;h<this.children.length;h++){let m=this.children[h],g=d+m.size;if(i>d&&s<g)return m.setSelection(e-d-m.border,n-d-m.border,r,u);d=g}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),a=r.root.getSelection(),c=r.domSelectionRange(),f=!1;if((se||H)&&e==n){let{node:h,offset:d}=o;if(h.nodeType==3){if(f=!!(d&&h.nodeValue[d-1]==`
6
+ `).scrollIntoView()),!0)};function Wr(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 Jl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let u=n.node(-1),i=n.indexAfter(-1),s=Wr(u.contentMatchAt(i));if(!s||!u.canReplaceWith(i,i,s))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,s.createAndFill());l.setSelection(O.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},jl=(t,e)=>{let n=t.selection,{$from:r,$to:u}=n;if(n instanceof te||r.parent.inlineContent||u.parent.inlineContent)return!1;let i=Wr(u.parent.contentMatchAt(u.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&u.index()<u.parent.childCount?r:u).pos,o=t.tr.insert(s,i.createAndFill());o.setSelection(F.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},Ul=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ot(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),u=r&&jt(r);return u==null?!1:(e&&e(t.tr.lift(r,u).scrollIntoView()),!0)};function Kl(t){return(e,n)=>{let{$from:r,$to:u}=e.selection;if(e.selection instanceof A&&e.selection.node.isBlock)return!r.parentOffset||!Ot(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,o,l=!1,a=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),a=r.start(h)==r.pos-(r.depth-h),o=Wr(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(l&&o?{type:o}:null),s=h;break}else{if(h==1)return!1;i.unshift(null)}let c=e.tr;(e.selection instanceof F||e.selection instanceof te)&&c.deleteSelection();let f=c.mapping.map(r.pos),p=Ot(c.doc,f,i.length,i);if(p||(i[0]=o?{type:o}:null,p=Ot(c.doc,f,i.length,i)),!p)return!1;if(c.split(f,i.length,i),!l&&a&&r.node(s).type!=o){let h=c.mapping.map(r.before(s)),d=c.doc.resolve(h);o&&r.node(s-1).canReplaceWith(d.index(),d.index()+1,o)&&c.setNodeMarkup(c.mapping.map(r.before(s)),o)}return n&&n(c.scrollIntoView()),!0}}const Zl=Kl(),Gl=(t,e)=>(e&&e(t.tr.setSelection(new te(t.doc))),!0);function Yl(t,e,n){let r=e.nodeBefore,u=e.nodeAfter,i=e.index();return!r||!u||!r.type.compatibleContent(u.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(u.isTextblock||Lr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ms(t,e,n,r){let u=e.nodeBefore,i=e.nodeAfter,s,o,l=u.type.spec.isolating||i.type.spec.isolating;if(!l&&Yl(t,e,n))return!0;let a=!l&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(s=(o=u.contentMatchAt(u.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,d=x.empty;for(let b=s.length-1;b>=0;b--)d=x.from(s[b].create(null,d));d=x.from(u.copy(d));let m=t.tr.step(new G(e.pos-1,h,e.pos,h,new D(d,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==u.type&&Lr(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let c=i.type.spec.isolating||r>0&&l?null:O.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),p=f&&jt(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(a&&mt(i,"start",!0)&&mt(u,"end")){let h=u,d=[];for(;d.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let b=x.empty;for(let y=d.length-1;y>=0;y--)b=x.from(d[y].copy(b));let k=t.tr.step(new G(e.pos-d.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new D(b,d.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function gs(t){return function(e,n){let r=e.selection,u=t<0?r.$from:r.$to,i=u.depth;for(;u.node(i).isInline;){if(!i)return!1;i--}return u.node(i).isTextblock?(n&&n(e.tr.setSelection(F.create(e.doc,t<0?u.start(i):u.end(i)))),!0):!1}}const Xl=gs(-1),Ql=gs(1);function ea(t,e=null){return function(n,r){let{$from:u,$to:i}=n.selection,s=u.blockRange(i),o=s&&ts(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function xr(t,e=null){return function(n,r){let u=!1;for(let i=0;i<n.selection.ranges.length&&!u;i++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[i];n.doc.nodesBetween(s,o,(l,a)=>{if(u)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)u=!0;else{let c=n.doc.resolve(a),f=c.index();u=c.parent.canReplaceWith(f,f+1,t)}})}if(!u)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];i.setBlockType(o,l,t,e)}r(i.scrollIntoView())}return!0}}function ta(t,e,n,r){for(let u=0;u<e.length;u++){let{$from:i,$to:s}=e[u],o=i.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(i.pos,s.pos,(l,a)=>{if(o)return!1;o=l.inlineContent&&l.type.allowsMarkType(n)}),o)return!0}return!1}function an(t,e=null,n){return function(r,u){let{empty:i,$cursor:s,ranges:o}=r.selection;if(i&&!s||!ta(r.doc,o,t))return!1;if(u)if(s)t.isInSet(r.storedMarks||s.marks())?u(r.tr.removeStoredMark(t)):u(r.tr.addStoredMark(t.create(e)));else{let l,a=r.tr;l=!o.some(c=>r.doc.rangeHasMark(c.$from.pos,c.$to.pos,t));for(let c=0;c<o.length;c++){let{$from:f,$to:p}=o[c];if(!l)a.removeMark(f.pos,p.pos,t);else{let h=f.pos,d=p.pos,m=f.nodeAfter,g=p.nodeBefore,b=m&&m.isText?/^\s*/.exec(m.text)[0].length:0,k=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;h+b<d&&(h+=b,d-=k),a.addMark(h,d,t.create(e))}}u(a.scrollIntoView())}return!0}}function Hr(...t){return function(e,n,r){for(let u=0;u<t.length;u++)if(t[u](e,n,r))return!0;return!1}}let jn=Hr(ds,Pl,Ll),Mu=Hr(ds,Vl,$l);const Se={Enter:Hr(Hl,jl,Ul,Zl),"Mod-Enter":Jl,Backspace:jn,"Mod-Backspace":jn,"Shift-Backspace":jn,Delete:Mu,"Mod-Delete":Mu,"Mod-a":Gl},bs={"Ctrl-h":Se.Backspace,"Alt-Backspace":Se["Mod-Backspace"],"Ctrl-d":Se.Delete,"Ctrl-Alt-Backspace":Se["Mod-Delete"],"Alt-Delete":Se["Mod-Delete"],"Alt-d":Se["Mod-Delete"],"Ctrl-a":Xl,"Ctrl-e":Ql};for(let t in Se)bs[t]=Se[t];const na=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,ra=na?bs:Se;function xs(t,e){return ks(t,e)!=null}function ks(t,e){const{from:n,$from:r,to:u,empty:i}=t.selection;if(!e)return null;if(i){if(t.storedMarks){const c=t.storedMarks.find(f=>f.type.name===e.name);if(c!=null)return c}const l=r.marks().find(c=>c.type.name===e.name);if(l!=null)return l;const a=r.nodeAfter;if(a&&a.marks){const c=a.marks.find(f=>f.type.name===e.name);if(c!=null)return c}return null}let s=null;return t.doc.nodesBetween(n,u,o=>{if(s!=null)return!1;if(o.marks){const l=o.marks.find(a=>a.type.name===e.name);if(l!=null)return s=l,!1}}),s}function cn(t,e,n){return t.map(()=>{const r=e.value,u=r.state.schema.marks[n];return xs(r.state,u)})}function ua(t,e,n){const{$from:r}=t.selection;for(let i=r.depth;i>0;i--){const s=r.node(i);if(s.type.name===e.name)return n!=null?Object.keys(n).every(o=>s.attrs[o]===n[o]):!0}const u=t.doc.nodeAt(r.pos);return u&&u.type.name===e.name?n!=null?Object.keys(n).every(i=>u.attrs[i]===n[i]):!0:!1}function Dt(t,e,n,r){return t.map(()=>{const u=e.value,i=u.state.schema.nodes[n];return i?ua(u.state,i,r):!1})}function he({active:t,display:e,onClick:n,disabled:r,label:u,icon:i,size:s}){return S.When(e,()=>It.ToolbarButton({onClick:n,disabled:r,variant:t.map(o=>o?"filled":"light"),size:s},S.attr.title(u),Br.Icon({icon:i,size:s})))}function ia(t,e){const n=t.state.schema.marks.link;if(n==null)return;const{from:r,to:u}=t.state.selection,i=t.state.tr.addMark(r,u,n.create({href:e,title:null}));t.dispatch(i),t.focus()}function ys(t){const{state:e}=t,{$from:n,$to:r}=e.selection;if(!Cs(e))return null;let u=n.pos,i=r.pos;const s=e.doc;for(;u>0&&s.resolve(u-1).nodeAfter?.marks?.some(a=>a.type.name==="link");)u--;for(;i<s.content.size&&s.resolve(i).nodeAfter?.marks?.some(a=>a.type.name==="link");)i++;return{start:u,end:i}}function sa(t,e){const n=t.state.schema.marks.link;if(n==null)return;const r=ys(t);if(r==null)return;const{start:u,end:i}=r,s=t.state.tr.removeMark(u,i,n).addMark(u,i,n.create({href:e,title:null}));t.dispatch(s)}function oa(t){const e=t.state.schema.marks.link;if(e==null)return;const n=ys(t);if(n==null)return;const{start:r,end:u}=n,i=t.state.tr.removeMark(r,u,e);t.dispatch(i),t.focus()}function Cs(t){return xs(t,t.schema.marks.link)}function la({stateUpdate:t,view:e,isReadOnly:n,label:r,linkUrlPlaceholder:u,size:i}){const s=S.prop(null);s.on(l=>{l!=null&&sa(e.value,l)});const o=t.on(()=>{const l=ks(e.value.state,e.value.state.schema.marks.link);l!=null?s.set(l.attrs.href??""):s.set(null)});return S.Fragment(S.OnDispose(o),It.ToolbarGroup(he({display:S.signal(!0),active:cn(t,e,"link"),disabled:n,label:r,icon:"mdi:link-variant",size:i,onClick:()=>{const l=e.value.state;Cs(l)?(oa(e.value),s.set(null)):(ia(e.value,""),s.set(""))}}),S.Ensure(s,l=>Br.TextInput({value:l,autofocus:!0,onInput:s.set,placeholder:u,size:i}))),S.Ensure(s,l=>It.ToolbarButton({disabled:l.map(a=>a.trim()===""),variant:"text",onClick:()=>{const a=s.value;a&&window.open(a,"_blank")},size:i},"go")))}function rn({display:t},...e){return S.When(S.computedOf(...t)((...n)=>n.some(Boolean)),()=>It.ToolbarGroup(...e))}function Ds({view:t,stateUpdate:e,features:n,readOnly:r=S.signal(!1),size:u="sm"}){return S.Ensure(t,i=>S.Use(Br.BeatUII18n,s=>{const o=s.$.prosemirror,l=i;return It.Toolbar(rn({display:[n.$.bold,n.$.italic,n.$.code]},he({active:cn(e,l,"strong"),display:n.$.bold,onClick:()=>Un(l.value,"strong"),disabled:r,label:o.$.bold,icon:"mdi:format-bold",size:u}),he({active:cn(e,l,"em"),display:n.$.italic,onClick:()=>Un(l.value,"em"),disabled:r,label:o.$.italic,icon:"mdi:format-italic",size:u}),he({active:cn(e,l,"code"),display:n.$.code,onClick:()=>Un(l.value,"code"),disabled:r,label:o.$.code,icon:"mdi:code-tags",size:u})),rn({display:[n.$.headings]},S.Repeat(n.$.headerLevels.map(a=>Math.min(Math.max(a,1),6)),({counter:a})=>he({active:Dt(e,l,"heading",{level:a}),display:n.$.headings,onClick:()=>aa(l.value,a),disabled:r,label:o.map(c=>c.heading(a)),icon:`mdi:format-header-${a}`,size:u}))),rn({display:[n.$.bulletList,n.$.orderedList]},he({active:Dt(e,l,"bullet_list"),display:n.$.bulletList,onClick:()=>wu(l.value,"bullet_list"),disabled:r,label:o.$.bulletList,icon:"mdi:format-list-bulleted",size:u}),he({active:Dt(e,l,"ordered_list"),display:n.$.orderedList,onClick:()=>wu(l.value,"ordered_list"),disabled:r,label:o.$.orderedList,icon:"mdi:format-list-numbered",size:u})),rn({display:[n.$.blockquote,n.$.codeBlock,n.$.horizontalRule]},he({active:Dt(e,l,"blockquote"),display:n.$.blockquote,onClick:()=>ca(l.value),disabled:r,label:o.$.blockquote,icon:"mdi:format-quote-close",size:u}),he({active:Dt(e,l,"code_block"),display:n.$.codeBlock,onClick:()=>fa(l.value),disabled:r,label:o.$.codeBlock,icon:"mdi:code-braces",size:u}),he({active:S.signal(!1),display:n.$.horizontalRule,onClick:()=>da(l.value),disabled:r,label:o.$.horizontalRule,icon:"mdi:minus",size:u})),S.When(n.$.links,()=>la({stateUpdate:e,view:l,isReadOnly:r,label:o.$.link,linkUrlPlaceholder:o.$.linkUrlPlaceholder,size:u})))}))}function Un(t,e){const n=t.state.schema.marks[e];n!=null&&(an(n)(t.state,t.dispatch),t.focus())}function aa(t,e){const n=t.state.schema.nodes.heading;n!=null&&(xr(n,{level:e})(t.state,t.dispatch),t.focus())}async function wu(t,e){const{wrapInList:n,liftListItem:r}=await Promise.resolve().then(()=>require("./index-CfaWytS2.cjs")),u=t.state.schema.nodes[e],i=t.state.schema.nodes.list_item;if(u==null||i==null)return;const{state:s}=t,{$from:o}=s.selection;let l=null;for(let a=o.depth;a>0;a--){const c=o.node(a);if(c.type.name==="bullet_list"||c.type.name==="ordered_list"){l=c.type.name;break}}l===e?r(i)(s,t.dispatch):l!=null?r(i)(t.state,t.dispatch)&&n(u)(t.state,t.dispatch):n(u)(s,t.dispatch),t.focus()}function ca(t){const e=t.state.schema.nodes.blockquote;if(e==null)return;const{state:n}=t,{$from:r}=n.selection;let u=!1;for(let i=r.depth;i>0;i--)if(r.node(i).type.name==="blockquote"){u=!0;break}u?Wl(n,t.dispatch):ea(e)(n,t.dispatch),t.focus()}function fa(t){const e=t.state.schema.nodes.code_block,n=t.state.schema.nodes.paragraph;if(e==null||n==null)return;const{state:r}=t,{$from:u}=r.selection;let i=!1;for(let s=u.depth;s>0;s--)if(u.node(s).type.name==="code_block"){i=!0;break}i?xr(n)(r,t.dispatch):xr(e)(r,t.dispatch),t.focus()}function da(t){const e=t.state.schema.nodes.horizontal_rule;if(e!=null){const n=t.state.tr.replaceSelectionWith(e.create());t.dispatch(n),t.focus()}}const $=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},gt=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let kr=null;const Ee=function(t,e,n){let r=kr||(kr=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},ha=function(){kr=null},rt=function(t,e,n,r){return n&&(Tu(t,e,n,r,-1)||Tu(t,e,n,r,1))},pa=/^(img|br|input|textarea|hr)$/i;function Tu(t,e,n,r,u){for(var i;;){if(t==n&&e==r)return!0;if(e==(u<0?0:ie(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Ut(t)||pa.test(t.nodeName)||t.contentEditable=="false")return!1;e=$(t)+(u<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(u<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=u;else return!1;else t=s,e=u<0?ie(t):0}else return!1}}function ie(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ma(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=ie(t)}else if(t.parentNode&&!Ut(t))e=$(t),t=t.parentNode;else return null}}function ga(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&&!Ut(t))e=$(t)+1,t=t.parentNode;else return null}}function ba(t,e,n){for(let r=e==0,u=e==ie(t);r||u;){if(t==n)return!0;let i=$(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,u=u&&i==ie(t)}}function Ut(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const wn=function(t){return t.focusNode&&rt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function je(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function xa(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ka(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ie(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ie(r.startContainer),r.startOffset)}}}const ke=typeof navigator<"u"?navigator:null,Ou=typeof document<"u"?document:null,He=ke&&ke.userAgent||"",yr=/Edge\/(\d+)/.exec(He),_s=/MSIE \d/.exec(He),Cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(He),Y=!!(_s||Cr||yr),Le=_s?document.documentMode:Cr?+Cr[1]:yr?+yr[1]:0,se=!Y&&/gecko\/(\d+)/i.test(He);se&&+(/Firefox\/(\d+)/.exec(He)||[0,0])[1];const Dr=!Y&&/Chrome\/(\d+)/.exec(He),L=!!Dr,Es=Dr?+Dr[1]:0,H=!Y&&!!ke&&/Apple Computer/.test(ke.vendor),bt=H&&(/Mobile\/\w+/.test(He)||!!ke&&ke.maxTouchPoints>2),ue=bt||(ke?/Mac/.test(ke.platform):!1),Ss=ke?/Win/.test(ke.platform):!1,Ae=/Android \d/.test(He),Kt=!!Ou&&"webkitFontSmoothing"in Ou.documentElement.style,ya=Kt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ca(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function _e(t,e){return typeof t=="number"?t:t[e]}function Da(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,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 Fu(t,e,n){let r=t.someProp("scrollThreshold")||0,u=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=gt(s);continue}let o=s,l=o==i.body,a=l?Ca(i):Da(o),c=0,f=0;if(e.top<a.top+_e(r,"top")?f=-(a.top-e.top+_e(u,"top")):e.bottom>a.bottom-_e(r,"bottom")&&(f=e.bottom-e.top>a.bottom-a.top?e.top+_e(u,"top")-a.top:e.bottom-a.bottom+_e(u,"bottom")),e.left<a.left+_e(r,"left")?c=-(a.left-e.left+_e(u,"left")):e.right>a.right-_e(r,"right")&&(c=e.right-a.right+_e(u,"right")),c||f)if(l)i.defaultView.scrollBy(c,f);else{let h=o.scrollLeft,d=o.scrollTop;f&&(o.scrollTop+=f),c&&(o.scrollLeft+=c);let m=o.scrollLeft-h,g=o.scrollTop-d;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let p=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(p))break;s=p=="absolute"?s.offsetParent:gt(s)}}function _a(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,u;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(i,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){r=o,u=l.top;break}}return{refDOM:r,refTop:u,stack:As(t.dom)}}function As(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=gt(r));return e}function Ea({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Ms(n,r==0?0:r-e)}function Ms(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:u,left:i}=t[n];r.scrollTop!=u+e&&(r.scrollTop=u+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let st=null;function Sa(t){if(t.setActive)return t.setActive();if(st)return t.focus(st);let e=As(t);t.focus(st==null?{get preventScroll(){return st={preventScroll:!0},!0}}:void 0),st||(st=!1,Ms(e,0))}function ws(t,e){let n,r=2e8,u,i=0,s=e.top,o=e.top,l,a;for(let c=t.firstChild,f=0;c;c=c.nextSibling,f++){let p;if(c.nodeType==1)p=c.getClientRects();else if(c.nodeType==3)p=Ee(c).getClientRects();else continue;for(let h=0;h<p.length;h++){let d=p[h];if(d.top<=s&&d.bottom>=o){s=Math.max(d.bottom,s),o=Math.min(d.top,o);let m=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(m<r){n=c,r=m,u=m&&n.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e,c.nodeType==1&&m&&(i=f+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!l&&d.left<=e.left&&d.right>=e.left&&(l=c,a={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(i=f+1)}}return!n&&l&&(n=l,u=a,r=0),n&&n.nodeType==3?Aa(n,u):!n||r&&n.nodeType==1?{node:t,offset:i}:ws(n,u)}function Aa(t,e){let n=t.nodeValue.length,r=document.createRange(),u;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=Te(r,1);if(s.top!=s.bottom&&Jr(e,s)){u={node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),u||{node:t,offset:0}}function Jr(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ma(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function wa(t,e,n){let{node:r,offset:u}=ws(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,u,i)}function Ta(t,e,n,r){let u=-1;for(let i=e,s=!1;i!=t.dom;){let o=t.docView.nearestDesc(i,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?u=o.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(u=o.posAfter),s=!0),!o.contentDOM&&u<0&&!o.node.isText))return(o.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;i=o.dom.parentNode}return u>-1?u:t.docView.posFromDOM(e,n,-1)}function Ts(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let u=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=u;;){let s=t.childNodes[i];if(s.nodeType==1){let o=s.getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(Jr(e,a))return Ts(s,e,a)}}if((i=(i+1)%r)==u)break}return t}function Oa(t,e){let n=t.dom.ownerDocument,r,u=0,i=ka(n,e.left,e.top);i&&({node:r,offset:u}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let a=t.dom.getBoundingClientRect();if(!Jr(e,a)||(s=Ts(t.dom,e,a),!s))return null}if(H)for(let a=s;r&&a;a=gt(a))a.draggable&&(r=void 0);if(s=Ma(s,e),r){if(se&&r.nodeType==1&&(u=Math.min(u,r.childNodes.length),u<r.childNodes.length)){let c=r.childNodes[u],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&u++}let a;Kt&&u&&r.nodeType==1&&(a=r.childNodes[u-1]).nodeType==1&&a.contentEditable=="false"&&a.getBoundingClientRect().top>=e.top&&u--,r==t.dom&&u==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(u==0||r.nodeType!=1||r.childNodes[u-1].nodeName!="BR")&&(o=Ta(t,r,u,e))}o==null&&(o=wa(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function Nu(t){return t.top<t.bottom||t.left<t.right}function Te(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Nu(r))return r}return Array.prototype.find.call(n,Nu)||t.getBoundingClientRect()}const Fa=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Os(t,e,n){let{node:r,offset:u,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Kt||se;if(r.nodeType==3)if(s&&(Fa.test(r.nodeValue)||(n<0?!u:u==r.nodeValue.length))){let l=Te(Ee(r,u,u),n);if(se&&u&&/\s/.test(r.nodeValue[u-1])&&u<r.nodeValue.length){let a=Te(Ee(r,u-1,u-1),-1);if(a.top==l.top){let c=Te(Ee(r,u,u+1),-1);if(c.top!=l.top)return _t(c,c.left<a.left)}}return l}else{let l=u,a=u,c=n<0?1:-1;return n<0&&!u?(a++,c=-1):n>=0&&u==r.nodeValue.length?(l--,c=1):n<0?l--:a++,_t(Te(Ee(r,l,a),c),c<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&u&&(n<0||u==ie(r))){let l=r.childNodes[u-1];if(l.nodeType==1)return Kn(l.getBoundingClientRect(),!1)}if(i==null&&u<ie(r)){let l=r.childNodes[u];if(l.nodeType==1)return Kn(l.getBoundingClientRect(),!0)}return Kn(r.getBoundingClientRect(),n>=0)}if(i==null&&u&&(n<0||u==ie(r))){let l=r.childNodes[u-1],a=l.nodeType==3?Ee(l,ie(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(a)return _t(Te(a,1),!1)}if(i==null&&u<ie(r)){let l=r.childNodes[u];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let a=l?l.nodeType==3?Ee(l,0,s?0:1):l.nodeType==1?l:null:null;if(a)return _t(Te(a,-1),!0)}return _t(Te(r.nodeType==3?Ee(r):r,-n),n>=0)}function _t(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 Kn(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 Fs(t,e,n){let r=t.state,u=t.root.activeElement;r!=e&&t.updateState(e),u!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),u!=t.dom&&u&&u.focus()}}function Na(t,e,n){let r=e.selection,u=n=="up"?r.$from:r.$to;return Fs(t,e,()=>{let{node:i}=t.docView.domFromPos(u.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(i,!0);if(!o)break;if(o.node.isBlock){i=o.contentDOM||o.dom;break}i=o.dom.parentNode}let s=Os(t,u.pos,1);for(let o=i.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=Ee(o,0,o.nodeValue.length).getClientRects();else continue;for(let a=0;a<l.length;a++){let c=l[a];if(c.bottom>c.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const Ia=/[\u0590-\u08ac]/;function Ra(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let u=r.parentOffset,i=!u,s=u==r.parent.content.size,o=t.domSelection();return o?!Ia.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?i:s:Fs(t,e,()=>{let{focusNode:l,focusOffset:a,anchorNode:c,anchorOffset:f}=t.domSelectionRange(),p=o.caretBidiLevel;o.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:d,focusOffset:m}=t.domSelectionRange(),g=d&&!h.contains(d.nodeType==1?d:d.parentNode)||l==d&&a==m;try{o.collapse(c,f),l&&(l!=c||a!=f)&&o.extend&&o.extend(l,a)}catch{}return p!=null&&(o.caretBidiLevel=p),g}):r.pos==r.start()||r.pos==r.end()}let Iu=null,Ru=null,Bu=!1;function Ba(t,e,n){return Iu==e&&Ru==n?Bu:(Iu=e,Ru=n,Bu=n=="up"||n=="down"?Na(t,e,n):Ra(t,e,n))}const oe=0,zu=1,Ke=2,ye=3;class Zt{constructor(e,n,r,u){this.parent=e,this.children=n,this.dom=r,this.contentDOM=u,this.dirty=oe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let u=this.children[n];if(u==e)return r;r+=u.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(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let u;if(e==this.dom&&this.contentDOM)u=n>$(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))u=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){u=!1;break}if(i.previousSibling)break}if(u==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){u=!0;break}if(i.nextSibling)break}}return u??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,u=e;u;u=u.parentNode){let i=this.getDesc(u),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let u=e;u;u=u.parentNode){let i=this.getDesc(u);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let u=this.children[n],i=r+u.size;if(r==e&&i!=r){for(;!u.border&&u.children.length;)for(let s=0;s<u.children.length;s++){let o=u.children[s];if(o.size){u=o;break}}return u}if(e<i)return u.descAt(e-r-u.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,u=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(o>e||s instanceof Is){u=e-i;break}i=o}if(u)return this.children[r].domFromPos(u-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Ns&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?$(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?$(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let u=-1,i=-1;for(let s=r,o=0;;o++){let l=this.children[o],a=s+l.size;if(u==-1&&e<=a){let c=s+l.border;if(e>=c&&n<=a-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,c);e=s;for(let f=o;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){u=$(p.dom)+1;break}e-=p.size}u==-1&&(u=0)}if(u>-1&&(a>n||o==this.children.length-1)){n=a;for(let c=o+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=$(f.dom);break}n+=f.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:n,fromOffset:u,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,u=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let h=0,d=0;h<this.children.length;h++){let m=this.children[h],g=d+m.size;if(i>d&&s<g)return m.setSelection(e-d-m.border,n-d-m.border,r,u);d=g}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),a=r.root.getSelection(),c=r.domSelectionRange(),f=!1;if((se||H)&&e==n){let{node:h,offset:d}=o;if(h.nodeType==3){if(f=!!(d&&h.nodeValue[d-1]==`
7
7
  `),f&&d==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(o=l={node:g.parentNode,offset:$(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[d-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(se&&c.focusNode&&c.focusNode!=l.node&&c.focusNode.nodeType==1){let h=c.focusNode.childNodes[c.focusOffset];h&&h.contentEditable=="false"&&(u=!0)}if(!(u||f&&H)&&rt(o.node,o.offset,c.anchorNode,c.anchorOffset)&&rt(l.node,l.offset,c.focusNode,c.focusOffset))return;let p=!1;if((a.extend||e==n)&&!(f&&se)){a.collapse(o.node,o.offset);try{e!=n&&a.extend(l.node,l.offset),p=!0}catch{}}if(!p){if(e>n){let d=o;o=l,l=d}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(o.node,o.offset),a.removeAllRanges(),a.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,u=0;u<this.children.length;u++){let i=this.children[u],s=r+i.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let o=r+i.border,l=s-i.border;if(e>=o&&n<=l){this.dirty=e==r||n==s?Ke:zu,e==o&&n==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ye:i.markDirty(e-o,n-o);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ke:ye}r=s}this.dirty=Ke}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ke:zu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ns extends Zt{constructor(e,n,r,u){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return u;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let o=document.createElement("span");o.appendChild(s),s=o}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==oe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class za extends Zt{constructor(e,n,r,u){super(e,[],n,null),this.textDOM=r,this.text=u}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ut extends Zt{constructor(e,n,r,u,i){super(e,[],r,u),this.mark=n,this.spec=i}static create(e,n,r,u){let i=u.nodeViews[n.type.name],s=i&&i(n,u,r);return(!s||!s.dom)&&(s=yt.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new ut(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ye||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ye&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=oe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=oe}}slice(e,n,r){let u=ut.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Er(i,n,s,r)),e>0&&(i=Er(i,0,e,r));for(let o=0;o<i.length;o++)i[o].parent=u;return u.children=i,u}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class qe extends Zt{constructor(e,n,r,u,i,s,o,l,a){super(e,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=u,this.nodeDOM=o}static create(e,n,r,u,i,s){let o=i.nodeViews[n.type.name],l,a=o&&o(n,i,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,u),c=a&&a.dom,f=a&&a.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=yt.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let p=c;return c=zs(c,r,n),a?l=new va(e,n,r,u,c,f||null,p,a,i,s+1):n.isText?new Tn(e,n,r,u,c,p,i):new qe(e,n,r,u,c,f||null,p,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,n,r){return this.dirty==oe&&e.eq(this.node)&&gn(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,u=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,l=new La(this,s&&s.node,e);$a(this.node,this.innerDeco,(a,c,f)=>{a.spec.marks?l.syncToMarks(a.spec.marks,r,e,c):a.type.side>=0&&!f&&l.syncToMarks(c==this.node.childCount?T.none:this.node.child(c).marks,r,e,c),l.placeWidget(a,e,u)},(a,c,f,p)=>{l.syncToMarks(a.marks,r,e,p);let h;l.findNodeMatch(a,c,f,p)||o&&e.state.selection.from>u&&e.state.selection.to<u+a.nodeSize&&(h=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(a,c,f,h,e)||l.updateNextNode(a,c,f,e,p,u)||l.addNode(a,c,f,e,u),u+=a.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Ke)&&(s&&this.protectLocalComposition(e,s),Rs(this.contentDOM,this.children,e),bt&&Wa(this.dom))}localCompositionInfo(e,n){let{from:r,to:u}=e.state.selection;if(!(e.state.selection instanceof F)||r<n||u>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,o=Ha(this.node.content,s,r-n,u-n);return o<0?null:{node:i,pos:o,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:u}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new za(this,i,n,u);e.input.compositionNodes.push(s),this.children=Er(this.children,r,r+u.length,e,s)}update(e,n,r,u){return this.dirty==ye||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,u),!0)}updateInner(e,n,r,u){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(u,this.posAtStart),this.dirty=oe}updateOuterDeco(e){if(gn(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Bs(this.dom,this.nodeDOM,_r(this.outerDeco,this.node,n),_r(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function vu(t,e,n,r,u){zs(r,e,t);let i=new qe(void 0,t,e,n,r,r,r,u,0);return i.contentDOM&&i.updateChildren(u,0),i}class Tn extends qe{constructor(e,n,r,u,i,s,o){super(e,n,r,u,i,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,u){return this.dirty==ye||this.dirty!=oe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=oe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,u.trackWrites==this.nodeDOM&&(u.trackWrites=null)),this.node=e,this.dirty=oe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let u=this.node.cut(e,n),i=document.createTextNode(u.text);return new Tn(this.parent,u,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ye)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Is extends Zt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==oe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class va extends qe{constructor(e,n,r,u,i,s,o,l,a,c){super(e,n,r,u,i,s,o,a,c),this.spec=l}update(e,n,r,u){if(this.dirty==ye)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,u),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,u)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,u){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,u)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Rs(t,e,n){let r=t.firstChild,u=!1;for(let i=0;i<e.length;i++){let s=e[i],o=s.dom;if(o.parentNode==t){for(;o!=r;)r=Pu(r),u=!0;r=r.nextSibling}else u=!0,t.insertBefore(o,r);if(s instanceof ut){let l=r?r.previousSibling:t.lastChild;Rs(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=Pu(r),u=!0;u&&n.trackWrites==t&&(n.trackWrites=null)}const Ft=function(t){t&&(this.nodeName=t)};Ft.prototype=Object.create(null);const Ze=[new Ft];function _r(t,e,n){if(t.length==0)return Ze;let r=n?Ze[0]:new Ft,u=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&u.push(r=new Ft(s.nodeName));for(let o in s){let l=s[o];l!=null&&(n&&u.length==1&&u.push(r=new Ft(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+l:o=="style"?r.style=(r.style?r.style+";":"")+l:o!="nodeName"&&(r[o]=l))}}}return u}function Bs(t,e,n,r){if(n==Ze&&r==Ze)return e;let u=e;for(let i=0;i<r.length;i++){let s=r[i],o=n[i];if(i){let l;o&&o.nodeName==s.nodeName&&u!=t&&(l=u.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(u),o=Ze[0]),u=l}Pa(u,o||Ze[0],s)}return u}function Pa(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)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):[],u=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)u.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<u.length;i++)r.indexOf(u[i])==-1&&t.classList.add(u[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,u;for(;u=r.exec(e.style);)t.style.removeProperty(u[1])}n.style&&(t.style.cssText+=n.style)}}function zs(t,e,n){return Bs(t,t,Ze,_r(e,n,t.nodeType!=1))}function gn(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Pu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class La{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=qa(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,u){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=oe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,a=this.top.children.length;u<this.preMatch.index&&(a=Math.min(this.index+3,a));for(let c=this.index;c<a;c++){let f=this.top.children[c];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=ut.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,u){let i=-1,s;if(u>=this.preMatch.index&&(s=this.preMatch.matches[u-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let o=this.index,l=Math.min(this.top.children.length,o+5);o<l;o++){let a=this.top.children[o];if(a.matchesNode(e,n,r)&&!this.preMatch.matched.has(a)){i=o;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,u,i){let s=this.top.children[u];return s.dirty==ye&&s.dom==s.contentDOM&&(s.dirty=Ke),s.update(e,n,r,i)?(this.destroyBetween(this.index,u),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let u=this.index;u<this.top.children.length;u++)if(this.top.children[u]==r)return u}return-1}e=n}}updateNextNode(e,n,r,u,i,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof qe){let a=this.preMatch.matched.get(l);if(a!=null&&a!=i)return!1;let c=l.dom,f,p=this.isLocked(c)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=ye&&gn(n,l.outerDeco));if(!p&&l.update(e,n,r,u))return this.destroyBetween(this.index,o),l.dom!=c&&(this.changed=!0),this.index++,!0;if(!p&&(f=this.recreateWrapper(l,e,n,r,u,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Ke,f.updateChildren(u,s+1),f.dirty=oe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,u,i,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!gn(r,e.outerDeco)||!u.eq(e.innerDeco))return null;let o=qe.create(this.top,n,r,u,i,s);if(o.contentDOM){o.children=e.children,e.children=[];for(let l of o.children)l.parent=o}return e.destroy(),o}addNode(e,n,r,u,i){let s=qe.create(this.top,e,n,r,u,i);s.contentDOM&&s.updateChildren(u,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let u=this.index<this.top.children.length?this.top.children[this.index]:null;if(u&&u.matchesWidget(e)&&(e==u.widget||!u.widget.type.toDOM.parentNode))this.index++;else{let i=new Ns(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof ut;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Tn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((H||L)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let u=new Is(this.top,[],r,null);n!=this.top?n.children.push(u):n.children.splice(this.index++,0,u),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function qa(t,e){let n=e,r=n.children.length,u=t.childCount,i=new Map,s=[];e:for(;u>0;){let o;for(;;)if(r){let a=n.children[r-1];if(a instanceof ut)n=a,r=a.children.length;else{o=a,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=o.node;if(l){if(l!=t.child(u-1))break;--u,i.set(o,u),s.push(o)}}return{index:u,matched:i,matches:s.reverse()}}function Va(t,e){return t.type.side-e.type.side}function $a(t,e,n,r){let u=e.locals(t),i=0;if(u.length==0){for(let a=0;a<t.childCount;a++){let c=t.child(a);r(c,u,e.forChild(i,c),a),i+=c.nodeSize}return}let s=0,o=[],l=null;for(let a=0;;){let c,f;for(;s<u.length&&u[s].to==i;){let g=u[s++];g.widget&&(c?(f||(f=[c])).push(g):c=g)}if(c)if(f){f.sort(Va);for(let g=0;g<f.length;g++)n(f[g],a,!!l)}else n(c,a,!!l);let p,h;if(l)h=-1,p=l,l=null;else if(a<t.childCount)h=a,p=t.child(a++);else break;for(let g=0;g<o.length;g++)o[g].to<=i&&o.splice(g--,1);for(;s<u.length&&u[s].from<=i&&u[s].to>i;)o.push(u[s++]);let d=i+p.nodeSize;if(p.isText){let g=d;s<u.length&&u[s].from<g&&(g=u[s].from);for(let b=0;b<o.length;b++)o[b].to<g&&(g=o[b].to);g<d&&(l=p.cut(g-i),p=p.cut(0,g-i),d=g,h=-1)}else for(;s<u.length&&u[s].to<d;)s++;let m=p.isInline&&!p.isLeaf?o.filter(g=>!g.inline):o.slice();r(p,m,e.forChild(i,p),h),i=d}}function Wa(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 Ha(t,e,n,r){for(let u=0,i=0;u<t.childCount&&i<=r;){let s=t.child(u++),o=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;u<t.childCount;){let a=t.child(u++);if(i+=a.nodeSize,!a.isText)break;l+=a.text}if(i>=n){if(i>=r&&l.slice(r-e.length-o,r-o)==e)return r-e.length;let a=o<r?l.lastIndexOf(e,r-o-1):-1;if(a>=0&&a+e.length+o>=n)return o+a;if(n==r&&l.length>=r+e.length-o&&l.slice(r-o,r-o+e.length)==e)return r}}return-1}function Er(t,e,n,r,u){let i=[];for(let s=0,o=0;s<t.length;s++){let l=t[s],a=o,c=o+=l.size;a>=n||c<=e?i.push(l):(a<e&&i.push(l.slice(0,e-a,r)),u&&(i.push(u),u=void 0),c>n&&i.push(l.slice(n-a,l.size,r)))}return i}function jr(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let u=t.docView.nearestDesc(n.focusNode),i=u&&u.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let o=r.resolve(s),l,a;if(wn(n)){for(l=s;u&&!u.node;)u=u.parent;let f=u.node;if(u&&f.isAtom&&A.isSelectable(f)&&u.parent&&!(f.isInline&&ba(n.focusNode,n.focusOffset,u.dom))){let p=u.posBefore;a=new A(s==p?o:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,p=s;for(let h=0;h<n.rangeCount;h++){let d=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(d.startContainer,d.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(d.endContainer,d.endOffset,-1))}if(f<0)return null;[l,s]=p==t.state.selection.anchor?[p,f]:[f,p],o=r.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let c=r.resolve(l);if(!a){let f=e=="pointer"||t.state.selection.head<o.pos&&!i?1:-1;a=Ur(t,c,o,f)}return a}function vs(t){return t.editable?t.hasFocus():Ls(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Me(t,e=!1){let n=t.state.selection;if(Ps(t,n),!!vs(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&L){let r=t.domSelectionRange(),u=t.domObserver.currentSelection;if(r.anchorNode&&u.anchorNode&&rt(r.anchorNode,r.anchorOffset,u.anchorNode,u.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)ja(t);else{let{anchor:r,head:u}=n,i,s;Lu&&!(n instanceof F)&&(n.$from.parent.inlineContent||(i=qu(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=qu(t,n.to))),t.docView.setSelection(r,u,t,e),Lu&&(i&&Vu(i),s&&Vu(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ja(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Lu=H||L&&Es<63;function qu(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),u=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(H&&u&&u.contentEditable=="false")return Zn(u);if((!u||u.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(u)return Zn(u);if(i)return Zn(i)}}function Zn(t){return t.contentEditable="true",H&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Vu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ja(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,u=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=u)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!vs(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ja(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,$(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Y&&Le<=11&&(n.disabled=!0,n.disabled=!1)}function Ps(t,e){if(e instanceof A){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&($u(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else $u(t)}function $u(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ur(t,e,n,r){return t.someProp("createSelectionBetween",u=>u(t,e,n))||F.between(e,n,r)}function Wu(t){return t.editable&&!t.hasFocus()?!1:Ls(t)}function Ls(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;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{return!1}}function Ua(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return rt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Sr(t,e){let{$anchor:n,$head:r}=t.selection,u=e>0?n.max(r):n.min(r),i=u.parent.inlineContent?u.depth?t.doc.resolve(e>0?u.after():u.before()):null:u;return i&&O.findFrom(i,e)}function Oe(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Hu(t,e,n){let r=t.state.selection;if(r instanceof F)if(n.indexOf("s")>-1){let{$head:u}=r,i=u.textOffset?null:e<0?u.nodeBefore:u.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(u.pos+i.nodeSize*(e<0?-1:1));return Oe(t,new F(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let u=Sr(t.state,e);return u&&u instanceof A?Oe(t,u):!1}else if(!(ue&&n.indexOf("m")>-1)){let u=r.$head,i=u.textOffset?null:e<0?u.nodeBefore:u.nodeAfter,s;if(!i||i.isText)return!1;let o=e<0?u.pos-i.nodeSize:u.pos;return i.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM?A.isSelectable(i)?Oe(t,new A(e<0?t.state.doc.resolve(u.pos-i.nodeSize):u)):Kt?Oe(t,new F(t.state.doc.resolve(e<0?o:o+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof A&&r.node.isInline)return Oe(t,new F(e>0?r.$to:r.$from));{let u=Sr(t.state,e);return u?Oe(t,u):!1}}}function bn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Nt(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ot(t,e){return e<0?Ka(t):Za(t)}function Ka(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let u,i,s=!1;for(se&&n.nodeType==1&&r<bn(n)&&Nt(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Nt(o,-1))u=n,i=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(qs(n))break;{let o=n.previousSibling;for(;o&&Nt(o,-1);)u=n.parentNode,i=$(o),o=o.previousSibling;if(o)n=o,r=bn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Ar(t,n,r):u&&Ar(t,u,i)}function Za(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let u=bn(n),i,s;for(;;)if(r<u){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Nt(o,1))i=n,s=++r;else break}else{if(qs(n))break;{let o=n.nextSibling;for(;o&&Nt(o,1);)i=o.parentNode,s=$(o)+1,o=o.nextSibling;if(o)n=o,r=0,u=bn(n);else{if(n=n.parentNode,n==t.dom)break;r=u=0}}}i&&Ar(t,i,s)}function qs(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ga(t,e){for(;t&&e==t.childNodes.length&&!Ut(t);)e=$(t)+1,t=t.parentNode;for(;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 Ya(t,e){for(;t&&!e&&!Ut(t);)e=$(t),t=t.parentNode;for(;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 Ar(t,e,n){if(e.nodeType!=3){let i,s;(s=Ga(e,n))?(e=s,n=0):(i=Ya(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(wn(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:u}=t;setTimeout(()=>{t.state==u&&Me(t)},50)}function Ju(t,e){let n=t.state.doc.resolve(e);if(!(L||Ss)&&n.parent.inlineContent){let u=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>u.top&&s<u.bottom&&Math.abs(i.left-u.left)>1)return i.left<u.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>u.top&&s<u.bottom&&Math.abs(i.left-u.left)>1)return i.left>u.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function ju(t,e,n){let r=t.state.selection;if(r instanceof F&&!r.empty||n.indexOf("s")>-1||ue&&n.indexOf("m")>-1)return!1;let{$from:u,$to:i}=r;if(!u.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Sr(t.state,e);if(s&&s instanceof A)return Oe(t,s)}if(!u.parent.inlineContent){let s=e<0?u:i,o=r instanceof te?O.near(s,e):O.findFrom(s,e);return o?Oe(t,o):!1}return!1}function Uu(t,e){if(!(t.state.selection instanceof F))return!0;let{$head:n,$anchor:r,empty:u}=t.state.selection;if(!n.sameParent(r))return!0;if(!u)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function Ku(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Xa(t){if(!H||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ku(t,r,"true"),setTimeout(()=>Ku(t,r,"false"),20)}return!1}function Qa(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function ec(t,e){let n=e.keyCode,r=Qa(e);if(n==8||ue&&n==72&&r=="c")return Uu(t,-1)||ot(t,-1);if(n==46&&!e.shiftKey||ue&&n==68&&r=="c")return Uu(t,1)||ot(t,1);if(n==13||n==27)return!0;if(n==37||ue&&n==66&&r=="c"){let u=n==37?Ju(t,t.state.selection.from)=="ltr"?-1:1:-1;return Hu(t,u,r)||ot(t,u)}else if(n==39||ue&&n==70&&r=="c"){let u=n==39?Ju(t,t.state.selection.from)=="ltr"?1:-1:1;return Hu(t,u,r)||ot(t,u)}else{if(n==38||ue&&n==80&&r=="c")return ju(t,-1,r)||ot(t,-1);if(n==40||ue&&n==78&&r=="c")return Xa(t)||ju(t,1,r)||ot(t,1);if(r==(ue?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Kr(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:u,openEnd:i}=e;for(;u>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){u--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||yt.fromSchema(t.state.schema),o=js(),l=o.createElement("div");l.appendChild(s.serializeFragment(r,{document:o}));let a=l.firstChild,c,f=0;for(;a&&a.nodeType==1&&(c=Js[a.nodeName.toLowerCase()]);){for(let h=c.length-1;h>=0;h--){let d=o.createElement(c[h]);for(;l.firstChild;)d.appendChild(l.firstChild);l.appendChild(d),f++}a=l.firstChild}a&&a.nodeType==1&&a.setAttribute("data-pm-slice",`${u} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
8
8
 
9
9
  `);return{dom:l,text:p,slice:e}}function Vs(t,e,n,r,u){let i=u.parent.type.spec.code,s,o;if(!n&&!e)return null;let l=!!e&&(r||i||!n);if(l){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return o=new D(x.from(t.state.schema.text(e.replace(/\r\n?/g,`
@@ -1,6 +1,6 @@
1
1
  import { When as En, attr as je, prop as zi, Fragment as vi, OnDispose as mr, Ensure as gr, signal as br, computedOf as xr, Use as Pi, Repeat as Wo, Value as U, html as cu, Task as Ho, WithElement as Jo } from "@tempots/dom";
2
- import { a as Li, b as qi, T as jo } from "./toolbar-CdY5huSG.js";
3
- import { c as Uo, T as Ko, a as Zo } from "./translations-BEMKy6-W.js";
2
+ import { a as Li, b as qi, T as jo } from "./toolbar-DNpBIoJo.js";
3
+ import { c as Uo, T as Ko, a as Zo } from "./translations-0tLX4x7M.js";
4
4
  import { L as Go } from "./link-portal-Cr2l9f3k.js";
5
5
  import { ticker as Yo } from "@tempots/ui";
6
6
  import { T as Xo } from "./theme-B5pmbvQ_.js";
@@ -5806,7 +5806,7 @@ function Aa(t, e) {
5806
5806
  n != null && (_r(n, { level: e })(t.state, t.dispatch), t.focus());
5807
5807
  }
5808
5808
  async function Fu(t, e) {
5809
- const { wrapInList: n, liftListItem: r } = await import("./index-mPVib4v9.js"), u = t.state.schema.nodes[e], i = t.state.schema.nodes.list_item;
5809
+ const { wrapInList: n, liftListItem: r } = await import("./index-CGEzILlC.js"), u = t.state.schema.nodes[e], i = t.state.schema.nodes.list_item;
5810
5810
  if (u == null || i == null) return;
5811
5811
  const { state: s } = t, { $from: o } = s.selection;
5812
5812
  let l = null;