@lexical/table 0.21.1-nightly.20241218.0 → 0.21.1-nightly.20241220.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,7 +44,7 @@ a}getAndClearNextFocus(){let {nextFocus:a}=this;null!==a&&(this.nextFocus=null);
44
44
  this.focusX&&e===this.focusY)return!1;this.focusX=f;this.focusY=e;return this.isHighlightingCells&&(b=U(d,v.$getNearestNodeFromDOMNode(a.elem,void 0)),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==b)?(this.focusCellNodeKey=b.getKey(),a=this.$getAnchorTableCellOrThrow(),d.getKey(),a.getKey(),b.getKey(),f=v.$getSelection(),f=R(f)?f.clone():xa(),f.set(d.getKey(),a.getKey(),b.getKey()),this.tableSelection=f,v.$setSelection(this.tableSelection),c.dispatchCommand(v.SELECTION_CHANGE_COMMAND,
45
45
  void 0),Aa(c,this.table,this.tableSelection),!0):!1}$getAnchorTableCell(){return this.anchorCellNodeKey?v.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){let a=this.$getAnchorTableCell();null===a&&E(234);return a}$getFocusTableCell(){return this.focusCellNodeKey?v.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){let a=this.$getFocusTableCell();null===a&&E(235);return a}$setAnchorCellForSelection(a){this.isHighlightingCells=!1;this.anchorCell=a;this.anchorX=
46
46
  a.x;this.anchorY=a.y;let {tableNode:b}=this.$lookup();a=U(b,v.$getNearestNodeFromDOMNode(a.elem,void 0));null!==a&&(a=a.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():xa(),this.anchorCellNodeKey=a)}$formatCells(a){let b=v.$getSelection();R(b)||E(236);let c=v.$createRangeSelection(),d=c.anchor,f=c.focus,e=b.getNodes().filter(C);0<e.length||E(237);let g=e[0].getFirstChild(),n=v.$isParagraphNode(g)?g.getFormatFlags(a,null):null;e.forEach(r=>{d.set(r.getKey(),0,"element");
47
- f.set(r.getKey(),r.getChildrenSize(),"element");c.formatText(a,n)});v.$setSelection(b);this.editor.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){let {editor:a}=this,b=v.$getNodeByKey(this.tableNodeKey);if(!L(b))throw Error("Expected TableNode.");var c=v.$getSelection();R(c)||E(255);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),v.$getRoot().selectStart()):(c.forEach(d=>{if(v.$isElementNode(d)){let f=v.$createParagraphNode(),
47
+ f.set(r.getKey(),r.getChildrenSize(),"element");c.formatText(a,n)});v.$setSelection(b);this.editor.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){let {editor:a}=this,b=v.$getNodeByKey(this.tableNodeKey);if(!L(b))throw Error("Expected TableNode.");var c=v.$getSelection();R(c)||E(253);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),v.$getRoot().selectStart()):(c.forEach(d=>{if(v.$isElementNode(d)){let f=v.$createParagraphNode(),
48
48
  e=v.$createTextNode();f.append(e);d.append(f);d.getChildren().forEach(g=>{g!==f&&g.remove()})}}),Aa(a,this.table,null),v.$setSelection(null),a.dispatchCommand(v.SELECTION_CHANGE_COMMAND,void 0))}}function S(a,b){if(!b)return b;a="TABLE"===b.nodeName?b:a.getDOMSlot(b).element;"TABLE"!==a.nodeName&&E(245,b.nodeName);return a}function U(a,b){for(let c=b,d=null;null!==c;c=c.getParent()){if(a.is(c))return d;C(c)&&(d=c)}return null}
49
49
  let Ba=[[v.KEY_ARROW_DOWN_COMMAND,"down"],[v.KEY_ARROW_UP_COMMAND,"up"],[v.KEY_ARROW_LEFT_COMMAND,"backward"],[v.KEY_ARROW_RIGHT_COMMAND,"forward"]],Ca=[v.DELETE_WORD_COMMAND,v.DELETE_LINE_COMMAND,v.DELETE_CHARACTER_COMMAND],Da=[v.KEY_BACKSPACE_COMMAND,v.KEY_DELETE_COMMAND];
50
50
  function Ea(a,b,c,d){let f=c.getRootElement(),e=c._window;null!==f&&null!==e||E(246);let g=new za(c,a.getKey()),n=S(a,b);Fa(n,g);g.listenersToRemove.add(()=>{Ga(n)===g&&delete n.__lexicalTableSelection});let r=()=>{if(!g.isSelecting){var l=()=>{g.isSelecting=!1;e.removeEventListener("mouseup",l);e.removeEventListener("mousemove",k)},k=m=>{if(v.isDOMNode(m.target))if(1!==(m.buttons&1)&&g.isSelecting)g.isSelecting=!1,e.removeEventListener("mouseup",l),e.removeEventListener("mousemove",k);else{var q=
@@ -99,7 +99,7 @@ domRows:d}=b;for(b=0;b<c;b++){let e=d[b];if(null!=e)for(let g=0;g<e.length;g++){
99
99
  b,c){a=this.getDOMCellFromCords(a,b,c);if(null==a)return null;a=v.$getNearestNodeFromDOMNode(a.elem);return C(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(a){this.getWritable().__rowStriping=a}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){let a=this.getFirstChild();if(!a)return 0;let b=0;a.getChildren().forEach(c=>
100
100
  {C(c)&&(b+=c.getColSpan())});return b}}function hb(a){let b=la();a.hasAttribute("data-lexical-row-striping")&&b.setRowStriping(!0);var c=a.querySelector(":scope > colgroup");if(c){a=[];for(let d of c.querySelectorAll(":scope > col")){c=d.style.width||"";if(!ba.test(c)&&(c=d.getAttribute("width")||"",!/^\d+$/.test(c))){a=void 0;break}a.push(parseFloat(c))}a&&b.setColWidths(a)}return{after:d=>h.$descendantsMatching(d,K),node:b}}function la(){return v.$applyNodeReplacement(new Z)}
101
101
  function L(a){return a instanceof Z}function ib({rows:a,columns:b,includeHeaders:c}){a=ka(Number(a),Number(b),c);h.$insertNodeToNearestRoot(a);a=a.getFirstDescendant();v.$isTextNode(a)&&a.select();return!0}function jb(a){K(a.getParent())?a.isEmpty()&&a.append(v.$createParagraphNode()):a.remove()}function kb(a){L(a.getParent())?h.$unwrapAndFilterDescendants(a,C):a.remove()}
102
- function lb(a){h.$unwrapAndFilterDescendants(a,K);let [b]=ra(a,null,null),c=b.reduce((f,e)=>Math.max(f,e.length),0);a=a.getChildren();for(let f=0;f<b.length;++f){let e=a[f];if(e){K(e)||E(253,e.constructor.name,e.getType());var d=b[f].reduce((g,n)=>n?1+g:g,0);if(d!==c)for(;d<c;++d){let g=B();g.append(v.$createParagraphNode());e.append(g)}}}}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=ra;exports.$createTableCellNode=B;exports.$createTableNode=la;
102
+ function lb(a){h.$unwrapAndFilterDescendants(a,K);let [b]=ra(a,null,null),c=b.reduce((f,e)=>Math.max(f,e.length),0);a=a.getChildren();for(let f=0;f<b.length;++f){let e=a[f];if(e){K(e)||E(254,e.constructor.name,e.getType());var d=b[f].reduce((g,n)=>n?1+g:g,0);if(d!==c)for(;d<c;++d){let g=B();g.append(v.$createParagraphNode());e.append(g)}}}}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=ra;exports.$createTableCellNode=B;exports.$createTableNode=la;
103
103
  exports.$createTableNodeWithDimensions=ka;exports.$createTableRowNode=J;exports.$createTableSelection=xa;exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let f=0;f<c.length;f++){var d=c[f];if(K(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a};
104
104
  exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=v.$getSelection();v.$isRangeSelection(a)||R(a)||E(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=Q(b);var [f]=Q(a);let [e,g,n]=O(d,c,f);var {startColumn:r}=g;let {startRow:p,startColumn:l}=n;b=Math.min(r,l);var k=Math.max(r+c.__colSpan-1,l+f.__colSpan-1);a=k-b+1;if(e[0].length===k-b+1)d.selectPrevious(),d.remove();else{var m=e.length;for(let q=0;q<m;q++)for(let u=b;u<=k;u++){let {cell:t,startColumn:w}=e[q][u];w<b?u===b&&t.setColSpan(t.__colSpan-
105
105
  Math.min(a,t.__colSpan-(b-w))):w+t.__colSpan-1>k?u===k&&t.setColSpan(t.__colSpan-(k-w+1)):t.remove()}k=e[p];f=r>l?k[r+c.__colSpan]:k[l+f.__colSpan];void 0!==f?({cell:r}=f,M(r)):({cell:r}=l<r?k[l-1]:k[r-1],M(r));if(r=d.getColWidths())r=[...r],r.splice(b,a),d.setColWidths(r)}};
@@ -120,6 +120,6 @@ exports.$unmergeCell=function(){var a=v.$getSelection();v.$isRangeSelection(a)||
120
120
  if(1<a){for(var q=1;q<a;q++)b.insertAfter(B(l[q]|m[0]).append(v.$createParagraphNode()));b.setColSpan(1)}if(1<f){let w;for(q=1;q<f;q++){var u=r+q;let D=e[u];w=(w||c).getNextSibling();K(w)||E(125);var t=null;for(let z=0;z<n;z++){let A=D[z],G=A.cell;A.startRow===u&&(t=G);1<G.__colSpan&&(z+=G.__colSpan-1)}if(null===t)for(t=a-1;0<=t;t--)qa(w,B(l[t]|m[q]).append(v.$createParagraphNode()));else for(u=a-1;0<=u;u--)t.insertAfter(B(l[u]|m[q]).append(v.$createParagraphNode()))}b.setRowSpan(1)}}};
121
121
  exports.INSERT_TABLE_COMMAND=ea;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=Z;exports.TableObserver=za;exports.TableRowNode=I;exports.applyTableHandlers=Ea;exports.getDOMCellFromTarget=Ha;exports.getTableElement=S;exports.getTableObserverFromTableElement=Ga;
122
122
  exports.registerTableCellUnmergeTransform=function(a){return a.registerNodeTransform(y,b=>{if(1<b.getColSpan()||1<b.getRowSpan()){var [,,c]=Q(b);[b]=O(c,b,b);let f=b.length,e=b[0].length;c=c.getFirstChild();K(c)||E(175);let g=[];for(let n=0;n<f;n++){0!==n&&(c=c.getNextSibling(),K(c)||E(175));let r=null;for(let p=0;p<e;p++){var d=b[n][p];let l=d.cell;if(d.startRow===n&&d.startColumn===p)r=l,g.push(l);else if(1<l.getColSpan()||1<l.getRowSpan())C(l)||E(176),d=B(l.__headerState),null!==r?r.insertAfter(d):
123
- h.$insertFirst(c,d)}}for(let n of g)n.setColSpan(1),n.setRowSpan(1)}})};exports.registerTablePlugin=function(a){a.hasNodes([Z])||E(254);return h.mergeRegister(a.registerCommand(ea,ib,v.COMMAND_PRIORITY_EDITOR),a.registerNodeTransform(Z,lb),a.registerNodeTransform(I,kb),a.registerNodeTransform(y,jb))};
123
+ h.$insertFirst(c,d)}}for(let n of g)n.setColSpan(1),n.setRowSpan(1)}})};exports.registerTablePlugin=function(a){a.hasNodes([Z])||E(255);return h.mergeRegister(a.registerCommand(ea,ib,v.COMMAND_PRIORITY_EDITOR),a.registerNodeTransform(Z,lb),a.registerNodeTransform(I,kb),a.registerNodeTransform(y,jb))};
124
124
  exports.registerTableSelectionObserver=function(a,b=!0){let c=new Map,d=(e,g,n)=>{n=S(e,n);e=Ea(e,n,a,b);c.set(g,[e,n])},f=a.registerMutationListener(Z,e=>{a.getEditorState().read(()=>{for(const [g,n]of e){const r=c.get(g);if("created"===n||"updated"===n){const {tableNode:p,tableElement:l}=ya(g);void 0===r?d(p,g,l):l!==r[1]&&(r[0].removeListeners(),c.delete(g),d(p,g,l))}else"destroyed"===n&&void 0!==r&&(r[0].removeListeners(),c.delete(g))}},{editor:a})},{skipInitialization:!1});return()=>{f();for(let [,
125
125
  [e]]of c)e.removeListeners()}};exports.setScrollableTablesActive=function(a,b){b?gb.add(a):gb.delete(a)}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{addClassNamesToElement as e,$descendantsMatching as t,$findMatchingParent as n,removeClassNamesFromElement as o,objectKlassEquals as r,isHTMLElement as l,$insertFirst as s,mergeRegister as i,$insertNodeToNearestRoot as c,$unwrapAndFilterDescendants as a}from"@lexical/utils";import{ElementNode as u,isHTMLElement as h,$createParagraphNode as d,$isElementNode as g,$isLineBreakNode as f,$isTextNode as m,$applyNodeReplacement as p,createCommand as S,$createTextNode as C,$getSelection as _,$isRangeSelection as w,$createPoint as b,$isParagraphNode as y,$normalizeSelection__EXPERIMENTAL as N,isCurrentlyReadOnlyMode as x,TEXT_TYPE_TO_FORMAT as T,$getNodeByKey as v,$getEditor as R,$setSelection as O,SELECTION_CHANGE_COMMAND as F,getDOMSelection as k,$createRangeSelection as E,$getRoot as K,COMMAND_PRIORITY_HIGH as M,KEY_ESCAPE_COMMAND as A,COMMAND_PRIORITY_CRITICAL as $,CUT_COMMAND as L,FORMAT_TEXT_COMMAND as P,FORMAT_ELEMENT_COMMAND as H,CONTROLLED_TEXT_INSERTION_COMMAND as W,KEY_TAB_COMMAND as B,FOCUS_COMMAND as D,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as I,$getPreviousSelection as U,$getNearestNodeFromDOMNode as z,$createRangeSelectionFromDom as Y,INSERT_PARAGRAPH_COMMAND as q,$isRootOrShadowRoot as X,$isDecoratorNode as J,KEY_ARROW_DOWN_COMMAND as j,KEY_ARROW_UP_COMMAND as V,KEY_ARROW_LEFT_COMMAND as G,KEY_ARROW_RIGHT_COMMAND as Q,DELETE_WORD_COMMAND as Z,DELETE_LINE_COMMAND as ee,DELETE_CHARACTER_COMMAND as te,KEY_BACKSPACE_COMMAND as ne,KEY_DELETE_COMMAND as oe,isDOMNode as re,setDOMUnmanaged as le,COMMAND_PRIORITY_EDITOR as se}from"lexical";import{copyToClipboard as ie,$getClipboardDataFromSelection as ce}from"@lexical/clipboard";const ae=/^(\d+(?:\.\d+)?)px$/,ue={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class he extends u{static getType(){return"tablecell"}static clone(e){return new he(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor}static importDOM(){return{td:e=>({conversion:de,priority:0}),th:e=>({conversion:de,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1;return ge(e.headerState,t,e.width||void 0).setRowSpan(n).setBackgroundColor(e.backgroundColor||null)}constructor(e=ue.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(h(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign="top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ue.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ue.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function de(e){const t=e,n=e.nodeName.toLowerCase();let o;ae.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ge("th"===n?ue.ROW:ue.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style,i=(s&&s.textDecoration||"").split(" "),c="700"===s.fontWeight||"bold"===s.fontWeight,a=i.includes("line-through"),u="italic"===s.fontStyle,h=i.includes("underline");return{after:e=>(0===e.length&&e.push(d()),e),forChild:(e,t)=>{if(fe(t)&&!g(e)){const t=d();return f(e)&&"\n"===e.getTextContent()?null:(m(e)&&(c&&e.toggleFormat("bold"),a&&e.toggleFormat("strikethrough"),u&&e.toggleFormat("italic"),h&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ge(e=ue.NO_STATUS,t=1,n){return p(new he(e,t,n))}function fe(e){return e instanceof he}const me=S("INSERT_TABLE_COMMAND");function pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se=pe((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class Ce extends u{static getType(){return"tablerow"}static clone(e){return new Ce(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:_e,priority:0})}}static importJSON(e){return we(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){return{...super.exportJSON(),...this.getHeight()&&{height:this.getHeight()},type:"tablerow",version:1}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){return this.getWritable().__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function _e(e){const n=e;let o;return ae.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,fe),node:we(o)}}function we(e){return p(new Ce(e))}function be(e){return e instanceof Ce}const ye="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Ne=ye&&"documentMode"in document?document.documentMode:null,xe=ye&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Te(e,t,n=!0){const o=It();for(let r=0;r<e;r++){const e=we();for(let o=0;o<t;o++){let t=ue.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ue.ROW),0===o&&n.columns&&(t|=ue.COLUMN)):n&&(0===r&&(t|=ue.ROW),0===o&&(t|=ue.COLUMN));const l=ge(t),s=d();s.append(C()),l.append(s),e.append(l)}o.append(e)}return o}function ve(e){const t=n(e,(e=>fe(e)));return fe(t)?t:null}function Re(e){const t=n(e,(e=>be(e)));if(be(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Oe(e){const t=n(e,(e=>Ut(e)));if(Ut(t))return t;throw new Error("Expected table cell to be inside of table.")}function Fe(e){const t=Re(e);return Oe(t).getChildren().findIndex((e=>e.is(t)))}function ke(e){return Re(e).getChildren().findIndex((t=>t.is(e)))}function Ee(e,t){const n=Oe(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Ke(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Me(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const s=l[t];if(!be(s))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=s.getChildren(),t=e.length,o=we();for(let n=0;n<t;n++){const t=e[n];fe(t)||Se(12);const{above:l,below:s}=Ee(t,r);let i=ue.NO_STATUS;const c=l&&l.getWidth()||s&&s.getWidth()||void 0;(l&&l.hasHeaderState(ue.COLUMN)||s&&s.hasHeaderState(ue.COLUMN))&&(i|=ue.COLUMN);const a=ge(i,1,c);a.append(d()),o.append(a)}n?s.insertAfter(o):s.insertBefore(o)}return e}ye&&"InputEvent"in window&&!Ne&&new window.InputEvent("input");const Ae=(e,t)=>e===ue.BOTH||e===t?t:ue.NO_STATUS;function $e(e=!0){const t=_();w(t)||Ge(t)||Se(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=qe(n),[l,,s]=qe(o),[i,c,a]=ze(s,l,r),u=i[0].length,{startRow:h}=a,{startRow:g}=c;let f=null;if(e){const e=Math.max(g+l.__rowSpan,h+r.__rowSpan)-1,t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=Ae(e,ue.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Se(256),o.insertAfter(n),f=n}else{const e=Math.min(g,h),t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l===e){const e=t[o].cell.__headerState,r=Ae(e,ue.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Se(257),o.insertBefore(n),f=n}return f}function Le(e,t,n=!0,o,r){const l=e.getChildren(),s=[];for(let e=0;e<l.length;e++){const n=l[e];if(be(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];fe(o)||Se(12);const{left:l,right:i}=Ee(o,r);let c=ue.NO_STATUS;(l&&l.hasHeaderState(ue.ROW)||i&&i.hasHeaderState(ue.ROW))&&(c|=ue.ROW);const a=ge(c);a.append(d()),s.push({newTableCell:a,targetCell:o})}}return s.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function Pe(e=!0){const t=_();w(t)||Ge(t)||Se(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=qe(n),[l,,s]=qe(o),[i,c,a]=ze(s,l,r),u=i.length,h=e?Math.max(c.startColumn,a.startColumn):Math.min(c.startColumn,a.startColumn),g=e?h+l.__colSpan-1:h-1,f=s.getFirstChild();be(f)||Se(120);let m=null;function p(e=ue.NO_STATUS){const t=ge(e).append(d());return null===m&&(m=t),t}let S=f;e:for(let e=0;e<u;e++){if(0!==e){const e=S.getNextSibling();be(e)||Se(121),S=e}const t=i[e],n=t[g<0?0:g].cell.__headerState,o=Ae(n,ue.ROW);if(g<0){Ie(S,p(o));continue}const{cell:r,startColumn:l,startRow:s}=t[g];if(l+r.__colSpan-1<=g){let n=r,l=s,i=g;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){S.append(p(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(p(o))}else r.setColSpan(r.__colSpan+1)}null!==m&&De(m);const C=s.getColWidths();if(C){const e=[...C],t=g<0?0:g,n=e[t];e.splice(t,0,n),s.setColWidths(e)}return m}function He(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(be(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function We(){const e=_();w(e)||Ge(e)||Se(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=qe(t),[l]=qe(n),[s,i,c]=ze(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,g=o.__rowSpan,f=s[h+1],m=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(e===a&&o<a){const e=a-o;n.setRowSpan(n.__rowSpan-Math.min(g,n.__rowSpan-e))}if(o>=a&&o+n.__rowSpan-1>h){n.setRowSpan(n.__rowSpan-(h-o+1)),null===m&&Se(122);let r=null;for(let n=0;n<t;n++){const t=f[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?Ie(m,n):r.insertAfter(n)}}}const t=r.getChildAtIndex(e);be(t)||Se(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];De(e)}else{const e=s[a-1],{cell:t}=e[0];De(t)}}function Be(){const e=_();w(e)||Ge(e)||Se(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=qe(t),[l]=qe(n),[s,i,c]=ze(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),g=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),f=g-d+1;if(s[0].length===g-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=g;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(f,n.__colSpan-e))}}else if(o+n.__colSpan-1>g){if(t===g){const e=g-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],S=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==S){const{cell:e}=S;De(e)}else{const e=h<a?p[h-1]:p[a-1],{cell:t}=e;De(t)}const C=r.getColWidths();if(C){const e=[...C];e.splice(d,f),r.setColWidths(e)}}function De(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Ie(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ue(){const e=_();w(e)||Ge(e)||Se(188);const t=e.anchor.getNode(),[n,o,r]=qe(t),l=n.__colSpan,s=n.__rowSpan;if(1===l&&1===s)return;const[i,c]=ze(r,n,n),{startColumn:a,startRow:u}=c,h=n.__headerState&ue.COLUMN,g=Array.from({length:l},((e,t)=>{let n=h;for(let e=0;0!==n&&e<i.length;e++)n&=i[e][t+a].cell.__headerState;return n})),f=n.__headerState&ue.ROW,m=Array.from({length:s},((e,t)=>{let n=f;for(let e=0;0!==n&&e<i[0].length;e++)n&=i[t+u][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(ge(g[e]|m[0]).append(d()));n.setColSpan(1)}if(s>1){let e;for(let t=1;t<s;t++){const n=u+t,r=i[n];e=(e||o).getNextSibling(),be(e)||Se(125);let s=null;for(let e=0;e<a;e++){const t=r[e],o=t.cell;t.startRow===n&&(s=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===s)for(let n=l-1;n>=0;n--)Ie(e,ge(g[n]|m[t]).append(d()));else for(let e=l-1;e>=0;e--)s.insertAfter(ge(g[e]|m[t]).append(d()))}n.setRowSpan(1)}}function ze(e,t,n){const[o,r,l]=Ye(e,t,n);return null===r&&Se(207),null===l&&Se(208),[o,r,l]}function Ye(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];be(o)||Se(209);for(let c=o.getFirstChild(),a=0;null!=c;c=c.getNextSibling()){fe(c)||Se(147);const o=s(e);for(;void 0!==o[a];)a++;const u={cell:c,startColumn:a,startRow:e},{__rowSpan:h,__colSpan:d}=c;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[a+e]=u}null!==t&&null===r&&t.is(c)&&(r=u),null!==n&&null===l&&n.is(c)&&(l=u)}}return[o,r,l]}function qe(e){let t;if(e instanceof he)t=e;else if("__type"in e){const o=n(e,fe);fe(o)||Se(148),t=o}else{const o=n(e.getNode(),fe);fe(o)||Se(148),t=o}const o=t.getParent();be(o)||Se(149);const r=o.getParent();return Ut(r)||Se(210),[t,o,r]}function Xe(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,c=r,a=o,u=r;function h(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<c||l>a||s>u;){if(o<i){const t=u-c,n=i-1;for(let o=0;o<=t;o++)h(e[c+o][n]);i=n}if(r<c){const t=a-i,n=c-1;for(let o=0;o<=t;o++)h(e[n][i+o]);c=n}if(l>a){const t=u-c,n=a+1;for(let o=0;o<=t;o++)h(e[c+o][n]);a=n}if(s>u){const t=a-i,n=u+1;for(let o=0;o<=t;o++)h(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function Je(e){const[t,,n]=qe(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c}}return null}function je(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map((t=>{const o=e[t].getNode(),r=n(o,fe);fe(r)||Se(238,t,o.getKey(),o.getType());const l=r.getParent();be(l)||Se(239,t);const s=l.getParent();return Ut(s)||Se(240,t),[o,r,l,s]}));return l.is(a)||Se(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class Ve{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return Ge(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new Ve(this.tableKey,b(this.anchor.key,this.anchor.offset,this.anchor.type),b(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(fe).forEach((e=>{const n=e.getFirstChild();y(n)&&(t|=n.getTextFormat())}));const n=T[e];return!!(t&n)}insertNodes(e){const t=this.focus.getNode();g(t)||Se(151);N(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=je(this),n=Je(e);null===n&&Se(153);const o=Je(t);null===o&&Se(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=je(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Se(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Se(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=ze(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Xe(l,s,i),d=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();be(o)||Se(160),o!==g&&(d.set(o.getKey(),o),g=o),d.has(n.getKey())||Ze(n,(e=>{d.set(e.getKey(),e)}))}const f=Array.from(d.values());return x()||(this._cachedNodes=f),f}getTextContent(){const e=this.getNodes().filter((e=>fe(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ge(e){return e instanceof Ve}function Qe(){const e=b("root",0,"element"),t=b("root",0,"element");return new Ve("root",e,t)}function Ze(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&g(o)&&n.push(o.getChildren())}}function et(e,t=R()){const n=v(e);Ut(n)||Se(231,e);const o=rt(n,t.getElementByKey(e));return null===o&&Se(232,e),{tableElement:o,tableNode:n}}class tt{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return et(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=gt(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=gt(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();ft(e,gt(t,n),null),null!==_()&&(O(null),e.dispatchCommand(F,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();o(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Se(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),ft(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=k(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=Mt(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=function(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=_(),r=Ge(o)?o.clone():Qe();return r.set(e.getKey(),t.getKey(),n.getKey()),r}(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(F,void 0),ft(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?v(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Se(234),e}$getFocusTableCell(){return this.focusCellNodeKey?v(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Se(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Mt(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():Qe(),this.anchorCellNodeKey=e}}$formatCells(e){const t=_();Ge(t)||Se(236);const n=E(),o=n.anchor,r=n.focus,l=t.getNodes().filter(fe);l.length>0||Se(237);const s=l[0].getFirstChild(),i=y(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),O(t),this.editor.dispatchCommand(F,void 0)}$clearText(){const{editor:e}=this,t=v(this.tableNodeKey);if(!Ut(t))throw new Error("Expected TableNode.");const n=_();Ge(n)||Se(255);const o=n.getNodes().filter(fe);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(g(e)){const t=d(),n=C();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),ft(e,this.table,null),O(null),e.dispatchCommand(F,void 0);else{t.selectPrevious(),t.remove();K().selectStart()}}}const nt="__lexicalTableSelection",ot=e=>!(1&~e.buttons);function rt(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Se(245,t.nodeName),n}function lt(e){return e._window}function st(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;fe(n)&&(o=n)}return null}const it=[[j,"down"],[V,"up"],[G,"backward"],[Q,"forward"]],ct=[Z,ee,te],at=[ne,oe];function ut(e,t,o,l){const s=o.getRootElement(),i=lt(o);null!==s&&null!==i||Se(246);const c=new tt(o,e.getKey()),a=rt(e,t);!function(e,t){null!==ht(e)&&Se(205);e[nt]=t}(a,c),c.listenersToRemove.add((()=>function(e,t){ht(e)===t&&delete e[nt]}(a,c)));a.addEventListener("mousedown",(t=>{if(0!==t.button||!re(t.target)||!i)return;const n=dt(t.target);null!==n&&o.update((()=>{const o=U();if(xe&&t.shiftKey&&yt(o,e)&&(w(o)||Ge(o))){const r=o.anchor.getNode(),l=st(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(Kt(c,l)),c.$setFocusCellForSelection(n),Ft(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else c.$setAnchorCellForSelection(n)})),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("mouseup",e),i.removeEventListener("mousemove",t)},t=n=>{if(!re(n.target))return;if(!ot(n)&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("mouseup",e),void i.removeEventListener("mousemove",t);const r=!a.contains(n.target);let l=null;if(r){for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(l=a.contains(e)?dt(e):null,l)break}else l=dt(n.target);!l||null!==c.focusCell&&l.elem===c.focusCell.elem||(c.setNextFocus({focusCell:l,override:r}),o.dispatchCommand(F,void 0))};c.isSelecting=!0,i.addEventListener("mouseup",e,c.listenerOptions),i.addEventListener("mousemove",t,c.listenerOptions)})()}),c.listenerOptions);i.addEventListener("mousedown",(e=>{const t=e.target;0===e.button&&re(t)&&o.update((()=>{const e=_();Ge(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()}))}),c.listenerOptions);for(const[t,n]of it)c.listenersToRemove.add(o.registerCommand(t,(t=>Ot(o,t,n,e,c)),M));c.listenersToRemove.add(o.registerCommand(A,(t=>{const n=_();if(Ge(n)){const o=st(e,n.focus.getNode());if(null!==o)return Ft(t),o.selectEnd(),!0}return!1}),M));const u=t=>()=>{const o=_();if(!yt(o,e))return!1;if(Ge(o))return c.$clearText(),!0;if(w(o)){if(!fe(st(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),!0;const a=n(o.anchor.getNode(),(e=>g(e))),u=a&&n(a,(e=>g(e)&&fe(e.getParent())));if(!g(u)||!g(a))return!1;if(t===ee&&null===u.getPreviousSibling())return!0}return!1};for(const e of ct)c.listenersToRemove.add(o.registerCommand(e,u(e),$));const h=t=>{const n=_();if(!Ge(n)&&!w(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Ge(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0)};for(const e of at)c.listenersToRemove.add(o.registerCommand(e,h,$));return c.listenersToRemove.add(o.registerCommand(L,(e=>{const t=_();if(t){if(!Ge(t)&&!w(t))return!1;ie(o,r(e,ClipboardEvent)?e:null,ce(t));const n=h(e);return w(t)?(t.removeText(),!0):n}return!1}),$)),c.listenersToRemove.add(o.registerCommand(P,(t=>{const o=_();if(!yt(o,e))return!1;if(Ge(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),(e=>fe(e)));if(!fe(e))return!1}return!1}),$)),c.listenersToRemove.add(o.registerCommand(H,(t=>{const n=_();if(!Ge(n)||!yt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!fe(o)||!fe(r))return!1;const[l,s,i]=ze(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];g(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),$)),c.listenersToRemove.add(o.registerCommand(W,(t=>{const r=_();if(!yt(r,e))return!1;if(Ge(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),(e=>fe(e)));if(!fe(l))return!1;if("string"==typeof t){const n=Et(o,r,e);if(n)return kt(n,e,[C(t)]),!0}}return!1}),$)),l&&c.listenersToRemove.add(o.registerCommand(B,(t=>{const o=_();if(!w(o)||!o.isCollapsed()||!yt(o,e))return!1;const r=vt(o.anchor.getNode());return!(null===r||!e.is(Rt(r)))&&(Ft(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(g(l))return l.selectEnd();const s=n(e,be);null===s&&Se(247);for(let e=s[o]();be(e);e=e[o]()){const t=e[r]();if(g(t))return t.selectEnd()}const i=n(s,Ut);null===i&&Se(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)}),$)),c.listenersToRemove.add(o.registerCommand(D,(t=>e.isSelected()),M)),c.listenersToRemove.add(o.registerCommand(I,(e=>{const{nodes:t,selection:o}=e,r=o.getStartEndPoints(),l=Ge(o),s=w(o)&&null!==n(o.anchor.getNode(),(e=>fe(e)))&&null!==n(o.focus.getNode(),(e=>fe(e)))||l;if(1!==t.length||!Ut(t[0])||!s||null===r)return!1;const[i]=r,c=t[0],a=c.getChildren(),u=c.getFirstChildOrThrow().getChildrenSize(),h=c.getChildrenSize(),g=n(i.getNode(),(e=>fe(e))),f=g&&n(g,(e=>be(e))),p=f&&n(f,(e=>Ut(e)));if(!fe(g)||!be(f)||!Ut(p))return!1;const S=f.getIndexWithinParent(),C=Math.min(p.getChildrenSize()-1,S+h-1),_=g.getIndexWithinParent(),b=Math.min(f.getChildrenSize()-1,_+u-1),y=Math.min(_,b),N=Math.min(S,C),x=Math.max(_,b),T=Math.max(S,C),v=p.getChildren();let R=0;for(let e=N;e<=T;e++){const t=v[e];if(!be(t))return!1;const n=a[R];if(!be(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!fe(t))return!1;const n=r[l];if(!fe(n))return!1;const s=t.getChildren();n.getChildren().forEach((e=>{if(m(e)){d().append(e),t.append(e)}else t.append(e)})),s.forEach((e=>e.remove())),l++}R++}return!0}),$)),c.listenersToRemove.add(o.registerCommand(F,(()=>{const t=_(),r=U(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(Ge(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&yt(t,e))return c.$setFocusCellForSelection(n),!0}if(c.getAndClearShouldCheckSelection()&&w(r)&&w(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=vt(o);if(null!==l&&be(r)){const t=r.getFirstChild();if(fe(t)&&e.is(n(l,(n=>n.is(e)||n.is(t)))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:r}=t,l=n.getNode(),s=r.getNode(),i=vt(l),a=vt(s),u=!(!i||!e.is(Rt(i))),h=!(!a||!e.is(Rt(a))),d=u!==h,g=u&&h,f=t.isBackward();if(d){const n=t.clone();if(h){const[t]=ze(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(f?o.getKey():r.getKey(),f?o.getChildrenSize():r.getChildrenSize(),"element")}else if(u){const[t]=ze(e,i,i),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(f?r.getKey():o.getKey(),f?r.getChildrenSize():0,"element")}O(n),pt(o,c)}else g&&(i.is(a)||(c.$setAnchorCellForSelection(Kt(c,i)),c.$setFocusCellForSelection(Kt(c,a),!0)))}else if(t&&Ge(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=k(i);if(n&&n.anchorNode&&n.focusNode){const r=z(n.focusNode),l=r&&!e.isParentOf(r),s=z(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=Y(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(Ge(t)||Ge(r))&&c.tableSelection&&!c.tableSelection.is(r)?(Ge(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!Ge(t)&&Ge(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),mt(t.table,(t=>{const n=t.elem;t.highlighted=!1,Tt(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&pt(o,c),!1)}),$)),c.listenersToRemove.add(o.registerCommand(q,(()=>{const t=_();if(!w(t)||!t.isCollapsed()||!yt(t,e))return!1;const n=Et(o,t,e);return!!n&&(kt(n,e),!0)}),$)),c}function ht(e){return e[nt]||null}function dt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function gt(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=rt(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function ft(e,t,n){const o=new Set(n?n.getNodes():[]);mt(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,xt(e,t)):(t.highlighted=!1,Tt(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function mt(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=z(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function pt(e,t){t.$disableHighlightStyle(),mt(t.table,(t=>{t.highlighted=!0,xt(e,t)}))}const St=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Nt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Nt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?Nt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Nt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Ct(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function _t([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function wt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Se(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Se(250,n,String(s)),i}function bt(e,t,n,o,r){const l=Xe(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=Ct(e,t);return null===n&&Se(249,t.cell.getKey()),n}(l,n),[d,g]=_t(h);let f=l[d],m=l[g];"forward"===r?f+="maxColumn"===d?1:c:"backward"===r?f-="minColumn"===d?1:u:"down"===r?m+="maxRow"===g?1:i:"up"===r&&(m-="minRow"===g?1:a);const p=t[m];if(void 0===p)return!1;const S=p[f];if(void 0===S)return!1;const[C,_]=function(e,t,n){const o=Xe(e,t,n),r=Ct(o,t);if(r)return[wt(e,o,r),wt(e,o,_t(r))];const l=Ct(o,n);if(l)return[wt(e,o,_t(l)),wt(e,o,l)];const s=["minColumn","minRow"];return[wt(e,o,s),wt(e,o,_t(s))]}(t,n,S),w=Kt(e,C.cell),b=Kt(e,_.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function yt(e,t){if(w(e)||Ge(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Nt(e,t){t?e.selectStart():e.selectEnd()}function xt(t,n){const o=n.elem,r=t._config.theme;fe(z(o))||Se(131),e(o,r.tableCellSelected)}function Tt(e,t){const n=t.elem;fe(z(n))||Se(131);const r=e._config.theme;o(n,r.tableCellSelected)}function vt(e){const t=n(e,fe);return fe(t)?t:null}function Rt(e){const t=n(e,Ut);return Ut(t)?t:null}function Ot(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=_();if(!yt(s,r)){if(w(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(g(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Ut(n)&&(Ft(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=n(e,(e=>Ut(e)));if(fe(l)&&(l=n(l,Ut)),l!==r)return!1;if(!l)return!1;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return!1;let c=0;"up"===o&&g(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&g(i)){const e=i.getLastChild();a=e||i,c=m(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,m(a)?"text":"element"),O(u),Ft(t),!0}if(X(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==st(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=qe(e),[o]=qe(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=n(e,(e=>g(e)&&!e.isInline()));if(fe(r)&&(r=n(r,Ut)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(Ut(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=qe(e),[l]=qe(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),Ft(t),O(c),!0}}}}return"down"===o&&Pt(e)&&l.setShouldCheckSelection(),!1}if(w(s)&&s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe);if(!fe(a)||!a.is(u))return!1;const h=Rt(a);if(h!==r&&null!=h){const n=rt(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=gt(h,n),Ot(e,t,o,h,l)}if("backward"===o||"forward"===o){const e=i.type,l=i.offset,c=i.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!J(u[0]))&&(!!function(e,t,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,t,o,r){const l=n(o,(e=>g(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===t:t===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,t,o,r)}(e,l,c,o)&&function(e,t,o,r,l){const[s,i]=ze(r,o,o);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,i,l))return!1;const c=function(e,t,o){const r=n(e,(e=>g(e)&&!e.isInline()));if(!r)return;const l="backward"===t?r.getPreviousSibling():r.getNextSibling();return l&&Ut(l)?l:"backward"===t?o.getPreviousSibling():o.getNextSibling()}(t,l,r);if(!c||Ut(c))return!1;Ft(e),"backward"===l?c.selectEnd():c.selectStart();return!0}(t,c,a,r,o))}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let m;if("element"===i.type)m=f.getBoundingClientRect();else{const t=k(lt(e));if(null===t||0===t.rangeCount)return!1;m=t.getRangeAt(0).getBoundingClientRect()}const p="up"===o?a.getFirstChild():a.getLastChild();if(null==p)return!1;const S=e.getElementByKey(p.__key);if(null==S)return!1;const C=S.getBoundingClientRect();if("up"===o?C.top>m.top-m.height:m.bottom+m.height>C.bottom){Ft(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return St(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}else if(Ge(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe),[h]=s.getNodes();Ut(h)||Se(251);const d=rt(h,e.getElementByKey(h.getKey()));if(!fe(a)||!fe(u)||!Ut(h)||null==d)return!1;l.$updateTableTableSelection(s);const g=gt(h,d),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.$setAnchorCellForSelection(m),Ft(t),t.shiftKey){const[e,t,n]=ze(r,a,u);return bt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function Ft(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function kt(e,t,n){const o=d();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function Et(e,t,o){const r=o.getParent();if(!r)return;const l=k(lt(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=rt(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),(e=>fe(e)));if(!a)return;const u=n(a,(e=>Ut(e)));if(!Ut(u)||!u.is(o))return;const[h,d]=ze(o,a,a),g=h[0][0],f=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,S=m===g.startRow&&p===g.startColumn,C=m===f.startRow&&p===f.startColumn;return S?"first":C?"last":void 0}function Kt(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Mt(e,t,n){return st(e,z(t,n))}function At(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function $t(t,n,r){r?(e(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(o(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}const Lt=new WeakSet;function Pt(e=R()){return Lt.has(e)}function Ht(e,t){t?Lt.add(e):Lt.delete(e)}class Wt extends u{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Wt(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:Dt,priority:1})}}static importJSON(e){const t=It();return t.__rowStriping=e.rowStriping||!1,t.__colWidths=e.colWidths,t}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&Se(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table"),r=document.createElement("colgroup");if(o.appendChild(r),At(o,0,this.getColumnCount(),this.getColWidths()),le(r),e(o,t.theme.table),this.__rowStriping&&$t(o,t,!0),Pt(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),n}return o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&$t(t,n,this.__rowStriping),At(t,0,this.getColumnCount(),this.getColWidths()),!1}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return{after:e=>{if(t.after&&(e=t.after(e)),l(e)&&"TABLE"!==e.nodeName&&(e=e.querySelector("table")),!l(e))return null;const[n]=Ye(this,null,null),o=new Map;for(const e of n)for(const t of e){const e=t.cell.getKey();o.has(e)||o.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const r=new Set;for(const t of e.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const e=t.getAttribute("data-temporary-table-cell-lexical-key");if(e){const n=o.get(e);if(t.removeAttribute("data-temporary-table-cell-lexical-key"),n){o.delete(e);for(let e=0;e<n.colSpan;e++)r.add(e+n.startColumn)}}}const s=e.querySelector(":scope > colgroup");if(s){const t=Array.from(e.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>r.has(t)));s.replaceChildren(...t)}const i=e.querySelectorAll(":scope > tr");if(i.length>0){const t=document.createElement("tbody");for(const e of i)t.appendChild(e);e.append(t)}return e},element:l(n)&&"TABLE"!==n.nodeName?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=Mt(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=z(o.elem);return fe(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){this.getWritable().__rowStriping=e}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{fe(e)&&(t+=e.getColSpan())})),t}}function Bt(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Se(230),gt(t,n)}function Dt(e){const n=It();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ae.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:e=>t(e,be),node:n}}function It(){return p(new Wt)}function Ut(e){return e instanceof Wt}function zt({rows:e,columns:t,includeHeaders:n}){const o=Te(Number(e),Number(t),n);c(o);const r=o.getFirstDescendant();return m(r)&&r.select(),!0}function Yt(e){be(e.getParent())?e.isEmpty()&&e.append(d()):e.remove()}function qt(e){Ut(e.getParent())?a(e,fe):e.remove()}function Xt(e){a(e,be);const[t]=Ye(e,null,null),n=t.reduce(((e,t)=>Math.max(e,t.length)),0),o=e.getChildren();for(let e=0;e<t.length;++e){const r=o[e];if(!r)continue;be(r)||Se(253,r.constructor.name,r.getType());const l=t[e].reduce(((e,t)=>t?1+e:e),0);if(l!==n)for(let e=l;e<n;++e){const e=ge();e.append(d()),r.append(e)}}}function Jt(e){return e.registerNodeTransform(he,(e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=qe(e),[n]=ze(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();be(l)||Se(175);const i=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),be(l)||Se(175));let t=null;for(let o=0;o<r;o++){const r=n[e][o],c=r.cell;if(r.startRow===e&&r.startColumn===o)t=c,i.push(c);else if(c.getColSpan()>1||c.getRowSpan()>1){fe(c)||Se(176);const e=ge(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))}function jt(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=rt(o,l),i=ut(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Wt,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=et(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function Vt(e){return e.hasNodes([Wt])||Se(254),i(e.registerCommand(me,zt,se),e.registerNodeTransform(Wt,Xt),e.registerNodeTransform(Ce,qt),e.registerNodeTransform(he,Yt))}export{ze as $computeTableMap,Ye as $computeTableMapSkipCellCheck,ge as $createTableCellNode,It as $createTableNode,Te as $createTableNodeWithDimensions,we as $createTableRowNode,Qe as $createTableSelection,He as $deleteTableColumn,Be as $deleteTableColumn__EXPERIMENTAL,We as $deleteTableRow__EXPERIMENTAL,vt as $findCellNode,Rt as $findTableNode,Bt as $getElementForTableNode,qe as $getNodeTriplet,et as $getTableAndElementByKey,ve as $getTableCellNodeFromLexicalNode,Je as $getTableCellNodeRect,ke as $getTableColumnIndexFromTableCellNode,Oe as $getTableNodeFromLexicalNodeOrThrow,Fe as $getTableRowIndexFromTableCellNode,Re as $getTableRowNodeFromTableCellNodeOrThrow,Le as $insertTableColumn,Pe as $insertTableColumn__EXPERIMENTAL,Me as $insertTableRow,$e as $insertTableRow__EXPERIMENTAL,Pt as $isScrollableTablesActive,fe as $isTableCellNode,Ut as $isTableNode,be as $isTableRowNode,Ge as $isTableSelection,Ke as $removeTableRowAtIndex,Ue as $unmergeCell,me as INSERT_TABLE_COMMAND,ue as TableCellHeaderStates,he as TableCellNode,Wt as TableNode,tt as TableObserver,Ce as TableRowNode,ut as applyTableHandlers,dt as getDOMCellFromTarget,rt as getTableElement,ht as getTableObserverFromTableElement,Jt as registerTableCellUnmergeTransform,Vt as registerTablePlugin,jt as registerTableSelectionObserver,Ht as setScrollableTablesActive};
9
+ import{addClassNamesToElement as e,$descendantsMatching as t,$findMatchingParent as n,removeClassNamesFromElement as o,objectKlassEquals as r,isHTMLElement as l,$insertFirst as s,mergeRegister as i,$insertNodeToNearestRoot as c,$unwrapAndFilterDescendants as a}from"@lexical/utils";import{ElementNode as u,isHTMLElement as h,$createParagraphNode as d,$isElementNode as g,$isLineBreakNode as f,$isTextNode as m,$applyNodeReplacement as p,createCommand as S,$createTextNode as C,$getSelection as _,$isRangeSelection as w,$createPoint as b,$isParagraphNode as y,$normalizeSelection__EXPERIMENTAL as N,isCurrentlyReadOnlyMode as x,TEXT_TYPE_TO_FORMAT as T,$getNodeByKey as v,$getEditor as R,$setSelection as O,SELECTION_CHANGE_COMMAND as F,getDOMSelection as k,$createRangeSelection as E,$getRoot as K,COMMAND_PRIORITY_HIGH as M,KEY_ESCAPE_COMMAND as A,COMMAND_PRIORITY_CRITICAL as $,CUT_COMMAND as L,FORMAT_TEXT_COMMAND as P,FORMAT_ELEMENT_COMMAND as H,CONTROLLED_TEXT_INSERTION_COMMAND as W,KEY_TAB_COMMAND as B,FOCUS_COMMAND as D,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as I,$getPreviousSelection as U,$getNearestNodeFromDOMNode as z,$createRangeSelectionFromDom as Y,INSERT_PARAGRAPH_COMMAND as q,$isRootOrShadowRoot as X,$isDecoratorNode as J,KEY_ARROW_DOWN_COMMAND as j,KEY_ARROW_UP_COMMAND as V,KEY_ARROW_LEFT_COMMAND as G,KEY_ARROW_RIGHT_COMMAND as Q,DELETE_WORD_COMMAND as Z,DELETE_LINE_COMMAND as ee,DELETE_CHARACTER_COMMAND as te,KEY_BACKSPACE_COMMAND as ne,KEY_DELETE_COMMAND as oe,isDOMNode as re,setDOMUnmanaged as le,COMMAND_PRIORITY_EDITOR as se}from"lexical";import{copyToClipboard as ie,$getClipboardDataFromSelection as ce}from"@lexical/clipboard";const ae=/^(\d+(?:\.\d+)?)px$/,ue={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class he extends u{static getType(){return"tablecell"}static clone(e){return new he(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor}static importDOM(){return{td:e=>({conversion:de,priority:0}),th:e=>({conversion:de,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1;return ge(e.headerState,t,e.width||void 0).setRowSpan(n).setBackgroundColor(e.backgroundColor||null)}constructor(e=ue.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(h(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign="top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ue.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ue.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function de(e){const t=e,n=e.nodeName.toLowerCase();let o;ae.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ge("th"===n?ue.ROW:ue.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style,i=(s&&s.textDecoration||"").split(" "),c="700"===s.fontWeight||"bold"===s.fontWeight,a=i.includes("line-through"),u="italic"===s.fontStyle,h=i.includes("underline");return{after:e=>(0===e.length&&e.push(d()),e),forChild:(e,t)=>{if(fe(t)&&!g(e)){const t=d();return f(e)&&"\n"===e.getTextContent()?null:(m(e)&&(c&&e.toggleFormat("bold"),a&&e.toggleFormat("strikethrough"),u&&e.toggleFormat("italic"),h&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ge(e=ue.NO_STATUS,t=1,n){return p(new he(e,t,n))}function fe(e){return e instanceof he}const me=S("INSERT_TABLE_COMMAND");function pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se=pe((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class Ce extends u{static getType(){return"tablerow"}static clone(e){return new Ce(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:_e,priority:0})}}static importJSON(e){return we(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){return{...super.exportJSON(),...this.getHeight()&&{height:this.getHeight()},type:"tablerow",version:1}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){return this.getWritable().__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function _e(e){const n=e;let o;return ae.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,fe),node:we(o)}}function we(e){return p(new Ce(e))}function be(e){return e instanceof Ce}const ye="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Ne=ye&&"documentMode"in document?document.documentMode:null,xe=ye&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Te(e,t,n=!0){const o=It();for(let r=0;r<e;r++){const e=we();for(let o=0;o<t;o++){let t=ue.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ue.ROW),0===o&&n.columns&&(t|=ue.COLUMN)):n&&(0===r&&(t|=ue.ROW),0===o&&(t|=ue.COLUMN));const l=ge(t),s=d();s.append(C()),l.append(s),e.append(l)}o.append(e)}return o}function ve(e){const t=n(e,(e=>fe(e)));return fe(t)?t:null}function Re(e){const t=n(e,(e=>be(e)));if(be(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Oe(e){const t=n(e,(e=>Ut(e)));if(Ut(t))return t;throw new Error("Expected table cell to be inside of table.")}function Fe(e){const t=Re(e);return Oe(t).getChildren().findIndex((e=>e.is(t)))}function ke(e){return Re(e).getChildren().findIndex((t=>t.is(e)))}function Ee(e,t){const n=Oe(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Ke(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Me(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const s=l[t];if(!be(s))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=s.getChildren(),t=e.length,o=we();for(let n=0;n<t;n++){const t=e[n];fe(t)||Se(12);const{above:l,below:s}=Ee(t,r);let i=ue.NO_STATUS;const c=l&&l.getWidth()||s&&s.getWidth()||void 0;(l&&l.hasHeaderState(ue.COLUMN)||s&&s.hasHeaderState(ue.COLUMN))&&(i|=ue.COLUMN);const a=ge(i,1,c);a.append(d()),o.append(a)}n?s.insertAfter(o):s.insertBefore(o)}return e}ye&&"InputEvent"in window&&!Ne&&new window.InputEvent("input");const Ae=(e,t)=>e===ue.BOTH||e===t?t:ue.NO_STATUS;function $e(e=!0){const t=_();w(t)||Ge(t)||Se(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=qe(n),[l,,s]=qe(o),[i,c,a]=ze(s,l,r),u=i[0].length,{startRow:h}=a,{startRow:g}=c;let f=null;if(e){const e=Math.max(g+l.__rowSpan,h+r.__rowSpan)-1,t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=Ae(e,ue.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Se(256),o.insertAfter(n),f=n}else{const e=Math.min(g,h),t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l===e){const e=t[o].cell.__headerState,r=Ae(e,ue.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Se(257),o.insertBefore(n),f=n}return f}function Le(e,t,n=!0,o,r){const l=e.getChildren(),s=[];for(let e=0;e<l.length;e++){const n=l[e];if(be(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];fe(o)||Se(12);const{left:l,right:i}=Ee(o,r);let c=ue.NO_STATUS;(l&&l.hasHeaderState(ue.ROW)||i&&i.hasHeaderState(ue.ROW))&&(c|=ue.ROW);const a=ge(c);a.append(d()),s.push({newTableCell:a,targetCell:o})}}return s.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function Pe(e=!0){const t=_();w(t)||Ge(t)||Se(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=qe(n),[l,,s]=qe(o),[i,c,a]=ze(s,l,r),u=i.length,h=e?Math.max(c.startColumn,a.startColumn):Math.min(c.startColumn,a.startColumn),g=e?h+l.__colSpan-1:h-1,f=s.getFirstChild();be(f)||Se(120);let m=null;function p(e=ue.NO_STATUS){const t=ge(e).append(d());return null===m&&(m=t),t}let S=f;e:for(let e=0;e<u;e++){if(0!==e){const e=S.getNextSibling();be(e)||Se(121),S=e}const t=i[e],n=t[g<0?0:g].cell.__headerState,o=Ae(n,ue.ROW);if(g<0){Ie(S,p(o));continue}const{cell:r,startColumn:l,startRow:s}=t[g];if(l+r.__colSpan-1<=g){let n=r,l=s,i=g;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){S.append(p(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(p(o))}else r.setColSpan(r.__colSpan+1)}null!==m&&De(m);const C=s.getColWidths();if(C){const e=[...C],t=g<0?0:g,n=e[t];e.splice(t,0,n),s.setColWidths(e)}return m}function He(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(be(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function We(){const e=_();w(e)||Ge(e)||Se(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=qe(t),[l]=qe(n),[s,i,c]=ze(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,g=o.__rowSpan,f=s[h+1],m=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(e===a&&o<a){const e=a-o;n.setRowSpan(n.__rowSpan-Math.min(g,n.__rowSpan-e))}if(o>=a&&o+n.__rowSpan-1>h){n.setRowSpan(n.__rowSpan-(h-o+1)),null===m&&Se(122);let r=null;for(let n=0;n<t;n++){const t=f[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?Ie(m,n):r.insertAfter(n)}}}const t=r.getChildAtIndex(e);be(t)||Se(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];De(e)}else{const e=s[a-1],{cell:t}=e[0];De(t)}}function Be(){const e=_();w(e)||Ge(e)||Se(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=qe(t),[l]=qe(n),[s,i,c]=ze(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),g=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),f=g-d+1;if(s[0].length===g-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=g;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(f,n.__colSpan-e))}}else if(o+n.__colSpan-1>g){if(t===g){const e=g-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],S=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==S){const{cell:e}=S;De(e)}else{const e=h<a?p[h-1]:p[a-1],{cell:t}=e;De(t)}const C=r.getColWidths();if(C){const e=[...C];e.splice(d,f),r.setColWidths(e)}}function De(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Ie(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ue(){const e=_();w(e)||Ge(e)||Se(188);const t=e.anchor.getNode(),[n,o,r]=qe(t),l=n.__colSpan,s=n.__rowSpan;if(1===l&&1===s)return;const[i,c]=ze(r,n,n),{startColumn:a,startRow:u}=c,h=n.__headerState&ue.COLUMN,g=Array.from({length:l},((e,t)=>{let n=h;for(let e=0;0!==n&&e<i.length;e++)n&=i[e][t+a].cell.__headerState;return n})),f=n.__headerState&ue.ROW,m=Array.from({length:s},((e,t)=>{let n=f;for(let e=0;0!==n&&e<i[0].length;e++)n&=i[t+u][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(ge(g[e]|m[0]).append(d()));n.setColSpan(1)}if(s>1){let e;for(let t=1;t<s;t++){const n=u+t,r=i[n];e=(e||o).getNextSibling(),be(e)||Se(125);let s=null;for(let e=0;e<a;e++){const t=r[e],o=t.cell;t.startRow===n&&(s=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===s)for(let n=l-1;n>=0;n--)Ie(e,ge(g[n]|m[t]).append(d()));else for(let e=l-1;e>=0;e--)s.insertAfter(ge(g[e]|m[t]).append(d()))}n.setRowSpan(1)}}function ze(e,t,n){const[o,r,l]=Ye(e,t,n);return null===r&&Se(207),null===l&&Se(208),[o,r,l]}function Ye(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];be(o)||Se(209);for(let c=o.getFirstChild(),a=0;null!=c;c=c.getNextSibling()){fe(c)||Se(147);const o=s(e);for(;void 0!==o[a];)a++;const u={cell:c,startColumn:a,startRow:e},{__rowSpan:h,__colSpan:d}=c;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[a+e]=u}null!==t&&null===r&&t.is(c)&&(r=u),null!==n&&null===l&&n.is(c)&&(l=u)}}return[o,r,l]}function qe(e){let t;if(e instanceof he)t=e;else if("__type"in e){const o=n(e,fe);fe(o)||Se(148),t=o}else{const o=n(e.getNode(),fe);fe(o)||Se(148),t=o}const o=t.getParent();be(o)||Se(149);const r=o.getParent();return Ut(r)||Se(210),[t,o,r]}function Xe(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,c=r,a=o,u=r;function h(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<c||l>a||s>u;){if(o<i){const t=u-c,n=i-1;for(let o=0;o<=t;o++)h(e[c+o][n]);i=n}if(r<c){const t=a-i,n=c-1;for(let o=0;o<=t;o++)h(e[n][i+o]);c=n}if(l>a){const t=u-c,n=a+1;for(let o=0;o<=t;o++)h(e[c+o][n]);a=n}if(s>u){const t=a-i,n=u+1;for(let o=0;o<=t;o++)h(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function Je(e){const[t,,n]=qe(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c}}return null}function je(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map((t=>{const o=e[t].getNode(),r=n(o,fe);fe(r)||Se(238,t,o.getKey(),o.getType());const l=r.getParent();be(l)||Se(239,t);const s=l.getParent();return Ut(s)||Se(240,t),[o,r,l,s]}));return l.is(a)||Se(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class Ve{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return Ge(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new Ve(this.tableKey,b(this.anchor.key,this.anchor.offset,this.anchor.type),b(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(fe).forEach((e=>{const n=e.getFirstChild();y(n)&&(t|=n.getTextFormat())}));const n=T[e];return!!(t&n)}insertNodes(e){const t=this.focus.getNode();g(t)||Se(151);N(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=je(this),n=Je(e);null===n&&Se(153);const o=Je(t);null===o&&Se(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=je(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Se(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Se(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=ze(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Xe(l,s,i),d=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();be(o)||Se(160),o!==g&&(d.set(o.getKey(),o),g=o),d.has(n.getKey())||Ze(n,(e=>{d.set(e.getKey(),e)}))}const f=Array.from(d.values());return x()||(this._cachedNodes=f),f}getTextContent(){const e=this.getNodes().filter((e=>fe(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ge(e){return e instanceof Ve}function Qe(){const e=b("root",0,"element"),t=b("root",0,"element");return new Ve("root",e,t)}function Ze(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&g(o)&&n.push(o.getChildren())}}function et(e,t=R()){const n=v(e);Ut(n)||Se(231,e);const o=rt(n,t.getElementByKey(e));return null===o&&Se(232,e),{tableElement:o,tableNode:n}}class tt{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return et(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=gt(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=gt(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();ft(e,gt(t,n),null),null!==_()&&(O(null),e.dispatchCommand(F,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();o(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Se(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),ft(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=k(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=Mt(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=function(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=_(),r=Ge(o)?o.clone():Qe();return r.set(e.getKey(),t.getKey(),n.getKey()),r}(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(F,void 0),ft(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?v(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Se(234),e}$getFocusTableCell(){return this.focusCellNodeKey?v(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Se(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Mt(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():Qe(),this.anchorCellNodeKey=e}}$formatCells(e){const t=_();Ge(t)||Se(236);const n=E(),o=n.anchor,r=n.focus,l=t.getNodes().filter(fe);l.length>0||Se(237);const s=l[0].getFirstChild(),i=y(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),O(t),this.editor.dispatchCommand(F,void 0)}$clearText(){const{editor:e}=this,t=v(this.tableNodeKey);if(!Ut(t))throw new Error("Expected TableNode.");const n=_();Ge(n)||Se(253);const o=n.getNodes().filter(fe);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(g(e)){const t=d(),n=C();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),ft(e,this.table,null),O(null),e.dispatchCommand(F,void 0);else{t.selectPrevious(),t.remove();K().selectStart()}}}const nt="__lexicalTableSelection",ot=e=>!(1&~e.buttons);function rt(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Se(245,t.nodeName),n}function lt(e){return e._window}function st(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;fe(n)&&(o=n)}return null}const it=[[j,"down"],[V,"up"],[G,"backward"],[Q,"forward"]],ct=[Z,ee,te],at=[ne,oe];function ut(e,t,o,l){const s=o.getRootElement(),i=lt(o);null!==s&&null!==i||Se(246);const c=new tt(o,e.getKey()),a=rt(e,t);!function(e,t){null!==ht(e)&&Se(205);e[nt]=t}(a,c),c.listenersToRemove.add((()=>function(e,t){ht(e)===t&&delete e[nt]}(a,c)));a.addEventListener("mousedown",(t=>{if(0!==t.button||!re(t.target)||!i)return;const n=dt(t.target);null!==n&&o.update((()=>{const o=U();if(xe&&t.shiftKey&&yt(o,e)&&(w(o)||Ge(o))){const r=o.anchor.getNode(),l=st(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(Kt(c,l)),c.$setFocusCellForSelection(n),Ft(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else c.$setAnchorCellForSelection(n)})),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("mouseup",e),i.removeEventListener("mousemove",t)},t=n=>{if(!re(n.target))return;if(!ot(n)&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("mouseup",e),void i.removeEventListener("mousemove",t);const r=!a.contains(n.target);let l=null;if(r){for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(l=a.contains(e)?dt(e):null,l)break}else l=dt(n.target);!l||null!==c.focusCell&&l.elem===c.focusCell.elem||(c.setNextFocus({focusCell:l,override:r}),o.dispatchCommand(F,void 0))};c.isSelecting=!0,i.addEventListener("mouseup",e,c.listenerOptions),i.addEventListener("mousemove",t,c.listenerOptions)})()}),c.listenerOptions);i.addEventListener("mousedown",(e=>{const t=e.target;0===e.button&&re(t)&&o.update((()=>{const e=_();Ge(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()}))}),c.listenerOptions);for(const[t,n]of it)c.listenersToRemove.add(o.registerCommand(t,(t=>Ot(o,t,n,e,c)),M));c.listenersToRemove.add(o.registerCommand(A,(t=>{const n=_();if(Ge(n)){const o=st(e,n.focus.getNode());if(null!==o)return Ft(t),o.selectEnd(),!0}return!1}),M));const u=t=>()=>{const o=_();if(!yt(o,e))return!1;if(Ge(o))return c.$clearText(),!0;if(w(o)){if(!fe(st(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),!0;const a=n(o.anchor.getNode(),(e=>g(e))),u=a&&n(a,(e=>g(e)&&fe(e.getParent())));if(!g(u)||!g(a))return!1;if(t===ee&&null===u.getPreviousSibling())return!0}return!1};for(const e of ct)c.listenersToRemove.add(o.registerCommand(e,u(e),$));const h=t=>{const n=_();if(!Ge(n)&&!w(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Ge(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0)};for(const e of at)c.listenersToRemove.add(o.registerCommand(e,h,$));return c.listenersToRemove.add(o.registerCommand(L,(e=>{const t=_();if(t){if(!Ge(t)&&!w(t))return!1;ie(o,r(e,ClipboardEvent)?e:null,ce(t));const n=h(e);return w(t)?(t.removeText(),!0):n}return!1}),$)),c.listenersToRemove.add(o.registerCommand(P,(t=>{const o=_();if(!yt(o,e))return!1;if(Ge(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),(e=>fe(e)));if(!fe(e))return!1}return!1}),$)),c.listenersToRemove.add(o.registerCommand(H,(t=>{const n=_();if(!Ge(n)||!yt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!fe(o)||!fe(r))return!1;const[l,s,i]=ze(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];g(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),$)),c.listenersToRemove.add(o.registerCommand(W,(t=>{const r=_();if(!yt(r,e))return!1;if(Ge(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),(e=>fe(e)));if(!fe(l))return!1;if("string"==typeof t){const n=Et(o,r,e);if(n)return kt(n,e,[C(t)]),!0}}return!1}),$)),l&&c.listenersToRemove.add(o.registerCommand(B,(t=>{const o=_();if(!w(o)||!o.isCollapsed()||!yt(o,e))return!1;const r=vt(o.anchor.getNode());return!(null===r||!e.is(Rt(r)))&&(Ft(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(g(l))return l.selectEnd();const s=n(e,be);null===s&&Se(247);for(let e=s[o]();be(e);e=e[o]()){const t=e[r]();if(g(t))return t.selectEnd()}const i=n(s,Ut);null===i&&Se(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)}),$)),c.listenersToRemove.add(o.registerCommand(D,(t=>e.isSelected()),M)),c.listenersToRemove.add(o.registerCommand(I,(e=>{const{nodes:t,selection:o}=e,r=o.getStartEndPoints(),l=Ge(o),s=w(o)&&null!==n(o.anchor.getNode(),(e=>fe(e)))&&null!==n(o.focus.getNode(),(e=>fe(e)))||l;if(1!==t.length||!Ut(t[0])||!s||null===r)return!1;const[i]=r,c=t[0],a=c.getChildren(),u=c.getFirstChildOrThrow().getChildrenSize(),h=c.getChildrenSize(),g=n(i.getNode(),(e=>fe(e))),f=g&&n(g,(e=>be(e))),p=f&&n(f,(e=>Ut(e)));if(!fe(g)||!be(f)||!Ut(p))return!1;const S=f.getIndexWithinParent(),C=Math.min(p.getChildrenSize()-1,S+h-1),_=g.getIndexWithinParent(),b=Math.min(f.getChildrenSize()-1,_+u-1),y=Math.min(_,b),N=Math.min(S,C),x=Math.max(_,b),T=Math.max(S,C),v=p.getChildren();let R=0;for(let e=N;e<=T;e++){const t=v[e];if(!be(t))return!1;const n=a[R];if(!be(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!fe(t))return!1;const n=r[l];if(!fe(n))return!1;const s=t.getChildren();n.getChildren().forEach((e=>{if(m(e)){d().append(e),t.append(e)}else t.append(e)})),s.forEach((e=>e.remove())),l++}R++}return!0}),$)),c.listenersToRemove.add(o.registerCommand(F,(()=>{const t=_(),r=U(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(Ge(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&yt(t,e))return c.$setFocusCellForSelection(n),!0}if(c.getAndClearShouldCheckSelection()&&w(r)&&w(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=vt(o);if(null!==l&&be(r)){const t=r.getFirstChild();if(fe(t)&&e.is(n(l,(n=>n.is(e)||n.is(t)))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:r}=t,l=n.getNode(),s=r.getNode(),i=vt(l),a=vt(s),u=!(!i||!e.is(Rt(i))),h=!(!a||!e.is(Rt(a))),d=u!==h,g=u&&h,f=t.isBackward();if(d){const n=t.clone();if(h){const[t]=ze(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(f?o.getKey():r.getKey(),f?o.getChildrenSize():r.getChildrenSize(),"element")}else if(u){const[t]=ze(e,i,i),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(f?r.getKey():o.getKey(),f?r.getChildrenSize():0,"element")}O(n),pt(o,c)}else g&&(i.is(a)||(c.$setAnchorCellForSelection(Kt(c,i)),c.$setFocusCellForSelection(Kt(c,a),!0)))}else if(t&&Ge(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=k(i);if(n&&n.anchorNode&&n.focusNode){const r=z(n.focusNode),l=r&&!e.isParentOf(r),s=z(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=Y(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(Ge(t)||Ge(r))&&c.tableSelection&&!c.tableSelection.is(r)?(Ge(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!Ge(t)&&Ge(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),mt(t.table,(t=>{const n=t.elem;t.highlighted=!1,Tt(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&pt(o,c),!1)}),$)),c.listenersToRemove.add(o.registerCommand(q,(()=>{const t=_();if(!w(t)||!t.isCollapsed()||!yt(t,e))return!1;const n=Et(o,t,e);return!!n&&(kt(n,e),!0)}),$)),c}function ht(e){return e[nt]||null}function dt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function gt(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=rt(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function ft(e,t,n){const o=new Set(n?n.getNodes():[]);mt(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,xt(e,t)):(t.highlighted=!1,Tt(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function mt(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=z(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function pt(e,t){t.$disableHighlightStyle(),mt(t.table,(t=>{t.highlighted=!0,xt(e,t)}))}const St=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Nt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Nt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?Nt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Nt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Ct(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function _t([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function wt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Se(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Se(250,n,String(s)),i}function bt(e,t,n,o,r){const l=Xe(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=Ct(e,t);return null===n&&Se(249,t.cell.getKey()),n}(l,n),[d,g]=_t(h);let f=l[d],m=l[g];"forward"===r?f+="maxColumn"===d?1:c:"backward"===r?f-="minColumn"===d?1:u:"down"===r?m+="maxRow"===g?1:i:"up"===r&&(m-="minRow"===g?1:a);const p=t[m];if(void 0===p)return!1;const S=p[f];if(void 0===S)return!1;const[C,_]=function(e,t,n){const o=Xe(e,t,n),r=Ct(o,t);if(r)return[wt(e,o,r),wt(e,o,_t(r))];const l=Ct(o,n);if(l)return[wt(e,o,_t(l)),wt(e,o,l)];const s=["minColumn","minRow"];return[wt(e,o,s),wt(e,o,_t(s))]}(t,n,S),w=Kt(e,C.cell),b=Kt(e,_.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function yt(e,t){if(w(e)||Ge(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Nt(e,t){t?e.selectStart():e.selectEnd()}function xt(t,n){const o=n.elem,r=t._config.theme;fe(z(o))||Se(131),e(o,r.tableCellSelected)}function Tt(e,t){const n=t.elem;fe(z(n))||Se(131);const r=e._config.theme;o(n,r.tableCellSelected)}function vt(e){const t=n(e,fe);return fe(t)?t:null}function Rt(e){const t=n(e,Ut);return Ut(t)?t:null}function Ot(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=_();if(!yt(s,r)){if(w(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(g(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Ut(n)&&(Ft(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=n(e,(e=>Ut(e)));if(fe(l)&&(l=n(l,Ut)),l!==r)return!1;if(!l)return!1;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return!1;let c=0;"up"===o&&g(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&g(i)){const e=i.getLastChild();a=e||i,c=m(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,m(a)?"text":"element"),O(u),Ft(t),!0}if(X(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==st(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=qe(e),[o]=qe(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=n(e,(e=>g(e)&&!e.isInline()));if(fe(r)&&(r=n(r,Ut)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(Ut(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=qe(e),[l]=qe(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),Ft(t),O(c),!0}}}}return"down"===o&&Pt(e)&&l.setShouldCheckSelection(),!1}if(w(s)&&s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe);if(!fe(a)||!a.is(u))return!1;const h=Rt(a);if(h!==r&&null!=h){const n=rt(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=gt(h,n),Ot(e,t,o,h,l)}if("backward"===o||"forward"===o){const e=i.type,l=i.offset,c=i.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!J(u[0]))&&(!!function(e,t,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,t,o,r){const l=n(o,(e=>g(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===t:t===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,t,o,r)}(e,l,c,o)&&function(e,t,o,r,l){const[s,i]=ze(r,o,o);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,i,l))return!1;const c=function(e,t,o){const r=n(e,(e=>g(e)&&!e.isInline()));if(!r)return;const l="backward"===t?r.getPreviousSibling():r.getNextSibling();return l&&Ut(l)?l:"backward"===t?o.getPreviousSibling():o.getNextSibling()}(t,l,r);if(!c||Ut(c))return!1;Ft(e),"backward"===l?c.selectEnd():c.selectStart();return!0}(t,c,a,r,o))}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let m;if("element"===i.type)m=f.getBoundingClientRect();else{const t=k(lt(e));if(null===t||0===t.rangeCount)return!1;m=t.getRangeAt(0).getBoundingClientRect()}const p="up"===o?a.getFirstChild():a.getLastChild();if(null==p)return!1;const S=e.getElementByKey(p.__key);if(null==S)return!1;const C=S.getBoundingClientRect();if("up"===o?C.top>m.top-m.height:m.bottom+m.height>C.bottom){Ft(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return St(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}else if(Ge(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe),[h]=s.getNodes();Ut(h)||Se(251);const d=rt(h,e.getElementByKey(h.getKey()));if(!fe(a)||!fe(u)||!Ut(h)||null==d)return!1;l.$updateTableTableSelection(s);const g=gt(h,d),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.$setAnchorCellForSelection(m),Ft(t),t.shiftKey){const[e,t,n]=ze(r,a,u);return bt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function Ft(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function kt(e,t,n){const o=d();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function Et(e,t,o){const r=o.getParent();if(!r)return;const l=k(lt(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=rt(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),(e=>fe(e)));if(!a)return;const u=n(a,(e=>Ut(e)));if(!Ut(u)||!u.is(o))return;const[h,d]=ze(o,a,a),g=h[0][0],f=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,S=m===g.startRow&&p===g.startColumn,C=m===f.startRow&&p===f.startColumn;return S?"first":C?"last":void 0}function Kt(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Mt(e,t,n){return st(e,z(t,n))}function At(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function $t(t,n,r){r?(e(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(o(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}const Lt=new WeakSet;function Pt(e=R()){return Lt.has(e)}function Ht(e,t){t?Lt.add(e):Lt.delete(e)}class Wt extends u{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Wt(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:Dt,priority:1})}}static importJSON(e){const t=It();return t.__rowStriping=e.rowStriping||!1,t.__colWidths=e.colWidths,t}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&Se(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table"),r=document.createElement("colgroup");if(o.appendChild(r),At(o,0,this.getColumnCount(),this.getColWidths()),le(r),e(o,t.theme.table),this.__rowStriping&&$t(o,t,!0),Pt(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),n}return o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&$t(t,n,this.__rowStriping),At(t,0,this.getColumnCount(),this.getColWidths()),!1}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return{after:e=>{if(t.after&&(e=t.after(e)),l(e)&&"TABLE"!==e.nodeName&&(e=e.querySelector("table")),!l(e))return null;const[n]=Ye(this,null,null),o=new Map;for(const e of n)for(const t of e){const e=t.cell.getKey();o.has(e)||o.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const r=new Set;for(const t of e.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const e=t.getAttribute("data-temporary-table-cell-lexical-key");if(e){const n=o.get(e);if(t.removeAttribute("data-temporary-table-cell-lexical-key"),n){o.delete(e);for(let e=0;e<n.colSpan;e++)r.add(e+n.startColumn)}}}const s=e.querySelector(":scope > colgroup");if(s){const t=Array.from(e.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>r.has(t)));s.replaceChildren(...t)}const i=e.querySelectorAll(":scope > tr");if(i.length>0){const t=document.createElement("tbody");for(const e of i)t.appendChild(e);e.append(t)}return e},element:l(n)&&"TABLE"!==n.nodeName?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=Mt(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=z(o.elem);return fe(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){this.getWritable().__rowStriping=e}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{fe(e)&&(t+=e.getColSpan())})),t}}function Bt(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Se(230),gt(t,n)}function Dt(e){const n=It();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ae.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:e=>t(e,be),node:n}}function It(){return p(new Wt)}function Ut(e){return e instanceof Wt}function zt({rows:e,columns:t,includeHeaders:n}){const o=Te(Number(e),Number(t),n);c(o);const r=o.getFirstDescendant();return m(r)&&r.select(),!0}function Yt(e){be(e.getParent())?e.isEmpty()&&e.append(d()):e.remove()}function qt(e){Ut(e.getParent())?a(e,fe):e.remove()}function Xt(e){a(e,be);const[t]=Ye(e,null,null),n=t.reduce(((e,t)=>Math.max(e,t.length)),0),o=e.getChildren();for(let e=0;e<t.length;++e){const r=o[e];if(!r)continue;be(r)||Se(254,r.constructor.name,r.getType());const l=t[e].reduce(((e,t)=>t?1+e:e),0);if(l!==n)for(let e=l;e<n;++e){const e=ge();e.append(d()),r.append(e)}}}function Jt(e){return e.registerNodeTransform(he,(e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=qe(e),[n]=ze(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();be(l)||Se(175);const i=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),be(l)||Se(175));let t=null;for(let o=0;o<r;o++){const r=n[e][o],c=r.cell;if(r.startRow===e&&r.startColumn===o)t=c,i.push(c);else if(c.getColSpan()>1||c.getRowSpan()>1){fe(c)||Se(176);const e=ge(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))}function jt(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=rt(o,l),i=ut(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Wt,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=et(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function Vt(e){return e.hasNodes([Wt])||Se(255),i(e.registerCommand(me,zt,se),e.registerNodeTransform(Wt,Xt),e.registerNodeTransform(Ce,qt),e.registerNodeTransform(he,Yt))}export{ze as $computeTableMap,Ye as $computeTableMapSkipCellCheck,ge as $createTableCellNode,It as $createTableNode,Te as $createTableNodeWithDimensions,we as $createTableRowNode,Qe as $createTableSelection,He as $deleteTableColumn,Be as $deleteTableColumn__EXPERIMENTAL,We as $deleteTableRow__EXPERIMENTAL,vt as $findCellNode,Rt as $findTableNode,Bt as $getElementForTableNode,qe as $getNodeTriplet,et as $getTableAndElementByKey,ve as $getTableCellNodeFromLexicalNode,Je as $getTableCellNodeRect,ke as $getTableColumnIndexFromTableCellNode,Oe as $getTableNodeFromLexicalNodeOrThrow,Fe as $getTableRowIndexFromTableCellNode,Re as $getTableRowNodeFromTableCellNodeOrThrow,Le as $insertTableColumn,Pe as $insertTableColumn__EXPERIMENTAL,Me as $insertTableRow,$e as $insertTableRow__EXPERIMENTAL,Pt as $isScrollableTablesActive,fe as $isTableCellNode,Ut as $isTableNode,be as $isTableRowNode,Ge as $isTableSelection,Ke as $removeTableRowAtIndex,Ue as $unmergeCell,me as INSERT_TABLE_COMMAND,ue as TableCellHeaderStates,he as TableCellNode,Wt as TableNode,tt as TableObserver,Ce as TableRowNode,ut as applyTableHandlers,dt as getDOMCellFromTarget,rt as getTableElement,ht as getTableObserverFromTableElement,Jt as registerTableCellUnmergeTransform,Vt as registerTablePlugin,jt as registerTableSelectionObserver,Ht as setScrollableTablesActive};
package/package.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "table"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.21.1-nightly.20241218.0",
11
+ "version": "0.21.1-nightly.20241220.0",
12
12
  "main": "LexicalTable.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/clipboard": "0.21.1-nightly.20241218.0",
16
- "@lexical/utils": "0.21.1-nightly.20241218.0",
17
- "lexical": "0.21.1-nightly.20241218.0"
15
+ "@lexical/clipboard": "0.21.1-nightly.20241220.0",
16
+ "@lexical/utils": "0.21.1-nightly.20241220.0",
17
+ "lexical": "0.21.1-nightly.20241220.0"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",