sykpcomposer 0.0.45 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +7 -10
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1426,5 +1426,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1426
1426
|
animation: ${this.isEditingInProgress?tr.tooltipAnimations.hideAtOnce:tr.tooltipAnimations.hideWithDelay};
|
|
1427
1427
|
left: ${n?"0px":"100%"};
|
|
1428
1428
|
z-index: 10;
|
|
1429
|
-
`,A.append(H),_=H}!R&&x.width<1&&r.length>1&&(A.style.width="3px")}b.forEach(w=>{this.hoverList.push([w,_,e])})});this.remoteSelections=[],this.isEditingInProgress=!1,this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelectionDOMsMap={},this.activeEditorsKeys={},this.keyboardBindedListener=this._keyboardEventsListener.bind(this),this.mouseBindedListener=this._mouseEventsListener.bind(this),this.resizeBindedListener=this._resizeEventListener.bind(this),this.hideInUI=!1}_mouseEventsListener(d){let g=!1,t=d.target,f=!1,r=3;for(;r&&t;){if(t.__codox_track){g=!0;break}if(t.__lexicalEditor){g=!0,f=!0;break}t=t.parentNode,r--}if(!g)return;let n=null;for(let i in this.activeEditorsKeys){if(t[`__lexicalKey_${i}`]){n=i;break}t.__lexicalEditor&&(n=t.__lexicalEditor._key)}if(!n)return;let e=f?"root":t[`__lexicalKey_${n}`];if(!e||!this.trackedNodesKeys.has(`${e}__${n}`))return;let s=new Set;for(let i=0;i<this.hoverList.length;i++){let l=this.hoverList[i],[o,a,c]=l;if(s.has(c))continue;let u=tr.isMousePositionWithinElementCords(d,o);d.type===vr.mouseover&&u&&(a.style.animation=this.isEditingInProgress?tr.tooltipAnimations.hideAtOnce:tr.tooltipAnimations.showAtOnce,s.add(c)),d.type===vr.mouseout&&(a.style.animation=tr.tooltipAnimations.hideWithDelay,s.add(c)),d.type===vr.mousemove&&u&&(a.style.animation=this.isEditingInProgress?tr.tooltipAnimations.hideAtOnce:tr.tooltipAnimations.showAtOnce,s.add(c))}}_keyboardEventsListener(d){d.type===vr.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),d.type===vr.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(d){xe.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(vr.keypress,this.keyboardBindedListener),window.addEventListener(vr.keyup,this.keyboardBindedListener),window.addEventListener(vr.resize,this.resizeBindedListener),window.addEventListener(vr.scroll,this.resizeBindedListener);for(const d of Km)window.addEventListener(d,this.mouseBindedListener)}unmount(){window.removeEventListener(vr.keypress,this.keyboardBindedListener),window.removeEventListener(vr.keyup,this.keyboardBindedListener),window.removeEventListener(vr.resize,this.resizeBindedListener),window.removeEventListener(vr.scroll,this.resizeBindedListener);for(const d of Km)window.removeEventListener(d,this.mouseBindedListener);this.gcPrevPaintedRemoteSelections()}shouldUpdateRemoteSelections(){return!0}gcPrevPaintedRemoteSelections(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];for(let g in this.remoteSelectionDOMsMap)this.remoteSelectionDOMsMap[g].remove();this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelections=d||[],this.remoteSelectionDOMsMap={},this.activeEditorsKeys={}}paintRemoteSelections(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];this.gcPrevPaintedRemoteSelections(d);let g=xe.getMainEditorState();g.read&&g.read(()=>{for(let t of this.remoteSelections)if(Ff.validateJSONSelection(t,Mf.remote))if($e.isNestedSelectionJSON(t)){let{nestedSelectionJSON:f,nestedEditor:r}=$e.getNestedSelectionJSONFromMainSelectionJSON(t);if(!r)continue;r.getEditorState().read(()=>{let n=$e.JSONToLexical(f);if(n)try{this.paintSingleRemoteSelection({editor:r,selectionJSON:t,lexicalSelection:n,selectedNodes:n.getNodes(),isBackward:n.isBackward()})}catch(e){le.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:e,nestedSelectionJSON:f,fullSelection:t,lexicalSelection:n})}else le.error("DEBUGGER: [paintRemoteSelections] nested selection from json to lexical is null: ",{selection:t,nestedSelectionJSON:f,lexicalSelection:n})})}else{let f=$e.JSONToLexical(t);if(!f){le.error("DEBUGGER: [paintRemoteSelections] selection from json to lexical is null: ",{selection:t,lexicalSelection:f});continue}try{this.paintSingleRemoteSelection({editor:xe.getMainEditor(),selectionJSON:t,lexicalSelection:f,selectedNodes:f.getNodes(),isBackward:f.isBackward()})}catch(r){le.warn("[PAINT REMOTE SELECTION] failed - ",{error:r,fullSelection:t,lexicalSelection:f})}}})}updateRemoteSelections(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";this.shouldUpdateRemoteSelections(d)&&(le.log("[updateRemoteSelections] "+g,{newRemoteSelections:d}),Promise.resolve().then(()=>{this.paintRemoteSelections(d),this.hideInUI&&this.hideRemoteSelectionsFromUI()}))}clear(){this.gcPrevPaintedRemoteSelections()}getCurrentRemoteSelections(){return this.remoteSelections}hideRemoteSelectionsFromUI(){this.hideInUI||(this.hideInUI=!0);const d=document.querySelectorAll(".codox_remote_selection");for(let g of d)g.classList.add("hidden_codox_remote_selection")}showHiddenRemoteSelectionsInUI(){this.hideInUI=!1;const d=document.querySelectorAll(".hidden_codox_remote_selection");for(let g of d)g.classList.remove("hidden_codox_remote_selection")}}const go=new Nx;function Px(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(y=>y===_a.editorState)}function bu(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,g=xe.getMainEditorNodesClassesMap();const{klass:t}=g.get(y.type)||{};if(!t)return;const f=t.importJSON(y);if(y.children&&y.children.length)for(const r of y.children)bu(r,f);return d&&d.getChildrenSize&&d.splice(d.getChildrenSize(),0,[f]),f}function vu(y){if(y.getChildren)for(let d of y.getChildren())vu(d);y.remove()}function f0(y){y.__parent=null,y.__next=null,y.__prev=null}function p0(y,d){return!!xe.isLexicalEditorInstance(y)&&!(typeof d!="object"||!d.editorState||(y.update(()=>{try{let g=(0,ye.$getSelection)();const t=y.parseEditorState(d.editorState);if(t.isEmpty())return(0,ye.$getRoot)().clear(),!0;(0,ye.$setSelection)(g),y.setEditorState(t)}catch(g){le.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",g)}}),0))}function Ix(y,d){let g=d;for(const t of y)g=g[t];return g}function wa(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,g=arguments.length>2&&arguments[2]!==void 0&&arguments[2],t=null,f=Ix(y,g?d:xe.getMainEditorState().toJSON());return f&&(t=Sa(f)?(0,ye.$getRoot)():Tn.get(f.codoxId)),t||le.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:f,lexicalNode:t,pathArray:y,currentStateJSON:xe.getMainEditorState().toJSON(),newStateJSON:d,codoxNodes:Tn.nodesToArray(),searchInNewState:g}),t||(g?t:wa(y,d,!0))}function h0(y){le.log("[applyFullLexicalStateReplace] clear current state and apply new");const d=(0,ye.$getRoot)();d.clear();let g=xe.getMainEditorNodesClassesMap();function t(f){const r=g.get(f.type).klass.importJSON(f);if(f.children)for(const n of f.children)r.append(t(n));return r}for(const f of y.root.children)d.append(t(f))}function Rx(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(d.length){le.log("[applyDeltasToLexicalState] Original Deltas: ",{newStateJSON:y,deltas:JSON.parse(JSON.stringify(d))});for(const g of d){let{p:t}=g;const f=t[t.length-1],r=f==="children",n=typeof f=="number",e=!n&&!r,s=Px(t),i=s!==-1,l=g.hasOwnProperty("lm")&&typeof g.lm=="number";if(t.length)if(i){let o=s-1,a=wa(t.slice(0,o),y);if(a){let c=t.slice(0,s),u=y;for(const p of c)u=u[p];let h=Dl(t[o]);p0(a.getWritable()[h],u)}}else{if(r){let o=g.oi;if(!o){le.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:g});continue}if(o.some(c=>!(!c.hasOwnProperty("text")||typeof c.text=="string"))){le.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:g});continue}t.length=t.length-1;let a=wa(t,y);if(!a)continue;if(o.some(c=>!!c.codoxDId)){try{a=a.getWritable()}catch(p){le.debug("[applyDeltasToLexicalState][shouldUpdateLeaves] getWritable error: ",{err:p,delta:g,fullStateJSON:y});continue}let c={};for(let p of a.getChildren())p.codoxDId?c[p.codoxDId]=p:vu(p);let u=[],h=["codoxDId","codoxId","__key","__parent","__prev","__next"];for(let p=0;p<o.length;p++){let m=o[p],b=p===0,_=p===o.length-1,v=null,w=p>=0?u[p-1]:null;if(m.codoxDId){let x=c[m.codoxDId];if(x){x=x.getWritable();let S=bu(m);if(le.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:x,tmpDecorator:S}),!S){le.debug("[DELTA_DECORATOR_UPDATE] UPADATE SKIPPED: ",{exisingDecorator:x,tmpDecorator:S});continue}for(let E in S)if(S.hasOwnProperty(E)&&!h.includes(E))if(xe.isLexicalEditorInstance(S[E])){let k={editorState:S[E].getEditorState().toJSON()};p0(x[E],k)}else{let k=Rf(E),D=m[k];if(D===x[E]||!m.hasOwnProperty(k))continue;let N=D!==void 0&&S[E]!==D?D:S[E];k!=="height"&&k!=="width"||S[E]==="inherit"&&D===0&&(N=S[E]),x[E]=N}S.remove(),f0(x),v=x,delete c[m.codoxDId]}}v||(v=bu(m),v.codoxDId&&v.__type==="excalidraw"&&v.__data==="[]"&&(v.__data="{}")),v=v.getWritable(),u.push(v),v.__parent=a.__key,b?(a.__first=v.__key,v.__prev=null,_&&(a.__last=v.__key)):_?(a.__last=v.__key,v.__next=null,v.__prev=w.__key,w.__next=v.__key):(v.__prev=w.__key,w.__next=v.__key),a.__size=u.length}for(let p in c){let m=c[p];m=m.getWritable(),f0(m),vu(m),delete c[p]}}else{let c=o.map(u=>bu(u));a.splice(0,a.getChildrenSize(),c)}}if(n){if(g.ld){const o=g.ld,a=Tn.get(o.codoxId);a.getChildrenSize&&a.getChildrenSize()?vu(a):a.remove()}if(g.li){let o=xe.getMainEditorNodesClassesMap();const a=g.li,c=o.get(a.type).klass.importJSON(a);if(t.length===1&&t[0]==="root")(0,ye.$getRoot)().splice(0,0,[c]);else{const u=t[t.length-1];t.length=t.length-2;let h=wa(t,y);h&&h.splice(u,0,[c])}if(a.children&&a.children.length){let u=function(h,p){const m=o.get(h.type).klass.importJSON(h);if(p.splice(p.getChildrenSize(),0,[m]),h.children&&h.children.length)for(const b of h.children)u(b,m)};for(const h of a.children)u(h,c)}}if(g.oi||g.od){let{p:o,oi:a,od:c}=g,u=wa(o,y);if(u)try{let h=u.getWritable();if(a){let p=Object.keys(a);for(let m of p)h[Dl(m)]=a[m]}if(c){let p=Object.keys(c);for(let m of p)delete h[Dl(m)]}}catch(h){le.debug("[applyDeltasToLexicalState][delta oi/od] getWritable error: ",{err:h,delta:g})}}if(l){let{p:o,lm:a}=g,c=o[o.length-1],u=a,h=u<c,p=wa(o,y);if(p){let m=p.getParent().getChildren(),b=m[c],_=m[u];h?_.insertBefore(b):_.insertAfter(b)}}}if(e){const o=t[t.length-1];let a=Dl(o);t.length=t.length-1;let c,u=wa(t,y);if(!u){le.error("Missing node when update node attr from delta: ",{path:t,delta:g,fullStateJSON:y,currentEditorState:xe.getMainEditorState().toJSON()});continue}try{c=u.getWritable()}catch(p){le.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:p,delta:g})}if(!c)continue;let h=g.oi;if(o==="format"&&(h=I_(h)),o==="direction"&&(u.hasOwnProperty(a)||(a="__dir")),!c.hasOwnProperty(a)){let p=Object.keys(c);for(let m of p){let b=Rf(m);if(o.startsWith(b)){a=m;break}}}c[a]=h}}else if(g.oi&&g.oi.root)return h0(g.oi)}}else le.log("[applyDeltasToLexicalState] stop, no deltas: ",d)}function Mx(y){let d=y.clipboardData.getData(M_.paste),g=!1;try{d=JSON.parse(d),typeof d=="object"&&d.nodes&&Array.isArray(d.nodes)&&(g=!0)}catch{return!1}if(!g)return!1;if(g){Tn.clearPastedIds();const t=f=>{if(f.codoxId&&Tn.addPastedId(f.codoxId),f.children&&f.children.length)for(const r of f.children)t(r)};for(const f of d.nodes)t(f)}return!1}var Dx=y=>{var d={};return rn.d(d,y),d};const g0=Dx({useCollaborationContext:()=>K1});var Lx=y=>{var d={};return rn.d(d,y),d};const Li=Lx({LexicalComposerContext:()=>xf,useLexicalComposerContext:()=>Tr});class m0{constructor(){this.blacklist=Object.keys(Gm).reduce((d,g)=>{let t=Gm[g];return d[g]=t.reduce((f,r)=>(f[r]=r,f),{}),d},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(d){return d instanceof ye.TextNode||d instanceof ye.ParagraphNode||d instanceof ye.RootNode}setClientCallback(d){this._clientCallback=d}removeClientCallback(){this._clientCallback=null}invokeClientCallback(){this._clientCallback&&this._clientCallback()}trackBlacklisted(d){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>2?arguments[2]:void 0;if(zf||g!==$r.created||this._isBlacklistedFound||!d||!d.__type||this._shouldSkipNode(d))return;let f=t||xe.getMainEditorState(),r=d.__type,n=this.blacklist[r];n&&f.read(()=>{let e=d.getParent();for(;e!==null;){let s=e?e.__type:null;if(!s)return;if(n[s])return le.warn("[ContentNestingsWatcher][trackBlacklisted] FOUND: ",{targetNode:d,targetType:r,parent:e,parentType:s,mutationType:g}),void(this._isBlacklistedFound=!0);e=e.getParent()}})}trackBlacklistedInNestedEditor(d){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>3?arguments[3]:void 0;if(g!==$r.created||this._isBlacklistedFound||this._shouldSkipNode(d))return;let f=t.__type,r=d.__type;if(!f||!r)return;let n=this.blacklist[r];n&&n[f]&&(this._isBlacklistedFound=!0,le.warn("[ContentNestingsWatcher][trackBlacklistedInNestedEditor] FOUND: ",{targetNode:d,targetType:r,rootNode:t,rootType:f,mutationType:g}))}isBlacklistedFound(){let d=this._isBlacklistedFound;return d&&(this._isBlacklistedFound=!1),d}}const Bx=new m0,Bi=Bx,Fx=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function zx(y,d){if(y==null)return{};var g,t,f=Ux(y,d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(y);for(t=0;t<r.length;t++)g=r[t],d.indexOf(g)>=0||{}.propertyIsEnumerable.call(y,g)&&(f[g]=y[g])}return f}function Ux(y,d){if(y==null)return{};var g={};for(var t in y)if({}.hasOwnProperty.call(y,t)){if(d.indexOf(t)>=0)continue;g[t]=y[t]}return g}class $x{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(d,g){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:s}=f,i=(zx(f,Fx),xe.getMainEditor()),l=xe.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),c=Bf(o,a),u=r._selection,h=n._selection,p=!1,m=null,b=xe.isOnlySelectionChanged(e,s),_=d[g];if(le.debug("[NESTED EDITOR LISTENER] invoked: ",{lexicalNode:d,key:d.__key,onlySelectionChanged:b,newEditorStateJSON:o,prevEditorStateJSON:a,isSameState:c,lexicalSelection:u,prevLexicalSelection:h,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,nestedEditorKey:_._key}),Bi.isBlacklistedFound())return t=!0,le.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),xe.scanLexicalNodeForNestedEditorAttribute(d)?(_.update(()=>{try{const v=_.parseEditorState(a);if(v.isEmpty())return(0,ye.$getRoot)().clear(),!0;_.setEditorState(v)}catch(v){le.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",v)}}),void Bi.invokeClientCallback()):void 0;if(t)t=!1;else{if(d.codoxId||d.codoxDId){let v=null;l.read(()=>{v=$e.getNodeAncestorsCodoxIds(d),!d.codoxId&&d.codoxDId&&v.push(d.codoxDId)}),r.read(()=>{let w=Rf(g),x=$e.lexicalToJSONNested(u,w,v);m=xe.getCurrentNestedSelectionJSON(),p=$e.equalSelectionsJSON(m,x),p||xe.setNestedSelectionJSON(x)})}c&&p||i.update(()=>{try{le.debug("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE",{mainTags:i._updateTags,nestedTags:_&&_._updateTags,isSameState:c,isSameSelection:p,onlyNestedSelectionChanged:b,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,lexicalNode:d,lexicalSelection:u,prevLexicalSelection:h,mainEditorTags:i._updateTags,mainEditorTagsSize:i._updateTags.size}),xe.addUpdateTag({fromNestedEditor:!0}),d.markDirty()}catch(v){le.error("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE - ERROR: ",v)}})}}}_isNestedEditorManaged(d){return!!this.nestedEditorsListenersMap[d]}gc(){for(let d in this.nestedEditorsListenersMap)if(!xe.getLexicalNodeByKey(d)){let g=this.nestedEditorsListenersMap[d];g&&g(),delete this.nestedEditorsListenersMap[d]}}manageNestedEditorInLexicalNode(d){if(this._isNestedEditorManaged(d.getKey()))return;let g=xe.scanLexicalNodeForNestedEditorAttribute(d);if(g){let t=d[g],f=this._createNestedEditorUpdatesListener(d,g),r=[];t._nodes.forEach((s,i,l)=>{let{klass:o}=s,a=t.registerMutationListener(o,c=>{for(let[u,h]of c)if(h===$r.created){let p=t.getEditorState()._nodeMap.get(u);p&&Bi.trackBlacklistedInNestedEditor(p,h,t.getEditorState(),d)}});r.push(a)});let n=(0,vs.mergeRegister)(t.registerUpdateListener(f),...r),e=d.getKey();this.nestedEditorsListenersMap[e]=n}}gcNestedEditorListenerInLexicalNode(d){let g=d.getKey(),t=this.nestedEditorsListenersMap[g];t&&(t(),delete this.nestedEditorsListenersMap[g])}manageNestedEditorInClonedLexicalNode(d,g){let t=d.getKey();t!==g.getKey()&&this._isNestedEditorManaged(t)&&(this.gcNestedEditorListenerInLexicalNode(d),this.manageNestedEditorInLexicalNode(g))}setNestedEditorSelection(d){let{nestedSelectionJSON:g,nestedEditor:t}=$e.getNestedSelectionJSONFromMainSelectionJSON(d);if(!t)return!1;let f=!0;return t.update(()=>{try{let r=$e.JSONToLexical(g);(0,ye.$setSelection)(r),le.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){le.error("[setNestedEditorSelection] set nested selection error: ",r),f=!1}}),f}clearListeners(){for(let d in this.nestedEditorsListenersMap){let g=this.nestedEditorsListenersMap[d];g&&g(),delete this.nestedEditorsListenersMap[d]}}}const Hx=new $x,oi=Hx,qx=function(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let g=(0,ye.createEditor)({namespace:"validation",nodes:[...d],onError:e=>{throw e},parentEditor:null});const t=new m0,f=g.parseEditorState(y);if(f.isEmpty())return;g.setEditorState(f);let r=g.getEditorState();const n=r._nodeMap[Symbol.iterator]();for(const e of n){let[s,i]=e;if(i&&(t.trackBlacklisted(i,$r.created,r),t.isBlacklistedFound()))throw new Error(D_)}}catch(g){throw g}};class Jx{constructor(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}_scanForCellHeaderState(d,g,t,f){if(g.length<f)return null;let r,n=g.some(s=>s.__headerState===Mi.BOTH||s.__headerState===Mi.ROW),e=d.some((s,i)=>{if(s.__size<f)return!1;let l=s.getChildAtIndex(t);return!(!l||l.__headerState!==Mi.BOTH&&l.__headerState!==Mi.COLUMN)});return n&&e?r=Mi.BOTH:n&&!e?r=Mi.ROW:e&&!n&&(r=Mi.COLUMN),r}_isValidCellChildren(d){for(let g of d)if(Es(g)||!Cs(g)&&Cn(g))return!1;return!0}_createEmptyCell(){let d=(0,En.$createTableCellNode)();return d.append((0,ye.$createParagraphNode)()),d}_wrapInvalidCellChildrenIntoParagraph(d){let g=(0,ye.$createParagraphNode)().getWritable(),t=d.getChildren();(d=d.getWritable()).__first=g.__key,d.__last=g.__key,d.__size=1,g.__parent=d.__key,t.forEach((f,r)=>{(f=f.getWritable()).__parent=null,g.append(f)})}_createFixAction_APPEND_CELLS_TO_ROW(d,g){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:d,numOfCellsToAppend:g});let t=(0,ye.$getNodeByKey)(d);for(;g;){let f=(0,En.$createTableCellNode)().append((0,ye.$createParagraphNode)());f.setRowSpan(1).setColSpan(1),t.append(f),g--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(d){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:d}),(0,ye.$getNodeByKey)(d).append((0,ye.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(d){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:d});let g=(0,ye.$getNodeByKey)(d);this._wrapInvalidCellChildrenIntoParagraph(g)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(d){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:d});let g=(0,ye.$getNodeByKey)(d),t=(0,En.$createTableRowNode)();t.append(this._createEmptyCell()),g.append(t)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(d,g){return()=>{for(g||(g=1);g;)(0,ye.$getNodeByKey)(d).append(this._createEmptyCell()),g--}}_createFixAction_WRAP_INVALID_ROW_NODE(d,g){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:d,rowKey:g});let t=(0,ye.$getNodeByKey)(d);if(!t)return;let f=(0,ye.$getNodeByKey)(g);if(!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling();f.__parent=null,f.__prev=null,f.__next=null;let e=(0,En.$createTableRowNode)();if((0,En.$isTableCellNode)(f))f.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(f):f.append((0,ye.$createParagraphNode)()),e.append(f);else{let s=this._isValidCellChildren([f]),i=(0,En.$createTableCellNode)();if(e.append(i),s)i.append(f);else{let l=(0,ye.$createParagraphNode)();l.append(f),i.append(l)}}e.__parent=t.__key,t.__first===f.__key&&(t.__first=e.__key),t.__last===f.__key&&(t.__last=e.__key),r&&(r=r.getWritable(),r.__next=e.__key,e.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=e.__key,e.__next=n.__key)}}_createFixAction_WRAP_INVALID_CELL_NODE(d,g){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:d,cellKey:g});let t=(0,ye.$getNodeByKey)(d);if(!t)return;let f=(0,ye.$getNodeByKey)(g);if(f.remove(),f=(0,ye.$createParagraphNode)(),!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling(),e=(0,En.$createTableCellNode)();if(e.__parent=t.__key,t.__first===f.__key&&(t.__first=e.__key),t.__last===f.__key&&(t.__last=e.__key),r&&(r=r.getWritable(),r.__next=e.__key,e.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=e.__key,e.__next=n.__key),f.__parent=null,f.__prev=null,f.__next=null,this._isValidCellChildren([f]))e.append(f);else{let s=(0,ye.$createParagraphNode)();s.append(f),e.append(s)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(d,g){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:d,headerStateToApply:g});let t=(0,ye.$getNodeByKey)(d);t&&(t=t.getWritable(),t.__headerState=g)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(d){let g=xe.getMainEditorState()._selection;if(le.debug(`[${d}]`,{selection:g}),!(0,ye.$isRangeSelection)(g))return;let t=[];try{let f=xe.getLexicalNodeByKey(g.anchor.key),r=xe.getLexicalNodeByKey(g.focus.key);f&&r&&(t=g.isBackward()?r.getNodesBetween(f):f.getNodesBetween(r))}catch(f){le.warn("[TablesValidator][tableRemoveEventListener] get range selection nodes internal lexical error: ",f)}t.forEach(f=>{(0,En.$isTableNode)(f)&&this.removeCandidateTableKeys.add(f.__key)})}tableNodeRemoveListener(d){this.removeCandidateTableKeys.has(d)&&this.removeCandidateTableKeys.delete(d)}shouldGCRemovedTables(){return!!this.removeCandidateTableKeys.size}gcRemovedTables(){le.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),xe.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(d=>{let g=(0,ye.$getNodeByKey)(d);g&&g.remove()}),this.removeCandidateTableKeys.clear(),(0,ye.$addUpdateTag)(Xr.historic)})}tableUpdateListener(d){this.validateTableCandidateKeys.add(d)}tableRowNodeChangesListener(d){let g=arguments.length>1&&arguments[1]!==void 0&&arguments[1],t=xe.getLexicalNodeByKey(d);if(!t)return void(g&&le.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:d}));let f=t.__parent;f?this.validateTableCandidateKeys.add(f):le.debug("[tableRowNodeChangesListener] no parent table for row node found in lexical: ",{rowNode:t})}tableCellNodeChangesListener(d){let g=xe.getLexicalNodeByKey(d);if(!g||!g.__parent)return;let t=xe.getLexicalNodeByKey(g.__parent);t&&t.__parent&&this.validateTableCandidateKeys.add(t.__parent)}shouldValidateUpdatedTables(){return!!this.validateTableCandidateKeys.size}validateUpdatedTables(){let d=Array.from(this.validateTableCandidateKeys);return xe.getMainEditorState().read(()=>{for(let g of d){let t=xe.getLexicalNodeByKey(g);if(!t)continue;let f=t.getChildren();if(!f.length){this.tableFixActions.push(this._createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(g));continue}let r=0;f.forEach(i=>{i.__size>r&&(r=i.__size)});let n=[],e=f.map((i,l)=>{if(!(0,En.$isTableRowNode)(i))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_ROW_NODE(g,i.__key)),"invalid_row_node";let o=i.getChildren();if(!o.length&&!n.length)return this.tableFixActions.push(this._createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(i.__key,r)),"empty_row_should_add_cell";if(!o.length&&n.length)return n=[],"empty_row_should_be_empty";let a=0;if(n.length){let u=[];n.forEach(h=>{let[p,m]=h;a+=m,p--,p&&u.push([p,m])}),n=[...u]}let c=o.map((u,h)=>{if(!(0,En.$isTableCellNode)(u))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_CELL_NODE(i.__key,u.__key)),a++,"invalid_cell_node_should_wrap_in_cell";let p,m=u.getChildren(),b=!m.length;if(b?this.tableFixActions.push(this._createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(u.__key)):(p=this._isValidCellChildren(m),p||this.tableFixActions.push(this._createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(u.__key))),u.__rowSpan>1){let _=u.__rowSpan,v=u.__colSpan;n.push([_-1,v])}if(a+=u.__colSpan,u.__headerState===Mi.NO_STATUS){let _=this._scanForCellHeaderState(f,o,h,r);_&&this.tableFixActions.push(this._createFixAction_APPLY_HEADER_STATE_TO_CELL(u.__key,_))}return{cellKey:u.__key,rowKey:i.__key,tableKey:g,colSpan:u.__colSpan,rowSpan:u.__rowSpan,headerState:u.__headerState,childrenAreValid:p,isEmptyCell:b}});if(a<r){let u=r-a;this.tableFixActions.push(this._createFixAction_APPEND_CELLS_TO_ROW(i.__key,u))}return{realRowLength:a,rowKey:i.__key,tableKey:g,cells:c}}),s=!this.tableFixActions.length;le[s?"debug":"warn"](`[TablesValidator][validateUpdatedTables] IS TABLE VALID: ${s}`,{tableNodeKey:g,tableValidationMatrix:e,requiredRowLength:r}),this.validateTableCandidateKeys.delete(g)}}),!this.tableFixActions.length}shouldFixTablesStructure(){return!!this.tableFixActions.length}fixTablesStructure(){if(!this.tableFixActions.length)return;let d=xe.getMainEditor();le.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),d.update(()=>{for(let g of this.tableFixActions)g();this.tableFixActions=[],(0,ye.$addUpdateTag)(Xr.historic)})}ensureDocTablesAreValid(d){return this.shouldGCRemovedTables()?(le.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(le.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(le.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(d.toJSON()))}),this.fixTablesStructure(),!1)}}const jo=new Jx,Wx=["contentChanged"],Vx=["state","remoteSelection"];function y0(y,d){var g=Object.keys(y);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(y);d&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(y,f).enumerable})),g.push.apply(g,t)}return g}function ws(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?y0(Object(g),!0).forEach(function(t){Kx(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):y0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function Kx(y,d,g){return(d=Gx(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function Gx(y){var d=Yx(y,"string");return typeof d=="symbol"?d:d+""}function Yx(y,d){if(typeof y!="object"||!y)return y;var g=y[Symbol.toPrimitive];if(g!==void 0){var t=g.call(y,d||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(y)}function b0(y,d){if(y==null)return{};var g,t,f=Zx(y,d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(y);for(t=0;t<r.length;t++)g=r[t],d.indexOf(g)>=0||{}.propertyIsEnumerable.call(y,g)&&(f[g]=y[g])}return f}function Zx(y,d){if(y==null)return{};var g={};for(var t in y)if({}.hasOwnProperty.call(y,t)){if(d.indexOf(t)>=0)continue;g[t]=y[t]}return g}const zf={DEBUG:!1,VERSION:"1.0.2",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";le.info("MODE: ","production");const Qx=y=>async()=>{const{state:d,timestamp:g}=await y();if(!xe.isValidJSONState(d))throw new Error("Invalid state received from fetchDocOnNetworkReconnect hook");const{commentThreads:t,root:f}=d,r={content:{comments:t,root:f},timestamp:g};return le.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let _u=0,ii=null,Uf=!1,mo={},$f={};const Xx=(0,Gt.forwardRef)((y,d)=>{let{onBlacklistedInsert:g}=y;const t=(0,Gt.useContext)(Li.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,Li.useLexicalComposerContext)(),r=(0,g0.useCollaborationContext)();(0,Gt.useEffect)(()=>{if(le.debug("[INIT] lexical context check: ",{lexicalContext:t,editor:f}),!f)return;le.log("[useEffect][editor] Editor instance changed: ",{editor:f,key:f._key}),xe.setMainEditor(f),Tn.gcAbandonedNodes(),oi.gc(),jo.clear(),le.log("[useEffect][editor] subscribe to editor changes");const b=(0,vs.mergeRegister)(f.registerUpdateListener(h),f.registerCommand(ye.PASTE_COMMAND,Mx,ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.UNDO_COMMAND,()=>{xe.setUndoInvoked(!0)},ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.REDO_COMMAND,()=>{xe.setRedoInvoked(!0)},ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.KEY_DELETE_COMMAND,(v,w)=>{jo.tableRemoveEventListener("KEY_DELETE_COMMAND")},ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.KEY_BACKSPACE_COMMAND,(v,w)=>{jo.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.CUT_COMMAND,(v,w)=>{jo.tableRemoveEventListener("CUT_COMMAND")},ye.COMMAND_PRIORITY_CRITICAL),...p());go.mount(),xe.alignStateSelectionJSONsFromLatestEditor(),le.debug("New editor mounted: ",{isCodoxStarted:xe.isCodoxStarted,codoxLexicalEditorManager:xe,nestedEditorsProcessor:oi});let _=f._onError;return f._onError=v=>{le.error("[ERROR HANDLER WRAPPER] error from editor: ",v),_&&_(v),u()},g&&Bi.setClientCallback(g),()=>{xe.getMainEditorKey()&&(le.debug("Unmount prev editor"),b(),xe.removeMainEditor(),go.unmount(),xe.clearJSONs(),Sn.clear(),jo.clear(),xe.isCodoxStarted&&(le.debug("EDITOR USE_EFFECT stopping codox"),n(),xe.setIsCodoxStarted(!1)),Bi.removeClientCallback())}},[f]);const n=()=>{xe.isCodoxStarted&&(le.log("[stopCodoxInstance] stopping codox"),xe.setIsCodoxStarted(!1),zf||Zo().stop(),xe.clearJSONs(),Tn.clearAll(),go.clear(),Sn.resetComments(),oi.clearListeners())},e=async b=>{le.debug("[startCodoxInstance] invoked"),Zo().createNewInstance(),le.debug("[startCodoxInstance] instance created");for(let O in $f)Zo().instance.on(O,$f[O]);if(le.debug("[startCodoxInstance] events subscribed"),mo=b,ii=mo.docId,!ii)return le.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:ii});let _=Sn.initialCommentsExist();le.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(Sn.activateInitialComments(f,Tn),le.log("[activateInitialComments] "));let v=xe.getMainEditorState().toJSON();if(!xe.isValidJSONState(v))throw le.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:ii,initJSONState:v}),new Error("start codox skipped - invalid init state");le.log("[startCodoxInstance] starting codox with: ",{docId:ii,initJSONState:v,config:mo,codoxComments:Sn}),xe.currentContentStateJSON||xe.setCurrentContentStateJSON(v),xe.isCodoxStarted&&n();let{username:w,apiKey:x,getServerState:S,domain:E="",demo:k=!1,hooks:D}=mo;D&&D.fetchDocOnNetworkReconnect&&(D.fetchDocOnNetworkReconnect=Qx(D.fetchDocOnNetworkReconnect));const N=b0(D,Wx);await Zo().start(Zo().createConfig(ws(ws({},mo),{},{docId:ii,username:w,apiKey:x,domain:E,hooks:ws({syncState:l,getState:i,getServerState:async()=>await S(ii)},N),editorInstanceHooks:{getSelection:()=>xe.getCurrentActiveSelectionJSON(),setSelection:O=>o(O),getState:i,setState:O=>{const{root:R,comments:A}=O;le.info("DEBUG: EDITOR INSTANCE setState:",{fullState:O}),a({state:{root:R},selection:xe.getCurrentActiveSelectionJSON()},go.getCurrentRemoteSelections()),Sn.setAllComments(A)},enableEditor:()=>{xe.disableEditorReadOnlyMode()},disableEditor:()=>{xe.enableEditorReadOnlyMode(),go.updateRemoteSelections([])},getContent:()=>{let O=xe.composeFullStateWithRootAndComments();return le.info("[getContent]: ",O),{state:O}}},appServer:mo.appServer,demo:k}))),le.log("[startCodoxInstance] codox started - first sync invoking"),xe.setIsCodoxStarted(!0),r.clientID=mo.username,r.name=mo.username,c()},s=()=>{let b=xe.composeFullStateWithRootAndComments({directlyFromEditor:!0});e(b)},i=()=>({state:ws(ws({},xe.getMainEditorState().toJSON()),{},{comments:Sn.getAllComments()}),docId:ii}),l=b=>{if(!xe.isCodoxStarted)return;le.log("[SYNC_STATE]: Before sync payload = ",b);const _=Zo().sync({meta:b}),{state:v,remoteSelection:w=[]}=_,x=b0(_,Vx);if(le.log("[SYNC_STATE]: After sync",{state:v,remoteSelection:w,rest:x}),!v)return le.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),s();const S=v.state;le.log("[SYNC_STATE] synced state: ",{synced:JSON.parse(JSON.stringify(S))});let{stateFromSync:E,commentsFromSync:k}=xe.extractStateAndCommentsFromSynced(S);if(!xe.isValidJSONState(E.state))return le.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:E.state}),s();a(E,w),Sn.setAllComments(k)},o=b=>{if(!xe.isCodoxStarted||(le.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:b}),!Ff.validateJSONSelection(b,Mf.local)))return;let _=xe.getCurrentActiveSelectionJSON();if($e.equalSelectionsJSON(_,b))return void le.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let v=$e.isNestedSelectionJSON(b);f.update(()=>{le.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:b});const w=$e.JSONToLexical(b);if(le.log("[setLocalSelectionFromSync] lexical selection to apply: ",w),v){let x=oi.setNestedEditorSelection(b);xe.setNestedSelectionJSON(x?b:null)}else(0,ye.$setSelection)(w),xe.setMainSelectionJSON(b);le.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:xe.getCurrentActiveSelectionJSON()})})},a=function(){let{state:b,selection:_,stateReplace:v}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",S=xe.getCurrentContentStateJSON();le.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:JSON.parse(JSON.stringify(b)),newSelectionJSON:_,remoteSelection:w,stateReplace:v,editor:f}),_===void 0&&le.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",_);const E=Bf(S,b),k=$e.equalSelectionsJSON(xe.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(xe.addUpdateTag({isSameState:E,isSameSelection:k,updateTag:x}),v)le.log("[updateEditor] invoke full stateReplace after sync"),h0(b),S=xe.setCurrentContentStateJSON(b),(0,ye.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S);else{le.log("[updateEditor] invoke deltas diff");let N=Zo().diff(S,b,{keyNames:{default:"codoxId"}});le.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:b,deltas:N&&JSON.parse(JSON.stringify(N))}),N&&N.length&&(le.log("[updateEditor] apply deltas to lexical state"),Rx(b,N),S=xe.setCurrentContentStateJSON(b),(0,ye.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(Ff.validateJSONSelection(_,Mf.local)||(_=xe.getCurrentActiveSelectionJSON()),D){let N=oi.setNestedEditorSelection(_);xe.setNestedSelectionJSON(N?_:null),le.log("[updateEditor] nested selection updated",N?_:null)}else if(_!==void 0){const N=$e.JSONToLexical(_);le.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:N}),(0,ye.$setSelection)(N),xe.setMainSelectionJSON(_),le.log("[updateEditor] selection updated",_)}},{onUpdate:()=>{E||go.updateRemoteSelections(w,"from onUpdate hook")}}),E&&go.updateRemoteSelections(w,"from direct updateEditor")},c=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";if(!xe.isCodoxStarted)return;le.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:b});let _=xe.composeFullStateWithRootAndComments();const v={docId:ii,state:{state:_,selection:xe.getCurrentActiveSelectionJSON()}};le.log("[codoxSync]: Before sync",{local:v,upd_call_counter:b}),le.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(v.state)));let{state:w,remoteSelection:x=[],changes:S}=Zo().sync({state:v,meta:{}});if(le.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(w)),remoteSelection:x,changes:S}),!w)return le.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),s();const E=w.state;le.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(E)),b);let{stateFromSync:k,commentsFromSync:D}=xe.extractStateAndCommentsFromSynced(E);if(!xe.isValidJSONState(k.state))return le.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),s();a(k,x),Sn.setAllComments(D)},u=()=>{le.warn("[rollbackStateDuringUpdateError] rollback invoked"),le.log("[rollbackStateDuringUpdateError] values: ",{prevState:xe.getPrevContentStateJSON(),currentState:xe.getCurrentContentStateJSON(),prevSelection:xe.getPrevMainSelectionJSON(),currentSelection:xe.getCurrentActiveSelectionJSON(),codoxComments:Sn});let b=xe.getPrevContentStateJSON(),_=xe.getPrevMainSelectionJSON();a({state:b,selection:_},go.getCurrentRemoteSelections(),Xr.historic);let v=xe.undoInvoked(),w=xe.redoInvoked();Sn.gcAbandonedNodeKeys(xe.getMainEditorState()._nodeMap),v&&f.dispatchCommand(ye.CAN_REDO_COMMAND,!1),w&&f.dispatchCommand(ye.CAN_UNDO_COMMAND,!1)},h=b=>{let{editorState:_,prevEditorState:v,tags:w,dirtyElements:x,dirtyLeaves:S}=b;if(Uf)return Uf=!1,void le.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(Bi.isBlacklistedFound())return Uf=!0,le.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((V,G)=>{let F=null,q=null;G.read(()=>{F=$e.lexicalToJSON(G._selection),q=G.toJSON()});let T=null,I=null;V.read(()=>{let L=(0,ye.$getSelection)();I=$e.lexicalToJSON(L),T=V.toJSON()}),xe.setCurrentContentStateJSON(T),xe.setMainSelectionJSON(I),a({state:q,selection:F},go.getCurrentRemoteSelections(),Xr.historic),f.dispatchCommand(ye.CAN_REDO_COMMAND,!1),f.dispatchCommand(ye.CAN_UNDO_COMMAND,!1)})(_,v),void Bi.invokeClientCallback();if(!jo.ensureDocTablesAreValid(_))return;_u++,le.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:_u,isCodoxStarted:xe.isCodoxStarted});let E=xe.isOnlySelectionChanged(x,S),k=null,D=null,N=null,O=null,R=xe.getCurrentContentStateJSON(),A=w.has("codox_sync_state_changes"),z=w.has(Ll),H=xe.undoInvoked(),$=xe.redoInvoked(),M=xe.canUndo(),J=xe.canRedo();k=_.toJSON(),D=v.toJSON(),v.read(()=>{O=$e.lexicalToJSON(v._selection)}),_.read(()=>{let V=(0,ye.$getSelection)();N=$e.lexicalToJSON(V);let G=$e.JSONToLexical(N),F=V===null&&G===null||V.is(G);le.log("[editorUpdatesListener] new values: ",{newContentStateJSON:k,currentContentStateJSON:JSON.parse(JSON.stringify(R)),prevContentStateJSON:JSON.parse(JSON.stringify(D)),currentCommentsJSON:JSON.parse(JSON.stringify(Sn.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(N)),currentMainSelectionJSON:JSON.parse(JSON.stringify(xe.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(xe.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(xe.getCurrentActiveSelectionJSON())),lexicalSelection:V,convertedBackMainSelection:G,isMainSelectionConvertionCorrect:F,nodes:f._editorState._nodeMap,fullEditor:f,codoxNodesMap:Tn.toArray(),codoxComments:Sn,isUpdateFromSync:A,isUpdateFromComments:z,tags:w,onlySelectionChanged:E,undoInvoked:H,redoInvoked:$,canUndo:M,canRedo:J})});let K=Bf(R,k),P=$e.equalSelectionsJSON(xe.getCurrentActiveSelectionJSON(),N);le.log("[editorUpdatesListener] compares: ",{isStateSame:K,isSelectionSame:P});let U=K&&P&&!z;if(!K||z||A){let V=ws({},K?R:k),G=Sn.getAllComments();G.length&&(V.commentThreads=G);let F={source:A?Ym.remote:Ym.local,content:V};mo.hooks&&mo.hooks.contentChanged&&mo.hooks.contentChanged(F),Zo().instance.emit("content_changed",F)}if(U)le.log("[editorUpdatesListener] STOP - state and selection and comments are same ",_u);else if(xe.undoInvoked()&&xe.setUndoInvoked(!1),xe.redoInvoked()&&xe.setRedoInvoked(!1),xe.setCurrentContentStateJSON(k),xe.setPrevContentStateJSON(D),xe.setMainSelectionJSON(N),xe.setPrevMainSelectionJSON(O),zf){let V=xe.getCurrentActiveSelectionJSON();a({state:xe.getCurrentContentStateJSON(),selection:V},[])}else c(_u)},p=()=>{let b=[];return xe.getMainEditorNodesClassesMap().forEach((_,v,w)=>{let{klass:x}=_,S=f.registerMutationListener(x,E=>{for(let[k,D]of E){if(!$r[D])continue;const N=xe.getLexicalNodeByKey(k);if(D===$r.created&&N&&Bi.trackBlacklisted(N,D),x.name===En.TableNode.name&&(D===$r.destroyed?jo.tableNodeRemoveListener(k):jo.tableUpdateListener(k)),x.name===En.TableRowNode.name&&D!==$r.destroyed&&jo.tableRowNodeChangesListener(k,D===$r.updated),x.name===En.TableCellNode.name&&D===$r.updated&&jo.tableCellNodeChangesListener(k),x.name===Qr.MarkNode.name&&(le.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:N,mutationType:D,codoxComments:Sn}),D===$r.destroyed?Sn.removeRelatedNodeKey(k):N&&Sn.addRelatedNodeKey(N.__key,N.__ids,D===$r.created)),N&&N.codoxId){if(D===$r.destroyed)return void(N.codoxId&&Tn.remove(N.codoxId));k0(N)||le.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:D,node:N}),Tn.add(N.codoxId,N)}}b.push(S)})}),b},m={start:e,stop:n,on:(b,_)=>{le.info(`Subscribing client to codox ${b} event`),$f[b]=_},cursor:{hide:()=>{go.hideRemoteSelectionsFromUI()},show:()=>{go.showHiddenRemoteSelectionsInUI()}},initComments:b=>{Sn.setInitialComments(b)}};return(0,Gt.useImperativeHandle)(d,()=>m),null}),tw=Xx,ew=["comments"];function v0(y,d){var g=Object.keys(y);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(y);d&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(y,f).enumerable})),g.push.apply(g,t)}return g}function Hf(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?v0(Object(g),!0).forEach(function(t){nw(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):v0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function nw(y,d,g){return(d=rw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function rw(y){var d=ow(y,"string");return typeof d=="symbol"?d:d+""}function ow(y,d){if(typeof y!="object"||!y)return y;var g=y[Symbol.toPrimitive];if(g!==void 0){var t=g.call(y,d||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(y)}function iw(y,d){if(y==null)return{};var g,t,f=aw(y,d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(y);for(t=0;t<r.length;t++)g=r[t],d.indexOf(g)>=0||{}.propertyIsEnumerable.call(y,g)&&(f[g]=y[g])}return f}function aw(y,d){if(y==null)return{};var g={};for(var t in y)if({}.hasOwnProperty.call(y,t)){if(d.indexOf(t)>=0)continue;g[t]=y[t]}return g}class sw extends Vm{constructor(){super(),this.mainEditor=null,this.mainEditorKey=null,this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this._isCodoxStarted=!1,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1}setCanUndo(d){this._canUndo=d}setCanRedo(d){this._canRedo=d}canUndo(){return this._canUndo}canRedo(){return this._canRedo}setUndoInvoked(d){this._undoInvoked=d}setRedoInvoked(d){this._redoInvoked=d}undoInvoked(){return this._undoInvoked}redoInvoked(){return this._redoInvoked}setIsCodoxStarted(){let d=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this._isCodoxStarted=d}get isCodoxStarted(){return this._isCodoxStarted}getMainEditorKey(){return this.mainEditorKey}setMainEditor(d){this.mainEditor=d,this.mainEditorKey=d._key}clearJSONs(){le.debug("[CodoxLexicalEditorManager][clearJSONs] invoked"),this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null}removeMainEditor(){this.mainEditor=null,this.mainEditorKey=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1,super.clear()}getMainEditor(){return this.mainEditor}alignStateSelectionJSONsFromLatestEditor(){this.getMainEditorState().read(()=>{this.setCurrentContentStateJSON(this.getMainEditorState().toJSON()),this.setMainSelectionJSON($e.lexicalToJSON((0,ye.$getSelection)()))})}mainEditorExists(){return!!this.mainEditor}getMainEditorState(){return this.mainEditor?this.mainEditor.getEditorState():{}}getMainEditorNodesClassesMap(){return this.mainEditor?this.mainEditor._nodes:new Map}getLexicalNodeByKey(d){return this.mainEditor?this.getMainEditorState()._nodeMap.get(d):null}isLexicalEditorInstance(d){return d&&typeof d=="object"&&!!d.setEditorState}setCurrentContentStateJSON(d){return this.currentContentStateJSON=d,this.currentContentStateJSON}getCurrentContentStateJSON(){return this.currentContentStateJSON}setPrevContentStateJSON(d){this.prevContentStateJSON=d}getPrevContentStateJSON(){return this.prevContentStateJSON}setMainSelectionJSON(d){this.currentMainSelectionJSON=d,this.currentMainSelectionJSON&&this.currentNestedSelectionJSON&&(this.currentNestedSelectionJSON=null)}setNestedSelectionJSON(d){this.currentNestedSelectionJSON=d,this.currentNestedSelectionJSON&&this.currentMainSelectionJSON&&(this.currentMainSelectionJSON=null)}getCurrentMainSelectionJSON(){return this.currentMainSelectionJSON}getCurrentNestedSelectionJSON(){return this.currentNestedSelectionJSON}getCurrentActiveSelectionJSON(){return!this.currentMainSelectionJSON&&this.currentNestedSelectionJSON?this.currentNestedSelectionJSON:this.currentMainSelectionJSON}clearSelectionJSON(){this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null}setPrevMainSelectionJSON(d){this.prevMainSelectionJSON=d}getPrevMainSelectionJSON(){return this.prevMainSelectionJSON}extractStateAndCommentsFromSynced(d){let{state:{comments:g},selection:t,stateReplace:f}=d;return{stateFromSync:{state:Hf({},iw(d.state,ew)),selection:t,stateReplace:f},commentsFromSync:g}}composeFullStateWithRootAndComments(){let{directlyFromEditor:d=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Hf(Hf({},d?this.getMainEditorState().toJSON():this.currentContentStateJSON),{},{comments:Sn.getAllComments()})}isValidJSONState(d){let g=!1;try{if(!d)throw new Error("State is undefined");if(!d.root)throw new Error("State 'root' node is missing");let t=this.getMainEditorNodesClassesMap(),f=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",e=r,s=t.get(e.type);if(!s)throw new Error(`Node with type "${e.type}" is not registered in editor`);let{klass:i}=s;if(n==="root"){let l=i.prototype instanceof ye.ElementNode,o=i.prototype instanceof ye.DecoratorNode;if(!l&&!o)throw new Error("State root node can have only element nodes as children")}if(e.children)for(let l of e.children)f(l,e.type)};f(d.root),g=!0}catch(t){le.error("[isValidJSONState] invalid state found: ",t.message),g=!1}return g}scanLexicalNodeForNestedEditorAttribute(d){for(let g in d){let t=d[g];if(this.isLexicalEditorInstance(t))return g}return""}isOnlySelectionChanged(d,g){return d.size===0&&g.size===0}addUpdateTag(){let{isSameState:d,isSameSelection:g,fromNestedEditor:t=!1,updateTag:f=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return f?(le.log(`[addUpdateTag] explicit add of tag "${f}" `),void(0,ye.$addUpdateTag)(f)):t?(le.log(`[addUpdateTag] add "${Xr.historic}" tag - change invoked by nested editor`),void(0,ye.$addUpdateTag)(Xr.historic)):void(d?(le.log(`[addUpdateTag] add "${Xr.historic}" tag - state is same`),(0,ye.$addUpdateTag)(Xr.historic)):(le.log(`[addUpdateTag] add "${Xr.historyMerge}" tag - state is different`),(0,ye.$addUpdateTag)(Xr.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const lw=new sw,xe=lw;class cw{constructor(){this._nodesMap=new Map,this._pastedNodesCodoxIds=new Set}get size(){return this._nodesMap.size}add(d,g){this._nodesMap.set(d,g)}get(d){return this._nodesMap.get(d)||null}remove(d){this._nodesMap.delete(d)}has(d){return this._nodesMap.has(d)}nodesToArray(){return Array.from(this._nodesMap.values())}keysToArray(){return Array.from(this._nodesMap.keys())}toArray(){return Array.from(this._nodesMap.entries())}addPastedId(d){this._pastedNodesCodoxIds.add(d)}removePastedId(d){this._pastedNodesCodoxIds.delete(d)}hasPastedId(d){return this._pastedNodesCodoxIds.has(d)}clearPastedIds(){this._pastedNodesCodoxIds.size>0&&this._pastedNodesCodoxIds.clear()}isEmptyPastedIds(){return this._pastedNodesCodoxIds.size===0}getPastedIdsSize(){return this._pastedNodesCodoxIds.size}clearAll(){this._nodesMap.clear(),this._pastedNodesCodoxIds.clear()}gcAbandonedNodes(){let d=xe.getMainEditorState();if(!d._nodeMap)return;let g=this.nodesToArray();for(let t of g)d._nodeMap.has(t.__key)||this.remove(t.codoxId)}}const uw=new cw,Tn=uw;function _0(y,d){var g=Object.keys(y);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(y);d&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(y,f).enumerable})),g.push.apply(g,t)}return g}function x0(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?_0(Object(g),!0).forEach(function(t){dw(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):_0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function dw(y,d,g){return(d=fw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function fw(y){var d=pw(y,"string");return typeof d=="symbol"?d:d+""}function pw(y,d){if(typeof y!="object"||!y)return y;var g=y[Symbol.toPrimitive];if(g!==void 0){var t=g.call(y,d||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(y)}const qf=()=>x_(),w0=y=>typeof y=="number";function Ss(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const g=function(){for(var t=arguments.length,f=new Array(t),r=0;r<t;r++)f[r]=arguments[r];return y.apply(this,f)};return Object.defineProperty(g,"name",{value:d,writable:!0}),g}const Sa=y=>y.__type==="root"||y.type==="root",S0=y=>Sa(y.getParent()),Fn=y=>y.__type===hu.text||y.type===hu.text||y.hasOwnProperty("__text")||y.hasOwnProperty("text"),Cs=y=>(0,ye.$isElementNode)(y),Es=y=>(0,En.$isTableNode)(y)||(0,En.$isTableRowNode)(y)||(0,En.$isTableCellNode)(y),hw=y=>!y.getChildren,C0=y=>!!y.getChildren,Cn=y=>(0,ye.$isDecoratorNode)(y),Fl=y=>(0,p_.$isLinkNode)(y),zl=y=>y.__type==="mark"||y.type==="mark",Jf=y=>(0,ye.$isLineBreakNode)(y),Fi=y=>Fn(y)||Jf(y),Wf=y=>y.__type===hu.horizontalrule||y.type===hu.horizontalrule,E0=y=>{if(Fi(y)||Fl(y)||zl(y))return!1;if(!y.__parent||y.__parent==="root"||(0,ye.$isParagraphNode)(y))return!0;let d=y.getParent().getChildren();return d.length===1&&d[0].__key===y.__key?!((Cn(y)||Fl(y)||zl(y))&&!Wf(y)):!d.some(g=>{let t=Wf(g);return g.__key!==y.__key&&(Fi(g)||Cn(g)&&!t||Fl(g)||zl(g))})},k0=y=>{const d=Tn.get(y.codoxId);return!d||y.__key===d.__key},ks=function(y){const d=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||qf();y.codoxId=d,Tn.add(d,y)},O0=y=>{Tn.remove(y.codoxId),delete y.codoxId},gw=y=>{if(!C0(y)||!y.getChildrenSize())return;const d=y.getChildren();if(d.some(f=>!!(0,ye.$isParagraphNode)(f)))return;let g=!1,t=[];for(let f of d)(Fi(f)||Cn(f)||Fl(f)||zl(f))&&!g&&(Wf(f)||(g=!0)),(C0(f)||Cn(f))&&t.push(f);for(let f of t)g||f.codoxId?g&&f.codoxId&&(f=f.getWritable(),O0(f)):(f=f.getWritable(),ks(f))},mw=y=>{const d=x0({},y);for(const g in y)y[g]===void 0&&y.hasOwnProperty(g)&&delete d[g];return d},yw=y=>{const d=`__nativeCreateDOM_${y.name}`;y.prototype[d]=Ss(y.prototype.createDOM,d),y.prototype.createDOM=function(g,t){if(E0(this))if(this.codoxId){if(!k0(this)){let r=Tn.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(le.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),Tn.add(this.codoxId,this)):ks(this)}}else ks(this);else this.codoxId&&O0(this);Cn(this)&&!this.codoxDId&&(this.codoxDId=qf()),oi.manageNestedEditorInLexicalNode(this);let f=this[d](g,t);return f.__codox_track=!0,f}},bw=y=>{const d=`__nativeUpdateDOM_${y.name}`;return y.prototype[d]=Ss(y.prototype.updateDOM,d),y.prototype.updateDOM=function(){const g=this[d](...arguments);return gw(this),g},y},vw=y=>{const d=`__nativeRemove_${y.name}`;return y.prototype[d]=Ss(y.prototype.remove,d),y.prototype.remove=function(){const g=this.codoxId;return g&&Tn.remove(g),oi.gcNestedEditorListenerInLexicalNode(this),this[d](...arguments)},y},_w=y=>{const d=`__nativeExportJSON_${y.name}`;y.prototype[d]=Ss(y.prototype.exportJSON,d),y.prototype.exportJSON=function(){const g=this[d]();return this.codoxId&&(g.codoxId=this.codoxId),this.codoxDId&&(g.codoxDId=this.codoxDId),Fn(this)&&w0(g.format)&&this.hasFormat&&(g.format=P_(this)),mw(g)}},xw=y=>{const d="__nativeImportJSON";y[d]=Ss(y.importJSON,d),y.importJSON=function(g){const t=x0({},g);Fn(t)&&!w0(t.format)&&(t.format=N_(t.format));const f=y[d](t);oi.manageNestedEditorInLexicalNode(f);const r=E0(f);return r&&t.codoxId&&(Tn.hasPastedId(t.codoxId)&&Tn.has(t.codoxId)?(Tn.removePastedId(t.codoxId),ks(f)):ks(f,t.codoxId)),r&&!f.codoxId&&ks(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},ww=y=>{const d="__nativeClone";y[d]=Ss(y.clone,d),y.clone=function(g){const t=y[d](g);return g.codoxId&&(t.codoxId=g.codoxId),g.codoxDId&&(t.codoxDId=g.codoxDId),oi.manageNestedEditorInClonedLexicalNode(g,t),t}},Sw=y=>{let d=!1,g=!1,t=!1,f=!1;y.forEach(n=>{n.name===ye.TextNode.name?d=!0:n.name===ye.ParagraphNode.name?g=!0:n.name===ye.LineBreakNode.name?t=!0:n.name===Qr.MarkNode.name&&(f=!0)});let r=[];return d||r.push(ye.TextNode),g||r.push(ye.ParagraphNode),t||r.push(ye.LineBreakNode),f||r.push(Qr.MarkNode),r.length?[...r,...y]:y},Cw=function(){return Sw(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(y=>(y.hasOwnProperty("__isCodoxExtended")||(yw(y),bw(y),_w(y),vw(y),xw(y),ww(y),Object.defineProperty(y,"__isCodoxExtended",{value:!0,writable:!1})),y))};var xu=rn(777),Os={};Os.styleTagTransform=ri(),Os.setAttributes=ei(),Os.insert=ti().bind(null,"head"),Os.domAPI=Xo(),Os.insertStyleElement=ni(),Qo()(xu.A,Os),xu.A&&xu.A.locals&&xu.A.locals;var Ew=y=>{var d={};return rn.d(d,y),d};const kw=Ew({AutoFocusPlugin:()=>$g});var Ow=y=>{var d={};return rn.d(d,y),d};const Tw=Ow({ClearEditorPlugin:()=>Y1});var jw=y=>{var d={};return rn.d(d,y),d};const Aw=jw({LexicalComposer:()=>Ug});var Nw=y=>{var d={};return rn.d(d,y),d};const T0=Nw({default:()=>Q1});var Pw=y=>{var d={};return rn.d(d,y),d};const Iw=Pw({HistoryPlugin:()=>om});var Rw=y=>{var d={};return rn.d(d,y),d};const Mw=Rw({OnChangePlugin:()=>t_});var Dw=y=>{var d={};return rn.d(d,y),d};const Lw=Dw({PlainTextPlugin:()=>l_});var Bw=y=>{var d={};return rn.d(d,y),d};const j0=Bw({$isRootTextContentEmpty:()=>sm,$rootTextContent:()=>am});var Fw=y=>{var d={};return rn.d(d,y),d};const Ts=Fw({createPortal:()=>Tb.createPortal}),zw=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Uw=zw?Gt.useLayoutEffect:Gt.useEffect,A0=Uw;var wu=rn(253),js={};js.styleTagTransform=ri(),js.setAttributes=ei(),js.insert=ti().bind(null,"head"),js.domAPI=Xo(),js.insertStyleElement=ni(),Qo()(wu.A,js),wu.A&&wu.A.locals&&wu.A.locals;function $w(y){let{onClose:d,children:g,title:t,closeOnClickOutside:f}=y;const r=(0,Gt.useRef)(null);return(0,Gt.useEffect)(()=>{r.current!==null&&r.current.focus()},[]),(0,Gt.useEffect)(()=>{let n=null;const e=l=>{l.key==="Escape"&&d()},s=l=>{const o=l.target;r.current!==null&&!r.current.contains(o)&&f&&d()},i=r.current;return i!==null&&(n=i.parentElement,n!==null&&n.addEventListener("click",s)),window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),n!==null&&(n==null||n.removeEventListener("click",s))}},[f,d]),Gt.createElement("div",{className:"Modal__overlay",role:"dialog"},Gt.createElement("div",{className:"Modal__modal",tabIndex:-1,ref:r},Gt.createElement("h2",{className:"Modal__title"},t),Gt.createElement("button",{className:"Modal__closeButton","aria-label":"Close modal",type:"button",onClick:d},"X"),Gt.createElement("div",{className:"Modal__content"},g)))}function Hw(y){let{onClose:d,children:g,title:t,closeOnClickOutside:f=!1}=y;return(0,Ts.createPortal)(Gt.createElement($w,{onClose:d,title:t,closeOnClickOutside:f},g),document.body)}function N0(){const[y,d]=(0,Gt.useState)(null),g=(0,Gt.useCallback)(()=>{d(null)},[]),t=(0,Gt.useMemo)(()=>{if(y===null)return null;const{title:r,content:n,closeOnClickOutside:e}=y;return Gt.createElement(Hw,{onClose:g,title:r,closeOnClickOutside:e},n)},[y,g]),f=(0,Gt.useCallback)(function(r,n){d({closeOnClickOutside:arguments.length>2&&arguments[2]!==void 0&&arguments[2],content:n(g),title:r})},[g]);return[t,f]}var Su=rn(191),As={};As.styleTagTransform=ri(),As.setAttributes=ei(),As.insert=ti().bind(null,"head"),As.domAPI=Xo(),As.insertStyleElement=ni(),Qo()(Su.A,As),Su.A&&Su.A.locals&&Su.A.locals;const qw={blockCursor:"CommentEditorTheme__blockCursor",characterLimit:"CommentEditorTheme__characterLimit",code:"CommentEditorTheme__code",codeHighlight:{atrule:"CommentEditorTheme__tokenAttr",attr:"CommentEditorTheme__tokenAttr",boolean:"CommentEditorTheme__tokenProperty",builtin:"CommentEditorTheme__tokenSelector",cdata:"CommentEditorTheme__tokenComment",char:"CommentEditorTheme__tokenSelector",class:"CommentEditorTheme__tokenFunction","class-name":"CommentEditorTheme__tokenFunction",comment:"CommentEditorTheme__tokenComment",constant:"CommentEditorTheme__tokenProperty",deleted:"CommentEditorTheme__tokenProperty",doctype:"CommentEditorTheme__tokenComment",entity:"CommentEditorTheme__tokenOperator",function:"CommentEditorTheme__tokenFunction",important:"CommentEditorTheme__tokenVariable",inserted:"CommentEditorTheme__tokenSelector",keyword:"CommentEditorTheme__tokenAttr",namespace:"CommentEditorTheme__tokenVariable",number:"CommentEditorTheme__tokenProperty",operator:"CommentEditorTheme__tokenOperator",prolog:"CommentEditorTheme__tokenComment",property:"CommentEditorTheme__tokenProperty",punctuation:"CommentEditorTheme__tokenPunctuation",regex:"CommentEditorTheme__tokenVariable",selector:"CommentEditorTheme__tokenSelector",string:"CommentEditorTheme__tokenSelector",symbol:"CommentEditorTheme__tokenProperty",tag:"CommentEditorTheme__tokenProperty",url:"CommentEditorTheme__tokenOperator",variable:"CommentEditorTheme__tokenVariable"},embedBlock:{base:"CommentEditorTheme__embedBlock",focus:"CommentEditorTheme__embedBlockFocus"},hashtag:"CommentEditorTheme__hashtag",heading:{h1:"CommentEditorTheme__h1",h2:"CommentEditorTheme__h2",h3:"CommentEditorTheme__h3",h4:"CommentEditorTheme__h4",h5:"CommentEditorTheme__h5",h6:"CommentEditorTheme__h6"},image:"editor-image",indent:"CommentEditorTheme__indent",inlineImage:"inline-editor-image",layoutContainer:"CommentEditorTheme__layoutContainer",layoutItem:"CommentEditorTheme__layoutItem",link:"CommentEditorTheme__link",list:{checklist:"CommentEditorTheme__checklist",listitem:"CommentEditorTheme__listItem",listitemChecked:"CommentEditorTheme__listItemChecked",listitemUnchecked:"CommentEditorTheme__listItemUnchecked",nested:{listitem:"CommentEditorTheme__nestedListItem"},olDepth:["CommentEditorTheme__ol1","CommentEditorTheme__ol2","CommentEditorTheme__ol3","CommentEditorTheme__ol4","CommentEditorTheme__ol5"],ul:"CommentEditorTheme__ul"},ltr:"CommentEditorTheme__ltr",mark:"CommentEditorTheme__mark",markOverlap:"CommentEditorTheme__markOverlap",paragraph:"CommentEditorTheme__paragraph",quote:"CommentEditorTheme__quote",rtl:"CommentEditorTheme__rtl",table:"CommentEditorTheme__table",tableCell:"CommentEditorTheme__tableCell",tableCellActionButton:"CommentEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"CommentEditorTheme__tableCellActionButtonContainer",tableCellEditing:"CommentEditorTheme__tableCellEditing",tableCellHeader:"CommentEditorTheme__tableCellHeader",tableCellPrimarySelected:"CommentEditorTheme__tableCellPrimarySelected",tableCellResizer:"CommentEditorTheme__tableCellResizer",tableCellSelected:"CommentEditorTheme__tableCellSelected",tableCellSortedIndicator:"CommentEditorTheme__tableCellSortedIndicator",tableResizeRuler:"CommentEditorTheme__tableCellResizeRuler",tableSelected:"CommentEditorTheme__tableSelected",tableSelection:"CommentEditorTheme__tableSelection",text:{bold:"CommentEditorTheme__textBold",code:"CommentEditorTheme__textCode",italic:"CommentEditorTheme__textItalic",strikethrough:"CommentEditorTheme__textStrikethrough",subscript:"CommentEditorTheme__textSubscript",superscript:"CommentEditorTheme__textSuperscript",underline:"CommentEditorTheme__textUnderline",underlineStrikethrough:"CommentEditorTheme__textUnderlineStrikethrough"}},Jw=qw;var Cu=rn(72),Ns={};Ns.styleTagTransform=ri(),Ns.setAttributes=ei(),Ns.insert=ti().bind(null,"head"),Ns.domAPI=Xo(),Ns.insertStyleElement=ni(),Qo()(Cu.A,Ns),Cu.A&&Cu.A.locals&&Cu.A.locals;function Ww(){for(var y=arguments.length,d=new Array(y),g=0;g<y;g++)d[g]=arguments[g];return d.filter(Boolean).join(" ")}function Vf(){return Vf=Object.assign?Object.assign.bind():function(y){for(var d=1;d<arguments.length;d++){var g=arguments[d];for(var t in g)({}).hasOwnProperty.call(g,t)&&(y[t]=g[t])}return y},Vf.apply(null,arguments)}function zi(y){let{"data-test-id":d,children:g,className:t,onClick:f,disabled:r,small:n,title:e}=y;return Gt.createElement("button",Vf({disabled:r,className:Ww("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},d&&{"data-test-id":d}),g)}var Eu=rn(129),Ps={};Ps.styleTagTransform=ri(),Ps.setAttributes=ei(),Ps.insert=ti().bind(null,"head"),Ps.domAPI=Xo(),Ps.insertStyleElement=ni(),Qo()(Eu.A,Ps),Eu.A&&Eu.A.locals&&Eu.A.locals;var Vw=y=>{var d={};return rn.d(d,y),d};const Kw=Vw({ContentEditable:()=>Hg});function Gw(y){let{className:d}=y;return Gt.createElement(Kw.ContentEditable,{className:d||"ContentEditable__root"})}var ku=rn(457),Is={};Is.styleTagTransform=ri(),Is.setAttributes=ei(),Is.insert=ti().bind(null,"head"),Is.domAPI=Xo(),Is.insertStyleElement=ni(),Qo()(ku.A,Is),ku.A&&ku.A.locals&&ku.A.locals;function Yw(y){let{children:d,className:g}=y;return Gt.createElement("div",{className:g||"Placeholder__root"},d)}const Zw=T0.default.LexicalErrorBoundary||T0.default,Qw=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"#050505",className:"codox-add-comment-right"},Gt.createElement("path",{d:"M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H4.414A2 2 0 0 0 3 11.586l-2 2V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12.793a.5.5 0 0 0 .854.353l2.853-2.853A1 1 0 0 1 4.414 12H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"}),Gt.createElement("path",{d:"M3 3.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 6a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 6zm0 2.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"})),P0=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",className:"codox-remove-comment"},Gt.createElement("path",{d:"M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z"})),Xw=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"codox-add-comment"},Gt.createElement("path",{d:"M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576 6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76 7.494-7.493Z"})),tS=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"#0000008c",className:"codox-hide-show-comments"},Gt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13 5.885v1.166a3.95 3.95 0 0 1-3.949 3.95H6.917a.748.748 0 0 0-.45.15l-1.345 1.007a.752.752 0 0 0-.032 1.181A2.933 2.933 0 0 0 6.95 14h2.716l2.534 1.901a.506.506 0 0 0 .524.047A.501.501 0 0 0 13 15.5V14h.051a2.949 2.949 0 0 0 2.95-2.949v-3.05a3.002 3.002 0 0 0-2.002-2.83.756.756 0 0 0-.999.714"}),Gt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.05 1H2.95A2.952 2.952 0 0 0 0 3.949v3.102A2.952 2.952 0 0 0 2.949 10H3v1.5a.502.502 0 0 0 .8.4L6.334 10H9.05A2.952 2.952 0 0 0 12 7.05V3.95A2.952 2.952 0 0 0 9.05 1"}));function I0(y,d,g){let t=arguments.length>3&&arguments[3]!==void 0?arguments[3]:performance.now(),f=arguments.length>4&&arguments[4]!==void 0&&arguments[4];return Sn.createNewCommentObj({content:y,author:d,codoxId:g,timeStamp:t,deleted:f})}function eS(y,d,g){return Sn.createNewThreadObj({quote:y,comments:d,codoxId:g})}function nS(y){let{anchorKey:d,editor:g,onAddComment:t}=y;const f=(0,Gt.useRef)(null),r=(0,Gt.useCallback)(()=>{const n=f.current,e=g.getRootElement(),s=g.getElementByKey(d);if(n!==null&&e!==null&&s!==null){const{right:i}=e.getBoundingClientRect(),{top:l}=s.getBoundingClientRect();n.style.left=i-20+"px",n.style.top=l-30+"px"}},[d,g]);return(0,Gt.useEffect)(()=>(window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[g,r]),A0(()=>{r()},[d,g,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(Qw,null)))}function rS(y){let{onEscape:d}=y;const[g]=(0,Li.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>g.registerCommand(ye.KEY_ESCAPE_COMMAND,t=>d(t),2),[g,d]),null}function oS(y){let{editorRef:d}=y;const[g]=(0,Li.useLexicalComposerContext)();return typeof d=="function"?d(g):typeof d=="object"&&(d.current=g),null}function R0(y){let{className:d,autoFocus:g,onEscape:t,onChange:f,editorRef:r,placeholder:n="Type a comment...",onEditorClick:e=()=>{}}=y;const s={namespace:"Commenting",nodes:[],onError:i=>{throw i},theme:Jw};return Gt.createElement(Aw.LexicalComposer,{initialConfig:s},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(Lw.PlainTextPlugin,{contentEditable:Gt.createElement(Gw,{className:d}),placeholder:Gt.createElement(Yw,null,n),ErrorBoundary:Zw}),Gt.createElement(Mw.OnChangePlugin,{onChange:f}),Gt.createElement(Iw.HistoryPlugin,null),g!==!1&&Gt.createElement(kw.AutoFocusPlugin,null),Gt.createElement(rS,{onEscape:t}),Gt.createElement(Tw.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(oS,{editorRef:r})))}function M0(y,d){return(0,Gt.useCallback)((g,t)=>{g.read(()=>{y((0,j0.$rootTextContent)()),d(!(0,j0.$isRootTextContentEmpty)(t.isComposing(),!0))})},[d,y])}function iS(y){let{editor:d,cancelAddComment:g,submitAddComment:t}=y;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),s=(0,Gt.useRef)(null),i=(0,Gt.useMemo)(()=>({container:document.createElement("div"),elements:[]}),[]),l=(0,Gt.useRef)(null),o=B0(),a=(0,Gt.useCallback)(()=>{d.getEditorState().read(()=>{const u=(0,ye.$getSelection)();if((0,ye.$isRangeSelection)(u)){l.current=u.clone();const h=u.anchor,p=u.focus,m=(0,xa.createDOMRange)(d,h.getNode(),h.offset,p.getNode(),p.offset),b=s.current;if(m!==null&&b!==null){const{left:_,bottom:v,width:w}=m.getBoundingClientRect(),x=(0,xa.createRectsFromDOMRange)(d,m);let S=x.length===1?_+w/2-125:_-125;S<10&&(S=10),b.style.left=`${S}px`,b.style.top=`${v+20+(window.pageYOffset||document.documentElement.scrollTop)}px`;const E=x.length,{container:k}=i,D=i.elements,N=D.length;for(let O=0;O<E;O++){const R=x[O];let A=D[O];A===void 0&&(A=document.createElement("span"),D[O]=A,k.appendChild(A));const z="255, 212, 0",H=`position:absolute;top:${R.top+(window.pageYOffset||document.documentElement.scrollTop)}px;left:${R.left}px;height:${R.height}px;width:${R.width}px;background-color:rgba(${z}, 0.3);pointer-events:none;z-index:5;`;A.style.cssText=H}for(let O=N-1;O>=E;O--){const R=D[O];k.removeChild(R),D.pop()}}}})},[d,i]);A0(()=>{a();const u=i.container,h=document.body;if(h!==null)return h.appendChild(u),()=>{h.removeChild(u)}},[i.container,a]),(0,Gt.useEffect)(()=>(window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}),[a]);const c=M0(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:s},Gt.createElement(R0,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:u=>(u.preventDefault(),g(),!0),onChange:c}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement(zi,{onClick:g,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement(zi,{onClick:()=>{if(n){let u=d.getEditorState().read(()=>{const h=l.current;return h?h.getTextContent():""});u.length>100&&(u=u.slice(0,99)+"…"),t(eS(u,[I0(f,o)]),!0,void 0,l.current),l.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function aS(y){let{submitAddComment:d,thread:g,placeholder:t}=y;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),s=(0,Gt.useRef)(null),i=B0(),l=M0(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(R0,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:l,editorRef:s,placeholder:t}),Gt.createElement(zi,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){d(I0(f,i),!1,g);const o=s.current;o!==null&&o.dispatchCommand(ye.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(Xw,null)))}function D0(y){let{commentOrThread:d,deleteCommentOrThread:g,onClose:t,thread:f}=y;return Gt.createElement(Gt.Fragment,null,"Are you sure you want to delete this ",d.type,"?",Gt.createElement("div",{className:"Modal__content"},Gt.createElement(zi,{onClick:()=>{g(d,f),t()}},"Delete")," ",Gt.createElement(zi,{onClick:()=>{t()}},"Cancel")))}function L0(y){let{comment:d,deleteComment:g,thread:t,rtf:f}=y;const r=Math.round((d.timeStamp-performance.now())/1e3),n=Math.round(r/60),[e,s]=N0();return Gt.createElement("li",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment"},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Details"},Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Author"},d.author),Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Time"},"· ",r>-10?"Just now":f.format(n,"minute"))),Gt.createElement("p",{className:d.deleted?"CodoxCommentPlugin_CommentsPanel_DeletedComment":""},d.content),!d.deleted&&Gt.createElement(Gt.Fragment,null,Gt.createElement(zi,{onClick:()=>{s("Delete Comment",i=>Gt.createElement(D0,{commentOrThread:d,deleteCommentOrThread:g,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(P0,null)),e))}function sS(y){let{activeIDs:d,comments:g,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=y;const[e]=(0,Li.useLexicalComposerContext)(),[s,i]=(0,Gt.useState)(0),[l,o]=N0(),a=(0,Gt.useMemo)(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return(0,Gt.useEffect)(()=>{const c=setTimeout(()=>{i(s+1)},1e4);return()=>{clearTimeout(c)}},[s]),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List",ref:f},g.map(c=>{const u=c.codoxId;if(!u)return null;if(c.type==="thread"){const h=()=>{if(n.get(u)!==void 0&&(d===null||d.indexOf(u)===-1)){const p=document.activeElement;e.update(()=>{(0,ye.$setSelection)(null)},{onUpdate(){p!==null&&p.focus()}})}};return Gt.createElement("li",{key:u,onClick:h,className:`CodoxCommentPlugin_CommentsPanel_List_Thread ${n.has(u)?"interactive":""} ${d.indexOf(u)===-1?"":"active"}`},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_QuoteBox"},Gt.createElement("blockquote",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Quote"},"> ",Gt.createElement("span",null,c.quote)),Gt.createElement(zi,{onClick:()=>{o("Delete Thread",p=>Gt.createElement(D0,{commentOrThread:c,deleteCommentOrThread:t,onClose:p}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(P0,null)),l),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},c.comments.map(p=>Gt.createElement(L0,{key:p.codoxId,comment:p,deleteComment:t,thread:c,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(aS,{submitAddComment:r,thread:c,placeholder:"Reply to comment..."})))}return Gt.createElement(L0,{key:u,comment:c,deleteComment:t,rtf:a})}))}function lS(y){let{activeIDs:d,deleteCommentOrThread:g,comments:t,submitAddComment:f,markNodeMap:r}=y;const n=(0,Gt.useRef)(null),e=t.length===0;return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel"},Gt.createElement("h2",{className:"CodoxCommentPlugin_CommentsPanel_Heading"},"Comments"),e?Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_Empty"},"No Comments"):Gt.createElement(sS,{activeIDs:d,comments:t,deleteCommentOrThread:g,listRef:n,submitAddComment:f,markNodeMap:r}))}function B0(){const y=(0,g0.useCollaborationContext)(),{yjsDocMap:d,name:g}=y;return g||"Playground User"}function cS(y){const[d]=(0,Li.useLexicalComposerContext)(),g=J_(),t=(0,Gt.useMemo)(()=>new Map,[]),[f,r]=(0,Gt.useState)(),[n,e]=(0,Gt.useState)([]),[s,i]=(0,Gt.useState)(!1),[l,o]=(0,Gt.useState)(!1);(0,Gt.useEffect)(()=>{!g.length&&l?o(!1):g.length},[g]);const a=(0,Gt.useCallback)(()=>{d.update(()=>{const h=(0,ye.$getSelection)();h!==null&&(h.dirty=!0)}),i(!1)},[d]),c=(0,Gt.useCallback)((h,p)=>{if(h.type==="comment"){if(le.log("[deleteCommentOrThread]: type comment new values",{comment:h,thread:p,markNodeMap:t}),Sn.removeComment(p.codoxId,h.codoxId),!p)return;const m=p.codoxId,b=t.get(m);d.update(()=>{b?b.forEach((_,v)=>{const w=(0,ye.$getNodeByKey)(v);le.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:w}),w&&w.markDirty()}):(0,ye.$getRoot)().markDirty(),(0,ye.$addUpdateTag)(Xr.historic),(0,ye.$addUpdateTag)(Ll)})}else{le.log("[deleteCommentOrThread]: type thread new values",{comment:h,markNodeMap:t});const m=p!==void 0?p.codoxId:h.codoxId,b=t.get(m);setTimeout(()=>{d.update(()=>{if(b)for(const _ of b){const v=(0,ye.$getNodeByKey)(_);le.log("[deleteCommentOrThread]: type thread new values",{node:v}),(0,Qr.$isMarkNode)(v)&&(v.deleteID(m),v.getIDs().length===0&&(0,Qr.$unwrapMarkNode)(v))}else(0,ye.$getRoot)().markDirty(),le.debug("[deleteCommentOrThread][refreshComments]");Sn.refreshComments(!0),(0,ye.$addUpdateTag)(Ll)})})}},[d,t]),u=(0,Gt.useCallback)((h,p,m,b)=>{if(le.log("[submitAddComment]: new values",{commentOrThread:h,isInlineComment:p,thread:m,markNodeMap:t}),m?Sn.addComment(m.codoxId,h):Sn.addCommentThread(h),p)d.update(()=>{if((0,ye.$isRangeSelection)(b)){const _=b.isBackward(),v=h.codoxId;(0,Qr.$wrapSelectionInMarkNode)(b,_,v),(0,ye.$addUpdateTag)(Ll)}}),i(!1);else if(!p&&m){const _=m.codoxId,v=t.get(_);if(!v)return void Sn.removeComment(m.codoxId,h.codoxId);d.update(()=>{v.forEach((w,x)=>{let S=(0,ye.$getNodeByKey)(x);S&&S.markDirty()}),(0,ye.$addUpdateTag)(Xr.historic),(0,ye.$addUpdateTag)(Ll)})}},[d]);return(0,Gt.useEffect)(()=>{const h=[];for(let p=0;p<n.length;p++){const m=n[p],b=t.get(m);if(b!==void 0)for(const _ of b){const v=d.getElementByKey(_);v!==null&&(v.classList.add("selected"),h.push(v),o(!0))}}return()=>{for(let p=0;p<h.length;p++)h[p].classList.remove("selected")}},[n,d,t]),(0,Gt.useEffect)(()=>{const h=new Map;return(0,vs.mergeRegister)((0,vs.registerNestedElementResolver)(d,Qr.MarkNode,p=>(0,Qr.$createMarkNode)(p.getIDs()),(p,m)=>{p.getIDs().forEach(b=>{m.addID(b)})}),d.registerMutationListener(Qr.MarkNode,p=>{d.getEditorState().read(()=>{for(const[m,b]of p){const _=(0,ye.$getNodeByKey)(m);let v=[];b==="destroyed"?v=h.get(m)||[]:(0,Qr.$isMarkNode)(_)&&(v=_.getIDs());for(let w=0;w<v.length;w++){const x=v[w];let S=t.get(x);h.set(m,v),b==="destroyed"?S!==void 0&&(S.delete(m),S.size===0&&t.delete(x)):(S===void 0&&(S=new Set,t.set(x,S)),S.has(m)||S.add(m))}}})}),d.registerUpdateListener(p=>{let{editorState:m,tags:b}=p;m.read(()=>{const _=(0,ye.$getSelection)();let v=!1,w=!1;if((0,ye.$isRangeSelection)(_)){const x=_.anchor.getNode();if((0,ye.$isTextNode)(x)){const S=(0,Qr.$getMarkIDs)(x,_.anchor.offset);S!==null&&(e(S),v=!0),_.isCollapsed()||(r(x.getKey()),w=!0)}}v||e(x=>x.length===0?x:[]),w||r(null),(0,ye.$isRangeSelection)(_)&&i(!1)})}),d.registerCommand(Lf,()=>{const p=window.getSelection();return p!==null&&p.removeAllRanges(),i(!0),!0},ye.COMMAND_PRIORITY_EDITOR))},[d,t]),Gt.createElement(Gt.Fragment,null,s&&(0,Ts.createPortal)(Gt.createElement(iS,{editor:d,cancelAddComment:a,submitAddComment:u}),document.body),f!=null&&!s&&(0,Ts.createPortal)(Gt.createElement(nS,{anchorKey:f,editor:d,onAddComment:()=>{d.dispatchCommand(Lf,void 0)}}),document.body),(0,Ts.createPortal)(Gt.createElement(zi,{className:"CodoxCommentPlugin_ShowCommentsButton "+(l?"active":""),onClick:()=>o(!l),title:l?"Hide Comments":"Show Comments"},Gt.createElement(tS,null)),document.body),l&&(0,Ts.createPortal)(Gt.createElement(lS,{comments:g,submitAddComment:u,deleteCommentOrThread:c,activeIDs:n,markNodeMap:t}),document.body))}var Ou=rn(766),Rs={};Rs.styleTagTransform=ri(),Rs.setAttributes=ei(),Rs.insert=ti().bind(null,"head"),Rs.domAPI=Xo(),Rs.insertStyleElement=ni(),Qo()(Ou.A,Rs),Ou.A&&Ou.A.locals&&Ou.A.locals;var Tu=rn(225),Ms={};Ms.styleTagTransform=ri(),Ms.setAttributes=ei(),Ms.insert=ti().bind(null,"head"),Ms.domAPI=Xo(),Ms.insertStyleElement=ni(),Qo()(Tu.A,Ms),Tu.A&&Tu.A.locals&&Tu.A.locals;function uS(y){let{label:d,value:g,onChange:t,placeholder:f="","data-test-id":r,type:n="text"}=y;return Gt.createElement("div",{className:"CodoxInput__wrapper"},Gt.createElement("label",{className:"CodoxInput__label"},d),Gt.createElement("input",{type:n,className:"CodoxInput__input",placeholder:f,value:g,onChange:e=>{t(e.target.value)},"data-test-id":r}))}function F0(y,d){var g=Object.keys(y);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(y);d&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(y,f).enumerable})),g.push.apply(g,t)}return g}function ju(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?F0(Object(g),!0).forEach(function(t){dS(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):F0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function dS(y,d,g){return(d=fS(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function fS(y){var d=pS(y,"string");return typeof d=="symbol"?d:d+""}function pS(y,d){if(typeof y!="object"||!y)return y;var g=y[Symbol.toPrimitive];if(g!==void 0){var t=g.call(y,d||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(y)}let Ul=!1;const hS=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],$l=214,z0=150;function gS(y){let{color:d,onChange:g}=y;const[t,f]=(0,Gt.useState)(Ds("hex",d)),[r,n]=(0,Gt.useState)(d),e=(0,Gt.useRef)(null),s=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*$l,y:(100-t.hsv.v)/100*z0}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*$l}),[t.hsv]);return(0,Gt.useEffect)(()=>{e.current!==null&&g&&n(t.hex)},[t,g]),(0,Gt.useEffect)(()=>{if(d===void 0)return;const l=Ds("hex",d);f(l),n(l.hex)},[d]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:$l},ref:e},Gt.createElement(uS,{label:"Hex",onChange:l=>{if(n(l),/^#[0-9A-Fa-f]{6}$/i.test(l)){const o=Ds("hex",l);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},hS.map(l=>Gt.createElement("button",{className:l===t.hex?" active":"",key:l,style:{backgroundColor:l},onClick:()=>(o=>{n(o);let a=Ds("hex",o);f(a),g(a.hex,Ul)})(l)}))),Gt.createElement(U0,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:l=>{let{x:o,y:a}=l;const c=Ds("hsv",ju(ju({},t.hsv),{},{s:o/$l*100,v:100-a/z0*100}));f(c),n(c.hex),g(c.hex,Ul)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:s.x,top:s.y}})),Gt.createElement(U0,{className:"codox-color-picker-hue",onChange:l=>{let{x:o}=l;const a=Ds("hsv",ju(ju({},t.hsv),{},{h:o/$l*360}));f(a),n(a.hex),g(a.hex,Ul)}},Gt.createElement("div",{className:"codox-color-picker-hue_cursor",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`,left:i.x}})),Gt.createElement("div",{className:"codox-color-picker-color",style:{backgroundColor:t.hex}}))}function U0(y){let{className:d,style:g,onChange:t,children:f}=y;const r=(0,Gt.useRef)(null),n=(0,Gt.useRef)(!1),e=s=>{if(r.current){const{current:i}=r,{width:l,height:o,left:a,top:c}=i.getBoundingClientRect(),u=$0(s.clientX-a,l,0),h=$0(s.clientY-c,o,0);t({x:u,y:h})}};return Gt.createElement("div",{ref:r,className:d,style:g,onMouseDown:s=>{if(s.button!==0)return;e(s);const i=o=>{n.current=!0,Ul=!0,e(o)},l=o=>{n.current&&(Ul=!1),document.removeEventListener("mousemove",i,!1),document.removeEventListener("mouseup",l,!1),e(o),n.current=!1};document.addEventListener("mousemove",i,!1),document.addEventListener("mouseup",l,!1)}},f)}function $0(y,d,g){return y>d?d:y<g?g:y}function H0(y){if(!y.startsWith("#")){const d=document.createElement("canvas").getContext("2d");if(!d)throw new Error("2d context not supported or canvas already initialized");return d.fillStyle=y,d.fillStyle}return y.length===4||y.length===5?y=y.split("").map((d,g)=>g?d+d:"#").join(""):y.length===7||y.length===9?y:"#000000"}function q0(y){const d=(y.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(g,t,f,r)=>"#"+t+t+f+f+r+r).substring(1).match(/.{2}/g)||[]).map(g=>parseInt(g,16));return{b:d[2],g:d[1],r:d[0]}}function Kf(y){let{r:d,g,b:t}=y;d/=255,g/=255,t/=255;const f=Math.max(d,g,t),r=f-Math.min(d,g,t);return{h:r?60*(f===d?(g-t)/r+(g<t?6:0):f===g?2+(t-d)/r:4+(d-g)/r):0,s:f?r/f*100:0,v:100*f}}function mS(y){let{h:d,s:g,v:t}=y;g/=100,t/=100;const f=~~(d/60),r=d/60-f,n=t*(1-g),e=t*(1-g*r),s=t*(1-g*(1-r)),i=f%6,l=Math.round(255*[t,e,n,n,s,t][i]),o=Math.round(255*[s,t,t,e,n,n][i]);return{b:Math.round(255*[n,n,s,t,t,e][i]),g:o,r:l}}function J0(y){let{b:d,g,r:t}=y;return"#"+[t,g,d].map(f=>f.toString(16).padStart(2,"0")).join("")}function Ds(y,d){let g=H0("#121212"),t=q0(g),f=Kf(t);return y==="hex"?(g=H0(d),t=q0(g),f=Kf(t)):y==="rgb"?(t=d,g=J0(t),f=Kf(t)):y==="hsv"&&(f=d,t=mS(f),g=J0(t)),{hex:g,hsv:f,rgb:t}}const yS=Gt.createContext(null),W0=4;function bS(y){let{children:d,dropDownRef:g,onClose:t,dropdownClassName:f}=y;const[r,n]=(0,Gt.useState)(),[e,s]=(0,Gt.useState)(),i=(0,Gt.useCallback)(o=>{n(a=>a?[...a,o]:[o])},[n]),l=(0,Gt.useMemo)(()=>({registerItem:i}),[i]);return(0,Gt.useEffect)(()=>{r&&!e&&s(r[0]),e&&e.current&&e.current.focus()},[r,e]),Gt.createElement(yS.Provider,{value:l},Gt.createElement("div",{className:f,ref:g,onKeyDown:o=>{if(!r)return;const a=o.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(a)&&o.preventDefault(),a==="Escape"||a==="Tab"?t():a==="ArrowUp"?s(c=>{if(!c)return r[0];const u=r.indexOf(c)-1;return r[u===-1?r.length-1:u]}):a==="ArrowDown"&&s(c=>c?r[r.indexOf(c)+1]:r[0])}},d))}function vS(y){let{disabled:d=!1,buttonLabel:g,buttonAriaLabel:t,buttonClassName:f,buttonIconClassName:r,children:n,stopCloseOnClickSelf:e,dropdownClassName:s,buttonLabelClassName:i,dropdownChevronClassName:l}=y;const o=(0,Gt.useRef)(null),a=(0,Gt.useRef)(null),[c,u]=(0,Gt.useState)(!1);return(0,Gt.useEffect)(()=>{const h=a.current,p=o.current;if(c&&h!==null&&p!==null){const{top:m,left:b}=h.getBoundingClientRect();p.style.top=`${m+h.offsetHeight+W0}px`,p.style.left=`${Math.min(b,window.innerWidth-p.offsetWidth-20)}px`}},[o,a,c]),(0,Gt.useEffect)(()=>{const h=a.current;if(h!==null&&c){const p=m=>{const b=m.target;e&&o.current&&o.current.contains(b)||h.contains(b)||u(!1)};return document.addEventListener("click",p),()=>{document.removeEventListener("click",p)}}},[o,a,c,e]),(0,Gt.useEffect)(()=>{const h=()=>{if(c){const p=a.current,m=o.current;if(p!==null&&m!==null){const{top:b}=p.getBoundingClientRect(),_=b+p.offsetHeight+W0;_!==m.getBoundingClientRect().top&&(m.style.top=`${_}px`)}}};return document.addEventListener("scroll",h),()=>{document.removeEventListener("scroll",h)}},[a,o,c]),Gt.createElement(Gt.Fragment,null,Gt.createElement("button",{type:"button",disabled:d,"aria-label":t||g,className:f,onClick:()=>u(!c),ref:a},r&&Gt.createElement("span",{className:r}),g&&Gt.createElement("span",{className:i},g),Gt.createElement("i",{className:l})),c&&(0,Ts.createPortal)(Gt.createElement(bS,{dropDownRef:o,onClose:()=>{u(!1),a&&a.current&&a.current.focus()},dropdownClassName:s},n),document.body))}const _S=["disabled","stopCloseOnClickSelf","color","onChange"];function Gf(){return Gf=Object.assign?Object.assign.bind():function(y){for(var d=1;d<arguments.length;d++){var g=arguments[d];for(var t in g)({}).hasOwnProperty.call(g,t)&&(y[t]=g[t])}return y},Gf.apply(null,arguments)}function xS(y,d){if(y==null)return{};var g,t,f=wS(y,d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(y);for(t=0;t<r.length;t++)g=r[t],d.indexOf(g)>=0||{}.propertyIsEnumerable.call(y,g)&&(f[g]=y[g])}return f}function wS(y,d){if(y==null)return{};var g={};for(var t in y)if({}.hasOwnProperty.call(y,t)){if(d.indexOf(t)>=0)continue;g[t]=y[t]}return g}function V0(y){let{disabled:d=!1,stopCloseOnClickSelf:g=!0,color:t,onChange:f}=y,r=xS(y,_S);return Gt.createElement(vS,Gf({},r,{disabled:d,stopCloseOnClickSelf:g}),Gt.createElement(gS,{color:t,onChange:f}))}const SS=y=>{let{onColorChange:d,buttonClassName:g,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=y;const[i]=(0,Li.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,c]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,vs.mergeRegister)(i.registerEditableListener(h=>{o(h)}),i.registerUpdateListener(h=>{let{editorState:p}=h;p.read(()=>{const m=(0,ye.$getSelection)();if((0,ye.$isRangeSelection)(m)){let b=(0,xa.$getSelectionStyleValueForProperty)(m,"color");b!==a&&(c(b||""),d(b))}})})),[i]);const u=(0,Gt.useCallback)((h,p)=>{i.update(()=>{const m=(0,ye.$getSelection)();m!==null&&(0,xa.$patchStyleText)(m,{color:h})})},[i]);return Gt.createElement(V0,{disabled:!l,color:a,onChange:u,buttonClassName:g||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},CS=SS,ES=y=>{let{onColorChange:d,buttonClassName:g,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=y;const[i]=(0,Li.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,c]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,vs.mergeRegister)(i.registerEditableListener(h=>{o(h)}),i.registerUpdateListener(h=>{let{editorState:p}=h;p.read(()=>{const m=(0,ye.$getSelection)();if((0,ye.$isRangeSelection)(m)){let b=(0,xa.$getSelectionStyleValueForProperty)(m,"background-color");b!==a&&(c(b||""),d(b))}})})),[i]);const u=(0,Gt.useCallback)((h,p)=>{i.update(()=>{const m=(0,ye.$getSelection)();m!==null&&(0,xa.$patchStyleText)(m,{"background-color":h})})},[i]);return Gt.createElement(V0,{disabled:!l,color:a,onChange:u,buttonClassName:g||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},kS=ES;var OS=Ii.yy;Ii._U,Ii.a8,Ii.Vs,Ii.Cn;var TS=Ii.gK,jS=Ii.vv;function AS(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var Au=AS(function(y){const d=new URLSearchParams;d.append("code",y);for(let g=1;g<arguments.length;g++)d.append("v",arguments[g]);throw Error(`Minified Lexical error #${y}; visit https://lexical.dev/docs/error?${d} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function NS({hasCellMerge:y=!0,hasCellBackgroundColor:d=!0,hasTabHandler:g=!0}){const[t]=Tr();return Fe.useEffect(()=>(t.hasNodes([To,Oo,ba])||Au(10),ko(t.registerCommand(M1,({columns:f,rows:r,includeHeaders:n})=>{const e=Tm(Number(r),Number(f),n);tm(e);const s=e.getFirstDescendant();return Pe(s)&&s.select(),!0},an),t.registerNodeTransform(To,f=>{const[r]=jm(f,null,null),n=r.reduce((e,s)=>Math.max(e,s.length),0);for(let e=0;e<r.length;++e){const s=r[e].length;if(s===n)continue;const i=r[e][s-1].cell;for(let l=s;l<n;++l){const o=hs(0);o.append(Qn()),i!==null?i.insertAfter(o):em(i,o)}}}))),[t]),Fe.useEffect(()=>{const f=new Map,r=e=>{const s=e.getKey(),i=t.getElementByKey(s);if(i&&!f.has(s)){const l=q1(e,i,t,g);f.set(s,l)}};t.getEditorState().read(()=>{const e=Hh(To);for(const s of e)Jn(s)&&r(s)});const n=t.registerMutationListener(To,e=>{for(const[s,i]of e)if(i==="created")t.getEditorState().read(()=>{const l=Hn(s);Jn(l)&&r(l)});else if(i==="destroyed"){const l=f.get(s);l!==void 0&&(l.removeListeners(),f.delete(s))}});return()=>{n();for(const[,e]of f)e.removeListeners()}},[t,g]),Fe.useEffect(()=>{if(!y)return t.registerNodeTransform(Oo,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=ms(f),[n]=gs(r,f,f),e=n.length,s=n[0].length;let i=r.getFirstChild();Mr(i)||Au(175);const l=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),Mr(i)||Au(175));let a=null;for(let c=0;c<s;c++){const u=n[o][c],h=u.cell;if(u.startRow===o&&u.startColumn===c)a=h,l.push(h);else if(h.getColSpan()>1||h.getRowSpan()>1){on(h)||Au(176);const p=hs(h.__headerState);a!==null?a.insertAfter(p):em(i,p)}}}for(const o of l)o.setColSpan(1),o.setRowSpan(1)}})},[t,y]),Fe.useEffect(()=>{if(!d)return t.registerNodeTransform(Oo,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,d,y]),null}const PS={code:"editor-code",heading:{h1:"editor-heading-h1",h2:"editor-heading-h2",h3:"editor-heading-h3",h4:"editor-heading-h4",h5:"editor-heading-h5"},image:"editor-image",link:"editor-link",list:{listitem:"editor-listitem",nested:{listitem:"editor-nested-listitem"},ol:"editor-list-ol",ul:"editor-list-ul"},ltr:"ltr",paragraph:"editor-paragraph",placeholder:"editor-placeholder",quote:"editor-quote",rtl:"rtl",text:{bold:"editor-text-bold",code:"editor-text-code",hashtag:"editor-text-hashtag",italic:"editor-text-italic",overflowed:"editor-text-overflowed",strikethrough:"editor-text-strikethrough",underline:"editor-text-underline",underlineStrikethrough:"editor-text-underlineStrikethrough"},table:"PlaygroundEditorTheme__table",tableAddColumns:"PlaygroundEditorTheme__tableAddColumns",tableAddRows:"PlaygroundEditorTheme__tableAddRows",tableCell:"PlaygroundEditorTheme__tableCell",tableCellActionButton:"PlaygroundEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"PlaygroundEditorTheme__tableCellActionButtonContainer",tableCellEditing:"PlaygroundEditorTheme__tableCellEditing",tableCellHeader:"PlaygroundEditorTheme__tableCellHeader",tableCellPrimarySelected:"PlaygroundEditorTheme__tableCellPrimarySelected",tableCellResizer:"PlaygroundEditorTheme__tableCellResizer",tableCellSelected:"PlaygroundEditorTheme__tableCellSelected",tableCellSortedIndicator:"PlaygroundEditorTheme__tableCellSortedIndicator",tableResizeRuler:"PlaygroundEditorTheme__tableCellResizeRuler",tableSelected:"PlaygroundEditorTheme__tableSelected",tableSelection:"PlaygroundEditorTheme__tableSelection"},IS="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",RS="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",MS="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik00IDEySDIwTTEyIDRWMjAiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4NCjwvc3ZnPg==",DS="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik02IDEyTDE4IDEyIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+DQo8L3N2Zz4=",Ca=8,Ea=72,LS=15;function BS({selectionFontSize:y,disabled:d,editor:g}){const[t,f]=Yn.useState(y),[r,n]=Yn.useState(!1);Yn.useState(!1);const e=(c,u)=>{if(!u)return c;let h=c;switch(u){case 2:switch(!0){case c>Ea:h=Ea;break;case c>=48:h-=12;break;case c>=24:h-=4;break;case c>=14:h-=2;break;case c>=9:h-=1;break;default:h=Ca;break}break;case 1:switch(!0){case c<Ca:h=Ca;break;case c<12:h+=1;break;case c<20:h+=2;break;case c<36:h+=4;break;case c<=60:h+=12;break;default:h=Ea;break}break}return h},s=Yn.useCallback((c,u)=>{const h=p=>(p||(p=`${LS}px`),p=p.slice(0,-2),`${e(Number(p),u)}px`);g.update(()=>{if(g.isEditable()){const p=je();p!==null&&Gg(p,{"font-size":c||h})}})},[g]),i=c=>{const u=Number(t);if(c.key!=="Tab"){if(["e","E","+","-"].includes(c.key)||isNaN(u)){c.preventDefault(),f("");return}n(!0),(c.key==="Enter"||c.key==="Escape")&&(c.preventDefault(),a(u))}},l=()=>{if(t!==""&&r){const c=Number(t);a(c)}},o=c=>{if(t!==""){const u=e(Number(t),c);s(String(u)+"px",null)}else s(null,c)},a=c=>{let u=c;c>Ea?u=Ea:c<Ca&&(u=Ca),f(String(u)),s(String(u)+"px",null),n(!1)};return Yn.useEffect(()=>{f(y)},[y]),Se.jsxs(Se.Fragment,{children:[Se.jsx("button",{type:"button",disabled:d||y!==""&&Number(t)<=Ca,onClick:()=>o(2),className:"toolbar-item font-decrement",children:Se.jsx("img",{src:DS,height:16,width:16,style:{marginTop:"5px"}})}),Se.jsx("input",{type:"number",value:t,disabled:d,className:"toolbar-item font-size-input",min:Ca,max:Ea,onChange:c=>f(c.target.value),onKeyDown:i,onBlur:l}),Se.jsx("button",{type:"button",disabled:d||y!==""&&Number(t)>=Ea,onClick:()=>o(1),className:"toolbar-item font-increment",children:Se.jsx("img",{src:MS,height:16,width:16,style:{marginTop:"5px"}})}),Se.jsx("div",{children:Se.jsx("div",{className:"symbol-dropdown",children:Se.jsxs("select",{name:"cars",id:"cars",children:[Se.jsx("option",{value:"Heading 1",children:"Heading 1"}),Se.jsx("option",{value:"Heading 2",children:"Heading 2"}),Se.jsx("option",{value:"Heading 3",children:"heading 3"})]})})})]})}const FS="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function zS(){const[y,d]=Fe.useState(""),[g,t]=Fe.useState(""),[f,r]=Fe.useState(!1),[n]=Tr(),e=()=>{!y||!g||(n.update(()=>{const s=Tm(y,g,!0);tm(s)}),r(!1))};return Se.jsxs(Se.Fragment,{children:[Se.jsx("button",{className:"toolbar-item ",onClick:()=>r(!0),children:Se.jsx("img",{className:"add-toolbar-table-icon",src:FS,alt:"Add Table"})}),f&&Se.jsx("div",{className:"modal-overlay",children:Se.jsxs("div",{className:"modal-content",children:[Se.jsx("h3",{children:"Select Table Dimensions"}),Se.jsx("div",{className:"select-table-container",children:Se.jsx("input",{type:"number",value:y,onChange:s=>d(Number(s.target.value)),placeholder:"Rows"})}),Se.jsx("div",{className:"select-table-container",children:Se.jsx("input",{type:"number",value:g,onChange:s=>t(Number(s.target.value)),placeholder:"Columns"})}),Se.jsx("div",{children:Se.jsxs("div",{className:"modal-buttons",children:[Se.jsx("button",{className:"toolbar-item",onClick:e,children:"Add"}),Se.jsx("button",{className:"toolbar-item",onClick:()=>r(!1),children:"Cancel"})]})})]})})]})}const US="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",$S=[{letter:"",uppercase:"A",lowercase:"α"},{letter:"Beta",uppercase:"Β",lowercase:"β"},{letter:"Gamma",uppercase:"Γ",lowercase:"γ"},{letter:"Delta",uppercase:"Δ",lowercase:"δ"},{letter:"Epsilon",uppercase:"Ε",lowercase:"ε"},{letter:"Zeta",uppercase:"Ζ",lowercase:"ζ"},{letter:" Eta ",uppercase:"Η",lowercase:"η"},{letter:"Theta",uppercase:"Θ",lowercase:"θ"},{letter:"Iota",uppercase:"Ι",lowercase:"ι"},{letter:"Kappa",uppercase:"Κ",lowercase:"κ"}];function HS(){const[y]=Tr(),[d,g]=Fe.useState(!1),t=f=>{y.update(()=>{var n;const r=je();if(_e(r)){const e=r.anchor.getNode();let s="inherit";if(e instanceof ki){const l=e.getStyle();s=((n=l==null?void 0:l.match(/font-size:\s*(\S+);/))==null?void 0:n[1])||s}const i=Zn(f);r.insertNodes([i])}}),g(!1)};return Se.jsxs("div",{children:[Se.jsx("button",{className:"toolbar-item symbols-toolbar",onClick:()=>g(!d),children:"Symbols"}),d&&Se.jsx("div",{className:"modal-overlay",children:Se.jsxs("div",{className:"modal-content-symb",children:[Se.jsx("div",{className:"symbol-Flex-container",children:$S.map(({letter:f,uppercase:r,lowercase:n})=>Se.jsxs("div",{className:"symbol-items",children:[Se.jsx("button",{onClick:()=>t(n),children:n}),Se.jsx("button",{onClick:()=>t(r),children:r})]},f))}),Se.jsx("button",{className:"toolbar-item close-btn",onClick:()=>g(!1),children:Se.jsx("img",{src:US,width:16,height:16})})]})})]})}const Yf=1;function Zf(){return Se.jsx("div",{className:"divider"})}function qS(){const[y]=Tr(),d=Fe.useRef(null),[g,t]=Fe.useState(!1),[f,r]=Fe.useState(!1),[n,e]=Fe.useState(!1),[s,i]=Fe.useState(!1),[l,o]=Fe.useState(!1),[a,c]=Fe.useState(!1),[u,h]=Fe.useState(!1),[p,m]=Fe.useState(!1),[b,_]=Fe.useState("11px"),[v,w]=Fe.useState(()=>y.isEditable()),x=Fe.useCallback(()=>{const S=je();_e(S)&&(e(S.hasFormat("bold")),i(S.hasFormat("italic")),o(S.hasFormat("underline")),c(S.hasFormat("strikethrough")),h(S.hasFormat("subscript")),m(S.hasFormat("superscript")),_(Yg(S,"font-size","11px")))},[]);return Fe.useEffect(()=>ko(y.registerUpdateListener(({editorState:S})=>{S.read(()=>{x()})}),y.registerCommand(qo,(S,E)=>(x(),!1),Yf),y.registerCommand(Xa,S=>(t(S),!1),Yf),y.registerCommand(Qa,S=>(r(S),!1),Yf)),[y,x]),Se.jsxs("div",{className:"toolbar",ref:d,children:[Se.jsx("button",{disabled:!g,onClick:()=>{y.dispatchCommand(cl,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:Se.jsx("i",{className:"format undo"})}),Se.jsx("button",{disabled:!f,onClick:()=>{y.dispatchCommand(ul,void 0)},className:"toolbar-item","aria-label":"Redo",children:Se.jsx("i",{className:"format redo"})}),Se.jsx(Zf,{}),Se.jsx(BS,{selectionFontSize:b.slice(0,-2),editor:y,disabled:!v}),Se.jsx(Zf,{}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"bold")},className:"toolbar-item spaced "+(n?"active":""),"aria-label":"Format Bold",children:Se.jsx("i",{className:"format bold"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"italic")},className:"toolbar-item spaced "+(s?"active":""),"aria-label":"Format Italics",children:Se.jsx("i",{className:"format italic"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"underline")},className:"toolbar-item spaced "+(l?"active":""),"aria-label":"Format Underline",children:Se.jsx("i",{className:"format underline"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"strikethrough")},className:"toolbar-item spaced "+(a?"active":""),"aria-label":"Format Strikethrough",children:Se.jsx("i",{className:"format strikethrough"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"superscript")},className:"toolbar-item spaced "+(p?"active":""),"aria-label":"Format SuperScript",children:Se.jsx("img",{src:RS,height:16,width:16,style:{marginTop:"1px"}})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"subscript")},className:"toolbar-item spaced "+(u?"active":""),"aria-label":"Format SubScript",children:Se.jsx("img",{src:IS,height:16,width:16,style:{marginTop:"1px"}})}),Se.jsx(Zf,{}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Za,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:Se.jsx("i",{className:"format left-align"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Za,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:Se.jsx("i",{className:"format center-align"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Za,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:Se.jsx("i",{className:"format right-align"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Za,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:Se.jsx("i",{className:"format justify-align"})}),Se.jsx(zS,{}),Se.jsx(HS,{})," "]})}const Qf=TS([...[To,ba,Oo]]);function JS(){return Se.jsx("div",{className:"editor-placeholder"})}const WS={namespace:"React.js Demo",nodes:Qf,onError(y){throw y},theme:PS},VS=()=>Se.jsx(Se.Fragment,{children:"hello"});function KS({collabApiKey:y,spfList:d,userObj:g}){const[t,f]=Fe.useState(!1),[r,n]=Fe.useState([]),[e,s]=Fe.useState("demo_docId_1"),[i,l]=Fe.useState({root:null}),{userId:o,userName:a,userEmail:c}=g,u=Fe.useRef(),p={docId:e,apiKey:y,user:{name:a,id:o,email:c},hooks:{contentChanged:({source:w,content:x})=>{},usersUpdate:w=>{n(w)}}},m=()=>{u.current&&u.current.start(p).then(()=>{console.log("[Lexical Demo][codox.start] success"),f(!0)}).catch(w=>console.log("[Lexical Demo][codox.start] error",w))};Fe.useEffect(()=>()=>{b()},[]);const b=()=>{u.current&&(console.log("i am stop"),u.current.stop()),f(!1)};let _={root:{children:[{children:[],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,showUI:!0}],direction:"ltr",format:"",indent:0,type:"root",version:1}};Fe.useEffect(()=>{(async()=>{if(!e)return;t&&b();let w=_;if(w)try{jS(w,Qf),l(w)}catch(x){console.error("[APP] error: ",x)}})()},[e]),Fe.useEffect(()=>{i&&e&&!t&&m()},[i,e,t]),Fe.useMemo(()=>({editorState:i?JSON.stringify({root:i.root}):null,namespace:"Playground",nodes:Qf,onError:w=>{throw w},theme:{}}),[i]);const v=()=>{let w=[],x=[];return r&&r.length>0&&r.map((S,E)=>{x.includes(S.name)||(x.push(S.name),w.push(Se.jsxs("div",{title:S.email,className:`avatarStyle avatar-color-${E+1}`,children:[" ",S.name&&S.name[0]]})))}),Se.jsx("div",{className:"flexContainer",children:w})};return Se.jsx("div",{children:u&&Se.jsxs(Ug,{initialConfig:WS,children:[v(),Se.jsxs("div",{className:"editor-container",children:[Se.jsx(qS,{}),Se.jsxs("div",{className:"editor-inner",children:[Se.jsx(O1,{contentEditable:Se.jsx(Hg,{className:"editor-input"}),placeholder:Se.jsx(JS,{}),ErrorBoundary:VS}),Se.jsx(OS,{ref:u}),Se.jsx(om,{}),Se.jsx(NS,{}),Se.jsx($g,{})]})]})]})})}Ir.Editor=KS,Object.defineProperty(Ir,Symbol.toStringTag,{value:"Module"})});
|
|
1429
|
+
`,A.append(H),_=H}!R&&x.width<1&&r.length>1&&(A.style.width="3px")}b.forEach(w=>{this.hoverList.push([w,_,e])})});this.remoteSelections=[],this.isEditingInProgress=!1,this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelectionDOMsMap={},this.activeEditorsKeys={},this.keyboardBindedListener=this._keyboardEventsListener.bind(this),this.mouseBindedListener=this._mouseEventsListener.bind(this),this.resizeBindedListener=this._resizeEventListener.bind(this),this.hideInUI=!1}_mouseEventsListener(d){let g=!1,t=d.target,f=!1,r=3;for(;r&&t;){if(t.__codox_track){g=!0;break}if(t.__lexicalEditor){g=!0,f=!0;break}t=t.parentNode,r--}if(!g)return;let n=null;for(let i in this.activeEditorsKeys){if(t[`__lexicalKey_${i}`]){n=i;break}t.__lexicalEditor&&(n=t.__lexicalEditor._key)}if(!n)return;let e=f?"root":t[`__lexicalKey_${n}`];if(!e||!this.trackedNodesKeys.has(`${e}__${n}`))return;let s=new Set;for(let i=0;i<this.hoverList.length;i++){let l=this.hoverList[i],[o,a,c]=l;if(s.has(c))continue;let u=tr.isMousePositionWithinElementCords(d,o);d.type===vr.mouseover&&u&&(a.style.animation=this.isEditingInProgress?tr.tooltipAnimations.hideAtOnce:tr.tooltipAnimations.showAtOnce,s.add(c)),d.type===vr.mouseout&&(a.style.animation=tr.tooltipAnimations.hideWithDelay,s.add(c)),d.type===vr.mousemove&&u&&(a.style.animation=this.isEditingInProgress?tr.tooltipAnimations.hideAtOnce:tr.tooltipAnimations.showAtOnce,s.add(c))}}_keyboardEventsListener(d){d.type===vr.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),d.type===vr.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(d){xe.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(vr.keypress,this.keyboardBindedListener),window.addEventListener(vr.keyup,this.keyboardBindedListener),window.addEventListener(vr.resize,this.resizeBindedListener),window.addEventListener(vr.scroll,this.resizeBindedListener);for(const d of Km)window.addEventListener(d,this.mouseBindedListener)}unmount(){window.removeEventListener(vr.keypress,this.keyboardBindedListener),window.removeEventListener(vr.keyup,this.keyboardBindedListener),window.removeEventListener(vr.resize,this.resizeBindedListener),window.removeEventListener(vr.scroll,this.resizeBindedListener);for(const d of Km)window.removeEventListener(d,this.mouseBindedListener);this.gcPrevPaintedRemoteSelections()}shouldUpdateRemoteSelections(){return!0}gcPrevPaintedRemoteSelections(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];for(let g in this.remoteSelectionDOMsMap)this.remoteSelectionDOMsMap[g].remove();this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelections=d||[],this.remoteSelectionDOMsMap={},this.activeEditorsKeys={}}paintRemoteSelections(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];this.gcPrevPaintedRemoteSelections(d);let g=xe.getMainEditorState();g.read&&g.read(()=>{for(let t of this.remoteSelections)if(Ff.validateJSONSelection(t,Mf.remote))if($e.isNestedSelectionJSON(t)){let{nestedSelectionJSON:f,nestedEditor:r}=$e.getNestedSelectionJSONFromMainSelectionJSON(t);if(!r)continue;r.getEditorState().read(()=>{let n=$e.JSONToLexical(f);if(n)try{this.paintSingleRemoteSelection({editor:r,selectionJSON:t,lexicalSelection:n,selectedNodes:n.getNodes(),isBackward:n.isBackward()})}catch(e){le.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:e,nestedSelectionJSON:f,fullSelection:t,lexicalSelection:n})}else le.error("DEBUGGER: [paintRemoteSelections] nested selection from json to lexical is null: ",{selection:t,nestedSelectionJSON:f,lexicalSelection:n})})}else{let f=$e.JSONToLexical(t);if(!f){le.error("DEBUGGER: [paintRemoteSelections] selection from json to lexical is null: ",{selection:t,lexicalSelection:f});continue}try{this.paintSingleRemoteSelection({editor:xe.getMainEditor(),selectionJSON:t,lexicalSelection:f,selectedNodes:f.getNodes(),isBackward:f.isBackward()})}catch(r){le.warn("[PAINT REMOTE SELECTION] failed - ",{error:r,fullSelection:t,lexicalSelection:f})}}})}updateRemoteSelections(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";this.shouldUpdateRemoteSelections(d)&&(le.log("[updateRemoteSelections] "+g,{newRemoteSelections:d}),Promise.resolve().then(()=>{this.paintRemoteSelections(d),this.hideInUI&&this.hideRemoteSelectionsFromUI()}))}clear(){this.gcPrevPaintedRemoteSelections()}getCurrentRemoteSelections(){return this.remoteSelections}hideRemoteSelectionsFromUI(){this.hideInUI||(this.hideInUI=!0);const d=document.querySelectorAll(".codox_remote_selection");for(let g of d)g.classList.add("hidden_codox_remote_selection")}showHiddenRemoteSelectionsInUI(){this.hideInUI=!1;const d=document.querySelectorAll(".hidden_codox_remote_selection");for(let g of d)g.classList.remove("hidden_codox_remote_selection")}}const go=new Nx;function Px(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(y=>y===_a.editorState)}function bu(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,g=xe.getMainEditorNodesClassesMap();const{klass:t}=g.get(y.type)||{};if(!t)return;const f=t.importJSON(y);if(y.children&&y.children.length)for(const r of y.children)bu(r,f);return d&&d.getChildrenSize&&d.splice(d.getChildrenSize(),0,[f]),f}function vu(y){if(y.getChildren)for(let d of y.getChildren())vu(d);y.remove()}function f0(y){y.__parent=null,y.__next=null,y.__prev=null}function p0(y,d){return!!xe.isLexicalEditorInstance(y)&&!(typeof d!="object"||!d.editorState||(y.update(()=>{try{let g=(0,ye.$getSelection)();const t=y.parseEditorState(d.editorState);if(t.isEmpty())return(0,ye.$getRoot)().clear(),!0;(0,ye.$setSelection)(g),y.setEditorState(t)}catch(g){le.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",g)}}),0))}function Ix(y,d){let g=d;for(const t of y)g=g[t];return g}function wa(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,g=arguments.length>2&&arguments[2]!==void 0&&arguments[2],t=null,f=Ix(y,g?d:xe.getMainEditorState().toJSON());return f&&(t=Sa(f)?(0,ye.$getRoot)():Tn.get(f.codoxId)),t||le.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:f,lexicalNode:t,pathArray:y,currentStateJSON:xe.getMainEditorState().toJSON(),newStateJSON:d,codoxNodes:Tn.nodesToArray(),searchInNewState:g}),t||(g?t:wa(y,d,!0))}function h0(y){le.log("[applyFullLexicalStateReplace] clear current state and apply new");const d=(0,ye.$getRoot)();d.clear();let g=xe.getMainEditorNodesClassesMap();function t(f){const r=g.get(f.type).klass.importJSON(f);if(f.children)for(const n of f.children)r.append(t(n));return r}for(const f of y.root.children)d.append(t(f))}function Rx(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(d.length){le.log("[applyDeltasToLexicalState] Original Deltas: ",{newStateJSON:y,deltas:JSON.parse(JSON.stringify(d))});for(const g of d){let{p:t}=g;const f=t[t.length-1],r=f==="children",n=typeof f=="number",e=!n&&!r,s=Px(t),i=s!==-1,l=g.hasOwnProperty("lm")&&typeof g.lm=="number";if(t.length)if(i){let o=s-1,a=wa(t.slice(0,o),y);if(a){let c=t.slice(0,s),u=y;for(const p of c)u=u[p];let h=Dl(t[o]);p0(a.getWritable()[h],u)}}else{if(r){let o=g.oi;if(!o){le.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:g});continue}if(o.some(c=>!(!c.hasOwnProperty("text")||typeof c.text=="string"))){le.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:g});continue}t.length=t.length-1;let a=wa(t,y);if(!a)continue;if(o.some(c=>!!c.codoxDId)){try{a=a.getWritable()}catch(p){le.debug("[applyDeltasToLexicalState][shouldUpdateLeaves] getWritable error: ",{err:p,delta:g,fullStateJSON:y});continue}let c={};for(let p of a.getChildren())p.codoxDId?c[p.codoxDId]=p:vu(p);let u=[],h=["codoxDId","codoxId","__key","__parent","__prev","__next"];for(let p=0;p<o.length;p++){let m=o[p],b=p===0,_=p===o.length-1,v=null,w=p>=0?u[p-1]:null;if(m.codoxDId){let x=c[m.codoxDId];if(x){x=x.getWritable();let S=bu(m);if(le.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:x,tmpDecorator:S}),!S){le.debug("[DELTA_DECORATOR_UPDATE] UPADATE SKIPPED: ",{exisingDecorator:x,tmpDecorator:S});continue}for(let E in S)if(S.hasOwnProperty(E)&&!h.includes(E))if(xe.isLexicalEditorInstance(S[E])){let k={editorState:S[E].getEditorState().toJSON()};p0(x[E],k)}else{let k=Rf(E),D=m[k];if(D===x[E]||!m.hasOwnProperty(k))continue;let N=D!==void 0&&S[E]!==D?D:S[E];k!=="height"&&k!=="width"||S[E]==="inherit"&&D===0&&(N=S[E]),x[E]=N}S.remove(),f0(x),v=x,delete c[m.codoxDId]}}v||(v=bu(m),v.codoxDId&&v.__type==="excalidraw"&&v.__data==="[]"&&(v.__data="{}")),v=v.getWritable(),u.push(v),v.__parent=a.__key,b?(a.__first=v.__key,v.__prev=null,_&&(a.__last=v.__key)):_?(a.__last=v.__key,v.__next=null,v.__prev=w.__key,w.__next=v.__key):(v.__prev=w.__key,w.__next=v.__key),a.__size=u.length}for(let p in c){let m=c[p];m=m.getWritable(),f0(m),vu(m),delete c[p]}}else{let c=o.map(u=>bu(u));a.splice(0,a.getChildrenSize(),c)}}if(n){if(g.ld){const o=g.ld,a=Tn.get(o.codoxId);a.getChildrenSize&&a.getChildrenSize()?vu(a):a.remove()}if(g.li){let o=xe.getMainEditorNodesClassesMap();const a=g.li,c=o.get(a.type).klass.importJSON(a);if(t.length===1&&t[0]==="root")(0,ye.$getRoot)().splice(0,0,[c]);else{const u=t[t.length-1];t.length=t.length-2;let h=wa(t,y);h&&h.splice(u,0,[c])}if(a.children&&a.children.length){let u=function(h,p){const m=o.get(h.type).klass.importJSON(h);if(p.splice(p.getChildrenSize(),0,[m]),h.children&&h.children.length)for(const b of h.children)u(b,m)};for(const h of a.children)u(h,c)}}if(g.oi||g.od){let{p:o,oi:a,od:c}=g,u=wa(o,y);if(u)try{let h=u.getWritable();if(a){let p=Object.keys(a);for(let m of p)h[Dl(m)]=a[m]}if(c){let p=Object.keys(c);for(let m of p)delete h[Dl(m)]}}catch(h){le.debug("[applyDeltasToLexicalState][delta oi/od] getWritable error: ",{err:h,delta:g})}}if(l){let{p:o,lm:a}=g,c=o[o.length-1],u=a,h=u<c,p=wa(o,y);if(p){let m=p.getParent().getChildren(),b=m[c],_=m[u];h?_.insertBefore(b):_.insertAfter(b)}}}if(e){const o=t[t.length-1];let a=Dl(o);t.length=t.length-1;let c,u=wa(t,y);if(!u){le.error("Missing node when update node attr from delta: ",{path:t,delta:g,fullStateJSON:y,currentEditorState:xe.getMainEditorState().toJSON()});continue}try{c=u.getWritable()}catch(p){le.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:p,delta:g})}if(!c)continue;let h=g.oi;if(o==="format"&&(h=I_(h)),o==="direction"&&(u.hasOwnProperty(a)||(a="__dir")),!c.hasOwnProperty(a)){let p=Object.keys(c);for(let m of p){let b=Rf(m);if(o.startsWith(b)){a=m;break}}}c[a]=h}}else if(g.oi&&g.oi.root)return h0(g.oi)}}else le.log("[applyDeltasToLexicalState] stop, no deltas: ",d)}function Mx(y){let d=y.clipboardData.getData(M_.paste),g=!1;try{d=JSON.parse(d),typeof d=="object"&&d.nodes&&Array.isArray(d.nodes)&&(g=!0)}catch{return!1}if(!g)return!1;if(g){Tn.clearPastedIds();const t=f=>{if(f.codoxId&&Tn.addPastedId(f.codoxId),f.children&&f.children.length)for(const r of f.children)t(r)};for(const f of d.nodes)t(f)}return!1}var Dx=y=>{var d={};return rn.d(d,y),d};const g0=Dx({useCollaborationContext:()=>K1});var Lx=y=>{var d={};return rn.d(d,y),d};const Li=Lx({LexicalComposerContext:()=>xf,useLexicalComposerContext:()=>Tr});class m0{constructor(){this.blacklist=Object.keys(Gm).reduce((d,g)=>{let t=Gm[g];return d[g]=t.reduce((f,r)=>(f[r]=r,f),{}),d},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(d){return d instanceof ye.TextNode||d instanceof ye.ParagraphNode||d instanceof ye.RootNode}setClientCallback(d){this._clientCallback=d}removeClientCallback(){this._clientCallback=null}invokeClientCallback(){this._clientCallback&&this._clientCallback()}trackBlacklisted(d){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>2?arguments[2]:void 0;if(zf||g!==$r.created||this._isBlacklistedFound||!d||!d.__type||this._shouldSkipNode(d))return;let f=t||xe.getMainEditorState(),r=d.__type,n=this.blacklist[r];n&&f.read(()=>{let e=d.getParent();for(;e!==null;){let s=e?e.__type:null;if(!s)return;if(n[s])return le.warn("[ContentNestingsWatcher][trackBlacklisted] FOUND: ",{targetNode:d,targetType:r,parent:e,parentType:s,mutationType:g}),void(this._isBlacklistedFound=!0);e=e.getParent()}})}trackBlacklistedInNestedEditor(d){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>3?arguments[3]:void 0;if(g!==$r.created||this._isBlacklistedFound||this._shouldSkipNode(d))return;let f=t.__type,r=d.__type;if(!f||!r)return;let n=this.blacklist[r];n&&n[f]&&(this._isBlacklistedFound=!0,le.warn("[ContentNestingsWatcher][trackBlacklistedInNestedEditor] FOUND: ",{targetNode:d,targetType:r,rootNode:t,rootType:f,mutationType:g}))}isBlacklistedFound(){let d=this._isBlacklistedFound;return d&&(this._isBlacklistedFound=!1),d}}const Bx=new m0,Bi=Bx,Fx=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function zx(y,d){if(y==null)return{};var g,t,f=Ux(y,d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(y);for(t=0;t<r.length;t++)g=r[t],d.indexOf(g)>=0||{}.propertyIsEnumerable.call(y,g)&&(f[g]=y[g])}return f}function Ux(y,d){if(y==null)return{};var g={};for(var t in y)if({}.hasOwnProperty.call(y,t)){if(d.indexOf(t)>=0)continue;g[t]=y[t]}return g}class $x{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(d,g){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:s}=f,i=(zx(f,Fx),xe.getMainEditor()),l=xe.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),c=Bf(o,a),u=r._selection,h=n._selection,p=!1,m=null,b=xe.isOnlySelectionChanged(e,s),_=d[g];if(le.debug("[NESTED EDITOR LISTENER] invoked: ",{lexicalNode:d,key:d.__key,onlySelectionChanged:b,newEditorStateJSON:o,prevEditorStateJSON:a,isSameState:c,lexicalSelection:u,prevLexicalSelection:h,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,nestedEditorKey:_._key}),Bi.isBlacklistedFound())return t=!0,le.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),xe.scanLexicalNodeForNestedEditorAttribute(d)?(_.update(()=>{try{const v=_.parseEditorState(a);if(v.isEmpty())return(0,ye.$getRoot)().clear(),!0;_.setEditorState(v)}catch(v){le.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",v)}}),void Bi.invokeClientCallback()):void 0;if(t)t=!1;else{if(d.codoxId||d.codoxDId){let v=null;l.read(()=>{v=$e.getNodeAncestorsCodoxIds(d),!d.codoxId&&d.codoxDId&&v.push(d.codoxDId)}),r.read(()=>{let w=Rf(g),x=$e.lexicalToJSONNested(u,w,v);m=xe.getCurrentNestedSelectionJSON(),p=$e.equalSelectionsJSON(m,x),p||xe.setNestedSelectionJSON(x)})}c&&p||i.update(()=>{try{le.debug("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE",{mainTags:i._updateTags,nestedTags:_&&_._updateTags,isSameState:c,isSameSelection:p,onlyNestedSelectionChanged:b,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,lexicalNode:d,lexicalSelection:u,prevLexicalSelection:h,mainEditorTags:i._updateTags,mainEditorTagsSize:i._updateTags.size}),xe.addUpdateTag({fromNestedEditor:!0}),d.markDirty()}catch(v){le.error("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE - ERROR: ",v)}})}}}_isNestedEditorManaged(d){return!!this.nestedEditorsListenersMap[d]}gc(){for(let d in this.nestedEditorsListenersMap)if(!xe.getLexicalNodeByKey(d)){let g=this.nestedEditorsListenersMap[d];g&&g(),delete this.nestedEditorsListenersMap[d]}}manageNestedEditorInLexicalNode(d){if(this._isNestedEditorManaged(d.getKey()))return;let g=xe.scanLexicalNodeForNestedEditorAttribute(d);if(g){let t=d[g],f=this._createNestedEditorUpdatesListener(d,g),r=[];t._nodes.forEach((s,i,l)=>{let{klass:o}=s,a=t.registerMutationListener(o,c=>{for(let[u,h]of c)if(h===$r.created){let p=t.getEditorState()._nodeMap.get(u);p&&Bi.trackBlacklistedInNestedEditor(p,h,t.getEditorState(),d)}});r.push(a)});let n=(0,vs.mergeRegister)(t.registerUpdateListener(f),...r),e=d.getKey();this.nestedEditorsListenersMap[e]=n}}gcNestedEditorListenerInLexicalNode(d){let g=d.getKey(),t=this.nestedEditorsListenersMap[g];t&&(t(),delete this.nestedEditorsListenersMap[g])}manageNestedEditorInClonedLexicalNode(d,g){let t=d.getKey();t!==g.getKey()&&this._isNestedEditorManaged(t)&&(this.gcNestedEditorListenerInLexicalNode(d),this.manageNestedEditorInLexicalNode(g))}setNestedEditorSelection(d){let{nestedSelectionJSON:g,nestedEditor:t}=$e.getNestedSelectionJSONFromMainSelectionJSON(d);if(!t)return!1;let f=!0;return t.update(()=>{try{let r=$e.JSONToLexical(g);(0,ye.$setSelection)(r),le.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){le.error("[setNestedEditorSelection] set nested selection error: ",r),f=!1}}),f}clearListeners(){for(let d in this.nestedEditorsListenersMap){let g=this.nestedEditorsListenersMap[d];g&&g(),delete this.nestedEditorsListenersMap[d]}}}const Hx=new $x,oi=Hx,qx=function(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let g=(0,ye.createEditor)({namespace:"validation",nodes:[...d],onError:e=>{throw e},parentEditor:null});const t=new m0,f=g.parseEditorState(y);if(f.isEmpty())return;g.setEditorState(f);let r=g.getEditorState();const n=r._nodeMap[Symbol.iterator]();for(const e of n){let[s,i]=e;if(i&&(t.trackBlacklisted(i,$r.created,r),t.isBlacklistedFound()))throw new Error(D_)}}catch(g){throw g}};class Jx{constructor(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}_scanForCellHeaderState(d,g,t,f){if(g.length<f)return null;let r,n=g.some(s=>s.__headerState===Mi.BOTH||s.__headerState===Mi.ROW),e=d.some((s,i)=>{if(s.__size<f)return!1;let l=s.getChildAtIndex(t);return!(!l||l.__headerState!==Mi.BOTH&&l.__headerState!==Mi.COLUMN)});return n&&e?r=Mi.BOTH:n&&!e?r=Mi.ROW:e&&!n&&(r=Mi.COLUMN),r}_isValidCellChildren(d){for(let g of d)if(Es(g)||!Cs(g)&&Cn(g))return!1;return!0}_createEmptyCell(){let d=(0,En.$createTableCellNode)();return d.append((0,ye.$createParagraphNode)()),d}_wrapInvalidCellChildrenIntoParagraph(d){let g=(0,ye.$createParagraphNode)().getWritable(),t=d.getChildren();(d=d.getWritable()).__first=g.__key,d.__last=g.__key,d.__size=1,g.__parent=d.__key,t.forEach((f,r)=>{(f=f.getWritable()).__parent=null,g.append(f)})}_createFixAction_APPEND_CELLS_TO_ROW(d,g){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:d,numOfCellsToAppend:g});let t=(0,ye.$getNodeByKey)(d);for(;g;){let f=(0,En.$createTableCellNode)().append((0,ye.$createParagraphNode)());f.setRowSpan(1).setColSpan(1),t.append(f),g--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(d){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:d}),(0,ye.$getNodeByKey)(d).append((0,ye.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(d){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:d});let g=(0,ye.$getNodeByKey)(d);this._wrapInvalidCellChildrenIntoParagraph(g)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(d){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:d});let g=(0,ye.$getNodeByKey)(d),t=(0,En.$createTableRowNode)();t.append(this._createEmptyCell()),g.append(t)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(d,g){return()=>{for(g||(g=1);g;)(0,ye.$getNodeByKey)(d).append(this._createEmptyCell()),g--}}_createFixAction_WRAP_INVALID_ROW_NODE(d,g){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:d,rowKey:g});let t=(0,ye.$getNodeByKey)(d);if(!t)return;let f=(0,ye.$getNodeByKey)(g);if(!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling();f.__parent=null,f.__prev=null,f.__next=null;let e=(0,En.$createTableRowNode)();if((0,En.$isTableCellNode)(f))f.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(f):f.append((0,ye.$createParagraphNode)()),e.append(f);else{let s=this._isValidCellChildren([f]),i=(0,En.$createTableCellNode)();if(e.append(i),s)i.append(f);else{let l=(0,ye.$createParagraphNode)();l.append(f),i.append(l)}}e.__parent=t.__key,t.__first===f.__key&&(t.__first=e.__key),t.__last===f.__key&&(t.__last=e.__key),r&&(r=r.getWritable(),r.__next=e.__key,e.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=e.__key,e.__next=n.__key)}}_createFixAction_WRAP_INVALID_CELL_NODE(d,g){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:d,cellKey:g});let t=(0,ye.$getNodeByKey)(d);if(!t)return;let f=(0,ye.$getNodeByKey)(g);if(f.remove(),f=(0,ye.$createParagraphNode)(),!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling(),e=(0,En.$createTableCellNode)();if(e.__parent=t.__key,t.__first===f.__key&&(t.__first=e.__key),t.__last===f.__key&&(t.__last=e.__key),r&&(r=r.getWritable(),r.__next=e.__key,e.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=e.__key,e.__next=n.__key),f.__parent=null,f.__prev=null,f.__next=null,this._isValidCellChildren([f]))e.append(f);else{let s=(0,ye.$createParagraphNode)();s.append(f),e.append(s)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(d,g){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:d,headerStateToApply:g});let t=(0,ye.$getNodeByKey)(d);t&&(t=t.getWritable(),t.__headerState=g)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(d){let g=xe.getMainEditorState()._selection;if(le.debug(`[${d}]`,{selection:g}),!(0,ye.$isRangeSelection)(g))return;let t=[];try{let f=xe.getLexicalNodeByKey(g.anchor.key),r=xe.getLexicalNodeByKey(g.focus.key);f&&r&&(t=g.isBackward()?r.getNodesBetween(f):f.getNodesBetween(r))}catch(f){le.warn("[TablesValidator][tableRemoveEventListener] get range selection nodes internal lexical error: ",f)}t.forEach(f=>{(0,En.$isTableNode)(f)&&this.removeCandidateTableKeys.add(f.__key)})}tableNodeRemoveListener(d){this.removeCandidateTableKeys.has(d)&&this.removeCandidateTableKeys.delete(d)}shouldGCRemovedTables(){return!!this.removeCandidateTableKeys.size}gcRemovedTables(){le.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),xe.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(d=>{let g=(0,ye.$getNodeByKey)(d);g&&g.remove()}),this.removeCandidateTableKeys.clear(),(0,ye.$addUpdateTag)(Xr.historic)})}tableUpdateListener(d){this.validateTableCandidateKeys.add(d)}tableRowNodeChangesListener(d){let g=arguments.length>1&&arguments[1]!==void 0&&arguments[1],t=xe.getLexicalNodeByKey(d);if(!t)return void(g&&le.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:d}));let f=t.__parent;f?this.validateTableCandidateKeys.add(f):le.debug("[tableRowNodeChangesListener] no parent table for row node found in lexical: ",{rowNode:t})}tableCellNodeChangesListener(d){let g=xe.getLexicalNodeByKey(d);if(!g||!g.__parent)return;let t=xe.getLexicalNodeByKey(g.__parent);t&&t.__parent&&this.validateTableCandidateKeys.add(t.__parent)}shouldValidateUpdatedTables(){return!!this.validateTableCandidateKeys.size}validateUpdatedTables(){let d=Array.from(this.validateTableCandidateKeys);return xe.getMainEditorState().read(()=>{for(let g of d){let t=xe.getLexicalNodeByKey(g);if(!t)continue;let f=t.getChildren();if(!f.length){this.tableFixActions.push(this._createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(g));continue}let r=0;f.forEach(i=>{i.__size>r&&(r=i.__size)});let n=[],e=f.map((i,l)=>{if(!(0,En.$isTableRowNode)(i))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_ROW_NODE(g,i.__key)),"invalid_row_node";let o=i.getChildren();if(!o.length&&!n.length)return this.tableFixActions.push(this._createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(i.__key,r)),"empty_row_should_add_cell";if(!o.length&&n.length)return n=[],"empty_row_should_be_empty";let a=0;if(n.length){let u=[];n.forEach(h=>{let[p,m]=h;a+=m,p--,p&&u.push([p,m])}),n=[...u]}let c=o.map((u,h)=>{if(!(0,En.$isTableCellNode)(u))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_CELL_NODE(i.__key,u.__key)),a++,"invalid_cell_node_should_wrap_in_cell";let p,m=u.getChildren(),b=!m.length;if(b?this.tableFixActions.push(this._createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(u.__key)):(p=this._isValidCellChildren(m),p||this.tableFixActions.push(this._createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(u.__key))),u.__rowSpan>1){let _=u.__rowSpan,v=u.__colSpan;n.push([_-1,v])}if(a+=u.__colSpan,u.__headerState===Mi.NO_STATUS){let _=this._scanForCellHeaderState(f,o,h,r);_&&this.tableFixActions.push(this._createFixAction_APPLY_HEADER_STATE_TO_CELL(u.__key,_))}return{cellKey:u.__key,rowKey:i.__key,tableKey:g,colSpan:u.__colSpan,rowSpan:u.__rowSpan,headerState:u.__headerState,childrenAreValid:p,isEmptyCell:b}});if(a<r){let u=r-a;this.tableFixActions.push(this._createFixAction_APPEND_CELLS_TO_ROW(i.__key,u))}return{realRowLength:a,rowKey:i.__key,tableKey:g,cells:c}}),s=!this.tableFixActions.length;le[s?"debug":"warn"](`[TablesValidator][validateUpdatedTables] IS TABLE VALID: ${s}`,{tableNodeKey:g,tableValidationMatrix:e,requiredRowLength:r}),this.validateTableCandidateKeys.delete(g)}}),!this.tableFixActions.length}shouldFixTablesStructure(){return!!this.tableFixActions.length}fixTablesStructure(){if(!this.tableFixActions.length)return;let d=xe.getMainEditor();le.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),d.update(()=>{for(let g of this.tableFixActions)g();this.tableFixActions=[],(0,ye.$addUpdateTag)(Xr.historic)})}ensureDocTablesAreValid(d){return this.shouldGCRemovedTables()?(le.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(le.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(le.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(d.toJSON()))}),this.fixTablesStructure(),!1)}}const jo=new Jx,Wx=["contentChanged"],Vx=["state","remoteSelection"];function y0(y,d){var g=Object.keys(y);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(y);d&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(y,f).enumerable})),g.push.apply(g,t)}return g}function ws(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?y0(Object(g),!0).forEach(function(t){Kx(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):y0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function Kx(y,d,g){return(d=Gx(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function Gx(y){var d=Yx(y,"string");return typeof d=="symbol"?d:d+""}function Yx(y,d){if(typeof y!="object"||!y)return y;var g=y[Symbol.toPrimitive];if(g!==void 0){var t=g.call(y,d||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(y)}function b0(y,d){if(y==null)return{};var g,t,f=Zx(y,d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(y);for(t=0;t<r.length;t++)g=r[t],d.indexOf(g)>=0||{}.propertyIsEnumerable.call(y,g)&&(f[g]=y[g])}return f}function Zx(y,d){if(y==null)return{};var g={};for(var t in y)if({}.hasOwnProperty.call(y,t)){if(d.indexOf(t)>=0)continue;g[t]=y[t]}return g}const zf={DEBUG:!1,VERSION:"1.0.2",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";le.info("MODE: ","production");const Qx=y=>async()=>{const{state:d,timestamp:g}=await y();if(!xe.isValidJSONState(d))throw new Error("Invalid state received from fetchDocOnNetworkReconnect hook");const{commentThreads:t,root:f}=d,r={content:{comments:t,root:f},timestamp:g};return le.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let _u=0,ii=null,Uf=!1,mo={},$f={};const Xx=(0,Gt.forwardRef)((y,d)=>{let{onBlacklistedInsert:g}=y;const t=(0,Gt.useContext)(Li.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,Li.useLexicalComposerContext)(),r=(0,g0.useCollaborationContext)();(0,Gt.useEffect)(()=>{if(le.debug("[INIT] lexical context check: ",{lexicalContext:t,editor:f}),!f)return;le.log("[useEffect][editor] Editor instance changed: ",{editor:f,key:f._key}),xe.setMainEditor(f),Tn.gcAbandonedNodes(),oi.gc(),jo.clear(),le.log("[useEffect][editor] subscribe to editor changes");const b=(0,vs.mergeRegister)(f.registerUpdateListener(h),f.registerCommand(ye.PASTE_COMMAND,Mx,ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.UNDO_COMMAND,()=>{xe.setUndoInvoked(!0)},ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.REDO_COMMAND,()=>{xe.setRedoInvoked(!0)},ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.KEY_DELETE_COMMAND,(v,w)=>{jo.tableRemoveEventListener("KEY_DELETE_COMMAND")},ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.KEY_BACKSPACE_COMMAND,(v,w)=>{jo.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},ye.COMMAND_PRIORITY_CRITICAL),f.registerCommand(ye.CUT_COMMAND,(v,w)=>{jo.tableRemoveEventListener("CUT_COMMAND")},ye.COMMAND_PRIORITY_CRITICAL),...p());go.mount(),xe.alignStateSelectionJSONsFromLatestEditor(),le.debug("New editor mounted: ",{isCodoxStarted:xe.isCodoxStarted,codoxLexicalEditorManager:xe,nestedEditorsProcessor:oi});let _=f._onError;return f._onError=v=>{le.error("[ERROR HANDLER WRAPPER] error from editor: ",v),_&&_(v),u()},g&&Bi.setClientCallback(g),()=>{xe.getMainEditorKey()&&(le.debug("Unmount prev editor"),b(),xe.removeMainEditor(),go.unmount(),xe.clearJSONs(),Sn.clear(),jo.clear(),xe.isCodoxStarted&&(le.debug("EDITOR USE_EFFECT stopping codox"),n(),xe.setIsCodoxStarted(!1)),Bi.removeClientCallback())}},[f]);const n=()=>{xe.isCodoxStarted&&(le.log("[stopCodoxInstance] stopping codox"),xe.setIsCodoxStarted(!1),zf||Zo().stop(),xe.clearJSONs(),Tn.clearAll(),go.clear(),Sn.resetComments(),oi.clearListeners())},e=async b=>{le.debug("[startCodoxInstance] invoked"),Zo().createNewInstance(),le.debug("[startCodoxInstance] instance created");for(let O in $f)Zo().instance.on(O,$f[O]);if(le.debug("[startCodoxInstance] events subscribed"),mo=b,ii=mo.docId,!ii)return le.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:ii});let _=Sn.initialCommentsExist();le.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(Sn.activateInitialComments(f,Tn),le.log("[activateInitialComments] "));let v=xe.getMainEditorState().toJSON();if(!xe.isValidJSONState(v))throw le.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:ii,initJSONState:v}),new Error("start codox skipped - invalid init state");le.log("[startCodoxInstance] starting codox with: ",{docId:ii,initJSONState:v,config:mo,codoxComments:Sn}),xe.currentContentStateJSON||xe.setCurrentContentStateJSON(v),xe.isCodoxStarted&&n();let{username:w,apiKey:x,getServerState:S,domain:E="",demo:k=!1,hooks:D}=mo;D&&D.fetchDocOnNetworkReconnect&&(D.fetchDocOnNetworkReconnect=Qx(D.fetchDocOnNetworkReconnect));const N=b0(D,Wx);await Zo().start(Zo().createConfig(ws(ws({},mo),{},{docId:ii,username:w,apiKey:x,domain:E,hooks:ws({syncState:l,getState:i,getServerState:async()=>await S(ii)},N),editorInstanceHooks:{getSelection:()=>xe.getCurrentActiveSelectionJSON(),setSelection:O=>o(O),getState:i,setState:O=>{const{root:R,comments:A}=O;le.info("DEBUG: EDITOR INSTANCE setState:",{fullState:O}),a({state:{root:R},selection:xe.getCurrentActiveSelectionJSON()},go.getCurrentRemoteSelections()),Sn.setAllComments(A)},enableEditor:()=>{xe.disableEditorReadOnlyMode()},disableEditor:()=>{xe.enableEditorReadOnlyMode(),go.updateRemoteSelections([])},getContent:()=>{let O=xe.composeFullStateWithRootAndComments();return le.info("[getContent]: ",O),{state:O}}},appServer:mo.appServer,demo:k}))),le.log("[startCodoxInstance] codox started - first sync invoking"),xe.setIsCodoxStarted(!0),r.clientID=mo.username,r.name=mo.username,c()},s=()=>{let b=xe.composeFullStateWithRootAndComments({directlyFromEditor:!0});e(b)},i=()=>({state:ws(ws({},xe.getMainEditorState().toJSON()),{},{comments:Sn.getAllComments()}),docId:ii}),l=b=>{if(!xe.isCodoxStarted)return;le.log("[SYNC_STATE]: Before sync payload = ",b);const _=Zo().sync({meta:b}),{state:v,remoteSelection:w=[]}=_,x=b0(_,Vx);if(le.log("[SYNC_STATE]: After sync",{state:v,remoteSelection:w,rest:x}),!v)return le.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),s();const S=v.state;le.log("[SYNC_STATE] synced state: ",{synced:JSON.parse(JSON.stringify(S))});let{stateFromSync:E,commentsFromSync:k}=xe.extractStateAndCommentsFromSynced(S);if(!xe.isValidJSONState(E.state))return le.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:E.state}),s();a(E,w),Sn.setAllComments(k)},o=b=>{if(!xe.isCodoxStarted||(le.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:b}),!Ff.validateJSONSelection(b,Mf.local)))return;let _=xe.getCurrentActiveSelectionJSON();if($e.equalSelectionsJSON(_,b))return void le.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let v=$e.isNestedSelectionJSON(b);f.update(()=>{le.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:b});const w=$e.JSONToLexical(b);if(le.log("[setLocalSelectionFromSync] lexical selection to apply: ",w),v){let x=oi.setNestedEditorSelection(b);xe.setNestedSelectionJSON(x?b:null)}else(0,ye.$setSelection)(w),xe.setMainSelectionJSON(b);le.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:xe.getCurrentActiveSelectionJSON()})})},a=function(){let{state:b,selection:_,stateReplace:v}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",S=xe.getCurrentContentStateJSON();le.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:JSON.parse(JSON.stringify(b)),newSelectionJSON:_,remoteSelection:w,stateReplace:v,editor:f}),_===void 0&&le.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",_);const E=Bf(S,b),k=$e.equalSelectionsJSON(xe.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(xe.addUpdateTag({isSameState:E,isSameSelection:k,updateTag:x}),v)le.log("[updateEditor] invoke full stateReplace after sync"),h0(b),S=xe.setCurrentContentStateJSON(b),(0,ye.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S);else{le.log("[updateEditor] invoke deltas diff");let N=Zo().diff(S,b,{keyNames:{default:"codoxId"}});le.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:b,deltas:N&&JSON.parse(JSON.stringify(N))}),N&&N.length&&(le.log("[updateEditor] apply deltas to lexical state"),Rx(b,N),S=xe.setCurrentContentStateJSON(b),(0,ye.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(Ff.validateJSONSelection(_,Mf.local)||(_=xe.getCurrentActiveSelectionJSON()),D){let N=oi.setNestedEditorSelection(_);xe.setNestedSelectionJSON(N?_:null),le.log("[updateEditor] nested selection updated",N?_:null)}else if(_!==void 0){const N=$e.JSONToLexical(_);le.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:N}),(0,ye.$setSelection)(N),xe.setMainSelectionJSON(_),le.log("[updateEditor] selection updated",_)}},{onUpdate:()=>{E||go.updateRemoteSelections(w,"from onUpdate hook")}}),E&&go.updateRemoteSelections(w,"from direct updateEditor")},c=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";if(!xe.isCodoxStarted)return;le.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:b});let _=xe.composeFullStateWithRootAndComments();const v={docId:ii,state:{state:_,selection:xe.getCurrentActiveSelectionJSON()}};le.log("[codoxSync]: Before sync",{local:v,upd_call_counter:b}),le.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(v.state)));let{state:w,remoteSelection:x=[],changes:S}=Zo().sync({state:v,meta:{}});if(le.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(w)),remoteSelection:x,changes:S}),!w)return le.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),s();const E=w.state;le.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(E)),b);let{stateFromSync:k,commentsFromSync:D}=xe.extractStateAndCommentsFromSynced(E);if(!xe.isValidJSONState(k.state))return le.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),s();a(k,x),Sn.setAllComments(D)},u=()=>{le.warn("[rollbackStateDuringUpdateError] rollback invoked"),le.log("[rollbackStateDuringUpdateError] values: ",{prevState:xe.getPrevContentStateJSON(),currentState:xe.getCurrentContentStateJSON(),prevSelection:xe.getPrevMainSelectionJSON(),currentSelection:xe.getCurrentActiveSelectionJSON(),codoxComments:Sn});let b=xe.getPrevContentStateJSON(),_=xe.getPrevMainSelectionJSON();a({state:b,selection:_},go.getCurrentRemoteSelections(),Xr.historic);let v=xe.undoInvoked(),w=xe.redoInvoked();Sn.gcAbandonedNodeKeys(xe.getMainEditorState()._nodeMap),v&&f.dispatchCommand(ye.CAN_REDO_COMMAND,!1),w&&f.dispatchCommand(ye.CAN_UNDO_COMMAND,!1)},h=b=>{let{editorState:_,prevEditorState:v,tags:w,dirtyElements:x,dirtyLeaves:S}=b;if(Uf)return Uf=!1,void le.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(Bi.isBlacklistedFound())return Uf=!0,le.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((V,G)=>{let F=null,q=null;G.read(()=>{F=$e.lexicalToJSON(G._selection),q=G.toJSON()});let T=null,I=null;V.read(()=>{let L=(0,ye.$getSelection)();I=$e.lexicalToJSON(L),T=V.toJSON()}),xe.setCurrentContentStateJSON(T),xe.setMainSelectionJSON(I),a({state:q,selection:F},go.getCurrentRemoteSelections(),Xr.historic),f.dispatchCommand(ye.CAN_REDO_COMMAND,!1),f.dispatchCommand(ye.CAN_UNDO_COMMAND,!1)})(_,v),void Bi.invokeClientCallback();if(!jo.ensureDocTablesAreValid(_))return;_u++,le.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:_u,isCodoxStarted:xe.isCodoxStarted});let E=xe.isOnlySelectionChanged(x,S),k=null,D=null,N=null,O=null,R=xe.getCurrentContentStateJSON(),A=w.has("codox_sync_state_changes"),z=w.has(Ll),H=xe.undoInvoked(),$=xe.redoInvoked(),M=xe.canUndo(),J=xe.canRedo();k=_.toJSON(),D=v.toJSON(),v.read(()=>{O=$e.lexicalToJSON(v._selection)}),_.read(()=>{let V=(0,ye.$getSelection)();N=$e.lexicalToJSON(V);let G=$e.JSONToLexical(N),F=V===null&&G===null||V.is(G);le.log("[editorUpdatesListener] new values: ",{newContentStateJSON:k,currentContentStateJSON:JSON.parse(JSON.stringify(R)),prevContentStateJSON:JSON.parse(JSON.stringify(D)),currentCommentsJSON:JSON.parse(JSON.stringify(Sn.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(N)),currentMainSelectionJSON:JSON.parse(JSON.stringify(xe.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(xe.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(xe.getCurrentActiveSelectionJSON())),lexicalSelection:V,convertedBackMainSelection:G,isMainSelectionConvertionCorrect:F,nodes:f._editorState._nodeMap,fullEditor:f,codoxNodesMap:Tn.toArray(),codoxComments:Sn,isUpdateFromSync:A,isUpdateFromComments:z,tags:w,onlySelectionChanged:E,undoInvoked:H,redoInvoked:$,canUndo:M,canRedo:J})});let K=Bf(R,k),P=$e.equalSelectionsJSON(xe.getCurrentActiveSelectionJSON(),N);le.log("[editorUpdatesListener] compares: ",{isStateSame:K,isSelectionSame:P});let U=K&&P&&!z;if(!K||z||A){let V=ws({},K?R:k),G=Sn.getAllComments();G.length&&(V.commentThreads=G);let F={source:A?Ym.remote:Ym.local,content:V};mo.hooks&&mo.hooks.contentChanged&&mo.hooks.contentChanged(F),Zo().instance.emit("content_changed",F)}if(U)le.log("[editorUpdatesListener] STOP - state and selection and comments are same ",_u);else if(xe.undoInvoked()&&xe.setUndoInvoked(!1),xe.redoInvoked()&&xe.setRedoInvoked(!1),xe.setCurrentContentStateJSON(k),xe.setPrevContentStateJSON(D),xe.setMainSelectionJSON(N),xe.setPrevMainSelectionJSON(O),zf){let V=xe.getCurrentActiveSelectionJSON();a({state:xe.getCurrentContentStateJSON(),selection:V},[])}else c(_u)},p=()=>{let b=[];return xe.getMainEditorNodesClassesMap().forEach((_,v,w)=>{let{klass:x}=_,S=f.registerMutationListener(x,E=>{for(let[k,D]of E){if(!$r[D])continue;const N=xe.getLexicalNodeByKey(k);if(D===$r.created&&N&&Bi.trackBlacklisted(N,D),x.name===En.TableNode.name&&(D===$r.destroyed?jo.tableNodeRemoveListener(k):jo.tableUpdateListener(k)),x.name===En.TableRowNode.name&&D!==$r.destroyed&&jo.tableRowNodeChangesListener(k,D===$r.updated),x.name===En.TableCellNode.name&&D===$r.updated&&jo.tableCellNodeChangesListener(k),x.name===Qr.MarkNode.name&&(le.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:N,mutationType:D,codoxComments:Sn}),D===$r.destroyed?Sn.removeRelatedNodeKey(k):N&&Sn.addRelatedNodeKey(N.__key,N.__ids,D===$r.created)),N&&N.codoxId){if(D===$r.destroyed)return void(N.codoxId&&Tn.remove(N.codoxId));k0(N)||le.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:D,node:N}),Tn.add(N.codoxId,N)}}b.push(S)})}),b},m={start:e,stop:n,on:(b,_)=>{le.info(`Subscribing client to codox ${b} event`),$f[b]=_},cursor:{hide:()=>{go.hideRemoteSelectionsFromUI()},show:()=>{go.showHiddenRemoteSelectionsInUI()}},initComments:b=>{Sn.setInitialComments(b)}};return(0,Gt.useImperativeHandle)(d,()=>m),null}),tw=Xx,ew=["comments"];function v0(y,d){var g=Object.keys(y);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(y);d&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(y,f).enumerable})),g.push.apply(g,t)}return g}function Hf(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?v0(Object(g),!0).forEach(function(t){nw(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):v0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function nw(y,d,g){return(d=rw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function rw(y){var d=ow(y,"string");return typeof d=="symbol"?d:d+""}function ow(y,d){if(typeof y!="object"||!y)return y;var g=y[Symbol.toPrimitive];if(g!==void 0){var t=g.call(y,d||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(y)}function iw(y,d){if(y==null)return{};var g,t,f=aw(y,d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(y);for(t=0;t<r.length;t++)g=r[t],d.indexOf(g)>=0||{}.propertyIsEnumerable.call(y,g)&&(f[g]=y[g])}return f}function aw(y,d){if(y==null)return{};var g={};for(var t in y)if({}.hasOwnProperty.call(y,t)){if(d.indexOf(t)>=0)continue;g[t]=y[t]}return g}class sw extends Vm{constructor(){super(),this.mainEditor=null,this.mainEditorKey=null,this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this._isCodoxStarted=!1,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1}setCanUndo(d){this._canUndo=d}setCanRedo(d){this._canRedo=d}canUndo(){return this._canUndo}canRedo(){return this._canRedo}setUndoInvoked(d){this._undoInvoked=d}setRedoInvoked(d){this._redoInvoked=d}undoInvoked(){return this._undoInvoked}redoInvoked(){return this._redoInvoked}setIsCodoxStarted(){let d=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this._isCodoxStarted=d}get isCodoxStarted(){return this._isCodoxStarted}getMainEditorKey(){return this.mainEditorKey}setMainEditor(d){this.mainEditor=d,this.mainEditorKey=d._key}clearJSONs(){le.debug("[CodoxLexicalEditorManager][clearJSONs] invoked"),this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null}removeMainEditor(){this.mainEditor=null,this.mainEditorKey=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1,super.clear()}getMainEditor(){return this.mainEditor}alignStateSelectionJSONsFromLatestEditor(){this.getMainEditorState().read(()=>{this.setCurrentContentStateJSON(this.getMainEditorState().toJSON()),this.setMainSelectionJSON($e.lexicalToJSON((0,ye.$getSelection)()))})}mainEditorExists(){return!!this.mainEditor}getMainEditorState(){return this.mainEditor?this.mainEditor.getEditorState():{}}getMainEditorNodesClassesMap(){return this.mainEditor?this.mainEditor._nodes:new Map}getLexicalNodeByKey(d){return this.mainEditor?this.getMainEditorState()._nodeMap.get(d):null}isLexicalEditorInstance(d){return d&&typeof d=="object"&&!!d.setEditorState}setCurrentContentStateJSON(d){return this.currentContentStateJSON=d,this.currentContentStateJSON}getCurrentContentStateJSON(){return this.currentContentStateJSON}setPrevContentStateJSON(d){this.prevContentStateJSON=d}getPrevContentStateJSON(){return this.prevContentStateJSON}setMainSelectionJSON(d){this.currentMainSelectionJSON=d,this.currentMainSelectionJSON&&this.currentNestedSelectionJSON&&(this.currentNestedSelectionJSON=null)}setNestedSelectionJSON(d){this.currentNestedSelectionJSON=d,this.currentNestedSelectionJSON&&this.currentMainSelectionJSON&&(this.currentMainSelectionJSON=null)}getCurrentMainSelectionJSON(){return this.currentMainSelectionJSON}getCurrentNestedSelectionJSON(){return this.currentNestedSelectionJSON}getCurrentActiveSelectionJSON(){return!this.currentMainSelectionJSON&&this.currentNestedSelectionJSON?this.currentNestedSelectionJSON:this.currentMainSelectionJSON}clearSelectionJSON(){this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null}setPrevMainSelectionJSON(d){this.prevMainSelectionJSON=d}getPrevMainSelectionJSON(){return this.prevMainSelectionJSON}extractStateAndCommentsFromSynced(d){let{state:{comments:g},selection:t,stateReplace:f}=d;return{stateFromSync:{state:Hf({},iw(d.state,ew)),selection:t,stateReplace:f},commentsFromSync:g}}composeFullStateWithRootAndComments(){let{directlyFromEditor:d=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Hf(Hf({},d?this.getMainEditorState().toJSON():this.currentContentStateJSON),{},{comments:Sn.getAllComments()})}isValidJSONState(d){let g=!1;try{if(!d)throw new Error("State is undefined");if(!d.root)throw new Error("State 'root' node is missing");let t=this.getMainEditorNodesClassesMap(),f=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",e=r,s=t.get(e.type);if(!s)throw new Error(`Node with type "${e.type}" is not registered in editor`);let{klass:i}=s;if(n==="root"){let l=i.prototype instanceof ye.ElementNode,o=i.prototype instanceof ye.DecoratorNode;if(!l&&!o)throw new Error("State root node can have only element nodes as children")}if(e.children)for(let l of e.children)f(l,e.type)};f(d.root),g=!0}catch(t){le.error("[isValidJSONState] invalid state found: ",t.message),g=!1}return g}scanLexicalNodeForNestedEditorAttribute(d){for(let g in d){let t=d[g];if(this.isLexicalEditorInstance(t))return g}return""}isOnlySelectionChanged(d,g){return d.size===0&&g.size===0}addUpdateTag(){let{isSameState:d,isSameSelection:g,fromNestedEditor:t=!1,updateTag:f=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return f?(le.log(`[addUpdateTag] explicit add of tag "${f}" `),void(0,ye.$addUpdateTag)(f)):t?(le.log(`[addUpdateTag] add "${Xr.historic}" tag - change invoked by nested editor`),void(0,ye.$addUpdateTag)(Xr.historic)):void(d?(le.log(`[addUpdateTag] add "${Xr.historic}" tag - state is same`),(0,ye.$addUpdateTag)(Xr.historic)):(le.log(`[addUpdateTag] add "${Xr.historyMerge}" tag - state is different`),(0,ye.$addUpdateTag)(Xr.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const lw=new sw,xe=lw;class cw{constructor(){this._nodesMap=new Map,this._pastedNodesCodoxIds=new Set}get size(){return this._nodesMap.size}add(d,g){this._nodesMap.set(d,g)}get(d){return this._nodesMap.get(d)||null}remove(d){this._nodesMap.delete(d)}has(d){return this._nodesMap.has(d)}nodesToArray(){return Array.from(this._nodesMap.values())}keysToArray(){return Array.from(this._nodesMap.keys())}toArray(){return Array.from(this._nodesMap.entries())}addPastedId(d){this._pastedNodesCodoxIds.add(d)}removePastedId(d){this._pastedNodesCodoxIds.delete(d)}hasPastedId(d){return this._pastedNodesCodoxIds.has(d)}clearPastedIds(){this._pastedNodesCodoxIds.size>0&&this._pastedNodesCodoxIds.clear()}isEmptyPastedIds(){return this._pastedNodesCodoxIds.size===0}getPastedIdsSize(){return this._pastedNodesCodoxIds.size}clearAll(){this._nodesMap.clear(),this._pastedNodesCodoxIds.clear()}gcAbandonedNodes(){let d=xe.getMainEditorState();if(!d._nodeMap)return;let g=this.nodesToArray();for(let t of g)d._nodeMap.has(t.__key)||this.remove(t.codoxId)}}const uw=new cw,Tn=uw;function _0(y,d){var g=Object.keys(y);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(y);d&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(y,f).enumerable})),g.push.apply(g,t)}return g}function x0(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?_0(Object(g),!0).forEach(function(t){dw(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):_0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function dw(y,d,g){return(d=fw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function fw(y){var d=pw(y,"string");return typeof d=="symbol"?d:d+""}function pw(y,d){if(typeof y!="object"||!y)return y;var g=y[Symbol.toPrimitive];if(g!==void 0){var t=g.call(y,d||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(y)}const qf=()=>x_(),w0=y=>typeof y=="number";function Ss(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const g=function(){for(var t=arguments.length,f=new Array(t),r=0;r<t;r++)f[r]=arguments[r];return y.apply(this,f)};return Object.defineProperty(g,"name",{value:d,writable:!0}),g}const Sa=y=>y.__type==="root"||y.type==="root",S0=y=>Sa(y.getParent()),Fn=y=>y.__type===hu.text||y.type===hu.text||y.hasOwnProperty("__text")||y.hasOwnProperty("text"),Cs=y=>(0,ye.$isElementNode)(y),Es=y=>(0,En.$isTableNode)(y)||(0,En.$isTableRowNode)(y)||(0,En.$isTableCellNode)(y),hw=y=>!y.getChildren,C0=y=>!!y.getChildren,Cn=y=>(0,ye.$isDecoratorNode)(y),Fl=y=>(0,p_.$isLinkNode)(y),zl=y=>y.__type==="mark"||y.type==="mark",Jf=y=>(0,ye.$isLineBreakNode)(y),Fi=y=>Fn(y)||Jf(y),Wf=y=>y.__type===hu.horizontalrule||y.type===hu.horizontalrule,E0=y=>{if(Fi(y)||Fl(y)||zl(y))return!1;if(!y.__parent||y.__parent==="root"||(0,ye.$isParagraphNode)(y))return!0;let d=y.getParent().getChildren();return d.length===1&&d[0].__key===y.__key?!((Cn(y)||Fl(y)||zl(y))&&!Wf(y)):!d.some(g=>{let t=Wf(g);return g.__key!==y.__key&&(Fi(g)||Cn(g)&&!t||Fl(g)||zl(g))})},k0=y=>{const d=Tn.get(y.codoxId);return!d||y.__key===d.__key},ks=function(y){const d=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||qf();y.codoxId=d,Tn.add(d,y)},O0=y=>{Tn.remove(y.codoxId),delete y.codoxId},gw=y=>{if(!C0(y)||!y.getChildrenSize())return;const d=y.getChildren();if(d.some(f=>!!(0,ye.$isParagraphNode)(f)))return;let g=!1,t=[];for(let f of d)(Fi(f)||Cn(f)||Fl(f)||zl(f))&&!g&&(Wf(f)||(g=!0)),(C0(f)||Cn(f))&&t.push(f);for(let f of t)g||f.codoxId?g&&f.codoxId&&(f=f.getWritable(),O0(f)):(f=f.getWritable(),ks(f))},mw=y=>{const d=x0({},y);for(const g in y)y[g]===void 0&&y.hasOwnProperty(g)&&delete d[g];return d},yw=y=>{const d=`__nativeCreateDOM_${y.name}`;y.prototype[d]=Ss(y.prototype.createDOM,d),y.prototype.createDOM=function(g,t){if(E0(this))if(this.codoxId){if(!k0(this)){let r=Tn.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(le.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),Tn.add(this.codoxId,this)):ks(this)}}else ks(this);else this.codoxId&&O0(this);Cn(this)&&!this.codoxDId&&(this.codoxDId=qf()),oi.manageNestedEditorInLexicalNode(this);let f=this[d](g,t);return f.__codox_track=!0,f}},bw=y=>{const d=`__nativeUpdateDOM_${y.name}`;return y.prototype[d]=Ss(y.prototype.updateDOM,d),y.prototype.updateDOM=function(){const g=this[d](...arguments);return gw(this),g},y},vw=y=>{const d=`__nativeRemove_${y.name}`;return y.prototype[d]=Ss(y.prototype.remove,d),y.prototype.remove=function(){const g=this.codoxId;return g&&Tn.remove(g),oi.gcNestedEditorListenerInLexicalNode(this),this[d](...arguments)},y},_w=y=>{const d=`__nativeExportJSON_${y.name}`;y.prototype[d]=Ss(y.prototype.exportJSON,d),y.prototype.exportJSON=function(){const g=this[d]();return this.codoxId&&(g.codoxId=this.codoxId),this.codoxDId&&(g.codoxDId=this.codoxDId),Fn(this)&&w0(g.format)&&this.hasFormat&&(g.format=P_(this)),mw(g)}},xw=y=>{const d="__nativeImportJSON";y[d]=Ss(y.importJSON,d),y.importJSON=function(g){const t=x0({},g);Fn(t)&&!w0(t.format)&&(t.format=N_(t.format));const f=y[d](t);oi.manageNestedEditorInLexicalNode(f);const r=E0(f);return r&&t.codoxId&&(Tn.hasPastedId(t.codoxId)&&Tn.has(t.codoxId)?(Tn.removePastedId(t.codoxId),ks(f)):ks(f,t.codoxId)),r&&!f.codoxId&&ks(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},ww=y=>{const d="__nativeClone";y[d]=Ss(y.clone,d),y.clone=function(g){const t=y[d](g);return g.codoxId&&(t.codoxId=g.codoxId),g.codoxDId&&(t.codoxDId=g.codoxDId),oi.manageNestedEditorInClonedLexicalNode(g,t),t}},Sw=y=>{let d=!1,g=!1,t=!1,f=!1;y.forEach(n=>{n.name===ye.TextNode.name?d=!0:n.name===ye.ParagraphNode.name?g=!0:n.name===ye.LineBreakNode.name?t=!0:n.name===Qr.MarkNode.name&&(f=!0)});let r=[];return d||r.push(ye.TextNode),g||r.push(ye.ParagraphNode),t||r.push(ye.LineBreakNode),f||r.push(Qr.MarkNode),r.length?[...r,...y]:y},Cw=function(){return Sw(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(y=>(y.hasOwnProperty("__isCodoxExtended")||(yw(y),bw(y),_w(y),vw(y),xw(y),ww(y),Object.defineProperty(y,"__isCodoxExtended",{value:!0,writable:!1})),y))};var xu=rn(777),Os={};Os.styleTagTransform=ri(),Os.setAttributes=ei(),Os.insert=ti().bind(null,"head"),Os.domAPI=Xo(),Os.insertStyleElement=ni(),Qo()(xu.A,Os),xu.A&&xu.A.locals&&xu.A.locals;var Ew=y=>{var d={};return rn.d(d,y),d};const kw=Ew({AutoFocusPlugin:()=>$g});var Ow=y=>{var d={};return rn.d(d,y),d};const Tw=Ow({ClearEditorPlugin:()=>Y1});var jw=y=>{var d={};return rn.d(d,y),d};const Aw=jw({LexicalComposer:()=>Ug});var Nw=y=>{var d={};return rn.d(d,y),d};const T0=Nw({default:()=>Q1});var Pw=y=>{var d={};return rn.d(d,y),d};const Iw=Pw({HistoryPlugin:()=>om});var Rw=y=>{var d={};return rn.d(d,y),d};const Mw=Rw({OnChangePlugin:()=>t_});var Dw=y=>{var d={};return rn.d(d,y),d};const Lw=Dw({PlainTextPlugin:()=>l_});var Bw=y=>{var d={};return rn.d(d,y),d};const j0=Bw({$isRootTextContentEmpty:()=>sm,$rootTextContent:()=>am});var Fw=y=>{var d={};return rn.d(d,y),d};const Ts=Fw({createPortal:()=>Tb.createPortal}),zw=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Uw=zw?Gt.useLayoutEffect:Gt.useEffect,A0=Uw;var wu=rn(253),js={};js.styleTagTransform=ri(),js.setAttributes=ei(),js.insert=ti().bind(null,"head"),js.domAPI=Xo(),js.insertStyleElement=ni(),Qo()(wu.A,js),wu.A&&wu.A.locals&&wu.A.locals;function $w(y){let{onClose:d,children:g,title:t,closeOnClickOutside:f}=y;const r=(0,Gt.useRef)(null);return(0,Gt.useEffect)(()=>{r.current!==null&&r.current.focus()},[]),(0,Gt.useEffect)(()=>{let n=null;const e=l=>{l.key==="Escape"&&d()},s=l=>{const o=l.target;r.current!==null&&!r.current.contains(o)&&f&&d()},i=r.current;return i!==null&&(n=i.parentElement,n!==null&&n.addEventListener("click",s)),window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),n!==null&&(n==null||n.removeEventListener("click",s))}},[f,d]),Gt.createElement("div",{className:"Modal__overlay",role:"dialog"},Gt.createElement("div",{className:"Modal__modal",tabIndex:-1,ref:r},Gt.createElement("h2",{className:"Modal__title"},t),Gt.createElement("button",{className:"Modal__closeButton","aria-label":"Close modal",type:"button",onClick:d},"X"),Gt.createElement("div",{className:"Modal__content"},g)))}function Hw(y){let{onClose:d,children:g,title:t,closeOnClickOutside:f=!1}=y;return(0,Ts.createPortal)(Gt.createElement($w,{onClose:d,title:t,closeOnClickOutside:f},g),document.body)}function N0(){const[y,d]=(0,Gt.useState)(null),g=(0,Gt.useCallback)(()=>{d(null)},[]),t=(0,Gt.useMemo)(()=>{if(y===null)return null;const{title:r,content:n,closeOnClickOutside:e}=y;return Gt.createElement(Hw,{onClose:g,title:r,closeOnClickOutside:e},n)},[y,g]),f=(0,Gt.useCallback)(function(r,n){d({closeOnClickOutside:arguments.length>2&&arguments[2]!==void 0&&arguments[2],content:n(g),title:r})},[g]);return[t,f]}var Su=rn(191),As={};As.styleTagTransform=ri(),As.setAttributes=ei(),As.insert=ti().bind(null,"head"),As.domAPI=Xo(),As.insertStyleElement=ni(),Qo()(Su.A,As),Su.A&&Su.A.locals&&Su.A.locals;const qw={blockCursor:"CommentEditorTheme__blockCursor",characterLimit:"CommentEditorTheme__characterLimit",code:"CommentEditorTheme__code",codeHighlight:{atrule:"CommentEditorTheme__tokenAttr",attr:"CommentEditorTheme__tokenAttr",boolean:"CommentEditorTheme__tokenProperty",builtin:"CommentEditorTheme__tokenSelector",cdata:"CommentEditorTheme__tokenComment",char:"CommentEditorTheme__tokenSelector",class:"CommentEditorTheme__tokenFunction","class-name":"CommentEditorTheme__tokenFunction",comment:"CommentEditorTheme__tokenComment",constant:"CommentEditorTheme__tokenProperty",deleted:"CommentEditorTheme__tokenProperty",doctype:"CommentEditorTheme__tokenComment",entity:"CommentEditorTheme__tokenOperator",function:"CommentEditorTheme__tokenFunction",important:"CommentEditorTheme__tokenVariable",inserted:"CommentEditorTheme__tokenSelector",keyword:"CommentEditorTheme__tokenAttr",namespace:"CommentEditorTheme__tokenVariable",number:"CommentEditorTheme__tokenProperty",operator:"CommentEditorTheme__tokenOperator",prolog:"CommentEditorTheme__tokenComment",property:"CommentEditorTheme__tokenProperty",punctuation:"CommentEditorTheme__tokenPunctuation",regex:"CommentEditorTheme__tokenVariable",selector:"CommentEditorTheme__tokenSelector",string:"CommentEditorTheme__tokenSelector",symbol:"CommentEditorTheme__tokenProperty",tag:"CommentEditorTheme__tokenProperty",url:"CommentEditorTheme__tokenOperator",variable:"CommentEditorTheme__tokenVariable"},embedBlock:{base:"CommentEditorTheme__embedBlock",focus:"CommentEditorTheme__embedBlockFocus"},hashtag:"CommentEditorTheme__hashtag",heading:{h1:"CommentEditorTheme__h1",h2:"CommentEditorTheme__h2",h3:"CommentEditorTheme__h3",h4:"CommentEditorTheme__h4",h5:"CommentEditorTheme__h5",h6:"CommentEditorTheme__h6"},image:"editor-image",indent:"CommentEditorTheme__indent",inlineImage:"inline-editor-image",layoutContainer:"CommentEditorTheme__layoutContainer",layoutItem:"CommentEditorTheme__layoutItem",link:"CommentEditorTheme__link",list:{checklist:"CommentEditorTheme__checklist",listitem:"CommentEditorTheme__listItem",listitemChecked:"CommentEditorTheme__listItemChecked",listitemUnchecked:"CommentEditorTheme__listItemUnchecked",nested:{listitem:"CommentEditorTheme__nestedListItem"},olDepth:["CommentEditorTheme__ol1","CommentEditorTheme__ol2","CommentEditorTheme__ol3","CommentEditorTheme__ol4","CommentEditorTheme__ol5"],ul:"CommentEditorTheme__ul"},ltr:"CommentEditorTheme__ltr",mark:"CommentEditorTheme__mark",markOverlap:"CommentEditorTheme__markOverlap",paragraph:"CommentEditorTheme__paragraph",quote:"CommentEditorTheme__quote",rtl:"CommentEditorTheme__rtl",table:"CommentEditorTheme__table",tableCell:"CommentEditorTheme__tableCell",tableCellActionButton:"CommentEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"CommentEditorTheme__tableCellActionButtonContainer",tableCellEditing:"CommentEditorTheme__tableCellEditing",tableCellHeader:"CommentEditorTheme__tableCellHeader",tableCellPrimarySelected:"CommentEditorTheme__tableCellPrimarySelected",tableCellResizer:"CommentEditorTheme__tableCellResizer",tableCellSelected:"CommentEditorTheme__tableCellSelected",tableCellSortedIndicator:"CommentEditorTheme__tableCellSortedIndicator",tableResizeRuler:"CommentEditorTheme__tableCellResizeRuler",tableSelected:"CommentEditorTheme__tableSelected",tableSelection:"CommentEditorTheme__tableSelection",text:{bold:"CommentEditorTheme__textBold",code:"CommentEditorTheme__textCode",italic:"CommentEditorTheme__textItalic",strikethrough:"CommentEditorTheme__textStrikethrough",subscript:"CommentEditorTheme__textSubscript",superscript:"CommentEditorTheme__textSuperscript",underline:"CommentEditorTheme__textUnderline",underlineStrikethrough:"CommentEditorTheme__textUnderlineStrikethrough"}},Jw=qw;var Cu=rn(72),Ns={};Ns.styleTagTransform=ri(),Ns.setAttributes=ei(),Ns.insert=ti().bind(null,"head"),Ns.domAPI=Xo(),Ns.insertStyleElement=ni(),Qo()(Cu.A,Ns),Cu.A&&Cu.A.locals&&Cu.A.locals;function Ww(){for(var y=arguments.length,d=new Array(y),g=0;g<y;g++)d[g]=arguments[g];return d.filter(Boolean).join(" ")}function Vf(){return Vf=Object.assign?Object.assign.bind():function(y){for(var d=1;d<arguments.length;d++){var g=arguments[d];for(var t in g)({}).hasOwnProperty.call(g,t)&&(y[t]=g[t])}return y},Vf.apply(null,arguments)}function zi(y){let{"data-test-id":d,children:g,className:t,onClick:f,disabled:r,small:n,title:e}=y;return Gt.createElement("button",Vf({disabled:r,className:Ww("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},d&&{"data-test-id":d}),g)}var Eu=rn(129),Ps={};Ps.styleTagTransform=ri(),Ps.setAttributes=ei(),Ps.insert=ti().bind(null,"head"),Ps.domAPI=Xo(),Ps.insertStyleElement=ni(),Qo()(Eu.A,Ps),Eu.A&&Eu.A.locals&&Eu.A.locals;var Vw=y=>{var d={};return rn.d(d,y),d};const Kw=Vw({ContentEditable:()=>Hg});function Gw(y){let{className:d}=y;return Gt.createElement(Kw.ContentEditable,{className:d||"ContentEditable__root"})}var ku=rn(457),Is={};Is.styleTagTransform=ri(),Is.setAttributes=ei(),Is.insert=ti().bind(null,"head"),Is.domAPI=Xo(),Is.insertStyleElement=ni(),Qo()(ku.A,Is),ku.A&&ku.A.locals&&ku.A.locals;function Yw(y){let{children:d,className:g}=y;return Gt.createElement("div",{className:g||"Placeholder__root"},d)}const Zw=T0.default.LexicalErrorBoundary||T0.default,Qw=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"#050505",className:"codox-add-comment-right"},Gt.createElement("path",{d:"M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H4.414A2 2 0 0 0 3 11.586l-2 2V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12.793a.5.5 0 0 0 .854.353l2.853-2.853A1 1 0 0 1 4.414 12H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"}),Gt.createElement("path",{d:"M3 3.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 6a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 6zm0 2.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"})),P0=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",className:"codox-remove-comment"},Gt.createElement("path",{d:"M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z"})),Xw=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"codox-add-comment"},Gt.createElement("path",{d:"M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576 6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76 7.494-7.493Z"})),tS=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"#0000008c",className:"codox-hide-show-comments"},Gt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13 5.885v1.166a3.95 3.95 0 0 1-3.949 3.95H6.917a.748.748 0 0 0-.45.15l-1.345 1.007a.752.752 0 0 0-.032 1.181A2.933 2.933 0 0 0 6.95 14h2.716l2.534 1.901a.506.506 0 0 0 .524.047A.501.501 0 0 0 13 15.5V14h.051a2.949 2.949 0 0 0 2.95-2.949v-3.05a3.002 3.002 0 0 0-2.002-2.83.756.756 0 0 0-.999.714"}),Gt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.05 1H2.95A2.952 2.952 0 0 0 0 3.949v3.102A2.952 2.952 0 0 0 2.949 10H3v1.5a.502.502 0 0 0 .8.4L6.334 10H9.05A2.952 2.952 0 0 0 12 7.05V3.95A2.952 2.952 0 0 0 9.05 1"}));function I0(y,d,g){let t=arguments.length>3&&arguments[3]!==void 0?arguments[3]:performance.now(),f=arguments.length>4&&arguments[4]!==void 0&&arguments[4];return Sn.createNewCommentObj({content:y,author:d,codoxId:g,timeStamp:t,deleted:f})}function eS(y,d,g){return Sn.createNewThreadObj({quote:y,comments:d,codoxId:g})}function nS(y){let{anchorKey:d,editor:g,onAddComment:t}=y;const f=(0,Gt.useRef)(null),r=(0,Gt.useCallback)(()=>{const n=f.current,e=g.getRootElement(),s=g.getElementByKey(d);if(n!==null&&e!==null&&s!==null){const{right:i}=e.getBoundingClientRect(),{top:l}=s.getBoundingClientRect();n.style.left=i-20+"px",n.style.top=l-30+"px"}},[d,g]);return(0,Gt.useEffect)(()=>(window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[g,r]),A0(()=>{r()},[d,g,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(Qw,null)))}function rS(y){let{onEscape:d}=y;const[g]=(0,Li.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>g.registerCommand(ye.KEY_ESCAPE_COMMAND,t=>d(t),2),[g,d]),null}function oS(y){let{editorRef:d}=y;const[g]=(0,Li.useLexicalComposerContext)();return typeof d=="function"?d(g):typeof d=="object"&&(d.current=g),null}function R0(y){let{className:d,autoFocus:g,onEscape:t,onChange:f,editorRef:r,placeholder:n="Type a comment...",onEditorClick:e=()=>{}}=y;const s={namespace:"Commenting",nodes:[],onError:i=>{throw i},theme:Jw};return Gt.createElement(Aw.LexicalComposer,{initialConfig:s},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(Lw.PlainTextPlugin,{contentEditable:Gt.createElement(Gw,{className:d}),placeholder:Gt.createElement(Yw,null,n),ErrorBoundary:Zw}),Gt.createElement(Mw.OnChangePlugin,{onChange:f}),Gt.createElement(Iw.HistoryPlugin,null),g!==!1&&Gt.createElement(kw.AutoFocusPlugin,null),Gt.createElement(rS,{onEscape:t}),Gt.createElement(Tw.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(oS,{editorRef:r})))}function M0(y,d){return(0,Gt.useCallback)((g,t)=>{g.read(()=>{y((0,j0.$rootTextContent)()),d(!(0,j0.$isRootTextContentEmpty)(t.isComposing(),!0))})},[d,y])}function iS(y){let{editor:d,cancelAddComment:g,submitAddComment:t}=y;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),s=(0,Gt.useRef)(null),i=(0,Gt.useMemo)(()=>({container:document.createElement("div"),elements:[]}),[]),l=(0,Gt.useRef)(null),o=B0(),a=(0,Gt.useCallback)(()=>{d.getEditorState().read(()=>{const u=(0,ye.$getSelection)();if((0,ye.$isRangeSelection)(u)){l.current=u.clone();const h=u.anchor,p=u.focus,m=(0,xa.createDOMRange)(d,h.getNode(),h.offset,p.getNode(),p.offset),b=s.current;if(m!==null&&b!==null){const{left:_,bottom:v,width:w}=m.getBoundingClientRect(),x=(0,xa.createRectsFromDOMRange)(d,m);let S=x.length===1?_+w/2-125:_-125;S<10&&(S=10),b.style.left=`${S}px`,b.style.top=`${v+20+(window.pageYOffset||document.documentElement.scrollTop)}px`;const E=x.length,{container:k}=i,D=i.elements,N=D.length;for(let O=0;O<E;O++){const R=x[O];let A=D[O];A===void 0&&(A=document.createElement("span"),D[O]=A,k.appendChild(A));const z="255, 212, 0",H=`position:absolute;top:${R.top+(window.pageYOffset||document.documentElement.scrollTop)}px;left:${R.left}px;height:${R.height}px;width:${R.width}px;background-color:rgba(${z}, 0.3);pointer-events:none;z-index:5;`;A.style.cssText=H}for(let O=N-1;O>=E;O--){const R=D[O];k.removeChild(R),D.pop()}}}})},[d,i]);A0(()=>{a();const u=i.container,h=document.body;if(h!==null)return h.appendChild(u),()=>{h.removeChild(u)}},[i.container,a]),(0,Gt.useEffect)(()=>(window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}),[a]);const c=M0(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:s},Gt.createElement(R0,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:u=>(u.preventDefault(),g(),!0),onChange:c}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement(zi,{onClick:g,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement(zi,{onClick:()=>{if(n){let u=d.getEditorState().read(()=>{const h=l.current;return h?h.getTextContent():""});u.length>100&&(u=u.slice(0,99)+"…"),t(eS(u,[I0(f,o)]),!0,void 0,l.current),l.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function aS(y){let{submitAddComment:d,thread:g,placeholder:t}=y;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),s=(0,Gt.useRef)(null),i=B0(),l=M0(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(R0,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:l,editorRef:s,placeholder:t}),Gt.createElement(zi,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){d(I0(f,i),!1,g);const o=s.current;o!==null&&o.dispatchCommand(ye.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(Xw,null)))}function D0(y){let{commentOrThread:d,deleteCommentOrThread:g,onClose:t,thread:f}=y;return Gt.createElement(Gt.Fragment,null,"Are you sure you want to delete this ",d.type,"?",Gt.createElement("div",{className:"Modal__content"},Gt.createElement(zi,{onClick:()=>{g(d,f),t()}},"Delete")," ",Gt.createElement(zi,{onClick:()=>{t()}},"Cancel")))}function L0(y){let{comment:d,deleteComment:g,thread:t,rtf:f}=y;const r=Math.round((d.timeStamp-performance.now())/1e3),n=Math.round(r/60),[e,s]=N0();return Gt.createElement("li",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment"},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Details"},Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Author"},d.author),Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Time"},"· ",r>-10?"Just now":f.format(n,"minute"))),Gt.createElement("p",{className:d.deleted?"CodoxCommentPlugin_CommentsPanel_DeletedComment":""},d.content),!d.deleted&&Gt.createElement(Gt.Fragment,null,Gt.createElement(zi,{onClick:()=>{s("Delete Comment",i=>Gt.createElement(D0,{commentOrThread:d,deleteCommentOrThread:g,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(P0,null)),e))}function sS(y){let{activeIDs:d,comments:g,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=y;const[e]=(0,Li.useLexicalComposerContext)(),[s,i]=(0,Gt.useState)(0),[l,o]=N0(),a=(0,Gt.useMemo)(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return(0,Gt.useEffect)(()=>{const c=setTimeout(()=>{i(s+1)},1e4);return()=>{clearTimeout(c)}},[s]),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List",ref:f},g.map(c=>{const u=c.codoxId;if(!u)return null;if(c.type==="thread"){const h=()=>{if(n.get(u)!==void 0&&(d===null||d.indexOf(u)===-1)){const p=document.activeElement;e.update(()=>{(0,ye.$setSelection)(null)},{onUpdate(){p!==null&&p.focus()}})}};return Gt.createElement("li",{key:u,onClick:h,className:`CodoxCommentPlugin_CommentsPanel_List_Thread ${n.has(u)?"interactive":""} ${d.indexOf(u)===-1?"":"active"}`},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_QuoteBox"},Gt.createElement("blockquote",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Quote"},"> ",Gt.createElement("span",null,c.quote)),Gt.createElement(zi,{onClick:()=>{o("Delete Thread",p=>Gt.createElement(D0,{commentOrThread:c,deleteCommentOrThread:t,onClose:p}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(P0,null)),l),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},c.comments.map(p=>Gt.createElement(L0,{key:p.codoxId,comment:p,deleteComment:t,thread:c,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(aS,{submitAddComment:r,thread:c,placeholder:"Reply to comment..."})))}return Gt.createElement(L0,{key:u,comment:c,deleteComment:t,rtf:a})}))}function lS(y){let{activeIDs:d,deleteCommentOrThread:g,comments:t,submitAddComment:f,markNodeMap:r}=y;const n=(0,Gt.useRef)(null),e=t.length===0;return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel"},Gt.createElement("h2",{className:"CodoxCommentPlugin_CommentsPanel_Heading"},"Comments"),e?Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_Empty"},"No Comments"):Gt.createElement(sS,{activeIDs:d,comments:t,deleteCommentOrThread:g,listRef:n,submitAddComment:f,markNodeMap:r}))}function B0(){const y=(0,g0.useCollaborationContext)(),{yjsDocMap:d,name:g}=y;return g||"Playground User"}function cS(y){const[d]=(0,Li.useLexicalComposerContext)(),g=J_(),t=(0,Gt.useMemo)(()=>new Map,[]),[f,r]=(0,Gt.useState)(),[n,e]=(0,Gt.useState)([]),[s,i]=(0,Gt.useState)(!1),[l,o]=(0,Gt.useState)(!1);(0,Gt.useEffect)(()=>{!g.length&&l?o(!1):g.length},[g]);const a=(0,Gt.useCallback)(()=>{d.update(()=>{const h=(0,ye.$getSelection)();h!==null&&(h.dirty=!0)}),i(!1)},[d]),c=(0,Gt.useCallback)((h,p)=>{if(h.type==="comment"){if(le.log("[deleteCommentOrThread]: type comment new values",{comment:h,thread:p,markNodeMap:t}),Sn.removeComment(p.codoxId,h.codoxId),!p)return;const m=p.codoxId,b=t.get(m);d.update(()=>{b?b.forEach((_,v)=>{const w=(0,ye.$getNodeByKey)(v);le.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:w}),w&&w.markDirty()}):(0,ye.$getRoot)().markDirty(),(0,ye.$addUpdateTag)(Xr.historic),(0,ye.$addUpdateTag)(Ll)})}else{le.log("[deleteCommentOrThread]: type thread new values",{comment:h,markNodeMap:t});const m=p!==void 0?p.codoxId:h.codoxId,b=t.get(m);setTimeout(()=>{d.update(()=>{if(b)for(const _ of b){const v=(0,ye.$getNodeByKey)(_);le.log("[deleteCommentOrThread]: type thread new values",{node:v}),(0,Qr.$isMarkNode)(v)&&(v.deleteID(m),v.getIDs().length===0&&(0,Qr.$unwrapMarkNode)(v))}else(0,ye.$getRoot)().markDirty(),le.debug("[deleteCommentOrThread][refreshComments]");Sn.refreshComments(!0),(0,ye.$addUpdateTag)(Ll)})})}},[d,t]),u=(0,Gt.useCallback)((h,p,m,b)=>{if(le.log("[submitAddComment]: new values",{commentOrThread:h,isInlineComment:p,thread:m,markNodeMap:t}),m?Sn.addComment(m.codoxId,h):Sn.addCommentThread(h),p)d.update(()=>{if((0,ye.$isRangeSelection)(b)){const _=b.isBackward(),v=h.codoxId;(0,Qr.$wrapSelectionInMarkNode)(b,_,v),(0,ye.$addUpdateTag)(Ll)}}),i(!1);else if(!p&&m){const _=m.codoxId,v=t.get(_);if(!v)return void Sn.removeComment(m.codoxId,h.codoxId);d.update(()=>{v.forEach((w,x)=>{let S=(0,ye.$getNodeByKey)(x);S&&S.markDirty()}),(0,ye.$addUpdateTag)(Xr.historic),(0,ye.$addUpdateTag)(Ll)})}},[d]);return(0,Gt.useEffect)(()=>{const h=[];for(let p=0;p<n.length;p++){const m=n[p],b=t.get(m);if(b!==void 0)for(const _ of b){const v=d.getElementByKey(_);v!==null&&(v.classList.add("selected"),h.push(v),o(!0))}}return()=>{for(let p=0;p<h.length;p++)h[p].classList.remove("selected")}},[n,d,t]),(0,Gt.useEffect)(()=>{const h=new Map;return(0,vs.mergeRegister)((0,vs.registerNestedElementResolver)(d,Qr.MarkNode,p=>(0,Qr.$createMarkNode)(p.getIDs()),(p,m)=>{p.getIDs().forEach(b=>{m.addID(b)})}),d.registerMutationListener(Qr.MarkNode,p=>{d.getEditorState().read(()=>{for(const[m,b]of p){const _=(0,ye.$getNodeByKey)(m);let v=[];b==="destroyed"?v=h.get(m)||[]:(0,Qr.$isMarkNode)(_)&&(v=_.getIDs());for(let w=0;w<v.length;w++){const x=v[w];let S=t.get(x);h.set(m,v),b==="destroyed"?S!==void 0&&(S.delete(m),S.size===0&&t.delete(x)):(S===void 0&&(S=new Set,t.set(x,S)),S.has(m)||S.add(m))}}})}),d.registerUpdateListener(p=>{let{editorState:m,tags:b}=p;m.read(()=>{const _=(0,ye.$getSelection)();let v=!1,w=!1;if((0,ye.$isRangeSelection)(_)){const x=_.anchor.getNode();if((0,ye.$isTextNode)(x)){const S=(0,Qr.$getMarkIDs)(x,_.anchor.offset);S!==null&&(e(S),v=!0),_.isCollapsed()||(r(x.getKey()),w=!0)}}v||e(x=>x.length===0?x:[]),w||r(null),(0,ye.$isRangeSelection)(_)&&i(!1)})}),d.registerCommand(Lf,()=>{const p=window.getSelection();return p!==null&&p.removeAllRanges(),i(!0),!0},ye.COMMAND_PRIORITY_EDITOR))},[d,t]),Gt.createElement(Gt.Fragment,null,s&&(0,Ts.createPortal)(Gt.createElement(iS,{editor:d,cancelAddComment:a,submitAddComment:u}),document.body),f!=null&&!s&&(0,Ts.createPortal)(Gt.createElement(nS,{anchorKey:f,editor:d,onAddComment:()=>{d.dispatchCommand(Lf,void 0)}}),document.body),(0,Ts.createPortal)(Gt.createElement(zi,{className:"CodoxCommentPlugin_ShowCommentsButton "+(l?"active":""),onClick:()=>o(!l),title:l?"Hide Comments":"Show Comments"},Gt.createElement(tS,null)),document.body),l&&(0,Ts.createPortal)(Gt.createElement(lS,{comments:g,submitAddComment:u,deleteCommentOrThread:c,activeIDs:n,markNodeMap:t}),document.body))}var Ou=rn(766),Rs={};Rs.styleTagTransform=ri(),Rs.setAttributes=ei(),Rs.insert=ti().bind(null,"head"),Rs.domAPI=Xo(),Rs.insertStyleElement=ni(),Qo()(Ou.A,Rs),Ou.A&&Ou.A.locals&&Ou.A.locals;var Tu=rn(225),Ms={};Ms.styleTagTransform=ri(),Ms.setAttributes=ei(),Ms.insert=ti().bind(null,"head"),Ms.domAPI=Xo(),Ms.insertStyleElement=ni(),Qo()(Tu.A,Ms),Tu.A&&Tu.A.locals&&Tu.A.locals;function uS(y){let{label:d,value:g,onChange:t,placeholder:f="","data-test-id":r,type:n="text"}=y;return Gt.createElement("div",{className:"CodoxInput__wrapper"},Gt.createElement("label",{className:"CodoxInput__label"},d),Gt.createElement("input",{type:n,className:"CodoxInput__input",placeholder:f,value:g,onChange:e=>{t(e.target.value)},"data-test-id":r}))}function F0(y,d){var g=Object.keys(y);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(y);d&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(y,f).enumerable})),g.push.apply(g,t)}return g}function ju(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?F0(Object(g),!0).forEach(function(t){dS(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):F0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function dS(y,d,g){return(d=fS(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function fS(y){var d=pS(y,"string");return typeof d=="symbol"?d:d+""}function pS(y,d){if(typeof y!="object"||!y)return y;var g=y[Symbol.toPrimitive];if(g!==void 0){var t=g.call(y,d||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(y)}let Ul=!1;const hS=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],$l=214,z0=150;function gS(y){let{color:d,onChange:g}=y;const[t,f]=(0,Gt.useState)(Ds("hex",d)),[r,n]=(0,Gt.useState)(d),e=(0,Gt.useRef)(null),s=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*$l,y:(100-t.hsv.v)/100*z0}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*$l}),[t.hsv]);return(0,Gt.useEffect)(()=>{e.current!==null&&g&&n(t.hex)},[t,g]),(0,Gt.useEffect)(()=>{if(d===void 0)return;const l=Ds("hex",d);f(l),n(l.hex)},[d]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:$l},ref:e},Gt.createElement(uS,{label:"Hex",onChange:l=>{if(n(l),/^#[0-9A-Fa-f]{6}$/i.test(l)){const o=Ds("hex",l);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},hS.map(l=>Gt.createElement("button",{className:l===t.hex?" active":"",key:l,style:{backgroundColor:l},onClick:()=>(o=>{n(o);let a=Ds("hex",o);f(a),g(a.hex,Ul)})(l)}))),Gt.createElement(U0,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:l=>{let{x:o,y:a}=l;const c=Ds("hsv",ju(ju({},t.hsv),{},{s:o/$l*100,v:100-a/z0*100}));f(c),n(c.hex),g(c.hex,Ul)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:s.x,top:s.y}})),Gt.createElement(U0,{className:"codox-color-picker-hue",onChange:l=>{let{x:o}=l;const a=Ds("hsv",ju(ju({},t.hsv),{},{h:o/$l*360}));f(a),n(a.hex),g(a.hex,Ul)}},Gt.createElement("div",{className:"codox-color-picker-hue_cursor",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`,left:i.x}})),Gt.createElement("div",{className:"codox-color-picker-color",style:{backgroundColor:t.hex}}))}function U0(y){let{className:d,style:g,onChange:t,children:f}=y;const r=(0,Gt.useRef)(null),n=(0,Gt.useRef)(!1),e=s=>{if(r.current){const{current:i}=r,{width:l,height:o,left:a,top:c}=i.getBoundingClientRect(),u=$0(s.clientX-a,l,0),h=$0(s.clientY-c,o,0);t({x:u,y:h})}};return Gt.createElement("div",{ref:r,className:d,style:g,onMouseDown:s=>{if(s.button!==0)return;e(s);const i=o=>{n.current=!0,Ul=!0,e(o)},l=o=>{n.current&&(Ul=!1),document.removeEventListener("mousemove",i,!1),document.removeEventListener("mouseup",l,!1),e(o),n.current=!1};document.addEventListener("mousemove",i,!1),document.addEventListener("mouseup",l,!1)}},f)}function $0(y,d,g){return y>d?d:y<g?g:y}function H0(y){if(!y.startsWith("#")){const d=document.createElement("canvas").getContext("2d");if(!d)throw new Error("2d context not supported or canvas already initialized");return d.fillStyle=y,d.fillStyle}return y.length===4||y.length===5?y=y.split("").map((d,g)=>g?d+d:"#").join(""):y.length===7||y.length===9?y:"#000000"}function q0(y){const d=(y.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(g,t,f,r)=>"#"+t+t+f+f+r+r).substring(1).match(/.{2}/g)||[]).map(g=>parseInt(g,16));return{b:d[2],g:d[1],r:d[0]}}function Kf(y){let{r:d,g,b:t}=y;d/=255,g/=255,t/=255;const f=Math.max(d,g,t),r=f-Math.min(d,g,t);return{h:r?60*(f===d?(g-t)/r+(g<t?6:0):f===g?2+(t-d)/r:4+(d-g)/r):0,s:f?r/f*100:0,v:100*f}}function mS(y){let{h:d,s:g,v:t}=y;g/=100,t/=100;const f=~~(d/60),r=d/60-f,n=t*(1-g),e=t*(1-g*r),s=t*(1-g*(1-r)),i=f%6,l=Math.round(255*[t,e,n,n,s,t][i]),o=Math.round(255*[s,t,t,e,n,n][i]);return{b:Math.round(255*[n,n,s,t,t,e][i]),g:o,r:l}}function J0(y){let{b:d,g,r:t}=y;return"#"+[t,g,d].map(f=>f.toString(16).padStart(2,"0")).join("")}function Ds(y,d){let g=H0("#121212"),t=q0(g),f=Kf(t);return y==="hex"?(g=H0(d),t=q0(g),f=Kf(t)):y==="rgb"?(t=d,g=J0(t),f=Kf(t)):y==="hsv"&&(f=d,t=mS(f),g=J0(t)),{hex:g,hsv:f,rgb:t}}const yS=Gt.createContext(null),W0=4;function bS(y){let{children:d,dropDownRef:g,onClose:t,dropdownClassName:f}=y;const[r,n]=(0,Gt.useState)(),[e,s]=(0,Gt.useState)(),i=(0,Gt.useCallback)(o=>{n(a=>a?[...a,o]:[o])},[n]),l=(0,Gt.useMemo)(()=>({registerItem:i}),[i]);return(0,Gt.useEffect)(()=>{r&&!e&&s(r[0]),e&&e.current&&e.current.focus()},[r,e]),Gt.createElement(yS.Provider,{value:l},Gt.createElement("div",{className:f,ref:g,onKeyDown:o=>{if(!r)return;const a=o.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(a)&&o.preventDefault(),a==="Escape"||a==="Tab"?t():a==="ArrowUp"?s(c=>{if(!c)return r[0];const u=r.indexOf(c)-1;return r[u===-1?r.length-1:u]}):a==="ArrowDown"&&s(c=>c?r[r.indexOf(c)+1]:r[0])}},d))}function vS(y){let{disabled:d=!1,buttonLabel:g,buttonAriaLabel:t,buttonClassName:f,buttonIconClassName:r,children:n,stopCloseOnClickSelf:e,dropdownClassName:s,buttonLabelClassName:i,dropdownChevronClassName:l}=y;const o=(0,Gt.useRef)(null),a=(0,Gt.useRef)(null),[c,u]=(0,Gt.useState)(!1);return(0,Gt.useEffect)(()=>{const h=a.current,p=o.current;if(c&&h!==null&&p!==null){const{top:m,left:b}=h.getBoundingClientRect();p.style.top=`${m+h.offsetHeight+W0}px`,p.style.left=`${Math.min(b,window.innerWidth-p.offsetWidth-20)}px`}},[o,a,c]),(0,Gt.useEffect)(()=>{const h=a.current;if(h!==null&&c){const p=m=>{const b=m.target;e&&o.current&&o.current.contains(b)||h.contains(b)||u(!1)};return document.addEventListener("click",p),()=>{document.removeEventListener("click",p)}}},[o,a,c,e]),(0,Gt.useEffect)(()=>{const h=()=>{if(c){const p=a.current,m=o.current;if(p!==null&&m!==null){const{top:b}=p.getBoundingClientRect(),_=b+p.offsetHeight+W0;_!==m.getBoundingClientRect().top&&(m.style.top=`${_}px`)}}};return document.addEventListener("scroll",h),()=>{document.removeEventListener("scroll",h)}},[a,o,c]),Gt.createElement(Gt.Fragment,null,Gt.createElement("button",{type:"button",disabled:d,"aria-label":t||g,className:f,onClick:()=>u(!c),ref:a},r&&Gt.createElement("span",{className:r}),g&&Gt.createElement("span",{className:i},g),Gt.createElement("i",{className:l})),c&&(0,Ts.createPortal)(Gt.createElement(bS,{dropDownRef:o,onClose:()=>{u(!1),a&&a.current&&a.current.focus()},dropdownClassName:s},n),document.body))}const _S=["disabled","stopCloseOnClickSelf","color","onChange"];function Gf(){return Gf=Object.assign?Object.assign.bind():function(y){for(var d=1;d<arguments.length;d++){var g=arguments[d];for(var t in g)({}).hasOwnProperty.call(g,t)&&(y[t]=g[t])}return y},Gf.apply(null,arguments)}function xS(y,d){if(y==null)return{};var g,t,f=wS(y,d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(y);for(t=0;t<r.length;t++)g=r[t],d.indexOf(g)>=0||{}.propertyIsEnumerable.call(y,g)&&(f[g]=y[g])}return f}function wS(y,d){if(y==null)return{};var g={};for(var t in y)if({}.hasOwnProperty.call(y,t)){if(d.indexOf(t)>=0)continue;g[t]=y[t]}return g}function V0(y){let{disabled:d=!1,stopCloseOnClickSelf:g=!0,color:t,onChange:f}=y,r=xS(y,_S);return Gt.createElement(vS,Gf({},r,{disabled:d,stopCloseOnClickSelf:g}),Gt.createElement(gS,{color:t,onChange:f}))}const SS=y=>{let{onColorChange:d,buttonClassName:g,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=y;const[i]=(0,Li.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,c]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,vs.mergeRegister)(i.registerEditableListener(h=>{o(h)}),i.registerUpdateListener(h=>{let{editorState:p}=h;p.read(()=>{const m=(0,ye.$getSelection)();if((0,ye.$isRangeSelection)(m)){let b=(0,xa.$getSelectionStyleValueForProperty)(m,"color");b!==a&&(c(b||""),d(b))}})})),[i]);const u=(0,Gt.useCallback)((h,p)=>{i.update(()=>{const m=(0,ye.$getSelection)();m!==null&&(0,xa.$patchStyleText)(m,{color:h})})},[i]);return Gt.createElement(V0,{disabled:!l,color:a,onChange:u,buttonClassName:g||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},CS=SS,ES=y=>{let{onColorChange:d,buttonClassName:g,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=y;const[i]=(0,Li.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,c]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,vs.mergeRegister)(i.registerEditableListener(h=>{o(h)}),i.registerUpdateListener(h=>{let{editorState:p}=h;p.read(()=>{const m=(0,ye.$getSelection)();if((0,ye.$isRangeSelection)(m)){let b=(0,xa.$getSelectionStyleValueForProperty)(m,"background-color");b!==a&&(c(b||""),d(b))}})})),[i]);const u=(0,Gt.useCallback)((h,p)=>{i.update(()=>{const m=(0,ye.$getSelection)();m!==null&&(0,xa.$patchStyleText)(m,{"background-color":h})})},[i]);return Gt.createElement(V0,{disabled:!l,color:a,onChange:u,buttonClassName:g||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},kS=ES;var OS=Ii.yy;Ii._U,Ii.a8,Ii.Vs,Ii.Cn;var TS=Ii.gK,jS=Ii.vv;function AS(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var Au=AS(function(y){const d=new URLSearchParams;d.append("code",y);for(let g=1;g<arguments.length;g++)d.append("v",arguments[g]);throw Error(`Minified Lexical error #${y}; visit https://lexical.dev/docs/error?${d} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function NS({hasCellMerge:y=!0,hasCellBackgroundColor:d=!0,hasTabHandler:g=!0}){const[t]=Tr();return Fe.useEffect(()=>(t.hasNodes([To,Oo,ba])||Au(10),ko(t.registerCommand(M1,({columns:f,rows:r,includeHeaders:n})=>{const e=Tm(Number(r),Number(f),n);tm(e);const s=e.getFirstDescendant();return Pe(s)&&s.select(),!0},an),t.registerNodeTransform(To,f=>{const[r]=jm(f,null,null),n=r.reduce((e,s)=>Math.max(e,s.length),0);for(let e=0;e<r.length;++e){const s=r[e].length;if(s===n)continue;const i=r[e][s-1].cell;for(let l=s;l<n;++l){const o=hs(0);o.append(Qn()),i!==null?i.insertAfter(o):em(i,o)}}}))),[t]),Fe.useEffect(()=>{const f=new Map,r=e=>{const s=e.getKey(),i=t.getElementByKey(s);if(i&&!f.has(s)){const l=q1(e,i,t,g);f.set(s,l)}};t.getEditorState().read(()=>{const e=Hh(To);for(const s of e)Jn(s)&&r(s)});const n=t.registerMutationListener(To,e=>{for(const[s,i]of e)if(i==="created")t.getEditorState().read(()=>{const l=Hn(s);Jn(l)&&r(l)});else if(i==="destroyed"){const l=f.get(s);l!==void 0&&(l.removeListeners(),f.delete(s))}});return()=>{n();for(const[,e]of f)e.removeListeners()}},[t,g]),Fe.useEffect(()=>{if(!y)return t.registerNodeTransform(Oo,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=ms(f),[n]=gs(r,f,f),e=n.length,s=n[0].length;let i=r.getFirstChild();Mr(i)||Au(175);const l=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),Mr(i)||Au(175));let a=null;for(let c=0;c<s;c++){const u=n[o][c],h=u.cell;if(u.startRow===o&&u.startColumn===c)a=h,l.push(h);else if(h.getColSpan()>1||h.getRowSpan()>1){on(h)||Au(176);const p=hs(h.__headerState);a!==null?a.insertAfter(p):em(i,p)}}}for(const o of l)o.setColSpan(1),o.setRowSpan(1)}})},[t,y]),Fe.useEffect(()=>{if(!d)return t.registerNodeTransform(Oo,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,d,y]),null}const PS={code:"editor-code",heading:{h1:"editor-heading-h1",h2:"editor-heading-h2",h3:"editor-heading-h3",h4:"editor-heading-h4",h5:"editor-heading-h5"},image:"editor-image",link:"editor-link",list:{listitem:"editor-listitem",nested:{listitem:"editor-nested-listitem"},ol:"editor-list-ol",ul:"editor-list-ul"},ltr:"ltr",paragraph:"editor-paragraph",placeholder:"editor-placeholder",quote:"editor-quote",rtl:"rtl",text:{bold:"editor-text-bold",code:"editor-text-code",hashtag:"editor-text-hashtag",italic:"editor-text-italic",overflowed:"editor-text-overflowed",strikethrough:"editor-text-strikethrough",underline:"editor-text-underline",underlineStrikethrough:"editor-text-underlineStrikethrough"},table:"PlaygroundEditorTheme__table",tableAddColumns:"PlaygroundEditorTheme__tableAddColumns",tableAddRows:"PlaygroundEditorTheme__tableAddRows",tableCell:"PlaygroundEditorTheme__tableCell",tableCellActionButton:"PlaygroundEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"PlaygroundEditorTheme__tableCellActionButtonContainer",tableCellEditing:"PlaygroundEditorTheme__tableCellEditing",tableCellHeader:"PlaygroundEditorTheme__tableCellHeader",tableCellPrimarySelected:"PlaygroundEditorTheme__tableCellPrimarySelected",tableCellResizer:"PlaygroundEditorTheme__tableCellResizer",tableCellSelected:"PlaygroundEditorTheme__tableCellSelected",tableCellSortedIndicator:"PlaygroundEditorTheme__tableCellSortedIndicator",tableResizeRuler:"PlaygroundEditorTheme__tableCellResizeRuler",tableSelected:"PlaygroundEditorTheme__tableSelected",tableSelection:"PlaygroundEditorTheme__tableSelection"},IS="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",RS="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",MS="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik00IDEySDIwTTEyIDRWMjAiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4NCjwvc3ZnPg==",DS="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik02IDEyTDE4IDEyIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+DQo8L3N2Zz4=",Ca=8,Ea=72,LS=15;function BS({selectionFontSize:y,disabled:d,editor:g}){const[t,f]=Yn.useState(y),[r,n]=Yn.useState(!1);Yn.useState(!1);const e=(c,u)=>{if(!u)return c;let h=c;switch(u){case 2:switch(!0){case c>Ea:h=Ea;break;case c>=48:h-=12;break;case c>=24:h-=4;break;case c>=14:h-=2;break;case c>=9:h-=1;break;default:h=Ca;break}break;case 1:switch(!0){case c<Ca:h=Ca;break;case c<12:h+=1;break;case c<20:h+=2;break;case c<36:h+=4;break;case c<=60:h+=12;break;default:h=Ea;break}break}return h},s=Yn.useCallback((c,u)=>{const h=p=>(p||(p=`${LS}px`),p=p.slice(0,-2),`${e(Number(p),u)}px`);g.update(()=>{if(g.isEditable()){const p=je();p!==null&&Gg(p,{"font-size":c||h})}})},[g]),i=c=>{const u=Number(t);if(c.key!=="Tab"){if(["e","E","+","-"].includes(c.key)||isNaN(u)){c.preventDefault(),f("");return}n(!0),(c.key==="Enter"||c.key==="Escape")&&(c.preventDefault(),a(u))}},l=()=>{if(t!==""&&r){const c=Number(t);a(c)}},o=c=>{if(t!==""){const u=e(Number(t),c);s(String(u)+"px",null)}else s(null,c)},a=c=>{let u=c;c>Ea?u=Ea:c<Ca&&(u=Ca),f(String(u)),s(String(u)+"px",null),n(!1)};return Yn.useEffect(()=>{f(y)},[y]),Se.jsxs(Se.Fragment,{children:[Se.jsx("button",{type:"button",disabled:d||y!==""&&Number(t)<=Ca,onClick:()=>o(2),className:"toolbar-item font-decrement",children:Se.jsx("img",{src:DS,height:16,width:16,style:{marginTop:"5px"}})}),Se.jsx("input",{type:"number",value:t,disabled:d,className:"toolbar-item font-size-input",min:Ca,max:Ea,onChange:c=>f(c.target.value),onKeyDown:i,onBlur:l}),Se.jsx("button",{type:"button",disabled:d||y!==""&&Number(t)>=Ea,onClick:()=>o(1),className:"toolbar-item font-increment",children:Se.jsx("img",{src:MS,height:16,width:16,style:{marginTop:"5px"}})}),Se.jsx("div",{children:Se.jsx("div",{className:"symbol-dropdown",children:Se.jsxs("select",{name:"cars",id:"cars",children:[Se.jsx("option",{value:"Heading 1",children:"Heading 1"}),Se.jsx("option",{value:"Heading 2",children:"Heading 2"}),Se.jsx("option",{value:"Heading 3",children:"heading 3"})]})})})]})}const FS="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function zS(){const[y,d]=Fe.useState(""),[g,t]=Fe.useState(""),[f,r]=Fe.useState(!1),[n]=Tr(),e=()=>{!y||!g||(n.update(()=>{const s=Tm(y,g,!0);tm(s)}),r(!1))};return Se.jsxs(Se.Fragment,{children:[Se.jsx("button",{className:"toolbar-item ",onClick:()=>r(!0),children:Se.jsx("img",{className:"add-toolbar-table-icon",src:FS,alt:"Add Table"})}),f&&Se.jsx("div",{className:"modal-overlay",children:Se.jsxs("div",{className:"modal-content",children:[Se.jsx("h3",{children:"Select Table Dimensions"}),Se.jsx("div",{className:"select-table-container",children:Se.jsx("input",{type:"number",value:y,onChange:s=>d(Number(s.target.value)),placeholder:"Rows"})}),Se.jsx("div",{className:"select-table-container",children:Se.jsx("input",{type:"number",value:g,onChange:s=>t(Number(s.target.value)),placeholder:"Columns"})}),Se.jsx("div",{children:Se.jsxs("div",{className:"modal-buttons",children:[Se.jsx("button",{className:"toolbar-item",onClick:e,children:"Add"}),Se.jsx("button",{className:"toolbar-item",onClick:()=>r(!1),children:"Cancel"})]})})]})})]})}const US="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",$S=[{letter:"",uppercase:"A",lowercase:"α"},{letter:"Beta",uppercase:"Β",lowercase:"β"},{letter:"Gamma",uppercase:"Γ",lowercase:"γ"},{letter:"Delta",uppercase:"Δ",lowercase:"δ"},{letter:"Epsilon",uppercase:"Ε",lowercase:"ε"},{letter:"Zeta",uppercase:"Ζ",lowercase:"ζ"},{letter:" Eta ",uppercase:"Η",lowercase:"η"},{letter:"Theta",uppercase:"Θ",lowercase:"θ"},{letter:"Iota",uppercase:"Ι",lowercase:"ι"},{letter:"Kappa",uppercase:"Κ",lowercase:"κ"}];function HS(){const[y]=Tr(),[d,g]=Fe.useState(!1),t=f=>{y.update(()=>{var n;const r=je();if(_e(r)){const e=r.anchor.getNode();let s="inherit";if(e instanceof ki){const l=e.getStyle();s=((n=l==null?void 0:l.match(/font-size:\s*(\S+);/))==null?void 0:n[1])||s}const i=Zn(f);r.insertNodes([i])}}),g(!1)};return Se.jsxs("div",{children:[Se.jsx("button",{className:"toolbar-item symbols-toolbar",onClick:()=>g(!d),children:"Symbols"}),d&&Se.jsx("div",{className:"modal-overlay",children:Se.jsxs("div",{className:"modal-content-symb",children:[Se.jsx("div",{className:"symbol-Flex-container",children:$S.map(({letter:f,uppercase:r,lowercase:n})=>Se.jsxs("div",{className:"symbol-items",children:[Se.jsx("button",{onClick:()=>t(n),children:n}),Se.jsx("button",{onClick:()=>t(r),children:r})]},f))}),Se.jsx("button",{className:"toolbar-item close-btn",onClick:()=>g(!1),children:Se.jsx("img",{src:US,width:16,height:16})})]})})]})}const Yf=1;function Zf(){return Se.jsx("div",{className:"divider"})}function qS(){const[y]=Tr(),d=Fe.useRef(null),[g,t]=Fe.useState(!1),[f,r]=Fe.useState(!1),[n,e]=Fe.useState(!1),[s,i]=Fe.useState(!1),[l,o]=Fe.useState(!1),[a,c]=Fe.useState(!1),[u,h]=Fe.useState(!1),[p,m]=Fe.useState(!1),[b,_]=Fe.useState("11px"),[v,w]=Fe.useState(()=>y.isEditable()),x=Fe.useCallback(()=>{const S=je();_e(S)&&(e(S.hasFormat("bold")),i(S.hasFormat("italic")),o(S.hasFormat("underline")),c(S.hasFormat("strikethrough")),h(S.hasFormat("subscript")),m(S.hasFormat("superscript")),_(Yg(S,"font-size","11px")))},[]);return Fe.useEffect(()=>ko(y.registerUpdateListener(({editorState:S})=>{S.read(()=>{x()})}),y.registerCommand(qo,(S,E)=>(x(),!1),Yf),y.registerCommand(Xa,S=>(t(S),!1),Yf),y.registerCommand(Qa,S=>(r(S),!1),Yf)),[y,x]),Se.jsxs("div",{className:"toolbar",ref:d,children:[Se.jsx("button",{disabled:!g,onClick:()=>{y.dispatchCommand(cl,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:Se.jsx("i",{className:"format undo"})}),Se.jsx("button",{disabled:!f,onClick:()=>{y.dispatchCommand(ul,void 0)},className:"toolbar-item","aria-label":"Redo",children:Se.jsx("i",{className:"format redo"})}),Se.jsx(Zf,{}),Se.jsx(BS,{selectionFontSize:b.slice(0,-2),editor:y,disabled:!v}),Se.jsx(Zf,{}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"bold")},className:"toolbar-item spaced "+(n?"active":""),"aria-label":"Format Bold",children:Se.jsx("i",{className:"format bold"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"italic")},className:"toolbar-item spaced "+(s?"active":""),"aria-label":"Format Italics",children:Se.jsx("i",{className:"format italic"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"underline")},className:"toolbar-item spaced "+(l?"active":""),"aria-label":"Format Underline",children:Se.jsx("i",{className:"format underline"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"strikethrough")},className:"toolbar-item spaced "+(a?"active":""),"aria-label":"Format Strikethrough",children:Se.jsx("i",{className:"format strikethrough"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"superscript")},className:"toolbar-item spaced "+(p?"active":""),"aria-label":"Format SuperScript",children:Se.jsx("img",{src:RS,height:16,width:16,style:{marginTop:"1px"}})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Cr,"subscript")},className:"toolbar-item spaced "+(u?"active":""),"aria-label":"Format SubScript",children:Se.jsx("img",{src:IS,height:16,width:16,style:{marginTop:"1px"}})}),Se.jsx(Zf,{}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Za,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:Se.jsx("i",{className:"format left-align"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Za,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:Se.jsx("i",{className:"format center-align"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Za,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:Se.jsx("i",{className:"format right-align"})}),Se.jsx("button",{onClick:()=>{y.dispatchCommand(Za,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:Se.jsx("i",{className:"format justify-align"})}),Se.jsx(zS,{}),Se.jsx(HS,{})," "]})}const Qf=TS([...[To,ba,Oo]]);function JS(){return Se.jsx("div",{className:"editor-placeholder"})}const WS={namespace:"React.js Demo",nodes:Qf,onError(y){throw y},theme:PS},VS=()=>Se.jsx(Se.Fragment,{children:"hello"});function KS({collabApiKey:y,spfList:d,userObj:g}){const[t,f]=Fe.useState(!1),[r,n]=Fe.useState([]),[e,s]=Fe.useState("demo_docId_1"),[i,l]=Fe.useState({root:null}),{userId:o,userName:a,userEmail:c}=g,u=Fe.useRef(),p={docId:e,apiKey:y,user:{name:a,id:o,email:c},hooks:{contentChanged:({source:w,content:x})=>{},usersUpdate:w=>{n(w)}}},m=()=>{u.current&&u.current.start(p).then(()=>{console.log("[Lexical Demo][codox.start] success"),f(!0)}).catch(w=>console.log("[Lexical Demo][codox.start] error",w))},b=()=>{u.current&&(console.log("Codox stoped"),u.current.stop()),f(!1)};let _={root:{children:[{children:[],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,showUI:!0}],direction:"ltr",format:"",indent:0,type:"root",version:1}};Fe.useEffect(()=>{(async()=>{if(!e)return;t&&b();let w=_;if(w)try{jS(w,Qf),l(w)}catch(x){console.error("[APP] error: ",x)}})()},[e]),Fe.useEffect(()=>{i&&e&&!t&&m()},[i,e,t]),Fe.useMemo(()=>({editorState:i?JSON.stringify({root:i.root}):null,namespace:"Playground",nodes:Qf,onError:w=>{throw w},theme:{}}),[i]);const v=()=>{let w=[],x=[];return r&&r.length>0&&r.map((S,E)=>{x.includes(S.name)||(x.push(S.name),w.push(Se.jsxs("div",{title:S.email,className:`avatarStyle avatar-color-${E+1}`,children:[" ",S.name&&S.name[0]]})))}),Se.jsx("div",{className:"flexContainer",children:w})};return console.log("iam user object",g),console.log("i am CodoxStarted",t),Fe.useEffect(()=>{setTimeout(()=>{(!u||!u.current)&&m()},5e3)},[]),Se.jsx("div",{children:t&&Se.jsxs(Ug,{initialConfig:WS,children:[v(),Se.jsxs("div",{className:"editor-container",children:[Se.jsx(qS,{}),Se.jsxs("div",{className:"editor-inner",children:[Se.jsx(O1,{contentEditable:Se.jsx(Hg,{className:"editor-input"}),placeholder:Se.jsx(JS,{}),ErrorBoundary:VS}),Se.jsx(OS,{ref:u}),Se.jsx(om,{}),Se.jsx(NS,{}),Se.jsx($g,{})]})]})]})})}Ir.Editor=KS,Object.defineProperty(Ir,Symbol.toStringTag,{value:"Module"})});
|
|
1430
1430
|
//# sourceMappingURL=index.umd.js.map
|