/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../prosemirror-state/dist/index.js"),e=require("../../prosemirror-model/dist/index.js"),o=require("../../prosemirror-view/dist/index.js"),n=require("../../prosemirror-keymap/dist/index.js"),l=require("../../prosemirror-transform/dist/index.js");let r,s;if("undefined"!=typeof WeakMap){let t=new WeakMap;r=e=>t.get(e),s=(e,o)=>(t.set(e,o),o)}else{const t=[],e=10;let o=0;r=e=>{for(let o=0;o<t.length;o+=2)if(t[o]==e)return t[o+1]},s=(n,l)=>(o==e&&(o=0),t[o++]=n,t[o++]=l)}var i=class{constructor(t,e,o,n){this.width=t,this.height=e,this.map=o,this.problems=n}findCell(t){for(let e=0;e<this.map.length;e++){const o=this.map[e];if(o!=t)continue;const n=e%this.width,l=e/this.width|0;let r=n+1,s=l+1;for(let t=1;r<this.width&&this.map[e+t]==o;t++)r++;for(let t=1;s<this.height&&this.map[e+this.width*t]==o;t++)s++;return{left:n,top:l,right:r,bottom:s}}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:n,right:l,top:r,bottom:s}=this.findCell(t);return"horiz"==e?(o<0?0==n:l==this.width)?null:this.map[r*this.width+(o<0?n-1:l)]:(o<0?0==r:s==this.height)?null:this.map[n+this.width*(o<0?r-1:s)]}rectBetween(t,e){const{left:o,right:n,top:l,bottom:r}=this.findCell(t),{left:s,right:i,top:c,bottom:a}=this.findCell(e);return{left:Math.min(o,s),top:Math.min(l,c),right:Math.max(n,i),bottom:Math.max(r,a)}}cellsInRect(t){const e=[],o={};for(let n=t.top;n<t.bottom;n++)for(let l=t.left;l<t.right;l++){const r=n*this.width+l,s=this.map[r];o[s]||(o[s]=!0,l==t.left&&l&&this.map[r-1]==s||n==t.top&&n&&this.map[r-this.width]==s||e.push(s))}return e}positionAt(t,e,o){for(let n=0,l=0;;n++){const r=l+o.child(n).nodeSize;if(n==t){let o=e+t*this.width;const n=(t+1)*this.width;for(;o<n&&this.map[o]<l;)o++;return o==n?r-1:this.map[o]}l=r}}static get(t){return r(t)||s(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,o=!1;for(let n=0;n<t.childCount;n++){const l=t.child(n);let r=0;if(o)for(let e=0;e<n;e++){const o=t.child(e);for(let t=0;t<o.childCount;t++){const l=o.child(t);e+l.attrs.rowspan>n&&(r+=l.attrs.colspan)}}for(let t=0;t<l.childCount;t++){const e=l.child(t);r+=e.attrs.colspan,e.attrs.rowspan>1&&(o=!0)}-1==e?e=r:e!=r&&(e=Math.max(e,r))}return e}(t),o=t.childCount,n=[];let l=0,r=null;const s=[];for(let i=0,c=e*o;i<c;i++)n[i]=0;for(let i=0,c=0;i<o;i++){const a=t.child(i);c++;for(let t=0;;t++){for(;l<n.length&&0!=n[l];)l++;if(t==a.childCount)break;const p=a.child(t),{colspan:d,rowspan:h,colwidth:f}=p.attrs;for(let t=0;t<h;t++){if(t+i>=o){(r||(r=[])).push({type:"overlong_rowspan",pos:c,n:h-t});break}const a=l+t*e;for(let t=0;t<d;t++){0==n[a+t]?n[a+t]=c:(r||(r=[])).push({type:"collision",row:i,pos:c,n:d-t});const o=f&&f[t];if(o){const n=(a+t)%e*2,l=s[n];null==l||l!=o&&1==s[n+1]?(s[n]=o,s[n+1]=1):l==o&&s[n+1]++}}}l+=d,c+=p.nodeSize}const p=(i+1)*e;let d=0;for(;l<p;)0==n[l++]&&d++;d&&(r||(r=[])).push({type:"missing",row:i,n:d}),c++}0!==e&&0!==o||(r||(r=[])).push({type:"zero_sized"});const a=new i(e,o,n,r);let p=!1;for(let i=0;!p&&i<s.length;i+=2)null!=s[i]&&s[i+1]<o&&(p=!0);p&&function(t,e,o){t.problems||(t.problems=[]);const n={};for(let l=0;l<t.map.length;l++){const r=t.map[l];if(n[r])continue;n[r]=!0;const s=o.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let i=null;const a=s.attrs;for(let o=0;o<a.colspan;o++){const n=e[(l+o)%t.width*2];null==n||a.colwidth&&a.colwidth[o]==n||((i||(i=c(a)))[o]=n)}i&&t.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:i})}}(a,s,t);return a}(t))}};function c(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let o=0;o<t.colspan;o++)e.push(0);return e}function a(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const o in t.nodes){const n=t.nodes[o],l=n.spec.tableRole;l&&(e[l]=n)}}return e}const p=new t.PluginKey("selectingCells");function d(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function h(t){const e=t.selection.$head;for(let o=e.depth;o>0;o--)if("row"==e.node(o).type.spec.tableRole)return!0;return!1}function f(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&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const o=d(e.$head)||u(e.$head);if(o)return o;throw new RangeError(`No cell found around position ${e.head}`)}function u(t){for(let e=t.nodeAfter,o=t.pos;e;e=e.firstChild,o++){const n=e.type.spec.tableRole;if("cell"==n||"header_cell"==n)return t.doc.resolve(o)}for(let e=t.nodeBefore,o=t.pos;e;e=e.lastChild,o--){const n=e.type.spec.tableRole;if("cell"==n||"header_cell"==n)return t.doc.resolve(o-e.nodeSize)}}function m(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function w(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function g(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function C(t,e,o){const n=t.node(-1),l=i.get(n),r=t.start(-1),s=l.nextCell(t.pos-r,e,o);return null==s?null:t.node(0).resolve(r+s)}function b(t,e,o=1){const n={...t,colspan:t.colspan-o};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(e,o),n.colwidth.some(t=>t>0)||(n.colwidth=null)),n}function v(t,e,o=1){const n={...t,colspan:t.colspan+o};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let t=0;t<o;t++)n.colwidth.splice(e,0,0)}return n}function S(t,e,o){const n=a(e.type.schema).header_cell;for(let l=0;l<t.height;l++)if(e.nodeAt(t.map[o+l*t.width]).type!=n)return!1;return!0}var y=class o extends t.Selection{constructor(e,o=e){const n=e.node(-1),l=i.get(n),r=e.start(-1),s=l.rectBetween(e.pos-r,o.pos-r),c=e.node(0),a=l.cellsInRect(s).filter(t=>t!=o.pos-r);a.unshift(o.pos-r);const p=a.map(e=>{const o=n.nodeAt(e);if(!o)throw new RangeError(`No cell with offset ${e} found`);const l=r+e+1;return new t.SelectionRange(c.resolve(l),c.resolve(l+o.content.size))});super(p[0].$from,p[0].$to,p),this.$anchorCell=e,this.$headCell=o}map(e,n){const l=e.resolve(n.map(this.$anchorCell.pos)),r=e.resolve(n.map(this.$headCell.pos));if(m(l)&&m(r)&&g(l,r)){const t=this.$anchorCell.node(-1)!=l.node(-1);return t&&this.isRowSelection()?o.rowSelection(l,r):t&&this.isColSelection()?o.colSelection(l,r):new o(l,r)}return t.TextSelection.between(l,r)}content(){const t=this.$anchorCell.node(-1),o=i.get(t),n=this.$anchorCell.start(-1),l=o.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},s=[];for(let i=l.top;i<l.bottom;i++){const n=[];for(let e=i*o.width+l.left,s=l.left;s<l.right;s++,e++){const s=o.map[e];if(r[s])continue;r[s]=!0;const i=o.findCell(s);let c=t.nodeAt(s);if(!c)throw new RangeError(`No cell with offset ${s} found`);const a=l.left-i.left,p=i.right-l.right;if(a>0||p>0){let t=c.attrs;if(a>0&&(t=b(t,0,a)),p>0&&(t=b(t,t.colspan-p,p)),i.left<l.left){if(c=c.type.createAndFill(t),!c)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else c=c.type.create(t,c.content)}if(i.top<l.top||i.bottom>l.bottom){const t={...c.attrs,rowspan:Math.min(i.bottom,l.bottom)-Math.max(i.top,l.top)};c=i.top<l.top?c.type.createAndFill(t):c.type.create(t,c.content)}n.push(c)}s.push(t.child(i).copy(e.Fragment.from(n)))}const c=this.isColSelection()&&this.isRowSelection()?t:s;return new e.Slice(e.Fragment.from(c),1,1)}replace(o,n=e.Slice.empty){const l=o.steps.length,r=this.ranges;for(let t=0;t<r.length;t++){const{$from:s,$to:i}=r[t],c=o.mapping.slice(l);o.replace(c.map(s.pos),c.map(i.pos),t?e.Slice.empty:n)}const s=t.Selection.findFrom(o.doc.resolve(o.mapping.slice(l).map(this.to)),-1);s&&o.setSelection(s)}replaceWith(t,o){this.replace(t,new e.Slice(e.Fragment.from(o),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),o=i.get(e),n=this.$anchorCell.start(-1),l=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n));for(let r=0;r<l.length;r++)t(e.nodeAt(l[r]),n+l[r])}isColSelection(){const t=this.$anchorCell.index(-1),e=this.$headCell.index(-1);if(Math.min(t,e)>0)return!1;const o=t+this.$anchorCell.nodeAfter.attrs.rowspan,n=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,n)==this.$headCell.node(-1).childCount}static colSelection(t,e=t){const n=t.node(-1),l=i.get(n),r=t.start(-1),s=l.findCell(t.pos-r),c=l.findCell(e.pos-r),a=t.node(0);return s.top<=c.top?(s.top>0&&(t=a.resolve(r+l.map[s.left])),c.bottom<l.height&&(e=a.resolve(r+l.map[l.width*(l.height-1)+c.right-1]))):(c.top>0&&(e=a.resolve(r+l.map[c.left])),s.bottom<l.height&&(t=a.resolve(r+l.map[l.width*(l.height-1)+s.right-1]))),new o(t,e)}isRowSelection(){const t=this.$anchorCell.node(-1),e=i.get(t),o=this.$anchorCell.start(-1),n=e.colCount(this.$anchorCell.pos-o),l=e.colCount(this.$headCell.pos-o);if(Math.min(n,l)>0)return!1;const r=n+this.$anchorCell.nodeAfter.attrs.colspan,s=l+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,s)==e.width}eq(t){return t instanceof o&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,e=t){const n=t.node(-1),l=i.get(n),r=t.start(-1),s=l.findCell(t.pos-r),c=l.findCell(e.pos-r),a=t.node(0);return s.left<=c.left?(s.left>0&&(t=a.resolve(r+l.map[s.top*l.width])),c.right<l.width&&(e=a.resolve(r+l.map[l.width*(c.top+1)-1]))):(c.left>0&&(e=a.resolve(r+l.map[c.top*l.width])),s.right<l.width&&(t=a.resolve(r+l.map[l.width*(s.top+1)-1]))),new o(t,e)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,e){return new o(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){return new o(t.resolve(e),t.resolve(n))}getBookmark(){return new x(this.$anchorCell.pos,this.$headCell.pos)}};y.prototype.visible=!1,t.Selection.jsonID("cell",y);var x=class e{constructor(t,e){this.anchor=t,this.head=e}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const o=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==o.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&o.index()<o.parent.childCount&&n.index()<n.parent.childCount&&g(o,n)?new y(o,n):t.Selection.near(n,1)}};function A(t){if(!(t.selection instanceof y))return null;const e=[];return t.selection.forEachCell((t,n)=>{e.push(o.Decoration.node(n,n+t.nodeSize,{class:"selectedCell"}))}),o.DecorationSet.create(t.doc,e)}const $=new t.PluginKey("fix-tables");function R(t,e,o,n){const l=t.childCount,r=e.childCount;t:for(let s=0,i=0;s<r;s++){const r=e.child(s);for(let e=i,n=Math.min(l,s+3);e<n;e++)if(t.child(e)==r){i=e+1,o+=r.nodeSize;continue t}n(r,o),i<l&&t.child(i).sameMarkup(r)?R(t.child(i),r,o+1,n):r.nodesBetween(0,r.content.size,n,o+1),o+=r.nodeSize}}function M(t,e){let o;const n=(e,n)=>{"table"==e.type.spec.tableRole&&(o=function(t,e,o,n){const l=i.get(e);if(!l.problems)return n;n||(n=t.tr);const r=[];for(let i=0;i<l.height;i++)r.push(0);for(let i=0;i<l.problems.length;i++){const t=l.problems[i];if("collision"==t.type){const l=e.nodeAt(t.pos);if(!l)continue;const s=l.attrs;for(let e=0;e<s.rowspan;e++)r[t.row+e]+=t.n;n.setNodeMarkup(n.mapping.map(o+1+t.pos),null,b(s,s.colspan-t.n,t.n))}else if("missing"==t.type)r[t.row]+=t.n;else if("overlong_rowspan"==t.type){const l=e.nodeAt(t.pos);if(!l)continue;n.setNodeMarkup(n.mapping.map(o+1+t.pos),null,{...l.attrs,rowspan:l.attrs.rowspan-t.n})}else if("colwidth mismatch"==t.type){const l=e.nodeAt(t.pos);if(!l)continue;n.setNodeMarkup(n.mapping.map(o+1+t.pos),null,{...l.attrs,colwidth:t.colwidth})}else if("zero_sized"==t.type){const t=n.mapping.map(o);n.delete(t,t+e.nodeSize)}}let s,c;for(let i=0;i<r.length;i++)r[i]&&(null==s&&(s=i),c=i);for(let i=0,p=o+1;i<l.height;i++){const o=e.child(i),l=p+o.nodeSize,d=r[i];if(d>0){let e="cell";o.firstChild&&(e=o.firstChild.type.spec.tableRole);const r=[];for(let o=0;o<d;o++){const o=a(t.schema)[e].createAndFill();o&&r.push(o)}const h=0!=i&&s!=i-1||c!=i?l-1:p+1;n.insert(n.mapping.map(h),r)}p=l}return n.setMeta($,{fixTables:!0})}(t,e,n,o))};return e?e.doc!=t.doc&&R(e.doc,t.doc,0,n):t.doc.descendants(n),o}function z(t){const e=t.selection,o=f(t),n=o.node(-1),l=o.start(-1),r=i.get(n);return{...e instanceof y?r.rectBetween(e.$anchorCell.pos-l,e.$headCell.pos-l):r.findCell(o.pos-l),tableStart:l,map:r,table:n}}function N(t,{map:e,tableStart:o,table:n},l){let r=l>0?-1:0;S(e,n,l+r)&&(r=0==l||l==e.width?null:0);for(let s=0;s<e.height;s++){const i=s*e.width+l;if(l>0&&l<e.width&&e.map[i-1]==e.map[i]){const r=e.map[i],c=n.nodeAt(r);t.setNodeMarkup(t.mapping.map(o+r),null,v(c.attrs,l-e.colCount(r))),s+=c.attrs.rowspan-1}else{const c=null==r?a(n.type.schema).cell:n.nodeAt(e.map[i+r]).type,p=e.positionAt(s,l,n);t.insert(t.mapping.map(o+p),c.createAndFill())}}return t}function E(t,{map:e,table:o,tableStart:n},l){const r=t.mapping.maps.length;for(let s=0;s<e.height;){const i=s*e.width+l,c=e.map[i],a=o.nodeAt(c),p=a.attrs;if(l>0&&e.map[i-1]==c||l<e.width-1&&e.map[i+1]==c)t.setNodeMarkup(t.mapping.slice(r).map(n+c),null,b(p,l-e.colCount(c)));else{const e=t.mapping.slice(r).map(n+c);t.delete(e,e+a.nodeSize)}s+=p.rowspan}}function k(t,e,o){var n;const l=a(e.type.schema).header_cell;for(let r=0;r<t.width;r++)if((null===(n=e.nodeAt(t.map[r+o*t.width]))||void 0===n?void 0:n.type)!=l)return!1;return!0}function T(t,{map:e,tableStart:o,table:n},l){let r=o;for(let a=0;a<l;a++)r+=n.child(a).nodeSize;const s=[];let i=l>0?-1:0;k(e,n,l+i)&&(i=0==l||l==e.height?null:0);for(let p=0,d=e.width*l;p<e.width;p++,d++)if(l>0&&l<e.height&&e.map[d]==e.map[d-e.width]){const l=e.map[d],r=n.nodeAt(l).attrs;t.setNodeMarkup(o+l,null,{...r,rowspan:r.rowspan+1}),p+=r.colspan-1}else{var c;const t=null==i?a(n.type.schema).cell:null===(c=n.nodeAt(e.map[d+i*e.width]))||void 0===c?void 0:c.type,o=null==t?void 0:t.createAndFill();o&&s.push(o)}return t.insert(r,a(n.type.schema).row.create(null,s)),t}function D(t,{map:e,table:o,tableStart:n},l){let r=0;for(let a=0;a<l;a++)r+=o.child(a).nodeSize;const s=r+o.child(l).nodeSize,i=t.mapping.maps.length;t.delete(r+n,s+n);const c=new Set;for(let a=0,p=l*e.width;a<e.width;a++,p++){const r=e.map[p];if(!c.has(r))if(c.add(r),l>0&&r==e.map[p-e.width]){const e=o.nodeAt(r).attrs;t.setNodeMarkup(t.mapping.slice(i).map(r+n),null,{...e,rowspan:e.rowspan-1}),a+=e.colspan-1}else if(l<e.height&&r==e.map[p+e.width]){const s=o.nodeAt(r),c=s.attrs,p=s.type.create({...c,rowspan:s.attrs.rowspan-1},s.content),d=e.positionAt(l+1,a,o);t.insert(t.mapping.slice(i).map(n+d),p),a+=c.colspan-1}}}function _(t){const e=t.content;return 1==e.childCount&&e.child(0).isTextblock&&0==e.child(0).childCount}function F(t){return(e,o)=>{const n=e.selection;let l,r;if(n instanceof y){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;l=n.$anchorCell.nodeAfter,r=n.$anchorCell.pos}else{var s;if(l=function(t){for(let e=t.depth;e>0;e--){const o=t.node(e).type.spec.tableRole;if("cell"===o||"header_cell"===o)return t.node(e)}return null}(n.$from),!l)return!1;r=null===(s=d(n.$from))||void 0===s?void 0:s.pos}if(null==l||null==r)return!1;if(1==l.attrs.colspan&&1==l.attrs.rowspan)return!1;if(o){let s=l.attrs;const i=[],c=s.colwidth;s.rowspan>1&&(s={...s,rowspan:1}),s.colspan>1&&(s={...s,colspan:1});const a=z(e),p=e.tr;for(let t=0;t<a.right-a.left;t++)i.push(c?{...s,colwidth:c&&c[t]?[c[t]]:null}:s);let d;for(let e=a.top;e<a.bottom;e++){let o=a.map.positionAt(e,a.left,a.table);e==a.top&&(o+=l.nodeSize);for(let n=a.left,r=0;n<a.right;n++,r++)n==a.left&&e==a.top||p.insert(d=p.mapping.map(o+a.tableStart,1),t({node:l,row:e,col:n}).createAndFill(i[r]))}p.setNodeMarkup(r,t({node:l,row:a.top,col:a.left}),i[0]),n instanceof y&&p.setSelection(new y(p.doc.resolve(n.$anchorCell.pos),d?p.doc.resolve(d):void 0)),o(p)}return!0}}function H(t,e,o){const n=e.map.cellsInRect({left:0,top:0,right:"row"==t?e.map.width:1,bottom:"column"==t?e.map.height:1});for(let l=0;l<n.length;l++){const t=e.table.nodeAt(n[l]);if(t&&t.type!==o.header_cell)return!1}return!0}function L(t,e){return(e=e||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(e,o){if(!h(e))return!1;if(o){const n=a(e.schema),l=z(e),r=e.tr,s=l.map.cellsInRect("column"==t?{left:l.left,top:0,right:l.right,bottom:l.map.height}:"row"==t?{left:0,top:l.top,right:l.map.width,bottom:l.bottom}:l),i=s.map(t=>l.table.nodeAt(t));for(let t=0;t<s.length;t++)i[t].type==n.header_cell&&r.setNodeMarkup(l.tableStart+s[t],n.cell,i[t].attrs);if(0===r.steps.length)for(let t=0;t<s.length;t++)r.setNodeMarkup(l.tableStart+s[t],n.header_cell,i[t].attrs);o(r)}return!0}}(t):function(e,o){if(!h(e))return!1;if(o){const n=a(e.schema),l=z(e),r=e.tr,s=H("row",l,n),i=H("column",l,n),c=("column"===t?s:"row"===t&&i)?1:0,p="column"==t?{left:0,top:c,right:1,bottom:l.map.height}:"row"==t?{left:c,top:0,right:l.map.width,bottom:1}:l,d="column"==t?i?n.cell:n.header_cell:"row"==t?s?n.cell:n.header_cell:n.cell;l.map.cellsInRect(p).forEach(t=>{const e=t+l.tableStart,o=r.doc.nodeAt(e);o&&r.setNodeMarkup(e,d,o.attrs)}),o(r)}return!0}}L("row",{useDeprecatedLogic:!0}),L("column",{useDeprecatedLogic:!0});const B=L("cell",{useDeprecatedLogic:!0});function W(t,o){const n=t.selection;if(!(n instanceof y))return!1;if(o){const l=t.tr,r=a(t.schema).cell.createAndFill().content;n.forEachCell((t,o)=>{t.content.eq(r)||l.replace(l.mapping.map(o+1),l.mapping.map(o+t.nodeSize-1),new e.Slice(r,0,0))}),l.docChanged&&o(l)}return!0}function I(t){if(0===t.size)return null;let{content:o,openStart:n,openEnd:l}=t;for(;1==o.childCount&&(n>0&&l>0||"table"==o.child(0).type.spec.tableRole);)n--,l--,o=o.child(0).content;const r=o.child(0),s=r.type.spec.tableRole,i=r.type.schema,c=[];if("row"==s)for(let p=0;p<o.childCount;p++){let t=o.child(p).content;const r=p?0:Math.max(0,n-1),s=p<o.childCount-1?0:Math.max(0,l-1);(r||s)&&(t=P(a(i).row,new e.Slice(t,r,s)).content),c.push(t)}else{if("cell"!=s&&"header_cell"!=s)return null;c.push(n||l?P(a(i).row,new e.Slice(o,n,l)).content:o)}return function(t,o){const n=[];for(let e=0;e<o.length;e++){const t=o[e];for(let o=t.childCount-1;o>=0;o--){const{rowspan:l,colspan:r}=t.child(o).attrs;for(let t=e;t<e+l;t++)n[t]=(n[t]||0)+r}}let l=0;for(let e=0;e<n.length;e++)l=Math.max(l,n[e]);for(let r=0;r<n.length;r++)if(r>=o.length&&o.push(e.Fragment.empty),n[r]<l){const s=a(t).cell.createAndFill(),i=[];for(let t=n[r];t<l;t++)i.push(s);o[r]=o[r].append(e.Fragment.from(i))}return{height:o.length,width:l,rows:o}}(i,c)}function P(t,e){const o=t.createAndFill();return new l.Transform(o).replace(0,o.content.size,e).doc}function K({width:t,height:o,rows:n},l,r){if(t!=l){const o=[],r=[];for(let t=0;t<n.length;t++){const s=n[t],i=[];for(let e=o[t]||0,n=0;e<l;n++){let r=s.child(n%s.childCount);e+r.attrs.colspan>l&&(r=r.type.createChecked(b(r.attrs,r.attrs.colspan,e+r.attrs.colspan-l),r.content)),i.push(r),e+=r.attrs.colspan;for(let e=1;e<r.attrs.rowspan;e++)o[t+e]=(o[t+e]||0)+r.attrs.colspan}r.push(e.Fragment.from(i))}n=r,t=l}if(o!=r){const t=[];for(let l=0,s=0;l<r;l++,s++){const i=[],c=n[s%o];for(let t=0;t<c.childCount;t++){let e=c.child(t);l+e.attrs.rowspan>r&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,r-e.attrs.rowspan)},e.content)),i.push(e)}t.push(e.Fragment.from(i))}n=t,o=r}return{width:t,height:o,rows:n}}function O(t,e,o,n,l,r,s,i){if(0==s||s==e.height)return!1;let c=!1;for(let a=l;a<r;a++){const l=s*e.width+a,r=e.map[l];if(e.map[l-e.width]==r){c=!0;const l=o.nodeAt(r),{top:p,left:d}=e.findCell(r);t.setNodeMarkup(t.mapping.slice(i).map(r+n),null,{...l.attrs,rowspan:s-p}),t.insert(t.mapping.slice(i).map(e.positionAt(s,d,o)),l.type.createAndFill({...l.attrs,rowspan:p+l.attrs.rowspan-s})),a+=l.attrs.colspan-1}}return c}function q(t,e,o,n,l,r,s,i){if(0==s||s==e.width)return!1;let c=!1;for(let a=l;a<r;a++){const l=a*e.width+s,r=e.map[l];if(e.map[l-1]==r){c=!0;const l=o.nodeAt(r),p=e.colCount(r),d=t.mapping.slice(i).map(r+n);t.setNodeMarkup(d,null,b(l.attrs,s-p,l.attrs.colspan-(s-p))),t.insert(d+l.nodeSize,l.type.createAndFill(b(l.attrs,0,s-p))),a+=l.attrs.rowspan-1}}return c}function V(t,o,n,l,r){let s=n?t.doc.nodeAt(n-1):t.doc;if(!s)throw new Error("No table found");let c=i.get(s);const{top:p,left:d}=l,h=d+r.width,f=p+r.height,u=t.tr;let m=0;function w(){if(s=n?u.doc.nodeAt(n-1):u.doc,!s)throw new Error("No table found");c=i.get(s),m=u.mapping.maps.length}(function(t,o,n,l,r,s,i){const c=a(t.doc.type.schema);let p,d;if(r>o.width)for(let e=0,a=0;e<o.height;e++){const s=n.child(e);a+=s.nodeSize;const h=[];let f;f=null==s.lastChild||s.lastChild.type==c.cell?p||(p=c.cell.createAndFill()):d||(d=c.header_cell.createAndFill());for(let t=o.width;t<r;t++)h.push(f);t.insert(t.mapping.slice(i).map(a-1+l),h)}if(s>o.height){const a=[];for(let t=0,e=(o.height-1)*o.width;t<Math.max(o.width,r);t++){const l=!(t>=o.width)&&n.nodeAt(o.map[e+t]).type==c.header_cell;a.push(l?d||(d=c.header_cell.createAndFill()):p||(p=c.cell.createAndFill()))}const h=c.row.create(null,e.Fragment.from(a)),f=[];for(let t=o.height;t<s;t++)f.push(h);t.insert(t.mapping.slice(i).map(l+n.nodeSize-2),f)}return!(!p&&!d)})(u,c,s,n,h,f,m)&&w(),O(u,c,s,n,d,h,p,m)&&w(),O(u,c,s,n,d,h,f,m)&&w(),q(u,c,s,n,p,f,d,m)&&w(),q(u,c,s,n,p,f,h,m)&&w();for(let i=p;i<f;i++){const t=c.positionAt(i,d,s),o=c.positionAt(i,h,s);u.replace(u.mapping.slice(m).map(t+n),u.mapping.slice(m).map(o+n),new e.Slice(r.rows[i-p],0,0))}w(),u.setSelection(new y(u.doc.resolve(n+c.positionAt(p,d,s)),u.doc.resolve(n+c.positionAt(f-1,h-1,s)))),o(u)}const X=n.keydownHandler({ArrowLeft:J("horiz",-1),ArrowRight:J("horiz",1),ArrowUp:J("vert",-1),ArrowDown:J("vert",1),"Shift-ArrowLeft":U("horiz",-1),"Shift-ArrowRight":U("horiz",1),"Shift-ArrowUp":U("vert",-1),"Shift-ArrowDown":U("vert",1),Backspace:W,"Mod-Backspace":W,Delete:W,"Mod-Delete":W});function j(t,e,o){return!o.eq(t.selection)&&(e&&e(t.tr.setSelection(o).scrollIntoView()),!0)}function J(e,o){return(n,l,r)=>{if(!r)return!1;const s=n.selection;if(s instanceof y)return j(n,l,t.Selection.near(s.$headCell,o));if("horiz"!=e&&!s.empty)return!1;const i=Z(r,e,o);if(null==i)return!1;if("horiz"==e)return j(n,l,t.Selection.near(n.doc.resolve(s.head+o),o));{const r=n.doc.resolve(i),s=C(r,e,o);let c;return c=s?t.Selection.near(s,1):o<0?t.Selection.near(n.doc.resolve(r.before(-1)),-1):t.Selection.near(n.doc.resolve(r.after(-1)),1),j(n,l,c)}}}function U(t,e){return(o,n,l)=>{if(!l)return!1;const r=o.selection;let s;if(r instanceof y)s=r;else{const n=Z(l,t,e);if(null==n)return!1;s=new y(o.doc.resolve(n))}const i=C(s.$headCell,t,e);return!!i&&j(o,n,new y(s.$anchorCell,i))}}function Y(t,e){const o=d(t.state.doc.resolve(e));return!!o&&(t.dispatch(t.state.tr.setSelection(new y(o))),!0)}function G(t,o,n){if(!h(t.state))return!1;let l=I(n);const r=t.state.selection;if(r instanceof y){l||(l={width:1,height:1,rows:[e.Fragment.from(P(a(t.state.schema).cell,n))]});const o=r.$anchorCell.node(-1),s=r.$anchorCell.start(-1),c=i.get(o).rectBetween(r.$anchorCell.pos-s,r.$headCell.pos-s);return l=K(l,c.right-c.left,c.bottom-c.top),V(t.state,t.dispatch,s,c,l),!0}if(l){const e=f(t.state),o=e.start(-1);return V(t.state,t.dispatch,o,i.get(e.node(-1)).findCell(e.pos-o),l),!0}return!1}function Q(t,e){var o;if(0!=e.button)return;if(e.ctrlKey||e.metaKey)return;const n=tt(t,e.target);let l;if(e.shiftKey&&t.state.selection instanceof y)r(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&null!=(l=d(t.state.selection.$anchor))&&(null===(o=et(t,e))||void 0===o?void 0:o.pos)!=l.pos)r(l,e),e.preventDefault();else if(!n)return;function r(e,o){let n=et(t,o);const l=null==p.getState(t.state);if(!n||!g(e,n)){if(!l)return;n=e}const r=new y(e,n);if(l||!t.state.selection.eq(r)){const o=t.state.tr.setSelection(r);l&&o.setMeta(p,e.pos),t.dispatch(o)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",i),null!=p.getState(t.state)&&t.dispatch(t.state.tr.setMeta(p,-1))}function i(o){const l=o,i=p.getState(t.state);let c;if(null!=i)c=t.state.doc.resolve(i);else if(tt(t,l.target)!=n&&(c=et(t,e),!c))return s();c&&r(c,l)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",i)}function Z(e,o,n){if(!(e.state.selection instanceof t.TextSelection))return null;const{$head:l}=e.state.selection;for(let t=l.depth-1;t>=0;t--){const r=l.node(t);if((n<0?l.index(t):l.indexAfter(t))!=(n<0?0:r.childCount))return null;if("cell"==r.type.spec.tableRole||"header_cell"==r.type.spec.tableRole){const r=l.before(t),s="vert"==o?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?r:null}}return null}function tt(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function et(t,e){const o=t.posAtCoords({left:e.clientX,top:e.clientY});if(!o)return null;let{inside:n,pos:l}=o;return n>=0&&d(t.state.doc.resolve(n))||d(t.state.doc.resolve(l))}var ot=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,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",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),nt(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,nt(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function nt(t,e,o,n,l,r){let s=0,i=!0,c=e.firstChild;const a=t.firstChild;if(a){for(let t=0,o=0;t<a.childCount;t++){const{colspan:p,colwidth:d}=a.child(t).attrs;for(let t=0;t<p;t++,o++){const a=l==o?r:d&&d[t],p=a?a+"px":"";if(s+=a||n,a||(i=!1),c)c.style.width!=p&&(c.style.width=p),c=c.nextSibling;else{const t=document.createElement("col");t.style.width=p,e.appendChild(t)}}}for(;c;){var p;const t=c.nextSibling;null===(p=c.parentNode)||void 0===p||p.removeChild(c),c=t}i?(o.style.width=s+"px",o.style.minWidth=""):(o.style.width="",o.style.minWidth=s+"px")}}const lt=new t.PluginKey("tableColumnResizing");var rt=class t{constructor(t,e){this.activeHandle=t,this.dragging=e}apply(e){const o=this,n=e.getMeta(lt);if(n&&null!=n.setHandle)return new t(n.setHandle,!1);if(n&&void 0!==n.setDragging)return new t(o.activeHandle,n.setDragging);if(o.activeHandle>-1&&e.docChanged){let n=e.mapping.map(o.activeHandle,-1);return m(e.doc.resolve(n))||(n=-1),new t(n,o.dragging)}return o}};function st(t,e,o,n){const l="right"==o?-n:n,r=t.posAtCoords({left:e.clientX+l,top:e.clientY});if(!r)return-1;const{pos:s}=r,c=d(t.state.doc.resolve(s));if(!c)return-1;if("right"==o)return c.pos;const a=i.get(c.node(-1)),p=c.start(-1),h=a.map.indexOf(c.pos-p);return h%a.width==0?-1:p+a.map[h-1]}function it(t,e,o){const n=e.clientX-t.startX;return Math.max(o,t.startWidth+n)}function ct(t,e){t.dispatch(t.state.tr.setMeta(lt,{setHandle:e}))}function at(t,e,o,n){const l=t.state.doc.resolve(e),r=l.node(-1),s=l.start(-1),c=i.get(r).colCount(l.pos-s)+l.nodeAfter.attrs.colspan-1;let a=t.domAtPos(l.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&nt(r,a.firstChild,a,n,c,o)}function pt(t){return Array(t).fill(0)}exports.CellBookmark=x,exports.CellSelection=y,exports.ResizeState=rt,exports.TableMap=i,exports.TableView=ot,exports.__clipCells=K,exports.__insertCells=V,exports.__pastedCells=I,exports.addColSpan=v,exports.addColumn=N,exports.addColumnAfter=function(t,e){if(!h(t))return!1;if(e){const o=z(t);e(N(t.tr,o,o.right))}return!0},exports.addColumnBefore=function(t,e){if(!h(t))return!1;if(e){const o=z(t);e(N(t.tr,o,o.left))}return!0},exports.addRow=T,exports.addRowAfter=function(t,e){if(!h(t))return!1;if(e){const o=z(t);e(T(t.tr,o,o.bottom))}return!0},exports.addRowBefore=function(t,e){if(!h(t))return!1;if(e){const o=z(t);e(T(t.tr,o,o.top))}return!0},exports.cellAround=d,exports.cellNear=u,exports.columnIsHeader=S,exports.columnResizing=function({handleWidth:e=5,cellMinWidth:n=25,defaultCellMinWidth:l=100,View:r=ot,lastColumnResizable:s=!0}={}){const c=new t.Plugin({key:lt,state:{init(t,e){var o;const n=null===(o=c.spec)||void 0===o||null===(o=o.props)||void 0===o?void 0:o.nodeViews,s=a(e.schema).table.name;return r&&n&&(n[s]=(t,e)=>new r(t,l,e)),new rt(-1,!1)},apply:(t,e)=>e.apply(t)},props:{attributes:t=>{const e=lt.getState(t);return e&&e.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,o)=>{!function(t,e,o,n){if(!t.editable)return;const l=lt.getState(t.state);if(!l)return;if(!l.dragging){const r=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(e.target);let s=-1;if(r){const{left:n,right:l}=r.getBoundingClientRect();e.clientX-n<=o?s=st(t,e,"left",o):l-e.clientX<=o&&(s=st(t,e,"right",o))}if(s!=l.activeHandle){if(!n&&-1!==s){const e=t.state.doc.resolve(s),o=e.node(-1),n=i.get(o),l=e.start(-1);if(n.colCount(e.pos-l)+e.nodeAfter.attrs.colspan-1==n.width-1)return}ct(t,s)}}}(t,o,e,s)},mouseleave:t=>{!function(t){if(!t.editable)return;const e=lt.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&ct(t,-1)}(t)},mousedown:(t,e)=>{!function(t,e,o,n){var l;if(!t.editable)return!1;const r=null!==(l=t.dom.ownerDocument.defaultView)&&void 0!==l?l:window,s=lt.getState(t.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const c=t.state.doc.nodeAt(s.activeHandle),a=function(t,e,{colspan:o,colwidth:n}){const l=n&&n[n.length-1];if(l)return l;const r=t.domAtPos(e);let s=r.node.childNodes[r.offset].offsetWidth,i=o;if(n)for(let c=0;c<o;c++)n[c]&&(s-=n[c],i--);return s/i}(t,s.activeHandle,c.attrs);function p(e){r.removeEventListener("mouseup",p),r.removeEventListener("mousemove",d);const n=lt.getState(t.state);(null==n?void 0:n.dragging)&&(!function(t,e,o){const n=t.state.doc.resolve(e),l=n.node(-1),r=i.get(l),s=n.start(-1),c=r.colCount(n.pos-s)+n.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let i=0;i<r.height;i++){const t=i*r.width+c;if(i&&r.map[t]==r.map[t-r.width])continue;const e=r.map[t],n=l.nodeAt(e).attrs,p=1==n.colspan?0:c-r.colCount(e);if(n.colwidth&&n.colwidth[p]==o)continue;const d=n.colwidth?n.colwidth.slice():pt(n.colspan);d[p]=o,a.setNodeMarkup(s+e,null,{...n,colwidth:d})}a.docChanged&&t.dispatch(a)}(t,n.activeHandle,it(n.dragging,e,o)),t.dispatch(t.state.tr.setMeta(lt,{setDragging:null})))}function d(e){if(!e.which)return p(e);const l=lt.getState(t.state);if(l&&l.dragging){const r=it(l.dragging,e,o);at(t,l.activeHandle,r,n)}}t.dispatch(t.state.tr.setMeta(lt,{setDragging:{startX:e.clientX,startWidth:a}})),at(t,s.activeHandle,a,n),r.addEventListener("mouseup",p),r.addEventListener("mousemove",d),e.preventDefault()}(t,e,n,l)}},decorations:t=>{const e=lt.getState(t);if(e&&e.activeHandle>-1)return function(t,e){const n=[],l=t.doc.resolve(e),r=l.node(-1);if(!r)return o.DecorationSet.empty;const s=i.get(r),c=l.start(-1),a=s.colCount(l.pos-c)+l.nodeAfter.attrs.colspan-1;for(let i=0;i<s.height;i++){const e=a+i*s.width;if(!(a!=s.width-1&&s.map[e]==s.map[e+1]||0!=i&&s.map[e]==s.map[e-s.width])){var p;const l=s.map[e],i=c+l+r.nodeAt(l).nodeSize-1,a=document.createElement("div");a.className="column-resize-handle",(null===(p=lt.getState(t))||void 0===p?void 0:p.dragging)&&n.push(o.Decoration.node(c+l,c+l+r.nodeAt(l).nodeSize,{class:"column-resize-dragging"})),n.push(o.Decoration.widget(i,a))}}return o.DecorationSet.create(t.doc,n)}(t,e.activeHandle)},nodeViews:{}}});return c},exports.columnResizingPluginKey=lt,exports.deleteCellSelection=W,exports.deleteColumn=function(t,e){if(!h(t))return!1;if(e){const o=z(t),n=t.tr;if(0==o.left&&o.right==o.map.width)return!1;for(let t=o.right-1;E(n,o,t),t!=o.left;t--){const t=o.tableStart?n.doc.nodeAt(o.tableStart-1):n.doc;if(!t)throw new RangeError("No table found");o.table=t,o.map=i.get(t)}e(n)}return!0},exports.deleteRow=function(t,e){if(!h(t))return!1;if(e){const o=z(t),n=t.tr;if(0==o.top&&o.bottom==o.map.height)return!1;for(let t=o.bottom-1;D(n,o,t),t!=o.top;t--){const t=o.tableStart?n.doc.nodeAt(o.tableStart-1):n.doc;if(!t)throw new RangeError("No table found");o.table=t,o.map=i.get(o.table)}e(n)}return!0},exports.deleteTable=function(t,e){const o=t.selection.$anchor;for(let n=o.depth;n>0;n--)if("table"==o.node(n).type.spec.tableRole)return e&&e(t.tr.delete(o.before(n),o.after(n)).scrollIntoView()),!0;return!1},exports.fixTables=M,exports.fixTablesKey=$,exports.goToNextCell=function(e){return function(o,n){if(!h(o))return!1;const l=function(t,e){if(e<0){const e=t.nodeBefore;if(e)return t.pos-e.nodeSize;for(let o=t.index(-1)-1,n=t.before();o>=0;o--){const e=t.node(-1).child(o),l=e.lastChild;if(l)return n-1-l.nodeSize;n-=e.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const e=t.node(-1);for(let o=t.indexAfter(-1),n=t.after();o<e.childCount;o++){const t=e.child(o);if(t.childCount)return n+1;n+=t.nodeSize}}return null}(f(o),e);if(null==l)return!1;if(n){const e=o.doc.resolve(l);n(o.tr.setSelection(t.TextSelection.between(e,w(e))).scrollIntoView())}return!0}},exports.handlePaste=G,exports.inSameTable=g,exports.isInTable=h,exports.mergeCells=function(t,o){const n=t.selection;if(!(n instanceof y)||n.$anchorCell.pos==n.$headCell.pos)return!1;const l=z(t),{map:r}=l;if(function({width:t,height:e,map:o},n){let l=n.top*t+n.left,r=l,s=(n.bottom-1)*t+n.left,i=l+(n.right-n.left-1);for(let c=n.top;c<n.bottom;c++){if(n.left>0&&o[r]==o[r-1]||n.right<t&&o[i]==o[i+1])return!0;r+=t,i+=t}for(let c=n.left;c<n.right;c++){if(n.top>0&&o[l]==o[l-t]||n.bottom<e&&o[s]==o[s+t])return!0;l++,s++}return!1}(r,l))return!1;if(o){const n=t.tr,s={};let i,c,a=e.Fragment.empty;for(let t=l.top;t<l.bottom;t++)for(let e=l.left;e<l.right;e++){const o=r.map[t*r.width+e],p=l.table.nodeAt(o);if(!s[o]&&p)if(s[o]=!0,null==i)i=o,c=p;else{_(p)||(a=a.append(p.content));const t=n.mapping.map(o+l.tableStart);n.delete(t,t+p.nodeSize)}}if(null==i||null==c)return!0;if(n.setNodeMarkup(i+l.tableStart,null,{...v(c.attrs,c.attrs.colspan,l.right-l.left-c.attrs.colspan),rowspan:l.bottom-l.top}),a.size>0){const t=i+1+c.content.size,e=_(c)?i+1:t;n.replaceWith(e+l.tableStart,t+l.tableStart,a)}n.setSelection(new y(n.doc.resolve(i+l.tableStart))),o(n)}return!0},exports.moveCellForward=w,exports.nextCell=C,exports.pointsAtCell=m,exports.removeColSpan=b,exports.removeColumn=E,exports.removeRow=D,exports.rowIsHeader=k,exports.selectedRect=z,exports.selectionCell=f,exports.setCellAttr=function(t,e){return function(o,n){if(!h(o))return!1;const l=f(o);if(l.nodeAfter.attrs[t]===e)return!1;if(n){const r=o.tr;o.selection instanceof y?o.selection.forEachCell((o,n)=>{o.attrs[t]!==e&&r.setNodeMarkup(n,null,{...o.attrs,[t]:e})}):r.setNodeMarkup(l.pos,null,{...l.nodeAfter.attrs,[t]:e}),n(r)}return!0}},exports.splitCell=function(t,e){const o=a(t.schema);return F(({node:t})=>o[t.type.spec.tableRole])(t,e)},exports.splitCellWithType=F,exports.tableEditing=function({allowTableNodeSelection:e=!1}={}){return new t.Plugin({key:p,state:{init:()=>null,apply(t,e){const o=t.getMeta(p);if(null!=o)return-1==o?null:o;if(null==e||!t.docChanged)return e;const{deleted:n,pos:l}=t.mapping.mapResult(e);return n?null:l}},props:{decorations:A,handleDOMEvents:{mousedown:Q},createSelectionBetween:t=>null!=p.getState(t.state)?t.state.selection:null,handleTripleClick:Y,handleKeyDown:X,handlePaste:G},appendTransaction:(o,n,l)=>function(e,o,n){const l=(o||e).selection,r=(o||e).doc;let s,c;if(l instanceof t.NodeSelection&&(c=l.node.type.spec.tableRole)){if("cell"==c||"header_cell"==c)s=y.create(r,l.from);else if("row"==c){const t=r.resolve(l.from+1);s=y.rowSelection(t,t)}else if(!n){const t=i.get(l.node),e=l.from+1,o=e+t.map[t.width*t.height-1];s=y.create(r,e+1,o)}}else l instanceof t.TextSelection&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let o=t.pos,n=e.pos,l=t.depth;for(;l>=0&&!(t.after(l+1)<t.end(l));l--,o++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,n--);return o==n&&/row|table/.test(t.node(l).type.spec.tableRole)}(l)?s=t.TextSelection.create(r,l.from):l instanceof t.TextSelection&&function({$from:t,$to:e}){let o,n;for(let l=t.depth;l>0;l--){const e=t.node(l);if("cell"===e.type.spec.tableRole||"header_cell"===e.type.spec.tableRole){o=e;break}}for(let l=e.depth;l>0;l--){const t=e.node(l);if("cell"===t.type.spec.tableRole||"header_cell"===t.type.spec.tableRole){n=t;break}}return o!==n&&0===e.parentOffset}(l)&&(s=t.TextSelection.create(r,l.$from.start(),l.$from.end()));return s&&(o||(o=e.tr)).setSelection(s),o}(l,M(l,n),e)})},exports.tableEditingKey=p,exports.tableNodeTypes=a,exports.toggleHeader=L,exports.toggleHeaderCell=B,exports.updateColumnsOnResize=nt;