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