New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/table

Package Overview
Dependencies
Maintainers
0
Versions
296
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/table - npm Package Compare versions

Comparing version 0.26.0 to 0.26.1-nightly.20250303.0

2

LexicalTable.prod.js

@@ -9,2 +9,2 @@ /**

"use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/clipboard");const o=/^(\d+(?:\.\d+)?)px$/,r={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class l extends t.ElementNode{static getType(){return"tablecell"}static clone(e){return new l(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:i,priority:0}),th:e=>({conversion:i,priority:0})}}static importJSON(e){return a().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=r.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),s(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const n=super.exportDOM(e);if(t.isHTMLElement(n.element)){const e=n.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=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return n}exportJSON(){return{...super.exportJSON(),...s(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,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=r.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}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,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!==r.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||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function s(e){return"middle"===e||"bottom"===e}function i(e){const n=e,l=e.nodeName.toLowerCase();let i;o.test(n.style.width)&&(i=parseFloat(n.style.width));const u=a("th"===l?r.ROW:r.NO_STATUS,n.colSpan,i);u.__rowSpan=n.rowSpan;const d=n.style.backgroundColor;""!==d&&(u.__backgroundColor=d);const h=n.style.verticalAlign;s(h)&&(u.__verticalAlign=h);const g=n.style,f=(g&&g.textDecoration||"").split(" "),m="700"===g.fontWeight||"bold"===g.fontWeight,C=f.includes("line-through"),_="italic"===g.fontStyle,p=f.includes("underline");return{after:e=>(0===e.length&&e.push(t.$createParagraphNode()),e),forChild:(e,n)=>{if(c(n)&&!t.$isElementNode(e)){const n=t.$createParagraphNode();return t.$isLineBreakNode(e)&&"\n"===e.getTextContent()?null:(t.$isTextNode(e)&&(m&&e.toggleFormat("bold"),C&&e.toggleFormat("strikethrough"),_&&e.toggleFormat("italic"),p&&e.toggleFormat("underline")),n.append(e),n)}return e},node:u}}function a(e=r.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new l(e,n,o))}function c(e){return e instanceof l}const u=t.createCommand("INSERT_TABLE_COMMAND");function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h=d((function(e){const t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(let e=1;e<arguments.length;e++)n.append("v",arguments[e]);throw t.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class g extends t.ElementNode{static getType(){return"tablerow"}static clone(e){return new g(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:f,priority:0})}}static importJSON(e){return m().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e.addClassNamesToElement(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function f(t){const n=t;let r;return o.test(n.style.height)&&(r=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,c),node:m(r)}}function m(e){return t.$applyNodeReplacement(new g(e))}function C(e){return e instanceof g}const _="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,p=_&&"documentMode"in document?document.documentMode:null,S=_&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function N(e,n,o=!0){const l=Me();for(let s=0;s<e;s++){const e=m();for(let l=0;l<n;l++){let n=r.NO_STATUS;"object"==typeof o?(0===s&&o.rows&&(n|=r.ROW),0===l&&o.columns&&(n|=r.COLUMN)):o&&(0===s&&(n|=r.ROW),0===l&&(n|=r.COLUMN));const i=a(n),c=t.$createParagraphNode();c.append(t.$createTextNode()),i.append(c),e.append(i)}l.append(e)}return l}function w(t){const n=e.$findMatchingParent(t,(e=>C(e)));if(C(n))return n;throw new Error("Expected table cell to be inside of table row.")}function b(t){const n=e.$findMatchingParent(t,(e=>Ee(e)));if(Ee(n))return n;throw new Error("Expected table cell to be inside of table.")}function T(e,t){const n=b(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)}}_&&"InputEvent"in window&&!p&&new window.InputEvent("input");const y=(e,t)=>e===r.BOTH||e===t?t:r.NO_STATUS;function R(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function $(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function M(e,t,n){const[o,r,l]=E(e,t,n);return null===r&&h(207),null===l&&h(208),[o,r,l]}function E(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];C(o)||h(209);const a=s(e);for(let u=o.getFirstChild(),d=0;null!=u;u=u.getNextSibling()){for(c(u)||h(147);void 0!==a[d];)d++;const o={cell:u,startColumn:d,startRow:e},{__rowSpan:g,__colSpan:f}=u;for(let t=0;t<g&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<f;e++)n[d+e]=o}null!==t&&null===r&&t.is(u)&&(r=o),null!==n&&null===l&&n.is(u)&&(l=o)}}return[o,r,l]}function O(t){let n;if(t instanceof l)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,c);c(o)||h(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),c);c(o)||h(148),n=o}const o=n.getParent();C(o)||h(149);const r=o.getParent();return Ee(r)||h(210),[n,o,r]}function x(e,t,n){let o,r=Math.min(t.startColumn,n.startColumn),l=Math.min(t.startRow,n.startRow),s=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),i=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1);do{o=!1;for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const a=e[t][n];if(!a)continue;const c=a.startColumn+a.cell.__colSpan-1,u=a.startRow+a.cell.__rowSpan-1,d=a.startColumn<=s&&c>=r,h=a.startRow<=i&&u>=l;if(d&&h){const e=Math.min(r,a.startColumn),t=Math.max(s,c),n=Math.min(l,a.startRow),d=Math.max(i,u);e===r&&t===s&&n===l&&d===i||(r=e,s=t,l=n,i=d,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function A(e){const[t,,n]=O(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,a=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<a;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:i};r+=a}}return null}function v(t){const[[n,o,r,l],[s,i,a,u]]=["anchor","focus"].map((n=>{const o=t[n].getNode(),r=e.$findMatchingParent(o,c);c(r)||h(238,n,o.getKey(),o.getType());const l=r.getParent();C(l)||h(239,n);const s=l.getParent();return Ee(s)||h(240,n),[o,r,l,s]}));return l.is(u)||h(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:a,focusTable:u}}class F{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 P(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 F(this.tableKey,t.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),t.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let n=0;this.getNodes().filter(c).forEach((e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())}));const o=t.TEXT_TYPE_TO_FORMAT[e];return!!(n&o)}insertNodes(e){const n=this.focus.getNode();t.$isElementNode(n)||h(151);t.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=v(this),n=A(e);null===n&&h(153);const o=A(t);null===o&&h(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:n,anchorCell:o,focusCell:r}=v(this),l=r.getParents()[1];if(l!==n){if(n.isParentOf(r)){const e=l.getParent();null==e&&h(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&h(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[s,i,a]=M(n,o,r),{minColumn:c,maxColumn:u,minRow:d,maxRow:g}=x(s,i,a),f=new Map([[n.getKey(),n]]);let m=null;for(let e=d;e<=g;e++)for(let t=c;t<=u;t++){const{cell:n}=s[e][t],o=n.getParent();C(o)||h(160),o!==m&&(f.set(o.getKey(),o),m=o),f.has(n.getKey())||K(n,(e=>{f.set(e.getKey(),e)}))}const _=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=_),_}getTextContent(){const e=this.getNodes().filter((e=>c(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 P(e){return e instanceof F}function D(){const e=t.$createPoint("root",0,"element"),n=t.$createPoint("root",0,"element");return new F("root",e,n)}function I(e,n,o){e.getKey(),n.getKey(),o.getKey();const r=t.$getSelection(),l=P(r)?r.clone():D();return l.set(e.getKey(),n.getKey(),o.getKey()),l}function K(e,n){const o=[[e]];for(let e=o.at(-1);void 0!==e&&o.length>0;e=o.at(-1)){const r=e.pop();void 0===r?o.pop():!1!==n(r)&&t.$isElementNode(r)&&o.push(r.getChildren())}}function L(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);Ee(o)||h(231,e);const r=B(o,n.getElementByKey(e));return null===r&&h(232,e),{tableElement:r,tableNode:o}}class k{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 L(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=V(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=V(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:n,tableElement:o}=this.$lookup();Q(e,V(n,o),null),null!==t.$getSelection()&&(t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){const t=this.editor,{tableElement:n}=this.$lookup();e.removeClassNamesFromElement(n,t._config.theme.tableSelection),n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e.addClassNamesToElement(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&h(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Q(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=t.getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=e.x,s=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===l&&this.anchorY===s&&!n){if(l===this.focusX&&s===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=l,this.focusY=s,this.isHighlightingCells){const n=_e(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=I(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),Q(o,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?t.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&h(234),e}$getFocusTableCell(){return this.focusCellNodeKey?t.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&h(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=_e(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():D(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();P(n)||h(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(c);s.length>0||h(237);const i=s[0].getFirstChild(),a=t.$isParagraphNode(i)?i.getFormatFlags(e,null):null;s.forEach((t=>{r.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),o.formatText(e,a)})),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!Ee(n))throw new Error("Expected TableNode.");const o=t.$getSelection();P(o)||h(253);const r=o.getNodes().filter(c);if(r.length===this.table.columns*this.table.rows){n.selectPrevious();const o=n.getParent();return n.remove(),void(t.$isRootNode(o)&&o.isEmpty()&&e.dispatchCommand(t.INSERT_PARAGRAPH_COMMAND,void 0))}r.forEach((e=>{if(t.$isElementNode(e)){const n=t.$createParagraphNode(),o=t.$createTextNode();n.append(o),e.append(n),e.getChildren().forEach((e=>{e!==n&&e.remove()}))}})),Q(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const H="__lexicalTableSelection",W=e=>!(1&~e.buttons);function B(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&h(245,t.nodeName),n}function z(e){return e._window}function Y(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;c(n)&&(o=n)}return null}const U=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],X=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],J=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function q(o,r,l,s){const i=l.getRootElement(),a=z(l);null!==i&&null!==a||h(246);const u=new k(l,o.getKey()),d=B(o,r);!function(e,t){null!==G(e)&&h(205);e[H]=t}(d,u),u.listenersToRemove.add((()=>function(e,t){G(e)===t&&delete e[H]}(d,u)));const g=e=>{if(0!==e.button||!t.isDOMNode(e.target)||!a)return;const n=j(e.target);null!==n&&l.update((()=>{const r=t.$getPreviousSelection();if(S&&e.shiftKey&&se(r,o)&&(t.$isRangeSelection(r)||P(r))){const t=r.anchor.getNode(),l=Y(o,r.anchor.getNode());if(l)u.$setAnchorCellForSelection(Ce(u,l)),u.$setFocusCellForSelection(n),ge(e);else{(o.isBefore(t)?o.selectStart():o.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else u.$setAnchorCellForSelection(n)})),(()=>{if(u.isSelecting)return;const e=()=>{u.isSelecting=!1,a.removeEventListener("mouseup",e),a.removeEventListener("mousemove",n)},n=o=>{if(!t.isDOMNode(o.target))return;if(!W(o)&&u.isSelecting)return u.isSelecting=!1,a.removeEventListener("mouseup",e),void a.removeEventListener("mousemove",n);const r=!d.contains(o.target);let s=null;if(r){for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(s=d.contains(e)?j(e):null,s)break}else s=j(o.target);!s||null!==u.focusCell&&s.elem===u.focusCell.elem||(u.setNextFocus({focusCell:s,override:r}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};u.isSelecting=!0,a.addEventListener("mouseup",e,u.listenerOptions),a.addEventListener("mousemove",n,u.listenerOptions)})()};d.addEventListener("mousedown",g,u.listenerOptions),u.listenersToRemove.add((()=>{d.removeEventListener("mousedown",g)}));const f=e=>{if(e.detail>=3&&t.isDOMNode(e.target)){null!==j(e.target)&&e.preventDefault()}};d.addEventListener("mousedown",f,u.listenerOptions),u.listenersToRemove.add((()=>{d.removeEventListener("mousedown",f)}));const m=e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update((()=>{const e=t.$getSelection();P(e)&&e.tableKey===u.tableNodeKey&&i.contains(n)&&u.$clearHighlight()}))};a.addEventListener("mousedown",m,u.listenerOptions),u.listenersToRemove.add((()=>{a.removeEventListener("mousedown",m)}));for(const[e,n]of U)u.listenersToRemove.add(l.registerCommand(e,(e=>he(l,e,n,o,u)),t.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,(e=>{const n=t.$getSelection();if(P(n)){const t=Y(o,n.focus.getNode());if(null!==t)return ge(e),t.selectEnd(),!0}return!1}),t.COMMAND_PRIORITY_HIGH));const _=n=>()=>{const r=t.$getSelection();if(!se(r,o))return!1;if(P(r))return u.$clearText(),!0;if(t.$isRangeSelection(r)){if(!c(Y(o,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),s=r.focus.getNode(),i=o.isParentOf(l),a=o.isParentOf(s);if(i&&!a||a&&!i)return u.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),(e=>t.$isElementNode(e))),h=d&&e.$findMatchingParent(d,(e=>t.$isElementNode(e)&&c(e.getParent())));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(n===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of X)u.listenersToRemove.add(l.registerCommand(e,_(e),t.COMMAND_PRIORITY_CRITICAL));const p=e=>{const n=t.$getSelection();if(!P(n)&&!t.$isRangeSelection(n))return!1;const r=o.isParentOf(n.anchor.getNode());if(r!==o.isParentOf(n.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:s,type:i}=n[t];return o[n[e].isBefore(n[t])?"selectPrevious":"selectNext"]()[t].set(l,s,i),!1}return!!se(n,o)&&(!!P(n)&&(e&&(e.preventDefault(),e.stopPropagation()),u.$clearText(),!0))};for(const e of J)u.listenersToRemove.add(l.registerCommand(e,p,t.COMMAND_PRIORITY_CRITICAL));return u.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,(o=>{const r=t.$getSelection();if(r){if(!P(r)&&!t.$isRangeSelection(r))return!1;n.copyToClipboard(l,e.objectKlassEquals(o,ClipboardEvent)?o:null,n.$getClipboardDataFromSelection(r));const s=p(o);return t.$isRangeSelection(r)?(r.removeText(),!0):s}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,(n=>{const r=t.$getSelection();if(!se(r,o))return!1;if(P(r))return u.$formatCells(n),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(t))return!1}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,(e=>{const n=t.$getSelection();if(!P(n)||!se(n,o))return!1;const r=n.anchor.getNode(),l=n.focus.getNode();if(!c(r)||!c(l))return!1;if(function(e,t){if(P(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=M(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,o))return o.setFormat(e),!0;const[s,i,a]=M(o,r,l),u=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(i.startColumn+i.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(i.startRow,a.startRow),g=Math.min(i.startColumn,a.startColumn),f=new Set;for(let n=h;n<=u;n++)for(let o=g;o<=d;o++){const r=s[n][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(e);const l=r.getChildren();for(let n=0;n<l.length;n++){const o=l[n];t.$isElementNode(o)&&!o.isInline()&&o.setFormat(e)}}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.CONTROLLED_TEXT_INSERTION_COMMAND,(n=>{const r=t.$getSelection();if(!se(r,o))return!1;if(P(r))return u.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const s=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(s))return!1;if("string"==typeof n){const e=me(l,r,o);if(e)return fe(e,o,[t.$createTextNode(n)]),!0}}return!1}),t.COMMAND_PRIORITY_CRITICAL)),s&&u.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,(n=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!se(r,o))return!1;const l=ue(r.anchor.getNode());return!(null===l||!o.is(de(l)))&&(ge(n),function(n,o){const r="next"===o?"getNextSibling":"getPreviousSibling",l="next"===o?"getFirstChild":"getLastChild",s=n[r]();if(t.$isElementNode(s))return s.selectEnd();const i=e.$findMatchingParent(n,C);null===i&&h(247);for(let e=i[r]();C(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(i,Ee);null===a&&h(248);"next"===o?a.selectNext():a.selectPrevious()}(l,n.shiftKey?"previous":"next"),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,(e=>o.isSelected()),t.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n=>{const{nodes:o,selection:r}=n,l=r.getStartEndPoints(),s=P(r),i=t.$isRangeSelection(r)&&null!==e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)))&&null!==e.$findMatchingParent(r.focus.getNode(),(e=>c(e)))||s;if(1!==o.length||!Ee(o[0])||!i||null===l)return!1;const[a]=l,u=o[0],d=u.getChildren(),h=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),f=e.$findMatchingParent(a.getNode(),(e=>c(e))),m=f&&e.$findMatchingParent(f,(e=>C(e))),_=m&&e.$findMatchingParent(m,(e=>Ee(e)));if(!c(f)||!C(m)||!Ee(_))return!1;const p=m.getIndexWithinParent(),S=Math.min(_.getChildrenSize()-1,p+g-1),N=f.getIndexWithinParent(),w=Math.min(m.getChildrenSize()-1,N+h-1),b=Math.min(N,w),T=Math.min(p,S),y=Math.max(N,w),R=Math.max(p,S),$=_.getChildren();let M=0;for(let e=T;e<=R;e++){const n=$[e];if(!C(n))return!1;const o=d[M];if(!C(o))return!1;const r=n.getChildren(),l=o.getChildren();let s=0;for(let e=b;e<=y;e++){const n=r[e];if(!c(n))return!1;const o=l[s];if(!c(o))return!1;const i=n.getChildren();o.getChildren().forEach((e=>{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),n.append(e)}else n.append(e)})),i.forEach((e=>e.remove())),s++}M++}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,(()=>{const n=t.$getSelection(),r=t.$getPreviousSelection(),s=u.getAndClearNextFocus();if(null!==s){const{focusCell:e}=s;if(P(n)&&n.tableKey===u.tableNodeKey)return(e.x!==u.focusX||e.y!==u.focusY)&&(u.$setFocusCellForSelection(e),!0);if(e!==u.anchorCell&&se(n,o))return u.$setFocusCellForSelection(e),!0}if(u.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(n)&&n.isCollapsed()){const t=n.anchor.getNode(),r=o.getFirstChild(),l=ue(t);if(null!==l&&C(r)){const t=r.getFirstChild();if(c(t)&&o.is(e.$findMatchingParent(l,(e=>e.is(o)||e.is(t)))))return t.selectStart(),!0}}if(t.$isRangeSelection(n)){const{anchor:e,focus:r}=n,s=e.getNode(),i=r.getNode(),a=ue(s),c=ue(i),d=!(!a||!o.is(de(a))),h=!(!c||!o.is(de(c))),g=d!==h,f=d&&h,m=n.isBackward();if(g){const e=n.clone();if(h){const[t]=M(o,c,c),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(m?n.getKey():r.getKey(),m?n.getChildrenSize():r.getChildrenSize(),"element")}else if(d){const[t]=M(o,a,a),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(m?r.getKey():n.getKey(),m?r.getChildrenSize():0,"element")}t.$setSelection(e),ee(l,u)}else f&&(a.is(c)||(u.$setAnchorCellForSelection(Ce(u,a)),u.$setFocusCellForSelection(Ce(u,c),!0)))}else if(n&&P(n)&&n.is(r)&&n.tableKey===o.getKey()){const e=t.getDOMSelection(a);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),s=r&&!o.isParentOf(r),i=t.$getNearestNodeFromDOMNode(e.anchorNode),a=i&&o.isParentOf(i);if(s&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(o.getKey(),n.isBackward()?o.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return n&&!n.is(r)&&(P(n)||P(r))&&u.tableSelection&&!u.tableSelection.is(r)?(P(n)&&n.tableKey===u.tableNodeKey?u.$updateTableTableSelection(n):!P(n)&&P(r)&&r.tableKey===u.tableNodeKey&&u.$updateTableTableSelection(null),!1):(u.hasHijackedSelectionStyles&&!o.isSelected()?function(e,t){t.$enableHighlightStyle(),Z(t.table,(t=>{const n=t.elem;t.highlighted=!1,ce(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(l,u):!u.hasHijackedSelectionStyles&&o.isSelected()&&ee(l,u),!1)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!se(e,o))return!1;const n=me(l,e,o);return!!n&&(fe(n,o),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u}function G(e){return e[H]||null}function j(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 V(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=B(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 Q(e,t,n){const o=new Set(n?n.getNodes():[]);Z(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,ae(e,t)):(t.highlighted=!1,ce(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Z(e,n){const{domRows:o}=e;for(let e=0;e<o.length;e++){const r=o[e];if(r)for(let o=0;o<r.length;o++){const l=r[o];if(!l)continue;const s=t.$getNearestNodeFromDOMNode(l.elem);null!==s&&n(l,s,{x:o,y:e})}}}function ee(e,t){t.$disableHighlightStyle(),Z(t.table,(t=>{t.highlighted=!0,ae(e,t)}))}const te=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?ie(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?ie(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?ie(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?ie(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function ne(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 oe([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function re(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&h(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&h(250,n,String(s)),i}function le(e,t,n,o,r){const l=x(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,a=1,c=1;const u=e[r],d=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),a=Math.max(a,e[t][o].cell.__colSpan);return{bottomSpan:c,leftSpan:i,rightSpan:a,topSpan:s}}(t,l),{topSpan:i,leftSpan:a,bottomSpan:c,rightSpan:u}=s,d=function(e,t){const n=ne(e,t);return null===n&&h(249,t.cell.getKey()),n}(l,n),[g,f]=oe(d);let m=l[g],C=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?C+="maxRow"===f?1:i:"up"===r&&(C-="minRow"===f?1:c);const _=t[C];if(void 0===_)return!1;const p=_[m];if(void 0===p)return!1;const[S,N]=function(e,t,n){const o=x(e,t,n),r=ne(o,t);if(r)return[re(e,o,r),re(e,o,oe(r))];const l=ne(o,n);if(l)return[re(e,o,oe(l)),re(e,o,l)];const s=["minColumn","minRow"];return[re(e,o,s),re(e,o,oe(s))]}(t,n,p),w=Ce(e,S.cell),b=Ce(e,N.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function se(e,n){if(t.$isRangeSelection(e)||P(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function ie(e,t){t?e.selectStart():e.selectEnd()}function ae(n,o){const r=o.elem,l=n._config.theme;c(t.$getNearestNodeFromDOMNode(r))||h(131),e.addClassNamesToElement(r,l.tableCellSelected)}function ce(n,o){const r=o.elem;c(t.$getNearestNodeFromDOMNode(r))||h(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ue(t){const n=e.$findMatchingParent(t,c);return c(n)?n:null}function de(t){const n=e.$findMatchingParent(t,Ee);return Ee(n)?n:null}function he(n,o,r,l,s){if(("up"===r||"down"===r)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(n))return!1;const i=t.$getSelection();if(!se(i,l)){if(t.$isRangeSelection(i)){if("backward"===r){if(i.focus.offset>0)return!1;const e=function(e){for(let n=e,o=e;null!==o;n=o,o=o.getParent())if(t.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(i.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Ee(n)&&(ge(o),o.shiftKey?i.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(o.shiftKey&&("up"===r||"down"===r)){const n=i.focus.getNode();if(!i.isCollapsed()&&("up"===r&&!i.isBackward()||"down"===r&&i.isBackward())){let s=e.$findMatchingParent(n,(e=>Ee(e)));if(c(s)&&(s=e.$findMatchingParent(s,Ee)),s!==l)return!1;if(!s)return!1;const a="down"===r?s.getNextSibling():s.getPreviousSibling();if(!a)return!1;let u=0;"up"===r&&t.$isElementNode(a)&&(u=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,u=t.$isTextNode(d)?d.getTextContentSize():0}const h=i.clone();return h.focus.set(d.getKey(),u,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),ge(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==Y(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=O(e),[o]=O(t),r=l.getCordsFromCellNode(n,s.table),i=l.getCordsFromCellNode(o,s.table),a=l.getDOMCellFromCordsOrThrow(r.x,r.y,s.table),c=l.getDOMCellFromCordsOrThrow(i.x,i.y,s.table);return s.$setAnchorCellForSelection(a),s.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(c(l)&&(l=e.$findMatchingParent(l,Ee)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(Ee(a)&&s.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=O(e),[s]=O(n),c=i.clone();return c.focus.set(("up"===r?l:s).getKey(),"up"===r?0:s.getChildrenSize(),"element"),ge(o),t.$setSelection(c),!0}}}}return"down"===r&&ye(n)&&s.setShouldCheckSelection(),!1}if(t.$isRangeSelection(i)&&i.isCollapsed()){const{anchor:a,focus:u}=i,d=e.$findMatchingParent(a.getNode(),c),h=e.$findMatchingParent(u.getNode(),c);if(!c(d)||!d.is(h))return!1;const g=de(d);if(g!==l&&null!=g){const e=B(g,n.getElementByKey(g.getKey()));if(null!=e)return s.table=V(g,e),he(n,o,r,g,s)}if("backward"===r||"forward"===r){const n=a.type,s=a.offset,c=a.getNode();if(!c)return!1;const u=i.getNodes();return(1!==u.length||!t.$isDecoratorNode(u[0]))&&(!!function(n,o,r,l){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(n,r,l)||function(n,o,r,l){const s=e.$findMatchingParent(r,(e=>t.$isElementNode(e)&&!e.isInline()));if(!s)return!1;const i="backward"===l?0===o:o===r.getTextContentSize();return"text"===n&&i&&("backward"===l?null===s.getPreviousSibling():null===s.getNextSibling())}(n,o,r,l)}(n,s,c,r)&&function(n,o,r,l,s){const[i,a]=M(l,r,r);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}(i,a,s))return!1;const c=function(n,o,r){const l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(!l)return;const s="backward"===o?l.getPreviousSibling():l.getNextSibling();return s&&Ee(s)?s:"backward"===o?r.getPreviousSibling():r.getNextSibling()}(o,s,l);if(!c||Ee(c))return!1;ge(n),"backward"===s?c.selectEnd():c.selectStart();return!0}(o,c,d,l,r))}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let C;if("element"===a.type)C=m.getBoundingClientRect();else{const e=t.getDOMSelection(z(n));if(null===e||0===e.rangeCount)return!1;C=e.getRangeAt(0).getBoundingClientRect()}const _="up"===r?d.getFirstChild():d.getLastChild();if(null==_)return!1;const p=n.getElementByKey(_.__key);if(null==p)return!1;const S=p.getBoundingClientRect();if("up"===r?S.top>C.top-C.height:C.bottom+C.height>S.bottom){ge(o);const e=l.getCordsFromCellNode(d,s.table);if(!o.shiftKey)return te(s,l,e.x,e.y,r);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,s.table);s.$setAnchorCellForSelection(t),s.$setFocusCellForSelection(t,!0)}return!0}}else if(P(i)){const{anchor:t,focus:a}=i,u=e.$findMatchingParent(t.getNode(),c),d=e.$findMatchingParent(a.getNode(),c),[g]=i.getNodes();Ee(g)||h(251);const f=B(g,n.getElementByKey(g.getKey()));if(!c(u)||!c(d)||!Ee(g)||null==f)return!1;s.$updateTableTableSelection(i);const m=V(g,f),C=l.getCordsFromCellNode(u,m),_=l.getDOMCellFromCordsOrThrow(C.x,C.y,m);if(s.$setAnchorCellForSelection(_),ge(o),o.shiftKey){const[e,t,n]=M(l,u,d);return le(s,e,t,n,r)}return d.selectEnd(),!0}return!1}function ge(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function fe(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function me(n,o,r){const l=r.getParent();if(!l)return;const s=t.getDOMSelection(z(n));if(!s)return;const i=s.anchorNode,a=n.getElementByKey(l.getKey()),u=B(r,n.getElementByKey(r.getKey()));if(!i||!a||!u||!a.contains(i)||u.contains(i))return;const d=e.$findMatchingParent(o.anchor.getNode(),(e=>c(e)));if(!d)return;const h=e.$findMatchingParent(d,(e=>Ee(e)));if(!Ee(h)||!h.is(r))return;const[g,f]=M(r,d,d),m=g[0][0],C=g[g.length-1][g[0].length-1],{startRow:_,startColumn:p}=f,S=_===m.startRow&&p===m.startColumn,N=_===C.startRow&&p===C.startColumn;return S?"first":N?"last":void 0}function Ce(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function _e(e,n,o){return Y(e,t.$getNearestNodeFromDOMNode(n,o))}function pe(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 Se(t,n,o){o?(e.addClassNamesToElement(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(e.removeClassNamesFromElement(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Ne(t,n,o){o>0?(e.addClassNamesToElement(t,n.theme.tableFrozenColumn),t.setAttribute("data-lexical-frozen-column","true")):(e.removeClassNamesFromElement(t,n.theme.tableFrozenColumn),t.removeAttribute("data-lexical-frozen-column"))}function we(t,n,o){o>0?(e.addClassNamesToElement(t,n.theme.tableFrozenRow),t.setAttribute("data-lexical-frozen-row","true")):(e.removeClassNamesFromElement(t,n.theme.tableFrozenRow),t.removeAttribute("data-lexical-frozen-row"))}function be(t,n,o){if(!n.theme.tableAlignment)return;const r=[],l=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?l:r).push(t)}e.removeClassNamesFromElement(t,...r),e.addClassNamesToElement(t,...l)}const Te=new WeakSet;function ye(e=t.$getEditor()){return Te.has(e)}class Re extends t.ElementNode{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 Re(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:$e,priority:1})}}static importJSON(e){return Me().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&h(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table");this.__style&&(r.style.cssText=this.__style);const l=document.createElement("colgroup");if(r.appendChild(l),pe(r,0,this.getColumnCount(),this.getColWidths()),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),be(r,n,this.getFormatType()),this.__frozenColumnCount&&Ne(r,n,this.__frozenColumnCount),this.__frozenRowCount&&we(r,n,this.__frozenRowCount),this.__rowStriping&&Se(r,n,!0),ye(o)){const t=document.createElement("div"),o=n.theme.tableScrollableWrapper;return o?e.addClassNamesToElement(t,o):t.style.cssText="overflow-x: auto;",t.appendChild(r),t}return r}updateDOM(e,t,n){e.__rowStriping!==this.__rowStriping&&Se(t,n,this.__rowStriping),e.__frozenColumnCount!==this.__frozenColumnCount&&Ne(t,n,this.__frozenColumnCount),e.__frozenRowCount!==this.__frozenRowCount&&we(t,n,this.__frozenRowCount),pe(t,0,this.getColumnCount(),this.getColWidths());const o=this.getDOMSlot(t).element;return e.__style!==this.__style&&(o.style.cssText=this.__style),be(o,n,this.getFormatType()),!1}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o),this.__format&&be(o,t._config,this.getFormatType())),e.isHTMLElement(o)&&"TABLE"!==o.nodeName&&(o=o.querySelector("table")),!e.isHTMLElement(o))return null;const[r]=E(this,null,null),l=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();l.has(e)||l.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=l.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){l.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn)}}}const i=o.querySelector(":scope > colgroup");if(i){const e=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>s.has(t)));i.replaceChildren(...e)}const a=o.querySelectorAll(":scope > tr");if(a.length>0){const e=document.createElement("tbody");for(const t of a)e.appendChild(t);o.append(e)}return o},element:e.isHTMLElement(o)&&"TABLE"!==o.nodeName?o.querySelector("table"):o}}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=_e(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,n,o){const r=this.getDOMCellFromCords(e,n,o);if(null==r)return null;const l=t.$getNearestNodeFromDOMNode(r.elem);return c(l)?l: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){const t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{c(e)&&(t+=e.getColSpan())})),t}}function $e(t){const n=Me();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const r=t.querySelector(":scope > colgroup");if(r){let e=[];for(const t of r.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!o.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:t=>e.$descendantsMatching(t,C),node:n}}function Me(){return t.$applyNodeReplacement(new Re)}function Ee(e){return e instanceof Re}function Oe({rows:n,columns:o,includeHeaders:r}){const l=t.$getSelection();if(!l||!t.$isRangeSelection(l))return!1;if(de(l.anchor.getNode()))return!1;const s=N(Number(n),Number(o),r);e.$insertNodeToNearestRoot(s);const i=s.getFirstDescendant();return t.$isTextNode(i)&&i.select(),!0}function xe(e){C(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function Ae(t){Ee(t.getParent())?e.$unwrapAndFilterDescendants(t,c):t.remove()}function ve(n){e.$unwrapAndFilterDescendants(n,C);const[o]=E(n,null,null),r=o.reduce(((e,t)=>Math.max(e,t.length)),0),l=n.getChildren();for(let e=0;e<o.length;++e){const n=l[e];if(!n)continue;C(n)||h(254,n.constructor.name,n.getType());const s=o[e].reduce(((e,t)=>t?1+e:e),0);if(s!==r)for(let e=s;e<r;++e){const e=a();e.append(t.$createParagraphNode()),n.append(e)}}}function Fe(n){if(n.detail<3||!t.isDOMNode(n.target))return!1;const o=t.$getNearestNodeFromDOMNode(n.target);if(null===o)return!1;const r=e.$findMatchingParent(o,(e=>t.$isElementNode(e)&&!e.isInline()));if(null===r)return!1;return!!c(r.getParent())&&(r.select(0),!0)}exports.$computeTableMap=M,exports.$computeTableMapSkipCellCheck=E,exports.$createTableCellNode=a,exports.$createTableNode=Me,exports.$createTableNodeWithDimensions=N,exports.$createTableRowNode=m,exports.$createTableSelection=D,exports.$createTableSelectionFrom=I,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(C(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},exports.$deleteTableColumn__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=O(n),[s]=O(o),[i,a,c]=M(l,r,s),{startColumn:u}=a,{startRow:d,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+s.__colSpan-1),C=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const _=i.length;for(let e=0;e<_;e++)for(let t=f;t<=m;t++){const{cell:n,startColumn:o}=i[e][t];if(o<f){if(t===f){const e=f-o;n.setColSpan(n.__colSpan-Math.min(C,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=i[d],S=u>g?p[u+r.__colSpan]:p[g+s.__colSpan];if(void 0!==S){const{cell:e}=S;R(e)}else{const e=g<u?p[g-1]:p[u-1],{cell:t}=e;R(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,C),l.setColWidths(e)}},exports.$deleteTableRow__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=O(n),[s]=O(o),[i,a,c]=M(l,r,s),{startRow:u}=a,{startRow:d}=c,g=d+s.__rowSpan-1;if(i.length===g-u+1)return void l.remove();const f=i[0].length,m=r.__rowSpan,_=i[g+1],p=l.getChildAtIndex(g+1);for(let e=g;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=i[e][t];if(r===t){if(e===u&&o<u){const e=u-o;n.setRowSpan(n.__rowSpan-Math.min(m,n.__rowSpan-e))}if(o>=u&&o+n.__rowSpan-1>g){n.setRowSpan(n.__rowSpan-(g-o+1)),null===p&&h(122);let r=null;for(let n=0;n<t;n++){const t=_[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?$(p,n):r.insertAfter(n)}}}const t=l.getChildAtIndex(e);C(t)||h(206,String(e)),t.remove()}if(void 0!==_){const{cell:e}=_[0];R(e)}else{const e=i[u-1],{cell:t}=e[0];R(t)}},exports.$findCellNode=ue,exports.$findTableNode=de,exports.$getElementForTableNode=function(e,t){const n=e.getElementByKey(t.getKey());return null===n&&h(230),V(t,n)},exports.$getNodeTriplet=O,exports.$getTableAndElementByKey=L,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,(e=>c(e)));return c(n)?n:null},exports.$getTableCellNodeRect=A,exports.$getTableColumnIndexFromTableCellNode=function(e){return w(e).getChildren().findIndex((t=>t.is(e)))},exports.$getTableNodeFromLexicalNodeOrThrow=b,exports.$getTableRowIndexFromTableCellNode=function(e){const t=w(e);return b(t).getChildren().findIndex((e=>e.is(t)))},exports.$getTableRowNodeFromTableCellNodeOrThrow=w,exports.$insertTableColumn=function(e,n,o=!0,l,s){const i=e.getChildren(),u=[];for(let e=0;e<i.length;e++){const o=i[e];if(C(o))for(let e=0;e<l;e++){const e=o.getChildren();if(n>=e.length||n<0)throw new Error("Table column target index out of range");const l=e[n];c(l)||h(12);const{left:i,right:d}=T(l,s);let g=r.NO_STATUS;(i&&i.hasHeaderState(r.ROW)||d&&d.hasHeaderState(r.ROW))&&(g|=r.ROW);const f=a(g);f.append(t.$createParagraphNode()),u.push({newTableCell:f,targetCell:l})}}return u.forEach((({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)})),e},exports.$insertTableColumn__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||P(n)||h(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[s]=O(o),[i,,c]=O(l),[u,d,g]=M(c,i,s),f=u.length,m=e?Math.max(d.startColumn,g.startColumn):Math.min(d.startColumn,g.startColumn),_=e?m+i.__colSpan-1:m-1,p=c.getFirstChild();C(p)||h(120);let S=null;function N(e=r.NO_STATUS){const n=a(e).append(t.$createParagraphNode());return null===S&&(S=n),n}let w=p;e:for(let e=0;e<f;e++){if(0!==e){const e=w.getNextSibling();C(e)||h(121),w=e}const t=u[e],n=t[_<0?0:_].cell.__headerState,o=y(n,r.ROW);if(_<0){$(w,N(o));continue}const{cell:l,startColumn:s,startRow:i}=t[_];if(s+l.__colSpan-1<=_){let n=l,r=i,s=_;for(;r!==e&&n.__rowSpan>1;){if(s-=l.__colSpan,!(s>=0)){w.append(N(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(N(o))}else l.setColSpan(l.__colSpan+1)}null!==S&&R(S);const b=c.getColWidths();if(b){const e=[...b],t=_<0?0:_,n=e[t];e.splice(t,0,n),c.setColWidths(e)}return S},exports.$insertTableRow=function(e,n,o=!0,l,s){const i=e.getChildren();if(n>=i.length||n<0)throw new Error("Table row target index out of range");const u=i[n];if(!C(u))throw new Error("Row before insertion index does not exist.");for(let e=0;e<l;e++){const e=u.getChildren(),n=e.length,l=m();for(let o=0;o<n;o++){const n=e[o];c(n)||h(12);const{above:i,below:u}=T(n,s);let d=r.NO_STATUS;const g=i&&i.getWidth()||u&&u.getWidth()||void 0;(i&&i.hasHeaderState(r.COLUMN)||u&&u.hasHeaderState(r.COLUMN))&&(d|=r.COLUMN);const f=a(d,1,g);f.append(t.$createParagraphNode()),l.append(f)}o?u.insertAfter(l):u.insertBefore(l)}return e},exports.$insertTableRow__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||P(n)||h(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[s]=O(o),[i,,c]=O(l),[u,d,g]=M(c,i,s),f=u[0].length,{startRow:_}=g,{startRow:p}=d;let S=null;if(e){const e=Math.max(p+i.__rowSpan,_+s.__rowSpan)-1,n=u[e],o=m();for(let l=0;l<f;l++){const{cell:s,startRow:i}=n[l];if(i+s.__rowSpan-1<=e){const e=n[l].cell.__headerState,s=y(e,r.COLUMN);o.append(a(s).append(t.$createParagraphNode()))}else s.setRowSpan(s.__rowSpan+1)}const l=c.getChildAtIndex(e);C(l)||h(256),l.insertAfter(o),S=o}else{const e=Math.min(p,_),n=u[e],o=m();for(let l=0;l<f;l++){const{cell:s,startRow:i}=n[l];if(i===e){const e=n[l].cell.__headerState,s=y(e,r.COLUMN);o.append(a(s).append(t.$createParagraphNode()))}else s.setRowSpan(s.__rowSpan+1)}const l=c.getChildAtIndex(e);C(l)||h(257),l.insertBefore(o),S=o}return S},exports.$isScrollableTablesActive=ye,exports.$isTableCellNode=c,exports.$isTableNode=Ee,exports.$isTableRowNode=C,exports.$isTableSelection=P,exports.$removeTableRowAtIndex=function(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},exports.$unmergeCell=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const n=e.anchor.getNode(),[o,l,s]=O(n),i=o.__colSpan,c=o.__rowSpan;if(1===i&&1===c)return;const[u,d]=M(s,o,o),{startColumn:g,startRow:f}=d,m=o.__headerState&r.COLUMN,_=Array.from({length:i},((e,t)=>{let n=m;for(let e=0;0!==n&&e<u.length;e++)n&=u[e][t+g].cell.__headerState;return n})),p=o.__headerState&r.ROW,S=Array.from({length:c},((e,t)=>{let n=p;for(let e=0;0!==n&&e<u[0].length;e++)n&=u[t+f][e].cell.__headerState;return n}));if(i>1){for(let e=1;e<i;e++)o.insertAfter(a(_[e]|S[0]).append(t.$createParagraphNode()));o.setColSpan(1)}if(c>1){let e;for(let n=1;n<c;n++){const o=f+n,r=u[o];e=(e||l).getNextSibling(),C(e)||h(125);let s=null;for(let e=0;e<g;e++){const t=r[e],n=t.cell;t.startRow===o&&(s=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===s)for(let o=i-1;o>=0;o--)$(e,a(_[o]|S[n]).append(t.$createParagraphNode()));else for(let e=i-1;e>=0;e--)s.insertAfter(a(_[e]|S[n]).append(t.$createParagraphNode()))}o.setRowSpan(1)}},exports.INSERT_TABLE_COMMAND=u,exports.TableCellHeaderStates=r,exports.TableCellNode=l,exports.TableNode=Re,exports.TableObserver=k,exports.TableRowNode=g,exports.applyTableHandlers=q,exports.getDOMCellFromTarget=j,exports.getTableElement=B,exports.getTableObserverFromTableElement=G,exports.registerTableCellUnmergeTransform=function(t){return t.registerNodeTransform(l,(t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=O(t),[o]=M(n,t,t),r=o.length,l=o[0].length;let s=n.getFirstChild();C(s)||h(175);const i=[];for(let t=0;t<r;t++){0!==t&&(s=s.getNextSibling(),C(s)||h(175));let n=null;for(let r=0;r<l;r++){const l=o[t][r],u=l.cell;if(l.startRow===t&&l.startColumn===r)n=u,i.push(u);else if(u.getColSpan()>1||u.getRowSpan()>1){c(u)||h(176);const t=a(u.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(s,t)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))},exports.registerTablePlugin=function(n){return n.hasNodes([Re])||h(255),e.mergeRegister(n.registerCommand(u,Oe,t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(({nodes:e,selection:n})=>{if(!t.$isRangeSelection(n))return!1;return null!==de(n.anchor.getNode())&&e.some(Ee)}),t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.CLICK_COMMAND,Fe,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(Re,ve),n.registerNodeTransform(g,Ae),n.registerNodeTransform(l,xe))},exports.registerTableSelectionObserver=function(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=B(o,l),i=q(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Re,(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}=L(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()}},exports.setScrollableTablesActive=function(e,t){t?Te.add(e):Te.delete(e)};
"use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/clipboard");const o=/^(\d+(?:\.\d+)?)px$/,r={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class l extends t.ElementNode{static getType(){return"tablecell"}static clone(e){return new l(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:i,priority:0}),th:e=>({conversion:i,priority:0})}}static importJSON(e){return a().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=r.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),s(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const n=super.exportDOM(e);if(t.isHTMLElement(n.element)){const e=n.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=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return n}exportJSON(){return{...super.exportJSON(),...s(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,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=r.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}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,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!==r.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||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function s(e){return"middle"===e||"bottom"===e}function i(e){const n=e,l=e.nodeName.toLowerCase();let i;o.test(n.style.width)&&(i=parseFloat(n.style.width));const u=a("th"===l?r.ROW:r.NO_STATUS,n.colSpan,i);u.__rowSpan=n.rowSpan;const d=n.style.backgroundColor;""!==d&&(u.__backgroundColor=d);const h=n.style.verticalAlign;s(h)&&(u.__verticalAlign=h);const g=n.style,f=(g&&g.textDecoration||"").split(" "),m="700"===g.fontWeight||"bold"===g.fontWeight,C=f.includes("line-through"),_="italic"===g.fontStyle,p=f.includes("underline");return{after:e=>(0===e.length&&e.push(t.$createParagraphNode()),e),forChild:(e,n)=>{if(c(n)&&!t.$isElementNode(e)){const n=t.$createParagraphNode();return t.$isLineBreakNode(e)&&"\n"===e.getTextContent()?null:(t.$isTextNode(e)&&(m&&e.toggleFormat("bold"),C&&e.toggleFormat("strikethrough"),_&&e.toggleFormat("italic"),p&&e.toggleFormat("underline")),n.append(e),n)}return e},node:u}}function a(e=r.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new l(e,n,o))}function c(e){return e instanceof l}const u=t.createCommand("INSERT_TABLE_COMMAND");function d(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class h extends t.ElementNode{static getType(){return"tablerow"}static clone(e){return new h(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:g,priority:0})}}static importJSON(e){return f().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e.addClassNamesToElement(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function g(t){const n=t;let r;return o.test(n.style.height)&&(r=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,c),node:f(r)}}function f(e){return t.$applyNodeReplacement(new h(e))}function m(e){return e instanceof h}const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_=C&&"documentMode"in document?document.documentMode:null,p=C&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function S(e,n,o=!0){const l=Ee();for(let s=0;s<e;s++){const e=f();for(let l=0;l<n;l++){let n=r.NO_STATUS;"object"==typeof o?(0===s&&o.rows&&(n|=r.ROW),0===l&&o.columns&&(n|=r.COLUMN)):o&&(0===s&&(n|=r.ROW),0===l&&(n|=r.COLUMN));const i=a(n),c=t.$createParagraphNode();c.append(t.$createTextNode()),i.append(c),e.append(i)}l.append(e)}return l}function N(t){const n=e.$findMatchingParent(t,(e=>m(e)));if(m(n))return n;throw new Error("Expected table cell to be inside of table row.")}function w(t){const n=e.$findMatchingParent(t,(e=>xe(e)));if(xe(n))return n;throw new Error("Expected table cell to be inside of table.")}function b(e,t){const n=w(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)}}C&&"InputEvent"in window&&!_&&new window.InputEvent("input");const T=(e,t)=>e===r.BOTH||e===t?t:r.NO_STATUS;function $(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function y(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function R(e,t,n){const[o,r,l]=M(e,t,n);return null===r&&d(207),null===l&&d(208),[o,r,l]}function M(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];m(o)||d(209);const a=s(e);for(let u=o.getFirstChild(),h=0;null!=u;u=u.getNextSibling()){for(c(u)||d(147);void 0!==a[h];)h++;const o={cell:u,startColumn:h,startRow:e},{__rowSpan:g,__colSpan:f}=u;for(let t=0;t<g&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<f;e++)n[h+e]=o}null!==t&&null===r&&t.is(u)&&(r=o),null!==n&&null===l&&n.is(u)&&(l=o)}}return[o,r,l]}function E(t){let n;if(t instanceof l)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,c);c(o)||d(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),c);c(o)||d(148),n=o}const o=n.getParent();m(o)||d(149);const r=o.getParent();return xe(r)||d(210),[n,o,r]}function x(e,t,n){let o,r=Math.min(t.startColumn,n.startColumn),l=Math.min(t.startRow,n.startRow),s=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),i=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1);do{o=!1;for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const a=e[t][n];if(!a)continue;const c=a.startColumn+a.cell.__colSpan-1,u=a.startRow+a.cell.__rowSpan-1,d=a.startColumn<=s&&c>=r,h=a.startRow<=i&&u>=l;if(d&&h){const e=Math.min(r,a.startColumn),t=Math.max(s,c),n=Math.min(l,a.startRow),d=Math.max(i,u);e===r&&t===s&&n===l&&d===i||(r=e,s=t,l=n,i=d,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function O(e){const[t,,n]=E(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,a=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<a;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:i};r+=a}}return null}function A(t){const[[n,o,r,l],[s,i,a,u]]=["anchor","focus"].map((n=>{const o=t[n].getNode(),r=e.$findMatchingParent(o,c);c(r)||d(238,n,o.getKey(),o.getType());const l=r.getParent();m(l)||d(239,n);const s=l.getParent();return xe(s)||d(240,n),[o,r,l,s]}));return l.is(u)||d(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:a,focusTable:u}}class v{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 F(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 v(this.tableKey,t.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),t.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let n=0;this.getNodes().filter(c).forEach((e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())}));const o=t.TEXT_TYPE_TO_FORMAT[e];return!!(n&o)}insertNodes(e){const n=this.focus.getNode();t.$isElementNode(n)||d(151);t.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=A(this),n=O(e);null===n&&d(153);const o=O(t);null===o&&d(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:n,anchorCell:o,focusCell:r}=A(this),l=r.getParents()[1];if(l!==n){if(n.isParentOf(r)){const e=l.getParent();null==e&&d(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&d(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[s,i,a]=R(n,o,r),{minColumn:c,maxColumn:u,minRow:h,maxRow:g}=x(s,i,a),f=new Map([[n.getKey(),n]]);let C=null;for(let e=h;e<=g;e++)for(let t=c;t<=u;t++){const{cell:n}=s[e][t],o=n.getParent();m(o)||d(160),o!==C&&(f.set(o.getKey(),o),C=o),f.has(n.getKey())||I(n,(e=>{f.set(e.getKey(),e)}))}const _=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=_),_}getTextContent(){const e=this.getNodes().filter((e=>c(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 F(e){return e instanceof v}function P(){const e=t.$createPoint("root",0,"element"),n=t.$createPoint("root",0,"element");return new v("root",e,n)}function D(e,n,o){e.getKey(),n.getKey(),o.getKey();const r=t.$getSelection(),l=F(r)?r.clone():P();return l.set(e.getKey(),n.getKey(),o.getKey()),l}function I(e,n){const o=[[e]];for(let e=o.at(-1);void 0!==e&&o.length>0;e=o.at(-1)){const r=e.pop();void 0===r?o.pop():!1!==n(r)&&t.$isElementNode(r)&&o.push(r.getChildren())}}function K(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);xe(o)||d(231,e);const r=B(o,n.getElementByKey(e));return null===r&&d(232,e),{tableElement:r,tableNode:o}}class L{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 K(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=j(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=j(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:n,tableElement:o}=this.$lookup();V(e,j(n,o),null),null!==t.$getSelection()&&(t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){const t=this.editor,{tableElement:n}=this.$lookup();e.removeClassNamesFromElement(n,t._config.theme.tableSelection),n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e.addClassNamesToElement(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&d(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),V(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=t.getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=e.x,s=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===l&&this.anchorY===s&&!n){if(l===this.focusX&&s===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=l,this.focusY=s,this.isHighlightingCells){const n=_e(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=D(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),V(o,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?t.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&d(234),e}$getFocusTableCell(){return this.focusCellNodeKey?t.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&d(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=_e(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():P(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();F(n)||d(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(c);s.length>0||d(237);const i=s[0].getFirstChild(),a=t.$isParagraphNode(i)?i.getFormatFlags(e,null):null;s.forEach((t=>{r.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),o.formatText(e,a)})),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!xe(n))throw new Error("Expected TableNode.");const o=t.$getSelection();F(o)||d(253);const r=o.getNodes().filter(c);if(r.length===this.table.columns*this.table.rows){n.selectPrevious();const o=n.getParent();return n.remove(),void(t.$isRootNode(o)&&o.isEmpty()&&e.dispatchCommand(t.INSERT_PARAGRAPH_COMMAND,void 0))}r.forEach((e=>{if(t.$isElementNode(e)){const n=t.$createParagraphNode(),o=t.$createTextNode();n.append(o),e.append(n),e.getChildren().forEach((e=>{e!==n&&e.remove()}))}})),V(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const k="__lexicalTableSelection",H=e=>!(1&~e.buttons);function B(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&d(245,t.nodeName),n}function W(e){return e._window}function z(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;c(n)&&(o=n)}return null}const Y=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],U=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],X=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function J(o,r,l,s){const i=l.getRootElement(),a=W(l);null!==i&&null!==a||d(246);const u=new L(l,o.getKey()),h=B(o,r);!function(e,t){null!==q(e)&&d(205);e[k]=t}(h,u),u.listenersToRemove.add((()=>function(e,t){q(e)===t&&delete e[k]}(h,u)));const g=e=>{if(0!==e.button||!t.isDOMNode(e.target)||!a)return;const n=G(e.target);null!==n&&l.update((()=>{const r=t.$getPreviousSelection();if(p&&e.shiftKey&&le(r,o)&&(t.$isRangeSelection(r)||F(r))){const t=r.anchor.getNode(),l=z(o,r.anchor.getNode());if(l)u.$setAnchorCellForSelection(Ce(u,l)),u.$setFocusCellForSelection(n),ge(e);else{(o.isBefore(t)?o.selectStart():o.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else u.$setAnchorCellForSelection(n)})),(()=>{if(u.isSelecting)return;const e=()=>{u.isSelecting=!1,a.removeEventListener("mouseup",e),a.removeEventListener("mousemove",n)},n=o=>{if(!t.isDOMNode(o.target))return;if(!H(o)&&u.isSelecting)return u.isSelecting=!1,a.removeEventListener("mouseup",e),void a.removeEventListener("mousemove",n);const r=!h.contains(o.target);let s=null;if(r){for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(s=h.contains(e)?G(e):null,s)break}else s=G(o.target);!s||null!==u.focusCell&&s.elem===u.focusCell.elem||(u.setNextFocus({focusCell:s,override:r}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};u.isSelecting=!0,a.addEventListener("mouseup",e,u.listenerOptions),a.addEventListener("mousemove",n,u.listenerOptions)})()};h.addEventListener("mousedown",g,u.listenerOptions),u.listenersToRemove.add((()=>{h.removeEventListener("mousedown",g)}));const f=e=>{if(e.detail>=3&&t.isDOMNode(e.target)){null!==G(e.target)&&e.preventDefault()}};h.addEventListener("mousedown",f,u.listenerOptions),u.listenersToRemove.add((()=>{h.removeEventListener("mousedown",f)}));const C=e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update((()=>{const e=t.$getSelection();F(e)&&e.tableKey===u.tableNodeKey&&i.contains(n)&&u.$clearHighlight()}))};a.addEventListener("mousedown",C,u.listenerOptions),u.listenersToRemove.add((()=>{a.removeEventListener("mousedown",C)}));for(const[e,n]of Y)u.listenersToRemove.add(l.registerCommand(e,(e=>he(l,e,n,o,u)),t.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,(e=>{const n=t.$getSelection();if(F(n)){const t=z(o,n.focus.getNode());if(null!==t)return ge(e),t.selectEnd(),!0}return!1}),t.COMMAND_PRIORITY_HIGH));const _=n=>()=>{const r=t.$getSelection();if(!le(r,o))return!1;if(F(r))return u.$clearText(),!0;if(t.$isRangeSelection(r)){if(!c(z(o,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),s=r.focus.getNode(),i=o.isParentOf(l),a=o.isParentOf(s);if(i&&!a||a&&!i)return u.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),(e=>t.$isElementNode(e))),h=d&&e.$findMatchingParent(d,(e=>t.$isElementNode(e)&&c(e.getParent())));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(n===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of U)u.listenersToRemove.add(l.registerCommand(e,_(e),t.COMMAND_PRIORITY_CRITICAL));const S=e=>{const n=t.$getSelection();if(!F(n)&&!t.$isRangeSelection(n))return!1;const r=o.isParentOf(n.anchor.getNode());if(r!==o.isParentOf(n.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:s,type:i}=n[t];return o[n[e].isBefore(n[t])?"selectPrevious":"selectNext"]()[t].set(l,s,i),!1}return!!le(n,o)&&(!!F(n)&&(e&&(e.preventDefault(),e.stopPropagation()),u.$clearText(),!0))};for(const e of X)u.listenersToRemove.add(l.registerCommand(e,S,t.COMMAND_PRIORITY_CRITICAL));return u.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,(o=>{const r=t.$getSelection();if(r){if(!F(r)&&!t.$isRangeSelection(r))return!1;n.copyToClipboard(l,e.objectKlassEquals(o,ClipboardEvent)?o:null,n.$getClipboardDataFromSelection(r));const s=S(o);return t.$isRangeSelection(r)?(r.removeText(),!0):s}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,(n=>{const r=t.$getSelection();if(!le(r,o))return!1;if(F(r))return u.$formatCells(n),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(t))return!1}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,(e=>{const n=t.$getSelection();if(!F(n)||!le(n,o))return!1;const r=n.anchor.getNode(),l=n.focus.getNode();if(!c(r)||!c(l))return!1;if(function(e,t){if(F(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=R(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,o))return o.setFormat(e),!0;const[s,i,a]=R(o,r,l),u=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(i.startColumn+i.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(i.startRow,a.startRow),g=Math.min(i.startColumn,a.startColumn),f=new Set;for(let n=h;n<=u;n++)for(let o=g;o<=d;o++){const r=s[n][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(e);const l=r.getChildren();for(let n=0;n<l.length;n++){const o=l[n];t.$isElementNode(o)&&!o.isInline()&&o.setFormat(e)}}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.CONTROLLED_TEXT_INSERTION_COMMAND,(n=>{const r=t.$getSelection();if(!le(r,o))return!1;if(F(r))return u.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const s=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(s))return!1;if("string"==typeof n){const e=me(l,r,o);if(e)return fe(e,o,[t.$createTextNode(n)]),!0}}return!1}),t.COMMAND_PRIORITY_CRITICAL)),s&&u.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,(n=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!le(r,o))return!1;const l=ce(r.anchor.getNode());return!(null===l||!o.is(ue(l)))&&(ge(n),function(n,o){const r="next"===o?"getNextSibling":"getPreviousSibling",l="next"===o?"getFirstChild":"getLastChild",s=n[r]();if(t.$isElementNode(s))return s.selectEnd();const i=e.$findMatchingParent(n,m);null===i&&d(247);for(let e=i[r]();m(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(i,xe);null===a&&d(248);"next"===o?a.selectNext():a.selectPrevious()}(l,n.shiftKey?"previous":"next"),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,(e=>o.isSelected()),t.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n=>{const{nodes:o,selection:r}=n,l=r.getStartEndPoints(),s=F(r),i=t.$isRangeSelection(r)&&null!==e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)))&&null!==e.$findMatchingParent(r.focus.getNode(),(e=>c(e)))||s;if(1!==o.length||!xe(o[0])||!i||null===l)return!1;const[a]=l,u=o[0],d=u.getChildren(),h=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),f=e.$findMatchingParent(a.getNode(),(e=>c(e))),C=f&&e.$findMatchingParent(f,(e=>m(e))),_=C&&e.$findMatchingParent(C,(e=>xe(e)));if(!c(f)||!m(C)||!xe(_))return!1;const p=C.getIndexWithinParent(),S=Math.min(_.getChildrenSize()-1,p+g-1),N=f.getIndexWithinParent(),w=Math.min(C.getChildrenSize()-1,N+h-1),b=Math.min(N,w),T=Math.min(p,S),$=Math.max(N,w),y=Math.max(p,S),R=_.getChildren();let M=0;for(let e=T;e<=y;e++){const n=R[e];if(!m(n))return!1;const o=d[M];if(!m(o))return!1;const r=n.getChildren(),l=o.getChildren();let s=0;for(let e=b;e<=$;e++){const n=r[e];if(!c(n))return!1;const o=l[s];if(!c(o))return!1;const i=n.getChildren();o.getChildren().forEach((e=>{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),n.append(e)}else n.append(e)})),i.forEach((e=>e.remove())),s++}M++}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,(()=>{const n=t.$getSelection(),r=t.$getPreviousSelection(),s=u.getAndClearNextFocus();if(null!==s){const{focusCell:e}=s;if(F(n)&&n.tableKey===u.tableNodeKey)return(e.x!==u.focusX||e.y!==u.focusY)&&(u.$setFocusCellForSelection(e),!0);if(e!==u.anchorCell&&le(n,o))return u.$setFocusCellForSelection(e),!0}if(u.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(n)&&n.isCollapsed()){const t=n.anchor.getNode(),r=o.getFirstChild(),l=ce(t);if(null!==l&&m(r)){const t=r.getFirstChild();if(c(t)&&o.is(e.$findMatchingParent(l,(e=>e.is(o)||e.is(t)))))return t.selectStart(),!0}}if(t.$isRangeSelection(n)){const{anchor:e,focus:r}=n,s=e.getNode(),i=r.getNode(),a=ce(s),c=ce(i),d=!(!a||!o.is(ue(a))),h=!(!c||!o.is(ue(c))),g=d!==h,f=d&&h,m=n.isBackward();if(g){const e=n.clone();if(h){const[t]=R(o,c,c),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(m?n.getKey():r.getKey(),m?n.getChildrenSize():r.getChildrenSize(),"element")}else if(d){const[t]=R(o,a,a),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(m?r.getKey():n.getKey(),m?r.getChildrenSize():0,"element")}t.$setSelection(e),Z(l,u)}else f&&(a.is(c)||(u.$setAnchorCellForSelection(Ce(u,a)),u.$setFocusCellForSelection(Ce(u,c),!0)))}else if(n&&F(n)&&n.is(r)&&n.tableKey===o.getKey()){const e=t.getDOMSelection(a);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),s=r&&!o.isParentOf(r),i=t.$getNearestNodeFromDOMNode(e.anchorNode),a=i&&o.isParentOf(i);if(s&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(o.getKey(),n.isBackward()?o.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return n&&!n.is(r)&&(F(n)||F(r))&&u.tableSelection&&!u.tableSelection.is(r)?(F(n)&&n.tableKey===u.tableNodeKey?u.$updateTableTableSelection(n):!F(n)&&F(r)&&r.tableKey===u.tableNodeKey&&u.$updateTableTableSelection(null),!1):(u.hasHijackedSelectionStyles&&!o.isSelected()?function(e,t){t.$enableHighlightStyle(),Q(t.table,(t=>{const n=t.elem;t.highlighted=!1,ae(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(l,u):!u.hasHijackedSelectionStyles&&o.isSelected()&&Z(l,u),!1)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!le(e,o))return!1;const n=me(l,e,o);return!!n&&(fe(n,o),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u}function q(e){return e[k]||null}function G(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 j(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=B(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 V(e,t,n){const o=new Set(n?n.getNodes():[]);Q(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,ie(e,t)):(t.highlighted=!1,ae(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Q(e,n){const{domRows:o}=e;for(let e=0;e<o.length;e++){const r=o[e];if(r)for(let o=0;o<r.length;o++){const l=r[o];if(!l)continue;const s=t.$getNearestNodeFromDOMNode(l.elem);null!==s&&n(l,s,{x:o,y:e})}}}function Z(e,t){t.$disableHighlightStyle(),Q(t.table,(t=>{t.highlighted=!0,ie(e,t)}))}const ee=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?se(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?se(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?se(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?se(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function te(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 ne([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function oe(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&d(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&d(250,n,String(s)),i}function re(e,t,n,o,r){const l=x(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,a=1,c=1;const u=e[r],d=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),a=Math.max(a,e[t][o].cell.__colSpan);return{bottomSpan:c,leftSpan:i,rightSpan:a,topSpan:s}}(t,l),{topSpan:i,leftSpan:a,bottomSpan:c,rightSpan:u}=s,h=function(e,t){const n=te(e,t);return null===n&&d(249,t.cell.getKey()),n}(l,n),[g,f]=ne(h);let m=l[g],C=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?C+="maxRow"===f?1:i:"up"===r&&(C-="minRow"===f?1:c);const _=t[C];if(void 0===_)return!1;const p=_[m];if(void 0===p)return!1;const[S,N]=function(e,t,n){const o=x(e,t,n),r=te(o,t);if(r)return[oe(e,o,r),oe(e,o,ne(r))];const l=te(o,n);if(l)return[oe(e,o,ne(l)),oe(e,o,l)];const s=["minColumn","minRow"];return[oe(e,o,s),oe(e,o,ne(s))]}(t,n,p),w=Ce(e,S.cell),b=Ce(e,N.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function le(e,n){if(t.$isRangeSelection(e)||F(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function se(e,t){t?e.selectStart():e.selectEnd()}function ie(n,o){const r=o.elem,l=n._config.theme;c(t.$getNearestNodeFromDOMNode(r))||d(131),e.addClassNamesToElement(r,l.tableCellSelected)}function ae(n,o){const r=o.elem;c(t.$getNearestNodeFromDOMNode(r))||d(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ce(t){const n=e.$findMatchingParent(t,c);return c(n)?n:null}function ue(t){const n=e.$findMatchingParent(t,xe);return xe(n)?n:null}function de(n,o,r,l,s,i,a){const u=t.$caretFromPoint(r.focus,s?"previous":"next");if(t.$isExtendableTextPointCaret(u))return!1;let d=u;for(const e of t.$extendCaretToRange(u).iterNodeCarets("shadowRoot")){if(!t.$isSiblingCaret(e)||!t.$isElementNode(e.origin))return!1;d=e}const h=d.getParentAtCaret();if(!c(h))return!1;const g=h,f=function(e){for(const n of t.$extendCaretToRange(e).iterNodeCarets("root")){const{origin:o}=n;if(c(o)){if(t.$isChildCaret(n))return t.$getChildCaret(o,e.direction)}else if(!m(o))break}return null}(t.$getSiblingCaret(g,d.direction)),C=e.$findMatchingParent(g,xe);if(!C||!C.is(i))return!1;const _=n.getElementByKey(g.getKey()),p=G(_);if(!_||!p)return!1;const S=Re(n,C);if(a.table=S,f)if("extend"===l){const e=G(n.getElementByKey(f.origin.getKey()));if(!e)return!1;a.$setAnchorCellForSelection(p),a.$setFocusCellForSelection(e,!0)}else{const e=t.$normalizeCaret(f);t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}else if("extend"===l)a.$setAnchorCellForSelection(p),a.$setFocusCellForSelection(p,!0);else{const e=function(e){const n=t.$getAdjacentChildCaret(e);return t.$isChildCaret(n)?t.$normalizeCaret(n):e}(t.$getSiblingCaret(C,u.direction));t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}return ge(o),!0}function he(n,o,r,l,s){if(("up"===r||"down"===r)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(n))return!1;const i=t.$getSelection();if(!le(i,l)){if(t.$isRangeSelection(i)){if("backward"===r){if(i.focus.offset>0)return!1;const e=function(e){for(let n=e,o=e;null!==o;n=o,o=o.getParent())if(t.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(i.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!xe(n)&&(ge(o),o.shiftKey?i.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(o.shiftKey&&("up"===r||"down"===r)){const n=i.focus.getNode();if(!i.isCollapsed()&&("up"===r&&!i.isBackward()||"down"===r&&i.isBackward())){let s=e.$findMatchingParent(n,(e=>xe(e)));if(c(s)&&(s=e.$findMatchingParent(s,xe)),s!==l)return!1;if(!s)return!1;const a="down"===r?s.getNextSibling():s.getPreviousSibling();if(!a)return!1;let u=0;"up"===r&&t.$isElementNode(a)&&(u=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,u=t.$isTextNode(d)?d.getTextContentSize():0}const h=i.clone();return h.focus.set(d.getKey(),u,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),ge(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==z(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=E(e),[o]=E(t),r=l.getCordsFromCellNode(n,s.table),i=l.getCordsFromCellNode(o,s.table),a=l.getDOMCellFromCordsOrThrow(r.x,r.y,s.table),c=l.getDOMCellFromCordsOrThrow(i.x,i.y,s.table);return s.$setAnchorCellForSelection(a),s.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(c(l)&&(l=e.$findMatchingParent(l,xe)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(xe(a)&&s.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=E(e),[s]=E(n),c=i.clone();return c.focus.set(("up"===r?l:s).getKey(),"up"===r?0:s.getChildrenSize(),"element"),ge(o),t.$setSelection(c),!0}}}}return"down"===r&&$e(n)&&s.setShouldCheckSelection(),!1}if(t.$isRangeSelection(i)){if("backward"===r||"forward"===r){return de(n,o,i,o.shiftKey?"extend":"move","backward"===r,l,s)}if(i.isCollapsed()){const{anchor:a,focus:u}=i,d=e.$findMatchingParent(a.getNode(),c),h=e.$findMatchingParent(u.getNode(),c);if(!c(d)||!d.is(h))return!1;const g=ue(d);if(g!==l&&null!=g){const e=B(g,n.getElementByKey(g.getKey()));if(null!=e)return s.table=j(g,e),he(n,o,r,g,s)}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let C;if("element"===a.type)C=m.getBoundingClientRect();else{const e=t.getDOMSelection(W(n));if(null===e||0===e.rangeCount)return!1;C=e.getRangeAt(0).getBoundingClientRect()}const _="up"===r?d.getFirstChild():d.getLastChild();if(null==_)return!1;const p=n.getElementByKey(_.__key);if(null==p)return!1;const S=p.getBoundingClientRect();if("up"===r?S.top>C.top-C.height:C.bottom+C.height>S.bottom){ge(o);const e=l.getCordsFromCellNode(d,s.table);if(!o.shiftKey)return ee(s,l,e.x,e.y,r);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,s.table);s.$setAnchorCellForSelection(t),s.$setFocusCellForSelection(t,!0)}return!0}}}else if(F(i)){const{anchor:t,focus:a}=i,u=e.$findMatchingParent(t.getNode(),c),h=e.$findMatchingParent(a.getNode(),c),[g]=i.getNodes();xe(g)||d(251);const f=B(g,n.getElementByKey(g.getKey()));if(!c(u)||!c(h)||!xe(g)||null==f)return!1;s.$updateTableTableSelection(i);const m=j(g,f),C=l.getCordsFromCellNode(u,m),_=l.getDOMCellFromCordsOrThrow(C.x,C.y,m);if(s.$setAnchorCellForSelection(_),ge(o),o.shiftKey){const[e,t,n]=R(l,u,h);return re(s,e,t,n,r)}return h.selectEnd(),!0}return!1}function ge(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function fe(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function me(n,o,r){const l=r.getParent();if(!l)return;const s=t.getDOMSelection(W(n));if(!s)return;const i=s.anchorNode,a=n.getElementByKey(l.getKey()),u=B(r,n.getElementByKey(r.getKey()));if(!i||!a||!u||!a.contains(i)||u.contains(i))return;const d=e.$findMatchingParent(o.anchor.getNode(),(e=>c(e)));if(!d)return;const h=e.$findMatchingParent(d,(e=>xe(e)));if(!xe(h)||!h.is(r))return;const[g,f]=R(r,d,d),m=g[0][0],C=g[g.length-1][g[0].length-1],{startRow:_,startColumn:p}=f,S=_===m.startRow&&p===m.startColumn,N=_===C.startRow&&p===C.startColumn;return S?"first":N?"last":void 0}function Ce(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function _e(e,n,o){return z(e,t.$getNearestNodeFromDOMNode(n,o))}function pe(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 Se(t,n,o){o?(e.addClassNamesToElement(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(e.removeClassNamesFromElement(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Ne(t,n,o){o>0?(e.addClassNamesToElement(t,n.theme.tableFrozenColumn),t.setAttribute("data-lexical-frozen-column","true")):(e.removeClassNamesFromElement(t,n.theme.tableFrozenColumn),t.removeAttribute("data-lexical-frozen-column"))}function we(t,n,o){o>0?(e.addClassNamesToElement(t,n.theme.tableFrozenRow),t.setAttribute("data-lexical-frozen-row","true")):(e.removeClassNamesFromElement(t,n.theme.tableFrozenRow),t.removeAttribute("data-lexical-frozen-row"))}function be(t,n,o){if(!n.theme.tableAlignment)return;const r=[],l=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?l:r).push(t)}e.removeClassNamesFromElement(t,...r),e.addClassNamesToElement(t,...l)}const Te=new WeakSet;function $e(e=t.$getEditor()){return Te.has(e)}class ye extends t.ElementNode{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 ye(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:Me,priority:1})}}static importJSON(e){return Ee().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&d(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table");this.__style&&(r.style.cssText=this.__style);const l=document.createElement("colgroup");if(r.appendChild(l),pe(r,0,this.getColumnCount(),this.getColWidths()),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),be(r,n,this.getFormatType()),this.__frozenColumnCount&&Ne(r,n,this.__frozenColumnCount),this.__frozenRowCount&&we(r,n,this.__frozenRowCount),this.__rowStriping&&Se(r,n,!0),$e(o)){const t=document.createElement("div"),o=n.theme.tableScrollableWrapper;return o?e.addClassNamesToElement(t,o):t.style.cssText="overflow-x: auto;",t.appendChild(r),t}return r}updateDOM(e,t,n){e.__rowStriping!==this.__rowStriping&&Se(t,n,this.__rowStriping),e.__frozenColumnCount!==this.__frozenColumnCount&&Ne(t,n,this.__frozenColumnCount),e.__frozenRowCount!==this.__frozenRowCount&&we(t,n,this.__frozenRowCount),pe(t,0,this.getColumnCount(),this.getColWidths());const o=this.getDOMSlot(t).element;return e.__style!==this.__style&&(o.style.cssText=this.__style),be(o,n,this.getFormatType()),!1}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o),this.__format&&be(o,t._config,this.getFormatType())),e.isHTMLElement(o)&&"TABLE"!==o.nodeName&&(o=o.querySelector("table")),!e.isHTMLElement(o))return null;const[r]=M(this,null,null),l=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();l.has(e)||l.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=l.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){l.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn)}}}const i=o.querySelector(":scope > colgroup");if(i){const e=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>s.has(t)));i.replaceChildren(...e)}const a=o.querySelectorAll(":scope > tr");if(a.length>0){const e=document.createElement("tbody");for(const t of a)e.appendChild(t);o.append(e)}return o},element:e.isHTMLElement(o)&&"TABLE"!==o.nodeName?o.querySelector("table"):o}}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=_e(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,n,o){const r=this.getDOMCellFromCords(e,n,o);if(null==r)return null;const l=t.$getNearestNodeFromDOMNode(r.elem);return c(l)?l: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){const t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{c(e)&&(t+=e.getColSpan())})),t}}function Re(e,t){const n=e.getElementByKey(t.getKey());return null===n&&d(230),j(t,n)}function Me(t){const n=Ee();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const r=t.querySelector(":scope > colgroup");if(r){let e=[];for(const t of r.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!o.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:t=>e.$descendantsMatching(t,m),node:n}}function Ee(){return t.$applyNodeReplacement(new ye)}function xe(e){return e instanceof ye}function Oe({rows:n,columns:o,includeHeaders:r}){const l=t.$getSelection();if(!l||!t.$isRangeSelection(l))return!1;if(ue(l.anchor.getNode()))return!1;const s=S(Number(n),Number(o),r);e.$insertNodeToNearestRoot(s);const i=s.getFirstDescendant();return t.$isTextNode(i)&&i.select(),!0}function Ae(e){m(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function ve(t){xe(t.getParent())?e.$unwrapAndFilterDescendants(t,c):t.remove()}function Fe(n){e.$unwrapAndFilterDescendants(n,m);const[o]=M(n,null,null),r=o.reduce(((e,t)=>Math.max(e,t.length)),0),l=n.getChildren();for(let e=0;e<o.length;++e){const n=l[e];if(!n)continue;m(n)||d(254,n.constructor.name,n.getType());const s=o[e].reduce(((e,t)=>t?1+e:e),0);if(s!==r)for(let e=s;e<r;++e){const e=a();e.append(t.$createParagraphNode()),n.append(e)}}}function Pe(n){if(n.detail<3||!t.isDOMNode(n.target))return!1;const o=t.$getNearestNodeFromDOMNode(n.target);if(null===o)return!1;const r=e.$findMatchingParent(o,(e=>t.$isElementNode(e)&&!e.isInline()));if(null===r)return!1;return!!c(r.getParent())&&(r.select(0),!0)}exports.$computeTableMap=R,exports.$computeTableMapSkipCellCheck=M,exports.$createTableCellNode=a,exports.$createTableNode=Ee,exports.$createTableNodeWithDimensions=S,exports.$createTableRowNode=f,exports.$createTableSelection=P,exports.$createTableSelectionFrom=D,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(m(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},exports.$deleteTableColumn__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||F(e)||d(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=E(n),[s]=E(o),[i,a,c]=R(l,r,s),{startColumn:u}=a,{startRow:h,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+s.__colSpan-1),C=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const _=i.length;for(let e=0;e<_;e++)for(let t=f;t<=m;t++){const{cell:n,startColumn:o}=i[e][t];if(o<f){if(t===f){const e=f-o;n.setColSpan(n.__colSpan-Math.min(C,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=i[h],S=u>g?p[u+r.__colSpan]:p[g+s.__colSpan];if(void 0!==S){const{cell:e}=S;$(e)}else{const e=g<u?p[g-1]:p[u-1],{cell:t}=e;$(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,C),l.setColWidths(e)}},exports.$deleteTableRow__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||F(e)||d(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=E(n),[s]=E(o),[i,a,c]=R(l,r,s),{startRow:u}=a,{startRow:h}=c,g=h+s.__rowSpan-1;if(i.length===g-u+1)return void l.remove();const f=i[0].length,C=r.__rowSpan,_=i[g+1],p=l.getChildAtIndex(g+1);for(let e=g;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=i[e][t];if(r===t){if(e===u&&o<u){const e=u-o;n.setRowSpan(n.__rowSpan-Math.min(C,n.__rowSpan-e))}if(o>=u&&o+n.__rowSpan-1>g){n.setRowSpan(n.__rowSpan-(g-o+1)),null===p&&d(122);let r=null;for(let n=0;n<t;n++){const t=_[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?y(p,n):r.insertAfter(n)}}}const t=l.getChildAtIndex(e);m(t)||d(206,String(e)),t.remove()}if(void 0!==_){const{cell:e}=_[0];$(e)}else{const e=i[u-1],{cell:t}=e[0];$(t)}},exports.$findCellNode=ce,exports.$findTableNode=ue,exports.$getElementForTableNode=Re,exports.$getNodeTriplet=E,exports.$getTableAndElementByKey=K,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,(e=>c(e)));return c(n)?n:null},exports.$getTableCellNodeRect=O,exports.$getTableColumnIndexFromTableCellNode=function(e){return N(e).getChildren().findIndex((t=>t.is(e)))},exports.$getTableNodeFromLexicalNodeOrThrow=w,exports.$getTableRowIndexFromTableCellNode=function(e){const t=N(e);return w(t).getChildren().findIndex((e=>e.is(t)))},exports.$getTableRowNodeFromTableCellNodeOrThrow=N,exports.$insertTableColumn=function(e,n,o=!0,l,s){const i=e.getChildren(),u=[];for(let e=0;e<i.length;e++){const o=i[e];if(m(o))for(let e=0;e<l;e++){const e=o.getChildren();if(n>=e.length||n<0)throw new Error("Table column target index out of range");const l=e[n];c(l)||d(12);const{left:i,right:h}=b(l,s);let g=r.NO_STATUS;(i&&i.hasHeaderState(r.ROW)||h&&h.hasHeaderState(r.ROW))&&(g|=r.ROW);const f=a(g);f.append(t.$createParagraphNode()),u.push({newTableCell:f,targetCell:l})}}return u.forEach((({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)})),e},exports.$insertTableColumn__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||F(n)||d(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[s]=E(o),[i,,c]=E(l),[u,h,g]=R(c,i,s),f=u.length,C=e?Math.max(h.startColumn,g.startColumn):Math.min(h.startColumn,g.startColumn),_=e?C+i.__colSpan-1:C-1,p=c.getFirstChild();m(p)||d(120);let S=null;function N(e=r.NO_STATUS){const n=a(e).append(t.$createParagraphNode());return null===S&&(S=n),n}let w=p;e:for(let e=0;e<f;e++){if(0!==e){const e=w.getNextSibling();m(e)||d(121),w=e}const t=u[e],n=t[_<0?0:_].cell.__headerState,o=T(n,r.ROW);if(_<0){y(w,N(o));continue}const{cell:l,startColumn:s,startRow:i}=t[_];if(s+l.__colSpan-1<=_){let n=l,r=i,s=_;for(;r!==e&&n.__rowSpan>1;){if(s-=l.__colSpan,!(s>=0)){w.append(N(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(N(o))}else l.setColSpan(l.__colSpan+1)}null!==S&&$(S);const b=c.getColWidths();if(b){const e=[...b],t=_<0?0:_,n=e[t];e.splice(t,0,n),c.setColWidths(e)}return S},exports.$insertTableRow=function(e,n,o=!0,l,s){const i=e.getChildren();if(n>=i.length||n<0)throw new Error("Table row target index out of range");const u=i[n];if(!m(u))throw new Error("Row before insertion index does not exist.");for(let e=0;e<l;e++){const e=u.getChildren(),n=e.length,l=f();for(let o=0;o<n;o++){const n=e[o];c(n)||d(12);const{above:i,below:u}=b(n,s);let h=r.NO_STATUS;const g=i&&i.getWidth()||u&&u.getWidth()||void 0;(i&&i.hasHeaderState(r.COLUMN)||u&&u.hasHeaderState(r.COLUMN))&&(h|=r.COLUMN);const f=a(h,1,g);f.append(t.$createParagraphNode()),l.append(f)}o?u.insertAfter(l):u.insertBefore(l)}return e},exports.$insertTableRow__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||F(n)||d(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[s]=E(o),[i,,c]=E(l),[u,h,g]=R(c,i,s),C=u[0].length,{startRow:_}=g,{startRow:p}=h;let S=null;if(e){const e=Math.max(p+i.__rowSpan,_+s.__rowSpan)-1,n=u[e],o=f();for(let l=0;l<C;l++){const{cell:s,startRow:i}=n[l];if(i+s.__rowSpan-1<=e){const e=n[l].cell.__headerState,s=T(e,r.COLUMN);o.append(a(s).append(t.$createParagraphNode()))}else s.setRowSpan(s.__rowSpan+1)}const l=c.getChildAtIndex(e);m(l)||d(256),l.insertAfter(o),S=o}else{const e=Math.min(p,_),n=u[e],o=f();for(let l=0;l<C;l++){const{cell:s,startRow:i}=n[l];if(i===e){const e=n[l].cell.__headerState,s=T(e,r.COLUMN);o.append(a(s).append(t.$createParagraphNode()))}else s.setRowSpan(s.__rowSpan+1)}const l=c.getChildAtIndex(e);m(l)||d(257),l.insertBefore(o),S=o}return S},exports.$isScrollableTablesActive=$e,exports.$isTableCellNode=c,exports.$isTableNode=xe,exports.$isTableRowNode=m,exports.$isTableSelection=F,exports.$removeTableRowAtIndex=function(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},exports.$unmergeCell=function(){const e=t.$getSelection();t.$isRangeSelection(e)||F(e)||d(188);const n=e.anchor.getNode(),[o,l,s]=E(n),i=o.__colSpan,c=o.__rowSpan;if(1===i&&1===c)return;const[u,h]=R(s,o,o),{startColumn:g,startRow:f}=h,C=o.__headerState&r.COLUMN,_=Array.from({length:i},((e,t)=>{let n=C;for(let e=0;0!==n&&e<u.length;e++)n&=u[e][t+g].cell.__headerState;return n})),p=o.__headerState&r.ROW,S=Array.from({length:c},((e,t)=>{let n=p;for(let e=0;0!==n&&e<u[0].length;e++)n&=u[t+f][e].cell.__headerState;return n}));if(i>1){for(let e=1;e<i;e++)o.insertAfter(a(_[e]|S[0]).append(t.$createParagraphNode()));o.setColSpan(1)}if(c>1){let e;for(let n=1;n<c;n++){const o=f+n,r=u[o];e=(e||l).getNextSibling(),m(e)||d(125);let s=null;for(let e=0;e<g;e++){const t=r[e],n=t.cell;t.startRow===o&&(s=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===s)for(let o=i-1;o>=0;o--)y(e,a(_[o]|S[n]).append(t.$createParagraphNode()));else for(let e=i-1;e>=0;e--)s.insertAfter(a(_[e]|S[n]).append(t.$createParagraphNode()))}o.setRowSpan(1)}},exports.INSERT_TABLE_COMMAND=u,exports.TableCellHeaderStates=r,exports.TableCellNode=l,exports.TableNode=ye,exports.TableObserver=L,exports.TableRowNode=h,exports.applyTableHandlers=J,exports.getDOMCellFromTarget=G,exports.getTableElement=B,exports.getTableObserverFromTableElement=q,exports.registerTableCellUnmergeTransform=function(t){return t.registerNodeTransform(l,(t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=E(t),[o]=R(n,t,t),r=o.length,l=o[0].length;let s=n.getFirstChild();m(s)||d(175);const i=[];for(let t=0;t<r;t++){0!==t&&(s=s.getNextSibling(),m(s)||d(175));let n=null;for(let r=0;r<l;r++){const l=o[t][r],u=l.cell;if(l.startRow===t&&l.startColumn===r)n=u,i.push(u);else if(u.getColSpan()>1||u.getRowSpan()>1){c(u)||d(176);const t=a(u.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(s,t)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))},exports.registerTablePlugin=function(n){return n.hasNodes([ye])||d(255),e.mergeRegister(n.registerCommand(u,Oe,t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(({nodes:e,selection:n})=>{if(!t.$isRangeSelection(n))return!1;return null!==ue(n.anchor.getNode())&&e.some(xe)}),t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.CLICK_COMMAND,Pe,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(ye,Fe),n.registerNodeTransform(h,ve),n.registerNodeTransform(l,Ae))},exports.registerTableSelectionObserver=function(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=B(o,l),i=J(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(ye,(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}=K(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()}},exports.setScrollableTablesActive=function(e,t){t?Te.add(e):Te.delete(e)};

@@ -25,3 +25,3 @@ /**

export declare function getTableObserverFromTableElement(tableElement: HTMLTableElementWithWithTableSelectionState): TableObserver | null;
export declare function getDOMCellFromTarget(node: Node): TableDOMCell | null;
export declare function getDOMCellFromTarget(node: null | Node): TableDOMCell | null;
export declare function doesTargetContainText(node: Node): boolean;

@@ -28,0 +28,0 @@ export declare function getTable(tableNode: TableNode, dom: HTMLElement): TableDOMTable;

@@ -11,9 +11,9 @@ {

"license": "MIT",
"version": "0.26.0",
"version": "0.26.1-nightly.20250303.0",
"main": "LexicalTable.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/clipboard": "0.26.0",
"@lexical/utils": "0.26.0",
"lexical": "0.26.0"
"@lexical/clipboard": "0.26.1-nightly.20250303.0",
"@lexical/utils": "0.26.1-nightly.20250303.0",
"lexical": "0.26.1-nightly.20250303.0"
},

@@ -20,0 +20,0 @@ "repository": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc