@lattice-php/lattice 0.65.0 → 0.67.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.
- package/dist/dnd/cancel-drag-start.d.ts +9 -0
- package/dist/dnd/cancel-drag-start.js +22 -0
- package/dist/dnd/cancel-drag-start.js.map +1 -0
- package/dist/dnd/index.d.ts +1 -0
- package/dist/dnd/index.js +2 -1
- package/dist/registry.d.ts +1 -1
- package/dist/registry.js.map +1 -1
- package/dist/runtime.d.ts +8 -2
- package/dist/runtime.js +9 -2
- package/dist/types/generated.d.ts +3 -2
- package/dist-standalone/chunks/{chart-view-DMWZM4CR.js → chart-view-D9CaiZJ1.js} +6 -6
- package/dist-standalone/chunks/date-picker-view-q0M-czhr.js +1 -0
- package/dist-standalone/chunks/dist-CBO25w6A.js +106 -0
- package/dist-standalone/chunks/{floating-ui.dom-CAMzcZKV.js → floating-ui.dom-C6CLKWO6.js} +1 -1
- package/dist-standalone/chunks/{input-0lNoXsuO.js → input-BIm8kbcS.js} +1 -1
- package/dist-standalone/chunks/pattern-input-view-BrHa0ZuE.js +1 -0
- package/dist-standalone/chunks/rich-editor-view-CznmPhtn.js +54 -0
- package/dist-standalone/chunks/runtime-BPVuv-X-.js +162 -0
- package/dist-standalone/chunks/{subscriptions-7SHEm8to.js → subscriptions-BEh9jchY.js} +1 -1
- package/dist-standalone/lattice.js +1 -1
- package/dist-standalone/manifest.json +1 -1
- package/dist-standalone/runtime.js +1 -1
- package/dist-standalone/sprite.svg +1 -1
- package/package.json +6 -6
- package/dist-standalone/chunks/date-picker-view-DrtfhWIp.js +0 -1
- package/dist-standalone/chunks/dist-Dd8dg4q5.js +0 -106
- package/dist-standalone/chunks/pattern-input-view-rhGqJ1Hj.js +0 -1
- package/dist-standalone/chunks/rich-editor-view-zB0idi1U.js +0 -53
- package/dist-standalone/chunks/runtime-C7m3FL07.js +0 -162
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{At as n,Dt as r,Et as i,Ht as a,Lt as o,Mt as s,Ot as c,Rt as l,Tt as u,_t as d,c as f,d as p,f as m,jt as h,kt as g,l as _,m as v,p as y,rn as b,u as x,vt as S,xt as ee}from"./runtime-BPVuv-X-.js";import{t as te}from"./react-dom-Dl-LT-t1.js";import{t as ne}from"./jsx-runtime-NZYk81nU.js";import{i as re}from"./registry-context-gXwNT8GJ.js";import{a as C,d as ie,f as w,h as ae,i as oe,l as T,n as se,o as ce,r as le,s as ue,t as de,u as fe}from"./floating-ui.dom-C6CLKWO6.js";import{c as E}from"./instance-D6cXaqIT.js";import{$ as D,A as pe,B as me,C as he,D as ge,E as _e,F as ve,G as ye,H as be,I as xe,J as Se,K as Ce,L as we,M as Te,N as Ee,O as De,P as Oe,Q as ke,R as Ae,S as je,T as Me,U as Ne,V as Pe,W as O,X as Fe,Y as Ie,Z as Le,_ as Re,a as ze,at as k,b as Be,c as Ve,ct as He,d as Ue,et as We,f as A,g as Ge,h as Ke,i as qe,it as Je,j as Ye,k as Xe,l as j,lt as M,m as Ze,nt as N,o as Qe,ot as $e,p as et,q as tt,rt as P,s as nt,st as rt,t as it,tt as F,u as at,ut as I,v as ot,w as st,x as ct,y as lt,z as ut}from"./dist-CBO25w6A.js";function dt(e={}){return new F({view(t){return new ft(t,e)}})}var ft=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=He(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},L=class e extends P{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):P.near(r)}content(){return I.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new pt(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!ht(e)||!gt(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!We.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};L.prototype.visible=!1,L.findFrom=L.findGapCursorFrom,P.jsonID(`gapcursor`,L);var pt=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return L.valid(t)?new L(t):P.near(t)}};function mt(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function ht(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||mt(e.type))return!0;if(e.inlineContent)return!1}}return!0}function gt(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||mt(e.type))return!0;if(e.inlineContent)return!1}}return!0}function _t(){return new F({props:{decorations:St,createSelectionBetween(e,t,n){return t.pos==n.pos&&L.valid(n)?new L(n):null},handleClick:bt,handleKeyDown:vt,handleDOMEvents:{beforeinput:xt}}})}var vt=Le({ArrowLeft:yt(`horiz`,-1),ArrowRight:yt(`horiz`,1),ArrowUp:yt(`vert`,-1),ArrowDown:yt(`vert`,1)});function yt(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof k){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=L.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new L(c))),!0):!1}}function bt(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!L.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&We.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new L(r))),!0)}function xt(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof L))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=M.empty;for(let e=r.length-1;e>=0;e--)i=M.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new I(i,0,0));return a.setSelection(k.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function St(e){if(!(e.selection instanceof L))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,D.create(e.doc,[ke.widget(e.selection.head,t,{key:`gapcursor`})])}var Ct=200,R=function(){};R.prototype.append=function(e){return e.length?(e=R.from(e),!this.length&&e||e.length<Ct&&this.leafAppend(e)||this.length<Ct&&e.leafPrepend(this)||this.appendInner(e)):this},R.prototype.prepend=function(e){return e.length?R.from(e).append(this):this},R.prototype.appendInner=function(e){return new Tt(this,e)},R.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?R.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},R.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},R.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},R.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},R.from=function(e){return e instanceof R?e:e&&e.length?new wt(e):R.empty};var wt=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Ct)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ct)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(R);R.empty=new wt([]);var Tt=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(R),Et=500,Dt=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new kt(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new kt(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new kt(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>jt&&(s=Ot(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new $e;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new kt(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new kt(i,o,l))}else r.push(new kt(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new kt(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>Et&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new kt(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(R.from(i.reverse()),a)}};Dt.empty=new Dt(R.empty,0);function Ot(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var kt=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},At=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},jt=20;function Mt(e,t,n,r){let i=n.getMeta(Bt),a;if(i)return i.historyState;n.getMeta(Vt)&&(e=new At(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Bt))return o.getMeta(Bt).redo?new At(e.done.addTransform(n,void 0,r,zt(t)),e.undone,Pt(n.mapping.maps),e.prevTime,e.prevComposition):new At(e.done,e.undone.addTransform(n,void 0,r,zt(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Nt(n,e.prevRanges)),s=o?Ft(e.prevRanges,n.mapping):Pt(n.mapping.maps);return new At(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,zt(t)),Dt.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new At(e.done.rebased(n,a),e.undone.rebased(n,a),Ft(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new At(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ft(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Nt(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function Pt(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Ft(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function It(e,t,n){let r=zt(t),i=Bt.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new At(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Bt,{redo:n,historyState:c})}var Lt=!1,Rt=null;function zt(e){let t=e.plugins;if(Rt!=t){Lt=!1,Rt=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Lt=!0;break}}return Lt}var Bt=new N(`history`),Vt=new N(`closeHistory`);function Ht(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new F({key:Bt,state:{init(){return new At(Dt.empty,Dt.empty,null,0,-1)},apply(t,n,r){return Mt(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Wt:n==`historyRedo`?Gt:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Ut(e,t){return(n,r)=>{let i=Bt.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=It(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Wt=Ut(!1,!0),Gt=Ut(!0,!0);j.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new F({key:new N(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var Kt=j.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[dt(this.options)]}});j.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new F({key:new N(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return D.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(ke.node(t,t+e.nodeSize,{class:this.options.className}))}),D.create(e,a)}}})]}});var qt=j.create({name:`gapCursor`,addProseMirrorPlugins(){return[_t()]},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:Ze(_e(e,`allowGapCursor`,t))??null}}}),Jt=`placeholder`,Yt=new N(`tiptap__placeholder`);function Xt(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),ke.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Zt(e,t){return typeof e==`function`?e(t):e}function Qt({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&ut(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Xt({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Zt(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function $t({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&ut(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Xt({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Zt(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Qt({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return D.create(r,o)}function en(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function tn(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function nn(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function rn(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function an(e,t){let n=nn(e,t.from,t.to);return n.push(tn(e,en(e,t.from))),t.to>t.from?n.push(tn(e,en(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(tn(e,en(e,Math.min(t.from+1,e.content.size)))),n}function on(e,t,n){let r=[];if(e.docChanged){let t=Me(e);for(let e of t)r.push(...an(n.doc,e.newRange))}return e.selectionSet&&(r.push(tn(n.doc,en(n.doc,e.mapping.map(t.selection.anchor)))),r.push(tn(n.doc,en(n.doc,n.selection.anchor)))),rn(r)}function sn(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function cn({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=sn(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Qt({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function ln({editor:e,options:t,dataAttribute:n}){return{init(r,i){return $t({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??D.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:cn({decorations:i.map(r.mapping,r.doc),ranges:on(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function un(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function dn({editor:e,options:t}){let n=t.dataAttribute?`data-${un(t.dataAttribute)}`:`data-${Jt}`,r=t.showOnlyCurrent&&!t.includeChildren;return new F({key:Yt,...r?{}:{state:ln({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>$t({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?D.empty:Yt.getState(n)??D.empty}})}var fn=j.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Jt,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[dn({editor:this.editor,options:this.options})]}});function pn(e,t){return!e.selection.empty&&!me(e.selection)&&t.isEditable}function mn(e,t){return pn(e,t)&&!t.isFocused&&!t.view.dragging}function hn(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function gn(e){e.focus()}j.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new F({key:new N(`selection`),props:{decorations(n){return mn(n,e)?D.create(n.doc,[ke.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return pn(t.state,e)&&hn(),!1},focus(t){return pn(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&gn(t)}),!1}}}})]}});function _n({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var vn=j.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new N(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new F({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!_n({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!_n({node:r,types:n})}}})]}}),yn=j.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Wt(e,t),redo:()=>({state:e,dispatch:t})=>Gt(e,t)}},addProseMirrorPlugins(){return[Ht(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),bn=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},xn=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new I(n,0,0);return e.replace(l,i.after(),r),e.setSelection(k.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},Sn=/^\s*>\s$/,Cn=A.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return bn(`blockquote`,{...O(this.options.HTMLAttributes,e),children:bn(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
2
|
+
`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
|
|
3
|
+
`))}),n.join(`
|
|
4
|
+
>
|
|
5
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>xn(this.editor,this.type)}},addInputRules(){return[Fe({find:Sn,type:this.type})]}}),wn=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Tn=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,En=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Dn=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,On=Ue.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return bn(`strong`,{...O(this.options.HTMLAttributes,e),children:bn(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[be({find:wn,type:this.type}),be({find:En,type:this.type})]},addPasteRules(){return[Ne({find:Tn,type:this.type}),Ne({find:Dn,type:this.type})]}}),kn=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},An=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},jn=Ue.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,O(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[be({find:kn,type:this.type})]},addPasteRules(){return[Ne({find:An,type:this.type})]}}),Mn=4,Nn=/^```([a-z]+)?[\s\n]$/,Pn=/^~~~([a-z]+)?[\s\n]$/,Fn=A.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Mn,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,O(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
|
|
6
|
+
`):`\`\`\`${r}
|
|
7
|
+
|
|
8
|
+
\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Mn,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
|
|
9
|
+
`,`
|
|
10
|
+
`).split(`
|
|
11
|
+
`).map(e=>o+e).join(`
|
|
12
|
+
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Mn,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
|
|
13
|
+
`,`
|
|
14
|
+
`).split(`
|
|
15
|
+
`),c=0,l=0,u=r-a;for(let e=0;e<s.length;e+=1){if(l+s[e].length>=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e<c;e+=1)p+=s[e].length+1;return e.delete(p,p+f),r-p<=f&&e.setSelection(k.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
|
|
16
|
+
`,`
|
|
17
|
+
`).split(`
|
|
18
|
+
`).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(`
|
|
19
|
+
`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
20
|
+
|
|
21
|
+
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(P.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Ie({find:Nn,type:this.type,getAttributes:e=>({language:e[1]})}),Ie({find:Pn,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new F({key:new N(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
|
|
22
|
+
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(k.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),In=A.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,O(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
23
|
+
`},renderMarkdown:()=>`
|
|
24
|
+
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ln=A.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,O(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Ie({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Rn=A.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,O(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Ke(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return me(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(k.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(We.create(t.doc,n.pos)):t.setSelection(k.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(k.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ye({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),zn=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Bn=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Vn=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Hn=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Un=Ue.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,O(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[be({find:zn,type:this.type}),be({find:Vn,type:this.type})]},addPasteRules(){return[Ne({find:Bn,type:this.type}),Ne({find:Hn,type:this.type})]}}),Wn=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Gn=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Kn=`numeric`,qn=`ascii`,Jn=`alpha`,Yn=`asciinumeric`,Xn=`alphanumeric`,Zn=`domain`,Qn=`emoji`,$n=`scheme`,er=`slashscheme`,tr=`whitespace`;function nr(e,t){return e in t||(t[e]=[]),t[e]}function rr(e,t,n){t[Kn]&&(t[Yn]=!0,t[Xn]=!0),t[qn]&&(t[Yn]=!0,t[Jn]=!0),t[Yn]&&(t[Xn]=!0),t[Jn]&&(t[Xn]=!0),t[Xn]&&(t[Zn]=!0),t[Qn]&&(t[Zn]=!0);for(let r in t){let t=nr(r,n);t.indexOf(e)<0&&t.push(e)}}function ir(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function z(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}z.groups={},z.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=z.groups;let i;return t&&t.j?i=t:(i=new z(t),n&&r&&rr(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=z.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new z,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new z,a&&(r&&(o.t&&typeof o.t==`string`?rr(a,Object.assign(ir(o.t,r),n),r):n&&rr(a,n,r)),o.t=a),i.j[e]=o,o}};var B=(e,t,n,r,i)=>e.ta(t,n,r,i),V=(e,t,n,r,i)=>e.tr(t,n,r,i),ar=(e,t,n,r,i)=>e.ts(t,n,r,i),H=(e,t,n,r,i)=>e.tt(t,n,r,i),or=`WORD`,sr=`UWORD`,cr=`ASCIINUMERICAL`,lr=`ALPHANUMERICAL`,ur=`LOCALHOST`,dr=`TLD`,fr=`UTLD`,pr=`SCHEME`,mr=`SLASH_SCHEME`,hr=`NUM`,gr=`WS`,_r=`NL`,vr=`OPENBRACE`,yr=`CLOSEBRACE`,br=`OPENBRACKET`,xr=`CLOSEBRACKET`,Sr=`OPENPAREN`,Cr=`CLOSEPAREN`,wr=`OPENANGLEBRACKET`,Tr=`CLOSEANGLEBRACKET`,Er=`FULLWIDTHLEFTPAREN`,Dr=`FULLWIDTHRIGHTPAREN`,Or=`LEFTCORNERBRACKET`,kr=`RIGHTCORNERBRACKET`,Ar=`LEFTWHITECORNERBRACKET`,jr=`RIGHTWHITECORNERBRACKET`,Mr=`FULLWIDTHLESSTHAN`,Nr=`FULLWIDTHGREATERTHAN`,Pr=`AMPERSAND`,Fr=`APOSTROPHE`,Ir=`ASTERISK`,Lr=`AT`,Rr=`BACKSLASH`,zr=`BACKTICK`,Br=`CARET`,Vr=`COLON`,Hr=`COMMA`,Ur=`DOLLAR`,Wr=`DOT`,Gr=`EQUALS`,Kr=`EXCLAMATION`,U=`HYPHEN`,qr=`PERCENT`,Jr=`PIPE`,Yr=`PLUS`,Xr=`POUND`,Zr=`QUERY`,Qr=`QUOTE`,$r=`FULLWIDTHMIDDLEDOT`,ei=`SEMI`,ti=`SLASH`,ni=`TILDE`,ri=`UNDERSCORE`,ii=`EMOJI`,ai=`SYM`,oi=Object.freeze({__proto__:null,ALPHANUMERICAL:lr,AMPERSAND:Pr,APOSTROPHE:Fr,ASCIINUMERICAL:cr,ASTERISK:Ir,AT:Lr,BACKSLASH:Rr,BACKTICK:zr,CARET:Br,CLOSEANGLEBRACKET:Tr,CLOSEBRACE:yr,CLOSEBRACKET:xr,CLOSEPAREN:Cr,COLON:Vr,COMMA:Hr,DOLLAR:Ur,DOT:Wr,EMOJI:ii,EQUALS:Gr,EXCLAMATION:Kr,FULLWIDTHGREATERTHAN:Nr,FULLWIDTHLEFTPAREN:Er,FULLWIDTHLESSTHAN:Mr,FULLWIDTHMIDDLEDOT:$r,FULLWIDTHRIGHTPAREN:Dr,HYPHEN:U,LEFTCORNERBRACKET:Or,LEFTWHITECORNERBRACKET:Ar,LOCALHOST:ur,NL:_r,NUM:hr,OPENANGLEBRACKET:wr,OPENBRACE:vr,OPENBRACKET:br,OPENPAREN:Sr,PERCENT:qr,PIPE:Jr,PLUS:Yr,POUND:Xr,QUERY:Zr,QUOTE:Qr,RIGHTCORNERBRACKET:kr,RIGHTWHITECORNERBRACKET:jr,SCHEME:pr,SEMI:ei,SLASH:ti,SLASH_SCHEME:mr,SYM:ai,TILDE:ni,TLD:dr,UNDERSCORE:ri,UTLD:fr,UWORD:sr,WORD:or,WS:gr}),si=/[a-z]/,ci=/\p{L}/u,li=/\p{Emoji}/u,ui=/\d/,di=/\s/,fi=`\r`,pi=`
|
|
25
|
+
`,mi=`️`,hi=``,gi=``,_i=null,vi=null;function yi(e=[]){let t={};z.groups=t;let n=new z;_i??=Ci(Wn),vi??=Ci(Gn),H(n,`'`,Fr),H(n,`{`,vr),H(n,`}`,yr),H(n,`[`,br),H(n,`]`,xr),H(n,`(`,Sr),H(n,`)`,Cr),H(n,`<`,wr),H(n,`>`,Tr),H(n,`(`,Er),H(n,`)`,Dr),H(n,`「`,Or),H(n,`」`,kr),H(n,`『`,Ar),H(n,`』`,jr),H(n,`<`,Mr),H(n,`>`,Nr),H(n,`&`,Pr),H(n,`*`,Ir),H(n,`@`,Lr),H(n,"`",zr),H(n,`^`,Br),H(n,`:`,Vr),H(n,`,`,Hr),H(n,`$`,Ur),H(n,`.`,Wr),H(n,`=`,Gr),H(n,`!`,Kr),H(n,`-`,U),H(n,`%`,qr),H(n,`|`,Jr),H(n,`+`,Yr),H(n,`#`,Xr),H(n,`?`,Zr),H(n,`"`,Qr),H(n,`/`,ti),H(n,`;`,ei),H(n,`~`,ni),H(n,`_`,ri),H(n,`\\`,Rr),H(n,`・`,$r);let r=V(n,ui,hr,{[Kn]:!0});V(r,ui,r);let i=V(r,si,cr,{[Yn]:!0}),a=V(r,ci,lr,{[Xn]:!0}),o=V(n,si,or,{[qn]:!0});V(o,ui,i),V(o,si,o),V(i,ui,i),V(i,si,i);let s=V(n,ci,sr,{[Jn]:!0});V(s,si),V(s,ui,a),V(s,ci,s),V(a,ui,a),V(a,si),V(a,ci,a);let c=H(n,pi,_r,{[tr]:!0}),l=H(n,fi,gr,{[tr]:!0}),u=V(n,di,gr,{[tr]:!0});H(n,gi,u),H(l,pi,c),H(l,gi,u),V(l,di,u),H(u,fi),H(u,pi),V(u,di,u),H(u,gi,u);let d=V(n,li,ii,{[Qn]:!0});H(d,`#`),V(d,li,d),H(d,mi,d);let f=H(d,hi);H(f,`#`),V(f,li,d);let p=[[si,o],[ui,i]],m=[[si,null],[ci,s],[ui,a]];for(let e=0;e<_i.length;e++)Si(n,_i[e],dr,or,p);for(let e=0;e<vi.length;e++)Si(n,vi[e],fr,sr,m);rr(dr,{tld:!0,ascii:!0},t),rr(fr,{utld:!0,alpha:!0},t),Si(n,`file`,pr,or,p),Si(n,`mailto`,pr,or,p),Si(n,`http`,mr,or,p),Si(n,`https`,mr,or,p),Si(n,`ftp`,mr,or,p),Si(n,`ftps`,mr,or,p),rr(pr,{scheme:!0,ascii:!0},t),rr(mr,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[$n]:!0}:{[er]:!0};r.indexOf(`-`)>=0?i[Zn]=!0:si.test(r)?ui.test(r)?i[Yn]=!0:i[qn]=!0:i[Kn]=!0,ar(n,r,r,i)}return ar(n,`localhost`,ur,{ascii:!0}),n.jd=new z(ai),{start:n,tokens:Object.assign({groups:t},oi)}}function bi(e,t){let n=xi(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function xi(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function Si(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new z(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new z(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function Ci(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var wi={defaultProtocol:`http`,events:null,format:Ei,formatHref:Ei,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ti(e,t=null){let n=Object.assign({},wi);e&&(n=Object.assign(n,e instanceof Ti?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}Ti.prototype={o:wi,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:wi[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function Ei(e){return e}function Di(e,t){this.t=`token`,this.v=e,this.tk=t}Di.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=wi.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function Oi(e,t){class n extends Di{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var ki=Oi(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Ai=Oi(`text`),ji=Oi(`nl`),Mi=Oi(`url`,{isLink:!0,toHref(e=wi.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==ur&&e[1].t===Vr}}),W=e=>new z(e);function Ni({groups:e}){let t=e.domain.concat([Pr,Ir,Lr,Rr,zr,Br,Ur,Gr,U,hr,qr,Jr,Yr,Xr,ti,ai,ni,ri]),n=[Fr,Vr,Hr,Wr,Kr,qr,Zr,Qr,ei,wr,Tr,vr,yr,xr,br,Sr,Cr,Er,Dr,Or,kr,Ar,jr,Mr,Nr],r=[Pr,Fr,Ir,Rr,zr,Br,Ur,Gr,U,vr,yr,qr,Jr,Yr,Xr,Zr,ti,ai,ni,ri],i=W(),a=H(i,ni);B(a,r,a),B(a,e.domain,a);let o=W(),s=W(),c=W();B(i,e.domain,o),B(i,e.scheme,s),B(i,e.slashscheme,c),B(o,r,a),B(o,e.domain,o);let l=H(o,Lr);H(a,Lr,l),H(s,Lr,l),H(c,Lr,l);let u=H(a,Wr);B(u,r,a),B(u,e.domain,a);let d=W();B(l,e.domain,d),B(d,e.domain,d);let f=H(d,Wr);B(f,e.domain,d);let p=W(ki);B(f,e.tld,p),B(f,e.utld,p),H(l,ur,p);let m=H(d,U);H(m,U,m),B(m,e.domain,d),B(p,e.domain,d),H(p,Wr,f),H(p,U,m);let h=H(o,U),g=H(o,Wr);H(h,U,h),B(h,e.domain,o),B(g,r,a),B(g,e.domain,o);let _=W(Mi);B(g,e.tld,_),B(g,e.utld,_),B(_,e.domain,o),B(_,r,a),H(_,Wr,g),H(_,U,h),H(_,Lr,l);let v=H(_,Vr),y=W(Mi);B(v,e.numeric,y);let b=W(Mi),x=W();B(b,t,b),B(b,n,x),B(x,t,b),B(x,n,x),H(_,ti,b),H(y,ti,b);let S=H(s,Vr),ee=H(H(H(c,Vr),ti),ti);B(s,e.domain,o),H(s,Wr,g),H(s,U,h),B(c,e.domain,o),H(c,Wr,g),H(c,U,h),B(S,e.domain,b),H(S,ti,b),H(S,Zr,b),B(ee,e.domain,b),B(ee,t,b),H(ee,ti,b);let te=[[vr,yr],[br,xr],[Sr,Cr],[wr,Tr],[Er,Dr],[Or,kr],[Ar,jr],[Mr,Nr]];for(let e=0;e<te.length;e++){let[r,i]=te[e],a=H(b,r);H(x,r,a);let o=W(Mi);B(a,t,o);let s=W();B(a,n,s),H(a,i,b),B(o,t,o),B(o,n,s),B(s,t,o),B(s,n,s),H(o,i,b),H(s,i,b)}return H(i,ur,_),H(i,_r,ji),{start:i,tokens:oi}}function Pi(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Fi(Ai,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(Fi(e,t,r))}}return o.length>0&&a.push(Fi(Ai,t,o)),a}function Fi(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var Ii=typeof console<`u`&&console&&console.warn||(()=>{}),Li=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,G={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Ri(){return z.groups={},G.scanner=null,G.parser=null,G.tokenQueue=[],G.pluginQueue=[],G.customSchemes=[],G.initialized=!1,G}function zi(e,t=!1){if(G.initialized&&Ii(`linkifyjs: already initialized - will not register custom scheme "${e}" ${Li}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
26
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
27
|
+
2. Cannot start or end with "-"
|
|
28
|
+
3. "-" cannot repeat`);G.customSchemes.push([e,t])}function Bi(){G.scanner=yi(G.customSchemes);for(let e=0;e<G.tokenQueue.length;e++)G.tokenQueue[e][1]({scanner:G.scanner});G.parser=Ni(G.scanner.tokens);for(let e=0;e<G.pluginQueue.length;e++)G.pluginQueue[e][1]({scanner:G.scanner,parser:G.parser});return G.initialized=!0,G}function Vi(e){return G.initialized||Bi(),Pi(G.parser.start,e,bi(G.scanner.start,e))}Vi.scan=bi;function Hi(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new Ti(n),i=Vi(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var Ui=`[\0- \xA0 -\u2029 ]`,Wi=new RegExp(Ui),Gi=RegExp(`${Ui}$`),Ki=new RegExp(Ui,`g`);function qi(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function Ji(e){return new F({key:new N(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=Ge(n.doc,[...t]);if(Me(s).forEach(({newRange:t})=>{let n=ct(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!Gi.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(Wi).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=Vi(n).map(t=>t.toObject(e.defaultProtocol));if(!qi(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{ge(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function Yi(e){return new F({key:new N(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=st(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var Xi=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,Zi=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Qi(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function $i(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&Qi(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function ea(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||Qi(e,t.index??0)||$i(e,t.index??0)?!1:!!r.trim()&&n(i)}function ta(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function na(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function ra(e){return{href:e.data?.href,title:e.data?.title??null}}function ia(e){let t=be({find:t=>{let n=Xi.exec(t);return!n||!ea(t,n,e.isAllowedHref)?null:ta(n)},type:e.type,getAttributes:ra});return new at({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function aa(e){let t=Ne({find:t=>{let n=[];for(let r of t.matchAll(Zi))ea(t,r,e.isAllowedHref)&&n.push(ta(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>na(t,e)));return[...n,...r]},type:e.type,getAttributes:ra});return new et({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function oa(e){return new F({key:new N(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=Hi(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function sa(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(Ki,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var ca=Ue.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){zi(e);return}zi(e.scheme,e.optionalSlashes)})},onDestroy(){Ri()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!sa(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!sa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!sa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,O(this.options.HTMLAttributes,e),0]:[`a`,O(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!sa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!sa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[ia({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!sa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;Hi(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!sa(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[aa({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!sa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[Ne({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(Ji({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!sa(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(Yi({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(oa({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),la=Object.defineProperty,ua=(e,t)=>{for(var n in t)la(e,n,{get:t[n],enumerable:!0})},da=`listItem`,fa=`textStyle`,pa=/^\s*([-+*])\s$/,ma=A.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,O(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
29
|
+
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(da,this.editor.getAttributes(fa)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Fe({find:pa,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Fe({find:pa,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(fa),editor:this.editor})),[e]}}),ha=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},ga=(e,t,n,r)=>{let i=ha(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:c,items:l}=i,u=e.tr;u.delete(s,s+o.nodeSize);let d=u.mapping.map(c);return u.insert(d,M.from(l)),u.setSelection(a.map(u.doc,u.mapping)),t&&t(u),!0},_a=(e,t,n)=>ga(e.state,e.view.dispatch,t,n),va=(e,t)=>j.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>_a(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),ya=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],ba=`abcdefghijklmnopqrstuvwxyz`,xa=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function Sa(e){let t=e,n=``;for(let[e,r]of ya)for(;t>=e;)n+=r,t-=e;return n}function Ca(e){return Sa(e).toUpperCase()}function wa(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of ya)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function Ta(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=wa(e);return t<=0?!1:(e===e.toLowerCase()?Sa(t):Ca(t))===e}function Ea(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function Da(e){if(e<=26)return ba[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?ba[n]:ba[t]+ba[n]}function Oa(e){if(!(!e||/^\d+$/.test(e))){if(Ta(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function ka(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=Oa(e);if(t===`i`||t===`I`)return wa(e);if(t===`a`||t===`A`){let t=Ea(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function Aa(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return Da(t);case`A`:return Da(t).toUpperCase();case`i`:return Sa(t);case`I`:return Ca(t);default:return String(t)}}function ja(e){if(e.length===0)return!1;let t=Oa(e[0])??`numeric`,n=ka(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=Aa(t,n+r);if(e[r]!==i)return!1}return!0}function Ma(e){return{type:Oa(e),start:ka(e)}}function Na(e){let{type:t,start:n}=Ma(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function Pa(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${Da(r)}${n}`;case`A`:return`${Da(r).toUpperCase()}${n}`;case`i`:return`${Sa(r)}${n}`;case`I`:return`${Ca(r)}${n}`;default:return`${r}${n}`}}function Fa(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function Ia(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var La=A.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,O(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(Fa(e))return{type:`listItem`,content:[{type:`paragraph`,content:Ia(e.text||``,t)}]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else{let i=e.tokens[0];if(i&&i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:r}},renderMarkdown:(e,t,n)=>Se(e,t,e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){let t=e.meta?.parentAttrs?.start||1;return Pa(e.meta?.parentAttrs?.type,t-1+(e.index||0),`. `)}return`- `},n),addExtensions(){return[va(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});ua({},{findListItemPos:()=>Ra,getNextListDepth:()=>za,handleBackspace:()=>Va,handleDelete:()=>Wa,handleTab:()=>Ga,hasListBefore:()=>Ba,hasListItemAfter:()=>Ka,hasListItemBefore:()=>qa,listItemHasSubList:()=>Ja,nextListIsDeeper:()=>Ha,nextListIsHigher:()=>Ua});var Ra=(e,t)=>{let{$from:n}=t.selection,r=Xe(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},za=(e,t)=>{let n=Ra(e,t);if(!n)return!1;let[,r]=De(t,e,n.$pos.pos+4);return r},Ba=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},Va=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Ae(e.state,t)&&Ba(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!Ae(e.state,t)||!we(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},Ha=(e,t)=>{let n=za(e,t),r=Ra(e,t);return!r||!n?!1:n>r.depth},Ua=(e,t)=>{let n=za(e,t),r=Ra(e,t);return!r||!n?!1:n<r.depth},Wa=(e,t)=>{if(!Ae(e.state,t)||!xe(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Ha(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():Ua(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},Ga=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||Ae(r,t))return!1;let o=pe(a);if(!o||!n.includes(o.type.name))return!1;let s=o.lastChild;if(!s||s.type.name!==t)return!1;let c=a.parent;if(!s.canReplace(s.childCount,s.childCount,M.from(c)))return!1;let l=a.before(),u=a.after(),d=l-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(l,u).insert(d,M.from(c)),e.setSelection(k.create(e.doc,d+1)),e.scrollIntoView()),!0))},Ka=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-n.parentOffset-2);return r.index()!==r.parent.childCount-1&&r.nodeAfter?.type.name===e},qa=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-2);return r.index()!==0&&r.nodeBefore?.type.name===e},Ja=(e,t,n)=>{if(!n)return!1;let r=Xe(e,t.schema),i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},Ya=j.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Wa(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Wa(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Va(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Va(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&Ga(e,t,n))return!0;return!1}}}}),Xa=RegExp(`^(\\s*)(${xa})([.)])\\s+(.*)$`),Za=/^\s/,Qa={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function $a(e){return Xa.test(e.trimStart())}function eo(e){let t=e.trimStart();return Qa.bulletItem.test(t)||$a(t)||Qa.heading.test(t)||Qa.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||Qa.codeFence.test(t)||Qa.blockMath.test(t)}function to(e){return Object.values(Qa).some(t=>t.test(e))}function no(e){let t=[],n=[],r=!1;return e.forEach(e=>{if(r){n.push(e);return}if(e.trim()===``){r=!0,n.push(e);return}if(t.length>0&&eo(e)){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}function ro(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],a=i.match(Xa);if(!a)break;let[,o,s,c,l]=a,u=o.length,d=parseInt(s,10),f=isNaN(d)?Oa(s):void 0,p=isNaN(d)?ka(s):d,m=[l],h=n+1,g=[i],_=!1;for(;h<e.length;){let t=e[h];if(t.match(Xa))break;if(t.trim()===``)g.push(t),m.push(``),_=!0,h+=1;else if(t.match(Za)){let e=t.length-t.trimStart().length,n=u+s.length+1;g.push(t),m.push(t.slice(Math.min(e,n))),h+=1}else{if(_||to(t))break;g.push(t),m.push(t),h+=1}}t.push({indent:u,number:p,type:f,content:m.join(`
|
|
30
|
+
`).trim(),contentLines:m,raw:g.join(`
|
|
31
|
+
`)}),r=h,n=h}return[t,r]}var io=RegExp(`^(${xa})([.)])\\s+(.+)$`);function ao(e){let t=e.split(`
|
|
32
|
+
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(io);if(!t)return null;n.push({marker:t[1],content:t[3]})}return ja(n.map(e=>e.marker))?{type:`orderedList`,attrs:Na(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function oo(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=no(a.contentLines),c=o.join(`
|
|
33
|
+
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
|
|
34
|
+
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=oo(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
|
|
35
|
+
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function so(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var co=`listItem`,lo=`textStyle`,uo=/^(\d+)\.\s$/;function fo(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var po=A.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=fo(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=fo(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=O(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?so(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
36
|
+
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let r=e.split(`
|
|
37
|
+
`),[i,a]=ro(r);if(i.length===0)return;let o=oo(i,i[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,typeMarker:i[0]?.type,items:o,raw:r.slice(0,a).join(`
|
|
38
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(co,this.editor.getAttributes(lo)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new F({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=ao(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=Fe({find:uo,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Fe({find:uo,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(lo)}),joinPredicate:e,editor:this.editor})),[t]}}),mo=/^\s*(\[([( |x])?\])\s$/,ho=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,go=(e,t,n)=>(n?.checkboxLabel)?.call(n,e,t)||`Task item checkbox for ${e.textContent||`empty task item`}`,_o=A.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,O(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{let n=`- [${e.attrs?.checked?`x`:` `}] `;return Se(e,t,n)},addExtensions(){return this.options.nested?[va(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=ho;let l=e=>{let t=go(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Ye(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Fe({find:mo,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),vo=A.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,O(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
39
|
+
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=Ce(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=Ce(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});j.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(ma.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(La.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Ya.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(po.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(_o.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(vo.configure(this.options.taskList)),e}});var yo=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,bo=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,xo=Ue.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,O(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[be({find:yo,type:this.type})]},addPasteRules(){return[Ne({find:bo,type:this.type})]}}),So=Ue.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,O(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Co=j.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(On.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(Cn.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(ma.configure(this.options.bulletList)),this.options.code!==!1&&e.push(jn.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Fn.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Ve.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Kt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(qt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(In.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Ln.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(yn.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Rn.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Un.configure(this.options.italic)),this.options.listItem!==!1&&e.push(La.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Ya.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(ca.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(po.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(nt.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(xo.configure(this.options.strike)),this.options.text!==!1&&e.push(Qe.configure(this.options.text)),this.options.underline!==!1&&e.push(So.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(vn.configure(this.options?.trailingNode)),e}}),K=e(t(),1),wo=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},To=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=wo(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},Eo=(e,t)=>{let{state:n,view:r,extensionManager:i}=e,{schema:a,selection:o}=n,{empty:s,$anchor:c}=o,l=!!i.extensions.find(e=>e.name===`gapCursor`);if(!s||c.parent.type!==a.nodes.detailsSummary||!l||t===`right`&&c.parentOffset!==c.parent.nodeSize-2)return!1;let u=je(e=>e.type===a.nodes.details)(o);if(!u)return!1;let d=Be(u.node,e=>e.type===a.nodes.detailsContent);if(!d.length||wo(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=L.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new L(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},Do=A.create({name:`details`,content:`detailsSummary detailsContent`,group:`block`,defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:`is-open`,HTMLAttributes:{},renderToggleButton:({element:e,isOpen:t})=>{e.setAttribute(`aria-label`,t?`Collapse details content`:`Expand details content`)}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:e=>e.hasAttribute(`open`),renderHTML:({open:e})=>e?{open:``}:{}}}:[]},parseHTML(){return[{tag:`details`}]},renderHTML({HTMLAttributes:e}){return[`details`,O(this.options.HTMLAttributes,e),0]},...Re({nodeName:`details`,content:`block`}),addNodeView(){return({editor:e,getPos:t,node:n,HTMLAttributes:r})=>{let i=document.createElement(`div`),a=O(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(a).forEach(([e,t])=>i.setAttribute(e,t));let o=document.createElement(`button`);o.type=`button`;let s=e=>{this.options.renderToggleButton({element:o,...e})};i.append(o);let c=document.createElement(`div`);i.append(c);let l=e=>{let{setToValue:t,node:r=n}=e||{};if(t!==void 0)if(t){if(i.classList.contains(this.options.openClassName))return;i.classList.add(this.options.openClassName)}else{if(!i.classList.contains(this.options.openClassName))return;i.classList.remove(this.options.openClassName)}else i.classList.toggle(this.options.openClassName);let a=i.classList.contains(this.options.openClassName);s({isOpen:a,node:r});let o=new Event(`toggleDetailsContent`);c.querySelector(`:scope > div[data-type="detailsContent"]`)?.dispatchEvent(o)};return s({isOpen:!!n.attrs.open,node:n}),n.attrs.open&&setTimeout(()=>l()),o.addEventListener(`click`,()=>{if(l(),!this.options.persist){e.commands.focus(void 0,{scrollIntoView:!1});return}if(e.isEditable&&typeof t==`function`){let{from:n,to:r}=e.state.selection;e.chain().command(({tr:e})=>{let n=t();if(typeof n!=`number`)return!1;let r=e.doc.nodeAt(n);return r?.type===this.type&&(e.setNodeMarkup(n,void 0,{open:!r.attrs.open}),!0)}).setTextSelection({from:n,to:r}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:i,contentDOM:c,ignoreMutation(e){if(e.type===`selection`)return!1;let t=e.target,n=i.contains(t);return o.contains(t)||!n||i===t},update:e=>e.type===this.type&&(e.attrs.open===void 0?s({isOpen:i.classList.contains(this.options.openClassName),node:e}):l({setToValue:e.attrs.open,node:e}),!0)}}},addCommands(){return{setDetails:()=>({state:e,chain:t})=>{let{schema:n,selection:r}=e,{$from:i,$to:a}=r,o=i.blockRange(a);if(!o)return!1;let s=e.doc.slice(o.start,o.end);if(!n.nodes.detailsContent.contentMatch.matchFragment(s.content))return!1;let c=s.toJSON()?.content||[];return t().insertContentAt({from:o.start,to:o.end},{type:this.name,content:[{type:`detailsSummary`},{type:`detailsContent`,content:c}]}).setTextSelection(o.start+2).run()},unsetDetails:()=>({state:e,chain:t})=>{let{selection:n,schema:r}=e,i=je(e=>e.type===this.type)(n);if(!i)return!1;let a=Be(i.node,e=>e.type===r.nodes.detailsSummary),o=Be(i.node,e=>e.type===r.nodes.detailsContent);if(!a.length||!o.length)return!1;let s=a[0],c=o[0],l=i.pos,u=e.doc.resolve(l),d={from:l,to:l+i.node.nodeSize},f=c.node.content.toJSON()||[],p=[u.parent.type.contentMatch.defaultType?.create(null,s.node.content).toJSON(),...f];return t().insertContentAt(d,p).setTextSelection(l+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:e,selection:t}=this.editor.state,{empty:n,$anchor:r}=t;return!n||r.parent.type!==e.nodes.detailsSummary?!1:r.parentOffset===0?this.editor.commands.unsetDetails():this.editor.commands.command(({tr:e})=>{let t=r.pos-1,n=r.pos;return e.delete(t,n),!0})},Enter:({editor:e})=>{let{state:t,view:n}=e,{schema:r,selection:i}=t,{$head:a}=i;if(a.parent.type!==r.nodes.detailsSummary)return!1;let o=wo(a.after()+1,e),s=o?t.doc.nodeAt(a.after()):a.node(-2);if(!s)return!1;let c=o?0:a.indexAfter(-1),l=ot(s.contentMatchAt(c));if(!l||!s.canReplaceWith(c,c,l))return!1;let u=l.createAndFill();if(!u)return!1;let d=o?a.after()+1:a.after(-1),f=t.tr.replaceWith(d,d,u),p=f.doc.resolve(d),m=P.near(p,1);return f.setSelection(m),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:e})=>Eo(e,`right`),ArrowDown:({editor:e})=>Eo(e,`down`)}},addProseMirrorPlugins(){return[new F({key:new N(`detailsSelection`),appendTransaction:(e,t,n)=>{let{editor:r,type:i}=this;if(r.view.composing||!e.some(e=>e.selectionSet)||!t.selection.empty||!n.selection.empty||!ve(n,i.name))return;let{$from:a}=n.selection;if(wo(a.pos,r))return;let o=To(a,e=>e.type===i,r);if(!o)return;let s=Be(o.node,e=>e.type===n.schema.nodes.detailsSummary);if(!s.length)return;let c=s[0],l=(t.selection.from<n.selection.from?`forward`:`backward`)==`forward`?o.start+c.pos:o.pos+c.pos+c.node.nodeSize,u=k.create(n.doc,l);return n.tr.setSelection(u)}})]}}),Oo=A.create({name:`detailsContent`,content:`block+`,defining:!0,selectable:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,O(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:e})=>{let t=document.createElement(`div`),n=O(this.options.HTMLAttributes,e,{"data-type":this.name,hidden:`hidden`});return Object.entries(n).forEach(([e,n])=>t.setAttribute(e,n)),t.addEventListener(`toggleDetailsContent`,()=>{t.toggleAttribute(`hidden`)}),{dom:t,contentDOM:t,ignoreMutation(e){return e.type===`selection`?!1:!t.contains(e.target)||t===e.target},update:e=>e.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{state:t,view:n}=e,{selection:r}=t,{$from:i,empty:a}=r,o=je(e=>e.type===this.type)(r);if(!a||!o||!o.node.childCount)return!1;let s=i.index(o.depth),{childCount:c}=o.node;if(c!==s+1)return!1;let l=o.node.type.contentMatch.defaultType?.createAndFill();if(!l)return!1;let u=t.doc.resolve(o.pos+1),d=c-1,f=o.node.child(d),p=u.posAtIndex(d,o.depth);if(!f.eq(l))return!1;let m=i.node(-3);if(!m)return!1;let h=i.indexAfter(-3),g=ot(m.contentMatchAt(h));if(!g||!m.canReplaceWith(h,h,g))return!1;let _=g.createAndFill();if(!_)return!1;let{tr:v}=t,y=i.after(-2);v.replaceWith(y,y,_);let b=v.doc.resolve(y),x=P.near(b,1);v.setSelection(x);let S=p,ee=p+f.nodeSize;return v.delete(S,ee),v.scrollIntoView(),n.dispatch(v),!0}}},...Re({nodeName:`detailsContent`})}),ko=A.create({name:`detailsSummary`,content:`text*`,defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`summary`}]},renderHTML({HTMLAttributes:e}){return[`summary`,O(this.options.HTMLAttributes,e),0]},...Re({nodeName:`detailsSummary`,content:`inline`})}),Ao=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,jo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Mo=Ue.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Te(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){return[`mark`,O(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark(`highlight`,t.parseInline(e.tokens||[])),markdownTokenizer:{name:`highlight`,level:`inline`,start:e=>e.indexOf(`==`),tokenize(e,t,n){let r=/^(==)([^=]+)(==)/.exec(e);if(r){let e=r[2].trim(),t=n.inlineTokens(e);return{type:`highlight`,raw:r[0],text:e,tokens:t}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[be({find:Ao,type:this.type})]},addPasteRules(){return[Ne({find:jo,type:this.type})]}}),No,Po;if(typeof WeakMap<`u`){let e=new WeakMap;No=t=>e.get(t),Po=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;No=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},Po=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var q=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return No(e)||Po(e,Fo(e))}};function Fo(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=Io(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new q(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&Lo(s,o,e),s}function Io(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Lo(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=Ro(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function Ro(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function J(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var zo=new N(`selectingCells`);function Bo(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Vo(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function Y(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Ho(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Bo(t.$head)||Uo(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Uo(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Wo(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Go(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Ko(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function qo(e,t,n){let r=e.node(-1),i=q.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Jo(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Yo(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function Xo(e,t,n){let r=J(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var X=class e extends P{constructor(e,t=e){let n=e.node(-1),r=q.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Je(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Wo(r)&&Wo(i)&&Ko(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return k.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=q.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=Jo(e,0,l)),u>0&&(e=Jo(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(M.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new I(M.from(o),1,1)}replace(e,t=I.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?I.empty:t)}let i=P.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new I(M.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=q.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=q.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new Zo(this.$anchorCell.pos,this.$headCell.pos)}};X.prototype.visible=!1,P.jsonID(`cell`,X);var Zo=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Ko(t,n)?new X(t,n):P.near(n,1)}};function Qo(e){if(!(e.selection instanceof X))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(ke.node(n,n+e.nodeSize,{class:`selectedCell`}))}),D.create(e.doc,t)}function $o({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function es({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function ts(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof We&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=X.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=X.rowSelection(e,e)}else if(!n){let e=q.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=X.create(i,t+1,n)}}else r instanceof k&&$o(r)?a=k.create(i,r.from):r instanceof k&&es(r)&&(a=k.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var ns=new N(`fix-tables`);function rs(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?rs(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function is(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=as(e,t,r,n))};return t?t.doc!=e.doc&&rs(t.doc,e.doc,0,r):e.doc.descendants(r),n}function as(e,t,n,r){let i=q.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,Jo(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=J(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(ns,{fixTables:!0})}function Z(e){let t=e.selection,n=Ho(e),r=n.node(-1),i=n.start(-1),a=q.get(r);return{...t instanceof X?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function os(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Xo(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Yo(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?J(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function ss(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(os(e.tr,n,n.left))}return!0}function cs(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(os(e.tr,n,n.right))}return!0}function ls(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,Jo(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function us(e,t){if(!Y(e))return!1;if(t){let n=Z(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;ls(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=q.get(e)}t(r)}return!0}function ds(e,t,n){let r=J(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function fs(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;ds(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?J(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,J(r.type.schema).row.create(null,o)),e}function ps(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(fs(e.tr,n,n.top))}return!0}function ms(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(fs(e.tr,n,n.bottom))}return!0}function hs(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function gs(e,t){if(!Y(e))return!1;if(t){let n=Z(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;hs(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=q.get(n.table)}t(r)}return!0}function _s(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function vs({width:e,height:t,map:n},r){let i=r.top*e+r.left,a=i,o=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[a]==n[a-1]||r.right<e&&n[s]==n[s+1])return!0;a+=e,s+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[o]==n[o+e])return!0;i++,o++}return!1}function ys(e,t){let n=e.selection;if(!(n instanceof X)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Z(e),{map:i}=r;if(vs(i,r))return!1;if(t){let n=e.tr,a={},o=M.empty,s,c;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){let l=i.map[e*i.width+t],u=r.table.nodeAt(l);if(!(a[l]||!u))if(a[l]=!0,s==null)s=l,c=u;else{_s(u)||(o=o.append(u.content));let e=n.mapping.map(l+r.tableStart);n.delete(e,e+u.nodeSize)}}if(s==null||c==null)return!0;if(n.setNodeMarkup(s+r.tableStart,null,{...Yo(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),o.size>0){let e=s+1+c.content.size,t=_s(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new X(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function bs(e,t){let n=J(e.schema);return xs(({node:e})=>n[e.type.spec.tableRole])(e,t)}function xs(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof X){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=Vo(r.$from),!i)return!1;a=Bo(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=Z(t),u=t.tr;for(let e=0;e<l.right-l.left;e++)s.push(c?{...o,colwidth:c&&c[e]?[c[e]]:null}:o);let d;for(let t=l.top;t<l.bottom;t++){let n=l.map.positionAt(t,l.left,l.table);t==l.top&&(n+=i.nodeSize);for(let r=l.left,a=0;r<l.right;r++,a++)(r!=l.left||t!=l.top)&&u.insert(d=u.mapping.map(n+l.tableStart,1),e({node:i,row:t,col:r}).createAndFill(s[a]))}u.setNodeMarkup(a,e({node:i,row:l.top,col:l.left}),s[0]),r instanceof X&&u.setSelection(new X(u.doc.resolve(r.$anchorCell.pos),d?u.doc.resolve(d):void 0)),n(u)}return!0}}function Ss(e,t){return function(n,r){if(!Y(n))return!1;let i=Ho(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof X?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Cs(e){return function(t,n){if(!Y(t))return!1;if(n){let r=J(t.schema),i=Z(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function ws(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function Ts(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?Cs(e):function(t,n){if(!Y(t))return!1;if(n){let r=J(t.schema),i=Z(t),a=t.tr,o=ws(`row`,i,r),s=ws(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}Ts(`row`,{useDeprecatedLogic:!0}),Ts(`column`,{useDeprecatedLogic:!0});var Es=Ts(`cell`,{useDeprecatedLogic:!0});function Ds(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function Os(e){return function(t,n){if(!Y(t))return!1;let r=Ds(Ho(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(k.between(e,Go(e))).scrollIntoView())}return!0}}function ks(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function As(e,t){let n=e.selection;if(!(n instanceof X))return!1;if(t){let r=e.tr,i=J(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new I(i,0,0))}),r.docChanged&&t(r)}return!0}function js(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=Ns(J(o).row,new I(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?Ns(J(o).row,new I(t,n,r)).content:t);else return null;return Ms(o,s)}function Ms(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(M.empty),n[i]<r){let a=J(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(M.from(o))}return{height:t.length,width:r,rows:t}}function Ns(e,t){let n=e.createAndFill();return new rt(n).replace(0,n.content.size,t).doc}function Ps({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(Jo(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(M.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(M.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function Fs(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=J(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,M.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function Is(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function Ls(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,Jo(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Jo(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function Rs(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=q.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=q.get(a),f=d.mapping.maps.length}Fs(d,o,a,n,l,u,f)&&p(),Is(d,o,a,n,c,l,s,f)&&p(),Is(d,o,a,n,c,l,u,f)&&p(),Ls(d,o,a,n,s,u,c,f)&&p(),Ls(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new I(i.rows[e-s],0,0))}p(),d.setSelection(new X(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var zs=Le({ArrowLeft:Vs(`horiz`,-1),ArrowRight:Vs(`horiz`,1),ArrowUp:Vs(`vert`,-1),ArrowDown:Vs(`vert`,1),"Shift-ArrowLeft":Hs(`horiz`,-1),"Shift-ArrowRight":Hs(`horiz`,1),"Shift-ArrowUp":Hs(`vert`,-1),"Shift-ArrowDown":Hs(`vert`,1),Backspace:As,"Mod-Backspace":As,Delete:As,"Mod-Delete":As});function Bs(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Vs(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof X)return Bs(n,r,P.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Ks(i,e,t);if(o==null)return!1;if(e==`horiz`)return Bs(n,r,P.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=qo(i,e,t),s;return s=a?P.near(a,1):t<0?P.near(n.doc.resolve(i.before(-1)),-1):P.near(n.doc.resolve(i.after(-1)),1),Bs(n,r,s)}}}function Hs(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof X)o=a;else{let r=Ks(i,e,t);if(r==null)return!1;o=new X(n.doc.resolve(r))}let s=qo(o.$headCell,e,t);return s?Bs(n,r,new X(o.$anchorCell,s)):!1}}function Us(e,t){let n=e.state.doc,r=Bo(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new X(r))),!0):!1}function Ws(e,t,n){if(!Y(e.state))return!1;let r=js(n),i=e.state.selection;if(i instanceof X){r||={width:1,height:1,rows:[M.from(Ns(J(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=q.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Ps(r,o.right-o.left,o.bottom-o.top),Rs(e.state,e.dispatch,a,o,r),!0}if(r){let t=Ho(e.state),n=t.start(-1);return Rs(e.state,e.dispatch,n,q.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function Gs(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=qs(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof X)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Bo(e.state.selection.$anchor))!=null&&Js(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Js(e,n),i=zo.getState(e.state)==null;if(!r||!Ko(t,r))if(i)r=t;else return;let a=new X(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(zo,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),zo.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(zo,-1))}function o(r){let o=r,s=zo.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(qs(e,o.target)!=n&&(c=Js(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function Ks(e,t,n){if(!(e.state.selection instanceof k))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function qs(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Js(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Bo(e.state.doc.resolve(r))||Bo(e.state.doc.resolve(i))}var Ys=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Xs(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,Xs(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Xs(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var Q=new N(`tableColumnResizing`);function Zs({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Ys,lastColumnResizable:i=!0}={}){let a=new F({key:Q,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=J(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new Qs(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=Q.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{$s(t,n,e,i)},mouseleave:e=>{ec(e)},mousedown:(e,r)=>{tc(e,r,t,n)}},decorations:e=>{let t=Q.getState(e);if(t&&t.activeHandle>-1)return uc(e,t.activeHandle)},nodeViews:{}}});return a}var Qs=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(Q);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Wo(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function $s(e,t,n,r){if(!e.editable)return;let i=Q.getState(e.state);if(i&&!i.dragging){let a=rc(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=ic(e,t,`left`,n):i-t.clientX<=n&&(o=ic(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=q.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}oc(e,o)}}}function ec(e){if(!e.editable)return;let t=Q.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&oc(e,-1)}function tc(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=Q.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=nc(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(Q,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=Q.getState(e.state);r?.dragging&&(sc(e,r.activeHandle,ac(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Q,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=Q.getState(e.state);if(i&&i.dragging){let a=ac(i.dragging,t,n);cc(e,i.activeHandle,a,r)}}return cc(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function nc(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function rc(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function ic(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=Bo(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=q.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function ac(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function oc(e,t){e.dispatch(e.state.tr.setMeta(Q,{setHandle:t}))}function sc(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=q.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():lc(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function cc(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=q.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&Xs(a,c.firstChild,c,r,s,n)}function lc(e){return Array(e).fill(0)}function uc(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return D.empty;let a=q.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,Q.getState(e)?.dragging&&n.push(ke.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(ke.widget(s,c))}}return D.create(e.doc,n)}function dc({allowTableNodeSelection:e=!1}={}){return new F({key:zo,state:{init(){return null},apply(e,t){let n=e.getMeta(zo);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:Qo,handleDOMEvents:{mousedown:Gs},createSelectionBetween(e){return zo.getState(e.state)==null?null:e.state.selection},handleTripleClick:Us,handleKeyDown:zs,handlePaste:Ws},appendTransaction(t,n,r){return ts(r,is(r,n),e)}})}function fc(e){return e===`left`||e===`right`||e===`center`?e:null}function pc(e){let t=(e.style.textAlign||``).trim().toLowerCase(),n=(e.getAttribute(`align`)||``).trim().toLowerCase();return fc(t||n)}function mc(e){return fc(e?.align)}function hc(){return{default:null,parseHTML:e=>pc(e),renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}function gc(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function _c(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):gc(e)}var vc=/[ \t\r\n\f]+/g;function yc(e){return e.children.length>0?!1:(e.textContent??``).replace(vc,``)===``}function bc(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}var xc=A.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:_c},align:hc()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>yc(e)?{}:!1,getContent:(e,t)=>bc(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,O(this.options.HTMLAttributes,e),0]}}),Sc=A.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:_c},align:hc()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>yc(e)?{}:!1,getContent:(e,t)=>bc(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,O(this.options.HTMLAttributes,e),0]}}),Cc=A.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,O(this.options.HTMLAttributes,e),0]}});function wc(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function Tc(e,t,n,r,i,a){var o;let s=0,c=!0,l=t.firstChild,u=e.firstChild;if(u!==null)for(let e=0,n=0;e<u.childCount;e+=1){let{colspan:o,colwidth:d}=u.child(e).attrs;for(let e=0;e<o;e+=1,n+=1){let o=i===n?a:d&&d[e],u=o?`${o}px`:``;if(s+=o||r,o||(c=!1),l){if(l.style.width!==u){let[e,t]=wc(r,o);l.style.setProperty(e,t)}l=l.nextSibling}else{let e=document.createElement(`col`),[n,i]=wc(r,o);e.style.setProperty(n,i),t.appendChild(e)}}}for(;l;){let e=l.nextSibling;(o=l.parentNode)==null||o.removeChild(l),l=e}let d=e.attrs.style&&typeof e.attrs.style==`string`&&/\bwidth\s*:/i.test(e.attrs.style);c&&!d?(n.style.width=`${s}px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=`${s}px`)}var Ec=class{constructor(e,t,n,r={}){this.node=e,this.cellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`));for(let[e,t]of Object.entries(r))t!=null&&(e===`style`?this.table.style.cssText=String(t):this.table.setAttribute(e,String(t)));e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Tc(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type===this.node.type&&(this.node=e,Tc(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){let t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type===`attributes`||e.type===`childList`||e.type===`characterData`))}};function Dc(e,t,n,r){let i=0,a=!0,o=[],s=e.firstChild;if(!s)return{};for(let e=0,c=0;e<s.childCount;e+=1){let{colspan:l,colwidth:u}=s.child(e).attrs;for(let e=0;e<l;e+=1,c+=1){let s=n===c?r:u&&u[e];i+=s||t,s||(a=!1);let[l,d]=wc(t,s);o.push([`col`,{style:`${l}: ${d}`}])}}let c=a?`${i}px`:``,l=a?``:`${i}px`;return{colgroup:[`colgroup`,{},...o],tableWidth:c,tableMinWidth:l}}function Oc(e,t){return t?e.createChecked(null,t):e.createAndFill()}function kc(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function Ac(e,t,n,r,i){let a=kc(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=Oc(a.cell,i);if(e&&s.push(e),r){let e=Oc(a.header_cell,i);e&&o.push(e)}}let c=[];for(let e=0;e<t;e+=1)c.push(a.row.createChecked(null,r&&e===0?o:s));return a.table.createChecked(null,c)}function jc(e){return e instanceof X}var Mc=({editor:e})=>{let{selection:t}=e.state;if(!jc(t))return!1;let n=0;return he(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function Nc(e,t){let n=e.mapping.map(t);if(he(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(k.near(e.doc.resolve(i),-1))}function Pc(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}if(e[n]!=="`"){t+=e[n++];continue}let r=0;for(;n+r<e.length&&e[n+r]==="`";)r+=1;let i=n+r,a=!1;for(;i<e.length;){if(e[i]!=="`"){i+=1;continue}let o=0;for(;i+o<e.length&&e[i+o]==="`";)o+=1;if(o===r){let o=e.slice(n+r,i);t+=e.slice(n,n+r)+o.replace(/(?<!\\)\|/g,`\\|`)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function Fc(e){return e.split(`
|
|
40
|
+
`).map(e=>!e.includes(`|`)||!e.includes("`")?e:Pc(e)).join(`
|
|
41
|
+
`)}function Ic(e){return(e||``).replace(/\s+/g,` `).trim()}function Lc(e,t,n={}){let r=n.cellLineSeparator??``;if(!e||!e.content||e.content.length===0)return``;let i=[];e.content.forEach(e=>{let n=[];e.content&&e.content.forEach(e=>{let i=``;i=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>t.renderChildren(e)).join(r):e.content?t.renderChildren(e.content):``;let a=Ic(i.split(r).join(`
|
|
42
|
+
`).replace(/[ \t]*\r?\n[ \t]*/g,`<br>`)),o=e.type===`tableHeader`,s=mc(e.attrs);n.push({text:a,isHeader:o,align:s})}),i.push(n)});let a=i.reduce((e,t)=>Math.max(e,t.length),0);if(a===0)return``;let o=Array.from({length:a}).fill(0);i.forEach(e=>{for(let t=0;t<a;t+=1){let n=(e[t]?.text||``).length;n>o[t]&&(o[t]=n),o[t]<3&&(o[t]=3)}});let s=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),c=i[0],l=c.some(e=>e.isHeader),u=Array.from({length:a}).fill(null);i.forEach(e=>{for(let t=0;t<a;t+=1)!u[t]&&e[t]?.align&&(u[t]=e[t].align)});let d=`
|
|
43
|
+
`,f=Array.from({length:a}).map((e,t)=>l&&c[t]&&c[t].text||``);return d+=`| ${f.map((e,t)=>s(e,o[t])).join(` | `)} |
|
|
44
|
+
`,d+=`| ${o.map((e,t)=>{let n=Math.max(3,e),r=u[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |
|
|
45
|
+
`,(l?i.slice(1):i).forEach(e=>{d+=`| ${Array.from({length:a}).fill(0).map((t,n)=>s(e[n]&&e[n].text||``,o[n])).join(` | `)} |
|
|
46
|
+
`}),d}var Rc=Lc,zc=A.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Ec,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=Dc(e,this.options.cellMinWidth),a=t.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}let s=[`table`,O(this.options.HTMLAttributes,t,{style:o()}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},s]:s},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=fc(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=fc(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>Rc(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(`
|
|
47
|
+
`);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(`
|
|
48
|
+
|
|
49
|
+
`),i=r>=0?e.slice(0,r):e,a=i.split(`
|
|
50
|
+
`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=Fc(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(`
|
|
51
|
+
`).length,u=e.split(`
|
|
52
|
+
`).slice(0,l).join(`
|
|
53
|
+
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=Ac(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(k.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>ss(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>cs(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=he(e.selection.$from,e=>e.type.name===`table`);return us(e,t&&(e=>{n&&Nc(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>ps(e,t),addRowAfter:()=>({state:e,dispatch:t})=>ms(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=he(e.selection.$from,e=>e.type.name===`table`);return gs(e,t&&(e=>{n&&Nc(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>ks(e,t),mergeCells:()=>({state:e,dispatch:t})=>ys(e,t),splitCell:()=>({state:e,dispatch:t})=>bs(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Ts(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Ts(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Es(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>ys(e,t)?!0:bs(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Ss(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Os(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Os(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&is(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=X.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Mc,"Mod-Backspace":Mc,Delete:Mc,"Mod-Delete":Mc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Zs({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],dc({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){let e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:e,view:n,HTMLAttributes:r})=>{let i=O(this.options.HTMLAttributes,r);return new t(e,this.options.cellMinWidth,n,i)}},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:Ze(_e(e,`tableRole`,t))}}}),Bc=j.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(zc.configure(this.options.table)),this.options.tableCell!==!1&&e.push(xc.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Sc.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Cc.configure(this.options.tableRow)),e}}),Vc=j.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}}),$=e(ne(),1),Hc=[1,2,3,4,5,6],Uc=[`left`,`center`,`right`,`justify`],Wc={left:{icon:`align-left`,key:`align-left`,label:`Align left`},center:{icon:`align-center`,key:`align-center`,label:`Align center`},right:{icon:`align-right`,key:`align-right`,label:`Align right`},justify:{icon:`align-justify`,key:`justify`,label:`Justify`}},Gc=[`😀`,`😅`,`😂`,`🥳`,`😎`,`🤔`,`👍`,`🙏`,`🔥`,`🎉`,`🚀`,`💡`,`✅`,`❌`,`⭐`,`❤️`];function Kc(e){let t=(e??Hc).filter(e=>e>=1&&e<=6);return t.length>0?t:Hc}function qc({editor:e,levels:t}){let{t:n}=E(`lattice`),a=n(`form.editor.heading`,`Heading`);return(0,$.jsxs)(u,{children:[(0,$.jsx)(c,{asChild:!0,children:(0,$.jsx)(f,{active:e.isActive(`heading`),icon:`heading`,label:a,testId:`editor-heading`})}),(0,$.jsx)(i,{className:`min-w-32`,children:t.map(t=>(0,$.jsx)(r,{className:ae(e.isActive(`heading`,{level:t})&&`bg-lt-accent text-lt-accent-fg`),"data-test":`editor-heading-${t}`,onClick:()=>e.chain().focus().toggleHeading({level:t}).run(),children:n(`form.editor.heading-${t}`,`Heading ${t}`)},t))})]})}function Jc({editor:e}){let{t}=E(`lattice`),[r,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(``),c=()=>{a?e.chain().focus().extendMarkRange(`link`).setLink({href:a}).run():e.chain().focus().extendMarkRange(`link`).unsetLink().run(),i(!1)};return(0,$.jsxs)(n,{onOpenChange:t=>{t&&o(e.getAttributes(`link`).href??``),i(t)},open:r,children:[(0,$.jsx)(s,{asChild:!0,children:(0,$.jsx)(f,{active:e.isActive(`link`),icon:`link`,label:t(`form.editor.link`,`Link`),testId:`editor-link`})}),(0,$.jsxs)(h,{className:`flex w-72 items-center gap-1 p-2`,children:[(0,$.jsx)(`input`,{"aria-label":t(`form.editor.link-url`,`Link URL`),className:`h-7 min-w-0 flex-1 rounded-lt-sm border border-lt-input bg-transparent px-2 text-sm outline-none focus:border-lt-ring`,"data-test":`editor-link-url`,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())},placeholder:`https://`,type:`url`,value:a}),(0,$.jsx)(f,{icon:`check`,label:t(`form.editor.link-apply`,`Apply link`),onClick:c,testId:`editor-link-apply`}),e.isActive(`link`)&&(0,$.jsx)(f,{icon:`trash-2`,label:t(`form.editor.link-remove`,`Remove link`),onClick:()=>{e.chain().focus().extendMarkRange(`link`).unsetLink().run(),i(!1)},testId:`editor-link-remove`})]})]})}function Yc({editor:e,emojis:t}){let{t:r}=E(`lattice`),[i,a]=(0,K.useState)(!1);return(0,$.jsxs)(n,{onOpenChange:a,open:i,children:[(0,$.jsx)(s,{asChild:!0,children:(0,$.jsx)(f,{icon:`smile`,label:r(`form.editor.insert-emoji`,`Insert emoji`),testId:`editor-emoji`})}),(0,$.jsx)(h,{className:`grid grid-cols-8 gap-0.5 p-1`,children:t.map(t=>(0,$.jsx)(`button`,{className:`inline-flex size-7 items-center justify-center rounded-lt-sm text-base hover:bg-lt-accent`,onClick:()=>{e.chain().focus().insertContent(t).run(),a(!1)},onMouseDown:e=>e.preventDefault(),type:`button`,children:t},t))})]})}function Xc(e,t,n,r){return{icon:t,key:e,label:n,isActive:e=>e.isActive(r),run:e=>e.chain().focus().toggleMark(r).run()}}var Zc={bold:{group:`marks`,starterKit:()=>({bold:{}}),toolbar:()=>[Xc(`bold`,`bold`,`Bold`,`bold`)]},italic:{group:`marks`,starterKit:()=>({italic:{}}),toolbar:()=>[Xc(`italic`,`italic`,`Italic`,`italic`)]},strike:{group:`marks`,starterKit:()=>({strike:{}}),toolbar:()=>[Xc(`strikethrough`,`strikethrough`,`Strikethrough`,`strike`)]},underline:{group:`marks`,starterKit:()=>({underline:{}}),toolbar:()=>[Xc(`underline`,`underline`,`Underline`,`underline`)]},highlight:{group:`marks`,extensions:()=>[Mo],toolbar:()=>[Xc(`highlight`,`highlighter`,`Highlight`,`highlight`)]},code:{group:`marks`,starterKit:()=>({code:{}}),toolbar:()=>[Xc(`code`,`code-xml`,`Code`,`code`)]},heading:{starterKit:e=>({heading:{levels:Kc(e.levels)}}),toolbar:e=>{let t=Kc(e.levels);return[{key:`heading`,component:({editor:e})=>(0,$.jsx)(qc,{editor:e,levels:t})}]},commands:e=>Kc(e.levels).map(e=>({key:`heading-${e}`,icon:`heading-${e}`,label:`Heading ${e}`,keywords:[`h${e}`,`title`],run:t=>t.chain().focus().setHeading({level:e}).run()}))},"bullet-list":{group:`blocks`,starterKit:()=>({bulletList:{},listItem:{}}),toolbar:()=>[{icon:`list`,key:`bullet-list`,label:`Bullet list`,isActive:e=>e.isActive(`bulletList`),run:e=>e.chain().focus().toggleBulletList().run()}],commands:()=>[{icon:`list`,key:`bullet-list`,label:`Bullet list`,keywords:[`ul`,`unordered`],run:e=>e.chain().focus().toggleBulletList().run()}]},"ordered-list":{group:`blocks`,starterKit:()=>({orderedList:{},listItem:{}}),toolbar:()=>[{icon:`list-ordered`,key:`ordered-list`,label:`Ordered list`,isActive:e=>e.isActive(`orderedList`),run:e=>e.chain().focus().toggleOrderedList().run()}],commands:()=>[{icon:`list-ordered`,key:`ordered-list`,label:`Ordered list`,keywords:[`ol`,`numbered`],run:e=>e.chain().focus().toggleOrderedList().run()}]},blockquote:{group:`blocks`,starterKit:()=>({blockquote:{}}),toolbar:()=>[{icon:`quote`,key:`blockquote`,label:`Blockquote`,isActive:e=>e.isActive(`blockquote`),run:e=>e.chain().focus().toggleBlockquote().run()}],commands:()=>[{icon:`quote`,key:`blockquote`,label:`Blockquote`,keywords:[`quote`,`cite`],run:e=>e.chain().focus().toggleBlockquote().run()}]},"code-block":{group:`blocks`,starterKit:()=>({codeBlock:{}}),toolbar:()=>[{icon:`code`,key:`code-block`,label:`Code block`,isActive:e=>e.isActive(`codeBlock`),run:e=>e.chain().focus().toggleCodeBlock().run()}],commands:()=>[{icon:`code`,key:`code-block`,label:`Code block`,keywords:[`codeblock`,`pre`,`fence`],run:e=>e.chain().focus().toggleCodeBlock().run()}]},"horizontal-rule":{group:`blocks`,starterKit:()=>({horizontalRule:{}}),toolbar:()=>[{icon:`minus`,key:`horizontal-rule`,label:`Horizontal rule`,isActive:()=>!1,run:e=>e.chain().focus().setHorizontalRule().run()}],commands:()=>[{icon:`minus`,key:`horizontal-rule`,label:`Horizontal rule`,keywords:[`hr`,`divider`,`rule`],run:e=>e.chain().focus().setHorizontalRule().run()}]},"text-align":{extensions:e=>[Vc.configure({alignments:e.alignments??Uc,types:[`heading`,`paragraph`]})],toolbar:e=>(e.alignments??Uc).filter(e=>e in Wc).map(e=>({...Wc[e],isActive:t=>t.isActive({textAlign:e}),run:t=>t.chain().focus().setTextAlign(e).run()}))},link:{starterKit:e=>({link:{openOnClick:e.openOnClick??!1,...e.protocols?{protocols:e.protocols}:{}}}),toolbar:()=>[{key:`link`,component:({editor:e})=>(0,$.jsx)(Jc,{editor:e})}]},table:{group:`insert`,extensions:()=>[Bc.configure({table:{resizable:!1}})],toolbar:e=>[{icon:`table`,key:`insert-table`,label:`Insert table`,isActive:e=>e.isActive(`table`),run:t=>t.chain().focus().insertTable({rows:e.rows??3,cols:e.cols??3,withHeaderRow:e.withHeaderRow??!0}).run()},{icon:`columns-3`,key:`add-column`,label:`Add column`,isActive:()=>!1,isDisabled:e=>!e.can().addColumnAfter(),run:e=>e.chain().focus().addColumnAfter().run()},{icon:`rows-3`,key:`add-row`,label:`Add row`,isActive:()=>!1,isDisabled:e=>!e.can().addRowAfter(),run:e=>e.chain().focus().addRowAfter().run()},{icon:`trash-2`,key:`delete-table`,label:`Delete table`,isActive:()=>!1,isDisabled:e=>!e.can().deleteTable(),run:e=>e.chain().focus().deleteTable().run()}],commands:e=>[{icon:`table`,key:`insert-table`,label:`Insert table`,keywords:[`table`,`grid`],isAvailable:e=>e.can().insertTable(),run:t=>t.chain().focus().insertTable({rows:e.rows??3,cols:e.cols??3,withHeaderRow:e.withHeaderRow??!0}).run()}]},details:{group:`insert`,extensions:()=>[Do,ko,Oo],toolbar:()=>[{icon:`chevron-right`,key:`details`,label:`Details`,isActive:e=>e.isActive(`details`),run:e=>{if(e.isActive(`details`)){e.chain().focus().unsetDetails().run();return}e.chain().focus().setDetails().run()}}],commands:()=>[{icon:`chevron-right`,key:`details`,label:`Details`,keywords:[`toggle`,`collapse`,`accordion`],isAvailable:e=>e.can().setDetails(),run:e=>e.chain().focus().setDetails().run()}]},"slash-menu":{},emoji:{toolbar:e=>{let t=e.emojis??Gc;return[{key:`insert-emoji`,component:({editor:e})=>(0,$.jsx)(Yc,{editor:e,emojis:t})}]}}};function Qc(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var $c=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Pe(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(C(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(fe(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(T(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(de(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(ie(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(se(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(ce(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(ue(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=tt(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof We){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof X){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():Qc(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&oe(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},el=e=>new F({key:typeof e.pluginKey==`string`?new N(e.pluginKey):e.pluginKey,view:t=>new $c({view:t,...e})});j.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[el({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var tl=e(te(),1),nl=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return Ee(e,{textSerializers:Oe(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(C(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(fe(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(T(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(de(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(ie(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(se(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(ce(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(ue(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){if(!this.view?.dom?.parentNode)return;let{selection:e}=this.editor.state,t=tt(this.view,e.from,e.to);oe({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},rl=e=>new F({key:typeof e.pluginKey==`string`?new N(e.pluginKey):e.pluginKey,view:t=>new nl({view:t,...e})});j.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[rl({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function il(e,t){return e??new N(t)}var al=typeof window<`u`?K.useLayoutEffect:K.useEffect,ol=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),sl=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),cl=new Set([`children`,`className`,`style`]),ll=new Set([`tabIndex`]),ul=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),dl={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function fl(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function pl(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function ml(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||ul.has(e)}function hl(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function gl(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:dl[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function _l(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function vl(e){return ll.has(e)}function yl(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function bl(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function xl(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||sl.has(e)?String(t):`${t}px`}function Sl(e,t){ol.has(t)||e.style.removeProperty(hl(t))}function Cl(e,t,n){ol.has(t)||e.style.setProperty(hl(t),xl(t,n))}function wl(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(cl.has(r)||!ml(r)||fl(r,t[r])||fl(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=pl(r);if(a==null||a===!1){vl(r)&&bl(e,r),e.removeAttribute(o);return}if(a===!0){vl(r)&&yl(e,r,!0),e.setAttribute(o,``);return}if(vl(r)){yl(e,r,a);return}e.setAttribute(o,String(a))})}function Tl(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function El(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){Sl(e,t);return}Cl(e,t,a)}})}function Dl(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!fl(t,n))return;let{eventName:i,options:a}=gl(t),o=t=>{n(_l(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function Ol(e,t){let n=(0,K.useRef)({}),r=(0,K.useRef)([]);al(()=>{let i=n.current;return Tl(e,i.className,t.className),El(e,i.style,t.style),wl(e,i,t),r.current=Dl(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}K.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,K.useRef)(document.createElement(`div`)),f=(0,K.useRef)(il(e,`bubbleMenu`)).current;Ol(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=qe(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,K.useRef)(h);g.current=h;let[_,v]=(0,K.useState)(!1),y=(0,K.useRef)(!0);return(0,K.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=el({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,K.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,tl.createPortal)(c,d.current)});var kl=K.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,K.useRef)(document.createElement(`div`)),d=(0,K.useRef)(il(e,`floatingMenu`)).current;Ol(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=qe(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,K.useRef)(m);h.current=m;let[g,_]=(0,K.useState)(!1),v=(0,K.useRef)(!0);return(0,K.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=rl({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,K.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,tl.createPortal)(s,u.current)});function Al(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=lt(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function jl(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
|
|
54
|
+
`);return/\s/.test(n)}):!1}function Ml(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function Nl(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:Ml(e)}function Pl({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!jl(r)}function Fl({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function Il({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),D.create(a.doc,[ke.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function Ll({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function Rl({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function zl({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[T({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(C()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function Bl(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function Vl({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&Bl(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=le(c,o,()=>{oe(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{if(s.onPosition){s.onPosition({x:e,y:t,placement:n,strategy:r});return}Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``)})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function Hl({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=Rl({editor:e,items:n}),v=zl({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,ee=b.query!==x.query,te=b.text!==x.text,ne=b.range.from!==x.range.from||b.range.to!==x.range.to,re=ee||te||ne;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&re)S=`updated`;else return;let C=S===`stopped`?b:x,ie=n.dom.querySelector(`[data-decoration-id="${C.decorationId}"]`),w=m(n,ie),ae=i===0||(C.query?C.query.length>=i:!1),oe=(S===`started`||S===`updated`)&&ae;if(g={editor:e,range:C.range,query:C.query||``,text:C.text||``,items:o??[],command:t=>p({editor:e,range:C.range,props:t}),decorationNode:ie,clientRect:w,loading:oe,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:Vl({getReferenceRect:w,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var T;r==null||(T=r.onBeforeStart)==null||T.call(r,g)}if(S===`updated`){var se;r==null||(se=r.onBeforeUpdate)==null||se.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`)if(!oe)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(C.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}if(S===`stopped`){_.abort(),y(S,g),g=void 0;return}S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var Ul=new N(`suggestion`);function Wl({pluginKey:e=Ul,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:ee=()=>!0,findSuggestionMatch:te=Al,shouldShow:ne,shouldResetDismissed:re}){let C=S?.(),ie=r&&!i,w=(n,r)=>Nl(t,n,r,e);function ae(e){return Pl({...e,editor:t,shouldResetDismissed:re,effectiveAllowSpaces:ie})}let oe=t=>Fl({view:t,pluginKeyRef:e});return new F({key:e,view:()=>Hl({editor:t,pluginKey:e,items:f,renderer:C,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:w,dispatchExit:oe}),state:Ll({editor:t,char:n,effectiveAllowSpaces:ie,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:te,allow:ee,shouldShow:ne,shouldKeepDismissed:ae,pluginKey:e}),props:Il({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:C,dispatchExit:oe})})}function Gl(e,t=Ul){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function Kl(e,t){return`${e}-option-${t}`}function ql({activeIndex:e,id:t,items:n,onHighlight:r,onSelect:i}){let{t:a}=E(`lattice`),o=(0,K.useRef)(null);return(0,K.useEffect)(()=>{o.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[e,n]),(0,$.jsx)(`div`,{"aria-label":a(`form.editor.block-menu`,`Insert block`),className:ae(g,`max-h-72 w-56 overflow-y-auto p-1`),"data-test":`editor-block-menu`,id:t,ref:o,role:`listbox`,children:n.length===0?(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-lt-muted-fg`,children:a(`form.editor.block-menu-empty`,`No results`)}):n.map((o,s)=>(0,$.jsxs)(K.Fragment,{children:[s>0&&n[s-1].group!==o.group&&(0,$.jsx)(`div`,{className:`mx-1 my-1 h-px bg-lt-border`}),(0,$.jsxs)(`button`,{"aria-selected":s===e,className:ae(`flex w-full items-center gap-2 rounded-lt-sm px-2 py-1.5 text-left text-sm`,s===e&&`bg-lt-accent text-lt-accent-fg`),"data-test":`editor-block-${o.key}`,id:Kl(t,o.key),onClick:()=>i(o),onMouseDown:e=>e.preventDefault(),onMouseMove:()=>r(s),role:`option`,type:`button`,children:[(0,$.jsx)(w,{className:`shrink-0 text-lt-muted-fg`,name:o.icon}),a(`form.editor.${o.key}`,o.label)]})]},o.key))})}var Jl=new N(`latticeSlashMenu`);function Yl(e){return j.create({name:`latticeSlashMenu`,addProseMirrorPlugins(){return[Wl({editor:this.editor,pluginKey:Jl,char:`/`,allow:({editor:e})=>!e.isActive(`codeBlock`),items:()=>e.commands(),command:({editor:e,range:t,props:n})=>{e.chain().focus().deleteRange(t).run(),n.run(e)},render:()=>({onStart:t=>e.handle.current?.onStart(t),onUpdate:t=>e.handle.current?.onUpdate(t),onKeyDown:t=>e.handle.current?.onKeyDown(t)??!1,onExit:()=>e.handle.current?.onExit()})})]}})}function Xl(e,t,n,r){let i=t.trim().toLowerCase();return e.filter(e=>e.isAvailable&&!e.isAvailable(n)?!1:i===``||[r(e.key,e.label),e.label,e.key,...e.keywords??[]].some(e=>e.toLowerCase().includes(i)))}var Zl={placement:`left`,offset:4,flip:!1};function Ql({editor:e,handleRef:t}){let{t:n}=E(`lattice`),r=(0,K.useId)(),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(0),[c]=(0,K.useState)(()=>{let e=document.createElement(`div`);return e.className=`z-lt-popover`,e}),l=(0,K.useRef)(null),u=(0,K.useMemo)(()=>i?Xl(i.items,i.query,e,(e,t)=>n(`form.editor.${e}`,t)):[],[i,e,n]),d=(0,K.useRef)(u),p=(0,K.useRef)(o),m=(0,K.useRef)(i);return(0,K.useEffect)(()=>{d.current=u,p.current=o,m.current=i}),(0,K.useEffect)(()=>(t.current={onStart:e=>{a({items:e.items,query:e.query,command:e.command}),s(0),l.current=e.mount(c)},onUpdate:e=>{e.query!==m.current?.query&&s(0),a({items:e.items,query:e.query,command:e.command})},onKeyDown:({view:e,event:t})=>{if(t.key===`Escape`)return Gl(e,Jl),!0;let n=d.current;if(n.length===0)return!1;if(t.key===`ArrowDown`)return s(e=>Math.min(n.length-1,e+1)),!0;if(t.key===`ArrowUp`)return s(e=>Math.max(0,e-1)),!0;if(t.key===`Enter`){let e=n[p.current];return e&&m.current?.command(e),!0}return!1},onExit:()=>{l.current?.(),l.current=null,a(null)}},()=>{t.current=null,l.current?.(),l.current=null}),[c,t]),(0,K.useEffect)(()=>{let t=e.view.dom;if(!i){t.removeAttribute(`aria-controls`),t.removeAttribute(`aria-activedescendant`);return}t.setAttribute(`aria-controls`,r);let n=u[o];n?t.setAttribute(`aria-activedescendant`,Kl(r,n.key)):t.removeAttribute(`aria-activedescendant`)},[i,u,o,e,r]),(0,$.jsxs)($.Fragment,{children:[(0,tl.createPortal)(i&&(0,$.jsx)(ql,{activeIndex:o,id:r,items:u,onHighlight:s,onSelect:e=>i.command(e)}),c),(0,$.jsx)(kl,{editor:e,options:Zl,children:(0,$.jsx)(f,{icon:`plus`,label:n(`form.editor.add-block`,`Add block`),onClick:()=>e.chain().focus().insertContent(`/`).run(),testId:`editor-add-block`})})]})}function $l({editor:e,items:t}){let{t:n}=E(`lattice`);return(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-0.5 border-b border-lt-border p-1`,children:t.map((t,r)=>{if(t===`separator`)return(0,$.jsx)(`span`,{className:`mx-1 h-5 w-px bg-lt-border`},`sep-${r}`);if(`component`in t){let n=t.component;return(0,$.jsx)(n,{editor:e},t.key)}let i=n(`form.editor.${t.key}`,t.label);return(0,$.jsx)(f,{active:t.isActive(e),disabled:t.isDisabled?.(e)??!1,icon:t.icon,label:i,onClick:()=>t.run(e),testId:`editor-${t.key}`},t.key)})})}var eu=({node:e})=>{let t=re(_),{errors:n}=b(),{hidden:r,required:i,readOnly:s,disabled:c}=d(e),{change:u,blur:f}=o(),h=e.props.name,g=a(),te=l(h),ne=g?g.getValue(h):te,C=g?g.scopedName(h):h,ie=g?g.errorKey(h):h,w=s||c,oe=typeof ne==`object`&&ne?ne:e.props.value??``,T=(0,K.useMemo)(()=>v(e.props.extensions,{...Zc,...t}),[t,e.props.extensions]),se=(0,K.useMemo)(()=>y(T),[T]),ce=(0,K.useMemo)(()=>x(T),[T]),le=T.some(e=>e.type===`slash-menu`),ue=(0,K.useRef)(ce),de=(0,K.useRef)(null);(0,K.useEffect)(()=>{ue.current=ce},[ce]);let fe=(0,K.useMemo)(()=>[Co.configure(p(T)),fn.configure({placeholder:e.props.placeholder??``}),...le?[Yl({commands:()=>ue.current,handle:de})]:[],...m(T)],[T,e.props.placeholder,le]),E=ze({extensions:fe,content:oe,editable:!w,immediatelyRender:!1,shouldRerenderOnTransaction:!0,editorProps:{attributes:{class:ae(`lattice-prose min-h-32 px-3 py-2 outline-none`,le&&`pl-9`)}},onUpdate:({editor:e})=>{u(h,e.isEmpty?null:e.getJSON())},onBlur:()=>{f(h)}});if((0,K.useEffect)(()=>{E?.setEditable(!w)},[E,w]),r)return null;let D=ne?JSON.stringify(ne):``;return(0,$.jsx)(ee,{error:n[ie],helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,labelAction:S(e.props.labelAction),label:e.props.label??``,id:C,required:i,children:t=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{...t,className:ae(`overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[length:var(--lt-ring-width)] focus-within:ring-lt-ring/50`,w&&`opacity-60`),role:`group`,children:[E&&!w&&e.props.toolbar&&se.length>0&&(0,$.jsx)($l,{editor:E,items:se}),(0,$.jsx)(it,{editor:E}),E&&!w&&le&&(0,$.jsx)(Ql,{editor:E,handleRef:de})]}),(0,$.jsx)(`input`,{name:C,type:`hidden`,value:D})]})})};export{eu as default};
|