sykpcomposer 0.0.63 → 0.0.65
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 +2395 -2395
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +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?Xn.tooltipAnimations.hideAtOnce:Xn.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=Xn.isMousePositionWithinElementCords(d,o);d.type===_r.mouseover&&u&&(a.style.animation=this.isEditingInProgress?Xn.tooltipAnimations.hideAtOnce:Xn.tooltipAnimations.showAtOnce,s.add(c)),d.type===_r.mouseout&&(a.style.animation=Xn.tooltipAnimations.hideWithDelay,s.add(c)),d.type===_r.mousemove&&u&&(a.style.animation=this.isEditingInProgress?Xn.tooltipAnimations.hideAtOnce:Xn.tooltipAnimations.showAtOnce,s.add(c))}}_keyboardEventsListener(d){d.type===_r.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),d.type===_r.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(d){we.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(_r.keypress,this.keyboardBindedListener),window.addEventListener(_r.keyup,this.keyboardBindedListener),window.addEventListener(_r.resize,this.resizeBindedListener),window.addEventListener(_r.scroll,this.resizeBindedListener);for(const d of a0)window.addEventListener(d,this.mouseBindedListener)}unmount(){window.removeEventListener(_r.keypress,this.keyboardBindedListener),window.removeEventListener(_r.keyup,this.keyboardBindedListener),window.removeEventListener(_r.resize,this.resizeBindedListener),window.removeEventListener(_r.scroll,this.resizeBindedListener);for(const d of a0)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=we.getMainEditorState();g.read&&g.read(()=>{for(let t of this.remoteSelections)if(qf.validateJSONSelection(t,zf.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:we.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 vo=new iw;function aw(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(y=>y===Sa.editorState)}function _u(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,g=we.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)_u(r,f);return d&&d.getChildrenSize&&d.splice(d.getChildrenSize(),0,[f]),f}function xu(y){if(y.getChildren)for(let d of y.getChildren())xu(d);y.remove()}function C0(y){y.__parent=null,y.__next=null,y.__prev=null}function E0(y,d){return!!we.isLexicalEditorInstance(y)&&!(typeof d!="object"||!d.editorState||(y.update(()=>{try{let g=(0,be.$getSelection)();const t=y.parseEditorState(d.editorState);if(t.isEmpty())return(0,be.$getRoot)().clear(),!0;(0,be.$setSelection)(g),y.setEditorState(t)}catch(g){le.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",g)}}),0))}function sw(y,d){let g=d;for(const t of y)g=g[t];return g}function Ea(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=sw(y,g?d:we.getMainEditorState().toJSON());return f&&(t=ka(f)?(0,be.$getRoot)():jn.get(f.codoxId)),t||le.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:f,lexicalNode:t,pathArray:y,currentStateJSON:we.getMainEditorState().toJSON(),newStateJSON:d,codoxNodes:jn.nodesToArray(),searchInNewState:g}),t||(g?t:Ea(y,d,!0))}function k0(y){le.log("[applyFullLexicalStateReplace] clear current state and apply new");const d=(0,be.$getRoot)();d.clear();let g=we.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 lw(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=aw(t),i=s!==-1,l=g.hasOwnProperty("lm")&&typeof g.lm=="number";if(t.length)if(i){let o=s-1,a=Ea(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=Ll(t[o]);E0(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=Ea(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:xu(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=_u(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(we.isLexicalEditorInstance(S[E])){let k={editorState:S[E].getEditorState().toJSON()};E0(x[E],k)}else{let k=Ff(E),D=m[k];if(D===x[E]||!m.hasOwnProperty(k))continue;let P=D!==void 0&&S[E]!==D?D:S[E];k!=="height"&&k!=="width"||S[E]==="inherit"&&D===0&&(P=S[E]),x[E]=P}S.remove(),C0(x),v=x,delete c[m.codoxDId]}}v||(v=_u(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(),C0(m),xu(m),delete c[p]}}else{let c=o.map(u=>_u(u));a.splice(0,a.getChildrenSize(),c)}}if(n){if(g.ld){const o=g.ld,a=jn.get(o.codoxId);a.getChildrenSize&&a.getChildrenSize()?xu(a):a.remove()}if(g.li){let o=we.getMainEditorNodesClassesMap();const a=g.li,c=o.get(a.type).klass.importJSON(a);if(t.length===1&&t[0]==="root")(0,be.$getRoot)().splice(0,0,[c]);else{const u=t[t.length-1];t.length=t.length-2;let h=Ea(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=Ea(o,y);if(u)try{let h=u.getWritable();if(a){let p=Object.keys(a);for(let m of p)h[Ll(m)]=a[m]}if(c){let p=Object.keys(c);for(let m of p)delete h[Ll(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=Ea(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=Ll(o);t.length=t.length-1;let c,u=Ea(t,y);if(!u){le.error("Missing node when update node attr from delta: ",{path:t,delta:g,fullStateJSON:y,currentEditorState:we.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=sx(h)),o==="direction"&&(u.hasOwnProperty(a)||(a="__dir")),!c.hasOwnProperty(a)){let p=Object.keys(c);for(let m of p){let b=Ff(m);if(o.startsWith(b)){a=m;break}}}c[a]=h}}else if(g.oi&&g.oi.root)return k0(g.oi)}}else le.log("[applyDeltasToLexicalState] stop, no deltas: ",d)}function cw(y){let d=y.clipboardData.getData(cx.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){jn.clearPastedIds();const t=f=>{if(f.codoxId&&jn.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 uw=y=>{var d={};return on.d(d,y),d};const O0=uw({useCollaborationContext:()=>w_});var dw=y=>{var d={};return on.d(d,y),d};const Fi=dw({LexicalComposerContext:()=>Ef,useLexicalComposerContext:()=>jr});class T0{constructor(){this.blacklist=Object.keys(s0).reduce((d,g)=>{let t=s0[g];return d[g]=t.reduce((f,r)=>(f[r]=r,f),{}),d},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(d){return d instanceof be.TextNode||d instanceof be.ParagraphNode||d instanceof be.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(Jf||g!==Jr.created||this._isBlacklistedFound||!d||!d.__type||this._shouldSkipNode(d))return;let f=t||we.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!==Jr.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 fw=new T0,zi=fw,pw=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function hw(y,d){if(y==null)return{};var g,t,f=gw(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 gw(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 mw{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(d,g){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:s}=f,i=(hw(f,pw),we.getMainEditor()),l=we.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),c=Hf(o,a),u=r._selection,h=n._selection,p=!1,m=null,b=we.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}),zi.isBlacklistedFound())return t=!0,le.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),we.scanLexicalNodeForNestedEditorAttribute(d)?(_.update(()=>{try{const v=_.parseEditorState(a);if(v.isEmpty())return(0,be.$getRoot)().clear(),!0;_.setEditorState(v)}catch(v){le.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",v)}}),void zi.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=Ff(g),x=$e.lexicalToJSONNested(u,w,v);m=we.getCurrentNestedSelectionJSON(),p=$e.equalSelectionsJSON(m,x),p||we.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}),we.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(!we.getLexicalNodeByKey(d)){let g=this.nestedEditorsListenersMap[d];g&&g(),delete this.nestedEditorsListenersMap[d]}}manageNestedEditorInLexicalNode(d){if(this._isNestedEditorManaged(d.getKey()))return;let g=we.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===Jr.created){let p=t.getEditorState()._nodeMap.get(u);p&&zi.trackBlacklistedInNestedEditor(p,h,t.getEditorState(),d)}});r.push(a)});let n=(0,bs.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,be.$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 yw=new mw,si=yw,bw=function(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let g=(0,be.createEditor)({namespace:"validation",nodes:[...d],onError:e=>{throw e},parentEditor:null});const t=new T0,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,Jr.created,r),t.isBlacklistedFound()))throw new Error(ux)}}catch(g){throw g}};class vw{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===Li.BOTH||s.__headerState===Li.ROW),e=d.some((s,i)=>{if(s.__size<f)return!1;let l=s.getChildAtIndex(t);return!(!l||l.__headerState!==Li.BOTH&&l.__headerState!==Li.COLUMN)});return n&&e?r=Li.BOTH:n&&!e?r=Li.ROW:e&&!n&&(r=Li.COLUMN),r}_isValidCellChildren(d){for(let g of d)if(Cs(g)||!Ss(g)&&En(g))return!1;return!0}_createEmptyCell(){let d=(0,kn.$createTableCellNode)();return d.append((0,be.$createParagraphNode)()),d}_wrapInvalidCellChildrenIntoParagraph(d){let g=(0,be.$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,be.$getNodeByKey)(d);for(;g;){let f=(0,kn.$createTableCellNode)().append((0,be.$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,be.$getNodeByKey)(d).append((0,be.$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,be.$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,be.$getNodeByKey)(d),t=(0,kn.$createTableRowNode)();t.append(this._createEmptyCell()),g.append(t)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(d,g){return()=>{for(g||(g=1);g;)(0,be.$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,be.$getNodeByKey)(d);if(!t)return;let f=(0,be.$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,kn.$createTableRowNode)();if((0,kn.$isTableCellNode)(f))f.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(f):f.append((0,be.$createParagraphNode)()),e.append(f);else{let s=this._isValidCellChildren([f]),i=(0,kn.$createTableCellNode)();if(e.append(i),s)i.append(f);else{let l=(0,be.$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,be.$getNodeByKey)(d);if(!t)return;let f=(0,be.$getNodeByKey)(g);if(f.remove(),f=(0,be.$createParagraphNode)(),!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling(),e=(0,kn.$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,be.$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,be.$getNodeByKey)(d);t&&(t=t.getWritable(),t.__headerState=g)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(d){let g=we.getMainEditorState()._selection;if(le.debug(`[${d}]`,{selection:g}),!(0,be.$isRangeSelection)(g))return;let t=[];try{let f=we.getLexicalNodeByKey(g.anchor.key),r=we.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,kn.$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}),we.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(d=>{let g=(0,be.$getNodeByKey)(d);g&&g.remove()}),this.removeCandidateTableKeys.clear(),(0,be.$addUpdateTag)(no.historic)})}tableUpdateListener(d){this.validateTableCandidateKeys.add(d)}tableRowNodeChangesListener(d){let g=arguments.length>1&&arguments[1]!==void 0&&arguments[1],t=we.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=we.getLexicalNodeByKey(d);if(!g||!g.__parent)return;let t=we.getLexicalNodeByKey(g.__parent);t&&t.__parent&&this.validateTableCandidateKeys.add(t.__parent)}shouldValidateUpdatedTables(){return!!this.validateTableCandidateKeys.size}validateUpdatedTables(){let d=Array.from(this.validateTableCandidateKeys);return we.getMainEditorState().read(()=>{for(let g of d){let t=we.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,kn.$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,kn.$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===Li.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=we.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,be.$addUpdateTag)(no.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 No=new vw,_w=["contentChanged"],xw=["state","remoteSelection"];function j0(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 xs(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?j0(Object(g),!0).forEach(function(t){ww(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):j0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function ww(y,d,g){return(d=Sw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function Sw(y){var d=Cw(y,"string");return typeof d=="symbol"?d:d+""}function Cw(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 A0(y,d){if(y==null)return{};var g,t,f=Ew(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 Ew(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 Jf={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 kw=y=>async()=>{const{state:d,timestamp:g}=await y();if(!we.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 wu=0,li=null,Vf=!1,_o={},Wf={};const Ow=(0,Gt.forwardRef)((y,d)=>{let{onBlacklistedInsert:g}=y;const t=(0,Gt.useContext)(Fi.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,Fi.useLexicalComposerContext)(),r=(0,O0.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}),we.setMainEditor(f),jn.gcAbandonedNodes(),si.gc(),No.clear(),le.log("[useEffect][editor] subscribe to editor changes");const b=(0,bs.mergeRegister)(f.registerUpdateListener(h),f.registerCommand(be.PASTE_COMMAND,cw,be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.UNDO_COMMAND,()=>{we.setUndoInvoked(!0)},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.REDO_COMMAND,()=>{we.setRedoInvoked(!0)},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.KEY_DELETE_COMMAND,(v,w)=>{No.tableRemoveEventListener("KEY_DELETE_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.KEY_BACKSPACE_COMMAND,(v,w)=>{No.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.CUT_COMMAND,(v,w)=>{No.tableRemoveEventListener("CUT_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),...p());vo.mount(),we.alignStateSelectionJSONsFromLatestEditor(),le.debug("New editor mounted: ",{isCodoxStarted:we.isCodoxStarted,codoxLexicalEditorManager:we,nestedEditorsProcessor:si});let _=f._onError;return f._onError=v=>{le.error("[ERROR HANDLER WRAPPER] error from editor: ",v),_&&_(v),u()},g&&zi.setClientCallback(g),()=>{we.getMainEditorKey()&&(le.debug("Unmount prev editor"),b(),we.removeMainEditor(),vo.unmount(),we.clearJSONs(),Cn.clear(),No.clear(),we.isCodoxStarted&&(le.debug("EDITOR USE_EFFECT stopping codox"),n(),we.setIsCodoxStarted(!1)),zi.removeClientCallback())}},[f]);const n=()=>{we.isCodoxStarted&&(le.log("[stopCodoxInstance] stopping codox"),we.setIsCodoxStarted(!1),Jf||ti().stop(),we.clearJSONs(),jn.clearAll(),vo.clear(),Cn.resetComments(),si.clearListeners())},e=async b=>{le.debug("[startCodoxInstance] invoked"),ti().createNewInstance(),le.debug("[startCodoxInstance] instance created");for(let O in Wf)ti().instance.on(O,Wf[O]);if(le.debug("[startCodoxInstance] events subscribed"),_o=b,li=_o.docId,!li)return le.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:li});let _=Cn.initialCommentsExist();le.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(Cn.activateInitialComments(f,jn),le.log("[activateInitialComments] "));let v=we.getMainEditorState().toJSON();if(!we.isValidJSONState(v))throw le.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:li,initJSONState:v}),new Error("start codox skipped - invalid init state");le.log("[startCodoxInstance] starting codox with: ",{docId:li,initJSONState:v,config:_o,codoxComments:Cn}),we.currentContentStateJSON||we.setCurrentContentStateJSON(v),we.isCodoxStarted&&n();let{username:w,apiKey:x,getServerState:S,domain:E="",demo:k=!1,hooks:D}=_o;D&&D.fetchDocOnNetworkReconnect&&(D.fetchDocOnNetworkReconnect=kw(D.fetchDocOnNetworkReconnect));const P=A0(D,_w);await ti().start(ti().createConfig(xs(xs({},_o),{},{docId:li,username:w,apiKey:x,domain:E,hooks:xs({syncState:l,getState:i,getServerState:async()=>await S(li)},P),editorInstanceHooks:{getSelection:()=>we.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:we.getCurrentActiveSelectionJSON()},vo.getCurrentRemoteSelections()),Cn.setAllComments(A)},enableEditor:()=>{we.disableEditorReadOnlyMode()},disableEditor:()=>{we.enableEditorReadOnlyMode(),vo.updateRemoteSelections([])},getContent:()=>{let O=we.composeFullStateWithRootAndComments();return le.info("[getContent]: ",O),{state:O}}},appServer:_o.appServer,demo:k}))),le.log("[startCodoxInstance] codox started - first sync invoking"),we.setIsCodoxStarted(!0),r.clientID=_o.username,r.name=_o.username,c()},s=()=>{let b=we.composeFullStateWithRootAndComments({directlyFromEditor:!0});e(b)},i=()=>({state:xs(xs({},we.getMainEditorState().toJSON()),{},{comments:Cn.getAllComments()}),docId:li}),l=b=>{if(!we.isCodoxStarted)return;le.log("[SYNC_STATE]: Before sync payload = ",b);const _=ti().sync({meta:b}),{state:v,remoteSelection:w=[]}=_,x=A0(_,xw);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}=we.extractStateAndCommentsFromSynced(S);if(!we.isValidJSONState(E.state))return le.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:E.state}),s();a(E,w),Cn.setAllComments(k)},o=b=>{if(!we.isCodoxStarted||(le.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:b}),!qf.validateJSONSelection(b,zf.local)))return;let _=we.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=si.setNestedEditorSelection(b);we.setNestedSelectionJSON(x?b:null)}else(0,be.$setSelection)(w),we.setMainSelectionJSON(b);le.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:we.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=we.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=Hf(S,b),k=$e.equalSelectionsJSON(we.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(we.addUpdateTag({isSameState:E,isSameSelection:k,updateTag:x}),v)le.log("[updateEditor] invoke full stateReplace after sync"),k0(b),S=we.setCurrentContentStateJSON(b),(0,be.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S);else{le.log("[updateEditor] invoke deltas diff");let P=ti().diff(S,b,{keyNames:{default:"codoxId"}});le.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:b,deltas:P&&JSON.parse(JSON.stringify(P))}),P&&P.length&&(le.log("[updateEditor] apply deltas to lexical state"),lw(b,P),S=we.setCurrentContentStateJSON(b),(0,be.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(qf.validateJSONSelection(_,zf.local)||(_=we.getCurrentActiveSelectionJSON()),D){let P=si.setNestedEditorSelection(_);we.setNestedSelectionJSON(P?_:null),le.log("[updateEditor] nested selection updated",P?_:null)}else if(_!==void 0){const P=$e.JSONToLexical(_);le.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:P}),(0,be.$setSelection)(P),we.setMainSelectionJSON(_),le.log("[updateEditor] selection updated",_)}},{onUpdate:()=>{E||vo.updateRemoteSelections(w,"from onUpdate hook")}}),E&&vo.updateRemoteSelections(w,"from direct updateEditor")},c=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";if(!we.isCodoxStarted)return;le.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:b});let _=we.composeFullStateWithRootAndComments();const v={docId:li,state:{state:_,selection:we.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}=ti().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}=we.extractStateAndCommentsFromSynced(E);if(!we.isValidJSONState(k.state))return le.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),s();a(k,x),Cn.setAllComments(D)},u=()=>{le.warn("[rollbackStateDuringUpdateError] rollback invoked"),le.log("[rollbackStateDuringUpdateError] values: ",{prevState:we.getPrevContentStateJSON(),currentState:we.getCurrentContentStateJSON(),prevSelection:we.getPrevMainSelectionJSON(),currentSelection:we.getCurrentActiveSelectionJSON(),codoxComments:Cn});let b=we.getPrevContentStateJSON(),_=we.getPrevMainSelectionJSON();a({state:b,selection:_},vo.getCurrentRemoteSelections(),no.historic);let v=we.undoInvoked(),w=we.redoInvoked();Cn.gcAbandonedNodeKeys(we.getMainEditorState()._nodeMap),v&&f.dispatchCommand(be.CAN_REDO_COMMAND,!1),w&&f.dispatchCommand(be.CAN_UNDO_COMMAND,!1)},h=b=>{let{editorState:_,prevEditorState:v,tags:w,dirtyElements:x,dirtyLeaves:S}=b;if(Vf)return Vf=!1,void le.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(zi.isBlacklistedFound())return Vf=!0,le.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((W,G)=>{let F=null,q=null;G.read(()=>{F=$e.lexicalToJSON(G._selection),q=G.toJSON()});let T=null,I=null;W.read(()=>{let L=(0,be.$getSelection)();I=$e.lexicalToJSON(L),T=W.toJSON()}),we.setCurrentContentStateJSON(T),we.setMainSelectionJSON(I),a({state:q,selection:F},vo.getCurrentRemoteSelections(),no.historic),f.dispatchCommand(be.CAN_REDO_COMMAND,!1),f.dispatchCommand(be.CAN_UNDO_COMMAND,!1)})(_,v),void zi.invokeClientCallback();if(!No.ensureDocTablesAreValid(_))return;wu++,le.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:wu,isCodoxStarted:we.isCodoxStarted});let E=we.isOnlySelectionChanged(x,S),k=null,D=null,P=null,O=null,R=we.getCurrentContentStateJSON(),A=w.has("codox_sync_state_changes"),z=w.has(Bl),H=we.undoInvoked(),$=we.redoInvoked(),M=we.canUndo(),J=we.canRedo();k=_.toJSON(),D=v.toJSON(),v.read(()=>{O=$e.lexicalToJSON(v._selection)}),_.read(()=>{let W=(0,be.$getSelection)();P=$e.lexicalToJSON(W);let G=$e.JSONToLexical(P),F=W===null&&G===null||W.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(Cn.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(P)),currentMainSelectionJSON:JSON.parse(JSON.stringify(we.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(we.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(we.getCurrentActiveSelectionJSON())),lexicalSelection:W,convertedBackMainSelection:G,isMainSelectionConvertionCorrect:F,nodes:f._editorState._nodeMap,fullEditor:f,codoxNodesMap:jn.toArray(),codoxComments:Cn,isUpdateFromSync:A,isUpdateFromComments:z,tags:w,onlySelectionChanged:E,undoInvoked:H,redoInvoked:$,canUndo:M,canRedo:J})});let K=Hf(R,k),N=$e.equalSelectionsJSON(we.getCurrentActiveSelectionJSON(),P);le.log("[editorUpdatesListener] compares: ",{isStateSame:K,isSelectionSame:N});let U=K&&N&&!z;if(!K||z||A){let W=xs({},K?R:k),G=Cn.getAllComments();G.length&&(W.commentThreads=G);let F={source:A?l0.remote:l0.local,content:W};_o.hooks&&_o.hooks.contentChanged&&_o.hooks.contentChanged(F),ti().instance.emit("content_changed",F)}if(U)le.log("[editorUpdatesListener] STOP - state and selection and comments are same ",wu);else if(we.undoInvoked()&&we.setUndoInvoked(!1),we.redoInvoked()&&we.setRedoInvoked(!1),we.setCurrentContentStateJSON(k),we.setPrevContentStateJSON(D),we.setMainSelectionJSON(P),we.setPrevMainSelectionJSON(O),Jf){let W=we.getCurrentActiveSelectionJSON();a({state:we.getCurrentContentStateJSON(),selection:W},[])}else c(wu)},p=()=>{let b=[];return we.getMainEditorNodesClassesMap().forEach((_,v,w)=>{let{klass:x}=_,S=f.registerMutationListener(x,E=>{for(let[k,D]of E){if(!Jr[D])continue;const P=we.getLexicalNodeByKey(k);if(D===Jr.created&&P&&zi.trackBlacklisted(P,D),x.name===kn.TableNode.name&&(D===Jr.destroyed?No.tableNodeRemoveListener(k):No.tableUpdateListener(k)),x.name===kn.TableRowNode.name&&D!==Jr.destroyed&&No.tableRowNodeChangesListener(k,D===Jr.updated),x.name===kn.TableCellNode.name&&D===Jr.updated&&No.tableCellNodeChangesListener(k),x.name===eo.MarkNode.name&&(le.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:P,mutationType:D,codoxComments:Cn}),D===Jr.destroyed?Cn.removeRelatedNodeKey(k):P&&Cn.addRelatedNodeKey(P.__key,P.__ids,D===Jr.created)),P&&P.codoxId){if(D===Jr.destroyed)return void(P.codoxId&&jn.remove(P.codoxId));B0(P)||le.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:D,node:P}),jn.add(P.codoxId,P)}}b.push(S)})}),b},m={start:e,stop:n,on:(b,_)=>{le.info(`Subscribing client to codox ${b} event`),Wf[b]=_},cursor:{hide:()=>{vo.hideRemoteSelectionsFromUI()},show:()=>{vo.showHiddenRemoteSelectionsInUI()}},initComments:b=>{Cn.setInitialComments(b)}};return(0,Gt.useImperativeHandle)(d,()=>m),null}),Tw=Ow,jw=["comments"];function P0(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 Kf(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?P0(Object(g),!0).forEach(function(t){Aw(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):P0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function Aw(y,d,g){return(d=Pw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function Pw(y){var d=Nw(y,"string");return typeof d=="symbol"?d:d+""}function Nw(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=Rw(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 Rw(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 Mw extends i0{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,be.$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:Kf({},Iw(d.state,jw)),selection:t,stateReplace:f},commentsFromSync:g}}composeFullStateWithRootAndComments(){let{directlyFromEditor:d=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Kf(Kf({},d?this.getMainEditorState().toJSON():this.currentContentStateJSON),{},{comments:Cn.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 be.ElementNode,o=i.prototype instanceof be.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,be.$addUpdateTag)(f)):t?(le.log(`[addUpdateTag] add "${no.historic}" tag - change invoked by nested editor`),void(0,be.$addUpdateTag)(no.historic)):void(d?(le.log(`[addUpdateTag] add "${no.historic}" tag - state is same`),(0,be.$addUpdateTag)(no.historic)):(le.log(`[addUpdateTag] add "${no.historyMerge}" tag - state is different`),(0,be.$addUpdateTag)(no.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const Dw=new Mw,we=Dw;class Lw{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=we.getMainEditorState();if(!d._nodeMap)return;let g=this.nodesToArray();for(let t of g)d._nodeMap.has(t.__key)||this.remove(t.codoxId)}}const Bw=new Lw,jn=Bw;function N0(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 I0(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?N0(Object(g),!0).forEach(function(t){Fw(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):N0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function Fw(y,d,g){return(d=zw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function zw(y){var d=Uw(y,"string");return typeof d=="symbol"?d:d+""}function Uw(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 Gf=()=>G_(),R0=y=>typeof y=="number";function ws(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 ka=y=>y.__type==="root"||y.type==="root",M0=y=>ka(y.getParent()),$n=y=>y.__type===mu.text||y.type===mu.text||y.hasOwnProperty("__text")||y.hasOwnProperty("text"),Ss=y=>(0,be.$isElementNode)(y),Cs=y=>(0,kn.$isTableNode)(y)||(0,kn.$isTableRowNode)(y)||(0,kn.$isTableCellNode)(y),$w=y=>!y.getChildren,D0=y=>!!y.getChildren,En=y=>(0,be.$isDecoratorNode)(y),zl=y=>(0,U_.$isLinkNode)(y),Ul=y=>y.__type==="mark"||y.type==="mark",Yf=y=>(0,be.$isLineBreakNode)(y),Ui=y=>$n(y)||Yf(y),Zf=y=>y.__type===mu.horizontalrule||y.type===mu.horizontalrule,L0=y=>{if(Ui(y)||zl(y)||Ul(y))return!1;if(!y.__parent||y.__parent==="root"||(0,be.$isParagraphNode)(y))return!0;let d=y.getParent().getChildren();return d.length===1&&d[0].__key===y.__key?!((En(y)||zl(y)||Ul(y))&&!Zf(y)):!d.some(g=>{let t=Zf(g);return g.__key!==y.__key&&(Ui(g)||En(g)&&!t||zl(g)||Ul(g))})},B0=y=>{const d=jn.get(y.codoxId);return!d||y.__key===d.__key},Es=function(y){const d=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||Gf();y.codoxId=d,jn.add(d,y)},F0=y=>{jn.remove(y.codoxId),delete y.codoxId},Hw=y=>{if(!D0(y)||!y.getChildrenSize())return;const d=y.getChildren();if(d.some(f=>!!(0,be.$isParagraphNode)(f)))return;let g=!1,t=[];for(let f of d)(Ui(f)||En(f)||zl(f)||Ul(f))&&!g&&(Zf(f)||(g=!0)),(D0(f)||En(f))&&t.push(f);for(let f of t)g||f.codoxId?g&&f.codoxId&&(f=f.getWritable(),F0(f)):(f=f.getWritable(),Es(f))},qw=y=>{const d=I0({},y);for(const g in y)y[g]===void 0&&y.hasOwnProperty(g)&&delete d[g];return d},Jw=y=>{const d=`__nativeCreateDOM_${y.name}`;y.prototype[d]=ws(y.prototype.createDOM,d),y.prototype.createDOM=function(g,t){if(L0(this))if(this.codoxId){if(!B0(this)){let r=jn.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}),jn.add(this.codoxId,this)):Es(this)}}else Es(this);else this.codoxId&&F0(this);En(this)&&!this.codoxDId&&(this.codoxDId=Gf()),si.manageNestedEditorInLexicalNode(this);let f=this[d](g,t);return f.__codox_track=!0,f}},Vw=y=>{const d=`__nativeUpdateDOM_${y.name}`;return y.prototype[d]=ws(y.prototype.updateDOM,d),y.prototype.updateDOM=function(){const g=this[d](...arguments);return Hw(this),g},y},Ww=y=>{const d=`__nativeRemove_${y.name}`;return y.prototype[d]=ws(y.prototype.remove,d),y.prototype.remove=function(){const g=this.codoxId;return g&&jn.remove(g),si.gcNestedEditorListenerInLexicalNode(this),this[d](...arguments)},y},Kw=y=>{const d=`__nativeExportJSON_${y.name}`;y.prototype[d]=ws(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),$n(this)&&R0(g.format)&&this.hasFormat&&(g.format=ax(this)),qw(g)}},Gw=y=>{const d="__nativeImportJSON";y[d]=ws(y.importJSON,d),y.importJSON=function(g){const t=I0({},g);$n(t)&&!R0(t.format)&&(t.format=ix(t.format));const f=y[d](t);si.manageNestedEditorInLexicalNode(f);const r=L0(f);return r&&t.codoxId&&(jn.hasPastedId(t.codoxId)&&jn.has(t.codoxId)?(jn.removePastedId(t.codoxId),Es(f)):Es(f,t.codoxId)),r&&!f.codoxId&&Es(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},Yw=y=>{const d="__nativeClone";y[d]=ws(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),si.manageNestedEditorInClonedLexicalNode(g,t),t}},Zw=y=>{let d=!1,g=!1,t=!1,f=!1;y.forEach(n=>{n.name===be.TextNode.name?d=!0:n.name===be.ParagraphNode.name?g=!0:n.name===be.LineBreakNode.name?t=!0:n.name===eo.MarkNode.name&&(f=!0)});let r=[];return d||r.push(be.TextNode),g||r.push(be.ParagraphNode),t||r.push(be.LineBreakNode),f||r.push(eo.MarkNode),r.length?[...r,...y]:y},Qw=function(){return Zw(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(y=>(y.hasOwnProperty("__isCodoxExtended")||(Jw(y),Vw(y),Kw(y),Ww(y),Gw(y),Yw(y),Object.defineProperty(y,"__isCodoxExtended",{value:!0,writable:!1})),y))};var Su=on(777),ks={};ks.styleTagTransform=ai(),ks.setAttributes=oi(),ks.insert=ri().bind(null,"head"),ks.domAPI=ni(),ks.insertStyleElement=ii(),ei()(Su.A,ks),Su.A&&Su.A.locals&&Su.A.locals;var Xw=y=>{var d={};return on.d(d,y),d};const tS=Xw({AutoFocusPlugin:()=>Qg});var eS=y=>{var d={};return on.d(d,y),d};const nS=eS({ClearEditorPlugin:()=>C_});var rS=y=>{var d={};return on.d(d,y),d};const oS=rS({LexicalComposer:()=>Zg});var iS=y=>{var d={};return on.d(d,y),d};const z0=iS({default:()=>k_});var aS=y=>{var d={};return on.d(d,y),d};const sS=aS({HistoryPlugin:()=>hm});var lS=y=>{var d={};return on.d(d,y),d};const cS=lS({OnChangePlugin:()=>T_});var uS=y=>{var d={};return on.d(d,y),d};const dS=uS({PlainTextPlugin:()=>D_});var fS=y=>{var d={};return on.d(d,y),d};const U0=fS({$isRootTextContentEmpty:()=>mm,$rootTextContent:()=>gm});var pS=y=>{var d={};return on.d(d,y),d};const Os=pS({createPortal:()=>Qb.createPortal}),hS=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,gS=hS?Gt.useLayoutEffect:Gt.useEffect,$0=gS;var Cu=on(253),Ts={};Ts.styleTagTransform=ai(),Ts.setAttributes=oi(),Ts.insert=ri().bind(null,"head"),Ts.domAPI=ni(),Ts.insertStyleElement=ii(),ei()(Cu.A,Ts),Cu.A&&Cu.A.locals&&Cu.A.locals;function mS(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 yS(y){let{onClose:d,children:g,title:t,closeOnClickOutside:f=!1}=y;return(0,Os.createPortal)(Gt.createElement(mS,{onClose:d,title:t,closeOnClickOutside:f},g),document.body)}function H0(){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(yS,{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 Eu=on(191),js={};js.styleTagTransform=ai(),js.setAttributes=oi(),js.insert=ri().bind(null,"head"),js.domAPI=ni(),js.insertStyleElement=ii(),ei()(Eu.A,js),Eu.A&&Eu.A.locals&&Eu.A.locals;const bS={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"}},vS=bS;var ku=on(72),As={};As.styleTagTransform=ai(),As.setAttributes=oi(),As.insert=ri().bind(null,"head"),As.domAPI=ni(),As.insertStyleElement=ii(),ei()(ku.A,As),ku.A&&ku.A.locals&&ku.A.locals;function _S(){for(var y=arguments.length,d=new Array(y),g=0;g<y;g++)d[g]=arguments[g];return d.filter(Boolean).join(" ")}function Qf(){return Qf=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},Qf.apply(null,arguments)}function $i(y){let{"data-test-id":d,children:g,className:t,onClick:f,disabled:r,small:n,title:e}=y;return Gt.createElement("button",Qf({disabled:r,className:_S("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},d&&{"data-test-id":d}),g)}var Ou=on(129),Ps={};Ps.styleTagTransform=ai(),Ps.setAttributes=oi(),Ps.insert=ri().bind(null,"head"),Ps.domAPI=ni(),Ps.insertStyleElement=ii(),ei()(Ou.A,Ps),Ou.A&&Ou.A.locals&&Ou.A.locals;var xS=y=>{var d={};return on.d(d,y),d};const wS=xS({ContentEditable:()=>Xg});function SS(y){let{className:d}=y;return Gt.createElement(wS.ContentEditable,{className:d||"ContentEditable__root"})}var Tu=on(457),Ns={};Ns.styleTagTransform=ai(),Ns.setAttributes=oi(),Ns.insert=ri().bind(null,"head"),Ns.domAPI=ni(),Ns.insertStyleElement=ii(),ei()(Tu.A,Ns),Tu.A&&Tu.A.locals&&Tu.A.locals;function CS(y){let{children:d,className:g}=y;return Gt.createElement("div",{className:g||"Placeholder__root"},d)}const ES=z0.default.LexicalErrorBoundary||z0.default,kS=()=>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"})),q0=()=>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"})),OS=()=>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 J0(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 Cn.createNewCommentObj({content:y,author:d,codoxId:g,timeStamp:t,deleted:f})}function jS(y,d,g){return Cn.createNewThreadObj({quote:y,comments:d,codoxId:g})}function AS(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]),$0(()=>{r()},[d,g,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(kS,null)))}function PS(y){let{onEscape:d}=y;const[g]=(0,Fi.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>g.registerCommand(be.KEY_ESCAPE_COMMAND,t=>d(t),2),[g,d]),null}function NS(y){let{editorRef:d}=y;const[g]=(0,Fi.useLexicalComposerContext)();return typeof d=="function"?d(g):typeof d=="object"&&(d.current=g),null}function V0(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:vS};return Gt.createElement(oS.LexicalComposer,{initialConfig:s},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(dS.PlainTextPlugin,{contentEditable:Gt.createElement(SS,{className:d}),placeholder:Gt.createElement(CS,null,n),ErrorBoundary:ES}),Gt.createElement(cS.OnChangePlugin,{onChange:f}),Gt.createElement(sS.HistoryPlugin,null),g!==!1&&Gt.createElement(tS.AutoFocusPlugin,null),Gt.createElement(PS,{onEscape:t}),Gt.createElement(nS.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(NS,{editorRef:r})))}function W0(y,d){return(0,Gt.useCallback)((g,t)=>{g.read(()=>{y((0,U0.$rootTextContent)()),d(!(0,U0.$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=Y0(),a=(0,Gt.useCallback)(()=>{d.getEditorState().read(()=>{const u=(0,be.$getSelection)();if((0,be.$isRangeSelection)(u)){l.current=u.clone();const h=u.anchor,p=u.focus,m=(0,Ca.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,Ca.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,P=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=P-1;O>=E;O--){const R=D[O];k.removeChild(R),D.pop()}}}})},[d,i]);$0(()=>{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=W0(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:s},Gt.createElement(V0,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:u=>(u.preventDefault(),g(),!0),onChange:c}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement($i,{onClick:g,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement($i,{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(jS(u,[J0(f,o)]),!0,void 0,l.current),l.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function RS(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=Y0(),l=W0(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(V0,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:l,editorRef:s,placeholder:t}),Gt.createElement($i,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){d(J0(f,i),!1,g);const o=s.current;o!==null&&o.dispatchCommand(be.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(OS,null)))}function K0(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($i,{onClick:()=>{g(d,f),t()}},"Delete")," ",Gt.createElement($i,{onClick:()=>{t()}},"Cancel")))}function G0(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]=H0();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($i,{onClick:()=>{s("Delete Comment",i=>Gt.createElement(K0,{commentOrThread:d,deleteCommentOrThread:g,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(q0,null)),e))}function MS(y){let{activeIDs:d,comments:g,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=y;const[e]=(0,Fi.useLexicalComposerContext)(),[s,i]=(0,Gt.useState)(0),[l,o]=H0(),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,be.$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($i,{onClick:()=>{o("Delete Thread",p=>Gt.createElement(K0,{commentOrThread:c,deleteCommentOrThread:t,onClose:p}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(q0,null)),l),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},c.comments.map(p=>Gt.createElement(G0,{key:p.codoxId,comment:p,deleteComment:t,thread:c,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(RS,{submitAddComment:r,thread:c,placeholder:"Reply to comment..."})))}return Gt.createElement(G0,{key:u,comment:c,deleteComment:t,rtf:a})}))}function DS(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(MS,{activeIDs:d,comments:t,deleteCommentOrThread:g,listRef:n,submitAddComment:f,markNodeMap:r}))}function Y0(){const y=(0,O0.useCollaborationContext)(),{yjsDocMap:d,name:g}=y;return g||"Playground User"}function LS(y){const[d]=(0,Fi.useLexicalComposerContext)(),g=vx(),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,be.$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}),Cn.removeComment(p.codoxId,h.codoxId),!p)return;const m=p.codoxId,b=t.get(m);d.update(()=>{b?b.forEach((_,v)=>{const w=(0,be.$getNodeByKey)(v);le.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:w}),w&&w.markDirty()}):(0,be.$getRoot)().markDirty(),(0,be.$addUpdateTag)(no.historic),(0,be.$addUpdateTag)(Bl)})}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,be.$getNodeByKey)(_);le.log("[deleteCommentOrThread]: type thread new values",{node:v}),(0,eo.$isMarkNode)(v)&&(v.deleteID(m),v.getIDs().length===0&&(0,eo.$unwrapMarkNode)(v))}else(0,be.$getRoot)().markDirty(),le.debug("[deleteCommentOrThread][refreshComments]");Cn.refreshComments(!0),(0,be.$addUpdateTag)(Bl)})})}},[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?Cn.addComment(m.codoxId,h):Cn.addCommentThread(h),p)d.update(()=>{if((0,be.$isRangeSelection)(b)){const _=b.isBackward(),v=h.codoxId;(0,eo.$wrapSelectionInMarkNode)(b,_,v),(0,be.$addUpdateTag)(Bl)}}),i(!1);else if(!p&&m){const _=m.codoxId,v=t.get(_);if(!v)return void Cn.removeComment(m.codoxId,h.codoxId);d.update(()=>{v.forEach((w,x)=>{let S=(0,be.$getNodeByKey)(x);S&&S.markDirty()}),(0,be.$addUpdateTag)(no.historic),(0,be.$addUpdateTag)(Bl)})}},[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,bs.mergeRegister)((0,bs.registerNestedElementResolver)(d,eo.MarkNode,p=>(0,eo.$createMarkNode)(p.getIDs()),(p,m)=>{p.getIDs().forEach(b=>{m.addID(b)})}),d.registerMutationListener(eo.MarkNode,p=>{d.getEditorState().read(()=>{for(const[m,b]of p){const _=(0,be.$getNodeByKey)(m);let v=[];b==="destroyed"?v=h.get(m)||[]:(0,eo.$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,be.$getSelection)();let v=!1,w=!1;if((0,be.$isRangeSelection)(_)){const x=_.anchor.getNode();if((0,be.$isTextNode)(x)){const S=(0,eo.$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,be.$isRangeSelection)(_)&&i(!1)})}),d.registerCommand($f,()=>{const p=window.getSelection();return p!==null&&p.removeAllRanges(),i(!0),!0},be.COMMAND_PRIORITY_EDITOR))},[d,t]),Gt.createElement(Gt.Fragment,null,s&&(0,Os.createPortal)(Gt.createElement(IS,{editor:d,cancelAddComment:a,submitAddComment:u}),document.body),f!=null&&!s&&(0,Os.createPortal)(Gt.createElement(AS,{anchorKey:f,editor:d,onAddComment:()=>{d.dispatchCommand($f,void 0)}}),document.body),(0,Os.createPortal)(Gt.createElement($i,{className:"CodoxCommentPlugin_ShowCommentsButton "+(l?"active":""),onClick:()=>o(!l),title:l?"Hide Comments":"Show Comments"},Gt.createElement(TS,null)),document.body),l&&(0,Os.createPortal)(Gt.createElement(DS,{comments:g,submitAddComment:u,deleteCommentOrThread:c,activeIDs:n,markNodeMap:t}),document.body))}var ju=on(766),Is={};Is.styleTagTransform=ai(),Is.setAttributes=oi(),Is.insert=ri().bind(null,"head"),Is.domAPI=ni(),Is.insertStyleElement=ii(),ei()(ju.A,Is),ju.A&&ju.A.locals&&ju.A.locals;var Au=on(225),Rs={};Rs.styleTagTransform=ai(),Rs.setAttributes=oi(),Rs.insert=ri().bind(null,"head"),Rs.domAPI=ni(),Rs.insertStyleElement=ii(),ei()(Au.A,Rs),Au.A&&Au.A.locals&&Au.A.locals;function BS(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 Z0(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 Pu(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?Z0(Object(g),!0).forEach(function(t){FS(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):Z0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function FS(y,d,g){return(d=zS(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function zS(y){var d=US(y,"string");return typeof d=="symbol"?d:d+""}function US(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 $l=!1;const $S=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],Hl=214,Q0=150;function HS(y){let{color:d,onChange:g}=y;const[t,f]=(0,Gt.useState)(Ms("hex",d)),[r,n]=(0,Gt.useState)(d),e=(0,Gt.useRef)(null),s=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*Hl,y:(100-t.hsv.v)/100*Q0}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*Hl}),[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=Ms("hex",d);f(l),n(l.hex)},[d]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:Hl},ref:e},Gt.createElement(BS,{label:"Hex",onChange:l=>{if(n(l),/^#[0-9A-Fa-f]{6}$/i.test(l)){const o=Ms("hex",l);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},$S.map(l=>Gt.createElement("button",{className:l===t.hex?" active":"",key:l,style:{backgroundColor:l},onClick:()=>(o=>{n(o);let a=Ms("hex",o);f(a),g(a.hex,$l)})(l)}))),Gt.createElement(X0,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:l=>{let{x:o,y:a}=l;const c=Ms("hsv",Pu(Pu({},t.hsv),{},{s:o/Hl*100,v:100-a/Q0*100}));f(c),n(c.hex),g(c.hex,$l)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:s.x,top:s.y}})),Gt.createElement(X0,{className:"codox-color-picker-hue",onChange:l=>{let{x:o}=l;const a=Ms("hsv",Pu(Pu({},t.hsv),{},{h:o/Hl*360}));f(a),n(a.hex),g(a.hex,$l)}},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 X0(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=ty(s.clientX-a,l,0),h=ty(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,$l=!0,e(o)},l=o=>{n.current&&($l=!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 ty(y,d,g){return y>d?d:y<g?g:y}function ey(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 ny(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 Xf(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 qS(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 ry(y){let{b:d,g,r:t}=y;return"#"+[t,g,d].map(f=>f.toString(16).padStart(2,"0")).join("")}function Ms(y,d){let g=ey("#121212"),t=ny(g),f=Xf(t);return y==="hex"?(g=ey(d),t=ny(g),f=Xf(t)):y==="rgb"?(t=d,g=ry(t),f=Xf(t)):y==="hsv"&&(f=d,t=qS(f),g=ry(t)),{hex:g,hsv:f,rgb:t}}const JS=Gt.createContext(null),oy=4;function VS(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(JS.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 WS(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+oy}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+oy;_!==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,Os.createPortal)(Gt.createElement(VS,{dropDownRef:o,onClose:()=>{u(!1),a&&a.current&&a.current.focus()},dropdownClassName:s},n),document.body))}const KS=["disabled","stopCloseOnClickSelf","color","onChange"];function tp(){return tp=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},tp.apply(null,arguments)}function GS(y,d){if(y==null)return{};var g,t,f=YS(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 YS(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 iy(y){let{disabled:d=!1,stopCloseOnClickSelf:g=!0,color:t,onChange:f}=y,r=GS(y,KS);return Gt.createElement(WS,tp({},r,{disabled:d,stopCloseOnClickSelf:g}),Gt.createElement(HS,{color:t,onChange:f}))}const ZS=y=>{let{onColorChange:d,buttonClassName:g,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=y;const[i]=(0,Fi.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,c]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,bs.mergeRegister)(i.registerEditableListener(h=>{o(h)}),i.registerUpdateListener(h=>{let{editorState:p}=h;p.read(()=>{const m=(0,be.$getSelection)();if((0,be.$isRangeSelection)(m)){let b=(0,Ca.$getSelectionStyleValueForProperty)(m,"color");b!==a&&(c(b||""),d(b))}})})),[i]);const u=(0,Gt.useCallback)((h,p)=>{i.update(()=>{const m=(0,be.$getSelection)();m!==null&&(0,Ca.$patchStyleText)(m,{color:h})})},[i]);return Gt.createElement(iy,{disabled:!l,color:a,onChange:u,buttonClassName:g||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},QS=ZS,XS=y=>{let{onColorChange:d,buttonClassName:g,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=y;const[i]=(0,Fi.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,c]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,bs.mergeRegister)(i.registerEditableListener(h=>{o(h)}),i.registerUpdateListener(h=>{let{editorState:p}=h;p.read(()=>{const m=(0,be.$getSelection)();if((0,be.$isRangeSelection)(m)){let b=(0,Ca.$getSelectionStyleValueForProperty)(m,"background-color");b!==a&&(c(b||""),d(b))}})})),[i]);const u=(0,Gt.useCallback)((h,p)=>{i.update(()=>{const m=(0,be.$getSelection)();m!==null&&(0,Ca.$patchStyleText)(m,{"background-color":h})})},[i]);return Gt.createElement(iy,{disabled:!l,color:a,onChange:u,buttonClassName:g||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},t2=XS;var e2=Mi.yy;Mi._U,Mi.a8,Mi.Vs,Mi.Cn;var n2=Mi.gK,r2=Mi.vv;function o2(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var Nu=o2(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 i2({hasCellMerge:y=!0,hasCellBackgroundColor:d=!0,hasTabHandler:g=!0}){const[t]=jr();return Ce.useEffect(()=>(t.hasNodes([bo,Ao,xa])||Nu(10),mo(t.registerCommand(i_,({columns:f,rows:r,includeHeaders:n})=>{const e=Lm(Number(r),Number(f),n);um(e);const s=e.getFirstDescendant();return Ne(s)&&s.select(),!0},an),t.registerNodeTransform(bo,f=>{const[r]=Um(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=Xo(0);o.append(Un()),i!==null?i.insertAfter(o):dm(i,o)}}}))),[t]),Ce.useEffect(()=>{const f=new Map,r=e=>{const s=e.getKey(),i=t.getElementByKey(s);if(i&&!f.has(s)){const l=b_(e,i,t,g);f.set(s,l)}};t.getEditorState().read(()=>{const e=Xh(bo);for(const s of e)Pn(s)&&r(s)});const n=t.registerMutationListener(bo,e=>{for(const[s,i]of e)if(i==="created")t.getEditorState().read(()=>{const l=Vn(s);Pn(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]),Ce.useEffect(()=>{if(!y)return t.registerNodeTransform(Ao,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=qr(f),[n]=Po(r,f,f),e=n.length,s=n[0].length;let i=r.getFirstChild();sr(i)||Nu(175);const l=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),sr(i)||Nu(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){rn(h)||Nu(176);const p=Xo(h.__headerState);a!==null?a.insertAfter(p):dm(i,p)}}}for(const o of l)o.setColSpan(1),o.setRowSpan(1)}})},[t,y]),Ce.useEffect(()=>{if(!d)return t.registerNodeTransform(Ao,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,d,y]),null}const a2={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"},s2="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",l2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",ay=Qn.createContext(null),sy=4;function Iu({children:y,className:d,onClick:g,title:t}){const f=Ce.useRef(null),r=Qn.useContext(ay);if(r===null)throw new Error("DropDownItem must be used within a DropDown");const{registerItem:n}=r;return Ce.useEffect(()=>{f&&f.current&&n(f)},[f,n]),he.jsx("button",{className:d,onClick:g,ref:f,title:t,type:"button",children:y})}function c2({children:y,dropDownRef:d,onClose:g}){const[t,f]=Ce.useState(),[r,n]=Ce.useState(),e=Ce.useCallback(l=>{f(o=>o?[...o,l]:[l])},[f]),s=l=>{if(!t)return;const o=l.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(o)&&l.preventDefault(),o==="Escape"||o==="Tab"?g():o==="ArrowUp"?n(a=>{if(!a)return t[0];const c=t.indexOf(a)-1;return t[c===-1?t.length-1:c]}):o==="ArrowDown"&&n(a=>a?t[t.indexOf(a)+1]:t[0])},i=Ce.useMemo(()=>({registerItem:e}),[e]);return Ce.useEffect(()=>{t&&!r&&n(t[0]),r&&r.current&&r.current.focus()},[t,r]),he.jsx(ay.Provider,{value:i,children:he.jsx("div",{className:"dropdown",ref:d,onKeyDown:s,children:y})})}function u2({disabled:y=!1,buttonLabel:d,buttonAriaLabel:g,buttonClassName:t,buttonIconClassName:f,children:r,stopCloseOnClickSelf:n}){const e=Ce.useRef(null),s=Ce.useRef(null),[i,l]=Ce.useState(!1),o=()=>{l(!1),s&&s.current&&s.current.focus()};return Ce.useEffect(()=>{const a=s.current,c=e.current;if(i&&a!==null&&c!==null){const{top:u,left:h}=a.getBoundingClientRect();c.style.top=`${u+a.offsetHeight+sy}px`,c.style.left=`${Math.min(h,window.innerWidth-c.offsetWidth-20)}px`}},[e,s,i]),Ce.useEffect(()=>{const a=s.current;if(a!==null&&i){const c=u=>{const h=u.target;n&&e.current&&e.current.contains(h)||a.contains(h)||l(!1)};return document.addEventListener("click",c),()=>{document.removeEventListener("click",c)}}},[e,s,i,n]),Ce.useEffect(()=>{const a=()=>{if(i){const c=s.current,u=e.current;if(c!==null&&u!==null){const{top:h}=c.getBoundingClientRect(),p=h+c.offsetHeight+sy;p!==u.getBoundingClientRect().top&&(u.style.top=`${p}px`)}}};return document.addEventListener("scroll",a),()=>{document.removeEventListener("scroll",a)}},[s,e,i]),he.jsxs(he.Fragment,{children:[he.jsxs("button",{type:"button",disabled:y,"aria-label":g||d,className:t,onClick:()=>l(!i),ref:s,children:[f&&he.jsx("span",{className:f}),d&&he.jsx("span",{className:"text dropdown-button-text",children:d}),he.jsx("i",{className:"chevron-down"})]}),i&&$r.createPortal(he.jsx(c2,{dropDownRef:e,onClose:o,children:r}),document.body)]})}function ly(){return he.jsx("div",{className:"divider"})}const ep=8,np=72,Ds={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",paragraph:"Normal"},rp={h1:{fontFamily:"Arial",fontSize:25,fontColor:"#000000",leadingSpace:.5,trailingSpace:.5},h2:{fontFamily:"Verdana",fontSize:20,fontColor:"#111111",leadingSpace:.3,trailingSpace:.4},h3:{fontFamily:"Arial",fontSize:16,fontColor:"#222222",leadingSpace:.2,trailingSpace:.3},paragraph:{fontFamily:"Arial",fontSize:11,fontColor:"#333333",leadingSpace:.1,trailingSpace:.2}};function d2({selectionFontSize:y,disabled:d,editor:g,blockType:t}){const[f,r]=Qn.useState(y),[n,e]=Qn.useState(t),s=c=>{g.update(()=>{if(g.isEditable()){const u=Oe();u!==null&&im(u,c)}})},i=c=>{r(c.target.value)},l=()=>{const c=Number(f);if(!isNaN(c)){const u=Math.min(Math.max(c,ep),np);r(String(u)),s({"font-size":`${u}px`})}},o=c=>{const u=rp[n].fontSize,h=c?Math.min(u+2,np):Math.max(u-2,ep);r(String(h)),s({"font-size":`${h}px`})},a=c=>{if(e(c),c==="paragraph"){const u=rp.paragraph;cy(),r(String(u.fontSize)),s({"font-size":`${u.fontSize}px`,color:u.fontColor,"font-family":u.fontFamily,"line-height":`${1+u.leadingSpace}em`,"margin-bottom":`${u.trailingSpace}em`})}else{const{fontSize:u,fontColor:h,fontFamily:p,leadingSpace:m,trailingSpace:b}=rp[c];cy(),r(String(u)),s({"font-size":`${u}px`,color:h,"font-family":p,"line-height":`${1+m}em`,"margin-bottom":`${b}em`})}};return Qn.useEffect(()=>{const c=()=>{g.update(()=>{const u=Oe();if(u!==null){const p=u.getNodes()[0];if(!Ne(p)){const m=p.getType();m in Ds&&e(m)}}})};return g.registerUpdateListener(c),()=>{g.registerUpdateListener(c)}},[g]),he.jsxs(he.Fragment,{children:[he.jsx("button",{type:"button",disabled:d,onClick:()=>o(!1),className:"toolbar-item font-decrement"}),he.jsx("input",{type:"number",value:f,disabled:d,readOnly:!0,className:"toolbar-item font-size-input",min:ep,max:np,onChange:i,onBlur:l}),he.jsx("button",{type:"button",disabled:d,onClick:()=>o(!0),className:"toolbar-item font-increment"}),he.jsx(ly,{}),he.jsxs("div",{className:"symbol-dropdown cust-head-dropDown",children:[he.jsxs(u2,{disabled:d,buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"Formatting options for text style",buttonIconClassName:"icon block-type "+n,buttonLabel:Ds[n],children:[he.jsxs(Iu,{className:`item ${n==="paragraph"?"active":""}`,onClick:()=>a("paragraph"),children:[he.jsx("i",{className:"icon paragraph"}),he.jsx("span",{className:"text",children:Ds.paragraph})]}),he.jsxs(Iu,{className:`item ${n==="h1"?"active":""}`,onClick:()=>a("h1"),children:[he.jsx("i",{className:"icon h1"}),he.jsx("span",{className:"text",children:Ds.h1})]}),he.jsxs(Iu,{className:`item ${n==="h2"?"active":""}`,onClick:()=>a("h2"),children:[he.jsx("i",{className:"icon h2"}),he.jsx("span",{className:"text",children:Ds.h2})]}),he.jsxs(Iu,{className:`item ${n==="h3"?"active":""}`,onClick:()=>a("h3"),children:[he.jsx("i",{className:"icon h3"}),he.jsx("span",{className:"text",children:Ds.h3})]})]}),he.jsx(ly,{})]})]})}function cy(y){throw new Error("Function not implemented.")}const f2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",p2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function h2(){const[y,d]=Ce.useState("4"),[g,t]=Ce.useState("4"),[f,r]=Ce.useState(!1),[n,e]=Ce.useState(),[s]=jr(),i=()=>{!y||!g||(s.update(()=>{const l=Lm(y,g,!0),o=um(l);e(o)}),r(!1))};return he.jsxs(he.Fragment,{children:[he.jsx("button",{className:"toolbar-item ",onClick:()=>r(!0),children:he.jsx("img",{className:"add-toolbar-table-icon",src:p2,alt:"Add Table"})}),f&&he.jsx("div",{className:"modal-overlay",children:he.jsxs("div",{className:"modal-content",children:[he.jsx("h3",{children:"Select Table Dimensions"}),he.jsx("button",{className:"modal-buttons-close",onClick:()=>r(!1),children:he.jsx("img",{src:f2,height:16,width:16,style:{margin:"0 0 29px 10px"}})}),he.jsxs("div",{className:"select-table-container",children:[he.jsx("label",{children:"Rows"}),he.jsx("input",{type:"number",value:y,onChange:l=>d(Number(l.target.value))})]}),he.jsxs("div",{className:"select-table-container",children:[he.jsx("label",{children:"Column"}),he.jsx("input",{type:"number",value:g,onChange:l=>t(Number(l.target.value))})]}),he.jsx("div",{children:he.jsx("div",{className:"modal-buttons",children:he.jsx("button",{className:"toolbar-item",onClick:i,children:"Confirm"})})})]})})]})}const uy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNCAxMkgyME0xMiA0VjIwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==",dy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNiAxMkwxOCAxMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=";var g2=typeof global=="object"&&global&&global.Object===Object&&global;const m2=g2;var y2=typeof self=="object"&&self&&self.Object===Object&&self,b2=m2||y2||Function("return this")();const fy=b2;var v2=fy.Symbol;const Ru=v2;var py=Object.prototype,_2=py.hasOwnProperty,x2=py.toString,ql=Ru?Ru.toStringTag:void 0;function w2(y){var d=_2.call(y,ql),g=y[ql];try{y[ql]=void 0;var t=!0}catch{}var f=x2.call(y);return t&&(d?y[ql]=g:delete y[ql]),f}var S2=Object.prototype,C2=S2.toString;function E2(y){return C2.call(y)}var k2="[object Null]",O2="[object Undefined]",hy=Ru?Ru.toStringTag:void 0;function T2(y){return y==null?y===void 0?O2:k2:hy&&hy in Object(y)?w2(y):E2(y)}function j2(y){return y!=null&&typeof y=="object"}var A2="[object Symbol]";function P2(y){return typeof y=="symbol"||j2(y)&&T2(y)==A2}var N2=/\s/;function I2(y){for(var d=y.length;d--&&N2.test(y.charAt(d)););return d}var R2=/^\s+/;function M2(y){return y&&y.slice(0,I2(y)+1).replace(R2,"")}function op(y){var d=typeof y;return y!=null&&(d=="object"||d=="function")}var gy=0/0,D2=/^[-+]0x[0-9a-f]+$/i,L2=/^0b[01]+$/i,B2=/^0o[0-7]+$/i,F2=parseInt;function my(y){if(typeof y=="number")return y;if(P2(y))return gy;if(op(y)){var d=typeof y.valueOf=="function"?y.valueOf():y;y=op(d)?d+"":d}if(typeof y!="string")return y===0?y:+y;y=M2(y);var g=L2.test(y);return g||B2.test(y)?F2(y.slice(2),g?2:8):D2.test(y)?gy:+y}var z2=function(){return fy.Date.now()};const ip=z2;var U2="Expected a function",$2=Math.max,H2=Math.min;function q2(y,d,g){var t,f,r,n,e,s,i=0,l=!1,o=!1,a=!0;if(typeof y!="function")throw new TypeError(U2);d=my(d)||0,op(g)&&(l=!!g.leading,o="maxWait"in g,r=o?$2(my(g.maxWait)||0,d):r,a="trailing"in g?!!g.trailing:a);function c(x){var S=t,E=f;return t=f=void 0,i=x,n=y.apply(E,S),n}function u(x){return i=x,e=setTimeout(m,d),l?c(x):n}function h(x){var S=x-s,E=x-i,k=d-S;return o?H2(k,r-E):k}function p(x){var S=x-s,E=x-i;return s===void 0||S>=d||S<0||o&&E>=r}function m(){var x=ip();if(p(x))return b(x);e=setTimeout(m,h(x))}function b(x){return e=void 0,a&&t?c(x):(t=f=void 0,n)}function _(){e!==void 0&&clearTimeout(e),i=0,t=s=f=e=void 0}function v(){return e===void 0?n:b(ip())}function w(){var x=ip(),S=p(x);if(t=arguments,f=this,s=x,S){if(e===void 0)return u(s);if(o)return clearTimeout(e),e=setTimeout(m,d),c(s)}return e===void 0&&(e=setTimeout(m,d)),n}return w.cancel=_,w.flush=v,w}function J2(y,d,g){const t=Ce.useRef(null);return t.current=y,Ce.useMemo(()=>q2((...f)=>{t.current&&t.current(...f)},d,{maxWait:g}),[d,g])}const yy=20;function V2({anchorElem:y}){const[d]=jr(),g=au(),[t,f]=Ce.useState(!1),[r,n]=Ce.useState(!1),[e,s]=Ce.useState(!1),[i,l]=Ce.useState({}),o=Ce.useRef(new Set),a=Ce.useRef(null),c=J2(m=>{const{isOutside:b,tableDOMNode:_}=W2(m);if(b){f(!1),n(!1);return}if(!_)return;a.current=_;let v=null,w=null,x=null;if(d.update(()=>{var E;const S=rr(_);if(rn(S)){const k=vn(S,D=>Pn(D));if(!Pn(k))return;if(x=d.getElementByKey(k==null?void 0:k.getKey()),x){const D=k.getChildrenSize(),P=(E=k.getChildAtIndex(0))==null?void 0:E.getChildrenSize(),O=u_(S),R=Fm(S);O===D-1?v=S:R===P-1&&(w=S)}}}),x){const{width:S,y:E,right:k,left:D,bottom:P,height:O}=x.getBoundingClientRect(),{y:R,left:A}=y.getBoundingClientRect();v?(n(!1),f(!0),l({height:yy,left:D-A,top:P-R+5,width:S})):w&&(n(!0),f(!1),l({height:O,left:k-A+5,top:E-R,width:yy}))}},50,250),u=Ce.useMemo(()=>new ResizeObserver(()=>{f(!1),n(!1)}),[]);Ce.useEffect(()=>{if(e)return document.addEventListener("mousemove",c),()=>{f(!1),n(!1),c.cancel(),document.removeEventListener("mousemove",c)}},[e,c]),Ce.useEffect(()=>mo(d.registerMutationListener(bo,m=>{d.getEditorState().read(()=>{for(const[b,_]of m){const v=d.getElementByKey(b);switch(_){case"created":o.current.add(b),s(o.current.size>0),v&&u.observe(v);break;case"destroyed":o.current.delete(b),s(o.current.size>0),u.disconnect(),o.current.forEach(w=>{const x=d.getElementByKey(w);x&&u.observe(x)});break}}})})),[d,u]);const h=m=>{d.update(()=>{if(a.current){const b=rr(a.current);b==null||b.selectEnd(),m?(d_(),f(!1)):(f_(),n(!1))}})},p=m=>{d.update(()=>{if(a.current){const b=rr(a.current);b==null||b.selectEnd(),m?(p_(),f(!1)):(h_(),n(!1))}})};return g?he.jsxs(he.Fragment,{children:[t&&he.jsxs("div",{children:[he.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%",padding:"20px"},onClick:()=>h(!0),children:he.jsx("img",{src:uy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),he.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%"},onClick:()=>p(!0),children:he.jsx("img",{src:dy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]}),r&&he.jsxs("div",{className:"table-add-row-flex-container",children:[he.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%",padding:"20px"},onClick:()=>h(!1),children:he.jsx("img",{src:uy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),he.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%"},onClick:()=>p(!1),children:he.jsx("img",{src:dy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]})]}):null}function W2(y){const d=y.target;if(d&&d instanceof HTMLElement){const g=d.closest("td.PlaygroundEditorTheme__tableCell, th.PlaygroundEditorTheme__tableCell");return{isOutside:!(g||d.closest("button.PlaygroundEditorTheme__tableAddRows")||d.closest("button.PlaygroundEditorTheme__tableAddColumns")||d.closest("div.TableCellResizer__resizer")),tableDOMNode:g}}else return{isOutside:!0,tableDOMNode:null}}function K2({anchorElem:y=document.body}){return au()?$r.createPortal(he.jsx(V2,{anchorElem:y}),y):null}const ap=1;function sp(){return he.jsx("div",{className:"divider"})}function G2({renderOnlineUsers:y}){const[d]=jr(),g=Ce.useRef(null),[t,f]=Ce.useState(!1),[r,n]=Ce.useState(!1),[e,s]=Ce.useState(!1),[i,l]=Ce.useState(!1),[o,a]=Ce.useState(!1),[c,u]=Ce.useState(!1),[h,p]=Ce.useState(!1),[m,b]=Ce.useState(!1),[_,v]=Ce.useState("11px"),[w,x]=Ce.useState(()=>d.isEditable()),S=Ce.useCallback(()=>{const E=Oe();xe(E)&&(s(E.hasFormat("bold")),l(E.hasFormat("italic")),a(E.hasFormat("underline")),u(E.hasFormat("strikethrough")),p(E.hasFormat("subscript")),b(E.hasFormat("superscript")),v(am(E,"font-size","11px")))},[]);return Ce.useEffect(()=>mo(d.registerUpdateListener(({editorState:E})=>{E.read(()=>{S()})}),d.registerCommand(Wo,(E,k)=>(S(),!1),ap),d.registerCommand(ts,E=>(f(E),!1),ap),d.registerCommand(Xa,E=>(n(E),!1),ap)),[d,S]),he.jsxs("div",{className:"toolbar",ref:g,children:[he.jsx("button",{disabled:!t,onClick:()=>{d.dispatchCommand(cl,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:he.jsx("i",{className:"format undo"})}),he.jsx("button",{disabled:!r,onClick:()=>{d.dispatchCommand(ul,void 0)},className:"toolbar-item","aria-label":"Redo",children:he.jsx("i",{className:"format redo"})}),he.jsx(sp,{}),he.jsx(d2,{selectionFontSize:_.slice(0,-2),editor:d,disabled:!w,blockType:"paragraph"}),he.jsx(sp,{}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"bold")},className:"toolbar-item spaced "+(e?"active":""),"aria-label":"Format Bold",children:he.jsx("i",{className:"format bold"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"italic")},className:"toolbar-item spaced "+(i?"active":""),"aria-label":"Format Italics",children:he.jsx("i",{className:"format italic"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"underline")},className:"toolbar-item spaced "+(o?"active":""),"aria-label":"Format Underline",children:he.jsx("i",{className:"format underline"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"strikethrough")},className:"toolbar-item spaced "+(c?"active":""),"aria-label":"Format Strikethrough",children:he.jsx("i",{className:"format strikethrough"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"superscript")},className:"toolbar-item spaced "+(m?"active":""),"aria-label":"Format SuperScript",children:he.jsx("img",{src:l2,height:16,width:16,style:{marginTop:"1px"}})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"subscript")},className:"toolbar-item spaced "+(h?"active":""),"aria-label":"Format SubScript",children:he.jsx("img",{src:s2,height:16,width:16,style:{marginTop:"1px"}})}),he.jsx(sp,{}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Qa,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:he.jsx("i",{className:"format left-align"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Qa,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:he.jsx("i",{className:"format center-align"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Qa,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:he.jsx("i",{className:"format right-align"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Qa,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:he.jsx("i",{className:"format justify-align"})}),he.jsx(h2,{}),he.jsx(K2,{}),he.jsx("span",{children:y()})]})}const lp=n2([...[bo,xa,Ao]]);function Y2(){return he.jsx("div",{className:"editor-placeholder"})}const Z2={namespace:"React.js Demo",nodes:lp,onError(y){throw y},theme:a2},Q2=()=>he.jsx(he.Fragment,{children:"hello"});function X2({collabApiKey:y,spfList:d,userObj:g}){const[t,f]=Ce.useState(!1),[r,n]=Ce.useState([]),[e,s]=Ce.useState("demo_docId_1"),[i,l]=Ce.useState({root:null}),{userId:o,userName:a,userEmail:c}=g,u=Ce.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))};Ce.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}};Ce.useEffect(()=>{(async()=>{if(!e)return;t&&b();let w=_;if(w)try{r2(w,lp),console.log("afsjdjs"),l(w)}catch(x){console.error("[APP] error: ",x)}})()},[e]),Ce.useEffect(()=>{i&&e&&!t&&m()},[i,e,t]),Ce.useMemo(()=>({editorState:i?JSON.stringify({root:i.root}):null,namespace:"Playground",nodes:lp,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(he.jsxs("div",{title:S.email,className:`avatarStyle avatar-color-${E+1}`,children:[" ",S.name&&S.name[0],S.name&&S.name[4]]},E)))}),he.jsx("div",{className:"flexContainer",children:w})};return he.jsx("div",{children:he.jsx(Zg,{initialConfig:Z2,children:he.jsxs("div",{className:"editor-container",children:[he.jsx(G2,{renderOnlineUsers:v}),he.jsxs("div",{className:"editor-inner",children:[he.jsx(Z1,{contentEditable:he.jsx(Xg,{className:"editor-input"}),placeholder:he.jsx(Y2,{}),ErrorBoundary:Q2}),he.jsx(e2,{ref:u}),he.jsx(hm,{}),he.jsx(i2,{}),he.jsx(Qg,{})]})]})})})}Mr.Editor=X2,Object.defineProperty(Mr,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=Xn.isMousePositionWithinElementCords(d,o);d.type===_r.mouseover&&u&&(a.style.animation=this.isEditingInProgress?Xn.tooltipAnimations.hideAtOnce:Xn.tooltipAnimations.showAtOnce,s.add(c)),d.type===_r.mouseout&&(a.style.animation=Xn.tooltipAnimations.hideWithDelay,s.add(c)),d.type===_r.mousemove&&u&&(a.style.animation=this.isEditingInProgress?Xn.tooltipAnimations.hideAtOnce:Xn.tooltipAnimations.showAtOnce,s.add(c))}}_keyboardEventsListener(d){d.type===_r.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),d.type===_r.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(d){we.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(_r.keypress,this.keyboardBindedListener),window.addEventListener(_r.keyup,this.keyboardBindedListener),window.addEventListener(_r.resize,this.resizeBindedListener),window.addEventListener(_r.scroll,this.resizeBindedListener);for(const d of a0)window.addEventListener(d,this.mouseBindedListener)}unmount(){window.removeEventListener(_r.keypress,this.keyboardBindedListener),window.removeEventListener(_r.keyup,this.keyboardBindedListener),window.removeEventListener(_r.resize,this.resizeBindedListener),window.removeEventListener(_r.scroll,this.resizeBindedListener);for(const d of a0)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=we.getMainEditorState();g.read&&g.read(()=>{for(let t of this.remoteSelections)if(qf.validateJSONSelection(t,zf.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:we.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 vo=new iw;function aw(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(y=>y===Sa.editorState)}function _u(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,g=we.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)_u(r,f);return d&&d.getChildrenSize&&d.splice(d.getChildrenSize(),0,[f]),f}function xu(y){if(y.getChildren)for(let d of y.getChildren())xu(d);y.remove()}function C0(y){y.__parent=null,y.__next=null,y.__prev=null}function E0(y,d){return!!we.isLexicalEditorInstance(y)&&!(typeof d!="object"||!d.editorState||(y.update(()=>{try{let g=(0,be.$getSelection)();const t=y.parseEditorState(d.editorState);if(t.isEmpty())return(0,be.$getRoot)().clear(),!0;(0,be.$setSelection)(g),y.setEditorState(t)}catch(g){le.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",g)}}),0))}function sw(y,d){let g=d;for(const t of y)g=g[t];return g}function Ea(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=sw(y,g?d:we.getMainEditorState().toJSON());return f&&(t=ka(f)?(0,be.$getRoot)():jn.get(f.codoxId)),t||le.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:f,lexicalNode:t,pathArray:y,currentStateJSON:we.getMainEditorState().toJSON(),newStateJSON:d,codoxNodes:jn.nodesToArray(),searchInNewState:g}),t||(g?t:Ea(y,d,!0))}function k0(y){le.log("[applyFullLexicalStateReplace] clear current state and apply new");const d=(0,be.$getRoot)();d.clear();let g=we.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 lw(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=aw(t),i=s!==-1,l=g.hasOwnProperty("lm")&&typeof g.lm=="number";if(t.length)if(i){let o=s-1,a=Ea(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=Ll(t[o]);E0(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=Ea(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:xu(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=_u(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(we.isLexicalEditorInstance(S[E])){let k={editorState:S[E].getEditorState().toJSON()};E0(x[E],k)}else{let k=Ff(E),D=m[k];if(D===x[E]||!m.hasOwnProperty(k))continue;let P=D!==void 0&&S[E]!==D?D:S[E];k!=="height"&&k!=="width"||S[E]==="inherit"&&D===0&&(P=S[E]),x[E]=P}S.remove(),C0(x),v=x,delete c[m.codoxDId]}}v||(v=_u(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(),C0(m),xu(m),delete c[p]}}else{let c=o.map(u=>_u(u));a.splice(0,a.getChildrenSize(),c)}}if(n){if(g.ld){const o=g.ld,a=jn.get(o.codoxId);a.getChildrenSize&&a.getChildrenSize()?xu(a):a.remove()}if(g.li){let o=we.getMainEditorNodesClassesMap();const a=g.li,c=o.get(a.type).klass.importJSON(a);if(t.length===1&&t[0]==="root")(0,be.$getRoot)().splice(0,0,[c]);else{const u=t[t.length-1];t.length=t.length-2;let h=Ea(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=Ea(o,y);if(u)try{let h=u.getWritable();if(a){let p=Object.keys(a);for(let m of p)h[Ll(m)]=a[m]}if(c){let p=Object.keys(c);for(let m of p)delete h[Ll(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=Ea(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=Ll(o);t.length=t.length-1;let c,u=Ea(t,y);if(!u){le.error("Missing node when update node attr from delta: ",{path:t,delta:g,fullStateJSON:y,currentEditorState:we.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=sx(h)),o==="direction"&&(u.hasOwnProperty(a)||(a="__dir")),!c.hasOwnProperty(a)){let p=Object.keys(c);for(let m of p){let b=Ff(m);if(o.startsWith(b)){a=m;break}}}c[a]=h}}else if(g.oi&&g.oi.root)return k0(g.oi)}}else le.log("[applyDeltasToLexicalState] stop, no deltas: ",d)}function cw(y){let d=y.clipboardData.getData(cx.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){jn.clearPastedIds();const t=f=>{if(f.codoxId&&jn.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 uw=y=>{var d={};return on.d(d,y),d};const O0=uw({useCollaborationContext:()=>w_});var dw=y=>{var d={};return on.d(d,y),d};const Fi=dw({LexicalComposerContext:()=>Ef,useLexicalComposerContext:()=>jr});class T0{constructor(){this.blacklist=Object.keys(s0).reduce((d,g)=>{let t=s0[g];return d[g]=t.reduce((f,r)=>(f[r]=r,f),{}),d},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(d){return d instanceof be.TextNode||d instanceof be.ParagraphNode||d instanceof be.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(Jf||g!==Jr.created||this._isBlacklistedFound||!d||!d.__type||this._shouldSkipNode(d))return;let f=t||we.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!==Jr.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 fw=new T0,zi=fw,pw=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function hw(y,d){if(y==null)return{};var g,t,f=gw(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 gw(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 mw{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(d,g){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:s}=f,i=(hw(f,pw),we.getMainEditor()),l=we.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),c=Hf(o,a),u=r._selection,h=n._selection,p=!1,m=null,b=we.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}),zi.isBlacklistedFound())return t=!0,le.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),we.scanLexicalNodeForNestedEditorAttribute(d)?(_.update(()=>{try{const v=_.parseEditorState(a);if(v.isEmpty())return(0,be.$getRoot)().clear(),!0;_.setEditorState(v)}catch(v){le.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",v)}}),void zi.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=Ff(g),x=$e.lexicalToJSONNested(u,w,v);m=we.getCurrentNestedSelectionJSON(),p=$e.equalSelectionsJSON(m,x),p||we.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}),we.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(!we.getLexicalNodeByKey(d)){let g=this.nestedEditorsListenersMap[d];g&&g(),delete this.nestedEditorsListenersMap[d]}}manageNestedEditorInLexicalNode(d){if(this._isNestedEditorManaged(d.getKey()))return;let g=we.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===Jr.created){let p=t.getEditorState()._nodeMap.get(u);p&&zi.trackBlacklistedInNestedEditor(p,h,t.getEditorState(),d)}});r.push(a)});let n=(0,bs.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,be.$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 yw=new mw,si=yw,bw=function(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let g=(0,be.createEditor)({namespace:"validation",nodes:[...d],onError:e=>{throw e},parentEditor:null});const t=new T0,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,Jr.created,r),t.isBlacklistedFound()))throw new Error(ux)}}catch(g){throw g}};class vw{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===Li.BOTH||s.__headerState===Li.ROW),e=d.some((s,i)=>{if(s.__size<f)return!1;let l=s.getChildAtIndex(t);return!(!l||l.__headerState!==Li.BOTH&&l.__headerState!==Li.COLUMN)});return n&&e?r=Li.BOTH:n&&!e?r=Li.ROW:e&&!n&&(r=Li.COLUMN),r}_isValidCellChildren(d){for(let g of d)if(Cs(g)||!Ss(g)&&En(g))return!1;return!0}_createEmptyCell(){let d=(0,kn.$createTableCellNode)();return d.append((0,be.$createParagraphNode)()),d}_wrapInvalidCellChildrenIntoParagraph(d){let g=(0,be.$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,be.$getNodeByKey)(d);for(;g;){let f=(0,kn.$createTableCellNode)().append((0,be.$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,be.$getNodeByKey)(d).append((0,be.$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,be.$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,be.$getNodeByKey)(d),t=(0,kn.$createTableRowNode)();t.append(this._createEmptyCell()),g.append(t)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(d,g){return()=>{for(g||(g=1);g;)(0,be.$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,be.$getNodeByKey)(d);if(!t)return;let f=(0,be.$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,kn.$createTableRowNode)();if((0,kn.$isTableCellNode)(f))f.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(f):f.append((0,be.$createParagraphNode)()),e.append(f);else{let s=this._isValidCellChildren([f]),i=(0,kn.$createTableCellNode)();if(e.append(i),s)i.append(f);else{let l=(0,be.$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,be.$getNodeByKey)(d);if(!t)return;let f=(0,be.$getNodeByKey)(g);if(f.remove(),f=(0,be.$createParagraphNode)(),!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling(),e=(0,kn.$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,be.$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,be.$getNodeByKey)(d);t&&(t=t.getWritable(),t.__headerState=g)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(d){let g=we.getMainEditorState()._selection;if(le.debug(`[${d}]`,{selection:g}),!(0,be.$isRangeSelection)(g))return;let t=[];try{let f=we.getLexicalNodeByKey(g.anchor.key),r=we.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,kn.$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}),we.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(d=>{let g=(0,be.$getNodeByKey)(d);g&&g.remove()}),this.removeCandidateTableKeys.clear(),(0,be.$addUpdateTag)(no.historic)})}tableUpdateListener(d){this.validateTableCandidateKeys.add(d)}tableRowNodeChangesListener(d){let g=arguments.length>1&&arguments[1]!==void 0&&arguments[1],t=we.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=we.getLexicalNodeByKey(d);if(!g||!g.__parent)return;let t=we.getLexicalNodeByKey(g.__parent);t&&t.__parent&&this.validateTableCandidateKeys.add(t.__parent)}shouldValidateUpdatedTables(){return!!this.validateTableCandidateKeys.size}validateUpdatedTables(){let d=Array.from(this.validateTableCandidateKeys);return we.getMainEditorState().read(()=>{for(let g of d){let t=we.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,kn.$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,kn.$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===Li.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=we.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,be.$addUpdateTag)(no.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 No=new vw,_w=["contentChanged"],xw=["state","remoteSelection"];function j0(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 xs(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?j0(Object(g),!0).forEach(function(t){ww(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):j0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function ww(y,d,g){return(d=Sw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function Sw(y){var d=Cw(y,"string");return typeof d=="symbol"?d:d+""}function Cw(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 A0(y,d){if(y==null)return{};var g,t,f=Ew(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 Ew(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 Jf={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 kw=y=>async()=>{const{state:d,timestamp:g}=await y();if(!we.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 wu=0,li=null,Vf=!1,_o={},Wf={};const Ow=(0,Gt.forwardRef)((y,d)=>{let{onBlacklistedInsert:g}=y;const t=(0,Gt.useContext)(Fi.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,Fi.useLexicalComposerContext)(),r=(0,O0.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}),we.setMainEditor(f),jn.gcAbandonedNodes(),si.gc(),No.clear(),le.log("[useEffect][editor] subscribe to editor changes");const b=(0,bs.mergeRegister)(f.registerUpdateListener(h),f.registerCommand(be.PASTE_COMMAND,cw,be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.UNDO_COMMAND,()=>{we.setUndoInvoked(!0)},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.REDO_COMMAND,()=>{we.setRedoInvoked(!0)},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.KEY_DELETE_COMMAND,(v,w)=>{No.tableRemoveEventListener("KEY_DELETE_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.KEY_BACKSPACE_COMMAND,(v,w)=>{No.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.CUT_COMMAND,(v,w)=>{No.tableRemoveEventListener("CUT_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),...p());vo.mount(),we.alignStateSelectionJSONsFromLatestEditor(),le.debug("New editor mounted: ",{isCodoxStarted:we.isCodoxStarted,codoxLexicalEditorManager:we,nestedEditorsProcessor:si});let _=f._onError;return f._onError=v=>{le.error("[ERROR HANDLER WRAPPER] error from editor: ",v),_&&_(v),u()},g&&zi.setClientCallback(g),()=>{we.getMainEditorKey()&&(le.debug("Unmount prev editor"),b(),we.removeMainEditor(),vo.unmount(),we.clearJSONs(),Cn.clear(),No.clear(),we.isCodoxStarted&&(le.debug("EDITOR USE_EFFECT stopping codox"),n(),we.setIsCodoxStarted(!1)),zi.removeClientCallback())}},[f]);const n=()=>{we.isCodoxStarted&&(le.log("[stopCodoxInstance] stopping codox"),we.setIsCodoxStarted(!1),Jf||ti().stop(),we.clearJSONs(),jn.clearAll(),vo.clear(),Cn.resetComments(),si.clearListeners())},e=async b=>{le.debug("[startCodoxInstance] invoked"),ti().createNewInstance(),le.debug("[startCodoxInstance] instance created");for(let O in Wf)ti().instance.on(O,Wf[O]);if(le.debug("[startCodoxInstance] events subscribed"),_o=b,li=_o.docId,!li)return le.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:li});let _=Cn.initialCommentsExist();le.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(Cn.activateInitialComments(f,jn),le.log("[activateInitialComments] "));let v=we.getMainEditorState().toJSON();if(!we.isValidJSONState(v))throw le.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:li,initJSONState:v}),new Error("start codox skipped - invalid init state");le.log("[startCodoxInstance] starting codox with: ",{docId:li,initJSONState:v,config:_o,codoxComments:Cn}),we.currentContentStateJSON||we.setCurrentContentStateJSON(v),we.isCodoxStarted&&n();let{username:w,apiKey:x,getServerState:S,domain:E="",demo:k=!1,hooks:D}=_o;D&&D.fetchDocOnNetworkReconnect&&(D.fetchDocOnNetworkReconnect=kw(D.fetchDocOnNetworkReconnect));const P=A0(D,_w);await ti().start(ti().createConfig(xs(xs({},_o),{},{docId:li,username:w,apiKey:x,domain:E,hooks:xs({syncState:l,getState:i,getServerState:async()=>await S(li)},P),editorInstanceHooks:{getSelection:()=>we.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:we.getCurrentActiveSelectionJSON()},vo.getCurrentRemoteSelections()),Cn.setAllComments(A)},enableEditor:()=>{we.disableEditorReadOnlyMode()},disableEditor:()=>{we.enableEditorReadOnlyMode(),vo.updateRemoteSelections([])},getContent:()=>{let O=we.composeFullStateWithRootAndComments();return le.info("[getContent]: ",O),{state:O}}},appServer:_o.appServer,demo:k}))),le.log("[startCodoxInstance] codox started - first sync invoking"),we.setIsCodoxStarted(!0),r.clientID=_o.username,r.name=_o.username,c()},s=()=>{let b=we.composeFullStateWithRootAndComments({directlyFromEditor:!0});e(b)},i=()=>({state:xs(xs({},we.getMainEditorState().toJSON()),{},{comments:Cn.getAllComments()}),docId:li}),l=b=>{if(!we.isCodoxStarted)return;le.log("[SYNC_STATE]: Before sync payload = ",b);const _=ti().sync({meta:b}),{state:v,remoteSelection:w=[]}=_,x=A0(_,xw);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}=we.extractStateAndCommentsFromSynced(S);if(!we.isValidJSONState(E.state))return le.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:E.state}),s();a(E,w),Cn.setAllComments(k)},o=b=>{if(!we.isCodoxStarted||(le.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:b}),!qf.validateJSONSelection(b,zf.local)))return;let _=we.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=si.setNestedEditorSelection(b);we.setNestedSelectionJSON(x?b:null)}else(0,be.$setSelection)(w),we.setMainSelectionJSON(b);le.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:we.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=we.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=Hf(S,b),k=$e.equalSelectionsJSON(we.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(we.addUpdateTag({isSameState:E,isSameSelection:k,updateTag:x}),v)le.log("[updateEditor] invoke full stateReplace after sync"),k0(b),S=we.setCurrentContentStateJSON(b),(0,be.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S);else{le.log("[updateEditor] invoke deltas diff");let P=ti().diff(S,b,{keyNames:{default:"codoxId"}});le.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:b,deltas:P&&JSON.parse(JSON.stringify(P))}),P&&P.length&&(le.log("[updateEditor] apply deltas to lexical state"),lw(b,P),S=we.setCurrentContentStateJSON(b),(0,be.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(qf.validateJSONSelection(_,zf.local)||(_=we.getCurrentActiveSelectionJSON()),D){let P=si.setNestedEditorSelection(_);we.setNestedSelectionJSON(P?_:null),le.log("[updateEditor] nested selection updated",P?_:null)}else if(_!==void 0){const P=$e.JSONToLexical(_);le.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:P}),(0,be.$setSelection)(P),we.setMainSelectionJSON(_),le.log("[updateEditor] selection updated",_)}},{onUpdate:()=>{E||vo.updateRemoteSelections(w,"from onUpdate hook")}}),E&&vo.updateRemoteSelections(w,"from direct updateEditor")},c=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";if(!we.isCodoxStarted)return;le.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:b});let _=we.composeFullStateWithRootAndComments();const v={docId:li,state:{state:_,selection:we.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}=ti().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}=we.extractStateAndCommentsFromSynced(E);if(!we.isValidJSONState(k.state))return le.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),s();a(k,x),Cn.setAllComments(D)},u=()=>{le.warn("[rollbackStateDuringUpdateError] rollback invoked"),le.log("[rollbackStateDuringUpdateError] values: ",{prevState:we.getPrevContentStateJSON(),currentState:we.getCurrentContentStateJSON(),prevSelection:we.getPrevMainSelectionJSON(),currentSelection:we.getCurrentActiveSelectionJSON(),codoxComments:Cn});let b=we.getPrevContentStateJSON(),_=we.getPrevMainSelectionJSON();a({state:b,selection:_},vo.getCurrentRemoteSelections(),no.historic);let v=we.undoInvoked(),w=we.redoInvoked();Cn.gcAbandonedNodeKeys(we.getMainEditorState()._nodeMap),v&&f.dispatchCommand(be.CAN_REDO_COMMAND,!1),w&&f.dispatchCommand(be.CAN_UNDO_COMMAND,!1)},h=b=>{let{editorState:_,prevEditorState:v,tags:w,dirtyElements:x,dirtyLeaves:S}=b;if(Vf)return Vf=!1,void le.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(zi.isBlacklistedFound())return Vf=!0,le.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((W,G)=>{let F=null,q=null;G.read(()=>{F=$e.lexicalToJSON(G._selection),q=G.toJSON()});let T=null,I=null;W.read(()=>{let L=(0,be.$getSelection)();I=$e.lexicalToJSON(L),T=W.toJSON()}),we.setCurrentContentStateJSON(T),we.setMainSelectionJSON(I),a({state:q,selection:F},vo.getCurrentRemoteSelections(),no.historic),f.dispatchCommand(be.CAN_REDO_COMMAND,!1),f.dispatchCommand(be.CAN_UNDO_COMMAND,!1)})(_,v),void zi.invokeClientCallback();if(!No.ensureDocTablesAreValid(_))return;wu++,le.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:wu,isCodoxStarted:we.isCodoxStarted});let E=we.isOnlySelectionChanged(x,S),k=null,D=null,P=null,O=null,R=we.getCurrentContentStateJSON(),A=w.has("codox_sync_state_changes"),z=w.has(Bl),H=we.undoInvoked(),$=we.redoInvoked(),M=we.canUndo(),J=we.canRedo();k=_.toJSON(),D=v.toJSON(),v.read(()=>{O=$e.lexicalToJSON(v._selection)}),_.read(()=>{let W=(0,be.$getSelection)();P=$e.lexicalToJSON(W);let G=$e.JSONToLexical(P),F=W===null&&G===null||W.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(Cn.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(P)),currentMainSelectionJSON:JSON.parse(JSON.stringify(we.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(we.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(we.getCurrentActiveSelectionJSON())),lexicalSelection:W,convertedBackMainSelection:G,isMainSelectionConvertionCorrect:F,nodes:f._editorState._nodeMap,fullEditor:f,codoxNodesMap:jn.toArray(),codoxComments:Cn,isUpdateFromSync:A,isUpdateFromComments:z,tags:w,onlySelectionChanged:E,undoInvoked:H,redoInvoked:$,canUndo:M,canRedo:J})});let K=Hf(R,k),N=$e.equalSelectionsJSON(we.getCurrentActiveSelectionJSON(),P);le.log("[editorUpdatesListener] compares: ",{isStateSame:K,isSelectionSame:N});let U=K&&N&&!z;if(!K||z||A){let W=xs({},K?R:k),G=Cn.getAllComments();G.length&&(W.commentThreads=G);let F={source:A?l0.remote:l0.local,content:W};_o.hooks&&_o.hooks.contentChanged&&_o.hooks.contentChanged(F),ti().instance.emit("content_changed",F)}if(U)le.log("[editorUpdatesListener] STOP - state and selection and comments are same ",wu);else if(we.undoInvoked()&&we.setUndoInvoked(!1),we.redoInvoked()&&we.setRedoInvoked(!1),we.setCurrentContentStateJSON(k),we.setPrevContentStateJSON(D),we.setMainSelectionJSON(P),we.setPrevMainSelectionJSON(O),Jf){let W=we.getCurrentActiveSelectionJSON();a({state:we.getCurrentContentStateJSON(),selection:W},[])}else c(wu)},p=()=>{let b=[];return we.getMainEditorNodesClassesMap().forEach((_,v,w)=>{let{klass:x}=_,S=f.registerMutationListener(x,E=>{for(let[k,D]of E){if(!Jr[D])continue;const P=we.getLexicalNodeByKey(k);if(D===Jr.created&&P&&zi.trackBlacklisted(P,D),x.name===kn.TableNode.name&&(D===Jr.destroyed?No.tableNodeRemoveListener(k):No.tableUpdateListener(k)),x.name===kn.TableRowNode.name&&D!==Jr.destroyed&&No.tableRowNodeChangesListener(k,D===Jr.updated),x.name===kn.TableCellNode.name&&D===Jr.updated&&No.tableCellNodeChangesListener(k),x.name===eo.MarkNode.name&&(le.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:P,mutationType:D,codoxComments:Cn}),D===Jr.destroyed?Cn.removeRelatedNodeKey(k):P&&Cn.addRelatedNodeKey(P.__key,P.__ids,D===Jr.created)),P&&P.codoxId){if(D===Jr.destroyed)return void(P.codoxId&&jn.remove(P.codoxId));B0(P)||le.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:D,node:P}),jn.add(P.codoxId,P)}}b.push(S)})}),b},m={start:e,stop:n,on:(b,_)=>{le.info(`Subscribing client to codox ${b} event`),Wf[b]=_},cursor:{hide:()=>{vo.hideRemoteSelectionsFromUI()},show:()=>{vo.showHiddenRemoteSelectionsInUI()}},initComments:b=>{Cn.setInitialComments(b)}};return(0,Gt.useImperativeHandle)(d,()=>m),null}),Tw=Ow,jw=["comments"];function P0(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 Kf(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?P0(Object(g),!0).forEach(function(t){Aw(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):P0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function Aw(y,d,g){return(d=Pw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function Pw(y){var d=Nw(y,"string");return typeof d=="symbol"?d:d+""}function Nw(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=Rw(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 Rw(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 Mw extends i0{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,be.$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:Kf({},Iw(d.state,jw)),selection:t,stateReplace:f},commentsFromSync:g}}composeFullStateWithRootAndComments(){let{directlyFromEditor:d=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Kf(Kf({},d?this.getMainEditorState().toJSON():this.currentContentStateJSON),{},{comments:Cn.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 be.ElementNode,o=i.prototype instanceof be.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,be.$addUpdateTag)(f)):t?(le.log(`[addUpdateTag] add "${no.historic}" tag - change invoked by nested editor`),void(0,be.$addUpdateTag)(no.historic)):void(d?(le.log(`[addUpdateTag] add "${no.historic}" tag - state is same`),(0,be.$addUpdateTag)(no.historic)):(le.log(`[addUpdateTag] add "${no.historyMerge}" tag - state is different`),(0,be.$addUpdateTag)(no.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const Dw=new Mw,we=Dw;class Lw{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=we.getMainEditorState();if(!d._nodeMap)return;let g=this.nodesToArray();for(let t of g)d._nodeMap.has(t.__key)||this.remove(t.codoxId)}}const Bw=new Lw,jn=Bw;function N0(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 I0(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?N0(Object(g),!0).forEach(function(t){Fw(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):N0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function Fw(y,d,g){return(d=zw(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function zw(y){var d=Uw(y,"string");return typeof d=="symbol"?d:d+""}function Uw(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 Gf=()=>G_(),R0=y=>typeof y=="number";function ws(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 ka=y=>y.__type==="root"||y.type==="root",M0=y=>ka(y.getParent()),$n=y=>y.__type===mu.text||y.type===mu.text||y.hasOwnProperty("__text")||y.hasOwnProperty("text"),Ss=y=>(0,be.$isElementNode)(y),Cs=y=>(0,kn.$isTableNode)(y)||(0,kn.$isTableRowNode)(y)||(0,kn.$isTableCellNode)(y),$w=y=>!y.getChildren,D0=y=>!!y.getChildren,En=y=>(0,be.$isDecoratorNode)(y),zl=y=>(0,U_.$isLinkNode)(y),Ul=y=>y.__type==="mark"||y.type==="mark",Yf=y=>(0,be.$isLineBreakNode)(y),Ui=y=>$n(y)||Yf(y),Zf=y=>y.__type===mu.horizontalrule||y.type===mu.horizontalrule,L0=y=>{if(Ui(y)||zl(y)||Ul(y))return!1;if(!y.__parent||y.__parent==="root"||(0,be.$isParagraphNode)(y))return!0;let d=y.getParent().getChildren();return d.length===1&&d[0].__key===y.__key?!((En(y)||zl(y)||Ul(y))&&!Zf(y)):!d.some(g=>{let t=Zf(g);return g.__key!==y.__key&&(Ui(g)||En(g)&&!t||zl(g)||Ul(g))})},B0=y=>{const d=jn.get(y.codoxId);return!d||y.__key===d.__key},Es=function(y){const d=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||Gf();y.codoxId=d,jn.add(d,y)},F0=y=>{jn.remove(y.codoxId),delete y.codoxId},Hw=y=>{if(!D0(y)||!y.getChildrenSize())return;const d=y.getChildren();if(d.some(f=>!!(0,be.$isParagraphNode)(f)))return;let g=!1,t=[];for(let f of d)(Ui(f)||En(f)||zl(f)||Ul(f))&&!g&&(Zf(f)||(g=!0)),(D0(f)||En(f))&&t.push(f);for(let f of t)g||f.codoxId?g&&f.codoxId&&(f=f.getWritable(),F0(f)):(f=f.getWritable(),Es(f))},qw=y=>{const d=I0({},y);for(const g in y)y[g]===void 0&&y.hasOwnProperty(g)&&delete d[g];return d},Jw=y=>{const d=`__nativeCreateDOM_${y.name}`;y.prototype[d]=ws(y.prototype.createDOM,d),y.prototype.createDOM=function(g,t){if(L0(this))if(this.codoxId){if(!B0(this)){let r=jn.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}),jn.add(this.codoxId,this)):Es(this)}}else Es(this);else this.codoxId&&F0(this);En(this)&&!this.codoxDId&&(this.codoxDId=Gf()),si.manageNestedEditorInLexicalNode(this);let f=this[d](g,t);return f.__codox_track=!0,f}},Vw=y=>{const d=`__nativeUpdateDOM_${y.name}`;return y.prototype[d]=ws(y.prototype.updateDOM,d),y.prototype.updateDOM=function(){const g=this[d](...arguments);return Hw(this),g},y},Ww=y=>{const d=`__nativeRemove_${y.name}`;return y.prototype[d]=ws(y.prototype.remove,d),y.prototype.remove=function(){const g=this.codoxId;return g&&jn.remove(g),si.gcNestedEditorListenerInLexicalNode(this),this[d](...arguments)},y},Kw=y=>{const d=`__nativeExportJSON_${y.name}`;y.prototype[d]=ws(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),$n(this)&&R0(g.format)&&this.hasFormat&&(g.format=ax(this)),qw(g)}},Gw=y=>{const d="__nativeImportJSON";y[d]=ws(y.importJSON,d),y.importJSON=function(g){const t=I0({},g);$n(t)&&!R0(t.format)&&(t.format=ix(t.format));const f=y[d](t);si.manageNestedEditorInLexicalNode(f);const r=L0(f);return r&&t.codoxId&&(jn.hasPastedId(t.codoxId)&&jn.has(t.codoxId)?(jn.removePastedId(t.codoxId),Es(f)):Es(f,t.codoxId)),r&&!f.codoxId&&Es(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},Yw=y=>{const d="__nativeClone";y[d]=ws(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),si.manageNestedEditorInClonedLexicalNode(g,t),t}},Zw=y=>{let d=!1,g=!1,t=!1,f=!1;y.forEach(n=>{n.name===be.TextNode.name?d=!0:n.name===be.ParagraphNode.name?g=!0:n.name===be.LineBreakNode.name?t=!0:n.name===eo.MarkNode.name&&(f=!0)});let r=[];return d||r.push(be.TextNode),g||r.push(be.ParagraphNode),t||r.push(be.LineBreakNode),f||r.push(eo.MarkNode),r.length?[...r,...y]:y},Qw=function(){return Zw(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(y=>(y.hasOwnProperty("__isCodoxExtended")||(Jw(y),Vw(y),Kw(y),Ww(y),Gw(y),Yw(y),Object.defineProperty(y,"__isCodoxExtended",{value:!0,writable:!1})),y))};var Su=on(777),ks={};ks.styleTagTransform=ai(),ks.setAttributes=oi(),ks.insert=ri().bind(null,"head"),ks.domAPI=ni(),ks.insertStyleElement=ii(),ei()(Su.A,ks),Su.A&&Su.A.locals&&Su.A.locals;var Xw=y=>{var d={};return on.d(d,y),d};const tS=Xw({AutoFocusPlugin:()=>Qg});var eS=y=>{var d={};return on.d(d,y),d};const nS=eS({ClearEditorPlugin:()=>C_});var rS=y=>{var d={};return on.d(d,y),d};const oS=rS({LexicalComposer:()=>Zg});var iS=y=>{var d={};return on.d(d,y),d};const z0=iS({default:()=>k_});var aS=y=>{var d={};return on.d(d,y),d};const sS=aS({HistoryPlugin:()=>hm});var lS=y=>{var d={};return on.d(d,y),d};const cS=lS({OnChangePlugin:()=>T_});var uS=y=>{var d={};return on.d(d,y),d};const dS=uS({PlainTextPlugin:()=>D_});var fS=y=>{var d={};return on.d(d,y),d};const U0=fS({$isRootTextContentEmpty:()=>mm,$rootTextContent:()=>gm});var pS=y=>{var d={};return on.d(d,y),d};const Os=pS({createPortal:()=>Qb.createPortal}),hS=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,gS=hS?Gt.useLayoutEffect:Gt.useEffect,$0=gS;var Cu=on(253),Ts={};Ts.styleTagTransform=ai(),Ts.setAttributes=oi(),Ts.insert=ri().bind(null,"head"),Ts.domAPI=ni(),Ts.insertStyleElement=ii(),ei()(Cu.A,Ts),Cu.A&&Cu.A.locals&&Cu.A.locals;function mS(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 yS(y){let{onClose:d,children:g,title:t,closeOnClickOutside:f=!1}=y;return(0,Os.createPortal)(Gt.createElement(mS,{onClose:d,title:t,closeOnClickOutside:f},g),document.body)}function H0(){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(yS,{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 Eu=on(191),js={};js.styleTagTransform=ai(),js.setAttributes=oi(),js.insert=ri().bind(null,"head"),js.domAPI=ni(),js.insertStyleElement=ii(),ei()(Eu.A,js),Eu.A&&Eu.A.locals&&Eu.A.locals;const bS={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"}},vS=bS;var ku=on(72),As={};As.styleTagTransform=ai(),As.setAttributes=oi(),As.insert=ri().bind(null,"head"),As.domAPI=ni(),As.insertStyleElement=ii(),ei()(ku.A,As),ku.A&&ku.A.locals&&ku.A.locals;function _S(){for(var y=arguments.length,d=new Array(y),g=0;g<y;g++)d[g]=arguments[g];return d.filter(Boolean).join(" ")}function Qf(){return Qf=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},Qf.apply(null,arguments)}function $i(y){let{"data-test-id":d,children:g,className:t,onClick:f,disabled:r,small:n,title:e}=y;return Gt.createElement("button",Qf({disabled:r,className:_S("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},d&&{"data-test-id":d}),g)}var Ou=on(129),Ps={};Ps.styleTagTransform=ai(),Ps.setAttributes=oi(),Ps.insert=ri().bind(null,"head"),Ps.domAPI=ni(),Ps.insertStyleElement=ii(),ei()(Ou.A,Ps),Ou.A&&Ou.A.locals&&Ou.A.locals;var xS=y=>{var d={};return on.d(d,y),d};const wS=xS({ContentEditable:()=>Xg});function SS(y){let{className:d}=y;return Gt.createElement(wS.ContentEditable,{className:d||"ContentEditable__root"})}var Tu=on(457),Ns={};Ns.styleTagTransform=ai(),Ns.setAttributes=oi(),Ns.insert=ri().bind(null,"head"),Ns.domAPI=ni(),Ns.insertStyleElement=ii(),ei()(Tu.A,Ns),Tu.A&&Tu.A.locals&&Tu.A.locals;function CS(y){let{children:d,className:g}=y;return Gt.createElement("div",{className:g||"Placeholder__root"},d)}const ES=z0.default.LexicalErrorBoundary||z0.default,kS=()=>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"})),q0=()=>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"})),OS=()=>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 J0(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 Cn.createNewCommentObj({content:y,author:d,codoxId:g,timeStamp:t,deleted:f})}function jS(y,d,g){return Cn.createNewThreadObj({quote:y,comments:d,codoxId:g})}function AS(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]),$0(()=>{r()},[d,g,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(kS,null)))}function PS(y){let{onEscape:d}=y;const[g]=(0,Fi.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>g.registerCommand(be.KEY_ESCAPE_COMMAND,t=>d(t),2),[g,d]),null}function NS(y){let{editorRef:d}=y;const[g]=(0,Fi.useLexicalComposerContext)();return typeof d=="function"?d(g):typeof d=="object"&&(d.current=g),null}function V0(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:vS};return Gt.createElement(oS.LexicalComposer,{initialConfig:s},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(dS.PlainTextPlugin,{contentEditable:Gt.createElement(SS,{className:d}),placeholder:Gt.createElement(CS,null,n),ErrorBoundary:ES}),Gt.createElement(cS.OnChangePlugin,{onChange:f}),Gt.createElement(sS.HistoryPlugin,null),g!==!1&&Gt.createElement(tS.AutoFocusPlugin,null),Gt.createElement(PS,{onEscape:t}),Gt.createElement(nS.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(NS,{editorRef:r})))}function W0(y,d){return(0,Gt.useCallback)((g,t)=>{g.read(()=>{y((0,U0.$rootTextContent)()),d(!(0,U0.$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=Y0(),a=(0,Gt.useCallback)(()=>{d.getEditorState().read(()=>{const u=(0,be.$getSelection)();if((0,be.$isRangeSelection)(u)){l.current=u.clone();const h=u.anchor,p=u.focus,m=(0,Ca.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,Ca.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,P=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=P-1;O>=E;O--){const R=D[O];k.removeChild(R),D.pop()}}}})},[d,i]);$0(()=>{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=W0(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:s},Gt.createElement(V0,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:u=>(u.preventDefault(),g(),!0),onChange:c}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement($i,{onClick:g,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement($i,{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(jS(u,[J0(f,o)]),!0,void 0,l.current),l.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function RS(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=Y0(),l=W0(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(V0,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:l,editorRef:s,placeholder:t}),Gt.createElement($i,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){d(J0(f,i),!1,g);const o=s.current;o!==null&&o.dispatchCommand(be.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(OS,null)))}function K0(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($i,{onClick:()=>{g(d,f),t()}},"Delete")," ",Gt.createElement($i,{onClick:()=>{t()}},"Cancel")))}function G0(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]=H0();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($i,{onClick:()=>{s("Delete Comment",i=>Gt.createElement(K0,{commentOrThread:d,deleteCommentOrThread:g,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(q0,null)),e))}function MS(y){let{activeIDs:d,comments:g,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=y;const[e]=(0,Fi.useLexicalComposerContext)(),[s,i]=(0,Gt.useState)(0),[l,o]=H0(),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,be.$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($i,{onClick:()=>{o("Delete Thread",p=>Gt.createElement(K0,{commentOrThread:c,deleteCommentOrThread:t,onClose:p}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(q0,null)),l),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},c.comments.map(p=>Gt.createElement(G0,{key:p.codoxId,comment:p,deleteComment:t,thread:c,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(RS,{submitAddComment:r,thread:c,placeholder:"Reply to comment..."})))}return Gt.createElement(G0,{key:u,comment:c,deleteComment:t,rtf:a})}))}function DS(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(MS,{activeIDs:d,comments:t,deleteCommentOrThread:g,listRef:n,submitAddComment:f,markNodeMap:r}))}function Y0(){const y=(0,O0.useCollaborationContext)(),{yjsDocMap:d,name:g}=y;return g||"Playground User"}function LS(y){const[d]=(0,Fi.useLexicalComposerContext)(),g=vx(),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,be.$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}),Cn.removeComment(p.codoxId,h.codoxId),!p)return;const m=p.codoxId,b=t.get(m);d.update(()=>{b?b.forEach((_,v)=>{const w=(0,be.$getNodeByKey)(v);le.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:w}),w&&w.markDirty()}):(0,be.$getRoot)().markDirty(),(0,be.$addUpdateTag)(no.historic),(0,be.$addUpdateTag)(Bl)})}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,be.$getNodeByKey)(_);le.log("[deleteCommentOrThread]: type thread new values",{node:v}),(0,eo.$isMarkNode)(v)&&(v.deleteID(m),v.getIDs().length===0&&(0,eo.$unwrapMarkNode)(v))}else(0,be.$getRoot)().markDirty(),le.debug("[deleteCommentOrThread][refreshComments]");Cn.refreshComments(!0),(0,be.$addUpdateTag)(Bl)})})}},[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?Cn.addComment(m.codoxId,h):Cn.addCommentThread(h),p)d.update(()=>{if((0,be.$isRangeSelection)(b)){const _=b.isBackward(),v=h.codoxId;(0,eo.$wrapSelectionInMarkNode)(b,_,v),(0,be.$addUpdateTag)(Bl)}}),i(!1);else if(!p&&m){const _=m.codoxId,v=t.get(_);if(!v)return void Cn.removeComment(m.codoxId,h.codoxId);d.update(()=>{v.forEach((w,x)=>{let S=(0,be.$getNodeByKey)(x);S&&S.markDirty()}),(0,be.$addUpdateTag)(no.historic),(0,be.$addUpdateTag)(Bl)})}},[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,bs.mergeRegister)((0,bs.registerNestedElementResolver)(d,eo.MarkNode,p=>(0,eo.$createMarkNode)(p.getIDs()),(p,m)=>{p.getIDs().forEach(b=>{m.addID(b)})}),d.registerMutationListener(eo.MarkNode,p=>{d.getEditorState().read(()=>{for(const[m,b]of p){const _=(0,be.$getNodeByKey)(m);let v=[];b==="destroyed"?v=h.get(m)||[]:(0,eo.$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,be.$getSelection)();let v=!1,w=!1;if((0,be.$isRangeSelection)(_)){const x=_.anchor.getNode();if((0,be.$isTextNode)(x)){const S=(0,eo.$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,be.$isRangeSelection)(_)&&i(!1)})}),d.registerCommand($f,()=>{const p=window.getSelection();return p!==null&&p.removeAllRanges(),i(!0),!0},be.COMMAND_PRIORITY_EDITOR))},[d,t]),Gt.createElement(Gt.Fragment,null,s&&(0,Os.createPortal)(Gt.createElement(IS,{editor:d,cancelAddComment:a,submitAddComment:u}),document.body),f!=null&&!s&&(0,Os.createPortal)(Gt.createElement(AS,{anchorKey:f,editor:d,onAddComment:()=>{d.dispatchCommand($f,void 0)}}),document.body),(0,Os.createPortal)(Gt.createElement($i,{className:"CodoxCommentPlugin_ShowCommentsButton "+(l?"active":""),onClick:()=>o(!l),title:l?"Hide Comments":"Show Comments"},Gt.createElement(TS,null)),document.body),l&&(0,Os.createPortal)(Gt.createElement(DS,{comments:g,submitAddComment:u,deleteCommentOrThread:c,activeIDs:n,markNodeMap:t}),document.body))}var ju=on(766),Is={};Is.styleTagTransform=ai(),Is.setAttributes=oi(),Is.insert=ri().bind(null,"head"),Is.domAPI=ni(),Is.insertStyleElement=ii(),ei()(ju.A,Is),ju.A&&ju.A.locals&&ju.A.locals;var Au=on(225),Rs={};Rs.styleTagTransform=ai(),Rs.setAttributes=oi(),Rs.insert=ri().bind(null,"head"),Rs.domAPI=ni(),Rs.insertStyleElement=ii(),ei()(Au.A,Rs),Au.A&&Au.A.locals&&Au.A.locals;function BS(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 Z0(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 Pu(y){for(var d=1;d<arguments.length;d++){var g=arguments[d]!=null?arguments[d]:{};d%2?Z0(Object(g),!0).forEach(function(t){FS(y,t,g[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(g)):Z0(Object(g)).forEach(function(t){Object.defineProperty(y,t,Object.getOwnPropertyDescriptor(g,t))})}return y}function FS(y,d,g){return(d=zS(d))in y?Object.defineProperty(y,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):y[d]=g,y}function zS(y){var d=US(y,"string");return typeof d=="symbol"?d:d+""}function US(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 $l=!1;const $S=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],Hl=214,Q0=150;function HS(y){let{color:d,onChange:g}=y;const[t,f]=(0,Gt.useState)(Ms("hex",d)),[r,n]=(0,Gt.useState)(d),e=(0,Gt.useRef)(null),s=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*Hl,y:(100-t.hsv.v)/100*Q0}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*Hl}),[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=Ms("hex",d);f(l),n(l.hex)},[d]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:Hl},ref:e},Gt.createElement(BS,{label:"Hex",onChange:l=>{if(n(l),/^#[0-9A-Fa-f]{6}$/i.test(l)){const o=Ms("hex",l);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},$S.map(l=>Gt.createElement("button",{className:l===t.hex?" active":"",key:l,style:{backgroundColor:l},onClick:()=>(o=>{n(o);let a=Ms("hex",o);f(a),g(a.hex,$l)})(l)}))),Gt.createElement(X0,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:l=>{let{x:o,y:a}=l;const c=Ms("hsv",Pu(Pu({},t.hsv),{},{s:o/Hl*100,v:100-a/Q0*100}));f(c),n(c.hex),g(c.hex,$l)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:s.x,top:s.y}})),Gt.createElement(X0,{className:"codox-color-picker-hue",onChange:l=>{let{x:o}=l;const a=Ms("hsv",Pu(Pu({},t.hsv),{},{h:o/Hl*360}));f(a),n(a.hex),g(a.hex,$l)}},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 X0(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=ty(s.clientX-a,l,0),h=ty(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,$l=!0,e(o)},l=o=>{n.current&&($l=!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 ty(y,d,g){return y>d?d:y<g?g:y}function ey(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 ny(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 Xf(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 qS(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 ry(y){let{b:d,g,r:t}=y;return"#"+[t,g,d].map(f=>f.toString(16).padStart(2,"0")).join("")}function Ms(y,d){let g=ey("#121212"),t=ny(g),f=Xf(t);return y==="hex"?(g=ey(d),t=ny(g),f=Xf(t)):y==="rgb"?(t=d,g=ry(t),f=Xf(t)):y==="hsv"&&(f=d,t=qS(f),g=ry(t)),{hex:g,hsv:f,rgb:t}}const JS=Gt.createContext(null),oy=4;function VS(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(JS.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 WS(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+oy}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+oy;_!==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,Os.createPortal)(Gt.createElement(VS,{dropDownRef:o,onClose:()=>{u(!1),a&&a.current&&a.current.focus()},dropdownClassName:s},n),document.body))}const KS=["disabled","stopCloseOnClickSelf","color","onChange"];function tp(){return tp=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},tp.apply(null,arguments)}function GS(y,d){if(y==null)return{};var g,t,f=YS(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 YS(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 iy(y){let{disabled:d=!1,stopCloseOnClickSelf:g=!0,color:t,onChange:f}=y,r=GS(y,KS);return Gt.createElement(WS,tp({},r,{disabled:d,stopCloseOnClickSelf:g}),Gt.createElement(HS,{color:t,onChange:f}))}const ZS=y=>{let{onColorChange:d,buttonClassName:g,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=y;const[i]=(0,Fi.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,c]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,bs.mergeRegister)(i.registerEditableListener(h=>{o(h)}),i.registerUpdateListener(h=>{let{editorState:p}=h;p.read(()=>{const m=(0,be.$getSelection)();if((0,be.$isRangeSelection)(m)){let b=(0,Ca.$getSelectionStyleValueForProperty)(m,"color");b!==a&&(c(b||""),d(b))}})})),[i]);const u=(0,Gt.useCallback)((h,p)=>{i.update(()=>{const m=(0,be.$getSelection)();m!==null&&(0,Ca.$patchStyleText)(m,{color:h})})},[i]);return Gt.createElement(iy,{disabled:!l,color:a,onChange:u,buttonClassName:g||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},QS=ZS,XS=y=>{let{onColorChange:d,buttonClassName:g,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=y;const[i]=(0,Fi.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,c]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,bs.mergeRegister)(i.registerEditableListener(h=>{o(h)}),i.registerUpdateListener(h=>{let{editorState:p}=h;p.read(()=>{const m=(0,be.$getSelection)();if((0,be.$isRangeSelection)(m)){let b=(0,Ca.$getSelectionStyleValueForProperty)(m,"background-color");b!==a&&(c(b||""),d(b))}})})),[i]);const u=(0,Gt.useCallback)((h,p)=>{i.update(()=>{const m=(0,be.$getSelection)();m!==null&&(0,Ca.$patchStyleText)(m,{"background-color":h})})},[i]);return Gt.createElement(iy,{disabled:!l,color:a,onChange:u,buttonClassName:g||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},t2=XS;var e2=Mi.yy;Mi._U,Mi.a8,Mi.Vs,Mi.Cn;var n2=Mi.gK,r2=Mi.vv;function o2(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var Nu=o2(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 i2({hasCellMerge:y=!0,hasCellBackgroundColor:d=!0,hasTabHandler:g=!0}){const[t]=jr();return Ce.useEffect(()=>(t.hasNodes([bo,Ao,xa])||Nu(10),mo(t.registerCommand(i_,({columns:f,rows:r,includeHeaders:n})=>{const e=Lm(Number(r),Number(f),n);um(e);const s=e.getFirstDescendant();return Ne(s)&&s.select(),!0},an),t.registerNodeTransform(bo,f=>{const[r]=Um(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=Xo(0);o.append(Un()),i!==null?i.insertAfter(o):dm(i,o)}}}))),[t]),Ce.useEffect(()=>{const f=new Map,r=e=>{const s=e.getKey(),i=t.getElementByKey(s);if(i&&!f.has(s)){const l=b_(e,i,t,g);f.set(s,l)}};t.getEditorState().read(()=>{const e=Xh(bo);for(const s of e)Pn(s)&&r(s)});const n=t.registerMutationListener(bo,e=>{for(const[s,i]of e)if(i==="created")t.getEditorState().read(()=>{const l=Vn(s);Pn(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]),Ce.useEffect(()=>{if(!y)return t.registerNodeTransform(Ao,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=qr(f),[n]=Po(r,f,f),e=n.length,s=n[0].length;let i=r.getFirstChild();sr(i)||Nu(175);const l=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),sr(i)||Nu(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){rn(h)||Nu(176);const p=Xo(h.__headerState);a!==null?a.insertAfter(p):dm(i,p)}}}for(const o of l)o.setColSpan(1),o.setRowSpan(1)}})},[t,y]),Ce.useEffect(()=>{if(!d)return t.registerNodeTransform(Ao,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,d,y]),null}const a2={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"},s2="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",l2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",ay=Qn.createContext(null),sy=4;function Iu({children:y,className:d,onClick:g,title:t}){const f=Ce.useRef(null),r=Qn.useContext(ay);if(r===null)throw new Error("DropDownItem must be used within a DropDown");const{registerItem:n}=r;return Ce.useEffect(()=>{f&&f.current&&n(f)},[f,n]),he.jsx("button",{className:d,onClick:g,ref:f,title:t,type:"button",children:y})}function c2({children:y,dropDownRef:d,onClose:g}){const[t,f]=Ce.useState(),[r,n]=Ce.useState(),e=Ce.useCallback(l=>{f(o=>o?[...o,l]:[l])},[f]),s=l=>{if(!t)return;const o=l.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(o)&&l.preventDefault(),o==="Escape"||o==="Tab"?g():o==="ArrowUp"?n(a=>{if(!a)return t[0];const c=t.indexOf(a)-1;return t[c===-1?t.length-1:c]}):o==="ArrowDown"&&n(a=>a?t[t.indexOf(a)+1]:t[0])},i=Ce.useMemo(()=>({registerItem:e}),[e]);return Ce.useEffect(()=>{t&&!r&&n(t[0]),r&&r.current&&r.current.focus()},[t,r]),he.jsx(ay.Provider,{value:i,children:he.jsx("div",{className:"dropdown",ref:d,onKeyDown:s,children:y})})}function u2({disabled:y=!1,buttonLabel:d,buttonAriaLabel:g,buttonClassName:t,buttonIconClassName:f,children:r,stopCloseOnClickSelf:n}){const e=Ce.useRef(null),s=Ce.useRef(null),[i,l]=Ce.useState(!1),o=()=>{l(!1),s&&s.current&&s.current.focus()};return Ce.useEffect(()=>{const a=s.current,c=e.current;if(i&&a!==null&&c!==null){const{top:u,left:h}=a.getBoundingClientRect();c.style.top=`${u+a.offsetHeight+sy}px`,c.style.left=`${Math.min(h,window.innerWidth-c.offsetWidth-20)}px`}},[e,s,i]),Ce.useEffect(()=>{const a=s.current;if(a!==null&&i){const c=u=>{const h=u.target;n&&e.current&&e.current.contains(h)||a.contains(h)||l(!1)};return document.addEventListener("click",c),()=>{document.removeEventListener("click",c)}}},[e,s,i,n]),Ce.useEffect(()=>{const a=()=>{if(i){const c=s.current,u=e.current;if(c!==null&&u!==null){const{top:h}=c.getBoundingClientRect(),p=h+c.offsetHeight+sy;p!==u.getBoundingClientRect().top&&(u.style.top=`${p}px`)}}};return document.addEventListener("scroll",a),()=>{document.removeEventListener("scroll",a)}},[s,e,i]),he.jsxs(he.Fragment,{children:[he.jsxs("button",{type:"button",disabled:y,"aria-label":g||d,className:t,onClick:()=>l(!i),ref:s,children:[f&&he.jsx("span",{className:f}),d&&he.jsx("span",{className:"text dropdown-button-text",children:d}),he.jsx("i",{className:"chevron-down"})]}),i&&$r.createPortal(he.jsx(c2,{dropDownRef:e,onClose:o,children:r}),document.body)]})}function ly(){return he.jsx("div",{className:"divider"})}const ep=8,np=72,Ds={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",paragraph:"Normal"},rp={h1:{fontFamily:"Arial",fontSize:25,fontColor:"#000000",leadingSpace:.5,trailingSpace:.5},h2:{fontFamily:"Verdana",fontSize:20,fontColor:"#111111",leadingSpace:.3,trailingSpace:.4},h3:{fontFamily:"Arial",fontSize:16,fontColor:"#222222",leadingSpace:.2,trailingSpace:.3},paragraph:{fontFamily:"Arial",fontSize:11,fontColor:"#333333",leadingSpace:.1,trailingSpace:.2}};function d2({selectionFontSize:y,disabled:d,editor:g,blockType:t}){const[f,r]=Qn.useState(y),[n,e]=Qn.useState(t),s=c=>{g.update(()=>{if(g.isEditable()){const u=Oe();u!==null&&im(u,c)}})},i=c=>{r(c.target.value)},l=()=>{const c=Number(f);if(!isNaN(c)){const u=Math.min(Math.max(c,ep),np);r(String(u)),s({"font-size":`${u}px`})}},o=c=>{const u=rp[n].fontSize,h=c?Math.min(u+2,np):Math.max(u-2,ep);r(String(h)),s({"font-size":`${h}px`})},a=c=>{if(e(c),c==="paragraph"){const u=rp.paragraph;cy(),r(String(u.fontSize)),s({"font-size":`${u.fontSize}px`,color:u.fontColor,"font-family":u.fontFamily,"line-height":`${1+u.leadingSpace}em`,"margin-bottom":`${u.trailingSpace}em`})}else{const{fontSize:u,fontColor:h,fontFamily:p,leadingSpace:m,trailingSpace:b}=rp[c];cy(),r(String(u)),s({"font-size":`${u}px`,color:h,"font-family":p,"line-height":`${1+m}em`,"margin-bottom":`${b}em`})}};return Qn.useEffect(()=>{const c=()=>{g.update(()=>{const u=Oe();if(u!==null){const p=u.getNodes()[0];if(!Ne(p)){const m=p.getType();m in Ds&&e(m)}}})};return g.registerUpdateListener(c),()=>{g.registerUpdateListener(c)}},[g]),he.jsxs(he.Fragment,{children:[he.jsx("button",{type:"button",disabled:d,onClick:()=>o(!1),className:"toolbar-item font-decrement"}),he.jsx("input",{type:"number",value:f,disabled:d,readOnly:!0,className:"toolbar-item font-size-input",min:ep,max:np,onChange:i,onBlur:l}),he.jsx("button",{type:"button",disabled:d,onClick:()=>o(!0),className:"toolbar-item font-increment"}),he.jsx(ly,{}),he.jsxs("div",{className:"symbol-dropdown cust-head-dropDown",children:[he.jsxs(u2,{disabled:d,buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"Formatting options for text style",buttonIconClassName:"icon block-type "+n,buttonLabel:Ds[n],children:[he.jsxs(Iu,{className:`item ${n==="paragraph"?"active":""}`,onClick:()=>a("paragraph"),children:[he.jsx("i",{className:"icon paragraph"}),he.jsx("span",{className:"text",children:Ds.paragraph})]}),he.jsxs(Iu,{className:`item ${n==="h1"?"active":""}`,onClick:()=>a("h1"),children:[he.jsx("i",{className:"icon h1"}),he.jsx("span",{className:"text",children:Ds.h1})]}),he.jsxs(Iu,{className:`item ${n==="h2"?"active":""}`,onClick:()=>a("h2"),children:[he.jsx("i",{className:"icon h2"}),he.jsx("span",{className:"text",children:Ds.h2})]}),he.jsxs(Iu,{className:`item ${n==="h3"?"active":""}`,onClick:()=>a("h3"),children:[he.jsx("i",{className:"icon h3"}),he.jsx("span",{className:"text",children:Ds.h3})]})]}),he.jsx(ly,{})]})]})}function cy(y){throw new Error("Function not implemented.")}const f2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",p2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function h2(){const[y,d]=Ce.useState("4"),[g,t]=Ce.useState("4"),[f,r]=Ce.useState(!1),[n,e]=Ce.useState(),[s]=jr(),i=()=>{!y||!g||(s.update(()=>{const l=Lm(y,g,!0),o=um(l);e(o)}),r(!1))};return he.jsxs(he.Fragment,{children:[he.jsx("button",{className:"toolbar-item ",onClick:()=>r(!0),children:he.jsx("img",{className:"add-toolbar-table-icon",src:p2,alt:"Add Table"})}),f&&he.jsx("div",{className:"modal-overlay",children:he.jsxs("div",{className:"modal-content",children:[he.jsx("h3",{children:"Select Table Dimensions"}),he.jsx("button",{className:"modal-buttons-close",onClick:()=>r(!1),children:he.jsx("img",{src:f2,height:16,width:16,style:{margin:"0 0 29px 10px"}})}),he.jsxs("div",{className:"select-table-container",children:[he.jsx("label",{children:"Rows"}),he.jsx("input",{type:"number",value:y,onChange:l=>d(Number(l.target.value))})]}),he.jsxs("div",{className:"select-table-container",children:[he.jsx("label",{children:"Column"}),he.jsx("input",{type:"number",value:g,onChange:l=>t(Number(l.target.value))})]}),he.jsx("div",{children:he.jsx("div",{className:"modal-buttons",children:he.jsx("button",{className:"toolbar-item",onClick:i,children:"Confirm"})})})]})})]})}const uy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNCAxMkgyME0xMiA0VjIwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==",dy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNiAxMkwxOCAxMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=";var g2=typeof global=="object"&&global&&global.Object===Object&&global;const m2=g2;var y2=typeof self=="object"&&self&&self.Object===Object&&self,b2=m2||y2||Function("return this")();const fy=b2;var v2=fy.Symbol;const Ru=v2;var py=Object.prototype,_2=py.hasOwnProperty,x2=py.toString,ql=Ru?Ru.toStringTag:void 0;function w2(y){var d=_2.call(y,ql),g=y[ql];try{y[ql]=void 0;var t=!0}catch{}var f=x2.call(y);return t&&(d?y[ql]=g:delete y[ql]),f}var S2=Object.prototype,C2=S2.toString;function E2(y){return C2.call(y)}var k2="[object Null]",O2="[object Undefined]",hy=Ru?Ru.toStringTag:void 0;function T2(y){return y==null?y===void 0?O2:k2:hy&&hy in Object(y)?w2(y):E2(y)}function j2(y){return y!=null&&typeof y=="object"}var A2="[object Symbol]";function P2(y){return typeof y=="symbol"||j2(y)&&T2(y)==A2}var N2=/\s/;function I2(y){for(var d=y.length;d--&&N2.test(y.charAt(d)););return d}var R2=/^\s+/;function M2(y){return y&&y.slice(0,I2(y)+1).replace(R2,"")}function op(y){var d=typeof y;return y!=null&&(d=="object"||d=="function")}var gy=0/0,D2=/^[-+]0x[0-9a-f]+$/i,L2=/^0b[01]+$/i,B2=/^0o[0-7]+$/i,F2=parseInt;function my(y){if(typeof y=="number")return y;if(P2(y))return gy;if(op(y)){var d=typeof y.valueOf=="function"?y.valueOf():y;y=op(d)?d+"":d}if(typeof y!="string")return y===0?y:+y;y=M2(y);var g=L2.test(y);return g||B2.test(y)?F2(y.slice(2),g?2:8):D2.test(y)?gy:+y}var z2=function(){return fy.Date.now()};const ip=z2;var U2="Expected a function",$2=Math.max,H2=Math.min;function q2(y,d,g){var t,f,r,n,e,s,i=0,l=!1,o=!1,a=!0;if(typeof y!="function")throw new TypeError(U2);d=my(d)||0,op(g)&&(l=!!g.leading,o="maxWait"in g,r=o?$2(my(g.maxWait)||0,d):r,a="trailing"in g?!!g.trailing:a);function c(x){var S=t,E=f;return t=f=void 0,i=x,n=y.apply(E,S),n}function u(x){return i=x,e=setTimeout(m,d),l?c(x):n}function h(x){var S=x-s,E=x-i,k=d-S;return o?H2(k,r-E):k}function p(x){var S=x-s,E=x-i;return s===void 0||S>=d||S<0||o&&E>=r}function m(){var x=ip();if(p(x))return b(x);e=setTimeout(m,h(x))}function b(x){return e=void 0,a&&t?c(x):(t=f=void 0,n)}function _(){e!==void 0&&clearTimeout(e),i=0,t=s=f=e=void 0}function v(){return e===void 0?n:b(ip())}function w(){var x=ip(),S=p(x);if(t=arguments,f=this,s=x,S){if(e===void 0)return u(s);if(o)return clearTimeout(e),e=setTimeout(m,d),c(s)}return e===void 0&&(e=setTimeout(m,d)),n}return w.cancel=_,w.flush=v,w}function J2(y,d,g){const t=Ce.useRef(null);return t.current=y,Ce.useMemo(()=>q2((...f)=>{t.current&&t.current(...f)},d,{maxWait:g}),[d,g])}const yy=20;function V2({anchorElem:y}){const[d]=jr(),g=au(),[t,f]=Ce.useState(!1),[r,n]=Ce.useState(!1),[e,s]=Ce.useState(!1),[i,l]=Ce.useState({}),o=Ce.useRef(new Set),a=Ce.useRef(null),c=J2(m=>{const{isOutside:b,tableDOMNode:_}=W2(m);if(b){f(!1),n(!1);return}if(!_)return;a.current=_;let v=null,w=null,x=null;if(d.update(()=>{var E;const S=rr(_);if(rn(S)){const k=vn(S,D=>Pn(D));if(!Pn(k))return;if(x=d.getElementByKey(k==null?void 0:k.getKey()),x){const D=k.getChildrenSize(),P=(E=k.getChildAtIndex(0))==null?void 0:E.getChildrenSize(),O=u_(S),R=Fm(S);O===D-1?v=S:R===P-1&&(w=S)}}}),x){const{width:S,y:E,right:k,left:D,bottom:P,height:O}=x.getBoundingClientRect(),{y:R,left:A}=y.getBoundingClientRect();v?(n(!1),f(!0),l({height:yy,left:D-A,top:P-R+5,width:S})):w&&(n(!0),f(!1),l({height:O,left:k-A+5,top:E-R,width:yy}))}},50,250),u=Ce.useMemo(()=>new ResizeObserver(()=>{f(!1),n(!1)}),[]);Ce.useEffect(()=>{if(e)return document.addEventListener("mousemove",c),()=>{f(!1),n(!1),c.cancel(),document.removeEventListener("mousemove",c)}},[e,c]),Ce.useEffect(()=>mo(d.registerMutationListener(bo,m=>{d.getEditorState().read(()=>{for(const[b,_]of m){const v=d.getElementByKey(b);switch(_){case"created":o.current.add(b),s(o.current.size>0),v&&u.observe(v);break;case"destroyed":o.current.delete(b),s(o.current.size>0),u.disconnect(),o.current.forEach(w=>{const x=d.getElementByKey(w);x&&u.observe(x)});break}}})})),[d,u]);const h=m=>{d.update(()=>{if(a.current){const b=rr(a.current);b==null||b.selectEnd(),m?(d_(),f(!1)):(f_(),n(!1))}})},p=m=>{d.update(()=>{if(a.current){const b=rr(a.current);b==null||b.selectEnd(),m?(p_(),f(!1)):(h_(),n(!1))}})};return g?he.jsxs(he.Fragment,{children:[t&&he.jsxs("div",{children:[he.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%",padding:"20px"},onClick:()=>h(!0),children:he.jsx("img",{src:uy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),he.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%"},onClick:()=>p(!0),children:he.jsx("img",{src:dy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]}),r&&he.jsxs("div",{className:"table-add-row-flex-container",children:[he.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%",padding:"20px"},onClick:()=>h(!1),children:he.jsx("img",{src:uy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),he.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%"},onClick:()=>p(!1),children:he.jsx("img",{src:dy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]})]}):null}function W2(y){const d=y.target;if(d&&d instanceof HTMLElement){const g=d.closest("td.PlaygroundEditorTheme__tableCell, th.PlaygroundEditorTheme__tableCell");return{isOutside:!(g||d.closest("button.PlaygroundEditorTheme__tableAddRows")||d.closest("button.PlaygroundEditorTheme__tableAddColumns")||d.closest("div.TableCellResizer__resizer")),tableDOMNode:g}}else return{isOutside:!0,tableDOMNode:null}}function K2({anchorElem:y=document.body}){return au()?$r.createPortal(he.jsx(V2,{anchorElem:y}),y):null}const ap=1;function sp(){return he.jsx("div",{className:"divider"})}function G2({renderOnlineUsers:y}){const[d]=jr(),g=Ce.useRef(null),[t,f]=Ce.useState(!1),[r,n]=Ce.useState(!1),[e,s]=Ce.useState(!1),[i,l]=Ce.useState(!1),[o,a]=Ce.useState(!1),[c,u]=Ce.useState(!1),[h,p]=Ce.useState(!1),[m,b]=Ce.useState(!1),[_,v]=Ce.useState("11px"),[w,x]=Ce.useState(()=>d.isEditable()),S=Ce.useCallback(()=>{const E=Oe();xe(E)&&(s(E.hasFormat("bold")),l(E.hasFormat("italic")),a(E.hasFormat("underline")),u(E.hasFormat("strikethrough")),p(E.hasFormat("subscript")),b(E.hasFormat("superscript")),v(am(E,"font-size","11px")))},[]);return Ce.useEffect(()=>mo(d.registerUpdateListener(({editorState:E})=>{E.read(()=>{S()})}),d.registerCommand(Wo,(E,k)=>(S(),!1),ap),d.registerCommand(ts,E=>(f(E),!1),ap),d.registerCommand(Xa,E=>(n(E),!1),ap)),[d,S]),he.jsxs("div",{className:"toolbar",ref:g,children:[he.jsx("button",{disabled:!t,onClick:()=>{d.dispatchCommand(cl,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:he.jsx("i",{className:"format undo"})}),he.jsx("button",{disabled:!r,onClick:()=>{d.dispatchCommand(ul,void 0)},className:"toolbar-item","aria-label":"Redo",children:he.jsx("i",{className:"format redo"})}),he.jsx(sp,{}),he.jsx(d2,{selectionFontSize:_.slice(0,-2),editor:d,disabled:!w,blockType:"paragraph"}),he.jsx(sp,{}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"bold")},className:"toolbar-item spaced "+(e?"active":""),"aria-label":"Format Bold",children:he.jsx("i",{className:"format bold"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"italic")},className:"toolbar-item spaced "+(i?"active":""),"aria-label":"Format Italics",children:he.jsx("i",{className:"format italic"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"underline")},className:"toolbar-item spaced "+(o?"active":""),"aria-label":"Format Underline",children:he.jsx("i",{className:"format underline"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"strikethrough")},className:"toolbar-item spaced "+(c?"active":""),"aria-label":"Format Strikethrough",children:he.jsx("i",{className:"format strikethrough"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"superscript")},className:"toolbar-item spaced "+(m?"active":""),"aria-label":"Format SuperScript",children:he.jsx("img",{src:l2,height:16,width:16,style:{marginTop:"1px"}})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Er,"subscript")},className:"toolbar-item spaced "+(h?"active":""),"aria-label":"Format SubScript",children:he.jsx("img",{src:s2,height:16,width:16,style:{marginTop:"1px"}})}),he.jsx(sp,{}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Qa,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:he.jsx("i",{className:"format left-align"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Qa,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:he.jsx("i",{className:"format center-align"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Qa,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:he.jsx("i",{className:"format right-align"})}),he.jsx("button",{onClick:()=>{d.dispatchCommand(Qa,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:he.jsx("i",{className:"format justify-align"})}),he.jsx(h2,{}),he.jsx(K2,{}),he.jsx("div",{className:"avtar-outer-div",children:y()})]})}const lp=n2([...[bo,xa,Ao]]);function Y2(){return he.jsx("div",{className:"editor-placeholder"})}const Z2={namespace:"React.js Demo",nodes:lp,onError(y){throw y},theme:a2},Q2=()=>he.jsx(he.Fragment,{children:"hello"});function X2({collabApiKey:y,spfList:d,userObj:g}){const[t,f]=Ce.useState(!1),[r,n]=Ce.useState([]),[e,s]=Ce.useState("demo_docId_1"),[i,l]=Ce.useState({root:null}),{userId:o,userName:a,userEmail:c}=g,u=Ce.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))};Ce.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}};Ce.useEffect(()=>{(async()=>{if(!e)return;t&&b();let w=_;if(w)try{r2(w,lp),console.log("afsjdjs"),l(w)}catch(x){console.error("[APP] error: ",x)}})()},[e]),Ce.useEffect(()=>{i&&e&&!t&&m()},[i,e,t]),Ce.useMemo(()=>({editorState:i?JSON.stringify({root:i.root}):null,namespace:"Playground",nodes:lp,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(he.jsxs("div",{title:S.email,className:`avatarStyle avatar-color-${E+1}`,children:[" ",S.name&&S.name[0],S.name&&S.name[4]]},E)))}),he.jsx("div",{className:"flexContainer",children:w})};return he.jsx("div",{children:he.jsx(Zg,{initialConfig:Z2,children:he.jsxs("div",{className:"editor-container",children:[he.jsx(G2,{renderOnlineUsers:v}),he.jsxs("div",{className:"editor-inner",children:[he.jsx(Z1,{contentEditable:he.jsx(Xg,{className:"editor-input"}),placeholder:he.jsx(Y2,{}),ErrorBoundary:Q2}),he.jsx(e2,{ref:u}),he.jsx(hm,{}),he.jsx(i2,{}),he.jsx(Qg,{})]})]})})})}Mr.Editor=X2,Object.defineProperty(Mr,Symbol.toStringTag,{value:"Module"})});
|
|
1430
1430
|
//# sourceMappingURL=index.umd.js.map
|