UNPKG

lexical

Version:

Lexical is an extensible text editor framework that provides excellent reliability, accessible and performance.

9 lines (8 loc) 132 kB
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ "use strict";function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);n.search=r.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=n&&"documentMode"in document?document.documentMode:null,o=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),i=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=!(!n||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=n&&/Android/.test(navigator.userAgent),u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&a&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&o&&!u;function h(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const g=0,_=1,p=2,y=128,m=1,x=2,C=3,S=4,N=5,T=6,v=l||c||d?" ":"​",k="\n\n",E=i?" ":v,O="֑-߿יִ-﷽ﹰ-ﻼ",b="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",M=new RegExp("^[^"+b+"]*["+O+"]"),A=new RegExp("^[^"+O+"]*["+b+"]"),w={bold:1,capitalize:1024,code:16,highlight:y,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},D={directionless:1,unmergeable:2},P={center:2,end:6,justify:4,left:1,right:3,start:5},I={[x]:"center",[T]:"end",[S]:"justify",[m]:"left",[C]:"right",[N]:"start"},L={normal:0,segmented:2,token:1},F={[g]:"normal",[p]:"segmented",[_]:"token"},R="$config";function K(t,e,n,r,o,i){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(co(s)&&K(s,t,n,r,o,i),n.has(t)||i.delete(t),o.push(t)),s=s.getNextSibling()}}let B=!1,z=0;function W(t){z=t.timeStamp}function $(t,e,n){const r="BR"===t.nodeName,o=e.__lexicalLineBreak;return o&&(t===o||r&&t.previousSibling===o)||r&&void 0!==Zo(t,n)}function U(t,e,n){const r=Ji(Li(n));let o=null,i=null;null!==r&&r.anchorNode===t&&(o=r.anchorOffset,i=r.focusOffset);const s=t.nodeValue;null!==s&&di(e,s,o,i,!1)}function J(t,e,n){if(ar(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return $o(e)&&n.isAttached()}function Y(t,e,n,r){for(let o=t;o&&!os(o);o=Mi(o)){const t=Zo(o,e);if(void 0!==t){const e=Xo(t,n);if(e)return fo(e)||!ji(o)?void 0:[o,e]}else if(o===r)return[r,oi(n)]}}function j(t,e,n){B=!0;const r=performance.now()-z>100;try{oo(t,()=>{const o=kr()||function(t){return t.getEditorState().read(()=>{const t=kr();return null!==t?t.clone():null})}(t),s=new Map,l=t.getRootElement(),c=t._editorState,a=t._blockCursorElement;let u=!1,f="";for(let n=0;n<e.length;n++){const d=e[n],h=d.type,g=d.target,_=Y(g,t,c,l);if(!_)continue;const[p,y]=_;if("characterData"===h)r&&Zn(y)&&$o(g)&&J(o,g,y)&&U(g,y,t);else if("childList"===h){u=!0;const e=d.addedNodes;for(let n=0;n<e.length;n++){const r=e[n],o=Qo(r),s=r.parentNode;if(null!=s&&r!==a&&null===o&&!$(r,s,t)){if(i){const t=(ji(r)?r.innerText:null)||r.nodeValue;t&&(f+=t)}s.removeChild(r)}}const n=d.removedNodes,r=n.length;if(r>0){let e=0;for(let o=0;o<r;o++){const r=n[o];($(r,g,t)||a===r)&&(g.appendChild(r),e++)}r!==e&&s.set(p,y)}}}if(s.size>0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const d=n.takeRecords();if(d.length>0){for(let e=0;e<d.length;e++){const n=d[e],r=n.addedNodes,o=n.target;for(let e=0;e<r.length;e++){const n=r[e],i=n.parentNode;null==i||"BR"!==n.nodeName||$(n,o,t)||i.removeChild(n)}}n.takeRecords()}null!==o&&(u&&ii(o),i&&ki(t)&&o.insertRawText(f))})}finally{B=!1}}function H(t){const e=t._observer;if(null!==e){j(t,e.takeRecords(),e)}}function V(t){!function(t){0===z&&Li(t).addEventListener("textInput",W,!0)}(t),t._observer=new MutationObserver((e,n)=>{j(t,e,n)})}class G{key;parse;unparse;isEqual;defaultValue;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||nt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0)}}function q(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function X(t){const e=new Map,n=new Set;for(let r="function"==typeof t?t:t.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:t}=ss(r);if(t&&t.stateConfigs)for(const r of t.stateConfigs){let t;"stateConfig"in r?(t=r.stateConfig,r.flat&&n.add(t.key)):t=r,e.set(t.key,t)}}return{flatKeys:n,sharedConfigMap:e}}class Q{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,r=new Map,o=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=r;const{sharedConfigMap:i}=this.sharedNodeState,s=void 0!==o?o:function(t,e,n){let r=n.size;if(e)for(const o in e){const e=t.get(o);e&&n.has(e)||r++}return r}(i,n,r);this.size=s}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return et(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,r=new Map(this.knownState);return new Q(t,e,function(t,e,n){let r;if(n)for(const[o,i]of Object.entries(n)){const n=t.get(o);n?e.has(n)||e.set(n,n.parse(i)):(r=r||{},r[o]=i)}return r}(e.sharedConfigMap,r,n),r,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:r,unknownState:o}=this;r.has(t)||o&&n in o||(o&&(delete o[n],this.unknownState=et(o)),this.size++),r.set(t,e)}updateFromUnknown(t,e){const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function Z(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new Q(e,tt(e));return e.__state=n,n}function tt(t){return t.__state?t.__state.sharedNodeState:wo(Qi(),t.getType()).sharedNodeState}function et(t){if(t)for(const e in t)return t}function nt(t){return t}function rt(t,e,n){for(const[r,o]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const e=n?n.getValue(r):r.defaultValue;if(e!==o&&!r.isEqual(e,o))return!0}return!1}function ot(t,e,n){const{unknownState:r}=e,o=n?n.unknownState:void 0;if(r)for(const[e,n]of Object.entries(r)){if(t.has(e))continue;t.add(e);if(n!==(o?o[e]:void 0))return!0}return!1}function it(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function st(t,e){const n=t.__mode,r=t.__format,o=t.__style,i=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===i)&&(null===r||r===s)&&(null===o||o===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;if(t&&e&&t.size!==e.size)return!1;const n=new Set;return!(t&&rt(n,t,e)||e&&rt(n,e,t)||t&&ot(n,t,e)||e&&ot(n,e,t))}(c,a))}function lt(t,e){const n=t.mergeWithSibling(e),r=jr()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function ct(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Zn(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(st(e,r)){r=lt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&Zn(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(st(r,n)){r=lt(r,n);break}break}n.remove()}}else r.remove()}function at(t){return ut(t.anchor),ut(t.focus),t}function ut(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let r,o;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),o=!0):(r=e.getChildAtIndex(n),o=!1),Zn(r)){t.set(r.__key,o?r.getTextContentSize():0,"text",!0);break}if(!co(r))break;t.set(r.__key,o?r.getChildrenSize():0,"element",!0)}}let ft,dt,ht,gt,_t,pt,yt,mt,xt,Ct,St="",Nt=null,Tt=null,vt="",kt=!1,Et=!1;function Ot(t,e){const n=yt.get(t);if(null!==e){const n=Jt(t);n.parentNode===e&&e.removeChild(n)}if(mt.has(t)||dt._keyToDOMMap.delete(t),co(n)){const t=Bt(n,yt);bt(t,0,t.length-1,null)}void 0!==n&&Ni(Ct,ht,gt,n,"destroyed")}function bt(t,e,n,r){let o=e;for(;o<=n;++o){const e=t[o];void 0!==e&&Ot(e,r)}}function Mt(t,e){t.setProperty("text-align",e)}const At="40px";function wt(t,e){const n=ft.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||At;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`)}function Dt(t,e){const n=t.style;0===e?Mt(n,""):1===e?Mt(n,"left"):2===e?Mt(n,"center"):3===e?Mt(n,"right"):4===e?Mt(n,"justify"):5===e?Mt(n,"start"):6===e&&Mt(n,"end")}function Pt(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(go(t))return null;const n=t.getParentOrThrow();return go(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function It(e,n){const r=mt.get(e);void 0===r&&t(60);const o=r.createDOM(ft,dt);if(function(t,e,n){const r=n._keyToDOMMap;(function(t,e,n){const r=`__lexicalKey_${e._key}`;t[r]=n})(e,n,t),r.set(t,e)}(e,o,dt),Zn(r)?o.setAttribute("data-lexical-text","true"):fo(r)&&o.setAttribute("data-lexical-decorator","true"),co(r)){const t=r.__indent,e=r.__size;if(Pt(o,r),0!==t&&wt(o,t),0!==e){const t=e-1;Lt(Bt(r,mt),r,0,t,r.getDOMSlot(o))}const n=r.__format;0!==n&&Dt(o,n),r.isInline()||Rt(null,r,o),Oi(r)&&(St+=k,vt+=k)}else{const t=r.getTextContent();if(fo(r)){const t=r.decorate(dt,ft);null!==t&&Wt(e,t),o.contentEditable="false"}St+=t,vt+=t}return null!==n&&n.insertChild(o),Ni(Ct,ht,gt,r,"created"),o}function Lt(t,e,n,r,o){const i=St;St="";let s=n;for(;s<=r;++s){It(t[s],o);const e=mt.get(t[s]);null!==e&&Zn(e)&&null===Nt&&(Nt=e.getFormat(),Tt=e.getStyle())}Oi(e)&&(St+=k);o.element.__lexicalTextContent=St,St=i+St}function Ft(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return Ln(t)?"line-break":fo(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Rt(t,e,n){const r=Ft(t,yt),o=Ft(e,mt);r!==o&&e.getDOMSlot(n).setManagedLineBreak(o)}function Kt(e,n,r){var o;Nt=null,Tt=null,function(e,n,r){const o=St,i=e.__size,s=n.__size;St="";const l=r.element;if(1===i&&1===s){const t=e.__first,r=n.__first;if(t===r)zt(t,l);else{const e=Jt(t),n=It(r,null);try{l.replaceChild(n,e)}catch(o){if("object"==typeof o&&null!=o){const i=`${o.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(i)}throw o}Ot(t,null)}const o=mt.get(r);Zn(o)&&null===Nt&&(Nt=o.getFormat(),Tt=o.getStyle())}else{const o=Bt(e,yt),c=Bt(n,mt);if(o.length!==i&&t(227),c.length!==s&&t(228),0===i)0!==s&&Lt(c,n,0,s-1,r);else if(0===s){if(0!==i){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;bt(o,0,i-1,t?null:l),t&&(l.textContent="")}}else!function(t,e,n,r,o,i){const s=r-1,l=o-1;let c,a,u=i.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],r=n[d];if(t===r)u=$t(zt(r,i.element)),f++,d++;else{void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const o=a.has(t),s=c.has(r);if(o)if(s){const t=bi(dt,r);t===u?u=$t(zt(r,i.element)):(i.withBefore(u).insertChild(t),zt(r,i.element)),f++,d++}else It(r,i.withBefore(u)),d++;else u=$t(Jt(t)),Ot(t,i.element),f++}const o=mt.get(r);null!==o&&Zn(o)&&null===Nt&&(Nt=o.getFormat(),Tt=o.getStyle())}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:dt.getElementByKey(e);Lt(n,t,d,l,i.withBefore(r))}else g&&!h&&bt(e,f,s,i.element)}(n,o,c,i,s,r)}Oi(n)&&(St+=k);l.__lexicalTextContent=St,St=o+St}(e,n,n.getDOMSlot(r)),o=n,null==Nt||Nt===o.__textFormat||Et||o.setTextFormat(Nt),function(t){null==Tt||Tt===t.__textStyle||Et||t.setTextStyle(Tt)}(n)}function Bt(e,n){const r=[];let o=e.__first;for(;null!==o;){const e=n.get(o);void 0===e&&t(101),r.push(o),o=e.__next}return r}function zt(e,n){const r=yt.get(e);let o=mt.get(e);void 0!==r&&void 0!==o||t(61);const i=kt||pt.has(e)||_t.has(e),s=bi(dt,e);if(r===o&&!i){if(co(r)){const t=s.__lexicalTextContent;void 0!==t&&(St+=t,vt+=t)}else{const t=r.getTextContent();vt+=t,St+=t}return s}if(r!==o&&i&&Ni(Ct,ht,gt,o,"updated"),o.updateDOM(r,s,ft)){const r=It(e,null);return null===n&&t(62),n.replaceChild(r,s),Ot(e,null),r}if(co(r)&&co(o)){const t=o.__indent;(kt||t!==r.__indent)&&wt(s,t);const e=o.__format;if((kt||e!==r.__format)&&Dt(s,e),i&&(Kt(r,o,s),go(o)||o.isInline()||Rt(r,o,s)),Oi(o)&&(St+=k,vt+=k),(kt||o.__dir!==r.__dir)&&(Pt(s,o),go(o)&&!kt))for(const t of o.getChildren())if(co(t)){Pt(bi(dt,t.getKey()),t)}}else{const t=o.getTextContent();if(fo(o)){const t=o.decorate(dt,ft);null!==t&&Wt(e,t)}St+=t,vt+=t}if(!Et&&go(o)&&o.__cachedText!==vt){const t=o.getWritable();t.__cachedText=vt,o=t}return s}function Wt(t,e){let n=dt._pendingDecorators;const r=dt._decorators;if(null===n){if(r[t]===e)return;n=ei(dt)}n[t]=e}function $t(t){let e=t.nextSibling;return null!==e&&e===dt._blockCursorElement&&(e=e.nextSibling),e}function Ut(t,e,n,r,o,i){St="",vt="",kt=2===r,dt=n,ft=n._config,ht=n._nodes,gt=dt._listeners.mutation,_t=o,pt=i,yt=t._nodeMap,mt=e._nodeMap,Et=e._readOnly,xt=new Map(n._keyToDOMMap);const s=new Map;return Ct=s,zt("root",null),dt=void 0,ht=void 0,_t=void 0,pt=void 0,yt=void 0,mt=void 0,ft=void 0,xt=void 0,Ct=void 0,s}function Jt(e){const n=xt.get(e);return void 0===n&&t(75,e),n}function Yt(t){return{type:t}}const jt=Yt("SELECTION_CHANGE_COMMAND"),Ht=Yt("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Vt=Yt("CLICK_COMMAND"),Gt=Yt("BEFORE_INPUT_COMMAND"),qt=Yt("INPUT_COMMAND"),Xt=Yt("COMPOSITION_START_COMMAND"),Qt=Yt("COMPOSITION_END_COMMAND"),Zt=Yt("DELETE_CHARACTER_COMMAND"),te=Yt("INSERT_LINE_BREAK_COMMAND"),ee=Yt("INSERT_PARAGRAPH_COMMAND"),ne=Yt("CONTROLLED_TEXT_INSERTION_COMMAND"),re=Yt("PASTE_COMMAND"),oe=Yt("REMOVE_TEXT_COMMAND"),ie=Yt("DELETE_WORD_COMMAND"),se=Yt("DELETE_LINE_COMMAND"),le=Yt("FORMAT_TEXT_COMMAND"),ce=Yt("UNDO_COMMAND"),ae=Yt("REDO_COMMAND"),ue=Yt("KEYDOWN_COMMAND"),fe=Yt("KEY_ARROW_RIGHT_COMMAND"),de=Yt("MOVE_TO_END"),he=Yt("KEY_ARROW_LEFT_COMMAND"),ge=Yt("MOVE_TO_START"),_e=Yt("KEY_ARROW_UP_COMMAND"),pe=Yt("KEY_ARROW_DOWN_COMMAND"),ye=Yt("KEY_ENTER_COMMAND"),me=Yt("KEY_SPACE_COMMAND"),xe=Yt("KEY_BACKSPACE_COMMAND"),Ce=Yt("KEY_ESCAPE_COMMAND"),Se=Yt("KEY_DELETE_COMMAND"),Ne=Yt("KEY_TAB_COMMAND"),Te=Yt("INSERT_TAB_COMMAND"),ve=Yt("INDENT_CONTENT_COMMAND"),ke=Yt("OUTDENT_CONTENT_COMMAND"),Ee=Yt("DROP_COMMAND"),Oe=Yt("FORMAT_ELEMENT_COMMAND"),be=Yt("DRAGSTART_COMMAND"),Me=Yt("DRAGOVER_COMMAND"),Ae=Yt("DRAGEND_COMMAND"),we=Yt("COPY_COMMAND"),De=Yt("CUT_COMMAND"),Pe=Yt("SELECT_ALL_COMMAND"),Ie=Yt("CLEAR_EDITOR_COMMAND"),Le=Yt("CLEAR_HISTORY_COMMAND"),Fe=Yt("CAN_REDO_COMMAND"),Re=Yt("CAN_UNDO_COMMAND"),Ke=Yt("FOCUS_COMMAND"),Be=Yt("BLUR_COMMAND"),ze=Yt("KEY_MODIFIER_COMMAND"),We=Object.freeze({}),$e=[["keydown",function(t,e){if(Ue=t.timeStamp,Je=t.key,e.isComposing())return;Ei(e,ue,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Hi(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&oo(e,()=>{Io(n)||(qe=!0)})}],["compositionstart",function(t,e){Ei(e,Xt,t)}],["compositionend",function(t,e){i?Qe=!0:c||!l&&!d?Ei(e,Qt,t):(Ze=!0,tn=t.data)}],["input",function(t,e){t.stopPropagation(),oo(e,()=>{e.dispatchCommand(qt,t)},{event:t}),je=null}],["click",function(t,e){oo(e,()=>{const n=kr(),r=Ji(Li(e)),o=Er();if(r)if(ar(n)){const e=n.anchor,i=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!go(i)&&1===ri().getChildrenSize()&&i.getTopLevelElementOrThrow().isEmpty()&&null!==o&&n.is(o))r.removeAllRanges(),n.dirty=!0;else if(3===t.detail&&!n.isCollapsed()){if(i!==n.focus.getNode()){const t=ls(i,t=>co(t)&&!t.isInline());co(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(ji(n)||$o(n)){ii(vr(o,r,e,t))}}Ei(e,Vt,t)})}],["cut",We],["copy",We],["dragstart",We],["dragover",We],["dragend",We],["paste",We],["focus",We],["blur",We],["drop",We]];s&&$e.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||i&&ki(e))return;if("insertCompositionText"===n)return;Ei(e,Gt,t)}(t,e)]);let Ue=0,Je=null,Ye=0,je=null;const He=new WeakMap,Ve=new WeakMap;let Ge=!1,qe=!1,Xe=!1,Qe=!1,Ze=!1,tn="",en=null,nn=[0,"",0,"root",0];function rn(t,e,n,r,o){const i=t.anchor,l=t.focus,c=i.getNode(),a=jr(),u=Ji(Li(a)),f=null!==u?u.anchorNode:null,d=i.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!Zn(c)||(!o&&(!s||Ye<r+50)||c.isDirty()&&g<2||li(n))&&i.offset!==l.offset&&!c.isComposing()||Wo(c)||c.isDirty()&&g>1||(o||!s)&&null!==h&&!c.isComposing()&&f!==Jo(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||c.getFormat()!==t.format||c.getStyle()!==t.style||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,r=e.getParentOrThrow(),o=zo(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||o||function(t){const e=t.getPreviousSibling();return(Zn(e)||co(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||o)}(t,c)}function on(t,e){return $o(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function sn(e,n,r){const{anchorNode:o,anchorOffset:i,focusNode:s,focusOffset:l}=e;Ge&&(Ge=!1,on(o,i)&&on(s,l)&&!en)||oo(n,()=>{if(!r)return void ii(null);if(!Fo(n,o,s))return;let c=kr();if(en&&ar(c)&&c.isCollapsed()){const t=c.anchor,e=en.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=en.clone(),ii(c))}if(en=null,ar(c)){const r=c.anchor,o=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const i=Li(n).event,s=i?i.timeStamp:performance.now(),[l,a,u,f,d]=nn,h=ri(),g=!1===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)ln(c,l,a);else if("text"===r.type)Zn(o)||t(141),cn(c,o);else if("element"===r.type&&!g){co(o)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();ln(t,n,r)}(c,e):ln(c,0,"")}}else{const t=r.key,e=c.focus.key,n=c.getNodes(),o=n.length,s=c.isBackward(),a=s?l:i,u=s?i:l,f=s?e:t,d=s?t:e;let h=2047,g=!1;for(let t=0;t<o;t++){const e=n[t],r=e.getTextContentSize();if(Zn(e)&&0!==r&&!(0===t&&e.__key===f&&a===r||t===o-1&&e.__key===d&&0===u)&&(g=!0,h&=e.getFormat(),0===h))break}c.format=g?h:0}}Ei(n,jt,void 0)})}function ln(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=!0)}function cn(t,e){ln(t,e.getFormat(),e.getStyle())}function an(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function un(e){const n=e.inputType,r=an(e),o=jr(),i=kr();if("deleteContentBackward"===n){if(null===i){const t=Er();if(!ar(t))return!0;ii(t.clone())}if(ar(i)){const n=i.anchor.key===i.focus.key;if(s=e.timeStamp,"MediaLast"===Je&&s<Ue+30&&o.isComposing()&&n){if(Go(null),Ue=0,setTimeout(()=>{oo(o,()=>{Go(null)})},30),ar(i)){const e=i.anchor.getNode();e.markDirty(),Zn(e)||t(142),cn(i,e)}}else{Go(null),e.preventDefault();const t=i.anchor.getNode(),r=t.getTextContent(),s=t.canInsertTextAfter(),l=0===i.anchor.offset&&i.focus.offset===r.length;let c=f&&n&&!l&&s;if(c&&i.isCollapsed()&&(c=!fo(vi(i.anchor,!0))),!c){Ei(o,Zt,!0);const t=kr();f&&ar(t)&&t.isCollapsed()&&(en=t,setTimeout(()=>en=null))}}return!0}}var s;if(!ar(i))return!0;const l=e.data;null!==je&&fi(!1,o,je),i.dirty&&null===je||!i.isCollapsed()||go(i.anchor.getNode())||null===r||i.applyDOMRange(r),je=null;const a=i.anchor,u=i.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===l)e.preventDefault(),Ei(o,te,!1);else if(l===k)e.preventDefault(),Ei(o,ee,void 0);else if(null==l&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=l&&rn(i,r,l,e.timeStamp,!0)?(e.preventDefault(),Ei(o,ne,l)):je=l;return Ye=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Ei(o,ne,e);break;case"insertFromComposition":Go(null),Ei(o,ne,e);break;case"insertLineBreak":Go(null),Ei(o,te,!1);break;case"insertParagraph":Go(null),Xe&&!c?(Xe=!1,Ei(o,te,!1)):Ei(o,ee,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Ei(o,re,e);break;case"deleteByComposition":(function(t,e){return t!==e||co(t)||co(e)||!zo(t)||!zo(e)})(d,h)&&Ei(o,oe,e);break;case"deleteByDrag":case"deleteByCut":Ei(o,oe,e);break;case"deleteContent":Ei(o,Zt,!1);break;case"deleteWordBackward":Ei(o,ie,!0);break;case"deleteWordForward":Ei(o,ie,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Ei(o,se,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Ei(o,se,!1);break;case"formatStrikeThrough":Ei(o,le,"strikethrough");break;case"formatBold":Ei(o,le,"bold");break;case"formatItalic":Ei(o,le,"italic");break;case"formatUnderline":Ei(o,le,"underline");break;case"historyUndo":Ei(o,ce,void 0);break;case"historyRedo":Ei(o,ae,void 0)}return!0}function fn(t){if(ji(t.target)&&Io(t.target))return!0;const e=jr(),n=kr(),r=t.data,o=an(t);if(null!=r&&ar(n)&&rn(n,o,r,t.timeStamp,!1)){Qe&&(gn(e,r),Qe=!1);const o=n.anchor.getNode(),a=Ji(Li(e));if(null===a)return!0;const u=n.isBackward(),f=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;s&&!n.isCollapsed()&&Zn(o)&&null!==a.anchorNode&&o.getTextContent().slice(0,f)+r+o.getTextContent().slice(f+h)===ui(a.anchorNode)||Ei(e,ne,r);const g=r.length;i&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),l||c||d||!e.isComposing()||(Ue=0,Go(null))}else{fi(!1,e,null!==r?r:void 0),Qe&&(gn(e,r||void 0),Qe=!1)}return function(){Ur();const t=jr();H(t)}(),!0}function dn(t){const e=jr(),n=kr();if(ar(n)&&!e.isComposing()){const r=n.anchor,o=n.anchor.getNode();Go(r.key),(t.timeStamp<Ue+30||"element"===r.type||!n.isCollapsed()||o.getFormat()!==n.format||Zn(o)&&o.getStyle()!==n.style)&&Ei(e,ne,E)}return!0}function hn(t){return gn(jr(),t.data),!0}function gn(t,e){const n=t._compositionKey;if(Go(null),null!==n&&null!=e){if(""===e){const e=Xo(n),r=Jo(t.getElementByKey(n));return void(null!==r&&null!==r.nodeValue&&Zn(e)&&di(e,r.nodeValue,null,null,!0))}if("\n"===e[e.length-1]){const e=kr();if(ar(e)){const n=e.focus;return e.anchor.set(n.key,n.offset,n.type),void Ei(t,ye,null)}}}fi(!0,t,e)}function _n(t){const e=jr();if(null==t.key)return!0;if(Ze&&xi(t))return oo(e,()=>{gn(e,tn)}),Ze=!1,tn="",!0;if(function(t){return pi(t,"ArrowRight",{shiftKey:"any"})}(t))Ei(e,fe,t);else if(function(t){return pi(t,"ArrowRight",yi)}(t))Ei(e,de,t);else if(function(t){return pi(t,"ArrowLeft",{shiftKey:"any"})}(t))Ei(e,he,t);else if(function(t){return pi(t,"ArrowLeft",yi)}(t))Ei(e,ge,t);else if(function(t){return pi(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Ei(e,_e,t);else if(function(t){return pi(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Ei(e,pe,t);else if(function(t){return pi(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))Xe=!0,Ei(e,ye,t);else if(function(t){return" "===t.key}(t))Ei(e,me,t);else if(function(t){return o&&pi(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),Xe=!0,Ei(e,te,!0);else if(function(t){return pi(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))Xe=!1,Ei(e,ye,t);else if(function(t){return pi(t,"Backspace",{shiftKey:"any"})||o&&pi(t,"h",{ctrlKey:!0})}(t))xi(t)?Ei(e,xe,t):(t.preventDefault(),Ei(e,Zt,!0));else if(function(t){return"Escape"===t.key}(t))Ei(e,Ce,t);else if(function(t){return pi(t,"Delete",{})||o&&pi(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Ei(e,Zt,!1)):Ei(e,Se,t);else if(function(t){return pi(t,"Backspace",mi)}(t))t.preventDefault(),Ei(e,ie,!0);else if(function(t){return pi(t,"Delete",mi)}(t))t.preventDefault(),Ei(e,ie,!1);else if(function(t){return o&&pi(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Ei(e,se,!0);else if(function(t){return o&&(pi(t,"Delete",{metaKey:!0})||pi(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Ei(e,se,!1);else if(function(t){return pi(t,"b",yi)}(t))t.preventDefault(),Ei(e,le,"bold");else if(function(t){return pi(t,"u",yi)}(t))t.preventDefault(),Ei(e,le,"underline");else if(function(t){return pi(t,"i",yi)}(t))t.preventDefault(),Ei(e,le,"italic");else if(function(t){return pi(t,"Tab",{shiftKey:"any"})}(t))Ei(e,Ne,t);else if(function(t){return pi(t,"z",yi)}(t))t.preventDefault(),Ei(e,ce,void 0);else if(function(t){if(o)return pi(t,"z",{metaKey:!0,shiftKey:!0});return pi(t,"y",{ctrlKey:!0})||pi(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Ei(e,ae,void 0);else{const n=e._editorState._selection;null===n||ar(n)?Ci(t)&&(t.preventDefault(),Ei(e,Pe,t)):!function(t){return pi(t,"c",yi)}(t)?!function(t){return pi(t,"x",yi)}(t)?Ci(t)&&(t.preventDefault(),Ei(e,Pe,t)):(t.preventDefault(),Ei(e,De,t)):(t.preventDefault(),Ei(e,we,t))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(ze,t),!0}function pn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const yn=new Map;function mn(t){const e=Yi(t.target);if(null===e)return;const n=Ko(e.anchorNode);if(null===n)return;qe&&(qe=!1,oo(n,()=>{const r=Er(),o=e.anchorNode;if(ji(o)||$o(o)){ii(vr(r,e,n,t))}}));const r=ci(n),o=r[r.length-1],i=o._key,s=yn.get(i),l=s||o;l!==n&&sn(e,l,!1),sn(e,n,!0),n!==o?yn.set(i,n):s&&yn.delete(i)}function xn(t){t._lexicalHandled=!0}function Cn(t){return!0===t._lexicalHandled}const Sn=()=>{};function Nn(e){const n=He.get(e);if(void 0===n)return void Sn();const r=Ve.get(n);if(void 0===r)return void Sn();const o=r-1;o>=0||t(164),He.delete(e),Ve.set(n,o),0===o&&n.removeEventListener("selectionchange",mn);const i=Bo(e);Ro(i)?(!function(t){if(null!==t._parentEditor){const e=ci(t),n=e[e.length-1]._key;yn.get(n)===t&&yn.delete(n)}else yn.delete(t._key)}(i),e.__lexicalEditor=null):i&&t(198);const s=pn(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[]}function Tn(t,e,n){Ur();const r=t.__key,o=t.getParent();if(null===o)return;const i=function(t){const e=kr();if(!ar(e)||!co(t))return e;const{anchor:n,focus:r}=e,o=n.getNode(),i=r.getNode();Pi(o,t)&&n.set(t.__key,0,"element");Pi(i,t)&&r.set(t.__key,0,"element");return e}(t);let s=!1;if(ar(i)&&e){const e=i.anchor,n=i.focus;e.key===r&&(Mr(e,t,o,t.getPreviousSibling(),t.getNextSibling()),s=!0),n.key===r&&(Mr(n,t,o,t.getPreviousSibling(),t.getNextSibling()),s=!0)}else fr(i)&&e&&t.isSelected()&&t.selectPrevious();if(ar(i)&&e&&!s){const e=t.getIndexWithinParent();Ho(t),Or(i,o,e,-1)}else Ho(t);n||Ri(o)||o.canBeEmpty()||!o.isEmpty()||Tn(o,e),e&&i&&go(o)&&o.isEmpty()&&o.selectEnd()}const vn=Symbol.for("ephemeral");function kn(t){return t[vn]||!1}class En{__type;__key;__parent;__prev;__next;__state;static getType(){const{ownNodeType:e}=ss(this);return void 0===e&&t(64,this.name),e}static clone(e){t(65,this.name)}$config(){return{}}config(t,e){const n=e.extends||Object.getPrototypeOf(this.constructor);return Object.assign(e,{extends:n,type:t}),{[t]:e}}afterCloneFrom(t){this.__key===t.__key?(this.__parent=t.__parent,this.__next=t.__next,this.__prev=t.__prev,this.__state=t.__state):t.__state&&(this.__state=t.__state.getWritable(this))}static importDOM;constructor(t){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",{configurable:!0,enumerable:!1,value:void 0,writable:!0}),jo(this,t)}getType(){return this.__type}isInline(){t(137,this.constructor.name)}isAttached(){let t=this.__key;for(;null!==t;){if("root"===t)return!0;const e=Xo(t);if(null===e)break;t=e.__parent}return!1}isSelected(t){const e=t||kr();if(null==e)return!1;const n=e.getNodes().some(t=>t.__key===this.__key);if(Zn(this))return n;if(ar(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(fo(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:Xo(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(Ri(n))return co(e)||e===this&&fo(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:Xo(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:Xo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=co(this)?this:this.getParent(),n=co(t)?t:t.getParent(),r=e&&n?Bs(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Bs(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===Fs(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=Bs(this,t);return null!==e&&"ancestor"===e.type}getNodesBetween(e){const n=this.isBefore(e),r=[],o=new Set;let i=this;for(;null!==i;){const s=i.__key;if(o.has(s)||(o.add(s),r.push(i)),i===e)break;const l=co(i)?n?i.getFirstChild():i.getLastChild():null;if(null!==l){i=l;continue}const c=n?i.getNextSibling():i.getPreviousSibling();if(null!==c){i=c;continue}const a=i.getParentOrThrow();if(o.has(a.__key)||r.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||o.has(f.__key)||r.push(f)}while(null===u);i=u}return n||r.reverse(),r}isDirty(){const t=jr()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(kn(this))return this;const e=Xo(this.__key);return null===e&&t(113),e}getWritable(){if(kn(this))return this;Ur();const t=Yr(),e=jr(),n=t._nodeMap,r=this.__key,o=this.getLatest(),i=e._cloneNotNeeded,s=kr();if(null!==s&&s.setCachedNodes(null),i.has(r))return Vo(o),o;const l=ns(o);return i.add(r),Vo(l),n.set(r,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,r){t(71)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),r=e.$;let o=r;for(const t of tt(n).flatKeys)t in e&&(void 0!==o&&o!==r||(o={...r}),o[t]=e[t]);return(n.__state||o)&&Z(t).updateFromJSON(o),n}(this,t)}static transform(){return null}remove(t){Tn(this,!0,t)}replace(e,n){Ur();let r=kr();null!==r&&(r=r.clone()),zi(this,e);const o=this.getLatest(),i=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Ho(l);const u=o.getPreviousSibling(),f=o.getNextSibling(),d=o.__prev,h=o.__next,g=o.__parent;if(Tn(o,!1,!0),null===u)c.__first=s;else{u.getWritable().__next=s}if(l.__prev=d,null===f)c.__last=s;else{f.getWritable().__prev=s}if(l.__next=h,l.__parent=g,c.__size=a,n&&(co(this)&&co(l)||t(139),this.getChildren().forEach(t=>{l.append(t)})),ar(r)){ii(r);const t=r.anchor,e=r.focus;t.key===i&&lr(t,l),e.key===i&&lr(e,l)}return qo()===i&&Go(s),l}insertAfter(t,e=!0){Ur(),zi(this,t);const n=this.getWritable(),r=t.getWritable(),o=r.getParent(),i=kr();let s=!1,l=!1;if(null!==o){const e=t.getIndexWithinParent();if(Ho(r),ar(i)){const t=o.__key,n=i.anchor,r=i.focus;s="element"===n.type&&n.key===t&&n.offset===e+1,l="element"===r.type&&r.key===t&&r.offset===e+1}}const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=r.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&ar(i)){const t=this.getIndexWithinParent();Or(i,a,t+1);const e=a.__key;s&&i.anchor.set(e,t+2,"element"),l&&i.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){Ur(),zi(this,t);const n=this.getWritable(),r=t.getWritable(),o=r.__key;Ho(r);const i=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===i)s.__first=o;else{i.getWritable().__next=o}s.__size++,n.__prev=o,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const a=kr();if(e&&ar(a)){Or(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return No()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){Ur();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(co(n))return n.select();if(!Zn(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){Ur();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(co(n))return n.select(0,0);if(!Zn(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}const On="history-merge",bn="collaboration",Mn="skip-scroll-into-view",An="skip-dom-selection",wn="skip-selection-focus";class Dn extends En{static getType(){return"linebreak"}static clone(t){return new Dn(t.__key)}constructor(t){super(t)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:t=>function(t){const e=t.parentElement;if(null!==e&&qi(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Fn(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&Fn(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&qi(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Fn(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&Fn(r))return!0}return!1}(t)?null:{conversion:Pn,priority:0}}}static importJSON(t){return In().updateFromJSON(t)}}function Pn(t){return{node:In()}}function In(){return Bi(new Dn)}function Ln(t){return t instanceof Dn}function Fn(t){return $o(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function Rn(t,e){return 16&e?"code":e&y?"mark":32&e?"sub":64&e?"sup":null}function Kn(t,e){return 1&e?"strong":2&e?"em":"span"}function Bn(t,e,n,r,o){const i=r.classList;let s=Si(o,"base");void 0!==s&&i.add(...s),s=Si(o,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||i.add(...s)):c&&i.remove(...s));for(const t in w){const r=w[t];if(s=Si(o,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&i.remove(...s);continue}(0===(e&r)||c&&"underline"===t||"strikethrough"===t)&&i.add(...s)}else e&r&&i.remove(...s)}}function zn(t,e,n){const r=e.firstChild,o=n.isComposing(),s=t+(o?v:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(o||i){const[e,n,o]=function(t,e){const n=t.length,r=e.length;let o=0,i=0;for(;o<n&&o<r&&t[o]===e[o];)o++;for(;i+o<n&&i+o<r&&t[n-i-1]===e[r-i-1];)i++;return[o,n-o-i,e.slice(o,r-i)]}(t,s);0!==n&&r.deleteData(e,n),r.insertData(e,o)}else r.nodeValue=s}}function Wn(t,e,n,r,o,i){zn(o,t,e);const s=i.theme.text;void 0!==s&&Bn(0,0,r,t,s)}function $n(t,e){const n=document.createElement(e);return n.appendChild(t),n}class Un extends En{__text;__format;__style;__mode;__detail;static getType(){return"text"}static clone(t){return new Un(t.__text,t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text,this.__format=t.__format,this.__style=t.__style,this.__mode=t.__mode,this.__detail=t.__detail}constructor(t="",e){super(e),this.__text=t,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const t=this.getLatest();return F[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===qo()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(t){const e=w[t];return 0!==(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return Yo(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,r=Rn(0,n),o=Kn(0,n),i=null===r?o:r,s=document.createElement(i);let l=s;this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==r&&(l=document.createElement(o),s.appendChild(l));Wn(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&(s.style.cssText=c),s}updateDOM(e,n,r){const o=this.__text,i=e.__format,s=this.__format,l=Rn(0,i),c=Rn(0,s),a=Kn(0,i),u=Kn(0,s);if((null===l?a:l)!==(null===c?u:c))return!0;if(l===c&&a!==u){const e=n.firstChild;null==e&&t(48);const i=document.createElement(u);return Wn(i,this,0,s,o,r),n.replaceChild(i,e),!1}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),zn(o,f,this);const d=r.theme.text;void 0!==d&&i!==s&&Bn(0,i,s,f,d);const h=e.__style,g=this.__style;return h!==g&&(n.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:Vn,priority:0}),b:()=>({conversion:Yn,priority:0}),code:()=>({conversion:Xn,priority:0}),em:()=>({conversion:Xn,priority:0}),i:()=>({conversion:Xn,priority:0}),mark:()=>({conversion:Xn,priority:0}),s:()=>({conversion:Xn,priority:0}),span:()=>({conversion:Jn,priority:0}),strong:()=>({conversion:Xn,priority:0}),sub:()=>({conversion:Xn,priority:0}),sup:()=>({conversion:Xn,priority:0}),u:()=>({conversion:Xn,priority:0})}}static importJSON(t){return Qn().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return ji(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=$n(n,"b")),this.hasFormat("italic")&&(n=$n(n,"i")),this.hasFormat("strikethrough")&&(n=$n(n,"s")),this.hasFormat("underline")&&(n=$n(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?w[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?D[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Yo(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=L[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){Ur();let n=t,r=e;const o=kr(),i=this.getTextContent(),s=this.__key;if("string"==typeof i){const t=i.length;void 0===n&&(n=t),void 0===r&&(r=t)}else n=0,r=0;if(!ar(o))return Sr(s,n,s,r,"text","text");{const t=qo();t!==o.anchor.key&&t!==o.focus.key||Go(s),o.setTextNodeRange(this,n,this,r)}return o}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,r){const o=this.getWritable(),i=o.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=kr();if(r&&ar(c)){const e=t+s;c.setTextNodeRange(o,e,o,e)}const a=i.slice(0,l)+n+i.slice(l+e);return o.__text=a,o}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){Ur();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,o=qo(),i=n.length;t.sort((t,e)=>t-e),t.push(i);const s=[],l=t.length;for(let e=0,r=0;e<i&&r<=l;r++){const o=t[r];o>e&&(s.push(n.slice(e,o)),e=o)}const c=s.length;if(1===c)return[e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,y=null;const m=kr();if(ar(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===r&&(p=t),"text"===e.type&&e.key===r&&(y=e)}e.isSegmented()?(f=Qn(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=it(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const n=Qn(s[t]);n.__format=d,n.__style=h,n.__detail=g,n.__state=it(e,n);const i=n.__key;o===r&&Go(i),x.push(n)}const C=p?p.offset:null,S=y?y.offset:null;let N=0;for(const t of x){if(!p&&!y)break;const e=N+t.getTextContentSize();if(null!==p&&null!==C&&C<=e&&C>=N&&(p.set(t.getKey(),C-N,"text"),C<e&&(p=null)),null!==y&&null!==S&&S<=e&&S>=N){y.set(t.getKey(),S-N,"text");break}N=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&Vo(e);null!==n&&Vo(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),ar(m)&&Or(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const r=this.__key,o=e.__key,i=this.__text,s=i.length;qo()===o&&Go(r);const l=kr();if(ar(l)){const t=l.anchor,i=l.focus;null!==t&&t.key===o&&Ar(t,n,r,e,s),null!==i&&i.key===o&&Ar(i,n,r,e,s)}const c=e.__text,a=n?c+i:i+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function Jn(t){return{forChild:tr(t.style),node:null}}function Yn(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:tr(e.style,n?void 0:"bold"),node:null}}const jn=new WeakMap;function Hn(t){if(!ji(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Vn(e){const n=e;null===e.parentElement&&t(129);let r=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=jn.get(n))&&!Hn(n);)r.push(n),n=n.parentNode;const o=void 0===e?n:e;for(let t=0;t<r.length;t++)jn.set(r[t],o);return o}(n)){const t=r.split(/(\r?\n|\t)/),e=[],n=t.length;for(let r=0;r<n;r++){const n=t[r];"\n"===n||"\r\n"===n?e.push(In()):"\t"===n?e.push(nr()):""!==n&&e.push(Qn(n))}return{node:e}}if(r=r.replace(/\r/g,"").replace(/[ \t\n]+/g," "),""===r)return{node:null};if(" "===r[0]){let t=n,e=!0;for(;null!==t&&null!==(t=Gn(t,!1));){const n=t.textContent||"";if(n.length>0){/[ \t\n]$/.test(n)&&(r=r.slice(1)),e=!1;break}}e&&(r=r.slice(1))}if(" "===r[r.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=Gn(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(r=r.slice(0,r.length-1))}return""===r?{node:null}:{node:Qn(r)}}function Gn(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,ji(n)){const t=n.style.display;if(""===t&&!Gi(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if($o(n))return n;if("BR"===n.nodeName)return null}}const qn={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Xn(t){const e=qn[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:tr(t.style,e),node:null}}function Qn(t=""){return Bi(new Un(t))}function Zn(t){return t instanceof Un}function tr(t,e){const n=t.fontWeight,r=t.textDecoration.split(" "),o="700"===n||"bold"===n,i=r.includes("line-through"),s="italic"===t.fontStyle,l=r.includes("underline"),c=t.verticalAlign;return t=>Zn(t)?(o&&!t.hasFormat("bold")&&t.toggleFormat("bold"),i&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class er extends Un{static getType(){return"tab"}static clone(t){return new er(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=Si(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return nr().updateFromJSON(t)}setTextContent(t){return"\t"!==t&&""!==t&&e(126),super.setTextContent("\t")}spliceText(e,n,r,o){return""===r&&0===n||"\t"===r&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function nr(){return Bi(new er)}function rr(t){return t instanceof er}class or{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offset<t.offset;return Ls(Gs(zs(this,"next")),Gs(zs(t,"next")))<0}getNode(){const e=Xo(this.key);return null===e&&t(20),e}set(t,e,n,r){const o=this._selection,i=this.key;r&&this.key===t&&this.offset===e&&this.type===n||(this.key=t,this.offset=e,this.type=n,$r()||(qo()===i&&Go(t),null!==o&&(o.setCachedNodes(null),o.dirty=!0)))}}function ir(t,e,n){return new or(t,e,n)}function sr(t,e){let n=e.__key,r=t.offset,o="element";if(Zn(e)){o="text";const t=e.getTextContentSize();r>t&&(r=t)}else if(!co(e)){const t=e.getNextSibling();if(Zn(t))n=t.__key,r=0,o="text";else{const t=e.getParent();t&&(n=t.__key,r=e.getIndexWithinParent()+1)}}t.set(n,r,o)}function lr(t,e){if(co(e)){const n=e.getLastDescendant();co(n)||Zn(n)?sr(t,n):sr(t,e)}else sr(t,e)}class cr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!fr(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new cr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),n=e.length,r=e[n-1];let o;if(Zn(r))o=r.select();else{const t=r.getIndexWithinParent()+1;o=r.getParentOrThrow().select(t,t)}o.insertNodes(t);for(let t=0;t<n;t++)e[t].remove()}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=this._nodes,n=[];for(const t of e){const e=Xo(t);null!==e&&n.push(e)}return $r()||(this._cachedNodes=n),n}getTextContent(){const t=this.getNodes();let e="";for(let n=0;n<t.length;n++)e+=t[n].getTextContent();return e}deleteNodes(){const t=this.getNodes();if((kr()||Er())===this&&t[0]){const e=Ns(t[0],"next");$s(Ps(e,e))}for(const e of t)e.remove()}}function ar(t){return t instanceof ur}class ur{format;style;anchor;focus;_cachedNodes;dirty;constructor(t,e,n,r){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!ar(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,r]=t.getTextSlices();n&&e.push(n.caret.origin);const o=new Set,i=new Set;for(const n of t)if(ms(n)){const{origin:t}=n;0===e.length?o.add(t):(i.add(t),e.push(t))}else{const{origin:t}=n;co(t)&&i.has(t)||e.push(t)}r&&e.push(r.caret.origin);if(ys(t.focus)&&co(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=Es(t.focus.origin,"previous");ms(n)&&o.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=bs(n))o.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!co(t)||i.has(t)||t.isEmpty()||o.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=Gs(t.anchor),r=Gs(t.anchor.getFlipped()),o=t=>ps(t)?t.origin:t.getNodeAtCaret(),i=o(n)||o(r)||(t.anchor.g