@storyblok/js 5.1.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +1 -1
- package/package.json +2 -2
package/dist/storyblok-js.js
CHANGED
|
@@ -40,7 +40,7 @@ ${d.slice(p+2)}`,m+=1;else break}e.push({indent:p,number:parseInt(r,10),content:
|
|
|
40
40
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),o=e==null?void 0:e.index;return o!==void 0?o:-1},tokenize:(t,e,o)=>{var a;const n=t.split(`
|
|
41
41
|
`),[s,i]=xd(n);if(s.length===0)return;const r=ol(s,0,o);return r.length===0?void 0:{type:"list",ordered:!0,start:((a=s[0])==null?void 0:a.number)||1,items:r,raw:n.slice(0,i).join(`
|
|
42
42
|
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Td,this.editor.getAttributes(al)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ct({find:nl,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,o)=>o.childCount+o.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ct({find:nl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(al)}),joinPredicate:(e,o)=>o.childCount+o.attrs.start===+e[1],editor:this.editor})),[t]}}),Md=/^\s*(\[([( |x])?\])\s$/,Bd=K.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:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",R(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const o=[];if(t.tokens&&t.tokens.length>0?o.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?o.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):o.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const a=e.parseChildren(t.nestedTokens);o.push(...a)}return e.createNode("taskItem",{checked:t.checked||!1},o)},renderMarkdown:(t,e)=>{var o;const n=`- [${(o=t.attrs)!=null&&o.checked?"x":" "}] `;return Ln(t,e,n)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:o,editor:a})=>{const n=document.createElement("li"),s=document.createElement("label"),i=document.createElement("span"),r=document.createElement("input"),l=document.createElement("div"),p=m=>{var u,d;r.ariaLabel=((d=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:d.call(u,m,r.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};p(t),s.contentEditable="false",r.type="checkbox",r.addEventListener("mousedown",m=>m.preventDefault()),r.addEventListener("change",m=>{if(!a.isEditable&&!this.options.onReadOnlyChecked){r.checked=!r.checked;return}const{checked:u}=m.target;a.isEditable&&typeof o=="function"&&a.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const g=o();if(typeof g!="number")return!1;const f=d.doc.nodeAt(g);return d.setNodeMarkup(g,void 0,{...f==null?void 0:f.attrs,checked:u}),!0}).run(),!a.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,u)||(r.checked=!r.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,u])=>{n.setAttribute(m,u)}),n.dataset.checked=t.attrs.checked,r.checked=t.attrs.checked,s.append(r,i),n.append(s,l),Object.entries(e).forEach(([m,u])=>{n.setAttribute(m,u)});let c=new Set(Object.keys(e));return{dom:n,contentDOM:l,update:m=>{if(m.type!==this.type)return!1;n.dataset.checked=m.attrs.checked,r.checked=m.attrs.checked,p(m);const u=a.extensionManager.attributes,d=Du(m,u),g=new Set(Object.keys(d)),f=this.options.HTMLAttributes;return c.forEach(h=>{g.has(h)||(h in f?n.setAttribute(h,f[h]):n.removeAttribute(h))}),Object.entries(d).forEach(([h,b])=>{b==null?h in f?n.setAttribute(h,f[h]):n.removeAttribute(h):n.setAttribute(h,b)}),c=g,!0}}}},addInputRules(){return[Ct({find:Md,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Rd=K.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",R(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
43
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const o=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return o!==void 0?o:-1},tokenize(t,e,o){const a=s=>{const i=Rn(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:r=>({indentLevel:r[1].length,mainContent:r[4],checked:r[3].toLowerCase()==="x"}),createToken:(r,l)=>({type:"taskItem",raw:"",mainContent:r.mainContent,indentLevel:r.indentLevel,checked:r.checked,text:r.mainContent,tokens:o.inlineTokens(r.mainContent),nestedTokens:l}),customNestedParser:a},o);return i?[{type:"taskList",raw:i.raw,items:i.items}]:o.blockTokens(s)},n=Rn(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,i)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:o.inlineTokens(s.mainContent),nestedTokens:i}),customNestedParser:a},o);if(n)return{type:"taskList",raw:n.raw,items:n.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ee.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Jr.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Gr.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Ed.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(sl.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Bd.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Rd.configure(this.options.taskList)),t}});class ae extends x{constructor(e){super(e,e)}map(e,o){let a=e.resolve(o.map(this.head));return ae.valid(a)?new ae(a):x.near(a)}content(){return F.empty}eq(e){return e instanceof ae&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,o){if(typeof o.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ae(e.resolve(o.pos))}getBookmark(){return new $n(this.anchor)}static valid(e){let o=e.parent;if(o.isTextblock||!Ld(e)||!Nd(e))return!1;let a=o.type.spec.allowGapCursor;if(a!=null)return a;let n=o.contentMatchAt(e.index()).defaultType;return n&&n.isTextblock}static findGapCursorFrom(e,o,a=!1){e:for(;;){if(!a&&ae.valid(e))return e;let n=e.pos,s=null;for(let i=e.depth;;i--){let r=e.node(i);if(o>0?e.indexAfter(i)<r.childCount:e.index(i)>0){s=r.child(o>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;n+=o;let l=e.doc.resolve(n);if(ae.valid(l))return l}for(;;){let i=o>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!C.isSelectable(s)){e=e.doc.resolve(n+s.nodeSize*o),a=!1;continue e}break}s=i,n+=o;let r=e.doc.resolve(n);if(ae.valid(r))return r}return null}}}ae.prototype.visible=!1,ae.findFrom=ae.findGapCursorFrom,x.jsonID("gapcursor",ae);class $n{constructor(e){this.pos=e}map(e){return new $n(e.map(this.pos))}resolve(e){let o=e.resolve(this.pos);return ae.valid(o)?new ae(o):x.near(o)}}function il(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Ld(t){for(let e=t.depth;e>=0;e--){let o=t.index(e),a=t.node(e);if(o==0){if(a.type.spec.isolating)return!0;continue}for(let n=a.child(o-1);;n=n.lastChild){if(n.childCount==0&&!n.inlineContent||il(n.type))return!0;if(n.inlineContent)return!1}}return!0}function Nd(t){for(let e=t.depth;e>=0;e--){let o=t.indexAfter(e),a=t.node(e);if(o==a.childCount){if(a.type.spec.isolating)return!0;continue}for(let n=a.child(o);;n=n.firstChild){if(n.childCount==0&&!n.inlineContent||il(n.type))return!0;if(n.inlineContent)return!1}}return!0}wr({ArrowLeft:Po("horiz",-1),ArrowRight:Po("horiz",1),ArrowUp:Po("vert",-1),ArrowDown:Po("vert",1)});function Po(t,e){const o=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(a,n,s){let i=a.selection,r=e>0?i.$to:i.$from,l=i.empty;if(i instanceof E){if(!s.endOfTextblock(o)||r.depth==0)return!1;l=!1,r=a.doc.resolve(e>0?r.after():r.before())}let p=ae.findGapCursorFrom(r,e,l);return p?(n&&n(a.tr.setSelection(new ae(p))),!0):!1}}var Ho=(t,e)=>e.view.domAtPos(t).node.offsetParent!==null,zd=(t,e,o)=>{for(let a=t.depth;a>0;a-=1){const n=t.node(a),s=e(n),i=Ho(t.start(a),o);if(s&&i)return{pos:a>0?t.before(a):0,start:t.start(a),depth:a,node:n}}},rl=(t,e)=>{const{state:o,view:a,extensionManager:n}=t,{schema:s,selection:i}=o,{empty:r,$anchor:l}=i,p=!!n.extensions.find(b=>b.name==="gapCursor");if(!r||l.parent.type!==s.nodes.detailsSummary||!p||e==="right"&&l.parentOffset!==l.parent.nodeSize-2)return!1;const c=mt(b=>b.type===s.nodes.details)(i);if(!c)return!1;const m=No(c.node,b=>b.type===s.nodes.detailsContent);if(!m.length||Ho(c.start+m[0].pos+1,t))return!1;const d=o.doc.resolve(c.pos+c.node.nodeSize),g=ae.findFrom(d,1,!1);if(!g)return!1;const{tr:f}=o,h=new ae(g);return f.setSelection(h),f.scrollIntoView(),a.dispatch(f),!0},Od=K.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:"is-open",HTMLAttributes:{}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:({open:t})=>t?{open:""}:{}}}:[]},parseHTML(){return[{tag:"details"}]},renderHTML({HTMLAttributes:t}){return["details",R(this.options.HTMLAttributes,t),0]},...$o({nodeName:"details",content:"block"}),addNodeView(){return({editor:t,getPos:e,node:o,HTMLAttributes:a})=>{const n=document.createElement("div"),s=R(this.options.HTMLAttributes,a,{"data-type":this.name});Object.entries(s).forEach(([p,c])=>n.setAttribute(p,c));const i=document.createElement("button");i.type="button",n.append(i);const r=document.createElement("div");n.append(r);const l=p=>{if(p!==void 0)if(p){if(n.classList.contains(this.options.openClassName))return;n.classList.add(this.options.openClassName)}else{if(!n.classList.contains(this.options.openClassName))return;n.classList.remove(this.options.openClassName)}else n.classList.toggle(this.options.openClassName);const c=new Event("toggleDetailsContent"),m=r.querySelector(':scope > div[data-type="detailsContent"]');m==null||m.dispatchEvent(c)};return o.attrs.open&&setTimeout(()=>l()),i.addEventListener("click",()=>{if(l(),!this.options.persist){t.commands.focus(void 0,{scrollIntoView:!1});return}if(t.isEditable&&typeof e=="function"){const{from:p,to:c}=t.state.selection;t.chain().command(({tr:m})=>{const u=e();if(!u)return!1;const d=m.doc.nodeAt(u);return(d==null?void 0:d.type)!==this.type?!1:(m.setNodeMarkup(u,void 0,{open:!d.attrs.open}),!0)}).setTextSelection({from:p,to:c}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:n,contentDOM:r,ignoreMutation(p){return p.type==="selection"?!1:!n.contains(p.target)||n===p.target},update:p=>p.type!==this.type?!1:(p.attrs.open!==void 0&&l(p.attrs.open),!0)}}},addCommands(){return{setDetails:()=>({state:t,chain:e})=>{var o;const{schema:a,selection:n}=t,{$from:s,$to:i}=n,r=s.blockRange(i);if(!r)return!1;const l=t.doc.slice(r.start,r.end);if(!a.nodes.detailsContent.contentMatch.matchFragment(l.content))return!1;const c=((o=l.toJSON())==null?void 0:o.content)||[];return e().insertContentAt({from:r.start,to:r.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:c}]}).setTextSelection(r.start+2).run()},unsetDetails:()=>({state:t,chain:e})=>{const{selection:o,schema:a}=t,n=mt(b=>b.type===this.type)(o);if(!n)return!1;const s=No(n.node,b=>b.type===a.nodes.detailsSummary),i=No(n.node,b=>b.type===a.nodes.detailsContent);if(!s.length||!i.length)return!1;const r=s[0],l=i[0],p=n.pos,c=t.doc.resolve(p),m=p+n.node.nodeSize,u={from:p,to:m},d=l.node.content.toJSON()||[],g=c.parent.type.contentMatch.defaultType,h=[g==null?void 0:g.create(null,r.node.content).toJSON(),...d];return e().insertContentAt(u,h).setTextSelection(p+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{const{schema:t,selection:e}=this.editor.state,{empty:o,$anchor:a}=e;return!o||a.parent.type!==t.nodes.detailsSummary?!1:a.parentOffset!==0?this.editor.commands.command(({tr:n})=>{const s=a.pos-1,i=a.pos;return n.delete(s,i),!0}):this.editor.commands.unsetDetails()},Enter:({editor:t})=>{const{state:e,view:o}=t,{schema:a,selection:n}=e,{$head:s}=n;if(s.parent.type!==a.nodes.detailsSummary)return!1;const i=Ho(s.after()+1,t),r=i?e.doc.nodeAt(s.after()):s.node(-2);if(!r)return!1;const l=i?0:s.indexAfter(-1),p=Dn(r.contentMatchAt(l));if(!p||!r.canReplaceWith(l,l,p))return!1;const c=p.createAndFill();if(!c)return!1;const m=i?s.after()+1:s.after(-1),u=e.tr.replaceWith(m,m,c),d=u.doc.resolve(m),g=x.near(d,1);return u.setSelection(g),u.scrollIntoView(),o.dispatch(u),!0},ArrowRight:({editor:t})=>rl(t,"right"),ArrowDown:({editor:t})=>rl(t,"down")}},addProseMirrorPlugins(){return[new se({key:new Q("detailsSelection"),appendTransaction:(t,e,o)=>{const{editor:a,type:n}=this;if(a.view.composing||!t.some(b=>b.selectionSet)||!e.selection.empty||!o.selection.empty||!Tu(o,n.name))return;const{$from:l}=o.selection;if(Ho(l.pos,a))return;const c=zd(l,b=>b.type===n,a);if(!c)return;const m=No(c.node,b=>b.type===o.schema.nodes.detailsSummary);if(!m.length)return;const u=m[0],g=(e.selection.from<o.selection.from?"forward":"backward")==="forward"?c.start+u.pos:c.pos+u.pos+u.node.nodeSize,f=E.create(o.doc,g);return o.tr.setSelection(f)}})]}}),$d=K.create({name:"detailsContent",content:"block+",defining:!0,selectable:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",R(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:t})=>{const e=document.createElement("div"),o=R(this.options.HTMLAttributes,t,{"data-type":this.name,hidden:"hidden"});return Object.entries(o).forEach(([a,n])=>e.setAttribute(a,n)),e.addEventListener("toggleDetailsContent",()=>{e.toggleAttribute("hidden")}),{dom:e,contentDOM:e,ignoreMutation(a){return a.type==="selection"?!1:!e.contains(a.target)||e===a.target},update:a=>a.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{state:e,view:o}=t,{selection:a}=e,{$from:n,empty:s}=a,i=mt(T=>T.type===this.type)(a);if(!s||!i||!i.node.childCount)return!1;const r=n.index(i.depth),{childCount:l}=i.node;if(!(l===r+1))return!1;const c=i.node.type.contentMatch.defaultType,m=c==null?void 0:c.createAndFill();if(!m)return!1;const u=e.doc.resolve(i.pos+1),d=l-1,g=i.node.child(d),f=u.posAtIndex(d,i.depth);if(!g.eq(m))return!1;const b=n.node(-3);if(!b)return!1;const j=n.indexAfter(-3),D=Dn(b.contentMatchAt(j));if(!D||!b.canReplaceWith(j,j,D))return!1;const w=D.createAndFill();if(!w)return!1;const{tr:y}=e,I=n.after(-2);y.replaceWith(I,I,w);const _=y.doc.resolve(I),A=x.near(_,1);y.setSelection(A);const B=f,L=f+g.nodeSize;return y.delete(B,L),y.scrollIntoView(),o.dispatch(y),!0}}},...$o({nodeName:"detailsContent"})}),Pd=K.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:t}){return["summary",R(this.options.HTMLAttributes,t),0]},...$o({nodeName:"detailsSummary",content:"inline"})});let Pn,Hn;if(typeof WeakMap<"u"){let t=new WeakMap;Pn=e=>t.get(e),Hn=(e,o)=>(t.set(e,o),o)}else{const t=[];let o=0;Pn=a=>{for(let n=0;n<t.length;n+=2)if(t[n]==a)return t[n+1]},Hn=(a,n)=>(o==10&&(o=0),t[o++]=a,t[o++]=n)}var J=class{constructor(t,e,o,a){this.width=t,this.height=e,this.map=o,this.problems=a}findCell(t){for(let e=0;e<this.map.length;e++){const o=this.map[e];if(o!=t)continue;const a=e%this.width,n=e/this.width|0;let s=a+1,i=n+1;for(let r=1;s<this.width&&this.map[e+r]==o;r++)s++;for(let r=1;i<this.height&&this.map[e+this.width*r]==o;r++)i++;return{left:a,top:n,right:s,bottom:i}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,o){const{left:a,right:n,top:s,bottom:i}=this.findCell(t);return e=="horiz"?(o<0?a==0:n==this.width)?null:this.map[s*this.width+(o<0?a-1:n)]:(o<0?s==0:i==this.height)?null:this.map[a+this.width*(o<0?s-1:i)]}rectBetween(t,e){const{left:o,right:a,top:n,bottom:s}=this.findCell(t),{left:i,right:r,top:l,bottom:p}=this.findCell(e);return{left:Math.min(o,i),top:Math.min(n,l),right:Math.max(a,r),bottom:Math.max(s,p)}}cellsInRect(t){const e=[],o={};for(let a=t.top;a<t.bottom;a++)for(let n=t.left;n<t.right;n++){const s=a*this.width+n,i=this.map[s];o[i]||(o[i]=!0,!(n==t.left&&n&&this.map[s-1]==i||a==t.top&&a&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(t,e,o){for(let a=0,n=0;;a++){const s=n+o.child(a).nodeSize;if(a==t){let i=e+t*this.width;const r=(t+1)*this.width;for(;i<r&&this.map[i]<n;)i++;return i==r?s-1:this.map[i]}n=s}}static get(t){return Pn(t)||Hn(t,Hd(t))}};function Hd(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=qd(t),o=t.childCount,a=[];let n=0,s=null;const i=[];for(let p=0,c=e*o;p<c;p++)a[p]=0;for(let p=0,c=0;p<o;p++){const m=t.child(p);c++;for(let g=0;;g++){for(;n<a.length&&a[n]!=0;)n++;if(g==m.childCount)break;const f=m.child(g),{colspan:h,rowspan:b,colwidth:j}=f.attrs;for(let D=0;D<b;D++){if(D+p>=o){(s||(s=[])).push({type:"overlong_rowspan",pos:c,n:b-D});break}const w=n+D*e;for(let y=0;y<h;y++){a[w+y]==0?a[w+y]=c:(s||(s=[])).push({type:"collision",row:p,pos:c,n:h-y});const I=j&&j[y];if(I){const _=(w+y)%e*2,A=i[_];A==null||A!=I&&i[_+1]==1?(i[_]=I,i[_+1]=1):A==I&&i[_+1]++}}}n+=h,c+=f.nodeSize}const u=(p+1)*e;let d=0;for(;n<u;)a[n++]==0&&d++;d&&(s||(s=[])).push({type:"missing",row:p,n:d}),c++}(e===0||o===0)&&(s||(s=[])).push({type:"zero_sized"});const r=new J(e,o,a,s);let l=!1;for(let p=0;!l&&p<i.length;p+=2)i[p]!=null&&i[p+1]<o&&(l=!0);return l&&Wd(r,i,t),r}function qd(t){let e=-1,o=!1;for(let a=0;a<t.childCount;a++){const n=t.child(a);let s=0;if(o)for(let i=0;i<a;i++){const r=t.child(i);for(let l=0;l<r.childCount;l++){const p=r.child(l);i+p.attrs.rowspan>a&&(s+=p.attrs.colspan)}}for(let i=0;i<n.childCount;i++){const r=n.child(i);s+=r.attrs.colspan,r.attrs.rowspan>1&&(o=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function Wd(t,e,o){t.problems||(t.problems=[]);const a={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(a[s])continue;a[s]=!0;const i=o.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let r=null;const l=i.attrs;for(let p=0;p<l.colspan;p++){const c=e[(n+p)%t.width*2];c!=null&&(!l.colwidth||l.colwidth[p]!=c)&&((r||(r=Ud(l)))[p]=c)}r&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:r})}}function Ud(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let o=0;o<t.colspan;o++)e.push(0);return e}function le(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const o in t.nodes){const a=t.nodes[o],n=a.spec.tableRole;n&&(e[n]=a)}}return e}const Je=new Q("selectingCells");function dt(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Kd(t){for(let e=t.depth;e>0;e--){const o=t.node(e).type.spec.tableRole;if(o==="cell"||o==="header_cell")return t.node(e)}return null}function _e(t){const e=t.selection.$head;for(let o=e.depth;o>0;o--)if(e.node(o).type.spec.tableRole=="row")return!0;return!1}function qo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const o=dt(e.$head)||Vd(e.$head);if(o)return o;throw new RangeError(`No cell found around position ${e.head}`)}function Vd(t){for(let e=t.nodeAfter,o=t.pos;e;e=e.firstChild,o++){const a=e.type.spec.tableRole;if(a=="cell"||a=="header_cell")return t.doc.resolve(o)}for(let e=t.nodeBefore,o=t.pos;e;e=e.lastChild,o--){const a=e.type.spec.tableRole;if(a=="cell"||a=="header_cell")return t.doc.resolve(o-e.nodeSize)}}function qn(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Jd(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Wn(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function ll(t,e,o){const a=t.node(-1),n=J.get(a),s=t.start(-1),i=n.nextCell(t.pos-s,e,o);return i==null?null:t.node(0).resolve(s+i)}function gt(t,e,o=1){const a={...t,colspan:t.colspan-o};return a.colwidth&&(a.colwidth=a.colwidth.slice(),a.colwidth.splice(e,o),a.colwidth.some(n=>n>0)||(a.colwidth=null)),a}function pl(t,e,o=1){const a={...t,colspan:t.colspan+o};if(a.colwidth){a.colwidth=a.colwidth.slice();for(let n=0;n<o;n++)a.colwidth.splice(e,0,0)}return a}function Gd(t,e,o){const a=le(e.type.schema).header_cell;for(let n=0;n<t.height;n++)if(e.nodeAt(t.map[o+n*t.width]).type!=a)return!1;return!0}var P=class Le extends x{constructor(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),i=n.rectBetween(e.pos-s,o.pos-s),r=e.node(0),l=n.cellsInRect(i).filter(c=>c!=o.pos-s);l.unshift(o.pos-s);const p=l.map(c=>{const m=a.nodeAt(c);if(!m)throw new RangeError(`No cell with offset ${c} found`);const u=s+c+1;return new ki(r.resolve(u),r.resolve(u+m.content.size))});super(p[0].$from,p[0].$to,p),this.$anchorCell=e,this.$headCell=o}map(e,o){const a=e.resolve(o.map(this.$anchorCell.pos)),n=e.resolve(o.map(this.$headCell.pos));if(qn(a)&&qn(n)&&Wn(a,n)){const s=this.$anchorCell.node(-1)!=a.node(-1);return s&&this.isRowSelection()?Le.rowSelection(a,n):s&&this.isColSelection()?Le.colSelection(a,n):new Le(a,n)}return E.between(a,n)}content(){const e=this.$anchorCell.node(-1),o=J.get(e),a=this.$anchorCell.start(-1),n=o.rectBetween(this.$anchorCell.pos-a,this.$headCell.pos-a),s={},i=[];for(let l=n.top;l<n.bottom;l++){const p=[];for(let c=l*o.width+n.left,m=n.left;m<n.right;m++,c++){const u=o.map[c];if(s[u])continue;s[u]=!0;const d=o.findCell(u);let g=e.nodeAt(u);if(!g)throw new RangeError(`No cell with offset ${u} found`);const f=n.left-d.left,h=d.right-n.right;if(f>0||h>0){let b=g.attrs;if(f>0&&(b=gt(b,0,f)),h>0&&(b=gt(b,b.colspan-h,h)),d.left<n.left){if(g=g.type.createAndFill(b),!g)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else g=g.type.create(b,g.content)}if(d.top<n.top||d.bottom>n.bottom){const b={...g.attrs,rowspan:Math.min(d.bottom,n.bottom)-Math.max(d.top,n.top)};d.top<n.top?g=g.type.createAndFill(b):g=g.type.create(b,g.content)}p.push(g)}i.push(e.child(l).copy(v.from(p)))}const r=this.isColSelection()&&this.isRowSelection()?e:i;return new F(v.from(r),1,1)}replace(e,o=F.empty){const a=e.steps.length,n=this.ranges;for(let i=0;i<n.length;i++){const{$from:r,$to:l}=n[i],p=e.mapping.slice(a);e.replace(p.map(r.pos),p.map(l.pos),i?F.empty:o)}const s=x.findFrom(e.doc.resolve(e.mapping.slice(a).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,o){this.replace(e,new F(v.from(o),0,0))}forEachCell(e){const o=this.$anchorCell.node(-1),a=J.get(o),n=this.$anchorCell.start(-1),s=a.cellsInRect(a.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n));for(let i=0;i<s.length;i++)e(o.nodeAt(s[i]),n+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),o=this.$headCell.index(-1);if(Math.min(e,o)>0)return!1;const a=e+this.$anchorCell.nodeAfter.attrs.rowspan,n=o+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(a,n)==this.$headCell.node(-1).childCount}static colSelection(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),i=n.findCell(e.pos-s),r=n.findCell(o.pos-s),l=e.node(0);return i.top<=r.top?(i.top>0&&(e=l.resolve(s+n.map[i.left])),r.bottom<n.height&&(o=l.resolve(s+n.map[n.width*(n.height-1)+r.right-1]))):(r.top>0&&(o=l.resolve(s+n.map[r.left])),i.bottom<n.height&&(e=l.resolve(s+n.map[n.width*(n.height-1)+i.right-1]))),new Le(e,o)}isRowSelection(){const e=this.$anchorCell.node(-1),o=J.get(e),a=this.$anchorCell.start(-1),n=o.colCount(this.$anchorCell.pos-a),s=o.colCount(this.$headCell.pos-a);if(Math.min(n,s)>0)return!1;const i=n+this.$anchorCell.nodeAfter.attrs.colspan,r=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,r)==o.width}eq(e){return e instanceof Le&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),i=n.findCell(e.pos-s),r=n.findCell(o.pos-s),l=e.node(0);return i.left<=r.left?(i.left>0&&(e=l.resolve(s+n.map[i.top*n.width])),r.right<n.width&&(o=l.resolve(s+n.map[n.width*(r.top+1)-1]))):(r.left>0&&(o=l.resolve(s+n.map[r.top*n.width])),i.right<n.width&&(e=l.resolve(s+n.map[n.width*(i.top+1)-1]))),new Le(e,o)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,o){return new Le(e.resolve(o.anchor),e.resolve(o.head))}static create(e,o,a=o){return new Le(e.resolve(o),e.resolve(a))}getBookmark(){return new Xd(this.$anchorCell.pos,this.$headCell.pos)}};P.prototype.visible=!1,x.jsonID("cell",P);var Xd=class vp{constructor(e,o){this.anchor=e,this.head=o}map(e){return new vp(e.map(this.anchor),e.map(this.head))}resolve(e){const o=e.resolve(this.anchor),a=e.resolve(this.head);return o.parent.type.spec.tableRole=="row"&&a.parent.type.spec.tableRole=="row"&&o.index()<o.parent.childCount&&a.index()<a.parent.childCount&&Wn(o,a)?new P(o,a):x.near(a,1)}};function Yd(t){if(!(t.selection instanceof P))return null;const e=[];return t.selection.forEachCell((o,a)=>{e.push(he.node(a,a+o.nodeSize,{class:"selectedCell"}))}),X.create(t.doc,e)}function Qd({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let o=t.pos,a=e.pos,n=t.depth;for(;n>=0&&!(t.after(n+1)<t.end(n));n--,o++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,a--);return o==a&&/row|table/.test(t.node(n).type.spec.tableRole)}function Zd({$from:t,$to:e}){let o,a;for(let n=t.depth;n>0;n--){const s=t.node(n);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){o=s;break}}for(let n=e.depth;n>0;n--){const s=e.node(n);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){a=s;break}}return o!==a&&e.parentOffset===0}function eg(t,e,o){const a=(e||t).selection,n=(e||t).doc;let s,i;if(a instanceof C&&(i=a.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=P.create(n,a.from);else if(i=="row"){const r=n.resolve(a.from+1);s=P.rowSelection(r,r)}else if(!o){const r=J.get(a.node),l=a.from+1,p=l+r.map[r.width*r.height-1];s=P.create(n,l+1,p)}}else a instanceof E&&Qd(a)?s=E.create(n,a.from):a instanceof E&&Zd(a)&&(s=E.create(n,a.$from.start(),a.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}const tg=new Q("fix-tables");function cl(t,e,o,a){const n=t.childCount,s=e.childCount;e:for(let i=0,r=0;i<s;i++){const l=e.child(i);for(let p=r,c=Math.min(n,i+3);p<c;p++)if(t.child(p)==l){r=p+1,o+=l.nodeSize;continue e}a(l,o),r<n&&t.child(r).sameMarkup(l)?cl(t.child(r),l,o+1,a):l.nodesBetween(0,l.content.size,a,o+1),o+=l.nodeSize}}function ml(t,e){let o;const a=(n,s)=>{n.type.spec.tableRole=="table"&&(o=og(t,n,s,o))};return e?e.doc!=t.doc&&cl(e.doc,t.doc,0,a):t.doc.descendants(a),o}function og(t,e,o,a){const n=J.get(e);if(!n.problems)return a;a||(a=t.tr);const s=[];for(let l=0;l<n.height;l++)s.push(0);for(let l=0;l<n.problems.length;l++){const p=n.problems[l];if(p.type=="collision"){const c=e.nodeAt(p.pos);if(!c)continue;const m=c.attrs;for(let u=0;u<m.rowspan;u++)s[p.row+u]+=p.n;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,gt(m,m.colspan-p.n,p.n))}else if(p.type=="missing")s[p.row]+=p.n;else if(p.type=="overlong_rowspan"){const c=e.nodeAt(p.pos);if(!c)continue;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,{...c.attrs,rowspan:c.attrs.rowspan-p.n})}else if(p.type=="colwidth mismatch"){const c=e.nodeAt(p.pos);if(!c)continue;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,{...c.attrs,colwidth:p.colwidth})}else if(p.type=="zero_sized"){const c=a.mapping.map(o);a.delete(c,c+e.nodeSize)}}let i,r;for(let l=0;l<s.length;l++)s[l]&&(i==null&&(i=l),r=l);for(let l=0,p=o+1;l<n.height;l++){const c=e.child(l),m=p+c.nodeSize,u=s[l];if(u>0){let d="cell";c.firstChild&&(d=c.firstChild.type.spec.tableRole);const g=[];for(let h=0;h<u;h++){const b=le(t.schema)[d].createAndFill();b&&g.push(b)}const f=(l==0||i==l-1)&&r==l?p+1:m-1;a.insert(a.mapping.map(f),g)}p=m}return a.setMeta(tg,{fixTables:!0})}function Ie(t){const e=t.selection,o=qo(t),a=o.node(-1),n=o.start(-1),s=J.get(a);return{...e instanceof P?s.rectBetween(e.$anchorCell.pos-n,e.$headCell.pos-n):s.findCell(o.pos-n),tableStart:n,map:s,table:a}}function ul(t,{map:e,tableStart:o,table:a},n){let s=n>0?-1:0;Gd(e,a,n+s)&&(s=n==0||n==e.width?null:0);for(let i=0;i<e.height;i++){const r=i*e.width+n;if(n>0&&n<e.width&&e.map[r-1]==e.map[r]){const l=e.map[r],p=a.nodeAt(l);t.setNodeMarkup(t.mapping.map(o+l),null,pl(p.attrs,n-e.colCount(l))),i+=p.attrs.rowspan-1}else{const l=s==null?le(a.type.schema).cell:a.nodeAt(e.map[r+s]).type,p=e.positionAt(i,n,a);t.insert(t.mapping.map(o+p),l.createAndFill())}}return t}function ag(t,e){if(!_e(t))return!1;if(e){const o=Ie(t);e(ul(t.tr,o,o.left))}return!0}function ng(t,e){if(!_e(t))return!1;if(e){const o=Ie(t);e(ul(t.tr,o,o.right))}return!0}function sg(t,{map:e,table:o,tableStart:a},n){const s=t.mapping.maps.length;for(let i=0;i<e.height;){const r=i*e.width+n,l=e.map[r],p=o.nodeAt(l),c=p.attrs;if(n>0&&e.map[r-1]==l||n<e.width-1&&e.map[r+1]==l)t.setNodeMarkup(t.mapping.slice(s).map(a+l),null,gt(c,n-e.colCount(l)));else{const m=t.mapping.slice(s).map(a+l);t.delete(m,m+p.nodeSize)}i+=c.rowspan}}function ig(t,e){if(!_e(t))return!1;if(e){const o=Ie(t),a=t.tr;if(o.left==0&&o.right==o.map.width)return!1;for(let n=o.right-1;sg(a,o,n),n!=o.left;n--){const s=o.tableStart?a.doc.nodeAt(o.tableStart-1):a.doc;if(!s)throw new RangeError("No table found");o.table=s,o.map=J.get(s)}e(a)}return!0}function rg(t,e,o){var a;const n=le(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((a=e.nodeAt(t.map[s+o*t.width]))===null||a===void 0?void 0:a.type)!=n)return!1;return!0}function dl(t,{map:e,tableStart:o,table:a},n){let s=o;for(let p=0;p<n;p++)s+=a.child(p).nodeSize;const i=[];let r=n>0?-1:0;rg(e,a,n+r)&&(r=n==0||n==e.height?null:0);for(let p=0,c=e.width*n;p<e.width;p++,c++)if(n>0&&n<e.height&&e.map[c]==e.map[c-e.width]){const m=e.map[c],u=a.nodeAt(m).attrs;t.setNodeMarkup(o+m,null,{...u,rowspan:u.rowspan+1}),p+=u.colspan-1}else{var l;const m=r==null?le(a.type.schema).cell:(l=a.nodeAt(e.map[c+r*e.width]))===null||l===void 0?void 0:l.type,u=m==null?void 0:m.createAndFill();u&&i.push(u)}return t.insert(s,le(a.type.schema).row.create(null,i)),t}function lg(t,e){if(!_e(t))return!1;if(e){const o=Ie(t);e(dl(t.tr,o,o.top))}return!0}function pg(t,e){if(!_e(t))return!1;if(e){const o=Ie(t);e(dl(t.tr,o,o.bottom))}return!0}function cg(t,{map:e,table:o,tableStart:a},n){let s=0;for(let p=0;p<n;p++)s+=o.child(p).nodeSize;const i=s+o.child(n).nodeSize,r=t.mapping.maps.length;t.delete(s+a,i+a);const l=new Set;for(let p=0,c=n*e.width;p<e.width;p++,c++){const m=e.map[c];if(!l.has(m)){if(l.add(m),n>0&&m==e.map[c-e.width]){const u=o.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(r).map(m+a),null,{...u,rowspan:u.rowspan-1}),p+=u.colspan-1}else if(n<e.height&&m==e.map[c+e.width]){const u=o.nodeAt(m),d=u.attrs,g=u.type.create({...d,rowspan:u.attrs.rowspan-1},u.content),f=e.positionAt(n+1,p,o);t.insert(t.mapping.slice(r).map(a+f),g),p+=d.colspan-1}}}}function mg(t,e){if(!_e(t))return!1;if(e){const o=Ie(t),a=t.tr;if(o.top==0&&o.bottom==o.map.height)return!1;for(let n=o.bottom-1;cg(a,o,n),n!=o.top;n--){const s=o.tableStart?a.doc.nodeAt(o.tableStart-1):a.doc;if(!s)throw new RangeError("No table found");o.table=s,o.map=J.get(o.table)}e(a)}return!0}function gl(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function ug({width:t,height:e,map:o},a){let n=a.top*t+a.left,s=n,i=(a.bottom-1)*t+a.left,r=n+(a.right-a.left-1);for(let l=a.top;l<a.bottom;l++){if(a.left>0&&o[s]==o[s-1]||a.right<t&&o[r]==o[r+1])return!0;s+=t,r+=t}for(let l=a.left;l<a.right;l++){if(a.top>0&&o[n]==o[n-t]||a.bottom<e&&o[i]==o[i+t])return!0;n++,i++}return!1}function fl(t,e){const o=t.selection;if(!(o instanceof P)||o.$anchorCell.pos==o.$headCell.pos)return!1;const a=Ie(t),{map:n}=a;if(ug(n,a))return!1;if(e){const s=t.tr,i={};let r=v.empty,l,p;for(let c=a.top;c<a.bottom;c++)for(let m=a.left;m<a.right;m++){const u=n.map[c*n.width+m],d=a.table.nodeAt(u);if(!(i[u]||!d))if(i[u]=!0,l==null)l=u,p=d;else{gl(d)||(r=r.append(d.content));const g=s.mapping.map(u+a.tableStart);s.delete(g,g+d.nodeSize)}}if(l==null||p==null)return!0;if(s.setNodeMarkup(l+a.tableStart,null,{...pl(p.attrs,p.attrs.colspan,a.right-a.left-p.attrs.colspan),rowspan:a.bottom-a.top}),r.size>0){const c=l+1+p.content.size,m=gl(p)?l+1:c;s.replaceWith(m+a.tableStart,c+a.tableStart,r)}s.setSelection(new P(s.doc.resolve(l+a.tableStart))),e(s)}return!0}function hl(t,e){const o=le(t.schema);return dg(({node:a})=>o[a.type.spec.tableRole])(t,e)}function dg(t){return(e,o)=>{const a=e.selection;let n,s;if(a instanceof P){if(a.$anchorCell.pos!=a.$headCell.pos)return!1;n=a.$anchorCell.nodeAfter,s=a.$anchorCell.pos}else{var i;if(n=Kd(a.$from),!n)return!1;s=(i=dt(a.$from))===null||i===void 0?void 0:i.pos}if(n==null||s==null||n.attrs.colspan==1&&n.attrs.rowspan==1)return!1;if(o){let r=n.attrs;const l=[],p=r.colwidth;r.rowspan>1&&(r={...r,rowspan:1}),r.colspan>1&&(r={...r,colspan:1});const c=Ie(e),m=e.tr;for(let d=0;d<c.right-c.left;d++)l.push(p?{...r,colwidth:p&&p[d]?[p[d]]:null}:r);let u;for(let d=c.top;d<c.bottom;d++){let g=c.map.positionAt(d,c.left,c.table);d==c.top&&(g+=n.nodeSize);for(let f=c.left,h=0;f<c.right;f++,h++)f==c.left&&d==c.top||m.insert(u=m.mapping.map(g+c.tableStart,1),t({node:n,row:d,col:f}).createAndFill(l[h]))}m.setNodeMarkup(s,t({node:n,row:c.top,col:c.left}),l[0]),a instanceof P&&m.setSelection(new P(m.doc.resolve(a.$anchorCell.pos),u?m.doc.resolve(u):void 0)),o(m)}return!0}}function gg(t,e){return function(o,a){if(!_e(o))return!1;const n=qo(o);if(n.nodeAfter.attrs[t]===e)return!1;if(a){const s=o.tr;o.selection instanceof P?o.selection.forEachCell((i,r)=>{i.attrs[t]!==e&&s.setNodeMarkup(r,null,{...i.attrs,[t]:e})}):s.setNodeMarkup(n.pos,null,{...n.nodeAfter.attrs,[t]:e}),a(s)}return!0}}function fg(t){return function(e,o){if(!_e(e))return!1;if(o){const a=le(e.schema),n=Ie(e),s=e.tr,i=n.map.cellsInRect(t=="column"?{left:n.left,top:0,right:n.right,bottom:n.map.height}:t=="row"?{left:0,top:n.top,right:n.map.width,bottom:n.bottom}:n),r=i.map(l=>n.table.nodeAt(l));for(let l=0;l<i.length;l++)r[l].type==a.header_cell&&s.setNodeMarkup(n.tableStart+i[l],a.cell,r[l].attrs);if(s.steps.length===0)for(let l=0;l<i.length;l++)s.setNodeMarkup(n.tableStart+i[l],a.header_cell,r[l].attrs);o(s)}return!0}}function bl(t,e,o){const a=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let n=0;n<a.length;n++){const s=e.table.nodeAt(a[n]);if(s&&s.type!==o.header_cell)return!1}return!0}function Kt(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?fg(t):function(o,a){if(!_e(o))return!1;if(a){const n=le(o.schema),s=Ie(o),i=o.tr,r=bl("row",s,n),l=bl("column",s,n),p=(t==="column"?r:t==="row"&&l)?1:0,c=t=="column"?{left:0,top:p,right:1,bottom:s.map.height}:t=="row"?{left:p,top:0,right:s.map.width,bottom:1}:s,m=t=="column"?l?n.cell:n.header_cell:t=="row"?r?n.cell:n.header_cell:n.cell;s.map.cellsInRect(c).forEach(u=>{const d=u+s.tableStart,g=i.doc.nodeAt(d);g&&i.setNodeMarkup(d,m,g.attrs)}),a(i)}return!0}}Kt("row",{useDeprecatedLogic:!0}),Kt("column",{useDeprecatedLogic:!0});const hg=Kt("cell",{useDeprecatedLogic:!0});function bg(t,e){if(e<0){const o=t.nodeBefore;if(o)return t.pos-o.nodeSize;for(let a=t.index(-1)-1,n=t.before();a>=0;a--){const s=t.node(-1).child(a),i=s.lastChild;if(i)return n-1-i.nodeSize;n-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const o=t.node(-1);for(let a=t.indexAfter(-1),n=t.after();a<o.childCount;a++){const s=o.child(a);if(s.childCount)return n+1;n+=s.nodeSize}}return null}function jl(t){return function(e,o){if(!_e(e))return!1;const a=bg(qo(e),t);if(a==null)return!1;if(o){const n=e.doc.resolve(a);o(e.tr.setSelection(E.between(n,Jd(n))).scrollIntoView())}return!0}}function jg(t,e){const o=t.selection.$anchor;for(let a=o.depth;a>0;a--)if(o.node(a).type.spec.tableRole=="table")return e&&e(t.tr.delete(o.before(a),o.after(a)).scrollIntoView()),!0;return!1}function Wo(t,e){const o=t.selection;if(!(o instanceof P))return!1;if(e){const a=t.tr,n=le(t.schema).cell.createAndFill().content;o.forEachCell((s,i)=>{s.content.eq(n)||a.replace(a.mapping.map(i+1),a.mapping.map(i+s.nodeSize-1),new F(n,0,0))}),a.docChanged&&e(a)}return!0}function vg(t){if(t.size===0)return null;let{content:e,openStart:o,openEnd:a}=t;for(;e.childCount==1&&(o>0&&a>0||e.child(0).type.spec.tableRole=="table");)o--,a--,e=e.child(0).content;const n=e.child(0),s=n.type.spec.tableRole,i=n.type.schema,r=[];if(s=="row")for(let l=0;l<e.childCount;l++){let p=e.child(l).content;const c=l?0:Math.max(0,o-1),m=l<e.childCount-1?0:Math.max(0,a-1);(c||m)&&(p=Un(le(i).row,new F(p,c,m)).content),r.push(p)}else if(s=="cell"||s=="header_cell")r.push(o||a?Un(le(i).row,new F(e,o,a)).content:e);else return null;return kg(i,r)}function kg(t,e){const o=[];for(let n=0;n<e.length;n++){const s=e[n];for(let i=s.childCount-1;i>=0;i--){const{rowspan:r,colspan:l}=s.child(i).attrs;for(let p=n;p<n+r;p++)o[p]=(o[p]||0)+l}}let a=0;for(let n=0;n<o.length;n++)a=Math.max(a,o[n]);for(let n=0;n<o.length;n++)if(n>=e.length&&e.push(v.empty),o[n]<a){const s=le(t).cell.createAndFill(),i=[];for(let r=o[n];r<a;r++)i.push(s);e[n]=e[n].append(v.from(i))}return{height:e.length,width:a,rows:e}}function Un(t,e){const o=t.createAndFill();return new vi(o).replace(0,o.content.size,e).doc}function Fg({width:t,height:e,rows:o},a,n){if(t!=a){const s=[],i=[];for(let r=0;r<o.length;r++){const l=o[r],p=[];for(let c=s[r]||0,m=0;c<a;m++){let u=l.child(m%l.childCount);c+u.attrs.colspan>a&&(u=u.type.createChecked(gt(u.attrs,u.attrs.colspan,c+u.attrs.colspan-a),u.content)),p.push(u),c+=u.attrs.colspan;for(let d=1;d<u.attrs.rowspan;d++)s[r+d]=(s[r+d]||0)+u.attrs.colspan}i.push(v.from(p))}o=i,t=a}if(e!=n){const s=[];for(let i=0,r=0;i<n;i++,r++){const l=[],p=o[r%e];for(let c=0;c<p.childCount;c++){let m=p.child(c);i+m.attrs.rowspan>n&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,n-m.attrs.rowspan)},m.content)),l.push(m)}s.push(v.from(l))}o=s,e=n}return{width:t,height:e,rows:o}}function yg(t,e,o,a,n,s,i){const r=t.doc.type.schema,l=le(r);let p,c;if(n>e.width)for(let m=0,u=0;m<e.height;m++){const d=o.child(m);u+=d.nodeSize;const g=[];let f;d.lastChild==null||d.lastChild.type==l.cell?f=p||(p=l.cell.createAndFill()):f=c||(c=l.header_cell.createAndFill());for(let h=e.width;h<n;h++)g.push(f);t.insert(t.mapping.slice(i).map(u-1+a),g)}if(s>e.height){const m=[];for(let g=0,f=(e.height-1)*e.width;g<Math.max(e.width,n);g++){const h=g>=e.width?!1:o.nodeAt(e.map[f+g]).type==l.header_cell;m.push(h?c||(c=l.header_cell.createAndFill()):p||(p=l.cell.createAndFill()))}const u=l.row.create(null,v.from(m)),d=[];for(let g=e.height;g<s;g++)d.push(u);t.insert(t.mapping.slice(i).map(a+o.nodeSize-2),d)}return!!(p||c)}function vl(t,e,o,a,n,s,i,r){if(i==0||i==e.height)return!1;let l=!1;for(let p=n;p<s;p++){const c=i*e.width+p,m=e.map[c];if(e.map[c-e.width]==m){l=!0;const u=o.nodeAt(m),{top:d,left:g}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(r).map(m+a),null,{...u.attrs,rowspan:i-d}),t.insert(t.mapping.slice(r).map(e.positionAt(i,g,o)),u.type.createAndFill({...u.attrs,rowspan:d+u.attrs.rowspan-i})),p+=u.attrs.colspan-1}}return l}function kl(t,e,o,a,n,s,i,r){if(i==0||i==e.width)return!1;let l=!1;for(let p=n;p<s;p++){const c=p*e.width+i,m=e.map[c];if(e.map[c-1]==m){l=!0;const u=o.nodeAt(m),d=e.colCount(m),g=t.mapping.slice(r).map(m+a);t.setNodeMarkup(g,null,gt(u.attrs,i-d,u.attrs.colspan-(i-d))),t.insert(g+u.nodeSize,u.type.createAndFill(gt(u.attrs,0,i-d))),p+=u.attrs.rowspan-1}}return l}function Fl(t,e,o,a,n){let s=o?t.doc.nodeAt(o-1):t.doc;if(!s)throw new Error("No table found");let i=J.get(s);const{top:r,left:l}=a,p=l+n.width,c=r+n.height,m=t.tr;let u=0;function d(){if(s=o?m.doc.nodeAt(o-1):m.doc,!s)throw new Error("No table found");i=J.get(s),u=m.mapping.maps.length}yg(m,i,s,o,p,c,u)&&d(),vl(m,i,s,o,l,p,r,u)&&d(),vl(m,i,s,o,l,p,c,u)&&d(),kl(m,i,s,o,r,c,l,u)&&d(),kl(m,i,s,o,r,c,p,u)&&d();for(let g=r;g<c;g++){const f=i.positionAt(g,l,s),h=i.positionAt(g,p,s);m.replace(m.mapping.slice(u).map(f+o),m.mapping.slice(u).map(h+o),new F(n.rows[g-r],0,0))}d(),m.setSelection(new P(m.doc.resolve(o+i.positionAt(r,l,s)),m.doc.resolve(o+i.positionAt(c-1,p-1,s)))),e(m)}const _g=wr({ArrowLeft:Ko("horiz",-1),ArrowRight:Ko("horiz",1),ArrowUp:Ko("vert",-1),ArrowDown:Ko("vert",1),"Shift-ArrowLeft":Vo("horiz",-1),"Shift-ArrowRight":Vo("horiz",1),"Shift-ArrowUp":Vo("vert",-1),"Shift-ArrowDown":Vo("vert",1),Backspace:Wo,"Mod-Backspace":Wo,Delete:Wo,"Mod-Delete":Wo});function Uo(t,e,o){return o.eq(t.selection)?!1:(e&&e(t.tr.setSelection(o).scrollIntoView()),!0)}function Ko(t,e){return(o,a,n)=>{if(!n)return!1;const s=o.selection;if(s instanceof P)return Uo(o,a,x.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const i=yl(n,t,e);if(i==null)return!1;if(t=="horiz")return Uo(o,a,x.near(o.doc.resolve(s.head+e),e));{const r=o.doc.resolve(i),l=ll(r,t,e);let p;return l?p=x.near(l,1):e<0?p=x.near(o.doc.resolve(r.before(-1)),-1):p=x.near(o.doc.resolve(r.after(-1)),1),Uo(o,a,p)}}}function Vo(t,e){return(o,a,n)=>{if(!n)return!1;const s=o.selection;let i;if(s instanceof P)i=s;else{const l=yl(n,t,e);if(l==null)return!1;i=new P(o.doc.resolve(l))}const r=ll(i.$headCell,t,e);return r?Uo(o,a,new P(i.$anchorCell,r)):!1}}function Dg(t,e){const o=t.state.doc,a=dt(o.resolve(e));return a?(t.dispatch(t.state.tr.setSelection(new P(a))),!0):!1}function wg(t,e,o){if(!_e(t.state))return!1;let a=vg(o);const n=t.state.selection;if(n instanceof P){a||(a={width:1,height:1,rows:[v.from(Un(le(t.state.schema).cell,o))]});const s=n.$anchorCell.node(-1),i=n.$anchorCell.start(-1),r=J.get(s).rectBetween(n.$anchorCell.pos-i,n.$headCell.pos-i);return a=Fg(a,r.right-r.left,r.bottom-r.top),Fl(t.state,t.dispatch,i,r,a),!0}else if(a){const s=qo(t.state),i=s.start(-1);return Fl(t.state,t.dispatch,i,J.get(s.node(-1)).findCell(s.pos-i),a),!0}else return!1}function Ig(t,e){var o;if(e.button!=0||e.ctrlKey||e.metaKey)return;const a=_l(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof P)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&a&&(n=dt(t.state.selection.$anchor))!=null&&((o=Kn(t,e))===null||o===void 0?void 0:o.pos)!=n.pos)s(n,e),e.preventDefault();else if(!a)return;function s(l,p){let c=Kn(t,p);const m=Je.getState(t.state)==null;if(!c||!Wn(l,c))if(m)c=l;else return;const u=new P(l,c);if(m||!t.state.selection.eq(u)){const d=t.state.tr.setSelection(u);m&&d.setMeta(Je,l.pos),t.dispatch(d)}}function i(){t.root.removeEventListener("mouseup",i),t.root.removeEventListener("dragstart",i),t.root.removeEventListener("mousemove",r),Je.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Je,-1))}function r(l){const p=l,c=Je.getState(t.state);let m;if(c!=null)m=t.state.doc.resolve(c);else if(_l(t,p.target)!=a&&(m=Kn(t,e),!m))return i();m&&s(m,p)}t.root.addEventListener("mouseup",i),t.root.addEventListener("dragstart",i),t.root.addEventListener("mousemove",r)}function yl(t,e,o){if(!(t.state.selection instanceof E))return null;const{$head:a}=t.state.selection;for(let n=a.depth-1;n>=0;n--){const s=a.node(n);if((o<0?a.index(n):a.indexAfter(n))!=(o<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const i=a.before(n),r=e=="vert"?o>0?"down":"up":o>0?"right":"left";return t.endOfTextblock(r)?i:null}}return null}function _l(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Kn(t,e){const o=t.posAtCoords({left:e.clientX,top:e.clientY});if(!o)return null;let{inside:a,pos:n}=o;return a>=0&&dt(t.state.doc.resolve(a))||dt(t.state.doc.resolve(n))}var Cg=class{constructor(e,o){this.node=e,this.defaultCellMinWidth=o,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",`${o}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Vn(e,this.colgroup,this.table,o),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Vn(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Vn(t,e,o,a,n,s){let i=0,r=!0,l=e.firstChild;const p=t.firstChild;if(p){for(let m=0,u=0;m<p.childCount;m++){const{colspan:d,colwidth:g}=p.child(m).attrs;for(let f=0;f<d;f++,u++){const h=n==u?s:g&&g[f],b=h?h+"px":"";if(i+=h||a,h||(r=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const j=document.createElement("col");j.style.width=b,e.appendChild(j)}}}for(;l;){var c;const m=l.nextSibling;(c=l.parentNode)===null||c===void 0||c.removeChild(l),l=m}r?(o.style.width=i+"px",o.style.minWidth=""):(o.style.width="",o.style.minWidth=i+"px")}}const be=new Q("tableColumnResizing");function Eg({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:o=100,View:a=Cg,lastColumnResizable:n=!0}={}){const s=new se({key:be,state:{init(i,r){var l;const p=(l=s.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,c=le(r.schema).table.name;return a&&p&&(p[c]=(m,u)=>new a(m,o,u)),new Ag(-1,!1)},apply(i,r){return r.apply(i)}},props:{attributes:i=>{const r=be.getState(i);return r&&r.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,r)=>{xg(i,r,t,n)},mouseleave:i=>{Sg(i)},mousedown:(i,r)=>{Tg(i,r,e,o)}},decorations:i=>{const r=be.getState(i);if(r&&r.activeHandle>-1)return Ng(i,r.activeHandle)},nodeViews:{}}});return s}var Ag=class Ba{constructor(e,o){this.activeHandle=e,this.dragging=o}apply(e){const o=this,a=e.getMeta(be);if(a&&a.setHandle!=null)return new Ba(a.setHandle,!1);if(a&&a.setDragging!==void 0)return new Ba(o.activeHandle,a.setDragging);if(o.activeHandle>-1&&e.docChanged){let n=e.mapping.map(o.activeHandle,-1);return qn(e.doc.resolve(n))||(n=-1),new Ba(n,o.dragging)}return o}};function xg(t,e,o,a){if(!t.editable)return;const n=be.getState(t.state);if(n&&!n.dragging){const s=Bg(e.target);let i=-1;if(s){const{left:r,right:l}=s.getBoundingClientRect();e.clientX-r<=o?i=Dl(t,e,"left",o):l-e.clientX<=o&&(i=Dl(t,e,"right",o))}if(i!=n.activeHandle){if(!a&&i!==-1){const r=t.state.doc.resolve(i),l=r.node(-1),p=J.get(l),c=r.start(-1);if(p.colCount(r.pos-c)+r.nodeAfter.attrs.colspan-1==p.width-1)return}Il(t,i)}}}function Sg(t){if(!t.editable)return;const e=be.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Il(t,-1)}function Tg(t,e,o,a){var n;if(!t.editable)return!1;const s=(n=t.dom.ownerDocument.defaultView)!==null&&n!==void 0?n:window,i=be.getState(t.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const r=t.state.doc.nodeAt(i.activeHandle),l=Mg(t,i.activeHandle,r.attrs);t.dispatch(t.state.tr.setMeta(be,{setDragging:{startX:e.clientX,startWidth:l}}));function p(m){s.removeEventListener("mouseup",p),s.removeEventListener("mousemove",c);const u=be.getState(t.state);u!=null&&u.dragging&&(Rg(t,u.activeHandle,wl(u.dragging,m,o)),t.dispatch(t.state.tr.setMeta(be,{setDragging:null})))}function c(m){if(!m.which)return p(m);const u=be.getState(t.state);if(u&&u.dragging){const d=wl(u.dragging,m,o);Cl(t,u.activeHandle,d,a)}}return Cl(t,i.activeHandle,l,a),s.addEventListener("mouseup",p),s.addEventListener("mousemove",c),e.preventDefault(),!0}function Mg(t,e,{colspan:o,colwidth:a}){const n=a&&a[a.length-1];if(n)return n;const s=t.domAtPos(e);let i=s.node.childNodes[s.offset].offsetWidth,r=o;if(a)for(let l=0;l<o;l++)a[l]&&(i-=a[l],r--);return i/r}function Bg(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Dl(t,e,o,a){const n=o=="right"?-a:a,s=t.posAtCoords({left:e.clientX+n,top:e.clientY});if(!s)return-1;const{pos:i}=s,r=dt(t.state.doc.resolve(i));if(!r)return-1;if(o=="right")return r.pos;const l=J.get(r.node(-1)),p=r.start(-1),c=l.map.indexOf(r.pos-p);return c%l.width==0?-1:p+l.map[c-1]}function wl(t,e,o){const a=e.clientX-t.startX;return Math.max(o,t.startWidth+a)}function Il(t,e){t.dispatch(t.state.tr.setMeta(be,{setHandle:e}))}function Rg(t,e,o){const a=t.state.doc.resolve(e),n=a.node(-1),s=J.get(n),i=a.start(-1),r=s.colCount(a.pos-i)+a.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let p=0;p<s.height;p++){const c=p*s.width+r;if(p&&s.map[c]==s.map[c-s.width])continue;const m=s.map[c],u=n.nodeAt(m).attrs,d=u.colspan==1?0:r-s.colCount(m);if(u.colwidth&&u.colwidth[d]==o)continue;const g=u.colwidth?u.colwidth.slice():Lg(u.colspan);g[d]=o,l.setNodeMarkup(i+m,null,{...u,colwidth:g})}l.docChanged&&t.dispatch(l)}function Cl(t,e,o,a){const n=t.state.doc.resolve(e),s=n.node(-1),i=n.start(-1),r=J.get(s).colCount(n.pos-i)+n.nodeAfter.attrs.colspan-1;let l=t.domAtPos(n.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Vn(s,l.firstChild,l,a,r,o)}function Lg(t){return Array(t).fill(0)}function Ng(t,e){const o=[],a=t.doc.resolve(e),n=a.node(-1);if(!n)return X.empty;const s=J.get(n),i=a.start(-1),r=s.colCount(a.pos-i)+a.nodeAfter.attrs.colspan-1;for(let p=0;p<s.height;p++){const c=r+p*s.width;if((r==s.width-1||s.map[c]!=s.map[c+1])&&(p==0||s.map[c]!=s.map[c-s.width])){var l;const m=s.map[c],u=i+m+n.nodeAt(m).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",!((l=be.getState(t))===null||l===void 0)&&l.dragging&&o.push(he.node(i+m,i+m+n.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),o.push(he.widget(u,d))}}return X.create(t.doc,o)}function zg({allowTableNodeSelection:t=!1}={}){return new se({key:Je,state:{init(){return null},apply(e,o){const a=e.getMeta(Je);if(a!=null)return a==-1?null:a;if(o==null||!e.docChanged)return o;const{deleted:n,pos:s}=e.mapping.mapResult(o);return n?null:s}},props:{decorations:Yd,handleDOMEvents:{mousedown:Ig},createSelectionBetween(e){return Je.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Dg,handleKeyDown:_g,handlePaste:wg},appendTransaction(e,o,a){return eg(a,ml(a,o),t)}})}var El=K.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,o;const a=t.getAttribute("colwidth"),n=a?a.split(",").map(s=>parseInt(s,10)):null;if(!n){const s=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),i=Array.from(((o=t.parentElement)==null?void 0:o.children)||[]).indexOf(t);if(i&&i>-1&&s&&s[i]){const r=s[i].getAttribute("width");return r?[parseInt(r,10)]:null}}return n}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",R(this.options.HTMLAttributes,t),0]}}),Al=K.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(a=>parseInt(a,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",R(this.options.HTMLAttributes,t),0]}}),xl=K.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",R(this.options.HTMLAttributes,t),0]}});function Jn(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Sl(t,e,o,a,n,s){var i;let r=0,l=!0,p=e.firstChild;const c=t.firstChild;if(c!==null)for(let u=0,d=0;u<c.childCount;u+=1){const{colspan:g,colwidth:f}=c.child(u).attrs;for(let h=0;h<g;h+=1,d+=1){const b=n===d?s:f&&f[h],j=b?`${b}px`:"";if(r+=b||a,b||(l=!1),p){if(p.style.width!==j){const[D,w]=Jn(a,b);p.style.setProperty(D,w)}p=p.nextSibling}else{const D=document.createElement("col"),[w,y]=Jn(a,b);D.style.setProperty(w,y),e.appendChild(D)}}}for(;p;){const u=p.nextSibling;(i=p.parentNode)==null||i.removeChild(p),p=u}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!m?(o.style.width=`${r}px`,o.style.minWidth=""):(o.style.width="",o.style.minWidth=`${r}px`)}var Og=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,Sl(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,o=this.dom.contains(e),a=this.contentDOM.contains(e);return!!(o&&!a&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function $g(t,e,o,a){let n=0,s=!0;const i=[],r=t.firstChild;if(!r)return{};for(let m=0,u=0;m<r.childCount;m+=1){const{colspan:d,colwidth:g}=r.child(m).attrs;for(let f=0;f<d;f+=1,u+=1){const h=o===u?a:g&&g[f];n+=h||e,h||(s=!1);const[b,j]=Jn(e,h);i.push(["col",{style:`${b}: ${j}`}])}}const l=s?`${n}px`:"",p=s?"":`${n}px`;return{colgroup:["colgroup",{},...i],tableWidth:l,tableMinWidth:p}}function Tl(t,e){return t.createAndFill()}function Pg(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(o=>{const a=t.nodes[o];a.spec.tableRole&&(e[a.spec.tableRole]=a)}),t.cached.tableNodeTypes=e,e}function Hg(t,e,o,a,n){const s=Pg(t),i=[],r=[];for(let p=0;p<o;p+=1){const c=Tl(s.cell);if(c&&r.push(c),a){const m=Tl(s.header_cell);m&&i.push(m)}}const l=[];for(let p=0;p<e;p+=1)l.push(s.row.createChecked(null,a&&p===0?i:r));return s.table.createChecked(null,l)}function qg(t){return t instanceof P}var Jo=({editor:t})=>{const{selection:e}=t.state;if(!qg(e))return!1;let o=0;const a=Nr(e.ranges[0].$from,s=>s.type.name==="table");return a==null||a.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(o+=1)}),o===e.ranges.length?(t.commands.deleteTable(),!0):!1},Wg="";function Ug(t){return(t||"").replace(/\s+/g," ").trim()}function Kg(t,e,o={}){var a;const n=(a=o.cellLineSeparator)!=null?a:Wg;if(!t||!t.content||t.content.length===0)return"";const s=[];t.content.forEach(g=>{const f=[];g.content&&g.content.forEach(h=>{let b="";h.content&&Array.isArray(h.content)&&h.content.length>1?b=h.content.map(y=>e.renderChildren(y)).join(n):b=h.content?e.renderChildren(h.content):"";const j=Ug(b),D=h.type==="tableHeader";f.push({text:j,isHeader:D})}),s.push(f)});const i=s.reduce((g,f)=>Math.max(g,f.length),0);if(i===0)return"";const r=new Array(i).fill(0);s.forEach(g=>{var f;for(let h=0;h<i;h+=1){const j=(((f=g[h])==null?void 0:f.text)||"").length;j>r[h]&&(r[h]=j),r[h]<3&&(r[h]=3)}});const l=(g,f)=>g+" ".repeat(Math.max(0,f-g.length)),p=s[0],c=p.some(g=>g.isHeader);let m=`
|
|
43
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const o=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return o!==void 0?o:-1},tokenize(t,e,o){const a=s=>{const i=Rn(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:r=>({indentLevel:r[1].length,mainContent:r[4],checked:r[3].toLowerCase()==="x"}),createToken:(r,l)=>({type:"taskItem",raw:"",mainContent:r.mainContent,indentLevel:r.indentLevel,checked:r.checked,text:r.mainContent,tokens:o.inlineTokens(r.mainContent),nestedTokens:l}),customNestedParser:a},o);return i?[{type:"taskList",raw:i.raw,items:i.items}]:o.blockTokens(s)},n=Rn(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,i)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:o.inlineTokens(s.mainContent),nestedTokens:i}),customNestedParser:a},o);if(n)return{type:"taskList",raw:n.raw,items:n.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ee.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Jr.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Gr.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Ed.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(sl.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Bd.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Rd.configure(this.options.taskList)),t}});class ae extends x{constructor(e){super(e,e)}map(e,o){let a=e.resolve(o.map(this.head));return ae.valid(a)?new ae(a):x.near(a)}content(){return F.empty}eq(e){return e instanceof ae&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,o){if(typeof o.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ae(e.resolve(o.pos))}getBookmark(){return new $n(this.anchor)}static valid(e){let o=e.parent;if(o.inlineContent||!Ld(e)||!Nd(e))return!1;let a=o.type.spec.allowGapCursor;if(a!=null)return a;let n=o.contentMatchAt(e.index()).defaultType;return n&&n.isTextblock}static findGapCursorFrom(e,o,a=!1){e:for(;;){if(!a&&ae.valid(e))return e;let n=e.pos,s=null;for(let i=e.depth;;i--){let r=e.node(i);if(o>0?e.indexAfter(i)<r.childCount:e.index(i)>0){s=r.child(o>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;n+=o;let l=e.doc.resolve(n);if(ae.valid(l))return l}for(;;){let i=o>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!C.isSelectable(s)){e=e.doc.resolve(n+s.nodeSize*o),a=!1;continue e}break}s=i,n+=o;let r=e.doc.resolve(n);if(ae.valid(r))return r}return null}}}ae.prototype.visible=!1,ae.findFrom=ae.findGapCursorFrom,x.jsonID("gapcursor",ae);class $n{constructor(e){this.pos=e}map(e){return new $n(e.map(this.pos))}resolve(e){let o=e.resolve(this.pos);return ae.valid(o)?new ae(o):x.near(o)}}function il(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Ld(t){for(let e=t.depth;e>=0;e--){let o=t.index(e),a=t.node(e);if(o==0){if(a.type.spec.isolating)return!0;continue}for(let n=a.child(o-1);;n=n.lastChild){if(n.childCount==0&&!n.inlineContent||il(n.type))return!0;if(n.inlineContent)return!1}}return!0}function Nd(t){for(let e=t.depth;e>=0;e--){let o=t.indexAfter(e),a=t.node(e);if(o==a.childCount){if(a.type.spec.isolating)return!0;continue}for(let n=a.child(o);;n=n.firstChild){if(n.childCount==0&&!n.inlineContent||il(n.type))return!0;if(n.inlineContent)return!1}}return!0}wr({ArrowLeft:Po("horiz",-1),ArrowRight:Po("horiz",1),ArrowUp:Po("vert",-1),ArrowDown:Po("vert",1)});function Po(t,e){const o=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(a,n,s){let i=a.selection,r=e>0?i.$to:i.$from,l=i.empty;if(i instanceof E){if(!s.endOfTextblock(o)||r.depth==0)return!1;l=!1,r=a.doc.resolve(e>0?r.after():r.before())}let p=ae.findGapCursorFrom(r,e,l);return p?(n&&n(a.tr.setSelection(new ae(p))),!0):!1}}var Ho=(t,e)=>e.view.domAtPos(t).node.offsetParent!==null,zd=(t,e,o)=>{for(let a=t.depth;a>0;a-=1){const n=t.node(a),s=e(n),i=Ho(t.start(a),o);if(s&&i)return{pos:a>0?t.before(a):0,start:t.start(a),depth:a,node:n}}},rl=(t,e)=>{const{state:o,view:a,extensionManager:n}=t,{schema:s,selection:i}=o,{empty:r,$anchor:l}=i,p=!!n.extensions.find(b=>b.name==="gapCursor");if(!r||l.parent.type!==s.nodes.detailsSummary||!p||e==="right"&&l.parentOffset!==l.parent.nodeSize-2)return!1;const c=mt(b=>b.type===s.nodes.details)(i);if(!c)return!1;const m=No(c.node,b=>b.type===s.nodes.detailsContent);if(!m.length||Ho(c.start+m[0].pos+1,t))return!1;const d=o.doc.resolve(c.pos+c.node.nodeSize),g=ae.findFrom(d,1,!1);if(!g)return!1;const{tr:f}=o,h=new ae(g);return f.setSelection(h),f.scrollIntoView(),a.dispatch(f),!0},Od=K.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:"is-open",HTMLAttributes:{}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:({open:t})=>t?{open:""}:{}}}:[]},parseHTML(){return[{tag:"details"}]},renderHTML({HTMLAttributes:t}){return["details",R(this.options.HTMLAttributes,t),0]},...$o({nodeName:"details",content:"block"}),addNodeView(){return({editor:t,getPos:e,node:o,HTMLAttributes:a})=>{const n=document.createElement("div"),s=R(this.options.HTMLAttributes,a,{"data-type":this.name});Object.entries(s).forEach(([p,c])=>n.setAttribute(p,c));const i=document.createElement("button");i.type="button",n.append(i);const r=document.createElement("div");n.append(r);const l=p=>{if(p!==void 0)if(p){if(n.classList.contains(this.options.openClassName))return;n.classList.add(this.options.openClassName)}else{if(!n.classList.contains(this.options.openClassName))return;n.classList.remove(this.options.openClassName)}else n.classList.toggle(this.options.openClassName);const c=new Event("toggleDetailsContent"),m=r.querySelector(':scope > div[data-type="detailsContent"]');m==null||m.dispatchEvent(c)};return o.attrs.open&&setTimeout(()=>l()),i.addEventListener("click",()=>{if(l(),!this.options.persist){t.commands.focus(void 0,{scrollIntoView:!1});return}if(t.isEditable&&typeof e=="function"){const{from:p,to:c}=t.state.selection;t.chain().command(({tr:m})=>{const u=e();if(!u)return!1;const d=m.doc.nodeAt(u);return(d==null?void 0:d.type)!==this.type?!1:(m.setNodeMarkup(u,void 0,{open:!d.attrs.open}),!0)}).setTextSelection({from:p,to:c}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:n,contentDOM:r,ignoreMutation(p){return p.type==="selection"?!1:!n.contains(p.target)||n===p.target},update:p=>p.type!==this.type?!1:(p.attrs.open!==void 0&&l(p.attrs.open),!0)}}},addCommands(){return{setDetails:()=>({state:t,chain:e})=>{var o;const{schema:a,selection:n}=t,{$from:s,$to:i}=n,r=s.blockRange(i);if(!r)return!1;const l=t.doc.slice(r.start,r.end);if(!a.nodes.detailsContent.contentMatch.matchFragment(l.content))return!1;const c=((o=l.toJSON())==null?void 0:o.content)||[];return e().insertContentAt({from:r.start,to:r.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:c}]}).setTextSelection(r.start+2).run()},unsetDetails:()=>({state:t,chain:e})=>{const{selection:o,schema:a}=t,n=mt(b=>b.type===this.type)(o);if(!n)return!1;const s=No(n.node,b=>b.type===a.nodes.detailsSummary),i=No(n.node,b=>b.type===a.nodes.detailsContent);if(!s.length||!i.length)return!1;const r=s[0],l=i[0],p=n.pos,c=t.doc.resolve(p),m=p+n.node.nodeSize,u={from:p,to:m},d=l.node.content.toJSON()||[],g=c.parent.type.contentMatch.defaultType,h=[g==null?void 0:g.create(null,r.node.content).toJSON(),...d];return e().insertContentAt(u,h).setTextSelection(p+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{const{schema:t,selection:e}=this.editor.state,{empty:o,$anchor:a}=e;return!o||a.parent.type!==t.nodes.detailsSummary?!1:a.parentOffset!==0?this.editor.commands.command(({tr:n})=>{const s=a.pos-1,i=a.pos;return n.delete(s,i),!0}):this.editor.commands.unsetDetails()},Enter:({editor:t})=>{const{state:e,view:o}=t,{schema:a,selection:n}=e,{$head:s}=n;if(s.parent.type!==a.nodes.detailsSummary)return!1;const i=Ho(s.after()+1,t),r=i?e.doc.nodeAt(s.after()):s.node(-2);if(!r)return!1;const l=i?0:s.indexAfter(-1),p=Dn(r.contentMatchAt(l));if(!p||!r.canReplaceWith(l,l,p))return!1;const c=p.createAndFill();if(!c)return!1;const m=i?s.after()+1:s.after(-1),u=e.tr.replaceWith(m,m,c),d=u.doc.resolve(m),g=x.near(d,1);return u.setSelection(g),u.scrollIntoView(),o.dispatch(u),!0},ArrowRight:({editor:t})=>rl(t,"right"),ArrowDown:({editor:t})=>rl(t,"down")}},addProseMirrorPlugins(){return[new se({key:new Q("detailsSelection"),appendTransaction:(t,e,o)=>{const{editor:a,type:n}=this;if(a.view.composing||!t.some(b=>b.selectionSet)||!e.selection.empty||!o.selection.empty||!Tu(o,n.name))return;const{$from:l}=o.selection;if(Ho(l.pos,a))return;const c=zd(l,b=>b.type===n,a);if(!c)return;const m=No(c.node,b=>b.type===o.schema.nodes.detailsSummary);if(!m.length)return;const u=m[0],g=(e.selection.from<o.selection.from?"forward":"backward")==="forward"?c.start+u.pos:c.pos+u.pos+u.node.nodeSize,f=E.create(o.doc,g);return o.tr.setSelection(f)}})]}}),$d=K.create({name:"detailsContent",content:"block+",defining:!0,selectable:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",R(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:t})=>{const e=document.createElement("div"),o=R(this.options.HTMLAttributes,t,{"data-type":this.name,hidden:"hidden"});return Object.entries(o).forEach(([a,n])=>e.setAttribute(a,n)),e.addEventListener("toggleDetailsContent",()=>{e.toggleAttribute("hidden")}),{dom:e,contentDOM:e,ignoreMutation(a){return a.type==="selection"?!1:!e.contains(a.target)||e===a.target},update:a=>a.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{state:e,view:o}=t,{selection:a}=e,{$from:n,empty:s}=a,i=mt(T=>T.type===this.type)(a);if(!s||!i||!i.node.childCount)return!1;const r=n.index(i.depth),{childCount:l}=i.node;if(!(l===r+1))return!1;const c=i.node.type.contentMatch.defaultType,m=c==null?void 0:c.createAndFill();if(!m)return!1;const u=e.doc.resolve(i.pos+1),d=l-1,g=i.node.child(d),f=u.posAtIndex(d,i.depth);if(!g.eq(m))return!1;const b=n.node(-3);if(!b)return!1;const j=n.indexAfter(-3),D=Dn(b.contentMatchAt(j));if(!D||!b.canReplaceWith(j,j,D))return!1;const w=D.createAndFill();if(!w)return!1;const{tr:y}=e,I=n.after(-2);y.replaceWith(I,I,w);const _=y.doc.resolve(I),A=x.near(_,1);y.setSelection(A);const B=f,L=f+g.nodeSize;return y.delete(B,L),y.scrollIntoView(),o.dispatch(y),!0}}},...$o({nodeName:"detailsContent"})}),Pd=K.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:t}){return["summary",R(this.options.HTMLAttributes,t),0]},...$o({nodeName:"detailsSummary",content:"inline"})});let Pn,Hn;if(typeof WeakMap<"u"){let t=new WeakMap;Pn=e=>t.get(e),Hn=(e,o)=>(t.set(e,o),o)}else{const t=[];let o=0;Pn=a=>{for(let n=0;n<t.length;n+=2)if(t[n]==a)return t[n+1]},Hn=(a,n)=>(o==10&&(o=0),t[o++]=a,t[o++]=n)}var J=class{constructor(t,e,o,a){this.width=t,this.height=e,this.map=o,this.problems=a}findCell(t){for(let e=0;e<this.map.length;e++){const o=this.map[e];if(o!=t)continue;const a=e%this.width,n=e/this.width|0;let s=a+1,i=n+1;for(let r=1;s<this.width&&this.map[e+r]==o;r++)s++;for(let r=1;i<this.height&&this.map[e+this.width*r]==o;r++)i++;return{left:a,top:n,right:s,bottom:i}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,o){const{left:a,right:n,top:s,bottom:i}=this.findCell(t);return e=="horiz"?(o<0?a==0:n==this.width)?null:this.map[s*this.width+(o<0?a-1:n)]:(o<0?s==0:i==this.height)?null:this.map[a+this.width*(o<0?s-1:i)]}rectBetween(t,e){const{left:o,right:a,top:n,bottom:s}=this.findCell(t),{left:i,right:r,top:l,bottom:p}=this.findCell(e);return{left:Math.min(o,i),top:Math.min(n,l),right:Math.max(a,r),bottom:Math.max(s,p)}}cellsInRect(t){const e=[],o={};for(let a=t.top;a<t.bottom;a++)for(let n=t.left;n<t.right;n++){const s=a*this.width+n,i=this.map[s];o[i]||(o[i]=!0,!(n==t.left&&n&&this.map[s-1]==i||a==t.top&&a&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(t,e,o){for(let a=0,n=0;;a++){const s=n+o.child(a).nodeSize;if(a==t){let i=e+t*this.width;const r=(t+1)*this.width;for(;i<r&&this.map[i]<n;)i++;return i==r?s-1:this.map[i]}n=s}}static get(t){return Pn(t)||Hn(t,Hd(t))}};function Hd(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=qd(t),o=t.childCount,a=[];let n=0,s=null;const i=[];for(let p=0,c=e*o;p<c;p++)a[p]=0;for(let p=0,c=0;p<o;p++){const m=t.child(p);c++;for(let g=0;;g++){for(;n<a.length&&a[n]!=0;)n++;if(g==m.childCount)break;const f=m.child(g),{colspan:h,rowspan:b,colwidth:j}=f.attrs;for(let D=0;D<b;D++){if(D+p>=o){(s||(s=[])).push({type:"overlong_rowspan",pos:c,n:b-D});break}const w=n+D*e;for(let y=0;y<h;y++){a[w+y]==0?a[w+y]=c:(s||(s=[])).push({type:"collision",row:p,pos:c,n:h-y});const I=j&&j[y];if(I){const _=(w+y)%e*2,A=i[_];A==null||A!=I&&i[_+1]==1?(i[_]=I,i[_+1]=1):A==I&&i[_+1]++}}}n+=h,c+=f.nodeSize}const u=(p+1)*e;let d=0;for(;n<u;)a[n++]==0&&d++;d&&(s||(s=[])).push({type:"missing",row:p,n:d}),c++}(e===0||o===0)&&(s||(s=[])).push({type:"zero_sized"});const r=new J(e,o,a,s);let l=!1;for(let p=0;!l&&p<i.length;p+=2)i[p]!=null&&i[p+1]<o&&(l=!0);return l&&Wd(r,i,t),r}function qd(t){let e=-1,o=!1;for(let a=0;a<t.childCount;a++){const n=t.child(a);let s=0;if(o)for(let i=0;i<a;i++){const r=t.child(i);for(let l=0;l<r.childCount;l++){const p=r.child(l);i+p.attrs.rowspan>a&&(s+=p.attrs.colspan)}}for(let i=0;i<n.childCount;i++){const r=n.child(i);s+=r.attrs.colspan,r.attrs.rowspan>1&&(o=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function Wd(t,e,o){t.problems||(t.problems=[]);const a={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(a[s])continue;a[s]=!0;const i=o.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let r=null;const l=i.attrs;for(let p=0;p<l.colspan;p++){const c=e[(n+p)%t.width*2];c!=null&&(!l.colwidth||l.colwidth[p]!=c)&&((r||(r=Ud(l)))[p]=c)}r&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:r})}}function Ud(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let o=0;o<t.colspan;o++)e.push(0);return e}function le(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const o in t.nodes){const a=t.nodes[o],n=a.spec.tableRole;n&&(e[n]=a)}}return e}const Je=new Q("selectingCells");function dt(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Kd(t){for(let e=t.depth;e>0;e--){const o=t.node(e).type.spec.tableRole;if(o==="cell"||o==="header_cell")return t.node(e)}return null}function _e(t){const e=t.selection.$head;for(let o=e.depth;o>0;o--)if(e.node(o).type.spec.tableRole=="row")return!0;return!1}function qo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const o=dt(e.$head)||Vd(e.$head);if(o)return o;throw new RangeError(`No cell found around position ${e.head}`)}function Vd(t){for(let e=t.nodeAfter,o=t.pos;e;e=e.firstChild,o++){const a=e.type.spec.tableRole;if(a=="cell"||a=="header_cell")return t.doc.resolve(o)}for(let e=t.nodeBefore,o=t.pos;e;e=e.lastChild,o--){const a=e.type.spec.tableRole;if(a=="cell"||a=="header_cell")return t.doc.resolve(o-e.nodeSize)}}function qn(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Jd(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Wn(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function ll(t,e,o){const a=t.node(-1),n=J.get(a),s=t.start(-1),i=n.nextCell(t.pos-s,e,o);return i==null?null:t.node(0).resolve(s+i)}function gt(t,e,o=1){const a={...t,colspan:t.colspan-o};return a.colwidth&&(a.colwidth=a.colwidth.slice(),a.colwidth.splice(e,o),a.colwidth.some(n=>n>0)||(a.colwidth=null)),a}function pl(t,e,o=1){const a={...t,colspan:t.colspan+o};if(a.colwidth){a.colwidth=a.colwidth.slice();for(let n=0;n<o;n++)a.colwidth.splice(e,0,0)}return a}function Gd(t,e,o){const a=le(e.type.schema).header_cell;for(let n=0;n<t.height;n++)if(e.nodeAt(t.map[o+n*t.width]).type!=a)return!1;return!0}var P=class Le extends x{constructor(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),i=n.rectBetween(e.pos-s,o.pos-s),r=e.node(0),l=n.cellsInRect(i).filter(c=>c!=o.pos-s);l.unshift(o.pos-s);const p=l.map(c=>{const m=a.nodeAt(c);if(!m)throw new RangeError(`No cell with offset ${c} found`);const u=s+c+1;return new ki(r.resolve(u),r.resolve(u+m.content.size))});super(p[0].$from,p[0].$to,p),this.$anchorCell=e,this.$headCell=o}map(e,o){const a=e.resolve(o.map(this.$anchorCell.pos)),n=e.resolve(o.map(this.$headCell.pos));if(qn(a)&&qn(n)&&Wn(a,n)){const s=this.$anchorCell.node(-1)!=a.node(-1);return s&&this.isRowSelection()?Le.rowSelection(a,n):s&&this.isColSelection()?Le.colSelection(a,n):new Le(a,n)}return E.between(a,n)}content(){const e=this.$anchorCell.node(-1),o=J.get(e),a=this.$anchorCell.start(-1),n=o.rectBetween(this.$anchorCell.pos-a,this.$headCell.pos-a),s={},i=[];for(let l=n.top;l<n.bottom;l++){const p=[];for(let c=l*o.width+n.left,m=n.left;m<n.right;m++,c++){const u=o.map[c];if(s[u])continue;s[u]=!0;const d=o.findCell(u);let g=e.nodeAt(u);if(!g)throw new RangeError(`No cell with offset ${u} found`);const f=n.left-d.left,h=d.right-n.right;if(f>0||h>0){let b=g.attrs;if(f>0&&(b=gt(b,0,f)),h>0&&(b=gt(b,b.colspan-h,h)),d.left<n.left){if(g=g.type.createAndFill(b),!g)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else g=g.type.create(b,g.content)}if(d.top<n.top||d.bottom>n.bottom){const b={...g.attrs,rowspan:Math.min(d.bottom,n.bottom)-Math.max(d.top,n.top)};d.top<n.top?g=g.type.createAndFill(b):g=g.type.create(b,g.content)}p.push(g)}i.push(e.child(l).copy(v.from(p)))}const r=this.isColSelection()&&this.isRowSelection()?e:i;return new F(v.from(r),1,1)}replace(e,o=F.empty){const a=e.steps.length,n=this.ranges;for(let i=0;i<n.length;i++){const{$from:r,$to:l}=n[i],p=e.mapping.slice(a);e.replace(p.map(r.pos),p.map(l.pos),i?F.empty:o)}const s=x.findFrom(e.doc.resolve(e.mapping.slice(a).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,o){this.replace(e,new F(v.from(o),0,0))}forEachCell(e){const o=this.$anchorCell.node(-1),a=J.get(o),n=this.$anchorCell.start(-1),s=a.cellsInRect(a.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n));for(let i=0;i<s.length;i++)e(o.nodeAt(s[i]),n+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),o=this.$headCell.index(-1);if(Math.min(e,o)>0)return!1;const a=e+this.$anchorCell.nodeAfter.attrs.rowspan,n=o+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(a,n)==this.$headCell.node(-1).childCount}static colSelection(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),i=n.findCell(e.pos-s),r=n.findCell(o.pos-s),l=e.node(0);return i.top<=r.top?(i.top>0&&(e=l.resolve(s+n.map[i.left])),r.bottom<n.height&&(o=l.resolve(s+n.map[n.width*(n.height-1)+r.right-1]))):(r.top>0&&(o=l.resolve(s+n.map[r.left])),i.bottom<n.height&&(e=l.resolve(s+n.map[n.width*(n.height-1)+i.right-1]))),new Le(e,o)}isRowSelection(){const e=this.$anchorCell.node(-1),o=J.get(e),a=this.$anchorCell.start(-1),n=o.colCount(this.$anchorCell.pos-a),s=o.colCount(this.$headCell.pos-a);if(Math.min(n,s)>0)return!1;const i=n+this.$anchorCell.nodeAfter.attrs.colspan,r=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,r)==o.width}eq(e){return e instanceof Le&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),i=n.findCell(e.pos-s),r=n.findCell(o.pos-s),l=e.node(0);return i.left<=r.left?(i.left>0&&(e=l.resolve(s+n.map[i.top*n.width])),r.right<n.width&&(o=l.resolve(s+n.map[n.width*(r.top+1)-1]))):(r.left>0&&(o=l.resolve(s+n.map[r.top*n.width])),i.right<n.width&&(e=l.resolve(s+n.map[n.width*(i.top+1)-1]))),new Le(e,o)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,o){return new Le(e.resolve(o.anchor),e.resolve(o.head))}static create(e,o,a=o){return new Le(e.resolve(o),e.resolve(a))}getBookmark(){return new Xd(this.$anchorCell.pos,this.$headCell.pos)}};P.prototype.visible=!1,x.jsonID("cell",P);var Xd=class vp{constructor(e,o){this.anchor=e,this.head=o}map(e){return new vp(e.map(this.anchor),e.map(this.head))}resolve(e){const o=e.resolve(this.anchor),a=e.resolve(this.head);return o.parent.type.spec.tableRole=="row"&&a.parent.type.spec.tableRole=="row"&&o.index()<o.parent.childCount&&a.index()<a.parent.childCount&&Wn(o,a)?new P(o,a):x.near(a,1)}};function Yd(t){if(!(t.selection instanceof P))return null;const e=[];return t.selection.forEachCell((o,a)=>{e.push(he.node(a,a+o.nodeSize,{class:"selectedCell"}))}),X.create(t.doc,e)}function Qd({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let o=t.pos,a=e.pos,n=t.depth;for(;n>=0&&!(t.after(n+1)<t.end(n));n--,o++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,a--);return o==a&&/row|table/.test(t.node(n).type.spec.tableRole)}function Zd({$from:t,$to:e}){let o,a;for(let n=t.depth;n>0;n--){const s=t.node(n);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){o=s;break}}for(let n=e.depth;n>0;n--){const s=e.node(n);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){a=s;break}}return o!==a&&e.parentOffset===0}function eg(t,e,o){const a=(e||t).selection,n=(e||t).doc;let s,i;if(a instanceof C&&(i=a.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=P.create(n,a.from);else if(i=="row"){const r=n.resolve(a.from+1);s=P.rowSelection(r,r)}else if(!o){const r=J.get(a.node),l=a.from+1,p=l+r.map[r.width*r.height-1];s=P.create(n,l+1,p)}}else a instanceof E&&Qd(a)?s=E.create(n,a.from):a instanceof E&&Zd(a)&&(s=E.create(n,a.$from.start(),a.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}const tg=new Q("fix-tables");function cl(t,e,o,a){const n=t.childCount,s=e.childCount;e:for(let i=0,r=0;i<s;i++){const l=e.child(i);for(let p=r,c=Math.min(n,i+3);p<c;p++)if(t.child(p)==l){r=p+1,o+=l.nodeSize;continue e}a(l,o),r<n&&t.child(r).sameMarkup(l)?cl(t.child(r),l,o+1,a):l.nodesBetween(0,l.content.size,a,o+1),o+=l.nodeSize}}function ml(t,e){let o;const a=(n,s)=>{n.type.spec.tableRole=="table"&&(o=og(t,n,s,o))};return e?e.doc!=t.doc&&cl(e.doc,t.doc,0,a):t.doc.descendants(a),o}function og(t,e,o,a){const n=J.get(e);if(!n.problems)return a;a||(a=t.tr);const s=[];for(let l=0;l<n.height;l++)s.push(0);for(let l=0;l<n.problems.length;l++){const p=n.problems[l];if(p.type=="collision"){const c=e.nodeAt(p.pos);if(!c)continue;const m=c.attrs;for(let u=0;u<m.rowspan;u++)s[p.row+u]+=p.n;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,gt(m,m.colspan-p.n,p.n))}else if(p.type=="missing")s[p.row]+=p.n;else if(p.type=="overlong_rowspan"){const c=e.nodeAt(p.pos);if(!c)continue;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,{...c.attrs,rowspan:c.attrs.rowspan-p.n})}else if(p.type=="colwidth mismatch"){const c=e.nodeAt(p.pos);if(!c)continue;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,{...c.attrs,colwidth:p.colwidth})}else if(p.type=="zero_sized"){const c=a.mapping.map(o);a.delete(c,c+e.nodeSize)}}let i,r;for(let l=0;l<s.length;l++)s[l]&&(i==null&&(i=l),r=l);for(let l=0,p=o+1;l<n.height;l++){const c=e.child(l),m=p+c.nodeSize,u=s[l];if(u>0){let d="cell";c.firstChild&&(d=c.firstChild.type.spec.tableRole);const g=[];for(let h=0;h<u;h++){const b=le(t.schema)[d].createAndFill();b&&g.push(b)}const f=(l==0||i==l-1)&&r==l?p+1:m-1;a.insert(a.mapping.map(f),g)}p=m}return a.setMeta(tg,{fixTables:!0})}function Ie(t){const e=t.selection,o=qo(t),a=o.node(-1),n=o.start(-1),s=J.get(a);return{...e instanceof P?s.rectBetween(e.$anchorCell.pos-n,e.$headCell.pos-n):s.findCell(o.pos-n),tableStart:n,map:s,table:a}}function ul(t,{map:e,tableStart:o,table:a},n){let s=n>0?-1:0;Gd(e,a,n+s)&&(s=n==0||n==e.width?null:0);for(let i=0;i<e.height;i++){const r=i*e.width+n;if(n>0&&n<e.width&&e.map[r-1]==e.map[r]){const l=e.map[r],p=a.nodeAt(l);t.setNodeMarkup(t.mapping.map(o+l),null,pl(p.attrs,n-e.colCount(l))),i+=p.attrs.rowspan-1}else{const l=s==null?le(a.type.schema).cell:a.nodeAt(e.map[r+s]).type,p=e.positionAt(i,n,a);t.insert(t.mapping.map(o+p),l.createAndFill())}}return t}function ag(t,e){if(!_e(t))return!1;if(e){const o=Ie(t);e(ul(t.tr,o,o.left))}return!0}function ng(t,e){if(!_e(t))return!1;if(e){const o=Ie(t);e(ul(t.tr,o,o.right))}return!0}function sg(t,{map:e,table:o,tableStart:a},n){const s=t.mapping.maps.length;for(let i=0;i<e.height;){const r=i*e.width+n,l=e.map[r],p=o.nodeAt(l),c=p.attrs;if(n>0&&e.map[r-1]==l||n<e.width-1&&e.map[r+1]==l)t.setNodeMarkup(t.mapping.slice(s).map(a+l),null,gt(c,n-e.colCount(l)));else{const m=t.mapping.slice(s).map(a+l);t.delete(m,m+p.nodeSize)}i+=c.rowspan}}function ig(t,e){if(!_e(t))return!1;if(e){const o=Ie(t),a=t.tr;if(o.left==0&&o.right==o.map.width)return!1;for(let n=o.right-1;sg(a,o,n),n!=o.left;n--){const s=o.tableStart?a.doc.nodeAt(o.tableStart-1):a.doc;if(!s)throw new RangeError("No table found");o.table=s,o.map=J.get(s)}e(a)}return!0}function rg(t,e,o){var a;const n=le(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((a=e.nodeAt(t.map[s+o*t.width]))===null||a===void 0?void 0:a.type)!=n)return!1;return!0}function dl(t,{map:e,tableStart:o,table:a},n){let s=o;for(let p=0;p<n;p++)s+=a.child(p).nodeSize;const i=[];let r=n>0?-1:0;rg(e,a,n+r)&&(r=n==0||n==e.height?null:0);for(let p=0,c=e.width*n;p<e.width;p++,c++)if(n>0&&n<e.height&&e.map[c]==e.map[c-e.width]){const m=e.map[c],u=a.nodeAt(m).attrs;t.setNodeMarkup(o+m,null,{...u,rowspan:u.rowspan+1}),p+=u.colspan-1}else{var l;const m=r==null?le(a.type.schema).cell:(l=a.nodeAt(e.map[c+r*e.width]))===null||l===void 0?void 0:l.type,u=m==null?void 0:m.createAndFill();u&&i.push(u)}return t.insert(s,le(a.type.schema).row.create(null,i)),t}function lg(t,e){if(!_e(t))return!1;if(e){const o=Ie(t);e(dl(t.tr,o,o.top))}return!0}function pg(t,e){if(!_e(t))return!1;if(e){const o=Ie(t);e(dl(t.tr,o,o.bottom))}return!0}function cg(t,{map:e,table:o,tableStart:a},n){let s=0;for(let p=0;p<n;p++)s+=o.child(p).nodeSize;const i=s+o.child(n).nodeSize,r=t.mapping.maps.length;t.delete(s+a,i+a);const l=new Set;for(let p=0,c=n*e.width;p<e.width;p++,c++){const m=e.map[c];if(!l.has(m)){if(l.add(m),n>0&&m==e.map[c-e.width]){const u=o.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(r).map(m+a),null,{...u,rowspan:u.rowspan-1}),p+=u.colspan-1}else if(n<e.height&&m==e.map[c+e.width]){const u=o.nodeAt(m),d=u.attrs,g=u.type.create({...d,rowspan:u.attrs.rowspan-1},u.content),f=e.positionAt(n+1,p,o);t.insert(t.mapping.slice(r).map(a+f),g),p+=d.colspan-1}}}}function mg(t,e){if(!_e(t))return!1;if(e){const o=Ie(t),a=t.tr;if(o.top==0&&o.bottom==o.map.height)return!1;for(let n=o.bottom-1;cg(a,o,n),n!=o.top;n--){const s=o.tableStart?a.doc.nodeAt(o.tableStart-1):a.doc;if(!s)throw new RangeError("No table found");o.table=s,o.map=J.get(o.table)}e(a)}return!0}function gl(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function ug({width:t,height:e,map:o},a){let n=a.top*t+a.left,s=n,i=(a.bottom-1)*t+a.left,r=n+(a.right-a.left-1);for(let l=a.top;l<a.bottom;l++){if(a.left>0&&o[s]==o[s-1]||a.right<t&&o[r]==o[r+1])return!0;s+=t,r+=t}for(let l=a.left;l<a.right;l++){if(a.top>0&&o[n]==o[n-t]||a.bottom<e&&o[i]==o[i+t])return!0;n++,i++}return!1}function fl(t,e){const o=t.selection;if(!(o instanceof P)||o.$anchorCell.pos==o.$headCell.pos)return!1;const a=Ie(t),{map:n}=a;if(ug(n,a))return!1;if(e){const s=t.tr,i={};let r=v.empty,l,p;for(let c=a.top;c<a.bottom;c++)for(let m=a.left;m<a.right;m++){const u=n.map[c*n.width+m],d=a.table.nodeAt(u);if(!(i[u]||!d))if(i[u]=!0,l==null)l=u,p=d;else{gl(d)||(r=r.append(d.content));const g=s.mapping.map(u+a.tableStart);s.delete(g,g+d.nodeSize)}}if(l==null||p==null)return!0;if(s.setNodeMarkup(l+a.tableStart,null,{...pl(p.attrs,p.attrs.colspan,a.right-a.left-p.attrs.colspan),rowspan:a.bottom-a.top}),r.size>0){const c=l+1+p.content.size,m=gl(p)?l+1:c;s.replaceWith(m+a.tableStart,c+a.tableStart,r)}s.setSelection(new P(s.doc.resolve(l+a.tableStart))),e(s)}return!0}function hl(t,e){const o=le(t.schema);return dg(({node:a})=>o[a.type.spec.tableRole])(t,e)}function dg(t){return(e,o)=>{const a=e.selection;let n,s;if(a instanceof P){if(a.$anchorCell.pos!=a.$headCell.pos)return!1;n=a.$anchorCell.nodeAfter,s=a.$anchorCell.pos}else{var i;if(n=Kd(a.$from),!n)return!1;s=(i=dt(a.$from))===null||i===void 0?void 0:i.pos}if(n==null||s==null||n.attrs.colspan==1&&n.attrs.rowspan==1)return!1;if(o){let r=n.attrs;const l=[],p=r.colwidth;r.rowspan>1&&(r={...r,rowspan:1}),r.colspan>1&&(r={...r,colspan:1});const c=Ie(e),m=e.tr;for(let d=0;d<c.right-c.left;d++)l.push(p?{...r,colwidth:p&&p[d]?[p[d]]:null}:r);let u;for(let d=c.top;d<c.bottom;d++){let g=c.map.positionAt(d,c.left,c.table);d==c.top&&(g+=n.nodeSize);for(let f=c.left,h=0;f<c.right;f++,h++)f==c.left&&d==c.top||m.insert(u=m.mapping.map(g+c.tableStart,1),t({node:n,row:d,col:f}).createAndFill(l[h]))}m.setNodeMarkup(s,t({node:n,row:c.top,col:c.left}),l[0]),a instanceof P&&m.setSelection(new P(m.doc.resolve(a.$anchorCell.pos),u?m.doc.resolve(u):void 0)),o(m)}return!0}}function gg(t,e){return function(o,a){if(!_e(o))return!1;const n=qo(o);if(n.nodeAfter.attrs[t]===e)return!1;if(a){const s=o.tr;o.selection instanceof P?o.selection.forEachCell((i,r)=>{i.attrs[t]!==e&&s.setNodeMarkup(r,null,{...i.attrs,[t]:e})}):s.setNodeMarkup(n.pos,null,{...n.nodeAfter.attrs,[t]:e}),a(s)}return!0}}function fg(t){return function(e,o){if(!_e(e))return!1;if(o){const a=le(e.schema),n=Ie(e),s=e.tr,i=n.map.cellsInRect(t=="column"?{left:n.left,top:0,right:n.right,bottom:n.map.height}:t=="row"?{left:0,top:n.top,right:n.map.width,bottom:n.bottom}:n),r=i.map(l=>n.table.nodeAt(l));for(let l=0;l<i.length;l++)r[l].type==a.header_cell&&s.setNodeMarkup(n.tableStart+i[l],a.cell,r[l].attrs);if(s.steps.length===0)for(let l=0;l<i.length;l++)s.setNodeMarkup(n.tableStart+i[l],a.header_cell,r[l].attrs);o(s)}return!0}}function bl(t,e,o){const a=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let n=0;n<a.length;n++){const s=e.table.nodeAt(a[n]);if(s&&s.type!==o.header_cell)return!1}return!0}function Kt(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?fg(t):function(o,a){if(!_e(o))return!1;if(a){const n=le(o.schema),s=Ie(o),i=o.tr,r=bl("row",s,n),l=bl("column",s,n),p=(t==="column"?r:t==="row"&&l)?1:0,c=t=="column"?{left:0,top:p,right:1,bottom:s.map.height}:t=="row"?{left:p,top:0,right:s.map.width,bottom:1}:s,m=t=="column"?l?n.cell:n.header_cell:t=="row"?r?n.cell:n.header_cell:n.cell;s.map.cellsInRect(c).forEach(u=>{const d=u+s.tableStart,g=i.doc.nodeAt(d);g&&i.setNodeMarkup(d,m,g.attrs)}),a(i)}return!0}}Kt("row",{useDeprecatedLogic:!0}),Kt("column",{useDeprecatedLogic:!0});const hg=Kt("cell",{useDeprecatedLogic:!0});function bg(t,e){if(e<0){const o=t.nodeBefore;if(o)return t.pos-o.nodeSize;for(let a=t.index(-1)-1,n=t.before();a>=0;a--){const s=t.node(-1).child(a),i=s.lastChild;if(i)return n-1-i.nodeSize;n-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const o=t.node(-1);for(let a=t.indexAfter(-1),n=t.after();a<o.childCount;a++){const s=o.child(a);if(s.childCount)return n+1;n+=s.nodeSize}}return null}function jl(t){return function(e,o){if(!_e(e))return!1;const a=bg(qo(e),t);if(a==null)return!1;if(o){const n=e.doc.resolve(a);o(e.tr.setSelection(E.between(n,Jd(n))).scrollIntoView())}return!0}}function jg(t,e){const o=t.selection.$anchor;for(let a=o.depth;a>0;a--)if(o.node(a).type.spec.tableRole=="table")return e&&e(t.tr.delete(o.before(a),o.after(a)).scrollIntoView()),!0;return!1}function Wo(t,e){const o=t.selection;if(!(o instanceof P))return!1;if(e){const a=t.tr,n=le(t.schema).cell.createAndFill().content;o.forEachCell((s,i)=>{s.content.eq(n)||a.replace(a.mapping.map(i+1),a.mapping.map(i+s.nodeSize-1),new F(n,0,0))}),a.docChanged&&e(a)}return!0}function vg(t){if(t.size===0)return null;let{content:e,openStart:o,openEnd:a}=t;for(;e.childCount==1&&(o>0&&a>0||e.child(0).type.spec.tableRole=="table");)o--,a--,e=e.child(0).content;const n=e.child(0),s=n.type.spec.tableRole,i=n.type.schema,r=[];if(s=="row")for(let l=0;l<e.childCount;l++){let p=e.child(l).content;const c=l?0:Math.max(0,o-1),m=l<e.childCount-1?0:Math.max(0,a-1);(c||m)&&(p=Un(le(i).row,new F(p,c,m)).content),r.push(p)}else if(s=="cell"||s=="header_cell")r.push(o||a?Un(le(i).row,new F(e,o,a)).content:e);else return null;return kg(i,r)}function kg(t,e){const o=[];for(let n=0;n<e.length;n++){const s=e[n];for(let i=s.childCount-1;i>=0;i--){const{rowspan:r,colspan:l}=s.child(i).attrs;for(let p=n;p<n+r;p++)o[p]=(o[p]||0)+l}}let a=0;for(let n=0;n<o.length;n++)a=Math.max(a,o[n]);for(let n=0;n<o.length;n++)if(n>=e.length&&e.push(v.empty),o[n]<a){const s=le(t).cell.createAndFill(),i=[];for(let r=o[n];r<a;r++)i.push(s);e[n]=e[n].append(v.from(i))}return{height:e.length,width:a,rows:e}}function Un(t,e){const o=t.createAndFill();return new vi(o).replace(0,o.content.size,e).doc}function Fg({width:t,height:e,rows:o},a,n){if(t!=a){const s=[],i=[];for(let r=0;r<o.length;r++){const l=o[r],p=[];for(let c=s[r]||0,m=0;c<a;m++){let u=l.child(m%l.childCount);c+u.attrs.colspan>a&&(u=u.type.createChecked(gt(u.attrs,u.attrs.colspan,c+u.attrs.colspan-a),u.content)),p.push(u),c+=u.attrs.colspan;for(let d=1;d<u.attrs.rowspan;d++)s[r+d]=(s[r+d]||0)+u.attrs.colspan}i.push(v.from(p))}o=i,t=a}if(e!=n){const s=[];for(let i=0,r=0;i<n;i++,r++){const l=[],p=o[r%e];for(let c=0;c<p.childCount;c++){let m=p.child(c);i+m.attrs.rowspan>n&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,n-m.attrs.rowspan)},m.content)),l.push(m)}s.push(v.from(l))}o=s,e=n}return{width:t,height:e,rows:o}}function yg(t,e,o,a,n,s,i){const r=t.doc.type.schema,l=le(r);let p,c;if(n>e.width)for(let m=0,u=0;m<e.height;m++){const d=o.child(m);u+=d.nodeSize;const g=[];let f;d.lastChild==null||d.lastChild.type==l.cell?f=p||(p=l.cell.createAndFill()):f=c||(c=l.header_cell.createAndFill());for(let h=e.width;h<n;h++)g.push(f);t.insert(t.mapping.slice(i).map(u-1+a),g)}if(s>e.height){const m=[];for(let g=0,f=(e.height-1)*e.width;g<Math.max(e.width,n);g++){const h=g>=e.width?!1:o.nodeAt(e.map[f+g]).type==l.header_cell;m.push(h?c||(c=l.header_cell.createAndFill()):p||(p=l.cell.createAndFill()))}const u=l.row.create(null,v.from(m)),d=[];for(let g=e.height;g<s;g++)d.push(u);t.insert(t.mapping.slice(i).map(a+o.nodeSize-2),d)}return!!(p||c)}function vl(t,e,o,a,n,s,i,r){if(i==0||i==e.height)return!1;let l=!1;for(let p=n;p<s;p++){const c=i*e.width+p,m=e.map[c];if(e.map[c-e.width]==m){l=!0;const u=o.nodeAt(m),{top:d,left:g}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(r).map(m+a),null,{...u.attrs,rowspan:i-d}),t.insert(t.mapping.slice(r).map(e.positionAt(i,g,o)),u.type.createAndFill({...u.attrs,rowspan:d+u.attrs.rowspan-i})),p+=u.attrs.colspan-1}}return l}function kl(t,e,o,a,n,s,i,r){if(i==0||i==e.width)return!1;let l=!1;for(let p=n;p<s;p++){const c=p*e.width+i,m=e.map[c];if(e.map[c-1]==m){l=!0;const u=o.nodeAt(m),d=e.colCount(m),g=t.mapping.slice(r).map(m+a);t.setNodeMarkup(g,null,gt(u.attrs,i-d,u.attrs.colspan-(i-d))),t.insert(g+u.nodeSize,u.type.createAndFill(gt(u.attrs,0,i-d))),p+=u.attrs.rowspan-1}}return l}function Fl(t,e,o,a,n){let s=o?t.doc.nodeAt(o-1):t.doc;if(!s)throw new Error("No table found");let i=J.get(s);const{top:r,left:l}=a,p=l+n.width,c=r+n.height,m=t.tr;let u=0;function d(){if(s=o?m.doc.nodeAt(o-1):m.doc,!s)throw new Error("No table found");i=J.get(s),u=m.mapping.maps.length}yg(m,i,s,o,p,c,u)&&d(),vl(m,i,s,o,l,p,r,u)&&d(),vl(m,i,s,o,l,p,c,u)&&d(),kl(m,i,s,o,r,c,l,u)&&d(),kl(m,i,s,o,r,c,p,u)&&d();for(let g=r;g<c;g++){const f=i.positionAt(g,l,s),h=i.positionAt(g,p,s);m.replace(m.mapping.slice(u).map(f+o),m.mapping.slice(u).map(h+o),new F(n.rows[g-r],0,0))}d(),m.setSelection(new P(m.doc.resolve(o+i.positionAt(r,l,s)),m.doc.resolve(o+i.positionAt(c-1,p-1,s)))),e(m)}const _g=wr({ArrowLeft:Ko("horiz",-1),ArrowRight:Ko("horiz",1),ArrowUp:Ko("vert",-1),ArrowDown:Ko("vert",1),"Shift-ArrowLeft":Vo("horiz",-1),"Shift-ArrowRight":Vo("horiz",1),"Shift-ArrowUp":Vo("vert",-1),"Shift-ArrowDown":Vo("vert",1),Backspace:Wo,"Mod-Backspace":Wo,Delete:Wo,"Mod-Delete":Wo});function Uo(t,e,o){return o.eq(t.selection)?!1:(e&&e(t.tr.setSelection(o).scrollIntoView()),!0)}function Ko(t,e){return(o,a,n)=>{if(!n)return!1;const s=o.selection;if(s instanceof P)return Uo(o,a,x.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const i=yl(n,t,e);if(i==null)return!1;if(t=="horiz")return Uo(o,a,x.near(o.doc.resolve(s.head+e),e));{const r=o.doc.resolve(i),l=ll(r,t,e);let p;return l?p=x.near(l,1):e<0?p=x.near(o.doc.resolve(r.before(-1)),-1):p=x.near(o.doc.resolve(r.after(-1)),1),Uo(o,a,p)}}}function Vo(t,e){return(o,a,n)=>{if(!n)return!1;const s=o.selection;let i;if(s instanceof P)i=s;else{const l=yl(n,t,e);if(l==null)return!1;i=new P(o.doc.resolve(l))}const r=ll(i.$headCell,t,e);return r?Uo(o,a,new P(i.$anchorCell,r)):!1}}function Dg(t,e){const o=t.state.doc,a=dt(o.resolve(e));return a?(t.dispatch(t.state.tr.setSelection(new P(a))),!0):!1}function wg(t,e,o){if(!_e(t.state))return!1;let a=vg(o);const n=t.state.selection;if(n instanceof P){a||(a={width:1,height:1,rows:[v.from(Un(le(t.state.schema).cell,o))]});const s=n.$anchorCell.node(-1),i=n.$anchorCell.start(-1),r=J.get(s).rectBetween(n.$anchorCell.pos-i,n.$headCell.pos-i);return a=Fg(a,r.right-r.left,r.bottom-r.top),Fl(t.state,t.dispatch,i,r,a),!0}else if(a){const s=qo(t.state),i=s.start(-1);return Fl(t.state,t.dispatch,i,J.get(s.node(-1)).findCell(s.pos-i),a),!0}else return!1}function Ig(t,e){var o;if(e.button!=0||e.ctrlKey||e.metaKey)return;const a=_l(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof P)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&a&&(n=dt(t.state.selection.$anchor))!=null&&((o=Kn(t,e))===null||o===void 0?void 0:o.pos)!=n.pos)s(n,e),e.preventDefault();else if(!a)return;function s(l,p){let c=Kn(t,p);const m=Je.getState(t.state)==null;if(!c||!Wn(l,c))if(m)c=l;else return;const u=new P(l,c);if(m||!t.state.selection.eq(u)){const d=t.state.tr.setSelection(u);m&&d.setMeta(Je,l.pos),t.dispatch(d)}}function i(){t.root.removeEventListener("mouseup",i),t.root.removeEventListener("dragstart",i),t.root.removeEventListener("mousemove",r),Je.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Je,-1))}function r(l){const p=l,c=Je.getState(t.state);let m;if(c!=null)m=t.state.doc.resolve(c);else if(_l(t,p.target)!=a&&(m=Kn(t,e),!m))return i();m&&s(m,p)}t.root.addEventListener("mouseup",i),t.root.addEventListener("dragstart",i),t.root.addEventListener("mousemove",r)}function yl(t,e,o){if(!(t.state.selection instanceof E))return null;const{$head:a}=t.state.selection;for(let n=a.depth-1;n>=0;n--){const s=a.node(n);if((o<0?a.index(n):a.indexAfter(n))!=(o<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const i=a.before(n),r=e=="vert"?o>0?"down":"up":o>0?"right":"left";return t.endOfTextblock(r)?i:null}}return null}function _l(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Kn(t,e){const o=t.posAtCoords({left:e.clientX,top:e.clientY});if(!o)return null;let{inside:a,pos:n}=o;return a>=0&&dt(t.state.doc.resolve(a))||dt(t.state.doc.resolve(n))}var Cg=class{constructor(e,o){this.node=e,this.defaultCellMinWidth=o,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",`${o}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Vn(e,this.colgroup,this.table,o),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Vn(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Vn(t,e,o,a,n,s){let i=0,r=!0,l=e.firstChild;const p=t.firstChild;if(p){for(let m=0,u=0;m<p.childCount;m++){const{colspan:d,colwidth:g}=p.child(m).attrs;for(let f=0;f<d;f++,u++){const h=n==u?s:g&&g[f],b=h?h+"px":"";if(i+=h||a,h||(r=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const j=document.createElement("col");j.style.width=b,e.appendChild(j)}}}for(;l;){var c;const m=l.nextSibling;(c=l.parentNode)===null||c===void 0||c.removeChild(l),l=m}r?(o.style.width=i+"px",o.style.minWidth=""):(o.style.width="",o.style.minWidth=i+"px")}}const be=new Q("tableColumnResizing");function Eg({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:o=100,View:a=Cg,lastColumnResizable:n=!0}={}){const s=new se({key:be,state:{init(i,r){var l;const p=(l=s.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,c=le(r.schema).table.name;return a&&p&&(p[c]=(m,u)=>new a(m,o,u)),new Ag(-1,!1)},apply(i,r){return r.apply(i)}},props:{attributes:i=>{const r=be.getState(i);return r&&r.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,r)=>{xg(i,r,t,n)},mouseleave:i=>{Sg(i)},mousedown:(i,r)=>{Tg(i,r,e,o)}},decorations:i=>{const r=be.getState(i);if(r&&r.activeHandle>-1)return Ng(i,r.activeHandle)},nodeViews:{}}});return s}var Ag=class Ba{constructor(e,o){this.activeHandle=e,this.dragging=o}apply(e){const o=this,a=e.getMeta(be);if(a&&a.setHandle!=null)return new Ba(a.setHandle,!1);if(a&&a.setDragging!==void 0)return new Ba(o.activeHandle,a.setDragging);if(o.activeHandle>-1&&e.docChanged){let n=e.mapping.map(o.activeHandle,-1);return qn(e.doc.resolve(n))||(n=-1),new Ba(n,o.dragging)}return o}};function xg(t,e,o,a){if(!t.editable)return;const n=be.getState(t.state);if(n&&!n.dragging){const s=Bg(e.target);let i=-1;if(s){const{left:r,right:l}=s.getBoundingClientRect();e.clientX-r<=o?i=Dl(t,e,"left",o):l-e.clientX<=o&&(i=Dl(t,e,"right",o))}if(i!=n.activeHandle){if(!a&&i!==-1){const r=t.state.doc.resolve(i),l=r.node(-1),p=J.get(l),c=r.start(-1);if(p.colCount(r.pos-c)+r.nodeAfter.attrs.colspan-1==p.width-1)return}Il(t,i)}}}function Sg(t){if(!t.editable)return;const e=be.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Il(t,-1)}function Tg(t,e,o,a){var n;if(!t.editable)return!1;const s=(n=t.dom.ownerDocument.defaultView)!==null&&n!==void 0?n:window,i=be.getState(t.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const r=t.state.doc.nodeAt(i.activeHandle),l=Mg(t,i.activeHandle,r.attrs);t.dispatch(t.state.tr.setMeta(be,{setDragging:{startX:e.clientX,startWidth:l}}));function p(m){s.removeEventListener("mouseup",p),s.removeEventListener("mousemove",c);const u=be.getState(t.state);u!=null&&u.dragging&&(Rg(t,u.activeHandle,wl(u.dragging,m,o)),t.dispatch(t.state.tr.setMeta(be,{setDragging:null})))}function c(m){if(!m.which)return p(m);const u=be.getState(t.state);if(u&&u.dragging){const d=wl(u.dragging,m,o);Cl(t,u.activeHandle,d,a)}}return Cl(t,i.activeHandle,l,a),s.addEventListener("mouseup",p),s.addEventListener("mousemove",c),e.preventDefault(),!0}function Mg(t,e,{colspan:o,colwidth:a}){const n=a&&a[a.length-1];if(n)return n;const s=t.domAtPos(e);let i=s.node.childNodes[s.offset].offsetWidth,r=o;if(a)for(let l=0;l<o;l++)a[l]&&(i-=a[l],r--);return i/r}function Bg(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Dl(t,e,o,a){const n=o=="right"?-a:a,s=t.posAtCoords({left:e.clientX+n,top:e.clientY});if(!s)return-1;const{pos:i}=s,r=dt(t.state.doc.resolve(i));if(!r)return-1;if(o=="right")return r.pos;const l=J.get(r.node(-1)),p=r.start(-1),c=l.map.indexOf(r.pos-p);return c%l.width==0?-1:p+l.map[c-1]}function wl(t,e,o){const a=e.clientX-t.startX;return Math.max(o,t.startWidth+a)}function Il(t,e){t.dispatch(t.state.tr.setMeta(be,{setHandle:e}))}function Rg(t,e,o){const a=t.state.doc.resolve(e),n=a.node(-1),s=J.get(n),i=a.start(-1),r=s.colCount(a.pos-i)+a.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let p=0;p<s.height;p++){const c=p*s.width+r;if(p&&s.map[c]==s.map[c-s.width])continue;const m=s.map[c],u=n.nodeAt(m).attrs,d=u.colspan==1?0:r-s.colCount(m);if(u.colwidth&&u.colwidth[d]==o)continue;const g=u.colwidth?u.colwidth.slice():Lg(u.colspan);g[d]=o,l.setNodeMarkup(i+m,null,{...u,colwidth:g})}l.docChanged&&t.dispatch(l)}function Cl(t,e,o,a){const n=t.state.doc.resolve(e),s=n.node(-1),i=n.start(-1),r=J.get(s).colCount(n.pos-i)+n.nodeAfter.attrs.colspan-1;let l=t.domAtPos(n.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Vn(s,l.firstChild,l,a,r,o)}function Lg(t){return Array(t).fill(0)}function Ng(t,e){const o=[],a=t.doc.resolve(e),n=a.node(-1);if(!n)return X.empty;const s=J.get(n),i=a.start(-1),r=s.colCount(a.pos-i)+a.nodeAfter.attrs.colspan-1;for(let p=0;p<s.height;p++){const c=r+p*s.width;if((r==s.width-1||s.map[c]!=s.map[c+1])&&(p==0||s.map[c]!=s.map[c-s.width])){var l;const m=s.map[c],u=i+m+n.nodeAt(m).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",!((l=be.getState(t))===null||l===void 0)&&l.dragging&&o.push(he.node(i+m,i+m+n.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),o.push(he.widget(u,d))}}return X.create(t.doc,o)}function zg({allowTableNodeSelection:t=!1}={}){return new se({key:Je,state:{init(){return null},apply(e,o){const a=e.getMeta(Je);if(a!=null)return a==-1?null:a;if(o==null||!e.docChanged)return o;const{deleted:n,pos:s}=e.mapping.mapResult(o);return n?null:s}},props:{decorations:Yd,handleDOMEvents:{mousedown:Ig},createSelectionBetween(e){return Je.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Dg,handleKeyDown:_g,handlePaste:wg},appendTransaction(e,o,a){return eg(a,ml(a,o),t)}})}var El=K.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,o;const a=t.getAttribute("colwidth"),n=a?a.split(",").map(s=>parseInt(s,10)):null;if(!n){const s=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),i=Array.from(((o=t.parentElement)==null?void 0:o.children)||[]).indexOf(t);if(i&&i>-1&&s&&s[i]){const r=s[i].getAttribute("width");return r?[parseInt(r,10)]:null}}return n}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",R(this.options.HTMLAttributes,t),0]}}),Al=K.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(a=>parseInt(a,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",R(this.options.HTMLAttributes,t),0]}}),xl=K.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",R(this.options.HTMLAttributes,t),0]}});function Jn(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Sl(t,e,o,a,n,s){var i;let r=0,l=!0,p=e.firstChild;const c=t.firstChild;if(c!==null)for(let u=0,d=0;u<c.childCount;u+=1){const{colspan:g,colwidth:f}=c.child(u).attrs;for(let h=0;h<g;h+=1,d+=1){const b=n===d?s:f&&f[h],j=b?`${b}px`:"";if(r+=b||a,b||(l=!1),p){if(p.style.width!==j){const[D,w]=Jn(a,b);p.style.setProperty(D,w)}p=p.nextSibling}else{const D=document.createElement("col"),[w,y]=Jn(a,b);D.style.setProperty(w,y),e.appendChild(D)}}}for(;p;){const u=p.nextSibling;(i=p.parentNode)==null||i.removeChild(p),p=u}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!m?(o.style.width=`${r}px`,o.style.minWidth=""):(o.style.width="",o.style.minWidth=`${r}px`)}var Og=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,Sl(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,o=this.dom.contains(e),a=this.contentDOM.contains(e);return!!(o&&!a&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function $g(t,e,o,a){let n=0,s=!0;const i=[],r=t.firstChild;if(!r)return{};for(let m=0,u=0;m<r.childCount;m+=1){const{colspan:d,colwidth:g}=r.child(m).attrs;for(let f=0;f<d;f+=1,u+=1){const h=o===u?a:g&&g[f];n+=h||e,h||(s=!1);const[b,j]=Jn(e,h);i.push(["col",{style:`${b}: ${j}`}])}}const l=s?`${n}px`:"",p=s?"":`${n}px`;return{colgroup:["colgroup",{},...i],tableWidth:l,tableMinWidth:p}}function Tl(t,e){return t.createAndFill()}function Pg(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(o=>{const a=t.nodes[o];a.spec.tableRole&&(e[a.spec.tableRole]=a)}),t.cached.tableNodeTypes=e,e}function Hg(t,e,o,a,n){const s=Pg(t),i=[],r=[];for(let p=0;p<o;p+=1){const c=Tl(s.cell);if(c&&r.push(c),a){const m=Tl(s.header_cell);m&&i.push(m)}}const l=[];for(let p=0;p<e;p+=1)l.push(s.row.createChecked(null,a&&p===0?i:r));return s.table.createChecked(null,l)}function qg(t){return t instanceof P}var Jo=({editor:t})=>{const{selection:e}=t.state;if(!qg(e))return!1;let o=0;const a=Nr(e.ranges[0].$from,s=>s.type.name==="table");return a==null||a.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(o+=1)}),o===e.ranges.length?(t.commands.deleteTable(),!0):!1},Wg="";function Ug(t){return(t||"").replace(/\s+/g," ").trim()}function Kg(t,e,o={}){var a;const n=(a=o.cellLineSeparator)!=null?a:Wg;if(!t||!t.content||t.content.length===0)return"";const s=[];t.content.forEach(g=>{const f=[];g.content&&g.content.forEach(h=>{let b="";h.content&&Array.isArray(h.content)&&h.content.length>1?b=h.content.map(y=>e.renderChildren(y)).join(n):b=h.content?e.renderChildren(h.content):"";const j=Ug(b),D=h.type==="tableHeader";f.push({text:j,isHeader:D})}),s.push(f)});const i=s.reduce((g,f)=>Math.max(g,f.length),0);if(i===0)return"";const r=new Array(i).fill(0);s.forEach(g=>{var f;for(let h=0;h<i;h+=1){const j=(((f=g[h])==null?void 0:f.text)||"").length;j>r[h]&&(r[h]=j),r[h]<3&&(r[h]=3)}});const l=(g,f)=>g+" ".repeat(Math.max(0,f-g.length)),p=s[0],c=p.some(g=>g.isHeader);let m=`
|
|
44
44
|
`;const u=new Array(i).fill(0).map((g,f)=>c&&p[f]&&p[f].text||"");return m+=`| ${u.map((g,f)=>l(g,r[f])).join(" | ")} |
|
|
45
45
|
`,m+=`| ${r.map(g=>"-".repeat(Math.max(3,g))).join(" | ")} |
|
|
46
46
|
`,(c?s.slice(1):s).forEach(g=>{m+=`| ${new Array(i).fill(0).map((f,h)=>l(g[h]&&g[h].text||"",r[h])).join(" | ")} |
|
package/dist/storyblok-js.mjs
CHANGED
|
@@ -10027,7 +10027,7 @@ class ee extends x {
|
|
|
10027
10027
|
*/
|
|
10028
10028
|
static valid(e) {
|
|
10029
10029
|
let o = e.parent;
|
|
10030
|
-
if (o.
|
|
10030
|
+
if (o.inlineContent || !Ld(e) || !Nd(e))
|
|
10031
10031
|
return !1;
|
|
10032
10032
|
let a = o.type.spec.allowGapCursor;
|
|
10033
10033
|
if (a != null)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "SDK to integrate Storyblok into your project using JavaScript.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@storyblok/richtext": "4.1.
|
|
31
|
+
"@storyblok/richtext": "4.1.1",
|
|
32
32
|
"storyblok-js-client": "7.3.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|