sykpcomposer 0.0.255 → 0.0.256
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/{ImageComponent-1844a69d.js → ImageComponent-2de0808d.js} +3 -3
- package/dist/{ImageComponent-1844a69d.js.map → ImageComponent-2de0808d.js.map} +1 -1
- package/dist/{InlineImageComponent-b0672dcf.js → InlineImageComponent-2d3ae046.js} +3 -3
- package/dist/{InlineImageComponent-b0672dcf.js.map → InlineImageComponent-2d3ae046.js.map} +1 -1
- package/dist/{LexicalNestedComposer.prod-8ab06bb5.js → LexicalNestedComposer.prod-b1e8e0ed.js} +2 -2
- package/dist/{LexicalNestedComposer.prod-8ab06bb5.js.map → LexicalNestedComposer.prod-b1e8e0ed.js.map} +1 -1
- package/dist/{index-7c231e11.js → index-ef98e4fa.js} +4 -4
- package/dist/{index-7c231e11.js.map → index-ef98e4fa.js.map} +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
package/dist/index.umd.js
CHANGED
|
@@ -1504,5 +1504,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1504
1504
|
left: ${t?"0px":"100%"};
|
|
1505
1505
|
z-index: 10;
|
|
1506
1506
|
`,R.append(O),b=O}!P&&x.width<1&&n.length>1&&(R.style.width="3px")}_.forEach(C=>{this.hoverList.push([C,b,o])})});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(i){let p=!1,e=i.target,l=!1,n=3;for(;n&&e;){if(e.__codox_track){p=!0;break}if(e.__lexicalEditor){p=!0,l=!0;break}e=e.parentNode,n--}if(!p)return;let t=null;for(let r in this.activeEditorsKeys){if(e[`__lexicalKey_${r}`]){t=r;break}e.__lexicalEditor&&(t=e.__lexicalEditor._key)}if(!t)return;let o=l?"root":e[`__lexicalKey_${t}`];if(!o||!this.trackedNodesKeys.has(`${o}__${t}`))return;let a=new Set;for(let r=0;r<this.hoverList.length;r++){let d=this.hoverList[r],[s,u,c]=d;if(a.has(c))continue;let f=Qr.isMousePositionWithinElementCords(i,s);i.type===xo.mouseover&&f&&(u.style.animation=this.isEditingInProgress?Qr.tooltipAnimations.hideAtOnce:Qr.tooltipAnimations.showAtOnce,a.add(c)),i.type===xo.mouseout&&(u.style.animation=Qr.tooltipAnimations.hideWithDelay,a.add(c)),i.type===xo.mousemove&&f&&(u.style.animation=this.isEditingInProgress?Qr.tooltipAnimations.hideAtOnce:Qr.tooltipAnimations.showAtOnce,a.add(c))}}_keyboardEventsListener(i){i.type===xo.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),i.type===xo.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(i){Vt.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(xo.keypress,this.keyboardBindedListener),window.addEventListener(xo.keyup,this.keyboardBindedListener),window.addEventListener(xo.resize,this.resizeBindedListener),window.addEventListener(xo.scroll,this.resizeBindedListener);for(const i of rv)window.addEventListener(i,this.mouseBindedListener)}unmount(){window.removeEventListener(xo.keypress,this.keyboardBindedListener),window.removeEventListener(xo.keyup,this.keyboardBindedListener),window.removeEventListener(xo.resize,this.resizeBindedListener),window.removeEventListener(xo.scroll,this.resizeBindedListener);for(const i of rv)window.removeEventListener(i,this.mouseBindedListener);this.gcPrevPaintedRemoteSelections()}shouldUpdateRemoteSelections(){return!0}gcPrevPaintedRemoteSelections(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];for(let p in this.remoteSelectionDOMsMap)this.remoteSelectionDOMsMap[p].remove();this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelections=i||[],this.remoteSelectionDOMsMap={},this.activeEditorsKeys={}}paintRemoteSelections(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];this.gcPrevPaintedRemoteSelections(i);let p=Vt.getMainEditorState();p.read&&p.read(()=>{for(let e of this.remoteSelections)if(lg.validateJSONSelection(e,ig.remote))if(cn.isNestedSelectionJSON(e)){let{nestedSelectionJSON:l,nestedEditor:n}=cn.getNestedSelectionJSONFromMainSelectionJSON(e);if(!n)continue;n.getEditorState().read(()=>{let t=cn.JSONToLexical(l);if(t)try{this.paintSingleRemoteSelection({editor:n,selectionJSON:e,lexicalSelection:t,selectedNodes:t.getNodes(),isBackward:t.isBackward()})}catch(o){At.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:o,nestedSelectionJSON:l,fullSelection:e,lexicalSelection:t})}else At.error("DEBUGGER: [paintRemoteSelections] nested selection from json to lexical is null: ",{selection:e,nestedSelectionJSON:l,lexicalSelection:t})})}else{let l=cn.JSONToLexical(e);if(!l){At.error("DEBUGGER: [paintRemoteSelections] selection from json to lexical is null: ",{selection:e,lexicalSelection:l});continue}try{this.paintSingleRemoteSelection({editor:Vt.getMainEditor(),selectionJSON:e,lexicalSelection:l,selectedNodes:l.getNodes(),isBackward:l.isBackward()})}catch(n){At.warn("[PAINT REMOTE SELECTION] failed - ",{error:n,fullSelection:e,lexicalSelection:l})}}})}updateRemoteSelections(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";this.shouldUpdateRemoteSelections(i)&&(At.log("[updateRemoteSelections] "+p,{newRemoteSelections:i}),Promise.resolve().then(()=>{this.paintRemoteSelections(i),this.hideInUI&&this.hideRemoteSelectionsFromUI()}))}clear(){this.gcPrevPaintedRemoteSelections()}getCurrentRemoteSelections(){return this.remoteSelections}hideRemoteSelectionsFromUI(){this.hideInUI||(this.hideInUI=!0);const i=document.querySelectorAll(".codox_remote_selection");for(let p of i)p.classList.add("hidden_codox_remote_selection")}showHiddenRemoteSelectionsInUI(){this.hideInUI=!1;const i=document.querySelectorAll(".hidden_codox_remote_selection");for(let p of i)p.classList.remove("hidden_codox_remote_selection")}}const Bi=new uO;function dO(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(h=>h===Vs.editorState)}function vf(h){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=Vt.getMainEditorNodesClassesMap();const{klass:e}=p.get(h.type)||{};if(!e)return;const l=e.importJSON(h);if(h.children&&h.children.length)for(const n of h.children)vf(n,l);return i&&i.getChildrenSize&&i.splice(i.getChildrenSize(),0,[l]),l}function _f(h){if(h.getChildren)for(let i of h.getChildren())_f(i);h.remove()}function xv(h){h.__parent=null,h.__next=null,h.__prev=null}function wv(h,i){return!!Vt.isLexicalEditorInstance(h)&&!(typeof i!="object"||!i.editorState||(h.update(()=>{try{let p=(0,Ft.$getSelection)();const e=h.parseEditorState(i.editorState);if(e.isEmpty())return(0,Ft.$getRoot)().clear(),!0;(0,Ft.$setSelection)(p),h.setEditorState(e)}catch(p){At.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",p)}}),0))}function fO(h,i){let p=i;for(const e of h)p=p[e];return p}function Ks(h){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=arguments.length>2&&arguments[2]!==void 0&&arguments[2],e=null,l=fO(h,p?i:Vt.getMainEditorState().toJSON());return l&&(e=Ys(l)?(0,Ft.$getRoot)():Or.get(l.codoxId)),e||At.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:l,lexicalNode:e,pathArray:h,currentStateJSON:Vt.getMainEditorState().toJSON(),newStateJSON:i,codoxNodes:Or.nodesToArray(),searchInNewState:p}),e||(p?e:Ks(h,i,!0))}function Sv(h){At.log("[applyFullLexicalStateReplace] clear current state and apply new");const i=(0,Ft.$getRoot)();i.clear();let p=Vt.getMainEditorNodesClassesMap();function e(l){const n=p.get(l.type).klass.importJSON(l);if(l.children)for(const t of l.children)n.append(e(t));return n}for(const l of h.root.children)i.append(e(l))}function pO(h){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(i.length){At.log("[applyDeltasToLexicalState] Original Deltas: ",{newStateJSON:h,deltas:JSON.parse(JSON.stringify(i))});for(const p of i){let{p:e}=p;const l=e[e.length-1],n=l==="children",t=typeof l=="number",o=!t&&!n,a=dO(e),r=a!==-1,d=p.hasOwnProperty("lm")&&typeof p.lm=="number";if(e.length)if(r){let s=a-1,u=Ks(e.slice(0,s),h);if(u){let c=e.slice(0,a),f=h;for(const g of c)f=f[g];let y=xu(e[s]);wv(u.getWritable()[y],f)}}else{if(n){let s=p.oi;if(!s){At.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:p});continue}if(s.some(c=>!(!c.hasOwnProperty("text")||typeof c.text=="string"))){At.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:p});continue}e.length=e.length-1;let u=Ks(e,h);if(!u)continue;if(s.some(c=>!!c.codoxDId)){try{u=u.getWritable()}catch(g){At.debug("[applyDeltasToLexicalState][shouldUpdateLeaves] getWritable error: ",{err:g,delta:p,fullStateJSON:h});continue}let c={};for(let g of u.getChildren())g.codoxDId?c[g.codoxDId]=g:_f(g);let f=[],y=["codoxDId","codoxId","__key","__parent","__prev","__next"];for(let g=0;g<s.length;g++){let v=s[g],_=g===0,b=g===s.length-1,S=null,C=g>=0?f[g-1]:null;if(v.codoxDId){let x=c[v.codoxDId];if(x){x=x.getWritable();let m=vf(v);if(At.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:x,tmpDecorator:m}),!m){At.debug("[DELTA_DECORATOR_UPDATE] UPADATE SKIPPED: ",{exisingDecorator:x,tmpDecorator:m});continue}for(let w in m)if(m.hasOwnProperty(w)&&!y.includes(w))if(Vt.isLexicalEditorInstance(m[w])){let E={editorState:m[w].getEditorState().toJSON()};wv(x[w],E)}else{let E=og(w),N=v[E];if(N===x[w]||!v.hasOwnProperty(E))continue;let M=N!==void 0&&m[w]!==N?N:m[w];E!=="height"&&E!=="width"||m[w]==="inherit"&&N===0&&(M=m[w]),x[w]=M}m.remove(),xv(x),S=x,delete c[v.codoxDId]}}S||(S=vf(v),S.codoxDId&&S.__type==="excalidraw"&&S.__data==="[]"&&(S.__data="{}")),S=S.getWritable(),f.push(S),S.__parent=u.__key,_?(u.__first=S.__key,S.__prev=null,b&&(u.__last=S.__key)):b?(u.__last=S.__key,S.__next=null,S.__prev=C.__key,C.__next=S.__key):(S.__prev=C.__key,C.__next=S.__key),u.__size=f.length}for(let g in c){let v=c[g];v=v.getWritable(),xv(v),_f(v),delete c[g]}}else{let c=s.map(f=>vf(f));u.splice(0,u.getChildrenSize(),c)}}if(t){if(p.ld){const s=p.ld,u=Or.get(s.codoxId);u.getChildrenSize&&u.getChildrenSize()?_f(u):u.remove()}if(p.li){let s=Vt.getMainEditorNodesClassesMap();const u=p.li,c=s.get(u.type).klass.importJSON(u);if(e.length===1&&e[0]==="root")(0,Ft.$getRoot)().splice(0,0,[c]);else{const f=e[e.length-1];e.length=e.length-2;let y=Ks(e,h);y&&y.splice(f,0,[c])}if(u.children&&u.children.length){let f=function(y,g){const v=s.get(y.type).klass.importJSON(y);if(g.splice(g.getChildrenSize(),0,[v]),y.children&&y.children.length)for(const _ of y.children)f(_,v)};for(const y of u.children)f(y,c)}}if(p.oi||p.od){let{p:s,oi:u,od:c}=p,f=Ks(s,h);if(f)try{let y=f.getWritable();if(u){let g=Object.keys(u);for(let v of g)y[xu(v)]=u[v]}if(c){let g=Object.keys(c);for(let v of g)delete y[xu(v)]}}catch(y){At.debug("[applyDeltasToLexicalState][delta oi/od] getWritable error: ",{err:y,delta:p})}}if(d){let{p:s,lm:u}=p,c=s[s.length-1],f=u,y=f<c,g=Ks(s,h);if(g){let v=g.getParent().getChildren(),_=v[c],b=v[f];y?b.insertBefore(_):b.insertAfter(_)}}}if(o){const s=e[e.length-1];let u=xu(s);e.length=e.length-1;let c,f=Ks(e,h);if(!f){At.error("Missing node when update node attr from delta: ",{path:e,delta:p,fullStateJSON:h,currentEditorState:Vt.getMainEditorState().toJSON()});continue}try{c=f.getWritable()}catch(g){At.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:g,delta:p})}if(!c)continue;let y=p.oi;if(s==="format"&&(y=f2(y)),s==="direction"&&(f.hasOwnProperty(u)||(u="__dir")),!c.hasOwnProperty(u)){let g=Object.keys(c);for(let v of g){let _=og(v);if(s.startsWith(_)){u=v;break}}}c[u]=y}}else if(p.oi&&p.oi.root)return Sv(p.oi)}}else At.log("[applyDeltasToLexicalState] stop, no deltas: ",i)}function hO(h){let i=null,p=!1;try{i=h.clipboardData.getData(h2.paste),i=JSON.parse(i),typeof i=="object"&&i.nodes&&Array.isArray(i.nodes)&&(p=!0)}catch{return!1}if(!p)return!1;if(p){Or.clearPastedIds();const e=l=>{if(l.codoxId&&Or.addPastedId(l.codoxId),l.children&&l.children.length)for(const n of l.children)e(n)};for(const l of i.nodes)e(l)}return!1}var gO=h=>{var i={};return Tn.d(i,h),i};const Cv=gO({useCollaborationContext:()=>Jb});var mO=h=>{var i={};return Tn.d(i,h),i};const ss=mO({LexicalComposerContext:()=>Dc,useLexicalComposerContext:()=>Xn});class Ev{constructor(){this.blacklist=Object.keys(ov).reduce((i,p)=>{let e=ov[p];return i[p]=e.reduce((l,n)=>(l[n]=n,l),{}),i},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(i){return i instanceof Ft.TextNode||i instanceof Ft.ParagraphNode||i instanceof Ft.RootNode}setClientCallback(i){this._clientCallback=i}removeClientCallback(){this._clientCallback=null}invokeClientCallback(){this._clientCallback&&this._clientCallback()}trackBlacklisted(i){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",e=arguments.length>2?arguments[2]:void 0;if(cg||p!==oi.created||this._isBlacklistedFound||!i||!i.__type||this._shouldSkipNode(i))return;let l=e||Vt.getMainEditorState(),n=i.__type,t=this.blacklist[n];t&&l.read(()=>{let o=i.getParent();for(;o!==null;){let a=o?o.__type:null;if(!a)return;if(t[a])return At.warn("[ContentNestingsWatcher][trackBlacklisted] FOUND: ",{targetNode:i,targetType:n,parent:o,parentType:a,mutationType:p}),void(this._isBlacklistedFound=!0);o=o.getParent()}})}trackBlacklistedInNestedEditor(i){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",e=arguments.length>3?arguments[3]:void 0;if(p!==oi.created||this._isBlacklistedFound||this._shouldSkipNode(i))return;let l=e.__type,n=i.__type;if(!l||!n)return;let t=this.blacklist[n];t&&t[l]&&(this._isBlacklistedFound=!0,At.warn("[ContentNestingsWatcher][trackBlacklistedInNestedEditor] FOUND: ",{targetNode:i,targetType:n,rootNode:e,rootType:l,mutationType:p}))}isBlacklistedFound(){let i=this._isBlacklistedFound;return i&&(this._isBlacklistedFound=!1),i}}const yO=new Ev,ls=yO,bO=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function vO(h,i){if(h==null)return{};var p,e,l=_O(h,i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(h);for(e=0;e<n.length;e++)p=n[e],i.includes(p)||{}.propertyIsEnumerable.call(h,p)&&(l[p]=h[p])}return l}function _O(h,i){if(h==null)return{};var p={};for(var e in h)if({}.hasOwnProperty.call(h,e)){if(i.includes(e))continue;p[e]=h[e]}return p}class xO{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(i,p){let e=!1;return function(l){let{editorState:n,prevEditorState:t,dirtyElements:o,dirtyLeaves:a}=l,r=(vO(l,bO),Vt.getMainEditor()),d=Vt.getMainEditorState(),s=n.toJSON(),u=t.toJSON(),c=sg(s,u),f=n._selection,y=t._selection,g=!1,v=null,_=Vt.isOnlySelectionChanged(o,a),b=i[p];if(At.debug("[NESTED EDITOR LISTENER] invoked: ",{lexicalNode:i,key:i.__key,onlySelectionChanged:_,newEditorStateJSON:s,prevEditorStateJSON:u,isSameState:c,lexicalSelection:f,prevLexicalSelection:y,mainDirtyLeaves:r._dirtyLeaves.size,mainDirtyElements:r._dirtyElements.size,nestedDirtyLeaves:b._dirtyLeaves.size,nestedDirtyElements:b._dirtyElements.size,nestedEditorKey:b._key}),ls.isBlacklistedFound())return e=!0,At.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),Vt.scanLexicalNodeForNestedEditorAttribute(i)?(b.update(()=>{try{const S=b.parseEditorState(u);if(S.isEmpty())return(0,Ft.$getRoot)().clear(),!0;b.setEditorState(S)}catch(S){At.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",S)}}),void ls.invokeClientCallback()):void 0;if(e)e=!1;else{if(i.codoxId||i.codoxDId){let S=null;d.read(()=>{S=cn.getNodeAncestorsCodoxIds(i),!i.codoxId&&i.codoxDId&&S.push(i.codoxDId)}),n.read(()=>{let C=og(p),x=cn.lexicalToJSONNested(f,C,S);v=Vt.getCurrentNestedSelectionJSON(),g=cn.equalSelectionsJSON(v,x),g||Vt.setNestedSelectionJSON(x)})}c&&g||r.update(()=>{try{At.debug("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE",{mainTags:r._updateTags,nestedTags:b&&b._updateTags,isSameState:c,isSameSelection:g,onlyNestedSelectionChanged:_,mainDirtyLeaves:r._dirtyLeaves.size,mainDirtyElements:r._dirtyElements.size,nestedDirtyLeaves:b._dirtyLeaves.size,nestedDirtyElements:b._dirtyElements.size,lexicalNode:i,lexicalSelection:f,prevLexicalSelection:y,mainEditorTags:r._updateTags,mainEditorTagsSize:r._updateTags.size}),Vt.addUpdateTag({fromNestedEditor:!0}),i.markDirty()}catch(S){At.error("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE - ERROR: ",S)}})}}}_isNestedEditorManaged(i){return!!this.nestedEditorsListenersMap[i]}gc(){for(let i in this.nestedEditorsListenersMap)if(!Vt.getLexicalNodeByKey(i)){let p=this.nestedEditorsListenersMap[i];p&&p(),delete this.nestedEditorsListenersMap[i]}}manageNestedEditorInLexicalNode(i){if(this._isNestedEditorManaged(i.getKey()))return;let p=Vt.scanLexicalNodeForNestedEditorAttribute(i);if(p){let e=i[p],l=this._createNestedEditorUpdatesListener(i,p),n=[];e._nodes.forEach((a,r,d)=>{let{klass:s}=a,u=e.registerMutationListener(s,c=>{for(let[f,y]of c)if(y===oi.created){let g=e.getEditorState()._nodeMap.get(f);g&&ls.trackBlacklistedInNestedEditor(g,y,e.getEditorState(),i)}});n.push(u)});let t=(0,Wl.mergeRegister)(e.registerUpdateListener(l),...n),o=i.getKey();this.nestedEditorsListenersMap[o]=t}}gcNestedEditorListenerInLexicalNode(i){let p=i.getKey(),e=this.nestedEditorsListenersMap[p];e&&(e(),delete this.nestedEditorsListenersMap[p])}manageNestedEditorInClonedLexicalNode(i,p){let e=i.getKey();e!==p.getKey()&&this._isNestedEditorManaged(e)&&(this.gcNestedEditorListenerInLexicalNode(i),this.manageNestedEditorInLexicalNode(p))}setNestedEditorSelection(i){let{nestedSelectionJSON:p,nestedEditor:e}=cn.getNestedSelectionJSONFromMainSelectionJSON(i);if(!e)return!1;let l=!0;return e.update(()=>{try{let n=cn.JSONToLexical(p);(0,Ft.$setSelection)(n),At.debug("[setNestedEditorSelection]: lexical nested selection: ",n)}catch(n){At.error("[setNestedEditorSelection] set nested selection error: ",n),l=!1}}),l}clearListeners(){for(let i in this.nestedEditorsListenersMap){let p=this.nestedEditorsListenersMap[i];p&&p(),delete this.nestedEditorsListenersMap[i]}}}const wO=new xO,Na=wO,SO=function(h){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let p=(0,Ft.createEditor)({namespace:"validation",nodes:[...i],onError:o=>{throw o},parentEditor:null});const e=new Ev,l=p.parseEditorState(h);if(l.isEmpty())return;p.setEditorState(l);let n=p.getEditorState();const t=n._nodeMap[Symbol.iterator]();for(const o of t){let[a,r]=o;if(r&&(e.trackBlacklisted(r,oi.created,n),e.isBlacklistedFound()))throw new Error(g2)}}catch(p){throw p}};class CO{constructor(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}_scanForCellHeaderState(i,p,e,l){if(p.length<l)return null;let n,t=p.some(a=>a.__headerState===is.BOTH||a.__headerState===is.ROW),o=i.some((a,r)=>{if(a.__size<l)return!1;let d=a.getChildAtIndex(e);return!(!d||d.__headerState!==is.BOTH&&d.__headerState!==is.COLUMN)});return t&&o?n=is.BOTH:t&&!o?n=is.ROW:o&&!t&&(n=is.COLUMN),n}_isValidCellChildren(i){for(let p of i)if(Yl(p)||!Gl(p)&&vr(p))return!1;return!0}_createEmptyCell(){let i=(0,Cr.$createTableCellNode)();return i.append((0,Ft.$createParagraphNode)()),i}_wrapInvalidCellChildrenIntoParagraph(i){let p=(0,Ft.$createParagraphNode)().getWritable(),e=i.getChildren();(i=i.getWritable()).__first=p.__key,i.__last=p.__key,i.__size=1,p.__parent=i.__key,e.forEach((l,n)=>{(l=l.getWritable()).__parent=null,p.append(l)})}_createFixAction_APPEND_CELLS_TO_ROW(i,p){return()=>{At.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:i,numOfCellsToAppend:p});let e=(0,Ft.$getNodeByKey)(i);for(;p;){let l=(0,Cr.$createTableCellNode)().append((0,Ft.$createParagraphNode)());l.setRowSpan(1).setColSpan(1),e.append(l),p--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(i){return()=>{At.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:i}),(0,Ft.$getNodeByKey)(i).append((0,Ft.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(i){return()=>{At.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:i});let p=(0,Ft.$getNodeByKey)(i);this._wrapInvalidCellChildrenIntoParagraph(p)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(i){return()=>{At.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:i});let p=(0,Ft.$getNodeByKey)(i),e=(0,Cr.$createTableRowNode)();e.append(this._createEmptyCell()),p.append(e)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(i,p){return()=>{for(p||(p=1);p;)(0,Ft.$getNodeByKey)(i).append(this._createEmptyCell()),p--}}_createFixAction_WRAP_INVALID_ROW_NODE(i,p){return()=>{At.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:i,rowKey:p});let e=(0,Ft.$getNodeByKey)(i);if(!e)return;let l=(0,Ft.$getNodeByKey)(p);if(!l)return;e=e.getWritable(),l=l.getWritable();let n=l.getPreviousSibling(),t=l.getNextSibling();l.__parent=null,l.__prev=null,l.__next=null;let o=(0,Cr.$createTableRowNode)();if((0,Cr.$isTableCellNode)(l))l.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(l):l.append((0,Ft.$createParagraphNode)()),o.append(l);else{let a=this._isValidCellChildren([l]),r=(0,Cr.$createTableCellNode)();if(o.append(r),a)r.append(l);else{let d=(0,Ft.$createParagraphNode)();d.append(l),r.append(d)}}o.__parent=e.__key,e.__first===l.__key&&(e.__first=o.__key),e.__last===l.__key&&(e.__last=o.__key),n&&(n=n.getWritable(),n.__next=o.__key,o.__prev=n.__key),t&&(t=t.getWritable(),t.__prev=o.__key,o.__next=t.__key)}}_createFixAction_WRAP_INVALID_CELL_NODE(i,p){return()=>{At.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:i,cellKey:p});let e=(0,Ft.$getNodeByKey)(i);if(!e)return;let l=(0,Ft.$getNodeByKey)(p);if(l.remove(),l=(0,Ft.$createParagraphNode)(),!l)return;e=e.getWritable(),l=l.getWritable();let n=l.getPreviousSibling(),t=l.getNextSibling(),o=(0,Cr.$createTableCellNode)();if(o.__parent=e.__key,e.__first===l.__key&&(e.__first=o.__key),e.__last===l.__key&&(e.__last=o.__key),n&&(n=n.getWritable(),n.__next=o.__key,o.__prev=n.__key),t&&(t=t.getWritable(),t.__prev=o.__key,o.__next=t.__key),l.__parent=null,l.__prev=null,l.__next=null,this._isValidCellChildren([l]))o.append(l);else{let a=(0,Ft.$createParagraphNode)();a.append(l),o.append(a)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(i,p){return()=>{At.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:i,headerStateToApply:p});let e=(0,Ft.$getNodeByKey)(i);e&&(e=e.getWritable(),e.__headerState=p)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(i){let p=Vt.getMainEditorState()._selection;if(At.debug(`[${i}]`,{selection:p}),!(0,Ft.$isRangeSelection)(p))return;let e=[];try{let l=Vt.getLexicalNodeByKey(p.anchor.key),n=Vt.getLexicalNodeByKey(p.focus.key);l&&n&&(e=p.isBackward()?n.getNodesBetween(l):l.getNodesBetween(n))}catch(l){At.warn("[TablesValidator][tableRemoveEventListener] get range selection nodes internal lexical error: ",l)}e.forEach(l=>{(0,Cr.$isTableNode)(l)&&this.removeCandidateTableKeys.add(l.__key)})}tableNodeRemoveListener(i){this.removeCandidateTableKeys.has(i)&&this.removeCandidateTableKeys.delete(i)}shouldGCRemovedTables(){return!!this.removeCandidateTableKeys.size}gcRemovedTables(){At.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),Vt.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(i=>{let p=(0,Ft.$getNodeByKey)(i);p&&p.remove()}),this.removeCandidateTableKeys.clear(),(0,Ft.$addUpdateTag)(vi.historic)})}tableUpdateListener(i){this.validateTableCandidateKeys.add(i)}tableRowNodeChangesListener(i){let p=arguments.length>1&&arguments[1]!==void 0&&arguments[1],e=Vt.getLexicalNodeByKey(i);if(!e)return void(p&&At.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:i}));let l=e.__parent;l?this.validateTableCandidateKeys.add(l):At.debug("[tableRowNodeChangesListener] no parent table for row node found in lexical: ",{rowNode:e})}tableCellNodeChangesListener(i){let p=Vt.getLexicalNodeByKey(i);if(!p||!p.__parent)return;let e=Vt.getLexicalNodeByKey(p.__parent);e&&e.__parent&&this.validateTableCandidateKeys.add(e.__parent)}shouldValidateUpdatedTables(){return!!this.validateTableCandidateKeys.size}validateUpdatedTables(){let i=Array.from(this.validateTableCandidateKeys);return Vt.getMainEditorState().read(()=>{for(let p of i){let e=Vt.getLexicalNodeByKey(p);if(!e)continue;let l=e.getChildren();if(!l.length){this.tableFixActions.push(this._createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(p));continue}let n=0;l.forEach(r=>{r.__size>n&&(n=r.__size)});let t=[],o=l.map((r,d)=>{if(!(0,Cr.$isTableRowNode)(r))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_ROW_NODE(p,r.__key)),"invalid_row_node";let s=r.getChildren();if(!s.length&&!t.length)return this.tableFixActions.push(this._createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(r.__key,n)),"empty_row_should_add_cell";if(!s.length&&t.length)return t=[],"empty_row_should_be_empty";let u=0;if(t.length){let f=[];t.forEach(y=>{let[g,v]=y;u+=v,g--,g&&f.push([g,v])}),t=[...f]}let c=s.map((f,y)=>{if(!(0,Cr.$isTableCellNode)(f))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_CELL_NODE(r.__key,f.__key)),u++,"invalid_cell_node_should_wrap_in_cell";let g,v=f.getChildren(),_=!v.length;if(_?this.tableFixActions.push(this._createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(f.__key)):(g=this._isValidCellChildren(v),g||this.tableFixActions.push(this._createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(f.__key))),f.__rowSpan>1){let b=f.__rowSpan,S=f.__colSpan;t.push([b-1,S])}if(u+=f.__colSpan,f.__headerState===is.NO_STATUS){let b=this._scanForCellHeaderState(l,s,y,n);b&&this.tableFixActions.push(this._createFixAction_APPLY_HEADER_STATE_TO_CELL(f.__key,b))}return{cellKey:f.__key,rowKey:r.__key,tableKey:p,colSpan:f.__colSpan,rowSpan:f.__rowSpan,headerState:f.__headerState,childrenAreValid:g,isEmptyCell:_}});if(u<n){let f=n-u;this.tableFixActions.push(this._createFixAction_APPEND_CELLS_TO_ROW(r.__key,f))}return{realRowLength:u,rowKey:r.__key,tableKey:p,cells:c}}),a=!this.tableFixActions.length;At[a?"debug":"warn"](`[TablesValidator][validateUpdatedTables] IS TABLE VALID: ${a}`,{tableNodeKey:p,tableValidationMatrix:o,requiredRowLength:n}),this.validateTableCandidateKeys.delete(p)}}),!this.tableFixActions.length}shouldFixTablesStructure(){return!!this.tableFixActions.length}fixTablesStructure(){if(!this.tableFixActions.length)return;let i=Vt.getMainEditor();At.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),i.update(()=>{for(let p of this.tableFixActions)p();this.tableFixActions=[],(0,Ft.$addUpdateTag)(vi.historic)})}ensureDocTablesAreValid(i){return this.shouldGCRemovedTables()?(At.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(At.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(At.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(i.toJSON()))}),this.fixTablesStructure(),!1)}}const na=new CO,EO=["contentChanged"],OO=["state","remoteSelection"];function Ov(h,i){var p=Object.keys(h);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(h);i&&(e=e.filter(function(l){return Object.getOwnPropertyDescriptor(h,l).enumerable})),p.push.apply(p,e)}return p}function Jl(h){for(var i=1;i<arguments.length;i++){var p=arguments[i]!=null?arguments[i]:{};i%2?Ov(Object(p),!0).forEach(function(e){kO(h,e,p[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(p)):Ov(Object(p)).forEach(function(e){Object.defineProperty(h,e,Object.getOwnPropertyDescriptor(p,e))})}return h}function kO(h,i,p){return(i=TO(i))in h?Object.defineProperty(h,i,{value:p,enumerable:!0,configurable:!0,writable:!0}):h[i]=p,h}function TO(h){var i=AO(h,"string");return typeof i=="symbol"?i:i+""}function AO(h,i){if(typeof h!="object"||!h)return h;var p=h[Symbol.toPrimitive];if(p!==void 0){var e=p.call(h,i||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(h)}function kv(h,i){if(h==null)return{};var p,e,l=jO(h,i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(h);for(e=0;e<n.length;e++)p=n[e],i.includes(p)||{}.propertyIsEnumerable.call(h,p)&&(l[p]=h[p])}return l}function jO(h,i){if(h==null)return{};var p={};for(var e in h)if({}.hasOwnProperty.call(h,e)){if(i.includes(e))continue;p[e]=h[e]}return p}const cg={DEBUG:!1,VERSION:"1.0.5",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";At.info("MODE: ","production");const NO=h=>async()=>{const{state:i,timestamp:p}=await h();if(!Vt.isValidJSONState(i))throw new Error("Invalid state received from fetchDocOnNetworkReconnect hook");const{commentThreads:e,root:l}=i,n={content:{comments:e,root:l},timestamp:p};return At.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:n}),n};let xf=0,Gs=null,ug=!1,_i={},dg={};const PO=(0,ft.forwardRef)((h,i)=>{let{onBlacklistedInsert:p}=h;const e=(0,ft.useContext)(ss.LexicalComposerContext);if(!e)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[l]=(0,ss.useLexicalComposerContext)(),n=(0,Cv.useCollaborationContext)();(0,ft.useEffect)(()=>{if(At.debug("[INIT] lexical context check: ",{lexicalContext:e,editor:l}),!l)return;At.log("[useEffect][editor] Editor instance changed: ",{editor:l,key:l._key}),Vt.setMainEditor(l),Or.gcAbandonedNodes(),Na.gc(),na.clear(),At.log("[useEffect][editor] subscribe to editor changes");const _=(0,Wl.mergeRegister)(l.registerUpdateListener(y),l.registerCommand(Ft.PASTE_COMMAND,hO,Ft.COMMAND_PRIORITY_CRITICAL),l.registerCommand(Ft.UNDO_COMMAND,()=>{Vt.setUndoInvoked(!0)},Ft.COMMAND_PRIORITY_CRITICAL),l.registerCommand(Ft.REDO_COMMAND,()=>{Vt.setRedoInvoked(!0)},Ft.COMMAND_PRIORITY_CRITICAL),l.registerCommand(Ft.KEY_DELETE_COMMAND,(S,C)=>{na.tableRemoveEventListener("KEY_DELETE_COMMAND")},Ft.COMMAND_PRIORITY_CRITICAL),l.registerCommand(Ft.KEY_BACKSPACE_COMMAND,(S,C)=>{na.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},Ft.COMMAND_PRIORITY_CRITICAL),l.registerCommand(Ft.CUT_COMMAND,(S,C)=>{na.tableRemoveEventListener("CUT_COMMAND")},Ft.COMMAND_PRIORITY_CRITICAL),...g());Bi.mount(),Vt.alignStateSelectionJSONsFromLatestEditor(),At.debug("New editor mounted: ",{isCodoxStarted:Vt.isCodoxStarted,codoxLexicalEditorManager:Vt,nestedEditorsProcessor:Na});let b=l._onError;return l._onError=S=>{At.error("[ERROR HANDLER WRAPPER] error from editor: ",S),b&&b(S),f()},p&&ls.setClientCallback(p),()=>{Vt.getMainEditorKey()&&(At.debug("Unmount prev editor"),_(),Vt.removeMainEditor(),Bi.unmount(),Vt.clearJSONs(),br.clear(),na.clear(),Vt.isCodoxStarted&&(At.debug("EDITOR USE_EFFECT stopping codox"),t(),Vt.setIsCodoxStarted(!1)),ls.removeClientCallback())}},[l]);const t=()=>{Vt.isCodoxStarted&&(At.log("[stopCodoxInstance] stopping codox"),Vt.setIsCodoxStarted(!1),cg||ta().stop(),Vt.clearJSONs(),Or.clearAll(),Bi.clear(),br.resetComments(),Na.clearListeners())},o=async _=>{At.debug("[startCodoxInstance] invoked",{codoxConfigFromClient:_}),Vt.isCodoxStarted&&t(),ta().createNewInstance(),At.debug("[startCodoxInstance] instance created");for(let B in dg)ta().instance.on(B,dg[B]);if(At.debug("[startCodoxInstance] events subscribed"),_i=_,Gs=_i.docId,!Gs)return At.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:Gs});let b=br.initialCommentsExist();At.debug("[startCodoxInstance] initCommentsExist: ",b),b&&(br.activateInitialComments(l,Or),At.log("[activateInitialComments] "));let S=Vt.getMainEditorContentStateJSON();if(!Vt.isValidJSONState(S))throw At.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:Gs,initJSONState:S}),new Error("start codox skipped - invalid init state");At.log("[startCodoxInstance] starting codox with: ",{docId:Gs,initJSONState:S,config:_i,codoxComments:br});let{username:C,apiKey:x,getServerState:m,domain:w="",demo:E=!1,hooks:N}=_i;N&&N.fetchDocOnNetworkReconnect&&(N.fetchDocOnNetworkReconnect=NO(N.fetchDocOnNetworkReconnect));const M=kv(N,EO);await ta().start(ta().createConfig(Jl(Jl({},_i),{},{docId:Gs,username:C,apiKey:x,domain:w,hooks:Jl({syncState:d,getState:r,getServerState:async()=>await m(Gs)},M),editorInstanceHooks:{getSelection:()=>Vt.getCurrentActiveSelectionJSON(),setSelection:B=>s(B),getState:r,setState:B=>{const{root:P,comments:R}=B;At.info("DEBUG: EDITOR INSTANCE setState:",{fullState:B}),u({state:{root:P},selection:Vt.getCurrentActiveSelectionJSON()},Bi.getCurrentRemoteSelections()),br.setAllComments(R)},enableEditor:()=>{Vt.disableEditorReadOnlyMode()},disableEditor:()=>{console.log("[CodoxCollabPlugin] disabling editor"),Vt.enableEditorReadOnlyMode(),Bi.updateRemoteSelections([])},getContent:()=>{let B=Vt.composeFullStateWithRootAndComments();return At.info("[getContent]: ",B),{state:B}}},appServer:_i.appServer,demo:E}))),At.log("[startCodoxInstance] codox started - first sync invoking"),Vt.setIsCodoxStarted(!0),n.clientID=_i.username,n.name=_i.username,c({shouldValidateLexicalState:!1})},a=()=>{o(_i)},r=()=>({state:Jl(Jl({},Vt.getMainEditorContentStateJSON()),{},{comments:br.getAllComments()})}),d=_=>{if(!Vt.isCodoxStarted)return;At.log("[SYNC_STATE]: Before sync payload = ",_);const b=ta().sync({meta:_}),{state:S,remoteSelection:C=[]}=b,x=kv(b,OO);if(At.log("[SYNC_STATE]: After sync",{state:S,remoteSelection:C,rest:x}),!S)return At.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),a();const m=S.state;At.log("[SYNC_STATE] synced state: ",{synced:JSON.parse(JSON.stringify(m))});let{stateFromSync:w,commentsFromSync:E}=Vt.extractStateAndCommentsFromSynced(m);if(!Vt.isValidJSONState(w.state))return At.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:w.state}),a();u(w,C),br.setAllComments(E)},s=_=>{if(!Vt.isCodoxStarted||(At.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:_}),!lg.validateJSONSelection(_,ig.local)))return;let b=Vt.getCurrentActiveSelectionJSON();if(cn.equalSelectionsJSON(b,_))return void At.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let S=cn.isNestedSelectionJSON(_);l.update(()=>{At.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:_});const C=cn.JSONToLexical(_);if(At.log("[setLocalSelectionFromSync] lexical selection to apply: ",C),S){let x=Na.setNestedEditorSelection(_);Vt.setNestedSelectionJSON(x?_:null)}else(0,Ft.$setSelection)(C),Vt.setMainSelectionJSON(_);At.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:Vt.getCurrentActiveSelectionJSON()})})},u=function(){let{state:_,selection:b,stateReplace:S}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",m=Vt.getMainEditorContentStateJSON();At.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(m)),newStateJSON:JSON.parse(JSON.stringify(_)),newSelectionJSON:b,remoteSelection:C,stateReplace:S,editor:l}),b===void 0&&At.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",b);const w=sg(m,_),E=cn.equalSelectionsJSON(Vt.getCurrentActiveSelectionJSON(),b);l.update(()=>{if(Vt.addUpdateTag({isSameState:w,isSameSelection:E,updateTag:x}),S)At.log("[updateEditor] invoke full stateReplace after sync"),Sv(_),(0,Ft.$addUpdateTag)("codox_sync_state_changes");else{At.log("[updateEditor] invoke deltas diff");let M=ta().diff(m,_,{keyNames:{default:"codoxId"}});At.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(m)),newStateJSON:_,deltas:M&&JSON.parse(JSON.stringify(M))}),M&&M.length&&(At.log("[updateEditor] apply deltas to lexical state"),pO(_,M),(0,Ft.$addUpdateTag)("codox_sync_state_changes"))}let N=cn.isNestedSelectionJSON(b);if(lg.validateJSONSelection(b,ig.local)||(b=Vt.getCurrentActiveSelectionJSON()),N){let M=Na.setNestedEditorSelection(b);Vt.setNestedSelectionJSON(M?b:null),At.log("[updateEditor] nested selection updated",M?b:null)}else if(b!==void 0){const M=cn.JSONToLexical(b);At.log("[updateEditor] updated selection to apply: ",{isSameSelection:E,newSelectionJSON:b,lexicalSelection:M}),(0,Ft.$setSelection)(M),Vt.setMainSelectionJSON(b),At.log("[updateEditor] selection updated",b)}},{onUpdate:()=>{w||Bi.updateRemoteSelections(C,"from onUpdate hook")}}),w&&Bi.updateRemoteSelections(C,"from direct updateEditor")},c=function(){let{upd_call_counter:_="",shouldValidateLexicalState:b=!0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!Vt.isCodoxStarted)return;let S=Vt.composeFullStateWithRootAndComments();if(b&&!Vt.isValidJSONState(S))return At.error("[invokeSync] - invalid lexical state for sync - sync invoke skipped - restarting codox",{lexicalJSONState:{root:S.root}}),a();At.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:_});const C={state:{state:S,selection:Vt.getCurrentActiveSelectionJSON()}};At.log("[codoxSync]: Before sync",{local:C,upd_call_counter:_}),At.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(C.state)));let{state:x,remoteSelection:m=[],changes:w}=ta().sync({state:C,meta:{}});if(At.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(x)),remoteSelection:m,changes:w}),!x)return At.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),a();const E=x.state;At.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(E)),_);let{stateFromSync:N,commentsFromSync:M}=Vt.extractStateAndCommentsFromSynced(E);if(!Vt.isValidJSONState(N.state))return At.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:N.state}),a();u(N,m),br.setAllComments(M)},f=()=>{At.warn("[rollbackStateDuringUpdateError] rollback invoked");let _=Vt.getPrevContentStateJSON(),b=Vt.getPrevMainSelectionJSON();At.log("[rollbackStateDuringUpdateError] values: ",{prevState:_,currentState:Vt.getMainEditorContentStateJSON(),prevSelection:b,currentSelection:Vt.getCurrentActiveSelectionJSON(),codoxComments:br}),u({state:_,selection:b},Bi.getCurrentRemoteSelections(),vi.historic);let S=Vt.undoInvoked(),C=Vt.redoInvoked();br.gcAbandonedNodeKeys(Vt.getMainEditorStateNodesMap()),S&&l.dispatchCommand(Ft.CAN_REDO_COMMAND,!1),C&&l.dispatchCommand(Ft.CAN_UNDO_COMMAND,!1)},y=_=>{let{editorState:b,prevEditorState:S,tags:C,dirtyElements:x,dirtyLeaves:m}=_;if(ug)return ug=!1,void At.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(ls.isBlacklistedFound())return ug=!0,At.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((z,$)=>{let K=null,F=null;$.read(()=>{K=cn.lexicalToJSON($._selection),F=$.toJSON()});let q=null;z.read(()=>{let W=(0,Ft.$getSelection)();q=cn.lexicalToJSON(W),z.toJSON()}),Vt.setMainSelectionJSON(q),u({state:F,selection:K},Bi.getCurrentRemoteSelections(),vi.historic),l.dispatchCommand(Ft.CAN_REDO_COMMAND,!1),l.dispatchCommand(Ft.CAN_UNDO_COMMAND,!1)})(b,S),void ls.invokeClientCallback();if(!na.ensureDocTablesAreValid(b))return;xf++,At.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:xf,isCodoxStarted:Vt.isCodoxStarted});let w=Vt.isOnlySelectionChanged(x,m),E=null,N=null,M=null,B=null,P=C.has("codox_sync_state_changes"),R=C.has(wu),j=Vt.undoInvoked(),O=Vt.redoInvoked(),A=Vt.canUndo(),D=Vt.canRedo();E=b.toJSON(),N=S.toJSON(),S.read(()=>{B=cn.lexicalToJSON(S._selection)}),b.read(()=>{let z=(0,Ft.$getSelection)();M=cn.lexicalToJSON(z);let $=cn.JSONToLexical(M),K=z===null&&$===null||z.is($);At.log("[editorUpdatesListener] new values: ",{newContentStateJSON:E,prevContentStateJSON:JSON.parse(JSON.stringify(N)),currentCommentsJSON:JSON.parse(JSON.stringify(br.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(M)),currentMainSelectionJSON:JSON.parse(JSON.stringify(Vt.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(Vt.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(Vt.getCurrentActiveSelectionJSON())),lexicalSelection:z,convertedBackMainSelection:$,isMainSelectionConvertionCorrect:K,nodes:l._editorState._nodeMap,fullEditor:l,codoxNodesMap:Or.toArray(),codoxComments:br,isUpdateFromSync:P,isUpdateFromComments:R,tags:C,onlySelectionChanged:w,undoInvoked:j,redoInvoked:O,canUndo:A,canRedo:D})});let L=sg(E,N),J=cn.equalSelectionsJSON(Vt.getCurrentActiveSelectionJSON(),M);At.log("[editorUpdatesListener] compares: ",{isStateSame:L,isSelectionSame:J});let T=L&&J&&!R;if(!L||R||P){At.log("[editorUpdatesListener] should trigger content_changed for client");let z=Jl({},E),$=br.getAllComments();$.length&&(z.commentThreads=$);let K={source:P?iv.remote:iv.local,content:z};_i.hooks&&_i.hooks.contentChanged&&_i.hooks.contentChanged(K),ta().instance&&ta().instance.emit("content_changed",K)}if(T)At.log("[editorUpdatesListener] STOP - state and selection and comments are same ",xf);else if(Vt.undoInvoked()&&Vt.setUndoInvoked(!1),Vt.redoInvoked()&&Vt.setRedoInvoked(!1),Vt.setPrevContentStateJSON(N),Vt.setMainSelectionJSON(M),Vt.setPrevMainSelectionJSON(B),Vt.isCodoxStarted)if(cg){let z=Vt.getCurrentActiveSelectionJSON();u({state:Vt.getMainEditorContentStateJSON(),selection:z},[])}else c({upd_call_counter:xf});else At.log("[editorUpdatesListener] STOP - Codox is not started - prevent sync invoke")},g=()=>{let _=[];return Vt.getMainEditorNodesClassesMap().forEach((b,S,C)=>{let{klass:x}=b,m=l.registerMutationListener(x,w=>{for(let[E,N]of w){if(!oi[N])continue;const M=Vt.getLexicalNodeByKey(E);if(N===oi.created&&M&&ls.trackBlacklisted(M,N),x.name===Cr.TableNode.name&&(N===oi.destroyed?na.tableNodeRemoveListener(E):na.tableUpdateListener(E)),x.name===Cr.TableRowNode.name&&N!==oi.destroyed&&na.tableRowNodeChangesListener(E,N===oi.updated),x.name===Cr.TableCellNode.name&&N===oi.updated&&na.tableCellNodeChangesListener(E),x.name===bi.MarkNode.name&&(At.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:E,node:M,mutationType:N,codoxComments:br}),N===oi.destroyed?br.removeRelatedNodeKey(E):M&&br.addRelatedNodeKey(M.__key,M.__ids,N===oi.created)),M&&M.codoxId){if(N===oi.destroyed)return void(M.codoxId&&Or.remove(M.codoxId));Rv(M)||At.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:N,node:M}),Or.add(M.codoxId,M)}}_.push(m)})}),_},v={start:o,stop:t,on:(_,b)=>{At.info(`Subscribing client to codox ${_} event`),dg[_]=b},cursor:{hide:()=>{Bi.hideRemoteSelectionsFromUI()},show:()=>{Bi.showHiddenRemoteSelectionsInUI()}},initComments:_=>{br.setInitialComments(_)}};return(0,ft.useImperativeHandle)(i,()=>v),null}),IO=PO,MO=["comments"];function Tv(h,i){var p=Object.keys(h);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(h);i&&(e=e.filter(function(l){return Object.getOwnPropertyDescriptor(h,l).enumerable})),p.push.apply(p,e)}return p}function fg(h){for(var i=1;i<arguments.length;i++){var p=arguments[i]!=null?arguments[i]:{};i%2?Tv(Object(p),!0).forEach(function(e){RO(h,e,p[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(p)):Tv(Object(p)).forEach(function(e){Object.defineProperty(h,e,Object.getOwnPropertyDescriptor(p,e))})}return h}function RO(h,i,p){return(i=DO(i))in h?Object.defineProperty(h,i,{value:p,enumerable:!0,configurable:!0,writable:!0}):h[i]=p,h}function DO(h){var i=LO(h,"string");return typeof i=="symbol"?i:i+""}function LO(h,i){if(typeof h!="object"||!h)return h;var p=h[Symbol.toPrimitive];if(p!==void 0){var e=p.call(h,i||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(h)}function BO(h,i){if(h==null)return{};var p,e,l=FO(h,i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(h);for(e=0;e<n.length;e++)p=n[e],i.includes(p)||{}.propertyIsEnumerable.call(h,p)&&(l[p]=h[p])}return l}function FO(h,i){if(h==null)return{};var p={};for(var e in h)if({}.hasOwnProperty.call(h,e)){if(i.includes(e))continue;p[e]=h[e]}return p}class zO extends nv{constructor(){super(),this.mainEditor=null,this.mainEditorKey=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(i){this._canUndo=i}setCanRedo(i){this._canRedo=i}canUndo(){return this._canUndo}canRedo(){return this._canRedo}setUndoInvoked(i){this._undoInvoked=i}setRedoInvoked(i){this._redoInvoked=i}undoInvoked(){return this._undoInvoked}redoInvoked(){return this._redoInvoked}setIsCodoxStarted(){let i=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this._isCodoxStarted=i}get isCodoxStarted(){return this._isCodoxStarted}getMainEditorKey(){return this.mainEditorKey}setMainEditor(i){this.mainEditor=i,this.mainEditorKey=i._key}clearJSONs(){At.debug("[CodoxLexicalEditorManager][clearJSONs] invoked"),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.setMainSelectionJSON(cn.lexicalToJSON((0,Ft.$getSelection)()))})}mainEditorExists(){return!!this.mainEditor}getMainEditorState(){return this.mainEditor?this.mainEditor.getEditorState():{}}getMainEditorNodesClassesMap(){return this.mainEditor?this.mainEditor._nodes:new Map}getMainEditorStateNodesMap(){return this.mainEditor?this.mainEditor.getEditorState()._nodeMap:new Map}getLexicalNodeByKey(i){return this.mainEditor?this.getMainEditorState()._nodeMap.get(i):null}isLexicalEditorInstance(i){return i&&typeof i=="object"&&!!i.setEditorState}getMainEditorContentStateJSON(){return this.getMainEditorState().toJSON()}setPrevContentStateJSON(i){this.prevContentStateJSON=i}getPrevContentStateJSON(){return this.prevContentStateJSON}setMainSelectionJSON(i){this.currentMainSelectionJSON=i,this.currentMainSelectionJSON&&this.currentNestedSelectionJSON&&(this.currentNestedSelectionJSON=null)}setNestedSelectionJSON(i){this.currentNestedSelectionJSON=i,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(i){this.prevMainSelectionJSON=i}getPrevMainSelectionJSON(){return this.prevMainSelectionJSON}extractStateAndCommentsFromSynced(i){let{state:{comments:p},selection:e,stateReplace:l}=i;return{stateFromSync:{state:fg({},BO(i.state,MO)),selection:e,stateReplace:l},commentsFromSync:p}}composeFullStateWithRootAndComments(){return fg(fg({},this.getMainEditorState().toJSON()),{},{comments:br.getAllComments()})}isValidJSONState(i){let p=!1;try{if(!i)throw new Error("State is undefined");if(!i.root)throw new Error("State 'root' node is missing");let e=this.getMainEditorNodesClassesMap(),l=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",o=n,a=e.get(o.type);if(!a)throw new Error(`Node with type "${o.type}" is not registered in editor`);let{klass:r}=a;if(t==="root"){let d=r.prototype instanceof Ft.ElementNode,s=r.prototype instanceof Ft.DecoratorNode;if(!d&&!s)throw new Error("State root node can have only element nodes as children")}if(o.children)for(let d of o.children)l(d,o.type)};l(i.root),p=!0}catch(e){At.error("[isValidJSONState] invalid state found: ",e.message),p=!1}return p}scanLexicalNodeForNestedEditorAttribute(i){for(let p in i){let e=i[p];if(this.isLexicalEditorInstance(e))return p}return""}isOnlySelectionChanged(i,p){return i.size===0&&p.size===0}addUpdateTag(){let{isSameState:i,isSameSelection:p,fromNestedEditor:e=!1,updateTag:l=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return l?(At.log(`[addUpdateTag] explicit add of tag "${l}" `),void(0,Ft.$addUpdateTag)(l)):e?(At.log(`[addUpdateTag] add "${vi.historic}" tag - change invoked by nested editor`),void(0,Ft.$addUpdateTag)(vi.historic)):void(i?(At.log(`[addUpdateTag] add "${vi.historic}" tag - state is same`),(0,Ft.$addUpdateTag)(vi.historic)):(At.log(`[addUpdateTag] add "${vi.historyMerge}" tag - state is different`),(0,Ft.$addUpdateTag)(vi.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const UO=new zO,Vt=UO;class HO{constructor(){this._nodesMap=new Map,this._pastedNodesCodoxIds=new Set}get size(){return this._nodesMap.size}add(i,p){this._nodesMap.set(i,p)}get(i){return this._nodesMap.get(i)||null}remove(i){this._nodesMap.delete(i)}has(i){return this._nodesMap.has(i)}nodesToArray(){return Array.from(this._nodesMap.values())}keysToArray(){return Array.from(this._nodesMap.keys())}toArray(){return Array.from(this._nodesMap.entries())}addPastedId(i){this._pastedNodesCodoxIds.add(i)}removePastedId(i){this._pastedNodesCodoxIds.delete(i)}hasPastedId(i){return this._pastedNodesCodoxIds.has(i)}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 i=Vt.getMainEditorState();if(!i._nodeMap)return;let p=this.nodesToArray();for(let e of p)i._nodeMap.has(e.__key)||this.remove(e.codoxId)}}const qO=new HO,Or=qO;function Av(h,i){var p=Object.keys(h);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(h);i&&(e=e.filter(function(l){return Object.getOwnPropertyDescriptor(h,l).enumerable})),p.push.apply(p,e)}return p}function jv(h){for(var i=1;i<arguments.length;i++){var p=arguments[i]!=null?arguments[i]:{};i%2?Av(Object(p),!0).forEach(function(e){WO(h,e,p[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(p)):Av(Object(p)).forEach(function(e){Object.defineProperty(h,e,Object.getOwnPropertyDescriptor(p,e))})}return h}function WO(h,i,p){return(i=$O(i))in h?Object.defineProperty(h,i,{value:p,enumerable:!0,configurable:!0,writable:!0}):h[i]=p,h}function $O(h){var i=VO(h,"string");return typeof i=="symbol"?i:i+""}function VO(h,i){if(typeof h!="object"||!h)return h;var p=h[Symbol.toPrimitive];if(p!==void 0){var e=p.call(h,i||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(h)}const pg=()=>e2(),Nv=h=>typeof h=="number";function Kl(h){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const p=function(){for(var e=arguments.length,l=new Array(e),n=0;n<e;n++)l[n]=arguments[n];return h.apply(this,l)};return Object.defineProperty(p,"name",{value:i,writable:!0}),p}const Ys=h=>h.__type==="root"||h.type==="root",Pv=h=>Ys(h.getParent()),zr=h=>h.__type===gf.text||h.type===gf.text||h.hasOwnProperty("__text")||h.hasOwnProperty("text"),Gl=h=>(0,Ft.$isElementNode)(h),Yl=h=>(0,Cr.$isTableNode)(h)||(0,Cr.$isTableRowNode)(h)||(0,Cr.$isTableCellNode)(h),JO=h=>!h.getChildren,Iv=h=>!!h.getChildren,vr=h=>(0,Ft.$isDecoratorNode)(h),Cu=h=>(0,VE.$isLinkNode)(h),Eu=h=>h.__type==="mark"||h.type==="mark",hg=h=>(0,Ft.$isLineBreakNode)(h),cs=h=>zr(h)||hg(h),gg=h=>h.__type===gf.horizontalrule||h.type===gf.horizontalrule,Mv=h=>{if(cs(h)||Cu(h)||Eu(h))return!1;if(!h.__parent||h.__parent==="root"||(0,Ft.$isParagraphNode)(h))return!0;let i=h.getParent().getChildren();return i.length===1&&i[0].__key===h.__key?!((vr(h)||Cu(h)||Eu(h))&&!gg(h)):!i.some(p=>{let e=gg(p);return p.__key!==h.__key&&(cs(p)||vr(p)&&!e||Cu(p)||Eu(p))})},Rv=h=>{const i=Or.get(h.codoxId);return!i||h.__key===i.__key},Zl=function(h){const i=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||pg();h.codoxId=i,Or.add(i,h)},Dv=h=>{Or.remove(h.codoxId),delete h.codoxId},KO=h=>{if(!Iv(h)||!h.getChildrenSize())return;const i=h.getChildren();if(i.some(l=>!!(0,Ft.$isParagraphNode)(l)))return;let p=!1,e=[];for(let l of i)(cs(l)||vr(l)||Cu(l)||Eu(l))&&!p&&(gg(l)||(p=!0)),(Iv(l)||vr(l))&&e.push(l);for(let l of e)p||l.codoxId?p&&l.codoxId&&(l=l.getWritable(),Dv(l)):(l=l.getWritable(),Zl(l))},GO=h=>{const i=jv({},h);for(const p in h)h[p]===void 0&&h.hasOwnProperty(p)&&delete i[p];return i},YO=h=>{const i=`__nativeCreateDOM_${h.name}`;h.prototype[i]=Kl(h.prototype.createDOM,i),h.prototype.createDOM=function(p,e){if(Mv(this))if(this.codoxId){if(!Rv(this)){let n=Or.get(this.codoxId);n.__type===this.__type&&this.isAttached()&&!n.isAttached()?(At.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:n}),Or.add(this.codoxId,this)):Zl(this)}}else Zl(this);else this.codoxId&&Dv(this);vr(this)&&!this.codoxDId&&(this.codoxDId=pg()),Na.manageNestedEditorInLexicalNode(this);let l=this[i](p,e);return l.__codox_track=!0,l}},ZO=h=>{const i=`__nativeUpdateDOM_${h.name}`;return h.prototype[i]=Kl(h.prototype.updateDOM,i),h.prototype.updateDOM=function(){const p=this[i](...arguments);return KO(this),p},h},QO=h=>{const i=`__nativeRemove_${h.name}`;return h.prototype[i]=Kl(h.prototype.remove,i),h.prototype.remove=function(){const p=this.codoxId;return p&&Or.remove(p),Na.gcNestedEditorListenerInLexicalNode(this),this[i](...arguments)},h},XO=h=>{const i=`__nativeExportJSON_${h.name}`;h.prototype[i]=Kl(h.prototype.exportJSON,i),h.prototype.exportJSON=function(){const p=this[i]();return this.codoxId&&(p.codoxId=this.codoxId),this.codoxDId&&(p.codoxDId=this.codoxDId),zr(this)&&Nv(p.format)&&this.hasFormat&&(p.format=d2(this)),GO(p)}},ek=h=>{const i="__nativeImportJSON";h[i]=Kl(h.importJSON,i),h.importJSON=function(p){const e=jv({},p);zr(e)&&!Nv(e.format)&&(e.format=u2(e.format));const l=h[i](e);Na.manageNestedEditorInLexicalNode(l);const n=Mv(l);return n&&e.codoxId&&(Or.hasPastedId(e.codoxId)&&Or.has(e.codoxId)?(Or.removePastedId(e.codoxId),Zl(l)):Zl(l,e.codoxId)),n&&!l.codoxId&&Zl(l),e.codoxDId&&(l.codoxDId=e.codoxDId),l}},tk=h=>{const i="__nativeClone";h[i]=Kl(h.clone,i),h.clone=function(p){const e=h[i](p);return p.codoxId&&(e.codoxId=p.codoxId),p.codoxDId&&(e.codoxDId=p.codoxDId),Na.manageNestedEditorInClonedLexicalNode(p,e),e}},nk=h=>{let i=!1,p=!1,e=!1,l=!1;h.forEach(t=>{t.name===Ft.TextNode.name?i=!0:t.name===Ft.ParagraphNode.name?p=!0:t.name===Ft.LineBreakNode.name?e=!0:t.name===bi.MarkNode.name&&(l=!0)});let n=[];return i||n.push(Ft.TextNode),p||n.push(Ft.ParagraphNode),e||n.push(Ft.LineBreakNode),l||n.push(bi.MarkNode),n.length?[...n,...h]:h},rk=function(){return nk(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(h=>(h.hasOwnProperty("__isCodoxExtended")||(YO(h),ZO(h),XO(h),QO(h),ek(h),tk(h),Object.defineProperty(h,"__isCodoxExtended",{value:!0,writable:!1})),h))};var wf=Tn(777),Ql={};Ql.styleTagTransform=ja(),Ql.setAttributes=Ta(),Ql.insert=ka().bind(null,"head"),Ql.domAPI=Oa(),Ql.insertStyleElement=Aa(),Ea()(wf.A,Ql),wf.A&&wf.A.locals&&wf.A.locals;var ok=h=>{var i={};return Tn.d(i,h),i};const ik=ok({AutoFocusPlugin:()=>dE});var ak=h=>{var i={};return Tn.d(i,h),i};const sk=ak({ClearEditorPlugin:()=>EE});var lk=h=>{var i={};return Tn.d(i,h),i};const ck=lk({LexicalComposer:()=>bh});var uk=h=>{var i={};return Tn.d(i,h),i};const Lv=uk({default:()=>vu});var dk=h=>{var i={};return Tn.d(i,h),i};const fk=dk({HistoryPlugin:()=>ng});var pk=h=>{var i={};return Tn.d(i,h),i};const hk=pk({OnChangePlugin:()=>Yb});var gk=h=>{var i={};return Tn.d(i,h),i};const mk=gk({PlainTextPlugin:()=>UE});var yk=h=>{var i={};return Tn.d(i,h),i};const Bv=yk({$isRootTextContentEmpty:()=>Fb,$rootTextContent:()=>Bb});var bk=h=>{var i={};return Tn.d(i,h),i};const Xl=bk({createPortal:()=>nd.createPortal}),vk=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,_k=vk?ft.useLayoutEffect:ft.useEffect,Fv=_k;var Sf=Tn(253),ec={};ec.styleTagTransform=ja(),ec.setAttributes=Ta(),ec.insert=ka().bind(null,"head"),ec.domAPI=Oa(),ec.insertStyleElement=Aa(),Ea()(Sf.A,ec),Sf.A&&Sf.A.locals&&Sf.A.locals;function xk(h){let{onClose:i,children:p,title:e,closeOnClickOutside:l}=h;const n=(0,ft.useRef)(null);return(0,ft.useEffect)(()=>{n.current!==null&&n.current.focus()},[]),(0,ft.useEffect)(()=>{let t=null;const o=d=>{d.key==="Escape"&&i()},a=d=>{const s=d.target;n.current!==null&&!n.current.contains(s)&&l&&i()},r=n.current;return r!==null&&(t=r.parentElement,t!==null&&t.addEventListener("click",a)),window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o),t!==null&&(t==null||t.removeEventListener("click",a))}},[l,i]),ft.createElement("div",{className:"Modal__overlay",role:"dialog"},ft.createElement("div",{className:"Modal__modal",tabIndex:-1,ref:n},ft.createElement("h2",{className:"Modal__title"},e),ft.createElement("button",{className:"Modal__closeButton","aria-label":"Close modal",type:"button",onClick:i},"X"),ft.createElement("div",{className:"Modal__content"},p)))}function wk(h){let{onClose:i,children:p,title:e,closeOnClickOutside:l=!1}=h;return(0,Xl.createPortal)(ft.createElement(xk,{onClose:i,title:e,closeOnClickOutside:l},p),document.body)}function zv(){const[h,i]=(0,ft.useState)(null),p=(0,ft.useCallback)(()=>{i(null)},[]),e=(0,ft.useMemo)(()=>{if(h===null)return null;const{title:n,content:t,closeOnClickOutside:o}=h;return ft.createElement(wk,{onClose:p,title:n,closeOnClickOutside:o},t)},[h,p]),l=(0,ft.useCallback)(function(n,t){i({closeOnClickOutside:arguments.length>2&&arguments[2]!==void 0&&arguments[2],content:t(p),title:n})},[p]);return[e,l]}var Cf=Tn(191),tc={};tc.styleTagTransform=ja(),tc.setAttributes=Ta(),tc.insert=ka().bind(null,"head"),tc.domAPI=Oa(),tc.insertStyleElement=Aa(),Ea()(Cf.A,tc),Cf.A&&Cf.A.locals&&Cf.A.locals;const Sk={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"}},Ck=Sk;var Ef=Tn(72),nc={};nc.styleTagTransform=ja(),nc.setAttributes=Ta(),nc.insert=ka().bind(null,"head"),nc.domAPI=Oa(),nc.insertStyleElement=Aa(),Ea()(Ef.A,nc),Ef.A&&Ef.A.locals&&Ef.A.locals;function Ek(){for(var h=arguments.length,i=new Array(h),p=0;p<h;p++)i[p]=arguments[p];return i.filter(Boolean).join(" ")}function mg(){return mg=Object.assign?Object.assign.bind():function(h){for(var i=1;i<arguments.length;i++){var p=arguments[i];for(var e in p)({}).hasOwnProperty.call(p,e)&&(h[e]=p[e])}return h},mg.apply(null,arguments)}function us(h){let{"data-test-id":i,children:p,className:e,onClick:l,disabled:n,small:t,title:o}=h;return ft.createElement("button",mg({disabled:n,className:Ek("Button__root",n&&"Button__disabled",t&&"Button__small",e),onClick:l,title:o,"aria-label":o},i&&{"data-test-id":i}),p)}var Of=Tn(129),rc={};rc.styleTagTransform=ja(),rc.setAttributes=Ta(),rc.insert=ka().bind(null,"head"),rc.domAPI=Oa(),rc.insertStyleElement=Aa(),Ea()(Of.A,rc),Of.A&&Of.A.locals&&Of.A.locals;var Ok=h=>{var i={};return Tn.d(i,h),i};const kk=Ok({ContentEditable:()=>df});function Tk(h){let{className:i}=h;return ft.createElement(kk.ContentEditable,{className:i||"ContentEditable__root"})}var kf=Tn(457),oc={};oc.styleTagTransform=ja(),oc.setAttributes=Ta(),oc.insert=ka().bind(null,"head"),oc.domAPI=Oa(),oc.insertStyleElement=Aa(),Ea()(kf.A,oc),kf.A&&kf.A.locals&&kf.A.locals;function Ak(h){let{children:i,className:p}=h;return ft.createElement("div",{className:p||"Placeholder__root"},i)}const jk=Lv.default.LexicalErrorBoundary||Lv.default,Nk=()=>ft.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"#050505",className:"codox-add-comment-right"},ft.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"}),ft.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"})),Uv=()=>ft.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",className:"codox-remove-comment"},ft.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"})),Pk=()=>ft.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"codox-add-comment"},ft.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"})),Ik=()=>ft.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"#0000008c",className:"codox-hide-show-comments"},ft.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"}),ft.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 Hv(h,i,p){let e=arguments.length>3&&arguments[3]!==void 0?arguments[3]:performance.now(),l=arguments.length>4&&arguments[4]!==void 0&&arguments[4];return br.createNewCommentObj({content:h,author:i,codoxId:p,timeStamp:e,deleted:l})}function Mk(h,i,p){return br.createNewThreadObj({quote:h,comments:i,codoxId:p})}function Rk(h){let{anchorKey:i,editor:p,onAddComment:e}=h;const l=(0,ft.useRef)(null),n=(0,ft.useCallback)(()=>{const t=l.current,o=p.getRootElement(),a=p.getElementByKey(i);if(t!==null&&o!==null&&a!==null){const{right:r}=o.getBoundingClientRect(),{top:d}=a.getBoundingClientRect();t.style.left=r-20+"px",t.style.top=d-30+"px"}},[i,p]);return(0,ft.useEffect)(()=>(window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}),[p,n]),Fv(()=>{n()},[i,p,n]),ft.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:l},ft.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:e},ft.createElement(Nk,null)))}function Dk(h){let{onEscape:i}=h;const[p]=(0,ss.useLexicalComposerContext)();return(0,ft.useEffect)(()=>p.registerCommand(Ft.KEY_ESCAPE_COMMAND,e=>i(e),2),[p,i]),null}function Lk(h){let{editorRef:i}=h;const[p]=(0,ss.useLexicalComposerContext)();return typeof i=="function"?i(p):typeof i=="object"&&(i.current=p),null}function qv(h){let{className:i,autoFocus:p,onEscape:e,onChange:l,editorRef:n,placeholder:t="Type a comment...",onEditorClick:o=()=>{}}=h;const a={namespace:"Commenting",nodes:[],onError:r=>{throw r},theme:Ck};return ft.createElement(ck.LexicalComposer,{initialConfig:a},ft.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:o},ft.createElement(mk.PlainTextPlugin,{contentEditable:ft.createElement(Tk,{className:i}),placeholder:ft.createElement(Ak,null,t),ErrorBoundary:jk}),ft.createElement(hk.OnChangePlugin,{onChange:l}),ft.createElement(fk.HistoryPlugin,null),p!==!1&&ft.createElement(ik.AutoFocusPlugin,null),ft.createElement(Dk,{onEscape:e}),ft.createElement(sk.ClearEditorPlugin,null),n!==void 0&&ft.createElement(Lk,{editorRef:n})))}function Wv(h,i){return(0,ft.useCallback)((p,e)=>{p.read(()=>{h((0,Bv.$rootTextContent)()),i(!(0,Bv.$isRootTextContentEmpty)(e.isComposing(),!0))})},[i,h])}function Bk(h){let{editor:i,cancelAddComment:p,submitAddComment:e}=h;const[l,n]=(0,ft.useState)(""),[t,o]=(0,ft.useState)(!1),a=(0,ft.useRef)(null),r=(0,ft.useMemo)(()=>({container:document.createElement("div"),elements:[]}),[]),d=(0,ft.useRef)(null),s=Jv(),u=(0,ft.useCallback)(()=>{i.getEditorState().read(()=>{const f=(0,Ft.$getSelection)();if((0,Ft.$isRangeSelection)(f)){d.current=f.clone();const y=f.anchor,g=f.focus,v=(0,Js.createDOMRange)(i,y.getNode(),y.offset,g.getNode(),g.offset),_=a.current;if(v!==null&&_!==null){const{left:b,bottom:S,width:C}=v.getBoundingClientRect(),x=(0,Js.createRectsFromDOMRange)(i,v);let m=x.length===1?b+C/2-125:b-125;m<10&&(m=10),_.style.left=`${m}px`,_.style.top=`${S+20+(window.pageYOffset||document.documentElement.scrollTop)}px`;const w=x.length,{container:E}=r,N=r.elements,M=N.length;for(let B=0;B<w;B++){const P=x[B];let R=N[B];R===void 0&&(R=document.createElement("span"),N[B]=R,E.appendChild(R));const j="255, 212, 0",O=`position:absolute;top:${P.top+(window.pageYOffset||document.documentElement.scrollTop)}px;left:${P.left}px;height:${P.height}px;width:${P.width}px;background-color:rgba(${j}, 0.3);pointer-events:none;z-index:5;`;R.style.cssText=O}for(let B=M-1;B>=w;B--){const P=N[B];E.removeChild(P),N.pop()}}}})},[i,r]);Fv(()=>{u();const f=r.container,y=document.body;if(y!==null)return y.appendChild(f),()=>{y.removeChild(f)}},[r.container,u]),(0,ft.useEffect)(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[u]);const c=Wv(n,o);return ft.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:a},ft.createElement(qv,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:f=>(f.preventDefault(),p(),!0),onChange:c}),ft.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},ft.createElement(us,{onClick:p,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),ft.createElement(us,{onClick:()=>{if(t){let f=i.getEditorState().read(()=>{const y=d.current;return y?y.getTextContent():""});f.length>100&&(f=f.slice(0,99)+"…"),e(Mk(f,[Hv(l,s)]),!0,void 0,d.current),d.current=null}},disabled:!t,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function Fk(h){let{submitAddComment:i,thread:p,placeholder:e}=h;const[l,n]=(0,ft.useState)(""),[t,o]=(0,ft.useState)(!1),a=(0,ft.useRef)(null),r=Jv(),d=Wv(n,o);return ft.createElement(ft.Fragment,null,ft.createElement(qv,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:d,editorRef:a,placeholder:e}),ft.createElement(us,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(t){i(Hv(l,r),!1,p);const s=a.current;s!==null&&s.dispatchCommand(Ft.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!t},ft.createElement(Pk,null)))}function $v(h){let{commentOrThread:i,deleteCommentOrThread:p,onClose:e,thread:l}=h;return ft.createElement(ft.Fragment,null,"Are you sure you want to delete this ",i.type,"?",ft.createElement("div",{className:"Modal__content"},ft.createElement(us,{onClick:()=>{p(i,l),e()}},"Delete")," ",ft.createElement(us,{onClick:()=>{e()}},"Cancel")))}function Vv(h){let{comment:i,deleteComment:p,thread:e,rtf:l}=h;const n=Math.round((i.timeStamp-performance.now())/1e3),t=Math.round(n/60),[o,a]=zv();return ft.createElement("li",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment"},ft.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Details"},ft.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Author"},i.author),ft.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Time"},"· ",n>-10?"Just now":l.format(t,"minute"))),ft.createElement("p",{className:i.deleted?"CodoxCommentPlugin_CommentsPanel_DeletedComment":""},i.content),!i.deleted&&ft.createElement(ft.Fragment,null,ft.createElement(us,{onClick:()=>{a("Delete Comment",r=>ft.createElement($v,{commentOrThread:i,deleteCommentOrThread:p,thread:e,onClose:r}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},ft.createElement(Uv,null)),o))}function zk(h){let{activeIDs:i,comments:p,deleteCommentOrThread:e,listRef:l,submitAddComment:n,markNodeMap:t}=h;const[o]=(0,ss.useLexicalComposerContext)(),[a,r]=(0,ft.useState)(0),[d,s]=zv(),u=(0,ft.useMemo)(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return(0,ft.useEffect)(()=>{const c=setTimeout(()=>{r(a+1)},1e4);return()=>{clearTimeout(c)}},[a]),ft.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List",ref:l},p.map(c=>{const f=c.codoxId;if(!f)return null;if(c.type==="thread"){const y=()=>{if(t.get(f)!==void 0&&(i===null||i.indexOf(f)===-1)){const g=document.activeElement;o.update(()=>{(0,Ft.$setSelection)(null)},{onUpdate(){g!==null&&g.focus()}})}};return ft.createElement("li",{key:f,onClick:y,className:`CodoxCommentPlugin_CommentsPanel_List_Thread ${t.has(f)?"interactive":""} ${i.indexOf(f)===-1?"":"active"}`},ft.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_QuoteBox"},ft.createElement("blockquote",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Quote"},"> ",ft.createElement("span",null,c.quote)),ft.createElement(us,{onClick:()=>{s("Delete Thread",g=>ft.createElement($v,{commentOrThread:c,deleteCommentOrThread:e,onClose:g}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},ft.createElement(Uv,null)),d),ft.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},c.comments.map(g=>ft.createElement(Vv,{key:g.codoxId,comment:g,deleteComment:e,thread:c,rtf:u}))),ft.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},ft.createElement(Fk,{submitAddComment:n,thread:c,placeholder:"Reply to comment..."})))}return ft.createElement(Vv,{key:f,comment:c,deleteComment:e,rtf:u})}))}function Uk(h){let{activeIDs:i,deleteCommentOrThread:p,comments:e,submitAddComment:l,markNodeMap:n}=h;const t=(0,ft.useRef)(null),o=e.length===0;return ft.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel"},ft.createElement("h2",{className:"CodoxCommentPlugin_CommentsPanel_Heading"},"Comments"),o?ft.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_Empty"},"No Comments"):ft.createElement(zk,{activeIDs:i,comments:e,deleteCommentOrThread:p,listRef:t,submitAddComment:l,markNodeMap:n}))}function Jv(){const h=(0,Cv.useCollaborationContext)(),{yjsDocMap:i,name:p}=h;return p||"Playground User"}function Hk(h){const[i]=(0,ss.useLexicalComposerContext)(),p=C2(),e=(0,ft.useMemo)(()=>new Map,[]),[l,n]=(0,ft.useState)(),[t,o]=(0,ft.useState)([]),[a,r]=(0,ft.useState)(!1),[d,s]=(0,ft.useState)(!1);(0,ft.useEffect)(()=>{!p.length&&d?s(!1):p.length},[p]);const u=(0,ft.useCallback)(()=>{i.update(()=>{const y=(0,Ft.$getSelection)();y!==null&&(y.dirty=!0)}),r(!1)},[i]),c=(0,ft.useCallback)((y,g)=>{if(y.type==="comment"){if(At.log("[deleteCommentOrThread]: type comment new values",{comment:y,thread:g,markNodeMap:e}),br.removeComment(g.codoxId,y.codoxId),!g)return;const v=g.codoxId,_=e.get(v);i.update(()=>{_?_.forEach((b,S)=>{const C=(0,Ft.$getNodeByKey)(S);At.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:C}),C&&C.markDirty()}):(0,Ft.$getRoot)().markDirty(),(0,Ft.$addUpdateTag)(vi.historic),(0,Ft.$addUpdateTag)(wu)})}else{At.log("[deleteCommentOrThread]: type thread new values",{comment:y,markNodeMap:e});const v=g!==void 0?g.codoxId:y.codoxId,_=e.get(v);setTimeout(()=>{i.update(()=>{if(_)for(const b of _){const S=(0,Ft.$getNodeByKey)(b);At.log("[deleteCommentOrThread]: type thread new values",{node:S}),(0,bi.$isMarkNode)(S)&&(S.deleteID(v),S.getIDs().length===0&&(0,bi.$unwrapMarkNode)(S))}else(0,Ft.$getRoot)().markDirty(),At.debug("[deleteCommentOrThread][refreshComments]");br.refreshComments(!0),(0,Ft.$addUpdateTag)(wu)})})}},[i,e]),f=(0,ft.useCallback)((y,g,v,_)=>{if(At.log("[submitAddComment]: new values",{commentOrThread:y,isInlineComment:g,thread:v,markNodeMap:e}),v?br.addComment(v.codoxId,y):br.addCommentThread(y),g)i.update(()=>{if((0,Ft.$isRangeSelection)(_)){const b=_.isBackward(),S=y.codoxId;(0,bi.$wrapSelectionInMarkNode)(_,b,S),(0,Ft.$addUpdateTag)(wu)}}),r(!1);else if(!g&&v){const b=v.codoxId,S=e.get(b);if(!S)return void br.removeComment(v.codoxId,y.codoxId);i.update(()=>{S.forEach((C,x)=>{let m=(0,Ft.$getNodeByKey)(x);m&&m.markDirty()}),(0,Ft.$addUpdateTag)(vi.historic),(0,Ft.$addUpdateTag)(wu)})}},[i]);return(0,ft.useEffect)(()=>{const y=[];for(let g=0;g<t.length;g++){const v=t[g],_=e.get(v);if(_!==void 0)for(const b of _){const S=i.getElementByKey(b);S!==null&&(S.classList.add("selected"),y.push(S),s(!0))}}return()=>{for(let g=0;g<y.length;g++)y[g].classList.remove("selected")}},[t,i,e]),(0,ft.useEffect)(()=>{const y=new Map;return(0,Wl.mergeRegister)((0,Wl.registerNestedElementResolver)(i,bi.MarkNode,g=>(0,bi.$createMarkNode)(g.getIDs()),(g,v)=>{g.getIDs().forEach(_=>{v.addID(_)})}),i.registerMutationListener(bi.MarkNode,g=>{i.getEditorState().read(()=>{for(const[v,_]of g){const b=(0,Ft.$getNodeByKey)(v);let S=[];_==="destroyed"?S=y.get(v)||[]:(0,bi.$isMarkNode)(b)&&(S=b.getIDs());for(let C=0;C<S.length;C++){const x=S[C];let m=e.get(x);y.set(v,S),_==="destroyed"?m!==void 0&&(m.delete(v),m.size===0&&e.delete(x)):(m===void 0&&(m=new Set,e.set(x,m)),m.has(v)||m.add(v))}}})}),i.registerUpdateListener(g=>{let{editorState:v,tags:_}=g;v.read(()=>{const b=(0,Ft.$getSelection)();let S=!1,C=!1;if((0,Ft.$isRangeSelection)(b)){const x=b.anchor.getNode();if((0,Ft.$isTextNode)(x)){const m=(0,bi.$getMarkIDs)(x,b.anchor.offset);m!==null&&(o(m),S=!0),b.isCollapsed()||(n(x.getKey()),C=!0)}}S||o(x=>x.length===0?x:[]),C||n(null),(0,Ft.$isRangeSelection)(b)&&r(!1)})}),i.registerCommand(ag,()=>{const g=window.getSelection();return g!==null&&g.removeAllRanges(),r(!0),!0},Ft.COMMAND_PRIORITY_EDITOR))},[i,e]),ft.createElement(ft.Fragment,null,a&&(0,Xl.createPortal)(ft.createElement(Bk,{editor:i,cancelAddComment:u,submitAddComment:f}),document.body),l!=null&&!a&&(0,Xl.createPortal)(ft.createElement(Rk,{anchorKey:l,editor:i,onAddComment:()=>{i.dispatchCommand(ag,void 0)}}),document.body),(0,Xl.createPortal)(ft.createElement(us,{className:"CodoxCommentPlugin_ShowCommentsButton "+(d?"active":""),onClick:()=>s(!d),title:d?"Hide Comments":"Show Comments"},ft.createElement(Ik,null)),document.body),d&&(0,Xl.createPortal)(ft.createElement(Uk,{comments:p,submitAddComment:f,deleteCommentOrThread:c,activeIDs:t,markNodeMap:e}),document.body))}var Tf=Tn(766),ic={};ic.styleTagTransform=ja(),ic.setAttributes=Ta(),ic.insert=ka().bind(null,"head"),ic.domAPI=Oa(),ic.insertStyleElement=Aa(),Ea()(Tf.A,ic),Tf.A&&Tf.A.locals&&Tf.A.locals;var Af=Tn(225),ac={};ac.styleTagTransform=ja(),ac.setAttributes=Ta(),ac.insert=ka().bind(null,"head"),ac.domAPI=Oa(),ac.insertStyleElement=Aa(),Ea()(Af.A,ac),Af.A&&Af.A.locals&&Af.A.locals;function qk(h){let{label:i,value:p,onChange:e,placeholder:l="","data-test-id":n,type:t="text"}=h;return ft.createElement("div",{className:"CodoxInput__wrapper"},ft.createElement("label",{className:"CodoxInput__label"},i),ft.createElement("input",{type:t,className:"CodoxInput__input",placeholder:l,value:p,onChange:o=>{e(o.target.value)},"data-test-id":n}))}function Kv(h,i){var p=Object.keys(h);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(h);i&&(e=e.filter(function(l){return Object.getOwnPropertyDescriptor(h,l).enumerable})),p.push.apply(p,e)}return p}function jf(h){for(var i=1;i<arguments.length;i++){var p=arguments[i]!=null?arguments[i]:{};i%2?Kv(Object(p),!0).forEach(function(e){Wk(h,e,p[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(p)):Kv(Object(p)).forEach(function(e){Object.defineProperty(h,e,Object.getOwnPropertyDescriptor(p,e))})}return h}function Wk(h,i,p){return(i=$k(i))in h?Object.defineProperty(h,i,{value:p,enumerable:!0,configurable:!0,writable:!0}):h[i]=p,h}function $k(h){var i=Vk(h,"string");return typeof i=="symbol"?i:i+""}function Vk(h,i){if(typeof h!="object"||!h)return h;var p=h[Symbol.toPrimitive];if(p!==void 0){var e=p.call(h,i||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(h)}let Ou=!1;const Jk=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"];function Kk(h){let{color:i,onChange:p}=h;const[e,l]=(0,ft.useState)(sc("hex",i)),[n,t]=(0,ft.useState)(i),o=(0,ft.useRef)(null),a=(0,ft.useMemo)(()=>({x:e.hsv.s/100*214,y:(100-e.hsv.v)/100*150}),[e.hsv.s,e.hsv.v]),r=(0,ft.useMemo)(()=>({x:e.hsv.h/360*214}),[e.hsv]);return(0,ft.useEffect)(()=>{o.current!==null&&p&&t(e.hex)},[e,p]),(0,ft.useEffect)(()=>{if(i===void 0)return;const d=sc("hex",i);l(d),t(d.hex)},[i]),ft.createElement("div",{className:"codox-color-picker-wrapper",style:{width:214},ref:o},ft.createElement(qk,{label:"Hex",onChange:d=>{if(t(d),/^#[0-9A-Fa-f]{6}$/i.test(d)){const s=sc("hex",d);l(s)}},value:n}),ft.createElement("div",{className:"codox-color-picker-basic-color"},Jk.map(d=>ft.createElement("button",{className:d===e.hex?" active":"",key:d,style:{backgroundColor:d},onClick:()=>(s=>{t(s);let u=sc("hex",s);l(u),p(u.hex,Ou)})(d)}))),ft.createElement(Gv,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${e.hsv.h}, 100%, 50%)`},onChange:d=>{let{x:s,y:u}=d;const c=sc("hsv",jf(jf({},e.hsv),{},{s:s/214*100,v:100-u/150*100}));l(c),t(c.hex),p(c.hex,Ou)}},ft.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:e.hex,left:a.x,top:a.y}})),ft.createElement(Gv,{className:"codox-color-picker-hue",onChange:d=>{let{x:s}=d;const u=sc("hsv",jf(jf({},e.hsv),{},{h:s/214*360}));l(u),t(u.hex),p(u.hex,Ou)}},ft.createElement("div",{className:"codox-color-picker-hue_cursor",style:{backgroundColor:`hsl(${e.hsv.h}, 100%, 50%)`,left:r.x}})),ft.createElement("div",{className:"codox-color-picker-color",style:{backgroundColor:e.hex}}))}function Gv(h){let{className:i,style:p,onChange:e,children:l}=h;const n=(0,ft.useRef)(null),t=(0,ft.useRef)(!1),o=a=>{if(n.current){const{current:r}=n,{width:d,height:s,left:u,top:c}=r.getBoundingClientRect(),f=Yv(a.clientX-u,d,0),y=Yv(a.clientY-c,s,0);e({x:f,y})}};return ft.createElement("div",{ref:n,className:i,style:p,onMouseDown:a=>{if(a.button!==0)return;o(a);const r=s=>{t.current=!0,Ou=!0,o(s)},d=s=>{t.current&&(Ou=!1),document.removeEventListener("mousemove",r,!1),document.removeEventListener("mouseup",d,!1),o(s),t.current=!1};document.addEventListener("mousemove",r,!1),document.addEventListener("mouseup",d,!1)}},l)}function Yv(h,i,p){return h>i?i:h<p?p:h}function Zv(h){if(!h.startsWith("#")){const i=document.createElement("canvas").getContext("2d");if(!i)throw new Error("2d context not supported or canvas already initialized");return i.fillStyle=h,i.fillStyle}return h.length===4||h.length===5?h=h.split("").map((i,p)=>p?i+i:"#").join(""):h.length===7||h.length===9?h:"#000000"}function Qv(h){const i=(h.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(p,e,l,n)=>"#"+e+e+l+l+n+n).substring(1).match(/.{2}/g)||[]).map(p=>parseInt(p,16));return{b:i[2],g:i[1],r:i[0]}}function yg(h){let{r:i,g:p,b:e}=h;i/=255,p/=255,e/=255;const l=Math.max(i,p,e),n=l-Math.min(i,p,e);return{h:n?60*(l===i?(p-e)/n+(p<e?6:0):l===p?2+(e-i)/n:4+(i-p)/n):0,s:l?n/l*100:0,v:100*l}}function Gk(h){let{h:i,s:p,v:e}=h;p/=100,e/=100;const l=~~(i/60),n=i/60-l,t=e*(1-p),o=e*(1-p*n),a=e*(1-p*(1-n)),r=l%6,d=Math.round(255*[e,o,t,t,a,e][r]),s=Math.round(255*[a,e,e,o,t,t][r]);return{b:Math.round(255*[t,t,a,e,e,o][r]),g:s,r:d}}function Xv(h){let{b:i,g:p,r:e}=h;return"#"+[e,p,i].map(l=>l.toString(16).padStart(2,"0")).join("")}function sc(h,i){let p=Zv("#121212"),e=Qv(p),l=yg(e);return h==="hex"?(p=Zv(i),e=Qv(p),l=yg(e)):h==="rgb"?(e=i,p=Xv(e),l=yg(e)):h==="hsv"&&(l=i,e=Gk(l),p=Xv(e)),{hex:p,hsv:l,rgb:e}}const Yk=ft.createContext(null);function Zk(h){let{children:i,dropDownRef:p,onClose:e,dropdownClassName:l}=h;const[n,t]=(0,ft.useState)(),[o,a]=(0,ft.useState)(),r=(0,ft.useCallback)(s=>{t(u=>u?[...u,s]:[s])},[t]),d=(0,ft.useMemo)(()=>({registerItem:r}),[r]);return(0,ft.useEffect)(()=>{n&&!o&&a(n[0]),o&&o.current&&o.current.focus()},[n,o]),ft.createElement(Yk.Provider,{value:d},ft.createElement("div",{className:l,ref:p,onKeyDown:s=>{if(!n)return;const u=s.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(u)&&s.preventDefault(),u==="Escape"||u==="Tab"?e():u==="ArrowUp"?a(c=>{if(!c)return n[0];const f=n.indexOf(c)-1;return n[f===-1?n.length-1:f]}):u==="ArrowDown"&&a(c=>c?n[n.indexOf(c)+1]:n[0])}},i))}function Qk(h){let{disabled:i=!1,buttonLabel:p,buttonAriaLabel:e,buttonClassName:l,buttonIconClassName:n,children:t,stopCloseOnClickSelf:o,dropdownClassName:a,buttonLabelClassName:r,dropdownChevronClassName:d}=h;const s=(0,ft.useRef)(null),u=(0,ft.useRef)(null),[c,f]=(0,ft.useState)(!1);return(0,ft.useEffect)(()=>{const y=u.current,g=s.current;if(c&&y!==null&&g!==null){const{top:v,left:_}=y.getBoundingClientRect();g.style.top=`${v+y.offsetHeight+4}px`,g.style.left=`${Math.min(_,window.innerWidth-g.offsetWidth-20)}px`}},[s,u,c]),(0,ft.useEffect)(()=>{const y=u.current;if(y!==null&&c){const g=v=>{const _=v.target;o&&s.current&&s.current.contains(_)||y.contains(_)||f(!1)};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}}},[s,u,c,o]),(0,ft.useEffect)(()=>{const y=()=>{if(c){const g=u.current,v=s.current;if(g!==null&&v!==null){const{top:_}=g.getBoundingClientRect(),b=_+g.offsetHeight+4;b!==v.getBoundingClientRect().top&&(v.style.top=`${b}px`)}}};return document.addEventListener("scroll",y),()=>{document.removeEventListener("scroll",y)}},[u,s,c]),ft.createElement(ft.Fragment,null,ft.createElement("button",{type:"button",disabled:i,"aria-label":e||p,className:l,onClick:()=>f(!c),ref:u},n&&ft.createElement("span",{className:n}),p&&ft.createElement("span",{className:r},p),ft.createElement("i",{className:d})),c&&(0,Xl.createPortal)(ft.createElement(Zk,{dropDownRef:s,onClose:()=>{f(!1),u&&u.current&&u.current.focus()},dropdownClassName:a},t),document.body))}const Xk=["disabled","stopCloseOnClickSelf","color","onChange"];function bg(){return bg=Object.assign?Object.assign.bind():function(h){for(var i=1;i<arguments.length;i++){var p=arguments[i];for(var e in p)({}).hasOwnProperty.call(p,e)&&(h[e]=p[e])}return h},bg.apply(null,arguments)}function eT(h,i){if(h==null)return{};var p,e,l=tT(h,i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(h);for(e=0;e<n.length;e++)p=n[e],i.includes(p)||{}.propertyIsEnumerable.call(h,p)&&(l[p]=h[p])}return l}function tT(h,i){if(h==null)return{};var p={};for(var e in h)if({}.hasOwnProperty.call(h,e)){if(i.includes(e))continue;p[e]=h[e]}return p}function e1(h){let{disabled:i=!1,stopCloseOnClickSelf:p=!0,color:e,onChange:l}=h,n=eT(h,Xk);return ft.createElement(Qk,bg({},n,{disabled:i,stopCloseOnClickSelf:p}),ft.createElement(Kk,{color:e,onChange:l}))}const nT=h=>{let{onColorChange:i,buttonClassName:p,buttonIconClassName:e,buttonAriaLabel:l,buttonLabel:n,dropdownClassName:t,buttonLabelClassName:o,dropdownChevronClassName:a}=h;const[r]=(0,ss.useLexicalComposerContext)(),[d,s]=(0,ft.useState)(()=>r.isEditable()),[u,c]=(0,ft.useState)("");(0,ft.useEffect)(()=>(0,Wl.mergeRegister)(r.registerEditableListener(y=>{s(y)}),r.registerUpdateListener(y=>{let{editorState:g}=y;g.read(()=>{const v=(0,Ft.$getSelection)();if((0,Ft.$isRangeSelection)(v)){let _=(0,Js.$getSelectionStyleValueForProperty)(v,"color");_!==u&&(c(_||""),i(_))}})})),[r]);const f=(0,ft.useCallback)((y,g)=>{r.update(()=>{const v=(0,Ft.$getSelection)();v!==null&&(0,Js.$patchStyleText)(v,{color:y})})},[r]);return ft.createElement(e1,{disabled:!d,color:u,onChange:f,buttonClassName:p||"",buttonIconClassName:e||"",buttonAriaLabel:l||"",buttonLabel:n||"",dropdownClassName:t||"",buttonLabelClassName:o||"",dropdownChevronClassName:a||""})},rT=nT,oT=h=>{let{onColorChange:i,buttonClassName:p,buttonIconClassName:e,buttonAriaLabel:l,buttonLabel:n,dropdownClassName:t,buttonLabelClassName:o,dropdownChevronClassName:a}=h;const[r]=(0,ss.useLexicalComposerContext)(),[d,s]=(0,ft.useState)(()=>r.isEditable()),[u,c]=(0,ft.useState)("#fff");(0,ft.useEffect)(()=>(0,Wl.mergeRegister)(r.registerEditableListener(y=>{s(y)}),r.registerUpdateListener(y=>{let{editorState:g}=y;g.read(()=>{const v=(0,Ft.$getSelection)();if((0,Ft.$isRangeSelection)(v)){let _=(0,Js.$getSelectionStyleValueForProperty)(v,"background-color");_!==u&&(c(_||""),i(_))}})})),[r]);const f=(0,ft.useCallback)((y,g)=>{r.update(()=>{const v=(0,Ft.$getSelection)();v!==null&&(0,Js.$patchStyleText)(v,{"background-color":y})})},[r]);return ft.createElement(e1,{disabled:!d,color:u,onChange:f,buttonClassName:p||"",buttonIconClassName:e||"",buttonAriaLabel:l||"",buttonLabel:n||"",dropdownClassName:t||"",buttonLabelClassName:o||"",dropdownChevronClassName:a||""})},iT=oT;var t1=rs.yy;rs._U,rs.a8,rs.Vs,rs.Cn;var n1=rs.gK;rs.vv;const aT=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?Oe.useLayoutEffect:Oe.useEffect,r1=h=>{const i=document.getElementById("typeahead-menu");if(!i)return;const p=i.getBoundingClientRect();p.top+p.height>window.innerHeight&&i.scrollIntoView({block:"center"}),p.top<0&&i.scrollIntoView({block:"center"}),h.scrollIntoView({block:"nearest"})};function o1(h,i){const p=h.getBoundingClientRect(),e=i.getBoundingClientRect();return p.top>e.top&&p.top<e.bottom}function sT(h,i,p,e){const[l]=Xn();Oe.useEffect(()=>{if(i!=null&&h!=null){const n=l.getRootElement(),t=n!=null?function(s,u){let c=getComputedStyle(s);const f=c.position==="absolute",y=/(auto|scroll)/;if(c.position==="fixed")return document.body;for(let g=s;g=g.parentElement;)if(c=getComputedStyle(g),(!f||c.position!=="static")&&y.test(c.overflow+c.overflowY+c.overflowX))return g;return document.body}(n):document.body;let o=!1,a=o1(i,t);const r=function(){o||(window.requestAnimationFrame(function(){p(),o=!1}),o=!0);const s=o1(i,t);s!==a&&(a=s,e!=null&&e(s))},d=new ResizeObserver(p);return window.addEventListener("resize",p),document.addEventListener("scroll",r,{capture:!0,passive:!0}),d.observe(i),()=>{d.unobserve(i),window.removeEventListener("resize",p),document.removeEventListener("scroll",r,!0)}}},[i,l,e,p,h])}const i1=ki();function lT({close:h,editor:i,anchorElementRef:p,resolution:e,options:l,menuRenderFn:n,onSelectOption:t,shouldSplitNodeWithQuery:o=!1,commandPriority:a=Ln}){const[r,d]=Oe.useState(null),s=e.match&&e.match.matchingString;Oe.useEffect(()=>{d(0)},[s]);const u=Oe.useCallback(f=>{i.update(()=>{const y=e.match!=null&&o?function(g){const v=jt();if(!Tt(v)||!v.isCollapsed())return null;const _=v.anchor;if(_.type!=="text")return null;const b=_.getNode();if(!b.isSimpleText())return null;const S=_.offset,C=b.getTextContent().slice(0,S),x=g.replaceableString.length,m=S-function(E,N,M){let B=M;for(let P=B;P<=N.length;P++)E.substr(-P)===N.substr(0,P)&&(B=P);return B}(C,g.matchingString,x);if(m<0)return null;let w;return m===0?[w]=b.splitText(S):[,w]=b.splitText(m,S),w}(e.match):null;t(f,y,h,e.match?e.match.matchingString:"")})},[i,o,e.match,t,h]),c=Oe.useCallback(f=>{const y=i.getRootElement();y!==null&&(y.setAttribute("aria-activedescendant","typeahead-item-"+f),d(f))},[i]);return Oe.useEffect(()=>()=>{const f=i.getRootElement();f!==null&&f.removeAttribute("aria-activedescendant")},[i]),aT(()=>{l===null?d(null):r===null&&c(0)},[l,r,c]),Oe.useEffect(()=>qr(i.registerCommand(i1,({option:f})=>!(!f.ref||f.ref.current==null)&&(r1(f.ref.current),!0),a)),[i,c,a]),Oe.useEffect(()=>qr(i.registerCommand(Hc,f=>{const y=f;if(l!==null&&l.length&&r!==null){const g=r!==l.length-1?r+1:0;c(g);const v=l[g];v.ref!=null&&v.ref.current&&i.dispatchCommand(i1,{index:g,option:v}),y.preventDefault(),y.stopImmediatePropagation()}return!0},a),i.registerCommand(Uc,f=>{const y=f;if(l!==null&&l.length&&r!==null){const g=r!==0?r-1:l.length-1;c(g);const v=l[g];v.ref!=null&&v.ref.current&&r1(v.ref.current),y.preventDefault(),y.stopImmediatePropagation()}return!0},a),i.registerCommand($a,f=>{const y=f;return y.preventDefault(),y.stopImmediatePropagation(),h(),!0},a),i.registerCommand(id,f=>{const y=f;return l!==null&&r!==null&&l[r]!=null&&(y.preventDefault(),y.stopImmediatePropagation(),u(l[r]),!0)},a),i.registerCommand(Ki,f=>l!==null&&r!==null&&l[r]!=null&&(f!==null&&(f.preventDefault(),f.stopImmediatePropagation()),u(l[r]),!0),a)),[u,h,i,l,r,c,a]),n(p,Oe.useMemo(()=>({options:l,selectOptionAndCleanUp:u,selectedIndex:r,setHighlightedIndex:d}),[u,r,l]),e.match?e.match.matchingString:"")}function cT({options:h,onQueryChange:i,onSelectOption:p,onOpen:e,onClose:l,menuRenderFn:n,triggerFn:t,anchorClassName:o,commandPriority:a=Ln,parent:r}){const[d]=Xn(),[s,u]=Oe.useState(null),c=function(g,v,_,b=document.body){const[S]=Xn(),C=Oe.useRef(document.createElement("div")),x=Oe.useCallback(()=>{C.current.style.top=C.current.style.bottom;const w=S.getRootElement(),E=C.current,N=E.firstChild;if(w!==null&&g!==null){const{left:M,top:B,width:P,height:R}=g.getRect(),j=C.current.offsetHeight;if(E.style.top=`${B+window.pageYOffset+j+3}px`,E.style.left=`${M+window.pageXOffset}px`,E.style.height=`${R}px`,E.style.width=`${P}px`,N!==null){N.style.top=`${B}`;const O=N.getBoundingClientRect(),A=O.height,D=O.width,L=w.getBoundingClientRect();M+D>L.right&&(E.style.left=`${L.right-D+window.pageXOffset}px`),(B+A>window.innerHeight||B+A>L.bottom)&&B-L.top>A+R&&(E.style.top=B-A+window.pageYOffset-R+"px")}E.isConnected||(_!=null&&(E.className=_),E.setAttribute("aria-label","Typeahead menu"),E.setAttribute("id","typeahead-menu"),E.setAttribute("role","listbox"),E.style.display="block",E.style.position="absolute",b.append(E)),C.current=E,w.setAttribute("aria-controls","typeahead-menu")}},[S,g,_,b]);Oe.useEffect(()=>{const w=S.getRootElement();if(g!==null)return x(),()=>{w!==null&&w.removeAttribute("aria-controls");const E=C.current;E!==null&&E.isConnected&&E.remove()}},[S,x,g]);const m=Oe.useCallback(w=>{g!==null&&(w||v(null))},[g,v]);return sT(g,C.current,x,m),C}(s,u,o,r),f=Oe.useCallback(()=>{u(null),l!=null&&s!==null&&l()},[l,s]),y=Oe.useCallback(g=>{u(g),e!=null&&s===null&&e(g)},[e,s]);return Oe.useEffect(()=>{const g=d.registerUpdateListener(()=>{d.getEditorState().read(()=>{const v=d._window||window,_=v.document.createRange(),b=jt(),S=function(m){let w=null;return m.getEditorState().read(()=>{const E=jt();Tt(E)&&(w=function(N){const M=N.anchor;if(M.type!=="text")return null;const B=M.getNode();if(!B.isSimpleText())return null;const P=M.offset;return B.getTextContent().slice(0,P)}(E))}),w}(d);if(!Tt(b)||!b.isCollapsed()||S===null||_===null)return void f();const C=t(S,d);if(i(C?C.matchingString:null),C!==null&&!function(m,w){return w===0&&m.getEditorState().read(()=>{const E=jt();if(Tt(E)){const N=E.anchor.getNode().getPreviousSibling();return $t(N)&&N.isTextEntity()}return!1})}(d,C.leadOffset)&&function(w,E,N){const M=N.getSelection();if(M===null||!M.isCollapsed)return!1;const B=M.anchorNode,P=w,R=M.anchorOffset;if(B==null||R==null)return!1;try{E.setStart(B,P),E.setEnd(B,R)}catch{return!1}return!0}(C.leadOffset,_,v)!==null)return x=()=>y({getRect:()=>_.getBoundingClientRect(),match:C}),void(sr.startTransition?sr.startTransition(x):x());var x;f()})});return()=>{g()}},[d,t,i,s,f,y]),s===null||d===null?null:Ne.jsx(lT,{close:f,resolution:s,editor:d,anchorElementRef:c,options:h,menuRenderFn:n,shouldSplitNodeWithQuery:!0,onSelectOption:p,commandPriority:a})}function a1(h,i){return h.getEditorState().read(()=>{const p=rr(i);return p!==null&&p.isSelected()})}function Nf(h){const[i]=Xn(),[p,e]=Oe.useState(()=>a1(i,h));return Oe.useEffect(()=>{let l=!0;const n=i.registerUpdateListener(()=>{l&&e(a1(i,h))});return()=>{l=!1,n()}},[i,h]),[p,Oe.useCallback(l=>{i.update(()=>{let n=jt();lr(n)||(n=Id(),or(n)),lr(n)&&(l?n.add(h):n.delete(h))})},[i,h]),Oe.useCallback(()=>{i.update(()=>{const l=jt();lr(l)&&l.clear()})},[i])]}const lc=typeof window<"u"&&typeof window.document.createElement<"u",uT=lc&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ku=lc&&window.matchMedia("(pointer: coarse)").matches,dT=lc?Oe.useLayoutEffect:Oe.useEffect,vg=()=>{const[h]=Xn(),[i,p]=Oe.useState(()=>lc?h.getRootElement()===document.activeElement:!1);return dT(()=>qr(h.registerCommand(ld,()=>(p(!0),!1),lu),h.registerCommand(cd,()=>(p(!1),!1),lu)),[h]),i};function fT(h){const{value:i,trigger:p,data:e,className:l,classNameFocused:n,classNames:t,nodeKey:o,component:a}=h,[r]=Xn(),d=vg(),[s,u,c]=Nf(o),f=Oe.useRef(null),y=p+i,g=Oe.useMemo(()=>{if(l){const m=[l];return s&&d&&n&&m.push(n),m.join(" ").trim()||void 0}return""},[s,l,n,d]),v=Oe.useCallback(m=>{if(s&&lr(jt())){m.preventDefault();const w=rr(o);Qs(w)&&w.remove()}return!1},[s,o]),_=Oe.useCallback(m=>{const w=rr(o);if(!(w!=null&&w.isSelected()))return!1;let E=!1;const N=Mf(w);return Nt(N)&&(N.selectEnd(),E=!0),$t(N)&&(N.select(),E=!0),cr(N)&&(N.selectNext(),E=!0),N===null&&(w.selectPrevious(),E=!0),E&&m.preventDefault(),E},[o]),b=Oe.useCallback(m=>{const w=rr(o);if(!(w!=null&&w.isSelected()))return!1;let E=!1;const N=If(w);return Nt(N)&&(N.selectStart(),E=!0),$t(N)&&(N.select(0,0),E=!0),cr(N)&&(N.selectPrevious(),E=!0),N===null&&(w.selectNext(),E=!0),E&&m.preventDefault(),E},[o]),S=Oe.useCallback(m=>{var w;return m.target===f.current||!((w=f.current)===null||w===void 0)&&w.contains(m.target)?(m.shiftKey||c(),u(!0),!0):!1},[c,u]),C=Oe.useCallback(()=>{const m=rr(o);if(!(m!=null&&m.isSelected()))return!1;const w=jt();return lr(w)&&or(null),!1},[o]),x=Oe.useCallback(()=>uT&&s?(u(!1),!0):!1,[s,u]);return Oe.useEffect(()=>{const m=qr(r.registerCommand(Ua,S,Ln),r.registerCommand(ma,v,Ln),r.registerCommand(Ai,v,Ln),r.registerCommand(zc,_,Ln),r.registerCommand(Fc,b,Ln),r.registerCommand(cd,C,Ln),r.registerCommand(Uo,x,Ln));return()=>{m()}},[r,_,b,S,v,C,x]),a?Ne.jsx(a,{ref:f,trigger:p,value:i,data:e,className:g,"data-beautiful-mention":y,children:y}):t?Ne.jsxs("span",{ref:f,className:s&&t.containerFocused?t.containerFocused:t.container,"data-beautiful-mention":y,children:[Ne.jsx("span",{className:t.trigger,children:p}),Ne.jsx("span",{className:t.value,children:i})]}):Ne.jsx("span",{ref:f,className:g,"data-beautiful-mention":y,children:y})}function pT(h){const i=h.getAttribute("data-lexical-beautiful-mention-trigger"),p=h.getAttribute("data-lexical-beautiful-mention-value");let e;const l=h.getAttribute("data-lexical-beautiful-mention-data");if(l)try{e=JSON.parse(l)}catch(n){console.warn("Failed to parse data attribute of beautiful mention node",n)}return i!=null&&p!==null?{node:Tu(i,p,e)}:null}class Zs extends Nl{static getType(){return"beautifulMention"}static clone(i){return new Zs(i.__trigger,i.__value,i.__data,i.__key)}constructor(i,p,e,l){super(l),this.__trigger=i,this.__value=p,this.__data=e}createDOM(){return document.createElement("span")}updateDOM(){return!1}exportDOM(){const i=document.createElement("span");return i.setAttribute("data-lexical-beautiful-mention","true"),i.setAttribute("data-lexical-beautiful-mention-trigger",this.__trigger),i.setAttribute("data-lexical-beautiful-mention-value",this.__value),this.__data&&i.setAttribute("data-lexical-beautiful-mention-data",JSON.stringify(this.__data)),i.textContent=this.getTextContent(),{element:i}}static importDOM(){return{span:i=>i.hasAttribute("data-lexical-beautiful-mention")?{conversion:pT,priority:1}:null}}static importJSON(i){return Tu(i.trigger,i.value,i.data)}exportJSON(){const i=this.__data;return Object.assign(Object.assign({trigger:this.__trigger,value:this.__value},i?{data:i}:{}),{type:"beautifulMention",version:1})}getTextContent(){const i=this.getLatest();return i.__trigger+i.__value}getTrigger(){return this.getLatest().__trigger}getValue(){return this.getLatest().__value}setValue(i){const p=this.getWritable();p.__value=i}getData(){return this.getLatest().__data}setData(i){const p=this.getWritable();p.__data=i}component(){return null}decorate(i,p){const{className:e,classNameFocused:l,classNames:n}=this.getCssClassesFromTheme(p);return Ne.jsx(fT,{nodeKey:this.getKey(),trigger:this.getTrigger(),value:this.getValue(),data:this.getData(),className:e,classNameFocused:l,classNames:n,component:this.component()})}getCssClassesFromTheme(i){var p;const e=i.theme.beautifulMentions||{},l=Object.entries(e).find(([d])=>new RegExp(d).test(this.__trigger)),n=(p=l==null?void 0:l[0])!==null&&p!==void 0?p:"",t=l==null?void 0:l[1],o=typeof t=="string"?t:void 0,a=o&&typeof e[n+"Focused"]=="string"?e[n+"Focused"]:void 0;return{className:o,classNameFocused:a,classNames:l&&typeof t!="string"?t:void 0}}}function Tu(h,i,p){const e=new Zs(h,i,p);return No(e)}function Qs(h){return h instanceof Zs}const hT="";class Pf extends Yi{static getType(){return"zeroWidth"}static clone(i){return new Pf(i.__textContent,i.__key)}static importJSON(i){return gT()}constructor(i,p){super(hT,p),this.__textContent=i}exportJSON(){return Object.assign(Object.assign({},super.exportJSON()),{text:"",type:"zeroWidth"})}updateDOM(){return!1}static importDOM(){return null}exportDOM(i){return{element:null}}isTextEntity(){return!0}getTextContent(){return this.__textContent}}function gT(h=""){const i=new Pf(h);return i.setMode("segmented"),No(i)}function _g(h){return h instanceof Pf}const mT=`\\.,\\*\\?\\$\\|#{}\\(\\)\\^\\[\\]\\\\/!%'"~=<>_:;`,yT="\\(",bT=h=>"(?:"+h.join("|")+")",s1=(h,i)=>(h.length===0?"":"(?!"+h.join("|")+")")+"[^\\s"+i+"]",vT=75;function xg(h,i,p){return new RegExp(s1(i,p)).test(h)}function Au(h,i){const p=jt();if(!p||!Tt(p))return;const e=p.anchor,l=p.focus,[n]=p.getNodes();if(e.key!==l.key||e.offset!==l.offset||!n)return;const t=$t(n)&&n.isSimpleText(),o=e.type,a=e.offset,r=ra(n),d=a===0,s=r.length===a,u=r.charAt(a-1),c=r.charAt(a),f=xg(u,h,i),y=xg(c,h,i),g=/\s/.test(u),v=/\s/.test(c),_=Mf(n),b=If(n),S=n.getParent(),C={node:n,type:o,offset:a,isTextNode:t,textContent:r,selection:p,prevNode:_,nextNode:b,parentNode:S,cursorAtStartOfNode:d,cursorAtEndOfNode:s,wordCharBeforeCursor:f,wordCharAfterCursor:y,spaceBeforeCursor:g,spaceAfterCursor:v};return t?Object.assign(Object.assign({},C),{isTextNode:!0,node:n}):Object.assign(Object.assign({},C),{isTextNode:!1,node:n})}function If(h){let i=h.getNextSibling();for(;i!==null&&_g(i);)i=i.getNextSibling();return i}function Mf(h){let i=h.getPreviousSibling();for(;i!==null&&_g(i);)i=i.getPreviousSibling();return i}function ra(h){return _g(h)?"":h.getTextContent()}function _T(h,i){return typeof h=="string"||typeof h=="boolean"?h:i===null?!1:typeof h=="object"?h[i]:!1}function xT(h,i){return typeof h=="number"||h===!1?h:typeof h>"u"?5:i===null?!1:typeof h=="object"?h[i]:5}function wT(h){const i=h.getLastDescendant();return Nt(i)||$t(i)?i:cr(i)?i.getParent():h}function wg(){const h=yr(),i=wT(h),p=i==null?void 0:i.getKey(),e=Nt(i)?i.getChildrenSize():$t(i)?ra(i).length:0,l=Nt(i)?"element":"text";if(p){const n=Tl();n.anchor.set(p,e,l),n.focus.set(p,e,l),or(n)}}function Sg(h){return h=h??Nx(),qp(Zs)}class Cg{constructor(i,p,e){this.value=i,this.displayValue=p,this.data=e,this.key=e?JSON.stringify(Object.assign(Object.assign({},e),{value:i})):i,this.displayValue=p??i,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(i){this.ref={current:i}}}function l1(h){const i=jt();if(!Tt(i)||!i.isCollapsed())return null;const p=i.anchor;if(p.type!=="text")return null;const e=p.getNode();if(!e.isSimpleText())return null;const l=p.offset,n=ra(e).slice(0,l),t=h.replaceableString.length,o=ST(n,h.matchingString,t),a=l-o;if(a<0)return null;let r;return a===0?[r]=e.splitText(l):[,r]=e.splitText(a,l),r}function ST(h,i,p){let e=p;for(let l=e;l<=i.length;l++)h.substring(-l)===i.substring(0,l)&&(e=l);return e}class Rf extends mi{static getType(){return"placeholder"}static clone(i){return new Rf(i.__textContent,i.__key)}constructor(i,p){super(p),this.__textContent=i}createDOM(i){const p=document.createElement("img");return p.style.display="inline",p.style.border="none",p.style.margin="0",p.style.height="1px",p.style.width="1px",p}updateDOM(){return!1}static importDOM(){return null}static importJSON(i){return CT()}isInline(){return!0}exportJSON(){return Object.assign(Object.assign({},super.exportJSON()),{type:"placeholder"})}getTextContent(){return""}}function CT(h=""){const i=new Rf(h);return No(i)}function ET(h){return h instanceof Rf}const OT=ki(),kT=ki(),TT=ki(),AT=ki();function c1(h,i,p,e){return u1(h,i,p,void 0,void 0,e)}function jT(h,i,p,e,l,n){return u1(h,i,p,e,l,n)}function u1(h,i,p,e,l,n){const t=Au(h,i);if(!t)return!1;const{node:o,selection:a,wordCharBeforeCursor:r,wordCharAfterCursor:d,cursorAtStartOfNode:s,cursorAtEndOfNode:u,prevNode:c,nextNode:f}=t,y=e?Tu(p,e,l):ar(p),g=[];if(!(xa(o)&&s)&&!$t(o))return n&&g.push(ar(" ")),g.push(y),a.insertNodes(g),!0;let v=null;return n&&(r||s&&c!==null&&!$t(c))&&g.push(ar(" ")),g.push(y),n&&(d||u&&f!==null&&!$t(f))&&(v=ar(" "),g.push(v)),a.insertNodes(g),g.length>1&&($t(y)?y.select():v&&v.selectPrevious()),!0}function NT(h,i,p=!0){let e=!1,l=null,n=null;const t=Sg();for(const o of t){const a=o.getTrigger()===h,r=o.getValue()===i;a&&(r||!i)&&(l=Mf(o),n=If(o),o.remove(),e=!0,$t(l)&&ra(l).endsWith(" ")&&n&&ra(n).startsWith(" ")&&l.setTextContent(ra(l).slice(0,-1)),(n===null||ET(n))&&$t(l)&&ra(l).endsWith(" ")&&l.setTextContent(ra(l).trimEnd()))}return e&&p?d1(l,n):p||or(null),e}function PT(h,i,p,e=!0){const l=Sg();let n=null;for(const t of l){const o=t.getTrigger()===h,a=t.getValue()===p;o&&(a||!p)&&(n=t,t.setValue(i))}if(n&&e){const t=Mf(n),o=If(n);d1(t,o),o&&$t(o)?o.select(0,0):wg()}else e||or(null);return n!==null}function d1(h,i){i&&$t(i)?i.select(0,0):h&&$t(h)?h.select():wg()}class Eg extends Cg{constructor(i,p,e,l={}){super(p,e,l),this.itemType=i,this.comboboxItem={itemType:i,value:p,displayValue:e,data:l},this.menuOption=new Cg(p,e,l)}}function Og(h){let i=null;return h.getEditorState().read(()=>{const p=jt();Tt(p)&&(i=IT(p))}),i}function IT(h){const i=h.anchor;if(i.type!=="text")return null;const p=i.getNode();if(!p.isSimpleText())return null;const e=i.offset;return ra(p).slice(0,e)}function MT(h){return h.key.length===1&&!h.ctrlKey&&!h.altKey&&!h.metaKey&&!h.repeat}function RT(h,i,p){const[e]=Xn(),[l,n]=Oe.useState(i??null),[t,o]=Oe.useState(null);return Oe.useEffect(()=>{if(i){n(i);return}return e.registerRootListener(a=>{a&&n(a.parentElement)})},[e,i]),Oe.useEffect(()=>{if(!l)return;if(!h){t&&(t.remove(),o(null));return}const{height:a}=l.getBoundingClientRect(),r=t??document.createElement("div");r.style.position="absolute",r.style.left="0",r.style.right="0",r.style.paddingTop=`${a}px`,l.prepend(r),t||o(r);const d=new ResizeObserver(([s])=>{r.style.paddingTop=`${s.contentRect.height}px`});return d.observe(l),setTimeout(()=>{r.className=p??""}),()=>{d.disconnect(),l.removeChild(r)}},[l,h,t,p]),t}function DT(h,i){var p;const e=(p=h.split(/\s/).pop())!==null&&p!==void 0?p:h,l=h!==e?h.lastIndexOf(e):0;return i.some(t=>t.startsWith(e)&&t!==e)?{leadOffset:l,matchingString:e,replaceableString:e}:null}function LT(h){var i;const{onSelectOption:p,triggers:e,punctuation:l,autoSpace:n,loading:t,triggerFn:o,onQueryChange:a,onReset:r,comboboxAnchor:d,comboboxAnchorClassName:s,comboboxComponent:u="div",comboboxItemComponent:c="div",onComboboxOpen:f,onComboboxClose:y,onComboboxFocusChange:g,comboboxAdditionalItems:v=[],onComboboxItemSelect:_}=h,b=vg(),[S]=Xn(),[C,x]=Oe.useState(null),[m,w]=Oe.useState(null),[E,N]=Oe.useState(null),[M,B]=Oe.useState(null),P=h.options.length===0?"trigger":"value",R=Oe.useMemo(()=>{const Z=v.map(X=>new Eg("additional",X.value,X.displayValue,X.data));if(P==="trigger"){const X=e.map(ee=>new Eg("trigger",ee,ee));return!M||X.every(ee=>!ee.value.startsWith(M))?[...X,...Z]:[...X.filter(ee=>ee.value.startsWith(M)),...Z]}return[...h.options.map(X=>new Eg("value",X.value,X.displayValue,X.data)),...Z]},[v,P,h.options,e,M]),[j,O]=Oe.useState((i=h.comboboxOpen)!==null&&i!==void 0?i:!1),A=RT(j,d,s),D=Oe.useCallback(Z=>{ku||x(Z)},[]),L=Oe.useCallback(Z=>{var X;const ne=(X=R[Z].ref)===null||X===void 0?void 0:X.current;ne&&ne.scrollIntoView({block:"nearest"})},[R]),J=Oe.useCallback((Z,X)=>{if(!b)return!1;let ee;return X==="up"?C===null?ee=R.length-1:C===0?ee=null:ee=C-1:C===null?ee=0:C===R.length-1?ee=null:ee=C+1,D(ee),ee&&L(ee),Z.preventDefault(),Z.stopImmediatePropagation(),!0},[b,C,R.length,L,D]),T=Oe.useCallback(Z=>{D(Z),L(Z)},[L,D]),z=Oe.useCallback(()=>{D(null)},[D]),$=Oe.useCallback(Z=>{const X=R[Z];_==null||_(X.comboboxItem),X.itemType!=="additional"&&(S.update(()=>{const ee=E?l1(E):null;p(X.menuOption,ee)}),N(null),a(null),B(null),D(null))},[R,S,a,D,_,E,p]),K=Oe.useCallback(Z=>{const X=R[Z];_==null||_(X.comboboxItem),X.itemType!=="additional"&&(S.update(()=>{const ee=m?l1(m):null;if(ee){const ne=ar(X.value);ee.replace(ne),ne.select()}else c1(e,l,X.value,n)}),w(null),B(null),D(0))},[R,S,D,_,m,e,l,n]),F=Oe.useCallback(Z=>{P==="trigger"&&K(Z),P==="value"&&$(Z)},[P,K,$]),q=Oe.useCallback(Z=>{if(!b||C===null)return!1;let X=!1;return P==="trigger"&&(X=!0,K(C)),P==="value"&&(X=!0,$(C)),X&&(Z.preventDefault(),Z.stopImmediatePropagation()),X},[b,$,K,P,C]),W=Oe.useCallback(()=>{const Z=Og(S),X=Z?Z.substring(0,Z.length-1):void 0;return X!=null&&X.trim()||D(null),!1},[S,D]),H=Oe.useCallback(Z=>{if(O(!0),!MT(Z))return!1;const X=Og(S),ne=(X===null?Z.key:X+Z.key).trim();return R.some(ce=>ce.displayValue.startsWith(ne)&&ne.length<=ce.displayValue.length)?D(0):P==="trigger"&&D(null),!1},[S,R,P,D]),G=Oe.useCallback(()=>(O(!0),!1),[]),Y=Oe.useCallback(()=>(O(!1),M||(B(null),w(null),N(null)),!1),[M]);return Oe.useEffect(()=>qr(S.registerCommand(Hc,Z=>J(Z,"down"),Ln),S.registerCommand(Uc,Z=>J(Z,"up"),Ln),S.registerCommand(Ki,q,lu),S.registerCommand(id,q,Ln),S.registerCommand(Ai,W,Ln),S.registerCommand(wp,H,Ln),S.registerCommand(ld,G,lu),S.registerCommand(Ua,()=>(j||O(!0),!1),Ln),S.registerCommand($a,()=>(O(!1),!1),Ln)),[S,j,J,q,W,H,G]),Oe.useEffect(()=>{const Z=()=>{S.getEditorState().read(()=>{const X=Og(S);if(X===null){r(),w(null),N(null),a(null),B(null);return}const ee=DT(X,e);if(w(ee),ee){B(ee.matchingString),N(null);return}const ne=o(X,S);if(N(ne),a(ne?ne.matchingString:null),ne!=null&&ne.matchingString){B(ne.matchingString);return}B(null)})};return S.registerUpdateListener(Z)},[S,o,a,r,e]),Oe.useEffect(()=>{var Z;O((Z=h.comboboxOpen)!==null&&Z!==void 0?Z:!1)},[h.comboboxOpen]),Oe.useEffect(()=>{j?f==null||f():(x(null),y==null||y())},[f,y,j]),Oe.useEffect(()=>{C!==null&&R[C]?g==null||g(R[C].comboboxItem):g==null||g(null)},[C,R,g]),Oe.useEffect(()=>{if(!lc)return;const Z=S.getRootElement(),X=ee=>{A&&!A.contains(ee.target)&&Z&&!Z.contains(ee.target)&&Y()};return document.addEventListener("mousedown",X),()=>{document.removeEventListener("mousedown",X)}},[A,S,Y]),!j||!A?null:nd.createPortal(Ne.jsx(u,{loading:t,itemType:P,role:"menu","aria-activedescendant":C!==null&&R[C]?R[C].displayValue:"","aria-label":"Choose trigger and value","aria-hidden":!j,children:R.map((Z,X)=>Ne.jsx(c,{selected:X===C,role:"menuitem","aria-selected":C===X,"aria-label":`Choose ${Z.value}`,item:Z.comboboxItem,ref:Z.setRefElement,onClick:()=>{F(X)},onMouseEnter:()=>{T(X)},onMouseLeave:z,onMouseDown:ee=>{ee.preventDefault()},children:Z.displayValue},Z.key))}),A)}function BT(h,i){const[p,e]=Oe.useState(h);return Oe.useEffect(()=>{const l=setTimeout(()=>{e(h)},i);return()=>{clearTimeout(l)}},[h,i]),p}function FT(h){const{queryString:i,trigger:p,searchDelay:e,items:l,onSearch:n,justSelectedAnOption:t}=h,o=BT(i,e),[a,r]=Oe.useState(!1),[d,s]=Oe.useState([]),[u,c]=Oe.useState(null);return Oe.useEffect(()=>{if(!l)return;if(p===null){s([]),c(null);return}const f=Object.entries(l).find(([g])=>new RegExp(g).test(p));if(!f)return;const y=i?f[1].filter(g=>(typeof g=="string"?g:g.value).toLowerCase().includes(i.toLowerCase())):[...f[1]];s(y),c(i)},[l,p,i]),Oe.useEffect(()=>{if(n){if(p===null||o===null){s([]),c(null);return}r(!0),c(o),n(p,t!=null&&t.current?"":o).then(f=>{s(f)}).finally(()=>{r(!1)}),t!=null&&t.current&&(t.current=!1)}},[o,n,p,t]),Oe.useMemo(()=>({loading:a,results:d,query:u}),[a,d,u])}var zT=globalThis&&globalThis.__rest||function(h,i){var p={};for(var e in h)Object.prototype.hasOwnProperty.call(h,e)&&i.indexOf(e)<0&&(p[e]=h[e]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,e=Object.getOwnPropertySymbols(h);l<e.length;l++)i.indexOf(e[l])<0&&Object.prototype.propertyIsEnumerable.call(h,e[l])&&(p[e[l]]=h[e[l]]);return p};class Df extends Cg{constructor(i,p,e,l){super(p,e,l),this.trigger=i,this.menuItem={trigger:i,value:p,displayValue:e,data:l}}}const UT=h=>"(?:\\.[ |$]|\\s|["+h+"]|)";function HT(h,i,p,e){return new RegExp((i?`(^|\\s|${i})(`:"(^|\\s)(")+bT(h)+"((?:"+s1(h,p)+(e?UT(p):"")+"){0,"+vT+"}))$")}function f1(h,i,p,e,l){const n=HT(i,p,e,l).exec(h);if(n!==null){const t=n[1],o=n[2],a=n[3];if(o.length>=1)return{leadOffset:n.index+t.length,matchingString:a,replaceableString:o}}return null}function qT(h){const{items:i,onSearch:p,autoSpace:e=!0,searchDelay:l=h.onSearch?250:0,allowSpaces:n=!0,insertOnBlur:t=!0,menuComponent:o="ul",menuItemComponent:a="li",emptyComponent:r,menuAnchorClassName:d,showMentionsOnDelete:s,showCurrentMentionsAsSuggestions:u=!0,mentionEnclosure:c,onMenuOpen:f,onMenuClose:y,onMenuItemSelect:g,punctuation:v=mT,preTriggerChars:_=yT}=h,b=Oe.useRef(!1),S=vg(),C=Oe.useMemo(()=>{var Y;return(Y=h.triggers)!==null&&Y!==void 0?Y:Object.keys(i??{})},[h.triggers,i]),[x]=Xn(),[m,w]=Oe.useState(null),[E,N]=Oe.useState(null),{results:M,loading:B,query:P}=FT({queryString:m,searchDelay:l,trigger:E,items:i,onSearch:p,justSelectedAnOption:b}),R=Oe.useRef(),j=Oe.useRef(null),O=_T(h.creatable,E),A=xT(h.menuItemLimit,E),D=Oe.useMemo(()=>{if(!E)return[];let Y=M.map(X=>{if(typeof X=="string")return new Df(E,X,X);{const{value:ee}=X,ne=zT(X,["value"]);return new Df(E,ee,ee,ne)}});if(A!==!1&&A>0&&(Y=Y.slice(0,A)),(!p||!B&&P!==null)&&u&&x.getEditorState().read(()=>{const X=Sg(x);for(const ee of X){const ne=ee.getValue(),ce=ee.getData();ee.getTrigger()===E&&(P===null||ee.getValue().startsWith(P))&&Y.every(se=>se.value!==ne)&&Y.push(new Df(E,ne,ne,ce))}}),P&&Y.every(X=>X.displayValue!==P)){const X=typeof O=="string"?O.replace("{{name}}",P):typeof O>"u"||O?`Add "${P}"`:void 0;X&&Y.push(new Df(E,P,X))}return Y},[M,p,B,P,x,E,O,A,u]),L=!!D.length||B,J=Oe.useCallback(()=>{N(null)},[]),T=Oe.useCallback((Y,Z,X)=>{x.update(()=>{if(!E)return;const ne=!!O&&Y.value!==Y.displayValue&&c&&/\s/.test(Y.value)?c+Y.value+c:Y.value,ce=Tu(E,ne,Y.data);if(Z){const se=Z.getNextSibling();if(Z.replace(ce),se instanceof Yi){const ue=se.getTextContent();!/\s/.test(ue)&&ne.includes(ue)&&se.remove()}}X==null||X(),b.current=!0})},[x,E,O,c]),z=Oe.useCallback((Y,Z,X)=>{E&&(g==null||g({trigger:E,value:Y.value,displayValue:Y.displayValue,data:Y.data}),T(Y,Z,X))},[T,g,E]),$=Oe.useCallback(Y=>{const Z=f1(Y,C,_,v,n);if(Z){const{replaceableString:X,matchingString:ee}=Z,ne=X.lastIndexOf(ee),ce=ne===-1?X:X.substring(0,ne)+X.substring(ne+ee.length);if(N(ce||null),Z.replaceableString)return Z}else N(null);return null},[_,n,v,C]),K=Oe.useCallback(()=>{const Y=R.current;let Z=typeof Y=="number"?D[Y]:void 0;const X=D.find(le=>le.value!==le.displayValue);if(X&&(ku||Z===null)&&(Z=X),!Z)return!1;const ee=Au(C,v);if(!E||!(ee!=null&&ee.isTextNode))return!1;const ne=ee.node,ce=ra(ne),se=f1(ce,C,_,v,n);if(se===null)return!1;const ue=ce.search(new RegExp(`${se.replaceableString}\\s?$`));if(ue===-1)return!1;const Ce=Tu(E,Z.value,Z.data);return x.update(()=>{ne.setTextContent(ce.substring(0,ue)),ne.insertAfter(Ce),Ce.selectNext()},{tag:"history-merge"}),!0},[x,D,_,v,E,C,n]),F=Oe.useCallback(()=>{const Y=jt();if((!Y||lr(Y))&&j.current){const Z=j.current.clone();or(Z)}else Y||wg();j.current&&(j.current=null)},[]),q=Oe.useCallback(Y=>{if(!s)return!1;const Z=Au(C,v);if(Z){const{node:X,prevNode:ee,offset:ne}=Z,ce=Qs(X)?X:Qs(ee)&&ne===0?ee:null;if(ce){const se=ce.getTrigger();return ce.replace(ar(se)),Y.preventDefault(),!0}}return!1},[s,C,v]),W=Oe.useCallback((Y=!1)=>{if(!e)return;const Z=Au(C,v);if(!Z)return;const{node:X,offset:ee,type:ne,parentNode:ce,isTextNode:se,textContent:ue,prevNode:Ce,nextNode:le,wordCharAfterCursor:de,cursorAtStartOfNode:Me,cursorAtEndOfNode:Fe}=Z;if(se&&Me&&Qs(Ce)){X.insertBefore(ar(" "));return}if(Qs(X)&&Ce===null&&xa(ce)&&ne==="element"&&ee===0){const we=ar(" ");X.insertBefore(we),we.selectStart();return}if(se&&Fe&&Qs(le)){X.insertAfter(ar(" "));return}if(se&&Y&&de){const we=ue.substring(0,ee)+" "+ue.substring(ee);X.setTextContent(we);return}Qs(X)&&le===null&&X.insertAfter(ar(" "))},[v,C,e]),H=Oe.useCallback(Y=>{var Z;const{key:X,metaKey:ee,ctrlKey:ne}=Y,ce=X.length===1,se=xg(X,C,v),ue=n&&/^\s$/.test(X);if(!ce||ee||ne)return!1;let Ce=X;const le=Au(C,v);if(le!=null&&le.isTextNode){const{textContent:Me,offset:Fe}=le;Ce=(((Z=Me.substring(0,Fe).split(/\s+/).at(-1))!==null&&Z!==void 0?Z:"")+X).trim()}const de=C.some(Me=>Ce===Me);return!se&&!de&&!ue?K():(W(de),!1)},[W,v,K,C,n]),G=Oe.useCallback(Y=>{var Z;const X=(Z=Y.clipboardData)===null||Z===void 0?void 0:Z.getData("text/plain"),ee=X==null?void 0:X.charAt(0),ne=C.some(se=>ee===se),ce=ee&&new RegExp(`[\\s${v}]`).test(ee);return(ne||!ce)&&W(),!1},[W,C,v]);return Oe.useEffect(()=>{if(!x.hasNodes([Zs]))throw new Error("BeautifulMentionsPlugin: BeautifulMentionNode not registered on editor");return qr(x.registerCommand(Uo,()=>{const Y=jt();return Y&&!lr(Y)?j.current=Y:Y||(j.current=null),!1},Ln),x.registerCommand(wp,H,Ln),x.registerCommand(Ai,q,Ln),x.registerCommand(cd,()=>t?K():!1,Ln),x.registerCommand(Mm,()=>!n&&O?K():!1,Ln),x.registerCommand(OT,({trigger:Y,value:Z,data:X,focus:ee=!0})=>{F();const ne=jT(C,v,Y,Z,X,e);return ee||or(null),ne},Ln),x.registerCommand(kT,({trigger:Y,value:Z,focus:X})=>{const ee=NT(Y,Z,X);return X||(j.current=null),ee},Ln),x.registerCommand(TT,({trigger:Y,newValue:Z,value:X,focus:ee})=>PT(Y,Z,X,ee),Ln),x.registerCommand(AT,({trigger:Y})=>(F(),c1(C,v,Y,e)),Ln),x.registerCommand(Ps,G,Ln))},[x,C,v,e,n,t,O,S,K,H,q,G,F]),Oe.useEffect(()=>{L&&S?f==null||f():y==null||y(),L&&!S&&J()},[f,y,L,S,J]),lc?h.combobox?Ne.jsx(LT,{options:D,loading:B,onQueryChange:w,onSelectOption:T,onReset:()=>{N(null)},triggerFn:$,triggers:C,punctuation:v,creatable:O,comboboxOpen:h.comboboxOpen,comboboxAnchor:h.comboboxAnchor,comboboxAnchorClassName:h.comboboxAnchorClassName,comboboxComponent:h.comboboxComponent,comboboxItemComponent:h.comboboxItemComponent,comboboxAdditionalItems:h.comboboxAdditionalItems,onComboboxOpen:h.onComboboxOpen,onComboboxClose:h.onComboboxClose,onComboboxFocusChange:h.onComboboxFocusChange,onComboboxItemSelect:h.onComboboxItemSelect}):Ne.jsx(cT,{commandPriority:lu,onQueryChange:w,onSelectOption:z,triggerFn:$,options:D,anchorClassName:d,onClose:J,menuRenderFn:(Y,{selectedIndex:Z,selectOptionAndCleanUp:X,setHighlightedIndex:ee})=>(R.current=Z,Y.current&&D.length===0&&P&&!B&&S&&r?nd.createPortal(Ne.jsx(r,{}),Y.current):Y.current&&L?nd.createPortal(Ne.jsx(o,{loading:B,role:"menu","aria-label":"Choose a mention","aria-hidden":!L,"aria-activedescendant":!ku&&Z!==null&&D[Z]?D[Z].displayValue:"",children:D.map((ne,ce)=>Ne.jsx(a,Object.assign({tabIndex:-1,selected:!ku&&Z===ce,ref:ne.setRefElement,role:"menuitem","aria-selected":!ku&&Z===ce,"aria-label":`Choose ${ne.value}`,item:ne.menuItem,itemValue:ne.value,label:ne.displayValue},ne.data,{onClick:()=>{ee(ce),X(ne)},onMouseDown:se=>{se.preventDefault()},onMouseEnter:()=>{ee(ce)},children:ne.displayValue}),ne.key))}),Y.current):null)}):null}const WT=({loading:h,...i})=>h?Ne.jsx("ul",{id:"mention-container",className:"mentionsContainer",...i,children:Ne.jsx("li",{className:"mentionsContainerItem",children:"Loading..."})}):Ne.jsx("ul",{id:"mention-container",className:"mentionsContainer",...i}),$T=Oe.forwardRef(({selected:h,item:i,children:p,...e},l)=>{var n,t,o;return Ne.jsx("li",{className:`mentionsContainerItem ${h&&"selected"}`,...e,ref:l,"data-id":(n=i==null?void 0:i.data)==null?void 0:n.id,"data-list-name":(t=i==null?void 0:i.data)==null?void 0:t.listName,"data-value":(o=i==null?void 0:i.data)==null?void 0:o.value,children:i.value})});let ju=[];function VT({nodeKey:h}){const[i]=Xn(),[p,e,l]=Nf(h),[n,t]=sr.useState(ju),o=Oe.useCallback(a=>{const r=jt();return lr(r)&&i.update(()=>{r.getNodes().forEach(d=>{if(KT(d)){d.remove();const s=[...n];s.pop(),t(s),ju=s}})}),!1},[i,p]);return Oe.useEffect(()=>qr(i.registerCommand(Ua,a=>{const r=i.getElementByKey(h);return a.target===r?(a.shiftKey&&l(),e(!p),!0):!1},Ln),i.registerCommand(ma,o,Ln),i.registerCommand(Ai,o,Ln)),[l,i,p,h,o,e]),Oe.useEffect(()=>{const a=i.getElementByKey(h);a!==null&&(a.className="")},[i,p,h]),null}class Nu extends Nl{static getType(){return"page-break"}static clone(i){return new Nu(i.__key)}static importJSON(i){return p1()}static importDOM(){return{figure:i=>i.getAttribute("type")!==this.getType()?null:{conversion:JT,priority:ni}}}exportJSON(){return{type:this.getType(),version:1}}createDOM(){const i=document.createElement("figure");return i.style.pageBreakAfter="always",i.setAttribute("type",this.getType()),ju.push(ju.length+1),i.textContent=String(ju.length),i}getTextContent(){return`
|
|
1507
|
-
`}isInline(){return!1}updateDOM(){return!1}decorate(){return Ne.jsx(VT,{nodeKey:this.__key})}}function JT(){return{node:p1()}}function p1(){return new Nu}function KT(h){return h instanceof Nu}const WA="";function h1({className:h,style:i}){return Ne.jsx(df,{className:h||"ContentEditable__root",style:i})}const $A="";function g1({children:h,className:i}){return Ne.jsx("div",{className:i||"Placeholder__root",children:h})}const GT=({onChange:h})=>{const[i]=Xn(),[p,e]=Oe.useState(!0),l=Oe.useRef(""),n=l.current,t=Oe.useCallback(()=>{i.update(()=>{const o=I0(i);p?e(!1):o!==n&&(h(o),l.current=o)})},[i,p,h,n]);return Oe.useEffect(()=>{const o=i.registerUpdateListener(t);return()=>o()},[i,t]),null},YT=n1([...[Ri,Us,Mi,Yd,Qd,ef,Zs,Nu]]);function ZT({collabApiKey:h,userObj:i,styleConfig:p,docId:e,onlUser:l,setonlUser:n,savedSpfEditorState:t,setSavedEditorState:o,setSavedEditorState2:a,mentionItems:r,showtoolbar:d=!0,customHeight:s,customWidth:u,disabled:c,editorId:f,onPaste:y,source:g}){const v=Oe.useRef(null),{pageMarginTop:_,pageMarginLeft:b,pageMarginBottom:S,pageMarginRight:C,heading:x}=p||{};Oe.useState("");const[m,w]=Oe.useState(!0),E=Oe.useRef(null),[N,M]=Oe.useState(!1),[B,P]=Oe.useState([]),R=Oe.useRef(),[j,O]=Oe.useState({root:null}),[A,D]=Oe.useState(0);let L={namespace:`editor_${f}`,nodes:[...YT],onError(G){throw G},theme:o0,editorState:G=>{G.update(()=>{if(t&&m){const Z=new DOMParser().parseFromString(t,"text/html"),X=jh(G,Z);X.forEach(ee=>{ee instanceof Mi&&ee.setStyle("font-weight: normal")}),yr(),Al(X),w(!1)}})}};Oe.useEffect(()=>{setTimeout(()=>{Fl(".custom-margin").css({paddingTop:`${_||"16px"}`,paddingRight:`${C||"16px"}`,paddingLeft:`${b||"16px"}`,paddingBottom:`${S||"16px"}`}),Fl(".editor-inner").css({maxHeight:s?`${s}px`:"100%",overflow:"scroll",height:s?`${s}px`:"100%",minHeight:"200px",maxWidth:u?`${u}px`:"100%"}),Fl(".editor-input").attr("contentEditable",!c)},500)},[]);const{userName:J,userId:T,userEmail:z}=i,K={docId:f,apiKey:h,user:{name:J,id:T,email:z},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:G,content:Y})=>{},usersUpdate:G=>{P(G),renderOnlineUsers(G)}}},F=()=>{R.current&&R.current.start(K).then(()=>{console.log("[Lexical Demo][codox.start] success"),M(!0)}).catch(G=>console.log("[Lexical Demo][codox.start] error",G))};Oe.useEffect(()=>()=>{q()},[]);const q=()=>{R.current&&R.current.stop(),M(!1)};Oe.useEffect(()=>{j&&e&&!N&&F()},[j,e,N]),Oe.useEffect(()=>{let G=[],Y=[];B&&B.length>0&&B.map((Z,X)=>{Y.includes(Z.name)||(Y.push(Z.name),G.push(Ne.jsxs("div",{title:Z.email,className:`avatarStyle avatar-color-${X+1}`,children:[" ",Z.name&&Z.name[0],Z.name&&Z.name[4]]},X)))}),n(G)},[B]),Oe.useEffect(()=>{(async G=>{const Y=!!h,Z=!!i,X=!!p;A>1&&A<200&&D(A+1),console.log(Y&&Z&&X?"All three conditions are met.":Y&&Z||Y&&X||Z&&X?"Any two of the three conditions are met.":Y||Z||X?"Any one of the three conditions is met.":"None of the three conditions are met.")})()},[h,i,p]);const W=Oe.useCallback(G=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{o(G)},500)},[f,o,a]),H=Oe.useCallback(G=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{a(G)},500)},[f,o,a]);return Ne.jsxs("div",{ref:v,children:[Ne.jsx(sS,{children:Ne.jsxs(bh,{initialConfig:L,children:[Ne.jsx(t1,{ref:R}),Ne.jsxs("div",{className:"editor-container",children:[d&&Ne.jsx(aE,{styleConfig:p,onlUser:l,stopCodox:q,startCodox:F,source:g,onPaste:y}),Ne.jsx("div",{className:"editor-inner",children:Ne.jsx(uf,{contentEditable:Ne.jsx("div",{className:"custom-margin",children:Ne.jsx(df,{className:"editor-input inpt-1"})}),placeholder:null,ErrorBoundary:vu})})]}),Ne.jsx(Vw,{}),Ne.jsx(mE,{}),Ne.jsx(Xw,{}),Ne.jsx(uS,{}),Ne.jsx(ng,{}),Ne.jsx(qT,{items:r,menuComponent:WT,menuItemComponent:$T}),Ne.jsx(GT,{onChange:f.includes("objective")?W:H})]})}),Ne.jsx(uC,{styleConfig:p})]})}const QT=n1([...[]]);function XT({collabApiKey:h,userObj:i,docId:p,setonlUser:e,savedSpfEditorState:l,setSavedEditorState:n,customHeight:t,customWidth:o,editorId:a}){const r=Oe.useRef(null),[d,s]=Oe.useState(!0),[u,c]=Oe.useState(!1),[f,y]=Oe.useState([]),g=Oe.useRef(),[v,_]=Oe.useState({root:null});Oe.useState(0);const b=Oe.useRef(""),S={namespace:`editor_${a}`,nodes:[...QT],onError(B){throw B},theme:o0,editorState:B=>{B.update(()=>{if(l&&d){const R=new DOMParser().parseFromString(l,"text/html"),j=jh(B,R);yr(),Al(j),s(!1)}})}};Oe.useEffect(()=>{setTimeout(()=>{Fl(".custom-margin-2").css({height:`${t}px`}),Fl(".editor-inner-2").css({background:"#fff",position:"relative",top:"20px",padding:"20px",borderRadius:"0 0 10px 10px",maxHeight:`${t}px`,overflow:"scroll",height:`${t}px`,minHeight:"200px",maxWidth:o?`${o}px`:"100%"})},500)},[]);const{userName:C,userId:x,userEmail:m}=i,E={docId:a,apiKey:h,user:{name:C,id:x,email:m},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:B,content:P})=>{},usersUpdate:B=>{y(B),renderOnlineUsers(B)}}},N=()=>{g.current&&g.current.start(E).then(()=>{console.log("[Lexical Demo][codox.start] success"),c(!0)}).catch(B=>console.log("[Lexical Demo][codox.start] error",B))};Oe.useEffect(()=>{v&&p&&!u&&N()},[v,p,u]),Oe.useEffect(()=>{let B=[],P=[];f&&f.length>0&&f.map((R,j)=>{P.includes(R.name)||(P.push(R.name),B.push(Ne.jsxs("div",{title:R.email,className:`avatarStyle avatar-color-${j+1}`,children:[" ",R.name&&R.name[0],R.name&&R.name[4]]},j)))}),e(B)},[f]);const M=()=>{let B=Fl(".editor-input-2").html();B!==b.current&&(console.log("Editor Variant 2 HTML",B),n(B),b.current=B)};return Ne.jsx("div",{ref:r,children:Ne.jsxs(bh,{initialConfig:S,children:[Ne.jsx(t1,{ref:g}),Ne.jsx("div",{className:"editor-container",children:Ne.jsxs("div",{className:"editor-inner-2",children:[Ne.jsx(uf,{contentEditable:Ne.jsx("div",{className:"custom-margin-2",children:Ne.jsx(df,{className:"editor-input-2 inpt-2"})}),placeholder:null,ErrorBoundary:vu}),Ne.jsx(Yb,{onChange:M})]})}),Ne.jsx(ng,{})]})})}const KA="";function eA(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var tA=eA(function(h){const i=new URLSearchParams;i.append("code",h);for(let p=1;p<arguments.length;p++)i.append("v",arguments[p]);throw Error(`Minified Lexical error #${h}; visit https://lexical.dev/docs/error?${i} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function m1(h){const i=h.transform();return i!==null?new Set([i]):new Set}function y1({initialEditor:h,children:i,initialNodes:p,initialTheme:e,skipCollabChecks:l}){const n=Oe.useRef(!1),t=Oe.useContext(Dc);t==null&&tA(9);const[o,{getTheme:a}]=t,r=Oe.useMemo(()=>{const c=e||a()||void 0,f=Pm(t,c);if(c!==void 0&&(h._config.theme=c),h._parentEditor=o,p)for(let y of p){let g=null,v=null;if(typeof y!="function"){const b=y;y=b.replace,g=b.with,v=b.withKlass||null}const _=h._nodes.get(y.getType());h._nodes.set(y.getType(),{exportDOM:_?_.exportDOM:void 0,klass:y,replace:g,replaceWithKlass:v,transforms:m1(y)})}else{const y=h._nodes=new Map(o._nodes);for(const[g,v]of y)h._nodes.set(g,{exportDOM:v.exportDOM,klass:v.klass,replace:v.replace,replaceWithKlass:v.replaceWithKlass,transforms:m1(v.klass)})}return h._config.namespace=o._config.namespace,h._editable=o._editable,[h,f]},[]),{isCollabActive:d,yjsDocMap:s}=Jb(),u=l||n.current||s.has(h.getKey());return Oe.useEffect(()=>{u&&(n.current=!0)},[u]),Oe.useEffect(()=>o.registerEditableListener(c=>{h.setEditable(c)}),[h,o]),Ne.jsx(Dc.Provider,{value:r,children:!d||u?i:null})}function kg(h,i,p){return Math.min(Math.max(h,i),p)}const kr={east:1,north:8,south:2,west:4};function nA({onResizeStart:h,onResizeEnd:i,buttonRef:p,imageRef:e,maxWidth:l,editor:n,showCaption:t,setShowCaption:o,captionsEnabled:a}){const r=Oe.useRef(null),d=Oe.useRef({priority:"",value:"default"}),s=Oe.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),u=n.getRootElement(),c=u!==null?u.getBoundingClientRect().width-20:100,f=u!==null?u.getBoundingClientRect().height-20:100,y=100,g=100,v=x=>{const m=x===kr.east||x===kr.west,w=x===kr.north||x===kr.south,E=x&kr.north&&x&kr.west||x&kr.south&&x&kr.east,N=m?"ew":w?"ns":E?"nwse":"nesw";u!==null&&u.style.setProperty("cursor",`${N}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${N}-resize`,"important"),d.current.value=document.body.style.getPropertyValue("-webkit-user-select"),d.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))},_=()=>{u!==null&&u.style.setProperty("cursor","text"),document.body!==null&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",d.current.value,d.current.priority))},b=(x,m)=>{if(!n.isEditable())return;const w=e.current,E=r.current;if(w!==null&&E!==null){x.preventDefault();const{width:N,height:M}=w.getBoundingClientRect(),B=s.current;B.startWidth=N,B.startHeight=M,B.ratio=N/M,B.currentWidth=N,B.currentHeight=M,B.startX=x.clientX,B.startY=x.clientY,B.isResizing=!0,B.direction=m,v(m),h(),E.classList.add("image-control-wrapper--resizing"),w.style.height=`${M}px`,w.style.width=`${N}px`,document.addEventListener("pointermove",S),document.addEventListener("pointerup",C)}},S=x=>{const m=e.current,w=s.current,E=w.direction&(kr.east|kr.west),N=w.direction&(kr.south|kr.north);if(m!==null&&w.isResizing){if(E&&N){let M=Math.floor(w.startX-x.clientX);M=w.direction&kr.east?-M:M;const B=kg(w.startWidth+M,y,c),P=B/w.ratio;m.style.width=`${B}px`,m.style.height=`${P}px`,w.currentHeight=P,w.currentWidth=B}else if(N){let M=Math.floor(w.startY-x.clientY);M=w.direction&kr.south?-M:M;const B=kg(w.startHeight+M,g,f);m.style.height=`${B}px`,m.style.maxHeight=`${B}px`,w.currentHeight=B}else{let M=Math.floor(w.startX-x.clientX);M=w.direction&kr.east?-M:M;const B=kg(w.startWidth+M,y,c);m.style.width=`${B}px`,m.style.maxWidth=`${B}px`,w.currentWidth=B}m&&(m.setAttribute("width",`${w.currentWidth}`),m.setAttribute("height",`${w.currentHeight}`))}},C=()=>{const x=e.current,m=s.current,w=r.current;if(x!==null&&w!==null&&m.isResizing){const E=m.currentWidth,N=m.currentHeight;m.startWidth=0,m.startHeight=0,m.ratio=0,m.startX=0,m.startY=0,m.currentWidth=0,m.currentHeight=0,m.isResizing=!1,w.classList.remove("image-control-wrapper--resizing"),_(),i(E,N),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C)}};return Ne.jsxs("div",{ref:r,children:[Ne.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:x=>{b(x,kr.north)}}),Ne.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:x=>{b(x,kr.north|kr.east)}}),Ne.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:x=>{b(x,kr.east)}}),Ne.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:x=>{b(x,kr.south|kr.east)}}),Ne.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:x=>{b(x,kr.south)}}),Ne.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:x=>{b(x,kr.south|kr.west)}}),Ne.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:x=>{b(x,kr.west)}}),Ne.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:x=>{b(x,kr.north|kr.west)}})]})}const Lf={x:0,y:0,width:0,height:0,unit:"px"},cc=(h,i,p)=>Math.min(Math.max(h,i),p),rA=(...h)=>h.filter(i=>i&&typeof i=="string").join(" "),b1=(h,i)=>h===i||h.width===i.width&&h.height===i.height&&h.x===i.x&&h.y===i.y&&h.unit===i.unit;function uc(h,i,p){return h.unit==="%"?{...Lf,...h,unit:"%"}:{unit:"%",x:h.x?h.x/i*100:0,y:h.y?h.y/p*100:0,width:h.width?h.width/i*100:0,height:h.height?h.height/p*100:0}}function ds(h,i,p){return h.unit?h.unit==="px"?{...Lf,...h,unit:"px"}:{unit:"px",x:h.x?h.x*i/100:0,y:h.y?h.y*p/100:0,width:h.width?h.width*i/100:0,height:h.height?h.height*p/100:0}:{...Lf,...h,unit:"px"}}function v1(h,i,p,e,l,n=0,t=0,o=e,a=l){const r={...h};let d=Math.min(n,e),s=Math.min(t,l),u=Math.min(o,e),c=Math.min(a,l);i&&(i>1?(d=t?t*i:d,s=d/i,u=o*i):(s=n?n/i:s,d=s*i,c=a/i)),r.y<0&&(r.height=Math.max(r.height+r.y,s),r.y=0),r.x<0&&(r.width=Math.max(r.width+r.x,d),r.x=0);const f=e-(r.x+r.width);f<0&&(r.x=Math.min(r.x,e-d),r.width+=f);const y=l-(r.y+r.height);if(y<0&&(r.y=Math.min(r.y,l-s),r.height+=y),r.width<d&&((p==="sw"||p=="nw")&&(r.x-=d-r.width),r.width=d),r.height<s&&((p==="nw"||p=="ne")&&(r.y-=s-r.height),r.height=s),r.width>u&&((p==="sw"||p=="nw")&&(r.x-=u-r.width),r.width=u),r.height>c&&((p==="nw"||p=="ne")&&(r.y-=c-r.height),r.height=c),i){const g=r.width/r.height;if(g<i){const v=Math.max(r.width/i,s);(p==="nw"||p=="ne")&&(r.y-=v-r.height),r.height=v}else if(g>i){const v=Math.max(r.height*i,d);(p==="sw"||p=="nw")&&(r.x-=v-r.width),r.width=v}}return r}function oA(h,i,p,e){const l={...h};return i==="ArrowLeft"?e==="nw"?(l.x-=p,l.y-=p,l.width+=p,l.height+=p):e==="w"?(l.x-=p,l.width+=p):e==="sw"?(l.x-=p,l.width+=p,l.height+=p):e==="ne"?(l.y+=p,l.width-=p,l.height-=p):e==="e"?l.width-=p:e==="se"&&(l.width-=p,l.height-=p):i==="ArrowRight"&&(e==="nw"?(l.x+=p,l.y+=p,l.width-=p,l.height-=p):e==="w"?(l.x+=p,l.width-=p):e==="sw"?(l.x+=p,l.width-=p,l.height-=p):e==="ne"?(l.y-=p,l.width+=p,l.height+=p):e==="e"?l.width+=p:e==="se"&&(l.width+=p,l.height+=p)),i==="ArrowUp"?e==="nw"?(l.x-=p,l.y-=p,l.width+=p,l.height+=p):e==="n"?(l.y-=p,l.height+=p):e==="ne"?(l.y-=p,l.width+=p,l.height+=p):e==="sw"?(l.x+=p,l.width-=p,l.height-=p):e==="s"?l.height-=p:e==="se"&&(l.width-=p,l.height-=p):i==="ArrowDown"&&(e==="nw"?(l.x+=p,l.y+=p,l.width-=p,l.height-=p):e==="n"?(l.y+=p,l.height-=p):e==="ne"?(l.y+=p,l.width-=p,l.height-=p):e==="sw"?(l.x-=p,l.width+=p,l.height+=p):e==="s"?l.height+=p:e==="se"&&(l.width+=p,l.height+=p)),l}const dc={capture:!0,passive:!1};let iA=0;const fs=class Ji extends Oe.PureComponent{constructor(){super(...arguments),this.docMoveBound=!1,this.mouseDownOnCrop=!1,this.dragStarted=!1,this.evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0},this.componentRef=Oe.createRef(),this.mediaRef=Oe.createRef(),this.initChangeCalled=!1,this.instanceId=`rc-${iA++}`,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=i=>{const{crop:p,disabled:e}=this.props,l=this.getBox();if(!p)return;const n=ds(p,l.width,l.height);if(e)return;i.cancelable&&i.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const t=i.target.dataset.ord,o=!!t;let a=i.clientX,r=i.clientY,d=n.x,s=n.y;if(t){const u=i.clientX-l.x,c=i.clientY-l.y;let f=0,y=0;t==="ne"||t=="e"?(f=u-(n.x+n.width),y=c-n.y,d=n.x,s=n.y+n.height):t==="se"||t==="s"?(f=u-(n.x+n.width),y=c-(n.y+n.height),d=n.x,s=n.y):t==="sw"||t=="w"?(f=u-n.x,y=c-(n.y+n.height),d=n.x+n.width,s=n.y):(t==="nw"||t=="n")&&(f=u-n.x,y=c-n.y,d=n.x+n.width,s=n.y+n.height),a=d+l.x+f,r=s+l.y+y}this.evData={startClientX:a,startClientY:r,startCropX:d,startCropY:s,clientX:i.clientX,clientY:i.clientY,isResize:o,ord:t},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})},this.onComponentPointerDown=i=>{const{crop:p,disabled:e,locked:l,keepSelection:n,onChange:t}=this.props,o=this.getBox();if(e||l||n&&p)return;i.cancelable&&i.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const a=i.clientX-o.x,r=i.clientY-o.y,d={unit:"px",x:a,y:r,width:0,height:0};this.evData={startClientX:i.clientX,startClientY:i.clientY,startCropX:a,startCropY:r,clientX:i.clientX,clientY:i.clientY,isResize:!0},this.mouseDownOnCrop=!0,t(ds(d,o.width,o.height),uc(d,o.width,o.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})},this.onDocPointerMove=i=>{const{crop:p,disabled:e,onChange:l,onDragStart:n}=this.props,t=this.getBox();if(e||!p||!this.mouseDownOnCrop)return;i.cancelable&&i.preventDefault(),this.dragStarted||(this.dragStarted=!0,n&&n(i));const{evData:o}=this;o.clientX=i.clientX,o.clientY=i.clientY;let a;o.isResize?a=this.resizeCrop():a=this.dragCrop(),b1(p,a)||l(ds(a,t.width,t.height),uc(a,t.width,t.height))},this.onComponentKeyDown=i=>{const{crop:p,disabled:e,onChange:l,onComplete:n}=this.props;if(e)return;const t=i.key;let o=!1;if(!p)return;const a=this.getBox(),r=this.makePixelCrop(a),d=(navigator.platform.match("Mac")?i.metaKey:i.ctrlKey)?Ji.nudgeStepLarge:i.shiftKey?Ji.nudgeStepMedium:Ji.nudgeStep;if(t==="ArrowLeft"?(r.x-=d,o=!0):t==="ArrowRight"?(r.x+=d,o=!0):t==="ArrowUp"?(r.y-=d,o=!0):t==="ArrowDown"&&(r.y+=d,o=!0),o){i.cancelable&&i.preventDefault(),r.x=cc(r.x,0,a.width-r.width),r.y=cc(r.y,0,a.height-r.height);const s=ds(r,a.width,a.height),u=uc(r,a.width,a.height);l(s,u),n&&n(s,u)}},this.onHandlerKeyDown=(i,p)=>{const{aspect:e=0,crop:l,disabled:n,minWidth:t=0,minHeight:o=0,maxWidth:a,maxHeight:r,onChange:d,onComplete:s}=this.props,u=this.getBox();if(n||!l)return;if(i.key==="ArrowUp"||i.key==="ArrowDown"||i.key==="ArrowLeft"||i.key==="ArrowRight")i.stopPropagation(),i.preventDefault();else return;const c=(navigator.platform.match("Mac")?i.metaKey:i.ctrlKey)?Ji.nudgeStepLarge:i.shiftKey?Ji.nudgeStepMedium:Ji.nudgeStep,f=ds(l,u.width,u.height),y=oA(f,i.key,c,p),g=v1(y,e,p,u.width,u.height,t,o,a,r);if(!b1(l,g)){const v=uc(g,u.width,u.height);d(g,v),s&&s(g,v)}},this.onDocPointerDone=i=>{const{crop:p,disabled:e,onComplete:l,onDragEnd:n}=this.props,t=this.getBox();this.unbindDocMove(),!(e||!p)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,n&&n(i),l&&l(ds(p,t.width,t.height),uc(p,t.width,t.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))},this.onDragFocus=()=>{var i;(i=this.componentRef.current)==null||i.scrollTo(0,0)}}get document(){return document}getBox(){const i=this.mediaRef.current;if(!i)return{x:0,y:0,width:0,height:0};const{x:p,y:e,width:l,height:n}=i.getBoundingClientRect();return{x:p,y:e,width:l,height:n}}componentDidUpdate(i){const{crop:p,onComplete:e}=this.props;if(e&&!i.crop&&p){const{width:l,height:n}=this.getBox();l&&n&&e(ds(p,l,n),uc(p,l,n))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,dc),this.document.addEventListener("pointerup",this.onDocPointerDone,dc),this.document.addEventListener("pointercancel",this.onDocPointerDone,dc),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,dc),this.document.removeEventListener("pointerup",this.onDocPointerDone,dc),this.document.removeEventListener("pointercancel",this.onDocPointerDone,dc),this.docMoveBound=!1)}getCropStyle(){const{crop:i}=this.props;if(i)return{top:`${i.y}${i.unit}`,left:`${i.x}${i.unit}`,width:`${i.width}${i.unit}`,height:`${i.height}${i.unit}`}}dragCrop(){const{evData:i}=this,p=this.getBox(),e=this.makePixelCrop(p),l=i.clientX-i.startClientX,n=i.clientY-i.startClientY;return e.x=cc(i.startCropX+l,0,p.width-e.width),e.y=cc(i.startCropY+n,0,p.height-e.height),e}getPointRegion(i,p,e,l){const{evData:n}=this,t=n.clientX-i.x,o=n.clientY-i.y;let a;l&&p?a=p==="nw"||p==="n"||p==="ne":a=o<n.startCropY;let r;return e&&p?r=p==="nw"||p==="w"||p==="sw":r=t<n.startCropX,r?a?"nw":"sw":a?"ne":"se"}resolveMinDimensions(i,p,e=0,l=0){const n=Math.min(e,i.width),t=Math.min(l,i.height);return!p||!n&&!t?[n,t]:p>1?n?[n,n/p]:[t*p,t]:t?[t*p,t]:[n,n/p]}resizeCrop(){const{evData:i}=this,{aspect:p=0,maxWidth:e,maxHeight:l}=this.props,n=this.getBox(),[t,o]=this.resolveMinDimensions(n,p,this.props.minWidth,this.props.minHeight);let a=this.makePixelCrop(n);const r=this.getPointRegion(n,i.ord,t,o),d=i.ord||r;let s=i.clientX-i.startClientX,u=i.clientY-i.startClientY;(t&&d==="nw"||d==="w"||d==="sw")&&(s=Math.min(s,-t)),(o&&d==="nw"||d==="n"||d==="ne")&&(u=Math.min(u,-o));const c={unit:"px",x:0,y:0,width:0,height:0};r==="ne"?(c.x=i.startCropX,c.width=s,p?(c.height=c.width/p,c.y=i.startCropY-c.height):(c.height=Math.abs(u),c.y=i.startCropY-c.height)):r==="se"?(c.x=i.startCropX,c.y=i.startCropY,c.width=s,p?c.height=c.width/p:c.height=u):r==="sw"?(c.x=i.startCropX+s,c.y=i.startCropY,c.width=Math.abs(s),p?c.height=c.width/p:c.height=u):r==="nw"&&(c.x=i.startCropX+s,c.width=Math.abs(s),p?(c.height=c.width/p,c.y=i.startCropY-c.height):(c.height=Math.abs(u),c.y=i.startCropY+u));const f=v1(c,p,r,n.width,n.height,t,o,e,l);return p||Ji.xyOrds.indexOf(d)>-1?a=f:Ji.xOrds.indexOf(d)>-1?(a.x=f.x,a.width=f.width):Ji.yOrds.indexOf(d)>-1&&(a.y=f.y,a.height=f.height),a.x=cc(a.x,0,n.width-a.width),a.y=cc(a.y,0,n.height-a.height),a}renderCropSelection(){const{ariaLabels:i=Ji.defaultProps.ariaLabels,disabled:p,locked:e,renderSelectionAddon:l,ruleOfThirds:n,crop:t}=this.props,o=this.getCropStyle();if(t)return Oe.createElement("div",{style:o,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":i.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!p&&!e&&Oe.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},Oe.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),Oe.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),Oe.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),Oe.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":i.nwDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"nw"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":i.nDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"n"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":i.neDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"ne"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":i.eDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"e"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":i.seDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"se"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":i.sDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"s"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":i.swDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"sw"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":i.wDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"w"),role:"button"})),l&&Oe.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:a=>a.stopPropagation()},l(this.state)),n&&Oe.createElement(Oe.Fragment,null,Oe.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),Oe.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(i){const p={...Lf,...this.props.crop||{}};return ds(p,i.width,i.height)}render(){const{aspect:i,children:p,circularCrop:e,className:l,crop:n,disabled:t,locked:o,style:a,ruleOfThirds:r}=this.props,{cropIsActive:d,newCropIsBeingDrawn:s}=this.state,u=n?this.renderCropSelection():null,c=rA("ReactCrop",l,d&&"ReactCrop--active",t&&"ReactCrop--disabled",o&&"ReactCrop--locked",s&&"ReactCrop--new-crop",n&&i&&"ReactCrop--fixed-aspect",n&&e&&"ReactCrop--circular-crop",n&&r&&"ReactCrop--rule-of-thirds",!this.dragStarted&&n&&!n.width&&!n.height&&"ReactCrop--invisible-crop",e&&"ReactCrop--no-animate");return Oe.createElement("div",{ref:this.componentRef,className:c,style:a},Oe.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},p),n?Oe.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},Oe.createElement("defs",null,Oe.createElement("mask",{id:`hole-${this.instanceId}`},Oe.createElement("rect",{width:"100%",height:"100%",fill:"white"}),e?Oe.createElement("ellipse",{cx:`${n.x+n.width/2}${n.unit}`,cy:`${n.y+n.height/2}${n.unit}`,rx:`${n.width/2}${n.unit}`,ry:`${n.height/2}${n.unit}`,fill:"black"}):Oe.createElement("rect",{x:`${n.x}${n.unit}`,y:`${n.y}${n.unit}`,width:`${n.width}${n.unit}`,height:`${n.height}${n.unit}`,fill:"black"}))),Oe.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,u)}};fs.xOrds=["e","w"],fs.yOrds=["n","s"],fs.xyOrds=["nw","ne","se","sw"],fs.nudgeStep=1,fs.nudgeStepMedium=10,fs.nudgeStepLarge=100,fs.defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};let aA=fs;const GA="",Tg=ki();function sA({altText:h,className:i,src:p,width:e,height:l,maxWidth:n,imageRef:t,startCrop:o,setStartCrop:a,isFocused:r,nodeKey:d}){const[s,u]=Oe.useState(null),[c,f]=Oe.useState(null),[y,g]=Oe.useState({unit:"px",x:25,y:25,width:50,height:50}),[v]=Xn(),_=()=>{if(s){const m=t.current;if(!m||!s)return;const w=m.naturalWidth/m.width,E=m.naturalHeight/m.height,N=new OffscreenCanvas(s.width*w,s.height*E),M=N.getContext("2d");if(!M)throw new Error("No 2D context available");M.drawImage(m,s.x*w,s.y*E,s.width*w,s.height*E,0,0,s.width*w,s.height*E),N.convertToBlob({type:"image/png"}).then(B=>{const P=URL.createObjectURL(B);f(P),a(!1);const R=new FileReader;R.onload=()=>{const j=R.result;v.update(()=>{const O=rr(d);fu(O)&&j&&O.setSrc(j)})},R.onerror=()=>{console.log("error")},R.readAsDataURL(B)})}},b=()=>{o||a(m=>{if(m===!1){const w=t.current;g({unit:"px",x:0,y:0,width:w.width,height:w.height})}return!m})},S=Oe.useRef(null),C=Oe.useRef(null);Oe.useEffect(()=>{s&&(S.current=s)},[s]);const x=m=>{C.current&&!C.current.contains(m.target)&&a(!1)};return Oe.useEffect(()=>(document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}),[]),Ne.jsxs("div",{ref:C,children:[r&&Ne.jsx("button",{style:{zIndex:999},className:"image-caption-button",onClick:()=>b(),children:"Crop"}),o&&Ne.jsx("button",{style:{zIndex:999},className:"image-caption-button",onClick:()=>_(),children:"Apply Crop"}),o?Ne.jsx(aA,{crop:y,onChange:m=>g(m),onComplete:m=>u(m),children:Ne.jsx("img",{className:i||void 0,src:c||p,alt:h,ref:t,style:{height:l,maxWidth:n,width:e},draggable:"false"})}):Ne.jsx("img",{className:i||void 0,src:c||p,alt:h,ref:t,style:{height:l,maxWidth:n,width:e},draggable:"false"})]})}function lA({src:h,altText:i,nodeKey:p,width:e,height:l,maxWidth:n,resizable:t,showCaption:o,caption:a}){const r=Oe.useRef(null),d=Oe.useRef(null),[s,u,c]=Nf(p),[f,y]=Oe.useState(!1),[g]=Xn(),[v,_]=Oe.useState(null),[b,S]=Oe.useState(!1),C=Oe.useRef(null),x=Oe.useCallback(O=>{if(s&&lr(jt())){O.preventDefault();const D=rr(p);if(fu(D))return D.remove(),!0}return!1},[s,p]),m=Oe.useCallback(O=>{const A=jt(),D=d.current;if(s&&lr(A)&&A.getNodes().length===1){if(o)return or(null),O.preventDefault(),a.focus(),!0;if(D!==null&&D!==document.activeElement)return O.preventDefault(),D.focus(),!0}return!1},[a,s,o]),w=Oe.useCallback(O=>C.current===a||d.current===O.target?(or(null),g.update(()=>{u(!0);const A=g.getRootElement();A!==null&&A.focus()}),!0):!1,[a,g,u]),E=Oe.useCallback(O=>{const A=O;return f?!0:A.target===r.current?(A.shiftKey?u(!s):(c(),u(!0)),!0):!1},[f,s,u,c]),N=Oe.useCallback(O=>{g.getEditorState().read(()=>{const A=jt();O.target.tagName==="IMG"&&Tt(A)&&A.getNodes().length===1&&g.dispatchCommand(Tg,O)})},[g]);Oe.useEffect(()=>{let O=!0;const A=g.getRootElement(),D=qr(g.registerUpdateListener(({editorState:L})=>{O&&_(L.read(()=>jt()))}),g.registerCommand(Uo,(L,J)=>(C.current=J,!1),Ln),g.registerCommand(Ua,E,Ln),g.registerCommand(Tg,E,Ln),g.registerCommand(Ms,L=>L.target===r.current?(L.preventDefault(),!0):!1,Ln),g.registerCommand(ma,x,Ln),g.registerCommand(Ai,x,Ln),g.registerCommand(Ki,m,Ln),g.registerCommand($a,w,Ln));return A==null||A.addEventListener("contextmenu",N),()=>{O=!1,D(),A==null||A.removeEventListener("contextmenu",N)}},[c,g,f,s,p,x,m,w,E,N,u]);const M=()=>{g.update(()=>{const O=rr(p);fu(O)&&O.setShowCaption(!0)})},B=(O,A)=>{setTimeout(()=>{y(!1)},200),g.update(()=>{const D=rr(p);console.log(D,"node"),fu(D)&&D.setWidthAndHeight(O,A)})},P=()=>{b||y(!0)},R=s&&lr(v)&&!f,j=s||f;return Ne.jsx(Oe.Suspense,{fallback:null,children:Ne.jsxs(Ne.Fragment,{children:[Ne.jsx("div",{draggable:R,children:Ne.jsx(sA,{className:j?`focused ${lr(v)?"draggable":""}`:null,src:h,altText:i,width:e,height:l,maxWidth:n,imageRef:r,startCrop:b,setStartCrop:S,isFocused:j,nodeKey:p})}),o&&Ne.jsx("div",{className:"image-caption-container",children:Ne.jsx(y1,{initialEditor:a,children:Ne.jsx(uf,{contentEditable:Ne.jsx(h1,{className:"ImageNode__contentEditable"}),placeholder:Ne.jsx(g1,{className:"ImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:vu})})}),!b&&t&&lr(v)&&j&&Ne.jsx(nA,{showCaption:o,setShowCaption:M,editor:g,buttonRef:d,maxWidth:n,onResizeStart:b?()=>{}:P,onResizeEnd:b?()=>{}:B,captionsEnabled:!1,imageRef:r})]})})}const cA=Object.freeze(Object.defineProperty({__proto__:null,RIGHT_CLICK_IMAGE_COMMAND:Tg,default:lA},Symbol.toStringTag,{value:"Module"})),_1=new Set;function uA(h){if(!_1.has(h))throw new Promise(i=>{const p=new Image;p.src=h,p.onload=()=>{_1.add(h),i(null)}})}function dA({altText:h,className:i,imageRef:p,src:e,width:l,height:n,position:t}){return uA(e),Ne.jsx("img",{className:i||void 0,src:e,alt:h,ref:p,"data-position":t,style:{display:"block",height:n,width:l},draggable:"false"})}function x1({activeEditor:h,nodeKey:i,onClose:p}){const l=h.getEditorState().read(()=>rr(i)),[n,t]=Oe.useState(l.getAltText()),[o,a]=Oe.useState(l.getShowCaption()),[r,d]=Oe.useState(l.getPosition()),s=f=>{a(f.target.checked)},u=f=>{d(f.target.value)},c=()=>{const f={altText:n,position:r,showCaption:o};l&&h.update(()=>{l.update(f)}),p()};return Ne.jsxs(Ne.Fragment,{children:[Ne.jsx("div",{style:{marginBottom:"1em"},children:Ne.jsx(G0,{label:"Alt Text",placeholder:"Descriptive alternative text",onChange:t,value:n,"data-test-id":"image-modal-alt-text-input"})}),Ne.jsxs(lS,{style:{marginBottom:"1em",width:"208px"},value:r,label:"Position",name:"position",id:"position-select",onChange:u,children:[Ne.jsx("option",{value:"left",children:"Left"}),Ne.jsx("option",{value:"right",children:"Right"}),Ne.jsx("option",{value:"full",children:"Full Width"})]}),Ne.jsxs("div",{className:"Input__wrapper",children:[Ne.jsx("input",{id:"caption",type:"checkbox",checked:o,onChange:s}),Ne.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),Ne.jsx(Y0,{children:Ne.jsx(Z0,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>c(),children:"Confirm"})})]})}function fA({src:h,altText:i,nodeKey:p,width:e,height:l,showCaption:n,caption:t,position:o}){const[a,r]=Lb(),d=Oe.useRef(null),s=Oe.useRef(null),[u,c,f]=Nf(p),[y]=Xn(),[g,v]=Oe.useState(null),_=Oe.useRef(null),b=Oe.useCallback(w=>{if(u&&lr(jt())){w.preventDefault();const N=rr(p);if(P0(N))return N.remove(),!0}return!1},[u,p]),S=Oe.useCallback(w=>{const E=jt(),N=s.current;if(u&&lr(E)&&E.getNodes().length===1){if(n)return or(null),w.preventDefault(),t.focus(),!0;if(N!==null&&N!==document.activeElement)return w.preventDefault(),N.focus(),!0}return!1},[t,u,n]),C=Oe.useCallback(w=>_.current===t||s.current===w.target?(or(null),y.update(()=>{c(!0);const E=y.getRootElement();E!==null&&E.focus()}),!0):!1,[t,y,c]);Oe.useEffect(()=>{let w=!0;const E=qr(y.registerUpdateListener(({editorState:N})=>{w&&v(N.read(()=>jt()))}),y.registerCommand(Uo,(N,M)=>(_.current=M,!1),Ln),y.registerCommand(Ua,N=>{const M=N;return M.target===d.current?(M.shiftKey?c(!u):(f(),c(!0)),!0):!1},Ln),y.registerCommand(Ms,N=>N.target===d.current?(N.preventDefault(),!0):!1,Ln),y.registerCommand(ma,b,Ln),y.registerCommand(Ai,b,Ln),y.registerCommand(Ki,S,Ln),y.registerCommand($a,C,Ln));return()=>{w=!1,E()}},[f,y,u,p,b,S,C,c]);const x=u&&lr(g),m=u;return Ne.jsxs(Oe.Suspense,{fallback:null,children:[Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs("div",{draggable:x,children:[Ne.jsx("button",{className:"image-edit-button",ref:s,onClick:()=>{r("Update Inline Image",w=>Ne.jsx(x1,{activeEditor:y,nodeKey:p,onClose:w}))},children:"Edit"}),Ne.jsx(dA,{className:m?`focused ${lr(g)?"draggable":""}`:null,src:h,altText:i,imageRef:d,width:e,height:l,position:o})]}),n&&Ne.jsx("div",{className:"image-caption-container",children:Ne.jsx(y1,{initialEditor:t,children:Ne.jsx(uf,{contentEditable:Ne.jsx(h1,{className:"InlineImageNode__contentEditable"}),placeholder:Ne.jsx(g1,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:vu})})})]}),a]})}const pA=Object.freeze(Object.defineProperty({__proto__:null,UpdateInlineImageDialog:x1,default:fA},Symbol.toStringTag,{value:"Module"}));To.Editor=ZT,To.EditorVariant2=XT,Object.defineProperty(To,Symbol.toStringTag,{value:"Module"})});
|
|
1507
|
+
`}isInline(){return!1}updateDOM(){return!1}decorate(){return Ne.jsx(VT,{nodeKey:this.__key})}}function JT(){return{node:p1()}}function p1(){return new Nu}function KT(h){return h instanceof Nu}const WA="";function h1({className:h,style:i}){return Ne.jsx(df,{className:h||"ContentEditable__root",style:i})}const $A="";function g1({children:h,className:i}){return Ne.jsx("div",{className:i||"Placeholder__root",children:h})}const GT=({onChange:h})=>{const[i]=Xn(),[p,e]=Oe.useState(!0),l=Oe.useRef(""),n=l.current,t=Oe.useCallback(()=>{i.update(()=>{const o=I0(i);p?e(!1):o!==n&&(h(o),l.current=o)})},[i,p,h,n]);return Oe.useEffect(()=>{const o=i.registerUpdateListener(t);return()=>o()},[i,t]),null},YT=n1([...[Ri,Us,Mi,Yd,Qd,ef,Zs,Nu]]);function ZT({collabApiKey:h,userObj:i,styleConfig:p,docId:e,onlUser:l,setonlUser:n,savedSpfEditorState:t,setSavedEditorState:o,setSavedEditorState2:a,mentionItems:r,showtoolbar:d=!0,customHeight:s,customWidth:u,disabled:c,editorId:f,onPaste:y,source:g}){const v=Oe.useRef(null),{pageMarginTop:_,pageMarginLeft:b,pageMarginBottom:S,pageMarginRight:C,heading:x}=p||{};Oe.useState("");const[m,w]=Oe.useState(!0),E=Oe.useRef(null),[N,M]=Oe.useState(!1),[B,P]=Oe.useState([]),R=Oe.useRef(),[j,O]=Oe.useState({root:null}),[A,D]=Oe.useState(0);let L={namespace:`editor_${f}`,nodes:[...YT],onError(G){throw G},theme:o0,editorState:G=>{G.update(()=>{if(t&&m){const Z=new DOMParser().parseFromString(t,"text/html"),X=jh(G,Z);X.forEach(ee=>{ee instanceof Mi&&ee.setStyle("font-weight: normal")}),yr(),Al(X),w(!1)}})}};Oe.useEffect(()=>{setTimeout(()=>{Fl(".custom-margin").css({paddingTop:`${_||"16px"}`,paddingRight:`${C||"16px"}`,paddingLeft:`${b||"16px"}`,paddingBottom:`${S||"16px"}`}),Fl(".editor-inner").css({maxHeight:s?`${s}px`:"100%",overflow:"scroll",height:s?`${s}px`:"100%",minHeight:"200px",maxWidth:u?`${u}px`:"100%"}),Fl(".editor-input").attr("contentEditable",!c)},500)},[]);const{userName:J,userId:T,userEmail:z}=i,K={docId:f,apiKey:h,user:{name:J,id:T,email:z},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:G,content:Y})=>{},usersUpdate:G=>{h&&h.length>0&&(P(G),renderOnlineUsers(G))}}},F=()=>{R.current&&R.current.start(K).then(()=>{console.log("[Lexical Demo][codox.start] success"),M(!0)}).catch(G=>console.log("[Lexical Demo][codox.start] error",G))};Oe.useEffect(()=>()=>{q()},[]);const q=()=>{R.current&&R.current.stop(),M(!1)};Oe.useEffect(()=>{j&&e&&!N&&F()},[j,e,N]),Oe.useEffect(()=>{let G=[],Y=[];B&&B.length>0&&B.map((Z,X)=>{Y.includes(Z.name)||(Y.push(Z.name),G.push(Ne.jsxs("div",{title:Z.email,className:`avatarStyle avatar-color-${X+1}`,children:[" ",Z.name&&Z.name[0],Z.name&&Z.name[4]]},X)))}),n(G)},[B]),Oe.useEffect(()=>{(async G=>{const Y=!!h,Z=!!i,X=!!p;A>1&&A<200&&D(A+1),console.log(Y&&Z&&X?"All three conditions are met.":Y&&Z||Y&&X||Z&&X?"Any two of the three conditions are met.":Y||Z||X?"Any one of the three conditions is met.":"None of the three conditions are met.")})()},[h,i,p]);const W=Oe.useCallback(G=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{o(G)},500)},[f,o,a]),H=Oe.useCallback(G=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{a(G)},500)},[f,o,a]);return Ne.jsxs("div",{ref:v,children:[Ne.jsx(sS,{children:Ne.jsxs(bh,{initialConfig:L,children:[Ne.jsx(t1,{ref:R}),Ne.jsxs("div",{className:"editor-container",children:[d&&Ne.jsx(aE,{styleConfig:p,onlUser:l,stopCodox:q,startCodox:F,source:g,onPaste:y}),Ne.jsx("div",{className:"editor-inner",children:Ne.jsx(uf,{contentEditable:Ne.jsx("div",{className:"custom-margin",children:Ne.jsx(df,{className:"editor-input inpt-1"})}),placeholder:null,ErrorBoundary:vu})})]}),Ne.jsx(Vw,{}),Ne.jsx(mE,{}),Ne.jsx(Xw,{}),Ne.jsx(uS,{}),Ne.jsx(ng,{}),Ne.jsx(qT,{items:r,menuComponent:WT,menuItemComponent:$T}),Ne.jsx(GT,{onChange:f.includes("objective")?W:H})]})}),Ne.jsx(uC,{styleConfig:p})]})}const QT=n1([...[]]);function XT({collabApiKey:h,userObj:i,docId:p,setonlUser:e,savedSpfEditorState:l,setSavedEditorState:n,customHeight:t,customWidth:o,editorId:a}){const r=Oe.useRef(null),[d,s]=Oe.useState(!0),[u,c]=Oe.useState(!1),[f,y]=Oe.useState([]),g=Oe.useRef(),[v,_]=Oe.useState({root:null});Oe.useState(0);const b=Oe.useRef(""),S={namespace:`editor_${a}`,nodes:[...QT],onError(B){throw B},theme:o0,editorState:B=>{B.update(()=>{if(l&&d){const R=new DOMParser().parseFromString(l,"text/html"),j=jh(B,R);yr(),Al(j),s(!1)}})}};Oe.useEffect(()=>{setTimeout(()=>{Fl(".custom-margin-2").css({height:`${t}px`}),Fl(".editor-inner-2").css({background:"#fff",position:"relative",top:"20px",padding:"20px",borderRadius:"0 0 10px 10px",maxHeight:`${t}px`,overflow:"scroll",height:`${t}px`,minHeight:"200px",maxWidth:o?`${o}px`:"100%"})},500)},[]);const{userName:C,userId:x,userEmail:m}=i,E={docId:a,apiKey:h,user:{name:C,id:x,email:m},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:B,content:P})=>{},usersUpdate:B=>{y(B),renderOnlineUsers(B)}}},N=()=>{g.current&&g.current.start(E).then(()=>{console.log("[Lexical Demo][codox.start] success"),c(!0)}).catch(B=>console.log("[Lexical Demo][codox.start] error",B))};Oe.useEffect(()=>{v&&p&&!u&&N()},[v,p,u]),Oe.useEffect(()=>{let B=[],P=[];f&&f.length>0&&f.map((R,j)=>{P.includes(R.name)||(P.push(R.name),B.push(Ne.jsxs("div",{title:R.email,className:`avatarStyle avatar-color-${j+1}`,children:[" ",R.name&&R.name[0],R.name&&R.name[4]]},j)))}),e(B)},[f]);const M=()=>{let B=Fl(".editor-input-2").html();B!==b.current&&(console.log("Editor Variant 2 HTML",B),n(B),b.current=B)};return Ne.jsx("div",{ref:r,children:Ne.jsxs(bh,{initialConfig:S,children:[Ne.jsx(t1,{ref:g}),Ne.jsx("div",{className:"editor-container",children:Ne.jsxs("div",{className:"editor-inner-2",children:[Ne.jsx(uf,{contentEditable:Ne.jsx("div",{className:"custom-margin-2",children:Ne.jsx(df,{className:"editor-input-2 inpt-2"})}),placeholder:null,ErrorBoundary:vu}),Ne.jsx(Yb,{onChange:M})]})}),Ne.jsx(ng,{})]})})}const KA="";function eA(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var tA=eA(function(h){const i=new URLSearchParams;i.append("code",h);for(let p=1;p<arguments.length;p++)i.append("v",arguments[p]);throw Error(`Minified Lexical error #${h}; visit https://lexical.dev/docs/error?${i} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function m1(h){const i=h.transform();return i!==null?new Set([i]):new Set}function y1({initialEditor:h,children:i,initialNodes:p,initialTheme:e,skipCollabChecks:l}){const n=Oe.useRef(!1),t=Oe.useContext(Dc);t==null&&tA(9);const[o,{getTheme:a}]=t,r=Oe.useMemo(()=>{const c=e||a()||void 0,f=Pm(t,c);if(c!==void 0&&(h._config.theme=c),h._parentEditor=o,p)for(let y of p){let g=null,v=null;if(typeof y!="function"){const b=y;y=b.replace,g=b.with,v=b.withKlass||null}const _=h._nodes.get(y.getType());h._nodes.set(y.getType(),{exportDOM:_?_.exportDOM:void 0,klass:y,replace:g,replaceWithKlass:v,transforms:m1(y)})}else{const y=h._nodes=new Map(o._nodes);for(const[g,v]of y)h._nodes.set(g,{exportDOM:v.exportDOM,klass:v.klass,replace:v.replace,replaceWithKlass:v.replaceWithKlass,transforms:m1(v.klass)})}return h._config.namespace=o._config.namespace,h._editable=o._editable,[h,f]},[]),{isCollabActive:d,yjsDocMap:s}=Jb(),u=l||n.current||s.has(h.getKey());return Oe.useEffect(()=>{u&&(n.current=!0)},[u]),Oe.useEffect(()=>o.registerEditableListener(c=>{h.setEditable(c)}),[h,o]),Ne.jsx(Dc.Provider,{value:r,children:!d||u?i:null})}function kg(h,i,p){return Math.min(Math.max(h,i),p)}const kr={east:1,north:8,south:2,west:4};function nA({onResizeStart:h,onResizeEnd:i,buttonRef:p,imageRef:e,maxWidth:l,editor:n,showCaption:t,setShowCaption:o,captionsEnabled:a}){const r=Oe.useRef(null),d=Oe.useRef({priority:"",value:"default"}),s=Oe.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),u=n.getRootElement(),c=u!==null?u.getBoundingClientRect().width-20:100,f=u!==null?u.getBoundingClientRect().height-20:100,y=100,g=100,v=x=>{const m=x===kr.east||x===kr.west,w=x===kr.north||x===kr.south,E=x&kr.north&&x&kr.west||x&kr.south&&x&kr.east,N=m?"ew":w?"ns":E?"nwse":"nesw";u!==null&&u.style.setProperty("cursor",`${N}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${N}-resize`,"important"),d.current.value=document.body.style.getPropertyValue("-webkit-user-select"),d.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))},_=()=>{u!==null&&u.style.setProperty("cursor","text"),document.body!==null&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",d.current.value,d.current.priority))},b=(x,m)=>{if(!n.isEditable())return;const w=e.current,E=r.current;if(w!==null&&E!==null){x.preventDefault();const{width:N,height:M}=w.getBoundingClientRect(),B=s.current;B.startWidth=N,B.startHeight=M,B.ratio=N/M,B.currentWidth=N,B.currentHeight=M,B.startX=x.clientX,B.startY=x.clientY,B.isResizing=!0,B.direction=m,v(m),h(),E.classList.add("image-control-wrapper--resizing"),w.style.height=`${M}px`,w.style.width=`${N}px`,document.addEventListener("pointermove",S),document.addEventListener("pointerup",C)}},S=x=>{const m=e.current,w=s.current,E=w.direction&(kr.east|kr.west),N=w.direction&(kr.south|kr.north);if(m!==null&&w.isResizing){if(E&&N){let M=Math.floor(w.startX-x.clientX);M=w.direction&kr.east?-M:M;const B=kg(w.startWidth+M,y,c),P=B/w.ratio;m.style.width=`${B}px`,m.style.height=`${P}px`,w.currentHeight=P,w.currentWidth=B}else if(N){let M=Math.floor(w.startY-x.clientY);M=w.direction&kr.south?-M:M;const B=kg(w.startHeight+M,g,f);m.style.height=`${B}px`,m.style.maxHeight=`${B}px`,w.currentHeight=B}else{let M=Math.floor(w.startX-x.clientX);M=w.direction&kr.east?-M:M;const B=kg(w.startWidth+M,y,c);m.style.width=`${B}px`,m.style.maxWidth=`${B}px`,w.currentWidth=B}m&&(m.setAttribute("width",`${w.currentWidth}`),m.setAttribute("height",`${w.currentHeight}`))}},C=()=>{const x=e.current,m=s.current,w=r.current;if(x!==null&&w!==null&&m.isResizing){const E=m.currentWidth,N=m.currentHeight;m.startWidth=0,m.startHeight=0,m.ratio=0,m.startX=0,m.startY=0,m.currentWidth=0,m.currentHeight=0,m.isResizing=!1,w.classList.remove("image-control-wrapper--resizing"),_(),i(E,N),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C)}};return Ne.jsxs("div",{ref:r,children:[Ne.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:x=>{b(x,kr.north)}}),Ne.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:x=>{b(x,kr.north|kr.east)}}),Ne.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:x=>{b(x,kr.east)}}),Ne.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:x=>{b(x,kr.south|kr.east)}}),Ne.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:x=>{b(x,kr.south)}}),Ne.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:x=>{b(x,kr.south|kr.west)}}),Ne.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:x=>{b(x,kr.west)}}),Ne.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:x=>{b(x,kr.north|kr.west)}})]})}const Lf={x:0,y:0,width:0,height:0,unit:"px"},cc=(h,i,p)=>Math.min(Math.max(h,i),p),rA=(...h)=>h.filter(i=>i&&typeof i=="string").join(" "),b1=(h,i)=>h===i||h.width===i.width&&h.height===i.height&&h.x===i.x&&h.y===i.y&&h.unit===i.unit;function uc(h,i,p){return h.unit==="%"?{...Lf,...h,unit:"%"}:{unit:"%",x:h.x?h.x/i*100:0,y:h.y?h.y/p*100:0,width:h.width?h.width/i*100:0,height:h.height?h.height/p*100:0}}function ds(h,i,p){return h.unit?h.unit==="px"?{...Lf,...h,unit:"px"}:{unit:"px",x:h.x?h.x*i/100:0,y:h.y?h.y*p/100:0,width:h.width?h.width*i/100:0,height:h.height?h.height*p/100:0}:{...Lf,...h,unit:"px"}}function v1(h,i,p,e,l,n=0,t=0,o=e,a=l){const r={...h};let d=Math.min(n,e),s=Math.min(t,l),u=Math.min(o,e),c=Math.min(a,l);i&&(i>1?(d=t?t*i:d,s=d/i,u=o*i):(s=n?n/i:s,d=s*i,c=a/i)),r.y<0&&(r.height=Math.max(r.height+r.y,s),r.y=0),r.x<0&&(r.width=Math.max(r.width+r.x,d),r.x=0);const f=e-(r.x+r.width);f<0&&(r.x=Math.min(r.x,e-d),r.width+=f);const y=l-(r.y+r.height);if(y<0&&(r.y=Math.min(r.y,l-s),r.height+=y),r.width<d&&((p==="sw"||p=="nw")&&(r.x-=d-r.width),r.width=d),r.height<s&&((p==="nw"||p=="ne")&&(r.y-=s-r.height),r.height=s),r.width>u&&((p==="sw"||p=="nw")&&(r.x-=u-r.width),r.width=u),r.height>c&&((p==="nw"||p=="ne")&&(r.y-=c-r.height),r.height=c),i){const g=r.width/r.height;if(g<i){const v=Math.max(r.width/i,s);(p==="nw"||p=="ne")&&(r.y-=v-r.height),r.height=v}else if(g>i){const v=Math.max(r.height*i,d);(p==="sw"||p=="nw")&&(r.x-=v-r.width),r.width=v}}return r}function oA(h,i,p,e){const l={...h};return i==="ArrowLeft"?e==="nw"?(l.x-=p,l.y-=p,l.width+=p,l.height+=p):e==="w"?(l.x-=p,l.width+=p):e==="sw"?(l.x-=p,l.width+=p,l.height+=p):e==="ne"?(l.y+=p,l.width-=p,l.height-=p):e==="e"?l.width-=p:e==="se"&&(l.width-=p,l.height-=p):i==="ArrowRight"&&(e==="nw"?(l.x+=p,l.y+=p,l.width-=p,l.height-=p):e==="w"?(l.x+=p,l.width-=p):e==="sw"?(l.x+=p,l.width-=p,l.height-=p):e==="ne"?(l.y-=p,l.width+=p,l.height+=p):e==="e"?l.width+=p:e==="se"&&(l.width+=p,l.height+=p)),i==="ArrowUp"?e==="nw"?(l.x-=p,l.y-=p,l.width+=p,l.height+=p):e==="n"?(l.y-=p,l.height+=p):e==="ne"?(l.y-=p,l.width+=p,l.height+=p):e==="sw"?(l.x+=p,l.width-=p,l.height-=p):e==="s"?l.height-=p:e==="se"&&(l.width-=p,l.height-=p):i==="ArrowDown"&&(e==="nw"?(l.x+=p,l.y+=p,l.width-=p,l.height-=p):e==="n"?(l.y+=p,l.height-=p):e==="ne"?(l.y+=p,l.width-=p,l.height-=p):e==="sw"?(l.x-=p,l.width+=p,l.height+=p):e==="s"?l.height+=p:e==="se"&&(l.width+=p,l.height+=p)),l}const dc={capture:!0,passive:!1};let iA=0;const fs=class Ji extends Oe.PureComponent{constructor(){super(...arguments),this.docMoveBound=!1,this.mouseDownOnCrop=!1,this.dragStarted=!1,this.evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0},this.componentRef=Oe.createRef(),this.mediaRef=Oe.createRef(),this.initChangeCalled=!1,this.instanceId=`rc-${iA++}`,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=i=>{const{crop:p,disabled:e}=this.props,l=this.getBox();if(!p)return;const n=ds(p,l.width,l.height);if(e)return;i.cancelable&&i.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const t=i.target.dataset.ord,o=!!t;let a=i.clientX,r=i.clientY,d=n.x,s=n.y;if(t){const u=i.clientX-l.x,c=i.clientY-l.y;let f=0,y=0;t==="ne"||t=="e"?(f=u-(n.x+n.width),y=c-n.y,d=n.x,s=n.y+n.height):t==="se"||t==="s"?(f=u-(n.x+n.width),y=c-(n.y+n.height),d=n.x,s=n.y):t==="sw"||t=="w"?(f=u-n.x,y=c-(n.y+n.height),d=n.x+n.width,s=n.y):(t==="nw"||t=="n")&&(f=u-n.x,y=c-n.y,d=n.x+n.width,s=n.y+n.height),a=d+l.x+f,r=s+l.y+y}this.evData={startClientX:a,startClientY:r,startCropX:d,startCropY:s,clientX:i.clientX,clientY:i.clientY,isResize:o,ord:t},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})},this.onComponentPointerDown=i=>{const{crop:p,disabled:e,locked:l,keepSelection:n,onChange:t}=this.props,o=this.getBox();if(e||l||n&&p)return;i.cancelable&&i.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const a=i.clientX-o.x,r=i.clientY-o.y,d={unit:"px",x:a,y:r,width:0,height:0};this.evData={startClientX:i.clientX,startClientY:i.clientY,startCropX:a,startCropY:r,clientX:i.clientX,clientY:i.clientY,isResize:!0},this.mouseDownOnCrop=!0,t(ds(d,o.width,o.height),uc(d,o.width,o.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})},this.onDocPointerMove=i=>{const{crop:p,disabled:e,onChange:l,onDragStart:n}=this.props,t=this.getBox();if(e||!p||!this.mouseDownOnCrop)return;i.cancelable&&i.preventDefault(),this.dragStarted||(this.dragStarted=!0,n&&n(i));const{evData:o}=this;o.clientX=i.clientX,o.clientY=i.clientY;let a;o.isResize?a=this.resizeCrop():a=this.dragCrop(),b1(p,a)||l(ds(a,t.width,t.height),uc(a,t.width,t.height))},this.onComponentKeyDown=i=>{const{crop:p,disabled:e,onChange:l,onComplete:n}=this.props;if(e)return;const t=i.key;let o=!1;if(!p)return;const a=this.getBox(),r=this.makePixelCrop(a),d=(navigator.platform.match("Mac")?i.metaKey:i.ctrlKey)?Ji.nudgeStepLarge:i.shiftKey?Ji.nudgeStepMedium:Ji.nudgeStep;if(t==="ArrowLeft"?(r.x-=d,o=!0):t==="ArrowRight"?(r.x+=d,o=!0):t==="ArrowUp"?(r.y-=d,o=!0):t==="ArrowDown"&&(r.y+=d,o=!0),o){i.cancelable&&i.preventDefault(),r.x=cc(r.x,0,a.width-r.width),r.y=cc(r.y,0,a.height-r.height);const s=ds(r,a.width,a.height),u=uc(r,a.width,a.height);l(s,u),n&&n(s,u)}},this.onHandlerKeyDown=(i,p)=>{const{aspect:e=0,crop:l,disabled:n,minWidth:t=0,minHeight:o=0,maxWidth:a,maxHeight:r,onChange:d,onComplete:s}=this.props,u=this.getBox();if(n||!l)return;if(i.key==="ArrowUp"||i.key==="ArrowDown"||i.key==="ArrowLeft"||i.key==="ArrowRight")i.stopPropagation(),i.preventDefault();else return;const c=(navigator.platform.match("Mac")?i.metaKey:i.ctrlKey)?Ji.nudgeStepLarge:i.shiftKey?Ji.nudgeStepMedium:Ji.nudgeStep,f=ds(l,u.width,u.height),y=oA(f,i.key,c,p),g=v1(y,e,p,u.width,u.height,t,o,a,r);if(!b1(l,g)){const v=uc(g,u.width,u.height);d(g,v),s&&s(g,v)}},this.onDocPointerDone=i=>{const{crop:p,disabled:e,onComplete:l,onDragEnd:n}=this.props,t=this.getBox();this.unbindDocMove(),!(e||!p)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,n&&n(i),l&&l(ds(p,t.width,t.height),uc(p,t.width,t.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))},this.onDragFocus=()=>{var i;(i=this.componentRef.current)==null||i.scrollTo(0,0)}}get document(){return document}getBox(){const i=this.mediaRef.current;if(!i)return{x:0,y:0,width:0,height:0};const{x:p,y:e,width:l,height:n}=i.getBoundingClientRect();return{x:p,y:e,width:l,height:n}}componentDidUpdate(i){const{crop:p,onComplete:e}=this.props;if(e&&!i.crop&&p){const{width:l,height:n}=this.getBox();l&&n&&e(ds(p,l,n),uc(p,l,n))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,dc),this.document.addEventListener("pointerup",this.onDocPointerDone,dc),this.document.addEventListener("pointercancel",this.onDocPointerDone,dc),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,dc),this.document.removeEventListener("pointerup",this.onDocPointerDone,dc),this.document.removeEventListener("pointercancel",this.onDocPointerDone,dc),this.docMoveBound=!1)}getCropStyle(){const{crop:i}=this.props;if(i)return{top:`${i.y}${i.unit}`,left:`${i.x}${i.unit}`,width:`${i.width}${i.unit}`,height:`${i.height}${i.unit}`}}dragCrop(){const{evData:i}=this,p=this.getBox(),e=this.makePixelCrop(p),l=i.clientX-i.startClientX,n=i.clientY-i.startClientY;return e.x=cc(i.startCropX+l,0,p.width-e.width),e.y=cc(i.startCropY+n,0,p.height-e.height),e}getPointRegion(i,p,e,l){const{evData:n}=this,t=n.clientX-i.x,o=n.clientY-i.y;let a;l&&p?a=p==="nw"||p==="n"||p==="ne":a=o<n.startCropY;let r;return e&&p?r=p==="nw"||p==="w"||p==="sw":r=t<n.startCropX,r?a?"nw":"sw":a?"ne":"se"}resolveMinDimensions(i,p,e=0,l=0){const n=Math.min(e,i.width),t=Math.min(l,i.height);return!p||!n&&!t?[n,t]:p>1?n?[n,n/p]:[t*p,t]:t?[t*p,t]:[n,n/p]}resizeCrop(){const{evData:i}=this,{aspect:p=0,maxWidth:e,maxHeight:l}=this.props,n=this.getBox(),[t,o]=this.resolveMinDimensions(n,p,this.props.minWidth,this.props.minHeight);let a=this.makePixelCrop(n);const r=this.getPointRegion(n,i.ord,t,o),d=i.ord||r;let s=i.clientX-i.startClientX,u=i.clientY-i.startClientY;(t&&d==="nw"||d==="w"||d==="sw")&&(s=Math.min(s,-t)),(o&&d==="nw"||d==="n"||d==="ne")&&(u=Math.min(u,-o));const c={unit:"px",x:0,y:0,width:0,height:0};r==="ne"?(c.x=i.startCropX,c.width=s,p?(c.height=c.width/p,c.y=i.startCropY-c.height):(c.height=Math.abs(u),c.y=i.startCropY-c.height)):r==="se"?(c.x=i.startCropX,c.y=i.startCropY,c.width=s,p?c.height=c.width/p:c.height=u):r==="sw"?(c.x=i.startCropX+s,c.y=i.startCropY,c.width=Math.abs(s),p?c.height=c.width/p:c.height=u):r==="nw"&&(c.x=i.startCropX+s,c.width=Math.abs(s),p?(c.height=c.width/p,c.y=i.startCropY-c.height):(c.height=Math.abs(u),c.y=i.startCropY+u));const f=v1(c,p,r,n.width,n.height,t,o,e,l);return p||Ji.xyOrds.indexOf(d)>-1?a=f:Ji.xOrds.indexOf(d)>-1?(a.x=f.x,a.width=f.width):Ji.yOrds.indexOf(d)>-1&&(a.y=f.y,a.height=f.height),a.x=cc(a.x,0,n.width-a.width),a.y=cc(a.y,0,n.height-a.height),a}renderCropSelection(){const{ariaLabels:i=Ji.defaultProps.ariaLabels,disabled:p,locked:e,renderSelectionAddon:l,ruleOfThirds:n,crop:t}=this.props,o=this.getCropStyle();if(t)return Oe.createElement("div",{style:o,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":i.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!p&&!e&&Oe.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},Oe.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),Oe.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),Oe.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),Oe.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":i.nwDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"nw"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":i.nDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"n"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":i.neDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"ne"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":i.eDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"e"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":i.seDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"se"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":i.sDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"s"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":i.swDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"sw"),role:"button"}),Oe.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":i.wDragHandle,onKeyDown:a=>this.onHandlerKeyDown(a,"w"),role:"button"})),l&&Oe.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:a=>a.stopPropagation()},l(this.state)),n&&Oe.createElement(Oe.Fragment,null,Oe.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),Oe.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(i){const p={...Lf,...this.props.crop||{}};return ds(p,i.width,i.height)}render(){const{aspect:i,children:p,circularCrop:e,className:l,crop:n,disabled:t,locked:o,style:a,ruleOfThirds:r}=this.props,{cropIsActive:d,newCropIsBeingDrawn:s}=this.state,u=n?this.renderCropSelection():null,c=rA("ReactCrop",l,d&&"ReactCrop--active",t&&"ReactCrop--disabled",o&&"ReactCrop--locked",s&&"ReactCrop--new-crop",n&&i&&"ReactCrop--fixed-aspect",n&&e&&"ReactCrop--circular-crop",n&&r&&"ReactCrop--rule-of-thirds",!this.dragStarted&&n&&!n.width&&!n.height&&"ReactCrop--invisible-crop",e&&"ReactCrop--no-animate");return Oe.createElement("div",{ref:this.componentRef,className:c,style:a},Oe.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},p),n?Oe.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},Oe.createElement("defs",null,Oe.createElement("mask",{id:`hole-${this.instanceId}`},Oe.createElement("rect",{width:"100%",height:"100%",fill:"white"}),e?Oe.createElement("ellipse",{cx:`${n.x+n.width/2}${n.unit}`,cy:`${n.y+n.height/2}${n.unit}`,rx:`${n.width/2}${n.unit}`,ry:`${n.height/2}${n.unit}`,fill:"black"}):Oe.createElement("rect",{x:`${n.x}${n.unit}`,y:`${n.y}${n.unit}`,width:`${n.width}${n.unit}`,height:`${n.height}${n.unit}`,fill:"black"}))),Oe.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,u)}};fs.xOrds=["e","w"],fs.yOrds=["n","s"],fs.xyOrds=["nw","ne","se","sw"],fs.nudgeStep=1,fs.nudgeStepMedium=10,fs.nudgeStepLarge=100,fs.defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};let aA=fs;const GA="",Tg=ki();function sA({altText:h,className:i,src:p,width:e,height:l,maxWidth:n,imageRef:t,startCrop:o,setStartCrop:a,isFocused:r,nodeKey:d}){const[s,u]=Oe.useState(null),[c,f]=Oe.useState(null),[y,g]=Oe.useState({unit:"px",x:25,y:25,width:50,height:50}),[v]=Xn(),_=()=>{if(s){const m=t.current;if(!m||!s)return;const w=m.naturalWidth/m.width,E=m.naturalHeight/m.height,N=new OffscreenCanvas(s.width*w,s.height*E),M=N.getContext("2d");if(!M)throw new Error("No 2D context available");M.drawImage(m,s.x*w,s.y*E,s.width*w,s.height*E,0,0,s.width*w,s.height*E),N.convertToBlob({type:"image/png"}).then(B=>{const P=URL.createObjectURL(B);f(P),a(!1);const R=new FileReader;R.onload=()=>{const j=R.result;v.update(()=>{const O=rr(d);fu(O)&&j&&O.setSrc(j)})},R.onerror=()=>{console.log("error")},R.readAsDataURL(B)})}},b=()=>{o||a(m=>{if(m===!1){const w=t.current;g({unit:"px",x:0,y:0,width:w.width,height:w.height})}return!m})},S=Oe.useRef(null),C=Oe.useRef(null);Oe.useEffect(()=>{s&&(S.current=s)},[s]);const x=m=>{C.current&&!C.current.contains(m.target)&&a(!1)};return Oe.useEffect(()=>(document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}),[]),Ne.jsxs("div",{ref:C,children:[r&&Ne.jsx("button",{style:{zIndex:999},className:"image-caption-button",onClick:()=>b(),children:"Crop"}),o&&Ne.jsx("button",{style:{zIndex:999},className:"image-caption-button",onClick:()=>_(),children:"Apply Crop"}),o?Ne.jsx(aA,{crop:y,onChange:m=>g(m),onComplete:m=>u(m),children:Ne.jsx("img",{className:i||void 0,src:c||p,alt:h,ref:t,style:{height:l,maxWidth:n,width:e},draggable:"false"})}):Ne.jsx("img",{className:i||void 0,src:c||p,alt:h,ref:t,style:{height:l,maxWidth:n,width:e},draggable:"false"})]})}function lA({src:h,altText:i,nodeKey:p,width:e,height:l,maxWidth:n,resizable:t,showCaption:o,caption:a}){const r=Oe.useRef(null),d=Oe.useRef(null),[s,u,c]=Nf(p),[f,y]=Oe.useState(!1),[g]=Xn(),[v,_]=Oe.useState(null),[b,S]=Oe.useState(!1),C=Oe.useRef(null),x=Oe.useCallback(O=>{if(s&&lr(jt())){O.preventDefault();const D=rr(p);if(fu(D))return D.remove(),!0}return!1},[s,p]),m=Oe.useCallback(O=>{const A=jt(),D=d.current;if(s&&lr(A)&&A.getNodes().length===1){if(o)return or(null),O.preventDefault(),a.focus(),!0;if(D!==null&&D!==document.activeElement)return O.preventDefault(),D.focus(),!0}return!1},[a,s,o]),w=Oe.useCallback(O=>C.current===a||d.current===O.target?(or(null),g.update(()=>{u(!0);const A=g.getRootElement();A!==null&&A.focus()}),!0):!1,[a,g,u]),E=Oe.useCallback(O=>{const A=O;return f?!0:A.target===r.current?(A.shiftKey?u(!s):(c(),u(!0)),!0):!1},[f,s,u,c]),N=Oe.useCallback(O=>{g.getEditorState().read(()=>{const A=jt();O.target.tagName==="IMG"&&Tt(A)&&A.getNodes().length===1&&g.dispatchCommand(Tg,O)})},[g]);Oe.useEffect(()=>{let O=!0;const A=g.getRootElement(),D=qr(g.registerUpdateListener(({editorState:L})=>{O&&_(L.read(()=>jt()))}),g.registerCommand(Uo,(L,J)=>(C.current=J,!1),Ln),g.registerCommand(Ua,E,Ln),g.registerCommand(Tg,E,Ln),g.registerCommand(Ms,L=>L.target===r.current?(L.preventDefault(),!0):!1,Ln),g.registerCommand(ma,x,Ln),g.registerCommand(Ai,x,Ln),g.registerCommand(Ki,m,Ln),g.registerCommand($a,w,Ln));return A==null||A.addEventListener("contextmenu",N),()=>{O=!1,D(),A==null||A.removeEventListener("contextmenu",N)}},[c,g,f,s,p,x,m,w,E,N,u]);const M=()=>{g.update(()=>{const O=rr(p);fu(O)&&O.setShowCaption(!0)})},B=(O,A)=>{setTimeout(()=>{y(!1)},200),g.update(()=>{const D=rr(p);console.log(D,"node"),fu(D)&&D.setWidthAndHeight(O,A)})},P=()=>{b||y(!0)},R=s&&lr(v)&&!f,j=s||f;return Ne.jsx(Oe.Suspense,{fallback:null,children:Ne.jsxs(Ne.Fragment,{children:[Ne.jsx("div",{draggable:R,children:Ne.jsx(sA,{className:j?`focused ${lr(v)?"draggable":""}`:null,src:h,altText:i,width:e,height:l,maxWidth:n,imageRef:r,startCrop:b,setStartCrop:S,isFocused:j,nodeKey:p})}),o&&Ne.jsx("div",{className:"image-caption-container",children:Ne.jsx(y1,{initialEditor:a,children:Ne.jsx(uf,{contentEditable:Ne.jsx(h1,{className:"ImageNode__contentEditable"}),placeholder:Ne.jsx(g1,{className:"ImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:vu})})}),!b&&t&&lr(v)&&j&&Ne.jsx(nA,{showCaption:o,setShowCaption:M,editor:g,buttonRef:d,maxWidth:n,onResizeStart:b?()=>{}:P,onResizeEnd:b?()=>{}:B,captionsEnabled:!1,imageRef:r})]})})}const cA=Object.freeze(Object.defineProperty({__proto__:null,RIGHT_CLICK_IMAGE_COMMAND:Tg,default:lA},Symbol.toStringTag,{value:"Module"})),_1=new Set;function uA(h){if(!_1.has(h))throw new Promise(i=>{const p=new Image;p.src=h,p.onload=()=>{_1.add(h),i(null)}})}function dA({altText:h,className:i,imageRef:p,src:e,width:l,height:n,position:t}){return uA(e),Ne.jsx("img",{className:i||void 0,src:e,alt:h,ref:p,"data-position":t,style:{display:"block",height:n,width:l},draggable:"false"})}function x1({activeEditor:h,nodeKey:i,onClose:p}){const l=h.getEditorState().read(()=>rr(i)),[n,t]=Oe.useState(l.getAltText()),[o,a]=Oe.useState(l.getShowCaption()),[r,d]=Oe.useState(l.getPosition()),s=f=>{a(f.target.checked)},u=f=>{d(f.target.value)},c=()=>{const f={altText:n,position:r,showCaption:o};l&&h.update(()=>{l.update(f)}),p()};return Ne.jsxs(Ne.Fragment,{children:[Ne.jsx("div",{style:{marginBottom:"1em"},children:Ne.jsx(G0,{label:"Alt Text",placeholder:"Descriptive alternative text",onChange:t,value:n,"data-test-id":"image-modal-alt-text-input"})}),Ne.jsxs(lS,{style:{marginBottom:"1em",width:"208px"},value:r,label:"Position",name:"position",id:"position-select",onChange:u,children:[Ne.jsx("option",{value:"left",children:"Left"}),Ne.jsx("option",{value:"right",children:"Right"}),Ne.jsx("option",{value:"full",children:"Full Width"})]}),Ne.jsxs("div",{className:"Input__wrapper",children:[Ne.jsx("input",{id:"caption",type:"checkbox",checked:o,onChange:s}),Ne.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),Ne.jsx(Y0,{children:Ne.jsx(Z0,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>c(),children:"Confirm"})})]})}function fA({src:h,altText:i,nodeKey:p,width:e,height:l,showCaption:n,caption:t,position:o}){const[a,r]=Lb(),d=Oe.useRef(null),s=Oe.useRef(null),[u,c,f]=Nf(p),[y]=Xn(),[g,v]=Oe.useState(null),_=Oe.useRef(null),b=Oe.useCallback(w=>{if(u&&lr(jt())){w.preventDefault();const N=rr(p);if(P0(N))return N.remove(),!0}return!1},[u,p]),S=Oe.useCallback(w=>{const E=jt(),N=s.current;if(u&&lr(E)&&E.getNodes().length===1){if(n)return or(null),w.preventDefault(),t.focus(),!0;if(N!==null&&N!==document.activeElement)return w.preventDefault(),N.focus(),!0}return!1},[t,u,n]),C=Oe.useCallback(w=>_.current===t||s.current===w.target?(or(null),y.update(()=>{c(!0);const E=y.getRootElement();E!==null&&E.focus()}),!0):!1,[t,y,c]);Oe.useEffect(()=>{let w=!0;const E=qr(y.registerUpdateListener(({editorState:N})=>{w&&v(N.read(()=>jt()))}),y.registerCommand(Uo,(N,M)=>(_.current=M,!1),Ln),y.registerCommand(Ua,N=>{const M=N;return M.target===d.current?(M.shiftKey?c(!u):(f(),c(!0)),!0):!1},Ln),y.registerCommand(Ms,N=>N.target===d.current?(N.preventDefault(),!0):!1,Ln),y.registerCommand(ma,b,Ln),y.registerCommand(Ai,b,Ln),y.registerCommand(Ki,S,Ln),y.registerCommand($a,C,Ln));return()=>{w=!1,E()}},[f,y,u,p,b,S,C,c]);const x=u&&lr(g),m=u;return Ne.jsxs(Oe.Suspense,{fallback:null,children:[Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs("div",{draggable:x,children:[Ne.jsx("button",{className:"image-edit-button",ref:s,onClick:()=>{r("Update Inline Image",w=>Ne.jsx(x1,{activeEditor:y,nodeKey:p,onClose:w}))},children:"Edit"}),Ne.jsx(dA,{className:m?`focused ${lr(g)?"draggable":""}`:null,src:h,altText:i,imageRef:d,width:e,height:l,position:o})]}),n&&Ne.jsx("div",{className:"image-caption-container",children:Ne.jsx(y1,{initialEditor:t,children:Ne.jsx(uf,{contentEditable:Ne.jsx(h1,{className:"InlineImageNode__contentEditable"}),placeholder:Ne.jsx(g1,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:vu})})})]}),a]})}const pA=Object.freeze(Object.defineProperty({__proto__:null,UpdateInlineImageDialog:x1,default:fA},Symbol.toStringTag,{value:"Module"}));To.Editor=ZT,To.EditorVariant2=XT,Object.defineProperty(To,Symbol.toStringTag,{value:"Module"})});
|
|
1508
1508
|
//# sourceMappingURL=index.umd.js.map
|