@lattice-php/lattice 0.56.2 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/fragments/fragment.js +1 -1
  2. package/dist/fragments/fragment.js.map +1 -1
  3. package/dist/index.d.ts +3 -3
  4. package/dist/index.js +3 -3
  5. package/dist/inertia-navigation.d.ts +10 -0
  6. package/dist/inertia-navigation.js +18 -1
  7. package/dist/inertia-navigation.js.map +1 -1
  8. package/dist/layout/components/menu-item.js +3 -3
  9. package/dist/layout/components/menu-item.js.map +1 -1
  10. package/dist/layout/components/outlet.js +3 -4
  11. package/dist/layout/components/outlet.js.map +1 -1
  12. package/dist/layout/components/popover.js +4 -4
  13. package/dist/layout/components/popover.js.map +1 -1
  14. package/dist/layout/components/schema-layout.js +3 -3
  15. package/dist/layout/components/schema-layout.js.map +1 -1
  16. package/dist/layout/components/sidebar.js +4 -4
  17. package/dist/layout/components/sidebar.js.map +1 -1
  18. package/dist/layout/hooks/context.d.ts +5 -3
  19. package/dist/layout/hooks/context.js +13 -4
  20. package/dist/layout/hooks/context.js.map +1 -1
  21. package/dist/layout/index.d.ts +1 -1
  22. package/dist/layout/index.js +2 -2
  23. package/dist/notifications/components/notification-list.js +1 -1
  24. package/dist/notifications/components/notification-list.js.map +1 -1
  25. package/dist/notifications/components/notifications-sheet.d.ts +3 -0
  26. package/dist/notifications/components/notifications-sheet.js +59 -0
  27. package/dist/notifications/components/notifications-sheet.js.map +1 -0
  28. package/dist/notifications/components/notifications.js +23 -19
  29. package/dist/notifications/components/notifications.js.map +1 -1
  30. package/dist/notifications/context.d.ts +17 -0
  31. package/dist/notifications/context.js +36 -0
  32. package/dist/notifications/context.js.map +1 -0
  33. package/dist/notifications/store.d.ts +1 -1
  34. package/dist/notifications/store.js.map +1 -1
  35. package/dist/provider-base.js +9 -7
  36. package/dist/provider-base.js.map +1 -1
  37. package/dist/runtime.d.ts +7 -3
  38. package/dist/runtime.js +8 -5
  39. package/dist/types/generated.d.ts +1 -0
  40. package/dist-standalone/chunks/{chart-view-oULAY8WG.js → chart-view-eWW-pC-B.js} +6 -6
  41. package/dist-standalone/chunks/{date-picker-field-BtFIuqiR.js → date-picker-field-FY2OOgtu.js} +1 -1
  42. package/dist-standalone/chunks/{field-TNAMMeq0.js → field-DMXnzaJF.js} +1 -1
  43. package/dist-standalone/chunks/floating-ui.dom-CAMzcZKV.js +1 -0
  44. package/dist-standalone/chunks/{input-C-Wm1w0g.js → input-0lNoXsuO.js} +1 -1
  45. package/dist-standalone/chunks/registry-context-gXwNT8GJ.js +1 -0
  46. package/dist-standalone/chunks/{rich-editor-field-BAfgX13j.js → rich-editor-field-B0XwZGpp.js} +4 -4
  47. package/dist-standalone/chunks/runtime-BjRIrbqh.js +162 -0
  48. package/dist-standalone/chunks/{subscriptions-CPPj3zAw.js → subscriptions-CSh5RtT7.js} +1 -1
  49. package/dist-standalone/lattice.css +1 -1
  50. package/dist-standalone/lattice.js +1 -1
  51. package/dist-standalone/manifest.json +1 -1
  52. package/dist-standalone/runtime.js +1 -1
  53. package/package.json +6 -6
  54. package/dist-standalone/chunks/floating-ui.dom-DRSJZ5ii.js +0 -1
  55. package/dist-standalone/chunks/registry-context-Q5KtSmdi.js +0 -1
  56. package/dist-standalone/chunks/runtime-ckCQ5M2S.js +0 -162
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{Ct as n,Ot as r,Ut as i,_t as a,c as o,ct as s,d as c,f as l,gt as u,ht as d,l as f,lt as p,mt as m,pt as h,s as g,u as _,ut as ee,vt as te,wt as v,yt as y}from"./runtime-ckCQ5M2S.js";import{i as ne}from"./registry-context-Q5KtSmdi.js";import{t as b}from"./jsx-runtime-NZYk81nU.js";import{_ as re}from"./floating-ui.dom-DRSJZ5ii.js";import{c as ie}from"./instance-D6cXaqIT.js";import{$ as x,A as ae,B as oe,C as se,D as ce,E as le,F as ue,G as de,H as fe,I as pe,J as me,K as he,L as ge,M as _e,N as ve,O as ye,P as be,Q as xe,R as S,S as Se,T as Ce,U as we,V as Te,W as Ee,X as C,Y as w,Z as T,_ as De,b as Oe,c as E,d as D,et as ke,f as Ae,g as je,h as Me,i as Ne,it as O,j as Pe,k as Fe,l as Ie,m as Le,n as Re,nt as ze,p as Be,q as k,r as Ve,rt as A,s as He,t as Ue,tt as We,u as Ge,v as Ke,w as qe,x as Je,y as Ye,z as j}from"./dist-DAHNiLp2.js";function Xe(e={}){return new w({view(t){return new Ze(t,e)}})}var Ze=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=ze(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)}},M=class e extends T{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):T.near(r)}content(){return O.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 Qe(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!et(e)||!tt(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&&!me.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}}};M.prototype.visible=!1,M.findFrom=M.findGapCursorFrom,T.jsonID(`gapcursor`,M);var Qe=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 M.valid(t)?new M(t):T.near(t)}};function $e(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function et(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||$e(e.type))return!0;if(e.inlineContent)return!1}}return!0}function tt(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||$e(e.type))return!0;if(e.inlineContent)return!1}}return!0}function nt(){return new w({props:{decorations:st,createSelectionBetween(e,t,n){return t.pos==n.pos&&M.valid(n)?new M(n):null},handleClick:at,handleKeyDown:rt,handleDOMEvents:{beforeinput:ot}}})}var rt=de({ArrowLeft:it(`horiz`,-1),ArrowRight:it(`horiz`,1),ArrowUp:it(`vert`,-1),ArrowDown:it(`vert`,1)});function it(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 x){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=M.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new M(c))),!0):!1}}function at(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!M.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&me.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new M(r))),!0)}function ot(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof M))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=A.empty;for(let e=r.length-1;e>=0;e--)i=A.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new O(i,0,0));return a.setSelection(x.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function st(e){if(!(e.selection instanceof M))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,k.create(e.doc,[he.widget(e.selection.head,t,{key:`gapcursor`})])}var ct=200,N=function(){};N.prototype.append=function(e){return e.length?(e=N.from(e),!this.length&&e||e.length<ct&&this.leafAppend(e)||this.length<ct&&e.leafPrepend(this)||this.appendInner(e)):this},N.prototype.prepend=function(e){return e.length?N.from(e).append(this):this},N.prototype.appendInner=function(e){return new ut(this,e)},N.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?N.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},N.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},N.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)},N.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},N.from=function(e){return e instanceof N?e:e&&e.length?new lt(e):N.empty};var lt=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}(N);N.empty=new lt([]);var ut=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}(N),dt=500,ft=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 mt(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 mt(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 mt(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>gt&&(s=pt(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new ke;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 mt(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 mt(i,o,l))}else r.push(new mt(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new mt(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>dt&&(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 mt(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(N.from(i.reverse()),a)}};ft.empty=new ft(N.empty,0);function pt(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var mt=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)}}},ht=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},gt=20;function _t(e,t,n,r){let i=n.getMeta(Tt),a;if(i)return i.historyState;n.getMeta(Et)&&(e=new ht(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Tt))return o.getMeta(Tt).redo?new ht(e.done.addTransform(n,void 0,r,wt(t)),e.undone,yt(n.mapping.maps),e.prevTime,e.prevComposition):new ht(e.done,e.undone.addTransform(n,void 0,r,wt(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||!vt(n,e.prevRanges)),s=o?bt(e.prevRanges,n.mapping):yt(n.mapping.maps);return new ht(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,wt(t)),ft.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new ht(e.done.rebased(n,a),e.undone.rebased(n,a),bt(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new ht(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),bt(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function vt(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 yt(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 bt(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 xt(e,t,n){let r=wt(t),i=Tt.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 ht(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Tt,{redo:n,historyState:c})}var St=!1,Ct=null;function wt(e){let t=e.plugins;if(Ct!=t){St=!1,Ct=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){St=!0;break}}return St}var Tt=new C(`history`),Et=new C(`closeHistory`);function Dt(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new w({key:Tt,state:{init(){return new ht(ft.empty,ft.empty,null,0,-1)},apply(t,n,r){return _t(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?kt:n==`historyRedo`?At:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Ot(e,t){return(n,r)=>{let i=Tt.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=xt(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var kt=Ot(!1,!0),At=Ot(!0,!0);E.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 w({key:new C(`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 jt=E.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[Xe(this.options)]}});E.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new w({key:new C(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return k.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(he.node(t,t+e.nodeSize,{class:this.options.className}))}),k.create(e,a)}}})]}});var Mt=E.create({name:`gapCursor`,addProseMirrorPlugins(){return[nt()]},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:Be(qe(e,`allowGapCursor`,t))??null}}}),Nt=`placeholder`,Pt=new C(`tiptap__placeholder`);function Ft(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),he.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function It(e,t){return typeof e==`function`?e(t):e}function Lt({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&&ue(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Ft({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:It(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function Rt({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&&ue(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Ft({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:It(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Lt({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return k.create(r,o)}function zt(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 Bt(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function Vt(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 Ht(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 Ut(e,t){let n=Vt(e,t.from,t.to);return n.push(Bt(e,zt(e,t.from))),t.to>t.from?n.push(Bt(e,zt(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(Bt(e,zt(e,Math.min(t.from+1,e.content.size)))),n}function Wt(e,t,n){let r=[];if(e.docChanged){let t=se(e);for(let e of t)r.push(...Ut(n.doc,e.newRange))}return e.selectionSet&&(r.push(Bt(n.doc,zt(n.doc,e.mapping.map(t.selection.anchor)))),r.push(Bt(n.doc,zt(n.doc,n.selection.anchor)))),Ht(r)}function Gt(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 Kt({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}=Gt(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=Lt({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function qt({editor:e,options:t,dataAttribute:n}){return{init(r,i){return Rt({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??k.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:Kt({decorations:i.map(r.mapping,r.doc),ranges:Wt(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function Jt(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function Yt({editor:e,options:t}){let n=t.dataAttribute?`data-${Jt(t.dataAttribute)}`:`data-${Nt}`,r=t.showOnlyCurrent&&!t.includeChildren;return new w({key:Pt,...r?{}:{state:qt({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>Rt({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?k.empty:Pt.getState(n)??k.empty}})}var Xt=E.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Nt,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Yt({editor:this.editor,options:this.options})]}});function Zt(e,t){return!e.selection.empty&&!pe(e.selection)&&t.isEditable}function Qt(e,t){return Zt(e,t)&&!t.isFocused&&!t.view.dragging}function $t(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function en(e){e.focus()}E.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new w({key:new C(`selection`),props:{decorations(n){return Qt(n,e)?k.create(n.doc,[he.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return Zt(t.state,e)&&$t(),!1},focus(t){return Zt(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&en(t)}),!1}}}})]}});function tn({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var nn=E.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new C(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 w({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!tn({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!tn({node:r,types:n})}}})]}}),rn=E.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>kt(e,t),redo:()=>({state:e,dispatch:t})=>At(e,t)}},addProseMirrorPlugins(){return[Dt(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()}}}),an=(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]},on=(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 O(n,0,0);return e.replace(l,i.after(),r),e.setSelection(x.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},sn=/^\s*>\s$/,cn=D.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return an(`blockquote`,{...j(this.options.HTMLAttributes,e),children:an(`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(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{Dt as n,Mt as r,Ot as i,St as a,_t as o,bt as s,c,d as l,dt as u,f as d,ft as f,gt as p,l as m,pt as h,qt as g,s as _,u as ee,vt as te,xt as v,yt as y}from"./runtime-BjRIrbqh.js";import{t as b}from"./jsx-runtime-NZYk81nU.js";import{i as ne}from"./registry-context-gXwNT8GJ.js";import{p as re}from"./floating-ui.dom-CAMzcZKV.js";import{c as ie}from"./instance-D6cXaqIT.js";import{$ as x,A as ae,B as oe,C as se,D as ce,E as le,F as ue,G as de,H as fe,I as pe,J as me,K as he,L as ge,M as _e,N as ve,O as ye,P as be,Q as xe,R as S,S as Se,T as Ce,U as we,V as Te,W as Ee,X as C,Y as w,Z as T,_ as De,b as Oe,c as E,d as D,et as ke,f as Ae,g as je,h as Me,i as Ne,it as O,j as Pe,k as Fe,l as Ie,m as Le,n as Re,nt as ze,p as Be,q as k,r as Ve,rt as A,s as He,t as Ue,tt as We,u as Ge,v as Ke,w as qe,x as Je,y as Ye,z as j}from"./dist-DAHNiLp2.js";function Xe(e={}){return new w({view(t){return new Ze(t,e)}})}var Ze=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=ze(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)}},M=class e extends T{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):T.near(r)}content(){return O.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 Qe(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!et(e)||!tt(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&&!me.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}}};M.prototype.visible=!1,M.findFrom=M.findGapCursorFrom,T.jsonID(`gapcursor`,M);var Qe=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 M.valid(t)?new M(t):T.near(t)}};function $e(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function et(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||$e(e.type))return!0;if(e.inlineContent)return!1}}return!0}function tt(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||$e(e.type))return!0;if(e.inlineContent)return!1}}return!0}function nt(){return new w({props:{decorations:st,createSelectionBetween(e,t,n){return t.pos==n.pos&&M.valid(n)?new M(n):null},handleClick:at,handleKeyDown:rt,handleDOMEvents:{beforeinput:ot}}})}var rt=de({ArrowLeft:it(`horiz`,-1),ArrowRight:it(`horiz`,1),ArrowUp:it(`vert`,-1),ArrowDown:it(`vert`,1)});function it(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 x){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=M.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new M(c))),!0):!1}}function at(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!M.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&me.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new M(r))),!0)}function ot(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof M))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=A.empty;for(let e=r.length-1;e>=0;e--)i=A.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new O(i,0,0));return a.setSelection(x.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function st(e){if(!(e.selection instanceof M))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,k.create(e.doc,[he.widget(e.selection.head,t,{key:`gapcursor`})])}var ct=200,N=function(){};N.prototype.append=function(e){return e.length?(e=N.from(e),!this.length&&e||e.length<ct&&this.leafAppend(e)||this.length<ct&&e.leafPrepend(this)||this.appendInner(e)):this},N.prototype.prepend=function(e){return e.length?N.from(e).append(this):this},N.prototype.appendInner=function(e){return new ut(this,e)},N.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?N.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},N.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},N.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)},N.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},N.from=function(e){return e instanceof N?e:e&&e.length?new lt(e):N.empty};var lt=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}(N);N.empty=new lt([]);var ut=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}(N),dt=500,ft=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 mt(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 mt(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 mt(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>gt&&(s=pt(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new ke;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 mt(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 mt(i,o,l))}else r.push(new mt(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new mt(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>dt&&(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 mt(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(N.from(i.reverse()),a)}};ft.empty=new ft(N.empty,0);function pt(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var mt=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)}}},ht=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},gt=20;function _t(e,t,n,r){let i=n.getMeta(Tt),a;if(i)return i.historyState;n.getMeta(Et)&&(e=new ht(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Tt))return o.getMeta(Tt).redo?new ht(e.done.addTransform(n,void 0,r,wt(t)),e.undone,yt(n.mapping.maps),e.prevTime,e.prevComposition):new ht(e.done,e.undone.addTransform(n,void 0,r,wt(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||!vt(n,e.prevRanges)),s=o?bt(e.prevRanges,n.mapping):yt(n.mapping.maps);return new ht(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,wt(t)),ft.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new ht(e.done.rebased(n,a),e.undone.rebased(n,a),bt(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new ht(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),bt(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function vt(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 yt(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 bt(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 xt(e,t,n){let r=wt(t),i=Tt.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 ht(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Tt,{redo:n,historyState:c})}var St=!1,Ct=null;function wt(e){let t=e.plugins;if(Ct!=t){St=!1,Ct=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){St=!0;break}}return St}var Tt=new C(`history`),Et=new C(`closeHistory`);function Dt(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new w({key:Tt,state:{init(){return new ht(ft.empty,ft.empty,null,0,-1)},apply(t,n,r){return _t(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?kt:n==`historyRedo`?At:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Ot(e,t){return(n,r)=>{let i=Tt.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=xt(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var kt=Ot(!1,!0),At=Ot(!0,!0);E.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 w({key:new C(`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 jt=E.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[Xe(this.options)]}});E.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new w({key:new C(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return k.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(he.node(t,t+e.nodeSize,{class:this.options.className}))}),k.create(e,a)}}})]}});var Mt=E.create({name:`gapCursor`,addProseMirrorPlugins(){return[nt()]},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:Be(qe(e,`allowGapCursor`,t))??null}}}),Nt=`placeholder`,Pt=new C(`tiptap__placeholder`);function Ft(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),he.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function It(e,t){return typeof e==`function`?e(t):e}function Lt({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&&ue(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Ft({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:It(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function Rt({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&&ue(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Ft({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:It(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Lt({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return k.create(r,o)}function zt(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 Bt(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function Vt(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 Ht(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 Ut(e,t){let n=Vt(e,t.from,t.to);return n.push(Bt(e,zt(e,t.from))),t.to>t.from?n.push(Bt(e,zt(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(Bt(e,zt(e,Math.min(t.from+1,e.content.size)))),n}function Wt(e,t,n){let r=[];if(e.docChanged){let t=se(e);for(let e of t)r.push(...Ut(n.doc,e.newRange))}return e.selectionSet&&(r.push(Bt(n.doc,zt(n.doc,e.mapping.map(t.selection.anchor)))),r.push(Bt(n.doc,zt(n.doc,n.selection.anchor)))),Ht(r)}function Gt(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 Kt({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}=Gt(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=Lt({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function qt({editor:e,options:t,dataAttribute:n}){return{init(r,i){return Rt({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??k.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:Kt({decorations:i.map(r.mapping,r.doc),ranges:Wt(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function Jt(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function Yt({editor:e,options:t}){let n=t.dataAttribute?`data-${Jt(t.dataAttribute)}`:`data-${Nt}`,r=t.showOnlyCurrent&&!t.includeChildren;return new w({key:Pt,...r?{}:{state:qt({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>Rt({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?k.empty:Pt.getState(n)??k.empty}})}var Xt=E.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Nt,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Yt({editor:this.editor,options:this.options})]}});function Zt(e,t){return!e.selection.empty&&!pe(e.selection)&&t.isEditable}function Qt(e,t){return Zt(e,t)&&!t.isFocused&&!t.view.dragging}function $t(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function en(e){e.focus()}E.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new w({key:new C(`selection`),props:{decorations(n){return Qt(n,e)?k.create(n.doc,[he.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return Zt(t.state,e)&&$t(),!1},focus(t){return Zt(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&en(t)}),!1}}}})]}});function tn({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var nn=E.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new C(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 w({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!tn({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!tn({node:r,types:n})}}})]}}),rn=E.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>kt(e,t),redo:()=>({state:e,dispatch:t})=>At(e,t)}},addProseMirrorPlugins(){return[Dt(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()}}}),an=(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]},on=(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 O(n,0,0);return e.replace(l,i.after(),r),e.setSelection(x.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},sn=/^\s*>\s$/,cn=D.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return an(`blockquote`,{...j(this.options.HTMLAttributes,e),children:an(`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
2
  `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
3
3
  `))}),n.join(`
4
4
  >
@@ -22,7 +22,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpah
22
22
  `));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(x.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),xn=D.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`,j(this.options.HTMLAttributes,e)]},renderText(){return`
23
23
  `},renderMarkdown:()=>`
24
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()}}}),Sn=D.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]}`,j(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=>we({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Cn=D.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,j(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Le(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return pe(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(x.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(me.create(t.doc,n.pos)):t.setSelection(x.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(x.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[oe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),wn=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Tn=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,En=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Dn=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,On=Ge.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`,j(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[ge({find:wn,type:this.type}),ge({find:En,type:this.type})]},addPasteRules(){return[S({find:Tn,type:this.type}),S({find:Dn,type:this.type})]}}),kn=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,An=`ελ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`,jn=`numeric`,Mn=`ascii`,Nn=`alpha`,Pn=`asciinumeric`,Fn=`alphanumeric`,In=`domain`,Ln=`emoji`,Rn=`scheme`,zn=`slashscheme`,Bn=`whitespace`;function Vn(e,t){return e in t||(t[e]=[]),t[e]}function Hn(e,t,n){t[jn]&&(t[Pn]=!0,t[Fn]=!0),t[Mn]&&(t[Pn]=!0,t[Nn]=!0),t[Pn]&&(t[Fn]=!0),t[Nn]&&(t[Fn]=!0),t[Fn]&&(t[In]=!0),t[Ln]&&(t[In]=!0);for(let r in t){let t=Vn(r,n);t.indexOf(e)<0&&t.push(e)}}function Un(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function P(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}P.groups={},P.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||=P.groups;let i;return t&&t.j?i=t:(i=new P(t),n&&r&&Hn(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||=P.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 P,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new P,a&&(r&&(o.t&&typeof o.t==`string`?Hn(a,Object.assign(Un(o.t,r),n),r):n&&Hn(a,n,r)),o.t=a),i.j[e]=o,o}};var F=(e,t,n,r,i)=>e.ta(t,n,r,i),I=(e,t,n,r,i)=>e.tr(t,n,r,i),Wn=(e,t,n,r,i)=>e.ts(t,n,r,i),L=(e,t,n,r,i)=>e.tt(t,n,r,i),R=`WORD`,Gn=`UWORD`,Kn=`ASCIINUMERICAL`,qn=`ALPHANUMERICAL`,Jn=`LOCALHOST`,Yn=`TLD`,Xn=`UTLD`,Zn=`SCHEME`,Qn=`SLASH_SCHEME`,$n=`NUM`,er=`WS`,tr=`NL`,nr=`OPENBRACE`,rr=`CLOSEBRACE`,ir=`OPENBRACKET`,ar=`CLOSEBRACKET`,or=`OPENPAREN`,sr=`CLOSEPAREN`,cr=`OPENANGLEBRACKET`,lr=`CLOSEANGLEBRACKET`,ur=`FULLWIDTHLEFTPAREN`,dr=`FULLWIDTHRIGHTPAREN`,fr=`LEFTCORNERBRACKET`,pr=`RIGHTCORNERBRACKET`,mr=`LEFTWHITECORNERBRACKET`,hr=`RIGHTWHITECORNERBRACKET`,gr=`FULLWIDTHLESSTHAN`,_r=`FULLWIDTHGREATERTHAN`,vr=`AMPERSAND`,yr=`APOSTROPHE`,br=`ASTERISK`,xr=`AT`,Sr=`BACKSLASH`,Cr=`BACKTICK`,wr=`CARET`,Tr=`COLON`,Er=`COMMA`,Dr=`DOLLAR`,z=`DOT`,Or=`EQUALS`,kr=`EXCLAMATION`,B=`HYPHEN`,Ar=`PERCENT`,jr=`PIPE`,Mr=`PLUS`,Nr=`POUND`,Pr=`QUERY`,Fr=`QUOTE`,Ir=`FULLWIDTHMIDDLEDOT`,Lr=`SEMI`,V=`SLASH`,Rr=`TILDE`,zr=`UNDERSCORE`,Br=`EMOJI`,Vr=`SYM`,Hr=Object.freeze({__proto__:null,ALPHANUMERICAL:qn,AMPERSAND:vr,APOSTROPHE:yr,ASCIINUMERICAL:Kn,ASTERISK:br,AT:xr,BACKSLASH:Sr,BACKTICK:Cr,CARET:wr,CLOSEANGLEBRACKET:lr,CLOSEBRACE:rr,CLOSEBRACKET:ar,CLOSEPAREN:sr,COLON:Tr,COMMA:Er,DOLLAR:Dr,DOT:z,EMOJI:Br,EQUALS:Or,EXCLAMATION:kr,FULLWIDTHGREATERTHAN:_r,FULLWIDTHLEFTPAREN:ur,FULLWIDTHLESSTHAN:gr,FULLWIDTHMIDDLEDOT:Ir,FULLWIDTHRIGHTPAREN:dr,HYPHEN:B,LEFTCORNERBRACKET:fr,LEFTWHITECORNERBRACKET:mr,LOCALHOST:Jn,NL:tr,NUM:$n,OPENANGLEBRACKET:cr,OPENBRACE:nr,OPENBRACKET:ir,OPENPAREN:or,PERCENT:Ar,PIPE:jr,PLUS:Mr,POUND:Nr,QUERY:Pr,QUOTE:Fr,RIGHTCORNERBRACKET:pr,RIGHTWHITECORNERBRACKET:hr,SCHEME:Zn,SEMI:Lr,SLASH:V,SLASH_SCHEME:Qn,SYM:Vr,TILDE:Rr,TLD:Yn,UNDERSCORE:zr,UTLD:Xn,UWORD:Gn,WORD:R,WS:er}),H=/[a-z]/,Ur=/\p{L}/u,Wr=/\p{Emoji}/u,U=/\d/,Gr=/\s/,Kr=`\r`,qr=`
25
- `,Jr=`️`,Yr=`‍`,Xr=``,Zr=null,Qr=null;function $r(e=[]){let t={};P.groups=t;let n=new P;Zr??=ri(kn),Qr??=ri(An),L(n,`'`,yr),L(n,`{`,nr),L(n,`}`,rr),L(n,`[`,ir),L(n,`]`,ar),L(n,`(`,or),L(n,`)`,sr),L(n,`<`,cr),L(n,`>`,lr),L(n,`(`,ur),L(n,`)`,dr),L(n,`「`,fr),L(n,`」`,pr),L(n,`『`,mr),L(n,`』`,hr),L(n,`<`,gr),L(n,`>`,_r),L(n,`&`,vr),L(n,`*`,br),L(n,`@`,xr),L(n,"`",Cr),L(n,`^`,wr),L(n,`:`,Tr),L(n,`,`,Er),L(n,`$`,Dr),L(n,`.`,z),L(n,`=`,Or),L(n,`!`,kr),L(n,`-`,B),L(n,`%`,Ar),L(n,`|`,jr),L(n,`+`,Mr),L(n,`#`,Nr),L(n,`?`,Pr),L(n,`"`,Fr),L(n,`/`,V),L(n,`;`,Lr),L(n,`~`,Rr),L(n,`_`,zr),L(n,`\\`,Sr),L(n,`・`,Ir);let r=I(n,U,$n,{[jn]:!0});I(r,U,r);let i=I(r,H,Kn,{[Pn]:!0}),a=I(r,Ur,qn,{[Fn]:!0}),o=I(n,H,R,{[Mn]:!0});I(o,U,i),I(o,H,o),I(i,U,i),I(i,H,i);let s=I(n,Ur,Gn,{[Nn]:!0});I(s,H),I(s,U,a),I(s,Ur,s),I(a,U,a),I(a,H),I(a,Ur,a);let c=L(n,qr,tr,{[Bn]:!0}),l=L(n,Kr,er,{[Bn]:!0}),u=I(n,Gr,er,{[Bn]:!0});L(n,Xr,u),L(l,qr,c),L(l,Xr,u),I(l,Gr,u),L(u,Kr),L(u,qr),I(u,Gr,u),L(u,Xr,u);let d=I(n,Wr,Br,{[Ln]:!0});L(d,`#`),I(d,Wr,d),L(d,Jr,d);let f=L(d,Yr);L(f,`#`),I(f,Wr,d);let p=[[H,o],[U,i]],m=[[H,null],[Ur,s],[U,a]];for(let e=0;e<Zr.length;e++)ni(n,Zr[e],Yn,R,p);for(let e=0;e<Qr.length;e++)ni(n,Qr[e],Xn,Gn,m);Hn(Yn,{tld:!0,ascii:!0},t),Hn(Xn,{utld:!0,alpha:!0},t),ni(n,`file`,Zn,R,p),ni(n,`mailto`,Zn,R,p),ni(n,`http`,Qn,R,p),ni(n,`https`,Qn,R,p),ni(n,`ftp`,Qn,R,p),ni(n,`ftps`,Qn,R,p),Hn(Zn,{scheme:!0,ascii:!0},t),Hn(Qn,{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]?{[Rn]:!0}:{[zn]:!0};r.indexOf(`-`)>=0?i[In]=!0:H.test(r)?U.test(r)?i[Pn]=!0:i[Mn]=!0:i[jn]=!0,Wn(n,r,r,i)}return Wn(n,`localhost`,Jn,{ascii:!0}),n.jd=new P(Vr),{start:n,tokens:Object.assign({groups:t},Hr)}}function ei(e,t){let n=ti(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 ti(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 ni(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 P(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new P(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function ri(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 ii={defaultProtocol:`http`,events:null,format:oi,formatHref:oi,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ai(e,t=null){let n=Object.assign({},ii);e&&(n=Object.assign(n,e instanceof ai?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}ai.prototype={o:ii,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]:ii[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 oi(e){return e}function si(e,t){this.t=`token`,this.v=e,this.tk=t}si.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=ii.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 ci(e,t){class n extends si{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 li=ci(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),ui=ci(`text`),di=ci(`nl`),fi=ci(`url`,{isLink:!0,toHref(e=ii.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==Jn&&e[1].t===Tr}}),W=e=>new P(e);function pi({groups:e}){let t=e.domain.concat([vr,br,xr,Sr,Cr,wr,Dr,Or,B,$n,Ar,jr,Mr,Nr,V,Vr,Rr,zr]),n=[yr,Tr,Er,z,kr,Ar,Pr,Fr,Lr,cr,lr,nr,rr,ar,ir,or,sr,ur,dr,fr,pr,mr,hr,gr,_r],r=[vr,yr,br,Sr,Cr,wr,Dr,Or,B,nr,rr,Ar,jr,Mr,Nr,Pr,V,Vr,Rr,zr],i=W(),a=L(i,Rr);F(a,r,a),F(a,e.domain,a);let o=W(),s=W(),c=W();F(i,e.domain,o),F(i,e.scheme,s),F(i,e.slashscheme,c),F(o,r,a),F(o,e.domain,o);let l=L(o,xr);L(a,xr,l),L(s,xr,l),L(c,xr,l);let u=L(a,z);F(u,r,a),F(u,e.domain,a);let d=W();F(l,e.domain,d),F(d,e.domain,d);let f=L(d,z);F(f,e.domain,d);let p=W(li);F(f,e.tld,p),F(f,e.utld,p),L(l,Jn,p);let m=L(d,B);L(m,B,m),F(m,e.domain,d),F(p,e.domain,d),L(p,z,f),L(p,B,m);let h=L(o,B),g=L(o,z);L(h,B,h),F(h,e.domain,o),F(g,r,a),F(g,e.domain,o);let _=W(fi);F(g,e.tld,_),F(g,e.utld,_),F(_,e.domain,o),F(_,r,a),L(_,z,g),L(_,B,h),L(_,xr,l);let ee=L(_,Tr),te=W(fi);F(ee,e.numeric,te);let v=W(fi),y=W();F(v,t,v),F(v,n,y),F(y,t,v),F(y,n,y),L(_,V,v),L(te,V,v);let ne=L(s,Tr),b=L(L(L(c,Tr),V),V);F(s,e.domain,o),L(s,z,g),L(s,B,h),F(c,e.domain,o),L(c,z,g),L(c,B,h),F(ne,e.domain,v),L(ne,V,v),L(ne,Pr,v),F(b,e.domain,v),F(b,t,v),L(b,V,v);let re=[[nr,rr],[ir,ar],[or,sr],[cr,lr],[ur,dr],[fr,pr],[mr,hr],[gr,_r]];for(let e=0;e<re.length;e++){let[r,i]=re[e],a=L(v,r);L(y,r,a);let o=W(fi);F(a,t,o);let s=W();F(a,n,s),L(a,i,v),F(o,t,o),F(o,n,s),F(s,t,o),F(s,n,s),L(o,i,v),L(s,i,v)}return L(i,Jn,_),L(i,tr,di),{start:i,tokens:Hr}}function mi(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(hi(ui,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(hi(e,t,r))}}return o.length>0&&a.push(hi(ui,t,o)),a}function hi(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var gi=typeof console<`u`&&console&&console.warn||(()=>{}),_i=`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 vi(){return P.groups={},G.scanner=null,G.parser=null,G.tokenQueue=[],G.pluginQueue=[],G.customSchemes=[],G.initialized=!1,G}function yi(e,t=!1){if(G.initialized&&gi(`linkifyjs: already initialized - will not register custom scheme "${e}" ${_i}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
25
+ `,Jr=`️`,Yr=`‍`,Xr=``,Zr=null,Qr=null;function $r(e=[]){let t={};P.groups=t;let n=new P;Zr??=ri(kn),Qr??=ri(An),L(n,`'`,yr),L(n,`{`,nr),L(n,`}`,rr),L(n,`[`,ir),L(n,`]`,ar),L(n,`(`,or),L(n,`)`,sr),L(n,`<`,cr),L(n,`>`,lr),L(n,`(`,ur),L(n,`)`,dr),L(n,`「`,fr),L(n,`」`,pr),L(n,`『`,mr),L(n,`』`,hr),L(n,`<`,gr),L(n,`>`,_r),L(n,`&`,vr),L(n,`*`,br),L(n,`@`,xr),L(n,"`",Cr),L(n,`^`,wr),L(n,`:`,Tr),L(n,`,`,Er),L(n,`$`,Dr),L(n,`.`,z),L(n,`=`,Or),L(n,`!`,kr),L(n,`-`,B),L(n,`%`,Ar),L(n,`|`,jr),L(n,`+`,Mr),L(n,`#`,Nr),L(n,`?`,Pr),L(n,`"`,Fr),L(n,`/`,V),L(n,`;`,Lr),L(n,`~`,Rr),L(n,`_`,zr),L(n,`\\`,Sr),L(n,`・`,Ir);let r=I(n,U,$n,{[jn]:!0});I(r,U,r);let i=I(r,H,Kn,{[Pn]:!0}),a=I(r,Ur,qn,{[Fn]:!0}),o=I(n,H,R,{[Mn]:!0});I(o,U,i),I(o,H,o),I(i,U,i),I(i,H,i);let s=I(n,Ur,Gn,{[Nn]:!0});I(s,H),I(s,U,a),I(s,Ur,s),I(a,U,a),I(a,H),I(a,Ur,a);let c=L(n,qr,tr,{[Bn]:!0}),l=L(n,Kr,er,{[Bn]:!0}),u=I(n,Gr,er,{[Bn]:!0});L(n,Xr,u),L(l,qr,c),L(l,Xr,u),I(l,Gr,u),L(u,Kr),L(u,qr),I(u,Gr,u),L(u,Xr,u);let d=I(n,Wr,Br,{[Ln]:!0});L(d,`#`),I(d,Wr,d),L(d,Jr,d);let f=L(d,Yr);L(f,`#`),I(f,Wr,d);let p=[[H,o],[U,i]],m=[[H,null],[Ur,s],[U,a]];for(let e=0;e<Zr.length;e++)ni(n,Zr[e],Yn,R,p);for(let e=0;e<Qr.length;e++)ni(n,Qr[e],Xn,Gn,m);Hn(Yn,{tld:!0,ascii:!0},t),Hn(Xn,{utld:!0,alpha:!0},t),ni(n,`file`,Zn,R,p),ni(n,`mailto`,Zn,R,p),ni(n,`http`,Qn,R,p),ni(n,`https`,Qn,R,p),ni(n,`ftp`,Qn,R,p),ni(n,`ftps`,Qn,R,p),Hn(Zn,{scheme:!0,ascii:!0},t),Hn(Qn,{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]?{[Rn]:!0}:{[zn]:!0};r.indexOf(`-`)>=0?i[In]=!0:H.test(r)?U.test(r)?i[Pn]=!0:i[Mn]=!0:i[jn]=!0,Wn(n,r,r,i)}return Wn(n,`localhost`,Jn,{ascii:!0}),n.jd=new P(Vr),{start:n,tokens:Object.assign({groups:t},Hr)}}function ei(e,t){let n=ti(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 ti(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 ni(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 P(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new P(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function ri(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 ii={defaultProtocol:`http`,events:null,format:oi,formatHref:oi,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ai(e,t=null){let n=Object.assign({},ii);e&&(n=Object.assign(n,e instanceof ai?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}ai.prototype={o:ii,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]:ii[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 oi(e){return e}function si(e,t){this.t=`token`,this.v=e,this.tk=t}si.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=ii.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 ci(e,t){class n extends si{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 li=ci(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),ui=ci(`text`),di=ci(`nl`),fi=ci(`url`,{isLink:!0,toHref(e=ii.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==Jn&&e[1].t===Tr}}),W=e=>new P(e);function pi({groups:e}){let t=e.domain.concat([vr,br,xr,Sr,Cr,wr,Dr,Or,B,$n,Ar,jr,Mr,Nr,V,Vr,Rr,zr]),n=[yr,Tr,Er,z,kr,Ar,Pr,Fr,Lr,cr,lr,nr,rr,ar,ir,or,sr,ur,dr,fr,pr,mr,hr,gr,_r],r=[vr,yr,br,Sr,Cr,wr,Dr,Or,B,nr,rr,Ar,jr,Mr,Nr,Pr,V,Vr,Rr,zr],i=W(),a=L(i,Rr);F(a,r,a),F(a,e.domain,a);let o=W(),s=W(),c=W();F(i,e.domain,o),F(i,e.scheme,s),F(i,e.slashscheme,c),F(o,r,a),F(o,e.domain,o);let l=L(o,xr);L(a,xr,l),L(s,xr,l),L(c,xr,l);let u=L(a,z);F(u,r,a),F(u,e.domain,a);let d=W();F(l,e.domain,d),F(d,e.domain,d);let f=L(d,z);F(f,e.domain,d);let p=W(li);F(f,e.tld,p),F(f,e.utld,p),L(l,Jn,p);let m=L(d,B);L(m,B,m),F(m,e.domain,d),F(p,e.domain,d),L(p,z,f),L(p,B,m);let h=L(o,B),g=L(o,z);L(h,B,h),F(h,e.domain,o),F(g,r,a),F(g,e.domain,o);let _=W(fi);F(g,e.tld,_),F(g,e.utld,_),F(_,e.domain,o),F(_,r,a),L(_,z,g),L(_,B,h),L(_,xr,l);let ee=L(_,Tr),te=W(fi);F(ee,e.numeric,te);let v=W(fi),y=W();F(v,t,v),F(v,n,y),F(y,t,v),F(y,n,y),L(_,V,v),L(te,V,v);let b=L(s,Tr),ne=L(L(L(c,Tr),V),V);F(s,e.domain,o),L(s,z,g),L(s,B,h),F(c,e.domain,o),L(c,z,g),L(c,B,h),F(b,e.domain,v),L(b,V,v),L(b,Pr,v),F(ne,e.domain,v),F(ne,t,v),L(ne,V,v);let re=[[nr,rr],[ir,ar],[or,sr],[cr,lr],[ur,dr],[fr,pr],[mr,hr],[gr,_r]];for(let e=0;e<re.length;e++){let[r,i]=re[e],a=L(v,r);L(y,r,a);let o=W(fi);F(a,t,o);let s=W();F(a,n,s),L(a,i,v),F(o,t,o),F(o,n,s),F(s,t,o),F(s,n,s),L(o,i,v),L(s,i,v)}return L(i,Jn,_),L(i,tr,di),{start:i,tokens:Hr}}function mi(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(hi(ui,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(hi(e,t,r))}}return o.length>0&&a.push(hi(ui,t,o)),a}function hi(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var gi=typeof console<`u`&&console&&console.warn||(()=>{}),_i=`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 vi(){return P.groups={},G.scanner=null,G.parser=null,G.tokenQueue=[],G.pluginQueue=[],G.customSchemes=[],G.initialized=!1,G}function yi(e,t=!1){if(G.initialized&&gi(`linkifyjs: already initialized - will not register custom scheme "${e}" ${_i}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
26
26
  1. Must only contain digits, lowercase ASCII letters or "-"
27
27
  2. Cannot start or end with "-"
28
28
  3. "-" cannot repeat`);G.customSchemes.push([e,t])}function bi(){G.scanner=$r(G.customSchemes);for(let e=0;e<G.tokenQueue.length;e++)G.tokenQueue[e][1]({scanner:G.scanner});G.parser=pi(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 xi(e){return G.initialized||bi(),mi(G.parser.start,e,ei(G.scanner.start,e))}xi.scan=ei;function Si(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 ai(n),i=xi(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 Ci=`[\0- \xA0 ᠎ -\u2029  ]`,wi=new RegExp(Ci),Ti=RegExp(`${Ci}$`),Ei=new RegExp(Ci,`g`);function Di(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function Oi(e){return new w({key:new C(`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=Me(n.doc,[...t]);if(se(s).forEach(({newRange:t})=>{let n=Ye(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(!Ti.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=xi(n).map(t=>t.toObject(e.defaultProtocol));if(!Di(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=>{Ce(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 ki(e){return new w({key:new C(`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=Se(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 Ai=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,ji=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Mi(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function Ni(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&Mi(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 Pi(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||Mi(e,t.index??0)||Ni(e,t.index??0)?!1:!!r.trim()&&n(i)}function Fi(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 Ii(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function Li(e){return{href:e.data?.href,title:e.data?.title??null}}function Ri(e){let t=ge({find:t=>{let n=Ai.exec(t);return!n||!Pi(t,n,e.isAllowedHref)?null:Fi(n)},type:e.type,getAttributes:Li});return new Ie({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 zi(e){let t=S({find:t=>{let n=[];for(let r of t.matchAll(ji))Pi(t,r,e.isAllowedHref)&&n.push(Fi(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>Ii(t,e)));return[...n,...r]},type:e.type,getAttributes:Li});return new Ae({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 Bi(e){return new w({key:new C(`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=Si(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 K(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(Ei,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var Vi=Ge.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`){yi(e);return}yi(e.scheme,e.optionalSlashes)})},onDestroy(){vi()},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)=>!!K(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=>!!K(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=>!!K(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,j(this.options.HTMLAttributes,e),0]:[`a`,j(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=>!!K(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=>!!K(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?[Ri({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!K(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;Si(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!K(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?[zi({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!K(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[S({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(Oi({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!K(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(ki({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(Bi({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),Hi=Object.defineProperty,Ui=(e,t)=>{for(var n in t)Hi(e,n,{get:t[n],enumerable:!0})},Wi=`listItem`,Gi=`textStyle`,Ki=/^\s*([-+*])\s$/,qi=D.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`,j(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,`
@@ -36,7 +36,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpah
36
36
  `):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let r=e.split(`
37
37
  `),[i,a]=Ia(r);if(i.length===0)return;let o=za(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
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(Va,this.editor.getAttributes(Ha)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new w({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=Ra(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=Ee({find:Ua,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ee({find:Ua,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ha)}),joinPredicate:e,editor:this.editor})),[t]}}),Ka=/^\s*(\[([( |x])?\])\s$/,qa=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,Ja=(e,t,n)=>(n?.checkboxLabel)?.call(n,e,t)||`Task item checkbox for ${e.textContent||`empty task item`}`,Ya=D.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`,j(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 fe(e,t,n)},addExtensions(){return this.options.nested?[Zi(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=qa;let l=e=>{let t=Ja(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=Fe(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[Ee({find:Ka,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Xa=D.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`,j(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=Te(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=Te(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()}}});E.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(qi.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ga.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Oa.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Ga.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Ya.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Xa.configure(this.options.taskList)),e}});var Za=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Qa=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$a=Ge.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`,j(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[ge({find:Za,type:this.type})]},addPasteRules(){return[S({find:Qa,type:this.type})]}}),eo=Ge.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`,j(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()}}}),to=E.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(pn.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(cn.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(qi.configure(this.options.bulletList)),this.options.code!==!1&&e.push(gn.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(bn.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Ve.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(jt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Mt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(xn.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Sn.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(rn.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Cn.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(On.configure(this.options.italic)),this.options.listItem!==!1&&e.push(ga.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Oa.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(Vi.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(Ga.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Re.configure(this.options.paragraph)),this.options.strike!==!1&&e.push($a.configure(this.options.strike)),this.options.text!==!1&&e.push(Ue.configure(this.options.text)),this.options.underline!==!1&&e.push(eo.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(nn.configure(this.options?.trailingNode)),e}}),no=e(t(),1),ro=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},io=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=ro(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},ao=(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=Oe(e=>e.type===a.nodes.details)(o);if(!u)return!1;let d=Ke(u.node,e=>e.type===a.nodes.detailsContent);if(!d.length||ro(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=M.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new M(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},oo=D.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`,j(this.options.HTMLAttributes,e),0]},...je({nodeName:`details`,content:`block`}),addNodeView(){return({editor:e,getPos:t,node:n,HTMLAttributes:r})=>{let i=document.createElement(`div`),a=j(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=Oe(e=>e.type===this.type)(n);if(!i)return!1;let a=Ke(i.node,e=>e.type===r.nodes.detailsSummary),o=Ke(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=ro(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=De(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=T.near(p,1);return f.setSelection(m),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:e})=>ao(e,`right`),ArrowDown:({editor:e})=>ao(e,`down`)}},addProseMirrorPlugins(){return[new w({key:new C(`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||!Pe(n,i.name))return;let{$from:a}=n.selection;if(ro(a.pos,r))return;let o=io(a,e=>e.type===i,r);if(!o)return;let s=Ke(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=x.create(n.doc,l);return n.tr.setSelection(u)}})]}}),so=D.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`,j(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:e})=>{let t=document.createElement(`div`),n=j(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=Oe(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=De(m.contentMatchAt(h));if(!g||!m.canReplaceWith(h,h,g))return!1;let _=g.createAndFill();if(!_)return!1;let{tr:ee}=t,te=i.after(-2);ee.replaceWith(te,te,_);let v=ee.doc.resolve(te),y=T.near(v,1);ee.setSelection(y);let ne=p,b=p+f.nodeSize;return ee.delete(ne,b),ee.scrollIntoView(),n.dispatch(ee),!0}}},...je({nodeName:`detailsContent`})}),co=D.create({name:`detailsSummary`,content:`text*`,defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`summary`}]},renderHTML({HTMLAttributes:e}){return[`summary`,j(this.options.HTMLAttributes,e),0]},...je({nodeName:`detailsSummary`,content:`inline`})}),lo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,uo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,fo=Ge.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||ae(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`,j(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[ge({find:lo,type:this.type})]},addPasteRules(){return[S({find:uo,type:this.type})]}}),po,mo;if(typeof WeakMap<`u`){let e=new WeakMap;po=t=>e.get(t),mo=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;po=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},mo=(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 po(e)||mo(e,ho(e))}};function ho(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=go(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&&_o(s,o,e),s}function go(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 _o(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||=vo(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function vo(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 yo=new C(`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 xo(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 So(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)||Co(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Co(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 To(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Eo(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Do(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 Oo(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 ko(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 Ao(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 T{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 xe(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)&&Eo(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 x.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=Oo(e,0,l)),u>0&&(e=Oo(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(A.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new O(A.from(o),1,1)}replace(e,t=O.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?O.empty:t)}let i=T.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new O(A.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 jo(this.$anchorCell.pos,this.$headCell.pos)}};X.prototype.visible=!1,T.jsonID(`cell`,X);var jo=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&&Eo(t,n)?new X(t,n):T.near(n,1)}};function Mo(e){if(!(e.selection instanceof X))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(he.node(n,n+e.nodeSize,{class:`selectedCell`}))}),k.create(e.doc,t)}function No({$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 Po({$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 Fo(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof me&&(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 x&&No(r)?a=x.create(i,r.from):r instanceof x&&Po(r)&&(a=x.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Io=new C(`fix-tables`);function Lo(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)?Lo(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Ro(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=zo(e,t,r,n))};return t?t.doc!=e.doc&&Lo(t.doc,e.doc,0,r):e.doc.descendants(r),n}function zo(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,Oo(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(Io,{fixTables:!0})}function Z(e){let t=e.selection,n=So(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 Bo(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Ao(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,ko(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 Vo(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Bo(e.tr,n,n.left))}return!0}function Ho(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Bo(e.tr,n,n.right))}return!0}function Uo(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,Oo(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 Wo(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;Uo(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 Go(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 Ko(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;Go(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 qo(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Ko(e.tr,n,n.top))}return!0}function Jo(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Ko(e.tr,n,n.bottom))}return!0}function Yo(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 Xo(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;Yo(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 Zo(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function Qo({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 $o(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(Qo(i,r))return!1;if(t){let n=e.tr,a={},o=A.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{Zo(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,{...ko(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=Zo(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 es(e,t){let n=J(e.schema);return ts(({node:e})=>n[e.type.spec.tableRole])(e,t)}function ts(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=xo(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 ns(e,t){return function(n,r){if(!Y(n))return!1;let i=So(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 rs(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 is(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 as(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?rs(e):function(t,n){if(!Y(t))return!1;if(n){let r=J(t.schema),i=Z(t),a=t.tr,o=is(`row`,i,r),s=is(`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}}as(`row`,{useDeprecatedLogic:!0}),as(`column`,{useDeprecatedLogic:!0});var os=as(`cell`,{useDeprecatedLogic:!0});function ss(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 cs(e){return function(t,n){if(!Y(t))return!1;let r=ss(So(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(x.between(e,To(e))).scrollIntoView())}return!0}}function ls(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 us(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 O(i,0,0))}),r.docChanged&&t(r)}return!0}function ds(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=ps(J(o).row,new O(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?ps(J(o).row,new O(t,n,r)).content:t);else return null;return fs(o,s)}function fs(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(A.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(A.from(o))}return{height:t.length,width:r,rows:t}}function ps(e,t){let n=e.createAndFill();return new We(n).replace(0,n.content.size,t).doc}function ms({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(Oo(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(A.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(A.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function hs(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,A.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 gs(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 _s(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,Oo(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Oo(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function vs(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}hs(d,o,a,n,l,u,f)&&p(),gs(d,o,a,n,c,l,s,f)&&p(),gs(d,o,a,n,c,l,u,f)&&p(),_s(d,o,a,n,s,u,c,f)&&p(),_s(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 O(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 ys=de({ArrowLeft:xs(`horiz`,-1),ArrowRight:xs(`horiz`,1),ArrowUp:xs(`vert`,-1),ArrowDown:xs(`vert`,1),"Shift-ArrowLeft":Ss(`horiz`,-1),"Shift-ArrowRight":Ss(`horiz`,1),"Shift-ArrowUp":Ss(`vert`,-1),"Shift-ArrowDown":Ss(`vert`,1),Backspace:us,"Mod-Backspace":us,Delete:us,"Mod-Delete":us});function bs(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function xs(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof X)return bs(n,r,T.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Es(i,e,t);if(o==null)return!1;if(e==`horiz`)return bs(n,r,T.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Do(i,e,t),s;return s=a?T.near(a,1):t<0?T.near(n.doc.resolve(i.before(-1)),-1):T.near(n.doc.resolve(i.after(-1)),1),bs(n,r,s)}}}function Ss(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof X)o=a;else{let r=Es(i,e,t);if(r==null)return!1;o=new X(n.doc.resolve(r))}let s=Do(o.$headCell,e,t);return s?bs(n,r,new X(o.$anchorCell,s)):!1}}function Cs(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=ds(n),i=e.state.selection;if(i instanceof X){r||={width:1,height:1,rows:[A.from(ps(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=ms(r,o.right-o.left,o.bottom-o.top),vs(e.state,e.dispatch,a,o,r),!0}if(r){let t=So(e.state),n=t.start(-1);return vs(e.state,e.dispatch,n,q.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function Ts(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Ds(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&&Os(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Os(e,n),i=yo.getState(e.state)==null;if(!r||!Eo(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(yo,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),yo.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(yo,-1))}function o(r){let o=r,s=yo.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Ds(e,o.target)!=n&&(c=Os(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 Es(e,t,n){if(!(e.state.selection instanceof x))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 Ds(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Os(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 ks=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`)),As(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,As(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function As(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 C(`tableColumnResizing`);function js({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=ks,lastColumnResizable:i=!0}={}){let a=new w({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 Ms(-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)=>{Ns(t,n,e,i)},mouseleave:e=>{Ps(e)},mousedown:(e,r)=>{Fs(e,r,t,n)}},decorations:e=>{let t=Q.getState(e);if(t&&t.activeHandle>-1)return Ws(e,t.activeHandle)},nodeViews:{}}});return a}var Ms=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 Ns(e,t,n,r){if(!e.editable)return;let i=Q.getState(e.state);if(i&&!i.dragging){let a=Ls(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=Rs(e,t,`left`,n):i-t.clientX<=n&&(o=Rs(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}Bs(e,o)}}}function Ps(e){if(!e.editable)return;let t=Q.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Bs(e,-1)}function Fs(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=Is(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&&(Vs(e,r.activeHandle,zs(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=zs(i.dragging,t,n);Hs(e,i.activeHandle,a,r)}}return Hs(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function Is(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 Ls(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Rs(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 zs(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Bs(e,t){e.dispatch(e.state.tr.setMeta(Q,{setHandle:t}))}function Vs(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():Us(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function Hs(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&&As(a,c.firstChild,c,r,s,n)}function Us(e){return Array(e).fill(0)}function Ws(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return k.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(he.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(he.widget(s,c))}}return k.create(e.doc,n)}function Gs({allowTableNodeSelection:e=!1}={}){return new w({key:yo,state:{init(){return null},apply(e,t){let n=e.getMeta(yo);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:Mo,handleDOMEvents:{mousedown:Ts},createSelectionBetween(e){return yo.getState(e.state)==null?null:e.state.selection},handleTripleClick:Cs,handleKeyDown:ys,handlePaste:ws},appendTransaction(t,n,r){return Fo(r,Ro(r,n),e)}})}function Ks(e){return e===`left`||e===`right`||e===`center`?e:null}function qs(e){let t=(e.style.textAlign||``).trim().toLowerCase(),n=(e.getAttribute(`align`)||``).trim().toLowerCase();return Ks(t||n)}function Js(e){return Ks(e?.align)}function Ys(){return{default:null,parseHTML:e=>qs(e),renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}function Xs(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 Zs(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):Xs(e)}var Qs=/[ \t\r\n\f]+/g;function $s(e){return e.children.length>0?!1:(e.textContent??``).replace(Qs,``)===``}function ec(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}var tc=D.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Zs},align:Ys()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>$s(e)?{}:!1,getContent:(e,t)=>ec(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,j(this.options.HTMLAttributes,e),0]}}),nc=D.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Zs},align:Ys()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>$s(e)?{}:!1,getContent:(e,t)=>ec(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,j(this.options.HTMLAttributes,e),0]}}),rc=D.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,j(this.options.HTMLAttributes,e),0]}});function ic(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function ac(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]=ic(r,o);l.style.setProperty(e,t)}l=l.nextSibling}else{let e=document.createElement(`col`),[n,i]=ic(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 oc=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`)),ac(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,ac(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 sc(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]=ic(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 cc(e,t){return t?e.createChecked(null,t):e.createAndFill()}function lc(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 uc(e,t,n,r,i){let a=lc(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=cc(a.cell,i);if(e&&s.push(e),r){let e=cc(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 dc(e){return e instanceof X}var fc=({editor:e})=>{let{selection:t}=e.state;if(!dc(t))return!1;let n=0;return Je(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 pc(e,t){let n=e.mapping.map(t);if(Je(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(x.near(e.doc.resolve(i),-1))}function mc(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 hc(e){return e.split(`
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=Te(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=Te(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()}}});E.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(qi.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ga.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Oa.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Ga.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Ya.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Xa.configure(this.options.taskList)),e}});var Za=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Qa=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$a=Ge.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`,j(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[ge({find:Za,type:this.type})]},addPasteRules(){return[S({find:Qa,type:this.type})]}}),eo=Ge.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`,j(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()}}}),to=E.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(pn.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(cn.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(qi.configure(this.options.bulletList)),this.options.code!==!1&&e.push(gn.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(bn.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Ve.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(jt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Mt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(xn.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Sn.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(rn.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Cn.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(On.configure(this.options.italic)),this.options.listItem!==!1&&e.push(ga.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Oa.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(Vi.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(Ga.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Re.configure(this.options.paragraph)),this.options.strike!==!1&&e.push($a.configure(this.options.strike)),this.options.text!==!1&&e.push(Ue.configure(this.options.text)),this.options.underline!==!1&&e.push(eo.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(nn.configure(this.options?.trailingNode)),e}}),no=e(t(),1),ro=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},io=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=ro(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},ao=(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=Oe(e=>e.type===a.nodes.details)(o);if(!u)return!1;let d=Ke(u.node,e=>e.type===a.nodes.detailsContent);if(!d.length||ro(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=M.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new M(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},oo=D.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`,j(this.options.HTMLAttributes,e),0]},...je({nodeName:`details`,content:`block`}),addNodeView(){return({editor:e,getPos:t,node:n,HTMLAttributes:r})=>{let i=document.createElement(`div`),a=j(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=Oe(e=>e.type===this.type)(n);if(!i)return!1;let a=Ke(i.node,e=>e.type===r.nodes.detailsSummary),o=Ke(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=ro(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=De(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=T.near(p,1);return f.setSelection(m),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:e})=>ao(e,`right`),ArrowDown:({editor:e})=>ao(e,`down`)}},addProseMirrorPlugins(){return[new w({key:new C(`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||!Pe(n,i.name))return;let{$from:a}=n.selection;if(ro(a.pos,r))return;let o=io(a,e=>e.type===i,r);if(!o)return;let s=Ke(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=x.create(n.doc,l);return n.tr.setSelection(u)}})]}}),so=D.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`,j(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:e})=>{let t=document.createElement(`div`),n=j(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=Oe(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=De(m.contentMatchAt(h));if(!g||!m.canReplaceWith(h,h,g))return!1;let _=g.createAndFill();if(!_)return!1;let{tr:ee}=t,te=i.after(-2);ee.replaceWith(te,te,_);let v=ee.doc.resolve(te),y=T.near(v,1);ee.setSelection(y);let b=p,ne=p+f.nodeSize;return ee.delete(b,ne),ee.scrollIntoView(),n.dispatch(ee),!0}}},...je({nodeName:`detailsContent`})}),co=D.create({name:`detailsSummary`,content:`text*`,defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`summary`}]},renderHTML({HTMLAttributes:e}){return[`summary`,j(this.options.HTMLAttributes,e),0]},...je({nodeName:`detailsSummary`,content:`inline`})}),lo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,uo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,fo=Ge.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||ae(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`,j(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[ge({find:lo,type:this.type})]},addPasteRules(){return[S({find:uo,type:this.type})]}}),po,mo;if(typeof WeakMap<`u`){let e=new WeakMap;po=t=>e.get(t),mo=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;po=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},mo=(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 po(e)||mo(e,ho(e))}};function ho(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=go(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&&_o(s,o,e),s}function go(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 _o(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||=vo(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function vo(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 yo=new C(`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 xo(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 So(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)||Co(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Co(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 To(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Eo(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Do(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 Oo(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 ko(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 Ao(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 T{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 xe(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)&&Eo(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 x.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=Oo(e,0,l)),u>0&&(e=Oo(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(A.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new O(A.from(o),1,1)}replace(e,t=O.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?O.empty:t)}let i=T.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new O(A.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 jo(this.$anchorCell.pos,this.$headCell.pos)}};X.prototype.visible=!1,T.jsonID(`cell`,X);var jo=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&&Eo(t,n)?new X(t,n):T.near(n,1)}};function Mo(e){if(!(e.selection instanceof X))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(he.node(n,n+e.nodeSize,{class:`selectedCell`}))}),k.create(e.doc,t)}function No({$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 Po({$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 Fo(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof me&&(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 x&&No(r)?a=x.create(i,r.from):r instanceof x&&Po(r)&&(a=x.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Io=new C(`fix-tables`);function Lo(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)?Lo(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Ro(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=zo(e,t,r,n))};return t?t.doc!=e.doc&&Lo(t.doc,e.doc,0,r):e.doc.descendants(r),n}function zo(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,Oo(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(Io,{fixTables:!0})}function Z(e){let t=e.selection,n=So(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 Bo(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Ao(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,ko(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 Vo(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Bo(e.tr,n,n.left))}return!0}function Ho(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Bo(e.tr,n,n.right))}return!0}function Uo(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,Oo(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 Wo(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;Uo(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 Go(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 Ko(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;Go(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 qo(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Ko(e.tr,n,n.top))}return!0}function Jo(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Ko(e.tr,n,n.bottom))}return!0}function Yo(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 Xo(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;Yo(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 Zo(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function Qo({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 $o(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(Qo(i,r))return!1;if(t){let n=e.tr,a={},o=A.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{Zo(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,{...ko(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=Zo(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 es(e,t){let n=J(e.schema);return ts(({node:e})=>n[e.type.spec.tableRole])(e,t)}function ts(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=xo(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 ns(e,t){return function(n,r){if(!Y(n))return!1;let i=So(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 rs(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 is(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 as(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?rs(e):function(t,n){if(!Y(t))return!1;if(n){let r=J(t.schema),i=Z(t),a=t.tr,o=is(`row`,i,r),s=is(`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}}as(`row`,{useDeprecatedLogic:!0}),as(`column`,{useDeprecatedLogic:!0});var os=as(`cell`,{useDeprecatedLogic:!0});function ss(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 cs(e){return function(t,n){if(!Y(t))return!1;let r=ss(So(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(x.between(e,To(e))).scrollIntoView())}return!0}}function ls(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 us(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 O(i,0,0))}),r.docChanged&&t(r)}return!0}function ds(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=ps(J(o).row,new O(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?ps(J(o).row,new O(t,n,r)).content:t);else return null;return fs(o,s)}function fs(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(A.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(A.from(o))}return{height:t.length,width:r,rows:t}}function ps(e,t){let n=e.createAndFill();return new We(n).replace(0,n.content.size,t).doc}function ms({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(Oo(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(A.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(A.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function hs(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,A.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 gs(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 _s(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,Oo(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Oo(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function vs(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}hs(d,o,a,n,l,u,f)&&p(),gs(d,o,a,n,c,l,s,f)&&p(),gs(d,o,a,n,c,l,u,f)&&p(),_s(d,o,a,n,s,u,c,f)&&p(),_s(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 O(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 ys=de({ArrowLeft:xs(`horiz`,-1),ArrowRight:xs(`horiz`,1),ArrowUp:xs(`vert`,-1),ArrowDown:xs(`vert`,1),"Shift-ArrowLeft":Ss(`horiz`,-1),"Shift-ArrowRight":Ss(`horiz`,1),"Shift-ArrowUp":Ss(`vert`,-1),"Shift-ArrowDown":Ss(`vert`,1),Backspace:us,"Mod-Backspace":us,Delete:us,"Mod-Delete":us});function bs(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function xs(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof X)return bs(n,r,T.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Es(i,e,t);if(o==null)return!1;if(e==`horiz`)return bs(n,r,T.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Do(i,e,t),s;return s=a?T.near(a,1):t<0?T.near(n.doc.resolve(i.before(-1)),-1):T.near(n.doc.resolve(i.after(-1)),1),bs(n,r,s)}}}function Ss(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof X)o=a;else{let r=Es(i,e,t);if(r==null)return!1;o=new X(n.doc.resolve(r))}let s=Do(o.$headCell,e,t);return s?bs(n,r,new X(o.$anchorCell,s)):!1}}function Cs(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=ds(n),i=e.state.selection;if(i instanceof X){r||={width:1,height:1,rows:[A.from(ps(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=ms(r,o.right-o.left,o.bottom-o.top),vs(e.state,e.dispatch,a,o,r),!0}if(r){let t=So(e.state),n=t.start(-1);return vs(e.state,e.dispatch,n,q.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function Ts(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Ds(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&&Os(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Os(e,n),i=yo.getState(e.state)==null;if(!r||!Eo(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(yo,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),yo.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(yo,-1))}function o(r){let o=r,s=yo.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Ds(e,o.target)!=n&&(c=Os(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 Es(e,t,n){if(!(e.state.selection instanceof x))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 Ds(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Os(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 ks=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`)),As(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,As(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function As(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 C(`tableColumnResizing`);function js({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=ks,lastColumnResizable:i=!0}={}){let a=new w({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 Ms(-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)=>{Ns(t,n,e,i)},mouseleave:e=>{Ps(e)},mousedown:(e,r)=>{Fs(e,r,t,n)}},decorations:e=>{let t=Q.getState(e);if(t&&t.activeHandle>-1)return Ws(e,t.activeHandle)},nodeViews:{}}});return a}var Ms=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 Ns(e,t,n,r){if(!e.editable)return;let i=Q.getState(e.state);if(i&&!i.dragging){let a=Ls(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=Rs(e,t,`left`,n):i-t.clientX<=n&&(o=Rs(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}Bs(e,o)}}}function Ps(e){if(!e.editable)return;let t=Q.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Bs(e,-1)}function Fs(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=Is(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&&(Vs(e,r.activeHandle,zs(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=zs(i.dragging,t,n);Hs(e,i.activeHandle,a,r)}}return Hs(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function Is(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 Ls(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Rs(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 zs(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Bs(e,t){e.dispatch(e.state.tr.setMeta(Q,{setHandle:t}))}function Vs(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():Us(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function Hs(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&&As(a,c.firstChild,c,r,s,n)}function Us(e){return Array(e).fill(0)}function Ws(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return k.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(he.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(he.widget(s,c))}}return k.create(e.doc,n)}function Gs({allowTableNodeSelection:e=!1}={}){return new w({key:yo,state:{init(){return null},apply(e,t){let n=e.getMeta(yo);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:Mo,handleDOMEvents:{mousedown:Ts},createSelectionBetween(e){return yo.getState(e.state)==null?null:e.state.selection},handleTripleClick:Cs,handleKeyDown:ys,handlePaste:ws},appendTransaction(t,n,r){return Fo(r,Ro(r,n),e)}})}function Ks(e){return e===`left`||e===`right`||e===`center`?e:null}function qs(e){let t=(e.style.textAlign||``).trim().toLowerCase(),n=(e.getAttribute(`align`)||``).trim().toLowerCase();return Ks(t||n)}function Js(e){return Ks(e?.align)}function Ys(){return{default:null,parseHTML:e=>qs(e),renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}function Xs(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 Zs(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):Xs(e)}var Qs=/[ \t\r\n\f]+/g;function $s(e){return e.children.length>0?!1:(e.textContent??``).replace(Qs,``)===``}function ec(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}var tc=D.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Zs},align:Ys()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>$s(e)?{}:!1,getContent:(e,t)=>ec(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,j(this.options.HTMLAttributes,e),0]}}),nc=D.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Zs},align:Ys()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>$s(e)?{}:!1,getContent:(e,t)=>ec(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,j(this.options.HTMLAttributes,e),0]}}),rc=D.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,j(this.options.HTMLAttributes,e),0]}});function ic(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function ac(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]=ic(r,o);l.style.setProperty(e,t)}l=l.nextSibling}else{let e=document.createElement(`col`),[n,i]=ic(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 oc=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`)),ac(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,ac(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 sc(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]=ic(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 cc(e,t){return t?e.createChecked(null,t):e.createAndFill()}function lc(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 uc(e,t,n,r,i){let a=lc(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=cc(a.cell,i);if(e&&s.push(e),r){let e=cc(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 dc(e){return e instanceof X}var fc=({editor:e})=>{let{selection:t}=e.state;if(!dc(t))return!1;let n=0;return Je(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 pc(e,t){let n=e.mapping.map(t);if(Je(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(x.near(e.doc.resolve(i),-1))}function mc(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 hc(e){return e.split(`
40
40
  `).map(e=>!e.includes(`|`)||!e.includes("`")?e:mc(e)).join(`
41
41
  `)}function gc(e){return(e||``).replace(/\s+/g,` `).trim()}function _c(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=gc(i.split(r).join(`
42
42
  `).replace(/[ \t]*\r?\n[ \t]*/g,`<br>`)),o=e.type===`tableHeader`,s=Js(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=`
@@ -50,4 +50,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpah
50
50
  `);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=hc(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(`
51
51
  `).length,u=e.split(`
52
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=uc(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(x.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Vo(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Ho(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=Je(e.selection.$from,e=>e.type.name===`table`);return Wo(e,t&&(e=>{n&&pc(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>qo(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Jo(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=Je(e.selection.$from,e=>e.type.name===`table`);return Xo(e,t&&(e=>{n&&pc(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>ls(e,t),mergeCells:()=>({state:e,dispatch:t})=>$o(e,t),splitCell:()=>({state:e,dispatch:t})=>es(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>as(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>as(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>os(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>$o(e,t)?!0:es(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>ns(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>cs(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>cs(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Ro(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:fc,"Mod-Backspace":fc,Delete:fc,"Mod-Delete":fc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[js({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Gs({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=j(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:Be(qe(e,`tableRole`,t))}}}),bc=E.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(yc.configure(this.options.table)),this.options.tableCell!==!1&&e.push(tc.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(nc.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(rc.configure(this.options.tableRow)),e}}),xc=E.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(b(),1),Sc=[1,2,3,4,5,6],Cc=[`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`}},Tc=[`😀`,`😅`,`😂`,`🥳`,`😎`,`🤔`,`👍`,`🙏`,`🔥`,`🎉`,`🚀`,`💡`,`✅`,`❌`,`⭐`,`❤️`];function Ec(e){let t=(e??Sc).filter(e=>e>=1&&e<=6);return t.length>0?t:Sc}function Dc({editor:e,levels:t}){let{t:n}=ie(`lattice`),r=n(`form.editor.heading`,`Heading`);return(0,$.jsxs)(h,{children:[(0,$.jsx)(u,{asChild:!0,children:(0,$.jsx)(g,{active:e.isActive(`heading`),icon:`heading`,label:r,testId:`editor-heading`})}),(0,$.jsx)(m,{className:`min-w-32`,children:t.map(t=>(0,$.jsx)(d,{className:re(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 Oc({editor:e}){let{t}=ie(`lattice`),[n,r]=(0,no.useState)(!1),[i,o]=(0,no.useState)(``),s=()=>{i?e.chain().focus().extendMarkRange(`link`).setLink({href:i}).run():e.chain().focus().extendMarkRange(`link`).unsetLink().run(),r(!1)};return(0,$.jsxs)(a,{onOpenChange:t=>{t&&o(e.getAttributes(`link`).href??``),r(t)},open:n,children:[(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(g,{active:e.isActive(`link`),icon:`link`,label:t(`form.editor.link`,`Link`),testId:`editor-link`})}),(0,$.jsxs)(te,{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(),s())},placeholder:`https://`,type:`url`,value:i}),(0,$.jsx)(g,{icon:`check`,label:t(`form.editor.link-apply`,`Apply link`),onClick:s,testId:`editor-link-apply`}),e.isActive(`link`)&&(0,$.jsx)(g,{icon:`trash-2`,label:t(`form.editor.link-remove`,`Remove link`),onClick:()=>{e.chain().focus().extendMarkRange(`link`).unsetLink().run(),r(!1)},testId:`editor-link-remove`})]})]})}function kc({editor:e,emojis:t}){let{t:n}=ie(`lattice`),[r,i]=(0,no.useState)(!1);return(0,$.jsxs)(a,{onOpenChange:i,open:r,children:[(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(g,{icon:`smile`,label:n(`form.editor.insert-emoji`,`Insert emoji`),testId:`editor-emoji`})}),(0,$.jsx)(te,{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(),i(!1)},onMouseDown:e=>e.preventDefault(),type:`button`,children:t},t))})]})}function Ac(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 jc={bold:{group:`marks`,starterKit:()=>({bold:{}}),toolbar:()=>[Ac(`bold`,`bold`,`Bold`,`bold`)]},italic:{group:`marks`,starterKit:()=>({italic:{}}),toolbar:()=>[Ac(`italic`,`italic`,`Italic`,`italic`)]},strike:{group:`marks`,starterKit:()=>({strike:{}}),toolbar:()=>[Ac(`strikethrough`,`strikethrough`,`Strikethrough`,`strike`)]},underline:{group:`marks`,starterKit:()=>({underline:{}}),toolbar:()=>[Ac(`underline`,`underline`,`Underline`,`underline`)]},highlight:{group:`marks`,extensions:()=>[fo],toolbar:()=>[Ac(`highlight`,`highlighter`,`Highlight`,`highlight`)]},code:{group:`marks`,starterKit:()=>({code:{}}),toolbar:()=>[Ac(`code`,`code-xml`,`Code`,`code`)]},heading:{starterKit:e=>({heading:{levels:Ec(e.levels)}}),toolbar:e=>{let t=Ec(e.levels);return[{key:`heading`,component:({editor:e})=>(0,$.jsx)(Dc,{editor:e,levels:t})}]}},"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()}]},"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()}]},blockquote:{group:`blocks`,starterKit:()=>({blockquote:{}}),toolbar:()=>[{icon:`quote`,key:`blockquote`,label:`Blockquote`,isActive:e=>e.isActive(`blockquote`),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()}]},"horizontal-rule":{group:`blocks`,starterKit:()=>({horizontalRule:{}}),toolbar:()=>[{icon:`minus`,key:`horizontal-rule`,label:`Horizontal rule`,isActive:()=>!1,run:e=>e.chain().focus().setHorizontalRule().run()}]},"text-align":{extensions:e=>[xc.configure({alignments:e.alignments??Cc,types:[`heading`,`paragraph`]})],toolbar:e=>(e.alignments??Cc).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)(Oc,{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()}]},details:{group:`insert`,extensions:()=>[oo,co,so],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()}}]},emoji:{toolbar:e=>{let t=e.emojis??Tc;return[{key:`insert-emoji`,component:({editor:e})=>(0,$.jsx)(kc,{editor:e,emojis:t})}]}}};function Mc({editor:e,items:t}){let{t:n}=ie(`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)(g,{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 Nc=({node:e})=>{let t=ne(o),{errors:a}=i(),{hidden:u,required:d,readOnly:m,disabled:h}=s(e),{change:g,blur:te}=n(),y=e.props.name,b=r(),ie=v(y),x=b?b.getValue(y):ie,ae=b?b.scopedName(y):y,oe=b?b.errorKey(y):y,se=m||h,ce=typeof x==`object`&&x?x:e.props.value??``,le=(0,no.useMemo)(()=>l(e.props.extensions,{...jc,...t}),[t,e.props.extensions]),ue=(0,no.useMemo)(()=>c(le),[le]),de=(0,no.useMemo)(()=>[to.configure(f(le)),Xt.configure({placeholder:e.props.placeholder??``}),..._(le)],[le,e.props.placeholder]),fe=He({extensions:de,content:ce,editable:!se,immediatelyRender:!1,shouldRerenderOnTransaction:!0,editorProps:{attributes:{class:`lattice-prose min-h-32 px-3 py-2 outline-none`}},onUpdate:({editor:e})=>{g(y,e.isEmpty?null:e.getJSON())},onBlur:()=>{te(y)}});if((0,no.useEffect)(()=>{fe?.setEditable(!se)},[fe,se]),u)return null;let pe=x?JSON.stringify(x):``;return(0,$.jsx)(ee,{error:a[oe],helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,labelAction:p(e.props.labelAction),label:e.props.label??``,id:ae,required:d,children:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{...e,className:re(`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`,se&&`opacity-60`),role:`group`,children:[fe&&!se&&ue.length>0&&(0,$.jsx)(Mc,{editor:fe,items:ue}),(0,$.jsx)(Ne,{editor:fe})]}),(0,$.jsx)(`input`,{name:ae,type:`hidden`,value:pe})]})})};export{Nc as default};
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=uc(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(x.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Vo(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Ho(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=Je(e.selection.$from,e=>e.type.name===`table`);return Wo(e,t&&(e=>{n&&pc(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>qo(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Jo(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=Je(e.selection.$from,e=>e.type.name===`table`);return Xo(e,t&&(e=>{n&&pc(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>ls(e,t),mergeCells:()=>({state:e,dispatch:t})=>$o(e,t),splitCell:()=>({state:e,dispatch:t})=>es(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>as(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>as(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>os(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>$o(e,t)?!0:es(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>ns(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>cs(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>cs(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Ro(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:fc,"Mod-Backspace":fc,Delete:fc,"Mod-Delete":fc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[js({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Gs({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=j(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:Be(qe(e,`tableRole`,t))}}}),bc=E.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(yc.configure(this.options.table)),this.options.tableCell!==!1&&e.push(tc.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(nc.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(rc.configure(this.options.tableRow)),e}}),xc=E.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(b(),1),Sc=[1,2,3,4,5,6],Cc=[`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`}},Tc=[`😀`,`😅`,`😂`,`🥳`,`😎`,`🤔`,`👍`,`🙏`,`🔥`,`🎉`,`🚀`,`💡`,`✅`,`❌`,`⭐`,`❤️`];function Ec(e){let t=(e??Sc).filter(e=>e>=1&&e<=6);return t.length>0?t:Sc}function Dc({editor:e,levels:t}){let{t:n}=ie(`lattice`),r=n(`form.editor.heading`,`Heading`);return(0,$.jsxs)(p,{children:[(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(_,{active:e.isActive(`heading`),icon:`heading`,label:r,testId:`editor-heading`})}),(0,$.jsx)(o,{className:`min-w-32`,children:t.map(t=>(0,$.jsx)(te,{className:re(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 Oc({editor:e}){let{t}=ie(`lattice`),[n,r]=(0,no.useState)(!1),[i,o]=(0,no.useState)(``),c=()=>{i?e.chain().focus().extendMarkRange(`link`).setLink({href:i}).run():e.chain().focus().extendMarkRange(`link`).unsetLink().run(),r(!1)};return(0,$.jsxs)(s,{onOpenChange:t=>{t&&o(e.getAttributes(`link`).href??``),r(t)},open:n,children:[(0,$.jsx)(a,{asChild:!0,children:(0,$.jsx)(_,{active:e.isActive(`link`),icon:`link`,label:t(`form.editor.link`,`Link`),testId:`editor-link`})}),(0,$.jsxs)(v,{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:i}),(0,$.jsx)(_,{icon:`check`,label:t(`form.editor.link-apply`,`Apply link`),onClick:c,testId:`editor-link-apply`}),e.isActive(`link`)&&(0,$.jsx)(_,{icon:`trash-2`,label:t(`form.editor.link-remove`,`Remove link`),onClick:()=>{e.chain().focus().extendMarkRange(`link`).unsetLink().run(),r(!1)},testId:`editor-link-remove`})]})]})}function kc({editor:e,emojis:t}){let{t:n}=ie(`lattice`),[r,i]=(0,no.useState)(!1);return(0,$.jsxs)(s,{onOpenChange:i,open:r,children:[(0,$.jsx)(a,{asChild:!0,children:(0,$.jsx)(_,{icon:`smile`,label:n(`form.editor.insert-emoji`,`Insert emoji`),testId:`editor-emoji`})}),(0,$.jsx)(v,{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(),i(!1)},onMouseDown:e=>e.preventDefault(),type:`button`,children:t},t))})]})}function Ac(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 jc={bold:{group:`marks`,starterKit:()=>({bold:{}}),toolbar:()=>[Ac(`bold`,`bold`,`Bold`,`bold`)]},italic:{group:`marks`,starterKit:()=>({italic:{}}),toolbar:()=>[Ac(`italic`,`italic`,`Italic`,`italic`)]},strike:{group:`marks`,starterKit:()=>({strike:{}}),toolbar:()=>[Ac(`strikethrough`,`strikethrough`,`Strikethrough`,`strike`)]},underline:{group:`marks`,starterKit:()=>({underline:{}}),toolbar:()=>[Ac(`underline`,`underline`,`Underline`,`underline`)]},highlight:{group:`marks`,extensions:()=>[fo],toolbar:()=>[Ac(`highlight`,`highlighter`,`Highlight`,`highlight`)]},code:{group:`marks`,starterKit:()=>({code:{}}),toolbar:()=>[Ac(`code`,`code-xml`,`Code`,`code`)]},heading:{starterKit:e=>({heading:{levels:Ec(e.levels)}}),toolbar:e=>{let t=Ec(e.levels);return[{key:`heading`,component:({editor:e})=>(0,$.jsx)(Dc,{editor:e,levels:t})}]}},"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()}]},"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()}]},blockquote:{group:`blocks`,starterKit:()=>({blockquote:{}}),toolbar:()=>[{icon:`quote`,key:`blockquote`,label:`Blockquote`,isActive:e=>e.isActive(`blockquote`),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()}]},"horizontal-rule":{group:`blocks`,starterKit:()=>({horizontalRule:{}}),toolbar:()=>[{icon:`minus`,key:`horizontal-rule`,label:`Horizontal rule`,isActive:()=>!1,run:e=>e.chain().focus().setHorizontalRule().run()}]},"text-align":{extensions:e=>[xc.configure({alignments:e.alignments??Cc,types:[`heading`,`paragraph`]})],toolbar:e=>(e.alignments??Cc).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)(Oc,{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()}]},details:{group:`insert`,extensions:()=>[oo,co,so],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()}}]},emoji:{toolbar:e=>{let t=e.emojis??Tc;return[{key:`insert-emoji`,component:({editor:e})=>(0,$.jsx)(kc,{editor:e,emojis:t})}]}}};function Mc({editor:e,items:t}){let{t:n}=ie(`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)(_,{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 Nc=({node:e})=>{let t=ne(c),{errors:a}=g(),{hidden:o,required:s,readOnly:p,disabled:_}=u(e),{change:te,blur:v}=n(),y=e.props.name,b=r(),ie=i(y),x=b?b.getValue(y):ie,ae=b?b.scopedName(y):y,oe=b?b.errorKey(y):y,se=p||_,ce=typeof x==`object`&&x?x:e.props.value??``,le=(0,no.useMemo)(()=>d(e.props.extensions,{...jc,...t}),[t,e.props.extensions]),ue=(0,no.useMemo)(()=>l(le),[le]),de=(0,no.useMemo)(()=>[to.configure(m(le)),Xt.configure({placeholder:e.props.placeholder??``}),...ee(le)],[le,e.props.placeholder]),fe=He({extensions:de,content:ce,editable:!se,immediatelyRender:!1,shouldRerenderOnTransaction:!0,editorProps:{attributes:{class:`lattice-prose min-h-32 px-3 py-2 outline-none`}},onUpdate:({editor:e})=>{te(y,e.isEmpty?null:e.getJSON())},onBlur:()=>{v(y)}});if((0,no.useEffect)(()=>{fe?.setEditable(!se)},[fe,se]),o)return null;let pe=x?JSON.stringify(x):``;return(0,$.jsx)(h,{error:a[oe],helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,labelAction:f(e.props.labelAction),label:e.props.label??``,id:ae,required:s,children:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{...e,className:re(`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`,se&&`opacity-60`),role:`group`,children:[fe&&!se&&ue.length>0&&(0,$.jsx)(Mc,{editor:fe,items:ue}),(0,$.jsx)(Ne,{editor:fe})]}),(0,$.jsx)(`input`,{name:ae,type:`hidden`,value:pe})]})})};export{Nc as default};